I wanted to know how I can parse an IPv6 address in C and convert it to a 128 bit value?
So a hex address like 1:22:333:aaaa:b:c:d:e
needs to be convert
if you can use boost, something like this should work:
#include
using boost::asio::ip;
bool parseIpv6String(std::string ipv6_string, char* dest){
try{
address_v6 addr = address_v6::from_string(ipv6_string);
memcpy(dest,addr.to_bytes().data(), 16);
}catch(...){
return false;
}
return true;
}
It is a bit more portable than for example POSIX specific functions.