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.

380 lines
8.4 KiB

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