blob: 6c492a2e3094c1b94ebe48b561f2d78696aa3e77 [file] [log] [blame]
Patrick Venturec7c1c3c2017-11-15 14:29:18 -08001#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
10namespace ipmi
11{
12namespace 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
18std::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
28std::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