USBGuard
Software framework that protects your computer against rogue USB devices by implementing basic whitelisting and blacklisting capabilities.
Public Member Functions | List of all members
usbguard::USBDescriptorParser Class Reference

Parses USB descriptors. More...

#include <USB.hpp>

Public Member Functions

 USBDescriptorParser (USBDescriptorParserHooks &hooks)
 
size_t parse (std::istream &stream)
 Initiate parsing of USB descriptors from an input stream. More...
 
const std::vector< USBDescriptor > * getDescriptor (uint8_t bDescriptorType) const
 Returns a pointer to a USBDescriptor of type bDescriptorType that is stored in the USB descriptor state. More...
 
void setDescriptor (uint8_t bDescriptorType, const USBDescriptor &descriptor)
 Set the active instance of an USB descriptor of type bDescriptorType. More...
 
void delDescriptor (uint8_t bDescriptorType)
 Delete the active instance of an USB descriptor of bDescriptorType type. More...
 
bool haveDescriptor (uint8_t bDescriptorType) const
 Checks whether descriptor state contains a USB descriptor of type bDescriptorType. More...
 
const std::vector< std::pair< uint8_t, size_t > > getDescriptorCounts () const
 Returns a vector of (bDescriptorType, count) pairs. More...
 

Detailed Description

Parses USB descriptors.

Member Function Documentation

◆ delDescriptor()

void usbguard::USBDescriptorParser::delDescriptor ( uint8_t  bDescriptorType)

Delete the active instance of an USB descriptor of bDescriptorType type.

Parameters
bDescriptorTypeType of descriptor to remove.

◆ getDescriptor()

const std::vector< USBDescriptor > * usbguard::USBDescriptorParser::getDescriptor ( uint8_t  bDescriptorType) const

Returns a pointer to a USBDescriptor of type bDescriptorType that is stored in the USB descriptor state.

If there's no such descriptor, then nullptr is returned.

Parameters
bDescriptorTypeType of descriptor.
Returns
Pointer to a USBDescriptor of type bDescriptorType or nullptr if there's no such descriptor.

◆ getDescriptorCounts()

const std::vector< std::pair< uint8_t, size_t > > usbguard::USBDescriptorParser::getDescriptorCounts ( ) const

Returns a vector of (bDescriptorType, count) pairs.

Returns
Vector of (bDescriptorType, count) pairs.

◆ haveDescriptor()

bool usbguard::USBDescriptorParser::haveDescriptor ( uint8_t  bDescriptorType) const

Checks whether descriptor state contains a USB descriptor of type bDescriptorType.

Parameters
bDescriptorTypeType of descriptor.
Returns
True if the descriptor state contains a USB descriptor of type bDescriptorType, false otherwise.

◆ parse()

size_t usbguard::USBDescriptorParser::parse ( std::istream &  stream)

Initiate parsing of USB descriptors from an input stream.

Parameters
streamStream to parse.
Returns
Number of bytes succesfully parsed/processed from the stream.

◆ setDescriptor()

void usbguard::USBDescriptorParser::setDescriptor ( uint8_t  bDescriptorType,
const USBDescriptor descriptor 
)

Set the active instance of an USB descriptor of type bDescriptorType.

Parameters
bDescriptorTypeType of descriptor. @descriptor Descriptor to set.

The documentation for this class was generated from the following files: