diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2011-07-28 10:20:32 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2011-07-28 10:20:32 +0200 |
commit | a8986413c299c77c6f57f7e8f8f0e5abf1a882c9 (patch) | |
tree | 59f4f944266d6bbf6b551aa2b739b992ed3afb79 | |
parent | 6123996833bfcb450007392a9f9a2a046f9356cc (diff) | |
download | pingu-a8986413c299c77c6f57f7e8f8f0e5abf1a882c9.tar.bz2 pingu-a8986413c299c77c6f57f7e8f8f0e5abf1a882c9.tar.xz |
Use sockaddr_any for storing address and gateway
-rw-r--r-- | pingu_host.c | 4 | ||||
-rw-r--r-- | pingu_iface.c | 2 | ||||
-rw-r--r-- | pingu_iface.h | 16 |
3 files changed, 18 insertions, 4 deletions
diff --git a/pingu_host.c b/pingu_host.c index da14858..427fe9a 100644 --- a/pingu_host.c +++ b/pingu_host.c @@ -156,7 +156,7 @@ static char *get_provider_gateway(struct pingu_host *p) return p->host; } -static void exec_route_change(void) +static void exec_route_change_hook(void) { struct pingu_host *host; struct list_head *n; @@ -240,7 +240,7 @@ int pingu_host_set_status(struct pingu_host *host, int status) } if (action != NULL) execute_action(action); - exec_route_change(); + exec_route_change_hook(); return status; } diff --git a/pingu_iface.c b/pingu_iface.c index 689d36b..7b97c62 100644 --- a/pingu_iface.c +++ b/pingu_iface.c @@ -118,7 +118,7 @@ void pingu_iface_set_addr(struct pingu_iface *iface, int family, log_debug("%s: address removed", iface->name); return; } - iface->primary_addr.sa_family = family; + iface->primary_addr.sa.sa_family = family; switch (family) { case AF_INET: sin = (struct sockaddr_in *)&iface->primary_addr; diff --git a/pingu_iface.h b/pingu_iface.h index b44415d..e690506 100644 --- a/pingu_iface.h +++ b/pingu_iface.h @@ -1,19 +1,33 @@ #ifndef PINGU_IFACE_H #define PINGU_IFACE_H +#include <netinet/in.h> #include <ev.h> #include "list.h" +union sockaddr_any { + struct sockaddr sa; + struct sockaddr_in sin; + struct sockaddr_in6 sin6; +}; + +struct pingu_gateway { + union sockaddr_any gw; + int metric; + struct list_head gateway_list_entry; +}; + struct pingu_iface { char name[32]; int index; int has_binding; int has_link; int fd; - struct sockaddr primary_addr; + union sockaddr_any primary_addr; int route_table; struct list_head iface_list_entry; struct list_head ping_list; + struct list_head gateway_list; struct ev_io socket_watcher; }; |