mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-02 13:30:13 +01:00
std-aux: add nm_utils_addr_family_to_str() helper
Like nm_utils_addr_family_to_char(), but gives a different treatment to AF_UNSPEC to return "" instead of 'X'. As such, it also needs to return a string and not a char.
This commit is contained in:
parent
7459a8c67a
commit
f9fa3fbf9f
1 changed files with 15 additions and 0 deletions
|
|
@ -1134,6 +1134,21 @@ nm_ptr_to_uintptr(const void *p)
|
|||
#define NM_AF_INET_SIZE 4 /* sizeof (in_addr_t) */
|
||||
#define NM_AF_INET6_SIZE 16 /* sizeof (stuct in6_addr) */
|
||||
|
||||
static inline const char *
|
||||
nm_utils_addr_family_to_str(int addr_family)
|
||||
{
|
||||
switch (addr_family) {
|
||||
case NM_AF_UNSPEC:
|
||||
return "";
|
||||
case NM_AF_INET:
|
||||
return "4";
|
||||
case NM_AF_INET6:
|
||||
return "6";
|
||||
}
|
||||
nm_assert_not_reached();
|
||||
return "?";
|
||||
}
|
||||
|
||||
static inline char
|
||||
nm_utils_addr_family_to_char(int addr_family)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue