Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 1 | #include <map> |
| 2 | #include <string> |
| 3 | |
Patrick Venture | c01edf2 | 2017-12-22 14:03:06 -0800 | [diff] [blame] | 4 | #include "utils.hpp" |
| 5 | |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 6 | // Not sure if this should live in utils. Because it's really a per-system |
| 7 | // configuration, instead of just hard-coding channel 1 to be eth0, one could |
| 8 | // conceivably configure it however they pleased. |
| 9 | // |
| 10 | // In this design, channel 0 is the in-band host channel. |
| 11 | |
| 12 | namespace ipmi |
| 13 | { |
| 14 | namespace network |
| 15 | { |
| 16 | |
Patrick Venture | c01edf2 | 2017-12-22 14:03:06 -0800 | [diff] [blame] | 17 | extern const ipmi::network::ChannelEthMap ethdevices; |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 18 | |
| 19 | // Given a channel number, return a matching ethernet device, or empty string |
| 20 | // if there is no match. |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 21 | std::string ChanneltoEthernet(int channel) |
| 22 | { |
Patrick Venture | c01edf2 | 2017-12-22 14:03:06 -0800 | [diff] [blame] | 23 | auto dev = ethdevices.find(channel); |
| 24 | if (dev == ethdevices.end()) |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 25 | { |
| 26 | return ""; |
| 27 | } |
| 28 | |
| 29 | return dev->second; |
| 30 | } |
| 31 | |
| 32 | } // namespace network |
| 33 | } // namespace ipmi |
| 34 | |