浏览代码

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.
pd 14 年之前
父节点
当前提交
17f0202793
共有 5 个文件被更改,包括 59 次插入2 次删除
  1. 23 2
      modules_k/pua/README
  2. 24 0
      modules_k/pua/doc/pua_admin.xml
  3. 3 0
      modules_k/pua/hash.c
  4. 8 0
      modules_k/pua/pua.c
  5. 1 0
      modules_k/pua/pua.h

+ 23 - 2
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();

+ 24 - 0
modules_k/pua/doc/pua_admin.xml

@@ -256,6 +256,30 @@ modparam("pua", "dlginfo_increase_version", 1)
 ...
 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>

+ 3 - 0
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,

+ 8 - 0
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, &reginfo_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);

+ 1 - 0
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;