folly/folly/IPAddress.cpp

/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <folly/IPAddress.h>

#include <limits>
#include <ostream>
#include <string>
#include <vector>

#include <fmt/core.h>

#include <folly/String.h>
#include <folly/detail/IPAddressSource.h>
#include <folly/small_vector.h>

ostream;
string;
vector;

namespace folly {

// free functions
size_t hash_value(const IPAddress& addr) {}
ostream& operator<<(ostream& os, const IPAddress& addr) {}
void toAppend(IPAddress addr, string* result) {}
void toAppend(IPAddress addr, fbstring* result) {}

bool IPAddress::validate(StringPiece ip) noexcept {}

// public static
IPAddressV4 IPAddress::createIPv4(const IPAddress& addr) {}

// public static
IPAddressV6 IPAddress::createIPv6(const IPAddress& addr) {}

namespace {

auto splitIpSlashCidr(StringPiece ipSlashCidr) {}

} // namespace

// public static
CIDRNetwork IPAddress::createNetwork(
    StringPiece ipSlashCidr,
    int defaultCidr, /* = -1 */
    bool applyMask /* = true */) {}

// public static
Expected<CIDRNetwork, CIDRNetworkError> IPAddress::tryCreateNetwork(
    StringPiece ipSlashCidr, int defaultCidr, bool applyMask) {}

// public static
std::string IPAddress::networkToString(const CIDRNetwork& network) {}

// public static
IPAddress IPAddress::fromBinary(ByteRange bytes) {}

Expected<IPAddress, IPAddressFormatError> IPAddress::tryFromBinary(
    ByteRange bytes) noexcept {}

// public static
IPAddress IPAddress::fromLong(uint32_t src) {}
IPAddress IPAddress::fromLongHBO(uint32_t src) {}

// default constructor
IPAddress::IPAddress() :{}

// public string constructor
IPAddress::IPAddress(StringPiece str) :{}

Expected<IPAddress, IPAddressFormatError> IPAddress::tryFromString(
    StringPiece str) noexcept {}

// public sockaddr constructor
IPAddress::IPAddress(const sockaddr* addr) :{}

folly::Expected<IPAddress, IPAddressFormatError> IPAddress::tryFromSockAddr(
    const sockaddr* addr) noexcept {}

// public ipv4 constructor
IPAddress::IPAddress(const IPAddressV4 ipV4Addr) noexcept
    :{}

// public ipv4 constructor
IPAddress::IPAddress(const in_addr ipV4Addr) noexcept
    :{}

// public ipv6 constructor
IPAddress::IPAddress(const IPAddressV6& ipV6Addr) noexcept
    :{}

// public ipv6 constructor
IPAddress::IPAddress(const in6_addr& ipV6Addr) noexcept
    :{}

// Assign from V4 address
IPAddress& IPAddress::operator=(const IPAddressV4& ipv4_addr) noexcept {}

// Assign from V6 address
IPAddress& IPAddress::operator=(const IPAddressV6& ipv6_addr) noexcept {}

// public
bool IPAddress::inSubnet(StringPiece cidrNetwork) const {}

// public
bool IPAddress::inSubnet(const IPAddress& subnet, uint8_t cidr) const {}

// public
bool IPAddress::inSubnetWithMask(
    const IPAddress& subnet, ByteRange mask) const {}

uint8_t IPAddress::getNthMSByte(size_t byteIndex) const {}

// public
bool operator==(const IPAddress& addr1, const IPAddress& addr2) {}

bool operator<(const IPAddress& addr1, const IPAddress& addr2) {}

CIDRNetwork IPAddress::longestCommonPrefix(
    const CIDRNetwork& one, const CIDRNetwork& two) {}

// clang-format off
[[noreturn]] void IPAddress::asV4Throw() const {}

[[noreturn]] void IPAddress::asV6Throw() const {}
// clang-format on

} // namespace folly