Commit cad60e04 authored by Pekka Pessi's avatar Pekka Pessi

sofia-sip/tport_tag.h: added TPTAG_KEEPALIVE(), TPTAG_PINGPONG(), TPTAG_PONG2PING()

darcs-hash:20070725160533-65a35-c1217c49eab31628bb688cb1ed74e315a2dd8a9e.gz
parent d645ee69
......@@ -225,6 +225,66 @@ 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_keepalive;
/**Keepalive interval in milliseconds.
*
* If 0 or UINT_MAX, do not use keepalives. Default value is 0.
*
* On TCP, the keepalive if a CR-LF-CR-LF sequence.
*
* Use with tport_tcreate(), tport_tbind(), tport_set_params(), nua_create(),
* nta_agent_create(), nta_agent_add_tport(), nth_engine_create(), or
* initial nth_site_create().
*
* @sa TPTAG_PINGPONG(), TPTAG_PONG2PING(), TPTAG_TIMEOUT(), TPTAG_IDLE()
*/
#define TPTAG_KEEPALIVE(x) tptag_keepalive, tag_uint_v((x))
TPORT_DLL extern tag_typedef_t tptag_keepalive_ref;
#define TPTAG_KEEPALIVE_REF(x) tptag_keepalive_ref, tag_uint_vr(&(x))
TPORT_DLL extern tag_typedef_t tptag_pingpong;
/**Ping-pong interval in milliseconds.
*
* If 0 or UINT_MAX, do not check for PONGs. Default value is 0.
*
* If set, the ping-pong protocol is used on TCP connections. If pinger
* sends a ping and receives no data in the specified ping-pong interval, it
* considers the connection failed and closes it. The value recommended in
* draft-ietf-sip-outbound-10 is 10 seconds (10000 milliseconds).
*
* Use with tport_tcreate(), tport_tbind(), tport_set_params(), nua_create(),
* nta_agent_create(), nta_agent_add_tport(), nth_engine_create(), or
* initial nth_site_create().
*
* @sa TPTAG_PONG2PING(), TPTAG_KEEPALIVE(), TPTAG_TIMEOUT(), TPTAG_IDLE(),
* draft-ietf-sip-outbound-10.txt
*/
#define TPTAG_PINGPONG(x) tptag_pingpong, tag_uint_v((x))
TPORT_DLL extern tag_typedef_t tptag_pingpong_ref;
#define TPTAG_PINGPONG_REF(x) tptag_pingpong_ref, tag_uint_vr(&(x))
TPORT_DLL extern tag_typedef_t tptag_pong2ping;
/**Respond PING with PONG.
*
* If true, respond with PONG to PING. Default value is 0 (false).
*
* If set, the ping-pong protocol is used on TCP connections. If a ping (at
* least 4 whitespace characters) is received within messages, a pong
* (CR-LF) is sent in response.
*
* Use with tport_tcreate(), tport_tbind(), tport_set_params(), nua_create(),
* nta_agent_create(), nta_agent_add_tport(), nth_engine_create(), or
* initial nth_site_create().
*
* @sa TPTAG_PINGPONG(), TPTAG_KEEPALIVE(), TPTAG_TIMEOUT(), TPTAG_IDLE()
*/
#define TPTAG_PONG2PING(x) tptag_pong2ping, tag_bool_v((x))
TPORT_DLL extern tag_typedef_t tptag_pong2ping_ref;
#define TPTAG_PONG2PING_REF(x) tptag_pong2ping_ref, tag_bool_vr(&(x))
TPORT_DLL extern tag_typedef_t tptag_sigcomp_lifetime;
/**Default SigComp lifetime in seconds.
*
......
......@@ -483,6 +483,9 @@ 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_keepalive = 0;
tpp->tpp_pingpong = 0;
tpp->tpp_pong2ping = 0;
tpp->tpp_stun_server = 1;
tpp->tpp_tos = -1; /* set invalid, valid values are 0-255 */
......@@ -1115,6 +1118,14 @@ void tport_decref(tport_t **ttp)
*
* @param self pointer to a transport object
* @param tag,value,... list of tags
*
* @TAGS
* TPTAG_MTU_REF(), TPTAG_QUEUESIZE_REF(), TPTAG_IDLE_REF(),
* TPTAG_TIMEOUT_REF(), TPTAG_KEEPALIVE_REF(), TPTAG_PINGPONG_REF(),
* TPTAG_PONG2PING_REF(), TPTAG_DEBUG_DROP_REF(), TPTAG_THRPSIZE_REF(),
* TPTAG_THRPRQSIZE_REF(), TPTAG_SIGCOMP_LIFETIME_REF(),
* TPTAG_CONNECT_REF(), TPTAG_SDWN_ERROR_REF(), TPTAG_REUSE_REF(),
* TPTAG_STUN_SERVER_REF(), TPTAG_PUBLIC_REF() and TPTAG_TOS_REF().
*/
int tport_get_params(tport_t const *self,
tag_type_t tag, tag_value_t value, ...)
......@@ -1142,10 +1153,15 @@ int tport_get_params(tport_t const *self,
TPTAG_QUEUESIZE(tpp->tpp_qsize),
TPTAG_IDLE(tpp->tpp_idle),
TPTAG_TIMEOUT(tpp->tpp_timeout),
TPTAG_KEEPALIVE(tpp->tpp_keepalive),
TPTAG_PINGPONG(tpp->tpp_pingpong),
TPTAG_PONG2PING(tpp->tpp_pong2ping),
TPTAG_SDWN_ERROR(tpp->tpp_sdwn_error),
TPTAG_DEBUG_DROP(tpp->tpp_drop),
TPTAG_THRPSIZE(tpp->tpp_thrpsize),
TPTAG_THRPRQSIZE(tpp->tpp_thrprqsize),
TPTAG_SIGCOMP_LIFETIME(tpp->tpp_sigcomp_lifetime),
TPTAG_STUN_SERVER(tpp->tpp_stun_server),
TAG_IF(pri, TPTAG_PUBLIC(pri ? pri->pri_public : 0)),
TPTAG_TOS(tpp->tpp_tos),
TAG_END());
......@@ -1162,6 +1178,7 @@ int tport_get_params(tport_t const *self,
*
* @TAGS
* TPTAG_MTU(), TPTAG_QUEUESIZE(), TPTAG_IDLE(), TPTAG_TIMEOUT(),
* TPTAG_KEEPALIVE(), TPTAG_PINGPONG(), TPTAG_PONG2PING(),
* TPTAG_DEBUG_DROP(), TPTAG_THRPSIZE(), TPTAG_THRPRQSIZE(),
* TPTAG_SIGCOMP_LIFETIME(), TPTAG_CONNECT(), TPTAG_SDWN_ERROR(),
* TPTAG_REUSE(), TPTAG_STUN_SERVER(), and TPTAG_TOS().
......@@ -1174,7 +1191,7 @@ int tport_set_params(tport_t *self,
tport_params_t tpp[1], *tpp0;
usize_t mtu;
int connect, sdwn_error, reusable, stun_server;
int connect, sdwn_error, reusable, stun_server, pong2ping;
if (self == NULL)
return su_seterrno(EINVAL);
......@@ -1186,6 +1203,7 @@ int tport_set_params(tport_t *self,
sdwn_error = tpp->tpp_sdwn_error;
reusable = self->tp_reusable;
stun_server = tpp->tpp_stun_server;
pong2ping = tpp->tpp_pong2ping;
ta_start(ta, tag, value);
......@@ -1194,6 +1212,9 @@ 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_KEEPALIVE_REF(tpp->tpp_keepalive),
TPTAG_PINGPONG_REF(tpp->tpp_pingpong),
TPTAG_PONG2PING_REF(pong2ping),
TPTAG_DEBUG_DROP_REF(tpp->tpp_drop),
TPTAG_THRPSIZE_REF(tpp->tpp_thrpsize),
TPTAG_THRPRQSIZE_REF(tpp->tpp_thrprqsize),
......@@ -1231,6 +1252,10 @@ int tport_set_params(tport_t *self,
tpp->tpp_sdwn_error = sdwn_error;
self->tp_reusable = reusable;
tpp->tpp_stun_server = stun_server;
tpp->tpp_pong2ping = pong2ping;
if (memcmp(tpp0, tpp, sizeof tpp) == 0)
return n;
if (tport_is_secondary(self) &&
self->tp_params == self->tp_pri->pri_primary->tp_params) {
......
......@@ -94,6 +94,9 @@ 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_keepalive; /**< Keepalive PING interval */
unsigned tpp_pingpong; /**< PONG-to-PING interval */
unsigned tpp_sigcomp_lifetime; /**< SigComp compartment lifetime */
unsigned tpp_thrpsize; /**< Size of thread pool */
......@@ -106,6 +109,7 @@ typedef struct {
unsigned tpp_conn_orient:1; /**< Connection-orienteded */
unsigned tpp_sdwn_error:1; /**< If true, shutdown is error. */
unsigned tpp_stun_server:1; /**< If true, use stun server */
unsigned tpp_pong2ping:1; /**< If true, respond with pong to ping */
unsigned :0;
......
......@@ -64,6 +64,9 @@ tag_typedef_t tptag_sdwn_after = BOOLTAG_TYPEDEF(sdwn_after);
tag_typedef_t tptag_close_after = BOOLTAG_TYPEDEF(sdwn_after);
tag_typedef_t tptag_idle = UINTTAG_TYPEDEF(idle);
tag_typedef_t tptag_timeout = UINTTAG_TYPEDEF(timeout);
tag_typedef_t tptag_keepalive = UINTTAG_TYPEDEF(keepalive);
tag_typedef_t tptag_pingpong = UINTTAG_TYPEDEF(pingpong);
tag_typedef_t tptag_pong2ping = BOOLTAG_TYPEDEF(pong2ping);
tag_typedef_t tptag_sigcomp_lifetime = UINTTAG_TYPEDEF(sigcomp_lifetime);
tag_typedef_t tptag_certificate = STRTAG_TYPEDEF(certificate);
tag_typedef_t tptag_compartment = PTRTAG_TYPEDEF(compartment);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment