Module: sip-router
Branch: master
Commit: c56ccc8d156dcf01be7debe528d8572a82b43fad
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c56ccc8…
Author: Richard Good <richard.good(a)smilecoms.com>
Committer: Richard Good <richard.good(a)smilecoms.com>
Date: Fri May 2 12:15:53 2014 +0200
modules/ims_registrar_scscf: fix to remove subscriptions when UE explicitly deregisters
---
modules/ims_registrar_scscf/save.c | 31 +++++++++++++++++++------------
1 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/modules/ims_registrar_scscf/save.c b/modules/ims_registrar_scscf/save.c
index 78d5793..6b5794b 100644
--- a/modules/ims_registrar_scscf/save.c
+++ b/modules/ims_registrar_scscf/save.c
@@ -76,12 +76,15 @@
#include "server_assignment.h"
#include "userdata_parser.h"
#include "../../lib/ims/ims_getters.h"
+#include "registrar_notify.h"
#include "cxdx_sar.h"
extern struct tm_binds tmb;
extern int store_data_on_dereg; /**< should we store SAR user data on de-registration */
+extern int ue_unsubscribe_on_dereg;
+
/*! \brief
* Calculate absolute expires value per contact as follows:
* 1) If the contact has expires value, use the value. If it
@@ -607,18 +610,22 @@ static inline int unregister_contact(udomain_t* _d, str* public_identity, contac
//Richard added this - fix to remove subscribes that have presentity and watcher uri same as a contact aor that is being removed
//When UEs explicitly dereg - they don't unsubscribe, so we remove subscriptions for them
- s = impu_rec->shead;
- LM_DBG("Checking if there is a subscription to this IMPU that has same watcher contact as this contact");
- while (s) {
-
- LM_DBG("Subscription for this impurecord: watcher uri [%.*s] presentity uri [%.*s] watcher contact [%.*s] ", s->watcher_uri.len, s->watcher_uri.s,
- s->presentity_uri.len, s->presentity_uri.s, s->watcher_contact.len, s->watcher_contact.s);
- LM_DBG("Contact to be removed [%.*s] ", ucontact->c.len, ucontact->c.s);
- if ((s->watcher_contact.len == ucontact->c.len) && (strncasecmp(s->watcher_contact.s, ucontact->c.s, ucontact->c.len) == 0)) {
- LM_DBG("This contact has a subscription to its own status - so going to delete the subscription");
- ul.external_delete_subscriber(s, _d, 0 /*domain is locked*/);
- }
- s = s->next;
+ //only do this if ue_unsubscribe_on_dereg is set to 0
+ if(!ue_unsubscribe_on_dereg){
+ s = impu_rec->shead;
+ LM_DBG("Checking if there is a subscription to this IMPU that has same watcher contact as this contact");
+ while (s) {
+
+ LM_DBG("Subscription for this impurecord: watcher uri [%.*s] presentity uri [%.*s] watcher contact [%.*s] ", s->watcher_uri.len, s->watcher_uri.s,
+ s->presentity_uri.len, s->presentity_uri.s, s->watcher_contact.len, s->watcher_contact.s);
+ LM_DBG("Contact to be removed [%.*s] ", ucontact->c.len, ucontact->c.s);
+ if(contact_port_ip_match(&s->watcher_contact, &ucontact->c)) {
+ //if ((s->watcher_contact.len == ucontact->c.len) && (strncasecmp(s->watcher_contact.s, ucontact->c.s, ucontact->c.len) == 0)) {
+ LM_DBG("This contact has a subscription to its own status - so going to delete the subscription");
+ ul.external_delete_subscriber(s, _d, 0 /*domain is locked*/);
+ }
+ s = s->next;
+ }
}
if (ul.delete_ucontact(impu_rec, ucontact) != 0) {
Module: sip-router
Branch: master
Commit: f149fe0bf499c2ed9a4238cea5bdf2ecbb28c941
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=f149fe0…
Author: Richard Good <richard.good(a)smilecoms.com>
Committer: Richard Good <richard.good(a)smilecoms.com>
Date: Fri May 2 12:15:05 2014 +0200
modules/ims_registrar_scscf: Fix to not send notifies to UEs that explicitly deregister
---
modules/ims_registrar_scscf/registrar_notify.c | 100 +++++++++++++++++++-----
modules/ims_registrar_scscf/registrar_notify.h | 3 +
2 files changed, 82 insertions(+), 21 deletions(-)
diff --git a/modules/ims_registrar_scscf/registrar_notify.c b/modules/ims_registrar_scscf/registrar_notify.c
index 3f04dbe..e5086a5 100644
--- a/modules/ims_registrar_scscf/registrar_notify.c
+++ b/modules/ims_registrar_scscf/registrar_notify.c
@@ -90,6 +90,8 @@ static str subss_hdr2 = {"\r\n", 2};
static str ctype_hdr1 = {"Content-Type: ", 14};
static str ctype_hdr2 = {"\r\n", 2};
+extern int ue_unsubscribe_on_dereg;
+
int notify_init() {
notification_list = shm_malloc(sizeof (reg_notification_list));
if (!notification_list) return 0;
@@ -468,7 +470,7 @@ int event_reg(udomain_t* _d, impurecord_t* r_passed, ucontact_t* c_passed, int e
return 0;
}
- content = get_reginfo_partial(r_passed, c_passed, event_type);
+ content = get_reginfo_partial(r_passed, c_passed, event_type);
create_notifications(_d, r_passed, c_passed, presentity_uri, watcher_contact, content, event_type);
if (content.s) pkg_free(content.s);
// if (send_now) notification_timer(0, 0);
@@ -1202,6 +1204,52 @@ int subscribe_reply(struct sip_msg *msg, int code, char *text, int *expires, str
}
+/* function to convert contact aor to only have data after @ - ie strip user part */
+int aor_to_contact(str* aor, str* contact) {
+ char* p;
+ int ret = 0; //success
+
+ contact->s = aor->s;
+ contact->len = aor->len;
+ if (memcmp(aor->s, "sip:", 4) == 0) {
+ contact->s = aor->s + 4;
+ contact->len-=4;
+ }
+
+ if ((p=memchr(contact->s, '@', contact->len))) {
+ contact->len -= (p - contact->s + 1);
+ contact->s = p+1;
+ }
+
+ if ((p=memchr(contact->s, ';', contact->len))) {
+ contact->len = p - contact->s;
+ }
+
+ if ((p=memchr(contact->s, '>', contact->len))) {
+ contact->len = p - contact->s;
+ }
+
+ return ret;
+}
+
+/*!
+ * \brief Match a contact record to a contact string but only compare the ip port portion
+ * \param ptr contact record
+ * \param _c contact string
+ * \return ptr on successfull match, 0 when they not match
+ */
+int contact_port_ip_match(str *c1, str *c2) {
+
+ str ip_port1, ip_port2;
+ aor_to_contact(c1, &ip_port1);//strip userpart from test contact
+ aor_to_contact(c2, &ip_port2);//strip userpart from test contact
+ LM_DBG("Matching contact using only port and ip - comparing [%.*s] and [%.*s]\n", ip_port1.len, ip_port1.s, ip_port2.len, ip_port2.s);
+ if ((ip_port1.len == ip_port2.len) && !memcmp(ip_port1.s, ip_port2.s, ip_port1.len)) {
+ return 1;
+ }
+ return 0;
+}
+
static str subs_terminated = {"terminated", 10};
static str subs_active = {"active;expires=", 15};
@@ -1268,10 +1316,10 @@ void create_notifications(udomain_t* _t, impurecord_t* r_passed, ucontact_t* c_p
LM_DBG("Subscription state: [%.*s]", subscription_state.len, subscription_state.s);
}
- //This is a fix to ensure that when a user subscribes a full reg info is only sent to that UE
+ //This is a fix to ensure that when a user subscribes a full reg info is only sent to that UE
if (event_type == IMS_REGISTRAR_SUBSCRIBE) {
- if ((watcher_contact->len == s->watcher_contact.len) && (strncasecmp(s->watcher_contact.s, watcher_contact->s, watcher_contact->len) == 0) &&
- (presentity_uri->len == s->presentity_uri.len) && (strncasecmp(s->presentity_uri.s, presentity_uri->s, presentity_uri->len) == 0)) {
+ if (contact_port_ip_match(watcher_contact, &s->watcher_contact) &&
+ (presentity_uri->len == s->presentity_uri.len) && (memcmp(s->presentity_uri.s, presentity_uri->s, presentity_uri->len) == 0)) {
LM_DBG("This is a fix to ensure that we only send full reg info XML to the UE that just subscribed");
LM_DBG("about to make new notification!");
n = new_notification(subscription_state, content_type, content,
@@ -1291,23 +1339,33 @@ void create_notifications(udomain_t* _t, impurecord_t* r_passed, ucontact_t* c_p
}
}
} else {
- LM_DBG("about to make new notification!");
- n = new_notification(subscription_state, content_type, content,
- s->version++, s);
- if (n) {
- //LM_DBG("Notification exists - about to add it");
- //add_notification(n);
-
- //Richard just gonna send it - not bother queueing etc.
- //TODO look at impact of this - sending straight away vs queueing and getting another process to send
- LM_DBG("About to send notification");
- send_notification(n);
- LM_DBG("About to free notification");
- free_notification(n);
- } else {
- LM_DBG("Notification does not exist");
- }
- }
+
+ if(event_type == IMS_REGISTRAR_CONTACT_UNREGISTERED && !ue_unsubscribe_on_dereg &&
+ (contact_port_ip_match(&c_passed->c, &s->watcher_contact) &&
+ (r_passed->public_identity.len == s->presentity_uri.len) && (memcmp(s->presentity_uri.s, r_passed->public_identity.s, r_passed->public_identity.len) == 0))){
+ //if this is UNREGISTER and the UEs do not unsubscribe to dereg and this is a UE subscribing to its own reg event
+ //then we do not send notifications
+ LM_DBG("This is a UNREGISTER event for a UE that subscribed to its own state that does not unsubscribe to dereg - therefore no notification");
+ }
+ else{
+ LM_DBG("about to make new notification!");
+ n = new_notification(subscription_state, content_type, content,
+ s->version++, s);
+ if (n) {
+ //LM_DBG("Notification exists - about to add it");
+ //add_notification(n);
+
+ //Richard just gonna send it - not bother queueing etc.
+ //TODO look at impact of this - sending straight away vs queueing and getting another process to send
+ LM_DBG("About to send notification");
+ send_notification(n);
+ LM_DBG("About to free notification");
+ free_notification(n);
+ } else {
+ LM_DBG("Notification does not exist");
+ }
+ }
+ }
//}
s = s->next;
diff --git a/modules/ims_registrar_scscf/registrar_notify.h b/modules/ims_registrar_scscf/registrar_notify.h
index cbac7d3..8886316 100644
--- a/modules/ims_registrar_scscf/registrar_notify.h
+++ b/modules/ims_registrar_scscf/registrar_notify.h
@@ -144,4 +144,7 @@ dlg_t* build_dlg_t_from_notification(reg_notification* n);
int notify_init();
void notify_destroy();
+int aor_to_contact(str* aor, str* contact);
+int contact_port_ip_match(str *c1, str *c2);
+
#endif //S_CSCF_REGISTRAR_NOTIFY_H_
Module: sip-router
Branch: master
Commit: 5f49f1ab481ef4c8b9fc236d905485390969f894
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5f49f1a…
Author: Richard Good <richard.good(a)smilecoms.com>
Committer: Richard Good <richard.good(a)smilecoms.com>
Date: Fri May 2 12:14:00 2014 +0200
modules/ims_registrar_scscf: added mod_param ue_unsubscribe_on_dereg
New mod param ue_unsubscribe_on_dereg: for UEs that do no send UNSUBSCRIBE for reg event when deregistering
---
modules/ims_registrar_scscf/reg_mod.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/modules/ims_registrar_scscf/reg_mod.c b/modules/ims_registrar_scscf/reg_mod.c
index 7194588..30898b2 100644
--- a/modules/ims_registrar_scscf/reg_mod.c
+++ b/modules/ims_registrar_scscf/reg_mod.c
@@ -91,6 +91,9 @@ int scscf_support_wildcardPSI = 0;
char *scscf_name = "sip:scscf2.ims.smilecoms.com:6060"; /* default scscf_name - actual should be set via parameter*/
int store_data_on_dereg = 0; /**< should we store SAR data on de-registration */
+int ue_unsubscribe_on_dereg = 0; /*many UEs do not unsubscribe on de reg - therefore we should remove their subscription and not send a notify
+ Some UEs do unsubscribe then everything is fine*/
+
/* parameters storage */
char* cxdx_dest_realm_s = "ims.smilecoms.com";
str cxdx_dest_realm;
@@ -242,6 +245,7 @@ static param_export_t params[] = {
{"subscription_default_expires", INT_PARAM, &subscription_default_expires},
{"subscription_min_expires", INT_PARAM, &subscription_min_expires},
{"subscription_max_expires", INT_PARAM, &subscription_max_expires},
+ {"ue_unsubscribe_on_dereg", INT_PARAM, &ue_unsubscribe_on_dereg},
{0, 0, 0}
};
THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
The following task has a new comment added:
FS#426 - DNS SRV lookup in rewritehost port fails
User who did this - Rob Eijgenraam (robeyg)
----------
retrieved 4.1 branch and compiled it.
working again!
thanks for quick response.
----------
More information can be found at the following URL:
http://sip-router.org/tracker/index.php?do=details&task_id=426#comment1429
You are receiving this message because you have requested it from the Flyspray bugtracking system. If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.