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 262a4053ff
commit 0d62735f99
7 changed files with 85 additions and 70 deletions

View File

@@ -285,9 +285,6 @@ static int iax_template_parse(struct iax_template *cur, struct ast_config *cfg,
int foundportno = 0;
int foundserverportno = 0;
int x;
struct in_addr ia;
struct hostent *hp;
struct ast_hostent h;
struct iax_template *src, tmp;
const char *t;
if (def) {
@@ -335,15 +332,15 @@ static int iax_template_parse(struct iax_template *cur, struct ast_config *cfg,
} else
ast_log(LOG_WARNING, "Ignoring invalid %s '%s' for '%s' at line %d\n", v->name, v->value, s, v->lineno);
} else if (!strcasecmp(v->name, "server") || !strcasecmp(v->name, "altserver")) {
hp = ast_gethostbyname(v->value, &h);
if (hp) {
memcpy(&ia, hp->h_addr, sizeof(ia));
if (!strcasecmp(v->name, "server"))
cur->server = ntohl(ia.s_addr);
else
cur->altserver = ntohl(ia.s_addr);
} else
struct ast_sockaddr addr = { {0,} };
if (ast_sockaddr_resolve_first_af(&addr, v->value, PARSE_PORT_FORBID, AF_INET)) {
ast_log(LOG_WARNING, "Ignoring invalid %s '%s' for '%s' at line %d\n", v->name, v->value, s, v->lineno);
} else {
if (!strcasecmp(v->name, "server"))
cur->server = ast_sockaddr_ipv4(&addr);
else
cur->altserver = ast_sockaddr_ipv4(&addr);
}
} else if (!strcasecmp(v->name, "codec")) {
struct ast_format *tmpfmt;
if ((tmpfmt = ast_format_cache_get(v->value))) {