[sr-dev] git:master:72c8f8c6: modules/ims_registrar_scscf: in notify set contact expires to 0 if negative

Richard Good richard.good at smilecoms.com
Wed Jan 21 11:06:17 CET 2015


Module: kamailio
Branch: master
Commit: 72c8f8c6f898be0bb1b0400d191d7ab55cc47c3c
URL: https://github.com/kamailio/kamailio/commit/72c8f8c6f898be0bb1b0400d191d7ab55cc47c3c

Author: Richard Good <richard.good at smilecoms.com>
Committer: Richard Good <richard.good at smilecoms.com>
Date: 2015-01-21T12:05:25+02:00

modules/ims_registrar_scscf: in notify set contact expires to 0 if negative

---

Modified: modules/ims_registrar_scscf/registrar_notify.c

---

Diff:  https://github.com/kamailio/kamailio/commit/72c8f8c6f898be0bb1b0400d191d7ab55cc47c3c.diff
Patch: https://github.com/kamailio/kamailio/commit/72c8f8c6f898be0bb1b0400d191d7ab55cc47c3c.patch

---

diff --git a/modules/ims_registrar_scscf/registrar_notify.c b/modules/ims_registrar_scscf/registrar_notify.c
index 0118cfb..d1d19ad 100644
--- a/modules/ims_registrar_scscf/registrar_notify.c
+++ b/modules/ims_registrar_scscf/registrar_notify.c
@@ -1523,6 +1523,8 @@ str generate_reginfo_full(udomain_t* _t, str* impu_list, int num_impus) {
     buf.len = 0;
     pad.s = padc;
     pad.len = 0;
+    
+    int expires;
 
     LM_DBG("Getting reginfo_full");
 
@@ -1561,14 +1563,24 @@ str generate_reginfo_full(udomain_t* _t, str* impu_list, int num_impus) {
 	    if (ptr->q != -1) {
 		LM_DBG("q value not equal to -1");
 		float q = (float) ptr->q / 1000;
+		expires = ptr->expires - act_time;
+		if(expires < 0) {
+		    LM_WARN("Contact expires is negative - setting to 0\n");
+		    expires = 0;
+		}
 		sprintf(pad.s, contact_s_q.s, ptr, r_active.len, r_active.s,
-			r_registered.len, r_registered.s, ptr->expires - act_time,
+			r_registered.len, r_registered.s, expires,
 			q);
 	    } else {
 		LM_DBG("q value equal to -1");
-	    sprintf(pad.s, contact_s.s, ptr, r_active.len, r_active.s,
+		expires = ptr->expires - act_time;
+		if(expires < 0) {
+		    LM_WARN("Contact expires is negative - setting to 0\n");
+		    expires = 0;
+		}
+		sprintf(pad.s, contact_s.s, ptr, r_active.len, r_active.s,
 			r_registered.len, r_registered.s,
-			ptr->expires - act_time);
+			expires);
 	    }
 	    pad.len = strlen(pad.s);
 	    STR_APPEND(buf, pad);
@@ -1657,6 +1669,11 @@ str get_reginfo_partial(impurecord_t *r, ucontact_t *c, int event_type) {
 
     if (r) {
         expires = c->expires - act_time;
+	if(expires < 0) {
+	    LM_WARN("Contact expires is negative - setting to 0\n");
+	    expires = 0;
+	}
+	
         if (//richard we only use expired and unregistered
                 (event_type == IMS_REGISTRAR_CONTACT_EXPIRED ||
                 event_type == IMS_REGISTRAR_CONTACT_UNREGISTERED)




More information about the sr-dev mailing list