The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1994, 1995, 1996, 1997 |
| 3 | * The Regents of the University of California. All rights reserved. |
| 4 | * |
| 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 |
| 16 | * written permission. |
| 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. |
| 20 | */ |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 21 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 22 | /* \summary: Asynchronous Transfer Mode (ATM) printer */ |
| 23 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 24 | #ifdef HAVE_CONFIG_H |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 25 | #include <config.h> |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 26 | #endif |
| 27 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 28 | #include "netdissect-stdinc.h" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 29 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 30 | #define ND_LONGJMP_FROM_TCHECK |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 31 | #include "netdissect.h" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 32 | #include "extract.h" |
| 33 | #include "addrtoname.h" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 34 | #include "atm.h" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 35 | #include "llc.h" |
| 36 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 37 | /* start of the original atmuni31.h */ |
| 38 | |
| 39 | /* |
| 40 | * Copyright (c) 1997 Yen Yen Lim and North Dakota State University |
| 41 | * All rights reserved. |
| 42 | * |
| 43 | * Redistribution and use in source and binary forms, with or without |
| 44 | * modification, are permitted provided that the following conditions |
| 45 | * are met: |
| 46 | * 1. Redistributions of source code must retain the above copyright |
| 47 | * notice, this list of conditions and the following disclaimer. |
| 48 | * 2. Redistributions in binary form must reproduce the above copyright |
| 49 | * notice, this list of conditions and the following disclaimer in the |
| 50 | * documentation and/or other materials provided with the distribution. |
| 51 | * 3. All advertising materials mentioning features or use of this software |
| 52 | * must display the following acknowledgement: |
| 53 | * This product includes software developed by Yen Yen Lim and |
| 54 | North Dakota State University |
| 55 | * 4. The name of the author may not be used to endorse or promote products |
| 56 | * derived from this software without specific prior written permission. |
| 57 | * |
| 58 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 59 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 60 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 61 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, |
| 62 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 63 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 64 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 65 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 66 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| 67 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 68 | * POSSIBILITY OF SUCH DAMAGE. |
| 69 | */ |
| 70 | |
| 71 | /* Based on UNI3.1 standard by ATM Forum */ |
| 72 | |
| 73 | /* ATM traffic types based on VPI=0 and (the following VCI */ |
| 74 | #define VCI_PPC 0x05 /* Point-to-point signal msg */ |
| 75 | #define VCI_BCC 0x02 /* Broadcast signal msg */ |
| 76 | #define VCI_OAMF4SC 0x03 /* Segment OAM F4 flow cell */ |
| 77 | #define VCI_OAMF4EC 0x04 /* End-to-end OAM F4 flow cell */ |
| 78 | #define VCI_METAC 0x01 /* Meta signal msg */ |
| 79 | #define VCI_ILMIC 0x10 /* ILMI msg */ |
| 80 | |
| 81 | /* Q.2931 signalling messages */ |
| 82 | #define CALL_PROCEED 0x02 /* call proceeding */ |
| 83 | #define CONNECT 0x07 /* connect */ |
| 84 | #define CONNECT_ACK 0x0f /* connect_ack */ |
| 85 | #define SETUP 0x05 /* setup */ |
| 86 | #define RELEASE 0x4d /* release */ |
| 87 | #define RELEASE_DONE 0x5a /* release_done */ |
| 88 | #define RESTART 0x46 /* restart */ |
| 89 | #define RESTART_ACK 0x4e /* restart ack */ |
| 90 | #define STATUS 0x7d /* status */ |
| 91 | #define STATUS_ENQ 0x75 /* status ack */ |
| 92 | #define ADD_PARTY 0x80 /* add party */ |
| 93 | #define ADD_PARTY_ACK 0x81 /* add party ack */ |
| 94 | #define ADD_PARTY_REJ 0x82 /* add party rej */ |
| 95 | #define DROP_PARTY 0x83 /* drop party */ |
| 96 | #define DROP_PARTY_ACK 0x84 /* drop party ack */ |
| 97 | |
| 98 | /* Information Element Parameters in the signalling messages */ |
| 99 | #define CAUSE 0x08 /* cause */ |
| 100 | #define ENDPT_REF 0x54 /* endpoint reference */ |
| 101 | #define AAL_PARA 0x58 /* ATM adaptation layer parameters */ |
| 102 | #define TRAFF_DESCRIP 0x59 /* atm traffic descriptors */ |
| 103 | #define CONNECT_ID 0x5a /* connection identifier */ |
| 104 | #define QOS_PARA 0x5c /* quality of service parameters */ |
| 105 | #define B_HIGHER 0x5d /* broadband higher layer information */ |
| 106 | #define B_BEARER 0x5e /* broadband bearer capability */ |
| 107 | #define B_LOWER 0x5f /* broadband lower information */ |
| 108 | #define CALLING_PARTY 0x6c /* calling party number */ |
| 109 | #define CALLED_PARTY 0x70 /* called party nmber */ |
| 110 | |
| 111 | #define Q2931 0x09 |
| 112 | |
| 113 | /* Q.2931 signalling general messages format */ |
| 114 | #define PROTO_POS 0 /* offset of protocol discriminator */ |
| 115 | #define CALL_REF_POS 2 /* offset of call reference value */ |
| 116 | #define MSG_TYPE_POS 5 /* offset of message type */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 117 | #if 0 |
| 118 | #define MSG_LEN_POS 7 /* offset of message length */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 119 | #define IE_BEGIN_POS 9 /* offset of first information element */ |
| 120 | |
| 121 | /* format of signalling messages */ |
| 122 | #define TYPE_POS 0 |
| 123 | #define LEN_POS 2 |
| 124 | #define FIELD_BEGIN_POS 4 |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 125 | #endif |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 126 | |
| 127 | /* end of the original atmuni31.h */ |
| 128 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 129 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 130 | #define OAM_CRC10_MASK 0x3ff |
| 131 | #define OAM_PAYLOAD_LEN 48 |
| 132 | #define OAM_FUNCTION_SPECIFIC_LEN 45 /* this excludes crc10 and cell-type/function-type */ |
| 133 | #define OAM_CELLTYPE_FUNCTYPE_LEN 1 |
| 134 | |
| 135 | static const struct tok oam_f_values[] = { |
| 136 | { VCI_OAMF4SC, "OAM F4 (segment)" }, |
| 137 | { VCI_OAMF4EC, "OAM F4 (end)" }, |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 138 | { 0, NULL } |
| 139 | }; |
| 140 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 141 | static const struct tok atm_pty_values[] = { |
| 142 | { 0x0, "user data, uncongested, SDU 0" }, |
| 143 | { 0x1, "user data, uncongested, SDU 1" }, |
| 144 | { 0x2, "user data, congested, SDU 0" }, |
| 145 | { 0x3, "user data, congested, SDU 1" }, |
| 146 | { 0x4, "VCC OAM F5 flow segment" }, |
| 147 | { 0x5, "VCC OAM F5 flow end-to-end" }, |
| 148 | { 0x6, "Traffic Control and resource Mgmt" }, |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 149 | { 0, NULL } |
| 150 | }; |
| 151 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 152 | #define OAM_CELLTYPE_FM 0x1 |
| 153 | #define OAM_CELLTYPE_PM 0x2 |
| 154 | #define OAM_CELLTYPE_AD 0x8 |
| 155 | #define OAM_CELLTYPE_SM 0xf |
| 156 | |
| 157 | static const struct tok oam_celltype_values[] = { |
| 158 | { OAM_CELLTYPE_FM, "Fault Management" }, |
| 159 | { OAM_CELLTYPE_PM, "Performance Management" }, |
| 160 | { OAM_CELLTYPE_AD, "activate/deactivate" }, |
| 161 | { OAM_CELLTYPE_SM, "System Management" }, |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 162 | { 0, NULL } |
| 163 | }; |
| 164 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 165 | #define OAM_FM_FUNCTYPE_AIS 0x0 |
| 166 | #define OAM_FM_FUNCTYPE_RDI 0x1 |
| 167 | #define OAM_FM_FUNCTYPE_CONTCHECK 0x4 |
| 168 | #define OAM_FM_FUNCTYPE_LOOPBACK 0x8 |
| 169 | |
| 170 | static const struct tok oam_fm_functype_values[] = { |
| 171 | { OAM_FM_FUNCTYPE_AIS, "AIS" }, |
| 172 | { OAM_FM_FUNCTYPE_RDI, "RDI" }, |
| 173 | { OAM_FM_FUNCTYPE_CONTCHECK, "Continuity Check" }, |
| 174 | { OAM_FM_FUNCTYPE_LOOPBACK, "Loopback" }, |
| 175 | { 0, NULL } |
| 176 | }; |
| 177 | |
| 178 | static const struct tok oam_pm_functype_values[] = { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 179 | { 0x0, "Forward Monitoring" }, |
| 180 | { 0x1, "Backward Reporting" }, |
| 181 | { 0x2, "Monitoring and Reporting" }, |
| 182 | { 0, NULL } |
| 183 | }; |
| 184 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 185 | static const struct tok oam_ad_functype_values[] = { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 186 | { 0x0, "Performance Monitoring" }, |
| 187 | { 0x1, "Continuity Check" }, |
| 188 | { 0, NULL } |
| 189 | }; |
| 190 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 191 | #define OAM_FM_LOOPBACK_INDICATOR_MASK 0x1 |
| 192 | |
| 193 | static const struct tok oam_fm_loopback_indicator_values[] = { |
| 194 | { 0x0, "Reply" }, |
| 195 | { 0x1, "Request" }, |
| 196 | { 0, NULL } |
| 197 | }; |
| 198 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 199 | static const struct uint_tokary oam_celltype2tokary[] = { |
| 200 | { OAM_CELLTYPE_FM, oam_fm_functype_values }, |
| 201 | { OAM_CELLTYPE_PM, oam_pm_functype_values }, |
| 202 | { OAM_CELLTYPE_AD, oam_ad_functype_values }, |
| 203 | /* uint2tokary() does not use array termination. */ |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 204 | }; |
| 205 | |
| 206 | /* |
| 207 | * Print an RFC 1483 LLC-encapsulated ATM frame. |
| 208 | */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 209 | static u_int |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 210 | atm_llc_print(netdissect_options *ndo, |
| 211 | const u_char *p, int length, int caplen) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 212 | { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 213 | int llc_hdrlen; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 214 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 215 | llc_hdrlen = llc_print(ndo, p, length, caplen, NULL, NULL); |
| 216 | if (llc_hdrlen < 0) { |
| 217 | /* packet not known, print raw packet */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 218 | if (!ndo->ndo_suppress_default_print) |
| 219 | ND_DEFAULTPRINT(p, caplen); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 220 | llc_hdrlen = -llc_hdrlen; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 221 | } |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 222 | return (llc_hdrlen); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | /* |
| 226 | * Given a SAP value, generate the LLC header value for a UI packet |
| 227 | * with that SAP as the source and destination SAP. |
| 228 | */ |
| 229 | #define LLC_UI_HDR(sap) ((sap)<<16 | (sap<<8) | 0x03) |
| 230 | |
| 231 | /* |
| 232 | * This is the top level routine of the printer. 'p' points |
| 233 | * to the LLC/SNAP header of the packet, 'h->ts' is the timestamp, |
| 234 | * 'h->len' is the length of the packet off the wire, and 'h->caplen' |
| 235 | * is the number of bytes actually captured. |
| 236 | */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 237 | void |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 238 | atm_if_print(netdissect_options *ndo, |
| 239 | const struct pcap_pkthdr *h, const u_char *p) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 240 | { |
| 241 | u_int caplen = h->caplen; |
| 242 | u_int length = h->len; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 243 | uint32_t llchdr; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 244 | u_int hdrlen = 0; |
| 245 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 246 | ndo->ndo_protocol = "atm"; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 247 | |
| 248 | /* Cisco Style NLPID ? */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 249 | if (GET_U_1(p) == LLC_UI) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 250 | if (ndo->ndo_eflag) |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 251 | ND_PRINT("CNLPID "); |
| 252 | ndo->ndo_ll_hdr_len += 1; |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 253 | isoclns_print(ndo, p + 1, length - 1); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 254 | return; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | /* |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 258 | * Must have at least a DSAP, an SSAP, and the first byte of the |
| 259 | * control field. |
| 260 | */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 261 | |
| 262 | /* |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 263 | * Extract the presumed LLC header into a variable, for quick |
| 264 | * testing. |
| 265 | * Then check for a header that's neither a header for a SNAP |
| 266 | * packet nor an RFC 2684 routed NLPID-formatted PDU nor |
| 267 | * an 802.2-but-no-SNAP IP packet. |
| 268 | */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 269 | llchdr = GET_BE_U_3(p); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 270 | if (llchdr != LLC_UI_HDR(LLCSAP_SNAP) && |
| 271 | llchdr != LLC_UI_HDR(LLCSAP_ISONS) && |
| 272 | llchdr != LLC_UI_HDR(LLCSAP_IP)) { |
| 273 | /* |
| 274 | * XXX - assume 802.6 MAC header from Fore driver. |
| 275 | * |
| 276 | * Unfortunately, the above list doesn't check for |
| 277 | * all known SAPs, doesn't check for headers where |
| 278 | * the source and destination SAP aren't the same, |
| 279 | * and doesn't check for non-UI frames. It also |
| 280 | * runs the risk of an 802.6 MAC header that happens |
| 281 | * to begin with one of those values being |
| 282 | * incorrectly treated as an 802.2 header. |
| 283 | * |
| 284 | * So is that Fore driver still around? And, if so, |
| 285 | * is it still putting 802.6 MAC headers on ATM |
| 286 | * packets? If so, could it be changed to use a |
| 287 | * new DLT_IEEE802_6 value if we added it? |
| 288 | */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 289 | if (ndo->ndo_eflag) |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 290 | ND_PRINT("%08x%08x %08x%08x ", |
| 291 | GET_BE_U_4(p), |
| 292 | GET_BE_U_4(p + 4), |
| 293 | GET_BE_U_4(p + 8), |
| 294 | GET_BE_U_4(p + 12)); |
| 295 | /* Always cover the full header. */ |
| 296 | ND_TCHECK_LEN(p, 20); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 297 | p += 20; |
| 298 | length -= 20; |
| 299 | caplen -= 20; |
| 300 | hdrlen += 20; |
| 301 | } |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 302 | ndo->ndo_ll_hdr_len += hdrlen; |
| 303 | ndo->ndo_ll_hdr_len += atm_llc_print(ndo, p, length, caplen); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | /* |
| 307 | * ATM signalling. |
| 308 | */ |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 309 | static const struct tok msgtype2str[] = { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 310 | { CALL_PROCEED, "Call_proceeding" }, |
| 311 | { CONNECT, "Connect" }, |
| 312 | { CONNECT_ACK, "Connect_ack" }, |
| 313 | { SETUP, "Setup" }, |
| 314 | { RELEASE, "Release" }, |
| 315 | { RELEASE_DONE, "Release_complete" }, |
| 316 | { RESTART, "Restart" }, |
| 317 | { RESTART_ACK, "Restart_ack" }, |
| 318 | { STATUS, "Status" }, |
| 319 | { STATUS_ENQ, "Status_enquiry" }, |
| 320 | { ADD_PARTY, "Add_party" }, |
| 321 | { ADD_PARTY_ACK, "Add_party_ack" }, |
| 322 | { ADD_PARTY_REJ, "Add_party_reject" }, |
| 323 | { DROP_PARTY, "Drop_party" }, |
| 324 | { DROP_PARTY_ACK, "Drop_party_ack" }, |
| 325 | { 0, NULL } |
| 326 | }; |
| 327 | |
| 328 | static void |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 329 | sig_print(netdissect_options *ndo, |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 330 | const u_char *p) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 331 | { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 332 | uint32_t call_ref; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 333 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 334 | if (GET_U_1(p + PROTO_POS) == Q2931) { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 335 | /* |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 336 | * protocol:Q.2931 for User to Network Interface |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 337 | * (UNI 3.1) signalling |
| 338 | */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 339 | ND_PRINT("Q.2931"); |
| 340 | ND_PRINT(":%s ", |
| 341 | tok2str(msgtype2str, "msgtype#%u", GET_U_1(p + MSG_TYPE_POS))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 342 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 343 | /* |
| 344 | * The call reference comes before the message type, |
| 345 | * so if we know we have the message type, which we |
| 346 | * do from the caplen test above, we also know we have |
| 347 | * the call reference. |
| 348 | */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 349 | call_ref = GET_BE_U_3(p + CALL_REF_POS); |
| 350 | ND_PRINT("CALL_REF:0x%06x", call_ref); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 351 | } else { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 352 | /* SSCOP with some unknown protocol atop it */ |
| 353 | ND_PRINT("SSCOP, proto %u ", GET_U_1(p + PROTO_POS)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 354 | } |
| 355 | } |
| 356 | |
| 357 | /* |
| 358 | * Print an ATM PDU (such as an AAL5 PDU). |
| 359 | */ |
| 360 | void |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 361 | atm_print(netdissect_options *ndo, |
| 362 | u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length, |
| 363 | u_int caplen) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 364 | { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 365 | ndo->ndo_protocol = "atm"; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 366 | if (ndo->ndo_eflag) |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 367 | ND_PRINT("VPI:%u VCI:%u ", vpi, vci); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 368 | |
| 369 | if (vpi == 0) { |
| 370 | switch (vci) { |
| 371 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 372 | case VCI_PPC: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 373 | sig_print(ndo, p); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 374 | return; |
| 375 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 376 | case VCI_BCC: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 377 | ND_PRINT("broadcast sig: "); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 378 | return; |
| 379 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 380 | case VCI_OAMF4SC: /* fall through */ |
| 381 | case VCI_OAMF4EC: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 382 | oam_print(ndo, p, length, ATM_OAM_HEC); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 383 | return; |
| 384 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 385 | case VCI_METAC: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 386 | ND_PRINT("meta: "); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 387 | return; |
| 388 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 389 | case VCI_ILMIC: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 390 | ND_PRINT("ilmi: "); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 391 | snmp_print(ndo, p, length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 392 | return; |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | switch (traftype) { |
| 397 | |
| 398 | case ATM_LLC: |
| 399 | default: |
| 400 | /* |
| 401 | * Assumes traffic is LLC if unknown. |
| 402 | */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 403 | atm_llc_print(ndo, p, length, caplen); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 404 | break; |
| 405 | |
| 406 | case ATM_LANE: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 407 | lane_print(ndo, p, length, caplen); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 408 | break; |
| 409 | } |
| 410 | } |
| 411 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 412 | struct oam_fm_loopback_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 413 | nd_uint8_t loopback_indicator; |
| 414 | nd_uint32_t correlation_tag; |
| 415 | nd_byte loopback_id[12]; |
| 416 | nd_byte source_id[12]; |
| 417 | nd_byte unused[16]; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 418 | }; |
| 419 | |
| 420 | struct oam_fm_ais_rdi_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 421 | nd_uint8_t failure_type; |
| 422 | nd_byte failure_location[16]; |
| 423 | nd_byte unused[28]; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 424 | }; |
| 425 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 426 | void |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 427 | oam_print(netdissect_options *ndo, |
| 428 | const u_char *p, u_int length, u_int hec) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 429 | { |
| 430 | uint32_t cell_header; |
| 431 | uint16_t vpi, vci, cksum, cksum_shouldbe, idx; |
| 432 | uint8_t cell_type, func_type, payload, clp; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 433 | const struct tok *oam_functype_str; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 434 | |
| 435 | union { |
| 436 | const struct oam_fm_loopback_t *oam_fm_loopback; |
| 437 | const struct oam_fm_ais_rdi_t *oam_fm_ais_rdi; |
| 438 | } oam_ptr; |
| 439 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 440 | ndo->ndo_protocol = "oam"; |
| 441 | cell_header = GET_BE_U_4(p + hec); |
| 442 | cell_type = (GET_U_1((p + ATM_HDR_LEN_NOHEC + hec)) >> 4) & 0x0f; |
| 443 | func_type = GET_U_1((p + ATM_HDR_LEN_NOHEC + hec)) & 0x0f; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 444 | |
| 445 | vpi = (cell_header>>20)&0xff; |
| 446 | vci = (cell_header>>4)&0xffff; |
| 447 | payload = (cell_header>>1)&0x7; |
| 448 | clp = cell_header&0x1; |
| 449 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 450 | ND_PRINT("%s, vpi %u, vci %u, payload [ %s ], clp %u, length %u", |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 451 | tok2str(oam_f_values, "OAM F5", vci), |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 452 | vpi, vci, |
| 453 | tok2str(atm_pty_values, "Unknown", payload), |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 454 | clp, length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 455 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 456 | if (!ndo->ndo_vflag) { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 457 | return; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 458 | } |
| 459 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 460 | ND_PRINT("\n\tcell-type %s (%u)", |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 461 | tok2str(oam_celltype_values, "unknown", cell_type), |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 462 | cell_type); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 463 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 464 | oam_functype_str = uint2tokary(oam_celltype2tokary, cell_type); |
| 465 | if (oam_functype_str == NULL) |
| 466 | ND_PRINT(", func-type unknown (%u)", func_type); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 467 | else |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 468 | ND_PRINT(", func-type %s (%u)", |
| 469 | tok2str(oam_functype_str, "none", func_type), |
| 470 | func_type); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 471 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 472 | p += ATM_HDR_LEN_NOHEC + hec; |
| 473 | |
| 474 | switch (cell_type << 4 | func_type) { |
| 475 | case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_LOOPBACK): |
| 476 | oam_ptr.oam_fm_loopback = (const struct oam_fm_loopback_t *)(p + OAM_CELLTYPE_FUNCTYPE_LEN); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 477 | ND_TCHECK_SIZE(oam_ptr.oam_fm_loopback); |
| 478 | ND_PRINT("\n\tLoopback-Indicator %s, Correlation-Tag 0x%08x", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 479 | tok2str(oam_fm_loopback_indicator_values, |
| 480 | "Unknown", |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 481 | GET_U_1(oam_ptr.oam_fm_loopback->loopback_indicator) & OAM_FM_LOOPBACK_INDICATOR_MASK), |
| 482 | GET_BE_U_4(oam_ptr.oam_fm_loopback->correlation_tag)); |
| 483 | ND_PRINT("\n\tLocation-ID "); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 484 | for (idx = 0; idx < sizeof(oam_ptr.oam_fm_loopback->loopback_id); idx++) { |
| 485 | if (idx % 2) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 486 | ND_PRINT("%04x ", |
| 487 | GET_BE_U_2(&oam_ptr.oam_fm_loopback->loopback_id[idx])); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 488 | } |
| 489 | } |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 490 | ND_PRINT("\n\tSource-ID "); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 491 | for (idx = 0; idx < sizeof(oam_ptr.oam_fm_loopback->source_id); idx++) { |
| 492 | if (idx % 2) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 493 | ND_PRINT("%04x ", |
| 494 | GET_BE_U_2(&oam_ptr.oam_fm_loopback->source_id[idx])); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 495 | } |
| 496 | } |
| 497 | break; |
| 498 | |
| 499 | case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_AIS): |
| 500 | case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_RDI): |
| 501 | oam_ptr.oam_fm_ais_rdi = (const struct oam_fm_ais_rdi_t *)(p + OAM_CELLTYPE_FUNCTYPE_LEN); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 502 | ND_TCHECK_SIZE(oam_ptr.oam_fm_ais_rdi); |
| 503 | ND_PRINT("\n\tFailure-type 0x%02x", |
| 504 | GET_U_1(oam_ptr.oam_fm_ais_rdi->failure_type)); |
| 505 | ND_PRINT("\n\tLocation-ID "); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 506 | for (idx = 0; idx < sizeof(oam_ptr.oam_fm_ais_rdi->failure_location); idx++) { |
| 507 | if (idx % 2) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 508 | ND_PRINT("%04x ", |
| 509 | GET_BE_U_2(&oam_ptr.oam_fm_ais_rdi->failure_location[idx])); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 510 | } |
| 511 | } |
| 512 | break; |
| 513 | |
| 514 | case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_CONTCHECK): |
| 515 | /* FIXME */ |
| 516 | break; |
| 517 | |
| 518 | default: |
| 519 | break; |
| 520 | } |
| 521 | |
| 522 | /* crc10 checksum verification */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 523 | cksum = GET_BE_U_2(p + OAM_CELLTYPE_FUNCTYPE_LEN + OAM_FUNCTION_SPECIFIC_LEN) |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 524 | & OAM_CRC10_MASK; |
| 525 | cksum_shouldbe = verify_crc10_cksum(0, p, OAM_PAYLOAD_LEN); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 526 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 527 | ND_PRINT("\n\tcksum 0x%03x (%scorrect)", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 528 | cksum, |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 529 | cksum_shouldbe == 0 ? "" : "in"); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 530 | } |