Source code of Windows XP (NT5)
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.

83 lines
2.8 KiB

  1. // DPortMap.h : Declaration of the CDynamicPortMapping
  2. #ifndef __DYNAMICPORTMAPPING_H_
  3. #define __DYNAMICPORTMAPPING_H_
  4. #include <upnp.h>
  5. /////////////////////////////////////////////////////////////////////////////
  6. // CDynamicPortMapping
  7. class ATL_NO_VTABLE CDynamicPortMapping :
  8. public CComObjectRootEx<CComSingleThreadModel>,
  9. // public CComCoClass<CDynamicPortMapping, &CLSID_DynamicPortMapping>,
  10. public IDispatchImpl<IDynamicPortMapping, &IID_IDynamicPortMapping, &LIBID_NATUPNPLib>
  11. {
  12. private:
  13. enum eEnumData {
  14. eNoData = -1,
  15. eSomeData,
  16. eAllData
  17. };
  18. eEnumData m_eComplete;
  19. CComBSTR m_cbRemoteHost; // "" == wildcard (for static)
  20. long m_lExternalPort;
  21. CComBSTR m_cbProtocol; // "TCP" or "UDP"
  22. long m_lInternalPort; // internal == external for static
  23. CComBSTR m_cbInternalClient;
  24. VARIANT_BOOL m_vbEnabled;
  25. CComBSTR m_cbDescription;
  26. // Lease is live
  27. CComPtr<IUPnPService> m_spUPS;
  28. public:
  29. CDynamicPortMapping()
  30. {
  31. m_eComplete = eNoData;
  32. m_lInternalPort =
  33. m_lExternalPort = 0;
  34. m_vbEnabled = VARIANT_FALSE;
  35. }
  36. //DECLARE_REGISTRY_RESOURCEID(IDR_DYNAMICPORTMAPPING)
  37. DECLARE_PROTECT_FINAL_CONSTRUCT()
  38. BEGIN_COM_MAP(CDynamicPortMapping)
  39. COM_INTERFACE_ENTRY(IDynamicPortMapping)
  40. COM_INTERFACE_ENTRY(IDispatch)
  41. END_COM_MAP()
  42. // IDynamicPortMapping
  43. public:
  44. STDMETHOD(get_ExternalIPAddress)(/*[out, retval]*/ BSTR *pVal); // live one!
  45. STDMETHOD(get_RemoteHost)(/*[out, retval]*/ BSTR *pVal);
  46. STDMETHOD(get_ExternalPort)(/*[out, retval]*/ long *pVal);
  47. STDMETHOD(get_Protocol)(/*[out, retval]*/ BSTR *pVal);
  48. STDMETHOD(get_InternalPort)(/*[out, retval]*/ long *pVal);
  49. STDMETHOD(get_InternalClient)(/*[out, retval]*/ BSTR *pVal);
  50. STDMETHOD(get_Enabled)(/*[out, retval]*/ VARIANT_BOOL *pVal);
  51. STDMETHOD(get_Description)(/*[out, retval]*/ BSTR *pVal);
  52. STDMETHOD(get_LeaseDuration)(/*[out, retval]*/ long *pVal); // live one!
  53. STDMETHOD(RenewLease)(/*[in]*/ long lLeaseDurationDesired, /*[out, retval]*/ long * pLeaseDurationReturned);
  54. STDMETHOD(EditInternalClient)(/*[in]*/ BSTR bstrInternalClient);
  55. STDMETHOD(Enable)(/*[in]*/ VARIANT_BOOL vb);
  56. STDMETHOD(EditDescription)(/*[in]*/ BSTR bstrDescription);
  57. STDMETHOD(EditInternalPort)(/*[in]*/ long lInternalPort);
  58. // CDynamicPortMapping
  59. public:
  60. static HRESULT CreateInstance (IUPnPService * pUPS, long lIndex, IDynamicPortMapping ** ppDPM);
  61. HRESULT Initialize (IUPnPService * pUPS, long lIndex);
  62. static HRESULT CreateInstance (IUPnPService * pUPS, BSTR bstrRemoteHost, long lExternalPort, BSTR bstrProtocol, IDynamicPortMapping ** ppDPM);
  63. HRESULT Initialize (IUPnPService * pUPS, BSTR bstrRemoteHost, long lExternalPort, BSTR bstrProtocol);
  64. private:
  65. HRESULT GetAllData (long * pLease = NULL);
  66. };
  67. #endif //__DYNAMICPORTMAPPING_H_