7#ifndef BOTAN_IPV6_ADDRESS_H_
8#define BOTAN_IPV6_ADDRESS_H_
10#include <botan/types.h>
27 explicit IPv6Address(std::span<const uint8_t, 16> ip);
29 explicit IPv6Address(std::array<uint8_t, 16> ip) : m_ip(ip) {}
31 static std::optional<IPv6Address> from_string(std::string_view str);
45 std::span<const uint8_t, 16>
address()
const {
return m_ip; }
55 std::optional<size_t> prefix_length()
const;
62 std::optional<IPv4Address> as_ipv4()
const;
65 std::array<uint8_t, 16> m_ip;
95 static std::optional<IPv6Subnet>
from_string(std::string_view str);
109 bool is_host()
const {
return m_prefix_length == 128; }
123 std::vector<uint8_t> serialize()
const;
129 uint8_t m_prefix_length;
#define BOTAN_PUBLIC_API(maj, min)
static IPv6Address host_mask()
auto operator<=>(const IPv6Address &) const =default
IPv6Address(std::span< const uint8_t, 16 > ip)
static IPv6Address netmask(size_t bits)
IPv6Address(std::array< uint8_t, 16 > ip)
std::span< const uint8_t, 16 > address() const
friend bool operator==(const IPv6Subnet &, const IPv6Subnet &)=default
size_t prefix_length() const
Prefix length in [0, 128].
static std::optional< IPv6Subnet > from_address_and_mask(std::span< const uint8_t, 32 > addr_and_mask)
const IPv6Address & address() const
The network address (host bits already zeroed).
static std::optional< IPv6Subnet > from_string(std::string_view str)
IPv6Subnet(IPv6Address address, size_t prefix_length)
bool is_host() const
True iff prefix_length() == 128.
static IPv6Subnet host(IPv6Address address)
std::string to_string(ErrorType type)
Convert an ErrorType to string.
ECIES_Flags operator&(ECIES_Flags a, ECIES_Flags b)