Bug 886134 - Change Datachannel m-line from SCTP/DTLS to DTLS/SCTP - target FF24 r=jesup a=bajaj
authorEthan Hugg <ethanhugg@gmail.com>
Tue, 02 Jul 2013 15:08:59 -0700
changeset 147891 8d66e748a49b3ccb2b3cd36f6e1c423983110b50
parent 147890 d0b270f86f3e96fb63925ca1aaa4853f165a0264
child 147892 582ac0f3876fd69ebf42294c42be3c3617a09edf
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, bajaj
bugs886134
milestone24.0a2
Bug 886134 - Change Datachannel m-line from SCTP/DTLS to DTLS/SCTP - target FF24 r=jesup a=bajaj
media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp_crypto.c
media/webrtc/signaling/src/sipcc/core/sdp/sdp.h
media/webrtc/signaling/src/sipcc/core/sdp/sdp_main.c
media/webrtc/signaling/src/sipcc/core/sdp/sdp_token.c
media/webrtc/signaling/test/signaling_unittests.cpp
--- a/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp_crypto.c
+++ b/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp_crypto.c
@@ -990,18 +990,18 @@ gsmsdp_negotiate_offer_crypto (fsmdef_dc
         }
         break;
 
     case SDP_TRANSPORT_RTPSAVPF:
         /* Remote offers Extended SRTP for media transport */
         negotiated_transport = SDP_TRANSPORT_RTPSAVPF;
         break;
 
-    case SDP_TRANSPORT_SCTPDTLS:
-        negotiated_transport = SDP_TRANSPORT_SCTPDTLS;
+    case SDP_TRANSPORT_DTLSSCTP:
+        negotiated_transport = SDP_TRANSPORT_DTLSSCTP;
         break;
 
     default:
         /* Unknown */
         break;
     }
     return (negotiated_transport);
 }
@@ -1071,18 +1071,18 @@ gsmsdp_negotiate_answer_crypto (fsmdef_d
             /* we offered RTP but remote comes back with SRTP, fail */
         }
         break;
 
     case SDP_TRANSPORT_RTPSAVPF:
         negotiated_transport = SDP_TRANSPORT_RTPSAVPF;
         break;
 
-    case SDP_TRANSPORT_SCTPDTLS:
-        negotiated_transport = SDP_TRANSPORT_SCTPDTLS;
+    case SDP_TRANSPORT_DTLSSCTP:
+        negotiated_transport = SDP_TRANSPORT_DTLSSCTP;
         break;
 
     default:
         /* Unknown */
         break;
     }
     GSM_DEBUG(GSM_F_PREFIX "negotiated transport %d", fname, negotiated_transport);
     return (negotiated_transport);
@@ -1310,17 +1310,17 @@ gsmsdp_init_sdp_media_transport (fsmdef_
 
     /* Initialize crypto context */
     gsmsdp_init_crypto_context(media);
 
     config_get_value(CFGID_RTPSAVPF, &rtpsavpf, sizeof(rtpsavpf));
     config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode));
 
     if (SDP_MEDIA_APPLICATION == media->type) {
-        media->transport = SDP_TRANSPORT_SCTPDTLS;
+        media->transport = SDP_TRANSPORT_DTLSSCTP;
     } else if (rtpsavpf) {
         media->transport = SDP_TRANSPORT_RTPSAVPF;
     } else if (sdpmode) {
         media->transport = SDP_TRANSPORT_RTPSAVP;
     } else	if ((sip_regmgr_get_sec_level(dcb_p->line) != ENCRYPTED) ||
         (!FSM_CHK_FLAGS(media->flags, FSM_MEDIA_F_SUPPORT_SECURITY))) {
         /*
          * The signaling is not encrypted or this media can not support
--- a/media/webrtc/signaling/src/sipcc/core/sdp/sdp.h
+++ b/media/webrtc/signaling/src/sipcc/core/sdp/sdp.h
@@ -174,17 +174,17 @@ typedef enum {
     SDP_TRANSPORT_AAL2_ITU,
     SDP_TRANSPORT_AAL2_ATMF,
     SDP_TRANSPORT_AAL2_CUSTOM,
     SDP_TRANSPORT_AAL1AVP,
     SDP_TRANSPORT_UDPSPRT,
     SDP_TRANSPORT_RTPSAVP,
     SDP_TRANSPORT_TCP,
     SDP_TRANSPORT_RTPSAVPF,
-    SDP_TRANSPORT_SCTPDTLS,
+    SDP_TRANSPORT_DTLSSCTP,
     SDP_MAX_TRANSPORT_TYPES,
     SDP_TRANSPORT_UNSUPPORTED,
     SDP_TRANSPORT_INVALID
 } sdp_transport_e;
 
 
 /* Encryption KeyType */
 typedef enum {
--- a/media/webrtc/signaling/src/sipcc/core/sdp/sdp_main.c
+++ b/media/webrtc/signaling/src/sipcc/core/sdp/sdp_main.c
@@ -224,17 +224,17 @@ const sdp_namearray_t sdp_transport[SDP_
     {"AAL2/ITU",     sizeof("AAL2/ITU")},
     {"AAL2/ATMF",    sizeof("AAL2/ATMF")},
     {"AAL2/custom",  sizeof("AAL2/custom")},
     {"AAL1/AVP",     sizeof("AAL1/AVP")},
     {"udpsprt",      sizeof("udpsprt")},
     {"RTP/SAVP",     sizeof("RTP/SAVP")},
     {"tcp",          sizeof("tcp")},
     {"RTP/SAVPF",    sizeof("RTP/SAVPF")},
-    {"SCTP/DTLS",    sizeof("SCTP/DTLS")}
+    {"DTLS/SCTP",    sizeof("DTLS/SCTP")}
 };
 
 /* Note: These *must* be in the same order as the enum type. */
 const sdp_namearray_t sdp_encrypt[SDP_MAX_ENCRYPT_TYPES] =
 {
     {"clear",        sizeof("clear")},
     {"base64",       sizeof("base64")},
     {"uri",          sizeof("uri")},
--- a/media/webrtc/signaling/src/sipcc/core/sdp/sdp_token.c
+++ b/media/webrtc/signaling/src/sipcc/core/sdp/sdp_token.c
@@ -1190,16 +1190,28 @@ sdp_result_e sdp_parse_media (sdp_t *sdp
     mca_p->transport = SDP_TRANSPORT_UNSUPPORTED;
     for (i=0; i < SDP_MAX_TRANSPORT_TYPES; i++) {
         if (cpr_strncasecmp(tmp, sdp_transport[i].name,
                         sdp_transport[i].strlen) == 0) {
             mca_p->transport = (sdp_transport_e)i;
             break;
         }
     }
+
+    /* TODO(ehugg): Remove this next block when backward
+       compatibility with versions earlier than FF24
+       is no longer required.  See Bug 886134 */
+#define DATACHANNEL_OLD_TRANSPORT "SCTP/DTLS"
+    if (mca_p->transport == SDP_TRANSPORT_UNSUPPORTED) {
+        if (cpr_strncasecmp(tmp, DATACHANNEL_OLD_TRANSPORT,
+            strlen(DATACHANNEL_OLD_TRANSPORT)) == 0) {
+            mca_p->transport = SDP_TRANSPORT_DTLSSCTP;
+        }
+    }
+
     if (mca_p->transport == SDP_TRANSPORT_UNSUPPORTED) {
         /* If we don't recognize or don't support the transport type,
          * just store the first num as the port.
          */
         mca_p->port = num[0];
         sdp_parse_error(sdp_p->peerconnection,
             "%s Warning: Transport protocol type unsupported "
             "(%s).", sdp_p->debug_str, tmp);
@@ -1214,17 +1226,17 @@ sdp_result_e sdp_parse_media (sdp_t *sdp
         if ((mca_p->transport == SDP_TRANSPORT_RTPAVP) ||
 	    (mca_p->transport == SDP_TRANSPORT_RTPSAVP) ||
 	    (mca_p->transport == SDP_TRANSPORT_RTPSAVPF) ||
             (mca_p->transport == SDP_TRANSPORT_UDP) ||
             (mca_p->transport == SDP_TRANSPORT_TCP) ||
             (mca_p->transport == SDP_TRANSPORT_UDPTL) ||
             (mca_p->transport == SDP_TRANSPORT_UDPSPRT) ||
             (mca_p->transport == SDP_TRANSPORT_LOCAL) ||
-            (mca_p->transport == SDP_TRANSPORT_SCTPDTLS)) {
+            (mca_p->transport == SDP_TRANSPORT_DTLSSCTP)) {
             /* Port format is simply <port>.  Make sure that either
              * the choose param is allowed or that the choose value
              * wasn't specified.
              */
             if ((sdp_p->conf_p->allow_choose[SDP_CHOOSE_PORTNUM]) ||
                 (num[0] != SDP_CHOOSE_PARAM)) {
                 mca_p->port        = num[0];
                 mca_p->port_format = SDP_PORT_NUM_ONLY;
@@ -1366,18 +1378,18 @@ sdp_result_e sdp_parse_media (sdp_t *sdp
 	    SDP_FREE(mca_p);
             return (SDP_INVALID_PARAMETER);
         }
     } else {
         /* Transport is a non-AAL2 type.  Parse payloads normally. */
         sdp_parse_payload_types(sdp_p, mca_p, ptr);
     }
 
-    /* Parse SCTP/DTLS port */
-    if (mca_p->transport == SDP_TRANSPORT_SCTPDTLS) {
+    /* Parse DTLS/SCTP port */
+    if (mca_p->transport == SDP_TRANSPORT_DTLSSCTP) {
         ptr = sdp_getnextstrtok(ptr, port, sizeof(port), " \t", &result);
         if (result != SDP_SUCCESS) {
             sdp_parse_error(sdp_p->peerconnection,
                 "%s No sctp port specified in m= media line, "
                 "parse failed.", sdp_p->debug_str);
             SDP_FREE(mca_p);
             sdp_p->conf_p->num_invalid_param++;
             return (SDP_INVALID_PARAMETER);
@@ -1548,29 +1560,29 @@ sdp_result_e sdp_build_media (sdp_t *sdp
         }
         return (SDP_SUCCESS);
     }
 
     /* Build the transport name */
     flex_string_sprintf(fs, "%s",
                      sdp_get_transport_name(mca_p->transport));
 
-    if(mca_p->transport != SDP_TRANSPORT_SCTPDTLS) {
+    if(mca_p->transport != SDP_TRANSPORT_DTLSSCTP) {
 
         /* Build the format lists */
         for (i=0; i < mca_p->num_payloads; i++) {
             if (mca_p->payload_indicator[i] == SDP_PAYLOAD_ENUM) {
                 flex_string_sprintf(fs, " %s",
                                  sdp_get_payload_name((sdp_payload_e)mca_p->payload_type[i]));
             } else {
                 flex_string_sprintf(fs, " %u", mca_p->payload_type[i]);
             }
         }
     } else {
-        /* Add port to SDP if transport is SCTP/DTLS */
+        /* Add port to SDP if transport is DTLS/SCTP */
     	flex_string_sprintf(fs, " %u ", (u32)mca_p->sctpport);
     }
 
     flex_string_sprintf(fs, "\r\n");
 
     if (sdp_p->debug_flag[SDP_DEBUG_TRACE]) {
         SDP_PRINT("%s Built m= media line", sdp_p->debug_str);
     }
--- a/media/webrtc/signaling/test/signaling_unittests.cpp
+++ b/media/webrtc/signaling/test/signaling_unittests.cpp
@@ -2269,17 +2269,17 @@ TEST_F(SignalingTest, missingUfrag)
     "a=rtpmap:120 VP8/90000\r\n"
     "a=recvonly\r\n"
     "a=candidate:0 1 UDP 2113601791 192.168.178.20 49929 typ host\r\n"
     "a=candidate:1 1 UDP 1694236671 77.9.79.167 49929 typ srflx raddr "
       "192.168.178.20 rport 49929\r\n"
     "a=candidate:0 2 UDP 2113601790 192.168.178.20 50769 typ host\r\n"
     "a=candidate:1 2 UDP 1694236670 77.9.79.167 50769 typ srflx raddr "
       "192.168.178.20 rport 50769\r\n"
-    "m=application 54054 SCTP/DTLS 5000 \r\n"
+    "m=application 54054 DTLS/SCTP 5000 \r\n"
     "c=IN IP4 77.9.79.167\r\n"
     "a=fmtp:HuRUu]Dtcl\\zM,7(OmEU%O$gU]x/z\tD protocol=webrtc-datachannel;"
       "streams=16\r\n"
     "a=sendrecv\r\n";
 
   // Need to create an offer, since that's currently required by our
   // FSM. This may change in the future.
   a1_.CreateOffer(constraints, OFFER_AV, SHOULD_SENDRECV_AV);