1#ifndef BLUETOE_LINK_LAYER_ADDRESS_HPP
2#define BLUETOE_LINK_LAYER_ADDRESS_HPP
5#include <initializer_list>
11 class random_device_address;
27 explicit address(
const std::initializer_list< std::uint8_t >& initial_values );
32 explicit address(
const std::uint8_t* initial_values );
45 template <
typename HashFunc >
51 std::ostream&
print( std::ostream& )
const;
56 std::uint8_t
msb()
const;
83 static std::uint32_t create_prand( std::uint32_t rand );
85 static constexpr std::size_t address_size_in_bytes = 6;
86 std::uint8_t value_[ address_size_in_bytes ];
89 void operator delete (
void* ptr );
90 void operator delete[](
void* ptr );
96 std::ostream& operator<<( std::ostream& out,
const address& a );
134 return ( *(
end() - 1 ) & 0xC0 ) == 0xC0;
144 const auto v = *(
end() - 1 ) & 0xC0;
145 return v == 0x40 || v == 0x00;
155 return ( *(
end() - 1 ) & 0xC0 ) == 0x40;
166 using address::operator==;
167 using address::operator!=;
210 std::ostream& operator<<( std::ostream& out,
const device_address& a );
264 template <
typename HashFunc >
267 const std::uint32_t prand = create_prand( random );
268 const std::uint32_t hash = hash_func( irk, prand );
270 std::uint8_t initial_values[ address_size_in_bytes ] = {
271 static_cast<uint8_t
>( prand >> 16 ),
272 static_cast<uint8_t
>( prand >> 8 ),
273 static_cast<uint8_t
>( prand ),
274 static_cast<uint8_t
>( hash >> 16 ),
275 static_cast<uint8_t
>( hash >> 8 ),
276 static_cast<uint8_t
>( hash ) };
a 48-bit universal LAN MAC address
Definition: address.hpp:17
bool operator==(const address &rhs) const
returns true, if this address is the same as the rhs address
static random_device_address generate_static_random_address(std::uint32_t seed)
generates a valid static random address out of a given seed value
bool operator!=(const address &rhs) const
returns false, if this address is the same as the rhs address
std::uint8_t msb() const
returns the most significant byte of the address
std::uint8_t const * const_iterator
random access iterator
Definition: address.hpp:71
address(const std::uint8_t *initial_values)
initializing an address by taking 6 bytes from the given start of an array
address(const std::initializer_list< std::uint8_t > &initial_values)
initialize an address by a initializer list with exactly 6 elements
static random_device_address generate_resolvable_private_address(const std::uint8_t *irk, std::uint32_t random, HashFunc hash_func)
generates a resolvable private address
Definition: address.hpp:265
const_iterator begin() const
returns an iterator to the first byte (LSB) of the address
std::ostream & print(std::ostream &) const
prints this in a human readable manner
address()
creates the address with all octes beeing zero (00:00:00:00:00:00)
const_iterator end() const
returns an iterator one behind the last byte of the address
data type containing a device address and the address type (public or random).
Definition: address.hpp:107
bool is_private() const
returns true, if the given address is not a static device address
Definition: address.hpp:142
device_address(const std::initializer_list< std::uint8_t > &initial_values, bool is_random)
initialize an address by a initializer list with exactly 6 elements and a flag indicating whether thi...
Definition: address.hpp:183
bool is_resolvable() const
returns true, if the given address is private and resolvable
Definition: address.hpp:153
bool is_random() const
returns true, if this device address is a random device address.
Definition: address.hpp:114
device_address(const std::uint8_t *initial_values, bool is_random)
initializing an address by taking 6 bytes from the given start of an array and a flag indicating whet...
Definition: address.hpp:192
bool operator==(const device_address &rhs) const
returns true, if this device address is the same as the rhs device address
bool is_random_resolvable() const
returns true, if the address is random and resolvable
Definition: address.hpp:161
bool operator!=(const device_address &rhs) const
returns false, if this device address is the same as the rhs device address
device_address(bool is_random)
constructs a public or random default device address (00:00:00:00:00:00)
Definition: address.hpp:201
bool is_static() const
returns true, if the given address is a static device address
Definition: address.hpp:132
bool is_public() const
shortcut for !is_random()
Definition: address.hpp:122
data type containing a public device address
Definition: address.hpp:218
public_device_address()
initialize a public device address 00:00:00:00:00:00
Definition: address.hpp:223
public_device_address(const std::initializer_list< std::uint8_t > &initial_values)
initialize a public device address by a initializer list with exactly 6 elements
Definition: address.hpp:228
public_device_address(const std::uint8_t *initial_values)
initializing a public device address by taking 6 bytes from the given start of an array
Definition: address.hpp:234
data type containing a random device address
Definition: address.hpp:244
random_device_address()
initialize a random device address 00:00:00:00:00:00
Definition: address.hpp:249
random_device_address(const std::initializer_list< std::uint8_t > &initial_values)
initialize a random device address by a initializer list with exactly 6 elements
Definition: address.hpp:254
random_device_address(const std::uint8_t *initial_values)
initializing a random device address by taking 6 bytes from the given start of an array
Definition: address.hpp:260