|
Botan 3.12.0
Crypto and TLS for C&
|
#include <ipv6_address.h>
Public Member Functions | |
| const IPv6Address & | address () const |
| The network address (host bits already zeroed). | |
| bool | contains (const IPv6Address &ip) const |
True iff ip falls within this subnet. | |
| IPv6Subnet (IPv6Address address, size_t prefix_length) | |
| bool | is_host () const |
| True iff prefix_length() == 128. | |
| size_t | prefix_length () const |
| Prefix length in [0, 128]. | |
| std::vector< uint8_t > | serialize () const |
| std::string | to_string () const |
| CIDR-style "2001:db8::/32". | |
Static Public Member Functions | |
| static std::optional< IPv6Subnet > | from_address_and_mask (std::span< const uint8_t, 32 > addr_and_mask) |
| static std::optional< IPv6Subnet > | from_string (std::string_view str) |
| static IPv6Subnet | host (IPv6Address address) |
Friends | |
| bool | operator== (const IPv6Subnet &, const IPv6Subnet &)=default |
An IPv6 subnet in CIDR form: a network address paired with a prefix length
Definition at line 71 of file ipv6_address.h.
| Botan::IPv6Subnet::IPv6Subnet | ( | IPv6Address | address, |
| size_t | prefix_length ) |
Construct from a network address and a prefix length in [0, 128]. Host bits of address are cleared.
Throws Invalid_Argument if prefix_length > 128.
Definition at line 94 of file ipv6_address.cpp.
References address(), and prefix_length().
Referenced by from_address_and_mask(), from_string(), host(), and operator==.
|
inline |
The network address (host bits already zeroed).
Definition at line 103 of file ipv6_address.h.
Referenced by host(), and IPv6Subnet().
| bool Botan::IPv6Subnet::contains | ( | const IPv6Address & | ip | ) | const |
True iff ip falls within this subnet.
Definition at line 143 of file ipv6_address.cpp.
References Botan::IPv6Address::netmask().
|
static |
Construct from a network address and a 16-byte CIDR netmask. Returns nullopt if netmask is not a valid contiguous CIDR prefix.
Definition at line 101 of file ipv6_address.cpp.
References IPv6Subnet().
Referenced by Botan::GeneralName::decode_from().
|
static |
Parse the CIDR-style form "2001:db8::/32".
The "/N" suffix is required: bare addresses should be parsed via IPv6Address::from_string and wrapped with IPv6Subnet::host if needed.
Returns nullopt on parse failure or out-of-range prefix length.
Definition at line 113 of file ipv6_address.cpp.
References Botan::IPv6Address::from_string(), and IPv6Subnet().
|
inlinestatic |
A single-host subnet (prefix length 128) covering exactly address.
Definition at line 100 of file ipv6_address.h.
References address(), and IPv6Subnet().
Referenced by Botan::GeneralName::ipv6_address().
|
inline |
True iff prefix_length() == 128.
Definition at line 109 of file ipv6_address.h.
Referenced by serialize().
|
inline |
Prefix length in [0, 128].
Definition at line 106 of file ipv6_address.h.
Referenced by IPv6Subnet().
| std::vector< uint8_t > Botan::IPv6Subnet::serialize | ( | ) | const |
Bytes for use in a DER-encoded GeneralName iPAddress field:
Definition at line 151 of file ipv6_address.cpp.
References Botan::IPv6Address::address(), is_host(), and Botan::IPv6Address::netmask().
| std::string Botan::IPv6Subnet::to_string | ( | ) | const |
CIDR-style "2001:db8::/32".
Definition at line 147 of file ipv6_address.cpp.
References Botan::fmt().
|
friend |
References IPv6Subnet().