This commit is contained in:
JerryXiao 2022-11-11 01:24:51 +08:00
parent 2bbc57814e
commit ff6237a382
Signed by: Jerry
GPG key ID: 22618F758B5BE2E5

View file

@ -733,6 +733,27 @@ PJ_DEF(pj_status_t) pj_sockaddr_parse( int af, unsigned options,
/* Resolve the IP address of local machine */ /* Resolve the IP address of local machine */
PJ_DEF(pj_status_t) pj_gethostip(int af, pj_sockaddr *addr) PJ_DEF(pj_status_t) pj_gethostip(int af, pj_sockaddr *addr)
{
char *bind = NULL;
if (af == PJ_AF_INET) {
bind = getenv("PJSIP_BIND4");
}
else if (af == PJ_AF_INET6) {
bind = getenv("PJSIP_BIND6");
}
if (bind) {
pj_str_t pjbind = pj_str(bind);
pj_sockaddr dst_addr;
pj_status_t status = pj_sockaddr_init(af, &dst_addr, &pjbind, 0);
if (status == PJ_SUCCESS) {
pj_sockaddr_cp(addr, &dst_addr);
printf("---------- af:%d, bind:%s, PJ_SUCCESS:%d\n", af, bind, status);
return status;
}
}
return _pj_gethostip(af, addr);
}
pj_status_t _pj_gethostip(int af, pj_sockaddr *addr)
{ {
unsigned i, count, cand_cnt; unsigned i, count, cand_cnt;
enum { enum {