shared: add NMIPAddr struct

This commit is contained in:
Thomas Haller
2017-09-14 08:32:27 +02:00
parent 569b443233
commit dd0617547d
5 changed files with 24 additions and 24 deletions

View File

@@ -32,6 +32,10 @@ const void *const _NM_PTRARRAY_EMPTY[1] = { NULL };
/*****************************************************************************/
const NMIPAddr nm_ip_addr_zero = { 0 };
/*****************************************************************************/
void
nm_utils_strbuf_append_c (char **buf, gsize *len, char c)
{

View File

@@ -22,6 +22,25 @@
#ifndef __NM_SHARED_UTILS_H__
#define __NM_SHARED_UTILS_H__
#include <netinet/in.h>
/*****************************************************************************/
typedef struct {
union {
guint8 addr_ptr[1];
in_addr_t addr4;
struct in6_addr addr6;
/* NMIPAddr is really a union for IP addresses.
* However, as ethernet addresses fit in here nicely, use
* it also for an ethernet MAC address. */
guint8 addr_eth[6 /*ETH_ALEN*/];
};
} NMIPAddr;
extern const NMIPAddr nm_ip_addr_zero;
/*****************************************************************************/
#define NM_CMP_RETURN(c) \

View File

@@ -110,10 +110,6 @@ _nm_utils_set_testing (NMUtilsTestFlags flags)
/*****************************************************************************/
const NMIPAddr nm_ip_addr_zero = NMIPAddrInit;
/*****************************************************************************/
static GSList *_singletons = NULL;
static gboolean _singletons_shutdown = FALSE;

View File

@@ -90,25 +90,6 @@ GETTER (void) \
/*****************************************************************************/
typedef struct {
union {
guint8 addr_ptr[1];
in_addr_t addr4;
struct in6_addr addr6;
/* NMIPAddr is really a union for IP addresses.
* However, as ethernet addresses fit in here nicely, use
* it also for an ethernet MAC address. */
guint8 addr_eth[6 /*ETH_ALEN*/];
};
} NMIPAddr;
extern const NMIPAddr nm_ip_addr_zero;
#define NMIPAddrInit { .addr6 = IN6ADDR_ANY_INIT }
/*****************************************************************************/
guint nm_utils_in6_addr_hash (const struct in6_addr *addr);
gboolean nm_ethernet_address_is_valid (gconstpointer addr, gssize len);

View File

@@ -2087,7 +2087,7 @@ _new_from_nl_route (struct nlmsghdr *nlh, gboolean id_only)
|| tb[RTA_GATEWAY]
|| tb[RTA_FLOW]) {
int ifindex = 0;
NMIPAddr gateway = NMIPAddrInit;
NMIPAddr gateway = { };
if (tb[RTA_OIF])
ifindex = nla_get_u32 (tb[RTA_OIF]);