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 23b0453382SBill Fenner #ifndef lint 245b0fe478SBruce M Simpson static const char rcsid[] _U_ = 25a5779b6eSRui Paulo "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.25 2005-11-13 12:12:42 guy Exp $ (LBL)"; 26b0453382SBill Fenner #endif 27b0453382SBill Fenner 28b0453382SBill Fenner #ifdef HAVE_CONFIG_H 29b0453382SBill Fenner #include "config.h" 30b0453382SBill Fenner #endif 31b0453382SBill Fenner 325b0fe478SBruce M Simpson #include <tcpdump-stdinc.h> 33b0453382SBill Fenner 34b0453382SBill Fenner #include <stdio.h> 35b0453382SBill Fenner #include <pcap.h> 36b0453382SBill Fenner 37b0453382SBill Fenner #include "interface.h" 38b0453382SBill Fenner #include "addrtoname.h" 395b0fe478SBruce M Simpson #include "extract.h" 40685295f4SBill Fenner #include "ether.h" 41b0453382SBill Fenner #include "lane.h" 42b0453382SBill Fenner 435b0fe478SBruce M Simpson static const struct tok lecop2str[] = { 445b0fe478SBruce M Simpson { 0x0001, "configure request" }, 455b0fe478SBruce M Simpson { 0x0101, "configure response" }, 465b0fe478SBruce M Simpson { 0x0002, "join request" }, 475b0fe478SBruce M Simpson { 0x0102, "join response" }, 485b0fe478SBruce M Simpson { 0x0003, "ready query" }, 495b0fe478SBruce M Simpson { 0x0103, "ready indication" }, 505b0fe478SBruce M Simpson { 0x0004, "register request" }, 515b0fe478SBruce M Simpson { 0x0104, "register response" }, 525b0fe478SBruce M Simpson { 0x0005, "unregister request" }, 535b0fe478SBruce M Simpson { 0x0105, "unregister response" }, 545b0fe478SBruce M Simpson { 0x0006, "ARP request" }, 555b0fe478SBruce M Simpson { 0x0106, "ARP response" }, 565b0fe478SBruce M Simpson { 0x0007, "flush request" }, 575b0fe478SBruce M Simpson { 0x0107, "flush response" }, 585b0fe478SBruce M Simpson { 0x0008, "NARP request" }, 595b0fe478SBruce M Simpson { 0x0009, "topology request" }, 605b0fe478SBruce M Simpson { 0, NULL } 615b0fe478SBruce M Simpson }; 625b0fe478SBruce M Simpson 63*27df3f5dSRui Paulo static void 64*27df3f5dSRui Paulo lane_hdr_print(const u_char *bp) 65b0453382SBill Fenner { 66*27df3f5dSRui Paulo (void)printf("lecid:%x ", EXTRACT_16BITS(bp)); 67b0453382SBill Fenner } 68b0453382SBill Fenner 69b0453382SBill Fenner /* 705b0fe478SBruce M Simpson * This is the top level routine of the printer. 'p' points 715b0fe478SBruce M Simpson * to the LANE header of the packet, 'h->ts' is the timestamp, 721de50e9fSSam Leffler * 'h->len' is the length of the packet off the wire, and 'h->caplen' 73b0453382SBill Fenner * is the number of bytes actually captured. 745b0fe478SBruce M Simpson * 755b0fe478SBruce M Simpson * This assumes 802.3, not 802.5, LAN emulation. 76b0453382SBill Fenner */ 77b0453382SBill Fenner void 785b0fe478SBruce M Simpson lane_print(const u_char *p, u_int length, u_int caplen) 79b0453382SBill Fenner { 805b0fe478SBruce M Simpson struct lane_controlhdr *lec; 81b0453382SBill Fenner 825b0fe478SBruce M Simpson if (caplen < sizeof(struct lane_controlhdr)) { 835b0fe478SBruce M Simpson printf("[|lane]"); 845b0fe478SBruce M Simpson return; 855b0fe478SBruce M Simpson } 865b0fe478SBruce M Simpson 875b0fe478SBruce M Simpson lec = (struct lane_controlhdr *)p; 885b0fe478SBruce M Simpson if (EXTRACT_16BITS(&lec->lec_header) == 0xff00) { 895b0fe478SBruce M Simpson /* 905b0fe478SBruce M Simpson * LE Control. 915b0fe478SBruce M Simpson */ 925b0fe478SBruce M Simpson printf("lec: proto %x vers %x %s", 935b0fe478SBruce M Simpson lec->lec_proto, lec->lec_vers, 945b0fe478SBruce M Simpson tok2str(lecop2str, "opcode-#%u", EXTRACT_16BITS(&lec->lec_opcode))); 955b0fe478SBruce M Simpson return; 965b0fe478SBruce M Simpson } 97b0453382SBill Fenner 98*27df3f5dSRui Paulo /* 99*27df3f5dSRui Paulo * Go past the LE header. 100*27df3f5dSRui Paulo */ 101*27df3f5dSRui Paulo length -= 2; 102*27df3f5dSRui Paulo caplen -= 2; 103*27df3f5dSRui Paulo p += 2; 104b0453382SBill Fenner 105b0453382SBill Fenner /* 106*27df3f5dSRui Paulo * Now print the encapsulated frame, under the assumption 107*27df3f5dSRui Paulo * that it's an Ethernet frame. 108b0453382SBill Fenner */ 109*27df3f5dSRui Paulo ether_print(p, length, caplen, lane_hdr_print, p - 2); 1105b0fe478SBruce M Simpson } 1115b0fe478SBruce M Simpson 1125b0fe478SBruce M Simpson u_int 1135b0fe478SBruce M Simpson lane_if_print(const struct pcap_pkthdr *h, const u_char *p) 1145b0fe478SBruce M Simpson { 1155b0fe478SBruce M Simpson lane_print(p, h->len, h->caplen); 1165b0fe478SBruce M Simpson 1175b0fe478SBruce M Simpson return (sizeof(struct lecdatahdr_8023)); 118b0453382SBill Fenner } 119