]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ipcomp.c
CI: Add warning exemptions for Sun C (suncc-5.14) on Solaris 10
[tcpdump] / print-ipcomp.c
index 86625429b26976663a4a2f5af43fd060102e78db..a88f679750621343fa716dfcaae59f55df1ca1f8 100644 (file)
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.4 2000-01-19 04:51:11 itojun Exp $";
-#endif
+/* \summary: IP Payload Compression Protocol (IPComp) printer */
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+#include <config.h>
 
-#include <string.h>
-#include <sys/param.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+#include "netdissect-stdinc.h"
 
-#include <net/route.h>
-#include <net/if.h>
-
-#include <netinet/in.h>
-#include <netinet/if_ether.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_icmp.h>
-#include <netinet/ip_var.h>
-#include <netinet/udp.h>
-#include <netinet/udp_var.h>
-#include <netinet/tcp.h>
-
-#include <stdio.h>
-
-#ifdef INET6
-#include <netinet/ip6.h>
-#endif
+#include "netdissect.h"
+#include "extract.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 */
+       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 */
 };
 
-#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
-#include <zlib.h>
-#endif
-
-#include "interface.h"
-#include "addrtoname.h"
-
-int
-ipcomp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
+void
+ipcomp_print(netdissect_options *ndo, 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
+       const struct ipcomp *ipcomp;
+       uint16_t cpi;
 
-       ipcomp = (struct ipcomp *)bp;
-       cpi = (u_int16_t)ntohs(ipcomp->comp_cpi);
+       ndo->ndo_protocol = "ipcomp";
+       ipcomp = (const struct ipcomp *)bp;
+       cpi = GET_BE_U_2(ipcomp->comp_cpi);
 
-       /* 'ep' points to the end of avaible data. */
-       ep = snapend;
-
-       if ((u_char *)(ipcomp + 1) >= ep - sizeof(struct ipcomp)) {
-               fputs("[|IPCOMP]", stdout);
-               goto fail;
-       }
-       printf("IPComp(cpi=%u)", 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);
-
-       printf(": ");
-       return advance;
-
-#endif
-fail:
-       if (nhdr)
-               *nhdr = -1;
-       return 65536;
 }