Tom Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 1 | #include "channel_auth.hpp" |
| 2 | |
William A. Kennington III | 4f09eae | 2019-02-12 17:10:35 -0800 | [diff] [blame] | 3 | #include <ipmid/api.h> |
Tom Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 4 | |
Richard Marian Thomaiyar | 716d1ef | 2019-03-11 20:08:57 +0530 | [diff] [blame] | 5 | #include <user_channel/channel_layer.hpp> |
| 6 | #include <user_channel/user_layer.hpp> |
| 7 | |
Tom Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 8 | namespace command |
| 9 | { |
| 10 | |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 11 | std::vector<uint8_t> |
| 12 | GetChannelCapabilities(const std::vector<uint8_t>& inPayload, |
| 13 | const message::Handler& handler) |
Tom Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 14 | { |
Richard Marian Thomaiyar | 716d1ef | 2019-03-11 20:08:57 +0530 | [diff] [blame] | 15 | 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 Mauery | 052b7cf | 2019-05-08 15:59:41 -0700 | [diff] [blame] | 22 | constexpr unsigned int channelMask = 0x0f; |
| 23 | uint8_t chNum = ipmi::convertCurrentChannelNum( |
| 24 | request->channelNumber & channelMask, getInterfaceIndex()); |
| 25 | |
Richard Marian Thomaiyar | 716d1ef | 2019-03-11 20:08:57 +0530 | [diff] [blame] | 26 | 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 Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 35 | std::vector<uint8_t> outPayload(sizeof(GetChannelCapabilitiesResp)); |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 36 | auto response = |
| 37 | reinterpret_cast<GetChannelCapabilitiesResp*>(outPayload.data()); |
Tom Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 38 | |
| 39 | // A canned response, since there is no user and channel management. |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 40 | response->completionCode = IPMI_CC_OK; |
Tom Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 41 | |
Richard Marian Thomaiyar | 716d1ef | 2019-03-11 20:08:57 +0530 | [diff] [blame] | 42 | response->channelNumber = chNum; |
Tom Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 43 | |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 44 | response->ipmiVersion = 1; // IPMI v2.0 extended capabilities available. |
Tom Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 45 | 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 Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 52 | response->reserved3 = 0; |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 53 | 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 Thomaiyar | 716d1ef | 2019-03-11 20:08:57 +0530 | [diff] [blame] | 56 | 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 Joseph | 615e4fd | 2019-02-09 23:10:48 +0530 | [diff] [blame] | 62 | response->nullUsers = 0; // Null usernames disabled |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 63 | response->anonymousLogin = 0; // Anonymous Login disabled |
Tom Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 64 | |
| 65 | response->reserved4 = 0; |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 66 | response->extCapabilities = 0x2; // Channel supports IPMI v2.0 connections |
Tom Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 67 | |
| 68 | response->oemID[0] = 0; |
| 69 | response->oemID[1] = 0; |
| 70 | response->oemID[2] = 0; |
| 71 | response->oemAuxillary = 0; |
Tom Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 72 | return outPayload; |
| 73 | } |
| 74 | |
| 75 | } // namespace command |