#include <netaddress.h>
#include <util/threadinterrupt.h>
#include <variant>
Go to the source code of this file.
|
| std::variant< MappingResult, MappingError > | NATPMPRequestPortMap (const CNetAddr &gateway, uint16_t port, uint32_t lifetime, CThreadInterrupt &interrupt, int num_tries=3, std::chrono::milliseconds timeout_per_try=std::chrono::milliseconds(1000)) |
| std::variant< MappingResult, MappingError > | PCPRequestPortMap (const PCPMappingNonce &nonce, const CNetAddr &gateway, const CNetAddr &bind, uint16_t port, uint32_t lifetime, CThreadInterrupt &interrupt, int num_tries=3, std::chrono::milliseconds timeout_per_try=std::chrono::milliseconds(1000)) |
|
| constexpr size_t | PCP_MAP_NONCE_SIZE = 12 |
| | Mapping nonce size in bytes (see RFC6887 section 11.1).
|
◆ PCPMappingNonce
PCP mapping nonce. Arbitrary data chosen by the client to identify a mapping.
Definition at line 20 of file pcp.h.
◆ MappingError
Unsuccessful response to a port mapping.
| Enumerator |
|---|
| NETWORK_ERROR | Any kind of network-level error.
|
| PROTOCOL_ERROR | Any kind of protocol-level error, except unsupported version or no resources.
|
| UNSUPP_VERSION | Unsupported protocol version.
|
| NO_RESOURCES | No resources available (port probably already mapped).
|
Definition at line 23 of file pcp.h.
◆ NATPMPRequestPortMap()
| std::variant< MappingResult, MappingError > NATPMPRequestPortMap |
( |
const CNetAddr & | gateway, |
|
|
uint16_t | port, |
|
|
uint32_t | lifetime, |
|
|
CThreadInterrupt & | interrupt, |
|
|
int | num_tries = 3, |
|
|
std::chrono::milliseconds | timeout_per_try = std::chrono::milliseconds(1000) ) |
Try to open a port using RFC 6886 NAT-PMP. IPv4 only.
- 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.
Definition at line 282 of file pcp.cpp.
◆ PCPRequestPortMap()
Try to open a port using RFC 6887 Port Control Protocol (PCP). Handles IPv4 and IPv6.
- 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.
Definition at line 406 of file pcp.cpp.
◆ PCP_MAP_NONCE_SIZE
| size_t PCP_MAP_NONCE_SIZE = 12 |
|
constexpr |
Mapping nonce size in bytes (see RFC6887 section 11.1).
Definition at line 17 of file pcp.h.