From 8d2cc498cf61a6088a1ee4b9eb2cccf5c91a1b70 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Thu, 19 Apr 2007 11:03:23 +0000 Subject: 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 --- pjnath/src/pjnath/ice_strans.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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; icand_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; -- cgit v1.2.3