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.

1302 lines
36 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. nbifs.c
  5. Abstract:
  6. IPX Router Console Monitoring and Configuration tool.
  7. NBIPX Interface configuration and monitoring.
  8. Author:
  9. Vadim Eydelman 06/07/1996
  10. --*/
  11. #include "precomp.h"
  12. #pragma hdrstop
  13. DWORD
  14. MIBGetNbIpxIf(
  15. PWCHAR InterfaceNameW,
  16. HANDLE hFile
  17. );
  18. DWORD
  19. CfgGetNbIpxIf (
  20. LPWSTR InterfaceNameW,
  21. HANDLE hFile
  22. );
  23. DWORD
  24. MIBEnumNbIpxIfs (
  25. VOID
  26. );
  27. DWORD
  28. CfgEnumNbIpxIfs (
  29. VOID
  30. );
  31. DWORD
  32. CfgSetNbIpxIf (
  33. LPWSTR InterfaceNameW,
  34. PULONG pAccept OPTIONAL,
  35. PULONG pDeliver OPTIONAL
  36. );
  37. DWORD
  38. AdmSetNbIpxIf (
  39. LPWSTR InterfaceNameW,
  40. PULONG pAccept OPTIONAL,
  41. PULONG pDeliver OPTIONAL
  42. );
  43. DWORD
  44. GetNbIpxClientIf (
  45. PWCHAR InterfaceNameW,
  46. UINT msg,
  47. HANDLE hFile
  48. );
  49. DWORD
  50. APIENTRY
  51. HelpNbIf (
  52. IN int argc,
  53. IN WCHAR *argv[]
  54. )
  55. {
  56. DisplayMessage (g_hModule, HLP_IPX_NBIF);
  57. return 0;
  58. }
  59. DWORD
  60. APIENTRY
  61. ShowNbIf (
  62. IN int argc,
  63. IN WCHAR *argv[],
  64. IN HANDLE hFile
  65. )
  66. {
  67. WCHAR IfName[ MAX_INTERFACE_NAME_LEN ];
  68. DWORD rc, dwSize = sizeof(IfName);
  69. if (argc < 1)
  70. {
  71. if (g_hMIBServer)
  72. {
  73. rc = MIBEnumNbIpxIfs ();
  74. if (rc == NO_ERROR)
  75. {
  76. rc = GetNbIpxClientIf (
  77. VAL_DIALINCLIENT,
  78. MSG_CLIENT_NBIF_MIB_TABLE_FMT,
  79. NULL
  80. );
  81. }
  82. else
  83. {
  84. if ( !hFile ) { DisplayIPXMessage (g_hModule, MSG_REGISTRY_FALLBACK); }
  85. goto EnumerateThroughCfg;
  86. }
  87. }
  88. else
  89. {
  90. EnumerateThroughCfg:
  91. rc = CfgEnumNbIpxIfs ();
  92. if (rc == NO_ERROR)
  93. {
  94. rc = GetNbIpxClientIf (
  95. VAL_DIALINCLIENT,
  96. MSG_CLIENT_NBIF_CFG_TABLE_FMT,
  97. NULL
  98. );
  99. }
  100. }
  101. }
  102. else
  103. {
  104. unsigned count;
  105. #define InterfaceNameW argv[0]
  106. count = wcslen( InterfaceNameW );
  107. if ( !_wcsicmp( argv[0], VAL_DIALINCLIENT ) )
  108. {
  109. rc = GetNbIpxClientIf(
  110. VAL_DIALINCLIENT, MSG_CLIENT_NBIF_CFG_SCREEN_FMT, hFile
  111. );
  112. }
  113. else if ((count > 0) && (count <= MAX_INTERFACE_NAME_LEN))
  114. {
  115. if (g_hMIBServer)
  116. {
  117. //======================================
  118. // Translate the Interface Name
  119. //======================================
  120. rc = IpmontrGetIfNameFromFriendlyName(
  121. InterfaceNameW, IfName, &dwSize
  122. );
  123. if ( rc == NO_ERROR )
  124. {
  125. rc = MIBGetNbIpxIf ( IfName, hFile );
  126. if (rc != NO_ERROR)
  127. {
  128. if ( !hFile ) { DisplayIPXMessage (g_hModule, MSG_REGISTRY_FALLBACK); }
  129. goto GetIfFromCfg;
  130. }
  131. }
  132. else
  133. {
  134. if ( !hFile ) { DisplayError( g_hModule, rc ); }
  135. }
  136. }
  137. else
  138. {
  139. GetIfFromCfg:
  140. //======================================
  141. // Translate the Interface Name
  142. //======================================
  143. rc = IpmontrGetIfNameFromFriendlyName(
  144. InterfaceNameW, IfName, &dwSize
  145. );
  146. if ( rc == NO_ERROR )
  147. {
  148. rc = CfgGetNbIpxIf ( IfName, hFile );
  149. }
  150. else
  151. {
  152. if ( !hFile ) { DisplayError( g_hModule, rc ); }
  153. }
  154. }
  155. }
  156. else
  157. {
  158. if ( !hFile ) { DisplayIPXMessage (g_hModule, MSG_INVALID_INTERFACE_NAME); }
  159. rc = ERROR_INVALID_PARAMETER;
  160. }
  161. }
  162. return rc;
  163. #undef InterfaceNameW
  164. }
  165. DWORD
  166. APIENTRY
  167. SetNbIf (
  168. IN int argc,
  169. IN WCHAR *argv[]
  170. )
  171. {
  172. LPWSTR InterfaceNameW;
  173. WCHAR IfName[ MAX_INTERFACE_NAME_LEN + 1 ];
  174. DWORD rc, dwSize = sizeof(IfName);
  175. if (argc >= 1)
  176. {
  177. unsigned count;
  178. BOOLEAN client = FALSE;
  179. #define InterfaceNameW argv[0]
  180. if ( !_wcsicmp( argv[0],VAL_DIALINCLIENT ) )
  181. {
  182. client = TRUE;
  183. }
  184. else
  185. {
  186. count = wcslen (InterfaceNameW);
  187. }
  188. if (client || ((count > 0) && (count <= MAX_INTERFACE_NAME_LEN)))
  189. {
  190. int i;
  191. ULONG accept, deliver;
  192. PULONG pAccept = NULL, pDeliver = NULL;
  193. for ( i = 1; i < argc; i++ )
  194. {
  195. if ( !_wcsicmp( argv[i], TOKEN_BCASTACCEPT ) )
  196. {
  197. if ( (pAccept == NULL) && (i < argc - 1) &&
  198. !MatchEnumTag(
  199. g_hModule, argv[i+1], NUM_TOKENS_IN_TABLE( AdminStates ),
  200. AdminStates, &accept
  201. ) )
  202. {
  203. i += 1;
  204. pAccept = &accept;
  205. continue;
  206. }
  207. else
  208. {
  209. break;
  210. }
  211. }
  212. if ( !_wcsicmp( argv[i], TOKEN_BCASTDELIVER ) )
  213. {
  214. if ( (pDeliver == NULL) && (i < argc - 1) &&
  215. !MatchEnumTag (g_hModule, argv[i+1],
  216. NUM_TOKENS_IN_TABLE( NbDeliverStates ),
  217. NbDeliverStates, &deliver) )
  218. {
  219. i += 1;
  220. pDeliver = &deliver;
  221. continue;
  222. }
  223. else
  224. {
  225. break;
  226. }
  227. }
  228. if (pAccept == NULL)
  229. {
  230. if ( !MatchEnumTag(
  231. g_hModule, argv[ i ], NUM_TOKENS_IN_TABLE( AdminStates ),
  232. AdminStates, &accept
  233. ))
  234. {
  235. pAccept = &accept;
  236. }
  237. else
  238. {
  239. break;
  240. }
  241. }
  242. else if (pDeliver == NULL)
  243. {
  244. if ( !MatchEnumTag(
  245. g_hModule, argv[i], NUM_TOKENS_IN_TABLE( NbDeliverStates ),
  246. NbDeliverStates, &deliver
  247. ) )
  248. {
  249. pDeliver = &deliver;
  250. }
  251. else
  252. {
  253. break;
  254. }
  255. }
  256. else
  257. {
  258. break;
  259. }
  260. }
  261. if (i == argc)
  262. {
  263. if (!client)
  264. {
  265. DWORD rc2;
  266. //======================================
  267. // Translate the Interface Name
  268. //======================================
  269. rc = IpmontrGetIfNameFromFriendlyName(
  270. InterfaceNameW, IfName, &dwSize
  271. );
  272. if ( rc == NO_ERROR )
  273. {
  274. rc2 = CfgSetNbIpxIf( IfName, pAccept, pDeliver);
  275. if (rc2 == NO_ERROR)
  276. {
  277. if (g_hMprAdmin)
  278. {
  279. rc = AdmSetNbIpxIf( IfName, pAccept, pDeliver );
  280. }
  281. }
  282. else
  283. {
  284. rc = rc2;
  285. }
  286. }
  287. else
  288. {
  289. DisplayError( g_hModule, rc );
  290. }
  291. }
  292. else
  293. {
  294. rc = CfgSetNbIpxIf (NULL, pAccept, pDeliver);
  295. if (rc == NO_ERROR)
  296. {
  297. if (g_hMprAdmin)
  298. {
  299. rc = AdmSetNbIpxIf (NULL, pAccept, pDeliver);
  300. }
  301. }
  302. }
  303. }
  304. else
  305. {
  306. DisplayMessage (g_hModule, HLP_IPX_NBIF);
  307. rc = ERROR_INVALID_PARAMETER;
  308. }
  309. }
  310. else
  311. {
  312. DisplayIPXMessage (g_hModule, MSG_INVALID_INTERFACE_NAME);
  313. rc = ERROR_INVALID_PARAMETER;
  314. }
  315. }
  316. else
  317. {
  318. DisplayMessage (g_hModule, HLP_IPX_NBIF);
  319. rc = ERROR_INVALID_PARAMETER;
  320. }
  321. return rc;
  322. #undef InterfaceNameW
  323. }
  324. DWORD
  325. MIBGetNbIpxIf (
  326. PWCHAR InterfaceNameW,
  327. HANDLE hFile
  328. )
  329. {
  330. DWORD rc, i;
  331. DWORD sz;
  332. IPX_MIB_GET_INPUT_DATA MibGetInputData;
  333. PIPX_INTERFACE pIf;
  334. WCHAR IfName[ MAX_INTERFACE_NAME_LEN + 1 ];
  335. DWORD dwSize = sizeof(IfName);
  336. MibGetInputData.TableId = IPX_INTERFACE_TABLE;
  337. rc = GetIpxInterfaceIndex (
  338. g_hMIBServer, InterfaceNameW,
  339. &MibGetInputData.MibIndex.InterfaceTableIndex.InterfaceIndex
  340. );
  341. if (rc == NO_ERROR)
  342. {
  343. rc = MprAdminMIBEntryGet(
  344. g_hMIBServer, PID_IPX, IPX_PROTOCOL_BASE, &MibGetInputData,
  345. sizeof(IPX_MIB_GET_INPUT_DATA), (LPVOID * ) & pIf, &sz
  346. );
  347. if (rc == NO_ERROR && pIf)
  348. {
  349. PWCHAR buffer[2];
  350. //======================================
  351. // Translate the Interface Name
  352. //======================================
  353. rc = IpmontrGetFriendlyNameFromIfName( InterfaceNameW, IfName, &dwSize );
  354. if ( rc == NO_ERROR )
  355. {
  356. buffer[ 0 ] = GetEnumString(
  357. g_hModule, pIf->NetbiosAccept,
  358. NUM_TOKENS_IN_TABLE( AdminStates ),
  359. AdminStates
  360. );
  361. buffer[ 1 ] = GetEnumString(
  362. g_hModule, pIf->NetbiosDeliver,
  363. NUM_TOKENS_IN_TABLE( NbDeliverStates ),
  364. NbDeliverStates
  365. );
  366. if ( buffer[ 0 ] && buffer[ 1 ] )
  367. {
  368. if ( hFile )
  369. {
  370. DisplayMessageT(
  371. DMP_IPX_NB_SET_INTERFACE, IfName, buffer[ 0 ],
  372. buffer[ 1 ]
  373. );
  374. }
  375. else
  376. {
  377. DisplayIPXMessage(
  378. g_hModule, MSG_NBIF_MIB_SCREEN_FMT,
  379. IfName, buffer[ 0 ], buffer[ 1 ],
  380. pIf->IfStats.NetbiosReceived,
  381. pIf->IfStats.NetbiosSent
  382. );
  383. }
  384. }
  385. }
  386. MprAdminMIBBufferFree (pIf);
  387. }
  388. else
  389. {
  390. if ( !hFile ) { DisplayError( g_hModule, rc); }
  391. }
  392. }
  393. else
  394. {
  395. if ( !hFile ) { DisplayError( g_hModule, rc); }
  396. }
  397. return rc;
  398. }
  399. DWORD
  400. CfgGetNbIpxIf (
  401. LPWSTR InterfaceNameW,
  402. HANDLE hFile
  403. )
  404. {
  405. DWORD rc;
  406. DWORD sz;
  407. HANDLE hIfCfg;
  408. WCHAR IfName[ MAX_INTERFACE_NAME_LEN + 1 ];
  409. DWORD dwSize = sizeof(IfName);
  410. rc = MprConfigInterfaceGetHandle (
  411. g_hMprConfig, InterfaceNameW, &hIfCfg
  412. );
  413. if ( rc == NO_ERROR )
  414. {
  415. HANDLE hIfTrCfg;
  416. rc = MprConfigInterfaceTransportGetHandle (
  417. g_hMprConfig, hIfCfg, PID_IPX, &hIfTrCfg
  418. );
  419. if (rc == NO_ERROR)
  420. {
  421. LPBYTE pIfBlock;
  422. rc = MprConfigInterfaceTransportGetInfo (
  423. g_hMprConfig, hIfCfg, hIfTrCfg, &pIfBlock, &sz
  424. );
  425. if (rc == NO_ERROR)
  426. {
  427. PIPX_TOC_ENTRY pIpxToc;
  428. pIpxToc = GetIPXTocEntry (
  429. (PIPX_INFO_BLOCK_HEADER)pIfBlock,
  430. IPX_INTERFACE_INFO_TYPE);
  431. if (pIpxToc != NULL)
  432. {
  433. DWORD i;
  434. PIPX_IF_INFO pIpxInfo;
  435. PWCHAR buffer[2];
  436. pIpxInfo = (PIPX_IF_INFO) (pIfBlock + pIpxToc->Offset);
  437. //======================================
  438. // Translate the Interface Name
  439. //======================================
  440. rc = IpmontrGetFriendlyNameFromIfName( InterfaceNameW, IfName, &dwSize );
  441. if ( rc == NO_ERROR )
  442. {
  443. buffer[ 0 ] = GetEnumString(
  444. g_hModule, pIpxInfo->NetbiosAccept,
  445. NUM_TOKENS_IN_TABLE( AdminStates ),
  446. AdminStates
  447. );
  448. buffer[ 1 ] = GetEnumString(
  449. g_hModule, pIpxInfo->NetbiosDeliver,
  450. NUM_TOKENS_IN_TABLE( NbDeliverStates ),
  451. NbDeliverStates
  452. );
  453. if ( buffer[ 0 ] && buffer[ 1 ] )
  454. {
  455. if ( hFile )
  456. {
  457. DisplayMessageT(
  458. DMP_IPX_NB_SET_INTERFACE, IfName, buffer[ 0 ],
  459. buffer[ 1 ]
  460. );
  461. }
  462. else
  463. {
  464. DisplayIPXMessage(
  465. g_hModule, MSG_NBIF_CFG_SCREEN_FMT,
  466. IfName, buffer[ 0 ], buffer[ 1 ]
  467. );
  468. }
  469. }
  470. }
  471. }
  472. else
  473. {
  474. if ( !hFile ) { DisplayIPXMessage (g_hModule, MSG_INTERFACE_INFO_CORRUPTED); }
  475. rc = ERROR_INVALID_DATA;
  476. }
  477. }
  478. else if ((rc == ERROR_FILE_NOT_FOUND) || (rc == ERROR_NO_MORE_ITEMS))
  479. {
  480. if ( !hFile ) { DisplayIPXMessage (g_hModule, MSG_NO_IPX_ON_INTERFACE_CFG); }
  481. }
  482. else
  483. {
  484. if ( !hFile ) { DisplayError( g_hModule, rc); }
  485. }
  486. }
  487. else
  488. {
  489. if ( !hFile ) { DisplayError( g_hModule, rc); }
  490. }
  491. }
  492. else if ((rc == ERROR_FILE_NOT_FOUND) || (rc == ERROR_NO_MORE_ITEMS))
  493. {
  494. if ( !hFile ) { DisplayError( g_hModule, ERROR_NO_SUCH_INTERFACE); }
  495. }
  496. else
  497. {
  498. if ( !hFile ) { DisplayError( g_hModule, rc); }
  499. }
  500. return rc;
  501. }
  502. DWORD
  503. GetNbIpxClientIf (
  504. PWCHAR InterfaceName,
  505. UINT msg,
  506. HANDLE hFile
  507. )
  508. {
  509. DWORD rc;
  510. LPBYTE pClBlock;
  511. HANDLE hTrCfg;
  512. hTrCfg = NULL;
  513. if (g_hMprAdmin)
  514. {
  515. DWORD sz;
  516. rc = MprAdminTransportGetInfo(
  517. g_hMprAdmin, PID_IPX, NULL, NULL, &pClBlock, &sz
  518. );
  519. if (rc == NO_ERROR)
  520. {
  521. }
  522. else
  523. {
  524. if ((rc == ERROR_FILE_NOT_FOUND) || (rc == ERROR_NO_MORE_ITEMS))
  525. {
  526. if ( !hFile ) { DisplayIPXMessage (g_hModule, MSG_NO_IPX_IN_ROUTER_ADM); }
  527. }
  528. else
  529. {
  530. if ( !hFile ) { DisplayError( g_hModule, rc); }
  531. }
  532. if ( !hFile ) { DisplayIPXMessage (g_hModule, MSG_REGISTRY_FALLBACK); }
  533. goto GetFromCfg;
  534. }
  535. }
  536. else
  537. {
  538. GetFromCfg:
  539. rc = MprConfigTransportGetHandle (
  540. g_hMprConfig, PID_IPX, &hTrCfg
  541. );
  542. if (rc == NO_ERROR)
  543. {
  544. DWORD sz;
  545. rc = MprConfigTransportGetInfo (
  546. g_hMprConfig, hTrCfg, NULL, NULL, &pClBlock, &sz, NULL
  547. );
  548. if (rc == NO_ERROR)
  549. {
  550. NOTHING;
  551. }
  552. else
  553. {
  554. if ( !hFile ) { DisplayError( g_hModule, rc); }
  555. }
  556. }
  557. else
  558. {
  559. if ((rc == ERROR_FILE_NOT_FOUND) || (rc == ERROR_NO_MORE_ITEMS))
  560. {
  561. if ( !hFile ) { DisplayIPXMessage (g_hModule, MSG_NO_IPX_IN_ROUTER_ADM); }
  562. }
  563. else
  564. {
  565. if ( !hFile ) { DisplayError( g_hModule, rc); }
  566. }
  567. }
  568. }
  569. if (rc == NO_ERROR)
  570. {
  571. DWORD i;
  572. PIPX_TOC_ENTRY pIpxToc;
  573. pIpxToc = GetIPXTocEntry(
  574. (PIPX_INFO_BLOCK_HEADER)pClBlock,
  575. IPX_INTERFACE_INFO_TYPE
  576. );
  577. if (pIpxToc != NULL)
  578. {
  579. PIPX_IF_INFO pIpxInfo;
  580. PWCHAR buffer[2];
  581. pIpxInfo = (PIPX_IF_INFO) (pClBlock + pIpxToc->Offset);
  582. buffer[ 0 ] = GetEnumString(
  583. g_hModule,
  584. pIpxInfo->NetbiosAccept,
  585. NUM_TOKENS_IN_TABLE( AdminStates ),
  586. AdminStates
  587. );
  588. buffer[ 1 ] = GetEnumString(
  589. g_hModule, pIpxInfo->NetbiosDeliver,
  590. NUM_TOKENS_IN_TABLE( NbDeliverStates ),
  591. NbDeliverStates
  592. );
  593. if ( buffer[ 0 ] && buffer[ 1 ] )
  594. {
  595. if ( hFile )
  596. {
  597. DisplayMessageT(
  598. DMP_IPX_NB_SET_INTERFACE, InterfaceName, buffer[ 0 ],
  599. buffer[ 1 ]
  600. );
  601. }
  602. else
  603. {
  604. DisplayIPXMessage(
  605. g_hModule, msg, InterfaceName,
  606. buffer[ 0 ], buffer[ 1 ]
  607. );
  608. }
  609. }
  610. }
  611. else
  612. {
  613. if ( !hFile ) { DisplayIPXMessage (g_hModule, MSG_INTERFACE_INFO_CORRUPTED); }
  614. rc = ERROR_INVALID_DATA;
  615. }
  616. if (hTrCfg != NULL)
  617. {
  618. MprConfigBufferFree (pClBlock);
  619. }
  620. else
  621. {
  622. MprAdminBufferFree (pClBlock);
  623. }
  624. }
  625. return rc;
  626. }
  627. PIPX_IF_INFO
  628. GetIpxNbInterface(
  629. HANDLE hIf,
  630. LPBYTE *pIfBlock
  631. )
  632. {
  633. DWORD dwSize;
  634. DWORD dwErr;
  635. PIPX_TOC_ENTRY pIpxToc;
  636. dwErr = MprAdminInterfaceTransportGetInfo(
  637. g_hMprAdmin, hIf, PID_IPX, pIfBlock, &dwSize
  638. );
  639. if (dwErr != NO_ERROR)
  640. {
  641. return NULL;
  642. }
  643. pIpxToc = GetIPXTocEntry(
  644. (PIPX_INFO_BLOCK_HEADER)(*pIfBlock),
  645. IPX_INTERFACE_INFO_TYPE
  646. );
  647. if (!pIpxToc)
  648. {
  649. return NULL;
  650. }
  651. return (PIPX_IF_INFO)((*pIfBlock) + (pIpxToc->Offset));
  652. // return (PIPX_IF_INFO)GetIPXTocEntry((PIPX_INFO_BLOCK_HEADER)(*pIfBlock),IPX_INTERFACE_INFO_TYPE);
  653. }
  654. DWORD
  655. MIBEnumNbIpxIfs(
  656. VOID
  657. )
  658. {
  659. PMPR_INTERFACE_0 IfList = NULL;
  660. DWORD dwErr = 0, dwRead, dwTot, i, j, rc;
  661. PWCHAR buffer[4];
  662. PIPX_IF_INFO pIpxInfo = NULL;
  663. LPBYTE buf = NULL;
  664. WCHAR IfName[ MAX_INTERFACE_NAME_LEN + 1 ];
  665. DWORD dwSize = sizeof(IfName);
  666. DisplayIPXMessage ( g_hModule, MSG_NBIF_MIB_TABLE_HDR );
  667. dwErr = MprAdminInterfaceEnum(
  668. g_hMprAdmin, 0, (unsigned char **) & IfList, MAXULONG,
  669. &dwRead, &dwTot, NULL
  670. );
  671. if (dwErr != NO_ERROR)
  672. {
  673. return dwErr;
  674. }
  675. for (i = 0; i < dwRead; i++)
  676. {
  677. if ((pIpxInfo = GetIpxNbInterface(IfList[i].hInterface, &buf)) != NULL)
  678. {
  679. //======================================
  680. // Translate the Interface Name
  681. //======================================
  682. rc = IpmontrGetFriendlyNameFromIfName( IfList[i].wszInterfaceName, IfName, &dwSize );
  683. if ( rc == NO_ERROR )
  684. {
  685. buffer[ 0 ] = GetEnumString(
  686. g_hModule, pIpxInfo->NetbiosAccept,
  687. NUM_TOKENS_IN_TABLE( AdminStates ),
  688. AdminStates
  689. );
  690. buffer[ 1 ] = GetEnumString(
  691. g_hModule, pIpxInfo->NetbiosDeliver,
  692. NUM_TOKENS_IN_TABLE( NbDeliverStates ),
  693. NbDeliverStates
  694. );
  695. if ( buffer[ 0 ] && buffer[ 1 ] )
  696. {
  697. DisplayIPXMessage(
  698. g_hModule, MSG_NBIF_MIB_TABLE_FMT,
  699. IfName, buffer[ 0 ], buffer[ 1 ]
  700. );
  701. }
  702. }
  703. }
  704. if (buf)
  705. {
  706. MprAdminBufferFree(buf);
  707. }
  708. buf = NULL;
  709. }
  710. return NO_ERROR;
  711. }
  712. /*
  713. DWORD
  714. MIBEnumNbIpxIfs (
  715. VOID
  716. ) {
  717. DWORD rc;
  718. DWORD sz;
  719. IPX_MIB_GET_INPUT_DATA MibGetInputData;
  720. PIPX_INTERFACE pIf;
  721. DisplayIPXMessage (g_hModule, MSG_NBIF_MIB_TABLE_HDR);
  722. MibGetInputData.TableId = IPX_INTERFACE_TABLE;
  723. rc = MprAdminMIBEntryGetFirst (
  724. g_hMIBServer,
  725. PID_IPX,
  726. IPX_PROTOCOL_BASE,
  727. &MibGetInputData,
  728. sizeof(IPX_MIB_GET_INPUT_DATA),
  729. (LPVOID *)&pIf,
  730. &sz);
  731. while (rc==NO_ERROR) {
  732. WCHAR buffer[2][MAX_VALUE];
  733. HANDLE hIfCfg;
  734. WCHAR InterfaceNameW[MAX_INTERFACE_NAME_LEN+1];
  735. pIf->InterfaceName[47]=0;
  736. mbstowcs (InterfaceNameW, pIf->InterfaceName, sizeof (InterfaceNameW));
  737. //======================================
  738. // Translate the Interface Name
  739. //======================================
  740. if ((rc=(*(Params->IfName2DescA))(pIf->InterfaceName,
  741. Params->IfNamBufferA,
  742. &Params->IfNamBufferLength)) != NO_ERROR) {
  743. return rc;
  744. }
  745. //======================================
  746. if (MprConfigInterfaceGetHandle (
  747. g_hMprConfig,
  748. InterfaceNameW,
  749. &hIfCfg)==NO_ERROR) {
  750. DisplayIPXMessage (g_hModule,
  751. MSG_NBIF_MIB_TABLE_FMT,
  752. pIf->InterfaceName, //Params->IfNamBufferA,
  753. GetValueString (g_hModule, Utils, AdminStates,
  754. pIf->NetbiosAccept, buffer[0]),
  755. GetValueString (g_hModule, Utils, NbDeliverStates,
  756. pIf->NetbiosDeliver, buffer[1])
  757. );
  758. }
  759. MibGetInputData.MibIndex.InterfaceTableIndex.InterfaceIndex
  760. = pIf->InterfaceIndex;
  761. MprAdminMIBBufferFree (pIf);
  762. rc = MprAdminMIBEntryGetNext (
  763. g_hMIBServer,
  764. PID_IPX,
  765. IPX_PROTOCOL_BASE,
  766. &MibGetInputData,
  767. sizeof(IPX_MIB_GET_INPUT_DATA),
  768. (LPVOID *)&pIf,
  769. &sz);
  770. }
  771. if (rc==ERROR_NO_MORE_ITEMS)
  772. return NO_ERROR;
  773. else {
  774. if (rc==NO_ERROR)
  775. rc = ERROR_GEN_FAILURE;
  776. DisplayError( g_hModule, rc);
  777. return rc;
  778. }
  779. }
  780. */
  781. DWORD
  782. CfgEnumNbIpxIfs (
  783. VOID
  784. )
  785. {
  786. DWORD rc = NO_ERROR;
  787. DWORD read, total, processed = 0, i, j;
  788. DWORD hResume = 0;
  789. DWORD sz;
  790. PMPR_INTERFACE_0 pRi0;
  791. WCHAR IfName[ MAX_INTERFACE_NAME_LEN + 1 ];
  792. DWORD dwSize = sizeof(IfName);
  793. DisplayIPXMessage (g_hModule, MSG_NBIF_CFG_TABLE_HDR);
  794. do
  795. {
  796. rc = MprConfigInterfaceEnum (
  797. g_hMprConfig, 0, (LPBYTE * ) & pRi0, MAXULONG, &read,
  798. &total, &hResume
  799. );
  800. if ( rc == NO_ERROR )
  801. {
  802. for (i = 0; i < read; i++)
  803. {
  804. HANDLE hIfTrCfg;
  805. rc = MprConfigInterfaceTransportGetHandle(
  806. g_hMprConfig, pRi0[i].hInterface, PID_IPX, &hIfTrCfg
  807. );
  808. if (rc == NO_ERROR)
  809. {
  810. LPBYTE pIfBlock;
  811. rc = MprConfigInterfaceTransportGetInfo (
  812. g_hMprConfig, pRi0[i].hInterface, hIfTrCfg,
  813. &pIfBlock, &sz
  814. );
  815. if (rc == NO_ERROR)
  816. {
  817. PIPX_TOC_ENTRY pIpxToc;
  818. pIpxToc = GetIPXTocEntry(
  819. (PIPX_INFO_BLOCK_HEADER)pIfBlock,
  820. IPX_INTERFACE_INFO_TYPE
  821. );
  822. if (pIpxToc != NULL)
  823. {
  824. PIPX_IF_INFO pIpxInfo;
  825. PWCHAR buffer[2];
  826. pIpxInfo = (PIPX_IF_INFO) (pIfBlock + pIpxToc->Offset);
  827. //======================================
  828. // Translate the Interface Name
  829. //======================================
  830. rc = IpmontrGetFriendlyNameFromIfName(
  831. pRi0[i].wszInterfaceName, IfName, &dwSize
  832. );
  833. if ( rc == NO_ERROR )
  834. {
  835. buffer[ 0 ] = GetEnumString(
  836. g_hModule, pIpxInfo->NetbiosAccept,
  837. NUM_TOKENS_IN_TABLE( AdminStates ),
  838. AdminStates
  839. );
  840. buffer[ 1 ] = GetEnumString(
  841. g_hModule, pIpxInfo->NetbiosDeliver,
  842. NUM_TOKENS_IN_TABLE( NbDeliverStates ),
  843. NbDeliverStates
  844. );
  845. if ( buffer[ 0 ] && buffer[ 1 ] )
  846. {
  847. DisplayIPXMessage(
  848. g_hModule, MSG_NBIF_CFG_TABLE_FMT,
  849. IfName, buffer[ 0 ], buffer[ 1 ]
  850. );
  851. }
  852. }
  853. }
  854. else
  855. {
  856. DisplayIPXMessage (g_hModule, MSG_INTERFACE_INFO_CORRUPTED);
  857. rc = ERROR_INVALID_DATA;
  858. }
  859. }
  860. else if (rc != ERROR_NO_MORE_ITEMS)
  861. {
  862. // No IPX installed
  863. DisplayError( g_hModule, rc);
  864. }
  865. }
  866. else
  867. {
  868. //DisplayError( g_hModule, rc);
  869. rc = NO_ERROR;
  870. }
  871. }
  872. processed += read;
  873. MprConfigBufferFree (pRi0);
  874. }
  875. else
  876. {
  877. DisplayError( g_hModule, rc);
  878. break;
  879. }
  880. } while (processed < total);
  881. return rc;
  882. }
  883. DWORD
  884. CfgSetNbIpxIf (
  885. LPWSTR InterfaceNameW,
  886. PULONG pAccept OPTIONAL,
  887. PULONG pDeliver OPTIONAL
  888. )
  889. {
  890. DWORD rc;
  891. DWORD sz;
  892. HANDLE hTrCfg;
  893. HANDLE hIfCfg;
  894. HANDLE hIfTrCfg;
  895. LPBYTE pIfBlock;
  896. if (InterfaceNameW != NULL)
  897. {
  898. rc = MprConfigInterfaceGetHandle(
  899. g_hMprConfig, InterfaceNameW, &hIfCfg
  900. );
  901. if (rc == NO_ERROR)
  902. {
  903. rc = MprConfigInterfaceTransportGetHandle (
  904. g_hMprConfig, hIfCfg, PID_IPX, &hIfTrCfg
  905. );
  906. if (rc == NO_ERROR)
  907. {
  908. rc = MprConfigInterfaceTransportGetInfo (
  909. g_hMprConfig, hIfCfg, hIfTrCfg, &pIfBlock, &sz
  910. );
  911. }
  912. }
  913. }
  914. else
  915. {
  916. rc = MprConfigTransportGetHandle (
  917. g_hMprConfig, PID_IPX, &hTrCfg
  918. );
  919. if (rc == NO_ERROR)
  920. {
  921. rc = MprConfigTransportGetInfo (
  922. g_hMprConfig, hTrCfg, NULL, NULL, &pIfBlock, &sz, NULL
  923. );
  924. }
  925. }
  926. if (rc == NO_ERROR)
  927. {
  928. PIPX_TOC_ENTRY pIpxToc;
  929. pIpxToc = GetIPXTocEntry (
  930. (PIPX_INFO_BLOCK_HEADER)pIfBlock,
  931. IPX_INTERFACE_INFO_TYPE
  932. );
  933. if (pIpxToc != NULL)
  934. {
  935. PIPX_IF_INFO pIpxInfo;
  936. pIpxInfo = (PIPX_IF_INFO) (pIfBlock + pIpxToc->Offset);
  937. if (ARGUMENT_PRESENT (pAccept))
  938. {
  939. pIpxInfo->NetbiosAccept = *pAccept;
  940. }
  941. if (ARGUMENT_PRESENT (pDeliver))
  942. {
  943. pIpxInfo->NetbiosDeliver = *pDeliver;
  944. }
  945. if (InterfaceNameW != NULL)
  946. {
  947. rc = MprConfigInterfaceTransportSetInfo (
  948. g_hMprConfig, hIfCfg, hIfTrCfg, pIfBlock, sz
  949. );
  950. }
  951. else
  952. {
  953. rc = MprConfigTransportSetInfo (
  954. g_hMprConfig, hTrCfg, NULL, 0, pIfBlock, sz, NULL
  955. );
  956. }
  957. if (rc == NO_ERROR)
  958. {
  959. if (InterfaceNameW != NULL)
  960. {
  961. DisplayIPXMessage (g_hModule, MSG_NBIF_SET_CFG, InterfaceNameW );
  962. }
  963. }
  964. else
  965. {
  966. DisplayIPXMessage (g_hModule, MSG_CLIENT_NBIF_SET_CFG );
  967. }
  968. }
  969. else
  970. {
  971. DisplayIPXMessage (g_hModule, MSG_INTERFACE_INFO_CORRUPTED);
  972. rc = ERROR_INVALID_DATA;
  973. }
  974. MprConfigBufferFree (pIfBlock);
  975. }
  976. else
  977. {
  978. DisplayError( g_hModule, rc);
  979. }
  980. return rc;
  981. }
  982. DWORD
  983. AdmSetNbIpxIf (
  984. LPWSTR InterfaceNameW,
  985. PULONG pAccept OPTIONAL,
  986. PULONG pDeliver OPTIONAL
  987. )
  988. {
  989. DWORD rc;
  990. DWORD sz;
  991. HANDLE hIfAdm;
  992. LPBYTE pIfBlock;
  993. if (InterfaceNameW != NULL)
  994. {
  995. rc = MprAdminInterfaceGetHandle (
  996. g_hMprAdmin, InterfaceNameW, &hIfAdm, FALSE
  997. );
  998. if (rc == NO_ERROR)
  999. {
  1000. rc = MprAdminInterfaceTransportGetInfo (
  1001. g_hMprAdmin, hIfAdm, PID_IPX, &pIfBlock, &sz
  1002. );
  1003. }
  1004. }
  1005. else
  1006. {
  1007. rc = MprAdminTransportGetInfo (
  1008. g_hMprAdmin, PID_IPX, NULL, NULL, &pIfBlock, &sz
  1009. );
  1010. if (rc == NO_ERROR)
  1011. {
  1012. if (pIfBlock == NULL)
  1013. return rc;
  1014. }
  1015. }
  1016. if (rc == NO_ERROR)
  1017. {
  1018. PIPX_TOC_ENTRY pIpxToc;
  1019. pIpxToc = GetIPXTocEntry (
  1020. (PIPX_INFO_BLOCK_HEADER)pIfBlock,
  1021. IPX_INTERFACE_INFO_TYPE
  1022. );
  1023. if (pIpxToc != NULL)
  1024. {
  1025. PIPX_IF_INFO pIpxInfo;
  1026. pIpxInfo = (PIPX_IF_INFO)(pIfBlock + pIpxToc->Offset);
  1027. if (ARGUMENT_PRESENT (pAccept))
  1028. {
  1029. pIpxInfo->NetbiosAccept = *pAccept;
  1030. }
  1031. if (ARGUMENT_PRESENT (pDeliver))
  1032. {
  1033. pIpxInfo->NetbiosDeliver = *pDeliver;
  1034. }
  1035. if (InterfaceNameW != NULL)
  1036. {
  1037. rc = MprAdminInterfaceTransportSetInfo (
  1038. g_hMprAdmin, hIfAdm, PID_IPX, pIfBlock,
  1039. ((PIPX_INFO_BLOCK_HEADER)pIfBlock)->Size
  1040. );
  1041. }
  1042. else
  1043. {
  1044. rc = MprAdminTransportSetInfo (
  1045. g_hMprAdmin, PID_IPX, NULL, 0, pIfBlock,
  1046. ((PIPX_INFO_BLOCK_HEADER)pIfBlock)->Size
  1047. );
  1048. }
  1049. if (rc == NO_ERROR)
  1050. {
  1051. if (InterfaceNameW != NULL)
  1052. {
  1053. DisplayIPXMessage (
  1054. g_hModule,MSG_NBIF_SET_ADM, InterfaceNameW
  1055. );
  1056. }
  1057. else
  1058. {
  1059. DisplayIPXMessage (g_hModule, MSG_CLIENT_NBIF_SET_ADM);
  1060. }
  1061. }
  1062. else
  1063. {
  1064. DisplayError( g_hModule, rc);
  1065. }
  1066. }
  1067. else
  1068. {
  1069. DisplayIPXMessage (g_hModule, MSG_INTERFACE_INFO_CORRUPTED);
  1070. rc = ERROR_INVALID_DATA;
  1071. }
  1072. MprAdminBufferFree (pIfBlock);
  1073. }
  1074. else
  1075. {
  1076. DisplayError( g_hModule, rc);
  1077. }
  1078. return rc;
  1079. }