summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2011-05-12 12:27:37 +0200
committerAndrew Tridgell <tridge@samba.org>2011-06-06 12:26:09 +1000
commitd8d63b53b7beed80e9224ce8079c18da95b28247 (patch)
tree8d00600b49865f5b1d71cf59fe34458990af0513
parenta527b96c968037db2d699493a9017709d053f95a (diff)
downloadsamba-d8d63b53b7beed80e9224ce8079c18da95b28247.tar.gz
samba-d8d63b53b7beed80e9224ce8079c18da95b28247.tar.bz2
samba-d8d63b53b7beed80e9224ce8079c18da95b28247.zip
s4-ipv6: added ipv4 functions to interface code
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.
-rw-r--r--source4/lib/socket/interface.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/source4/lib/socket/interface.c b/source4/lib/socket/interface.c
index 0de44c1517..3737f57f9b 100644
--- a/source4/lib/socket/interface.c
+++ b/source4/lib/socket/interface.c
@@ -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
**/