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, |
| 12 | OPEN_SESSION_REQUEST = 0x10, |
| 13 | OPEN_SESSION_RESPONSE = 0x11, |
| 14 | RAKP1 = 0x12, |
| 15 | RAKP2 = 0x13, |
| 16 | RAKP3 = 0x14, |
| 17 | RAKP4 = 0x15, |
| 18 | INVALID = 0xFF, |
| 19 | }; |
| 20 | |
| 21 | /* |
| 22 | * @ struct Message |
| 23 | * |
| 24 | * IPMI message is data encapsulated in an IPMI Session packet. The IPMI |
| 25 | * Session packets are encapsulated in RMCP packets, which are encapsulated in |
| 26 | * UDP datagrams. Refer Section 13.5 of IPMI specification(IPMI Messages |
| 27 | * Encapsulation Under RMCP). IPMI payload is a special class of data |
| 28 | * encapsulated in an IPMI session packet. |
| 29 | */ |
| 30 | struct Message |
| 31 | { |
| 32 | static constexpr uint32_t MESSAGE_INVALID_SESSION_ID = 0xBADBADFF; |
| 33 | |
| 34 | Message() |
| 35 | : payloadType(PayloadType::INVALID), |
| 36 | rcSessionID(Message::MESSAGE_INVALID_SESSION_ID), |
| 37 | bmcSessionID(Message::MESSAGE_INVALID_SESSION_ID) {} |
| 38 | |
| 39 | ~Message() = default; |
| 40 | Message(const Message&) = default; |
| 41 | Message& operator=(const Message&) = default; |
| 42 | Message(Message&&) = default; |
| 43 | Message& operator=(Message&&) = default; |
| 44 | |
| 45 | bool isPacketEncrypted; // Message's Encryption Status |
| 46 | bool isPacketAuthenticated; // Message's Authentication Status |
| 47 | PayloadType payloadType; // Type of message payload (IPMI,SOL ..etc) |
| 48 | uint32_t rcSessionID; // Remote Client's Session ID |
| 49 | uint32_t bmcSessionID; // BMC's session ID |
| 50 | uint32_t sessionSeqNum; // Session Sequence Number |
| 51 | |
| 52 | /* |
| 53 | * “Payloads” are a capability specified for RMCP+ that enable an IPMI |
| 54 | * session to carry types of traffic that are in addition to IPMI Messages. |
| 55 | * Payloads can be ‘standard’ or ‘OEM’.Standard payload types include IPMI |
| 56 | * Messages, messages for session setup under RMCP+, and the payload for the |
| 57 | * “Serial Over LAN” capability introduced in IPMI v2.0. |
| 58 | */ |
| 59 | std::vector<uint8_t> payload; |
| 60 | }; |
| 61 | |
| 62 | namespace LAN |
| 63 | { |
| 64 | |
| 65 | namespace header |
| 66 | { |
| 67 | |
| 68 | // IPMI LAN Message Request Header |
| 69 | struct Request |
| 70 | { |
| 71 | uint8_t rsaddr; |
| 72 | uint8_t netfn; |
| 73 | uint8_t cs; |
| 74 | uint8_t rqaddr; |
| 75 | uint8_t rqseq; |
| 76 | uint8_t cmd; |
| 77 | } __attribute__((packed)); |
| 78 | |
| 79 | // IPMI LAN Message Response Header |
| 80 | struct Response |
| 81 | { |
| 82 | uint8_t rqaddr; |
| 83 | uint8_t netfn; |
| 84 | uint8_t cs; |
| 85 | uint8_t rsaddr; |
| 86 | uint8_t rqseq; |
| 87 | uint8_t cmd; |
| 88 | } __attribute__((packed)); |
| 89 | |
| 90 | } // namespace header |
| 91 | |
| 92 | namespace trailer |
| 93 | { |
| 94 | |
| 95 | // IPMI LAN Message Trailer |
| 96 | struct Request |
| 97 | { |
| 98 | uint8_t checksum; |
| 99 | } __attribute__((packed)); |
| 100 | |
| 101 | using Response = Request; |
| 102 | |
| 103 | } // namespace trailer |
| 104 | |
| 105 | } // namespace LAN |
| 106 | |
| 107 | } // namespace message |
| 108 | |