+static int fio_fill_addr(struct thread_data *td, const char *host, int af,
+ void *dst, struct addrinfo **res)
+{
+ struct netio_options *o = td->eo;
+ struct addrinfo hints;
+ int ret;
+
+ if (inet_pton(af, host, dst))
+ return 0;
+
+ memset(&hints, 0, sizeof(hints));
+
+ if (is_tcp(o))
+ hints.ai_socktype = SOCK_STREAM;
+ else
+ hints.ai_socktype = SOCK_DGRAM;
+
+ if (is_ipv6(o))
+ hints.ai_family = AF_INET6;
+ else
+ hints.ai_family = AF_INET;
+
+ ret = getaddrinfo(host, NULL, &hints, res);
+ if (ret) {
+ int e = EINVAL;
+ char str[128];
+
+ if (ret == EAI_SYSTEM)
+ e = errno;
+
+ snprintf(str, sizeof(str), "getaddrinfo: %s", gai_strerror(ret));
+ td_verror(td, e, str);
+ return 1;
+ }
+
+ return 0;
+}
+