1 | #include <machine/rtems-bsd-user-space.h> |
---|
2 | |
---|
3 | /* |
---|
4 | * Marko Kiiskila carnil@cs.tut.fi |
---|
5 | * |
---|
6 | * Tampere University of Technology - Telecommunications Laboratory |
---|
7 | * |
---|
8 | * Permission to use, copy, modify and distribute this |
---|
9 | * software and its documentation is hereby granted, |
---|
10 | * provided that both the copyright notice and this |
---|
11 | * permission notice appear in all copies of the software, |
---|
12 | * derivative works or modified versions, and any portions |
---|
13 | * thereof, that both notices appear in supporting |
---|
14 | * documentation, and that the use of this software is |
---|
15 | * acknowledged in any publications resulting from using |
---|
16 | * the software. |
---|
17 | * |
---|
18 | * TUT ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" |
---|
19 | * CONDITION AND DISCLAIMS ANY LIABILITY OF ANY KIND FOR |
---|
20 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS |
---|
21 | * SOFTWARE. |
---|
22 | * |
---|
23 | */ |
---|
24 | |
---|
25 | #ifndef lint |
---|
26 | static const char rcsid[] _U_ = |
---|
27 | "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.25 2005-11-13 12:12:42 guy Exp $ (LBL)"; |
---|
28 | #endif |
---|
29 | |
---|
30 | #ifdef HAVE_CONFIG_H |
---|
31 | #include "config.h" |
---|
32 | #endif |
---|
33 | |
---|
34 | #include <tcpdump-stdinc.h> |
---|
35 | |
---|
36 | #include <stdio.h> |
---|
37 | #include <pcap.h> |
---|
38 | |
---|
39 | #include "interface.h" |
---|
40 | #include "addrtoname.h" |
---|
41 | #include "extract.h" |
---|
42 | #include "ether.h" |
---|
43 | #include "lane.h" |
---|
44 | |
---|
45 | static const struct tok lecop2str[] = { |
---|
46 | { 0x0001, "configure request" }, |
---|
47 | { 0x0101, "configure response" }, |
---|
48 | { 0x0002, "join request" }, |
---|
49 | { 0x0102, "join response" }, |
---|
50 | { 0x0003, "ready query" }, |
---|
51 | { 0x0103, "ready indication" }, |
---|
52 | { 0x0004, "register request" }, |
---|
53 | { 0x0104, "register response" }, |
---|
54 | { 0x0005, "unregister request" }, |
---|
55 | { 0x0105, "unregister response" }, |
---|
56 | { 0x0006, "ARP request" }, |
---|
57 | { 0x0106, "ARP response" }, |
---|
58 | { 0x0007, "flush request" }, |
---|
59 | { 0x0107, "flush response" }, |
---|
60 | { 0x0008, "NARP request" }, |
---|
61 | { 0x0009, "topology request" }, |
---|
62 | { 0, NULL } |
---|
63 | }; |
---|
64 | |
---|
65 | static void |
---|
66 | lane_hdr_print(netdissect_options *ndo, const u_char *bp) |
---|
67 | { |
---|
68 | (void)ND_PRINT((ndo, "lecid:%x ", EXTRACT_16BITS(bp))); |
---|
69 | } |
---|
70 | |
---|
71 | /* |
---|
72 | * This is the top level routine of the printer. 'p' points |
---|
73 | * to the LANE header of the packet, 'h->ts' is the timestamp, |
---|
74 | * 'h->len' is the length of the packet off the wire, and 'h->caplen' |
---|
75 | * is the number of bytes actually captured. |
---|
76 | * |
---|
77 | * This assumes 802.3, not 802.5, LAN emulation. |
---|
78 | */ |
---|
79 | void |
---|
80 | lane_print(const u_char *p, u_int length, u_int caplen) |
---|
81 | { |
---|
82 | struct lane_controlhdr *lec; |
---|
83 | |
---|
84 | if (caplen < sizeof(struct lane_controlhdr)) { |
---|
85 | printf("[|lane]"); |
---|
86 | return; |
---|
87 | } |
---|
88 | |
---|
89 | lec = (struct lane_controlhdr *)p; |
---|
90 | if (EXTRACT_16BITS(&lec->lec_header) == 0xff00) { |
---|
91 | /* |
---|
92 | * LE Control. |
---|
93 | */ |
---|
94 | printf("lec: proto %x vers %x %s", |
---|
95 | lec->lec_proto, lec->lec_vers, |
---|
96 | tok2str(lecop2str, "opcode-#%u", EXTRACT_16BITS(&lec->lec_opcode))); |
---|
97 | return; |
---|
98 | } |
---|
99 | |
---|
100 | /* |
---|
101 | * Go past the LE header. |
---|
102 | */ |
---|
103 | length -= 2; |
---|
104 | caplen -= 2; |
---|
105 | p += 2; |
---|
106 | |
---|
107 | /* |
---|
108 | * Now print the encapsulated frame, under the assumption |
---|
109 | * that it's an Ethernet frame. |
---|
110 | */ |
---|
111 | ether_print(gndo, p, length, caplen, lane_hdr_print, p - 2); |
---|
112 | } |
---|
113 | |
---|
114 | u_int |
---|
115 | lane_if_print(const struct pcap_pkthdr *h, const u_char *p) |
---|
116 | { |
---|
117 | lane_print(p, h->len, h->caplen); |
---|
118 | |
---|
119 | return (sizeof(struct lecdatahdr_8023)); |
---|
120 | } |
---|