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.1.1.5 (requested by me...



details:   https://anonhg.NetBSD.org/src/rev/a124ead81172
branches:  netbsd-1-5
changeset: 491105:a124ead81172
user:      he <he%NetBSD.org@localhost>
date:      Wed Apr 04 20:56:21 2001 +0000

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

diffstat:

 usr.sbin/dhcp/dhcpctl/Makefile.dist      |   17 +-
 usr.sbin/dhcp/includes/omapip/omapip_p.h |   18 +-
 usr.sbin/dhcp/includes/tree.h            |   34 +-
 usr.sbin/dhcp/omapip/connection.c        |  423 ++++++++++++++++++++++++------
 usr.sbin/dhcp/server/class.c             |   12 +-
 5 files changed, 395 insertions(+), 109 deletions(-)

diffs (truncated from 710 to 300 lines):

diff -r 3978f103158e -r a124ead81172 usr.sbin/dhcp/dhcpctl/Makefile.dist
--- a/usr.sbin/dhcp/dhcpctl/Makefile.dist       Wed Apr 04 20:56:18 2001 +0000
+++ b/usr.sbin/dhcp/dhcpctl/Makefile.dist       Wed Apr 04 20:56:21 2001 +0000
@@ -24,19 +24,18 @@
 MAN    = dhcpctl.3
 HDRS   = dhcpctl.h
 
-DEBUG  = -g
 INCLUDES = $(BINDINC) -I$(TOP)/includes
 CFLAGS = $(DEBUG) $(PREDEFINES) $(INCLUDES) $(COPTS)
+DHCPCTLLIBS = libdhcpctl.a ../common/libdhcp.a $(BINDLIB) \
+               ../omapip/libomapi.a ../dst/libdst.a
 
-all:   libdhcpctl.a svtest cltest $(CATMANPAGES)
+all:   libdhcpctl.a omshell cltest $(CATMANPAGES)
 
-svtest:        test.o libdhcpctl.a ../omapip/libomapi.a $(BINDLIB)
-       $(CC) $(DEBUG) $(LFLAGS) -o svtest test.o libdhcpctl.a \
-                       ../omapip/libomapi.a $(BINDLIB) $(LIBS)
+omshell:       omshell.o $(DHCPCTLLIBS)
+       $(CC) $(DEBUG) $(LFLAGS) -o omshell omshell.o $(DHCPCTLLIBS) $(LIBS)
 
-cltest:        cltest.o libdhcpctl.a ../omapip/libomapi.a $(BINDLIB)
-       $(CC) $(DEBUG) $(LFLAGS) -o cltest cltest.o libdhcpctl.a \
-                       ../omapip/libomapi.a $(BINDLIB) $(LIBS)
+cltest:        cltest.o $(DHCPCTLLIBS)
+       $(CC) $(DEBUG) $(LFLAGS) -o cltest cltest.o $(DHCPCTLLIBS) $(LIBS)
 
 libdhcpctl.a:  $(OBJ)
        rm -f libdhcpctl.a
@@ -78,7 +77,7 @@
        -rm -f Makefile
 
 links:
-       @for foo in $(SRC) $(MAN) test.c cltest.c $(HDRS); do \
+       @for foo in $(SRC) $(MAN) omshell.c cltest.c $(HDRS); do \
          if [ ! -b $$foo ]; then \
            rm -f $$foo; \
          fi; \
diff -r 3978f103158e -r a124ead81172 usr.sbin/dhcp/includes/omapip/omapip_p.h
--- a/usr.sbin/dhcp/includes/omapip/omapip_p.h  Wed Apr 04 20:56:18 2001 +0000
+++ b/usr.sbin/dhcp/includes/omapip/omapip_p.h  Wed Apr 04 20:56:21 2001 +0000
@@ -3,7 +3,7 @@
    Private master include file for the OMAPI library. */
 
 /*
- * Copyright (c) 1996-2000 Internet Software Consortium.
+ * Copyright (c) 1996-2001 Internet Software Consortium.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -75,6 +75,7 @@
 #include <omapip/convert.h>
 #include <omapip/hash.h>
 #include <omapip/omapip.h>
+#include <omapip/trace.h>
 
 /* OMAPI protocol header, version 1.00 */
 typedef struct {
@@ -172,6 +173,7 @@
 typedef struct __omapi_listener_object {
        OMAPI_OBJECT_PREAMBLE;
        int socket;             /* Connection socket. */
+       int index;
        struct sockaddr_in address;
        isc_result_t (*verify_addr) (omapi_object_t *, omapi_addr_t *);
 } omapi_listener_object_t;
@@ -179,6 +181,7 @@
 typedef struct __omapi_connection_object {
        OMAPI_OBJECT_PREAMBLE;
        int socket;             /* Connection socket. */
+       int32_t index;
        omapi_connection_state_t state;
        struct sockaddr_in remote_addr;
        struct sockaddr_in local_addr;
@@ -261,6 +264,19 @@
                                         const unsigned char *data,
                                         const unsigned len,
                                         omapi_typed_data_t **result);
+isc_result_t omapi_listener_connect (omapi_connection_object_t **obj,
+                                    omapi_listener_object_t *listener,
+                                    int socket,
+                                    struct sockaddr_in *remote_addr);
+void omapi_listener_trace_setup (void);
+void omapi_connection_trace_setup (void);
+void omapi_buffer_trace_setup (void);
+void omapi_connection_register (omapi_connection_object_t *,
+                               const char *, int);
+void trace_mr_init (void);
+
+OMAPI_ARRAY_TYPE_DECL(omapi_listener, omapi_listener_object_t);
+OMAPI_ARRAY_TYPE_DECL(omapi_connection, omapi_connection_object_t);
 
 extern int log_priority;
 extern int log_perror;
diff -r 3978f103158e -r a124ead81172 usr.sbin/dhcp/includes/tree.h
--- a/usr.sbin/dhcp/includes/tree.h     Wed Apr 04 20:56:18 2001 +0000
+++ b/usr.sbin/dhcp/includes/tree.h     Wed Apr 04 20:56:21 2001 +0000
@@ -3,7 +3,7 @@
    Definitions for address trees... */
 
 /*
- * Copyright (c) 1996-1999 Internet Software Consortium.
+ * Copyright (c) 1996-2001 Internet Software Consortium.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -47,6 +47,22 @@
        struct _pair *cdr;
 } *pair;
 
+struct option_chain_head {
+       int refcnt;
+       pair first;
+};
+
+struct enumeration_value {
+       const char *name;
+       u_int8_t value;
+};
+
+struct enumeration {
+       struct enumeration *next;
+       const char *name;
+       struct enumeration_value *values;
+};     
+
 /* Tree node types... */
 #define TREE_CONCAT            1
 #define TREE_HOST_LOOKUP       2
@@ -182,7 +198,8 @@
        expr_remainder,
        expr_binary_and,
        expr_binary_or,
-       expr_binary_xor
+       expr_binary_xor,
+       expr_client_state
 };
 
 struct expression {
@@ -281,6 +298,7 @@
 struct option_state; /* forward */
 struct decoded_option_state; /* forward */
 struct lease; /* forward */
+struct client_state; /* forward */
 
 struct universe {
        const char *name;
@@ -289,11 +307,13 @@
                                             unsigned);
        void (*save_func) (struct universe *, struct option_state *,
                           struct option_cache *);
-       void (*foreach) (struct packet *, struct lease *,
+       void (*foreach) (struct packet *,
+                        struct lease *, struct client_state *,
                         struct option_state *, struct option_state *,
                         struct binding_scope **, struct universe *, void *,
                         void (*) (struct option_cache *, struct packet *,
-                                  struct lease *, struct option_state *,
+                                  struct lease *, struct client_state *,
+                                  struct option_state *,
                                   struct option_state *,
                                   struct binding_scope **,
                                   struct universe *, void *));
@@ -303,10 +323,10 @@
                                         struct option_state *,
                                         const char *, int);
        int (*decode) (struct option_state *,
-                      unsigned char *, unsigned, struct universe *);
+                      const unsigned char *, unsigned, struct universe *);
        int (*encapsulate) (struct data_string *, struct packet *,
-                           struct lease *, struct option_state *,
-                           struct option_state *,
+                           struct lease *, struct client_state *,
+                           struct option_state *, struct option_state *,
                            struct binding_scope **,
                            struct universe *);
        void (*store_tag) PROTO ((unsigned char *, u_int32_t));
diff -r 3978f103158e -r a124ead81172 usr.sbin/dhcp/omapip/connection.c
--- a/usr.sbin/dhcp/omapip/connection.c Wed Apr 04 20:56:18 2001 +0000
+++ b/usr.sbin/dhcp/omapip/connection.c Wed Apr 04 20:56:21 2001 +0000
@@ -3,7 +3,7 @@
    Subroutines for dealing with connections. */
 
 /*
- * Copyright (c) 1999-2000 Internet Software Consortium.
+ * Copyright (c) 1999-2001 Internet Software Consortium.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -43,6 +43,18 @@
 
 #include <omapip/omapip_p.h>
 #include <arpa/inet.h>
+#include <arpa/nameser.h>
+
+
+#if defined (TRACING)
+static void trace_connect_input (trace_type_t *, unsigned, char *);
+static void trace_connect_stop (trace_type_t *);
+static void trace_disconnect_input (trace_type_t *, unsigned, char *);
+static void trace_disconnect_stop (trace_type_t *);
+trace_type_t *trace_connect;
+trace_type_t *trace_disconnect;
+extern omapi_array_t *trace_listeners;
+#endif
 
 OMAPI_OBJECT_ALLOC (omapi_connection,
                    omapi_connection_object_t, omapi_type_connection)
@@ -107,6 +119,10 @@
        omapi_connection_object_t *obj;
        int flag;
        struct sockaddr_in local_sin;
+#if defined (TRACING)
+       trace_addr_t *addrs;
+       u_int16_t naddrs;
+#endif
 
        obj = (omapi_connection_object_t *)0;
        status = omapi_connection_allocate (&obj, MDL);
@@ -125,87 +141,294 @@
                return status;
        }
 
-       /* Create a socket on which to communicate. */
-       obj -> socket =
-               socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
-       if (obj -> socket < 0) {
-               omapi_connection_dereference (&obj, MDL);
-               if (errno == EMFILE || errno == ENFILE || errno == ENOBUFS)
-                       return ISC_R_NORESOURCES;
-               return ISC_R_UNEXPECTED;
-       }
-
-       /* Set up the local address, if any. */
-       if (local_addr) {
-               /* Only do TCPv4 so far. */
-               if (local_addr -> addrtype != AF_INET) {
-                       omapi_connection_dereference (&obj, MDL);
-                       return ISC_R_INVALIDARG;
-               }
-               local_sin.sin_port = htons (local_addr -> port);
-               memcpy (&local_sin.sin_addr,
-                       local_addr -> address,
-                       local_addr -> addrlen);
-#if defined (HAVE_SA_LEN)
-               local_sin.sin_len = sizeof local_addr;
-#endif
-               local_sin.sin_family = AF_INET;
-               memset (&local_sin.sin_zero, 0, sizeof local_sin.sin_zero);
-
-               if (bind (obj -> socket, (struct sockaddr *)&local_sin,
-                         sizeof local_sin) < 0) {
-                       omapi_object_dereference ((omapi_object_t **)&obj,
-                                                 MDL);
-                       if (errno == EADDRINUSE)
-                               return ISC_R_ADDRINUSE;
-                       if (errno == EADDRNOTAVAIL)
-                               return ISC_R_ADDRNOTAVAIL;
-                       if (errno == EACCES)
-                               return ISC_R_NOPERM;
-                       return ISC_R_UNEXPECTED;
-               }
-       }
-
-#if defined (HAVE_SETFD)
-       if (fcntl (obj -> socket, F_SETFD, 1) < 0) {
-               close (obj -> socket);
-               omapi_connection_dereference (&obj, MDL);
-               return ISC_R_UNEXPECTED;
-       }
-#endif
-
-       /* Set the SO_REUSEADDR flag (this should not fail). */
-       flag = 1;
-       if (setsockopt (obj -> socket, SOL_SOCKET, SO_REUSEADDR,
-                       (char *)&flag, sizeof flag) < 0) {
-               omapi_connection_dereference (&obj, MDL);
-               return ISC_R_UNEXPECTED;
-       }
-       
-       /* Set the file to nonblocking mode. */
-       if (fcntl (obj -> socket, F_SETFL, O_NONBLOCK) < 0) {
-               omapi_connection_dereference (&obj, MDL);
-               return ISC_R_UNEXPECTED;
-       }
-
        /* Store the address list on the object. */
        omapi_addr_list_reference (&obj -> connect_list, remote_addrs, MDL);
        obj -> cptr = 0;
+       obj -> state = omapi_connection_unconnected;
 
-       status = (omapi_register_io_object
-                 ((omapi_object_t *)obj,
-                  0, omapi_connection_writefd,
-                  0, omapi_connection_connect,
-                  omapi_connection_reaper));
-       if (status != ISC_R_SUCCESS)
-               goto out;
-       obj -> state = omapi_connection_unconnected;



Home | Main Index | Thread Index | Old Index