summaryrefslogtreecommitdiff
path: root/source3/nmbd/nmbd_subnetdb.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-10-10 18:25:16 -0700
committerJeremy Allison <jra@samba.org>2007-10-10 18:25:16 -0700
commit8e54530b52fd256137740107e9fdf000f00a7a30 (patch)
treef9ca56cc0b2eff78c3550c924c79ee4ca0666fd2 /source3/nmbd/nmbd_subnetdb.c
parent0ec55a246238b6cfb3727942c20cd55a16ab4d4a (diff)
downloadsamba-8e54530b52fd256137740107e9fdf000f00a7a30.tar.gz
samba-8e54530b52fd256137740107e9fdf000f00a7a30.tar.bz2
samba-8e54530b52fd256137740107e9fdf000f00a7a30.zip
Add start of IPv6 implementation. Currently most of this is avoiding
IPv6 in winbindd, but moves most of the socket functions that were wrongly in lib/util.c into lib/util_sock.c and provides generic IPv4/6 independent versions of most things. Still lots of work to do, but now I can see how I'll fix the access check code. Nasty part that remains is the name resolution code which is used to returning arrays of in_addr structs. Jeremy. (This used to be commit 3f6bd0e1ec5cc6670f3d08f76fc2cd94c9cd1a08)
Diffstat (limited to 'source3/nmbd/nmbd_subnetdb.c')
-rw-r--r--source3/nmbd/nmbd_subnetdb.c50
1 files changed, 33 insertions, 17 deletions
diff --git a/source3/nmbd/nmbd_subnetdb.c b/source3/nmbd/nmbd_subnetdb.c
index 690ca5b621..7fd241cf62 100644
--- a/source3/nmbd/nmbd_subnetdb.c
+++ b/source3/nmbd/nmbd_subnetdb.c
@@ -24,7 +24,6 @@
#include "includes.h"
-extern struct in_addr loopback_ip;
extern int global_nmb_port;
/* This is the broadcast subnets database. */
@@ -169,12 +168,16 @@ static struct subnet_record *make_subnet(const char *name, enum subnet_type type
Create a normal subnet
**************************************************************************/
-struct subnet_record *make_normal_subnet(struct interface *iface)
+struct subnet_record *make_normal_subnet(const struct interface *iface)
{
+
struct subnet_record *subrec;
+ const struct in_addr *pip = &((const struct sockaddr_in *)&iface->ip)->sin_addr;
+ const struct in_addr *pbcast = &((const struct sockaddr_in *)&iface->bcast)->sin_addr;
+ const struct in_addr *pnmask = &((const struct sockaddr_in *)&iface->netmask)->sin_addr;
- subrec = make_subnet(inet_ntoa(iface->ip), NORMAL_SUBNET,
- iface->ip, iface->bcast, iface->nmask);
+ subrec = make_subnet(inet_ntoa(*pip), NORMAL_SUBNET,
+ *pip, *pbcast, *pnmask);
if (subrec) {
add_subnet(subrec);
}
@@ -186,8 +189,9 @@ struct subnet_record *make_normal_subnet(struct interface *iface)
**************************************************************************/
BOOL create_subnets(void)
-{
- int num_interfaces = iface_count();
+{
+ /* We only count IPv4 interfaces whilst we're waiting. */
+ int num_interfaces = iface_count_v4();
int i;
struct in_addr unicast_ip, ipzero;
@@ -197,47 +201,59 @@ BOOL create_subnets(void)
DEBUG(0,("create_subnets: No local interfaces !\n"));
DEBUG(0,("create_subnets: Waiting for an interface to appear ...\n"));
- /*
+ /*
* Whilst we're waiting for an interface, allow SIGTERM to
* cause us to exit.
*/
saved_handler = CatchSignal( SIGTERM, SIGNAL_CAST SIG_DFL );
- while (iface_count() == 0) {
+ /* We only count IPv4 interfaces here. */
+ while (iface_count_v4() == 0) {
sleep(5);
load_interfaces();
}
- /*
+ /*
* We got an interface, restore our normal term handler.
*/
CatchSignal( SIGTERM, SIGNAL_CAST saved_handler );
}
+ /*
+ * Here we count v4 and v6 - we know there's at least one
+ * IPv4 interface and we filter on it below.
+ */
num_interfaces = iface_count();
- /*
+ /*
* Create subnets from all the local interfaces and thread them onto
- * the linked list.
+ * the linked list.
*/
for (i = 0 ; i < num_interfaces; i++) {
- struct interface *iface = get_interface(i);
+ const struct interface *iface = get_interface(i);
if (!iface) {
DEBUG(2,("create_subnets: can't get interface %d.\n", i ));
continue;
}
+ /* Ensure we're only dealing with IPv4 here. */
+ if (iface->ip.ss_family != AF_INET) {
+ DEBUG(2,("create_subnets: "
+ "ignoring non IPv4 interface.\n"));
+ continue;
+ }
+
/*
* We don't want to add a loopback interface, in case
* someone has added 127.0.0.1 for smbd, nmbd needs to
* ignore it here. JRA.
*/
- if (ip_equal(iface->ip, loopback_ip)) {
+ if (is_loopback_addr(&iface->ip)) {
DEBUG(2,("create_subnets: Ignoring loopback interface.\n" ));
continue;
}
@@ -254,8 +270,8 @@ BOOL create_subnets(void)
}
if (lp_we_are_a_wins_server()) {
- /* Pick the first interface ip address as the WINS server ip. */
- struct in_addr *nip = iface_n_ip(0);
+ /* Pick the first interface IPv4 address as the WINS server ip. */
+ const struct in_addr *nip = first_ipv4_iface();
if (!nip) {
return False;
@@ -266,7 +282,7 @@ BOOL create_subnets(void)
/* note that we do not set the wins server IP here. We just
set it at zero and let the wins registration code cope
with getting the IPs right for each packet */
- zero_ip(&unicast_ip);
+ zero_ip_v4(&unicast_ip);
}
/*
@@ -279,7 +295,7 @@ BOOL create_subnets(void)
unicast_subnet = make_subnet( "UNICAST_SUBNET", UNICAST_SUBNET,
unicast_ip, unicast_ip, unicast_ip);
- zero_ip(&ipzero);
+ zero_ip_v4(&ipzero);
remote_broadcast_subnet = make_subnet( "REMOTE_BROADCAST_SUBNET",
REMOTE_BROADCAST_SUBNET,