]>
git.saurik.com Git - apple/network_cmds.git/blob - tcpdump.tproj/print-isoclns.c
cea4a7e3f4ff80165d1896ea47c95db175d4f246
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) 1992, 1993, 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.
44 * Original code by Matt Thomas, Digital Equipment Corporation
48 static const char rcsid
[] =
49 "@(#) $Header: /cvs/Darwin/Commands/NeXT/network_cmds/tcpdump.tproj/print-isoclns.c,v 1.1.1.1 1999/05/02 03:58:34 wsanchez Exp $ (LBL)";
52 #include <sys/types.h>
54 #include <sys/socket.h>
62 #include <netinet/in.h>
63 #include <netinet/if_ether.h>
67 #include "interface.h"
68 #include "addrtoname.h"
69 #include "ethertype.h"
76 static int osi_cksum(const u_char
*, u_int
, const u_char
*, u_char
*, u_char
*);
77 static void esis_print(const u_char
*, u_int
);
80 isoclns_print(const u_char
*p
, u_int length
, u_int caplen
,
81 const u_char
*esrc
, const u_char
*edst
)
84 printf("[|iso-clns] ");
87 etheraddr_string(esrc
),
88 etheraddr_string(edst
));
95 /* esis_print(&p, &length); */
98 (void)printf(" %s > %s",
99 etheraddr_string(esrc
),
100 etheraddr_string(edst
));
106 (void)printf(" %s > %s",
107 etheraddr_string(esrc
),
108 etheraddr_string(edst
));
109 esis_print(p
, length
);
115 (void)printf(" %s > %s",
116 etheraddr_string(esrc
),
117 etheraddr_string(edst
));
118 /* isis_print(&p, &length); */
119 (void)printf(" len=%d ", length
);
121 default_print_unaligned(p
, caplen
);
125 printf("iso-nullns");
127 (void)printf(" %s > %s",
128 etheraddr_string(esrc
),
129 etheraddr_string(edst
));
133 printf("iso-clns %02x", p
[0]);
135 (void)printf(" %s > %s",
136 etheraddr_string(esrc
),
137 etheraddr_string(edst
));
138 (void)printf(" len=%d ", length
);
140 default_print_unaligned(p
, caplen
);
145 #define ESIS_REDIRECT 6
158 esis_print(const u_char
*p
, u_int length
)
162 const struct esis_hdr
*eh
= (const struct esis_hdr
*) &p
[2];
170 printf(" no header at all!");
178 printf(" LI(%d) > PDU size (%d)!", li
, length
);
181 if (li
< sizeof(struct esis_hdr
) + 2) {
185 printf(" too short for esis header %d:", li
);
186 while (--length
>= 0)
187 printf("%02X", *p
++);
191 switch (eh
->type
& 0x1f) {
206 printf(" type %d", eh
->type
& 0x1f);
209 off
[0] = eh
->cksum
[0];
210 off
[1] = eh
->cksum
[1];
211 if (vflag
&& osi_cksum(p
, li
, eh
->cksum
, cksum
, off
)) {
212 printf(" bad cksum (got %02x%02x want %02x%02x)",
213 eh
->cksum
[1], eh
->cksum
[0], cksum
[1], cksum
[0]);
216 if (eh
->version
!= 1) {
217 printf(" unsupported version %d", eh
->version
);
220 p
+= sizeof(*eh
) + 2;
221 li
-= sizeof(*eh
) + 2; /* protoid * li */
223 switch (eh
->type
& 0x1f) {
224 case ESIS_REDIRECT
: {
225 const u_char
*dst
, *snpa
, *is
;
227 dst
= p
; p
+= *p
+ 1;
230 printf(" %s", isonsap_string(dst
));
231 snpa
= p
; p
+= *p
+ 1;
240 printf(" > %s", etheraddr_string(&snpa
[1]));
242 printf(" > %s", isonsap_string(is
));
261 printf(" %s", isonsap_string(is
));
267 (void)printf(" len=%d", length
);
268 if (length
&& p
< snapend
) {
269 length
= snapend
- p
;
270 default_print(p
, length
);
275 while (p
< ep
&& li
) {
282 printf(" bad opts/li");
289 printf(" opt (%d) too long", op
);
297 if (op
== 198 && opli
== 2) {
298 printf(" tmo=%d", q
[0] * 256 + q
[1]);
301 printf (" %d:<", op
);
303 printf("%02x", *q
++);
309 osi_cksum(register const u_char
*p
, register u_int len
,
310 const u_char
*toff
, u_char
*cksum
, u_char
*off
)
312 int x
, y
, f
= (len
- ((toff
- p
) + 1));
313 int32_t c0
= 0, c1
= 0;
315 if ((cksum
[0] = off
[0]) == 0 && (cksum
[1] = off
[1]) == 0)
327 x
= 255 - (-x
% 255);
332 y
= 255 - (-y
% 255);
339 return (off
[0] != cksum
[0] || off
[1] != cksum
[1]);