command_line_parser.h
Go to the documentation of this file.
1 //
2 // Bareflank Hypervisor
3 //
4 // Copyright (C) 2015 Assured Information Security, Inc.
5 // Author: Rian Quinn <quinnr@ainfosec.com>
6 // Author: Brendan Kerrigan <kerriganb@ainfosec.com>
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 
22 #ifndef COMMAND_LINE_PARSER_H
23 #define COMMAND_LINE_PARSER_H
24 
25 #include <vector>
26 #include <string>
27 
28 #include <file.h>
29 #include <ioctl.h>
30 
32 {
33 enum type
34 {
35  help = 1,
36  load = 2,
37  unload = 3,
38  start = 4,
39  stop = 5,
40  dump = 6,
41  status = 7,
42  vmcall = 8
43 };
44 }
45 
55 {
56 public:
57 
60  using arg_list_type = std::vector<arg_type>;
65 
72 
78  virtual ~command_line_parser() = default;
79 
93  virtual void parse(const arg_list_type &args);
94 
102  virtual command_type cmd() const noexcept;
103 
115  virtual const filename_type &modules() const noexcept;
116 
124  virtual cpuid_type cpuid() const noexcept;
125 
133  virtual vcpuid_type vcpuid() const noexcept;
134 
146  virtual const registers_type &registers() const noexcept;
147 
155  virtual const filename_type &ifile() const noexcept;
156 
164  virtual const filename_type &ofile() const noexcept;
165 
166 private:
167 
168  void reset() noexcept;
169 
170  void parse_load(arg_list_type &args);
171  void parse_unload(arg_list_type &args);
172  void parse_start(arg_list_type &args);
173  void parse_stop(arg_list_type &args);
174  void parse_dump(arg_list_type &args);
175  void parse_status(arg_list_type &args);
176  void parse_vmcall(arg_list_type &args);
177 
178  void parse_vmcall_version(arg_list_type &args);
179  void parse_vmcall_registers(arg_list_type &args);
180  void parse_vmcall_string(arg_list_type &args);
181  void parse_vmcall_data(arg_list_type &args);
182  void parse_vmcall_event(arg_list_type &args);
183  void parse_vmcall_unittest(arg_list_type &args);
184 
185  void parse_vmcall_string_unformatted(arg_list_type &args);
186  void parse_vmcall_string_json(arg_list_type &args);
187 
188  void parse_vmcall_data_unformatted(arg_list_type &args);
189 
190 private:
191 
192  command_type m_cmd;
193  filename_type m_modules;
194  cpuid_type m_cpuid;
195  vcpuid_type m_vcpuid;
196  registers_type m_registers;
197  filename_type m_ifile;
198  filename_type m_ofile;
199  arg_type m_string_data;
200 };
201 
202 #endif
uint64_t vcpuid_type
Definition: ioctl.h:56
virtual const filename_type & ifile() const noexcept
file::filename_type filename_type
virtual void parse(const arg_list_type &args)
struct vmcall_registers_t registers_type
Definition: ioctl.h:59
Definition: vcpuid.h:29
ioctl::cpuid_type cpuid_type
void uint64_t uint64_t uint64_t *rdx noexcept
virtual command_type cmd() const noexcept
std::vector< arg_type > arg_list_type
std::string filename_type
Definition: file.h:41
virtual const filename_type & ofile() const noexcept
virtual const registers_type & registers() const noexcept
ioctl::vcpuid_type vcpuid_type
virtual ~command_line_parser()=default
uint64_t cpuid_type
Definition: ioctl.h:55
virtual const filename_type & modules() const noexcept