blob: c5fa33beb4a8c3496e0164021bc14d62de23d486 [file] [log] [blame]
The Android Open Source Project2949f582009-03-03 19:30:46 -08001/*
2 * Marko Kiiskila carnil@cs.tut.fi
3 *
4 * Tampere University of Technology - Telecommunications Laboratory
5 *
6 * Permission to use, copy, modify and distribute this
7 * software and its documentation is hereby granted,
8 * provided that both the copyright notice and this
9 * permission notice appear in all copies of the software,
10 * derivative works or modified versions, and any portions
11 * thereof, that both notices appear in supporting
12 * documentation, and that the use of this software is
13 * acknowledged in any publications resulting from using
14 * the software.
15 *
16 * TUT ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17 * CONDITION AND DISCLAIMS ANY LIABILITY OF ANY KIND FOR
18 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS
19 * SOFTWARE.
20 *
21 */
22
Elliott Hughese2e3bd12017-05-15 10:59:29 -070023/* \summary: ATM LANE printer */
24
The Android Open Source Project2949f582009-03-03 19:30:46 -080025#ifdef HAVE_CONFIG_H
Elliott Hughes820eced2021-08-20 18:00:50 -070026#include <config.h>
The Android Open Source Project2949f582009-03-03 19:30:46 -080027#endif
28
Elliott Hughes820eced2021-08-20 18:00:50 -070029#include "netdissect-stdinc.h"
The Android Open Source Project2949f582009-03-03 19:30:46 -080030
Elliott Hughes820eced2021-08-20 18:00:50 -070031#define ND_LONGJMP_FROM_TCHECK
Elliott Hughese2e3bd12017-05-15 10:59:29 -070032#include "netdissect.h"
The Android Open Source Project2949f582009-03-03 19:30:46 -080033#include "extract.h"
Elliott Hughes892a68b2015-10-19 14:43:53 -070034
35struct lecdatahdr_8023 {
Elliott Hughes820eced2021-08-20 18:00:50 -070036 nd_uint16_t le_header;
37 nd_mac_addr h_dest;
38 nd_mac_addr h_source;
39 nd_uint16_t h_type;
Elliott Hughes892a68b2015-10-19 14:43:53 -070040};
41
42struct lane_controlhdr {
Elliott Hughes820eced2021-08-20 18:00:50 -070043 nd_uint16_t lec_header;
44 nd_uint8_t lec_proto;
45 nd_uint8_t lec_vers;
46 nd_uint16_t lec_opcode;
Elliott Hughes892a68b2015-10-19 14:43:53 -070047};
The Android Open Source Project2949f582009-03-03 19:30:46 -080048
49static const struct tok lecop2str[] = {
50 { 0x0001, "configure request" },
51 { 0x0101, "configure response" },
52 { 0x0002, "join request" },
53 { 0x0102, "join response" },
54 { 0x0003, "ready query" },
55 { 0x0103, "ready indication" },
56 { 0x0004, "register request" },
57 { 0x0104, "register response" },
58 { 0x0005, "unregister request" },
59 { 0x0105, "unregister response" },
60 { 0x0006, "ARP request" },
61 { 0x0106, "ARP response" },
62 { 0x0007, "flush request" },
63 { 0x0107, "flush response" },
64 { 0x0008, "NARP request" },
65 { 0x0009, "topology request" },
66 { 0, NULL }
67};
68
JP Abgrall53f17a92014-02-12 14:02:41 -080069static void
70lane_hdr_print(netdissect_options *ndo, const u_char *bp)
The Android Open Source Project2949f582009-03-03 19:30:46 -080071{
Elliott Hughes820eced2021-08-20 18:00:50 -070072 ND_PRINT("lecid:%x ", GET_BE_U_2(bp));
The Android Open Source Project2949f582009-03-03 19:30:46 -080073}
74
75/*
The Android Open Source Project2949f582009-03-03 19:30:46 -080076 * This assumes 802.3, not 802.5, LAN emulation.
77 */
78void
Elliott Hughes892a68b2015-10-19 14:43:53 -070079lane_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
The Android Open Source Project2949f582009-03-03 19:30:46 -080080{
Elliott Hughese2e3bd12017-05-15 10:59:29 -070081 const struct lane_controlhdr *lec;
The Android Open Source Project2949f582009-03-03 19:30:46 -080082
Elliott Hughes820eced2021-08-20 18:00:50 -070083 ndo->ndo_protocol = "lane";
The Android Open Source Project2949f582009-03-03 19:30:46 -080084
Elliott Hughese2e3bd12017-05-15 10:59:29 -070085 lec = (const struct lane_controlhdr *)p;
Elliott Hughes820eced2021-08-20 18:00:50 -070086 if (GET_BE_U_2(lec->lec_header) == 0xff00) {
The Android Open Source Project2949f582009-03-03 19:30:46 -080087 /*
88 * LE Control.
89 */
Elliott Hughes820eced2021-08-20 18:00:50 -070090 ND_PRINT("lec: proto %x vers %x %s",
91 GET_U_1(lec->lec_proto),
92 GET_U_1(lec->lec_vers),
93 tok2str(lecop2str, "opcode-#%u", GET_BE_U_2(lec->lec_opcode)));
The Android Open Source Project2949f582009-03-03 19:30:46 -080094 return;
95 }
96
JP Abgrall53f17a92014-02-12 14:02:41 -080097 /*
98 * Go past the LE header.
99 */
Elliott Hughes820eced2021-08-20 18:00:50 -0700100 ND_TCHECK_2(p); /* Needed */
JP Abgrall53f17a92014-02-12 14:02:41 -0800101 length -= 2;
102 caplen -= 2;
103 p += 2;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800104
105 /*
JP Abgrall53f17a92014-02-12 14:02:41 -0800106 * Now print the encapsulated frame, under the assumption
107 * that it's an Ethernet frame.
The Android Open Source Project2949f582009-03-03 19:30:46 -0800108 */
Elliott Hughes892a68b2015-10-19 14:43:53 -0700109 ether_print(ndo, p, length, caplen, lane_hdr_print, p - 2);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800110}