#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/feedback/redaction_tool/ip_address.h"
#include <algorithm>
#include <climits>
#include <string_view>
#include "base/check_op.h"
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "base/strings/strcat.h"
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
#include "base/trace_event/memory_usage_estimator.h"
#include "base/values.h"
#include "components/feedback/redaction_tool/url_canon_ip.h"
#include "components/feedback/redaction_tool/url_canon_stdstring.h"
#include "third_party/abseil-cpp/absl/container/inlined_vector.h"
namespace redaction_internal {
namespace {
constexpr uint8_t kIPv4MappedPrefix[] = …;
bool IPAddressPrefixCheck(const IPAddressBytes& ip_address,
const uint8_t* ip_prefix,
size_t prefix_length_in_bits) { … }
bool ParseIPLiteralToBytes(std::string_view ip_literal, IPAddressBytes* bytes) { … }
}
IPAddressBytes::IPAddressBytes() : … { … }
IPAddressBytes::IPAddressBytes(const uint8_t* data, size_t data_len) { … }
IPAddressBytes::~IPAddressBytes() = default;
IPAddressBytes::IPAddressBytes(IPAddressBytes const& other) = default;
void IPAddressBytes::Assign(const uint8_t* data, size_t data_len) { … }
bool IPAddressBytes::operator<(const IPAddressBytes& other) const { … }
bool IPAddressBytes::operator==(const IPAddressBytes& other) const { … }
bool IPAddressBytes::operator!=(const IPAddressBytes& other) const { … }
IPAddress::IPAddress() = default;
IPAddress::IPAddress(const IPAddress& other) = default;
IPAddress::IPAddress(const IPAddressBytes& address) : … { … }
IPAddress::IPAddress(const uint8_t* address, size_t address_len)
: … { … }
IPAddress::IPAddress(uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3) { … }
IPAddress::IPAddress(uint8_t b0,
uint8_t b1,
uint8_t b2,
uint8_t b3,
uint8_t b4,
uint8_t b5,
uint8_t b6,
uint8_t b7,
uint8_t b8,
uint8_t b9,
uint8_t b10,
uint8_t b11,
uint8_t b12,
uint8_t b13,
uint8_t b14,
uint8_t b15) { … }
IPAddress::~IPAddress() = default;
bool IPAddress::IsIPv4() const { … }
bool IPAddress::IsIPv6() const { … }
bool IPAddress::IsValid() const { … }
bool IPAddress::IsIPv4MappedIPv6() const { … }
bool IPAddress::AssignFromIPLiteral(std::string_view ip_literal) { … }
IPAddress IPAddress::AllZeros(size_t num_zero_bytes) { … }
IPAddress IPAddress::IPv4AllZeros() { … }
IPAddress IPAddress::IPv6AllZeros() { … }
bool IPAddress::operator==(const IPAddress& that) const { … }
bool IPAddress::operator!=(const IPAddress& that) const { … }
bool IPAddress::operator<(const IPAddress& that) const { … }
std::string IPAddress::ToString() const { … }
IPAddress ConvertIPv4ToIPv4MappedIPv6(const IPAddress& address) { … }
IPAddress ConvertIPv4MappedIPv6ToIPv4(const IPAddress& address) { … }
bool IPAddressMatchesPrefix(const IPAddress& ip_address,
const IPAddress& ip_prefix,
size_t prefix_length_in_bits) { … }
}