4 * Copyright (c) 1994, 1995, 1996, 1997
5 * The Regents of the University of California. All rights reserved.
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
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.
23 #include <sys/cdefs.h>
26 static const char rcsid
[] _U_
=
27 "@(#) Header: /tcpdump/master/tcpdump/print-atm.c,v 1.38.2.6 2006/01/25 13:27:24 hannes Exp (LBL)";
29 __RCSID("$NetBSD: tcpdump2rcsid.ex,v 1.1 2001/06/25 20:09:58 itojun Exp $");
37 #include <tcpdump-stdinc.h>
43 #include "interface.h"
45 #include "addrtoname.h"
46 #include "ethertype.h"
53 struct tok oam_f_values
[] = {
54 { OAMF4SC
, "OAM F4 (segment)" },
55 { OAMF4EC
, "OAM F4 (end)" },
59 struct tok oam_celltype_values
[] = {
60 { 0x1, "Fault Management" },
61 { 0x2, "Performance Management" },
62 { 0x8, "activate/deactivate" },
63 { 0xf, "System Management" },
67 struct tok oam_fm_functype_values
[] = {
70 { 0x4, "Continuity Check" },
75 struct tok oam_pm_functype_values
[] = {
76 { 0x0, "Forward Monitoring" },
77 { 0x1, "Backward Reporting" },
78 { 0x2, "Monitoring and Reporting" },
82 struct tok oam_ad_functype_values
[] = {
83 { 0x0, "Performance Monitoring" },
84 { 0x1, "Continuity Check" },
88 static const struct tok
*oam_functype_values
[16] = {
90 oam_fm_functype_values
, /* 1 */
91 oam_pm_functype_values
, /* 2 */
97 oam_ad_functype_values
, /* 8 */
108 * Print an RFC 1483 LLC-encapsulated ATM frame.
111 atm_llc_print(const u_char
*p
, int length
, int caplen
)
113 u_short extracted_ethertype
;
115 if (!llc_print(p
, length
, caplen
, NULL
, NULL
,
116 &extracted_ethertype
)) {
117 /* ether_type not known, print raw packet */
118 if (extracted_ethertype
) {
120 etherproto_string(htons(extracted_ethertype
)));
122 if (!suppress_default_print
)
123 default_print(p
, caplen
);
128 * Given a SAP value, generate the LLC header value for a UI packet
129 * with that SAP as the source and destination SAP.
131 #define LLC_UI_HDR(sap) ((sap)<<16 | (sap<<8) | 0x03)
134 * This is the top level routine of the printer. 'p' points
135 * to the LLC/SNAP header of the packet, 'h->ts' is the timestamp,
136 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
137 * is the number of bytes actually captured.
140 atm_if_print(const struct pcap_pkthdr
*h
, const u_char
*p
)
142 u_int caplen
= h
->caplen
;
143 u_int length
= h
->len
;
152 /* Cisco Style NLPID ? */
156 isoclns_print(p
+1, length
-1, caplen
-1);
161 * Extract the presumed LLC header into a variable, for quick
163 * Then check for a header that's neither a header for a SNAP
164 * packet nor an RFC 2684 routed NLPID-formatted PDU nor
165 * an 802.2-but-no-SNAP IP packet.
167 llchdr
= EXTRACT_24BITS(p
);
168 if (llchdr
!= LLC_UI_HDR(LLCSAP_SNAP
) &&
169 llchdr
!= LLC_UI_HDR(LLCSAP_ISONS
) &&
170 llchdr
!= LLC_UI_HDR(LLCSAP_IP
)) {
172 * XXX - assume 802.6 MAC header from Fore driver.
174 * Unfortunately, the above list doesn't check for
175 * all known SAPs, doesn't check for headers where
176 * the source and destination SAP aren't the same,
177 * and doesn't check for non-UI frames. It also
178 * runs the risk of an 802.6 MAC header that happens
179 * to begin with one of those values being
180 * incorrectly treated as an 802.2 header.
182 * So is that Fore driver still around? And, if so,
183 * is it still putting 802.6 MAC headers on ATM
184 * packets? If so, could it be changed to use a
185 * new DLT_IEEE802_6 value if we added it?
188 printf("%08x%08x %08x%08x ",
192 EXTRACT_32BITS(p
+12));
198 atm_llc_print(p
, length
, caplen
);
205 static struct tok msgtype2str
[] = {
206 { CALL_PROCEED
, "Call_proceeding" },
207 { CONNECT
, "Connect" },
208 { CONNECT_ACK
, "Connect_ack" },
210 { RELEASE
, "Release" },
211 { RELEASE_DONE
, "Release_complete" },
212 { RESTART
, "Restart" },
213 { RESTART_ACK
, "Restart_ack" },
214 { STATUS
, "Status" },
215 { STATUS_ENQ
, "Status_enquiry" },
216 { ADD_PARTY
, "Add_party" },
217 { ADD_PARTY_ACK
, "Add_party_ack" },
218 { ADD_PARTY_REJ
, "Add_party_reject" },
219 { DROP_PARTY
, "Drop_party" },
220 { DROP_PARTY_ACK
, "Drop_party_ack" },
225 sig_print(const u_char
*p
, int caplen
)
227 bpf_u_int32 call_ref
;
229 if (caplen
< PROTO_POS
) {
233 if (p
[PROTO_POS
] == Q2931
) {
235 * protocol:Q.2931 for User to Network Interface
236 * (UNI 3.1) signalling
239 if (caplen
< MSG_TYPE_POS
) {
244 tok2str(msgtype2str
, "msgtype#%d", p
[MSG_TYPE_POS
]));
246 if (caplen
< CALL_REF_POS
+3) {
250 call_ref
= EXTRACT_24BITS(&p
[CALL_REF_POS
]);
251 printf("CALL_REF:0x%06x", call_ref
);
253 /* SCCOP with some unknown protocol atop it */
254 printf("SSCOP, proto %d ", p
[PROTO_POS
]);
259 * Print an ATM PDU (such as an AAL5 PDU).
262 atm_print(u_int vpi
, u_int vci
, u_int traftype
, const u_char
*p
, u_int length
,
266 printf("VPI:%u VCI:%u ", vpi
, vci
);
272 sig_print(p
, caplen
);
276 printf("broadcast sig: ");
279 case OAMF4SC
: /* fall through */
281 oam_print(p
, length
, ATM_OAM_HEC
);
290 snmp_print(p
, length
);
300 * Assumes traffic is LLC if unknown.
302 atm_llc_print(p
, length
, caplen
);
306 lane_print(p
, length
, caplen
);
312 oam_print (const u_char
*p
, u_int length
, u_int hec
) {
314 u_int32_t cell_header
;
315 u_int16_t cell_type
, func_type
,vpi
,vci
,payload
,clp
;
317 cell_header
= EXTRACT_32BITS(p
+hec
);
318 cell_type
= ((*(p
+4+hec
))>>4) & 0x0f;
319 func_type
= *(p
+4+hec
) & 0x0f;
321 vpi
= (cell_header
>>20)&0xff;
322 vci
= (cell_header
>>4)&0xffff;
323 payload
= (cell_header
>>1)&0x7;
324 clp
= cell_header
&0x1;
326 printf("%s, vpi %u, vci %u, payload %u, clp %u, ",
327 tok2str(oam_f_values
, "OAM F5", vci
),
328 vpi
, vci
, payload
, clp
);
330 printf("cell-type %s (%u)",
331 tok2str(oam_celltype_values
, "unknown", cell_type
),
334 if (oam_functype_values
[cell_type
] == NULL
)
335 printf(", func-type unknown (%u)", func_type
);
337 printf(", func-type %s (%u)",
338 bittok2str(oam_functype_values
[cell_type
],"none",func_type
),
341 printf(", length %u",length
);