]> sjero.net Git - linphone/commitdiff
Add tcp_tls_keepalive configuration option to (de)activate SIP keepalive for TCP...
authorGhislain MARY <ghislain.mary@belledonne-communications.com>
Mon, 21 Jan 2013 10:25:38 +0000 (11:25 +0100)
committerGhislain MARY <ghislain.mary@belledonne-communications.com>
Mon, 21 Jan 2013 10:25:38 +0000 (11:25 +0100)
coreapi/linphonecore.c
coreapi/private.h
coreapi/sal.h
coreapi/sal_eXosip2.c
coreapi/sal_eXosip2.h

index 28488e1dd1bc4cdf12b5bf58d5725877d5b60f14..3904afc9b824e536511f5dfa01c8dde8c73fc9b8 100644 (file)
@@ -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);
index 5c09974b7e7a9f666ffb8b4ed4def9ad6545fc2a..edb717ae3c3850076b3e2334c8ba8af011f2a9e6 100644 (file)
@@ -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
index 9c0ceca76900097b9a60b293d2440cbd8f95d620..ba6daa2211ad2b7abd9ee3808f77beb9cbb917fd 100644 (file)
@@ -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
index 93686a75e538985ac16385236072540fe4d50435..d8332621d539d1302aa805a43007504ccadbb4ba 100644 (file)
@@ -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;
index 89ac93abf1132b97ef0064331e541c47d91c869e..81e3ed9a7902b10ad01cf4d9a8446ef1ba5d9efe 100644 (file)
@@ -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{