[Pkg-voip-commits] [kamailio] 01/03: Imported changes from upstream/4.1.1

Victor Seva Lopez maniac-guest at moszumanska.debian.org
Wed Jan 15 13:03:09 UTC 2014


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

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

commit 1da4ff781d4bf17e578f7b8b673791d76d59e55f
Author: Victor Seva <linuxmaniac at torreviejawireless.org>
Date:   Wed Jan 15 13:05:49 2014 +0100

    Imported changes from upstream/4.1.1
---
 ChangeLog                                     | 475 +++++++++++++++++++++++++-
 Makefile.defs                                 |  34 +-
 Makefile.groups                               |  13 +-
 autover.h                                     |   4 +-
 dset.c                                        |   4 +-
 flags.c                                       |   2 +-
 lib/ims/ims_getters.c                         |  51 +--
 mem/q_malloc.c                                |   6 +
 modules/acc/README                            |   4 +-
 modules/acc/acc.c                             |   4 +-
 modules/acc/acc_logic.c                       |  27 +-
 modules/acc/doc/acc_admin.xml                 |   4 +-
 modules/auth_ephemeral/autheph_mod.c          |   5 +
 modules/auth_ephemeral/autheph_mod.h          |   5 +
 modules/auth_ephemeral/authorize.c            |   5 +
 modules/auth_ephemeral/authorize.h            |   5 +
 modules/auth_ephemeral/checks.c               |   5 +
 modules/auth_ephemeral/checks.h               |   5 +
 modules/avpops/avpops_parse.c                 |   8 +
 modules/ctl/fifo_server.c                     |   2 +-
 modules/db_flatstore/flat_rpc.c               |   2 +
 modules/dialog_ng/dlg_handlers.c              |   2 +-
 modules/htable/README                         |  40 +--
 modules/htable/doc/htable_admin.xml           |  32 +-
 modules/htable/htable.c                       |  32 +-
 modules/ims_registrar_pcscf/reg_mod.c         |   7 +-
 modules/ims_registrar_scscf/cxdx_sar.c        |  15 +-
 modules/maxfwd/maxfwd.c                       |   2 +-
 modules/outbound/api.h                        |   5 +
 modules/outbound/config.c                     |   5 +
 modules/outbound/config.h                     |   5 +
 modules/outbound/ob_mod.c                     |   5 +
 modules/permissions/README                    | 117 +++----
 modules/permissions/address.c                 |   4 +-
 modules/permissions/doc/permissions_admin.xml |   3 +-
 modules/permissions/hash.c                    |  20 ++
 modules/pike/pike_top.c                       |   5 +-
 modules/presence_dialoginfo/notify_body.c     |  85 ++++-
 modules/print/README                          |  13 +-
 modules/pua/send_subscribe.c                  |  12 +-
 modules/pv/pv_core.c                          |   4 +-
 modules/pv/pv_trans.c                         |   6 +-
 modules/ratelimit/ratelimit.c                 |   2 +-
 modules/registrar/save.c                      | 103 +++---
 modules/sdpops/sdpops_mod.c                   | 156 ++++-----
 modules/sipcapture/sipcapture.c               |  13 +-
 modules/snmpstats/Makefile                    |   2 +-
 modules/snmpstats/mibs/KAMAILIO-TC            |   7 +-
 modules/tls/tls_cfg.c                         |   3 +-
 modules/tls/tls_cfg.h                         |   3 +-
 modules/tls/tls_config.c                      |   4 +-
 modules/tls/tls_domain.c                      |   3 +-
 modules/tls/tls_domain.h                      |   3 +-
 modules/tls/tls_mod.c                         |   3 +-
 modules/tls/tls_rpc.c                         |  10 +-
 modules/tls/tls_server.c                      |  11 +-
 modules/tls/tls_util.c                        |  14 +-
 modules/tm/t_reply.c                          |  13 +-
 modules/tm/t_serial.c                         |  34 +-
 modules/tmrec/README                          |   8 +-
 modules/tmrec/doc/tmrec_admin.xml             |   7 +-
 modules/usrloc/ucontact.c                     |  48 ++-
 modules/usrloc/udomain.c                      |  10 +-
 modules/websocket/config.c                    |   5 +
 modules/websocket/config.h                    |   5 +
 modules/websocket/ws_conn.c                   |   5 +
 modules/websocket/ws_conn.h                   |   5 +
 modules/websocket/ws_frame.c                  |  12 +-
 modules/websocket/ws_frame.h                  |   5 +
 modules/websocket/ws_handshake.c              |   5 +
 modules/websocket/ws_handshake.h              |   5 +
 modules/websocket/ws_mod.c                    |   5 +
 modules/websocket/ws_mod.h                    |   5 +
 msg_translator.c                              |   2 +-
 parser/parse_fline.c                          |   2 +-
 pkg/kamailio/deb/debian/changelog             |   6 +
 pkg/kamailio/deb/jessie/changelog             |   6 +
 pkg/kamailio/deb/lucid/changelog              |   6 +
 pkg/kamailio/deb/precise/changelog            |   6 +
 pkg/kamailio/deb/squeeze/changelog            |   6 +
 pkg/kamailio/deb/wheezy/changelog             |   6 +
 pkg/kamailio/rpm/kamailio.spec-4.1            |   2 +-
 pkg/kamailio/rpm/kamailio.spec.CenOS          |   2 +-
 pkg/kamailio/rpm/kamailio.spec.SuSE           |   2 +-
 select_buf.c                                  |   2 +-
 85 files changed, 1230 insertions(+), 421 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index da203d2..8e8066b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,477 @@
-===================== 2013-XY-XY Version 4.1.0 Released =====================
+===================== 2014-01-09 Version 4.1.1 Released =====================
+
+===================== Changes Since Version 4.1.0 ===========================
+
+commit b9e86b9fd8f7102838b0012f6ebfecd55ef607be
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Thu Jan 9 15:59:01 2014 +0100
+
+    Makefile.defs: version set to 4.1.1
+
+commit 497d0c5ad34250106782bc9a424e872d341305b7
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Thu Jan 9 15:58:08 2014 +0100
+
+    pkg/deb: versio set to 4.1.1 in deb specs
+
+commit 1e5f78ae7934112e502a1573aa2490ea647b08d0
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Thu Jan 9 15:54:31 2014 +0100
+
+    pkg/rpm: versio set to 4.1.1 in rpm specs
+
+commit 32aacba6663f0836c8599c588d8d6d708af5afa3
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Wed Jan 8 19:06:19 2014 +0100
+
+    htable, permissions, print: regenerated readme files
+
+commit af04ad88d6db1b2e3cf7d9cd99906c83d58f4f9d
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Tue Jan 7 10:23:11 2014 +0100
+
+    permissions: fixed previous commit which used invalid variable
+    
+    - reported by Kelvin Chua
+    
+    (cherry picked from commit 34d9088d74cb8269960cc20912a675a67598e7d7)
+
+commit 11ff3de741b95fea003fa5e91ceb69df15fd0fd6
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Tue Jan 7 00:58:20 2014 +0100
+
+    presence_dialoginfo: handle all states to get most relevant xml
+    
+    - patch from FS#341
+    
+    (cherry picked from commit f845465eb96770e0c02c92ae862cdc94f561e29e)
+
+commit 9af6dbd51e3085d111c54b778b03d191a6a31060
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Tue Jan 7 00:10:34 2014 +0100
+
+    tls: the pointer of cfg structure
+    
+    - synchronize when updating the list of tls configs and their reference
+      count
+    - with parts from patch by Ding Ma, FS#380, contributed under BSD license
+    
+    (cherry picked from commit 208934d47ac1585d42029234267bcceab40ae218)
+
+commit b55c87afd5a02b8c6244e8557879da9a09e02c22
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Mon Jan 6 19:51:41 2014 +0100
+
+    permissions: note about peer tag mode that applies only for allow_trusted()
+    
+    (cherry picked from commit 15f8a92baf58ee70e837b3b7e7f208b1a2678a0a)
+
+commit 4ec0be8deaab21050015a3b7828a667f40c8f150
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Mon Jan 6 19:48:54 2014 +0100
+
+    permissions: set peer tag avp for allow_address_group()
+    
+    - also for allow_source_address_group()
+    - reported by Kelvin Chua
+    
+    (cherry picked from commit 0c67042fa629ee4744cfc31a15e571b7340b0881)
+
+commit 93f493645f424bc34a0e641f89ed08766a542de4
+Author: Alexandr Dubovikov <alexandr.dubovikov at gmail.com>
+Date:   Tue Dec 31 23:24:02 2013 +0100
+
+    modules/sipcapture:  Fixed bad timestamp in the raw socket mode
+    
+    HEPpy New Year!
+    
+    (cherry picked from commit cc34c8e2c1e0eeafa0088c2d159260e4b10652c9)
+
+commit 7552d77f3184777a0b12cdf3354013f2bc4f546d
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Fri Dec 27 23:31:41 2013 +0100
+
+    htable: added section id for functions and parameters
+    
+    (cherry picked from commit 0e0b8cd883718bb5d19999e800159add7714f69e)
+
+commit c00a33aa378d886b8e0d3a6370b9df2e3559b021
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Thu Dec 19 21:15:12 2013 +0100
+
+    acc: use r-uri winning branch even for local generated replies
+    
+    - it was only for received and relayed replies
+    - reported by Kelvin Chua
+    
+    (cherry picked from commit 81b9c83b2fa3bd32d502a1ae9014cc7d6747e710)
+
+commit d1c3ebe4ac3fdfab5d3360bff76e3c22561d95b1
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Fri Dec 6 19:03:08 2013 +0100
+
+    tls: removed unsigned int comparison with <0
+    
+    (cherry picked from commit 7d6dc390bac2b49615444bcbad74cd39f3c82302)
+
+commit 04778b76c3afa0090db421ec7258f443dc1f2899
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Fri Dec 6 18:54:52 2013 +0100
+
+    sipcapture: fixed clang compile warnings
+    
+    - extra parameters for sprintf() match format specifiers
+    
+    (cherry picked from commit b131f4402cf604bbe90123aa95a6cbc8412c2de0)
+
+commit 90f8cee3bf20d4ae3c89b08809de749b5176a084
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Fri Dec 6 18:34:49 2013 +0100
+
+    ratelimit: signed check for pipe number in rpc_set_queue()
+    
+    - rpc can reand signed value
+    
+    (cherry picked from commit ed034d4d9096d8c77269828c8efdafb26eac5372)
+
+commit b1bffbe734bf7718a5d5b61ba2e55801160c49e1
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Fri Dec 6 18:30:49 2013 +0100
+
+    pike: memset of address print buffer with proper size
+    
+    (cherry picked from commit d54eb083f59fb55ccbc79e49b5b3e05426bd3795)
+
+commit 7e35f56d3f3955e6e815cda80c4e7c21835ac24d
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Fri Dec 6 18:25:30 2013 +0100
+
+    permissions: signess warning fix
+    
+    (cherry picked from commit 26e04f2053c9f33333bbbf79af6897428a1d9a88)
+
+commit 5481307088c7fda489495a99a163a782d901b6e4
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Fri Dec 6 18:23:17 2013 +0100
+
+    maxforwards: use standard format instead of GNU old-style field designator
+    
+    (cherry picked from commit cd04947b0ccb1c861274483f458bfc7f4329accb)
+
+commit d7d84da459884897f4cc5b84fc19c266831e8fcb
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Fri Dec 6 18:20:16 2013 +0100
+
+    ctl: removed not needed extra paranthesis
+    
+    (cherry picked from commit efda774f6391f1e909a9967898c64fb25f53eeba)
+
+commit bb9df83f99523c58acae1d5278457ba6128966a7
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Fri Dec 6 18:18:48 2013 +0100
+
+    acc: strftime() returns 0 on error
+    
+    (cherry picked from commit 89262590e4d47e480fb4984f18e12b4e4edb4ca6)
+
+commit 7323998af0f1d71dbc22d699979e45fb512fa3aa
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Fri Dec 6 18:15:22 2013 +0100
+
+    pv: use int index for looking up flag index
+    
+    - some functions used for check may return negative on error
+    
+    (cherry picked from commit 30359b3cfce2ce909153e06b1954778c4eababa7)
+
+commit eab7927a930c9781603538d0b2ae4595b1e5c586
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Fri Dec 6 11:41:38 2013 +0100
+
+    snmpstats: use install-cfg target to deploy MIBs
+    
+    - existing target was no longer valid from v3.0
+    
+    (cherry picked from commit a8d0d9e9224c2e7399c95c533dff67a6303891d2)
+
+commit e53117a038961b912ebb95c8a07468f87c161db2
+Author: Carsten Bock <carsten at ng-voice.com>
+Date:   Wed Dec 11 13:47:57 2013 +0100
+
+    lib/ims: Replaced custom getter for P-Asserted-Identity with the Parser from Core
+    (cherry picked from commit af1734cea213b2a07c9d725fff158cd4899725d1)
+
+commit 723bf45840b02e70bcb1c7f9c11a2e64e4f303db
+Author: Carsten Bock <carsten at ng-voice.com>
+Date:   Mon Dec 9 20:07:12 2013 +0100
+
+    ims_registrar_pcscf: Bugfix: Properly handle the case, when we do not have a Asserted Identity
+    (cherry picked from commit 6b0bcff43c0b3c22f399211aeb7e9279f7c35814)
+
+commit bf0a544d135b029ad381746b380bb6f71c52aee7
+Author: Carsten Bock <carsten at ng-voice.com>
+Date:   Mon Dec 9 23:00:08 2013 +0100
+
+    Improved Free at cscf_get_service_route(), caused a reproducable crash
+    (cherry picked from commit caa9954d3c017ce741245d8f2b338158caf2270f)
+
+commit d6480f98aef45b8c569ef9edf90c6cf1604cc2f8
+Author: Carlos Ruiz Diaz <carlos.ruizdiaz at gmail.com>
+Date:   Wed Dec 18 15:28:39 2013 -0300
+
+    ims_registrar_scscf: fix crash caused by an uninitialized AVP
+    (cherry picked from commit 52d727dc249a88b31348b008045cc6071ab215a7)
+
+commit 2dd36bbae6f05ea0c980e58f247ac7e4f737f6a6
+Author: Victor Seva <linuxmaniac at torreviejawireless.org>
+Date:   Tue Jan 7 13:59:37 2014 +0100
+
+    usrloc: add user_col to the update contact query with instance
+    
+    (cherry picked from commit b393656c1113eb3630470389f142c53fbc085a90)
+
+commit f97723dd17d5bf9e0d2dd02982cfbca0146b7e99
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Mon Jan 6 23:11:33 2014 +0100
+
+    websocket: store sub protocol value for later use in encode_and_send_ws_frame()
+    
+    - the ws connection pointer can be set null if the browser closes the
+      connection
+    - patch by Vitaliy Aleksandrov, FS#364
+    
+    (cherry picked from commit 438eafc92ecf9d3b52f95c9952bc26b147fdf328)
+
+commit 3bfb9030dda5776744efc4f408557e044b4ebb75
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Mon Jan 6 22:52:11 2014 +0100
+
+    htable: free temporary slots used to reload hash table via rpc command
+    
+    - use system memory for temporary slots
+    
+    (cherry picked from commit f35c49085bdcc623ef45aa33a99af3265d3e6eeb)
+
+commit 2b450f573bdbcb88d0418a43a6707875f050eb33
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Mon Jan 6 22:46:48 2014 +0100
+
+    htable: use system malloc for temporary allocation of hash table realod slots
+    
+    - copes better with large number of slots, without a need to use shm
+    
+    (cherry picked from commit 13626ccffeaa7654c58576c3d1cc417dea865ca9)
+
+commit 75e904f2c2034075383b412e2dcb18c6fb01c7c3
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Thu Jan 2 13:22:28 2014 +0100
+
+    htable: use pkg for temporary hash table slots used for reload
+    
+    - free the temporary slots after reload, reported in FS#385
+    
+    (cherry picked from commit 53689b55632c6208e6326f1a5f4b3c45da216f43)
+
+commit 71463b06efa2997950aaf1ef088076258fe8a03a
+Author: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
+Date:   Sun Jan 5 18:16:04 2014 +0000
+
+    modules/websocket: added OpenSSL licensing exception
+    
+    (cherry picked from commit 661d7d3a6231713861a8a1236dd7d783113c2890)
+
+commit bdb3a86c4453790a91de5aa2320de5b5bb26ad5c
+Author: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
+Date:   Sun Jan 5 18:15:33 2014 +0000
+
+    modules/outbound: added OpenSSL licensing exception
+    
+    (cherry picked from commit 6741c47ad75806355cd7564d419df56acc68987b)
+
+commit fb364e0b29ce388574a61ebc4a428c559c411a2a
+Author: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
+Date:   Sun Jan 5 18:15:07 2014 +0000
+
+    modules/auth_ephemeral: added OpenSSL licensing exception
+    
+    (cherry picked from commit 99960be1d55df2ba4ca596c42c8e78e36dad3cf1)
+
+commit df0218611b8f27ccaa924b8f88560c2e81966823
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Thu Jan 2 11:25:56 2014 +0100
+
+    tmrec: updated the examples with tmrec duration
+    
+    - hint to read rfc2445 for duration format
+    
+    (cherry picked from commit 99d1170469c60206992c083f2ba0e9dc6b580d37)
+
+commit 2ac00f9083846b958da5396cb4f5a51527957324
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Fri Jan 3 10:11:26 2014 +0100
+
+    acc: regenerated README
+
+commit 4ac82cdf92ae6c0e2ff9c1238bfe28cfcefea99c
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Fri Jan 3 10:04:39 2014 +0100
+
+    acc: added note about MySQL InnoDB not supporting INSERT DELAYED
+    
+    - reported by Daniel Tryba
+    
+    (cherry picked from commit d26eff22c8a543c63a40cd7d91bb3c70f04aabc6)
+
+commit a4060da5e1fe1e64c224ff32d669a699a0d5cd1d
+Author: Juha Heinanen <jh at tutpro.com>
+Date:   Thu Dec 26 17:51:04 2013 +0200
+
+    modules/pua: added some missing lock releases
+    (cherry picked from commit 4eb338611e716e7a32f252acbae52bace6047a0a)
+
+commit 9e8c3f90e9467153b1e63a257ccdfb09adc4ecfd
+Author: Juha Heinanen <jh at tutpro.com>
+Date:   Thu Dec 19 16:21:25 2013 +0200
+
+    modules/pv: fixed params and param transformation
+    
+    - params need to be taken from sip_params field of sip_uri struct
+    (cherry picked from commit e54b3ec673cb32664a1e8de2e591190f22216724)
+
+commit d75bc3b69151a9d0391309e6bb51784f3b6b9a83
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Mon Dec 16 09:26:03 2013 +0100
+
+    db_flatstore: update timestamp for kamailio specific rpc rotate
+    
+    - do also in 'rotate' command, not only in 'k_rotate'
+    - from a patch by Abdelkader Allam
+    
+    (cherry picked from commit b15aefa31e45f1ad6a45b64905f9fae24e0f790e)
+
+commit 98ecf7d2c5753357fd2c1d1e8e72f425e4d48f9b
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Thu Dec 12 15:50:27 2013 +0100
+
+    snmpstats: fixe MIB file definitions
+    
+    - patch by takeshi, FS#363
+    
+    (cherry picked from commit ab75785aa707f10fdbccfb0531a0f35e820f5ebc)
+
+commit 5b869a7c1c584f2762610c5310e7281375c8103d
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Wed Dec 11 23:58:11 2013 +0100
+
+    tm: reset temporary linking of reply to transaction after branch failure route execution
+    
+    - reported by Robert Boisvert, FS#379
+    
+    (cherry picked from commit 0ebc983a422cd5ee4baa39bb3ef3bdbeeefd4571)
+
+commit e96a8b80fd253777e1d001ad778c5a62473ba010
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Wed Dec 11 23:01:41 2013 +0100
+
+    avpops: create a local pv structure when parameter is only flags
+    
+    - flags details are stored inside it
+    - fixes crash at startup reported by Kevin Scott Adams, FS#381
+    
+    (cherry picked from commit 3c88f1de9d647db8a14bae45af1fa3b34f74d4e6)
+
+commit eaeb74f5b6af5be13f88de93729998f13e9a06b7
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Wed Dec 11 09:49:52 2013 +0100
+
+    core: safety check for double free in q_malloc as in f_malloc
+    
+    (cherry picked from commit 943a5941f5ab479803fb30e19e9fa607f0f0fe14)
+
+commit 8df9d2336e7de2648288cf8ff6821e6820d88da9
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Mon Dec 9 10:06:15 2013 +0100
+
+    usrloc: avoid double locking when preloading attributes
+    
+    - reported by Seudin Kasumovic, FS#378
+    
+    (cherry picked from commit 888635bfa3719afeeea6f5f0d407aa862ceb34ac)
+
+commit efb2670ef03b69cb0ae26e7c9ac427c995ffbacf
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Mon Dec 9 10:05:11 2013 +0100
+
+    registrar: handle error case when deleting contact fails for unregister()
+    
+    - reformatted file
+    
+    (cherry picked from commit 67d218e29457ffd75148c8c520b26ec6f3f41719)
+
+commit f08c9545016da2bb974a1a8ded82c7aa25e9b704
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Sat Dec 7 13:35:45 2013 +0100
+
+    tm: safety checks inside t_next_contacts()
+    
+    (cherry picked from commit 21027d0c17558f3a1a4797049448cbbdfe50554f)
+
+commit 45ea3c6de26def1fa704f3e444bd37800ca09d9f
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Fri Dec 6 18:02:36 2013 +0100
+
+    usrloc: proper index for domain column when laoding extra attributes
+    
+    - patch by Seudin Kasumovic, FS#377
+    
+    (cherry picked from commit 551524cfc83b922c23e2d26f8cc5950df2a0af54)
+
+commit 90681624c54f0ec0b1259e205bcc0274316b4549
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Fri Dec 6 17:16:25 2013 +0100
+
+    core: fixed several clang compiler warnings
+    
+    (cherry picked from commit f0fb6f1e9fbb2f7f0c2bed5ba0d50a56cf5cf444)
+
+commit 5552d9f733a6423d4d940f9b93a6808de0800a1d
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Fri Dec 6 16:33:04 2013 +0100
+
+    Makefile.defs: compiler optimization level made variable
+    
+    - allow using -O3 for clang, which gives error on the former default -O9
+    
+    (cherry picked from commit 0713c0de50f8c2f4da2ee0ef33b0505c37792392)
+
+commit c56e66287d4456692bdad0f2454896ffd342cf0d
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Fri Dec 6 11:32:41 2013 +0100
+
+    sdpops: fix setting 0 instead of \r for sdp_get_line_startswith()
+    
+    - reported by Tuan Viet Nguyen
+    
+    (cherry picked from commit 041b12dc6e5ad88e981d44180436a90518cbcf0d)
+
+commit bd5335ac84bdb8854a7b7dab41136fe6abd01c9f
+Author: Daniel-Constantin Mierla <miconda at gmail.com>
+Date:   Thu Dec 5 09:58:38 2013 +0100
+
+    Makefile.groups: include gzcompress, sipt and mohqueue in packaging groups
+    
+    (cherry picked from commit 4dcbd1b1cbd4854607d286094c42d257623c548d)
+
+commit 7cc7bde95757ea8861c07acafeb528e09e0b52ac
+Author: Hugh Waite <hugh.waite at crocodile-rcs.com>
+Date:   Wed Dec 4 22:37:31 2013 +0000
+
+    dialog_ng: Fix segfault in dlg_new_dialog
+    
+    (cherry picked from commit 32f9c9187a9d886c46b24ee38173274da63febda)
+
+
+===================== 2013-12-04 Version 4.1.0 Released =====================
 
 ===================== Changes Since Version 4.0.0 ===========================
 
diff --git a/Makefile.defs b/Makefile.defs
index 480a3f8..9b2259a 100644
--- a/Makefile.defs
+++ b/Makefile.defs
@@ -164,7 +164,7 @@ INSTALL_FLAVOUR=$(FLAVOUR)
 # version number
 VERSION = 4
 PATCHLEVEL = 1
-SUBLEVEL =  0
+SUBLEVEL =  1
 EXTRAVERSION =
 
 # memory manager switcher
@@ -273,6 +273,7 @@ CC_LONGVER:=$(shell if  $(CC) -v 2>/dev/null; then \
 					else \
 						$(CC) -V 2>&1 ; \
 					fi )
+CC_OPT ?= -O9
 MKTAGS=ctags
 
 #find-out the compiler's name
@@ -334,6 +335,7 @@ ifneq (, $(findstring clang, $(CC_LONGVER)))
 	CC_FULLVER:=$(shell echo "$(CC_LONGVER)" | head -n 1 |  sed -e 's/.*version \([0-9]\.[0-9]\).*/\1/g' )
 	CC_SHORTVER:=$(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
 	CC_VER=$(CC) $(CC_FULLVER)
+	CC_OPT=-O3
 	MKDEP=$(CC) -MM 
 endif
 
@@ -887,7 +889,7 @@ ifeq	($(ARCH), i386)
 ifeq		($(CC_NAME), gcc) 
 				C_DEFS+=-DCC_GCC_LIKE_ASM
 				#common stuff
-				CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE)
+				CFLAGS=-g $(CC_OPT) -funroll-loops  -Wcast-align $(PROFILE)
 			#if gcc 4.5+ or 4.2+
 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
 $(call				set_if_empty,CPU,athlon64)
@@ -945,8 +947,8 @@ ifeq		($(CC_NAME), clang)
 $(call                          set_if_empty,CPU,athlon64)
 					C_DEFS+=-DCC_GCC_LIKE_ASM
                                         CFLAGS+=-m32
-                                                -O9      \
-                                                         \
+                                                $(CC_OPT) \
+                                                          \
                                                 -mtune=$(CPU)
                                         LDFLAGS+=-m32
 else			# CC_NAME, clang
@@ -972,7 +974,7 @@ ifeq	($(ARCH), x86_64)
 ifeq		($(CC_NAME), gcc)
 				C_DEFS+=-DCC_GCC_LIKE_ASM
 				#common stuff
-				CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE)
+				CFLAGS=-g $(CC_OPT) -funroll-loops  -Wcast-align $(PROFILE)
 			#if gcc 4.5+
 			# don't add '-mtune=$(CPU)' - gcc failure
 ifeq			($(CC_SHORTVER), 4.5+)
@@ -1041,7 +1043,7 @@ ifeq            ($(CC_NAME), clang)
 $(call                          set_if_empty,CPU,opteron)
 					C_DEFS+=-DCC_GCC_LIKE_ASM
                                         CFLAGS+=-m64 \
-                                                -O9        
+                                                $(CC_OPT)        
                                         LDFLAGS+=-m64
 else      	# CC_NAME, clang
 ifeq		($(CC_NAME), icc)
@@ -1066,7 +1068,7 @@ ifeq	($(ARCH), sparc64)
 ifeq		($(CC_NAME), gcc)
 				C_DEFS+=-DCC_GCC_LIKE_ASM -DSPARC64_MODE
 				#common stuff
-				CFLAGS=-g -O9 -funroll-loops  $(PROFILE) \
+				CFLAGS=-g $(CC_OPT) -funroll-loops  $(PROFILE) \
 					#-Wcast-align \
 					#-Wmissing-prototypes 
 				#if gcc 4.5+ or 4.2+
@@ -1157,7 +1159,7 @@ ifeq	($(ARCH), sparc)
 ifeq		($(CC_NAME), gcc)
 				C_DEFS+=-DCC_GCC_LIKE_ASM
 				#common stuff
-				CFLAGS=-g -O9 -funroll-loops  $(PROFILE) \
+				CFLAGS=-g $(CC_OPT) -funroll-loops  $(PROFILE) \
 					#-Wcast-align \
 					#-Wmissing-prototypes 
 				#if gcc 4.5+ or 4.2+
@@ -1222,7 +1224,7 @@ ifeq	($(ARCH), arm)
 ifeq		($(CC_NAME), gcc)
 				C_DEFS+=-DCC_GCC_LIKE_ASM
 				#common stuff
-				CFLAGS=-marm -march=armv5t -O9 -funroll-loops -fsigned-char $(PROFILE)
+				CFLAGS=-marm -march=armv5t $(CC_OPT) -funroll-loops -fsigned-char $(PROFILE)
 			#if gcc 4.5+ or 4.2+
 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
 					CFLAGS+= -ftree-vectorize -fno-strict-overflow
@@ -1270,7 +1272,7 @@ ifeq	($(ARCH), arm6)
 ifeq		($(CC_NAME), gcc)
 				C_DEFS+=-DCC_GCC_LIKE_ASM
 				#common stuff
-				CFLAGS=-march=armv6 -O9 -funroll-loops -fsigned-char \
+				CFLAGS=-march=armv6 $(CC_OPT) -funroll-loops -fsigned-char \
 						$(PROFILE)
 			#if gcc 4.5+ or 4.2+
 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
@@ -1317,7 +1319,7 @@ ifeq	($(ARCH), mips)
 ifeq		($(CC_NAME), gcc)
 				C_DEFS+=-DCC_GCC_LIKE_ASM
 				#common stuff
-				CFLAGS=-O9 -funroll-loops  $(PROFILE)
+				CFLAGS=$(CC_OPT) -funroll-loops  $(PROFILE)
 			#if gcc 4.5+ or 4.2+
 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
 					CFLAGS+=-march=r3000 -minline-all-stringops \
@@ -1364,7 +1366,7 @@ ifeq	($(ARCH), mips2)
 ifeq		($(CC_NAME), gcc)
 				C_DEFS+=-DCC_GCC_LIKE_ASM
 				#common stuff
-				CFLAGS= -mips2 -O9 -funroll-loops $(PROFILE)
+				CFLAGS= -mips2 $(CC_OPT) -funroll-loops $(PROFILE)
 			#if gcc 4.5+ or 4.2+
 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
 					CFLAGS+=-minline-all-stringops -ftree-vectorize \
@@ -1409,7 +1411,7 @@ ifeq	($(ARCH), mips64)
 ifeq		($(CC_NAME), gcc)
 				C_DEFS+=-DCC_GCC_LIKE_ASM
 				#common stuff
-				CFLAGS= -mips64 -O9 -funroll-loops $(PROFILE)
+				CFLAGS= -mips64 $(CC_OPT) -funroll-loops $(PROFILE)
 			#if gcc 4.5+ or 4.2+
 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
 					CFLAGS+=-minline-all-stringops -ftree-vectorize \
@@ -1454,7 +1456,7 @@ ifeq	($(ARCH), alpha)
 ifeq		($(CC_NAME), gcc)
 				C_DEFS+=-DCC_GCC_LIKE_ASM
 				#common stuff
-				CFLAGS= -O9 -funroll-loops $(PROFILE)
+				CFLAGS= $(CC_OPT) -funroll-loops $(PROFILE)
 			#if gcc 4.5 or 4.2+
 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
 					CFLAGS+= -fno-strict-overflow
@@ -1500,7 +1502,7 @@ ifeq	($(ARCH), ppc)
 ifeq		($(CC_NAME), gcc)
 				C_DEFS+=-DCC_GCC_LIKE_ASM
 				#common stuff
-				CFLAGS= -O9 -funroll-loops -fsigned-char $(PROFILE)
+				CFLAGS= $(CC_OPT) -funroll-loops -fsigned-char $(PROFILE)
 			#if gcc 4.5+ or 4.2+
 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
 $(call				set_if_empty,CPU,powerpc)
@@ -1549,7 +1551,7 @@ ifeq	($(ARCH), ppc64)
 ifeq		($(CC_NAME), gcc)
 				C_DEFS+=-DCC_GCC_LIKE_ASM
 				#common stuff
-				CFLAGS= -O9 -funroll-loops -fsigned-char $(PROFILE)
+				CFLAGS= $(CC_OPT) -funroll-loops -fsigned-char $(PROFILE)
 			#if gcc 4.5+ or 4.2+
 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
 $(call				set_if_empty,CPU,powerpc64)
diff --git a/Makefile.groups b/Makefile.groups
index d1cad86..30f2f17 100644
--- a/Makefile.groups
+++ b/Makefile.groups
@@ -13,7 +13,7 @@ mod_list_basic=async auth benchmark blst cfg_rpc cfgutils corex counters \
 				   mediaproxy mi_datagram mi_fifo mi_rpc mqueue \
 				   nat_traversal nathelper path pike pv ratelimit rr rtimer \
 				   rtpproxy sanity sdpops siputils sl statistics textops \
-				   textopsx tm tmx topoh xlog rtpproxy-ng stun
+				   textopsx tm tmx topoh xlog rtpproxy-ng stun sipt
 
 # - extra used modules, with no extra dependency
 mod_list_extra=avp auth_diameter call_control cnxcc dmq domainpolicy msrp pdb \
@@ -23,7 +23,7 @@ mod_list_extra=avp auth_diameter call_control cnxcc dmq domainpolicy msrp pdb \
 # - common modules depending on database
 mod_list_db=acc alias_db auth_db avpops cfg_db db_text db_flatstore \
 			  db_cluster dialog dispatcher domain drouting group \
-			  htable imc matrix msilo mtree p_usrloc pdt permissions \
+			  htable imc matrix mohqueue msilo mtree p_usrloc pdt permissions \
 			  pipelimit prefix_route registrar sipcapture siptrace speeddial \
 			  sqlops uac uri_db userblacklist usrloc
 
@@ -154,6 +154,9 @@ mod_list_java=app_java
 # - modules depending on iptables library
 mod_list_iptrtpproxy=iptrtpproxy
 
+# - modules depending on gzip library
+mod_list_gzcompress=gzcompress
+
 # - all modules
 mod_list_all=$(sort $(mod_list_basic) $(mod_list_extra) \
 			   $(mod_list_db) $(mod_list_dbuid) \
@@ -175,7 +178,8 @@ mod_list_all=$(sort $(mod_list_basic) $(mod_list_extra) \
 			   $(mod_list_iptrtpproxy) $(mod_list_mi_xmlrpc) \
 			   $(mod_list_outbound) $(mod_list_osp) \
 			   $(mod_list_java) $(mod_list_dnssec) \
-			   $(mod_list_sctp) $(mod_list_autheph))
+			   $(mod_list_sctp) $(mod_list_autheph) \
+			   $(mod_list_gzcompress))
 
 
 
@@ -333,6 +337,9 @@ module_group_ksctp=$(mod_list_sctp)
 # pkg auth_ephemeral module
 module_group_kautheph=$(mod_list_autheph)
 
+# pkg gzcompress module
+module_group_kgzcompress=$(mod_list_gzcompress)
+
 # list of static modules
 #
 static_modules:=
diff --git a/autover.h b/autover.h
index 3314601..103957c 100644
--- a/autover.h
+++ b/autover.h
@@ -2,6 +2,6 @@
  * DO NOT EDIT IT
  */
 
-#define REPO_VER "350d2e"
-#define REPO_HASH "350d2e"
+#define REPO_VER "d6ffa1"
+#define REPO_HASH "d6ffa1"
 #define REPO_STATE ""
diff --git a/dset.c b/dset.c
index 13b000b..4b886bd 100644
--- a/dset.c
+++ b/dset.c
@@ -90,7 +90,7 @@ branch_t *get_sip_branch(int idx)
 		return NULL;
 	if(idx<0)
 	{
-		if(nr_branches + idx >= 0)
+		if((int)nr_branches + idx >= 0)
 			return &branches[nr_branches+idx];
 		return NULL;
 	}
@@ -109,7 +109,7 @@ int drop_sip_branch(int idx)
 {
 	if(nr_branches==0 || idx>=nr_branches)
 		return 0;
-	if(idx<0 && nr_branches+idx<0)
+	if(idx<0 && (int)nr_branches+idx<0)
 		return 0;
 	/* last branch */
 	if(idx==nr_branches-1)
diff --git a/flags.c b/flags.c
index 1523d0b..becb569 100644
--- a/flags.c
+++ b/flags.c
@@ -74,7 +74,7 @@ int flag_in_range( flag_t flag ) {
 			flag, MAX_FLAG );
 		return 0;
 	}
-	if (flag<0) {
+	if ((int)flag<0) {
 		LOG(L_ERR, "ERROR: message flag (%d) must be in range %d..%d\n",
 			flag, 0, MAX_FLAG );
 		return 0;
diff --git a/lib/ims/ims_getters.c b/lib/ims/ims_getters.c
index 05450f1..a41cd31 100644
--- a/lib/ims/ims_getters.c
+++ b/lib/ims/ims_getters.c
@@ -56,6 +56,7 @@
 #include "../../parser/parse_from.h"
 #include "../../parser/parse_content.h"
 #include "ims_getters.h"
+#include "../../parser/parse_ppi_pai.h"
 
 
 /**
@@ -389,45 +390,13 @@ str s_asserted_identity={"P-Asserted-Identity",19};
  */
 str cscf_get_asserted_identity(struct sip_msg *msg)
 {
-	name_addr_t id;
-	struct hdr_field *h;
-	rr_t *r;
-	memset(&id,0,sizeof(name_addr_t));
-	if (!msg) return id.uri;
-	if (parse_headers(msg, HDR_EOH_F, 0)<0) {
-		return id.uri;
-	}
-	h = msg->headers;
-	while(h)
-	{
-		if (h->name.len == s_asserted_identity.len  &&
-				strncasecmp(h->name.s,s_asserted_identity.s,s_asserted_identity.len)==0)
-		{
-			if (parse_rr(h)<0){
-				//This might be an old client
-				LM_CRIT("WARN:cscf_get_asserted_identity: P-Asserted-Identity header must contain a Nameaddr!!! Fix the client!\n");
-				id.name.s = h->body.s;
-				id.name.len = 0;
-				id.len = h->body.len;
-				id.uri = h->body;
-				while(id.uri.len && (id.uri.s[0]==' ' || id.uri.s[0]=='\t' || id.uri.s[0]=='<')){
-					id.uri.s = id.uri.s+1;
-					id.uri.len --;
-				}
-				while(id.uri.len && (id.uri.s[id.uri.len-1]==' ' || id.uri.s[id.uri.len-1]=='\t' || id.uri.s[id.uri.len-1]=='>')){
-					id.uri.len--;
-				}
-				return id.uri;	
-			}
-			r = (rr_t*) h->parsed;
-			id = r->nameaddr; 
-			free_rr(&r);
-			h->parsed=r;
-			return id.uri;
-		}
-		h = h->next;
+	str uri = {0,0};
+	if (!msg) return uri;
+	if((parse_pai_header(msg) == 0) && (msg->pai) && (msg->pai->parsed)) {
+		to_body_t *pai = get_pai(msg)->id;
+		return pai->uri;
 	}
-	return id.uri;
+	return uri;
 }
 
 static str phone_context_s={";phone-context=",15};
@@ -1361,14 +1330,16 @@ str* cscf_get_service_route(struct sip_msg *msg, int *size, int is_shm) {
 		h = h->next;
 	}
 	if (is_shm) {
-		while (h)
+		h = msg->headers;
+		while (h) {
 			if (h->name.len == 13
 					&& strncasecmp(h->name.s, "Service-Route", 13) == 0) {
 				h->parsed = 0;
 				r = (rr_t*) h->parsed;
 				free_rr(&r);
 			}
-		h = h->next;
+			h = h->next;
+		}
 	}
 
 	return x;
diff --git a/mem/q_malloc.c b/mem/q_malloc.c
index 50acab9..8c36d03 100644
--- a/mem/q_malloc.c
+++ b/mem/q_malloc.c
@@ -473,6 +473,12 @@ void qm_free(struct qm_block* qm, void* p)
 	MDBG("qm_free: freeing frag. %p alloc'ed from %s: %s(%ld)\n",
 			f, f->file, f->func, f->line);
 #endif
+	if (unlikely(f->u.is_free)){
+		LM_INFO("freeing a free fragment (%p/%p) - ignore\n",
+				f, p);
+		return;
+	}
+
 	size=f->size;
 	qm->used-=size;
 	qm->real_used-=size;
diff --git a/modules/acc/README b/modules/acc/README
index f6b1c5c..7a6361c 100644
--- a/modules/acc/README
+++ b/modules/acc/README
@@ -1109,7 +1109,9 @@ modparam("acc", "db_extra", "ct=$hdr(Content-type); email=$avp(s:email)")
 
    If set to 1, use INSERT DELAYED to add records to accounting tables
    when the DB driver has support for it. If no INSERT DELAYED support is
-   offered by DB driver, then standard INSERT is used.
+   offered by DB driver, then standard INSERT is used. Beware that MySQL
+   InnoDB engine doesn't support INSERT DELAYED, thus be sure the acc
+   tables are defined with different type (e.g., MyISAM).
 
    Default value is 0 (no INSERT DELAYED).
 
diff --git a/modules/acc/acc.c b/modules/acc/acc.c
index efaebc0..c44a9e4 100644
--- a/modules/acc/acc.c
+++ b/modules/acc/acc.c
@@ -301,7 +301,7 @@ int acc_log_request( struct sip_msg *rq)
 			t = gmtime(&acc_env.ts);
 		}
 		if(strftime(acc_time_format_buf, ACC_TIME_FORMAT_SIZE,
-					acc_time_format, t)<0) {
+					acc_time_format, t)<=0) {
 			acc_time_format_buf[0] = '\0';
 		}
 		LM_GEN2(log_facility, log_level, "%.*stimestamp=%lu;%s=%s%s",
@@ -463,7 +463,7 @@ int acc_db_request( struct sip_msg *rq)
 			t = gmtime(&acc_env.ts);
 		}
 		if(strftime(acc_time_format_buf, ACC_TIME_FORMAT_SIZE,
-					acc_time_format, t)<0) {
+					acc_time_format, t)<=0) {
 			acc_time_format_buf[0] = '\0';
 		}
 		VAL_STRING(db_vals+(m++)) = acc_time_format_buf;
diff --git a/modules/acc/acc_logic.c b/modules/acc/acc_logic.c
index 50278fb..18437fc 100644
--- a/modules/acc/acc_logic.c
+++ b/modules/acc/acc_logic.c
@@ -344,11 +344,20 @@ static inline void on_missed(struct cell *t, struct sip_msg *req,
 {
 	str new_uri_bk = {0, 0};
 	int flags_to_reset = 0;
+	int br = -1;
 
-	/* set as new_uri the last branch */
+	/* get winning branch index, if set */
 	if (t->relayed_reply_branch>=0) {
+		br = t->relayed_reply_branch;
+	} else {
+		if(code>=300) {
+			br = tmb.t_get_picked_branch();
+		}
+	}
+	/* set as new_uri the one from selected branch */
+	if (br>=0) {
 		new_uri_bk = req->new_uri;
-		req->new_uri = t->uac[t->relayed_reply_branch].uri;
+		req->new_uri = t->uac[br].uri;
 		req->parsed_uri_ok = 0;
 	} else {
 		new_uri_bk.len = -1;
@@ -416,6 +425,7 @@ static inline void acc_onreply( struct cell* t, struct sip_msg *req,
 											struct sip_msg *reply, int code)
 {
 	str new_uri_bk;
+	int br = -1;
 
 	/* acc_onreply is bound to TMCB_REPLY which may be called
 	   from _reply, like when FR hits; we should not miss this
@@ -426,10 +436,19 @@ static inline void acc_onreply( struct cell* t, struct sip_msg *req,
 	if (!should_acc_reply(req, reply, code))
 		return;
 
-	/* for reply processing, set as new_uri the winning branch */
+	/* get winning branch index, if set */
 	if (t->relayed_reply_branch>=0) {
+		br = t->relayed_reply_branch;
+	} else {
+		if(code>=300) {
+			br = tmb.t_get_picked_branch();
+		}
+	}
+
+	/* for reply processing, set as new_uri the one from selected branch */
+	if (br>=0) {
 		new_uri_bk = req->new_uri;
-		req->new_uri = t->uac[t->relayed_reply_branch].uri;
+		req->new_uri = t->uac[br].uri;
 		req->parsed_uri_ok = 0;
 	} else {
 		new_uri_bk.len = -1;
diff --git a/modules/acc/doc/acc_admin.xml b/modules/acc/doc/acc_admin.xml
index 97858be..33ca1f8 100644
--- a/modules/acc/doc/acc_admin.xml
+++ b/modules/acc/doc/acc_admin.xml
@@ -1093,7 +1093,9 @@ modparam("acc", "db_extra", "ct=$hdr(Content-type); email=$avp(s:email)")
 		<para>
 		If set to 1, use INSERT DELAYED to add records to accounting tables
 		when the DB driver has support for it. If no INSERT DELAYED support
-		is offered by DB driver, then standard INSERT is used.
+		is offered by DB driver, then standard INSERT is used. Beware that
+		MySQL InnoDB engine doesn't support INSERT DELAYED, thus be sure
+		the acc tables are defined with different type (e.g., MyISAM).
 		</para>
 		<para>
 		Default value is 0 (no INSERT DELAYED).
diff --git a/modules/auth_ephemeral/autheph_mod.c b/modules/auth_ephemeral/autheph_mod.c
index 8e72fba..fb59e56 100644
--- a/modules/auth_ephemeral/autheph_mod.c
+++ b/modules/auth_ephemeral/autheph_mod.c
@@ -19,6 +19,11 @@
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Exception: permission to copy, modify, propagate, and distribute a work
+ * formed by combining OpenSSL toolkit software and the code in this file,
+ * such as linking with software components and libraries released under
+ * OpenSSL project license.
+ *
  */
 #include "../../dprint.h"
 #include "../../locking.h"
diff --git a/modules/auth_ephemeral/autheph_mod.h b/modules/auth_ephemeral/autheph_mod.h
index 62bc808..3ad2356 100644
--- a/modules/auth_ephemeral/autheph_mod.h
+++ b/modules/auth_ephemeral/autheph_mod.h
@@ -19,6 +19,11 @@
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Exception: permission to copy, modify, propagate, and distribute a work
+ * formed by combining OpenSSL toolkit software and the code in this file,
+ * such as linking with software components and libraries released under
+ * OpenSSL project license.
+ *
  */
 #ifndef AUTHEPH_MOD_H
 #define AUTHEPH_MOD_H
diff --git a/modules/auth_ephemeral/authorize.c b/modules/auth_ephemeral/authorize.c
index a09a9f8..454ecac 100644
--- a/modules/auth_ephemeral/authorize.c
+++ b/modules/auth_ephemeral/authorize.c
@@ -19,6 +19,11 @@
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Exception: permission to copy, modify, propagate, and distribute a work
+ * formed by combining OpenSSL toolkit software and the code in this file,
+ * such as linking with software components and libraries released under
+ * OpenSSL project license.
+ *
  */
 #include <openssl/hmac.h>
 #include <openssl/sha.h>
diff --git a/modules/auth_ephemeral/authorize.h b/modules/auth_ephemeral/authorize.h
index 8ce9331..0a7bb91 100644
--- a/modules/auth_ephemeral/authorize.h
+++ b/modules/auth_ephemeral/authorize.h
@@ -19,6 +19,11 @@
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Exception: permission to copy, modify, propagate, and distribute a work
+ * formed by combining OpenSSL toolkit software and the code in this file,
+ * such as linking with software components and libraries released under
+ * OpenSSL project license.
+ *
  */
 #ifndef AUTHORIZE_H
 #define AUTHORIZE_H
diff --git a/modules/auth_ephemeral/checks.c b/modules/auth_ephemeral/checks.c
index 447e997..dacec11 100644
--- a/modules/auth_ephemeral/checks.c
+++ b/modules/auth_ephemeral/checks.c
@@ -19,6 +19,11 @@
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Exception: permission to copy, modify, propagate, and distribute a work
+ * formed by combining OpenSSL toolkit software and the code in this file,
+ * such as linking with software components and libraries released under
+ * OpenSSL project license.
+ *
  */
 #include "../../dprint.h"
 #include "../../mod_fix.h"
diff --git a/modules/auth_ephemeral/checks.h b/modules/auth_ephemeral/checks.h
index 27cb7fe..ee23c7e 100644
--- a/modules/auth_ephemeral/checks.h
+++ b/modules/auth_ephemeral/checks.h
@@ -19,6 +19,11 @@
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Exception: permission to copy, modify, propagate, and distribute a work
+ * formed by combining OpenSSL toolkit software and the code in this file,
+ * such as linking with software components and libraries released under
+ * OpenSSL project license.
+ *
  */
 #ifndef CHECKS_H
 #define CHECKS_H
diff --git a/modules/avpops/avpops_parse.c b/modules/avpops/avpops_parse.c
index 3a16f18..3a6c5ec 100644
--- a/modules/avpops/avpops_parse.c
+++ b/modules/avpops/avpops_parse.c
@@ -129,6 +129,14 @@ int parse_avp_db(char *s, struct db_param *dbp, int allow_scheme)
 				goto error;
 			}
 		}
+		/* no pv to lookup, create one to store flags details */
+		dbp->a.u.sval = (pv_spec_t*)pkg_malloc(sizeof(pv_spec_t));
+		if(dbp->a.u.sval==NULL)
+		{
+			LM_ERR("no more pkg\n");
+			goto error;
+		}
+		memset(dbp->a.u.sval, 0, sizeof(pv_spec_t));
 		dbp->a.u.sval->pvp.pvn.u.isname.type |= (flags<<8)&0xff00;
 		dbp->a.type = AVPOPS_VAL_NONE;
 	} else {
diff --git a/modules/ctl/fifo_server.c b/modules/ctl/fifo_server.c
index c72dcbe..d5f849f 100644
--- a/modules/ctl/fifo_server.c
+++ b/modules/ctl/fifo_server.c
@@ -757,7 +757,7 @@ process:
 			ERR("File separator missing\n");
 			goto consume;
 		}
-		if ((file_sep == context.method)) {
+		if (file_sep == context.method) {
 			ERR("Empty command\n");
 			goto consume;
 		}
diff --git a/modules/db_flatstore/flat_rpc.c b/modules/db_flatstore/flat_rpc.c
index 2fe0d0f..5145d83 100644
--- a/modules/db_flatstore/flat_rpc.c
+++ b/modules/db_flatstore/flat_rpc.c
@@ -32,6 +32,7 @@
 
 #include "flat_rpc.h"
 #include "flatstore_mod.h"
+#include "km_flatstore_mod.h"
 
 #include <time.h>
 
@@ -43,6 +44,7 @@
  */
 static void rotate(rpc_t* rpc, void* c)
 {
+	*km_flat_rotate = time(0);
 	*flat_rotate = time(0);
 }
 
diff --git a/modules/dialog_ng/dlg_handlers.c b/modules/dialog_ng/dlg_handlers.c
index 262e923..93a00c7 100644
--- a/modules/dialog_ng/dlg_handlers.c
+++ b/modules/dialog_ng/dlg_handlers.c
@@ -905,9 +905,9 @@ int dlg_new_dialog(struct sip_msg *req, struct cell *t, const int run_initial_cb
     if (populate_leg_info(dlg, req, t, DLG_CALLER_LEG,
             &(get_from(req)->tag_value)) != 0) {
         LM_ERR("could not add further info to the dialog\n");
-        shm_free(dlg);
         lock_destroy(dlg->dlg_out_entries_lock);
         lock_dealloc(dlg->dlg_out_entries_lock);
+        shm_free(dlg);
         return -1;
     }
 
diff --git a/modules/htable/README b/modules/htable/README
index 31db1bc..5369a98 100644
--- a/modules/htable/README
+++ b/modules/htable/README
@@ -17,7 +17,7 @@ Alex Balashov
 
    <abalashov at evaristesys.com>
 
-   Copyright © 2008-2011 http://www.asipto.com
+   Copyright � 2008-2011 http://www.asipto.com
      __________________________________________________________________
 
    Table of Contents
@@ -178,7 +178,7 @@ Chapter 1. Admin Guide
    You can read more about hash tables at:
    http://en.wikipedia.org/wiki/Hash_table.
 
-   The “name” can be a static string or can include pseudo- variables that
+   The "name" can be a static string or can include pseudo- variables that
    will be replaced at runtime.
 
    Example 1.1. Accessing $sht(htname=>key)
@@ -201,7 +201,7 @@ $sht(a=>$ci::srcip) = $si;
    the failed authentications per user and one for storing the time of
    last authentication attempt. To ensure unique name per user, the hash
    table uses a combination of authentication username and text
-   “::auth_count” and “::last_auth”.
+   "::auth_count" and "::last_auth".
 
    Example 1.2. Dictionary attack limitation
 ...
@@ -495,7 +495,7 @@ modparam("htable", "enable_dmq", 1)
    4.4. sht_lock(htable=>key)
    4.5. sht_unlock(htable=>key)
 
-4.1.  sht_print()
+4.1. sht_print()
 
    Dump content of hash table to L_ERR log level. Intended for debug
    purposes.
@@ -508,7 +508,7 @@ modparam("htable", "enable_dmq", 1)
 sht_print();
 ...
 
-4.2.  sht_rm_name_re(htable=>regexp)
+4.2. sht_rm_name_re(htable=>regexp)
 
    Delete all entries in the htable that match the name against regular
    expression.
@@ -521,7 +521,7 @@ sht_print();
 sht_rm_name_re("ha=>.*");
 ...
 
-4.3.  sht_rm_value_re(htable=>regexp)
+4.3. sht_rm_value_re(htable=>regexp)
 
    Delete all entries in the htable that match the value against regular
    expression.
@@ -534,7 +534,7 @@ sht_rm_name_re("ha=>.*");
 sht_rm_value_re("ha=>.*");
 ...
 
-4.4.  sht_lock(htable=>key)
+4.4. sht_lock(htable=>key)
 
    Lock the slot in htable corespoding to the key item.
 
@@ -545,7 +545,7 @@ sht_rm_value_re("ha=>.*");
 sht_lock("ha=>test");
 ...
 
-4.5.  sht_unlock(htable=>key)
+4.5. sht_unlock(htable=>key)
 
    Unlock the slot in htable corespoding to the key item.
 
@@ -576,7 +576,7 @@ sht_unlock("ha=>test");
    6.2. sht_dump
    6.3. sht_delete
 
-6.1.  sht_reload
+6.1. sht_reload
 
    Reload a hash table from database.
 
@@ -589,7 +589,7 @@ sht_unlock("ha=>test");
                 _hash_table_name_
                 _empty_line_
 
-6.2.  sht_dump
+6.2. sht_dump
 
    Dump content of a hash table via MI.
 
@@ -602,7 +602,7 @@ sht_unlock("ha=>test");
                 _hash_table_name_
                 _empty_line_
 
-6.3.  sht_delete
+6.3. sht_delete
 
    Delete a key from a hash table via MI.
 
@@ -632,7 +632,7 @@ sht_unlock("ha=>test");
    7.7. htable.listTables
    7.8. htable.stats
 
-7.1.  htable.get htable key
+7.1. htable.get htable key
 
    Lists one value in a hash table
 
@@ -648,7 +648,7 @@ sht_unlock("ha=>test");
 kamcmd htable.get students daniel
 ...
 
-7.2.  htable.delete htable key
+7.2. htable.delete htable key
 
    Delete one value in a hash table
 
@@ -664,7 +664,7 @@ kamcmd htable.get students daniel
 kamcmd htable.get students anna
 ...
 
-7.3.  htable.sets htable key value
+7.3. htable.sets htable key value
 
    Set an item in hash table to string value.
 
@@ -681,7 +681,7 @@ kamcmd htable.get students anna
 kamcmd htable.sets test x abc
 ...
 
-7.4.  htable.seti htable key value
+7.4. htable.seti htable key value
 
    Set an item in hash table to integer value.
 
@@ -698,7 +698,7 @@ kamcmd htable.sets test x abc
 kamcmd htable.sets test x 123
 ...
 
-7.5.  htable.dump htable
+7.5. htable.dump htable
 
    Lists all the values in a hash table
 
@@ -712,7 +712,7 @@ kamcmd htable.sets test x 123
 kamcmd htable.dump ipban
 ...
 
-7.6.  htable.reload htable
+7.6. htable.reload htable
 
    Reload hash table from database.
 
@@ -726,7 +726,7 @@ kamcmd htable.dump ipban
 kamcmd htable.reload ipban
 ...
 
-7.7.  htable.listTables
+7.7. htable.listTables
 
    Lists all defined tables
 
@@ -740,7 +740,7 @@ kamcmd htable.reload ipban
 kamcmd htable.listTables
 ...
 
-7.8.  htable.stats
+7.8. htable.stats
 
    Get statistics for hash tables - name, number of slots, number of
    items, max number of items per slot, min number of items per slot.
@@ -759,7 +759,7 @@ kamcmd htable.stats
 
    8.1. htable:mod-init
 
-8.1.  htable:mod-init
+8.1. htable:mod-init
 
    When defined, the module calls event_route[htable:mod-init] after all
    modules have been initialized. A typical use case is to initialise
diff --git a/modules/htable/doc/htable_admin.xml b/modules/htable/doc/htable_admin.xml
index 3279738..b17902c 100644
--- a/modules/htable/doc/htable_admin.xml
+++ b/modules/htable/doc/htable_admin.xml
@@ -210,7 +210,7 @@ if(is_present_hf("Authorization"))
 	</section>
 	<section>
 	<title>Parameters</title>
-	<section>
+	<section id="htable.p.htable">
 		<title><varname>htable</varname> (str)</title>
 		<para>
 		The definition of a hash table. The value of the parameter must have the
@@ -298,7 +298,7 @@ modparam("htable", "htable", "c=>size=4;autoexpire=7200;initval=1;dmqreplicat
 </programlisting>
 		</example>
 	</section>
-	<section>
+	<section id="htable.p.db_url">
 		<title><varname>db_url</varname> (str)</title>
 		<para>
 			The URL to connect to database for loading values in hash
@@ -318,7 +318,7 @@ modparam("htable", "db_url", "&defaultdb;")
 </programlisting>
 		</example>
 	</section>
-	<section>
+	<section id="htable.p.key_name_column">
 		<title><varname>key_name_column</varname> (str)</title>
 		<para>
 			The name of the column containing hash table key name.
@@ -337,7 +337,7 @@ modparam("htable", "key_name_column", "kname")
 </programlisting>
 		</example>
 	</section>
-	<section>
+	<section id="htable.p.key_type_column">
 		<title><varname>key_type_column</varname> (str)</title>
 		<para>
 			The name of the column containing hash table key type.
@@ -356,7 +356,7 @@ modparam("htable", "key_type_column", "ktype")
 </programlisting>
 		</example>
 	</section>
-	<section>
+	<section id="htable.p.value_type_column">
 		<title><varname>value_type_column</varname> (str)</title>
 		<para>
 			The name of the column containing hash table value type.
@@ -375,7 +375,7 @@ modparam("htable", "value_type_column", "vtype")
 </programlisting>
 		</example>
 	</section>
-	<section>
+	<section id="htable.p.key_value_column">
 		<title><varname>key_value_column</varname> (str)</title>
 		<para>
 			The name of the column containing hash table key value.
@@ -394,7 +394,7 @@ modparam("htable", "key_value_column", "kvalue")
 </programlisting>
 		</example>
 	</section>
-	<section>
+	<section id="htable.p.expires_column">
 		<title><varname>expires_column</varname> (str)</title>
 		<para>
 			The name of the column containing expires type.
@@ -413,7 +413,7 @@ modparam("htable", "expires", "expiry")
 </programlisting>
 		</example>
 	</section>
-	<section>
+	<section id="htable.p.array_size_suffix">
 		<title><varname>array_size_suffix</varname> (str)</title>
 		<para>
 			The suffix to be added to store the number of items in an
@@ -433,7 +433,7 @@ modparam("htable", "array_size_suffix", "-count")
 </programlisting>
 		</example>
 	</section>
-	<section>
+	<section id="htable.p.fetch_rows">
 		<title><varname>fetch_rows</varname> (integer)</title>
 		<para>
 		How many rows to fetch at once from database.
@@ -452,7 +452,7 @@ modparam("htable", "fetch_rows", 1000)
 </programlisting>
 		</example>
 	</section>
-	<section>
+	<section id="htable.p.timer_interval">
 		<title><varname>timer_interval</varname> (integer)</title>
 		<para>
 		Interval in seconds to check for expired htable values.
@@ -471,7 +471,7 @@ modparam("htable", "timer_interval", 10)
 </programlisting>
 		</example>
 	</section>
-	<section>
+	<section id="htable.p.timer_mode">
 		<title><varname>timer_mode</varname> (integer)</title>
 		<para>
 		If set to 1, will start a new timer process. If set to 0
@@ -492,7 +492,7 @@ modparam("htable", "timer_mode", 1)
 </programlisting>
 		</example>
 	</section>
-	<section>
+	<section id="htable.p.db_expires">
 		<title><varname>db_expires</varname> (integer)</title>
 		<para>
 			If set to 1, will load/save the expires values of the items in
@@ -513,7 +513,7 @@ modparam("htable", "db_expires", 1)
 </programlisting>
 		</example>
 	</section>
-	<section>
+	<section id="htable.p.enable_dmq">
 		<title><varname>enable_dmq</varname> (integer)</title>
 		<para>
 			If set to 1, will enable DMQ replication of actions performed upon 
@@ -543,7 +543,7 @@ modparam("htable", "enable_dmq", 1)
 	</section>
 	<section>
 	<title>Functions</title>
-	<section>
+	<section id="htable.f.sht_print">
 		<title>
 		<function moreinfo="none">sht_print()</function>
 		</title>
@@ -564,7 +564,7 @@ sht_print();
 </programlisting>
 		</example>
 	</section>
-	<section>
+	<section id="htable.f.sht_rm_name_re">
 		<title>
 		<function moreinfo="none">sht_rm_name_re(htable=>regexp)</function>
 		</title>
@@ -585,7 +585,7 @@ sht_rm_name_re("ha=>.*");
 </programlisting>
 		</example>
 	</section>
-	<section>
+	<section id="htable.f.sht_rm_value_re">
 		<title>
 		<function moreinfo="none">sht_rm_value_re(htable=>regexp)</function>
 		</title>
diff --git a/modules/htable/htable.c b/modules/htable/htable.c
index 1900ec5..ab2ecea 100644
--- a/modules/htable/htable.c
+++ b/modules/htable/htable.c
@@ -490,7 +490,8 @@ static struct mi_root* ht_mi_reload(struct mi_root* cmd_tree, void* param)
 		return init_mi_tree( 500, "no such hash table", 18);
 	}
 	memcpy(&nht, ht, sizeof(ht_t));
-	nht.entries = (ht_entry_t*)shm_malloc(nht.htsize*sizeof(ht_entry_t));
+	/* it's temporary operation - use system malloc */
+	nht.entries = (ht_entry_t*)malloc(nht.htsize*sizeof(ht_entry_t));
 	if(nht.entries == NULL)
 	{
 		ht_db_close_con();
@@ -500,6 +501,18 @@ static struct mi_root* ht_mi_reload(struct mi_root* cmd_tree, void* param)
 
 	if(ht_db_load_table(&nht, &ht->dbtable, 0)<0)
 	{
+		/* free any entry set if it was a partial load */
+		for(i=0; i<nht.htsize; i++)
+		{
+			first = nht.entries[i].first;
+			while(first)
+			{
+				it = first;
+				first = first->next;
+				ht_cell_free(it);
+			}
+		}
+		free(nht.entries);
 		ht_db_close_con();
 		return init_mi_tree(500, MI_ERR_RELOAD, MI_ERR_RELOAD_LEN);
 	}
@@ -525,6 +538,7 @@ static struct mi_root* ht_mi_reload(struct mi_root* cmd_tree, void* param)
 			ht_cell_free(it);
 		}
 	}
+	free(nht.entries);
 	ht_db_close_con();
 	return init_mi_tree( 200, MI_OK_S, MI_OK_LEN);
 }
@@ -1035,7 +1049,8 @@ static void htable_rpc_reload(rpc_t* rpc, void* c)
 
 
 	memcpy(&nht, ht, sizeof(ht_t));
-	nht.entries = (ht_entry_t*)shm_malloc(nht.htsize*sizeof(ht_entry_t));
+	/* it's temporary operation - use system malloc */
+	nht.entries = (ht_entry_t*)malloc(nht.htsize*sizeof(ht_entry_t));
 	if(nht.entries == NULL)
 	{
 		ht_db_close_con();
@@ -1046,6 +1061,18 @@ static void htable_rpc_reload(rpc_t* rpc, void* c)
 
 	if(ht_db_load_table(&nht, &ht->dbtable, 0)<0)
 	{
+		/* free any entry set if it was a partial load */
+		for(i=0; i<nht.htsize; i++)
+		{
+			first = nht.entries[i].first;
+			while(first)
+			{
+				it = first;
+				first = first->next;
+				ht_cell_free(it);
+			}
+		}
+		free(nht.entries);
 		ht_db_close_con();
 		rpc->fault(c, 500, "Mtree reload failed");
 		return;
@@ -1072,6 +1099,7 @@ static void htable_rpc_reload(rpc_t* rpc, void* c)
 			ht_cell_free(it);
 		}
 	}
+	free(nht.entries);
 	ht_db_close_con();
 	return;
 }
diff --git a/modules/ims_registrar_pcscf/reg_mod.c b/modules/ims_registrar_pcscf/reg_mod.c
index d844832..b2ffe8e 100644
--- a/modules/ims_registrar_pcscf/reg_mod.c
+++ b/modules/ims_registrar_pcscf/reg_mod.c
@@ -394,12 +394,13 @@ static int w_assert_identity(struct sip_msg* _m, char* _d, char* _preferred_uri)
 }
 
 /*
- * Returns the current RTP-Statistics from the RTP-Proxy
+ * Get the asserted Identity for the current user
  */
 static int
 pv_get_asserted_identity_f(struct sip_msg *msg, pv_param_t *param,
 		  pv_value_t *res)
 {
-    str * ret_val = get_asserted_identity(msg);
-    return pv_get_strval(msg, param, res, ret_val);
+	str * ret_val = get_asserted_identity(msg);
+	if (ret_val != NULL) return pv_get_strval(msg, param, res, ret_val);
+	else return -1;
 }
diff --git a/modules/ims_registrar_scscf/cxdx_sar.c b/modules/ims_registrar_scscf/cxdx_sar.c
index 7ff976b..122edc4 100644
--- a/modules/ims_registrar_scscf/cxdx_sar.c
+++ b/modules/ims_registrar_scscf/cxdx_sar.c
@@ -141,6 +141,13 @@ void async_cdp_callback(int is_timeout, void *param, AAAMessage *saa, long elaps
             goto error_no_send;
         }
 
+	set_avp_list(AVP_TRACK_FROM | AVP_CLASS_URI, &t->uri_avps_from);
+	set_avp_list(AVP_TRACK_TO | AVP_CLASS_URI, &t->uri_avps_to);
+	set_avp_list(AVP_TRACK_FROM | AVP_CLASS_USER, &t->user_avps_from);
+	set_avp_list(AVP_TRACK_TO | AVP_CLASS_USER, &t->user_avps_to);
+	set_avp_list(AVP_TRACK_FROM | AVP_CLASS_DOMAIN, &t->domain_avps_from);
+	set_avp_list(AVP_TRACK_TO | AVP_CLASS_DOMAIN, &t->domain_avps_to);
+
         get_act_time();
 
         if (is_timeout) {
@@ -253,12 +260,6 @@ done:
     if (data->sar_assignment_type != AVP_IMS_SAR_UNREGISTERED_USER)
         reg_send_reply_transactional(t->uas.request, data->contact_header, t);
     LM_DBG("DBG:SAR Async CDP callback: ... Done resuming transaction\n");
-    set_avp_list(AVP_TRACK_FROM | AVP_CLASS_URI, &t->uri_avps_from);
-    set_avp_list(AVP_TRACK_TO | AVP_CLASS_URI, &t->uri_avps_to);
-    set_avp_list(AVP_TRACK_FROM | AVP_CLASS_USER, &t->user_avps_from);
-    set_avp_list(AVP_TRACK_TO | AVP_CLASS_USER, &t->user_avps_to);
-    set_avp_list(AVP_TRACK_FROM | AVP_CLASS_DOMAIN, &t->domain_avps_from);
-    set_avp_list(AVP_TRACK_TO | AVP_CLASS_DOMAIN, &t->domain_avps_to);
 
     create_return_code(result);
 
@@ -278,6 +279,8 @@ done:
 error:
     if (data->sar_assignment_type != AVP_IMS_SAR_UNREGISTERED_USER)
         reg_send_reply_transactional(t->uas.request, data->contact_header, t);
+		
+    create_return_code(-2);
 
 error_no_send: //if we don't have the transaction then we can't send a transaction response
     update_stat(rejected_registrations, 1);
diff --git a/modules/maxfwd/maxfwd.c b/modules/maxfwd/maxfwd.c
index 01e64a6..371a1aa 100644
--- a/modules/maxfwd/maxfwd.c
+++ b/modules/maxfwd/maxfwd.c
@@ -55,7 +55,7 @@ struct cfg_group_maxfwd {
 };
 
 static struct cfg_group_maxfwd default_maxfwd_cfg = {
-	max_limit:16
+	.max_limit=16
 };
 
 static void *maxfwd_cfg = &default_maxfwd_cfg;
diff --git a/modules/outbound/api.h b/modules/outbound/api.h
index fc0e8b9..facc1db 100644
--- a/modules/outbound/api.h
+++ b/modules/outbound/api.h
@@ -19,6 +19,11 @@
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Exception: permission to copy, modify, propagate, and distribute a work
+ * formed by combining OpenSSL toolkit software and the code in this file,
+ * such as linking with software components and libraries released under
+ * OpenSSL project license.
+ *
  */
 
 #ifndef OB_API_H
diff --git a/modules/outbound/config.c b/modules/outbound/config.c
index bcb6fbb..5b291f4 100644
--- a/modules/outbound/config.c
+++ b/modules/outbound/config.c
@@ -17,6 +17,11 @@
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Exception: permission to copy, modify, propagate, and distribute a work
+ * formed by combining OpenSSL toolkit software and the code in this file,
+ * such as linking with software components and libraries released under
+ * OpenSSL project license.
+ *
  */
 
 /*!
diff --git a/modules/outbound/config.h b/modules/outbound/config.h
index 0410ff5..cf6796e 100644
--- a/modules/outbound/config.h
+++ b/modules/outbound/config.h
@@ -17,6 +17,11 @@
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Exception: permission to copy, modify, propagate, and distribute a work
+ * formed by combining OpenSSL toolkit software and the code in this file,
+ * such as linking with software components and libraries released under
+ * OpenSSL project license.
+ *
  */
 
 /*!
diff --git a/modules/outbound/ob_mod.c b/modules/outbound/ob_mod.c
index 9902e91..038c5fa 100644
--- a/modules/outbound/ob_mod.c
+++ b/modules/outbound/ob_mod.c
@@ -19,6 +19,11 @@
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Exception: permission to copy, modify, propagate, and distribute a work
+ * formed by combining OpenSSL toolkit software and the code in this file,
+ * such as linking with software components and libraries released under
+ * OpenSSL project license.
+ *
  */
 #include <openssl/hmac.h>
 #include <openssl/rand.h>
diff --git a/modules/permissions/README b/modules/permissions/README
index 3ad7325..9835af6 100644
--- a/modules/permissions/README
+++ b/modules/permissions/README
@@ -14,9 +14,9 @@ Edited by
 
 Juha Heinanen
 
-   Copyright © 2003 Miklos Tirpak
+   Copyright � 2003 Miklos Tirpak
 
-   Copyright © 2006-2008 Juha Heinanen
+   Copyright � 2006-2008 Juha Heinanen
      __________________________________________________________________
 
    Table of Contents
@@ -250,7 +250,7 @@ Chapter 1. Admin Guide
 
    Function for registration checking is called allow_register and the
    algorithm is very similar to the algorithm described in Section 1.1,
-   “Call Routing”. The only difference is in the way how pairs are
+   "Call Routing". The only difference is in the way how pairs are
    created.
 
    Instead of From header field the function uses To header field because
@@ -261,8 +261,8 @@ Chapter 1. Admin Guide
    Thus, pairs used in matching will look like this: (To, Contact 1), (To,
    Contact 2), (To, Contact 3), and so on..
 
-   The algorithm of matching is same as described in Section 1.1, “Call
-   Routing”.
+   The algorithm of matching is same as described in Section 1.1, "Call
+   Routing".
 
 1.3. URI Permissions
 
@@ -387,7 +387,7 @@ Chapter 1. Admin Guide
    specify full pathname then the directory in which is the main config
    file is located will be used.
 
-   Default value is “permissions.allow”.
+   Default value is "permissions.allow".
 
    Example 1.1. Set default_allow_file parameter
 ...
@@ -400,7 +400,7 @@ modparam("permissions", "default_allow_file", "/etc/permissions.allow")
    without parameters. If you don't specify full pathname then the
    directory in which the main config file is located will be used.
 
-   Default value is “permissions.deny”.
+   Default value is "permissions.deny".
 
    Example 1.2. Set default_deny_file parameter
 ...
@@ -435,7 +435,7 @@ Note
 
    Including leading dot.
 
-   Default value is “.allow”.
+   Default value is ".allow".
 
    Example 1.4. Set allow_suffix parameter
 ...
@@ -452,7 +452,7 @@ Note
 
    Including leading dot.
 
-   Default value is “.deny”.
+   Default value is ".deny".
 
    Example 1.5. Set deny_suffix parameter
 ...
@@ -464,7 +464,7 @@ modparam("permissions", "deny_suffix", ".deny")
    This is URL of the database to be used to store rules used by
    allow_trusted function.
 
-   Default value is “NULL”.
+   Default value is "NULL".
 
    Example 1.6. Set db_url parameter
 ...
@@ -476,7 +476,7 @@ modparam("permissions", "db_url", "dbdriver://username:password@dbhost/dbname")
    Name of database table containing IP subnets and DNS domain names used
    by allow_address and allow_source_address functions.
 
-   Default value is “address”.
+   Default value is "address".
 
    Example 1.7. Set address_table parameter
 ...
@@ -488,7 +488,7 @@ modparam("permissions", "address_table", "addr")
    Name of address table column containing group identifier of the
    address.
 
-   Default value is “grp”.
+   Default value is "grp".
 
    Example 1.8. Set grp_col parameter
 ...
@@ -499,7 +499,7 @@ modparam("permissions", "grp_col", "group_id")
 
    Name of address table column containing IP address part of the address.
 
-   Default value is “ip_addr”.
+   Default value is "ip_addr".
 
    Example 1.9. Set ip_addr_col parameter
 ...
@@ -511,7 +511,7 @@ modparam("permissions", "ip_addr_col", "ip_address")
    Name of address table column containing network mask of the address.
    Possible values are 0-32.
 
-   Default value is “mask”.
+   Default value is "mask".
 
    Example 1.10. Set mask_col parameter
 ...
@@ -522,7 +522,7 @@ modparam("permissions", "mask_col", "subnet_length")
 
    Name of address table column containing port part of the address.
 
-   Default value is “port”.
+   Default value is "port".
 
    Example 1.11. Set port_col parameter
 ...
@@ -546,7 +546,7 @@ modparam("permissions", "db_mode", 1)
    Name of database table containing matching rules used by allow_trusted
    function.
 
-   Default value is “trusted”.
+   Default value is "trusted".
 
    Example 1.13. Set trusted_table parameter
 ...
@@ -558,7 +558,7 @@ modparam("permissions", "trusted_table", "pbx")
    Name of trusted table column containing source IP address that is
    matched against source IP address of received request.
 
-   Default value is “src_ip”.
+   Default value is "src_ip".
 
    Example 1.14. Set source_col parameter
 ...
@@ -569,10 +569,10 @@ modparam("permissions", "source_col", "source_ip_address")
 
    Name of trusted table column containing transport protocol that is
    matched against transport protocol of received request. Possible values
-   that can be stored in proto_col are “any”, “udp”, “tcp”, “tls”, “sctp”,
-   and “none”. Value “any” matches always and value “none” never.
+   that can be stored in proto_col are "any", "udp", "tcp", "tls", "sctp",
+   and "none". Value "any" matches always and value "none" never.
 
-   Default value is “proto”.
+   Default value is "proto".
 
    Example 1.15. Set proto_col parameter
 ...
@@ -584,7 +584,7 @@ modparam("permissions", "proto_col", "transport")
    Name of trusted table column containing regular expression that is
    matched against From URI.
 
-   Default value is “from_pattern”.
+   Default value is "from_pattern".
 
    Example 1.16. Set from_col parameter
 ...
@@ -597,7 +597,7 @@ modparam("permissions", "from_col", "regexp")
    added as value to peer_tag AVP if peer_tag AVP has been defined and if
    the address or peer matches.
 
-   Default value is “tag”.
+   Default value is "tag".
 
    Example 1.17. Set tag_col parameter
 ...
@@ -609,7 +609,7 @@ modparam("permissions", "tag_col", "peer_tag")
    If defined, the AVP will be set as side effect of allow_trusted() call
    to not NULL tag column value of the matching peer.
 
-   Default value is “undefined”.
+   Default value is "undefined".
 
    Example 1.18. Set peer_tag_avp parameter
 ...
@@ -620,9 +620,10 @@ modparam("permissions", "peer_tag_avp", "$avp(i:707)")
 
    Tag mode for allow_trusted(). 0 sets only the tag of the first match. 1
    adds the tags of all matches to the avp. In addition the return value
-   of allow_trusted() is the number of matches.
+   of allow_trusted() is the number of matches. This parameter is not used
+   for address table matching functions.
 
-   Default value is “0”.
+   Default value is "0".
 
    Example 1.19. Set peer_tag_mode parameter
 ...
@@ -643,10 +644,10 @@ modparam("permissions", "peer_tag_mode", "1")
    4.10. allow_address_group(addr, port)
    4.11. allow_trusted([src_ip_pvar, proto_pvar])
 
-4.1.  allow_routing()
+4.1. allow_routing()
 
    Returns true if all pairs constructed as described in Section 1.1,
-   “Call Routing” have appropriate permissions according to the
+   "Call Routing" have appropriate permissions according to the
    configuration files. This function uses default configuration files
    specified in default_allow_file and default_deny_file.
 
@@ -659,10 +660,10 @@ if (allow_routing()) {
 };
 ...
 
-4.2.  allow_routing(basename)
+4.2. allow_routing(basename)
 
    Returns true if all pairs constructed as described in Section 1.1,
-   “Call Routing” have appropriate permissions according to the
+   "Call Routing" have appropriate permissions according to the
    configuration files given as parameters.
 
    Meaning of the parameters is as follows:
@@ -682,10 +683,10 @@ if (allow_routing("basename")) {
 };
 ...
 
-4.3.  allow_routing(allow_file,deny_file)
+4.3. allow_routing(allow_file,deny_file)
 
    Returns true if all pairs constructed as described in Section 1.1,
-   “Call Routing” have appropriate permissions according to the
+   "Call Routing" have appropriate permissions according to the
    configuration files given as parameters.
 
    Meaning of the parameters is as follows:
@@ -707,10 +708,10 @@ if (allow_routing("rules.allow", "rules.deny")) {
 };
 ...
 
-4.4.  allow_register(basename)
+4.4. allow_register(basename)
 
    The function returns true if all pairs constructed as described in
-   Section 1.2, “Registration Permissions” have appropriate permissions
+   Section 1.2, "Registration Permissions" have appropriate permissions
    according to the configuration files given as parameters.
 
    Meaning of the parameters is as follows:
@@ -735,10 +736,10 @@ if (method=="REGISTER") {
 };
 ...
 
-4.5.  allow_register(allow_file, deny_file)
+4.5. allow_register(allow_file, deny_file)
 
    The function returns true if all pairs constructed as described in
-   Section 1.2, “Registration Permissions” have appropriate permissions
+   Section 1.2, "Registration Permissions" have appropriate permissions
    according to the configuration files given as parameters.
 
    Meaning of the parameters is as follows:
@@ -765,10 +766,10 @@ if (method=="REGISTER") {
 };
 ...
 
-4.6.  allow_uri(basename, pvar)
+4.6. allow_uri(basename, pvar)
 
-   Returns true if the pair constructed as described in Section 1.3, “URI
-   Permissions” have appropriate permissions according to the
+   Returns true if the pair constructed as described in Section 1.3, "URI
+   Permissions" have appropriate permissions according to the
    configuration files specified by the parameter.
 
    Meaning of the parameter is as follows:
@@ -792,7 +793,7 @@ if (allow_uri("basename", "$avp(i:705)") {  // Check URI stored in $avp(i:705)
 };
 ...
 
-4.7.  allow_address(group_id, ip_addr_pvar, port_pvar)
+4.7. allow_address(group_id, ip_addr_pvar, port_pvar)
 
    Returns true if address and port given as values of pvar arguments
    belonging to a group given as group_id argument matches an IP subnet or
@@ -821,7 +822,7 @@ if (!allow_address("2", "$avp(dst_adr)", "$avp(dst_port)") {
 };
 ...
 
-4.8.  allow_source_address([group_id])
+4.8. allow_source_address([group_id])
 
    Equal to allow_address(group_id, "$si", "$sp"). If 'group_id' is
    missing, the function is equal to allow_address("1", "$si", "$sp").
@@ -837,7 +838,7 @@ if (!allow_source_address("1")) {
 };
 ...
 
-4.9.  allow_source_address_group()
+4.9. allow_source_address_group()
 
    Checks if source address/port is found in cached address or subnet
    table in any group. If yes, returns that group. If not returns -1. Port
@@ -854,7 +855,7 @@ if ($var(group) != -1) {
 };
 ...
 
-4.10.  allow_address_group(addr, port)
+4.10. allow_address_group(addr, port)
 
    Checks if address/port is found in cached address or subnet table in
    any group. If yes, returns that group. If not returns -1. Port value 0
@@ -872,19 +873,19 @@ if ($var(group) != -1) {
 };
 ...
 
-4.11.  allow_trusted([src_ip_pvar, proto_pvar])
+4.11. allow_trusted([src_ip_pvar, proto_pvar])
 
    Checks based either on request's source address and transport protocol
    or source address and transport protocol given in pvar arguments, and
    From URI of request if request can be trusted without authentication.
-   Returns 1 if a match is found as described in Section 1.5, “Trusted
-   Requests” and -1 otherwise. If a match is found and peer_tag_avp has
+   Returns 1 if a match is found as described in Section 1.5, "Trusted
+   Requests" and -1 otherwise. If a match is found and peer_tag_avp has
    been defined, adds a non-NULL tag column value of the matching peer to
    AVP peer_tag_avp.
 
    Source address and transport protocol given in pvar arguments must be
    in string format. Valid transport protocol values are (ignoring case)
-   "any", "udp, "tcp", "tls", and "sctp".
+   "any", "udp, "tcp", "tls", "ws", "wss" and "sctp".
 
    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
 
@@ -908,7 +909,7 @@ if (allow_trusted("$si", "$proto")) {
    5.5. trusted_dump
    5.6. allow_uri
 
-5.1.  address_reload
+5.1. address_reload
 
    Causes permissions module to re-read the contents of address database
    table into cache memory. In cache memory the entries are for
@@ -917,35 +918,35 @@ if (allow_trusted("$si", "$proto")) {
 
    Parameters: none
 
-5.2.  address_dump
+5.2. address_dump
 
    Causes permissions module to dump contents of cache memory address
    table.
 
    Parameters: none
 
-5.3.  subnet_dump
+5.3. subnet_dump
 
    Causes permissions module to dump contents of cache memory subnet
    table.
 
    Parameters: none
 
-5.4.  trusted_reload
+5.4. trusted_reload
 
    Causes permissions module to re-read the contents of trusted table into
    cache memory.
 
    Parameters: none
 
-5.5.  trusted_dump
+5.5. trusted_dump
 
    Causes permissions module to dump contents of trusted table from cache
    memory.
 
    Parameters: none
 
-5.6.  allow_uri
+5.6. allow_uri
 
    Tests if (URI, Contact) pair is allowed according to allow/deny files.
    The files must already have been loaded by Kamailio.
@@ -966,7 +967,7 @@ if (allow_trusted("$si", "$proto")) {
    6.5. trustedReload
    6.6. trustedDump
 
-6.1.  addressReload
+6.1. addressReload
 
    Causes permissions module to re-read the contents of address database
    table into cache memory. In cache memory the entries are for
@@ -975,21 +976,21 @@ if (allow_trusted("$si", "$proto")) {
 
    Parameters: none
 
-6.2.  addressDump
+6.2. addressDump
 
    Causes permissions module to dump contents of cache memory address
    table. (Not the subnet table).
 
    Parameters: none
 
-6.3.  subnetDump
+6.3. subnetDump
 
    Causes permissions module to dump contents of cache memory subnet
    table.
 
    Parameters: none
 
-6.4.  testUri basename uri contact
+6.4. testUri basename uri contact
 
    Tests if (URI, Contact) pair is allowed according to allow/deny files.
    The files must already have been loaded by Kamailio.
@@ -1001,14 +1002,14 @@ if (allow_trusted("$si", "$proto")) {
      * URI - URI to be tested
      * Contact - Contact to be tested
 
-6.5.  trustedReload
+6.5. trustedReload
 
    Causes permissions module to re-read the contents of trusted table into
    cache memory.
 
    Parameters: none
 
-6.6.  trustedDump
+6.6. trustedDump
 
    Causes permissions module to dump contents of trusted table from cache
    memory.
diff --git a/modules/permissions/address.c b/modules/permissions/address.c
index 6dc3275..2600086 100644
--- a/modules/permissions/address.c
+++ b/modules/permissions/address.c
@@ -191,12 +191,12 @@ int reload_address_table(void)
 		//	goto dberror;
 		} else {
 			if(ipa->af == AF_INET6) {
-				if(mask<0 || mask>128) {
+				if((int)mask<0 || mask>128) {
 					LM_DBG("failure during IP mask check for v6\n");
 					goto dberror;
 				}
 			} else {
-				if(mask<0 || mask>32) {
+				if((int)mask<0 || mask>32) {
 					LM_DBG("failure during IP mask check for v4\n");
 					goto dberror;
 				}
diff --git a/modules/permissions/doc/permissions_admin.xml b/modules/permissions/doc/permissions_admin.xml
index 8e2ba00..c955d2a 100644
--- a/modules/permissions/doc/permissions_admin.xml
+++ b/modules/permissions/doc/permissions_admin.xml
@@ -687,7 +687,8 @@ modparam("permissions", "peer_tag_avp", "$avp(i:707)")
 		<para>
 		Tag mode for allow_trusted(). 0 sets only the tag of the
 		first match. 1 adds the tags of all matches to the avp. In addition
-		the return value of allow_trusted() is the number of matches.
+		the return value of allow_trusted() is the number of matches. This
+		parameter is not used for address table matching functions.
 		</para>
 		<para>
 		<emphasis>
diff --git a/modules/permissions/hash.c b/modules/permissions/hash.c
index 3a16581..ab09bf1 100644
--- a/modules/permissions/hash.c
+++ b/modules/permissions/hash.c
@@ -486,6 +486,7 @@ int find_group_in_addr_hash_table(struct addr_list** table,
 {
 	struct addr_list *np;
 	str addr_str;
+	avp_value_t val;
 
 	addr_str.s = (char*)addr->u.addr;
 	addr_str.len = 4;
@@ -493,6 +494,15 @@ int find_group_in_addr_hash_table(struct addr_list** table,
 	for (np = table[perm_hash(addr_str)]; np != NULL; np = np->next) {
 		if (((np->port == 0) || (np->port == port))
 				&& ip_addr_cmp(&np->addr, addr)) {
+
+			if (tag_avp.n && np->tag.s) {
+				val.s = np->tag;
+				if (add_avp(tag_avp_type|AVP_VAL_STR, tag_avp, val) != 0) {
+					LM_ERR("setting of tag_avp failed\n");
+					return -1;
+				}
+			}
+
 			return np->grp;
 		}
 	}
@@ -710,6 +720,7 @@ int find_group_in_subnet_table(struct subnet* table,
 		ip_addr_t *addr, unsigned int port)
 {
 	unsigned int count, i;
+	avp_value_t val;
 
 	count = table[PERM_MAX_SUBNETS].grp;
 
@@ -717,7 +728,16 @@ int find_group_in_subnet_table(struct subnet* table,
 	while (i < count) {
 		if ( ((table[i].port == port) || (table[i].port == 0))
 			&& (ip_addr_match_net(addr, &table[i].subnet, table[i].mask)==0))
+		{
+			if (tag_avp.n && table[i].tag.s) {
+				val.s = table[i].tag;
+				if (add_avp(tag_avp_type|AVP_VAL_STR, tag_avp, val) != 0) {
+					LM_ERR("setting of tag_avp failed\n");
+					return -1;
+				}
+			}
 			return table[i].grp;
+		}
 		i++;
 	}
 
diff --git a/modules/pike/pike_top.c b/modules/pike/pike_top.c
index c3d001e..8399602 100644
--- a/modules/pike/pike_top.c
+++ b/modules/pike/pike_top.c
@@ -13,14 +13,15 @@
 static struct TopListItem_t *top_list_root = 0;
 static struct TopListItem_t *top_list_iter = 0;
 
-static char buff[128];
+#define PIKE_BUFF_SIZE	128
+static char buff[PIKE_BUFF_SIZE];
 
 struct TopListItem_t *pike_top_get_root() { return top_list_root; }
 
 char *pike_top_print_addr( unsigned char *ip, int iplen, char *buff, int buffsize )
 {
 	unsigned short *ipv6_ptr = (unsigned short *)ip;
-	memset( buff, 0, sizeof(buff));
+	memset(buff, 0, PIKE_BUFF_SIZE*sizeof(char));
 	
 	DBG("pike:top:print_addr(iplen: %d, buffsize: %d)", iplen, buffsize);
 	
diff --git a/modules/presence_dialoginfo/notify_body.c b/modules/presence_dialoginfo/notify_body.c
index 23ea1b2..7f74b1f 100644
--- a/modules/presence_dialoginfo/notify_body.c
+++ b/modules/presence_dialoginfo/notify_body.c
@@ -32,6 +32,12 @@
  */
 
 #define MAX_INT_LEN 11 /* 2^32: 10 chars + 1 char sign */
+#define DEF_TRYING_NODE 1
+#define DEF_PROCEEDING_NODE 2
+#define DEF_EARLY_NODE 4
+#define DEF_CONFIRMED_NODE 8
+#define DEF_TERMINATED_NODE 16
+
 
 #include <string.h>
 #include <stdlib.h>
@@ -103,6 +109,9 @@ str* agregate_xmls(str* pres_user, str* pres_domain, str** body_array, int n)
 	xmlNodePtr terminated_node = NULL;
 	xmlNodePtr early_node = NULL;
 	xmlNodePtr confirmed_node = NULL;
+	xmlNodePtr proceed_node = NULL;
+	xmlNodePtr trying_node = NULL;
+
 
 	char *state = NULL;
 	xmlChar *dialog_id = NULL;
@@ -236,39 +245,61 @@ str* agregate_xmls(str* pres_user, str* pres_domain, str** body_array, int n)
 							LM_DBG("state element content = %s\n", state);
 							if (strcasecmp(state,"terminated") == 0)
 							{
+								LM_DBG("found terminated state\n" );
 								terminated_node = node;
 							} else if (strcasecmp(state,"confirmed") == 0 && node_id == i) {
 								/*  here we check if confirmed is terminated or not
 								 *  if it is not we are in the middle of the conversation
 								 */
-								if(check_relevant_state(dialog_id, xml_array, j) > 1)
+								if(check_relevant_state(dialog_id, xml_array, j) >= DEF_TERMINATED_NODE)
 								{
-									LM_DBG("confirmed state for dialog %s, but it was terminated\n", dialog_id );
+									LM_DBG("confirmed state for dialog %s, but it is not latest state\n", dialog_id );
 								}else{
-									LM_DBG("confirmed state for dialog %s, and it is not terminated\n", dialog_id );
+									LM_DBG("confirmed state for dialog %s and latest state for this dialog\n", dialog_id );
 									confirmed_node = node;
 								}
 
 
 							} else if (strcasecmp(state,"early") == 0 && node_id == i) {
-								if(check_relevant_state(dialog_id, xml_array, j)  > 0)
+								if(check_relevant_state(dialog_id, xml_array, j)  >= DEF_CONFIRMED_NODE)
 								{
-									LM_DBG("early state for dialog %s, but it was confirmed or terminated\n", dialog_id );
+									LM_DBG("early state for dialog %s, but it is not latest state\n", dialog_id );
 								}else{
-									LM_DBG("early state for dialog %s and it is still relevant\n", dialog_id );
+									LM_DBG("early state for dialog %s and latest state for this dialog\n", dialog_id );
 									early_node = node;
 								}
+							} else if (strcasecmp(state,"proceeding") == 0 && node_id == i) {
+								if(check_relevant_state(dialog_id, xml_array, j)  >= DEF_EARLY_NODE)
+								{
+									LM_DBG("proceeding state for dialog %s, but it is not latest state\n", dialog_id );
+								}else{
+									LM_DBG("proceeding state for dialog %s and latest state for this dialog\n", dialog_id );
+									proceed_node = node;
+								}
+							} else if (strcasecmp(state,"trying") == 0 && node_id == i) {
+								if(check_relevant_state(dialog_id, xml_array, j)  >= DEF_PROCEEDING_NODE)
+								{
+									LM_DBG("trying state for dialog %s, but it is not latest state\n", dialog_id );
+								}else{
+									LM_DBG("trying state for dialog %s and latest state for this dialog\n", dialog_id );
+									trying_node = node;
+								}
 							}
 							if(early_node != NULL) {
 								winner_dialog_node = early_node;
-							} else {
-								if(confirmed_node != NULL)
-								{
+							} else if(confirmed_node != NULL) {
 									winner_dialog_node = confirmed_node;
-								}else {
+							} else if(proceed_node != NULL) {
+									winner_dialog_node = proceed_node;
+							} else if(trying_node != NULL) {
+									winner_dialog_node = trying_node;
+							} else if(terminated_node != NULL) {
 									winner_dialog_node = terminated_node;
-								}
+							} else {
+								/* assume a failure somewhere and all above nodes are NULL */
+								winner_dialog_node = node;
 							}
+							/*
 							if(winner_dialog_node == NULL) {
 								priority = get_dialog_state_priority(state);
 								if (priority > winner_priority) {
@@ -277,6 +308,7 @@ str* agregate_xmls(str* pres_user, str* pres_domain, str** body_array, int n)
 									winner_dialog_node = node;
 								}
 							}
+							*/
 							xmlFree(state);
 						}
 					}
@@ -336,7 +368,7 @@ error:
 	return NULL;
 }
 
-
+/*
 int get_dialog_state_priority(char *state) {
 	if (strcasecmp(state,"terminated") == 0)
 		return 0;
@@ -351,8 +383,9 @@ int get_dialog_state_priority(char *state) {
 
 	return 0;
 }
+*/
 
-/* returns 2 -> terminated, 1 -> confirmed, 3 -> both */
+/* returns 16 -> terminated, 8 -> confirmed, 4 -> early */
 int check_relevant_state (xmlChar * dialog_id, xmlDocPtr * xml_array, int total_nodes)
 {
 	int result = 0;
@@ -391,7 +424,7 @@ int check_relevant_state (xmlChar * dialog_id, xmlDocPtr * xml_array, int total_
 							{
 								LM_DBG ("Found terminated in dialog %s\n",
 										dialog_id);
-								result += 2;
+								result += DEF_TERMINATED_NODE;
 							}
 							/* check if state is confirmed for this dialog. */
 							if ((strcasecmp (state, "confirmed") == 0)
@@ -399,8 +432,30 @@ int check_relevant_state (xmlChar * dialog_id, xmlDocPtr * xml_array, int total_
 									&& (strcasecmp ((char*)dialog_id_tmp, (char*)dialog_id) == 0))
 							{
 								LM_DBG ("Found confirmed in dialog %s\n", dialog_id);
-								result += 1;
+								result += DEF_CONFIRMED_NODE;
 							}
+							if ((strcasecmp (state, "early") == 0)
+									&& (node_id == i) && (node_id >= 0)
+									&& (strcasecmp ((char*)dialog_id_tmp, (char*)dialog_id) == 0))
+							{
+								LM_DBG ("Found early in dialog %s\n", dialog_id);
+								result += DEF_EARLY_NODE;
+							}
+							if ((strcasecmp (state, "proceeding") == 0)
+									&& (node_id == i) && (node_id >= 0)
+									&& (strcasecmp ((char*)dialog_id_tmp, (char*)dialog_id) == 0))
+							{
+								LM_DBG ("Found proceeding in dialog %s\n", dialog_id);
+								result += DEF_PROCEEDING_NODE;
+							}
+							if ((strcasecmp (state, "trying") == 0)
+									&& (node_id == i) && (node_id >= 0)
+									&& (strcasecmp ((char*)dialog_id_tmp, (char*)dialog_id) == 0))
+							{
+								LM_DBG ("Found trying in dialog %s\n", dialog_id);
+								result += DEF_TRYING_NODE;
+							}
+
 
 							xmlFree (state);
 						}
diff --git a/modules/print/README b/modules/print/README
index 3327979..94f46c0 100644
--- a/modules/print/README
+++ b/modules/print/README
@@ -1,4 +1,3 @@
-
 Print Module
 
 Andrei Pelinescu-Onciul
@@ -6,7 +5,7 @@ Andrei Pelinescu-Onciul
    FhG FOKUS
 
    Copyright � 2003 FhG FOKUS
-     _________________________________________________________________
+     __________________________________________________________________
 
    Table of Contents
 
@@ -20,7 +19,7 @@ Andrei Pelinescu-Onciul
 
         3. Functions
 
-              3.1. print(txt) 
+              3.1. print(txt)
 
    List of Examples
 
@@ -40,12 +39,12 @@ Chapter 1. Admin Guide
 
    3. Functions
 
-        3.1. print(txt) 
+        3.1. print(txt)
 
 1. Overview
 
    This is an example module. It implements only one function that prints
-   its  string  parameter  to  stdout (it won't work if ser is started in
+   its string parameter to stdout (it won't work if ser is started in
    daemon mode). It also shows how module parameters can be declared.
 
 2. Parameters
@@ -77,9 +76,9 @@ modparam("print", "int_param", 42)
 
 3. Functions
 
-   3.1. print(txt) 
+   3.1. print(txt)
 
-3.1.  print(txt)
+3.1. print(txt)
 
    Prints string to stdout.
 
diff --git a/modules/pua/send_subscribe.c b/modules/pua/send_subscribe.c
index 006bae4..d568ff2 100644
--- a/modules/pua/send_subscribe.c
+++ b/modules/pua/send_subscribe.c
@@ -1030,8 +1030,12 @@ int send_subscribe(subs_info_t* subs)
 insert:
 	
 		if (subs->expires == 0)
+		{
 			/* Don't create a new dialog when expires == 0 */
-			goto done;	
+       			if (dbmode != PUA_DB_ONLY)
+				lock_release(&HashT->p_records[hash_code].lock);
+			goto done;
+		}
 
 		if(subs->flag & UPDATE_TYPE)
 		{
@@ -1044,6 +1048,8 @@ insert:
 		{
 			LM_ERR("while building callback"
 					" param\n");
+       			if (dbmode != PUA_DB_ONLY)
+				lock_release(&HashT->p_records[hash_code].lock);
 			goto error;
 		}
 		hentity->flag= flag;
@@ -1068,6 +1074,8 @@ insert:
 				uac_r.dialog = 0;
 			}
 			shm_free(hentity);
+       			if (dbmode != PUA_DB_ONLY)
+				lock_release(&HashT->p_records[hash_code].lock);
 
 			/* Although this is an error must not return -1 as the
 			   calling function must continue processing. */
@@ -1089,6 +1097,8 @@ insert:
 		if(presentity== NULL)
 		{
 			LM_ERR("no more share memory\n");
+       			if (dbmode != PUA_DB_ONLY)
+				lock_release(&HashT->p_records[hash_code].lock);
 			goto error;
 		}
 		memset(presentity, 0, size);
diff --git a/modules/pv/pv_core.c b/modules/pv/pv_core.c
index 85e6f8a..0afd9b1 100644
--- a/modules/pv/pv_core.c
+++ b/modules/pv/pv_core.c
@@ -2849,12 +2849,12 @@ error:
 
 int pv_parse_flag_param(pv_spec_p sp, str *in)
 {
-	unsigned int n;
+	int n;
 
 	if(sp==NULL || in==NULL || in->len<=0)
 		return -1;
 
-	if (str2int(in, &n) != 0)
+	if (str2sint(in, &n) != 0)
 	{
 		if ((n = get_flag_no(in->s, in->len)) < 0)
 		{
diff --git a/modules/pv/pv_trans.c b/modules/pv/pv_trans.c
index 738efca..7c75deb 100644
--- a/modules/pv/pv_trans.c
+++ b/modules/pv/pv_trans.c
@@ -1025,7 +1025,7 @@ int tr_eval_uri(struct sip_msg *msg, tr_param_t *tp, int subtype,
 			val->ri = _tr_parsed_uri.port_no;
 			break;
 		case TR_URI_PARAMS:
-			val->rs = (_tr_parsed_uri.params.s)?_tr_parsed_uri.params:_tr_empty;
+			val->rs = (_tr_parsed_uri.sip_params.s)?_tr_parsed_uri.sip_params:_tr_empty;
 			break;
 		case TR_URI_PARAM:
 			if(tp==NULL)
@@ -1033,7 +1033,7 @@ int tr_eval_uri(struct sip_msg *msg, tr_param_t *tp, int subtype,
 				LM_ERR("param invalid parameters\n");
 				return -1;
 			}
-			if(_tr_parsed_uri.params.len<=0)
+			if(_tr_parsed_uri.sip_params.len<=0)
 			{
 				val->rs = _tr_empty;
 				val->flags = PV_VAL_STR;
@@ -1043,7 +1043,7 @@ int tr_eval_uri(struct sip_msg *msg, tr_param_t *tp, int subtype,
 
 			if(_tr_uri_params == NULL)
 			{
-				sv = _tr_parsed_uri.params;
+				sv = _tr_parsed_uri.sip_params;
 				if (parse_params(&sv, CLASS_ANY, &phooks, &_tr_uri_params)<0)
 					return -1;
 			}
diff --git a/modules/ratelimit/ratelimit.c b/modules/ratelimit/ratelimit.c
index 2aab068..8165ff8 100644
--- a/modules/ratelimit/ratelimit.c
+++ b/modules/ratelimit/ratelimit.c
@@ -1189,7 +1189,7 @@ static void rpc_set_queue(rpc_t *rpc, void *c) {
 
 	if (rpc->scan(c, "dSd", &queue_no, &method, &pipe_no) < 3) return;
 
-	if (pipe_no >= MAX_PIPES || pipe_no < 0) {
+	if (pipe_no >= MAX_PIPES || (int)pipe_no < 0) {
 		LM_ERR("Invalid pipe number: %d\n", pipe_no);
 		rpc->fault(c, 400, "Invalid pipe number");
 		return;
diff --git a/modules/registrar/save.c b/modules/registrar/save.c
index fc5d564..caa81df 100644
--- a/modules/registrar/save.c
+++ b/modules/registrar/save.c
@@ -95,7 +95,7 @@ static inline int star(sip_msg_t *_m, udomain_t* _d, str* _a, str *_h)
 {
 	urecord_t* r;
 	ucontact_t* c;
-	
+
 	ul.lock_udomain(_d, _a);
 
 	if (!ul.get_urecord(_d, _a, &r)) {
@@ -114,11 +114,11 @@ static inline int star(sip_msg_t *_m, udomain_t* _d, str* _a, str *_h)
 
 	if (ul.delete_urecord(_d, _a, r) < 0) {
 		LM_ERR("failed to remove record from usrloc\n");
-		
-		     /* Delete failed, try to get corresponding
-		      * record structure and send back all existing
-		      * contacts
-		      */
+
+		/* Delete failed, try to get corresponding
+		 * record structure and send back all existing
+		 * contacts
+		 */
 		rerrno = R_UL_DEL_R;
 		if (!ul.get_urecord(_d, _a, &r)) {
 			build_contact(_m, r->contacts, _h);
@@ -133,7 +133,7 @@ static inline int star(sip_msg_t *_m, udomain_t* _d, str* _a, str *_h)
 
 
 /*! \brief
- */
+*/
 static struct socket_info *get_sock_val(struct sip_msg *msg)
 {
 	struct socket_info *sock;
@@ -179,10 +179,10 @@ static struct socket_info *get_sock_val(struct sip_msg *msg)
 		socks = vavp->val.v.s;
 	}
 	if (parse_phostport( socks.s, &hosts.s, &hosts.len,
-	&port, &proto)!=0) {
+				&port, &proto)!=0) {
 		socks.s[socks.len] = c;
 		LM_ERR("bad socket <%.*s> in \n",
-			socks.len, socks.s);
+				socks.len, socks.s);
 		return 0;
 	}
 	if(sock_hdr_name.len>0 && c!=0) {
@@ -211,7 +211,7 @@ static inline int no_contacts(sip_msg_t *_m, udomain_t* _d, str* _a, str* _h)
 {
 	urecord_t* r;
 	int res;
-	
+
 	ul.lock_udomain(_d, _a);
 	res = ul.get_urecord(_d, _a, &r);
 	if (res < 0) {
@@ -220,7 +220,7 @@ static inline int no_contacts(sip_msg_t *_m, udomain_t* _d, str* _a, str* _h)
 		ul.unlock_udomain(_d, _a);
 		return -1;
 	}
-	
+
 	if (res == 0) {  /* Contacts found */
 		build_contact(_m, r->contacts, _h);
 		ul.release_urecord(r);
@@ -280,7 +280,7 @@ static inline ucontact_info_t* pack_ci( struct sip_msg* _m, contact_t* _c, unsig
 
 		/* set tcp connection id */
 		if (_m->rcv.proto==PROTO_TCP || _m->rcv.proto==PROTO_TLS
-		        || _m->rcv.proto==PROTO_WS  || _m->rcv.proto==PROTO_WSS) {
+				|| _m->rcv.proto==PROTO_WS  || _m->rcv.proto==PROTO_WSS) {
 			ci.tcpconn_id = _m->rcv.proto_reserved1;
 		} else {
 			ci.tcpconn_id = -1;
@@ -288,7 +288,7 @@ static inline ucontact_info_t* pack_ci( struct sip_msg* _m, contact_t* _c, unsig
 
 		/* additional info from message */
 		if (parse_headers(_m, HDR_USERAGENT_F, 0) != -1 && _m->user_agent &&
-		_m->user_agent->body.len>0 && _m->user_agent->body.len<MAX_UA_SIZE) {
+				_m->user_agent->body.len>0 && _m->user_agent->body.len<MAX_UA_SIZE) {
 			ci.user_agent = &_m->user_agent->body;
 		} else {
 			ci.user_agent = &no_ua;
@@ -379,8 +379,8 @@ static inline ucontact_info_t* pack_ci( struct sip_msg* _m, contact_t* _c, unsig
 				if (received_found==0) {
 					memset(&val, 0, sizeof(int_str));
 					if (rcv_avp_name.n!=0
-								&& search_first_avp(rcv_avp_type, rcv_avp_name, &val, 0)
-								&& val.s.len > 0) {
+							&& search_first_avp(rcv_avp_type, rcv_avp_name, &val, 0)
+							&& val.s.len > 0) {
 						if (val.s.len>RECEIVED_MAX_SIZE) {
 							rerrno = R_CONTACT_LEN;
 							LM_ERR("received too long\n");
@@ -574,13 +574,13 @@ error:
 
 
 static int test_max_contacts(struct sip_msg* _m, urecord_t* _r, contact_t* _c,
-										ucontact_info_t *ci, int mc)
+		ucontact_info_t *ci, int mc)
 {
 	int num;
 	int e;
 	ucontact_t* ptr, *cont;
 	int ret;
-	
+
 	num = 0;
 	ptr = _r->contacts;
 	while(ptr) {
@@ -590,7 +590,7 @@ static int test_max_contacts(struct sip_msg* _m, urecord_t* _r, contact_t* _c,
 		ptr = ptr->next;
 	}
 	LM_DBG("%d valid contacts\n", num);
-	
+
 	for( ; _c ; _c = get_next_contact(_c) ) {
 		/* calculate expires */
 		calc_contact_expires(_m, _c->expires, &e);
@@ -610,7 +610,7 @@ static int test_max_contacts(struct sip_msg* _m, urecord_t* _r, contact_t* _c,
 			if (e == 0) num--;
 		}
 	}
-	
+
 	LM_DBG("%d contacts after commit\n", num);
 	if (num > mc) {
 		LM_INFO("too many contacts for AOR <%.*s>\n", _r->aor.len, _r->aor.s);
@@ -668,7 +668,7 @@ static inline int update_contacts(struct sip_msg* _m, urecord_t* _r, int _mode,
 
 #ifdef USE_TCP
 	if ( (_m->flags&tcp_persistent_flag) &&
-	(_m->rcv.proto==PROTO_TCP||_m->rcv.proto==PROTO_TLS||_m->rcv.proto==PROTO_WS||_m->rcv.proto==PROTO_WSS)) {
+			(_m->rcv.proto==PROTO_TCP||_m->rcv.proto==PROTO_TLS||_m->rcv.proto==PROTO_WS||_m->rcv.proto==PROTO_WSS)) {
 		e_max = -1;
 		tcp_check = 1;
 	} else {
@@ -756,15 +756,15 @@ static inline int update_contacts(struct sip_msg* _m, urecord_t* _r, int _mode,
 				/* If call-id has changed then delete all records with this sip.instance
 				   then insert new record */
 				if (ci->instance.s != NULL &&
-					(ci->callid->len != c->callid.len ||
-						strncmp(ci->callid->s, c->callid.s, ci->callid->len) != 0))
+						(ci->callid->len != c->callid.len ||
+						 strncmp(ci->callid->s, c->callid.s, ci->callid->len) != 0))
 				{
 					ptr = _r->contacts;
 					while (ptr)
 					{
 						ptr0 = ptr->next;
 						if ((ptr != c) && ptr->instance.len == c->instance.len &&
-							strncmp(ptr->instance.s, c->instance.s, ptr->instance.len) == 0)
+								strncmp(ptr->instance.s, c->instance.s, ptr->instance.len) == 0)
 						{
 							ul.delete_ucontact(_r, ptr);
 						}
@@ -912,12 +912,12 @@ int save(struct sip_msg* _m, udomain_t* _d, int _cflags, str *_uri)
 	}
 
 	if (reg_outbound_mode != REG_OUTBOUND_NONE
-		&& !(parse_headers(_m, HDR_VIA2_F, 0) == -1 || _m->via2 == 0
-			|| _m->via2->error != PARSE_OK)) {
+			&& !(parse_headers(_m, HDR_VIA2_F, 0) == -1 || _m->via2 == 0
+				|| _m->via2->error != PARSE_OK)) {
 		/* Outbound supported on server, and more than one Via: - not the first hop */
 
 		if (!(parse_headers(_m, HDR_PATH_F, 0) == -1 || _m->path == 0)) {
-		        route = (rr_t *)0;
+			route = (rr_t *)0;
 			if (parse_rr_body(_m->path->body.s, _m->path->body.len, &route) < 0) {
 				LM_ERR("Failed to parse Path: header body\n");
 				goto error;
@@ -949,7 +949,7 @@ int save(struct sip_msg* _m, udomain_t* _d, int _cflags, str *_uri)
 
 		if ((use_ob == 0) && (reg_regid_mode == REG_REGID_OUTBOUND)) {
 			if ((get_supported(_m) & F_OPTION_TAG_OUTBOUND)
-			    && contact->reg_id) {
+					&& contact->reg_id) {
 				LM_WARN("Outbound used by UAC but not supported by edge proxy\n");
 				rerrno = R_OB_UNSUP_EDGE;
 				goto error;
@@ -959,7 +959,7 @@ int save(struct sip_msg* _m, udomain_t* _d, int _cflags, str *_uri)
 			}
 		}
 	}
-	
+
 	get_act_time();
 	c = get_first_contact(_m);
 
@@ -1012,9 +1012,9 @@ int unregister(struct sip_msg* _m, udomain_t* _d, str* _uri, str *_ruid)
 	if (_ruid == NULL) {
 		/* No ruid provided - remove all contacts for aor */
 
-	        if (extract_aor(_uri, &aor, NULL) < 0) {
-		        LM_ERR("failed to extract Address Of Record\n");
-		        return -1;
+		if (extract_aor(_uri, &aor, NULL) < 0) {
+			LM_ERR("failed to extract Address Of Record\n");
+			return -1;
 		}
 
 		u = parse_to_uri(_m);
@@ -1029,36 +1029,37 @@ int unregister(struct sip_msg* _m, udomain_t* _d, str* _uri, str *_ruid)
 	} else {
 		/* ruid provided - remove a specific contact */
 
-	        if (_uri->len > 0) {
+		if (_uri->len > 0) {
 
-		        if (extract_aor(_uri, &aor, NULL) < 0) {
-		                LM_ERR("failed to extract Address Of Record\n");
-		                return -1;
-		        }
+			if (extract_aor(_uri, &aor, NULL) < 0) {
+				LM_ERR("failed to extract Address Of Record\n");
+				return -1;
+			}
 
-		        if (ul.get_urecord_by_ruid(_d, ul.get_aorhash(&aor),
-						   _ruid, &r, &c) != 0) {
-			        LM_WARN("AOR/Contact not found\n");
-			        return -1;
+			if (ul.get_urecord_by_ruid(_d, ul.get_aorhash(&aor),
+						_ruid, &r, &c) != 0) {
+				LM_WARN("AOR/Contact not found\n");
+				return -1;
 			}
 			if (ul.delete_ucontact(r, c) != 0) {
-			        LM_WARN("could not delete contact\n");
-			        return -1;
+				ul.unlock_udomain(_d, &aor);
+				LM_WARN("could not delete contact\n");
+				return -1;
 			}
 			ul.unlock_udomain(_d, &aor);
 
 		} else {
 
-   		        res = ul.delete_urecord_by_ruid(_d, _ruid);
+			res = ul.delete_urecord_by_ruid(_d, _ruid);
 			switch (res) {
-			case -1:
-			        LM_ERR("could not delete contact\n");
-			        return -1;
-			case -2:
-			        LM_WARN("contact not found\n");
-			        return -1;
-			default:
-			        return 1;
+				case -1:
+					LM_ERR("could not delete contact\n");
+					return -1;
+				case -2:
+					LM_WARN("contact not found\n");
+					return -1;
+				default:
+					return 1;
 			}
 
 		}
diff --git a/modules/sdpops/sdpops_mod.c b/modules/sdpops/sdpops_mod.c
index a506fc6..16f2278 100644
--- a/modules/sdpops/sdpops_mod.c
+++ b/modules/sdpops/sdpops_mod.c
@@ -168,8 +168,8 @@ int sdp_remove_str_codec_id_attrs(sip_msg_t* msg,
 	payload = sdp_stream->payload_attr;
 	while (payload) {
 		LM_DBG("a= ... for codec %.*s/%.*s\n",
-			payload->rtp_payload.len, payload->rtp_payload.s,
-			payload->rtp_enc.len, payload->rtp_enc.s);
+				payload->rtp_payload.len, payload->rtp_payload.s,
+				payload->rtp_enc.len, payload->rtp_enc.s);
 		if(rm_codec->len==payload->rtp_payload.len
 				&& strncmp(payload->rtp_payload.s, rm_codec->s,
 					rm_codec->len)==0) {
@@ -181,8 +181,8 @@ int sdp_remove_str_codec_id_attrs(sip_msg_t* msg,
 							aline.len, 0);
 					if (anchor == NULL) {
 						LM_ERR("failed to remove [%.*s] inside [%.*s]\n",
-							rm_codec->len, rm_codec->s,
-							aline.len, aline.s);
+								rm_codec->len, rm_codec->s,
+								aline.len, aline.s);
 						return -1;
 					}
 				}
@@ -195,8 +195,8 @@ int sdp_remove_str_codec_id_attrs(sip_msg_t* msg,
 							aline.len, 0);
 					if (anchor == NULL) {
 						LM_ERR("failed to remove [%.*s] inside [%.*s]\n",
-							rm_codec->len, rm_codec->s,
-							aline.len, aline.s);
+								rm_codec->len, rm_codec->s,
+								aline.len, aline.s);
 						return -1;
 					}
 				}
@@ -226,7 +226,7 @@ int sdp_codec_in_str(str *allcodecs, str* codec, char delim)
 			if(codec->len <= allcodecs->len-i) {
 				if(strncmp(&allcodecs->s[i], codec->s, codec->len)==0) {
 					if(&allcodecs->s[i+codec->len]
-									== &allcodecs->s[allcodecs->len]
+							== &allcodecs->s[allcodecs->len]
 							|| allcodecs->s[i+codec->len] == delim) {
 						/* match */
 						return 1;
@@ -263,12 +263,12 @@ int sdp_remove_str_codec_id(sip_msg_t* msg, str *allcodecs, str* rmcodec)
 			if(rmcodec->len <= allcodecs->len-i) {
 				if(strncmp(&allcodecs->s[i], rmcodec->s, rmcodec->len)==0) {
 					if(&allcodecs->s[i+rmcodec->len]
-									== &allcodecs->s[allcodecs->len]
+							== &allcodecs->s[allcodecs->len]
 							|| allcodecs->s[i+rmcodec->len] == ' ') {
 						/* match - remove also the space before codec id */
 						LM_DBG("found codec [%.*s] inside [%.*s]\n",
-									rmcodec->len, rmcodec->s,
-									allcodecs->len, allcodecs->s);
+								rmcodec->len, rmcodec->s,
+								allcodecs->len, allcodecs->s);
 						anchor = del_lump(msg, &allcodecs->s[i-1] - msg->buf,
 								rmcodec->len+1, 0);
 						if (anchor == NULL) {
@@ -332,8 +332,8 @@ int sdp_remove_codecs_by_id(sip_msg_t* msg, str* codecs)
 			if(!sdp_stream) break;
 
 			LM_DBG("stream %d of %d - payloads [%.*s]\n",
-				sdp_stream_num, sdp_session_num, 
-				sdp_stream->payloads.len, sdp_stream->payloads.s);
+					sdp_stream_num, sdp_session_num, 
+					sdp_stream->payloads.len, sdp_stream->payloads.s);
 			sdp_codecs = sdp_stream->payloads;
 			tmp_codecs = *codecs;
 			while(str_find_token(&tmp_codecs, &rm_codec, ',')==0
@@ -598,8 +598,8 @@ int sdp_keep_codecs_by_id(sip_msg_t* msg, str* codecs, str *media)
 			if(!sdp_stream) break;
 
 			LM_DBG("stream %d of %d - payloads [%.*s]\n",
-				sdp_stream_num, sdp_session_num,
-				sdp_stream->payloads.len, sdp_stream->payloads.s);
+					sdp_stream_num, sdp_session_num,
+					sdp_stream->payloads.len, sdp_stream->payloads.s);
 			if((media==NULL)
 					|| (media->len==sdp_stream->media.len
 						&& strncasecmp(sdp_stream->media.s, media->s,
@@ -615,8 +615,8 @@ int sdp_keep_codecs_by_id(sip_msg_t* msg, str* codecs, str *media)
 
 					if(sdp_codec_in_str(codecs, &rm_codec, ',')==0) {
 						LM_DBG("codecs [%.*s] - remove [%.*s]\n",
-							sdp_codecs.len, sdp_codecs.s,
-							rm_codec.len, rm_codec.s);
+								sdp_codecs.len, sdp_codecs.s,
+								rm_codec.len, rm_codec.s);
 						sdp_remove_str_codec_id(msg, &sdp_codecs, &rm_codec);
 						sdp_remove_str_codec_id_attrs(msg, sdp_stream, &rm_codec);
 					}
@@ -761,11 +761,11 @@ static int sdp_with_media(sip_msg_t *msg, str *media)
 			if(!sdp_stream) break;
 
 			LM_DBG("stream %d of %d - media [%.*s]\n",
-				sdp_stream_num, sdp_session_num,
-				sdp_stream->media.len, sdp_stream->media.s);
+					sdp_stream_num, sdp_session_num,
+					sdp_stream->media.len, sdp_stream->media.s);
 			if(media->len==sdp_stream->media.len
 					&& strncasecmp(sdp_stream->media.s, media->s,
-							media->len)==0)
+						media->len)==0)
 				return 1;
 			sdp_stream_num++;
 		}
@@ -838,16 +838,16 @@ static int sdp_remove_media(sip_msg_t *msg, str *media)
 			if(!sdp_stream) break;
 
 			LM_DBG("stream %d of %d - media [%.*s]\n",
-				sdp_stream_num, sdp_session_num,
-				sdp_stream->media.len, sdp_stream->media.s);
+					sdp_stream_num, sdp_session_num,
+					sdp_stream->media.len, sdp_stream->media.s);
 			if(media->len==sdp_stream->media.len
 					&& strncasecmp(sdp_stream->media.s, media->s,
-							media->len)==0)
+						media->len)==0)
 			{
 				/* found - remove */
 				LM_DBG("removing media stream: %.*s", media->len, media->s);
 				nxt_stream = get_sdp_stream(msg, sdp_session_num,
-								sdp_stream_num+1);
+						sdp_stream_num+1);
 				/* skip back 'm=' */
 				dstart = sdp_stream->media.s - 2;
 				if(!nxt_stream) {
@@ -860,7 +860,7 @@ static int sdp_remove_media(sip_msg_t *msg, str *media)
 				anchor = del_lump(msg, dstart - msg->buf, dlen, 0);
 				if (anchor == NULL) {
 					LM_ERR("failed to remove media type [%.*s]\n",
-						 media->len, media->s);
+							media->len, media->s);
 					return -1;
 				}
 
@@ -930,11 +930,11 @@ static int sdp_with_transport(sip_msg_t *msg, str *transport)
 			if(!sdp_stream) break;
 
 			LM_DBG("stream %d of %d - transport [%.*s]\n",
-				sdp_stream_num, sdp_session_num,
-				sdp_stream->transport.len, sdp_stream->transport.s);
+					sdp_stream_num, sdp_session_num,
+					sdp_stream->transport.len, sdp_stream->transport.s);
 			if(transport->len==sdp_stream->transport.len
 					&& strncasecmp(sdp_stream->transport.s, transport->s,
-							transport->len)==0)
+						transport->len)==0)
 				return 1;
 			sdp_stream_num++;
 		}
@@ -1007,16 +1007,16 @@ static int sdp_remove_transport(sip_msg_t *msg, str *transport)
 			if(!sdp_stream) break;
 
 			LM_DBG("stream %d of %d - transport [%.*s]\n",
-				sdp_stream_num, sdp_session_num,
-				sdp_stream->transport.len, sdp_stream->transport.s);
+					sdp_stream_num, sdp_session_num,
+					sdp_stream->transport.len, sdp_stream->transport.s);
 			if(transport->len==sdp_stream->transport.len
 					&& strncasecmp(sdp_stream->transport.s, transport->s,
-							transport->len)==0)
+						transport->len)==0)
 			{
 				/* found - remove */
 				LM_DBG("removing transport stream: %.*s", transport->len, transport->s);
 				nxt_stream = get_sdp_stream(msg, sdp_session_num,
-								sdp_stream_num+1);
+						sdp_stream_num+1);
 				/* skip back 'm=' */
 				dstart = sdp_stream->media.s - 2;
 				if(!nxt_stream) {
@@ -1029,7 +1029,7 @@ static int sdp_remove_transport(sip_msg_t *msg, str *transport)
 				anchor = del_lump(msg, dstart - msg->buf, dlen, 0);
 				if (anchor == NULL) {
 					LM_ERR("failed to remove transport type [%.*s]\n",
-						 transport->len, transport->s);
+							transport->len, transport->s);
 					return -1;
 				}
 
@@ -1111,8 +1111,8 @@ int sdp_with_codecs_by_id(sip_msg_t* msg, str* codecs)
 			if(!sdp_stream) break;
 
 			LM_DBG("stream %d of %d - payloads [%.*s]\n",
-				sdp_stream_num, sdp_session_num,
-				sdp_stream->payloads.len, sdp_stream->payloads.s);
+					sdp_stream_num, sdp_session_num,
+					sdp_stream->payloads.len, sdp_stream->payloads.s);
 			sdp_codecs = sdp_stream->payloads;
 			tmp_codecs = *codecs;
 			while(str_find_token(&tmp_codecs, &fnd_codec, ',')==0
@@ -1123,13 +1123,13 @@ int sdp_with_codecs_by_id(sip_msg_t* msg, str* codecs)
 
 				if(sdp_codec_in_str(&sdp_codecs, &fnd_codec, ' ')==0) {
 					LM_DBG("codecs [%.*s] - not found [%.*s]\n",
-						sdp_codecs.len, sdp_codecs.s,
-						fnd_codec.len, fnd_codec.s);
+							sdp_codecs.len, sdp_codecs.s,
+							fnd_codec.len, fnd_codec.s);
 					notfound = 1;
 				} else {
 					LM_DBG("codecs [%.*s] - found [%.*s]\n",
-						sdp_codecs.len, sdp_codecs.s,
-						fnd_codec.len, fnd_codec.s);
+							sdp_codecs.len, sdp_codecs.s,
+							fnd_codec.len, fnd_codec.s);
 					foundone = 1;
 				}
 			}
@@ -1250,7 +1250,7 @@ static int w_sdp_get(sip_msg_t* msg, char *avp)
 	str s;
 	pv_spec_t *avp_spec = NULL;
 	int sdp_missing=1;
-	
+
 	s.s = avp; s.len = strlen(s.s);
 	if (pv_locate_name(&s) != s.len)
 	{
@@ -1275,7 +1275,7 @@ static int w_sdp_get(sip_msg_t* msg, char *avp)
 		return -1;
 	}
 	sdp = (sdp_info_t*)msg->body;
-	
+
 	if (sdp_missing) {
 		LM_DBG("No SDP\n");
 		return -2;
@@ -1286,10 +1286,10 @@ static int w_sdp_get(sip_msg_t* msg, char *avp)
 	}
 	if (add_avp(AVP_VAL_STR | avp_type, avp_name, avp_val) != 0)
 	{
-	  LM_ERR("Failed to add SDP avp");
-	  return -1;
+		LM_ERR("Failed to add SDP avp");
+		return -1;
 	}
-	
+
 	return 1;
 }
 
@@ -1314,16 +1314,16 @@ static int w_sdp_get_line_startswith(sip_msg_t *msg, char *avp, char *s_line)
 	char* p = NULL;
 	str s;
 	str sline;
-        int_str avp_val;
-        int_str avp_name;
-        pv_spec_t *avp_spec = NULL;
-        static unsigned short avp_type = 0;
+	int_str avp_val;
+	int_str avp_name;
+	pv_spec_t *avp_spec = NULL;
+	static unsigned short avp_type = 0;
 	int sdp_missing=1;
 
 	if (s_line == NULL || strlen(s_line) <= 0)
 	{
 		LM_ERR("Search string is null or empty\n");
-		    return -1;
+		return -1;
 	}
 	sline.s = s_line;
 	sline.len = strlen(s_line);
@@ -1337,10 +1337,10 @@ static int w_sdp_get_line_startswith(sip_msg_t *msg, char *avp, char *s_line)
 
 	sdp = (sdp_info_t *)msg->body;
 
-        if (sdp_missing || sdp == NULL)
+	if (sdp_missing || sdp == NULL)
 	{
-                LM_DBG("No SDP\n");
-                return -2;
+		LM_DBG("No SDP\n");
+		return -2;
 	}
 
 	body.s = sdp->raw_sdp.s;
@@ -1360,29 +1360,29 @@ static int w_sdp_get_line_startswith(sip_msg_t *msg, char *avp, char *s_line)
 	if (avp == NULL || strlen(avp) <= 0)
 	{
 		LM_ERR("avp variable is null or empty\n");
-		    return -1;
+		return -1;
 	}
 
 	s.s = avp;
 	s.len = strlen(s.s);
 
 	if (pv_locate_name(&s) != s.len)
-        {
-                LM_ERR("invalid parameter\n");
-                return -1;
-        }
-
-        if (((avp_spec = pv_cache_get(&s)) == NULL)
-                        || avp_spec->type!=PVT_AVP) {
-                LM_ERR("malformed or non AVP %s AVP definition\n", avp);
-                return -1;
-        }
-
-        if(pv_get_avp_name(0, &avp_spec->pvp, &avp_name, &avp_type)!=0)
-        {
-                LM_ERR("[%s]- invalid AVP definition\n", avp);
-                return -1;
-        }
+	{
+		LM_ERR("invalid parameter\n");
+		return -1;
+	}
+
+	if (((avp_spec = pv_cache_get(&s)) == NULL)
+			|| avp_spec->type!=PVT_AVP) {
+		LM_ERR("malformed or non AVP %s AVP definition\n", avp);
+		return -1;
+	}
+
+	if(pv_get_avp_name(0, &avp_spec->pvp, &avp_name, &avp_type)!=0)
+	{
+		LM_ERR("[%s]- invalid AVP definition\n", avp);
+		return -1;
+	}
 
 	p = find_sdp_line(body.s, body.s+body.len, sline.s[0]);
 	while (p != NULL)
@@ -1395,21 +1395,21 @@ static int w_sdp_get_line_startswith(sip_msg_t *msg, char *avp, char *s_line)
 
 		if (strncmp(line.s, sline.s, sline.len) == 0)
 		{
-            		avp_val.s.s = line.s;
-            		avp_val.s.len = line.len;
+			avp_val.s.s = line.s;
+			avp_val.s.len = line.len;
 
-			// remove ending \r\n if exists
+			/* skip ending \r\n if exists */
 			if (avp_val.s.s[line.len-2] == '\r' && avp_val.s.s[line.len-1] == '\n')
 			{
-			    avp_val.s.s[line.len-2] = '\0';
-			    avp_val.s.len -= 2;
+				/* add_avp() clones to shm and adds 0-terminating char */
+				avp_val.s.len -= 2;
 			}
 
-    			if (add_avp(AVP_VAL_STR | avp_type, avp_name, avp_val) != 0)
-    			{
-        		    LM_ERR("Failed to add SDP line avp");
-        		    return -1;
-    			}
+			if (add_avp(AVP_VAL_STR | avp_type, avp_name, avp_val) != 0)
+			{
+				LM_ERR("Failed to add SDP line avp");
+				return -1;
+			}
 
 			return 1;
 		}
diff --git a/modules/sipcapture/sipcapture.c b/modules/sipcapture/sipcapture.c
index 932ba4d..dc46ab8 100644
--- a/modules/sipcapture/sipcapture.c
+++ b/modules/sipcapture/sipcapture.c
@@ -486,7 +486,7 @@ int capture_mode_set_params (_capture_mode_data_t * n, str * params){
 		}
 
 		else if (pit->name.len == 10 && strncmp (pit->name.s, "table_name", pit->name.len)==0){
-			if ((n->no_tables = parse_table_names(pit->body, &n->table_names))<0){
+			if ((int)(n->no_tables = parse_table_names(pit->body, &n->table_names))<0){
 				LM_ERR("parsing capture_mode: table name parsing failed\n");
 				goto error;
 			}
@@ -781,14 +781,14 @@ static int mod_init(void) {
 	while (c){
 		/*for the default capture_mode, don't add it's name to the stat name*/
 		def = (capture_def && c == capture_def)?1:0;
-		stat_name = (char *)shm_malloc(sizeof (char) * snprintf(NULL, 0 , (def)?"captured_requests":"captured_requests[%.*s]", c->name.len, c->name.s) + 1);
-		sprintf(stat_name, (def)?"captured_requests":"captured_requests[%.*s]", c->name.len, c->name.s);
+		stat_name = (char *)shm_malloc(sizeof (char) * (snprintf(NULL, 0 , (def)?"captured_requests%.*s":"captured_requests[%.*s]", (def)?0:c->name.len, (def)?"":c->name.s) + 1));
+		sprintf(stat_name, (def)?"captured_requests%.*s":"captured_requests[%.*s]", (def)?0:c->name.len, (def)?"":c->name.s);
 		stats[i].name = stat_name;
 		stats[i].flags = 0;
 		stats[i].stat_pointer = &c->sipcapture_req;
 		i++;
-		stat_name = (char *)shm_malloc(sizeof (char) * snprintf(NULL, 0 , (def)?"captured_replies":"captured_replies[%.*s]", c->name.len, c->name.s) + 1);
-		sprintf(stat_name, (def)?"captured_replies":"captured_replies[%.*s]", c->name.len, c->name.s);
+		stat_name = (char *)shm_malloc(sizeof (char) * (snprintf(NULL, 0 , (def)?"captured_replies%.*s":"captured_replies[%.*s]", (def)?0:c->name.len, (def)?"":c->name.s) + 1));
+		sprintf(stat_name, (def)?"captured_replies%.*s":"captured_replies[%.*s]", (def)?0:c->name.len, (def)?"":c->name.s);
 		stats[i].name = stat_name;
 		stats[i].flags = 0;
 		stats[i].stat_pointer = &c->sipcapture_rpl;
@@ -1017,7 +1017,8 @@ static int child_init(int rank)
                 LM_ERR("no more pkg memory left\n");
                 return -1;
         }
-
+        
+	heptime->tv_sec = 0;
 
 	return 0;
 }
diff --git a/modules/snmpstats/Makefile b/modules/snmpstats/Makefile
index 2fd7f6c..0778be1 100644
--- a/modules/snmpstats/Makefile
+++ b/modules/snmpstats/Makefile
@@ -42,7 +42,7 @@ SERLIBPATH=../../lib
 SER_LIBS+=$(SERLIBPATH)/kcore/kcore
 include ../../Makefile.modules
 
-install_module_custom:
+install-cfg:
 	echo "installing mibs ..."
 	mkdir -p $(INSTALLMIBDIR)
 	$(INSTALL_CFG) mibs/KAMAILIO* $(INSTALLMIBDIR)
diff --git a/modules/snmpstats/mibs/KAMAILIO-TC b/modules/snmpstats/mibs/KAMAILIO-TC
index 81d1459..171c491 100644
--- a/modules/snmpstats/mibs/KAMAILIO-TC
+++ b/modules/snmpstats/mibs/KAMAILIO-TC
@@ -62,7 +62,7 @@ KamailioSIPTransportProtocol ::= TEXTUAL-CONVENTION
                             tcp(2),
                             sctp(3),
                             tls(4),
-                            sctp_tls(5),
+                            sctptls(5),
 			    ws(6),
 			    wss(7)
            }
@@ -79,14 +79,13 @@ KamailioSIPEntityRole ::= TEXTUAL-CONVENTION
 		operation of a SIP outbound edge proxy node.
 		Kamailio adds the role 'sipcaptureServer' for
 		operation of a Homer SIPcapture node."
-		"
            SYNTAX BITS {
                             other(0),
                             userAgent(1),
                             proxyServer(2),
                             redirectServer(3),
-                            registrarServer(4)
-                            edgeproxyServer(5)
+                            registrarServer(4),
+                            edgeproxyServer(5),
                             sipcaptureServer(6)
            }
 
diff --git a/modules/tls/tls_cfg.c b/modules/tls/tls_cfg.c
index c92f742..fbf3ab3 100644
--- a/modules/tls/tls_cfg.c
+++ b/modules/tls/tls_cfg.c
@@ -2,6 +2,7 @@
  * TLS module
  *
  * Copyright (C) 2010 iptelorg GmbH
+ * Copyright (C) 2013 Motorola Solutions, Inc.
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -76,7 +77,7 @@ struct cfg_group_tls default_tls_cfg = {
 	0 /* send_close_notify (off by default)*/
 };
 
-void* tls_cfg = &default_tls_cfg;
+volatile void* tls_cfg = &default_tls_cfg;
 
 
 /* if *to<0 to=default_val, else if to>max_val to=max_val */
diff --git a/modules/tls/tls_cfg.h b/modules/tls/tls_cfg.h
index f7a4c4e..4aeb5f5 100644
--- a/modules/tls/tls_cfg.h
+++ b/modules/tls/tls_cfg.h
@@ -2,6 +2,7 @@
  * TLS module
  * 
  * Copyright (C) 2010 iptelorg GmbH
+ * Copyright (C) 2013 Motorola Solutions, Inc.
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -101,7 +102,7 @@ struct cfg_group_tls {
 
 
 extern struct cfg_group_tls default_tls_cfg;
-extern void* tls_cfg;
+extern volatile void* tls_cfg;
 extern cfg_def_t tls_cfg_def[];
 
 
diff --git a/modules/tls/tls_config.c b/modules/tls/tls_config.c
index f05c211..7937876 100644
--- a/modules/tls/tls_config.c
+++ b/modules/tls/tls_config.c
@@ -84,7 +84,7 @@ static int parse_ipv4(struct ip_addr* ip, cfg_token_t* token,
 	ip->len = 4;
 
 	if (str2int(&token->val, &v) < 0) goto err;
-	if (v < 0 || v > 255) goto err;
+	if (v > 255) goto err;
 
 	ip->u.addr[0] = v;
 
@@ -97,7 +97,7 @@ static int parse_ipv4(struct ip_addr* ip, cfg_token_t* token,
 		if (ret < 0) return -1;
 		if (ret > 0 || t.type != CFG_TOKEN_ALPHA) goto err;
 		if (str2int(&t.val, &v) < 0)  goto err;
-		if (v < 0 || v > 255) goto err;
+		if (v > 255) goto err;
 		ip->u.addr[i] = v;
 	}
 
diff --git a/modules/tls/tls_domain.c b/modules/tls/tls_domain.c
index b8362f4..b832c63 100644
--- a/modules/tls/tls_domain.c
+++ b/modules/tls/tls_domain.c
@@ -2,6 +2,7 @@
  * TLS module
  *
  * Copyright (C) 2005,2006 iptelorg GmbH
+ * Copyright (C) 2013 Motorola Solutions, Inc.
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -23,7 +24,6 @@
  * Module: @ref tls
  */
 
-
 #include <stdlib.h>
 #include <openssl/ssl.h>
 #include <openssl/opensslv.h>
@@ -119,6 +119,7 @@ void tls_free_cfg(tls_domains_cfg_t* cfg)
 	}
 	if (cfg->srv_default) tls_free_domain(cfg->srv_default);
 	if (cfg->cli_default) tls_free_domain(cfg->cli_default);
+	shm_free(cfg);
 }
 
 
diff --git a/modules/tls/tls_domain.h b/modules/tls/tls_domain.h
index 15652bc..38c5087 100644
--- a/modules/tls/tls_domain.h
+++ b/modules/tls/tls_domain.h
@@ -2,6 +2,7 @@
  * TLS module
  *
  * Copyright (C) 2005,2006 iptelorg GmbH
+ * Copyright (C) 2013 Motorola Solutions, Inc.
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -99,7 +100,7 @@ typedef struct tls_domains_cfg {
 	tls_domain_t* srv_list;    /**< Server domain list */
 	tls_domain_t* cli_list;    /**< Client domain list */
 	struct tls_domains_cfg* next; /**< Next element in the garbage list */
-	int ref_count;             /**< How many connections use this configuration */
+	volatile int ref_count;             /**< How many connections use this configuration */
 } tls_domains_cfg_t;
 
 
diff --git a/modules/tls/tls_mod.c b/modules/tls/tls_mod.c
index d8e30b3..b206bf6 100644
--- a/modules/tls/tls_mod.c
+++ b/modules/tls/tls_mod.c
@@ -2,6 +2,7 @@
  * TLS module
  *
  * Copyright (C) 2007 iptelorg GmbH 
+ * Copyright (C) Motorola Solutions, Inc.
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -278,7 +279,7 @@ static int mod_init(void)
 	}
 	/* declare configuration */
 	if (cfg_declare("tls", tls_cfg_def, &default_tls_cfg,
-							cfg_sizeof(tls), &tls_cfg)) {
+							cfg_sizeof(tls), (void **)&tls_cfg)) {
 		ERR("failed to register the configuration\n");
 		return -1;
 	}
diff --git a/modules/tls/tls_rpc.c b/modules/tls/tls_rpc.c
index 458a215..c7c994d 100644
--- a/modules/tls/tls_rpc.c
+++ b/modules/tls/tls_rpc.c
@@ -2,6 +2,7 @@
  * TLS module - management interface
  *
  * Copyright (C) 2005 iptelorg GmbH
+ * Copyright (C) 2013 Motorola Solutions, Inc.
  *
  * This file is part of sip-router, a free SIP server.
  *
@@ -56,10 +57,11 @@ static void tls_reload(rpc_t* rpc, void* ctx)
 		return;
 	}
 
-	     /* Try to delete old configurations first */
+	/* Try to delete old configurations first */
 	collect_garbage();
 
 	cfg = tls_load_config(&tls_domains_cfg_file);
+
 	if (!cfg) {
 		rpc->fault(ctx, 500, "Error while loading TLS configuration file"
 							" (consult server log)");
@@ -78,8 +80,14 @@ static void tls_reload(rpc_t* rpc, void* ctx)
 	}
 
 	DBG("TLS configuration successfuly loaded");
+
+	lock_get(tls_domains_cfg_lock);
+
 	cfg->next = (*tls_domains_cfg);
 	*tls_domains_cfg = cfg;
+
+	lock_release(tls_domains_cfg_lock);
+
 	return;
 
  error:
diff --git a/modules/tls/tls_server.c b/modules/tls/tls_server.c
index 4b8db14..cfd09c4 100644
--- a/modules/tls/tls_server.c
+++ b/modules/tls/tls_server.c
@@ -2,6 +2,7 @@
  * TLS module - main server part
  *
  * Copyright (C) 2005-2010 iptelorg GmbH
+ * Copyright (C) 2013 Motorola Solutions, Inc.
  *
  * This file is part of SIP-router, a free SIP server.
  *
@@ -148,13 +149,10 @@ static int tls_complete_init(struct tcp_connection* c)
 		goto error2;
 	}
 	     /* Get current TLS configuration and increase reference
-	      * count immediately. There is no need to lock the structure
-	      * here, because it does not get deleted immediately. When
-	      * SER reloads TLS configuration it will put the old configuration
-	      * on a garbage queue and delete it later, so we know here that
-	      * the pointer we get from *tls_domains_cfg will be valid for a while,
-		  * at least by the time this function finishes
+	      * count immediately.
 	      */
+
+	lock_get(tls_domains_cfg_lock);
 	cfg = *tls_domains_cfg;
 
 	     /* Increment the reference count in the configuration structure, this
@@ -162,6 +160,7 @@ static int tls_complete_init(struct tcp_connection* c)
 	      * not get deleted if there are still connection referencing its SSL_CTX
 	      */
 	cfg->ref_count++;
+	lock_release(tls_domains_cfg_lock);
 
 	if (c->flags & F_CONN_PASSIVE) {
 		state=S_TLS_ACCEPTING;
diff --git a/modules/tls/tls_util.c b/modules/tls/tls_util.c
index d8ffba2..88416a1 100644
--- a/modules/tls/tls_util.c
+++ b/modules/tls/tls_util.c
@@ -2,6 +2,7 @@
  * TLS module
  *
  * Copyright (C) 2005 iptelorg GmbH
+ * Copyright (C) 2013 Motorola Solutions, Inc.
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -16,6 +17,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+
 #define _GNU_SOURCE 1 /* Needed for strndup */
 
 #include <string.h>
@@ -66,7 +68,7 @@ int shm_asciiz_dup(char** dest, char* val)
  */
 void collect_garbage(void)
 {
-	tls_domains_cfg_t* prev, *cur;
+	tls_domains_cfg_t *prev, *cur, *next;
 
 	     /* Make sure we do not run two garbage collectors
 	      * at the same time
@@ -80,14 +82,16 @@ void collect_garbage(void)
 	cur = (*tls_domains_cfg)->next;
 
 	while(cur) {
+		next = cur->next;
 		if (cur->ref_count == 0) {
-			     /* Not referenced by any existing connection */
+			/* Not referenced by any existing connection */
 			prev->next = cur->next;
 			tls_free_cfg(cur);
+		} else {
+			/* Only update prev if we didn't remove cur */
+			prev = cur;
 		}
-
-		prev = cur;
-		cur = cur->next;
+		cur = next;
 	}
 
 	lock_release(tls_domains_cfg_lock);
diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c
index 562b583..4d9901d 100644
--- a/modules/tm/t_reply.c
+++ b/modules/tm/t_reply.c
@@ -1093,7 +1093,7 @@ int run_branch_failure_handlers(struct cell *t, struct sip_msg *rpl,
 
 	/* failure_route for a local UAC? */
 	if (!shmem_msg) {
-		LOG(L_WARN,"Warning: run_branch_failure_handlers: no UAC support (%d, %d) \n",
+		LOG(L_WARN,"no UAC support (%d, %d) \n",
 			on_branch_failure, t->tmcb_hl.reg_types);
 		return 0;
 	}
@@ -1101,13 +1101,13 @@ int run_branch_failure_handlers(struct cell *t, struct sip_msg *rpl,
 	/* don't start faking anything if we don't have to */
 	if (unlikely((on_branch_failure < 0) && !has_tran_tmcbs( t, TMCB_ON_BRANCH_FAILURE))) {
 		LOG(L_WARN,
-			"Warning: run_failure_handlers: no branch_failure handler (%d, %d)\n",
+			"no branch_failure handler (%d, %d)\n",
 			on_branch_failure, t->tmcb_hl.reg_types);
 		return 1;
 	}
 
 	if (!fake_req(&faked_req, shmem_msg, extra_flags, &t->uac[picked_branch])) {
-		LOG(L_ERR, "ERROR: run_branch_failure_handlers: fake_req failed\n");
+		LOG(L_ERR, "fake_req failed\n");
 		return 0;
 	}
 	/* fake also the env. conforming to the fake msg */
@@ -1124,7 +1124,7 @@ int run_branch_failure_handlers(struct cell *t, struct sip_msg *rpl,
 		if (exec_pre_script_cb(&faked_req, BRANCH_FAILURE_CB_TYPE)>0) {
 			/* run a branch_failure_route action if some was marked */
 			if (run_top_route(event_rt.rlist[on_branch_failure], &faked_req, 0)<0)
-				LOG(L_ERR, "ERROR: run_branch_failure_handlers: Error in run_top_route\n");
+				LOG(L_ERR, "error in run_top_route\n");
 			exec_post_script_cb(&faked_req, BRANCH_FAILURE_CB_TYPE);
 		}
 		/* update message flags, if changed in branch_failure route */
@@ -1357,9 +1357,9 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
 		/* also append the current reply to the transaction to
 		 * make it available in failure routes - a kind of "fake"
 		 * save of the final reply per branch */
-		Trans->uac[branch].reply = reply;
 		if (unlikely(has_tran_tmcbs( Trans, TMCB_ON_BRANCH_FAILURE_RO|TMCB_ON_BRANCH_FAILURE)
-						|| (Trans->uac[picked_branch].on_branch_failure) )) {
+						|| (Trans->uac[branch].on_branch_failure) )) {
+			Trans->uac[branch].reply = reply;
 			extra_flags=
 				((Trans->uac[branch].request.flags & F_RB_TIMEOUT)?
 							FL_TIMEOUT:0) | 
@@ -1369,6 +1369,7 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
 			picked_branch = branch;
 			run_branch_failure_handlers( Trans, Trans->uac[branch].reply,
 									new_code, extra_flags);
+			Trans->uac[branch].reply = 0;
 		}
 
 
diff --git a/modules/tm/t_serial.c b/modules/tm/t_serial.c
index 93c7480..62200ad 100644
--- a/modules/tm/t_serial.c
+++ b/modules/tm/t_serial.c
@@ -488,14 +488,24 @@ int t_next_contacts(struct sip_msg* msg, char* key, char* value)
 		il->next = (struct instance_list *)0;
 		set_instance(msg, &instance);
 	} else {
+		instance.s = 0;
 		instance.len = 0;
 	}
 
 	vavp = xavp_get(&ruid_name, xavp->val.v.xavp);
-	ruid = vavp->val.v.s;
-
+	if (vavp != NULL) {
+		ruid = vavp->val.v.s;
+	} else {
+		ruid.s = 0;
+		ruid.len = 0;
+	}
 	vavp = xavp_get(&ua_name, xavp->val.v.xavp);
-	location_ua = vavp->val.v.s;
+	if (vavp != NULL) {
+		location_ua = vavp->val.v.s;
+	} else {
+		location_ua.s = 0;
+		location_ua.len = 0;
+	}
 
 	/* Rewrite Request-URI */
 	rewrite_uri(msg, &uri);
@@ -582,10 +592,20 @@ int t_next_contacts(struct sip_msg* msg, char* key, char* value)
 		flags = vavp->val.v.i;
 
 		vavp = xavp_get(&ruid_name, xavp->val.v.xavp);
-		ruid = vavp->val.v.s;
+		if (vavp != NULL) {
+			ruid = vavp->val.v.s;
+		} else {
+			ruid.s = 0;
+			ruid.len = 0;
+		}
 
 		vavp = xavp_get(&ua_name, xavp->val.v.xavp);
-		location_ua = vavp->val.v.s;
+		if (vavp != NULL) {
+			location_ua = vavp->val.v.s;
+		} else {
+			location_ua.s = 0;
+			location_ua.len = 0;
+		}
 
 		vavp = xavp_get(&instance_name, xavp->val.v.xavp);
 		if (vavp != NULL) {
@@ -623,6 +643,7 @@ int t_next_contacts(struct sip_msg* msg, char* key, char* value)
 				il = ilp;
 			}
 		} else {
+			instance.s = 0;
 			instance.len = 0;
 		}
 
@@ -632,7 +653,8 @@ int t_next_contacts(struct sip_msg* msg, char* key, char* value)
 				dst_uri.len, (dst_uri.len > 0)?dst_uri.s:"",
 				path.len, (path.len>0)?path.s:"",
 				instance.len, (instance.len>0)?instance.s:"",
-				ruid.len, ruid.s, location_ua.len, location_ua.s);
+				ruid.len, (ruid.len>0)?ruid.s:"",
+				location_ua.len, (location_ua.len>0)?location_ua.s:"");
 		if (append_branch(msg, &uri, &dst_uri, &path, 0, flags, sock, &instance, 0,
 					&ruid, &location_ua) != 1) {
 			LM_ERR("appending branch failed\n");
diff --git a/modules/tmrec/README b/modules/tmrec/README
index 6cffee0..84b7a56 100644
--- a/modules/tmrec/README
+++ b/modules/tmrec/README
@@ -138,7 +138,7 @@ modparam("tmrec", "separator", ";")
        subsequent intervals do not overlap. For non-recurring intervals,
        durations of any positive length are permitted. Zero-length
        duration means "forever". Negative-length durations are not
-       allowed.
+       allowed. See RFC 2445 for the format of duration.
      * frequency - can be one of the following values: "daily" - specify
        repeating periods based on an interval of a day or more; "weekly" -
        specify repeating periods based on an interval of a week or more;
@@ -222,9 +222,9 @@ modparam("tmrec", "separator", ";")
 
    Example 1.2. tmrec_match usage
 ...
-        if(tmrec_match("20120101T000000|24H|weekly|||SA,SU")
+        if(tmrec_match("20120101T000000|PT24H|weekly|||SA,SU")
         xdbg("it is weekend!\n");
-    if(tmrec_match("20120101T083000|10H|weekly|||MO,TU,WE,TH,FR")
+    if(tmrec_match("20120101T083000|PT10H|weekly|||MO,TU,WE,TH,FR")
         xdbg("it is with working hours\n");
 ...
 
@@ -298,7 +298,7 @@ if(is_leap_year("2010"))
 
    Example 1.4. time_period_match usage
 ...
-if(time_period_match("wd{1-5} hr{8-16}, wd{1-5} hr{17} min{0-29}"))
+if(time_period_match("wd{2-6} hr{8-16}, wd{1-5} hr{17} min{0-29}"))
         xdbg("Monday to Friday, 8:00 to 17:30\n");
 
 if(time_period_match("weekday { sat sun }, weekday {mo-fr} hr {17-8},wd{mo-wed}h
diff --git a/modules/tmrec/doc/tmrec_admin.xml b/modules/tmrec/doc/tmrec_admin.xml
index 782b1f1..7a429eb 100644
--- a/modules/tmrec/doc/tmrec_admin.xml
+++ b/modules/tmrec/doc/tmrec_admin.xml
@@ -127,7 +127,8 @@ modparam("tmrec", "separator", ";")
 			be small enough such that subsequent intervals do not overlap. 
 			For non-recurring intervals, durations of any positive length are 
 			permitted.  Zero-length duration means <quote>forever</quote>. 
-			Negative-length durations are not allowed.
+			Negative-length durations are not allowed. See RFC 2445 for
+			the format of duration.
 			</para>
 		</listitem>
 		<listitem>
@@ -274,9 +275,9 @@ modparam("tmrec", "separator", ";")
 		<title><function>tmrec_match</function> usage</title>
 		<programlisting format="linespecific">
 ...
-	if(tmrec_match("20120101T000000|24H|weekly|||SA,SU")
+	if(tmrec_match("20120101T000000|PT24H|weekly|||SA,SU")
         xdbg("it is weekend!\n");
-    if(tmrec_match("20120101T083000|10H|weekly|||MO,TU,WE,TH,FR")
+    if(tmrec_match("20120101T083000|PT10H|weekly|||MO,TU,WE,TH,FR")
         xdbg("it is with working hours\n");
 ...
 </programlisting>
diff --git a/modules/usrloc/ucontact.c b/modules/usrloc/ucontact.c
index 4877c7f..b18ce98 100644
--- a/modules/usrloc/ucontact.c
+++ b/modules/usrloc/ucontact.c
@@ -1051,8 +1051,8 @@ int db_update_ucontact_instance(ucontact_t* _c)
 {
 	str auser;
 	str adomain;
-	db_key_t keys1[2];
-	db_val_t vals1[2];
+	db_key_t keys1[4];
+	db_val_t vals1[4];
 	int n1;
 
 	db_key_t keys2[13];
@@ -1070,6 +1070,13 @@ int db_update_ucontact_instance(ucontact_t* _c)
 	}
 
 	n1 = 0;
+	keys1[n1] = &user_col;
+	vals1[n1].type = DB1_STR;
+	vals1[n1].nul = 0;
+	vals1[n1].val.str_val = *_c->aor;
+	LM_DBG("aor:%.*s\n", vals1[n1].val.str_val.len, vals1[n1].val.str_val.s);
+	n1++;
+
 	keys1[n1] = &instance_col;
 	vals1[n1].type = DB1_STR;
 	vals1[n1].nul = 0;
@@ -1181,6 +1188,29 @@ int db_update_ucontact_instance(ucontact_t* _c)
 	LM_DBG("contact:%.*s\n", vals2[n2].val.str_val.len, vals2[n2].val.str_val.s);
 	n2++;
 
+	auser = *_c->aor;
+	if (use_domain) {
+		keys1[n1] = &domain_col;
+		vals1[n1].type = DB1_STR;
+		vals1[n1].nul = 0;
+		adomain.s = memchr(_c->aor->s, '@', _c->aor->len);
+		if (adomain.s==0) {
+			vals1[0].val.str_val.len = 0;
+			vals1[n1].val.str_val = *_c->aor;
+			auser.len = 0;
+			adomain = *_c->aor;
+		} else {
+			vals1[0].val.str_val.len = adomain.s - _c->aor->s;
+			vals1[n1].val.str_val.s = adomain.s + 1;
+			vals1[n1].val.str_val.len = _c->aor->s + _c->aor->len - adomain.s - 1;
+			auser.len = adomain.s - _c->aor->s;
+			adomain.s++;
+			adomain.len = _c->aor->s +
+				_c->aor->len - adomain.s;
+		}
+		n1++;
+	}
+
 	if (ul_dbf.use_table(ul_dbh, _c->domain) < 0) {
 		LM_ERR("sql use_table failed\n");
 		return -1;
@@ -1204,19 +1234,7 @@ int db_update_ucontact_instance(ucontact_t* _c)
 
 	/* delete old db attrs and add the current list */
 	if (ul_xavp_contact_name.s) {
-	        auser = *_c->aor;
-	        if (use_domain) {
-			adomain.s = memchr(_c->aor->s, '@', _c->aor->len);
-			if (adomain.s==0) {
-				auser.len = 0;
-				adomain = *_c->aor;
-			} else {
-				auser.len = adomain.s - _c->aor->s;
-				adomain.s++;
-				adomain.len = _c->aor->s +
-					_c->aor->len - adomain.s;
-			}
-
+	    if (use_domain) {
 			uldb_delete_attrs(_c->domain, &auser,
 					  &adomain, &_c->ruid);
 			uldb_insert_attrs(_c->domain, &auser,
diff --git a/modules/usrloc/udomain.c b/modules/usrloc/udomain.c
index 244f8e7..88fc7e4 100644
--- a/modules/usrloc/udomain.c
+++ b/modules/usrloc/udomain.c
@@ -1250,8 +1250,8 @@ int uldb_preload_attrs(udomain_t *_d)
 			}
 
 			if (use_domain) {
-				domain.s = (char*)VAL_STRING(ROW_VALUES(row) + 6);
-				if (VAL_NULL(ROW_VALUES(row)+6) || domain.s==0 || domain.s[0]==0){
+				domain.s = (char*)VAL_STRING(ROW_VALUES(row) + 5);
+				if (VAL_NULL(ROW_VALUES(row)+5) || domain.s==0 || domain.s[0]==0){
 					LM_CRIT("empty domain record for user %.*s...skipping\n",
 							user.len, user.s);
 					continue;
@@ -1270,8 +1270,7 @@ int uldb_preload_attrs(udomain_t *_d)
 				suri = user;
 			}
 
-			lock_udomain(_d, &suri);
-			if (get_urecord_by_ruid(_d, ul_get_aorhash(&suri), &ruid, &r, &c) > 0) {
+			if (get_urecord_by_ruid(_d, ul_get_aorhash(&suri), &ruid, &r, &c) < 0) {
 				/* delete attrs records from db table */
 				LM_INFO("no contact record for this ruid\n");
 				uldb_delete_attrs(_d->name, &user, &domain, &ruid);
@@ -1287,8 +1286,9 @@ int uldb_preload_attrs(udomain_t *_d)
 							LM_INFO("cannot add values to contact xavp\n");
 					}
 				}
+				/* get_urecord_by_ruid() locks the slot */
+				unlock_udomain(_d, &suri);
 			}
-			unlock_udomain(_d, &user);
 		}
 
 		if (DB_CAPABILITY(ul_dbf, DB_CAP_FETCH)) {
diff --git a/modules/websocket/config.c b/modules/websocket/config.c
index e6e6a50..a0607a7 100644
--- a/modules/websocket/config.c
+++ b/modules/websocket/config.c
@@ -19,6 +19,11 @@
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Exception: permission to copy, modify, propagate, and distribute a work
+ * formed by combining OpenSSL toolkit software and the code in this file,
+ * such as linking with software components and libraries released under
+ * OpenSSL project license.
+ *
  */
 
 /*!
diff --git a/modules/websocket/config.h b/modules/websocket/config.h
index 690649e..64ed5bd 100644
--- a/modules/websocket/config.h
+++ b/modules/websocket/config.h
@@ -19,6 +19,11 @@
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Exception: permission to copy, modify, propagate, and distribute a work
+ * formed by combining OpenSSL toolkit software and the code in this file,
+ * such as linking with software components and libraries released under
+ * OpenSSL project license.
+ *
  */
 
 /*!
diff --git a/modules/websocket/ws_conn.c b/modules/websocket/ws_conn.c
index 613f14e..9f2b672 100644
--- a/modules/websocket/ws_conn.c
+++ b/modules/websocket/ws_conn.c
@@ -19,6 +19,11 @@
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Exception: permission to copy, modify, propagate, and distribute a work
+ * formed by combining OpenSSL toolkit software and the code in this file,
+ * such as linking with software components and libraries released under
+ * OpenSSL project license.
+ *
  */
 
 #include "../../locking.h"
diff --git a/modules/websocket/ws_conn.h b/modules/websocket/ws_conn.h
index d022d0e..0c7d639 100644
--- a/modules/websocket/ws_conn.h
+++ b/modules/websocket/ws_conn.h
@@ -19,6 +19,11 @@
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Exception: permission to copy, modify, propagate, and distribute a work
+ * formed by combining OpenSSL toolkit software and the code in this file,
+ * such as linking with software components and libraries released under
+ * OpenSSL project license.
+ *
  */
 
 #ifndef _WS_CONN_H
diff --git a/modules/websocket/ws_frame.c b/modules/websocket/ws_frame.c
index a3a4cef..ba0713b 100644
--- a/modules/websocket/ws_frame.c
+++ b/modules/websocket/ws_frame.c
@@ -19,6 +19,11 @@
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Exception: permission to copy, modify, propagate, and distribute a work
+ * formed by combining OpenSSL toolkit software and the code in this file,
+ * such as linking with software components and libraries released under
+ * OpenSSL project license.
+ *
  */
 
 #include <limits.h>
@@ -136,6 +141,7 @@ static int encode_and_send_ws_frame(ws_frame_t *frame, conn_close_t conn_close)
 	struct dest_info dst;
 	union sockaddr_union *from = NULL;
 	union sockaddr_union local_addr;
+	int sub_proto;
 
 	LM_DBG("encoding WebSocket frame\n");
 
@@ -161,6 +167,8 @@ static int encode_and_send_ws_frame(ws_frame_t *frame, conn_close_t conn_close)
 		return -1;
 	}
 
+	sub_proto = frame->wsc->sub_protocol;
+
 	switch(frame->opcode)
 	{
 	case OPCODE_TEXT_FRAME:
@@ -294,9 +302,9 @@ static int encode_and_send_ws_frame(ws_frame_t *frame, conn_close_t conn_close)
 		LM_ERR("sending WebSocket frame\n");
 		pkg_free(send_buf);
 		update_stat(ws_failed_connections, 1);
-		if (frame->wsc->sub_protocol == SUB_PROTOCOL_SIP)
+		if (sub_proto == SUB_PROTOCOL_SIP)
 			update_stat(ws_sip_failed_connections, 1);
-		else if (frame->wsc->sub_protocol == SUB_PROTOCOL_MSRP)
+		else if (sub_proto == SUB_PROTOCOL_MSRP)
 			update_stat(ws_msrp_failed_connections, 1);
 		if (wsconn_rm(frame->wsc, WSCONN_EVENTROUTE_YES) < 0)
 			LM_ERR("removing WebSocket connection\n");
diff --git a/modules/websocket/ws_frame.h b/modules/websocket/ws_frame.h
index 1210c6c..815ec65 100644
--- a/modules/websocket/ws_frame.h
+++ b/modules/websocket/ws_frame.h
@@ -19,6 +19,11 @@
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Exception: permission to copy, modify, propagate, and distribute a work
+ * formed by combining OpenSSL toolkit software and the code in this file,
+ * such as linking with software components and libraries released under
+ * OpenSSL project license.
+ *
  */
 
 #ifndef _WS_FRAME_H
diff --git a/modules/websocket/ws_handshake.c b/modules/websocket/ws_handshake.c
index c4e3143..05332e4 100644
--- a/modules/websocket/ws_handshake.c
+++ b/modules/websocket/ws_handshake.c
@@ -19,6 +19,11 @@
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Exception: permission to copy, modify, propagate, and distribute a work
+ * formed by combining OpenSSL toolkit software and the code in this file,
+ * such as linking with software components and libraries released under
+ * OpenSSL project license.
+ *
  */
 
 #include <openssl/sha.h>
diff --git a/modules/websocket/ws_handshake.h b/modules/websocket/ws_handshake.h
index e7ff8e0..5c69fa2 100644
--- a/modules/websocket/ws_handshake.h
+++ b/modules/websocket/ws_handshake.h
@@ -19,6 +19,11 @@
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Exception: permission to copy, modify, propagate, and distribute a work
+ * formed by combining OpenSSL toolkit software and the code in this file,
+ * such as linking with software components and libraries released under
+ * OpenSSL project license.
+ *
  */
 
 #ifndef _WS_HANDSHAKE_H
diff --git a/modules/websocket/ws_mod.c b/modules/websocket/ws_mod.c
index ec5e07c..8932769 100644
--- a/modules/websocket/ws_mod.c
+++ b/modules/websocket/ws_mod.c
@@ -19,6 +19,11 @@
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Exception: permission to copy, modify, propagate, and distribute a work
+ * formed by combining OpenSSL toolkit software and the code in this file,
+ * such as linking with software components and libraries released under
+ * OpenSSL project license.
+ *
  */
 
 #include "../../dprint.h"
diff --git a/modules/websocket/ws_mod.h b/modules/websocket/ws_mod.h
index 819d3ea..8db9fef 100644
--- a/modules/websocket/ws_mod.h
+++ b/modules/websocket/ws_mod.h
@@ -19,6 +19,11 @@
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Exception: permission to copy, modify, propagate, and distribute a work
+ * formed by combining OpenSSL toolkit software and the code in this file,
+ * such as linking with software components and libraries released under
+ * OpenSSL project license.
+ *
  */
 
 #ifndef _WS_MOD_H
diff --git a/msg_translator.c b/msg_translator.c
index b4581e7..13b0785 100644
--- a/msg_translator.c
+++ b/msg_translator.c
@@ -1575,7 +1575,7 @@ static inline int adjust_clen(struct sip_msg* msg, int body_delta, int proto)
 		 */
 		/* no need for Content-Length if it's and UDP packet and
 		 * it hasn't Content-Length already */
-		if ((msg->content_length==0)){
+		if (msg->content_length==0){
 		    /* content-length doesn't exist, append it */
 			/* msg->unparsed should point just before the final crlf
 			 * - whole message was parsed by the above parse_headers
diff --git a/parser/parse_fline.c b/parser/parse_fline.c
index 8dacfe5..b8fee65 100644
--- a/parser/parse_fline.c
+++ b/parser/parse_fline.c
@@ -233,7 +233,7 @@ error:
 	if (prn) {
 		for (t=0; t<offset; t++)
 			if (*(buffer+t)) *(prn+t)=*(buffer+t);
-			else *(prn+t)='�';
+			else *(prn+t)=176; /* '�' */
 		LOG(L_DBG, "parsed so far: %.*s\n", offset, ZSW(prn) );
 		pkg_free( prn );
 	};
diff --git a/pkg/kamailio/deb/debian/changelog b/pkg/kamailio/deb/debian/changelog
index f5d3633..fcf832b 100644
--- a/pkg/kamailio/deb/debian/changelog
+++ b/pkg/kamailio/deb/debian/changelog
@@ -1,3 +1,9 @@
+kamailio (4.1.1) unstable; urgency=low
+
+  * update to 4.1.1 from upstream
+
+ -- Daniel-Constantin Mierla <miconda at gmail.com>  Thu, 09 Jan 2014 15:45:35 +0100
+
 kamailio (4.1.0) unstable; urgency=low
 
   * update to 4.1.0
diff --git a/pkg/kamailio/deb/jessie/changelog b/pkg/kamailio/deb/jessie/changelog
index f5d3633..fcf832b 100644
--- a/pkg/kamailio/deb/jessie/changelog
+++ b/pkg/kamailio/deb/jessie/changelog
@@ -1,3 +1,9 @@
+kamailio (4.1.1) unstable; urgency=low
+
+  * update to 4.1.1 from upstream
+
+ -- Daniel-Constantin Mierla <miconda at gmail.com>  Thu, 09 Jan 2014 15:45:35 +0100
+
 kamailio (4.1.0) unstable; urgency=low
 
   * update to 4.1.0
diff --git a/pkg/kamailio/deb/lucid/changelog b/pkg/kamailio/deb/lucid/changelog
index f5d3633..fcf832b 100644
--- a/pkg/kamailio/deb/lucid/changelog
+++ b/pkg/kamailio/deb/lucid/changelog
@@ -1,3 +1,9 @@
+kamailio (4.1.1) unstable; urgency=low
+
+  * update to 4.1.1 from upstream
+
+ -- Daniel-Constantin Mierla <miconda at gmail.com>  Thu, 09 Jan 2014 15:45:35 +0100
+
 kamailio (4.1.0) unstable; urgency=low
 
   * update to 4.1.0
diff --git a/pkg/kamailio/deb/precise/changelog b/pkg/kamailio/deb/precise/changelog
index 74a19e1..753f2af 100644
--- a/pkg/kamailio/deb/precise/changelog
+++ b/pkg/kamailio/deb/precise/changelog
@@ -1,3 +1,9 @@
+kamailio (4.1.1) unstable; urgency=low
+
+  * update to 4.1.1 from upstream
+
+ -- Daniel-Constantin Mierla <miconda at gmail.com>  Thu, 09 Jan 2014 15:45:35 +0100
+
 kamailio (4.1.0) unstable; urgency=low
 
   * update to 4.1.0
diff --git a/pkg/kamailio/deb/squeeze/changelog b/pkg/kamailio/deb/squeeze/changelog
index f5d3633..fcf832b 100644
--- a/pkg/kamailio/deb/squeeze/changelog
+++ b/pkg/kamailio/deb/squeeze/changelog
@@ -1,3 +1,9 @@
+kamailio (4.1.1) unstable; urgency=low
+
+  * update to 4.1.1 from upstream
+
+ -- Daniel-Constantin Mierla <miconda at gmail.com>  Thu, 09 Jan 2014 15:45:35 +0100
+
 kamailio (4.1.0) unstable; urgency=low
 
   * update to 4.1.0
diff --git a/pkg/kamailio/deb/wheezy/changelog b/pkg/kamailio/deb/wheezy/changelog
index f5d3633..fcf832b 100644
--- a/pkg/kamailio/deb/wheezy/changelog
+++ b/pkg/kamailio/deb/wheezy/changelog
@@ -1,3 +1,9 @@
+kamailio (4.1.1) unstable; urgency=low
+
+  * update to 4.1.1 from upstream
+
+ -- Daniel-Constantin Mierla <miconda at gmail.com>  Thu, 09 Jan 2014 15:45:35 +0100
+
 kamailio (4.1.0) unstable; urgency=low
 
   * update to 4.1.0
diff --git a/pkg/kamailio/rpm/kamailio.spec-4.1 b/pkg/kamailio/rpm/kamailio.spec-4.1
index 12b02f0..6578398 100644
--- a/pkg/kamailio/rpm/kamailio.spec-4.1
+++ b/pkg/kamailio/rpm/kamailio.spec-4.1
@@ -1,5 +1,5 @@
 %define name    kamailio
-%define ver     1.2.0
+%define ver     4.1.1
 %define rel     0
 
 %define EXCLUDED_MODULES	mysql jabber cpl-c avp_radius auth_radius group_radius uri_radius pa postgres osp tlsops unixodbc
diff --git a/pkg/kamailio/rpm/kamailio.spec.CenOS b/pkg/kamailio/rpm/kamailio.spec.CenOS
index 6b396c7..29417db 100644
--- a/pkg/kamailio/rpm/kamailio.spec.CenOS
+++ b/pkg/kamailio/rpm/kamailio.spec.CenOS
@@ -1,5 +1,5 @@
 %define name    kamailio
-%define ver     3.2.0
+%define ver     4.1.1
 %define rel     0
 %define _sharedir %{_prefix}/share
 
diff --git a/pkg/kamailio/rpm/kamailio.spec.SuSE b/pkg/kamailio/rpm/kamailio.spec.SuSE
index 77af948..eead83e 100644
--- a/pkg/kamailio/rpm/kamailio.spec.SuSE
+++ b/pkg/kamailio/rpm/kamailio.spec.SuSE
@@ -1,5 +1,5 @@
 %define name    kamailio
-%define ver     1.2.0
+%define ver     4.1.1
 %define rel     0
 
 %define EXCLUDED_MODULES	mysql jabber cpl-c auth_radius misc_radius peering postgress pa unixodbc osp tlsops
diff --git a/select_buf.c b/select_buf.c
index b3463a8..7277d48 100644
--- a/select_buf.c
+++ b/select_buf.c
@@ -162,7 +162,7 @@ int int_to_static_buffer(str* res, int val)
 {
 	char *c;
 	c = int2str(abs(val), &res->len);
-	res->s = get_static_buffer(res->len+(val<0)?1:0);
+	res->s = get_static_buffer(res->len+((val<0)?1:0));
 	if (!res->s) return -1;
 	if (val < 0) {
 		res->s[0] = '-';	

-- 
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