5#ifndef BITCOIN_COMMON_PCP_H
6#define BITCOIN_COMMON_PCP_H
54std::variant<MappingResult, MappingError>
NATPMPRequestPortMap(
const CNetAddr &gateway, uint16_t port, uint32_t lifetime,
int num_tries = 3, std::chrono::milliseconds timeout_per_try = std::chrono::milliseconds(1000));
66std::variant<MappingResult, MappingError>
PCPRequestPortMap(
const PCPMappingNonce &
nonce,
const CNetAddr &gateway,
const CNetAddr &bind, uint16_t port, uint32_t lifetime,
int num_tries = 3, std::chrono::milliseconds timeout_per_try = std::chrono::milliseconds(1000));
A combination of a network address (CNetAddr) and a (TCP) port.
std::variant< MappingResult, MappingError > PCPRequestPortMap(const PCPMappingNonce &nonce, const CNetAddr &gateway, const CNetAddr &bind, uint16_t port, uint32_t lifetime, int num_tries=3, std::chrono::milliseconds timeout_per_try=std::chrono::milliseconds(1000))
Try to open a port using RFC 6887 Port Control Protocol (PCP).
std::array< uint8_t, PCP_MAP_NONCE_SIZE > PCPMappingNonce
PCP mapping nonce. Arbitrary data chosen by the client to identify a mapping.
constexpr size_t PCP_MAP_NONCE_SIZE
Mapping nonce size in bytes (see RFC6887 section 11.1).
MappingError
Unsuccessful response to a port mapping.
@ PROTOCOL_ERROR
Any kind of protocol-level error, except unsupported version or no resources.
@ NO_RESOURCES
No resources available (port probably already mapped).
@ UNSUPP_VERSION
Unsupported protocol version.
@ NETWORK_ERROR
Any kind of network-level error.
std::variant< MappingResult, MappingError > NATPMPRequestPortMap(const CNetAddr &gateway, uint16_t port, uint32_t lifetime, int num_tries=3, std::chrono::milliseconds timeout_per_try=std::chrono::milliseconds(1000))
Try to open a port using RFC 6886 NAT-PMP.
Successful response to a port mapping.
CService external
External host:port.
uint32_t lifetime
Granted lifetime of binding (seconds).
CService internal
Internal host:port.
MappingResult(uint8_t version, const CService &internal_in, const CService &external_in, uint32_t lifetime_in)
std::string ToString()
Format mapping as string for logging.
uint8_t version
Protocol version, one of NATPMP_VERSION or PCP_VERSION.