1 #include "channel_auth.hpp" 2 3 #include <ipmid/api.h> 4 5 #include <user_channel/channel_layer.hpp> 6 #include <user_channel/user_layer.hpp> 7 8 namespace command 9 { 10 11 std::vector<uint8_t> 12 GetChannelCapabilities(const std::vector<uint8_t>& inPayload, 13 std::shared_ptr<message::Handler>& handler) 14 { 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 constexpr unsigned int channelMask = 0x0f; 23 uint8_t chNum = ipmi::convertCurrentChannelNum( 24 request->channelNumber & channelMask, getInterfaceIndex()); 25 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 35 std::vector<uint8_t> outPayload(sizeof(GetChannelCapabilitiesResp)); 36 auto response = 37 reinterpret_cast<GetChannelCapabilitiesResp*>(outPayload.data()); 38 39 // A canned response, since there is no user and channel management. 40 response->completionCode = IPMI_CC_OK; 41 42 response->channelNumber = chNum; 43 44 response->ipmiVersion = 1; // IPMI v2.0 extended capabilities available. 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 52 response->reserved3 = 0; 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 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 62 response->nullUsers = 0; // Null usernames disabled 63 response->anonymousLogin = 0; // Anonymous Login disabled 64 65 response->reserved4 = 0; 66 response->extCapabilities = 0x2; // Channel supports IPMI v2.0 connections 67 68 response->oemID[0] = 0; 69 response->oemID[1] = 0; 70 response->oemID[2] = 0; 71 response->oemAuxillary = 0; 72 return outPayload; 73 } 74 75 } // namespace command 76