From d8d63b53b7beed80e9224ce8079c18da95b28247 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 12 May 2011 12:27:37 +0200 Subject: 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. --- source4/lib/socket/interface.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'source4/lib/socket') 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 **/ -- cgit