]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Copy the entire chaddr field, even if the length is shorter than the total. This...
authorTed Lemon <source@isc.org>
Fri, 6 Feb 1998 01:05:39 +0000 (01:05 +0000)
committerTed Lemon <source@isc.org>
Fri, 6 Feb 1998 01:05:39 +0000 (01:05 +0000)
server/bootp.c

index 135d16a578bee6b4b2eb4243bdd263af25e9cfca..1b4b1e275a6b11e0f6b4cbea110e3c469521fccf 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.29 1998/02/06 01:05:39 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -222,32 +222,41 @@ 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, 0, options,
+                                     (struct agent_options *)0, 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;