]> The Tcpdump Group git mirrors - tcpdump/commitdiff
use draft 22 declaration for dhcp6 (which is under dhcwg last call - hope
authoritojun <itojun>
Thu, 10 Jan 2002 09:05:07 +0000 (09:05 +0000)
committeritojun <itojun>
Thu, 10 Jan 2002 09:05:07 +0000 (09:05 +0000)
it does not change again).

FILES
dhcp6.h [deleted file]
dhcp6opt.h [deleted file]
print-dhcp6.c

diff --git a/FILES b/FILES
index 3b4f3d42ad2b328c80229619e617de8b547ca5c4..c65384efe94359f35e6ecdb356449221b77397e7 100644 (file)
--- a/FILES
+++ b/FILES
@@ -23,8 +23,6 @@ config.sub
 configure
 configure.in
 decnet.h
-dhcp6.h
-dhcp6opt.h
 esp.h
 ether.h
 ethertype.h
diff --git a/dhcp6.h b/dhcp6.h
deleted file mode 100644 (file)
index 044fad6..0000000
--- a/dhcp6.h
+++ /dev/null
@@ -1,200 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/Attic/dhcp6.h,v 1.4 2000-12-17 23:07:48 guy Exp $ (LBL) */
-/*
- * Copyright (C) 1998 and 1999 WIDE Project.
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 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 project nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-/*
- * draft-ietf-dhc-dhcpv6-15
- */
-
-#ifndef __DHCP6_H_DEFINED
-#define __DHCP6_H_DEFINED
-
-/* Error Values */
-#define DH6ERR_FAILURE         16
-#define DH6ERR_AUTHFAIL                17
-#define DH6ERR_POORLYFORMED    18
-#define DH6ERR_UNAVAIL         19
-#define DH6ERR_NOBINDING       20
-#define DH6ERR_INVALIDSOURCE   21
-#define DH6ERR_NOSERVER                23
-#define DH6ERR_ICMPERROR       64
-
-/* Message type */
-#define DH6_SOLICIT    1
-#define DH6_ADVERT     2
-#define DH6_REQUEST    3
-#define DH6_REPLY      4
-#define DH6_RELEASE    5
-#define DH6_RECONFIG   6
-
-/* Predefined addresses */
-#define DH6ADDR_ALLAGENT       "ff02::1:2"
-#define DH6ADDR_ALLSERVER      "ff05::1:3"
-#define DH6ADDR_ALLRELAY       "ff05::1:4"
-#define DH6PORT_DOWNSTREAM     "546"
-#define DH6PORT_UPSTREAM       "547"
-
-/* Protocol constants */
-#define ADV_CLIENT_WAIT                2       /* sec */
-#define DEFAULT_SOLICIT_HOPCOUNT       4
-#define SERVER_MIN_ADV_DELAY   100     /* msec */
-#define SERVER_MAX_ADV_DELAY   1000    /* msec */
-#define REPLY_MSG_TIMEOUT      2       /* sec */
-#define REQUEST_MSG_MIN_RETRANS        10      /* retransmissions */
-#define RECONF_MSG_MIN_RETRANS 10      /* retransmissions */
-#define RECONF_MSG_RETRANS_INTERVAL    12      /* sec */
-#define RECONF_MMSG_MIN_RESP   2       /* sec */
-#define RECONF_MMSG_MAX_RESP   10      /* sec */
-#define RECONF_MULTICAST_REQUEST_WAIT  120     /* sec */
-#define MIN_SOLICIT_DELAY      1       /* sec */
-#define MAX_SOLICIT_DELAY      5       /* sec */
-#define XID_TIMEOUT            600     /* sec */
-
-/* DHCP6 base packet format */
-struct dhcp6_solicit {
-       u_int8_t dh6sol_msgtype;                /* DH6_SOLICIT */
-       u_int8_t dh6sol_flags;
-#define DH6SOL_CLOSE   0x80
-#define DH6SOL_PREFIX  0x40
-       /* XXX: solicit-ID is a 9-bit field...ugly! */
-#define DH6SOL_SOLICIT_ID_MASK 0x01ff
-#define DH6SOL_SOLICIT_ID_SHIFT 0
-#define DH6SOL_SOLICIT_ID(x) \
-    (((x) & DH6SOL_SOLICIT_ID_MASK) >> DH6SOL_SOLICIT_ID_SHIFT)
-#define DH6SOL_SOLICIT_PLEN_MASK 0xfe00
-#define DH6SOL_SOLICIT_PLEN_SHIFT 9
-#define DH6SOL_SOLICIT_PLEN(x) \
-    (((x) & DH6SOL_SOLICIT_PLEN_MASK) >> DH6SOL_SOLICIT_PLEN_SHIFT)
-       u_int16_t dh6sol_plen_id; /* prefix-len and solict-ID */
-       struct in6_addr dh6sol_cliaddr; /* client's lladdr */
-       struct in6_addr dh6sol_relayaddr; /* relay agent's lladdr */
-};
-
-struct dhcp6_advert {
-       u_int8_t dh6adv_msgtype;                /* DH6_ADVERT */
-       u_int8_t dh6adv_rsv_id; /* reserved and uppermost bit of ID */
-       u_int8_t dh6adv_solcit_id; /* lower 8 bits of solicit-ID */
-       u_int8_t dh6adv_pref;
-       struct in6_addr dh6adv_cliaddr; /* client's link-local addr */
-       struct in6_addr dh6adv_relayaddr; /* relay agent's (non-ll) addr */
-       struct in6_addr dh6adv_serveraddr; /* server's addr */
-       /* extensions */
-};
-
-struct dhcp6_request {
-       u_int8_t dh6req_msgtype;                /* DH6_REQUEST */
-       u_int8_t dh6req_flags;
-#define DH6REQ_CLOSE           0x80
-#define DH6REQ_REBOOT          0x40
-       u_int16_t dh6req_xid;           /* transaction-ID */
-       struct in6_addr dh6req_cliaddr; /* client's lladdr */
-       struct in6_addr dh6req_relayaddr; /* relay agent's (non-ll) addr */
-       struct in6_addr dh6req_serveraddr; /* server's addr */
-       /* extensions */
-};
-
-struct dhcp6_reply {
-       u_int8_t dh6rep_msgtype;                /* DH6_REPLY */
-       u_int8_t dh6rep_flagandstat;
-#define DH6REP_RELAYPRESENT    0x80
-#define DH6REP_STATMASK                0x7f
-       u_int16_t dh6rep_xid;           /* transaction-ID */
-       struct in6_addr dh6rep_cliaddr; /* client's lladdr */
-       /* struct in6_addr dh6rep_relayaddr; optional: relay address */
-       /* extensions */
-};
-
-/* XXX: followings are based on older drafts */
-struct dhcp6_release {
-       u_int8_t dh6rel_msgtype;                /* DH6_RELEASE */
-       u_int8_t dh6rel_flags;
-#define DH6REL_DIRECT  0x80
-       u_int16_t dh6rel_xid;           /* transaction-ID */
-       struct in6_addr dh6rel_cliaddr; /* client's lladdr */
-       struct in6_addr dh6rel_relayaddr; /* relay agent's (non-ll) addr */
-       struct in6_addr dh6rel_reladdr; /* server's addr to be released */
-       /* extensions */
-};
-
-struct dhcp6_reconfig {
-       u_int8_t dh6cfg_msgtype;                /* DH6_RECONFIG */
-       u_int8_t dh6cfg_flags;
-#define DH6REP_NOREPLY 0x80
-       u_int16_t dh6cfg_xid;           /* transaction-ID */
-       struct in6_addr dh6cfg_servaddr; /* server's addr */
-       /* extensions */
-};
-
-union dhcp6 {
-       u_int8_t dh6_msgtype;
-       struct dhcp6_solicit dh6_sol;
-       struct dhcp6_advert dh6_adv;
-       struct dhcp6_request dh6_req;
-       struct dhcp6_reply dh6_rep;
-       struct dhcp6_release dh6_rel;
-       struct dhcp6_reconfig dh6_cfg;
-};
-
-/* DHCP6 extension */
-struct dhcp6e_ipaddr {
-       u_int16_t dh6eip_type;
-       u_int16_t dh6eip_len;
-       u_int8_t dh6eip_status;
-#define DH6EX_IP_SUCCESS       0       /* request granted, no errors */
-#define DH6EX_IP_SECFAIL       18      /* Security parameters failed */
-#define DH6EX_IP_AAAAFAIL      20      /* AAAA Record Parameter Problem */
-#define DH6EX_IP_PTRFAIL       21      /* PTR Record Parameter Problem */
-#define DH6EX_IP_PARAMFAIL     22      /* Unable to honor required params */
-#define DH6EX_IP_DNSNAMEFAIL   23      /* DNS name string error */
-#define DH6EX_IP_NODYNDNS      24      /* dynDNS Not Implemented */
-#define DH6EX_IP_NOAUTHDNS     25      /* Authoritative DNS Server not found */
-#define DH6EX_IP_DNSFORMFAIL   33      /* DNS format error */
-#define DH6EX_IP_SERVFAIL      34      /* dynDNS unavailable at this time */
-#define DH6EX_IP_NXDOMAIN      35      /* name does not exist */
-#define DH6EX_IP_NOTIMP                36      /* DNS does not support the Opcode */
-#define DH6EX_IP_REFUSED       37      /* DNS refuses specified operation */
-#define DH6EX_IP_YXDOMAIN      38      /* name does not exist */
-#define DH6EX_IP_YXRRSET       39      /* RRset does not exist */
-#define DH6EX_IP_NXRRSET       40      /* RRset does not exist */
-#define DH6EX_IP_NOTAUTH       41      /* non authoritative name server */
-#define DH6EX_IP_NOTZONE       42      /* prerequisite out of zone */
-       u_int8_t dh6eip_flags;
-#define DH6EX_IP_CLIANTADDR    0x80    /* C: cliant's addr */
-#define DH6EX_IP_LIFETIME      0x40    /* L: preferred/valid lifetime */
-#define DH6EX_IP_FORCEOPTS     0x20    /* Q: options are mandatory */
-#define DH6EX_IP_AAAA          0x10    /* A: DNS dynamic update for AAAA */
-#define DH6EX_IP_PTR           0x08    /* P: DNS dynamic update for PTR*/
-       u_int8_t dh6eip_pad;
-       u_int8_t dh6eip_prefixlen;
-       /* struct in6_addr: client's address (if C bit = 1) */
-       /* u_int: preferred lifetime (if L bit = 1) */
-       /* u_int: valid lifetime (if L bit = 1) */
-       /* string: DNS name */
-};
-
-#endif /*__DHCP6_H_DEFINED*/
diff --git a/dhcp6opt.h b/dhcp6opt.h
deleted file mode 100644 (file)
index fac577d..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/Attic/dhcp6opt.h,v 1.4 2001-09-17 21:57:51 fenner Exp $ (LBL) */
-/*
- * Copyright (C) 1998 and 1999 WIDE Project.
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 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 project nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * draft-ietf-dhc-v6exts-11
- */
-
-#ifndef __DHCP6OPT_H_DEFINED
-#define __DHCP6OPT_H_DEFINED
-
-#define OL6_N  -1
-#define OL6_16N        -2
-#define OL6_Z  -3
-
-#define OT6_NONE       0
-#define OT6_V6         1
-#define OT6_STR                2
-#define OT6_NUM                3
-
-struct dhcp6_opt {
-       u_int code;
-       int len;
-       const char *name;
-       int type;
-};
-
-/* index to parameters */
-#define DH6T_CLIENT_ADV_WAIT           1       /* milliseconds */
-#define DH6T_DEFAULT_SOLICIT_HOPCOUNT  2       /* times */
-#define DH6T_SERVER_MIN_ADV_DELAY      3       /* milliseconds */
-#define DH6T_SERVER_MAX_ADV_DELAY      4       /* milliseconds */
-#define DH6T_REQUEST_MSG_MIN_RETRANS   5       /* retransmissions */
-#define DH6T_REPLY_MSG_TIMEOUT         6       /* milliseconds */
-#define DH6T_REPLY_MSG_RETRANS_INTERVAL        7       /* milliseconds */
-#define DH6T_RECONF_MSG_TIMEOUT                8       /* milliseconds */
-#define DH6T_RECONF_MSG_MIN_RETRANS    9       /* retransmissions */
-#define DH6T_RECONF_MSG_RETRANS_INTERVAL 10    /* milliseconds */
-#define DH6T_RECONF_MMSG_MIN_RESP      11      /* milliseconds */
-#define DH6T_RECONF_MMSG_MAX_RESP      12      /* milliseconds */
-#define DH6T_MIN_SOLICIT_DELAY         13      /* milliseconds */
-#define DH6T_MAX_SOLICIT_DELAY         14      /* milliseconds */
-#define DH6T_XID_TIMEOUT               15      /* milliseconds */
-#define DH6T_RECONF_MULTICAST_REQUEST_WAIT 16  /* milliseconds */
-
-#if 0
-extern struct dhcp6_opt *dh6o_pad;
-extern struct dhcp6_opt *dh6o_end;
-extern int dhcp6_param[];
-extern void dhcp6opttab_init (void);
-extern struct dhcp6_opt *dhcp6opttab_byname (char *);
-extern struct dhcp6_opt *dhcp6opttab_bycode (u_int);
-#endif
-
-#endif /*__DHCP6OPT_H_DEFINED*/
index 6cb83ea6297813a66ce9f8233f48102f0575a8e1..cca0030fb6f7357613d877f9d78d8e9d455db34f 100644 (file)
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+/*
+ * draft-ietf-dhc-dhcpv6-22.txt
+ */
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.14 2001-09-17 21:57:59 fenner Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.15 2002-01-10 09:05:09 itojun Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -52,172 +55,125 @@ struct rtentry;
 
 #include "interface.h"
 #include "addrtoname.h"
-#include "dhcp6.h"
-#include "dhcp6opt.h"
-
-#if 0
-static void dhcp6opttab_init(void);
-static struct dhcp6_opt *dhcp6opttab_byname(char *);
-#endif
-static struct dhcp6_opt *dhcp6opttab_bycode(u_int);
-
-static const char tstr[] = " [|dhcp6]";
-
-static struct dhcp6_opt dh6opttab[] = {
-       /* IP Address Extension */
-       { 1, OL6_N,     "IP Address",                   OT6_NONE, },
-
-       /* General Extension */
-       { 8193, OL6_N,  "IEEE 1003.1 POSIX Timezone",   OT6_STR, },
-       { 8194, OL6_16N, "Domain Name Server",          OT6_V6, },
-       { 8195, OL6_N,  "Domain Name",                  OT6_STR, },
-
-       { 8196, OL6_N,  "SLP Agent",                    OT6_NONE, },
-       { 8197, OL6_N,  "SLP Scope"     ,               OT6_NONE, },
-       { 8198, OL6_16N, "Network Time Protocol Servers", OT6_V6, },
-       { 8199, OL6_N,  "NIS Domain",                   OT6_STR, },
-       { 8200, OL6_16N, "NIS Servers",                 OT6_V6, },
-       { 8201, OL6_N,  "NIS+ Domain",                  OT6_STR, },
-       { 8202, OL6_16N, "NIS+ Servers",                OT6_V6, },
-
-       /* TCP Parameters */
-       { 8203, 4,      "TCP Keepalive Interval",       OT6_NUM, },
 
-       /* DHCPv6 Extensions */
-       { 8204, 4,      "Maximum DHCPv6 Message Size",  OT6_NUM, },
-       { 8205, OL6_N,  "DHCP Retransmission and Configuration Parameter",
-                                                       OT6_NONE, },
-       { 8206, OL6_N,  "Extension Request",            OT6_NONE, },
-       { 8207, OL6_N,  "Subnet Prefix",                OT6_NONE, },
-       { 8208, OL6_N,  "Platform Specific Information", OT6_NONE, },
-       { 8209, OL6_N,  "Platform Class Identifier",    OT6_STR, },
-       { 8210, OL6_N,  "Class Identifier",             OT6_STR, },
-       { 8211, 16,     "Reconfigure Multicast Address", OT6_V6, },
-       { 8212, 16,     "Renumber DHCPv6 Server Address",
-                                                       OT6_V6, },
-       { 8213, OL6_N,  "Client-Server Authentication", OT6_NONE, },
-       { 8214, 4,      "Client Key Selection",         OT6_NUM, },
-
-       /* End Extension */
-       { 65536, OL6_Z, "End",                          OT6_NONE, },
-
-       { 0 },
-};
-
-#if 0
-static struct dhcp6_opt *dh6o_pad;
-static struct dhcp6_opt *dh6o_end;
+/* Error Values */
+#define DH6ERR_FAILURE         16
+#define DH6ERR_AUTHFAIL                17
+#define DH6ERR_POORLYFORMED    18
+#define DH6ERR_UNAVAIL         19
+#define DH6ERR_OPTUNAVAIL      20
+
+/* Message type */
+#define DH6_REPLY      7
+#define DH6_INFORM_REQ 11
+
+/* DHCP6 base packet format */
+struct dhcp6 {
+       union {
+               u_int8_t m;
+               u_int32_t x;
+       } dh6_msgtypexid;
+       struct in6_addr dh6_servaddr;
+       /* options follow */
+} __attribute__ ((__packed__));
+#define dh6_msgtype    dh6_msgtypexid.m
+#define dh6_xid                dh6_msgtypexid.x
+#define DH6_XIDMASK    0x00ffffff
+
+/* option */
+#define DH6OPT_DUID    1       /* TBD */
+#define DH6OPT_DNS     11      /* TBD */
+struct dhcp6opt {
+       u_int16_t dh6opt_type;
+       u_int16_t dh6opt_len;
+       /* type-dependent data follows */
+} __attribute__ ((__packed__));
 
 static void
-dhcp6opttab_init()
-{
-       dh6o_pad = dhcp6opttab_bycode(0);
-       dh6o_end = dhcp6opttab_bycode(65536);
-}
-#endif
-
-#if 0
-static struct dhcp6_opt *
-dhcp6opttab_byname(name)
-       char *name;
+dhcp6opt_print(u_char *cp, u_char *ep)
 {
-       struct dhcp6_opt *p;
-
-       for (p = dh6opttab; p->code; p++)
-               if (strcmp(name, p->name) == 0)
-                       return p;
-       return NULL;
-}
-#endif
-
-static struct dhcp6_opt *
-dhcp6opttab_bycode(code)
-       u_int code;
-{
-       struct dhcp6_opt *p;
-
-       for (p = dh6opttab; p->code; p++)
-               if (p->code == code)
-                       return p;
-       return NULL;
-}
-
-static void
-dhcp6ext_print(u_char *cp, u_char *ep)
-{
-       u_int16_t code, len;
-       struct dhcp6_opt *p;
-       char buf[BUFSIZ];
+       struct dhcp6opt *dh6o;
+       u_char *tp;
        int i;
+       size_t optlen;
 
        if (cp == ep)
                return;
        while (cp < ep) {
-               if (ep - cp < sizeof(u_int16_t))
-                       break;
-               code = ntohs(*(u_int16_t *)&cp[0]);
-               if (ep - cp < sizeof(u_int16_t) * 2)
-                       break;
-               if (code != 65535)
-                       len = ntohs(*(u_int16_t *)&cp[2]);
-               else
-                       len = 0;
-               if (ep - cp < len + 4)
-                       break;
-               p = dhcp6opttab_bycode(code);
-               if (p == NULL) {
-                       printf("(unknown, len=%d)", len);
-                       cp += len + 4;
-                       continue;
-               }
-
-               /* sanity check on length */
-               switch (p->len) {
-               case OL6_N:
-                       break;
-               case OL6_16N:
-                       if (len % 16 != 0)
-                               goto trunc;
-                       break;
-               case OL6_Z:
-                       if (len != 0)
-                               goto trunc;
+               if (ep - cp < sizeof(*dh6o))
+                       goto trunc;
+               dh6o = (struct dhcp6opt *)cp;
+               optlen = ntohs(dh6o->dh6opt_len);
+               if (ep - cp < sizeof(*dh6o) + optlen)
+                       goto trunc;
+               switch (ntohs(dh6o->dh6opt_type)) {
+               case DH6OPT_DUID:
+                       printf(" (duid");       /*)*/
+                       if (optlen < 2) {
+                               /*(*/
+                               printf(" ??)");
+                               break;
+                       }
+                       tp = (u_char *)(dh6o + 1);
+                       switch (ntohs(*(u_int16_t *)tp)) {
+                       case 1:
+                               if (optlen >= 2 + 6) {
+                                       printf(" hwaddr/time time %u type %u ",
+                                           ntohl(*(u_int32_t *)&tp[2]),
+                                           ntohs(*(u_int16_t *)&tp[6]));
+                                       for (i = 8; i < optlen; i++)
+                                               printf("%02x", tp[i]);
+                                       /*(*/
+                                       printf(")");
+                               } else {
+                                       /*(*/
+                                       printf(" ??)");
+                               }
+                               break;
+                       case 2:
+                               if (optlen >= 2 + 8) {
+                                       printf(" vid ");
+                                       for (i = 2; i < 2 + 8; i++)
+                                               printf("%02x", tp[i]);
+                                       /*(*/
+                                       printf(")");
+                               } else {
+                                       /*(*/
+                                       printf(" ??)");
+                               }
+                               break;
+                       case 3:
+                               if (optlen >= 2 + 2) {
+                                       printf(" hwaddr type %u ",
+                                           ntohs(*(u_int16_t *)&tp[2]));
+                                       for (i = 4; i < optlen; i++)
+                                               printf("%02x", tp[i]);
+                                       /*(*/
+                                       printf(")");
+                               } else {
+                                       /*(*/
+                                       printf(" ??)");
+                               }
+                       }
                        break;
+               case DH6OPT_DNS:
+                       printf(" (dnsserver");  /*)*/
+                       if (optlen % 16) {
+                               /*(*/
+                               printf(" ??)");
+                               break;
+                       }
+                       tp = (u_char *)(dh6o + 1);
+                       for (i = 0; i < optlen; i += 16)
+                               printf(" %s", ip6addr_string(&tp[i]));
+                       /*(*/
+                       printf(")");
                default:
-                       if (len != p->len)
-                               goto trunc;
+                       printf(" (opt-%u)", ntohs(dh6o->dh6opt_type));
                        break;
                }
-               if (cp + 4 + len > ep) {
-                       printf(" [|%s]", p->name);
-                       return;
-               }
 
-               printf(" (%s, ", p->name);
-               switch (p->type) {
-               case OT6_V6:
-                       for (i = 0; i < len; i += 16) {
-                               inet_ntop(AF_INET6, &cp[4 + i], buf,
-                                       sizeof(buf));
-                               if (i != 0)
-                                       printf(",");
-                               printf("%s", buf);
-                       }
-                       break;
-               case OT6_STR:
-                       memset(&buf, 0, sizeof(buf));
-                       strncpy(buf, &cp[4], len);
-                       printf("%s", buf);
-                       break;
-               case OT6_NUM:
-                       printf("%d", (u_int32_t)ntohl(*(u_int32_t *)&cp[4]));
-                       break;
-               default:
-                       for (i = 0; i < len; i++)
-                               printf("%02x", cp[4 + i] & 0xff);
-               }
-               printf(")");
-               cp += len + 4;
+               cp += sizeof(*dh6o) + optlen;
        }
        return;
 
@@ -226,128 +182,57 @@ trunc:
 }
 
 /*
- * Print dhcp6 requests
+ * Print dhcp6 packets
  */
 void
 dhcp6_print(register const u_char *cp, u_int length,
            u_int16_t sport, u_int16_t dport)
 {
-       union dhcp6 *dh6;
+       struct dhcp6 *dh6;
        u_char *ep;
        u_char *extp;
-       u_int16_t field16;
+       const char *name;
 
        printf("dhcp6");
 
        ep = (u_char *)snapend;
 
        dh6 = (union dhcp6 *)cp;
-       TCHECK(dh6->dh6_msgtype);
+       TCHECK(dh6->dh6_servaddr);
        switch (dh6->dh6_msgtype) {
-       case DH6_SOLICIT:
-               if (!(vflag && TTEST(dh6->dh6_sol.dh6sol_relayaddr))) {
-                       printf(" solicit");
-                       break;
-               }
-
-               printf(" solicit (");   /*)*/
-               if (dh6->dh6_sol.dh6sol_flags != 0) {
-                       u_int8_t f = dh6->dh6_sol.dh6sol_flags;
-                       printf("%s%s ",
-                          (f & DH6SOL_PREFIX) ? "P" : "",
-                          (f & DH6SOL_CLOSE) ? "C" : "");
-               }
-
-               memcpy(&field16, &dh6->dh6_sol.dh6sol_plen_id,
-                      sizeof(field16));
-               field16 = ntohs(field16);
-               if (field16 & ~DH6SOL_SOLICIT_PLEN_MASK)
-                       printf("plen=%d ", DH6SOL_SOLICIT_PLEN(field16));
-               printf("solicit-ID=%d", DH6SOL_SOLICIT_ID(field16));
-               
-               printf(" cliaddr=%s",
-                       ip6addr_string(&dh6->dh6_sol.dh6sol_cliaddr));
-               printf(" relayaddr=%s", 
-                       ip6addr_string(&dh6->dh6_sol.dh6sol_relayaddr));
-               /*(*/
-               printf(")");
-               break;
-       case DH6_ADVERT:
-               if (!(vflag && TTEST(dh6->dh6_adv.dh6adv_serveraddr))) {
-                       printf(" advert");
-                       break;
-               }
-               printf(" advert (");    /*)*/
-               memcpy(&field16, &dh6->dh6_adv.dh6adv_rsv_id, sizeof(field16));
-               printf("solicit-ID=%d",
-                      ntohs(field16) & DH6SOL_SOLICIT_ID_MASK); 
-               printf(" pref=%u", dh6->dh6_adv.dh6adv_pref);
-               printf(" cliaddr=%s",
-                       ip6addr_string(&dh6->dh6_adv.dh6adv_cliaddr));
-               printf(" relayaddr=%s", 
-                       ip6addr_string(&dh6->dh6_adv.dh6adv_relayaddr));
-               printf(" servaddr=%s", 
-                       ip6addr_string(&dh6->dh6_adv.dh6adv_serveraddr));
-               extp = (u_char *)((&dh6->dh6_adv) + 1);
-               dhcp6ext_print(extp, ep);
-               /*(*/
-               printf(")");
-               break;
-       case DH6_REQUEST:
-               if (!(vflag && TTEST(dh6->dh6_req.dh6req_relayaddr))) {
-                       printf(" request");
-                       break;
-               }
-               printf(" request (");   /*)*/
-               if (dh6->dh6_req.dh6req_flags != 0) {
-                       u_int8_t f = dh6->dh6_req.dh6req_flags;
-                       printf("%s%s ",
-                          (f & DH6REQ_CLOSE) ? "C" : "",
-                          (f & DH6REQ_REBOOT) ? "R" : "");
-               }
-               printf("xid=0x%04x", dh6->dh6_req.dh6req_xid);
-               printf(" cliaddr=%s",
-                      ip6addr_string(&dh6->dh6_req.dh6req_cliaddr));
-               printf(" relayaddr=%s", 
-                      ip6addr_string(&dh6->dh6_req.dh6req_relayaddr));
-               printf(" servaddr=%s",
-                      ip6addr_string(&dh6->dh6_req.dh6req_serveraddr));
-               dhcp6ext_print((char *)(&dh6->dh6_req + 1), ep);
-               /*(*/
-               printf(")");
-               break;
        case DH6_REPLY:
-               if (!(vflag && TTEST(dh6->dh6_rep.dh6rep_xid))) {
-                       printf(" reply");
-                       break;
-               }
-               printf(" reply (");     /*)*/
-               if ((dh6->dh6_rep.dh6rep_flagandstat & DH6REP_RELAYPRESENT) != 0)
-                       printf("R ");
-               printf("stat=0x%02x",
-                       dh6->dh6_rep.dh6rep_flagandstat & DH6REP_STATMASK);
-               printf(" xid=0x%04x", dh6->dh6_rep.dh6rep_xid);
-               printf(" cliaddr=%s",
-                      ip6addr_string(&dh6->dh6_rep.dh6rep_cliaddr));
-               extp = (u_char *)((&dh6->dh6_rep) + 1);
-               if ((dh6->dh6_rep.dh6rep_flagandstat & DH6REP_RELAYPRESENT) !=
-                   0) {
-                       printf(" relayaddr=%s", ip6addr_string(extp));
-                       extp += sizeof(struct in6_addr);
-               }
-               dhcp6ext_print(extp, ep);
-               /*(*/
-               printf(")");
+               name = "reply";
                break;
-       case DH6_RELEASE:
-               printf(" release");
+       case DH6_INFORM_REQ:
+               name= "inf-req";
                break;
-       case DH6_RECONFIG:
-               printf(" reconfig");
+       default:
+               name = NULL;
                break;
        }
+
+       if (!vflag) {
+               if (name)
+                       printf(" %s", name);
+               else
+                       printf(" msgtype-%u", dh6->dh6_msgtype);
+               return;
+       }
+
+       /* XXX relay agent messages have to be handled differently */
+
+       if (name)
+               printf(" %s (", name);  /*)*/
+       else
+               printf(" msgtype-%u (", dh6->dh6_msgtype);      /*)*/
+       printf("xid=%x", ntohl(dh6->dh6_xid) & DH6_XIDMASK);
+       printf(" server=%s", ip6addr_string(&dh6->dh6_servaddr));
+       extp = (u_char *)(dh6 + 1);
+       dhcp6opt_print(extp, ep);
+       /*(*/
+       printf(")");
        return;
 
 trunc:
-       printf("%s", tstr);
+       printf("[|dhcp6]");
 }