]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Pull up 1.29 and 1.30
authorTed Lemon <source@isc.org>
Mon, 29 Jun 1998 22:14:11 +0000 (22:14 +0000)
committerTed Lemon <source@isc.org>
Mon, 29 Jun 1998 22:14:11 +0000 (22:14 +0000)
server/bootp.c

index 135d16a578bee6b4b2eb4243bdd263af25e9cfca..8f0591259813f1d7697929535026bd092f9ab166 100644 (file)
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: bootp.c,v 1.28 1997/09/16 18:17:55 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: bootp.c,v 1.28.2.1 1998/06/29 22:14:11 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -110,13 +110,21 @@ void bootp (packet)
 
                if (host && (!host -> group -> allow_booting)) {
                        note ("Ignoring excluded BOOTP client %s",
-                             host -> name);
+                             host -> name
+                             ? host -> name
+                             : print_hw_addr (packet -> raw -> htype,
+                                              packet -> raw -> hlen,
+                                              packet -> raw -> chaddr));
                        return;
                }
                        
                if (host && (!host -> group -> allow_bootp)) {
                        note ("Ignoring BOOTP request from client %s",
-                             host -> name);
+                             host -> name
+                             ? host -> name
+                             : print_hw_addr (packet -> raw -> htype,
+                                              packet -> raw -> hlen,
+                                              packet -> raw -> chaddr));
                        return;
                }
                        
@@ -222,32 +230,40 @@ void bootp (packet)
        memset (&raw, 0, sizeof raw);
        outgoing.raw = &raw;
 
-       /* Come up with a list of options that we want to send to this
-          client.   Start with the per-subnet options, and then override
-          those with client-specific options. */
+       /* If we didn't get a known vendor magic number on the way in,
+          just copy the input options to the output. */
+       if (!packet -> options_valid) {
+               memcpy (outgoing.raw -> options,
+                       packet -> raw -> options, DHCP_OPTION_LEN);
+               outgoing.packet_length = BOOTP_MIN_LEN;
+       } else {
+               /* Come up with a list of options that we want to send
+                  to this client.  Start with the per-subnet options,
+                  and then override those with client-specific
+                  options. */
 
-       memcpy (options, subnet -> group -> options, sizeof options);
+               memcpy (options, subnet -> group -> options, sizeof options);
 
-       for (i = 0; i < 256; i++) {
-               if (hp -> group -> options [i])
-                       options [i] = hp -> group -> options [i];
-       }
+               for (i = 0; i < 256; i++) {
+                       if (hp -> group -> options [i])
+                               options [i] = hp -> group -> options [i];
+               }
 
-       /* Pack the options into the buffer.   Unlike DHCP, we can't
-          pack options into the filename and server name buffers. */
+               /* Pack the options into the buffer.  Unlike DHCP, we
+                  can't pack options into the filename and server
+                  name buffers. */
 
-       outgoing.packet_length =
-               cons_options (packet, outgoing.raw, options, 0, 0, 1);
-       if (outgoing.packet_length < BOOTP_MIN_LEN)
-               outgoing.packet_length = BOOTP_MIN_LEN;
+               outgoing.packet_length =
+                       cons_options (packet, outgoing.raw, options, 0, 0, 1);
+               if (outgoing.packet_length < BOOTP_MIN_LEN)
+                       outgoing.packet_length = BOOTP_MIN_LEN;
+       }
 
        /* Take the fields that we care about... */
        raw.op = BOOTREPLY;
        raw.htype = packet -> raw -> htype;
        raw.hlen = packet -> raw -> hlen;
-       memcpy (raw.chaddr, packet -> raw -> chaddr, raw.hlen);
-       memset (&raw.chaddr [raw.hlen], 0,
-               (sizeof raw.chaddr) - raw.hlen);
+       memcpy (raw.chaddr, packet -> raw -> chaddr, sizeof raw.chaddr);
        raw.hops = packet -> raw -> hops;
        raw.xid = packet -> raw -> xid;
        raw.secs = packet -> raw -> secs;
@@ -275,7 +291,8 @@ void bootp (packet)
                strncpy (raw.file, hp -> group -> filename,
                         (sizeof raw.file) - 1);
                raw.file [(sizeof raw.file) - 1] = 0;
-       }
+       } else
+               memcpy (raw.file, packet -> raw -> file, sizeof raw.file);
 
        /* Set up the hardware destination address... */
        hto.htype = packet -> raw -> htype;