1 /*
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
23 /* \summary: ATM LANE printer */
24
25 #include <config.h>
26
27 #include "netdissect-stdinc.h"
28
29 #define ND_LONGJMP_FROM_TCHECK
30 #include "netdissect.h"
31 #include "extract.h"
32
33 struct lecdatahdr_8023 {
34 nd_uint16_t le_header;
35 nd_mac_addr h_dest;
36 nd_mac_addr h_source;
37 nd_uint16_t h_type;
38 };
39
40 struct lane_controlhdr {
41 nd_uint16_t lec_header;
42 nd_uint8_t lec_proto;
43 nd_uint8_t lec_vers;
44 nd_uint16_t lec_opcode;
45 };
46
47 static const struct tok lecop2str[] = {
48 { 0x0001, "configure request" },
49 { 0x0101, "configure response" },
50 { 0x0002, "join request" },
51 { 0x0102, "join response" },
52 { 0x0003, "ready query" },
53 { 0x0103, "ready indication" },
54 { 0x0004, "register request" },
55 { 0x0104, "register response" },
56 { 0x0005, "unregister request" },
57 { 0x0105, "unregister response" },
58 { 0x0006, "ARP request" },
59 { 0x0106, "ARP response" },
60 { 0x0007, "flush request" },
61 { 0x0107, "flush response" },
62 { 0x0008, "NARP request" },
63 { 0x0009, "topology request" },
64 { 0, NULL }
65 };
66
67 static void
lane_hdr_print(netdissect_options * ndo,const u_char * bp)68 lane_hdr_print(netdissect_options *ndo, const u_char *bp)
69 {
70 ND_PRINT("lecid:%x ", GET_BE_U_2(bp));
71 }
72
73 /*
74 * This assumes 802.3, not 802.5, LAN emulation.
75 */
76 void
lane_print(netdissect_options * ndo,const u_char * p,u_int length,u_int caplen)77 lane_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
78 {
79 const struct lane_controlhdr *lec;
80
81 ndo->ndo_protocol = "lane";
82
83 lec = (const struct lane_controlhdr *)p;
84 if (GET_BE_U_2(lec->lec_header) == 0xff00) {
85 /*
86 * LE Control.
87 */
88 ND_PRINT("lec: proto %x vers %x %s",
89 GET_U_1(lec->lec_proto),
90 GET_U_1(lec->lec_vers),
91 tok2str(lecop2str, "opcode-#%u", GET_BE_U_2(lec->lec_opcode)));
92 return;
93 }
94
95 /*
96 * Go past the LE header.
97 */
98 ND_TCHECK_2(p); /* Needed */
99 length -= 2;
100 caplen -= 2;
101 p += 2;
102
103 /*
104 * Now print the encapsulated frame, under the assumption
105 * that it's an Ethernet frame.
106 */
107 ether_print(ndo, p, length, caplen, lane_hdr_print, p - 2);
108 }
109