1 /*
2  * Copyright (c) 1990 The Regents of the University of California.
3  * All rights reserved.
4  *
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
16  * written permission.
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.
20  */
21 
22 #ifndef lint
23 static  char rcsid[] =
24 	"@(#)$Header: print-ppp.c,v 1.5 91/04/19 10:46:44 mccanne Exp $ (LBL)";
25 #endif
26 
27 #ifdef PPP
28 #include <stdio.h>
29 #include <netdb.h>
30 #include <ctype.h>
31 #include <signal.h>
32 #include <errno.h>
33 #include <sys/param.h>
34 #include <sys/types.h>
35 #include <sys/time.h>
36 /*#include <sys/timeb.h>*/
37 #include <sys/socket.h>
38 #include <sys/file.h>
39 #include <sys/mbuf.h>
40 #include <sys/ioctl.h>
41 
42 #include <net/if.h>
43 #include <netinet/in.h>
44 #include <netinet/in_systm.h>
45 #include <netinet/ip.h>
46 
47 #include <net/bpf.h>
48 
49 #include "interface.h"
50 #include "addrtoname.h"
51 
52 /* XXX This goes somewhere else. */
53 #define PPP_HDRLEN 4
54 
55 void
56 ppp_if_print(p, tvp, length, caplen)
57 	u_char *p;
58 	struct timeval *tvp;
59 	int length;
60 	int caplen;
61 {
62 	struct ip *ip;
63 
64 	if (tflag > 0) {
65 		int i = (tvp->tv_sec + thiszone) % 86400;
66 		(void)printf(timestamp_fmt,
67 			     i / 3600, (i % 3600) / 60, i % 60,
68 			     tvp->tv_usec / timestamp_scale);
69 	} else if (tflag < 0)
70 		printf("%d.%06d ", tvp->tv_sec, tvp->tv_usec);
71 
72 	if (caplen < PPP_HDRLEN) {
73 		printf("[|ppp]");
74 		goto out;
75 	}
76 
77 	/*
78 	 * Some printers want to get back at the link level addresses,
79 	 * and/or check that they're not walking off the end of the packet.
80 	 * Rather than pass them all the way down, we set these globals.
81 	 */
82 	packetp = (u_char *)p;
83 	snapend = (u_char *)p + caplen;
84 
85 	length -= PPP_HDRLEN;
86 
87 	ip = (struct ip *)(p + PPP_HDRLEN);
88 
89 	if (eflag)
90 		printf("%c %02x %04x: ", p[0] ? 'O' : 'I', p[1],
91 		       ntohs(*(u_short *)&p[2]));
92 
93 	ip_print(ip, length);
94 
95 	if (xflag)
96 		default_print((u_short *)ip, caplen - PPP_HDRLEN);
97  out:
98 	putchar('\n');
99 }
100 #else
101 #include <stdio.h>
102 void
103 ppp_if_print()
104 {
105 	void error();
106 
107 	error("not configured for ppp");
108 	/* NOTREACHED */
109 }
110 #endif
111