Selaa lähdekoodia

ims_registrar_pcscf: option to delay record expiration instead of immediate delete

- new parameter delete_delay
Supreeth Herle 1 vuosi sitten
vanhempi
commit
bc3e758fb3

+ 5 - 0
src/modules/ims_registrar_pcscf/ims_registrar_pcscf_mod.c

@@ -105,6 +105,10 @@ char *rcv_avp_param = 0;
 unsigned short rcv_avp_type = 0;
 int_str rcv_avp_name;
 
+ims_registrar_pcscf_params_t _imsregp_params = {
+	.delete_delay = 0
+};
+
 // static str orig_prefix = {"sip:orig@",9};
 
 /*! \brief Module init & destroy function */
@@ -186,6 +190,7 @@ static param_export_t params[] = {{"pcscf_uri", PARAM_STR, &pcscf_uri},
 		{"force_icscf_uri", PARAM_STR, &force_icscf_uri},
 		{"reginfo_queue_size_threshold", INT_PARAM,
 				&reginfo_queue_size_threshold},
+		{"delete_delay", PARAM_INT, &_imsregp_params.delete_delay},
 		//	{"store_profile_dereg",	INT_PARAM, &store_data_on_dereg},
 		{0, 0, 0}};
 

+ 4 - 0
src/modules/ims_registrar_pcscf/ims_registrar_pcscf_mod.h

@@ -57,6 +57,10 @@
 #define USERNAME_MAX_SIZE 64
 #define DOMAIN_MAX_SIZE 128
 
+typedef struct ims_registrar_pcscf_params {
+	int delete_delay;
+} ims_registrar_pcscf_params_t;
+
 extern unsigned short rcv_avp_type;
 extern int_str rcv_avp_name;
 extern int is_registered_fallback2ip;

+ 16 - 5
src/modules/ims_registrar_pcscf/notify.c

@@ -81,6 +81,8 @@ extern time_t time_now;
 
 extern int subscribe_to_reginfo;
 
+extern ims_registrar_pcscf_params_t _imsregp_params;
+
 int process_contact(
 		udomain_t *_d, int expires, str contact_uri, int contact_state)
 {
@@ -211,14 +213,23 @@ int process_contact(
 		//		}
 	} else { //contact exists
 		if(contact_state == STATE_TERMINATED) {
-			//delete contact
 			LM_DBG("This contact <%.*s> is in state terminated and is in "
 				   "usrloc so removing it from usrloc\n",
 					contact_uri.len, contact_uri.s);
-			if(ul.delete_pcontact(_d, pcontact) != 0) {
-				LM_DBG("failed to delete pcscf contact <%.*s> - not a problem "
-					   "this may have been removed by de registration",
-						contact_uri.len, contact_uri.s);
+			if(_imsregp_params.delete_delay <= 0) {
+				//delete contact
+				if(ul.delete_pcontact(_d, pcontact) != 0) {
+					LM_DBG("failed to delete pcscf contact <%.*s> - not a "
+						   "problem "
+						   "this may have been removed by de registration",
+							contact_uri.len, contact_uri.s);
+				}
+			} else {
+				// rather than delete update the pcontact with expire value
+				ci.expires = local_time_now + _imsregp_params.delete_delay;
+				if(ul.update_pcontact(_d, &ci, pcontact) != 0) {
+					LM_DBG("failed to update pcscf contact on de-register\n");
+				}
 			}
 			/*TODO_LATEST - put this back */
 		} else { //state is active

+ 16 - 3
src/modules/ims_registrar_pcscf/save.c

@@ -63,6 +63,8 @@ extern int subscription_expires;
 extern pua_api_t pua;
 extern ipsec_pcscf_api_t ipsec_pcscf;
 
+extern ims_registrar_pcscf_params_t _imsregp_params;
+
 struct sip_msg *get_request_from_reply(struct sip_msg *reply)
 {
 	struct cell *t;
@@ -247,9 +249,20 @@ static inline int update_contacts(struct sip_msg *req, struct sip_msg *rpl,
 							<= 0) { //remove contact - de-register
 						LM_DBG("This is a de-registration for contact <%.*s>\n",
 								c->uri.len, c->uri.s);
-						if(ul.delete_pcontact(_d, pcontact) != 0) {
-							LM_ERR("failed to delete pcscf contact <%.*s>\n",
-									c->uri.len, c->uri.s);
+						if(_imsregp_params.delete_delay <= 0) {
+							if(ul.delete_pcontact(_d, pcontact) != 0) {
+								LM_ERR("failed to delete pcscf contact "
+									   "<%.*s>\n",
+										c->uri.len, c->uri.s);
+							}
+						} else {
+							// rather than delete update the pcontact with expire value of 10 seconds
+							ci.expires = local_time_now
+										 + _imsregp_params.delete_delay;
+							if(ul.update_pcontact(_d, &ci, pcontact) != 0) {
+								LM_DBG("failed to update pcscf contact on "
+									   "de-register\n");
+							}
 						}
 						//TODO_LATEST replace above
 					} else { //update contact