Bug 1142964 - Fix ICE tiebreaker on Windows. r=bwc
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Fri, 21 Aug 2015 10:35:28 -0700
changeset 258979 1eb1c6f76ffc18bd10796bb660c703fd3693e50f
parent 258978 42869ce0e1295e7bb92d7d9e05d80fb6b128a002
child 258980 976e8661ca3c649cbd8bed408193b20852c4a62a
push id29268
push userryanvm@gmail.com
push dateTue, 25 Aug 2015 00:37:23 +0000
treeherdermozilla-central@08015770c9d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc
bugs1142964
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1142964 - Fix ICE tiebreaker on Windows. r=bwc
media/mtransport/third_party/nICEr/src/ice/ice_candidate_pair.c
media/mtransport/third_party/nICEr/src/ice/ice_component.c
media/mtransport/third_party/nICEr/src/stun/stun_build.c
media/mtransport/third_party/nICEr/src/stun/stun_build.h
media/mtransport/third_party/nICEr/src/stun/stun_client_ctx.c
media/mtransport/third_party/nICEr/src/stun/stun_client_ctx.h
media/mtransport/third_party/nICEr/src/stun/stun_codec.c
--- a/media/mtransport/third_party/nICEr/src/ice/ice_candidate_pair.c
+++ b/media/mtransport/third_party/nICEr/src/ice/ice_candidate_pair.c
@@ -120,17 +120,17 @@ int nr_ice_candidate_pair_create(nr_ice_
       ABORT(R_NO_MEMORY);
     if(r=r_data_copy(&pair->stun_client->params.ice_binding_request.password,
       &rcand->stream->l2r_pass))
       ABORT(r);
     pair->stun_client->params.ice_binding_request.priority=t_priority;
     /* TODO(ekr@rtfm.com): Do we need to frob this when we change role. Bug 890667 */
     pair->stun_client->params.ice_binding_request.control = pctx->controlling?
       NR_ICE_CONTROLLING:NR_ICE_CONTROLLED;
-    pair->stun_client->params.ice_use_candidate.priority=t_priority;
+    pair->stun_client->params.ice_binding_request.priority=t_priority;
 
     pair->stun_client->params.ice_binding_request.tiebreaker=pctx->tiebreaker;
 
     *pairp=pair;
 
     _status=0;
   abort:
     if(_status){
--- a/media/mtransport/third_party/nICEr/src/ice/ice_component.c
+++ b/media/mtransport/third_party/nICEr/src/ice/ice_component.c
@@ -745,17 +745,17 @@ static int nr_ice_component_process_inco
         }
       }
     }
     else{
       if(nr_stun_message_has_attribute(sreq,NR_STUN_ATTR_ICE_CONTROLLED,&attr)){
         /* OK, there is a conflict. Who's right? */
         r_log(LOG_ICE,LOG_INFO,"ICE-PEER(%s): role conflict, both controlled",comp->stream->pctx->label);
 
-        if(attr->u.ice_controlling < comp->stream->pctx->tiebreaker){
+        if(attr->u.ice_controlled < comp->stream->pctx->tiebreaker){
           /* Update the peer ctx. This will propagate to all candidate pairs
              in the context. */
           nr_ice_peer_ctx_switch_controlling_role(comp->stream->pctx);
         }
         else {
           /* We are: throw an error */
           r_log(LOG_ICE,LOG_WARNING,"ICE-PEER(%s): returning 487 role conflict",comp->stream->pctx->label);
 
--- a/media/mtransport/third_party/nICEr/src/stun/stun_build.c
+++ b/media/mtransport/third_party/nICEr/src/stun/stun_build.c
@@ -214,17 +214,17 @@ nr_stun_build_req_stund_0_96(nr_stun_cli
  abort:
    if (_status) nr_stun_message_destroy(&req);
    return _status;
 }
 #endif /* USE_STUND_0_96 */
 
 #ifdef USE_ICE
 int
-nr_stun_build_use_candidate(nr_stun_client_ice_use_candidate_params *params, nr_stun_message **msg)
+nr_stun_build_use_candidate(nr_stun_client_ice_binding_request_params *params, nr_stun_message **msg)
 {
    int r,_status;
    nr_stun_message *req = 0;
 
    if ((r=nr_stun_form_request_or_indication(NR_STUN_MODE_STUN, NR_STUN_MSG_BINDING_REQUEST, &req)))
        ABORT(r);
 
    if ((r=nr_stun_message_add_username_attribute(req, params->username)))
--- a/media/mtransport/third_party/nICEr/src/stun/stun_build.h
+++ b/media/mtransport/third_party/nICEr/src/stun/stun_build.h
@@ -71,36 +71,28 @@ typedef struct nr_stun_client_stun_bindi
 #endif
 } nr_stun_client_stun_binding_request_stund_0_96_params;
 
 int nr_stun_build_req_stund_0_96(nr_stun_client_stun_binding_request_stund_0_96_params *params, nr_stun_message **msg);
 #endif /* USE_STUND_0_96 */
 
 
 #ifdef USE_ICE
-typedef struct nr_stun_client_ice_use_candidate_params_ {
-    char *username;
-    Data password;
-    UINT4 priority;
-    UINT8 tiebreaker;
-} nr_stun_client_ice_use_candidate_params;
-
-int nr_stun_build_use_candidate(nr_stun_client_ice_use_candidate_params *params, nr_stun_message **msg);
-
-
 typedef struct nr_stun_client_ice_binding_request_params_ {
     char *username;
     Data password;
     UINT4 priority;
     int control;
 #define NR_ICE_CONTROLLING  1
 #define NR_ICE_CONTROLLED   2
     UINT8 tiebreaker;
 } nr_stun_client_ice_binding_request_params;
 
+int nr_stun_build_use_candidate(nr_stun_client_ice_binding_request_params *params, nr_stun_message **msg);
+
 int nr_stun_build_req_ice(nr_stun_client_ice_binding_request_params *params, nr_stun_message **msg);
 #endif /* USE_ICE */
 
 
 typedef struct nr_stun_client_auth_params_ {
     char authenticate;
     char *username;
     char *realm;
--- a/media/mtransport/third_party/nICEr/src/stun/stun_client_ctx.c
+++ b/media/mtransport/third_party/nICEr/src/stun/stun_client_ctx.c
@@ -332,17 +332,17 @@ static int nr_stun_client_send_request(n
         case NR_STUN_CLIENT_MODE_BINDING_REQUEST_STUND_0_96:
             if ((r=nr_stun_build_req_stund_0_96(&ctx->params.stun_binding_request_stund_0_96, &ctx->request)))
                 ABORT(r);
             break;
 #endif /* USE_STUND_0_96 */
 
 #ifdef USE_ICE
         case NR_ICE_CLIENT_MODE_USE_CANDIDATE:
-            if ((r=nr_stun_build_use_candidate(&ctx->params.ice_use_candidate, &ctx->request)))
+            if ((r=nr_stun_build_use_candidate(&ctx->params.ice_binding_request, &ctx->request)))
                 ABORT(r);
             break;
         case NR_ICE_CLIENT_MODE_BINDING_REQUEST:
             if ((r=nr_stun_build_req_ice(&ctx->params.ice_binding_request, &ctx->request)))
                 ABORT(r);
             break;
 #endif /* USE_ICE */
 
--- a/media/mtransport/third_party/nICEr/src/stun/stun_client_ctx.h
+++ b/media/mtransport/third_party/nICEr/src/stun/stun_client_ctx.h
@@ -60,17 +60,16 @@ typedef union nr_stun_client_params_ {
 
     nr_stun_client_stun_binding_request_params               stun_binding_request;
     nr_stun_client_stun_keepalive_params                     stun_keepalive;
 #ifdef USE_STUND_0_96
     nr_stun_client_stun_binding_request_stund_0_96_params    stun_binding_request_stund_0_96;
 #endif /* USE_STUND_0_96 */
 
 #ifdef USE_ICE
-    nr_stun_client_ice_use_candidate_params                  ice_use_candidate;
     nr_stun_client_ice_binding_request_params                ice_binding_request;
 #endif /* USE_ICE */
 
 #ifdef USE_TURN
     nr_stun_client_allocate_request_params                   allocate_request;
     nr_stun_client_refresh_request_params                    refresh_request;
     nr_stun_client_permission_request_params                 permission_request;
     nr_stun_client_send_indication_params                    send_indication;
--- a/media/mtransport/third_party/nICEr/src/stun/stun_codec.c
+++ b/media/mtransport/third_party/nICEr/src/stun/stun_codec.c
@@ -1317,17 +1317,17 @@ nr_stun_encode_message(nr_stun_message *
     r_dump(NR_LOG_STUN, LOG_DEBUG, "Encoded ID", (void*)&msg->header.id, sizeof(msg->header.id));
 
     TAILQ_FOREACH(attr, &msg->attributes, entry) {
         if ((r=nr_stun_find_attr_info(attr->type, &attr_info))) {
             r_log(NR_LOG_STUN, LOG_WARNING, "Unrecognized attribute: 0x%04x", attr->type);
             ABORT(R_INTERNAL);
         }
 
-        attr_info->name = attr_info->name;
+        attr->name = attr_info->name;
         attr->type_name = attr_info->codec->name;
         attr->encoding = (nr_stun_encoded_attribute*)&msg->buffer[msg->length];
 
         if (attr_info->codec->encode != 0) {
             if ((r=attr_info->codec->encode(attr_info, &attr->u, msg->length, sizeof(msg->buffer), msg->buffer, &attr->encoding_length))) {
                 r_log(NR_LOG_STUN, LOG_WARNING, "Unable to encode %s", attr_info->name);
                 ABORT(r);
             }
@@ -1350,16 +1350,19 @@ nr_stun_encode_message(nr_stun_message *
                 nr_stun_encode((UCHAR*)"\0\0\0\0", padding_bytes, sizeof(msg->buffer), msg->buffer, &msg->length);
                 attr->encoding_length += padding_bytes;
             }
 
             msg->header.length += attr->encoding_length;
             length_offset = length_offset_hold;
             (void)nr_stun_encode_htons(msg->header.length, sizeof(msg->buffer), msg->buffer, &length_offset);
         }
+        else {
+            r_log(NR_LOG_STUN, LOG_WARNING, "Missing encode function for attribute: %s", attr_info->name);
+        }
     }
 
     r_log(NR_LOG_STUN, LOG_DEBUG, "Encoded Length: %d", msg->header.length);
 
     assert(msg->length < NR_STUN_MAX_MESSAGE_SIZE);
 
 #ifdef SANITY_CHECKS
     sanity_check_encoding_stuff(msg);