summaryrefslogtreecommitdiff
path: root/source4/lib/netif/interface.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-02-15 04:18:11 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:51:56 -0500
commit048704a7e54573086e7913519d2b72577a34b135 (patch)
treeb2267d9f1c79163c5496da5e2e0028a11fde7cd5 /source4/lib/netif/interface.c
parent8c7a593bcd5a30e47d1f062bfb9ca7d5118fe459 (diff)
downloadsamba-048704a7e54573086e7913519d2b72577a34b135.tar.gz
samba-048704a7e54573086e7913519d2b72577a34b135.tar.bz2
samba-048704a7e54573086e7913519d2b72577a34b135.zip
r13505: allow servers to bind to non-broadcast interfaces. Servers now
specifically ask for iface_n_bcast() and have to check if it returns NULL, in which case it is a non-broadcast interface (This used to be commit d004e250b6710251ea089ac242775481f13b5c2b)
Diffstat (limited to 'source4/lib/netif/interface.c')
-rw-r--r--source4/lib/netif/interface.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/source4/lib/netif/interface.c b/source4/lib/netif/interface.c
index 2a0e3642fe..222e63b92e 100644
--- a/source4/lib/netif/interface.c
+++ b/source4/lib/netif/interface.c
@@ -29,7 +29,6 @@
struct interface {
struct interface *next, *prev;
struct ipv4_addr ip;
- struct ipv4_addr bcast;
struct ipv4_addr nmask;
const char *ip_s;
const char *bcast_s;
@@ -75,16 +74,12 @@ add an interface to the linked list of interfaces
static void add_interface(struct in_addr ip, struct in_addr nmask)
{
struct interface *iface;
+ struct ipv4_addr bcast;
if (iface_find(ip, False)) {
DEBUG(3,("not adding duplicate interface %s\n",inet_ntoa(ip)));
return;
}
- if (nmask.s_addr == ~0) {
- DEBUG(3,("not adding non-broadcast interface %s\n",inet_ntoa(ip)));
- return;
- }
-
iface = talloc(local_interfaces, struct interface);
if (!iface) return;
@@ -92,18 +87,20 @@ static void add_interface(struct in_addr ip, struct in_addr nmask)
iface->ip = tov4(ip);
iface->nmask = tov4(nmask);
- iface->bcast.addr = MKBCADDR(iface->ip.addr, iface->nmask.addr);
+ bcast.addr = MKBCADDR(iface->ip.addr, iface->nmask.addr);
/* keep string versions too, to avoid people tripping over the implied
static in sys_inet_ntoa() */
iface->ip_s = talloc_strdup(iface, sys_inet_ntoa(iface->ip));
- iface->bcast_s = talloc_strdup(iface, sys_inet_ntoa(iface->bcast));
iface->nmask_s = talloc_strdup(iface, sys_inet_ntoa(iface->nmask));
+
+ if (nmask.s_addr != ~0) {
+ iface->bcast_s = talloc_strdup(iface, sys_inet_ntoa(bcast));
+ }
DLIST_ADD_END(local_interfaces, iface, struct interface *);
- DEBUG(2,("added interface ip=%s bcast=%s nmask=%s\n",
- iface->ip_s, iface->bcast_s, iface->nmask_s));
+ DEBUG(2,("added interface ip=%s nmask=%s\n", iface->ip_s, iface->nmask_s));
}
@@ -149,8 +146,7 @@ static void interpret_interface(const char *token,
}
ip.s_addr = interpret_addr2(token).addr;
for (i=0;i<total_probed;i++) {
- if (ip.s_addr == probed_ifaces[i].ip.s_addr &&
- probed_ifaces[i].netmask.s_addr != ~0) {
+ if (ip.s_addr == probed_ifaces[i].ip.s_addr) {
add_interface(probed_ifaces[i].ip,
probed_ifaces[i].netmask);
return;
@@ -209,15 +205,14 @@ static void load_interfaces(void)
/* probe the kernel for interfaces */
total_probed = get_interfaces(ifaces, MAX_INTERFACES);
- /* if we don't have a interfaces line then use all broadcast capable
- interfaces except loopback */
+ /* if we don't have a interfaces line then use all interfaces
+ except loopback */
if (!ptr || !*ptr || !**ptr) {
if (total_probed <= 0) {
DEBUG(0,("ERROR: Could not determine network interfaces, you must use a interfaces config line\n"));
}
for (i=0;i<total_probed;i++) {
- if (ifaces[i].netmask.s_addr != ~0 &&
- ifaces[i].ip.s_addr != loopback_ip.addr) {
+ if (ifaces[i].ip.s_addr != loopback_ip.addr) {
add_interface(ifaces[i].ip,
ifaces[i].netmask);
}