tm: Fix setting flags for record-route headers

The flags where set in add_uac() by counting the number of record-route
headers added by prepare_new_uac(). The latter function backups and
restores the list of lumps, so add_uac() only sees the original list,
which is not what has happened on the branch being handled.

Moving setting the flags into prepare_new_uac() fixes this.

This fixed the dialog module, which has to remove the correct number
of RR headers from the callee's routeset (which it does based on the
tm flags).

(cherry picked from commit ee9b78709516b935e087b0efcb620c13aad1a740)
kcore: print_rr_body: return number of printed Record-Route bodies

Act like the documentation, return the number of printed RR bodies, not the
total number of RR bodies.

(cherry picked from commit aa4fabe05dd3b6dc841325fe279596293d327a92)
core: sip_msg_shm_clone: clone parsed maxforwards value in shm

maxfwd module modified the msg buf directly instead of adding a lump. In
addition it is filling the parsed value of the header field.

Clone this field into shm so later code can at least determine if the msg
has been mangled so it can retreive the original value of the header.

(cherry picked from commit 42f506c08073c5f8ca84f1f12ea9e6c820f162d8)
core: Document the right type for 'str*' in the RPC interface

(cherry picked from commit a4eacbb469909978b7a9eff8767dcbdd5110ee99)
mi_datagram: Send error response on out-of-memory

(cherry picked from commit 902a77af1501f78fcc1205a37a5307e1d300f301)
dmq: check if dmq socket exists

(cherry picked from commit c6d2480efd95336ae34a2fb732dd4cb62ac89cbb)
dmq: handle failure to build callback parameter

(cherry picked from commit e98c601c43edbfbf7b389e04e9fb16839577ef5a)
dmq: unlock in failure path in build_notification_body()

(cherry picked from commit 5f05db99979e6c74d8303437d6c422478a1fbc7c)
tm: log an error message as error, not debug

(cherry picked from commit 54f19e018a1a569b532555311505d4962de49bd7)
tm: remove dead code

(cherry picked from commit 3d24997fd1ba34bd4e426656b1533530718008a0)
core: time_t is unsigned, handle integer underflow correctly

When the processing of the timer code takes longer than the interval, don't
sleep for 4Gs.

(cherry picked from commit 8adcf8f0e3ba2fa969583f6630dbd9e3aaecfcac)
core: fork_*_utimer()'s interval is in microseconds

Sync comments with code and function names

(cherry picked from commit e2596876b830783de88934d45c9c5563ba2c3577)
tm: backup xavps before running callbacks

regular avps were being backupped, just not xavps.

(cherry picked from commit e1f96b11379abd60fd53c49a376f6cf3cb1fc69d)
dispatcher: Ignore IPv6 addresses if IPv6 lookups are disabled.

(cherry picked from commit 2d7f748ef690846365e4dd5bc5a91df21e39321c)
core: Don't log errors when dns find no more records

If the proxy is listeneing on both ipv4 and ipv6, DNS attempts are done for
both A and AAAA records. If the last of these lookup fails with no records
found, don't log an error if the first lookup did already return records.

(cherry picked from commit 3aec75e97b579cc67340c0fb81b276321b4ab73a)
perl: check for and handle memory allocation failures

(cherry picked from commit 293caa403bba6741d15254a42d106392fc657888)
dialog: release lock when profile has been found

(cherry picked from commit 10a655b5545f5170f339a9f18d702f4e85dd5778)
dialog: break loop when profile entry doesn't exist

(cherry picked from commit a65a212c1e7587182f113a94f3d0d8b46c97baa0)
dialog: fix crash when trying to RPC export a "remote" profile

(cherry picked from commit 79695ed2628db60199647baf653ce5f9b9005fe9)
perl: Sync log levels with kamailio core

(cherry picked from commit 92fa1ac28b4991cd83338d1f99e898dfe1d8742f)