MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / QueryDefaultGateway

Function QueryDefaultGateway

src/common/netif.cpp:296–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294}
295
296std::optional<CNetAddr> QueryDefaultGateway(Network network)
297{
298 Assume(network == NET_IPV4 || network == NET_IPV6);
299
300 sa_family_t family;
301 if (network == NET_IPV4) {
302 family = AF_INET;
303 } else if(network == NET_IPV6) {
304 family = AF_INET6;
305 } else {
306 return std::nullopt;
307 }
308
309 std::optional<CNetAddr> ret = QueryDefaultGatewayImpl(family);
310
311 // It's possible for the default gateway to be 0.0.0.0 or ::0 on at least Windows
312 // for some routing strategies. If so, return as if no default gateway was found.
313 if (ret && !ret->IsBindAny()) {
314 return ret;
315 } else {
316 return std::nullopt;
317 }
318}
319
320std::vector<CNetAddr> GetLocalAddresses()
321{

Callers 1

ProcessPCPFunction · 0.85

Calls 2

QueryDefaultGatewayImplFunction · 0.85
IsBindAnyMethod · 0.80

Tested by

no test coverage detected