blob: f719452a34e81b1cf3ab986a818b775f0c9728f2 [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 }
Vernon Mauery052b7cf2019-05-08 15:59:41 -070022 constexpr unsigned int channelMask = 0x0f;
23 uint8_t chNum = ipmi::convertCurrentChannelNum(
24 request->channelNumber & channelMask, getInterfaceIndex());
25
Richard Marian Thomaiyar716d1ef2019-03-11 20:08:57 +053026 if (!ipmi::isValidChannel(chNum) ||
27 (ipmi::EChannelSessSupported::none ==
28 ipmi::getChannelSessionSupport(chNum)) ||
29 !ipmi::isValidPrivLimit(request->reqMaxPrivLevel))
30 {
31 std::vector<uint8_t> errorPayload{IPMI_CC_INVALID_FIELD_REQUEST};
32 return errorPayload;
33 }
34
Tom Joseph4a8f34d2016-12-06 17:07:46 +053035 std::vector<uint8_t> outPayload(sizeof(GetChannelCapabilitiesResp));
Vernon Mauery9e801a22018-10-12 13:20:49 -070036 auto response =
37 reinterpret_cast<GetChannelCapabilitiesResp*>(outPayload.data());
Tom Joseph4a8f34d2016-12-06 17:07:46 +053038
39 // A canned response, since there is no user and channel management.
Vernon Mauery9e801a22018-10-12 13:20:49 -070040 response->completionCode = IPMI_CC_OK;
Tom Joseph4a8f34d2016-12-06 17:07:46 +053041
Richard Marian Thomaiyar716d1ef2019-03-11 20:08:57 +053042 response->channelNumber = chNum;
Tom Joseph4a8f34d2016-12-06 17:07:46 +053043
Vernon Mauery9e801a22018-10-12 13:20:49 -070044 response->ipmiVersion = 1; // IPMI v2.0 extended capabilities available.
Tom Joseph4a8f34d2016-12-06 17:07:46 +053045 response->reserved1 = 0;
46 response->oem = 0;
47 response->straightKey = 0;
48 response->reserved2 = 0;
49 response->md5 = 0;
50 response->md2 = 0;
51
Tom Joseph4a8f34d2016-12-06 17:07:46 +053052 response->reserved3 = 0;
Vernon Mauery9e801a22018-10-12 13:20:49 -070053 response->KGStatus = 0; // KG is set to default
54 response->perMessageAuth = 0; // Per-message Authentication is enabled
55 response->userAuth = 0; // User Level Authentication is enabled
Richard Marian Thomaiyar716d1ef2019-03-11 20:08:57 +053056 uint8_t maxChUsers = 0;
57 uint8_t enabledUsers = 0;
58 uint8_t fixedUsers = 0;
59 ipmi::ipmiUserGetAllCounts(maxChUsers, enabledUsers, fixedUsers);
60
61 response->nonNullUsers = enabledUsers > 0 ? 1 : 0; // Non-null usernames
Tom Joseph615e4fd2019-02-09 23:10:48 +053062 response->nullUsers = 0; // Null usernames disabled
Vernon Mauery9e801a22018-10-12 13:20:49 -070063 response->anonymousLogin = 0; // Anonymous Login disabled
Tom Joseph4a8f34d2016-12-06 17:07:46 +053064
65 response->reserved4 = 0;
Vernon Mauery9e801a22018-10-12 13:20:49 -070066 response->extCapabilities = 0x2; // Channel supports IPMI v2.0 connections
Tom Joseph4a8f34d2016-12-06 17:07:46 +053067
68 response->oemID[0] = 0;
69 response->oemID[1] = 0;
70 response->oemID[2] = 0;
71 response->oemAuxillary = 0;
Tom Joseph4a8f34d2016-12-06 17:07:46 +053072 return outPayload;
73}
74
75} // namespace command