From f9699a50372fce5b374b3e768fd433296403e894 Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Fri, 28 Sep 2012 06:17:11 +0000 Subject: Close #1587: Added settings to accept call replace when in early state and as UAS: accept_replace_in_early_state in pjsip_cfg_t and PJSIP_ACCEPT_REPLACE_IN_EARLY_STATE macro. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4267 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/include/pjsip/sip_config.h | 24 ++++++++++++++++++++++++ pjsip/src/pjsip-ua/sip_replaces.c | 4 +++- pjsip/src/pjsip/sip_config.c | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) (limited to 'pjsip') diff --git a/pjsip/include/pjsip/sip_config.h b/pjsip/include/pjsip/sip_config.h index b67859fb..3527d536 100644 --- a/pjsip/include/pjsip/sip_config.h +++ b/pjsip/include/pjsip/sip_config.h @@ -77,6 +77,15 @@ typedef struct pjsip_cfg_t */ pj_bool_t allow_port_in_fromto_hdr; + /** + * Accept call replace in early state when invite is not initiated + * by the user agent. RFC 3891 Section 3 disallows this, however, + * for better interoperability reason, this might be ignored. + * + * Default is PJSIP_ACCEPT_REPLACE_IN_EARLY_STATE. + */ + pj_bool_t accept_replace_in_early_state; + /** * Allow hash character ('#') to appear in outgoing URIs. See * https://trac.pjsip.org/repos/ticket/1569 @@ -274,6 +283,21 @@ PJ_INLINE(pjsip_cfg_t*) pjsip_cfg(void) #endif +/** + * Accept call replace in early state when invite is not initiated + * by the user agent. RFC 3891 Section 3 disallows this, however, + * for better interoperability reason, this might be ignored. + * + * This option can also be controlled at run-time by the + * \a accept_replace_in_early_state setting in pjsip_cfg_t. + * + * Default is 0 (no). + */ +#ifndef PJSIP_ACCEPT_REPLACE_IN_EARLY_STATE +# define PJSIP_ACCEPT_REPLACE_IN_EARLY_STATE 0 +#endif + + /** * This setting controls the threshold of the UDP packet, which if it's * larger than this value the request will be sent with TCP. This setting diff --git a/pjsip/src/pjsip-ua/sip_replaces.c b/pjsip/src/pjsip-ua/sip_replaces.c index 70329f97..3bda5305 100644 --- a/pjsip/src/pjsip-ua/sip_replaces.c +++ b/pjsip/src/pjsip-ua/sip_replaces.c @@ -305,7 +305,9 @@ PJ_DEF(pj_status_t) pjsip_replaces_verify_request( pjsip_rx_data *rdata, * initiated by this UA, it returns a 481 (Call/Transaction Does Not * Exist) response to the new INVITE. */ - if (inv->state <= PJSIP_INV_STATE_EARLY && inv->role != PJSIP_ROLE_UAC) { + if (inv->state <= PJSIP_INV_STATE_EARLY && inv->role != PJSIP_ROLE_UAC && + pjsip_cfg()->endpt.accept_replace_in_early_state == PJ_FALSE) + { code = PJSIP_SC_CALL_TSX_DOES_NOT_EXIST; warn_text = "Found early INVITE session but not initiated by this UA"; goto on_return; diff --git a/pjsip/src/pjsip/sip_config.c b/pjsip/src/pjsip/sip_config.c index ce970e8a..e64e49d7 100644 --- a/pjsip/src/pjsip/sip_config.c +++ b/pjsip/src/pjsip/sip_config.c @@ -26,6 +26,7 @@ pjsip_cfg_t pjsip_sip_cfg_var = /* Global settings */ { PJSIP_ALLOW_PORT_IN_FROMTO_HDR, + PJSIP_ACCEPT_REPLACE_IN_EARLY_STATE, 0, PJSIP_DONT_SWITCH_TO_TCP }, -- cgit v1.2.3