From 64f0348a3f994334abe64a4d4896109c3c8c9039 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 13 Dec 1997 14:16:07 +0000 Subject: This is it ! The mega-merge of the JRA_NMBD_REWRITE branch back into the main tree. For the cvs logs of all the files starting nmbd_*.c, look in the JRA_NMBD_REWRITE branch. That branch has now been discontinued. Jeremy. (This used to be commit d80b0cb645f81d16734929a0b27a91c6650499bb) --- source3/lib/interface.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/interface.c b/source3/lib/interface.c index 8af2696a44..0008ad889d 100644 --- a/source3/lib/interface.c +++ b/source3/lib/interface.c @@ -24,7 +24,7 @@ extern int DEBUGLEVEL; struct in_addr ipzero; -struct in_addr wins_ip; +struct in_addr allones_ip; struct in_addr loopback_ip; static struct in_addr default_ip; static struct in_addr default_bcast; @@ -33,7 +33,7 @@ static BOOL got_ip=False; static BOOL got_bcast=False; static BOOL got_nmask=False; -struct interface *local_interfaces = NULL; +static struct interface *local_interfaces = NULL; struct interface *last_iface; @@ -262,7 +262,7 @@ static void interpret_interfaces(char *s, struct interface **interfaces, struct in_addr ip; ipzero = *interpret_addr2("0.0.0.0"); - wins_ip = *interpret_addr2("255.255.255.255"); + allones_ip = *interpret_addr2("255.255.255.255"); loopback_ip = *interpret_addr2("127.0.0.1"); while (next_token(&ptr,token,NULL)) { @@ -424,6 +424,33 @@ int iface_count(void) return ret; } +/**************************************************************************** + True if we have two or more interfaces. + **************************************************************************/ +BOOL we_are_multihomed() +{ + static int multi = -1; + + if(multi == -1) + multi = (iface_count() > 1 ? True : False); + + return multi; +} + +/**************************************************************************** + return the Nth interface + **************************************************************************/ +struct interface *get_interface(int n) +{ + struct interface *i; + + for (i=local_interfaces;i && n;i=i->next) + n--; + + if (i) return i; + return NULL; +} + /**************************************************************************** return IP of the Nth interface **************************************************************************/ @@ -453,7 +480,9 @@ static struct interface *iface_find(struct in_addr ip) } /* these 3 functions return the ip/bcast/nmask for the interface - most appropriate for the given ip address */ + most appropriate for the given ip address. If they can't find + an appropriate interface they return the requested field of the + first known interface. */ struct in_addr *iface_bcast(struct in_addr ip) { -- cgit