mirror of
https://github.com/the-tcpdump-group/tcpdump.git
synced 2024-11-23 10:04:05 +08:00
NDOize CIP, IPComp and IPFC decoders
Also remove some unneeded includes while at it.
This commit is contained in:
parent
88e479b75e
commit
207f31f2bd
@ -219,7 +219,6 @@ 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 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);
|
||||
extern void isoclns_print(const u_char *, u_int, u_int);
|
||||
extern void krb_print(const u_char *);
|
||||
@ -265,7 +264,6 @@ extern void rip_print(const u_char *, u_int);
|
||||
extern u_int sl_if_print(const struct pcap_pkthdr *, const u_char *);
|
||||
extern void lane_print(const u_char *, u_int, u_int);
|
||||
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 chdlc_print(register const u_char *, u_int);
|
||||
@ -295,7 +293,6 @@ extern void udld_print(const u_char *, u_int);
|
||||
extern void udp_print(const u_char *, u_int, const u_char *, int);
|
||||
extern void vtp_print(const u_char *, u_int);
|
||||
extern void wb_print(const void *, u_int);
|
||||
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);
|
||||
extern void ipx_netbios_print(const u_char *, u_int);
|
||||
|
@ -371,6 +371,9 @@ extern void hex_print(netdissect_options *,const char *ident, const u_char *cp,u
|
||||
extern int ah_print(netdissect_options *, register const u_char *);
|
||||
extern void beep_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void dtp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern u_int cip_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
|
||||
extern int ipcomp_print(netdissect_options *, register const u_char *, int *);
|
||||
extern u_int ipfc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
|
||||
|
||||
/* stuff that has not yet been rototiled */
|
||||
extern const u_char * ns_nprint (register const u_char *, register const u_char *);
|
||||
@ -474,7 +477,6 @@ extern void sctp_print(netdissect_options *ndo,
|
||||
extern void sl_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
|
||||
|
||||
extern void lane_if_print(u_char *,const struct pcap_pkthdr *,const u_char *);
|
||||
extern void cip_if_print(u_char *,const struct pcap_pkthdr *,const u_char *);
|
||||
extern void sl_bsdos_if_print(u_char *,
|
||||
const struct pcap_pkthdr *, const u_char *);
|
||||
extern void sll_if_print(u_char *,
|
||||
@ -491,8 +493,6 @@ extern void udp_print(netdissect_options *,const u_char *, u_int,
|
||||
const u_char *, int);
|
||||
extern void wb_print(netdissect_options *,const void *, u_int);
|
||||
extern void esp_print_decodesecret(netdissect_options *ndo);
|
||||
extern int ipcomp_print(netdissect_options *,register const u_char *,
|
||||
register const u_char *, int *);
|
||||
extern void rx_print(netdissect_options *,register const u_char *,
|
||||
int, int, int, u_char *);
|
||||
extern void netbeui_print(netdissect_options *,u_short,
|
||||
|
30
print-cip.c
30
print-cip.c
@ -28,12 +28,8 @@
|
||||
|
||||
#include <tcpdump-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "interface.h"
|
||||
#include "addrtoname.h"
|
||||
#include "ethertype.h"
|
||||
#include "ether.h"
|
||||
|
||||
#define RFC1483LLC_LEN 8
|
||||
|
||||
@ -46,12 +42,12 @@ static const unsigned char rfcllc[] = {
|
||||
0x00 };
|
||||
|
||||
static inline void
|
||||
cip_print(int length)
|
||||
cip_print(netdissect_options *ndo, int length)
|
||||
{
|
||||
/*
|
||||
* There is no MAC-layer header, so just print the length.
|
||||
*/
|
||||
printf("%d: ", length);
|
||||
ND_PRINT((ndo, "%d: ", length));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -61,19 +57,19 @@ cip_print(int length)
|
||||
* is the number of bytes actually captured.
|
||||
*/
|
||||
u_int
|
||||
cip_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
cip_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
|
||||
{
|
||||
u_int caplen = h->caplen;
|
||||
u_int length = h->len;
|
||||
u_short extracted_ethertype;
|
||||
|
||||
if (memcmp(rfcllc, p, sizeof(rfcllc))==0 && caplen < RFC1483LLC_LEN) {
|
||||
printf("[|cip]");
|
||||
ND_PRINT((ndo, "[|cip]"));
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (eflag)
|
||||
cip_print(length);
|
||||
if (ndo->ndo_eflag)
|
||||
cip_print(ndo, length);
|
||||
|
||||
if (memcmp(rfcllc, p, sizeof(rfcllc)) == 0) {
|
||||
/*
|
||||
@ -82,20 +78,20 @@ cip_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
if (llc_print(p, length, caplen, NULL, NULL,
|
||||
&extracted_ethertype) == 0) {
|
||||
/* ether_type not known, print raw packet */
|
||||
if (!eflag)
|
||||
cip_print(length);
|
||||
if (!ndo->ndo_eflag)
|
||||
cip_print(ndo, length);
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* LLC header is absent; treat it as just IP.
|
||||
*/
|
||||
ip_print(gndo, p, length);
|
||||
ip_print(ndo, p, length);
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
@ -351,7 +351,7 @@ again:
|
||||
case IPPROTO_IPCOMP:
|
||||
{
|
||||
int enh;
|
||||
ipds->advance = ipcomp_print(ipds->cp, &enh);
|
||||
ipds->advance = ipcomp_print(ndo, ipds->cp, &enh);
|
||||
if (ipds->advance <= 0)
|
||||
break;
|
||||
ipds->cp += ipds->advance;
|
||||
|
@ -219,7 +219,7 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
|
||||
case IPPROTO_IPCOMP:
|
||||
{
|
||||
int enh;
|
||||
advance = ipcomp_print(cp, &enh);
|
||||
advance = ipcomp_print(ndo, cp, &enh);
|
||||
nh = enh & 0xff;
|
||||
break;
|
||||
}
|
||||
|
@ -23,11 +23,8 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <tcpdump-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
struct ipcomp {
|
||||
u_int8_t comp_nxt; /* Next Header */
|
||||
u_int8_t comp_flags; /* Length of data, in 32bit */
|
||||
@ -38,11 +35,11 @@ struct ipcomp {
|
||||
#include <zlib.h>
|
||||
#endif
|
||||
|
||||
#include "interface.h"
|
||||
#include "netdissect.h"
|
||||
#include "extract.h"
|
||||
|
||||
int
|
||||
ipcomp_print(register const u_char *bp, int *nhdr _U_)
|
||||
ipcomp_print(netdissect_options *ndo, register const u_char *bp, int *nhdr _U_)
|
||||
{
|
||||
register const struct ipcomp *ipcomp;
|
||||
register const u_char *ep;
|
||||
@ -55,13 +52,13 @@ ipcomp_print(register const u_char *bp, int *nhdr _U_)
|
||||
cpi = EXTRACT_16BITS(&ipcomp->comp_cpi);
|
||||
|
||||
/* 'ep' points to the end of available data. */
|
||||
ep = snapend;
|
||||
ep = ndo->ndo_snapend;
|
||||
|
||||
if ((u_char *)(ipcomp + 1) >= ep - sizeof(struct ipcomp)) {
|
||||
fputs("[|IPCOMP]", stdout);
|
||||
ND_PRINT((ndo, "[|IPCOMP]"));
|
||||
goto fail;
|
||||
}
|
||||
printf("IPComp(cpi=0x%04x)", cpi);
|
||||
ND_PRINT((ndo, "IPComp(cpi=0x%04x)", cpi));
|
||||
|
||||
#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
|
||||
if (1)
|
||||
@ -76,7 +73,7 @@ ipcomp_print(register const u_char *bp, int *nhdr _U_)
|
||||
*nhdr = ipcomp->comp_nxt;
|
||||
advance = sizeof(struct ipcomp);
|
||||
|
||||
printf(": ");
|
||||
ND_PRINT((ndo, ": "));
|
||||
return advance;
|
||||
|
||||
#endif
|
||||
|
31
print-ipfc.c
31
print-ipfc.c
@ -25,12 +25,10 @@
|
||||
|
||||
#include <tcpdump-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "interface.h"
|
||||
#include "addrtoname.h"
|
||||
#include "ethertype.h"
|
||||
|
||||
#include "ether.h"
|
||||
|
||||
@ -62,7 +60,8 @@ extract_ipfc_addrs(const struct ipfc_header *ipfcp, char *ipfcsrc,
|
||||
* Print the Network_Header
|
||||
*/
|
||||
static inline void
|
||||
ipfc_hdr_print(register const struct ipfc_header *ipfcp _U_,
|
||||
ipfc_hdr_print(netdissect_options *ndo,
|
||||
register const struct ipfc_header *ipfcp _U_,
|
||||
register u_int length, register const u_char *ipfcsrc,
|
||||
register const u_char *ipfcdst)
|
||||
{
|
||||
@ -74,18 +73,18 @@ ipfc_hdr_print(register const struct ipfc_header *ipfcp _U_,
|
||||
/*
|
||||
* XXX - show the upper 16 bits? Do so only if "vflag" is set?
|
||||
*/
|
||||
(void) printf("%s %s %d: ", srcname, dstname, length);
|
||||
ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
|
||||
}
|
||||
|
||||
static void
|
||||
ipfc_print(const u_char *p, u_int length, u_int caplen)
|
||||
ipfc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
|
||||
{
|
||||
const struct ipfc_header *ipfcp = (const struct ipfc_header *)p;
|
||||
struct ether_header ehdr;
|
||||
u_short extracted_ethertype;
|
||||
|
||||
if (caplen < IPFC_HDRLEN) {
|
||||
printf("[|ipfc]");
|
||||
ND_PRINT((ndo, "[|ipfc]"));
|
||||
return;
|
||||
}
|
||||
/*
|
||||
@ -93,8 +92,8 @@ ipfc_print(const u_char *p, u_int length, u_int caplen)
|
||||
*/
|
||||
extract_ipfc_addrs(ipfcp, (char *)ESRC(&ehdr), (char *)EDST(&ehdr));
|
||||
|
||||
if (eflag)
|
||||
ipfc_hdr_print(ipfcp, length, ESRC(&ehdr), EDST(&ehdr));
|
||||
if (ndo->ndo_eflag)
|
||||
ipfc_hdr_print(ndo, ipfcp, length, ESRC(&ehdr), EDST(&ehdr));
|
||||
|
||||
/* Skip over Network_Header */
|
||||
length -= IPFC_HDRLEN;
|
||||
@ -108,15 +107,15 @@ ipfc_print(const u_char *p, u_int length, u_int caplen)
|
||||
* Some kinds of LLC packet we cannot
|
||||
* handle intelligently
|
||||
*/
|
||||
if (!eflag)
|
||||
ipfc_hdr_print(ipfcp, length + IPFC_HDRLEN,
|
||||
if (!ndo->ndo_eflag)
|
||||
ipfc_hdr_print(ndo, ipfcp, length + IPFC_HDRLEN,
|
||||
ESRC(&ehdr), EDST(&ehdr));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,9 +126,9 @@ ipfc_print(const u_char *p, u_int length, u_int caplen)
|
||||
* is the number of bytes actually captured.
|
||||
*/
|
||||
u_int
|
||||
ipfc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
|
||||
ipfc_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
|
||||
{
|
||||
ipfc_print(p, h->len, h->caplen);
|
||||
ipfc_print(ndo, p, h->len, h->caplen);
|
||||
|
||||
return (IPFC_HDRLEN);
|
||||
}
|
||||
|
18
tcpdump.c
18
tcpdump.c
@ -174,12 +174,6 @@ static const struct printer printers[] = {
|
||||
{ token_if_print, DLT_IEEE802 },
|
||||
#ifdef DLT_LANE8023
|
||||
{ lane_if_print, DLT_LANE8023 },
|
||||
#endif
|
||||
#ifdef DLT_CIP
|
||||
{ cip_if_print, DLT_CIP },
|
||||
#endif
|
||||
#ifdef DLT_ATM_CLIP
|
||||
{ cip_if_print, DLT_ATM_CLIP },
|
||||
#endif
|
||||
{ sl_if_print, DLT_SLIP },
|
||||
#ifdef DLT_SLIP_BSDOS
|
||||
@ -232,9 +226,6 @@ static const struct printer printers[] = {
|
||||
#ifdef DLT_SUNATM
|
||||
{ sunatm_if_print, DLT_SUNATM },
|
||||
#endif
|
||||
#ifdef DLT_IP_OVER_FC
|
||||
{ ipfc_if_print, DLT_IP_OVER_FC },
|
||||
#endif
|
||||
#ifdef DLT_PRISM_HEADER
|
||||
{ prism_if_print, DLT_PRISM_HEADER },
|
||||
#endif
|
||||
@ -343,6 +334,15 @@ static const struct ndo_printer ndo_printers[] = {
|
||||
#endif
|
||||
#if defined(DLT_NFLOG) && defined(HAVE_PCAP_NFLOG_H)
|
||||
{ nflog_if_print, DLT_NFLOG},
|
||||
#endif
|
||||
#ifdef DLT_CIP
|
||||
{ cip_if_print, DLT_CIP },
|
||||
#endif
|
||||
#ifdef DLT_ATM_CLIP
|
||||
{ cip_if_print, DLT_ATM_CLIP },
|
||||
#endif
|
||||
#ifdef DLT_IP_OVER_FC
|
||||
{ ipfc_if_print, DLT_IP_OVER_FC },
|
||||
#endif
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user