Module: sip-router Branch: master Commit: 17f020279301b9aa8c0e4b0f20ef3a1f9d059d04 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=17f02027...
Author: pd peter.dunkley@crocodile-rcs.com Committer: pd peter.dunkley@crocodile-rcs.com Date: Thu Jul 21 15:04:23 2011 +0100
pua(k): added new modparam check_remote_contact
- This defaults to 1 (current behaviour), but when set to 0 means that the pua module won't check that the remote contact matches when finding a dialog in the hash table.
This is very important as when the initial SUBSCRIBE is created for an RLS to Presence dialog the remote contact will be set to the R-URI of the SUBSCRIBE. However, subsequent requests within the dialog need to use the remote contact as provided by the far end as the R-URI.
This meant that re-SUBSCRIBEs from RLS to Presence get treated as new dialog forming requests and causes lots of extra entries in the pua and active_watchers tables.
---
modules_k/pua/README | 25 +++++++++++++++++++++++-- modules_k/pua/doc/pua_admin.xml | 24 ++++++++++++++++++++++++ modules_k/pua/hash.c | 3 +++ modules_k/pua/pua.c | 8 ++++++++ modules_k/pua/pua.h | 1 + 5 files changed, 59 insertions(+), 2 deletions(-)
diff --git a/modules_k/pua/README b/modules_k/pua/README index bdd1aed..766a8cd 100644 --- a/modules_k/pua/README +++ b/modules_k/pua/README @@ -32,6 +32,7 @@ Anca-Maria Vamanu 3.7. outbound_proxy (str) 3.8. dlginfo_increase_version (int) 3.9. reginfo_increase_version (int) + 3.10. check_remote_contact (int)
4. Exported Functions
@@ -59,7 +60,8 @@ Anca-Maria Vamanu 1.7. Set outbound_proxy parameter 1.8. Set dlginfo_increase_version parameter 1.9. Set reginfo_increase_version parameter - 1.10. pua_update_contact usage + 1.10. Set check_remote_contact parameter + 1.11. pua_update_contact usage 2.1. pua_api structure 2.2. pua_is_dialog usage example 2.3. register_puacb usage example @@ -86,6 +88,7 @@ Chapter 1. Admin Guide 3.7. outbound_proxy (str) 3.8. dlginfo_increase_version (int) 3.9. reginfo_increase_version (int) + 3.10. check_remote_contact (int)
4. Exported Functions
@@ -145,6 +148,7 @@ Chapter 1. Admin Guide 3.7. outbound_proxy (str) 3.8. dlginfo_increase_version (int) 3.9. reginfo_increase_version (int) + 3.10. check_remote_contact (int)
3.1. hash_size (int)
@@ -264,6 +268,23 @@ modparam("pua", "dlginfo_increase_version", 1) modparam("pua", "reginfo_increase_version", 1) ...
+3.10. check_remote_contact (int) + + When sending a SUBSCRIBE check that the remote contact matches the one + in the stored dialog or not. If the remote contact is checked and does + not match the one in the stored dialog then the dialog is not matched. + Checking the remote contact can cause problems when using modules like + RLS and should not be required in order to properly match the dialog + anyway. Set this parameter to 0 to disable checking of remote contact + for SUBSCRIBE dialog matching. + + Default value is “1”. + + Example 1.10. Set check_remote_contact parameter +... +modparam("pua", "check_remote_contact", 0) +... + 4. Exported Functions
4.1. pua_update_contact() @@ -283,7 +304,7 @@ modparam("pua", "reginfo_increase_version", 1) * 1 - if success. * -1 - if error.
- Example 1.10. pua_update_contact usage + Example 1.11. pua_update_contact usage ... if(method=="NOTIFY") pua_update_contact(); diff --git a/modules_k/pua/doc/pua_admin.xml b/modules_k/pua/doc/pua_admin.xml index 0868de4..495b4c8 100644 --- a/modules_k/pua/doc/pua_admin.xml +++ b/modules_k/pua/doc/pua_admin.xml @@ -259,6 +259,30 @@ modparam("pua", "reginfo_increase_version", 1) </programlisting> </example> </section> + <section> + <title><varname>check_remote_contact</varname> (int)</title> + <para> + When sending a SUBSCRIBE check that the remote contact matches the + one in the stored dialog or not. If the remote contact is checked + and does not match the one in the stored dialog then the dialog is + not matched. Checking the remote contact can cause problems when + using modules like RLS and should not be required in order to + properly match the dialog anyway. Set this parameter to 0 to + disable checking of remote contact for SUBSCRIBE dialog matching. + </para> + <para> + <emphasis>Default value is <quote>1</quote>. + </emphasis> + </para> + <example> + <title>Set <varname>check_remote_contact</varname> parameter</title> + <programlisting format="linespecific"> +... +modparam("pua", "check_remote_contact", 0) +... +</programlisting> + </example> + </section> </section>
<section> diff --git a/modules_k/pua/hash.c b/modules_k/pua/hash.c index bc8eb20..c5e996c 100644 --- a/modules_k/pua/hash.c +++ b/modules_k/pua/hash.c @@ -140,6 +140,9 @@ ua_pres_t* search_htable(ua_pres_t* pres, unsigned int hash_code) (strncmp(p->watcher_uri->s, pres->watcher_uri->s, pres->watcher_uri->len )==0)) { + if (check_remote_contact == 0) + break; + if(pres->remote_contact.s) if(pres->remote_contact.len== p->remote_contact.len && strncmp(pres->remote_contact.s, p->remote_contact.s, diff --git a/modules_k/pua/pua.c b/modules_k/pua/pua.c index 6600a98..c507797 100644 --- a/modules_k/pua/pua.c +++ b/modules_k/pua/pua.c @@ -65,6 +65,7 @@ static str db_url = str_init(DEFAULT_DB_URL); static str db_table= str_init("pua"); int update_period= 100; str outbound_proxy = {0, 0}; +int check_remote_contact = 1; int startup_time = 0; int dlginfo_increase_version = 0; int reginfo_increase_version = 0; @@ -125,6 +126,7 @@ static param_export_t params[]={ {"outbound_proxy", STR_PARAM, &outbound_proxy.s }, {"dlginfo_increase_version", INT_PARAM, &dlginfo_increase_version}, {"reginfo_increase_version", INT_PARAM, ®info_increase_version}, + {"check_remote_contact", INT_PARAM, &check_remote_contact }, {0, 0, 0 } };
@@ -231,6 +233,12 @@ static int mod_init(void) return -1; }
+ if(check_remote_contact<0 || check_remote_contact>1) + { + LM_ERR("bad value for check_remote_contact\n"); + return -1; + } + startup_time = (int) time(NULL); register_timer(hashT_clean, 0, update_period- 5); diff --git a/modules_k/pua/pua.h b/modules_k/pua/pua.h index 3db757a..bb2072d 100644 --- a/modules_k/pua/pua.h +++ b/modules_k/pua/pua.h @@ -42,6 +42,7 @@ extern int min_expires; extern int pua_ul_publish; extern int default_expires; extern str outbound_proxy; +extern int check_remote_contact;
int reginfo_increase_version;