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.

350 lines
7.2 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. sap.c
  5. Abstract:
  6. IPX Router Console Monitoring and Configuration tool.
  7. SAP Command dispatcher.
  8. Author:
  9. V Raman 1/5/1998
  10. --*/
  11. #include "precomp.h"
  12. #pragma hdrstop
  13. FN_HANDLE_CMD HandleIpxSapAddFilter;
  14. FN_HANDLE_CMD HandleIpxSapDelFilter;
  15. FN_HANDLE_CMD HandleIpxSapSetFilter;
  16. FN_HANDLE_CMD HandleIpxSapShowFilter;
  17. FN_HANDLE_CMD HandleIpxSapSetInterface;
  18. FN_HANDLE_CMD HandleIpxSapShowInterface;
  19. FN_HANDLE_CMD HandleIpxSapSetGlobal;
  20. FN_HANDLE_CMD HandleIpxSapShowGlobal;
  21. //
  22. // Table of add, delete, set and show commands for IPXSAP
  23. //
  24. //
  25. // The commands are prefix-matched with the command-line, in sequential
  26. // order. So a command like 'ADD INTERFACE FILTER' must come before
  27. // the command 'ADD INTERFACE' in the table.
  28. //
  29. CMD_ENTRY g_IpxSapAddCmdTable[] =
  30. {
  31. CREATE_CMD_ENTRY( IPXSAP_ADD_FILTER, HandleIpxSapAddFilter )
  32. };
  33. CMD_ENTRY g_IpxSapDelCmdTable[] =
  34. {
  35. CREATE_CMD_ENTRY( IPXSAP_DEL_FILTER, HandleIpxSapDelFilter )
  36. };
  37. CMD_ENTRY g_IpxSapSetCmdTable[] =
  38. {
  39. CREATE_CMD_ENTRY( IPXSAP_SET_GLOBAL, HandleIpxSapSetGlobal ),
  40. CREATE_CMD_ENTRY( IPXSAP_SET_INTERFACE, HandleIpxSapSetInterface ),
  41. CREATE_CMD_ENTRY( IPXSAP_SET_FILTER, HandleIpxSapSetFilter )
  42. };
  43. CMD_ENTRY g_IpxSapShowCmdTable[] =
  44. {
  45. CREATE_CMD_ENTRY( IPXSAP_SHOW_GLOBAL, HandleIpxSapShowGlobal ),
  46. CREATE_CMD_ENTRY( IPXSAP_SHOW_INTERFACE, HandleIpxSapShowInterface ),
  47. CREATE_CMD_ENTRY( IPXSAP_SHOW_FILTER, HandleIpxSapShowFilter )
  48. };
  49. //
  50. // Command groups
  51. //
  52. CMD_GROUP_ENTRY g_IpxSapCmdGroups[] =
  53. {
  54. CREATE_CMD_GROUP_ENTRY( GROUP_ADD, g_IpxSapAddCmdTable ),
  55. CREATE_CMD_GROUP_ENTRY( GROUP_DELETE, g_IpxSapDelCmdTable ),
  56. CREATE_CMD_GROUP_ENTRY( GROUP_SET, g_IpxSapSetCmdTable ),
  57. CREATE_CMD_GROUP_ENTRY( GROUP_SHOW, g_IpxSapShowCmdTable )
  58. };
  59. ULONG g_ulIpxSapNumGroups =
  60. sizeof( g_IpxSapCmdGroups ) / sizeof( CMD_GROUP_ENTRY );
  61. //
  62. // functions to handle top level functions
  63. //
  64. DWORD
  65. HandleIpxSapDump(
  66. IN LPCWSTR pwszMachine,
  67. IN OUT LPWSTR *ppwcArguments,
  68. IN DWORD dwCurrentIndex,
  69. IN DWORD dwArgCount,
  70. IN DWORD dwFlags,
  71. IN LPCVOID pvData,
  72. OUT BOOL *pbDone
  73. )
  74. {
  75. DWORD dwErr, dwRead = 0, dwTot = 0, i;
  76. PMPR_INTERFACE_0 IfList;
  77. WCHAR IfDisplayName[ MAX_INTERFACE_NAME_LEN + 1 ];
  78. PWCHAR argv[1];
  79. DWORD dwSize = sizeof(IfDisplayName);
  80. DisplayIPXMessage (g_hModule, MSG_IPX_SAP_DUMP_HEADER);
  81. DisplayMessageT( DMP_IPX_SAP_HEADER );
  82. ShowSapGl(0, NULL, (HANDLE)-1);
  83. //
  84. // enumerate interfaces
  85. //
  86. if ( g_hMprAdmin )
  87. {
  88. dwErr = MprAdminInterfaceEnum(
  89. g_hMprAdmin, 0, (unsigned char **)&IfList, MAXULONG, &dwRead,
  90. &dwTot,NULL
  91. );
  92. }
  93. else
  94. {
  95. dwErr = MprConfigInterfaceEnum(
  96. g_hMprConfig, 0, (unsigned char **)&IfList, MAXULONG, &dwRead,
  97. &dwTot,NULL
  98. );
  99. }
  100. if ( dwErr != NO_ERROR )
  101. {
  102. return dwErr;
  103. }
  104. //
  105. // enumerate filters on each interface
  106. //
  107. for ( i = 0; i < dwRead; i++ )
  108. {
  109. dwErr = IpmontrGetFriendlyNameFromIfName(
  110. IfList[i].wszInterfaceName, IfDisplayName, &dwSize
  111. );
  112. if ( dwErr == NO_ERROR )
  113. {
  114. argv[0] = IfDisplayName;
  115. ShowSapIf( 1, argv, (HANDLE)-1 );
  116. ShowSapFlt( 1, argv, (HANDLE)-1 );
  117. }
  118. }
  119. DisplayMessageT( DMP_IPX_SAP_FOOTER );
  120. DisplayIPXMessage (g_hModule, MSG_IPX_SAP_DUMP_FOOTER);
  121. if ( g_hMprAdmin )
  122. {
  123. MprAdminBufferFree( IfList );
  124. }
  125. else
  126. {
  127. MprConfigBufferFree( IfList );
  128. }
  129. return NO_ERROR;
  130. }
  131. //
  132. // Functions to handle IPX SAP Filter add/del/set/show
  133. //
  134. DWORD
  135. HandleIpxSapAddFilter(
  136. IN LPCWSTR pwszMachine,
  137. IN OUT LPWSTR *ppwcArguments,
  138. IN DWORD dwCurrentIndex,
  139. IN DWORD dwArgCount,
  140. IN DWORD dwFlags,
  141. IN LPCVOID pvData,
  142. OUT BOOL *pbDone
  143. )
  144. {
  145. return CreateSapFlt(
  146. dwArgCount - dwCurrentIndex, ppwcArguments + dwCurrentIndex
  147. );
  148. }
  149. DWORD
  150. HandleIpxSapDelFilter(
  151. IN LPCWSTR pwszMachine,
  152. IN OUT LPWSTR *ppwcArguments,
  153. IN DWORD dwCurrentIndex,
  154. IN DWORD dwArgCount,
  155. IN DWORD dwFlags,
  156. IN LPCVOID pvData,
  157. OUT BOOL *pbDone
  158. )
  159. {
  160. return DeleteSapFlt(
  161. dwArgCount - dwCurrentIndex, ppwcArguments + dwCurrentIndex
  162. );
  163. }
  164. DWORD
  165. HandleIpxSapSetFilter(
  166. IN LPCWSTR pwszMachine,
  167. IN OUT LPWSTR *ppwcArguments,
  168. IN DWORD dwCurrentIndex,
  169. IN DWORD dwArgCount,
  170. IN DWORD dwFlags,
  171. IN LPCVOID pvData,
  172. OUT BOOL *pbDone
  173. )
  174. {
  175. return SetSapFlt(
  176. dwArgCount - dwCurrentIndex, ppwcArguments + dwCurrentIndex
  177. );
  178. }
  179. DWORD
  180. HandleIpxSapShowFilter(
  181. IN LPCWSTR pwszMachine,
  182. IN OUT LPWSTR *ppwcArguments,
  183. IN DWORD dwCurrentIndex,
  184. IN DWORD dwArgCount,
  185. IN DWORD dwFlags,
  186. IN LPCVOID pvData,
  187. OUT BOOL *pbDone
  188. )
  189. {
  190. return ShowSapFlt(
  191. dwArgCount - dwCurrentIndex, ppwcArguments + dwCurrentIndex, NULL
  192. );
  193. }
  194. DWORD
  195. HandleIpxSapSetInterface(
  196. IN LPCWSTR pwszMachine,
  197. IN OUT LPWSTR *ppwcArguments,
  198. IN DWORD dwCurrentIndex,
  199. IN DWORD dwArgCount,
  200. IN DWORD dwFlags,
  201. IN LPCVOID pvData,
  202. OUT BOOL *pbDone
  203. )
  204. {
  205. return SetSapIf(
  206. dwArgCount - dwCurrentIndex, ppwcArguments + dwCurrentIndex
  207. );
  208. }
  209. DWORD
  210. HandleIpxSapShowInterface(
  211. IN LPCWSTR pwszMachine,
  212. IN OUT LPWSTR *ppwcArguments,
  213. IN DWORD dwCurrentIndex,
  214. IN DWORD dwArgCount,
  215. IN DWORD dwFlags,
  216. IN LPCVOID pvData,
  217. OUT BOOL *pbDone
  218. )
  219. {
  220. return ShowSapIf(
  221. dwArgCount - dwCurrentIndex, ppwcArguments + dwCurrentIndex, NULL
  222. );
  223. }
  224. DWORD
  225. HandleIpxSapSetGlobal(
  226. IN LPCWSTR pwszMachine,
  227. IN OUT LPWSTR *ppwcArguments,
  228. IN DWORD dwCurrentIndex,
  229. IN DWORD dwArgCount,
  230. IN DWORD dwFlags,
  231. IN LPCVOID pvData,
  232. OUT BOOL *pbDone
  233. )
  234. {
  235. return SetSapGl(
  236. dwArgCount - dwCurrentIndex, ppwcArguments + dwCurrentIndex
  237. );
  238. }
  239. DWORD
  240. HandleIpxSapShowGlobal(
  241. IN LPCWSTR pwszMachine,
  242. IN OUT LPWSTR *ppwcArguments,
  243. IN DWORD dwCurrentIndex,
  244. IN DWORD dwArgCount,
  245. IN DWORD dwFlags,
  246. IN LPCVOID pvData,
  247. OUT BOOL *pbDone
  248. )
  249. {
  250. return ShowSapGl(
  251. dwArgCount - dwCurrentIndex, ppwcArguments + dwCurrentIndex, NULL
  252. );
  253. }
  254. DWORD
  255. IpxSapDump(
  256. IN LPCWSTR pwszRouter,
  257. IN OUT LPWSTR *ppwcArguments,
  258. IN DWORD dwArgCount,
  259. IN LPCVOID pvData
  260. )
  261. {
  262. ConnectToRouter(pwszRouter);
  263. //g_hMIBServer = (MIB_SERVER_HANDLE)pvData;
  264. return HandleIpxSapDump(pwszRouter, ppwcArguments, dwArgCount,
  265. 0, 0, pvData, NULL);
  266. }