TT#90101 don't blindly accept a protocol switch in an answer

An endpoint switching protocols is normally passed through to the peer,
but in an answer that is usually not desirable. Change the default
behaviour to stick to the original protocol that was offered even if the
answerer changes protocols.

Change-Id: Ib288549f4b1c9ab57a6333c6b7dd511537af96f7
pull/1072/head
Richard Fuchs 5 years ago
parent ae5b1762b9
commit 12ac8846de

@ -845,6 +845,14 @@ Optionally included keys are:
Valid values are: `RTP/AVP`, `RTP/AVPF`, `RTP/SAVP`, `RTP/SAVPF`.
Additionally the string `accept` can be given in `answer` messages to allow a special case: By
default (when no `transport-protocol` override is given) in answer messages, *rtpengine* will
use the transport protocol that was originally offered. However, an answering client may answer
with a different protocol than what was offered (e.g. offer was for `RTP/AVP` and answer comes
with `RTP/AVPF`). The default behaviour for *rtpengine* is to ignore this protocol change and
still proceed with the protocol that was originally offered. Using the `accept` option here
tells *rtpengine* to go along with this protocol change and pass it to the original offerer.
* `media address`
This can be used to override both the addresses present in the SDP body

@ -1909,14 +1909,30 @@ static void __update_media_protocol(struct call_media *media, struct call_media
/* deduct protocol from stream parameters received */
if (other_media->protocol != sp->protocol) {
other_media->protocol = sp->protocol;
/* if the endpoint changes the protocol, we reset the other side's
/* If the endpoint changes the protocol, we reset the other side's
* protocol as well. this lets us remember our previous overrides,
* but also lets endpoints re-negotiate.
* Exception: OSRTP answer/accept. */
if (flags && flags->opmode == OP_ANSWER && other_media->protocol && other_media->protocol->rtp
&& !other_media->protocol->srtp
&& media->protocol && media->protocol->osrtp && flags->osrtp_accept)
;
* Answers are a special case: handle OSRTP answer/accept, but otherwise
* answer with the same protocol that was offered, unless we're instructed
* not to. */
if (flags && flags->opmode == OP_ANSWER) {
// OSRTP?
if (other_media->protocol && other_media->protocol->rtp
&& !other_media->protocol->srtp
&& media->protocol && media->protocol->osrtp)
{
// accept it?
if (flags->osrtp_accept)
;
else
media->protocol = NULL; // reject
}
// pass through any other protocol change?
else if (!flags->protocol_accept)
;
else
media->protocol = NULL;
}
else
media->protocol = NULL;
}

@ -963,8 +963,13 @@ static void call_ng_process_flags(struct sdp_ng_flags *out, bencode_item_t *inpu
call_ng_flags_list(out, input, "T.38", ng_t38_option, NULL);
#endif
bencode_get_alt(input, "transport-protocol", "transport protocol", &out->transport_protocol_str);
out->transport_protocol = transport_protocol(&out->transport_protocol_str);
str transport_protocol_str;
bencode_get_alt(input, "transport-protocol", "transport protocol", &transport_protocol_str);
if (!str_cmp(&transport_protocol_str, "accept"))
out->protocol_accept = 1;
else
out->transport_protocol = transport_protocol(&transport_protocol_str);
bencode_get_alt(input, "media-address", "media address", &out->media_address);
if (bencode_get_alt(input, "address-family", "address family", &out->address_family_str))
out->address_family = get_socket_family_rfc(&out->address_family_str);

@ -25,7 +25,6 @@ struct sdp_ng_flags {
str received_from_family;
str received_from_address;
str media_address;
str transport_protocol_str;
str address_family_str;
const struct transport_protocol *transport_protocol;
sockaddr_t parsed_received_from;
@ -47,6 +46,7 @@ struct sdp_ng_flags {
rev_ptime;
GHashTable *sdes_no;
int asymmetric:1,
protocol_accept:1,
no_redis_update:1,
unidirectional:1,
trust_address:1,

@ -36,6 +36,238 @@ my ($sock_a, $sock_b, $sock_c, $sock_d, $port_a, $port_b, $ssrc, $resp,
# stray answer protocol changes
new_call;
offer('stray answer protocol changes, default', {
ICE => 'remove',
flags => [],
'transport-protocol' => 'RTP/SAVP',
DTLS => 'off',
}, <<SDP);
v=0
o=Z 58440449 0 IN IP4 89.225.243.254
s=Z
c=IN IP4 89.225.243.254
t=0 0
m=audio 8000 RTP/AVP 0 101 8
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv
--------------------------------------
v=0
o=Z 58440449 0 IN IP4 89.225.243.254
s=Z
c=IN IP4 203.0.113.1
t=0 0
m=audio PORT RTP/SAVP 0 101 8
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=rtpmap:8 PCMA/8000
a=fmtp:101 0-16
a=sendrecv
a=rtcp:PORT
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:CRYPTO128
a=crypto:2 AES_CM_128_HMAC_SHA1_32 inline:CRYPTO128
a=crypto:3 AES_192_CM_HMAC_SHA1_80 inline:CRYPTO192
a=crypto:4 AES_192_CM_HMAC_SHA1_32 inline:CRYPTO192
a=crypto:5 AES_256_CM_HMAC_SHA1_80 inline:CRYPTO256
a=crypto:6 AES_256_CM_HMAC_SHA1_32 inline:CRYPTO256
a=crypto:7 F8_128_HMAC_SHA1_80 inline:CRYPTO128
a=crypto:8 F8_128_HMAC_SHA1_32 inline:CRYPTO128
a=crypto:9 NULL_HMAC_SHA1_80 inline:CRYPTO128
a=crypto:10 NULL_HMAC_SHA1_32 inline:CRYPTO128
SDP
answer('stray answer protocol changes, default', {
ICE => 'remove',
flags => [],
DTLS => 'off',
}, <<SDP);
v=0
o=- 810178487 810178487 IN IP4 0.0.0.0
s=-
c=IN IP4 0.0.0.0
t=0 0
m=audio 40444 RTP/SAVPF 0 101 8
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=rtpmap:8 PCMA/8000
a=direction:both
a=sendonly
a=rtcp:40445
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:05sglrIFGQuJpqOblofVYYh+PF93dGyOjFW6Q934
--------------------------------------
v=0
o=- 810178487 810178487 IN IP4 0.0.0.0
s=-
c=IN IP4 0.0.0.0
t=0 0
m=audio PORT RTP/AVP 0 101 8
a=direction:both
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=rtpmap:8 PCMA/8000
a=sendonly
a=rtcp:PORT
SDP
new_call;
offer('stray answer protocol changes, proto accept', {
ICE => 'remove',
flags => [],
'transport-protocol' => 'RTP/SAVP',
DTLS => 'off',
}, <<SDP);
v=0
o=Z 58440449 0 IN IP4 89.225.243.254
s=Z
c=IN IP4 89.225.243.254
t=0 0
m=audio 8000 RTP/AVP 0 101 8
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv
--------------------------------------
v=0
o=Z 58440449 0 IN IP4 89.225.243.254
s=Z
c=IN IP4 203.0.113.1
t=0 0
m=audio PORT RTP/SAVP 0 101 8
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=rtpmap:8 PCMA/8000
a=fmtp:101 0-16
a=sendrecv
a=rtcp:PORT
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:CRYPTO128
a=crypto:2 AES_CM_128_HMAC_SHA1_32 inline:CRYPTO128
a=crypto:3 AES_192_CM_HMAC_SHA1_80 inline:CRYPTO192
a=crypto:4 AES_192_CM_HMAC_SHA1_32 inline:CRYPTO192
a=crypto:5 AES_256_CM_HMAC_SHA1_80 inline:CRYPTO256
a=crypto:6 AES_256_CM_HMAC_SHA1_32 inline:CRYPTO256
a=crypto:7 F8_128_HMAC_SHA1_80 inline:CRYPTO128
a=crypto:8 F8_128_HMAC_SHA1_32 inline:CRYPTO128
a=crypto:9 NULL_HMAC_SHA1_80 inline:CRYPTO128
a=crypto:10 NULL_HMAC_SHA1_32 inline:CRYPTO128
SDP
answer('stray answer protocol changes, proto accept', {
ICE => 'remove',
flags => [],
DTLS => 'off',
'transport-protocol' => 'accept',
}, <<SDP);
v=0
o=- 810178487 810178487 IN IP4 0.0.0.0
s=-
c=IN IP4 0.0.0.0
t=0 0
m=audio 40444 RTP/SAVPF 0 101 8
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=rtpmap:8 PCMA/8000
a=direction:both
a=sendonly
a=rtcp:40445
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:05sglrIFGQuJpqOblofVYYh+PF93dGyOjFW6Q934
--------------------------------------
v=0
o=- 810178487 810178487 IN IP4 0.0.0.0
s=-
c=IN IP4 0.0.0.0
t=0 0
m=audio PORT RTP/SAVPF 0 101 8
a=direction:both
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=rtpmap:8 PCMA/8000
a=sendonly
a=rtcp:PORT
SDP
new_call;
offer('stray answer protocol changes, proto override', {
ICE => 'remove',
flags => [],
'transport-protocol' => 'RTP/SAVP',
DTLS => 'off',
}, <<SDP);
v=0
o=Z 58440449 0 IN IP4 89.225.243.254
s=Z
c=IN IP4 89.225.243.254
t=0 0
m=audio 8000 RTP/AVP 0 101 8
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv
--------------------------------------
v=0
o=Z 58440449 0 IN IP4 89.225.243.254
s=Z
c=IN IP4 203.0.113.1
t=0 0
m=audio PORT RTP/SAVP 0 101 8
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=rtpmap:8 PCMA/8000
a=fmtp:101 0-16
a=sendrecv
a=rtcp:PORT
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:CRYPTO128
a=crypto:2 AES_CM_128_HMAC_SHA1_32 inline:CRYPTO128
a=crypto:3 AES_192_CM_HMAC_SHA1_80 inline:CRYPTO192
a=crypto:4 AES_192_CM_HMAC_SHA1_32 inline:CRYPTO192
a=crypto:5 AES_256_CM_HMAC_SHA1_80 inline:CRYPTO256
a=crypto:6 AES_256_CM_HMAC_SHA1_32 inline:CRYPTO256
a=crypto:7 F8_128_HMAC_SHA1_80 inline:CRYPTO128
a=crypto:8 F8_128_HMAC_SHA1_32 inline:CRYPTO128
a=crypto:9 NULL_HMAC_SHA1_80 inline:CRYPTO128
a=crypto:10 NULL_HMAC_SHA1_32 inline:CRYPTO128
SDP
answer('stray answer protocol changes, proto accept', {
ICE => 'remove',
flags => [],
DTLS => 'off',
'transport-protocol' => 'RTP/AVPF',
}, <<SDP);
v=0
o=- 810178487 810178487 IN IP4 0.0.0.0
s=-
c=IN IP4 0.0.0.0
t=0 0
m=audio 40444 RTP/SAVPF 0 101 8
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=rtpmap:8 PCMA/8000
a=direction:both
a=sendonly
a=rtcp:40445
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:05sglrIFGQuJpqOblofVYYh+PF93dGyOjFW6Q934
--------------------------------------
v=0
o=- 810178487 810178487 IN IP4 0.0.0.0
s=-
c=IN IP4 0.0.0.0
t=0 0
m=audio PORT RTP/AVPF 0 101 8
a=direction:both
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=rtpmap:8 PCMA/8000
a=sendonly
a=rtcp:PORT
SDP
# GH 1058
new_call;

Loading…
Cancel
Save