]>
git.saurik.com Git - apple/network_cmds.git/blob - tcpdump.tproj/print-atm.c
4abe2add211a37e2bb01a61a90bf955828e9eb91
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.0 (the 'License'). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
25 * Copyright (c) 1994, 1995, 1996
26 * The Regents of the University of California. All rights reserved.
28 * Redistribution and use in source and binary forms, with or without
29 * modification, are permitted provided that: (1) source code distributions
30 * retain the above copyright notice and this paragraph in its entirety, (2)
31 * distributions including binary code include the above copyright notice and
32 * this paragraph in its entirety in the documentation or other materials
33 * provided with the distribution, and (3) all advertising materials mentioning
34 * features or use of this software display the following acknowledgement:
35 * ``This product includes software developed by the University of California,
36 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
37 * the University nor the names of its contributors may be used to endorse
38 * or promote products derived from this software without specific prior
40 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
41 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
42 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
45 static const char rcsid
[] =
46 "@(#) $Header: /cvs/Darwin/Commands/NeXT/network_cmds/tcpdump.tproj/print-atm.c,v 1.1.1.1 1999/05/02 03:58:33 wsanchez Exp $ (LBL)";
49 #include <sys/param.h>
51 #include <sys/socket.h>
59 #include <netinet/in.h>
60 #include <netinet/if_ether.h>
61 #include <netinet/in_systm.h>
62 #include <netinet/ip.h>
63 #include <netinet/ip_var.h>
64 #include <netinet/udp.h>
65 #include <netinet/udp_var.h>
66 #include <netinet/tcp.h>
67 #include <netinet/tcpip.h>
72 #include "addrtoname.h"
73 #include "ethertype.h"
74 #include "interface.h"
77 * This is the top level routine of the printer. 'p' is the points
78 * to the LLC/SNAP header of the packet, 'tvp' is the timestamp,
79 * 'length' is the length of the packet off the wire, and 'caplen'
80 * is the number of bytes actually captured.
83 atm_if_print(u_char
*user
, const struct pcap_pkthdr
*h
, const u_char
*p
)
85 u_int caplen
= h
->caplen
;
86 u_int length
= h
->len
;
95 if (p
[0] != 0xaa || p
[1] != 0xaa || p
[2] != 0x03) {
96 /*XXX assume 802.6 MAC header from fore driver */
98 printf("%04x%04x %04x%04x ",
99 p
[0] << 24 | p
[1] << 16 | p
[2] << 8 | p
[3],
100 p
[4] << 24 | p
[5] << 16 | p
[6] << 8 | p
[7],
101 p
[8] << 24 | p
[9] << 16 | p
[10] << 8 | p
[11],
102 p
[12] << 24 | p
[13] << 16 | p
[14] << 8 | p
[15]);
107 ethertype
= p
[6] << 8 | p
[7];
109 printf("%02x %02x %02x %02x-%02x-%02x %04x: ",
110 p
[0], p
[1], p
[2], /* dsap/ssap/ctrl */
111 p
[3], p
[4], p
[5], /* manufacturer's code */
115 * Some printers want to get back at the ethernet addresses,
116 * and/or check that they're not walking off the end of the packet.
117 * Rather than pass them all the way down, we set these globals.
120 snapend
= p
+ caplen
;
132 /*XXX this probably isn't right */
134 case ETHERTYPE_REVARP
:
135 arp_print(p
, length
, caplen
);
139 decnet_print(p
, length
, caplen
);
142 case ETHERTYPE_ATALK
:
144 fputs("et1 ", stdout
);
145 atalk_print(p
, length
);
149 aarp_print(p
, length
);
153 case ETHERTYPE_MOPRC
:
154 case ETHERTYPE_MOPDL
:
155 /* default_print for now */
158 /* ether_type not known, print raw packet */
160 printf("%02x %02x %02x %02x-%02x-%02x %04x: ",
161 p
[0], p
[1], p
[2], /* dsap/ssap/ctrl */
162 p
[3], p
[4], p
[5], /* manufacturer's code */
164 if (!xflag
&& !qflag
)
165 default_print(p
, caplen
);
168 default_print(p
, caplen
);