From 1f6eabf364e17b0556994c5011622d0a8015bac0 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 30 Sep 2014 00:41:51 +0200 Subject: rework big parts of the code --- netlink-notify.h | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 netlink-notify.h (limited to 'netlink-notify.h') diff --git a/netlink-notify.h b/netlink-notify.h new file mode 100644 index 0000000..3ca7430 --- /dev/null +++ b/netlink-notify.h @@ -0,0 +1,93 @@ +/* + * (C) 2014 by Christian Hesse + * + * This software may be used and distributed according to the terms + * of the GNU General Public License, incorporated herein by reference. + */ + +#ifndef NETLINK_NOTIFY_H +#define NETLINK_NOTIFY_H + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +/* we have to undefine this before including net/if.h to + * notget redefined structs, etc. */ +#undef __USE_MISC +#include +#include +#include + +#include + +#include "version.h" +#include "config.h" + +#define PROGNAME "netlink-notify" + +#define CHECK_CONNECTED IFF_LOWER_UP + +struct addresses_seen { + char address[INET6_ADDRSTRLEN]; + unsigned char prefix; + struct addresses_seen *next; +}; + +struct ifs { + char name[IF_NAMESIZE]; + int state; + uint8_t deleted; + struct addresses_seen *addresses_seen; + NotifyNotification *notification; +}; + +/*** free_addresses ***/ +void free_addresses(struct addresses_seen *addresses_seen); + +/*** add_address ***/ +struct addresses_seen * add_address(struct addresses_seen *addresses_seen, const char *address, unsigned char prefix); + +/*** remove_address ***/ +struct addresses_seen * remove_address(struct addresses_seen *addresses_seen, const char *address, unsigned char prefix); + +/*** match_address ***/ +int match_address(struct addresses_seen *addresses_seen, const char *address, unsigned char prefix); + +/*** list_addresses ***/ +void list_addresses(struct addresses_seen *addresses_seen, char *interface); + +/*** newstr_link ***/ +char * newstr_link(const char *text, char *interface, unsigned int flags); + +/*** newstr_addr ***/ +char * newstr_addr(const char *text, char *interface, unsigned char family, char *ipaddr, unsigned char prefix); + +/*** newstr_away ***/ +char * newstr_away(const char *text, char *interface); + +/*** open_netlink ***/ +int open_netlink (void); + +/*** read_event ***/ +int read_event (int sockint); + +/*** msg_handler ***/ +int msg_handler (struct sockaddr_nl *nl, struct nlmsghdr *msg); + +/*** received_signal ***/ +void received_signal(int signal); + +/*** main ***/ +int main (int argc, char **argv); + +#endif /* NETLINK_NOTIFY_H */ -- cgit v1.2.3-54-g00ecf