resolve merge conflicts and update for proper build; including:

o print-fr.c returned to code on vendor branch
o remove pmap_prot.h include from print-sunrprc.c
o remove gcc/i386-specific ntoh* write-arounds from tcpdump-stdinc.h

Reviewed by:	bms
This commit is contained in:
Sam Leffler 2005-05-29 19:09:28 +00:00
parent 3d1038b8ce
commit c1ad1296ec
31 changed files with 3342 additions and 1825 deletions

View File

@ -25,7 +25,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.96.2.6 2004/03/24 04:14:31 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.108 2005/03/27 22:38:09 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -41,11 +41,15 @@ struct rtentry; /* declarations in <net/if.h> */
#include <net/if.h> /* for "struct ifnet" in "struct arpcom" on Solaris */
#include <netinet/if_ether.h>
#endif /* HAVE_NETINET_IF_ETHER_H */
#ifdef HAVE_NETINET_ETHER_H
#include <netinet/ether.h> /* ether_ntohost on linux */
#endif /* HAVE_NETINET_ETHER_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
extern int ether_ntohost(char *, const struct ether_addr *);
#endif
#include <pcap.h>
#include <pcap-namedb.h>
#include <signal.h>
@ -105,25 +109,20 @@ win32_gethostbyaddr(const char *addr, int len, int type)
memset(&addr6, 0, sizeof(addr6));
addr6.sin6_family = AF_INET6;
memcpy(&addr6.sin6_addr, addr, len);
#ifdef __MINGW32__
/* MinGW doesn't provide getnameinfo */
return NULL;
#else
if (getnameinfo((struct sockaddr *)&addr6, sizeof(addr6),
hname, sizeof(hname), NULL, 0, 0)) {
return NULL;
hname, sizeof(hname), NULL, 0, 0)) {
return NULL;
} else {
strcpy(host.h_name, hname);
return &host;
}
#endif /* __MINGW32__ */
break;
default:
return NULL;
}
}
#define gethostbyaddr win32_gethostbyaddr
#endif /* INET6 & WIN32*/
#endif /* INET6 & WIN32 */
#ifdef INET6
struct h6namemem {
@ -466,18 +465,25 @@ etheraddr_string(register const u_char *ep)
#ifdef USE_ETHER_NTOHOST
if (!nflag) {
char buf2[128];
if (ether_ntohost(buf2, (const struct ether_addr *)ep) == 0) {
/*
* We don't cast it to "const struct ether_addr *"
* because some systems don't modify the Ethernet
* address but fail to declare the second argument
* as a "const" pointer.
*/
if (ether_ntohost(buf2, (struct ether_addr *)ep) == 0) {
tp->e_name = strdup(buf2);
return (tp->e_name);
}
}
#endif
cp = buf;
*cp++ = hex[*ep >> 4 ];
*cp++ = hex[*ep >> 4 ];
*cp++ = hex[*ep++ & 0xf];
for (i = 5; (int)--i >= 0;) {
*cp++ = ':';
*cp++ = hex[*ep >> 4 ];
*cp++ = hex[*ep >> 4 ];
*cp++ = hex[*ep++ & 0xf];
}
*cp = '\0';
@ -488,7 +494,7 @@ etheraddr_string(register const u_char *ep)
const char *
linkaddr_string(const u_char *ep, const unsigned int len)
{
register u_int i, j;
register u_int i;
register char *cp;
register struct enamemem *tp;
@ -502,13 +508,11 @@ linkaddr_string(const u_char *ep, const unsigned int len)
tp->e_name = cp = (char *)malloc(len*3);
if (tp->e_name == NULL)
error("linkaddr_string: malloc");
if ((j = *ep >> 4) != 0)
*cp++ = hex[j];
*cp++ = hex[*ep >> 4];
*cp++ = hex[*ep++ & 0xf];
for (i = len-1; i > 0 ; --i) {
*cp++ = ':';
if ((j = *ep >> 4) != 0)
*cp++ = hex[j];
*cp++ = hex[*ep >> 4];
*cp++ = hex[*ep++ & 0xf];
}
*cp = '\0';
@ -587,27 +591,32 @@ llcsap_string(u_char sap)
return (tp->name);
}
#define ISONSAP_MAX_LENGTH 20
const char *
isonsap_string(const u_char *nsap)
isonsap_string(const u_char *nsap, register u_int nsap_length)
{
register u_int i, nlen = nsap[0];
register u_int nsap_idx;
register char *cp;
register struct enamemem *tp;
if (nsap_length < 1 || nsap_length > ISONSAP_MAX_LENGTH)
error("isonsap_string: illegal length");
tp = lookup_nsap(nsap);
if (tp->e_name)
return tp->e_name;
tp->e_name = cp = (char *)malloc(nlen * 2 + 2 + (nlen>>1));
tp->e_name = cp = (char *)malloc(sizeof("xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx"));
if (cp == NULL)
error("isonsap_string: malloc");
nsap++;
for (i = 0; i < nlen; i++) {
for (nsap_idx = 0; nsap_idx < nsap_length; nsap_idx++) {
*cp++ = hex[*nsap >> 4];
*cp++ = hex[*nsap++ & 0xf];
if (((i & 1) == 0) && (i + 1 < nlen))
*cp++ = '.';
if (((nsap_idx & 1) == 0) &&
(nsap_idx + 1 < nsap_length)) {
*cp++ = '.';
}
}
*cp = '\0';
return (tp->e_name);
@ -708,13 +717,14 @@ init_servarray(void)
endservent();
}
/*XXX from libbpfc.a */
#ifndef WIN32
extern struct eproto {
/* in libpcap.a (nametoaddr.c) */
#if defined(WIN32) && !defined(USE_STATIC_LIBPCAP)
__declspec(dllimport)
#else
__declspec( dllimport) struct eproto {
extern
#endif
char *s;
const struct eproto {
const char *s;
u_short p;
} eproto_db[];
@ -832,9 +842,16 @@ init_etherarray(void)
continue;
#ifdef USE_ETHER_NTOHOST
/* Use yp/nis version of name if available */
if (ether_ntohost(name, (const struct ether_addr *)el->addr) == 0) {
tp->e_name = strdup(name);
/*
* Use YP/NIS version of name if available.
*
* We don't cast it to "const struct ether_addr *"
* because some systems don't modify the Ethernet
* address but fail to declare the second argument
* as a "const" pointer.
*/
if (ether_ntohost(name, (struct ether_addr *)el->addr) == 0) {
tp->e_name = strdup(name);
continue;
}
#endif

View File

@ -18,8 +18,8 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.20 2003/07/01 19:10:26 guy Exp $ (LBL)
*
* @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.24 2004/10/07 16:04:07 hannes Exp $ (LBL)
* $FreeBSD$
*/
@ -35,6 +35,13 @@
* <netinet/if_ether.h> if all it needs are ETHERTYPE_ values.
*/
#ifndef ETHERTYPE_LEN
#define ETHERTYPE_LEN 2
#endif
#ifndef ETHERTYPE_GRE_ISO
#define ETHERTYPE_GRE_ISO 0x00FE /* not really an ethertype only used in GRE */
#endif
#ifndef ETHERTYPE_PUP
#define ETHERTYPE_PUP 0x0200 /* PUP protocol */
#endif
@ -122,6 +129,12 @@
#ifndef ETHERTYPE_PPPOES2
#define ETHERTYPE_PPPOES2 0x3c13
#endif
#ifndef ETHERTYPE_JUMBO
#define ETHERTYPE_JUMBO 0x8870
#endif
#ifndef ETHERTYPE_EAPOL
#define ETHERTYPE_EAPOL 0x888e
#endif
#ifndef ETHERTYPE_LOOPBACK
#define ETHERTYPE_LOOPBACK 0x9000
#endif

View File

@ -18,8 +18,8 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.217.2.5 2004/03/17 19:47:48 guy Exp $ (LBL)
*
* @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.244 2005/04/06 21:33:27 mcr Exp $ (LBL)
* $FreeBSD$
*/
@ -63,30 +63,6 @@ extern char *strdup(const char *);
extern char *strsep(char **, const char *);
#endif
struct tok {
int v; /* value */
const char *s; /* string */
};
extern int aflag; /* translate network and broadcast addresses */
extern int dflag; /* print filter code */
extern int eflag; /* print ethernet header */
extern int fflag; /* don't translate "foreign" IP address */
extern int nflag; /* leave addresses as numbers */
extern int Nflag; /* remove domains from printed host names */
extern int qflag; /* quick (shorter) output */
extern int Rflag; /* print sequence # field in AH/ESP*/
extern int sflag; /* use the libsmi to translate OIDs */
extern int Sflag; /* print raw TCP sequence numbers */
extern int tflag; /* print packet arrival time */
extern int uflag; /* Print undecoded NFS handles */
extern int vflag; /* verbose */
extern int xflag; /* print packet in hex */
extern int Xflag; /* print packet in hex/ascii */
extern int Aflag; /* print packet only in ascii observing TAB, LF, CR and SPACE as graphical chars */
extern char *espsecret;
extern int packettype; /* as specified by -T */
#define PT_VAT 1 /* Visual Audio Tool */
#define PT_WB 2 /* distributed White Board */
#define PT_RPC 3 /* Remote Procedure Call */
@ -134,10 +110,6 @@ extern char *program_name; /* used to generate self-identifying messages */
extern int32_t thiszone; /* seconds offset from gmt to local time */
extern int snaplen;
/* global pointer to end of current packet (during printing) */
extern const u_char *snapend;
/*
* True if "l" bytes of "var" were captured.
*
@ -163,9 +135,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 const char *tok2str(const struct tok *, const char *, int);
extern int mask2plen(u_int32_t);
extern char *bittok2str(const struct tok *, const char *, int);
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)
@ -181,7 +151,7 @@ extern char *copy_argv(char **);
extern void safeputchar(int);
extern void safeputs(const char *);
extern const char *isonsap_string(const u_char *);
extern const char *isonsap_string(const u_char *, register u_int);
extern const char *llcsap_string(u_char);
extern const char *protoid_string(const u_char *);
extern const char *ipxsap_string(u_short);
@ -193,11 +163,11 @@ extern const char *dnnum_string(u_short);
#include <pcap.h>
extern int print_unknown_data(const u_char *, const char *,int);
extern void ascii_print_with_offset(const u_char *, const u_char *, u_int, u_int);
extern void ascii_print(const u_char *, const u_char *, u_int);
extern void hex_print_with_offset(const u_char *, const u_char *, u_int, u_int);
extern void ascii_print_with_offset(const char *, const u_char *, u_int, u_int);
extern void ascii_print(const char *, const u_char *, u_int);
extern void hex_print_with_offset(const char *, const u_char *, u_int, u_int);
extern void telnet_print(const u_char *, u_int);
extern void hex_print(const u_char *, const u_char *, u_int);
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 *);
@ -205,20 +175,19 @@ extern int snap_print(const u_char *, u_int, u_int, u_short *, u_int32_t,
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 arp_print(const u_char *, u_int, u_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 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);
extern void cnfp_print(const u_char *, const u_char *);
extern void decnet_print(const u_char *, u_int, u_int);
extern void default_print(const u_char *, u_int);
extern void default_print_unaligned(const u_char *, u_int);
extern void dvmrp_print(const u_char *, u_int);
extern void egp_print(const u_char *);
extern void egp_print(const u_char *, u_int);
extern u_int enc_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int pflog_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int arcnet_if_print(const struct pcap_pkthdr *, const u_char *);
@ -238,7 +207,6 @@ extern void gre_print(const u_char *, u_int);
extern void icmp_print(const u_char *, u_int, const u_char *, int);
extern void igmp_print(const u_char *, u_int);
extern void igrp_print(const u_char *, u_int, const u_char *);
extern void ip_print(const u_char *, u_int);
extern void ipN_print(const u_char *, u_int);
extern u_int ipfc_if_print(const struct pcap_pkthdr *, const u_char *);
extern void ipx_print(const u_char *, u_int);
@ -257,6 +225,9 @@ extern void pimv1_print(const u_char *, u_int);
extern void cisco_autorp_print(const u_char *, u_int);
extern void rsvp_print(const u_char *, u_int);
extern void ldp_print(const u_char *, u_int);
extern void lmp_print(const u_char *, u_int);
extern void lspping_print(const u_char *, u_int);
extern void eigrp_print(const u_char *, u_int);
extern void mobile_print(const u_char *, u_int);
extern void pim_print(const u_char *, u_int);
extern u_int pppoe_print(const u_char *, u_int);
@ -266,6 +237,7 @@ extern u_int ppp_hdlc_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int ppp_bsdos_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int pppoe_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int prism_if_print(const struct pcap_pkthdr *, const u_char *);
extern void q933_print(const u_char *, u_int);
extern int vjc_print(register const char *, u_short);
extern u_int raw_if_print(const struct pcap_pkthdr *, const u_char *);
extern void rip_print(const u_char *, u_int);
@ -275,17 +247,20 @@ extern u_int lane_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int cip_if_print(const struct pcap_pkthdr *, const u_char *);
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_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 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 *);
extern u_int symantec_if_print(const struct pcap_pkthdr *, 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 timed_print(const u_char *);
extern void udp_print(const u_char *, u_int, const u_char *, int);
extern void wb_print(const void *, u_int);
extern int ah_print(register const u_char *);
extern int esp_print(register const u_char *, register const u_char *, int *, int *);
extern void isakmp_print(const u_char *, u_int, const u_char *);
extern int ipcomp_print(register const u_char *, int *);
extern void rx_print(register const u_char *, int, int, int, u_char *);
extern void netbeui_print(u_short, const u_char *, int);
@ -294,6 +269,7 @@ extern void nbt_tcp_print(const u_char *, int);
extern void nbt_udp137_print(const u_char *, int);
extern void nbt_udp138_print(const u_char *, int);
extern char *smb_errstr(int, int);
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);
@ -308,6 +284,8 @@ extern void mpls_lsp_ping_print(const u_char *, u_int);
extern void zephyr_print(const u_char *, int);
extern void hsrp_print(const u_char *, u_int);
extern void bfd_print(const u_char *, u_int, u_int);
extern void sip_print(const u_char *, u_int);
extern void syslog_print(const u_char *, u_int);
#ifdef INET6
extern void ip6_print(const u_char *, u_int);
@ -329,4 +307,38 @@ extern u_int16_t in_cksum_shouldbe(u_int16_t, u_int16_t);
struct bpf_program;
extern void bpf_dump(struct bpf_program *, int);
#endif
#include "netdissect.h"
/* forward compatibility */
netdissect_options *gndo;
#define eflag gndo->ndo_eflag
#define fflag gndo->ndo_fflag
#define nflag gndo->ndo_nflag
#define Nflag gndo->ndo_Nflag
#define Oflag gndo->ndo_Oflag
#define pflag gndo->ndo_pflag
#define qflag gndo->ndo_qflag
#define Rflag gndo->ndo_Rflag
#define sflag gndo->ndo_sflag
#define Sflag gndo->ndo_Sflag
#define tflag gndo->ndo_tflag
#define Uflag gndo->ndo_Uflag
#define uflag gndo->ndo_uflag
#define vflag gndo->ndo_vflag
#define xflag gndo->ndo_xflag
#define Xflag gndo->ndo_Xflag
#define Cflag gndo->ndo_Cflag
#define Aflag gndo->ndo_Aflag
#define packettype gndo->ndo_packettype
#define tcpmd5secret gndo->ndo_tcpmd5secret
#define Wflag gndo->ndo_Wflag
#define WflagChars gndo->ndo_WflagChars
#define Cflag_count gndo->ndo_Cflag_count
#define snaplen gndo->ndo_snaplen
#define snapend gndo->ndo_snapend

View File

@ -44,7 +44,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.25.2.2 2003/11/16 08:51:07 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.28 2004/03/25 03:30:55 mcr Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -113,7 +113,7 @@ static int is_UCX(const unsigned char *);
void
Parse_fh(fh, len, fsidp, inop, osnamep, fsnamep, ourself)
register const unsigned char *fh;
int len;
int len _U_;
my_fsid *fsidp;
ino_t *inop;
const char **osnamep; /* if non-NULL, return OS name here */

View File

@ -1,4 +1,4 @@
/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.14 2003/05/22 15:29:22 hannes Exp $ (LBL) */
/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.16 2004/10/20 16:14:16 hannes Exp $ (LBL) */
/*
* Point to Point Protocol (PPP) RFC1331
*
@ -24,6 +24,9 @@
#undef PPP_CONTROL
#define PPP_CONTROL 0x03 /* The control byte value */
#define PPP_WITHDIRECTION_IN 0x00 /* non-standard for DLT_PPP_WITHDIRECTION */
#define PPP_WITHDIRECTION_OUT 0x01 /* non-standard for DLT_PPP_WITHDIRECTION */
/* Protocol numbers */
#ifndef PPP_IP
#define PPP_IP 0x0021 /* Raw IP */
@ -40,6 +43,7 @@
#define PPP_BRPDU 0x0031 /* Bridging PDU */
#define PPP_STII 0x0033 /* Stream Protocol (ST-II) */
#define PPP_VINES 0x0035 /* Banyan Vines */
#define PPP_ML 0x003d /* Multi-Link PPP */
#define PPP_IPV6 0x0057 /* IPv6 */
#define PPP_COMP 0x00fd /* Compressed Datagram */
@ -68,7 +72,7 @@
#define PPP_CHAP 0xc223 /* Challenge Handshake Authentication Protocol */
#define PPP_BACP 0xc02b /* Bandwidth Allocation Control Protocol */
#define PPP_BAP 0xc02d /* BAP */
#define PPP_MP 0xc03d /* Multi-Link */
#define PPP_MPCP 0xc03d /* Multi-Link */
#define PPP_SPAP_OLD 0xc123
#define PPP_EAP 0xc227

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.61.2.2 2003/11/16 08:51:10 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.64 2004/04/30 16:42:14 mcr Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -35,7 +35,7 @@ static const char rcsid[] _U_ =
#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "netdissect.h"
#include "addrtoname.h"
#include "ether.h"
#include "ethertype.h"
@ -160,173 +160,184 @@ struct atmarp_pkthdr {
static u_char ezero[6];
static void
atmarp_addr_print(const u_char *ha, u_int ha_len, const u_char *srca,
atmarp_addr_print(netdissect_options *ndo,
const u_char *ha, u_int ha_len, const u_char *srca,
u_int srca_len)
{
if (ha_len == 0)
(void)printf("<No address>");
ND_PRINT((ndo, "<No address>"));
else {
(void)printf("%s", linkaddr_string(ha, ha_len));
if (srca_len != 0)
(void)printf(",%s", linkaddr_string(srca, srca_len));
ND_PRINT((ndo, "%s", linkaddr_string(ha, ha_len)));
if (srca_len != 0)
ND_PRINT((ndo, ",%s",
linkaddr_string(srca, srca_len)));
}
}
static void
atmarp_print(const u_char *bp, u_int length, u_int caplen)
atmarp_print(netdissect_options *ndo,
const u_char *bp, u_int length, u_int caplen)
{
const struct atmarp_pkthdr *ap;
u_short pro, hrd, op;
ap = (const struct atmarp_pkthdr *)bp;
TCHECK(*ap);
ND_TCHECK(*ap);
hrd = ATMHRD(ap);
pro = ATMPRO(ap);
op = ATMOP(ap);
if (!TTEST2(*aar_tpa(ap), ATMTPLN(ap))) {
(void)printf("truncated-atmarp");
default_print((const u_char *)ap, length);
if (!ND_TTEST2(*aar_tpa(ap), ATMTPLN(ap))) {
ND_PRINT((ndo, "truncated-atmarp"));
ND_DEFAULTPRINT((const u_char *)ap, length);
return;
}
if ((pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL) ||
ATMSPLN(ap) != 4 || ATMTPLN(ap) != 4) {
(void)printf("atmarp-#%d for proto #%d (%d/%d) hardware #%d",
op, pro, ATMSPLN(ap), ATMTPLN(ap), hrd);
ND_PRINT((ndo, "atmarp-#%d for proto #%d (%d/%d) hardware #%d",
op, pro, ATMSPLN(ap), ATMTPLN(ap), hrd));
return;
}
if (pro == ETHERTYPE_TRAIL)
(void)printf("trailer-");
ND_PRINT((ndo, "trailer-"));
switch (op) {
case ARPOP_REQUEST:
(void)printf("arp who-has %s", ipaddr_string(ATMTPA(ap)));
ND_PRINT((ndo, "arp who-has %s", ipaddr_string(ATMTPA(ap))));
if (ATMTHLN(ap) != 0) {
(void)printf(" (");
atmarp_addr_print(ATMTHA(ap), ATMTHLN(ap),
ND_PRINT((ndo, " ("));
atmarp_addr_print(ndo, ATMTHA(ap), ATMTHLN(ap),
ATMTSA(ap), ATMTSLN(ap));
(void)printf(")");
ND_PRINT((ndo, ")"));
}
(void)printf(" tell %s", ipaddr_string(ATMSPA(ap)));
ND_PRINT((ndo, " tell %s", ipaddr_string(ATMSPA(ap))));
break;
case ARPOP_REPLY:
(void)printf("arp reply %s", ipaddr_string(ATMSPA(ap)));
(void)printf(" is-at ");
atmarp_addr_print(ATMSHA(ap), ATMSHLN(ap), ATMSSA(ap),
ND_PRINT((ndo, "arp reply %s", ipaddr_string(ATMSPA(ap))));
ND_PRINT((ndo, " is-at "));
atmarp_addr_print(ndo, ATMSHA(ap), ATMSHLN(ap), ATMSSA(ap),
ATMSSLN(ap));
break;
case ARPOP_INVREQUEST:
(void)printf("invarp who-is ");
atmarp_addr_print(ATMTHA(ap), ATMTHLN(ap), ATMTSA(ap),
ND_PRINT((ndo, "invarp who-is "));
atmarp_addr_print(ndo, ATMTHA(ap), ATMTHLN(ap), ATMTSA(ap),
ATMTSLN(ap));
(void)printf(" tell ");
atmarp_addr_print(ATMSHA(ap), ATMSHLN(ap), ATMSSA(ap),
ND_PRINT((ndo, " tell "));
atmarp_addr_print(ndo, ATMSHA(ap), ATMSHLN(ap), ATMSSA(ap),
ATMSSLN(ap));
break;
case ARPOP_INVREPLY:
(void)printf("invarp reply ");
atmarp_addr_print(ATMSHA(ap), ATMSHLN(ap), ATMSSA(ap),
ND_PRINT((ndo, "invarp reply "));
atmarp_addr_print(ndo, ATMSHA(ap), ATMSHLN(ap), ATMSSA(ap),
ATMSSLN(ap));
(void)printf(" at %s", ipaddr_string(ATMSPA(ap)));
ND_PRINT((ndo, " at %s", ipaddr_string(ATMSPA(ap))));
break;
case ATMARPOP_NAK:
(void)printf("nak reply for %s",
ipaddr_string(ATMSPA(ap)));
ND_PRINT((ndo, "nak reply for %s",
ipaddr_string(ATMSPA(ap))));
break;
default:
(void)printf("atmarp-#%d", op);
default_print((const u_char *)ap, caplen);
ND_PRINT((ndo, "atmarp-#%d", op));
ND_DEFAULTPRINT((const u_char *)ap, caplen);
return;
}
return;
trunc:
(void)printf("[|atmarp]");
ND_PRINT((ndo, "[|atmarp]"));
}
void
arp_print(const u_char *bp, u_int length, u_int caplen)
arp_print(netdissect_options *ndo,
const u_char *bp, u_int length, u_int caplen)
{
const struct arp_pkthdr *ap;
u_short pro, hrd, op;
ap = (const struct arp_pkthdr *)bp;
TCHECK(*ap);
ND_TCHECK(*ap);
hrd = HRD(ap);
if (hrd == ARPHRD_ATM2225) {
atmarp_print(bp, length, caplen);
atmarp_print(ndo, bp, length, caplen);
return;
}
pro = PRO(ap);
op = OP(ap);
if (!TTEST2(*ar_tpa(ap), PLN(ap))) {
(void)printf("truncated-arp");
default_print((const u_char *)ap, length);
if (!ND_TTEST2(*ar_tpa(ap), PLN(ap))) {
ND_PRINT((ndo, "truncated-arp"));
ND_DEFAULTPRINT((const u_char *)ap, length);
return;
}
if ((pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL) ||
PLN(ap) != 4 || HLN(ap) == 0) {
(void)printf("arp-#%d for proto #%d (%d) hardware #%d (%d)",
op, pro, PLN(ap), hrd, HLN(ap));
ND_PRINT((ndo, "arp-#%d for proto #%d (%d) hardware #%d (%d)",
op, pro, PLN(ap), hrd, HLN(ap)));
return;
}
if (pro == ETHERTYPE_TRAIL)
(void)printf("trailer-");
ND_PRINT((ndo, "trailer-"));
switch (op) {
case ARPOP_REQUEST:
(void)printf("arp who-has %s", ipaddr_string(TPA(ap)));
ND_PRINT((ndo, "arp who-has %s", ipaddr_string(TPA(ap))));
if (memcmp((const char *)ezero, (const char *)THA(ap), HLN(ap)) != 0)
(void)printf(" (%s)",
linkaddr_string(THA(ap), HLN(ap)));
(void)printf(" tell %s", ipaddr_string(SPA(ap)));
ND_PRINT((ndo, " (%s)",
linkaddr_string(THA(ap), HLN(ap))));
ND_PRINT((ndo, " tell %s", ipaddr_string(SPA(ap))));
break;
case ARPOP_REPLY:
(void)printf("arp reply %s", ipaddr_string(SPA(ap)));
(void)printf(" is-at %s", linkaddr_string(SHA(ap), HLN(ap)));
ND_PRINT((ndo, "arp reply %s", ipaddr_string(SPA(ap))));
ND_PRINT((ndo, " is-at %s", linkaddr_string(SHA(ap), HLN(ap))));
break;
case ARPOP_REVREQUEST:
(void)printf("rarp who-is %s tell %s",
linkaddr_string(THA(ap), HLN(ap)),
linkaddr_string(SHA(ap), HLN(ap)));
ND_PRINT((ndo, "rarp who-is %s tell %s",
linkaddr_string(THA(ap), HLN(ap)),
linkaddr_string(SHA(ap), HLN(ap))));
break;
case ARPOP_REVREPLY:
(void)printf("rarp reply %s at %s",
linkaddr_string(THA(ap), HLN(ap)),
ipaddr_string(TPA(ap)));
ND_PRINT((ndo, "rarp reply %s at %s",
linkaddr_string(THA(ap), HLN(ap)),
ipaddr_string(TPA(ap))));
break;
case ARPOP_INVREQUEST:
(void)printf("invarp who-is %s tell %s",
linkaddr_string(THA(ap), HLN(ap)),
linkaddr_string(SHA(ap), HLN(ap)));
ND_PRINT((ndo, "invarp who-is %s tell %s",
linkaddr_string(THA(ap), HLN(ap)),
linkaddr_string(SHA(ap), HLN(ap))));
break;
case ARPOP_INVREPLY:
(void)printf("invarp reply %s at %s",
linkaddr_string(THA(ap), HLN(ap)),
ipaddr_string(TPA(ap)));
ND_PRINT((ndo,"invarp reply %s at %s",
linkaddr_string(THA(ap), HLN(ap)),
ipaddr_string(TPA(ap))));
break;
default:
(void)printf("arp-#%d", op);
default_print((const u_char *)ap, caplen);
ND_PRINT((ndo, "arp-#%d", op));
ND_DEFAULTPRINT((const u_char *)ap, caplen);
return;
}
if (hrd != ARPHRD_ETHER)
printf(" hardware #%d", hrd);
ND_PRINT((ndo, " hardware #%d", hrd));
return;
trunc:
(void)printf("[|arp]");
ND_PRINT((ndo, "[|arp]"));
}
/*
* Local Variables:
* c-style: bsd
* End:
*/

View File

@ -25,7 +25,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.78.2.2 2003/11/16 08:51:11 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.81 2004/05/01 09:41:50 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -181,6 +181,9 @@ atalk_print(register const u_char *bp, u_int length)
register const struct atDDP *dp;
u_short snet;
if(!eflag)
printf("AT ");
if (length < ddpSize) {
(void)printf(" [|ddp %d]", length);
return;
@ -189,7 +192,7 @@ atalk_print(register const u_char *bp, u_int length)
snet = EXTRACT_16BITS(&dp->srcNet);
printf("%s.%s", ataddr_string(snet, dp->srcNode),
ddpskt_string(dp->srcSkt));
printf(" > %s.%s:",
printf(" > %s.%s: ",
ataddr_string(EXTRACT_16BITS(&dp->dstNet), dp->dstNode),
ddpskt_string(dp->dstSkt));
bp += ddpSize;
@ -250,6 +253,10 @@ ddp_print(register const u_char *bp, register u_int length, register int t,
atp_print((const struct atATP *)bp, length);
break;
case ddpEIGRP:
eigrp_print(bp, length);
break;
default:
(void)printf(" at-%s %d", tok2str(type2str, NULL, t), length);
break;

View File

@ -22,7 +22,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.33.2.2 2003/11/16 08:51:11 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.38 2005/01/19 16:46:27 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -45,6 +45,54 @@ static const char rcsid[] _U_ =
#include "ether.h"
struct tok oam_celltype_values[] = {
{ 0x1, "Fault Management" },
{ 0x2, "Performance Management" },
{ 0x8, "activate/deactivate" },
{ 0xf, "System Management" },
{ 0, NULL }
};
struct tok oam_fm_functype_values[] = {
{ 0x0, "AIS" },
{ 0x1, "RDI" },
{ 0x4, "Continuity Check" },
{ 0x8, "Loopback" },
{ 0, NULL }
};
struct tok oam_pm_functype_values[] = {
{ 0x0, "Forward Monitoring" },
{ 0x1, "Backward Reporting" },
{ 0x2, "Monitoring and Reporting" },
{ 0, NULL }
};
struct tok oam_ad_functype_values[] = {
{ 0x0, "Performance Monitoring" },
{ 0x1, "Continuity Check" },
{ 0, NULL }
};
static const struct tok *oam_functype_values[16] = {
NULL,
oam_fm_functype_values, /* 1 */
oam_pm_functype_values, /* 2 */
NULL,
NULL,
NULL,
NULL,
NULL,
oam_ad_functype_values, /* 8 */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
};
/*
* Print an RFC 1483 LLC-encapsulated ATM frame.
*/
@ -74,7 +122,7 @@ atm_llc_print(const u_char *p, int length, int caplen)
/*
* This is the top level routine of the printer. 'p' points
* to the LLC/SNAP header of the packet, 'h->ts' is the timestamp,
* 'h->length' is the length of the packet off the wire, and 'h->caplen'
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int
@ -208,12 +256,9 @@ atm_print(u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
printf("broadcast sig: ");
return;
case OAMF4SC:
printf("oamF4(segment): ");
return;
case OAMF4SC: /* fall through */
case OAMF4EC:
printf("oamF4(end): ");
oam_print(p, length);
return;
case METAC:
@ -242,3 +287,47 @@ atm_print(u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
break;
}
}
int
oam_print (const u_char *p, u_int length) {
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;
vpi = (cell_header>>20)&0xff;
vci = (cell_header>>4)&0xffff;
payload = (cell_header>>1)&0x7;
clp = cell_header&0x1;
switch (vci) {
case OAMF4SC:
printf("OAM F4 (segment), ");
break;
case OAMF4EC:
printf("OAM F4 (end), ");
break;
default:
printf("OAM F5, ");
break;
}
if (eflag)
printf("vpi %u, vci %u, payload %u, clp %u, ",vpi,vci,payload,clp);
printf("cell-type %s (%u)",
tok2str(oam_celltype_values, "unknown", cell_type),
cell_type);
if (oam_functype_values[cell_type] == NULL)
printf(", func-type unknown (%u)", func_type);
else
printf(", func-type %s (%u)",
bittok2str(oam_functype_values[cell_type],"none",func_type),
func_type);
printf(", length %u",length);
return 1;
}

View File

@ -24,7 +24,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.75.2.3 2004/03/02 07:45:13 hannes Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.78 2004/03/02 07:38:10 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.86.2.3 2004/03/28 20:54:00 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.89 2004/03/23 19:03:03 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H

View File

@ -22,7 +22,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.82.2.3 2003/12/29 22:42:21 hannes Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.95 2005/04/06 21:32:39 mcr Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -39,10 +39,24 @@ static const char rcsid[] _U_ =
#include "ethertype.h"
#include "ether.h"
const u_char *snapend;
#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" },
@ -71,7 +85,11 @@ const struct tok ethertype_values[] = {
{ ETHERTYPE_PPP, "PPP" },
{ ETHERTYPE_PPPOED, "PPPoE D" },
{ ETHERTYPE_PPPOES, "PPPoE S" },
{ ETHERTYPE_EAPOL, "EAPOL" },
{ ETHERTYPE_JUMBO, "Jumbo" },
{ ETHERTYPE_LOOPBACK, "Loopback" },
{ ETHERTYPE_ISO, "OSI" },
{ ETHERTYPE_GRE_ISO, "GRE-OSI" },
{ 0, NULL}
};
@ -153,7 +171,7 @@ ether_print(const u_char *p, u_int length, u_int caplen)
/*
* This is the top level routine of the printer. 'p' points
* to the ether header of the packet, 'h->ts' is the timestamp,
* 'h->length' is the length of the packet off the wire, and 'h->caplen'
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int
@ -186,7 +204,7 @@ ether_encap_print(u_short ether_type, const u_char *p,
switch (ether_type) {
case ETHERTYPE_IP:
ip_print(p, length);
ip_print(gndo, p, length);
return (1);
#ifdef INET6
@ -197,7 +215,7 @@ ether_encap_print(u_short ether_type, const u_char *p,
case ETHERTYPE_ARP:
case ETHERTYPE_REVARP:
arp_print(p, length, caplen);
arp_print(gndo, p, length, caplen);
return (1);
case ETHERTYPE_DN:
@ -250,6 +268,35 @@ ether_encap_print(u_short ether_type, const u_char *p,
return (1);
case ETHERTYPE_JUMBO:
ether_type = ntohs(*(u_int16_t *)(p));
p += 2;
length -= 2;
caplen -= 2;
if (ether_type > ETHERMTU) {
if (eflag)
printf("ethertype %s, ",
tok2str(ethertype_values,"0x%04x", ether_type));
goto recurse;
}
*extracted_ether_type = 0;
if (llc_print(p, length, caplen, p - 16, p - 10,
extracted_ether_type) == 0) {
ether_hdr_print(p - 16, length + 2);
}
if (!xflag && !qflag)
default_print(p - 16, caplen + 2);
return (1);
case ETHERTYPE_ISO:
isoclns_print(p+1, length-1, length-1);
return(1);
case ETHERTYPE_PPPOED:
case ETHERTYPE_PPPOES:
case ETHERTYPE_PPPOED2:
@ -257,6 +304,10 @@ ether_encap_print(u_short ether_type, const u_char *p,
pppoe_print(p, length);
return (1);
case ETHERTYPE_EAPOL:
eap_print(gndo, p, length);
return (1);
case ETHERTYPE_PPP:
if (length) {
printf(": ");
@ -281,3 +332,12 @@ ether_encap_print(u_short ether_type, const u_char *p,
return (0);
}
}
/*
* Local Variables:
* c-style: whitesmith
* c-basic-offset: 8
* End:
*/

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.61.2.2 2003/11/16 08:51:20 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.64 2004/03/17 23:24:37 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -300,7 +300,7 @@ fddi_print(const u_char *p, u_int length, u_int caplen)
/*
* This is the top level routine of the printer. 'p' points
* to the FDDI header of the packet, 'h->ts' is the timestamp,
* 'h->length' is the length of the packet off the wire, and 'h->caplen'
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int

View File

@ -22,103 +22,110 @@
*/
#ifndef lint
static char rcsid[] =
"@(#)$Header: /home/ncvs/src/contrib/tcpdump/print-fr.c,v 1.1 1997/12/31 21:50:31 pst Exp $ (LBL)";
static const char rcsid[] _U_ =
"@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.32 2005/04/06 21:32:39 mcr Exp $ (LBL)";
#endif
#ifdef PPP
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#if __STDC__
struct mbuf;
struct rtentry;
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <net/if.h>
#include <net/if_var.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <tcpdump-stdinc.h>
#include <ctype.h>
#include <netdb.h>
#include <pcap.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <pcap.h>
#include <netinet/if_ether.h>
#include "ethertype.h"
#include <net/ppp_defs.h>
#include "interface.h"
#include "addrtoname.h"
#include "interface.h"
#include "ethertype.h"
#include "nlpid.h"
#include "extract.h"
#include "oui.h"
void q933_print();
#define FR_EA_BIT(p) ((p)&0x1)
#define FR_DLCI(b0,b1) ((((b0)&0xFC)<<2)+(((b1)&0xF0)>>4))
struct fr_nlpids {
u_short id;
char *name;
};
/* find out how many bytes are there in a frame */
int
fr_addr_len(const u_char *p)
{
int i=0;
while (!FR_EA_BIT(p[i]) && i++ && !FR_EA_BIT(p[i+1])) i++;
return (i+1);
}
/* the following is for framerelay */
#define NLPID_LEN 1 /* NLPID is one byte long */
#define NLPID_Q933 0x08
#define NLPID_CLNP 0x81
#define NLPID_ESIS 0x82
#define NLPID_ISIS 0x83
#define NLPID_CONS 0x84
#define NLPID_IDRP 0x85
#define NLPID_X25_ESIS 0x8a
#define NLPID_IP 0xcc
static struct fr_nlpids fr_nlpids[256];
static fr_nlpid_flag =0;
void init_fr_nlpids()
{
int i;
if (!fr_nlpid_flag) {
for (i=0; i < 256; i++) {
fr_nlpids[i].id = 0;
fr_nlpids[i].name = "Not Specified";
}
fr_nlpids[NLPID_Q933].name = "Q.933";
fr_nlpids[NLPID_CLNP].name = "CLNP";
fr_nlpids[NLPID_ESIS].name = "ESIS";
fr_nlpids[NLPID_ISIS].name = "ISIS";
fr_nlpids[NLPID_CONS].name = "CONS";
fr_nlpids[NLPID_IDRP].name = "IDRP";
fr_nlpids[NLPID_X25_ESIS].name = "X25_ESIS";
fr_nlpids[NLPID_IP].name = "IP";
}
fr_nlpid_flag = 1;
}
/* Framerelay packet structure */
static void frf15_print(const u_char *, u_int);
/*
+---------------------------+
| flag (7E hexadecimal) |
* the frame relay header has a variable length
*
* the EA bit determines if there is another byte
* in the header
*
* minimum header length is 2 bytes
* maximum header length is 4 bytes
*
* 7 6 5 4 3 2 1 0
* +----+----+----+----+----+----+----+----+
* | DLCI (6 bits) | CR | EA |
* +----+----+----+----+----+----+----+----+
* | DLCI (4 bits) |FECN|BECN| DE | EA |
* +----+----+----+----+----+----+----+----+
* | DLCI (7 bits) | EA |
* +----+----+----+----+----+----+----+----+
* | DLCI (6 bits) |SDLC| EA |
* +----+----+----+----+----+----+----+----+
*/
#define FR_EA_BIT 0x01
#define FR_CR_BIT 0x02000000
#define FR_DE_BIT 0x00020000
#define FR_BECN_BIT 0x00040000
#define FR_FECN_BIT 0x00080000
#define FR_SDLC_BIT 0x00000002
struct tok fr_header_flag_values[] = {
{ FR_CR_BIT, "C!" },
{ FR_DE_BIT, "DE" },
{ FR_BECN_BIT, "BECN" },
{ FR_FECN_BIT, "FECN" },
{ FR_SDLC_BIT, "sdlcore" },
{ 0, NULL }
};
/* Finds out Q.922 address length, DLCI and flags. Returns 0 on success
* save the flags dep. on address length
*/
static int parse_q922_addr(const u_char *p, u_int *dlci, u_int *sdlcore,
u_int *addr_len, u_int8_t *flags)
{
if ((p[0] & FR_EA_BIT))
return -1;
*addr_len = 2;
*dlci = ((p[0] & 0xFC) << 2) | ((p[1] & 0xF0) >> 4);
flags[0] = p[0] & 0x02; /* populate the first flag fields */
flags[1] = p[1] & 0x0c;
if (p[1] & FR_EA_BIT)
return 0; /* 2-byte Q.922 address */
p += 2;
(*addr_len)++; /* 3- or 4-byte Q.922 address */
if ((p[0] & FR_EA_BIT) == 0) {
*dlci = (*dlci << 7) | (p[0] >> 1);
(*addr_len)++; /* 4-byte Q.922 address */
p++;
}
if ((p[0] & FR_EA_BIT) == 0)
return -1; /* more than 4 bytes of Q.922 address? */
flags[3] = p[0] & 0x02;
if (p[0] & 0x02)
*sdlcore = p[0] >> 2;
else
*dlci = (*dlci << 6) | (p[0] >> 2);
return 0;
}
/* Frame Relay packet structure, with flags and CRC removed
+---------------------------+
| Q.922 Address* |
+-- --+
@ -137,136 +144,221 @@ void init_fr_nlpids()
| . |
| . |
+---------------------------+
| Frame Check Sequence |
+-- . --+
| (two octets) |
+---------------------------+
| flag (7E hexadecimal) |
+---------------------------+
* Q.922 addresses, as presently defined, are two octets and
contain a 10-bit DLCI. In some networks Q.922 addresses
may optionally be increased to three or four octets.
*/
#define FR_PROTOCOL(p) fr_protocol((p))
int
fr_hdrlen(const u_char *p)
static u_int
fr_hdrlen(const u_char *p, u_int addr_len, u_int caplen)
{
int hlen;
hlen = fr_addr_len(p)+1; /* addr_len + 0x03 + padding */
if( p[hlen] )
return hlen;
else
return hlen+1;
}
#define LAYER2_LEN(p) (fr_hdrlen((p))+NLPID_LEN)
int
fr_protocol(const u_char *p)
{
int hlen;
hlen = fr_addr_len(p) + 1;
if (p[hlen]) /* check for padding */
return p[hlen];
if ((caplen > addr_len + 1 /* UI */ + 1 /* pad */) &&
!p[addr_len + 1] /* pad exist */)
return addr_len + 1 /* UI */ + 1 /* pad */ + 1 /* NLPID */;
else
return p[hlen+1];
return addr_len + 1 /* UI */ + 1 /* NLPID */;
}
void
fr_hdlc_print(const u_char *p, int length)
static void
fr_hdr_print(int length, u_int addr_len, u_int dlci, u_int8_t *flags, u_int16_t nlpid)
{
int proto;
int i;
int hlen;
proto = FR_PROTOCOL(p);
init_fr_nlpids();
/* this is kinda kludge since it assumed that DLCI is two bytes. */
printf("%4d %02x%02x=DLCI(%d) ", length, p[0], p[1], FR_DLCI(p[0],p[1]));
printf("%02x %6s: ", proto, fr_nlpids[proto].name);
if (qflag) {
(void)printf("Q.922, DLCI %u, length %u: ",
dlci,
length);
} else {
if (nlpid <= 0xff) /* if its smaller than 256 then its a NLPID */
(void)printf("Q.922, hdr-len %u, DLCI %u, Flags [%s], NLPID %s (0x%02x), length %u: ",
addr_len,
dlci,
bittok2str(fr_header_flag_values, "none", EXTRACT_32BITS(flags)),
tok2str(nlpid_values,"unknown", nlpid),
nlpid,
length);
else /* must be an ethertype */
(void)printf("Q.922, hdr-len %u, DLCI %u, Flags [%s], cisco-ethertype %s (0x%04x), length %u: ",
addr_len,
dlci,
bittok2str(fr_header_flag_values, "none", EXTRACT_32BITS(flags)),
tok2str(ethertype_values, "unknown", nlpid),
nlpid,
length);
}
}
void
fr_if_print(u_char *user, const struct pcap_pkthdr *h,
register const u_char *p)
u_int
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;
int frame_relay = 0,
proto = FR_PROTOCOL(p);
u_int16_t extracted_ethertype;
u_int32_t orgcode;
register u_short et;
u_int dlci;
u_int sdlcore;
u_int addr_len;
u_int16_t nlpid;
u_int hdr_len;
u_int8_t flags[4];
ts_print(&h->ts);
if (caplen < fr_hdrlen(p)) {
if (caplen < 4) { /* minimum frame header length */
printf("[|fr]");
goto out;
return caplen;
}
/*
* Some printers want to get back at the link level addresses,
* and/or check that they're not walking off the end of the packet.
* Rather than pass them all the way down, we set these globals.
*/
packetp = p;
snapend = p + caplen;
if (parse_q922_addr(p, &dlci, &sdlcore, &addr_len, flags)) {
printf("Q.922, invalid address");
return caplen;
}
hdr_len = fr_hdrlen(p, addr_len, caplen);
if (caplen < hdr_len) {
printf("[|fr]");
return caplen;
}
if (p[addr_len] != 0x03 && dlci != 0) {
/* lets figure out if we have cisco style encapsulation: */
extracted_ethertype = EXTRACT_16BITS(p+addr_len);
if (eflag)
fr_hdr_print(length, addr_len, dlci, flags, extracted_ethertype);
if (ether_encap_print(extracted_ethertype,
p+addr_len+ETHERTYPE_LEN,
length-addr_len-ETHERTYPE_LEN,
caplen-addr_len-ETHERTYPE_LEN,
&extracted_ethertype) == 0)
/* ether_type not known, probably it wasn't one */
printf("UI %02x! ", p[addr_len]);
else
return hdr_len;
}
if (!p[addr_len + 1]) { /* pad byte should be used with 3-byte Q.922 */
if (addr_len != 3)
printf("Pad! ");
} else if (addr_len == 3)
printf("No pad! ");
nlpid = p[hdr_len - 1];
if (eflag)
fr_hdlc_print(p, length);
fr_hdr_print(length, addr_len, dlci, flags, nlpid);
length = length - (fr_hdrlen(p) + NLPID_LEN);
p += hdr_len;
length -= hdr_len;
caplen -= hdr_len;
switch(FR_PROTOCOL(p)) {
switch (nlpid) {
case NLPID_IP:
case ETHERTYPE_IP:
ip_print((const u_char *)(p + LAYER2_LEN(p)), length);
ip_print(gndo, p, length);
break;
#ifdef INET6
case NLPID_IP6:
ip6_print(p, length);
break;
#endif
case NLPID_CLNP:
case NLPID_ESIS:
case NLPID_ISIS:
isoclns_print((const u_char *)(p + LAYER2_LEN(p)), length,
caplen, "000000", "000000");
isoclns_print(p-1, length+1, caplen+1); /* OSI printers need the NLPID field */
break;
case NLPID_Q933:
q933_print((const u_char *)(p + LAYER2_LEN(p)), length);
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) {
/* 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);
}
break;
case NLPID_Q933:
q933_print(p, length);
break;
case NLPID_MFR:
frf15_print(p, length);
break;
default:
if(!eflag)
fr_hdlc_print(p, length);
if(!xflag)
default_print((const u_char *)(p + LAYER2_LEN(p)),
caplen - LAYER2_LEN(p));
if (!eflag)
fr_hdr_print(length + hdr_len, addr_len,
dlci, flags, nlpid);
if (!xflag)
default_print(p, caplen);
}
if (xflag)
default_print((const u_char *)(p + LAYER2_LEN(p)),
caplen - LAYER2_LEN(p));
out:
putchar('\n');
return hdr_len;
}
#else
#include <sys/types.h>
#include <sys/time.h>
#include <stdio.h>
/* an NLPID of 0xb1 indicates a 2-byte
* FRF.15 header
*
* 7 6 5 4 3 2 1 0
* +----+----+----+----+----+----+----+----+
* ~ Q.922 header ~
* +----+----+----+----+----+----+----+----+
* | NLPID (8 bits) | NLPID=0xb1
* +----+----+----+----+----+----+----+----+
* | B | E | C |seq. (high 4 bits) | R |
* +----+----+----+----+----+----+----+----+
* | sequence (low 8 bits) |
* +----+----+----+----+----+----+----+----+
*/
struct tok frf15_flag_values[] = {
{ 0x80, "Begin" },
{ 0x40, "End" },
{ 0x20, "Control" },
{ 0, NULL }
};
#define FR_FRF15_FRAGTYPE 0x01
static void
frf15_print (const u_char *p, u_int length) {
u_int16_t sequence_num, flags;
flags = p[0]&0xe0;
sequence_num = (p[0]&0x1e)<<7 | p[1];
printf("FRF.15, seq 0x%03x, Flags [%s],%s Fragmentation, length %u",
sequence_num,
bittok2str(frf15_flag_values,"none",flags),
flags&FR_FRF15_FRAGTYPE ? "Interface" : "End-to-End",
length);
/* TODO:
* depending on all permutations of the B, E and C bit
* dig as deep as we can - e.g. on the first (B) fragment
* there is enough payload to print the IP header
* on non (B) fragments it depends if the fragmentation
* model is end-to-end or interface based wether we want to print
* another Q.922 header
*/
#include "interface.h"
u_int
fr_if_print(const struct pcap_pkthdr *h, const u_char *p)
{
error("not configured for ppp");
/* NOTREACHED */
}
#endif
/*
* Q.933 decoding portion for framerelay specific.
@ -315,112 +407,205 @@ fr_if_print(const struct pcap_pkthdr *h, const u_char *p)
#define MSG_TYPE_STATUS 0x7D
#define MSG_TYPE_STATUS_ENQ 0x75
#define ONE_BYTE_IE_MASK 0xF0
/* See L2 protocol ID picture above */
struct q933_header {
u_char call_ref; /* usually is 0 for framerelay PVC */
u_char msg_type;
struct tok fr_q933_msg_values[] = {
{ MSG_TYPE_ESC_TO_NATIONAL, "ESC to National" },
{ MSG_TYPE_ALERT, "Alert" },
{ MSG_TYPE_CALL_PROCEEDING, "Call proceeding" },
{ MSG_TYPE_CONNECT, "Connect" },
{ MSG_TYPE_CONNECT_ACK, "Connect ACK" },
{ MSG_TYPE_PROGRESS, "Progress" },
{ MSG_TYPE_SETUP, "Setup" },
{ MSG_TYPE_DISCONNECT, "Disconnect" },
{ MSG_TYPE_RELEASE, "Release" },
{ MSG_TYPE_RELEASE_COMPLETE, "Release Complete" },
{ MSG_TYPE_RESTART, "Restart" },
{ MSG_TYPE_RESTART_ACK, "Restart ACK" },
{ MSG_TYPE_STATUS, "Status Reply" },
{ MSG_TYPE_STATUS_ENQ, "Status Enquiry" },
{ 0, NULL }
};
#define REPORT_TYPE_IE 0x01
#define LINK_VERIFY_IE_91 0x19
#define LINK_VERIFY_IE_94 0x03
#define PVC_STATUS_IE 0x07
#define MSG_ANSI_LOCKING_SHIFT 0x95
#define FR_LMI_ANSI_REPORT_TYPE_IE 0x01
#define FR_LMI_ANSI_LINK_VERIFY_IE_91 0x19 /* details? */
#define FR_LMI_ANSI_LINK_VERIFY_IE 0x03
#define FR_LMI_ANSI_PVC_STATUS_IE 0x07
#define FR_LMI_CCITT_REPORT_TYPE_IE 0x51
#define FR_LMI_CCITT_LINK_VERIFY_IE 0x53
#define FR_LMI_CCITT_PVC_STATUS_IE 0x57
struct tok fr_q933_ie_values_codeset5[] = {
{ FR_LMI_ANSI_REPORT_TYPE_IE, "ANSI Report Type" },
{ FR_LMI_ANSI_LINK_VERIFY_IE_91, "ANSI Link Verify" },
{ FR_LMI_ANSI_LINK_VERIFY_IE, "ANSI Link Verify" },
{ FR_LMI_ANSI_PVC_STATUS_IE, "ANSI PVC Status" },
{ FR_LMI_CCITT_REPORT_TYPE_IE, "CCITT Report Type" },
{ FR_LMI_CCITT_LINK_VERIFY_IE, "CCITT Link Verify" },
{ FR_LMI_CCITT_PVC_STATUS_IE, "CCITT PVC Status" },
{ 0, NULL }
};
#define FR_LMI_REPORT_TYPE_IE_FULL_STATUS 0
#define FR_LMI_REPORT_TYPE_IE_LINK_VERIFY 1
#define FR_LMI_REPORT_TYPE_IE_ASYNC_PVC 2
struct tok fr_lmi_report_type_ie_values[] = {
{ FR_LMI_REPORT_TYPE_IE_FULL_STATUS, "Full Status" },
{ FR_LMI_REPORT_TYPE_IE_LINK_VERIFY, "Link verify" },
{ FR_LMI_REPORT_TYPE_IE_ASYNC_PVC, "Async PVC Status" },
{ 0, NULL }
};
/* array of 16 codepages - currently we only support codepage 5 */
static struct tok *fr_q933_ie_codesets[] = {
NULL,
NULL,
NULL,
NULL,
NULL,
fr_q933_ie_values_codeset5,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
};
#define MAX_IE_SIZE
struct common_ie_header {
u_char ie_id;
u_char ie_len;
u_int8_t ie_id;
u_int8_t ie_len;
};
#define FULL_STATUS 0
#define LINK_VERIFY 1
#define ASYNC_PVC 2
void
q933_print(const u_char *p, int length)
q933_print(const u_char *p, u_int length)
{
struct q933_header *header = (struct q933_header *)(p+1);
const u_char *ptemp = p;
int ie_type, ie_len;
char *decode_str, temp_str[255];
struct common_ie_header *ie_p;
int olen;
int is_ansi = 0;
u_int dlci,codeset;
if (length < 9) { /* shortest: Q.933a LINK VERIFY */
printf("[|q.933]");
return;
}
codeset = p[2]&0x0f; /* extract the codeset */
if (p[2] == MSG_ANSI_LOCKING_SHIFT)
is_ansi = 1;
printf("%s", eflag ? "" : "Q.933, ");
/* printing out header part */
printf("Call Ref: %02x, MSG Type: %02x",
header->call_ref, header->msg_type);
switch(header->msg_type) {
case MSG_TYPE_STATUS:
decode_str = "STATUS REPLY";
break;
case MSG_TYPE_STATUS_ENQ:
decode_str = "STATUS ENQUIRY";
break;
default:
decode_str = "UNKNOWN MSG Type";
}
printf(" %s\n", decode_str);
printf(is_ansi ? "ANSI" : "CCITT ");
length = length - 3;
ptemp = ptemp + 3;
if (p[0])
printf(", Call Ref: 0x%02x", p[0]);
if (vflag)
printf(", %s (0x%02x), length %u",
tok2str(fr_q933_msg_values,"unknown message",p[1]),
p[1],
length);
else
printf(", %s",
tok2str(fr_q933_msg_values,"unknown message 0x%02x",p[1]));
olen = length; /* preserve the original length for non verbose mode */
if (length < (u_int)(2 - is_ansi)) {
printf("[|q.933]");
return;
}
length -= 2 - is_ansi;
ptemp += 2 + is_ansi;
/* Loop through the rest of IE */
while( length > 0 ) {
if( ptemp[0] & ONE_BYTE_IE_MASK ) {
ie_len = 1;
printf("\t\tOne byte IE: %02x, Content %02x\n",
(*ptemp & 0x70)>>4, (*ptemp & 0x0F));
length--;
ptemp++;
}
else { /* Multi-byte IE */
while (length > sizeof(struct common_ie_header)) {
ie_p = (struct common_ie_header *)ptemp;
switch (ie_p->ie_id) {
case REPORT_TYPE_IE:
switch(ptemp[2]) {
case FULL_STATUS:
decode_str = "FULL STATUS";
break;
case LINK_VERIFY:
decode_str = "LINK VERIFY";
break;
case ASYNC_PVC:
decode_str = "Async PVC Status";
break;
default:
decode_str = "Reserved Value";
}
break;
case LINK_VERIFY_IE_91:
case LINK_VERIFY_IE_94:
snprintf(temp_str, sizeof(temp_str), "TX Seq: %3d, RX Seq: %3d",
ptemp[2], ptemp[3]);
decode_str = temp_str;
break;
case PVC_STATUS_IE:
snprintf(temp_str,sizeof(temp_str), "DLCI %d: status %s %s",
((ptemp[2]&0x3f)<<4)+ ((ptemp[3]&0x78)>>3),
ptemp[4] & 0x8 ?"new,":" ",
ptemp[4] & 0x2 ?"Active":"Inactive");
break;
default:
decode_str = "Non-decoded Value";
if (length < sizeof(struct common_ie_header) ||
length < sizeof(struct common_ie_header) + ie_p->ie_len) {
if (vflag) /* not bark if there is just a trailer */
printf("\n[|q.933]");
else
printf(", length %u",olen);
return;
}
printf("\t\tIE: %02X Len: %d, %s\n",
ie_p->ie_id, ie_p->ie_len, decode_str);
/* lets do the full IE parsing only in verbose mode
* however some IEs (DLCI Status, Link Verify)
* are also intereststing in non-verbose mode */
if (vflag)
printf("\n\t%s IE (%u), length %u: ",
tok2str(fr_q933_ie_codesets[codeset],"unknown",ie_p->ie_id),
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 (vflag <= 1)
print_unknown_data(ptemp+2,"\n\t",ie_p->ie_len);
break;
}
/* do we want to see a hexdump of the IE ? */
if (vflag> 1)
print_unknown_data(ptemp+2,"\n\t ",ie_p->ie_len);
length = length - ie_p->ie_len - 2;
ptemp = ptemp + ie_p->ie_len + 2;
}
}
if (!vflag)
printf(", length %u",olen);
}

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.73.2.3 2004/03/24 00:56:34 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.81 2005/04/06 21:32:40 mcr Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -42,6 +42,7 @@ static const char rcsid[] _U_ =
#include "ip.h"
#include "udp.h"
#include "ipproto.h"
#include "mpls.h"
/*
* Interface Control Message Protocol Definitions.
@ -87,6 +88,12 @@ struct icmp {
struct ip idi_ip;
/* options and then 64 bits of data */
} id_ip;
struct mpls_ext {
u_int8_t legacy_header[128]; /* extension header starts 128 bytes after ICMP header */
u_int8_t version_res[2];
u_int8_t checksum[2];
u_int8_t data[1];
} mpls_ext;
u_int32_t id_mask;
u_int8_t id_data[1];
} icmp_dun;
@ -96,8 +103,14 @@ struct icmp {
#define icmp_ip icmp_dun.id_ip.idi_ip
#define icmp_mask icmp_dun.id_mask
#define icmp_data icmp_dun.id_data
#define icmp_mpls_ext_version icmp_dun.mpls_ext.version_res
#define icmp_mpls_ext_checksum icmp_dun.mpls_ext.checksum
#define icmp_mpls_ext_data icmp_dun.mpls_ext.data
};
#define ICMP_MPLS_EXT_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
#define ICMP_MPLS_EXT_VERSION 2
/*
* Lower bounds on packet lengths for various types.
* For the error advice packets must first insure that the
@ -107,6 +120,7 @@ struct icmp {
* ip header length.
*/
#define ICMP_MINLEN 8 /* abs minimum */
#define ICMP_EXTD_MINLEN (156 - sizeof (struct ip)) /* draft-bonica-icmp-mpls-02 */
#define ICMP_TSLEN (8 + 3 * sizeof (u_int32_t)) /* timestamp */
#define ICMP_MASKLEN 12 /* address mask */
#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
@ -160,6 +174,8 @@ struct icmp {
(type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
(type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
(type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
#define ICMP_MPLS_EXT_TYPE(type) \
((type) == ICMP_UNREACH || (type) == ICMP_TIMXCEED)
/* rfc1700 */
#ifndef ICMP_UNREACH_NET_UNKNOWN
#define ICMP_UNREACH_NET_UNKNOWN 6 /* destination net unknown */
@ -262,6 +278,19 @@ struct id_rdiscovery {
u_int32_t ird_pref;
};
/* draft-bonica-icmp-mpls-02 */
struct icmp_mpls_ext_object_header_t {
u_int8_t length[2];
u_int8_t class_num;
u_int8_t ctype;
};
static const struct tok icmp_mpls_ext_obj_values[] = {
{ 1, "MPLS Stack Entry" },
{ 2, "Extended Payload" },
{ 0, NULL}
};
void
icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
{
@ -271,7 +300,10 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
const char *str, *fmt;
const struct ip *oip;
const struct udphdr *ouh;
u_int hlen, dport, mtu;
const u_int8_t *obj_tptr;
u_int32_t raw_label;
const struct icmp_mpls_ext_object_header_t *icmp_mpls_ext_object_header;
u_int hlen, dport, mtu, obj_tlen, obj_class_num, obj_ctype;
char buf[MAXHOSTNAMELEN + 100];
dp = (struct icmp *)bp;
@ -479,7 +511,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
str = tok2str(icmp2str, "type-#%d", dp->icmp_type);
break;
}
(void)printf("icmp %d: %s", plen, str);
(void)printf("ICMP %s, length %u", str, plen);
if (vflag && !fragmented) { /* don't attempt checksumming if this is a frag */
u_int16_t sum, icmp_sum;
if (TTEST2(*bp, plen)) {
@ -492,13 +524,88 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
}
}
}
if (vflag > 1 && !ICMP_INFOTYPE(dp->icmp_type)) {
if (vflag >= 1 && !ICMP_INFOTYPE(dp->icmp_type)) {
bp += 8;
(void)printf(" for ");
(void)printf("\n\t");
ip = (struct ip *)bp;
snaplen = snapend - bp;
ip_print(bp, EXTRACT_16BITS(&ip->ip_len));
ip_print(gndo, bp, EXTRACT_16BITS(&ip->ip_len));
}
if (vflag >= 1 && plen > ICMP_EXTD_MINLEN && ICMP_MPLS_EXT_TYPE(dp->icmp_type)) {
TCHECK(*(dp->icmp_mpls_ext_version));
printf("\n\tMPLS extension v%u",ICMP_MPLS_EXT_EXTRACT_VERSION(*(dp->icmp_mpls_ext_version)));
/*
* Sanity checking of the header.
*/
if (ICMP_MPLS_EXT_EXTRACT_VERSION(*(dp->icmp_mpls_ext_version)) != ICMP_MPLS_EXT_VERSION) {
printf(" packet not supported");
return;
}
hlen = plen - ICMP_EXTD_MINLEN;
TCHECK2(*(dp->icmp_mpls_ext_checksum), 2);
printf(", checksum 0x%04x (unverified), length %u", /* FIXME */
EXTRACT_16BITS(dp->icmp_mpls_ext_checksum),
hlen);
hlen -= 4; /* subtract common header size */
obj_tptr = (u_int8_t *)dp->icmp_mpls_ext_data;
while (hlen > sizeof(struct icmp_mpls_ext_object_header_t)) {
icmp_mpls_ext_object_header = (struct icmp_mpls_ext_object_header_t *)obj_tptr;
TCHECK(*icmp_mpls_ext_object_header);
obj_tlen = EXTRACT_16BITS(icmp_mpls_ext_object_header->length);
obj_class_num = icmp_mpls_ext_object_header->class_num;
obj_ctype = icmp_mpls_ext_object_header->ctype;
obj_tptr += sizeof(struct icmp_mpls_ext_object_header_t);
printf("\n\t %s Object (%u), Class-Type: %u, length %u",
tok2str(icmp_mpls_ext_obj_values,"unknown",obj_class_num),
obj_class_num,
obj_ctype,
obj_tlen);
hlen-=sizeof(struct icmp_mpls_ext_object_header_t); /* length field includes tlv header */
if (obj_tlen < sizeof(struct icmp_mpls_ext_object_header_t))
break;
obj_tlen-=sizeof(struct icmp_mpls_ext_object_header_t);
switch (obj_class_num) {
case 1:
switch(obj_ctype) {
case 1:
TCHECK2(*obj_tptr, 4);
raw_label = EXTRACT_32BITS(obj_tptr);
printf("\n\t label %u, exp %u", MPLS_LABEL(raw_label), MPLS_EXP(raw_label));
if (MPLS_STACK(raw_label))
printf(", [S]");
printf(", ttl %u", MPLS_TTL(raw_label));
break;
default:
print_unknown_data(obj_tptr, "\n\t ", obj_tlen);
}
break;
/*
* FIXME those are the defined objects that lack a decoder
* you are welcome to contribute code ;-)
*/
case 2:
default:
print_unknown_data(obj_tptr, "\n\t ", obj_tlen);
break;
}
if (hlen < obj_tlen)
break;
hlen -= obj_tlen;
obj_tptr += obj_tlen;
}
}
return;
trunc:
fputs("[|icmp]", stdout);

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.128.2.6 2004/03/24 09:01:39 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.149 2005/04/07 00:28:17 mcr Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -43,11 +43,23 @@ static const char rcsid[] _U_ =
#include "ip.h"
#include "ipproto.h"
struct tok ip_option_values[] = {
{ IPOPT_EOL, "EOL" },
{ IPOPT_NOP, "NOP" },
{ IPOPT_TS, "timestamp" },
{ IPOPT_SECURITY, "security" },
{ IPOPT_RR, "RR" },
{ IPOPT_SSRR, "SSRR" },
{ IPOPT_LSRR, "LSRR" },
{ IPOPT_RA, "RA" },
{ 0, NULL }
};
/*
* print the recorded route in an IP RR, LSRR or SSRR option.
*/
static void
ip_printroute(const char *type, register const u_char *cp, u_int length)
ip_printroute(register const u_char *cp, u_int length)
{
register u_int ptr;
register u_int len;
@ -56,25 +68,21 @@ ip_printroute(const char *type, register const u_char *cp, u_int length)
printf(" [bad length %u]", length);
return;
}
printf(" %s{", type);
if ((length + 1) & 3)
printf(" [bad length %u]", length);
ptr = cp[2] - 1;
if (ptr < 3 || ((ptr + 1) & 3) || ptr > length + 1)
printf(" [bad ptr %u]", cp[2]);
type = "";
for (len = 3; len < length; len += 4) {
if (ptr == len)
type = "#";
printf("%s%s", type, ipaddr_string(&cp[len]));
type = " ";
printf("%s", ipaddr_string(&cp[len]));
if (ptr > len)
printf (", ");
}
printf("%s}", ptr == len? "#" : "");
}
/*
* If source-routing is present, return the final destination.
* If source-routing is present and valid, return the final destination.
* Otherwise, return IP destination.
*
* This is used for UDP and TCP pseudo-header in the checksum
@ -96,14 +104,15 @@ ip_finddst(const struct ip *ip)
TCHECK(*cp);
tt = *cp;
if (tt == IPOPT_NOP || tt == IPOPT_EOL)
if (tt == IPOPT_EOL)
break;
else if (tt == IPOPT_NOP)
len = 1;
else {
TCHECK(cp[1]);
len = cp[1];
}
if (len < 2) {
return 0;
if (len < 2)
break;
}
TCHECK2(*cp, len);
switch (tt) {
@ -111,15 +120,14 @@ ip_finddst(const struct ip *ip)
case IPOPT_SSRR:
case IPOPT_LSRR:
if (len < 7)
return 0;
break;
memcpy(&retval, cp + len - 4, 4);
return retval;
}
}
return ip->ip_dst.s_addr;
trunc:
return 0;
memcpy(&retval, &ip->ip_dst.s_addr, sizeof(u_int32_t));
return retval;
}
static void
@ -190,75 +198,56 @@ ip_printts(register const u_char *cp, u_int length)
static void
ip_optprint(register const u_char *cp, u_int length)
{
register u_int len;
register u_int option_len;
for (; length > 0; cp += len, length -= len) {
int tt;
for (; length > 0; cp += option_len, length -= option_len) {
u_int option_code;
TCHECK(*cp);
tt = *cp;
if (tt == IPOPT_NOP || tt == IPOPT_EOL)
len = 1;
option_code = *cp;
if (option_code == IPOPT_NOP ||
option_code == IPOPT_EOL)
option_len = 1;
else {
TCHECK(cp[1]);
len = cp[1];
if (len < 2) {
printf("[|ip op len %d]", len);
return;
}
TCHECK2(*cp, len);
option_len = cp[1];
}
switch (tt) {
printf("%s (%u) len %u",
tok2str(ip_option_values,"unknown",option_code),
option_code,
option_len);
if (option_len < 2)
return;
TCHECK2(*cp, option_len);
switch (option_code) {
case IPOPT_EOL:
printf(" EOL");
if (length > 1)
printf("-%d", length - 1);
return;
case IPOPT_NOP:
printf(" NOP");
break;
case IPOPT_TS:
ip_printts(cp, len);
break;
#ifndef IPOPT_SECURITY
#define IPOPT_SECURITY 130
#endif /* IPOPT_SECURITY */
case IPOPT_SECURITY:
printf(" SECURITY{%d}", len);
break;
case IPOPT_RR:
ip_printroute("RR", cp, len);
ip_printts(cp, option_len);
break;
case IPOPT_RR: /* fall through */
case IPOPT_SSRR:
ip_printroute("SSRR", cp, len);
break;
case IPOPT_LSRR:
ip_printroute("LSRR", cp, len);
ip_printroute( cp, option_len);
break;
#ifndef IPOPT_RA
#define IPOPT_RA 148 /* router alert */
#endif
case IPOPT_RA:
printf(" RA");
if (len != 4)
printf("{%d}", len);
else {
TCHECK(cp[3]);
if (cp[2] || cp[3])
printf("%d.%d", cp[2], cp[3]);
}
TCHECK(cp[3]);
if (EXTRACT_16BITS(&cp[2]) != 0)
printf("value %u", EXTRACT_16BITS(&cp[2]));
break;
case IPOPT_NOP: /* nothing to print - fall through */
case IPOPT_SECURITY:
default:
printf(" IPOPT-%d{%d}", cp[0], len);
break;
}
}
@ -369,70 +358,255 @@ static struct tok ip_frag_values[] = {
{ 0, NULL }
};
struct ip_print_demux_state {
const struct ip *ip;
const u_char *cp;
u_int len, off;
u_char nh;
int advance;
};
static void
ip_print_demux(netdissect_options *ndo,
struct ip_print_demux_state *ipds)
{
struct protoent *proto;
again:
switch (ipds->nh) {
case IPPROTO_AH:
ipds->nh = *ipds->cp;
ipds->advance = ah_print(ipds->cp);
if (ipds->advance <= 0)
break;
ipds->cp += ipds->advance;
ipds->len -= ipds->advance;
goto again;
case IPPROTO_ESP:
{
int enh, padlen;
ipds->advance = esp_print(ndo, ipds->cp, ipds->len,
(const u_char *)ipds->ip,
&enh, &padlen);
if (ipds->advance <= 0)
break;
ipds->cp += ipds->advance;
ipds->len -= ipds->advance + padlen;
ipds->nh = enh & 0xff;
goto again;
}
case IPPROTO_IPCOMP:
{
int enh;
ipds->advance = ipcomp_print(ipds->cp, &enh);
if (ipds->advance <= 0)
break;
ipds->cp += ipds->advance;
ipds->len -= ipds->advance;
ipds->nh = enh & 0xff;
goto again;
}
case IPPROTO_SCTP:
sctp_print(ipds->cp, (const u_char *)ipds->ip, ipds->len);
break;
case IPPROTO_TCP:
tcp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip,
(ipds->off &~ 0x6000));
break;
case IPPROTO_UDP:
udp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip,
(ipds->off &~ 0x6000));
break;
case IPPROTO_ICMP:
/* pass on the MF bit plus the offset to detect fragments */
icmp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip,
(ipds->off & 0x3fff));
break;
case IPPROTO_PIGP:
/*
* XXX - the current IANA protocol number assignments
* page lists 9 as "any private interior gateway
* (used by Cisco for their IGRP)" and 88 as
* "EIGRP" from Cisco.
*
* Recent BSD <netinet/in.h> headers define
* IP_PROTO_PIGP as 9 and IP_PROTO_IGRP as 88.
* We define IP_PROTO_PIGP as 9 and
* IP_PROTO_EIGRP as 88; those names better
* match was the current protocol number
* assignments say.
*/
igrp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
break;
case IPPROTO_EIGRP:
eigrp_print(ipds->cp, ipds->len);
break;
case IPPROTO_ND:
ND_PRINT((ndo, " nd %d", ipds->len));
break;
case IPPROTO_EGP:
egp_print(ipds->cp, ipds->len);
break;
case IPPROTO_OSPF:
ospf_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
break;
case IPPROTO_IGMP:
igmp_print(ipds->cp, ipds->len);
break;
case IPPROTO_IPV4:
/* DVMRP multicast tunnel (ip-in-ip encapsulation) */
ip_print(gndo, ipds->cp, ipds->len);
if (! vflag) {
ND_PRINT((ndo, " (ipip-proto-4)"));
return;
}
break;
#ifdef INET6
case IPPROTO_IPV6:
/* ip6-in-ip encapsulation */
ip6_print(ipds->cp, ipds->len);
break;
#endif /*INET6*/
case IPPROTO_RSVP:
rsvp_print(ipds->cp, ipds->len);
break;
case IPPROTO_GRE:
/* do it */
gre_print(ipds->cp, ipds->len);
break;
case IPPROTO_MOBILE:
mobile_print(ipds->cp, ipds->len);
break;
case IPPROTO_PIM:
pim_print(ipds->cp, ipds->len);
break;
case IPPROTO_VRRP:
vrrp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
break;
default:
if ((proto = getprotobynumber(ipds->nh)) != NULL)
ND_PRINT((ndo, " %s", proto->p_name));
else
ND_PRINT((ndo, " ip-proto-%d", ipds->nh));
ND_PRINT((ndo, " %d", ipds->len));
break;
}
}
void
ip_print_inner(netdissect_options *ndo,
const u_char *bp,
u_int length, u_int nh,
const u_char *bp2)
{
struct ip_print_demux_state ipd;
ipd.ip = (const struct ip *)bp2;
ipd.cp = bp;
ipd.len = length;
ipd.off = 0;
ipd.nh = nh;
ipd.advance = 0;
ip_print_demux(ndo, &ipd);
}
/*
* print an IP datagram.
*/
void
ip_print(register const u_char *bp, register u_int length)
ip_print(netdissect_options *ndo,
const u_char *bp,
u_int length)
{
register const struct ip *ip;
register u_int hlen, len, len0, off;
struct ip_print_demux_state ipd;
struct ip_print_demux_state *ipds=&ipd;
const u_char *ipend;
register const u_char *cp;
u_char nh;
int advance;
struct protoent *proto;
u_int hlen;
u_int16_t sum, ip_sum;
struct protoent *proto;
ip = (const struct ip *)bp;
if (IP_V(ip) != 4) { /* print version if != 4 */
printf("IP%u ", IP_V(ip));
if (IP_V(ip) == 6)
ipds->ip = (const struct ip *)bp;
if (IP_V(ipds->ip) != 4) { /* print version if != 4 */
printf("IP%u ", IP_V(ipds->ip));
if (IP_V(ipds->ip) == 6)
printf(", wrong link-layer encapsulation");
}
else
else if (!eflag)
printf("IP ");
if ((u_char *)(ip + 1) > snapend) {
if ((u_char *)(ipds->ip + 1) > snapend) {
printf("[|ip]");
return;
}
if (length < sizeof (struct ip)) {
(void)printf("truncated-ip %d", length);
(void)printf("truncated-ip %u", length);
return;
}
hlen = IP_HL(ip) * 4;
hlen = IP_HL(ipds->ip) * 4;
if (hlen < sizeof (struct ip)) {
(void)printf("bad-hlen %u", hlen);
return;
}
len = EXTRACT_16BITS(&ip->ip_len);
if (length < len)
ipds->len = EXTRACT_16BITS(&ipds->ip->ip_len);
if (length < ipds->len)
(void)printf("truncated-ip - %u bytes missing! ",
len - length);
if (len < hlen) {
(void)printf("bad-len %u", len);
return;
ipds->len - length);
if (ipds->len < hlen) {
#ifdef GUESS_TSO
if (ipds->len) {
(void)printf("bad-len %u", ipds->len);
return;
}
else {
/* we guess that it is a TSO send */
ipds->len = length;
}
#else
(void)printf("bad-len %u", ipds->len);
return;
#endif /* GUESS_TSO */
}
/*
* Cut off the snapshot length to the end of the IP payload.
*/
ipend = bp + len;
ipend = bp + ipds->len;
if (ipend < snapend)
snapend = ipend;
len -= hlen;
len0 = len;
ipds->len -= hlen;
off = EXTRACT_16BITS(&ip->ip_off);
ipds->off = EXTRACT_16BITS(&ipds->ip->ip_off);
if (vflag) {
(void)printf("(tos 0x%x", (int)ip->ip_tos);
(void)printf("(tos 0x%x", (int)ipds->ip->ip_tos);
/* ECN bits */
if (ip->ip_tos & 0x03) {
switch (ip->ip_tos & 0x03) {
if (ipds->ip->ip_tos & 0x03) {
switch (ipds->ip->ip_tos & 0x03) {
case 1:
(void)printf(",ECT(1)");
break;
@ -444,8 +618,8 @@ ip_print(register const u_char *bp, register u_int length)
}
}
if (ip->ip_ttl >= 1)
(void)printf(", ttl %3u", ip->ip_ttl);
if (ipds->ip->ip_ttl >= 1)
(void)printf(", ttl %3u", ipds->ip->ip_ttl);
/*
* for the firewall guys, print id, offset.
@ -453,23 +627,25 @@ ip_print(register const u_char *bp, register u_int length)
* For unfragmented datagrams, note the don't fragment flag.
*/
(void)printf(", id %u, offset %u, flags [%s]",
EXTRACT_16BITS(&ip->ip_id),
(off & 0x1fff) * 8,
bittok2str(ip_frag_values, "none", off & 0xe000 ));
(void)printf(", id %u, offset %u, flags [%s], proto: %s (%u)",
EXTRACT_16BITS(&ipds->ip->ip_id),
(ipds->off & 0x1fff) * 8,
bittok2str(ip_frag_values, "none", ipds->off&0xe000 ),
tok2str(ipproto_values,"unknown",ipds->ip->ip_p),
ipds->ip->ip_p);
(void)printf(", length: %u", EXTRACT_16BITS(&ip->ip_len));
(void)printf(", length: %u", EXTRACT_16BITS(&ipds->ip->ip_len));
if ((hlen - sizeof(struct ip)) > 0) {
(void)printf(", optlength: %u (", hlen - (u_int)sizeof(struct ip));
ip_optprint((u_char *)(ip + 1), hlen - sizeof(struct ip));
printf(", options ( ");
ip_optprint((u_char *)(ipds->ip + 1), hlen - sizeof(struct ip));
printf(" )");
}
if ((u_char *)ip + hlen <= snapend) {
sum = in_cksum((const u_short *)ip, hlen, 0);
if ((u_char *)ipds->ip + hlen <= snapend) {
sum = in_cksum((const u_short *)ipds->ip, hlen, 0);
if (sum != 0) {
ip_sum = EXTRACT_16BITS(&ip->ip_sum);
ip_sum = EXTRACT_16BITS(&ipds->ip->ip_sum);
(void)printf(", bad cksum %x (->%x)!", ip_sum,
in_cksum_shouldbe(ip_sum, sum));
}
@ -482,133 +658,17 @@ ip_print(register const u_char *bp, register u_int length)
* If this is fragment zero, hand it to the next higher
* level protocol.
*/
if ((off & 0x1fff) == 0) {
cp = (const u_char *)ip + hlen;
nh = ip->ip_p;
if ((ipds->off & 0x1fff) == 0) {
ipds->cp = (const u_char *)ipds->ip + hlen;
ipds->nh = ipds->ip->ip_p;
if (nh != IPPROTO_TCP && nh != IPPROTO_UDP &&
nh != IPPROTO_SCTP) {
(void)printf("%s > %s: ", ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
}
again:
switch (nh) {
case IPPROTO_AH:
nh = *cp;
advance = ah_print(cp);
if (advance <= 0)
break;
cp += advance;
len -= advance;
goto again;
case IPPROTO_ESP:
{
int enh, padlen;
advance = esp_print(cp, (const u_char *)ip, &enh, &padlen);
if (advance <= 0)
break;
cp += advance;
len -= advance + padlen;
nh = enh & 0xff;
goto again;
}
case IPPROTO_IPCOMP:
{
int enh;
advance = ipcomp_print(cp, &enh);
if (advance <= 0)
break;
cp += advance;
len -= advance;
nh = enh & 0xff;
goto again;
}
case IPPROTO_SCTP:
sctp_print(cp, (const u_char *)ip, len);
break;
case IPPROTO_TCP:
tcp_print(cp, len, (const u_char *)ip, (off &~ 0x6000));
break;
case IPPROTO_UDP:
udp_print(cp, len, (const u_char *)ip, (off &~ 0x6000));
break;
case IPPROTO_ICMP:
/* pass on the MF bit plus the offset to detect fragments */
icmp_print(cp, len, (const u_char *)ip, (off & 0x3fff));
break;
case IPPROTO_IGRP:
igrp_print(cp, len, (const u_char *)ip);
break;
case IPPROTO_ND:
(void)printf(" nd %d", len);
break;
case IPPROTO_EGP:
egp_print(cp);
break;
case IPPROTO_OSPF:
ospf_print(cp, len, (const u_char *)ip);
break;
case IPPROTO_IGMP:
igmp_print(cp, len);
break;
case IPPROTO_IPV4:
/* DVMRP multicast tunnel (ip-in-ip encapsulation) */
ip_print(cp, len);
if (! vflag) {
printf(" (ipip-proto-4)");
return;
}
break;
#ifdef INET6
case IPPROTO_IPV6:
/* ip6-in-ip encapsulation */
ip6_print(cp, len);
break;
#endif /*INET6*/
case IPPROTO_RSVP:
rsvp_print(cp, len);
break;
case IPPROTO_GRE:
/* do it */
gre_print(cp, len);
break;
case IPPROTO_MOBILE:
mobile_print(cp, len);
break;
case IPPROTO_PIM:
pim_print(cp, len);
break;
case IPPROTO_VRRP:
vrrp_print(cp, len, ip->ip_ttl);
break;
default:
if ((proto = getprotobynumber(nh)) != NULL)
(void)printf(" %s", proto->p_name);
else
(void)printf(" ip-proto-%d", nh);
printf(" %d", len);
break;
if (ipds->nh != IPPROTO_TCP && ipds->nh != IPPROTO_UDP &&
ipds->nh != IPPROTO_SCTP) {
(void)printf("%s > %s: ",
ipaddr_string(&ipds->ip->ip_src),
ipaddr_string(&ipds->ip->ip_dst));
}
ip_print_demux(ndo, ipds);
} else {
/* Ultra quiet now means that all this stuff should be suppressed */
if (qflag > 1) return;
@ -618,13 +678,13 @@ ip_print(register const u_char *bp, register u_int length)
* next level protocol header. print the ip addr
* and the protocol.
*/
if (off & 0x1fff) {
(void)printf("%s > %s:", ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
if ((proto = getprotobynumber(ip->ip_p)) != NULL)
if (ipds->off & 0x1fff) {
(void)printf("%s > %s:", ipaddr_string(&ipds->ip->ip_src),
ipaddr_string(&ipds->ip->ip_dst));
if ((proto = getprotobynumber(ipds->ip->ip_p)) != NULL)
(void)printf(" %s", proto->p_name);
else
(void)printf(" ip-proto-%d", ip->ip_p);
(void)printf(" ip-proto-%d", ipds->ip->ip_p);
}
}
}
@ -642,7 +702,7 @@ ipN_print(register const u_char *bp, register u_int length)
memcpy (&hdr, (char *)ip, 4);
switch (IP_V(&hdr)) {
case 4:
ip_print (bp, length);
ip_print (gndo, bp, length);
return;
#ifdef INET6
case 6:
@ -655,5 +715,11 @@ ipN_print(register const u_char *bp, register u_int length)
}
}
/*
* Local Variables:
* c-style: whitesmith
* c-basic-offset: 8
* End:
*/

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.32.2.8 2003/11/24 20:31:22 guy Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.47 2005/04/06 21:32:40 mcr Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -65,16 +65,43 @@ ip6_print(register const u_char *bp, register u_int length)
TCHECK(*ip6);
if (length < sizeof (struct ip6_hdr)) {
(void)printf("truncated-ip6 %d", length);
(void)printf("truncated-ip6 %u", length);
return;
}
if (!eflag)
printf("IP6 ");
payload_len = EXTRACT_16BITS(&ip6->ip6_plen);
len = payload_len + sizeof(struct ip6_hdr);
if (length < len)
(void)printf("truncated-ip6 - %d bytes missing!",
(void)printf("truncated-ip6 - %u bytes missing!",
len - length);
if (vflag) {
flow = EXTRACT_32BITS(&ip6->ip6_flow);
printf("(");
#if 0
/* rfc1883 */
if (flow & 0x0f000000)
(void)printf("pri 0x%02x, ", (flow & 0x0f000000) >> 24);
if (flow & 0x00ffffff)
(void)printf("flowlabel 0x%06x, ", flow & 0x00ffffff);
#else
/* RFC 2460 */
if (flow & 0x0ff00000)
(void)printf("class 0x%02x, ", (flow & 0x0ff00000) >> 20);
if (flow & 0x000fffff)
(void)printf("flowlabel 0x%05x, ", flow & 0x000fffff);
#endif
(void)printf("hlim %u, next-header: %s (%u), length: %u) ",
ip6->ip6_hlim,
tok2str(ipproto_values,"unknown",ip6->ip6_nxt),
ip6->ip6_nxt,
payload_len);
}
/*
* Cut off the snapshot length to the end of the IP payload.
*/
@ -108,7 +135,7 @@ ip6_print(register const u_char *bp, register u_int length)
case IPPROTO_FRAGMENT:
advance = frag6_print(cp, (const u_char *)ip6);
if (snapend <= cp + advance)
goto end;
return;
nh = *cp;
fragmented = 1;
break;
@ -127,23 +154,23 @@ ip6_print(register const u_char *bp, register u_int length)
*/
advance = mobility_print(cp, (const u_char *)ip6);
nh = *cp;
goto end;
return;
case IPPROTO_ROUTING:
advance = rt6_print(cp, (const u_char *)ip6);
nh = *cp;
break;
case IPPROTO_SCTP:
sctp_print(cp, (const u_char *)ip6, len);
goto end;
return;
case IPPROTO_TCP:
tcp_print(cp, len, (const u_char *)ip6, fragmented);
goto end;
return;
case IPPROTO_UDP:
udp_print(cp, len, (const u_char *)ip6, fragmented);
goto end;
return;
case IPPROTO_ICMPV6:
icmp6_print(cp, len, (const u_char *)ip6, fragmented);
goto end;
return;
case IPPROTO_AH:
advance = ah_print(cp);
nh = *cp;
@ -151,7 +178,7 @@ ip6_print(register const u_char *bp, register u_int length)
case IPPROTO_ESP:
{
int enh, padlen;
advance = esp_print(cp, (const u_char *)ip6, &enh, &padlen);
advance = esp_print(gndo, cp, len, (const u_char *)ip6, &enh, &padlen);
nh = enh & 0xff;
len -= padlen;
break;
@ -166,56 +193,29 @@ ip6_print(register const u_char *bp, register u_int length)
case IPPROTO_PIM:
pim_print(cp, len);
goto end;
return;
case IPPROTO_OSPF:
ospf6_print(cp, len);
goto end;
return;
case IPPROTO_IPV6:
ip6_print(cp, len);
goto end;
return;
case IPPROTO_IPV4:
ip_print(cp, len);
goto end;
ip_print(gndo, cp, len);
return;
case IPPROTO_NONE:
(void)printf("no next header");
goto end;
return;
default:
(void)printf("ip-proto-%d %d", ip6->ip6_nxt, len);
goto end;
return;
}
}
end:
flow = EXTRACT_32BITS(&ip6->ip6_flow);
#if 0
/* rfc1883 */
if (flow & 0x0f000000)
(void)printf(" [pri 0x%x]", (flow & 0x0f000000) >> 24);
if (flow & 0x00ffffff)
(void)printf(" [flowlabel 0x%x]", flow & 0x00ffffff);
#else
/* RFC 2460 */
if (flow & 0x0ff00000)
(void)printf(" [class 0x%x]", (flow & 0x0ff00000) >> 20);
if (flow & 0x000fffff)
(void)printf(" [flowlabel 0x%x]", flow & 0x000fffff);
#endif
if (ip6->ip6_hlim <= 1)
(void)printf(" [hlim %u]", ip6->ip6_hlim);
if (vflag) {
printf(" (");
(void)printf("len %u", payload_len);
if (ip6->ip6_hlim > 1)
(void)printf(", hlim %d", (int)ip6->ip6_hlim);
printf(")");
}
return;
trunc:
(void)printf("[|ip6]");

View File

@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.34.2.2 2003/11/16 08:51:28 guy Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.40 2004/05/26 19:57:57 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -58,12 +58,15 @@ ipx_print(const u_char *p, u_int length)
{
const struct ipxHdr *ipx = (const struct ipxHdr *)p;
if (!eflag)
printf("IPX ");
TCHECK(ipx->srcSkt);
(void)printf("%s.%04x > ",
ipxaddr_string(EXTRACT_32BITS(ipx->srcNet), ipx->srcNode),
EXTRACT_16BITS(&ipx->srcSkt));
(void)printf("%s.%04x:",
(void)printf("%s.%04x: ",
ipxaddr_string(EXTRACT_32BITS(ipx->dstNet), ipx->dstNode),
EXTRACT_16BITS(&ipx->dstSkt));
@ -96,7 +99,7 @@ ipx_decode(const struct ipxHdr *ipx, const u_char *datap, u_int length)
dstSkt = EXTRACT_16BITS(&ipx->dstSkt);
switch (dstSkt) {
case IPX_SKT_NCP:
(void)printf(" ipx-ncp %d", length);
(void)printf("ipx-ncp %d", length);
break;
case IPX_SKT_SAP:
ipx_sap_print((u_short *)datap, length);
@ -105,25 +108,25 @@ ipx_decode(const struct ipxHdr *ipx, const u_char *datap, u_int length)
ipx_rip_print((u_short *)datap, length);
break;
case IPX_SKT_NETBIOS:
(void)printf(" ipx-netbios %d", length);
(void)printf("ipx-netbios %d", length);
#ifdef TCPDUMP_DO_SMB
ipx_netbios_print(datap, length);
#endif
break;
case IPX_SKT_DIAGNOSTICS:
(void)printf(" ipx-diags %d", length);
(void)printf("ipx-diags %d", length);
break;
case IPX_SKT_NWLINK_DGM:
(void)printf(" ipx-nwlink-dgm %d", length);
(void)printf("ipx-nwlink-dgm %d", length);
#ifdef TCPDUMP_DO_SMB
ipx_netbios_print(datap, length);
#endif
break;
case IPX_SKT_EIGRP:
(void)printf(" ipx-eigrp %d", length);
eigrp_print(datap, length);
break;
default:
(void)printf(" ipx-#%x %d", dstSkt, length);
(void)printf("ipx-#%x %d", dstSkt, length);
break;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.53.2.3 2003/12/29 22:33:18 hannes Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.61 2005/04/06 21:32:41 mcr Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -44,6 +44,7 @@ static const char rcsid[] _U_ =
#include "llc.h"
#include "ethertype.h"
#include "oui.h"
static struct tok llc_values[] = {
{ LLCSAP_NULL, "Null" },
@ -96,7 +97,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
memcpy((char *)&llc, (char *)p, min(caplen, sizeof(llc)));
if (eflag)
printf("LLC, dsap %s (0x%02x), ssap %s (0x%02x), cmd 0x%02x, ",
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),
@ -118,9 +119,12 @@ llc_print(const u_char *p, u_int length, u_int caplen,
* such as an 802.11 network; this has appeared in at
* least one capture file.)
*/
printf("(NOV-802.3) ");
ipx_print(p, length);
return (1);
if (eflag)
printf("IPX-802.3: ");
ipx_print(p, length);
return (1);
}
if (llc.ssap == LLCSAP_8021D && llc.dsap == LLCSAP_8021D) {
@ -129,7 +133,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
}
if (llc.ssap == LLCSAP_IP && llc.dsap == LLCSAP_IP) {
ip_print(p+4, length-4);
ip_print(gndo, p+4, length-4);
return (1);
}
@ -218,6 +222,14 @@ llc_print(const u_char *p, u_int length, u_int caplen,
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);
/*
* XXX - what *is* the right bridge pad value here?
* Does anybody ever bridge one form of LAN traffic
@ -310,7 +322,6 @@ llc_print(const u_char *p, u_int length, u_int caplen,
length -= 4;
caplen -= 4;
}
(void)printf(" len=%d", length);
return(1);
}
@ -429,3 +440,11 @@ snap_print(const u_char *p, u_int length, u_int caplen,
}
return (0);
}
/*
* Local Variables:
* c-style: whitesmith
* c-basic-offset: 8
* End:
*/

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.99.2.2 2003/11/16 08:51:35 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.106 2005/01/05 08:16:45 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -32,8 +32,6 @@ static const char rcsid[] _U_ =
#include <tcpdump-stdinc.h>
#include <rpc/rpc.h>
#include <pcap.h>
#include <stdio.h>
#include <string.h>
@ -49,15 +47,16 @@ static const char rcsid[] _U_ =
#ifdef INET6
#include "ip6.h"
#endif
#include "rpc_auth.h"
#include "rpc_msg.h"
static void nfs_printfh(const u_int32_t *, const u_int);
static void xid_map_enter(const struct rpc_msg *, const u_char *);
static int32_t xid_map_find(const struct rpc_msg *, const u_char *,
static void xid_map_enter(const struct sunrpc_msg *, const u_char *);
static int32_t xid_map_find(const struct sunrpc_msg *, const u_char *,
u_int32_t *, u_int32_t *);
static void interp_reply(const struct rpc_msg *, u_int32_t, u_int32_t, int);
static void interp_reply(const struct sunrpc_msg *, u_int32_t, u_int32_t, int);
static const u_int32_t *parse_post_op_attr(const u_int32_t *, int);
static void print_sattr3(const struct nfsv3_sattr *sa3, int verbose);
static int print_int64(const u_int32_t *dp, int how);
static void print_nfsaddr(const u_char *, const char *, const char *);
/*
@ -159,59 +158,6 @@ static struct tok type2str[] = {
{ 0, NULL }
};
/*
* Print out a 64-bit integer. This appears to be different on each system,
* try to make the best of it. The integer stored as 2 consecutive XDR
* encoded 32-bit integers, to which a pointer is passed.
*
* Assume that a system that has INT64_FORMAT defined, has a 64-bit
* integer datatype and can print it.
*/
#define UNSIGNED 0
#define SIGNED 1
#define HEX 2
static int print_int64(const u_int32_t *dp, int how)
{
#ifdef INT64_FORMAT
u_int64_t res;
res = ((u_int64_t)EXTRACT_32BITS(&dp[0]) << 32) | (u_int64_t)EXTRACT_32BITS(&dp[1]);
switch (how) {
case SIGNED:
printf(INT64_FORMAT, res);
break;
case UNSIGNED:
printf(U_INT64_FORMAT, res);
break;
case HEX:
printf(HEX_INT64_FORMAT, res);
break;
default:
return (0);
}
#else
u_int32_t high;
high = EXTRACT_32BITS(&dp[0]);
switch (how) {
case SIGNED:
case UNSIGNED:
case HEX:
if (high != 0)
printf("0x%x%08x", high, EXTRACT_32BITS(&dp[1]));
else
printf("0x%x", EXTRACT_32BITS(&dp[1]));
break;
default:
return (0);
}
#endif
return 1;
}
static void
print_nfsaddr(const u_char *bp, const char *s, const char *d)
{
@ -342,12 +288,12 @@ void
nfsreply_print(register const u_char *bp, u_int length,
register const u_char *bp2)
{
register const struct rpc_msg *rp;
register const struct sunrpc_msg *rp;
u_int32_t proc, vers;
char srcid[20], dstid[20]; /*fits 32bit*/
nfserr = 0; /* assume no error */
rp = (const struct rpc_msg *)bp;
rp = (const struct sunrpc_msg *)bp;
if (!nflag) {
strlcpy(srcid, "nfs", sizeof(srcid));
@ -360,9 +306,9 @@ nfsreply_print(register const u_char *bp, u_int length,
}
print_nfsaddr(bp2, srcid, dstid);
(void)printf("reply %s %d",
EXTRACT_32BITS(&rp->rm_reply.rp_stat) == MSG_ACCEPTED?
"ok":"ERR",
length);
EXTRACT_32BITS(&rp->rm_reply.rp_stat) == SUNRPC_MSG_ACCEPTED?
"ok":"ERR",
length);
if (xid_map_find(rp, bp2, &proc, &vers) >= 0)
interp_reply(rp, proc, vers, length);
@ -373,7 +319,7 @@ nfsreply_print(register const u_char *bp, u_int length,
* If the packet was truncated, return 0.
*/
static const u_int32_t *
parsereq(register const struct rpc_msg *rp, register u_int length)
parsereq(register const struct sunrpc_msg *rp, register u_int length)
{
register const u_int32_t *dp;
register u_int len;
@ -473,7 +419,7 @@ void
nfsreq_print(register const u_char *bp, u_int length,
register const u_char *bp2)
{
register const struct rpc_msg *rp;
register const struct sunrpc_msg *rp;
register const u_int32_t *dp;
nfs_type type;
int v3;
@ -482,7 +428,7 @@ nfsreq_print(register const u_char *bp, u_int length,
char srcid[20], dstid[20]; /*fits 32bit*/
nfserr = 0; /* assume no error */
rp = (const struct rpc_msg *)bp;
rp = (const struct sunrpc_msg *)bp;
if (!nflag) {
snprintf(srcid, sizeof(srcid), "%u",
EXTRACT_32BITS(&rp->rm_xid));
@ -555,9 +501,9 @@ nfsreq_print(register const u_char *bp, u_int length,
(dp = parsefh(dp, v3)) != NULL) {
if (v3) {
TCHECK(dp[2]);
printf(" %u bytes @ ",
EXTRACT_32BITS(&dp[2]));
print_int64(dp, UNSIGNED);
printf(" %u bytes @ %" PRIu64,
EXTRACT_32BITS(&dp[2]),
EXTRACT_64BITS(&dp[0]));
} else {
TCHECK(dp[1]);
printf(" %u bytes @ %u",
@ -573,10 +519,11 @@ nfsreq_print(register const u_char *bp, u_int length,
if ((dp = parsereq(rp, length)) != NULL &&
(dp = parsefh(dp, v3)) != NULL) {
if (v3) {
TCHECK(dp[4]);
printf(" %u bytes @ ",
EXTRACT_32BITS(&dp[4]));
print_int64(dp, UNSIGNED);
TCHECK(dp[2]);
printf(" %u (%u) bytes @ %" PRIu64,
EXTRACT_32BITS(&dp[4]),
EXTRACT_32BITS(&dp[2]),
EXTRACT_64BITS(&dp[0]));
if (vflag) {
dp += 3;
TCHECK(dp[0]);
@ -691,9 +638,9 @@ nfsreq_print(register const u_char *bp, u_int length,
* We shouldn't really try to interpret the
* offset cookie here.
*/
printf(" %u bytes @ ",
EXTRACT_32BITS(&dp[4]));
print_int64(dp, SIGNED);
printf(" %u bytes @ %" PRId64,
EXTRACT_32BITS(&dp[4]),
EXTRACT_64BITS(&dp[0]));
if (vflag)
printf(" verf %08x%08x", dp[2],
dp[3]);
@ -720,11 +667,14 @@ nfsreq_print(register const u_char *bp, u_int length,
* We don't try to interpret the offset
* cookie here.
*/
printf(" %u bytes @ ", EXTRACT_32BITS(&dp[4]));
print_int64(dp, SIGNED);
if (vflag)
printf(" %u bytes @ %" PRId64,
EXTRACT_32BITS(&dp[4]),
EXTRACT_64BITS(&dp[0]));
if (vflag) {
TCHECK(dp[5]);
printf(" max %u verf %08x%08x",
EXTRACT_32BITS(&dp[5]), dp[2], dp[3]);
}
return;
}
break;
@ -754,8 +704,10 @@ nfsreq_print(register const u_char *bp, u_int length,
printf(" commit");
if ((dp = parsereq(rp, length)) != NULL &&
(dp = parsefh(dp, v3)) != NULL) {
printf(" %u bytes @ ", EXTRACT_32BITS(&dp[2]));
print_int64(dp, UNSIGNED);
TCHECK(dp[2]);
printf(" %u bytes @ %" PRIu64,
EXTRACT_32BITS(&dp[2]),
EXTRACT_64BITS(&dp[0]));
return;
}
break;
@ -861,7 +813,7 @@ int xid_map_next = 0;
int xid_map_hint = 0;
static void
xid_map_enter(const struct rpc_msg *rp, const u_char *bp)
xid_map_enter(const struct sunrpc_msg *rp, const u_char *bp)
{
struct ip *ip = NULL;
#ifdef INET6
@ -909,7 +861,7 @@ xid_map_enter(const struct rpc_msg *rp, const u_char *bp)
* version in vers return, or returns -1 on failure
*/
static int
xid_map_find(const struct rpc_msg *rp, const u_char *bp, u_int32_t *proc,
xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, u_int32_t *proc,
u_int32_t *vers)
{
int i;
@ -976,11 +928,11 @@ xid_map_find(const struct rpc_msg *rp, const u_char *bp, u_int32_t *proc,
* If the packet was truncated, return 0.
*/
static const u_int32_t *
parserep(register const struct rpc_msg *rp, register u_int length)
parserep(register const struct sunrpc_msg *rp, register u_int length)
{
register const u_int32_t *dp;
u_int len;
enum accept_stat astat;
enum sunrpc_accept_stat astat;
/*
* Portability note:
@ -1014,30 +966,30 @@ parserep(register const struct rpc_msg *rp, register u_int length)
astat = EXTRACT_32BITS(dp);
switch (astat) {
case SUCCESS:
case SUNRPC_SUCCESS:
break;
case PROG_UNAVAIL:
case SUNRPC_PROG_UNAVAIL:
printf(" PROG_UNAVAIL");
nfserr = 1; /* suppress trunc string */
return (NULL);
case PROG_MISMATCH:
case SUNRPC_PROG_MISMATCH:
printf(" PROG_MISMATCH");
nfserr = 1; /* suppress trunc string */
return (NULL);
case PROC_UNAVAIL:
case SUNRPC_PROC_UNAVAIL:
printf(" PROC_UNAVAIL");
nfserr = 1; /* suppress trunc string */
return (NULL);
case GARBAGE_ARGS:
case SUNRPC_GARBAGE_ARGS:
printf(" GARBAGE_ARGS");
nfserr = 1; /* suppress trunc string */
return (NULL);
case SYSTEM_ERR:
case SUNRPC_SYSTEM_ERR:
printf(" SYSTEM_ERR");
nfserr = 1; /* suppress trunc string */
return (NULL);
@ -1091,8 +1043,8 @@ parsefattr(const u_int32_t *dp, int verbose, int v3)
EXTRACT_32BITS(&fap->fa_gid));
if (v3) {
TCHECK(fap->fa3_size);
printf(" sz ");
print_int64((u_int32_t *)&fap->fa3_size, UNSIGNED);
printf(" sz %" PRIu64,
EXTRACT_64BITS((u_int32_t *)&fap->fa3_size));
} else {
TCHECK(fap->fa2_size);
printf(" sz %d", EXTRACT_32BITS(&fap->fa2_size));
@ -1106,10 +1058,10 @@ parsefattr(const u_int32_t *dp, int verbose, int v3)
EXTRACT_32BITS(&fap->fa_nlink),
EXTRACT_32BITS(&fap->fa3_rdev.specdata1),
EXTRACT_32BITS(&fap->fa3_rdev.specdata2));
printf(" fsid ");
print_int64((u_int32_t *)&fap->fa3_fsid, HEX);
printf(" fileid ");
print_int64((u_int32_t *)&fap->fa3_fileid, HEX);
printf(" fsid %" PRIx64,
EXTRACT_64BITS((u_int32_t *)&fap->fa3_fsid));
printf(" fileid %" PRIx64,
EXTRACT_64BITS((u_int32_t *)&fap->fa3_fileid));
printf(" a/m/ctime %u.%06u",
EXTRACT_32BITS(&fap->fa3_atime.nfsv3_sec),
EXTRACT_32BITS(&fap->fa3_atime.nfsv3_nsec));
@ -1217,20 +1169,15 @@ parsestatfs(const u_int32_t *dp, int v3)
sfsp = (const struct nfs_statfs *)dp;
if (v3) {
printf(" tbytes ");
print_int64((u_int32_t *)&sfsp->sf_tbytes, UNSIGNED);
printf(" fbytes ");
print_int64((u_int32_t *)&sfsp->sf_fbytes, UNSIGNED);
printf(" abytes ");
print_int64((u_int32_t *)&sfsp->sf_abytes, UNSIGNED);
printf(" tbytes %" PRIu64 " fbytes %" PRIu64 " abytes %" PRIu64,
EXTRACT_64BITS((u_int32_t *)&sfsp->sf_tbytes),
EXTRACT_64BITS((u_int32_t *)&sfsp->sf_fbytes),
EXTRACT_64BITS((u_int32_t *)&sfsp->sf_abytes));
if (vflag) {
printf(" tfiles ");
print_int64((u_int32_t *)&sfsp->sf_tfiles, UNSIGNED);
printf(" ffiles ");
print_int64((u_int32_t *)&sfsp->sf_ffiles, UNSIGNED);
printf(" afiles ");
print_int64((u_int32_t *)&sfsp->sf_afiles, UNSIGNED);
printf(" invar %u",
printf(" tfiles %" PRIu64 " ffiles %" PRIu64 " afiles %" PRIu64 " invar %u",
EXTRACT_64BITS((u_int32_t *)&sfsp->sf_tfiles),
EXTRACT_64BITS((u_int32_t *)&sfsp->sf_ffiles),
EXTRACT_64BITS((u_int32_t *)&sfsp->sf_afiles),
EXTRACT_32BITS(&sfsp->sf_invarsec));
}
} else {
@ -1274,8 +1221,7 @@ parserddires(const u_int32_t *dp)
static const u_int32_t *
parse_wcc_attr(const u_int32_t *dp)
{
printf(" sz ");
print_int64(dp, UNSIGNED);
printf(" sz %" PRIu64, EXTRACT_64BITS(&dp[0]));
printf(" mtime %u.%06u ctime %u.%06u",
EXTRACT_32BITS(&dp[2]), EXTRACT_32BITS(&dp[3]),
EXTRACT_32BITS(&dp[4]), EXTRACT_32BITS(&dp[5]));
@ -1421,10 +1367,10 @@ parsefsinfo(const u_int32_t *dp)
EXTRACT_32BITS(&sfp->fs_wtpref),
EXTRACT_32BITS(&sfp->fs_dtpref));
if (vflag) {
printf(" rtmult %u wtmult %u maxfsz ",
printf(" rtmult %u wtmult %u maxfsz %" PRIu64,
EXTRACT_32BITS(&sfp->fs_rtmult),
EXTRACT_32BITS(&sfp->fs_wtmult));
print_int64((u_int32_t *)&sfp->fs_maxfilesize, UNSIGNED);
EXTRACT_32BITS(&sfp->fs_wtmult),
EXTRACT_64BITS((u_int32_t *)&sfp->fs_maxfilesize));
printf(" delta %u.%06u ",
EXTRACT_32BITS(&sfp->fs_timedelta.nfsv3_sec),
EXTRACT_32BITS(&sfp->fs_timedelta.nfsv3_nsec));
@ -1465,7 +1411,7 @@ parsepathconf(const u_int32_t *dp)
}
static void
interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int length)
interp_reply(const struct sunrpc_msg *rp, u_int32_t proc, u_int32_t vers, int length)
{
register const u_int32_t *dp;
register int v3;

View File

@ -27,7 +27,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.37.2.2 2003/11/16 08:51:36 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.41 2004/01/28 14:54:50 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -54,6 +54,26 @@ static void p_sfix(const struct s_fixedpt *);
static void p_ntp_time(const struct l_fixedpt *);
static void p_ntp_delta(const struct l_fixedpt *, const struct l_fixedpt *);
static struct tok ntp_mode_values[] = {
{ MODE_UNSPEC, "unspecified" },
{ MODE_SYM_ACT, "symmetric active" },
{ MODE_SYM_PAS, "symmetric passive" },
{ MODE_CLIENT, "Client" },
{ MODE_SERVER, "Server" },
{ MODE_BROADCAST, "Broadcast" },
{ MODE_RES1, "Reserved" },
{ MODE_RES2, "Reserved" },
{ 0, NULL }
};
static struct tok ntp_leapind_values[] = {
{ NO_WARNING, "" },
{ PLUS_SEC, "+1s" },
{ MINUS_SEC, "-1s" },
{ ALARM, "clock unsynchronized" },
{ 0, NULL }
};
/*
* Print ntp requests
*/
@ -64,90 +84,49 @@ ntp_print(register const u_char *cp, u_int length)
int mode, version, leapind;
bp = (struct ntpdata *)cp;
/* Note funny sized packets */
if (length != sizeof(struct ntpdata))
(void)printf(" [len=%d]", length);
TCHECK(bp->status);
version = (int)(bp->status & VERSIONMASK) >> 3;
printf("NTPv%d", version);
leapind = bp->status & LEAPMASK;
switch (leapind) {
case NO_WARNING:
break;
case PLUS_SEC:
fputs(" +1s", stdout);
break;
case MINUS_SEC:
fputs(" -1s", stdout);
break;
}
mode = bp->status & MODEMASK;
switch (mode) {
if (!vflag) {
printf (", %s, length %u",
tok2str(ntp_mode_values, "Unknown mode", mode),
length);
return;
}
printf (", length %u\n\t%s",
length,
tok2str(ntp_mode_values, "Unknown mode", mode));
case MODE_UNSPEC: /* unspecified */
fputs(" unspec", stdout);
break;
case MODE_SYM_ACT: /* symmetric active */
fputs(" sym_act", stdout);
break;
case MODE_SYM_PAS: /* symmetric passive */
fputs(" sym_pas", stdout);
break;
case MODE_CLIENT: /* client */
fputs(" client", stdout);
break;
case MODE_SERVER: /* server */
fputs(" server", stdout);
break;
case MODE_BROADCAST: /* broadcast */
fputs(" bcast", stdout);
break;
case MODE_RES1: /* reserved */
fputs(" res1", stdout);
break;
case MODE_RES2: /* reserved */
fputs(" res2", stdout);
break;
}
leapind = bp->status & LEAPMASK;
printf (", Leap indicator: %s (%u)",
tok2str(ntp_leapind_values, "Unknown", leapind),
leapind);
TCHECK(bp->stratum);
printf(", strat %d", bp->stratum);
printf(", Stratum %u", bp->stratum);
TCHECK(bp->ppoll);
printf(", poll %d", bp->ppoll);
printf(", poll %us", bp->ppoll);
/* Can't TCHECK bp->precision bitfield so bp->distance + 0 instead */
TCHECK2(bp->distance, 0);
printf(", prec %d", bp->precision);
TCHECK2(bp->root_delay, 0);
printf(", precision %d", bp->precision);
if (!vflag)
return;
TCHECK(bp->root_delay);
fputs("\n\tRoot Delay: ", stdout);
p_sfix(&bp->root_delay);
TCHECK(bp->distance);
fputs(" dist ", stdout);
p_sfix(&bp->distance);
TCHECK(bp->dispersion);
fputs(", disp ", stdout);
p_sfix(&bp->dispersion);
TCHECK(bp->root_dispersion);
fputs(", Root dispersion: ", stdout);
p_sfix(&bp->root_dispersion);
TCHECK(bp->refid);
fputs(", ref ", stdout);
fputs(", Reference-ID: ", stdout);
/* Interpretation depends on stratum */
switch (bp->stratum) {
@ -174,21 +153,29 @@ ntp_print(register const u_char *cp, u_int length)
break;
}
TCHECK(bp->reftime);
putchar('@');
p_ntp_time(&(bp->reftime));
TCHECK(bp->ref_timestamp);
fputs("\n\t Reference Timestamp: ", stdout);
p_ntp_time(&(bp->ref_timestamp));
TCHECK(bp->org);
fputs(" orig ", stdout);
p_ntp_time(&(bp->org));
TCHECK(bp->org_timestamp);
fputs("\n\t Originator Timestamp: ", stdout);
p_ntp_time(&(bp->org_timestamp));
TCHECK(bp->rec);
fputs(" rec ", stdout);
p_ntp_delta(&(bp->org), &(bp->rec));
TCHECK(bp->rec_timestamp);
fputs("\n\t Receive Timestamp: ", stdout);
p_ntp_time(&(bp->rec_timestamp));
TCHECK(bp->xmt);
fputs(" xmt ", stdout);
p_ntp_delta(&(bp->org), &(bp->xmt));
TCHECK(bp->xmt_timestamp);
fputs("\n\t Transmit Timestamp: ", stdout);
p_ntp_time(&(bp->xmt_timestamp));
fputs("\n\t Originator - Receive Timestamp: ", stdout);
p_ntp_delta(&(bp->org_timestamp), &(bp->rec_timestamp));
fputs("\n\t Originator - Transmit Timestamp: ", stdout);
p_ntp_delta(&(bp->org_timestamp), &(bp->xmt_timestamp));
/* FIXME key-id, authentication */
return;
@ -231,9 +218,9 @@ p_ntp_time(register const struct l_fixedpt *lfp)
#ifdef HAVE_STRFTIME
/*
* For extra verbosity, print the time in human-readable format.
* print the time in human-readable format.
*/
if (vflag > 1 && i) {
if (i) {
time_t seconds = i - JAN_1970;
struct tm *tm;
char time_buf[128];

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.49.2.2 2003/11/16 08:51:36 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.53 2005/04/06 21:32:41 mcr Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -127,7 +127,7 @@ null_print(u_int family, u_int length)
/*
* This is the top level routine of the printer. 'p' points
* to the ether header of the packet, 'h->ts' is the timestamp,
* 'h->length' is the length of the packet off the wire, and 'h->caplen'
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int
@ -165,7 +165,7 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p)
switch (family) {
case BSD_AF_INET:
ip_print(p, length);
ip_print(gndo, p, length);
break;
#ifdef INET6
@ -199,3 +199,9 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p)
return (NULL_HDRLEN);
}
/*
* Local Variables:
* c-style: whitesmith
* c-basic-offset: 8
* End:
*/

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.37.2.4 2004/03/24 02:52:37 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.45 2005/04/06 21:32:42 mcr Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -31,6 +31,56 @@ static const char rcsid[] _U_ =
#endif
#include <tcpdump-stdinc.h>
#include "interface.h"
#define PIMV2_TYPE_HELLO 0
#define PIMV2_TYPE_REGISTER 1
#define PIMV2_TYPE_REGISTER_STOP 2
#define PIMV2_TYPE_JOIN_PRUNE 3
#define PIMV2_TYPE_BOOTSTRAP 4
#define PIMV2_TYPE_ASSERT 5
#define PIMV2_TYPE_GRAFT 6
#define PIMV2_TYPE_GRAFT_ACK 7
#define PIMV2_TYPE_CANDIDATE_RP 8
#define PIMV2_TYPE_PRUNE_REFRESH 9
static struct tok pimv2_type_values[] = {
{ PIMV2_TYPE_HELLO, "Hello" },
{ PIMV2_TYPE_REGISTER, "Register" },
{ PIMV2_TYPE_REGISTER_STOP, "Register Stop" },
{ PIMV2_TYPE_JOIN_PRUNE, "Join / Prune" },
{ PIMV2_TYPE_BOOTSTRAP, "Bootstrap" },
{ PIMV2_TYPE_ASSERT, "Assert" },
{ PIMV2_TYPE_GRAFT, "Graft" },
{ PIMV2_TYPE_GRAFT_ACK, "Graft Acknowledgement" },
{ PIMV2_TYPE_CANDIDATE_RP, "Candidate RP Advertisement" },
{ PIMV2_TYPE_PRUNE_REFRESH, "Prune Refresh" },
{ 0, NULL}
};
#define PIMV2_HELLO_OPTION_HOLDTIME 1
#define PIMV2_HELLO_OPTION_LANPRUNEDELAY 2
#define PIMV2_HELLO_OPTION_DR_PRIORITY_OLD 18
#define PIMV2_HELLO_OPTION_DR_PRIORITY 19
#define PIMV2_HELLO_OPTION_GENID 20
#define PIMV2_HELLO_OPTION_REFRESH_CAP 21
#define PIMV2_HELLO_OPTION_BIDIR_CAP 22
#define PIMV2_HELLO_OPTION_ADDRESS_LIST 24
#define PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD 65001
static struct tok pimv2_hello_option_values[] = {
{ PIMV2_HELLO_OPTION_HOLDTIME, "Hold Time" },
{ PIMV2_HELLO_OPTION_LANPRUNEDELAY, "LAN Prune Delay" },
{ PIMV2_HELLO_OPTION_DR_PRIORITY_OLD, "DR Priority (Old)" },
{ PIMV2_HELLO_OPTION_DR_PRIORITY, "DR Priority" },
{ PIMV2_HELLO_OPTION_GENID, "Generation ID" },
{ PIMV2_HELLO_OPTION_REFRESH_CAP, "State Refresh Capability" },
{ PIMV2_HELLO_OPTION_BIDIR_CAP, "Bi-Directional Capability" },
{ PIMV2_HELLO_OPTION_ADDRESS_LIST, "Address List" },
{ PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD, "Address List (Old)" },
{ 0, NULL}
};
/*
* XXX: We consider a case where IPv6 is not ready yet for portability,
@ -365,12 +415,25 @@ pim_print(register const u_char *bp, register u_int len)
#endif
switch (PIM_VER(pim->pim_typever)) {
case 2: /* avoid hardcoding? */
(void)printf("pim v2");
pimv2_print(bp, len);
break;
case 2:
if (!vflag) {
printf("PIMv%u, %s, length: %u",
PIM_VER(pim->pim_typever),
tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)),
len);
return;
} else {
printf("PIMv%u, length: %u\n\t%s",
PIM_VER(pim->pim_typever),
len,
tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)));
pimv2_print(bp, len);
}
break;
default:
(void)printf("pim v%d", PIM_VER(pim->pim_typever));
printf("PIMv%u, length: %u",
PIM_VER(pim->pim_typever),
len);
break;
}
return;
@ -563,94 +626,86 @@ pimv2_print(register const u_char *bp, register u_int len)
TCHECK(pim->pim_rsv);
pimv2_addr_len = pim->pim_rsv;
if (pimv2_addr_len != 0)
(void)printf("[RFC2117-encoding] ");
(void)printf(", RFC2117-encoding");
switch (PIM_TYPE(pim->pim_typever)) {
case 0:
case PIMV2_TYPE_HELLO:
{
u_int16_t otype, olen;
(void)printf(" Hello");
bp += 4;
while (bp < ep) {
TCHECK2(bp[0], 4);
otype = EXTRACT_16BITS(&bp[0]);
olen = EXTRACT_16BITS(&bp[2]);
TCHECK2(bp[0], 4 + olen);
switch (otype) {
case 1: /* Hold time */
(void)printf(" (Hold-time ");
relts_print(EXTRACT_16BITS(&bp[4]));
(void)printf(")");
break;
case 2: /* LAN Prune Delay */
(void)printf(" (LAN-Prune-Delay: ");
printf("\n\t %s Option (%u), length: %u, Value: ",
tok2str( pimv2_hello_option_values,"Unknown",otype),
otype,
olen);
bp += 4;
switch (otype) {
case PIMV2_HELLO_OPTION_HOLDTIME:
relts_print(EXTRACT_16BITS(bp));
break;
case PIMV2_HELLO_OPTION_LANPRUNEDELAY:
if (olen != 4) {
(void)printf("!olen=%d!)", olen);
(void)printf("ERROR: Option Lenght != 4 Bytes (%u)", olen);
} else {
char t_bit;
u_int16_t lan_delay, override_interval;
lan_delay = EXTRACT_16BITS(&bp[4]);
override_interval = EXTRACT_16BITS(&bp[6]);
lan_delay = EXTRACT_16BITS(bp);
override_interval = EXTRACT_16BITS(bp+2);
t_bit = (lan_delay & 0x8000)? 1 : 0;
lan_delay &= ~0x8000;
(void)printf("T-bit=%d lan-delay=%dms override-interval=%dms)",
(void)printf("\n\t T-bit=%d, LAN delay %dms, Override interval %dms",
t_bit, lan_delay, override_interval);
}
break;
case 18: /* Old DR-Priority */
if (olen == 4)
(void)printf(" (OLD-DR-Priority: %d)",
EXTRACT_32BITS(&bp[4]));
else
goto unknown;
case PIMV2_HELLO_OPTION_DR_PRIORITY_OLD:
case PIMV2_HELLO_OPTION_DR_PRIORITY:
switch (olen) {
case 0:
printf("Bi-Directional Capability (Old)");
break;
case 4:
printf("%u", EXTRACT_32BITS(bp));
break;
default:
printf("ERROR: Option Lenght != 4 Bytes (%u)", olen);
break;
}
break;
case PIMV2_HELLO_OPTION_GENID:
(void)printf("0x%08x", EXTRACT_32BITS(bp));
break;
case 19: /* DR-Priority */
if (olen == 0) {
(void)printf(" (OLD-bidir-capable)");
break;
case PIMV2_HELLO_OPTION_REFRESH_CAP:
(void)printf("v%d", *bp);
if (*(bp+1) != 0) {
(void)printf(", interval ");
relts_print(*(bp+1));
}
(void)printf(" (DR-Priority: ");
if (olen != 4) {
(void)printf("!olen=%d!)", olen);
} else {
(void)printf("%d)", EXTRACT_32BITS(&bp[4]));
if (EXTRACT_16BITS(bp+2) != 0) {
(void)printf(" ?0x%04x?", EXTRACT_16BITS(bp+2));
}
break;
case 20:
(void)printf(" (Genid: 0x%08x)", EXTRACT_32BITS(&bp[4]));
case PIMV2_HELLO_OPTION_BIDIR_CAP:
break;
case 21:
(void)printf(" (State Refresh Capable; v%d", bp[4]);
if (bp[5] != 0) {
(void)printf(" interval ");
relts_print(bp[5]);
}
if (EXTRACT_16BITS(&bp[6]) != 0) {
(void)printf(" ?0x%04x?", EXTRACT_16BITS(&bp[6]));
}
(void)printf(")");
break;
case 22: /* Bidir-Capable */
(void)printf(" (bidir-capable)");
break;
case 24: /* Address List */
case 65001: /* Address List (old implementations) */
(void)printf(" (%saddr-list",
otype == 65001 ? "old" : "");
case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD:
case PIMV2_HELLO_OPTION_ADDRESS_LIST:
if (vflag > 1) {
const u_char *ptr = &bp[4];
while (ptr < &bp[4 + olen]) {
const u_char *ptr = bp;
while (ptr < (bp+olen)) {
int advance;
printf(" ");
printf("\n\t ");
advance = pimv2_addr_print(ptr, pimv2_unicast, 0);
if (advance < 0) {
printf("...");
@ -659,23 +714,24 @@ pimv2_print(register const u_char *bp, register u_int len)
ptr += advance;
}
}
(void)printf(")");
break;
default:
unknown:
if (vflag)
(void)printf(" [Hello option %d]", otype);
if (vflag <= 1)
print_unknown_data(bp,"\n\t ",olen);
break;
}
bp += 4 + olen;
/* do we want to see an additionally hexdump ? */
if (vflag> 1)
print_unknown_data(bp,"\n\t ",olen);
bp += olen;
}
break;
}
case 1:
case PIMV2_TYPE_REGISTER:
{
struct ip *ip;
(void)printf(" Register");
if (vflag && bp + 8 <= ep) {
(void)printf(" %s%s", bp[4] & 0x80 ? "B" : "",
bp[4] & 0x40 ? "N" : "");
@ -689,7 +745,7 @@ pimv2_print(register const u_char *bp, register u_int len)
switch (IP_V(ip)) {
case 4: /* IPv4 */
printf(" ");
ip_print(bp, len);
ip_print(gndo, bp, len);
break;
#ifdef INET6
case 6: /* IPv6 */
@ -704,8 +760,7 @@ pimv2_print(register const u_char *bp, register u_int len)
break;
}
case 2:
(void)printf(" Register-Stop");
case PIMV2_TYPE_REGISTER_STOP:
bp += 4; len -= 4;
if (bp >= ep)
break;
@ -725,9 +780,46 @@ pimv2_print(register const u_char *bp, register u_int len)
bp += advance; len -= advance;
break;
case 3:
case 6:
case 7:
case PIMV2_TYPE_JOIN_PRUNE:
case PIMV2_TYPE_GRAFT:
case PIMV2_TYPE_GRAFT_ACK:
/*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* |PIM Ver| Type | Addr length | Checksum |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Unicast-Upstream Neighbor Address |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Reserved | Num groups | Holdtime |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Encoded-Multicast Group Address-1 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Number of Joined Sources | Number of Pruned Sources |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Encoded-Joined Source Address-1 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | . |
* | . |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Encoded-Joined Source Address-n |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Encoded-Pruned Source Address-1 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | . |
* | . |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Encoded-Pruned Source Address-n |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | . |
* | . |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Encoded-Multicast Group Address-n |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
{
u_int8_t ngroup;
u_int16_t holdtime;
@ -735,22 +827,11 @@ pimv2_print(register const u_char *bp, register u_int len)
u_int16_t nprune;
int i, j;
switch (PIM_TYPE(pim->pim_typever)) {
case 3:
(void)printf(" Join/Prune");
break;
case 6:
(void)printf(" Graft");
break;
case 7:
(void)printf(" Graft-ACK");
break;
}
bp += 4; len -= 4;
if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/
if (bp >= ep)
break;
(void)printf(" upstream-neighbor=");
(void)printf(", upstream-neighbor: ");
if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
(void)printf("...");
break;
@ -761,11 +842,11 @@ pimv2_print(register const u_char *bp, register u_int len)
break;
ngroup = bp[1];
holdtime = EXTRACT_16BITS(&bp[2]);
(void)printf(" groups=%u", ngroup);
(void)printf("\n\t %u group(s)", ngroup);
if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/
(void)printf(" holdtime=");
(void)printf(", holdtime: ");
if (holdtime == 0xffff)
(void)printf("infty");
(void)printf("infinite");
else
relts_print(holdtime);
}
@ -773,7 +854,7 @@ pimv2_print(register const u_char *bp, register u_int len)
for (i = 0; i < ngroup; i++) {
if (bp >= ep)
goto jp_done;
(void)printf(" (group%d: ", i);
(void)printf("\n\t group #%u: ", i+1);
if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
(void)printf("...)");
goto jp_done;
@ -785,36 +866,32 @@ pimv2_print(register const u_char *bp, register u_int len)
}
njoin = EXTRACT_16BITS(&bp[0]);
nprune = EXTRACT_16BITS(&bp[2]);
(void)printf(" join=%u", njoin);
(void)printf(", joined sources: %u, pruned sources: %u", njoin,nprune);
bp += 4; len -= 4;
for (j = 0; j < njoin; j++) {
(void)printf(" ");
(void)printf("\n\t joined source #%u: ",j+1);
if ((advance = pimv2_addr_print(bp, pimv2_source, 0)) < 0) {
(void)printf("...)");
goto jp_done;
}
bp += advance; len -= advance;
}
(void)printf(" prune=%u", nprune);
for (j = 0; j < nprune; j++) {
(void)printf(" ");
(void)printf("\n\t pruned source #%u: ",j+1);
if ((advance = pimv2_addr_print(bp, pimv2_source, 0)) < 0) {
(void)printf("...)");
goto jp_done;
}
bp += advance; len -= advance;
}
(void)printf(")");
}
jp_done:
break;
}
case 4:
case PIMV2_TYPE_BOOTSTRAP:
{
int i, j, frpcnt;
(void)printf(" Bootstrap");
bp += 4;
/* Fragment Tag, Hash Mask len, and BSR-priority */
@ -888,8 +965,7 @@ pimv2_print(register const u_char *bp, register u_int len)
bs_done:
break;
}
case 5:
(void)printf(" Assert");
case PIMV2_TYPE_ASSERT:
bp += 4; len -= 4;
if (bp >= ep)
break;
@ -915,11 +991,9 @@ pimv2_print(register const u_char *bp, register u_int len)
(void)printf(" metric=%u", EXTRACT_32BITS(&bp[4]));
break;
case 8:
case PIMV2_TYPE_CANDIDATE_RP:
{
int i, pfxcnt;
(void)printf(" Candidate-RP-Advertisement");
bp += 4;
/* Prefix-Cnt, Priority, and Holdtime */
@ -955,8 +1029,7 @@ pimv2_print(register const u_char *bp, register u_int len)
break;
}
case 9:
(void)printf(" Prune-Refresh");
case PIMV2_TYPE_PRUNE_REFRESH:
(void)printf(" src=");
if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
(void)printf("...");
@ -991,3 +1064,10 @@ pimv2_print(register const u_char *bp, register u_int len)
trunc:
(void)printf("[|pim]");
}
/*
* Local Variables:
* c-style: whitesmith
* c-basic-offset: 8
* End:
*/

View File

@ -33,7 +33,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.89.2.4 2004/07/13 16:00:25 hannes Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.108 2005/04/06 21:32:42 mcr Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -49,6 +49,7 @@ static const char rcsid[] _U_ =
#include <pcap.h>
#include <stdio.h>
#include <stdlib.h>
#include "interface.h"
#include "extract.h"
@ -56,6 +57,7 @@ static const char rcsid[] _U_ =
#include "ppp.h"
#include "chdlc.h"
#include "ethertype.h"
#include "oui.h"
/*
* The following constatns are defined by IANA. Please refer to
@ -72,13 +74,16 @@ struct tok ppptype2str[] = {
{ PPP_DECNET, "DECNET" },
{ PPP_APPLE, "APPLE" },
{ PPP_IPX, "IPX" },
{ PPP_VJC, "VJC" },
{ PPP_VJNC, "VJNC" },
{ PPP_VJC, "VJC IP" },
{ PPP_VJNC, "VJNC IP" },
{ PPP_BRPDU, "BRPDU" },
{ PPP_STII, "STII" },
{ PPP_VINES, "VINES" },
{ PPP_MPLS_UCAST, "MPLS" },
{ PPP_MPLS_MCAST, "MPLS" },
{ PPP_COMP, "Compressed"},
{ PPP_ML, "MLPPP"},
{ PPP_IPV6, "IP6"},
{ PPP_HELLO, "HELLO" },
{ PPP_LUXCOM, "LUXCOM" },
@ -91,15 +96,19 @@ struct tok ppptype2str[] = {
{ PPP_IPXCP, "IPXCP" },
{ PPP_STIICP, "STIICP" },
{ PPP_VINESCP, "VINESCP" },
{ PPP_IPV6CP, "IP6CP" },
{ PPP_MPLSCP, "MPLSCP" },
{ PPP_LCP, "LCP" },
{ PPP_PAP, "PAP" },
{ PPP_LQM, "LQM" },
{ PPP_CHAP, "CHAP" },
{ PPP_EAP, "EAP" },
{ PPP_SPAP, "SPAP" },
{ PPP_SPAP_OLD, "Old-SPAP" },
{ PPP_BACP, "BACP" },
{ PPP_BAP, "BAP" },
{ PPP_MP, "ML" },
{ PPP_MPCP, "MLPPP-CP" },
{ 0, NULL }
};
@ -198,7 +207,7 @@ static const char *lcpconfopts[] = {
"deprecated(15)", /* used to be a Compund-Frames */
"deprecated(16)", /* used to be a Nominal-Data-Encap */
"MRRU", /* (17) */
"SSNHF", /* (18) */
"12-Bit seq #", /* (18) */
"End-Disc", /* (19) */
"Proprietary", /* (20) */
"DCE-Id", /* (21) */
@ -213,7 +222,6 @@ static const char *lcpconfopts[] = {
"PPP-Muxing", /* (30) */
};
/* IPV6CP - to be supported */
/* ECP - to be supported */
/* CCP Config Options */
@ -277,17 +285,36 @@ static const char *ccpconfopts[] = {
/* SDCP - to be supported */
/* IPCP Config Options */
#define IPCPOPT_2ADDR 1 /* RFC1172, RFC1332 (deprecated) */
#define IPCPOPT_IPCOMP 2 /* RFC1332 */
#define IPCPOPT_ADDR 3 /* RFC1332 */
#define IPCPOPT_MOBILE4 4 /* RFC2290 */
#define IPCPOPT_PRIDNS 129 /* RFC1877 */
#define IPCPOPT_PRINBNS 130 /* RFC1877 */
#define IPCPOPT_SECDNS 131 /* RFC1877 */
#define IPCPOPT_SECNBNS 132 /* RFC1877 */
struct tok ipcpopt_values[] = {
{ IPCPOPT_2ADDR, "IP-Addrs" },
{ IPCPOPT_IPCOMP, "IP-Comp" },
{ IPCPOPT_ADDR, "IP-Addr" },
{ IPCPOPT_MOBILE4, "Home-Addr" },
{ IPCPOPT_PRIDNS, "Pri-DNS" },
{ IPCPOPT_PRINBNS, "Pri-NBNS" },
{ IPCPOPT_SECDNS, "Sec-DNS" },
{ IPCPOPT_SECNBNS, "Sec-NBNS" },
{ 0, NULL }
};
/* IP6CP Config Options */
#define IP6CP_IFID 1
struct tok ip6cpopt_values[] = {
{ IP6CP_IFID, "Interface-ID" },
{ 0, NULL }
};
/* ATCP - to be supported */
/* OSINLCP - to be supported */
/* BVCP - to be supported */
@ -302,6 +329,13 @@ static const char *ccpconfopts[] = {
#define AUTHALG_MSCHAP1 128 /* RFC2433 */
#define AUTHALG_MSCHAP2 129 /* RFC2795 */
struct tok authalg_values[] = {
{ AUTHALG_CHAPMD5, "MD5" },
{ AUTHALG_MSCHAP1, "MS-CHAPv1" },
{ AUTHALG_MSCHAP2, "MS-CHAPv2" },
{ 0, NULL }
};
/* FCS Alternatives - to be supported */
/* Multilink Endpoint Discriminator (RFC1717) */
@ -327,14 +361,12 @@ static const char *ccpconfopts[] = {
#define CHAP_SUCC 3
#define CHAP_FAIL 4
#define CHAP_CODEMIN CHAP_CHAL
#define CHAP_CODEMAX CHAP_FAIL
static const char *chapcode[] = {
"Chal", /* (1) */
"Resp", /* (2) */
"Succ", /* (3) */
"Fail", /* (4) */
struct tok chapcode_values[] = {
{ CHAP_CHAL, "Challenge" },
{ CHAP_RESP, "Response" },
{ CHAP_SUCC, "Success" },
{ CHAP_FAIL, "Fail" },
{ 0, NULL}
};
/* PAP */
@ -343,13 +375,11 @@ static const char *chapcode[] = {
#define PAP_AACK 2
#define PAP_ANAK 3
#define PAP_CODEMIN PAP_AREQ
#define PAP_CODEMAX PAP_ANAK
static const char *papcode[] = {
"Auth-Req", /* (1) */
"Auth-Ack", /* (2) */
"Auth-Nak", /* (3) */
struct tok papcode_values[] = {
{ PAP_AREQ, "Auth-Req" },
{ PAP_AACK, "Auth-ACK" },
{ PAP_ANAK, "Auth-NACK" },
{ 0, NULL }
};
/* BAP */
@ -366,11 +396,14 @@ static void handle_ctrl_proto (u_int proto,const u_char *p, int length);
static void handle_chap (const u_char *p, int length);
static void handle_pap (const u_char *p, int length);
static void handle_bap (const u_char *p, int length);
static void handle_mlppp(const u_char *p, int length);
static int print_lcp_config_options (const u_char *p, int);
static int print_ipcp_config_options (const u_char *p, int);
static int print_ip6cp_config_options (const u_char *p, int);
static int print_ccp_config_options (const u_char *p, int);
static int print_bacp_config_options (const u_char *p, int);
static void handle_ppp (u_int proto, const u_char *p, int length);
static void ppp_hdlc(const u_char *p, int length);
/* generic Control Protocol (e.g. LCP, IPCP, CCP, etc.) handler */
static void
@ -384,7 +417,7 @@ handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
tptr=pptr;
typestr = tok2str(ppptype2str, "unknown", proto);
typestr = tok2str(ppptype2str, "unknown ctrl-proto (0x%04x)", proto);
printf("%s, ",typestr);
if (length < 4) /* FIXME weak boundary checking */
@ -403,7 +436,7 @@ handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
tptr += 2;
if (length <= 4)
return; /* there may be a NULL confreq etc. */
goto print_len_and_return; /* there may be a NULL confreq etc. */
switch (code) {
case CPCODES_VEXT:
@ -413,7 +446,9 @@ handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
printf(", Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
tptr += 4;
TCHECK2(*tptr, 3);
printf(" OUI 0x%06x", EXTRACT_24BITS(tptr));
printf(" Vendor: %s (%u)",
tok2str(oui_values,"Unknown",EXTRACT_24BITS(tptr)),
EXTRACT_24BITS(tptr));
/* XXX: need to decode Kind and Value(s)? */
break;
case CPCODES_CONF_REQ:
@ -429,6 +464,9 @@ handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
case PPP_IPCP:
pfunc = print_ipcp_config_options;
break;
case PPP_IPV6CP:
pfunc = print_ip6cp_config_options;
break;
case PPP_CCP:
pfunc = print_ccp_config_options;
break;
@ -437,17 +475,16 @@ handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
break;
default:
/*
* This should never happen, but we set
* "pfunc" to squelch uninitialized
* variable warnings from compilers.
* No print routine for the options for
* this protocol.
*/
pfunc = NULL;
break;
}
if (pfunc == NULL) /* catch the above null pointer if unknown CP */
break;
if (pfunc == NULL) /* catch the above null pointer if unknown CP */
break;
if ((j = (*pfunc)(tptr, len)) == 0)
break;
x -= j;
@ -498,6 +535,8 @@ handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
print_unknown_data(pptr-2,"\n\t",length+2);
break;
}
print_len_and_return:
printf(", length %u", length);
if (vflag >1)
@ -522,7 +561,7 @@ print_lcp_config_options(const u_char *p, int length)
if (length < len)
return 0;
if ((opt >= LCPOPT_MIN) && (opt <= LCPOPT_MAX))
printf(", %s ", lcpconfopts[opt]);
printf(", %s (%u)", lcpconfopts[opt],opt);
else {
printf(", unknown LCP option 0x%02x", opt);
return len;
@ -532,11 +571,13 @@ print_lcp_config_options(const u_char *p, int length)
case LCPOPT_VEXT:
if (len >= 6) {
TCHECK2(*(p + 2), 3);
printf(" OUI 0x%06x", EXTRACT_24BITS(p+2));
printf(" Vendor: %s (%u)",
tok2str(oui_values,"Unknown",EXTRACT_24BITS(p+2)),
EXTRACT_24BITS(p+2));
#if 0
TCHECK(p[5]);
printf(" kind 0x%02x", p[5]);
printf(" val 0x")
printf(", kind: 0x%02x", p[5]);
printf(", Value: 0x")
for (i = 0; i < len - 6; i++) {
TCHECK(p[6 + i]);
printf("%02x", p[6 + i]);
@ -553,45 +594,26 @@ print_lcp_config_options(const u_char *p, int length)
case LCPOPT_ACCM:
if (len == 6) {
TCHECK2(*(p + 2), 4);
printf(" %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)));
switch (EXTRACT_16BITS(p+2)) {
case PPP_PAP:
printf(" PAP");
break;
case PPP_CHAP:
printf(" CHAP");
TCHECK(p[4]);
switch (p[4]) {
default:
printf(", unknown-algorithm-%u", p[4]);
break;
case AUTHALG_CHAPMD5:
printf(", MD5");
break;
case AUTHALG_MSCHAP1:
printf(", MSCHAPv1");
break;
case AUTHALG_MSCHAP2:
printf(", MSCHAPv2");
break;
}
printf(", %s",tok2str(authalg_values,"Unknown Auth Alg %u",p[4]));
break;
case PPP_PAP: /* fall through */
case PPP_EAP:
printf(" EAP");
break;
case PPP_SPAP:
printf(" SPAP");
break;
case PPP_SPAP_OLD:
printf(" Old-SPAP");
break;
break;
default:
printf("unknown");
print_unknown_data(p,"\n\t",len);
}
}
break;
@ -697,7 +719,7 @@ print_lcp_config_options(const u_char *p, int length)
case LCPOPT_DEP14:
case LCPOPT_DEP15:
case LCPOPT_DEP16:
case LCPOPT_MLSSNHF:
case LCPOPT_MLSSNHF:
case LCPOPT_PROP:
case LCPOPT_DCEID:
case LCPOPT_MPP:
@ -718,6 +740,27 @@ print_lcp_config_options(const u_char *p, int length)
return 0;
}
/* ML-PPP*/
struct tok ppp_ml_flag_values[] = {
{ 0x80, "begin" },
{ 0x40, "end" },
{ 0, NULL }
};
static void
handle_mlppp(const u_char *p, int length) {
if (!eflag)
printf("MLPPP, ");
printf("seq 0x%03x, Flags [%s], length %u",
(EXTRACT_16BITS(p))&0x0fff, /* only support 12-Bit sequence space for now */
bittok2str(ppp_ml_flag_values, "none", *p & 0xc0),
length);
return;
}
/* CHAP */
static void
handle_chap(const u_char *p, int length)
@ -739,16 +782,13 @@ handle_chap(const u_char *p, int length)
TCHECK(*p);
code = *p;
if ((code >= CHAP_CODEMIN) && (code <= CHAP_CODEMAX))
printf("%s", chapcode[code - 1]);
else {
printf("0x%02x", code);
return;
}
printf("CHAP, %s (0x%02x)",
tok2str(chapcode_values,"unknown",code),
code);
p++;
TCHECK(*p);
printf("(%u)", *p); /* ID */
printf(", id %u", *p); /* ID */
p++;
TCHECK2(*p, 2);
@ -821,16 +861,13 @@ handle_pap(const u_char *p, int length)
TCHECK(*p);
code = *p;
if ((code >= PAP_CODEMIN) && (code <= PAP_CODEMAX))
printf("%s", papcode[code - 1]);
else {
printf("0x%02x", code);
return;
}
printf("PAP, %s (0x%02x)",
tok2str(papcode_values,"unknown",code),
code);
p++;
TCHECK(*p);
printf("(%u)", *p); /* ID */
printf(", id %u", *p); /* ID */
p++;
TCHECK2(*p, 2);
@ -908,61 +945,41 @@ print_ipcp_config_options(const u_char *p, int length)
opt = p[0];
if (length < len)
return 0;
printf(", %s (0x%02x) ",
tok2str(ipcpopt_values,"unknown",opt),
opt);
switch (opt) {
case IPCPOPT_2ADDR: /* deprecated */
if (len != 10)
goto invlen;
TCHECK2(*(p + 6), 4);
printf(", IP-Addrs src %s, dst %s",
printf("src %s, dst %s",
ipaddr_string(p + 2),
ipaddr_string(p + 6));
break;
case IPCPOPT_IPCOMP:
if (len < 4)
goto invlen;
printf(", IP-Comp");
TCHECK2(*(p + 2), 2);
if (EXTRACT_16BITS(p + 2) == PPP_VJC) {
printf(" VJ-Comp");
printf("VJ-Comp");
/* XXX: VJ-Comp parameters should be decoded */
} else
printf(" unknown-comp-proto=%04x", EXTRACT_16BITS(p + 2));
break;
case IPCPOPT_ADDR:
if (len != 6)
goto invlen;
TCHECK2(*(p + 2), 4);
printf(", IP-Addr %s", ipaddr_string(p + 2));
printf("unknown-comp-proto %04x", EXTRACT_16BITS(p + 2));
break;
case IPCPOPT_ADDR: /* those options share the same format - fall through */
case IPCPOPT_MOBILE4:
if (len != 6)
goto invlen;
TCHECK2(*(p + 2), 4);
printf(", Home-Addr %s", ipaddr_string(p + 2));
break;
case IPCPOPT_PRIDNS:
if (len != 6)
goto invlen;
TCHECK2(*(p + 2), 4);
printf(", Pri-DNS %s", ipaddr_string(p + 2));
break;
case IPCPOPT_PRINBNS:
if (len != 6)
goto invlen;
TCHECK2(*(p + 2), 4);
printf(", Pri-NBNS %s", ipaddr_string(p + 2));
break;
case IPCPOPT_SECDNS:
if (len != 6)
goto invlen;
TCHECK2(*(p + 2), 4);
printf(", Sec-DNS %s", ipaddr_string(p + 2));
break;
case IPCPOPT_SECNBNS:
if (len != 6)
goto invlen;
TCHECK2(*(p + 2), 4);
printf(", Sec-NBNS %s", ipaddr_string(p + 2));
printf("%s", ipaddr_string(p + 2));
break;
default:
printf(", unknown-%d", opt);
@ -979,6 +996,51 @@ print_ipcp_config_options(const u_char *p, int length)
return 0;
}
/* IP6CP config options */
static int
print_ip6cp_config_options(const u_char *p, int length)
{
int len, opt;
if (length < 2)
return 0;
TCHECK2(*p, 2);
len = p[1];
opt = p[0];
if (length < len)
return 0;
printf(", %s (0x%02x) ",
tok2str(ip6cpopt_values,"unknown",opt),
opt);
switch (opt) {
case IP6CP_IFID:
if (len != 10)
goto invlen;
TCHECK2(*(p + 2), 8);
printf("%04x:%04x:%04x:%04x",
EXTRACT_16BITS(p + 2),
EXTRACT_16BITS(p + 4),
EXTRACT_16BITS(p + 6),
EXTRACT_16BITS(p + 8));
break;
default:
printf(", unknown-%d", opt);
break;
}
return len;
invlen:
printf(", invalid-length-%d", opt);
return 0;
trunc:
printf("[|ip6cp]");
return 0;
}
/* CCP config options */
static int
print_ccp_config_options(const u_char *p, int length)
@ -1053,12 +1115,83 @@ print_bacp_config_options(const u_char *p, int length)
}
static void
ppp_hdlc(const u_char *p, int length)
{
u_char *b, *s, *t, c;
int i, proto;
const void *se;
b = (u_int8_t *)malloc(length);
if (b == NULL)
return;
/*
* Unescape all the data into a temporary, private, buffer.
* Do this so that we dont overwrite the original packet
* contents.
*/
for (s = (u_char *)p, t = b, i = length; i > 0; i--) {
c = *s++;
if (c == 0x7d) {
if (i > 1) {
i--;
c = *s++ ^ 0x20;
} else
continue;
}
*t++ = c;
}
se = snapend;
snapend = t;
/* now lets guess about the payload codepoint format */
proto = *b; /* start with a one-octet codepoint guess */
switch (proto) {
case PPP_IP:
ip_print(gndo, b+1, t - b - 1);
goto cleanup;
#ifdef INET6
case PPP_IPV6:
ip6_print(b+1, t - b - 1);
goto cleanup;
#endif
default: /* no luck - try next guess */
break;
}
proto = EXTRACT_16BITS(b); /* next guess - load two octets */
switch (proto) {
case (PPP_ADDRESS << 8 | PPP_CONTROL): /* looks like a PPP frame */
proto = EXTRACT_16BITS(b+2); /* load the PPP proto-id */
handle_ppp(proto, b+4, t - b - 4);
break;
default: /* last guess - proto must be a PPP proto-id */
handle_ppp(proto, b+2, t - b - 2);
break;
}
cleanup:
snapend = se;
free(b);
return;
}
/* PPP */
static void
handle_ppp(u_int proto, const u_char *p, int length)
{
if ((proto & 0xff00) == 0x7e00) {/* is this an escape code ? */
ppp_hdlc(p-1, length);
return;
}
switch (proto) {
case PPP_LCP:
case PPP_LCP: /* fall through */
case PPP_IPCP:
case PPP_OSICP:
case PPP_MPLSCP:
@ -1067,6 +1200,9 @@ handle_ppp(u_int proto, const u_char *p, int length)
case PPP_BACP:
handle_ctrl_proto(proto, p, length);
break;
case PPP_ML:
handle_mlppp(p, length);
break;
case PPP_CHAP:
handle_chap(p, length);
break;
@ -1077,8 +1213,9 @@ handle_ppp(u_int proto, const u_char *p, int length)
handle_bap(p, length);
break;
case ETHERTYPE_IP: /*XXX*/
case PPP_VJNC:
case PPP_IP:
ip_print(p, length);
ip_print(gndo, p, length);
break;
#ifdef INET6
case ETHERTYPE_IPV6: /*XXX*/
@ -1097,10 +1234,13 @@ handle_ppp(u_int proto, const u_char *p, int length)
case PPP_MPLS_MCAST:
mpls_print(p, length);
break;
case PPP_COMP:
printf("compressed PPP data");
break;
default:
printf("unknown PPP protocol (0x%04x)", proto);
print_unknown_data(p,"\n\t",length);
break;
printf("%s ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", proto));
print_unknown_data(p,"\n\t",length);
break;
}
}
@ -1108,7 +1248,7 @@ handle_ppp(u_int proto, const u_char *p, int length)
u_int
ppp_print(register const u_char *p, u_int length)
{
u_int proto;
u_int proto,ppp_header;
u_int olen = length; /* _o_riginal length */
u_int hdr_len = 0;
@ -1119,11 +1259,30 @@ ppp_print(register const u_char *p, u_int length)
if (length < 2)
goto trunc;
TCHECK2(*p, 2);
if (*p == PPP_ADDRESS && *(p + 1) == PPP_CONTROL) {
p += 2; /* ACFC not used */
length -= 2;
hdr_len += 2;
}
ppp_header = EXTRACT_16BITS(p);
switch(ppp_header) {
case (PPP_WITHDIRECTION_IN << 8 | PPP_CONTROL):
if (eflag) printf("In ");
p += 2;
length -= 2;
hdr_len += 2;
break;
case (PPP_WITHDIRECTION_OUT << 8 | PPP_CONTROL):
if (eflag) printf("Out ");
p += 2;
length -= 2;
hdr_len += 2;
break;
case (PPP_ADDRESS << 8 | PPP_CONTROL):
p += 2; /* ACFC not used */
length -= 2;
hdr_len += 2;
break;
default:
break;
}
if (length < 2)
goto trunc;
@ -1142,7 +1301,7 @@ ppp_print(register const u_char *p, u_int length)
}
if (eflag)
printf("PPP-%s (0x%04x), length %u: ",
printf("%s (0x%04x), length %u: ",
tok2str(ppptype2str, "unknown", proto),
proto,
olen);
@ -1440,3 +1599,11 @@ ppp_bsdos_if_print(const struct pcap_pkthdr *h _U_, register const u_char *p _U_
#endif /* __bsdi__ */
return (hdrlength);
}
/*
* Local Variables:
* c-style: whitesmith
* c-basic-offset: 8
* End:
*/

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.62.2.2 2003/11/16 08:51:44 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.65 2005/04/06 21:32:42 mcr Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -71,7 +71,7 @@ sl_if_print(const struct pcap_pkthdr *h, const u_char *p)
switch (IP_V(ip)) {
case 4:
ip_print((u_char *)ip, length);
ip_print(gndo, (u_char *)ip, length);
break;
#ifdef INET6
case 6:
@ -106,7 +106,7 @@ sl_bsdos_if_print(const struct pcap_pkthdr *h, const u_char *p)
sliplink_print(p, ip, length);
#endif
ip_print((u_char *)ip, length);
ip_print(gndo, (u_char *)ip, length);
return (SLIP_HDRLEN);
}

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.43.2.2 2003/11/16 08:51:47 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.46 2004/12/27 00:41:31 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -32,13 +32,12 @@ static const char rcsid[] _U_ =
#include <tcpdump-stdinc.h>
#ifdef HAVE_GETRPCBYNUMBER
#include <rpc/rpc.h>
#ifdef HAVE_RPC_RPCENT_H
#include <rpc/rpcent.h>
#endif
#ifndef WIN32
#include <rpc/pmap_prot.h>
#endif /* WIN32 */
#endif /* HAVE_RPC_RPCENT_H */
#endif /* HAVE_GETRPCBYNUMBER */
#include <stdio.h>
#include <string.h>
@ -52,6 +51,9 @@ static const char rcsid[] _U_ =
#include "ip6.h"
#endif
#include "rpc_auth.h"
#include "rpc_msg.h"
static struct tok proc2str[] = {
{ PMAPPROC_NULL, "null" },
{ PMAPPROC_SET, "set" },
@ -69,7 +71,7 @@ void
sunrpcrequest_print(register const u_char *bp, register u_int length,
register const u_char *bp2)
{
register const struct rpc_msg *rp;
register const struct sunrpc_msg *rp;
register const struct ip *ip;
#ifdef INET6
register const struct ip6_hdr *ip6;
@ -77,7 +79,7 @@ sunrpcrequest_print(register const u_char *bp, register u_int length,
u_int32_t x;
char srcid[20], dstid[20]; /*fits 32bit*/
rp = (struct rpc_msg *)bp;
rp = (struct sunrpc_msg *)bp;
if (!nflag) {
snprintf(srcid, sizeof(srcid), "0x%x",
@ -135,7 +137,7 @@ static char *
progstr(prog)
u_int32_t prog;
{
#ifndef WIN32
#ifdef HAVE_GETRPCBYNUMBER
register struct rpcent *rp;
#endif
static char buf[32];
@ -143,12 +145,12 @@ progstr(prog)
if (lastprog != 0 && prog == lastprog)
return (buf);
#ifndef WIN32
#ifdef HAVE_GETRPCBYNUMBER
rp = getrpcbynumber(prog);
if (rp == NULL)
#endif /* WIN32 */
#endif
(void) snprintf(buf, sizeof(buf), "#%u", prog);
#ifndef WIN32
#ifdef HAVE_GETRPCBYNUMBER
else
strlcpy(buf, rp->r_name, sizeof(buf));
#endif

View File

@ -27,7 +27,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.22.2.2 2003/11/16 08:51:51 guy Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.25 2004/03/17 23:24:38 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -187,7 +187,7 @@ token_print(const u_char *p, u_int length, u_int caplen)
/*
* This is the top level routine of the printer. 'p' points
* to the TR header of the packet, 'h->ts' is the timestamp,
* 'h->length' is the length of the packet off the wire, and 'h->caplen'
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.124.2.5 2003/11/19 00:19:25 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.138 2005/04/07 00:28:17 mcr Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -37,8 +37,6 @@ static const char rcsid[] _U_ =
#endif
#include <arpa/tftp.h>
#include <rpc/rpc.h>
#include <stdio.h>
#include <string.h>
@ -54,6 +52,8 @@ static const char rcsid[] _U_ =
#include "ip6.h"
#endif
#include "ipproto.h"
#include "rpc_auth.h"
#include "rpc_msg.h"
#include "nameser.h"
#include "nfs.h"
@ -470,8 +470,8 @@ udp_print(register const u_char *bp, u_int length,
return;
}
if (packettype) {
register struct rpc_msg *rp;
enum msg_type direction;
register struct sunrpc_msg *rp;
enum sunrpc_msg_type direction;
switch (packettype) {
@ -486,9 +486,9 @@ udp_print(register const u_char *bp, u_int length,
break;
case PT_RPC:
rp = (struct rpc_msg *)(up + 1);
direction = (enum msg_type)EXTRACT_32BITS(&rp->rm_direction);
if (direction == CALL)
rp = (struct sunrpc_msg *)(up + 1);
direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
if (direction == SUNRPC_CALL)
sunrpcrequest_print((u_char *)rp, length,
(u_char *)ip);
else
@ -528,7 +528,7 @@ udp_print(register const u_char *bp, u_int length,
#ifdef INET6
ip6 != NULL);
#else
FALSE);
0);
#endif
break;
}
@ -536,24 +536,24 @@ udp_print(register const u_char *bp, u_int length,
}
if (!qflag) {
register struct rpc_msg *rp;
enum msg_type direction;
register struct sunrpc_msg *rp;
enum sunrpc_msg_type direction;
rp = (struct rpc_msg *)(up + 1);
rp = (struct sunrpc_msg *)(up + 1);
if (TTEST(rp->rm_direction)) {
direction = (enum msg_type)EXTRACT_32BITS(&rp->rm_direction);
if (dport == NFS_PORT && direction == CALL) {
direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
if (dport == NFS_PORT && direction == SUNRPC_CALL) {
nfsreq_print((u_char *)rp, length,
(u_char *)ip);
return;
}
if (sport == NFS_PORT && direction == REPLY) {
if (sport == NFS_PORT && direction == SUNRPC_REPLY) {
nfsreply_print((u_char *)rp, length,
(u_char *)ip);
return;
}
#ifdef notdef
if (dport == SUNRPC_PORT && direction == CALL) {
if (dport == SUNRPC_PORT && direction == SUNRPC_CALL) {
sunrpcrequest_print((u_char *)rp, length, (u_char *)ip);
return;
}
@ -570,7 +570,7 @@ udp_print(register const u_char *bp, u_int length,
}
udpipaddr_print(ip, sport, dport);
if (IP_V(ip) == 4 && vflag && !fragmented) {
if (IP_V(ip) == 4 && (vflag > 1) && !fragmented) {
int sum = up->uh_sum;
if (sum == 0) {
(void)printf("[no cksum] ");
@ -615,13 +615,15 @@ udp_print(register const u_char *bp, u_int length,
#ifdef INET6
ip6 != NULL);
#else
FALSE);
0);
#endif
else if (ISPORT(ISAKMP_PORT))
isakmp_print((const u_char *)(up + 1), length, bp2);
else if (ISPORT(ISAKMP_PORT))
isakmp_print(gndo, (const u_char *)(up + 1), length, bp2);
else if (ISPORT(ISAKMP_PORT_NATT))
isakmp_rfc3948_print(gndo, (const u_char *)(up + 1), length, bp2);
#if 1 /*???*/
else if (ISPORT(ISAKMP_PORT_USER1) || ISPORT(ISAKMP_PORT_USER2))
isakmp_print((const u_char *)(up + 1), length, bp2);
else if (ISPORT(ISAKMP_PORT_USER1) || ISPORT(ISAKMP_PORT_USER2))
isakmp_print(gndo, (const u_char *)(up + 1), length, bp2);
#endif
else if (ISPORT(SNMP_PORT) || ISPORT(SNMPTRAP_PORT))
snmp_print((const u_char *)(up + 1), length);
@ -675,14 +677,29 @@ udp_print(register const u_char *bp, u_int length,
else if (ISPORT(LDP_PORT))
ldp_print((const u_char *)(up + 1), length);
else if (ISPORT(MPLS_LSP_PING_PORT))
mpls_lsp_ping_print((const u_char *)(up + 1), length);
lspping_print((const u_char *)(up + 1), length);
else if (dport == BFD_CONTROL_PORT ||
dport == BFD_ECHO_PORT )
bfd_print((const u_char *)(up+1), length, dport);
else if (ISPORT(LMP_PORT))
lmp_print((const u_char *)(up + 1), length);
else if (ISPORT(SIP_PORT))
sip_print((const u_char *)(up + 1), length);
else if (ISPORT(SYSLOG_PORT))
syslog_print((const u_char *)(up + 1), length);
else
(void)printf("UDP, length: %u",
(void)printf("UDP, length %u",
(u_int32_t)(ulen - sizeof(*up)));
#undef ISPORT
} else
(void)printf("UDP, length: %u", (u_int32_t)(ulen - sizeof(*up)));
(void)printf("UDP, length %u", (u_int32_t)(ulen - sizeof(*up)));
}
/*
* Local Variables:
* c-style: whitesmith
* c-basic-offset: 8
* End:
*/

View File

@ -30,6 +30,8 @@
*
*
* @(#) $Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.12 2005/03/27 01:35:45 guy Exp $ (LBL)
*
* $FreeBSD$
*/
/*
@ -122,37 +124,6 @@ typedef char* caddr_t;
#define FOPEN_WRITE_BIN FOPEN_WRITE_TXT
#endif
#if defined(__GNUC__) && defined(__i386__)
#undef ntohl
#undef ntohs
#undef htonl
#undef htons
extern __inline__ unsigned long __ntohl (unsigned long x);
extern __inline__ unsigned short __ntohs (unsigned short x);
#define ntohl(x) __ntohl(x)
#define ntohs(x) __ntohs(x)
#define htonl(x) __ntohl(x)
#define htons(x) __ntohs(x)
extern __inline__ unsigned long __ntohl (unsigned long x)
{
__asm__ ("xchgb %b0, %h0\n\t" /* swap lower bytes */
"rorl $16, %0\n\t" /* swap words */
"xchgb %b0, %h0" /* swap higher bytes */
: "=q" (x) : "0" (x));
return (x);
}
extern __inline__ unsigned short __ntohs (unsigned short x)
{
__asm__ ("xchgb %b0, %h0" /* swap bytes */
: "=q" (x) : "0" (x));
return (x);
}
#endif
#ifndef INET_ADDRSTRLEN
#define INET_ADDRSTRLEN 16
#endif

View File

@ -1,4 +1,4 @@
.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1,v 1.148.2.6 2004/03/28 21:25:03 fenner Exp $ (LBL)
.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1,v 1.167 2004/12/28 22:31:25 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 "7 January 2004"
.TH TCPDUMP 1 "22 March 2004"
.SH NAME
tcpdump \- dump traffic on a network
.SH SYNOPSIS
@ -56,12 +56,16 @@ tcpdump \- dump traffic on a network
.I module
]
[
.B \-r
.I file
.B \-M
.I secret
]
.br
.ti +8
[
.B \-r
.I file
]
[
.B \-s
.I snaplen
]
@ -76,6 +80,12 @@ tcpdump \- dump traffic on a network
.br
.ti +8
[
.B \-W
.I filecount
]
.br
.ti +8
[
.B \-E
.I spi@ipaddr algo:secret,...
]
@ -85,6 +95,10 @@ tcpdump \- dump traffic on a network
.B \-y
.I datalinktype
]
[
.B \-Z
.I user
]
.ti +8
[
.B \-y
@ -250,7 +264,7 @@ currently larger than \fIfile_size\fP and, if so, close the current
savefile and open a new one. Savefiles after the first savefile will
have the name specified with the
.B \-w
flag, with a number after it, starting at 2 and continuing upward.
flag, with a number after it, starting at 1 and continuing upward.
The units of \fIfile_size\fP are millions of bytes (1,000,000 bytes,
not 1,048,576 bytes).
.TP
@ -384,6 +398,10 @@ Load SMI MIB module definitions from file \fImodule\fR.
This option
can be used several times to load several MIB modules into \fItcpdump\fP.
.TP
.B \-M
Use \fIsecret\fP as a shared secret for validating the digests found in
TCP segments with the TCP-MD5 option (RFC 2385), if present.
.TP
.B \-n
Don't convert addresses (i.e., host addresses, port numbers, etc.) to names.
.TP
@ -493,11 +511,15 @@ that lacks the
function.
.TP
.B \-v
(Slightly more) verbose output.
When parsing and printing, produce (slightly more) verbose output.
For example, the time to live,
identification, total length and options in an IP packet are printed.
Also enables additional packet integrity checks such as verifying the
IP and ICMP header checksum.
.IP
When writing to a file with the
.B \-w
option, report, every 10 seconds, the number of packets captured.
.TP
.B \-vv
Even more verbose output.
@ -519,6 +541,16 @@ them out.
They can later be printed with the \-r option.
Standard output is used if \fIfile\fR is ``-''.
.TP
.B \-W
Used in conjunction with the
.I \-C
option, this will limit the number
of files created to the specified number, and begin overwriting files
from the beginning, thus creating a 'rotating' buffer.
In addition, it will name
the files with enough leading 0s to support the maximum number of
files, allowing them to sort correctly.
.TP
.B \-x
Print each packet (minus its link level header) in hex.
The smaller of the entire packet or
@ -544,6 +576,14 @@ its link level header, in hex and ASCII.
.TP
.B \-y
Set the data link type to use while capturing packets to \fIdatalinktype\fP.
.TP
.B \-Z
Drops privileges (if root) and changes user ID to
.I user
and the group ID to the primary group of
.IR user .
.IP
This behavior can also be enabled by default at compile time.
.IP "\fI expression\fP"
.RS
selects which packets will be dumped.
@ -685,18 +725,18 @@ which is equivalent to:
If \fIhost\fR is a name with multiple IP addresses, each address will
be checked for a match.
.IP "\fBether dst \fIehost\fP
True if the ethernet destination address is \fIehost\fP.
True if the Ethernet destination address is \fIehost\fP.
\fIEhost\fP
may be either a name from /etc/ethers or a number (see
.IR ethers (3N)
for numeric format).
.IP "\fBether src \fIehost\fP
True if the ethernet source address is \fIehost\fP.
True if the Ethernet source address is \fIehost\fP.
.IP "\fBether host \fIehost\fP
True if either the ethernet source or destination address is \fIehost\fP.
True if either the Ethernet source or destination address is \fIehost\fP.
.IP "\fBgateway\fP \fIhost\fP
True if the packet used \fIhost\fP as a gateway.
I.e., the ethernet
I.e., the Ethernet
source or destination address was \fIhost\fP but neither the IP source
nor the IP destination was \fIhost\fP.
\fIHost\fP must be a name and
@ -776,9 +816,9 @@ True if the packet is an IP packet (see
.IR ip (4P))
of protocol type \fIprotocol\fP.
\fIProtocol\fP can be a number or one of the names
\fIicmp\fP, \fIicmp6\fP, \fIigmp\fP, \fIigrp\fP, \fIpim\fP, \fIah\fP,
\fIesp\fP, \fIvrrp\fP, \fIudp\fP, or \fItcp\fP.
Note that the identifiers \fItcp\fP, \fIudp\fP, and \fIicmp\fP are also
\fBicmp\fP, \fBicmp6\fP, \fBigmp\fP, \fBigrp\fP, \fBpim\fP, \fBah\fP,
\fBesp\fP, \fBvrrp\fP, \fBudp\fP, or \fBtcp\fP.
Note that the identifiers \fBtcp\fP, \fBudp\fP, and \fBicmp\fP are also
keywords and must be escaped via backslash (\\), which is \\\\ in the C-shell.
Note that this primitive does not chase the protocol header chain.
.IP "\fBip6 proto \fIprotocol\fR"
@ -804,7 +844,7 @@ so this can be somewhat slow.
.IP "\fBip protochain \fIprotocol\fR"
Equivalent to \fBip6 protochain \fIprotocol\fR, but this is for IPv4.
.IP "\fBether broadcast\fR"
True if the packet is an ethernet broadcast packet.
True if the packet is an Ethernet broadcast packet.
The \fIether\fP
keyword is optional.
.IP "\fBip broadcast\fR"
@ -819,8 +859,8 @@ done has no netmask or because the capture is being done on the Linux
"any" interface, which can capture on more than one interface, this
check will not work correctly.
.IP "\fBether multicast\fR"
True if the packet is an ethernet multicast packet.
The \fIether\fP
True if the packet is an Ethernet multicast packet.
The \fBether\fP
keyword is optional.
This is shorthand for `\fBether[0] & 1 != 0\fP'.
.IP "\fBip multicast\fR"
@ -830,9 +870,9 @@ True if the packet is an IPv6 multicast packet.
.IP "\fBether proto \fIprotocol\fR"
True if the packet is of ether type \fIprotocol\fR.
\fIProtocol\fP can be a number or one of the names
\fIip\fP, \fIip6\fP, \fIarp\fP, \fIrarp\fP, \fIatalk\fP, \fIaarp\fP,
\fIdecnet\fP, \fIsca\fP, \fIlat\fP, \fImopdl\fP, \fImoprc\fP,
\fIiso\fP, \fIstp\fP, \fIipx\fP, or \fInetbeui\fP.
\fBip\fP, \fBip6\fP, \fBarp\fP, \fBrarp\fP, \fBatalk\fP, \fBaarp\fP,
\fBdecnet\fP, \fBsca\fP, \fBlat\fP, \fBmopdl\fP, \fBmoprc\fP,
\fBiso\fP, \fBstp\fP, \fBipx\fP, or \fBnetbeui\fP.
Note these identifiers are also keywords
and must be escaped via backslash (\\).
.IP
@ -855,10 +895,10 @@ The exceptions are:
\fItcpdump\fR checks the DSAP (Destination Service Access Point) and
SSAP (Source Service Access Point) fields of the LLC header;
.TP
\fBstp\fP and \fInetbeui\fP
\fBstp\fP and \fBnetbeui\fP
\fItcpdump\fR checks the DSAP of the LLC header;
.TP
\fIatalk\fP
\fBatalk\fP
\fItcpdump\fR checks for a SNAP-format packet with an OUI of 0x080007
and the AppleTalk etype.
.RE
@ -867,7 +907,7 @@ In the case of Ethernet, \fItcpdump\fR checks the Ethernet type field
for most of those protocols. The exceptions are:
.RS
.TP
\fBiso\fP, \fBsap\fP, and \fBnetbeui\fP
\fBiso\fP, \fBstp\fP, and \fBnetbeui\fP
\fItcpdump\fR checks for an 802.3 frame and then checks the LLC header as
it does for FDDI, Token Ring, and 802.11;
.TP
@ -985,7 +1025,7 @@ where \fIp\fR is one of the above protocols.
.IP "\fBiso proto \fIprotocol\fR"
True if the packet is an OSI packet of protocol type \fIprotocol\fP.
\fIProtocol\fP can be a number or one of the names
\fIclnp\fP, \fIesis\fP, or \fIisis\fP.
\fBclnp\fP, \fBesis\fP, or \fBisis\fP.
.IP "\fBclnp\fR, \fBesis\fR, \fBisis\fR"
Abbreviations for:
.in +.5i
@ -1053,7 +1093,8 @@ True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =,
!=, and \fIexpr\fR is an arithmetic expression composed of integer
constants (expressed in standard C syntax), the normal binary operators
[+, -, *, /, &, |, <<, >>], a length operator, and special packet data
accessors.
accessors. Note that all comparisons are unsigned, so that, for example,
0x80000000 and 0xffffffff are > 0.
To access
data inside the packet, use the following syntax:
.in +.5i
@ -1207,6 +1248,16 @@ tcpdump 'tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 and not src and dst net \fIlocal
.fi
.RE
.LP
To print all IPv4 HTTP packets to and from port 80, i.e. print only
packets that contain data, not, for example, SYN and FIN packets and
ACK-only packets. (IPv6 is left as an exercise for the reader.)
.RS
.nf
.B
tcpdump 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
.fi
.RE
.LP
To print IP packets longer than 576 bytes sent through gateway \fIsnup\fP:
.RS
.nf
@ -1217,7 +1268,7 @@ tcpdump 'gateway snup and ip[2:2] > 576'
.LP
To print IP broadcast or multicast packets that were
.I not
sent via ethernet broadcast or multicast:
sent via Ethernet broadcast or multicast:
.RS
.nf
.B
@ -1246,7 +1297,7 @@ gives a brief description and examples of most of the formats.
Link Level Headers
.LP
If the '-e' option is given, the link level header is printed out.
On ethernets, the source and destination addresses, protocol,
On Ethernets, the source and destination addresses, protocol,
and packet length are printed.
.LP
On FDDI networks, the '-e' option causes \fItcpdump\fP to print
@ -1324,9 +1375,9 @@ arp reply csam is-at CSAM\fR
.fi
.RE
The first line says that rtsg sent an arp packet asking
for the ethernet address of internet host csam.
for the Ethernet address of internet host csam.
Csam
replies with its ethernet address (in this example, ethernet addresses
replies with its Ethernet address (in this example, Ethernet addresses
are in caps and internet addresses in lower case).
.LP
This would look less redundant if we had done \fItcpdump \-n\fP:
@ -1348,8 +1399,8 @@ CSAM RTSG 0806 64: arp reply csam is-at CSAM\fR
.sp .5
.fi
.RE
For the first packet this says the ethernet source address is RTSG, the
destination is the ethernet broadcast address, the type field
For the first packet this says the Ethernet source address is RTSG, the
destination is the Ethernet broadcast address, the type field
contained hex 0806 (type ETHER_ARP) and the total length was 64 bytes.
.HD
TCP Packets
@ -1777,11 +1828,6 @@ Be warned that with -v a single SMB packet
may take up a page or more, so only use -v if you really want all the
gory details.
If you are decoding SMB sessions containing unicode strings then you
may wish to set the environment variable USE_UNICODE to 1.
A patch to
auto-detect unicode strings would be welcome.
For information on SMB packet formats and what all te fields mean see
www.cifs.org or the pub/samba/specs/ directory on your favorite
samba.org mirror site.
@ -2136,7 +2182,7 @@ and is as accurate as the kernel's clock.
The timestamp reflects the time the kernel first saw the packet.
No attempt
is made to account for the time lag between when the
ethernet interface removed the packet from the wire and when the kernel
Ethernet interface removed the packet from the wire and when the kernel
serviced the `new packet' interrupt.
.SH "SEE ALSO"
bpf(4), pcap(3)

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.216.2.10 2004/03/17 19:47:48 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.253 2005/01/27 18:30:36 hannes Exp $ (LBL)";
#endif
/* $FreeBSD$ */
@ -58,12 +58,22 @@ extern int SIZE_BUF;
#define uint UINT
#endif /* WIN32 */
#ifdef HAVE_SMI_H
#include <smi.h>
#endif
#include <pcap.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef WIN32
#include <pwd.h>
#include <grp.h>
#include <errno.h>
#endif /* WIN32 */
#include "netdissect.h"
#include "interface.h"
#include "addrtoname.h"
#include "machdep.h"
@ -71,33 +81,19 @@ extern int SIZE_BUF;
#include "gmt2local.h"
#include "pcap-missing.h"
netdissect_options Gndo;
netdissect_options *gndo = &Gndo;
/*
* Define the maximum number of files for the -C flag, and how many
* characters can be added to a filename for the -C flag (which
* should be enough to handle MAX_CFLAG - 1).
*/
#define MAX_CFLAG 1000000
#define MAX_CFLAG_CHARS 6
int dflag; /* print filter code */
int eflag; /* print ethernet header */
int fflag; /* don't translate "foreign" IP address */
int Lflag; /* list available data link types and exit */
int nflag; /* leave addresses as numbers */
int Nflag; /* remove domains from printed host names */
int Oflag = 1; /* run filter code optimizer */
int pflag; /* don't go promiscuous */
int qflag; /* quick (shorter) output */
int Rflag = 1; /* print sequence # field in AH/ESP*/
int sflag = 0; /* use the libsmi to translate OIDs */
int Sflag; /* print raw TCP sequence numbers */
int tflag = 1; /* print packet arrival time */
int Uflag = 0; /* "unbuffered" output of dump files */
int uflag = 0; /* Print undecoded NFS handles */
int vflag; /* verbose */
int xflag; /* print packet in hex */
int Xflag; /* print packet in ascii as well as hex */
off_t Cflag = 0; /* rotate dump files after this many bytes */
int Aflag = 0; /* print packet only in ascii observing LF, CR, TAB, SPACE */
int dlt = -1; /* if != -1, ask libpcap for the DLT it names */
const char *dlt_name = NULL;
char *espsecret = NULL; /* ESP secret key */
int packettype;
static int infodelay;
static int infoprint;
@ -112,19 +108,28 @@ static void usage(void) __attribute__((noreturn));
static void show_dlts_and_exit(pcap_t *pd) __attribute__((noreturn));
static void print_packet(u_char *, const struct pcap_pkthdr *, const u_char *);
static void ndo_default_print(netdissect_options *, const u_char *, u_int);
static void dump_packet_and_trunc(u_char *, const struct pcap_pkthdr *, const u_char *);
static void dump_packet(u_char *, const struct pcap_pkthdr *, const u_char *);
static void droproot(const char *, const char *);
static void ndo_error(netdissect_options *ndo, const char *fmt, ...);
static void ndo_warning(netdissect_options *ndo, const char *fmt, ...);
#ifdef SIGINFO
RETSIGTYPE requestinfo(int);
#endif
#if defined(USE_WIN32_MM_TIMER)
#include <MMsystem.h>
static UINT timer_id;
static void CALLBACK verbose_stats_dump(UINT, UINT, DWORD_PTR, DWORD_PTR, DWORD_PTR);
#elif defined(HAVE_ALARM)
static void verbose_stats_dump(int sig);
#endif
static void info(int);
static u_int packets_captured;
/* Length of saved portion of packet. */
int snaplen = DEFAULT_SNAPLEN;
typedef u_int (*if_printer)(const struct pcap_pkthdr *, const u_char *);
struct printer {
@ -153,6 +158,9 @@ static struct printer printers[] = {
{ sl_bsdos_if_print, DLT_SLIP_BSDOS },
#endif
{ ppp_if_print, DLT_PPP },
#ifdef DLT_PPP_WITHDIRECTION
{ ppp_if_print, DLT_PPP_WITHDIRECTION },
#endif
#ifdef DLT_PPP_BSDOS
{ ppp_bsdos_if_print, DLT_PPP_BSDOS },
#endif
@ -208,8 +216,23 @@ static struct printer printers[] = {
#ifdef DLT_ENC
{ enc_if_print, DLT_ENC },
#endif
#ifdef DLT_SYMANTEC_FIREWALL
{ symantec_if_print, DLT_SYMANTEC_FIREWALL },
#endif
#ifdef DLT_APPLE_IP_OVER_IEEE1394
{ ap1394_if_print, DLT_APPLE_IP_OVER_IEEE1394 },
#endif
#ifdef DLT_JUNIPER_ATM1
{ juniper_atm1_print, DLT_JUNIPER_ATM1 },
#endif
#ifdef DLT_JUNIPER_ATM2
{ juniper_atm2_print, DLT_JUNIPER_ATM2 },
#endif
#ifdef DLT_JUNIPER_MLFR
{ juniper_mlfr_print, DLT_JUNIPER_MLFR },
#endif
#ifdef DLT_JUNIPER_MLPPP
{ juniper_mlppp_print, DLT_JUNIPER_MLPPP },
#endif
{ NULL, 0 },
};
@ -291,6 +314,12 @@ show_dlts_and_exit(pcap_t *pd)
#define B_FLAG_USAGE
#endif /* WIN32 */
#ifdef HAVE_PCAP_FINDALLDEVS
#ifndef HAVE_PCAP_IF_T
#undef HAVE_PCAP_FINDALLDEVS
#endif
#endif
#ifdef HAVE_PCAP_FINDALLDEVS
#define D_FLAG "D"
#else
@ -303,12 +332,89 @@ show_dlts_and_exit(pcap_t *pd)
#define U_FLAG
#endif
#ifndef WIN32
/* Drop root privileges and chroot if necessary */
static void
droproot(const char *username, const char *chroot_dir)
{
struct passwd *pw = NULL;
if (chroot_dir && !username) {
fprintf(stderr, "tcpdump: Chroot without dropping root is insecure\n");
exit(1);
}
pw = getpwnam(username);
if (pw) {
if (chroot_dir) {
if (chroot(chroot_dir) != 0 || chdir ("/") != 0) {
fprintf(stderr, "tcpdump: Couldn't chroot/chdir to '%.64s': %s\n",
chroot_dir, pcap_strerror(errno));
exit(1);
}
}
if (initgroups(pw->pw_name, pw->pw_gid) != 0 ||
setgid(pw->pw_gid) != 0 || setuid(pw->pw_uid) != 0) {
fprintf(stderr, "tcpdump: Couldn't change to '%.32s' uid=%lu gid=%lu: %s\n",
username,
(unsigned long)pw->pw_uid,
(unsigned long)pw->pw_gid,
pcap_strerror(errno));
exit(1);
}
}
else {
fprintf(stderr, "tcpdump: Couldn't find user '%.32s'\n",
username);
exit(1);
}
}
#endif /* WIN32 */
static int
getWflagChars(int x)
{
int c = 0;
x -= 1;
while (x > 0) {
c += 1;
x /= 10;
}
return c;
}
static void
MakeFilename(char *buffer, char *orig_name, int cnt, int max_chars)
{
if (cnt == 0 && max_chars == 0)
strcpy(buffer, orig_name);
else
sprintf(buffer, "%s%0*d", orig_name, max_chars, cnt);
}
static int tcpdump_printf(netdissect_options *ndo _U_,
const char *fmt, ...)
{
va_list args;
int ret;
va_start(args, fmt);
ret=vfprintf(stdout, fmt, args);
va_end(args);
return ret;
}
int
main(int argc, char **argv)
{
register int cnt, op, i;
bpf_u_int32 localnet, netmask;
register char *cp, *infile, *cmdbuf, *device, *RFileName, *WFileName;
register char *cp, *infile, *cmdbuf, *device, *RFileName, *WFileName, *WFileNameAlt;
pcap_handler callback;
int type;
struct bpf_program fcode;
@ -319,6 +425,8 @@ main(int argc, char **argv)
struct dump_info dumpinfo;
u_char *pcap_userdata;
char ebuf[PCAP_ERRBUF_SIZE];
char *username = NULL;
char *chroot_dir = NULL;
#ifdef HAVE_PCAP_FINDALLDEVS
pcap_if_t *devpointer;
int devnum;
@ -329,6 +437,15 @@ main(int argc, char **argv)
if(wsockinit() != 0) return 1;
#endif /* WIN32 */
gndo->ndo_Oflag=1;
gndo->ndo_Rflag=1;
gndo->ndo_dlt=-1;
gndo->ndo_default_print=ndo_default_print;
gndo->ndo_printf=tcpdump_printf;
gndo->ndo_error=ndo_error;
gndo->ndo_warning=ndo_warning;
gndo->ndo_snaplen = DEFAULT_SNAPLEN;
cnt = -1;
device = NULL;
infile = NULL;
@ -348,7 +465,7 @@ main(int argc, char **argv)
opterr = 0;
while (
(op = getopt(argc, argv, "aA" B_FLAG "c:C:d" D_FLAG "eE:fF:i:lLm:nNOpqr:Rs:StT:u" U_FLAG "vw:xXy:Y")) != -1)
(op = getopt(argc, argv, "aA" B_FLAG "c:C:d" D_FLAG "eE:fF:i:lLm:M:nNOpqr:Rs:StT:u" U_FLAG "vw:W:xXy:YZ:")) != -1)
switch (op) {
case 'a':
@ -413,7 +530,7 @@ main(int argc, char **argv)
#ifndef HAVE_LIBCRYPTO
warning("crypto code not compiled in");
#endif
espsecret = optarg;
gndo->ndo_espsecret = optarg;
break;
case 'f':
@ -501,6 +618,14 @@ main(int argc, char **argv)
#endif
break;
case 'M':
/* TCP-MD5 shared secret */
#ifndef HAVE_LIBCRYPTO
warning("crypto code not compiled in");
#endif
tcpmd5secret = optarg;
break;
case 'O':
Oflag = 0;
break;
@ -538,7 +663,7 @@ main(int argc, char **argv)
break;
case 't':
--tflag;
++tflag;
break;
case 'T':
@ -582,20 +707,27 @@ main(int argc, char **argv)
WFileName = optarg;
break;
case 'W':
Wflag = atoi(optarg);
if (Wflag < 0)
error("invalid number of output files %s", optarg);
WflagChars = getWflagChars(Wflag);
break;
case 'x':
++xflag;
break;
case 'X':
++xflag;
++Xflag;
break;
case 'y':
dlt_name = optarg;
dlt = pcap_datalink_name_to_val(dlt_name);
if (dlt < 0)
error("invalid data link type %s", dlt_name);
gndo->ndo_dltname = optarg;
gndo->ndo_dlt =
pcap_datalink_name_to_val(gndo->ndo_dltname);
if (gndo->ndo_dlt < 0)
error("invalid data link type %s", gndo->ndo_dltname);
break;
#if defined(HAVE_PCAP_DEBUG) || defined(HAVE_YYDEBUG)
@ -612,13 +744,55 @@ main(int argc, char **argv)
}
break;
#endif
case 'Z':
if (optarg) {
username = strdup(optarg);
}
else {
usage();
/* NOTREACHED */
}
break;
default:
usage();
/* NOTREACHED */
}
if (tflag > 0)
switch (tflag) {
case 0: /* Default */
case 4: /* Default + Date*/
thiszone = gmt2local(0);
break;
case 1: /* No time stamp */
case 2: /* Unix timeval style */
case 3: /* Microseconds since previous packet */
break;
default: /* Not supported */
error("only -t, -tt, -ttt, and -tttt are supported");
break;
}
#ifdef WITH_CHROOT
/* if run as root, prepare for chrooting */
if (getuid() == 0 || geteuid() == 0) {
/* future extensibility for cmd-line arguments */
if (!chroot_dir)
chroot_dir = WITH_CHROOT;
}
#endif
#ifdef WITH_USER
/* if run as root, prepare for dropping root privileges */
if (getuid() == 0 || geteuid() == 0) {
/* Run with '-Z root' to restore old behaviour */
if (!username)
username = WITH_USER;
}
#endif
if (RFileName != NULL) {
int dlt;
@ -634,7 +808,8 @@ main(int argc, char **argv)
* people's trace files (especially if we're set-UID
* root).
*/
setuid(getuid());
if (setgid(getgid()) != 0 || setuid(getuid()) != 0 )
fprintf(stderr, "Warning: setgid/setuid failed !\n");
#endif /* WIN32 */
pd = pcap_open_offline(RFileName, ebuf);
if (pd == NULL)
@ -661,11 +836,8 @@ main(int argc, char **argv)
error("%s", ebuf);
}
#ifdef WIN32
if(IsTextUnicode(device,
wcslen((short*)device), // Device always ends with a double \0, so this way to determine its
// length should be always valid
NULL))
{
if(strlen(device) == 1) //we assume that an ASCII string is always longer than 1 char
{ //a Unicode string has a \0 as second byte (so strlen() is 1)
fprintf(stderr, "%s: listening on %ws\n", program_name, device);
}
else
@ -681,11 +853,24 @@ main(int argc, char **argv)
error("%s", ebuf);
else if (*ebuf)
warning("%s", ebuf);
/*
* Let user own process after socket has been opened.
*/
#ifndef WIN32
if (setgid(getgid()) != 0 || setuid(getuid()) != 0)
fprintf(stderr, "Warning: setgid/setuid failed !\n");
#endif /* WIN32 */
#ifdef WIN32
if(UserBufferSize != 1000000)
if(pcap_setbuff(pd, UserBufferSize)==-1){
error("%s", pcap_geterr(pd));
}
#endif /* WIN32 */
if (Lflag)
show_dlts_and_exit(pd);
if (dlt >= 0) {
if (gndo->ndo_dlt >= 0) {
#ifdef HAVE_PCAP_SET_DATALINK
if (pcap_set_datalink(pd, dlt) < 0)
if (pcap_set_datalink(pd, gndo->ndo_dlt) < 0)
error("%s", pcap_geterr(pd));
#else
/*
@ -693,13 +878,13 @@ main(int argc, char **argv)
* data link type, so we only let them
* set it to what it already is.
*/
if (dlt != pcap_datalink(pd)) {
if (gndo->ndo_dlt != pcap_datalink(pd)) {
error("%s is not one of the DLTs supported by this device\n",
dlt_name);
gndo->ndo_dltname);
}
#endif
(void)fprintf(stderr, "%s: data link type %s\n",
program_name, dlt_name);
program_name, gndo->ndo_dltname);
(void)fflush(stderr);
}
i = pcap_snapshot(pd);
@ -712,12 +897,6 @@ main(int argc, char **argv)
netmask = 0;
warning("%s", ebuf);
}
/*
* Let user own process after socket has been opened.
*/
#ifndef WIN32
setuid(getuid());
#endif /* WIN32 */
}
if (infile)
cmdbuf = read_infile(infile);
@ -747,7 +926,13 @@ main(int argc, char **argv)
if (pcap_setfilter(pd, &fcode) < 0)
error("%s", pcap_geterr(pd));
if (WFileName) {
pcap_dumper_t *p = pcap_dump_open(pd, WFileName);
pcap_dumper_t *p;
WFileNameAlt = (char *)malloc(strlen(WFileName) + MAX_CFLAG_CHARS + 1);
if (WFileNameAlt == NULL)
error("malloc of WFileNameAlt");
MakeFilename(WFileNameAlt, WFileName, 0, WflagChars);
p = pcap_dump_open(pd, WFileNameAlt);
if (p == NULL)
error("%s", pcap_geterr(pd));
if (Cflag != 0) {
@ -764,18 +949,46 @@ main(int argc, char **argv)
type = pcap_datalink(pd);
printinfo.printer = lookup_printer(type);
if (printinfo.printer == NULL) {
dlt_name = pcap_datalink_val_to_name(type);
if (dlt_name != NULL)
error("unsupported data link type %s", dlt_name);
gndo->ndo_dltname = pcap_datalink_val_to_name(type);
if (gndo->ndo_dltname != NULL)
error("unsupported data link type %s",
gndo->ndo_dltname);
else
error("unsupported data link type %d", type);
}
callback = print_packet;
pcap_userdata = (u_char *)&printinfo;
}
#ifndef WIN32
/*
* We cannot do this earlier, because we want to be able to open
* the file (if done) for writing before giving up permissions.
*/
if (getuid() == 0 || geteuid() == 0) {
if (username || chroot_dir)
droproot(username, chroot_dir);
}
#endif /* WIN32 */
#ifdef SIGINFO
(void)setsignal(SIGINFO, requestinfo);
#endif
if (vflag > 0 && WFileName) {
/*
* When capturing to a file, "-v" means tcpdump should,
* every 10 secodns, "v"erbosely report the number of
* packets captured.
*/
#ifdef USE_WIN32_MM_TIMER
/* call verbose_stats_dump() each 1000 +/-100msec */
timer_id = timeSetEvent(1000, 100, verbose_stats_dump, 0, TIME_PERIODIC);
setvbuf(stderr, NULL, _IONBF, 0);
#elif defined(HAVE_ALARM)
(void)setsignal(SIGALRM, verbose_stats_dump);
alarm(1);
#endif
}
#ifndef WIN32
if (RFileName == NULL) {
int dlt;
@ -838,6 +1051,14 @@ main(int argc, char **argv)
static RETSIGTYPE
cleanup(int signo _U_)
{
#ifdef USE_WIN32_MM_TIMER
if (timer_id)
timeKillEvent(timer_id);
timer_id = 0;
#elif defined(HAVE_ALARM)
alarm(0);
#endif
#ifdef HAVE_PCAP_BREAKLOOP
/*
* We have "pcap_breakloop()"; use it, so that we do as little
@ -894,38 +1115,10 @@ info(register int verbose)
infoprint = 0;
}
static void
reverse(char *s)
{
int i, j, c;
for (i = 0, j = strlen(s) - 1; i < j; i++, j--) {
c = s[i];
s[i] = s[j];
s[j] = c;
}
}
static void
swebitoa(unsigned int n, char *s)
{
unsigned int i;
i = 0;
do {
s[i++] = n % 10 + '0';
} while ((n /= 10) > 0);
s[i] = '\0';
reverse(s);
}
static void
dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
{
struct dump_info *dump_info;
static uint cnt = 2;
char *name;
++packets_captured;
@ -944,14 +1137,18 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
* Close the current file and open a new one.
*/
pcap_dump_close(dump_info->p);
if (cnt >= 1000)
error("too many output files");
name = (char *) malloc(strlen(dump_info->WFileName) + 4);
Cflag_count++;
if (Wflag > 0) {
if (Cflag_count >= Wflag)
Cflag_count = 0;
} else {
if (Cflag_count >= MAX_CFLAG)
error("too many output files");
}
name = (char *)malloc(strlen(dump_info->WFileName) + MAX_CFLAG_CHARS + 1);
if (name == NULL)
error("dump_packet_and_trunc: malloc");
strcpy(name, dump_info->WFileName);
swebitoa(cnt, name + strlen(dump_info->WFileName));
cnt++;
MakeFilename(name, dump_info->WFileName, Cflag_count, WflagChars);
dump_info->p = pcap_dump_open(dump_info->pd, name);
free(name);
if (dump_info->p == NULL)
@ -1016,7 +1213,7 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
/*
* Include the link-layer header.
*/
default_print(sp, h->caplen);
hex_print("\n\t", sp, h->caplen);
} else {
/*
* Don't include the link-layer header - and if
@ -1024,7 +1221,26 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
* print nothing.
*/
if (h->caplen > hdrlen)
default_print(sp + hdrlen,
hex_print("\n\t", sp + hdrlen,
h->caplen - hdrlen);
}
} else if (Xflag) {
/*
* Print the raw packet data.
*/
if (Xflag > 1) {
/*
* Include the link-layer header.
*/
ascii_print("\n\t", sp, h->caplen);
} else {
/*
* Don't include the link-layer header - and if
* we have nothing past the link-layer header,
* print nothing.
*/
if (h->caplen > hdrlen)
ascii_print("\n\t", sp + hdrlen,
h->caplen - hdrlen);
}
}
@ -1056,18 +1272,26 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
* "Wpcap_version" information on Windows.
*/
char WDversion[]="current-cvs.tcpdump.org";
#if !defined(HAVE_GENERATED_VERSION)
char version[]="current-cvs.tcpdump.org";
#endif
char pcap_version[]="current-cvs.tcpdump.org";
char Wpcap_version[]="3.0 alpha";
char Wpcap_version[]="3.1";
#endif
/*
* By default, print the specified data out in hex.
*/
void
default_print(register const u_char *bp, register u_int length)
static void
ndo_default_print(netdissect_options *ndo _U_, const u_char *bp, u_int length)
{
ascii_print("\n\t", bp, length); /* pass on lf and identation string */
ascii_print("\n\t", bp, length); /* pass on lf and identation string */
}
void
default_print(const u_char *bp, u_int length)
{
ndo_default_print(gndo, bp, length);
}
#ifdef SIGINFO
@ -1080,6 +1304,29 @@ RETSIGTYPE requestinfo(int signo _U_)
}
#endif
/*
* Called once each second in verbose mode while dumping to file
*/
#ifdef USE_WIN32_MM_TIMER
void CALLBACK verbose_stats_dump (UINT timer_id _U_, UINT msg _U_, DWORD_PTR arg _U_,
DWORD_PTR dw1 _U_, DWORD_PTR dw2 _U_)
{
struct pcap_stat stat;
if (infodelay == 0 && pcap_stats(pd, &stat) >= 0)
fprintf(stderr, "Got %u\r", packets_captured);
}
#elif defined(HAVE_ALARM)
static void verbose_stats_dump(int sig _U_)
{
struct pcap_stat stat;
if (infodelay == 0 && pcap_stats(pd, &stat) >= 0)
fprintf(stderr, "Got %u\r", packets_captured);
alarm(1);
}
#endif
static void
usage(void)
{
@ -1093,8 +1340,12 @@ usage(void)
#endif /* HAVE_PCAP_LIB_VERSION */
#ifdef HAVE_PCAP_LIB_VERSION
#ifdef WIN32
(void)fprintf(stderr, "%s version %s, based on tcpdump version %s\n", program_name, WDversion, version);
#else /* WIN32 */
(void)fprintf(stderr, "%s version %s\n", program_name, version);
(void)fprintf(stderr, "%s\n", pcap_lib_version());
#endif /* WIN32 */
(void)fprintf(stderr, "%s\n",pcap_lib_version());
#else /* HAVE_PCAP_LIB_VERSION */
#ifdef WIN32
(void)fprintf(stderr, "%s version %s, based on tcpdump version %s\n", program_name, WDversion, version);
@ -1107,10 +1358,51 @@ usage(void)
(void)fprintf(stderr,
"Usage: %s [-aAd" D_FLAG "eflLnNOpqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [-c count] [ -C file_size ]\n", program_name);
(void)fprintf(stderr,
"\t\t[ -E algo:secret ] [ -F file ] [ -i interface ] [ -r file ]\n");
"\t\t[ -E algo:secret ] [ -F file ] [ -i interface ] [ -M secret ]\n");
(void)fprintf(stderr,
"\t\t[ -s snaplen ] [ -T type ] [ -w file ] [ -y datalinktype ]\n");
"\t\t[ -r file ] [ -s snaplen ] [ -T type ] [ -w file ]\n");
(void)fprintf(stderr,
"\t\t[ -W filecount ] [ -y datalinktype ] [ -Z user ]\n");
(void)fprintf(stderr,
"\t\t[ expression ]\n");
exit(1);
}
/* VARARGS */
static void
ndo_error(netdissect_options *ndo _U_, const char *fmt, ...)
{
va_list ap;
(void)fprintf(stderr, "%s: ", program_name);
va_start(ap, fmt);
(void)vfprintf(stderr, fmt, ap);
va_end(ap);
if (*fmt) {
fmt += strlen(fmt);
if (fmt[-1] != '\n')
(void)fputc('\n', stderr);
}
exit(1);
/* NOTREACHED */
}
/* VARARGS */
static void
ndo_warning(netdissect_options *ndo _U_, const char *fmt, ...)
{
va_list ap;
(void)fprintf(stderr, "%s: WARNING: ", program_name);
va_start(ap, fmt);
(void)vfprintf(stderr, fmt, ap);
va_end(ap);
if (*fmt) {
fmt += strlen(fmt);
if (fmt[-1] != '\n')
(void)fputc('\n', stderr);
}
}