Source-Changes-HG archive

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

[src/netbsd-1-5]: src/usr.sbin/dhcp Pull up revision 1.11 (requested by mellon):



details:   https://anonhg.NetBSD.org/src/rev/70d9ff957dae
branches:  netbsd-1-5
changeset: 491090:70d9ff957dae
user:      he <he%NetBSD.org@localhost>
date:      Wed Apr 04 20:55:20 2001 +0000

description:
Pull up revision 1.11 (requested by mellon):
  Update DHCP software to ISC version 3, Beta 2, Patchlevel 23.

diffstat:

 usr.sbin/dhcp/client/dhclient.8 |   35 ++-
 usr.sbin/dhcp/common/discover.c |  555 ++++++++++++++++++++++++++++++++-------
 2 files changed, 474 insertions(+), 116 deletions(-)

diffs (truncated from 739 to 300 lines):

diff -r 0560fcc2b66f -r 70d9ff957dae usr.sbin/dhcp/client/dhclient.8
--- a/usr.sbin/dhcp/client/dhclient.8   Wed Apr 04 20:55:17 2001 +0000
+++ b/usr.sbin/dhcp/client/dhclient.8   Wed Apr 04 20:55:20 2001 +0000
@@ -34,7 +34,10 @@
 .B -q
 ]
 [
-.B -c
+.B -1
+]
+[
+.B -r
 ]
 [
 .B -lf
@@ -49,6 +52,10 @@
 .I config-file
 ]
 [
+.B -sf
+.I script-file
+]
+[
 .B -s
 server
 ]
@@ -182,17 +189,32 @@
 flag prevents any messages other than errors from being printed to the
 standard error descriptor.
 .PP
+The client normally doesn't release the current lease as it is not
+required by the DHCP protocol.  Some cable ISPs require their clients
+to notify the server if they wish to release an assigned IP address.
+The
+.B -r
+flag explicitly releases the current lease.
+.PP
+The
+.B -1
+flag cause dhclient to try once to get a lease.  If it fails, dhclient exits
+with exit code two.
+.PP
 The DHCP client normally gets its configuration information from
 .B /etc/dhclient.conf,
 its lease database from
-.B /var/db/dhclient.leases
-and stores its process ID in a file called
-.B /var/run/dhclient.pid.
+.B /var/db/dhclient.leases,
+stores its process ID in a file called
+.B /var/run/dhclient.pid,
+and configures the network interface using
+.B /sbin/dhclient-script
 To specify different names and/or locations for these files, use the
 .B -cf,
-.B -lf
+.B -lf,
+.B -pf
 and
-.B -pf
+.B -sf
 flags, respectively, followed by the name of the file.   This can be
 particularly useful if, for example,
 .B /var/db
@@ -214,6 +236,7 @@
 .SH CONFIGURATION
 The syntax of the dhclient.conf(8) file is discussed seperately.
 .SH FILES
+.B /sbin/dhclient-script
 .B /etc/dhclient.conf, /var/db/dhclient.leases, /var/run/dhclient.pid,
 .B /var/db/dhclient.leases~.
 .SH SEE ALSO
diff -r 0560fcc2b66f -r 70d9ff957dae usr.sbin/dhcp/common/discover.c
--- a/usr.sbin/dhcp/common/discover.c   Wed Apr 04 20:55:17 2001 +0000
+++ b/usr.sbin/dhcp/common/discover.c   Wed Apr 04 20:55:20 2001 +0000
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: discover.c,v 1.4.2.3 2000/12/13 22:47:04 he Exp $ Copyright (c) 1995-2000 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: discover.c,v 1.4.2.4 2001/04/04 20:55:20 he Exp $ Copyright (c) 1995-2000 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -56,6 +56,7 @@
 u_int16_t remote_port;
 int (*dhcp_interface_setup_hook) (struct interface_info *, struct iaddr *);
 int (*dhcp_interface_discovery_hook) (struct interface_info *);
+int (*dhcp_interface_shutdown_hook) (struct interface_info *);
 
 struct in_addr limited_broadcast;
 struct in_addr local_address;
@@ -66,9 +67,55 @@
                                     struct iaddr, struct hardware *));
 
 omapi_object_type_t *dhcp_type_interface;
+#if defined (TRACING)
+trace_type_t *interface_trace;
+trace_type_t *inpacket_trace;
+trace_type_t *outpacket_trace;
+#endif
+struct interface_info **interface_vector;
+int interface_count;
+int interface_max;
 
 OMAPI_OBJECT_ALLOC (interface, struct interface_info, dhcp_type_interface)
 
+isc_result_t interface_setup ()
+{
+       isc_result_t status;
+       status = omapi_object_type_register (&dhcp_type_interface,
+                                            "interface",
+                                            dhcp_interface_set_value,
+                                            dhcp_interface_get_value,
+                                            dhcp_interface_destroy,
+                                            dhcp_interface_signal_handler,
+                                            dhcp_interface_stuff_values,
+                                            dhcp_interface_lookup, 
+                                            dhcp_interface_create,
+                                            dhcp_interface_remove,
+                                            0, 0, 0,
+                                            sizeof (struct interface_info),
+                                            interface_initialize);
+       if (status != ISC_R_SUCCESS)
+               log_fatal ("Can't register interface object type: %s",
+                          isc_result_totext (status));
+
+       return status;
+}
+
+#if defined (TRACING)
+void interface_trace_setup ()
+{
+       interface_trace = trace_type_register ("interface", (void *)0,
+                                              trace_interface_input,
+                                              trace_interface_stop, MDL);
+       inpacket_trace = trace_type_register ("inpacket", (void *)0,
+                                              trace_inpacket_input,
+                                              trace_inpacket_stop, MDL);
+       outpacket_trace = trace_type_register ("outpacket", (void *)0,
+                                              trace_outpacket_input,
+                                              trace_outpacket_stop, MDL);
+}
+#endif
+
 isc_result_t interface_initialize (omapi_object_t *ipo,
                                   const char *file, int line)
 {
@@ -105,26 +152,43 @@
        static int setup_fallback = 0;
        int wifcount = 0;
 
-       if (!dhcp_type_interface) {
-               status = omapi_object_type_register
-                       (&dhcp_type_interface, "interface",
-                        interface_set_value, interface_get_value,
-                        interface_destroy, interface_signal_handler,
-                        interface_stuff_values, 0, 0, 0, 0, 0, 0,
-                        sizeof (struct interface_info),
-                        interface_initialize);
-               if (status != ISC_R_SUCCESS)
-                       log_fatal ("Can't create interface object type: %s",
-                                  isc_result_totext (status));
-       }
-
        /* Create an unbound datagram socket to do the SIOCGIFADDR ioctl on. */
        if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
                log_fatal ("Can't create addrlist socket");
 
        /* Get the interface configuration information... */
+
+#ifdef SIOCGIFCONF_NULL_BUF_GIVES_CORRECT_LEN
+
+       /* linux will only tell us how long a buffer it wants if we give it
+        * a null buffer first. So, do a dry run to figure out the length.
+        * 
+        * XXX this code is duplicated from below because trying to fold
+        * the logic into the if statement and goto resulted in excesssive
+        * obfuscation. The intent is that unless you run Linux you shouldn't
+        * have to deal with this. */
+
+       ic.ifc_len = 0;
+       ic.ifc_ifcu.ifcu_buf = (caddr_t)NULL;
+
+       i = ioctl(sock, SIOCGIFCONF, &ic);
+       if (i < 0)
+               log_fatal ("ioctl: SIOCGIFCONF: %m");
+
+       ic.ifc_ifcu.ifcu_buf = dmalloc ((size_t)ic.ifc_len, MDL);
+       if (!ic.ifc_ifcu.ifcu_buf)
+               log_fatal ("Can't allocate SIOCGIFCONF buffer.");
+
+#else /* SIOCGIFCONF_NULL_BUF_GIVES_CORRECT_LEN */
+
+       /* otherwise, we just feed it a starting size, and it'll tell us if
+        * it needs more */
+
        ic.ifc_len = sizeof buf;
        ic.ifc_ifcu.ifcu_buf = (caddr_t)buf;
+
+#endif /* SIOCGIFCONF_NULL_BUF_GIVES_CORRECT_LEN */
+
       gifconf_again:
        i = ioctl(sock, SIOCGIFCONF, &ic);
 
@@ -205,19 +269,9 @@
                                           ifp -> ifr_name,
                                           isc_result_totext (status));
                        strcpy (tmp -> name, ifp -> ifr_name);
-                       tmp -> circuit_id = (u_int8_t *)tmp -> name;
-                       tmp -> circuit_id_len = strlen (tmp -> name);
-                       tmp -> remote_id = 0;
-                       tmp -> remote_id_len = 0;
-                       tmp -> flags = ir;
-                       if (interfaces) {
-                               interface_reference (&tmp -> next,
-                                                    interfaces, MDL);
-                               interface_dereference (&interfaces, MDL);
-                       }
-                       interface_reference (&interfaces, tmp, MDL);
+                       interface_snorf (tmp, ir);
                        interface_dereference (&tmp, MDL);
-                       tmp = interfaces;
+                       tmp = interfaces; /* XXX */
                }
 
                if (dhcp_interface_discovery_hook)
@@ -493,10 +547,13 @@
                                if (interfaces)
                                        interface_dereference (&interfaces,
                                                               MDL);
+                               if (next)
                                interface_reference (&interfaces, next, MDL);
                        } else {
                                interface_dereference (&last -> next, MDL);
-                               interface_reference (&last -> next, next, MDL);
+                               if (next)
+                                       interface_reference (&last -> next,
+                                                            next, MDL);
                        }
                        if (tmp -> next)
                                interface_dereference (&tmp -> next, MDL);
@@ -525,15 +582,16 @@
                        log_error ("No subnet declaration for %s (%s).",
                                   tmp -> name, inet_ntoa (foo.sin_addr));
                        if (supports_multiple_interfaces (tmp)) {
-                               log_error ("Ignoring requests on %s.",
-                                          tmp -> name);
-                               log_error ("If this is not what you want, %s",
-                                  "please write");
-                               log_error ("a subnet declaration in your %s",
-                                  "dhcpd.conf file for");
-                               log_error ("the network segment to %s %s %s",
+                               log_error ("** Ignoring requests on %s.  %s",
+                                          tmp -> name, "If this is not what");
+                               log_error ("   you want, please write %s",
+                                          "a subnet declaration");
+                               log_error ("   in your dhcpd.conf file %s",
+                                          "for the network segment");
+                               log_error ("   to %s %s %s",
                                           "which interface",
-                                          tmp -> name, "is attached.");
+                                          tmp -> name, "is attached. **");
+                               log_error ("%s", "");
                                goto next;
                        } else {
                                log_error ("You must write a subnet %s",
@@ -562,9 +620,15 @@
                        }
                }
 
+               /* Flag the index as not having been set, so that the
+                  interface registerer can set it or not as it chooses. */
+               tmp -> index = -1;
+
                /* Register the interface... */
                if_register_receive (tmp);
                if_register_send (tmp);
+
+               interface_stash (tmp);
                wifcount++;
 #if defined (HAVE_SETFD)
                if (fcntl (tmp -> rfdesc, F_SETFD, 1) < 0)
@@ -645,6 +709,9 @@
                (*dhcp_interface_setup_hook) (fallback_interface,
                                              (struct iaddr *)0);
        status = interface_reference (fp, fallback_interface, file, line);
+
+       fallback_interface -> index = -1;
+       interface_stash (fallback_interface);
        return status == ISC_R_SUCCESS;
 }
 
@@ -683,102 +750,370 @@
                return ISC_R_INVALIDARG;
        ip = (struct interface_info *)h;
 
-       for (status = ISC_R_UNEXPECTED; ; status = ISC_R_SUCCESS) {
-               if ((result = receive_packet (ip, u.packbuf, sizeof u, &from,
-                   &hfrom)) < 0) {



Home | Main Index | Thread Index | Old Index