]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#553] Fixed hasOpenSocket
authorFrancis Dupont <fdupont@isc.org>
Mon, 25 May 2020 09:44:57 +0000 (11:44 +0200)
committerFrancis Dupont <fdupont@isc.org>
Tue, 7 Jul 2020 10:47:26 +0000 (12:47 +0200)
configure.ac
src/lib/dhcp/iface_mgr.cc

index 8cb9850e08e8922ee21233d63152de0083caa7ae..3a4f574cb5f65bf58592689fd1fdb7ffaeebcb9b 100755 (executable)
@@ -484,7 +484,7 @@ AC_SEARCH_LIBS(dlsym, [dl])
 # Checks for typedefs, structures, and compiler characteristics.
 AC_HEADER_STDBOOL
 AC_TYPE_SIZE_T
-
+AC_TYPE_SSIZE_T
 
 # Detect OS type (it may be used to do OS-specific things, e.g.
 # interface detection in DHCP)
index b243167b695e5facf7ee6552d7a5de9a7448ba60..fd26a1dd76135b6996a177f4385e9af0b1468387 100644 (file)
@@ -449,16 +449,20 @@ IfaceMgr::hasOpenSocket(const IOAddress& addr) const {
             // if address is unspecified (in6addr_any).
             if (sock.addr_ == addr) {
                 return (true);
-
-            } else if (sock.addr_ == IOAddress("::")) {
+            } else if (sock.addr_.isV6Zero()) {
                 // Handle the case that the address is unspecified (any).
+                // This happens only with IPv6 so we do not check IPv4.
                 // In this case, we should check if the specified address
                 // belongs to any of the interfaces.
-                for (Iface::Address a : iface->getAddresses()) {
-                    if (addr == a.get()) {
-                        return (true);
+                for (IfacePtr it : ifaces_) {
+                    for (Iface::Address a : it->getAddresses()) {
+                        if (addr == a.get()) {
+                            return (true);
+                        }
                     }
                 }
+                // The address does not belongs to any interface.
+                return (false);
             }
         }
     }