119 h = ( ( h << 5 ) - h ) +
b[i];
128 b[0] = 0;
b[1] = 0;
b[2] = 0;
129 b[3] = 0;
b[4] = 0;
b[5] = 0;
148 const uint8_t needle_b[],
const jau::nsize_t needle_length,
182 std::string
toString() const noexcept;
190 if( lhs.length != rhs.length ) {
193 return !memcmp(&lhs.b, &rhs.b, lhs.length);
197 {
return !(lhs == rhs); }
206 __pack (
struct EUI48 {
219 constexpr EUI48() noexcept :
b{0} { }
228 EUI48(
const uint8_t * source,
const lb_endian_t byte_order)
noexcept;
242 static bool scanEUI48(
const std::string& str, EUI48& dest, std::string& errmsg);
254 EUI48(
const std::string& str);
256 constexpr EUI48(
const EUI48 &o)
noexcept =
default;
257 EUI48(EUI48 &&o)
noexcept =
default;
258 constexpr EUI48&
operator=(
const EUI48 &o)
noexcept =
default;
259 EUI48&
operator=(EUI48 &&o)
noexcept =
default;
261 constexpr std::size_t
hash_code() const noexcept {
263 std::size_t h =
b[0];
264 h = ( ( h << 5 ) - h ) +
b[1];
265 h = ( ( h << 5 ) - h ) +
b[2];
266 h = ( ( h << 5 ) - h ) +
b[3];
267 h = ( ( h << 5 ) - h ) +
b[4];
268 h = ( ( h << 5 ) - h ) +
b[5];
276 b[0] = 0;
b[1] = 0;
b[2] = 0;
277 b[3] = 0;
b[4] = 0;
b[5] = 0;
311 std::string
toString() const noexcept;
332 const uint8_t * a = lhs.b;
333 const uint8_t *
b = rhs.b;
334 return a[0] ==
b[0] &&
343 {
return !(lhs == rhs); }
345 constexpr static void bswap_6bytes(uint8_t* sink,
const uint8_t* source)
noexcept {
406 return a.hash_code();
410 template<>
struct hash<
jau::EUI48> {
412 return a.hash_code();
constexpr bool is_defined_endian(const endian_t &v) noexcept
Evaluates true if the given endian is defined, i.e.
constexpr uint16_t bswap(uint16_t const source) noexcept
constexpr bool is_little_or_big_endian() noexcept
Evaluates true if platform is running in little or big endian mode, i.e.
constexpr uint16_t cpu_to_be(uint16_t const h) noexcept
constexpr uint16_t le_to_cpu(uint16_t const l) noexcept
lb_endian_t
Simplified reduced endian type only covering little- and big-endian.
std::string to_string(const endian_t v) noexcept
Return std::string representation of the given endian.
constexpr bool is_little_endian(const endian_t byte_order) noexcept
Returns true if given byte_order equals endian::little, otherwise false.
constexpr uint16_t be_to_cpu(uint16_t const n) noexcept
constexpr uint16_t cpu_to_le(uint16_t const h) noexcept
@ native
Identifier for native platform type, one of the above.
@ native
Identifier for native platform type, one of the above.
uint_fast32_t nsize_t
Natural 'size_t' alternative using uint_fast32_t as its natural sized type.
int_fast32_t snsize_t
Natural 'ssize_t' alternative using int_fast32_t as its natural sized type.
static constexpr void bswap_6bytes(uint8_t *sink, const uint8_t *source) noexcept
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
bool operator==(const callocator< T1 > &lhs, const callocator< T2 > &rhs) noexcept
bool operator!=(const callocator< T1 > &lhs, const callocator< T2 > &rhs) noexcept
A 48 bit EUI-48 sub-identifier, see EUI48.
EUI48Sub & operator=(EUI48Sub &&o) noexcept=default
constexpr EUI48Sub & operator=(const EUI48Sub &o) noexcept=default
jau::nsize_t length
The actual length in bytes of the EUI48 sub-address, less or equal 6 bytes.
constexpr EUI48Sub() noexcept
bool contains(const EUI48Sub &needle) const noexcept
Returns true, if given EUI48Sub needle is contained in this instance haystack.
uint8_t b[6]
The <= 6 byte EUI48 sub-address.
constexpr EUI48Sub(const EUI48Sub &o) noexcept=default
static const EUI48Sub ALL_DEVICE
EUI48 MAC address matching all device, i.e.
constexpr std::size_t hash_code() const noexcept
static const EUI48Sub ANY_DEVICE
EUI48 MAC address matching any device, i.e.
jau::snsize_t indexOf(const EUI48Sub &needle, const lb_endian_t byte_order) const noexcept
Finds the index of given EUI48Sub needle within this instance haystack in the given byte order.
static jau::snsize_t indexOf(const uint8_t haystack_b[], const jau::nsize_t haystack_length, const uint8_t needle_b[], const jau::nsize_t needle_length, const lb_endian_t byte_order) noexcept
Find index of needle within haystack in the given byte order.
EUI48Sub(EUI48Sub &&o) noexcept=default
void clear()
Method clears the underlying byte array b and sets length to zero.
static const EUI48Sub LOCAL_DEVICE
EUI48 MAC address matching local device, i.e.
std::string toString() const noexcept
Returns the EUI48 sub-string representation with MSB first (lb_endian::big), less or equal 17 charact...
static bool scanEUI48Sub(const std::string &str, EUI48Sub &dest, std::string &errmsg)
Fills given EUI48Sub instance via given string representation.
A packed 48 bit EUI-48 identifier, formerly known as MAC-48 or simply network device MAC address (Med...
std::size_t operator()(jau::EUI48Sub const &a) const noexcept
std::size_t operator()(jau::EUI48 const &a) const noexcept