blob: c1e0b2e8e11f36cc9b0b502e8f41ce9d9ac3ed83 [file] [log] [blame]
The Android Open Source Project2949f582009-03-03 19:30:46 -08001/*
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
Elliott Hughes892a68b2015-10-19 14:43:53 -070023#define NETDISSECT_REWORKED
The Android Open Source Project2949f582009-03-03 19:30:46 -080024#ifdef HAVE_CONFIG_H
25#include "config.h"
26#endif
27
28#include <tcpdump-stdinc.h>
29
The Android Open Source Project2949f582009-03-03 19:30:46 -080030#include "interface.h"
The Android Open Source Project2949f582009-03-03 19:30:46 -080031#include "extract.h"
32#include "ether.h"
Elliott Hughes892a68b2015-10-19 14:43:53 -070033
34struct lecdatahdr_8023 {
35 uint16_t le_header;
36 uint8_t h_dest[ETHER_ADDR_LEN];
37 uint8_t h_source[ETHER_ADDR_LEN];
38 uint16_t h_type;
39};
40
41struct lane_controlhdr {
42 uint16_t lec_header;
43 uint8_t lec_proto;
44 uint8_t lec_vers;
45 uint16_t lec_opcode;
46};
The Android Open Source Project2949f582009-03-03 19:30:46 -080047
48static const struct tok lecop2str[] = {
49 { 0x0001, "configure request" },
50 { 0x0101, "configure response" },
51 { 0x0002, "join request" },
52 { 0x0102, "join response" },
53 { 0x0003, "ready query" },
54 { 0x0103, "ready indication" },
55 { 0x0004, "register request" },
56 { 0x0104, "register response" },
57 { 0x0005, "unregister request" },
58 { 0x0105, "unregister response" },
59 { 0x0006, "ARP request" },
60 { 0x0106, "ARP response" },
61 { 0x0007, "flush request" },
62 { 0x0107, "flush response" },
63 { 0x0008, "NARP request" },
64 { 0x0009, "topology request" },
65 { 0, NULL }
66};
67
JP Abgrall53f17a92014-02-12 14:02:41 -080068static void
69lane_hdr_print(netdissect_options *ndo, const u_char *bp)
The Android Open Source Project2949f582009-03-03 19:30:46 -080070{
Elliott Hughes892a68b2015-10-19 14:43:53 -070071 ND_PRINT((ndo, "lecid:%x ", EXTRACT_16BITS(bp)));
The Android Open Source Project2949f582009-03-03 19:30:46 -080072}
73
74/*
75 * This is the top level routine of the printer. 'p' points
76 * to the LANE header of the packet, 'h->ts' is the timestamp,
77 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
78 * is the number of bytes actually captured.
79 *
80 * This assumes 802.3, not 802.5, LAN emulation.
81 */
82void
Elliott Hughes892a68b2015-10-19 14:43:53 -070083lane_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
The Android Open Source Project2949f582009-03-03 19:30:46 -080084{
85 struct lane_controlhdr *lec;
The Android Open Source Project2949f582009-03-03 19:30:46 -080086
87 if (caplen < sizeof(struct lane_controlhdr)) {
Elliott Hughes892a68b2015-10-19 14:43:53 -070088 ND_PRINT((ndo, "[|lane]"));
The Android Open Source Project2949f582009-03-03 19:30:46 -080089 return;
90 }
91
92 lec = (struct lane_controlhdr *)p;
93 if (EXTRACT_16BITS(&lec->lec_header) == 0xff00) {
94 /*
95 * LE Control.
96 */
Elliott Hughes892a68b2015-10-19 14:43:53 -070097 ND_PRINT((ndo, "lec: proto %x vers %x %s",
The Android Open Source Project2949f582009-03-03 19:30:46 -080098 lec->lec_proto, lec->lec_vers,
Elliott Hughes892a68b2015-10-19 14:43:53 -070099 tok2str(lecop2str, "opcode-#%u", EXTRACT_16BITS(&lec->lec_opcode))));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800100 return;
101 }
102
JP Abgrall53f17a92014-02-12 14:02:41 -0800103 /*
104 * Go past the LE header.
105 */
106 length -= 2;
107 caplen -= 2;
108 p += 2;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800109
110 /*
JP Abgrall53f17a92014-02-12 14:02:41 -0800111 * Now print the encapsulated frame, under the assumption
112 * that it's an Ethernet frame.
The Android Open Source Project2949f582009-03-03 19:30:46 -0800113 */
Elliott Hughes892a68b2015-10-19 14:43:53 -0700114 ether_print(ndo, p, length, caplen, lane_hdr_print, p - 2);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800115}
116
117u_int
Elliott Hughes892a68b2015-10-19 14:43:53 -0700118lane_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800119{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700120 lane_print(ndo, p, h->len, h->caplen);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800121
122 return (sizeof(struct lecdatahdr_8023));
123}