xref: /dflybsd-src/contrib/tcpdump/print-ipcomp.c (revision 59c07fbdf8168fa08c76c515186d561b5a92690c)
141c99275SPeter Avalos /*
241c99275SPeter Avalos  * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
341c99275SPeter Avalos  *	The Regents of the University of California.  All rights reserved.
441c99275SPeter Avalos  *
541c99275SPeter Avalos  * Redistribution and use in source and binary forms, with or without
641c99275SPeter Avalos  * modification, are permitted provided that: (1) source code distributions
741c99275SPeter Avalos  * retain the above copyright notice and this paragraph in its entirety, (2)
841c99275SPeter Avalos  * distributions including binary code include the above copyright notice and
941c99275SPeter Avalos  * this paragraph in its entirety in the documentation or other materials
1041c99275SPeter Avalos  * provided with the distribution, and (3) all advertising materials mentioning
1141c99275SPeter Avalos  * features or use of this software display the following acknowledgement:
1241c99275SPeter Avalos  * ``This product includes software developed by the University of California,
1341c99275SPeter Avalos  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
1441c99275SPeter Avalos  * the University nor the names of its contributors may be used to endorse
1541c99275SPeter Avalos  * or promote products derived from this software without specific prior
1641c99275SPeter Avalos  * written permission.
1741c99275SPeter Avalos  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
1841c99275SPeter Avalos  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
1941c99275SPeter Avalos  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
2041c99275SPeter Avalos  */
2141c99275SPeter Avalos 
22411677aeSAaron LI /* \summary: IP Payload Compression Protocol (IPComp) printer */
2341c99275SPeter Avalos 
2441c99275SPeter Avalos #ifdef HAVE_CONFIG_H
25*ed775ee7SAntonio Huete Jimenez #include <config.h>
2641c99275SPeter Avalos #endif
2741c99275SPeter Avalos 
28*ed775ee7SAntonio Huete Jimenez #include "netdissect-stdinc.h"
2941c99275SPeter Avalos 
30411677aeSAaron LI #include "netdissect.h"
3141c99275SPeter Avalos #include "extract.h"
3241c99275SPeter Avalos 
33*ed775ee7SAntonio Huete Jimenez struct ipcomp {
34*ed775ee7SAntonio Huete Jimenez 	nd_uint8_t  comp_nxt;	/* Next Header */
35*ed775ee7SAntonio Huete Jimenez 	nd_uint8_t  comp_flags;	/* Length of data, in 32bit */
36*ed775ee7SAntonio Huete Jimenez 	nd_uint16_t comp_cpi;	/* Compression parameter index */
37*ed775ee7SAntonio Huete Jimenez };
38*ed775ee7SAntonio Huete Jimenez 
39411677aeSAaron LI void
ipcomp_print(netdissect_options * ndo,const u_char * bp)40*ed775ee7SAntonio Huete Jimenez ipcomp_print(netdissect_options *ndo, const u_char *bp)
4141c99275SPeter Avalos {
42*ed775ee7SAntonio Huete Jimenez 	const struct ipcomp *ipcomp;
43411677aeSAaron LI 	uint16_t cpi;
4441c99275SPeter Avalos 
45*ed775ee7SAntonio Huete Jimenez 	ndo->ndo_protocol = "ipcomp";
46411677aeSAaron LI 	ipcomp = (const struct ipcomp *)bp;
47*ed775ee7SAntonio Huete Jimenez 	cpi = GET_BE_U_2(ipcomp->comp_cpi);
4841c99275SPeter Avalos 
49*ed775ee7SAntonio Huete Jimenez 	ND_PRINT("IPComp(cpi=0x%04x)", cpi);
5041c99275SPeter Avalos 
5141c99275SPeter Avalos 	/*
52411677aeSAaron LI 	 * XXX - based on the CPI, we could decompress the packet here.
53411677aeSAaron LI 	 * Packet buffer management is a headache (if we decompress,
54411677aeSAaron LI 	 * packet will become larger).
55411677aeSAaron LI 	 *
56411677aeSAaron LI 	 * We would decompress the packet and then call a routine that,
57411677aeSAaron LI 	 * based on ipcomp->comp_nxt, dissects the decompressed data.
58411677aeSAaron LI 	 *
59411677aeSAaron LI 	 * Until we do that, however, we just return -1, so that
60411677aeSAaron LI 	 * the loop that processes "protocol"/"next header" types
61411677aeSAaron LI 	 * stops - there's nothing more it can do with a compressed
62411677aeSAaron LI 	 * payload.
6341c99275SPeter Avalos 	 */
6441c99275SPeter Avalos }
65