chromium/third_party/webrtc/rtc_base/ip_address.cc

/*
 *  Copyright 2004 The WebRTC Project Authors. All rights reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#if defined(WEBRTC_POSIX)
#include <netinet/in.h>
#include <sys/socket.h>

#include "absl/strings/string_view.h"
#ifdef OPENBSD
#include <netinet/in_systm.h>
#endif
#ifndef __native_client__
#include <netinet/ip.h>
#endif
#include <netdb.h>
#endif

#include "rtc_base/byte_order.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/net_helpers.h"
#include "rtc_base/string_utils.h"

#if defined(WEBRTC_WIN)
#include "rtc_base/win32.h"
#endif  // WEBRTC_WIN

namespace rtc {

// Prefixes used for categorizing IPv6 addresses.
static const in6_addr kV4MappedPrefix =;
static const in6_addr k6To4Prefix =;
static const in6_addr kTeredoPrefix =;
static const in6_addr kV4CompatibilityPrefix =;
static const in6_addr k6BonePrefix =;
static const in6_addr kPrivateNetworkPrefix =;

static bool IPIsHelper(const IPAddress& ip,
                       const in6_addr& tomatch,
                       int length);
static in_addr ExtractMappedAddress(const in6_addr& addr);

uint32_t IPAddress::v4AddressAsHostOrderInteger() const {}

int IPAddress::overhead() const {}

bool IPAddress::IsNil() const {}

size_t IPAddress::Size() const {}

bool IPAddress::operator==(const IPAddress& other) const {}

bool IPAddress::operator!=(const IPAddress& other) const {}

bool IPAddress::operator>(const IPAddress& other) const {}

bool IPAddress::operator<(const IPAddress& other) const {}

in6_addr IPAddress::ipv6_address() const {}

in_addr IPAddress::ipv4_address() const {}

std::string IPAddress::ToString() const {}

std::string IPAddress::ToSensitiveString() const {}

IPAddress IPAddress::Normalized() const {}

IPAddress IPAddress::AsIPv6Address() const {}

bool InterfaceAddress::operator==(const InterfaceAddress& other) const {}

bool InterfaceAddress::operator!=(const InterfaceAddress& other) const {}

const InterfaceAddress& InterfaceAddress::operator=(
    const InterfaceAddress& other) {}

std::string InterfaceAddress::ToString() const {}

static bool IPIsPrivateNetworkV4(const IPAddress& ip) {}

static bool IPIsPrivateNetworkV6(const IPAddress& ip) {}

bool IPIsPrivateNetwork(const IPAddress& ip) {}

static bool IPIsSharedNetworkV4(const IPAddress& ip) {}

bool IPIsSharedNetwork(const IPAddress& ip) {}

in_addr ExtractMappedAddress(const in6_addr& in6) {}

bool IPFromAddrInfo(struct addrinfo* info, IPAddress* out) {}

bool IPFromString(absl::string_view str, IPAddress* out) {}

bool IPFromString(absl::string_view str, int flags, InterfaceAddress* out) {}

bool IPIsAny(const IPAddress& ip) {}

static bool IPIsLoopbackV4(const IPAddress& ip) {}

static bool IPIsLoopbackV6(const IPAddress& ip) {}

bool IPIsLoopback(const IPAddress& ip) {}

bool IPIsPrivate(const IPAddress& ip) {}

bool IPIsUnspec(const IPAddress& ip) {}

size_t HashIP(const IPAddress& ip) {}

IPAddress TruncateIP(const IPAddress& ip, int length) {}

int CountIPMaskBits(const IPAddress& mask) {}

bool IPIsHelper(const IPAddress& ip, const in6_addr& tomatch, int length) {}

bool IPIs6Bone(const IPAddress& ip) {}

bool IPIs6To4(const IPAddress& ip) {}

static bool IPIsLinkLocalV4(const IPAddress& ip) {}

static bool IPIsLinkLocalV6(const IPAddress& ip) {}

bool IPIsLinkLocal(const IPAddress& ip) {}

// According to http://www.ietf.org/rfc/rfc2373.txt, Appendix A, page 19.  An
// address which contains MAC will have its 11th and 12th bytes as FF:FE as well
// as the U/L bit as 1.
bool IPIsMacBased(const IPAddress& ip) {}

bool IPIsSiteLocal(const IPAddress& ip) {}

bool IPIsULA(const IPAddress& ip) {}

bool IPIsTeredo(const IPAddress& ip) {}

bool IPIsV4Compatibility(const IPAddress& ip) {}

bool IPIsV4Mapped(const IPAddress& ip) {}

int IPAddressPrecedence(const IPAddress& ip) {}

IPAddress GetLoopbackIP(int family) {}

IPAddress GetAnyIP(int family) {}

}  // namespace rtc