/// <summary>获取指定设备的端口映射信息</summary> /// <param name="index">索引</param> /// <returns></returns> public PortMappingEntry GetMapByIndex(Int32 index) { PortMappingEntryRequest entity = new PortMappingEntryRequest(); entity.Name = "GetGenericPortMappingEntry"; entity.NewPortMappingIndex = index; PortMappingEntry response = Request <PortMappingEntry>(entity); return(response); }
/// <summary>删除端口映射</summary> /// <param name="remoteHost">远程主机</param> /// <param name="externalPort">外部端口</param> /// <param name="protocol">TCP或UDP</param> /// <returns></returns> public Boolean Delete(String remoteHost, Int32 externalPort, String protocol) { var entity = new PortMappingEntry(); entity.Name = "DeletePortMapping"; entity.RemoteHost = remoteHost; entity.ExternalPort = externalPort; entity.Protocol = protocol; var response = Request <PortMappingEntry>(entity); return(response != null); }
/// <summary>获取指定设备的端口映射信息</summary> /// <param name="remoteHost">远程主机</param> /// <param name="externalPort">外部端口</param> /// <param name="protocol">TCP/UDP</param> /// <returns></returns> public PortMappingEntry GetMapByPortAndProtocol(String remoteHost, Int32 externalPort, String protocol) { PortMappingEntry entity = new PortMappingEntry(); entity.Name = "GetSpecificPortMappingEntry"; entity.RemoteHost = remoteHost; entity.ExternalPort = externalPort; entity.Protocol = protocol; PortMappingEntry response = Request <PortMappingEntry>(entity); return(response); }
/// <summary>添加映射端口</summary> /// <param name="remoteHost">远程主机</param> /// <param name="externalPort">外部端口</param> /// <param name="protocol">TCP或UDP</param> /// <param name="internalPort">内部端口</param> /// <param name="internalClient">本地IP地址</param> /// <param name="enabled">是否启用[0,1]</param> /// <param name="description">端口映射的描述</param> /// <param name="duration">映射的持续时间,用0表示永久</param> /// <returns>bool</returns> public Boolean Add(String remoteHost, Int32 externalPort, String protocol, Int32 internalPort, String internalClient, Int32 enabled, String description, Int32 duration) { var entity = new PortMappingEntry(); entity.Name = "AddPortMapping"; entity.RemoteHost = remoteHost; entity.ExternalPort = externalPort; entity.Protocol = protocol; entity.InternalClient = internalClient; entity.InternalPort = internalPort; entity.Enabled = enabled; entity.Description = description; entity.LeaseDuration = duration; var response = Request <PortMappingEntry>(entity); return(response != null); }