utils.c: Remove all usages of ast_gethostbyname()

gethostbyname() and gethostbyname_r() are deprecated in favor of
getaddrinfo() which we use in the ast_sockaddr family of functions.

ASTERISK-29819 #close

Change-Id: Ie277c0ef768d753b169c121ef570a71665692ab7
This commit is contained in:
Sean Bright
2021-12-24 11:26:31 -05:00
committed by Kevin Harwell
parent 54f2f1e027
commit 0bbef4d8c5
7 changed files with 85 additions and 70 deletions

View File

@@ -6847,8 +6847,6 @@ static int reload_config(void)
{
struct ast_config *cfg;
struct ast_variable *v;
struct ast_hostent ahp;
struct hostent *hp;
struct sockaddr_in bindaddr = { 0, };
char *config = "unistim.conf";
char *cat;
@@ -6916,11 +6914,11 @@ static int reload_config(void)
}
} else if (!strcasecmp(v->name, "public_ip")) {
if (!ast_strlen_zero(v->value)) {
if (!(hp = ast_gethostbyname(v->value, &ahp))) {
struct ast_sockaddr addr = { {0,} };
if (ast_sockaddr_resolve_first_af(&addr, v->value, PARSE_PORT_FORBID, AF_INET)) {
ast_log(LOG_WARNING, "Invalid address: %s\n", v->value);
} else {
memcpy(&public_ip.sin_addr, hp->h_addr, sizeof(public_ip.sin_addr));
public_ip.sin_family = AF_INET;
ast_sockaddr_to_sin(&addr, &public_ip);
}
}
}