source: rtems-libbsd/freebsd/contrib/tcpdump/print-ipcomp.c @ 084d4db

4.11
Last change on this file since 084d4db was 8440506, checked in by Chris Johns <chrisj@…>, on 06/15/15 at 07:42:23

Add tcpdump and libpcap.

  • Update the file builder generator to handle generator specific cflags and includes. The tcpdump and libpcap have localised headers and need specific headers paths to see them. There are also module specific flags and these need to be passed to the lex and yacc generators.
  • Add the tcpdump support.
  • Property mode set to 100644
File size: 2.6 KB
Line 
1#include <machine/rtems-bsd-user-space.h>
2
3/*
4 * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
5 *      The Regents of the University of California.  All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that: (1) source code distributions
9 * retain the above copyright notice and this paragraph in its entirety, (2)
10 * distributions including binary code include the above copyright notice and
11 * this paragraph in its entirety in the documentation or other materials
12 * provided with the distribution, and (3) all advertising materials mentioning
13 * features or use of this software display the following acknowledgement:
14 * ``This product includes software developed by the University of California,
15 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16 * the University nor the names of its contributors may be used to endorse
17 * or promote products derived from this software without specific prior
18 * written permission.
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 */
23
24#ifndef lint
25static const char rcsid[] _U_ =
26    "@(#) $Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.20 2003-11-19 00:36:08 guy Exp $";
27#endif
28
29#ifdef HAVE_CONFIG_H
30#include "config.h"
31#endif
32
33#include <string.h>
34#include <tcpdump-stdinc.h>
35
36#include <stdio.h>
37
38struct ipcomp {
39        u_int8_t comp_nxt;      /* Next Header */
40        u_int8_t comp_flags;    /* Length of data, in 32bit */
41        u_int16_t comp_cpi;     /* Compression parameter index */
42};
43
44#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
45#include <zlib.h>
46#endif
47
48#include "interface.h"
49#include "addrtoname.h"
50#include "extract.h"
51
52int
53ipcomp_print(register const u_char *bp, int *nhdr _U_)
54{
55        register const struct ipcomp *ipcomp;
56        register const u_char *ep;
57        u_int16_t cpi;
58#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
59        int advance;
60#endif
61
62        ipcomp = (struct ipcomp *)bp;
63        cpi = EXTRACT_16BITS(&ipcomp->comp_cpi);
64
65        /* 'ep' points to the end of available data. */
66        ep = snapend;
67
68        if ((u_char *)(ipcomp + 1) >= ep - sizeof(struct ipcomp)) {
69                fputs("[|IPCOMP]", stdout);
70                goto fail;
71        }
72        printf("IPComp(cpi=0x%04x)", cpi);
73
74#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
75        if (1)
76                goto fail;
77
78        /*
79         * We may want to decompress the packet here.  Packet buffer
80         * management is a headache (if we decompress, packet will become
81         * larger).
82         */
83        if (nhdr)
84                *nhdr = ipcomp->comp_nxt;
85        advance = sizeof(struct ipcomp);
86
87        printf(": ");
88        return advance;
89
90#endif
91fail:
92        return -1;
93}
Note: See TracBrowser for help on using the repository browser.