blob: db46c0677952c4bb9000e022ed3c7fb6f79354db [file] [log] [blame]
Tom Joseph9b672192016-08-08 08:34:08 -05001#pragma once
2
3#include <memory>
4#include <vector>
5
6namespace message
7{
8
9enum class PayloadType : uint8_t
10{
Vernon Mauery9e801a22018-10-12 13:20:49 -070011 IPMI = 0x00,
12 SOL = 0x01,
13 OPEN_SESSION_REQUEST = 0x10,
Tom Joseph9b672192016-08-08 08:34:08 -050014 OPEN_SESSION_RESPONSE = 0x11,
Vernon Mauery9e801a22018-10-12 13:20:49 -070015 RAKP1 = 0x12,
16 RAKP2 = 0x13,
17 RAKP3 = 0x14,
18 RAKP4 = 0x15,
19 INVALID = 0xFF,
Tom Joseph9b672192016-08-08 08:34:08 -050020};
21
Tom Joseph3563f8f2017-05-08 15:42:54 +053022/**
23 * @struct Message
Tom Joseph9b672192016-08-08 08:34:08 -050024 *
25 * IPMI message is data encapsulated in an IPMI Session packet. The IPMI
26 * Session packets are encapsulated in RMCP packets, which are encapsulated in
27 * UDP datagrams. Refer Section 13.5 of IPMI specification(IPMI Messages
28 * Encapsulation Under RMCP). IPMI payload is a special class of data
29 * encapsulated in an IPMI session packet.
30 */
31struct Message
32{
33 static constexpr uint32_t MESSAGE_INVALID_SESSION_ID = 0xBADBADFF;
34
Vernon Mauery9e801a22018-10-12 13:20:49 -070035 Message() :
36 payloadType(PayloadType::INVALID),
37 rcSessionID(Message::MESSAGE_INVALID_SESSION_ID),
38 bmcSessionID(Message::MESSAGE_INVALID_SESSION_ID)
39 {
40 }
Tom Joseph9b672192016-08-08 08:34:08 -050041
42 ~Message() = default;
43 Message(const Message&) = default;
44 Message& operator=(const Message&) = default;
45 Message(Message&&) = default;
46 Message& operator=(Message&&) = default;
47
Vernon Mauery9e801a22018-10-12 13:20:49 -070048 bool isPacketEncrypted; // Message's Encryption Status
49 bool isPacketAuthenticated; // Message's Authentication Status
50 PayloadType payloadType; // Type of message payload (IPMI,SOL ..etc)
51 uint32_t rcSessionID; // Remote Client's Session ID
52 uint32_t bmcSessionID; // BMC's session ID
53 uint32_t sessionSeqNum; // Session Sequence Number
Tom Joseph9b672192016-08-08 08:34:08 -050054
Tom Joseph3563f8f2017-05-08 15:42:54 +053055 /** @brief Message payload
56 *
57 * “Payloads” are a capability specified for RMCP+ that enable an IPMI
58 * session to carry types of traffic that are in addition to IPMI Messages.
59 * Payloads can be ‘standard’ or ‘OEM’.Standard payload types include IPMI
60 * Messages, messages for session setup under RMCP+, and the payload for
61 * the “Serial Over LAN” capability introduced in IPMI v2.0.
Tom Joseph9b672192016-08-08 08:34:08 -050062 */
63 std::vector<uint8_t> payload;
64};
65
66namespace LAN
67{
68
Tom Joseph63d3e492017-03-31 11:01:08 +053069constexpr uint8_t requesterBMCAddress = 0x20;
70constexpr uint8_t responderBMCAddress = 0x81;
71
Tom Joseph9b672192016-08-08 08:34:08 -050072namespace header
73{
74
Tom Joseph3563f8f2017-05-08 15:42:54 +053075/**
76 * @struct IPMI LAN Message Request Header
77 */
Tom Joseph9b672192016-08-08 08:34:08 -050078struct Request
79{
80 uint8_t rsaddr;
81 uint8_t netfn;
82 uint8_t cs;
83 uint8_t rqaddr;
84 uint8_t rqseq;
85 uint8_t cmd;
86} __attribute__((packed));
87
Tom Joseph3563f8f2017-05-08 15:42:54 +053088/**
89 * @struct IPMI LAN Message Response Header
90 */
Tom Joseph9b672192016-08-08 08:34:08 -050091struct Response
92{
93 uint8_t rqaddr;
94 uint8_t netfn;
95 uint8_t cs;
96 uint8_t rsaddr;
97 uint8_t rqseq;
98 uint8_t cmd;
99} __attribute__((packed));
100
101} // namespace header
102
103namespace trailer
104{
105
Tom Joseph3563f8f2017-05-08 15:42:54 +0530106/**
107 * @struct IPMI LAN Message Trailer
108 */
Tom Joseph9b672192016-08-08 08:34:08 -0500109struct Request
110{
111 uint8_t checksum;
112} __attribute__((packed));
113
114using Response = Request;
115
116} // namespace trailer
117
118} // namespace LAN
119
120} // namespace message