[SCM] Samba Shared Repository - branch master updated

Andrew Tridgell tridge at samba.org
Sun May 8 05:58:01 MDT 2011


The branch, master has been updated
       via  c596d85 s4-interfaces: keep interfaces in the order they were declared
       via  64adea3 s3-test: build smbtorture with --enable-developer
       via  8a07ec7 lib/socket: Remove outdated comment
       via  22cb631 s4-interfaces Rename interfaces code so not to conflict with source3/
       via  897ef82 s3-lib Use common lib/socket code for get_interfaces() et al
       via  f346a73 lib/socket move interfaces code to the top level
       via  879498b s4-lib/socket Samba4 is not IPv6 compatible
       via  5a8b6ac s4-lib merge get_interfaces() from Samba3 to Samba4
      from  45e26fd s3-smbd: expose smbd_set_server_fd()

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit c596d85afd41c2512ef77a10a9d6b40f4836c386
Author: Andrew Tridgell <tridge at samba.org>
Date:   Sun May 8 12:55:41 2011 +0200

    s4-interfaces: keep interfaces in the order they were declared
    
    the spoolss notify test depends on the interfaces order
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User: Andrew Tridgell <tridge at samba.org>
    Autobuild-Date: Sun May  8 13:57:58 CEST 2011 on sn-devel-104

commit 64adea3d857ac7fcfb86264e877e96a08c7b5aa0
Author: Andrew Tridgell <tridge at samba.org>
Date:   Sun May 8 12:55:00 2011 +0200

    s3-test: build smbtorture with --enable-developer
    
    this makes debugging of tests much easier, as we get debug symbols

commit 8a07ec7babe728adf8a3d590e4c6e6a5d5f66bcd
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue May 3 20:24:39 2011 +1000

    lib/socket: Remove outdated comment
    
    The autoconf and waf tests for interfaces logic are in libreplace now.

commit 22cb631b4fd0647b70fbaaafaffda8712a84a999
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon May 2 15:57:19 2011 +1000

    s4-interfaces Rename interfaces code so not to conflict with source3/
    
    The iface_count, iface_n_bcast, and load_interfaces functions
    conflicted with functions of the same name in source3, so the source4
    functions were renamed.  Hopefully we can actually wrap one around the
    other in future.
    
    Andrew Bartlett

commit 897ef820a40afffbf337b5487a49d957464def67
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon May 2 12:20:21 2011 +1000

    s3-lib Use common lib/socket code for get_interfaces() et al

commit f346a737855bb5018978f0fcf1dcafbf5dc7e603
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon May 2 13:02:17 2011 +1000

    lib/socket move interfaces code to the top level

commit 879498b3622102630a5ade8d7d5421720f6fd7c6
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue May 3 19:41:41 2011 +1000

    s4-lib/socket Samba4 is not IPv6 compatible
    
    Don't add IPv6 interfaces until we actually support them.
    
    I'll soon have IPv6 service at home, and then I'll make it my buisness
    to sort this out once and for all.
    
    Andrew Bartlett

commit 5a8b6ac4c0ea88bdab12349830985560c69cbf8c
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon May 2 12:09:19 2011 +1000

    s4-lib merge get_interfaces() from Samba3 to Samba4

-----------------------------------------------------------------------

Summary of changes:
 {source3/lib => lib/socket}/interfaces.c     |   10 +-
 {source3/include => lib/socket}/interfaces.h |   21 +--
 lib/socket/wscript_build                     |    7 +
 libcli/nbt/tools/nmblookup.c                 |    6 +-
 source3/Makefile-smbtorture4                 |    2 +-
 source3/Makefile.in                          |    2 +-
 source3/lib/access.c                         |    2 +-
 source3/lib/interface.c                      |    2 +-
 source3/lib/util_sock.c                      |    2 +-
 source3/wscript_build                        |    5 +-
 source4/cldap_server/cldap_server.c          |    8 +-
 source4/cldap_server/netlogon.c              |    6 +-
 source4/dns_server/dns_server.c              |    8 +-
 source4/echo_server/echo_server.c            |   10 +-
 source4/kdc/kdc.c                            |    8 +-
 source4/ldap_server/ldap_server.c            |    6 +-
 source4/lib/socket/interface.c               |  273 +++++++++++++++++---------
 source4/lib/socket/netif.c                   |  127 ------------
 source4/lib/socket/netif.h                   |   14 +--
 source4/lib/socket/testsuite.c               |   14 +-
 source4/lib/socket/wscript_build             |   10 +-
 source4/libcli/resolve/bcast.c               |    6 +-
 source4/libcli/resolve/wins.c                |    2 +-
 source4/libcli/wrepl/winsrepl.c              |    4 +-
 source4/nbt_server/interfaces.c              |   16 +-
 source4/nbt_server/nbt_server.c              |    4 +-
 source4/nbt_server/wins/wins_ldb.c           |    4 +-
 source4/nbt_server/wins/winsserver.c         |    6 +-
 source4/rpc_server/dcerpc_server.c           |    6 +-
 source4/scripting/python/pyglue.c            |   12 +-
 source4/smb_server/service_smb.c             |    6 +-
 source4/smb_server/smb_samba3.c              |    6 +-
 source4/torture/nbt/dgram.c                  |   12 +-
 source4/torture/nbt/register.c               |    8 +-
 source4/torture/nbt/wins.c                   |    4 +-
 source4/torture/nbt/winsbench.c              |    4 +-
 source4/torture/nbt/winsreplication.c        |   14 +-
 source4/torture/rpc/spoolss_notify.c         |    4 +-
 source4/web_server/web_server.c              |    6 +-
 source4/wrepl_server/wrepl_in_connection.c   |    6 +-
 source4/wrepl_server/wrepl_server.c          |    4 +-
 wscript_build                                |    1 +
 42 files changed, 321 insertions(+), 357 deletions(-)
 rename {source3/lib => lib/socket}/interfaces.c (96%)
 rename {source3/include => lib/socket}/interfaces.h (79%)
 create mode 100644 lib/socket/wscript_build
 delete mode 100644 source4/lib/socket/netif.c


Changeset truncated at 500 lines:

diff --git a/source3/lib/interfaces.c b/lib/socket/interfaces.c
similarity index 96%
rename from source3/lib/interfaces.c
rename to lib/socket/interfaces.c
index a2dce97..618714d 100644
--- a/source3/lib/interfaces.c
+++ b/lib/socket/interfaces.c
@@ -3,6 +3,7 @@
    return a list of network interfaces
    Copyright (C) Andrew Tridgell 1998
    Copyright (C) Jeremy Allison 2007
+   Copyright (C) Jelmer Vernooij 2007
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -18,8 +19,11 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+
 #include "includes.h"
+#include "system/network.h"
 #include "interfaces.h"
+#include "lib/util/tsort.h"
 
 /****************************************************************************
  Create a struct sockaddr_storage with the netmask bits set to 1.
@@ -81,13 +85,13 @@ static void make_bcast_or_net(struct sockaddr_storage *pss_out,
 #if defined(HAVE_IPV6)
 	if (pss_in->ss_family == AF_INET6) {
 		p = (char *)&((struct sockaddr_in6 *)pss_out)->sin6_addr;
-		pmask = discard_const_p(char, &((const struct sockaddr_in6 *)nmask)->sin6_addr);
+		pmask = discard_const_p(char, &((struct sockaddr_in6 *)nmask)->sin6_addr);
 		len = 16;
 	}
 #endif
 	if (pss_in->ss_family == AF_INET) {
 		p = (char *)&((struct sockaddr_in *)pss_out)->sin_addr;
-		pmask = discard_const_p(char, &((const struct sockaddr_in *)nmask)->sin_addr);
+		pmask = discard_const_p(char, &((struct sockaddr_in *)nmask)->sin_addr);
 		len = 4;
 	}
 
@@ -115,6 +119,7 @@ void make_net(struct sockaddr_storage *pss_out,
 	make_bcast_or_net(pss_out, pss_in, nmask, false);
 }
 
+
 /****************************************************************************
  Try the "standard" getifaddrs/freeifaddrs interfaces.
  Also gets IPv6 interfaces.
@@ -296,4 +301,3 @@ int get_interfaces(TALLOC_CTX *mem_ctx, struct iface_struct **pifaces)
 	*pifaces = ifaces;
 	return total;
 }
-
diff --git a/source3/include/interfaces.h b/lib/socket/interfaces.h
similarity index 79%
rename from source3/include/interfaces.h
rename to lib/socket/interfaces.h
index 6ba0e21..b4e113d 100644
--- a/source3/include/interfaces.h
+++ b/lib/socket/interfaces.h
@@ -1,7 +1,9 @@
 /*
    Unix SMB/CIFS implementation.
-   Machine customisation and include handling
-   Copyright (C) Jeremy Allison <jra at samba.org> 2007
+
+   structures for lib/netif/
+
+   Copyright (C) Andrew Tridgell 2004
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -16,16 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
-/*
-   This structure is used by lib/interfaces.c to return the list of network
-   interfaces on the machine
-*/
 
-#ifndef _INTERFACES_H
-#define _INTERFACES_H
-
-#include "../replace/replace.h"
-#include "../replace/system/network.h"
+#include "system/network.h"
 
 struct iface_struct {
 	char name[16];
@@ -35,6 +29,8 @@ struct iface_struct {
 	struct sockaddr_storage bcast;
 };
 
+struct interface;
+
 bool make_netmask(struct sockaddr_storage *pss_out,
 		  const struct sockaddr_storage *pss_in,
 		  unsigned long masklen);
@@ -44,6 +40,5 @@ void make_bcast(struct sockaddr_storage *pss_out,
 void make_net(struct sockaddr_storage *pss_out,
 	      const struct sockaddr_storage *pss_in,
 	      const struct sockaddr_storage *nmask);
-int get_interfaces(TALLOC_CTX *mem_ctx, struct iface_struct **pifaces);
 
-#endif
+int get_interfaces(TALLOC_CTX *mem_ctx, struct iface_struct **pifaces);
diff --git a/lib/socket/wscript_build b/lib/socket/wscript_build
new file mode 100644
index 0000000..61bde12
--- /dev/null
+++ b/lib/socket/wscript_build
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+
+bld.SAMBA_LIBRARY('interfaces',
+    source='interfaces.c',
+    deps='samba-util',
+    private_library=True
+    )
diff --git a/libcli/nbt/tools/nmblookup.c b/libcli/nbt/tools/nmblookup.c
index 7950ab8..f6117f2 100644
--- a/libcli/nbt/tools/nmblookup.c
+++ b/libcli/nbt/tools/nmblookup.c
@@ -246,9 +246,9 @@ static bool process_one(struct loadparm_context *lp_ctx, struct tevent_context *
 	} else {
 		int i, num_interfaces;
 
-		num_interfaces = iface_count(ifaces);
+		num_interfaces = iface_list_count(ifaces);
 		for (i=0;i<num_interfaces;i++) {
-			const char *bcast = iface_n_bcast(ifaces, i);
+			const char *bcast = iface_list_n_bcast(ifaces, i);
 			if (bcast == NULL) continue;
 			status = do_node_query(nbtsock, bcast, nbt_port, 
 					       node_name, node_type, true);
@@ -357,7 +357,7 @@ int main(int argc, const char *argv[])
 		exit(1);
 	}
 
-	load_interfaces(NULL, lpcfg_interfaces(cmdline_lp_ctx), &ifaces);
+	load_interface_list(NULL, lpcfg_interfaces(cmdline_lp_ctx), &ifaces);
 
 	ev = s4_event_context_init(talloc_autofree_context());
 
diff --git a/source3/Makefile-smbtorture4 b/source3/Makefile-smbtorture4
index 3e23b05..355c146 100644
--- a/source3/Makefile-smbtorture4
+++ b/source3/Makefile-smbtorture4
@@ -6,7 +6,7 @@ SAMBA4_BINARIES="smbtorture,ndrdump"
 samba4-configure:
 	@(cd .. && \
 		CFLAGS='' $(WAF) reconfigure || \
-		CFLAGS='' $(WAF) configure --enable-socket-wrapper --enable-nss-wrapper --enable-uid-wrapper --nonshared-binary=$(SAMBA4_BINARIES) --enable-auto-reconfigure --disable-s3build)
+		CFLAGS='' $(WAF) configure --enable-socket-wrapper --enable-nss-wrapper --enable-uid-wrapper --nonshared-binary=$(SAMBA4_BINARIES) --enable-auto-reconfigure --disable-s3build --enable-developer)
 
 .PHONY: samba4-configure
 
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 9dfeb7f..456d4f5 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -440,7 +440,7 @@ CRYPTO_OBJ = ../lib/crypto/crc32.o ../lib/crypto/md5.o \
 LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) \
 	  lib/messages.o librpc/gen_ndr/ndr_messaging.o lib/messages_local.o \
 	  lib/messages_ctdbd.o lib/ctdb_packet.o lib/ctdbd_conn.o \
-	  lib/interfaces.o lib/memcache.o \
+	  ../lib/socket/interfaces.o lib/memcache.o \
 	  lib/talloc_dict.o \
 	  lib/serverid.o \
 	  lib/util_sconn.o \
diff --git a/source3/lib/access.c b/source3/lib/access.c
index f9cd9d5..044c079 100644
--- a/source3/lib/access.c
+++ b/source3/lib/access.c
@@ -12,7 +12,7 @@
 
 #include "includes.h"
 #include "memcache.h"
-#include "interfaces.h"
+#include "lib/socket/interfaces.h"
 
 #define NAME_INDEX 0
 #define ADDR_INDEX 1
diff --git a/source3/lib/interface.c b/source3/lib/interface.c
index ac68324..39dc9cb 100644
--- a/source3/lib/interface.c
+++ b/source3/lib/interface.c
@@ -19,7 +19,7 @@
 */
 
 #include "includes.h"
-#include "interfaces.h"
+#include "lib/socket/interfaces.h"
 
 static struct iface_struct *probed_ifaces;
 static int total_probed;
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 922213d..371b8c0 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -24,7 +24,7 @@
 #include "memcache.h"
 #include "../lib/async_req/async_sock.h"
 #include "../lib/util/select.h"
-#include "interfaces.h"
+#include "lib/socket/interfaces.h"
 #include "../lib/util/tevent_unix.h"
 #include "../lib/util/tevent_ntstatus.h"
 
diff --git a/source3/wscript_build b/source3/wscript_build
index 0498a9a..149b5c5 100755
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -60,7 +60,7 @@ REG_PARSE_PRS_SRC = '''registry/reg_parse_prs.c'''
 LIB_SRC = '''
           lib/messages.c lib/messages_local.c
           lib/messages_ctdbd.c lib/ctdb_packet.c lib/ctdbd_conn.c
-          lib/interfaces.c lib/memcache.c
+          lib/memcache.c
           lib/talloc_dict.c
           lib/util_sconn.c
           lib/serverid.c
@@ -780,7 +780,7 @@ bld.SAMBA3_SUBSYSTEM('KRBCLIENT',
 
 bld.SAMBA3_LIBRARY('samba3core',
                    source=LIB_SRC,
-                   deps='LIBCRYPTO ndr ndr-util security NDR_SECURITY charset NDR_MESSAGING LIBASYNC_REQ tdb-wrap3 CHARSET3 UTIL_TDB UTIL_PW SAMBA_VERSION KRB5_WRAP flag_mapping util_reg passdb PTHREADPOOL',
+                   deps='LIBCRYPTO ndr ndr-util security NDR_SECURITY charset NDR_MESSAGING LIBASYNC_REQ tdb-wrap3 CHARSET3 UTIL_TDB UTIL_PW SAMBA_VERSION KRB5_WRAP flag_mapping util_reg passdb PTHREADPOOL interfaces',
                    private_library=True,
                    vars=locals())
 
@@ -1331,6 +1331,7 @@ bld.RECURSE('../auth')
 bld.RECURSE('../auth/kerberos')
 bld.RECURSE('../lib/addns')
 bld.RECURSE('../lib/async_req')
+bld.RECURSE('../lib/socket')
 bld.RECURSE('../libcli/auth')
 bld.RECURSE('../libcli/drsuapi')
 bld.RECURSE('../libcli/ldap')
diff --git a/source4/cldap_server/cldap_server.c b/source4/cldap_server/cldap_server.c
index 43eadf5..8e79af4 100644
--- a/source4/cldap_server/cldap_server.c
+++ b/source4/cldap_server/cldap_server.c
@@ -153,7 +153,7 @@ static NTSTATUS cldapd_startup_interfaces(struct cldapd_server *cldapd, struct l
 	TALLOC_CTX *tmp_ctx = talloc_new(cldapd);
 	NTSTATUS status;
 
-	num_interfaces = iface_count(ifaces);
+	num_interfaces = iface_list_count(ifaces);
 
 	/* if we are allowing incoming packets from any address, then
 	   we need to bind to the wildcard address */
@@ -165,7 +165,7 @@ static NTSTATUS cldapd_startup_interfaces(struct cldapd_server *cldapd, struct l
 	/* now we have to also listen on the specific interfaces,
 	   so that replies always come from the right IP */
 	for (i=0; i<num_interfaces; i++) {
-		const char *address = talloc_strdup(tmp_ctx, iface_n_ip(ifaces, i));
+		const char *address = talloc_strdup(tmp_ctx, iface_list_n_ip(ifaces, i));
 		status = cldapd_add_socket(cldapd, lp_ctx, address);
 		NT_STATUS_NOT_OK_RETURN(status);
 	}
@@ -184,9 +184,9 @@ static void cldapd_task_init(struct task_server *task)
 	NTSTATUS status;
 	struct interface *ifaces;
 	
-	load_interfaces(task, lpcfg_interfaces(task->lp_ctx), &ifaces);
+	load_interface_list(task, lpcfg_interfaces(task->lp_ctx), &ifaces);
 
-	if (iface_count(ifaces) == 0) {
+	if (iface_list_count(ifaces) == 0) {
 		task_server_terminate(task, "cldapd: no network interfaces configured", false);
 		return;
 	}
diff --git a/source4/cldap_server/netlogon.c b/source4/cldap_server/netlogon.c
index 6e455e4..3f3da8b 100644
--- a/source4/cldap_server/netlogon.c
+++ b/source4/cldap_server/netlogon.c
@@ -291,16 +291,16 @@ NTSTATUS fill_netlogon_samlogon_response(struct ldb_context *sam_ctx,
 	client_site      = samdb_client_site_name(sam_ctx, mem_ctx,
 						  src_address, NULL);
 	NT_STATUS_HAVE_NO_MEMORY(client_site);
-	load_interfaces(mem_ctx, lpcfg_interfaces(lp_ctx), &ifaces);
+	load_interface_list(mem_ctx, lpcfg_interfaces(lp_ctx), &ifaces);
 	/*
 	 * TODO: the caller should pass the address which the client
 	 * used to trigger this call, as the client is able to reach
 	 * this ip.
 	 */
 	if (src_address) {
-		pdc_ip = iface_best_ip(ifaces, src_address);
+		pdc_ip = iface_list_best_ip(ifaces, src_address);
 	} else {
-		pdc_ip = iface_n_ip(ifaces, 0);
+		pdc_ip = iface_list_n_ip(ifaces, 0);
 	}
 	ZERO_STRUCTP(netlogon);
 
diff --git a/source4/dns_server/dns_server.c b/source4/dns_server/dns_server.c
index 0e5def1..2c0a379 100644
--- a/source4/dns_server/dns_server.c
+++ b/source4/dns_server/dns_server.c
@@ -559,10 +559,10 @@ static NTSTATUS dns_startup_interfaces(struct dns_server *dns, struct loadparm_c
 		return NT_STATUS_INTERNAL_ERROR;
 	}
 
-	num_interfaces = iface_count(ifaces);
+	num_interfaces = iface_list_count(ifaces);
 
 	for (i=0; i<num_interfaces; i++) {
-		const char *address = talloc_strdup(tmp_ctx, iface_n_ip(ifaces, i));
+		const char *address = talloc_strdup(tmp_ctx, iface_list_n_ip(ifaces, i));
 
 		status = dns_add_socket(dns, model_ops, "dns", address, DNS_SERVICE_PORT);
 		NT_STATUS_NOT_OK_RETURN(status);
@@ -617,9 +617,9 @@ static void dns_task_init(struct task_server *task)
 		break;
 	}
 
-	load_interfaces(task, lpcfg_interfaces(task->lp_ctx), &ifaces);
+	load_interface_list(task, lpcfg_interfaces(task->lp_ctx), &ifaces);
 
-	if (iface_count(ifaces) == 0) {
+	if (iface_list_count(ifaces) == 0) {
 		task_server_terminate(task, "dns: no network interfaces configured", false);
 		return;
 	}
diff --git a/source4/echo_server/echo_server.c b/source4/echo_server/echo_server.c
index 4be6f21..2a4a0bb 100644
--- a/source4/echo_server/echo_server.c
+++ b/source4/echo_server/echo_server.c
@@ -25,7 +25,7 @@
 #include "param/param.h"
 /* This defines task_server_terminate */
 #include "smbd/process_model.h"
-/* We get load_interfaces from here */
+/* We get load_interface_list from here */
 #include "socket/netif.h"
 /* NTSTATUS-related stuff */
 #include "libcli/util/ntstatus.h"
@@ -269,10 +269,10 @@ static NTSTATUS echo_startup_interfaces(struct echo_server *echo,
 		return NT_STATUS_INTERNAL_ERROR;
 	}
 
-	num_interfaces = iface_count(ifaces);
+	num_interfaces = iface_list_count(ifaces);
 
 	for(i=0; i<num_interfaces; i++) {
-		const char *address = talloc_strdup(tmp_ctx, iface_n_ip(ifaces, i));
+		const char *address = talloc_strdup(tmp_ctx, iface_list_n_ip(ifaces, i));
 
 		status = echo_add_socket(echo, model_ops, "echo", address, ECHO_SERVICE_PORT);
 		NT_STATUS_NOT_OK_RETURN(status);
@@ -308,9 +308,9 @@ static void echo_task_init(struct task_server *task)
 		break;
 	}
 
-	load_interfaces(task, lpcfg_interfaces(task->lp_ctx), &ifaces);
+	load_interface_list(task, lpcfg_interfaces(task->lp_ctx), &ifaces);
 
-	if (iface_count(ifaces) == 0) {
+	if (iface_list_count(ifaces) == 0) {
 		task_server_terminate(task,
 				      "echo: No network interfaces configured",
 				      false);
diff --git a/source4/kdc/kdc.c b/source4/kdc/kdc.c
index 784b98b..02c6f92 100644
--- a/source4/kdc/kdc.c
+++ b/source4/kdc/kdc.c
@@ -729,7 +729,7 @@ static NTSTATUS kdc_startup_interfaces(struct kdc_server *kdc, struct loadparm_c
 		return NT_STATUS_INTERNAL_ERROR;
 	}
 
-	num_interfaces = iface_count(ifaces);
+	num_interfaces = iface_list_count(ifaces);
 
 	/* if we are allowing incoming packets from any address, then
 	   we need to bind to the wildcard address */
@@ -751,7 +751,7 @@ static NTSTATUS kdc_startup_interfaces(struct kdc_server *kdc, struct loadparm_c
 	}
 
 	for (i=0; i<num_interfaces; i++) {
-		const char *address = talloc_strdup(tmp_ctx, iface_n_ip(ifaces, i));
+		const char *address = talloc_strdup(tmp_ctx, iface_list_n_ip(ifaces, i));
 
 		if (kdc_port) {
 			status = kdc_add_socket(kdc, model_ops,
@@ -895,9 +895,9 @@ static void kdc_task_init(struct task_server *task)
 		break;
 	}
 
-	load_interfaces(task, lpcfg_interfaces(task->lp_ctx), &ifaces);
+	load_interface_list(task, lpcfg_interfaces(task->lp_ctx), &ifaces);
 
-	if (iface_count(ifaces) == 0) {
+	if (iface_list_count(ifaces) == 0) {
 		task_server_terminate(task, "kdc: no network interfaces configured", false);
 		return;
 	}
diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c
index 25dfadb..01846ad 100644
--- a/source4/ldap_server/ldap_server.c
+++ b/source4/ldap_server/ldap_server.c
@@ -951,15 +951,15 @@ static void ldapsrv_task_init(struct task_server *task)
 		int num_interfaces;
 		int i;
 
-		load_interfaces(task, lpcfg_interfaces(task->lp_ctx), &ifaces);
-		num_interfaces = iface_count(ifaces);
+		load_interface_list(task, lpcfg_interfaces(task->lp_ctx), &ifaces);
+		num_interfaces = iface_list_count(ifaces);
 
 		/* We have been given an interfaces line, and been 
 		   told to only bind to those interfaces. Create a
 		   socket per interface and bind to only these.
 		*/
 		for(i = 0; i < num_interfaces; i++) {
-			const char *address = iface_n_ip(ifaces, i);
+			const char *address = iface_list_n_ip(ifaces, i);
 			status = add_socket(task, task->lp_ctx, model_ops, address, ldap_service);
 			if (!NT_STATUS_IS_OK(status)) goto failed;
 		}
diff --git a/source4/lib/socket/interface.c b/source4/lib/socket/interface.c
index c4411b6..b762f55 100644
--- a/source4/lib/socket/interface.c
+++ b/source4/lib/socket/interface.c
@@ -25,11 +25,14 @@
 #include "../lib/util/util_net.h"
 #include "../lib/util/dlinklist.h"
 
-/** used for network interfaces */
+/* used for network interfaces */
 struct interface {
 	struct interface *next, *prev;
-	struct in_addr ip;
-	struct in_addr nmask;
+	char *name;
+	int flags;
+	struct sockaddr_storage ip;
+	struct sockaddr_storage netmask;
+	struct sockaddr_storage bcast;
 	const char *ip_s;
 	const char *bcast_s;
 	const char *nmask_s;
@@ -45,31 +48,51 @@ struct interface {
 /****************************************************************************
 Try and find an interface that matches an ip. If we cannot, return NULL
   **************************************************************************/
-static struct interface *iface_find(struct interface *interfaces, 
-				    struct in_addr ip, bool CheckMask)
+static struct interface *iface_list_find(struct interface *interfaces,
+					 const struct sockaddr *ip,
+					 bool check_mask)
 {
 	struct interface *i;
-	if (is_zero_ip_v4(ip)) return interfaces;
 
-	for (i=interfaces;i;i=i->next)
-		if (CheckMask) {
-			if (same_net_v4(i->ip,ip,i->nmask)) return i;
-		} else if (i->ip.s_addr == ip.s_addr) return i;
+	if (is_address_any(ip)) {
+		return interfaces;
+	}
+
+	for (i=interfaces;i;i=i->next) {
+		if (check_mask) {
+			if (same_net(ip, (struct sockaddr *)&i->ip, (struct sockaddr *)&i->netmask)) {
+				return i;
+			}
+		} else if (sockaddr_equal((struct sockaddr *)&i->ip, ip)) {
+			return i;
+		}
+	}
 
 	return NULL;
 }
 
-
 /****************************************************************************
 add an interface to the linked list of interfaces
 ****************************************************************************/
-static void add_interface(TALLOC_CTX *mem_ctx, struct in_addr ip, struct in_addr nmask, struct interface **interfaces)
+static void add_interface(TALLOC_CTX *mem_ctx, const struct iface_struct *ifs, struct interface **interfaces)
 {
+	char addr[INET6_ADDRSTRLEN];
 	struct interface *iface;
-	struct in_addr bcast;
 
-	if (iface_find(*interfaces, ip, false)) {
-		DEBUG(3,("not adding duplicate interface %s\n",inet_ntoa(ip)));
+	if (iface_list_find(*interfaces, (const struct sockaddr *)&ifs->ip, false)) {
+		DEBUG(3,("add_interface: not adding duplicate interface %s\n",
+			print_sockaddr(addr, sizeof(addr), &ifs->ip) ));
+		return;
+	}
+


-- 
Samba Shared Repository


More information about the samba-cvs mailing list