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.

126 lines
2.8 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1998 **/
  4. /**********************************************************************/
  5. /*
  6. acptctxt.h
  7. This file contains the definitions for the PASV_ACCEPT_CONTEXT and ACCEPT_CONTEXT_ENTRY
  8. classes used to deal with async PASV connections
  9. */
  10. #ifndef _ACPTCTXT_HXX_
  11. #define _ACPTCTXT_HXX_
  12. #define NEEDUPDATE_INDEX 0
  13. #define CANUPDATE_INDEX 1
  14. #define HAVEUPDATED_INDEX 2
  15. #define EXITTHREAD_INDEX 3
  16. #define LASTPREALLOC_INDEX 4
  17. //
  18. //Maximum amount of time we'll wait for a PASV connection, in milliseconds
  19. //
  20. #define MAX_PASV_WAIT_TIME 10000
  21. //
  22. // Time interval at which to check for timeouts, in milliseconds
  23. //
  24. #define PASV_TIMEOUT_INTERVAL 2000
  25. //
  26. // Number of timeouts permitted on a PASV connection
  27. //
  28. #define MAX_PASV_TIMEOUTS (MAX_PASV_WAIT_TIME/PASV_TIMEOUT_INTERVAL)
  29. #define ACCEPT_CONTEXT_GOOD_SIG (DWORD) 'PCCA'
  30. #define ACCEPT_CONTEXT_BAD_SIG (DWORD) 'pcca'
  31. class PASV_ACCEPT_CONTEXT
  32. {
  33. private:
  34. DWORD m_dwSignature;
  35. public:
  36. PASV_ACCEPT_CONTEXT();
  37. ~PASV_ACCEPT_CONTEXT();
  38. DWORD AddAcceptEvent( WSAEVENT hEvent,
  39. USER_DATA *pUserData );
  40. BOOL RemoveAcceptEvent( WSAEVENT hEvent,
  41. USER_DATA *pUserData,
  42. LPBOOL pfFound );
  43. VOID Lock() { EnterCriticalSection( &m_csLock ); }
  44. VOID Unlock() { LeaveCriticalSection( &m_csLock ); }
  45. DWORD ErrorStatus() { return m_dwErr; }
  46. DWORD QueryNumEvents() { return m_dwNumEvents; }
  47. BOOL IsValid() { return (m_dwSignature == ACCEPT_CONTEXT_GOOD_SIG); }
  48. static DWORD WINAPI AcceptThreadFunc( LPVOID pvContext );
  49. private:
  50. WSAEVENT m_ahEvents[WSA_MAXIMUM_WAIT_EVENTS];
  51. LPUSER_DATA m_apUserData[WSA_MAXIMUM_WAIT_EVENTS];
  52. DWORD m_adwNumTimeouts[WSA_MAXIMUM_WAIT_EVENTS];
  53. DWORD m_dwNumEvents;
  54. CRITICAL_SECTION m_csLock;
  55. HANDLE m_hWatchThread;
  56. DWORD m_dwThreadId;
  57. DWORD m_dwErr;
  58. };
  59. typedef PASV_ACCEPT_CONTEXT* PPASV_ACCEPT_CONTEXT;
  60. class ACCEPT_CONTEXT_ENTRY
  61. {
  62. public:
  63. ACCEPT_CONTEXT_ENTRY();
  64. ~ACCEPT_CONTEXT_ENTRY();
  65. PASV_ACCEPT_CONTEXT *m_pAcceptContext;
  66. LIST_ENTRY ListEntry;
  67. };
  68. typedef ACCEPT_CONTEXT_ENTRY * PACCEPT_CONTEXT_ENTRY;
  69. //
  70. // Utility functions
  71. //
  72. VOID DeleteAcceptContexts();
  73. DWORD CreateInitialAcceptContext();
  74. DWORD AddAcceptEvent( WSAEVENT hEvent,
  75. USER_DATA *pUserData );
  76. BOOL RemoveAcceptEvent( WSAEVENT hEvent,
  77. USER_DATA *pUserData );
  78. VOID CleanupTimedOutSocketContext( USER_DATA *pUserData);
  79. VOID SignalAcceptableSocket( USER_DATA *pUserData );
  80. #endif // _ACPTCTXT_HXX_