瀏覽代碼

usrloc: New matching mode: CALLID_ONLY

Carsten Bock 10 年之前
父節點
當前提交
a6609f5fb3
共有 6 個文件被更改,包括 106 次插入47 次删除
  1. 52 44
      modules/usrloc/README
  2. 12 0
      modules/usrloc/doc/usrloc.xml
  3. 13 0
      modules/usrloc/doc/usrloc_admin.xml
  4. 1 0
      modules/usrloc/ul_mod.c
  5. 4 3
      modules/usrloc/ul_mod.h
  6. 24 0
      modules/usrloc/urecord.c

+ 52 - 44
modules/usrloc/README

@@ -16,9 +16,17 @@ Edited by
 
 Bogdan-Andrei Iancu
 
-   Copyright © 2003 FhG FOKUS
+Edited by
+
+Carsten Bock
+
+   ng-voice GmbH
+
+   Copyright © 2003 FhG FOKUS
+
+   Copyright © 2005 Voice Sistem SRL
 
-   Copyright © 2005 Voice Sistem SRL
+   Copyright © 2015 ng-voice GmbH
      __________________________________________________________________
 
    Table of Contents
@@ -296,8 +304,8 @@ Chapter 1. Admin Guide
        retransmissions in this case.
 
    To find out how to control/select the contact maching algorithm, please
-   see the module parameter matching_mode - Section 3.26, "matching_mode
-   (integer)".
+   see the module parameter matching_mode - Section 3.26, “matching_mode
+   (integer)�.
 
 2. Dependencies
 
@@ -364,7 +372,7 @@ Chapter 1. Admin Guide
    is or not natted). This is a branch flag and it will be imported and
    used by all other modules depending of usrloc module.
 
-   Default value is "not set".
+   Default value is “not set�.
 
    Example 1.1. Set nat_bflag parameter
 ...
@@ -375,7 +383,7 @@ modparam("usrloc", "nat_bflag", 3)
 
    Name of database column containing usernames.
 
-   Default value is "username".
+   Default value is “username�.
 
    Example 1.2. Set user_column parameter
 ...
@@ -386,7 +394,7 @@ modparam("usrloc", "user_column", "username")
 
    Name of database column containing domains.
 
-   Default value is "domain".
+   Default value is “domain�.
 
    Example 1.3. Set user_column parameter
 ...
@@ -397,7 +405,7 @@ modparam("usrloc", "domain_column", "domain")
 
    Name of database column containing contacts.
 
-   Default value is "contact".
+   Default value is “contact�.
 
    Example 1.4. Set contact_column parameter
 ...
@@ -408,7 +416,7 @@ modparam("usrloc", "contact_column", "contact")
 
    Name of database column containing expires value.
 
-   Default value is "expires".
+   Default value is “expires�.
 
    Example 1.5. Set expires_column parameter
 ...
@@ -419,7 +427,7 @@ modparam("usrloc", "expires_column", "expires")
 
    Name of database column containing q values.
 
-   Default value is "q".
+   Default value is “q�.
 
    Example 1.6. Set q_column parameter
 ...
@@ -430,7 +438,7 @@ modparam("usrloc", "q_column", "q")
 
    Name of database column containing Call-ID values.
 
-   Default value is "callid".
+   Default value is “callid�.
 
    Example 1.7. Set callid_column parameter
 ...
@@ -441,7 +449,7 @@ modparam("usrloc", "callid_column", "callid")
 
    Name of database column containing Cseq.
 
-   Default value is "cseq".
+   Default value is “cseq�.
 
    Example 1.8. Set cseq_column parameter
 ...
@@ -452,7 +460,7 @@ modparam("usrloc", "cseq_column", "cseq")
 
    Name of database column containing supported methods.
 
-   Default value is "methods".
+   Default value is “methods�.
 
    Example 1.9. Set methods_column parameter
 ...
@@ -463,7 +471,7 @@ modparam("usrloc", "methods_column", "methods")
 
    Name of database column to save the internal flags of the record.
 
-   Default value is "flags".
+   Default value is “flags�.
 
    Example 1.10. Set flags_column parameter
 ...
@@ -474,7 +482,7 @@ modparam("usrloc", "flags_column", "flags")
 
    Name of database column to save the branch/contact flags of the record.
 
-   Default value is "cflags".
+   Default value is “cflags�.
 
    Example 1.11. Set cflags_column parameter
 ...
@@ -485,7 +493,7 @@ modparam("usrloc", "cflags_column", "cflags")
 
    Name of database column containing user-agent values.
 
-   Default value is "user_agent".
+   Default value is “user_agent�.
 
    Example 1.12. Set user_agent_column parameter
 ...
@@ -497,7 +505,7 @@ modparam("usrloc", "user_agent_column", "user_agent")
    Name of database column containing the source IP, port, and protocol
    from the REGISTER message.
 
-   Default value is "received".
+   Default value is “received�.
 
    Example 1.13. Set received_column parameter
 ...
@@ -509,7 +517,7 @@ modparam("usrloc", "received_column", "received")
    Name of database column containing the received socket information
    (IP:port) for the REGISTER message.
 
-   Default value is "socket".
+   Default value is “socket�.
 
    Example 1.14. Set socket_column parameter
 ...
@@ -520,7 +528,7 @@ modparam("usrloc", "socket_column", "socket")
 
    Name of database column containing the Path header.
 
-   Default value is "path".
+   Default value is “path�.
 
    Example 1.15. Set path_column parameter
 ...
@@ -531,7 +539,7 @@ modparam("usrloc", "path_column", "path")
 
    Name of database column containing the Kamailio record unique id.
 
-   Default value is "ruid".
+   Default value is “ruid�.
 
    Example 1.16. Set ruid_column parameter
 ...
@@ -543,7 +551,7 @@ modparam("usrloc", "ruid_column", "myruid")
    Name of database column containing the SIP instance ID (GRUU -
    RFC5627). This is a unique device identifier - UUID.
 
-   Default value is "instance".
+   Default value is “instance�.
 
    Example 1.17. Set instance_column parameter
 ...
@@ -554,7 +562,7 @@ modparam("usrloc", "instance_column", "myinstance")
 
    Name of database table column containing the value for server id.
 
-   Default value is "server_id".
+   Default value is “server_id�.
 
    Example 1.18. Set server_id_column parameter
 ...
@@ -565,7 +573,7 @@ modparam("usrloc", "server_id_column", "srv_id")
 
    Name of database table column containing the value for connection id.
 
-   Default value is "connection_id".
+   Default value is “connection_id�.
 
    Example 1.19. Set connection_id_column parameter
 ...
@@ -577,7 +585,7 @@ modparam("usrloc", "connection_id_column", "con_id")
    Name of database table column containing the value for keepalive
    status.
 
-   Default value is "keepalive".
+   Default value is “keepalive�.
 
    Example 1.20. Set keepalive_column parameter
 ...
@@ -590,7 +598,7 @@ modparam("usrloc", "keepalive_column", "kalive")
    identifing the user (along with the username part). Useful in multi
    domain scenarios. Non 0 value means true.
 
-   Default value is "0 (false)".
+   Default value is “0 (false)�.
 
    Example 1.21. Set use_domain parameter
 ...
@@ -602,7 +610,7 @@ modparam("usrloc", "use_domain", 1)
    If the user's contacts should be kept timestamp ordered; otherwise the
    contact will be ordered based on q value. Non 0 value means true.
 
-   Default value is "0 (false)".
+   Default value is “0 (false)�.
 
    Example 1.22. Set desc_time_order parameter
 ...
@@ -626,7 +634,7 @@ modparam("usrloc", "timer_interval", 120)
 
    URL of the database that should be used.
 
-   Default value is "mysql://kamailio:kamailiorw@localhost/kamailio".
+   Default value is “mysql://kamailio:kamailiorw@localhost/kamailio�.
 
    Example 1.24. Set db_url parameter
 ...
@@ -687,7 +695,7 @@ modparam("usrloc", "db_mode", 2)
 3.26. matching_mode (integer)
 
    What contact matching algorithm to be used. Refer to section
-   Section 1.1, "Contact matching" for the description of the algorithms.
+   Section 1.1, “Contact matching� for the description of the algorithms.
 
    The parameter may take the following values:
      * 0 - CONTACT ONLY based matching algorithm.
@@ -715,7 +723,7 @@ modparam("usrloc", "matching_mode", 1)
 
    A value of 0 disable the retransmission detection.
 
-   Default value is "20 seconds".
+   Default value is “20 seconds�.
 
    Example 1.27. Set cseq_delay parameter
 ...
@@ -729,7 +737,7 @@ modparam("usrloc", "cseq_delay", 5)
    startup. For 1MB of private memory (default) it should be below 4000.
    The database driver must support fetch_result() capability.
 
-   Default value is "2000".
+   Default value is “2000�.
 
    Example 1.28. Set fetch_rows parameter
 ...
@@ -742,7 +750,7 @@ modparam("usrloc", "fetch_rows", 3000)
    location records is 2^hash_size. For hash_size=4, the number of slots
    of the hash table is 16.
 
-   Default value is "10" (1024 slots).
+   Default value is “10� (1024 slots).
 
    Example 1.29. Set hash_size parameter
 ...
@@ -756,7 +764,7 @@ modparam("usrloc", "hash_size", 12)
    parameter only to load tables that are not used by registrar module
    directly in configuration file.
 
-   Default value is "NULL".
+   Default value is “NULL�.
 
    Example 1.30. Set preload parameter
 ...
@@ -769,7 +777,7 @@ modparam("usrloc", "preload", "location")
    UPDATE DB operations. It is recommended to set this parameter if you
    use Cassandra as a DB backend.
 
-   Default value is "0".
+   Default value is “0�.
 
    Example 1.31. Set db_update_as_insert parameter
 ...
@@ -784,7 +792,7 @@ modparam("usrloc", "db_update_as_insert", 1)
    parameter is ignored - e.g., MySQL and Postgres DB connectors offer
    affected_rows().
 
-   Default value is "0" (no DB INSERT).
+   Default value is “0� (no DB INSERT).
 
    Example 1.32. Set db_check_update parameter
 ...
@@ -798,7 +806,7 @@ modparam("usrloc", "db_check_update", 1)
    set to 0, no dedicated timer is started, the one from core will be
    used.
 
-   Default value is "0".
+   Default value is “0�.
 
    Example 1.33. Set timer_procs parameter
 ...
@@ -812,7 +820,7 @@ modparam("usrloc", "timer_procs", 4)
    xavp_contact must also be set to the same value to use the
    t_load_contacts and t_next_contacts functions.
 
-   Default value is "NULL".
+   Default value is “NULL�.
 
    Example 1.34. Set xavp_contact parameter
 ...
@@ -825,7 +833,7 @@ modparam("usrloc", "xavp_contact", "ulattrs")
    value. If it is set to 0, the old style using aor, contact and call-id
    is done.
 
-   Default value is "1".
+   Default value is “1�.
 
    Example 1.35. Set db_ops_ruid parameter
 ...
@@ -838,7 +846,7 @@ modparam("usrloc", "db_ops_ruid", 0)
    TCP/TLS/WS/WSS transports when it looses corresponding tcp connections.
    Does not currently work in DB-Only scheme.
 
-   Default value is "0".
+   Default value is “0�.
 
    Example 1.36. Set handle_lost_tcp parameter
 ...
@@ -850,7 +858,7 @@ modparam("usrloc", "handle_lost_tcp", 1)
    If set to 1, Kamailio will close the TCP connection when a contact has
    expired, if the corresponding transport is TCP/TLS/WS/WSS.
 
-   Default value is "0".
+   Default value is “0�.
 
    Example 1.37. Set close_expired_tcp parameter
 ...
@@ -865,7 +873,7 @@ modparam("usrloc", "close_expired_tcp", 1)
    expected to be on default type 'DATETIME'. When it is 1, the database
    columns types have to be changed manually to 'BIGINT'.
 
-   Default value is "0".
+   Default value is “0�.
 
    Example 1.38. Set expires_type parameter
 ...
@@ -880,7 +888,7 @@ modparam("usrloc", "expires_type", 1)
    (working for MySQL, PostgreSQL, ...). If it is set to 1, the query
    required by Oracle is used.
 
-   Default value is "0".
+   Default value is “0�.
 
    Example 1.39. Set db_raw_fetch_type parameter
 ...
@@ -892,7 +900,7 @@ modparam("usrloc", "db_raw_fetch_type", 1)
    If set to 1, the insert operation to database will add null values in
    the sql statement.
 
-   Default value is "0" (don't add null fields in insert statement).
+   Default value is “0� (don't add null fields in insert statement).
 
    Example 1.40. Set db_insert_null parameter
 ...
@@ -937,7 +945,7 @@ modparam("usrloc", "db_insert_null", 1)
 
    Parameters:
      * brief - (optional, may not be present); if equals to string
-       "brief", a brief dump will be done (only AOR and contacts, with no
+       “brief�, a brief dump will be done (only AOR and contacts, with no
        other details)
 
 5.4.  ul_flush
@@ -1277,7 +1285,7 @@ cont, ua, sock)
    them in the caller-supplied buffer. If the buffer is too small, the
    function returns positive value indicating how much additional space
    would be necessary to accommodate all of them. Please note that the
-   positive return value should be used only as a "hint", as there is no
+   positive return value should be used only as a “hint�, as there is no
    guarantee that during the time between two subsequent calls number of
    registered contacts will remain the same.
 

+ 12 - 0
modules/usrloc/doc/usrloc.xml

@@ -40,6 +40,14 @@
 			<email>[email protected]</email>
 		</address>
 		</editor>
+		<editor>
+		<firstname>Carsten</firstname>
+		<surname>Bock</surname>
+		<affiliation><orgname>ng-voice GmbH</orgname></affiliation>
+		<address>
+			<email>[email protected]</email>
+		</address>
+		</editor>
 	</authorgroup>
 	<copyright>
 		<year>2003</year>
@@ -49,6 +57,10 @@
 		<year>2005</year>
 		<holder>Voice Sistem SRL</holder>
 	</copyright>
+	<copyright>
+		<year>2015</year>
+		<holder>ng-voice GmbH</holder>
+	</copyright>
 	</bookinfo>
 	<toc></toc>
 	

+ 13 - 0
modules/usrloc/doc/usrloc_admin.xml

@@ -64,6 +64,13 @@
 				case.
 			</para>
 			</listitem>
+			<listitem>
+			<para>
+				<emphasis>Call-id only based</emphasis> - it is not
+				according to RFC3261, as it will check the Call-ID only
+				(independent of the Contact-Header or Path).
+			</para>
+			</listitem>
 		</itemizedlist>
 		<para>
 		To find out how to control/select the contact maching algorithm, please see the
@@ -708,6 +715,12 @@ modparam("usrloc", "db_mode", 2)
 				If no path is available, it defaults to mode 0.
 				</para>
 			</listitem>
+			<listitem>
+				<para><emphasis>3</emphasis> - CALLID only based 
+				matching algorithm. This mode will discard any duplicate
+				registration coming through different paths.
+				</para>
+			</listitem>
 		</itemizedlist>
 		<para>
 		<emphasis>

+ 1 - 0
modules/usrloc/ul_mod.c

@@ -316,6 +316,7 @@ static int mod_init(void)
 		case CONTACT_ONLY:
 		case CONTACT_CALLID:
 		case CONTACT_PATH:
+		case CONTACT_CALLID_ONLY:
 			break;
 		default:
 			LM_ERR("invalid matching mode %d\n", matching_mode);

+ 4 - 3
modules/usrloc/ul_mod.h

@@ -104,9 +104,10 @@ extern unsigned int ul_db_srvid;
 /*
  * Matching algorithms
  */
-#define CONTACT_ONLY        (0)
-#define CONTACT_CALLID      (1)
-#define CONTACT_PATH        (2)
+#define CONTACT_ONLY         (0)
+#define CONTACT_CALLID       (1)
+#define CONTACT_PATH         (2)
+#define CONTACT_CALLID_ONLY  (3)
 
 extern int matching_mode;
 

+ 24 - 0
modules/usrloc/urecord.c

@@ -705,6 +705,27 @@ static inline struct ucontact* contact_path_match( ucontact_t* ptr, str* _c, str
 	return 0;
 }
 
+
+
+/*!
+ * \brief Match a contact record to a Call-ID only
+ * \param ptr contact record
+ * \param _c contact string
+ * \return ptr on successfull match, 0 when they not match
+ */
+static inline struct ucontact* contact_match_callidonly( ucontact_t* ptr, str* _callid)
+{
+	while(ptr) {
+		if ((_callid->len == ptr->callid.len) && !memcmp(_callid->s, ptr->callid.s, _callid->len)) {
+			return ptr;
+		}
+		
+		ptr = ptr->next;
+	}
+	return 0;
+}
+
+
 /*!
  * \brief Get pointer to ucontact with given contact
  * \param _r record where to search the contacts
@@ -737,6 +758,9 @@ int get_ucontact(urecord_t* _r, str* _c, str* _callid, str* _path, int _cseq,
 		case CONTACT_PATH:
 			ptr = contact_path_match( _r->contacts, _c, _path);
 			break;
+		case CONTACT_CALLID_ONLY:
+			ptr = contact_match_callidonly( _r->contacts, _callid);
+			break;
 		default:
 			LM_CRIT("unknown matching_mode %d\n", matching_mode);
 			return -1;