mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-27 07:59:20 +00:00
change behavior of linphone_core_get_sip_transports() if random port selection was specified.
Only linphone_core_get_sip_transports_used() will return the real port if random port selection was specified.
This commit is contained in:
parent
250495034e
commit
266207c5f0
4 changed files with 35 additions and 8 deletions
|
|
@ -569,22 +569,34 @@ int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int i
|
|||
sal_address_destroy(sal_addr);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void remove_listening_point(belle_sip_listening_point_t* lp,belle_sip_provider_t* prov) {
|
||||
belle_sip_provider_remove_listening_point(prov,lp);
|
||||
}
|
||||
|
||||
int sal_get_listening_port(Sal *ctx, SalTransport tr){
|
||||
const char *tpn=sal_transport_to_string(tr);
|
||||
belle_sip_listening_point_t *lp=belle_sip_provider_get_listening_point(ctx->prov, tpn);
|
||||
if (lp){
|
||||
return belle_sip_listening_point_get_port(lp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sal_unlisten_ports(Sal *ctx){
|
||||
const belle_sip_list_t * lps = belle_sip_provider_get_listening_points(ctx->prov);
|
||||
belle_sip_list_t * tmp_list = belle_sip_list_copy(lps);
|
||||
belle_sip_list_for_each2 (tmp_list,(void (*)(void*,void*))remove_listening_point,ctx->prov);
|
||||
belle_sip_list_free(tmp_list);
|
||||
|
||||
ms_message("sal_unlisten_ports done");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ortp_socket_t sal_get_socket(Sal *ctx){
|
||||
ms_warning("sal_get_socket is deprecated");
|
||||
return -1;
|
||||
}
|
||||
|
||||
void sal_set_user_agent(Sal *ctx, const char *user_agent){
|
||||
belle_sip_header_user_agent_set_products(ctx->user_agent,NULL);
|
||||
belle_sip_header_user_agent_add_product(ctx->user_agent,user_agent);
|
||||
|
|
|
|||
|
|
@ -1521,7 +1521,7 @@ static void update_primary_contact(LinphoneCore *lc){
|
|||
lc->sip_conf.loopback_only=TRUE;
|
||||
}else lc->sip_conf.loopback_only=FALSE;
|
||||
linphone_address_set_domain(url,tmp);
|
||||
linphone_address_set_port(url,linphone_core_get_sip_port (lc));
|
||||
linphone_address_set_port(url,linphone_core_get_sip_port(lc));
|
||||
guessed=linphone_address_as_string(url);
|
||||
lc->sip_conf.guessed_contact=guessed;
|
||||
linphone_address_destroy(url);
|
||||
|
|
@ -1833,8 +1833,9 @@ void linphone_core_set_use_rfc2833_for_dtmf(LinphoneCore *lc,bool_t use_rfc2833)
|
|||
**/
|
||||
int linphone_core_get_sip_port(LinphoneCore *lc)
|
||||
{
|
||||
LCSipTransports *tr=&lc->sip_conf.transports;
|
||||
return tr->udp_port>0 ? tr->udp_port : (tr->tcp_port > 0 ? tr->tcp_port : tr->tls_port);
|
||||
LCSipTransports tr;
|
||||
linphone_core_get_sip_transports_used(lc,&tr);
|
||||
return tr.udp_port>0 ? tr.udp_port : (tr.tcp_port > 0 ? tr.tcp_port : tr.tls_port);
|
||||
}
|
||||
|
||||
#if !USE_BELLE_SIP
|
||||
|
|
@ -1949,7 +1950,7 @@ bool_t linphone_core_sip_transport_supported(const LinphoneCore *lc, LinphoneTra
|
|||
* Sets the ports to be used for each of transport (UDP or TCP)
|
||||
*
|
||||
* A zero value port for a given transport means the transport
|
||||
* is not used.
|
||||
* is not used. A value of LC_SIP_TRANSPORT_RANDOM (-1) means the port is to be choosen randomly by the system.
|
||||
*
|
||||
* @ingroup network_parameters
|
||||
**/
|
||||
|
|
@ -1990,9 +1991,9 @@ int linphone_core_set_sip_transports(LinphoneCore *lc, const LCSipTransports * t
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves the ports used for each transport (udp, tcp).
|
||||
* Retrieves the port configuration used for each transport (udp, tcp, tls).
|
||||
* A zero value port for a given transport means the transport
|
||||
* is not used.
|
||||
* is not used. A value of LC_SIP_TRANSPORT_RANDOM (-1) means the port is to be choosen randomly by the system.
|
||||
* @ingroup network_parameters
|
||||
**/
|
||||
int linphone_core_get_sip_transports(LinphoneCore *lc, LCSipTransports *tr){
|
||||
|
|
@ -2000,6 +2001,18 @@ int linphone_core_get_sip_transports(LinphoneCore *lc, LCSipTransports *tr){
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the real port number assigned for each sip transport (udp, tcp, tls).
|
||||
* A zero value means that the transport is not activated.
|
||||
* If LC_SIP_TRANSPORT_RANDOM was passed to linphone_core_set_sip_transports(), the random port choosed by the system is returned.
|
||||
* @ingroup network_parameters
|
||||
* @param tr a LCSipTransports structure.
|
||||
**/
|
||||
void linphone_core_get_sip_transports_used(LinphoneCore *lc, LCSipTransports *tr){
|
||||
tr->udp_port=sal_get_listening_port(lc->sal,SalTransportUDP);
|
||||
tr->tcp_port=sal_get_listening_port(lc->sal,SalTransportTCP);
|
||||
tr->tls_port=sal_get_listening_port(lc->sal,SalTransportTLS);
|
||||
}
|
||||
/**
|
||||
* Sets the UDP port to be used by SIP.
|
||||
*
|
||||
|
|
@ -2770,7 +2783,6 @@ LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const
|
|||
lc->vtable.display_warning(lc,_("Sorry, we have reached the maximum number of simultaneous calls"));
|
||||
return NULL;
|
||||
}
|
||||
linphone_core_get_default_proxy(lc,&proxy);
|
||||
|
||||
real_url=linphone_address_as_string(addr);
|
||||
proxy=linphone_core_lookup_known_proxy(lc,addr);
|
||||
|
|
|
|||
|
|
@ -1722,6 +1722,8 @@ LINPHONE_PUBLIC int linphone_core_set_sip_transports(LinphoneCore *lc, const LCS
|
|||
|
||||
LINPHONE_PUBLIC int linphone_core_get_sip_transports(LinphoneCore *lc, LCSipTransports *transports);
|
||||
|
||||
LINPHONE_PUBLIC void linphone_core_get_sip_transports_used(LinphoneCore *lc, LCSipTransports *tr);
|
||||
|
||||
LINPHONE_PUBLIC bool_t linphone_core_sip_transport_supported(const LinphoneCore *lc, LinphoneTransportType tp);
|
||||
/**
|
||||
*
|
||||
|
|
|
|||
|
|
@ -501,6 +501,7 @@ void sal_signing_key_delete(SalSigningKey *key);
|
|||
|
||||
void sal_set_callbacks(Sal *ctx, const SalCallbacks *cbs);
|
||||
int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int is_secure);
|
||||
int sal_get_listening_port(Sal *ctx, SalTransport tr);
|
||||
int sal_unlisten_ports(Sal *ctx);
|
||||
int sal_transport_available(Sal *ctx, SalTransport t);
|
||||
void sal_set_dscp(Sal *ctx, int dscp);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue