class Inet6
|
{
|
char m_buffer[IN6_ADDR_SIZE];
|
bool str_to_ipv6(const char *str, size_t str_length, CHARSET_INFO *cs);
|
public:
|
// Initialize from a text representation
|
Inet6(bool *error, const char *str, size_t length, CHARSET_INFO *cs)
|
{
|
*error= !str_to_ipv6(str, length, cs);
|
}
|
// Initialize from a binary representation
|
Inet6(bool *error, const char *str, size_t length)
|
{
|
if (!(*error= length != sizeof(m_buffer)))
|
memcpy(m_buffer, str, length);
|
}
|
Inet6(bool *error, Item *item);
|
bool to_binary(String *to) const
|
{
|
return to->copy(m_buffer, sizeof(m_buffer), &my_charset_bin);
|
}
|
size_t to_string(char *dst, size_t dstsize) const;
|
bool to_string(String *to) const
|
{
|
to->set_charset(&my_charset_latin1);
|
if (to->alloc(INET6_ADDRSTRLEN))
|
return true;
|
to->length((uint32) to_string((char*) to->ptr(), INET6_ADDRSTRLEN));
|
return false;
|
}
|
bool is_v4compat() const
|
{
|
static_assert(sizeof(in6_addr) == IN6_ADDR_SIZE, "unexpected in6_addr size");
|
return IN6_IS_ADDR_V4COMPAT((struct in6_addr *) m_buffer);
|
}
|
bool is_v4mapped() const
|
{
|
static_assert(sizeof(in6_addr) == IN6_ADDR_SIZE, "unexpected in6_addr size");
|
return IN6_IS_ADDR_V4MAPPED((struct in6_addr *) m_buffer);
|
}
|
};
|