Tom Joseph | 9b67219 | 2016-08-08 08:34:08 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <memory> |
| 4 | #include <vector> |
| 5 | |
| 6 | namespace message |
| 7 | { |
| 8 | |
| 9 | enum class PayloadType : uint8_t |
| 10 | { |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 11 | IPMI = 0x00, |
| 12 | SOL = 0x01, |
| 13 | OPEN_SESSION_REQUEST = 0x10, |
Tom Joseph | 9b67219 | 2016-08-08 08:34:08 -0500 | [diff] [blame] | 14 | OPEN_SESSION_RESPONSE = 0x11, |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 15 | RAKP1 = 0x12, |
| 16 | RAKP2 = 0x13, |
| 17 | RAKP3 = 0x14, |
| 18 | RAKP4 = 0x15, |
| 19 | INVALID = 0xFF, |
Tom Joseph | 9b67219 | 2016-08-08 08:34:08 -0500 | [diff] [blame] | 20 | }; |
| 21 | |
Tom Joseph | 3563f8f | 2017-05-08 15:42:54 +0530 | [diff] [blame] | 22 | /** |
| 23 | * @struct Message |
Tom Joseph | 9b67219 | 2016-08-08 08:34:08 -0500 | [diff] [blame] | 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 | |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 35 | Message() : |
| 36 | payloadType(PayloadType::INVALID), |
| 37 | rcSessionID(Message::MESSAGE_INVALID_SESSION_ID), |
| 38 | bmcSessionID(Message::MESSAGE_INVALID_SESSION_ID) |
| 39 | { |
| 40 | } |
Tom Joseph | 9b67219 | 2016-08-08 08:34:08 -0500 | [diff] [blame] | 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 | |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 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 |
Tom Joseph | 9b67219 | 2016-08-08 08:34:08 -0500 | [diff] [blame] | 54 | |
Tom Joseph | 3563f8f | 2017-05-08 15:42:54 +0530 | [diff] [blame] | 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. |
Tom Joseph | 9b67219 | 2016-08-08 08:34:08 -0500 | [diff] [blame] | 62 | */ |
| 63 | std::vector<uint8_t> payload; |
| 64 | }; |
| 65 | |
| 66 | namespace LAN |
| 67 | { |
| 68 | |
Tom Joseph | 63d3e49 | 2017-03-31 11:01:08 +0530 | [diff] [blame] | 69 | constexpr uint8_t requesterBMCAddress = 0x20; |
| 70 | constexpr uint8_t responderBMCAddress = 0x81; |
| 71 | |
Tom Joseph | 9b67219 | 2016-08-08 08:34:08 -0500 | [diff] [blame] | 72 | namespace header |
| 73 | { |
| 74 | |
Tom Joseph | 3563f8f | 2017-05-08 15:42:54 +0530 | [diff] [blame] | 75 | /** |
| 76 | * @struct IPMI LAN Message Request Header |
| 77 | */ |
Tom Joseph | 9b67219 | 2016-08-08 08:34:08 -0500 | [diff] [blame] | 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 | |
Tom Joseph | 3563f8f | 2017-05-08 15:42:54 +0530 | [diff] [blame] | 88 | /** |
| 89 | * @struct IPMI LAN Message Response Header |
| 90 | */ |
Tom Joseph | 9b67219 | 2016-08-08 08:34:08 -0500 | [diff] [blame] | 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 | |
Tom Joseph | 3563f8f | 2017-05-08 15:42:54 +0530 | [diff] [blame] | 106 | /** |
| 107 | * @struct IPMI LAN Message Trailer |
| 108 | */ |
Tom Joseph | 9b67219 | 2016-08-08 08:34:08 -0500 | [diff] [blame] | 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 |