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. rip.c
  5. Abstract:
  6. IPX Router Console Monitoring and Configuration tool.
  7. RIP Command dispatcher.
  8. Author:
  9. V Raman 1/5/1998
  10. --*/
  11. #include "precomp.h"
  12. #pragma hdrstop
  13. FN_HANDLE_CMD HandleIpxRipAddFilter;
  14. FN_HANDLE_CMD HandleIpxRipDelFilter;
  15. FN_HANDLE_CMD HandleIpxRipSetFilter;
  16. FN_HANDLE_CMD HandleIpxRipShowFilter;
  17. FN_HANDLE_CMD HandleIpxRipSetInterface;
  18. FN_HANDLE_CMD HandleIpxRipShowInterface;
  19. FN_HANDLE_CMD HandleIpxRipSetGlobal;
  20. FN_HANDLE_CMD HandleIpxRipShowGlobal;
  21. //
  22. // Table of add, delete, set and show commands for IPXRIP
  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_IpxRipAddCmdTable[] =
  30. {
  31. CREATE_CMD_ENTRY( IPXRIP_ADD_FILTER, HandleIpxRipAddFilter )
  32. };
  33. CMD_ENTRY g_IpxRipDelCmdTable[] =
  34. {
  35. CREATE_CMD_ENTRY( IPXRIP_DEL_FILTER, HandleIpxRipDelFilter )
  36. };
  37. CMD_ENTRY g_IpxRipSetCmdTable[] =
  38. {
  39. CREATE_CMD_ENTRY( IPXRIP_SET_GLOBAL, HandleIpxRipSetGlobal ),
  40. CREATE_CMD_ENTRY( IPXRIP_SET_INTERFACE, HandleIpxRipSetInterface ),
  41. CREATE_CMD_ENTRY( IPXRIP_SET_FILTER, HandleIpxRipSetFilter )
  42. };
  43. CMD_ENTRY g_IpxRipShowCmdTable[] =
  44. {
  45. CREATE_CMD_ENTRY( IPXRIP_SHOW_GLOBAL, HandleIpxRipShowGlobal ),
  46. CREATE_CMD_ENTRY( IPXRIP_SHOW_INTERFACE, HandleIpxRipShowInterface ),
  47. CREATE_CMD_ENTRY( IPXRIP_SHOW_FILTER, HandleIpxRipShowFilter )
  48. };
  49. //
  50. // Command groups
  51. //
  52. CMD_GROUP_ENTRY g_IpxRipCmdGroups[] =
  53. {
  54. CREATE_CMD_GROUP_ENTRY( GROUP_ADD, g_IpxRipAddCmdTable ),
  55. CREATE_CMD_GROUP_ENTRY( GROUP_DELETE, g_IpxRipDelCmdTable ),
  56. CREATE_CMD_GROUP_ENTRY( GROUP_SET, g_IpxRipSetCmdTable ),
  57. CREATE_CMD_GROUP_ENTRY( GROUP_SHOW, g_IpxRipShowCmdTable )
  58. };
  59. ULONG g_ulIpxRipNumGroups =
  60. sizeof( g_IpxRipCmdGroups ) / sizeof( CMD_GROUP_ENTRY );
  61. //
  62. // functions to handle top level functions
  63. //
  64. DWORD
  65. HandleIpxRipDump(
  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_RIP_DUMP_HEADER);
  81. DisplayMessageT( DMP_IPX_RIP_HEADER );
  82. ShowRipGl(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. ShowRipIf( 1, argv, (HANDLE)-1 );
  116. ShowRipFlt( 1, argv, (HANDLE)-1 );
  117. }
  118. }
  119. DisplayMessageT( DMP_IPX_RIP_FOOTER );
  120. DisplayIPXMessage (g_hModule, MSG_IPX_RIP_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 RIP Filter add/del/set/show
  133. //
  134. DWORD
  135. HandleIpxRipAddFilter(
  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 CreateRipFlt(
  146. dwArgCount - dwCurrentIndex, ppwcArguments + dwCurrentIndex
  147. );
  148. }
  149. DWORD
  150. HandleIpxRipDelFilter(
  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 DeleteRipFlt(
  161. dwArgCount - dwCurrentIndex, ppwcArguments + dwCurrentIndex
  162. );
  163. }
  164. DWORD
  165. HandleIpxRipSetFilter(
  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 SetRipFlt(
  176. dwArgCount - dwCurrentIndex, ppwcArguments + dwCurrentIndex
  177. );
  178. }
  179. DWORD
  180. HandleIpxRipShowFilter(
  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 ShowRipFlt(
  191. dwArgCount - dwCurrentIndex, ppwcArguments + dwCurrentIndex, NULL
  192. );
  193. }
  194. DWORD
  195. HandleIpxRipSetInterface(
  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 SetRipIf(
  206. dwArgCount - dwCurrentIndex, ppwcArguments + dwCurrentIndex
  207. );
  208. }
  209. DWORD
  210. HandleIpxRipShowInterface(
  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 ShowRipIf(
  221. dwArgCount - dwCurrentIndex, ppwcArguments + dwCurrentIndex, NULL
  222. );
  223. }
  224. DWORD
  225. HandleIpxRipSetGlobal(
  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 SetRipGl(
  236. dwArgCount - dwCurrentIndex, ppwcArguments + dwCurrentIndex
  237. );
  238. }
  239. DWORD
  240. HandleIpxRipShowGlobal(
  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 ShowRipGl(
  251. dwArgCount - dwCurrentIndex, ppwcArguments + dwCurrentIndex, NULL
  252. );
  253. }
  254. DWORD
  255. IpxRipDump(
  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 HandleIpxRipDump(pwszRouter, ppwcArguments, dwArgCount,
  265. 0, 0, pvData, NULL);
  266. }