1b0453382SBill Fenner /*
2b0453382SBill Fenner * Marko Kiiskila carnil@cs.tut.fi
3b0453382SBill Fenner *
4b0453382SBill Fenner * Tampere University of Technology - Telecommunications Laboratory
5b0453382SBill Fenner *
6b0453382SBill Fenner * Permission to use, copy, modify and distribute this
7b0453382SBill Fenner * software and its documentation is hereby granted,
8b0453382SBill Fenner * provided that both the copyright notice and this
9b0453382SBill Fenner * permission notice appear in all copies of the software,
10b0453382SBill Fenner * derivative works or modified versions, and any portions
11b0453382SBill Fenner * thereof, that both notices appear in supporting
12b0453382SBill Fenner * documentation, and that the use of this software is
13b0453382SBill Fenner * acknowledged in any publications resulting from using
14b0453382SBill Fenner * the software.
15b0453382SBill Fenner *
16b0453382SBill Fenner * TUT ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17b0453382SBill Fenner * CONDITION AND DISCLAIMS ANY LIABILITY OF ANY KIND FOR
18b0453382SBill Fenner * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS
19b0453382SBill Fenner * SOFTWARE.
20b0453382SBill Fenner *
21b0453382SBill Fenner */
22b0453382SBill Fenner
233340d773SGleb Smirnoff /* \summary: ATM LANE printer */
243340d773SGleb Smirnoff
25*ee67461eSJoseph Mingrone #include <config.h>
26b0453382SBill Fenner
27*ee67461eSJoseph Mingrone #include "netdissect-stdinc.h"
28b0453382SBill Fenner
29*ee67461eSJoseph Mingrone #define ND_LONGJMP_FROM_TCHECK
303340d773SGleb Smirnoff #include "netdissect.h"
315b0fe478SBruce M Simpson #include "extract.h"
323c602fabSXin LI
333c602fabSXin LI struct lecdatahdr_8023 {
34*ee67461eSJoseph Mingrone nd_uint16_t le_header;
35*ee67461eSJoseph Mingrone nd_mac_addr h_dest;
36*ee67461eSJoseph Mingrone nd_mac_addr h_source;
37*ee67461eSJoseph Mingrone nd_uint16_t h_type;
383c602fabSXin LI };
393c602fabSXin LI
403c602fabSXin LI struct lane_controlhdr {
41*ee67461eSJoseph Mingrone nd_uint16_t lec_header;
42*ee67461eSJoseph Mingrone nd_uint8_t lec_proto;
43*ee67461eSJoseph Mingrone nd_uint8_t lec_vers;
44*ee67461eSJoseph Mingrone nd_uint16_t lec_opcode;
453c602fabSXin LI };
46b0453382SBill Fenner
475b0fe478SBruce M Simpson static const struct tok lecop2str[] = {
485b0fe478SBruce M Simpson { 0x0001, "configure request" },
495b0fe478SBruce M Simpson { 0x0101, "configure response" },
505b0fe478SBruce M Simpson { 0x0002, "join request" },
515b0fe478SBruce M Simpson { 0x0102, "join response" },
525b0fe478SBruce M Simpson { 0x0003, "ready query" },
535b0fe478SBruce M Simpson { 0x0103, "ready indication" },
545b0fe478SBruce M Simpson { 0x0004, "register request" },
555b0fe478SBruce M Simpson { 0x0104, "register response" },
565b0fe478SBruce M Simpson { 0x0005, "unregister request" },
575b0fe478SBruce M Simpson { 0x0105, "unregister response" },
585b0fe478SBruce M Simpson { 0x0006, "ARP request" },
595b0fe478SBruce M Simpson { 0x0106, "ARP response" },
605b0fe478SBruce M Simpson { 0x0007, "flush request" },
615b0fe478SBruce M Simpson { 0x0107, "flush response" },
625b0fe478SBruce M Simpson { 0x0008, "NARP request" },
635b0fe478SBruce M Simpson { 0x0009, "topology request" },
645b0fe478SBruce M Simpson { 0, NULL }
655b0fe478SBruce M Simpson };
665b0fe478SBruce M Simpson
6727df3f5dSRui Paulo static void
lane_hdr_print(netdissect_options * ndo,const u_char * bp)68cac3dcd5SXin LI lane_hdr_print(netdissect_options *ndo, const u_char *bp)
69b0453382SBill Fenner {
70*ee67461eSJoseph Mingrone ND_PRINT("lecid:%x ", GET_BE_U_2(bp));
71b0453382SBill Fenner }
72b0453382SBill Fenner
73b0453382SBill Fenner /*
745b0fe478SBruce M Simpson * This assumes 802.3, not 802.5, LAN emulation.
75b0453382SBill Fenner */
76b0453382SBill Fenner void
lane_print(netdissect_options * ndo,const u_char * p,u_int length,u_int caplen)773c602fabSXin LI lane_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
78b0453382SBill Fenner {
793340d773SGleb Smirnoff const struct lane_controlhdr *lec;
80b0453382SBill Fenner
81*ee67461eSJoseph Mingrone ndo->ndo_protocol = "lane";
825b0fe478SBruce M Simpson
833340d773SGleb Smirnoff lec = (const struct lane_controlhdr *)p;
84*ee67461eSJoseph Mingrone if (GET_BE_U_2(lec->lec_header) == 0xff00) {
855b0fe478SBruce M Simpson /*
865b0fe478SBruce M Simpson * LE Control.
875b0fe478SBruce M Simpson */
88*ee67461eSJoseph Mingrone ND_PRINT("lec: proto %x vers %x %s",
89*ee67461eSJoseph Mingrone GET_U_1(lec->lec_proto),
90*ee67461eSJoseph Mingrone GET_U_1(lec->lec_vers),
91*ee67461eSJoseph Mingrone tok2str(lecop2str, "opcode-#%u", GET_BE_U_2(lec->lec_opcode)));
925b0fe478SBruce M Simpson return;
935b0fe478SBruce M Simpson }
94b0453382SBill Fenner
9527df3f5dSRui Paulo /*
9627df3f5dSRui Paulo * Go past the LE header.
9727df3f5dSRui Paulo */
98*ee67461eSJoseph Mingrone ND_TCHECK_2(p); /* Needed */
9927df3f5dSRui Paulo length -= 2;
10027df3f5dSRui Paulo caplen -= 2;
10127df3f5dSRui Paulo p += 2;
102b0453382SBill Fenner
103b0453382SBill Fenner /*
10427df3f5dSRui Paulo * Now print the encapsulated frame, under the assumption
10527df3f5dSRui Paulo * that it's an Ethernet frame.
106b0453382SBill Fenner */
1073c602fabSXin LI ether_print(ndo, p, length, caplen, lane_hdr_print, p - 2);
1085b0fe478SBruce M Simpson }
109