mirror of
https://github.com/the-tcpdump-group/tcpdump.git
synced 2024-11-23 10:04:05 +08:00
NDOize ARCNET, BFD and GRE decoders
This commit is contained in:
parent
0b08cf5378
commit
cf90fd1a84
@ -197,8 +197,6 @@ extern void dvmrp_print(const u_char *, u_int);
|
||||
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 *);
|
||||
extern u_int arcnet_linux_if_print(const struct pcap_pkthdr *, const u_char *);
|
||||
extern u_int token_print(const u_char *, u_int, u_int);
|
||||
extern u_int token_if_print(const struct pcap_pkthdr *, const u_char *);
|
||||
extern void fddi_print(const u_char *, u_int, u_int);
|
||||
@ -213,7 +211,6 @@ extern u_int ieee802_11_radio_if_print(const struct pcap_pkthdr *,
|
||||
const u_char *);
|
||||
extern u_int ieee802_11_radio_avs_if_print(const struct pcap_pkthdr *,
|
||||
const u_char *);
|
||||
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 ipN_print(const u_char *, u_int);
|
||||
@ -315,7 +312,6 @@ extern void mpls_lsp_ping_print(const u_char *, u_int);
|
||||
extern void zephyr_print(const u_char *, int);
|
||||
extern void zmtp1_print(const u_char *, u_int);
|
||||
extern void zmtp1_print_datagram(const u_char *, const 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);
|
||||
extern int mptcp_print(const u_char *, u_int, u_char);
|
||||
|
@ -387,6 +387,10 @@ extern u_int lane_if_print(netdissect_options *, const struct pcap_pkthdr *, con
|
||||
extern void otv_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void ahcp_print(netdissect_options *, const u_char *, const u_int);
|
||||
extern void vxlan_print(netdissect_options *, const u_char *, u_int);
|
||||
extern u_int arcnet_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
|
||||
extern u_int arcnet_linux_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
|
||||
extern void bfd_print(netdissect_options *, const u_char *, u_int, u_int);
|
||||
extern void gre_print(netdissect_options *, const u_char *, u_int);
|
||||
|
||||
/* stuff that has not yet been rototiled */
|
||||
extern const u_char * ns_nprint (register const u_char *, register const u_char *);
|
||||
@ -422,11 +426,9 @@ extern void dvmrp_print(netdissect_options *,const u_char *, u_int);
|
||||
extern void egp_print(netdissect_options *,const u_char *, u_int,
|
||||
const u_char *);
|
||||
|
||||
extern void arcnet_if_print(u_char*,const struct pcap_pkthdr *,const u_char *);
|
||||
extern void token_if_print(u_char *,const struct pcap_pkthdr *,const u_char *);
|
||||
extern void fddi_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
|
||||
|
||||
extern void gre_print(netdissect_options *,const u_char *, u_int);
|
||||
extern void icmp_print(netdissect_options *,const u_char *, u_int,
|
||||
const u_char *);
|
||||
extern void hsrp_print(netdissect_options *ndo,
|
||||
|
@ -27,8 +27,6 @@
|
||||
|
||||
#include <tcpdump-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "interface.h"
|
||||
#include "extract.h"
|
||||
|
||||
@ -101,7 +99,7 @@ struct arc_linux_header {
|
||||
#define ARC_LINUX_HDRLEN 5
|
||||
#define ARC_LINUX_HDRNEWLEN 8
|
||||
|
||||
static int arcnet_encap_print(u_char arctype, const u_char *p,
|
||||
static int arcnet_encap_print(netdissect_options *, u_char arctype, const u_char *p,
|
||||
u_int length, u_int caplen);
|
||||
|
||||
static const struct tok arctypemap[] = {
|
||||
@ -119,7 +117,8 @@ static const struct tok arctypemap[] = {
|
||||
};
|
||||
|
||||
static inline void
|
||||
arcnet_print(const u_char *bp, u_int length, int phds, int flag, u_int seqid)
|
||||
arcnet_print(netdissect_options *ndo, const u_char *bp, u_int length, int phds,
|
||||
int flag, u_int seqid)
|
||||
{
|
||||
const struct arc_header *ap;
|
||||
const char *arctypename;
|
||||
@ -128,40 +127,40 @@ arcnet_print(const u_char *bp, u_int length, int phds, int flag, u_int seqid)
|
||||
ap = (const struct arc_header *)bp;
|
||||
|
||||
|
||||
if (qflag) {
|
||||
(void)printf("%02x %02x %d: ",
|
||||
if (ndo->ndo_qflag) {
|
||||
ND_PRINT((ndo, "%02x %02x %d: ",
|
||||
ap->arc_shost,
|
||||
ap->arc_dhost,
|
||||
length);
|
||||
length));
|
||||
return;
|
||||
}
|
||||
|
||||
arctypename = tok2str(arctypemap, "%02x", ap->arc_type);
|
||||
|
||||
if (!phds) {
|
||||
(void)printf("%02x %02x %s %d: ",
|
||||
ND_PRINT((ndo, "%02x %02x %s %d: ",
|
||||
ap->arc_shost, ap->arc_dhost, arctypename,
|
||||
length);
|
||||
length));
|
||||
return;
|
||||
}
|
||||
|
||||
if (flag == 0) {
|
||||
(void)printf("%02x %02x %s seqid %04x %d: ",
|
||||
ND_PRINT((ndo, "%02x %02x %s seqid %04x %d: ",
|
||||
ap->arc_shost, ap->arc_dhost, arctypename, seqid,
|
||||
length);
|
||||
length));
|
||||
return;
|
||||
}
|
||||
|
||||
if (flag & 1)
|
||||
(void)printf("%02x %02x %s seqid %04x "
|
||||
ND_PRINT((ndo, "%02x %02x %s seqid %04x "
|
||||
"(first of %d fragments) %d: ",
|
||||
ap->arc_shost, ap->arc_dhost, arctypename, seqid,
|
||||
(flag + 3) / 2, length);
|
||||
(flag + 3) / 2, length));
|
||||
else
|
||||
(void)printf("%02x %02x %s seqid %04x "
|
||||
ND_PRINT((ndo, "%02x %02x %s seqid %04x "
|
||||
"(fragment %d) %d: ",
|
||||
ap->arc_shost, ap->arc_dhost, arctypename, seqid,
|
||||
flag/2 + 1, length);
|
||||
flag/2 + 1, length));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -171,7 +170,7 @@ arcnet_print(const u_char *bp, u_int length, int phds, int flag, u_int seqid)
|
||||
* is the number of bytes actually captured.
|
||||
*/
|
||||
u_int
|
||||
arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
arcnet_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
|
||||
{
|
||||
u_int caplen = h->caplen;
|
||||
u_int length = h->len;
|
||||
@ -182,7 +181,7 @@ arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
u_char arc_type;
|
||||
|
||||
if (caplen < ARC_HDRLEN) {
|
||||
printf("[|arcnet]");
|
||||
ND_PRINT((ndo, "[|arcnet]"));
|
||||
return (caplen);
|
||||
}
|
||||
|
||||
@ -203,15 +202,15 @@ arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
|
||||
if (phds) {
|
||||
if (caplen < ARC_HDRNEWLEN) {
|
||||
arcnet_print(p, length, 0, 0, 0);
|
||||
printf("[|phds]");
|
||||
arcnet_print(ndo, p, length, 0, 0, 0);
|
||||
ND_PRINT((ndo, "[|phds]"));
|
||||
return (caplen);
|
||||
}
|
||||
|
||||
if (ap->arc_flag == 0xff) {
|
||||
if (caplen < ARC_HDRNEWLEN_EXC) {
|
||||
arcnet_print(p, length, 0, 0, 0);
|
||||
printf("[|phds extended]");
|
||||
arcnet_print(ndo, p, length, 0, 0, 0);
|
||||
ND_PRINT((ndo, "[|phds extended]"));
|
||||
return (caplen);
|
||||
}
|
||||
flag = ap->arc_flag2;
|
||||
@ -225,8 +224,8 @@ arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
}
|
||||
|
||||
|
||||
if (eflag)
|
||||
arcnet_print(p, length, phds, flag, seqid);
|
||||
if (ndo->ndo_eflag)
|
||||
arcnet_print(ndo, p, length, phds, flag, seqid);
|
||||
|
||||
/*
|
||||
* Go past the ARCNET header.
|
||||
@ -242,8 +241,8 @@ arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
return (archdrlen);
|
||||
}
|
||||
|
||||
if (!arcnet_encap_print(arc_type, p, length, caplen))
|
||||
default_print(p, caplen);
|
||||
if (!arcnet_encap_print(ndo, arc_type, p, length, caplen))
|
||||
ndo->ndo_default_print(ndo, p, caplen);
|
||||
|
||||
return (archdrlen);
|
||||
}
|
||||
@ -259,7 +258,7 @@ arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
* extra "offset" field between the src/dest and packet type.
|
||||
*/
|
||||
u_int
|
||||
arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
arcnet_linux_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
|
||||
{
|
||||
u_int caplen = h->caplen;
|
||||
u_int length = h->len;
|
||||
@ -269,7 +268,7 @@ arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
u_char arc_type;
|
||||
|
||||
if (caplen < ARC_LINUX_HDRLEN) {
|
||||
printf("[|arcnet]");
|
||||
ND_PRINT((ndo, "[|arcnet]"));
|
||||
return (caplen);
|
||||
}
|
||||
|
||||
@ -280,7 +279,7 @@ arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
default:
|
||||
archdrlen = ARC_LINUX_HDRNEWLEN;
|
||||
if (caplen < ARC_LINUX_HDRNEWLEN) {
|
||||
printf("[|arcnet]");
|
||||
ND_PRINT((ndo, "[|arcnet]"));
|
||||
return (caplen);
|
||||
}
|
||||
break;
|
||||
@ -291,8 +290,8 @@ arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
break;
|
||||
}
|
||||
|
||||
if (eflag)
|
||||
arcnet_print(p, length, 0, 0, 0);
|
||||
if (ndo->ndo_eflag)
|
||||
arcnet_print(ndo, p, length, 0, 0, 0);
|
||||
|
||||
/*
|
||||
* Go past the ARCNET header.
|
||||
@ -301,8 +300,8 @@ arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
caplen -= archdrlen;
|
||||
p += archdrlen;
|
||||
|
||||
if (!arcnet_encap_print(arc_type, p, length, caplen))
|
||||
default_print(p, caplen);
|
||||
if (!arcnet_encap_print(ndo, arc_type, p, length, caplen))
|
||||
ndo->ndo_default_print(ndo, p, caplen);
|
||||
|
||||
return (archdrlen);
|
||||
}
|
||||
@ -316,30 +315,30 @@ arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
|
||||
|
||||
static int
|
||||
arcnet_encap_print(u_char arctype, const u_char *p,
|
||||
arcnet_encap_print(netdissect_options *ndo, u_char arctype, const u_char *p,
|
||||
u_int length, u_int caplen)
|
||||
{
|
||||
switch (arctype) {
|
||||
|
||||
case ARCTYPE_IP_OLD:
|
||||
case ARCTYPE_IP:
|
||||
ip_print(gndo, p, length);
|
||||
ip_print(ndo, p, length);
|
||||
return (1);
|
||||
|
||||
#ifdef INET6
|
||||
case ARCTYPE_INET6:
|
||||
ip6_print(gndo, p, length);
|
||||
ip6_print(ndo, p, length);
|
||||
return (1);
|
||||
#endif /*INET6*/
|
||||
|
||||
case ARCTYPE_ARP_OLD:
|
||||
case ARCTYPE_ARP:
|
||||
case ARCTYPE_REVARP:
|
||||
arp_print(gndo, p, length, caplen);
|
||||
arp_print(ndo, p, length, caplen);
|
||||
return (1);
|
||||
|
||||
case ARCTYPE_ATALK: /* XXX was this ever used? */
|
||||
if (vflag)
|
||||
if (ndo->ndo_vflag)
|
||||
fputs("et1 ", stdout);
|
||||
atalk_print(p, length);
|
||||
return (1);
|
||||
|
72
print-bfd.c
72
print-bfd.c
@ -20,9 +20,8 @@
|
||||
#include <tcpdump-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "interface.h"
|
||||
#include "netdissect.h"
|
||||
#include "extract.h"
|
||||
|
||||
#include "udp.h"
|
||||
@ -161,7 +160,8 @@ static const struct tok bfd_v1_state_values[] = {
|
||||
};
|
||||
|
||||
void
|
||||
bfd_print(register const u_char *pptr, register u_int len, register u_int port)
|
||||
bfd_print(netdissect_options *ndo, register const u_char *pptr,
|
||||
register u_int len, register u_int port)
|
||||
{
|
||||
const struct bfd_header_t *bfd_header;
|
||||
const struct bfd_auth_header_t *bfd_auth_header;
|
||||
@ -169,7 +169,7 @@ bfd_print(register const u_char *pptr, register u_int len, register u_int port)
|
||||
|
||||
bfd_header = (const struct bfd_header_t *)pptr;
|
||||
if (port == BFD_CONTROL_PORT) {
|
||||
TCHECK(*bfd_header);
|
||||
ND_TCHECK(*bfd_header);
|
||||
version = BFD_EXTRACT_VERSION(bfd_header->version_diag);
|
||||
} else if (port == BFD_ECHO_PORT) {
|
||||
/* Echo is BFD v1 only */
|
||||
@ -179,79 +179,79 @@ bfd_print(register const u_char *pptr, register u_int len, register u_int port)
|
||||
|
||||
/* BFDv0 */
|
||||
case (BFD_CONTROL_PORT << 8):
|
||||
if (vflag < 1 )
|
||||
if (ndo->ndo_vflag < 1)
|
||||
{
|
||||
printf("BFDv%u, %s, Flags: [%s], length: %u",
|
||||
ND_PRINT((ndo, "BFDv%u, %s, Flags: [%s], length: %u",
|
||||
version,
|
||||
tok2str(bfd_port_values, "unknown (%u)", port),
|
||||
bittok2str(bfd_v0_flag_values, "none", bfd_header->flags),
|
||||
len);
|
||||
len));
|
||||
return;
|
||||
}
|
||||
|
||||
printf("BFDv%u, length: %u\n\t%s, Flags: [%s], Diagnostic: %s (0x%02x)",
|
||||
ND_PRINT((ndo, "BFDv%u, length: %u\n\t%s, Flags: [%s], Diagnostic: %s (0x%02x)",
|
||||
version,
|
||||
len,
|
||||
tok2str(bfd_port_values, "unknown (%u)", port),
|
||||
bittok2str(bfd_v0_flag_values, "none", bfd_header->flags),
|
||||
tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(bfd_header->version_diag)),
|
||||
BFD_EXTRACT_DIAG(bfd_header->version_diag));
|
||||
BFD_EXTRACT_DIAG(bfd_header->version_diag)));
|
||||
|
||||
printf("\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
|
||||
ND_PRINT((ndo, "\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
|
||||
bfd_header->detect_time_multiplier,
|
||||
bfd_header->detect_time_multiplier * EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000,
|
||||
bfd_header->length);
|
||||
bfd_header->length));
|
||||
|
||||
|
||||
printf("\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator));
|
||||
printf(", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator));
|
||||
printf("\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000);
|
||||
printf("\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000);
|
||||
printf("\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000);
|
||||
ND_PRINT((ndo, "\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator)));
|
||||
ND_PRINT((ndo, ", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator)));
|
||||
ND_PRINT((ndo, "\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000));
|
||||
ND_PRINT((ndo, "\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000));
|
||||
ND_PRINT((ndo, "\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000));
|
||||
break;
|
||||
|
||||
/* BFDv1 */
|
||||
case (BFD_CONTROL_PORT << 8 | 1):
|
||||
if (vflag < 1 )
|
||||
if (ndo->ndo_vflag < 1)
|
||||
{
|
||||
printf("BFDv%u, %s, State %s, Flags: [%s], length: %u",
|
||||
ND_PRINT((ndo, "BFDv%u, %s, State %s, Flags: [%s], length: %u",
|
||||
version,
|
||||
tok2str(bfd_port_values, "unknown (%u)", port),
|
||||
tok2str(bfd_v1_state_values, "unknown (%u)", (bfd_header->flags & 0xc0) >> 6),
|
||||
bittok2str(bfd_v1_flag_values, "none", bfd_header->flags & 0x3f),
|
||||
len);
|
||||
len));
|
||||
return;
|
||||
}
|
||||
|
||||
printf("BFDv%u, length: %u\n\t%s, State %s, Flags: [%s], Diagnostic: %s (0x%02x)",
|
||||
ND_PRINT((ndo, "BFDv%u, length: %u\n\t%s, State %s, Flags: [%s], Diagnostic: %s (0x%02x)",
|
||||
version,
|
||||
len,
|
||||
tok2str(bfd_port_values, "unknown (%u)", port),
|
||||
tok2str(bfd_v1_state_values, "unknown (%u)", (bfd_header->flags & 0xc0) >> 6),
|
||||
bittok2str(bfd_v1_flag_values, "none", bfd_header->flags & 0x3f),
|
||||
tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(bfd_header->version_diag)),
|
||||
BFD_EXTRACT_DIAG(bfd_header->version_diag));
|
||||
BFD_EXTRACT_DIAG(bfd_header->version_diag)));
|
||||
|
||||
printf("\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
|
||||
ND_PRINT((ndo, "\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
|
||||
bfd_header->detect_time_multiplier,
|
||||
bfd_header->detect_time_multiplier * EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000,
|
||||
bfd_header->length);
|
||||
bfd_header->length));
|
||||
|
||||
|
||||
printf("\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator));
|
||||
printf(", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator));
|
||||
printf("\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000);
|
||||
printf("\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000);
|
||||
printf("\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000);
|
||||
ND_PRINT((ndo, "\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator)));
|
||||
ND_PRINT((ndo, ", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator)));
|
||||
ND_PRINT((ndo, "\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000));
|
||||
ND_PRINT((ndo, "\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000));
|
||||
ND_PRINT((ndo, "\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000));
|
||||
|
||||
if (bfd_header->flags & BFD_FLAG_AUTH) {
|
||||
pptr += sizeof (const struct bfd_header_t);
|
||||
bfd_auth_header = (const struct bfd_auth_header_t *)pptr;
|
||||
TCHECK2(*bfd_auth_header, sizeof(const struct bfd_auth_header_t));
|
||||
printf("\n\t%s (%u) Authentication, length %u present",
|
||||
ND_TCHECK2(*bfd_auth_header, sizeof(const struct bfd_auth_header_t));
|
||||
ND_PRINT((ndo, "\n\t%s (%u) Authentication, length %u present",
|
||||
tok2str(bfd_v1_authentication_values,"Unknown",bfd_auth_header->auth_type),
|
||||
bfd_auth_header->auth_type,
|
||||
bfd_auth_header->auth_len);
|
||||
bfd_auth_header->auth_len));
|
||||
}
|
||||
break;
|
||||
|
||||
@ -261,11 +261,11 @@ bfd_print(register const u_char *pptr, register u_int len, register u_int port)
|
||||
case (BFD_ECHO_PORT << 8 | 1):
|
||||
|
||||
default:
|
||||
printf("BFD, %s, length: %u",
|
||||
ND_PRINT((ndo, "BFD, %s, length: %u",
|
||||
tok2str(bfd_port_values, "unknown (%u)", port),
|
||||
len);
|
||||
if (vflag >= 1) {
|
||||
if(!print_unknown_data(gndo, pptr,"\n\t",len))
|
||||
len));
|
||||
if (ndo->ndo_vflag >= 1) {
|
||||
if(!print_unknown_data(ndo, pptr,"\n\t",len))
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@ -273,7 +273,7 @@ bfd_print(register const u_char *pptr, register u_int len, register u_int port)
|
||||
return;
|
||||
|
||||
trunc:
|
||||
printf("[|BFD]");
|
||||
ND_PRINT((ndo, "[|BFD]"));
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
|
160
print-gre.c
160
print-gre.c
@ -42,13 +42,10 @@
|
||||
|
||||
#include <tcpdump-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "interface.h"
|
||||
#include "extract.h"
|
||||
|
||||
#include "ip.h"
|
||||
#include "ethertype.h"
|
||||
|
||||
static const char tstr[] = "[|gre]";
|
||||
@ -78,49 +75,47 @@ static const struct tok gre_flag_values[] = {
|
||||
#define GRESRE_IP 0x0800 /* IP */
|
||||
#define GRESRE_ASN 0xfffe /* ASN */
|
||||
|
||||
void gre_print_0(const u_char *, u_int);
|
||||
void gre_print_1(const u_char *, u_int);
|
||||
void gre_sre_print(u_int16_t, u_int8_t, u_int8_t, const u_char *, u_int);
|
||||
void gre_sre_ip_print(u_int8_t, u_int8_t, const u_char *, u_int);
|
||||
void gre_sre_asn_print(u_int8_t, u_int8_t, const u_char *, u_int);
|
||||
static void gre_print_0(netdissect_options *, const u_char *, u_int);
|
||||
static void gre_print_1(netdissect_options *, const u_char *, u_int);
|
||||
static void gre_sre_print(netdissect_options *, u_int16_t, u_int8_t, u_int8_t, const u_char *, u_int);
|
||||
static void gre_sre_ip_print(netdissect_options *, u_int8_t, u_int8_t, const u_char *, u_int);
|
||||
static void gre_sre_asn_print(netdissect_options *, u_int8_t, u_int8_t, const u_char *, u_int);
|
||||
|
||||
void
|
||||
gre_print(const u_char *bp, u_int length)
|
||||
gre_print(netdissect_options *ndo, const u_char *bp, u_int length)
|
||||
{
|
||||
u_int len = length, vers;
|
||||
|
||||
if (len < 2) {
|
||||
printf("%s", tstr);
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
return;
|
||||
}
|
||||
vers = EXTRACT_16BITS(bp) & GRE_VERS_MASK;
|
||||
printf("GREv%u",vers);
|
||||
ND_PRINT((ndo, "GREv%u",vers));
|
||||
|
||||
switch(vers) {
|
||||
case 0:
|
||||
gre_print_0(bp, len);
|
||||
gre_print_0(ndo, bp, len);
|
||||
break;
|
||||
case 1:
|
||||
gre_print_1(bp, len);
|
||||
gre_print_1(ndo, bp, len);
|
||||
break;
|
||||
default:
|
||||
printf(" ERROR: unknown-version");
|
||||
ND_PRINT((ndo, " ERROR: unknown-version"));
|
||||
break;
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
gre_print_0(const u_char *bp, u_int length)
|
||||
static void
|
||||
gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
|
||||
{
|
||||
u_int len = length;
|
||||
u_int16_t flags, prot;
|
||||
|
||||
flags = EXTRACT_16BITS(bp);
|
||||
if (vflag)
|
||||
printf(", Flags [%s]",
|
||||
bittok2str(gre_flag_values,"none",flags));
|
||||
if (ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, ", Flags [%s]",
|
||||
bittok2str(gre_flag_values,"none",flags)));
|
||||
|
||||
len -= 2;
|
||||
bp += 2;
|
||||
@ -134,14 +129,14 @@ gre_print_0(const u_char *bp, u_int length)
|
||||
if ((flags & GRE_CP) | (flags & GRE_RP)) {
|
||||
if (len < 2)
|
||||
goto trunc;
|
||||
if (vflag)
|
||||
printf(", sum 0x%x", EXTRACT_16BITS(bp));
|
||||
if (ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, ", sum 0x%x", EXTRACT_16BITS(bp)));
|
||||
bp += 2;
|
||||
len -= 2;
|
||||
|
||||
if (len < 2)
|
||||
goto trunc;
|
||||
printf(", off 0x%x", EXTRACT_16BITS(bp));
|
||||
ND_PRINT((ndo, ", off 0x%x", EXTRACT_16BITS(bp)));
|
||||
bp += 2;
|
||||
len -= 2;
|
||||
}
|
||||
@ -149,7 +144,7 @@ gre_print_0(const u_char *bp, u_int length)
|
||||
if (flags & GRE_KP) {
|
||||
if (len < 4)
|
||||
goto trunc;
|
||||
printf(", key=0x%x", EXTRACT_32BITS(bp));
|
||||
ND_PRINT((ndo, ", key=0x%x", EXTRACT_32BITS(bp)));
|
||||
bp += 4;
|
||||
len -= 4;
|
||||
}
|
||||
@ -157,7 +152,7 @@ gre_print_0(const u_char *bp, u_int length)
|
||||
if (flags & GRE_SP) {
|
||||
if (len < 4)
|
||||
goto trunc;
|
||||
printf(", seq %u", EXTRACT_32BITS(bp));
|
||||
ND_PRINT((ndo, ", seq %u", EXTRACT_32BITS(bp)));
|
||||
bp += 4;
|
||||
len -= 4;
|
||||
}
|
||||
@ -179,7 +174,7 @@ gre_print_0(const u_char *bp, u_int length)
|
||||
if (af == 0 && srelen == 0)
|
||||
break;
|
||||
|
||||
gre_sre_print(af, sreoff, srelen, bp, len);
|
||||
gre_sre_print(ndo, af, sreoff, srelen, bp, len);
|
||||
|
||||
if (len < srelen)
|
||||
goto trunc;
|
||||
@ -188,25 +183,25 @@ gre_print_0(const u_char *bp, u_int length)
|
||||
}
|
||||
}
|
||||
|
||||
if (eflag)
|
||||
printf(", proto %s (0x%04x)",
|
||||
if (ndo->ndo_eflag)
|
||||
ND_PRINT((ndo, ", proto %s (0x%04x)",
|
||||
tok2str(ethertype_values,"unknown",prot),
|
||||
prot);
|
||||
prot));
|
||||
|
||||
printf(", length %u",length);
|
||||
ND_PRINT((ndo, ", length %u",length));
|
||||
|
||||
if (vflag < 1)
|
||||
printf(": "); /* put in a colon as protocol demarc */
|
||||
if (ndo->ndo_vflag < 1)
|
||||
ND_PRINT((ndo, ": ")); /* put in a colon as protocol demarc */
|
||||
else
|
||||
printf("\n\t"); /* if verbose go multiline */
|
||||
ND_PRINT((ndo, "\n\t")); /* if verbose go multiline */
|
||||
|
||||
switch (prot) {
|
||||
case ETHERTYPE_IP:
|
||||
ip_print(gndo, bp, len);
|
||||
ip_print(ndo, bp, len);
|
||||
break;
|
||||
#ifdef INET6
|
||||
case ETHERTYPE_IPV6:
|
||||
ip6_print(gndo, bp, len);
|
||||
ip6_print(ndo, bp, len);
|
||||
break;
|
||||
#endif
|
||||
case ETHERTYPE_MPLS:
|
||||
@ -222,19 +217,19 @@ gre_print_0(const u_char *bp, u_int length)
|
||||
isoclns_print(bp, len, len);
|
||||
break;
|
||||
case ETHERTYPE_TEB:
|
||||
ether_print(gndo, bp, len, len, NULL, NULL);
|
||||
ether_print(ndo, bp, len, len, NULL, NULL);
|
||||
break;
|
||||
default:
|
||||
printf("gre-proto-0x%x", prot);
|
||||
ND_PRINT((ndo, "gre-proto-0x%x", prot));
|
||||
}
|
||||
return;
|
||||
|
||||
trunc:
|
||||
printf("%s", tstr);
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
}
|
||||
|
||||
void
|
||||
gre_print_1(const u_char *bp, u_int length)
|
||||
static void
|
||||
gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
|
||||
{
|
||||
u_int len = length;
|
||||
u_int16_t flags, prot;
|
||||
@ -243,9 +238,9 @@ gre_print_1(const u_char *bp, u_int length)
|
||||
len -= 2;
|
||||
bp += 2;
|
||||
|
||||
if (vflag)
|
||||
printf(", Flags [%s]",
|
||||
bittok2str(gre_flag_values,"none",flags));
|
||||
if (ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, ", Flags [%s]",
|
||||
bittok2str(gre_flag_values,"none",flags)));
|
||||
|
||||
if (len < 2)
|
||||
goto trunc;
|
||||
@ -260,7 +255,7 @@ gre_print_1(const u_char *bp, u_int length)
|
||||
if (len < 4)
|
||||
goto trunc;
|
||||
k = EXTRACT_32BITS(bp);
|
||||
printf(", call %d", k & 0xffff);
|
||||
ND_PRINT((ndo, ", call %d", k & 0xffff));
|
||||
len -= 4;
|
||||
bp += 4;
|
||||
}
|
||||
@ -268,7 +263,7 @@ gre_print_1(const u_char *bp, u_int length)
|
||||
if (flags & GRE_SP) {
|
||||
if (len < 4)
|
||||
goto trunc;
|
||||
printf(", seq %u", EXTRACT_32BITS(bp));
|
||||
ND_PRINT((ndo, ", seq %u", EXTRACT_32BITS(bp)));
|
||||
bp += 4;
|
||||
len -= 4;
|
||||
}
|
||||
@ -276,78 +271,80 @@ gre_print_1(const u_char *bp, u_int length)
|
||||
if (flags & GRE_AP) {
|
||||
if (len < 4)
|
||||
goto trunc;
|
||||
printf(", ack %u", EXTRACT_32BITS(bp));
|
||||
ND_PRINT((ndo, ", ack %u", EXTRACT_32BITS(bp)));
|
||||
bp += 4;
|
||||
len -= 4;
|
||||
}
|
||||
|
||||
if ((flags & GRE_SP) == 0)
|
||||
printf(", no-payload");
|
||||
ND_PRINT((ndo, ", no-payload"));
|
||||
|
||||
if (eflag)
|
||||
printf(", proto %s (0x%04x)",
|
||||
if (ndo->ndo_eflag)
|
||||
ND_PRINT((ndo, ", proto %s (0x%04x)",
|
||||
tok2str(ethertype_values,"unknown",prot),
|
||||
prot);
|
||||
prot));
|
||||
|
||||
printf(", length %u",length);
|
||||
ND_PRINT((ndo, ", length %u",length));
|
||||
|
||||
if ((flags & GRE_SP) == 0)
|
||||
return;
|
||||
|
||||
if (vflag < 1)
|
||||
printf(": "); /* put in a colon as protocol demarc */
|
||||
if (ndo->ndo_vflag < 1)
|
||||
ND_PRINT((ndo, ": ")); /* put in a colon as protocol demarc */
|
||||
else
|
||||
printf("\n\t"); /* if verbose go multiline */
|
||||
ND_PRINT((ndo, "\n\t")); /* if verbose go multiline */
|
||||
|
||||
switch (prot) {
|
||||
case ETHERTYPE_PPP:
|
||||
ppp_print(bp, len);
|
||||
break;
|
||||
default:
|
||||
printf("gre-proto-0x%x", prot);
|
||||
ND_PRINT((ndo, "gre-proto-0x%x", prot));
|
||||
break;
|
||||
}
|
||||
return;
|
||||
|
||||
trunc:
|
||||
printf("%s", tstr);
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
}
|
||||
|
||||
void
|
||||
gre_sre_print(u_int16_t af, u_int8_t sreoff, u_int8_t srelen,
|
||||
const u_char *bp, u_int len)
|
||||
static void
|
||||
gre_sre_print(netdissect_options *ndo, u_int16_t af, u_int8_t sreoff,
|
||||
u_int8_t srelen, const u_char *bp, u_int len)
|
||||
{
|
||||
switch (af) {
|
||||
case GRESRE_IP:
|
||||
printf(", (rtaf=ip");
|
||||
gre_sre_ip_print(sreoff, srelen, bp, len);
|
||||
printf(") ");
|
||||
ND_PRINT((ndo, ", (rtaf=ip"));
|
||||
gre_sre_ip_print(ndo, sreoff, srelen, bp, len);
|
||||
ND_PRINT((ndo, ") "));
|
||||
break;
|
||||
case GRESRE_ASN:
|
||||
printf(", (rtaf=asn");
|
||||
gre_sre_asn_print(sreoff, srelen, bp, len);
|
||||
printf(") ");
|
||||
ND_PRINT((ndo, ", (rtaf=asn"));
|
||||
gre_sre_asn_print(ndo, sreoff, srelen, bp, len);
|
||||
ND_PRINT((ndo, ") "));
|
||||
break;
|
||||
default:
|
||||
printf(", (rtaf=0x%x) ", af);
|
||||
ND_PRINT((ndo, ", (rtaf=0x%x) ", af));
|
||||
}
|
||||
}
|
||||
void
|
||||
gre_sre_ip_print(u_int8_t sreoff, u_int8_t srelen, const u_char *bp, u_int len)
|
||||
|
||||
static void
|
||||
gre_sre_ip_print(netdissect_options *ndo, u_int8_t sreoff, u_int8_t srelen,
|
||||
const u_char *bp, u_int len)
|
||||
{
|
||||
struct in_addr a;
|
||||
const u_char *up = bp;
|
||||
|
||||
if (sreoff & 3) {
|
||||
printf(", badoffset=%u", sreoff);
|
||||
ND_PRINT((ndo, ", badoffset=%u", sreoff));
|
||||
return;
|
||||
}
|
||||
if (srelen & 3) {
|
||||
printf(", badlength=%u", srelen);
|
||||
ND_PRINT((ndo, ", badlength=%u", srelen));
|
||||
return;
|
||||
}
|
||||
if (sreoff >= srelen) {
|
||||
printf(", badoff/len=%u/%u", sreoff, srelen);
|
||||
ND_PRINT((ndo, ", badoff/len=%u/%u", sreoff, srelen));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -356,9 +353,9 @@ gre_sre_ip_print(u_int8_t sreoff, u_int8_t srelen, const u_char *bp, u_int len)
|
||||
return;
|
||||
|
||||
memcpy(&a, bp, sizeof(a));
|
||||
printf(" %s%s",
|
||||
ND_PRINT((ndo, " %s%s",
|
||||
((bp - up) == sreoff) ? "*" : "",
|
||||
inet_ntoa(a));
|
||||
inet_ntoa(a)));
|
||||
|
||||
bp += 4;
|
||||
len -= 4;
|
||||
@ -366,21 +363,22 @@ gre_sre_ip_print(u_int8_t sreoff, u_int8_t srelen, const u_char *bp, u_int len)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gre_sre_asn_print(u_int8_t sreoff, u_int8_t srelen, const u_char *bp, u_int len)
|
||||
static void
|
||||
gre_sre_asn_print(netdissect_options *ndo, u_int8_t sreoff, u_int8_t srelen,
|
||||
const u_char *bp, u_int len)
|
||||
{
|
||||
const u_char *up = bp;
|
||||
|
||||
if (sreoff & 1) {
|
||||
printf(", badoffset=%u", sreoff);
|
||||
ND_PRINT((ndo, ", badoffset=%u", sreoff));
|
||||
return;
|
||||
}
|
||||
if (srelen & 1) {
|
||||
printf(", badlength=%u", srelen);
|
||||
ND_PRINT((ndo, ", badlength=%u", srelen));
|
||||
return;
|
||||
}
|
||||
if (sreoff >= srelen) {
|
||||
printf(", badoff/len=%u/%u", sreoff, srelen);
|
||||
ND_PRINT((ndo, ", badoff/len=%u/%u", sreoff, srelen));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -388,9 +386,9 @@ gre_sre_asn_print(u_int8_t sreoff, u_int8_t srelen, const u_char *bp, u_int len)
|
||||
if (len < 2 || srelen == 0)
|
||||
return;
|
||||
|
||||
printf(" %s%x",
|
||||
ND_PRINT((ndo, " %s%x",
|
||||
((bp - up) == sreoff) ? "*" : "",
|
||||
EXTRACT_16BITS(bp));
|
||||
EXTRACT_16BITS(bp)));
|
||||
|
||||
bp += 2;
|
||||
len -= 2;
|
||||
|
@ -445,7 +445,7 @@ again:
|
||||
|
||||
case IPPROTO_GRE:
|
||||
/* do it */
|
||||
gre_print(ipds->cp, ipds->len);
|
||||
gre_print(ndo, ipds->cp, ipds->len);
|
||||
break;
|
||||
|
||||
case IPPROTO_MOBILE:
|
||||
|
@ -246,7 +246,7 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
|
||||
return;
|
||||
|
||||
case IPPROTO_GRE:
|
||||
gre_print(cp, len);
|
||||
gre_print(ndo, cp, len);
|
||||
return;
|
||||
|
||||
case IPPROTO_RSVP:
|
||||
|
@ -660,7 +660,7 @@ udp_print(register const u_char *bp, u_int 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);
|
||||
bfd_print(gndo, (const u_char *)(up+1), length, dport);
|
||||
else if (ISPORT(LMP_PORT))
|
||||
lmp_print((const u_char *)(up + 1), length);
|
||||
else if (ISPORT(VQP_PORT))
|
||||
|
@ -167,10 +167,6 @@ struct ndo_printer {
|
||||
|
||||
|
||||
static const struct printer printers[] = {
|
||||
{ arcnet_if_print, DLT_ARCNET },
|
||||
#ifdef DLT_ARCNET_LINUX
|
||||
{ arcnet_linux_if_print, DLT_ARCNET_LINUX },
|
||||
#endif
|
||||
{ token_if_print, DLT_IEEE802 },
|
||||
{ sl_if_print, DLT_SLIP },
|
||||
#ifdef DLT_SLIP_BSDOS
|
||||
@ -343,6 +339,10 @@ static const struct ndo_printer ndo_printers[] = {
|
||||
#endif
|
||||
#ifdef DLT_LANE8023
|
||||
{ lane_if_print, DLT_LANE8023 },
|
||||
#endif
|
||||
{ arcnet_if_print, DLT_ARCNET },
|
||||
#ifdef DLT_ARCNET_LINUX
|
||||
{ arcnet_linux_if_print, DLT_ARCNET_LINUX },
|
||||
#endif
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user