xref: /freebsd/contrib/tcpdump/print-ipcomp.c (revision 0a7e5f1f02aad2ff5fff1c60f44c6975fd07e1d9)
1b0453382SBill Fenner /*
2b0453382SBill Fenner  * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
3b0453382SBill Fenner  *	The Regents of the University of California.  All rights reserved.
4b0453382SBill Fenner  *
5b0453382SBill Fenner  * Redistribution and use in source and binary forms, with or without
6b0453382SBill Fenner  * modification, are permitted provided that: (1) source code distributions
7b0453382SBill Fenner  * retain the above copyright notice and this paragraph in its entirety, (2)
8b0453382SBill Fenner  * distributions including binary code include the above copyright notice and
9b0453382SBill Fenner  * this paragraph in its entirety in the documentation or other materials
10b0453382SBill Fenner  * provided with the distribution, and (3) all advertising materials mentioning
11b0453382SBill Fenner  * features or use of this software display the following acknowledgement:
12b0453382SBill Fenner  * ``This product includes software developed by the University of California,
13b0453382SBill Fenner  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14b0453382SBill Fenner  * the University nor the names of its contributors may be used to endorse
15b0453382SBill Fenner  * or promote products derived from this software without specific prior
16b0453382SBill Fenner  * written permission.
17b0453382SBill Fenner  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18b0453382SBill Fenner  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19b0453382SBill Fenner  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20b0453382SBill Fenner  */
21b0453382SBill Fenner 
223340d773SGleb Smirnoff /* \summary: IP Payload Compression Protocol (IPComp) printer */
233340d773SGleb Smirnoff 
24*ee67461eSJoseph Mingrone #include <config.h>
25b0453382SBill Fenner 
26*ee67461eSJoseph Mingrone #include "netdissect-stdinc.h"
27b0453382SBill Fenner 
283340d773SGleb Smirnoff #include "netdissect.h"
295b0fe478SBruce M Simpson #include "extract.h"
30b0453382SBill Fenner 
31*ee67461eSJoseph Mingrone struct ipcomp {
32*ee67461eSJoseph Mingrone 	nd_uint8_t  comp_nxt;	/* Next Header */
33*ee67461eSJoseph Mingrone 	nd_uint8_t  comp_flags;	/* Length of data, in 32bit */
34*ee67461eSJoseph Mingrone 	nd_uint16_t comp_cpi;	/* Compression parameter index */
35*ee67461eSJoseph Mingrone };
36*ee67461eSJoseph Mingrone 
373340d773SGleb Smirnoff void
ipcomp_print(netdissect_options * ndo,const u_char * bp)38*ee67461eSJoseph Mingrone ipcomp_print(netdissect_options *ndo, const u_char *bp)
39b0453382SBill Fenner {
40*ee67461eSJoseph Mingrone 	const struct ipcomp *ipcomp;
413c602fabSXin LI 	uint16_t cpi;
42b0453382SBill Fenner 
43*ee67461eSJoseph Mingrone 	ndo->ndo_protocol = "ipcomp";
443340d773SGleb Smirnoff 	ipcomp = (const struct ipcomp *)bp;
45*ee67461eSJoseph Mingrone 	cpi = GET_BE_U_2(ipcomp->comp_cpi);
46b0453382SBill Fenner 
47*ee67461eSJoseph Mingrone 	ND_PRINT("IPComp(cpi=0x%04x)", cpi);
48b0453382SBill Fenner 
49b0453382SBill Fenner 	/*
503340d773SGleb Smirnoff 	 * XXX - based on the CPI, we could decompress the packet here.
513340d773SGleb Smirnoff 	 * Packet buffer management is a headache (if we decompress,
523340d773SGleb Smirnoff 	 * packet will become larger).
533340d773SGleb Smirnoff 	 *
543340d773SGleb Smirnoff 	 * We would decompress the packet and then call a routine that,
553340d773SGleb Smirnoff 	 * based on ipcomp->comp_nxt, dissects the decompressed data.
563340d773SGleb Smirnoff 	 *
573340d773SGleb Smirnoff 	 * Until we do that, however, we just return -1, so that
583340d773SGleb Smirnoff 	 * the loop that processes "protocol"/"next header" types
593340d773SGleb Smirnoff 	 * stops - there's nothing more it can do with a compressed
603340d773SGleb Smirnoff 	 * payload.
61b0453382SBill Fenner 	 */
62b0453382SBill Fenner }
63