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-cip.c,v 1.16 2001-09-23 21:52:38 guy Exp $ (LBL)";
34 #include <sys/param.h>
36 #include <sys/types.h>
37 #include <sys/socket.h>
40 #include <netinet/in.h>
45 #include "interface.h"
46 #include "addrtoname.h"
47 #include "ethertype.h"
50 #define RFC1483LLC_LEN 8
52 static unsigned char rfcllc
[] = {
53 0xaa, /* DSAP: non-ISO */
54 0xaa, /* SSAP: non-ISO */
55 0x03, /* Ctrl: Unnumbered Information Command PDU */
56 0x00, /* OUI: EtherType */
61 cip_print(register const u_char
*bp
, int length
)
64 * There is no MAC-layer header, so just print the length.
66 printf("%d: ", length
);
70 * This is the top level routine of the printer. 'p' is the points
71 * to the raw header of the packet, 'tvp' is the timestamp,
72 * 'length' is the length of the packet off the wire, and 'caplen'
73 * is the number of bytes actually captured.
76 cip_if_print(u_char
*user
, const struct pcap_pkthdr
*h
, const u_char
*p
)
78 u_int caplen
= h
->caplen
;
79 u_int length
= h
->len
;
80 u_short extracted_ethertype
;
85 if (memcmp(rfcllc
, p
, sizeof(rfcllc
))==0 && caplen
< RFC1483LLC_LEN
) {
94 * Some printers want to get back at the ethernet addresses,
95 * and/or check that they're not walking off the end of the packet.
96 * Rather than pass them all the way down, we set these globals.
101 if (memcmp(rfcllc
, p
, sizeof(rfcllc
)) == 0) {
103 * LLC header is present. Try to print it & higher layers.
105 if (llc_print(p
, length
, caplen
, NULL
, NULL
,
106 &extracted_ethertype
) == 0) {
107 /* ether_type not known, print raw packet */
109 cip_print(p
, length
);
110 if (extracted_ethertype
) {
112 etherproto_string(htons(extracted_ethertype
)));
114 if (!xflag
&& !qflag
)
115 default_print(p
, caplen
);
119 * LLC header is absent; treat it as just IP.
125 default_print(p
, caplen
);