On 21.02.2014 21:14, Daniel-Constantin Mierla wrote:
Module: sip-router
Branch: master
Commit: 806e967e2e39e0140b992719e10693b9c768d758
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=806e967…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri Feb 21 21:07:43 2014 +0100
registrar: allow randomization of expire value coming from UA
- new parameter expire_range
- requested in FS#249
[...]
@@ -52,6 +53,8 @@ cfg_def_t registrar_cfg_def[] = {
"Contains number of second to expire if no expire hf or contact expire
present" },
{"default_expires_range", CFG_VAR_INT | CFG_CB_ONLY_ONCE, 0, 100, 0,
default_expires_range_update,
"Percent from default_expires that will be used in generating the range for the
expire interval"},
+ {"expires_range", CFG_VAR_INT | CFG_CB_ONLY_ONCE, 0, 100, 0,
expires_range_update,
+ "Percent from incoming expires that will be used in generating the range for the
expire interval"},
[...]
diff --git a/modules/registrar/sip_msg.c
b/modules/registrar/sip_msg.c
index a02b050..7ce9c59 100644
--- a/modules/registrar/sip_msg.c
+++ b/modules/registrar/sip_msg.c
@@ -67,11 +67,16 @@ static inline int get_expire_val(void)
- return p->val + act_time;
+ range = cfg_get(registrar, registrar_cfg, default_expires_range);
+ if(likely(range==0))
+ return p->val + act_time;
+ return p->val + act_time - (float)range/100 * p->val
+ + ((float)(rand()%100)/100) * ((float)range/100 * p->val);
Wrong variable fetched, should have been:
range = cfg_get(registrar, registrar_cfg, expires_range);
Also for clients who do not use the Expires header, the above logic
does not work. E.g. a lot of Cisco devices sends like this:
Contact: "foo" <sip:12345@10.10.1.234:5060>;expires=3600.
All my Cisco devices got a similar Contact with expires=3600 back.
--
Øyvind