add NUTAG_RETRY_AFTER_ENABLE() tag to lib sofia and use it in mod_sofia to disable processing retry-after headers on a per-call basis

This commit is contained in:
Anthony Minessale 2012-11-02 13:54:54 -05:00
parent b002394f21
commit e884de5b07
7 changed files with 46 additions and 1 deletions

View File

@ -1 +1 @@
Fri Oct 26 14:14:41 CDT 2012
Fri Nov 2 13:36:06 CDT 2012

View File

@ -1217,6 +1217,7 @@ int nua_base_client_check_restart(nua_client_request_t *cr,
status == 500 || status == 503 ||
status == 600 || status == 603) &&
sip->sip_retry_after &&
NH_PGET(nh, retry_after_enable) &&
sip->sip_retry_after->af_delta < 3200) {
su_timer_t *timer;
char phrase[18]; /* Retry After XXXX\0 */

View File

@ -157,6 +157,7 @@ int nua_stack_set_defaults(nua_handle_t *nh,
NHP_SET(nhp, callee_caps, 0);
NHP_SET(nhp, service_route_enable, 1);
NHP_SET(nhp, path_enable, 1);
NHP_SET(nhp, retry_after_enable, 1);
NHP_SET(nhp, refer_expires, 300);
NHP_SET(nhp, refer_with_id, 1);
@ -295,6 +296,7 @@ int nua_stack_init_instance(nua_handle_t *nh, tagi_t const *tags)
* NUTAG_ONLY183_100REL() \n
* NUTAG_OUTBOUND() \n
* NUTAG_PATH_ENABLE() \n
* NUTAG_RETRY_AFTER_ENABLE() \n
* NUTAG_PROXY() (aka NTATAG_DEFAULT_PROXY()) \n
* NUTAG_REFER_EXPIRES() \n
* NUTAG_REFER_WITH_ID() \n
@ -417,6 +419,7 @@ int nua_stack_init_instance(nua_handle_t *nh, tagi_t const *tags)
* NUTAG_ONLY183_100REL() \n
* NUTAG_OUTBOUND() \n
* NUTAG_PATH_ENABLE() \n
* NUTAG_RETRY_AFTER_ENABLE() \n
* NUTAG_PROXY() (aka NTATAG_DEFAULT_PROXY()) \n
* NUTAG_REFER_EXPIRES() \n
* NUTAG_REFER_WITH_ID() \n
@ -801,6 +804,10 @@ static int nhp_set_tags(su_home_t *home,
else if (tag == nutag_path_enable) {
NHP_SET(nhp, path_enable, value != 0);
}
/* NUTAG_RETRY_AFTER_ENABLE(retry_after_enable) */
else if (tag == nutag_retry_after_enable) {
NHP_SET(nhp, retry_after_enable, value != 0);
}
/* NUTAG_AUTH_CACHE(auth_cache) */
else if (tag == nutag_auth_cache) {
if (value >= 0 && value < (tag_value_t)_nua_auth_cache_invalid)
@ -1494,6 +1501,7 @@ int nua_stack_set_smime_params(nua_t *nua, tagi_t const *tags)
* NUTAG_ONLY183_100REL() \n
* NUTAG_OUTBOUND() \n
* NUTAG_PATH_ENABLE() \n
* NUTAG_RETRY_AFTER_ENABLE() \n
* NUTAG_REFER_EXPIRES() \n
* NUTAG_REFER_WITH_ID() \n
* NUTAG_REFRESH_WITHOUT_SDP() \n
@ -1669,6 +1677,7 @@ int nua_stack_get_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
TIF(NUTAG_MEDIA_FEATURES, media_features),
TIF(NUTAG_SERVICE_ROUTE_ENABLE, service_route_enable),
TIF(NUTAG_PATH_ENABLE, path_enable),
TIF(NUTAG_RETRY_AFTER_ENABLE, retry_after_enable),
TIF(NUTAG_AUTH_CACHE, auth_cache),
TIF(NUTAG_REFER_EXPIRES, refer_expires),
TIF(NUTAG_REFER_WITH_ID, refer_with_id),

View File

@ -111,6 +111,10 @@ struct nua_handle_preferences
unsigned nhp_refer_with_id:1;
unsigned nhp_timer_autorequire:1;
/** Enable Retry-After */
unsigned nhp_retry_after_enable:1;
unsigned:0;
/* Default lifetime for implicit subscriptions created by REFER */
@ -210,6 +214,7 @@ struct nua_handle_preferences
unsigned nhb_initial_route:1;
unsigned nhb_proxy:1;
unsigned nhb_timer_autorequire:1;
unsigned nhb_retry_after_enable:1;
unsigned :0;
} set_bits;
unsigned set_unsigned[2];

View File

@ -126,6 +126,7 @@
* - NUTAG_M_USERNAME()
* - NUTAG_OUTBOUND()
* - NUTAG_PATH_ENABLE()
* - NUTAG_RETRY_AFTER_ENABLE()
* - NUTAG_SERVICE_ROUTE_ENABLE()
* Specifications:
* - @RFC3261 section 10, @RFC3327, @RFC3608, @RFC3680, @RFC3840,
@ -2663,6 +2664,29 @@ tag_typedef_t nutag_path_enable = BOOLTAG_TYPEDEF(path_enable);
* Reference tag for NUTAG_PATH_ENABLE().
*/
/**@def NUTAG_RETRY_AFTER_ENABLE(x)
*
* If true, support RFC 3261 Retry-After
*
* @par Used with
* - nua_create(), nua_set_params(), nua_get_params()
* - nua_handle(), nua_set_hparams(), nua_get_hparams()
* - nua_register()
*
* @par Parameter type
* int (boolean: nonzero is true, zero is false)
*
* @par Values
* - 0 (false) - Do not honor Retry-After
* - 1 (true) - honor Retry-After
*
*/
tag_typedef_t nutag_retry_after_enable = BOOLTAG_TYPEDEF(retry_after_enable);
/**@def NUTAG_RETRY_AFTER_ENABLE_REF(x)
* Reference tag for NUTAG_RETRY_AFTER_ENABLE().
*/
/**@def NUTAG_SERVICE_ROUTE_ENABLE(x)

View File

@ -550,6 +550,11 @@ SOFIAPUBVAR tag_typedef_t nutag_path_enable;
#define NUTAG_PATH_ENABLE_REF(x) nutag_path_enable_ref, tag_bool_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_path_enable_ref;
#define NUTAG_RETRY_AFTER_ENABLE(x) nutag_retry_after_enable, tag_bool_v(x)
SOFIAPUBVAR tag_typedef_t nutag_retry_after_enable;
#define NUTAG_RETRY_AFTER_ENABLE_REF(x) nutag_retry_after_enable_ref, tag_bool_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_retry_after_enable_ref;
#define NUTAG_SERVICE_ROUTE_ENABLE(x) nutag_service_route_enable, tag_bool_v(x)
SOFIAPUBVAR tag_typedef_t nutag_service_route_enable;
#define NUTAG_SERVICE_ROUTE_ENABLE_REF(x) \

View File

@ -2408,6 +2408,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
profile, /* Additional data to pass to callback */
TAG_IF( ! sofia_test_pflag(profile, PFLAG_TLS) || ! profile->tls_only, NUTAG_URL(profile->bindurl)),
NTATAG_USER_VIA(1),
NUTAG_RETRY_AFTER_ENABLE(0),
TAG_IF(!strchr(profile->sipip, ':'),
SOATAG_AF(SOA_AF_IP4_ONLY)),
TAG_IF(strchr(profile->sipip, ':'),