/// <summary> /// Method to delete a port mapping /// </summary> /// <param name="remoteHost">the remote host</param> /// <param name="externalPort">the external port</param> /// <param name="protocol">the protocol</param> /// <returns></returns> public async Task DeletePortMappingAsync(IPAddress remoteHost, UInt16 externalPort, PortMappingProtocol protocol) { List <SoapRequestParameter> parameters = new List <SoapRequestParameter>() { new SoapRequestParameter("NewRemoteHost", remoteHost?.ToString()), new SoapRequestParameter("NewExternalPort", externalPort), new SoapRequestParameter("NewProtocol", protocol.ToString()) }; await this.InvokeAsync("DeletePortMapping", parameters.ToArray()); }
/// <summary> /// Method to get a specific port mapping entry /// </summary> /// <param name="remoteHost">the remote host</param> /// <param name="externalPort">the remote port</param> /// <param name="protocol">the protocol</param> /// <returns>the specific port mapping entry</returns> public async Task <PortMappingEntry> GetSpecificPortMappingEntryAsync(IPAddress remoteHost, UInt16 externalPort, PortMappingProtocol protocol) { List <SoapRequestParameter> parameters = new List <SoapRequestParameter>() { new SoapRequestParameter("NewRemoteHost", remoteHost?.ToString()), new SoapRequestParameter("NewExternalPort", externalPort), new SoapRequestParameter("NewProtocol", protocol.ToString()) }; XDocument document = await this.InvokeAsync("GetSpecificPortMappingEntry", parameters.ToArray()); PortMappingEntry entry = new PortMappingEntry() { RemoteHost = remoteHost, ExternalPort = externalPort, PortMappingProtocol = protocol }; entry.Enabled = document.Descendants("NewEnabled").First().Value == "1"; entry.InternalHost = IPAddress.TryParse(document.Descendants("NewInternalClient").First().Value, out IPAddress internalHost) ? internalHost : IPAddress.None; entry.InternalPort = Convert.ToUInt16(document.Descendants("NewInternalPort").First().Value); entry.LeaseDuration = Convert.ToUInt32(document.Descendants("NewLeaseDuration").First().Value); entry.Description = document.Descendants("NewPortMappingDescription").First().Value; return(entry); }