|
NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
|
MAC地址封装类 更多...
#include <mac_address.hpp>
Public 类型 | |
| using | bytes_type = array<byte_t, MAC_LEN> |
| MAC地址字节数组类型 | |
Public 成员函数 | |
| mac_address () noexcept=default | |
| 默认构造函数 | |
| mac_address (const byte_t *bytes) noexcept | |
| 从字节数组构造 | |
| mac_address (const bytes_type &bytes) noexcept | |
| 从字节数组容器构造 | |
| string | to_string () const |
| 转换为字符串表示 | |
| bool | operator== (const mac_address &other) const noexcept |
| 相等比较运算符 | |
| bool | operator!= (const mac_address &other) const noexcept |
| 不等比较运算符 | |
| const bytes_type & | bytes () const noexcept |
| 获取MAC地址字节数组 | |
| Public 成员函数 继承自 istringify< mac_address > | |
| NEFORCE_NODISCARD NEFORCE_CONSTEXPR20 string | to_string () const |
| 转换为字符串 | |
静态 Public 成员函数 | |
| static optional< mac_address > | parse (string_view str) |
| 从字符串解析MAC地址 | |
| static optional< mac_address > | parse (const ip_address &ip, const char *iface=nullptr) |
| 从IP地址获取MAC地址 | |
静态 Public 属性 | |
| static constexpr size_t | MAC_LEN = 6 |
| MAC地址字节长度 | |
MAC地址封装类
封装6字节的MAC地址,提供地址解析、格式化和ARP查询功能。
MAC地址格式:XX:XX:XX:XX:XX:XX(6组十六进制数,每组2位)
主要功能:
在文件 mac_address.hpp 第 39 行定义.
|
defaultnoexcept |
|
inlineexplicitnoexcept |
从字节数组构造
| bytes | 指向6字节数据的指针 |
在文件 mac_address.hpp 第 59 行定义.
引用了 bytes(), copy(), mac_address() , 以及 MAC_LEN.
|
inlineexplicitnoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
static |
从IP地址获取MAC地址
| ip | IP地址对象 |
| iface | 网络接口名称(Linux可选) |
通过ARP查询指定IP对应的MAC地址。
|
static |
从字符串解析MAC地址
| str | MAC地址字符串 |
支持的格式:
| string mac_address::to_string | ( | ) | const |
转换为字符串表示