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.

1022 lines
23 KiB

  1. /*++
  2. Copyright (c) 1998 - 2000 Microsoft Corporation
  3. Module Name:
  4. ldappx.h
  5. Abstract:
  6. Declares abstract data types and constants used in LDAP portion of the H.323/LDAP proxy.
  7. LDAP Proxy is designed as an addition to H.323 proxy. The main purpose of the
  8. LDAP proxy is to maintain LDAP Address Translation Table, which is used to map
  9. aliases of H.323 endpoints to their IP addresses. The proxy adds an entry when it
  10. intercepts an LDAP PDU from a client to directory server, and the PDU matches all
  11. predefined criteria.
  12. Author(s): ArlieD, IlyaK 14-Jul-1999
  13. Revision History:
  14. 07/14/1999 File creation Arlie Davis (ArlieD)
  15. 08/20/1999 Improvement of processing of LDAP Ilya Kleyman (IlyaK)
  16. LDAP SearchRequests
  17. 12/20/1999 Added prediction of receive sizes in Ilya Kleyman (IlyaK)
  18. non-interpretative data transfer mode
  19. 02/20/2000 Added expiration policy of the entries Ilya Kleyman (IlyaK)
  20. in LDAP Address Translation Table
  21. 03/12/2000 Added support for multiple private and Ilya Kleyman (IlyaK)
  22. multiple public interface for RRAS
  23. --*/
  24. #ifndef __h323ics_ldappx_h
  25. #define __h323ics_ldappx_h
  26. #define LDAP_PATH_EQUAL_CHAR '='
  27. #define LDAP_PATH_SEP_CHAR ','
  28. extern BOOLEAN NhIsLocalAddress (ULONG Address);
  29. extern ULONG NhMapAddressToAdapter (ULONG Address);
  30. typedef MessageID LDAP_MESSAGE_ID;
  31. #define ASN_SEQUENCE_TAG 0x30
  32. #define ASN_LONG_HEADER_BIT 0x80
  33. #define ASN_MIN_HEADER_LEN 2 // This value is fixed
  34. #define LDAP_STANDARD_PORT 389 // Well-known LDAP port
  35. #define LDAP_ALTERNATE_PORT 1002 // Alternate (ILS) LDAP port
  36. #define LDAP_BUFFER_RECEIVE_SIZE 0x400
  37. #define LDAP_BUFFER_MAX_RECV_SIZE 0x80000UL // Limit on maximum one-time receive size
  38. #define LDAP_MAX_TRANSLATION_TABLE_SIZE 100000 // Maximum number of entries in translation table
  39. #define LDAP_MAX_CONNECTIONS 50000 // Maximum number of concurrent connections through the proxy
  40. // data structures -------------------------------------------------------------------
  41. class LDAP_SOCKET;
  42. class LDAP_CONNECTION;
  43. struct LDAP_TRANSLATION_ENTRY
  44. {
  45. // An entry in the LDAP Address Translation Table is
  46. // to be identified by three components:
  47. // 1. Registered alias
  48. // 2. Registered address
  49. // 3. Directory server the alias is registered with
  50. // 4. Directory path on the server
  51. //
  52. // Currently only first three are used.
  53. //
  54. ANSI_STRING Alias; // Memory owned, use FreeAnsiString
  55. ANSI_STRING DirectoryPath; // Memory owned, use FreeAnsiString
  56. ANSI_STRING CN; // Subset of DirectoryPath, NOT owned, do NOT free
  57. IN_ADDR ClientAddress;
  58. SOCKADDR_IN ServerAddress;
  59. DWORD TimeStamp; // In seconds, since the last machine reboot
  60. void
  61. FreeContents (
  62. void
  63. )
  64. {
  65. FreeAnsiString (&Alias);
  66. FreeAnsiString (&DirectoryPath);
  67. CN.Buffer = NULL;
  68. }
  69. HRESULT
  70. IsRegisteredViaInterface (
  71. IN DWORD InterfaceAddress, // host order
  72. OUT BOOL *Result
  73. );
  74. };
  75. class LDAP_TRANSLATION_TABLE :
  76. public SIMPLE_CRITICAL_SECTION_BASE
  77. {
  78. // LDAP Address Translation Table is a serialized
  79. // container for translation entries. The Table
  80. // can conduct various types of searches, and has
  81. // an expiration policy on old entries. The expiration
  82. // is done by means of a periodic timer thread and
  83. // timestamps on each entry. Entries are added when
  84. // successful AddResponses are received in reply to
  85. // valid AddRequests. Entries are refreshed when
  86. // successful refresh SearchResponses are received for
  87. // valid refresh SearchRequests (for NetMeeting); or when
  88. // successful refresh ModifyResponses are received for
  89. // valid refresh ModifyRequests (for Phone Dialer).
  90. private:
  91. DYNAMIC_ARRAY <LDAP_TRANSLATION_ENTRY> Array;
  92. HANDLE GarbageCollectorTimerHandle;
  93. BOOL IsEnabled;
  94. private:
  95. HRESULT
  96. InsertEntryLocked (
  97. IN ANSI_STRING * Alias,
  98. IN ANSI_STRING * DirectoryPath,
  99. IN IN_ADDR ClientAddress,
  100. IN SOCKADDR_IN * ServerAddress,
  101. IN DWORD TimeToLive // in seconds
  102. );
  103. HRESULT
  104. FindEntryByPathServer (
  105. IN ANSI_STRING * DirectoryPath,
  106. IN SOCKADDR_IN * ServerAddress,
  107. OUT LDAP_TRANSLATION_ENTRY ** ReturnTranslationEntry
  108. );
  109. HRESULT FindEntryByAliasServer (
  110. IN ANSI_STRING * Alias,
  111. IN SOCKADDR_IN * ServerAddress,
  112. OUT LDAP_TRANSLATION_ENTRY ** ReturnTranslationEntry
  113. );
  114. public:
  115. LDAP_TRANSLATION_TABLE (
  116. void
  117. );
  118. ~LDAP_TRANSLATION_TABLE (
  119. void
  120. );
  121. HRESULT
  122. Start (
  123. void
  124. );
  125. void
  126. Stop (
  127. void
  128. );
  129. #if DBG
  130. void
  131. PrintTable (
  132. void
  133. );
  134. #endif
  135. #define LDAP_TRANSLATION_TABLE_GARBAGE_COLLECTION_PERIOD (10 * 60 * 1000) // Milliseconds
  136. #define LDAP_TRANSLATION_TABLE_ENTRY_INITIAL_TIME_TO_LIVE (10 * 60) // Seconds
  137. static
  138. void
  139. GarbageCollectorCallback (
  140. IN PVOID Context,
  141. IN BOOLEAN TimerOrWaitFired
  142. );
  143. HRESULT
  144. RefreshEntry (
  145. IN ANSI_STRING * Alias,
  146. IN ANSI_STRING * DirectoryPath,
  147. IN IN_ADDR ClientAddress,
  148. IN SOCKADDR_IN * ServerAddress,
  149. IN DWORD TimeToLive
  150. );
  151. void
  152. RemoveOldEntries (
  153. void
  154. );
  155. HRESULT
  156. QueryTableByAlias (
  157. IN ANSI_STRING * Alias,
  158. OUT IN_ADDR * ReturnClientAddress
  159. );
  160. HRESULT
  161. QueryTableByCN (
  162. IN ANSI_STRING * CN,
  163. OUT IN_ADDR * ReturnClientAddress
  164. );
  165. HRESULT
  166. QueryTableByAliasServer (
  167. IN ANSI_STRING * Alias,
  168. IN SOCKADDR_IN * ServerAddress,
  169. OUT IN_ADDR * ReturnClientAddress
  170. );
  171. HRESULT
  172. QueryTableByCNServer (
  173. IN ANSI_STRING * CN,
  174. IN SOCKADDR_IN * ServerAddress,
  175. OUT IN_ADDR * ReturnClientAddress
  176. );
  177. HRESULT
  178. InsertEntry (
  179. IN ANSI_STRING * Alias,
  180. IN ANSI_STRING * DirectoryPath,
  181. IN IN_ADDR ClientAddress,
  182. IN SOCKADDR_IN * ServerAddress,
  183. IN DWORD TimeToLive // in seconds
  184. );
  185. HRESULT
  186. RemoveEntry (
  187. IN SOCKADDR_IN * ServerAddress,
  188. IN ANSI_STRING * DirectoryPath
  189. );
  190. HRESULT
  191. RemoveEntryByAliasServer (
  192. IN ANSI_STRING * Alias,
  193. IN SOCKADDR_IN * ServerAddress
  194. );
  195. void
  196. OnInterfaceShutdown (
  197. IN DWORD InterfaceAddress
  198. );
  199. BOOL
  200. ReachedMaximumSize (
  201. void
  202. );
  203. };
  204. class LDAP_BUFFER
  205. {
  206. // LDAP_BUFFER is a simple structure
  207. // that can hold raw data and be chained
  208. // to other LDAP_BUFFERs
  209. public:
  210. LDAP_BUFFER (
  211. void
  212. );
  213. ~LDAP_BUFFER (
  214. void
  215. );
  216. public:
  217. DYNAMIC_ARRAY <BYTE> Data;
  218. LIST_ENTRY ListEntry;
  219. };
  220. enum NOTIFY_REASON
  221. {
  222. SOCKET_SEND_COMPLETE,
  223. SOCKET_RECEIVE_COMPLETE,
  224. };
  225. struct LDAP_OVERLAPPED
  226. {
  227. OVERLAPPED Overlapped;
  228. BOOL IsPending;
  229. DWORD BytesTransferred;
  230. LDAP_SOCKET * Socket;
  231. };
  232. class LDAP_PUMP
  233. {
  234. friend class LDAP_CONNECTION;
  235. friend class LDAP_SOCKET;
  236. private:
  237. LDAP_CONNECTION * Connection;
  238. LDAP_SOCKET * Source;
  239. LDAP_SOCKET * Dest;
  240. // When set, the pump works in raw data
  241. // transfer mode without modifications to
  242. // the payload
  243. BOOL IsPassiveDataTransfer;
  244. public:
  245. LDAP_PUMP (
  246. IN LDAP_CONNECTION * ArgConnection,
  247. IN LDAP_SOCKET * ArgSource,
  248. IN LDAP_SOCKET * ArgDest
  249. );
  250. ~LDAP_PUMP (
  251. void
  252. );
  253. void Start (
  254. void
  255. );
  256. void Stop (
  257. void
  258. );
  259. // source is indicating that it has received data
  260. void
  261. OnRecvBuffer (
  262. LDAP_BUFFER *
  263. );
  264. // destination is indicating that it has finished sending data
  265. void
  266. OnSendDrain (
  267. void
  268. );
  269. void
  270. SendQueueBuffer (
  271. IN LDAP_BUFFER * Buffer
  272. );
  273. BOOL
  274. CanIssueRecv (
  275. void
  276. );
  277. void
  278. Terminate (
  279. void
  280. );
  281. void
  282. EncodeSendMessage (
  283. IN LDAPMessage * Message
  284. );
  285. void
  286. StartPassiveDataTransfer (
  287. void
  288. );
  289. BOOL IsActivelyPassingData (
  290. void
  291. ) const;
  292. };
  293. class LDAP_SOCKET
  294. {
  295. // LDAP_SOCKET is a wrapper class
  296. // around Windows asynchrounous socket.
  297. // An instance of LDAP_SOCKET can
  298. // asynchronously connect, send and receive
  299. friend class LDAP_CONNECTION;
  300. friend class LDAP_PUMP;
  301. public:
  302. enum STATE {
  303. STATE_NONE,
  304. STATE_ISSUING_CONNECT,
  305. STATE_CONNECT_PENDING,
  306. STATE_CONNECTED,
  307. STATE_TERMINATED,
  308. };
  309. private:
  310. SOCKADDR_IN ActualDestinationAddress;
  311. SOCKADDR_IN RealSourceAddress;
  312. BOOL IsNatRedirectActive;
  313. LDAP_CONNECTION * LdapConnection;
  314. LDAP_PUMP * RecvPump;
  315. LDAP_PUMP * SendPump;
  316. SOCKET Socket;
  317. STATE State;
  318. // receive state
  319. LDAP_OVERLAPPED RecvOverlapped;
  320. LDAP_BUFFER * RecvBuffer; // must be valid if RecvOverlapped.IsPending, must be null otherwise
  321. DWORD RecvFlags;
  322. LIST_ENTRY RecvBufferQueue; // contains LDAP_BUFFER.ListEntry
  323. DWORD BytesToReceive;
  324. SAMPLE_PREDICTOR <5> RecvSizePredictor;
  325. // send stat
  326. LDAP_OVERLAPPED SendOverlapped;
  327. LDAP_BUFFER * SendBuffer; // must be valid if SendOverlapped.IsPending, must be null otherwise
  328. LIST_ENTRY SendBufferQueue; // contains LDAP_BUFFER.ListEntry
  329. // async connect state
  330. HANDLE ConnectEvent;
  331. HANDLE ConnectWaitHandle;
  332. BOOL AttemptAnotherConnect;
  333. private:
  334. inline
  335. void
  336. Lock (
  337. void
  338. );
  339. inline
  340. void
  341. Unlock (
  342. void
  343. );
  344. inline
  345. void
  346. AssertLocked (
  347. void
  348. );
  349. void
  350. OnConnectCompletionLocked (
  351. void
  352. );
  353. void
  354. FreeConnectResources (
  355. void
  356. );
  357. HRESULT
  358. AttemptAlternateConnect (
  359. void
  360. );
  361. void
  362. OnIoComplete (
  363. IN DWORD Status,
  364. IN DWORD BytesTransferred,
  365. IN LDAP_OVERLAPPED *
  366. );
  367. void
  368. OnRecvComplete (
  369. IN DWORD Status
  370. );
  371. void
  372. OnSendComplete (
  373. IN DWORD Status
  374. );
  375. void
  376. RecvBuildBuffer (
  377. IN LPBYTE Data,
  378. IN DWORD Length
  379. );
  380. void DeleteBufferList (
  381. IN LIST_ENTRY * ListHead
  382. );
  383. BOOL RecvRemoveBuffer (
  384. OUT LDAP_BUFFER ** ReturnBuffer
  385. );
  386. // returns TRUE if a message was dequeued
  387. BOOL SendNextBuffer (
  388. void
  389. );
  390. public:
  391. LDAP_SOCKET (
  392. IN LDAP_CONNECTION * ArgLdapConnection,
  393. IN LDAP_PUMP * ArgRecvPump,
  394. IN LDAP_PUMP * ArgSendPump
  395. );
  396. ~LDAP_SOCKET (
  397. void
  398. );
  399. HRESULT
  400. RecvIssue (
  401. void
  402. );
  403. // may queue the buffer
  404. void
  405. SendQueueBuffer(
  406. IN LDAP_BUFFER * Buffer
  407. );
  408. static
  409. void
  410. IoCompletionCallback (
  411. IN DWORD Status,
  412. IN DWORD Length,
  413. IN LPOVERLAPPED Overlapped
  414. );
  415. static
  416. void
  417. OnConnectCompletion (
  418. IN PVOID Context,
  419. IN BOOLEAN TimerOrWaitFired
  420. );
  421. HRESULT
  422. AcceptSocket (
  423. IN SOCKET LocalClientSocket
  424. );
  425. HRESULT
  426. IssueConnect (
  427. IN SOCKADDR_IN * DestinationAddress
  428. );
  429. void
  430. OnIoCompletion (
  431. IN LDAP_BUFFER * Message,
  432. IN DWORD Status,
  433. IN DWORD BytesTransferred
  434. );
  435. void
  436. Terminate (
  437. void
  438. );
  439. STATE
  440. GetState (void) {
  441. AssertLocked ();
  442. return State;
  443. }
  444. // retrieve the remote address of the connection
  445. BOOL
  446. GetRemoteAddress (
  447. OUT SOCKADDR_IN * ReturnAddress
  448. );
  449. // retrieve the local address of the connection
  450. BOOL
  451. GetLocalAddress (
  452. OUT SOCKADDR_IN * ReturnAddress
  453. );
  454. };
  455. // this represents a single outstanding operation that the client has initiated.
  456. enum LDAP_OPERATION_TYPE
  457. {
  458. LDAP_OPERATION_ADD,
  459. LDAP_OPERATION_SEARCH,
  460. LDAP_OPERATION_MODIFY,
  461. LDAP_OPERATION_DELETE,
  462. };
  463. struct LDAP_OPERATION
  464. {
  465. // LDAP_OPERATIONs are created and queued when
  466. // a client issues a request to the server.
  467. // The actual processing of the operation
  468. // starts when server sends back response
  469. // with data and/or status code.
  470. LDAP_MESSAGE_ID MessageID;
  471. DWORD Type;
  472. ANSI_STRING DirectoryPath; // owned by process heap
  473. ANSI_STRING Alias; // owned by process heap
  474. IN_ADDR ClientAddress;
  475. SOCKADDR_IN ServerAddress;
  476. DWORD EntryTimeToLive; // in seconds
  477. void
  478. FreeContents (
  479. void
  480. )
  481. {
  482. FreeAnsiString (&DirectoryPath);
  483. FreeAnsiString (&Alias);
  484. }
  485. };
  486. class LDAP_CONNECTION :
  487. public SIMPLE_CRITICAL_SECTION_BASE,
  488. public LIFETIME_CONTROLLER
  489. {
  490. // LDAP_CONNECTION represents two parts
  491. // (public and private) of the connection
  492. // being proxied by the LDAP proxy. In reflection
  493. // of this it has easily distinguishable Server
  494. // part and Client part
  495. friend class LDAP_SOCKET;
  496. public:
  497. enum STATE {
  498. STATE_NONE,
  499. STATE_CONNECT_PENDING,
  500. STATE_CONNECTED,
  501. STATE_TERMINATED,
  502. };
  503. LIST_ENTRY ListEntry;
  504. private:
  505. LDAP_SOCKET ClientSocket;
  506. LDAP_SOCKET ServerSocket;
  507. DWORD SourceInterfaceAddress; // address of the interface on which the conection was accepted, host order
  508. DWORD DestinationInterfaceAddress; // address of the interface on which the conection was accepted, host order
  509. SOCKADDR_IN SourceAddress; // address of the source (originator of the connection)
  510. SOCKADDR_IN DestinationAddress; // address of the destination (recipeint of the connection)
  511. LDAP_PUMP PumpClientToServer;
  512. LDAP_PUMP PumpServerToClient;
  513. STATE State;
  514. DYNAMIC_ARRAY <LDAP_OPERATION> OperationArray;
  515. private:
  516. void
  517. StartIo (
  518. void
  519. );
  520. BOOL
  521. ProcessLdapMessage (
  522. IN LDAP_PUMP * Pump,
  523. IN LDAPMessage * LdapMessage
  524. );
  525. // client to server messages
  526. BOOL
  527. ProcessAddRequest (
  528. IN LDAPMessage * Message
  529. );
  530. BOOL
  531. ProcessModifyRequest (
  532. IN LDAP_MESSAGE_ID MessageID,
  533. IN ModifyRequest * Request
  534. );
  535. BOOL
  536. ProcessDeleteRequest (
  537. IN LDAP_MESSAGE_ID MessageID,
  538. IN DelRequest * Request
  539. );
  540. BOOL
  541. ProcessSearchRequest (
  542. IN LDAPMessage * Message
  543. );
  544. // server to client messages
  545. void
  546. ProcessAddResponse (
  547. IN LDAPMessage * Response
  548. );
  549. void
  550. ProcessModifyResponse (
  551. IN LDAP_MESSAGE_ID MessageID,
  552. IN ModifyResponse * Response
  553. );
  554. void
  555. ProcessDeleteResponse (
  556. IN LDAP_MESSAGE_ID MessageID,
  557. IN DelResponse * Response
  558. );
  559. BOOL
  560. ProcessSearchResponse (
  561. IN LDAPMessage * Message
  562. );
  563. BOOL
  564. FindOperationIndexByMessageID (
  565. IN LDAP_MESSAGE_ID MessageID,
  566. OUT DWORD * ReturnIndex
  567. );
  568. BOOL
  569. FindOperationByMessageID (
  570. IN LDAP_MESSAGE_ID MessageID,
  571. OUT LDAP_OPERATION ** ReturnOperation
  572. );
  573. static
  574. INT
  575. BinarySearchOperationByMessageID (
  576. IN const LDAP_MESSAGE_ID * SearchKey,
  577. IN const LDAP_OPERATION * Comparand
  578. );
  579. HRESULT
  580. CreateOperation (
  581. IN LDAP_OPERATION_TYPE Type,
  582. IN LDAP_MESSAGE_ID MessageID,
  583. IN ANSI_STRING * DirectoryPath,
  584. IN ANSI_STRING * Alias,
  585. IN IN_ADDR ClientAddress,
  586. IN SOCKADDR_IN * ServerAddress,
  587. IN DWORD EntryTimeToLive // in seconds
  588. );
  589. public:
  590. LDAP_CONNECTION (
  591. IN NAT_KEY_SESSION_MAPPING_EX_INFORMATION * RedirectInformation
  592. );
  593. ~LDAP_CONNECTION (
  594. void
  595. );
  596. HRESULT
  597. Initialize (
  598. IN NAT_KEY_SESSION_MAPPING_EX_INFORMATION * RedirectInformation
  599. );
  600. HRESULT
  601. InitializeLocked (
  602. IN NAT_KEY_SESSION_MAPPING_EX_INFORMATION * RedirectInformation
  603. );
  604. HRESULT
  605. AcceptSocket (
  606. IN SOCKET Socket,
  607. IN SOCKADDR_IN * LocalAddress,
  608. IN SOCKADDR_IN * RemoteAddress,
  609. IN SOCKADDR_IN * ArgActualDestinationAddress
  610. );
  611. // process a given LDAP message buffer
  612. // in the context of a given pump (direction)
  613. void
  614. ProcessBuffer (
  615. IN LDAP_PUMP * Pump,
  616. IN LDAP_BUFFER * Buffer
  617. );
  618. void
  619. OnStateChange (
  620. IN LDAP_SOCKET * NotifyingSocket,
  621. IN LDAP_SOCKET::STATE NewState
  622. );
  623. void
  624. Terminate (
  625. void
  626. );
  627. void
  628. TerminateExternal (
  629. void
  630. );
  631. BOOL
  632. IsConnectionThrough (
  633. IN DWORD InterfaceAddress // host order
  634. );
  635. // safe, external version
  636. STATE
  637. GetState (
  638. void
  639. )
  640. {
  641. STATE ReturnState;
  642. Lock ();
  643. ReturnState = State;
  644. Unlock ();
  645. return ReturnState;
  646. }
  647. };
  648. DECLARE_SEARCH_FUNC_CAST (LDAP_MESSAGE_ID, LDAP_OPERATION);
  649. inline
  650. void
  651. LDAP_SOCKET::Lock (
  652. void
  653. )
  654. {
  655. LdapConnection -> Lock ();
  656. }
  657. inline
  658. void
  659. LDAP_SOCKET::Unlock (
  660. void
  661. )
  662. {
  663. LdapConnection -> Unlock ();
  664. }
  665. inline
  666. void
  667. LDAP_SOCKET::AssertLocked (
  668. void
  669. )
  670. {
  671. LdapConnection -> AssertLocked();
  672. }
  673. class LDAP_CONNECTION_ARRAY :
  674. public SIMPLE_CRITICAL_SECTION_BASE {
  675. private:
  676. // Contains set/array of LDAP_CONNECTION references
  677. DYNAMIC_ARRAY <LDAP_CONNECTION *> ConnectionArray;
  678. // Controls whether or not the structure will accept
  679. // new LDAP connections
  680. BOOL IsEnabled;
  681. public:
  682. LDAP_CONNECTION_ARRAY (void);
  683. HRESULT
  684. InsertConnection (
  685. IN LDAP_CONNECTION * LdapConnection
  686. );
  687. void
  688. RemoveConnection (
  689. IN LDAP_CONNECTION * LdapConnection
  690. );
  691. void
  692. OnInterfaceShutdown (
  693. IN DWORD InterfaceAddress // host order
  694. );
  695. void
  696. Start (
  697. void
  698. );
  699. void
  700. Stop (
  701. void
  702. );
  703. };
  704. class LDAP_ACCEPT
  705. {
  706. private:
  707. // Contain accept context
  708. ASYNC_ACCEPT AsyncAcceptContext;
  709. // Handles for dynamic redirects from the standard and
  710. // alternate LDAP ports to the selected loopback port
  711. HANDLE LoopbackRedirectHandle1;
  712. HANDLE LoopbackRedirectHandle2;
  713. private:
  714. HRESULT
  715. CreateBindSocket (
  716. void
  717. );
  718. HRESULT
  719. StartLoopbackNatRedirects (
  720. void
  721. );
  722. void
  723. StopLoopbackNatRedirects (
  724. void
  725. );
  726. void
  727. CloseSocket (
  728. void
  729. );
  730. static
  731. void
  732. AsyncAcceptFunction (
  733. IN PVOID Context,
  734. IN SOCKET Socket,
  735. IN SOCKADDR_IN * LocalAddress,
  736. IN SOCKADDR_IN * RemoteAddress
  737. );
  738. static
  739. HRESULT
  740. LDAP_ACCEPT::AsyncAcceptFunctionInternal (
  741. IN PVOID Context,
  742. IN SOCKET Socket,
  743. IN SOCKADDR_IN * LocalAddress,
  744. IN SOCKADDR_IN * RemoteAddress
  745. );
  746. public:
  747. LDAP_ACCEPT (
  748. void
  749. );
  750. HRESULT
  751. Start (
  752. void
  753. );
  754. void
  755. Stop(
  756. void
  757. );
  758. };
  759. class LDAP_CODER :
  760. public SIMPLE_CRITICAL_SECTION_BASE
  761. {
  762. private:
  763. ASN1encoding_t Encoder;
  764. ASN1decoding_t Decoder;
  765. public:
  766. LDAP_CODER (
  767. void
  768. );
  769. ~LDAP_CODER (
  770. void
  771. );
  772. DWORD
  773. Start (
  774. void
  775. );
  776. void
  777. Stop (
  778. void
  779. );
  780. ASN1error_e Decode (
  781. IN LPBYTE Data,
  782. IN DWORD Length,
  783. OUT LDAPMessage ** ReturnPduStructure,
  784. OUT DWORD * ReturnIndex
  785. );
  786. };
  787. struct LDAP_PATH_ELEMENTS
  788. {
  789. ANSI_STRING CN;
  790. ANSI_STRING C;
  791. ANSI_STRING O;
  792. ANSI_STRING ObjectClass;
  793. };
  794. struct LDAP_OBJECT_NAME_ELEMENTS
  795. {
  796. ANSI_STRING CN;
  797. ANSI_STRING O;
  798. ANSI_STRING OU;
  799. };
  800. extern SYNC_COUNTER LdapSyncCounter;
  801. extern LDAP_CONNECTION_ARRAY LdapConnectionArray;
  802. extern LDAP_TRANSLATION_TABLE LdapTranslationTable;
  803. extern LDAP_CODER LdapCoder;
  804. extern LDAP_ACCEPT LdapAccept;
  805. extern SOCKADDR_IN LdapListenSocketAddress;
  806. extern DWORD EnableLocalH323Routing;
  807. HRESULT
  808. LdapQueryTableByAlias (
  809. IN ANSI_STRING * Alias,
  810. OUT DWORD * ReturnClientAddress // host order
  811. );
  812. HRESULT
  813. LdapQueryTableByAliasServer (
  814. IN ANSI_STRING * Alias,
  815. IN SOCKADDR_IN * ServerAddress,
  816. OUT DWORD * ReturnClientAddress); // host order
  817. #if DBG
  818. void
  819. LdapPrintTable (
  820. void
  821. );
  822. #endif // DBG
  823. #endif // __h323ics_ldappx_h