blob: 9de190f2b36c42a9c3739a3020aa51f0fb420c5a [file] [log] [blame]
Patrick Venture0b02be92018-08-31 11:55:55 -07001#include "utils.hpp"
2
Patrick Venturec7c1c3c2017-11-15 14:29:18 -08003#include <map>
4#include <string>
5
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
12namespace ipmi
13{
14namespace network
15{
16
Patrick Venturec01edf22017-12-22 14:03:06 -080017extern const ipmi::network::ChannelEthMap ethdevices;
Patrick Venturec7c1c3c2017-11-15 14:29:18 -080018
19// Given a channel number, return a matching ethernet device, or empty string
20// if there is no match.
Patrick Venturec7c1c3c2017-11-15 14:29:18 -080021std::string ChanneltoEthernet(int channel)
22{
Patrick Venturec01edf22017-12-22 14:03:06 -080023 auto dev = ethdevices.find(channel);
24 if (dev == ethdevices.end())
Patrick Venturec7c1c3c2017-11-15 14:29:18 -080025 {
26 return "";
27 }
28
29 return dev->second;
30}
31
32} // namespace network
33} // namespace ipmi