libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::MACAddressRaw Struct Reference

原始 MAC 地址 / Raw MAC address More...

#include <net.hpp>

Public Member Functions

void ToString (char out[MACADDR_STRLEN]) const
 
bool operator== (const MACAddressRaw &other) const
 
bool operator!= (const MACAddressRaw &other) const
 

Static Public Member Functions

static MACAddressRaw FromString (const char *str)
 

Data Fields

uint8_t bytes [6] {}
 

Detailed Description

原始 MAC 地址 / Raw MAC address

Definition at line 68 of file net.hpp.

Member Function Documentation

◆ FromString()

static MACAddressRaw LibXR::MACAddressRaw::FromString ( const char * str)
inlinestatic

Definition at line 72 of file net.hpp.

73 {
74 MACAddressRaw mac{};
75 std::sscanf(str, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
76 &mac.bytes[0], &mac.bytes[1], &mac.bytes[2],
77 &mac.bytes[3], &mac.bytes[4], &mac.bytes[5]);
78 return mac;
79 }

◆ operator!=()

bool LibXR::MACAddressRaw::operator!= ( const MACAddressRaw & other) const
inline

Definition at line 93 of file net.hpp.

94 {
95 return !(*this == other);
96 }

◆ operator==()

bool LibXR::MACAddressRaw::operator== ( const MACAddressRaw & other) const
inline

Definition at line 88 of file net.hpp.

89 {
90 return std::memcmp(bytes, other.bytes, 6) == 0;
91 }

◆ ToString()

void LibXR::MACAddressRaw::ToString ( char out[MACADDR_STRLEN]) const
inline

Definition at line 81 of file net.hpp.

82 {
83 std::snprintf(out, MACADDR_STRLEN, "%02X:%02X:%02X:%02X:%02X:%02X",
84 bytes[0], bytes[1], bytes[2],
85 bytes[3], bytes[4], bytes[5]);
86 }

Field Documentation

◆ bytes

uint8_t LibXR::MACAddressRaw::bytes[6] {}

Definition at line 70 of file net.hpp.

70{};

The documentation for this struct was generated from the following file: