mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-22 10:46:59 +00:00
libnm-util: add nm_utils_hwaddr_type()
Returns the address type given the length.
This commit is contained in:
parent
6e4eb4902e
commit
1f8090fb58
|
@ -452,6 +452,7 @@ global:
|
|||
nm_utils_hwaddr_aton;
|
||||
nm_utils_hwaddr_len;
|
||||
nm_utils_hwaddr_ntoa;
|
||||
nm_utils_hwaddr_type;
|
||||
nm_utils_init;
|
||||
nm_utils_ip4_addresses_from_gvalue;
|
||||
nm_utils_ip4_addresses_to_gvalue;
|
||||
|
|
|
@ -2408,6 +2408,27 @@ nm_utils_hwaddr_len (int type)
|
|||
g_return_val_if_reached (-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_hwaddr_type:
|
||||
* @len: the length of hardware address in bytes
|
||||
*
|
||||
* Returns the type (either %ARPHRD_ETHER or %ARPHRD_INFINIBAND) of the raw
|
||||
* address given its length.
|
||||
*
|
||||
* Return value: the type, either %ARPHRD_ETHER or %ARPHRD_INFINIBAND, or -1 if
|
||||
* the address length was not recognized
|
||||
*/
|
||||
int
|
||||
nm_utils_hwaddr_type (int len)
|
||||
{
|
||||
if (len == ETH_ALEN)
|
||||
return ARPHRD_ETHER;
|
||||
else if (len == INFINIBAND_ALEN)
|
||||
return ARPHRD_INFINIBAND;
|
||||
else
|
||||
g_return_val_if_reached (-1);
|
||||
}
|
||||
|
||||
#define HEXVAL(c) ((c) <= '9' ? (c) - '0' : ((c) & 0x4F) - 'A' + 10)
|
||||
|
||||
/**
|
||||
|
|
|
@ -128,6 +128,7 @@ gboolean nm_utils_wifi_is_channel_valid (guint32 channel, const char *band);
|
|||
#define NM_UTILS_HWADDR_LEN_MAX 20 /* INFINIBAND_ALEN */
|
||||
|
||||
int nm_utils_hwaddr_len (int type) G_GNUC_PURE;
|
||||
int nm_utils_hwaddr_type (int len) G_GNUC_PURE;
|
||||
char *nm_utils_hwaddr_ntoa (gconstpointer addr, int type);
|
||||
GByteArray *nm_utils_hwaddr_atoba (const char *asc, int type);
|
||||
guint8 *nm_utils_hwaddr_aton (const char *asc, int type, gpointer buffer);
|
||||
|
|
Loading…
Reference in a new issue