+
+/**
+ * inet_pton() replacement
+ */
+int vlc_inet_pton (int af, const char *src, void *dst)
+{
+#ifndef HAVE_INET_PTON
+ /* Windows Vista has inet_pton(), but not XP. */
+ /* We have a pretty good example of abstraction inversion here... */
+ struct addrinfo hints = {
+ .ai_family = af,
+ .ai_socktype = SOCK_DGRAM, /* make sure we have... */
+ .ai_protocol = IPPROTO_UDP, /* ...only one response */
+ .ai_flags = AI_NUMERICHOST,
+ }, *res;
+
+ if (getaddrinfo (src, NULL, &hints, &res))
+ return 0;
+
+ const void *data;
+ size_t len;
+
+ switch (af)
+ {
+ case AF_INET:
+ data = &((const struct sockaddr_in *)res->ai_addr)->sin_addr;
+ len = sizeof (struct in_addr);
+ break;
+#ifdef AF_INET6
+ case AF_INET6:
+ data = &((const struct sockaddr_in6 *)res->ai_addr)->sin6_addr;
+ len = sizeof (struct in6_addr);
+ break;