mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-19 03:58:08 +00:00
Add tcp_tls_keepalive configuration option to (de)activate SIP keepalive for TCP/TLS.
This commit is contained in:
parent
2c5cef3bb3
commit
622af47cb2
5 changed files with 27 additions and 5 deletions
|
|
@ -635,7 +635,8 @@ static void sip_config_read(LinphoneCore *lc)
|
|||
lc->sip_conf.ping_with_options=lp_config_get_int(lc->config,"sip","ping_with_options",1);
|
||||
lc->sip_conf.auto_net_state_mon=lp_config_get_int(lc->config,"sip","auto_net_state_mon",1);
|
||||
lc->sip_conf.keepalive_period=lp_config_get_int(lc->config,"sip","keepalive_period",10000);
|
||||
sal_set_keepalive_period(lc->sal,lc->sip_conf.keepalive_period);
|
||||
lc->sip_conf.tcp_tls_keepalive=lp_config_get_int(lc->config,"sip","tcp_tls_keepalive",0);
|
||||
linphone_core_enable_keep_alive(lc, (lc->sip_conf.keepalive_period > 0));
|
||||
sal_use_one_matching_codec_policy(lc->sal,lp_config_get_int(lc->config,"sip","only_one_codec",0));
|
||||
sal_use_double_registrations(lc->sal,lp_config_get_int(lc->config,"sip","use_double_registrations",1));
|
||||
sal_use_dates(lc->sal,lp_config_get_int(lc->config,"sip","put_date",0));
|
||||
|
|
@ -5170,6 +5171,7 @@ const char *linphone_error_to_string(LinphoneReason err){
|
|||
*/
|
||||
void linphone_core_enable_keep_alive(LinphoneCore* lc,bool_t enable) {
|
||||
if (enable > 0) {
|
||||
sal_use_tcp_tls_keepalive(lc->sal,lc->sip_conf.tcp_tls_keepalive);
|
||||
sal_set_keepalive_period(lc->sal,lc->sip_conf.keepalive_period);
|
||||
} else {
|
||||
sal_set_keepalive_period(lc->sal,0);
|
||||
|
|
|
|||
|
|
@ -399,6 +399,7 @@ typedef struct sip_config
|
|||
bool_t register_only_when_network_is_up;
|
||||
bool_t ping_with_options;
|
||||
bool_t auto_net_state_mon;
|
||||
bool_t tcp_tls_keepalive;
|
||||
} sip_config_t;
|
||||
|
||||
typedef struct rtp_config
|
||||
|
|
|
|||
|
|
@ -343,6 +343,7 @@ ortp_socket_t sal_get_socket(Sal *ctx);
|
|||
void sal_set_user_agent(Sal *ctx, const char *user_agent);
|
||||
/*keepalive period in ms*/
|
||||
void sal_set_keepalive_period(Sal *ctx,unsigned int value);
|
||||
void sal_use_tcp_tls_keepalive(Sal *ctx, bool_t enabled);
|
||||
/**
|
||||
* returns keepalive period in ms
|
||||
* 0 desactiaved
|
||||
|
|
|
|||
|
|
@ -397,7 +397,8 @@ int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int i
|
|||
bool_t ipv6;
|
||||
int proto=IPPROTO_UDP;
|
||||
int keepalive = ctx->keepalive_period;
|
||||
|
||||
|
||||
ctx->transport = tr;
|
||||
switch (tr) {
|
||||
case SalTransportUDP:
|
||||
proto=IPPROTO_UDP;
|
||||
|
|
@ -406,7 +407,7 @@ int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int i
|
|||
case SalTransportTCP:
|
||||
case SalTransportTLS:
|
||||
proto= IPPROTO_TCP;
|
||||
keepalive=-1;
|
||||
if (!ctx->tcp_tls_keepalive) keepalive=-1;
|
||||
eXosip_set_option (EXOSIP_OPT_UDP_KEEP_ALIVE,&keepalive);
|
||||
set_tls_options(ctx);
|
||||
break;
|
||||
|
|
@ -2512,9 +2513,24 @@ void sal_address_destroy(SalAddress *u){
|
|||
osip_from_free((osip_from_t*)u);
|
||||
}
|
||||
|
||||
void sal_use_tcp_tls_keepalive(Sal *ctx, bool_t enabled) {
|
||||
ctx->tcp_tls_keepalive = enabled;
|
||||
}
|
||||
|
||||
void sal_set_keepalive_period(Sal *ctx,unsigned int value) {
|
||||
ctx->keepalive_period=value;
|
||||
eXosip_set_option (EXOSIP_OPT_UDP_KEEP_ALIVE, &value);
|
||||
switch (ctx->transport) {
|
||||
case SalTransportUDP:
|
||||
ctx->keepalive_period = value;
|
||||
break;
|
||||
case SalTransportTCP:
|
||||
case SalTransportTLS:
|
||||
if (ctx->tcp_tls_keepalive) ctx->keepalive_period = value;
|
||||
else ctx->keepalive_period = -1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
eXosip_set_option (EXOSIP_OPT_UDP_KEEP_ALIVE, &ctx->keepalive_period);
|
||||
}
|
||||
unsigned int sal_get_keepalive_period(Sal *ctx) {
|
||||
return ctx->keepalive_period;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ int sdp_to_media_description(sdp_message_t *sdp, SalMediaDescription *desc);
|
|||
|
||||
struct Sal{
|
||||
SalCallbacks callbacks;
|
||||
SalTransport transport;
|
||||
MSList *calls; /*MSList of SalOp */
|
||||
MSList *registers;/*MSList of SalOp */
|
||||
MSList *out_subscribes;/*MSList of SalOp */
|
||||
|
|
@ -51,6 +52,7 @@ struct Sal{
|
|||
bool_t verify_server_cn;
|
||||
bool_t expire_old_contact;
|
||||
bool_t add_dates;
|
||||
bool_t tcp_tls_keepalive;
|
||||
};
|
||||
|
||||
struct SalOp{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue