Skip to content

Commit

Permalink
ims_registrar_pcscf: option to delay record expiration instead of imm…
Browse files Browse the repository at this point in the history
…ediate delete

- new parameter delete_delay
  • Loading branch information
herlesupreeth authored and miconda committed Nov 30, 2023
1 parent 3b2bffc commit bc3e758
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/modules/ims_registrar_pcscf/ims_registrar_pcscf_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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}};

Expand Down
4 changes: 4 additions & 0 deletions src/modules/ims_registrar_pcscf/ims_registrar_pcscf_mod.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
21 changes: 16 additions & 5 deletions src/modules/ims_registrar_pcscf/notify.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down
19 changes: 16 additions & 3 deletions src/modules/ims_registrar_pcscf/save.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bc3e758

Please sign in to comment.