home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1 / HamRadio.cdr / misc / tcpipsrc / udpcmd.c < prev    next >
C/C++ Source or Header  |  1991-01-26  |  1KB  |  68 lines

  1. /* UDP-related user commands
  2.  * Copyright 1991 Phil Karn, KA9Q
  3.  */
  4. #include <stdio.h>
  5. #include "global.h"
  6. #include "mbuf.h"
  7. #include "netuser.h"
  8. #include "udp.h"
  9. #include "internet.h"
  10. #include "cmdparse.h"
  11. #include "commands.h"
  12.  
  13. static int doudpstat __ARGS((int argc,char *argv[],void *p));
  14.  
  15. static struct cmds Udpcmds[] = {
  16.     "status",    doudpstat,    0, 0,    NULLCHAR,
  17.     NULLCHAR,
  18. };
  19. int
  20. doudp(argc,argv,p)
  21. int argc;
  22. char *argv[];
  23. void *p;
  24. {
  25.     return subcmd(Udpcmds,argc,argv,p);
  26. }
  27. int
  28. st_udp(udp,n)
  29. struct udp_cb *udp;
  30. int n;
  31. {
  32.     if(n == 0)
  33.         tprintf("    &UCB Rcv-Q  Local socket\n");
  34.  
  35.     return tprintf("%8lx%6u  %s\n",ptol(udp),udp->rcvcnt,pinet(&udp->socket));
  36. }
  37.  
  38. /* Dump UDP statistics and control blocks */
  39. static int
  40. doudpstat(argc,argv,p)
  41. int argc;
  42. char *argv[];
  43. void *p;
  44. {
  45.     register struct udp_cb *udp;
  46.     register int i;
  47.  
  48.     for(i=1;i<=NUMUDPMIB;i++){
  49.         tprintf("(%2u)%-20s%10lu",i,
  50.          Udp_mib[i].name,Udp_mib[i].value.integer);
  51.         if(i % 2)
  52.             tprintf("     ");
  53.         else
  54.             tprintf("\n");
  55.     }
  56.     if((i % 2) == 0)
  57.         tprintf("\n");
  58.  
  59.     tprintf("    &UCB Rcv-Q  Local socket\n");
  60.     for(i=0;i<NUDP;i++){
  61.         for(udp = Udps[i];udp != NULLUDP; udp = udp->next){
  62.             if(st_udp(udp,1) == EOF)
  63.                 return 0;
  64.         }
  65.     }
  66.     return 0;
  67. }
  68.