USBGuard
Software framework that protects your computer against rogue USB devices by implementing basic whitelisting and blacklisting capabilities.
Interface.hpp
1 //
2 // Copyright (C) 2015 Red Hat, Inc.
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // Authors: Daniel Kopecek <dkopecek@redhat.com>
18 //
19 #pragma once
20 
21 #include "DeviceManager.hpp"
22 #include "Rule.hpp"
23 #include "RuleSet.hpp"
24 #include "Typedefs.hpp"
25 #include "USB.hpp"
26 
27 #include <map>
28 #include <string>
29 #include <vector>
30 
31 #include <cstdint>
32 
33 namespace usbguard
34 {
35 
40  class DLL_PUBLIC Interface
41  {
42  public:
43 
44  /*************************************************************************
45  ******************************* PARAMETERS ******************************
46  *************************************************************************/
47 
55  virtual std::string setParameter(const std::string& name, const std::string& value) = 0;
56 
63  virtual std::string getParameter(const std::string& name) = 0;
64 
65  /*************************************************************************
66  ******************************* METHODS *********************************
67  *************************************************************************/
68 
82  virtual uint32_t appendRule(const std::string& rule_spec,
83  uint32_t parent_id, bool permanent) = 0;
84 
90  virtual void removeRule(uint32_t id) = 0;
91 
100  virtual const std::vector<Rule> listRules(const std::string& query) = 0;
101 
119  virtual uint32_t applyDevicePolicy(uint32_t id,
120  Rule::Target target,
121  bool permanent) = 0;
122 
134  virtual const std::vector<Rule> listDevices(const std::string& query) = 0;
135 
136  /*************************************************************************
137  ******************************* SIGNALS *********************************
138  *************************************************************************/
139 
162  virtual void DevicePresenceChanged(uint32_t id,
164  Rule::Target target,
165  const std::string& device_rule) = 0;
166 
186  virtual void DevicePolicyChanged(uint32_t id,
187  Rule::Target target_old,
188  Rule::Target target_new,
189  const std::string& device_rule,
190  uint32_t rule_id) = 0;
191 
199  virtual void PropertyParameterChanged(const std::string& name,
200  const std::string& value_old,
201  const std::string& value_new) = 0;
202 
211  virtual void ExceptionMessage(const std::string& context,
212  const std::string& object,
213  const std::string& reason) = 0;
214  };
215 } /* namespace usbguard */
216 
217 /* vim: set ts=2 sw=2 et */
Target
Enumeration of possible rule targets.
Definition: Rule.hpp:86
EventType
Type of event that took place on the device.
Definition: DeviceManager.hpp:51
Allows to receive signals and to communicate with the USBGuard daemon.
Definition: Interface.hpp:40