mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
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:
committed by
Kevin Harwell
parent
262a4053ff
commit
0d62735f99
@@ -281,8 +281,6 @@ static int festival_exec(struct ast_channel *chan, const char *vdata)
|
||||
int usecache;
|
||||
int res = 0;
|
||||
struct sockaddr_in serv_addr;
|
||||
struct hostent *serverhost;
|
||||
struct ast_hostent ahp;
|
||||
int fd;
|
||||
FILE *fs;
|
||||
const char *host;
|
||||
@@ -398,15 +396,17 @@ static int festival_exec(struct ast_channel *chan, const char *vdata)
|
||||
|
||||
if ((serv_addr.sin_addr.s_addr = inet_addr(host)) == -1) {
|
||||
/* its a name rather than an ipnum */
|
||||
serverhost = ast_gethostbyname(host, &ahp);
|
||||
struct ast_sockaddr addr = { {0,} };
|
||||
|
||||
if (serverhost == NULL) {
|
||||
ast_log(LOG_WARNING, "festival_client: gethostbyname failed\n");
|
||||
if (ast_sockaddr_resolve_first_af(&addr, host, PARSE_PORT_FORBID, AF_INET)) {
|
||||
ast_log(LOG_WARNING, "festival_client: ast_sockaddr_resolve_first_af() failed\n");
|
||||
ast_config_destroy(cfg);
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
memmove(&serv_addr.sin_addr, serverhost->h_addr, serverhost->h_length);
|
||||
|
||||
/* We'll overwrite port and family in a sec */
|
||||
ast_sockaddr_to_sin(&addr, &serv_addr);
|
||||
}
|
||||
|
||||
serv_addr.sin_family = AF_INET;
|
||||
|
Reference in New Issue
Block a user