]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ipcomp.c
Makefile.in: don't remove configure and config.h.in in make distclean.
[tcpdump] / print-ipcomp.c
index 354eef3551e128da4e53e33742f25e50495cfcb6..c0c184ddc83982c1b00a501a7361238b85ec395b 100644 (file)
 /* \summary: IP Payload Compression Protocol (IPComp) printer */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
-#include <netdissect-stdinc.h>
-
-struct ipcomp {
-       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 "netdissect-stdinc.h"
 
 #include "netdissect.h"
 #include "extract.h"
 
-int
-ipcomp_print(netdissect_options *ndo, register const u_char *bp, int *nhdr _U_)
+struct ipcomp {
+       nd_uint8_t  comp_nxt;   /* Next Header */
+       nd_uint8_t  comp_flags; /* Length of data, in 32bit */
+       nd_uint16_t comp_cpi;   /* Compression parameter index */
+};
+
+void
+ipcomp_print(netdissect_options *ndo, const u_char *bp)
 {
-       register const struct ipcomp *ipcomp;
+       const struct ipcomp *ipcomp;
        uint16_t cpi;
-#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
-       int advance;
-#endif
 
+       ndo->ndo_protocol = "ipcomp";
        ipcomp = (const struct ipcomp *)bp;
-       ND_TCHECK(ipcomp->comp_cpi);
-       cpi = EXTRACT_16BITS(&ipcomp->comp_cpi);
+       cpi = GET_BE_U_2(ipcomp->comp_cpi);
 
-       ND_PRINT((ndo, "IPComp(cpi=0x%04x)", cpi));
-
-#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
-       if (1)
-               goto fail;
+       ND_PRINT("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);
-
-       ND_PRINT((ndo, ": "));
-       return advance;
-
-#endif
-trunc:
-       ND_PRINT((ndo, "[|IPCOMP]"));
-#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
-fail:
-#endif
-       return -1;
 }