home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1 / HamRadio.cdr / misc / src0131 / pppdump.c < prev    next >
C/C++ Source or Header  |  1990-11-02  |  2KB  |  74 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.  */
  11. #include <stdio.h>
  12. #include "global.h"
  13. #include "mbuf.h"
  14. #include "proc.h"
  15. #include "iface.h"
  16. #include "internet.h"
  17. #include "slcompre.h"
  18. #include "slip.h"
  19. #include "ppp.h"
  20. #include "trace.h"
  21.  
  22. /* dump a PPP packet */
  23. void
  24. ppp_dump(fp,bpp,unused)
  25. FILE *fp;
  26. struct mbuf **bpp;
  27. int unused;
  28. {
  29.     struct ppphdr phdr;
  30.     struct mbuf *bp, *tbp;
  31.  
  32.     ntohppp(&phdr,bpp);
  33.     fprintf(fp,"PPP: len %3u     ",(PPP_HDRLEN + len_p(*bpp)));
  34.     if (phdr.addr != HDLC_ALL_ADDR)
  35.         fprintf(fp,"!invalid addr field  ");
  36.     if (phdr.control != HDLC_UI)
  37.         fprintf(fp,"!invalid ctl field  ");
  38.  
  39.     switch(phdr.type){
  40.         case PPP_IP_TYPE:
  41.             fprintf(fp,"\t\tprotocol: IP\n");
  42.             ip_dump(fp,bpp,1);
  43.             break;
  44.         case PPP_IPCP_TYPE:
  45.             fprintf(fp,"\t\tprotocol: IPCP\n");
  46.             break;
  47.         case PPP_LCP_TYPE:
  48.             fprintf(fp,"\t\tprotocol: LCP\n");
  49.             break;
  50.         case PPP_PAP_TYPE:
  51.             fprintf(fp,"\t\tprotocol: PAP\n");
  52.             break;
  53.         case PPP_COMPR_TYPE:
  54.             fprintf(fp,"\t\tprotocol: VJ Compr TCP/IP\n");
  55.             vjcomp_dump(fp,bpp,0);
  56.             break;
  57.         case PPP_UNCOMP_TYPE:
  58.             fprintf(fp,"\t\tprotocol: VJ Uncompr TCP/IP\n");
  59.             fprintf(fp,"VJ Uncompr TCP/IP: connection 0x%02x\n",(*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.             free_p(bp);
  64.             *bpp = NULLBUF;
  65.             /* Restore the bytes used with Uncompressed TCP */
  66.             tbp->data[9] = TCP_PTCL;    /* FIX THIS! */
  67.             ip_dump(fp,&tbp,1);
  68.             break;
  69.         default:
  70.             fprintf(fp,"  unknown protocol: 0x%04x\n",phdr.type);
  71.             break;
  72.     }
  73. }
  74.