chiark / gitweb /
Release 1.2.3.
[preload-hacks] / noip.c
diff --git a/noip.c b/noip.c
index aca7b75e7d4e907b99e748d03a27b38d39a64d1a..345f3251d7c56d2e591fedee22b663e8b330e505 100644 (file)
--- a/noip.c
+++ b/noip.c
 #include <ifaddrs.h>
 #include <netdb.h>
 
+#ifndef SUN_LEN
+#  define SUN_LEN (sun) \
+       (strlen((sun)->sun_path) + offsetof(struct sockaddr_un, sun_path))
+#endif
+
 /*----- Data structures ---------------------------------------------------*/
 
 /* Unix socket status values. */
@@ -1122,7 +1127,11 @@ static int do_implicit_bind(int sk, const struct sockaddr *sa, unsigned f)
        sockaddr_in_range_p(sa, &i->minaddr, &i->maxaddr)) {
       D( fprintf(stderr, "noip(%d): match!\n", pid); )
       addr.sa.sa_family = sa->sa_family;
-      ipaddr_to_sockaddr(&addr.sa, &i->bindaddr);
+      switch (i->how) {
+       case EXPLICIT: ipaddr_to_sockaddr(&addr.sa, &i->bindaddr); break;
+       case SAME: copy_sockaddr(&addr.sa, sa); break;
+      }
+      port_to_sockaddr(&addr.sa, 0);
       goto found;
     }
   }