Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 3 | #include "types.hpp" |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 4 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 5 | #include <string> |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 6 | // IPMI commands for Transport net functions. |
| 7 | enum ipmi_netfn_storage_cmds |
| 8 | { |
| 9 | // Get capability bits |
| 10 | IPMI_CMD_SET_LAN = 0x01, |
| 11 | IPMI_CMD_GET_LAN = 0x02, |
| 12 | }; |
| 13 | |
| 14 | // Command specific completion codes |
| 15 | enum ipmi_transport_return_codes |
| 16 | { |
| 17 | IPMI_CC_PARM_NOT_SUPPORTED = 0x80, |
| 18 | }; |
| 19 | |
Adriana Kobylak | e08fbc6 | 2016-02-09 16:17:23 -0600 | [diff] [blame] | 20 | // Parameters |
William A. Kennington III | aab2023 | 2018-11-19 18:20:39 -0800 | [diff] [blame] | 21 | enum class LanParam : uint8_t |
William A. Kennington III | 7a3479e | 2018-11-19 17:41:20 -0800 | [diff] [blame] | 22 | { |
William A. Kennington III | aab2023 | 2018-11-19 18:20:39 -0800 | [diff] [blame] | 23 | INPROGRESS = 0, |
Patrick Venture | fc71115 | 2019-01-30 08:59:21 -0800 | [diff] [blame] | 24 | AUTHSUPPORT = 1, // Read-only |
William A. Kennington III | aab2023 | 2018-11-19 18:20:39 -0800 | [diff] [blame] | 25 | AUTHENABLES = 2, |
| 26 | IP = 3, |
| 27 | IPSRC = 4, |
| 28 | MAC = 5, |
| 29 | SUBNET = 6, |
Patrick Venture | fc71115 | 2019-01-30 08:59:21 -0800 | [diff] [blame] | 30 | IPHEADER_PARAMS = 7, |
| 31 | RMCP_PORT = 8, |
| 32 | RMCP_SECONDARY_PORT = 9, |
| 33 | BMC_GENERATED_ARP_CTRL = 10, |
| 34 | GRATUITOUS_ARP_INTERVAL = 11, |
William A. Kennington III | aab2023 | 2018-11-19 18:20:39 -0800 | [diff] [blame] | 35 | GATEWAY = 12, |
Patrick Venture | fc71115 | 2019-01-30 08:59:21 -0800 | [diff] [blame] | 36 | GATEWAY_MAC = 13, |
| 37 | GATEWAY_BACKUP = 14, |
| 38 | GATEWAY_BACKUP_MAC = 15, |
| 39 | COMMUNITY_STRING = 16, |
| 40 | LAN_ALERT_DESTINATION_COUNT = 17, // Read-only |
| 41 | LAN_ALERT_DESTINATION_TYPE = 18, // Type per destination |
| 42 | LAN_ALERT_DESTINATIONS = 19, |
William A. Kennington III | aab2023 | 2018-11-19 18:20:39 -0800 | [diff] [blame] | 43 | VLAN = 20, |
Patrick Venture | fc71115 | 2019-01-30 08:59:21 -0800 | [diff] [blame] | 44 | VLAN_PRIORITY = 21, |
| 45 | CIPHER_SUITE_COUNT = 22, // Read-only |
| 46 | CIPHER_SUITE_ENTRIES = 23, // Read-only |
| 47 | CIPHER_SUITE_PRIVILEGE_LEVELS = 24, |
| 48 | DESTINATION_ADDR_VLAN_TAGS = 25, |
| 49 | BAD_PASSWORD_THRESHOLD = 26, |
| 50 | IPV6_AND_IPV4_SUPPORTED = 50, // Read-only |
| 51 | IPV6_AND_IPV4_ENABLES = 51, |
| 52 | IPV6_HEADER_STATIC_TRAFFIC_CLASS = 52, |
| 53 | IPV6_HEADER_STATIC_HOP_LIMIT = 53, |
| 54 | IPV6_HEADER_FLOW_LABEL = 54, |
| 55 | IPV6_STATUS = 55, // Read-only |
| 56 | IPV6_STATIC_ADDRESSES = 56, |
| 57 | IPV6_DHCPV6_STATIC_DUID_STORAGE_LENGTH = 57, // Read-only |
| 58 | IPV6_DHCPV6_STATIC_DUIDS = 58, |
| 59 | IPV6_DYNAMIC_ADDRESSES = 59, // Read-only |
| 60 | IPV6_DHCPV6_DYNAMIC_DUID_STOR_LEN = 60, // Read-only |
| 61 | IPV6_DHCPV6_DYNAMIC_DUIDS = 61, |
| 62 | IPV6_DHCPV6_TIMING_CONF_SUPPORT = 62, // Read-only |
| 63 | IPV6_DHCPV6_TIMING_CONFIGURATION = 63, |
| 64 | IPV6_ROUTER_ADDRESS_CONF_CTRL = 64, |
| 65 | IPV6_STATIC_ROUTER_1_IP_ADDR = 65, |
| 66 | IPV6_STATIC_ROUTER_1_MAC_ADDR = 66, |
| 67 | IPV6_STATIC_ROUTER_1_PREFIX_LEN = 67, |
| 68 | IPV6_STATIC_ROUTER_1_PREFIX_VAL = 68, |
| 69 | IPV6_STATIC_ROUTER_2_IP_ADDR = 69, |
| 70 | IPV6_STATIC_ROUTER_2_MAC_ADDR = 70, |
| 71 | IPV6_STATIC_ROUTER_2_PREFIX_LEN = 71, |
| 72 | IPV6_STATIC_ROUTER_2_PREFIX_VAL = 72, |
| 73 | DYNAMIC_ROUTER_INFO_SET_COUNT = 73, // Read-only |
| 74 | IPV6_DYNAMIC_ROUTER_INFO_IP_ADDR = 74, // Read-only |
| 75 | IPV6_DYNAMIC_ROUTER_INFO_MAC = 75, // Read-only |
| 76 | IPV6_DYNAMIC_ROUTER_INFO_PREFIX_LEN = 76, // Read-only |
| 77 | IPV6_DYNAMIC_ROUTER_INFO_PREFIX_VAL = 77, // Read-only |
| 78 | IPV6_DYNAMIC_ROUTER_RECV_HOP_LIMIT = 78, |
| 79 | IPV6_NEIGHBOR_TIMING_CONF_SUPPORT = 79, // Read-only |
| 80 | IPV6_NEIGHBOR_TIMING_CONFIGURATION = 80, |
William A. Kennington III | 7a3479e | 2018-11-19 17:41:20 -0800 | [diff] [blame] | 81 | }; |
Adriana Kobylak | e08fbc6 | 2016-02-09 16:17:23 -0600 | [diff] [blame] | 82 | |
Patrick Venture | 585a1e9 | 2017-11-17 07:36:15 -0800 | [diff] [blame] | 83 | constexpr uint8_t SET_COMPLETE = 0; |
| 84 | constexpr uint8_t SET_IN_PROGRESS = 1; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 85 | constexpr uint8_t SET_COMMIT_WRITE = 2; // Optional |
| 86 | constexpr uint8_t SET_IN_PROGRESS_RESERVED = 3; // Reserved |
Patrick Venture | 585a1e9 | 2017-11-17 07:36:15 -0800 | [diff] [blame] | 87 | |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 88 | const int CHANNEL_MASK = 0x0f; |
| 89 | const int NUM_CHANNELS = 0x0f; |
| 90 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 91 | struct ChannelConfig_t |
| 92 | { |
| 93 | std::string ipaddr; |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 94 | ipmi::network::IPOrigin ipsrc = ipmi::network::IPOrigin::UNSPECIFIED; |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 95 | std::string netmask; |
| 96 | std::string gateway; |
| 97 | std::string macAddress; |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 98 | // IPMI stores the vlan info in 16 bits,32 bits is to aligned |
| 99 | // with phosphor-dbus interfaces. |
| 100 | // vlan id is in 12 bits and the 16th bit is for enable mask. |
| 101 | uint32_t vlanID = ipmi::network::VLAN_ID_MASK; |
Patrick Venture | 585a1e9 | 2017-11-17 07:36:15 -0800 | [diff] [blame] | 102 | uint8_t lan_set_in_progress = SET_COMPLETE; |
Ratan Gupta | 7a7f012 | 2018-03-07 12:31:05 +0530 | [diff] [blame] | 103 | bool flush = false; |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 104 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 105 | void clear() |
| 106 | { |
| 107 | ipaddr.clear(); |
| 108 | netmask.clear(); |
| 109 | gateway.clear(); |
| 110 | macAddress.clear(); |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 111 | vlanID = ipmi::network::VLAN_ID_MASK; |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 112 | ipsrc = ipmi::network::IPOrigin::UNSPECIFIED; |
Patrick Venture | 585a1e9 | 2017-11-17 07:36:15 -0800 | [diff] [blame] | 113 | lan_set_in_progress = SET_COMPLETE; |
Ratan Gupta | 7a7f012 | 2018-03-07 12:31:05 +0530 | [diff] [blame] | 114 | flush = false; |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 115 | } |
Nan Li | 3d0df91 | 2016-10-18 19:51:41 +0800 | [diff] [blame] | 116 | }; |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 117 | |
| 118 | // Given a channel, get the corresponding configuration, |
| 119 | // or allocate it first. |
| 120 | // |
| 121 | // @param[in] channel the channel |
| 122 | // @return the ChannelConfig_t pointer. |
| 123 | struct ChannelConfig_t* getChannelConfig(int channel); |
Ratan Gupta | 7a7f012 | 2018-03-07 12:31:05 +0530 | [diff] [blame] | 124 | |
| 125 | /** @brief Iterate over all the channelconfig and if |
| 126 | * user has given the data for a channel then |
| 127 | * apply the network changes for that channel. |
| 128 | */ |
| 129 | void commitNetworkChanges(); |
| 130 | |
| 131 | /* @brief Apply the network changes which is there in the |
| 132 | * network cache for a given channel which gets filled |
| 133 | * through setLan command. If some of the network |
| 134 | * parameter was not given by the setLan then this function |
| 135 | * gets the value of that parameter which is already |
| 136 | * configured on the system. |
| 137 | * @param[in] channel: channel number. |
| 138 | */ |
| 139 | void applyChanges(int channel); |