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
[] =
25 "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.12 2001-07-05 18:54:15 guy Exp $ (LBL)";
32 #include <sys/param.h>
34 #include <sys/types.h>
35 #include <sys/socket.h>
38 #include <netinet/in.h>
43 #include "interface.h"
44 #include "addrtoname.h"
49 lane_print(register const u_char
*bp
, int length
)
51 register const struct lecdatahdr_8023
*ep
;
53 ep
= (const struct lecdatahdr_8023
*)bp
;
55 (void)printf("lecid:%d %s %s %d: ",
57 etheraddr_string(ep
->h_source
),
58 etheraddr_string(ep
->h_dest
),
61 (void)printf("lecid:%d %s %s %s %d: ",
63 etheraddr_string(ep
->h_source
),
64 etheraddr_string(ep
->h_dest
),
65 etherproto_string(ep
->h_type
),
70 * This is the top level routine of the printer. 'p' is the points
71 * to the ether header of the packet, 'h->tv' is the timestamp,
72 * 'h->length' is the length of the packet off the wire, and 'h->caplen'
73 * is the number of bytes actually captured.
76 lane_if_print(u_char
*user
, const struct pcap_pkthdr
*h
, const u_char
*p
)
78 int caplen
= h
->caplen
;
80 struct lecdatahdr_8023
*ep
;
82 u_short extracted_ethertype
;
87 if (caplen
< sizeof(struct lecdatahdr_8023
)) {
93 lane_print(p
, length
);
96 * Some printers want to get back at the ethernet addresses,
97 * and/or check that they're not walking off the end of the packet.
98 * Rather than pass them all the way down, we set these globals.
101 snapend
= p
+ caplen
;
103 length
-= sizeof(struct lecdatahdr_8023
);
104 caplen
-= sizeof(struct lecdatahdr_8023
);
105 ep
= (struct lecdatahdr_8023
*)p
;
106 p
+= sizeof(struct lecdatahdr_8023
);
108 ether_type
= ntohs(ep
->h_type
);
111 * Is it (gag) an 802.3 encapsulation?
113 extracted_ethertype
= 0;
114 if (ether_type
< ETHERMTU
) {
115 /* Try to print the LLC-layer header & higher layers */
116 if (llc_print(p
, length
, caplen
, ep
->h_source
, ep
->h_dest
,
117 &extracted_ethertype
) == 0) {
118 /* ether_type not known, print raw packet */
120 lane_print((u_char
*)ep
, length
+ sizeof(*ep
));
121 if (extracted_ethertype
) {
123 etherproto_string(htons(extracted_ethertype
)));
125 if (!xflag
&& !qflag
)
126 default_print(p
, caplen
);
128 } else if (ether_encap_print(ether_type
, p
, length
, caplen
,
129 &extracted_ethertype
) == 0) {
130 /* ether_type not known, print raw packet */
132 lane_print((u_char
*)ep
, length
+ sizeof(*ep
));
133 if (!xflag
&& !qflag
)
134 default_print(p
, caplen
);
137 default_print(p
, caplen
);