]>
The Tcpdump Group git mirrors - tcpdump/blob - print-chdlc.c
2b364b9e9c0908ba9d9c35c1f27b80be29058c1f
1 /* maybe it should be merged into print-ppp.c */
3 * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
4 * The Regents of the University of California. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that: (1) source code distributions
8 * retain the above copyright notice and this paragraph in its entirety, (2)
9 * distributions including binary code include the above copyright notice and
10 * this paragraph in its entirety in the documentation or other materials
11 * provided with the distribution, and (3) all advertising materials mentioning
12 * features or use of this software display the following acknowledgement:
13 * ``This product includes software developed by the University of California,
14 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
15 * the University nor the names of its contributors may be used to endorse
16 * or promote products derived from this software without specific prior
18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
19 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
24 static const char rcsid
[] =
25 "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.17 2002-09-20 10:02:42 hannes Exp $ (LBL)";
32 #include <tcpdump-stdinc.h>
37 #include "interface.h"
38 #include "addrtoname.h"
39 #include "ethertype.h"
44 static void chdlc_slarp_print(const u_char
*, u_int
);
46 /* Standard CHDLC printer */
48 chdlc_if_print(u_char
*user _U_
, const struct pcap_pkthdr
*h
,
49 register const u_char
*p
)
51 register u_int length
= h
->len
;
52 register u_int caplen
= h
->caplen
;
58 * Some printers want to get back at the link level addresses,
59 * and/or check that they're not walking off the end of the packet.
60 * Rather than pass them all the way down, we set these globals.
65 chdlc_print(p
, length
, caplen
);
74 chdlc_print(register const u_char
*p
, u_int length
, u_int caplen
)
79 if (caplen
< CHDLC_HDRLEN
) {
84 proto
= EXTRACT_16BITS(&p
[2]);
94 printf("0x%02x ", p
[0]);
97 printf("%d %04x: ", length
, proto
);
100 length
-= CHDLC_HDRLEN
;
101 ip
= (const struct ip
*)(p
+ CHDLC_HDRLEN
);
104 ip_print((const u_char
*)ip
, length
);
108 ip6_print((const u_char
*)ip
, length
);
111 case CHDLC_TYPE_SLARP
:
112 chdlc_slarp_print((const u_char
*)ip
, length
);
116 chdlc_cdp_print((const u_char
*)ip
, length
);
120 isoclns_print(p
+CHDLC_HDRLEN
, length
, length
, NULL
, NULL
);
124 default_print((const u_char
*)ip
, caplen
- CHDLC_HDRLEN
);
129 #define SLARP_REQUEST 0
130 #define SLARP_REPLY 1
131 #define SLARP_KEEPALIVE 2
151 chdlc_slarp_print(const u_char
*cp
, u_int length
)
153 const struct cisco_slarp
*slarp
;
155 if (length
< SLARP_LEN
) {
160 slarp
= (const struct cisco_slarp
*)cp
;
161 switch (ntohl(slarp
->code
)) {
163 printf("slarp-request");
166 printf("slarp-reply %s/%s",
167 ipaddr_string(&slarp
->un
.addr
.addr
),
168 ipaddr_string(&slarp
->un
.addr
.mask
));
170 case SLARP_KEEPALIVE
:
171 printf("slarp-keepalive my=0x%x your=0x%x ",
172 (u_int32_t
)ntohl(slarp
->un
.keep
.myseq
),
173 (u_int32_t
)ntohl(slarp
->un
.keep
.yourseq
));
174 printf("reliability=0x%04x t1=%d.%d",
175 ntohs(slarp
->un
.keep
.rel
), ntohs(slarp
->un
.keep
.t1
),
176 ntohs(slarp
->un
.keep
.t2
));
179 printf("slarp-0x%x unknown", (u_int32_t
)ntohl(slarp
->code
));
183 if (SLARP_LEN
< length
&& vflag
)
184 printf("(trailing junk: %d bytes)", length
- SLARP_LEN
);