X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/10afb02ac804db7fa41a776fd61eff922c09c4df..refs/pull/482/head:/print-ipcomp.c diff --git a/print-ipcomp.c b/print-ipcomp.c index 8cdb779d..a6d25257 100644 --- a/print-ipcomp.c +++ b/print-ipcomp.c @@ -19,54 +19,46 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.16 2002-11-09 17:19:26 itojun Exp $"; -#endif - #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include -#include - -#include +#include struct ipcomp { - u_int8_t comp_nxt; /* Next Header */ - u_int8_t comp_flags; /* Length of data, in 32bit */ - u_int16_t comp_cpi; /* Compression parameter index */ -} __attribute__((packed)); + uint8_t comp_nxt; /* Next Header */ + uint8_t comp_flags; /* Length of data, in 32bit */ + uint16_t comp_cpi; /* Compression parameter index */ +}; #if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H) #include #endif -#include "interface.h" -#include "addrtoname.h" +#include "netdissect.h" +#include "extract.h" int -ipcomp_print(register const u_char *bp, int *nhdr) +ipcomp_print(netdissect_options *ndo, register const u_char *bp, int *nhdr _U_) { register const struct ipcomp *ipcomp; register const u_char *ep; - u_int16_t cpi; + uint16_t cpi; #if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H) int advance; #endif - ipcomp = (struct ipcomp *)bp; - cpi = (u_int16_t)ntohs(ipcomp->comp_cpi); + ipcomp = (const struct ipcomp *)bp; + 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); + if ((const u_char *)(ipcomp + 1) >= ep - sizeof(struct ipcomp)) { + 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) @@ -81,12 +73,10 @@ ipcomp_print(register const u_char *bp, int *nhdr) *nhdr = ipcomp->comp_nxt; advance = sizeof(struct ipcomp); - printf(": "); + ND_PRINT((ndo, ": ")); return advance; #endif fail: - if (nhdr) - *nhdr = -1; - return 65536; + return -1; }