From a54f6387071d386811f81f8446b64e51500e6dd3 Mon Sep 17 00:00:00 2001 From: Richard Fuchs <rfuchs@sipwise.com> Date: Tue, 21 Apr 2020 09:54:17 -0400 Subject: [PATCH] MT#55283 retain attributes of unsupp protocols closes #971 closes #1715 Change-Id: Icff09f0d052432a658a773700a837095a335c4f2 --- daemon/call.c | 2 +- daemon/ice.c | 2 +- daemon/sdp.c | 33 ++++++++++----- t/auto-daemon-tests.pl | 93 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 117 insertions(+), 13 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index a4591eeb1..9e5a65566 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1499,7 +1499,7 @@ static void __generate_crypto(const struct sdp_ng_flags *flags, struct call_medi MEDIA_CLEAR(this, SETUP_PASSIVE); MEDIA_CLEAR(this, SETUP_ACTIVE); - if (MEDIA_ISSET(this, PASSTHRU) && other) { + if (other && (MEDIA_ISSET(this, PASSTHRU) || !other->protocol)) { /* clear crypto for the other leg as well b/c passthrough only * works if it is done for both legs */ MEDIA_CLEAR(other, DTLS); diff --git a/daemon/ice.c b/daemon/ice.c index 85770c312..bdde63425 100644 --- a/daemon/ice.c +++ b/daemon/ice.c @@ -535,7 +535,7 @@ void ice_update(struct ice_agent *ag, struct stream_params *sp, bool allow_reset comps = 0; for (l = media->streams.head; l; l = l->next) components[comps++] = l->data; - if (comps == 2 && MEDIA_ISSET(media, RTCP_MUX)) + if (comps == 2 && (MEDIA_ISSET(media, RTCP_MUX) || !proto_is_rtp(media->protocol))) components[1] = NULL; comps = 0; diff --git a/daemon/sdp.c b/daemon/sdp.c index 1f851b2df..f5ab7bb35 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -2343,6 +2343,7 @@ static int process_media_attributes(struct sdp_chopper *chop, struct sdp_media * if (subst_str) goto strip_with_subst; + // protocol-agnostic attributes switch (attr->attr) { case ATTR_ICE: case ATTR_ICE_UFRAG: @@ -2371,12 +2372,6 @@ static int process_media_attributes(struct sdp_chopper *chop, struct sdp_media * break; goto strip; - case ATTR_RTCP: - case ATTR_RTCP_MUX: - if (flags->ice_option == ICE_FORCE_RELAY) - break; - goto strip; - case ATTR_IGNORE: case ATTR_END_OF_CANDIDATES: // we strip it here and re-insert it later case ATTR_MID: @@ -2390,6 +2385,21 @@ static int process_media_attributes(struct sdp_chopper *chop, struct sdp_media * goto strip; break; + default: + break; + } + + // leave everything alone if protocol is unsupported + if (!media->protocol) + continue; + + switch (attr->attr) { + case ATTR_RTCP: + case ATTR_RTCP_MUX: + if (flags->ice_option == ICE_FORCE_RELAY) + break; + goto strip; + case ATTR_RTPMAP: case ATTR_FMTP: if (media->codecs.codec_prefs.length > 0) @@ -2934,12 +2944,13 @@ static struct packet_stream *print_sdp_media_section(GString *s, struct call_med ps_rtcp = print_rtcp(s, media, rtp_ps_link, flags, sdp_media); - insert_crypto(s, media, flags); - insert_dtls(s, media, dtls_ptr(rtp_ps->selected_sfd), flags); + if (proto_is_rtp(media->protocol)) { + insert_crypto(s, media, flags); + insert_dtls(s, media, dtls_ptr(rtp_ps->selected_sfd), flags); - if (proto_is_rtp(media->protocol) && media->ptime) { - append_attr_int_to_gstring(s, "a=ptime:", &media->ptime, flags, - media->type_id); + if (media->ptime) + append_attr_int_to_gstring(s, "a=ptime:", &media->ptime, flags, + media->type_id); } if (MEDIA_ISSET(media, ICE) && media->ice_agent) { diff --git a/t/auto-daemon-tests.pl b/t/auto-daemon-tests.pl index caf199e49..83a36ac79 100755 --- a/t/auto-daemon-tests.pl +++ b/t/auto-daemon-tests.pl @@ -20935,6 +20935,99 @@ SDP is($port_a, $port_b, 'port unchanged'); +# GH #1715 + +new_call; +offer('GH #1715', {ICE => 'remove', "transport-protocol" => "RTP/AVP"}, <<SDP); +v=0 +o=sip:001011000000001\@ims.mnc001.mcc001.3gppnetwork.org 1611848049 1611848049 IN IP4 10.42.44.243 +s=- +c=IN IP4 10.42.44.243 +b=AS:41 +b=RS:512 +b=RR:1537 +t=0 0 +m=audio 30322 RTP/AVP 99 97 9 8 0 105 100 +b=AS:41 +b=RS:512 +b=RR:1537 +a=maxptime:240 +a=des:qos mandatory local sendrecv +a=curr:qos local none +a=des:qos optional remote sendrecv +a=curr:qos remote none +a=rtpmap:99 AMR-WB/16000 +a=fmtp:99 mode-set=0,1,2,5,7,8; max-red=0; mode-change-capability=2 +a=rtpmap:97 AMR/8000 +a=fmtp:97 mode-set=0,2,5,7; max-red=0; mode-change-capability=2 +a=rtpmap:9 G722/8000 +a=rtpmap:8 PCMA/8000 +a=rtpmap:0 PCMU/8000 +a=rtpmap:105 telephone-event/16000 +a=fmtp:105 0-15 +a=rtpmap:100 telephone-event/8000 +a=fmtp:100 0-15 +a=sendrecv +a=rtcp:30323 +a=ptime:20 +m=application 52718 UDP/DTLS/SCTP webrtc-datachannel +b=AS:500 +a=max-message-size:1024 +a=sctp-port:5000 +a=setup:passive +a=fingerprint:SHA-1 4A:AD:B9:B1:3F:82:18:3B:54:02:12:DF:3E:5D:49:6B:19:E5:7C:AB +a=tls-id: abc3de65cddef001be82 +a=dcmap:10 subprotocol="http" +a=dcmap:38754 max-time=150;label="low latency" +a=dcmap:7216 max-retr=5;label="low loss" +a=3gpp-qos-hint:loss=0.01;latency=100 +------------------------------- +v=0 +o=sip:001011000000001\@ims.mnc001.mcc001.3gppnetwork.org 1611848049 1611848049 IN IP4 10.42.44.243 +s=- +c=IN IP4 203.0.113.1 +b=AS:41 +b=RS:512 +b=RR:1537 +t=0 0 +m=audio PORT RTP/AVP 99 97 9 8 0 105 100 +b=AS:41 +b=RS:512 +b=RR:1537 +a=maxptime:240 +a=des:qos mandatory local sendrecv +a=curr:qos local none +a=des:qos optional remote sendrecv +a=curr:qos remote none +a=rtpmap:99 AMR-WB/16000 +a=fmtp:99 mode-set=0,1,2,5,7,8; max-red=0; mode-change-capability=2 +a=rtpmap:97 AMR/8000 +a=fmtp:97 mode-set=0,2,5,7; max-red=0; mode-change-capability=2 +a=rtpmap:9 G722/8000 +a=rtpmap:8 PCMA/8000 +a=rtpmap:0 PCMU/8000 +a=rtpmap:105 telephone-event/16000 +a=fmtp:105 0-15 +a=rtpmap:100 telephone-event/8000 +a=fmtp:100 0-15 +a=sendrecv +a=rtcp:PORT +a=ptime:20 +m=application PORT UDP/DTLS/SCTP webrtc-datachannel +b=AS:500 +a=max-message-size:1024 +a=sctp-port:5000 +a=setup:passive +a=fingerprint:SHA-1 4A:AD:B9:B1:3F:82:18:3B:54:02:12:DF:3E:5D:49:6B:19:E5:7C:AB +a=tls-id: abc3de65cddef001be82 +a=dcmap:10 subprotocol="http" +a=dcmap:38754 max-time=150;label="low latency" +a=dcmap:7216 max-retr=5;label="low loss" +a=3gpp-qos-hint:loss=0.01;latency=100 +a=sendrecv +SDP + + #done_testing;NGCP::Rtpengine::AutoTest::terminate('f00');exit; done_testing();