|
Botan 3.13.0
Crypto and TLS for C&
|
#include <ipv6_address.h>
Public Member Functions | |
| std::array< uint8_t, 16 > | address () const |
| std::optional< IPv4Address > | as_ipv4 () const |
| IPv6Address (std::array< uint8_t, 16 > ip) | |
| IPv6Address (std::span< const uint8_t, 16 > ip) | |
| IPv6Address | operator& (const IPv6Address &other) const |
| auto | operator<=> (const IPv6Address &) const =default |
| std::optional< size_t > | prefix_length () const |
| std::string | to_string () const |
Static Public Member Functions | |
| static std::optional< IPv6Address > | from_string (std::string_view str) |
| static IPv6Address | host_mask () |
| static IPv6Address | netmask (size_t bits) |
IPv6 Address
Definition at line 25 of file ipv6_address.h.
|
explicit |
Create an address from its 16 byte big-endian encoding
| ip | the bytes of the address |
Definition at line 17 of file ipv6_address.cpp.
Referenced by host_mask(), netmask(), operator&(), and operator<=>().
|
inlineexplicit |
Create an address from its 16 byte big-endian encoding
| ip | the bytes of the address |
Definition at line 37 of file ipv6_address.h.
|
inline |
Access the raw bytes of the address
Definition at line 79 of file ipv6_address.h.
Referenced by Botan::IPv6Subnet::serialize().
| std::optional< IPv4Address > Botan::IPv6Address::as_ipv4 | ( | ) | const |
If this IPv6 address is an IPv4-compatible IPv6 address (RFC 4291 2.5.5.1) or an IPv4-mapped IPv6 address (RFC 4291 2.5.5.2), return the embedded IPv4 address.
Definition at line 283 of file ipv6_address.cpp.
References as_ipv4(), and Botan::load_be().
Referenced by as_ipv4().
|
static |
Convert a string representation of an IPv6 address to IPv6Address.
Accepts the full form (eight colon-separated hex groups), the "::"-compressed form (exactly one run of zero groups elided), and combinations such as "2001:db8::1". The final 32 bits may be given in IPv4 dotted-decimal form (e.g. "::ffff:192.0.2.1"). Surrounding brackets and zone identifiers are not accepted.
Definition at line 24 of file ipv6_address.cpp.
Referenced by Botan::IPv6Subnet::from_string(), Botan::URI::Authority::from_string(), Botan::TLS::Server_Name_Indicator::hostname_acceptable_for_sni(), and Botan::X509_Certificate::matches_dns_name().
|
inlinestatic |
Return the netmask matching a single host
Definition at line 60 of file ipv6_address.h.
References IPv6Address(), and netmask().
|
static |
Return an address with the leading bits set to one and the remainder zero. Throws Invalid_Argument if bits > 128.
Definition at line 169 of file ipv6_address.cpp.
References BOTAN_ARG_CHECK, IPv6Address(), and netmask().
Referenced by Botan::IPv6Subnet::contains(), Botan::GeneralName::encode_into(), host_mask(), netmask(), prefix_length(), and Botan::IPv6Subnet::serialize().
| IPv6Address Botan::IPv6Address::operator& | ( | const IPv6Address & | other | ) | const |
Bitwise AND of two addresses, typically used to apply a netmask
| other | the address to AND with |
Definition at line 257 of file ipv6_address.cpp.
References IPv6Address(), and operator&().
Referenced by operator&().
|
default |
Order two addresses numerically
References IPv6Address().
| std::optional< size_t > Botan::IPv6Address::prefix_length | ( | ) | const |
If this value is a netmask consisting of a run of one bits followed by a run of zero bits, return the number of one bits.
Otherwise return nullopt.
Definition at line 265 of file ipv6_address.cpp.
References netmask(), and prefix_length().
Referenced by prefix_length().
| std::string Botan::IPv6Address::to_string | ( | ) | const |
Convert an IPv6 address to the RFC 5952 canonical text form: lowercase hex, leading zeros within a group suppressed, and the longest run of two or more zero groups compressed to "::". The mixed hex/dotted notation is never produced, even for IPv4-mapped addresses.
Definition at line 187 of file ipv6_address.cpp.
References Botan::make_uint16(), and to_string().
Referenced by to_string().