diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-10-10 12:55:06 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-10-11 09:29:33 +0200 |
commit | 104304864887f0e3765bb28333dc7b9bd991aa4f (patch) | |
tree | c1472d363822507fba1cebca8fb18f611accd51b /freebsd/contrib/tcpdump/print-ipcomp.c | |
parent | Update CONTRIBUTING.md (diff) | |
download | rtems-libbsd-104304864887f0e3765bb28333dc7b9bd991aa4f.tar.bz2 |
tcpdump: Update to FreeBSD head 2017-04-04
Update tcpdump from Git mirror commit
99a648a912e81e29d9c4c159cbbe263462f2d719 to
642b174daddbd0efd9bb5f242c43f4ab4db6869f.
Diffstat (limited to 'freebsd/contrib/tcpdump/print-ipcomp.c')
-rw-r--r-- | freebsd/contrib/tcpdump/print-ipcomp.c | 84 |
1 files changed, 34 insertions, 50 deletions
diff --git a/freebsd/contrib/tcpdump/print-ipcomp.c b/freebsd/contrib/tcpdump/print-ipcomp.c index 04f16b38..4716fdae 100644 --- a/freebsd/contrib/tcpdump/print-ipcomp.c +++ b/freebsd/contrib/tcpdump/print-ipcomp.c @@ -1,5 +1,8 @@ #include <machine/rtems-bsd-user-space.h> - +#ifdef __rtems__ +#include <machine/rtems-bsd-program.h> +#include "rtems-bsd-tcpdump-namespace.h" +#endif /* __rtems__ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -21,73 +24,54 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.20 2003-11-19 00:36:08 guy Exp $"; -#endif +/* \summary: IP Payload Compression Protocol (IPComp) printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <string.h> -#include <tcpdump-stdinc.h> - -#include <stdio.h> +#include <netdissect-stdinc.h> 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 */ + 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 <zlib.h> -#endif - -#include "interface.h" -#include "addrtoname.h" +#include "netdissect.h" #include "extract.h" -int -ipcomp_print(register const u_char *bp, int *nhdr _U_) +void +ipcomp_print(netdissect_options *ndo, register const u_char *bp) { register const struct ipcomp *ipcomp; - register const u_char *ep; - u_int16_t cpi; -#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H) - int advance; -#endif + uint16_t cpi; - ipcomp = (struct ipcomp *)bp; + ipcomp = (const struct ipcomp *)bp; + ND_TCHECK(*ipcomp); cpi = EXTRACT_16BITS(&ipcomp->comp_cpi); - /* 'ep' points to the end of available data. */ - ep = snapend; - - if ((u_char *)(ipcomp + 1) >= ep - sizeof(struct ipcomp)) { - fputs("[|IPCOMP]", stdout); - goto fail; - } - printf("IPComp(cpi=0x%04x)", cpi); - -#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H) - if (1) - goto fail; + ND_PRINT((ndo, "IPComp(cpi=0x%04x)", cpi)); /* - * We may want to decompress the packet here. Packet buffer - * management is a headache (if we decompress, packet will become - * larger). + * XXX - based on the CPI, we could decompress the packet here. + * Packet buffer management is a headache (if we decompress, + * packet will become larger). + * + * We would decompress the packet and then call a routine that, + * based on ipcomp->comp_nxt, dissects the decompressed data. + * + * Until we do that, however, we just return -1, so that + * the loop that processes "protocol"/"next header" types + * stops - there's nothing more it can do with a compressed + * payload. */ - if (nhdr) - *nhdr = ipcomp->comp_nxt; - advance = sizeof(struct ipcomp); + return; - printf(": "); - return advance; - -#endif -fail: - return -1; +trunc: + ND_PRINT((ndo, "[|IPCOMP]")); + return; } +#ifdef __rtems__ +#include "rtems-bsd-tcpdump-print-ipcomp-data.h" +#endif /* __rtems__ */ |