blob: a53727a37656923d60c32ea6be1c07cb7e23297a [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
22/*
23 * @ struct Message
24 *
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
53 /*
54 * “Payloads” are a capability specified for RMCP+ that enable an IPMI
55 * session to carry types of traffic that are in addition to IPMI Messages.
56 * Payloads can be ‘standard’ or ‘OEM’.Standard payload types include IPMI
57 * Messages, messages for session setup under RMCP+, and the payload for the
58 * “Serial Over LAN” capability introduced in IPMI v2.0.
59 */
60 std::vector<uint8_t> payload;
61};
62
63namespace LAN
64{
65
Tom Joseph63d3e492017-03-31 11:01:08 +053066constexpr uint8_t requesterBMCAddress = 0x20;
67constexpr uint8_t responderBMCAddress = 0x81;
68
Tom Joseph9b672192016-08-08 08:34:08 -050069namespace header
70{
71
72// IPMI LAN Message Request Header
73struct Request
74{
75 uint8_t rsaddr;
76 uint8_t netfn;
77 uint8_t cs;
78 uint8_t rqaddr;
79 uint8_t rqseq;
80 uint8_t cmd;
81} __attribute__((packed));
82
83// IPMI LAN Message Response Header
84struct Response
85{
86 uint8_t rqaddr;
87 uint8_t netfn;
88 uint8_t cs;
89 uint8_t rsaddr;
90 uint8_t rqseq;
91 uint8_t cmd;
92} __attribute__((packed));
93
94} // namespace header
95
96namespace trailer
97{
98
99// IPMI LAN Message Trailer
100struct Request
101{
102 uint8_t checksum;
103} __attribute__((packed));
104
105using Response = Request;
106
107} // namespace trailer
108
109} // namespace LAN
110
111} // namespace message
112