1 #include "pldm_base_cmd.hpp" 2 #include "pldm_bios_cmd.hpp" 3 #include "pldm_cmd_helper.hpp" 4 #include "pldm_fru_cmd.hpp" 5 #include "pldm_fw_update_cmd.hpp" 6 #include "pldm_platform_cmd.hpp" 7 #include "pldmtool/oem/ibm/pldm_oem_ibm.hpp" 8 9 #include <CLI/CLI.hpp> 10 11 namespace pldmtool 12 { 13 14 namespace raw 15 { 16 17 using namespace pldmtool::helper; 18 19 namespace 20 { 21 std::vector<std::unique_ptr<CommandInterface>> commands; 22 } 23 24 class RawOp : public CommandInterface 25 { 26 public: 27 ~RawOp() = default; 28 RawOp() = delete; 29 RawOp(const RawOp&) = delete; 30 RawOp(RawOp&&) = default; 31 RawOp& operator=(const RawOp&) = delete; 32 RawOp& operator=(RawOp&&) = default; 33 34 explicit RawOp(const char* type, const char* name, CLI::App* app) : 35 CommandInterface(type, name, app) 36 { 37 app->add_option("-d,--data", rawData, "raw data") 38 ->required() 39 ->expected(-3); 40 } 41 std::pair<int, std::vector<uint8_t>> createRequestMsg() override 42 43 { 44 return {PLDM_SUCCESS, rawData}; 45 } 46 47 void parseResponseMsg(pldm_msg* /* responsePtr */, 48 size_t /* payloadLength */) override 49 {} 50 51 private: 52 std::vector<uint8_t> rawData; 53 }; 54 55 void registerCommand(CLI::App& app) 56 { 57 auto raw = 58 app.add_subcommand("raw", "send a raw request and print response"); 59 commands.push_back(std::make_unique<RawOp>("raw", "raw", raw)); 60 } 61 62 } // namespace raw 63 } // namespace pldmtool 64 65 int main(int argc, char** argv) 66 { 67 CLI::App app{"PLDM requester tool for OpenBMC"}; 68 app.require_subcommand(1)->ignore_case(); 69 70 pldmtool::raw::registerCommand(app); 71 pldmtool::base::registerCommand(app); 72 pldmtool::bios::registerCommand(app); 73 pldmtool::platform::registerCommand(app); 74 pldmtool::fru::registerCommand(app); 75 pldmtool::fw_update::registerCommand(app); 76 77 #ifdef OEM_IBM 78 pldmtool::oem_ibm::registerCommand(app); 79 #endif 80 81 CLI11_PARSE(app, argc, argv); 82 return 0; 83 } 84