etc/protocols - sync with NetBSD-8
[minix.git] / external / bsd / tcpdump / dist / print-lane.c
blob5bbe0285c8a2e93c72de9d027f33f8fb8e3246f1
1 /*
2 * Marko Kiiskila carnil@cs.tut.fi
4 * Tampere University of Technology - Telecommunications Laboratory
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.
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.
23 #include <sys/cdefs.h>
24 #ifndef lint
25 __RCSID("$NetBSD: print-lane.c,v 1.4 2014/11/20 03:05:03 christos Exp $");
26 #endif
28 #define NETDISSECT_REWORKED
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
33 #include <tcpdump-stdinc.h>
35 #include "interface.h"
36 #include "extract.h"
37 #include "ether.h"
39 struct lecdatahdr_8023 {
40 uint16_t le_header;
41 uint8_t h_dest[ETHER_ADDR_LEN];
42 uint8_t h_source[ETHER_ADDR_LEN];
43 uint16_t h_type;
46 struct lane_controlhdr {
47 uint16_t lec_header;
48 uint8_t lec_proto;
49 uint8_t lec_vers;
50 uint16_t lec_opcode;
53 static const struct tok lecop2str[] = {
54 { 0x0001, "configure request" },
55 { 0x0101, "configure response" },
56 { 0x0002, "join request" },
57 { 0x0102, "join response" },
58 { 0x0003, "ready query" },
59 { 0x0103, "ready indication" },
60 { 0x0004, "register request" },
61 { 0x0104, "register response" },
62 { 0x0005, "unregister request" },
63 { 0x0105, "unregister response" },
64 { 0x0006, "ARP request" },
65 { 0x0106, "ARP response" },
66 { 0x0007, "flush request" },
67 { 0x0107, "flush response" },
68 { 0x0008, "NARP request" },
69 { 0x0009, "topology request" },
70 { 0, NULL }
73 static void
74 lane_hdr_print(netdissect_options *ndo, const u_char *bp)
76 ND_PRINT((ndo, "lecid:%x ", EXTRACT_16BITS(bp)));
80 * This is the top level routine of the printer. 'p' points
81 * to the LANE header of the packet, 'h->ts' is the timestamp,
82 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
83 * is the number of bytes actually captured.
85 * This assumes 802.3, not 802.5, LAN emulation.
87 void
88 lane_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
90 struct lane_controlhdr *lec;
92 if (caplen < sizeof(struct lane_controlhdr)) {
93 ND_PRINT((ndo, "[|lane]"));
94 return;
97 lec = (struct lane_controlhdr *)p;
98 if (EXTRACT_16BITS(&lec->lec_header) == 0xff00) {
100 * LE Control.
102 ND_PRINT((ndo, "lec: proto %x vers %x %s",
103 lec->lec_proto, lec->lec_vers,
104 tok2str(lecop2str, "opcode-#%u", EXTRACT_16BITS(&lec->lec_opcode))));
105 return;
109 * Go past the LE header.
111 length -= 2;
112 caplen -= 2;
113 p += 2;
116 * Now print the encapsulated frame, under the assumption
117 * that it's an Ethernet frame.
119 ether_print(ndo, p, length, caplen, lane_hdr_print, p - 2);
122 u_int
123 lane_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
125 lane_print(ndo, p, h->len, h->caplen);
127 return (sizeof(struct lecdatahdr_8023));