PCPRequestPortMap

Try to open a port using RFC 6887 Port Control Protocol (PCP). Handles IPv4 and IPv6.

Synopsis

Declared in <common/pcp.h>

std::variant<MappingResult, MappingError>
PCPRequestPortMap(
    PCPMappingNonce const& nonce,
    CNetAddr const& gateway,
    CNetAddr const& bind,
    uint16_t port,
    uint32_t lifetime,
    CThreadInterrupt& interrupt,
    int num_tries = 3,
    std::chrono::milliseconds timeout_per_try = std::chrono::milliseconds(1000));

Description

* nonce: Mapping cookie. Keep this the same over renewals. * gateway: Destination address for PCP requests (usually the default gateway). * bind: Specific local bind address for IPv6 pinholing. Set this as INADDR_ANY for IPv4. * 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.

Return Value

The mapping result on success, otherwise a MappingError.

Parameters

NameDescription
nonceMapping cookie; keep this the same across renewals.
gatewayDestination address for requests (usually the default gateway).
bindLocal bind address for IPv6 pinholing; INADDR_ANY for IPv4.
portInternal port, and desired external port.
lifetimeRequested lifetime in seconds; 0 deletes the mapping.
interruptInterruption signal used to abort while waiting for a response.
num_triesNumber of attempts in case of no response.
timeout_per_tryTime to wait for a response on each attempt.