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 | { |
| 11 | IPMI = 0x00, |
Tom Joseph | f7f984f | 2017-03-31 10:08:48 +0530 | [diff] [blame] | 12 | SOL = 0x01, |
Tom Joseph | 9b67219 | 2016-08-08 08:34:08 -0500 | [diff] [blame] | 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 | ~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 | |
| 63 | namespace LAN |
| 64 | { |
| 65 | |
| 66 | namespace header |
| 67 | { |
| 68 | |
| 69 | // IPMI LAN Message Request Header |
| 70 | struct Request |
| 71 | { |
| 72 | uint8_t rsaddr; |
| 73 | uint8_t netfn; |
| 74 | uint8_t cs; |
| 75 | uint8_t rqaddr; |
| 76 | uint8_t rqseq; |
| 77 | uint8_t cmd; |
| 78 | } __attribute__((packed)); |
| 79 | |
| 80 | // IPMI LAN Message Response Header |
| 81 | struct Response |
| 82 | { |
| 83 | uint8_t rqaddr; |
| 84 | uint8_t netfn; |
| 85 | uint8_t cs; |
| 86 | uint8_t rsaddr; |
| 87 | uint8_t rqseq; |
| 88 | uint8_t cmd; |
| 89 | } __attribute__((packed)); |
| 90 | |
| 91 | } // namespace header |
| 92 | |
| 93 | namespace trailer |
| 94 | { |
| 95 | |
| 96 | // IPMI LAN Message Trailer |
| 97 | struct Request |
| 98 | { |
| 99 | uint8_t checksum; |
| 100 | } __attribute__((packed)); |
| 101 | |
| 102 | using Response = Request; |
| 103 | |
| 104 | } // namespace trailer |
| 105 | |
| 106 | } // namespace LAN |
| 107 | |
| 108 | } // namespace message |
| 109 | |