glib-aux: add nm_utils_ip4_address_is_loopback()

This commit is contained in:
Thomas Haller 2022-07-22 18:30:44 +02:00
parent 51625013d4
commit 76d63c66d7
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -508,8 +508,16 @@ gboolean nm_utils_ip_is_site_local(int addr_family, const void *address);
/*****************************************************************************/
#define NM_IPV4LL_NETWORK ((in_addr_t) (htonl(0xA9FE0000lu)))
#define NM_IPV4LL_NETMASK ((in_addr_t) (htonl(0xFFFF0000lu)))
#define NM_IPV4LL_NETWORK ((in_addr_t) htonl(0xA9FE0000lu))
#define NM_IPV4LL_NETMASK ((in_addr_t) htonl(0xFFFF0000lu))
static inline gboolean
nm_utils_ip4_address_is_loopback(in_addr_t addr)
{
/* There is also IN_LOOPBACK() in <linux/in.h>, but there the
* argument is in host order not `in_addr_t`. */
return (addr & htonl(0xFF000000u)) == htonl(0x7F000000u);
}
static inline gboolean
nm_utils_ip4_address_is_link_local(in_addr_t addr)