libnm: add internal helper function nm_utils_inet_ntop()

This commit is contained in:
Thomas Haller
2017-11-08 22:13:40 +01:00
parent b227198e92
commit ffcab3f653
2 changed files with 18 additions and 0 deletions

View File

@@ -429,6 +429,8 @@ NMSettingBluetooth *_nm_connection_get_setting_bluetooth_for_nap (NMConnection *
/*****************************************************************************/
const char *nm_utils_inet_ntop (int addr_family, gconstpointer addr, char *dst);
gboolean _nm_utils_inet6_is_token (const struct in6_addr *in6addr);
/*****************************************************************************/

View File

@@ -3762,6 +3762,22 @@ nm_utils_is_uuid (const char *str)
static char _nm_utils_inet_ntop_buffer[NM_UTILS_INET_ADDRSTRLEN];
const char *
nm_utils_inet_ntop (int addr_family, gconstpointer addr, char *dst)
{
const char *s;
nm_assert_addr_family (addr_family);
nm_assert (addr);
s = inet_ntop (addr_family,
addr,
dst ? dst : _nm_utils_inet_ntop_buffer,
addr_family == AF_INET6 ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN);
nm_assert (s);
return s;
}
/**
* nm_utils_inet4_ntop: (skip)
* @inaddr: the address that should be converted to string.