]>
The Tcpdump Group git mirrors - tcpdump/blob - print-ppp.c
4a84fc955452972a161d128c5aee6e7e5d902f34
2 * Copyright (c) 1990, 1991, 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.
23 static const char rcsid
[] =
24 "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.26 1999-10-07 23:47:12 mcr Exp $ (LBL)";
27 #include <sys/param.h>
29 #include <sys/socket.h>
31 #include <sys/ioctl.h>
39 #include <netinet/in.h>
40 #include <netinet/in_systm.h>
41 #include <netinet/ip.h>
48 #include "interface.h"
49 #include "addrtoname.h"
52 /* XXX This goes somewhere else. */
55 /* Standard PPP printer */
57 ppp_if_print(u_char
*user
, const struct pcap_pkthdr
*h
,
58 register const u_char
*p
)
60 register u_int length
= h
->len
;
61 register u_int caplen
= h
->caplen
;
66 if (caplen
< PPP_HDRLEN
) {
72 * Some printers want to get back at the link level addresses,
73 * and/or check that they're not walking off the end of the packet.
74 * Rather than pass them all the way down, we set these globals.
80 printf("%c %4d %02x %04x: ", p
[0] ? 'O' : 'I', length
,
81 p
[1], ntohs(*(u_short
*)&p
[2]));
84 ip
= (struct ip
*)(p
+ PPP_HDRLEN
);
85 ip_print((const u_char
*)ip
, length
);
88 default_print((const u_char
*)ip
, caplen
- PPP_HDRLEN
);
93 /* proto type to string mapping */
94 static struct tok ptype2str
[] = {
103 #define PPP_BSDI_HDRLEN 24
105 /* BSD/OS specific PPP printer */
107 ppp_bsdos_if_print(u_char
*user
, const struct pcap_pkthdr
*h
,
108 register const u_char
*p
)
110 register u_int length
= h
->len
;
111 register u_int caplen
= h
->caplen
;
112 register int hdrlength
;
117 if (caplen
< PPP_BSDI_HDRLEN
) {
123 * Some printers want to get back at the link level addresses,
124 * and/or check that they're not walking off the end of the packet.
125 * Rather than pass them all the way down, we set these globals.
128 snapend
= p
+ caplen
;
131 if (p
[0] == PPP_ADDRESS
&& p
[1] == PPP_CONTROL
) {
133 printf("%02x %02x ", p
[0], p
[1]);
139 printf("%d ", length
);
140 /* Retrieve the protocol type */
142 /* Compressed protocol field */
145 printf("%02x ", ptype
);
149 /* Un-compressed protocol field */
150 ptype
= ntohs(*(u_short
*)p
);
152 printf("%04x ", ptype
);
162 printf("%s ", tok2str(ptype2str
, "proto-#%d", ptype
));
165 default_print((const u_char
*)p
, caplen
- hdrlength
);