multiple channel configuration support

Previously, the ipmi daemon only supported eth0 and hard-coded it
to channel 1.  This allows one to map via a configuration.  The
channel number provided is checked against a configuration to retrieve
the ethernet device identifier, e.g. eth0.

Tested: Ran on a quanta-q71l and was able to properly set MAC, IP,
Netmask, Gateway IP, and then verified the data was set for the eth1
via `ip addr show eth1`.

Change-Id: I92f63188297304e9454fd0d6fe32bc6cf84bb181
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/net.cpp b/net.cpp
new file mode 100644
index 0000000..6c492a2
--- /dev/null
+++ b/net.cpp
@@ -0,0 +1,41 @@
+#include <map>
+#include <string>
+
+// Not sure if this should live in utils.  Because it's really a per-system
+// configuration, instead of just hard-coding channel 1 to be eth0, one could
+// conceivably configure it however they pleased.
+//
+// In this design, channel 0 is the in-band host channel.
+
+namespace ipmi
+{
+namespace network
+{
+
+// This map should come from a configuration yaml.
+// Also, no need to really be a map, could be just an array
+// we index into by channel. :D
+std::map<int, std::string> ethDeviceMap = {
+    {1, "eth0"},
+    {2, "eth1"},
+};
+
+
+// Given a channel number, return a matching ethernet device, or empty string
+// if there is no match.
+// TODO provide this from a configuration:
+// https://github.com/openbmc/openbmc/issues/2667
+std::string ChanneltoEthernet(int channel)
+{
+    auto dev = ethDeviceMap.find(channel);
+    if (dev == ethDeviceMap.end())
+    {
+        return "";
+    }
+
+    return dev->second;
+}
+
+} // namespace network
+} // namespace ipmi
+