1 #pragma once 2 3 #include <memory> 4 #include <vector> 5 6 namespace message 7 { 8 9 enum class PayloadType : uint8_t 10 { 11 IPMI = 0x00, 12 SOL = 0x01, 13 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 */ 31 struct 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 } 41 42 ~Message() = default; 43 Message(const Message&) = default; 44 Message& operator=(const Message&) = default; 45 Message(Message&&) = default; 46 Message& operator=(Message&&) = default; 47 48 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 54 55 /** @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. 62 */ 63 std::vector<uint8_t> payload; 64 }; 65 66 namespace LAN 67 { 68 69 constexpr uint8_t requesterBMCAddress = 0x20; 70 constexpr uint8_t responderBMCAddress = 0x81; 71 72 namespace header 73 { 74 75 /** 76 * @struct IPMI LAN Message Request Header 77 */ 78 struct 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 88 /** 89 * @struct IPMI LAN Message Response Header 90 */ 91 struct 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 103 namespace trailer 104 { 105 106 /** 107 * @struct IPMI LAN Message Trailer 108 */ 109 struct Request 110 { 111 uint8_t checksum; 112 } __attribute__((packed)); 113 114 using Response = Request; 115 116 } // namespace trailer 117 118 } // namespace LAN 119 120 } // namespace message 121