Changeset 286:6241a8b649e0 in mediastreamer2


Ignore:
Timestamp:
Mar 3, 2009 5:37:07 PM (4 years ago)
Author:
aymeric <aymeric@…>
Branch:
default
Message:

work on role and tie-break value

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@289 3f6dc0c8-ddfe-455d-9043-3cd528dc4637

File:
1 edited

Legend:

Unmodified
Added
Removed
  • linphone/mediastreamer2/src/ice.c

    r283 r286  
    8787           req.hasUseCandidate = TRUE; 
    8888 
    89    if (remote_candidate->rem_controlvalue==0) 
    90            { 
    91                    /* calculated once only */ 
    92                    remote_candidate->rem_controlvalue = random(); 
    93                    remote_candidate->rem_controlvalue = remote_candidate->rem_controlvalue >> 32; 
    94                    remote_candidate->rem_controlvalue = random(); 
    95            } 
     89    if (remote_candidate->rem_controlvalue==0) { 
     90      /* calculated once only */     
     91      remote_candidate->rem_controlvalue = random() * (0x7fffffffffffffff/0x7fff); 
     92    } 
    9693    
    9794   if (remote_candidate->rem_controlling==1) 
     
    414411                 } 
    415412                 
    416                 if ((remote_candidates[0].rem_controlling==0 && msg.hasIceControlling) 
    417                         ||(remote_candidates[0].rem_controlling==1 && msg.hasIceControlled)) 
    418                         { 
    419                          char buf[STUN_MAX_MESSAGE_SIZE]; 
    420                          int len = sizeof(buf); 
    421                          ms_error("487 Role Conflict"); 
    422                          _ice_createErrorResponse(&resp, 4, 87, "Role Conflict"); 
    423                          len = stunEncodeMessage(&resp, buf, len, &hmacPassword ); 
    424                          if (len) 
    425                                  sendMessage( rtp_socket, buf, len, remote_addr.addr, remote_addr.port); 
    426                          return -1; 
    427                         }                
    428  
    429  
     413    if (remote_candidates->rem_controlvalue==0) { 
     414      /* calculated once only */     
     415      remote_candidates->rem_controlvalue = random() * (0x7fffffffffffffff/0x7fff); 
     416    } 
     417 
     418                if (remote_candidates[0].rem_controlling==0 && msg.hasIceControlling) { 
     419      /* If the agent's tie-breaker is larger than or equal 
     420         to the contents of the ICE-CONTROLLING attribute 
     421         -> send 487, and do not change ROLE */ 
     422      if (remote_candidates->rem_controlvalue >= msg.iceControlling.value) { 
     423                           char buf[STUN_MAX_MESSAGE_SIZE]; 
     424                           int len = sizeof(buf); 
     425                           ms_error("487 Role Conflict"); 
     426                           _ice_createErrorResponse(&resp, 4, 87, "Role Conflict"); 
     427                           len = stunEncodeMessage(&resp, buf, len, &hmacPassword ); 
     428                           if (len) 
     429                                   sendMessage( rtp_socket, buf, len, remote_addr.addr, remote_addr.port); 
     430                           return -1; 
     431                        } 
     432      else { 
     433        remote_candidates[0].rem_controlling = 1; 
     434      } 
     435    } 
     436 
     437                if (remote_candidates[0].rem_controlling==1 && msg.hasIceControlled) { 
     438 
     439      /* If the agent's tie-breaker is larger than or equal 
     440      to the contents of the ICE-CONTROLLED attribute 
     441      -> change ROLE */ 
     442      if (remote_candidates->rem_controlvalue >= msg.iceControlled.value) { 
     443        remote_candidates[0].rem_controlling = 0; 
     444        } 
     445      else { 
     446        char buf[STUN_MAX_MESSAGE_SIZE]; 
     447        int len = sizeof(buf); 
     448        ms_error("487 Role Conflict"); 
     449        _ice_createErrorResponse(&resp, 4, 87, "Role Conflict"); 
     450        len = stunEncodeMessage(&resp, buf, len, &hmacPassword ); 
     451        if (len) 
     452         sendMessage( rtp_socket, buf, len, remote_addr.addr, remote_addr.port); 
     453        return -1; 
     454        } 
     455      } 
    430456 
    431457                /* 7.2.1.3. Learning Peer Reflexive Candidates */ 
Note: See TracChangeset for help on using the changeset viewer.