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.

115 lines
2.3 KiB

  1. #include "beacon.h"
  2. CInternetGateway::CInternetGateway()
  3. {
  4. m_MediaType = NCM_NONE;
  5. ZeroMemory(&m_LocalAdapterGUID, sizeof(m_LocalAdapterGUID));
  6. ZeroMemory(&m_Services, sizeof(m_Services));
  7. m_UniqueDeviceName = NULL;
  8. }
  9. HRESULT CInternetGateway::FinalRelease()
  10. {
  11. for(int i = 0; i < SAHOST_SERVICE_MAX; i++)
  12. {
  13. if(NULL != m_Services[i])
  14. {
  15. m_Services[i]->Release();
  16. }
  17. }
  18. SysFreeString(m_UniqueDeviceName);
  19. return S_OK;
  20. }
  21. HRESULT CInternetGateway::SetMediaType(NETCON_MEDIATYPE MediaType)
  22. {
  23. m_MediaType = MediaType;
  24. return S_OK;
  25. }
  26. HRESULT CInternetGateway::SetLocalAdapterGUID(GUID* pGuid)
  27. {
  28. CopyMemory(&m_LocalAdapterGUID, pGuid, sizeof(GUID));
  29. return S_OK;
  30. }
  31. HRESULT CInternetGateway::SetService(ULONG ulService, IUPnPService* pService)
  32. {
  33. HRESULT hr = S_OK;
  34. if(SAHOST_SERVICE_MAX > ulService && NULL == m_Services[ulService])
  35. {
  36. m_Services[ulService] = pService;
  37. pService->AddRef();
  38. }
  39. else
  40. {
  41. hr = E_INVALIDARG;
  42. }
  43. return hr;
  44. }
  45. HRESULT CInternetGateway::SetUniqueDeviceName(BSTR UniqueDeviceName)
  46. {
  47. HRESULT hr = S_OK;
  48. m_UniqueDeviceName = SysAllocString(UniqueDeviceName);
  49. if(NULL == m_UniqueDeviceName)
  50. {
  51. hr = E_OUTOFMEMORY;
  52. }
  53. return hr;
  54. }
  55. HRESULT CInternetGateway::GetMediaType(NETCON_MEDIATYPE* pMediaType)
  56. {
  57. *pMediaType = m_MediaType;
  58. return S_OK;
  59. }
  60. HRESULT CInternetGateway::GetLocalAdapterGUID(GUID* pGuid)
  61. {
  62. CopyMemory(pGuid, &m_LocalAdapterGUID, sizeof(GUID));
  63. return S_OK;
  64. }
  65. HRESULT CInternetGateway::GetService(SAHOST_SERVICES ulService, IUPnPService** ppService)
  66. {
  67. HRESULT hr = S_OK;
  68. *ppService = NULL;
  69. if(SAHOST_SERVICE_MAX > ulService)
  70. {
  71. *ppService = m_Services[ulService];
  72. if(NULL != *ppService)
  73. {
  74. (*ppService)->AddRef();
  75. }
  76. else
  77. {
  78. hr = E_FAIL;
  79. }
  80. }
  81. else
  82. {
  83. hr = E_INVALIDARG;
  84. }
  85. return hr;
  86. }
  87. HRESULT CInternetGateway::GetUniqueDeviceName(BSTR* pUniqueDeviceName)
  88. {
  89. HRESULT hr = S_OK;
  90. *pUniqueDeviceName = SysAllocString(m_UniqueDeviceName);
  91. if(NULL == *pUniqueDeviceName)
  92. {
  93. hr = E_OUTOFMEMORY;
  94. }
  95. return hr;
  96. }