diff options
Diffstat (limited to 'source/lib/interface.c')
-rw-r--r-- | source/lib/interface.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/source/lib/interface.c b/source/lib/interface.c index d43001342e7..3a269294ed9 100644 --- a/source/lib/interface.c +++ b/source/lib/interface.c @@ -1,5 +1,6 @@ /* - Unix SMB/CIFS implementation. + Unix SMB/Netbios implementation. + Version 1.9. multiple interface handling Copyright (C) Andrew Tridgell 1992-1998 @@ -23,10 +24,11 @@ static struct iface_struct *probed_ifaces; static int total_probed; +struct in_addr ipzero; struct in_addr allones_ip; struct in_addr loopback_ip; -static struct interface *local_interfaces; +static struct interface *local_interfaces = NULL; #define ALLONES ((uint32)0xFFFFFFFF) #define MKBCADDR(_IP, _NM) ((_IP & _NM) | (_NM ^ ALLONES)) @@ -38,7 +40,7 @@ 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) { struct interface *i; - if (is_zero_ip(ip)) return local_interfaces; + if (zero_ip(ip)) return local_interfaces; for (i=local_interfaces;i;i=i->next) if (CheckMask) { @@ -100,12 +102,12 @@ static void interpret_interface(char *token) char *p; int i, added=0; - zero_ip(&ip); - zero_ip(&nmask); + ip = ipzero; + nmask = ipzero; /* first check if it is an interface name */ for (i=0;i<total_probed;i++) { - if (gen_fnmatch(token, probed_ifaces[i].name) == 0) { + if (ms_fnmatch(token, probed_ifaces[i].name) == 0) { add_interface(probed_ifaces[i].ip, probed_ifaces[i].netmask); added = 1; @@ -114,7 +116,7 @@ static void interpret_interface(char *token) if (added) return; /* maybe it is a DNS name */ - p = strchr_m(token,'/'); + p = strchr(token,'/'); if (!p) { ip = *interpret_addr2(token); for (i=0;i<total_probed;i++) { @@ -162,12 +164,14 @@ load the list of network interfaces ****************************************************************************/ void load_interfaces(void) { - char **ptr; + char *ptr; + fstring token; int i; struct iface_struct ifaces[MAX_INTERFACES]; ptr = lp_interfaces(); + ipzero = *interpret_addr2("0.0.0.0"); allones_ip = *interpret_addr2("255.255.255.255"); loopback_ip = *interpret_addr2("127.0.0.1"); @@ -190,7 +194,7 @@ void load_interfaces(void) /* if we don't have a interfaces line then use all broadcast capable interfaces except loopback */ - if (!ptr || !*ptr || !**ptr) { + if (!ptr || !*ptr) { if (total_probed <= 0) { DEBUG(0,("ERROR: Could not determine network interfaces, you must use a interfaces config line\n")); exit(1); @@ -205,11 +209,8 @@ void load_interfaces(void) return; } - if (ptr) { - while (*ptr) { - interpret_interface(*ptr); - ptr++; - } + while (next_token(&ptr,token,NULL,sizeof(token))) { + interpret_interface(token); } if (!local_interfaces) { |