/* inetpton(af, src, dst)
**
** This is a wrapper for inet_pton(), so we can use ipv4 addresses with an
** af of AF_INET6, and that it gets converted to ipv4 mapped ipv6.
**
** (c) 2000 Kurt Roeckx <q@ping.be>, Licensed under GNU GPL v2.
*/
int inetpton(int af, const char *src, void *dst)
{
int i;
/* an empty string should listen to all */
if (af == AF_INET6 && *src && !strchr(src, ':'))
{
i = inet_pton(AF_INET, src, dst);
/* ugly hack */
memcpy(dst + 12, dst, 4);
memset(dst, 0, 10);
memset(dst + 10, 0xff, 2);
return i;
}
return inet_pton(af, src, dst);
}