resolve merge conflicts

Approved by:	re (scottl)
This commit is contained in:
Sam Leffler 2005-07-11 04:14:02 +00:00
parent 091040346a
commit 29292c17af
22 changed files with 1013 additions and 492 deletions

View File

@ -25,7 +25,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.108 2005/03/27 22:38:09 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.108.2.5 2005/04/25 08:43:05 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -44,12 +44,18 @@ struct rtentry; /* declarations in <net/if.h> */
#ifdef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST
#include <netinet/ether.h>
#endif /* NETINET_ETHER_H_DECLARES_ETHER_NTOHOST */
#endif /* USE_ETHER_NTOHOST */
#if !defined(HAVE_DECL_ETHER_NTOHOST) || !HAVE_DECL_ETHER_NTOHOST
#ifndef HAVE_STRUCT_ETHER_ADDR
struct ether_addr {
unsigned char ether_addr_octet[6];
};
#endif
extern int ether_ntohost(char *, const struct ether_addr *);
#endif
#endif /* USE_ETHER_NTOHOST */
#include <pcap.h>
#include <pcap-namedb.h>
#include <signal.h>
@ -61,6 +67,8 @@ extern int ether_ntohost(char *, const struct ether_addr *);
#include "addrtoname.h"
#include "llc.h"
#include "setsignal.h"
#include "extract.h"
#include "oui.h"
/*
* hash tables for whatever-to-name translations
@ -69,6 +77,7 @@ extern int ether_ntohost(char *, const struct ether_addr *);
*/
#define HASHNAMESIZE 4096
#define BUFSIZE 128
struct hnamemem {
u_int32_t addr;
@ -169,7 +178,7 @@ intoa(u_int32_t addr)
static char buf[sizeof(".xxx.xxx.xxx.xxx")];
NTOHL(addr);
cp = &buf[sizeof buf];
cp = buf + sizeof(buf);
*--cp = '\0';
n = 4;
@ -454,17 +463,17 @@ lookup_protoid(const u_char *pi)
const char *
etheraddr_string(register const u_char *ep)
{
register u_int i;
register u_int i, oui;
register char *cp;
register struct enamemem *tp;
char buf[sizeof("00:00:00:00:00:00")];
char buf[BUFSIZE];
tp = lookup_emem(ep);
if (tp->e_name)
return (tp->e_name);
#ifdef USE_ETHER_NTOHOST
if (!nflag) {
char buf2[128];
char buf2[BUFSIZE];
/*
* We don't cast it to "const struct ether_addr *"
@ -479,14 +488,20 @@ etheraddr_string(register const u_char *ep)
}
#endif
cp = buf;
oui=EXTRACT_24BITS(ep);
*cp++ = hex[*ep >> 4 ];
*cp++ = hex[*ep++ & 0xf];
for (i = 5; (int)--i >= 0;) {
*cp++ = ':';
*cp++ = hex[*ep >> 4 ];
*cp++ = hex[*ep++ & 0xf];
}
*cp = '\0';
for (i = 5; (int)--i >= 0;) {
*cp++ = ':';
*cp++ = hex[*ep >> 4 ];
*cp++ = hex[*ep++ & 0xf];
}
if (!nflag) {
snprintf(cp,BUFSIZE," (oui %s)",
tok2str(oui_values,"Unknown",oui));
} else
*cp = '\0';
tp->e_name = strdup(buf);
return (tp->e_name);
}
@ -600,7 +615,7 @@ isonsap_string(const u_char *nsap, register u_int nsap_length)
register struct enamemem *tp;
if (nsap_length < 1 || nsap_length > ISONSAP_MAX_LENGTH)
error("isonsap_string: illegal length");
return ("isonsap_string: illegal length");
tp = lookup_nsap(nsap);
if (tp->e_name)

View File

@ -38,6 +38,10 @@
#include <stdarg.h>
#if HAVE_STDINT_H
#include <stdint.h>
#endif
#if !defined(HAVE_SNPRINTF)
int snprintf(char *, size_t, const char *, ...)
__attribute__((format(printf, 3, 4)));
@ -135,6 +139,7 @@ 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 *);
extern int fn_printzp(const u_char *, u_int, const u_char *);
extern int mask2plen(u_int32_t);
extern const char *tok2strary_internal(const char **, int, const char *, int);
#define tok2strary(a,f,i) tok2strary_internal(a, sizeof(a)/sizeof(a[0]),f,i)
@ -171,15 +176,14 @@ extern void hex_print(const char *, const u_char *, u_int);
extern int ether_encap_print(u_short, const u_char *, u_int, u_int, u_short *);
extern int llc_print(const u_char *, u_int, u_int, const u_char *,
const u_char *, u_short *);
extern int snap_print(const u_char *, u_int, u_int, u_short *, u_int32_t,
u_short, u_int);
extern int snap_print(const u_char *, u_int, u_int, u_short *, u_int);
extern void aarp_print(const u_char *, u_int);
extern void aodv_print(const u_char *, u_int, int);
extern void atalk_print(const u_char *, u_int);
extern void atm_print(u_int, u_int, u_int, const u_char *, u_int, u_int);
extern u_int atm_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int sunatm_if_print(const struct pcap_pkthdr *, const u_char *);
extern int oam_print(const u_char *, u_int);
extern int oam_print(const u_char *, u_int, u_int);
extern void bootp_print(const u_char *, u_int);
extern void bgp_print(const u_char *, int);
extern void beep_print(const u_char *, u_int);
@ -199,6 +203,7 @@ extern u_int token_if_print(const struct pcap_pkthdr *, const u_char *);
extern void fddi_print(const u_char *, u_int, u_int);
extern u_int fddi_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int fr_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int fr_print(register const u_char *, u_int);
extern u_int ieee802_11_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int ieee802_11_radio_if_print(const struct pcap_pkthdr *,
const u_char *);
@ -249,8 +254,15 @@ extern u_int sl_bsdos_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int chdlc_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int juniper_atm1_print(const struct pcap_pkthdr *, const u_char *);
extern u_int juniper_atm2_print(const struct pcap_pkthdr *, const u_char *);
extern u_int juniper_mfr_print(const struct pcap_pkthdr *, register const u_char *);
extern u_int juniper_mlfr_print(const struct pcap_pkthdr *, const u_char *);
extern u_int juniper_mlppp_print(const struct pcap_pkthdr *, const u_char *);
extern u_int juniper_pppoe_print(const struct pcap_pkthdr *, const u_char *);
extern u_int juniper_pppoe_atm_print(const struct pcap_pkthdr *, const u_char *);
extern u_int juniper_ggsn_print(const struct pcap_pkthdr *, const u_char *);
extern u_int juniper_es_print(const struct pcap_pkthdr *, const u_char *);
extern u_int juniper_monitor_print(const struct pcap_pkthdr *, const u_char *);
extern u_int juniper_services_print(const struct pcap_pkthdr *, const u_char *);
extern u_int sll_if_print(const struct pcap_pkthdr *, const u_char *);
extern void snmp_print(const u_char *, u_int);
extern void sunrpcrequest_print(const u_char *, u_int, const u_char *);
@ -273,6 +285,7 @@ extern const char *nt_errstr(u_int32_t);
extern void print_data(const unsigned char *, int);
extern void l2tp_print(const u_char *, u_int);
extern void vrrp_print(const u_char *, u_int, int);
extern void pgm_print(const u_char *, u_int, const u_char *);
extern void cdp_print(const u_char *, u_int, u_int);
extern void stp_print(const u_char *, u_int);
extern void radius_print(const u_char *, u_int);
@ -314,7 +327,7 @@ extern void bpf_dump(struct bpf_program *, int);
/* forward compatibility */
netdissect_options *gndo;
extern netdissect_options *gndo;
#define eflag gndo->ndo_eflag
#define fflag gndo->ndo_fflag

View File

@ -22,7 +22,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.38 2005/01/19 16:46:27 hannes Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.38.2.2 2005/06/20 07:45:06 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -258,7 +258,7 @@ atm_print(u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
case OAMF4SC: /* fall through */
case OAMF4EC:
oam_print(p, length);
oam_print(p, length, ATM_OAM_HEC);
return;
case METAC:
@ -289,13 +289,13 @@ atm_print(u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
}
int
oam_print (const u_char *p, u_int length) {
oam_print (const u_char *p, u_int length, u_int hec) {
u_int16_t cell_header, cell_type, func_type,vpi,vci,payload,clp;
cell_header = EXTRACT_32BITS(p);
cell_type = ((*(p+4))>>4) & 0x0f;
func_type = *(p) & 0x0f;
cell_type = ((*(p+4+hec))>>4) & 0x0f;
func_type = *(p+4+hec) & 0x0f;
vpi = (cell_header>>20)&0xff;
vci = (cell_header>>4)&0xffff;

View File

@ -24,7 +24,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.78 2004/03/02 07:38:10 hannes Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.78.2.2 2005/05/06 04:19:39 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -446,7 +446,10 @@ rfc1048_print(register const u_char *bp)
case 'a':
/* ascii strings */
putchar('"');
(void)fn_printn(bp, size, NULL);
if (fn_printn(bp, size, snapend)) {
putchar('"');
goto trunc;
}
putchar('"');
bp += size;
size = 0;
@ -559,16 +562,20 @@ rfc1048_print(register const u_char *bp)
case TAG_CLIENT_FQDN:
/* option 81 should be at least 4 bytes long */
if (len < 4)
if (len < 4) {
printf("ERROR: options 81 len %u < 4 bytes", len);
break;
}
if (*bp++)
printf("[svrreg]");
if (*bp)
printf("%u/%u/", *bp, *(bp+1));
bp += 2;
putchar('"');
(void)fn_printn(bp, size - 3, NULL);
if (fn_printn(bp, size - 3, snapend)) {
putchar('"');
goto trunc;
}
putchar('"');
bp += size - 3;
size = 0;
@ -579,7 +586,10 @@ rfc1048_print(register const u_char *bp)
size--;
if (type == 0) {
putchar('"');
(void)fn_printn(bp, size, NULL);
if (fn_printn(bp, size, snapend)) {
putchar('"');
goto trunc;
}
putchar('"');
bp += size;
size = 0;

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.89 2004/03/23 19:03:03 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.89.2.1 2005/04/20 20:59:00 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -133,9 +133,10 @@ labellen(const u_char *cp)
i = *cp;
if ((i & INDIR_MASK) == EDNS0_MASK) {
int bitlen, elt;
if ((elt = (i & ~INDIR_MASK)) != EDNS0_ELT_BITLABEL)
if ((elt = (i & ~INDIR_MASK)) != EDNS0_ELT_BITLABEL) {
printf("<ELT %d>", elt);
return(-1);
}
if (!TTEST2(*(cp + 1), 1))
return(-1);
if ((bitlen = *(cp + 1)) == 0)

View File

@ -22,7 +22,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.95 2005/04/06 21:32:39 mcr Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.95.2.2 2005/07/01 16:16:30 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -39,24 +39,8 @@ static const char rcsid[] _U_ =
#include "ethertype.h"
#include "ether.h"
#include "llc.h"
const struct tok ethertype_values[] = {
/* not really ethertypes but PIDs that are used
in the SNAP printer - its more convenient
to put them into a single tokentable */
{ PID_RFC2684_ETH_FCS, "Ethernet + FCS" },
{ PID_RFC2684_ETH_NOFCS, "Ethernet no FCS" },
{ PID_RFC2684_802_4_FCS, "802.4 + FCS" },
{ PID_RFC2684_802_4_NOFCS, "w/o FCS" },
{ PID_RFC2684_802_5_FCS, "Tokenring + FCS" },
{ PID_RFC2684_802_5_NOFCS, "Tokenring no FCS" },
{ PID_RFC2684_FDDI_FCS, "FDDI + FCS" },
{ PID_RFC2684_FDDI_NOFCS, "FDDI no FCS" },
{ PID_RFC2684_802_6_FCS, "802.6 + FCS" },
{ PID_RFC2684_802_6_NOFCS, "802.6 no FCS" },
{ PID_RFC2684_BPDU, "BPDU" },
/* the real Ethertypes */
{ ETHERTYPE_IP, "IPv4" },
{ ETHERTYPE_MPLS, "MPLS unicast" },
{ ETHERTYPE_MPLS_MULTI, "MPLS multicast" },
@ -316,7 +300,7 @@ ether_encap_print(u_short ether_type, const u_char *p,
return (1);
case ETHERTYPE_LOOPBACK:
return (0);
return (1);
case ETHERTYPE_MPLS:
case ETHERTYPE_MPLS_MULTI:

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.32 2005/04/06 21:32:39 mcr Exp $ (LBL)";
"@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.32.2.4 2005/05/27 14:56:52 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -151,10 +151,9 @@ static int parse_q922_addr(const u_char *p, u_int *dlci, u_int *sdlcore,
*/
static u_int
fr_hdrlen(const u_char *p, u_int addr_len, u_int caplen)
fr_hdrlen(const u_char *p, u_int addr_len)
{
if ((caplen > addr_len + 1 /* UI */ + 1 /* pad */) &&
!p[addr_len + 1] /* pad exist */)
if (!p[addr_len + 1] /* pad exist */)
return addr_len + 1 /* UI */ + 1 /* pad */ + 1 /* NLPID */;
else
return addr_len + 1 /* UI */ + 1 /* NLPID */;
@ -192,9 +191,22 @@ fr_if_print(const struct pcap_pkthdr *h, register const u_char *p)
{
register u_int length = h->len;
register u_int caplen = h->caplen;
TCHECK2(*p, 4); /* minimum frame header length */
if ((length = fr_print(p, length)) == 0)
return (0);
else
return length;
trunc:
printf("[|fr]");
return caplen;
}
u_int
fr_print(register const u_char *p, u_int length)
{
u_int16_t extracted_ethertype;
u_int32_t orgcode;
register u_short et;
u_int dlci;
u_int sdlcore;
u_int addr_len;
@ -202,22 +214,14 @@ fr_if_print(const struct pcap_pkthdr *h, register const u_char *p)
u_int hdr_len;
u_int8_t flags[4];
if (caplen < 4) { /* minimum frame header length */
printf("[|fr]");
return caplen;
}
if (parse_q922_addr(p, &dlci, &sdlcore, &addr_len, flags)) {
printf("Q.922, invalid address");
return caplen;
return 0;
}
hdr_len = fr_hdrlen(p, addr_len, caplen);
if (caplen < hdr_len) {
printf("[|fr]");
return caplen;
}
TCHECK2(*p,addr_len+1+1);
hdr_len = fr_hdrlen(p, addr_len);
TCHECK2(*p,hdr_len);
if (p[addr_len] != 0x03 && dlci != 0) {
@ -230,7 +234,7 @@ fr_if_print(const struct pcap_pkthdr *h, register const u_char *p)
if (ether_encap_print(extracted_ethertype,
p+addr_len+ETHERTYPE_LEN,
length-addr_len-ETHERTYPE_LEN,
caplen-addr_len-ETHERTYPE_LEN,
length-addr_len-ETHERTYPE_LEN,
&extracted_ethertype) == 0)
/* ether_type not known, probably it wasn't one */
printf("UI %02x! ", p[addr_len]);
@ -251,7 +255,6 @@ fr_if_print(const struct pcap_pkthdr *h, register const u_char *p)
p += hdr_len;
length -= hdr_len;
caplen -= hdr_len;
switch (nlpid) {
case NLPID_IP:
@ -266,29 +269,17 @@ fr_if_print(const struct pcap_pkthdr *h, register const u_char *p)
case NLPID_CLNP:
case NLPID_ESIS:
case NLPID_ISIS:
isoclns_print(p-1, length+1, caplen+1); /* OSI printers need the NLPID field */
isoclns_print(p-1, length+1, length+1); /* OSI printers need the NLPID field */
break;
case NLPID_SNAP:
orgcode = EXTRACT_24BITS(p);
et = EXTRACT_16BITS(p + 3);
if (eflag)
(void)printf("SNAP, oui %s (0x%06x), ethertype %s (0x%04x): ",
tok2str(oui_values,"Unknown",orgcode),
orgcode,
tok2str(ethertype_values,"Unknown", et),
et);
if (snap_print((const u_char *)(p + 5), length - 5,
caplen - 5, &extracted_ethertype, orgcode, et,
0) == 0) {
if (snap_print(p, length, length, &extracted_ethertype, 0) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
fr_hdr_print(length + hdr_len, hdr_len,
dlci, flags, nlpid);
if (!xflag && !qflag)
default_print(p - hdr_len, caplen + hdr_len);
default_print(p - hdr_len, length + hdr_len);
}
break;
@ -305,10 +296,15 @@ fr_if_print(const struct pcap_pkthdr *h, register const u_char *p)
fr_hdr_print(length + hdr_len, addr_len,
dlci, flags, nlpid);
if (!xflag)
default_print(p, caplen);
default_print(p, length);
}
return hdr_len;
trunc:
printf("[|fr]");
return 0;
}
/* an NLPID of 0xb1 indicates a 2-byte
@ -484,6 +480,32 @@ struct common_ie_header {
u_int8_t ie_len;
};
static int fr_q933_print_ie_codeset5(const struct common_ie_header *ie_p,
const u_char *p);
typedef int (*codeset_pr_func_t)(const struct common_ie_header *ie_p,
const u_char *p);
/* array of 16 codepages - currently we only support codepage 5 */
static codeset_pr_func_t fr_q933_print_ie_codeset[] = {
NULL,
NULL,
NULL,
NULL,
NULL,
fr_q933_print_ie_codeset5,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
};
void
q933_print(const u_char *p, u_int length)
{
@ -491,7 +513,7 @@ q933_print(const u_char *p, u_int length)
struct common_ie_header *ie_p;
int olen;
int is_ansi = 0;
u_int dlci,codeset;
u_int codeset;
if (length < 9) { /* shortest: Q.933a LINK VERIFY */
printf("[|q.933]");
@ -506,7 +528,7 @@ q933_print(const u_char *p, u_int length)
printf("%s", eflag ? "" : "Q.933, ");
/* printing out header part */
printf(is_ansi ? "ANSI" : "CCITT ");
printf(is_ansi ? "ANSI" : "CCITT");
if (p[0])
printf(", Call Ref: 0x%02x", p[0]);
@ -550,53 +572,10 @@ q933_print(const u_char *p, u_int length)
ie_p->ie_id,
ie_p->ie_len);
switch (ie_p->ie_id) {
case FR_LMI_ANSI_REPORT_TYPE_IE: /* fall through */
case FR_LMI_CCITT_REPORT_TYPE_IE:
if (vflag)
printf("%s (%u)",
tok2str(fr_lmi_report_type_ie_values,"unknown",ptemp[2]),
ptemp[2]);
break;
case FR_LMI_ANSI_LINK_VERIFY_IE: /* fall through */
case FR_LMI_CCITT_LINK_VERIFY_IE:
case FR_LMI_ANSI_LINK_VERIFY_IE_91:
if (!vflag)
printf(", ");
printf("TX Seq: %3d, RX Seq: %3d", ptemp[2], ptemp[3]);
break;
case FR_LMI_ANSI_PVC_STATUS_IE: /* fall through */
case FR_LMI_CCITT_PVC_STATUS_IE:
if (!vflag)
printf(", ");
/* now parse the DLCI information element. */
if ((ie_p->ie_len < 3) ||
(ptemp[2] & 0x80) ||
((ie_p->ie_len == 3) && !(ptemp[3] & 0x80)) ||
((ie_p->ie_len == 4) && ((ptemp[3] & 0x80) || !(ptemp[4] & 0x80))) ||
((ie_p->ie_len == 5) && ((ptemp[3] & 0x80) || (ptemp[4] & 0x80) ||
!(ptemp[5] & 0x80))) ||
(ie_p->ie_len > 5) ||
!(ptemp[ie_p->ie_len + 1] & 0x80))
printf("Invalid DLCI IE");
dlci = ((ptemp[2] & 0x3F) << 4) | ((ptemp[3] & 0x78) >> 3);
if (ie_p->ie_len == 4)
dlci = (dlci << 6) | ((ptemp[4] & 0x7E) >> 1);
else if (ie_p->ie_len == 5)
dlci = (dlci << 13) | (ptemp[4] & 0x7F) | ((ptemp[5] & 0x7E) >> 1);
printf("DLCI %u: status %s%s", dlci,
ptemp[ie_p->ie_len + 1] & 0x8 ? "New, " : "",
ptemp[ie_p->ie_len + 1] & 0x2 ? "Active" : "Inactive");
break;
default:
if (!fr_q933_print_ie_codeset[codeset] ||
(*fr_q933_print_ie_codeset[codeset])(ie_p, ptemp)) {
if (vflag <= 1)
print_unknown_data(ptemp+2,"\n\t",ie_p->ie_len);
break;
}
/* do we want to see a hexdump of the IE ? */
@ -609,3 +588,56 @@ q933_print(const u_char *p, u_int length)
if (!vflag)
printf(", length %u",olen);
}
static int
fr_q933_print_ie_codeset5(const struct common_ie_header *ie_p, const u_char *p)
{
u_int dlci;
switch (ie_p->ie_id) {
case FR_LMI_ANSI_REPORT_TYPE_IE: /* fall through */
case FR_LMI_CCITT_REPORT_TYPE_IE:
if (vflag)
printf("%s (%u)",
tok2str(fr_lmi_report_type_ie_values,"unknown",p[2]),
p[2]);
return 1;
case FR_LMI_ANSI_LINK_VERIFY_IE: /* fall through */
case FR_LMI_CCITT_LINK_VERIFY_IE:
case FR_LMI_ANSI_LINK_VERIFY_IE_91:
if (!vflag)
printf(", ");
printf("TX Seq: %3d, RX Seq: %3d", p[2], p[3]);
return 1;
case FR_LMI_ANSI_PVC_STATUS_IE: /* fall through */
case FR_LMI_CCITT_PVC_STATUS_IE:
if (!vflag)
printf(", ");
/* now parse the DLCI information element. */
if ((ie_p->ie_len < 3) ||
(p[2] & 0x80) ||
((ie_p->ie_len == 3) && !(p[3] & 0x80)) ||
((ie_p->ie_len == 4) && ((p[3] & 0x80) || !(p[4] & 0x80))) ||
((ie_p->ie_len == 5) && ((p[3] & 0x80) || (p[4] & 0x80) ||
!(p[5] & 0x80))) ||
(ie_p->ie_len > 5) ||
!(p[ie_p->ie_len + 1] & 0x80))
printf("Invalid DLCI IE");
dlci = ((p[2] & 0x3F) << 4) | ((p[3] & 0x78) >> 3);
if (ie_p->ie_len == 4)
dlci = (dlci << 6) | ((p[4] & 0x7E) >> 1);
else if (ie_p->ie_len == 5)
dlci = (dlci << 13) | (p[4] & 0x7F) | ((p[5] & 0x7E) >> 1);
printf("DLCI %u: status %s%s", dlci,
p[ie_p->ie_len + 1] & 0x8 ? "New, " : "",
p[ie_p->ie_len + 1] & 0x2 ? "Active" : "Inactive");
return 1;
}
return 0;
}

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.81 2005/04/06 21:32:40 mcr Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.81.2.2 2005/07/01 16:13:37 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -291,6 +291,24 @@ static const struct tok icmp_mpls_ext_obj_values[] = {
{ 0, NULL}
};
/* prototypes */
const char *icmp_tstamp_print(u_int);
/* print the milliseconds since midnight UTC */
const char *
icmp_tstamp_print(u_int tstamp) {
u_int msec,sec,min,hrs;
static char buf[64];
msec = tstamp % 1000;
sec = tstamp / 1000;
min = sec / 60; sec -= min * 60;
hrs = min / 60; min -= hrs * 60;
snprintf(buf, sizeof(buf), "%02u:%02u:%02u.%03u",hrs,min,sec,msec);
return buf;
}
void
icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
{
@ -316,10 +334,11 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
case ICMP_ECHO:
case ICMP_ECHOREPLY:
TCHECK(dp->icmp_seq);
(void)snprintf(buf, sizeof(buf), "echo %s seq %u",
dp->icmp_type == ICMP_ECHO ?
"request" : "reply",
EXTRACT_16BITS(&dp->icmp_seq));
(void)snprintf(buf, sizeof(buf), "echo %s, id %u, seq %u",
dp->icmp_type == ICMP_ECHO ?
"request" : "reply",
EXTRACT_16BITS(&dp->icmp_id),
EXTRACT_16BITS(&dp->icmp_seq));
break;
case ICMP_UNREACH:
@ -499,13 +518,16 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
case ICMP_TSTAMPREPLY:
TCHECK(dp->icmp_ttime);
(void)snprintf(buf, sizeof(buf),
"time stamp reply id %u seq %u : org 0x%x recv 0x%x xmit 0x%x",
EXTRACT_16BITS(&dp->icmp_id),
EXTRACT_16BITS(&dp->icmp_seq),
EXTRACT_32BITS(&dp->icmp_otime),
EXTRACT_32BITS(&dp->icmp_rtime),
EXTRACT_32BITS(&dp->icmp_ttime));
break;
"time stamp reply id %u seq %u: org %s",
EXTRACT_16BITS(&dp->icmp_id),
EXTRACT_16BITS(&dp->icmp_seq),
icmp_tstamp_print(EXTRACT_32BITS(&dp->icmp_otime)));
(void)snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),", recv %s",
icmp_tstamp_print(EXTRACT_32BITS(&dp->icmp_rtime)));
(void)snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),", xmit %s",
icmp_tstamp_print(EXTRACT_32BITS(&dp->icmp_ttime)));
break;
default:
str = tok2str(icmp2str, "type-#%d", dp->icmp_type);

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.149 2005/04/07 00:28:17 mcr Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.149.2.1 2005/05/20 21:15:46 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -504,6 +504,10 @@ ip_print_demux(netdissect_options *ndo,
vrrp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
break;
case IPPROTO_PGM:
pgm_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
break;
default:
if ((proto = getprotobynumber(ipds->nh)) != NULL)
ND_PRINT((ndo, " %s", proto->p_name));

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.47 2005/04/06 21:32:40 mcr Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.47.2.2 2005/07/03 20:36:33 hannes Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -194,6 +194,7 @@ ip6_print(register const u_char *bp, register u_int length)
case IPPROTO_PIM:
pim_print(cp, len);
return;
case IPPROTO_OSPF:
ospf6_print(cp, len);
return;
@ -206,6 +207,18 @@ ip6_print(register const u_char *bp, register u_int length)
ip_print(gndo, cp, len);
return;
case IPPROTO_PGM:
pgm_print(cp, len, (const u_char *)ip6);
return;
case IPPROTO_GRE:
gre_print(cp, len);
return;
case IPPROTO_RSVP:
rsvp_print(cp, len);
return;
case IPPROTO_NONE:
(void)printf("no next header");
return;

View File

@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.40 2004/05/26 19:57:57 guy Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.40.2.2 2005/05/06 08:27:00 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -161,9 +161,13 @@ ipx_sap_print(const u_short *ipx, u_int length)
(void)printf("ipx-sap-nearest-resp");
for (i = 0; i < 8 && length > 0; i++) {
TCHECK2(ipx[25], 10);
TCHECK(ipx[0]);
(void)printf(" %s '", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0]))));
fn_print((u_char *)&ipx[1], (u_char *)&ipx[1] + 48);
if (fn_printzp((u_char *)&ipx[1], 48, snapend)) {
printf("'");
goto trunc;
}
TCHECK2(ipx[25], 10);
printf("' addr %s",
ipxaddr_string(EXTRACT_32BITS(&ipx[25]), (u_char *)&ipx[27]));
ipx += 32;

View File

@ -28,7 +28,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.133 2005/04/06 21:32:40 mcr Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.133.2.12 2005/06/16 01:14:52 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -129,7 +129,7 @@ static struct tok isis_pdu_values[] = {
#define ISIS_TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */
#define ISIS_TLV_NORTEL_PRIVATE1 176
#define ISIS_TLV_NORTEL_PRIVATE2 177
#define ISIS_TLV_RESTART_SIGNALING 211 /* draft-ietf-isis-restart-01 */
#define ISIS_TLV_RESTART_SIGNALING 211 /* rfc3847 */
#define ISIS_TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */
#define ISIS_TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */
#define ISIS_TLV_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */
@ -203,12 +203,20 @@ static struct tok esis_option_values[] = {
#define CLNP_OPTION_DISCARD_REASON 193
#define CLNP_OPTION_QOS_MAINTENANCE 195 /* iso8473 */
#define CLNP_OPTION_SECURITY 197 /* iso8473 */
#define CLNP_OPTION_SOURCE_ROUTING 200 /* iso8473 */
#define CLNP_OPTION_ROUTE_RECORDING 203 /* iso8473 */
#define CLNP_OPTION_PADDING 204 /* iso8473 */
#define CLNP_OPTION_PRIORITY 205 /* iso8473 */
static struct tok clnp_option_values[] = {
{ CLNP_OPTION_DISCARD_REASON, "Discard Reason"},
{ CLNP_OPTION_PRIORITY, "Priority"},
{ CLNP_OPTION_QOS_MAINTENANCE, "QoS Maintenance"},
{ CLNP_OPTION_SECURITY, "Security"},
{ CLNP_OPTION_SOURCE_ROUTING, "Source Routing"},
{ CLNP_OPTION_ROUTE_RECORDING, "Route Recording"},
{ CLNP_OPTION_PADDING, "Padding"},
{ 0, NULL }
};
@ -288,6 +296,40 @@ static struct tok *clnp_option_rfd_error_class[] = {
NULL
};
#define CLNP_OPTION_OPTION_QOS_MASK 0x3f
#define CLNP_OPTION_SCOPE_MASK 0xc0
#define CLNP_OPTION_SCOPE_SA_SPEC 0x40
#define CLNP_OPTION_SCOPE_DA_SPEC 0x80
#define CLNP_OPTION_SCOPE_GLOBAL 0xc0
static struct tok clnp_option_scope_values[] = {
{ CLNP_OPTION_SCOPE_SA_SPEC, "Source Address Specific"},
{ CLNP_OPTION_SCOPE_DA_SPEC, "Destination Address Specific"},
{ CLNP_OPTION_SCOPE_GLOBAL, "Globally unique"},
{ 0, NULL }
};
static struct tok clnp_option_sr_rr_values[] = {
{ 0x0, "partial"},
{ 0x1, "complete"},
{ 0, NULL }
};
static struct tok clnp_option_sr_rr_string_values[] = {
{ CLNP_OPTION_SOURCE_ROUTING, "source routing"},
{ CLNP_OPTION_ROUTE_RECORDING, "recording of route in progress"},
{ 0, NULL }
};
static struct tok clnp_option_qos_global_values[] = {
{ 0x20, "reserved"},
{ 0x10, "sequencing vs. delay"},
{ 0x08, "congested"},
{ 0x04, "delay vs. cost"},
{ 0x02, "error vs. delay"},
{ 0x01, "error vs. cost"},
{ 0, NULL }
};
#define ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* draft-ietf-isis-traffic-05 */
#define ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* draft-ietf-isis-gmpls-extensions */
@ -489,6 +531,7 @@ static struct tok isis_is_reach_virtual_values[] = {
static struct tok isis_restart_flag_values[] = {
{ 0x1, "Restart Request"},
{ 0x2, "Restart Acknowledgement"},
{ 0x4, "Suppress adjacency advertisement"},
{ 0, NULL }
};
@ -588,7 +631,9 @@ void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
break;
case NLPID_NULLNS:
(void)printf(", length: %u", length);
(void)printf("%slength: %u",
eflag ? "" : ", ",
length);
break;
case NLPID_Q933:
@ -612,7 +657,9 @@ void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
default:
if (!eflag)
printf("OSI NLPID 0x%02x unknown",*p);
(void)printf(", length: %u", length);
(void)printf("%slength: %u",
eflag ? "" : ", ",
length);
if (caplen > 1)
print_unknown_data(p,"\n\t",caplen);
break;
@ -658,7 +705,7 @@ struct clnp_segment_header_t {
static int clnp_print (const u_int8_t *pptr, u_int length)
{
const u_int8_t *optr,*source_address,*dest_address;
u_int li,source_address_length,dest_address_length, clnp_pdu_type, clnp_flags;
u_int li,tlen,nsap_offset,source_address_length,dest_address_length, clnp_pdu_type, clnp_flags;
const struct clnp_header_t *clnp_header;
const struct clnp_segment_header_t *clnp_segment_header;
u_int8_t rfd_error_major,rfd_error_minor;
@ -748,8 +795,7 @@ static int clnp_print (const u_int8_t *pptr, u_int length)
u_int op, opli;
const u_int8_t *tptr;
if (snapend - pptr < 2)
return (0);
TCHECK2(*pptr, 2);
if (li < 2) {
printf(", bad opts/li");
return (0);
@ -757,15 +803,14 @@ static int clnp_print (const u_int8_t *pptr, u_int length)
op = *pptr++;
opli = *pptr++;
li -= 2;
TCHECK2(*pptr, opli);
if (opli > li) {
printf(", opt (%d) too long", op);
return (0);
}
li -= opli;
tptr = pptr;
if (snapend < pptr)
return(0);
tlen = opli;
printf("\n\t %s Option #%u, length %u, value: ",
tok2str(clnp_option_values,"Unknown",op),
@ -774,9 +819,61 @@ static int clnp_print (const u_int8_t *pptr, u_int length)
switch (op) {
case CLNP_OPTION_ROUTE_RECORDING: /* those two options share the format */
case CLNP_OPTION_SOURCE_ROUTING:
printf("%s %s",
tok2str(clnp_option_sr_rr_values,"Unknown",*tptr),
tok2str(clnp_option_sr_rr_string_values,"Unknown Option %u",op));
nsap_offset=*(tptr+1);
if (nsap_offset == 0) {
printf(" Bad NSAP offset (0)");
break;
}
nsap_offset-=1; /* offset to nsap list */
if (nsap_offset > tlen) {
printf(" Bad NSAP offset (past end of option)");
break;
}
tptr+=nsap_offset;
tlen-=nsap_offset;
while (tlen > 0) {
source_address_length=*tptr;
if (tlen < source_address_length+1) {
printf("\n\t NSAP address goes past end of option");
break;
}
if (source_address_length > 0) {
source_address=(tptr+1);
TCHECK2(*source_address, source_address_length);
printf("\n\t NSAP address (length %u): %s",
source_address_length,
isonsap_string(source_address, source_address_length));
}
tlen-=source_address_length+1;
}
break;
case CLNP_OPTION_PRIORITY:
printf("%u", *tptr);
break;
printf("0x%1x", *tptr&0x0f);
break;
case CLNP_OPTION_QOS_MAINTENANCE:
printf("\n\t Format Code: %s",
tok2str(clnp_option_scope_values,"Reserved",*tptr&CLNP_OPTION_SCOPE_MASK));
if ((*tptr&CLNP_OPTION_SCOPE_MASK) == CLNP_OPTION_SCOPE_GLOBAL)
printf("\n\t QoS Flags [%s]",
bittok2str(clnp_option_qos_global_values,
"none",
*tptr&CLNP_OPTION_OPTION_QOS_MASK));
break;
case CLNP_OPTION_SECURITY:
printf("\n\t Format Code: %s, Security-Level %u",
tok2str(clnp_option_scope_values,"Reserved",*tptr&CLNP_OPTION_SCOPE_MASK),
*(tptr+1));
break;
case CLNP_OPTION_DISCARD_REASON:
rfd_error_major = (*tptr&0xf0) >> 4;
@ -788,6 +885,10 @@ static int clnp_print (const u_int8_t *pptr, u_int length)
rfd_error_minor);
break;
case CLNP_OPTION_PADDING:
printf("padding data");
break;
/*
* FIXME those are the defined Options that lack a decoder
* you are welcome to contribute code ;-)
@ -806,6 +907,7 @@ static int clnp_print (const u_int8_t *pptr, u_int length)
case CLNP_PDU_ER: /* fall through */
case CLNP_PDU_ERP:
TCHECK(*pptr);
if (*(pptr) == NLPID_CLNP) {
printf("\n\t-----original packet-----\n\t");
/* FIXME recursion protection */
@ -874,6 +976,7 @@ esis_print(const u_int8_t *pptr, u_int length)
}
esis_header = (const struct esis_header_t *) pptr;
TCHECK(*esis_header);
li = esis_header->length_indicator;
optr = pptr;
@ -923,7 +1026,8 @@ esis_print(const u_int8_t *pptr, u_int length)
/* do not attempt to verify the checksum if it is zero */
if (EXTRACT_16BITS(esis_header->cksum) == 0)
printf("(unverified)");
else printf("(%s)", osi_cksum(pptr, li) ? "incorrect" : "correct");
else
printf("(%s)", osi_cksum(pptr, li) ? "incorrect" : "correct");
printf(", holding time: %us, length indicator: %u",EXTRACT_16BITS(esis_header->holdtime),li);
@ -935,25 +1039,72 @@ esis_print(const u_int8_t *pptr, u_int length)
switch (esis_pdu_type) {
case ESIS_PDU_REDIRECT: {
const u_int8_t *dst, *snpa, *tptr;
const u_int8_t *dst, *snpa, *neta;
u_int dstl, snpal, netal;
dst = pptr; pptr += *pptr + 1;
if (pptr > snapend)
TCHECK(*pptr);
if (li < 1) {
printf(", bad redirect/li");
return;
printf("\n\t %s", isonsap_string(dst+1,*dst));
snpa = pptr; pptr += *pptr + 1;
tptr = pptr; pptr += *pptr + 1;
if (pptr > snapend)
}
dstl = *pptr;
pptr++;
li--;
TCHECK2(*pptr, dstl);
if (li < dstl) {
printf(", bad redirect/li");
return;
}
dst = pptr;
pptr += dstl;
li -= dstl;
printf("\n\t %s", isonsap_string(dst,dstl));
if (tptr[0] == 0)
printf("\n\t %s", etheraddr_string(&snpa[1]));
TCHECK(*pptr);
if (li < 1) {
printf(", bad redirect/li");
return;
}
snpal = *pptr;
pptr++;
li--;
TCHECK2(*pptr, snpal);
if (li < snpal) {
printf(", bad redirect/li");
return;
}
snpa = pptr;
pptr += snpal;
li -= snpal;
TCHECK(*pptr);
if (li < 1) {
printf(", bad redirect/li");
return;
}
netal = *pptr;
pptr++;
TCHECK2(*pptr, netal);
if (li < netal) {
printf(", bad redirect/li");
return;
}
neta = pptr;
pptr += netal;
li -= netal;
if (netal == 0)
printf("\n\t %s", etheraddr_string(snpa));
else
printf("\n\t %s", isonsap_string(tptr+1,*tptr));
printf("\n\t %s", isonsap_string(neta,netal));
break;
}
case ESIS_PDU_ESH:
TCHECK(*pptr);
if (li < 1) {
printf(", bad esh/li");
return;
}
source_address_number = *pptr;
pptr++;
li--;
@ -961,23 +1112,47 @@ esis_print(const u_int8_t *pptr, u_int length)
printf("\n\t Number of Source Addresses: %u", source_address_number);
while (source_address_number > 0) {
TCHECK(*pptr);
if (li < 1) {
printf(", bad esh/li");
return;
}
source_address_length = *pptr;
pptr++;
li--;
TCHECK2(*pptr, source_address_length);
if (li < source_address_length) {
printf(", bad esh/li");
return;
}
printf("\n\t NET (length: %u): %s",
source_address_length,
isonsap_string(pptr+1,source_address_length));
pptr += source_address_length+1;
li -= source_address_length+1;
isonsap_string(pptr,source_address_length));
pptr += source_address_length;
li -= source_address_length;
source_address_number--;
}
break;
case ESIS_PDU_ISH: {
TCHECK(*pptr);
if (li < 1) {
printf(", bad ish/li");
return;
}
source_address_length = *pptr;
printf("\n\t NET (length: %u): %s", source_address_length, isonsap_string(pptr+1, source_address_length));
pptr += source_address_length+1;
li -= source_address_length +1;
pptr++;
li--;
TCHECK2(*pptr, source_address_length);
if (li < source_address_length) {
printf(", bad ish/li");
return;
}
printf("\n\t NET (length: %u): %s", source_address_length, isonsap_string(pptr, source_address_length));
pptr += source_address_length;
li -= source_address_length;
break;
}
@ -994,8 +1169,7 @@ esis_print(const u_int8_t *pptr, u_int length)
u_int op, opli;
const u_int8_t *tptr;
if (snapend - pptr < 2)
return;
TCHECK2(*pptr, 2);
if (li < 2) {
printf(", bad opts/li");
return;
@ -1010,9 +1184,6 @@ esis_print(const u_int8_t *pptr, u_int length)
li -= opli;
tptr = pptr;
if (snapend < pptr)
return;
printf("\n\t %s Option #%u, length %u, value: ",
tok2str(esis_option_values,"Unknown",op),
op,
@ -1021,12 +1192,13 @@ esis_print(const u_int8_t *pptr, u_int length)
switch (op) {
case ESIS_OPTION_ES_CONF_TIME:
TCHECK2(*pptr, 2);
printf("%us", EXTRACT_16BITS(tptr));
break;
case ESIS_OPTION_PROTOCOLS:
while (opli>0) {
TCHECK(*pptr);
printf("%s (0x%02x)",
tok2str(nlpid_values,
"unknown",
@ -1058,6 +1230,8 @@ esis_print(const u_int8_t *pptr, u_int length)
print_unknown_data(pptr,"\n\t ",opli);
pptr += opli;
}
trunc:
return;
}
/* shared routine for printing system, node and lsp-ids */
@ -1329,7 +1503,7 @@ isis_print_is_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *i
not specified so just lets hexdump what is left */
if(subl>0){
if(!print_unknown_data(tptr,"\n\t\t ",
subl-36))
subl))
return(0);
}
}
@ -1942,7 +2116,11 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_ISNEIGH_VARLEN:
if (!TTEST2(*tptr, 1) || tmp < 3) /* min. TLV length */
goto trunctlv;
lan_alen = *tptr++; /* LAN adress length */
lan_alen = *tptr++; /* LAN address length */
if (lan_alen == 0) {
printf("\n\t LAN address length 0 bytes (invalid)");
break;
}
tmp --;
printf("\n\t LAN address length %u bytes ",lan_alen);
while (tmp >= lan_alen) {
@ -2086,7 +2264,7 @@ static int isis_print (const u_int8_t *p, u_int length)
break;
case ISIS_TLV_IP6ADDR:
while (tmp>0) {
while (tmp>=16) {
if (!TTEST2(*tptr, 16))
goto trunctlv;
@ -2190,7 +2368,7 @@ static int isis_print (const u_int8_t *p, u_int length)
break;
case ISIS_TLV_IPADDR:
while (tmp>0) {
while (tmp>=4) {
if (!TTEST2(*tptr, 4))
goto trunctlv;
printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr));
@ -2210,30 +2388,38 @@ static int isis_print (const u_int8_t *p, u_int length)
break;
case ISIS_TLV_SHARED_RISK_GROUP:
if (tmp < NODE_ID_LEN)
break;
if (!TTEST2(*tptr, NODE_ID_LEN))
goto trunctlv;
printf("\n\t IS Neighbor: %s", isis_print_id(tptr, NODE_ID_LEN));
tptr+=(NODE_ID_LEN);
tmp-=(NODE_ID_LEN);
if (tmp < 1)
break;
if (!TTEST2(*tptr, 1))
goto trunctlv;
printf(", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr++) ? "numbered" : "unnumbered");
tmp--;
if (tmp < 4)
break;
if (!TTEST2(*tptr,4))
goto trunctlv;
printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr));
tptr+=4;
tmp-=4;
if (tmp < 4)
break;
if (!TTEST2(*tptr,4))
goto trunctlv;
printf("\n\t IPv4 neighbor address: %s", ipaddr_string(tptr));
tptr+=4;
tmp-=4;
while (tmp>0) {
while (tmp>=4) {
if (!TTEST2(*tptr, 4))
goto trunctlv;
printf("\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr));
@ -2244,7 +2430,7 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_LSP:
tlv_lsp = (const struct isis_tlv_lsp *)tptr;
while(tmp>0) {
while(tmp>=sizeof(struct isis_tlv_lsp)) {
if (!TTEST((tlv_lsp->lsp_id)[LSP_ID_LEN-1]))
goto trunctlv;
printf("\n\t lsp-id: %s",
@ -2264,6 +2450,8 @@ static int isis_print (const u_int8_t *p, u_int length)
break;
case ISIS_TLV_CHECKSUM:
if (tmp < 2)
break;
if (!TTEST2(*tptr, 2))
goto trunctlv;
printf("\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr));
@ -2295,15 +2483,29 @@ static int isis_print (const u_int8_t *p, u_int length)
break;
case ISIS_TLV_RESTART_SIGNALING:
if (tmp < 3)
break;
if (!TTEST2(*tptr, 3))
goto trunctlv;
printf("\n\t Flags [%s], Remaining holding time %us",
bittok2str(isis_restart_flag_values, "none", *tptr),
EXTRACT_16BITS(tptr+1));
tptr+=3;
tmp-=3;
if (tmp == SYSTEM_ID_LEN) {
if (!TTEST2(*tptr, SYSTEM_ID_LEN))
goto trunctlv;
printf(", for %s",isis_print_id(tptr,SYSTEM_ID_LEN));
} else if (tmp == NODE_ID_LEN) {
if (!TTEST2(*tptr, NODE_ID_LEN))
goto trunctlv;
printf(", for %s",isis_print_id(tptr,NODE_ID_LEN));
}
break;
case ISIS_TLV_IDRP_INFO:
if (tmp < 1)
break;
if (!TTEST2(*tptr, 1))
goto trunctlv;
printf("\n\t Inter-Domain Information Type: %s",
@ -2326,6 +2528,8 @@ static int isis_print (const u_int8_t *p, u_int length)
break;
case ISIS_TLV_LSP_BUFFERSIZE:
if (tmp < 2)
break;
if (!TTEST2(*tptr, 2))
goto trunctlv;
printf("\n\t LSP Buffersize: %u",EXTRACT_16BITS(tptr));
@ -2342,6 +2546,8 @@ static int isis_print (const u_int8_t *p, u_int length)
break;
case ISIS_TLV_PREFIX_NEIGH:
if (tmp < sizeof(struct isis_metric_block))
break;
if (!TTEST2(*tptr, sizeof(struct isis_metric_block)))
goto trunctlv;
printf("\n\t Metric Block");
@ -2353,7 +2559,13 @@ static int isis_print (const u_int8_t *p, u_int length)
if (!TTEST2(*tptr, 1))
goto trunctlv;
prefix_len=*tptr++; /* read out prefix length in semioctets*/
if (prefix_len < 2) {
printf("\n\t\tAddress: prefix length %u < 2", prefix_len);
break;
}
tmp--;
if (tmp < prefix_len/2)
break;
if (!TTEST2(*tptr, prefix_len/2))
goto trunctlv;
printf("\n\t\tAddress: %s/%u",
@ -2365,12 +2577,16 @@ static int isis_print (const u_int8_t *p, u_int length)
break;
case ISIS_TLV_IIH_SEQNR:
if (tmp < 4)
break;
if (!TTEST2(*tptr, 4)) /* check if four bytes are on the wire */
goto trunctlv;
printf("\n\t Sequence number: %u", EXTRACT_32BITS(tptr) );
break;
case ISIS_TLV_VENDOR_PRIVATE:
if (tmp < 3)
break;
if (!TTEST2(*tptr, 3)) /* check if enough byte for a full oui */
goto trunctlv;
vendor_id = EXTRACT_24BITS(tptr);

View File

@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.61 2005/04/06 21:32:41 mcr Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.61.2.4 2005/04/26 07:27:16 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -61,6 +61,7 @@ static struct tok llc_values[] = {
{ LLCSAP_IPX, "IPX" },
{ LLCSAP_NETBEUI, "NetBeui" },
{ LLCSAP_ISONS, "OSI" },
{ 0, NULL },
};
static struct tok cmd2str[] = {
@ -75,6 +76,40 @@ static struct tok cmd2str[] = {
{ 0, NULL }
};
static const struct tok cisco_values[] = {
{ PID_CISCO_CDP, "CDP" },
{ 0, NULL }
};
static const struct tok bridged_values[] = {
{ PID_RFC2684_ETH_FCS, "Ethernet + FCS" },
{ PID_RFC2684_ETH_NOFCS, "Ethernet w/o FCS" },
{ PID_RFC2684_802_4_FCS, "802.4 + FCS" },
{ PID_RFC2684_802_4_NOFCS, "802.4 w/o FCS" },
{ PID_RFC2684_802_5_FCS, "Token Ring + FCS" },
{ PID_RFC2684_802_5_NOFCS, "Token Ring w/o FCS" },
{ PID_RFC2684_FDDI_FCS, "FDDI + FCS" },
{ PID_RFC2684_FDDI_NOFCS, "FDDI w/o FCS" },
{ PID_RFC2684_802_6_FCS, "802.6 + FCS" },
{ PID_RFC2684_802_6_NOFCS, "802.6 w/o FCS" },
{ PID_RFC2684_BPDU, "BPDU" },
{ 0, NULL },
};
struct oui_tok {
u_int32_t oui;
const struct tok *tok;
};
static const struct oui_tok oui_to_tok[] = {
{ OUI_ENCAP_ETHER, ethertype_values },
{ OUI_CISCO_90, ethertype_values }, /* uses some Ethertype values */
{ OUI_APPLETALK, ethertype_values }, /* uses some Ethertype values */
{ OUI_CISCO, cisco_values },
{ OUI_RFC2684, bridged_values }, /* bridged, RFC 2427 FR or RFC 2864 ATM */
{ 0, NULL }
};
/*
* Returns non-zero IFF it succeeds in printing the header
*/
@ -82,9 +117,9 @@ int
llc_print(const u_char *p, u_int length, u_int caplen,
const u_char *esrc, const u_char *edst, u_short *extracted_ethertype)
{
struct llc llc;
register u_short et;
u_int8_t dsap, ssap;
u_int16_t control;
int is_u;
register int ret;
if (caplen < 3) {
@ -93,18 +128,40 @@ llc_print(const u_char *p, u_int length, u_int caplen,
return(0);
}
/* Watch out for possible alignment problems */
memcpy((char *)&llc, (char *)p, min(caplen, sizeof(llc)));
dsap = *p;
ssap = *(p + 1);
if (eflag)
printf("LLC, dsap %s (0x%02x), ssap %s (0x%02x), cmd 0x%02x: ",
tok2str(llc_values,"Unknown",llc.dsap),
llc.dsap,
tok2str(llc_values,"Unknown",llc.ssap),
llc.ssap,
llc.llcu);
/*
* OK, what type of LLC frame is this? The length
* of the control field depends on that - I frames
* have a two-byte control field, and U frames have
* a one-byte control field.
*/
control = *(p + 2);
if ((control & LLC_U_FMT) == LLC_U_FMT) {
/*
* U frame.
*/
is_u = 1;
} else {
/*
* The control field in I and S frames is
* 2 bytes...
*/
if (caplen < 4) {
(void)printf("[|llc]");
default_print((u_char *)p, caplen);
return(0);
}
if (llc.ssap == LLCSAP_GLOBAL && llc.dsap == LLCSAP_GLOBAL) {
/*
* ...and is little-endian.
*/
control = EXTRACT_LE_16BITS(p + 2);
is_u = 0;
}
if (ssap == LLCSAP_GLOBAL && dsap == LLCSAP_GLOBAL) {
/*
* This is an Ethernet_802.3 IPX frame; it has an
* 802.3 header (i.e., an Ethernet header where the
@ -127,18 +184,38 @@ llc_print(const u_char *p, u_int length, u_int caplen,
return (1);
}
if (llc.ssap == LLCSAP_8021D && llc.dsap == LLCSAP_8021D) {
stp_print(p, length);
if (eflag) {
if (is_u) {
printf("LLC, dsap %s (0x%02x), ssap %s (0x%02x), cmd 0x%02x: ",
tok2str(llc_values, "Unknown", dsap),
dsap,
tok2str(llc_values, "Unknown", ssap),
ssap,
control);
} else {
printf("LLC, dsap %s (0x%02x), ssap %s (0x%02x), cmd 0x%04x: ",
tok2str(llc_values, "Unknown", dsap),
dsap,
tok2str(llc_values, "Unknown", ssap),
ssap,
control);
}
}
if (ssap == LLCSAP_8021D && dsap == LLCSAP_8021D &&
control == LLC_UI) {
stp_print(p+3, length-3);
return (1);
}
if (llc.ssap == LLCSAP_IP && llc.dsap == LLCSAP_IP) {
if (ssap == LLCSAP_IP && dsap == LLCSAP_IP &&
control == LLC_UI) {
ip_print(gndo, p+4, length-4);
return (1);
}
if (llc.ssap == LLCSAP_IPX && llc.dsap == LLCSAP_IPX &&
llc.llcui == LLC_UI) {
if (ssap == LLCSAP_IPX && dsap == LLCSAP_IPX &&
control == LLC_UI) {
/*
* This is an Ethernet_802.2 IPX frame, with an 802.3
* header and an 802.2 LLC header with the source and
@ -147,16 +224,13 @@ llc_print(const u_char *p, u_int length, u_int caplen,
* Skip DSAP, LSAP, and control field.
*/
printf("(NOV-802.2) ");
p += 3;
length -= 3;
caplen -= 3;
ipx_print(p, length);
ipx_print(p+3, length-3);
return (1);
}
#ifdef TCPDUMP_DO_SMB
if (llc.ssap == LLCSAP_NETBEUI && llc.dsap == LLCSAP_NETBEUI
&& (!(llc.llcu & LLC_S_FMT) || llc.llcu == LLC_U_FMT)) {
if (ssap == LLCSAP_NETBEUI && dsap == LLCSAP_NETBEUI
&& (!(control & LLC_S_FMT) || control == LLC_U_FMT)) {
/*
* we don't actually have a full netbeui parser yet, but the
* smb parser can handle many smb-in-netbeui packets, which
@ -169,107 +243,69 @@ llc_print(const u_char *p, u_int length, u_int caplen,
*/
/*
* Skip the DSAP and LSAP.
* Skip the LLC header.
*/
p += 2;
length -= 2;
caplen -= 2;
/*
* OK, what type of LLC frame is this? The length
* of the control field depends on that - I frames
* have a two-byte control field, and U frames have
* a one-byte control field.
*/
if (llc.llcu == LLC_U_FMT) {
control = llc.llcu;
p += 1;
length -= 1;
caplen -= 1;
if (is_u) {
p += 3;
length -= 3;
caplen -= 3;
} else {
/*
* The control field in I and S frames is
* little-endian.
*/
control = EXTRACT_LE_16BITS(&llc.llcu);
p += 2;
length -= 2;
caplen -= 2;
p += 4;
length -= 4;
caplen -= 4;
}
netbeui_print(control, p, length);
return (1);
}
#endif
if (llc.ssap == LLCSAP_ISONS && llc.dsap == LLCSAP_ISONS
&& llc.llcui == LLC_UI) {
if (ssap == LLCSAP_ISONS && dsap == LLCSAP_ISONS
&& control == LLC_UI) {
isoclns_print(p + 3, length - 3, caplen - 3);
return (1);
}
if (llc.ssap == LLCSAP_SNAP && llc.dsap == LLCSAP_SNAP
&& llc.llcui == LLC_UI) {
u_int32_t orgcode;
if (caplen < sizeof(llc)) {
(void)printf("[|llc-snap]");
default_print((u_char *)p, caplen);
return (0);
}
caplen -= sizeof(llc);
length -= sizeof(llc);
p += sizeof(llc);
orgcode = EXTRACT_24BITS(&llc.llc_orgcode[0]);
et = EXTRACT_16BITS(&llc.llc_ethertype[0]);
if (eflag)
(void)printf("oui %s (0x%06x), ethertype %s (0x%04x): ",
tok2str(oui_values,"Unknown",orgcode),
orgcode,
tok2str(ethertype_values,"Unknown", et),
et);
if (ssap == LLCSAP_SNAP && dsap == LLCSAP_SNAP
&& control == LLC_UI) {
/*
* XXX - what *is* the right bridge pad value here?
* Does anybody ever bridge one form of LAN traffic
* over a networking type that uses 802.2 LLC?
*/
ret = snap_print(p, length, caplen, extracted_ethertype,
orgcode, et, 2);
ret = snap_print(p+3, length-3, caplen-3, extracted_ethertype,
2);
if (ret)
return (ret);
}
if ((llc.ssap & ~LLC_GSAP) == llc.dsap) {
if (eflag || esrc == NULL || edst == NULL)
(void)printf("%s ", llcsap_string(llc.dsap));
else
(void)printf("%s > %s %s ",
if (!eflag) {
if ((ssap & ~LLC_GSAP) == dsap) {
if (esrc == NULL || edst == NULL)
(void)printf("%s ", llcsap_string(dsap));
else
(void)printf("%s > %s %s ",
etheraddr_string(esrc),
etheraddr_string(edst),
llcsap_string(dsap));
} else {
if (esrc == NULL || edst == NULL)
(void)printf("%s > %s ",
llcsap_string(ssap & ~LLC_GSAP),
llcsap_string(dsap));
else
(void)printf("%s %s > %s %s ",
etheraddr_string(esrc),
llcsap_string(ssap & ~LLC_GSAP),
etheraddr_string(edst),
llcsap_string(llc.dsap));
} else {
if (eflag || esrc == NULL || edst == NULL)
(void)printf("%s > %s ",
llcsap_string(llc.ssap & ~LLC_GSAP),
llcsap_string(llc.dsap));
else
(void)printf("%s %s > %s %s ",
etheraddr_string(esrc),
llcsap_string(llc.ssap & ~LLC_GSAP),
etheraddr_string(edst),
llcsap_string(llc.dsap));
llcsap_string(dsap));
}
}
if ((llc.llcu & LLC_U_FMT) == LLC_U_FMT) {
u_int16_t cmd;
if (is_u) {
const char *m;
char f;
cmd = LLC_U_CMD(llc.llcu);
m = tok2str(cmd2str, "%02x", cmd);
switch ((llc.ssap & LLC_GSAP) | (llc.llcu & LLC_U_POLL)) {
m = tok2str(cmd2str, "%02x", LLC_U_CMD(control));
switch ((ssap & LLC_GSAP) | (control & LLC_U_POLL)) {
case 0: f = 'C'; break;
case LLC_GSAP: f = 'R'; break;
case LLC_U_POLL: f = 'P'; break;
@ -283,7 +319,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
length -= 3;
caplen -= 3;
if ((llc.llcu & ~LLC_U_POLL) == LLC_XID) {
if ((control & ~LLC_U_POLL) == LLC_XID) {
if (*p == LLC_XID_FI) {
printf(": %02x %02x", p[1], p[2]);
p += 3;
@ -294,11 +330,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
} else {
char f;
/*
* The control field in I and S frames is little-endian.
*/
control = EXTRACT_LE_16BITS(&llc.llcu);
switch ((llc.ssap & LLC_GSAP) | (control & LLC_IS_POLL)) {
switch ((ssap & LLC_GSAP) | (control & LLC_IS_POLL)) {
case 0: f = 'C'; break;
case LLC_GSAP: f = 'R'; break;
case LLC_IS_POLL: f = 'P'; break;
@ -327,11 +359,37 @@ llc_print(const u_char *p, u_int length, u_int caplen,
int
snap_print(const u_char *p, u_int length, u_int caplen,
u_short *extracted_ethertype, u_int32_t orgcode, u_short et,
u_int bridge_pad)
u_short *extracted_ethertype, u_int bridge_pad)
{
u_int32_t orgcode;
register u_short et;
register int ret;
TCHECK2(*p, 5);
orgcode = EXTRACT_24BITS(p);
et = EXTRACT_16BITS(p + 3);
if (eflag) {
const struct tok *tok = NULL;
const struct oui_tok *otp;
for (otp = &oui_to_tok[0]; otp->tok != NULL; otp++) {
if (otp->oui == orgcode) {
tok = otp->tok;
break;
}
}
(void)printf("oui %s (0x%06x), %s %s (0x%04x): ",
tok2str(oui_values, "Unknown", orgcode),
orgcode,
(orgcode == 0x000000 ? "ethertype" : "pid"),
tok2str(tok, "Unknown", et),
et);
}
p += 5;
length -= 5;
caplen -= 5;
switch (orgcode) {
case OUI_ENCAP_ETHER:
case OUI_CISCO_90:
@ -383,6 +441,7 @@ snap_print(const u_char *p, u_int length, u_int caplen,
/*
* Skip the padding.
*/
TCHECK2(*p, bridge_pad);
caplen -= bridge_pad;
length -= bridge_pad;
p += bridge_pad;
@ -403,6 +462,7 @@ snap_print(const u_char *p, u_int length, u_int caplen,
* Skip the padding, but not the Access
* Control field.
*/
TCHECK2(*p, bridge_pad);
caplen -= bridge_pad;
length -= bridge_pad;
p += bridge_pad;
@ -423,6 +483,7 @@ snap_print(const u_char *p, u_int length, u_int caplen,
/*
* Skip the padding.
*/
TCHECK2(*p, bridge_pad + 1);
caplen -= bridge_pad + 1;
length -= bridge_pad + 1;
p += bridge_pad + 1;
@ -439,6 +500,10 @@ snap_print(const u_char *p, u_int length, u_int caplen,
}
}
return (0);
trunc:
(void)printf("[|snap]");
return (1);
}

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.106 2005/01/05 08:16:45 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.106.2.2 2005/05/06 07:57:18 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -390,9 +390,11 @@ parsefn(register const u_int32_t *dp)
cp = (u_char *)dp;
/* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */
dp += ((len + 3) & ~3) / sizeof(*dp);
/* XXX seems like we should be checking the length */
putchar('"');
(void) fn_printn(cp, len, NULL);
if (fn_printn(cp, len, snapend)) {
putchar('"');
goto trunc;
}
putchar('"');
return (dp);
@ -963,7 +965,7 @@ parserep(register const struct sunrpc_msg *rp, register u_int length)
/*
* now we can check the ar_stat field
*/
astat = EXTRACT_32BITS(dp);
astat = (enum sunrpc_accept_stat) EXTRACT_32BITS(dp);
switch (astat) {
case SUNRPC_SUCCESS:

View File

@ -27,7 +27,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.41 2004/01/28 14:54:50 hannes Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.41.2.1 2005/05/06 07:57:18 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -135,7 +135,8 @@ ntp_print(register const u_char *cp, u_int length)
break;
case PRIM_REF:
fn_printn((u_char *)&(bp->refid), 4, NULL);
if (fn_printn((u_char *)&(bp->refid), 4, snapend))
goto trunc;
break;
case INFO_QUERY:

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.53 2005/04/06 21:32:41 mcr Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.53.2.2 2005/05/19 07:26:18 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -72,49 +72,18 @@ static const char rcsid[] _U_ =
#define BSD_AF_INET6_FREEBSD 28
#define BSD_AF_INET6_DARWIN 30
static void
null_print(u_int family, u_int length)
{
if (nflag)
printf("AF %u ", family);
else {
switch (family) {
const struct tok bsd_af_values[] = {
{ BSD_AF_INET, "IPv4" },
{ BSD_AF_NS, "NS" },
{ BSD_AF_ISO, "ISO" },
{ BSD_AF_APPLETALK, "Appletalk" },
{ BSD_AF_IPX, "IPX" },
{ BSD_AF_INET6_BSD, "IPv6" },
{ BSD_AF_INET6_FREEBSD, "IPv6" },
{ BSD_AF_INET6_DARWIN, "IPv6" },
{ 0, NULL}
};
case BSD_AF_INET:
printf("ip ");
break;
#ifdef INET6
case BSD_AF_INET6_BSD:
case BSD_AF_INET6_FREEBSD:
case BSD_AF_INET6_DARWIN:
printf("ip6 ");
break;
#endif
case BSD_AF_NS:
printf("ns ");
break;
case BSD_AF_ISO:
printf("osi ");
break;
case BSD_AF_APPLETALK:
printf("atalk ");
break;
case BSD_AF_IPX:
printf("ipx ");
break;
default:
printf("AF %u ", family);
break;
}
}
printf("%d: ", length);
}
/*
* Byte-swap a 32-bit number.
@ -124,6 +93,20 @@ null_print(u_int family, u_int length)
#define SWAPLONG(y) \
((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff))
static inline void
null_hdr_print(u_int family, u_int length)
{
if (!qflag) {
(void)printf("AF %s (%u)",
tok2str(bsd_af_values,"Unknown",family),family);
} else {
(void)printf("%s",
tok2str(bsd_af_values,"Unknown AF %u",family));
}
(void)printf(", length %u: ", length);
}
/*
* This is the top level routine of the printer. 'p' points
* to the ether header of the packet, 'h->ts' is the timestamp,
@ -155,17 +138,17 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p)
if ((family & 0xFFFF0000) != 0)
family = SWAPLONG(family);
if (eflag)
null_hdr_print(family, length);
length -= NULL_HDRLEN;
caplen -= NULL_HDRLEN;
p += NULL_HDRLEN;
if (eflag)
null_print(family, length);
switch (family) {
case BSD_AF_INET:
ip_print(gndo, p, length);
ip_print(gndo, p, length);
break;
#ifdef INET6
@ -191,7 +174,7 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p)
default:
/* unknown AF_ value */
if (!eflag)
null_print(family, length + NULL_HDRLEN);
null_hdr_print(family, length + NULL_HDRLEN);
if (!xflag && !qflag)
default_print(p, caplen);
}

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.45 2005/04/06 21:32:42 mcr Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.45.2.2 2005/04/20 22:08:44 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -163,6 +163,10 @@ pimv1_join_prune_print(register const u_char *bp, register u_int len)
bp += 4;
len -= 4;
while (ngroups--) {
/*
* XXX - does the address have length "addrlen" and the
* mask length "maddrlen"?
*/
TCHECK2(bp[0], 4);
(void)printf("\n\tGroup: %s", ipaddr_string(bp));
TCHECK2(bp[4], 4);
@ -509,7 +513,6 @@ static int
pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent)
{
int af;
const char *afstr;
int len, hdrlen;
TCHECK(bp[0]);
@ -519,13 +522,11 @@ pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent)
switch (bp[0]) {
case 1:
af = AF_INET;
afstr = "IPv4";
len = 4;
break;
#ifdef INET6
case 2:
af = AF_INET6;
afstr = "IPv6";
len = 16;
break;
#endif
@ -539,12 +540,10 @@ pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent)
switch (pimv2_addr_len) {
case 4:
af = AF_INET;
afstr = "IPv4";
break;
#ifdef INET6
case 16:
af = AF_INET6;
afstr = "IPv6";
break;
#endif
default:

View File

@ -33,7 +33,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.108 2005/04/06 21:32:42 mcr Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.108.2.4 2005/06/18 23:56:40 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -245,43 +245,35 @@ static const char *lcpconfopts[] = {
/* 27-254 unassigned */
#define CCPOPT_RESV 255 /* RFC1962 */
#define CCPOPT_MIN CCPOPT_OUI
#define CCPOPT_MAX CCPOPT_DEFLATE /* XXX: should be CCPOPT_RESV but... */
static const char *ccpconfopts[] = {
"OUI", /* (0) */
"Pred-1", /* (1) */
"Pred-2", /* (2) */
"Puddle", /* (3) */
"unassigned(4)", /* (4) */
"unassigned(5)", /* (5) */
"unassigned(6)", /* (6) */
"unassigned(7)", /* (7) */
"unassigned(8)", /* (8) */
"unassigned(9)", /* (9) */
"unassigned(10)", /* (10) */
"unassigned(11)", /* (11) */
"unassigned(12)", /* (12) */
"unassigned(13)", /* (13) */
"unassigned(14)", /* (14) */
"unassigned(15)", /* (15) */
"HP-PPC", /* (16) */
"Stac-LZS", /* (17) */
"MPPC", /* (18) */
"Gand-FZA", /* (19) */
"V.42bis", /* (20) */
"BSD-Comp", /* (21) */
"unassigned(22)", /* (22) */
"LZS-DCP", /* (23) */
"MVRCA", /* (24) */
"DEC", /* (25) */
"Deflate", /* (26) */
const struct tok ccpconfopts_values[] = {
{ CCPOPT_OUI, "OUI" },
{ CCPOPT_PRED1, "Pred-1" },
{ CCPOPT_PRED2, "Pred-2" },
{ CCPOPT_PJUMP, "Puddle" },
{ CCPOPT_HPPPC, "HP-PPC" },
{ CCPOPT_STACLZS, "Stac-LZS" },
{ CCPOPT_MPPC, "MPPC" },
{ CCPOPT_GFZA, "Gand-FZA" },
{ CCPOPT_V42BIS, "V.42bis" },
{ CCPOPT_BSDCOMP, "BSD-Comp" },
{ CCPOPT_LZSDCP, "LZS-DCP" },
{ CCPOPT_MVRCA, "MVRCA" },
{ CCPOPT_DEC, "DEC" },
{ CCPOPT_DEFLATE, "Deflate" },
{ CCPOPT_RESV, "Reserved"},
{0, NULL}
};
/* BACP Config Options */
#define BACPOPT_FPEER 1 /* RFC2125 */
const struct tok bacconfopts_values[] = {
{ BACPOPT_FPEER, "Favored-Peer" },
{0, NULL}
};
/* SDCP - to be supported */
/* IPCP Config Options */
@ -354,6 +346,16 @@ struct tok authalg_values[] = {
#define CALLBACK_X500 4 /* X.500 distinguished name */
#define CALLBACK_CBCP 6 /* Location is determined during CBCP nego */
struct tok ppp_callback_values[] = {
{ CALLBACK_AUTH, "UserAuth" },
{ CALLBACK_DSTR, "DialString" },
{ CALLBACK_LID, "LocalID" },
{ CALLBACK_E164, "E.164" },
{ CALLBACK_X500, "X.500" },
{ CALLBACK_CBCP, "CBCP" },
{ 0, NULL }
};
/* CHAP */
#define CHAP_CHAL 1
@ -426,24 +428,34 @@ handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
code = *tptr++;
printf("%s (0x%02x), id %u",
printf("%s (0x%02x), id %u, length %u",
tok2str(cpcodes, "Unknown Opcode",code),
code,
*tptr++); /* ID */
code,
*tptr++, /* ID */
length+2);
if (!vflag)
return;
if (length <= 4)
return; /* there may be a NULL confreq etc. */
TCHECK2(*tptr, 2);
len = EXTRACT_16BITS(tptr);
tptr += 2;
if (length <= 4)
goto print_len_and_return; /* there may be a NULL confreq etc. */
printf("\n\tencoded length %u (=Option(s) length %u)",len,len-4);
if (vflag>1)
print_unknown_data(pptr-2,"\n\t",6);
switch (code) {
case CPCODES_VEXT:
if (length < 11)
break;
TCHECK2(*tptr, 4);
printf(", Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
printf("\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
tptr += 4;
TCHECK2(*tptr, 3);
printf(" Vendor: %s (%u)",
@ -503,26 +515,44 @@ handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
if (length < 6)
break;
TCHECK2(*tptr, 2);
printf(", Rejected %s Protocol (0x%04x)",
printf("\n\t Rejected %s Protocol (0x%04x)",
tok2str(ppptype2str,"unknown", EXTRACT_16BITS(tptr)),
EXTRACT_16BITS(tptr));
/* XXX: need to decode Rejected-Information? */
/* XXX: need to decode Rejected-Information? - hexdump for now */
if (len > 6) {
printf("\n\t Rejected Packet");
print_unknown_data(tptr+2,"\n\t ",len-2);
}
break;
case CPCODES_ECHO_REQ:
case CPCODES_ECHO_RPL:
case CPCODES_DISC_REQ:
if (length < 8)
break;
TCHECK2(*tptr, 4);
printf("\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
/* XXX: need to decode Data? - hexdump for now */
if (len > 8) {
printf("\n\t Data");
print_unknown_data(tptr+4,"\n\t ",len-4);
}
break;
case CPCODES_ID:
if (length < 8)
break;
TCHECK2(*tptr, 4);
printf(", Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
/* XXX: need to decode Data? */
printf("\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
/* RFC 1661 says this is intended to be human readable */
if (len > 8) {
printf("\n\t Message\n\t ");
fn_printn(tptr+4,len-4,snapend);
}
break;
case CPCODES_TIME_REM:
if (length < 12)
break;
TCHECK2(*tptr, 4);
printf(", Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
printf("\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
TCHECK2(*(tptr + 4), 4);
printf(", Seconds-Remaining %us", EXTRACT_32BITS(tptr + 4));
/* XXX: need to decode Message? */
@ -532,15 +562,9 @@ handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
* original pointer passed to the begin
* the PPP packet */
if (vflag <= 1)
print_unknown_data(pptr-2,"\n\t",length+2);
print_unknown_data(pptr-2,"\n\t ",length+2);
break;
}
print_len_and_return:
printf(", length %u", length);
if (vflag >1)
print_unknown_data(pptr-2,"\n\t",length+2);
return;
trunc:
@ -560,10 +584,17 @@ print_lcp_config_options(const u_char *p, int length)
opt = p[0];
if (length < len)
return 0;
if (len < 2) {
if ((opt >= LCPOPT_MIN) && (opt <= LCPOPT_MAX))
printf("\n\t %s Option (0x%02x), length %u (bogus, should be >= 2)", lcpconfopts[opt],opt,len);
else
printf("\n\tunknown LCP option 0x%02x", opt);
return 0;
}
if ((opt >= LCPOPT_MIN) && (opt <= LCPOPT_MAX))
printf(", %s (%u)", lcpconfopts[opt],opt);
printf("\n\t %s Option (0x%02x), length %u: ", lcpconfopts[opt],opt,len);
else {
printf(", unknown LCP option 0x%02x", opt);
printf("\n\tunknown LCP option 0x%02x", opt);
return len;
}
@ -571,7 +602,7 @@ print_lcp_config_options(const u_char *p, int length)
case LCPOPT_VEXT:
if (len >= 6) {
TCHECK2(*(p + 2), 3);
printf(" Vendor: %s (%u)",
printf("Vendor: %s (%u)",
tok2str(oui_values,"Unknown",EXTRACT_24BITS(p+2)),
EXTRACT_24BITS(p+2));
#if 0
@ -588,19 +619,19 @@ print_lcp_config_options(const u_char *p, int length)
case LCPOPT_MRU:
if (len == 4) {
TCHECK2(*(p + 2), 2);
printf(" %u", EXTRACT_16BITS(p + 2));
printf("%u", EXTRACT_16BITS(p + 2));
}
break;
case LCPOPT_ACCM:
if (len == 6) {
TCHECK2(*(p + 2), 4);
printf(" 0x%08x", EXTRACT_32BITS(p + 2));
printf("0x%08x", EXTRACT_32BITS(p + 2));
}
break;
case LCPOPT_AP:
if (len >= 4) {
TCHECK2(*(p + 2), 2);
printf(" %s", tok2str(ppptype2str,"Unknown Auth Proto (0x04x)",EXTRACT_16BITS(p+2)));
printf("%s", tok2str(ppptype2str,"Unknown Auth Proto (0x04x)",EXTRACT_16BITS(p+2)));
switch (EXTRACT_16BITS(p+2)) {
case PPP_CHAP:
@ -629,7 +660,7 @@ print_lcp_config_options(const u_char *p, int length)
case LCPOPT_MN:
if (len == 6) {
TCHECK2(*(p + 2), 4);
printf(" 0x%08x", EXTRACT_32BITS(p + 2));
printf("0x%08x", EXTRACT_32BITS(p + 2));
}
break;
case LCPOPT_PFC:
@ -639,41 +670,21 @@ print_lcp_config_options(const u_char *p, int length)
case LCPOPT_LD:
if (len == 4) {
TCHECK2(*(p + 2), 2);
printf(" 0x%04x", EXTRACT_16BITS(p + 2));
printf("0x%04x", EXTRACT_16BITS(p + 2));
}
break;
case LCPOPT_CBACK:
if (len < 3)
break;
TCHECK(p[2]);
switch (p[2]) { /* Operation */
case CALLBACK_AUTH:
printf(" UserAuth");
break;
case CALLBACK_DSTR:
printf(" DialString");
break;
case CALLBACK_LID:
printf(" LocalID");
break;
case CALLBACK_E164:
printf(" E.164");
break;
case CALLBACK_X500:
printf(" X.500");
break;
case CALLBACK_CBCP:
printf(" CBCP");
break;
default:
printf(" unknown-operation=%u", p[2]);
break;
}
printf("Callback Operation %s (%u)",
tok2str(ppp_callback_values,"Unknown",p[2]),
p[2]);
break;
case LCPOPT_MLMRRU:
if (len == 4) {
TCHECK2(*(p + 2), 2);
printf(" %u", EXTRACT_16BITS(p + 2));
printf("%u", EXTRACT_16BITS(p + 2));
}
break;
case LCPOPT_MLED:
@ -682,29 +693,29 @@ print_lcp_config_options(const u_char *p, int length)
TCHECK(p[2]);
switch (p[2]) { /* class */
case MEDCLASS_NULL:
printf(" Null");
printf("Null");
break;
case MEDCLASS_LOCAL:
printf(" Local"); /* XXX */
printf("Local"); /* XXX */
break;
case MEDCLASS_IPV4:
if (len != 7)
break;
TCHECK2(*(p + 3), 4);
printf(" IPv4 %s", ipaddr_string(p + 3));
printf("IPv4 %s", ipaddr_string(p + 3));
break;
case MEDCLASS_MAC:
if (len != 9)
break;
TCHECK(p[8]);
printf(" MAC %02x:%02x:%02x:%02x:%02x:%02x",
printf("MAC %02x:%02x:%02x:%02x:%02x:%02x",
p[3], p[4], p[5], p[6], p[7], p[8]);
break;
case MEDCLASS_MNB:
printf(" Magic-Num-Block"); /* XXX */
printf("Magic-Num-Block"); /* XXX */
break;
case MEDCLASS_PSNDN:
printf(" PSNDN"); /* XXX */
printf("PSNDN"); /* XXX */
break;
}
break;
@ -732,7 +743,15 @@ print_lcp_config_options(const u_char *p, int length)
case LCPOPT_PPPMUX:
break;
#endif
default:
if(vflag<2)
print_unknown_data(&p[2],"\n\t ",len-2);
break;
}
if (vflag>1)
print_unknown_data(&p[2],"\n\t ",len-2); /* exclude TLV header */
return len;
trunc:
@ -874,6 +893,16 @@ handle_pap(const u_char *p, int length)
len = EXTRACT_16BITS(p);
p += 2;
if ((int)len > length) {
printf(", length %u > packet size", len);
return;
}
length = len;
if (length < (p - p0)) {
printf(", length %u < PAP header length", length);
return;
}
switch (code) {
case PAP_AREQ:
if (length - (p - p0) < 1)
@ -945,10 +974,18 @@ print_ipcp_config_options(const u_char *p, int length)
opt = p[0];
if (length < len)
return 0;
if (len < 2) {
printf("\n\t %s Option (0x%02x), length %u (bogus, should be >= 2)",
tok2str(ipcpopt_values,"unknown",opt),
opt,
len);
return 0;
}
printf(", %s (0x%02x) ",
printf("\n\t %s Option (0x%02x), length %u: ",
tok2str(ipcpopt_values,"unknown",opt),
opt);
opt,
len);
switch (opt) {
case IPCPOPT_2ADDR: /* deprecated */
@ -982,9 +1019,12 @@ print_ipcp_config_options(const u_char *p, int length)
printf("%s", ipaddr_string(p + 2));
break;
default:
printf(", unknown-%d", opt);
if(vflag<2)
print_unknown_data(&p[2],"\n\t ",len-2);
break;
}
if (vflag>1)
print_unknown_data(&p[2],"\n\t ",len-2); /* exclude TLV header */
return len;
invlen:
@ -1009,10 +1049,18 @@ print_ip6cp_config_options(const u_char *p, int length)
opt = p[0];
if (length < len)
return 0;
if (len < 2) {
printf("\n\t %s Option (0x%02x), length %u (bogus, should be >= 2)",
tok2str(ip6cpopt_values,"unknown",opt),
opt,
len);
return 0;
}
printf(", %s (0x%02x) ",
printf("\n\t %s Option (0x%02x), length %u: ",
tok2str(ip6cpopt_values,"unknown",opt),
opt);
opt,
len);
switch (opt) {
case IP6CP_IFID:
@ -1026,9 +1074,13 @@ print_ip6cp_config_options(const u_char *p, int length)
EXTRACT_16BITS(p + 8));
break;
default:
printf(", unknown-%d", opt);
if(vflag<2)
print_unknown_data(&p[2],"\n\t ",len-2);
break;
}
if (vflag>1)
print_unknown_data(&p[2],"\n\t ",len-2); /* exclude TLV header */
return len;
invlen:
@ -1054,10 +1106,21 @@ print_ccp_config_options(const u_char *p, int length)
opt = p[0];
if (length < len)
return 0;
if ((opt >= CCPOPT_MIN) && (opt <= CCPOPT_MAX))
printf(", %s", ccpconfopts[opt]);
#if 0 /* XXX */
if (len < 2) {
printf("\n\t %s Option (0x%02x), length %u (bogus, should be >= 2)",
tok2str(ccpconfopts_values, "Unknown", opt),
opt,
len);
return 0;
}
printf("\n\t %s Option (0x%02x), length %u:",
tok2str(ccpconfopts_values, "Unknown", opt),
opt,
len);
switch (opt) {
/* fall through --> default: nothing supported yet */
case CCPOPT_OUI:
case CCPOPT_PRED1:
case CCPOPT_PRED2:
@ -1073,13 +1136,14 @@ print_ccp_config_options(const u_char *p, int length)
case CCPOPT_DEC:
case CCPOPT_DEFLATE:
case CCPOPT_RESV:
break;
default:
printf(", unknown-%d", opt);
if(vflag<2)
print_unknown_data(&p[2],"\n\t ",len-2);
break;
}
#endif
if (vflag>1)
print_unknown_data(&p[2],"\n\t ",len-2); /* exclude TLV header */
return len;
trunc:
@ -1100,13 +1164,32 @@ print_bacp_config_options(const u_char *p, int length)
opt = p[0];
if (length < len)
return 0;
if (opt == BACPOPT_FPEER) {
if (len < 2) {
printf("\n\t %s Option (0x%02x), length %u (bogus, should be >= 2)",
tok2str(bacconfopts_values, "Unknown", opt),
opt,
len);
return 0;
}
printf("\n\t %s Option (0x%02x), length %u:",
tok2str(bacconfopts_values, "Unknown", opt),
opt,
len);
switch (opt) {
case BACPOPT_FPEER:
TCHECK2(*(p + 2), 4);
printf(", Favored-Peer");
printf(", Magic-Num 0x%08x", EXTRACT_32BITS(p + 2));
} else {
printf(", unknown-option-%d", opt);
break;
default:
if(vflag<2)
print_unknown_data(&p[2],"\n\t ",len-2);
break;
}
if (vflag>1)
print_unknown_data(&p[2],"\n\t ",len-2); /* exclude TLV header */
return len;
trunc:

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.46 2004/12/27 00:41:31 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.46.2.1 2005/04/27 21:44:06 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -53,15 +53,16 @@ static const char rcsid[] _U_ =
#include "rpc_auth.h"
#include "rpc_msg.h"
#include "pmap_prot.h"
static struct tok proc2str[] = {
{ PMAPPROC_NULL, "null" },
{ PMAPPROC_SET, "set" },
{ PMAPPROC_UNSET, "unset" },
{ PMAPPROC_GETPORT, "getport" },
{ PMAPPROC_DUMP, "dump" },
{ PMAPPROC_CALLIT, "call" },
{ 0, NULL }
{ SUNRPC_PMAPPROC_NULL, "null" },
{ SUNRPC_PMAPPROC_SET, "set" },
{ SUNRPC_PMAPPROC_UNSET, "unset" },
{ SUNRPC_PMAPPROC_GETPORT, "getport" },
{ SUNRPC_PMAPPROC_DUMP, "dump" },
{ SUNRPC_PMAPPROC_CALLIT, "call" },
{ 0, NULL }
};
/* Forwards */
@ -88,7 +89,7 @@ sunrpcrequest_print(register const u_char *bp, register u_int length,
} else {
snprintf(srcid, sizeof(srcid), "0x%x",
EXTRACT_32BITS(&rp->rm_xid));
snprintf(dstid, sizeof(dstid), "0x%x", PMAPPORT);
snprintf(dstid, sizeof(dstid), "0x%x", SUNRPC_PMAPPORT);
}
switch (IP_V((struct ip *)bp2)) {
@ -119,10 +120,10 @@ sunrpcrequest_print(register const u_char *bp, register u_int length,
switch (EXTRACT_32BITS(&rp->rm_call.cb_proc)) {
case PMAPPROC_SET:
case PMAPPROC_UNSET:
case PMAPPROC_GETPORT:
case PMAPPROC_CALLIT:
case SUNRPC_PMAPPROC_SET:
case SUNRPC_PMAPPROC_UNSET:
case SUNRPC_PMAPPROC_GETPORT:
case SUNRPC_PMAPPROC_CALLIT:
x = EXTRACT_32BITS(&rp->rm_call.cb_prog);
if (!nflag)
printf(" %s", progstr(x));

View File

@ -57,6 +57,20 @@
#include <sys/types.h>
#include <net/netdb.h> /* in wpcap's Win32/include */
#if !defined(__MINGW32__) && !defined(__WATCOMC__)
#undef toascii
#define isascii __isascii
#define toascii __toascii
#define stat _stat
#define open _open
#define fstat _fstat
#define read _read
#define close _close
#define O_RDONLY _O_RDONLY
typedef short ino_t;
#endif /* __MINGW32__ */
#ifdef __MINGW32__
#include <stdint.h>
#endif
@ -91,8 +105,15 @@ typedef char* caddr_t;
#include <ctype.h>
#include <unistd.h>
#include <netdb.h>
#ifdef INTTYPES_H_DEFINES_FORMATS
#if HAVE_INTTYPES_H
#include <inttypes.h>
#else
#if HAVE_STDINT_H
#include <stdint.h>
#endif
#endif
#ifdef HAVE_SYS_BITYPES_H
#include <sys/bitypes.h>
#endif
#include <sys/param.h>
#include <sys/types.h> /* concession to AIX */

View File

@ -1,4 +1,4 @@
.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1,v 1.167 2004/12/28 22:31:25 guy Exp $ (LBL)
.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1,v 1.167.2.4 2005/05/02 21:27:34 guy Exp $ (LBL)
.\"
.\" $NetBSD: tcpdump.8,v 1.9 2003/03/31 00:18:17 perry Exp $
.\"
@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
.TH TCPDUMP 1 "22 March 2004"
.TH TCPDUMP 1 "18 April 2005"
.SH NAME
tcpdump \- dump traffic on a network
.SH SYNOPSIS
@ -603,10 +603,11 @@ different kinds of qualifier:
qualifiers say what kind of thing the id name or number refers to.
Possible types are
.BR host ,
.B net
.B net ,
.B port
and
.BR port .
E.g., `host foo', `net 128.3', `port 20'.
.BR portrange .
E.g., `host foo', `net 128.3', `port 20', `portrange 6000-6008'.
If there is no type
qualifier,
.B host
@ -657,7 +658,8 @@ protos are:
.B tcp
and
.BR udp .
E.g., `ether src foo', `arp net 128.3', `tcp port 21'.
E.g., `ether src foo', `arp net 128.3', `tcp port 21', `udp portrange
7000-7009'.
If there is
no proto qualifier, all protocols consistent with the type are
assumed.
@ -709,6 +711,7 @@ which may be either an address or a name.
True if the IPv4/v6 source field of the packet is \fIhost\fP.
.IP "\fBhost \fIhost\fP
True if either the IPv4/v6 source or destination of the packet is \fIhost\fP.
.IP
Any of the above host expressions can be prepended with the keywords,
\fBip\fP, \fBarp\fP, \fBrarp\fP, or \fBip6\fP as in:
.in +.5i
@ -763,7 +766,7 @@ number of \fInet\fP.
True if either the IPv4/v6 source or destination address of the packet has a network
number of \fInet\fP.
.IP "\fBnet \fInet\fR \fBmask \fInetmask\fR"
True if the IP address matches \fInet\fR with the specific \fInetmask\fR.
True if the IPv4 address matches \fInet\fR with the specific \fInetmask\fR.
May be qualified with \fBsrc\fR or \fBdst\fR.
Note that this syntax is not valid for IPv6 \fInet\fR.
.IP "\fBnet \fInet\fR/\fIlen\fR"
@ -787,8 +790,25 @@ both tcp/domain and udp/domain traffic).
True if the packet has a source port value of \fIport\fP.
.IP "\fBport \fIport\fR"
True if either the source or destination port of the packet is \fIport\fP.
Any of the above port expressions can be prepended with the keywords,
\fBtcp\fP or \fBudp\fP, as in:
.IP "\fBdst portrange \fIport1\fB-\fIport2\fR"
True if the packet is ip/tcp, ip/udp, ip6/tcp or ip6/udp and has a
destination port value between \fIport1\fP and \fIport2\fP.
.I port1
and
.I port2
are interpreted in the same fashion as the
.I port
parameter for
.BR port .
.IP "\fBsrc portrange \fIport1\fB-\fIport2\fR"
True if the packet has a source port value between \fIport1\fP and
\fIport2\fP.
.IP "\fBportrange \fIport1\fB-\fIport2\fR"
True if either the source or destination port of the packet is between
\fIport1\fP and \fIport2\fP.
.IP
Any of the above port or port range expressions can be prepended with
the keywords, \fBtcp\fP or \fBudp\fP, as in:
.in +.5i
.nf
\fBtcp src port \fIport\fR
@ -812,7 +832,7 @@ This is equivalent to:
.fi
.in -.5i
.IP "\fBip proto \fIprotocol\fR"
True if the packet is an IP packet (see
True if the packet is an IPv4 packet (see
.IR ip (4P))
of protocol type \fIprotocol\fP.
\fIProtocol\fP can be a number or one of the names
@ -864,7 +884,7 @@ The \fBether\fP
keyword is optional.
This is shorthand for `\fBether[0] & 1 != 0\fP'.
.IP "\fBip multicast\fR"
True if the packet is an IP multicast packet.
True if the packet is an IPv4 multicast packet.
.IP "\fBip6 multicast\fR"
True if the packet is an IPv6 multicast packet.
.IP "\fBether proto \fIprotocol\fR"
@ -1014,6 +1034,15 @@ If \fI[vlan_id]\fR is specified, only true is the packet has the specified
Note that the first \fBvlan\fR keyword encountered in \fIexpression\fR
changes the decoding offsets for the remainder of \fIexpression\fR
on the assumption that the packet is a VLAN packet.
the \fI[vlan_id]\fR statement may be used more than once, to filter on vlan hierarchies.
each use of the \fI[vlan_id]\fR \fIexpression\fR increments the filter offsets by 4.
.fi
example(s):
.fi
"vlan 100 && vlan 200" filters on vlan 200 encapsulated within vlan 100
.fi
"vlan && vlan 300 && ip" filters IPv4 protocols encapsulated in vlan 300 encapsulated within any higher order vlan
.fi
.IP "\fBtcp\fR, \fBudp\fR, \fBicmp\fR"
Abbreviations for:
.in +.5i
@ -1103,10 +1132,11 @@ data inside the packet, use the following syntax:
.fi
.in -.5i
\fIProto\fR is one of \fBether, fddi, tr, wlan, ppp, slip, link,
ip, arp, rarp, tcp, udp, icmp\fR or \fBip6\fR, and
ip, arp, rarp, tcp, udp, icmp, ip6\fR or \fBradio\fR, and
indicates the protocol layer for the index operation.
(\fBether, fddi, wlan, tr, ppp, slip\fR and \fBlink\fR all refer to the
link layer.)
link layer. \fBradio\fR refers to the "radio header" added to some
802.11 captures.)
Note that \fItcp, udp\fR and other upper-layer protocol types only
apply to IPv4, not IPv6 (this will be fixed in the future).
The byte offset, relative to the indicated protocol layer, is
@ -1118,10 +1148,11 @@ length of the packet.
For example, `\fBether[0] & 1 != 0\fP' catches all multicast traffic.
The expression `\fBip[0] & 0xf != 5\fP'
catches all IP packets with options.
catches all IPv4 packets with options.
The expression
`\fBip[6:2] & 0x1fff = 0\fP'
catches only unfragmented datagrams and frag zero of fragmented datagrams.
catches only unfragmented IPv4 datagrams and frag zero of fragmented
IPv4 datagrams.
This check is implicitly applied to the \fBtcp\fP and \fBudp\fP
index operations.
For instance, \fBtcp[0]\fP always means the first

View File

@ -30,7 +30,7 @@ static const char copyright[] _U_ =
"@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
The Regents of the University of California. All rights reserved.\n";
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.253 2005/01/27 18:30:36 hannes Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.253.2.8 2005/07/05 21:09:05 mcr Exp $ (LBL)";
#endif
/* $FreeBSD$ */
@ -228,11 +228,32 @@ static struct printer printers[] = {
#ifdef DLT_JUNIPER_ATM2
{ juniper_atm2_print, DLT_JUNIPER_ATM2 },
#endif
#ifdef DLT_JUNIPER_MFR
{ juniper_mfr_print, DLT_JUNIPER_MFR },
#endif
#ifdef DLT_JUNIPER_MLFR
{ juniper_mlfr_print, DLT_JUNIPER_MLFR },
#endif
#ifdef DLT_JUNIPER_MLPPP
{ juniper_mlppp_print, DLT_JUNIPER_MLPPP },
#endif
#ifdef DLT_JUNIPER_PPPOE
{ juniper_pppoe_print, DLT_JUNIPER_PPPOE },
#endif
#ifdef DLT_JUNIPER_PPPOE_ATM
{ juniper_pppoe_atm_print, DLT_JUNIPER_PPPOE_ATM },
#endif
#ifdef DLT_JUNIPER_GGSN
{ juniper_ggsn_print, DLT_JUNIPER_GGSN },
#endif
#ifdef DLT_JUNIPER_ES
{ juniper_es_print, DLT_JUNIPER_ES },
#endif
#ifdef DLT_JUNIPER_MONITOR
{ juniper_monitor_print, DLT_JUNIPER_MONITOR },
#endif
#ifdef DLT_JUNIPER_SERVICES
{ juniper_services_print, DLT_JUNIPER_SERVICES },
#endif
{ NULL, 0 },
};
@ -1132,7 +1153,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
* larger than Cflag - the last packet written to the
* file could put it over Cflag.
*/
if (ftell((FILE *)dump_info->p) > Cflag) {
if (pcap_dump_ftell(dump_info->p) > Cflag) {
/*
* Close the current file and open a new one.
*/