]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Panic commit.
authorTed Lemon <source@isc.org>
Wed, 27 Sep 2000 23:37:44 +0000 (23:37 +0000)
committerTed Lemon <source@isc.org>
Wed, 27 Sep 2000 23:37:44 +0000 (23:37 +0000)
Makefile.conf
dhcpctl/remote.c
dhcpctl/test.c
includes/netinet/udp.h
includes/site.h
omapip/support.c
server/omapi.c

index 37c3c2d3645803809b930ad26653553dc3b38e81..aa46b166d1000a5dff923136301168f272fa692c 100644 (file)
@@ -129,6 +129,7 @@ MINORVERSION=MinorVersion
 #VARRUN = /etc
 #VARDB = /etc
 #SCRIPT=solaris
+#AR=/bin/true
 ##--sunos5-gcc--
 
 ## Solaris 2.5 (with Sun cc)
index 546508746676c70d8337427c9087e4eaead4eda5..6d14807adf22d7ca7c4cb6a4d90c8aeb0362f84b 100644 (file)
@@ -111,13 +111,11 @@ dhcpctl_status dhcpctl_new_object (dhcpctl_handle *h,
        omapi_object_t *g;
        isc_result_t status;
 
-       m = dmalloc (sizeof *m, MDL);
-       if (!m)
-               return ISC_R_NOMEMORY;
-       memset (m, 0, sizeof *m);
-       m -> type = dhcpctl_remote_type;
-       m -> refcnt = 1;
-       rc_register_mdl (&m, m, m -> refcnt);
+       m = (dhcpctl_remote_object_t *)0;
+       status = omapi_object_allocate ((omapi_object_t **)&m,
+                                       dhcpctl_remote_type, 0, MDL);
+       if (status != ISC_R_SUCCESS)
+               return status;
 
        g = (omapi_object_t *)0;
        status = omapi_generic_new (&g, MDL);
index c4c91ed948a9b500548350351803a677211b494b..dda9d902fb7ec1ba50b24cd6b5469e27b1104e37 100644 (file)
@@ -122,6 +122,7 @@ int main (argc, argv)
                exit (1);
        }
 
+#if 0
        /* Create a named group that contains the values we want to assign
           to the host. */
        memset (&group_handle, 0, sizeof group_handle);
@@ -173,6 +174,7 @@ option domain-name-servers 10.0.0.1, 10.0.0.2;",
        printf ("group name = %.*s\n",
                (int)groupname -> len,
                groupname -> value);
+#endif
 
        memset (&host_handle, 0, sizeof host_handle);
        status = dhcpctl_new_object (&host_handle, connection, "host");
@@ -191,27 +193,20 @@ option domain-name-servers 10.0.0.1, 10.0.0.2;",
                exit (1);
        }
 
-       cid -> value [0] = 0; cid -> value [1] = 0x10;
-       cid -> value [2] = 0x5a; cid -> value [3] = 0xf8;
-       cid -> value [4] = 0x00; cid -> value [5] = 0xbb;
+       memset (&cid -> value [0], 0, 6);
 
-      doitagain:
        status = dhcpctl_set_value (host_handle,
-                                   cid, "dhcp-client-identifier");
-/*#else 
-  doitagain: */
-       status = dhcpctl_set_string_value (host_handle, "gnorf",
-                                          "name");
+                                   cid, "hardware-address");
        if (status != ISC_R_SUCCESS) {
                fprintf (stderr, "dhcpctl_set_value: %s\n",
                         isc_result_totext (status));
                exit (1);
        }
-/*#endif*/
 
-       status = dhcpctl_set_value (host_handle, groupname, "group");
+       status = dhcpctl_set_string_value (host_handle, "gnorf",
+                                          "name");
        if (status != ISC_R_SUCCESS) {
-               fprintf (stderr, "dhcpctl_set_value: %s\n",
+               fprintf (stderr, "dhcpctl_set_string_value: %s\n",
                         isc_result_totext (status));
                exit (1);
        }
@@ -244,6 +239,7 @@ option domain-name-servers 10.0.0.1, 10.0.0.2;",
                exit (1);
        }
 
+#if 0
        status = dhcpctl_set_string_value (host_handle, "\n\
 option host-name \"bar\";\n\
 option smtp-server 10.0.0.1;",
@@ -253,6 +249,7 @@ option smtp-server 10.0.0.1;",
                         isc_result_totext (status));
                exit (1);
        }
+#endif
 
        status = dhcpctl_open_object (host_handle, connection,
                                      DHCPCTL_CREATE | DHCPCTL_EXCL);
@@ -264,75 +261,49 @@ option smtp-server 10.0.0.1;",
 
        status = dhcpctl_wait_for_completion (host_handle, &waitstatus);
        if (status != ISC_R_SUCCESS) {
-               fprintf (stderr, "dhcpctl_wait_for_completion: %s\n",
+               fprintf (stderr, "create: dhcpctl_wait_for_completion: %s\n",
                         isc_result_totext (status));
                exit (1);
        }
 
        if (waitstatus != ISC_R_SUCCESS) {
-               status = dhcpctl_open_object (host_handle, connection, 0);
-               if (status != ISC_R_SUCCESS) {
-                       fprintf (stderr, "dhcpctl_open_object: %s\n",
-                                isc_result_totext (status));
-                       exit (1);
-               }
-               status = dhcpctl_wait_for_completion (host_handle,
-                                                     &waitstatus);
-               if (status != ISC_R_SUCCESS) {
-                       fprintf (stderr, "dhcpctl_wait_for_completion: %s\n",
-                                isc_result_totext (status));
-                       exit (1);
-               }
-               if (waitstatus != ISC_R_SUCCESS) {
-                       fprintf (stderr, "dhcpctl_wait_for_completion: %s\n",
-                                isc_result_totext (waitstatus));
-                       exit (1);
-               }
-
-               status = dhcpctl_object_remove (connection, host_handle);
-               if (status != ISC_R_SUCCESS) {
-                       fprintf (stderr, "dhcpctl_object_remove: %s\n",
-                                isc_result_totext (status));
-                       exit (1);
-               }
-               status = dhcpctl_wait_for_completion (host_handle,
-                                                     &waitstatus);
-               if (status != ISC_R_SUCCESS) {
-                       fprintf (stderr,
-                                "remove: dhcpctl_wait_for_completion: %s\n",
-                                isc_result_totext (status));
-                       exit (1);
-               }
-               if (waitstatus != ISC_R_SUCCESS) {
-                       fprintf (stderr,
-                                "remove: dhcpctl_wait_for_completion: %s\n",
-                                isc_result_totext (waitstatus));
-                       exit (1);
-               }
+               fprintf (stderr, "dhcpctl_open_object: %s\n",
+                        isc_result_totext (waitstatus));
+               exit (1);
+       }
 
-               omapi_object_dereference (&host_handle, MDL);
+       cid -> value [0] = 0; cid -> value [1] = 0x10;
+       cid -> value [2] = 0x5a; cid -> value [3] = 0xf8;
+       cid -> value [4] = 0x00; cid -> value [5] = 0xbb;
 
-               status = dhcpctl_new_object (&host_handle, connection, "host");
-               if (status != ISC_R_SUCCESS) {
-                       fprintf (stderr, "dhcpctl_new_object: %s\n",
-                                isc_result_totext (status));
-                       exit (1);
-               }
+       status = dhcpctl_set_value (host_handle,
+                                   cid, "hardware-address");
+       if (status != ISC_R_SUCCESS) {
+               fprintf (stderr, "dhcpctl_set_value: %s\n",
+                        isc_result_totext (status));
+               exit (1);
+       }
 
-               goto doitagain;
+       status = dhcpctl_object_update (connection, host_handle);
+       if (status != ISC_R_SUCCESS) {
+               fprintf (stderr, "dhcpctl_object_update: %s\n",
+                        isc_result_totext (status));
+               exit (1);
        }
 
-       memset (&result, 0, sizeof result);
-       status = dhcpctl_get_value (&result, host_handle, "name");
+       status = dhcpctl_wait_for_completion (host_handle, &waitstatus);
        if (status != ISC_R_SUCCESS) {
-               fprintf (stderr, "dhcpctl_get_value: %s\n",
+               fprintf (stderr, "update: dhcpctl_wait_for_completion: %s\n",
                         isc_result_totext (status));
                exit (1);
        }
 
-       printf ("host name = %.*s\n", (int)result -> len, result -> value);
+       if (waitstatus != ISC_R_SUCCESS) {
+               fprintf (stderr, "dhcpctl_object_update: %s\n",
+                        isc_result_totext (waitstatus));
+               exit (1);
+       }
 
-#if 0
        status = dhcpctl_object_remove (connection, host_handle);
        if (status != ISC_R_SUCCESS) {
                fprintf (stderr, "dhcpctl_object_remove: %s\n",
@@ -342,97 +313,65 @@ option smtp-server 10.0.0.1;",
        status = dhcpctl_wait_for_completion (host_handle,
                                              &waitstatus);
        if (status != ISC_R_SUCCESS) {
-               fprintf (stderr, "remove: dhcpctl_wait_for_completion: %s\n",
+               fprintf (stderr,
+                        "remove: dhcpctl_wait_for_completion: %s\n",
                         isc_result_totext (status));
                exit (1);
        }
        if (waitstatus != ISC_R_SUCCESS) {
-               fprintf (stderr, "remove: dhcpctl_wait_for_completion: %s\n",
+               fprintf (stderr,
+                        "remove: dhcpctl_wait_for_completion: %s\n",
                         isc_result_totext (waitstatus));
                exit (1);
        }
-#endif
 
-       /* Create a named group that contains the values we want to assign
-          to the host. */
-       memset (&lease_handle, 0, sizeof lease_handle);
-       status = dhcpctl_new_object (&lease_handle, connection, "lease");
+       omapi_object_dereference (&host_handle, MDL);
+
+       status = dhcpctl_new_object (&host_handle, connection, "host");
        if (status != ISC_R_SUCCESS) {
                fprintf (stderr, "dhcpctl_new_object: %s\n",
                         isc_result_totext (status));
                exit (1);
        }
 
-       memset (&ip_addr, 0, sizeof ip_addr);
-       status = omapi_data_string_new (&ip_addr, 4, MDL);
+       memset (&cid -> value [0], 0, 6);
+
+       status = dhcpctl_set_value (host_handle,
+                                   cid, "hardware-address");
        if (status != ISC_R_SUCCESS) {
-               fprintf (stderr, "omapi_data_string_new: %s\n",
+               fprintf (stderr, "dhcpctl_set_value: %s\n",
                         isc_result_totext (status));
                exit (1);
        }
 
-       ip_addr -> value [0] = 10; ip_addr -> value [1] = 0;
-       ip_addr -> value [2] = 0; ip_addr -> value [3] = 4;
-
-       status = dhcpctl_set_value (lease_handle, ip_addr, "ip-address");
+       status = dhcpctl_set_string_value (host_handle, "gnorf",
+                                          "name");
        if (status != ISC_R_SUCCESS) {
-               fprintf (stderr, "dhcpctl_set_value: %s\n",
+               fprintf (stderr, "dhcpctl_set_string_value: %s\n",
                         isc_result_totext (status));
                exit (1);
        }
 
-       status = dhcpctl_open_object (lease_handle, connection, 0);
+       status = dhcpctl_open_object (host_handle, connection,
+                                     DHCPCTL_CREATE | DHCPCTL_EXCL);
        if (status != ISC_R_SUCCESS) {
-               fprintf (stderr, "dhcpctl_open_object: %s\n",
+               fprintf (stderr, "dhcpctl_open_object 2: %s\n",
                         isc_result_totext (status));
                exit (1);
        }
 
-       status = dhcpctl_wait_for_completion (lease_handle, &waitstatus);
+       status = dhcpctl_wait_for_completion (host_handle, &waitstatus);
        if (status != ISC_R_SUCCESS) {
-               fprintf (stderr, "dhcpctl_wait_for_completion: %s\n",
+               fprintf (stderr, "create: dhcpctl_wait_for_completion: %s\n",
                         isc_result_totext (status));
                exit (1);
        }
+
        if (waitstatus != ISC_R_SUCCESS) {
-               fprintf (stderr, "lease object lookup: %s\n",
+               fprintf (stderr, "dhcpctl_open_object 2: %s\n",
                         isc_result_totext (waitstatus));
                exit (1);
        }
 
-       memset (&identifier, 0, sizeof identifier);
-       status = dhcpctl_get_value (&identifier, lease_handle,
-                                   "dhcp-client-identifier");
-       if (status == ISC_R_SUCCESS) {
-               printf ("lease client-identifier = %02x",
-                       identifier -> value [0]);
-               for (i = 1; i < identifier -> len; i++) {
-                       printf (":%02x", identifier -> value [i]);
-               }
-               putchar ('\n');
-       } else {
-               status = dhcpctl_get_value (&identifier, lease_handle,
-                                           "hardware-address");
-               if (status == ISC_R_SUCCESS) {
-                       printf ("lease hardware address = %02x",
-                               identifier -> value [0]);
-                       for (i = 1; i < identifier -> len; i++) {
-                               printf (":%02x", identifier -> value [i]);
-                       }
-                       putchar ('\n');
-                       dhcpctl_data_string_dereference (&identifier, MDL);
-                       status = dhcpctl_get_value (&identifier, lease_handle,
-                                                   "hardware-type");
-                       if (status == ISC_R_SUCCESS) {
-                               printf ("lease hardware type = %d\n",
-                                       identifier -> value [0]);
-                               dhcpctl_data_string_dereference (&identifier,
-                                                                MDL);
-                       }
-               } else {
-                       printf ("Unable to find identifier for lease.\n");
-               }
-       }
-
        exit (0);
 }
index c7964dfd30fce66a610008ff6ae859a5c1dd85e4..95bc044f7d90948c03350fa13d0a31e3cf95c1e4 100644 (file)
@@ -42,6 +42,6 @@
 struct udphdr {
        u_int16_t uh_sport;             /* source port */
        u_int16_t uh_dport;             /* destination port */
-       int16_t   uh_ulen;              /* udp length */
+       u_int16_t uh_ulen;              /* udp length */
        u_int16_t uh_sum;               /* udp checksum */
 };
index ba0e13252cb595b4f7908111fd563b194ae3ef1b..e0b04a3d1f1300911fc5feee5f48a367d48ca245 100644 (file)
    the aforementioned problems do not matter to you, or if no other
    API is supported for your system, you may want to go with it. */
 
-/* #define USE_SOCKETS */
+#define USE_SOCKETS
 
 /* Define this to use the Sun Streams NIT API.
 
index f9f148871cb1944ddc2e460daf854ac716e9ccda..9f92ad1831c26f877c0d4ced4effaa3f5243951c 100644 (file)
@@ -290,13 +290,43 @@ isc_result_t omapi_set_value (omapi_object_t *h,
                              omapi_typed_data_t *value)
 {
        omapi_object_t *outer;
+       isc_result_t status;
+
+       if (!value) {
+               log_info ("omapi_set_value (%.*s, NULL)",
+                         (int)name -> len, name -> value);
+       } else if (value -> type == omapi_datatype_int) {
+               log_info ("omapi_set_value (%.*s, %ld)",
+                         (int)name -> len, name -> value,
+                         (long)value -> u.integer);
+       } else if (value -> type == omapi_datatype_string) {
+               log_info ("omapi_set_value (%.*s, %.*s)",
+                         (int)name -> len, name -> value,
+                         (int)value -> u.buffer.len, value -> u.buffer.value);
+       } else if (value -> type == omapi_datatype_data) {
+               log_info ("omapi_set_value (%.*s, %ld %lx)",
+                         (int)name -> len, name -> value,
+                         (long)value -> u.buffer.len,
+                         (unsigned long)value -> u.buffer.value);
+       } else if (value -> type == omapi_datatype_object) {
+               log_info ("omapi_set_value (%.*s, %s)",
+                         (int)name -> len, name -> value,
+                         value -> u.object
+                         ? (value -> u.object -> type
+                            ? value -> u.object -> type -> name
+                            : "(unknown object)")
+                         : "(unknown object)");
+       }
 
        for (outer = h; outer -> outer; outer = outer -> outer)
                ;
        if (outer -> type -> set_value)
-               return (*(outer -> type -> set_value)) (outer,
-                                                       id, name, value);
-       return ISC_R_NOTFOUND;
+               status = (*(outer -> type -> set_value)) (outer,
+                                                         id, name, value);
+       else
+               status = ISC_R_NOTFOUND;
+       log_info (" ==> %s", isc_result_totext (status));
+       return status;
 }
 
 isc_result_t omapi_set_value_str (omapi_object_t *h,
index f95bb6a55efe2f0a93bfaf3231967953e3039370..d0292cf2db88d42ab6da068bb74fcd0b6e9380b6 100644 (file)
@@ -50,7 +50,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: omapi.c,v 1.35 2000/09/08 01:34:30 mellon Exp $ Copyright (c) 1999-2000 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: omapi.c,v 1.36 2000/09/27 23:37:44 mellon Exp $ Copyright (c) 1999-2000 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -973,9 +973,8 @@ isc_result_t dhcp_host_signal_handler (omapi_object_t *h,
        host = (struct host_decl *)h;
 
        if (!strcmp (name, "updated")) {
-               if ((host -> interface.hlen == 0 ||
-                    host -> interface.hbuf [0] == 0 ||
-                    host -> interface.hlen > 17) &&
+               /* There must be a client identifier of some sort. */
+               if (host -> interface.hlen == 0 &&
                    !host -> client_identifier.len)
                        return ISC_R_INVALIDARG;