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.

152 lines
3.8 KiB

  1. /*++
  2. Copyright (c) 1999, Microsoft Corporation
  3. Module Name:
  4. sample\sample.c
  5. Abstract:
  6. The file contains the command dispatcher for the sample IP protocol.
  7. --*/
  8. #include "precomp.h"
  9. #pragma hdrstop
  10. // global information for the sample context
  11. CONTEXT_ENTRY g_ceSample;
  12. ////////////////////////////////////////
  13. // Configuration Data For Sample
  14. ////////////////////////////////////////
  15. // default global configuration
  16. static IPSAMPLE_GLOBAL_CONFIG isDefaultGlobal =
  17. {
  18. IPSAMPLE_LOGGING_INFO // tag LOGLEVEL
  19. };
  20. // default interface configuration
  21. static IPSAMPLE_IF_CONFIG isDefaultInterface =
  22. {
  23. 0 // tag METRIC
  24. };
  25. // table of ADD commands
  26. static CMD_ENTRY isAddCmdTable[] =
  27. {
  28. CREATE_CMD_ENTRY(SAMPLE_ADD_IF, HandleSampleAddIf),
  29. };
  30. // table of DELETE commands
  31. static CMD_ENTRY isDeleteCmdTable[] =
  32. {
  33. CREATE_CMD_ENTRY(SAMPLE_DEL_IF, HandleSampleDelIf),
  34. };
  35. // table of SET commands
  36. static CMD_ENTRY isSetCmdTable[] =
  37. {
  38. CREATE_CMD_ENTRY(SAMPLE_SET_GLOBAL, HandleSampleSetGlobal),
  39. CREATE_CMD_ENTRY(SAMPLE_SET_IF, HandleSampleSetIf),
  40. };
  41. // table of SHOW commands
  42. static CMD_ENTRY isShowCmdTable[] =
  43. {
  44. CREATE_CMD_ENTRY(SAMPLE_SHOW_GLOBAL, HandleSampleShowGlobal),
  45. CREATE_CMD_ENTRY(SAMPLE_SHOW_IF, HandleSampleShowIf),
  46. CREATE_CMD_ENTRY(SAMPLE_MIB_SHOW_STATS, HandleSampleMibShowObject),
  47. CREATE_CMD_ENTRY(SAMPLE_MIB_SHOW_IFSTATS, HandleSampleMibShowObject),
  48. CREATE_CMD_ENTRY(SAMPLE_MIB_SHOW_IFBINDING, HandleSampleMibShowObject),
  49. };
  50. // table of above group commands
  51. static CMD_GROUP_ENTRY isGroupCmds[] =
  52. {
  53. CREATE_CMD_GROUP_ENTRY(GROUP_ADD, isAddCmdTable),
  54. CREATE_CMD_GROUP_ENTRY(GROUP_DELETE, isDeleteCmdTable),
  55. CREATE_CMD_GROUP_ENTRY(GROUP_SET, isSetCmdTable),
  56. CREATE_CMD_GROUP_ENTRY(GROUP_SHOW, isShowCmdTable),
  57. };
  58. // table of top commands (non group)
  59. static CMD_ENTRY isTopCmds[] =
  60. {
  61. CREATE_CMD_ENTRY(INSTALL, HandleSampleInstall),
  62. CREATE_CMD_ENTRY(UNINSTALL, HandleSampleUninstall),
  63. };
  64. // dump function
  65. DWORD
  66. WINAPI
  67. SampleDump(
  68. IN LPCWSTR pwszMachine,
  69. IN WCHAR **ppwcArguments,
  70. IN DWORD dwArgCount,
  71. IN PVOID pvData
  72. )
  73. {
  74. DWORD dwErr;
  75. HANDLE hFile = (HANDLE)-1;
  76. DisplayMessage(g_hModule, DMP_SAMPLE_HEADER);
  77. DisplayMessageT(DMP_SAMPLE_PUSHD);
  78. DisplayMessageT(DMP_SAMPLE_UNINSTALL);
  79. // dump SAMPLE global configuration
  80. SgcShow(FORMAT_DUMP) ;
  81. // dump SAMPLE configuration for all interfaces
  82. SicShowAll(FORMAT_DUMP) ;
  83. DisplayMessageT(DMP_POPD);
  84. DisplayMessage(g_hModule, DMP_SAMPLE_FOOTER);
  85. return NO_ERROR;
  86. }
  87. VOID
  88. SampleInitialize(
  89. )
  90. /*++
  91. Routine Description
  92. Initialize sample's information. Called by IpsamplemonStartHelper.
  93. Arguments
  94. None
  95. Return Value
  96. None
  97. --*/
  98. {
  99. // context version
  100. g_ceSample.dwVersion = SAMPLE_CONTEXT_VERSION;
  101. // context identifying string
  102. g_ceSample.pwszName = TOKEN_SAMPLE;
  103. // top level (non group) commands
  104. g_ceSample.ulNumTopCmds = sizeof(isTopCmds)/sizeof(CMD_ENTRY);
  105. g_ceSample.pTopCmds = isTopCmds;
  106. // group commands
  107. g_ceSample.ulNumGroupCmds = sizeof(isGroupCmds)/sizeof(CMD_GROUP_ENTRY);
  108. g_ceSample.pGroupCmds = isGroupCmds;
  109. // default configuration
  110. g_ceSample.pDefaultGlobal = (PBYTE) &isDefaultGlobal;
  111. g_ceSample.pDefaultInterface= (PBYTE) &isDefaultInterface;
  112. // dump function
  113. g_ceSample.pfnDump = SampleDump;
  114. }