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.

260 lines
9.0 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. services.c
  5. Abstract:
  6. IPX Router Console Monitoring and Configuration tool.
  7. Service Table monitoring.
  8. Author:
  9. Vadim Eydelman 06/07/1996
  10. --*/
  11. #include "precomp.h"
  12. #pragma hdrstop
  13. DWORD
  14. APIENTRY
  15. HelpService (
  16. IN int argc,
  17. IN WCHAR *argv[]
  18. )
  19. {
  20. DisplayIPXMessage (g_hModule, MSG_IPX_HELP_SERVICE);
  21. return 0;
  22. }
  23. DWORD
  24. APIENTRY
  25. ShowService (
  26. IN int argc,
  27. IN WCHAR *argv[]
  28. )
  29. {
  30. DWORD rc;
  31. if (g_hMIBServer)
  32. {
  33. IPX_MIB_GET_INPUT_DATA MibGetInputData;
  34. PIPX_SERVICE pSv;
  35. DWORD sz;
  36. MibGetInputData.TableId = IPX_SERV_TABLE;
  37. if (argc <= 2)
  38. {
  39. if (argc > 0)
  40. {
  41. ULONG val;
  42. UINT n;
  43. if ( (swscanf (argv[0], L"%4x%n", &val, &n) == 1)
  44. && (n == wcslen (argv[0])))
  45. {
  46. MibGetInputData.MibIndex.ServicesTableIndex.ServiceType = (USHORT)val;
  47. if (argc > 1)
  48. {
  49. UINT count;
  50. count = wcstombs(
  51. MibGetInputData.MibIndex.ServicesTableIndex.ServiceName,
  52. argv[1],
  53. sizeof (MibGetInputData.MibIndex.ServicesTableIndex.ServiceName)
  54. );
  55. if ((count > 0) &&
  56. (count < sizeof (MibGetInputData.MibIndex.ServicesTableIndex.ServiceName)))
  57. {
  58. rc = MprAdminMIBEntryGet(
  59. g_hMIBServer, PID_IPX, IPX_PROTOCOL_BASE, &MibGetInputData,
  60. sizeof(IPX_MIB_GET_INPUT_DATA), (LPVOID * ) & pSv, &sz
  61. );
  62. if (rc == NO_ERROR && pSv)
  63. {
  64. WCHAR InterfaceName[ MAX_INTERFACE_NAME_LEN + 1 ];
  65. WCHAR IfName[ MAX_INTERFACE_NAME_LEN + 1 ];
  66. DWORD dwSize = sizeof(IfName);
  67. rc = GetIpxInterfaceName(
  68. g_hMIBServer, pSv->InterfaceIndex, InterfaceName
  69. );
  70. if (rc == NO_ERROR)
  71. {
  72. PWCHAR buffer;
  73. //======================================
  74. // Translate the Interface Name
  75. //======================================
  76. rc = IpmontrGetFriendlyNameFromIfName( InterfaceName, IfName, &dwSize );
  77. if ( rc != NO_ERROR )
  78. {
  79. DisplayIPXMessage(
  80. g_hModule, MSG_SERVICE_SCREEN_FMT, pSv->Server.Type,
  81. pSv->Server.Name, IfName, pSv->Server.HopCount,
  82. pSv->Server.Network[0], pSv->Server.Network[1],
  83. pSv->Server.Network[2], pSv->Server.Network[3],
  84. pSv->Server.Node[0], pSv->Server.Node[1],
  85. pSv->Server.Node[2], pSv->Server.Node[3],
  86. pSv->Server.Node[4], pSv->Server.Node[5],
  87. pSv->Server.Socket[0], pSv->Server.Socket[1],
  88. GetEnumString(
  89. g_hModule, pSv->Protocol,
  90. NUM_TOKENS_IN_TABLE( IpxProtocols ),
  91. IpxProtocols
  92. )
  93. );
  94. }
  95. }
  96. else
  97. {
  98. DisplayError( g_hModule, rc);
  99. }
  100. }
  101. else
  102. {
  103. DisplayError( g_hModule, rc);
  104. }
  105. MprAdminMIBBufferFree (pSv);
  106. }
  107. else
  108. {
  109. rc = ERROR_INVALID_PARAMETER;
  110. DisplayIPXMessage (g_hModule, MSG_IPX_HELP_SERVICE);
  111. }
  112. goto Exit;
  113. }
  114. else
  115. {
  116. MibGetInputData.MibIndex.ServicesTableIndex.ServiceName[0] = 0;
  117. rc = MprAdminMIBEntryGetNext(
  118. g_hMIBServer, PID_IPX, IPX_PROTOCOL_BASE,
  119. &MibGetInputData, sizeof(IPX_MIB_GET_INPUT_DATA),
  120. (LPVOID * ) & pSv, &sz
  121. );
  122. }
  123. }
  124. else
  125. {
  126. rc = ERROR_INVALID_PARAMETER;
  127. DisplayIPXMessage (g_hModule, MSG_IPX_HELP_SERVICE);
  128. goto Exit;
  129. }
  130. }
  131. else
  132. {
  133. rc = MprAdminMIBEntryGetFirst(
  134. g_hMIBServer, PID_IPX, IPX_PROTOCOL_BASE, &MibGetInputData,
  135. sizeof(IPX_MIB_GET_INPUT_DATA), (LPVOID * ) & pSv, &sz
  136. );
  137. }
  138. DisplayIPXMessage (g_hModule, MSG_SERVICE_TABLE_HDR);
  139. while ( (pSv)
  140. && (rc == NO_ERROR)
  141. && ((argc == 0)
  142. || (MibGetInputData.MibIndex.ServicesTableIndex.ServiceType
  143. == pSv->Server.Type)))
  144. {
  145. WCHAR InterfaceName[ MAX_INTERFACE_NAME_LEN + 1 ];
  146. WCHAR IfName[ MAX_INTERFACE_NAME_LEN + 1 ];
  147. DWORD rc1, dwSize = sizeof(IfName);
  148. rc1 = GetIpxInterfaceName(
  149. g_hMIBServer, pSv->InterfaceIndex, InterfaceName
  150. );
  151. if (rc1 == NO_ERROR)
  152. {
  153. PWCHAR buffer;
  154. rc1 = IpmontrGetFriendlyNameFromIfName( InterfaceName, IfName, &dwSize );
  155. if ( rc1 == NO_ERROR )
  156. {
  157. DisplayIPXMessage(
  158. g_hModule, MSG_SERVICE_TABLE_FMT,
  159. pSv->Server.Type, pSv->Server.Name,
  160. IfName, pSv->Server.HopCount,
  161. GetEnumString(
  162. g_hModule, pSv->Protocol,
  163. NUM_TOKENS_IN_TABLE( IpxProtocols ),
  164. IpxProtocols
  165. )
  166. );
  167. }
  168. }
  169. else
  170. {
  171. DisplayError( g_hModule, rc1);
  172. }
  173. MibGetInputData.MibIndex.ServicesTableIndex.ServiceType = pSv->Server.Type;
  174. strncpy(
  175. MibGetInputData.MibIndex.ServicesTableIndex.ServiceName,
  176. pSv->Server.Name,
  177. sizeof (MibGetInputData.MibIndex.ServicesTableIndex.ServiceName)
  178. );
  179. MprAdminBufferFree (pSv);
  180. rc = MprAdminMIBEntryGetNext(
  181. g_hMIBServer, PID_IPX, IPX_PROTOCOL_BASE, &MibGetInputData,
  182. sizeof(IPX_MIB_GET_INPUT_DATA), (LPVOID * ) & pSv, &sz
  183. );
  184. }
  185. if (rc == NO_ERROR)
  186. {
  187. NOTHING;
  188. }
  189. else if (rc == ERROR_NO_MORE_ITEMS)
  190. {
  191. rc = NO_ERROR;
  192. }
  193. else
  194. {
  195. DisplayError( g_hModule, rc);
  196. }
  197. }
  198. else
  199. {
  200. DisplayIPXMessage (g_hModule, MSG_IPX_HELP_SERVICE);
  201. rc = ERROR_INVALID_PARAMETER;
  202. }
  203. }
  204. else
  205. {
  206. rc = ERROR_ROUTER_STOPPED;
  207. DisplayError( g_hModule, rc);
  208. }
  209. Exit:
  210. return rc ;
  211. }