Source code of Windows XP (NT5)
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.

1161 lines
21 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. rmftp.c
  5. Abstract:
  6. This module contains routines for the FTP transparent proxy module's
  7. interface to the IP router-manager. (See ROUTPROT.H for details).
  8. Author:
  9. Qiang Wang (qiangw) 10-Apr-2000
  10. Revision History:
  11. --*/
  12. #include "precomp.h"
  13. #pragma hdrstop
  14. #include <ipnatapi.h>
  15. COMPONENT_REFERENCE FtpComponentReference;
  16. PIP_FTP_GLOBAL_INFO FtpGlobalInfo = NULL;
  17. CRITICAL_SECTION FtpGlobalInfoLock;
  18. HANDLE FtpNotificationEvent;
  19. HANDLE FtpTimerQueueHandle = NULL;
  20. HANDLE FtpPortReservationHandle = NULL;
  21. ULONG FtpProtocolStopped = 0;
  22. const MPR_ROUTING_CHARACTERISTICS FtpRoutingCharacteristics =
  23. {
  24. MS_ROUTER_VERSION,
  25. MS_IP_FTP,
  26. RF_ROUTING|RF_ADD_ALL_INTERFACES,
  27. FtpRmStartProtocol,
  28. FtpRmStartComplete,
  29. FtpRmStopProtocol,
  30. FtpRmGetGlobalInfo,
  31. FtpRmSetGlobalInfo,
  32. NULL,
  33. NULL,
  34. FtpRmAddInterface,
  35. FtpRmDeleteInterface,
  36. FtpRmInterfaceStatus,
  37. FtpRmGetInterfaceInfo,
  38. FtpRmSetInterfaceInfo,
  39. FtpRmGetEventMessage,
  40. NULL,
  41. NULL,
  42. NULL,
  43. NULL,
  44. NULL,
  45. FtpRmMibCreate,
  46. FtpRmMibDelete,
  47. FtpRmMibGet,
  48. FtpRmMibSet,
  49. FtpRmMibGetFirst,
  50. FtpRmMibGetNext,
  51. NULL,
  52. NULL
  53. };
  54. IP_FTP_STATISTICS FtpStatistics;
  55. SUPPORT_FUNCTIONS FtpSupportFunctions;
  56. HANDLE FtpTranslatorHandle = NULL;
  57. VOID
  58. FtpCleanupModule(
  59. VOID
  60. )
  61. /*++
  62. Routine Description:
  63. This routine is invoked to cleanup the FTP transparent proxy module.
  64. Arguments:
  65. none.
  66. Return Value:
  67. none.
  68. Environment:
  69. Invoked from within a 'DllMain' routine on 'DLL_PROCESS_DETACH'.
  70. --*/
  71. {
  72. FtpShutdownInterfaceManagement();
  73. DeleteCriticalSection(&FtpGlobalInfoLock);
  74. DeleteComponentReference(&FtpComponentReference);
  75. } // FtpCleanupModule
  76. VOID
  77. FtpCleanupProtocol(
  78. VOID
  79. )
  80. /*++
  81. Routine Description:
  82. This routine is invoked to cleanup the FTP transparent proxy
  83. protocol-component after a 'StopProtocol'. It runs when the last reference
  84. to the component is released. (See 'COMPREF.H').
  85. Arguments:
  86. none.
  87. Return Value:
  88. none.
  89. Environment:
  90. Invoked from within an arbitrary context with no locks held.
  91. --*/
  92. {
  93. PROFILE("FtpCleanupProtocol");
  94. if (FtpGlobalInfo) { NH_FREE(FtpGlobalInfo); FtpGlobalInfo = NULL; }
  95. if (FtpTimerQueueHandle) {
  96. DeleteTimerQueueEx(FtpTimerQueueHandle, INVALID_HANDLE_VALUE);
  97. FtpTimerQueueHandle = NULL;
  98. }
  99. if (FtpPortReservationHandle) {
  100. NatShutdownPortReservation(FtpPortReservationHandle);
  101. FtpPortReservationHandle = NULL;
  102. }
  103. if (FtpTranslatorHandle) {
  104. NatShutdownTranslator(FtpTranslatorHandle); FtpTranslatorHandle = NULL;
  105. }
  106. InterlockedExchange(reinterpret_cast<LPLONG>(&FtpProtocolStopped), 1);
  107. SetEvent(FtpNotificationEvent);
  108. ResetComponentReference(&FtpComponentReference);
  109. } // FtpCleanupProtocol
  110. BOOLEAN
  111. FtpInitializeModule(
  112. VOID
  113. )
  114. /*++
  115. Routine Description:
  116. This routine is invoked to initialize the FnP module.
  117. Arguments:
  118. none.
  119. Return Value:
  120. BOOLEAN - TRUE if initialization succeeded, FALSE otherwise
  121. Environment:
  122. Invoked in the context of a 'DllMain' routine on 'DLL_PROCESS_ATTACH'.
  123. --*/
  124. {
  125. if (InitializeComponentReference(
  126. &FtpComponentReference, FtpCleanupProtocol
  127. )) {
  128. return FALSE;
  129. }
  130. __try {
  131. InitializeCriticalSection(&FtpGlobalInfoLock);
  132. } __except(EXCEPTION_EXECUTE_HANDLER) {
  133. DeleteComponentReference(&FtpComponentReference);
  134. return FALSE;
  135. }
  136. if (FtpInitializeInterfaceManagement()) {
  137. DeleteCriticalSection(&FtpGlobalInfoLock);
  138. DeleteComponentReference(&FtpComponentReference);
  139. return FALSE;
  140. }
  141. return TRUE;
  142. } // FtpInitializeModule
  143. ULONG
  144. APIENTRY
  145. FtpRmStartProtocol(
  146. HANDLE NotificationEvent,
  147. PSUPPORT_FUNCTIONS SupportFunctions,
  148. PVOID GlobalInfo,
  149. ULONG StructureVersion,
  150. ULONG StructureSize,
  151. ULONG StructureCount
  152. )
  153. /*++
  154. Routine Description:
  155. This routine is invoked to indicate the component's operation should begin.
  156. Arguments:
  157. NotificationEvent - event on which we notify the router-manager
  158. about asynchronous occurrences
  159. SupportFunctions - functions for initiating router-related operations
  160. GlobalInfo - configuration for the component
  161. Return Value:
  162. ULONG - Win32 status code.
  163. Environment:
  164. The routine runs in the context of an IP router-manager thread.
  165. --*/
  166. {
  167. ULONG Error = NO_ERROR;
  168. ULONG Size;
  169. PROFILE("FtpRmStartProtocol");
  170. REFERENCE_FTP_OR_RETURN(ERROR_CAN_NOT_COMPLETE);
  171. if (!GlobalInfo) { DEREFERENCE_FTP_AND_RETURN(ERROR_INVALID_PARAMETER); }
  172. do {
  173. //
  174. // Copy the global configuration
  175. //
  176. EnterCriticalSection(&FtpGlobalInfoLock);
  177. Size = sizeof(*FtpGlobalInfo);
  178. FtpGlobalInfo =
  179. reinterpret_cast<PIP_FTP_GLOBAL_INFO>(NH_ALLOCATE(Size));
  180. if (!FtpGlobalInfo) {
  181. LeaveCriticalSection(&FtpGlobalInfoLock);
  182. NhTrace(
  183. TRACE_FLAG_INIT,
  184. "FtpRmStartProtocol: cannot allocate global info"
  185. );
  186. NhErrorLog(
  187. IP_FTP_LOG_ALLOCATION_FAILED,
  188. 0,
  189. "%d",
  190. Size
  191. );
  192. Error = ERROR_NOT_ENOUGH_MEMORY;
  193. break;
  194. }
  195. CopyMemory(FtpGlobalInfo, GlobalInfo, Size);
  196. //
  197. // Save the notification event
  198. //
  199. FtpNotificationEvent = NotificationEvent;
  200. //
  201. // Save the support functions
  202. //
  203. if (!SupportFunctions) {
  204. ZeroMemory(&FtpSupportFunctions, sizeof(FtpSupportFunctions));
  205. } else {
  206. CopyMemory(
  207. &FtpSupportFunctions,
  208. SupportFunctions,
  209. sizeof(*SupportFunctions)
  210. );
  211. }
  212. //
  213. // Obtain a handle to the kernel-mode translation module.
  214. //
  215. Error = NatInitializeTranslator(&FtpTranslatorHandle);
  216. if (Error) {
  217. NhTrace(
  218. TRACE_FLAG_INIT,
  219. "FtpRmStartProtocol: error %d initializing translator",
  220. Error
  221. );
  222. break;
  223. }
  224. //
  225. // Obtain a port-reservation handle
  226. //
  227. Error =
  228. NatInitializePortReservation(
  229. FTP_PORT_RESERVATION_BLOCK_SIZE, &FtpPortReservationHandle
  230. );
  231. if (Error) {
  232. NhTrace(
  233. TRACE_FLAG_INIT,
  234. "FtpRmStartProtocol: error %d initializing port-reservation",
  235. Error
  236. );
  237. break;
  238. }
  239. FtpTimerQueueHandle = CreateTimerQueue();
  240. if (FtpTimerQueueHandle == NULL) {
  241. Error = GetLastError();
  242. NhTrace(
  243. TRACE_FLAG_INIT,
  244. "FtpRmStartProtocol: error %d initializing timer queue",
  245. Error
  246. );
  247. break;
  248. }
  249. LeaveCriticalSection(&FtpGlobalInfoLock);
  250. InterlockedExchange(reinterpret_cast<LPLONG>(&FtpProtocolStopped), 0);
  251. } while (FALSE);
  252. DEREFERENCE_FTP_AND_RETURN(Error);
  253. } // FtpRmStartProtocol
  254. ULONG
  255. APIENTRY
  256. FtpRmStartComplete(
  257. VOID
  258. )
  259. /*++
  260. Routine Description:
  261. This routine is invoked when the router has finished adding the initial
  262. configuration.
  263. Arguments:
  264. none.
  265. Return Value:
  266. ULONG - Win32 status code
  267. Environment:
  268. The routine runs in the context of an IP router-manager thread.
  269. --*/
  270. {
  271. return NO_ERROR;
  272. } // FtpRmStartComplete
  273. ULONG
  274. APIENTRY
  275. FtpRmStopProtocol(
  276. VOID
  277. )
  278. /*++
  279. Routine Description:
  280. This routine is invoked to stop the protocol.
  281. Arguments:
  282. none.
  283. Return Value:
  284. ULONG - Win32 status code
  285. Environment:
  286. The routine runs in the context of an IP router-manager thread.
  287. --*/
  288. {
  289. //
  290. // Reference the module to make sure it's running
  291. //
  292. REFERENCE_FTP_OR_RETURN(ERROR_CAN_NOT_COMPLETE);
  293. //
  294. // Drop the initial reference to cause a cleanup
  295. //
  296. ReleaseInitialComponentReference(&FtpComponentReference);
  297. return DEREFERENCE_FTP() ? NO_ERROR : ERROR_PROTOCOL_STOP_PENDING;
  298. } // FtpRmStopProtocol
  299. ULONG
  300. APIENTRY
  301. FtpRmAddInterface(
  302. PWCHAR Name,
  303. ULONG Index,
  304. NET_INTERFACE_TYPE Type,
  305. ULONG MediaType,
  306. USHORT AccessType,
  307. USHORT ConnectionType,
  308. PVOID InterfaceInfo,
  309. ULONG StructureVersion,
  310. ULONG StructureSize,
  311. ULONG StructureCount
  312. )
  313. /*++
  314. Routine Description:
  315. This routine is invoked to add an interface to the component.
  316. Arguments:
  317. Name - the name of the interface (unused)
  318. Index - the index of the interface
  319. Type - the type of the interface
  320. InterfaceInfo - the configuration information for the interface
  321. Return Value:
  322. ULONG - Win32 status code.
  323. Environment:
  324. The routine runs in the context of an IP router-manager thread.
  325. --*/
  326. {
  327. ULONG Error;
  328. PROFILE("FtpRmAddInterface");
  329. REFERENCE_FTP_OR_RETURN(ERROR_CAN_NOT_COMPLETE);
  330. Error =
  331. FtpCreateInterface(
  332. Index,
  333. Type,
  334. (PIP_FTP_INTERFACE_INFO)InterfaceInfo,
  335. NULL
  336. );
  337. DEREFERENCE_FTP_AND_RETURN(Error);
  338. } // FtpRmAddInterface
  339. ULONG
  340. APIENTRY
  341. FtpRmDeleteInterface(
  342. ULONG Index
  343. )
  344. /*++
  345. Routine Description:
  346. This routine is invoked to delete an interface from the component.
  347. Arguments:
  348. Index - the index of the interface
  349. Return Value:
  350. ULONG - Win32 status code
  351. Environment:
  352. The routine runs in the context of an IP router-manager thread.
  353. --*/
  354. {
  355. ULONG Error;
  356. PROFILE("FtpRmDeleteInterface");
  357. REFERENCE_FTP_OR_RETURN(ERROR_CAN_NOT_COMPLETE);
  358. Error =
  359. FtpDeleteInterface(
  360. Index
  361. );
  362. DEREFERENCE_FTP_AND_RETURN(Error);
  363. } // FtpRmDeleteInterface
  364. ULONG
  365. APIENTRY
  366. FtpRmGetEventMessage(
  367. OUT ROUTING_PROTOCOL_EVENTS* Event,
  368. OUT MESSAGE* Result
  369. )
  370. /*++
  371. Routine Description:
  372. This routine is invoked to retrieve an event message from the component.
  373. The only event message we generate is the 'ROUTER_STOPPED' message.
  374. Arguments:
  375. Event - receives the generated event
  376. Result - receives the associated result
  377. Return Value:
  378. ULONG - Win32 status code.
  379. --*/
  380. {
  381. PROFILE("FtpRmGetEventMessage");
  382. if (InterlockedExchange(reinterpret_cast<LPLONG>(&FtpProtocolStopped), 0))
  383. {
  384. *Event = ROUTER_STOPPED;
  385. return NO_ERROR;
  386. }
  387. return ERROR_NO_MORE_ITEMS;
  388. } // FtpRmGetEventMessage
  389. ULONG
  390. APIENTRY
  391. FtpRmGetInterfaceInfo(
  392. ULONG Index,
  393. PVOID InterfaceInfo,
  394. IN OUT PULONG InterfaceInfoSize,
  395. IN OUT PULONG StructureVersion,
  396. IN OUT PULONG StructureSize,
  397. IN OUT PULONG StructureCount
  398. )
  399. /*++
  400. Routine Description:
  401. This routine is invoked to retrieve the component's per-interface
  402. configuration.
  403. Arguments:
  404. Index - the index of the interface to be queried
  405. InterfaceInfo - receives the query results
  406. InterfaceInfoSize - receives the amount of data retrieved
  407. Return Value:
  408. ULONG - Win32 status code.
  409. --*/
  410. {
  411. ULONG Error;
  412. PROFILE("FtpRmGetInterfaceInfo");
  413. REFERENCE_FTP_OR_RETURN(ERROR_CAN_NOT_COMPLETE);
  414. Error =
  415. FtpQueryInterface(
  416. Index,
  417. (PIP_FTP_INTERFACE_INFO)InterfaceInfo,
  418. InterfaceInfoSize
  419. );
  420. *StructureSize = *InterfaceInfoSize;
  421. if (StructureCount) {*StructureCount = 1;}
  422. DEREFERENCE_FTP_AND_RETURN(Error);
  423. } // FtpRmGetInterfaceInfo
  424. ULONG
  425. APIENTRY
  426. FtpRmSetInterfaceInfo(
  427. ULONG Index,
  428. PVOID InterfaceInfo,
  429. ULONG StructureVersion,
  430. ULONG StructureSize,
  431. ULONG StructureCount
  432. )
  433. /*++
  434. Routine Description:
  435. This routine is invoked to change the component's per-interface
  436. configuration.
  437. Arguments:
  438. Index - the index of the interface to be updated
  439. InterfaceInfo - supplies the new configuration
  440. Return Value:
  441. ULONG - Win32 status code.
  442. --*/
  443. {
  444. ULONG Error;
  445. PROFILE("FtpRmSetInterfaceInfo");
  446. REFERENCE_FTP_OR_RETURN(ERROR_CAN_NOT_COMPLETE);
  447. Error =
  448. FtpConfigureInterface(
  449. Index,
  450. (PIP_FTP_INTERFACE_INFO)InterfaceInfo
  451. );
  452. DEREFERENCE_FTP_AND_RETURN(Error);
  453. } // FtpRmSetInterfaceInfo
  454. ULONG
  455. APIENTRY
  456. FtpRmInterfaceStatus(
  457. ULONG Index,
  458. BOOL InterfaceActive,
  459. ULONG StatusType,
  460. PVOID StatusInfo
  461. )
  462. /*++
  463. Routine Description:
  464. This routine is invoked to bind/unbind, enable/disable an interface
  465. Arguments:
  466. Index - the interface to be bound
  467. InterfaceActive - whether the interface is active
  468. StatusType - type of status being changed (bind or enabled)
  469. StatusInfo - Info pertaining to the state being changed
  470. Return Value:
  471. ULONG - Win32 Status code
  472. Environment:
  473. The routine runs in the context of an IP router-manager thread.
  474. --*/
  475. {
  476. ULONG Error = NO_ERROR;
  477. switch(StatusType) {
  478. case RIS_INTERFACE_ADDRESS_CHANGE: {
  479. PIP_ADAPTER_BINDING_INFO BindInfo =
  480. (PIP_ADAPTER_BINDING_INFO)StatusInfo;
  481. if (BindInfo->AddressCount) {
  482. Error = FtpRmBindInterface(Index, StatusInfo);
  483. } else {
  484. Error = FtpRmUnbindInterface(Index);
  485. }
  486. break;
  487. }
  488. case RIS_INTERFACE_ENABLED: {
  489. Error = FtpRmEnableInterface(Index);
  490. break;
  491. }
  492. case RIS_INTERFACE_DISABLED: {
  493. Error = FtpRmDisableInterface(Index);
  494. break;
  495. }
  496. }
  497. return Error;
  498. } // FtpRmInterfaceStatus
  499. ULONG
  500. FtpRmBindInterface(
  501. ULONG Index,
  502. PVOID BindingInfo
  503. )
  504. /*++
  505. Routine Description:
  506. This routine is invoked to bind an interface to its IP address(es).
  507. Arguments:
  508. Index - the interface to be bound
  509. BindingInfo - the addressing information
  510. Return Value:
  511. ULONG - Win32 status code.
  512. Environment:
  513. The routine runs in the context of an IP router-manager thread.
  514. --*/
  515. {
  516. ULONG Error;
  517. PROFILE("FtpRmBindInterface");
  518. REFERENCE_FTP_OR_RETURN(ERROR_CAN_NOT_COMPLETE);
  519. Error =
  520. FtpBindInterface(
  521. Index,
  522. (PIP_ADAPTER_BINDING_INFO)BindingInfo
  523. );
  524. DEREFERENCE_FTP_AND_RETURN(Error);
  525. } // FtpRmBindInterface
  526. ULONG
  527. FtpRmUnbindInterface(
  528. ULONG Index
  529. )
  530. /*++
  531. Routine Description:
  532. This routine is invoked to unbind an interface from its IP address(es).
  533. Arguments:
  534. Index - the interface to be unbound
  535. Return Value:
  536. ULONG - Win32 status code.
  537. Environment:
  538. The routine runs in the context of an IP router-manager thread.
  539. --*/
  540. {
  541. ULONG Error;
  542. PROFILE("FtpRmUnbindInterface");
  543. REFERENCE_FTP_OR_RETURN(ERROR_CAN_NOT_COMPLETE);
  544. Error =
  545. FtpUnbindInterface(
  546. Index
  547. );
  548. DEREFERENCE_FTP_AND_RETURN(Error);
  549. } // FtpRmUnbindInterface
  550. ULONG
  551. FtpRmEnableInterface(
  552. ULONG Index
  553. )
  554. /*++
  555. Routine Description:
  556. This routine is invoked to enable operation on an interface.
  557. Arguments:
  558. Index - the interface to be enabled.
  559. Return Value:
  560. ULONG - Win32 status code.
  561. Environment:
  562. The routine runs in the context of an IP router-manager thread.
  563. --*/
  564. {
  565. ULONG Error;
  566. PROFILE("FtpRmEnableInterface");
  567. REFERENCE_FTP_OR_RETURN(ERROR_CAN_NOT_COMPLETE);
  568. Error =
  569. FtpEnableInterface(
  570. Index
  571. );
  572. DEREFERENCE_FTP_AND_RETURN(Error);
  573. } // FtpRmEnableInterface
  574. ULONG
  575. FtpRmDisableInterface(
  576. ULONG Index
  577. )
  578. /*++
  579. Routine Description:
  580. This routine is invoked to disable operation on an interface.
  581. Arguments:
  582. Index - the interface to be disabled.
  583. Return Value:
  584. ULONG - Win32 status code.
  585. Environment:
  586. The routine runs in the context of an IP router-manager thread.
  587. --*/
  588. {
  589. ULONG Error;
  590. PROFILE("FtpRmDisableInterface");
  591. REFERENCE_FTP_OR_RETURN(ERROR_CAN_NOT_COMPLETE);
  592. Error =
  593. FtpDisableInterface(
  594. Index
  595. );
  596. DEREFERENCE_FTP_AND_RETURN(Error);
  597. } // FtpRmDisableInterface
  598. ULONG
  599. APIENTRY
  600. FtpRmGetGlobalInfo(
  601. PVOID GlobalInfo,
  602. IN OUT PULONG GlobalInfoSize,
  603. IN OUT PULONG StructureVersion,
  604. IN OUT PULONG StructureSize,
  605. IN OUT PULONG StructureCount
  606. )
  607. /*++
  608. Routine Description:
  609. This routine is invoked to retrieve the configuration for the component.
  610. Arguments:
  611. GlobalInfo - receives the configuration
  612. GlobalInfoSize - receives the size of the configuration
  613. Return Value:
  614. ULONG - Win32 status code
  615. Environment:
  616. The routine runs in the context of an IP router-manager thread.
  617. --*/
  618. {
  619. ULONG Size;
  620. PROFILE("FtpRmGetGlobalInfo");
  621. REFERENCE_FTP_OR_RETURN(ERROR_CAN_NOT_COMPLETE);
  622. if (!GlobalInfoSize || (*GlobalInfoSize && !GlobalInfo)) {
  623. DEREFERENCE_FTP_AND_RETURN(ERROR_INVALID_PARAMETER);
  624. }
  625. EnterCriticalSection(&FtpGlobalInfoLock);
  626. Size = sizeof(*FtpGlobalInfo);
  627. if (*GlobalInfoSize < Size) {
  628. LeaveCriticalSection(&FtpGlobalInfoLock);
  629. *StructureSize = *GlobalInfoSize = Size;
  630. if (StructureCount) {*StructureCount = 1;}
  631. DEREFERENCE_FTP_AND_RETURN(ERROR_INSUFFICIENT_BUFFER);
  632. }
  633. CopyMemory(GlobalInfo, FtpGlobalInfo, Size);
  634. LeaveCriticalSection(&FtpGlobalInfoLock);
  635. *StructureSize = *GlobalInfoSize = Size;
  636. if (StructureCount) {*StructureCount = 1;}
  637. DEREFERENCE_FTP_AND_RETURN(NO_ERROR);
  638. } // FtpRmGetGlobalInfo
  639. ULONG
  640. APIENTRY
  641. FtpRmSetGlobalInfo(
  642. PVOID GlobalInfo,
  643. ULONG StructureVersion,
  644. ULONG StructureSize,
  645. ULONG StructureCount
  646. )
  647. /*++
  648. Routine Description:
  649. This routine is invoked to change the configuration for the component.
  650. Arguments:
  651. GlobalInfo - the new configuration
  652. Return Value:
  653. ULONG - Win32 status code
  654. Environment:
  655. The routine runs in the context of an IP router-manager thread.
  656. --*/
  657. {
  658. ULONG OldFlags;
  659. ULONG NewFlags;
  660. PIP_FTP_GLOBAL_INFO NewInfo;
  661. ULONG Size;
  662. PROFILE("FtpRmSetGlobalInfo");
  663. REFERENCE_FTP_OR_RETURN(ERROR_CAN_NOT_COMPLETE);
  664. if (!GlobalInfo) { DEREFERENCE_FTP_AND_RETURN(ERROR_INVALID_PARAMETER); }
  665. Size = sizeof(*FtpGlobalInfo);
  666. NewInfo = reinterpret_cast<PIP_FTP_GLOBAL_INFO>(NH_ALLOCATE(Size));
  667. if (!NewInfo) {
  668. NhTrace(
  669. TRACE_FLAG_INIT,
  670. "FtpRmSetGlobalInfo: error reallocating global info"
  671. );
  672. NhErrorLog(
  673. IP_FTP_LOG_ALLOCATION_FAILED,
  674. 0,
  675. "%d",
  676. Size
  677. );
  678. DEREFERENCE_FTP_AND_RETURN(ERROR_NOT_ENOUGH_MEMORY);
  679. }
  680. CopyMemory(NewInfo, GlobalInfo, Size);
  681. EnterCriticalSection(&FtpGlobalInfoLock);
  682. OldFlags = FtpGlobalInfo->Flags;
  683. NH_FREE(FtpGlobalInfo);
  684. FtpGlobalInfo = NewInfo;
  685. NewFlags = FtpGlobalInfo->Flags;
  686. LeaveCriticalSection(&FtpGlobalInfoLock);
  687. DEREFERENCE_FTP_AND_RETURN(NO_ERROR);
  688. } // FtpRmSetGlobalInfo
  689. ULONG
  690. APIENTRY
  691. FtpRmMibCreate(
  692. ULONG InputDataSize,
  693. PVOID InputData
  694. )
  695. {
  696. return ERROR_NOT_SUPPORTED;
  697. }
  698. ULONG
  699. APIENTRY
  700. FtpRmMibDelete(
  701. ULONG InputDataSize,
  702. PVOID InputData
  703. )
  704. {
  705. return ERROR_NOT_SUPPORTED;
  706. }
  707. ULONG
  708. APIENTRY
  709. FtpRmMibGet(
  710. ULONG InputDataSize,
  711. PVOID InputData,
  712. OUT PULONG OutputDataSize,
  713. OUT PVOID OutputData
  714. )
  715. /*++
  716. Routine Description:
  717. The transparent proxy only exposes one item to the MIB; its statistics.
  718. Arguments:
  719. InputDataSize - the MIB query data size
  720. InputData - specifies the MIB object to be retrieved
  721. OutputDataSize - the MIB response data size
  722. OutputData - receives the MIB object retrieved
  723. Return Value:
  724. ULONG - Win32 status code.
  725. --*/
  726. {
  727. ULONG Error;
  728. PIP_FTP_MIB_QUERY Oidp;
  729. PROFILE("FtpRmMibGet");
  730. REFERENCE_FTP_OR_RETURN(ERROR_CAN_NOT_COMPLETE);
  731. if (InputDataSize < sizeof(*Oidp) || !OutputDataSize) {
  732. Error = ERROR_INVALID_PARAMETER;
  733. } else {
  734. Oidp = (PIP_FTP_MIB_QUERY)InputData;
  735. switch(Oidp->Oid) {
  736. case IP_FTP_STATISTICS_OID: {
  737. if (*OutputDataSize < sizeof(*Oidp) + sizeof(FtpStatistics)) {
  738. *OutputDataSize = sizeof(*Oidp) + sizeof(FtpStatistics);
  739. Error = ERROR_INSUFFICIENT_BUFFER;
  740. } else {
  741. *OutputDataSize = sizeof(*Oidp) + sizeof(FtpStatistics);
  742. Oidp = (PIP_FTP_MIB_QUERY)OutputData;
  743. Oidp->Oid = IP_FTP_STATISTICS_OID;
  744. CopyMemory(
  745. Oidp->Data,
  746. &FtpStatistics,
  747. sizeof(FtpStatistics)
  748. );
  749. Error = NO_ERROR;
  750. }
  751. break;
  752. }
  753. default: {
  754. NhTrace(
  755. TRACE_FLAG_FTP,
  756. "FtpRmMibGet: oid %d invalid",
  757. Oidp->Oid
  758. );
  759. Error = ERROR_INVALID_PARAMETER;
  760. break;
  761. }
  762. }
  763. }
  764. DEREFERENCE_FTP_AND_RETURN(Error);
  765. }
  766. ULONG
  767. APIENTRY
  768. FtpRmMibSet(
  769. ULONG InputDataSize,
  770. PVOID InputData
  771. )
  772. {
  773. return ERROR_NOT_SUPPORTED;
  774. }
  775. ULONG
  776. APIENTRY
  777. FtpRmMibGetFirst(
  778. ULONG InputDataSize,
  779. PVOID InputData,
  780. OUT PULONG OutputDataSize,
  781. OUT PVOID OutputData
  782. )
  783. {
  784. return ERROR_NOT_SUPPORTED;
  785. }
  786. ULONG
  787. APIENTRY
  788. FtpRmMibGetNext(
  789. ULONG InputDataSize,
  790. PVOID InputData,
  791. OUT PULONG OutputDataSize,
  792. OUT PVOID OutputData
  793. )
  794. {
  795. return ERROR_NOT_SUPPORTED;
  796. }