sip: Use per origin IP instead of a global IP

Sofia detects a NAT by presence of the "received" parameter in the Via header in
the response to a REGISTER. Sofia will then update the Contact header to use the
IP as reported by the registrar.

The "received" parameter MUST be included in the response according to
https://datatracker.ietf.org/doc/html/rfc3261#section-18.2.1
when the registrar detects a difference between the domain part of the top Via
header and the packet source address but practice has shown that this will not
always be the case.

Addditionally this change allows us to have origins bound to different network
interfaces which would be useful when a registrar can only be accessed through a
VPN.

This also fixes an issue with SDP introduced in
36880c3d34 which was only seen on some SIP
providers:

The session name ("s=") line is not relevant for establishing a connection,
the connection data (c=") line is.

See https://datatracker.ietf.org/doc/html/rfc4566 section 5.3 and 5.7
This commit is contained in:
Evangelos Ribeiro Tzaras
2021-11-23 00:58:08 +01:00
parent ae4053e1c9
commit 8b126484cb
6 changed files with 105 additions and 20 deletions

View File

@@ -445,7 +445,7 @@ test_sip_media_manager (void)
/* PCMA RTP */
sdp_message =
calls_sip_media_manager_get_capabilities (manager, 40002, FALSE, codecs);
calls_sip_media_manager_get_capabilities (manager, NULL, 40002, FALSE, codecs);
g_assert_true (sdp_message);
g_assert_true (find_string_in_sdp_message (sdp_message,
@@ -461,7 +461,7 @@ test_sip_media_manager (void)
/* PCMA SRTP */
sdp_message =
calls_sip_media_manager_get_capabilities (manager, 42002, TRUE, codecs);
calls_sip_media_manager_get_capabilities (manager, NULL, 42002, TRUE, codecs);
g_assert_true (sdp_message);
g_assert_true (find_string_in_sdp_message (sdp_message,
"m=audio 42002 RTP/SAVP 8"));
@@ -475,7 +475,7 @@ test_sip_media_manager (void)
codecs = g_list_append (NULL, media_codec_by_name ("G722"));
sdp_message =
calls_sip_media_manager_get_capabilities (manager, 42042, FALSE, codecs);
calls_sip_media_manager_get_capabilities (manager, NULL, 42042, FALSE, codecs);
g_assert_true (sdp_message);
g_assert_true (find_string_in_sdp_message (sdp_message,
@@ -496,7 +496,7 @@ test_sip_media_manager (void)
codecs = g_list_append (codecs, media_codec_by_name ("PCMA"));
sdp_message =
calls_sip_media_manager_get_capabilities (manager, 33340, FALSE, codecs);
calls_sip_media_manager_get_capabilities (manager, NULL, 33340, FALSE, codecs);
g_assert_true (sdp_message);
g_assert_true (find_string_in_sdp_message (sdp_message,
@@ -520,7 +520,7 @@ test_sip_media_manager (void)
codecs = g_list_append (codecs, media_codec_by_name ("PCMU"));
sdp_message =
calls_sip_media_manager_get_capabilities (manager, 18098, TRUE, codecs);
calls_sip_media_manager_get_capabilities (manager, NULL, 18098, TRUE, codecs);
g_assert_true (sdp_message);
g_assert_true (find_string_in_sdp_message (sdp_message,
@@ -535,7 +535,7 @@ test_sip_media_manager (void)
g_test_expect_message ("CallsSipMediaManager", G_LOG_LEVEL_WARNING,
"No supported codecs found. Can't build meaningful SDP message");
sdp_message =
calls_sip_media_manager_get_capabilities (manager, 25048, FALSE, NULL);
calls_sip_media_manager_get_capabilities (manager, NULL, 25048, FALSE, NULL);
g_test_assert_expected_messages ();
g_assert_true (sdp_message);