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.

357 lines
8.2 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. ipxgl.c
  5. Abstract:
  6. IPX Router Console Monitoring and Configuration tool.
  7. IPX Global configuration.
  8. Author:
  9. Vadim Eydelman 06/07/1996
  10. --*/
  11. #include "precomp.h"
  12. #pragma hdrstop
  13. DWORD
  14. CfgSetIpxGlInfo (
  15. IN DWORD *pLogLevel OPTIONAL
  16. );
  17. DWORD
  18. AdmSetIpxGlInfo (
  19. IN DWORD *pLogLevel OPTIONAL
  20. );
  21. int APIENTRY
  22. ShowIpxGl(
  23. IN int argc,
  24. IN WCHAR *argv[],
  25. IN BOOL bDump
  26. )
  27. {
  28. DWORD rc;
  29. LPBYTE pGlBlock;
  30. DWORD sz;
  31. HANDLE hTrCfg = NULL;
  32. PWCHAR buffer = NULL;
  33. if ( g_hMprAdmin )
  34. {
  35. rc = MprAdminTransportGetInfo(
  36. g_hMprAdmin, PID_IPX, &pGlBlock, &sz,
  37. NULL, NULL
  38. );
  39. if ( rc == NO_ERROR ) { }
  40. else
  41. {
  42. goto GetFromCfg;
  43. }
  44. }
  45. else
  46. {
  47. GetFromCfg:
  48. rc = MprConfigTransportGetHandle( g_hMprConfig, PID_IPX, &hTrCfg );
  49. if ( rc == NO_ERROR )
  50. {
  51. rc = MprConfigTransportGetInfo(
  52. g_hMprConfig, hTrCfg, &pGlBlock, &sz, NULL, NULL, NULL
  53. );
  54. }
  55. }
  56. if ( rc == NO_ERROR )
  57. {
  58. PIPX_TOC_ENTRY pIpxGlToc;
  59. pIpxGlToc = GetIPXTocEntry (
  60. (PIPX_INFO_BLOCK_HEADER)pGlBlock,
  61. IPX_GLOBAL_INFO_TYPE
  62. );
  63. if ( pIpxGlToc != NULL )
  64. {
  65. PIPX_GLOBAL_INFO pIpxGlInfo;
  66. PWCHAR buffer;
  67. pIpxGlInfo = (PIPX_GLOBAL_INFO) (pGlBlock+pIpxGlToc->Offset);
  68. buffer = GetEnumString(
  69. g_hModule, pIpxGlInfo->EventLogMask,
  70. NUM_VALUES_IN_TABLE( LogLevels ), LogLevels
  71. );
  72. if ( bDump )
  73. {
  74. DisplayIPXMessage (g_hModule, MSG_IPX_DUMP_GLOBAL_HEADER);
  75. DisplayMessageT( DMP_IPX_SET_GLOBAL, buffer );
  76. }
  77. else
  78. {
  79. DisplayIPXMessage(
  80. g_hModule, MSG_IPX_GLOBAL_FMT, buffer
  81. );
  82. }
  83. }
  84. else
  85. {
  86. DisplayIPXMessage (g_hModule, MSG_ROUTER_INFO_CORRUPTED);
  87. rc = ERROR_INVALID_DATA;
  88. }
  89. if (hTrCfg!=NULL)
  90. {
  91. MprConfigBufferFree (pGlBlock);
  92. }
  93. else
  94. {
  95. MprAdminBufferFree (pGlBlock);
  96. }
  97. }
  98. else if (!bDump)
  99. {
  100. DisplayError( g_hModule, rc);
  101. }
  102. return rc;
  103. }
  104. int APIENTRY
  105. SetIpxGl (
  106. IN int argc,
  107. IN WCHAR *argv[]
  108. )
  109. {
  110. DWORD rc;
  111. if ( argc >= 1 )
  112. {
  113. int i;
  114. unsigned n;
  115. PWCHAR buffer;
  116. DWORD logLevel;
  117. DWORD *pLogLevel = NULL;
  118. TOKEN_VALUE LogLevel[] =
  119. {
  120. { VAL_NONE, 0 },
  121. { VAL_ERRORS_ONLY, EVENTLOG_ERROR_TYPE },
  122. { VAL_ERRORS_AND_WARNINGS, EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE },
  123. { VAL_MAXINFO,
  124. EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE }
  125. };
  126. for ( i = 0; i < argc; i++ )
  127. {
  128. if ( !_wcsicmp( argv[i], TOKEN_LOGLEVEL ) )
  129. {
  130. if ( ( pLogLevel == NULL ) && ( i < argc - 1 ) &&
  131. !MatchEnumTag(
  132. g_hModule, argv[ i + 1 ], NUM_TOKENS_IN_TABLE( LogLevel ),
  133. LogLevel, &logLevel ) )
  134. {
  135. i += 1;
  136. pLogLevel = &logLevel;
  137. }
  138. else
  139. {
  140. break;
  141. }
  142. }
  143. else if ( pLogLevel == NULL )
  144. {
  145. if ( !MatchEnumTag(
  146. g_hModule, argv[ i ], NUM_TOKENS_IN_TABLE( LogLevel ),
  147. LogLevel, &logLevel ) )
  148. {
  149. pLogLevel = &logLevel;
  150. }
  151. else
  152. {
  153. break;
  154. }
  155. }
  156. }
  157. if ( i == argc )
  158. {
  159. rc = CfgSetIpxGlInfo( pLogLevel );
  160. if ( rc == NO_ERROR )
  161. {
  162. if ( g_hMprAdmin )
  163. {
  164. AdmSetIpxGlInfo( pLogLevel );
  165. }
  166. }
  167. }
  168. else
  169. {
  170. rc = ERROR_INVALID_SYNTAX;
  171. }
  172. }
  173. else
  174. {
  175. rc = ERROR_INVALID_SYNTAX;
  176. }
  177. return rc;
  178. }
  179. DWORD
  180. CfgSetIpxGlInfo (
  181. IN DWORD *pLogLevel OPTIONAL
  182. )
  183. {
  184. DWORD rc;
  185. HANDLE hTrCfg;
  186. rc = MprConfigTransportGetHandle( g_hMprConfig, PID_IPX, &hTrCfg );
  187. if ( rc == NO_ERROR )
  188. {
  189. DWORD sz;
  190. LPBYTE pGlBlock;
  191. rc = MprConfigTransportGetInfo(
  192. g_hMprConfig, hTrCfg, &pGlBlock, &sz, NULL, NULL, NULL
  193. );
  194. if (rc==NO_ERROR)
  195. {
  196. PIPX_TOC_ENTRY pIpxGlToc;
  197. pIpxGlToc = GetIPXTocEntry (
  198. (PIPX_INFO_BLOCK_HEADER)pGlBlock,
  199. IPX_GLOBAL_INFO_TYPE
  200. );
  201. if (pIpxGlToc!=NULL)
  202. {
  203. PIPX_GLOBAL_INFO pIpxGlInfo;
  204. pIpxGlInfo = (PIPX_GLOBAL_INFO) (pGlBlock+pIpxGlToc->Offset);
  205. if ( pLogLevel )
  206. {
  207. pIpxGlInfo->EventLogMask = *pLogLevel;
  208. }
  209. rc = MprConfigTransportSetInfo(
  210. g_hMprConfig, hTrCfg, pGlBlock, sz, NULL, 0, NULL
  211. );
  212. if (rc==NO_ERROR)
  213. {
  214. DisplayIPXMessage (g_hModule, MSG_IPXGL_SET_CFG);
  215. }
  216. else
  217. {
  218. DisplayError( g_hModule, rc);
  219. }
  220. }
  221. else
  222. {
  223. DisplayIPXMessage (g_hModule, MSG_ROUTER_INFO_CORRUPTED);
  224. rc = ERROR_INVALID_DATA;
  225. }
  226. MprConfigBufferFree (pGlBlock);
  227. }
  228. else
  229. {
  230. DisplayError( g_hModule, rc);
  231. }
  232. }
  233. else
  234. {
  235. DisplayError( g_hModule, rc);
  236. }
  237. return rc;
  238. }
  239. DWORD
  240. AdmSetIpxGlInfo (
  241. IN DWORD *pLogLevel OPTIONAL
  242. )
  243. {
  244. DWORD rc;
  245. LPBYTE pGlBlock;
  246. DWORD sz;
  247. rc = MprAdminTransportGetInfo(
  248. g_hMprAdmin, PID_IPX, &pGlBlock, &sz, NULL, NULL
  249. );
  250. if (rc==NO_ERROR)
  251. {
  252. PIPX_TOC_ENTRY pIpxGlToc;
  253. pIpxGlToc = GetIPXTocEntry (
  254. (PIPX_INFO_BLOCK_HEADER)pGlBlock,
  255. IPX_GLOBAL_INFO_TYPE
  256. );
  257. if (pIpxGlToc!=NULL)
  258. {
  259. PIPX_GLOBAL_INFO pIpxGlInfo;
  260. pIpxGlInfo = (PIPX_GLOBAL_INFO) (pGlBlock+pIpxGlToc->Offset);
  261. if (pLogLevel)
  262. {
  263. pIpxGlInfo->EventLogMask = *pLogLevel;
  264. }
  265. rc = MprAdminTransportSetInfo(
  266. g_hMprAdmin, PID_IPX, pGlBlock, sz, NULL, 0
  267. );
  268. if (rc==NO_ERROR)
  269. {
  270. DisplayIPXMessage (g_hModule,
  271. MSG_IPXGL_SET_ADM);
  272. }
  273. else
  274. {
  275. DisplayError( g_hModule, rc);
  276. }
  277. }
  278. else
  279. {
  280. DisplayIPXMessage (g_hModule, MSG_ROUTER_INFO_CORRUPTED);
  281. rc = ERROR_INVALID_DATA;
  282. }
  283. MprAdminBufferFree (pGlBlock);
  284. }
  285. else
  286. {
  287. DisplayError( g_hModule, rc);
  288. }
  289. return rc;
  290. }