Leaked source code of windows server 2003
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.

176 lines
4.5 KiB

  1. #include "pch.h"
  2. #pragma hdrstop
  3. #include "diag.h"
  4. #include "nb30.h"
  5. #define SZ_CMD_SHOW_LANA_DIAG L"showlanadiag"
  6. #define SZ_CMD_SHOW_LANA_PATHS L"showlanapaths"
  7. #define SZ_CMD_SET_LANA_NUMBER L"setlananumber"
  8. #define SZ_CMD_REWRITE_LANA_INFO L"rewritelanainfo"
  9. // Parameter strings for SZ_CMD_FULL_DIAGNOSTIC
  10. //
  11. #define SZ_PARAM_LEAK_CHECK L"leakcheck"
  12. VOID
  13. Usage (
  14. IN PCTSTR pszProgramName,
  15. IN COMMAND Command)
  16. {
  17. switch (Command)
  18. {
  19. case CMD_SHOW_LANA_DIAG:
  20. break;
  21. case CMD_SHOW_LANA_PATHS:
  22. break;
  23. case CMD_SET_LANA_NUMBER:
  24. g_pDiagCtx->Printf (ttidNcDiag,
  25. "\n"
  26. "%S %S <old lana number> <new lana number>\n"
  27. "\n",
  28. pszProgramName,
  29. SZ_CMD_SET_LANA_NUMBER);
  30. break;
  31. case CMD_REWRITE_LANA_INFO:
  32. break;
  33. default:
  34. g_pDiagCtx->Printf (ttidNcDiag,
  35. "\n"
  36. "Network Configuration Diagnostic\n"
  37. " View, manipulate, or test network configuration.\n"
  38. "\n"
  39. "%S [options]\n"
  40. " %-15S - Show bind paths and component descriptions for each exported lana\n"
  41. " %-15S - Change the lana number of a bind path\n"
  42. " %-15S - Verify and write out lana info to the registry\n"
  43. " %-15S - Show lana diagnostic info\n"
  44. "\n\n",
  45. pszProgramName,
  46. SZ_CMD_SHOW_LANA_PATHS,
  47. SZ_CMD_SET_LANA_NUMBER,
  48. SZ_CMD_REWRITE_LANA_INFO,
  49. SZ_CMD_SHOW_LANA_DIAG);
  50. break;
  51. }
  52. }
  53. #define NthArgIsPresent(_i) (_i < argc)
  54. #define NthArgIs(_i, _sz) ((_i < argc) && (0 == _wcsicmp(argv[_i], _sz)))
  55. EXTERN_C
  56. VOID
  57. __cdecl
  58. wmain (
  59. IN INT argc,
  60. IN PCWSTR argv[])
  61. {
  62. CDiagContext DiagCtx;
  63. DIAG_OPTIONS Options;
  64. INT iArg;
  65. DiagCtx.SetFlags (DF_SHOW_CONSOLE_OUTPUT);
  66. g_pDiagCtx = &DiagCtx;
  67. ZeroMemory (&Options, sizeof(Options));
  68. Options.pDiagCtx = g_pDiagCtx;
  69. Options.Command = CMD_INVALID;
  70. if (argc < 2)
  71. {
  72. Usage (argv[0], Options.Command);
  73. return;
  74. }
  75. iArg = 1;
  76. if (NthArgIs (iArg, SZ_CMD_SHOW_LANA_DIAG))
  77. {
  78. Options.Command = CMD_SHOW_LANA_DIAG;
  79. }
  80. else if (NthArgIs (iArg, SZ_CMD_SHOW_LANA_PATHS))
  81. {
  82. Options.Command = CMD_SHOW_LANA_PATHS;
  83. iArg++;
  84. if (NthArgIs (iArg, SZ_PARAM_LEAK_CHECK))
  85. {
  86. Options.fLeakCheck = TRUE;
  87. }
  88. }
  89. else if (NthArgIs (iArg, SZ_CMD_SET_LANA_NUMBER))
  90. {
  91. Options.Command = CMD_SET_LANA_NUMBER;
  92. iArg++;
  93. if (NthArgIsPresent (iArg) &&
  94. NthArgIsPresent (iArg+1))
  95. {
  96. ULONG Lana;
  97. PWSTR pszStop;
  98. BOOL fBadLana = FALSE;
  99. Lana = wcstoul (argv[iArg], &pszStop, 10);
  100. if ((MAX_LANA < Lana) || !pszStop || *pszStop)
  101. {
  102. fBadLana = TRUE;
  103. }
  104. else
  105. {
  106. Options.OldLanaNumber = (BYTE)Lana;
  107. Lana = wcstoul (argv[iArg+1], &pszStop, 10);
  108. if ((MAX_LANA < Lana) || !pszStop || *pszStop)
  109. {
  110. fBadLana = TRUE;
  111. }
  112. else
  113. {
  114. Options.NewLanaNumber = (BYTE)Lana;
  115. }
  116. }
  117. if (fBadLana)
  118. {
  119. g_pDiagCtx->Printf (ttidNcDiag,
  120. "\n"
  121. "Lana Numbers must be in 0-%u range, inclusive.\n"
  122. "\n", MAX_LANA);
  123. return;
  124. }
  125. }
  126. else
  127. {
  128. Usage (argv[0], Options.Command);
  129. return;
  130. }
  131. }
  132. else if (NthArgIs (iArg, SZ_CMD_REWRITE_LANA_INFO))
  133. {
  134. Options.Command = CMD_REWRITE_LANA_INFO;
  135. }
  136. else
  137. {
  138. Usage (argv[0], Options.Command);
  139. return;
  140. }
  141. HRESULT hr = CoInitializeEx (
  142. NULL,
  143. COINIT_DISABLE_OLE1DDE | COINIT_APARTMENTTHREADED);
  144. if (FAILED(hr))
  145. {
  146. g_pDiagCtx->Printf (ttidNcDiag,
  147. "Problem 0x%08x initializing COM library", hr);
  148. return;
  149. }
  150. LanaCfgFromCommandArgs (&Options);
  151. g_pDiagCtx->Printf (ttidNcDiag, "\n");
  152. }