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.

254 lines
7.8 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1994 - 1999
  3. Module Name:
  4. Command.c
  5. Abstract:
  6. Command line parse for RPC perf tests.
  7. Author:
  8. Mario Goertzel (mariogo) 29-Mar-1994
  9. Revision History:
  10. --*/
  11. #include <rpcperf.h>
  12. char *Endpoint = 0;
  13. char *Protseq = "ncacn_np";
  14. char *NetworkAddr = 0;
  15. unsigned long Iterations = 1000;
  16. unsigned long Interval = 15; // seconds
  17. unsigned int MinThreads = 3;
  18. char *AuthnLevelStr= "none";
  19. unsigned long AuthnLevel = RPC_C_AUTHN_LEVEL_NONE;
  20. long Options[7];
  21. char *LogFileName = 0;
  22. unsigned int OutputLevel = 1; // 1 - normal, 2 - trace, 3 - debug, other - invalid.
  23. int AppendOnly = 0;
  24. RPC_NOTIFICATION_TYPES NotificationType = RpcNotificationTypeEvent;
  25. unsigned long ulSecurityPackage;
  26. char *ServerPrincipalName = NULL;
  27. extern char *USAGE; // defined by each test, maybe NULL.
  28. const char *STANDARD_USAGE = "Standard Test Options:"
  29. " -e <endpoint>\n"
  30. " -s <server addr>\n"
  31. " -t <protseq>\n"
  32. " -i <# iterations>\n"
  33. " -l <log filename>\n"
  34. " -m <# min threads>\n"
  35. " -n <test options>\n"
  36. " -a <authn level>\n"
  37. " -r # - report results interval (scale tests)\n"
  38. " -y - turn on yielding in win16"
  39. " -v 1 - verbose outout"
  40. " -v 2 - trace output"
  41. " -w(e)vent|(a)pc|(n)one|(h)wnd|(c)allback\n"
  42. " -p appends to existing log (don't delete old one)\n"
  43. " -u <security_package_id>\n"
  44. " -N <server_principal_name>\n"
  45. ;
  46. void ParseArgv(int argc, char **argv)
  47. {
  48. int fMissingParm = 0;
  49. char *Name = *argv;
  50. char option;
  51. int options_count;
  52. for(options_count = 0; options_count < 7; options_count++)
  53. Options[options_count] = -1;
  54. options_count = 0;
  55. argc--;
  56. argv++;
  57. while(argc)
  58. {
  59. if (**argv != '/' &&
  60. **argv != '-')
  61. {
  62. printf("Invalid switch: %s\n", *argv);
  63. argc--;
  64. argv++;
  65. }
  66. else
  67. {
  68. option = argv[0][1];
  69. argc--;
  70. argv++;
  71. // Most switches require a second command line arg.
  72. if (argc < 1)
  73. fMissingParm = 1;
  74. switch(option)
  75. {
  76. case 'e':
  77. Endpoint = *argv;
  78. argc--;
  79. argv++;
  80. break;
  81. case 't':
  82. Protseq = *argv;
  83. argc--;
  84. argv++;
  85. break;
  86. case 's':
  87. NetworkAddr = *argv;
  88. argc--;
  89. argv++;
  90. break;
  91. case 'i':
  92. Iterations = atoi(*argv);
  93. argc--;
  94. argv++;
  95. if (Iterations == 0)
  96. Iterations = 1000;
  97. break;
  98. case 'm':
  99. MinThreads = atoi(*argv);
  100. argc--;
  101. argv++;
  102. if (MinThreads == 0)
  103. MinThreads = 1;
  104. break;
  105. case 'a':
  106. AuthnLevelStr = *argv;
  107. argc--;
  108. argv++;
  109. break;
  110. case 'N':
  111. ServerPrincipalName = *argv;
  112. argc--;
  113. argv++;
  114. break;
  115. case 'n':
  116. if (options_count < 7)
  117. {
  118. Options[options_count] = atoi(*argv);
  119. options_count++;
  120. }
  121. else
  122. printf("Maximum of seven -n switchs, extra ignored.\n");
  123. argc--;
  124. argv++;
  125. break;
  126. case 'r':
  127. Interval = atoi(*argv);
  128. argc--;
  129. argv++;
  130. break;
  131. case 'u':
  132. ulSecurityPackage = atoi(*argv);
  133. argc--;
  134. argv++;
  135. break;
  136. case 'l':
  137. LogFileName = *argv;
  138. argc--;
  139. argv++;
  140. break;
  141. case 'v':
  142. OutputLevel = atoi(*argv);
  143. argc--;
  144. argv++;
  145. break;
  146. case 'w':
  147. switch(**argv)
  148. {
  149. case 'e':
  150. NotificationType = RpcNotificationTypeEvent;
  151. break;
  152. case 'a':
  153. NotificationType = RpcNotificationTypeApc;
  154. break;
  155. case 'n':
  156. NotificationType = RpcNotificationTypeNone;
  157. break;
  158. case 'h':
  159. NotificationType = RpcNotificationTypeHwnd;
  160. break;
  161. case 'c':
  162. NotificationType = RpcNotificationTypeCallback;
  163. break;
  164. default:
  165. printf("Invalid wait method: '%c'.\n", *argv);
  166. return;
  167. }
  168. argc--;
  169. argv++;
  170. break;
  171. #ifdef __RPC_WIN16__
  172. case 'y':
  173. RpcWinSetYieldInfo(0, FALSE, 0, 0);
  174. fMissingParm = 0;
  175. break;
  176. #endif
  177. case 'p':
  178. AppendOnly = TRUE;
  179. fMissingParm = 0;
  180. break;
  181. default:
  182. fMissingParm = 0;
  183. printf("Usage: %s: %s\n", Name, (USAGE == 0)?STANDARD_USAGE:USAGE);
  184. exit(0);
  185. break;
  186. }
  187. if (fMissingParm)
  188. {
  189. printf("Invalid switch %s, missing required parameter\n", *argv);
  190. }
  191. }
  192. } // while argc
  193. // determine the security level
  194. if (strcmp("none", AuthnLevelStr) == 0)
  195. AuthnLevel = RPC_C_AUTHN_LEVEL_NONE;
  196. else if (strcmp("connect", AuthnLevelStr) == 0)
  197. AuthnLevel = RPC_C_AUTHN_LEVEL_CONNECT;
  198. else if (strcmp("call", AuthnLevelStr) == 0)
  199. AuthnLevel = RPC_C_AUTHN_LEVEL_CALL;
  200. else if (strcmp("pkt", AuthnLevelStr) == 0)
  201. AuthnLevel = RPC_C_AUTHN_LEVEL_PKT;
  202. else if (strcmp("integrity", AuthnLevelStr) == 0)
  203. AuthnLevel = RPC_C_AUTHN_LEVEL_PKT_INTEGRITY;
  204. else if (strcmp("privacy", AuthnLevelStr) == 0)
  205. AuthnLevel = RPC_C_AUTHN_LEVEL_PKT_PRIVACY;
  206. else
  207. {
  208. printf("%s is NOT a valid authentication level, default is NONE\n", AuthnLevelStr);
  209. }
  210. #if 0
  211. printf("Config: %s:%s[%s]\n"
  212. "Iterations: %d\n"
  213. "Server threads %d\n"
  214. "Options: %d %d %d\n",
  215. Protseq, NetworkAddr, Endpoint, Iterations, MinThreads,
  216. Options[0], Options[1], Options[2]);
  217. #endif
  218. #ifdef WIN32
  219. printf("Process ID: %d\n", GetCurrentProcessId());
  220. #else
  221. #endif
  222. return;
  223. }