diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-02-16 01:48:11 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:10:43 -0500 |
commit | 4c7c38e930805b84789cfb2472776d6939fc23f6 (patch) | |
tree | 4f7174c83760be60d1b65cd654a624b7b1b19c7c /source4/lib/netif/interface.c | |
parent | e284054f655a430769fb02e4927256495338ff66 (diff) | |
download | samba-4c7c38e930805b84789cfb2472776d6939fc23f6.tar.gz samba-4c7c38e930805b84789cfb2472776d6939fc23f6.tar.bz2 samba-4c7c38e930805b84789cfb2472776d6939fc23f6.zip |
r5411: make network interface selection a bit saner
- if we have no configured network interfaces, then don't start nbtd (when I add dynamic
interface loading this will change to a delay until a network interface comes up)
- choose the best interface by netmask for torture tests that need a
specific IP (such as the WINS test). Added iface_best_ip() for that.
- if specific interfaces are chosen in smb.conf, then keep that ordering, and
default to the first one listed
(This used to be commit 4d08c114079ef6d1d10a96195046fe43631aefa2)
Diffstat (limited to 'source4/lib/netif/interface.c')
-rw-r--r-- | source4/lib/netif/interface.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/source4/lib/netif/interface.c b/source4/lib/netif/interface.c index 2d90df43cf..78f4456cd8 100644 --- a/source4/lib/netif/interface.c +++ b/source4/lib/netif/interface.c @@ -94,7 +94,7 @@ static void add_interface(struct in_addr ip, struct in_addr nmask) iface->nmask = tov4(nmask); iface->bcast.addr = MKBCADDR(iface->ip.addr, iface->nmask.addr); - DLIST_ADD(local_interfaces, iface); + DLIST_ADD_END(local_interfaces, iface, struct interface *); DEBUG(2,("added interface ip=%s ",sys_inet_ntoa(iface->ip))); DEBUG(2,("bcast=%s ",sys_inet_ntoa(iface->bcast))); @@ -339,3 +339,18 @@ const char *iface_n_netmask(int n) return NULL; } +/* + return the local IP address that best matches a destination IP, or + our first interface if none match +*/ +const char *iface_best_ip(const char *dest) +{ + struct interface *iface; + struct in_addr ip; + ip.s_addr = interpret_addr(dest); + iface = iface_find(ip, True); + if (iface) { + return sys_inet_ntoa(iface->ip); + } + return iface_n_ip(0); +} |