@@ -179,7 +179,7 @@ std::string PCPResultString(uint8_t result_code)
179179}
180180
181181// ! Wrap address in IPv6 according to RFC6887. wrapped_addr needs to be able to store 16 bytes.
182- [[nodiscard]] bool PCPWrapAddress (Span <uint8_t > wrapped_addr, const CNetAddr &addr)
182+ [[nodiscard]] bool PCPWrapAddress (std::span <uint8_t > wrapped_addr, const CNetAddr &addr)
183183{
184184 Assume (wrapped_addr.size () == ADDR_IPV6_SIZE);
185185 if (addr.IsIPv4 ()) {
@@ -200,7 +200,7 @@ std::string PCPResultString(uint8_t result_code)
200200}
201201
202202// ! Unwrap PCP-encoded address according to RFC6887.
203- CNetAddr PCPUnwrapAddress (Span <const uint8_t > wrapped_addr)
203+ CNetAddr PCPUnwrapAddress (std::span <const uint8_t > wrapped_addr)
204204{
205205 Assume (wrapped_addr.size () == ADDR_IPV6_SIZE);
206206 if (util::HasPrefix (wrapped_addr, IPV4_IN_IPV6_PREFIX)) {
@@ -215,9 +215,9 @@ CNetAddr PCPUnwrapAddress(Span<const uint8_t> wrapped_addr)
215215}
216216
217217// ! PCP or NAT-PMP send-receive loop.
218- std::optional<std::vector<uint8_t >> PCPSendRecv (Sock &sock, const std::string &protocol, Span <const uint8_t > request, int num_tries,
218+ std::optional<std::vector<uint8_t >> PCPSendRecv (Sock &sock, const std::string &protocol, std::span <const uint8_t > request, int num_tries,
219219 std::chrono::milliseconds timeout_per_try,
220- std::function<bool (Span <const uint8_t >)> check_packet)
220+ std::function<bool (std::span <const uint8_t >)> check_packet)
221221{
222222 using namespace std ::chrono;
223223 // UDP is a potentially lossy protocol, so we try to send again a few times.
@@ -254,9 +254,9 @@ std::optional<std::vector<uint8_t>> PCPSendRecv(Sock &sock, const std::string &p
254254 LogPrintLevel (BCLog::NET, BCLog::Level::Warning, " %s: Could not receive response: %s\n " , protocol, NetworkErrorString (WSAGetLastError ()));
255255 return std::nullopt ; // Network-level error, probably no use retrying.
256256 }
257- LogPrintLevel (BCLog::NET, BCLog::Level::Debug, " %s: Received response of %d bytes: %s\n " , protocol, recvsz, HexStr (Span (response, recvsz)));
257+ LogPrintLevel (BCLog::NET, BCLog::Level::Debug, " %s: Received response of %d bytes: %s\n " , protocol, recvsz, HexStr (std::span (response, recvsz)));
258258
259- if (check_packet (Span <uint8_t >(response, recvsz))) {
259+ if (check_packet (std::span <uint8_t >(response, recvsz))) {
260260 got_response = true ; // Got expected response, break from receive loop as well as from retry loop.
261261 break ;
262262 }
@@ -309,7 +309,7 @@ std::variant<MappingResult, MappingError> NATPMPRequestPortMap(const CNetAddr &g
309309 request[NATPMP_HDR_OP_OFS] = NATPMP_REQUEST | NATPMP_OP_GETEXTERNAL;
310310
311311 auto recv_res = PCPSendRecv (*sock, " natpmp" , request, num_tries, timeout_per_try,
312- [&](const Span <const uint8_t > response) -> bool {
312+ [&](const std::span <const uint8_t > response) -> bool {
313313 if (response.size () < NATPMP_GETEXTERNAL_RESPONSE_SIZE) {
314314 LogPrintLevel (BCLog::NET, BCLog::Level::Warning, " natpmp: Response too small\n " );
315315 return false ; // Wasn't response to what we expected, try receiving next packet.
@@ -346,7 +346,7 @@ std::variant<MappingResult, MappingError> NATPMPRequestPortMap(const CNetAddr &g
346346 WriteBE32 (request.data () + NATPMP_MAP_REQUEST_LIFETIME_OFS, lifetime);
347347
348348 recv_res = PCPSendRecv (*sock, " natpmp" , request, num_tries, timeout_per_try,
349- [&](const Span <const uint8_t > response) -> bool {
349+ [&](const std::span <const uint8_t > response) -> bool {
350350 if (response.size () < NATPMP_MAP_RESPONSE_SIZE) {
351351 LogPrintLevel (BCLog::NET, BCLog::Level::Warning, " natpmp: Response too small\n " );
352352 return false ; // Wasn't response to what we expected, try receiving next packet.
@@ -438,7 +438,7 @@ std::variant<MappingResult, MappingError> PCPRequestPortMap(const PCPMappingNonc
438438 request[ofs + PCP_HDR_VERSION_OFS] = PCP_VERSION;
439439 request[ofs + PCP_HDR_OP_OFS] = PCP_REQUEST | PCP_OP_MAP;
440440 WriteBE32 (request.data () + ofs + PCP_HDR_LIFETIME_OFS, lifetime);
441- if (!PCPWrapAddress (Span (request).subspan (ofs + PCP_REQUEST_HDR_IP_OFS, ADDR_IPV6_SIZE), internal)) return MappingError::NETWORK_ERROR;
441+ if (!PCPWrapAddress (std::span (request).subspan (ofs + PCP_REQUEST_HDR_IP_OFS, ADDR_IPV6_SIZE), internal)) return MappingError::NETWORK_ERROR;
442442
443443 ofs += PCP_HDR_SIZE;
444444
@@ -449,15 +449,15 @@ std::variant<MappingResult, MappingError> PCPRequestPortMap(const PCPMappingNonc
449449 request[ofs + PCP_MAP_PROTOCOL_OFS] = PCP_PROTOCOL_TCP;
450450 WriteBE16 (request.data () + ofs + PCP_MAP_INTERNAL_PORT_OFS, port);
451451 WriteBE16 (request.data () + ofs + PCP_MAP_EXTERNAL_PORT_OFS, port);
452- if (!PCPWrapAddress (Span (request).subspan (ofs + PCP_MAP_EXTERNAL_IP_OFS, ADDR_IPV6_SIZE), bind)) return MappingError::NETWORK_ERROR;
452+ if (!PCPWrapAddress (std::span (request).subspan (ofs + PCP_MAP_EXTERNAL_IP_OFS, ADDR_IPV6_SIZE), bind)) return MappingError::NETWORK_ERROR;
453453
454454 ofs += PCP_MAP_SIZE;
455455 Assume (ofs == request.size ());
456456
457457 // Receive loop.
458458 bool is_natpmp = false ;
459459 auto recv_res = PCPSendRecv (*sock, " pcp" , request, num_tries, timeout_per_try,
460- [&](const Span <const uint8_t > response) -> bool {
460+ [&](const std::span <const uint8_t > response) -> bool {
461461 // Unsupported version according to RFC6887 appendix A and RFC6886 section 3.5, can fall back to NAT-PMP.
462462 if (response.size () == NATPMP_RESPONSE_HDR_SIZE && response[PCP_HDR_VERSION_OFS] == NATPMP_VERSION && response[PCP_RESPONSE_HDR_RESULT_OFS] == NATPMP_RESULT_UNSUPP_VERSION) {
463463 is_natpmp = true ;
0 commit comments