Module: kamailio
Branch: master
Commit: 81b084e662526bcb9a7eb5d49776e3ff0c4e20d9
URL:
https://github.com/kamailio/kamailio/commit/81b084e662526bcb9a7eb5d49776e3f…
Author: jaybeepee <jason.penton(a)gmail.com>
Committer: GitHub <noreply(a)github.com>
Date: 2016-07-07T15:38:46+02:00
Merge pull request #697 from athonet-open/rework_ims_registrar_params
ims_registrar_scscf: Refactor expire calculation
---
Modified: modules/ims_registrar_scscf/save.c
---
Diff:
https://github.com/kamailio/kamailio/commit/81b084e662526bcb9a7eb5d49776e3f…
Patch:
https://github.com/kamailio/kamailio/commit/81b084e662526bcb9a7eb5d49776e3f…
---
diff --git a/modules/ims_registrar_scscf/save.c b/modules/ims_registrar_scscf/save.c
index 624e0a9..15d2571 100644
--- a/modules/ims_registrar_scscf/save.c
+++ b/modules/ims_registrar_scscf/save.c
@@ -109,39 +109,35 @@ static inline int randomize_expires(int expires, int range) {
* the default value
*/
static inline int calc_contact_expires(contact_t *c, int expires_hdr, int sos_reg) {
- unsigned int r;
-
- if (expires_hdr >= 0U)
- r = expires_hdr;
- else {
- r = (sos_reg > 0) ? default_registrar_cfg.em_default_expires :
default_registrar_cfg.default_expires;
- goto end;
- }
- if (c && c->expires)
- str2int(&(c->expires->body), (unsigned int*) &r);
- if (r > 0) {
- if (!sos_reg && r < default_registrar_cfg.min_expires) {
- r = default_registrar_cfg.min_expires;
- goto end;
- }
- if (sos_reg && r < default_registrar_cfg.em_min_expires) {
- r = default_registrar_cfg.em_min_expires;
- goto end;
- }
- }
- if (!sos_reg && r > default_registrar_cfg.max_expires) {
- r = default_registrar_cfg.max_expires;
- goto end;
- }
- if (sos_reg && r > default_registrar_cfg.em_max_expires)
- r = default_registrar_cfg.em_min_expires;
-
+ int r;
+ if(c && c->expires)
+ str2int(&(c->expires->body), (unsigned int*) &r);
+ else if (expires_hdr >= 0)
+ r = expires_hdr;
+ else {
+ r = (sos_reg > 0) ? default_registrar_cfg.em_default_expires :
default_registrar_cfg.default_expires;
+ goto end;
+ }
+ if (!sos_reg && r < default_registrar_cfg.min_expires) {
+ r = default_registrar_cfg.min_expires;
+ goto end;
+ }
+ if (sos_reg && r < default_registrar_cfg.em_min_expires) {
+ r = default_registrar_cfg.em_min_expires;
+ goto end;
+ }
+ if (!sos_reg && r > default_registrar_cfg.max_expires) {
+ r = default_registrar_cfg.max_expires;
+ goto end;
+ }
+ if (sos_reg && r > default_registrar_cfg.em_max_expires) {
+ r = default_registrar_cfg.em_min_expires;
+ goto end;
+ }
end:
-
- r = randomize_expires(r, default_registrar_cfg.default_expires_range);
-
- LM_DBG("Calculated expires for contact is %d\n", r);
- return time(NULL) + r;
+ r = randomize_expires(r, default_registrar_cfg.default_expires_range);
+ LM_DBG("Calculated expires for contact is %d\n", r);
+ return time(NULL) + r;
}
/*! \brief