summaryrefslogtreecommitdiff
path: root/common/discover.c
diff options
context:
space:
mode:
authorDavid Hankins <dhankins@isc.org>2006-02-27 23:56:13 +0000
committerDavid Hankins <dhankins@isc.org>2006-02-27 23:56:13 +0000
commit25b988c68faa02465ec5d92dd7bb01039839313d (patch)
treea0850459bf30fcc0024b1492834617e2e436ac3c /common/discover.c
parent00663f8159abffa4ce3dbf1e29cbce17fc92a48c (diff)
downloadisc-dhcp-25b988c68faa02465ec5d92dd7bb01039839313d.tar.gz
- The IO system now tracks all local IP addresses, so that the DHCP
applications (particularly the dhcrelay) can discern between what frames were tranmsitted to it, and what frames are being carried through it which it should not intercept. [ISC-Bugs #15573]
Diffstat (limited to 'common/discover.c')
-rw-r--r--common/discover.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/common/discover.c b/common/discover.c
index 16796d78..4d22d149 100644
--- a/common/discover.c
+++ b/common/discover.c
@@ -34,7 +34,7 @@
#ifndef lint
static char copyright[] =
-"$Id: discover.c,v 1.49 2006/02/24 23:16:28 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n";
+"$Id: discover.c,v 1.50 2006/02/27 23:56:13 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -307,8 +307,38 @@ void discover_interfaces (state)
if (foo.sin_addr.s_addr == htonl (INADDR_LOOPBACK) &&
((tmp -> flags & INTERFACE_AUTOMATIC) &&
state == DISCOVER_SERVER))
- continue;
+ continue;
+ /* If the only address we have is 0.0.0.0, we
+ shouldn't consider the interface configured. */
+ if (foo.sin_addr.s_addr != htonl(INADDR_ANY))
+ tmp->configured = 1;
+
+ if (!tmp -> addresses) {
+ tmp -> addresses =
+ dmalloc (10 * sizeof (struct in_addr),
+ MDL);
+ if (!tmp -> addresses)
+ log_fatal ("no memory for ifaddrlist");
+ tmp -> address_count = 0;
+ tmp -> address_max = 10;
+ } else if (tmp -> address_count >= tmp -> address_max) {
+ struct in_addr *ta;
+ int newmax = tmp -> address_max * 2;
+ ta = dmalloc (newmax *
+ sizeof (struct in_addr), MDL);
+ if (!ta)
+ log_fatal ("no memory for new "
+ "ifaddrlist");
+ memcpy (ta, tmp -> addresses,
+ tmp -> address_max *
+ sizeof (struct in_addr));
+ dfree (tmp -> addresses, MDL);
+ tmp -> addresses = ta;
+ tmp -> address_max = newmax;
+ }
+ tmp -> addresses [tmp -> address_count++] =
+ foo.sin_addr;
/* If this is the first real IP address we've
found, keep a pointer to ifreq structure in
@@ -325,7 +355,6 @@ void discover_interfaces (state)
log_fatal ("no space for ifp.");
memcpy (tif, ifp, len);
tmp -> ifp = tif;
- tmp -> primary_address = foo.sin_addr;
}
/* Grab the address... */
@@ -1138,6 +1167,12 @@ void interface_stash (struct interface_info *tptr)
}
interface_vector = vec;
}
+ if (interface_vector [tptr -> index]) {
+ log_fatal("invalid tracefile - two interfaces with "
+ "same index - %s and %s",
+ interface_vector [tptr->index] -> name,
+ tptr -> name);
+ }
interface_reference (&interface_vector [tptr -> index], tptr, MDL);
if (tptr -> index >= interface_count)
interface_count = tptr -> index + 1;