Explicitly request literal mode after .Xr.
[netbsd-mini2440.git] / dist / tcpdump / print-sunatm.c
blobcbd9974c88d2de091ed65053ae1c2ea39edb40a9
1 /* $NetBSD$ */
3 /*
4 * Copyright (c) 1997 Yen Yen Lim and North Dakota State University
5 * All rights reserved.
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.
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.
34 #include <sys/cdefs.h>
35 #ifndef lint
36 #if 0
37 static const char rcsid[] _U_ =
38 "@(#) Header: /tcpdump/master/tcpdump/print-sunatm.c,v 1.8 2004/03/17 23:24:38 guy Exp (LBL)";
39 #else
40 __RCSID("$NetBSD: tcpdump2rcsid.ex,v 1.1 2001/06/25 20:09:58 itojun Exp $");
41 #endif
42 #endif
44 #ifdef HAVE_CONFIG_H
45 #include "config.h"
46 #endif
48 #include <tcpdump-stdinc.h>
50 struct mbuf;
51 struct rtentry;
53 #include <stdio.h>
54 #include <pcap.h>
56 #include "interface.h"
57 #include "extract.h"
58 #include "addrtoname.h"
60 #include "atm.h"
61 #include "atmuni31.h"
63 /* SunATM header for ATM packet */
64 #define DIR_POS 0 /* Direction (0x80 = transmit, 0x00 = receive) */
65 #define VPI_POS 1 /* VPI */
66 #define VCI_POS 2 /* VCI */
67 #define PKT_BEGIN_POS 4 /* Start of the ATM packet */
69 /* Protocol type values in the bottom for bits of the byte at SUNATM_DIR_POS. */
70 #define PT_LANE 0x01 /* LANE */
71 #define PT_LLC 0x02 /* LLC encapsulation */
74 * This is the top level routine of the printer. 'p' points
75 * to the SunATM pseudo-header for the packet, 'h->ts' is the timestamp,
76 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
77 * is the number of bytes actually captured.
79 u_int
80 sunatm_if_print(const struct pcap_pkthdr *h, const u_char *p)
82 u_int caplen = h->caplen;
83 u_int length = h->len;
84 u_short vci;
85 u_char vpi;
86 u_int traftype;
88 if (caplen < PKT_BEGIN_POS) {
89 printf("[|atm]");
90 return (caplen);
93 if (eflag) {
94 if (p[DIR_POS] & 0x80)
95 printf("Tx: ");
96 else
97 printf("Rx: ");
100 switch (p[DIR_POS] & 0x0f) {
102 case PT_LANE:
103 traftype = ATM_LANE;
104 break;
106 case PT_LLC:
107 traftype = ATM_LLC;
108 break;
110 default:
111 traftype = ATM_UNKNOWN;
112 break;
115 vci = EXTRACT_16BITS(&p[VCI_POS]);
116 vpi = p[VPI_POS];
118 p += PKT_BEGIN_POS;
119 caplen -= PKT_BEGIN_POS;
120 length -= PKT_BEGIN_POS;
121 atm_print(vpi, vci, traftype, p, length, caplen);
123 return (PKT_BEGIN_POS);