blob: 67ad8c78f262b61de59da191c47c7fe952eff79e [file] [log] [blame]
Tom Joseph4a8f34d2016-12-06 17:07:46 +05301#include "channel_auth.hpp"
2
William A. Kennington III4f09eae2019-02-12 17:10:35 -08003#include <ipmid/api.h>
Tom Joseph4a8f34d2016-12-06 17:07:46 +05304
Richard Marian Thomaiyar716d1ef2019-03-11 20:08:57 +05305#include <user_channel/channel_layer.hpp>
6#include <user_channel/user_layer.hpp>
7
Tom Joseph4a8f34d2016-12-06 17:07:46 +05308namespace command
9{
10
Vernon Mauery9e801a22018-10-12 13:20:49 -070011std::vector<uint8_t>
12 GetChannelCapabilities(const std::vector<uint8_t>& inPayload,
13 const message::Handler& handler)
Tom Joseph4a8f34d2016-12-06 17:07:46 +053014{
Richard Marian Thomaiyar716d1ef2019-03-11 20:08:57 +053015 auto request =
16 reinterpret_cast<const GetChannelCapabilitiesReq*>(inPayload.data());
17 if (inPayload.size() != sizeof(*request))
18 {
19 std::vector<uint8_t> errorPayload{IPMI_CC_REQ_DATA_LEN_INVALID};
20 return errorPayload;
21 }
22 uint8_t chNum = ipmi::convertCurrentChannelNum(request->channelNumber);
23 if (!ipmi::isValidChannel(chNum) ||
24 (ipmi::EChannelSessSupported::none ==
25 ipmi::getChannelSessionSupport(chNum)) ||
26 !ipmi::isValidPrivLimit(request->reqMaxPrivLevel))
27 {
28 std::vector<uint8_t> errorPayload{IPMI_CC_INVALID_FIELD_REQUEST};
29 return errorPayload;
30 }
31
Tom Joseph4a8f34d2016-12-06 17:07:46 +053032 std::vector<uint8_t> outPayload(sizeof(GetChannelCapabilitiesResp));
Vernon Mauery9e801a22018-10-12 13:20:49 -070033 auto response =
34 reinterpret_cast<GetChannelCapabilitiesResp*>(outPayload.data());
Tom Joseph4a8f34d2016-12-06 17:07:46 +053035
36 // A canned response, since there is no user and channel management.
Vernon Mauery9e801a22018-10-12 13:20:49 -070037 response->completionCode = IPMI_CC_OK;
Tom Joseph4a8f34d2016-12-06 17:07:46 +053038
Richard Marian Thomaiyar716d1ef2019-03-11 20:08:57 +053039 response->channelNumber = chNum;
Tom Joseph4a8f34d2016-12-06 17:07:46 +053040
Vernon Mauery9e801a22018-10-12 13:20:49 -070041 response->ipmiVersion = 1; // IPMI v2.0 extended capabilities available.
Tom Joseph4a8f34d2016-12-06 17:07:46 +053042 response->reserved1 = 0;
43 response->oem = 0;
44 response->straightKey = 0;
45 response->reserved2 = 0;
46 response->md5 = 0;
47 response->md2 = 0;
48
Tom Joseph4a8f34d2016-12-06 17:07:46 +053049 response->reserved3 = 0;
Vernon Mauery9e801a22018-10-12 13:20:49 -070050 response->KGStatus = 0; // KG is set to default
51 response->perMessageAuth = 0; // Per-message Authentication is enabled
52 response->userAuth = 0; // User Level Authentication is enabled
Richard Marian Thomaiyar716d1ef2019-03-11 20:08:57 +053053 uint8_t maxChUsers = 0;
54 uint8_t enabledUsers = 0;
55 uint8_t fixedUsers = 0;
56 ipmi::ipmiUserGetAllCounts(maxChUsers, enabledUsers, fixedUsers);
57
58 response->nonNullUsers = enabledUsers > 0 ? 1 : 0; // Non-null usernames
Tom Joseph615e4fd2019-02-09 23:10:48 +053059 response->nullUsers = 0; // Null usernames disabled
Vernon Mauery9e801a22018-10-12 13:20:49 -070060 response->anonymousLogin = 0; // Anonymous Login disabled
Tom Joseph4a8f34d2016-12-06 17:07:46 +053061
62 response->reserved4 = 0;
Vernon Mauery9e801a22018-10-12 13:20:49 -070063 response->extCapabilities = 0x2; // Channel supports IPMI v2.0 connections
Tom Joseph4a8f34d2016-12-06 17:07:46 +053064
65 response->oemID[0] = 0;
66 response->oemID[1] = 0;
67 response->oemID[2] = 0;
68 response->oemAuxillary = 0;
Tom Joseph4a8f34d2016-12-06 17:07:46 +053069 return outPayload;
70}
71
72} // namespace command