summaryrefslogtreecommitdiffstats
path: root/source/lib/interface.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1997-12-13 14:16:07 +0000
committerJeremy Allison <jra@samba.org>1997-12-13 14:16:07 +0000
commitd80b0cb645f81d16734929a0b27a91c6650499bb (patch)
treeebfed2074213433bc32bdb4e449b793a819b8628 /source/lib/interface.c
parent273978b7d72955efcc0e0d9e87438b45f51c163d (diff)
downloadsamba-d80b0cb645f81d16734929a0b27a91c6650499bb.tar.gz
samba-d80b0cb645f81d16734929a0b27a91c6650499bb.tar.xz
samba-d80b0cb645f81d16734929a0b27a91c6650499bb.zip
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.
Diffstat (limited to 'source/lib/interface.c')
-rw-r--r--source/lib/interface.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/source/lib/interface.c b/source/lib/interface.c
index 8af2696a446..0008ad889df 100644
--- a/source/lib/interface.c
+++ b/source/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)) {
@@ -425,6 +425,33 @@ int iface_count(void)
}
/****************************************************************************
+ 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
**************************************************************************/
struct in_addr *iface_n_ip(int n)
@@ -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)
{