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.

141 lines
4.2 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 2000-2002 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: AdapterEntry.h
  6. * Content: Strucutre definitions for IO data blocks
  7. *
  8. *
  9. * History:
  10. * Date By Reason
  11. * ==== == ======
  12. * 08/07/2000 jtk Dereived from IOData.cpp
  13. ***************************************************************************/
  14. #ifndef __ADAPTER_ENTRY_H__
  15. #define __ADAPTER_ENTRY_H__
  16. #ifndef DPNBUILD_ONLYONEADAPTER
  17. //**********************************************************************
  18. // Constant definitions
  19. //**********************************************************************
  20. //**********************************************************************
  21. // Macro definitions
  22. //**********************************************************************
  23. //**********************************************************************
  24. // Structure definitions
  25. //**********************************************************************
  26. //
  27. // forward references
  28. //
  29. class CThreadPool;
  30. //
  31. // class containing all data for an adapter list
  32. //
  33. class CAdapterEntry
  34. {
  35. public:
  36. #undef DPF_MODNAME
  37. #define DPF_MODNAME "CAdapterEntry::AddRef"
  38. void AddRef( void )
  39. {
  40. DNASSERT( m_lRefCount != 0 );
  41. DNInterlockedIncrement( &m_lRefCount );
  42. }
  43. #undef DPF_MODNAME
  44. #define DPF_MODNAME "CAdapterEntry::DecRef"
  45. void DecRef( void )
  46. {
  47. DNASSERT( m_lRefCount != 0 );
  48. if ( DNInterlockedDecrement( &m_lRefCount ) == 0 )
  49. {
  50. g_AdapterEntryPool.Release( this );
  51. }
  52. }
  53. #undef DPF_MODNAME
  54. #define DPF_MODNAME "CAdapterEntry::AddToAdapterList"
  55. void AddToAdapterList( CBilink *const pAdapterList )
  56. {
  57. DNASSERT( pAdapterList != NULL );
  58. //
  59. // This assumes the SPData socketportdata lock is held.
  60. //
  61. m_AdapterListLinkage.InsertBefore( pAdapterList );
  62. }
  63. CBilink *SocketPortList( void ) { return &m_ActiveSocketPorts; }
  64. const SOCKADDR *BaseAddress( void ) const { return (SOCKADDR*) (&m_BaseSocketAddress); }
  65. #undef DPF_MODNAME
  66. #define DPF_MODNAME "CAdapterEntry::SetBaseAddress"
  67. void SetBaseAddress( const SOCKADDR *const pSocketAddress, const int iSocketAddressSize )
  68. {
  69. DNASSERT(iSocketAddressSize <= sizeof(m_BaseSocketAddress));
  70. memcpy( &m_BaseSocketAddress, pSocketAddress, iSocketAddressSize );
  71. }
  72. #undef DPF_MODNAME
  73. #define DPF_MODNAME "CAdapterEntry::AdapterEntryFromAdapterLinkage"
  74. static CAdapterEntry *AdapterEntryFromAdapterLinkage( CBilink *const pLinkage )
  75. {
  76. DNASSERT( pLinkage != NULL );
  77. DBG_CASSERT( sizeof( BYTE* ) == sizeof( pLinkage ) );
  78. DBG_CASSERT( sizeof( CAdapterEntry* ) == sizeof( BYTE* ) );
  79. return reinterpret_cast<CAdapterEntry*>( &reinterpret_cast<BYTE*>( pLinkage )[ -OFFSETOF( CAdapterEntry, m_AdapterListLinkage ) ] );
  80. }
  81. #ifdef DBG
  82. void DebugPrintOutstandingSocketPorts( void );
  83. #endif // DBG
  84. //
  85. // Pool functions
  86. //
  87. static BOOL PoolAllocFunction( void* pvItem, void* pvContext );
  88. static void PoolInitFunction( void* pvItem, void* pvContext );
  89. static void PoolReleaseFunction( void* pvItem );
  90. static void PoolDeallocFunction( void* pvItem );
  91. protected:
  92. private:
  93. CBilink m_AdapterListLinkage; // linkage to other adapters
  94. CBilink m_ActiveSocketPorts; // linkage to active socket ports
  95. #ifdef DPNBUILD_NOIPV6
  96. SOCKADDR m_BaseSocketAddress; // socket address for this port class
  97. #else // ! DPNBUILD_NOIPV6
  98. SOCKADDR_STORAGE m_BaseSocketAddress; // socket address for this port class
  99. #endif // ! DPNBUILD_NOIPV6
  100. LONG m_lRefCount;
  101. // prevent unwarranted copies
  102. CAdapterEntry( const CAdapterEntry & );
  103. CAdapterEntry& operator=( const CAdapterEntry & );
  104. };
  105. //**********************************************************************
  106. // Variable definitions
  107. //**********************************************************************
  108. //**********************************************************************
  109. // Function prototypes
  110. //**********************************************************************
  111. #undef DPF_MODNAME
  112. #endif // ! DPNBUILD_ONLYONEADAPTER
  113. #endif // __ADAPTER_ENTRY_H__