Skip to content

Commit

Permalink
sa: fix build for old systems
Browse files Browse the repository at this point in the history
On some old systems getaddrinfo() is not available.
  • Loading branch information
cspiel1 committed Jul 2, 2021
1 parent 4915d6f commit 5510761
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/sa/sa.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ int sa_set(struct sa *sa, const struct pl *addr, uint16_t port)

int sa_addrinfo(const char *addr, struct sa *sa)
{
#ifdef AI_ADDRCONFIG
struct addrinfo *res, *res0 = NULL;
struct addrinfo hints;
int err = 0;
Expand All @@ -85,6 +86,9 @@ int sa_addrinfo(const char *addr, struct sa *sa)

freeaddrinfo(res0);
return err;
#else
return ENOTSUP;
#endif
}


Expand All @@ -107,9 +111,11 @@ int sa_pton(const char *addr, struct sa *sa)
sa->u.in.sin_family = AF_INET;
}
#ifdef HAVE_INET6
#ifdef AI_ADDRCONFIG
else if (!strncmp(addr, "fe80:", 5)) {
err = sa_addrinfo(addr, sa);
}
#endif
else if (inet_pton(AF_INET6, addr, &sa->u.in6.sin6_addr) > 0) {

if (IN6_IS_ADDR_V4MAPPED(&sa->u.in6.sin6_addr)) {
Expand Down

0 comments on commit 5510761

Please sign in to comment.