From 43d18b91b4e8ec417a6010ab22c1ba4edb1631c3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 10 Dec 2007 18:42:01 +0100 Subject: r26383: Make interfaces argument explicit. (This used to be commit 89008ae18d37e8bc5bb7c70ac3e2128134264f9f) --- source4/lib/socket/interface.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'source4/lib/socket') diff --git a/source4/lib/socket/interface.c b/source4/lib/socket/interface.c index 79c5673022..309ed80744 100644 --- a/source4/lib/socket/interface.c +++ b/source4/lib/socket/interface.c @@ -47,12 +47,13 @@ static struct interface *local_interfaces; /**************************************************************************** Try and find an interface that matches an ip. If we cannot, return NULL **************************************************************************/ -static struct interface *iface_find(struct in_addr ip, bool CheckMask) +static struct interface *iface_find(struct interface *interfaces, + struct in_addr ip, bool CheckMask) { struct interface *i; - if (is_zero_ip(ip)) return local_interfaces; + if (is_zero_ip(ip)) return interfaces; - for (i=local_interfaces;i;i=i->next) + for (i=interfaces;i;i=i->next) if (CheckMask) { if (same_net(i->ip,ip,i->nmask)) return i; } else if (i->ip.s_addr == ip.s_addr) return i; @@ -64,18 +65,19 @@ static struct interface *iface_find(struct in_addr ip, bool CheckMask) /**************************************************************************** add an interface to the linked list of interfaces ****************************************************************************/ -static void add_interface(struct in_addr ip, struct in_addr nmask) +static void add_interface(struct in_addr ip, struct in_addr nmask, struct interface **interfaces) { struct interface *iface; struct in_addr bcast; - if (iface_find(ip, false)) { + if (iface_find(*interfaces, ip, false)) { DEBUG(3,("not adding duplicate interface %s\n",inet_ntoa(ip))); return; } - iface = talloc(local_interfaces == NULL ? talloc_autofree_context() : local_interfaces, struct interface); - if (!iface) return; + iface = talloc(*interfaces == NULL ? talloc_autofree_context() : *interfaces, struct interface); + if (iface == NULL) + return; ZERO_STRUCTPN(iface); @@ -92,7 +94,7 @@ static void add_interface(struct in_addr ip, struct in_addr nmask) iface->bcast_s = talloc_strdup(iface, inet_ntoa(bcast)); } - DLIST_ADD_END(local_interfaces, iface, struct interface *); + DLIST_ADD_END(*interfaces, iface, struct interface *); DEBUG(2,("added interface ip=%s nmask=%s\n", iface->ip_s, iface->nmask_s)); } @@ -125,7 +127,8 @@ static void interpret_interface(const char *token, for (i=0;iip_s; } @@ -330,7 +335,7 @@ bool iface_is_local(struct loadparm_context *lp_ctx, const char *dest) load_interfaces(lp_interfaces(lp_ctx)); ip.s_addr = interpret_addr(dest); - if (iface_find(ip, true)) { + if (iface_find(local_interfaces, ip, true)) { return true; } return false; -- cgit