userver: utils::ip Namespace Reference
Loading...
Searching...
No Matches
utils::ip Namespace Reference

Detailed Description

IP address and utilities.

Classes

class  AddressBase
 Base class for IPv4/IPv6 addresses. More...
 
class  AddressSystemError
 Invalid network or address. More...
 
class  InetNetwork
 INET IPv4/IPv4 network. More...
 
class  NetworkBase
 Base class for IPv4/IPv6 network. More...
 

Typedefs

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

Functions

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

Variables

template<typename T >
constexpr bool kIsAddressType = std::is_same_v<T, AddressV4> || std::is_same_v<T, AddressV6>
 

Function Documentation

◆ AddressV4FromString()

AddressV4 utils::ip::AddressV4FromString ( utils::zstring_view  str)

Create an IPv4 address from an IP address string in dotted decimal form.

Exceptions
AddressSystemError

◆ NetworkV4FromString()

NetworkV4 utils::ip::NetworkV4FromString ( const std::string &  str)

Create an IPv4 network from a string containing IP address and prefix length.

Exceptions
std::invalid_argument,AddressSystemError

Variable Documentation

◆ kIsAddressType

template<typename T >
constexpr bool utils::ip::kIsAddressType = std::is_same_v<T, AddressV4> || std::is_same_v<T, AddressV6>
inlineconstexpr

Definition at line 64 of file ip.hpp.