[Pkg-voip-commits] [kamailio] 08/09: add upstream patches from 4.3 branch

Victor Seva Lopez maniac-guest at moszumanska.debian.org
Sat Jun 27 13:32:55 UTC 2015


This is an automated email from the git hooks/post-receive script.

maniac-guest pushed a commit to branch master
in repository kamailio.

commit c2d68d82e7fa0d83f85dbf6519e5e32d56ec073c
Author: Victor Seva <linuxmaniac at torreviejawireless.org>
Date:   Sat Jun 27 14:57:04 2015 +0200

    add upstream patches from 4.3 branch
---
 debian/patches/series                              |   24 +
 ...te-documentation-concerning-xavp_contact-.patch |   50 +
 ...-restore-contact-attributes-when-serial-f.patch | 1216 ++++++++++++++++++++
 ...ll-contact-attributes-are-initialised-to-.patch |   26 +
 ...0004-dispatcher-Fix-typo-in-error-message.patch |   26 +
 ...-added-priority_ordering-module-parameter.patch |  755 ++++++++++++
 ...les-lcr-added-priority_ordering-module-pa.patch |  756 ++++++++++++
 .../0007-uac-updated-notes-about-uac_auth.patch    |   63 +
 ...ntrant-mutex-for-dialogs-hash-table-slots.patch |  178 +++
 .../0009-dialog-removed-unused-variable.patch      |   25 +
 .../upstream/0010-utils-fixed-indentation.patch    |  249 ++++
 .../0011-Makefile.defs-fixes-indentation.patch     |   31 +
 ...w-type-field-in-domain_attrs-to-be-a-DB1_.patch |   40 +
 ...t-return-0-if-no-match-for-sdp_get_line_s.patch |   30 +
 ...mailio-user-home-dir-set-to-var-run-kamai.patch |   30 +
 ...api-evapi_close-doesn-t-use-any-parameter.patch |   26 +
 ...r-log-level-set-to-notice-for-importing-u.patch |   28 +
 .../0017-uac-fixed-typos-in-log-message.patch      |   26 +
 ...more-documentation-for-exported-functions.patch |   59 +
 ...on-proper-access-to-items-in-routes-array.patch |  138 +++
 ...-print-the-message-after-relaying-to-evap.patch |   45 +
 ...ty-check-for-branch-index-stored-interanl.patch |   39 +
 ...-documentation-about-json-routing-documen.patch |  131 +++
 .../0023-rtjson-updated-the-readme-content.patch   |   77 ++
 .../upstream/0024-uac-refreshed-the-readme.patch   |  325 ++++++
 25 files changed, 4393 insertions(+)

diff --git a/debian/patches/series b/debian/patches/series
index 4c0ffd7..a517f5e 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,27 @@
+upstream/0001-usrloc-Update-documentation-concerning-xavp_contact-.patch
+upstream/0002-tm-Load-and-restore-contact-attributes-when-serial-f.patch
+upstream/0003-tm-Ensure-all-contact-attributes-are-initialised-to-.patch
+upstream/0004-dispatcher-Fix-typo-in-error-message.patch
+upstream/0005-modules-lcr-added-priority_ordering-module-parameter.patch
+upstream/0006-Revert-modules-lcr-added-priority_ordering-module-pa.patch
+upstream/0007-uac-updated-notes-about-uac_auth.patch
+upstream/0008-dialog-re-entrant-mutex-for-dialogs-hash-table-slots.patch
+upstream/0009-dialog-removed-unused-variable.patch
+upstream/0010-utils-fixed-indentation.patch
+upstream/0011-Makefile.defs-fixes-indentation.patch
+upstream/0012-domain-allow-type-field-in-domain_attrs-to-be-a-DB1_.patch
+upstream/0013-sdpops-don-t-return-0-if-no-match-for-sdp_get_line_s.patch
+upstream/0014-Makefile-kamailio-user-home-dir-set-to-var-run-kamai.patch
+upstream/0015-evapi-evapi_close-doesn-t-use-any-parameter.patch
+upstream/0016-rtjson-error-log-level-set-to-notice-for-importing-u.patch
+upstream/0017-uac-fixed-typos-in-log-message.patch
+upstream/0018-evapi-more-documentation-for-exported-functions.patch
+upstream/0019-rtjson-proper-access-to-items-in-routes-array.patch
+upstream/0020-evapi-don-t-print-the-message-after-relaying-to-evap.patch
+upstream/0021-rtjson-safety-check-for-branch-index-stored-interanl.patch
+upstream/0022-rtjson-more-documentation-about-json-routing-documen.patch
+upstream/0023-rtjson-updated-the-readme-content.patch
+upstream/0024-uac-refreshed-the-readme.patch
 no_lib64_on_64_bits.patch
 no_INSTALL_file.patch
 fix_export.patch
diff --git a/debian/patches/upstream/0001-usrloc-Update-documentation-concerning-xavp_contact-.patch b/debian/patches/upstream/0001-usrloc-Update-documentation-concerning-xavp_contact-.patch
new file mode 100644
index 0000000..6b47148
--- /dev/null
+++ b/debian/patches/upstream/0001-usrloc-Update-documentation-concerning-xavp_contact-.patch
@@ -0,0 +1,50 @@
+From 1396a656ee9653a94bf1d3470fc2054b54fa40e5 Mon Sep 17 00:00:00 2001
+From: Hugh Waite <hugh.waite at acision.com>
+Date: Wed, 27 May 2015 14:33:06 +0100
+Subject: [PATCH] usrloc: Update documentation concerning xavp_contact
+ parameter
+
+- Note that tm xavp_contact parameter must match
+(cherry picked from commit b4488aa7d743b7f14bc0232beaa69f3591aa1b66)
+---
+ modules/usrloc/README               | 6 ++++--
+ modules/usrloc/doc/usrloc_admin.xml | 6 ++++--
+ 2 files changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/modules/usrloc/README b/modules/usrloc/README
+index bd5daaa..b0d551a 100644
+--- a/modules/usrloc/README
++++ b/modules/usrloc/README
+@@ -807,8 +807,10 @@ modparam("usrloc", "timer_procs", 4)
+ 
+ 3.34. xavp_contact (string)
+ 
+-   The name of XAVP storring the attributes per contact. They are saved in
+-   location record and restored at lookup.
++   The name of XAVP storing the attributes per contact. They are saved in
++   location record and restored at lookup. The tm module parameter
++   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".
+ 
+diff --git a/modules/usrloc/doc/usrloc_admin.xml b/modules/usrloc/doc/usrloc_admin.xml
+index ee569a4..eb5c53d 100644
+--- a/modules/usrloc/doc/usrloc_admin.xml
++++ b/modules/usrloc/doc/usrloc_admin.xml
+@@ -895,8 +895,10 @@ modparam("usrloc", "timer_procs", 4)
+ 	<section id="usrloc.p.xavp_contact">
+ 		<title><varname>xavp_contact</varname> (string)</title>
+ 		<para>
+-		The name of XAVP storring the attributes per contact. They are saved
+-		in location record and restored at lookup.
++		The name of XAVP storing the attributes per contact. They are saved
++		in location record and restored at lookup. The tm module parameter
++		<varname>xavp_contact</varname> must also be set to the same value to use the
++		<varname>t_load_contacts</varname> and <varname>t_next_contacts</varname> functions.
+ 		</para>
+ 		<para>
+ 		<emphasis>
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0002-tm-Load-and-restore-contact-attributes-when-serial-f.patch b/debian/patches/upstream/0002-tm-Load-and-restore-contact-attributes-when-serial-f.patch
new file mode 100644
index 0000000..29b618a
--- /dev/null
+++ b/debian/patches/upstream/0002-tm-Load-and-restore-contact-attributes-when-serial-f.patch
@@ -0,0 +1,1216 @@
+From 8ca68616a289a342f2ccedb42c7889294cebc4af Mon Sep 17 00:00:00 2001
+From: Hugh Waite <hugh.waite at acision.com>
+Date: Wed, 27 May 2015 14:36:56 +0100
+Subject: [PATCH] tm: Load and restore contact attributes when serial forking
+
+- Add xavp_contact parameter for name of xavp holding attributes from usrloc
+- t_load_contacts: Load per branch attributes into contact XAVP
+- t_next_contacts/t_next_contact_flow: Restore branch attributes
+(cherry picked from commit 4033b77bf99b1521df8add14c6abea3c85d225d1)
+---
+ modules/tm/README         | 310 ++++++++++++++++++++++++----------------------
+ modules/tm/doc/params.xml |  21 ++++
+ modules/tm/t_serial.c     |  51 +++++++-
+ modules/tm/tm.c           |   2 +
+ 4 files changed, 233 insertions(+), 151 deletions(-)
+
+diff --git a/modules/tm/README b/modules/tm/README
+index 3b30194..3e1ebec 100644
+--- a/modules/tm/README
++++ b/modules/tm/README
+@@ -67,6 +67,7 @@ Juha Heinanen
+               4.43. remap_503_500 (boolean)
+               4.44. failure_exec_mode (boolean)
+               4.45. dns_reuse_rcv_socket (boolean)
++              4.46. xavp_contact (string)
+ 
+         5. Functions
+ 
+@@ -189,51 +190,52 @@ Juha Heinanen
+    1.43. Set remap_503_500 parameter
+    1.44. Set failure_exec_mode parameter
+    1.45. Set dns_reuse_rcv_socket parameter
+-   1.46. t_relay usage
+-   1.47. t_relay_to_udp usage
+-   1.48. t_on_failure usage
+-   1.49. t_on_branch_failure usage
+-   1.50. t_on_reply usage
+-   1.51. t_on_branch usage
+-   1.52. t_newtran usage
+-   1.53. t_reply usage
+-   1.54. t_lookup_request usage
+-   1.55. t_retransmit_reply usage
+-   1.56. t_release usage
+-   1.57. t_forward_nonack usage
+-   1.58. t_set_fr usage
+-   1.59. t_reset_fr usage
+-   1.60. t_set_max_lifetime usage
+-   1.61. t_reset_max_lifetime usage
+-   1.62. t_set_retr usage
+-   1.63. t_reset_retr usage
+-   1.64. t_set_auto_inv_100 usage
+-   1.65. t_branch_timeout usage
+-   1.66. t_branch_replied usage
+-   1.67. t_any_timeout usage
+-   1.68. t_any_replied usage
+-   1.69. t_grep_status usage
+-   1.70. t_is_canceled usage
+-   1.71. t_is_expired usage
+-   1.72. t_relay_cancel usage
+-   1.73. t_lookup_cancel usage
+-   1.74. t_drop_replies() usage
+-   1.75. t_save_lumps() usage
+-   1.76. t_load_contacts usage
+-   1.77. t_next_contacts usage
+-   1.78. t_next_contact_flow usage
+-   1.79. t_check_status usage
+-   1.80. t_check_trans usage
+-   1.81. t_set_disable_6xx usage
+-   1.82. t_set_disable_failover usage
+-   1.83. t_set_disable_internal_reply usage
+-   1.84. t_replicate usage
+-   1.85. t_relay_to usage
+-   1.86. t_set_no_e2e_cancel_reason usage
+-   1.87. t_replicate usage
+-   1.88. t_use_uac_headers usage
+-   1.89. t_is_retr_async_reply usage
+-   1.90. event_route[tm:branch-failure] usage
++   1.46. Set xavp_contact parameter
++   1.47. t_relay usage
++   1.48. t_relay_to_udp usage
++   1.49. t_on_failure usage
++   1.50. t_on_branch_failure usage
++   1.51. t_on_reply usage
++   1.52. t_on_branch usage
++   1.53. t_newtran usage
++   1.54. t_reply usage
++   1.55. t_lookup_request usage
++   1.56. t_retransmit_reply usage
++   1.57. t_release usage
++   1.58. t_forward_nonack usage
++   1.59. t_set_fr usage
++   1.60. t_reset_fr usage
++   1.61. t_set_max_lifetime usage
++   1.62. t_reset_max_lifetime usage
++   1.63. t_set_retr usage
++   1.64. t_reset_retr usage
++   1.65. t_set_auto_inv_100 usage
++   1.66. t_branch_timeout usage
++   1.67. t_branch_replied usage
++   1.68. t_any_timeout usage
++   1.69. t_any_replied usage
++   1.70. t_grep_status usage
++   1.71. t_is_canceled usage
++   1.72. t_is_expired usage
++   1.73. t_relay_cancel usage
++   1.74. t_lookup_cancel usage
++   1.75. t_drop_replies() usage
++   1.76. t_save_lumps() usage
++   1.77. t_load_contacts usage
++   1.78. t_next_contacts usage
++   1.79. t_next_contact_flow usage
++   1.80. t_check_status usage
++   1.81. t_check_trans usage
++   1.82. t_set_disable_6xx usage
++   1.83. t_set_disable_failover usage
++   1.84. t_set_disable_internal_reply usage
++   1.85. t_replicate usage
++   1.86. t_relay_to usage
++   1.87. t_set_no_e2e_cancel_reason usage
++   1.88. t_replicate usage
++   1.89. t_use_uac_headers usage
++   1.90. t_is_retr_async_reply usage
++   1.91. event_route[tm:branch-failure] usage
+ 
+ Chapter 1. Admin Guide
+ 
+@@ -289,6 +291,7 @@ Chapter 1. Admin Guide
+         4.43. remap_503_500 (boolean)
+         4.44. failure_exec_mode (boolean)
+         4.45. dns_reuse_rcv_socket (boolean)
++        4.46. xavp_contact (string)
+ 
+    5. Functions
+ 
+@@ -655,6 +658,7 @@ failure_route["serial"]
+    4.43. remap_503_500 (boolean)
+    4.44. failure_exec_mode (boolean)
+    4.45. dns_reuse_rcv_socket (boolean)
++   4.46. xavp_contact (string)
+ 
+ 4.1. fr_timer (integer)
+ 
+@@ -1564,6 +1568,18 @@ modparam("tm", "failure_exec_mode", 1)
+ modparam("tm", "dns_reuse_rcv_socket", 1)
+ ...
+ 
++4.46. xavp_contact (string)
++
++   The name of XAVP storing the attributes per contact. This must be the
++   same as the usrloc parameter xavp_contacts.
++
++   Default value is "NULL".
++
++   Example 1.46. Set xavp_contact parameter
++...
++modparam("tm|usrloc", "xavp_contact", "ulattrs")
++...
++
+ 5. Functions
+ 
+    5.1. t_relay([host, port])
+@@ -1618,7 +1634,7 @@ modparam("tm", "dns_reuse_rcv_socket", 1)
+    5.50. t_use_uac_headers()
+    5.51. t_is_retr_async_reply()
+ 
+-5.1. t_relay([host, port])
++5.1.  t_relay([host, port])
+ 
+    Relay a message statefully either to the destination indicated in the
+    current URI (if called without any parameters) or to the specified host
+@@ -1637,7 +1653,7 @@ modparam("tm", "dns_reuse_rcv_socket", 1)
+    Returns a negative value on failure -- you may still want to send a
+    negative reply upstream statelessly not to leave upstream UAC in lurch.
+ 
+-   Example 1.46. t_relay usage
++   Example 1.47. t_relay usage
+ ...
+ if (!t_relay())
+ {
+@@ -1646,7 +1662,7 @@ if (!t_relay())
+ };
+ ...
+ 
+-5.2. t_relay_to_udp([ip, port])
++5.2.  t_relay_to_udp([ip, port])
+ 
+    Relay a message statefully using a fixed protocol either to the
+    specified fixed destination or to a destination derived from the
+@@ -1664,7 +1680,7 @@ if (!t_relay())
+    derived from the message uri (using sip sepcific DNS lookups), but with
+    the protocol corresponding to the function name.
+ 
+-   Example 1.47. t_relay_to_udp usage
++   Example 1.48. t_relay_to_udp usage
+ ...
+ if (src_ip==10.0.0.0/8)
+         t_relay_to_udp("1.2.3.4", "5060"); # sent to 1.2.3.4:5060 over udp
+@@ -1672,19 +1688,19 @@ else
+         t_relay_to_tcp(); # relay to msg. uri, but over tcp
+ ...
+ 
+-5.3. t_relay_to_tcp([ip, port])
++5.3.  t_relay_to_tcp([ip, port])
+ 
+    See function t_relay_to_udp([ip, port]).
+ 
+-5.4. t_relay_to_tls([ip, port])
++5.4.  t_relay_to_tls([ip, port])
+ 
+    See function t_relay_to_udp([ip, port]).
+ 
+-5.5. t_relay_to_sctp([ip, port])
++5.5.  t_relay_to_sctp([ip, port])
+ 
+    See function t_relay_to_udp([ip, port]).
+ 
+-5.6. t_on_failure(failure_route)
++5.6.  t_on_failure(failure_route)
+ 
+    Sets failure routing block, to which control is passed after a
+    transaction completed with a negative result but before sending a final
+@@ -1704,7 +1720,7 @@ else
+    Meaning of the parameters is as follows:
+      * failure_route - Failure route block to be called.
+ 
+-   Example 1.48. t_on_failure usage
++   Example 1.49. t_on_failure usage
+ ...
+ route {
+     t_on_failure("1");
+@@ -1721,7 +1737,7 @@ failure_route[1] {
+    See test/onr.cfg for a more complex example of combination of serial
+    with parallel forking.
+ 
+-5.7. t_on_branch_failure(branch_failure_route)
++5.7.  t_on_branch_failure(branch_failure_route)
+ 
+    Sets the branch_failure routing block, to which control is passed on
+    each negative response to a transaction. This route is run before
+@@ -1740,7 +1756,7 @@ failure_route[1] {
+      * branch_failure_route - Name of the branch_failure route block to be
+        called (it is prefixed internally with 'tm:branch-failure:').
+ 
+-   Example 1.49. t_on_branch_failure usage
++   Example 1.50. t_on_branch_failure usage
+ ...
+ route {
+     t_on_branch_failure("myroute");
+@@ -1754,7 +1770,7 @@ event_route[tm:branch-failure:myroute] {
+ }
+ ...
+ 
+-5.8. t_on_reply(onreply_route)
++5.8.  t_on_reply(onreply_route)
+ 
+    Sets the reply routing block, to which control is passed when a reply
+    for the current transaction is received. Note that the set of commands
+@@ -1763,7 +1779,7 @@ event_route[tm:branch-failure:myroute] {
+    Meaning of the parameters is as follows:
+      * onreply_route - Onreply route block to be called.
+ 
+-   Example 1.50. t_on_reply usage
++   Example 1.51. t_on_reply usage
+ ...
+ loadmodule "/usr/local/lib/ser/modules/nathelper.so"
+ ...
+@@ -1784,7 +1800,7 @@ es');
+         }
+ }
+ 
+-5.9. t_on_branch(branch_route)
++5.9.  t_on_branch(branch_route)
+ 
+    Sets the branch routing block, to which control is passed after forking
+    (when a new branch is created). For now branch routes are intended only
+@@ -1795,7 +1811,7 @@ es');
+    Meaning of the parameters is as follows:
+      * branch_route - branch route block to be called.
+ 
+-   Example 1.51. t_on_branch usage
++   Example 1.52. t_on_branch usage
+ ...
+ route {
+         t_on_branch("1");
+@@ -1808,13 +1824,13 @@ branch_route[1] {
+         }
+ }
+ 
+-5.10. t_newtran()
++5.10.  t_newtran()
+ 
+    Creates a new transaction, returns a negative value on error. This is
+    the only way a script can add a new transaction in an atomic way.
+    Typically, it is used to deploy a UAS.
+ 
+-   Example 1.52. t_newtran usage
++   Example 1.53. t_newtran usage
+ ...
+ if (t_newtran()) {
+     log("UAS logic");
+@@ -1824,7 +1840,7 @@ if (t_newtran()) {
+ 
+    See test/uas.cfg for more examples.
+ 
+-5.11. t_reply(code, reason_phrase)
++5.11.  t_reply(code, reason_phrase)
+ 
+    Sends a stateful reply after a transaction has been established. See
+    t_newtran for usage.
+@@ -1844,12 +1860,12 @@ if (t_newtran()) {
+      * code - Reply code number.
+      * reason_phrase - Reason string.
+ 
+-   Example 1.53. t_reply usage
++   Example 1.54. t_reply usage
+ ...
+ t_reply("404", "Not found");
+ ...
+ 
+-5.12. t_lookup_request()
++5.12.  t_lookup_request()
+ 
+    Checks if a transaction exists. Returns a positive value if so,
+    negative otherwise. Most likely you will not want to use it, as a
+@@ -1857,33 +1873,33 @@ t_reply("404", "Not found");
+    none was found. However this is safely (atomically) done using
+    t_newtran.
+ 
+-   Example 1.54. t_lookup_request usage
++   Example 1.55. t_lookup_request usage
+ ...
+ if (t_lookup_request()) {
+     ...
+ };
+ ...
+ 
+-5.13. t_retransmit_reply()
++5.13.  t_retransmit_reply()
+ 
+    Retransmits a reply sent previously by UAS transaction.
+ 
+-   Example 1.55. t_retransmit_reply usage
++   Example 1.56. t_retransmit_reply usage
+ ...
+ t_retransmit_reply();
+ ...
+ 
+-5.14. t_release()
++5.14.  t_release()
+ 
+    Remove transaction from memory (it will be first put on a wait timer to
+    absorb delayed messages).
+ 
+-   Example 1.56. t_release usage
++   Example 1.57. t_release usage
+ ...
+ t_release();
+ ...
+ 
+-5.15. t_forward_nonack([ip, port])
++5.15.  t_forward_nonack([ip, port])
+ 
+    Mainly for internal usage -- forward a non-ACK request statefully.
+    Variants of this functions can enforce a specific transport protocol.
+@@ -1892,28 +1908,28 @@ t_release();
+      * ip - IP address where the message should be sent.
+      * port - Port number.
+ 
+-   Example 1.57. t_forward_nonack usage
++   Example 1.58. t_forward_nonack usage
+ ...
+ t_forward_nonack("1.2.3.4", "5060");
+ ...
+ 
+-5.16. t_forward_nonack_udp(ip, port)
++5.16.  t_forward_nonack_udp(ip, port)
+ 
+    See function t_forward_nonack([ip, port]).
+ 
+-5.17. t_forward_nonack_tcp(ip, port)
++5.17.  t_forward_nonack_tcp(ip, port)
+ 
+    See function t_forward_nonack([ip, port]).
+ 
+-5.18. t_forward_nonack_tls(ip, port)
++5.18.  t_forward_nonack_tls(ip, port)
+ 
+    See function t_forward_nonack([ip, port]).
+ 
+-5.19. t_forward_nonack_sctp(ip, port)
++5.19.  t_forward_nonack_sctp(ip, port)
+ 
+    See function t_forward_nonack([ip, port]).
+ 
+-5.20. t_set_fr(fr_inv_timeout [, fr_timeout])
++5.20.  t_set_fr(fr_inv_timeout [, fr_timeout])
+ 
+    Sets the fr_inv_timeout and optionally fr_timeout for the current
+    transaction or for transactions created during the same script
+@@ -1931,7 +1947,7 @@ t_forward_nonack("1.2.3.4", "5060");
+ 
+    See also: fr_timer, fr_inv_timer, t_reset_fr().
+ 
+-   Example 1.58. t_set_fr usage
++   Example 1.59. t_set_fr usage
+ ...
+ route {
+         t_set_fr(10000); # set only fr invite timeout to 10s
+@@ -1947,7 +1963,7 @@ branch_route[1] {
+         }
+ }
+ 
+-5.21. t_reset_fr()
++5.21.  t_reset_fr()
+ 
+    Resets the fr_inv_timer and fr_timer for the current transaction to the
+    default values (set using the tm module parameters fr_inv_timer and
+@@ -1958,7 +1974,7 @@ branch_route[1] {
+ 
+    See also: fr_timer, fr_inv_timer, t_set_fr.
+ 
+-   Example 1.59. t_reset_fr usage
++   Example 1.60. t_reset_fr usage
+ ...
+ route {
+ ...
+@@ -1966,7 +1982,7 @@ route {
+ ...
+ }
+ 
+-5.22. t_set_max_lifetime(inv_lifetime, noninv_lifetime)
++5.22.  t_set_max_lifetime(inv_lifetime, noninv_lifetime)
+ 
+    Sets the maximum lifetime for the current INVITE or non-INVITE
+    transaction, or for transactions created during the same script
+@@ -1984,7 +2000,7 @@ route {
+ 
+    See also: max_inv_lifetime, max_noninv_lifetime, t_reset_max_lifetime.
+ 
+-   Example 1.60. t_set_max_lifetime usage
++   Example 1.61. t_set_max_lifetime usage
+ ...
+ route {
+     if (src_ip=1.2.3.4)
+@@ -1995,7 +2011,7 @@ route {
+                                           # INVITE and to 15s if not
+ }
+ 
+-5.23. t_reset_max_lifetime()
++5.23.  t_reset_max_lifetime()
+ 
+    Resets the the maximum lifetime for the current INVITE or non-INVITE
+    transaction to the default value (set using the tm module parameter
+@@ -2006,7 +2022,7 @@ route {
+ 
+    See also: max_inv_lifetime, max_noninv_lifetime, t_set_max_lifetime.
+ 
+-   Example 1.61. t_reset_max_lifetime usage
++   Example 1.62. t_reset_max_lifetime usage
+ ...
+ route {
+ ...
+@@ -2014,7 +2030,7 @@ route {
+ ...
+ }
+ 
+-5.24. t_set_retr(retr_t1_interval, retr_t2_interval)
++5.24.  t_set_retr(retr_t1_interval, retr_t2_interval)
+ 
+    Sets the retr_t1_interval and retr_t2_interval for the current
+    transaction or for transactions created during the same script
+@@ -2044,7 +2060,7 @@ route {
+ 
+    See also: retr_timer1, retr_timer2, t_reset_retr().
+ 
+-   Example 1.62. t_set_retr usage
++   Example 1.63. t_set_retr usage
+ ...
+ route {
+         t_set_retr(250, 0); # set only T1 to 250 ms
+@@ -2060,7 +2076,7 @@ branch_route[1] {
+         }
+ }
+ 
+-5.25. t_reset_retr()
++5.25.  t_reset_retr()
+ 
+    Resets the retr_timer1 and retr_timer2 for the current transaction to
+    the default values (set using the tm module parameters retr_timer1 and
+@@ -2071,7 +2087,7 @@ branch_route[1] {
+ 
+    See also: retr_timer1, retr_timer2, t_set_retr.
+ 
+-   Example 1.63. t_reset_retr usage
++   Example 1.64. t_reset_retr usage
+ ...
+ route {
+ ...
+@@ -2079,7 +2095,7 @@ route {
+ ...
+ }
+ 
+-5.26. t_set_auto_inv_100(0|1)
++5.26.  t_set_auto_inv_100(0|1)
+ 
+    Switch automatically sending 100 replies to INVITEs on/off on a per
+    transaction basis. It overrides the auto_inv_100 value for the current
+@@ -2087,7 +2103,7 @@ route {
+ 
+    See also: auto_inv_100.
+ 
+-   Example 1.64. t_set_auto_inv_100 usage
++   Example 1.65. t_set_auto_inv_100 usage
+ ...
+ route {
+ ...
+@@ -2096,13 +2112,13 @@ route {
+ ...
+ }
+ 
+-5.27. t_branch_timeout()
++5.27.  t_branch_timeout()
+ 
+    Returns true if the failure route is executed for a branch that did
+    timeout. It can be used from failure_route and branch-failure event
+    route.
+ 
+-   Example 1.65. t_branch_timeout usage
++   Example 1.66. t_branch_timeout usage
+ ...
+ failure_route[0]{
+         if (t_branch_timeout()){
+@@ -2111,14 +2127,14 @@ failure_route[0]{
+         }
+ }
+ 
+-5.28. t_branch_replied()
++5.28.  t_branch_replied()
+ 
+    Returns true if the failure route is executed for a branch that did
+    receive at least one reply in the past (the "current" reply is not
+    taken into account). It can be used from failure_route and
+    branch-failure event route.
+ 
+-   Example 1.66. t_branch_replied usage
++   Example 1.67. t_branch_replied usage
+ ...
+ failure_route[0]{
+         if (t_branch_timeout()){
+@@ -2130,12 +2146,12 @@ failure_route[0]{
+         }
+ }
+ 
+-5.29. t_any_timeout()
++5.29.  t_any_timeout()
+ 
+    Returns true if at least one of the current transactions branches did
+    timeout.
+ 
+-   Example 1.67. t_any_timeout usage
++   Example 1.68. t_any_timeout usage
+ ...
+ failure_route[0]{
+         if (!t_branch_timeout()){
+@@ -2146,13 +2162,13 @@ failure_route[0]{
+         }
+ }
+ 
+-5.30. t_any_replied()
++5.30.  t_any_replied()
+ 
+    Returns true if at least one of the current transactions branches did
+    receive some reply in the past. If called from a failure or onreply
+    route, the "current" reply is not taken into account.
+ 
+-   Example 1.68. t_any_replied usage
++   Example 1.69. t_any_replied usage
+ ...
+ onreply_route[0]{
+         if (!t_any_replied()){
+@@ -2161,12 +2177,12 @@ onreply_route[0]{
+         }
+ }
+ 
+-5.31. t_grep_status("code")
++5.31.  t_grep_status("code")
+ 
+    Returns true if "code" is the final reply received (or locally
+    generated) in at least one of the current transactions branches.
+ 
+-   Example 1.69. t_grep_status usage
++   Example 1.70. t_grep_status usage
+ ...
+ onreply_route[0]{
+         if (t_grep_status("486")){
+@@ -2175,11 +2191,11 @@ onreply_route[0]{
+         }
+ }
+ 
+-5.32. t_is_canceled()
++5.32.  t_is_canceled()
+ 
+    Returns true if the current transaction was canceled.
+ 
+-   Example 1.70. t_is_canceled usage
++   Example 1.71. t_is_canceled usage
+ ...
+ failure_route[0]{
+         if (t_is_canceled()){
+@@ -2188,12 +2204,12 @@ failure_route[0]{
+         }
+ }
+ 
+-5.33. t_is_expired()
++5.33.  t_is_expired()
+ 
+    Returns true if the current transaction has already been expired, i.e.
+    the max_inv_lifetime/max_noninv_lifetime interval has already elapsed.
+ 
+-   Example 1.71. t_is_expired usage
++   Example 1.72. t_is_expired usage
+ ...
+ failure_route[0]{
+         if (t_is_expired()){
+@@ -2202,7 +2218,7 @@ failure_route[0]{
+         }
+ }
+ 
+-5.34. t_relay_cancel()
++5.34.  t_relay_cancel()
+ 
+    Forwards the CANCEL if the corresponding INVITE transaction exists. The
+    function is supposed to be used at the very beginning of the script,
+@@ -2214,7 +2230,7 @@ failure_route[0]{
+    CANCELs were successfully sent to the pending branches, true if the
+    INVITE was not found, and false in case of any error.
+ 
+-   Example 1.72. t_relay_cancel usage
++   Example 1.73. t_relay_cancel usage
+ if (method == CANCEL) {
+         if (!t_relay_cancel()) {  # implicit drop if relaying was successful,
+                                   # nothing to do
+@@ -2227,7 +2243,7 @@ if (method == CANCEL) {
+         # do the same as for INVITEs
+ }
+ 
+-5.35. t_lookup_cancel([1])
++5.35.  t_lookup_cancel([1])
+ 
+    Returns true if the corresponding INVITE transaction exists for a
+    CANCEL request. The function can be called at the beginning of the
+@@ -2241,7 +2257,7 @@ if (method == CANCEL) {
+    overwritten with the flags of the INVITE. isflagset() can be used to
+    check the flags of the previously forwarded INVITE in this case.
+ 
+-   Example 1.73. t_lookup_cancel usage
++   Example 1.74. t_lookup_cancel usage
+ if (method == CANCEL) {
+         if (t_lookup_cancel()) {
+                 log("INVITE transaction exists");
+@@ -2259,7 +2275,7 @@ if (method == CANCEL) {
+         # do the same as for INVITEs
+ }
+ 
+-5.36. t_drop_replies([mode])
++5.36.  t_drop_replies([mode])
+ 
+    Drops all the previously received replies in failure_route block to
+    make sure that none of them is picked up again.
+@@ -2271,7 +2287,7 @@ if (method == CANCEL) {
+    Dropping replies works only if a new branch is added to the
+    transaction, or it is explicitly replied in the script!
+ 
+-   Example 1.74. t_drop_replies() usage
++   Example 1.75. t_drop_replies() usage
+ ...
+ failure_route[0]{
+         if (t_check_status("5[0-9][0-9]")){
+@@ -2287,7 +2303,7 @@ failure_route[0]{
+         }
+ }
+ 
+-5.37. t_save_lumps()
++5.37.  t_save_lumps()
+ 
+    Forces the modifications of the processed SIP message to be saved in
+    shared memory before t_relay() is called. The new branches which are
+@@ -2302,7 +2318,7 @@ failure_route[0]{
+    The transaction must be created by t_newtran() before calling
+    t_save_lumps().
+ 
+-   Example 1.75. t_save_lumps() usage
++   Example 1.76. t_save_lumps() usage
+ route {
+         ...
+         t_newtran();
+@@ -2327,7 +2343,7 @@ failure_route[1] {
+         t_relay();
+ }
+ 
+-5.38. t_load_contacts()
++5.38.  t_load_contacts()
+ 
+    This is the first of the three functions that can be used to implement
+    serial/parallel forking based on q and +sip.instance values of
+@@ -2361,7 +2377,7 @@ failure_route[1] {
+ 
+    This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.
+ 
+-   Example 1.76. t_load_contacts usage
++   Example 1.77. t_load_contacts usage
+ ...
+ if (!t_load_contacts()) {
+         sl_send_reply("500", "Server Internal Error - Cannot load contacts");
+@@ -2369,7 +2385,7 @@ if (!t_load_contacts()) {
+ };
+ ...
+ 
+-5.39. t_next_contacts()
++5.39.  t_next_contacts()
+ 
+    Function t_next_contacts() is the second of the three functions that
+    can be used to implement serial/parallel forking based on the q value
+@@ -2402,7 +2418,7 @@ if (!t_load_contacts()) {
+    contact_flows_avp are not anymore set. Based on that test, you can then
+    use t_set_fr() function to set timers according to your needs.
+ 
+-   Example 1.77. t_next_contacts usage
++   Example 1.78. t_next_contacts usage
+ ...
+ # First call after t_load_contacts() when transaction does not exist yet
+ # and contacts should be available
+@@ -2421,7 +2437,7 @@ if (!t_next_contacts()) {
+ };
+ ...
+ 
+-5.40. t_next_contact_flow()
++5.40.  t_next_contact_flow()
+ 
+    Function t_next_contact_flow() is the last of the three functions that
+    can be used to implement serial/parallel forking based on the q value
+@@ -2439,7 +2455,7 @@ if (!t_next_contacts()) {
+    thus there was nothing to do, and returns -1 in case of an error (see
+    syslog). This function can be used from a BRANCH_FAILURE event route.
+ 
+-   Example 1.78. t_next_contact_flow usage
++   Example 1.79. t_next_contact_flow usage
+ ...
+ event_route[tm:branch-failure:outbound]
+ {
+@@ -2451,7 +2467,7 @@ event_route[tm:branch-failure:outbound]
+         }
+ ...
+ 
+-5.41. t_check_status(re)
++5.41.  t_check_status(re)
+ 
+    Returns true if the regular expresion "re" match the reply code of the
+    response message as follows:
+@@ -2462,14 +2478,14 @@ event_route[tm:branch-failure:outbound]
+ 
+    This function can be used from ANY_ROUTE .
+ 
+-   Example 1.79. t_check_status usage
++   Example 1.80. t_check_status usage
+ ...
+ if (t_check_status("(487)|(408)")) {
+     log("487 or 408 negative reply\n");
+ }
+ ...
+ 
+-5.42. t_check_trans()
++5.42.  t_check_trans()
+ 
+    t_check_trans() can be used to quickly check if a message belongs or is
+    related to a transaction. It behaves differently for different types of
+@@ -2516,12 +2532,12 @@ Note
+ 
+    See also: t_lookup_request(), t_lookup_cancel().
+ 
+-   Example 1.80. t_check_trans usage
++   Example 1.81. t_check_trans usage
+ if ( method == "CANCEL" && !t_check_trans())
+         sl_reply("403", "cancel out of the blue forbidden");
+ # note: in this example t_check_trans() can be replaced by t_lookup_cancel()
+ 
+-5.43. t_set_disable_6xx(0|1)
++5.43.  t_set_disable_6xx(0|1)
+ 
+    Turn off/on 6xx replies special rfc conformant handling on a per
+    transaction basis. If turned off (t_set_disable_6xx("1")) 6XXs will be
+@@ -2531,7 +2547,7 @@ if ( method == "CANCEL" && !t_check_trans())
+ 
+    See also: disable_6xx_block.
+ 
+-   Example 1.81. t_set_disable_6xx usage
++   Example 1.82. t_set_disable_6xx usage
+ ...
+ route {
+ ...
+@@ -2540,13 +2556,13 @@ route {
+ ...
+ }
+ 
+-5.44. t_set_disable_failover(0|1)
++5.44.  t_set_disable_failover(0|1)
+ 
+    Turn off/on dns failover on a per transaction basis.
+ 
+    See also: use_dns_failover.
+ 
+-   Example 1.82. t_set_disable_failover usage
++   Example 1.83. t_set_disable_failover usage
+ ...
+ route {
+ ...
+@@ -2555,11 +2571,11 @@ route {
+ ...
+ }
+ 
+-5.45. t_set_disable_internal_reply(0|1)
++5.45.  t_set_disable_internal_reply(0|1)
+ 
+    Turn off/on sending internally a SIP reply in case of relay errors.
+ 
+-   Example 1.83. t_set_disable_internal_reply usage
++   Example 1.84. t_set_disable_internal_reply usage
+ ...
+ t_set_disable_internal_reply(1); # turn off sending internal reply on error
+ if(!t_relay()) {
+@@ -2567,7 +2583,7 @@ if(!t_relay()) {
+ }
+ ...
+ 
+-5.46. t_replicate([params])
++5.46.  t_replicate([params])
+ 
+    Replicate the SIP request to a specific address.
+ 
+@@ -2590,7 +2606,7 @@ if(!t_relay()) {
+      * hostport - address in "host:port" format. It can be given via an
+        AVP.
+ 
+-   Example 1.84. t_replicate usage
++   Example 1.85. t_replicate usage
+ ...
+ # sent to 1.2.3.4:5060 over tcp
+ t_replicate("sip:1.2.3.4:5060;transport=tcp");
+@@ -2603,7 +2619,7 @@ t_replicate("sip:$var(h);transport=tls");
+ t_replicate_to_udp("1.2.3.4", "5060");
+ ...
+ 
+-5.47. t_relay_to(proxy, flags)
++5.47.  t_relay_to(proxy, flags)
+ 
+    Forward the SIP request to a specific address, controlling internal
+    behavior via flags.
+@@ -2624,7 +2640,7 @@ t_replicate_to_udp("1.2.3.4", "5060");
+           + 0x02 - do not generate reply on internal error.
+           + 0x04 - disable dns failover.
+ 
+-   Example 1.85. t_relay_to usage
++   Example 1.86. t_relay_to usage
+ ...
+ # sent to 1.2.3.4:5060 over tcp
+ t_relay_to("tcp:1.2.3.4:5060");
+@@ -2636,7 +2652,7 @@ t_relay_to("tls:1.2.3.4");
+ t_relay_to("0x01");
+ ...
+ 
+-5.48. t_set_no_e2e_cancel_reason(0|1)
++5.48.  t_set_no_e2e_cancel_reason(0|1)
+ 
+    Enables/disables reason header (RFC 3326) copying from the triggering
+    received CANCEL to the generated hop-by-hop CANCEL. 0 enables and 1
+@@ -2647,7 +2663,7 @@ t_relay_to("0x01");
+ 
+    See also: e2e_cancel_reason.
+ 
+-   Example 1.86. t_set_no_e2e_cancel_reason usage
++   Example 1.87. t_set_no_e2e_cancel_reason usage
+ ...
+ route {
+ ...
+@@ -2657,7 +2673,7 @@ opying
+ ...
+ }
+ 
+-5.49. t_is_set(target)
++5.49.  t_is_set(target)
+ 
+    Return true if the attribute specified by 'target' is set for
+    transaction.
+@@ -2670,13 +2686,13 @@ opying
+      * onreply_route - the function returns true if an onreply route is
+        set to be executed.
+ 
+-   Example 1.87. t_replicate usage
++   Example 1.88. t_replicate usage
+ ...
+ if(!t_is_set("failure_route"))
+     LM_DBG("no failure route will be executed for current transaction\n");
+ ...
+ 
+-5.50. t_use_uac_headers()
++5.50.  t_use_uac_headers()
+ 
+    Set internal flags to tell tm to use UAC side for building headers for
+    local generated requests (ACK, CANCEL) - useful when changing From/To
+@@ -2684,12 +2700,12 @@ if(!t_is_set("failure_route"))
+ 
+    It returns true.
+ 
+-   Example 1.88. t_use_uac_headers usage
++   Example 1.89. t_use_uac_headers usage
+ ...
+ t_use_uac_headers();
+ ...
+ 
+-5.51. t_is_retr_async_reply()
++5.51.  t_is_retr_async_reply()
+ 
+    Check to see if the reply is a retransmitted reply on a transaction
+    that is currently suspended asynchronously (suspended during reply
+@@ -2703,7 +2719,7 @@ t_use_uac_headers();
+    returns true if the transaction is currently reply suspended or false
+    if not.
+ 
+-   Example 1.89. t_is_retr_async_reply usage
++   Example 1.90. t_is_retr_async_reply usage
+ ...
+ if (t_is_retr_async_reply()) {
+         xlog("L_DBG", "Dropping retransmitted reply which is still currently sus
+@@ -2792,7 +2808,7 @@ end of body
+ 
+ 6.2. Functions
+ 
+-6.2.1. register_tmcb(cb_type, cb_func)
++6.2.1.  register_tmcb(cb_type, cb_func)
+ 
+    For programmatic use only--register a function to be called back on an
+    event. See t_hooks.h for more details.
+@@ -2801,7 +2817,7 @@ end of body
+      * cb_type - Callback type.
+      * cb_func - Callback function.
+ 
+-6.2.2. load_tm(*import_structure)
++6.2.2.  load_tm(*import_structure)
+ 
+    For programmatic use only--import exported TM functions. See the acc
+    module for an example of use.
+@@ -2809,7 +2825,7 @@ end of body
+    Meaning of the parameters is as follows:
+      * import_structure - Pointer to the import structure.
+ 
+-6.2.3. int t_suspend(struct sip_msg *msg, unsigned int *hash_index, unsigned
++6.2.3.  int t_suspend(struct sip_msg *msg, unsigned int *hash_index, unsigned
+ int *label)
+ 
+    For programmatic use only. This function together with t_continue() can
+@@ -2847,7 +2863,7 @@ int *label)
+    t_suspend() should return 0 to make sure that the script processing
+    does not continue.
+ 
+-6.2.4. int t_continue(unsigned int hash_index, unsigned int label, struct
++6.2.4.  int t_continue(unsigned int hash_index, unsigned int label, struct
+ action *route)
+ 
+    For programmatic use only. This function is the pair of t_suspend(),
+@@ -2863,7 +2879,7 @@ action *route)
+ 
+    Return value: 0 - success, <0 - error.
+ 
+-6.2.5. int t_cancel_suspend(unsigned int hash_index, unsigned int label)
++6.2.5.  int t_cancel_suspend(unsigned int hash_index, unsigned int label)
+ 
+    For programmatic use only. This function is for revoking t_suspend()
+    from the same process as it was executed before. t_cancel_suspend() can
+@@ -2883,7 +2899,7 @@ action *route)
+ 
+    7.1. event_route[tm:branch-failure]
+ 
+-7.1. event_route[tm:branch-failure]
++7.1.  event_route[tm:branch-failure]
+ 
+    Named branch failure routes can be defined to run when when a failure
+    response is received. This allows handling failures on individual
+@@ -2893,7 +2909,7 @@ action *route)
+    enabled with the t_on_branch_failure function. This event_route uses
+    the BRANCH_FAILURE_ROUTE route type.
+ 
+-   Example 1.90. event_route[tm:branch-failure] usage
++   Example 1.91. event_route[tm:branch-failure] usage
+ ...
+ route {
+     t_on_branch_failure("myroute");
+diff --git a/modules/tm/doc/params.xml b/modules/tm/doc/params.xml
+index c0cdf16..2e0099b 100644
+--- a/modules/tm/doc/params.xml
++++ b/modules/tm/doc/params.xml
+@@ -1407,4 +1407,25 @@ modparam("tm", "dns_reuse_rcv_socket", 1)
+ 		</example>
+ 	</section>
+ 
++	<section id="tm.p.xavp_contact">
++		<title><varname>xavp_contact</varname> (string)</title>
++		<para>
++		The name of XAVP storing the attributes per contact. This must be the same as
++		the usrloc parameter <varname>xavp_contacts</varname>.
++		</para>
++		<para>
++		<emphasis>
++			Default value is <quote>NULL</quote>.
++		</emphasis>
++		</para>
++		<example>
++		<title>Set <varname>xavp_contact</varname> parameter</title>
++		<programlisting format="linespecific">
++...
++modparam("tm|usrloc", "xavp_contact", "ulattrs")
++...
++</programlisting>
++		</example>
++	</section>
++
+ </section>
+diff --git a/modules/tm/t_serial.c b/modules/tm/t_serial.c
+index b320759..ab83540 100644
+--- a/modules/tm/t_serial.c
++++ b/modules/tm/t_serial.c
+@@ -32,6 +32,7 @@
+ #include "../../dset.h"
+ #include "../../parser/msg_parser.h"
+ #include "../../ut.h"
++#include "../../xavp.h"
+ #include "config.h"
+ #include "t_funcs.h"
+ #include "t_reply.h"
+@@ -40,6 +41,8 @@
+ /* usr_avp flag for sequential forking */
+ #define Q_FLAG      (1<<2)
+ 
++extern str ulattrs_xavp_name;
++
+ /* Struture where information regarding contacts is stored */
+ struct contact {
+ 	str uri;
+@@ -53,6 +56,7 @@ struct contact {
+ 	unsigned int flags;
+ 	unsigned short q_flag;
+ 	struct contact *next;
++	sr_xavp_t *ulattrs;
+ };
+ 
+ struct instance_list {
+@@ -97,7 +101,7 @@ static str ua_name = {"ua", 2};
+ 
+ void add_contacts_avp(str *uri, str *dst_uri, str *path, str *sock_str,
+ 		unsigned int flags, unsigned int q_flag, str *instance,
+-		str *ruid, str *location_ua)
++		str *ruid, str *location_ua, sr_xavp_t *ulattrs_xavp)
+ {
+ 	sr_xavp_t *record;
+ 	sr_xval_t val;
+@@ -151,6 +155,8 @@ void add_contacts_avp(str *uri, str *dst_uri, str *path, str *sock_str,
+ 		xavp_add_value(&ua_name, &val, &record);
+ 	}
+ 
++	xavp_add(xavp_clone_level_nodata(ulattrs_xavp), &record);
++
+ 	val.type = SR_XTYPE_XAVP;
+ 	val.v.xavp = record;
+ 	if(xavp_add_value(&contacts_avp, &val, NULL)==NULL) {
+@@ -215,6 +221,10 @@ int t_load_contacts(struct sip_msg* msg, char* key, char* value)
+ 		contacts->instance = msg->instance;
+ 		contacts->ruid = msg->ruid;
+ 		contacts->location_ua = msg->location_ua;
++		if (ulattrs_xavp_name.s != NULL)
++		{
++			contacts->ulattrs = xavp_get_by_index(&ulattrs_xavp_name, 0, NULL);
++		}
+ 		first_idx = 0;
+ 	} else {
+ 		/* Insert first branch to first contact */
+@@ -234,6 +244,10 @@ int t_load_contacts(struct sip_msg* msg, char* key, char* value)
+ 		contacts->ruid.len = branch->ruid_len;
+ 		contacts->location_ua.s = branch->location_ua;
+ 		contacts->location_ua.len = branch->location_ua_len;
++		if (ulattrs_xavp_name.s != NULL)
++		{
++			contacts->ulattrs = xavp_get_by_index(&ulattrs_xavp_name, 1, NULL);
++		}
+ 		first_idx = 1;
+ 	}
+ 
+@@ -264,6 +278,10 @@ int t_load_contacts(struct sip_msg* msg, char* key, char* value)
+ 		next->ruid.len = branch->ruid_len;
+ 		next->location_ua.s = branch->location_ua;
+ 		next->location_ua.len = branch->location_ua_len;
++		if (ulattrs_xavp_name.s != NULL)
++		{
++			next->ulattrs = xavp_get_by_index(&ulattrs_xavp_name, idx + 1, NULL);
++		}
+ 		next->next = (struct contact *)0;
+ 
+ 		prev = (struct contact *)0;
+@@ -320,13 +338,17 @@ int t_load_contacts(struct sip_msg* msg, char* key, char* value)
+ 
+ 		add_contacts_avp(&(curr->uri), &(curr->dst_uri), &(curr->path),
+ 				&sock_str, curr->flags, curr->q_flag,
+-				&(curr->instance), &(curr->ruid), &(curr->location_ua));
++				&(curr->instance), &(curr->ruid), &(curr->location_ua),
++				curr->ulattrs);
+ 
+ 		curr = curr->next;
+ 	}
+ 
+ 	/* Clear all branches */
+ 	clear_branches();
++	if (ulattrs_xavp_name.s != NULL){
++		xavp_rm_by_name(&ulattrs_xavp_name, 1, NULL);
++	}
+ 
+ 	/* Free contact list */
+ 	free_contact_list(contacts);
+@@ -336,7 +358,7 @@ int t_load_contacts(struct sip_msg* msg, char* key, char* value)
+ 
+ void add_contact_flows_avp(str *uri, str *dst_uri, str *path, str *sock_str,
+ 		unsigned int flags, str *instance, str *ruid,
+-		str *location_ua)
++		str *location_ua, sr_xavp_t *ulattrs_xavp)
+ {
+ 	sr_xavp_t *record;
+ 	sr_xval_t val;
+@@ -382,6 +404,8 @@ void add_contact_flows_avp(str *uri, str *dst_uri, str *path, str *sock_str,
+ 		xavp_add_value(&ua_name, &val, &record);
+ 	}
+ 
++	xavp_add(ulattrs_xavp, &record);
++
+ 	val.type = SR_XTYPE_INT;
+ 	val.v.i = flags;
+ 	xavp_add_value(&flags_name, &val, &record);
+@@ -516,6 +540,12 @@ int t_next_contacts(struct sip_msg* msg, char* key, char* value)
+ 		location_ua.len = 0;
+ 	}
+ 
++	if (ulattrs_xavp_name.s != NULL)
++	{
++		vavp = xavp_extract(&ulattrs_xavp_name, &xavp->val.v.xavp);
++		xavp_insert(vavp, 0, NULL);
++	}
++
+ 	/* Rewrite Request-URI */
+ 	rewrite_uri(msg, &uri);
+ 
+@@ -627,8 +657,9 @@ int t_next_contacts(struct sip_msg* msg, char* key, char* value)
+ 				ilp = ilp->next;
+ 			}
+ 			if (ilp) {
++				vavp = (ulattrs_xavp_name.s != NULL)?xavp_extract(&ulattrs_xavp_name, &xavp->val.v.xavp):NULL;
+ 				add_contact_flows_avp(&uri, &dst_uri, &path, &sock_str,
+-						flags, &instance, &ruid, &location_ua);
++						flags, &instance, &ruid, &location_ua, vavp);
+ 				goto check_q_flag;
+ 			}
+ 			if (!q_flag) {
+@@ -672,6 +703,12 @@ int t_next_contacts(struct sip_msg* msg, char* key, char* value)
+ 			return -1;
+ 		}
+ 
++		if (ulattrs_xavp_name.s != NULL)
++		{
++			vavp = xavp_extract(&ulattrs_xavp_name, &xavp->val.v.xavp);
++			xavp_insert(vavp, nr_branches, NULL);
++		}
++
+ check_q_flag:
+ 		if (q_flag) {
+ 			free_instance_list(il);
+@@ -808,6 +845,12 @@ int t_next_contact_flow(struct sip_msg* msg, char* key, char* value)
+ 			return -1;
+ 		}
+ 
++		if (ulattrs_xavp_name.s != NULL)
++		{
++			vavp = xavp_extract(&ulattrs_xavp_name, &xavp->val.v.xavp);
++			xavp_insert(vavp, nr_branches, NULL);
++		}
++
+ 		xavp_rm(xavp, NULL);
+ 		return 1;
+ next_xavp:
+diff --git a/modules/tm/tm.c b/modules/tm/tm.c
+index b82775e..0293a1c 100644
+--- a/modules/tm/tm.c
++++ b/modules/tm/tm.c
+@@ -268,6 +268,7 @@ static char *fr_inv_timer_param = 0 /*FR_INV_TIMER_AVP*/;
+ 
+ str contacts_avp = {0, 0};
+ str contact_flows_avp = {0, 0};
++str ulattrs_xavp_name = {NULL, 0};
+ 
+ int tm_remap_503_500 = 1;
+ 
+@@ -512,6 +513,7 @@ static param_export_t params[]={
+ 	{"local_cancel_reason", PARAM_INT, &default_tm_cfg.local_cancel_reason   },
+ 	{"e2e_cancel_reason",   PARAM_INT, &default_tm_cfg.e2e_cancel_reason     },
+ #endif /* CANCEL_REASON_SUPPORT */
++	{"xavp_contact",        PARAM_STR, &ulattrs_xavp_name                    },
+ 	{0,0,0}
+ };
+ 
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0003-tm-Ensure-all-contact-attributes-are-initialised-to-.patch b/debian/patches/upstream/0003-tm-Ensure-all-contact-attributes-are-initialised-to-.patch
new file mode 100644
index 0000000..65a5cac
--- /dev/null
+++ b/debian/patches/upstream/0003-tm-Ensure-all-contact-attributes-are-initialised-to-.patch
@@ -0,0 +1,26 @@
+From b83c7fef0e4d5c3cab1e2d0ad46bab7e9a852118 Mon Sep 17 00:00:00 2001
+From: Hugh Waite <hugh.waite at acision.com>
+Date: Fri, 29 May 2015 14:40:53 +0100
+Subject: [PATCH] tm: Ensure all contact attributes are initialised to NULL
+ when serial forking (cherry picked from commit
+ 192cf785eead68980194e63b06e34bf8f5f861f3)
+
+---
+ modules/tm/t_serial.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/modules/tm/t_serial.c b/modules/tm/t_serial.c
+index ab83540..b278924 100644
+--- a/modules/tm/t_serial.c
++++ b/modules/tm/t_serial.c
+@@ -263,6 +263,7 @@ int t_load_contacts(struct sip_msg* msg, char* key, char* value)
+ 			return -1;
+ 		}
+ 
++		memset(next, 0, sizeof(struct contact));
+ 		next->uri.s = branch->uri;
+ 		next->uri.len = branch->len;
+ 		next->dst_uri.s = branch->dst_uri;
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0004-dispatcher-Fix-typo-in-error-message.patch b/debian/patches/upstream/0004-dispatcher-Fix-typo-in-error-message.patch
new file mode 100644
index 0000000..fe2ab6c
--- /dev/null
+++ b/debian/patches/upstream/0004-dispatcher-Fix-typo-in-error-message.patch
@@ -0,0 +1,26 @@
+From 2b34e4def552444fd72b9dc4f4ae286b19a839b7 Mon Sep 17 00:00:00 2001
+From: Hugh Waite <hugh.waite at acision.com>
+Date: Thu, 11 Jun 2015 10:17:32 +0100
+Subject: [PATCH] dispatcher: Fix typo in error message (cherry picked from
+ commit 55a7bf18d0663a9503320143958d0d9e2e845b26)
+
+---
+ modules/dispatcher/dispatcher.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/modules/dispatcher/dispatcher.c b/modules/dispatcher/dispatcher.c
+index 2e2c12f..c75b97d 100644
+--- a/modules/dispatcher/dispatcher.c
++++ b/modules/dispatcher/dispatcher.c
+@@ -764,7 +764,7 @@ static int ds_warn_fixup(void** param, int param_no)
+ {
+ 	if(!dst_avp_param.s || !grp_avp_param.s || !cnt_avp_param.s || !sock_avp_param.s)
+ 	{
+-		LM_ERR("failover functions used, but AVPs paraamters required"
++		LM_ERR("failover functions used, but required AVP parameters"
+ 				" are NULL -- feature disabled\n");
+ 	}
+ 	return 0;
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0005-modules-lcr-added-priority_ordering-module-parameter.patch b/debian/patches/upstream/0005-modules-lcr-added-priority_ordering-module-parameter.patch
new file mode 100644
index 0000000..d899e3b
--- /dev/null
+++ b/debian/patches/upstream/0005-modules-lcr-added-priority_ordering-module-parameter.patch
@@ -0,0 +1,755 @@
+From 27d0e6d99ee512788f16ce4f6b6e4127dea420bd Mon Sep 17 00:00:00 2001
+From: Juha Heinanen <jh at tutpro.com>
+Date: Tue, 16 Jun 2015 11:37:45 +0300
+Subject: [PATCH] modules/lcr: added priority_ordering module parameter
+
+- allows ordering of matched gateways only by priority and weight
+---
+ modules/lcr/README            | 219 +++++++++++++++++++++++-------------------
+ modules/lcr/doc/lcr_admin.xml |  48 ++++++++-
+ modules/lcr/lcr_mod.c         |  23 ++++-
+ 3 files changed, 183 insertions(+), 107 deletions(-)
+
+diff --git a/modules/lcr/README b/modules/lcr/README
+index 58268cf..e7d92eb 100644
+--- a/modules/lcr/README
++++ b/modules/lcr/README
+@@ -10,7 +10,7 @@ Juha Heinanen
+ 
+    <jh at tutpro.com>
+ 
+-   Copyright (c) 2005-2014 Juha Heinanen
++   Copyright © 2005-2014 Juha Heinanen
+      __________________________________________________________________
+ 
+    Table of Contents
+@@ -62,12 +62,13 @@ Juha Heinanen
+               3.35. lcr_rule_hash_size (integer)
+               3.36. lcr_gw_count (integer)
+               3.37. dont_strip_or_tag_flag (integer)
+-              3.38. fetch_rows (integer)
+-              3.39. ping_interval (integer)
+-              3.40. ping_inactivate_threshold (integer)
+-              3.41. ping_valid_reply_codes (string)
+-              3.42. ping_from (string)
+-              3.43. ping_socket (string)
++              3.38. priority_ordering (integer)
++              3.39. fetch_rows (integer)
++              3.40. ping_interval (integer)
++              3.41. ping_inactivate_threshold (integer)
++              3.42. ping_valid_reply_codes (string)
++              3.43. ping_from (string)
++              3.44. ping_socket (string)
+ 
+         4. Functions
+ 
+@@ -128,25 +129,26 @@ Juha Heinanen
+    1.35. Setting lcr_rule_hash_size module parameter
+    1.36. Setting lcr_gw_count module parameter
+    1.37. Setting dont_strip_or_tag_flag module parameter
+-   1.38. Set fetch_rows parameter
+-   1.39. Set ping_interval parameter
+-   1.40. Set ping_inactive_threshold parameter
+-   1.41. Set ping_valid_reply_codes parameter
+-   1.42. Set ping_from parameter
+-   1.43. Set ping_socket parameter
+-   1.44. load_gws usage
+-   1.45. next_gw usage from a route block
+-   1.46. next_gw usage from a failure route block
+-   1.47. inactivate_gw usage
+-   1.48. defunct_gw usage
+-   1.49. from_gw usage
++   1.38. Setting priority_ordering module parameter
++   1.39. Set fetch_rows parameter
++   1.40. Set ping_interval parameter
++   1.41. Set ping_inactivate_threshold parameter
++   1.42. Set ping_valid_reply_codes parameter
++   1.43. Set ping_from parameter
++   1.44. Set ping_socket parameter
++   1.45. load_gws usage
++   1.46. next_gw usage from a route block
++   1.47. next_gw usage from a failure route block
++   1.48. inactivate_gw usage
++   1.49. defunct_gw usage
+    1.50. from_gw usage
+-   1.51. to_gw usage
++   1.51. from_gw usage
+    1.52. to_gw usage
+-   1.53. lcr.reload RPC example
+-   1.54. lcr.dump_gws RPC example
+-   1.55. lcr.dump_rules RPC example
+-   1.56. lcr.defunct_gw RPC example
++   1.53. to_gw usage
++   1.54. lcr.reload RPC example
++   1.55. lcr.dump_gws RPC example
++   1.56. lcr.dump_rules RPC example
++   1.57. lcr.defunct_gw RPC example
+ 
+ Chapter 1. Admin Guide
+ 
+@@ -197,12 +199,13 @@ Chapter 1. Admin Guide
+         3.35. lcr_rule_hash_size (integer)
+         3.36. lcr_gw_count (integer)
+         3.37. dont_strip_or_tag_flag (integer)
+-        3.38. fetch_rows (integer)
+-        3.39. ping_interval (integer)
+-        3.40. ping_inactivate_threshold (integer)
+-        3.41. ping_valid_reply_codes (string)
+-        3.42. ping_from (string)
+-        3.43. ping_socket (string)
++        3.38. priority_ordering (integer)
++        3.39. fetch_rows (integer)
++        3.40. ping_interval (integer)
++        3.41. ping_inactivate_threshold (integer)
++        3.42. ping_valid_reply_codes (string)
++        3.43. ping_from (string)
++        3.44. ping_socket (string)
+ 
+    4. Functions
+ 
+@@ -248,9 +251,14 @@ Chapter 1. Admin Guide
+    currently designated as defunct) are ordered for forwarding purposes as
+    follows:
+ 
+-     * (1) according to longest Request-URI user part match
+-     * (2) according to tuple's priority
+-     * (3) according to tuple's randomized weight
++    1. according to longest Request-URI user part match
++    2. according to tuple's priority
++    3. according to tuple's randomized weight
++
++   or, if priority_ordering parameter is set to value 1, as follows:
++
++    1. according to tuple's priority
++    2. according to tuple's randomized weight
+ 
+    A tuple can be marked as a "stopper" tuple. If a "stopper" tuple
+    matches, then matching stops at it and all other tuples with shorter
+@@ -349,18 +357,19 @@ Chapter 1. Admin Guide
+    3.35. lcr_rule_hash_size (integer)
+    3.36. lcr_gw_count (integer)
+    3.37. dont_strip_or_tag_flag (integer)
+-   3.38. fetch_rows (integer)
+-   3.39. ping_interval (integer)
+-   3.40. ping_inactivate_threshold (integer)
+-   3.41. ping_valid_reply_codes (string)
+-   3.42. ping_from (string)
+-   3.43. ping_socket (string)
++   3.38. priority_ordering (integer)
++   3.39. fetch_rows (integer)
++   3.40. ping_interval (integer)
++   3.41. ping_inactivate_threshold (integer)
++   3.42. ping_valid_reply_codes (string)
++   3.43. ping_from (string)
++   3.44. ping_socket (string)
+ 
+ 3.1. db_url (string)
+ 
+    URL of the database table to be used.
+ 
+-   Default value is "mysql://kamailioro:kamailioro@localhost/kamailio".
++   Default value is “mysql://kamailioro:kamailioro@localhost/kamailio”.
+ 
+    Example 1.1. Setting db_url module parameter
+ ...
+@@ -371,7 +380,7 @@ modparam("lcr","db_url","dbdriver://username:password@dbhost/dbname")
+ 
+    Name of the table holding gateways definitions.
+ 
+-   Default value is "lcr_gw".
++   Default value is “lcr_gw”.
+ 
+    Example 1.2. Setting gw_table module parameter
+ ...
+@@ -383,7 +392,7 @@ modparam("lcr", "lcr_gw_table","gw")
+    Name of the auto-increment, primary key column. Common to all lcr
+    module tables.
+ 
+-   Default value is "id".
++   Default value is “id”.
+ 
+    Example 1.3. Setting id_column module parameter
+ ...
+@@ -397,7 +406,7 @@ modparam("lcr", "id_column", "row_id")
+    the column is integer from 1 to lcr_count. In lcr_gw table, value of
+    the column is from 0 to lcr_count.
+ 
+-   Default value is "lcr_id".
++   Default value is “lcr_id”.
+ 
+    Example 1.4. Setting lcr_id_column module parameter
+ ...
+@@ -408,7 +417,7 @@ modparam("lcr", "lcr_id_column", "lcr_identifier")
+ 
+    Name of the column holding gateway's name for documentation purpose.
+ 
+-   Default value is "gw_name".
++   Default value is “gw_name”.
+ 
+    Example 1.5. Setting gw_name_column module parameter
+ ...
+@@ -419,7 +428,7 @@ modparam("lcr", "gw_name_column", "name")
+ 
+    Name of the column holding the IPv4 or IPv6 address of the gateway.
+ 
+-   Default value is "ip_addr".
++   Default value is “ip_addr”.
+ 
+    Example 1.6. Setting ip_addr_column module parameter
+ ...
+@@ -431,7 +440,7 @@ modparam("lcr", "ip_addr_column", "ip")
+    Name of the column holding gateway's hostname that is used in
+    Request-URI hostpart, when request is sent to the gateway.
+ 
+-   Default value is "hostname".
++   Default value is “hostname”.
+ 
+    Example 1.7. Setting hostname_column module parameter
+ ...
+@@ -442,7 +451,7 @@ modparam("lcr", "hostname_column", "host")
+ 
+    Name of the column holding the port number of the gateway.
+ 
+-   Default value is "port".
++   Default value is “port”.
+ 
+    Example 1.8. Setting port_column module parameter
+ ...
+@@ -454,7 +463,7 @@ modparam("lcr", "port_column", "port")
+    Name of the column holding gateway's parameters that is used in
+    Request-URI, when request is sent to the gateway.
+ 
+-   Default value is "params".
++   Default value is “params”.
+ 
+    Example 1.9. Setting params_column module parameter
+ ...
+@@ -465,7 +474,7 @@ modparam("lcr", "params_column", "parameters")
+ 
+    Name of the column holding the uri scheme of the gateway.
+ 
+-   Default value is "uri_scheme".
++   Default value is “uri_scheme”.
+ 
+    Example 1.10. Setting uri_scheme_column module parameter
+ ...
+@@ -477,7 +486,7 @@ modparam("lcr", "uri_scheme_column", "uri_scheme")
+    Name of the column holding the transport protocol to be used for the
+    gateway.
+ 
+-   Default value is "transport".
++   Default value is “transport”.
+ 
+    Example 1.11. Setting transport_column module parameter
+ ...
+@@ -489,7 +498,7 @@ modparam("lcr", "transport_column", "trans")
+    Name of the column holding the number of characters to be stripped from
+    the front of Request-URI user part before inserting tag.
+ 
+-   Default value is "strip".
++   Default value is “strip”.
+ 
+    Example 1.12. Setting strip_column module parameter
+ ...
+@@ -501,7 +510,7 @@ modparam("lcr", "strip_column", "strip_count")
+    Name of the column holding gateway specific tag string that is added to
+    Request URI userpart after stripping.
+ 
+-   Default value is "tag".
++   Default value is “tag”.
+ 
+    Example 1.13. Setting tag_column module parameter
+ ...
+@@ -512,7 +521,7 @@ modparam("lcr", "tag_column", "gw_tag")
+ 
+    Name of the column holding gateway specific flag values.
+ 
+-   Default value is "flags".
++   Default value is “flags”.
+ 
+    Example 1.14. Setting flags_column module parameter
+ ...
+@@ -526,7 +535,7 @@ modparam("lcr", "flags_column", "gw_flags")
+    max UNIX timestamp value) or greater, gw is considered currently unused
+    and is not loaded into memory at all.
+ 
+-   Default value is "defunct".
++   Default value is “defunct”.
+ 
+    Example 1.15. Setting defunct_column module parameter
+ ...
+@@ -537,7 +546,7 @@ modparam("lcr", "defunct_column", "defunct_until")
+ 
+    Name of the table holding the LCR rules.
+ 
+-   Default value is "lcr_rule".
++   Default value is “lcr_rule”.
+ 
+    Example 1.16. Setting lcr_rule_table module parameter
+ ...
+@@ -549,7 +558,7 @@ modparam("lcr", "lcr_rule_table", "rules")
+    Name of the column holding prefix of Request-URI user part and prefix
+    of gateway.
+ 
+-   Default value is "prefix".
++   Default value is “prefix”.
+ 
+    Example 1.17. Setting prefix_column module parameter
+ ...
+@@ -560,7 +569,7 @@ modparam("lcr", "prefix_column", "number_prefix")
+ 
+    Name of the column holding the From (caller's) URI.
+ 
+-   Default value is "from_uri".
++   Default value is “from_uri”.
+ 
+    Example 1.18. Setting from_uri_column module parameter
+ ...
+@@ -572,7 +581,7 @@ modparam("lcr", "from_uri_column", "caller_uri")
+    Name of the column holding the regular expression to match against the
+    complete request URI (including the "sip:" prefix).
+ 
+-   Default value is "request_uri".
++   Default value is “request_uri”.
+ 
+    Example 1.19. Setting request_uri_column module parameter
+ ...
+@@ -583,7 +592,7 @@ modparam("lcr", "request_uri_column", "callee_uri")
+ 
+    Name of the column holding rule's stopper attribute.
+ 
+-   Default value is "stopper".
++   Default value is “stopper”.
+ 
+    Example 1.20. Setting stopper_column module parameter
+ ...
+@@ -595,7 +604,7 @@ modparam("lcr", "stopper_column", "stop")
+    Name of the column telling is the rule is currently enabled or
+    disabled.
+ 
+-   Default value is "enabled".
++   Default value is “enabled”.
+ 
+    Example 1.21. Setting enabled_column module parameter
+ ...
+@@ -607,7 +616,7 @@ modparam("lcr", "enabled_column", "in_use")
+    Name of the table holding information about the LCR rule targets
+    (gateways).
+ 
+-   Default value is "lcr_rule_target".
++   Default value is “lcr_rule_target”.
+ 
+    Example 1.22. Setting lcr_rule_target_table module parameter
+ ...
+@@ -619,7 +628,7 @@ modparam("lcr", "lcr_rule_target_table", "rules")
+    Name of lcr_rule_target_table column containing an id of lcr_rule
+    table.
+ 
+-   Default value is "rule_id".
++   Default value is “rule_id”.
+ 
+    Example 1.23. Setting rule_id_column module parameter
+ ...
+@@ -630,7 +639,7 @@ modparam("lcr", "rule_id_column", "rule")
+ 
+    Name of lcr_rule_target_table column containing an id of lcr_gw table.
+ 
+-   Default value is "gw_id".
++   Default value is “gw_id”.
+ 
+    Example 1.24. Setting gw_id_column module parameter
+ ...
+@@ -641,7 +650,7 @@ modparam("lcr", "gw_id_column", "gw")
+ 
+    Name of the column holding the priority of the rule target.
+ 
+-   Default value is "priority".
++   Default value is “priority”.
+ 
+    Example 1.25. Setting priority_column module parameter
+ ...
+@@ -652,7 +661,7 @@ modparam("lcr", "priority_column", "priority")
+ 
+    Name of the column holding weight of rule target.
+ 
+-   Default value is "weight".
++   Default value is “weight”.
+ 
+    Example 1.26. Setting weight_column module parameter
+ ...
+@@ -796,7 +805,18 @@ modparam("lcr", "lcr_gw_count", 1024)
+ modparam("lcr", "dont_strip_or_tag_flag", 10)
+ ...
+ 
+-3.38. fetch_rows (integer)
++3.38. priority_ordering (integer)
++
++   Defines how matching gateways are ordered (see Overview section).
++
++   Default value is 0.
++
++   Example 1.38.  Setting priority_ordering module parameter
++...
++modparam("lcr", "priority_ordering", 1)
++...
++
++3.39. fetch_rows (integer)
+ 
+    The number of the rows to be fetched at once from database when loading
+    data from lcr_rule table. This value can be used to tune the load time
+@@ -804,14 +824,14 @@ modparam("lcr", "dont_strip_or_tag_flag", 10)
+    3750. In order for this parameter to have effect, the database driver
+    must support fetch_result() capability.
+ 
+-   Default value is "1024".
++   Default value is “1024”.
+ 
+-   Example 1.38. Set fetch_rows parameter
++   Example 1.39. Set fetch_rows parameter
+ ...
+ modparam("lcr", "fetch_rows", 3000)
+ ...
+ 
+-3.39. ping_interval (integer)
++3.40. ping_interval (integer)
+ 
+    Interval in seconds for sending OPTIONS ping requests to gateways that,
+    due to failures, have been marked as inactive by inactivate_gw()
+@@ -821,62 +841,61 @@ modparam("lcr", "fetch_rows", 3000)
+ 
+    If value of this parameter is greater than zero, tm module must have
+    been loaded and parameters lcr_id_avp and defunct_gw_avp must have been
+-   defined. Value "0" disables sending of OPTIONS ping requests to failed
++   defined. Value “0” disables sending of OPTIONS ping requests to failed
+    gateways.
+ 
+-   Default value is "0".
++   Default value is “0”.
+ 
+-   Example 1.39.  Set ping_interval parameter
++   Example 1.40.  Set ping_interval parameter
+ ...
+ modparam("lcr", "ping_interval", 15)
+ ...
+ 
+-3.40. ping_inactivate_threshold (integer)
++3.41. ping_inactivate_threshold (integer)
+ 
+    Tells after how many failures (= inactivate_gw() function calls) a
+    gateway is marked as inactive.
+ 
+-   Default value is "1", i.e., gateway is marked inactive after first
+-   failure.
++   Default value is “1”, i.e., gateway is inactivated after first failure.
+ 
+-   Example 1.40.  Set ping_inactive_threshold parameter
++   Example 1.41.  Set ping_inactivate_threshold parameter
+ ...
+-modparam("lcr", "ping_inactive_threshold", 3)
++modparam("lcr", "ping_inactivate_threshold", 3)
+ ...
+ 
+-3.41. ping_valid_reply_codes (string)
++3.42. ping_valid_reply_codes (string)
+ 
+    A comma separated list of SIP reply codes, which are accepted as valid
+    replies to OPTIONS ping requests. Reply codes 2xx are by default
+    accepted as valid replies and they don't need to be listed here.
+ 
+-   Default value is "", i.e., only 2xx replies are considered as valid
++   Default value is “”, i.e., only 2xx replies are considered as valid
+    replies.
+ 
+-   Example 1.41.  Set ping_valid_reply_codes parameter
++   Example 1.42.  Set ping_valid_reply_codes parameter
+ ...
+ modparam("lcr", "ping_valid_reply_codes", "403,405,501")
+ ...
+ 
+-3.42. ping_from (string)
++3.43. ping_from (string)
+ 
+    From URI used in OPTIONS ping requests.
+ 
+-   Default value is "sip:pinger at localhost".
++   Default value is “sip:pinger at localhost”.
+ 
+-   Example 1.42.  Set ping_from parameter
++   Example 1.43.  Set ping_from parameter
+ ...
+ modparam("lcr", "ping_from", "sip:proxy.operator.com")
+ ...
+ 
+-3.43. ping_socket (string)
++3.44. ping_socket (string)
+ 
+    Socket to be used for sending OPTIONS ping request. If not set or set
+-   to "", default socket is used.
++   to “”, default socket is used.
+ 
+-   Default value is "".
++   Default value is “”.
+ 
+-   Example 1.43.  Set ping_socket parameter
++   Example 1.44.  Set ping_socket parameter
+ ...
+ modparam("lcr", "ping_socket", "192.98.102.10:5060")
+ ...
+@@ -912,7 +931,7 @@ modparam("lcr", "ping_socket", "192.98.102.10:5060")
+ 
+    This function can be used from REQUEST_ROUTE.
+ 
+-   Example 1.44. load_gws usage
++   Example 1.45. load_gws usage
+ ...
+ if (!load_gws(1, $rU, $var(caller_uri))) {
+         sl_send_reply("500", "Server Internal Error - Cannot load gateways");
+@@ -942,7 +961,7 @@ if (!load_gws(1, $rU, $var(caller_uri))) {
+ 
+    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
+ 
+-   Example 1.45. next_gw usage from a route block
++   Example 1.46. next_gw usage from a route block
+ ...
+ if (!next_gw()) {
+         sl_send_reply("503", "Service not available - No gateways");
+@@ -950,7 +969,7 @@ if (!next_gw()) {
+ };
+ ...
+ 
+-   Example 1.46. next_gw usage from a failure route block
++   Example 1.47. next_gw usage from a failure route block
+ ...
+ if (!next_gw()) {
+         t_reply("503", "Service not available - No more gateways");
+@@ -970,7 +989,7 @@ if (!next_gw()) {
+ 
+    This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.
+ 
+-   Example 1.47. inactivate_gw usage
++   Example 1.48. inactivate_gw usage
+ ...
+ failure_route [GW_FAILURE] {
+ ...
+@@ -991,7 +1010,7 @@ failure_route [GW_FAILURE] {
+ 
+    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
+ 
+-   Example 1.48. defunct_gw usage
++   Example 1.49. defunct_gw usage
+ ...
+ defunct_gw(60);
+ ...
+@@ -1023,7 +1042,7 @@ defunct_gw(60);
+    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
+    ONREPLY_ROUTE.
+ 
+-   Example 1.49. from_gw usage
++   Example 1.50. from_gw usage
+ ...
+ if (from_gw(1, $avp(s:real_source_addr), 2) {
+         ...
+@@ -1053,7 +1072,7 @@ if (from_gw(1, $avp(s:real_source_addr), 2) {
+    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
+    ONREPLY_ROUTE.
+ 
+-   Example 1.50. from_gw usage
++   Example 1.51. from_gw usage
+ ...
+ $var(lcr_id) = from_any_gw("192.168.1.1", 3);
+ ...
+@@ -1074,7 +1093,7 @@ $var(lcr_id) = from_any_gw("192.168.1.1", 3);
+ 
+    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
+ 
+-   Example 1.51. to_gw usage
++   Example 1.52. to_gw usage
+ ...
+ if (to_gw("1")) {
+         ...
+@@ -1100,7 +1119,7 @@ if (to_gw("1")) {
+ 
+    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
+ 
+-   Example 1.52. to_gw usage
++   Example 1.53. to_gw usage
+ ...
+ if (to_any_gw("192.55.66.2", 1)) {
+         ...
+@@ -1123,7 +1142,7 @@ if (to_any_gw("192.55.66.2", 1)) {
+ 
+    Parameters: none
+ 
+-   Example 1.53. lcr.reload RPC example
++   Example 1.54. lcr.reload RPC example
+                 $ kamcmd lcr.reload
+ 
+ 5.2. lcr.dump_gws
+@@ -1132,7 +1151,7 @@ if (to_any_gw("192.55.66.2", 1)) {
+ 
+    Parameters: none
+ 
+-   Example 1.54. lcr.dump_gws RPC example
++   Example 1.55. lcr.dump_gws RPC example
+                 $ kamcmd lcr.dump_gws
+ 
+ 5.3. lcr.dump_rules
+@@ -1142,7 +1161,7 @@ if (to_any_gw("192.55.66.2", 1)) {
+ 
+    Parameters: none
+ 
+-   Example 1.55. lcr.dump_rules RPC example
++   Example 1.56. lcr.dump_rules RPC example
+                 $ kamcmd lcr.dump_rules
+ 
+ 5.4. lcr.defunct_gw
+@@ -1155,7 +1174,7 @@ if (to_any_gw("192.55.66.2", 1)) {
+ 
+    Parameters: lcr_id gw_id period
+ 
+-   Example 1.56. lcr.defunct_gw RPC example
++   Example 1.57. lcr.defunct_gw RPC example
+                 $ kamcmd lcr.defunct_gw 1 4 120
+ 
+ 6. Known Limitations
+diff --git a/modules/lcr/doc/lcr_admin.xml b/modules/lcr/doc/lcr_admin.xml
+index fcd8d55..3a47466 100644
+--- a/modules/lcr/doc/lcr_admin.xml
++++ b/modules/lcr/doc/lcr_admin.xml
+@@ -44,20 +44,35 @@
+ 	are ordered for forwarding purposes as follows:
+ 	</para>
+ 	<para>
+-	<itemizedlist>
++	<orderedlist>
+             <listitem>
+-                <para>(1) according to longest Request-URI user part match
++                <para>according to longest Request-URI user part match
+                 </para>
+             </listitem>
+             <listitem>
+-                <para>(2) according to tuple's priority
++                <para>according to tuple's priority
+                 </para>
+             </listitem>
+             <listitem>
+-                <para>(3) according to tuple's randomized weight
++                <para>according to tuple's randomized weight
+                 </para>
+             </listitem>
+-        </itemizedlist>
++        </orderedlist>
++	</para>
++	<para>
++    or, if priority_ordering parameter is set to value 1, as follows:
++	</para>
++	<para>
++	<orderedlist>
++            <listitem>
++                <para>according to tuple's priority
++                </para>
++            </listitem>
++            <listitem>
++                <para>according to tuple's randomized weight
++                </para>
++            </listitem>
++        </orderedlist>
+ 	</para>
+ 	<para>
+ 	A tuple can be marked as a "stopper" tuple.  If a "stopper"
+@@ -971,6 +986,29 @@ modparam("lcr", "dont_strip_or_tag_flag", 10)
+ 	</section>
+ 
+ 	<section>
++		<title><varname>priority_ordering</varname> (integer)</title>
++		<para>
++		Defines how matching gateways are ordered (see Overview section).
++		</para>
++		<para>
++		<emphasis>
++			Default value is 0.
++		</emphasis>
++		</para>
++		<example>
++		<title>
++		Setting <varname>priority_ordering</varname> module
++		parameter
++		</title>
++		<programlisting format="linespecific">
++...
++modparam("lcr", "priority_ordering", 1)
++...
++</programlisting>
++                </example>
++	</section>
++
++	<section>
+ 		<title><varname>fetch_rows</varname> (integer)</title>
+ 		<para>
+ 		The number of the rows to be fetched at once from database
+diff --git a/modules/lcr/lcr_mod.c b/modules/lcr/lcr_mod.c
+index ae01b24..81247d2 100644
+--- a/modules/lcr/lcr_mod.c
++++ b/modules/lcr/lcr_mod.c
+@@ -218,6 +218,9 @@ str ping_valid_reply_codes_param = {"", 0};
+ str ping_socket_param = {"", 0};
+ str ping_from_param = {"sip:pinger at localhost", 20};
+ 
++/* use priority as main ordering criteria */
++static unsigned int priority_ordering_param = 0;
++
+ /*
+  * Other module types and variables
+  */
+@@ -345,6 +348,7 @@ static param_export_t params[] = {
+     {"lcr_rule_hash_size",       INT_PARAM, &lcr_rule_hash_size_param},
+     {"lcr_gw_count",             INT_PARAM, &lcr_gw_count_param},
+     {"dont_strip_or_prefix_flag",INT_PARAM, &dont_strip_or_prefix_flag_param},
++    {"priority_ordering",        INT_PARAM, &priority_ordering_param},
+     {"fetch_rows",               INT_PARAM, &fetch_rows_param},
+     {"ping_interval",            INT_PARAM, &ping_interval_param},
+     {"ping_inactivate_threshold",  INT_PARAM, &ping_inactivate_threshold_param},
+@@ -465,6 +469,12 @@ static int mod_init(void)
+ 	return -1;
+     }
+ 
++    if ((priority_ordering_param != 0) && (priority_ordering_param != 1)) {
++        LM_ERR("invalid priority_ordering value <%d>\n",
++	       priority_ordering_param);
++	return -1;
++    }
++
+     /* Process AVP params */
+ 
+     if (gw_uri_avp_param && *gw_uri_avp_param) {
+@@ -780,6 +790,17 @@ static int comp_matched(const void *m1, const void *m2)
+     struct matched_gw_info *mi1 = (struct matched_gw_info *) m1;
+     struct matched_gw_info *mi2 = (struct matched_gw_info *) m2;
+ 
++    if (priority_ordering_param) {
++        /* Sort by priority */
++	if (mi1->priority < mi2->priority) return 1;
++	if (mi1->priority == mi2->priority) {
++	    /* Sort by randomized weigth */
++	    if (mi1->weight > mi2->weight) return 1;
++	    if (mi1->weight == mi2->weight) return 0;
++	}
++	return -1;
++    }
++
+     /* Sort by prefix_len */
+     if (mi1->prefix_len > mi2->prefix_len) return 1;
+     if (mi1->prefix_len == mi2->prefix_len) {
+@@ -789,9 +810,7 @@ static int comp_matched(const void *m1, const void *m2)
+ 	    /* Sort by randomized weigth */
+ 	    if (mi1->weight > mi2->weight) return 1;
+ 	    if (mi1->weight == mi2->weight) return 0;
+-	    return -1;
+ 	}
+-	return -1;
+     }
+     return -1;
+ }
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0006-Revert-modules-lcr-added-priority_ordering-module-pa.patch b/debian/patches/upstream/0006-Revert-modules-lcr-added-priority_ordering-module-pa.patch
new file mode 100644
index 0000000..2d82c16
--- /dev/null
+++ b/debian/patches/upstream/0006-Revert-modules-lcr-added-priority_ordering-module-pa.patch
@@ -0,0 +1,756 @@
+From 65a4adb30436ae16f241aefb3c44fdd36192a3fd Mon Sep 17 00:00:00 2001
+From: Victor Seva <linuxmaniac at torreviejawireless.org>
+Date: Tue, 16 Jun 2015 11:25:50 +0200
+Subject: [PATCH] Revert "modules/lcr: added priority_ordering module
+ parameter"
+
+This reverts commit 27d0e6d99ee512788f16ce4f6b6e4127dea420bd.
+---
+ modules/lcr/README            | 219 +++++++++++++++++++-----------------------
+ modules/lcr/doc/lcr_admin.xml |  48 +--------
+ modules/lcr/lcr_mod.c         |  23 +----
+ 3 files changed, 107 insertions(+), 183 deletions(-)
+
+diff --git a/modules/lcr/README b/modules/lcr/README
+index e7d92eb..58268cf 100644
+--- a/modules/lcr/README
++++ b/modules/lcr/README
+@@ -10,7 +10,7 @@ Juha Heinanen
+ 
+    <jh at tutpro.com>
+ 
+-   Copyright © 2005-2014 Juha Heinanen
++   Copyright (c) 2005-2014 Juha Heinanen
+      __________________________________________________________________
+ 
+    Table of Contents
+@@ -62,13 +62,12 @@ Juha Heinanen
+               3.35. lcr_rule_hash_size (integer)
+               3.36. lcr_gw_count (integer)
+               3.37. dont_strip_or_tag_flag (integer)
+-              3.38. priority_ordering (integer)
+-              3.39. fetch_rows (integer)
+-              3.40. ping_interval (integer)
+-              3.41. ping_inactivate_threshold (integer)
+-              3.42. ping_valid_reply_codes (string)
+-              3.43. ping_from (string)
+-              3.44. ping_socket (string)
++              3.38. fetch_rows (integer)
++              3.39. ping_interval (integer)
++              3.40. ping_inactivate_threshold (integer)
++              3.41. ping_valid_reply_codes (string)
++              3.42. ping_from (string)
++              3.43. ping_socket (string)
+ 
+         4. Functions
+ 
+@@ -129,26 +128,25 @@ Juha Heinanen
+    1.35. Setting lcr_rule_hash_size module parameter
+    1.36. Setting lcr_gw_count module parameter
+    1.37. Setting dont_strip_or_tag_flag module parameter
+-   1.38. Setting priority_ordering module parameter
+-   1.39. Set fetch_rows parameter
+-   1.40. Set ping_interval parameter
+-   1.41. Set ping_inactivate_threshold parameter
+-   1.42. Set ping_valid_reply_codes parameter
+-   1.43. Set ping_from parameter
+-   1.44. Set ping_socket parameter
+-   1.45. load_gws usage
+-   1.46. next_gw usage from a route block
+-   1.47. next_gw usage from a failure route block
+-   1.48. inactivate_gw usage
+-   1.49. defunct_gw usage
++   1.38. Set fetch_rows parameter
++   1.39. Set ping_interval parameter
++   1.40. Set ping_inactive_threshold parameter
++   1.41. Set ping_valid_reply_codes parameter
++   1.42. Set ping_from parameter
++   1.43. Set ping_socket parameter
++   1.44. load_gws usage
++   1.45. next_gw usage from a route block
++   1.46. next_gw usage from a failure route block
++   1.47. inactivate_gw usage
++   1.48. defunct_gw usage
++   1.49. from_gw usage
+    1.50. from_gw usage
+-   1.51. from_gw usage
++   1.51. to_gw usage
+    1.52. to_gw usage
+-   1.53. to_gw usage
+-   1.54. lcr.reload RPC example
+-   1.55. lcr.dump_gws RPC example
+-   1.56. lcr.dump_rules RPC example
+-   1.57. lcr.defunct_gw RPC example
++   1.53. lcr.reload RPC example
++   1.54. lcr.dump_gws RPC example
++   1.55. lcr.dump_rules RPC example
++   1.56. lcr.defunct_gw RPC example
+ 
+ Chapter 1. Admin Guide
+ 
+@@ -199,13 +197,12 @@ Chapter 1. Admin Guide
+         3.35. lcr_rule_hash_size (integer)
+         3.36. lcr_gw_count (integer)
+         3.37. dont_strip_or_tag_flag (integer)
+-        3.38. priority_ordering (integer)
+-        3.39. fetch_rows (integer)
+-        3.40. ping_interval (integer)
+-        3.41. ping_inactivate_threshold (integer)
+-        3.42. ping_valid_reply_codes (string)
+-        3.43. ping_from (string)
+-        3.44. ping_socket (string)
++        3.38. fetch_rows (integer)
++        3.39. ping_interval (integer)
++        3.40. ping_inactivate_threshold (integer)
++        3.41. ping_valid_reply_codes (string)
++        3.42. ping_from (string)
++        3.43. ping_socket (string)
+ 
+    4. Functions
+ 
+@@ -251,14 +248,9 @@ Chapter 1. Admin Guide
+    currently designated as defunct) are ordered for forwarding purposes as
+    follows:
+ 
+-    1. according to longest Request-URI user part match
+-    2. according to tuple's priority
+-    3. according to tuple's randomized weight
+-
+-   or, if priority_ordering parameter is set to value 1, as follows:
+-
+-    1. according to tuple's priority
+-    2. according to tuple's randomized weight
++     * (1) according to longest Request-URI user part match
++     * (2) according to tuple's priority
++     * (3) according to tuple's randomized weight
+ 
+    A tuple can be marked as a "stopper" tuple. If a "stopper" tuple
+    matches, then matching stops at it and all other tuples with shorter
+@@ -357,19 +349,18 @@ Chapter 1. Admin Guide
+    3.35. lcr_rule_hash_size (integer)
+    3.36. lcr_gw_count (integer)
+    3.37. dont_strip_or_tag_flag (integer)
+-   3.38. priority_ordering (integer)
+-   3.39. fetch_rows (integer)
+-   3.40. ping_interval (integer)
+-   3.41. ping_inactivate_threshold (integer)
+-   3.42. ping_valid_reply_codes (string)
+-   3.43. ping_from (string)
+-   3.44. ping_socket (string)
++   3.38. fetch_rows (integer)
++   3.39. ping_interval (integer)
++   3.40. ping_inactivate_threshold (integer)
++   3.41. ping_valid_reply_codes (string)
++   3.42. ping_from (string)
++   3.43. ping_socket (string)
+ 
+ 3.1. db_url (string)
+ 
+    URL of the database table to be used.
+ 
+-   Default value is “mysql://kamailioro:kamailioro@localhost/kamailio”.
++   Default value is "mysql://kamailioro:kamailioro@localhost/kamailio".
+ 
+    Example 1.1. Setting db_url module parameter
+ ...
+@@ -380,7 +371,7 @@ modparam("lcr","db_url","dbdriver://username:password@dbhost/dbname")
+ 
+    Name of the table holding gateways definitions.
+ 
+-   Default value is “lcr_gw”.
++   Default value is "lcr_gw".
+ 
+    Example 1.2. Setting gw_table module parameter
+ ...
+@@ -392,7 +383,7 @@ modparam("lcr", "lcr_gw_table","gw")
+    Name of the auto-increment, primary key column. Common to all lcr
+    module tables.
+ 
+-   Default value is “id”.
++   Default value is "id".
+ 
+    Example 1.3. Setting id_column module parameter
+ ...
+@@ -406,7 +397,7 @@ modparam("lcr", "id_column", "row_id")
+    the column is integer from 1 to lcr_count. In lcr_gw table, value of
+    the column is from 0 to lcr_count.
+ 
+-   Default value is “lcr_id”.
++   Default value is "lcr_id".
+ 
+    Example 1.4. Setting lcr_id_column module parameter
+ ...
+@@ -417,7 +408,7 @@ modparam("lcr", "lcr_id_column", "lcr_identifier")
+ 
+    Name of the column holding gateway's name for documentation purpose.
+ 
+-   Default value is “gw_name”.
++   Default value is "gw_name".
+ 
+    Example 1.5. Setting gw_name_column module parameter
+ ...
+@@ -428,7 +419,7 @@ modparam("lcr", "gw_name_column", "name")
+ 
+    Name of the column holding the IPv4 or IPv6 address of the gateway.
+ 
+-   Default value is “ip_addr”.
++   Default value is "ip_addr".
+ 
+    Example 1.6. Setting ip_addr_column module parameter
+ ...
+@@ -440,7 +431,7 @@ modparam("lcr", "ip_addr_column", "ip")
+    Name of the column holding gateway's hostname that is used in
+    Request-URI hostpart, when request is sent to the gateway.
+ 
+-   Default value is “hostname”.
++   Default value is "hostname".
+ 
+    Example 1.7. Setting hostname_column module parameter
+ ...
+@@ -451,7 +442,7 @@ modparam("lcr", "hostname_column", "host")
+ 
+    Name of the column holding the port number of the gateway.
+ 
+-   Default value is “port”.
++   Default value is "port".
+ 
+    Example 1.8. Setting port_column module parameter
+ ...
+@@ -463,7 +454,7 @@ modparam("lcr", "port_column", "port")
+    Name of the column holding gateway's parameters that is used in
+    Request-URI, when request is sent to the gateway.
+ 
+-   Default value is “params”.
++   Default value is "params".
+ 
+    Example 1.9. Setting params_column module parameter
+ ...
+@@ -474,7 +465,7 @@ modparam("lcr", "params_column", "parameters")
+ 
+    Name of the column holding the uri scheme of the gateway.
+ 
+-   Default value is “uri_scheme”.
++   Default value is "uri_scheme".
+ 
+    Example 1.10. Setting uri_scheme_column module parameter
+ ...
+@@ -486,7 +477,7 @@ modparam("lcr", "uri_scheme_column", "uri_scheme")
+    Name of the column holding the transport protocol to be used for the
+    gateway.
+ 
+-   Default value is “transport”.
++   Default value is "transport".
+ 
+    Example 1.11. Setting transport_column module parameter
+ ...
+@@ -498,7 +489,7 @@ modparam("lcr", "transport_column", "trans")
+    Name of the column holding the number of characters to be stripped from
+    the front of Request-URI user part before inserting tag.
+ 
+-   Default value is “strip”.
++   Default value is "strip".
+ 
+    Example 1.12. Setting strip_column module parameter
+ ...
+@@ -510,7 +501,7 @@ modparam("lcr", "strip_column", "strip_count")
+    Name of the column holding gateway specific tag string that is added to
+    Request URI userpart after stripping.
+ 
+-   Default value is “tag”.
++   Default value is "tag".
+ 
+    Example 1.13. Setting tag_column module parameter
+ ...
+@@ -521,7 +512,7 @@ modparam("lcr", "tag_column", "gw_tag")
+ 
+    Name of the column holding gateway specific flag values.
+ 
+-   Default value is “flags”.
++   Default value is "flags".
+ 
+    Example 1.14. Setting flags_column module parameter
+ ...
+@@ -535,7 +526,7 @@ modparam("lcr", "flags_column", "gw_flags")
+    max UNIX timestamp value) or greater, gw is considered currently unused
+    and is not loaded into memory at all.
+ 
+-   Default value is “defunct”.
++   Default value is "defunct".
+ 
+    Example 1.15. Setting defunct_column module parameter
+ ...
+@@ -546,7 +537,7 @@ modparam("lcr", "defunct_column", "defunct_until")
+ 
+    Name of the table holding the LCR rules.
+ 
+-   Default value is “lcr_rule”.
++   Default value is "lcr_rule".
+ 
+    Example 1.16. Setting lcr_rule_table module parameter
+ ...
+@@ -558,7 +549,7 @@ modparam("lcr", "lcr_rule_table", "rules")
+    Name of the column holding prefix of Request-URI user part and prefix
+    of gateway.
+ 
+-   Default value is “prefix”.
++   Default value is "prefix".
+ 
+    Example 1.17. Setting prefix_column module parameter
+ ...
+@@ -569,7 +560,7 @@ modparam("lcr", "prefix_column", "number_prefix")
+ 
+    Name of the column holding the From (caller's) URI.
+ 
+-   Default value is “from_uri”.
++   Default value is "from_uri".
+ 
+    Example 1.18. Setting from_uri_column module parameter
+ ...
+@@ -581,7 +572,7 @@ modparam("lcr", "from_uri_column", "caller_uri")
+    Name of the column holding the regular expression to match against the
+    complete request URI (including the "sip:" prefix).
+ 
+-   Default value is “request_uri”.
++   Default value is "request_uri".
+ 
+    Example 1.19. Setting request_uri_column module parameter
+ ...
+@@ -592,7 +583,7 @@ modparam("lcr", "request_uri_column", "callee_uri")
+ 
+    Name of the column holding rule's stopper attribute.
+ 
+-   Default value is “stopper”.
++   Default value is "stopper".
+ 
+    Example 1.20. Setting stopper_column module parameter
+ ...
+@@ -604,7 +595,7 @@ modparam("lcr", "stopper_column", "stop")
+    Name of the column telling is the rule is currently enabled or
+    disabled.
+ 
+-   Default value is “enabled”.
++   Default value is "enabled".
+ 
+    Example 1.21. Setting enabled_column module parameter
+ ...
+@@ -616,7 +607,7 @@ modparam("lcr", "enabled_column", "in_use")
+    Name of the table holding information about the LCR rule targets
+    (gateways).
+ 
+-   Default value is “lcr_rule_target”.
++   Default value is "lcr_rule_target".
+ 
+    Example 1.22. Setting lcr_rule_target_table module parameter
+ ...
+@@ -628,7 +619,7 @@ modparam("lcr", "lcr_rule_target_table", "rules")
+    Name of lcr_rule_target_table column containing an id of lcr_rule
+    table.
+ 
+-   Default value is “rule_id”.
++   Default value is "rule_id".
+ 
+    Example 1.23. Setting rule_id_column module parameter
+ ...
+@@ -639,7 +630,7 @@ modparam("lcr", "rule_id_column", "rule")
+ 
+    Name of lcr_rule_target_table column containing an id of lcr_gw table.
+ 
+-   Default value is “gw_id”.
++   Default value is "gw_id".
+ 
+    Example 1.24. Setting gw_id_column module parameter
+ ...
+@@ -650,7 +641,7 @@ modparam("lcr", "gw_id_column", "gw")
+ 
+    Name of the column holding the priority of the rule target.
+ 
+-   Default value is “priority”.
++   Default value is "priority".
+ 
+    Example 1.25. Setting priority_column module parameter
+ ...
+@@ -661,7 +652,7 @@ modparam("lcr", "priority_column", "priority")
+ 
+    Name of the column holding weight of rule target.
+ 
+-   Default value is “weight”.
++   Default value is "weight".
+ 
+    Example 1.26. Setting weight_column module parameter
+ ...
+@@ -805,18 +796,7 @@ modparam("lcr", "lcr_gw_count", 1024)
+ modparam("lcr", "dont_strip_or_tag_flag", 10)
+ ...
+ 
+-3.38. priority_ordering (integer)
+-
+-   Defines how matching gateways are ordered (see Overview section).
+-
+-   Default value is 0.
+-
+-   Example 1.38.  Setting priority_ordering module parameter
+-...
+-modparam("lcr", "priority_ordering", 1)
+-...
+-
+-3.39. fetch_rows (integer)
++3.38. fetch_rows (integer)
+ 
+    The number of the rows to be fetched at once from database when loading
+    data from lcr_rule table. This value can be used to tune the load time
+@@ -824,14 +804,14 @@ modparam("lcr", "priority_ordering", 1)
+    3750. In order for this parameter to have effect, the database driver
+    must support fetch_result() capability.
+ 
+-   Default value is “1024”.
++   Default value is "1024".
+ 
+-   Example 1.39. Set fetch_rows parameter
++   Example 1.38. Set fetch_rows parameter
+ ...
+ modparam("lcr", "fetch_rows", 3000)
+ ...
+ 
+-3.40. ping_interval (integer)
++3.39. ping_interval (integer)
+ 
+    Interval in seconds for sending OPTIONS ping requests to gateways that,
+    due to failures, have been marked as inactive by inactivate_gw()
+@@ -841,61 +821,62 @@ modparam("lcr", "fetch_rows", 3000)
+ 
+    If value of this parameter is greater than zero, tm module must have
+    been loaded and parameters lcr_id_avp and defunct_gw_avp must have been
+-   defined. Value “0” disables sending of OPTIONS ping requests to failed
++   defined. Value "0" disables sending of OPTIONS ping requests to failed
+    gateways.
+ 
+-   Default value is “0”.
++   Default value is "0".
+ 
+-   Example 1.40.  Set ping_interval parameter
++   Example 1.39.  Set ping_interval parameter
+ ...
+ modparam("lcr", "ping_interval", 15)
+ ...
+ 
+-3.41. ping_inactivate_threshold (integer)
++3.40. ping_inactivate_threshold (integer)
+ 
+    Tells after how many failures (= inactivate_gw() function calls) a
+    gateway is marked as inactive.
+ 
+-   Default value is “1”, i.e., gateway is inactivated after first failure.
++   Default value is "1", i.e., gateway is marked inactive after first
++   failure.
+ 
+-   Example 1.41.  Set ping_inactivate_threshold parameter
++   Example 1.40.  Set ping_inactive_threshold parameter
+ ...
+-modparam("lcr", "ping_inactivate_threshold", 3)
++modparam("lcr", "ping_inactive_threshold", 3)
+ ...
+ 
+-3.42. ping_valid_reply_codes (string)
++3.41. ping_valid_reply_codes (string)
+ 
+    A comma separated list of SIP reply codes, which are accepted as valid
+    replies to OPTIONS ping requests. Reply codes 2xx are by default
+    accepted as valid replies and they don't need to be listed here.
+ 
+-   Default value is “”, i.e., only 2xx replies are considered as valid
++   Default value is "", i.e., only 2xx replies are considered as valid
+    replies.
+ 
+-   Example 1.42.  Set ping_valid_reply_codes parameter
++   Example 1.41.  Set ping_valid_reply_codes parameter
+ ...
+ modparam("lcr", "ping_valid_reply_codes", "403,405,501")
+ ...
+ 
+-3.43. ping_from (string)
++3.42. ping_from (string)
+ 
+    From URI used in OPTIONS ping requests.
+ 
+-   Default value is “sip:pinger at localhost”.
++   Default value is "sip:pinger at localhost".
+ 
+-   Example 1.43.  Set ping_from parameter
++   Example 1.42.  Set ping_from parameter
+ ...
+ modparam("lcr", "ping_from", "sip:proxy.operator.com")
+ ...
+ 
+-3.44. ping_socket (string)
++3.43. ping_socket (string)
+ 
+    Socket to be used for sending OPTIONS ping request. If not set or set
+-   to “”, default socket is used.
++   to "", default socket is used.
+ 
+-   Default value is “”.
++   Default value is "".
+ 
+-   Example 1.44.  Set ping_socket parameter
++   Example 1.43.  Set ping_socket parameter
+ ...
+ modparam("lcr", "ping_socket", "192.98.102.10:5060")
+ ...
+@@ -931,7 +912,7 @@ modparam("lcr", "ping_socket", "192.98.102.10:5060")
+ 
+    This function can be used from REQUEST_ROUTE.
+ 
+-   Example 1.45. load_gws usage
++   Example 1.44. load_gws usage
+ ...
+ if (!load_gws(1, $rU, $var(caller_uri))) {
+         sl_send_reply("500", "Server Internal Error - Cannot load gateways");
+@@ -961,7 +942,7 @@ if (!load_gws(1, $rU, $var(caller_uri))) {
+ 
+    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
+ 
+-   Example 1.46. next_gw usage from a route block
++   Example 1.45. next_gw usage from a route block
+ ...
+ if (!next_gw()) {
+         sl_send_reply("503", "Service not available - No gateways");
+@@ -969,7 +950,7 @@ if (!next_gw()) {
+ };
+ ...
+ 
+-   Example 1.47. next_gw usage from a failure route block
++   Example 1.46. next_gw usage from a failure route block
+ ...
+ if (!next_gw()) {
+         t_reply("503", "Service not available - No more gateways");
+@@ -989,7 +970,7 @@ if (!next_gw()) {
+ 
+    This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.
+ 
+-   Example 1.48. inactivate_gw usage
++   Example 1.47. inactivate_gw usage
+ ...
+ failure_route [GW_FAILURE] {
+ ...
+@@ -1010,7 +991,7 @@ failure_route [GW_FAILURE] {
+ 
+    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
+ 
+-   Example 1.49. defunct_gw usage
++   Example 1.48. defunct_gw usage
+ ...
+ defunct_gw(60);
+ ...
+@@ -1042,7 +1023,7 @@ defunct_gw(60);
+    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
+    ONREPLY_ROUTE.
+ 
+-   Example 1.50. from_gw usage
++   Example 1.49. from_gw usage
+ ...
+ if (from_gw(1, $avp(s:real_source_addr), 2) {
+         ...
+@@ -1072,7 +1053,7 @@ if (from_gw(1, $avp(s:real_source_addr), 2) {
+    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
+    ONREPLY_ROUTE.
+ 
+-   Example 1.51. from_gw usage
++   Example 1.50. from_gw usage
+ ...
+ $var(lcr_id) = from_any_gw("192.168.1.1", 3);
+ ...
+@@ -1093,7 +1074,7 @@ $var(lcr_id) = from_any_gw("192.168.1.1", 3);
+ 
+    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
+ 
+-   Example 1.52. to_gw usage
++   Example 1.51. to_gw usage
+ ...
+ if (to_gw("1")) {
+         ...
+@@ -1119,7 +1100,7 @@ if (to_gw("1")) {
+ 
+    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
+ 
+-   Example 1.53. to_gw usage
++   Example 1.52. to_gw usage
+ ...
+ if (to_any_gw("192.55.66.2", 1)) {
+         ...
+@@ -1142,7 +1123,7 @@ if (to_any_gw("192.55.66.2", 1)) {
+ 
+    Parameters: none
+ 
+-   Example 1.54. lcr.reload RPC example
++   Example 1.53. lcr.reload RPC example
+                 $ kamcmd lcr.reload
+ 
+ 5.2. lcr.dump_gws
+@@ -1151,7 +1132,7 @@ if (to_any_gw("192.55.66.2", 1)) {
+ 
+    Parameters: none
+ 
+-   Example 1.55. lcr.dump_gws RPC example
++   Example 1.54. lcr.dump_gws RPC example
+                 $ kamcmd lcr.dump_gws
+ 
+ 5.3. lcr.dump_rules
+@@ -1161,7 +1142,7 @@ if (to_any_gw("192.55.66.2", 1)) {
+ 
+    Parameters: none
+ 
+-   Example 1.56. lcr.dump_rules RPC example
++   Example 1.55. lcr.dump_rules RPC example
+                 $ kamcmd lcr.dump_rules
+ 
+ 5.4. lcr.defunct_gw
+@@ -1174,7 +1155,7 @@ if (to_any_gw("192.55.66.2", 1)) {
+ 
+    Parameters: lcr_id gw_id period
+ 
+-   Example 1.57. lcr.defunct_gw RPC example
++   Example 1.56. lcr.defunct_gw RPC example
+                 $ kamcmd lcr.defunct_gw 1 4 120
+ 
+ 6. Known Limitations
+diff --git a/modules/lcr/doc/lcr_admin.xml b/modules/lcr/doc/lcr_admin.xml
+index 3a47466..fcd8d55 100644
+--- a/modules/lcr/doc/lcr_admin.xml
++++ b/modules/lcr/doc/lcr_admin.xml
+@@ -44,35 +44,20 @@
+ 	are ordered for forwarding purposes as follows:
+ 	</para>
+ 	<para>
+-	<orderedlist>
++	<itemizedlist>
+             <listitem>
+-                <para>according to longest Request-URI user part match
++                <para>(1) according to longest Request-URI user part match
+                 </para>
+             </listitem>
+             <listitem>
+-                <para>according to tuple's priority
++                <para>(2) according to tuple's priority
+                 </para>
+             </listitem>
+             <listitem>
+-                <para>according to tuple's randomized weight
++                <para>(3) according to tuple's randomized weight
+                 </para>
+             </listitem>
+-        </orderedlist>
+-	</para>
+-	<para>
+-    or, if priority_ordering parameter is set to value 1, as follows:
+-	</para>
+-	<para>
+-	<orderedlist>
+-            <listitem>
+-                <para>according to tuple's priority
+-                </para>
+-            </listitem>
+-            <listitem>
+-                <para>according to tuple's randomized weight
+-                </para>
+-            </listitem>
+-        </orderedlist>
++        </itemizedlist>
+ 	</para>
+ 	<para>
+ 	A tuple can be marked as a "stopper" tuple.  If a "stopper"
+@@ -986,29 +971,6 @@ modparam("lcr", "dont_strip_or_tag_flag", 10)
+ 	</section>
+ 
+ 	<section>
+-		<title><varname>priority_ordering</varname> (integer)</title>
+-		<para>
+-		Defines how matching gateways are ordered (see Overview section).
+-		</para>
+-		<para>
+-		<emphasis>
+-			Default value is 0.
+-		</emphasis>
+-		</para>
+-		<example>
+-		<title>
+-		Setting <varname>priority_ordering</varname> module
+-		parameter
+-		</title>
+-		<programlisting format="linespecific">
+-...
+-modparam("lcr", "priority_ordering", 1)
+-...
+-</programlisting>
+-                </example>
+-	</section>
+-
+-	<section>
+ 		<title><varname>fetch_rows</varname> (integer)</title>
+ 		<para>
+ 		The number of the rows to be fetched at once from database
+diff --git a/modules/lcr/lcr_mod.c b/modules/lcr/lcr_mod.c
+index 81247d2..ae01b24 100644
+--- a/modules/lcr/lcr_mod.c
++++ b/modules/lcr/lcr_mod.c
+@@ -218,9 +218,6 @@ str ping_valid_reply_codes_param = {"", 0};
+ str ping_socket_param = {"", 0};
+ str ping_from_param = {"sip:pinger at localhost", 20};
+ 
+-/* use priority as main ordering criteria */
+-static unsigned int priority_ordering_param = 0;
+-
+ /*
+  * Other module types and variables
+  */
+@@ -348,7 +345,6 @@ static param_export_t params[] = {
+     {"lcr_rule_hash_size",       INT_PARAM, &lcr_rule_hash_size_param},
+     {"lcr_gw_count",             INT_PARAM, &lcr_gw_count_param},
+     {"dont_strip_or_prefix_flag",INT_PARAM, &dont_strip_or_prefix_flag_param},
+-    {"priority_ordering",        INT_PARAM, &priority_ordering_param},
+     {"fetch_rows",               INT_PARAM, &fetch_rows_param},
+     {"ping_interval",            INT_PARAM, &ping_interval_param},
+     {"ping_inactivate_threshold",  INT_PARAM, &ping_inactivate_threshold_param},
+@@ -469,12 +465,6 @@ static int mod_init(void)
+ 	return -1;
+     }
+ 
+-    if ((priority_ordering_param != 0) && (priority_ordering_param != 1)) {
+-        LM_ERR("invalid priority_ordering value <%d>\n",
+-	       priority_ordering_param);
+-	return -1;
+-    }
+-
+     /* Process AVP params */
+ 
+     if (gw_uri_avp_param && *gw_uri_avp_param) {
+@@ -790,17 +780,6 @@ static int comp_matched(const void *m1, const void *m2)
+     struct matched_gw_info *mi1 = (struct matched_gw_info *) m1;
+     struct matched_gw_info *mi2 = (struct matched_gw_info *) m2;
+ 
+-    if (priority_ordering_param) {
+-        /* Sort by priority */
+-	if (mi1->priority < mi2->priority) return 1;
+-	if (mi1->priority == mi2->priority) {
+-	    /* Sort by randomized weigth */
+-	    if (mi1->weight > mi2->weight) return 1;
+-	    if (mi1->weight == mi2->weight) return 0;
+-	}
+-	return -1;
+-    }
+-
+     /* Sort by prefix_len */
+     if (mi1->prefix_len > mi2->prefix_len) return 1;
+     if (mi1->prefix_len == mi2->prefix_len) {
+@@ -810,7 +789,9 @@ static int comp_matched(const void *m1, const void *m2)
+ 	    /* Sort by randomized weigth */
+ 	    if (mi1->weight > mi2->weight) return 1;
+ 	    if (mi1->weight == mi2->weight) return 0;
++	    return -1;
+ 	}
++	return -1;
+     }
+     return -1;
+ }
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0007-uac-updated-notes-about-uac_auth.patch b/debian/patches/upstream/0007-uac-updated-notes-about-uac_auth.patch
new file mode 100644
index 0000000..663ebd7
--- /dev/null
+++ b/debian/patches/upstream/0007-uac-updated-notes-about-uac_auth.patch
@@ -0,0 +1,63 @@
+From 43b70c5c809f666c74bc0b75ce7549d2a7b0518e Mon Sep 17 00:00:00 2001
+From: Daniel-Constantin Mierla <miconda at gmail.com>
+Date: Thu, 11 Jun 2015 10:49:10 +0200
+Subject: [PATCH] uac: updated notes about uac_auth()
+
+(cherry picked from commit db829aabf30c5b4fdfee5ebd842959b63a598b26)
+---
+ modules/uac/doc/uac_admin.xml | 32 +++++++++++++++++++++++++++++---
+ 1 file changed, 29 insertions(+), 3 deletions(-)
+
+diff --git a/modules/uac/doc/uac_admin.xml b/modules/uac/doc/uac_admin.xml
+index 0a154d9..3e6021f 100644
+--- a/modules/uac/doc/uac_admin.xml
++++ b/modules/uac/doc/uac_admin.xml
+@@ -42,8 +42,10 @@
+ 			</listitem>
+ 			<listitem>
+ 			<para>
+-				CSeq is not increased during authentication - the response 
+-				may be rejected.
++				CSeq is not increased automatically by uac_auth() during authentication
++				- the follow up request may be rejected. CSeq can be increased when
++				authenticating INVITE requests - dialog module has to be used, with
++				CSeq tracking feature enabled (see the readme of dialog module).
+ 			</para>
+ 			</listitem>
+ 			<listitem>
+@@ -688,7 +690,31 @@ uac_restore_to();
+ 				<title><function>uac_auth</function> usage</title>
+ 				<programlisting format="linespecific">
+ ...
+-uac_auth();
++modparam("uac","auth_username_avp","$avp(auser)")
++modparam("uac","auth_password_avp","$avp(apass)")
++modparam("uac","auth_realm_avp","$avp(arealm)")
++
++request_route {
++   ...
++   if(is_method("INVITE")) {
++      t_on_failure("TRUNKAUTH");
++   }
++   ...
++}
++
++failure_route[TRUNKAUTH] {
++
++    if (t_is_canceled()) {
++        exit;
++    }
++    if(t_check_status("401|407")) {
++        $avp(auser) = "test";
++        $avp(apass) = "test";
++        uac_auth();
++        t_relay();
++        exit;
++    }
++}
+ ...
+ 				</programlisting>
+ 			</example>
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0008-dialog-re-entrant-mutex-for-dialogs-hash-table-slots.patch b/debian/patches/upstream/0008-dialog-re-entrant-mutex-for-dialogs-hash-table-slots.patch
new file mode 100644
index 0000000..af989d3
--- /dev/null
+++ b/debian/patches/upstream/0008-dialog-re-entrant-mutex-for-dialogs-hash-table-slots.patch
@@ -0,0 +1,178 @@
+From 69fe3fae08a8ebbe4926fb1e96e52547fe1047bb Mon Sep 17 00:00:00 2001
+From: Daniel-Constantin Mierla <miconda at gmail.com>
+Date: Tue, 16 Jun 2015 15:06:43 +0200
+Subject: [PATCH] dialog: re-entrant mutex for dialogs hash table slots
+
+- changed from a lock set usage to per slot lock field
+
+(cherry picked from commit 9c3ea838b31039ac067e17d519df67b64b0dada1)
+---
+ modules/dialog/dlg_hash.c | 39 +++++++--------------------------------
+ modules/dialog/dlg_hash.h | 31 +++++++++++++++++++++++++------
+ 2 files changed, 32 insertions(+), 38 deletions(-)
+
+diff --git a/modules/dialog/dlg_hash.c b/modules/dialog/dlg_hash.c
+index 536fe32..e3d0005 100644
+--- a/modules/dialog/dlg_hash.c
++++ b/modules/dialog/dlg_hash.c
+@@ -42,9 +42,6 @@
+ #include "dlg_req_within.h"
+ #include "dlg_db_handler.h"
+ 
+-#define MAX_LDG_LOCKS  2048
+-#define MIN_LDG_LOCKS  2
+-
+ extern int dlg_ka_interval;
+ 
+ /*! global dialog table */
+@@ -223,7 +220,7 @@ int dlg_clean_run(ticks_t ti)
+ 	tm = (unsigned int)time(NULL);
+ 	for(i=0; i<d_table->size; i++)
+ 	{
+-		lock_set_get(d_table->locks, d_table->entries[i].lock_idx);
++		dlg_lock(d_table, &d_table->entries[i]);
+ 		dlg = d_table->entries[i].first;
+ 		while (dlg) {
+ 			tdlg = dlg;
+@@ -243,7 +240,7 @@ int dlg_clean_run(ticks_t ti)
+ 				tdlg->dflags |= DLG_FLAG_CHANGED;
+ 			}
+ 		}
+-		lock_set_release(d_table->locks, d_table->entries[i].lock_idx);
++		dlg_unlock(d_table, &d_table->entries[i]);
+ 	}
+ 	return 0;
+ }
+@@ -288,30 +285,13 @@ int init_dlg_table(unsigned int size)
+ 	d_table->size = size;
+ 	d_table->entries = (struct dlg_entry*)(d_table+1);
+ 
+-	n = (size<MAX_LDG_LOCKS)?size:MAX_LDG_LOCKS;
+-	for(  ; n>=MIN_LDG_LOCKS ; n-- ) {
+-		d_table->locks = lock_set_alloc(n);
+-		if (d_table->locks==0)
+-			continue;
+-		if (lock_set_init(d_table->locks)==0) {
+-			lock_set_dealloc(d_table->locks);
+-			d_table->locks = 0;
+-			continue;
+-		}
+-		d_table->locks_no = n;
+-		break;
+-	}
+-
+-	if (d_table->locks==0) {
+-		LM_ERR("unable to allocted at least %d locks for the hash table\n",
+-			MIN_LDG_LOCKS);
+-		goto error1;
+-	}
+-
+ 	for( i=0 ; i<size; i++ ) {
+ 		memset( &(d_table->entries[i]), 0, sizeof(struct dlg_entry) );
++		if(lock_init(&d_table->entries[i].lock)<0) {
++			LM_ERR("failed to init lock for slot: %d\n", i);
++			goto error1;
++		}
+ 		d_table->entries[i].next_id = rand() % (3*size);
+-		d_table->entries[i].lock_idx = i % d_table->locks_no;
+ 	}
+ 
+ 	return 0;
+@@ -411,11 +391,6 @@ void destroy_dlg_table(void)
+ 	if (d_table==0)
+ 		return;
+ 
+-	if (d_table->locks) {
+-		lock_set_destroy(d_table->locks);
+-		lock_set_dealloc(d_table->locks);
+-	}
+-
+ 	for( i=0 ; i<d_table->size; i++ ) {
+ 		dlg = d_table->entries[i].first;
+ 		while (dlg) {
+@@ -423,7 +398,7 @@ void destroy_dlg_table(void)
+ 			dlg = dlg->next;
+ 			destroy_dlg(l_dlg);
+ 		}
+-
++		lock_destroy(&d_table->entries[i].lock);
+ 	}
+ 
+ 	shm_free(d_table);
+diff --git a/modules/dialog/dlg_hash.h b/modules/dialog/dlg_hash.h
+index d79d994..b09fe38 100644
+--- a/modules/dialog/dlg_hash.h
++++ b/modules/dialog/dlg_hash.h
+@@ -33,6 +33,7 @@
+ #include "../../locking.h"
+ #include "../../lib/kmi/mi.h"
+ #include "../../timer.h"
++#include "../../atomic_ops.h"
+ #include "dlg_timer.h"
+ #include "dlg_cb.h"
+ 
+@@ -134,7 +135,9 @@ typedef struct dlg_entry
+ 	struct dlg_cell    *first;	/*!< dialog list */
+ 	struct dlg_cell    *last;	/*!< optimisation, end of the dialog list */
+ 	unsigned int       next_id;	/*!< next id */
+-	unsigned int       lock_idx;	/*!< lock index */
++	gen_lock_t lock;     /* mutex to access items in the slot */
++	atomic_t locker_pid; /* pid of the process that holds the lock */
++	int rec_lock_level;  /* recursive lock count */
+ } dlg_entry_t;
+ 
+ 
+@@ -143,8 +146,6 @@ typedef struct dlg_table
+ {
+ 	unsigned int       size;	/*!< size of the dialog table */
+ 	struct dlg_entry   *entries;	/*!< dialog hash table */
+-	unsigned int       locks_no;	/*!< number of locks */
+-	gen_lock_set_t     *locks;	/*!< lock table */
+ } dlg_table_t;
+ 
+ 
+@@ -160,12 +161,22 @@ extern dlg_table_t *d_table;
+ 
+ 
+ /*!
+- * \brief Set a dialog lock
++ * \brief Set a dialog lock (re-entrant)
+  * \param _table dialog table
+  * \param _entry locked entry
+  */
+ #define dlg_lock(_table, _entry) \
+-		lock_set_get( (_table)->locks, (_entry)->lock_idx);
++		do { \
++			int mypid; \
++			mypid = my_pid(); \
++			if (likely(atomic_get( &(_entry)->locker_pid) != mypid)) { \
++				lock_get( &(_entry)->lock); \
++				atomic_set( &(_entry)->locker_pid, mypid); \
++			} else { \
++				/* locked within the same process that executed us */ \
++				(_entry)->rec_lock_level++; \
++			} \
++		} while(0)
+ 
+ 
+ /*!
+@@ -174,7 +185,15 @@ extern dlg_table_t *d_table;
+  * \param _entry locked entry
+  */
+ #define dlg_unlock(_table, _entry) \
+-		lock_set_release( (_table)->locks, (_entry)->lock_idx);
++		do { \
++			if (likely((_entry)->rec_lock_level == 0)) { \
++				atomic_set( &(_entry)->locker_pid, 0); \
++				lock_release( &(_entry)->lock); \
++			} else  { \
++				/* recursive locked => decrease lock count */ \
++				(_entry)->rec_lock_level--; \
++			} \
++		} while(0)
+ 
+ /*!
+  * \brief Unlink a dialog from the list without locking
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0009-dialog-removed-unused-variable.patch b/debian/patches/upstream/0009-dialog-removed-unused-variable.patch
new file mode 100644
index 0000000..0ababd1
--- /dev/null
+++ b/debian/patches/upstream/0009-dialog-removed-unused-variable.patch
@@ -0,0 +1,25 @@
+From f4f400c6078ac45133c546ed0e42e434ae06c983 Mon Sep 17 00:00:00 2001
+From: Daniel-Constantin Mierla <miconda at gmail.com>
+Date: Tue, 16 Jun 2015 15:45:07 +0200
+Subject: [PATCH] dialog: removed unused variable
+
+(cherry picked from commit 6dba3a2d2785cba6b29bcb3d11b318687a12b632)
+---
+ modules/dialog/dlg_hash.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/modules/dialog/dlg_hash.c b/modules/dialog/dlg_hash.c
+index e3d0005..420caea 100644
+--- a/modules/dialog/dlg_hash.c
++++ b/modules/dialog/dlg_hash.c
+@@ -252,7 +252,6 @@ int dlg_clean_run(ticks_t ti)
+  */
+ int init_dlg_table(unsigned int size)
+ {
+-	unsigned int n;
+ 	unsigned int i;
+ 
+ 	dlg_ka_list_head = (dlg_ka_t **)shm_malloc(sizeof(dlg_ka_t *));
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0010-utils-fixed-indentation.patch b/debian/patches/upstream/0010-utils-fixed-indentation.patch
new file mode 100644
index 0000000..e52cf9f
--- /dev/null
+++ b/debian/patches/upstream/0010-utils-fixed-indentation.patch
@@ -0,0 +1,249 @@
+From 82b3e56c0ea38682d82ac7b5411555e7c8423eab Mon Sep 17 00:00:00 2001
+From: Daniel-Constantin Mierla <miconda at gmail.com>
+Date: Wed, 17 Jun 2015 16:12:44 +0200
+Subject: [PATCH] utils: fixed indentation
+
+(cherry picked from commit 8a9d7df57e0ac83bb8fb6f97c71b01ec96184ba0)
+---
+ modules/utils/functions.c | 196 +++++++++++++++++++++++-----------------------
+ 1 file changed, 98 insertions(+), 98 deletions(-)
+
+diff --git a/modules/utils/functions.c b/modules/utils/functions.c
+index 3bfcb26..d32d970 100644
+--- a/modules/utils/functions.c
++++ b/modules/utils/functions.c
+@@ -52,25 +52,25 @@
+  */
+ size_t write_function( void *ptr, size_t size, size_t nmemb, void *stream_ptr)
+ {
+-    http_res_stream_t *stream = (http_res_stream_t *) stream_ptr;
++	http_res_stream_t *stream = (http_res_stream_t *) stream_ptr;
+ 
+-    stream->buf = (char *) pkg_realloc(stream->buf, stream->curr_size + 
+-				(size * nmemb) + 1);
++	stream->buf = (char *) pkg_realloc(stream->buf, stream->curr_size + 
++			(size * nmemb) + 1);
+ 
+-    if (stream->buf == NULL) {
+-	LM_ERR("cannot allocate memory for stream\n");
+-	return CURLE_WRITE_ERROR;
+-    }
++	if (stream->buf == NULL) {
++		LM_ERR("cannot allocate memory for stream\n");
++		return CURLE_WRITE_ERROR;
++	}
+ 
+-    memcpy(&stream->buf[stream->pos], (char *) ptr, (size * nmemb));
++	memcpy(&stream->buf[stream->pos], (char *) ptr, (size * nmemb));
+ 
+-    stream->curr_size += ((size * nmemb) + 1);
+-    stream->pos += (size * nmemb);
++	stream->curr_size += ((size * nmemb) + 1);
++	stream->pos += (size * nmemb);
+ 
+-    stream->buf[stream->pos + 1] = '\0';
++	stream->buf[stream->pos + 1] = '\0';
+ 
+-    return size * nmemb;
+- }
++	return size * nmemb;
++}
+ 
+ 
+ /* 
+@@ -79,73 +79,73 @@ size_t write_function( void *ptr, size_t size, size_t nmemb, void *stream_ptr)
+  */
+ int http_query(struct sip_msg* _m, char* _url, char* _dst, char* _post)
+ {
+-    CURL *curl;
+-    CURLcode res;  
+-    str value, post_value;
+-    char *url, *at, *post;
+-    http_res_stream_t stream;
+-    long stat;
+-    pv_spec_t *dst;
+-    pv_value_t val;
+-    double download_size;
+-
+-    memset(&stream, 0, sizeof(http_res_stream_t));
+-
+-    if (fixup_get_svalue(_m, (gparam_p)_url, &value) != 0) {
+-	LM_ERR("cannot get page value\n");
+-	return -1;
+-    }
+-
+-    curl = curl_easy_init();
+-    if (curl == NULL) {
+-	LM_ERR("failed to initialize curl\n");
+-	return -1;
+-    }
+-
+-    url = pkg_malloc(value.len + 1);
+-    if (url == NULL) {
+-	curl_easy_cleanup(curl);
+-	LM_ERR("cannot allocate pkg memory for url\n");
+-	return -1;
+-    }
+-    memcpy(url, value.s, value.len);
+-    *(url + value.len) = (char)0;
+-    curl_easy_setopt(curl, CURLOPT_URL, url);
+-
+-    if (_post) {
+-        /* Now specify we want to POST data */ 
+-	curl_easy_setopt(curl, CURLOPT_POST, 1L);
+-
+-    	if (fixup_get_svalue(_m, (gparam_p)_post, &post_value) != 0) {
+-		LM_ERR("cannot get post value\n");
+-		curl_easy_cleanup(curl);
+-		pkg_free(url);
++	CURL *curl;
++	CURLcode res;  
++	str value, post_value;
++	char *url, *at, *post;
++	http_res_stream_t stream;
++	long stat;
++	pv_spec_t *dst;
++	pv_value_t val;
++	double download_size;
++
++	memset(&stream, 0, sizeof(http_res_stream_t));
++
++	if (fixup_get_svalue(_m, (gparam_p)_url, &value) != 0) {
++		LM_ERR("cannot get page value\n");
+ 		return -1;
+-    	}
+-        post = pkg_malloc(post_value.len + 1);
+-        if (post == NULL) {
++	}
++
++	curl = curl_easy_init();
++	if (curl == NULL) {
++		LM_ERR("failed to initialize curl\n");
++		return -1;
++	}
++
++	url = pkg_malloc(value.len + 1);
++	if (url == NULL) {
+ 		curl_easy_cleanup(curl);
+-		pkg_free(url);
+-        	LM_ERR("cannot allocate pkg memory for post\n");
+-        	return -1;
++		LM_ERR("cannot allocate pkg memory for url\n");
++		return -1;
++	}
++	memcpy(url, value.s, value.len);
++	*(url + value.len) = (char)0;
++	curl_easy_setopt(curl, CURLOPT_URL, url);
++
++	if (_post) {
++		/* Now specify we want to POST data */ 
++		curl_easy_setopt(curl, CURLOPT_POST, 1L);
++
++		if (fixup_get_svalue(_m, (gparam_p)_post, &post_value) != 0) {
++			LM_ERR("cannot get post value\n");
++			curl_easy_cleanup(curl);
++			pkg_free(url);
++			return -1;
++		}
++		post = pkg_malloc(post_value.len + 1);
++		if (post == NULL) {
++			curl_easy_cleanup(curl);
++			pkg_free(url);
++			LM_ERR("cannot allocate pkg memory for post\n");
++			return -1;
++		}
++		memcpy(post, post_value.s, post_value.len);
++		*(post + post_value.len) = (char)0;
++		curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post);
+ 	}
+-	memcpy(post, post_value.s, post_value.len);
+-	*(post + post_value.len) = (char)0;
+- 	curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post);
+-    }
+-       
+ 
+-    curl_easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1);
+-    curl_easy_setopt(curl, CURLOPT_TIMEOUT, (long)http_query_timeout);
+ 
+-    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_function);
+-    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &stream);
++	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1);
++	curl_easy_setopt(curl, CURLOPT_TIMEOUT, (long)http_query_timeout);
++
++	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_function);
++	curl_easy_setopt(curl, CURLOPT_WRITEDATA, &stream);
+ 
+-    res = curl_easy_perform(curl);  
+-    pkg_free(url);
+-    if (_post) {
+-	pkg_free(post);
+-    }
++	res = curl_easy_perform(curl);  
++	pkg_free(url);
++	if (_post) {
++		pkg_free(post);
++	}
+ 
+ 	if (res != CURLE_OK) {
+ 		/* http://curl.haxx.se/libcurl/c/libcurl-errors.html */
+@@ -156,33 +156,33 @@ int http_query(struct sip_msg* _m, char* _url, char* _dst, char* _post)
+ 		} else {
+ 			LM_ERR("failed to perform curl (%d)\n", res);
+ 		}
+-	
++
+ 		curl_easy_cleanup(curl);
+ 		if(stream.buf)
+ 			pkg_free(stream.buf);
+ 		return -1;
+-    }
+-
+-    curl_easy_getinfo(curl, CURLINFO_HTTP_CODE, &stat);
+-    if ((stat >= 200) && (stat < 500)) {
+-	curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD, &download_size);
+-	LM_DBG("http_query download size: %u\n", (unsigned int)download_size);
+-
+-	/* search for line feed */
+-	at = memchr(stream.buf, (char)10, download_size);
+-	if (at == NULL) {
+-	    /* not found: use whole stream */
+-	    at = stream.buf + (unsigned int)download_size;
+ 	}
+-	val.rs.s = stream.buf;
+-	val.rs.len = at - stream.buf;
+-	LM_DBG("http_query result: %.*s\n", val.rs.len, val.rs.s);
+-	val.flags = PV_VAL_STR;
+-	dst = (pv_spec_t *)_dst;
+-	dst->setf(_m, &dst->pvp, (int)EQ_T, &val);
+-    }
+-	
+-    curl_easy_cleanup(curl);
+-    pkg_free(stream.buf);
+-    return stat;
++
++	curl_easy_getinfo(curl, CURLINFO_HTTP_CODE, &stat);
++	if ((stat >= 200) && (stat < 500)) {
++		curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD, &download_size);
++		LM_DBG("http_query download size: %u\n", (unsigned int)download_size);
++
++		/* search for line feed */
++		at = memchr(stream.buf, (char)10, download_size);
++		if (at == NULL) {
++			/* not found: use whole stream */
++			at = stream.buf + (unsigned int)download_size;
++		}
++		val.rs.s = stream.buf;
++		val.rs.len = at - stream.buf;
++		LM_DBG("http_query result: %.*s\n", val.rs.len, val.rs.s);
++		val.flags = PV_VAL_STR;
++		dst = (pv_spec_t *)_dst;
++		dst->setf(_m, &dst->pvp, (int)EQ_T, &val);
++	}
++
++	curl_easy_cleanup(curl);
++	pkg_free(stream.buf);
++	return stat;
+ }
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0011-Makefile.defs-fixes-indentation.patch b/debian/patches/upstream/0011-Makefile.defs-fixes-indentation.patch
new file mode 100644
index 0000000..4ee8a6d
--- /dev/null
+++ b/debian/patches/upstream/0011-Makefile.defs-fixes-indentation.patch
@@ -0,0 +1,31 @@
+From 6da6b53ba373af00f4f29b097c28709b9436583b Mon Sep 17 00:00:00 2001
+From: Mikko Lehto <mslehto at iki.fi>
+Date: Thu, 18 Jun 2015 15:22:56 +0300
+Subject: [PATCH] Makefile.defs: fixes indentation
+
+(cherry picked from commit 89633c4c85a6a44df3bbe4a80cf5ca595b59c196)
+---
+ Makefile.defs | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/Makefile.defs b/Makefile.defs
+index 65e50e7..7051f3b 100644
+--- a/Makefile.defs
++++ b/Makefile.defs
+@@ -892,11 +892,8 @@ else		# CC_NAME, gcc
+ ifeq		($(CC_NAME), clang)
+ $(call                          set_if_empty,CPU,athlon64)
+ 					C_DEFS+=-DCC_GCC_LIKE_ASM
+-                                        CFLAGS+=-g -m32
+-                                                $(CC_OPT) \
+-                                                          \
+-                                                -mtune=$(CPU)
+-                                        LDFLAGS+=-m32
++					CFLAGS+=-g -m32 $(CC_OPT) -mtune=$(CPU)
++					LDFLAGS+=-m32
+ else			# CC_NAME, clang
+ ifeq		($(CC_NAME), icc)
+ 			C_DEFS+=-DCC_GCC_LIKE_ASM
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0012-domain-allow-type-field-in-domain_attrs-to-be-a-DB1_.patch b/debian/patches/upstream/0012-domain-allow-type-field-in-domain_attrs-to-be-a-DB1_.patch
new file mode 100644
index 0000000..0170590
--- /dev/null
+++ b/debian/patches/upstream/0012-domain-allow-type-field-in-domain_attrs-to-be-a-DB1_.patch
@@ -0,0 +1,40 @@
+From 75b853cf54c2dd7595c094b302af169fcad25fe0 Mon Sep 17 00:00:00 2001
+From: Daniel-Constantin Mierla <miconda at gmail.com>
+Date: Fri, 19 Jun 2015 10:41:08 +0200
+Subject: [PATCH] domain: allow 'type' field in domain_attrs to be a DB1_BIGINT
+
+- in addition to allowing DB1_INT
+- makes it work with MySQL views on 64bit systems
+- based on a patch by divereigh, GH#182
+
+(cherry picked from commit e6f3a512c599678fca08daca561bcad4c05add23)
+---
+ modules/domain/domain.c | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/modules/domain/domain.c b/modules/domain/domain.c
+index 19943ab..65b6aed 100644
+--- a/modules/domain/domain.c
++++ b/modules/domain/domain.c
+@@ -362,11 +362,16 @@ int reload_tables ( void )
+ 	}
+ 
+ 	if ((VAL_NULL(ROW_VALUES(row) + 2) == 1) ||
+-	    (VAL_TYPE(ROW_VALUES(row) + 2) != DB1_INT)) {
++	    ((VAL_TYPE(ROW_VALUES(row) + 2) != DB1_INT) &&
++	     (VAL_TYPE(ROW_VALUES(row) + 2) != DB1_BIGINT))) {
+ 	    LM_ERR("type at row <%u> is null or not int\n", i);
+ 	    goto err;
+ 	}
+-	type = (int)VAL_INT(ROW_VALUES(row) + 2);
++	if(VAL_TYPE(ROW_VALUES(row) + 2) == DB1_BIGINT) {
++		type = (int)VAL_BIGINT(ROW_VALUES(row) + 2);
++	} else {
++		type = (int)VAL_INT(ROW_VALUES(row) + 2);
++	}
+ 	if ((type != 0) && (type != 2)) {
+ 	    LM_ERR("unknown type <%d> at row <%u>\n", type, i);
+ 	    goto err;
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0013-sdpops-don-t-return-0-if-no-match-for-sdp_get_line_s.patch b/debian/patches/upstream/0013-sdpops-don-t-return-0-if-no-match-for-sdp_get_line_s.patch
new file mode 100644
index 0000000..97c49b6
--- /dev/null
+++ b/debian/patches/upstream/0013-sdpops-don-t-return-0-if-no-match-for-sdp_get_line_s.patch
@@ -0,0 +1,30 @@
+From 388433d265cfcf8637c4e549803ee84cc9ef8519 Mon Sep 17 00:00:00 2001
+From: Daniel-Constantin Mierla <miconda at gmail.com>
+Date: Fri, 19 Jun 2015 11:56:56 +0200
+Subject: [PATCH] sdpops: don't return 0 if no match for
+ sdp_get_line_startswith()
+
+- that causes exit of config execution
+- reported by Sebastian Damm
+
+(cherry picked from commit 0870ab88262bb61124899ad98d06a72a6cdc7129)
+---
+ modules/sdpops/sdpops_mod.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/modules/sdpops/sdpops_mod.c b/modules/sdpops/sdpops_mod.c
+index 2a4aa6b..f853996 100644
+--- a/modules/sdpops/sdpops_mod.c
++++ b/modules/sdpops/sdpops_mod.c
+@@ -1657,7 +1657,7 @@ static int w_sdp_get_line_startswith(sip_msg_t *msg, char *avp, char *s_line)
+ 		p = find_sdp_line(line.s + line.len, body.s + body.len, sline.s[0]);
+ 	}
+ 
+-	return 0;
++	return -1;
+ }
+ 
+ /**
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0014-Makefile-kamailio-user-home-dir-set-to-var-run-kamai.patch b/debian/patches/upstream/0014-Makefile-kamailio-user-home-dir-set-to-var-run-kamai.patch
new file mode 100644
index 0000000..56b4e4f
--- /dev/null
+++ b/debian/patches/upstream/0014-Makefile-kamailio-user-home-dir-set-to-var-run-kamai.patch
@@ -0,0 +1,30 @@
+From 2894aff93058d29e2ad336c43478c3fcb5d082b1 Mon Sep 17 00:00:00 2001
+From: Daniel-Constantin Mierla <miconda at gmail.com>
+Date: Fri, 19 Jun 2015 12:06:30 +0200
+Subject: [PATCH] Makefile: kamailio user home dir set to /var/run/kamailio for
+ install-initd-centos
+
+- affects the useradd command
+- it was pointing to lib dir
+
+(cherry picked from commit dc2d3c3f609c81e21928390110952f4070ea9c62)
+---
+ Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index efd58cc..2d28777 100644
+--- a/Makefile
++++ b/Makefile
+@@ -999,7 +999,7 @@ install_initd_centos install-initd-centos:
+ 		> /etc/default/$(NAME)
+ 	/usr/sbin/groupadd -r $(NAME)
+ 	/usr/sbin/useradd -r -g $(NAME) -s /bin/false -c "Kamailio Daemon" \
+-                  -d ${lib_prefix}/${lib_dir} $(NAME)
++                  -d /var/run/$(NAME) $(NAME)
+ 
+ .PHONY: dbschema
+ dbschema:
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0015-evapi-evapi_close-doesn-t-use-any-parameter.patch b/debian/patches/upstream/0015-evapi-evapi_close-doesn-t-use-any-parameter.patch
new file mode 100644
index 0000000..b5798a8
--- /dev/null
+++ b/debian/patches/upstream/0015-evapi-evapi_close-doesn-t-use-any-parameter.patch
@@ -0,0 +1,26 @@
+From dcd1ba0e3a4e37b0a291bdebb69df0edec29aff2 Mon Sep 17 00:00:00 2001
+From: Daniel-Constantin Mierla <miconda at gmail.com>
+Date: Tue, 23 Jun 2015 11:45:22 +0200
+Subject: [PATCH] evapi: evapi_close() doesn't use any parameter
+
+(cherry picked from commit cccd1a4b20c750246b491ff41090c5749561948d)
+---
+ modules/evapi/evapi_mod.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/modules/evapi/evapi_mod.c b/modules/evapi/evapi_mod.c
+index 2a3a824..eeafc21 100644
+--- a/modules/evapi/evapi_mod.c
++++ b/modules/evapi/evapi_mod.c
+@@ -66,6 +66,8 @@ static cmd_export_t cmds[]={
+ 		0, ANY_ROUTE},
+ 	{"evapi_async_relay", (cmd_function)w_evapi_async_relay, 1, fixup_evapi_relay,
+ 		0, REQUEST_ROUTE},
++	{"evapi_close",       (cmd_function)w_evapi_close,       0, NULL,
++		0, ANY_ROUTE},
+ 	{"evapi_close",       (cmd_function)w_evapi_close,       1, NULL,
+ 		0, ANY_ROUTE},
+ 	{0, 0, 0, 0, 0, 0}
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0016-rtjson-error-log-level-set-to-notice-for-importing-u.patch b/debian/patches/upstream/0016-rtjson-error-log-level-set-to-notice-for-importing-u.patch
new file mode 100644
index 0000000..6809b8b
--- /dev/null
+++ b/debian/patches/upstream/0016-rtjson-error-log-level-set-to-notice-for-importing-u.patch
@@ -0,0 +1,28 @@
+From 85f93d29191ee099704c850a8742cf23404a3e9f Mon Sep 17 00:00:00 2001
+From: Daniel-Constantin Mierla <miconda at gmail.com>
+Date: Tue, 23 Jun 2015 13:12:08 +0200
+Subject: [PATCH] rtjson: error log level set to notice for importing uac api
+
+- printed at module init, it is not preventing to start the server
+
+(cherry picked from commit 239c54843897ec143c03693e44c994ee9cdde684)
+---
+ modules/rtjson/rtjson_routing.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/modules/rtjson/rtjson_routing.c b/modules/rtjson/rtjson_routing.c
+index 71ac2e6..7e088c9 100644
+--- a/modules/rtjson/rtjson_routing.c
++++ b/modules/rtjson/rtjson_routing.c
+@@ -58,7 +58,7 @@ int rtjson_init(void)
+ 		memset(&tmb, 0, sizeof(struct tm_binds));
+ 	}
+ 	if (load_uac_api(&uacb) < 0) {
+-		LM_ERR("cannot bind to UAC API - some features are diabled\n");
++		LM_NOTICE("cannot bind to UAC API - some features are diabled\n");
+ 		memset(&uacb, 0, sizeof(uac_api_t));
+ 	}
+ 	return 0;
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0017-uac-fixed-typos-in-log-message.patch b/debian/patches/upstream/0017-uac-fixed-typos-in-log-message.patch
new file mode 100644
index 0000000..7ab3616
--- /dev/null
+++ b/debian/patches/upstream/0017-uac-fixed-typos-in-log-message.patch
@@ -0,0 +1,26 @@
+From bebf30abb057221be646e95b07cdaca88cab63b5 Mon Sep 17 00:00:00 2001
+From: Daniel-Constantin Mierla <miconda at gmail.com>
+Date: Tue, 23 Jun 2015 13:15:29 +0200
+Subject: [PATCH] uac: fixed typos in log message
+
+(cherry picked from commit 42f0a1ffe551442058f53c9446495d5e62dc5abc)
+---
+ modules/uac/api.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/modules/uac/api.h b/modules/uac/api.h
+index 403a303..689f1fe 100644
+--- a/modules/uac/api.h
++++ b/modules/uac/api.h
+@@ -20,7 +20,7 @@ int bind_uac(uac_api_t*);
+ inline static int load_uac_api(uac_api_t *uacb){
+ 	bind_uac_f bind_uac_exports;
+ 	if(!(bind_uac_exports=(bind_uac_f)find_export("bind_uac",1,0))){
+-		LM_ERR("Failed to import bind_iuax\n");
++		LM_ERR("Failed to import bind_uac\n");
+ 		return -1;
+ 	}
+ 	return bind_uac_exports(uacb);
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0018-evapi-more-documentation-for-exported-functions.patch b/debian/patches/upstream/0018-evapi-more-documentation-for-exported-functions.patch
new file mode 100644
index 0000000..9565e6a
--- /dev/null
+++ b/debian/patches/upstream/0018-evapi-more-documentation-for-exported-functions.patch
@@ -0,0 +1,59 @@
+From c6b64b214af224e3416cc1d302bea472d847cebf Mon Sep 17 00:00:00 2001
+From: Daniel-Constantin Mierla <miconda at gmail.com>
+Date: Tue, 23 Jun 2015 14:07:37 +0200
+Subject: [PATCH] evapi: more documentation for exported functions
+
+(cherry picked from commit 96225847ddfc2f879d63adbc0117748c9cf76f02)
+---
+ modules/evapi/doc/evapi_admin.xml | 27 ++++++++++++++++++++++-----
+ 1 file changed, 22 insertions(+), 5 deletions(-)
+
+diff --git a/modules/evapi/doc/evapi_admin.xml b/modules/evapi/doc/evapi_admin.xml
+index ef2e34a..574adef 100644
+--- a/modules/evapi/doc/evapi_admin.xml
++++ b/modules/evapi/doc/evapi_admin.xml
+@@ -131,8 +131,18 @@ modparam("evapi", "netstring_format", 0)
+ 		<function moreinfo="none">evapi_relay(evdata)</function>
+ 	    </title>
+ 	    <para>
+-		Relay the event data give as parameter to connected applications.
+-		The format on the network is netstring with evdata payload.
++		Relay the event data given as parameter to connected applications.
++		</para>
++		<para>
++		The format on the network is netstring with evdata payload if
++		netstring_format parameter is set to 1 or bare evdata if
++		netstring_format parameter is set to 0.
++		</para>
++		<para>
++		The function is passing the task to evapi dispatcher process, therefore
++		the SIP worker process is not blocked. Also, it doesn't wait for any
++		response, therefore the processing of the configuration continues
++		very fast when executing evapi_relay().
+ 		</para>
+ 		<para>
+ 		This function can be used from ANY_ROUTE.
+@@ -166,10 +176,17 @@ evapi_relay("{ \"event\": \"test\",\n \"data\": { \"fU\": \"$fU\" }\n}");
+ 		<function moreinfo="none">evapi_async_relay(evdata)</function>
+ 	    </title>
+ 	    <para>
+-		Relay the event data give as parameter to connected applications.
+-		The format on the network is netstring with evdata payload. Before
++		Relay the event data given as parameter to connected applications. Before
+ 		evaluating the parameter, the request processing is suspended using
+-		tm module.
++		tm module (using the t_suspend()/t_continue() framework). The routing
++		of the SIP request can be continued once event_route[evapi:message-received]
++		is triggered. After evapi_async_relay() returns true, no relaying should
++		happen in request_route(), it should be followed by exit;.
++		</para>
++		<para>
++		The format on the network is netstring with evdata payload if
++		netstring_format parameter is set to 1 or bare evdata if
++		netstring_format parameter is set to 0.
+ 		</para>
+ 		<para>
+ 		This function can be used from REQUEST_ROUTE.
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0019-rtjson-proper-access-to-items-in-routes-array.patch b/debian/patches/upstream/0019-rtjson-proper-access-to-items-in-routes-array.patch
new file mode 100644
index 0000000..3304e17
--- /dev/null
+++ b/debian/patches/upstream/0019-rtjson-proper-access-to-items-in-routes-array.patch
@@ -0,0 +1,138 @@
+From f1a39a6580f6af041f3b002961dcd6f45498ad87 Mon Sep 17 00:00:00 2001
+From: Daniel-Constantin Mierla <miconda at gmail.com>
+Date: Tue, 23 Jun 2015 16:09:40 +0200
+Subject: [PATCH] rtjson: proper access to items in routes array
+
+- more debug messages to show the internal operations
+
+(cherry picked from commit 8025761dc0c75fd50e3ee24be96d420df79659d5)
+---
+ modules/rtjson/rtjson_routing.c | 28 ++++++++++++++++++++--------
+ 1 file changed, 20 insertions(+), 8 deletions(-)
+
+diff --git a/modules/rtjson/rtjson_routing.c b/modules/rtjson/rtjson_routing.c
+index 7e088c9..c9ee5c3 100644
+--- a/modules/rtjson/rtjson_routing.c
++++ b/modules/rtjson/rtjson_routing.c
+@@ -312,17 +312,19 @@ error:
+  */
+ int rtjson_init_serial(sip_msg_t *msg, srjson_doc_t *jdoc, sr_xavp_t *iavp)
+ {
++	srjson_t *tj = NULL;
+ 	srjson_t *nj = NULL;
+ 	srjson_t *rj = NULL;
+ 	str val;
+ 	unsigned int bflags = 0;
+ 	unsigned int old_bflags = 0;
+ 
+-	nj = srjson_GetObjectItem(jdoc, jdoc->root, "routes");
+-	if(nj==NULL || nj->type!=srjson_Array || nj->child==NULL) {
++	tj = srjson_GetObjectItem(jdoc, jdoc->root, "routes");
++	if(tj==NULL || tj->type!=srjson_Array || tj->child==NULL) {
+ 		LM_ERR("missing or invalid routes field\n");
+ 		goto error;
+ 	}
++	nj = tj->child;
+ 
+ 	clear_branches();
+ 
+@@ -330,6 +332,7 @@ int rtjson_init_serial(sip_msg_t *msg, srjson_doc_t *jdoc, sr_xavp_t *iavp)
+ 	if(rj!=NULL && rj->type==srjson_String && rj->valuestring!=NULL) {
+ 		val.s = rj->valuestring;
+ 		val.len = strlen(val.s);
++		LM_DBG("rewrite r-uri to: [%.*s]\n", val.len, val.s);
+ 		if (rewrite_uri(msg, &val) < 0) {
+ 			LM_ERR("unable to rewrite Request-URI\n");
+ 			goto error;
+@@ -349,6 +352,7 @@ int rtjson_init_serial(sip_msg_t *msg, srjson_doc_t *jdoc, sr_xavp_t *iavp)
+ 	if(rj!=NULL && rj->type==srjson_String && rj->valuestring!=NULL) {
+ 		val.s = rj->valuestring;
+ 		val.len = strlen(val.s);
++		LM_DBG("rewrite dst-uri to: [%.*s]\n", val.len, val.s);
+ 		if (set_dst_uri(msg, &val) < 0) {
+ 			LM_ERR("unable to set destination uri\n");
+ 			goto error;
+@@ -359,6 +363,7 @@ int rtjson_init_serial(sip_msg_t *msg, srjson_doc_t *jdoc, sr_xavp_t *iavp)
+ 	if(rj!=NULL && rj->type==srjson_String && rj->valuestring!=NULL) {
+ 		val.s = rj->valuestring;
+ 		val.len = strlen(val.s);
++		LM_DBG("rewrite path to: [%.*s]\n", val.len, val.s);
+ 		if (set_path_vector(msg, &val) < 0) {
+ 			LM_ERR("unable to set path\n");
+ 			goto error;
+@@ -423,6 +428,7 @@ int rtjson_prepare_branch(sip_msg_t *msg, srjson_doc_t *jdoc, srjson_t *nj)
+ 	}
+ 
+ 	if(xhdr.len>4) {
++		LM_DBG("appending extra headers: [%.*s]\n", xhdr.len, xhdr.s);
+ 		anchor = anchor_lump(msg, msg->unparsed - msg->buf, 0, 0);
+ 		if(anchor == 0) {
+ 			LM_ERR("can't get anchor\n");
+@@ -532,14 +538,16 @@ error:
+  */
+ int rtjson_init_parallel(sip_msg_t *msg, srjson_doc_t *jdoc, sr_xavp_t *iavp)
+ {
++	srjson_t *tj = NULL;
+ 	srjson_t *nj = NULL;
+ 	int ret;
+ 
+-	nj = srjson_GetObjectItem(jdoc, jdoc->root, "routes");
+-	if(nj==NULL || nj->type!=srjson_Array || nj->child==NULL) {
++	tj = srjson_GetObjectItem(jdoc, jdoc->root, "routes");
++	if(tj==NULL || tj->type!=srjson_Array || tj->child==NULL) {
+ 		LM_ERR("missing or invalid routes field\n");
+ 		goto error;
+ 	}
++	nj = tj->child;
+ 
+ 	ret = rtjson_init_serial(msg, jdoc, iavp);
+ 	if(ret<0)
+@@ -569,6 +577,7 @@ int rtjson_next_route(sip_msg_t *msg)
+ 	sr_xavp_t *javp = NULL;
+ 	sr_xavp_t *iavp = NULL;
+ 	srjson_doc_t tdoc;
++	srjson_t *tj = NULL;
+ 	srjson_t *nj = NULL;
+ 	str val;
+ 	str xname;
+@@ -612,11 +621,12 @@ int rtjson_next_route(sip_msg_t *msg)
+ 		goto error;
+ 	}
+ 
+-	nj = srjson_GetObjectItem(&tdoc, tdoc.root, "routes");
+-	if(nj==NULL || nj->type!=srjson_Array || nj->child==NULL) {
++	tj = srjson_GetObjectItem(&tdoc, tdoc.root, "routes");
++	if(tj==NULL || tj->type!=srjson_Array || tj->child==NULL) {
+ 		LM_ERR("missing or invalid routes field\n");
+ 		goto error;
+ 	}
++	nj = tj->child;
+ 
+ 	i = 0;
+ 	while(nj && i<iavp->val.v.i) {
+@@ -646,6 +656,7 @@ int rtjson_update_branch(sip_msg_t *msg)
+ 	sr_xavp_t *javp = NULL;
+ 	sr_xavp_t *iavp = NULL;
+ 	srjson_doc_t tdoc;
++	srjson_t *tj = NULL;
+ 	srjson_t *nj = NULL;
+ 	str val;
+ 	str xname;
+@@ -689,11 +700,12 @@ int rtjson_update_branch(sip_msg_t *msg)
+ 		goto error;
+ 	}
+ 
+-	nj = srjson_GetObjectItem(&tdoc, tdoc.root, "routes");
+-	if(nj==NULL || nj->type!=srjson_Array || nj->child==NULL) {
++	tj = srjson_GetObjectItem(&tdoc, tdoc.root, "routes");
++	if(tj==NULL || tj->type!=srjson_Array || tj->child==NULL) {
+ 		LM_ERR("missing or invalid routes field\n");
+ 		goto error;
+ 	}
++	nj = tj->child;
+ 
+ 	i = 0;
+ 	while(nj && i<iavp->val.v.i) {
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0020-evapi-don-t-print-the-message-after-relaying-to-evap.patch b/debian/patches/upstream/0020-evapi-don-t-print-the-message-after-relaying-to-evap.patch
new file mode 100644
index 0000000..d916d4e
--- /dev/null
+++ b/debian/patches/upstream/0020-evapi-don-t-print-the-message-after-relaying-to-evap.patch
@@ -0,0 +1,45 @@
+From 32243fd248a5d49b22ee597fe02ca95f58cab8a5 Mon Sep 17 00:00:00 2001
+From: Daniel-Constantin Mierla <miconda at gmail.com>
+Date: Tue, 23 Jun 2015 16:44:11 +0200
+Subject: [PATCH] evapi: don't print the message after relaying to evapi
+ dispatcher
+
+- the dispatcher process can consume it and frees the pointers
+
+(cherry picked from commit 57b75141542cdaa471dab00cfb4f7d8812d41824)
+---
+ modules/evapi/evapi_dispatch.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/modules/evapi/evapi_dispatch.c b/modules/evapi/evapi_dispatch.c
+index 3029d77..159d14e 100644
+--- a/modules/evapi/evapi_dispatch.c
++++ b/modules/evapi/evapi_dispatch.c
+@@ -534,8 +534,8 @@ int evapi_relay(str *evdata)
+ 	int sbsize;
+ 	str *sbuf;
+ 
+-	LM_DBG("relaying event data [%.*s]\n",
+-			evdata->len, evdata->s);
++	LM_DBG("relaying event data [%.*s] (%d)\n",
++			evdata->len, evdata->s, evdata->len);
+ 
+ 	sbsize = evdata->len;
+ 	sbuf = (str*)shm_malloc(sizeof(str) + ((sbsize+32) * sizeof(char)));
+@@ -560,12 +560,12 @@ int evapi_relay(str *evdata)
+ 		return -1;
+ 	}
+ 
++	LM_DBG("sending [%p] [%.*s] (%d)\n", sbuf, sbuf->len, sbuf->s, sbuf->len);
+ 	len = write(_evapi_notify_sockets[1], &sbuf, sizeof(str*));
+ 	if(len<=0) {
+ 		LM_ERR("failed to pass the pointer to evapi dispatcher\n");
+ 		return -1;
+ 	}
+-	LM_DBG("sent [%p] [%.*s] (%d)\n", sbuf, sbuf->len, sbuf->s, sbuf->len);
+ 	return 0;
+ }
+ 
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0021-rtjson-safety-check-for-branch-index-stored-interanl.patch b/debian/patches/upstream/0021-rtjson-safety-check-for-branch-index-stored-interanl.patch
new file mode 100644
index 0000000..aa2adc8
--- /dev/null
+++ b/debian/patches/upstream/0021-rtjson-safety-check-for-branch-index-stored-interanl.patch
@@ -0,0 +1,39 @@
+From 4b19b9223d73d7138a48e7b358a86f2504efa4f0 Mon Sep 17 00:00:00 2001
+From: Daniel-Constantin Mierla <miconda at gmail.com>
+Date: Tue, 23 Jun 2015 16:45:17 +0200
+Subject: [PATCH] rtjson: safety check for branch index stored interanlly in
+ xavp
+
+(cherry picked from commit 59389b288fd50369226681b309c0895de03d7b77)
+---
+ modules/rtjson/rtjson_routing.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/modules/rtjson/rtjson_routing.c b/modules/rtjson/rtjson_routing.c
+index c9ee5c3..bb59da5 100644
+--- a/modules/rtjson/rtjson_routing.c
++++ b/modules/rtjson/rtjson_routing.c
+@@ -677,6 +677,10 @@ int rtjson_update_branch(sip_msg_t *msg)
+ 		LM_WARN("no idx for routing\n");
+ 		return -1;
+ 	}
++	if(iavp->val.v.i<=0) {
++		LM_WARN("invalid branch idx for routing\n");
++		return -1;
++	}
+ 
+ 	srjson_InitDoc(&tdoc, NULL);
+ 
+@@ -708,7 +712,8 @@ int rtjson_update_branch(sip_msg_t *msg)
+ 	nj = tj->child;
+ 
+ 	i = 0;
+-	while(nj && i<iavp->val.v.i) {
++	/* stop at number of branches - 1 */
++	while(nj && i<iavp->val.v.i-1) {
+ 		nj = nj->next;
+ 		i++;
+ 	}
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0022-rtjson-more-documentation-about-json-routing-documen.patch b/debian/patches/upstream/0022-rtjson-more-documentation-about-json-routing-documen.patch
new file mode 100644
index 0000000..46000b9
--- /dev/null
+++ b/debian/patches/upstream/0022-rtjson-more-documentation-about-json-routing-documen.patch
@@ -0,0 +1,131 @@
+From a5bb99b4499b1ffde155cad9b2bc1377caf19009 Mon Sep 17 00:00:00 2001
+From: Daniel-Constantin Mierla <miconda at gmail.com>
+Date: Tue, 23 Jun 2015 23:21:35 +0200
+Subject: [PATCH] rtjson: more documentation about json routing document format
+
+(cherry picked from commit 5db8bec2fdfba911f7053e615cf156d76af5fa46)
+---
+ modules/rtjson/doc/rtjson_admin.xml | 86 ++++++++++++++++++++++++++++++++++++-
+ 1 file changed, 84 insertions(+), 2 deletions(-)
+
+diff --git a/modules/rtjson/doc/rtjson_admin.xml b/modules/rtjson/doc/rtjson_admin.xml
+index 4218e73..fedd40c 100644
+--- a/modules/rtjson/doc/rtjson_admin.xml
++++ b/modules/rtjson/doc/rtjson_admin.xml
+@@ -148,6 +148,8 @@ rtjson_push_routes();
+ ...
+ rtjson_init_routes("$var(json)");
+ rtjson_push_routes();
++t_on_failure("REROUTE");
++t_relay();
+ ...
+ failure_route[REROUTE] {
+ 	rtjson_next_route();
+@@ -174,6 +176,8 @@ failure_route[REROUTE] {
+ ...
+ rtjson_init_routes("$var(json)");
+ rtjson_push_routes();
++t_on_branch("OUTGOING");
++t_relay();
+ ...
+ branch_route[OUTGOING] {
+ 	rtjson_update_branch();
+@@ -191,7 +195,85 @@ branch_route[OUTGOING] {
+ 		The format of the JSON document containing routing information.
+ 	</para>
+ 	<para>
+-		Description of the fields: TBA.
++		Description of the fields in the JSON routing document:
++			<itemizedlist>
++			<listitem>
++			<para>
++				<emphasis>version</emphasis> - intended to enforce versioning
++				checks (not enforced yet), recommended to be set to "1.0".
++			</para>
++			</listitem>
++			<listitem>
++			<para>
++				<emphasis>routing</emphasis> - can be "serial" or "parallel",
++				corresponding to desired routing type: serial or parallel forking.
++			</para>
++			</listitem>
++			<listitem>
++			<para>
++				<emphasis>routes</emphasis> - an array with structures holding
++				the attributes for destinations. The attributes can be:
++				<itemizedlist>
++				<listitem>
++				<para>
++					<emphasis>uri</emphasis> - request URI
++				</para>
++				</listitem>
++				<listitem>
++				<para>
++					<emphasis>dst_uri</emphasis> - outbound proxy URI
++				</para>
++				</listitem>
++				<listitem>
++				<para>
++					<emphasis>path</emphasis> - Path URI vector
++				</para>
++				</listitem>
++				<listitem>
++				<para>
++					<emphasis>socket</emphasis> - local socket
++				</para>
++				</listitem>
++				<listitem>
++				<para>
++					<emphasis>headers</emphasis> - a structure with values for headers
++					From and To specified as display name and URI, plus extra
++					headers to be appended to SIP request. It requires uac module in
++					order to update From and To headers.
++					Set by rtjson_update_branch() only for serial routing.
++				</para>
++				</listitem>
++				<listitem>
++				<para>
++					<emphasis>branch_flags</emphasis> - branch flags.
++					Set by rtjson_update_branch() only for serial routing.
++				</para>
++				</listitem>
++				<listitem>
++				<para>
++					<emphasis>fr_timer</emphasis> - value for fr_timer parameter of
++					tm module.
++					Set by rtjson_update_branch() only for serial routing.
++				</para>
++				</listitem>
++				<listitem>
++				<para>
++					<emphasis>fr_inv_timer</emphasis> - value for fr_inv_timer parameter
++					of tm module.
++					Set by rtjson_update_branch() only for serial routing.
++				</para>
++				</listitem>
++				</itemizedlist>
++			</para>
++			</listitem>
++			</itemizedlist>
++	</para>
++	<para>
++		Other fields can appear in the JSON routing document, being ignored
++		by rtjson functions. They can be processed directly in the configuration
++		files using json or jansson modules. For example, the document can include
++		the transaction identification tuple (index,label) that can be used
++		to resume the execution of a suspended transaction.
+ 	</para>
+ 	<example>
+ 		<title>JSON Routing Structure</title>
+@@ -199,7 +281,7 @@ branch_route[OUTGOING] {
+ ...
+ {
+ 	"version": "1.0",
+-	"routing": "parallel",
++	"routing": "serial",
+ 	"routes": [
+ 		{
+ 			"uri": "sip:127.0.0.1:5080",
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0023-rtjson-updated-the-readme-content.patch b/debian/patches/upstream/0023-rtjson-updated-the-readme-content.patch
new file mode 100644
index 0000000..670a968
--- /dev/null
+++ b/debian/patches/upstream/0023-rtjson-updated-the-readme-content.patch
@@ -0,0 +1,77 @@
+From 119a878abf15ae2af524174a5948f9b8b4d87599 Mon Sep 17 00:00:00 2001
+From: Daniel-Constantin Mierla <miconda at gmail.com>
+Date: Wed, 24 Jun 2015 13:31:56 +0200
+Subject: [PATCH] rtjson: updated the readme content
+
+---
+ modules/rtjson/README | 35 +++++++++++++++++++++++++++++++++--
+ 1 file changed, 33 insertions(+), 2 deletions(-)
+
+diff --git a/modules/rtjson/README b/modules/rtjson/README
+index b1cc61d..b1c94e0 100644
+--- a/modules/rtjson/README
++++ b/modules/rtjson/README
+@@ -155,6 +155,8 @@ rtjson_push_routes();
+ ...
+ rtjson_init_routes("$var(json)");
+ rtjson_push_routes();
++t_on_failure("REROUTE");
++t_relay();
+ ...
+ failure_route[REROUTE] {
+         rtjson_next_route();
+@@ -172,6 +174,8 @@ failure_route[REROUTE] {
+ ...
+ rtjson_init_routes("$var(json)");
+ rtjson_push_routes();
++t_on_branch("OUTGOING");
++t_relay();
+ ...
+ branch_route[OUTGOING] {
+         rtjson_update_branch();
+@@ -182,13 +186,40 @@ branch_route[OUTGOING] {
+ 
+    The format of the JSON document containing routing information.
+ 
+-   Description of the fields: TBA.
++   Description of the fields in the JSON routing document:
++     * version - intended to enforce versioning checks (not enforced yet),
++       recommended to be set to "1.0".
++     * routing - can be "serial" or "parallel", corresponding to desired
++       routing type: serial or parallel forking.
++     * routes - an array with structures holding the attributes for
++       destinations. The attributes can be:
++          + uri - request URI
++          + dst_uri - outbound proxy URI
++          + path - Path URI vector
++          + socket - local socket
++          + headers - a structure with values for headers From and To
++            specified as display name and URI, plus extra headers to be
++            appended to SIP request. It requires uac module in order to
++            update From and To headers. Set by rtjson_update_branch() only
++            for serial routing.
++          + branch_flags - branch flags. Set by rtjson_update_branch()
++            only for serial routing.
++          + fr_timer - value for fr_timer parameter of tm module. Set by
++            rtjson_update_branch() only for serial routing.
++          + fr_inv_timer - value for fr_inv_timer parameter of tm module.
++            Set by rtjson_update_branch() only for serial routing.
++
++   Other fields can appear in the JSON routing document, being ignored by
++   rtjson functions. They can be processed directly in the configuration
++   files using json or jansson modules. For example, the document can
++   include the transaction identification tuple (index,label) that can be
++   used to resume the execution of a suspended transaction.
+ 
+    Example 1.6. JSON Routing Structure
+ ...
+ {
+         "version": "1.0",
+-        "routing": "parallel",
++        "routing": "serial",
+         "routes": [
+                 {
+                         "uri": "sip:127.0.0.1:5080",
+-- 
+2.1.4
+
diff --git a/debian/patches/upstream/0024-uac-refreshed-the-readme.patch b/debian/patches/upstream/0024-uac-refreshed-the-readme.patch
new file mode 100644
index 0000000..9b68f24
--- /dev/null
+++ b/debian/patches/upstream/0024-uac-refreshed-the-readme.patch
@@ -0,0 +1,325 @@
+From 66cbab29ef285ea71116f814108106412f41eae5 Mon Sep 17 00:00:00 2001
+From: Daniel-Constantin Mierla <miconda at gmail.com>
+Date: Wed, 24 Jun 2015 13:32:12 +0200
+Subject: [PATCH] uac: refreshed the readme
+
+---
+ modules/uac/README | 111 +++++++++++++++++++++++++++++++++--------------------
+ 1 file changed, 69 insertions(+), 42 deletions(-)
+
+diff --git a/modules/uac/README b/modules/uac/README
+index ef1a218..4e8b324 100644
+--- a/modules/uac/README
++++ b/modules/uac/README
+@@ -14,9 +14,9 @@ Ramona-Elena Modroiu
+ 
+    <ramona at rosdev.ro>
+ 
+-   Copyright © 2009-2010 asipto.com
++   Copyright � 2009-2010 asipto.com
+ 
+-   Copyright © 2005 Voice Sistem
++   Copyright � 2005 Voice Sistem
+      __________________________________________________________________
+ 
+    Table of Contents
+@@ -191,9 +191,12 @@ Chapter 1. Admin Guide
+ 
+    Known limitations in this version:
+      * Authentication does not support qop auth-int, just qop auth;
+-     * CSeq is not increased during authentication - the response may be
+-       rejected.
+-     * The “uac_replace_*” functions can only be run once on the same SIP
++     * CSeq is not increased automatically by uac_auth() during
++       authentication - the follow up request may be rejected. CSeq can be
++       increased when authenticating INVITE requests - dialog module has
++       to be used, with CSeq tracking feature enabled (see the readme of
++       dialog module).
++     * The "uac_replace_*" functions can only be run once on the same SIP
+        request. Try to save needed changes in a pseudovariable and apply
+        them once.
+ 
+@@ -207,9 +210,9 @@ Chapter 1. Admin Guide
+    The following modules must be loaded before this module:
+      * TM - Transaction Module
+      * RR - Record-Route Module, but only if restore mode for From: URI is
+-       set to “auto”.
++       set to "auto".
+      * Dialog Module, but only if restore mode for From: URI is set to
+-       “auto” and you want uac_replace_from or uac_replace_to to store the
++       "auto" and you want uac_replace_from or uac_replace_to to store the
+        values of the URIs as dialog variables.
+ 
+ 2.2. External Libraries or Applications
+@@ -242,7 +245,7 @@ Chapter 1. Admin Guide
+    Name of Record-Route header parameter that will be used to store an
+    encoded version of the original FROM URI.
+ 
+-   This parameter is optional, it's default value being “vsf”.
++   This parameter is optional, it's default value being "vsf".
+ 
+    Example 1.1. Set rr_from_store_param parameter
+ ...
+@@ -254,7 +257,7 @@ modparam("uac","rr_from_store_param","my_param")
+    Name of Record-Route header parameter that will be used to store
+    (encoded) the original TO URI.
+ 
+-   This parameter is optional, it's default value being “vst”.
++   This parameter is optional, it's default value being "vst".
+ 
+    Example 1.2. Set rr_to_store_param parameter
+ ...
+@@ -265,16 +268,16 @@ modparam("uac","rr_to_store_param","my_param")
+ 
+    There are 3 modes of restoring the original FROM URI and the original
+    TO URI:
+-     * “none” - no information about original URI is stored; restoration
++     * "none" - no information about original URI is stored; restoration
+        is not possible.
+-     * “manual” - all following replies will be restored, but not also the
++     * "manual" - all following replies will be restored, but not also the
+        sequential requests - this must be manually updated based on
+        original URI.
+-     * “auto” - all sequential requests and replies will be automatically
++     * "auto" - all sequential requests and replies will be automatically
+        updated based on stored original URI. For this option you have to
+-       set “modparam("rr", "append_fromtag", 1)”.
++       set "modparam("rr", "append_fromtag", 1)".
+ 
+-   This parameter is optional, it's default value being “auto”.
++   This parameter is optional, it's default value being "auto".
+ 
+    Example 1.3. Set restore_mode parameter
+ ...
+@@ -366,9 +369,9 @@ modparam("uac","credential","username:domain:password")
+    This can be used if the realm upstream will be using is not known in
+    advance.
+ 
+-   If you define it, you also need to define “auth_username_avp”
+-   (Section 3.10, “auth_username_avp (string)”) and “auth_username_avp”
+-   (Section 3.11, “auth_password_avp (string)”).
++   If you define it, you also need to define "auth_username_avp"
++   (Section 3.10, "auth_username_avp (string)") and "auth_username_avp"
++   (Section 3.11, "auth_password_avp (string)").
+ 
+    Example 1.9. Set auth_realm_avp parameter
+ ...
+@@ -380,9 +383,9 @@ modparam("uac","auth_realm_avp","$avp(i:10)")
+    The definition of an AVP that might contain the username to be used to
+    perform authentication.
+ 
+-   If you define it, you also need to define “auth_realm_avp”
+-   (Section 3.9, “auth_realm_avp (string)”) and “auth_username_avp”
+-   (Section 3.11, “auth_password_avp (string)”).
++   If you define it, you also need to define "auth_realm_avp"
++   (Section 3.9, "auth_realm_avp (string)") and "auth_username_avp"
++   (Section 3.11, "auth_password_avp (string)").
+ 
+    Example 1.10. Set auth_username_avp parameter
+ ...
+@@ -394,9 +397,9 @@ modparam("uac","auth_username_avp","$avp(i:11)")
+    The definition of an AVP that might contain the password to be used to
+    perform authentication.
+ 
+-   If you define it, you also need to define “auth_password_avp”
+-   (Section 3.11, “auth_password_avp (string)”) and “auth_username_avp”
+-   (Section 3.11, “auth_password_avp (string)”).
++   If you define it, you also need to define "auth_password_avp"
++   (Section 3.11, "auth_password_avp (string)") and "auth_username_avp"
++   (Section 3.11, "auth_password_avp (string)").
+ 
+    Example 1.11. Set auth_password_avp parameter
+ ...
+@@ -443,7 +446,7 @@ modparam("uac", "reg_retry_interval", 300)
+ 
+    DB table name to fetch user profiles for registration.
+ 
+-   This parameter is optional, it's default value being “uacreg”.
++   This parameter is optional, it's default value being "uacreg".
+ 
+    Example 1.15. Set reg_db_table parameter
+ ...
+@@ -475,7 +478,7 @@ modparam("uac", "reg_contact_addr", "192.168.1.2:5080")
+    4.9. uac_reg_lookup(uuid, dst)
+    4.10. uac_reg_request_to(user, mode)
+ 
+-4.1.  uac_replace_from(display,uri)
++4.1. uac_replace_from(display,uri)
+ 
+    Replace in FROM header the display name and the URI part.
+ 
+@@ -518,7 +521,7 @@ uac_replace_from("","sip:robin at gotham.org");
+ uac_replace_from("","");
+ ...
+ 
+-4.2.  uac_replace_from(uri)
++4.2. uac_replace_from(uri)
+ 
+    Replace in FROM header the URI part without altering the display name.
+ 
+@@ -531,7 +534,7 @@ uac_replace_from("","");
+ uac_replace_from("sip:batman at gotham.org");
+ ...
+ 
+-4.3.  uac_restore_from()
++4.3. uac_restore_from()
+ 
+    This function will check if the FROM URI was modified and will use the
+    information stored in header parameter to restore the original FROM URI
+@@ -544,7 +547,7 @@ uac_replace_from("sip:batman at gotham.org");
+ uac_restore_from();
+ ...
+ 
+-4.4.  uac_replace_to(display,uri)
++4.4. uac_replace_to(display,uri)
+ 
+    Replace in TO header the display name and the URI part.
+ 
+@@ -569,7 +572,7 @@ uac_replace_to("","sip:robin at gotham.org");
+ uac_replace_to("","");
+ ...
+ 
+-4.5.  uac_replace_to(uri)
++4.5. uac_replace_to(uri)
+ 
+    Replace in TO header the URI part without altering the display name.
+ 
+@@ -600,7 +603,7 @@ uac_replace_to("","");
+ uac_replace_to("sip:batman at gotham.org");
+ ...
+ 
+-4.6.  uac_restore_to()
++4.6. uac_restore_to()
+ 
+    This function will check if the TO URI was modified and will use the
+    information stored in header parameter to restore the original TO URI
+@@ -613,7 +616,7 @@ uac_replace_to("sip:batman at gotham.org");
+ uac_restore_to();
+ ...
+ 
+-4.7.  uac_auth()
++4.7. uac_auth()
+ 
+    This function can be called only from failure route and will build the
+    authentication response header and insert it into the request without
+@@ -623,10 +626,34 @@ uac_restore_to();
+ 
+    Example 1.23. uac_auth usage
+ ...
+-uac_auth();
++modparam("uac","auth_username_avp","$avp(auser)")
++modparam("uac","auth_password_avp","$avp(apass)")
++modparam("uac","auth_realm_avp","$avp(arealm)")
++
++request_route {
++   ...
++   if(is_method("INVITE")) {
++      t_on_failure("TRUNKAUTH");
++   }
++   ...
++}
++
++failure_route[TRUNKAUTH] {
++
++    if (t_is_canceled()) {
++        exit;
++    }
++    if(t_check_status("401|407")) {
++        $avp(auser) = "test";
++        $avp(apass) = "test";
++        uac_auth();
++        t_relay();
++        exit;
++    }
++}
+ ...
+ 
+-4.8.  uac_req_send()
++4.8. uac_req_send()
+ 
+    This function sends a SIP message from the configuration file. The
+    message is built out of $uac_req(...) pseudo-variable.
+@@ -644,7 +671,7 @@ $uac_req(callid)=$(mb{s.md5});
+ uac_req_send();
+ ...
+ 
+-4.9.  uac_reg_lookup(uuid, dst)
++4.9. uac_reg_lookup(uuid, dst)
+ 
+    This function sets the PV dst to SIP URI that correspond to uuid in uac
+    registations table. uuid and dst must be pseudo-variables.
+@@ -660,7 +687,7 @@ if(uac_reg_lookup("$rU", "$ru"))
+ }
+ ...
+ 
+-4.10.  uac_reg_request_to(user, mode)
++4.10. uac_reg_request_to(user, mode)
+ 
+    This function can be used to send an authenticated request to a remote
+    user in the uac registrations table. It sets the request-uri, dst-uri
+@@ -704,7 +731,7 @@ failure_route[REMOTE_AUTH] {
+ 
+    6.1. event_route[uac:reply]
+ 
+-6.1.  event_route[uac:reply]
++6.1. event_route[uac:reply]
+ 
+    Event route executed for the final reply to the request set with
+    uac_req_send(). The associated $uac_req(evroute) has to be set to 1.
+@@ -741,7 +768,7 @@ event_route[uac:reply] {
+    8.5. uac.reg_reload
+    8.6. uac.reg_refresh
+ 
+-8.1.  uac.reg_dump
++8.1. uac.reg_dump
+ 
+    Dump the content of remote registration table from memory.
+ 
+@@ -750,7 +777,7 @@ event_route[uac:reply] {
+    kamcmd uac.reg_dump
+ ...
+ 
+-8.2.  uac.reg_info
++8.2. uac.reg_info
+ 
+    Return the details of a remote registration record based on a filter.
+    The command has two parameter: attribute and value. The attribute can
+@@ -763,7 +790,7 @@ event_route[uac:reply] {
+    kamcmd uac.reg_info l_uuid account123
+ ...
+ 
+-8.3.  uac.reg_enable
++8.3. uac.reg_enable
+ 
+    Enable a remote registration record based on a filter. The command has
+    two parameter: attribute and value. The attribute can be: l_uuid,
+@@ -776,7 +803,7 @@ event_route[uac:reply] {
+    kamcmd uac.reg_enable l_uuid account123
+ ...
+ 
+-8.4.  uac.reg_disable
++8.4. uac.reg_disable
+ 
+    Disable a remote registration record based on a filter. The command has
+    two parameter: attribute and value. The attribute can be: l_uuid,
+@@ -789,7 +816,7 @@ event_route[uac:reply] {
+    kamcmd uac.reg_disable l_uuid account123
+ ...
+ 
+-8.5.  uac.reg_reload
++8.5. uac.reg_reload
+ 
+    Reload the records from database for remote registrations.
+ 
+@@ -798,7 +825,7 @@ event_route[uac:reply] {
+    kamcmd uac.reg_reload
+ ...
+ 
+-8.6.  uac.reg_refresh
++8.6. uac.reg_refresh
+ 
+    Load one record by l_uuid from database for remote registrations. If
+    the record exists in memory, its authentication password is updated,
+-- 
+2.1.4
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/kamailio.git



More information about the Pkg-voip-commits mailing list