PUD: nwif: use interface address to detect whether it's an olsr interface
authorFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 5 Jun 2012 20:31:58 +0000 (22:31 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 7 Jun 2012 22:30:04 +0000 (00:30 +0200)
more reliable

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/pud/src/networkInterfaces.c

index 5cd7d38..8b7cbb9 100644 (file)
@@ -660,10 +660,11 @@ bool createNetworkInterfaces(socket_handler_func rxSocketHandlerFunction,
                        if (addrFamily == olsr_cnf->ip_version) {
                                char * ifName = ifAddr->ifa_name;
 
-                               /* determine whether the iterated interface is an OLSR
-                                * interface: returns NULL when the interface is not an
-                                * OLSR interface */
-                               struct interface *olsrIntf = if_ifwithname(ifName);
+                               struct interface * olsrIntf = ((addr->in.sa_family != olsr_cnf->ip_version) ?
+                                               NULL :
+                                               if_ifwithaddr((addr->in.sa_family == AF_INET) ?
+                                                               (union olsr_ip_addr *)&addr->in4.sin_addr :
+                                                               (union olsr_ip_addr *)&addr->in6.sin6_addr));
                                bool isOlsrIf = (olsrIntf != NULL);
 
                                /* determine whether the iterated interface is configured as a