Fixed #1512: added Option to continue ICE operation even when STUN resolution fails

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@4133 74dad513-b988-da41-8d7b-12977e46ad98
remotes/origin/android
Benny Prijono 13 years ago
parent a485e970e0
commit fe9bf3079b

@ -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;
/**

@ -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;
}

Loading…
Cancel
Save