xref: /netbsd-src/external/bsd/tcpdump/dist/print-ipcomp.c (revision 26ba0b503b498a5194a71ac319838b7f5497f3fe)
10f74e101Schristos /*
20f74e101Schristos  * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
30f74e101Schristos  *	The Regents of the University of California.  All rights reserved.
40f74e101Schristos  *
50f74e101Schristos  * Redistribution and use in source and binary forms, with or without
60f74e101Schristos  * modification, are permitted provided that: (1) source code distributions
70f74e101Schristos  * retain the above copyright notice and this paragraph in its entirety, (2)
80f74e101Schristos  * distributions including binary code include the above copyright notice and
90f74e101Schristos  * this paragraph in its entirety in the documentation or other materials
100f74e101Schristos  * provided with the distribution, and (3) all advertising materials mentioning
110f74e101Schristos  * features or use of this software display the following acknowledgement:
120f74e101Schristos  * ``This product includes software developed by the University of California,
130f74e101Schristos  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
140f74e101Schristos  * the University nor the names of its contributors may be used to endorse
150f74e101Schristos  * or promote products derived from this software without specific prior
160f74e101Schristos  * written permission.
170f74e101Schristos  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
180f74e101Schristos  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
190f74e101Schristos  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
200f74e101Schristos  */
210f74e101Schristos 
2211b3aaa1Schristos #include <sys/cdefs.h>
230f74e101Schristos #ifndef lint
24*26ba0b50Schristos __RCSID("$NetBSD: print-ipcomp.c,v 1.8 2024/09/02 16:15:31 christos Exp $");
250f74e101Schristos #endif
260f74e101Schristos 
27dc860a36Sspz /* \summary: IP Payload Compression Protocol (IPComp) printer */
28dc860a36Sspz 
29c74ad251Schristos #include <config.h>
300f74e101Schristos 
31c74ad251Schristos #include "netdissect-stdinc.h"
320f74e101Schristos 
33fdccd7e4Schristos #include "netdissect.h"
340f74e101Schristos #include "extract.h"
350f74e101Schristos 
36c74ad251Schristos struct ipcomp {
37c74ad251Schristos 	nd_uint8_t  comp_nxt;	/* Next Header */
38c74ad251Schristos 	nd_uint8_t  comp_flags;	/* Length of data, in 32bit */
39c74ad251Schristos 	nd_uint16_t comp_cpi;	/* Compression parameter index */
40c74ad251Schristos };
41c74ad251Schristos 
42dc860a36Sspz void
43c74ad251Schristos ipcomp_print(netdissect_options *ndo, const u_char *bp)
440f74e101Schristos {
45c74ad251Schristos 	const struct ipcomp *ipcomp;
46b3a00663Schristos 	uint16_t cpi;
470f74e101Schristos 
48c74ad251Schristos 	ndo->ndo_protocol = "ipcomp";
49fdccd7e4Schristos 	ipcomp = (const struct ipcomp *)bp;
50c74ad251Schristos 	cpi = GET_BE_U_2(ipcomp->comp_cpi);
510f74e101Schristos 
52c74ad251Schristos 	ND_PRINT("IPComp(cpi=0x%04x)", cpi);
530f74e101Schristos 
540f74e101Schristos 	/*
55dc860a36Sspz 	 * XXX - based on the CPI, we could decompress the packet here.
56dc860a36Sspz 	 * Packet buffer management is a headache (if we decompress,
57dc860a36Sspz 	 * packet will become larger).
58dc860a36Sspz 	 *
59dc860a36Sspz 	 * We would decompress the packet and then call a routine that,
60dc860a36Sspz 	 * based on ipcomp->comp_nxt, dissects the decompressed data.
61dc860a36Sspz 	 *
62dc860a36Sspz 	 * Until we do that, however, we just return -1, so that
63dc860a36Sspz 	 * the loop that processes "protocol"/"next header" types
64dc860a36Sspz 	 * stops - there's nothing more it can do with a compressed
65dc860a36Sspz 	 * payload.
660f74e101Schristos 	 */
670f74e101Schristos }
68