s4-ipv6: added ipv4 functions to interface code
authorAndrew Tridgell <tridge@samba.org>
Thu, 12 May 2011 10:27:37 +0000 (12:27 +0200)
committerAndrew Tridgell <tridge@samba.org>
Mon, 6 Jun 2011 02:26:09 +0000 (12:26 +1000)
this adds iface_list_first_v4() and iface_list_n_is_v4(). The NBT
server will use these to allow it to listen only for IPv4 addresses.

source4/lib/socket/interface.c

index 0de44c151709712732c96caf6e395fe5f25a532c..3737f57f9b5e24bb758571654231d7e1ce92627e 100644 (file)
@@ -348,6 +348,38 @@ const char *iface_list_n_ip(struct interface *ifaces, int n)
        return NULL;
 }
 
+
+/**
+  return the first IPv4 interface address we have registered
+  **/
+const char *iface_list_first_v4(struct interface *ifaces)
+{
+       struct interface *i;
+
+       for (i=ifaces; i; i=i->next) {
+               if (i->ip.ss_family == AF_INET) {
+                       return i->ip_s;
+               }
+       }
+       return NULL;
+}
+
+/**
+   check if an interface is IPv4
+  **/
+bool iface_list_n_is_v4(struct interface *ifaces, int n)
+{
+       struct interface *i;
+
+       for (i=ifaces;i && n;i=i->next)
+               n--;
+
+       if (i) {
+               return i->ip.ss_family == AF_INET;
+       }
+       return false;
+}
+
 /**
   return bcast of the Nth interface
   **/