folly/folly/SocketAddress.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.
 */

#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif

#include <folly/SocketAddress.h>

#include <cassert>
#include <cerrno>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <string>
#include <system_error>
#include <type_traits>

#include <boost/functional/hash.hpp>

#include <fmt/core.h>

#include <folly/Exception.h>
#include <folly/hash/Hash.h>
#include <folly/net/NetOps.h>
#include <folly/net/NetworkSocket.h>

namespace {

/**
 * A structure to free a struct addrinfo when it goes out of scope.
 */
struct ScopedAddrInfo {};

/**
 * A simple data structure for parsing a host-and-port string.
 *
 * Accepts a string of the form "<host>:<port>" or just "<port>",
 * and contains two string pointers to the host and the port portion of the
 * string.
 *
 * The HostAndPort may contain pointers into the original string.  It is
 * responsible for the user to ensure that the input string is valid for the
 * lifetime of the HostAndPort structure.
 */
struct HostAndPort {};

struct GetAddrInfoError {};

} // namespace

namespace folly {

bool SocketAddress::isPrivateAddress() const {}

bool SocketAddress::isLoopbackAddress() const {}

void SocketAddress::setFromHostPort(const char* host, uint16_t port) {}

void SocketAddress::setFromIpPort(const char* ip, uint16_t port) {}

void SocketAddress::setFromIpAddrPort(const IPAddress& ipAddr, uint16_t port) {}

void SocketAddress::setFromLocalPort(uint16_t port) {}

void SocketAddress::setFromLocalPort(const char* port) {}

void SocketAddress::setFromLocalIpPort(const char* addressAndPort) {}

void SocketAddress::setFromIpPort(const char* addressAndPort) {}

void SocketAddress::setFromHostPort(const char* hostAndPort) {}

int SocketAddress::getPortFrom(const struct sockaddr* address) {}

const char* SocketAddress::getFamilyNameFrom(
    const struct sockaddr* address, const char* defaultResult) {}

void SocketAddress::setFromPath(StringPiece path) {}

void SocketAddress::setFromPeerAddress(NetworkSocket socket) {}

void SocketAddress::setFromLocalAddress(NetworkSocket socket) {}

void SocketAddress::setFromSockaddr(const struct sockaddr* address) {}

void SocketAddress::setFromSockaddr(
    const struct sockaddr* address, socklen_t addrlen) {}

void SocketAddress::setFromSockaddr(const struct sockaddr_in* address) {}

void SocketAddress::setFromSockaddr(const struct sockaddr_in6* address) {}

void SocketAddress::setFromSockaddr(
    const struct sockaddr_un* address, socklen_t addrlen) {}

const folly::IPAddress& SocketAddress::getIPAddress() const {}

socklen_t SocketAddress::getActualSize() const {}

std::string SocketAddress::getFullyQualified() const {}

std::string SocketAddress::getAddressStr() const {}

bool SocketAddress::isFamilyInet() const {}

void SocketAddress::getAddressStr(char* buf, size_t buflen) const {}

uint16_t SocketAddress::getPort() const {}

void SocketAddress::setPort(uint16_t port) {}

void SocketAddress::convertToIPv4() {}

bool SocketAddress::tryConvertToIPv4() {}

bool SocketAddress::mapToIPv6() {}

std::string SocketAddress::getHostStr() const {}

std::string SocketAddress::getPath() const {}

std::string SocketAddress::describe() const {}

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

bool SocketAddress::prefixMatch(
    const SocketAddress& other, unsigned prefixLength) const {}

size_t SocketAddress::hash() const {}

struct addrinfo* SocketAddress::getAddrInfo(
    const char* host, uint16_t port, int flags) {}

struct addrinfo* SocketAddress::getAddrInfo(
    const char* host, const char* port, int flags) {}

void SocketAddress::setFromAddrInfo(const struct addrinfo* info) {}

void SocketAddress::setFromLocalAddr(const struct addrinfo* info) {}

void SocketAddress::setFromSocket(
    NetworkSocket socket,
    int (*fn)(NetworkSocket, struct sockaddr*, socklen_t*)) {}

std::string SocketAddress::getIpString(int flags) const {}

void SocketAddress::getIpString(char* buf, size_t buflen, int flags) const {}

void SocketAddress::updateUnixAddressLength(socklen_t addrlen) {}

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

size_t hash_value(const SocketAddress& address) {}

std::ostream& operator<<(std::ostream& os, const SocketAddress& addr) {}

} // namespace folly