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/e99caa48642f
branches:  trunk
changeset: 487645:e99caa48642f
user:      mellon <mellon%NetBSD.org@localhost>
date:      Sat Jun 10 18:17:18 2000 +0000

description:
Fix conflicts in merge.

diffstat:

 usr.sbin/dhcp/client/clparse.c       |   62 +-
 usr.sbin/dhcp/client/dhclient.8      |   15 +
 usr.sbin/dhcp/client/dhclient.c      |  264 +++++++--
 usr.sbin/dhcp/client/scripts/bsdos   |   12 +-
 usr.sbin/dhcp/client/scripts/freebsd |    8 +-
 usr.sbin/dhcp/client/scripts/netbsd  |    5 +-
 usr.sbin/dhcp/common/bpf.c           |   10 +-
 usr.sbin/dhcp/common/discover.c      |  228 +++-----
 usr.sbin/dhcp/common/dispatch.c      |   22 +-
 usr.sbin/dhcp/common/hash.c          |   66 +-
 usr.sbin/dhcp/common/options.c       |    9 +-
 usr.sbin/dhcp/common/tables.c        |   26 +-
 usr.sbin/dhcp/includes/dhcpd.h       |  440 ++++++++++++----
 usr.sbin/dhcp/includes/site.h        |   14 +-
 usr.sbin/dhcp/relay/dhcrelay.c       |   17 +-
 usr.sbin/dhcp/server/bootp.c         |   83 ++-
 usr.sbin/dhcp/server/dhcp.c          |  924 +++++++++++++++++++++++-----------
 usr.sbin/dhcp/server/dhcpd.c         |  214 ++++++-
 usr.sbin/dhcp/server/dhcpd.conf.5    |   23 +-
 19 files changed, 1645 insertions(+), 797 deletions(-)

diffs (truncated from 4523 to 300 lines):

diff -r 108fbaadc40a -r e99caa48642f usr.sbin/dhcp/client/clparse.c
--- a/usr.sbin/dhcp/client/clparse.c    Sat Jun 10 18:04:36 2000 +0000
+++ b/usr.sbin/dhcp/client/clparse.c    Sat Jun 10 18:17:18 2000 +0000
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: clparse.c,v 1.2 2000/04/23 18:39:00 thorpej Exp $ Copyright (c) 1996-2000 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: clparse.c,v 1.3 2000/06/10 18:17:18 mellon Exp $ Copyright (c) 1996-2000 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -97,11 +97,11 @@
        top_level_config.script_name = "/etc/dhclient-script";
        top_level_config.requested_options = default_requested_options;
 
-       top_level_config.on_receipt = new_group (MDL);
+       group_allocate (&top_level_config.on_receipt, MDL);
        if (!top_level_config.on_receipt)
                log_fatal ("no memory for top-level on_receipt group");
 
-       top_level_config.on_transmission = new_group (MDL);
+       group_allocate (&top_level_config.on_transmission, MDL);
        if (!top_level_config.on_transmission)
                log_fatal ("no memory for top-level on_transmission group");
 
@@ -291,7 +291,7 @@
                                return;
                        }
                        config -> auth_policy = policy;
-               } else if (token != BOOTP) {
+               } else if (token != TOKEN_BOOTP) {
                        if (policy != P_PREFER &&
                            policy != P_IGNORE &&
                            policy != P_ACCEPT) {
@@ -643,7 +643,7 @@
                return;
        }
 
-       ip = interface_or_dummy (val);
+       interface_or_dummy (&ip, val);
 
        /* If we were given a name, this is a pseudo-interface. */
        if (name) {
@@ -688,37 +688,49 @@
        token = next_token (&val, cfile);
 }
 
-struct interface_info *interface_or_dummy (name)
-       const char *name;
+int interface_or_dummy (struct interface_info **pi, const char *name)
 {
-       struct interface_info *ip;
+       struct interface_info *i;
+       struct interface_info *ip = (struct interface_info *)0;
 
        /* Find the interface (if any) that matches the name. */
-       for (ip = interfaces; ip; ip = ip -> next) {
-               if (!strcmp (ip -> name, name))
+       for (i = interfaces; i; i = i -> next) {
+               if (!strcmp (i -> name, name)) {
+                       interface_reference (&ip, i, MDL);
                        break;
+               }
        }
 
        /* If it's not a real interface, see if it's on the dummy list. */
        if (!ip) {
                for (ip = dummy_interfaces; ip; ip = ip -> next) {
-                       if (!strcmp (ip -> name, name))
+                       if (!strcmp (ip -> name, name)) {
+                               interface_reference (&ip, i, MDL);
                                break;
+                       }
                }
        }
 
        /* If we didn't find an interface, make a dummy interface as
           a placeholder. */
        if (!ip) {
-               ip = (struct interface_info *)dmalloc (sizeof *ip, MDL);
-               if (!ip)
-                       log_fatal ("No memory to record interface %s", name);
-               memset (ip, 0, sizeof *ip);
+               isc_result_t status;
+               status = interface_allocate (&ip, MDL);
+               if (status != ISC_R_SUCCESS)
+                       log_fatal ("Can't record interface %s: %s",
+                                  name, isc_result_totext (status));
                strcpy (ip -> name, name);
-               ip -> next = dummy_interfaces;
-               dummy_interfaces = ip;
+               if (dummy_interfaces) {
+                       interface_reference (&ip -> next,
+                                            dummy_interfaces, MDL);
+                       interface_dereference (&dummy_interfaces, MDL);
+               }
+               interface_reference (&dummy_interfaces, ip, MDL);
        }
-       return ip;
+       if (pi)
+               interface_reference (pi, ip, MDL);
+       interface_dereference (&ip, MDL);
+       return 1;
 }
 
 void make_client_state (state)
@@ -739,10 +751,11 @@
        if (!client -> config)
                log_fatal ("no memory for client config\n");
        memcpy (client -> config, config, sizeof *config);
-       client -> config -> on_receipt =
-               clone_group (config -> on_receipt, MDL);
-       client -> config -> on_transmission =
-               clone_group (config -> on_transmission, MDL);
+       if (!clone_group (&client -> config -> on_receipt,
+                         config -> on_receipt, MDL) ||
+           !clone_group (&client -> config -> on_transmission,
+                         config -> on_transmission, MDL))
+               log_fatal ("no memory for client state groups.");
 }
 
 /* client-lease-statement :==
@@ -907,7 +920,7 @@
                        parse_warn (cfile, "unknown key %s", val);
                parse_semi (cfile);
                break;
-             case BOOTP:
+             case TOKEN_BOOTP:
                lease -> is_bootp = 1;
                break;
 
@@ -919,8 +932,7 @@
                        skip_to_semi (cfile);
                        break;
                }
-               ip = interface_or_dummy (val);
-               *ipp = ip;
+               interface_or_dummy (ipp, val);
                break;
 
              case NAME:
diff -r 108fbaadc40a -r e99caa48642f usr.sbin/dhcp/client/dhclient.8
--- a/usr.sbin/dhcp/client/dhclient.8   Sat Jun 10 18:04:36 2000 +0000
+++ b/usr.sbin/dhcp/client/dhclient.8   Sat Jun 10 18:17:18 2000 +0000
@@ -53,6 +53,9 @@
 server
 ]
 [
+.B -w
+]
+[
 .I if0
 [
 .I ...ifN
@@ -196,6 +199,18 @@
 or
 .B RUNDIR
 has not yet been mounted when the DHCP client is started.
+.PP
+The DHCP client normally exits if it isn't able to identify any
+network interfaces to configure.   On laptop computers and other
+computers with hot-swappable I/O buses, it is possible that a
+broadcast interface may be added after system startup.   The
+.B -w
+flag can be used to cause the client not to exit when it doesn't find
+any such interfaces.   The
+.B dhcpccp (8)
+program can then be used to notify the client when a network interface
+has been added or removed, so that the client can configure an IP
+address on that interface.
 .SH CONFIGURATION
 The syntax of the dhclient.conf(8) file is discussed seperately.
 .SH FILES
diff -r 108fbaadc40a -r e99caa48642f usr.sbin/dhcp/client/dhclient.c
--- a/usr.sbin/dhcp/client/dhclient.c   Sat Jun 10 18:04:36 2000 +0000
+++ b/usr.sbin/dhcp/client/dhclient.c   Sat Jun 10 18:17:18 2000 +0000
@@ -15,7 +15,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
+ * 3. Neither the name of Internet Software Consortium nor the names
  *    of its contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
@@ -41,7 +41,7 @@
 
 #ifndef lint
 static char ocopyright[] =
-"$Id: dhclient.c,v 1.25 2000/04/22 08:18:12 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: dhclient.c,v 1.26 2000/06/10 18:17:19 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -71,8 +71,7 @@
    assert (state_is == state_shouldbe). */
 #define ASSERT_STATE(state_is, state_shouldbe) {}
 
-static char copyright[] =
-"Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.";
+static char copyright[] = "Copyright 1995-2000 Internet Software Consortium.";
 static char arr [] = "All rights reserved.";
 static char message [] = "Internet Software Consortium DHCP Client";
 static char contrib [] = "\nPlease contribute if you find this software useful.";
@@ -103,6 +102,7 @@
        int release_mode = 0;
        omapi_object_t *listener;
        isc_result_t result;
+       int persist = 0;
 
 #ifdef SYSLOG_4_2
        openlog ("dhclient", LOG_NDELAY);
@@ -115,6 +115,19 @@
        setlogmask (LOG_UPTO (LOG_INFO));
 #endif 
 
+       /* Set up the OMAPI. */
+       status = omapi_init ();
+       if (status != ISC_R_SUCCESS)
+               log_fatal ("Can't initialize OMAPI: %s",
+                          isc_result_totext (status));
+
+       /* Set up the OMAPI wrappers for various server database internal
+          objects. */
+       dhcp_common_objects_setup ();
+
+       dhcp_interface_discovery_hook = dhclient_interface_discovery_hook;
+       dhcp_interface_shutdown_hook = dhclient_interface_shutdown_hook;
+
        for (i = 1; i < argc; i++) {
                if (!strcmp (argv [i], "-r")) {
                        release_mode = 1;
@@ -154,21 +167,30 @@
                        relay = argv [i];
                } else if (!strcmp (argv [i], "-n")) {
                        /* do not start up any interfaces */
-                   interfaces_requested = 1;
+                       interfaces_requested = 1;
+               } else if (!strcmp (argv [i], "-w")) {
+                       /* do not exit if there are no broadcast interfaces. */
+                       persist = 1;
                } else if (argv [i][0] == '-') {
                    usage ();
                } else {
-                   struct interface_info *tmp = ((struct interface_info *)
-                                                 dmalloc (sizeof *tmp, MDL));
-                   if (!tmp)
-                       log_fatal ("Insufficient memory to %s %s",
-                              "record interface", argv [i]);
-                   memset (tmp, 0, sizeof *tmp);
+                   struct interface_info *tmp = (struct interface_info *)0;
+                   status = interface_allocate (&tmp, MDL);
+                   if (status != ISC_R_SUCCESS)
+                       log_fatal ("Can't record interface %s:%s",
+                                  argv [i], isc_result_totext (status));
+                   if (strlen (argv [i]) > sizeof tmp -> name)
+                           log_fatal ("%s: interface name too long (max %d)",
+                                      argv [i], strlen (argv [i]));
                    strcpy (tmp -> name, argv [i]);
-                   tmp -> next = interfaces;
+                   if (interfaces) {
+                           interface_reference (&tmp -> next,
+                                                interfaces, MDL);
+                           interface_dereference (&interfaces, MDL);
+                   }
+                   interface_reference (&interfaces, tmp, MDL);
                    tmp -> flags = INTERFACE_REQUESTED;
                    interfaces_requested = 1;
-                   interfaces = tmp;
                }
        }
 
@@ -255,16 +277,6 @@
 
        inaddr_any.s_addr = INADDR_ANY;
 
-       /* Set up the OMAPI. */
-       status = omapi_init ();
-       if (status != ISC_R_SUCCESS)
-               log_fatal ("Can't initialize OMAPI: %s",
-                          isc_result_totext (status));
-
-       /* Set up the OMAPI wrappers for various server database internal
-          objects. */
-       dhclient_db_objects_setup ();
-
        /* Discover all the network interfaces. */
        discover_interfaces (DISCOVER_UNCONFIGURED);
 
@@ -283,14 +295,19 @@
        /* If no broadcast interfaces were discovered, call the script
           and tell it so. */
        if (!interfaces) {
+               /* Call dhclient-script with the NBI flag, in case somebody
+                  cares. */
                script_init ((struct client_state *)0, "NBI",
                             (struct string_list *)0);
                script_go ((struct client_state *)0);
 



Home | Main Index | Thread Index | Old Index