]>
The Tcpdump Group git mirrors - tcpdump/blob - print-arcnet.c
2 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 * From: NetBSD: print-arcnet.c,v 1.2 2000/04/24 13:02:28 itojun Exp
24 static const char rcsid
[] =
25 "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.8 2002-06-11 17:08:41 itojun Exp $ (LBL)";
32 #include <sys/param.h>
34 #include <sys/socket.h>
36 #include <netinet/in.h>
41 #include "interface.h"
44 int arcnet_encap_print(u_char arctype
, const u_char
*p
,
45 u_int length
, u_int caplen
);
47 struct tok arctypemap
[] = {
48 { ARCTYPE_IP_OLD
, "oldip" },
49 { ARCTYPE_ARP_OLD
, "oldarp" },
51 { ARCTYPE_ARP
, "arp" },
52 { ARCTYPE_REVARP
, "rarp" },
53 { ARCTYPE_ATALK
, "atalk" },
54 { ARCTYPE_BANIAN
, "banyan" },
55 { ARCTYPE_IPX
, "ipx" },
56 { ARCTYPE_INET6
, "ipv6" },
57 { ARCTYPE_DIAGNOSE
, "diag" },
62 arcnet_print(const u_char
*bp
, u_int length
, int phds
, int flag
, u_int seqid
)
64 const struct arc_header
*ap
;
65 const char *arctypename
;
68 ap
= (const struct arc_header
*)bp
;
72 (void)printf("%02x %02x %d: ",
79 arctypename
= tok2str(arctypemap
, "%02x", ap
->arc_type
);
82 (void)printf("%02x %02x %s %d: ",
83 ap
->arc_shost
, ap
->arc_dhost
, arctypename
,
89 (void)printf("%02x %02x %s seqid %04x %d: ",
90 ap
->arc_shost
, ap
->arc_dhost
, arctypename
, seqid
,
96 (void)printf("%02x %02x %s seqid %04x "
97 "(first of %d fragments) %d: ",
98 ap
->arc_shost
, ap
->arc_dhost
, arctypename
, seqid
,
99 (flag
+ 3) / 2, length
);
101 (void)printf("%02x %02x %s seqid %04x "
102 "(fragment %d) %d: ",
103 ap
->arc_shost
, ap
->arc_dhost
, arctypename
, seqid
,
108 * This is the top level routine of the printer. 'p' is the points
109 * to the ether header of the packet, 'tvp' is the timestamp,
110 * 'length' is the length of the packet off the wire, and 'caplen'
111 * is the number of bytes actually captured.
114 arcnet_if_print(u_char
*user
, const struct pcap_pkthdr
*h
, const u_char
*p
)
116 u_int caplen
= h
->caplen
;
117 u_int length
= h
->len
;
118 const struct arc_header
*ap
;
120 int phds
, flag
= 0, archdrlen
= 0;
127 if (caplen
< ARC_HDRLEN
) {
132 ap
= (const struct arc_header
*)p
;
133 arc_type
= ap
->arc_type
;
140 case ARCTYPE_ARP_OLD
:
141 case ARCTYPE_DIAGNOSE
:
143 archdrlen
= ARC_HDRLEN
;
148 if (caplen
< ARC_HDRNEWLEN
) {
149 arcnet_print(p
, length
, 0, 0, 0);
154 if (ap
->arc_flag
== 0xff) {
155 if (caplen
< ARC_HDRNEWLEN_EXC
) {
156 arcnet_print(p
, length
, 0, 0, 0);
157 printf("[|phds extended]");
160 flag
= ap
->arc_flag2
;
161 seqid
= ap
->arc_seqid2
;
162 archdrlen
= ARC_HDRNEWLEN_EXC
;
165 seqid
= ap
->arc_seqid
;
166 archdrlen
= ARC_HDRNEWLEN
;
172 arcnet_print(p
, length
, phds
, flag
, seqid
);
175 * Some printers want to get back at the ethernet addresses,
176 * and/or check that they're not walking off the end of the packet.
177 * Rather than pass them all the way down, we set these globals.
180 snapend
= p
+ caplen
;
186 if (phds
&& flag
&& (flag
& 1) == 0)
189 if (!arcnet_encap_print(arc_type
, p
, length
, caplen
)) {
190 default_print(p
, caplen
);
196 default_print(p
, caplen
);
206 * Prints the packet encapsulated in an ARCnet data field,
207 * given the ARCnet system code.
209 * Returns non-zero if it can do so, zero if the system code is unknown.
214 arcnet_encap_print(u_char arctype
, const u_char
*p
,
215 u_int length
, u_int caplen
)
226 ip6_print(p
, length
);
230 case ARCTYPE_ARP_OLD
:
233 arp_print(p
, length
, caplen
);
236 case ARCTYPE_ATALK
: /* XXX was this ever used? */
238 fputs("et1 ", stdout
);
239 atalk_print(p
, length
);