[Serdev] FW: [Serusers] limiting expires time
Jan Janak
jan at iptel.org
Tue May 18 16:35:19 UTC 2004
Thanks a lot, it is in CVS now.
Jan.
On 17-05 11:56, Jamey Hicks wrote:
> Chris Crawford wrote:
>
> >I will put the enhancement into the registrar module. IMHO it should be
> >part of the registrar module and not a core option, so that it could be
> >set on a user-by-user basis. For instance, there may be a group (ACLs)
> >associated with limiting user registration times (normal users). There
> >also may be another group associated with 'permanent' registration times
> >(gateways, admins, etc.). It allows more flexibility with each
> >registration request.
> >
> >Below is the functionality that can be expected:
> >
> >1- If a maximum expires is set, then each contact in the 200 reply that
> >has an expires time greater than the max will be set to the maximum
> >expires.
> >2- If the expires header has a time greater than the configured max,
> >then the 200 reply header will be set to the maximum expires.
> >
> >Is this reasonable? Thoughts?
> >
> >
>
> It makes sense to me. I implemented this locally for a deployment last
> month. Patch attached. The patch also makes the default expires value
> a parameter, rather than hardcoding it.
>
> -Jamey
> Index: modules/registrar/reg_mod.c
> ===================================================================
> RCS file: /cvsroot/ser/sip_router/modules/registrar/reg_mod.c,v
> retrieving revision 1.20
> diff -u -r1.20 reg_mod.c
> --- modules/registrar/reg_mod.c 27 Apr 2004 21:59:33 -0000 1.20
> +++ modules/registrar/reg_mod.c 17 May 2004 16:00:07 -0000
> @@ -62,6 +62,9 @@
> int nat_flag = 4; /* SER flag marking contacts behind NAT */
> int min_expires = 60; /* Minimum expires the phones are allowed to use in seconds,
> * use 0 to switch expires checking off */
> +int max_expires = 0; /* Maximum expires the phones are allowed to use in seconds,
> + * use 0 to switch expires checking off */
> +int default_expires = 3600; /* Default expires the phones in case phone does not specify. */
> char* realm_pref = ""; /* Realm prefix to be removed */
> str realm_prefix;
>
> @@ -95,6 +98,8 @@
> {"nat_flag", INT_PARAM, &nat_flag },
> {"realm_prefix", STR_PARAM, &realm_pref },
> {"min_expires", INT_PARAM, &min_expires },
> + {"max_expires", INT_PARAM, &max_expires },
> + {"default_expires", INT_PARAM, &default_expires },
> {0,0,0}
> };
>
> Index: modules/registrar/reg_mod.h
> ===================================================================
> RCS file: /cvsroot/ser/sip_router/modules/registrar/reg_mod.h,v
> retrieving revision 1.11
> diff -u -r1.11 reg_mod.h
> --- modules/registrar/reg_mod.h 27 Apr 2004 21:59:33 -0000 1.11
> +++ modules/registrar/reg_mod.h 17 May 2004 16:00:07 -0000
> @@ -42,6 +42,8 @@
> extern int desc_time_order;
> extern int nat_flag;
> extern int min_expires;
> +extern int max_expires;
> +extern int default_expires;
> extern str realm_prefix;
>
> extern float def_q;
> Index: modules/registrar/sip_msg.c
> ===================================================================
> RCS file: /cvsroot/ser/sip_router/modules/registrar/sip_msg.c,v
> retrieving revision 1.13
> diff -u -r1.13 sip_msg.c
> --- modules/registrar/sip_msg.c 27 Apr 2004 14:53:22 -0000 1.13
> +++ modules/registrar/sip_msg.c 17 May 2004 16:00:07 -0000
> @@ -226,7 +226,7 @@
> *_e = get_expires_hf(_m);
> } else {
> if (str2int(&_ep->body, (unsigned int*)_e) < 0) {
> - *_e = 3600;
> + *_e = default_expires;
> }
> /* Convert to absolute value */
> if (*_e != 0) *_e += act_time;
> @@ -234,6 +234,9 @@
>
> if ((*_e != 0) && ((*_e - act_time) < min_expires)) {
> *_e = min_expires + act_time;
> + }
> + if ((*_e != 0) && max_expires && ((*_e - act_time) > max_expires)) {
> + *_e = max_expires + act_time;
> }
>
> return 0;
More information about the Serdev
mailing list