socket-util: introduce in_addr_union similar to sockaddr_union and make use of it everywhere

This commit is contained in:
Lennart Poettering 2014-06-18 12:34:02 +02:00
parent 03966da2ca
commit 5d3de3fe9c
3 changed files with 10 additions and 14 deletions

View File

@ -20,6 +20,7 @@
***/
#include <netinet/ether.h>
#include <net/if.h>
#include "util.h"
#include "macro.h"

View File

@ -36,6 +36,7 @@
#include "list.h"
#include "set.h"
#include "condition-util.h"
#include "socket-util.h"
#define CACHE_INFO_INFINITY_LIFE_TIME 0xFFFFFFFFU
#define VXLAN_VID_MAX (1u << 24) - 1
@ -184,10 +185,7 @@ struct Address {
struct in_addr broadcast;
struct ifa_cacheinfo cinfo;
union {
struct in_addr in;
struct in6_addr in6;
} in_addr;
union in_addr_union in_addr;
LIST_FIELDS(Address, addresses);
};
@ -201,15 +199,8 @@ struct Route {
unsigned char scope;
uint32_t metrics;
union {
struct in_addr in;
struct in6_addr in6;
} in_addr;
union {
struct in_addr in;
struct in6_addr in6;
} dst_addr;
union in_addr_union in_addr;
union in_addr_union dst_addr;
LIST_FIELDS(Route, routes);
};

View File

@ -24,7 +24,6 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/un.h>
#include <net/if.h>
#include <asm/types.h>
#include <linux/netlink.h>
#include <linux/if_packet.h>
@ -42,6 +41,11 @@ union sockaddr_union {
struct sockaddr_ll ll;
};
union in_addr_union {
struct in_addr in;
struct in6_addr in6;
};
typedef struct SocketAddress {
union sockaddr_union sockaddr;