1 #pragma once 2 3 #include "types.hpp" 4 #include <string> 5 // IPMI commands for Transport net functions. 6 enum ipmi_netfn_storage_cmds 7 { 8 // Get capability bits 9 IPMI_CMD_SET_LAN = 0x01, 10 IPMI_CMD_GET_LAN = 0x02, 11 }; 12 13 // Command specific completion codes 14 enum ipmi_transport_return_codes 15 { 16 IPMI_CC_PARM_NOT_SUPPORTED = 0x80, 17 }; 18 19 // Parameters 20 static const int LAN_PARM_INPROGRESS = 0; 21 static const int LAN_PARM_AUTHSUPPORT = 1; 22 static const int LAN_PARM_AUTHENABLES = 2; 23 static const int LAN_PARM_IP = 3; 24 static const int LAN_PARM_IPSRC = 4; 25 static const int LAN_PARM_MAC = 5; 26 static const int LAN_PARM_SUBNET = 6; 27 static const int LAN_PARM_GATEWAY = 12; 28 static const int LAN_PARM_VLAN = 20; 29 30 constexpr uint8_t SET_COMPLETE = 0; 31 constexpr uint8_t SET_IN_PROGRESS = 1; 32 constexpr uint8_t SET_COMMIT_WRITE = 2; //Optional 33 constexpr uint8_t SET_IN_PROGRESS_RESERVED = 3; //Reserved 34 35 const int CHANNEL_MASK = 0x0f; 36 const int NUM_CHANNELS = 0x0f; 37 38 struct ChannelConfig_t 39 { 40 std::string ipaddr; 41 ipmi::network::IPOrigin ipsrc = ipmi::network::IPOrigin::UNSPECIFIED; 42 std::string netmask; 43 std::string gateway; 44 std::string macAddress; 45 // IPMI stores the vlan info in 16 bits,32 bits is to aligned 46 // with phosphor-dbus interfaces. 47 // vlan id is in 12 bits and the 16th bit is for enable mask. 48 uint32_t vlanID = ipmi::network::VLAN_ID_MASK; 49 uint8_t lan_set_in_progress = SET_COMPLETE; 50 51 void clear() 52 { 53 ipaddr.clear(); 54 netmask.clear(); 55 gateway.clear(); 56 macAddress.clear(); 57 vlanID = ipmi::network::VLAN_ID_MASK; 58 ipsrc = ipmi::network::IPOrigin::UNSPECIFIED; 59 lan_set_in_progress = SET_COMPLETE; 60 } 61 }; 62 63 // Given a channel, get the corresponding configuration, 64 // or allocate it first. 65 // 66 // @param[in] channel the channel 67 // @return the ChannelConfig_t pointer. 68 struct ChannelConfig_t* getChannelConfig(int channel); 69