source: rtems-libbsd/freebsd/contrib/tcpdump/print-sunatm.c @ 8440506

4.1155-freebsd-126-freebsd-12freebsd-9.3
Last change on this file since 8440506 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: 3.4 KB
Line 
1#include <machine/rtems-bsd-user-space.h>
2
3/*
4 * Copyright (c) 1997 Yen Yen Lim and North Dakota State University
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 *    must display the following acknowledgement:
17 *      This product includes software developed by Yen Yen Lim and
18        North Dakota State University
19 * 4. The name of the author may not be used to endorse or promote products
20 *    derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
26 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 */
34#ifndef lint
35static const char rcsid[] _U_ =
36    "@(#) $Header: /tcpdump/master/tcpdump/print-sunatm.c,v 1.8 2004-03-17 23:24:38 guy Exp $ (LBL)";
37#endif
38
39#ifdef HAVE_CONFIG_H
40#include "config.h"
41#endif
42
43#include <tcpdump-stdinc.h>
44 
45struct mbuf;
46struct rtentry;
47 
48#include <stdio.h>
49#include <pcap.h>
50
51#include "interface.h"
52#include "extract.h"
53#include "addrtoname.h"
54
55#include "atm.h"
56#include "atmuni31.h"
57
58/* SunATM header for ATM packet */
59#define DIR_POS         0       /* Direction (0x80 = transmit, 0x00 = receive) */
60#define VPI_POS         1       /* VPI */
61#define VCI_POS         2       /* VCI */
62#define PKT_BEGIN_POS   4       /* Start of the ATM packet */
63
64/* Protocol type values in the bottom for bits of the byte at SUNATM_DIR_POS. */
65#define PT_LANE         0x01    /* LANE */
66#define PT_LLC          0x02    /* LLC encapsulation */
67
68/*
69 * This is the top level routine of the printer.  'p' points
70 * to the SunATM pseudo-header for the packet, 'h->ts' is the timestamp,
71 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
72 * is the number of bytes actually captured.
73 */
74u_int
75sunatm_if_print(const struct pcap_pkthdr *h, const u_char *p)
76{
77        u_int caplen = h->caplen;
78        u_int length = h->len;
79        u_short vci;
80        u_char vpi;
81        u_int traftype;
82
83        if (caplen < PKT_BEGIN_POS) {
84                printf("[|atm]");
85                return (caplen);
86        }
87
88        if (eflag) {
89                if (p[DIR_POS] & 0x80)
90                        printf("Tx: ");
91                else
92                        printf("Rx: ");
93        }
94
95        switch (p[DIR_POS] & 0x0f) {
96
97        case PT_LANE:
98                traftype = ATM_LANE;
99                break;
100
101        case PT_LLC:
102                traftype = ATM_LLC;
103                break;
104
105        default:
106                traftype = ATM_UNKNOWN;
107                break;
108        }
109
110        vci = EXTRACT_16BITS(&p[VCI_POS]);
111        vpi = p[VPI_POS];
112
113        p += PKT_BEGIN_POS;
114        caplen -= PKT_BEGIN_POS;
115        length -= PKT_BEGIN_POS;
116        atm_print(vpi, vci, traftype, p, length, caplen);
117
118        return (PKT_BEGIN_POS);
119}
Note: See TracBrowser for help on using the repository browser.