home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / ip / trace / tcpdump-2.2.1 / print-ppp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-07  |  2.6 KB  |  103 lines

  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.7 91/10/07 20:18:33 leres 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.     ts_print(tvp);
  65.  
  66.     if (caplen < PPP_HDRLEN) {
  67.         printf("[|ppp]");
  68.         goto out;
  69.     }
  70.  
  71.     /*
  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.
  75.      */
  76.     packetp = (u_char *)p;
  77.     snapend = (u_char *)p + caplen;
  78.  
  79.     if (eflag)
  80.         printf("%c %4d %02x %04x: ", p[0] ? 'O' : 'I', length,
  81.                p[1], ntohs(*(u_short *)&p[2]));
  82.  
  83.     length -= PPP_HDRLEN;
  84.     ip = (struct ip *)(p + PPP_HDRLEN);
  85.     ip_print(ip, length);
  86.  
  87.     if (xflag)
  88.         default_print((u_short *)ip, caplen - PPP_HDRLEN);
  89. out:
  90.     putchar('\n');
  91. }
  92. #else
  93. #include <stdio.h>
  94. void
  95. ppp_if_print()
  96. {
  97.     void error();
  98.  
  99.     error("not configured for ppp");
  100.     /* NOTREACHED */
  101. }
  102. #endif
  103.