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 64 of file net.hpp.

Member Function Documentation

◆ FromString()

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

Definition at line 68 of file net.hpp.

69 {
70 MACAddressRaw mac{};
71 std::sscanf(str, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &mac.bytes[0], &mac.bytes[1],
72 &mac.bytes[2], &mac.bytes[3], &mac.bytes[4], &mac.bytes[5]);
73 return mac;
74 }

◆ operator!=()

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

Definition at line 87 of file net.hpp.

87{ return !(*this == other); }

◆ operator==()

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

Definition at line 82 of file net.hpp.

83 {
84 return Memory::FastCmp(bytes, other.bytes, 6) == 0;
85 }
static int FastCmp(const void *a, const void *b, size_t size)
快速内存比较 / Fast memory comparison

◆ ToString()

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

Definition at line 76 of file net.hpp.

77 {
78 std::snprintf(out, MACADDR_STRLEN, "%02X:%02X:%02X:%02X:%02X:%02X", bytes[0],
79 bytes[1], bytes[2], bytes[3], bytes[4], bytes[5]);
80 }

Field Documentation

◆ bytes

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

Definition at line 66 of file net.hpp.

66{};

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