mirror of
https://github.com/the-tcpdump-group/tcpdump.git
synced 2024-11-27 03:53:53 +08:00
NDOize ATM, MPTCP, NTP, VTP & Whiteboard decoders
This commit is contained in:
parent
94b28f43b5
commit
90692fcf97
@ -166,10 +166,6 @@ extern void ascii_print(const u_char *, u_int);
|
||||
extern void aarp_print(const u_char *, u_int);
|
||||
extern void aodv_print(const u_char *, u_int, int);
|
||||
extern void atalk_print(const u_char *, u_int);
|
||||
extern void atm_print(u_int, u_int, u_int, const u_char *, u_int, u_int);
|
||||
extern u_int atm_if_print(const struct pcap_pkthdr *, const u_char *);
|
||||
extern u_int sunatm_if_print(const struct pcap_pkthdr *, const u_char *);
|
||||
extern int oam_print(const u_char *, u_int, u_int);
|
||||
extern void bootp_print(const u_char *, u_int);
|
||||
extern void bgp_print(const u_char *, int);
|
||||
extern void cnfp_print(const u_char *, const u_char *);
|
||||
@ -194,7 +190,6 @@ extern void nfsreq_print(const u_char *, u_int, const u_char *);
|
||||
extern void nfsreq_print_noaddr(const u_char *, u_int, const u_char *);
|
||||
extern void ns_print(const u_char *, u_int, int);
|
||||
extern const u_char * ns_nprint (register const u_char *, register const u_char *);
|
||||
extern void ntp_print(const u_char *, u_int);
|
||||
extern void ospf_print(const u_char *, u_int, const u_char *);
|
||||
extern void olsr_print (const u_char *, u_int, int);
|
||||
extern void pimv1_print(const u_char *, u_int);
|
||||
@ -229,8 +224,6 @@ extern void snmp_print(const u_char *, u_int);
|
||||
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 vtp_print(const u_char *, u_int);
|
||||
extern void wb_print(const void *, u_int);
|
||||
extern void rx_print(register const u_char *, int, int, int, u_char *);
|
||||
extern void netbeui_print(u_short, const u_char *, int);
|
||||
extern void ipx_netbios_print(const u_char *, u_int);
|
||||
@ -251,7 +244,6 @@ extern void forces_print(const u_char *, u_int);
|
||||
extern void mpls_lsp_ping_print(const u_char *, 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);
|
||||
|
||||
|
||||
#ifdef INET6
|
||||
|
10
netdissect.h
10
netdissect.h
@ -444,6 +444,14 @@ extern void lwapp_data_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void pgm_print(netdissect_options *, const u_char *, u_int, const u_char *);
|
||||
extern void pptp_print(netdissect_options *, const u_char *);
|
||||
extern void ldp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void wb_print(netdissect_options *, const void *, u_int);
|
||||
extern int oam_print(netdissect_options *, const u_char *, u_int, u_int);
|
||||
extern void atm_print(netdissect_options *, u_int, u_int, u_int, const u_char *, u_int, u_int);
|
||||
extern u_int sunatm_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
|
||||
extern u_int atm_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
|
||||
extern void vtp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern int mptcp_print(netdissect_options *, const u_char *, u_int, u_char);
|
||||
extern void ntp_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 *);
|
||||
@ -489,7 +497,6 @@ extern void nfsreply_print(netdissect_options *,const u_char *,
|
||||
extern void nfsreq_print(netdissect_options *,const u_char *,
|
||||
u_int, const u_char *);
|
||||
extern void ns_print(netdissect_options *,const u_char *, u_int);
|
||||
extern void ntp_print(netdissect_options *,const u_char *, u_int);
|
||||
extern void null_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
|
||||
extern void ospf_print(netdissect_options *,const u_char *,
|
||||
u_int, const u_char *);
|
||||
@ -522,7 +529,6 @@ extern void tcp_print(netdissect_options *,const u_char *, u_int,
|
||||
const u_char *, int);
|
||||
extern void tftp_print(netdissect_options *,const u_char *, u_int);
|
||||
extern void timed_print(netdissect_options *,const u_char *, u_int);
|
||||
extern void wb_print(netdissect_options *,const void *, u_int);
|
||||
extern void esp_print_decodesecret(netdissect_options *ndo);
|
||||
extern void rx_print(netdissect_options *,register const u_char *,
|
||||
int, int, int, u_char *);
|
||||
|
118
print-atm.c
118
print-atm.c
@ -19,25 +19,20 @@
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#define NETDISSECT_REWORKED
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <tcpdump-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "interface.h"
|
||||
#include "extract.h"
|
||||
#include "addrtoname.h"
|
||||
#include "ethertype.h"
|
||||
#include "atm.h"
|
||||
#include "atmuni31.h"
|
||||
#include "llc.h"
|
||||
|
||||
#include "ether.h"
|
||||
|
||||
static const char tstr[] = "[|atm]";
|
||||
|
||||
#define OAM_CRC10_MASK 0x3ff
|
||||
@ -132,19 +127,20 @@ static const struct tok *oam_functype_values[16] = {
|
||||
* Print an RFC 1483 LLC-encapsulated ATM frame.
|
||||
*/
|
||||
static void
|
||||
atm_llc_print(const u_char *p, int length, int caplen)
|
||||
atm_llc_print(netdissect_options *ndo,
|
||||
const u_char *p, int length, int caplen)
|
||||
{
|
||||
u_short extracted_ethertype;
|
||||
|
||||
if (!llc_print(gndo, p, length, caplen, NULL, NULL,
|
||||
if (!llc_print(ndo, p, length, caplen, NULL, NULL,
|
||||
&extracted_ethertype)) {
|
||||
/* ether_type not known, print raw packet */
|
||||
if (extracted_ethertype) {
|
||||
printf("(LLC %s) ",
|
||||
etherproto_string(htons(extracted_ethertype)));
|
||||
ND_PRINT((ndo, "(LLC %s) ",
|
||||
etherproto_string(htons(extracted_ethertype))));
|
||||
}
|
||||
if (!suppress_default_print)
|
||||
default_print(p, caplen);
|
||||
if (!ndo->ndo_suppress_default_print)
|
||||
ndo->ndo_default_print(ndo, p, caplen);
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,7 +157,8 @@ atm_llc_print(const u_char *p, int length, int caplen)
|
||||
* is the number of bytes actually captured.
|
||||
*/
|
||||
u_int
|
||||
atm_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
atm_if_print(netdissect_options *ndo,
|
||||
const struct pcap_pkthdr *h, const u_char *p)
|
||||
{
|
||||
u_int caplen = h->caplen;
|
||||
u_int length = h->len;
|
||||
@ -169,14 +166,14 @@ atm_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
u_int hdrlen = 0;
|
||||
|
||||
if (caplen < 8) {
|
||||
printf("%s", tstr);
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
return (caplen);
|
||||
}
|
||||
|
||||
/* Cisco Style NLPID ? */
|
||||
if (*p == LLC_UI) {
|
||||
if (eflag)
|
||||
printf("CNLPID ");
|
||||
if (ndo->ndo_eflag)
|
||||
ND_PRINT((ndo, "CNLPID "));
|
||||
isoclns_print(p+1, length-1, caplen-1);
|
||||
return hdrlen;
|
||||
}
|
||||
@ -208,18 +205,18 @@ atm_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
* packets? If so, could it be changed to use a
|
||||
* new DLT_IEEE802_6 value if we added it?
|
||||
*/
|
||||
if (eflag)
|
||||
printf("%08x%08x %08x%08x ",
|
||||
if (ndo->ndo_eflag)
|
||||
ND_PRINT((ndo, "%08x%08x %08x%08x ",
|
||||
EXTRACT_32BITS(p),
|
||||
EXTRACT_32BITS(p+4),
|
||||
EXTRACT_32BITS(p+8),
|
||||
EXTRACT_32BITS(p+12));
|
||||
EXTRACT_32BITS(p+12)));
|
||||
p += 20;
|
||||
length -= 20;
|
||||
caplen -= 20;
|
||||
hdrlen += 20;
|
||||
}
|
||||
atm_llc_print(p, length, caplen);
|
||||
atm_llc_print(ndo, p, length, caplen);
|
||||
return (hdrlen);
|
||||
}
|
||||
|
||||
@ -246,12 +243,13 @@ static const struct tok msgtype2str[] = {
|
||||
};
|
||||
|
||||
static void
|
||||
sig_print(const u_char *p, int caplen)
|
||||
sig_print(netdissect_options *ndo,
|
||||
const u_char *p, int caplen)
|
||||
{
|
||||
bpf_u_int32 call_ref;
|
||||
|
||||
if (caplen < PROTO_POS) {
|
||||
printf("%s", tstr);
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
return;
|
||||
}
|
||||
if (p[PROTO_POS] == Q2931) {
|
||||
@ -259,13 +257,13 @@ sig_print(const u_char *p, int caplen)
|
||||
* protocol:Q.2931 for User to Network Interface
|
||||
* (UNI 3.1) signalling
|
||||
*/
|
||||
printf("Q.2931");
|
||||
ND_PRINT((ndo, "Q.2931"));
|
||||
if (caplen < MSG_TYPE_POS) {
|
||||
printf(" %s", tstr);
|
||||
ND_PRINT((ndo, " %s", tstr));
|
||||
return;
|
||||
}
|
||||
printf(":%s ",
|
||||
tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS]));
|
||||
ND_PRINT((ndo, ":%s ",
|
||||
tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS])));
|
||||
|
||||
/*
|
||||
* The call reference comes before the message type,
|
||||
@ -274,10 +272,10 @@ sig_print(const u_char *p, int caplen)
|
||||
* the call reference.
|
||||
*/
|
||||
call_ref = EXTRACT_24BITS(&p[CALL_REF_POS]);
|
||||
printf("CALL_REF:0x%06x", call_ref);
|
||||
ND_PRINT((ndo, "CALL_REF:0x%06x", call_ref));
|
||||
} else {
|
||||
/* SCCOP with some unknown protocol atop it */
|
||||
printf("SSCOP, proto %d ", p[PROTO_POS]);
|
||||
ND_PRINT((ndo, "SSCOP, proto %d ", p[PROTO_POS]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -285,34 +283,35 @@ sig_print(const u_char *p, int caplen)
|
||||
* Print an ATM PDU (such as an AAL5 PDU).
|
||||
*/
|
||||
void
|
||||
atm_print(u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
|
||||
u_int caplen)
|
||||
atm_print(netdissect_options *ndo,
|
||||
u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
|
||||
u_int caplen)
|
||||
{
|
||||
if (eflag)
|
||||
printf("VPI:%u VCI:%u ", vpi, vci);
|
||||
if (ndo->ndo_eflag)
|
||||
ND_PRINT((ndo, "VPI:%u VCI:%u ", vpi, vci));
|
||||
|
||||
if (vpi == 0) {
|
||||
switch (vci) {
|
||||
|
||||
case VCI_PPC:
|
||||
sig_print(p, caplen);
|
||||
sig_print(ndo, p, caplen);
|
||||
return;
|
||||
|
||||
case VCI_BCC:
|
||||
printf("broadcast sig: ");
|
||||
ND_PRINT((ndo, "broadcast sig: "));
|
||||
return;
|
||||
|
||||
case VCI_OAMF4SC: /* fall through */
|
||||
case VCI_OAMF4EC:
|
||||
oam_print(p, length, ATM_OAM_HEC);
|
||||
oam_print(ndo, p, length, ATM_OAM_HEC);
|
||||
return;
|
||||
|
||||
case VCI_METAC:
|
||||
printf("meta: ");
|
||||
ND_PRINT((ndo, "meta: "));
|
||||
return;
|
||||
|
||||
case VCI_ILMIC:
|
||||
printf("ilmi: ");
|
||||
ND_PRINT((ndo, "ilmi: "));
|
||||
snmp_print(p, length);
|
||||
return;
|
||||
}
|
||||
@ -325,11 +324,11 @@ atm_print(u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
|
||||
/*
|
||||
* Assumes traffic is LLC if unknown.
|
||||
*/
|
||||
atm_llc_print(p, length, caplen);
|
||||
atm_llc_print(ndo, p, length, caplen);
|
||||
break;
|
||||
|
||||
case ATM_LANE:
|
||||
lane_print(gndo, p, length, caplen);
|
||||
lane_print(ndo, p, length, caplen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -349,7 +348,8 @@ struct oam_fm_ais_rdi_t {
|
||||
};
|
||||
|
||||
int
|
||||
oam_print (const u_char *p, u_int length, u_int hec) {
|
||||
oam_print (netdissect_options *ndo,
|
||||
const u_char *p, u_int length, u_int hec) {
|
||||
|
||||
u_int32_t cell_header;
|
||||
u_int16_t vpi, vci, cksum, cksum_shouldbe, idx;
|
||||
@ -370,47 +370,47 @@ oam_print (const u_char *p, u_int length, u_int hec) {
|
||||
payload = (cell_header>>1)&0x7;
|
||||
clp = cell_header&0x1;
|
||||
|
||||
printf("%s, vpi %u, vci %u, payload [ %s ], clp %u, length %u",
|
||||
ND_PRINT((ndo, "%s, vpi %u, vci %u, payload [ %s ], clp %u, length %u",
|
||||
tok2str(oam_f_values, "OAM F5", vci),
|
||||
vpi, vci,
|
||||
tok2str(atm_pty_values, "Unknown", payload),
|
||||
clp, length);
|
||||
clp, length));
|
||||
|
||||
if (!vflag) {
|
||||
if (!ndo->ndo_vflag) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("\n\tcell-type %s (%u)",
|
||||
ND_PRINT((ndo, "\n\tcell-type %s (%u)",
|
||||
tok2str(oam_celltype_values, "unknown", cell_type),
|
||||
cell_type);
|
||||
cell_type));
|
||||
|
||||
if (oam_functype_values[cell_type] == NULL)
|
||||
printf(", func-type unknown (%u)", func_type);
|
||||
ND_PRINT((ndo, ", func-type unknown (%u)", func_type));
|
||||
else
|
||||
printf(", func-type %s (%u)",
|
||||
ND_PRINT((ndo, ", func-type %s (%u)",
|
||||
tok2str(oam_functype_values[cell_type],"none",func_type),
|
||||
func_type);
|
||||
func_type));
|
||||
|
||||
p += ATM_HDR_LEN_NOHEC + hec;
|
||||
|
||||
switch (cell_type << 4 | func_type) {
|
||||
case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_LOOPBACK):
|
||||
oam_ptr.oam_fm_loopback = (const struct oam_fm_loopback_t *)(p + OAM_CELLTYPE_FUNCTYPE_LEN);
|
||||
printf("\n\tLoopback-Indicator %s, Correlation-Tag 0x%08x",
|
||||
ND_PRINT((ndo, "\n\tLoopback-Indicator %s, Correlation-Tag 0x%08x",
|
||||
tok2str(oam_fm_loopback_indicator_values,
|
||||
"Unknown",
|
||||
oam_ptr.oam_fm_loopback->loopback_indicator & OAM_FM_LOOPBACK_INDICATOR_MASK),
|
||||
EXTRACT_32BITS(&oam_ptr.oam_fm_loopback->correlation_tag));
|
||||
printf("\n\tLocation-ID ");
|
||||
EXTRACT_32BITS(&oam_ptr.oam_fm_loopback->correlation_tag)));
|
||||
ND_PRINT((ndo, "\n\tLocation-ID "));
|
||||
for (idx = 0; idx < sizeof(oam_ptr.oam_fm_loopback->loopback_id); idx++) {
|
||||
if (idx % 2) {
|
||||
printf("%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->loopback_id[idx]));
|
||||
ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->loopback_id[idx])));
|
||||
}
|
||||
}
|
||||
printf("\n\tSource-ID ");
|
||||
ND_PRINT((ndo, "\n\tSource-ID "));
|
||||
for (idx = 0; idx < sizeof(oam_ptr.oam_fm_loopback->source_id); idx++) {
|
||||
if (idx % 2) {
|
||||
printf("%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->source_id[idx]));
|
||||
ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->source_id[idx])));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -418,11 +418,11 @@ oam_print (const u_char *p, u_int length, u_int hec) {
|
||||
case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_AIS):
|
||||
case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_RDI):
|
||||
oam_ptr.oam_fm_ais_rdi = (const struct oam_fm_ais_rdi_t *)(p + OAM_CELLTYPE_FUNCTYPE_LEN);
|
||||
printf("\n\tFailure-type 0x%02x", oam_ptr.oam_fm_ais_rdi->failure_type);
|
||||
printf("\n\tLocation-ID ");
|
||||
ND_PRINT((ndo, "\n\tFailure-type 0x%02x", oam_ptr.oam_fm_ais_rdi->failure_type));
|
||||
ND_PRINT((ndo, "\n\tLocation-ID "));
|
||||
for (idx = 0; idx < sizeof(oam_ptr.oam_fm_ais_rdi->failure_location); idx++) {
|
||||
if (idx % 2) {
|
||||
printf("%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_ais_rdi->failure_location[idx]));
|
||||
ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_ais_rdi->failure_location[idx])));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -440,9 +440,9 @@ oam_print (const u_char *p, u_int length, u_int hec) {
|
||||
& OAM_CRC10_MASK;
|
||||
cksum_shouldbe = verify_crc10_cksum(0, p, OAM_PAYLOAD_LEN);
|
||||
|
||||
printf("\n\tcksum 0x%03x (%scorrect)",
|
||||
ND_PRINT((ndo, "\n\tcksum 0x%03x (%scorrect)",
|
||||
cksum,
|
||||
cksum_shouldbe == 0 ? "" : "in");
|
||||
cksum_shouldbe == 0 ? "" : "in"));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -922,7 +922,7 @@ juniper_atm1_print(const struct pcap_pkthdr *h, register const u_char *p)
|
||||
p+=l2info.header_len;
|
||||
|
||||
if (l2info.cookie[0] == 0x80) { /* OAM cell ? */
|
||||
oam_print(p,l2info.length,ATM_OAM_NOHEC);
|
||||
oam_print(gndo, p, l2info.length, ATM_OAM_NOHEC);
|
||||
return l2info.header_len;
|
||||
}
|
||||
|
||||
@ -970,7 +970,7 @@ juniper_atm2_print(const struct pcap_pkthdr *h, register const u_char *p)
|
||||
p+=l2info.header_len;
|
||||
|
||||
if (l2info.cookie[7] & ATM2_PKT_TYPE_MASK) { /* OAM cell ? */
|
||||
oam_print(p,l2info.length,ATM_OAM_NOHEC);
|
||||
oam_print(gndo, p, l2info.length, ATM_OAM_NOHEC);
|
||||
return l2info.header_len;
|
||||
}
|
||||
|
||||
|
@ -434,7 +434,7 @@ snap_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
|
||||
udld_print(ndo, p, length);
|
||||
return (1);
|
||||
case PID_CISCO_VTP:
|
||||
vtp_print(p, length);
|
||||
vtp_print(ndo, p, length);
|
||||
return (1);
|
||||
case PID_CISCO_PVST:
|
||||
case PID_CISCO_VLANBRIDGE:
|
||||
|
121
print-mptcp.c
121
print-mptcp.c
@ -32,20 +32,17 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define NETDISSECT_REWORKED
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <tcpdump-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "interface.h"
|
||||
#include "extract.h"
|
||||
#include "addrtoname.h"
|
||||
|
||||
#include "ipproto.h"
|
||||
#include "tcp.h"
|
||||
|
||||
#define MPTCP_SUB_CAPABLE 0x0
|
||||
@ -165,12 +162,16 @@ struct mp_prio {
|
||||
|
||||
#define MP_PRIO_B 0x01
|
||||
|
||||
static int dummy_print(const u_char *opt _U_, u_int opt_len _U_, u_char flags _U_)
|
||||
static int
|
||||
dummy_print(netdissect_options *ndo _U_,
|
||||
const u_char *opt _U_, u_int opt_len _U_, u_char flags _U_)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int mp_capable_print(const u_char *opt, u_int opt_len, u_char flags)
|
||||
static int
|
||||
mp_capable_print(netdissect_options *ndo,
|
||||
const u_char *opt, u_int opt_len, u_char flags)
|
||||
{
|
||||
struct mp_capable *mpc = (struct mp_capable *) opt;
|
||||
|
||||
@ -179,20 +180,22 @@ static int mp_capable_print(const u_char *opt, u_int opt_len, u_char flags)
|
||||
return 0;
|
||||
|
||||
if (MP_CAPABLE_OPT_VERSION(mpc->sub_ver) != 0) {
|
||||
printf(" Unknown Version (%d)", MP_CAPABLE_OPT_VERSION(mpc->sub_ver));
|
||||
ND_PRINT((ndo, " Unknown Version (%d)", MP_CAPABLE_OPT_VERSION(mpc->sub_ver)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (mpc->flags & MP_CAPABLE_C)
|
||||
printf(" csum");
|
||||
printf(" {0x%" PRIx64, EXTRACT_64BITS(mpc->sender_key));
|
||||
ND_PRINT((ndo, " csum"));
|
||||
ND_PRINT((ndo, " {0x%" PRIx64, EXTRACT_64BITS(mpc->sender_key)));
|
||||
if (opt_len == 20) /* ACK */
|
||||
printf(",0x%" PRIx64, EXTRACT_64BITS(mpc->receiver_key));
|
||||
printf("}");
|
||||
ND_PRINT((ndo, ",0x%" PRIx64, EXTRACT_64BITS(mpc->receiver_key)));
|
||||
ND_PRINT((ndo, "}"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int mp_join_print(const u_char *opt, u_int opt_len, u_char flags)
|
||||
static int
|
||||
mp_join_print(netdissect_options *ndo,
|
||||
const u_char *opt, u_int opt_len, u_char flags)
|
||||
{
|
||||
struct mp_join *mpj = (struct mp_join *) opt;
|
||||
|
||||
@ -203,26 +206,26 @@ static int mp_join_print(const u_char *opt, u_int opt_len, u_char flags)
|
||||
|
||||
if (opt_len != 24) {
|
||||
if (mpj->sub_b & MP_JOIN_B)
|
||||
printf(" backup");
|
||||
printf(" id %u", mpj->addr_id);
|
||||
ND_PRINT((ndo, " backup"));
|
||||
ND_PRINT((ndo, " id %u", mpj->addr_id));
|
||||
}
|
||||
|
||||
switch (opt_len) {
|
||||
case 12: /* SYN */
|
||||
printf(" token 0x%x" " nonce 0x%x",
|
||||
ND_PRINT((ndo, " token 0x%x" " nonce 0x%x",
|
||||
EXTRACT_32BITS(mpj->u.syn.token),
|
||||
EXTRACT_32BITS(mpj->u.syn.nonce));
|
||||
EXTRACT_32BITS(mpj->u.syn.nonce)));
|
||||
break;
|
||||
case 16: /* SYN/ACK */
|
||||
printf(" hmac 0x%" PRIx64 " nonce 0x%x",
|
||||
ND_PRINT((ndo, " hmac 0x%" PRIx64 " nonce 0x%x",
|
||||
EXTRACT_64BITS(mpj->u.synack.mac),
|
||||
EXTRACT_32BITS(mpj->u.synack.nonce));
|
||||
EXTRACT_32BITS(mpj->u.synack.nonce)));
|
||||
break;
|
||||
case 24: {/* ACK */
|
||||
size_t i;
|
||||
printf(" hmac 0x");
|
||||
ND_PRINT((ndo, " hmac 0x"));
|
||||
for (i = 0; i < sizeof(mpj->u.ack.mac); ++i)
|
||||
printf("%02x", mpj->u.ack.mac[i]);
|
||||
ND_PRINT((ndo, "%02x", mpj->u.ack.mac[i]));
|
||||
}
|
||||
default:
|
||||
break;
|
||||
@ -258,7 +261,9 @@ static u_int mp_dss_len(struct mp_dss *m, int csum)
|
||||
return len;
|
||||
}
|
||||
|
||||
static int mp_dss_print(const u_char *opt, u_int opt_len, u_char flags)
|
||||
static int
|
||||
mp_dss_print(netdissect_options *ndo,
|
||||
const u_char *opt, u_int opt_len, u_char flags)
|
||||
{
|
||||
struct mp_dss *mdss = (struct mp_dss *) opt;
|
||||
|
||||
@ -267,41 +272,43 @@ static int mp_dss_print(const u_char *opt, u_int opt_len, u_char flags)
|
||||
return 0;
|
||||
|
||||
if (mdss->flags & MP_DSS_F)
|
||||
printf(" fin");
|
||||
ND_PRINT((ndo, " fin"));
|
||||
|
||||
opt += 4;
|
||||
if (mdss->flags & MP_DSS_A) {
|
||||
printf(" ack ");
|
||||
ND_PRINT((ndo, " ack "));
|
||||
if (mdss->flags & MP_DSS_a) {
|
||||
printf("%" PRIu64, EXTRACT_64BITS(opt));
|
||||
ND_PRINT((ndo, "%" PRIu64, EXTRACT_64BITS(opt)));
|
||||
opt += 8;
|
||||
} else {
|
||||
printf("%u", EXTRACT_32BITS(opt));
|
||||
ND_PRINT((ndo, "%u", EXTRACT_32BITS(opt)));
|
||||
opt += 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (mdss->flags & MP_DSS_M) {
|
||||
printf(" seq ");
|
||||
ND_PRINT((ndo, " seq "));
|
||||
if (mdss->flags & MP_DSS_m) {
|
||||
printf("%" PRIu64, EXTRACT_64BITS(opt));
|
||||
ND_PRINT((ndo, "%" PRIu64, EXTRACT_64BITS(opt)));
|
||||
opt += 8;
|
||||
} else {
|
||||
printf("%u", EXTRACT_32BITS(opt));
|
||||
ND_PRINT((ndo, "%u", EXTRACT_32BITS(opt)));
|
||||
opt += 4;
|
||||
}
|
||||
printf(" subseq %u", EXTRACT_32BITS(opt));
|
||||
ND_PRINT((ndo, " subseq %u", EXTRACT_32BITS(opt)));
|
||||
opt += 4;
|
||||
printf(" len %u", EXTRACT_16BITS(opt));
|
||||
ND_PRINT((ndo, " len %u", EXTRACT_16BITS(opt)));
|
||||
opt += 2;
|
||||
|
||||
if (opt_len == mp_dss_len(mdss, 1))
|
||||
printf(" csum 0x%x", EXTRACT_16BITS(opt));
|
||||
ND_PRINT((ndo, " csum 0x%x", EXTRACT_16BITS(opt)));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int add_addr_print(const u_char *opt, u_int opt_len, u_char flags _U_)
|
||||
static int
|
||||
add_addr_print(netdissect_options *ndo,
|
||||
const u_char *opt, u_int opt_len, u_char flags _U_)
|
||||
{
|
||||
struct mp_add_addr *add_addr = (struct mp_add_addr *) opt;
|
||||
u_int ipver = MP_ADD_ADDR_IPVER(add_addr->sub_ipver);
|
||||
@ -310,19 +317,19 @@ static int add_addr_print(const u_char *opt, u_int opt_len, u_char flags _U_)
|
||||
!((opt_len == 20 || opt_len == 22) && ipver == 6))
|
||||
return 0;
|
||||
|
||||
printf(" id %u", add_addr->addr_id);
|
||||
ND_PRINT((ndo, " id %u", add_addr->addr_id));
|
||||
switch (ipver) {
|
||||
case 4:
|
||||
printf(" %s", ipaddr_string(add_addr->u.v4.addr));
|
||||
ND_PRINT((ndo, " %s", ipaddr_string(add_addr->u.v4.addr)));
|
||||
if (opt_len == 10)
|
||||
printf(":%u", EXTRACT_16BITS(add_addr->u.v4.port));
|
||||
ND_PRINT((ndo, ":%u", EXTRACT_16BITS(add_addr->u.v4.port)));
|
||||
break;
|
||||
case 6:
|
||||
#ifdef INET6
|
||||
printf(" %s", ip6addr_string(add_addr->u.v6.addr));
|
||||
ND_PRINT((ndo, " %s", ip6addr_string(add_addr->u.v6.addr)));
|
||||
#endif
|
||||
if (opt_len == 22)
|
||||
printf(":%u", EXTRACT_16BITS(add_addr->u.v6.port));
|
||||
ND_PRINT((ndo, ":%u", EXTRACT_16BITS(add_addr->u.v6.port)));
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
@ -331,7 +338,9 @@ static int add_addr_print(const u_char *opt, u_int opt_len, u_char flags _U_)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int remove_addr_print(const u_char *opt, u_int opt_len, u_char flags _U_)
|
||||
static int
|
||||
remove_addr_print(netdissect_options *ndo,
|
||||
const u_char *opt, u_int opt_len, u_char flags _U_)
|
||||
{
|
||||
struct mp_remove_addr *remove_addr = (struct mp_remove_addr *) opt;
|
||||
u_int8_t *addr_id = &remove_addr->addrs_id;
|
||||
@ -340,13 +349,15 @@ static int remove_addr_print(const u_char *opt, u_int opt_len, u_char flags _U_)
|
||||
return 0;
|
||||
|
||||
opt_len -= 3;
|
||||
printf(" id");
|
||||
ND_PRINT((ndo, " id"));
|
||||
while (opt_len--)
|
||||
printf(" %u", *addr_id++);
|
||||
ND_PRINT((ndo, " %u", *addr_id++));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int mp_prio_print(const u_char *opt, u_int opt_len, u_char flags _U_)
|
||||
static int
|
||||
mp_prio_print(netdissect_options *ndo,
|
||||
const u_char *opt, u_int opt_len, u_char flags _U_)
|
||||
{
|
||||
struct mp_prio *mpp = (struct mp_prio *) opt;
|
||||
|
||||
@ -354,36 +365,40 @@ static int mp_prio_print(const u_char *opt, u_int opt_len, u_char flags _U_)
|
||||
return 0;
|
||||
|
||||
if (mpp->sub_b & MP_PRIO_B)
|
||||
printf(" backup");
|
||||
ND_PRINT((ndo, " backup"));
|
||||
else
|
||||
printf(" non-backup");
|
||||
ND_PRINT((ndo, " non-backup"));
|
||||
if (opt_len == 4)
|
||||
printf(" id %u", mpp->addr_id);
|
||||
ND_PRINT((ndo, " id %u", mpp->addr_id));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int mp_fail_print(const u_char *opt, u_int opt_len, u_char flags _U_)
|
||||
static int
|
||||
mp_fail_print(netdissect_options *ndo,
|
||||
const u_char *opt, u_int opt_len, u_char flags _U_)
|
||||
{
|
||||
if (opt_len != 12)
|
||||
return 0;
|
||||
|
||||
printf(" seq %" PRIu64, EXTRACT_64BITS(opt + 4));
|
||||
ND_PRINT((ndo, " seq %" PRIu64, EXTRACT_64BITS(opt + 4)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int mp_fast_close_print(const u_char *opt, u_int opt_len, u_char flags _U_)
|
||||
static int
|
||||
mp_fast_close_print(netdissect_options *ndo,
|
||||
const u_char *opt, u_int opt_len, u_char flags _U_)
|
||||
{
|
||||
if (opt_len != 12)
|
||||
return 0;
|
||||
|
||||
printf(" key 0x%" PRIx64, EXTRACT_64BITS(opt + 4));
|
||||
ND_PRINT((ndo, " key 0x%" PRIx64, EXTRACT_64BITS(opt + 4)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const struct {
|
||||
const char *name;
|
||||
int (*print)(const u_char *, u_int, u_char);
|
||||
int (*print)(netdissect_options *, const u_char *, u_int, u_char);
|
||||
} mptcp_options[] = {
|
||||
{ "capable", mp_capable_print},
|
||||
{ "join", mp_join_print },
|
||||
@ -396,7 +411,9 @@ static const struct {
|
||||
{ "unknown", dummy_print },
|
||||
};
|
||||
|
||||
int mptcp_print(const u_char *cp, u_int len, u_char flags)
|
||||
int
|
||||
mptcp_print(netdissect_options *ndo,
|
||||
const u_char *cp, u_int len, u_char flags)
|
||||
{
|
||||
struct mptcp_option *opt;
|
||||
u_int subtype;
|
||||
@ -407,6 +424,6 @@ int mptcp_print(const u_char *cp, u_int len, u_char flags)
|
||||
opt = (struct mptcp_option *) cp;
|
||||
subtype = min(MPTCP_OPT_SUBTYPE(opt->sub_etc), MPTCP_SUB_FCLOSE + 1);
|
||||
|
||||
printf(" %s", mptcp_options[subtype].name);
|
||||
return mptcp_options[subtype].print(cp, len, flags);
|
||||
ND_PRINT((ndo, " %s", mptcp_options[subtype].name));
|
||||
return mptcp_options[subtype].print(ndo, cp, len, flags);
|
||||
}
|
||||
|
131
print-ntp.c
131
print-ntp.c
@ -23,14 +23,13 @@
|
||||
* loosely based on print-bootp.c
|
||||
*/
|
||||
|
||||
#define NETDISSECT_REWORKED
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <tcpdump-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_STRFTIME
|
||||
#include <time.h>
|
||||
#endif
|
||||
@ -168,9 +167,9 @@ struct ntpdata {
|
||||
#define INFO_QUERY 62 /* **** THIS implementation dependent **** */
|
||||
#define INFO_REPLY 63 /* **** THIS implementation dependent **** */
|
||||
|
||||
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 void p_sfix(netdissect_options *ndo, const struct s_fixedpt *);
|
||||
static void p_ntp_time(netdissect_options *, const struct l_fixedpt *);
|
||||
static void p_ntp_delta(netdissect_options *, const struct l_fixedpt *, const struct l_fixedpt *);
|
||||
|
||||
static const struct tok ntp_mode_values[] = {
|
||||
{ MODE_UNSPEC, "unspecified" },
|
||||
@ -202,20 +201,21 @@ static const struct tok ntp_stratum_values[] = {
|
||||
* Print ntp requests
|
||||
*/
|
||||
void
|
||||
ntp_print(register const u_char *cp, u_int length)
|
||||
ntp_print(netdissect_options *ndo,
|
||||
register const u_char *cp, u_int length)
|
||||
{
|
||||
register const struct ntpdata *bp;
|
||||
int mode, version, leapind;
|
||||
|
||||
bp = (struct ntpdata *)cp;
|
||||
|
||||
TCHECK(bp->status);
|
||||
ND_TCHECK(bp->status);
|
||||
|
||||
version = (int)(bp->status & VERSIONMASK) >> 3;
|
||||
printf("NTPv%d", version);
|
||||
ND_PRINT((ndo, "NTPv%d", version));
|
||||
|
||||
mode = bp->status & MODEMASK;
|
||||
if (!vflag) {
|
||||
if (!ndo->ndo_vflag) {
|
||||
printf (", %s, length %u",
|
||||
tok2str(ntp_mode_values, "Unknown mode", mode),
|
||||
length);
|
||||
@ -231,98 +231,99 @@ ntp_print(register const u_char *cp, u_int length)
|
||||
tok2str(ntp_leapind_values, "Unknown", leapind),
|
||||
leapind);
|
||||
|
||||
TCHECK(bp->stratum);
|
||||
printf(", Stratum %u (%s)",
|
||||
ND_TCHECK(bp->stratum);
|
||||
ND_PRINT((ndo, ", Stratum %u (%s)",
|
||||
bp->stratum,
|
||||
tok2str(ntp_stratum_values, (bp->stratum >=2 && bp->stratum<=15) ? "secondary reference" : "reserved", bp->stratum));
|
||||
tok2str(ntp_stratum_values, (bp->stratum >=2 && bp->stratum<=15) ? "secondary reference" : "reserved", bp->stratum)));
|
||||
|
||||
TCHECK(bp->ppoll);
|
||||
printf(", poll %u (%us)", bp->ppoll, 1 << bp->ppoll);
|
||||
ND_TCHECK(bp->ppoll);
|
||||
ND_PRINT((ndo, ", poll %u (%us)", bp->ppoll, 1 << bp->ppoll));
|
||||
|
||||
/* Can't TCHECK bp->precision bitfield so bp->distance + 0 instead */
|
||||
TCHECK2(bp->root_delay, 0);
|
||||
printf(", precision %d", bp->precision);
|
||||
/* Can't ND_TCHECK bp->precision bitfield so bp->distance + 0 instead */
|
||||
ND_TCHECK2(bp->root_delay, 0);
|
||||
ND_PRINT((ndo, ", precision %d", bp->precision));
|
||||
|
||||
TCHECK(bp->root_delay);
|
||||
fputs("\n\tRoot Delay: ", stdout);
|
||||
p_sfix(&bp->root_delay);
|
||||
ND_TCHECK(bp->root_delay);
|
||||
ND_PRINT((ndo, "\n\tRoot Delay: "));
|
||||
p_sfix(ndo, &bp->root_delay);
|
||||
|
||||
TCHECK(bp->root_dispersion);
|
||||
fputs(", Root dispersion: ", stdout);
|
||||
p_sfix(&bp->root_dispersion);
|
||||
ND_TCHECK(bp->root_dispersion);
|
||||
ND_PRINT((ndo, ", Root dispersion: "));
|
||||
p_sfix(ndo, &bp->root_dispersion);
|
||||
|
||||
TCHECK(bp->refid);
|
||||
fputs(", Reference-ID: ", stdout);
|
||||
ND_TCHECK(bp->refid);
|
||||
ND_PRINT((ndo, ", Reference-ID: "));
|
||||
/* Interpretation depends on stratum */
|
||||
switch (bp->stratum) {
|
||||
|
||||
case UNSPECIFIED:
|
||||
printf("(unspec)");
|
||||
ND_PRINT((ndo, "(unspec)"));
|
||||
break;
|
||||
|
||||
case PRIM_REF:
|
||||
if (fn_printn((u_char *)&(bp->refid), 4, snapend))
|
||||
if (fn_printn((u_char *)&(bp->refid), 4, ndo->ndo_snapend))
|
||||
goto trunc;
|
||||
break;
|
||||
|
||||
case INFO_QUERY:
|
||||
printf("%s INFO_QUERY", ipaddr_string(&(bp->refid)));
|
||||
ND_PRINT((ndo, "%s INFO_QUERY", ipaddr_string(&(bp->refid))));
|
||||
/* this doesn't have more content */
|
||||
return;
|
||||
|
||||
case INFO_REPLY:
|
||||
printf("%s INFO_REPLY", ipaddr_string(&(bp->refid)));
|
||||
ND_PRINT((ndo, "%s INFO_REPLY", ipaddr_string(&(bp->refid))));
|
||||
/* this is too complex to be worth printing */
|
||||
return;
|
||||
|
||||
default:
|
||||
printf("%s", ipaddr_string(&(bp->refid)));
|
||||
ND_PRINT((ndo, "%s", ipaddr_string(&(bp->refid))));
|
||||
break;
|
||||
}
|
||||
|
||||
TCHECK(bp->ref_timestamp);
|
||||
fputs("\n\t Reference Timestamp: ", stdout);
|
||||
p_ntp_time(&(bp->ref_timestamp));
|
||||
ND_TCHECK(bp->ref_timestamp);
|
||||
ND_PRINT((ndo, "\n\t Reference Timestamp: "));
|
||||
p_ntp_time(ndo, &(bp->ref_timestamp));
|
||||
|
||||
TCHECK(bp->org_timestamp);
|
||||
fputs("\n\t Originator Timestamp: ", stdout);
|
||||
p_ntp_time(&(bp->org_timestamp));
|
||||
ND_TCHECK(bp->org_timestamp);
|
||||
ND_PRINT((ndo, "\n\t Originator Timestamp: "));
|
||||
p_ntp_time(ndo, &(bp->org_timestamp));
|
||||
|
||||
TCHECK(bp->rec_timestamp);
|
||||
fputs("\n\t Receive Timestamp: ", stdout);
|
||||
p_ntp_time(&(bp->rec_timestamp));
|
||||
ND_TCHECK(bp->rec_timestamp);
|
||||
ND_PRINT((ndo, "\n\t Receive Timestamp: "));
|
||||
p_ntp_time(ndo, &(bp->rec_timestamp));
|
||||
|
||||
TCHECK(bp->xmt_timestamp);
|
||||
fputs("\n\t Transmit Timestamp: ", stdout);
|
||||
p_ntp_time(&(bp->xmt_timestamp));
|
||||
ND_TCHECK(bp->xmt_timestamp);
|
||||
ND_PRINT((ndo, "\n\t Transmit Timestamp: "));
|
||||
p_ntp_time(ndo, &(bp->xmt_timestamp));
|
||||
|
||||
fputs("\n\t Originator - Receive Timestamp: ", stdout);
|
||||
p_ntp_delta(&(bp->org_timestamp), &(bp->rec_timestamp));
|
||||
ND_PRINT((ndo, "\n\t Originator - Receive Timestamp: "));
|
||||
p_ntp_delta(ndo, &(bp->org_timestamp), &(bp->rec_timestamp));
|
||||
|
||||
fputs("\n\t Originator - Transmit Timestamp: ", stdout);
|
||||
p_ntp_delta(&(bp->org_timestamp), &(bp->xmt_timestamp));
|
||||
ND_PRINT((ndo, "\n\t Originator - Transmit Timestamp: "));
|
||||
p_ntp_delta(ndo, &(bp->org_timestamp), &(bp->xmt_timestamp));
|
||||
|
||||
if ( (sizeof(struct ntpdata) - length) == 16) { /* Optional: key-id */
|
||||
TCHECK(bp->key_id);
|
||||
printf("\n\tKey id: %u", bp->key_id);
|
||||
ND_TCHECK(bp->key_id);
|
||||
ND_PRINT((ndo, "\n\tKey id: %u", bp->key_id));
|
||||
} else if ( (sizeof(struct ntpdata) - length) == 0) { /* Optional: key-id + authentication */
|
||||
TCHECK(bp->key_id);
|
||||
printf("\n\tKey id: %u", bp->key_id);
|
||||
TCHECK2(bp->message_digest, sizeof (bp->message_digest));
|
||||
printf("\n\tAuthentication: %08x%08x%08x%08x",
|
||||
ND_TCHECK(bp->key_id);
|
||||
ND_PRINT((ndo, "\n\tKey id: %u", bp->key_id));
|
||||
ND_TCHECK2(bp->message_digest, sizeof (bp->message_digest));
|
||||
ND_PRINT((ndo, "\n\tAuthentication: %08x%08x%08x%08x",
|
||||
EXTRACT_32BITS(bp->message_digest),
|
||||
EXTRACT_32BITS(bp->message_digest + 4),
|
||||
EXTRACT_32BITS(bp->message_digest + 8),
|
||||
EXTRACT_32BITS(bp->message_digest + 12));
|
||||
EXTRACT_32BITS(bp->message_digest + 12)));
|
||||
}
|
||||
return;
|
||||
|
||||
trunc:
|
||||
fputs(" [|ntp]", stdout);
|
||||
ND_PRINT((ndo, " [|ntp]"));
|
||||
}
|
||||
|
||||
static void
|
||||
p_sfix(register const struct s_fixedpt *sfp)
|
||||
p_sfix(netdissect_options *ndo,
|
||||
register const struct s_fixedpt *sfp)
|
||||
{
|
||||
register int i;
|
||||
register int f;
|
||||
@ -332,13 +333,14 @@ p_sfix(register const struct s_fixedpt *sfp)
|
||||
f = EXTRACT_16BITS(&sfp->fraction);
|
||||
ff = f / 65536.0; /* shift radix point by 16 bits */
|
||||
f = ff * 1000000.0; /* Treat fraction as parts per million */
|
||||
printf("%d.%06d", i, f);
|
||||
ND_PRINT((ndo, "%d.%06d", i, f));
|
||||
}
|
||||
|
||||
#define FMAXINT (4294967296.0) /* floating point rep. of MAXINT */
|
||||
|
||||
static void
|
||||
p_ntp_time(register const struct l_fixedpt *lfp)
|
||||
p_ntp_time(netdissect_options *ndo,
|
||||
register const struct l_fixedpt *lfp)
|
||||
{
|
||||
register int32_t i;
|
||||
register u_int32_t uf;
|
||||
@ -352,7 +354,7 @@ p_ntp_time(register const struct l_fixedpt *lfp)
|
||||
ff += FMAXINT;
|
||||
ff = ff / FMAXINT; /* shift radix point by 32 bits */
|
||||
f = ff * 1000000000.0; /* treat fraction as parts per billion */
|
||||
printf("%u.%09d", i, f);
|
||||
ND_PRINT((ndo, "%u.%09d", i, f));
|
||||
|
||||
#ifdef HAVE_STRFTIME
|
||||
/*
|
||||
@ -372,8 +374,9 @@ p_ntp_time(register const struct l_fixedpt *lfp)
|
||||
|
||||
/* Prints time difference between *lfp and *olfp */
|
||||
static void
|
||||
p_ntp_delta(register const struct l_fixedpt *olfp,
|
||||
register const struct l_fixedpt *lfp)
|
||||
p_ntp_delta(netdissect_options *ndo,
|
||||
register const struct l_fixedpt *olfp,
|
||||
register const struct l_fixedpt *lfp)
|
||||
{
|
||||
register int32_t i;
|
||||
register u_int32_t u, uf;
|
||||
@ -387,7 +390,7 @@ p_ntp_delta(register const struct l_fixedpt *olfp,
|
||||
uf = EXTRACT_32BITS(&lfp->fraction);
|
||||
ouf = EXTRACT_32BITS(&olfp->fraction);
|
||||
if (ou == 0 && ouf == 0) {
|
||||
p_ntp_time(lfp);
|
||||
p_ntp_time(ndo, lfp);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -419,10 +422,6 @@ p_ntp_delta(register const struct l_fixedpt *olfp,
|
||||
ff += FMAXINT;
|
||||
ff = ff / FMAXINT; /* shift radix point by 32 bits */
|
||||
f = ff * 1000000000.0; /* treat fraction as parts per billion */
|
||||
if (signbit)
|
||||
putchar('-');
|
||||
else
|
||||
putchar('+');
|
||||
printf("%d.%09d", i, f);
|
||||
ND_PRINT((ndo, "%s%d.%09d", signbit ? "-" : "+", i, f));
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define NETDISSECT_REWORKED
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
@ -39,13 +40,10 @@
|
||||
struct mbuf;
|
||||
struct rtentry;
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "interface.h"
|
||||
#include "extract.h"
|
||||
|
||||
#include "atm.h"
|
||||
#include "atmuni31.h"
|
||||
|
||||
/* SunATM header for ATM packet */
|
||||
#define DIR_POS 0 /* Direction (0x80 = transmit, 0x00 = receive) */
|
||||
@ -64,7 +62,8 @@ struct rtentry;
|
||||
* is the number of bytes actually captured.
|
||||
*/
|
||||
u_int
|
||||
sunatm_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
sunatm_if_print(netdissect_options *ndo,
|
||||
const struct pcap_pkthdr *h, const u_char *p)
|
||||
{
|
||||
u_int caplen = h->caplen;
|
||||
u_int length = h->len;
|
||||
@ -73,15 +72,12 @@ sunatm_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
u_int traftype;
|
||||
|
||||
if (caplen < PKT_BEGIN_POS) {
|
||||
printf("[|atm]");
|
||||
ND_PRINT((ndo, "[|atm]"));
|
||||
return (caplen);
|
||||
}
|
||||
|
||||
if (eflag) {
|
||||
if (p[DIR_POS] & 0x80)
|
||||
printf("Tx: ");
|
||||
else
|
||||
printf("Rx: ");
|
||||
if (ndo->ndo_eflag) {
|
||||
ND_PRINT((ndo, p[DIR_POS] & 0x80 ? "Tx: " : "Rx: "));
|
||||
}
|
||||
|
||||
switch (p[DIR_POS] & 0x0f) {
|
||||
@ -105,7 +101,7 @@ sunatm_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
p += PKT_BEGIN_POS;
|
||||
caplen -= PKT_BEGIN_POS;
|
||||
length -= PKT_BEGIN_POS;
|
||||
atm_print(vpi, vci, traftype, p, length, caplen);
|
||||
atm_print(ndo, vpi, vci, traftype, p, length, caplen);
|
||||
|
||||
return (PKT_BEGIN_POS);
|
||||
}
|
||||
|
@ -576,7 +576,7 @@ tcp_print(register const u_char *bp, register u_int length,
|
||||
case TCPOPT_MPTCP:
|
||||
datalen = len - 2;
|
||||
LENCHECK(datalen);
|
||||
if (!mptcp_print(cp-2, len, flags))
|
||||
if (!mptcp_print(gndo, cp-2, len, flags))
|
||||
goto bad;
|
||||
break;
|
||||
|
||||
|
@ -410,7 +410,7 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
|
||||
|
||||
case PT_WB:
|
||||
udpipaddr_print(ndo, ip, sport, dport);
|
||||
wb_print((void *)(up + 1), length);
|
||||
wb_print(ndo, (void *)(up + 1), length);
|
||||
break;
|
||||
|
||||
case PT_RPC:
|
||||
@ -593,7 +593,7 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
|
||||
else if (ISPORT(SNMP_PORT) || ISPORT(SNMPTRAP_PORT))
|
||||
snmp_print((const u_char *)(up + 1), length);
|
||||
else if (ISPORT(NTP_PORT))
|
||||
ntp_print((const u_char *)(up + 1), length);
|
||||
ntp_print(ndo, (const u_char *)(up + 1), length);
|
||||
else if (ISPORT(KERBEROS_PORT) || ISPORT(KERBEROS_SEC_PORT))
|
||||
krb_print((const void *)(up + 1));
|
||||
else if (ISPORT(L2TP_PORT))
|
||||
@ -630,7 +630,7 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
|
||||
* Kludge in test for whiteboard packets.
|
||||
*/
|
||||
else if (dport == WB_PORT)
|
||||
wb_print((const void *)(up + 1), length);
|
||||
wb_print(ndo, (const void *)(up + 1), length);
|
||||
else if (ISPORT(CISCO_AUTORP_PORT))
|
||||
cisco_autorp_print((const void *)(up + 1), length);
|
||||
else if (ISPORT(RADIUS_PORT) ||
|
||||
|
70
print-vtp.c
70
print-vtp.c
@ -22,19 +22,16 @@
|
||||
* Original code ode by Carles Kishimoto <carles.kishimoto@gmail.com>
|
||||
*/
|
||||
|
||||
#define NETDISSECT_REWORKED
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <tcpdump-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "interface.h"
|
||||
#include "addrtoname.h"
|
||||
#include "extract.h"
|
||||
#include "nlpid.h"
|
||||
|
||||
#define VTP_HEADER_LEN 36
|
||||
#define VTP_DOMAIN_NAME_LEN 32
|
||||
@ -121,7 +118,8 @@ static const struct tok vtp_stp_type_values[] = {
|
||||
};
|
||||
|
||||
void
|
||||
vtp_print (const u_char *pptr, u_int length)
|
||||
vtp_print (netdissect_options *ndo,
|
||||
const u_char *pptr, u_int length)
|
||||
{
|
||||
int type, len, tlv_len, tlv_value;
|
||||
const u_char *tptr;
|
||||
@ -132,26 +130,26 @@ vtp_print (const u_char *pptr, u_int length)
|
||||
|
||||
tptr = pptr;
|
||||
|
||||
if (!TTEST2(*tptr, VTP_HEADER_LEN))
|
||||
if (!ND_TTEST2(*tptr, VTP_HEADER_LEN))
|
||||
goto trunc;
|
||||
|
||||
type = *(tptr+1);
|
||||
printf("VTPv%u, Message %s (0x%02x), length %u",
|
||||
ND_PRINT((ndo, "VTPv%u, Message %s (0x%02x), length %u",
|
||||
*tptr,
|
||||
tok2str(vtp_message_type_values,"Unknown message type", type),
|
||||
*(tptr+1),
|
||||
length);
|
||||
length));
|
||||
|
||||
/* In non-verbose mode, just print version and message type */
|
||||
if (vflag < 1) {
|
||||
if (ndo->ndo_vflag < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* verbose mode print all fields */
|
||||
printf("\n\tDomain name: %s, %s: %u",
|
||||
ND_PRINT((ndo, "\n\tDomain name: %s, %s: %u",
|
||||
(tptr+4),
|
||||
tok2str(vtp_header_values,"Unknown",*(tptr+1)),
|
||||
*(tptr+2));
|
||||
*(tptr+2)));
|
||||
|
||||
tptr += VTP_HEADER_LEN;
|
||||
|
||||
@ -179,20 +177,20 @@ vtp_print (const u_char *pptr, u_int length)
|
||||
*
|
||||
*/
|
||||
|
||||
printf("\n\t Config Rev %x, Updater %s",
|
||||
ND_PRINT((ndo, "\n\t Config Rev %x, Updater %s",
|
||||
EXTRACT_32BITS(tptr),
|
||||
ipaddr_string(tptr+4));
|
||||
ipaddr_string(tptr+4)));
|
||||
tptr += 8;
|
||||
printf(", Timestamp 0x%08x 0x%08x 0x%08x",
|
||||
ND_PRINT((ndo, ", Timestamp 0x%08x 0x%08x 0x%08x",
|
||||
EXTRACT_32BITS(tptr),
|
||||
EXTRACT_32BITS(tptr + 4),
|
||||
EXTRACT_32BITS(tptr + 8));
|
||||
EXTRACT_32BITS(tptr + 8)));
|
||||
tptr += VTP_UPDATE_TIMESTAMP_LEN;
|
||||
printf(", MD5 digest: %08x%08x%08x%08x",
|
||||
ND_PRINT((ndo, ", MD5 digest: %08x%08x%08x%08x",
|
||||
EXTRACT_32BITS(tptr),
|
||||
EXTRACT_32BITS(tptr + 4),
|
||||
EXTRACT_32BITS(tptr + 8),
|
||||
EXTRACT_32BITS(tptr + 12));
|
||||
EXTRACT_32BITS(tptr + 12)));
|
||||
tptr += VTP_MD5_DIGEST_LEN;
|
||||
break;
|
||||
|
||||
@ -218,7 +216,7 @@ vtp_print (const u_char *pptr, u_int length)
|
||||
*
|
||||
*/
|
||||
|
||||
printf(", Config Rev %x", EXTRACT_32BITS(tptr));
|
||||
ND_PRINT((ndo, ", Config Rev %x", EXTRACT_32BITS(tptr)));
|
||||
|
||||
/*
|
||||
* VLAN INFORMATION
|
||||
@ -242,17 +240,17 @@ vtp_print (const u_char *pptr, u_int length)
|
||||
if (len == 0)
|
||||
break;
|
||||
|
||||
if (!TTEST2(*tptr, len))
|
||||
if (!ND_TTEST2(*tptr, len))
|
||||
goto trunc;
|
||||
|
||||
vtp_vlan = (struct vtp_vlan_*)tptr;
|
||||
printf("\n\tVLAN info status %s, type %s, VLAN-id %u, MTU %u, SAID 0x%08x, Name %s",
|
||||
ND_PRINT((ndo, "\n\tVLAN info status %s, type %s, VLAN-id %u, MTU %u, SAID 0x%08x, Name %s",
|
||||
tok2str(vtp_vlan_status,"Unknown",vtp_vlan->status),
|
||||
tok2str(vtp_vlan_type_values,"Unknown",vtp_vlan->type),
|
||||
EXTRACT_16BITS(&vtp_vlan->vlanid),
|
||||
EXTRACT_16BITS(&vtp_vlan->mtu),
|
||||
EXTRACT_32BITS(&vtp_vlan->index),
|
||||
(tptr + VTP_VLAN_INFO_OFFSET));
|
||||
(tptr + VTP_VLAN_INFO_OFFSET)));
|
||||
|
||||
/*
|
||||
* Vlan names are aligned to 32-bit boundaries.
|
||||
@ -271,9 +269,9 @@ vtp_print (const u_char *pptr, u_int length)
|
||||
type = *tptr;
|
||||
tlv_len = *(tptr+1);
|
||||
|
||||
printf("\n\t\t%s (0x%04x) TLV",
|
||||
ND_PRINT((ndo, "\n\t\t%s (0x%04x) TLV",
|
||||
tok2str(vtp_vlan_tlv_values, "Unknown", type),
|
||||
type);
|
||||
type));
|
||||
|
||||
/*
|
||||
* infinite loop check
|
||||
@ -282,38 +280,38 @@ vtp_print (const u_char *pptr, u_int length)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TTEST2(*tptr, tlv_len*2 +2))
|
||||
if (!ND_TTEST2(*tptr, tlv_len*2 +2))
|
||||
goto trunc;
|
||||
|
||||
tlv_value = EXTRACT_16BITS(tptr+2);
|
||||
|
||||
switch (type) {
|
||||
case VTP_VLAN_STE_HOP_COUNT:
|
||||
printf(", %u", tlv_value);
|
||||
ND_PRINT((ndo, ", %u", tlv_value));
|
||||
break;
|
||||
|
||||
case VTP_VLAN_PRUNING:
|
||||
printf(", %s (%u)",
|
||||
ND_PRINT((ndo, ", %s (%u)",
|
||||
tlv_value == 1 ? "Enabled" : "Disabled",
|
||||
tlv_value);
|
||||
tlv_value));
|
||||
break;
|
||||
|
||||
case VTP_VLAN_STP_TYPE:
|
||||
printf(", %s (%u)",
|
||||
ND_PRINT((ndo, ", %s (%u)",
|
||||
tok2str(vtp_stp_type_values, "Unknown", tlv_value),
|
||||
tlv_value);
|
||||
tlv_value));
|
||||
break;
|
||||
|
||||
case VTP_VLAN_BRIDGE_TYPE:
|
||||
printf(", %s (%u)",
|
||||
ND_PRINT((ndo, ", %s (%u)",
|
||||
tlv_value == 1 ? "SRB" : "SRT",
|
||||
tlv_value);
|
||||
tlv_value));
|
||||
break;
|
||||
|
||||
case VTP_VLAN_BACKUP_CRF_MODE:
|
||||
printf(", %s (%u)",
|
||||
ND_PRINT((ndo, ", %s (%u)",
|
||||
tlv_value == 1 ? "Backup" : "Not backup",
|
||||
tlv_value);
|
||||
tlv_value));
|
||||
break;
|
||||
|
||||
/*
|
||||
@ -327,7 +325,7 @@ vtp_print (const u_char *pptr, u_int length)
|
||||
case VTP_VLAN_TRANS_BRIDGED_VLAN:
|
||||
case VTP_VLAN_ARP_HOP_COUNT:
|
||||
default:
|
||||
print_unknown_data(gndo,tptr, "\n\t\t ", 2 + tlv_len*2);
|
||||
print_unknown_data(ndo, tptr, "\n\t\t ", 2 + tlv_len*2);
|
||||
break;
|
||||
}
|
||||
len -= 2 + tlv_len*2;
|
||||
@ -352,7 +350,7 @@ vtp_print (const u_char *pptr, u_int length)
|
||||
*
|
||||
*/
|
||||
|
||||
printf("\n\tStart value: %u", EXTRACT_32BITS(tptr));
|
||||
ND_PRINT((ndo, "\n\tStart value: %u", EXTRACT_32BITS(tptr)));
|
||||
break;
|
||||
|
||||
case VTP_JOIN_MESSAGE:
|
||||
@ -367,7 +365,7 @@ vtp_print (const u_char *pptr, u_int length)
|
||||
return;
|
||||
|
||||
trunc:
|
||||
printf("[|vtp]");
|
||||
ND_PRINT((ndo, "[|vtp]"));
|
||||
}
|
||||
|
||||
/*
|
||||
|
143
print-wb.c
143
print-wb.c
@ -19,18 +19,19 @@
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#define NETDISSECT_REWORKED
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <tcpdump-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "interface.h"
|
||||
#include "addrtoname.h"
|
||||
#include "extract.h"
|
||||
|
||||
static const char tstr[] = "[|wb]";
|
||||
|
||||
/* XXX need to add byte-swapping macros! */
|
||||
/* XXX - you mean like the ones in "extract.h"? */
|
||||
|
||||
@ -175,7 +176,8 @@ struct pkt_prep {
|
||||
};
|
||||
|
||||
static int
|
||||
wb_id(const struct pkt_id *id, u_int len)
|
||||
wb_id(netdissect_options *ndo,
|
||||
const struct pkt_id *id, u_int len)
|
||||
{
|
||||
int i;
|
||||
const char *cp;
|
||||
@ -183,80 +185,83 @@ wb_id(const struct pkt_id *id, u_int len)
|
||||
char c;
|
||||
int nid;
|
||||
|
||||
printf(" wb-id:");
|
||||
if (len < sizeof(*id) || (u_char *)(id + 1) > snapend)
|
||||
ND_PRINT((ndo, " wb-id:"));
|
||||
if (len < sizeof(*id) || (u_char *)(id + 1) > ndo->ndo_snapend)
|
||||
return (-1);
|
||||
len -= sizeof(*id);
|
||||
|
||||
printf(" %u/%s:%u (max %u/%s:%u) ",
|
||||
ND_PRINT((ndo, " %u/%s:%u (max %u/%s:%u) ",
|
||||
EXTRACT_32BITS(&id->pi_ps.slot),
|
||||
ipaddr_string(&id->pi_ps.page.p_sid),
|
||||
EXTRACT_32BITS(&id->pi_ps.page.p_uid),
|
||||
EXTRACT_32BITS(&id->pi_mslot),
|
||||
ipaddr_string(&id->pi_mpage.p_sid),
|
||||
EXTRACT_32BITS(&id->pi_mpage.p_uid));
|
||||
EXTRACT_32BITS(&id->pi_mpage.p_uid)));
|
||||
|
||||
nid = EXTRACT_16BITS(&id->pi_ps.nid);
|
||||
len -= sizeof(*io) * nid;
|
||||
io = (struct id_off *)(id + 1);
|
||||
cp = (char *)(io + nid);
|
||||
if ((u_char *)cp + len <= snapend) {
|
||||
putchar('"');
|
||||
if ((u_char *)cp + len <= ndo->ndo_snapend) {
|
||||
ND_PRINT((ndo, "\""));
|
||||
(void)fn_print((u_char *)cp, (u_char *)cp + len);
|
||||
putchar('"');
|
||||
ND_PRINT((ndo, "\""));
|
||||
}
|
||||
|
||||
c = '<';
|
||||
for (i = 0; i < nid && (u_char *)(io + 1) <= snapend; ++io, ++i) {
|
||||
printf("%c%s:%u",
|
||||
c, ipaddr_string(&io->id), EXTRACT_32BITS(&io->off));
|
||||
for (i = 0; i < nid && (u_char *)(io + 1) <= ndo->ndo_snapend; ++io, ++i) {
|
||||
ND_PRINT((ndo, "%c%s:%u",
|
||||
c, ipaddr_string(&io->id), EXTRACT_32BITS(&io->off)));
|
||||
c = ',';
|
||||
}
|
||||
if (i >= nid) {
|
||||
printf(">");
|
||||
ND_PRINT((ndo, ">"));
|
||||
return (0);
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static int
|
||||
wb_rreq(const struct pkt_rreq *rreq, u_int len)
|
||||
wb_rreq(netdissect_options *ndo,
|
||||
const struct pkt_rreq *rreq, u_int len)
|
||||
{
|
||||
printf(" wb-rreq:");
|
||||
if (len < sizeof(*rreq) || (u_char *)(rreq + 1) > snapend)
|
||||
ND_PRINT((ndo, " wb-rreq:"));
|
||||
if (len < sizeof(*rreq) || (u_char *)(rreq + 1) > ndo->ndo_snapend)
|
||||
return (-1);
|
||||
|
||||
printf(" please repair %s %s:%u<%u:%u>",
|
||||
ND_PRINT((ndo, " please repair %s %s:%u<%u:%u>",
|
||||
ipaddr_string(&rreq->pr_id),
|
||||
ipaddr_string(&rreq->pr_page.p_sid),
|
||||
EXTRACT_32BITS(&rreq->pr_page.p_uid),
|
||||
EXTRACT_32BITS(&rreq->pr_sseq),
|
||||
EXTRACT_32BITS(&rreq->pr_eseq));
|
||||
EXTRACT_32BITS(&rreq->pr_eseq)));
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
wb_preq(const struct pkt_preq *preq, u_int len)
|
||||
wb_preq(netdissect_options *ndo,
|
||||
const struct pkt_preq *preq, u_int len)
|
||||
{
|
||||
printf(" wb-preq:");
|
||||
if (len < sizeof(*preq) || (u_char *)(preq + 1) > snapend)
|
||||
ND_PRINT((ndo, " wb-preq:"));
|
||||
if (len < sizeof(*preq) || (u_char *)(preq + 1) > ndo->ndo_snapend)
|
||||
return (-1);
|
||||
|
||||
printf(" need %u/%s:%u",
|
||||
ND_PRINT((ndo, " need %u/%s:%u",
|
||||
EXTRACT_32BITS(&preq->pp_low),
|
||||
ipaddr_string(&preq->pp_page.p_sid),
|
||||
EXTRACT_32BITS(&preq->pp_page.p_uid));
|
||||
EXTRACT_32BITS(&preq->pp_page.p_uid)));
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
wb_prep(const struct pkt_prep *prep, u_int len)
|
||||
wb_prep(netdissect_options *ndo,
|
||||
const struct pkt_prep *prep, u_int len)
|
||||
{
|
||||
int n;
|
||||
const struct pgstate *ps;
|
||||
const u_char *ep = snapend;
|
||||
const u_char *ep = ndo->ndo_snapend;
|
||||
|
||||
printf(" wb-prep:");
|
||||
ND_PRINT((ndo, " wb-prep:"));
|
||||
if (len < sizeof(*prep)) {
|
||||
return (-1);
|
||||
}
|
||||
@ -266,17 +271,17 @@ wb_prep(const struct pkt_prep *prep, u_int len)
|
||||
const struct id_off *io, *ie;
|
||||
char c = '<';
|
||||
|
||||
printf(" %u/%s:%u",
|
||||
ND_PRINT((ndo, " %u/%s:%u",
|
||||
EXTRACT_32BITS(&ps->slot),
|
||||
ipaddr_string(&ps->page.p_sid),
|
||||
EXTRACT_32BITS(&ps->page.p_uid));
|
||||
EXTRACT_32BITS(&ps->page.p_uid)));
|
||||
io = (struct id_off *)(ps + 1);
|
||||
for (ie = io + ps->nid; io < ie && (u_char *)(io + 1) <= ep; ++io) {
|
||||
printf("%c%s:%u", c, ipaddr_string(&io->id),
|
||||
EXTRACT_32BITS(&io->off));
|
||||
ND_PRINT((ndo, "%c%s:%u", c, ipaddr_string(&io->id),
|
||||
EXTRACT_32BITS(&io->off)));
|
||||
c = ',';
|
||||
}
|
||||
printf(">");
|
||||
ND_PRINT((ndo, ">"));
|
||||
ps = (struct pgstate *)io;
|
||||
}
|
||||
return ((u_char *)ps <= ep? 0 : -1);
|
||||
@ -303,21 +308,22 @@ static const char *dopstr[] = {
|
||||
};
|
||||
|
||||
static int
|
||||
wb_dops(const struct dophdr *dh, u_int32_t ss, u_int32_t es)
|
||||
wb_dops(netdissect_options *ndo,
|
||||
const struct dophdr *dh, u_int32_t ss, u_int32_t es)
|
||||
{
|
||||
printf(" <");
|
||||
ND_PRINT((ndo, " <"));
|
||||
for ( ; ss <= es; ++ss) {
|
||||
register int t = dh->dh_type;
|
||||
|
||||
if (t > DT_MAXTYPE)
|
||||
printf(" dop-%d!", t);
|
||||
ND_PRINT((ndo, " dop-%d!", t));
|
||||
else {
|
||||
printf(" %s", dopstr[t]);
|
||||
ND_PRINT((ndo, " %s", dopstr[t]));
|
||||
if (t == DT_SKIP || t == DT_HOLE) {
|
||||
u_int32_t ts = EXTRACT_32BITS(&dh->dh_ts);
|
||||
printf("%d", ts - ss + 1);
|
||||
ND_PRINT((ndo, "%d", ts - ss + 1));
|
||||
if (ss > ts || ts > es) {
|
||||
printf("[|]");
|
||||
ND_PRINT((ndo, "[|]"));
|
||||
if (ts < ss)
|
||||
return (0);
|
||||
}
|
||||
@ -325,55 +331,57 @@ wb_dops(const struct dophdr *dh, u_int32_t ss, u_int32_t es)
|
||||
}
|
||||
}
|
||||
dh = DOP_NEXT(dh);
|
||||
if ((u_char *)dh > snapend) {
|
||||
printf("[|wb]");
|
||||
if ((u_char *)dh > ndo->ndo_snapend) {
|
||||
ND_PRINT((ndo, tstr));
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf(" >");
|
||||
ND_PRINT((ndo, " >"));
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
wb_rrep(const struct pkt_rrep *rrep, u_int len)
|
||||
wb_rrep(netdissect_options *ndo,
|
||||
const struct pkt_rrep *rrep, u_int len)
|
||||
{
|
||||
const struct pkt_dop *dop = &rrep->pr_dop;
|
||||
|
||||
printf(" wb-rrep:");
|
||||
if (len < sizeof(*rrep) || (u_char *)(rrep + 1) > snapend)
|
||||
ND_PRINT((ndo, " wb-rrep:"));
|
||||
if (len < sizeof(*rrep) || (u_char *)(rrep + 1) > ndo->ndo_snapend)
|
||||
return (-1);
|
||||
len -= sizeof(*rrep);
|
||||
|
||||
printf(" for %s %s:%u<%u:%u>",
|
||||
ND_PRINT((ndo, " for %s %s:%u<%u:%u>",
|
||||
ipaddr_string(&rrep->pr_id),
|
||||
ipaddr_string(&dop->pd_page.p_sid),
|
||||
EXTRACT_32BITS(&dop->pd_page.p_uid),
|
||||
EXTRACT_32BITS(&dop->pd_sseq),
|
||||
EXTRACT_32BITS(&dop->pd_eseq));
|
||||
EXTRACT_32BITS(&dop->pd_eseq)));
|
||||
|
||||
if (vflag)
|
||||
return (wb_dops((const struct dophdr *)(dop + 1),
|
||||
if (ndo->ndo_vflag)
|
||||
return (wb_dops(ndo, (const struct dophdr *)(dop + 1),
|
||||
EXTRACT_32BITS(&dop->pd_sseq),
|
||||
EXTRACT_32BITS(&dop->pd_eseq)));
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
wb_drawop(const struct pkt_dop *dop, u_int len)
|
||||
wb_drawop(netdissect_options *ndo,
|
||||
const struct pkt_dop *dop, u_int len)
|
||||
{
|
||||
printf(" wb-dop:");
|
||||
if (len < sizeof(*dop) || (u_char *)(dop + 1) > snapend)
|
||||
ND_PRINT((ndo, " wb-dop:"));
|
||||
if (len < sizeof(*dop) || (u_char *)(dop + 1) > ndo->ndo_snapend)
|
||||
return (-1);
|
||||
len -= sizeof(*dop);
|
||||
|
||||
printf(" %s:%u<%u:%u>",
|
||||
ND_PRINT((ndo, " %s:%u<%u:%u>",
|
||||
ipaddr_string(&dop->pd_page.p_sid),
|
||||
EXTRACT_32BITS(&dop->pd_page.p_uid),
|
||||
EXTRACT_32BITS(&dop->pd_sseq),
|
||||
EXTRACT_32BITS(&dop->pd_eseq));
|
||||
EXTRACT_32BITS(&dop->pd_eseq)));
|
||||
|
||||
if (vflag)
|
||||
return (wb_dops((const struct dophdr *)(dop + 1),
|
||||
if (ndo->ndo_vflag)
|
||||
return (wb_dops(ndo, (const struct dophdr *)(dop + 1),
|
||||
EXTRACT_32BITS(&dop->pd_sseq),
|
||||
EXTRACT_32BITS(&dop->pd_eseq)));
|
||||
return (0);
|
||||
@ -383,57 +391,58 @@ wb_drawop(const struct pkt_dop *dop, u_int len)
|
||||
* Print whiteboard multicast packets.
|
||||
*/
|
||||
void
|
||||
wb_print(register const void *hdr, register u_int len)
|
||||
wb_print(netdissect_options *ndo,
|
||||
register const void *hdr, register u_int len)
|
||||
{
|
||||
register const struct pkt_hdr *ph;
|
||||
|
||||
ph = (const struct pkt_hdr *)hdr;
|
||||
if (len < sizeof(*ph) || (u_char *)(ph + 1) > snapend) {
|
||||
printf("[|wb]");
|
||||
if (len < sizeof(*ph) || (u_char *)(ph + 1) > ndo->ndo_snapend) {
|
||||
ND_PRINT((ndo, tstr));
|
||||
return;
|
||||
}
|
||||
len -= sizeof(*ph);
|
||||
|
||||
if (ph->ph_flags)
|
||||
printf("*");
|
||||
ND_PRINT((ndo, "*"));
|
||||
switch (ph->ph_type) {
|
||||
|
||||
case PT_KILL:
|
||||
printf(" wb-kill");
|
||||
ND_PRINT((ndo, " wb-kill"));
|
||||
return;
|
||||
|
||||
case PT_ID:
|
||||
if (wb_id((struct pkt_id *)(ph + 1), len) >= 0)
|
||||
if (wb_id(ndo, (struct pkt_id *)(ph + 1), len) >= 0)
|
||||
return;
|
||||
break;
|
||||
|
||||
case PT_RREQ:
|
||||
if (wb_rreq((struct pkt_rreq *)(ph + 1), len) >= 0)
|
||||
if (wb_rreq(ndo, (struct pkt_rreq *)(ph + 1), len) >= 0)
|
||||
return;
|
||||
break;
|
||||
|
||||
case PT_RREP:
|
||||
if (wb_rrep((struct pkt_rrep *)(ph + 1), len) >= 0)
|
||||
if (wb_rrep(ndo, (struct pkt_rrep *)(ph + 1), len) >= 0)
|
||||
return;
|
||||
break;
|
||||
|
||||
case PT_DRAWOP:
|
||||
if (wb_drawop((struct pkt_dop *)(ph + 1), len) >= 0)
|
||||
if (wb_drawop(ndo, (struct pkt_dop *)(ph + 1), len) >= 0)
|
||||
return;
|
||||
break;
|
||||
|
||||
case PT_PREQ:
|
||||
if (wb_preq((struct pkt_preq *)(ph + 1), len) >= 0)
|
||||
if (wb_preq(ndo, (struct pkt_preq *)(ph + 1), len) >= 0)
|
||||
return;
|
||||
break;
|
||||
|
||||
case PT_PREP:
|
||||
if (wb_prep((struct pkt_prep *)(ph + 1), len) >= 0)
|
||||
if (wb_prep(ndo, (struct pkt_prep *)(ph + 1), len) >= 0)
|
||||
return;
|
||||
break;
|
||||
|
||||
default:
|
||||
printf(" wb-%d!", ph->ph_type);
|
||||
ND_PRINT((ndo, " wb-%d!", ph->ph_type));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,6 @@ static const struct printer printers[] = {
|
||||
#ifdef DLT_PPP_BSDOS
|
||||
{ ppp_bsdos_if_print, DLT_PPP_BSDOS },
|
||||
#endif
|
||||
{ atm_if_print, DLT_ATM_RFC1483 },
|
||||
#ifdef DLT_PPP_SERIAL
|
||||
{ ppp_hdlc_if_print, DLT_PPP_SERIAL },
|
||||
#endif
|
||||
@ -188,9 +187,6 @@ static const struct printer printers[] = {
|
||||
#ifdef DLT_LTALK
|
||||
{ ltalk_if_print, DLT_LTALK },
|
||||
#endif
|
||||
#ifdef DLT_SUNATM
|
||||
{ sunatm_if_print, DLT_SUNATM },
|
||||
#endif
|
||||
#ifdef DLT_PRISM_HEADER
|
||||
{ prism_if_print, DLT_PRISM_HEADER },
|
||||
#endif
|
||||
@ -343,6 +339,10 @@ static const struct ndo_printer ndo_printers[] = {
|
||||
#endif
|
||||
#ifdef DLT_MFR
|
||||
{ mfr_if_print, DLT_MFR },
|
||||
#endif
|
||||
{ atm_if_print, DLT_ATM_RFC1483 },
|
||||
#ifdef DLT_SUNATM
|
||||
{ sunatm_if_print, DLT_SUNATM },
|
||||
#endif
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user