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



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

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

diffstat:

 usr.sbin/dhcp/common/alloc.c      |  116 +++++++-
 usr.sbin/dhcp/common/dlpi.c       |  248 ++++++++--------
 usr.sbin/dhcp/common/tree.c       |  573 ++++++++++++++++++++++++++++---------
 usr.sbin/dhcp/includes/cf/linux.h |    1 +
 4 files changed, 676 insertions(+), 262 deletions(-)

diffs (truncated from 1862 to 300 lines):

diff -r 37a0a8b051e9 -r fc6a47e03325 usr.sbin/dhcp/common/alloc.c
--- a/usr.sbin/dhcp/common/alloc.c      Wed Apr 04 20:55:55 2001 +0000
+++ b/usr.sbin/dhcp/common/alloc.c      Wed Apr 04 20:55:58 2001 +0000
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: alloc.c,v 1.1.1.6.2.2 2000/10/18 04:11:00 tv Exp $ Copyright (c) 1996-2000 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: alloc.c,v 1.1.1.6.2.3 2001/04/04 20:55:58 he Exp $ Copyright (c) 1996-2000 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -57,6 +57,120 @@
                    dhcp_type_shared_network)
 OMAPI_OBJECT_ALLOC (group_object, struct group_object, dhcp_type_group)
 
+int option_chain_head_allocate (ptr, file, line)
+       struct option_chain_head **ptr;
+       const char *file;
+       int line;
+{
+       int size;
+
+       if (!ptr) {
+               log_error ("%s(%d): null pointer", file, line);
+#if defined (POINTER_DEBUG)
+               abort ();
+#else
+               return 0;
+#endif
+       }
+       if (*ptr) {
+               log_error ("%s(%d): non-null pointer", file, line);
+#if defined (POINTER_DEBUG)
+               abort ();
+#else
+               *ptr = (struct option_chain_head *)0;
+#endif
+       }
+
+       *ptr = dmalloc (sizeof **ptr, file, line);
+       if (*ptr) {
+               memset (*ptr, 0, sizeof **ptr);
+               (*ptr) -> refcnt = 1;
+               return 1;
+       }
+       return 0;
+}
+
+int option_chain_head_reference (ptr, bp, file, line)
+       struct option_chain_head **ptr;
+       struct option_chain_head *bp;
+       const char *file;
+       int line;
+{
+       if (!ptr) {
+               log_error ("%s(%d): null pointer", file, line);
+#if defined (POINTER_DEBUG)
+               abort ();
+#else
+               return 0;
+#endif
+       }
+       if (*ptr) {
+               log_error ("%s(%d): non-null pointer", file, line);
+#if defined (POINTER_DEBUG)
+               abort ();
+#else
+               *ptr = (struct option_chain_head *)0;
+#endif
+       }
+       *ptr = bp;
+       bp -> refcnt++;
+       rc_register (file, line, ptr, bp, bp -> refcnt);
+       dmalloc_reuse (bp, file, line, 1);
+       return 1;
+}
+
+int option_chain_head_dereference (ptr, file, line)
+       struct option_chain_head **ptr;
+       const char *file;
+       int line;
+{
+       int i;
+       struct option_chain_head *option_chain_head;
+       pair car, cdr;
+
+       if (!ptr || !*ptr) {
+               log_error ("%s(%d): null pointer", file, line);
+#if defined (POINTER_DEBUG)
+               abort ();
+#else
+               return 0;
+#endif
+       }
+
+       option_chain_head = *ptr;
+       *ptr = (struct option_chain_head *)0;
+       --option_chain_head -> refcnt;
+       rc_register (file, line, ptr,
+                    option_chain_head, option_chain_head -> refcnt);
+       if (option_chain_head -> refcnt > 0)
+               return 1;
+
+       if (option_chain_head -> refcnt < 0) {
+               log_error ("%s(%d): negative refcnt!", file, line);
+#if defined (DEBUG_RC_HISTORY)
+               dump_rc_history ();
+#endif
+#if defined (POINTER_DEBUG)
+               abort ();
+#else
+               return 0;
+#endif
+       }
+
+       /* If there are any options on this head, free them. */
+       for (car = option_chain_head -> first; car; car = cdr) {
+               cdr = car -> cdr;
+               if (car -> car)
+                       option_cache_dereference ((struct option_cache **)
+                                                 (&car -> car), MDL);
+               dfree (car, MDL);
+               car = cdr;
+       }
+
+       dfree (option_chain_head, file, line);
+       return 1;
+}
+
 int group_allocate (ptr, file, line)
        struct group **ptr;
        const char *file;
diff -r 37a0a8b051e9 -r fc6a47e03325 usr.sbin/dhcp/common/dlpi.c
--- a/usr.sbin/dhcp/common/dlpi.c       Wed Apr 04 20:55:55 2001 +0000
+++ b/usr.sbin/dhcp/common/dlpi.c       Wed Apr 04 20:55:58 2001 +0000
@@ -84,7 +84,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: dlpi.c,v 1.1.1.7.2.1 2000/10/18 04:11:03 tv Exp $ Copyright (c) 1996-2000 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: dlpi.c,v 1.1.1.7.2.2 2001/04/04 20:55:59 he Exp $ Copyright (c) 1996-2000 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -130,15 +130,7 @@
 #define DLPI_MAXDLBUF          8192    /* Buffer size */
 #define DLPI_MAXDLADDR         1024    /* Max address size */
 #define DLPI_DEVDIR            "/dev/" /* Device directory */
-#define DLPI_DEFAULTSAP                0x0800  /* IP protocol */
 
-static void dlpi_makeaddr PROTO ((unsigned char *physaddr, int physaddrlen,
-                                 unsigned char *sap, int saplen,
-                                 unsigned char *buf));
-static void dlpi_parseaddr PROTO ((unsigned char *buf,
-                                  unsigned char *physaddr,
-                                  int physaddrlen, unsigned char *sap,
-                                  int saplen));
 static int dlpiopen PROTO ((char *ifname));
 static int dlpiunit PROTO ((char *ifname));
 static int dlpiinforeq PROTO ((int fd));
@@ -211,13 +203,10 @@
            log_fatal ("Can't open DLPI device for %s: %m", info -> name);
        }
 
-       /*
-        * Get information about the provider.
-        */
 
        /*
-        * Submit a DL_INFO_REQ request, to find
-        * the dl_mac_type and dl_provider_style
+       * Submit a DL_INFO_REQ request, to find the dl_mac_type and 
+         * dl_provider_style
         */
        if (dlpiinforeq(sock) < 0 || dlpiinfoack(sock, (char *)buf) < 0) {
            log_fatal ("Can't get DLPI MAC type for %s: %m", info -> name);
@@ -235,11 +224,21 @@
                info -> hw_address.hbuf [0] = HTYPE_FDDI;
                break;
              default:
-               log_fatal ("%s: unknown DLPI MAC type %ld",
-                      info -> name,
-                      dlp -> info_ack.dl_mac_type);
+              log_fatal ("%s: unsupported DLPI MAC type %ld",
+                     info -> name, dlp -> info_ack.dl_mac_type);
                break;
            }
+            /*
+             * copy the sap length and broadcast address of this interface
+             * to interface_info. This fixes nothing but seemed nicer than to
+             * assume -2 and ffffff.
+             */
+            info -> dlpi_sap_length = dlp -> info_ack.dl_sap_length;
+            info -> dlpi_broadcast_addr.hlen = 
+             dlp -> info_ack.dl_brdcst_addr_length;
+            memcpy (info -> dlpi_broadcast_addr.hbuf, 
+             (char *)dlp + dlp -> info_ack.dl_brdcst_addr_offset, 
+             dlp -> info_ack.dl_brdcst_addr_length);
        }
 
        if (dlp -> info_ack.dl_provider_style == DL_STYLE2) {
@@ -258,7 +257,7 @@
        /*
         * Bind to the IP service access point (SAP), connectionless (CLDLS).
         */
-       if (dlpibindreq (sock, DLPI_DEFAULTSAP, 0, DL_CLDLS, 0, 0) < 0
+      if (dlpibindreq (sock, ETHERTYPE_IP, 0, DL_CLDLS, 0, 0) < 0
            || dlpibindack (sock, (char *)buf) < 0) {
            log_fatal ("Can't bind DLPI device for %s: %m", info -> name);
        }
@@ -404,6 +403,8 @@
 {
 #ifdef USE_DLPI_PFMOD
        struct packetfilt pf;
+        struct ip iphdr;
+        u_int16_t offset;
 #endif
 
        /* Open a DLPI device and hang it on this interface... */
@@ -417,19 +418,18 @@
        pf.Pf_Priority = 0;
        pf.Pf_FilterLen = 0;
 
-#ifdef USE_DLPI_RAW
-       pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + 6;
-       pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT + ENF_CAND;
-       pf.Pf_Filter [pf.Pf_FilterLen++] = htons (ETHERTYPE_IP);
-       pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT;
-       pf.Pf_Filter [pf.Pf_FilterLen++] = htons (IPPROTO_UDP);
-       pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + 11;
-       pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSH00FF + ENF_AND;
-       pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_CAND;
-       pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + 18;
-       pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT + ENF_CAND;
-       pf.Pf_Filter [pf.Pf_FilterLen++] = htons (local_port);
-#else
+#if defined (USE_DLPI_RAW)
+# define ETHER_H_PREFIX (14) /* sizeof (ethernet_header) */
+    /*
+     * ethertype == ETHERTYPE_IP
+     */
+    offset = 12;
+    pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + (offset / 2);
+    pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT | ENF_CAND;
+    pf.Pf_Filter [pf.Pf_FilterLen++] = htons (ETHERTYPE_IP);
+# else
+# define ETHER_H_PREFIX (0)
+# endif /* USE_DLPI_RAW */
        /*
         * The packets that will be received on this file descriptor
         * will be IP packets (due to the SAP that was specified in
@@ -439,22 +439,32 @@
         * to the local port.  All offsets are relative to the start
         * of an IP packet.
         */
-       pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT;
-       pf.Pf_Filter [pf.Pf_FilterLen++] = htons (IPPROTO_UDP);
-       pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + 4;
-       pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSH00FF + ENF_AND;
-       pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_CAND;
-       pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + 11;
-       pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT + ENF_CAND;
-       pf.Pf_Filter [pf.Pf_FilterLen++] = htons (local_port);
-#endif
+
+        /*
+         * BOOTPS destination port
+         */
+        offset = ETHER_H_PREFIX + sizeof (iphdr) + sizeof (u_int16_t);
+        pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + (offset / 2);
+        pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT | ENF_CAND;
+        pf.Pf_Filter [pf.Pf_FilterLen++] = local_port;
+
+        /*
+         * protocol should be udp. this is a byte compare, test for
+         * endianess.
+         */
+        offset = ETHER_H_PREFIX + ((u_int8_t *)&(iphdr.ip_p) - (u_int8_t *)&iphdr);
+        pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + (offset / 2);
+        pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT | ENF_AND;
+        pf.Pf_Filter [pf.Pf_FilterLen++] = htons (0x00FF);
+        pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT | ENF_CAND;
+      pf.Pf_Filter [pf.Pf_FilterLen++] = htons (IPPROTO_UDP);
 
        /* Install the filter... */
        if (strioctl (info -> rfdesc, PFIOCSETF, INFTIM,
                      sizeof (pf), (char *)&pf) < 0) {
            log_fatal ("Can't set PFMOD receive filter on %s: %m", info -> name);
        }
-#endif
+#endif /* USE_DLPI_PFMOD */
 
         if (!quiet_interface_discovery)
                log_info ("Listening on DLPI/%s/%s%s%s",
@@ -509,14 +519,12 @@
        struct hardware *hto;
 {
        unsigned hbufp = 0;
-       double hh [16];



Home | Main Index | Thread Index | Old Index