]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Use interface_allocate to allocate command-line interfaces.
authorTed Lemon <source@isc.org>
Sat, 24 Jun 2000 16:13:19 +0000 (16:13 +0000)
committerTed Lemon <source@isc.org>
Sat, 24 Jun 2000 16:13:19 +0000 (16:13 +0000)
server/dhcpd.c

index af625b7759913cfef4049eb6905978b03d9b1a6f..d11afa14dcefdab1b809096e8881829e9e3a3f86 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char ocopyright[] =
-"$Id: dhcpd.c,v 1.93 2000/06/24 06:28:27 mellon Exp $ Copyright 1995-2000 Internet Software Consortium.";
+"$Id: dhcpd.c,v 1.94 2000/06/24 16:13:19 mellon Exp $ Copyright 1995-2000 Internet Software Consortium.";
 #endif
 
   static char copyright[] =
@@ -165,6 +165,20 @@ int main (argc, argv, envp)
        int lose;
        int omapi_port;
 
+       /* Set up the client classification system. */
+       classification_setup ();
+
+       /* Initialize the omapi system. */
+       result = omapi_init ();
+       if (result != ISC_R_SUCCESS)
+               log_fatal ("Can't initialize OMAPI: %s",
+                          isc_result_totext (result));
+
+       /* Set up the OMAPI wrappers for various server database internal
+          objects. */
+       dhcp_db_objects_setup ();
+       dhcp_common_objects_setup ();
+
        /* Initially, log errors to stderr as well as to syslogd. */
 #ifdef SYSLOG_4_2
        openlog ("dhcpd", LOG_NDELAY);
@@ -235,16 +249,20 @@ int main (argc, argv, envp)
                        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 *)0;
+                       result = interface_allocate (&tmp, MDL);
+                       if (result != ISC_R_SUCCESS)
+                               log_fatal ("Insufficient memory to %s %s: %s",
+                                          "record interface", argv [i],
+                                          isc_result_totext (result));
                        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 = tmp;
                }
        }
 
@@ -292,20 +310,6 @@ int main (argc, argv, envp)
        /* Get the current time... */
        GET_TIME (&cur_time);
 
-       /* Set up the client classification system. */
-       classification_setup ();
-
-       /* Initialize the omapi system. */
-       result = omapi_init ();
-       if (result != ISC_R_SUCCESS)
-               log_fatal ("Can't initialize OMAPI: %s",
-                          isc_result_totext (result));
-
-       /* Set up the OMAPI wrappers for various server database internal
-          objects. */
-       dhcp_db_objects_setup ();
-       dhcp_common_objects_setup ();
-
        /* Set up the initial dhcp option universe. */
        initialize_common_option_spaces ();
        initialize_server_option_spaces ();