| File: | root/firefox-clang/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_candidate_pair.c |
| Warning: | line 313, column 16 Although the value stored to 'r' is used in the enclosing expression, the value is never actually read from 'r' |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* |
| 2 | Copyright (c) 2007, Adobe Systems, Incorporated |
| 3 | All rights reserved. |
| 4 | |
| 5 | Redistribution and use in source and binary forms, with or without |
| 6 | modification, are permitted provided that the following conditions are |
| 7 | met: |
| 8 | |
| 9 | * Redistributions of source code must retain the above copyright |
| 10 | notice, this list of conditions and the following disclaimer. |
| 11 | |
| 12 | * Redistributions in binary form must reproduce the above copyright |
| 13 | notice, this list of conditions and the following disclaimer in the |
| 14 | documentation and/or other materials provided with the distribution. |
| 15 | |
| 16 | * Neither the name of Adobe Systems, Network Resonance nor the names of its |
| 17 | contributors may be used to endorse or promote products derived from |
| 18 | this software without specific prior written permission. |
| 19 | |
| 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | */ |
| 32 | |
| 33 | #include <assert.h> |
| 34 | #include <string.h> |
| 35 | #include <nr_api.h> |
| 36 | #include "async_timer.h" |
| 37 | #include "ice_ctx.h" |
| 38 | #include "ice_util.h" |
| 39 | #include "ice_codeword.h" |
| 40 | #include "stun.h" |
| 41 | |
| 42 | static char *nr_ice_cand_pair_states[]={"UNKNOWN","FROZEN","WAITING","IN_PROGRESS","FAILED","SUCCEEDED","CANCELLED"}; |
| 43 | |
| 44 | static void nr_ice_candidate_pair_restart_stun_role_change_cb(NR_SOCKET s, int how, void *cb_arg); |
| 45 | static void nr_ice_candidate_pair_compute_codeword(nr_ice_cand_pair *pair, |
| 46 | nr_ice_candidate *lcand, nr_ice_candidate *rcand); |
| 47 | |
| 48 | static void nr_ice_candidate_pair_set_priority(nr_ice_cand_pair *pair) |
| 49 | { |
| 50 | /* Priority computation S 5.7.2 */ |
| 51 | UINT8 controlling_priority, controlled_priority; |
| 52 | if(pair->pctx->controlling) |
| 53 | { |
| 54 | controlling_priority=pair->local->priority; |
| 55 | controlled_priority=pair->remote->priority; |
| 56 | } |
| 57 | else{ |
| 58 | controlling_priority=pair->remote->priority; |
| 59 | controlled_priority=pair->local->priority; |
| 60 | } |
| 61 | pair->priority=(MIN(controlling_priority, controlled_priority)(((controlling_priority)<(controlled_priority))?(controlling_priority ):(controlled_priority)))<<32 | |
| 62 | (MAX(controlling_priority, controlled_priority)(((controlling_priority)>(controlled_priority))?(controlling_priority ):(controlled_priority)))<<1 | |
| 63 | (controlled_priority > controlling_priority?0:1); |
| 64 | } |
| 65 | |
| 66 | int nr_ice_candidate_pair_create(nr_ice_peer_ctx *pctx, nr_ice_candidate *lcand,nr_ice_candidate *rcand,nr_ice_cand_pair **pairp) |
| 67 | { |
| 68 | nr_ice_cand_pair *pair=0; |
| 69 | int r,_status; |
| 70 | UINT4 RTO; |
| 71 | nr_ice_candidate tmpcand; |
| 72 | UINT8 t_priority; |
| 73 | |
| 74 | if(!(pair=RCALLOC(sizeof(nr_ice_cand_pair))r_calloc(0,1,sizeof(nr_ice_cand_pair)))) |
| 75 | ABORT(R_NO_MEMORY)do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 76 | |
| 77 | pair->pctx=pctx; |
| 78 | |
| 79 | nr_ice_candidate_pair_compute_codeword(pair,lcand,rcand); |
| 80 | |
| 81 | if(r=nr_concat_strings(&pair->as_string,pair->codeword,"|",lcand->addr.as_string,"|", |
| 82 | rcand->addr.as_string,"(",lcand->label,"|",rcand->label,")", NULL((void*)0))) |
| 83 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 84 | |
| 85 | nr_ice_candidate_pair_set_state(pctx,pair,NR_ICE_PAIR_STATE_FROZEN1); |
| 86 | pair->local=lcand; |
| 87 | pair->remote=rcand; |
| 88 | |
| 89 | nr_ice_candidate_pair_set_priority(pair); |
| 90 | |
| 91 | /* |
| 92 | TODO(bcampen@mozilla.com): Would be nice to log why this candidate was |
| 93 | created (initial pair generation, triggered check, and new trickle |
| 94 | candidate seem to be the possibilities here). |
| 95 | */ |
| 96 | r_log(LOG_ICE,LOG_INFO6,"ICE(%s)/CAND-PAIR(%s): Pairing candidate %s (%x):%s (%x) priority=%llu (%llx)",pctx->ctx->label,pair->codeword,lcand->addr.as_string,lcand->priority,rcand->addr.as_string,rcand->priority,pair->priority,pair->priority); |
| 97 | |
| 98 | /* Foundation */ |
| 99 | if(r=nr_concat_strings(&pair->foundation,lcand->foundation,"|", |
| 100 | rcand->foundation,NULL((void*)0))) |
| 101 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 102 | |
| 103 | /* Compute the RTO per S 16 */ |
| 104 | RTO = MAX(100, (pctx->ctx->Ta * pctx->waiting_pairs))(((100)>((pctx->ctx->Ta * pctx->waiting_pairs)))? (100):((pctx->ctx->Ta * pctx->waiting_pairs))); |
| 105 | |
| 106 | /* Make a bogus candidate to compute a theoretical peer reflexive |
| 107 | * priority per S 7.1.1.1 */ |
| 108 | memcpy(&tmpcand, lcand, sizeof(tmpcand)); |
| 109 | /* Non-standard behavior, but that's because the standard is wrong! If |
| 110 | * this is a relay candidate, it is never appropriate to assign it the |
| 111 | * priority of a prflx. One could attempt to compensate for this on the |
| 112 | * other side by overriding prflx candidates (and their priority) when |
| 113 | * identical trickle candidates arrive, but it is prudent to avoid creating |
| 114 | * this situation in the first place. |
| 115 | * TODO: It may be appropriate to assign it a higher priority than _other_ |
| 116 | * relay candidates. However, there are probably very few cases where it |
| 117 | * would matter. |
| 118 | * TODO: Note that we still have to contend with mismatched priorities for |
| 119 | * srflx here; if we have two srflx, and one of them is learned by the |
| 120 | * other side as a prflx, the other side is going to have a higher priority |
| 121 | * for that pair unless the priority is updated. For ICE-bis nomination, |
| 122 | * this won't matter a whole lot, but we do aggressive nomination, and |
| 123 | * there it is crucial. The controlled side has to pick the highest |
| 124 | * priority nominated pair, and all of them will get nominated. */ |
| 125 | if (tmpcand.type != RELAYED) { |
| 126 | tmpcand.type = PEER_REFLEXIVE; |
| 127 | } |
| 128 | if (r=nr_ice_candidate_compute_priority(&tmpcand)) |
| 129 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 130 | t_priority = tmpcand.priority; |
| 131 | |
| 132 | /* Our sending context */ |
| 133 | if(r=nr_stun_client_ctx_create(pair->as_string, |
| 134 | lcand->osock, |
| 135 | &rcand->addr,RTO,&pair->stun_client)) |
| 136 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 137 | if(!(pair->stun_client->params.ice_binding_request.username=r_strdup(rcand->stream->l2r_user))) |
| 138 | ABORT(R_NO_MEMORY)do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 139 | if(r=r_data_copy(&pair->stun_client->params.ice_binding_request.password, |
| 140 | &rcand->stream->l2r_pass)) |
| 141 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 142 | /* TODO(ekr@rtfm.com): Do we need to frob this when we change role. Bug 890667 */ |
| 143 | pair->stun_client->params.ice_binding_request.control = pctx->controlling? |
| 144 | NR_ICE_CONTROLLING1:NR_ICE_CONTROLLED2; |
| 145 | pair->stun_client->params.ice_binding_request.priority=t_priority; |
| 146 | |
| 147 | pair->stun_client->params.ice_binding_request.tiebreaker=pctx->tiebreaker; |
| 148 | |
| 149 | *pairp=pair; |
| 150 | |
| 151 | _status=0; |
| 152 | abort: |
| 153 | if(_status){ |
| 154 | nr_ice_candidate_pair_destroy(&pair); |
| 155 | } |
| 156 | return(_status); |
| 157 | } |
| 158 | |
| 159 | int nr_ice_candidate_pair_destroy(nr_ice_cand_pair **pairp) |
| 160 | { |
| 161 | nr_ice_cand_pair *pair; |
| 162 | |
| 163 | if(!pairp || !*pairp) |
| 164 | return(0); |
| 165 | |
| 166 | pair=*pairp; |
| 167 | *pairp=0; |
| 168 | |
| 169 | // record stats back to the ice ctx on destruction |
| 170 | if (pair->stun_client) { |
| 171 | nr_accumulate_count(&(pair->local->ctx->stats.stun_retransmits), pair->stun_client->retransmit_ct); |
| 172 | } |
| 173 | |
| 174 | RFREE(pair->as_string)if(pair->as_string) r_free(pair->as_string); |
| 175 | RFREE(pair->foundation)if(pair->foundation) r_free(pair->foundation); |
| 176 | nr_ice_socket_deregister(pair->local->isock,pair->stun_client_handle); |
| 177 | if (pair->stun_client) { |
| 178 | RFREE(pair->stun_client->params.ice_binding_request.username)if(pair->stun_client->params.ice_binding_request.username ) r_free(pair->stun_client->params.ice_binding_request. username); |
| 179 | RFREE(pair->stun_client->params.ice_binding_request.password.data)if(pair->stun_client->params.ice_binding_request.password .data) r_free(pair->stun_client->params.ice_binding_request .password.data); |
| 180 | nr_stun_client_ctx_destroy(&pair->stun_client); |
| 181 | } |
| 182 | |
| 183 | NR_async_timer_cancel(pair->stun_cb_timer); |
| 184 | NR_async_timer_cancel(pair->restart_role_change_cb_timer); |
| 185 | NR_async_timer_cancel(pair->restart_nominated_cb_timer); |
| 186 | |
| 187 | RFREE(pair)if(pair) r_free(pair); |
| 188 | return(0); |
| 189 | } |
| 190 | |
| 191 | int nr_ice_candidate_pair_unfreeze(nr_ice_peer_ctx *pctx, nr_ice_cand_pair *pair) |
| 192 | { |
| 193 | assert(pair->state==NR_ICE_PAIR_STATE_FROZEN)((void) sizeof ((pair->state==1) ? 1 : 0), __extension__ ( { if (pair->state==1) ; else __assert_fail ("pair->state==NR_ICE_PAIR_STATE_FROZEN" , "/root/firefox-clang/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_candidate_pair.c" , 193, __extension__ __PRETTY_FUNCTION__); })); |
| 194 | |
| 195 | nr_ice_candidate_pair_set_state(pctx,pair,NR_ICE_PAIR_STATE_WAITING2); |
| 196 | |
| 197 | return(0); |
| 198 | } |
| 199 | |
| 200 | static void nr_ice_candidate_pair_stun_cb(NR_SOCKET s, int how, void *cb_arg) |
| 201 | { |
| 202 | int r,_status; |
| 203 | nr_ice_cand_pair *pair=cb_arg; |
| 204 | nr_ice_cand_pair *actual_pair=0; |
| 205 | nr_ice_candidate *cand=0; |
| 206 | nr_stun_message *sres; |
| 207 | nr_transport_addr *request_src; |
| 208 | nr_transport_addr *request_dst; |
| 209 | nr_transport_addr *response_src; |
| 210 | nr_transport_addr response_dst; |
| 211 | nr_stun_message_attribute *attr; |
| 212 | |
| 213 | pair->stun_cb_timer=0; |
| 214 | |
| 215 | r_log(LOG_ICE,LOG_DEBUG7,"ICE-PEER(%s)/STREAM(%s)/CAND-PAIR(%s): STUN cb on pair addr = %s", |
| 216 | pair->pctx->label,pair->local->stream->label,pair->codeword,pair->as_string); |
| 217 | |
| 218 | /* This ordinarily shouldn't happen, but can if we're |
| 219 | doing the second check to confirm nomination. |
| 220 | Just bail out */ |
| 221 | if(pair->state==NR_ICE_PAIR_STATE_SUCCEEDED5) |
| 222 | goto done; |
| 223 | |
| 224 | switch(pair->stun_client->state){ |
| 225 | case NR_STUN_CLIENT_STATE_FAILED3: |
| 226 | sres=pair->stun_client->response; |
| 227 | if(sres && nr_stun_message_has_attribute(sres,NR_STUN_ATTR_ERROR_CODE0x0009,&attr)&&attr->u.error_code.number==487){ |
| 228 | |
| 229 | /* |
| 230 | * Flip the controlling bit; subsequent 487s for other pairs will be |
| 231 | * ignored, since we abandon their STUN transactions. |
| 232 | */ |
| 233 | nr_ice_peer_ctx_switch_controlling_role(pair->pctx); |
| 234 | |
| 235 | return; |
| 236 | } |
| 237 | /* Fall through */ |
| 238 | case NR_STUN_CLIENT_STATE_TIMED_OUT4: |
| 239 | nr_ice_candidate_pair_set_state(pair->pctx,pair,NR_ICE_PAIR_STATE_FAILED4); |
| 240 | break; |
| 241 | case NR_STUN_CLIENT_STATE_DONE2: |
| 242 | /* make sure the addresses match up S 7.1.2.2 */ |
| 243 | response_src=&pair->stun_client->peer_addr; |
| 244 | request_dst=&pair->remote->addr; |
| 245 | if (nr_transport_addr_cmp(response_src,request_dst,NR_TRANSPORT_ADDR_CMP_MODE_ALL4)){ |
| 246 | r_log(LOG_ICE,LOG_WARNING4,"ICE-PEER(%s)/CAND-PAIR(%s): Peer address mismatch %s != %s",pair->pctx->label,pair->codeword,response_src->as_string,request_dst->as_string); |
| 247 | nr_ice_candidate_pair_set_state(pair->pctx,pair,NR_ICE_PAIR_STATE_FAILED4); |
| 248 | break; |
| 249 | } |
| 250 | request_src=&pair->stun_client->my_addr; |
| 251 | nr_socket_getaddr(pair->local->osock,&response_dst); |
| 252 | if (nr_transport_addr_cmp(request_src,&response_dst,NR_TRANSPORT_ADDR_CMP_MODE_ALL4)){ |
| 253 | r_log(LOG_ICE,LOG_WARNING4,"ICE-PEER(%s)/CAND-PAIR(%s): Local address mismatch %s != %s",pair->pctx->label,pair->codeword,request_src->as_string,response_dst.as_string); |
| 254 | nr_ice_candidate_pair_set_state(pair->pctx,pair,NR_ICE_PAIR_STATE_FAILED4); |
| 255 | break; |
| 256 | } |
| 257 | |
| 258 | // Update the rtt related fields |
| 259 | if (pair->stun_client->rtt_valid) { |
| 260 | nr_ice_candidate_pair_update_rtt(pair, pair->stun_client->rtt_ms); |
| 261 | // clear rtt_ms so we can't double process it. |
| 262 | pair->stun_client->rtt_valid = 0; |
| 263 | pair->stun_client->rtt_ms = 0; |
| 264 | } |
| 265 | |
| 266 | if(strlen(pair->stun_client->results.ice_binding_response.mapped_addr.as_string)==0){ |
| 267 | /* we're using the mapped_addr returned by the server to lookup our |
| 268 | * candidate, but if the server fails to do that we can't perform |
| 269 | * the lookup -- this may be a BUG because if we've gotten here |
| 270 | * then the transaction ID check succeeded, and perhaps we should |
| 271 | * just assume that it's the server we're talking to and that our |
| 272 | * peer is ok, but I'm not sure how that'll interact with the |
| 273 | * peer reflexive logic below */ |
| 274 | r_log(LOG_ICE,LOG_WARNING4,"ICE-PEER(%s)/CAND-PAIR(%s): server failed to return mapped address on pair %s", pair->pctx->label,pair->codeword,pair->as_string); |
| 275 | nr_ice_candidate_pair_set_state(pair->pctx,pair,NR_ICE_PAIR_STATE_FAILED4); |
| 276 | break; |
| 277 | } |
| 278 | else if(!nr_transport_addr_cmp(&pair->local->addr,&pair->stun_client->results.ice_binding_response.mapped_addr,NR_TRANSPORT_ADDR_CMP_MODE_ALL4)){ |
| 279 | nr_ice_candidate_pair_set_state(pair->pctx,pair,NR_ICE_PAIR_STATE_SUCCEEDED5); |
| 280 | } |
| 281 | else if(pair->stun_client->state == NR_STUN_CLIENT_STATE_DONE2) { |
| 282 | /* OK, this didn't correspond to a pair on the check list, but |
| 283 | it probably matches one of our candidates */ |
| 284 | |
| 285 | cand=TAILQ_FIRST(&pair->local->component->candidates)((&pair->local->component->candidates)->tqh_first ); |
| 286 | while(cand){ |
| 287 | if(!nr_transport_addr_cmp(&cand->addr,&pair->stun_client->results.ice_binding_response.mapped_addr,NR_TRANSPORT_ADDR_CMP_MODE_ALL4)) { |
| 288 | r_log(LOG_ICE,LOG_DEBUG7,"ICE-PEER(%s): found pre-existing local candidate of type %d for mapped address %s", pair->pctx->label,cand->type,cand->addr.as_string); |
| 289 | assert(cand->type != HOST)((void) sizeof ((cand->type != HOST) ? 1 : 0), __extension__ ({ if (cand->type != HOST) ; else __assert_fail ("cand->type != HOST" , "/root/firefox-clang/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_candidate_pair.c" , 289, __extension__ __PRETTY_FUNCTION__); })); |
| 290 | break; |
| 291 | } |
| 292 | |
| 293 | cand=TAILQ_NEXT(cand,entry_comp)((cand)->entry_comp.tqe_next); |
| 294 | } |
| 295 | |
| 296 | if(!cand) { |
| 297 | /* OK, nothing found, must be a new peer reflexive */ |
| 298 | if (pair->local->stream->flags & NR_ICE_CTX_FLAGS_RELAY_ONLY(1<<2)) { |
| 299 | /* Any STUN response with a reflexive address in it is unwanted |
| 300 | when we'll send on relay only. Bail since cand is used below. */ |
| 301 | goto done; |
| 302 | } |
| 303 | if(r=nr_ice_candidate_create(pair->pctx->ctx, |
| 304 | pair->local->component,pair->local->isock,pair->local->osock, |
| 305 | PEER_REFLEXIVE,pair->local->tcp_type,0,pair->local->component->component_id,&cand)) |
| 306 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 307 | if(r=nr_transport_addr_copy(&cand->addr,&pair->stun_client->results.ice_binding_response.mapped_addr)) |
| 308 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 309 | cand->state=NR_ICE_CAND_STATE_INITIALIZED3; |
| 310 | TAILQ_INSERT_TAIL(&pair->local->component->candidates,cand,entry_comp)do { (((cand))->entry_comp.tqe_next) = ((void*)0); (cand)-> entry_comp.tqe_prev = (&pair->local->component-> candidates)->tqh_last; *(&pair->local->component ->candidates)->tqh_last = (cand); (&pair->local-> component->candidates)->tqh_last = &(((cand))->entry_comp .tqe_next); ; ; } while (0); |
| 311 | } else { |
| 312 | /* Check if we have a pair for this candidate already. */ |
| 313 | if(r=nr_ice_media_stream_find_pair(pair->remote->stream, cand, pair->remote, &actual_pair)) { |
Although the value stored to 'r' is used in the enclosing expression, the value is never actually read from 'r' | |
| 314 | r_log(LOG_ICE,LOG_DEBUG7,"ICE-PEER(%s): no pair exists for %s and %s", pair->pctx->label,cand->addr.as_string, pair->remote->addr.as_string); |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | if(!actual_pair) { |
| 319 | if(r=nr_ice_candidate_pair_create(pair->pctx,cand,pair->remote, &actual_pair)) |
| 320 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 321 | |
| 322 | if(r=nr_ice_component_insert_pair(actual_pair->remote->component,actual_pair)) |
| 323 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 324 | |
| 325 | /* If the original pair was nominated, make us nominated too. */ |
| 326 | if(pair->peer_nominated) |
| 327 | actual_pair->peer_nominated=1; |
| 328 | |
| 329 | /* Now mark the orig pair failed */ |
| 330 | nr_ice_candidate_pair_set_state(pair->pctx,pair,NR_ICE_PAIR_STATE_FAILED4); |
| 331 | } |
| 332 | |
| 333 | assert(actual_pair)((void) sizeof ((actual_pair) ? 1 : 0), __extension__ ({ if ( actual_pair) ; else __assert_fail ("actual_pair", "/root/firefox-clang/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_candidate_pair.c" , 333, __extension__ __PRETTY_FUNCTION__); })); |
| 334 | nr_ice_candidate_pair_set_state(actual_pair->pctx,actual_pair,NR_ICE_PAIR_STATE_SUCCEEDED5); |
| 335 | pair=actual_pair; |
| 336 | |
| 337 | } |
| 338 | |
| 339 | /* Should we set nominated? */ |
| 340 | if(pair->pctx->controlling){ |
| 341 | if(pair->pctx->ctx->flags & NR_ICE_CTX_FLAGS_AGGRESSIVE_NOMINATION(1)) |
| 342 | pair->nominated=1; |
| 343 | } |
| 344 | else{ |
| 345 | if(pair->peer_nominated) |
| 346 | pair->nominated=1; |
| 347 | } |
| 348 | |
| 349 | |
| 350 | /* increment the number of valid pairs in the component */ |
| 351 | /* We don't bother to maintain a separate valid list */ |
| 352 | pair->remote->component->valid_pairs++; |
| 353 | |
| 354 | /* S 7.1.2.2: unfreeze other pairs with the same foundation*/ |
| 355 | if(r=nr_ice_media_stream_unfreeze_pairs_foundation(pair->remote->stream,pair->foundation)) |
| 356 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 357 | |
| 358 | /* Deal with this pair being nominated */ |
| 359 | if(pair->nominated){ |
| 360 | if(r=nr_ice_component_nominated_pair(pair->remote->component, pair)) |
| 361 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 362 | } |
| 363 | |
| 364 | break; |
| 365 | default: |
| 366 | ABORT(R_INTERNAL)do { int _r=3; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 367 | } |
| 368 | |
| 369 | /* If we're controlling but in regular mode, ask the handler |
| 370 | if he wants to nominate something and stop... */ |
| 371 | if(pair->pctx->controlling && !(pair->pctx->ctx->flags & NR_ICE_CTX_FLAGS_AGGRESSIVE_NOMINATION(1))){ |
| 372 | |
| 373 | if(r=nr_ice_component_select_pair(pair->pctx,pair->remote->component)){ |
| 374 | if(r!=R_NOT_FOUND2) |
| 375 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | done: |
| 380 | _status=0; |
| 381 | abort: |
| 382 | if (_status) { |
| 383 | // cb doesn't return anything, but we should probably log that we aborted |
| 384 | // This also quiets the unused variable warnings. |
| 385 | r_log(LOG_ICE,LOG_DEBUG7,"ICE-PEER(%s)/STREAM(%s)/CAND-PAIR(%s): STUN cb pair addr = %s abort with status: %d", |
| 386 | pair->pctx->label,pair->local->stream->label,pair->codeword,pair->as_string, _status); |
| 387 | } |
| 388 | return; |
| 389 | } |
| 390 | |
| 391 | static void nr_ice_candidate_pair_restart(nr_ice_peer_ctx *pctx, nr_ice_cand_pair *pair) |
| 392 | { |
| 393 | int r,_status; |
| 394 | UINT4 mode; |
| 395 | |
| 396 | nr_ice_candidate_pair_set_state(pctx,pair,NR_ICE_PAIR_STATE_IN_PROGRESS3); |
| 397 | |
| 398 | /* Start STUN */ |
| 399 | if(pair->pctx->controlling && (pair->pctx->ctx->flags & NR_ICE_CTX_FLAGS_AGGRESSIVE_NOMINATION(1))) |
| 400 | mode=NR_ICE_CLIENT_MODE_USE_CANDIDATE10; |
| 401 | else |
| 402 | mode=NR_ICE_CLIENT_MODE_BINDING_REQUEST11; |
| 403 | |
| 404 | nr_stun_client_reset(pair->stun_client); |
| 405 | |
| 406 | if(r=nr_stun_client_start(pair->stun_client,mode,nr_ice_candidate_pair_stun_cb,pair)) |
| 407 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 408 | |
| 409 | if ((r=nr_ice_ctx_remember_id(pair->pctx->ctx, pair->stun_client->request))) { |
| 410 | /* ignore if this fails (which it shouldn't) because it's only an |
| 411 | * optimization and the cleanup routines are not going to do the right |
| 412 | * thing if this fails */ |
| 413 | assert(0)((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "/root/firefox-clang/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_candidate_pair.c" , 413, __extension__ __PRETTY_FUNCTION__); })); |
| 414 | } |
| 415 | |
| 416 | _status=0; |
| 417 | abort: |
| 418 | if(_status){ |
| 419 | /* Don't fire the CB, but schedule it to fire ASAP */ |
| 420 | assert(!pair->stun_cb_timer)((void) sizeof ((!pair->stun_cb_timer) ? 1 : 0), __extension__ ({ if (!pair->stun_cb_timer) ; else __assert_fail ("!pair->stun_cb_timer" , "/root/firefox-clang/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_candidate_pair.c" , 420, __extension__ __PRETTY_FUNCTION__); })); |
| 421 | NR_ASYNC_TIMER_SET(0,nr_ice_candidate_pair_stun_cb,pair, &pair->stun_cb_timer)NR_async_timer_set(0,nr_ice_candidate_pair_stun_cb,pair,(char *)__FUNCTION__,421,&pair->stun_cb_timer); |
| 422 | _status=0; |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | int nr_ice_candidate_pair_start(nr_ice_peer_ctx *pctx, nr_ice_cand_pair *pair) |
| 427 | { |
| 428 | int r,_status; |
| 429 | |
| 430 | /* Register the stun ctx for when responses come in*/ |
| 431 | if(r=nr_ice_socket_register_stun_client(pair->local->isock,pair->stun_client,&pair->stun_client_handle)) |
| 432 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 433 | |
| 434 | nr_ice_candidate_pair_restart(pctx, pair); |
| 435 | |
| 436 | _status=0; |
| 437 | abort: |
| 438 | return(_status); |
| 439 | } |
| 440 | |
| 441 | static int nr_ice_candidate_copy_for_triggered_check(nr_ice_cand_pair *pair) |
| 442 | { |
| 443 | int r,_status; |
| 444 | nr_ice_cand_pair *copy; |
| 445 | |
| 446 | if(r=nr_ice_candidate_pair_create(pair->pctx, pair->local, pair->remote, ©)) |
| 447 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 448 | |
| 449 | /* Preserve nomination status */ |
| 450 | copy->peer_nominated= pair->peer_nominated; |
| 451 | copy->nominated = pair->nominated; |
| 452 | |
| 453 | r_log(LOG_ICE,LOG_INFO6,"CAND-PAIR(%s): Adding pair to check list and trigger check queue: %s",pair->codeword,pair->as_string); |
| 454 | nr_ice_candidate_pair_insert(&pair->remote->stream->check_list,copy); |
| 455 | nr_ice_candidate_pair_trigger_check_append(&pair->remote->stream->trigger_check_queue,copy); |
| 456 | |
| 457 | copy->triggered = 1; |
| 458 | nr_ice_candidate_pair_set_state(copy->pctx,copy,NR_ICE_PAIR_STATE_WAITING2); |
| 459 | |
| 460 | _status=0; |
| 461 | abort: |
| 462 | return(_status); |
| 463 | } |
| 464 | |
| 465 | int nr_ice_candidate_pair_do_triggered_check(nr_ice_peer_ctx *pctx, nr_ice_cand_pair *pair, int force) |
| 466 | { |
| 467 | int r,_status; |
| 468 | |
| 469 | if(pair->state==NR_ICE_PAIR_STATE_SUCCEEDED5) { |
| 470 | r_log(LOG_ICE,LOG_DEBUG7,"ICE-PEER(%s)/CAND_PAIR(%s): No new trigger check for succeeded pair",pctx->label,pair->codeword); |
| 471 | return(0); |
| 472 | } else if (pair->local->stream->obsolete) { |
| 473 | r_log(LOG_ICE, LOG_DEBUG7, |
| 474 | "ICE-PEER(%s)/CAND_PAIR(%s): No new trigger check for pair with " |
| 475 | "obsolete stream", |
| 476 | pctx->label, pair->codeword); |
| 477 | return (0); |
| 478 | } |
| 479 | |
| 480 | /* Do not run this logic more than once on a given pair (|force| is set |
| 481 | * when the check we received has USE-CANDIDATE for this pair for the first |
| 482 | * time, and this pair is a higher priority than anything that has been |
| 483 | * nominated so far) */ |
| 484 | if(!pair->triggered || force){ |
| 485 | r_log(LOG_ICE,LOG_INFO6,"ICE-PEER(%s)/CAND-PAIR(%s): triggered check on %s",pctx->label,pair->codeword,pair->as_string); |
| 486 | |
| 487 | pair->triggered=1; |
| 488 | |
| 489 | switch(pair->state){ |
| 490 | case NR_ICE_PAIR_STATE_FAILED4: |
| 491 | /* OK, there was a pair, it's just invalid: According to Section |
| 492 | * 7.2.1.4, we need to resurrect it */ |
| 493 | r_log(LOG_ICE,LOG_INFO6,"ICE-PEER(%s)/CAND-PAIR(%s): received STUN check on failed pair, resurrecting: %s",pctx->label,pair->codeword,pair->as_string); |
| 494 | /* fall through */ |
| 495 | case NR_ICE_PAIR_STATE_FROZEN1: |
| 496 | nr_ice_candidate_pair_set_state(pctx,pair,NR_ICE_PAIR_STATE_WAITING2); |
| 497 | /* fall through even further */ |
| 498 | case NR_ICE_PAIR_STATE_WAITING2: |
| 499 | /* Append it additionally to the trigger check queue */ |
| 500 | r_log(LOG_ICE,LOG_INFO6,"ICE-PEER(%s)/CAND-PAIR(%s): Inserting pair to trigger check queue: %s",pctx->label,pair->codeword,pair->as_string); |
| 501 | nr_ice_candidate_pair_trigger_check_append(&pair->remote->stream->trigger_check_queue,pair); |
| 502 | break; |
| 503 | case NR_ICE_PAIR_STATE_CANCELLED6: |
| 504 | r_log(LOG_ICE,LOG_INFO6,"ICE-PEER(%s)/CAND-PAIR(%s): received STUN check on cancelled pair, resurrecting: %s",pctx->label,pair->codeword,pair->as_string); |
| 505 | /* fall through */ |
| 506 | case NR_ICE_PAIR_STATE_IN_PROGRESS3: |
| 507 | /* Instead of trying to maintain two stun contexts on the same pair, |
| 508 | * and handling heterogenous responses and error conditions, we instead |
| 509 | * create a second pair that is identical except that it has the |
| 510 | * |triggered| bit set. We also cancel the original pair, but it can |
| 511 | * still succeed on its own in the special waiting state. */ |
| 512 | if(r=nr_ice_candidate_copy_for_triggered_check(pair)) |
| 513 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 514 | nr_ice_candidate_pair_cancel(pair->pctx,pair,1); |
| 515 | break; |
| 516 | default: |
| 517 | /* all states are handled - a new/unknown state should not |
| 518 | * automatically enter the start_checks() below */ |
| 519 | assert(0)((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "/root/firefox-clang/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_candidate_pair.c" , 519, __extension__ __PRETTY_FUNCTION__); })); |
| 520 | break; |
| 521 | } |
| 522 | |
| 523 | /* Ensure that the timers are running to start checks on the topmost entry |
| 524 | * of the triggered check queue. */ |
| 525 | if(r=nr_ice_media_stream_start_checks(pair->pctx,pair->remote->stream)) |
| 526 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 527 | } |
| 528 | |
| 529 | _status=0; |
| 530 | abort: |
| 531 | return(_status); |
| 532 | } |
| 533 | |
| 534 | void nr_ice_candidate_pair_cancel(nr_ice_peer_ctx *pctx,nr_ice_cand_pair *pair, int move_to_wait_state) |
| 535 | { |
| 536 | if(pair->state != NR_ICE_PAIR_STATE_FAILED4){ |
| 537 | /* If it's already running we need to terminate the stun */ |
| 538 | if(pair->state==NR_ICE_PAIR_STATE_IN_PROGRESS3){ |
| 539 | if(move_to_wait_state) { |
| 540 | nr_stun_client_wait(pair->stun_client); |
| 541 | } else { |
| 542 | nr_stun_client_cancel(pair->stun_client); |
| 543 | } |
| 544 | } |
| 545 | nr_ice_candidate_pair_set_state(pctx,pair,NR_ICE_PAIR_STATE_CANCELLED6); |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | int nr_ice_candidate_pair_select(nr_ice_cand_pair *pair) |
| 550 | { |
| 551 | int r,_status; |
| 552 | |
| 553 | if(!pair){ |
| 554 | r_log(LOG_ICE,LOG_ERR3,"ICE-PAIR: No pair chosen"); |
| 555 | ABORT(R_BAD_ARGS)do { int _r=6; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 556 | } |
| 557 | |
| 558 | if(pair->state!=NR_ICE_PAIR_STATE_SUCCEEDED5){ |
| 559 | r_log(LOG_ICE,LOG_ERR3,"ICE-PEER(%s)/CAND-PAIR(%s): tried to install non-succeeded pair, ignoring: %s",pair->pctx->label,pair->codeword,pair->as_string); |
| 560 | } |
| 561 | else{ |
| 562 | /* Ok, they chose one */ |
| 563 | /* 1. Send a new request with nominated. Do it as a scheduled |
| 564 | event to avoid reentrancy issues. Only do this if it hasn't |
| 565 | happened already (though this shouldn't happen.) |
| 566 | */ |
| 567 | if(!pair->restart_nominated_cb_timer) |
| 568 | NR_ASYNC_TIMER_SET(0,nr_ice_candidate_pair_restart_stun_nominated_cb,pair,&pair->restart_nominated_cb_timer)NR_async_timer_set(0,nr_ice_candidate_pair_restart_stun_nominated_cb ,pair,(char *)__FUNCTION__,568,&pair->restart_nominated_cb_timer ); |
| 569 | |
| 570 | /* 2. Tell ourselves this pair is ready */ |
| 571 | if(r=nr_ice_component_nominated_pair(pair->remote->component, pair)) |
| 572 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 573 | } |
| 574 | |
| 575 | _status=0; |
| 576 | abort: |
| 577 | return(_status); |
| 578 | } |
| 579 | |
| 580 | void nr_ice_candidate_pair_set_state(nr_ice_peer_ctx *pctx, nr_ice_cand_pair *pair, int state) |
| 581 | { |
| 582 | r_log(LOG_ICE,LOG_INFO6,"ICE-PEER(%s)/CAND-PAIR(%s): setting pair to state %s: %s", |
| 583 | pctx->label,pair->codeword,nr_ice_cand_pair_states[state],pair->as_string); |
| 584 | |
| 585 | /* NOTE: This function used to reference pctx->state instead of |
| 586 | pair->state and the assignment to pair->state was at the top |
| 587 | of this function. Because pctx->state was never changed, this seems to have |
| 588 | been a typo. The natural logic is "if the state changed |
| 589 | decrement the counter" so this implies we should be checking |
| 590 | the pair state rather than the pctx->state. |
| 591 | |
| 592 | This didn't cause big problems because waiting_pairs was only |
| 593 | used for pacing, so the pacing just was kind of broken. |
| 594 | |
| 595 | This note is here as a reminder until we do more testing |
| 596 | and make sure that in fact this was a typo. |
| 597 | */ |
| 598 | if(pair->state!=NR_ICE_PAIR_STATE_WAITING2){ |
| 599 | if(state==NR_ICE_PAIR_STATE_WAITING2) |
| 600 | pctx->waiting_pairs++; |
| 601 | } |
| 602 | else{ |
| 603 | if(state!=NR_ICE_PAIR_STATE_WAITING2) |
| 604 | pctx->waiting_pairs--; |
| 605 | |
| 606 | assert(pctx->waiting_pairs>=0)((void) sizeof ((pctx->waiting_pairs>=0) ? 1 : 0), __extension__ ({ if (pctx->waiting_pairs>=0) ; else __assert_fail ("pctx->waiting_pairs>=0" , "/root/firefox-clang/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_candidate_pair.c" , 606, __extension__ __PRETTY_FUNCTION__); })); |
| 607 | } |
| 608 | pair->state=state; |
| 609 | |
| 610 | |
| 611 | if(pair->state==NR_ICE_PAIR_STATE_FAILED4 || |
| 612 | pair->state==NR_ICE_PAIR_STATE_CANCELLED6){ |
| 613 | nr_ice_component_failed_pair(pair->remote->component, pair); |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | void nr_ice_candidate_pair_dump_state(nr_ice_cand_pair *pair, int log_level) |
| 618 | { |
| 619 | r_log(LOG_ICE,log_level,"CAND-PAIR(%s): pair %s: state=%s, priority=0x%llx\n",pair->codeword,pair->as_string,nr_ice_cand_pair_states[pair->state],pair->priority); |
| 620 | } |
| 621 | |
| 622 | |
| 623 | int nr_ice_candidate_pair_trigger_check_append(nr_ice_cand_pair_head *head,nr_ice_cand_pair *pair) |
| 624 | { |
| 625 | if(pair->triggered_check_queue_entry.tqe_next || |
| 626 | pair->triggered_check_queue_entry.tqe_prev) |
| 627 | return(0); |
| 628 | |
| 629 | TAILQ_INSERT_TAIL(head,pair,triggered_check_queue_entry)do { (((pair))->triggered_check_queue_entry.tqe_next) = (( void*)0); (pair)->triggered_check_queue_entry.tqe_prev = ( head)->tqh_last; *(head)->tqh_last = (pair); (head)-> tqh_last = &(((pair))->triggered_check_queue_entry.tqe_next ); ; ; } while (0); |
| 630 | |
| 631 | return(0); |
| 632 | } |
| 633 | |
| 634 | void nr_ice_candidate_pair_insert(nr_ice_cand_pair_head *head,nr_ice_cand_pair *pair) |
| 635 | { |
| 636 | nr_ice_cand_pair *c1; |
| 637 | |
| 638 | c1=TAILQ_FIRST(head)((head)->tqh_first); |
| 639 | while(c1){ |
| 640 | if(c1->priority < pair->priority){ |
| 641 | TAILQ_INSERT_BEFORE(c1,pair,check_queue_entry)do { (pair)->check_queue_entry.tqe_prev = (c1)->check_queue_entry .tqe_prev; (((pair))->check_queue_entry.tqe_next) = (c1); * (c1)->check_queue_entry.tqe_prev = (pair); (c1)->check_queue_entry .tqe_prev = &(((pair))->check_queue_entry.tqe_next); ; ; } while (0); |
| 642 | break; |
| 643 | } |
| 644 | |
| 645 | c1=TAILQ_NEXT(c1,check_queue_entry)((c1)->check_queue_entry.tqe_next); |
| 646 | } |
| 647 | if(!c1) TAILQ_INSERT_TAIL(head,pair,check_queue_entry)do { (((pair))->check_queue_entry.tqe_next) = ((void*)0); ( pair)->check_queue_entry.tqe_prev = (head)->tqh_last; * (head)->tqh_last = (pair); (head)->tqh_last = &(((pair ))->check_queue_entry.tqe_next); ; ; } while (0); |
| 648 | } |
| 649 | |
| 650 | void nr_ice_candidate_pair_restart_stun_nominated_cb(NR_SOCKET s, int how, void *cb_arg) |
| 651 | { |
| 652 | nr_ice_cand_pair *pair=cb_arg; |
| 653 | int r,_status; |
| 654 | |
| 655 | pair->restart_nominated_cb_timer=0; |
| 656 | |
| 657 | r_log(LOG_ICE,LOG_INFO6,"ICE-PEER(%s)/STREAM(%s)/CAND-PAIR(%s)/COMP(%d): Restarting pair as nominated: %s",pair->pctx->label,pair->local->stream->label,pair->codeword,pair->remote->component->component_id,pair->as_string); |
| 658 | |
| 659 | nr_stun_client_reset(pair->stun_client); |
| 660 | |
| 661 | if(r=nr_stun_client_start(pair->stun_client,NR_ICE_CLIENT_MODE_USE_CANDIDATE10,nr_ice_candidate_pair_stun_cb,pair)) |
| 662 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 663 | |
| 664 | if(r=nr_ice_ctx_remember_id(pair->pctx->ctx, pair->stun_client->request)) |
| 665 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
| 666 | |
| 667 | _status=0; |
| 668 | abort: |
| 669 | if (_status) { |
| 670 | // cb doesn't return anything, but we should probably log that we aborted |
| 671 | // This also quiets the unused variable warnings. |
| 672 | r_log(LOG_ICE,LOG_DEBUG7,"ICE-PEER(%s)/STREAM(%s)/CAND-PAIR(%s)/COMP(%d): STUN nominated cb pair as nominated: %s abort with status: %d", |
| 673 | pair->pctx->label,pair->local->stream->label,pair->codeword,pair->remote->component->component_id,pair->as_string, _status); |
| 674 | } |
| 675 | return; |
| 676 | } |
| 677 | |
| 678 | static void nr_ice_candidate_pair_restart_stun_role_change_cb(NR_SOCKET s, int how, void *cb_arg) |
| 679 | { |
| 680 | nr_ice_cand_pair *pair=cb_arg; |
| 681 | |
| 682 | pair->restart_role_change_cb_timer=0; |
| 683 | |
| 684 | r_log(LOG_ICE,LOG_INFO6,"ICE-PEER(%s)/STREAM(%s)/CAND-PAIR(%s):COMP(%d): Restarting pair as %s: %s",pair->pctx->label,pair->local->stream->label,pair->codeword,pair->remote->component->component_id,pair->pctx->controlling ? "CONTROLLING" : "CONTROLLED",pair->as_string); |
| 685 | |
| 686 | nr_ice_candidate_pair_restart(pair->pctx, pair); |
| 687 | } |
| 688 | |
| 689 | void nr_ice_candidate_pair_role_change(nr_ice_cand_pair *pair) |
| 690 | { |
| 691 | pair->stun_client->params.ice_binding_request.control = pair->pctx->controlling ? NR_ICE_CONTROLLING1 : NR_ICE_CONTROLLED2; |
| 692 | nr_ice_candidate_pair_set_priority(pair); |
| 693 | |
| 694 | if(pair->state == NR_ICE_PAIR_STATE_IN_PROGRESS3) { |
| 695 | /* We could try only restarting in-progress pairs when they receive their |
| 696 | * 487, but this ends up being simpler, because any extra 487 are dropped. |
| 697 | */ |
| 698 | if(!pair->restart_role_change_cb_timer) |
| 699 | NR_ASYNC_TIMER_SET(0,nr_ice_candidate_pair_restart_stun_role_change_cb,pair,&pair->restart_role_change_cb_timer)NR_async_timer_set(0,nr_ice_candidate_pair_restart_stun_role_change_cb ,pair,(char *)__FUNCTION__,699,&pair->restart_role_change_cb_timer ); |
| 700 | } |
| 701 | } |
| 702 | |
| 703 | void nr_ice_candidate_pair_update_rtt(nr_ice_cand_pair *pair, UINT8 rtt_ms) |
| 704 | { |
| 705 | assert(pair)((void) sizeof ((pair) ? 1 : 0), __extension__ ({ if (pair) ; else __assert_fail ("pair", "/root/firefox-clang/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_candidate_pair.c" , 705, __extension__ __PRETTY_FUNCTION__); })); |
| 706 | |
| 707 | pair->responses_recvd++; |
| 708 | pair->current_rtt_ms = rtt_ms; |
| 709 | pair->total_rtt_ms += rtt_ms; |
| 710 | r_log(LOG_ICE,LOG_DEBUG7,"ICE-PEER(%s)/CAND-PAIR(%s): responses_recvd %llu, current_rtt_ms %llu ms, total_rtt_ms %llu ms", |
| 711 | pair->pctx->label,pair->codeword,pair->responses_recvd,pair->current_rtt_ms,pair->total_rtt_ms); |
| 712 | } |
| 713 | |
| 714 | static void nr_ice_candidate_pair_compute_codeword(nr_ice_cand_pair *pair, |
| 715 | nr_ice_candidate *lcand, nr_ice_candidate *rcand) |
| 716 | { |
| 717 | char as_string[2048]; |
| 718 | |
| 719 | snprintf(as_string, |
| 720 | sizeof(as_string), |
| 721 | "%s|%s(%s|%s)", |
| 722 | lcand->addr.as_string, |
| 723 | rcand->addr.as_string, |
| 724 | lcand->label, |
| 725 | rcand->label); |
| 726 | |
| 727 | nr_ice_compute_codeword(as_string,strlen(as_string),pair->codeword); |
| 728 | } |
| 729 |