MCPcopy Create free account
hub / github.com/ElementsProject/elements / NatpmpDiscover

Function NatpmpDiscover

src/mapport.cpp:62–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62static bool NatpmpDiscover(natpmp_t* natpmp, struct in_addr& external_ipv4_addr)
63{
64 const int r_send = sendpublicaddressrequest(natpmp);
65 if (r_send == 2 /* OK */) {
66 int r_read;
67 natpmpresp_t response;
68 do {
69 r_read = readnatpmpresponseorretry(natpmp, &response);
70 } while (r_read == NATPMP_TRYAGAIN);
71
72 if (r_read == 0) {
73 external_ipv4_addr = response.pnu.publicaddress.addr;
74 return true;
75 } else if (r_read == NATPMP_ERR_NOGATEWAYSUPPORT) {
76 LogPrintf("natpmp: The gateway does not support NAT-PMP.\n");
77 } else {
78 LogPrintf("natpmp: readnatpmpresponseorretry() for public address failed with %d error.\n", r_read);
79 }
80 } else {
81 LogPrintf("natpmp: sendpublicaddressrequest() failed with %d error.\n", r_send);
82 }
83
84 return false;
85}
86
87static bool NatpmpMapping(natpmp_t* natpmp, const struct in_addr& external_ipv4_addr, uint16_t private_port, bool& external_ip_discovered)
88{

Callers 1

ProcessNatpmpFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected