home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR3 / KA9Q212.ZIP / UDPCMD.C < prev    next >
C/C++ Source or Header  |  1993-07-16  |  2KB  |  72 lines

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