From 4dab426ecff089ef9aa9430656e653fca5e8149f Mon Sep 17 00:00:00 2001 From: Joseph Nadiv Date: Tue, 23 Nov 2021 12:40:56 -0500 Subject: [PATCH] [mod_sofia] Rewrite rport even if endpoint specifies port in contact If NDLB-force-rport is enabled, we rewrite the rport regardless of what the endpoint thinks the port should be. We do this by checking the status of server_rport_level before writing the port. Fixes #1457 --- src/mod/endpoints/mod_sofia/sofia_reg.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 9791190f5f..6f3ab51485 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -1546,7 +1546,7 @@ uint8_t sofia_reg_handle_register_token(nua_t *nua, sofia_profile_t *profile, nu exptime = 30; } - if (port) { + if (port && profile->server_rport_level == 0) { switch_snprintf(new_port, sizeof(new_port), ":%s", port); } @@ -1662,11 +1662,12 @@ uint8_t sofia_reg_handle_register_token(nua_t *nua, sofia_profile_t *profile, nu } if (!is_tcp && !is_tls && (zstr(network_ip) || !switch_check_network_list_ip(network_ip, profile->local_network)) && - profile->server_rport_level >= 2 && sip->sip_user_agent && + ((profile->server_rport_level == 3 && sip->sip_user_agent && sip->sip_user_agent->g_string && ( !strncasecmp(sip->sip_user_agent->g_string, "Polycom", 7) || !strncasecmp(sip->sip_user_agent->g_string, "KIRK Wireless Server", 20) || - !strncasecmp(sip->sip_user_agent->g_string, "ADTRAN_Total_Access", 19) )) { + !strncasecmp(sip->sip_user_agent->g_string, "ADTRAN_Total_Access", 19) )) + || (profile->server_rport_level == 1 || profile->server_rport_level == 2))) { if (sip->sip_via) { const char *host = sip->sip_via->v_host; const char *c_port = sip->sip_via->v_port;