DBus::Validator Class Reference

Contains various static routines for validating and/or sanitizing data. More...

#include <validator.h>

Static Public Member Functions

static bool validate_bus_name (std::string name)
 Validate a bus name. More...
 
static bool validate_interface_name (std::string name)
 Validate an interface name. More...
 
static bool validate_member_name (std::string name)
 Validate a member name. More...
 
static bool validate_error_name (std::string name)
 Validate an error name. More...
 
static bool message_is_small_enough (const std::vector< uint8_t > *data)
 Checks to make sure that the size of the message(after serialization) is lower than 2^27. More...
 
static constexpr uint32_t maximum_array_size ()
 Return the maximum array size. More...
 
static constexpr uint32_t maximum_message_size ()
 
static constexpr uint32_t maximum_message_depth ()
 

Private Member Functions

 Validator ()
 

Detailed Description

Contains various static routines for validating and/or sanitizing data.

Constructor & Destructor Documentation

◆ Validator()

DBus::Validator::Validator ( )
private

Member Function Documentation

◆ maximum_array_size()

static constexpr uint32_t DBus::Validator::maximum_array_size ( )
inlinestaticconstexpr

◆ maximum_message_depth()

static constexpr uint32_t DBus::Validator::maximum_message_depth ( )
inlinestaticconstexpr

◆ maximum_message_size()

static constexpr uint32_t DBus::Validator::maximum_message_size ( )
inlinestaticconstexpr

◆ message_is_small_enough()

bool Validator::message_is_small_enough ( const std::vector< uint8_t > *  data)
static

Checks to make sure that the size of the message(after serialization) is lower than 2^27.

Parameters
data
Returns

References maximum_message_size().

Referenced by DBus::Message::serialize_to_vector().

◆ validate_bus_name()

bool Validator::validate_bus_name ( std::string  name)
static

Validate a bus name.

According to the DBus specification:

Bus names that start with a colon (':') character are unique connection names. Other bus names are called well-known bus names.

-Bus names are composed of 1 or more elements separated by a period ('.') character. All elements must contain at least one character.

  • Each element must only contain the ASCII characters "[A-Z][a-z][0-9]_-", with "-" discouraged in new bus names. Only elements that are part of a unique connection name may begin with a digit, elements in other bus names must not begin with a digit.
  • Bus names must contain at least one '.' (period) character (and thus at least two elements).
  • Bus names must not begin with a '.' (period) character.
  • Bus names must not exceed the maximum name length(255).

Note that this method will reject technically-correct interface names that have '-' in them, as this is discouraged.

Parameters
nameThe name to validate
Returns

References is_allowable_character().

Referenced by DBus::Message::set_destination().

◆ validate_error_name()

bool Validator::validate_error_name ( std::string  name)
static

Validate an error name.

See validate_interface_name for specifications.

Parameters
name
Returns

References validate_interface_name().

◆ validate_interface_name()

bool Validator::validate_interface_name ( std::string  name)
static

Validate an interface name.

According to the DBus specification:

Interface names are composed of 2 or more elements separated by a period ('.') character. All elements must contain at least one character.

  • Each element must only contain the ASCII characters "[A-Z][a-z][0-9]_" and must not begin with a digit.
  • Interface names must not exceed the maximum name length.
Parameters
nameThe name to validate
Returns

References is_allowable_character().

Referenced by DBus::SignalMessage::set_interface(), and validate_error_name().

◆ validate_member_name()

bool Validator::validate_member_name ( std::string  name)
static

Validate a member name.

According to the DBus specification:

  • Must only contain the ASCII characters "[A-Z][a-z][0-9]_" and may not begin with a digit.
  • Must not contain the '.' (period) character.
  • Must not exceed the maximum name length.
  • Must be at least 1 byte in length.
Parameters
name
Returns

References is_allowable_character().


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