]> The Tcpdump Group git mirrors - tcpdump/blob - print-lane.c
print-802_11: cleanup handle_deauth()
[tcpdump] / print-lane.c
1 /*
2 * Marko Kiiskila carnil@cs.tut.fi
3 *
4 * Tampere University of Technology - Telecommunications Laboratory
5 *
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.
15 *
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.
20 *
21 */
22
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
26
27 #include <tcpdump-stdinc.h>
28
29 #include <stdio.h>
30 #include <pcap.h>
31
32 #include "interface.h"
33 #include "addrtoname.h"
34 #include "extract.h"
35 #include "ether.h"
36
37 #ifndef ETHER_ADDR_LEN
38 #define ETHER_ADDR_LEN 6
39 #endif
40
41 struct lecdatahdr_8023 {
42 u_int16_t le_header;
43 u_int8_t h_dest[ETHER_ADDR_LEN];
44 u_int8_t h_source[ETHER_ADDR_LEN];
45 u_int16_t h_type;
46 };
47
48 struct lane_controlhdr {
49 u_int16_t lec_header;
50 u_int8_t lec_proto;
51 u_int8_t lec_vers;
52 u_int16_t lec_opcode;
53 };
54
55 static const struct tok lecop2str[] = {
56 { 0x0001, "configure request" },
57 { 0x0101, "configure response" },
58 { 0x0002, "join request" },
59 { 0x0102, "join response" },
60 { 0x0003, "ready query" },
61 { 0x0103, "ready indication" },
62 { 0x0004, "register request" },
63 { 0x0104, "register response" },
64 { 0x0005, "unregister request" },
65 { 0x0105, "unregister response" },
66 { 0x0006, "ARP request" },
67 { 0x0106, "ARP response" },
68 { 0x0007, "flush request" },
69 { 0x0107, "flush response" },
70 { 0x0008, "NARP request" },
71 { 0x0009, "topology request" },
72 { 0, NULL }
73 };
74
75 static void
76 lane_hdr_print(netdissect_options *ndo, const u_char *bp)
77 {
78 (void)ND_PRINT((ndo, "lecid:%x ", EXTRACT_16BITS(bp)));
79 }
80
81 /*
82 * This is the top level routine of the printer. 'p' points
83 * to the LANE header of the packet, 'h->ts' is the timestamp,
84 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
85 * is the number of bytes actually captured.
86 *
87 * This assumes 802.3, not 802.5, LAN emulation.
88 */
89 void
90 lane_print(const u_char *p, u_int length, u_int caplen)
91 {
92 struct lane_controlhdr *lec;
93
94 if (caplen < sizeof(struct lane_controlhdr)) {
95 printf("[|lane]");
96 return;
97 }
98
99 lec = (struct lane_controlhdr *)p;
100 if (EXTRACT_16BITS(&lec->lec_header) == 0xff00) {
101 /*
102 * LE Control.
103 */
104 printf("lec: proto %x vers %x %s",
105 lec->lec_proto, lec->lec_vers,
106 tok2str(lecop2str, "opcode-#%u", EXTRACT_16BITS(&lec->lec_opcode)));
107 return;
108 }
109
110 /*
111 * Go past the LE header.
112 */
113 length -= 2;
114 caplen -= 2;
115 p += 2;
116
117 /*
118 * Now print the encapsulated frame, under the assumption
119 * that it's an Ethernet frame.
120 */
121 ether_print(gndo, p, length, caplen, lane_hdr_print, p - 2);
122 }
123
124 u_int
125 lane_if_print(const struct pcap_pkthdr *h, const u_char *p)
126 {
127 lane_print(p, h->len, h->caplen);
128
129 return (sizeof(struct lecdatahdr_8023));
130 }