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 23*3c602fabSXin LI #define NETDISSECT_REWORKED 24b0453382SBill Fenner #ifdef HAVE_CONFIG_H 25b0453382SBill Fenner #include "config.h" 26b0453382SBill Fenner #endif 27b0453382SBill Fenner 285b0fe478SBruce M Simpson #include <tcpdump-stdinc.h> 29b0453382SBill Fenner 30b0453382SBill Fenner #include "interface.h" 315b0fe478SBruce M Simpson #include "extract.h" 32685295f4SBill Fenner #include "ether.h" 33*3c602fabSXin LI 34*3c602fabSXin LI struct lecdatahdr_8023 { 35*3c602fabSXin LI uint16_t le_header; 36*3c602fabSXin LI uint8_t h_dest[ETHER_ADDR_LEN]; 37*3c602fabSXin LI uint8_t h_source[ETHER_ADDR_LEN]; 38*3c602fabSXin LI uint16_t h_type; 39*3c602fabSXin LI }; 40*3c602fabSXin LI 41*3c602fabSXin LI struct lane_controlhdr { 42*3c602fabSXin LI uint16_t lec_header; 43*3c602fabSXin LI uint8_t lec_proto; 44*3c602fabSXin LI uint8_t lec_vers; 45*3c602fabSXin LI uint16_t lec_opcode; 46*3c602fabSXin LI }; 47b0453382SBill Fenner 485b0fe478SBruce M Simpson static const struct tok lecop2str[] = { 495b0fe478SBruce M Simpson { 0x0001, "configure request" }, 505b0fe478SBruce M Simpson { 0x0101, "configure response" }, 515b0fe478SBruce M Simpson { 0x0002, "join request" }, 525b0fe478SBruce M Simpson { 0x0102, "join response" }, 535b0fe478SBruce M Simpson { 0x0003, "ready query" }, 545b0fe478SBruce M Simpson { 0x0103, "ready indication" }, 555b0fe478SBruce M Simpson { 0x0004, "register request" }, 565b0fe478SBruce M Simpson { 0x0104, "register response" }, 575b0fe478SBruce M Simpson { 0x0005, "unregister request" }, 585b0fe478SBruce M Simpson { 0x0105, "unregister response" }, 595b0fe478SBruce M Simpson { 0x0006, "ARP request" }, 605b0fe478SBruce M Simpson { 0x0106, "ARP response" }, 615b0fe478SBruce M Simpson { 0x0007, "flush request" }, 625b0fe478SBruce M Simpson { 0x0107, "flush response" }, 635b0fe478SBruce M Simpson { 0x0008, "NARP request" }, 645b0fe478SBruce M Simpson { 0x0009, "topology request" }, 655b0fe478SBruce M Simpson { 0, NULL } 665b0fe478SBruce M Simpson }; 675b0fe478SBruce M Simpson 6827df3f5dSRui Paulo static void 69cac3dcd5SXin LI lane_hdr_print(netdissect_options *ndo, const u_char *bp) 70b0453382SBill Fenner { 71*3c602fabSXin LI ND_PRINT((ndo, "lecid:%x ", EXTRACT_16BITS(bp))); 72b0453382SBill Fenner } 73b0453382SBill Fenner 74b0453382SBill Fenner /* 755b0fe478SBruce M Simpson * This is the top level routine of the printer. 'p' points 765b0fe478SBruce M Simpson * to the LANE header of the packet, 'h->ts' is the timestamp, 771de50e9fSSam Leffler * 'h->len' is the length of the packet off the wire, and 'h->caplen' 78b0453382SBill Fenner * is the number of bytes actually captured. 795b0fe478SBruce M Simpson * 805b0fe478SBruce M Simpson * This assumes 802.3, not 802.5, LAN emulation. 81b0453382SBill Fenner */ 82b0453382SBill Fenner void 83*3c602fabSXin LI lane_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen) 84b0453382SBill Fenner { 855b0fe478SBruce M Simpson struct lane_controlhdr *lec; 86b0453382SBill Fenner 875b0fe478SBruce M Simpson if (caplen < sizeof(struct lane_controlhdr)) { 88*3c602fabSXin LI ND_PRINT((ndo, "[|lane]")); 895b0fe478SBruce M Simpson return; 905b0fe478SBruce M Simpson } 915b0fe478SBruce M Simpson 925b0fe478SBruce M Simpson lec = (struct lane_controlhdr *)p; 935b0fe478SBruce M Simpson if (EXTRACT_16BITS(&lec->lec_header) == 0xff00) { 945b0fe478SBruce M Simpson /* 955b0fe478SBruce M Simpson * LE Control. 965b0fe478SBruce M Simpson */ 97*3c602fabSXin LI ND_PRINT((ndo, "lec: proto %x vers %x %s", 985b0fe478SBruce M Simpson lec->lec_proto, lec->lec_vers, 99*3c602fabSXin LI tok2str(lecop2str, "opcode-#%u", EXTRACT_16BITS(&lec->lec_opcode)))); 1005b0fe478SBruce M Simpson return; 1015b0fe478SBruce M Simpson } 102b0453382SBill Fenner 10327df3f5dSRui Paulo /* 10427df3f5dSRui Paulo * Go past the LE header. 10527df3f5dSRui Paulo */ 10627df3f5dSRui Paulo length -= 2; 10727df3f5dSRui Paulo caplen -= 2; 10827df3f5dSRui Paulo p += 2; 109b0453382SBill Fenner 110b0453382SBill Fenner /* 11127df3f5dSRui Paulo * Now print the encapsulated frame, under the assumption 11227df3f5dSRui Paulo * that it's an Ethernet frame. 113b0453382SBill Fenner */ 114*3c602fabSXin LI ether_print(ndo, p, length, caplen, lane_hdr_print, p - 2); 1155b0fe478SBruce M Simpson } 1165b0fe478SBruce M Simpson 1175b0fe478SBruce M Simpson u_int 118*3c602fabSXin LI lane_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p) 1195b0fe478SBruce M Simpson { 120*3c602fabSXin LI lane_print(ndo, p, h->len, h->caplen); 1215b0fe478SBruce M Simpson 1225b0fe478SBruce M Simpson return (sizeof(struct lecdatahdr_8023)); 123b0453382SBill Fenner } 124