2 * Copyright (c) 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 /* \summary: Asynchronous Transfer Mode (ATM) printer */
26 #include "netdissect-stdinc.h"
28 #define ND_LONGJMP_FROM_TCHECK
29 #include "netdissect.h"
31 #include "addrtoname.h"
35 /* start of the original atmuni31.h */
38 * Copyright (c) 1997 Yen Yen Lim and North Dakota State University
39 * All rights reserved.
41 * Redistribution and use in source and binary forms, with or without
42 * modification, are permitted provided that the following conditions
44 * 1. Redistributions of source code must retain the above copyright
45 * notice, this list of conditions and the following disclaimer.
46 * 2. Redistributions in binary form must reproduce the above copyright
47 * notice, this list of conditions and the following disclaimer in the
48 * documentation and/or other materials provided with the distribution.
49 * 3. All advertising materials mentioning features or use of this software
50 * must display the following acknowledgement:
51 * This product includes software developed by Yen Yen Lim and
52 North Dakota State University
53 * 4. The name of the author may not be used to endorse or promote products
54 * derived from this software without specific prior written permission.
56 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
57 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
58 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
59 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
60 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
61 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
62 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
65 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
66 * POSSIBILITY OF SUCH DAMAGE.
69 /* Based on UNI3.1 standard by ATM Forum */
71 /* ATM traffic types based on VPI=0 and (the following VCI */
72 #define VCI_PPC 0x05 /* Point-to-point signal msg */
73 #define VCI_BCC 0x02 /* Broadcast signal msg */
74 #define VCI_OAMF4SC 0x03 /* Segment OAM F4 flow cell */
75 #define VCI_OAMF4EC 0x04 /* End-to-end OAM F4 flow cell */
76 #define VCI_METAC 0x01 /* Meta signal msg */
77 #define VCI_ILMIC 0x10 /* ILMI msg */
79 /* Q.2931 signalling messages */
80 #define CALL_PROCEED 0x02 /* call proceeding */
81 #define CONNECT 0x07 /* connect */
82 #define CONNECT_ACK 0x0f /* connect_ack */
83 #define SETUP 0x05 /* setup */
84 #define RELEASE 0x4d /* release */
85 #define RELEASE_DONE 0x5a /* release_done */
86 #define RESTART 0x46 /* restart */
87 #define RESTART_ACK 0x4e /* restart ack */
88 #define STATUS 0x7d /* status */
89 #define STATUS_ENQ 0x75 /* status ack */
90 #define ADD_PARTY 0x80 /* add party */
91 #define ADD_PARTY_ACK 0x81 /* add party ack */
92 #define ADD_PARTY_REJ 0x82 /* add party rej */
93 #define DROP_PARTY 0x83 /* drop party */
94 #define DROP_PARTY_ACK 0x84 /* drop party ack */
96 /* Information Element Parameters in the signalling messages */
97 #define CAUSE 0x08 /* cause */
98 #define ENDPT_REF 0x54 /* endpoint reference */
99 #define AAL_PARA 0x58 /* ATM adaptation layer parameters */
100 #define TRAFF_DESCRIP 0x59 /* atm traffic descriptors */
101 #define CONNECT_ID 0x5a /* connection identifier */
102 #define QOS_PARA 0x5c /* quality of service parameters */
103 #define B_HIGHER 0x5d /* broadband higher layer information */
104 #define B_BEARER 0x5e /* broadband bearer capability */
105 #define B_LOWER 0x5f /* broadband lower information */
106 #define CALLING_PARTY 0x6c /* calling party number */
107 #define CALLED_PARTY 0x70 /* called party number */
111 /* Q.2931 signalling general messages format */
112 #define PROTO_POS 0 /* offset of protocol discriminator */
113 #define CALL_REF_POS 2 /* offset of call reference value */
114 #define MSG_TYPE_POS 5 /* offset of message type */
116 #define MSG_LEN_POS 7 /* offset of message length */
117 #define IE_BEGIN_POS 9 /* offset of first information element */
119 /* format of signalling messages */
122 #define FIELD_BEGIN_POS 4
125 /* end of the original atmuni31.h */
128 #define OAM_CRC10_MASK 0x3ff
129 #define OAM_PAYLOAD_LEN 48
130 #define OAM_FUNCTION_SPECIFIC_LEN 45 /* this excludes crc10 and cell-type/function-type */
131 #define OAM_CELLTYPE_FUNCTYPE_LEN 1
133 static const struct tok oam_f_values
[] = {
134 { VCI_OAMF4SC
, "OAM F4 (segment)" },
135 { VCI_OAMF4EC
, "OAM F4 (end)" },
139 static const struct tok atm_pty_values
[] = {
140 { 0x0, "user data, uncongested, SDU 0" },
141 { 0x1, "user data, uncongested, SDU 1" },
142 { 0x2, "user data, congested, SDU 0" },
143 { 0x3, "user data, congested, SDU 1" },
144 { 0x4, "VCC OAM F5 flow segment" },
145 { 0x5, "VCC OAM F5 flow end-to-end" },
146 { 0x6, "Traffic Control and resource Mgmt" },
150 #define OAM_CELLTYPE_FM 0x1
151 #define OAM_CELLTYPE_PM 0x2
152 #define OAM_CELLTYPE_AD 0x8
153 #define OAM_CELLTYPE_SM 0xf
155 static const struct tok oam_celltype_values
[] = {
156 { OAM_CELLTYPE_FM
, "Fault Management" },
157 { OAM_CELLTYPE_PM
, "Performance Management" },
158 { OAM_CELLTYPE_AD
, "activate/deactivate" },
159 { OAM_CELLTYPE_SM
, "System Management" },
163 #define OAM_FM_FUNCTYPE_AIS 0x0
164 #define OAM_FM_FUNCTYPE_RDI 0x1
165 #define OAM_FM_FUNCTYPE_CONTCHECK 0x4
166 #define OAM_FM_FUNCTYPE_LOOPBACK 0x8
168 static const struct tok oam_fm_functype_values
[] = {
169 { OAM_FM_FUNCTYPE_AIS
, "AIS" },
170 { OAM_FM_FUNCTYPE_RDI
, "RDI" },
171 { OAM_FM_FUNCTYPE_CONTCHECK
, "Continuity Check" },
172 { OAM_FM_FUNCTYPE_LOOPBACK
, "Loopback" },
176 static const struct tok oam_pm_functype_values
[] = {
177 { 0x0, "Forward Monitoring" },
178 { 0x1, "Backward Reporting" },
179 { 0x2, "Monitoring and Reporting" },
183 static const struct tok oam_ad_functype_values
[] = {
184 { 0x0, "Performance Monitoring" },
185 { 0x1, "Continuity Check" },
189 #define OAM_FM_LOOPBACK_INDICATOR_MASK 0x1
191 static const struct tok oam_fm_loopback_indicator_values
[] = {
197 static const struct uint_tokary oam_celltype2tokary
[] = {
198 { OAM_CELLTYPE_FM
, oam_fm_functype_values
},
199 { OAM_CELLTYPE_PM
, oam_pm_functype_values
},
200 { OAM_CELLTYPE_AD
, oam_ad_functype_values
},
201 /* uint2tokary() does not use array termination. */
205 * Print an RFC 1483 LLC-encapsulated ATM frame.
208 atm_llc_print(netdissect_options
*ndo
,
209 const u_char
*p
, int length
, int caplen
)
213 llc_hdrlen
= llc_print(ndo
, p
, length
, caplen
, NULL
, NULL
);
214 if (llc_hdrlen
< 0) {
215 /* packet not known, print raw packet */
216 if (!ndo
->ndo_suppress_default_print
)
217 ND_DEFAULTPRINT(p
, caplen
);
218 llc_hdrlen
= -llc_hdrlen
;
224 * Given a SAP value, generate the LLC header value for a UI packet
225 * with that SAP as the source and destination SAP.
227 #define LLC_UI_HDR(sap) ((sap)<<16 | (sap<<8) | 0x03)
230 * This is the top level routine of the printer. 'p' points
231 * to the LLC/SNAP header of the packet, 'h->ts' is the timestamp,
232 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
233 * is the number of bytes actually captured.
236 atm_if_print(netdissect_options
*ndo
,
237 const struct pcap_pkthdr
*h
, const u_char
*p
)
239 u_int caplen
= h
->caplen
;
240 u_int length
= h
->len
;
244 ndo
->ndo_protocol
= "atm";
246 /* Cisco Style NLPID ? */
247 if (GET_U_1(p
) == LLC_UI
) {
250 ndo
->ndo_ll_hdr_len
+= 1;
251 isoclns_print(ndo
, p
+ 1, length
- 1);
256 * Must have at least a DSAP, an SSAP, and the first byte of the
261 * Extract the presumed LLC header into a variable, for quick
263 * Then check for a header that's neither a header for a SNAP
264 * packet nor an RFC 2684 routed NLPID-formatted PDU nor
265 * an 802.2-but-no-SNAP IP packet.
267 llchdr
= GET_BE_U_3(p
);
268 if (llchdr
!= LLC_UI_HDR(LLCSAP_SNAP
) &&
269 llchdr
!= LLC_UI_HDR(LLCSAP_ISONS
) &&
270 llchdr
!= LLC_UI_HDR(LLCSAP_IP
)) {
272 * XXX - assume 802.6 MAC header from Fore driver.
274 * Unfortunately, the above list doesn't check for
275 * all known SAPs, doesn't check for headers where
276 * the source and destination SAP aren't the same,
277 * and doesn't check for non-UI frames. It also
278 * runs the risk of an 802.6 MAC header that happens
279 * to begin with one of those values being
280 * incorrectly treated as an 802.2 header.
282 * So is that Fore driver still around? And, if so,
283 * is it still putting 802.6 MAC headers on ATM
284 * packets? If so, could it be changed to use a
285 * new DLT_IEEE802_6 value if we added it?
288 ND_PRINT("%08x%08x %08x%08x ",
293 /* Always cover the full header. */
294 ND_TCHECK_LEN(p
, 20);
300 ndo
->ndo_ll_hdr_len
+= hdrlen
;
301 ndo
->ndo_ll_hdr_len
+= atm_llc_print(ndo
, p
, length
, caplen
);
307 static const struct tok msgtype2str
[] = {
308 { CALL_PROCEED
, "Call_proceeding" },
309 { CONNECT
, "Connect" },
310 { CONNECT_ACK
, "Connect_ack" },
312 { RELEASE
, "Release" },
313 { RELEASE_DONE
, "Release_complete" },
314 { RESTART
, "Restart" },
315 { RESTART_ACK
, "Restart_ack" },
316 { STATUS
, "Status" },
317 { STATUS_ENQ
, "Status_enquiry" },
318 { ADD_PARTY
, "Add_party" },
319 { ADD_PARTY_ACK
, "Add_party_ack" },
320 { ADD_PARTY_REJ
, "Add_party_reject" },
321 { DROP_PARTY
, "Drop_party" },
322 { DROP_PARTY_ACK
, "Drop_party_ack" },
327 sig_print(netdissect_options
*ndo
,
332 if (GET_U_1(p
+ PROTO_POS
) == Q2931
) {
334 * protocol:Q.2931 for User to Network Interface
335 * (UNI 3.1) signalling
339 tok2str(msgtype2str
, "msgtype#%u", GET_U_1(p
+ MSG_TYPE_POS
)));
342 * The call reference comes before the message type,
343 * so if we know we have the message type, which we
344 * do from the caplen test above, we also know we have
345 * the call reference.
347 call_ref
= GET_BE_U_3(p
+ CALL_REF_POS
);
348 ND_PRINT("CALL_REF:0x%06x", call_ref
);
350 /* SSCOP with some unknown protocol atop it */
351 ND_PRINT("SSCOP, proto %u ", GET_U_1(p
+ PROTO_POS
));
356 * Print an ATM PDU (such as an AAL5 PDU).
359 atm_print(netdissect_options
*ndo
,
360 u_int vpi
, u_int vci
, u_int traftype
, const u_char
*p
, u_int length
,
363 ndo
->ndo_protocol
= "atm";
365 ND_PRINT("VPI:%u VCI:%u ", vpi
, vci
);
375 ND_PRINT("broadcast sig: ");
378 case VCI_OAMF4SC
: /* fall through */
380 oam_print(ndo
, p
, length
, ATM_OAM_HEC
);
389 snmp_print(ndo
, p
, length
);
399 * Assumes traffic is LLC if unknown.
401 atm_llc_print(ndo
, p
, length
, caplen
);
405 lane_print(ndo
, p
, length
, caplen
);
410 struct oam_fm_loopback_t
{
411 nd_uint8_t loopback_indicator
;
412 nd_uint32_t correlation_tag
;
413 nd_byte loopback_id
[12];
414 nd_byte source_id
[12];
418 struct oam_fm_ais_rdi_t
{
419 nd_uint8_t failure_type
;
420 nd_byte failure_location
[16];
425 oam_print(netdissect_options
*ndo
,
426 const u_char
*p
, u_int length
, u_int hec
)
428 uint32_t cell_header
;
429 uint16_t vpi
, vci
, cksum
, cksum_shouldbe
, idx
;
430 uint8_t cell_type
, func_type
, payload
, clp
;
431 const struct tok
*oam_functype_str
;
434 const struct oam_fm_loopback_t
*oam_fm_loopback
;
435 const struct oam_fm_ais_rdi_t
*oam_fm_ais_rdi
;
438 ndo
->ndo_protocol
= "oam";
439 cell_header
= GET_BE_U_4(p
+ hec
);
440 cell_type
= (GET_U_1((p
+ ATM_HDR_LEN_NOHEC
+ hec
)) >> 4) & 0x0f;
441 func_type
= GET_U_1((p
+ ATM_HDR_LEN_NOHEC
+ hec
)) & 0x0f;
443 vpi
= (cell_header
>>20)&0xff;
444 vci
= (cell_header
>>4)&0xffff;
445 payload
= (cell_header
>>1)&0x7;
446 clp
= cell_header
&0x1;
448 ND_PRINT("%s, vpi %u, vci %u, payload [ %s ], clp %u, length %u",
449 tok2str(oam_f_values
, "OAM F5", vci
),
451 tok2str(atm_pty_values
, "Unknown", payload
),
454 if (!ndo
->ndo_vflag
) {
458 ND_PRINT("\n\tcell-type %s (%u)",
459 tok2str(oam_celltype_values
, "unknown", cell_type
),
462 oam_functype_str
= uint2tokary(oam_celltype2tokary
, cell_type
);
463 if (oam_functype_str
== NULL
)
464 ND_PRINT(", func-type unknown (%u)", func_type
);
466 ND_PRINT(", func-type %s (%u)",
467 tok2str(oam_functype_str
, "none", func_type
),
470 p
+= ATM_HDR_LEN_NOHEC
+ hec
;
472 switch (cell_type
<< 4 | func_type
) {
473 case (OAM_CELLTYPE_FM
<< 4 | OAM_FM_FUNCTYPE_LOOPBACK
):
474 oam_ptr
.oam_fm_loopback
= (const struct oam_fm_loopback_t
*)(p
+ OAM_CELLTYPE_FUNCTYPE_LEN
);
475 ND_TCHECK_SIZE(oam_ptr
.oam_fm_loopback
);
476 ND_PRINT("\n\tLoopback-Indicator %s, Correlation-Tag 0x%08x",
477 tok2str(oam_fm_loopback_indicator_values
,
479 GET_U_1(oam_ptr
.oam_fm_loopback
->loopback_indicator
) & OAM_FM_LOOPBACK_INDICATOR_MASK
),
480 GET_BE_U_4(oam_ptr
.oam_fm_loopback
->correlation_tag
));
481 ND_PRINT("\n\tLocation-ID ");
482 for (idx
= 0; idx
< sizeof(oam_ptr
.oam_fm_loopback
->loopback_id
); idx
++) {
485 GET_BE_U_2(&oam_ptr
.oam_fm_loopback
->loopback_id
[idx
]));
488 ND_PRINT("\n\tSource-ID ");
489 for (idx
= 0; idx
< sizeof(oam_ptr
.oam_fm_loopback
->source_id
); idx
++) {
492 GET_BE_U_2(&oam_ptr
.oam_fm_loopback
->source_id
[idx
]));
497 case (OAM_CELLTYPE_FM
<< 4 | OAM_FM_FUNCTYPE_AIS
):
498 case (OAM_CELLTYPE_FM
<< 4 | OAM_FM_FUNCTYPE_RDI
):
499 oam_ptr
.oam_fm_ais_rdi
= (const struct oam_fm_ais_rdi_t
*)(p
+ OAM_CELLTYPE_FUNCTYPE_LEN
);
500 ND_TCHECK_SIZE(oam_ptr
.oam_fm_ais_rdi
);
501 ND_PRINT("\n\tFailure-type 0x%02x",
502 GET_U_1(oam_ptr
.oam_fm_ais_rdi
->failure_type
));
503 ND_PRINT("\n\tLocation-ID ");
504 for (idx
= 0; idx
< sizeof(oam_ptr
.oam_fm_ais_rdi
->failure_location
); idx
++) {
507 GET_BE_U_2(&oam_ptr
.oam_fm_ais_rdi
->failure_location
[idx
]));
512 case (OAM_CELLTYPE_FM
<< 4 | OAM_FM_FUNCTYPE_CONTCHECK
):
520 /* crc10 checksum verification */
521 cksum
= GET_BE_U_2(p
+ OAM_CELLTYPE_FUNCTYPE_LEN
+ OAM_FUNCTION_SPECIFIC_LEN
)
523 cksum_shouldbe
= verify_crc10_cksum(0, p
, OAM_PAYLOAD_LEN
);
525 ND_PRINT("\n\tcksum 0x%03x (%scorrect)",
527 cksum_shouldbe
== 0 ? "" : "in");