blob: 17be41eb4d68cb1572bff747af8a4603d357df4c [file] [log] [blame]
Patrick Venturec7c1c3c2017-11-15 14:29:18 -08001#include <map>
2#include <string>
3
Patrick Venturec01edf22017-12-22 14:03:06 -08004#include "utils.hpp"
5
Patrick Venturec7c1c3c2017-11-15 14:29:18 -08006// 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
34