]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Removing the new I/O changes from HEAD. [ISC-Bugs #16328]
authorDavid Hankins <dhankins@isc.org>
Wed, 9 Aug 2006 14:57:48 +0000 (14:57 +0000)
committerDavid Hankins <dhankins@isc.org>
Wed, 9 Aug 2006 14:57:48 +0000 (14:57 +0000)
RELNOTES
client/dhclient.c
common/ctrace.c
common/discover.c
common/packet.c
includes/dhcpd.h
relay/dhcrelay.8
relay/dhcrelay.c
server/bootp.c
server/dhcp.c

index c71c44c2f4457ebe73427b759118992e05036bd7..20d56f0b0794aaa8455b059e6f6e429f17893da8 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -47,11 +47,6 @@ the README file.
 
 - RFC3942 compliance, site-local option spaces start at 224 now, not 128.
 
-- 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.
-
 - The Load Balance Algorithm was misimplemented.  The current implementation
   matches RFC 3074.
 
index 53ac8317a1552ec614ebe6e65a0fa8cc85eb43dc..db60ca5b54722798d7c7deb0cff54f2a158f9393 100644 (file)
@@ -32,7 +32,7 @@
 
 #ifndef lint
 static char ocopyright[] =
-"$Id: dhclient.c,v 1.142 2006/07/19 17:14:55 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium.  All rights reserved.\n";
+"$Id: dhclient.c,v 1.143 2006/08/09 14:57:47 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -231,8 +231,6 @@ int main (argc, argv, envp)
                }
        }
 
-       limited_broadcast.s_addr = INADDR_BROADCAST;
-
        if (!no_dhclient_conf && (s = getenv ("PATH_DHCLIENT_CONF"))) {
                path_dhclient_conf = s;
        }
index 5e8bcc09f1ef58850e47fda3d1ad01640f06e5d6..8bcb96741e2a41a926f6b634cac773775d004bc3 100644 (file)
@@ -32,7 +32,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: ctrace.c,v 1.5 2006/02/27 23:56:13 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium.  All rights reserved.\n";
+"$Id: ctrace.c,v 1.6 2006/08/09 14:57:47 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -46,10 +46,8 @@ void trace_interface_register (trace_type_t *ttype, struct interface_info *ip)
                memset (&tipkt, 0, sizeof tipkt);
                memcpy (&tipkt.hw_address,
                        &ip -> hw_address, sizeof ip -> hw_address);
-               if (ip -> address_count > 0)
-                       memcpy (&tipkt.primary_address,
-                               &ip -> addresses [0],
-                               sizeof ip -> addresses [0]);
+               memcpy (&tipkt.primary_address,
+                       &ip -> primary_address, sizeof ip -> primary_address);
                memcpy (tipkt.name, ip -> name, sizeof ip -> name);
                tipkt.index = htonl (ip -> index);
 
@@ -89,12 +87,8 @@ void trace_interface_input (trace_type_t *ttype, unsigned len, char *buf)
 
        memcpy (&ip -> hw_address, &tipkt -> hw_address,
                sizeof ip -> hw_address);
-       ip -> address_count = ip -> address_max = 1;
-       ip -> addresses = dmalloc (sizeof (struct in_addr), MDL);
-       if (!ip -> addresses)
-               log_fatal ("Can't allocate address buffer for trace interface");
-       memcpy (&ip -> addresses [0], &tipkt -> primary_address,
-               sizeof ip -> addresses [0]);
+       memcpy (&ip -> primary_address, &tipkt -> primary_address,
+               sizeof ip -> primary_address);
        memcpy (ip -> name, tipkt -> name, sizeof ip -> name);
        ip -> index = ntohl (tipkt -> index);
 
@@ -108,7 +102,7 @@ void trace_interface_input (trace_type_t *ttype, unsigned len, char *buf)
        ip -> ifp -> ifr_addr.sa_len = sizeof (struct sockaddr_in);
 #endif
        sin = (struct sockaddr_in *)&ip -> ifp -> ifr_addr;
-       sin -> sin_addr = ip -> addresses [0];
+       sin -> sin_addr = ip -> primary_address;
 
        addr.len = 4;
        memcpy (addr.iabuf, &sin -> sin_addr.s_addr, addr.len);
index 4d22d149ed5c598364efa3bfa7a8abeccf2643c2..c22a2a66e73064e0b3d6053674bc1534f9b9f854 100644 (file)
@@ -34,7 +34,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$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";
+"$Id: discover.c,v 1.51 2006/08/09 14:57:47 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -307,38 +307,8 @@ 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
@@ -355,6 +325,7 @@ 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... */
@@ -1167,12 +1138,6 @@ 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;
index 7614f57610f1ff7c95d124877b589688226c143a..a6e8e56736b012e35eb17f9fbaf6cf3cc6b1f2b1 100644 (file)
@@ -33,7 +33,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: packet.c,v 1.44 2006/07/19 18:00:36 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium.  All rights reserved.\n";
+"$Id: packet.c,v 1.45 2006/08/09 14:57:47 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -231,8 +231,6 @@ ssize_t decode_udp_ip_header (interface, buf, bufix, from, buflen)
   unsigned len;
   unsigned ulen;
   int ignore = 0;
-  struct interface_info *ii;
-  int i;
 
   memcpy(&ip, buf + bufix, sizeof (struct ip));
   udp = (struct udphdr *)(buf + bufix + ip_len);
@@ -247,38 +245,6 @@ ssize_t decode_udp_ip_header (interface, buf, bufix, from, buflen)
          return -1;
 #endif /* USERLAND_FILTER */
 
-  /* Eliminate packets that we might have accidentally intercepted because
-     we are doing routing. */
-
-  /* The DHCP client may not have an IP address; in that case, if we
-     got the packet, we need to look at it.   So if address_count is
-     zero on the interface on which we received the packet, accept the
-     packet. */
-  if (!interface -> configured)
-       goto good;
-
-  /* XXX we should handle subnet broadcast addresses here. */
-  /* XXX we should compare against 255.255.255.255, not limited_broadcast,
-     XXX because sometimes we tweak limited_broadcast for debugging.
-     XXX This is only currently a problem on the server. */
-  if (ip.ip_dst.s_addr == limited_broadcast.s_addr)
-         goto good;
-         
-  /* Check IP addresses of _all_ interfaces - it's perfectly okay to send
-     a packet to an IP address on one interface that happens to arrive
-     through another interface. */
-  /* XXX if the user excluded some interfaces, we will not accept packets
-     XXX for those interfaces. */
-  for (ii = interfaces; ii; ii = ii -> next) {
-         for (i = 0; i < ii -> address_count; i++) {
-                 if (ii -> addresses [i].s_addr == ip.ip_dst.s_addr)
-                         goto good;
-         }
-  }
-  /* The IP destination address didn't match any of our addresses. */
-  return -1;
-
- good:
   ulen = ntohs (udp -> uh_ulen);
   if (ulen < sizeof *udp ||
       ((unsigned char *)udp) + ulen > buf + bufix + buflen) {
index 5d1bdabefbecb3db936b55d3bceed392b8616c6c..49115e3ce29dbc046658547b8e0b4984e65fb292 100644 (file)
@@ -870,12 +870,6 @@ struct client_state {
        struct option_state *sent_options;      /* Options we sent. */
 };
 
-/* Relay agent server list. */
-struct server_list {
-       struct server_list *next;
-       struct sockaddr_in to;
-} *servers;
-
 /* Information about each network interface. */
 
 struct interface_info {
@@ -884,12 +878,7 @@ struct interface_info {
        struct shared_network *shared_network;
                                /* Networks connected to this interface. */
        struct hardware hw_address;     /* Its physical address. */
-       struct in_addr *addresses;      /* Addresses associated with
-                                          interface. */
-       int address_count;              /* Number of addresses associated with
-                                          interface. */
-       int address_max;                /* Max number of addresses we can
-                                          store in current buffer. */
+       struct in_addr primary_address; /* Primary interface address. */
 
        u_int8_t *circuit_id;           /* Circuit ID associated with this
                                           interface. */
@@ -898,8 +887,6 @@ struct interface_info {
        u_int8_t *remote_id;            /* Remote ID associated with this
                                           interface (if any). */
        unsigned remote_id_len;         /* Length of Remote ID. */
-       struct server_list *servers;    /* List of relay servers for this
-                                          interface. */
 
        char name [IFNAMSIZ];           /* Its name... */
        int index;                      /* Its index. */
@@ -912,9 +899,6 @@ struct interface_info {
        size_t rbuf_len;                /* Length of data in buffer. */
 
        struct ifreq *ifp;              /* Pointer to ifreq struct. */
-       int configured;                 /* If set to 1, interface has at
-                                        * least one valid IP address.
-                                        */
        u_int32_t flags;                /* Control flags... */
 #define INTERFACE_REQUESTED 1
 #define INTERFACE_AUTOMATIC 2
@@ -2162,7 +2146,6 @@ int parse_ip_addr_with_subnet(struct parse *, struct iaddrmatch *);
 void parse_reject_statement PROTO ((struct parse *, struct client_config *));
 
 /* dhcrelay.c */
-void new_relay_server (char *, struct server_list **);
 void relay PROTO ((struct interface_info *, struct dhcp_packet *, unsigned,
                   unsigned int, struct iaddr, struct hardware *));
 int strip_relay_agent_options PROTO ((struct interface_info *,
index 1e0a9a9c2b609d4b258bc4df8759279398ff58df..238b16dabc18ee80ce3a4bacfc4902be3ce70974 100644 (file)
@@ -27,7 +27,7 @@
 .\" see ``http://www.isc.org/isc''.  To learn more about Vixie
 .\" Enterprises, see ``http://www.vix.com''.
 .\"
-.\" $Id: dhcrelay.8,v 1.11 2006/02/27 23:56:13 dhankins Exp $
+.\" $Id: dhcrelay.8,v 1.12 2006/08/09 14:57:48 dhankins Exp $
 .\"
 .TH dhcrelay 8
 .SH NAME
@@ -48,11 +48,6 @@ dhcrelay - Dynamic Host Configuration Protocol Relay Agent
 .B -i
 .I if0
 [
-.B -is
-.I server
-...
-]
-[
 .B ...
 .B -i
 .I ifN
@@ -119,11 +114,6 @@ server) is attached.   However, in some cases it may be necessary to
 exclude some networks; in this case, you must list all those network
 interfaces that should \fInot\fR be excluded using the \fB-i\fR flag.
 .PP
-The
-.B -is
-flag can be used to indicate that for the previous interface specified with
--i, packets should be forwarded to the specified server.
-.PP
 In some cases it
 .I is
 helpful for the relay agent to forward requests from networks on which
index 859fcf0f6c7ee5e70a9e5b20b21f640229893b92..8465b03bcf951ae3d7718d7cae2a19b019e45f5c 100644 (file)
@@ -34,7 +34,7 @@
 
 #ifndef lint
 static char ocopyright[] =
-"$Id: dhcrelay.c,v 1.58 2006/05/11 14:48:59 shane Exp $ Copyright (c) 2004-2006 Internet Systems Consortium.  All rights reserved.\n";
+"$Id: dhcrelay.c,v 1.59 2006/08/09 14:57:48 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -92,6 +92,12 @@ enum { forward_and_append,   /* Forward and append our own relay option. */
 u_int16_t local_port;
 u_int16_t remote_port;
 
+/* Relay agent server list. */
+struct server_list {
+       struct server_list *next;
+       struct sockaddr_in to;
+} *servers;
+
 static char copyright [] = "Copyright 2004-2006 Internet Systems Consortium.";
 static char arr [] = "All rights reserved.";
 static char message [] = "Internet Systems Consortium DHCP Relay Agent";
@@ -104,12 +110,11 @@ int main (argc, argv, envp)
        int fd;
        int i;
        struct servent *ent;
-       struct server_list *sp = (struct server_list *)0;
+       struct server_list *sp = NULL;
        int no_daemon = 0;
        int quiet = 0;
        isc_result_t status;
        char *s;
-       struct interface_info *tmp = (struct interface_info *)0;
 
         /* Make sure that file descriptors 0 (stdin), 1, (stdout), and
            2 (stderr) are open. To do this, we assume that when we
@@ -154,8 +159,8 @@ int main (argc, argv, envp)
                } else if (!strcmp (argv [i], "-d")) {
                        no_daemon = 1;
                } else if (!strcmp (argv [i], "-i")) {
-                       if (tmp)
-                               interface_dereference (&tmp, MDL);
+                       struct interface_info *tmp =
+                               (struct interface_info *)0;
                        status = interface_allocate (&tmp, MDL);
                        if (status != ISC_R_SUCCESS)
                                log_fatal ("%s: interface_allocate: %s",
@@ -166,14 +171,7 @@ int main (argc, argv, envp)
                        }
                        strcpy (tmp -> name, argv [i]);
                        interface_snorf (tmp, INTERFACE_REQUESTED);
-               } else if (!strcmp (argv [i], "-is")) {
-                       if (++i == argc)
-                               usage ();
-                       if (!tmp) {
-                               log_error ("-is must follow -i.");
-                               usage ();
-                       }
-                       new_relay_server (argv [i], &tmp -> servers);
+                       interface_dereference (&tmp, MDL);
                } else if (!strcmp (argv [i], "-q")) {
                        quiet = 1;
                        quiet_interface_discovery = 1;
@@ -213,15 +211,33 @@ int main (argc, argv, envp)
                        log_info ("isc-dhcrelay-%s", DHCP_VERSION);
                        exit (0);
                } else {
-                       new_relay_server (argv [i], &servers);
+                       struct hostent *he;
+                       struct in_addr ia, *iap = (struct in_addr *)0;
+                       if (inet_aton (argv [i], &ia)) {
+                               iap = &ia;
+                       } else {
+                               he = gethostbyname (argv [i]);
+                               if (!he) {
+                                       log_error ("%s: host unknown",
+                                                  argv [i]);
+                               } else {
+                                       iap = ((struct in_addr *)
+                                              he -> h_addr_list [0]);
+                               }
+                       }
+                       if (iap) {
+                               sp = ((struct server_list *)
+                                     dmalloc (sizeof *sp, MDL));
+                               if (!sp)
+                                       log_fatal ("no memory for server.\n");
+                               sp -> next = servers;
+                               servers = sp;
+                               memcpy (&sp -> to.sin_addr,
+                                       iap, sizeof *iap);
+                       }
                }
        }
 
-       limited_broadcast.s_addr = INADDR_BROADCAST;
-
-       if (tmp)
-               interface_dereference (&tmp, MDL);
-
        if ((s = getenv ("PATH_DHCRELAY_PID"))) {
                path_dhcrelay_pid = s;
        }
@@ -248,7 +264,7 @@ int main (argc, argv, envp)
        remote_port = htons (ntohs (local_port) + 1);
   
        /* We need at least one server. */
-       if (!servers) {
+       if (!sp) {
                usage ();
        }
 
@@ -261,29 +277,6 @@ int main (argc, argv, envp)
 #endif
        }
 
-       if (interfaces) {
-               interface_reference (&tmp, interfaces, MDL);
-               do {
-                       struct interface_info *next = NULL;
-                       if (tmp -> next)
-                               interface_reference (&next, tmp -> next, MDL);
-               
-                       for (sp = tmp -> servers; sp; sp = sp -> next) {
-                               sp -> to.sin_port = local_port;
-                               sp -> to.sin_family = AF_INET;
-#ifdef HAVE_SA_LEN
-                               sp -> to.sin_len = sizeof sp -> to;
-#endif
-                       }
-
-                       interface_dereference (&tmp, MDL);
-                       if (next) {
-                               interface_reference (&tmp, next, MDL);
-                               interface_dereference (&next, MDL);
-                       }
-               } while (tmp);
-       }
-
        /* Get the current time... */
        GET_TIME (&cur_time);
 
@@ -335,36 +328,6 @@ int main (argc, argv, envp)
        return 0;
 }
 
-void new_relay_server (char *arg, struct server_list **servers)
-{
-       struct hostent *he;
-       struct in_addr ia, *iap = (struct in_addr *)0;
-       struct server_list *sp;
-
-       if (inet_aton (arg, &ia)) {
-               iap = &ia;
-       } else {
-               he = gethostbyname (arg);
-               if (!he) {
-                       log_error ("%s: host unknown", arg);
-               } else {
-                       iap = ((struct in_addr *)
-                              he -> h_addr_list [0]);
-               }
-       }
-       if (iap) {
-               sp = ((struct server_list *)
-                     dmalloc (sizeof *sp, MDL));
-               if (!sp)
-                       log_fatal ("no memory for server.\n");
-               memset(sp, 0, sizeof *sp);
-               sp -> next = *servers;
-               *servers = sp;
-               memcpy (&sp -> to.sin_addr,
-                       iap, sizeof *iap);
-       }
-}
-
 void relay (ip, packet, length, from_port, from, hfrom)
        struct interface_info *ip;
        struct dhcp_packet *packet;
@@ -377,7 +340,6 @@ void relay (ip, packet, length, from_port, from, hfrom)
        struct sockaddr_in to;
        struct interface_info *out;
        struct hardware hto, *htop;
-       int i;
 
        if (packet -> hlen > sizeof packet -> chaddr) {
                log_info ("Discarding packet with invalid hlen.");
@@ -388,16 +350,14 @@ void relay (ip, packet, length, from_port, from, hfrom)
           in the packet. */
        if (packet -> giaddr.s_addr) {
                for (out = interfaces; out; out = out -> next) {
-                       for (i = 0; i < out -> address_count; i++) {
-                               if (out -> addresses [i].s_addr ==
-                                   packet -> giaddr.s_addr)
-                                       goto matched;
-                       }
+                       if (!memcmp (&out -> primary_address,
+                                    &packet -> giaddr,
+                                    sizeof packet -> giaddr))
+                               break;
                }
        } else {
                out = (struct interface_info *)0;
        }
-      matched:
 
        /* If it's a bootreply, forward it to the client. */
        if (packet -> op == BOOTREPLY) {
@@ -433,18 +393,15 @@ void relay (ip, packet, length, from_port, from, hfrom)
                        return;
 
                if (!out) {
-                       log_error ("packet to bogus giaddr %s.",
+                       log_error ("packet to bogus giaddr %s.\n",
                              inet_ntoa (packet -> giaddr));
                        ++bogus_giaddr_drops;
                        return;
                }
 
-               if (out -> address_count < 1)
-                       log_fatal ("no IP address on interface %s!",
-                                  out -> name);
                if (send_packet (out,
                                 (struct packet *)0,
-                                packet, length, out -> addresses [0],
+                                packet, length, out -> primary_address,
                                 &to, htop) < 0) {
                        ++server_packet_errors;
                } else {
@@ -463,13 +420,10 @@ void relay (ip, packet, length, from_port, from, hfrom)
        if (out)
                return;
 
-       if (ip -> address_count < 1)
-               log_fatal ("no IP address on interface %s", ip -> name);
-
        /* Add relay agent options if indicated.   If something goes wrong,
           drop the packet. */
        if (!(length = add_relay_agent_options (ip, packet, length,
-                                               ip -> addresses [0])))
+                                               ip -> primary_address)))
                return;
 
        /* If giaddr is not already set, Set it so the server can
@@ -478,7 +432,7 @@ void relay (ip, packet, length, from_port, from, hfrom)
           set, the response will be sent directly to the relay agent
           that set giaddr, so we won't see it. */
        if (!packet -> giaddr.s_addr)
-               packet -> giaddr = ip -> addresses [0];
+               packet -> giaddr = ip -> primary_address;
        if (packet -> hops < max_hop_count)
                packet -> hops = packet -> hops + 1;
        else
@@ -486,12 +440,11 @@ void relay (ip, packet, length, from_port, from, hfrom)
 
        /* Otherwise, it's a BOOTREQUEST, so forward it to all the
           servers. */
-       for (sp = (ip -> servers
-                  ? ip -> servers : servers); sp; sp = sp -> next) {
+       for (sp = servers; sp; sp = sp -> next) {
                if (send_packet ((fallback_interface
                                  ? fallback_interface : interfaces),
                                 (struct packet *)0,
-                                packet, length, ip -> addresses [0],
+                                packet, length, ip -> primary_address,
                                 &sp -> to, (struct hardware *)0) < 0) {
                        ++client_packet_errors;
                } else {
@@ -502,12 +455,13 @@ void relay (ip, packet, length, from_port, from, hfrom)
                        ++client_packets_relayed;
                }
        }
+                                
 }
 
 static void usage ()
 {
        log_fatal ("Usage: dhcrelay [-p <port>] [-d] [-D] [-i %s%s%s%s",
-               "interface [-is server ... ]]\n                ",
+               "interface] [-q] [-a]\n                ",
                "[-c count] [-A length] ",
                "[-m append|replace|forward|discard]\n",
                "                [server1 [... serverN]]");
index 7bf2afe324a5f57521cbfdbf7affe9f8f0e456fb..6976f6d1e65517991bb5ecefbed05644df494689 100644 (file)
@@ -34,7 +34,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: bootp.c,v 1.75 2006/06/01 20:23:17 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium.  All rights reserved.\n";
+"$Id: bootp.c,v 1.76 2006/08/09 14:57:48 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -272,13 +272,11 @@ void bootp (packet)
                        memcpy (&raw.siaddr, d1.data, 4);
                data_string_forget (&d1, MDL);
        } else {
-               if (lease -> subnet -> shared_network -> interface &&
-                   lease -> subnet ->
-                   shared_network -> interface -> address_count)
+               if (lease -> subnet -> shared_network -> interface)
                        raw.siaddr = (lease -> subnet -> shared_network ->
-                                     interface -> addresses [0]);
-               else if (packet -> interface -> address_count)
-                       raw.siaddr = packet -> interface -> addresses [0];
+                                     interface -> primary_address);
+               else
+                       raw.siaddr = packet -> interface -> primary_address;
        }
 
        raw.giaddr = packet -> raw -> giaddr;
@@ -328,8 +326,7 @@ void bootp (packet)
        hto.hlen = packet -> raw -> hlen + 1;
        memcpy (&hto.hbuf [1], packet -> raw -> chaddr, packet -> raw -> hlen);
 
-       if (packet -> interface -> address_count)
-               from = packet -> interface -> addresses [0];
+       from = packet -> interface -> primary_address;
 
        /* Report what we're doing... */
        log_info ("%s", msgbuf);
index ddec7a53739a7751c29864ebb1cbc3998a43b475..59b97d9aecb58272f10c55f5a8ab819e54844004 100644 (file)
@@ -34,7 +34,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: dhcp.c,v 1.210 2006/07/31 23:17:24 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium.  All rights reserved.\n";
+"$Id: dhcp.c,v 1.211 2006/08/09 14:57:48 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -1361,8 +1361,7 @@ void nak_lease (packet, cip)
        option_state_dereference (&options, MDL);
 
 /*     memset (&raw.ciaddr, 0, sizeof raw.ciaddr);*/
-       if (packet -> interface -> address_count)
-               raw.siaddr = packet -> interface -> addresses [0];
+       raw.siaddr = packet -> interface -> primary_address;
        raw.giaddr = packet -> raw -> giaddr;
        memcpy (raw.chaddr, packet -> raw -> chaddr, sizeof raw.chaddr);
        raw.hlen = packet -> raw -> hlen;
@@ -2523,13 +2522,9 @@ void ack_lease (packet, lease, offer, when, msg, ms_nulltp, hp)
                }
        } else {
                /* XXXSK: should we use get_server_source_address() here? */
-               if (state -> ip -> address_count) {
-                       state -> from.len =
-                               sizeof state -> ip -> addresses [0];
-                       memcpy (state -> from.iabuf,
-                               &state -> ip -> addresses [0],
-                               state -> from.len);
-               }
+               state -> from.len = sizeof state -> ip -> primary_address;
+               memcpy (state -> from.iabuf, &state -> ip -> primary_address,
+                       state -> from.len);
        }
 
        /* Figure out the address of the boot file server. */
@@ -3944,22 +3939,18 @@ get_server_source_address(struct in_addr *from,
                data_string_forget(&d, MDL);
        }
 
-       if (packet->interface->address_count > 0) {
-               if (option_cache_allocate(&oc, MDL)) {
-                       a = &packet->interface->addresses[0];
-                       if (make_const_data(&oc->expression,
-                                           (char *)a, sizeof(*a),
-                                           0, 0, MDL)) {
-                               option_code_hash_lookup(&oc->option, 
-                                                       dhcp_universe.code_hash,
-                                                       &option_num, 0, MDL);
-                               save_option(&dhcp_universe, options, oc);
-                       }
-                       option_cache_dereference(&oc, MDL);
+       if (option_cache_allocate(&oc, MDL)) {
+               a = &packet->interface->primary_address;
+               if (make_const_data(&oc->expression,
+                                   (char *)a, sizeof(*a),
+                                   0, 0, MDL)) {
+                       option_code_hash_lookup(&oc->option, 
+                                               dhcp_universe.code_hash,
+                                               &option_num, 0, MDL);
+                       save_option(&dhcp_universe, options, oc);
                }
-               *from = packet->interface->addresses[0];
-       } else {
-                       memset(from, 0, sizeof(*from));
+               option_cache_dereference(&oc, MDL);
        }
+       *from = packet->interface->primary_address;
 }