core: add received parameter to via if rport parameter is present

- required by RFC3581, section 4.

(cherry picked from commit a1e96cbd5a3b43598c59cb50693e6b739801b804)
tm: test ending angle bracket for From/To URI when genrating local requests

- the value can start with a display name and can end up with double
  angle bracketting

(cherry picked from commit fb0cd1cd6a891ab5dc5f559bb6740ba62ac3daf4)
tm: extra checks to see if the transaction was canceled before forwarding branches

- catch cases when CANCEL arrives during branch_route execution
- reported  Sławomir Bocheński, FS#468

(cherry picked from commit b66033d0546bf57cfb0cd16f1072da80c5a79d34)
tm: beter detection of brackets in From/To values in UAC print functions

- commit fb0cd1cd6a891ab5dc5f559bb6740ba62ac3daf4 fixed the case of
  avoiding double <> when dispaly name was present, but affected when
  header parameters were given
- reported by Juha Heinanen

(cherry picked from commit 181c30705b3cb82245463015d98644c278131af2)
websocket: fix checking payload_len safety check for fragmentation

- a crafted websocket frame  using values spanning max unsinged int could have
  caused a failed detection of unsupported fragmentation and invalid memory access
- thanks to Peter Dunkley and Hugh Waite for assisting and pin-pointing
  where everything happens

(cherry picked from commit 6b8acf3204a8615762b0b5dcc6aac152f40b2ca0)
core: exit with -1 if there is a mismatch in version of module and core

- return code to shell 0 is like succesful run, some scripts not being
  able to say it was a failure to start

(cherry picked from commit c4f7356f2d8c057f59cb61948aa04664cecd35f7)
sms: declare inline functions static to work with clang linker

- otherwise it results in no symbol found at module loading time

(cherry picked from commit 8a51aa250c4e22e5933d0ff39a7a4b300007bb72)
benchmark: declare inline functions static to work with clang linker

- otherwise it results in no symbol found at module loading time

(cherry picked from commit 452f32235034916468cab577de3ca0d0f56fd5ea)
core: fixed overwriting mpath value given in command line via config

 - -L is in the group of options evaluated before config

(cherry picked from commit e1e40d3a58bf3ed6c4f2df830e29d5468d7bee82)
core: change the uid and gid for pid and pgid files

- use the user and group given to daemon to update ownership of pid and
  pgid files
- reported by Ovidiu Sas, FS#472

(cherry picked from commit c873758624da24359117b3fa158cc56ccd0a5d73)
core: more verbose log message for failing to find local socket

(cherry picked from commit f50c1e9fab16fb611f7bbc6002f4c8607bc8fbf2)
core: be prepared to get Via received param with brackets around ipv6 addr

- helper function to generate similar value

(cherry picked from commit b7bc7a5450b1e31697fb389a503463eac644b796)
db_berkely: end log message with new line

(cherry picked from commit 5822dc04f01b20ddfe9d37e9c0eea53fa658164b)
lib/srdb1: end of line after several debug messages

(cherry picked from commit e675f20af9a4d9a4b5e7b11277f4a4e0c774e128)
dialog: sync'ed parameter names for columns with source code

(cherry picked from commit ebe64df20181f4e569548961b9a1ca64b5cfa444)
modules/pua: db_mode=2 send_publish fixes

- plus small debug message edits
(cherry picked from commit 6822ff45e931ad3e93b22ebf7d1beb350bf27e70)

(cherry picked from commit 65659addafd0a492cafbb6c9cbaf3644442f333a)
tm: safety check for user_agent_header value

- don't add the header in local generated requests if the value is empty

(cherry picked from commit cea9b91dacdb23b22fc1a7dd8454994eab9efa6e)
(cherry picked from commit f90edc4efed7fb4bc2d0f6d1a20a69e1751485d3)
core: safety check for server_header lenght

- don't add the header in local generated replies if the value is empty

(cherry picked from commit 866ddc109bfd7c681e13ce529d271e8a2a33a972)
(cherry picked from commit 6f4c872f302111abda6aa810fb462b08809aaac9)
tm: handle r-uri alias parameter for local generated requests within a dialog

(cherry picked from commit 3e01905143ace159b18e11a31edf39018d754bba)
(cherry picked from commit 6c7bbcddf48dbfc1bf563eba9a9e10991ac52cc3)
dialplan: extended debug message to be more useful

(cherry picked from commit 37c6e7ec80a16b93751d535de3b7784c1270d8b8)
(cherry picked from commit 53eb694e38836b19e8af7ffaa59b7014cd5f497e)