Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/dhcp Fix conflicts in merge.



details:   https://anonhg.NetBSD.org/src/rev/2c634c45b40d
branches:  trunk
changeset: 467626:2c634c45b40d
user:      mellon <mellon%NetBSD.org@localhost>
date:      Fri Mar 26 17:52:45 1999 +0000

description:
Fix conflicts in merge.

diffstat:

 usr.sbin/dhcp/client/dhclient.c   |  56 +++++++++++++++++++-----------
 usr.sbin/dhcp/includes/dhcpd.h    |  10 ++++-
 usr.sbin/dhcp/server/bootp.c      |   5 +-
 usr.sbin/dhcp/server/dhcp.c       |  69 +++++++++++++++++++++++++++++---------
 usr.sbin/dhcp/server/dhcpd.c      |   4 +-
 usr.sbin/dhcp/server/dhcpd.conf.5 |   2 +-
 6 files changed, 102 insertions(+), 44 deletions(-)

diffs (truncated from 377 to 300 lines):

diff -r 28f46ae0e71a -r 2c634c45b40d usr.sbin/dhcp/client/dhclient.c
--- a/usr.sbin/dhcp/client/dhclient.c   Fri Mar 26 17:49:19 1999 +0000
+++ b/usr.sbin/dhcp/client/dhclient.c   Fri Mar 26 17:52:45 1999 +0000
@@ -56,7 +56,7 @@
 
 #ifndef lint
 static char ocopyright[] =
-"$Id: dhclient.c,v 1.15 1999/03/05 17:52:44 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: dhclient.c,v 1.16 1999/03/26 17:52:45 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -97,7 +97,7 @@
 static char copyright[] =
 "Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.";
 static char arr [] = "All rights reserved.";
-static char message [] = "Internet Software Consortium DHCP Client V2.0b1pl18";
+static char message [] = "Internet Software Consortium DHCP Client V2.0b1pl19";
 static char contrib [] = "\nPlease contribute if you find this software useful.";
 static char url [] = "For info, please visit http://www.isc.org/dhcp-contrib.html\n";;
 
@@ -493,7 +493,9 @@
             packet -> raw -> hlen) ||
            (memcmp (packet -> interface -> hw_address.haddr,
                     packet -> raw -> chaddr, packet -> raw -> hlen))) {
+#if defined (DEBUG)
                debug ("DHCPACK in wrong transaction.");
+#endif
                return;
        }
 
@@ -501,7 +503,9 @@
            ip -> client -> state != S_REQUESTING &&
            ip -> client -> state != S_RENEWING &&
            ip -> client -> state != S_REBINDING) {
+#if defined (DEBUG)
                debug ("DHCPACK in wrong state.");
+#endif
                return;
        }
 
@@ -738,7 +742,9 @@
             packet -> raw -> hlen) ||
            (memcmp (packet -> interface -> hw_address.haddr,
                     packet -> raw -> chaddr, packet -> raw -> hlen))) {
+#if defined (DEBUG)
                debug ("%s in wrong transaction.", name);
+#endif
                return;
        }
 
@@ -941,7 +947,9 @@
             packet -> raw -> hlen) ||
            (memcmp (packet -> interface -> hw_address.haddr,
                     packet -> raw -> chaddr, packet -> raw -> hlen))) {
+#if defined (DEBUG)
                debug ("DHCPNAK in wrong transaction.");
+#endif
                return;
        }
 
@@ -949,7 +957,9 @@
            ip -> client -> state != S_REQUESTING &&
            ip -> client -> state != S_RENEWING &&
            ip -> client -> state != S_REBINDING) {
+#if defined (DEBUG)
                debug ("DHCPNAK in wrong state.");
+#endif
                return;
        }
 
@@ -1057,10 +1067,11 @@
                         ip -> client -> config -> timeout) - cur_time + 1;
 
        /* Record the number of seconds since we started sending. */
-       if (interval < 255)
-               ip -> client -> packet.secs = interval;
+       if (interval < 65536)
+               ip -> client -> packet.secs = htons (interval);
        else
-               ip -> client -> packet.secs = 255;
+               ip -> client -> packet.secs = htons (65535);
+       ip -> client -> secs = ip -> client -> packet.secs;
 
        note ("DHCPDISCOVER on %s to %s port %d interval %ld",
              ip -> name,
@@ -1300,10 +1311,14 @@
                from.s_addr = INADDR_ANY;
 
        /* Record the number of seconds since we started sending. */
-       if (interval < 255)
-               ip -> client -> packet.secs = interval;
-       else
-               ip -> client -> packet.secs = 255;
+       if (ip -> client -> state == S_REQUESTING)
+               ip -> client -> packet.secs = ip -> client -> secs;
+       else {
+               if (interval < 65536)
+                       ip -> client -> packet.secs = htons (interval);
+               else
+                       ip -> client -> packet.secs = htons (65535);
+       }
 
        note ("DHCPREQUEST on %s to %s port %d", ip -> name,
              inet_ntoa (destination.sin_addr),
@@ -1433,8 +1448,8 @@
 
        /* Set up the option buffer... */
        ip -> client -> packet_length =
-               cons_options ((struct packet *)0, &ip -> client -> packet,
-                             options, 0, 0, 0);
+               cons_options ((struct packet *)0, &ip -> client -> packet, 0,
+                             options, 0, 0, 0, (u_int8_t *)0, 0);
        if (ip -> client -> packet_length < BOOTP_MIN_LEN)
                ip -> client -> packet_length = BOOTP_MIN_LEN;
 
@@ -1540,8 +1555,8 @@
 
        /* Set up the option buffer... */
        ip -> client -> packet_length =
-               cons_options ((struct packet *)0, &ip -> client -> packet,
-                             options, 0, 0, 0);
+               cons_options ((struct packet *)0, &ip -> client -> packet, 0,
+                             options, 0, 0, 0, (u_int8_t *)0, 0);
        if (ip -> client -> packet_length < BOOTP_MIN_LEN)
                ip -> client -> packet_length = BOOTP_MIN_LEN;
 
@@ -1641,8 +1656,8 @@
 
        /* Set up the option buffer... */
        ip -> client -> packet_length =
-               cons_options ((struct packet *)0, &ip -> client -> packet,
-                             options, 0, 0, 0);
+               cons_options ((struct packet *)0, &ip -> client -> packet, 0,
+                             options, 0, 0, 0, (u_int8_t *)0, 0);
        if (ip -> client -> packet_length < BOOTP_MIN_LEN)
                ip -> client -> packet_length = BOOTP_MIN_LEN;
 
@@ -1707,8 +1722,8 @@
 
        /* Set up the option buffer... */
        ip -> client -> packet_length =
-               cons_options ((struct packet *)0, &ip -> client -> packet,
-                             options, 0, 0, 0);
+               cons_options ((struct packet *)0, &ip -> client -> packet, 0,
+                             options, 0, 0, 0, (u_int8_t *)0, 0);
        if (ip -> client -> packet_length < BOOTP_MIN_LEN)
                ip -> client -> packet_length = BOOTP_MIN_LEN;
 
@@ -2022,14 +2037,13 @@
                                        }
                                        dp = dbuf;
                                        memcpy (dp,
+                                               lease -> options [i].data,
+                                               lease -> options [i].len);
+                                       memcpy (dp + lease -> options [i].len,
                                                ip -> client -> 
                                                config -> defaults [i].data,
                                                ip -> client -> 
                                                config -> defaults [i].len);
-                                       memcpy (dp + ip -> client -> 
-                                               config -> defaults [i].len,
-                                               lease -> options [i].data,
-                                               lease -> options [i].len);
                                }
                        } else {
                                dp = ip -> client ->
diff -r 28f46ae0e71a -r 2c634c45b40d usr.sbin/dhcp/includes/dhcpd.h
--- a/usr.sbin/dhcp/includes/dhcpd.h    Fri Mar 26 17:49:19 1999 +0000
+++ b/usr.sbin/dhcp/includes/dhcpd.h    Fri Mar 26 17:52:45 1999 +0000
@@ -160,6 +160,10 @@
 
        struct iaddr from;
 
+       int max_message_size;
+       u_int8_t *prl;
+       int prl_len;
+
        u_int32_t xid;
        u_int16_t secs;
        u_int16_t bootp_flags;
@@ -332,6 +336,7 @@
        enum dhcp_state state;          /* Current state for this interface. */
        struct iaddr destination;                   /* Where to send packet. */
        u_int32_t xid;                                    /* Transaction ID. */
+       u_int16_t secs;                     /* secs value from DHCPDISCOVER. */
        TIME first_sending;                     /* When was first copy sent? */
        TIME interval;                /* What's the current resend interval? */
        struct string_list *medium;                /* Last media type tried. */
@@ -457,8 +462,9 @@
 
 void parse_options PROTO ((struct packet *));
 void parse_option_buffer PROTO ((struct packet *, unsigned char *, int));
-int cons_options PROTO ((struct packet *, struct dhcp_packet *,
-                         struct tree_cache **, int, int, int));
+int cons_options PROTO ((struct packet *, struct dhcp_packet *, int,
+                        struct tree_cache **, int, int, int,
+                        u_int8_t *, int));
 int store_options PROTO ((unsigned char *, int, struct tree_cache **,
                           unsigned char *, int, int, int, int));
 char *pretty_print_option PROTO ((unsigned int,
diff -r 28f46ae0e71a -r 2c634c45b40d usr.sbin/dhcp/server/bootp.c
--- a/usr.sbin/dhcp/server/bootp.c      Fri Mar 26 17:49:19 1999 +0000
+++ b/usr.sbin/dhcp/server/bootp.c      Fri Mar 26 17:52:45 1999 +0000
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: bootp.c,v 1.5 1999/02/24 04:14:34 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: bootp.c,v 1.6 1999/03/26 17:52:45 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -254,7 +254,8 @@
                   name buffers. */
 
                outgoing.packet_length =
-                       cons_options (packet, outgoing.raw, options, 0, 0, 1);
+                       cons_options (packet, outgoing.raw,
+                                     0, options, 0, 0, 1, (u_int8_t *)0, 0);
                if (outgoing.packet_length < BOOTP_MIN_LEN)
                        outgoing.packet_length = BOOTP_MIN_LEN;
        }
diff -r 28f46ae0e71a -r 2c634c45b40d usr.sbin/dhcp/server/dhcp.c
--- a/usr.sbin/dhcp/server/dhcp.c       Fri Mar 26 17:49:19 1999 +0000
+++ b/usr.sbin/dhcp/server/dhcp.c       Fri Mar 26 17:52:45 1999 +0000
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: dhcp.c,v 1.6 1999/03/05 17:52:46 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: dhcp.c,v 1.7 1999/03/26 17:52:46 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -463,7 +463,8 @@
 
        /* Set up the option buffer... */
        outgoing.packet_length =
-               cons_options (packet, outgoing.raw, options, 0, 0, 0);
+               cons_options (packet, outgoing.raw, 0, options, 0, 0, 0,
+                             (u_int8_t *)0, 0);
 
 /*     memset (&raw.ciaddr, 0, sizeof raw.ciaddr);*/
        raw.siaddr = packet -> interface -> primary_address;
@@ -803,6 +804,30 @@
        state -> hops = packet -> raw -> hops;
        state -> offer = offer;
 
+       /* Get the Maximum Message Size option from the packet, if one
+          was sent. */
+       if (packet -> options [DHO_DHCP_MAX_MESSAGE_SIZE].data &&
+           (packet -> options [DHO_DHCP_MAX_MESSAGE_SIZE].len >=
+            sizeof (u_int16_t)))
+               state -> max_message_size =
+                       getUShort (packet -> options
+                                  [DHO_DHCP_MAX_MESSAGE_SIZE].data);
+
+       /* Save the parameter request list if there is one. */
+       i = DHO_DHCP_PARAMETER_REQUEST_LIST;
+       if (packet -> options [i].data) {
+               state -> prl = dmalloc (packet -> options [i].len,
+                                       "ack_lease: prl");
+               if (!state -> prl)
+                       warn ("no memory for parameter request list");
+               else {
+                       memcpy (state -> prl,
+                               packet -> options [i].data,
+                               packet -> options [i].len);
+                       state -> prl_len = packet -> options [i].len;
+               }
+       }
+
        /* Figure out what options to send to the client: */
 
        /* Start out with the subnet options... */
@@ -1110,7 +1135,9 @@
 
        /* Insert such options as will fit into the buffer. */
        packet_length = cons_options ((struct packet *)0, &raw,
-                                     state -> options, bufs, nulltp, bootpp);
+                                     state -> max_message_size,
+                                     state -> options, bufs, nulltp, bootpp,
+                                     state -> prl, state -> prl_len);
 
        /* Having done the cons_options(), we can release the tree_cache
           entries. */
@@ -1186,35 +1213,45 @@
                        result = send_packet (fallback_interface,
                                              (struct packet *)0,
                                              &raw, packet_length,
-                                             raw.siaddr, &to, &hto);
+                                             raw.siaddr,
+                                             &to, (struct hardware *)0);
 
                        free_lease_state (state, "dhcp_reply fallback 1");
                        lease -> state = (struct lease_state *)0;
                        return;
                }
 



Home | Main Index | Thread Index | Old Index