summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-04-19 11:03:23 +0000
committerBenny Prijono <bennylp@teluu.com>2007-04-19 11:03:23 +0000
commit8d2cc498cf61a6088a1ee4b9eb2cccf5c91a1b70 (patch)
tree7c71504e2e92829de6318028024af835a03dfdd1
parentf77c3cae6b439b111334439d9309ae44699b4709 (diff)
ICE: check for duplicate candidates, and change foundation to use the base address instead
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1207 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjnath/src/pjnath/ice_strans.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/pjnath/src/pjnath/ice_strans.c b/pjnath/src/pjnath/ice_strans.c
index d3ba78f4..a7e5f8f3 100644
--- a/pjnath/src/pjnath/ice_strans.c
+++ b/pjnath/src/pjnath/ice_strans.c
@@ -212,10 +212,24 @@ static pj_status_t add_cand( pj_ice_strans *ice_st,
pj_bool_t set_default)
{
pj_ice_strans_cand *cand;
+ unsigned i;
PJ_ASSERT_RETURN(ice_st && comp && addr, PJ_EINVAL);
PJ_ASSERT_RETURN(comp->cand_cnt < PJ_ICE_ST_MAX_CAND, PJ_ETOOMANY);
+ /* Check that we don't have candidate with the same
+ * address.
+ */
+ for (i=0; i<comp->cand_cnt; ++i) {
+ if (pj_memcmp(addr, &comp->cand_list[i].addr,
+ sizeof(pj_sockaddr_in))==0)
+ {
+ /* Duplicate */
+ PJ_LOG(5,(ice_st->obj_name, "Duplicate candidate not added"));
+ return PJ_SUCCESS;
+ }
+ }
+
cand = &comp->cand_list[comp->cand_cnt];
pj_bzero(cand, sizeof(*cand));
@@ -225,7 +239,7 @@ static pj_status_t add_cand( pj_ice_strans *ice_st,
cand->ice_cand_id = -1;
cand->local_pref = local_pref;
pj_ice_calc_foundation(ice_st->pool, &cand->foundation, type,
- (const pj_sockaddr*)addr);
+ &comp->local_addr);
if (set_default)
comp->default_cand = comp->cand_cnt;