diff --git a/daemon/call.c b/daemon/call.c index 2fb2ad8dc..c614be23a 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -867,6 +867,7 @@ static struct endpoint_map *__get_endpoint_map(struct call_media *media, unsigne return NULL; __C_DBG("allocating stream_fds for %u ports", num_ports); + MEDIA_CLEAR(media, PUBLIC); struct socket_intf_list *il; while ((il = t_queue_pop_head(&intf_sockets))) { diff --git a/daemon/media_socket.c b/daemon/media_socket.c index 2ebc4641b..1beff5541 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -2427,6 +2427,10 @@ static bool media_packet_address_check(struct packet_handler_ctx *phc) phc->mp.stream->endpoint.port); goto out; } + if (!MEDIA_ISSET(phc->mp.media, PUBLIC)) { + __C_DBG("media not answered"); + goto out; + } // GH #697 - apparent Asterisk bug where it sends stray RTCP to the RTP port. // work around this by detecting this situation and ignoring the packet for diff --git a/daemon/sdp.c b/daemon/sdp.c index 157370af5..a20de5b25 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -3253,6 +3253,8 @@ int sdp_create(str *out, struct call_monologue *monologue, sdp_ng_flags *flags) if (!sdp_out_add_media(s, media, port)) goto err; + MEDIA_SET(media, PUBLIC); + /* print media level attributes */ print_sdp_media_section(s, media, &sdp_address, copy_media, source_media, rtp_ps, rtp_ps_link, flags); diff --git a/include/call.h b/include/call.h index f32770a3f..19d0b49d6 100644 --- a/include/call.h +++ b/include/call.h @@ -215,6 +215,7 @@ enum { #define MEDIA_FLAG_REAL_SENDONLY (1LL << 35) #define MEDIA_FLAG_SELECT_PT (1LL << 36) #define MEDIA_FLAG_RECRYPT (1LL << 37) +#define MEDIA_FLAG_PUBLIC (1LL << 38) /* struct call_monologue */ #define ML_FLAG_REC_FORWARDING (1LL << 16) diff --git a/t/auto-daemon-tests-heuristic.pl b/t/auto-daemon-tests-heuristic.pl index 20e3b5156..80cb34147 100755 --- a/t/auto-daemon-tests-heuristic.pl +++ b/t/auto-daemon-tests-heuristic.pl @@ -580,5 +580,56 @@ rcv_no($sock_e); +($sock_a, $sock_b, $sock_c) = new_call( + [qw(198.51.100.1 2188)], # caller + [qw(198.51.100.3 2190)], # callee - from SDP + [qw(198.51.100.3 2210)], # hijack +); + +($port_a) = offer('offer only', { flags => ['strict source'] }, < '0 8', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2228236', + 'media_flags' => '274880135180', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '1', @@ -404,7 +404,7 @@ $json_exp = { 'format_str' => '8', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2293772', + 'media_flags' => '274880200716', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '1', @@ -415,7 +415,7 @@ $json_exp = { 'format_str' => '8', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '65548', + 'media_flags' => '274877972492', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '0', @@ -665,7 +665,7 @@ $json_exp = { 'format_str' => '0 8', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2228236', + 'media_flags' => '274880135180', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '1', @@ -922,7 +922,7 @@ $json_exp = { 'format_str' => '0 8', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2293772', + 'media_flags' => '274880200716', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '1', @@ -933,7 +933,7 @@ $json_exp = { 'format_str' => '0 8', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '65548', + 'media_flags' => '274877972492', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '0', @@ -1211,7 +1211,7 @@ $json_exp = { 'format_str' => '0 8', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2293772', + 'media_flags' => '274880200716', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '1', @@ -1222,7 +1222,7 @@ $json_exp = { 'format_str' => '0 8', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '65548', + 'media_flags' => '274877972492', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '0', @@ -1233,7 +1233,7 @@ $json_exp = { 'format_str' => '0 8', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2097156', + 'media_flags' => '274880004100', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '2', @@ -1244,7 +1244,7 @@ $json_exp = { 'format_str' => '0 8', 'index' => '2', 'logical_intf' => 'foo', - 'media_flags' => '2097156', + 'media_flags' => '274880004100', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '2', @@ -1566,12 +1566,12 @@ a=rtcp:PORT SDP -$json_exp->{'media-1'}{media_flags} = '2293772'; -$json_exp->{'media-0'}{media_flags} = '65548'; +$json_exp->{'media-1'}{media_flags} = '274880200716'; +$json_exp->{'media-0'}{media_flags} = '274877972492'; $json_exp->{'media-2'}{format_str} = '8'; -$json_exp->{'media-2'}{media_flags} = '2162692'; +$json_exp->{'media-2'}{media_flags} = '274880069636'; $json_exp->{'media-3'}{format_str} = '8'; -$json_exp->{'media-3'}{media_flags} = '2162692'; +$json_exp->{'media-3'}{media_flags} = '274880069636'; $json_exp->{'payload_types-2'}[0] = '8/PCMA/8000//0/20//'; $#{$json_exp->{'payload_types-2'}} = 0; $json_exp->{'payload_types-3'}[0] = '8/PCMA/8000//0/20//'; @@ -1653,7 +1653,7 @@ $json_exp = { 'format_str' => '0 8 9', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '65544', + 'media_flags' => '274877972488', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '0', @@ -1810,7 +1810,7 @@ $json_exp = { 'format_str' => '0 8 9', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '65544', + 'media_flags' => '274877972488', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '0', @@ -1821,7 +1821,7 @@ $json_exp = { 'format_str' => '0 8 9', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2097156', + 'media_flags' => '274880004100', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '1', @@ -2047,7 +2047,7 @@ $json_exp = { 'format_str' => '0 8 9', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '65544', + 'media_flags' => '274877972488', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '0', @@ -2058,7 +2058,7 @@ $json_exp = { 'format_str' => '0', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2162692', + 'media_flags' => '274880069636', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '1', @@ -2298,7 +2298,7 @@ $json_exp = { 'format_str' => '0 8 9', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '65544', + 'media_flags' => '274877972488', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '0', @@ -2309,7 +2309,7 @@ $json_exp = { 'format_str' => '0', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2162692', + 'media_flags' => '274880069636', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '1', @@ -2320,7 +2320,7 @@ $json_exp = { 'format_str' => '0 8 9', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2097156', + 'media_flags' => '274880004100', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '2', @@ -2565,7 +2565,7 @@ a=rtcp:PORT SDP $json_exp->{'media-2'}{format_str} = '0'; -$json_exp->{'media-2'}{media_flags} = '2162692'; +$json_exp->{'media-2'}{media_flags} = '274880069636'; $json_exp->{'stream-1'}{ps_flags} = '1179649'; $json_exp->{'stream-4'}{advertised_endpoint} = '198.51.100.14:6046'; $json_exp->{'stream-4'}{endpoint} = '198.51.100.14:6046'; diff --git a/t/auto-daemon-tests-redis.pl b/t/auto-daemon-tests-redis.pl index 13694786b..ce5d86f48 100755 --- a/t/auto-daemon-tests-redis.pl +++ b/t/auto-daemon-tests-redis.pl @@ -147,7 +147,7 @@ $json_exp = { 'format_str' => '0 8', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2228236', + 'media_flags' => '274880135180', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '1', @@ -405,7 +405,7 @@ $json_exp = { 'format_str' => '8', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2293772', + 'media_flags' => '274880200716', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '1', @@ -416,7 +416,7 @@ $json_exp = { 'format_str' => '8', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '65548', + 'media_flags' => '274877972492', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '0', @@ -666,7 +666,7 @@ $json_exp = { 'format_str' => '8', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2293772', + 'media_flags' => '274880200716', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '1', @@ -677,7 +677,7 @@ $json_exp = { 'format_str' => '8', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '65548', + 'media_flags' => '274877972492', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '0', @@ -927,7 +927,7 @@ $json_exp = { 'format_str' => '0 8', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2228236', + 'media_flags' => '274880135180', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '1', @@ -1184,7 +1184,7 @@ $json_exp = { 'format_str' => '0 8', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2293772', + 'media_flags' => '274880200716', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '1', @@ -1195,7 +1195,7 @@ $json_exp = { 'format_str' => '0 8', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '65548', + 'media_flags' => '274877972492', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '0', @@ -1473,7 +1473,7 @@ $json_exp = { 'format_str' => '0 8', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2293772', + 'media_flags' => '274880200716', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '1', @@ -1484,7 +1484,7 @@ $json_exp = { 'format_str' => '0 8', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '65548', + 'media_flags' => '274877972492', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '0', @@ -1495,7 +1495,7 @@ $json_exp = { 'format_str' => '0 8', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2097156', + 'media_flags' => '274880004100', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '2', @@ -1506,7 +1506,7 @@ $json_exp = { 'format_str' => '0 8', 'index' => '2', 'logical_intf' => 'foo', - 'media_flags' => '2097156', + 'media_flags' => '274880004100', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '2', @@ -1828,12 +1828,12 @@ a=rtcp:PORT SDP -$json_exp->{'media-1'}{media_flags} = '2293772'; -$json_exp->{'media-0'}{media_flags} = '65548'; +$json_exp->{'media-1'}{media_flags} = '274880200716'; +$json_exp->{'media-0'}{media_flags} = '274877972492'; $json_exp->{'media-2'}{format_str} = '8'; -$json_exp->{'media-2'}{media_flags} = '2162692'; +$json_exp->{'media-2'}{media_flags} = '274880069636'; $json_exp->{'media-3'}{format_str} = '8'; -$json_exp->{'media-3'}{media_flags} = '2162692'; +$json_exp->{'media-3'}{media_flags} = '274880069636'; $json_exp->{'payload_types-2'}[0] = '8/PCMA/8000//0/20//'; $#{$json_exp->{'payload_types-2'}} = 0; $json_exp->{'payload_types-3'}[0] = '8/PCMA/8000//0/20//'; @@ -1914,7 +1914,7 @@ $json_exp = { 'format_str' => '0 8 9', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '65544', + 'media_flags' => '274877972488', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '0', @@ -2071,7 +2071,7 @@ $json_exp = { 'format_str' => '0 8 9', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '65544', + 'media_flags' => '274877972488', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '0', @@ -2082,7 +2082,7 @@ $json_exp = { 'format_str' => '0 8 9', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2097156', + 'media_flags' => '274880004100', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '1', @@ -2308,7 +2308,7 @@ $json_exp = { 'format_str' => '0 8 9', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '65544', + 'media_flags' => '274877972488', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '0', @@ -2319,7 +2319,7 @@ $json_exp = { 'format_str' => '0', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2162692', + 'media_flags' => '274880069636', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '1', @@ -2559,7 +2559,7 @@ $json_exp = { 'format_str' => '0 8 9', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '65544', + 'media_flags' => '274877972488', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '0', @@ -2570,7 +2570,7 @@ $json_exp = { 'format_str' => '0', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2162692', + 'media_flags' => '274880069636', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '1', @@ -2581,7 +2581,7 @@ $json_exp = { 'format_str' => '0 8 9', 'index' => '1', 'logical_intf' => 'foo', - 'media_flags' => '2097156', + 'media_flags' => '274880004100', 'protocol' => 'RTP/AVP', 'ptime' => '0', 'tag' => '2', @@ -2826,7 +2826,7 @@ a=rtcp:PORT SDP $json_exp->{'media-2'}{format_str} = '0'; -$json_exp->{'media-2'}{media_flags} = '2162692'; +$json_exp->{'media-2'}{media_flags} = '274880069636'; $json_exp->{'stream-1'}{ps_flags} = '1179649'; $json_exp->{'stream-4'}{advertised_endpoint} = '198.51.100.14:6046'; $json_exp->{'stream-4'}{endpoint} = '198.51.100.14:6046';