From 5e23d504cd6a1da1d8bfc8365b3c4dbcd3c184f9 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Thu, 16 Feb 2012 05:35:25 +0000 Subject: Allow run-time control of automatic switching to TCP when request is larger than 1300 (the PJSIP_DONT_SWITCH_TO_TCP compile time setting) via pjsip_cfg()->endpt.disable_tcp_switch setting. Thanks Johan Lantz for the suggestion. git-svn-id: http://svn.pjsip.org/repos/pjproject/branches/1.x@3952 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/include/pjsip/sip_config.h | 10 ++++++++++ pjsip/src/pjsip/sip_config.c | 4 +++- pjsip/src/pjsip/sip_util.c | 5 ++--- 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'pjsip') diff --git a/pjsip/include/pjsip/sip_config.h b/pjsip/include/pjsip/sip_config.h index 6398e774..825db0d6 100644 --- a/pjsip/include/pjsip/sip_config.h +++ b/pjsip/include/pjsip/sip_config.h @@ -81,6 +81,13 @@ typedef struct pjsip_cfg_t * Disable rport in request. */ pj_bool_t disable_rport; + + /** + * Disable automatic switching from UDP to TCP if outgoing request + * is greater than 1300 bytes. See PJSIP_DONT_SWITCH_TO_TCP. + */ + pj_bool_t disable_tcp_switch; + } endpt; /** Transaction layer settings. */ @@ -251,6 +258,9 @@ PJ_INLINE(pjsip_cfg_t*) pjsip_cfg(void) * Disable the behavior of automatic switching to TCP whenever UDP packet * size exceeds the threshold defined in PJSIP_UDP_SIZE_THRESHOLD. * + * This option can also be controlled at run-time by the \a disable_tcp_switch + * setting in pjsip_cfg_t. + * * Default is 0 (no). */ #ifndef PJSIP_DONT_SWITCH_TO_TCP diff --git a/pjsip/src/pjsip/sip_config.c b/pjsip/src/pjsip/sip_config.c index 37a66a67..ce970e8a 100644 --- a/pjsip/src/pjsip/sip_config.c +++ b/pjsip/src/pjsip/sip_config.c @@ -25,7 +25,9 @@ pjsip_cfg_t pjsip_sip_cfg_var = { /* Global settings */ { - PJSIP_ALLOW_PORT_IN_FROMTO_HDR + PJSIP_ALLOW_PORT_IN_FROMTO_HDR, + 0, + PJSIP_DONT_SWITCH_TO_TCP }, /* Transaction settings */ diff --git a/pjsip/src/pjsip/sip_util.c b/pjsip/src/pjsip/sip_util.c index 4f82a1a6..f238f524 100644 --- a/pjsip/src/pjsip/sip_util.c +++ b/pjsip/src/pjsip/sip_util.c @@ -1248,14 +1248,14 @@ stateless_send_resolver_callback( pj_status_t status, } pj_assert(tdata->dest_info.addr.count != 0); -#if !defined(PJSIP_DONT_SWITCH_TO_TCP) || PJSIP_DONT_SWITCH_TO_TCP==0 /* RFC 3261 section 18.1.1: * If a request is within 200 bytes of the path MTU, or if it is larger * than 1300 bytes and the path MTU is unknown, the request MUST be sent * using an RFC 2914 [43] congestion controlled transport protocol, such * as TCP. */ - if (tdata->msg->type == PJSIP_REQUEST_MSG && + if (pjsip_cfg()->endpt.disable_tcp_switch==0 && + tdata->msg->type == PJSIP_REQUEST_MSG && tdata->dest_info.addr.count > 0 && tdata->dest_info.addr.entry[0].type == PJSIP_TRANSPORT_UDP) { @@ -1297,7 +1297,6 @@ stateless_send_resolver_callback( pj_status_t status, tdata->dest_info.addr.count = count * 2; } } -#endif /* !PJSIP_DONT_SWITCH_TO_TCP */ /* Process the addresses. */ stateless_send_transport_cb( stateless_data, tdata, -PJ_EPENDING); -- cgit v1.2.3