LLFIO v2.00
Loading...
Searching...
No Matches
llfio_v2_xxx::ip::address Class Reference

A version independent IP address. More...

#include "byte_socket_handle.hpp"

Inheritance diagram for llfio_v2_xxx::ip::address:
llfio_v2_xxx::ip::address_v4 llfio_v2_xxx::ip::address_v6

Public Member Functions

 address (const sockaddr_in &storage) noexcept
 
 address (const sockaddr_in6 &storage) noexcept
 
 address (const address &)=default
 
 address (address &&)=default
 
addressoperator= (const address &)=default
 
addressoperator= (address &&)=default
 
bool operator== (const address &o) const noexcept
 True if addresses are equal.
 
bool operator!= (const address &o) const noexcept
 True if addresses are not equal.
 
bool operator< (const address &o) const noexcept
 True if address is less than.
 
bool is_loopback () const noexcept
 True if address is loopback.
 
bool is_multicast () const noexcept
 True if address is multicast.
 
bool is_any () const noexcept
 True if address is any.
 
bool is_default () const noexcept
 True if address is default constructed.
 
bool is_v4 () const noexcept
 True if address is v4.
 
bool is_v6 () const noexcept
 True if address is v6.
 
unsigned short raw_family () const noexcept
 Returns the raw family of the address.
 
enum family family () const noexcept
 Returns the family of the addres.
 
uint16_t port () const noexcept
 Returns the port of the address.
 
uint32_t flowinfo () const noexcept
 Returns the IPv6 flow info, if address is v6.
 
uint32_t scope_id () const noexcept
 Returns the IPv6 scope id, if address is v6.
 
span< const byte > to_bytes () const noexcept
 Returns the bytes of the address in network order.
 
const sockaddr * to_sockaddr () const noexcept
 Returns the address as a sockaddr *.
 
int sockaddrlen () const noexcept
 Returns the size of the sockaddr
 

Protected Attributes

union { 
 
   struct { 
 
      unsigned short   _family 
 
      uint16_t   _port 
 
      union { 
 
         struct { 
 
            uint32_t   _flowinfo 
 
            byte   _addr [16] 
 
            uint32_t   _scope_id 
 
         }   ipv6 
 
         union { 
 
            byte   _addr [4] 
 
            uint32_t   _addr_be 
 
         }   ipv4 
 
      }  
 
   }  
 
   byte   _storage [32] 
 
};  
 

Friends

class llfio_v2_xxx::byte_socket_handle
 
class llfio_v2_xxx::listening_byte_socket_handle
 
std::ostream & operator<< (std::ostream &s, const address &v)
 Write address to stream.
 

Detailed Description

A version independent IP address.

Warning
This is deprecated and scheduled for removal in 2025.

This is inspired by asio::ip::address, but it also adds port() from asio::ip::endpoint and a few other observer member functions i.e. it fuses ASIO's many types into one.

The reason why is that this type is a simple wrap of struct sockaddr_in or struct sockaddr_in6, it doesn't split those structures into multiple C++ types.

Constructor & Destructor Documentation

◆ address()

constexpr llfio_v2_xxx::ip::address::address ( )
inlineconstexprnoexcept
130 : _storage{to_byte(0), to_byte(0), to_byte(0), to_byte(0), to_byte(0), to_byte(0), to_byte(0), to_byte(0), to_byte(0), to_byte(0), to_byte(0),
131 to_byte(0), to_byte(0), to_byte(0), to_byte(0), to_byte(0), to_byte(0), to_byte(0), to_byte(0), to_byte(0), to_byte(0), to_byte(0),
132 to_byte(0), to_byte(0), to_byte(0), to_byte(0), to_byte(0), to_byte(0), to_byte(0), to_byte(0), to_byte(0), to_byte(0)}
133 {
134 }

Member Function Documentation

◆ is_default()

bool llfio_v2_xxx::ip::address::is_default ( ) const
inlinenoexcept

True if address is default constructed.

157{ return _family == 0; }

◆ operator!=()

bool llfio_v2_xxx::ip::address::operator!= ( const address o) const
inlinenoexcept

True if addresses are not equal.

146{ return 0 != memcmp(_storage, o._storage, sizeof(_storage)); }

◆ operator<()

bool llfio_v2_xxx::ip::address::operator< ( const address o) const
inlinenoexcept

True if address is less than.

148{ return memcmp(_storage, o._storage, sizeof(_storage)) < 0; }

◆ operator==()

bool llfio_v2_xxx::ip::address::operator== ( const address o) const
inlinenoexcept

True if addresses are equal.

144{ return 0 == memcmp(_storage, o._storage, sizeof(_storage)); }

◆ to_bytes()

span< const byte > llfio_v2_xxx::ip::address::to_bytes ( ) const
inlinenoexcept

Returns the bytes of the address in network order.

175{ return is_v6() ? span<const byte>(ipv6._addr) : span<const byte>(ipv4._addr); }
bool is_v6() const noexcept
True if address is v6.

◆ to_sockaddr()

const sockaddr * llfio_v2_xxx::ip::address::to_sockaddr ( ) const
inlinenoexcept

Returns the address as a sockaddr *.

177{ return (const sockaddr *) _storage; }

The documentation for this class was generated from the following file: