]> arthur.barton.de Git - netatalk.git/commitdiff
We're listening of :::548 ie IPv6 socket by default, so ioctl for address needs its...
authorfranklahm <franklahm>
Fri, 6 Nov 2009 14:33:52 +0000 (14:33 +0000)
committerfranklahm <franklahm>
Fri, 6 Nov 2009 14:33:52 +0000 (14:33 +0000)
libatalk/dsi/dsi_tcp.c

index a239774a4e6e91811dfcda977b929bbccc88bfb8..023df9ae2f952c5c12947561e8c54eaa47b03ea1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: dsi_tcp.c,v 1.19 2009-11-06 13:53:16 franklahm Exp $
+ * $Id: dsi_tcp.c,v 1.20 2009-11-06 14:33:52 franklahm Exp $
  *
  * Copyright (c) 1997, 1998 Adrian Sun (asun@zoology.washington.edu)
  * All rights reserved. See COPYRIGHT.
@@ -361,6 +361,7 @@ int dsi_tcp_init(DSI *dsi, const char *hostname, const char *address,
 interfaces:
     LOG(log_warning, logtype_default, "dsi_tcp: cannot resolve hostname '%s'", hostname);
     /* get it from the interface list */
+    int fd;
     char **start, **list;
     struct ifreq ifr;
     start = list = getifacelist();
@@ -375,14 +376,17 @@ interfaces:
         if (ioctl(dsi->serversock, SIOCGIFFLAGS, &ifr) < 0)
             continue;
 
-        if (ifr.ifr_flags & (IFF_LOOPBACK | IFF_POINTOPOINT | IFF_SLAVE))
+//        if (ifr.ifr_flags & (IFF_LOOPBACK | IFF_POINTOPOINT | IFF_SLAVE))
+        if (ifr.ifr_flags & (IFF_LOOPBACK | IFF_SLAVE))
             continue;
 
         if (!(ifr.ifr_flags & (IFF_UP | IFF_RUNNING)) )
             continue;
 
-        if (ioctl(dsi->serversock, SIOCGIFADDR, &ifr) < 0)
+        fd = socket(PF_INET, SOCK_STREAM, 0);
+        if (ioctl(fd, SIOCGIFADDR, &ifr) < 0)
             continue;
+        close(fd);
 
         memcpy(&dsi->server, &ifr.ifr_addr, sizeof(struct sockaddr_storage));
         LOG(log_info, logtype_default, "dsi_tcp: '%s' on interface '%s' will be used instead.",