mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-29 10:20:11 +01:00
utils: introduce nm_ether_addr_from_string() helper
This commit is contained in:
parent
483d287590
commit
cd31559ded
2 changed files with 14 additions and 0 deletions
|
|
@ -146,6 +146,18 @@ G_STATIC_ASSERT(ETH_ALEN == sizeof(NMEtherAddr));
|
|||
|
||||
G_STATIC_ASSERT(_nm_alignof(struct ether_addr) <= _nm_alignof(NMEtherAddr));
|
||||
|
||||
NMEtherAddr *
|
||||
nm_ether_addr_from_string(NMEtherAddr *addr, const char *str)
|
||||
{
|
||||
nm_assert(addr);
|
||||
|
||||
if (!str || !_nm_utils_hwaddr_aton_exact(str, addr, ETH_ALEN)) {
|
||||
*addr = NM_ETHER_ADDR_INIT(0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return addr;
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2859,6 +2859,8 @@ nm_ether_addr_to_string(const NMEtherAddr *ether_addr, char sbuf[static(sizeof(N
|
|||
#define nm_ether_addr_to_string_a(ether_addr) \
|
||||
nm_ether_addr_to_string((ether_addr), g_alloca(sizeof(NMEtherAddr) * 3))
|
||||
|
||||
NMEtherAddr *nm_ether_addr_from_string(NMEtherAddr *addr, const char *str);
|
||||
|
||||
guint8 *nm_utils_hexstr2bin_full(const char *hexstr,
|
||||
gboolean allow_0x_prefix,
|
||||
gboolean delimiter_required,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue