Try to open a port using RFC 6886 NAT-PMP. IPv4 only.
Declared in <common/pcp.h>
std::variant<MappingResult, MappingError>
NATPMPRequestPortMap(
CNetAddr const& gateway,
uint16_t port,
uint32_t lifetime,
CThreadInterrupt& interrupt,
int num_tries = 3,
std::chrono::milliseconds timeout_per_try = std::chrono::milliseconds(1000));
* gateway: Destination address for PCP requests (usually the default gateway). * port: Internal port, and desired external port. * lifetime: Requested lifetime in seconds for mapping. The server may assign as shorter or longer lifetime. A lifetime of 0 deletes the mapping. * num_tries: Number of tries in case of no response.
Returns the external_ip:external_port of the mapping if successful, otherwise a MappingError.
The mapping result on success, otherwise a MappingError.
| Name | Description |
|---|---|
| gateway | Destination address for requests (usually the default gateway). |
| port | Internal port, and desired external port. |
| lifetime | Requested lifetime in seconds; 0 deletes the mapping. |
| interrupt | Interruption signal used to abort while waiting for a response. |
| num_tries | Number of attempts in case of no response. |
| timeout_per_try | Time to wait for a response on each attempt. |