blob: 59aa6e6000a10c4a9980b9c33d93574f97359c91 [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{
11 IPMI = 0x00,
Tom Josephf7f984f2017-03-31 10:08:48 +053012 SOL = 0x01,
Tom Joseph9b672192016-08-08 08:34:08 -050013 OPEN_SESSION_REQUEST = 0x10,
14 OPEN_SESSION_RESPONSE = 0x11,
15 RAKP1 = 0x12,
16 RAKP2 = 0x13,
17 RAKP3 = 0x14,
18 RAKP4 = 0x15,
19 INVALID = 0xFF,
20};
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
35 Message()
36 : payloadType(PayloadType::INVALID),
37 rcSessionID(Message::MESSAGE_INVALID_SESSION_ID),
38 bmcSessionID(Message::MESSAGE_INVALID_SESSION_ID) {}
39
40 ~Message() = default;
41 Message(const Message&) = default;
42 Message& operator=(const Message&) = default;
43 Message(Message&&) = default;
44 Message& operator=(Message&&) = default;
45
46 bool isPacketEncrypted; // Message's Encryption Status
47 bool isPacketAuthenticated; // Message's Authentication Status
48 PayloadType payloadType; // Type of message payload (IPMI,SOL ..etc)
49 uint32_t rcSessionID; // Remote Client's Session ID
50 uint32_t bmcSessionID; // BMC's session ID
51 uint32_t sessionSeqNum; // Session Sequence Number
52
Tom Joseph3563f8f2017-05-08 15:42:54 +053053 /** @brief Message payload
54 *
55 * “Payloads” are a capability specified for RMCP+ that enable an IPMI
56 * session to carry types of traffic that are in addition to IPMI Messages.
57 * Payloads can be ‘standard’ or ‘OEM’.Standard payload types include IPMI
58 * Messages, messages for session setup under RMCP+, and the payload for
59 * the “Serial Over LAN” capability introduced in IPMI v2.0.
Tom Joseph9b672192016-08-08 08:34:08 -050060 */
61 std::vector<uint8_t> payload;
62};
63
64namespace LAN
65{
66
Tom Joseph63d3e492017-03-31 11:01:08 +053067constexpr uint8_t requesterBMCAddress = 0x20;
68constexpr uint8_t responderBMCAddress = 0x81;
69
Tom Joseph9b672192016-08-08 08:34:08 -050070namespace header
71{
72
Tom Joseph3563f8f2017-05-08 15:42:54 +053073/**
74 * @struct IPMI LAN Message Request Header
75 */
Tom Joseph9b672192016-08-08 08:34:08 -050076struct Request
77{
78 uint8_t rsaddr;
79 uint8_t netfn;
80 uint8_t cs;
81 uint8_t rqaddr;
82 uint8_t rqseq;
83 uint8_t cmd;
84} __attribute__((packed));
85
Tom Joseph3563f8f2017-05-08 15:42:54 +053086/**
87 * @struct IPMI LAN Message Response Header
88 */
Tom Joseph9b672192016-08-08 08:34:08 -050089struct Response
90{
91 uint8_t rqaddr;
92 uint8_t netfn;
93 uint8_t cs;
94 uint8_t rsaddr;
95 uint8_t rqseq;
96 uint8_t cmd;
97} __attribute__((packed));
98
99} // namespace header
100
101namespace trailer
102{
103
Tom Joseph3563f8f2017-05-08 15:42:54 +0530104/**
105 * @struct IPMI LAN Message Trailer
106 */
Tom Joseph9b672192016-08-08 08:34:08 -0500107struct Request
108{
109 uint8_t checksum;
110} __attribute__((packed));
111
112using Response = Request;
113
114} // namespace trailer
115
116} // namespace LAN
117
118} // namespace message
119