1*05b00f60SXin Li /*
2*05b00f60SXin Li * Marko Kiiskila [email protected]
3*05b00f60SXin Li *
4*05b00f60SXin Li * Tampere University of Technology - Telecommunications Laboratory
5*05b00f60SXin Li *
6*05b00f60SXin Li * Permission to use, copy, modify and distribute this
7*05b00f60SXin Li * software and its documentation is hereby granted,
8*05b00f60SXin Li * provided that both the copyright notice and this
9*05b00f60SXin Li * permission notice appear in all copies of the software,
10*05b00f60SXin Li * derivative works or modified versions, and any portions
11*05b00f60SXin Li * thereof, that both notices appear in supporting
12*05b00f60SXin Li * documentation, and that the use of this software is
13*05b00f60SXin Li * acknowledged in any publications resulting from using
14*05b00f60SXin Li * the software.
15*05b00f60SXin Li *
16*05b00f60SXin Li * TUT ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17*05b00f60SXin Li * CONDITION AND DISCLAIMS ANY LIABILITY OF ANY KIND FOR
18*05b00f60SXin Li * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS
19*05b00f60SXin Li * SOFTWARE.
20*05b00f60SXin Li *
21*05b00f60SXin Li */
22*05b00f60SXin Li
23*05b00f60SXin Li /* \summary: ATM LANE printer */
24*05b00f60SXin Li
25*05b00f60SXin Li #ifdef HAVE_CONFIG_H
26*05b00f60SXin Li #include <config.h>
27*05b00f60SXin Li #endif
28*05b00f60SXin Li
29*05b00f60SXin Li #include "netdissect-stdinc.h"
30*05b00f60SXin Li
31*05b00f60SXin Li #define ND_LONGJMP_FROM_TCHECK
32*05b00f60SXin Li #include "netdissect.h"
33*05b00f60SXin Li #include "extract.h"
34*05b00f60SXin Li
35*05b00f60SXin Li struct lecdatahdr_8023 {
36*05b00f60SXin Li nd_uint16_t le_header;
37*05b00f60SXin Li nd_mac_addr h_dest;
38*05b00f60SXin Li nd_mac_addr h_source;
39*05b00f60SXin Li nd_uint16_t h_type;
40*05b00f60SXin Li };
41*05b00f60SXin Li
42*05b00f60SXin Li struct lane_controlhdr {
43*05b00f60SXin Li nd_uint16_t lec_header;
44*05b00f60SXin Li nd_uint8_t lec_proto;
45*05b00f60SXin Li nd_uint8_t lec_vers;
46*05b00f60SXin Li nd_uint16_t lec_opcode;
47*05b00f60SXin Li };
48*05b00f60SXin Li
49*05b00f60SXin Li static const struct tok lecop2str[] = {
50*05b00f60SXin Li { 0x0001, "configure request" },
51*05b00f60SXin Li { 0x0101, "configure response" },
52*05b00f60SXin Li { 0x0002, "join request" },
53*05b00f60SXin Li { 0x0102, "join response" },
54*05b00f60SXin Li { 0x0003, "ready query" },
55*05b00f60SXin Li { 0x0103, "ready indication" },
56*05b00f60SXin Li { 0x0004, "register request" },
57*05b00f60SXin Li { 0x0104, "register response" },
58*05b00f60SXin Li { 0x0005, "unregister request" },
59*05b00f60SXin Li { 0x0105, "unregister response" },
60*05b00f60SXin Li { 0x0006, "ARP request" },
61*05b00f60SXin Li { 0x0106, "ARP response" },
62*05b00f60SXin Li { 0x0007, "flush request" },
63*05b00f60SXin Li { 0x0107, "flush response" },
64*05b00f60SXin Li { 0x0008, "NARP request" },
65*05b00f60SXin Li { 0x0009, "topology request" },
66*05b00f60SXin Li { 0, NULL }
67*05b00f60SXin Li };
68*05b00f60SXin Li
69*05b00f60SXin Li static void
lane_hdr_print(netdissect_options * ndo,const u_char * bp)70*05b00f60SXin Li lane_hdr_print(netdissect_options *ndo, const u_char *bp)
71*05b00f60SXin Li {
72*05b00f60SXin Li ND_PRINT("lecid:%x ", GET_BE_U_2(bp));
73*05b00f60SXin Li }
74*05b00f60SXin Li
75*05b00f60SXin Li /*
76*05b00f60SXin Li * This assumes 802.3, not 802.5, LAN emulation.
77*05b00f60SXin Li */
78*05b00f60SXin Li void
lane_print(netdissect_options * ndo,const u_char * p,u_int length,u_int caplen)79*05b00f60SXin Li lane_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
80*05b00f60SXin Li {
81*05b00f60SXin Li const struct lane_controlhdr *lec;
82*05b00f60SXin Li
83*05b00f60SXin Li ndo->ndo_protocol = "lane";
84*05b00f60SXin Li
85*05b00f60SXin Li lec = (const struct lane_controlhdr *)p;
86*05b00f60SXin Li if (GET_BE_U_2(lec->lec_header) == 0xff00) {
87*05b00f60SXin Li /*
88*05b00f60SXin Li * LE Control.
89*05b00f60SXin Li */
90*05b00f60SXin Li ND_PRINT("lec: proto %x vers %x %s",
91*05b00f60SXin Li GET_U_1(lec->lec_proto),
92*05b00f60SXin Li GET_U_1(lec->lec_vers),
93*05b00f60SXin Li tok2str(lecop2str, "opcode-#%u", GET_BE_U_2(lec->lec_opcode)));
94*05b00f60SXin Li return;
95*05b00f60SXin Li }
96*05b00f60SXin Li
97*05b00f60SXin Li /*
98*05b00f60SXin Li * Go past the LE header.
99*05b00f60SXin Li */
100*05b00f60SXin Li ND_TCHECK_2(p); /* Needed */
101*05b00f60SXin Li length -= 2;
102*05b00f60SXin Li caplen -= 2;
103*05b00f60SXin Li p += 2;
104*05b00f60SXin Li
105*05b00f60SXin Li /*
106*05b00f60SXin Li * Now print the encapsulated frame, under the assumption
107*05b00f60SXin Li * that it's an Ethernet frame.
108*05b00f60SXin Li */
109*05b00f60SXin Li ether_print(ndo, p, length, caplen, lane_hdr_print, p - 2);
110*05b00f60SXin Li }
111