From bf89fbd81d50c94857ce6596f3445d3fa2037511 Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Wed, 3 Jul 2013 11:21:03 -0500 Subject: [PATCH] --resolve FS-5432 --- conf/vanilla/sip_profiles/internal.xml | 4 ++++ src/mod/endpoints/mod_sofia/conf/sofia.conf.xml | 4 ++++ src/mod/endpoints/mod_sofia/mod_sofia.h | 1 + src/mod/endpoints/mod_sofia/sofia.c | 8 ++++++++ src/mod/endpoints/mod_sofia/sofia_presence.c | 13 +++++++++++++ 5 files changed, 30 insertions(+) diff --git a/conf/vanilla/sip_profiles/internal.xml b/conf/vanilla/sip_profiles/internal.xml index df838406d1..423ec2a60a 100644 --- a/conf/vanilla/sip_profiles/internal.xml +++ b/conf/vanilla/sip_profiles/internal.xml @@ -311,6 +311,10 @@ + + + + diff --git a/src/mod/endpoints/mod_sofia/conf/sofia.conf.xml b/src/mod/endpoints/mod_sofia/conf/sofia.conf.xml index bf6bee7b28..5bd3a6dc12 100644 --- a/src/mod/endpoints/mod_sofia/conf/sofia.conf.xml +++ b/src/mod/endpoints/mod_sofia/conf/sofia.conf.xml @@ -353,6 +353,10 @@ + + + + diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 90e8dad19e..365f585787 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -672,6 +672,7 @@ struct sofia_profile { su_strlst_t *tls_verify_in_subjects; uint32_t sip_force_expires; uint32_t sip_expires_max_deviation; + uint32_t sip_subscription_max_deviation; int ireg_seconds; sofia_paid_type_t paid_type; uint32_t rtp_digit_delay; diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 54b683441c..d226b928f4 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -3685,6 +3685,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) profile->rtp_digit_delay = 40; profile->sip_force_expires = 0; profile->sip_expires_max_deviation = 0; + profile->sip_subscription_max_deviation = 0; profile->tls_version = 0; profile->tls_timeout = 300; profile->mflags = MFLAG_REFER | MFLAG_REGISTER; @@ -4635,6 +4636,13 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) } else { profile->sip_expires_max_deviation = 0; } + } else if (!strcasecmp(var, "sip-subscription-max-deviation")) { + int32_t sip_subscription_max_deviation = atoi(val); + if (sip_subscription_max_deviation >= 0) { + profile->sip_subscription_max_deviation = sip_subscription_max_deviation; + } else { + profile->sip_subscription_max_deviation = 0; + } } else if (!strcasecmp(var, "reuse-connections")) { switch_bool_t value = switch_true(val); if (!value) { diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 91ca35e879..47203d476d 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -3516,6 +3516,7 @@ void sofia_presence_handle_sip_i_subscribe(int status, long exp_delta = 0; char exp_delta_str[30] = ""; + uint32_t sub_max_deviation_var = 0; sip_to_t const *to; const char *from_user = NULL, *from_host = NULL; const char *to_user = NULL, *to_host = NULL; @@ -3615,6 +3616,18 @@ void sofia_presence_handle_sip_i_subscribe(int status, } } + if ((sub_max_deviation_var = profile->sip_subscription_max_deviation)) { + if (sub_max_deviation_var > 0) { + int sub_deviation; + srand( (unsigned) ( (unsigned)(intptr_t)switch_thread_self() + switch_micro_time_now() ) ); + /* random negative number between 0 and negative sub_max_deviation_var: */ + sub_deviation = ( rand() % sub_max_deviation_var ) - sub_max_deviation_var; + if ( (exp_delta + sub_deviation) > 45 ) { + exp_delta += sub_deviation; + } + } + } + if (mod_sofia_globals.debug_presence > 0 || mod_sofia_globals.debug_sla > 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DELTA %ld\n", exp_delta); }