#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.5 2000-05-13 18:28:47 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.13 2001-01-28 09:49:49 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include <sys/time.h>
#include <sys/socket.h>
-#if __STDC__
struct mbuf;
struct rtentry;
-#endif
-#include <net/if.h>
#include <netinet/in.h>
#include <ctype.h>
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
#include <stdio.h>
#include <string.h>
#include <arpa/inet.h>
#include "dhcp6opt.h"
#if 0
-static void dhcp6opttab_init __P((void));
-static struct dhcp6_opt *dhcp6opttab_byname __P((char *));
+static void dhcp6opttab_init(void);
+static struct dhcp6_opt *dhcp6opttab_byname(char *);
#endif
-static struct dhcp6_opt *dhcp6opttab_bycode __P((u_int));
+static struct dhcp6_opt *dhcp6opttab_bycode(u_int);
static char tstr[] = " [|dhcp6]";
{ 1, OL6_N, "IP Address", OT6_NONE, },
/* General Extension */
- { 2, 4, "Time Offset", OT6_NUM, },
- { 3, OL6_N, "IEEE 1003.1 POSIX Timezone", OT6_STR, },
- { 6, OL6_16N, "Domain Name Server", OT6_V6, },
- { 10, OL6_N, "Domain Name", OT6_STR, },
-
- /* Application and Service Parameters */
- { 16, OL6_N, "Directory Agent", OT6_NONE, },
- { 17, OL6_N, "Service Scope" , OT6_NONE, },
- { 18, OL6_16N, "Network Time Protocol Servers", OT6_V6, },
- { 19, OL6_N, "NIS Domain", OT6_STR, },
- { 20, OL6_16N, "NIS Servers", OT6_V6, },
- { 21, OL6_N, "NIS+ Domain", OT6_STR, },
- { 22, OL6_16N, "NIS+ Servers", OT6_V6, },
+ { 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 */
- { 32, 4, "TCP Keepalive Interval", OT6_NUM, },
+ { 8203, 4, "TCP Keepalive Interval", OT6_NUM, },
/* DHCPv6 Extensions */
- { 40, 4, "Maximum DHCPv6 Message Size", OT6_NUM, },
- { 41, OL6_N, "DHCP Retransmission and Configuration Parameter",
+ { 8204, 4, "Maximum DHCPv6 Message Size", OT6_NUM, },
+ { 8205, OL6_N, "DHCP Retransmission and Configuration Parameter",
OT6_NONE, },
- { 48, OL6_N, "Platform Specific Information", OT6_NONE, },
- { 49, OL6_N, "Platform Class Identifier", OT6_STR, },
- { 64, OL6_N, "Class Identifier", OT6_STR, },
- { 66, 16, "Reconfigure Multicast Address", OT6_V6, },
- { 67, 16, "Renumber DHCPv6 Server Address",
+ { 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, },
- { 68, OL6_N, "DHCP Relay ICMP Error Message", OT6_NONE, },
- { 84, OL6_N, "Client-Server Authentication", OT6_NONE, },
- { 85, 4, "Client Key Selection", OT6_NUM, },
+ { 8213, OL6_N, "Client-Server Authentication", OT6_NONE, },
+ { 8214, 4, "Client Key Selection", OT6_NUM, },
/* End Extension */
{ 65536, OL6_Z, "End", OT6_NONE, },
if (cp == ep)
return;
- printf(" ");
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);
break;
}
if (cp + 4 + len > ep) {
- printf("[|%s]", p->name);
+ printf(" [|%s]", p->name);
return;
}
- printf("(%s, ", p->name);
+ printf(" (%s, ", p->name);
switch (p->type) {
case OT6_V6:
for (i = 0; i < len; i += 16) {
TCHECK(dh6->dh6_msgtype);
switch (dh6->dh6_msgtype) {
case DH6_SOLICIT:
- if (vflag && TTEST(dh6->dh6_sol.dh6sol_relayaddr)) {
- printf(" solicit(");
- if ((dh6->dh6_sol.dh6sol_flags & DH6SOL_CLOSE) != 0)
- printf("C");
- if ((dh6->dh6_sol.dh6sol_flags & DH6SOL_PREFIX) != 0)
- printf("P");
- if (dh6->dh6_sol.dh6sol_flags != 0)
- printf(" ");
-
- memcpy(&field16, &dh6->dh6_sol.dh6sol_plen_id,
- sizeof(field16));
- field16 = ntohs(field16);
- if (field16 & ~DH6SOL_SOLICIT_ID_MASK)
- printf("plen=%d ",
- (0xff & (field16 &
- ~DH6SOL_SOLICIT_ID_MASK)>>9));
- printf("solicit-ID=%d",
- field16 & DH6SOL_SOLICIT_ID_MASK);
-
- printf(" cliaddr=%s",
- ip6addr_string(&dh6->dh6_sol.dh6sol_cliaddr));
- printf(" relayaddr=%s",
- ip6addr_string(&dh6->dh6_sol.dh6sol_relayaddr));
- printf(")");
- } else
+ 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(");
+ printf(" advert ("); /*)*/
memcpy(&field16, &dh6->dh6_adv.dh6adv_rsv_id, sizeof(field16));
printf("solicit-ID=%d",
ntohs(field16) & DH6SOL_SOLICIT_ID_MASK);
ip6addr_string(&dh6->dh6_adv.dh6adv_serveraddr));
extp = (u_char *)((&dh6->dh6_adv) + 1);
dhcp6ext_print(extp, ep);
+ /*(*/
printf(")");
break;
case DH6_REQUEST:
printf(" request");
break;
}
- printf(" request(");
- if ((dh6->dh6_req.dh6req_flags & DH6REQ_CLOSE) != 0)
- printf("C");
- if ((dh6->dh6_req.dh6req_flags & DH6REQ_REBOOT) != 0)
- printf("R");
- if (dh6->dh6_req.dh6req_flags != 0)
- printf(" ");
+ 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(" servaddr=%s",
ip6addr_string(&dh6->dh6_req.dh6req_serveraddr));
dhcp6ext_print((char *)(&dh6->dh6_req + 1), ep);
+ /*(*/
printf(")");
break;
case DH6_REPLY:
printf(" reply");
break;
}
- printf(" reply(");
+ printf(" reply ("); /*)*/
if ((dh6->dh6_rep.dh6rep_flagandstat & DH6REP_RELAYPRESENT) != 0)
- printf("R");
- if (((dh6->dh6_rep.dh6rep_flagandstat & ~DH6REP_STATMASK) & 0xff) != 0)
- printf(" ");
+ printf("R ");
printf("stat=0x%02x",
dh6->dh6_rep.dh6rep_flagandstat & DH6REP_STATMASK);
printf(" xid=0x%04x", dh6->dh6_rep.dh6rep_xid);
extp += sizeof(struct in6_addr);
}
dhcp6ext_print(extp, ep);
+ /*(*/
printf(")");
break;
case DH6_RELEASE: