diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/sofia-sip/tport_tag.h b/libs/sofia-sip/libsofia-sip-ua/tport/sofia-sip/tport_tag.h index 6e0ef165d0..de96fca3d8 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/sofia-sip/tport_tag.h +++ b/libs/sofia-sip/libsofia-sip-ua/tport/sofia-sip/tport_tag.h @@ -142,6 +142,12 @@ TPORT_DLL extern tag_typedef_t tptag_timeout; TPORT_DLL extern tag_typedef_t tptag_timeout_ref; #define TPTAG_TIMEOUT_REF(x) tptag_timeout_ref, tag_uint_vr(&(x)) +TPORT_DLL extern tag_typedef_t tptag_socket_keepalive; +#define TPTAG_SOCKET_KEEPALIVE(x) tptag_socket_keepalive, tag_uint_v((x)) + +TPORT_DLL extern tag_typedef_t tptag_socket_keepalive_ref; +#define TPTAG_SOCKET_KEEPALIVE_REF(x) tptag_socket_keepalive_ref, tag_uint_vr(&(x)) + TPORT_DLL extern tag_typedef_t tptag_keepalive; #define TPTAG_KEEPALIVE(x) tptag_keepalive, tag_uint_v((x)) diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport.c b/libs/sofia-sip/libsofia-sip-ua/tport/tport.c index 62193e9135..dd9c40c802 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport.c @@ -520,6 +520,7 @@ tport_t *tport_tcreate(tp_stack_t *stack, tpp->tpp_idle = UINT_MAX; tpp->tpp_timeout = UINT_MAX; tpp->tpp_sigcomp_lifetime = UINT_MAX; + tpp->tpp_socket_keepalive = 30; tpp->tpp_keepalive = 0; tpp->tpp_pingpong = 0; tpp->tpp_pong2ping = 0; @@ -1218,6 +1219,7 @@ int tport_get_params(tport_t const *self, TPTAG_QUEUESIZE(tpp->tpp_qsize), TPTAG_IDLE(tpp->tpp_idle), TPTAG_TIMEOUT(tpp->tpp_timeout), + TPTAG_SOCKET_KEEPALIVE(tpp->tpp_socket_keepalive), TPTAG_KEEPALIVE(tpp->tpp_keepalive), TPTAG_PINGPONG(tpp->tpp_pingpong), TPTAG_PONG2PING(tpp->tpp_pong2ping), @@ -1283,6 +1285,7 @@ int tport_set_params(tport_t *self, TAG_IF(!self->tp_queue, TPTAG_QUEUESIZE_REF(tpp->tpp_qsize)), TPTAG_IDLE_REF(tpp->tpp_idle), TPTAG_TIMEOUT_REF(tpp->tpp_timeout), + TPTAG_SOCKET_KEEPALIVE_REF(tpp->tpp_socket_keepalive), TPTAG_KEEPALIVE_REF(tpp->tpp_keepalive), TPTAG_PINGPONG_REF(tpp->tpp_pingpong), TPTAG_PONG2PING_REF(pong2ping), diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport_internal.h b/libs/sofia-sip/libsofia-sip-ua/tport/tport_internal.h index 5deac55268..f18fc93911 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport_internal.h +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport_internal.h @@ -106,6 +106,7 @@ typedef struct { unsigned tpp_mtu; /**< Maximum packet size */ unsigned tpp_idle; /**< Allowed connection idle time. */ unsigned tpp_timeout; /**< Allowed idle time for message. */ + unsigned tpp_socket_keepalive;/**< Socket keepalive interval */ unsigned tpp_keepalive; /**< Keepalive PING interval */ unsigned tpp_pingpong; /**< PONG-to-PING interval */ diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport_tag.c b/libs/sofia-sip/libsofia-sip-ua/tport/tport_tag.c index 59feeeceee..35262f4fe9 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport_tag.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport_tag.c @@ -179,6 +179,14 @@ tag_typedef_t tptag_idle = UINTTAG_TYPEDEF(idle); */ tag_typedef_t tptag_timeout = UINTTAG_TYPEDEF(timeout); +/**@def TPTAG_SOCKET_KEEPALIVE(x) + * + * Keepalive interval set on socket (where supported) in seconds. + * + * If 0 or UINT_MAX, do not use keepalives. Default value is 30. + */ +tag_typedef_t tptag_socket_keepalive = UINTTAG_TYPEDEF(socket_keepalive); + /**@def TPTAG_KEEPALIVE(x) * * Keepalive interval in milliseconds. diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c b/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c index d42547c582..9b700dc1a2 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c @@ -196,11 +196,7 @@ int tport_tcp_init_secondary(tport_t *self, int socket, int accepted, #if defined(SO_KEEPALIVE) setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, (void *)&val, sizeof val); #endif - val = (int)(self->tp_params->tpp_keepalive / 1000); - if (!val && (self->tp_params->tpp_keepalive > 0)) - SU_DEBUG_1(("%s(%p): Ignoring TCP keepalive value %u (<1000)\n", - __func__, (void *)self, - self->tp_params->tpp_keepalive)); + val = (int)(self->tp_params->tpp_socket_keepalive); #if defined(TCP_KEEPIDLE) if (val != 0 && val != UINT_MAX) { SU_DEBUG_3(("%s(%p): Setting TCP_KEEPIDLE to %d\n",