blob: e2eebc212330d3c5d7d709ad7110a8fb1011c569 [file] [log] [blame]
Tom Joseph8bb10b72016-12-06 17:47:56 +05301#pragma once
2
Tom Joseph8bb10b72016-12-06 17:47:56 +05303#include "comm_module.hpp"
Vernon Mauery9e801a22018-10-12 13:20:49 -07004#include "message_handler.hpp"
5
Andrew Geissler9d9b7632020-05-17 09:18:05 -05006#include <cstddef>
Vernon Mauery9e801a22018-10-12 13:20:49 -07007#include <vector>
Tom Joseph8bb10b72016-12-06 17:47:56 +05308
9namespace command
10{
11
Tom Joseph56527b92018-03-21 19:31:58 +053012constexpr size_t userNameMaxLen = 16;
13
Richard Marian Thomaiyar127748a2018-09-06 07:08:51 +053014constexpr uint8_t userNameOnlyLookupMask = 0x10;
15constexpr uint8_t userNameOnlyLookup = 0x10;
Richard Marian Thomaiyard91fd9d2018-12-06 12:03:50 +053016constexpr uint8_t userNamePrivLookup = 0x0;
Richard Marian Thomaiyar127748a2018-09-06 07:08:51 +053017
Tom Joseph3563f8f2017-05-08 15:42:54 +053018/**
Tom Joseph8bb10b72016-12-06 17:47:56 +053019 * @struct RAKP1request
20 *
21 * IPMI Payload for RAKP Message 1
22 */
23struct RAKP1request
24{
25 uint8_t messageTag;
26 uint8_t reserved1;
27 uint16_t reserved2;
28 uint32_t managedSystemSessionID;
29 uint8_t remote_console_random_number[16];
30 uint8_t req_max_privilege_level;
31 uint16_t reserved3;
32 uint8_t user_name_len;
Tom Joseph56527b92018-03-21 19:31:58 +053033 char user_name[userNameMaxLen];
Tom Joseph8bb10b72016-12-06 17:47:56 +053034} __attribute__((packed));
35
Tom Joseph3563f8f2017-05-08 15:42:54 +053036/**
Tom Joseph8bb10b72016-12-06 17:47:56 +053037 * @struct RAKP2response
38 *
39 * IPMI Payload for RAKP Message 2
40 */
41struct RAKP2response
42{
43 uint8_t messageTag;
44 uint8_t rmcpStatusCode;
45 uint16_t reserved;
46 uint32_t remoteConsoleSessionID;
47 uint8_t managed_system_random_number[16];
48 uint8_t managed_system_guid[16];
49} __attribute__((packed));
50
Tom Joseph3563f8f2017-05-08 15:42:54 +053051/**
Tom Joseph8bb10b72016-12-06 17:47:56 +053052 * @brief RAKP Message 1, RAKP Message 2
53 *
54 * These messages are used to exchange random number and identification
55 * information between the BMC and the remote console that are, in effect,
56 * mutual challenges for a challenge/response. (Unlike IPMI v1.5, the v2.0/RMCP+
57 * challenge/response is symmetric. I.e. the remote console and BMC both issues
58 * challenges,and both need to provide valid responses for the session to be
59 * activated.)
60 *
61 * The remote console request (RAKP Message 1) passes a random number and
62 * username/privilege information that the BMC will later use to ‘sign’ a
63 * response message based on key information associated with the user and the
64 * Authentication Algorithm negotiated in the Open Session Request/Response
65 * exchange. The BMC responds with RAKP Message 2 and passes a random number and
66 * GUID (globally unique ID) for the managed system that the remote console
67 * uses according the Authentication Algorithm to sign a response back to the
68 * BMC.
69 *
70 * @param[in] inPayload - Request Data for the command
71 * @param[in] handler - Reference to the Message Handler
72 *
73 * @return Response data for the command
74 */
Tom Joseph18a45e92017-04-11 11:30:44 +053075std::vector<uint8_t> RAKP12(const std::vector<uint8_t>& inPayload,
Vernon Mauery41ff9b52021-06-11 11:37:40 -070076 std::shared_ptr<message::Handler>& handler);
sunitakx0e0546f2021-06-15 08:57:10 +000077/**
78 *@brief Log Redfish event for invalid login attempted on RMCPP interface
79 *
80 * @param[in] journalMsg - Show journal Debug Message in journal logs
81 * @param[in] redfishMsg - Log Redfish Event Message
82 *
83 */
84void logInvalidLoginRedfishEvent(
85 const std::string& journalMsg,
86 const std::optional<std::string>& messageArgs = "RMCPP");
Tom Joseph8bb10b72016-12-06 17:47:56 +053087} // namespace command