1 #include "comm_module.hpp"
2 
3 #include "command/channel_auth.hpp"
4 #include "command/open_session.hpp"
5 #include "command/rakp12.hpp"
6 #include "command/rakp34.hpp"
7 #include "command/session_cmds.hpp"
8 #include "command_table.hpp"
9 #include "session.hpp"
10 
11 #include <algorithm>
12 #include <cstring>
13 #include <iomanip>
14 
15 namespace command
16 {
17 
18 void sessionSetupCommands()
19 {
20     static const command::CmdDetails commands[] = {
21         // Open Session Request/Response
22         {{(static_cast<uint32_t>(message::PayloadType::OPEN_SESSION_REQUEST)
23            << 16)},
24          &openSession,
25          session::Privilege::HIGHEST_MATCHING,
26          true},
27         // RAKP1 & RAKP2 Message
28         {{(static_cast<uint32_t>(message::PayloadType::RAKP1) << 16)},
29          &RAKP12,
30          session::Privilege::HIGHEST_MATCHING,
31          true},
32         // RAKP3 & RAKP4 Message
33         {{(static_cast<uint32_t>(message::PayloadType::RAKP3) << 16)},
34          &RAKP34,
35          session::Privilege::HIGHEST_MATCHING,
36          true},
37         // Get Channel Authentication Capabilities Command
38         {{(static_cast<uint32_t>(message::PayloadType::IPMI) << 16) |
39           static_cast<uint16_t>(command::NetFns::APP) | 0x38},
40          &GetChannelCapabilities,
41          session::Privilege::HIGHEST_MATCHING,
42          true},
43         // Get Channel Cipher Suites Command
44         {{(static_cast<uint32_t>(message::PayloadType::IPMI) << 16) |
45           static_cast<uint16_t>(::command::NetFns::APP) | 0x54},
46          &getChannelCipherSuites,
47          session::Privilege::HIGHEST_MATCHING,
48          true},
49         // Set Session Privilege Command
50         {{(static_cast<uint32_t>(message::PayloadType::IPMI) << 16) |
51           static_cast<uint16_t>(command::NetFns::APP) | 0x3B},
52          &setSessionPrivilegeLevel,
53          session::Privilege::USER,
54          false},
55         // Close Session Command
56         {{(static_cast<uint32_t>(message::PayloadType::IPMI) << 16) |
57           static_cast<uint16_t>(command::NetFns::APP) | 0x3C},
58          &closeSession,
59          session::Privilege::CALLBACK,
60          false},
61     };
62 
63     for (auto& iter : commands)
64     {
65         command::Table::get().registerCommand(
66             iter.command,
67             std::make_unique<command::NetIpmidEntry>(
68                 iter.command, iter.functor, iter.privilege, iter.sessionless));
69     }
70 }
71 
72 } // namespace command
73