userver: userver/utils/ip.hpp File Reference
Loading...
Searching...
No Matches
ip.hpp File Reference

Detailed Description

IPv4 and IPv6 addresses and networks.

Definition in file ip.hpp.

Go to the source code of this file.

#include <array>
#include <cstddef>
#include <cstdint>
#include <exception>
#include <string>
#include <string_view>
#include <system_error>
#include <vector>
#include <sys/socket.h>
#include <fmt/format.h>
#include <userver/compiler/impl/lifetime.hpp>
#include <userver/utils/zstring_view.hpp>
This graph shows which files directly or indirectly include this file:

Classes

class  utils::ip::AddressBase< N >
 Base class for IPv4/IPv6 addresses. More...
class  utils::ip::NetworkBase< Address >
 Base class for IPv4/IPv6 network. More...
class  utils::ip::InetNetwork
 INET IPv4/IPv4 network. More...
class  utils::ip::AddressSystemError
 Invalid network or address. More...

Namespaces

namespace  utils
 General-purpose utilities used across userver libraries.
namespace  utils::ip
 IP address parsing, formatting, and related utilities.

Typedefs

using utils::ip::AddressV4 = AddressBase<4>
 IPv4 address in network bytes order.
using utils::ip::AddressV6 = AddressBase<16>
 IPv6 address in network bytes order.
using utils::ip::NetworkV4 = NetworkBase<AddressV4>
 IPv4 network.
using utils::ip::NetworkV6 = NetworkBase<AddressV6>
 IPv6 network.

Functions

AddressV4 utils::ip::AddressV4FromString (utils::zstring_view str)
 Create an IPv4 address from an IP address string in dotted decimal form.
AddressV6 utils::ip::AddressV6FromString (utils::zstring_view str)
 Create an IPv6 address from an IP address string in dotted decimal form.
std::string utils::ip::AddressV4ToString (const AddressV4 &address)
 Get the address as a string in dotted decimal format.
std::string utils::ip::AddressV6ToString (const AddressV6 &address)
 Get the address as a string in dotted decimal format.
NetworkV4 utils::ip::NetworkV4FromString (std::string_view str)
 Create an IPv4 network from a string containing IP address and prefix length.
NetworkV6 utils::ip::NetworkV6FromString (std::string_view str)
 Create an IPv6 network from a string containing IP address and prefix length.
std::string utils::ip::NetworkV4ToString (const NetworkV4 &network)
 Get the network as an address in dotted decimal format.
std::string utils::ip::NetworkV6ToString (const NetworkV6 &network)
 Get the network as an address in dotted decimal format.
NetworkV4 utils::ip::TransformToCidrFormat (NetworkV4 network)
 Convert NetworkV4 to CIDR format.
NetworkV6 utils::ip::TransformToCidrFormat (NetworkV6 network)
 Convert NetworkV4 to CIDR format.
NetworkV4 utils::ip::NetworkV4FromInetNetwork (const InetNetwork &inet_network)
 Convert InetNetwork to NetworkV4.
NetworkV6 utils::ip::NetworkV6FromInetNetwork (const InetNetwork &inet_network)
 Convert InetNetwork to NetworkV6.
InetNetwork utils::ip::NetworkV4ToInetNetwork (const NetworkV4 &network)
 Convert NetworkV4 to InetNetwork.
InetNetwork utils::ip::NetworkV6ToInetNetwork (const NetworkV6 &network)
 Convert NetworkV6 to InetNetwork.