Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 1 | #include <map> |
| 2 | #include <string> |
| 3 | |
| 4 | // Not sure if this should live in utils. Because it's really a per-system |
| 5 | // configuration, instead of just hard-coding channel 1 to be eth0, one could |
| 6 | // conceivably configure it however they pleased. |
| 7 | // |
| 8 | // In this design, channel 0 is the in-band host channel. |
| 9 | |
| 10 | namespace ipmi |
| 11 | { |
| 12 | namespace network |
| 13 | { |
| 14 | |
| 15 | // This map should come from a configuration yaml. |
| 16 | // Also, no need to really be a map, could be just an array |
| 17 | // we index into by channel. :D |
| 18 | std::map<int, std::string> ethDeviceMap = { |
| 19 | {1, "eth0"}, |
| 20 | {2, "eth1"}, |
| 21 | }; |
| 22 | |
| 23 | |
| 24 | // Given a channel number, return a matching ethernet device, or empty string |
| 25 | // if there is no match. |
| 26 | // TODO provide this from a configuration: |
| 27 | // https://github.com/openbmc/openbmc/issues/2667 |
| 28 | std::string ChanneltoEthernet(int channel) |
| 29 | { |
| 30 | auto dev = ethDeviceMap.find(channel); |
| 31 | if (dev == ethDeviceMap.end()) |
| 32 | { |
| 33 | return ""; |
| 34 | } |
| 35 | |
| 36 | return dev->second; |
| 37 | } |
| 38 | |
| 39 | } // namespace network |
| 40 | } // namespace ipmi |
| 41 | |