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