X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-autoipd%2Fiface-linux.c;h=2ad8a61ab53b0992205aab915a4d7db29a58c0cf;hb=83b432c2369d7ef4142811bea0109b6588b6f313;hp=c2f24df7b8692a44b2b2abc4e8fa663c48506733;hpb=12874f5d761b4b80ac27c1fc758a93b69d92c34c;p=catta diff --git a/avahi-autoipd/iface-linux.c b/avahi-autoipd/iface-linux.c index c2f24df..2ad8a61 100644 --- a/avahi-autoipd/iface-linux.c +++ b/avahi-autoipd/iface-linux.c @@ -40,6 +40,16 @@ #include #include +#ifndef IFLA_RTA +#include +#define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg)))) +#endif + +#ifndef IFA_RTA +#include +#define IFA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg)))) +#endif + #include "iface.h" static int fd = -1; @@ -106,7 +116,6 @@ static int process_nlmsg(struct nlmsghdr *n) { if ((ifi->ifi_flags & IFF_LOOPBACK) || (ifi->ifi_flags & IFF_NOARP) || - !(ifi->ifi_flags & IFF_UP) || ifi->ifi_type != ARPHRD_ETHER) { daemon_log(LOG_ERR, "Interface not suitable."); return -1; @@ -121,7 +130,6 @@ static int process_nlmsg(struct nlmsghdr *n) { int l; uint32_t address = 0; Address *i; - char buf[32]; ifa = NLMSG_DATA(n); @@ -144,8 +152,6 @@ static int process_nlmsg(struct nlmsghdr *n) { a = RTA_NEXT(a, l); } - daemon_log(LOG_INFO, "%s", inet_ntop(AF_INET, &address, buf, sizeof(buf))); - if (!address || is_ll_address(address)) return 0; @@ -189,7 +195,7 @@ static int process_response(int wait_for_done, unsigned seq) { return -1; } - if (p->nlmsg_type == NLMSG_DONE && wait_for_done && p->nlmsg_seq == seq) + if (p->nlmsg_type == NLMSG_DONE && wait_for_done && p->nlmsg_seq == seq && (pid_t) p->nlmsg_pid == getpid()) return 0; if (p->nlmsg_type == NLMSG_ERROR) { @@ -201,9 +207,6 @@ static int process_response(int wait_for_done, unsigned seq) { } } - if ((pid_t) p->nlmsg_pid != getpid()) - continue; - if (process_nlmsg(p) < 0) return -1; } @@ -272,7 +275,7 @@ int iface_process(Event *event) { if (process_response(0, 0) < 0) return -1; - if (b && !!addresses) + if (b && !addresses) *event = EVENT_ROUTABLE_ADDR_UNCONFIGURED; else if (!b && addresses) *event = EVENT_ROUTABLE_ADDR_CONFIGURED;