mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-17 15:29:05 +00:00
netsock2: Add ast_sockaddr_resolve_first_af to netsock2 public API
This function originally was used in chan_sip to enable some simplifying assumptions and eventually was copy and pasted into res_pjsip_logger and res_hep. Since it's replicated in three places, it's probably best to move it into the public netsock2 API for these modules to use. Change-Id: Id52e23be885601c51d70259f62de1a5e59d38d04
This commit is contained in:
@@ -1380,8 +1380,6 @@ static int sip_dtmfmode(struct ast_channel *chan, const char *data);
|
||||
static int sip_addheader(struct ast_channel *chan, const char *data);
|
||||
static int sip_do_reload(enum channelreloadreason reason);
|
||||
static char *sip_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
|
||||
static int ast_sockaddr_resolve_first_af(struct ast_sockaddr *addr,
|
||||
const char *name, int flag, int family);
|
||||
static int ast_sockaddr_resolve_first(struct ast_sockaddr *addr,
|
||||
const char *name, int flag);
|
||||
static int ast_sockaddr_resolve_first_transport(struct ast_sockaddr *addr,
|
||||
@@ -34332,30 +34330,6 @@ static int reload(void)
|
||||
return AST_MODULE_LOAD_SUCCESS;
|
||||
}
|
||||
|
||||
/*! \brief Return the first entry from ast_sockaddr_resolve filtered by address family
|
||||
*
|
||||
* \warning Using this function probably means you have a faulty design.
|
||||
*/
|
||||
static int ast_sockaddr_resolve_first_af(struct ast_sockaddr *addr,
|
||||
const char* name, int flag, int family)
|
||||
{
|
||||
struct ast_sockaddr *addrs;
|
||||
int addrs_cnt;
|
||||
|
||||
addrs_cnt = ast_sockaddr_resolve(&addrs, name, flag, family);
|
||||
if (addrs_cnt <= 0) {
|
||||
return 1;
|
||||
}
|
||||
if (addrs_cnt > 1) {
|
||||
ast_debug(1, "Multiple addresses, using the first one only\n");
|
||||
}
|
||||
|
||||
ast_sockaddr_copy(addr, &addrs[0]);
|
||||
|
||||
ast_free(addrs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*! \brief Return the first entry from ast_sockaddr_resolve filtered by family of binddaddr
|
||||
*
|
||||
* \warning Using this function probably means you have a faulty design.
|
||||
|
||||
Reference in New Issue
Block a user