1 #include "ipmid.hpp"
2 #include "nlohmann/json.hpp"
3 
4 /** @brief The set channel access IPMI command.
5  *
6  *  @param[in] netfn
7  *  @param[in] cmd
8  *  @param[in] request
9  *  @param[in,out] response
10  *  @param[out] data_len
11  *  @param[in] context
12  *
13  *  @return IPMI_CC_OK on success, non-zero otherwise.
14  */
15 ipmi_ret_t ipmi_set_channel_access(
16         ipmi_netfn_t netfn,
17         ipmi_cmd_t cmd,
18         ipmi_request_t request,
19         ipmi_response_t response,
20         ipmi_data_len_t data_len,
21         ipmi_context_t context);
22 
23 /** @brief The get channel access IPMI command.
24  *
25  *  @param[in] netfn
26  *  @param[in] cmd
27  *  @param[in] request
28  *  @param[in,out] response
29  *  @param[out] data_len
30  *  @param[in] context
31  *
32  *  @return IPMI_CC_OK on success, non-zero otherwise.
33  */
34 ipmi_ret_t ipmi_get_channel_access(
35         ipmi_netfn_t netfn,
36         ipmi_cmd_t cmd,
37         ipmi_request_t request,
38         ipmi_response_t response,
39         ipmi_data_len_t data_len,
40         ipmi_context_t context);
41 
42 /** @brief The get channel info IPMI command.
43  *
44  *  @param[in] netfn
45  *  @param[in] cmd
46  *  @param[in] request
47  *  @param[in,out] response
48  *  @param[out] data_len
49  *  @param[in] context
50  *
51  *  @return IPMI_CC_OK on success, non-zero otherwise.
52  */
53 ipmi_ret_t ipmi_app_channel_info(
54         ipmi_netfn_t netfn,
55         ipmi_cmd_t cmd,
56         ipmi_request_t request,
57         ipmi_response_t response,
58         ipmi_data_len_t data_len,
59         ipmi_context_t context);
60 
61 /** @brief Implementation of get channel cipher suites command
62  *
63  *  @param[in] netfn - Net Function
64  *  @param[in] cmd - Command
65  *  @param[in] request - Request pointer
66  *  @param[in,out] response - Response pointer
67  *  @param[in,out] data_len - Data Length
68  *  @param[in] context - Context
69  *
70  *  @return IPMI_CC_OK on success, non-zero otherwise.
71  */
72 ipmi_ret_t getChannelCipherSuites(ipmi_netfn_t netfn,
73                                   ipmi_cmd_t cmd,
74                                   ipmi_request_t request,
75                                   ipmi_response_t response,
76                                   ipmi_data_len_t data_len,
77                                   ipmi_context_t context);
78 
79 namespace cipher
80 {
81 
82 static constexpr auto defaultChannelNumber = 1;
83 static constexpr auto listTypeMask = 0x80;
84 static constexpr auto listCipherSuite = 0x80;
85 static constexpr auto listIndexMask = 0x3F;
86 static constexpr auto respSize = 16;
87 
88 using Json = nlohmann::json;
89 static constexpr auto configFile =
90     "/usr/share/ipmi-providers/cipher_list.json";
91 static constexpr auto cipher = "cipher";
92 static constexpr auto stdCipherSuite = 0xC0;
93 static constexpr auto oemCipherSuite = 0xC1;
94 static constexpr auto oem = "oemiana";
95 static constexpr auto auth = "authentication";
96 static constexpr auto integrity = "integrity";
97 static constexpr auto integrityTag = 0x40;
98 static constexpr auto conf = "confidentiality";
99 static constexpr auto confTag = 0x80;
100 
101 } //namespace cipher
102 
103 /** @struct GetChannelCipherRequest
104  *
105  *  IPMI payload for Get Channel Cipher Suites command request
106  */
107 struct GetChannelCipherRequest
108 {
109     uint8_t channelNumber;      //!< Channel Number
110     uint8_t payloadType;        //!< Payload type number
111     uint8_t listIndex;          //!< List Index
112 } __attribute__((packed));
113 
114 /** @struct GetChannelCipherRespHeader
115  *
116  *  IPMI payload for Get Channel Cipher Suites command response header
117  */
118 struct GetChannelCipherRespHeader
119 {
120     uint8_t channelNumber;      //!< Channel Number
121 } __attribute__((packed));
122 
123 
124