| 396 | } |
| 397 | |
| 398 | bool CNetAddr::IsLocal() const |
| 399 | { |
| 400 | // IPv4 loopback (127.0.0.0/8 or 0.0.0.0/8) |
| 401 | if (IsIPv4() && (m_addr[0] == 127 || m_addr[0] == 0)) { |
| 402 | return true; |
| 403 | } |
| 404 | |
| 405 | // IPv6 loopback (::1/128) |
| 406 | static const unsigned char pchLocal[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}; |
| 407 | if (IsIPv6() && memcmp(m_addr.data(), pchLocal, sizeof(pchLocal)) == 0) { |
| 408 | return true; |
| 409 | } |
| 410 | |
| 411 | return false; |
| 412 | } |
| 413 | |
| 414 | /** |
| 415 | * @returns Whether or not this network address is a valid address that @a could |