Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

185 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 1997 FORE Systems, Inc.
  3. Copyright (c) 1997 Microsoft Corporation
  4. Module Name:
  5. atmlane.c
  6. Abstract:
  7. ATM ARP Admin Utility.
  8. Usage:
  9. atmarp
  10. Revision History:
  11. Who When What
  12. -------- -------- ---------------------------------------------
  13. josephj 06-10-1998 Created (adapted from atmlane admin utility).
  14. Notes:
  15. Modelled after atmlane utility.
  16. --*/
  17. #include "common.h"
  18. #include "atmmsg.h"
  19. BOOL
  20. ParseCmdLine(
  21. int argc,
  22. char * argv[]
  23. );
  24. OPTIONS g;
  25. void
  26. Usage(void);
  27. VOID __cdecl
  28. main(
  29. INT argc,
  30. CHAR *argv[]
  31. )
  32. {
  33. //
  34. // Parse args, determine if this is concerns the arp client or server.
  35. //
  36. if(!ParseCmdLine(argc, argv)){
  37. Usage();
  38. return;
  39. }
  40. DoAAS(&g);
  41. //
  42. // Following tries to open atmarpc.sys...
  43. //
  44. // DoAAC(&g);
  45. }
  46. void
  47. Usage(void)
  48. {
  49. printf( "\n Windows NT IP/ATM Information\n\n");
  50. printf(
  51. "USAGE: atmarp [/s] [/c] [/reset]\n");
  52. printf(
  53. " Options\n"
  54. " /? Display this help message.\n"
  55. " /s Display statistics for the ARP and MARS server.\n"
  56. " /c Display the ARP and MARS caches.\n"
  57. " /reset Reset the ARP and MARS statistics.\n\n"
  58. );
  59. printf(
  60. "The default is to display only the ARP and MARS statistics.\n\n"
  61. );
  62. }
  63. UINT FindOption(
  64. char *lptOpt,
  65. char **ppVal
  66. );
  67. enum
  68. {
  69. DISP_HELP,
  70. DISP_STATS,
  71. DISP_CACHES,
  72. DO_RESET,
  73. UNKNOWN_OPTION
  74. };
  75. struct _CmdOptions {
  76. char * lptOption;
  77. UINT uOpt;
  78. } CmdOptions[] = {
  79. {"/?" , DISP_HELP },
  80. {"-?" , DISP_HELP },
  81. {"/s" , DISP_STATS },
  82. {"-s" , DISP_STATS },
  83. {"/c" , DISP_CACHES },
  84. {"-c" , DISP_CACHES },
  85. {"/reset" , DO_RESET },
  86. {"-reset" , DO_RESET }
  87. };
  88. INT iCmdOptionsCounts = sizeof(CmdOptions)/sizeof(struct _CmdOptions);
  89. BOOL
  90. ParseCmdLine(
  91. int argc,
  92. char * argv[]
  93. )
  94. {
  95. BOOL bRetVal = TRUE;
  96. int iIndx;
  97. UINT uOpt;
  98. char *pVal;
  99. for(iIndx = 1; iIndx < argc; iIndx++)
  100. {
  101. uOpt = FindOption(argv[iIndx], &pVal);
  102. switch(uOpt){
  103. case DISP_STATS:
  104. g.DispStats = TRUE;
  105. break;
  106. case DISP_CACHES:
  107. g.DispCache = TRUE;
  108. break;
  109. case DO_RESET:
  110. g.DoResetStats = TRUE;
  111. break;
  112. default:
  113. printf("Unknown option - %s\n", argv[iIndx]); // fall through
  114. case DISP_HELP:
  115. bRetVal = FALSE;
  116. }
  117. }
  118. if (argc<=1)
  119. {
  120. //
  121. // Set default
  122. //
  123. g.DispStats = TRUE;
  124. }
  125. return bRetVal;
  126. }
  127. UINT FindOption(
  128. char *lptOpt,
  129. char **ppVal
  130. )
  131. {
  132. int i;
  133. UINT iLen;
  134. for(i = 0; i < iCmdOptionsCounts; i++){
  135. if(strlen(lptOpt) >= (iLen = strlen(CmdOptions[i].lptOption)))
  136. if(0 == _strnicmp(lptOpt, CmdOptions[i].lptOption, iLen)){
  137. *ppVal = lptOpt + iLen;
  138. return CmdOptions[i].uOpt;
  139. }
  140. }
  141. return UNKNOWN_OPTION;
  142. }