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.

76 lines
1.6 KiB

  1. #include "pch.h"
  2. #pragma hdrstop
  3. #include "CWANIPConnectionService.h"
  4. #include "ndispnp.h"
  5. #include "ras.h"
  6. #include "rasuip.h"
  7. #include "util.h"
  8. CWANIPConnectionService::CWANIPConnectionService()
  9. {
  10. }
  11. HRESULT CWANIPConnectionService::get_LastConnectionError(BSTR *pLastConnectionError)
  12. {
  13. HRESULT hr = S_OK;
  14. *pLastConnectionError = SysAllocString(L"ERROR_NONE");
  15. if(NULL == *pLastConnectionError)
  16. {
  17. hr = E_OUTOFMEMORY;
  18. }
  19. return hr;
  20. }
  21. HRESULT CWANIPConnectionService::RequestConnection(void)
  22. {
  23. HRESULT hr = S_OK;
  24. hr = ControlEnabled();
  25. if(SUCCEEDED(hr))
  26. {
  27. INetConnection* pNetConnection;
  28. hr = m_pHomenetConnection->GetINetConnection(&pNetConnection);
  29. if(SUCCEEDED(hr))
  30. {
  31. hr = pNetConnection->Connect();
  32. pNetConnection->Release();
  33. }
  34. if(FAILED(hr))
  35. {
  36. SetUPnPError(DCP_ERROR_CONNECTIONSETUPFAILED);
  37. }
  38. }
  39. else
  40. {
  41. SetUPnPError(DCP_CUSTOM_ERROR_ACCESSDENIED);
  42. }
  43. return hr;
  44. }
  45. HRESULT CWANIPConnectionService::ForceTermination(void)
  46. {
  47. HRESULT hr = S_OK;
  48. hr = ControlEnabled();
  49. if(SUCCEEDED(hr))
  50. {
  51. INetConnection* pNetConnection;
  52. hr = m_pHomenetConnection->GetINetConnection(&pNetConnection);
  53. if(SUCCEEDED(hr))
  54. {
  55. hr = pNetConnection->Disconnect();
  56. pNetConnection->Release();
  57. }
  58. }
  59. else
  60. {
  61. SetUPnPError(DCP_CUSTOM_ERROR_ACCESSDENIED);
  62. }
  63. return hr;
  64. }