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.

1514 lines
33 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. routing\netsh\ipx\ipxhandle.c
  5. Abstract:
  6. IPX Command handler.
  7. Revision History:
  8. V Raman 12/2/98 Created
  9. --*/
  10. #include "precomp.h"
  11. #pragma hdrstop
  12. DWORD
  13. HandleIpxInterface(
  14. IN OUT LPWSTR *ppwcArguments,
  15. IN DWORD dwCurrentIndex,
  16. IN DWORD dwArgCount,
  17. IN IPX_OPERATION ioOP
  18. );
  19. DWORD
  20. HandleIpxStaticRoute(
  21. IN OUT LPWSTR *ppwcArguments,
  22. IN DWORD dwCurrentIndex,
  23. IN DWORD dwArgCount,
  24. IN IPX_OPERATION ioOP
  25. );
  26. DWORD
  27. HandleIpxStaticService(
  28. IN OUT LPWSTR *ppwcArguments,
  29. IN DWORD dwCurrentIndex,
  30. IN DWORD dwArgCount,
  31. IN IPX_OPERATION ioOP
  32. );
  33. DWORD
  34. HandleIpxTrafficFilters(
  35. IN OUT LPWSTR *ppwcArguments,
  36. IN DWORD dwCurrentIndex,
  37. IN DWORD dwArgCount,
  38. IN IPX_OPERATION ioOP
  39. );
  40. //
  41. // Handle static route operations
  42. //
  43. DWORD
  44. HandleIpxAddRoute(
  45. IN LPCWSTR pwszMachineName,
  46. IN OUT LPWSTR *ppwcArguments,
  47. IN DWORD dwCurrentIndex,
  48. IN DWORD dwArgCount,
  49. IN DWORD dwFlags,
  50. IN LPCVOID pvData,
  51. OUT PBOOL pbDone
  52. )
  53. /*++
  54. Routine Description :
  55. This function handles addition of static IPX routes by
  56. mapping the parameters to those required by the corresp.
  57. routemon routine.
  58. Arguments :
  59. ppwcArguments - list of arguments to the add route command
  60. dwCurrentIndex - index of current argument in the argument table
  61. dwArgCount - Number of arguments in the argument table
  62. pbDone - As yet undetermined
  63. Return Value
  64. NO_ERROR - Success
  65. --*/
  66. {
  67. return HandleIpxStaticRoute(
  68. ppwcArguments, dwCurrentIndex, dwArgCount, IPX_OPERATION_ADD
  69. );
  70. }
  71. DWORD
  72. HandleIpxDelRoute(
  73. IN LPCWSTR pwszMachine,
  74. IN OUT LPWSTR *ppwcArguments,
  75. IN DWORD dwCurrentIndex,
  76. IN DWORD dwArgCount,
  77. IN DWORD dwFlags,
  78. IN LPCVOID pvData,
  79. OUT BOOL *pbDone
  80. )
  81. /*++
  82. Routine Description :
  83. This function handles deletion of static IPX routes by
  84. mapping the parameters to those required by the corresp.
  85. routemon routine.
  86. Arguments :
  87. ppwcArguments - list of arguments to the add route command
  88. dwCurrentIndex - index of current argument in the argument table
  89. dwArgCount - Number of arguments in the argument table
  90. pbDone - As yet undetermined
  91. Return Value
  92. NO_ERROR - Success
  93. --*/
  94. {
  95. return HandleIpxStaticRoute(
  96. ppwcArguments, dwCurrentIndex, dwArgCount, IPX_OPERATION_DELETE
  97. );
  98. }
  99. DWORD
  100. HandleIpxSetRoute(
  101. IN LPCWSTR pwszMachine,
  102. IN OUT LPWSTR *ppwcArguments,
  103. IN DWORD dwCurrentIndex,
  104. IN DWORD dwArgCount,
  105. IN DWORD dwFlags,
  106. IN LPCVOID pvData,
  107. OUT BOOL *pbDone
  108. )
  109. /*++
  110. Routine Description :
  111. This function handles update of static IPX routes by
  112. mapping the parameters to those required by the corresp.
  113. routemon routine.
  114. Arguments :
  115. ppwcArguments - list of arguments to the add route command
  116. dwCurrentIndex - index of current argument in the argument table
  117. dwArgCount - Number of arguments in the argument table
  118. pbDone - As yet undetermined
  119. Return Value
  120. NO_ERROR - Success
  121. --*/
  122. {
  123. return HandleIpxStaticRoute(
  124. ppwcArguments, dwCurrentIndex, dwArgCount, IPX_OPERATION_SET
  125. );
  126. }
  127. DWORD
  128. HandleIpxShowRoute(
  129. IN LPCWSTR pwszMachine,
  130. IN OUT LPWSTR *ppwcArguments,
  131. IN DWORD dwCurrentIndex,
  132. IN DWORD dwArgCount,
  133. IN DWORD dwFlags,
  134. IN LPCVOID pvData,
  135. OUT BOOL *pbDone
  136. )
  137. /*++
  138. Routine Description :
  139. This function handles display of static IPX routes by
  140. mapping the parameters to those required by the corresp.
  141. routemon routine.
  142. Arguments :
  143. ppwcArguments - list of arguments to the add route command
  144. dwCurrentIndex - index of current argument in the argument table
  145. dwArgCount - Number of arguments in the argument table
  146. pbDone - As yet undetermined
  147. Return Value
  148. NO_ERROR - Success
  149. --*/
  150. {
  151. return HandleIpxStaticRoute(
  152. ppwcArguments, dwCurrentIndex, dwArgCount, IPX_OPERATION_SHOW
  153. );
  154. }
  155. DWORD
  156. HandleIpxStaticRoute(
  157. IN OUT LPWSTR *ppwcOldArguments,
  158. IN DWORD dwCurrentIndex,
  159. IN DWORD dwOldArgCount,
  160. IN IPX_OPERATION ioOP
  161. )
  162. /*++
  163. Routine Description :
  164. This routine munges the command line and invokes the appropriate
  165. routemon routine to handle static route operations
  166. Arguments :
  167. ppwcArguments - command line argument array
  168. dwCurrentIndex - current argument under consideration
  169. dwArgCount - Number of arguments in ppwcArguments
  170. bAdd - flag indicating whether IPX is being added or deleted
  171. Return Value :
  172. --*/
  173. {
  174. DWORD dwErr;
  175. BOOL bFreeNewArg = FALSE;
  176. PWCHAR pwszIfName;
  177. DWORD dwArgCount = dwOldArgCount;
  178. PWCHAR *ppwcArguments = NULL;
  179. //
  180. // Check if name= option is specified
  181. //
  182. pwszIfName = TOKEN_INTERFACE_NAME;
  183. if ( pwszIfName == NULL )
  184. {
  185. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  186. DisplayError( g_hModule, dwErr );
  187. return dwErr;
  188. }
  189. do {
  190. // Munge arguments into old format
  191. dwErr = MungeArguments(
  192. ppwcOldArguments, dwOldArgCount, (PBYTE *) &ppwcArguments,
  193. &dwArgCount, &bFreeNewArg
  194. );
  195. if (dwErr)
  196. {
  197. break;
  198. }
  199. if ( ( dwCurrentIndex < dwArgCount ) &&
  200. !_wcsnicmp(
  201. ppwcArguments[ dwCurrentIndex ], pwszIfName, wcslen( pwszIfName )
  202. ) )
  203. {
  204. //
  205. // ok name= option tag specified, remove it and the following space
  206. //
  207. wcscpy(
  208. ppwcArguments[ dwCurrentIndex ],
  209. &ppwcArguments[ dwCurrentIndex ][ wcslen( pwszIfName ) + 2 ]
  210. );
  211. }
  212. //
  213. // Now invoke the original routemon routine with what looks
  214. // like an appriate command line
  215. //
  216. switch ( ioOP )
  217. {
  218. case IPX_OPERATION_ADD :
  219. dwErr = CreateStRt(
  220. dwArgCount - dwCurrentIndex,
  221. ppwcArguments + dwCurrentIndex
  222. );
  223. break;
  224. case IPX_OPERATION_DELETE :
  225. dwErr = DeleteStRt(
  226. dwArgCount - dwCurrentIndex,
  227. ppwcArguments + dwCurrentIndex
  228. );
  229. break;
  230. case IPX_OPERATION_SET :
  231. dwErr = SetStRt(
  232. dwArgCount - dwCurrentIndex,
  233. ppwcArguments + dwCurrentIndex
  234. );
  235. break;
  236. case IPX_OPERATION_SHOW :
  237. dwErr = ShowStRt(
  238. dwArgCount - dwCurrentIndex,
  239. ppwcArguments + dwCurrentIndex,
  240. FALSE
  241. );
  242. break;
  243. }
  244. } while (FALSE);
  245. if ( bFreeNewArg )
  246. {
  247. FreeArgTable( dwOldArgCount, ppwcArguments );
  248. }
  249. return dwErr;
  250. }
  251. //
  252. // Handle static service operations
  253. //
  254. DWORD
  255. HandleIpxAddService(
  256. IN LPCWSTR pwszMachine,
  257. IN OUT LPWSTR *ppwcArguments,
  258. IN DWORD dwCurrentIndex,
  259. IN DWORD dwArgCount,
  260. IN DWORD dwFlags,
  261. IN LPCVOID pvData,
  262. OUT BOOL *pbDone
  263. )
  264. /*++
  265. Routine Description :
  266. This function handles addition of static IPX services by
  267. mapping the parameters to those required by the corresp.
  268. routemon routine.
  269. Arguments :
  270. ppwcArguments - list of arguments to the add route command
  271. dwCurrentIndex - index of current argument in the argument table
  272. dwArgCount - Number of arguments in the argument table
  273. pbDone - As yet undetermined
  274. Return Value
  275. NO_ERROR - Success
  276. --*/
  277. {
  278. return HandleIpxStaticService(
  279. ppwcArguments, dwCurrentIndex, dwArgCount, IPX_OPERATION_ADD
  280. );
  281. }
  282. DWORD
  283. HandleIpxDelService(
  284. IN LPCWSTR pwszMachine,
  285. IN OUT LPWSTR *ppwcArguments,
  286. IN DWORD dwCurrentIndex,
  287. IN DWORD dwArgCount,
  288. IN DWORD dwFlags,
  289. IN LPCVOID pvData,
  290. OUT BOOL *pbDone
  291. )
  292. /*++
  293. Routine Description :
  294. This function handles deletion of static IPX services by
  295. mapping the parameters to those required by the corresp.
  296. routemon routine.
  297. Arguments :
  298. ppwcArguments - list of arguments to the add route command
  299. dwCurrentIndex - index of current argument in the argument table
  300. dwArgCount - Number of arguments in the argument table
  301. pbDone - As yet undetermined
  302. Return Value
  303. NO_ERROR - Success
  304. --*/
  305. {
  306. return HandleIpxStaticService(
  307. ppwcArguments, dwCurrentIndex, dwArgCount, IPX_OPERATION_DELETE
  308. );
  309. }
  310. DWORD
  311. HandleIpxSetService(
  312. IN LPCWSTR pwszMachine,
  313. IN OUT LPWSTR *ppwcArguments,
  314. IN DWORD dwCurrentIndex,
  315. IN DWORD dwArgCount,
  316. IN DWORD dwFlags,
  317. IN LPCVOID pvData,
  318. OUT BOOL *pbDone
  319. )
  320. /*++
  321. Routine Description :
  322. This function handles update of static IPX services by
  323. mapping the parameters to those required by the corresp.
  324. routemon routine.
  325. Arguments :
  326. ppwcArguments - list of arguments to the add route command
  327. dwCurrentIndex - index of current argument in the argument table
  328. dwArgCount - Number of arguments in the argument table
  329. pbDone - As yet undetermined
  330. Return Value
  331. NO_ERROR - Success
  332. --*/
  333. {
  334. return HandleIpxStaticService(
  335. ppwcArguments, dwCurrentIndex, dwArgCount, IPX_OPERATION_SET
  336. );
  337. }
  338. DWORD
  339. HandleIpxShowService(
  340. IN LPCWSTR pwszMachine,
  341. IN OUT LPWSTR *ppwcArguments,
  342. IN DWORD dwCurrentIndex,
  343. IN DWORD dwArgCount,
  344. IN DWORD dwFlags,
  345. IN LPCVOID pvData,
  346. OUT BOOL *pbDone
  347. )
  348. /*++
  349. Routine Description :
  350. This function handles display of static IPX services by
  351. mapping the parameters to those required by the corresp.
  352. routemon routine.
  353. Arguments :
  354. ppwcArguments - list of arguments to the add route command
  355. dwCurrentIndex - index of current argument in the argument table
  356. dwArgCount - Number of arguments in the argument table
  357. pbDone - As yet undetermined
  358. Return Value
  359. NO_ERROR - Success
  360. --*/
  361. {
  362. return HandleIpxStaticService(
  363. ppwcArguments, dwCurrentIndex, dwArgCount, IPX_OPERATION_SHOW
  364. );
  365. }
  366. DWORD
  367. HandleIpxStaticService(
  368. IN OUT LPWSTR *ppwcOldArguments,
  369. IN DWORD dwCurrentIndex,
  370. IN DWORD dwOldArgCount,
  371. IN IPX_OPERATION ioOP
  372. )
  373. /*++
  374. Routine Description :
  375. This routine munges the command line and invokes the appropriate
  376. routemon routine to handle static service operations
  377. Arguments :
  378. ppwcArguments - command line argument array
  379. dwCurrentIndex - current argument under consideration
  380. dwArgCount - Number of arguments in ppwcArguments
  381. bAdd - flag indicating whether IPX is being added or deleted
  382. Return Value :
  383. --*/
  384. {
  385. DWORD dwErr;
  386. BOOL bFreeNewArg = FALSE;
  387. PWCHAR pwszIfName;
  388. DWORD dwArgCount = dwOldArgCount;
  389. PWCHAR *ppwcArguments = NULL;
  390. //
  391. // Check if name= option is specified
  392. //
  393. pwszIfName = TOKEN_INTERFACE_NAME;
  394. if ( pwszIfName == NULL )
  395. {
  396. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  397. DisplayError( g_hModule, dwErr );
  398. return dwErr;
  399. }
  400. do {
  401. // Munge arguments into old format
  402. dwErr = MungeArguments(
  403. ppwcOldArguments, dwOldArgCount, (PBYTE *) &ppwcArguments,
  404. &dwArgCount, &bFreeNewArg
  405. );
  406. if (dwErr)
  407. {
  408. break;
  409. }
  410. if ( ( dwCurrentIndex < dwArgCount ) &&
  411. !_wcsnicmp(
  412. ppwcArguments[ dwCurrentIndex ], pwszIfName, wcslen( pwszIfName )
  413. ) )
  414. {
  415. //
  416. // ok name= option tag specified, remove it and the following space
  417. //
  418. wcscpy(
  419. ppwcArguments[ dwCurrentIndex ],
  420. &ppwcArguments[ dwCurrentIndex ][ wcslen( pwszIfName ) + 2 ]
  421. );
  422. }
  423. //
  424. // Now invoke the original routemon routine with what looks
  425. // like an appriate command line
  426. //
  427. switch ( ioOP )
  428. {
  429. case IPX_OPERATION_ADD :
  430. dwErr = CreateStSvc(
  431. dwArgCount - dwCurrentIndex,
  432. ppwcArguments + dwCurrentIndex
  433. );
  434. break;
  435. case IPX_OPERATION_DELETE :
  436. dwErr = DeleteStSvc(
  437. dwArgCount - dwCurrentIndex,
  438. ppwcArguments + dwCurrentIndex
  439. );
  440. break;
  441. case IPX_OPERATION_SET :
  442. dwErr = SetStSvc(
  443. dwArgCount - dwCurrentIndex,
  444. ppwcArguments + dwCurrentIndex
  445. );
  446. break;
  447. case IPX_OPERATION_SHOW :
  448. dwErr = ShowStSvc(
  449. dwArgCount - dwCurrentIndex,
  450. ppwcArguments + dwCurrentIndex,
  451. FALSE
  452. );
  453. break;
  454. }
  455. } while (FALSE);
  456. if ( bFreeNewArg )
  457. {
  458. FreeArgTable( dwOldArgCount, ppwcArguments );
  459. }
  460. return dwErr;
  461. }
  462. //
  463. // Handle packet filter operations
  464. //
  465. DWORD
  466. HandleIpxAddFilter(
  467. IN LPCWSTR pwszMachine,
  468. IN OUT LPWSTR *ppwcArguments,
  469. IN DWORD dwCurrentIndex,
  470. IN DWORD dwArgCount,
  471. IN DWORD dwFlags,
  472. IN LPCVOID pvData,
  473. OUT BOOL *pbDone
  474. )
  475. /*++
  476. Routine Description :
  477. This function handles addition of IPX traffic filters by
  478. mapping the parameters to those required by the corresp.
  479. routemon routine.
  480. Arguments :
  481. ppwcArguments - list of arguments to the add route command
  482. dwCurrentIndex - index of current argument in the argument table
  483. dwArgCount - Number of arguments in the argument table
  484. pbDone - As yet undetermined
  485. Return Value
  486. NO_ERROR - Success
  487. --*/
  488. {
  489. return HandleIpxTrafficFilters(
  490. ppwcArguments, dwCurrentIndex, dwArgCount, IPX_OPERATION_ADD
  491. );
  492. }
  493. DWORD
  494. HandleIpxDelFilter(
  495. IN LPCWSTR pwszMachine,
  496. IN OUT LPWSTR *ppwcArguments,
  497. IN DWORD dwCurrentIndex,
  498. IN DWORD dwArgCount,
  499. IN DWORD dwFlags,
  500. IN LPCVOID pvData,
  501. OUT BOOL *pbDone
  502. )
  503. /*++
  504. Routine Description :
  505. This function handles deletion of IPX traffic filters by
  506. mapping the parameters to those required by the corresp.
  507. routemon routine.
  508. Arguments :
  509. ppwcArguments - list of arguments to the add route command
  510. dwCurrentIndex - index of current argument in the argument table
  511. dwArgCount - Number of arguments in the argument table
  512. pbDone - As yet undetermined
  513. Return Value
  514. NO_ERROR - Success
  515. --*/
  516. {
  517. return HandleIpxTrafficFilters(
  518. ppwcArguments, dwCurrentIndex, dwArgCount, IPX_OPERATION_DELETE
  519. );
  520. }
  521. DWORD
  522. HandleIpxSetFilter(
  523. IN LPCWSTR pwszMachine,
  524. IN OUT LPWSTR *ppwcArguments,
  525. IN DWORD dwCurrentIndex,
  526. IN DWORD dwArgCount,
  527. IN DWORD dwFlags,
  528. IN LPCVOID pvData,
  529. OUT BOOL *pbDone
  530. )
  531. /*++
  532. Routine Description :
  533. This function handles update of IPX traffic filters by
  534. mapping the parameters to those required by the corresp.
  535. routemon routine.
  536. Arguments :
  537. ppwcArguments - list of arguments to the add route command
  538. dwCurrentIndex - index of current argument in the argument table
  539. dwArgCount - Number of arguments in the argument table
  540. pbDone - As yet undetermined
  541. Return Value
  542. NO_ERROR - Success
  543. --*/
  544. {
  545. return HandleIpxTrafficFilters(
  546. ppwcArguments, dwCurrentIndex, dwArgCount, IPX_OPERATION_SET
  547. );
  548. }
  549. DWORD
  550. HandleIpxShowFilter(
  551. IN LPCWSTR pwszMachine,
  552. IN OUT LPWSTR *ppwcArguments,
  553. IN DWORD dwCurrentIndex,
  554. IN DWORD dwArgCount,
  555. IN DWORD dwFlags,
  556. IN LPCVOID pvData,
  557. OUT BOOL *pbDone
  558. )
  559. /*++
  560. Routine Description :
  561. This function handles display of IPX traffic filters by
  562. mapping the parameters to those required by the corresp.
  563. routemon routine.
  564. Arguments :
  565. ppwcArguments - list of arguments to the add route command
  566. dwCurrentIndex - index of current argument in the argument table
  567. dwArgCount - Number of arguments in the argument table
  568. pbDone - As yet undetermined
  569. Return Value
  570. NO_ERROR - Success
  571. --*/
  572. {
  573. return HandleIpxTrafficFilters(
  574. ppwcArguments, dwCurrentIndex, dwArgCount, IPX_OPERATION_SHOW
  575. );
  576. }
  577. DWORD
  578. HandleIpxTrafficFilters(
  579. IN OUT LPWSTR *ppwcOldArguments,
  580. IN DWORD dwCurrentIndex,
  581. IN DWORD dwOldArgCount,
  582. IN IPX_OPERATION ioOP
  583. )
  584. /*++
  585. Routine Description :
  586. This routine munges the command line and invokes the appropriate
  587. routemon routine to handle traffic filter operations
  588. Arguments :
  589. ppwcArguments - command line argument array
  590. dwCurrentIndex - current argument under consideration
  591. dwArgCount - Number of arguments in ppwcArguments
  592. bAdd - flag indicating whether IPX is being added or deleted
  593. Return Value :
  594. --*/
  595. {
  596. DWORD dwErr;
  597. BOOL bFreeNewArg = FALSE;
  598. PWCHAR pwszIfName;
  599. DWORD dwArgCount = dwOldArgCount;
  600. PWCHAR *ppwcArguments = NULL;
  601. //
  602. // Check if name= option is specified
  603. //
  604. pwszIfName = TOKEN_INTERFACE_NAME;
  605. if ( pwszIfName == NULL )
  606. {
  607. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  608. DisplayError( g_hModule, dwErr );
  609. return dwErr;
  610. }
  611. do {
  612. // Munge arguments into old format
  613. dwErr = MungeArguments(
  614. ppwcOldArguments, dwOldArgCount, (PBYTE *) &ppwcArguments,
  615. &dwArgCount, &bFreeNewArg
  616. );
  617. if (dwErr)
  618. {
  619. break;
  620. }
  621. if ( ( dwCurrentIndex < dwArgCount ) &&
  622. !_wcsnicmp(
  623. ppwcArguments[ dwCurrentIndex ], pwszIfName, wcslen( pwszIfName )
  624. ) )
  625. {
  626. //
  627. // ok name= option tag specified, remove it and the following space
  628. //
  629. wcscpy(
  630. ppwcArguments[ dwCurrentIndex ],
  631. &ppwcArguments[ dwCurrentIndex ][ wcslen( pwszIfName ) + 2 ]
  632. );
  633. }
  634. //
  635. // Now invoke the original routemon routine with what looks
  636. // like an appriate command line
  637. //
  638. switch ( ioOP )
  639. {
  640. case IPX_OPERATION_ADD :
  641. dwErr = CreateTfFlt(
  642. dwArgCount - dwCurrentIndex,
  643. ppwcArguments + dwCurrentIndex
  644. );
  645. break;
  646. case IPX_OPERATION_DELETE :
  647. dwErr = DeleteTfFlt(
  648. dwArgCount - dwCurrentIndex,
  649. ppwcArguments + dwCurrentIndex
  650. );
  651. break;
  652. case IPX_OPERATION_SET :
  653. dwErr = SetTfFlt(
  654. dwArgCount - dwCurrentIndex,
  655. ppwcArguments + dwCurrentIndex
  656. );
  657. break;
  658. case IPX_OPERATION_SHOW :
  659. dwErr = ShowTfFlt(
  660. dwArgCount - dwCurrentIndex,
  661. ppwcArguments + dwCurrentIndex,
  662. FALSE
  663. );
  664. break;
  665. }
  666. } while (FALSE);
  667. if ( bFreeNewArg )
  668. {
  669. FreeArgTable( dwOldArgCount, ppwcArguments );
  670. }
  671. return dwErr;
  672. }
  673. //
  674. // Handle interface operations
  675. //
  676. DWORD
  677. HandleIpxAddInterface(
  678. IN LPCWSTR pwszMachine,
  679. IN OUT LPWSTR *ppwcArguments,
  680. IN DWORD dwCurrentIndex,
  681. IN DWORD dwArgCount,
  682. IN DWORD dwFlags,
  683. IN LPCVOID pvData,
  684. OUT BOOL *pbDone
  685. )
  686. /*++
  687. Routine Description :
  688. This routine munges the command line and invokes the appropriate
  689. routemon routine to handle interface addition
  690. Arguments :
  691. ppwcArguments - command line argument array
  692. dwCurrentIndex - current argument under consideration
  693. dwArgCount - Number of arguments in ppwcArguments
  694. pbDone - Don't know
  695. Return Value :
  696. --*/
  697. {
  698. return HandleIpxInterface(
  699. ppwcArguments, dwCurrentIndex, dwArgCount, IPX_OPERATION_ADD
  700. );
  701. }
  702. DWORD
  703. HandleIpxDelInterface(
  704. IN LPCWSTR pwszMachine,
  705. IN OUT LPWSTR *ppwcArguments,
  706. IN DWORD dwCurrentIndex,
  707. IN DWORD dwArgCount,
  708. IN DWORD dwFlags,
  709. IN LPCVOID pvData,
  710. OUT BOOL *pbDone
  711. )
  712. /*++
  713. Routine Description :
  714. This routine munges the command line and invokes the appropriate
  715. routemon routine to handle interface addition
  716. Arguments :
  717. ppwcArguments - command line argument array
  718. dwCurrentIndex - current argument under consideration
  719. dwArgCount - Number of arguments in ppwcArguments
  720. pbDone - Don't know
  721. Return Value :
  722. --*/
  723. {
  724. return HandleIpxInterface(
  725. ppwcArguments, dwCurrentIndex, dwArgCount, IPX_OPERATION_DELETE
  726. );
  727. }
  728. DWORD
  729. HandleIpxSetInterface(
  730. IN LPCWSTR pwszMachine,
  731. IN OUT LPWSTR *ppwcArguments,
  732. IN DWORD dwCurrentIndex,
  733. IN DWORD dwArgCount,
  734. IN DWORD dwFlags,
  735. IN LPCVOID pvData,
  736. OUT BOOL *pbDone
  737. )
  738. /*++
  739. Routine Description :
  740. This routine munges the command line and invokes the appropriate
  741. routemon routine to handle interface addition
  742. Arguments :
  743. ppwcArguments - command line argument array
  744. dwCurrentIndex - current argument under consideration
  745. dwArgCount - Number of arguments in ppwcArguments
  746. pbDone - Don't know
  747. Return Value :
  748. --*/
  749. {
  750. return HandleIpxInterface(
  751. ppwcArguments, dwCurrentIndex, dwArgCount, IPX_OPERATION_SET
  752. );
  753. }
  754. DWORD
  755. HandleIpxShowInterface(
  756. IN LPCWSTR pwszMachine,
  757. IN OUT LPWSTR *ppwcArguments,
  758. IN DWORD dwCurrentIndex,
  759. IN DWORD dwArgCount,
  760. IN DWORD dwFlags,
  761. IN LPCVOID pvData,
  762. OUT BOOL *pbDone
  763. )
  764. /*++
  765. Routine Description :
  766. This routine munges the command line and invokes the appropriate
  767. routemon routine to handle interface addition
  768. Arguments :
  769. ppwcArguments - command line argument array
  770. dwCurrentIndex - current argument under consideration
  771. dwArgCount - Number of arguments in ppwcArguments
  772. pbDone - Don't know
  773. Return Value :
  774. --*/
  775. {
  776. return HandleIpxInterface(
  777. ppwcArguments, dwCurrentIndex, dwArgCount, IPX_OPERATION_SHOW
  778. );
  779. }
  780. DWORD
  781. HandleIpxInterface(
  782. IN OUT LPWSTR *ppwcOldArguments,
  783. IN DWORD dwCurrentIndex,
  784. IN DWORD dwOldArgCount,
  785. IN IPX_OPERATION ioOP
  786. )
  787. /*++
  788. Routine Description :
  789. This routine munges the command line and invokes the appropriate
  790. routemon routine to handle interface addition
  791. Arguments :
  792. ppwcArguments - command line argument array
  793. dwCurrentIndex - current argument under consideration
  794. dwArgCount - Number of arguments in ppwcArguments
  795. bAdd - flag indicating whether IPX is being added or deleted
  796. Return Value :
  797. --*/
  798. {
  799. DWORD dwErr;
  800. BOOL bFreeNewArg = FALSE;
  801. PWCHAR pwszIfName;
  802. DWORD dwArgCount = dwOldArgCount;
  803. PWCHAR *ppwcArguments = NULL;
  804. //
  805. // Check if name= option is specified
  806. //
  807. pwszIfName = TOKEN_INTERFACE_NAME;
  808. if ( pwszIfName == NULL )
  809. {
  810. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  811. DisplayError( g_hModule, dwErr );
  812. return dwErr;
  813. }
  814. do {
  815. // Munge arguments into old format
  816. dwErr = MungeArguments(
  817. ppwcOldArguments, dwOldArgCount, (PBYTE *) &ppwcArguments,
  818. &dwArgCount, &bFreeNewArg
  819. );
  820. if (dwErr)
  821. {
  822. break;
  823. }
  824. if ( ( dwCurrentIndex < dwArgCount ) &&
  825. !_wcsnicmp(
  826. ppwcArguments[ dwCurrentIndex ], pwszIfName, wcslen( pwszIfName )
  827. ) )
  828. {
  829. //
  830. // ok name= option tag specified, remove it and the following space
  831. //
  832. wcscpy(
  833. ppwcArguments[ dwCurrentIndex ],
  834. &ppwcArguments[ dwCurrentIndex ][ wcslen( pwszIfName ) + 2 ]
  835. );
  836. }
  837. //
  838. // Now invoke the original routemon routine with what looks
  839. // like an appriate command line
  840. //
  841. switch ( ioOP )
  842. {
  843. case IPX_OPERATION_ADD :
  844. dwErr = InstallIpx(
  845. dwArgCount - dwCurrentIndex,
  846. ppwcArguments + dwCurrentIndex
  847. );
  848. break;
  849. case IPX_OPERATION_DELETE :
  850. dwErr = RemoveIpx(
  851. dwArgCount - dwCurrentIndex,
  852. ppwcArguments + dwCurrentIndex
  853. );
  854. break;
  855. case IPX_OPERATION_SET :
  856. dwErr = SetIpxIf(
  857. dwArgCount - dwCurrentIndex,
  858. ppwcArguments + dwCurrentIndex
  859. );
  860. break;
  861. case IPX_OPERATION_SHOW :
  862. dwErr = ShowIpxIf(
  863. dwArgCount - dwCurrentIndex,
  864. ppwcArguments + dwCurrentIndex,
  865. FALSE
  866. );
  867. break;
  868. }
  869. } while (FALSE);
  870. if ( bFreeNewArg )
  871. {
  872. FreeArgTable( dwOldArgCount, ppwcArguments );
  873. }
  874. return dwErr;
  875. }
  876. //
  877. // Handle loglevel operations
  878. //
  879. DWORD
  880. HandleIpxSetLoglevel(
  881. IN LPCWSTR pwszMachine,
  882. IN OUT LPWSTR *ppwcArguments,
  883. IN DWORD dwCurrentIndex,
  884. IN DWORD dwArgCount,
  885. IN DWORD dwFlags,
  886. IN LPCVOID pvData,
  887. OUT BOOL *pbDone
  888. )
  889. {
  890. DWORD dwErr;
  891. BOOL bFreeNewArg = FALSE;
  892. DWORD dwNewArgCount = dwArgCount;
  893. PWCHAR *ppwcNewArguments = NULL;
  894. do {
  895. // Munge arguments into old format
  896. dwErr = MungeArguments(
  897. ppwcArguments, dwArgCount, (PBYTE *) &ppwcNewArguments,
  898. &dwNewArgCount, &bFreeNewArg
  899. );
  900. if (dwErr)
  901. {
  902. break;
  903. }
  904. dwErr= SetIpxGl( dwNewArgCount - dwCurrentIndex,
  905. ppwcNewArguments + dwCurrentIndex );
  906. } while (FALSE);
  907. if ( bFreeNewArg )
  908. {
  909. FreeArgTable( dwArgCount, ppwcNewArguments );
  910. }
  911. return dwErr;
  912. }
  913. DWORD
  914. HandleIpxShowLoglevel(
  915. IN LPCWSTR pwszMachine,
  916. IN OUT LPWSTR *ppwcArguments,
  917. IN DWORD dwCurrentIndex,
  918. IN DWORD dwArgCount,
  919. IN DWORD dwFlags,
  920. IN LPCVOID pvData,
  921. OUT BOOL *pbDone
  922. )
  923. {
  924. return ShowIpxGl(
  925. dwArgCount - dwCurrentIndex,
  926. ppwcArguments + dwCurrentIndex,
  927. FALSE
  928. );
  929. }
  930. DWORD
  931. HandleIpxUpdate(
  932. IN LPCWSTR pwszMachine,
  933. IN OUT LPWSTR *ppwcArguments,
  934. IN DWORD dwCurrentIndex,
  935. IN DWORD dwArgCount,
  936. IN DWORD dwFlags,
  937. IN LPCVOID pvData,
  938. OUT BOOL *pbDone
  939. )
  940. {
  941. return NO_ERROR;
  942. }
  943. DWORD
  944. HandleIpxShowRouteTable(
  945. IN LPCWSTR pwszMachine,
  946. IN OUT LPWSTR *ppwcArguments,
  947. IN DWORD dwCurrentIndex,
  948. IN DWORD dwArgCount,
  949. IN DWORD dwFlags,
  950. IN LPCVOID pvData,
  951. OUT BOOL *pbDone
  952. )
  953. {
  954. return ShowRoute(
  955. dwArgCount - dwCurrentIndex,
  956. ppwcArguments + dwCurrentIndex
  957. );
  958. }
  959. DWORD
  960. HandleIpxShowServiceTable(
  961. IN LPCWSTR pwszMachine,
  962. IN OUT LPWSTR *ppwcArguments,
  963. IN DWORD dwCurrentIndex,
  964. IN DWORD dwArgCount,
  965. IN DWORD dwFlags,
  966. IN LPCVOID pvData,
  967. OUT BOOL *pbDone
  968. )
  969. {
  970. return ShowService(
  971. dwArgCount - dwCurrentIndex,
  972. ppwcArguments + dwCurrentIndex
  973. );
  974. }
  975. DWORD
  976. IpxDump(
  977. IN LPCWSTR pwszRouter,
  978. IN OUT LPWSTR *ppwcArguments,
  979. IN DWORD dwArgCount,
  980. IN LPCVOID pvData
  981. )
  982. {
  983. BOOL bDone;
  984. DWORD dwErr;
  985. dwErr = ConnectToRouter(pwszRouter);
  986. if (dwErr)
  987. {
  988. return dwErr;
  989. }
  990. DisplayIPXMessage (g_hModule, MSG_IPX_DUMP_HEADER );
  991. DisplayMessageT( DMP_IPX_HEADER );
  992. DumpIpxInformation(pwszRouter, ppwcArguments,dwArgCount,g_hMIBServer);
  993. DisplayMessageT( DMP_IPX_FOOTER );
  994. DisplayIPXMessage (g_hModule, MSG_IPX_DUMP_FOOTER );
  995. return NO_ERROR;
  996. }
  997. VOID
  998. DumpIpxInformation(
  999. IN LPCWSTR pwszMachineName,
  1000. IN OUT LPWSTR *ppwcArguments,
  1001. IN DWORD dwArgCount,
  1002. IN MIB_SERVER_HANDLE hMibServer
  1003. )
  1004. {
  1005. DWORD dwErr, dwRead = 0, dwTot = 0, i;
  1006. PMPR_INTERFACE_0 IfList;
  1007. WCHAR IfDisplayName[ MAX_INTERFACE_NAME_LEN + 1 ];
  1008. DWORD dwSize = sizeof(IfDisplayName);
  1009. PWCHAR argv[1];
  1010. //
  1011. // dump globals
  1012. //
  1013. ShowIpxGl( 0, NULL, TRUE );
  1014. //
  1015. // dump interfaces
  1016. //
  1017. ShowIpxIf( 0, NULL, TRUE );
  1018. //
  1019. // enumerate interfaces
  1020. //
  1021. if ( g_hMprAdmin )
  1022. {
  1023. dwErr = MprAdminInterfaceEnum(
  1024. g_hMprAdmin, 0, (unsigned char **)&IfList, MAXULONG, &dwRead,
  1025. &dwTot,NULL
  1026. );
  1027. }
  1028. else
  1029. {
  1030. dwErr = MprConfigInterfaceEnum(
  1031. g_hMprConfig, 0, (unsigned char **)&IfList, MAXULONG, &dwRead,
  1032. &dwTot,NULL
  1033. );
  1034. }
  1035. if ( dwErr != NO_ERROR )
  1036. {
  1037. DisplayError( g_hModule, dwErr);
  1038. return;
  1039. }
  1040. //
  1041. // enumerate filters on each interface
  1042. //
  1043. DisplayIPXMessage (g_hModule, MSG_IPX_DUMP_TRAFFIC_FILTER_HEADER );
  1044. for ( i = 0; i < dwRead; i++ )
  1045. {
  1046. dwErr = IpmontrGetFriendlyNameFromIfName(
  1047. IfList[i].wszInterfaceName, IfDisplayName, &dwSize
  1048. );
  1049. if ( dwErr == NO_ERROR )
  1050. {
  1051. argv[0] = IfDisplayName;
  1052. ShowTfFlt( 1, argv, TRUE );
  1053. }
  1054. }
  1055. //
  1056. // Enumerate static routes on each interface
  1057. //
  1058. DisplayIPXMessage (g_hModule, MSG_IPX_DUMP_STATIC_ROUTE_HEADER );
  1059. for ( i = 0; i < dwRead; i++ )
  1060. {
  1061. dwErr = IpmontrGetFriendlyNameFromIfName(
  1062. IfList[i].wszInterfaceName, IfDisplayName, &dwSize
  1063. );
  1064. if ( dwErr == NO_ERROR )
  1065. {
  1066. argv[0] = IfDisplayName;
  1067. ShowStRt( 1, argv, TRUE );
  1068. }
  1069. }
  1070. //
  1071. // Enumerate static services on each interface
  1072. //
  1073. DisplayIPXMessage (g_hModule, MSG_IPX_DUMP_STATIC_SERVICE_HEADER );
  1074. for ( i = 0; i < dwRead; i++ )
  1075. {
  1076. dwErr = IpmontrGetFriendlyNameFromIfName(
  1077. IfList[i].wszInterfaceName, IfDisplayName, &dwSize
  1078. );
  1079. if ( dwErr == NO_ERROR )
  1080. {
  1081. argv[0] = IfDisplayName;
  1082. ShowStSvc( 1, argv, TRUE );
  1083. }
  1084. }
  1085. if ( g_hMprAdmin )
  1086. {
  1087. MprAdminBufferFree( IfList );
  1088. }
  1089. else
  1090. {
  1091. MprConfigBufferFree( IfList );
  1092. }
  1093. }