Bug 933986. Switch over from index to an id, and ensure uniqueness when feeding into the candidate priority calculation. r=drno

MozReview-Commit-ID: 5LOQJbsnEWN

--HG--
extra : rebase_source : 644695f73f316fa8e71e410442f3796822e3255a
This commit is contained in:
Byron Campen [:bwc] 2013-11-04 16:50:10 -08:00
parent 22bd1820b5
commit 6765c70f22
4 changed files with 7 additions and 6 deletions

View File

@ -430,7 +430,7 @@ int nr_ice_candidate_compute_priority(nr_ice_candidate *cand)
if(r=NR_reg_get_uchar(NR_ICE_REG_PREF_TYPE_RELAYED_TCP,&type_preference))
ABORT(r);
}
stun_priority=31-cand->stun_server->index;
stun_priority=31-cand->stun_server->id;
break;
case SERVER_REFLEXIVE:
if(cand->base.protocol == IPPROTO_UDP) {
@ -440,7 +440,7 @@ int nr_ice_candidate_compute_priority(nr_ice_candidate *cand)
if(r=NR_reg_get_uchar(NR_ICE_REG_PREF_TYPE_SRV_RFLX_TCP,&type_preference))
ABORT(r);
}
stun_priority=31-cand->stun_server->index;
stun_priority=31-cand->stun_server->id;
break;
case PEER_REFLEXIVE:
if(cand->base.protocol == IPPROTO_UDP) {

View File

@ -243,6 +243,8 @@ static int nr_ice_component_initialize_udp(struct nr_ice_ctx_ *ctx,nr_ice_compon
if(ctx->stun_servers[j].transport!=IPPROTO_UDP)
continue;
/* Ensure id is set (nr_ice_ctx_set_stun_servers does not) */
ctx->stun_servers[j].id = j;
if(r=nr_ice_candidate_create(ctx,component,
isock,sock,SERVER_REFLEXIVE,0,
&ctx->stun_servers[j],component->component_id,&cand))
@ -272,6 +274,8 @@ static int nr_ice_component_initialize_udp(struct nr_ice_ctx_ *ctx,nr_ice_compon
continue;
if (!(ctx->flags & NR_ICE_CTX_FLAGS_RELAY_ONLY)) {
/* Ensure id is set with a unique value */
ctx->turn_servers[j].turn_server.id = j + ctx->stun_server_ct;
/* srvrflx */
if(r=nr_ice_candidate_create(ctx,component,
isock,sock,SERVER_REFLEXIVE,0,

View File

@ -108,7 +108,6 @@ int nr_ice_fetch_stun_servers(int ct, nr_ice_stun_server **out)
if(r=nr_ip4_port_to_transport_addr(ntohl(addr_int), port, IPPROTO_UDP,
&servers[i].u.addr))
ABORT(r);
servers[i].index=i;
servers[i].type = NR_ICE_STUN_SERVER_TYPE_ADDR;
RFREE(addr);
addr=0;
@ -299,8 +298,6 @@ int nr_ice_fetch_turn_servers(int ct, nr_ice_turn_server **out)
data.data=0;
}
servers[i].turn_server.index=i;
RFREE(addr);
addr=0;
}

View File

@ -61,7 +61,7 @@ typedef struct nr_ice_stun_server_ {
UINT2 port;
} dnsname;
} u;
int index;
int id;
int transport;
} nr_ice_stun_server;