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.

176 lines
5.6 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 2000-2002 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: AdapterEntry.cpp
  6. * Content: Structure used in the list of active sockets
  7. *
  8. *
  9. * History:
  10. * Date By Reason
  11. * ==== == ======
  12. * 08/07/2000 jtk Derived from IODAta.h
  13. ***************************************************************************/
  14. #include "dnwsocki.h"
  15. #ifndef DPNBUILD_ONLYONEADAPTER
  16. //**********************************************************************
  17. // Constant definitions
  18. //**********************************************************************
  19. //**********************************************************************
  20. // Macro definitions
  21. //**********************************************************************
  22. //**********************************************************************
  23. // Structure definitions
  24. //**********************************************************************
  25. //**********************************************************************
  26. // Variable definitions
  27. //**********************************************************************
  28. //**********************************************************************
  29. // Function prototypes
  30. //**********************************************************************
  31. //**********************************************************************
  32. // ------------------------------
  33. // CAdapterEntry::PoolAllocFunction
  34. //
  35. // Entry: Nothing
  36. //
  37. // Exit: Boolean indicating success
  38. // ------------------------------
  39. #undef DPF_MODNAME
  40. #define DPF_MODNAME "CAdapterEntry::PoolAllocFunction"
  41. BOOL CAdapterEntry::PoolAllocFunction( void* pvItem, void* pvContext )
  42. {
  43. CAdapterEntry* pAdapterEntry = (CAdapterEntry*)pvItem;
  44. pAdapterEntry->m_lRefCount = 0;
  45. pAdapterEntry->m_AdapterListLinkage.Initialize();
  46. pAdapterEntry->m_ActiveSocketPorts.Initialize();
  47. memset( &pAdapterEntry->m_BaseSocketAddress, 0x00, sizeof( pAdapterEntry->m_BaseSocketAddress ) );
  48. return TRUE;
  49. }
  50. //**********************************************************************
  51. //**********************************************************************
  52. // ------------------------------
  53. // CAdapterEntry::PoolInitFunction - called when item is removed from pool
  54. //
  55. // Entry: Nothing
  56. //
  57. // Exit: Boolean indicating success
  58. // ------------------------------
  59. #undef DPF_MODNAME
  60. #define DPF_MODNAME "CAdapterEntry::PoolInitFunction"
  61. void CAdapterEntry::PoolInitFunction( void* pvItem, void* pvContext )
  62. {
  63. CAdapterEntry* pAdapterEntry = (CAdapterEntry*)pvItem;
  64. DNASSERT( pAdapterEntry->m_AdapterListLinkage.IsEmpty() );
  65. DNASSERT( pAdapterEntry->m_ActiveSocketPorts.IsEmpty() );
  66. DNASSERT( pAdapterEntry->m_lRefCount == 0 );
  67. pAdapterEntry->m_lRefCount = 1;
  68. }
  69. //**********************************************************************
  70. //**********************************************************************
  71. // ------------------------------
  72. // CAdapterEntry::PoolReleaseFunction - called when item is returned to pool
  73. //
  74. // Entry: Nothing
  75. //
  76. // Exit: Nothing
  77. // ------------------------------
  78. #undef DPF_MODNAME
  79. #define DPF_MODNAME "CAdapterEntry::PoolReleaseFunction"
  80. void CAdapterEntry::PoolReleaseFunction( void* pvItem )
  81. {
  82. CAdapterEntry* pAdapterEntry = (CAdapterEntry*)pvItem;
  83. //
  84. // No more references, time to remove self from list.
  85. // This assumes the SPData socketportdata lock is held.
  86. //
  87. pAdapterEntry->m_AdapterListLinkage.RemoveFromList();
  88. DNASSERT( pAdapterEntry->m_AdapterListLinkage.IsEmpty() );
  89. DNASSERT( pAdapterEntry->m_ActiveSocketPorts.IsEmpty() );
  90. DNASSERT( pAdapterEntry->m_lRefCount == 0 );
  91. }
  92. //**********************************************************************
  93. //**********************************************************************
  94. // ------------------------------
  95. // CAdapterEntry::PoolDeallocFunction
  96. //
  97. // Entry: Nothing
  98. //
  99. // Exit: Boolean indicating success
  100. // ------------------------------
  101. #undef DPF_MODNAME
  102. #define DPF_MODNAME "CAdapterEntry::PoolDeallocFunction"
  103. void CAdapterEntry::PoolDeallocFunction( void* pvItem )
  104. {
  105. const CAdapterEntry* pAdapterEntry = (CAdapterEntry*)pvItem;
  106. DNASSERT( pAdapterEntry->m_AdapterListLinkage.IsEmpty() );
  107. DNASSERT( pAdapterEntry->m_ActiveSocketPorts.IsEmpty() );
  108. DNASSERT( pAdapterEntry->m_lRefCount == 0 );
  109. }
  110. //**********************************************************************
  111. #ifdef DBG
  112. //**********************************************************************
  113. // ------------------------------
  114. // CAdapterEntry::DebugPrintOutstandingSocketPorts - print out all the outstanding socket ports for this adapter
  115. //
  116. // Entry: None
  117. //
  118. // Exit: Nothing
  119. // ------------------------------
  120. #undef DPF_MODNAME
  121. #define DPF_MODNAME "CAdapterEntry::DebugPrintOutstandingSocketPorts"
  122. void CAdapterEntry::DebugPrintOutstandingSocketPorts( void )
  123. {
  124. CBilink * pBilink;
  125. CSocketPort * pSocketPort;
  126. DPFX(DPFPREP, 4, "Adapter entry 0x%p outstanding socket ports:", this);
  127. //
  128. // Find the base adapter entry for this network address. If none is found,
  129. // create a new one. If a new one cannot be created, fail.
  130. //
  131. pBilink = this->m_ActiveSocketPorts.GetNext();
  132. while (pBilink != &m_ActiveSocketPorts)
  133. {
  134. pSocketPort = CSocketPort::SocketPortFromBilink(pBilink);
  135. DPFX(DPFPREP, 4, " Socketport 0x%p", pSocketPort);
  136. pBilink = pBilink->GetNext();
  137. }
  138. }
  139. //**********************************************************************
  140. #endif // ! DPNBUILD_ONLYONEADAPTER
  141. #endif // DBG