Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/tcpdump minimize diffs to tcpdump.org tree, even if...
details: https://anonhg.NetBSD.org/src/rev/e36db9c5ddf0
branches: trunk
changeset: 502998:e36db9c5ddf0
user: itojun <itojun%NetBSD.org@localhost>
date: Sun Jan 28 10:05:05 2001 +0000
description:
minimize diffs to tcpdump.org tree, even if cosmetic.
changes include:
- do not chase header if ip/ip6 datagram is framgented, and it is not the
first fragment
- u_short -> u_int16_t
- buffer boundary checks, including sprintf -> snprintf
- cleanup truncated packet cases
- pull tcpdump.org enhancements/corrections for RIP, IPv6 options, ICMPv6,
OSPFv3, IPv4 options, BGP
there are a lot of local/conflicting changes. we'd gradually decrease
# of diffs by synchronizing both ends, and then move to src/dist/tcpdump
and reachover makefile.
diffstat:
usr.sbin/tcpdump/interface.h | 7 +-
usr.sbin/tcpdump/ntp.h | 6 +-
usr.sbin/tcpdump/ospf.h | 54 +++---
usr.sbin/tcpdump/ospf6.h | 27 +-
usr.sbin/tcpdump/print-ah.c | 11 +-
usr.sbin/tcpdump/print-ascii.c | 10 +-
usr.sbin/tcpdump/print-bgp.c | 202 ++++++++++++++++++++----
usr.sbin/tcpdump/print-decnet.c | 16 +-
usr.sbin/tcpdump/print-esp.c | 11 +-
usr.sbin/tcpdump/print-icmp.c | 239 ++++++++++++++++++++++------
usr.sbin/tcpdump/print-icmp6.c | 318 ++++++++++++++++++++++++++++++++------
usr.sbin/tcpdump/print-ip.c | 120 ++++++++++++--
usr.sbin/tcpdump/print-ip6.c | 36 ++--
usr.sbin/tcpdump/print-ip6opts.c | 194 ++++++++++++++++++++++-
usr.sbin/tcpdump/print-ipcomp.c | 26 +--
usr.sbin/tcpdump/print-isakmp.c | 12 +-
usr.sbin/tcpdump/print-mobile.c | 6 +-
usr.sbin/tcpdump/print-nfs.c | 68 +++++++-
usr.sbin/tcpdump/print-null.c | 21 +-
usr.sbin/tcpdump/print-ospf6.c | 93 ++++++----
usr.sbin/tcpdump/print-rip.c | 209 +++++++++++++++++--------
usr.sbin/tcpdump/print-rt6.c | 37 ++--
usr.sbin/tcpdump/print-tcp.c | 31 +-
usr.sbin/tcpdump/print-udp.c | 86 ++++++----
usr.sbin/tcpdump/route6d.h | 18 +-
usr.sbin/tcpdump/tcpdump.c | 22 +-
usr.sbin/tcpdump/util.c | 31 +++-
27 files changed, 1411 insertions(+), 500 deletions(-)
diffs (truncated from 3585 to 300 lines):
diff -r fa9c6911b35a -r e36db9c5ddf0 usr.sbin/tcpdump/interface.h
--- a/usr.sbin/tcpdump/interface.h Sun Jan 28 07:56:56 2001 +0000
+++ b/usr.sbin/tcpdump/interface.h Sun Jan 28 10:05:05 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: interface.h,v 1.16 2001/01/19 09:10:13 kleink Exp $ */
+/* $NetBSD: interface.h,v 1.17 2001/01/28 10:05:05 itojun Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
@@ -161,6 +161,7 @@
#endif
extern void ts_print(const struct timeval *);
+extern void relts_print(int);
extern int fn_print(const u_char *, const u_char *);
extern int fn_printn(const u_char *, u_int, const u_char *);
@@ -250,11 +251,11 @@
const u_char *);
extern void snmp_print(const u_char *, u_int);
extern void sunrpcrequest_print(const u_char *, u_int, const u_char *);
-extern void tcp_print(const u_char *, u_int, const u_char *);
+extern void tcp_print(const u_char *, u_int, const u_char *, int);
extern void tftp_print(const u_char *, u_int);
extern void token_if_print(u_char *, const struct pcap_pkthdr *,
const u_char *);
-extern void udp_print(const u_char *, u_int, const u_char *);
+extern void udp_print(const u_char *, u_int, const u_char *, int);
extern void vrrp_print(const u_char *, u_int, const u_char *);
extern void wb_print(const void *, u_int);
extern void hdlc_if_print(u_char *, const struct pcap_pkthdr *,
diff -r fa9c6911b35a -r e36db9c5ddf0 usr.sbin/tcpdump/ntp.h
--- a/usr.sbin/tcpdump/ntp.h Sun Jan 28 07:56:56 2001 +0000
+++ b/usr.sbin/tcpdump/ntp.h Sun Jan 28 10:05:05 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntp.h,v 1.3 1997/10/03 19:54:47 christos Exp $ */
+/* $NetBSD: ntp.h,v 1.4 2001/01/28 10:05:05 itojun Exp $ */
/* Header: ntp.h,v 1.3 95/05/04 17:52:49 mccanne Exp */
@@ -35,8 +35,8 @@
};
struct s_fixedpt {
- u_short int_part;
- u_short fraction;
+ u_int16_t int_part;
+ u_int16_t fraction;
};
/* ================= Table 3.3. Packet Variables ================= */
diff -r fa9c6911b35a -r e36db9c5ddf0 usr.sbin/tcpdump/ospf.h
--- a/usr.sbin/tcpdump/ospf.h Sun Jan 28 07:56:56 2001 +0000
+++ b/usr.sbin/tcpdump/ospf.h Sun Jan 28 10:05:05 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ospf.h,v 1.3 1997/10/03 19:54:50 christos Exp $ */
+/* $NetBSD: ospf.h,v 1.4 2001/01/28 10:05:05 itojun Exp $ */
/*
* Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
@@ -93,14 +93,14 @@
/* link state advertisement header */
struct lsa_hdr {
- u_short ls_age;
- u_char ls_options;
- u_char ls_type;
+ u_int16_t ls_age;
+ u_int8_t ls_options;
+ u_int8_t ls_type;
struct in_addr ls_stateid;
struct in_addr ls_router;
u_int32_t ls_seq;
- u_short ls_chksum;
- u_short ls_length;
+ u_int16_t ls_chksum;
+ u_int16_t ls_length;
} ;
/* link state advertisement */
@@ -111,15 +111,15 @@
union {
/* Router links advertisements */
struct {
- u_char rla_flags;
- u_char rla_zero[1];
- u_short rla_count;
+ u_int8_t rla_flags;
+ u_int8_t rla_zero[1];
+ u_int16_t rla_count;
struct rlalink {
struct in_addr link_id;
struct in_addr link_data;
- u_char link_type;
- u_char link_toscount;
- u_short link_tos0metric;
+ u_int8_t link_type;
+ u_int8_t link_toscount;
+ u_int16_t link_tos0metric;
} rla_link[1]; /* may repeat */
} un_rla;
@@ -158,9 +158,9 @@
* TOS metric struct (will be 0 or more in router links update)
*/
struct tos_metric {
- u_char tos_type;
- u_char tos_zero;
- u_short tos_metric;
+ u_int8_t tos_type;
+ u_int8_t tos_zero;
+ u_int16_t tos_metric;
} ;
#define OSPF_AUTH_SIZE 8
@@ -169,22 +169,22 @@
* the main header
*/
struct ospfhdr {
- u_char ospf_version;
- u_char ospf_type;
- u_short ospf_len;
+ u_int8_t ospf_version;
+ u_int8_t ospf_type;
+ u_int16_t ospf_len;
struct in_addr ospf_routerid;
struct in_addr ospf_areaid;
- u_short ospf_chksum;
- u_short ospf_authtype;
- u_char ospf_authdata[OSPF_AUTH_SIZE];
+ u_int16_t ospf_chksum;
+ u_int16_t ospf_authtype;
+ u_int8_t ospf_authdata[OSPF_AUTH_SIZE];
union {
/* Hello packet */
struct {
struct in_addr hello_mask;
- u_short hello_helloint;
- u_char hello_options;
- u_char hello_priority;
+ u_int16_t hello_helloint;
+ u_int8_t hello_options;
+ u_int8_t hello_priority;
u_int32_t hello_deadint;
struct in_addr hello_dr;
struct in_addr hello_bdr;
@@ -193,9 +193,9 @@
/* Database Description packet */
struct {
- u_char db_zero[2];
- u_char db_options;
- u_char db_flags;
+ u_int8_t db_zero[2];
+ u_int8_t db_options;
+ u_int8_t db_flags;
u_int32_t db_seq;
struct lsa_hdr db_lshdr[1]; /* may repeat */
} un_db;
diff -r fa9c6911b35a -r e36db9c5ddf0 usr.sbin/tcpdump/ospf6.h
--- a/usr.sbin/tcpdump/ospf6.h Sun Jan 28 07:56:56 2001 +0000
+++ b/usr.sbin/tcpdump/ospf6.h Sun Jan 28 10:05:05 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ospf6.h,v 1.2 1999/07/04 02:57:51 itojun Exp $ */
+/* $NetBSD: ospf6.h,v 1.3 2001/01/28 10:05:06 itojun Exp $ */
/*
* Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
@@ -85,10 +85,10 @@
#define SLA_MASK_METRIC 0x00ffffff
#define SLA_SHIFT_TOS 24
-/* asla_tosmetric breakdown */
-#define ASLA_FLAG_EXTERNAL 0x80000000
-#define ASLA_MASK_TOS 0x7f000000
-#define ASLA_SHIFT_TOS 24
+/* asla_metric */
+#define ASLA_FLAG_EXTERNAL 0x04000000
+#define ASLA_FLAG_FWDADDR 0x02000000
+#define ASLA_FLAG_ROUTETAG 0x01000000
#define ASLA_MASK_METRIC 0x00ffffff
/* multicast vertex type */
@@ -151,6 +151,13 @@
struct lsa_prefix inter_ap_prefix[1];
} un_inter_ap;
+ /* AS external links advertisements */
+ struct {
+ u_int32_t asla_metric;
+ struct lsa_prefix asla_prefix[1];
+ /* some optional fields follow */
+ } un_asla;
+
#if 0
/* Summary links advertisements */
struct {
@@ -158,16 +165,6 @@
u_int32_t sla_tosmetric[1]; /* may repeat */
} un_sla;
- /* AS external links advertisements */
- struct {
- struct in_addr asla_mask;
- struct aslametric {
- u_int32_t asla_tosmetric;
- struct in_addr asla_forward;
- struct in_addr asla_tag;
- } asla_metric[1]; /* may repeat */
- } un_asla;
-
/* Multicast group membership */
struct mcla {
u_int32_t mcla_vtype;
diff -r fa9c6911b35a -r e36db9c5ddf0 usr.sbin/tcpdump/print-ah.c
--- a/usr.sbin/tcpdump/print-ah.c Sun Jan 28 07:56:56 2001 +0000
+++ b/usr.sbin/tcpdump/print-ah.c Sun Jan 28 10:05:05 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: print-ah.c,v 1.3 1999/09/04 03:36:41 itojun Exp $ */
+/* $NetBSD: print-ah.c,v 1.4 2001/01/28 10:05:06 itojun Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
@@ -27,7 +27,7 @@
"@(#) /master/usr.sbin/tcpdump/tcpdump/print-icmp.c,v 2.1 1995/02/03 18:14:42 polk Exp (LBL)";
#else
#include <sys/cdefs.h>
-__RCSID("$NetBSD: print-ah.c,v 1.3 1999/09/04 03:36:41 itojun Exp $");
+__RCSID("$NetBSD: print-ah.c,v 1.4 2001/01/28 10:05:06 itojun Exp $");
#endif
#endif
@@ -65,7 +65,7 @@
u_int32_t spi;
ah = (struct ah *)bp;
- ep = snapend; /* 'ep' points to the end of avaible data. */
+ ep = snapend; /* 'ep' points to the end of available data. */
if ((u_char *)(ah + 1) >= ep - sizeof(struct ah))
goto trunc;
@@ -73,11 +73,10 @@
sumlen = ah->ah_len << 2;
spi = (u_int32_t)ntohl(ah->ah_spi);
- printf("AH(spi=%u", spi);
+ printf("AH(spi=0x%08x", spi);
if (vflag)
printf(",sumlen=%d", sumlen);
- if (Rflag)
- printf(",seq=0x%x", (u_int32_t)ntohl(*(u_int32_t *)(ah + 1)));
+ printf(",seq=0x%x", (u_int32_t)ntohl(*(u_int32_t *)(ah + 1)));
if (bp + sizeof(struct ah) + sumlen > ep)
fputs("[truncated]", stdout);
fputs("): ", stdout);
diff -r fa9c6911b35a -r e36db9c5ddf0 usr.sbin/tcpdump/print-ascii.c
--- a/usr.sbin/tcpdump/print-ascii.c Sun Jan 28 07:56:56 2001 +0000
+++ b/usr.sbin/tcpdump/print-ascii.c Sun Jan 28 10:05:05 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: print-ascii.c,v 1.1 1999/09/30 14:49:12 sjg Exp $ */
+/* $NetBSD: print-ascii.c,v 1.2 2001/01/28 10:05:06 itojun Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: print-ascii.c,v 1.1 1999/09/30 14:49:12 sjg Exp $");
+__RCSID("$NetBSD: print-ascii.c,v 1.2 2001/01/28 10:05:06 itojun Exp $");
#endif
#include <stdio.h>
#include <sys/types.h>
@@ -68,7 +68,8 @@
while (--nshorts >= 0) {
s1 = *cp++;
s2 = *cp++;
- (void)sprintf(hsp, " %02x%02x", s1, s2);
+ (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
+ " %02x%02x", s1, s2);
hsp += HEXDUMP_HEXSTUFF_PER_SHORT;
*(asp++) = (isgraph(s1) ? s1 : '.');
*(asp++) = (isgraph(s2) ? s2 : '.');
@@ -83,7 +84,8 @@
}
if (length & 1) {
s1 = *cp++;
- (void)sprintf(hsp, " %02x", s1);
+ (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
+ " %02x", s1);
hsp += 3;
*(asp++) = (isgraph(s1) ? s1 : '.');
++i;
diff -r fa9c6911b35a -r e36db9c5ddf0 usr.sbin/tcpdump/print-bgp.c
--- a/usr.sbin/tcpdump/print-bgp.c Sun Jan 28 07:56:56 2001 +0000
+++ b/usr.sbin/tcpdump/print-bgp.c Sun Jan 28 10:05:05 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: print-bgp.c,v 1.2 1999/12/11 18:20:27 thorpej Exp $ */
+/* $NetBSD: print-bgp.c,v 1.3 2001/01/28 10:05:06 itojun Exp $ */
Home |
Main Index |
Thread Index |
Old Index