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.

1652 lines
51 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. sapifs.c
  5. Abstract:
  6. IPX Router Console Monitoring and Configuration tool.
  7. SAP Interface configuration and monitoring.
  8. Author:
  9. Vadim Eydelman 06/07/1996
  10. --*/
  11. #include "precomp.h"
  12. #pragma hdrstop
  13. DWORD
  14. MIBGetSapIf(
  15. PWCHAR InterfaceNamew,
  16. HANDLE hFile
  17. );
  18. DWORD
  19. CfgGetSapIf (
  20. PWCHAR InterfaceNameW,
  21. HANDLE hFile
  22. );
  23. DWORD
  24. MIBEnumSapIfs (
  25. VOID
  26. );
  27. DWORD
  28. CfgEnumSapIfs (
  29. VOID
  30. );
  31. DWORD
  32. CfgSetSapIf (
  33. LPWSTR InterfaceNameW,
  34. PULONG pAdminState OPTIONAL,
  35. PULONG pAdvertise OPTIONAL,
  36. PULONG pListen OPTIONAL,
  37. PULONG pReply OPTIONAL,
  38. PULONG pUpdateMode OPTIONAL,
  39. PULONG pInterval OPTIONAL,
  40. PULONG pAgeMultiplier OPTIONAL
  41. );
  42. DWORD
  43. AdmSetSapIf (
  44. LPWSTR InterfaceNameW,
  45. PULONG pAdminState OPTIONAL,
  46. PULONG pUpdateMode OPTIONAL,
  47. PULONG pInterval OPTIONAL,
  48. PULONG pAdvertise OPTIONAL,
  49. PULONG pListen OPTIONAL,
  50. PULONG pReply OPTIONAL,
  51. PULONG pAgeMultiplier OPTIONAL
  52. );
  53. DWORD
  54. GetSapClientIf (
  55. PWCHAR InterfaceNameW,
  56. UINT msg,
  57. HANDLE hFile
  58. );
  59. DWORD
  60. APIENTRY
  61. HelpSapIf (
  62. IN int argc,
  63. IN WCHAR *argv[]
  64. )
  65. {
  66. DisplayMessage (g_hModule, HLP_IPX_SAPIF);
  67. return 0;
  68. }
  69. DWORD
  70. APIENTRY
  71. ShowSapIf (
  72. IN int argc,
  73. IN WCHAR *argv[],
  74. IN HANDLE hFile
  75. )
  76. {
  77. WCHAR IfName[ MAX_INTERFACE_NAME_LEN + 1 ];
  78. DWORD rc, dwSize = sizeof(IfName);
  79. if (argc < 1)
  80. {
  81. if (g_hMIBServer)
  82. {
  83. rc = MIBEnumSapIfs ();
  84. if (rc == NO_ERROR)
  85. {
  86. rc = GetSapClientIf (
  87. VAL_DIALINCLIENT,
  88. MSG_CLIENT_SAPIF_MIB_TABLE_FMT,
  89. NULL
  90. );
  91. }
  92. else
  93. {
  94. goto EnumerateThroughCfg;
  95. }
  96. }
  97. else
  98. {
  99. EnumerateThroughCfg:
  100. rc = CfgEnumSapIfs ();
  101. if (rc == NO_ERROR)
  102. {
  103. rc = GetSapClientIf(
  104. VAL_DIALINCLIENT,
  105. MSG_CLIENT_SAPIF_CFG_TABLE_FMT,
  106. NULL
  107. );
  108. }
  109. }
  110. }
  111. else
  112. {
  113. unsigned count;
  114. #define InterfaceNameW argv[0]
  115. count = wcslen( InterfaceNameW );
  116. if ( !_wcsicmp( argv[0], VAL_DIALINCLIENT ) )
  117. {
  118. rc = GetSapClientIf(
  119. VAL_DIALINCLIENT, MSG_CLIENT_SAPIF_CFG_SCREEN_FMT, hFile
  120. );
  121. }
  122. else if ((count > 0) && (count <= MAX_INTERFACE_NAME_LEN))
  123. {
  124. if (g_hMIBServer)
  125. {
  126. //======================================
  127. // Translate the Interface Name
  128. //======================================
  129. rc = IpmontrGetIfNameFromFriendlyName(
  130. InterfaceNameW, IfName, &dwSize
  131. );
  132. if ( rc == NO_ERROR )
  133. {
  134. rc = MIBGetSapIf (IfName, hFile);
  135. if (rc != NO_ERROR)
  136. {
  137. goto GetIfFromCfg;
  138. }
  139. }
  140. else
  141. {
  142. if (!hFile) { DisplayError( g_hModule, rc ); }
  143. }
  144. }
  145. else
  146. {
  147. GetIfFromCfg:
  148. //======================================
  149. // Translate the Interface Name
  150. //======================================
  151. rc = IpmontrGetIfNameFromFriendlyName(
  152. InterfaceNameW, IfName, &dwSize
  153. );
  154. if ( rc == NO_ERROR )
  155. {
  156. rc = CfgGetSapIf (IfName, hFile);
  157. }
  158. else
  159. {
  160. if ( !hFile ) { DisplayError( g_hModule, rc ); }
  161. }
  162. }
  163. }
  164. else
  165. {
  166. if ( !hFile ) { DisplayIPXMessage (g_hModule, MSG_INVALID_INTERFACE_NAME); }
  167. rc = ERROR_INVALID_PARAMETER;
  168. }
  169. }
  170. return rc;
  171. #undef InterfaceNameW
  172. }
  173. DWORD
  174. APIENTRY
  175. SetSapIf (
  176. IN int argc,
  177. IN WCHAR *argv[]
  178. )
  179. {
  180. LPWSTR InterfaceNameW;
  181. WCHAR IfName[ MAX_INTERFACE_NAME_LEN + 1 ];
  182. DWORD rc, dwSize = sizeof(IfName);
  183. if ( argc >= 1 )
  184. {
  185. unsigned count;
  186. BOOLEAN client = FALSE;
  187. #define InterfaceNameW argv[0]
  188. if ( !_wcsicmp( argv[0], VAL_DIALINCLIENT ) )
  189. {
  190. client = TRUE;
  191. }
  192. else
  193. {
  194. count = wcslen (InterfaceNameW);
  195. }
  196. if (client || ((count > 0) && (count <= MAX_INTERFACE_NAME_LEN)))
  197. {
  198. int i;
  199. unsigned n;
  200. ULONG adminState, updateMode, interval, ageMultiplier,
  201. advertise, listen, reply;
  202. PULONG pAdminState = NULL, pUpdateMode = NULL, pInterval = NULL,
  203. pAgeMultiplier = NULL, pAdvertise = NULL, pListen = NULL,
  204. pReply = NULL;
  205. for (i = 1; i < argc; i++)
  206. {
  207. if ( !_wcsicmp( argv[i], TOKEN_ADMINSTATE))
  208. {
  209. if ( (pAdminState == NULL) && (i < argc - 1) &&
  210. !MatchEnumTag(g_hModule, argv[i+1], NUM_TOKENS_IN_TABLE( AdminStates ),
  211. AdminStates, &adminState))
  212. {
  213. i += 1;
  214. pAdminState = &adminState;
  215. continue;
  216. }
  217. else
  218. {
  219. break;
  220. }
  221. }
  222. if ( !_wcsicmp( argv[i], TOKEN_ADVERTISE ))
  223. {
  224. if ( (pAdvertise == NULL) && (i < argc - 1)&&
  225. !MatchEnumTag (g_hModule, argv[i+1], NUM_TOKENS_IN_TABLE( AdminStates ),
  226. AdminStates, &advertise))
  227. {
  228. i += 1;
  229. pAdvertise = &advertise;
  230. continue;
  231. }
  232. else
  233. {
  234. break;
  235. }
  236. }
  237. if ( !_wcsicmp (argv[i], TOKEN_LISTEN ))
  238. {
  239. if ( (pListen == NULL) && (i < argc - 1) &&
  240. !MatchEnumTag (g_hModule, argv[i+1], NUM_TOKENS_IN_TABLE( AdminStates ),
  241. AdminStates, &listen))
  242. {
  243. i += 1;
  244. pListen = &listen;
  245. continue;
  246. }
  247. else
  248. {
  249. break;
  250. }
  251. }
  252. if ( !_wcsicmp (argv[i], TOKEN_GNSREPLY ))
  253. {
  254. if ( (pReply == NULL) && (i < argc - 1) &&
  255. !MatchEnumTag (g_hModule, argv[i+1], NUM_TOKENS_IN_TABLE( AdminStates ),
  256. AdminStates, &reply))
  257. {
  258. i += 1;
  259. pReply = &reply;
  260. continue;
  261. }
  262. else
  263. {
  264. break;
  265. }
  266. }
  267. if ( !_wcsicmp (argv[i], TOKEN_UPDATEMODE ))
  268. {
  269. if ( (pUpdateMode == NULL) && (i < argc - 1) &&
  270. !MatchEnumTag (g_hModule, argv[i+1], NUM_TOKENS_IN_TABLE( UpdateModes ),
  271. UpdateModes, &updateMode))
  272. {
  273. i += 1;
  274. pUpdateMode = &updateMode;
  275. continue;
  276. }
  277. else
  278. {
  279. break;
  280. }
  281. }
  282. if ( !_wcsicmp (argv[i], TOKEN_INTERVAL ))
  283. {
  284. if ((pInterval == NULL)
  285. && (i < argc - 1)
  286. && (swscanf (argv[i+1], L"%ld%n", &interval, &n) == 1)
  287. && (n == wcslen(argv[i+1])))
  288. {
  289. i += 1;
  290. pInterval = &interval;
  291. continue;
  292. }
  293. else
  294. {
  295. break;
  296. }
  297. }
  298. if ( !_wcsicmp (argv[i], TOKEN_AGEMULTIPLIER ))
  299. {
  300. if ((pAgeMultiplier == NULL)
  301. && (i < argc - 1)
  302. && (swscanf (argv[i+1], L"%ld%n", &ageMultiplier, &n) == 1)
  303. && (n == wcslen(argv[i+1])))
  304. {
  305. i += 1;
  306. pAgeMultiplier = &ageMultiplier;
  307. continue;
  308. }
  309. else
  310. {
  311. break;
  312. }
  313. }
  314. if (pAdminState == NULL)
  315. {
  316. if ( !MatchEnumTag (g_hModule, argv[ i ], NUM_TOKENS_IN_TABLE( AdminStates ),
  317. AdminStates, &adminState))
  318. {
  319. pAdminState = &adminState;
  320. }
  321. else
  322. {
  323. break;
  324. }
  325. }
  326. else if (pAdvertise == NULL)
  327. {
  328. if ( !MatchEnumTag (g_hModule, argv[ i ], NUM_TOKENS_IN_TABLE( AdminStates ),
  329. AdminStates, &advertise))
  330. {
  331. pAdvertise = &advertise;
  332. }
  333. else
  334. {
  335. break;
  336. }
  337. }
  338. else if (pListen == NULL)
  339. {
  340. if ( !MatchEnumTag (g_hModule, argv[ i ], NUM_TOKENS_IN_TABLE( AdminStates ),
  341. AdminStates, &listen))
  342. {
  343. pListen = &listen;
  344. }
  345. else
  346. {
  347. break;
  348. }
  349. }
  350. else if (pReply == NULL)
  351. {
  352. if ( !MatchEnumTag (g_hModule, argv[ i ], NUM_TOKENS_IN_TABLE( AdminStates ),
  353. AdminStates, &reply))
  354. {
  355. pReply = &reply;
  356. }
  357. else
  358. {
  359. break;
  360. }
  361. }
  362. else if (pUpdateMode == NULL)
  363. {
  364. if ( !MatchEnumTag (g_hModule, argv[ i ], NUM_TOKENS_IN_TABLE( UpdateModes ),
  365. UpdateModes, &updateMode))
  366. {
  367. pUpdateMode = &updateMode;
  368. }
  369. else
  370. {
  371. break;
  372. }
  373. }
  374. else if (pInterval == NULL)
  375. {
  376. if ((swscanf (argv[i], L"%ld%n", &interval, &n) == 1)
  377. && (n == wcslen(argv[i])))
  378. {
  379. pInterval = &interval;
  380. }
  381. else
  382. {
  383. break;
  384. }
  385. }
  386. else if (pAgeMultiplier == NULL)
  387. {
  388. if ((swscanf (argv[i], L"%ld%n", &ageMultiplier, &n) == 1)
  389. && (n == wcslen(argv[i])))
  390. {
  391. pAgeMultiplier = &ageMultiplier;
  392. }
  393. else
  394. {
  395. break;
  396. }
  397. }
  398. else
  399. {
  400. break;
  401. }
  402. }
  403. if ( i == argc )
  404. {
  405. if (!client)
  406. {
  407. DWORD rc2;
  408. //======================================
  409. // Translate the Interface Name
  410. //======================================
  411. rc = IpmontrGetIfNameFromFriendlyName(
  412. InterfaceNameW, IfName, &dwSize
  413. );
  414. if ( rc == NO_ERROR )
  415. {
  416. rc2 = CfgSetSapIf(
  417. IfName, pAdminState, pAdvertise, pListen, pReply,
  418. pUpdateMode, pInterval, pAgeMultiplier
  419. );
  420. if (rc2 == NO_ERROR)
  421. {
  422. if (g_hMprAdmin)
  423. {
  424. rc = AdmSetSapIf(
  425. IfName, pAdminState, pAdvertise, pListen,
  426. pReply, pUpdateMode, pInterval,
  427. pAgeMultiplier
  428. );
  429. }
  430. }
  431. else
  432. {
  433. rc = rc2;
  434. }
  435. }
  436. else
  437. {
  438. DisplayError( g_hModule, rc );
  439. }
  440. }
  441. else
  442. {
  443. rc = CfgSetSapIf(
  444. NULL, pAdminState, pAdvertise, pListen, pReply,
  445. pUpdateMode, pInterval, pAgeMultiplier
  446. );
  447. if (rc == NO_ERROR)
  448. {
  449. if (g_hMprAdmin)
  450. {
  451. rc = AdmSetSapIf(
  452. NULL, pAdminState, pAdvertise, pListen, pReply,
  453. pUpdateMode, pInterval, pAgeMultiplier
  454. );
  455. }
  456. }
  457. }
  458. }
  459. else
  460. {
  461. DisplayMessage (g_hModule, HLP_IPX_SAPIF);
  462. rc = ERROR_INVALID_PARAMETER;
  463. }
  464. }
  465. else
  466. {
  467. DisplayIPXMessage (g_hModule, MSG_INVALID_INTERFACE_NAME);
  468. rc = ERROR_INVALID_PARAMETER;
  469. }
  470. }
  471. else
  472. {
  473. DisplayMessage (g_hModule, HLP_IPX_SAPIF);
  474. rc = ERROR_INVALID_PARAMETER;
  475. }
  476. return rc;
  477. #undef InterfaceNameW
  478. }
  479. DWORD
  480. MIBGetSapIf(
  481. PWCHAR InterfaceNameW,
  482. HANDLE hFile
  483. )
  484. {
  485. DWORD rc;
  486. DWORD sz;
  487. SAP_MIB_GET_INPUT_DATA MibGetInputData;
  488. PSAP_INTERFACE pIf;
  489. WCHAR IfName[ MAX_INTERFACE_NAME_LEN + 1 ];
  490. DWORD dwSize = sizeof(IfName);
  491. MibGetInputData.TableId = SAP_INTERFACE_TABLE;
  492. rc = GetIpxInterfaceIndex(
  493. g_hMIBServer, InterfaceNameW, &MibGetInputData.InterfaceIndex
  494. );
  495. if (rc == NO_ERROR)
  496. {
  497. rc = MprAdminMIBEntryGet(
  498. g_hMIBServer, PID_IPX, IPX_PROTOCOL_SAP, &MibGetInputData,
  499. sizeof(SAP_MIB_GET_INPUT_DATA), (LPVOID * ) & pIf, &sz
  500. );
  501. if (rc == NO_ERROR)
  502. {
  503. PWCHAR buffer[6];
  504. DWORD i;
  505. //======================================
  506. // Translate the Interface Name
  507. //======================================
  508. rc = IpmontrGetFriendlyNameFromIfName(
  509. InterfaceNameW, IfName, &dwSize
  510. );
  511. if ( rc == NO_ERROR )
  512. {
  513. buffer[ 0 ] = GetEnumString(
  514. g_hModule, pIf->SapIfInfo.AdminState,
  515. NUM_TOKENS_IN_TABLE( AdminStates ),
  516. AdminStates
  517. );
  518. buffer[ 1 ] = GetEnumString(
  519. g_hModule, pIf->SapIfInfo.Supply,
  520. NUM_TOKENS_IN_TABLE( AdminStates ),
  521. AdminStates
  522. );
  523. buffer[ 2 ] = GetEnumString(
  524. g_hModule, pIf->SapIfInfo.Listen,
  525. NUM_TOKENS_IN_TABLE( AdminStates ),
  526. AdminStates
  527. );
  528. buffer[ 3 ] = GetEnumString(
  529. g_hModule, pIf->SapIfInfo.GetNearestServerReply,
  530. NUM_TOKENS_IN_TABLE( AdminStates ),
  531. AdminStates
  532. );
  533. buffer[ 4 ] = GetEnumString(
  534. g_hModule, pIf->SapIfInfo.UpdateMode,
  535. NUM_TOKENS_IN_TABLE( UpdateModes ),
  536. UpdateModes
  537. );
  538. buffer[ 5 ] = GetEnumString(
  539. g_hModule, pIf->SapIfStats.SapIfOperState,
  540. NUM_TOKENS_IN_TABLE( OperStates ),
  541. OperStates
  542. );
  543. if ( buffer [ 0 ] && buffer[ 1 ] && buffer[ 2 ] &&
  544. buffer[ 3 ] && buffer[ 4 ] && buffer[ 5 ] )
  545. {
  546. if ( hFile )
  547. {
  548. DisplayMessageT(
  549. DMP_IPX_SAP_SET_INTERFACE, IfName, buffer[ 0 ],
  550. buffer[ 1 ], buffer[ 2 ], buffer[ 3 ],
  551. buffer[ 4 ], pIf->SapIfInfo.PeriodicUpdateInterval,
  552. pIf->SapIfInfo.AgeIntervalMultiplier
  553. );
  554. }
  555. else
  556. {
  557. DisplayIPXMessage(
  558. g_hModule, MSG_SAPIF_MIB_SCREEN_FMT,
  559. IfName, buffer[ 0 ], buffer[ 1 ],
  560. buffer[ 2 ], buffer[ 3 ], buffer[ 4 ],
  561. pIf->SapIfInfo.PeriodicUpdateInterval,
  562. pIf->SapIfInfo.AgeIntervalMultiplier,
  563. buffer[5],
  564. pIf->SapIfStats.SapIfInputPackets,
  565. pIf->SapIfStats.SapIfOutputPackets
  566. );
  567. }
  568. }
  569. else
  570. {
  571. rc = ERROR_NOT_ENOUGH_MEMORY;
  572. if ( !hFile ) { DisplayError( g_hModule, rc ); }
  573. }
  574. MprAdminMIBBufferFree (pIf);
  575. }
  576. else
  577. {
  578. if ( !hFile ) { DisplayError( g_hModule, rc ); }
  579. }
  580. }
  581. else
  582. {
  583. if ( !hFile ) { DisplayError( g_hModule, rc); }
  584. }
  585. }
  586. else
  587. {
  588. if ( !hFile ) { DisplayError( g_hModule, rc); }
  589. }
  590. return rc;
  591. }
  592. DWORD
  593. CfgGetSapIf (
  594. PWCHAR InterfaceNameW,
  595. HANDLE hFile
  596. )
  597. {
  598. DWORD rc;
  599. DWORD sz;
  600. HANDLE hIfCfg;
  601. WCHAR IfName[ MAX_INTERFACE_NAME_LEN + 1 ];
  602. DWORD dwSize = sizeof(IfName);
  603. rc = MprConfigInterfaceGetHandle(
  604. g_hMprConfig, InterfaceNameW, &hIfCfg
  605. );
  606. if (rc == NO_ERROR)
  607. {
  608. HANDLE hIfTrCfg;
  609. rc = MprConfigInterfaceTransportGetHandle (
  610. g_hMprConfig, hIfCfg, PID_IPX, &hIfTrCfg
  611. );
  612. if (rc == NO_ERROR)
  613. {
  614. LPBYTE pIfBlock;
  615. rc = MprConfigInterfaceTransportGetInfo (
  616. g_hMprConfig, hIfCfg, hIfTrCfg, &pIfBlock, &sz
  617. );
  618. if (rc == NO_ERROR)
  619. {
  620. PIPX_TOC_ENTRY pSapToc;
  621. pSapToc = GetIPXTocEntry (
  622. (PIPX_INFO_BLOCK_HEADER)pIfBlock,
  623. IPX_PROTOCOL_SAP
  624. );
  625. if (pSapToc != NULL)
  626. {
  627. PSAP_IF_CONFIG pSapCfg;
  628. PWCHAR buffer[5];
  629. DWORD i;
  630. pSapCfg = (PSAP_IF_CONFIG)
  631. (pIfBlock + pSapToc->Offset);
  632. //======================================
  633. // Translate the Interface Name
  634. //======================================
  635. rc = IpmontrGetFriendlyNameFromIfName(
  636. InterfaceNameW, IfName, &dwSize
  637. );
  638. if ( rc == NO_ERROR )
  639. {
  640. buffer[ 0 ] = GetEnumString(
  641. g_hModule, pSapCfg->SapIfInfo.AdminState,
  642. NUM_TOKENS_IN_TABLE( AdminStates ),
  643. AdminStates
  644. );
  645. buffer[ 1 ] = GetEnumString(
  646. g_hModule, pSapCfg->SapIfInfo.Supply,
  647. NUM_TOKENS_IN_TABLE( AdminStates ),
  648. AdminStates
  649. );
  650. buffer[ 2 ] = GetEnumString(
  651. g_hModule, pSapCfg->SapIfInfo.Listen,
  652. NUM_TOKENS_IN_TABLE( AdminStates ),
  653. AdminStates
  654. );
  655. buffer[ 3 ] = GetEnumString(
  656. g_hModule, pSapCfg->SapIfInfo.GetNearestServerReply,
  657. NUM_TOKENS_IN_TABLE( AdminStates ),
  658. AdminStates
  659. );
  660. buffer[ 4 ] = GetEnumString(
  661. g_hModule, pSapCfg->SapIfInfo.UpdateMode,
  662. NUM_TOKENS_IN_TABLE( UpdateModes ),
  663. UpdateModes
  664. );
  665. if ( buffer [ 0 ] && buffer[ 1 ] && buffer[ 2 ] &&
  666. buffer[ 3 ] && buffer[ 4 ] )
  667. {
  668. if ( hFile )
  669. {
  670. DisplayMessageT(
  671. DMP_IPX_SAP_SET_INTERFACE, IfName, buffer[ 0 ],
  672. buffer[ 1 ], buffer[ 2 ], buffer[ 3 ],
  673. buffer[ 4 ], pSapCfg->SapIfInfo.PeriodicUpdateInterval,
  674. pSapCfg->SapIfInfo.AgeIntervalMultiplier
  675. );
  676. }
  677. else
  678. {
  679. DisplayIPXMessage(
  680. g_hModule, MSG_SAPIF_CFG_SCREEN_FMT,
  681. IfName, buffer[0], buffer[1], buffer[2],
  682. buffer[3], buffer[4],
  683. pSapCfg->SapIfInfo.PeriodicUpdateInterval,
  684. pSapCfg->SapIfInfo.AgeIntervalMultiplier
  685. );
  686. }
  687. }
  688. else
  689. {
  690. rc = ERROR_NOT_ENOUGH_MEMORY;
  691. if ( !hFile ) { DisplayError( g_hModule, rc ); }
  692. }
  693. }
  694. else
  695. {
  696. if ( !hFile ) { DisplayError( g_hModule, rc ); }
  697. }
  698. }
  699. else
  700. {
  701. if ( !hFile ) { DisplayIPXMessage (g_hModule, MSG_INTERFACE_INFO_CORRUPTED); }
  702. rc = ERROR_INVALID_DATA;
  703. }
  704. }
  705. else
  706. {
  707. if ( !hFile ) { DisplayError( g_hModule, rc); }
  708. }
  709. }
  710. else
  711. {
  712. if ( !hFile ) { DisplayError( g_hModule, rc); }
  713. }
  714. }
  715. else
  716. {
  717. if ( !hFile ) { DisplayError( g_hModule, rc); }
  718. }
  719. return rc;
  720. }
  721. DWORD
  722. GetSapClientIf(
  723. PWCHAR InterfaceName,
  724. UINT msg,
  725. HANDLE hFile
  726. )
  727. {
  728. DWORD rc;
  729. LPBYTE pClBlock;
  730. HANDLE hTrCfg;
  731. DWORD sz, i;
  732. hTrCfg = NULL;
  733. if (g_hMprAdmin)
  734. {
  735. rc = MprAdminTransportGetInfo(
  736. g_hMprAdmin, PID_IPX, NULL, NULL, &pClBlock, &sz
  737. );
  738. if (rc == NO_ERROR)
  739. {
  740. NOTHING;
  741. }
  742. else
  743. {
  744. if ( !hFile ) { DisplayError( g_hModule, rc); }
  745. goto GetFromCfg;
  746. }
  747. }
  748. else
  749. {
  750. GetFromCfg:
  751. rc = MprConfigTransportGetHandle (
  752. g_hMprConfig, PID_IPX, &hTrCfg
  753. );
  754. if (rc == NO_ERROR)
  755. {
  756. rc = MprConfigTransportGetInfo (
  757. g_hMprConfig, hTrCfg, NULL, NULL, &pClBlock, &sz, NULL
  758. );
  759. if (rc == NO_ERROR)
  760. {
  761. NOTHING;
  762. }
  763. else
  764. {
  765. if ( !hFile ) { DisplayError( g_hModule, rc); }
  766. }
  767. }
  768. else
  769. {
  770. if ( !hFile ) { DisplayError( g_hModule, rc); }
  771. }
  772. }
  773. if (rc == NO_ERROR)
  774. {
  775. PIPX_TOC_ENTRY pSapToc;
  776. pSapToc = GetIPXTocEntry(
  777. (PIPX_INFO_BLOCK_HEADER)pClBlock,
  778. IPX_PROTOCOL_SAP
  779. );
  780. if (pSapToc != NULL)
  781. {
  782. PSAP_IF_CONFIG pSapCfg;
  783. PWCHAR buffer[5];
  784. pSapCfg = (PSAP_IF_CONFIG)
  785. (pClBlock + pSapToc->Offset);
  786. buffer[ 0 ] = GetEnumString(
  787. g_hModule, pSapCfg->SapIfInfo.AdminState,
  788. NUM_TOKENS_IN_TABLE( AdminStates ),
  789. AdminStates
  790. );
  791. buffer[ 1 ] = GetEnumString(
  792. g_hModule, pSapCfg->SapIfInfo.Supply,
  793. NUM_TOKENS_IN_TABLE( AdminStates ),
  794. AdminStates
  795. );
  796. buffer[ 2 ] = GetEnumString(
  797. g_hModule, pSapCfg->SapIfInfo.Listen,
  798. NUM_TOKENS_IN_TABLE( AdminStates ),
  799. AdminStates
  800. );
  801. buffer[ 3 ] = GetEnumString(
  802. g_hModule, pSapCfg->SapIfInfo.GetNearestServerReply,
  803. NUM_TOKENS_IN_TABLE( AdminStates ),
  804. AdminStates
  805. );
  806. buffer[ 4 ] = GetEnumString(
  807. g_hModule, pSapCfg->SapIfInfo.UpdateMode,
  808. NUM_TOKENS_IN_TABLE( UpdateModes ),
  809. UpdateModes
  810. );
  811. switch (msg)
  812. {
  813. case MSG_CLIENT_SAPIF_MIB_TABLE_FMT:
  814. case MSG_CLIENT_SAPIF_CFG_TABLE_FMT:
  815. if ( buffer[ 4 ] && buffer[ 0 ] )
  816. {
  817. DisplayIPXMessage(
  818. g_hModule, msg, InterfaceName, buffer[ 4 ], buffer[ 0 ]
  819. );
  820. }
  821. else
  822. {
  823. rc = ERROR_NOT_ENOUGH_MEMORY;
  824. if ( !hFile ) { DisplayError( g_hModule, rc ); }
  825. }
  826. break;
  827. case MSG_CLIENT_SAPIF_MIB_SCREEN_FMT:
  828. case MSG_CLIENT_SAPIF_CFG_SCREEN_FMT:
  829. if ( buffer[ 0 ] && buffer[ 1 ] && buffer[ 2 ] && buffer[ 3 ] &&
  830. buffer[ 4 ] )
  831. {
  832. if ( hFile )
  833. {
  834. DisplayMessageT(
  835. DMP_IPX_SAP_SET_INTERFACE, InterfaceName, buffer[ 0 ],
  836. buffer[ 1 ], buffer[ 2 ], buffer[ 3 ],
  837. buffer[ 4 ], pSapCfg->SapIfInfo.PeriodicUpdateInterval,
  838. pSapCfg->SapIfInfo.AgeIntervalMultiplier
  839. );
  840. }
  841. else
  842. {
  843. DisplayIPXMessage(
  844. g_hModule, msg, InterfaceName,
  845. buffer[0], buffer[1], buffer[2], buffer[3], buffer[4],
  846. pSapCfg->SapIfInfo.PeriodicUpdateInterval,
  847. pSapCfg->SapIfInfo.AgeIntervalMultiplier
  848. );
  849. }
  850. }
  851. else
  852. {
  853. rc = ERROR_NOT_ENOUGH_MEMORY;
  854. if ( !hFile ) { DisplayError( g_hModule, rc ); }
  855. }
  856. break;
  857. }
  858. }
  859. else
  860. {
  861. if ( !hFile ) { DisplayIPXMessage (g_hModule, MSG_INTERFACE_INFO_CORRUPTED); }
  862. rc = ERROR_INVALID_DATA;
  863. }
  864. if (hTrCfg != NULL)
  865. {
  866. MprConfigBufferFree (pClBlock);
  867. }
  868. else
  869. {
  870. MprAdminBufferFree (pClBlock);
  871. }
  872. }
  873. return rc;
  874. }
  875. PSAP_IF_CONFIG
  876. GetIpxSapInterface(
  877. HANDLE hIf,
  878. LPBYTE *pIfBlock
  879. )
  880. {
  881. DWORD dwSize;
  882. DWORD dwErr;
  883. PIPX_TOC_ENTRY pIpxToc;
  884. dwErr = MprAdminInterfaceTransportGetInfo(
  885. g_hMprAdmin, hIf, PID_IPX, pIfBlock, &dwSize
  886. );
  887. if (dwErr != NO_ERROR)
  888. {
  889. return NULL;
  890. }
  891. pIpxToc = GetIPXTocEntry ((PIPX_INFO_BLOCK_HEADER)(*pIfBlock), IPX_PROTOCOL_SAP);
  892. if (!pIpxToc)
  893. {
  894. return NULL;
  895. }
  896. return (PSAP_IF_CONFIG)((*pIfBlock) + (pIpxToc->Offset));
  897. }
  898. DWORD
  899. MIBEnumSapIfs (VOID)
  900. {
  901. PMPR_INTERFACE_0 IfList = NULL;
  902. DWORD dwErr = 0, dwRead, dwTot, i, j;
  903. PWCHAR buffer[3];
  904. LPBYTE buf = NULL;
  905. PSAP_IF_CONFIG pSapCfg;
  906. WCHAR IfName[ MAX_INTERFACE_NAME_LEN + 1 ];
  907. DWORD dwSize = sizeof(IfName);
  908. DisplayIPXMessage (g_hModule, MSG_SAPIF_MIB_TABLE_HDR);
  909. dwErr = MprAdminInterfaceEnum(
  910. g_hMprAdmin, 0, (unsigned char **) & IfList, MAXULONG,
  911. &dwRead, &dwTot, NULL
  912. );
  913. if (dwErr != NO_ERROR)
  914. {
  915. return dwErr;
  916. }
  917. for (i = 0; i < dwRead; i++)
  918. {
  919. if ((pSapCfg = GetIpxSapInterface(IfList[i].hInterface, &buf)) != NULL)
  920. {
  921. //======================================
  922. // Translate the Interface Name
  923. //======================================
  924. dwErr = IpmontrGetFriendlyNameFromIfName(
  925. IfList[i].wszInterfaceName,
  926. IfName, &dwSize
  927. );
  928. if ( dwErr == NO_ERROR )
  929. {
  930. buffer[ 2 ] = GetEnumString(
  931. g_hModule, pSapCfg->SapIfInfo.AdminState,
  932. NUM_TOKENS_IN_TABLE( AdminStates ),
  933. AdminStates
  934. );
  935. buffer[ 0 ] = GetEnumString(
  936. g_hModule, pSapCfg->SapIfInfo.UpdateMode,
  937. NUM_TOKENS_IN_TABLE( UpdateModes ),
  938. UpdateModes
  939. );
  940. buffer[ 1 ] = GetEnumString(
  941. g_hModule, IfList[i].dwConnectionState,
  942. NUM_TOKENS_IN_TABLE( InterfaceStates ),
  943. InterfaceStates
  944. );
  945. if ( buffer[ 0 ] && buffer[ 1 ] && buffer[ 2 ] )
  946. {
  947. DisplayIPXMessage(
  948. g_hModule, MSG_SAPIF_MIB_TABLE_FMT,
  949. buffer[1], buffer[2], buffer[0],
  950. IfName
  951. );
  952. }
  953. else
  954. {
  955. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  956. DisplayError( g_hModule, dwErr );
  957. }
  958. }
  959. }
  960. }
  961. if (buf)
  962. {
  963. MprAdminBufferFree(buf);
  964. }
  965. buf = NULL;
  966. return NO_ERROR;
  967. }
  968. /*
  969. DWORD
  970. MIBEnumSapIfs (
  971. VOID
  972. ) {
  973. DWORD rc;
  974. DWORD sz;
  975. SAP_MIB_GET_INPUT_DATA MibGetInputData;
  976. PSAP_INTERFACE pIf;
  977. DisplayIPXMessage (g_hModule, MSG_SAPIF_MIB_TABLE_HDR);
  978. MibGetInputData.TableId = SAP_INTERFACE_TABLE;
  979. rc = MprAdminMIBEntryGetFirst (
  980. g_hMIBServer,
  981. PID_IPX,
  982. IPX_PROTOCOL_SAP,
  983. &MibGetInputData,
  984. sizeof(SAP_MIB_GET_INPUT_DATA),
  985. (LPVOID *)&pIf,
  986. &sz);
  987. while (rc==NO_ERROR) {
  988. // CHAR InterfaceNameA[IPX_INTERFACE_ANSI_NAME_LEN+1];
  989. CHAR InterfaceNameA[MAX_INTERFACE_NAME_LEN+1];
  990. DWORD rc1;
  991. //rc1 = GetIpxInterfaceName (g_hMIBServer,
  992. // pIf->InterfaceIndex,
  993. // InterfaceNameA);
  994. rc1=(*(Params->IfInd2IfNameA))(pIf->InterfaceIndex, InterfaceNameA, &(Params->IfNamBufferLength));
  995. if (rc1==NO_ERROR) {
  996. WCHAR buffer[3][MAX_VALUE];
  997. HANDLE hIfCfg;
  998. WCHAR InterfaceNameW[MAX_INTERFACE_NAME_LEN+1];
  999. mbstowcs (InterfaceNameW, InterfaceNameA, sizeof (InterfaceNameW));
  1000. if (MprConfigInterfaceGetHandle (
  1001. g_hMprConfig,
  1002. InterfaceNameW,
  1003. &hIfCfg)==NO_ERROR) {
  1004. //======================================
  1005. // Translate the Interface Name
  1006. //======================================
  1007. if ((rc=(*(Params->IfName2DescA))(InterfaceNameA,
  1008. Params->IfNamBufferA,
  1009. &Params->IfNamBufferLength)) != NO_ERROR) {
  1010. return rc;
  1011. }
  1012. //======================================
  1013. DisplayIPXMessage (g_hModule,
  1014. MSG_SAPIF_MIB_TABLE_FMT,
  1015. Params->IfNamBufferA, //InterfaceNameA,
  1016. GetValueString (g_hModule, Utils, UpdateModes,
  1017. pIf->SapIfInfo.UpdateMode, buffer[0]),
  1018. GetValueString (g_hModule, Utils, AdminStates,
  1019. pIf->SapIfInfo.AdminState, buffer[1]),
  1020. GetValueString (g_hModule, Utils, OperStates,
  1021. pIf->SapIfStats.SapIfOperState, buffer[2])
  1022. );
  1023. }
  1024. }
  1025. else
  1026. DisplayError( g_hModule, rc1);
  1027. MibGetInputData.InterfaceIndex
  1028. = pIf->InterfaceIndex;
  1029. MprAdminMIBBufferFree (pIf);
  1030. rc = MprAdminMIBEntryGetNext (
  1031. g_hMIBServer,
  1032. PID_IPX,
  1033. IPX_PROTOCOL_SAP,
  1034. &MibGetInputData,
  1035. sizeof(SAP_MIB_GET_INPUT_DATA),
  1036. (LPVOID *)&pIf,
  1037. &sz);
  1038. }
  1039. if (rc==ERROR_NO_MORE_ITEMS)
  1040. return NO_ERROR;
  1041. else {
  1042. DisplayError( g_hModule, rc);
  1043. return rc;
  1044. }
  1045. }
  1046. */
  1047. DWORD
  1048. CfgEnumSapIfs (
  1049. VOID
  1050. )
  1051. {
  1052. DWORD rc = NO_ERROR;
  1053. DWORD read, total, processed = 0, i, dwErr;
  1054. DWORD hResume = 0;
  1055. DWORD sz;
  1056. PMPR_INTERFACE_0 pRi0;
  1057. WCHAR IfName[ MAX_INTERFACE_NAME_LEN + 1 ];
  1058. DWORD dwSize = sizeof(IfName);
  1059. DisplayIPXMessage (g_hModule, MSG_SAPIF_CFG_TABLE_HDR);
  1060. do
  1061. {
  1062. rc = MprConfigInterfaceEnum (
  1063. g_hMprConfig, 0, (LPBYTE * ) & pRi0, MAXULONG,
  1064. &read, &total, &hResume
  1065. );
  1066. if (rc == NO_ERROR)
  1067. {
  1068. for (i = 0; i < read; i++)
  1069. {
  1070. HANDLE hIfTrCfg;
  1071. rc = MprConfigInterfaceTransportGetHandle (
  1072. g_hMprConfig, pRi0[i].hInterface, PID_IPX, &hIfTrCfg
  1073. );
  1074. if (rc == NO_ERROR)
  1075. {
  1076. LPBYTE pIfBlock;
  1077. rc = MprConfigInterfaceTransportGetInfo (
  1078. g_hMprConfig, pRi0[i].hInterface, hIfTrCfg, &pIfBlock, &sz
  1079. );
  1080. if (rc == NO_ERROR)
  1081. {
  1082. PIPX_TOC_ENTRY pSapToc;
  1083. pSapToc = GetIPXTocEntry (
  1084. (PIPX_INFO_BLOCK_HEADER)pIfBlock,
  1085. IPX_PROTOCOL_SAP
  1086. );
  1087. if (pSapToc != NULL)
  1088. {
  1089. PSAP_IF_CONFIG pSapCfg;
  1090. PWCHAR buffer[2];
  1091. pSapCfg = (PSAP_IF_CONFIG) (pIfBlock + pSapToc->Offset);
  1092. //======================================
  1093. // Translate the Interface Name
  1094. //======================================
  1095. dwErr = IpmontrGetFriendlyNameFromIfName(
  1096. pRi0[i].wszInterfaceName,
  1097. IfName, &dwSize
  1098. );
  1099. if ( dwErr != NO_ERROR )
  1100. {
  1101. buffer[ 1 ] = GetEnumString(
  1102. g_hModule, pSapCfg->SapIfInfo.AdminState,
  1103. NUM_TOKENS_IN_TABLE( AdminStates ),
  1104. AdminStates
  1105. );
  1106. buffer[ 0 ] = GetEnumString(
  1107. g_hModule, pSapCfg->SapIfInfo.UpdateMode,
  1108. NUM_TOKENS_IN_TABLE( UpdateModes ),
  1109. UpdateModes
  1110. );
  1111. if ( buffer[ 0 ] && buffer[ 1 ] )
  1112. {
  1113. DisplayIPXMessage(
  1114. g_hModule, MSG_SAPIF_CFG_TABLE_FMT,
  1115. IfName, buffer[0], buffer[1]
  1116. );
  1117. }
  1118. else
  1119. {
  1120. rc = ERROR_NOT_ENOUGH_MEMORY;
  1121. DisplayError( g_hModule, rc );
  1122. }
  1123. }
  1124. else
  1125. {
  1126. DisplayError( g_hModule, rc );
  1127. }
  1128. }
  1129. else
  1130. {
  1131. DisplayIPXMessage (g_hModule, MSG_INTERFACE_INFO_CORRUPTED);
  1132. rc = ERROR_INVALID_DATA;
  1133. }
  1134. }
  1135. else
  1136. {
  1137. DisplayError( g_hModule, rc);
  1138. }
  1139. }
  1140. else
  1141. {
  1142. //DisplayError( g_hModule, rc);
  1143. }
  1144. }
  1145. processed += read;
  1146. MprConfigBufferFree (pRi0);
  1147. }
  1148. else
  1149. {
  1150. DisplayError( g_hModule, rc);
  1151. break;
  1152. }
  1153. } while (processed < total);
  1154. return rc;
  1155. }
  1156. DWORD
  1157. CfgSetSapIf (
  1158. LPWSTR InterfaceNameW,
  1159. PULONG pAdminState OPTIONAL,
  1160. PULONG pAdvertise OPTIONAL,
  1161. PULONG pListen OPTIONAL,
  1162. PULONG pReply OPTIONAL,
  1163. PULONG pUpdateMode OPTIONAL,
  1164. PULONG pInterval OPTIONAL,
  1165. PULONG pAgeMultiplier OPTIONAL
  1166. )
  1167. {
  1168. DWORD rc;
  1169. DWORD sz;
  1170. HANDLE hTrCfg;
  1171. HANDLE hIfCfg;
  1172. HANDLE hIfTrCfg;
  1173. LPBYTE pIfBlock;
  1174. if (InterfaceNameW != NULL)
  1175. {
  1176. rc = MprConfigInterfaceGetHandle (
  1177. g_hMprConfig, InterfaceNameW, &hIfCfg
  1178. );
  1179. if (rc == NO_ERROR)
  1180. {
  1181. rc = MprConfigInterfaceTransportGetHandle (
  1182. g_hMprConfig, hIfCfg, PID_IPX, &hIfTrCfg
  1183. );
  1184. if (rc == NO_ERROR)
  1185. {
  1186. rc = MprConfigInterfaceTransportGetInfo (
  1187. g_hMprConfig, hIfCfg, hIfTrCfg, &pIfBlock, &sz
  1188. );
  1189. }
  1190. }
  1191. }
  1192. else
  1193. {
  1194. rc = MprConfigTransportGetHandle (
  1195. g_hMprConfig, PID_IPX, &hTrCfg
  1196. );
  1197. if (rc == NO_ERROR)
  1198. {
  1199. rc = MprConfigTransportGetInfo (
  1200. g_hMprConfig, hTrCfg, NULL, NULL, &pIfBlock, &sz, NULL
  1201. );
  1202. }
  1203. }
  1204. if (rc == NO_ERROR)
  1205. {
  1206. PIPX_TOC_ENTRY pSapToc;
  1207. pSapToc = GetIPXTocEntry (
  1208. (PIPX_INFO_BLOCK_HEADER)pIfBlock,
  1209. IPX_PROTOCOL_SAP
  1210. );
  1211. if (pSapToc != NULL)
  1212. {
  1213. PSAP_IF_CONFIG pSapCfg;
  1214. pSapCfg = (PSAP_IF_CONFIG) (pIfBlock + pSapToc->Offset);
  1215. if (ARGUMENT_PRESENT (pAdminState))
  1216. {
  1217. pSapCfg->SapIfInfo.AdminState = *pAdminState;
  1218. }
  1219. if (ARGUMENT_PRESENT (pAdvertise))
  1220. {
  1221. pSapCfg->SapIfInfo.Supply = *pAdvertise;
  1222. }
  1223. if (ARGUMENT_PRESENT (pListen))
  1224. {
  1225. pSapCfg->SapIfInfo.Listen = *pListen;
  1226. }
  1227. if (ARGUMENT_PRESENT (pReply))
  1228. {
  1229. pSapCfg->SapIfInfo.GetNearestServerReply = *pReply;
  1230. }
  1231. if (ARGUMENT_PRESENT (pUpdateMode))
  1232. {
  1233. pSapCfg->SapIfInfo.UpdateMode = *pUpdateMode;
  1234. }
  1235. if (ARGUMENT_PRESENT (pInterval))
  1236. {
  1237. pSapCfg->SapIfInfo.PeriodicUpdateInterval = *pInterval;
  1238. }
  1239. if (ARGUMENT_PRESENT (pAgeMultiplier))
  1240. {
  1241. pSapCfg->SapIfInfo.AgeIntervalMultiplier = *pAgeMultiplier;
  1242. }
  1243. if (InterfaceNameW != NULL)
  1244. {
  1245. rc = MprConfigInterfaceTransportSetInfo (
  1246. g_hMprConfig, hIfCfg, hIfTrCfg, pIfBlock, sz
  1247. );
  1248. }
  1249. else
  1250. {
  1251. rc = MprConfigTransportSetInfo (
  1252. g_hMprConfig, hTrCfg, NULL, 0, pIfBlock, sz, NULL
  1253. );
  1254. }
  1255. if (rc == NO_ERROR)
  1256. {
  1257. if (InterfaceNameW != NULL)
  1258. {
  1259. DisplayIPXMessage (
  1260. g_hModule, MSG_SAPIF_SET_CFG, InterfaceNameW
  1261. );
  1262. }
  1263. else
  1264. {
  1265. DisplayIPXMessage (g_hModule, MSG_CLIENT_SAPIF_SET_CFG);
  1266. }
  1267. }
  1268. else
  1269. {
  1270. DisplayError( g_hModule, rc);
  1271. }
  1272. }
  1273. else
  1274. {
  1275. DisplayIPXMessage (g_hModule, MSG_INTERFACE_INFO_CORRUPTED);
  1276. rc = ERROR_INVALID_DATA;
  1277. }
  1278. MprConfigBufferFree (pIfBlock);
  1279. }
  1280. else
  1281. {
  1282. DisplayError( g_hModule, rc);
  1283. }
  1284. return rc;
  1285. }
  1286. DWORD
  1287. AdmSetSapIf (
  1288. LPWSTR InterfaceNameW,
  1289. PULONG pAdminState OPTIONAL,
  1290. PULONG pAdvertise OPTIONAL,
  1291. PULONG pListen OPTIONAL,
  1292. PULONG pReply OPTIONAL,
  1293. PULONG pUpdateMode OPTIONAL,
  1294. PULONG pInterval OPTIONAL,
  1295. PULONG pAgeMultiplier OPTIONAL
  1296. )
  1297. {
  1298. DWORD rc;
  1299. DWORD sz;
  1300. HANDLE hIfAdm;
  1301. LPBYTE pIfBlock;
  1302. if (InterfaceNameW != NULL)
  1303. {
  1304. rc = MprAdminInterfaceGetHandle (
  1305. g_hMprAdmin, InterfaceNameW, &hIfAdm, FALSE
  1306. );
  1307. if (rc == NO_ERROR)
  1308. {
  1309. rc = MprAdminInterfaceTransportGetInfo (
  1310. g_hMprAdmin, hIfAdm, PID_IPX, &pIfBlock, &sz
  1311. );
  1312. }
  1313. }
  1314. else
  1315. {
  1316. rc = MprAdminTransportGetInfo (
  1317. g_hMprAdmin, PID_IPX, NULL, NULL, &pIfBlock, &sz
  1318. );
  1319. }
  1320. if (rc == NO_ERROR)
  1321. {
  1322. PIPX_TOC_ENTRY pSapToc;
  1323. pSapToc = GetIPXTocEntry (
  1324. (PIPX_INFO_BLOCK_HEADER)pIfBlock,
  1325. IPX_PROTOCOL_SAP
  1326. );
  1327. if (pSapToc != NULL)
  1328. {
  1329. PSAP_IF_CONFIG pSapCfg;
  1330. pSapCfg = (PSAP_IF_CONFIG) (pIfBlock + pSapToc->Offset);
  1331. if (ARGUMENT_PRESENT (pAdminState))
  1332. {
  1333. pSapCfg->SapIfInfo.AdminState = *pAdminState;
  1334. }
  1335. if (ARGUMENT_PRESENT (pAdvertise))
  1336. {
  1337. pSapCfg->SapIfInfo.Supply = *pAdvertise;
  1338. }
  1339. if (ARGUMENT_PRESENT (pListen))
  1340. {
  1341. pSapCfg->SapIfInfo.Listen = *pListen;
  1342. }
  1343. if (ARGUMENT_PRESENT (pReply))
  1344. {
  1345. pSapCfg->SapIfInfo.GetNearestServerReply = *pReply;
  1346. }
  1347. if (ARGUMENT_PRESENT (pUpdateMode))
  1348. {
  1349. pSapCfg->SapIfInfo.UpdateMode = *pUpdateMode;
  1350. }
  1351. if (ARGUMENT_PRESENT (pInterval))
  1352. {
  1353. pSapCfg->SapIfInfo.PeriodicUpdateInterval = *pInterval;
  1354. }
  1355. if (ARGUMENT_PRESENT (pAgeMultiplier))
  1356. {
  1357. pSapCfg->SapIfInfo.AgeIntervalMultiplier = *pAgeMultiplier;
  1358. }
  1359. if (InterfaceNameW != NULL)
  1360. {
  1361. rc = MprAdminInterfaceTransportSetInfo (
  1362. g_hMprAdmin, hIfAdm, PID_IPX, pIfBlock,
  1363. ((PIPX_INFO_BLOCK_HEADER)pIfBlock)->Size
  1364. );
  1365. }
  1366. else
  1367. {
  1368. rc = MprAdminTransportSetInfo (
  1369. g_hMprAdmin, PID_IPX, NULL, 0, pIfBlock,
  1370. ((PIPX_INFO_BLOCK_HEADER)pIfBlock)->Size
  1371. );
  1372. }
  1373. if (rc == NO_ERROR)
  1374. {
  1375. if (InterfaceNameW != NULL)
  1376. {
  1377. DisplayIPXMessage (g_hModule, MSG_SAPIF_SET_ADM, InterfaceNameW);
  1378. }
  1379. else
  1380. {
  1381. DisplayIPXMessage (g_hModule, MSG_CLIENT_SAPIF_SET_ADM);
  1382. }
  1383. }
  1384. else
  1385. {
  1386. DisplayError( g_hModule, rc);
  1387. }
  1388. }
  1389. else
  1390. {
  1391. DisplayIPXMessage (g_hModule, MSG_INTERFACE_INFO_CORRUPTED);
  1392. rc = ERROR_INVALID_DATA;
  1393. }
  1394. MprAdminBufferFree (pIfBlock);
  1395. }
  1396. else
  1397. {
  1398. DisplayError( g_hModule, rc);
  1399. }
  1400. return rc;
  1401. }