1 #pragma once
2 
3 #include <vector>
4 
5 #include "message_handler.hpp"
6 
7 namespace command
8 {
9 
10 /*
11  * @ struct GetChannelCapabilitiesReq
12  *
13  * IPMI Request data for Get Channel Authentication Capabilities command
14  */
15 struct GetChannelCapabilitiesReq
16 {
17     uint8_t channelNumber;
18     uint8_t reqMaxPrivLevel;
19 } __attribute__((packed));
20 
21 /*
22  * @ struct GetChannelCapabilitiesResp
23  *
24  * IPMI Response data for Get Channel Authentication Capabilities command
25  */
26 struct GetChannelCapabilitiesResp
27 {
28     uint8_t completionCode;     // Completion Code
29 
30     uint8_t channelNumber;      // Channel number that the request was
31     // received on
32 
33 #if BYTE_ORDER == LITTLE_ENDIAN
34     uint8_t none : 1;
35     uint8_t md2 : 1;
36     uint8_t md5 : 1;
37     uint8_t reserved2 : 1;
38     uint8_t straightKey : 1;   // Straight password/key support
39     // Support OEM identified by the IANA OEM ID in RMCP+ ping response
40     uint8_t oem : 1;
41     uint8_t reserved1 : 1;
42     uint8_t ipmiVersion : 1;    // 0b = IPMIV1.5 support only, 1B = IPMI V2.0
43     // support
44 #endif
45 
46 #if BYTE_ORDER == BIG_ENDIAN
47     uint8_t ipmiVersion : 1;    // 0b = IPMIV1.5 support only, 1B = IPMI V2.0
48     // support
49     uint8_t reserved1 : 1;
50     // Support OEM identified by the IANA OEM ID in RMCP+ ping response
51     uint8_t oem : 1;
52     uint8_t straightKey : 1;   // Straight password/key support
53     uint8_t reserved2 : 1;
54     uint8_t md5 : 1;
55     uint8_t md2 : 1;
56     uint8_t none : 1;
57 #endif
58 
59 #if BYTE_ORDER == LITTLE_ENDIAN
60     // Two key login status . only for IPMI V2.0 RMCP+ RAKP
61     uint8_t KGStatus : 1;
62     uint8_t perMessageAuth : 1; // Per-message authentication support
63     uint8_t userAuth : 1;       // User - level authentication status
64     // Anonymous login status for non_null usernames enabled/disabled
65     uint8_t nonNullUsers : 1;
66     // Anonymous login status for null user names enabled/disabled
67     uint8_t nullUsers : 1;
68     // Anonymous login status for anonymous login enabled/disabled
69     uint8_t anonymousLogin : 1;
70     uint8_t reserved3 : 2;
71 #endif
72 
73 #if BYTE_ORDER == BIG_ENDIAN
74     uint8_t reserved3 : 2;
75     // Anonymous login status for anonymous login enabled/disabled
76     uint8_t anonymousLogin : 1;
77     // Anonymous login status for null user names enabled/disabled
78     uint8_t nullUsers : 1;
79     // Anonymous login status for non_null usernames enabled/disabled
80     uint8_t nonNullUsers : 1;
81     uint8_t userAuth : 1;       // User - level authentication status
82     uint8_t perMessageAuth : 1; // Per-message authentication support
83     // Two key login status . only for IPMI V2.0 RMCP+ RAKP
84     uint8_t KGStatus : 1;
85 #endif
86 
87 #if BYTE_ORDER == LITTLE_ENDIAN
88     // Extended capabilities will be present only if IPMI version is V2.0
89     uint8_t extCapabilities : 2; // Channel support for IPMI V2.0 connections
90     uint8_t reserved4 : 6;
91 #endif
92 
93 #if BYTE_ORDER == BIG_ENDIAN
94     // Extended capabilities will be present only if IPMI version is V2.0
95     uint8_t reserved4 : 6;
96     uint8_t extCapabilities : 2; // Channel support for IPMI V2.0 connections
97 #endif
98 
99     // Below 4 bytes will all the 0's if no OEM authentication type available.
100     uint8_t oemID[3];  // IANA enterprise number for OEM/organization
101     uint8_t oemAuxillary;  // Addition OEM specific information..
102 } __attribute__((packed));
103 
104 /*
105  * @brief Get Channel Authentication Capabilities
106  *
107  * This message exchange provides a way for a remote console to discover what
108  * IPMI version is supported i.e. whether or not the BMC supports the IPMI
109  * v2.0 / RMCP+ packet format. It also provides information that the remote
110  * console can use to determine whether anonymous, “one-key”, or “two-key”
111  * logins are used.This information can guide a remote console in how it
112  * presents queries to users for username and password information. This is a
113  * ‘session-less’ command that the BMC accepts in both IPMI v1.5 and v2.0/RMCP+
114  * packet formats.
115  *
116  * @param[in] inPayload - Request Data for the command
117  * @param[in] handler - Reference to the Message Handler
118  *
119  * @return Response data for the command
120  */
121 std::vector<uint8_t> GetChannelCapabilities(std::vector<uint8_t>& inPayload,
122                                             const message::Handler& handler);
123 
124 } // namespace command
125