summaryrefslogtreecommitdiff
path: root/pjnath
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2012-05-21 14:00:17 +0000
committerBenny Prijono <bennylp@teluu.com>2012-05-21 14:00:17 +0000
commitbc727c6cde75bb4a53be927c4e32612eb65ee10b (patch)
tree813241a609978ad7bb6ddc81cbbf095676fff347 /pjnath
parent3952a97f6a2f9586b2cb88c3a352a29e79d612ca (diff)
Fixed #1512: added Option to continue ICE operation even when STUN resolution fails
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4133 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjnath')
-rw-r--r--pjnath/include/pjnath/ice_strans.h8
-rw-r--r--pjnath/src/pjnath/ice_strans.c42
2 files changed, 43 insertions, 7 deletions
diff --git a/pjnath/include/pjnath/ice_strans.h b/pjnath/include/pjnath/ice_strans.h
index 4530ddca..11cfc5db 100644
--- a/pjnath/include/pjnath/ice_strans.h
+++ b/pjnath/include/pjnath/ice_strans.h
@@ -269,6 +269,14 @@ typedef struct pj_ice_strans_cfg
*/
pj_uint16_t port;
+ /**
+ * Ignore STUN resolution error and proceed with just local
+ * addresses.
+ *
+ * The default is PJ_FALSE
+ */
+ pj_bool_t ignore_stun_error;
+
} stun;
/**
diff --git a/pjnath/src/pjnath/ice_strans.c b/pjnath/src/pjnath/ice_strans.c
index f9db39dd..f5561a91 100644
--- a/pjnath/src/pjnath/ice_strans.c
+++ b/pjnath/src/pjnath/ice_strans.c
@@ -221,6 +221,7 @@ PJ_DEF(void) pj_ice_strans_cfg_default(pj_ice_strans_cfg *cfg)
cfg->turn.conn_type = PJ_TURN_TP_UDP;
cfg->stun.max_host_cands = 64;
+ cfg->stun.ignore_stun_error = PJ_FALSE;
}
@@ -1501,8 +1502,14 @@ static pj_bool_t stun_on_status(pj_stun_sock *stun_sock,
/* May not have cand, e.g. when error during init */
if (cand)
cand->status = status;
- sess_fail(ice_st, PJ_ICE_STRANS_OP_INIT, "DNS resolution failed",
- status);
+ if (!ice_st->cfg.stun.ignore_stun_error) {
+ sess_fail(ice_st, PJ_ICE_STRANS_OP_INIT,
+ "DNS resolution failed", status);
+ } else {
+ PJ_LOG(4,(ice_st->obj_name,
+ "STUN error is ignored for comp %d",
+ comp->comp_id));
+ }
}
break;
case PJ_STUN_SOCK_BINDING_OP:
@@ -1539,7 +1546,7 @@ static pj_bool_t stun_on_status(pj_stun_sock *stun_sock,
if (comp->default_cand > idx) {
--comp->default_cand;
} else if (comp->default_cand == idx) {
- comp->default_cand = 0;
+ comp->default_cand = !idx;
}
/* Remove srflx candidate */
@@ -1567,16 +1574,37 @@ static pj_bool_t stun_on_status(pj_stun_sock *stun_sock,
/* May not have cand, e.g. when error during init */
if (cand)
cand->status = status;
- sess_fail(ice_st, PJ_ICE_STRANS_OP_INIT,
- "STUN binding request failed", status);
+ if (!ice_st->cfg.stun.ignore_stun_error) {
+ sess_fail(ice_st, PJ_ICE_STRANS_OP_INIT,
+ "STUN binding request failed", status);
+ } else {
+ PJ_LOG(4,(ice_st->obj_name,
+ "STUN error is ignored for comp %d",
+ comp->comp_id));
+
+ if (cand) {
+ unsigned idx = cand - comp->cand_list;
+
+ /* Update default candidate index */
+ if (comp->default_cand == idx) {
+ comp->default_cand = !idx;
+ }
+ }
+
+ sess_init_update(ice_st);
+ }
}
break;
case PJ_STUN_SOCK_KEEP_ALIVE_OP:
if (status != PJ_SUCCESS) {
pj_assert(cand != NULL);
cand->status = status;
- sess_fail(ice_st, PJ_ICE_STRANS_OP_INIT,
- "STUN keep-alive failed", status);
+ if (!ice_st->cfg.stun.ignore_stun_error) {
+ sess_fail(ice_st, PJ_ICE_STRANS_OP_INIT,
+ "STUN keep-alive failed", status);
+ } else {
+ PJ_LOG(4,(ice_st->obj_name, "STUN error is ignored"));
+ }
}
break;
}