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
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
24 static const char rcsid
[] _U_
=
25 "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.25 2005-11-13 12:12:42 guy Exp $ (LBL)";
32 #include <tcpdump-stdinc.h>
37 #include "interface.h"
38 #include "addrtoname.h"
43 static const struct tok lecop2str
[] = {
44 { 0x0001, "configure request" },
45 { 0x0101, "configure response" },
46 { 0x0002, "join request" },
47 { 0x0102, "join response" },
48 { 0x0003, "ready query" },
49 { 0x0103, "ready indication" },
50 { 0x0004, "register request" },
51 { 0x0104, "register response" },
52 { 0x0005, "unregister request" },
53 { 0x0105, "unregister response" },
54 { 0x0006, "ARP request" },
55 { 0x0106, "ARP response" },
56 { 0x0007, "flush request" },
57 { 0x0107, "flush response" },
58 { 0x0008, "NARP request" },
59 { 0x0009, "topology request" },
64 lane_hdr_print(register const u_char
*bp
, int length
)
66 register const struct lecdatahdr_8023
*ep
;
68 ep
= (const struct lecdatahdr_8023
*)bp
;
70 (void)printf("lecid:%x %s %s %d: ",
71 EXTRACT_16BITS(&ep
->le_header
),
72 etheraddr_string(ep
->h_source
),
73 etheraddr_string(ep
->h_dest
),
76 (void)printf("lecid:%x %s %s %s %d: ",
77 EXTRACT_16BITS(&ep
->le_header
),
78 etheraddr_string(ep
->h_source
),
79 etheraddr_string(ep
->h_dest
),
80 etherproto_string(ep
->h_type
),
85 * This is the top level routine of the printer. 'p' points
86 * to the LANE header of the packet, 'h->ts' is the timestamp,
87 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
88 * is the number of bytes actually captured.
90 * This assumes 802.3, not 802.5, LAN emulation.
93 lane_print(const u_char
*p
, u_int length
, u_int caplen
)
95 struct lane_controlhdr
*lec
;
96 struct lecdatahdr_8023
*ep
;
98 u_short extracted_ethertype
;
100 if (caplen
< sizeof(struct lane_controlhdr
)) {
105 lec
= (struct lane_controlhdr
*)p
;
106 if (EXTRACT_16BITS(&lec
->lec_header
) == 0xff00) {
110 printf("lec: proto %x vers %x %s",
111 lec
->lec_proto
, lec
->lec_vers
,
112 tok2str(lecop2str
, "opcode-#%u", EXTRACT_16BITS(&lec
->lec_opcode
)));
116 if (caplen
< sizeof(struct lecdatahdr_8023
)) {
122 lane_hdr_print(p
, length
);
125 * Go past the LANE header.
127 length
-= sizeof(struct lecdatahdr_8023
);
128 caplen
-= sizeof(struct lecdatahdr_8023
);
129 ep
= (struct lecdatahdr_8023
*)p
;
130 p
+= sizeof(struct lecdatahdr_8023
);
132 ether_type
= EXTRACT_16BITS(&ep
->h_type
);
135 * Is it (gag) an 802.3 encapsulation?
137 if (ether_type
<= ETHERMTU
) {
138 /* Try to print the LLC-layer header & higher layers */
139 if (llc_print(p
, length
, caplen
, ep
->h_source
, ep
->h_dest
,
140 &extracted_ethertype
) == 0) {
141 /* ether_type not known, print raw packet */
143 lane_hdr_print((u_char
*)ep
, length
+ sizeof(*ep
));
144 if (extracted_ethertype
) {
146 etherproto_string(htons(extracted_ethertype
)));
148 if (!suppress_default_print
)
149 default_print(p
, caplen
);
151 } else if (ether_encap_print(ether_type
, p
, length
, caplen
,
152 &extracted_ethertype
) == 0) {
153 /* ether_type not known, print raw packet */
155 lane_hdr_print((u_char
*)ep
, length
+ sizeof(*ep
));
156 if (!suppress_default_print
)
157 default_print(p
, caplen
);
162 lane_if_print(const struct pcap_pkthdr
*h
, const u_char
*p
)
164 lane_print(p
, h
->len
, h
->caplen
);
166 return (sizeof(struct lecdatahdr_8023
));