int use_ident, use_dns, timeout;
socklen_t llen, rlen;
struct iovec dat[3];
+ int gairesult;
if (argc < 2) {
fprintf(stderr, "info_slave needs a port number!\n");
continue;
bp = buf;
- if (getnameinfo(&remote.addr, rlen, host, sizeof host, NULL, 0,
- NI_NUMERICHOST | NI_NUMERICSERV) != 0) {
+ if ((gairesult = getnameinfo(&remote.addr, rlen, host, sizeof host, NULL,
+ 0, NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {
safe_str("Error: getnameinfo(remote): ", buf, &bp);
- safe_str(strerror(errno), buf, &bp);
+ if (gairesult == EAI_SYSTEM)
+ safe_str(strerror(errno), buf, &bp);
+ else
+ safe_str(gai_strerror(gairesult), buf, &bp);
} else {
safe_str(host, buf, &bp);
}
safe_chr('^', buf, &bp);
- if (getnameinfo(&local.addr, llen, NULL, 0, lport, sizeof lport,
- NI_NUMERICHOST | NI_NUMERICSERV) != 0) {
+ if ((gairesult = getnameinfo(&local.addr, llen, NULL, 0, lport,
+ sizeof lport,
+ NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {
safe_str("Error: getnameinfo(local): ", buf, &bp);
- safe_str(strerror(errno), buf, &bp);
+ if (gairesult == EAI_SYSTEM)
+ safe_str(strerror(errno), buf, &bp);
+ else
+ safe_str(gai_strerror(gairesult), buf, &bp);
} else {
safe_str(lport, buf, &bp);
}
ident_free(ident_result);
}
if (use_dns) {
- if (getnameinfo(&remote.addr, rlen, host, sizeof host, NULL, 0,
- NI_NUMERICSERV) != 0) {
+ if ((gairesult = getnameinfo(&remote.addr, rlen, host, sizeof host, NULL,
+ 0, NI_NUMERICSERV) != 0)) {
safe_str("Error: getnameinfo(local/dns): ", buf, &bp);
- safe_str(strerror(errno), buf, &bp);
+ if (gairesult == EAI_SYSTEM)
+ safe_str(strerror(errno), buf, &bp);
+ else
+ safe_str(gai_strerror(gairesult), buf, &bp);
} else {
safe_str(host, buf, &bp);
}