TT#112250 don't change ports when endpoint is talking ICE

Change-Id: I0e60534d6d3cb62d25b8d865da02c3472cf0994e
pull/1218/head
Richard Fuchs 5 years ago
parent 8aecb6a98a
commit eb1157d386

@ -702,6 +702,13 @@ Optionally included keys are:
Forces *rtpengine* to retain its local ports during a signalling exchange even when the
remote endpoint changes its port.
- `no port latching`
Port latching is enabled by default for endpoints which speak
ICE. With this option preset, a remote port change will result
in a local port change even for endpoints which speak ICE,
which will imply an ICE restart.
- `record call`
Identical to setting `record call` to `on` (see below).

@ -836,6 +836,8 @@ static struct endpoint_map *__get_endpoint_map(struct call_media *media, unsigne
if (flags && flags->port_latching)
/* do nothing - ignore endpoint addresses */ ;
else if (MEDIA_ISSET(media, ICE) && (!flags || !flags->no_port_latching))
; // don't change endpoint address if we're talking ICE
else if (is_addr_unspecified(&ep->address) || is_addr_unspecified(&em->endpoint.address)) {
/* handle zero endpoint address: only compare ports */
if (ep->port != em->endpoint.port)
@ -897,23 +899,22 @@ next_il:
}
static void __assign_stream_fds(struct call_media *media, GQueue *intf_sfds) {
GList *l, *k;
struct packet_stream *ps;
struct stream_fd *sfd, *intf_sfd;
struct intf_list *il;
int sfd_found;
int reset_ice = 0;
for (GList *k = media->streams.head; k; k = k->next) {
struct packet_stream *ps = k->data;
for (k = media->streams.head; k; k = k->next) {
ps = k->data;
// use opaque pointer to detect changes
void *old_selected_sfd = ps->selected_sfd;
g_queue_clear(&ps->sfds);
sfd_found = 0;
intf_sfd = NULL;
int sfd_found = 0;
struct stream_fd *intf_sfd = NULL;
for (l = intf_sfds->head; l; l = l->next) {
il = l->data;
for (GList *l = intf_sfds->head; l; l = l->next) {
struct intf_list *il = l->data;
sfd = g_queue_peek_nth(&il->list, ps->component - 1);
struct stream_fd *sfd = g_queue_peek_nth(&il->list, ps->component - 1);
if (!sfd) return ;
sfd->stream = ps;
@ -932,11 +933,12 @@ static void __assign_stream_fds(struct call_media *media, GQueue *intf_sfds) {
ps->selected_sfd = g_queue_peek_nth(&ps->sfds, 0);
}
/* XXX:
* handle crypto/dtls resets by moving contexts into sfd struct.
* handle ice resets too.
*/
if (old_selected_sfd && ps->selected_sfd && old_selected_sfd != ps->selected_sfd)
reset_ice = 1;
}
if (reset_ice && media->ice_agent)
ice_restart(media->ice_agent);
}
static int __wildcard_endpoint_map(struct call_media *media, unsigned int num_ports) {

@ -816,6 +816,9 @@ static void call_ng_flags_flags(struct sdp_ng_flags *out, str *s, void *dummy) {
case CSH_LOOKUP("port-latching"):
out->port_latching = 1;
break;
case CSH_LOOKUP("no-port-latching"):
out->no_port_latching = 1;
break;
case CSH_LOOKUP("generate-mid"):
out->generate_mid = 1;
break;

@ -69,6 +69,7 @@ struct sdp_ng_flags {
unidirectional:1,
trust_address:1,
port_latching:1,
no_port_latching:1,
replace_origin:1,
replace_sess_conn:1,
replace_sdp_version:1,

@ -33,13 +33,185 @@ my $pcma_5 = "\xad\xac\xa2\xa6\xbd\x9a\x06\x3f\x26\x2d\x2c\x2d\x26\x3f\x06\x9a\x
my ($sock_a, $sock_b, $sock_c, $sock_d, $port_a, $port_b, $ssrc, $ssrc_b, $resp,
$sock_ax, $sock_bx, $port_ax, $port_bx,
$srtp_ctx_a, $srtp_ctx_b, $srtp_ctx_a_rev, $srtp_ctx_b_rev,
$srtp_ctx_a, $srtp_ctx_b, $srtp_ctx_a_rev, $srtp_ctx_b_rev, $ufrag_a, $ufrag_b,
@ret1, @ret2, @ret3, @ret4, $srtp_key_a, $srtp_key_b, $ts, $seq);
new_call;
($port_a, undef, $ufrag_a) = offer('ICE re-invite',
{ ICE => 'force', }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.101.40
s=tester
t=0 0
m=audio 16478 RTP/AVP 8
c=IN IP4 198.51.100.1
----------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.101.40
s=tester
t=0 0
m=audio PORT RTP/AVP 8
c=IN IP4 203.0.113.1
a=rtpmap:8 PCMA/8000
a=sendrecv
a=rtcp:PORT
a=ice-ufrag:ICEUFRAG
a=ice-pwd:ICEPWD
a=candidate:ICEBASE 1 UDP 2130706431 203.0.113.1 PORT typ host
a=candidate:ICEBASE 1 UDP 2130706175 2001:db8:4321::1 PORT typ host
a=candidate:ICEBASE 2 UDP 2130706430 203.0.113.1 PORT typ host
a=candidate:ICEBASE 2 UDP 2130706174 2001:db8:4321::1 PORT typ host
SDP
($port_b, undef, $ufrag_b) = offer('ICE re-invite',
{ ICE => 'force', }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.101.40
s=tester
t=0 0
m=audio 16478 RTP/AVP 8
c=IN IP4 198.51.100.1
----------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.101.40
s=tester
t=0 0
m=audio PORT RTP/AVP 8
c=IN IP4 203.0.113.1
a=rtpmap:8 PCMA/8000
a=sendrecv
a=rtcp:PORT
a=ice-ufrag:ICEUFRAG
a=ice-pwd:ICEPWD
a=candidate:ICEBASE 1 UDP 2130706431 203.0.113.1 PORT typ host
a=candidate:ICEBASE 1 UDP 2130706175 2001:db8:4321::1 PORT typ host
a=candidate:ICEBASE 2 UDP 2130706430 203.0.113.1 PORT typ host
a=candidate:ICEBASE 2 UDP 2130706174 2001:db8:4321::1 PORT typ host
SDP
is($port_a, $port_b, 'port match');
is($ufrag_a, $ufrag_b, 'ufrag match');
($port_a, undef, $ufrag_a) = offer('ICE re-invite port change',
{ ICE => 'force', }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.101.40
s=tester
t=0 0
m=audio 16480 RTP/AVP 8
c=IN IP4 198.51.100.1
----------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.101.40
s=tester
t=0 0
m=audio PORT RTP/AVP 8
c=IN IP4 203.0.113.1
a=rtpmap:8 PCMA/8000
a=sendrecv
a=rtcp:PORT
a=ice-ufrag:ICEUFRAG
a=ice-pwd:ICEPWD
a=candidate:ICEBASE 1 UDP 2130706431 203.0.113.1 PORT typ host
a=candidate:ICEBASE 1 UDP 2130706175 2001:db8:4321::1 PORT typ host
a=candidate:ICEBASE 2 UDP 2130706430 203.0.113.1 PORT typ host
a=candidate:ICEBASE 2 UDP 2130706174 2001:db8:4321::1 PORT typ host
SDP
is($port_a, $port_b, 'port match');
is($ufrag_a, $ufrag_b, 'ufrag match');
new_call;
($port_a, undef, $ufrag_a) = offer('ICE re-invite',
{ ICE => 'force', flags => ['no port latching']}, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.101.40
s=tester
t=0 0
m=audio 16478 RTP/AVP 8
c=IN IP4 198.51.100.1
----------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.101.40
s=tester
t=0 0
m=audio PORT RTP/AVP 8
c=IN IP4 203.0.113.1
a=rtpmap:8 PCMA/8000
a=sendrecv
a=rtcp:PORT
a=ice-ufrag:ICEUFRAG
a=ice-pwd:ICEPWD
a=candidate:ICEBASE 1 UDP 2130706431 203.0.113.1 PORT typ host
a=candidate:ICEBASE 1 UDP 2130706175 2001:db8:4321::1 PORT typ host
a=candidate:ICEBASE 2 UDP 2130706430 203.0.113.1 PORT typ host
a=candidate:ICEBASE 2 UDP 2130706174 2001:db8:4321::1 PORT typ host
SDP
($port_b, undef, $ufrag_b) = offer('ICE re-invite',
{ ICE => 'force', flags => ['no port latching']}, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.101.40
s=tester
t=0 0
m=audio 16478 RTP/AVP 8
c=IN IP4 198.51.100.1
----------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.101.40
s=tester
t=0 0
m=audio PORT RTP/AVP 8
c=IN IP4 203.0.113.1
a=rtpmap:8 PCMA/8000
a=sendrecv
a=rtcp:PORT
a=ice-ufrag:ICEUFRAG
a=ice-pwd:ICEPWD
a=candidate:ICEBASE 1 UDP 2130706431 203.0.113.1 PORT typ host
a=candidate:ICEBASE 1 UDP 2130706175 2001:db8:4321::1 PORT typ host
a=candidate:ICEBASE 2 UDP 2130706430 203.0.113.1 PORT typ host
a=candidate:ICEBASE 2 UDP 2130706174 2001:db8:4321::1 PORT typ host
SDP
is($port_a, $port_b, 'port match');
is($ufrag_a, $ufrag_b, 'ufrag match');
($port_a, undef, $ufrag_a) = offer('ICE re-invite port change no port latching',
{ ICE => 'force', flags => ['no port latching']}, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.101.40
s=tester
t=0 0
m=audio 16480 RTP/AVP 8
c=IN IP4 198.51.100.1
----------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.101.40
s=tester
t=0 0
m=audio PORT RTP/AVP 8
c=IN IP4 203.0.113.1
a=rtpmap:8 PCMA/8000
a=sendrecv
a=rtcp:PORT
a=ice-ufrag:ICEUFRAG
a=ice-pwd:ICEPWD
a=candidate:ICEBASE 1 UDP 2130706431 203.0.113.1 PORT typ host
a=candidate:ICEBASE 1 UDP 2130706175 2001:db8:4321::1 PORT typ host
a=candidate:ICEBASE 2 UDP 2130706430 203.0.113.1 PORT typ host
a=candidate:ICEBASE 2 UDP 2130706174 2001:db8:4321::1 PORT typ host
SDP
isnt($port_a, $port_b, 'port match');
isnt($ufrag_a, $ufrag_b, 'ufrag match');
new_call;
offer('null address test A',

Loading…
Cancel
Save