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.

217 lines
4.9 KiB

  1. /*
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. blbconn.cpp
  5. Abstract:
  6. Author:
  7. */
  8. #include "stdafx.h"
  9. #include "blbgen.h"
  10. #include "blbconn.h"
  11. #include "sdpblob.h"
  12. STDMETHODIMP ITConnectionImpl::get_StartAddress(BSTR * pVal)
  13. {
  14. CLock Lock(g_DllLock);
  15. return m_SdpConnection->GetStartAddress().GetBstrCopy(pVal);
  16. }
  17. STDMETHODIMP ITConnectionImpl::get_NumAddresses(LONG * pVal)
  18. {
  19. BAIL_IF_NULL(pVal, E_INVALIDARG);
  20. CLock Lock(g_DllLock);
  21. // if the entry isn't valid, it means its one (by default)
  22. SDP_ULONG &NumAddresses = m_SdpConnection->GetNumAddresses();
  23. // vb doesn't take ulong values. this will only affect us if half or more of all the IP addresses
  24. // (not just multicast) are being used
  25. if( (LONG)(NumAddresses.IsValid()) )
  26. {
  27. *pVal = NumAddresses.GetValue();
  28. }
  29. else
  30. {
  31. //
  32. // TTL is a good flag if it is a ral address
  33. // 0: we don't have address
  34. // >0 we have an address
  35. //
  36. BYTE nTTL = 0;
  37. m_SdpConnection->GetTtl().GetValue(nTTL);
  38. *pVal = nTTL ? 1 : 0;
  39. }
  40. //*pVal = (LONG)(NumAddresses.IsValid()) ? NumAddresses.GetValue() : 0;
  41. return S_OK;
  42. }
  43. STDMETHODIMP ITConnectionImpl::get_Ttl(BYTE * pVal)
  44. {
  45. BAIL_IF_NULL(pVal, E_INVALIDARG);
  46. CLock Lock(g_DllLock);
  47. return m_SdpConnection->GetTtl().GetValue(*pVal);
  48. }
  49. STDMETHODIMP ITConnectionImpl::get_BandwidthModifier(BSTR * pVal)
  50. {
  51. CLock Lock(g_DllLock);
  52. return m_SdpBandwidth->GetModifier().GetBstrCopy(pVal);
  53. }
  54. STDMETHODIMP ITConnectionImpl::get_Bandwidth(DOUBLE * pVal)
  55. {
  56. BAIL_IF_NULL(pVal, E_INVALIDARG);
  57. CLock Lock(g_DllLock);
  58. ULONG BandwidthValue;
  59. BAIL_ON_FAILURE(m_SdpBandwidth->GetBandwidthValue().GetValue(BandwidthValue));
  60. // vb doesn't take a ulong value, so use the next bigger type
  61. *pVal = (DOUBLE)BandwidthValue;
  62. return S_OK;
  63. }
  64. STDMETHODIMP ITConnectionImpl::SetAddressInfo(BSTR StartAddress, LONG NumAddresses, BYTE Ttl)
  65. {
  66. if ( 0 > NumAddresses )
  67. {
  68. return E_INVALIDARG;
  69. }
  70. CLock Lock(g_DllLock);
  71. if ( !m_IsMain && ((NULL == StartAddress) || (WCHAR_EOS == StartAddress[0])) )
  72. {
  73. m_SdpConnection->Reset();
  74. return S_OK;
  75. }
  76. HRESULT HResult = m_SdpConnection->SetConnection(StartAddress, NumAddresses, Ttl);
  77. BAIL_ON_FAILURE(HResult);
  78. return S_OK;
  79. }
  80. STDMETHODIMP ITConnectionImpl::SetBandwidthInfo(BSTR Modifier, DOUBLE Bandwidth)
  81. {
  82. // the bandwidth value must be a valid ULONG value (vb restrictions)
  83. if ( !((0 <= Bandwidth) && (ULONG(-1) > Bandwidth)) )
  84. {
  85. return E_INVALIDARG;
  86. }
  87. // check if there is any fractional part, this check is valid as it is a valid ULONG value
  88. if ( Bandwidth != (ULONG)Bandwidth )
  89. {
  90. return E_INVALIDARG;
  91. }
  92. CLock Lock(g_DllLock);
  93. if ( (NULL == Modifier) || (WCHAR_EOS == Modifier[0]) )
  94. {
  95. m_SdpBandwidth->Reset();
  96. return S_OK;
  97. }
  98. return m_SdpBandwidth->SetBandwidth(Modifier, (ULONG)Bandwidth);
  99. }
  100. STDMETHODIMP ITConnectionImpl::SetEncryptionKey(BSTR KeyType, BSTR * KeyData)
  101. {
  102. CLock Lock(g_DllLock);
  103. if ( (NULL == KeyType) || (WCHAR_EOS == KeyType[0]) )
  104. {
  105. m_SdpKey->Reset();
  106. return S_OK;
  107. }
  108. return m_SdpKey->SetKey(KeyType, KeyData);
  109. }
  110. STDMETHODIMP ITConnectionImpl::GetEncryptionKey(BSTR * KeyType, VARIANT_BOOL * ValidKeyData, BSTR * KeyData)
  111. {
  112. BAIL_IF_NULL(KeyType, E_INVALIDARG);
  113. BAIL_IF_NULL(ValidKeyData, E_INVALIDARG);
  114. BAIL_IF_NULL(KeyData, E_INVALIDARG);
  115. CLock Lock(g_DllLock);
  116. HRESULT HResult = m_SdpKey->GetKeyType().GetBstrCopy(KeyType);
  117. BAIL_ON_FAILURE(HResult);
  118. if ( !m_SdpKey->GetKeyData().IsValid() )
  119. {
  120. *ValidKeyData = VARIANT_FALSE;
  121. return S_OK;
  122. }
  123. HResult = m_SdpKey->GetKeyData().GetBstrCopy(KeyData);
  124. *ValidKeyData = (SUCCEEDED(HResult))? VARIANT_TRUE : VARIANT_FALSE;
  125. if ( VARIANT_FALSE == *ValidKeyData )
  126. {
  127. SysFreeString(*KeyType);
  128. return HResult;
  129. }
  130. return S_OK;
  131. }
  132. STDMETHODIMP ITConnectionImpl::get_NetworkType(BSTR * pVal)
  133. {
  134. CLock Lock(g_DllLock);
  135. return m_SdpConnection->GetNetworkType().GetBstrCopy(pVal);
  136. }
  137. STDMETHODIMP ITConnectionImpl::put_NetworkType(BSTR newVal)
  138. {
  139. CLock Lock(g_DllLock);
  140. return m_SdpConnection->GetNetworkType().SetBstr(newVal);
  141. }
  142. STDMETHODIMP ITConnectionImpl::get_AddressType(BSTR * pVal)
  143. {
  144. CLock Lock(g_DllLock);
  145. return m_SdpConnection->GetAddressType().GetBstrCopy(pVal);
  146. }
  147. STDMETHODIMP ITConnectionImpl::put_AddressType(BSTR newVal)
  148. {
  149. CLock Lock(g_DllLock);
  150. return m_SdpConnection->GetAddressType().SetBstr(newVal);
  151. }