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.

164 lines
5.5 KiB

  1. /***************************************************************************
  2. *
  3. * Copyright (C) 2001-2002 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: spwrapper.h
  6. *
  7. * Content: Header for DP8SIM main SP interface wrapper object class.
  8. *
  9. * History:
  10. * Date By Reason
  11. * ======== ======== =========
  12. * 04/23/01 VanceO Created.
  13. *
  14. ***************************************************************************/
  15. //=============================================================================
  16. // Macros
  17. //=============================================================================
  18. #define DP8SIMSP_FROM_BILINK(b) (CONTAINING_OBJECT(b, CDP8SimSP, m_blList))
  19. //=============================================================================
  20. // Object flags
  21. //=============================================================================
  22. #define DP8SIMSPOBJ_INITIALIZED 0x01 // object has been initialized
  23. #define DP8SIMSPOBJ_STARTEDGLOBALWORKERTHREAD 0x02 // the global worker thread was started
  24. #define DP8SIMSPOBJ_CLOSING 0x04 // close is in progress, no new functions are allowed
  25. //=============================================================================
  26. // Service provider interface object class
  27. //=============================================================================
  28. class CDP8SimSP : public IDP8ServiceProvider
  29. {
  30. public:
  31. CDP8SimSP(const GUID * const pguidFakeSP, const GUID * const pguidRealSP); // constructor
  32. ~CDP8SimSP(void); // destructor
  33. STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
  34. STDMETHODIMP_(ULONG) AddRef(void);
  35. STDMETHODIMP_(ULONG) Release(void);
  36. STDMETHODIMP Initialize(PSPINITIALIZEDATA pspid);
  37. STDMETHODIMP Close(void);
  38. STDMETHODIMP Connect(PSPCONNECTDATA pspcd);
  39. STDMETHODIMP Disconnect(PSPDISCONNECTDATA pspdd);
  40. STDMETHODIMP Listen(PSPLISTENDATA pspld);
  41. STDMETHODIMP SendData(PSPSENDDATA pspsd);
  42. STDMETHODIMP EnumQuery(PSPENUMQUERYDATA pspeqd);
  43. STDMETHODIMP EnumRespond(PSPENUMRESPONDDATA psperd);
  44. STDMETHODIMP CancelCommand(HANDLE hCommand, DWORD dwCommandDescriptor);
  45. STDMETHODIMP EnumMulticastScopes(PSPENUMMULTICASTSCOPESDATA pspemsd);
  46. STDMETHODIMP ShareEndpointInfo(PSPSHAREENDPOINTINFODATA pspseid);
  47. STDMETHODIMP GetEndpointByAddress(PSPGETENDPOINTBYADDRESSDATA pspgebad);
  48. STDMETHODIMP Update(PSPUPDATEDATA pspud);
  49. STDMETHODIMP GetCaps(PSPGETCAPSDATA pspgcd);
  50. STDMETHODIMP SetCaps(PSPSETCAPSDATA pspscd);
  51. STDMETHODIMP ReturnReceiveBuffers(PSPRECEIVEDBUFFER psprb);
  52. STDMETHODIMP GetAddressInfo(PSPGETADDRESSINFODATA pspgaid);
  53. STDMETHODIMP IsApplicationSupported(PSPISAPPLICATIONSUPPORTEDDATA pspiasd);
  54. STDMETHODIMP EnumAdapters(PSPENUMADAPTERSDATA pspead);
  55. STDMETHODIMP ProxyEnumQuery(PSPPROXYENUMQUERYDATA psppeqd);
  56. HRESULT InitializeObject(void);
  57. void UninitializeObject(void);
  58. void PerformDelayedSend(PVOID const pvContext);
  59. void PerformDelayedReceive(PVOID const pvContext);
  60. void IncSendsPending(void);
  61. void DecSendsPending(void);
  62. void IncReceivesPending(void);
  63. void DecReceivesPending(void);
  64. static BOOL ShouldDrop(const FLOAT fDropPercentage);
  65. static BOOL GetDelay(const DWORD dwBandwidthBPS,
  66. const DWORD dwPacketHeaderSize,
  67. const DWORD dwDataSize,
  68. const DWORD dwMinRandMS,
  69. const DWORD dwMaxRandMS,
  70. DWORD * const pdwBandwidthDelay,
  71. DWORD * const pdwLatencyDelay);
  72. inline void GetAllReceiveParameters(DP8SIM_PARAMETERS * const pdp8sp) { this->m_DP8SimIPC.GetAllReceiveParameters(pdp8sp); };
  73. inline void IncrementStatsSendTransmitted(DWORD dwBytes, DWORD dwDelay) { this->m_DP8SimIPC.IncrementStatsSendTransmitted(dwBytes, dwDelay); };
  74. inline void IncrementStatsSendDropped(DWORD dwBytes) { this->m_DP8SimIPC.IncrementStatsSendDropped(dwBytes); };
  75. inline void IncrementStatsReceiveTransmitted(DWORD dwBytes, DWORD dwDelay) { this->m_DP8SimIPC.IncrementStatsReceiveTransmitted(dwBytes, dwDelay); };
  76. inline void IncrementStatsReceiveDropped(DWORD dwBytes) { this->m_DP8SimIPC.IncrementStatsReceiveDropped(dwBytes); };
  77. inline GUID * GetFakeSP(void) { return (&this->m_guidFakeSP); };
  78. CBilink m_blList; // list of all the DP8SimSP instances in existence
  79. private:
  80. BYTE m_Sig[4]; // debugging signature ('SPWP')
  81. LONG m_lRefCount; // reference count for this object
  82. DWORD m_dwFlags; // flags for this object
  83. DNCRITICAL_SECTION m_csLock; // lock preventing simultaneous usage of globals
  84. GUID m_guidFakeSP; // GUID of fake SP object
  85. GUID m_guidRealSP; // GUID of real SP object
  86. CDP8SimCB * m_pDP8SimCB; // pointer to callback interface wrapper object in use
  87. IDP8ServiceProvider * m_pDP8SP; // pointer to real service provider interface
  88. DWORD m_dwSendsPending; // number of outstanding sends
  89. HANDLE m_hLastPendingSendEvent; // handle to event to set when last send completes
  90. DWORD m_dwReceivesPending; // number of outstanding sends
  91. //HANDLE m_hLastPendingReceiveEvent; // handle to event to set when last send completes
  92. CDP8SimIPC m_DP8SimIPC; // object that handles interprocess communication
  93. inline BOOL IsValidObject(void)
  94. {
  95. if ((this == NULL) || (IsBadWritePtr(this, sizeof(CDP8SimSP))))
  96. {
  97. return FALSE;
  98. }
  99. if (*((DWORD*) (&this->m_Sig)) != 0x50575053) // 0x50 0x57 0x50 0x53 = 'PWPS' = 'SPWP' in Intel order
  100. {
  101. return FALSE;
  102. }
  103. return TRUE;
  104. };
  105. };