John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 1 | #include "pldm_base_cmd.hpp" |
Sridevi Ramesh | 9857643 | 2019-11-27 10:10:28 -0600 | [diff] [blame] | 2 | #include "pldm_bios_cmd.hpp" |
John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 3 | #include "pldm_cmd_helper.hpp" |
Sridevi Ramesh | d448975 | 2019-12-08 09:03:29 -0600 | [diff] [blame] | 4 | #include "pldm_fru_cmd.hpp" |
George Liu | d664936 | 2019-11-27 19:06:51 +0800 | [diff] [blame] | 5 | #include "pldm_platform_cmd.hpp" |
George Liu | 4407335 | 2020-03-12 14:00:13 +0800 | [diff] [blame] | 6 | #include "tool/oem/ibm/pldm_host_cmd.hpp" |
Lakshminarayana R. Kammath | 27693a4 | 2019-06-24 00:51:47 -0500 | [diff] [blame] | 7 | |
| 8 | #include <CLI/CLI.hpp> |
| 9 | |
John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 10 | namespace pldmtool |
| 11 | { |
| 12 | |
| 13 | namespace raw |
| 14 | { |
| 15 | |
| 16 | using namespace pldmtool::helper; |
| 17 | |
| 18 | namespace |
| 19 | { |
| 20 | std::vector<std::unique_ptr<CommandInterface>> commands; |
| 21 | } |
| 22 | |
| 23 | class RawOp : public CommandInterface |
| 24 | { |
| 25 | public: |
| 26 | ~RawOp() = default; |
| 27 | RawOp() = delete; |
| 28 | RawOp(const RawOp&) = delete; |
| 29 | RawOp(RawOp&&) = default; |
| 30 | RawOp& operator=(const RawOp&) = delete; |
| 31 | RawOp& operator=(RawOp&&) = default; |
| 32 | |
| 33 | explicit RawOp(const char* type, const char* name, CLI::App* app) : |
| 34 | CommandInterface(type, name, app) |
| 35 | { |
| 36 | app->add_option("-d,--data", rawData, "raw data") |
| 37 | ->required() |
| 38 | ->expected(-3); |
| 39 | } |
| 40 | std::pair<int, std::vector<uint8_t>> createRequestMsg() override |
| 41 | |
| 42 | { |
| 43 | return {PLDM_SUCCESS, rawData}; |
| 44 | } |
| 45 | |
| 46 | void parseResponseMsg(pldm_msg* /* responsePtr */, |
| 47 | size_t /* payloadLength */) override |
| 48 | { |
| 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 | |
Lakshminarayana R. Kammath | 27693a4 | 2019-06-24 00:51:47 -0500 | [diff] [blame] | 65 | int main(int argc, char** argv) |
| 66 | { |
| 67 | |
| 68 | CLI::App app{"PLDM requester tool for OpenBMC"}; |
John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 69 | app.require_subcommand(1)->ignore_case(); |
Lakshminarayana R. Kammath | 27693a4 | 2019-06-24 00:51:47 -0500 | [diff] [blame] | 70 | |
John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 71 | pldmtool::raw::registerCommand(app); |
| 72 | pldmtool::base::registerCommand(app); |
Sridevi Ramesh | 9857643 | 2019-11-27 10:10:28 -0600 | [diff] [blame] | 73 | pldmtool::bios::registerCommand(app); |
George Liu | d664936 | 2019-11-27 19:06:51 +0800 | [diff] [blame] | 74 | pldmtool::platform::registerCommand(app); |
Sridevi Ramesh | d448975 | 2019-12-08 09:03:29 -0600 | [diff] [blame] | 75 | pldmtool::fru::registerCommand(app); |
Zahed Hossain | f0d1722 | 2020-04-03 05:24:58 -0500 | [diff] [blame] | 76 | |
| 77 | #ifdef OEM_IBM |
George Liu | 4407335 | 2020-03-12 14:00:13 +0800 | [diff] [blame] | 78 | pldmtool::oem_ibm::power_host::registerCommand(app); |
Zahed Hossain | f0d1722 | 2020-04-03 05:24:58 -0500 | [diff] [blame] | 79 | #endif |
Lakshminarayana R. Kammath | 27693a4 | 2019-06-24 00:51:47 -0500 | [diff] [blame] | 80 | |
| 81 | CLI11_PARSE(app, argc, argv); |
John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 82 | return 0; |
Lakshminarayana R. Kammath | 27693a4 | 2019-06-24 00:51:47 -0500 | [diff] [blame] | 83 | } |