12#include <util/threadinterrupt.h> 
   14using namespace std::literals;
 
   17constexpr PCPMappingNonce PCP_NONCE{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc};
 
   23constexpr std::chrono::duration 
TIMEOUT{100ms};
 
   35    CreateSock = [&](
int domain, 
int type, 
int protocol) {
 
   36        if ((domain == AF_INET || domain == AF_INET6) && type == SOCK_DGRAM && protocol == IPPROTO_UDP) {
 
   39        return std::unique_ptr<FuzzedSock>();
 
   51    if (
const MappingResult* mapping = std::get_if<MappingResult>(&res)) {
 
   53        Assert(mapping->internal.GetPort() == port);
 
   63    CreateSock = [&](
int domain, 
int type, 
int protocol) {
 
   64        if (domain == AF_INET && type == SOCK_DGRAM && protocol == IPPROTO_UDP) {
 
   67        return std::unique_ptr<FuzzedSock>();
 
   78    if (
const MappingResult* mapping = std::get_if<MappingResult>(&res)) {
 
   80        Assert(mapping->internal.GetPort() == port);
 
#define Assert(val)
Identity function.
 
void DisableLogging() EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Disable logging This offers a slight speedup and slightly smaller memory usage compared to leaving th...
 
A helper class for interruptible sleeps.
 
std::variant< MappingResult, MappingError > NATPMPRequestPortMap(const CNetAddr &gateway, uint16_t port, uint32_t lifetime, CThreadInterrupt &interrupt, int num_tries, std::chrono::milliseconds timeout_per_try)
Try to open a port using RFC 6886 NAT-PMP.
 
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, std::chrono::milliseconds timeout_per_try)
Try to open a port using RFC 6887 Port Control Protocol (PCP).
 
BCLog::Logger & LogInstance()
 
std::function< std::unique_ptr< Sock >(int, int, int)> CreateSock
Socket factory.
 
std::array< uint8_t, PCP_MAP_NONCE_SIZE > PCPMappingNonce
PCP mapping nonce. Arbitrary data chosen by the client to identify a mapping.
 
Successful response to a port mapping.
 
FUZZ_TARGET(pcp_request_port_map,.init=port_map_target_init)
 
constexpr PCPMappingNonce PCP_NONCE
Fixed nonce to use in PCP port mapping requests.
 
constexpr int NUM_TRIES
Number of attempts to request a NAT-PMP or PCP port mapping to the gateway.
 
constexpr std::chrono::duration TIMEOUT
Timeout for each attempt to request a port mapping.
 
void port_map_target_init()
 
CNetAddr ConsumeNetAddr(FuzzedDataProvider &fuzzed_data_provider, FastRandomContext *rand) noexcept
Create a CNetAddr.
 
FuzzedDataProvider & fuzzed_data_provider