home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 3 / hamradioversion3.0examsandprograms1992.iso / packet / n17jsrc / pppdump.c < prev    next >
C/C++ Source or Header  |  1991-06-08  |  2KB  |  73 lines

  1. /*
  2.  *    PPPDUMP.C
  3.  *
  4.  *    12-89    -- Katie Stevens (dkstevens@ucdavis.edu)
  5.  *           UC Davis, Computing Services
  6.  *    PPP.08    05-90    [ks] improve tracing reports
  7.  *    PPP.09  05-90    [ks] add UPAP packet reporting
  8.  *    PPP.14    08-90    [ks] change UPAP to PAP for consistency with RFC1172
  9.  *    PPP.15    09-90    [ks] update to KA9Q NOS v900828
  10.  *    Jan 91    [Bill Simpson] small changes to match rewrite of PPP
  11.  */
  12. #include <stdio.h>
  13. #include "global.h"
  14. #include "mbuf.h"
  15. #include "proc.h"
  16. #include "iface.h"
  17. #include "internet.h"
  18. #include "ppp.h"
  19. #include "trace.h"
  20. /*#pragma option -G- */
  21. /* dump a PPP packet */
  22. void
  23. ppp_dump(fp,bpp,unused)
  24. FILE *fp;
  25. struct mbuf **bpp;
  26. int unused;
  27. {
  28.     struct ppp_hdr phdr;
  29.     struct mbuf *bp, *tbp;
  30.  
  31.     ntohppp(&phdr,bpp);
  32.     fprintf(fp,"PPP: len %3u     ",(PPP_HDR_LEN + len_p(*bpp)));
  33.     if (phdr.addr != HDLC_ALL_ADDR)
  34.         fprintf(fp,"!invalid addr field  ");
  35.     if (phdr.control != HDLC_UI)
  36.         fprintf(fp,"!invalid ctl field  ");
  37.  
  38.     switch(phdr.protocol){
  39.         case PPP_IP_PROTOCOL:
  40.             fprintf(fp,"\t\tprotocol: IP\n");
  41.             ip_dump(fp,bpp,1);
  42.             break;
  43.         case PPP_IPCP_PROTOCOL:
  44.             fprintf(fp,"\t\tprotocol: IPCP\n");
  45.             break;
  46.         case PPP_LCP_PROTOCOL:
  47.             fprintf(fp,"\t\tprotocol: LCP\n");
  48.             break;
  49.         case PPP_PAP_PROTOCOL:
  50.             fprintf(fp,"\t\tprotocol: PAP\n");
  51.             break;
  52.         case PPP_COMPR_PROTOCOL:
  53.             fprintf(fp,"\t\tprotocol: VJ Compr TCP/IP\n");
  54.             vjcomp_dump(fp,bpp,0);
  55.             break;
  56.         case PPP_UNCOMP_PROTOCOL:
  57.             fprintf(fp,"\t\tprotocol: VJ Uncompr TCP/IP\n");
  58.             fprintf(fp,"VJ Uncompr TCP/IP: connection 0x%02x\n",
  59.                 (*bpp)->data[9]);    /* FIX THIS! */
  60.             /* Get our own copy so we can mess with the data */
  61.             bp = *bpp;
  62.             tbp = copy_p(bp, len_p(bp));
  63.             /* Restore the bytes used with Uncompressed TCP */
  64.             tbp->data[9] = TCP_PTCL;    /* FIX THIS! */
  65.             ip_dump(fp,&tbp,1);
  66.             break;
  67.         default:
  68.             fprintf(fp,"  unknown protocol: 0x%04x\n",phdr.protocol);
  69.             break;
  70.     }
  71. }
  72. /*#pragma option -G */
  73.