blob: f52c1e8af1fb29d190c931ed856662c06046325b [file] [log] [blame]
John Wang58a0e062019-11-08 15:38:15 +08001#include "pldm_base_cmd.hpp"
Sridevi Ramesh98576432019-11-27 10:10:28 -06002#include "pldm_bios_cmd.hpp"
John Wang58a0e062019-11-08 15:38:15 +08003#include "pldm_cmd_helper.hpp"
Sridevi Rameshd4489752019-12-08 09:03:29 -06004#include "pldm_fru_cmd.hpp"
George Liud6649362019-11-27 19:06:51 +08005#include "pldm_platform_cmd.hpp"
Pavithra Barithayac4e80cc2020-05-26 07:00:26 -05006#include "pldmtool/oem/ibm/pldm_oem_ibm.hpp"
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -05007
8#include <CLI/CLI.hpp>
9
John Wang58a0e062019-11-08 15:38:15 +080010namespace pldmtool
11{
12
13namespace raw
14{
15
16using namespace pldmtool::helper;
17
18namespace
19{
20std::vector<std::unique_ptr<CommandInterface>> commands;
21}
22
23class 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
George Liu6492f522020-06-16 10:34:05 +080048 {}
John Wang58a0e062019-11-08 15:38:15 +080049
50 private:
51 std::vector<uint8_t> rawData;
52};
53
54void registerCommand(CLI::App& app)
55{
56 auto raw =
57 app.add_subcommand("raw", "send a raw request and print response");
58 commands.push_back(std::make_unique<RawOp>("raw", "raw", raw));
59}
60
61} // namespace raw
62} // namespace pldmtool
63
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050064int main(int argc, char** argv)
65{
66
67 CLI::App app{"PLDM requester tool for OpenBMC"};
John Wang58a0e062019-11-08 15:38:15 +080068 app.require_subcommand(1)->ignore_case();
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050069
John Wang58a0e062019-11-08 15:38:15 +080070 pldmtool::raw::registerCommand(app);
71 pldmtool::base::registerCommand(app);
Sridevi Ramesh98576432019-11-27 10:10:28 -060072 pldmtool::bios::registerCommand(app);
George Liud6649362019-11-27 19:06:51 +080073 pldmtool::platform::registerCommand(app);
Sridevi Rameshd4489752019-12-08 09:03:29 -060074 pldmtool::fru::registerCommand(app);
Zahed Hossainf0d17222020-04-03 05:24:58 -050075
76#ifdef OEM_IBM
Pavithra Barithayac4e80cc2020-05-26 07:00:26 -050077 pldmtool::oem_ibm::registerCommand(app);
Zahed Hossainf0d17222020-04-03 05:24:58 -050078#endif
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050079
80 CLI11_PARSE(app, argc, argv);
John Wang58a0e062019-11-08 15:38:15 +080081 return 0;
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050082}