blob: 58960825fcbb528c3d3a6941c3f03dac0e7f1189 [file] [log] [blame]
Ratan Guptab8e99552017-07-27 07:07:48 +05301#pragma once
2
Vernon Mauery33250242019-03-12 16:49:26 -07003#include <ipmid/types.hpp>
Ratan Guptab8e99552017-07-27 07:07:48 +05304#include <string>
Adriana Kobylak5d6481f2015-10-29 21:44:55 -05005// IPMI commands for Transport net functions.
6enum 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
14enum ipmi_transport_return_codes
15{
16 IPMI_CC_PARM_NOT_SUPPORTED = 0x80,
17};
18
Adriana Kobylake08fbc62016-02-09 16:17:23 -060019// Parameters
William A. Kennington IIIaab20232018-11-19 18:20:39 -080020enum class LanParam : uint8_t
William A. Kennington III7a3479e2018-11-19 17:41:20 -080021{
William A. Kennington IIIaab20232018-11-19 18:20:39 -080022 INPROGRESS = 0,
Patrick Venturefc711152019-01-30 08:59:21 -080023 AUTHSUPPORT = 1, // Read-only
William A. Kennington IIIaab20232018-11-19 18:20:39 -080024 AUTHENABLES = 2,
25 IP = 3,
26 IPSRC = 4,
27 MAC = 5,
28 SUBNET = 6,
Patrick Venturefc711152019-01-30 08:59:21 -080029 IPHEADER_PARAMS = 7,
30 RMCP_PORT = 8,
31 RMCP_SECONDARY_PORT = 9,
32 BMC_GENERATED_ARP_CTRL = 10,
33 GRATUITOUS_ARP_INTERVAL = 11,
William A. Kennington IIIaab20232018-11-19 18:20:39 -080034 GATEWAY = 12,
Patrick Venturefc711152019-01-30 08:59:21 -080035 GATEWAY_MAC = 13,
36 GATEWAY_BACKUP = 14,
37 GATEWAY_BACKUP_MAC = 15,
38 COMMUNITY_STRING = 16,
39 LAN_ALERT_DESTINATION_COUNT = 17, // Read-only
40 LAN_ALERT_DESTINATION_TYPE = 18, // Type per destination
41 LAN_ALERT_DESTINATIONS = 19,
William A. Kennington IIIaab20232018-11-19 18:20:39 -080042 VLAN = 20,
Patrick Venturefc711152019-01-30 08:59:21 -080043 VLAN_PRIORITY = 21,
44 CIPHER_SUITE_COUNT = 22, // Read-only
45 CIPHER_SUITE_ENTRIES = 23, // Read-only
46 CIPHER_SUITE_PRIVILEGE_LEVELS = 24,
47 DESTINATION_ADDR_VLAN_TAGS = 25,
48 BAD_PASSWORD_THRESHOLD = 26,
49 IPV6_AND_IPV4_SUPPORTED = 50, // Read-only
50 IPV6_AND_IPV4_ENABLES = 51,
51 IPV6_HEADER_STATIC_TRAFFIC_CLASS = 52,
52 IPV6_HEADER_STATIC_HOP_LIMIT = 53,
53 IPV6_HEADER_FLOW_LABEL = 54,
54 IPV6_STATUS = 55, // Read-only
55 IPV6_STATIC_ADDRESSES = 56,
56 IPV6_DHCPV6_STATIC_DUID_STORAGE_LENGTH = 57, // Read-only
57 IPV6_DHCPV6_STATIC_DUIDS = 58,
58 IPV6_DYNAMIC_ADDRESSES = 59, // Read-only
59 IPV6_DHCPV6_DYNAMIC_DUID_STOR_LEN = 60, // Read-only
60 IPV6_DHCPV6_DYNAMIC_DUIDS = 61,
61 IPV6_DHCPV6_TIMING_CONF_SUPPORT = 62, // Read-only
62 IPV6_DHCPV6_TIMING_CONFIGURATION = 63,
63 IPV6_ROUTER_ADDRESS_CONF_CTRL = 64,
64 IPV6_STATIC_ROUTER_1_IP_ADDR = 65,
65 IPV6_STATIC_ROUTER_1_MAC_ADDR = 66,
66 IPV6_STATIC_ROUTER_1_PREFIX_LEN = 67,
67 IPV6_STATIC_ROUTER_1_PREFIX_VAL = 68,
68 IPV6_STATIC_ROUTER_2_IP_ADDR = 69,
69 IPV6_STATIC_ROUTER_2_MAC_ADDR = 70,
70 IPV6_STATIC_ROUTER_2_PREFIX_LEN = 71,
71 IPV6_STATIC_ROUTER_2_PREFIX_VAL = 72,
72 DYNAMIC_ROUTER_INFO_SET_COUNT = 73, // Read-only
73 IPV6_DYNAMIC_ROUTER_INFO_IP_ADDR = 74, // Read-only
74 IPV6_DYNAMIC_ROUTER_INFO_MAC = 75, // Read-only
75 IPV6_DYNAMIC_ROUTER_INFO_PREFIX_LEN = 76, // Read-only
76 IPV6_DYNAMIC_ROUTER_INFO_PREFIX_VAL = 77, // Read-only
77 IPV6_DYNAMIC_ROUTER_RECV_HOP_LIMIT = 78,
78 IPV6_NEIGHBOR_TIMING_CONF_SUPPORT = 79, // Read-only
79 IPV6_NEIGHBOR_TIMING_CONFIGURATION = 80,
William A. Kennington III7a3479e2018-11-19 17:41:20 -080080};
Adriana Kobylake08fbc62016-02-09 16:17:23 -060081
Suryakanth Sekar0a327e12019-08-08 14:30:19 +053082// Data length of parameters
83constexpr size_t lanParamVLANSize = 4;
Patrick Venture585a1e92017-11-17 07:36:15 -080084constexpr uint8_t SET_COMPLETE = 0;
85constexpr uint8_t SET_IN_PROGRESS = 1;
Patrick Venture0b02be92018-08-31 11:55:55 -070086constexpr uint8_t SET_COMMIT_WRITE = 2; // Optional
87constexpr uint8_t SET_IN_PROGRESS_RESERVED = 3; // Reserved
Patrick Venture585a1e92017-11-17 07:36:15 -080088
Patrick Venturec7c1c3c2017-11-15 14:29:18 -080089const int CHANNEL_MASK = 0x0f;
90const int NUM_CHANNELS = 0x0f;
91
Ratan Guptab8e99552017-07-27 07:07:48 +053092struct ChannelConfig_t
93{
94 std::string ipaddr;
Ratan Guptacc6cdbf2017-09-01 23:06:25 +053095 ipmi::network::IPOrigin ipsrc = ipmi::network::IPOrigin::UNSPECIFIED;
Ratan Guptab8e99552017-07-27 07:07:48 +053096 std::string netmask;
97 std::string gateway;
98 std::string macAddress;
Ratan Gupta533d03b2017-07-30 10:39:22 +053099 // IPMI stores the vlan info in 16 bits,32 bits is to aligned
100 // with phosphor-dbus interfaces.
101 // vlan id is in 12 bits and the 16th bit is for enable mask.
102 uint32_t vlanID = ipmi::network::VLAN_ID_MASK;
Patrick Venture585a1e92017-11-17 07:36:15 -0800103 uint8_t lan_set_in_progress = SET_COMPLETE;
Ratan Gupta7a7f0122018-03-07 12:31:05 +0530104 bool flush = false;
Ratan Gupta533d03b2017-07-30 10:39:22 +0530105
Ratan Guptab8e99552017-07-27 07:07:48 +0530106 void clear()
107 {
108 ipaddr.clear();
109 netmask.clear();
110 gateway.clear();
111 macAddress.clear();
Ratan Gupta533d03b2017-07-30 10:39:22 +0530112 vlanID = ipmi::network::VLAN_ID_MASK;
Ratan Guptacc6cdbf2017-09-01 23:06:25 +0530113 ipsrc = ipmi::network::IPOrigin::UNSPECIFIED;
Patrick Venture585a1e92017-11-17 07:36:15 -0800114 lan_set_in_progress = SET_COMPLETE;
Ratan Gupta7a7f0122018-03-07 12:31:05 +0530115 flush = false;
Ratan Guptab8e99552017-07-27 07:07:48 +0530116 }
Nan Li3d0df912016-10-18 19:51:41 +0800117};
Patrick Venturec7c1c3c2017-11-15 14:29:18 -0800118
119// Given a channel, get the corresponding configuration,
120// or allocate it first.
121//
122// @param[in] channel the channel
123// @return the ChannelConfig_t pointer.
124struct ChannelConfig_t* getChannelConfig(int channel);
Ratan Gupta7a7f0122018-03-07 12:31:05 +0530125
126/** @brief Iterate over all the channelconfig and if
127 * user has given the data for a channel then
128 * apply the network changes for that channel.
129 */
130void commitNetworkChanges();
131
132/* @brief Apply the network changes which is there in the
133 * network cache for a given channel which gets filled
134 * through setLan command. If some of the network
135 * parameter was not given by the setLan then this function
136 * gets the value of that parameter which is already
137 * configured on the system.
138 * @param[in] channel: channel number.
139 */
140void applyChanges(int channel);
Suryakanth Sekar0a327e12019-08-08 14:30:19 +0530141constexpr uint16_t maxValidVLANIDValue = 4095;