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/tcpdump pullup (approved by: releng-1-5)
details: https://anonhg.NetBSD.org/src/rev/bf883d7bd753
branches: netbsd-1-5
changeset: 489012:bf883d7bd753
user: itojun <itojun%NetBSD.org@localhost>
date: Wed Aug 09 22:44:19 2000 +0000
description:
pullup (approved by: releng-1-5)
> sync with protocol change between dhcp6 14 draft to 15 draft
> dhcp6.h 1.1 -> 1.2
> print-dhcp6.c 1.1 -> 1.2
>
> add safeputc() and safeputs()
> interface.h 1.13 -> 1.14
> util.c 1.6 -> 1.7
>
> icmp6 nodeinfo 06 draft (should meet the revision which netbsd support)
> print-icmp6.c 1.7 -> 1.9
>
> compute pseudo-header checksum for tcp/udp over IPv6
> print-tcp.c 1.16 -> 1.19
> print-udp.c 1.13 -> 1.15
>
> buffer overrun and screen crash prevention in telnet decode
> print-telnet.c 1.2 -> 1.3
diffstat:
usr.sbin/tcpdump/dhcp6.h | 36 ++-
usr.sbin/tcpdump/interface.h | 5 +-
usr.sbin/tcpdump/print-dhcp6.c | 161 ++++++++------
usr.sbin/tcpdump/print-icmp6.c | 433 ++++++++++++++++++++++++++++++---------
usr.sbin/tcpdump/print-tcp.c | 71 ++++++-
usr.sbin/tcpdump/print-telnet.c | 26 +-
usr.sbin/tcpdump/print-udp.c | 70 ++++++-
usr.sbin/tcpdump/util.c | 25 ++-
8 files changed, 608 insertions(+), 219 deletions(-)
diffs (truncated from 1330 to 300 lines):
diff -r 3e321aa35b21 -r bf883d7bd753 usr.sbin/tcpdump/dhcp6.h
--- a/usr.sbin/tcpdump/dhcp6.h Wed Aug 09 19:16:58 2000 +0000
+++ b/usr.sbin/tcpdump/dhcp6.h Wed Aug 09 22:44:19 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dhcp6.h,v 1.1 1999/12/10 05:45:07 itojun Exp $ */
+/* $NetBSD: dhcp6.h,v 1.1.6.1 2000/08/09 22:44:19 itojun Exp $ */
/*
* Copyright (C) 1998 and 1999 WIDE Project.
@@ -29,7 +29,7 @@
* SUCH DAMAGE.
*/
/*
- * draft-ietf-dhc-dhcpv6-14
+ * draft-ietf-dhc-dhcpv6-15
*/
#ifndef __DHCP6_H_DEFINED
@@ -81,20 +81,27 @@
u_int8_t dh6sol_msgtype; /* DH6_SOLICIT */
u_int8_t dh6sol_flags;
#define DH6SOL_CLOSE 0x80
- u_int8_t dh6sol_pad;
- u_int8_t dh6sol_prefixsiz; /* prefix-size */
+#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 */
};
-/* NOTE: dhcpv6-12 and dhcpv6-13+n are not compatible at all */
struct dhcp6_advert {
u_int8_t dh6adv_msgtype; /* DH6_ADVERT */
- u_int8_t dh6adv_flags;
-#define DH6ADV_SERVPRESENT 0x80
- u_int8_t dh6adv_pad;
+ 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 lladdr */
+ 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 */
@@ -104,25 +111,26 @@
u_int8_t dh6req_msgtype; /* DH6_REQUEST */
u_int8_t dh6req_flags;
#define DH6REQ_CLOSE 0x80
-#define DH6REQ_SERVPRESENT 0x40
-#define DH6REQ_REBOOT 0x20
+#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; optional: server's 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_CLIPRESENT 0x80
+#define DH6REP_RELAYPRESENT 0x80
#define DH6REP_STATMASK 0x7f
u_int16_t dh6rep_xid; /* transaction-ID */
- /* struct in6_addr dh6rep_cliaddr; optional: client's lladdr */
+ 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;
diff -r 3e321aa35b21 -r bf883d7bd753 usr.sbin/tcpdump/interface.h
--- a/usr.sbin/tcpdump/interface.h Wed Aug 09 19:16:58 2000 +0000
+++ b/usr.sbin/tcpdump/interface.h Wed Aug 09 22:44:19 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: interface.h,v 1.12.4.1 2000/07/26 23:14:17 mycroft Exp $ */
+/* $NetBSD: interface.h,v 1.12.4.2 2000/08/09 22:44:19 itojun Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
@@ -185,6 +185,9 @@
extern char *read_infile(char *);
extern char *copy_argv(char **);
+extern void safeputchar(int);
+extern void safeputs(const char *);
+
extern char *isonsap_string(const u_char *);
extern char *llcsap_string(u_char);
extern char *protoid_string(const u_char *);
diff -r 3e321aa35b21 -r bf883d7bd753 usr.sbin/tcpdump/print-dhcp6.c
--- a/usr.sbin/tcpdump/print-dhcp6.c Wed Aug 09 19:16:58 2000 +0000
+++ b/usr.sbin/tcpdump/print-dhcp6.c Wed Aug 09 22:44:19 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: print-dhcp6.c,v 1.1 1999/12/10 05:45:08 itojun Exp $ */
+/* $NetBSD: print-dhcp6.c,v 1.1.6.1 2000/08/09 22:44:19 itojun Exp $ */
/*
* Copyright (C) 1998 and 1999 WIDE Project.
@@ -35,7 +35,7 @@
static const char rcsid[] =
"@(#) KAME Header: /cvsroot/kame/kame/kame/kame/tcpdump/print-dhcp6.c,v 1.5 1999/11/02 14:55:01 itojun Exp";
#else
-__RCSID("$NetBSD: print-dhcp6.c,v 1.1 1999/12/10 05:45:08 itojun Exp $");
+__RCSID("$NetBSD: print-dhcp6.c,v 1.1.6.1 2000/08/09 22:44:19 itojun Exp $");
#endif
#endif
@@ -77,36 +77,35 @@
{ 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, },
+ { 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, },
- /* 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, },
+ { 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, },
@@ -162,13 +161,18 @@
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);
@@ -194,11 +198,11 @@
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) {
@@ -235,11 +239,12 @@
*/
void
dhcp6_print(register const u_char *cp, u_int length,
- u_short sport, u_short dport)
+ u_int16_t sport, u_int16_t dport)
{
union dhcp6 *dh6;
u_char *ep;
u_char *extp;
+ u_int16_t field16;
printf("dhcp6");
@@ -249,31 +254,43 @@
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 != 0)
- printf(" ");
- 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(");
- if ((dh6->dh6_adv.dh6adv_flags & DH6ADV_SERVPRESENT) != 0)
- printf("S");
- if (dh6->dh6_adv.dh6adv_flags != 0)
- printf(" ");
- printf("pref=%u", dh6->dh6_adv.dh6adv_pref);
+ 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",
@@ -282,6 +299,7 @@
ip6addr_string(&dh6->dh6_adv.dh6adv_serveraddr));
extp = (u_char *)((&dh6->dh6_adv) + 1);
dhcp6ext_print(extp, ep);
+ /*(*/
printf(")");
break;
case DH6_REQUEST:
@@ -289,26 +307,22 @@
Home |
Main Index |
Thread Index |
Old Index