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 | } |
| 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 Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 32 | std::vector<uint8_t> outPayload(sizeof(GetChannelCapabilitiesResp)); |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 33 | auto response = |
| 34 | reinterpret_cast<GetChannelCapabilitiesResp*>(outPayload.data()); |
Tom Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 35 | |
| 36 | // A canned response, since there is no user and channel management. |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 37 | response->completionCode = IPMI_CC_OK; |
Tom Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 38 | |
Richard Marian Thomaiyar | 716d1ef | 2019-03-11 20:08:57 +0530 | [diff] [blame^] | 39 | response->channelNumber = chNum; |
Tom Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 40 | |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 41 | response->ipmiVersion = 1; // IPMI v2.0 extended capabilities available. |
Tom Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 42 | 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 Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 49 | response->reserved3 = 0; |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 50 | 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 Thomaiyar | 716d1ef | 2019-03-11 20:08:57 +0530 | [diff] [blame^] | 53 | 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 Joseph | 615e4fd | 2019-02-09 23:10:48 +0530 | [diff] [blame] | 59 | response->nullUsers = 0; // Null usernames disabled |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 60 | response->anonymousLogin = 0; // Anonymous Login disabled |
Tom Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 61 | |
| 62 | response->reserved4 = 0; |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 63 | response->extCapabilities = 0x2; // Channel supports IPMI v2.0 connections |
Tom Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 64 | |
| 65 | response->oemID[0] = 0; |
| 66 | response->oemID[1] = 0; |
| 67 | response->oemID[2] = 0; |
| 68 | response->oemAuxillary = 0; |
Tom Joseph | 4a8f34d | 2016-12-06 17:07:46 +0530 | [diff] [blame] | 69 | return outPayload; |
| 70 | } |
| 71 | |
| 72 | } // namespace command |