USBGuard
Software framework that protects your computer against rogue USB devices by implementing basic whitelisting and blacklisting capabilities.
|
Represents ID of a USB device. More...
#include <USB.hpp>
Public Member Functions | |
USBDeviceID ()=default | |
Default constructor. | |
USBDeviceID (const std::string &vendor_id, const std::string &product_id=std::string()) | |
Constructs a new ID with vendor_id and product_id . More... | |
USBDeviceID (const USBDeviceID &rhs)=default | |
Default copy constructor. More... | |
USBDeviceID & | operator= (const USBDeviceID &rhs)=default |
Default copy assignment. More... | |
void | setVendorID (const std::string &vendor_id) |
Sets vendor ID. More... | |
void | setProductID (const std::string &product_id) |
Sets product ID. More... | |
const std::string & | getVendorID () const |
Returns vendor ID. More... | |
const std::string & | getProductID () const |
Returns product ID. More... | |
std::string | toRuleString () const |
Returns ID in form of a string. More... | |
std::string | toString () const |
Same as toRuleString(). More... | |
bool | isSubsetOf (const USBDeviceID &rhs) const |
Checks if ID is subset of other ID. More... | |
Static Public Member Functions | |
static void | checkDeviceID (const std::string &vendor_id, const std::string &product_id) |
Checks if ID has a valid format. More... | |
Represents ID of a USB device.
Format: <vendor
id>
:<product
id>
Example: ffff:ffff
usbguard::USBDeviceID::USBDeviceID | ( | const std::string & | vendor_id, |
const std::string & | product_id = std::string() |
||
) |
Constructs a new ID with vendor_id
and product_id
.
Also performs checkDeviceID().
vendor_id | Vendor ID. |
product_id | Product ID. |
runtime_error | If ID would have invalid format. |
|
default |
Default copy constructor.
rhs | USBDeviceID to copy. |
|
static |
Checks if ID has a valid format.
If vendor id is empty or *
then product id must also be empty or *
. Both vendor id and product id can not be larger then their maximum size.
vendor_id | Vendor ID. |
product_id | Product ID. |
runtime_error | If ID has invalid format. |
const std::string & usbguard::USBDeviceID::getProductID | ( | ) | const |
Returns product ID.
const std::string & usbguard::USBDeviceID::getVendorID | ( | ) | const |
Returns vendor ID.
bool usbguard::USBDeviceID::isSubsetOf | ( | const USBDeviceID & | rhs | ) | const |
Checks if ID is subset of other ID.
Basically checks if both IDs have the same vendor and product ID. Either vendor or product ID can be empty and it might still be a subset.
rhs | ID to compare with. |
|
default |
Default copy assignment.
rhs | USBDeviceID to copy. |
void usbguard::USBDeviceID::setProductID | ( | const std::string & | product_id | ) |
Sets product ID.
Also performs checkDeviceID().
product_id | Product ID. |
runtime_error | If product ID invalidates ID format. Respectively, if setting product_id would cause checkDeviceID() to fail. |
void usbguard::USBDeviceID::setVendorID | ( | const std::string & | vendor_id | ) |
Sets vendor ID.
Also performs checkDeviceID().
vendor_id | Vendor ID. |
runtime_error | If vendor ID invalidates ID format. Respectively, if setting vendor_id would cause checkDeviceID() to fail. |
std::string usbguard::USBDeviceID::toRuleString | ( | ) | const |
Returns ID in form of a string.
String has the form: <vendor id>:<product id>.
std::string usbguard::USBDeviceID::toString | ( | ) | const |
Same as toRuleString().