| 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 | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 22 | #define NETDISSECT_REWORKED |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 23 | #ifdef HAVE_CONFIG_H |
| 24 | #include "config.h" |
| 25 | #endif |
| 26 | |
| 27 | #include <tcpdump-stdinc.h> |
| 28 | |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 29 | #include "interface.h" |
| 30 | #include "extract.h" |
| 31 | #include "addrtoname.h" |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 32 | #include "atm.h" |
| 33 | #include "atmuni31.h" |
| 34 | #include "llc.h" |
| 35 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 36 | static const char tstr[] = "[|atm]"; |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 37 | |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 38 | #define OAM_CRC10_MASK 0x3ff |
| 39 | #define OAM_PAYLOAD_LEN 48 |
| 40 | #define OAM_FUNCTION_SPECIFIC_LEN 45 /* this excludes crc10 and cell-type/function-type */ |
| 41 | #define OAM_CELLTYPE_FUNCTYPE_LEN 1 |
| 42 | |
| 43 | static const struct tok oam_f_values[] = { |
| 44 | { VCI_OAMF4SC, "OAM F4 (segment)" }, |
| 45 | { VCI_OAMF4EC, "OAM F4 (end)" }, |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 46 | { 0, NULL } |
| 47 | }; |
| 48 | |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 49 | static const struct tok atm_pty_values[] = { |
| 50 | { 0x0, "user data, uncongested, SDU 0" }, |
| 51 | { 0x1, "user data, uncongested, SDU 1" }, |
| 52 | { 0x2, "user data, congested, SDU 0" }, |
| 53 | { 0x3, "user data, congested, SDU 1" }, |
| 54 | { 0x4, "VCC OAM F5 flow segment" }, |
| 55 | { 0x5, "VCC OAM F5 flow end-to-end" }, |
| 56 | { 0x6, "Traffic Control and resource Mgmt" }, |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 57 | { 0, NULL } |
| 58 | }; |
| 59 | |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 60 | #define OAM_CELLTYPE_FM 0x1 |
| 61 | #define OAM_CELLTYPE_PM 0x2 |
| 62 | #define OAM_CELLTYPE_AD 0x8 |
| 63 | #define OAM_CELLTYPE_SM 0xf |
| 64 | |
| 65 | static const struct tok oam_celltype_values[] = { |
| 66 | { OAM_CELLTYPE_FM, "Fault Management" }, |
| 67 | { OAM_CELLTYPE_PM, "Performance Management" }, |
| 68 | { OAM_CELLTYPE_AD, "activate/deactivate" }, |
| 69 | { OAM_CELLTYPE_SM, "System Management" }, |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 70 | { 0, NULL } |
| 71 | }; |
| 72 | |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 73 | #define OAM_FM_FUNCTYPE_AIS 0x0 |
| 74 | #define OAM_FM_FUNCTYPE_RDI 0x1 |
| 75 | #define OAM_FM_FUNCTYPE_CONTCHECK 0x4 |
| 76 | #define OAM_FM_FUNCTYPE_LOOPBACK 0x8 |
| 77 | |
| 78 | static const struct tok oam_fm_functype_values[] = { |
| 79 | { OAM_FM_FUNCTYPE_AIS, "AIS" }, |
| 80 | { OAM_FM_FUNCTYPE_RDI, "RDI" }, |
| 81 | { OAM_FM_FUNCTYPE_CONTCHECK, "Continuity Check" }, |
| 82 | { OAM_FM_FUNCTYPE_LOOPBACK, "Loopback" }, |
| 83 | { 0, NULL } |
| 84 | }; |
| 85 | |
| 86 | static const struct tok oam_pm_functype_values[] = { |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 87 | { 0x0, "Forward Monitoring" }, |
| 88 | { 0x1, "Backward Reporting" }, |
| 89 | { 0x2, "Monitoring and Reporting" }, |
| 90 | { 0, NULL } |
| 91 | }; |
| 92 | |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 93 | static const struct tok oam_ad_functype_values[] = { |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 94 | { 0x0, "Performance Monitoring" }, |
| 95 | { 0x1, "Continuity Check" }, |
| 96 | { 0, NULL } |
| 97 | }; |
| 98 | |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 99 | #define OAM_FM_LOOPBACK_INDICATOR_MASK 0x1 |
| 100 | |
| 101 | static const struct tok oam_fm_loopback_indicator_values[] = { |
| 102 | { 0x0, "Reply" }, |
| 103 | { 0x1, "Request" }, |
| 104 | { 0, NULL } |
| 105 | }; |
| 106 | |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 107 | static const struct tok *oam_functype_values[16] = { |
| 108 | NULL, |
| 109 | oam_fm_functype_values, /* 1 */ |
| 110 | oam_pm_functype_values, /* 2 */ |
| 111 | NULL, |
| 112 | NULL, |
| 113 | NULL, |
| 114 | NULL, |
| 115 | NULL, |
| 116 | oam_ad_functype_values, /* 8 */ |
| 117 | NULL, |
| 118 | NULL, |
| 119 | NULL, |
| 120 | NULL, |
| 121 | NULL, |
| 122 | NULL, |
| 123 | NULL |
| 124 | }; |
| 125 | |
| 126 | /* |
| 127 | * Print an RFC 1483 LLC-encapsulated ATM frame. |
| 128 | */ |
| 129 | static void |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 130 | atm_llc_print(netdissect_options *ndo, |
| 131 | const u_char *p, int length, int caplen) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 132 | { |
| 133 | u_short extracted_ethertype; |
| 134 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 135 | if (!llc_print(ndo, p, length, caplen, NULL, NULL, |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 136 | &extracted_ethertype)) { |
| 137 | /* ether_type not known, print raw packet */ |
| 138 | if (extracted_ethertype) { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 139 | ND_PRINT((ndo, "(LLC %s) ", |
| 140 | etherproto_string(htons(extracted_ethertype)))); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 141 | } |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 142 | if (!ndo->ndo_suppress_default_print) |
| 143 | ND_DEFAULTPRINT(p, caplen); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 144 | } |
| 145 | } |
| 146 | |
| 147 | /* |
| 148 | * Given a SAP value, generate the LLC header value for a UI packet |
| 149 | * with that SAP as the source and destination SAP. |
| 150 | */ |
| 151 | #define LLC_UI_HDR(sap) ((sap)<<16 | (sap<<8) | 0x03) |
| 152 | |
| 153 | /* |
| 154 | * This is the top level routine of the printer. 'p' points |
| 155 | * to the LLC/SNAP header of the packet, 'h->ts' is the timestamp, |
| 156 | * 'h->len' is the length of the packet off the wire, and 'h->caplen' |
| 157 | * is the number of bytes actually captured. |
| 158 | */ |
| 159 | u_int |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 160 | atm_if_print(netdissect_options *ndo, |
| 161 | const struct pcap_pkthdr *h, const u_char *p) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 162 | { |
| 163 | u_int caplen = h->caplen; |
| 164 | u_int length = h->len; |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 165 | uint32_t llchdr; |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 166 | u_int hdrlen = 0; |
| 167 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 168 | if (caplen < 1 || length < 1) { |
| 169 | ND_PRINT((ndo, "%s", tstr)); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 170 | return (caplen); |
| 171 | } |
| 172 | |
| 173 | /* Cisco Style NLPID ? */ |
| 174 | if (*p == LLC_UI) { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 175 | if (ndo->ndo_eflag) |
| 176 | ND_PRINT((ndo, "CNLPID ")); |
| 177 | isoclns_print(ndo, p + 1, length - 1, caplen - 1); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 178 | return hdrlen; |
| 179 | } |
| 180 | |
| 181 | /* |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 182 | * Must have at least a DSAP, an SSAP, and the first byte of the |
| 183 | * control field. |
| 184 | */ |
| 185 | if (caplen < 3 || length < 3) { |
| 186 | ND_PRINT((ndo, "%s", tstr)); |
| 187 | return (caplen); |
| 188 | } |
| 189 | |
| 190 | /* |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 191 | * Extract the presumed LLC header into a variable, for quick |
| 192 | * testing. |
| 193 | * Then check for a header that's neither a header for a SNAP |
| 194 | * packet nor an RFC 2684 routed NLPID-formatted PDU nor |
| 195 | * an 802.2-but-no-SNAP IP packet. |
| 196 | */ |
| 197 | llchdr = EXTRACT_24BITS(p); |
| 198 | if (llchdr != LLC_UI_HDR(LLCSAP_SNAP) && |
| 199 | llchdr != LLC_UI_HDR(LLCSAP_ISONS) && |
| 200 | llchdr != LLC_UI_HDR(LLCSAP_IP)) { |
| 201 | /* |
| 202 | * XXX - assume 802.6 MAC header from Fore driver. |
| 203 | * |
| 204 | * Unfortunately, the above list doesn't check for |
| 205 | * all known SAPs, doesn't check for headers where |
| 206 | * the source and destination SAP aren't the same, |
| 207 | * and doesn't check for non-UI frames. It also |
| 208 | * runs the risk of an 802.6 MAC header that happens |
| 209 | * to begin with one of those values being |
| 210 | * incorrectly treated as an 802.2 header. |
| 211 | * |
| 212 | * So is that Fore driver still around? And, if so, |
| 213 | * is it still putting 802.6 MAC headers on ATM |
| 214 | * packets? If so, could it be changed to use a |
| 215 | * new DLT_IEEE802_6 value if we added it? |
| 216 | */ |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 217 | if (caplen < 20 || length < 20) { |
| 218 | ND_PRINT((ndo, "%s", tstr)); |
| 219 | return (caplen); |
| 220 | } |
| 221 | if (ndo->ndo_eflag) |
| 222 | ND_PRINT((ndo, "%08x%08x %08x%08x ", |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 223 | EXTRACT_32BITS(p), |
| 224 | EXTRACT_32BITS(p+4), |
| 225 | EXTRACT_32BITS(p+8), |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 226 | EXTRACT_32BITS(p+12))); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 227 | p += 20; |
| 228 | length -= 20; |
| 229 | caplen -= 20; |
| 230 | hdrlen += 20; |
| 231 | } |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 232 | atm_llc_print(ndo, p, length, caplen); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 233 | return (hdrlen); |
| 234 | } |
| 235 | |
| 236 | /* |
| 237 | * ATM signalling. |
| 238 | */ |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 239 | static const struct tok msgtype2str[] = { |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 240 | { CALL_PROCEED, "Call_proceeding" }, |
| 241 | { CONNECT, "Connect" }, |
| 242 | { CONNECT_ACK, "Connect_ack" }, |
| 243 | { SETUP, "Setup" }, |
| 244 | { RELEASE, "Release" }, |
| 245 | { RELEASE_DONE, "Release_complete" }, |
| 246 | { RESTART, "Restart" }, |
| 247 | { RESTART_ACK, "Restart_ack" }, |
| 248 | { STATUS, "Status" }, |
| 249 | { STATUS_ENQ, "Status_enquiry" }, |
| 250 | { ADD_PARTY, "Add_party" }, |
| 251 | { ADD_PARTY_ACK, "Add_party_ack" }, |
| 252 | { ADD_PARTY_REJ, "Add_party_reject" }, |
| 253 | { DROP_PARTY, "Drop_party" }, |
| 254 | { DROP_PARTY_ACK, "Drop_party_ack" }, |
| 255 | { 0, NULL } |
| 256 | }; |
| 257 | |
| 258 | static void |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 259 | sig_print(netdissect_options *ndo, |
| 260 | const u_char *p, int caplen) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 261 | { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 262 | uint32_t call_ref; |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 263 | |
| 264 | if (caplen < PROTO_POS) { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 265 | ND_PRINT((ndo, "%s", tstr)); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 266 | return; |
| 267 | } |
| 268 | if (p[PROTO_POS] == Q2931) { |
| 269 | /* |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 270 | * protocol:Q.2931 for User to Network Interface |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 271 | * (UNI 3.1) signalling |
| 272 | */ |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 273 | ND_PRINT((ndo, "Q.2931")); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 274 | if (caplen < MSG_TYPE_POS) { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 275 | ND_PRINT((ndo, " %s", tstr)); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 276 | return; |
| 277 | } |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 278 | ND_PRINT((ndo, ":%s ", |
| 279 | tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS]))); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 280 | |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 281 | /* |
| 282 | * The call reference comes before the message type, |
| 283 | * so if we know we have the message type, which we |
| 284 | * do from the caplen test above, we also know we have |
| 285 | * the call reference. |
| 286 | */ |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 287 | call_ref = EXTRACT_24BITS(&p[CALL_REF_POS]); |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 288 | ND_PRINT((ndo, "CALL_REF:0x%06x", call_ref)); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 289 | } else { |
| 290 | /* SCCOP with some unknown protocol atop it */ |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 291 | ND_PRINT((ndo, "SSCOP, proto %d ", p[PROTO_POS])); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 292 | } |
| 293 | } |
| 294 | |
| 295 | /* |
| 296 | * Print an ATM PDU (such as an AAL5 PDU). |
| 297 | */ |
| 298 | void |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 299 | atm_print(netdissect_options *ndo, |
| 300 | u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length, |
| 301 | u_int caplen) |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 302 | { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 303 | if (ndo->ndo_eflag) |
| 304 | ND_PRINT((ndo, "VPI:%u VCI:%u ", vpi, vci)); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 305 | |
| 306 | if (vpi == 0) { |
| 307 | switch (vci) { |
| 308 | |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 309 | case VCI_PPC: |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 310 | sig_print(ndo, p, caplen); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 311 | return; |
| 312 | |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 313 | case VCI_BCC: |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 314 | ND_PRINT((ndo, "broadcast sig: ")); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 315 | return; |
| 316 | |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 317 | case VCI_OAMF4SC: /* fall through */ |
| 318 | case VCI_OAMF4EC: |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 319 | oam_print(ndo, p, length, ATM_OAM_HEC); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 320 | return; |
| 321 | |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 322 | case VCI_METAC: |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 323 | ND_PRINT((ndo, "meta: ")); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 324 | return; |
| 325 | |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 326 | case VCI_ILMIC: |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 327 | ND_PRINT((ndo, "ilmi: ")); |
| 328 | snmp_print(ndo, p, length); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 329 | return; |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | switch (traftype) { |
| 334 | |
| 335 | case ATM_LLC: |
| 336 | default: |
| 337 | /* |
| 338 | * Assumes traffic is LLC if unknown. |
| 339 | */ |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 340 | atm_llc_print(ndo, p, length, caplen); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 341 | break; |
| 342 | |
| 343 | case ATM_LANE: |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 344 | lane_print(ndo, p, length, caplen); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 345 | break; |
| 346 | } |
| 347 | } |
| 348 | |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 349 | struct oam_fm_loopback_t { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 350 | uint8_t loopback_indicator; |
| 351 | uint8_t correlation_tag[4]; |
| 352 | uint8_t loopback_id[12]; |
| 353 | uint8_t source_id[12]; |
| 354 | uint8_t unused[16]; |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 355 | }; |
| 356 | |
| 357 | struct oam_fm_ais_rdi_t { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 358 | uint8_t failure_type; |
| 359 | uint8_t failure_location[16]; |
| 360 | uint8_t unused[28]; |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 361 | }; |
| 362 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 363 | int |
| 364 | oam_print (netdissect_options *ndo, |
| 365 | const u_char *p, u_int length, u_int hec) |
| 366 | { |
| 367 | uint32_t cell_header; |
| 368 | uint16_t vpi, vci, cksum, cksum_shouldbe, idx; |
| 369 | uint8_t cell_type, func_type, payload, clp; |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 370 | |
| 371 | union { |
| 372 | const struct oam_fm_loopback_t *oam_fm_loopback; |
| 373 | const struct oam_fm_ais_rdi_t *oam_fm_ais_rdi; |
| 374 | } oam_ptr; |
| 375 | |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 376 | |
| 377 | cell_header = EXTRACT_32BITS(p+hec); |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 378 | cell_type = ((*(p+ATM_HDR_LEN_NOHEC+hec))>>4) & 0x0f; |
| 379 | func_type = (*(p+ATM_HDR_LEN_NOHEC+hec)) & 0x0f; |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 380 | |
| 381 | vpi = (cell_header>>20)&0xff; |
| 382 | vci = (cell_header>>4)&0xffff; |
| 383 | payload = (cell_header>>1)&0x7; |
| 384 | clp = cell_header&0x1; |
| 385 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 386 | 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] | 387 | tok2str(oam_f_values, "OAM F5", vci), |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 388 | vpi, vci, |
| 389 | tok2str(atm_pty_values, "Unknown", payload), |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 390 | clp, length)); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 391 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 392 | if (!ndo->ndo_vflag) { |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 393 | return 1; |
| 394 | } |
| 395 | |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 396 | ND_PRINT((ndo, "\n\tcell-type %s (%u)", |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 397 | tok2str(oam_celltype_values, "unknown", cell_type), |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 398 | cell_type)); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 399 | |
| 400 | if (oam_functype_values[cell_type] == NULL) |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 401 | ND_PRINT((ndo, ", func-type unknown (%u)", func_type)); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 402 | else |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 403 | ND_PRINT((ndo, ", func-type %s (%u)", |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 404 | tok2str(oam_functype_values[cell_type],"none",func_type), |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 405 | func_type)); |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 406 | |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 407 | p += ATM_HDR_LEN_NOHEC + hec; |
| 408 | |
| 409 | switch (cell_type << 4 | func_type) { |
| 410 | case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_LOOPBACK): |
| 411 | oam_ptr.oam_fm_loopback = (const struct oam_fm_loopback_t *)(p + OAM_CELLTYPE_FUNCTYPE_LEN); |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 412 | ND_PRINT((ndo, "\n\tLoopback-Indicator %s, Correlation-Tag 0x%08x", |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 413 | tok2str(oam_fm_loopback_indicator_values, |
| 414 | "Unknown", |
| 415 | oam_ptr.oam_fm_loopback->loopback_indicator & OAM_FM_LOOPBACK_INDICATOR_MASK), |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 416 | EXTRACT_32BITS(&oam_ptr.oam_fm_loopback->correlation_tag))); |
| 417 | ND_PRINT((ndo, "\n\tLocation-ID ")); |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 418 | for (idx = 0; idx < sizeof(oam_ptr.oam_fm_loopback->loopback_id); idx++) { |
| 419 | if (idx % 2) { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 420 | 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] | 421 | } |
| 422 | } |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 423 | ND_PRINT((ndo, "\n\tSource-ID ")); |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 424 | for (idx = 0; idx < sizeof(oam_ptr.oam_fm_loopback->source_id); idx++) { |
| 425 | if (idx % 2) { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 426 | 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] | 427 | } |
| 428 | } |
| 429 | break; |
| 430 | |
| 431 | case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_AIS): |
| 432 | case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_RDI): |
| 433 | oam_ptr.oam_fm_ais_rdi = (const struct oam_fm_ais_rdi_t *)(p + OAM_CELLTYPE_FUNCTYPE_LEN); |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 434 | ND_PRINT((ndo, "\n\tFailure-type 0x%02x", oam_ptr.oam_fm_ais_rdi->failure_type)); |
| 435 | ND_PRINT((ndo, "\n\tLocation-ID ")); |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 436 | for (idx = 0; idx < sizeof(oam_ptr.oam_fm_ais_rdi->failure_location); idx++) { |
| 437 | if (idx % 2) { |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 438 | 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] | 439 | } |
| 440 | } |
| 441 | break; |
| 442 | |
| 443 | case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_CONTCHECK): |
| 444 | /* FIXME */ |
| 445 | break; |
| 446 | |
| 447 | default: |
| 448 | break; |
| 449 | } |
| 450 | |
| 451 | /* crc10 checksum verification */ |
| 452 | cksum = EXTRACT_16BITS(p + OAM_CELLTYPE_FUNCTYPE_LEN + OAM_FUNCTION_SPECIFIC_LEN) |
| 453 | & OAM_CRC10_MASK; |
| 454 | cksum_shouldbe = verify_crc10_cksum(0, p, OAM_PAYLOAD_LEN); |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 455 | |
| 456 | ND_PRINT((ndo, "\n\tcksum 0x%03x (%scorrect)", |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 457 | cksum, |
| Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 458 | cksum_shouldbe == 0 ? "" : "in")); |
| JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 459 | |
| The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 460 | return 1; |
| 461 | } |