117 h = ( ( h << 5 ) - h ) +
b[i];
126 b[0] = 0;
b[1] = 0;
b[2] = 0;
127 b[3] = 0;
b[4] = 0;
b[5] = 0;
146 const uint8_t needle_b[],
const jau::nsize_t needle_length,
180 std::string
toString() const noexcept;
188 if( lhs.length != rhs.length ) {
191 return !memcmp(&lhs.b, &rhs.b, lhs.length);
195 {
return !(lhs == rhs); }
204 __pack (
struct EUI48 {
217 constexpr EUI48() noexcept :
b{0} { }
226 EUI48(
const uint8_t * source,
const lb_endian_t byte_order)
noexcept;
240 static bool scanEUI48(
const std::string& str, EUI48& dest, std::string& errmsg);
252 EUI48(
const std::string& str);
254 constexpr EUI48(
const EUI48 &o)
noexcept =
default;
255 EUI48(EUI48 &&o)
noexcept =
default;
256 constexpr EUI48&
operator=(
const EUI48 &o)
noexcept =
default;
257 EUI48&
operator=(EUI48 &&o)
noexcept =
default;
259 constexpr std::size_t
hash_code() const noexcept {
261 std::size_t h =
b[0];
262 h = ( ( h << 5 ) - h ) +
b[1];
263 h = ( ( h << 5 ) - h ) +
b[2];
264 h = ( ( h << 5 ) - h ) +
b[3];
265 h = ( ( h << 5 ) - h ) +
b[4];
266 h = ( ( h << 5 ) - h ) +
b[5];
274 b[0] = 0;
b[1] = 0;
b[2] = 0;
275 b[3] = 0;
b[4] = 0;
b[5] = 0;
309 std::string
toString() const noexcept;
330 const uint8_t * a = lhs.b;
331 const uint8_t *
b = rhs.b;
332 return a[0] ==
b[0] &&
341 {
return !(lhs == rhs); }
343 constexpr static void bswap_6bytes(uint8_t* sink,
const uint8_t* source)
noexcept {
402 template<>
struct hash<
jau::io::net::EUI48Sub> {
404 return a.hash_code();
408 template<>
struct hash<
jau::io::net::EUI48> {
410 return a.hash_code();
constexpr bool is_little_endian() noexcept
Evaluates true if platform is running in little endian mode, i.e.
constexpr bool is_defined_endian(const endian_t &v) noexcept
Evaluates true if the given endian is defined, i.e.
constexpr bool is_little_or_big_endian() noexcept
Evaluates true if platform is running in little or big endian mode, i.e.
lb_endian_t
Simplified reduced endian type only covering little- and big-endian.
@ 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.
bool operator!=(const EUI48Sub &lhs, const EUI48Sub &rhs) noexcept
constexpr EUI48 cpu_to_le(EUI48 const &h) noexcept
static constexpr void bswap_6bytes(uint8_t *sink, const uint8_t *source) noexcept
constexpr EUI48 cpu_to_be(EUI48 const &h) noexcept
constexpr EUI48 bswap(EUI48 const &source) noexcept
std::string to_string(const EUI48Sub &a) noexcept
constexpr EUI48 le_to_cpu(EUI48 const &l) noexcept
constexpr EUI48 be_to_cpu(EUI48 const &n) noexcept
bool operator==(const EUI48Sub &lhs, const EUI48Sub &rhs) noexcept
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
A 48 bit EUI-48 sub-identifier, see EUI48.
constexpr std::size_t hash_code() const noexcept
uint8_t b[6]
The <= 6 byte EUI48 sub-address.
jau::nsize_t length
The actual length in bytes of the EUI48 sub-address, less or equal 6 bytes.
constexpr EUI48Sub() noexcept
EUI48Sub(EUI48Sub &&o) noexcept=default
constexpr EUI48Sub(const EUI48Sub &o) noexcept=default
static const EUI48Sub ANY_DEVICE
EUI48 MAC address matching any device, i.e.
void clear()
Method clears the underlying byte array b and sets length to zero.
bool contains(const EUI48Sub &needle) const noexcept
Returns true, if given EUI48Sub needle is contained in this instance haystack.
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.
static const EUI48Sub LOCAL_DEVICE
EUI48 MAC address matching local device, i.e.
EUI48Sub & operator=(EUI48Sub &&o) noexcept=default
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.
constexpr EUI48Sub & operator=(const EUI48Sub &o) noexcept=default
std::string toString() const noexcept
Returns the EUI48 sub-string representation with MSB first (lb_endian::big), less or equal 17 charact...
static const EUI48Sub ALL_DEVICE
EUI48 MAC address matching all device, i.e.
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::io::net::EUI48Sub const &a) const noexcept
std::size_t operator()(jau::io::net::EUI48 const &a) const noexcept