From e1c6fe15fdd58ddf2431f56c3ff9be08ebbd2ace Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Thu, 14 Jul 2016 05:15:16 +0000 Subject: Misc (re #1928): Print explicit log message about PJSUA ignoring IPv6 STUN server. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5383 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsua-lib/pjsua_core.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'pjsip') diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c index ea7aab2e..e3bc4e9f 100644 --- a/pjsip/src/pjsua-lib/pjsua_core.c +++ b/pjsip/src/pjsua-lib/pjsua_core.c @@ -1331,7 +1331,7 @@ static void resolve_stun_entry(pjsua_stun_resolve *sess) /* Loop while we have entry to try */ for (; sess->idx < sess->count; ++sess->idx) { - const int af = pj_AF_INET(); + int af; char target[64]; pj_str_t hostpart; pj_uint16_t port; @@ -1344,11 +1344,19 @@ static void resolve_stun_entry(pjsua_stun_resolve *sess) sess->srv[sess->idx].ptr); /* Parse the server entry into host:port */ - status = pj_sockaddr_parse2(af, 0, &sess->srv[sess->idx], - &hostpart, &port, NULL); + status = pj_sockaddr_parse2(pj_AF_UNSPEC(), 0, &sess->srv[sess->idx], + &hostpart, &port, &af); if (status != PJ_SUCCESS) { PJ_LOG(2,(THIS_FILE, "Invalid STUN server entry %s", target)); continue; + } else if (af != pj_AF_INET()) { + /* Ignore IPv6 STUN server for now */ + status = PJ_EAFNOTSUP; + PJ_LOG(3,(THIS_FILE, "Ignored STUN server entry %s, currently " + "only IPv4 STUN server is supported (does " + "IPv6 still need a mapped address?)", + target)); + continue; } /* Use default port if not specified */ @@ -1364,8 +1372,8 @@ static void resolve_stun_entry(pjsua_stun_resolve *sess) pj_bzero(&stun_sock_cb, sizeof(stun_sock_cb)); stun_sock_cb.on_status = &test_stun_on_status; status = pj_stun_sock_create(&pjsua_var.stun_cfg, "stunresolve", - pj_AF_INET(), &stun_sock_cb, - NULL, sess, &sess->stun_sock); + pj_AF_INET(), &stun_sock_cb, + NULL, sess, &sess->stun_sock); if (status != PJ_SUCCESS) { char errmsg[PJ_ERR_MSG_SIZE]; pj_strerror(status, errmsg, sizeof(errmsg)); @@ -1376,8 +1384,8 @@ static void resolve_stun_entry(pjsua_stun_resolve *sess) continue; } - status = pj_stun_sock_start(sess->stun_sock, &hostpart, - port, pjsua_var.resolver); + status = pj_stun_sock_start(sess->stun_sock, &hostpart, port, + pjsua_var.resolver); if (status != PJ_SUCCESS) { char errmsg[PJ_ERR_MSG_SIZE]; pj_strerror(status, errmsg, sizeof(errmsg)); -- cgit v1.2.3