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.

181 lines
5.3 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1999-2002 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: IOData.h
  6. * Content: Strucutre definitions for IO data blocks
  7. *
  8. *
  9. * History:
  10. * Date By Reason
  11. * ==== == ======
  12. * 11/25/1998 jtk Created
  13. ***************************************************************************/
  14. #ifndef __IODATA_H__
  15. #define __IODATA_H__
  16. //**********************************************************************
  17. // Constant definitions
  18. //**********************************************************************
  19. //**********************************************************************
  20. // Macro definitions
  21. //**********************************************************************
  22. //**********************************************************************
  23. // Structure definitions
  24. //**********************************************************************
  25. //
  26. // forward structure and class references
  27. //
  28. class CCommandData;
  29. class CEndpoint;
  30. class CSocketPort;
  31. class CSocketAddress;
  32. class CThreadPool;
  33. //
  34. // structures used to get I/O data from the pools
  35. //
  36. typedef struct _READ_IO_DATA_POOL_CONTEXT
  37. {
  38. #if ((! defined(DPNBUILD_NOIPV6)) || (! defined(DPNBUILD_NOIPX)))
  39. short sSPType;
  40. #endif // ! DPNBUILD_NOIPV6 or ! DPNBUILD_NOIPX
  41. #ifndef DPNBUILD_ONLYONEPROCESSOR
  42. DWORD dwCPU;
  43. #endif // ! DPNBUILD_ONLYONEPROCESSOR
  44. CThreadPool *pThreadPool;
  45. }READ_IO_DATA_POOL_CONTEXT;
  46. //
  47. // all data for a read operation
  48. //
  49. class CReadIOData
  50. {
  51. public:
  52. #undef DPF_MODNAME
  53. #define DPF_MODNAME "CReadIOData::AddRef"
  54. void AddRef( void )
  55. {
  56. DNInterlockedIncrement( &m_lRefCount );
  57. }
  58. #undef DPF_MODNAME
  59. #define DPF_MODNAME "CReadIOData::DecRef"
  60. void DecRef( void )
  61. {
  62. DNASSERT( m_lRefCount != 0 );
  63. if ( DNInterlockedDecrement( &m_lRefCount ) == 0 )
  64. {
  65. CThreadPool *pThreadPool;
  66. DNASSERT( m_pThreadPool != NULL );
  67. pThreadPool = m_pThreadPool;
  68. pThreadPool->ReturnReadIOData( this );
  69. }
  70. }
  71. SPRECEIVEDBUFFER *ReceivedBuffer( void ) { DNASSERT( m_pThreadPool != NULL ); return &m_SPReceivedBuffer; }
  72. #undef DPF_MODNAME
  73. #define DPF_MODNAME "CReadIOData::ReadDataFromSPReceivedBuffer"
  74. static CReadIOData *ReadDataFromSPReceivedBuffer( SPRECEIVEDBUFFER *const pSPReceivedBuffer )
  75. {
  76. DNASSERT( pSPReceivedBuffer != NULL );
  77. DBG_CASSERT( sizeof( BYTE* ) == sizeof( pSPReceivedBuffer ) );
  78. DBG_CASSERT( sizeof( CReadIOData* ) == sizeof( BYTE* ) );
  79. return reinterpret_cast<CReadIOData*>( &reinterpret_cast<BYTE*>( pSPReceivedBuffer )[ -OFFSETOF( CReadIOData, m_SPReceivedBuffer ) ] );
  80. }
  81. //
  82. // functions for managing read IO data pool
  83. //
  84. static BOOL ReadIOData_Alloc( void* pvItem, void* pvContext );
  85. static void ReadIOData_Get( void* pvItem, void* pvContext );
  86. static void ReadIOData_Release( void* pvItem );
  87. static void ReadIOData_Dealloc( void* pvItem );
  88. CSocketPort *SocketPort( void ) const { return m_pSocketPort; }
  89. #undef DPF_MODNAME
  90. #define DPF_MODNAME "CReadIOData::SetSocketPort"
  91. void SetSocketPort( CSocketPort *const pSocketPort )
  92. {
  93. DNASSERT( ( m_pSocketPort == NULL ) || ( pSocketPort == NULL ) );
  94. m_pSocketPort = pSocketPort;
  95. }
  96. #ifndef DPNBUILD_NOWINSOCK2
  97. #undef DPF_MODNAME
  98. #define DPF_MODNAME "CReadIOData::SetOverlapped"
  99. void SetOverlapped( OVERLAPPED *const pOverlapped )
  100. {
  101. DNASSERT( ( m_pOverlapped == NULL ) || ( pOverlapped == NULL ) );
  102. m_pOverlapped = pOverlapped;
  103. }
  104. OVERLAPPED *GetOverlapped( void ) { return m_pOverlapped; }
  105. #endif // ! DPNBUILD_NOWINSOCK2
  106. #ifndef DPNBUILD_ONLYONEPROCESSOR
  107. DWORD GetCPU( void ) const { return m_dwCPU; }
  108. #endif // ! DPNBUILD_ONLYONEPROCESSOR
  109. BYTE m_Sig[4]; // debugging signature ('RIOD')
  110. #ifndef DPNBUILD_NOWINSOCK2
  111. OVERLAPPED *m_pOverlapped; // pointer to overlapped I/O structure
  112. DWORD m_dwOverlappedBytesReceived;
  113. #endif // ! DPNBUILD_NOWINSOCK2
  114. CSocketPort *m_pSocketPort; // pointer to socket port associated with this IO request
  115. INT m_iSocketAddressSize; // size of received socket address (from Winsock)
  116. CSocketAddress *m_pSourceSocketAddress; // pointer to socket address class that's bound to the
  117. // local 'SocketAddress' element and is used to get the
  118. // address of the machine that originated the datagram
  119. INT m_ReceiveWSAReturn;
  120. DWORD m_dwBytesRead;
  121. DEBUG_ONLY( BOOL m_fRetainedByHigherLayer );
  122. #ifndef DPNBUILD_ONLYONEPROCESSOR
  123. DWORD m_dwCPU; // owning CPU
  124. #endif // ! DPNBUILD_ONLYONEPROCESSOR
  125. private:
  126. LONG m_lRefCount;
  127. CThreadPool *m_pThreadPool;
  128. SPRECEIVEDBUFFER m_SPReceivedBuffer;
  129. BYTE m_ReceivedData[ MAX_RECEIVE_FRAME_SIZE ];
  130. // prevent unwarranted copies
  131. CReadIOData( const CReadIOData & );
  132. CReadIOData& operator=( const CReadIOData & );
  133. };
  134. //**********************************************************************
  135. // Variable definitions
  136. //**********************************************************************
  137. //**********************************************************************
  138. // Function prototypes
  139. //**********************************************************************
  140. #undef DPF_MODNAME
  141. #endif // __IODATA_H__