Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error on raspberry pi #912

Closed
Abbas-Roushan opened this issue Jun 18, 2016 · 1 comment
Closed

error on raspberry pi #912

Abbas-Roushan opened this issue Jun 18, 2016 · 1 comment
Assignees
Labels
Milestone

Comments

@Abbas-Roushan
Copy link

hi

i install opensips on raspberry pi , with this command ,

GIT clone of latest stable release (2.2.0) LTS:

git clone https://github.com/OpenSIPS/opensips.git -b 2.2 opensips_2_2

and when i want to compile , i get this error :

fastlock.h:176:2: error: #error "unknown architecture"
#error "unknown architecture"
^
fastlock.h:287:2: error: #error "unknown architecture"
#error "unknown architecture"
^
In file included from lock_ops.h:76:0,
from locking.h:65,
from statistics.h:144,
from sr_module.h:49,
from usr_avp.c:34:
fastlock.h:176:2: error: #error "unknown architecture"
#error "unknown architecture"
^
fastlock.h:287:2: error: #error "unknown architecture"
#error "unknown architecture"
^
In file included from mem/../lock_ops.h:76:0,
from mem/../locking.h:65,
from mem/../statistics.h:144,
from mem/shm_mem.h:30,
from blacklists.c:35:
mem/../fastlock.h:176:2: error: #error "unknown architecture"
#error "unknown architecture"
^
mem/../fastlock.h:287:2: error: #error "unknown architecture"
#error "unknown architecture"
^
In file included from mem/../lock_ops.h:76:0,
from mem/../locking.h:65,
from mem/../statistics.h:144,
from mem/shm_mem.h:30,
from daemonize.c:57:
mem/../fastlock.h:176:2: error: #error "unknown architecture"
#error "unknown architecture"
^
mem/../fastlock.h:287:2: error: #error "unknown architecture"
#error "unknown architecture"
^
In file included from lock_ops.h:76:0,
from locking.h:65,
from statistics.h:144,
from sr_module.h:49,
from ut.h:37,
from transformations.c:35:
fastlock.h:176:2: error: #error "unknown architecture"
#error "unknown architecture"
^
fastlock.h:287:2: error: #error "unknown architecture"
#error "unknown architecture"
^
In file included from mem/../lock_ops.h:76:0,
from mem/../locking.h:65,
from mem/../statistics.h:144,
from mem/shm_mem.h:30,
from pt.c:28:
mem/../fastlock.h:176:2: error: #error "unknown architecture"
#error "unknown architecture"
^
mem/../fastlock.h:287:2: error: #error "unknown architecture"
#error "unknown architecture"
^
^Cmake: *** Deleting file 'pt.d'

@bogdan-iancu
Copy link
Member

@behesht , run "NICER=0 make" and post the compile line (just ahead the errors).

@bogdan-iancu bogdan-iancu added this to the 2.2.1 milestone Jun 21, 2016
@bogdan-iancu bogdan-iancu self-assigned this Jun 21, 2016
bogdan-iancu added a commit that referenced this issue Jul 5, 2016
Partial revert of 058e16 as we need some extra asm code for fast locking on arm6.
See #923
Closes #912

(cherry picked from commit a69c328)
bogdan-iancu added a commit that referenced this issue Jul 5, 2016
Partial revert of 058e16 as we need some extra asm code for fast locking on arm6.
See #923
Closes #912

(cherry picked from commit a69c328)
bogdan-iancu added a commit that referenced this issue Jul 5, 2016
Partial revert of 058e16 as we need some extra asm code for fast locking on arm6.
See #923
Closes #912

(cherry picked from commit a69c328)
jnewman02 added a commit to Vocalocity/opensips that referenced this issue Jul 30, 2016
* [acc] fix bugs in acc

* init all accounting methods data in mod_init as it was before;
cdr accounting initial data is loaded even if users don't use
CDRs but this shouldn't affect anything
* fix aaa bug - api was not loaded because it was badly included
in diameter define section
* fix event interface extra parameters - parsing extra parameters
for event interface was wrongly removed

* Make the s.int transformation more permissive

* Preserve sign on partially converted strings

* drouting api: Fix a double free bug

Crashes / memory corruptions could ensue after running "fraud_reload" MI
commands or during OpenSIPS shutdown, if fraud_detection had some data
to work with.

* [sipcapture hep] function to continue with the script after the hep route

* [sipcapture] update docs for new function

* clusterer: update README with a usage example

* clusterer: update html README layout

* TLS: Fix misleading error logs on accept() failures

OpenSIPS would always log SSL_accept() failures as being "rejected by
client". This is entirely not the case, as the errors may as very well be
server-side, due to cipher mismatches, failed peer verifications, etc.

Reported by Nabeel Shikder on the "users" mailing list

* Fixed bogus free of soring algorithms in DR.

* python: fix documentation links

* Update ws & tls modules documentation

* MYSQL DB migration updated.

SIP TRACE table changed, CALL CENTER tables added.

* Migrate cfg scripts to new acc interface.

* Fixed ilegal chars in XML

* Revert commit 1e1ea14

Do not automatically set db_url to the db_default_url as we have no idea if the default partition is gone be used. By forcing it we create some extra unwanted dependencies (like setting the version for the defaul table, even if not used).
Even if we break the backward compatibility, makes more sens to explicitly set the db_url if you use the default partition

* Revert commit d6cbbff

Do not automatically set db_url to the db_default_url as we have no idea if the default partition is gone be used. By forcing it we create some extra unwanted dependencies (like setting the version for the defaul table, even if not used).
Even if we break the backward compatibility, makes more sens to explicitly set the db_url if you use the default partition

* Fix bogus log

(cherry picked from commit 87c93b8)

* README files regenerated

* Fix extended Call-ID in B2B

The old CallID format did not ensure unicity across time, so we include now time info into the callid.
Closes  OpenSIPS#783 .

* Update CREDITS and AUTHORS

* Makefile: always put the minor in name

Even if it is redundant

* For beta release, enable malloc debugging

* Makefile: increase version to 2.3.0-dev

* Improve the AUTHORS file

* Various doc improvements

* [db_sqlite] use DB_STRING type when the column value type is DB_STRING

* Fix missing logs if debug_mode after log_stderror

* [db_sqlite] add explanation about implementation

* [dialog] repl_prof_add never increments the return buffer size for threshold comparison

* [siptrace][traceID]fix mysql uri parsing

* Fixed checking return code for pre raw callbacks

If the TH pre raw callbacks fails, it may return a NULL buffer, leading to a later crash when we want to parse the SIP message.

(cherry picked from commit 4be2662)

* [drouting] pvar for matched partition if wildcard operator used

* [drouting] check if partition pvar is writable

* [drouting] docs updated for partition id variable

* Fix typo in README example

* Fix missing GPL headers for mem files

* cachedb_redis: Prevent crash when re-connect keeps failing

* Fix a PKG leak in the SIP message processing stack

Commit 7464a86ec introduced a processing context leak during the
handling of basically any SIP request in all protocol stacks
except for HEP.

Reported by Trevor Francis <trevor@46labs.com>

* Allow negative values for "memdump" and "memlog"

They should behave just as "log_level" does.

* pi_http: return "200 OK" instead of "0 Unknown"

* Suppress "no free TCP receiver" logging noise

This was added long before async TCP support, and it is now
only useful to developers.

* [acc] fix double free issue

Since callbacks were registered only at first, and aftewards only
flags were changed there was no way to know if tm is to free the
shmed flags from acc or dialog. For this a new flag was introduced
to indicate whether the flags shall be removed either by dialog or
tm.

* [acc][bugfix] register tm free function only once

* dialog: Remove a chunk of dead code

*  [sipcapture][HOMERv5 incompatibility fix] HOMERv5 table rotation aware logic

    * HOMVERv5 allows rotating tables by having a prefix which is
    the fixed table name and a suffix which is a string containig
    timestamps
    * sip_capture now accepts table name as a parameter to sip_capture()
    function
    * both global table name and sip_capture table_name can have
    a prefix(string) and a suffix(strftime format string);
    * fixed bugs in async query building

* [sipcapture][HOMERv5 incompatibility fix]generic capturing function

      Added new function called report_capture which allows
capturing hep packets in a generic format. It will be very
effective for the third version of the hep protocol for capturing
packets other than SIP. Also added a new table called rtcp_capture
for storing everything capture with report capture.

* [sipcapture][HOMERv5 incompatibility fix] updated docs for report_capture and new table name format

* Fix typo in do_accounting() naming is cfg templates

* Fixed bogus pkg_free on pointer in data segment

Reported by @dzhou121
Closes OpenSIPS#854

(cherry picked from commit b9aa873)

* MI library: Add comments regarding a known issue

Currently, MI arrays cannot contain objects with non-identical
"name" attributes.

This patch also quickfixes this issue in mi_list_all_profiles() by dropping
the array idea altogether, in favour of a top-most object.

* [tm]fix context functions header

* [context][bugfix] each context has its own destroy functions vector

Credits to Razvan Crainea

* [siptrace][bugfix] sequential requests - set context for sl callbacks

* [proto_hep][bugfix] check memory allocation

* tls_list() may be called even without DB support

Avoid locking if DB support was not enabled.

* exclude proto_wss, use QM_MALLOC

(cherry picked from commit b7ac4fc)

* Fixed default FIFO file name

* Fixed MI nodes in 'sip_trace' command.

Formatting chars must not be included in the MI tree

* [acc][bugfix] correctly store do_accounting() flags

	Flags are now moved from processing context into
transaction context when the transaction is created, this way
having visibility for the whole transaction.

* [proto_hep][bugfix] fix bad sip payload size calculation

* [sipcapture] remove time-consuming unnecessary chunk of code

* [sipcapture] fix incompatibilities with HOMERv5 db schema

* [siptrace][bugfix] avoid double free on cancelled transaction

* [tls_mgm] properly handle SSL_ERROR_SYSCALL on SSL_shutdown

* memory hash summary: Fix a fragment counting bug

When debugging memory, a very small number of memory fragments would
be counted twice, leading to a slightly incorrect overall report
(almost unnoticeable)

* memory hash summary: Fix a rare memory leak

Proper cleanup upon running into a "no more system memory" state while
performing the fragment summary of the entire memory hash.

* Fixed arrays in clusterer_list MI command

* Fixed wrong MI tree in clusterer_list (related to previous commit)

* Avoid space in MI node name

(cherry picked from commit 5c8869b)

* Enable debug_mode settings only if debug_mode gets set to enable.

* [hep][bugfix] correctly store ports/addresses

* Revert "[hep][bugfix] correctly store ports/addresses"

This reverts commit 7b1359a.

* [proto_hep][bugfix] use the correct port when unpacking

* [siptrace][bugfix] use the correct sockaddr structure for storing

* allow a module to register multiple protocols

* mathops: fill in entire structure

* [drouting] bug fix and memory leak fix

* free gateways list for each carrier at reload
* use map_find instead of map_get to search an element in the tree

* [hep] multiple versions/protocols can be used in the same time

Since commit 0873c14 multiple
network protocols can be used from one module. Proto_hep was changed
to be able to use both tcp and udp in the same time. Moreover, there
is no hep_version needed since we can receive HEPv1,v2 and v3 on any
UDP interface. Since HEPv1 and v2 are not compatible with TCP, only
HEPv3 will be support. For HEPv3, Sipcapture module can now relay
packets from TCP to UDP or the reverse way.
Siptrace module was also improved. Trace id's can now be defined with
hep version and transport protocol, in order to be able to do multiple
types of tracing with different HEP protocols and/or network transports.

* [hep] updated docs for previos commit

* [proto_hep] correctly name function

* do not overwrite permissions of config file when re-installing

* Allow PREFIX overwrite

* [sipcapture] new HEPVERSION script variable

* [sipcapture] updated docs for HEPVERSION

* proto_bin: remove debug INFO message

* [acc][bugfix] fix memory leak

* fix leak caused by missed calls - receiving a negative reply
caused flags not being freed

* regex: fix spell-check in package

* Updated opensipsctl.base to also search /sbin

The md5 utility is located at /sbin/md5 on FreeBSD 8.3. An additional common location was added to allow the script to accommodate this.

* dialog and usrloc: broadcast replication data all time

This prevents clusterer module from marking a node as not reachable when there
is no traffic at all.

Fixes OpenSIPS#849

* debian: add missing dependency

Ovewrite lintian warning

(cherry picked from commit 83a23be)

* Makefile.conf: add deps for tls_mgm and proto_wss

This prevents 'make menuconf' from deleting these modules from the generated
configuration file

* ratelimit: initialize the length of the algorithm

* [sipcapture] be able to set proto_type in report capture function

* [sipcapture] fix bad conditions

* [sipcapture][bugfix] invalid memory access

* [sipcapture][bugfix] invalid static vector size calculation

* [siptrace][bugfix] fix trace_id parsing

* pv_printf() - Some code refactoring

Code is more reusable, and will lead to smaller number of LoC, less duplication
and fewer inconsistencies.

* [sipcapture][bugfix] fix bad string hex value parsing

* [sipcapture] fix new hep proto names string

* [sipcapture] allow any hep version for hep_net variable

* [siptrace] fix hash calculus for extended hep trace_id

* radcli support and radius library autodection from makefile
* aaa_radius module can be compiled with radcli library
* Makefile will autodetect the radius library to compile with; the
order is radcli-->freeradius-->radiusclient-ng if more radius
libraries are installed
* new Makefile rule "print_radius_lib"
* if custom library is to be used compile with
RADIUSCLIENT=RADCLI/FREERADIUS/RADIUSCLIENT

* [aaa_radius] implement missing function from radcli

	Functions like rc_get_ipaddr are removed from radcli
since they are only compatible with IPv4. Since aaa_radius
implementation is based on this function it had to be rewritten
in our module.

* event_flatstore doc: Fix some typos

* event_virtual doc: Fix grammar/typos

* proto_sctp: Fix startup bug caused by a typo

* [siptrace][bugfix] bad structre used when printing HEP trace_id via mi

* [sipcapture] fix sip_capture table schema

* [nathelper] fix bad logic regarding the timer list

* event_flatstore: Remove unncessary startup warning

* event_flatstore: Fix a memory management bug

* [dispatcher] fix double allocation issue

* [mi_json] return code rework for errors

	Mi_json now returns only 200 OK as HTTP code. We have two
records for inspecting mi level errors, "code" for the error code
and "reason" for the error message.

* [mi_json] remove double inverted commas for internal error messages

* [sipcapture] fix bad time calculation

* [sipcapture] fix possible data type loss

* Fixed bogus memory operations.

Fixed bogus free (of uninit pointer) if parse_contact() fails
Fixed shm leak on errors after print_rr_body
Fixed shm leak on success if record_route is present.
Reported by John Nash.

(cherry picked from commit 4b0fca5)

* nathelper: ping WSS clients when using natping_tcp

See ticket OpenSIPS#875

* [mi_json] return jsonrpc compliat error message

* usrloc: Fix some uninitialized memory issues

Reported by Minh Phan
Closes OpenSIPS#878

* [mi_json] minor fixes in mi_json

* [mi_xmlrpc] return code rework for errors

Mi_xmlrpc_ng now returns only 200 OK as HTTP code. We have two
labels for inspecting mi level faults, "code" for the error code
and "message" for the error message. Check
http://www.tutorialspoint.com/xml-rpc/xml_rpc_fault.htm for
more details.

* Fixed preserving 3xx Contacts in TH without dialog

Reported by Pete Kelly.
Closes OpenSIPS#656.

* [dispatcher] multiple fixes

* use pkg memory instead of shm for fixup variables
* fix int list building - avoid building a circular list

* Fix bogus timer ref counter during expire update.

Many thanks to Trevor Francis for reporting and helping with troubleshooting and testing.

* event_route: Fix compilation warning

* [Makefile] make json path editable

* Process sequential messages received in CONFIRMED_NA state

Due to UDP race conditions, sequential messages may be received
before the ACK confirming the initial INVITE ( eg. Re-INVITE sent
immediately as the call is established in order to force
a specific codec ) - also push these requests through the whole
dialog processing in order to avoid any future issues ( eg. CSEQ
updating which, if left unprocessed, will lead to generating out
of order sequentials by OpenSIPS )

* Fix a string concatenation operator bug

This patch fixes an issue with string concatenation where any NULL
operand would cause all operands to its left to be ignored when
computing the result of the expression.

Reported by Ovidiu Sas
Closes OpenSIPS#870

* clusterer: Fix bad doc example

Reported by "alias_neo" on IRC

* re-register topo hiding callbacks after restart

Thanks to Pete Kelly for reporting this

* th: fix dlg flag check

* Fix invalid memory access with async MySQL queries

Due to the way the libmysqlclient query result strings were managed,
they would be freed by the library before OpenSIPS would copy them
into the output AVPs.

This patch fixes the issue by adding a new DB API function which handles
the cleanup of async query results.

Reported by Ovidiu Sas
Addresses issue OpenSIPS#873

* provide a way to specifi opensipsctlrc

Add a new variable that can specify what opensipsctlrc file to use for the
opensipsctl and opensipsdbctl tools

* Added extra log message on openssl 1.0.1e-fips bug.

If CRYPTO_set_mem_functions() fails, make a note on the openssl 1.0.1e-fips bug, so users may have a hint on the actual issue.
See more  OpenSIPS#834.
Closes  OpenSIPS#834.

(cherry picked from commit c5bb0d0)

* Fix potential 100 Trying duplicates.

Added the "auto_100trying" module parameter to allow the script writter to take control (from script level) over when the 100 Trying reply is to be sent back.
By default, the reply is automatically generated when the INVITE transaction is created.
Fixes OpenSIPS#833

* [mmgeoip] allow chosing memory caching type

	Before GEOIP_MMAP_CACHE was used causing a segmentation
fault when database file was changed. Now users can choose between
reading the database directly from file, cahing it into memory with
the possibility to change the database file at runtime.

* Revert "Accept TCP aliases by default"

This reverts commit d62bc96.

Firstly, TCP connection reusage (RFC 5923) should only be employed between
TLS endpoints - only TLS allows the endpoints to authenticate each other
during connection setup, preventing unauthorized connection hijacking.

Secondly, aside from any security considerations, RFC 5923 must
not be employed fanatically (Proxy-Proxy, Edge-UA, UA-Proxy) on any TCP
connection (especially disregarding the ";alias" Via parameter!), but
rather only between adjacent SIP entities who can both initiate a
connection towards each other, and also support the RFC. In the real
world, we're basically only talking about the Proxy-Proxy usage case, as
any SIP UA scenario will most likely involve some form of NAT and a
Proxy that cannot open connections backwards, towards the UA. In these
cases, TCP connection reusage is _completely_ out of the question, as a
single UA might end up receiving all calls of all users behind their
public IP.

Thanks to Jonas Borjesson for reporting the problem in the first place.

* TCP connection lookup: Add matching by transport

The fact that all currently supported TCP-oriented protocols have different
standard ports is not an excuse for not including the transport into the
match condition (i.e. dest IP address + dest port + dest transport).

This may very well prevent issues with messages being sent out over the
wrong TCP connection in a number of scenarios where we employ TCP connection
reusage over both plain TCP and TLS with a Proxy that specifies the same port
in the topmost Via header when it establishes each of the two connections.

* TCP alias lookup: Add matching by transport

Further improving commit 13970bb.

* MI node creation: Add some useful function comments

* mi_xmlrpc_ng: Fix a shared memory leak

* mi_xmlrpc_ng: Fix NULL pointer dereference

Any MI tree with a topmost Array structure would have caused a crash

* mi_xmlrpc_ng: Remove an incorrect free operation

Completes commit d047e10

* Fixed typo

* Obey USE_SYSV_SEM and USE_PTHREAD_MUTEX.

If USE_SYSV_SEM or USE_PTHREAD_MUTEX are defined via Makefile.conf, do you force autodetection (based on arch type) of the locking support.

* Fix bogus destroy of a RW lock.

* Proper support for USE_POSIX_SEM option in Makefile

* Fix bogus set locking functions.

It is used for SYSTEM V locking only, looks like a copy'n'paste error.

* call_center: obey lock_set interface

* Fix warning in SYSTEM V locking functions

* Added some comment

* acc: Remove deprecated modparam dependency

* Update makefile to support gcc 6.1

Fix gcc 6.1 warnings

* acc: properly detect parsing errors

* dialplan: Fix a rule tie-breaking bug

When an input string would match both a "string" rule and a "regex"
rule, the priority based tie-breaking was incorrect (now favouring
the bigger priority instead - opposite to default module behavior).

Thanks to @paolodepa for suggesting this fix
Fixes issue OpenSIPS#696

* dialplan: Improve documentation

Added paragraphs regarding rule types along with explanations on
they way priorities and rule tie-breaking work.

* dbtext: convert DBG to ERR for better debugging

* clusterer: proper translation to bigint for dbtext

This creates the proper type for bigint in the clusterer table for dbtext

Thanks go to Trevor Francis from 46Labs for reporting this
Close OpenSIPS#699

* Improve error reporting for unknown script vars

Fixes OpenSIPS#574

* Fixed missing MI reply on pua_publish.

Properly send an MI reply for the async pua_publish with Expires 0.
Many thanks to Damien Sandrs for invetigating and reporting.

Closing OpenSIPS#657

* add license to rw_locking.h header

* Link the dialog cell into internally generated requests from the dialog module

Fixes OpenSIPS#839

* [acc] fix double free issue for multiple dlg callbacks

	The last byte in acc flag mask now holds a ref counter in
the last byte. The counter is increased each time a dialog callback
is invoked, and decreased for each free function corresponding to
a callback. When the ref counter reaches 0, flags can be freed.
The atomicity of the ref counter is based on the fact that
dialog callbacks and their free functions are called sequentially,
one after the other.
ACC_DIALOG_CONTEXT and ACC_CDR_REGISTERED flags where moved in the
7th byte of the flags.

* Fixed proper cleanup on failure of tcpconn_new()

The chances for going for error cases are very low, still let's do it in the proper way

* If POSIX sems are used, be sure to link against pthread lib

* Fixed interface matching in loose_route()

If port is missing in Route URI, do not assume default 5060, but consider the schema and protocol (they may require a different default port).
Ex: sip:10.0.0.5;transport=tls was previously handled as sip:10.0.0.5:5060;transport=tls, which is wrong as the default TLS port is 5061
Reported on mailing list by Ravitez Dondeti.

* Fix documentation on former b2bl_key_avp module param

* load_balancer: Fix a possible crash

Could have led to a segfault when OpenSIPS would run oom

Reported by Qasim Khan

* Proper handle the case of no usrloc domain registered.

Prevent get_next_udomain() crashing if there are no usrloc domains registered (reported by Qasim Akhan on users mailing list.
Do not enable the pinging support in nathelper if usrloc has no registered domains.

(cherry picked from commit 8f0c677)

* Fix error handling in DB writes.

If inserting/updating a dlg record in DB fails, do not exit with error, but continue with the rest of the dialogs.
Credits for finding and reporting this go to Rik Broers @ Motto

* Removed unused "error" jump label

* Removed wrong "NOT NULL" constraint over the contact DB fields

The code actually handles the case of NULL callee / caller contacts, so DB must allow NULL values.

* Removed compilation warning

implicit declaration of function â"sched_yield" [-Wimplicit-function-declaration]

(cherry picked from commit 8ef8d79)

* [mi_xmlrpc_ng] fix fault incompatibilities with xmlrpc standard

* Consider WSS also a SIPS protocol

Reported by Varghese Paul ( @varghesepaul )
Closing OpenSIPS#899.

* Fix evaluating the SIP port from a SIP URI.

Use the new function get_uri_port() to evaluate the port and proto, in a SIP wise manner, form a SIP URI. If port/proto are not explicitly set in the URI, consider the default port for the used transpor proto. If protocol misses, we assume the default protos according to the URI schema.

NOTE: it is completly bogus (and dangerous) to assue 5061 if SIPS schema is used as:
1) SIPS can use used with WSS, which actually has 443 port
2) TLS can pe required via transport param in a SIP schema URI too

* Fixed typo in comment.

* Fixed migration of Call Center tables

Reported by John Quick.

(cherry picked from commit d090114)

* Fixed forcing FAST LOCKS for arm6.

Use FAST locking support for arm6 too.
For Linux, use POSIX as default locking support.

* Fix docs on missing module dependency.

If replicate_contacts_to parameter is turned on, usrloc depends on the clusterer module.
Credits go to Sammy on mailing list.

* [acc][bugfix] enable acc flags refcount only after dlg callbacks called

* Fix memory corruption on $stat() vars

The $stat() var specs are kept in pkg, while the name (if stat not found) is kept in memeory. This means all the copies (form all procs) of the specs will point to a single shm block. It is not safet to free this block as you have no idea how many copies of the spec (from other processes) still refer the name.
Closes OpenSIPS#902

(cherry picked from commit 4baead7)

* Fixed failure to enable NAT pinging.

Commit 8f0c677 introduces a bug in testing is usrloc domains are available, and if not, to disable the NAT pinging in nathelper. The test is wrong as it is done in mod_init, while registrar module registerd the usrloc domain via fixup function, after the mod_init section.

Reported by Nick Altmann

* Add support for SIP URIs without user part in 'avpops' module.

This module provides a set of avp_db_xxx functions which take pseudo
var and flag as first argument. Flag can be one of username, domain,
uri or uuid. Previosly avp_db_xxx functions used to return an error if
flag has been set to username, domain or uri and specifed pseudo var
did not contain username and host after parsing as SIP URI. This
behaviour seems to be strange because if flag is being set to
domain/username and sip URI contains domain/username we can still
load/store/delete this variable.

(cherry picked from commit 459f2e9)

* dispatcher: round robin uses weights to select destination

* dispatcher: updated documentation for round-robin change

* usrloc User-Agent filtering: Fix memory corruption

The "ua_re_check" macro added by commit e5cb980 is broken in several ways:
    * unsafe read operation on shared memory
    * unsafe write operation on shared memory
    * incorrectly handled error case, without restoring the backup byte

This patch corrects the above issues by extending the user_agent buffer.

* Update rtpproxy.c

When building I/O vector for command to rtpproxy in "force_rtp_proxy_body", after an IPv6 address is detected and the "6" option is added, increase the length component in the I/O vector so it is passed correctly.

* Update rtpproxy.c

When moving stored parameters from Branch AVP to Dialog variable, make sure that the integer value "setid" is handled correctly so that it remains valid for the remainder of the dialog.

* rtpproxy: no need to update the len for IPv6

* Fix proper testing of context content

If a STR is register to the context, a valid STR * will be always returned , so we need to test the content, not the pointer.

(cherry picked from commit 968a8a8)

* [sqlite][bugfix] free column names when freeing the result

* init: use the specified CFGFILE in debian init

In case the CFGFILE changes in the init script, opensips will still start with
the compiled file instead of the one configured

* proto: always populate default values for protocols name and port

This allows you to print the protocol you received, and its associated port

* Fix wrong number of columns when preloading via a DB backend without Fetch support.

* Allow proto modules to populate its name

* Fix script varibles for providing port and proto (as part of SIP URI).

If the SIP URI does not have an explicit port or proto, determine the default port/proto in a SIP wise manner (rather than returning 5060 / UDP) (Ex: sip:example.com;transport=tls has default port 5061 and not 5060 ; or sips:example.com has default proto TLS and not UDP).

Affected variables are $dp, $rp, $op and $dP, $rP, $oP

* Fix dialplan module when using db_text backend.

The db_text makes no difference between NULL or "empty string" values in DB -> both are internally translated as NULL . The dialplan module, in a very abusive way, forces "not null" (in DB schema and in the code for data validation) even for columns that are optional (like subst_exp, repl_exp, timerec and attrs). Besides being bogus (if a column is not to be used, you have to set it to empty string rather than let it NULL), it makes impossible the usage of db_text with dialplan.
This fix allows (DB and code) the mentioned DB columns to be also NULL.
The change is backward compatible, it should not break any existing usage of the dialplan module.

(cherry picked from commit 8f54897)

* Refactor commit 58a944c

* Fix compiler warning

Using gcc 4.8.4, we would get:

net/trans.c:43:2: warning: missing initializer for field ‘name’ of
‘struct proto_info’ [-Wmissing-field-initializers]
  { }, /* PROTO_NONE */
    ^

* [siptrace][bugfix] fix bad macro in siptrace(trace local ip logic)

This commit closes OpenSIPS#916
Thanks to @Tinet-AaronAn for reporting the issue

* usrloc: Fix an operator precedence bug

Introduced in commit 03398fb. Oops!

* module statistics: Properly update the "real_used" memory stat

* Merge pull request OpenSIPS#919 from Danfx/2.2

Fix memory leak: after sqlite prepare was deleted stmt compiled, free…
(cherry picked from commit 308ff0d)

Conflicts:
	modules/db_sqlite/row.c

* [sqlite] fix warning

* permissions: fix get_source_group() return

In case a group is not found, return -1 instead of true

* acc: Fix incorrect Request-URI handling

If the config script does not include any Request-URI altering logic
(e.g. no lookup() or $ru manipulation), the acc module would incorrectly fill
in a "msg->new_uri" field which should NOT be freed into the SIP request
structure, leading to the memory pool being corrupted upon transaction release.

Credits to Guillaume Lacroix for reporting

* fix core database engine bug introduced with commit 980f15e

* [db_sqlite] fix memory management bugs

* core free function was used to free starting with commit 980f15e
which was not freeing the memory correctly(result rows were
allocated all at once, but in the current version they were freed
once at a time);
* check if memory is allocated to prevent core dumps;

* [db_sqlite] remove unnecessary file introduced in commit 5936274

* Fix socket selection for outbound UDP.

Do not use the bind_address of the process when comes to send an UDP package (bind_address may be different from process to process, so the selection may give different results, depending on the processes sending the UDP).
If you have a sip_msg, try using received interface of the msg (if matches), otherwise use the first UDP interface.

* Fixed compiling on arm6 with fastlocks

Partial revert of 058e16 as we need some extra asm code for fast locking on arm6.
See OpenSIPS#923
Closes OpenSIPS#912

* Fix error and warnings for compile flag USE_SHM_MEM

Fixes OpenSIPS#905

* Fix error message when a route is not defined.

Print the name of the route too - the ID is irrelevant for the script writter.

* dialog: advance to next cell in case of error

* [acc][bugfix] check if database loaded before using its handler

* Fix compiling warn on missing return

* Fix building Via Branch in stateless mode

Instead of copying the branch value from a previous statefull Via header (which may lead to overflow as OpenSIPS has a maximum value for the built branch), we generate a new branch value based on the previous Via branch - in this way, we have full controll over the length of the resulting Branch and we also inherit the uniqueness of the branch value (from the prev Via hdr).

Reported by Gupta, Rahul and Elliott, Ray

* Fix populating blacklists.

When creating the blacklists, use the port and protocol of the destination too, otherwise the rules may conflict or be too wide to be used (like 2 destinations with same IP but different ports).

* Fix populating blacklists.

When creating the blacklists, use the port and protocol of the destination too, otherwise the rules may conflict or be too wide to be used (like 2 destinations with same IP but different ports).

* Fix populating blacklists.

When creating the blacklists, use the port and protocol of the destination too, otherwise the rules may conflict or be too wide to be used (like 2 destinations with same IP but different ports).

* Fix advertised port and address per branch.

Before the advertised_port/address are preserved only in the UAS part of the transaction - that means it is only one value and it is from the setting done in Request Route; whatever later setting done in Failure Route or Branch Route are not preserved at transaction level (even if they are used on the spot, for sending out the INVITE).
So, when we have to build a local request (ACK or CANCEL), we do not remember which specific address/port were advertised for that particular UAC (branch).

Fixes OpenSIPS#917.

* add debian packaging for proto_wss, proto_tls and tls_mgm

Reported by Rik Broers
Close OpenSIPS#931

(cherry picked from commit b40035e)

* rest_client: Fix incorrect trim operation

* permissions: allow any supported protocol

Before this commit, the protocol check was hardcoded in the module. This
commit allows to add in the permissions table any transport protocol
supported.

Thanks go to Kirill Galinurov for reporting this!

* Fixed memory leak on modules/drouting/drouting.c

This leak occures in function get_group_id() when do_routing is called without parameters in opensips.cfg.
In this case the dr_default_grp variable is not equal -1 and 'return dr_default_grp' is executed without freeing the res variable previously allocated for query execution.

* Remove unnecessary test.

"res" cannot be null at that point

* Extended the callback in dialog module.

1) avoid deadlock if from a dialog callback run under the lock (like DLG_SAVED) you use dialog functions (via API) to add dlg vals or set profiles.
2) renamed DLG_SAVED into DLG_DB_SAVED
3) added new DLGCB_DB_WRITE_VP callback that is triggered (while dialog is locked) just before flushing the vals/profiles into DB - this will allow other modules to quickly insert / update dlg vals just before the DB flush (to take advantage of the dlg persistency, while handling dynamic values). <- this is required by some ongoing work in ACC module.

* 	[acc] introducing new extra/leg engine; module redesign

	Redesigning accounting module extra values engine raised
    new problems which in the end were solved by redesigning the
    whole accounting module.
        First of all an accounting module context was created
    which is available for the whole dialog lifetime. Having
    this mechanism all values that were stored in avps or dialog
    values are now being held in this context.
        Using the new dialog callback that is triggered at shutdown,
    extra and leg values are not abusing anymore of dialog values.
    We store them there only when OpenSIPS closes by any means. This
    made the code look a lot cleaner and the program faster by not
    creating a dialog value for all INVITEs and restoring it for each
    BYE.
        Accounting module extra values new engine are the main purpose
    of this commit. There are only two variables now, called
    $acc_extra and $acc_leg. They are visible during the whole lifetime
    of a dialog and provide a much cleaner and easier way to use this
    powerful engine.
        New parameters have been defined, extra_fields and leg_fields
    through which one can define tags and log values. The tags are
    used to reference $acc_extra and $acc_leg variables, whereas the
    leg_fields will be the value that you will see in the logs.
        As concerning the acc_leg variable, new legs can be created
    using acc_new_leg() function. The value of the current leg can
    be retrieved using $acc_current_leg. It's the script writer the
    one who has to decide when is the moment to jump to a new leg.
        Also from this commit diameter support from acc module has been
    removed. Diameter didn't have any support and it wasn't
    compatible with a diameter server.

* [acc] updated docs for previous commit

* [acc] fix bad condition when fetching context from dialog

* Added support for internal async I/Os

Module care register FDs to the reactor in order to be triggered when data is available (and run a handler).

* Better naming for the async script related functions

* Fix handling async in sync mode upon failure

* tm: Fix loader error
jnewman02 added a commit to Vocalocity/opensips that referenced this issue Jul 30, 2016
* Fix usage of t_reply_with_body() with reply lumps.

Force pushing all reply lumps (headers added to the reply) when using t_reply_with_body() - the function takes the msg from the transaction, not the real msg; so we need to be sure that the msg in transaction was fully cloned.

Reported by Giuseppe Cardone on mailing list.

* Check if at least one DB URL is provided in avpops

Reported by David Sanders (@dsanders11).
Closes #644 .

* Dialplan module should honor db_default_url
(cherry picked from commit 566d4db2cc634bfb0bcbd578acb70d1b69153d48)

* Dispatcher module should honor db_default_url
(cherry picked from commit 684846dd11573161958c0276b582e798c77a18d9)

* memset all connection memory to 0 to avoid unwanted values

* on DB error: avoid double free;release only in destroy function

* fix compression module bugs

* proper error messages on compress
* correct buffer size aproximation on gzip compress(10% + 12)
* fix bug on decompression

* Updated to support CNAM diversion use case.

* ratelimit: avoid deadlock if counter is not updated

(cherry picked from commit ec25c07c2e8b2baf792bd49f0044adb4a8f52573)

* Fix `make menuconfig` compile warnings

(cherry picked from commit b9fe3c2cf1a2f74fbaa451edfbfd597496bec747)

* fix: some sh(busybox) do not support syntax of `$(< file)'

(cherry picked from commit ffb25541b6bf4ee841072787f2a09c06c4885ab1)

* Fixed ACKs CSEQ number when doing in-dialog pinging

The ACK CSEQ number does not depend on the number of pings or other in-dialog requests since the INVITE transaction, it must be the same as the INVITE
Closes issue #680

(cherry picked from commit 26a0a62621f6d1e4ea9fee90684a143fbfdc8494)

* exec: Clarify what not to do with exec().

See:
https://github.com/OpenSIPS/opensips/pull/375#discussion-diff-19524753

* fix context reusage if async is made

This affects timers and failure routes that are supposed to reuse a static context

* context: add destroy function for registered ctx vars

* Fix potential memory corruption on TCP write errors

This patch fixes a well-hidden TCP connection referencing bug which
would only reveal itself upon running into failed TCP send() operations
due to various reasons (e.g. full send buffer) in high-traffic environments.

Credits to Hieu Ta and Don Steul from Jibe Mobile for detailed reporting
and providing an adequate replication environment

(cherry picked from commit 3e1a1a719215814f983001eef199ad01a263244f)

* TCP aliases: Fix more race conditions (issue #589)

_tcpconn_find() returns a pointer which should never be used outside of
TCP lock. This patch completes commit 22f4c1a2e05 by fixing two
additional issues of the same type in tcpconn_add_alias()

(cherry picked from commit cb5eebe00ea735f290a213ea74f55b4afcc06236)

* Fix compiler warnings with NO_DEBUG, NO_LOG

Also add a handy macro for future usage

(cherry picked from commit 48b88bd9a3b054992a9260f4de227af9853c1dea)

Conflicts:
	modules/emergency/emergency_methods.c
	modules/emergency/subscriber_emergency.c
	modules/usrloc/udomain.c

* run destroy context when the message is sent

Credits go to 46Labs for discovering and providing test scenarios

(cherry picked from commit 28bcadf6d874e8e675a7d51ba5288438d463848e)

* properly handle async functions when reactor cannot fullfil the request

Credits go to 46labs for debugging this

(cherry picked from commit c18c8ea1f655a34e67eb94e4c7484da6d6965582)

* fix mem leak in permissions

* Fixed Post Script callbacks triggering in Async.

If the async engine in TM detects a SIP retransmission, break script and run the Post Script callbacks, othewise the transaction will stay ref'ed for ever.
Credits for spotting this problem go to Razvan Crainea.

* topo_hiding: replace LM_INFO with LM_DBG for debugging logs

(cherry picked from commit 3ae7e37172b5ce3142e8448972a84a49d0faa53a)

* async: store cancelled and e2eack transactions in async ctx

This fix prevents transactions from being unrefferenced when dangling
transaction pointers remain stored in static variables.

(cherry picked from commit 3f3b6fdc71fb7f86f84e02fdf5f084bf9360deba)

* tm: free async context when resuming

This commit fixes context_alloc memory leak

(cherry picked from commit d69d085b886c621cd54554e44643f0f7849c5f0f)

* dialog: increase ref when setting dialog

(cherry picked from commit 528655892df6da11cbaba32833d3521187d399ca)

* fix str2int and str2sint input params check

* if a void string was given to the function ("") 0 value was returned which was not correct
* input values should be checked for NULL

* check if startup_done var is allocated before trying to set it

* fix warnings reported by Ovidiu Sas

(cherry picked from commit 19edf6159bb5a3ac639bd1792c5d2484f165b960)

* acc:evi: if the request failed send a missed event

In case the acc_evi_request() function was used on a failed request
(code < 300), send a missed event rather than the normal one.

Reported by Trevor Francis from 46Labs

(cherry picked from commit 18f5da047e6b87434c97f0ddee8a70d5baae79d7)

* RPM spec: remove excess rest client package

* dialplan: enhance debug probe

(cherry picked from commit f0a75d9ec6040370736a7200ac7c4659e1a052c8)

* dialplan: after inserting a new partition, set the pointer to the next record to NULL

(cherry picked from commit fb3923d7d578a9a9d3a2c0c3427df3c1c9ee1f44)

* dialplan: memset to 0 newly alocated memory for dp partition
 - suggested by Liviu Chircu

(cherry picked from commit 1cf5dd8e89a6f05a09a1964c2d53f6aee8ce6131)

* dialplan: allocate the right amount of memory when creating a partition

(cherry picked from commit bd35916e2e8d09d362f0e298e5e19469f7a53a8f)

* dialplan: check if memory is properly allocated when updateing partition records

(cherry picked from commit 889f353cecc7a9825867773eb57b0f9d6c21bc35)

* fix dangling db conns bug

* database are now started in child_init
* avoid opening db conns in mod_init and leaving them in the db pool because
when fork() shall be done all the processes will use the same db
structure therefore the same tcp connection

(cherry picked from commit 47b5dc900efd29f14397807e1947c99540159e26)

* Fix bug in populating the PIDs

(cherry picked from commit eccbf8d5d30bea765f19ab2b9816a57386091692)

* Fix proper reporting for the statistics types.

This fixes the charting of SHMEM related stats in Control Panel

(cherry picked from commit 52d5ef5bdf03aacb245420bc0193069a7b38322a)

* Reduce the amount of "useless" DBG's

(cherry picked from commit 0dca32bddce736ef9fcde5ccdb4674017f9fdf08)

* RPM spec: increase max files limit and add dependencies

* RPM spec: move ulimit to init-script

* properly handle epoll events

* b2b_logic: parameters cannot be lower than 1

(cherry picked from commit 152f22e63cc3f045492367b18ed5357cf5a89f2b)

* Return <null> value for missing AVPS.

Maintain database result integrity by supporting null column values.
Closes #693 and #677

* Merge pull request #681 from shiningstarj/dialoginfo-memory-leak

Presence_dialoginfo: Fix memory leaks in notify_body.c
(cherry picked from commit ab5cd613df4ef9831a33923ba5e51bf572203c8c)

* Fix DB key when updating the destination state.

Beside SIP URI, use the SET ID too when performing FB updates to set the destination state.
(a SIP URI may be present in multiple SET IDs)
Closes  #711 , reported by @mishehu

* b2b_logic: set late SDP negociation flag

For the entity that initiates a call, late SDP negociation is used, because
the SDP of the first entity is not known. This patch sets the late_sdp flag
for that entity, to flag the b2b logic to send the ACK with SDP.

This bug was reported on the mailing list by Sebastian Sastre.

(cherry picked from commit 20df8362455a60aaded86daa9a79d189b73a1880)

* Usrloc: modify invalid contacts behaviour

* stop inserting a contact even though received is OK
(call parse_uri() for each contact)
* at startup, if a bogus contact is found continue processing,
letting the user know that he has to remove that contact from
the database

* comparse_uris: unescape all characters in user field

* Manula cherry-pick of ef2232

* strip_body(): check if content-type exists

* avpops: start without db_url if no func is using DB

Conflicts:
	modules/avpops/avpops.c

* Merge pull request #746 from lemenkov/remove_has_sdp

rtpproxy: patch: has_sdp() does not exist
(cherry picked from commit 2e59ba930001593fcd8b60cf446979f69594bedf)

* cachedb_mongodb: Fix crash when losing DB connection

Tested with mongo-c-driver v0.6. It turns out that the driver's
mongo_cmd_get_last_error() does not always return an iterable bson
structure. This patch adds a safety check, so that iteration is skipped.

Reported by Sasmita Panda
Closes issue #747

(cherry picked from commit 2e5160e5e1d895a5694ba4297058e1ca587e787a)

* regex: Fix implicit declaration of 'isspace'

(cherry picked from commit 36072086f7996af4f1e4f4446017561d706250b3)

* Fix several print formatting bugs

%*.s is a format specifier for string width
%.*s is a format specifier for string length

99% of the time, we want the latter one and _not_ the former.

(cherry picked from commit e0c0a54ca599c0de9fa84ab6482a5698bf199e3b)

Conflicts:
	modules/event_flatstore/event_flatstore.c
	modules/proto_tls/tls_params.c
	modules/usrloc/dlist.c

* redis: add timeout for connect and query

This prevents OpenSIPS from blocking waiting for a connection to be
established.

Fixes #753 reported by Nick Altmann

(cherry picked from commit 76034ad60dfd991232ac3053c07f7a72de234e43)

* Fix pinging partitioning from nat_traversal.

Do not use the static counter as the timer routine gets executed in various processes now - better use a shm counter.
See all the details in #751
Based on the PR #751
Closing / outdating #751
Credits for finding the fix and comming up with a solutoin go to @aerringer.

* Fix race condition between retransmission and wait timer in TM.

Overlapping of retransmission timer and wait timer may lead to inconsistent timer list -> various crashes around TM timer lists.
Related to #749, #732, #723.
Many thanks for Trevor Francis ( @46labs )  for helping with the troubleshooting.

IMPORTANT NOTE: this is a temporary fix as it simply avoid the collision between the two timer routines - normally the routines themselves should be safe to run in parallel (more digging is required here).

(cherry picked from commit ea6e1fa7fed29efed6057894a8cc4054308160b3)

* Allow retransmissions and wait for reply/timeout on canceled branches.

Do not do anything about branches with no received reply; better continue the retransmission hoping to get something back; if still not, we will generate the 408 Timeout based on FR timer; this helps with better coping with missed/lated provisional replies in the context of cancelling the transaction

Many thanks to Maxim Sobolev for bringing this under discussion.
More to be read:
http://lists.opensips.org/pipermail/devel/2015-November/018623.html
http://lists.opensips.org/pipermail/devel/2015-December/018810.html

(cherry picked from commit 0dfb46df96d594c9b592d64913a44ab1cccd80e3)

* [snmpstats]more hints for setting up in the docs

(cherry-picked from 6e7535207d5531e0fc2562d05b874acd30488368)

* [sipcapture]mi_cmds were registered twice

(cherry picked from commit e36453ee6c687975382c3125b1dad9a382be041a)

* [sipcapture]completely remove mod_init mi_cmds registration

(cherry picked from commit 02defafe421fa1ff4ab0f05f63cc490fa1717ff3)

* ws: release TCP connection if not static

This should fix a memory leak (reported in #743 by Eric Tamme)

(cherry picked from commit 29190f3898e33c410745a9acce2f5ae8df650da1)

* tm: remove unused variables

(cherry picked from commit 666cf8316d3105a2920b68df8d600be02c8943bb)

* proto_ws: fix common variable used

* fixing coverity found defects - invalid memory access / memory corruptions

(cherry picked from commit c537cb8151e9436d88a9410e02ef11a093008ff0)

Conflicts:
	modules/dialog/dlg_tophiding.c

* fixing coverity found defects - resource leakage

(cherry picked from commit e09f09ae89aff31393b04e40b4f82632fd4f50ff)

* fixing coverity found defects - null dereference, break missing

(cherry picked from commit c004967f7c272e5b9043f5f3e330827f0682a009)

Conflicts:
	db/db.c

* fixing coverity found defects - processing initialized variables, control flow, invalid expressions

(cherry picked from commit b22844e0a1d4d54d0f8f836837f8447154799011)

Conflicts:
	modules/drouting/drouting.c

* fixing coverity found defects - logical fix in ul callback check type, null dereference

(cherry picked from commit aeedb7d94439b774d35009899b04d2c6060437d0)

Conflicts:
	modules/dispatcher/dispatcher.c

* fixing coverity found defects - null dereference, invalid e164 number check

(cherry picked from commit b8e2318ba58e56484294913e21a74a7cd79adf40)

* fixing coverity found defects - copying into fixed size buffer

(cherry picked from commit 92a7361eda2c6cd6e9ad637dab187cf87fefa987)

* fixing coverity found defects - copying into fixed size buffer without check, db_http

(cherry picked from commit d471234733de299c88f1036ba17a2406b8ae7a89)

* fixing coverity found defects - null dereference

(cherry picked from commit b578dda307f24e56f456e5b02c0c7591ed6746a4)

* fixing coverity found defects - null dereference

(cherry picked from commit 906bb9172b4ce0ab0e7bf4eca7da58211aa8ac5b)

Conflicts:
	cachedb/cachedb_id.c

* fixing coverity found defects - null dereference & broken logic

(cherry picked from commit 81aeba42ca04df7b3fc42ab2498717cc31227967)

* fixing coverity found defects - memory corruption, null dereference

(cherry picked from commit fd57609f5411e622dca593b729e1826269243c5b)

* Coverity PR: Fix bad conflict merge

* 2.1.2: update changelog and minor version

* RPM spec: update version to 2.1.2

* [avpops]check if asyn funcs used in separate loop(on acmds struct)

(cherry picked from commit 939b3433f3fe4c0887b818e856ff6e857c9e60d0)

* function search: properly search through switch st

(cherry picked from commit 446dd5876b633c95000e7b80a0ef8a3058c018a1)

* [avpops]fix acmds instead of cmds

(cherry picked from commit 9bd4c77ade737108aa45a755bb4e1055b4adca36)

* [siptrace]fix proto issues

leave IPPROTO_* format in hep header(which is returned by
pipport2su() function) and after setting it use OpenSIPS
format for sending(PROTO_UDP)

* RPM spec: prepare for new build system
- remove obsolete triggers
- change tarball name and url

* uac_registrant: update timer handling
 - closes #758 - uac_registrant wrong hash sequence

(cherry picked from commit be371dab7fa9b6fa495b99e69e623fed73500a74)

* fix calls per minute for fraud_detection module

Now the calls per minute parameter is build as consisting of an initial
time(t0) and a 60 seconds window(as was before). Each window slot holds the
calls received in that second(as before). The difference is that now
these parameters are updated based on three conditions:
* we receive the call between [t0; t0 + WINDOW_SIZE(60s)] - we only update
the number of calls for that slot(t0 + current time) and the calls per minute
parameter
* we receive the call in the interval of [t0+WINDOW_SIZE; t0+2*WINDOW_SIZE] -
we do the following: move t0 in current call time - WINDOW_SIZE, invalidate
all the calls we knew of from t0 to current t0 (current call time - WINDOW_SIZE)
* we receive a call after 2 * WINDOW_SIZE(60 seconds) + t0 - this invalidates
all the calls we knew of since the window is not does not contains calls newer
than the last 60 seconds;

(cherry picked from commit dd25c63adb8832d59861cf98b6fba1a2ad89a307)

* update ChangeLog with all commits in 2.1.2

* uri: fix e164_check overflow checking

Reported by @ferrored on github
Closes #762

(cherry picked from commit 70e5a656c3cd4aa14757245dd710d3869575d3ca)

* db in string or int pvar for avp_db_query()

(cherry picked from commit 8a512731df99621025744aaa25b17931759b91d4)

Conflicts:
	modules/avpops/avpops.c

* Fix restoring leg route set.

Reported by Søren Andersen.

* Merge pull request #664 from wdoekes/wjd-allow_unset_dlg_in_req_route

dialog: Document that unset_dlg_profile can be used from request_route.
(cherry picked from commit 8d23d9bd7e55ede0f68c042204096fe1b4087dae)

* Coverity PR: minor refactorings

(cherry picked from commit 975024142e724b315203dd14c58056a77f3d3959)

Conflicts:
	modules/ldap/iniparser.c
	modules/usrloc/dlist.c

Credits to Ognjen Seslija for the bug report

* Missing module "emergency" in extra list.

This was braking the creation of extra tables (at least in postgres is did).
Reported by Nathaniel L. Keeling III on mailing.

* increase versioning to 2.1.2

* Fix double free in case of errors when running MI command

(cherry picked from commit ce6e8444afeb887f30d38cf90b0176ae9960fb72)

* Fix STANDARD and EXTRA list of tables.

Permissions (in postgres) were not granted for the missing tables.
Reported by Nathaniel L. Keeling III on mailing list

* Removed double listing of "address" into EXTRA_TABLES.

* Fix bugs in modules-readm target.

(cherry picked from commit 0042b940dbffe057d06217845f399f758051c7fb)

* README files regenerated

* Fix codec handling functions when faulty streams are defined.

Bogus test on the return code of stream_process() (using bitwise OR for -1, 0 and 1 values :O ), leads to a generic failure to find any codec in any stream if there is an invalid stream in the SDP.
For example, if a video stream is defined but with no codecs, stream_process() will return -1 for it (as it is a bogus stream). While iterating through all the stream (including the valid audio stream), the -1 ret code will discard any 1 future ret code due the bogus bitwise OR.

(cherry picked from commit ef82ca2368462c41f7115202e90f73d8ab16fd1f)

Conflicts:
	modules/sipmsgops/codecs.c

* Fixed wrong warning on memory leak.

Set the auth_hdr buffer to NULL after moving the buffer into the lump.
Reported by Colin Martin on mailing list

* Fix the sizing of the Async Reactors.

Adjust the size of the reactor accroding the limit of opens files.
Closing #765.

(cherry picked from commit 2efdbf8c45a35c57754ac14e64a356b9bb74fd5f)

* Fix calculation of timer set on 32b

A bogus bitwise operation broke the calculation of the timer set on 32bits arch.
Reported by @mshary (Muhammad Shahzad Shafi)
Closes #732.

* Fixed autodetection of the reactor size (open files)

If we auto-detect the size of the reactor(via rulimit), be sure we have enough pkg memory (and do the necessary correction).
If the open files limit is given, warn if the reactor will use too much memory.
Thanks to MAxim Sobolev for reporting it via mailing list and to @cepehutu
Closes #778

(cherry picked from commit 6dd88abca4cf6f6ec484e7616a584c92d7ff874e)

* fix async: context shall be destroyed only at the last async call

(cherry picked from commit 672cb13084891afffba881d2129fdb2037b3dba6)

* Fix freeing processing context after a second async jump.

If thw processing ctx was stored back into transaction (due a new async call), do not free the current ctx (as it became NULL).
Reported by Minh PHAN (@qmphan).
Closes #780 .

(cherry picked from commit 031304af8be6f683fc4706fb9091fd2b12705f6d)

* Fixed improper setting of Missed column's type.

Credits go to Pete Kelly (@petekelly).
Closes #703 .

* Fix IPv6 insertion in fix_nated_contact()

Add the [ ]  around IPv6 in the newly built contact URI.
Reported by Jonathan Hunter on the mailing list

(cherry picked from commit ce89e291e0616d80d555f1e386edde5bbd3922e9)

* proper compile on gcc 4.8

(cherry picked from commit 421e3e3b50808f47129dbbb9f987145c8226c0f6)

* Fix proper callig in local cancels with TH.

Extend the coverage of the preocessing context and TM context over the cancel_branch() function (in the timeout handler) so the TH callbacks can reach back the dialog and do the TH related changes.
Reported by Julian Santer on mailing list.

* Don't push throug RTPProxy streams with port 0 in SDP

(cherry picked from commit 5dec43a750c7af714dfec9ac9ef43cc0c33e2280)

* arm: unforce thumb mode

(cherry picked from commit c24b587316306da0e5d58130d8712f314de8cd7a)

* Improve qvalue parsing

* accept qvalues with no decimal digits (e.g. "1." and "0.")
  (this removes E_Q_DEC_MISSING from error.h)
* improve bad qvalue error reporting

(cherry picked from commit ed60363d9d66bf230872c535e3fc0cf7f117b2c7)

* Fix contact DB delete in CONTACT_ONLY macthing.

Do not use the callid as part of the key during the DB delete as it may changed (can be updated) in the meanwhile.
Reported by @ferrored.
Closing #764
Many thanks to @ferrored for his support in troubleshooting this issue.

(cherry picked from commit 23155e5acb415a68a81aa070b3c0bf272a47544c)

* SIP forking engine: Fix async-related issues

Previously (on OpenSIPS...), doing _any_ async operation at script level
after a destination set had been built (by lookup(), append_branch(), etc)
would have lead to unpredictable results.

This patch addresses the problem by moving the destination set storage
into the current processing context (from static mem to pkg mem).

Impact on memory usage at worst (12 branches for each request) is
an extra 30 MB of PKG memory per every 1000 cps.

(cherry picked from commit a7b287f5f566b87017a5bc7b3e68ac2fdef5b024)

Conflicts:
	main.c

* Blacklisting logic: Fix async-related issues

Similar issue to the one behind commit a7b287f5f. Static memory
holders are no longer compatible with async operations and need
to be moved into dynamic mem (pkg in our case) so that data can
be properly restored before resuming the script.

(cherry picked from commit 2e7588bb43547152d1a594c0ea40b416b1959233)

Conflicts:
	blacklists.c

* Order target dependencies to avoid FTBFS in parallel builds.

* SIP forking logic: Add extra NULL checks

This prevents a crash when no branches are pushed yet, but a branch
management function is called (e.g. t_replicate() or a write to
$(branch(uri)[0]) is done)

Issue reported by Trevor Francis

(cherry picked from commit 5e3f06800eb7a4d9367c1dce87f43ab8420bad5d)

* sync with latest debian package

* Makefile: dash cannot use variables that contain -

* build: change variables for other OSes

(cherry picked from commit cec0c7244e3eb53c5c08144e17d5e0c5441e5eec)

* destination sets: Add yet another NULL check

Reported by Ovidiu Sas
Fixes #806

(cherry picked from commit 5718e24ea3c1d231365202c22893403dc58785bd)

* debian: fix packaging config target

* update changelog and add berkeley deb

* support reproducible builds

* update spelling checks

* other spellchecks

(cherry picked from commit a547af5b71ca2e9b951c164de82d292e464d35c4)

* tls: update install path

* Updated to support STIR.

* loop: declare fd_map for devpoll

Reported by Nathaniel L. Keeling III

(cherry picked from commit fe785bfa6e5b2ec5cf06c1850cca860f08989820)

* Deprecate 'use UNIVERSAL'

(cherry picked from commit e5f0b55da6fd24b6e661801d26d4dd53b1793fd3)

* rename s_addr to avoid overlapping with Solaris structs

Discovered by Nathaniel L. Keeling

(cherry picked from commit 6c990040da2fd472993015f787b84a10768e1f6c)

* packaging: add back the memcache for lua building

* tcp: prevent invalid mem access

Reported by Saúl Ibarra Corretgé

(cherry picked from commit a607aa846f659f9edf5e08bdb13831e633cdde33)

* Allow setting branch flags when no branches are yet appended

Commit 5e3f06800e was too restrictive, since flags for "branch 0"
(a special branch, stored in current struct sip_msg) may be set regardless of
the number of append_branch() operations done previously!

Reported by Dragomir Haralambiev

(cherry picked from commit 6d1704c6c936921c504c8261ef5de1d710ed3d22)

* tm: Refactor some hardcoded static string lengths

This also fixes a couple of chopped MI error strings in "t_uac_dlg"

(cherry picked from commit 60d4d4bc1edc493aaedcee40976347d3fbe9094e)

* Merge pull request #814 from sippy/master_rtpp_ip6_fix

Fix an issue with IPv6 in the rtpproxy module
(cherry picked from commit f906d931a0908bee05b04843d397fa848158311e)

* Fixed leak due wrong return code handling.

Based on a patch provided by Jarrod Baumann (@jarrodb)
Closes #822

(cherry picked from commit 3b37b827746459a538fb86507414d4a26481a946)

* t_newtran() automatically sends a 100 Tryting for INVITE.

TO have a consistent behavior between:
	t_newtran();
	t_relay();
and
	t_relay();

(where in the first case a 100 Trying will not be auto generated), we do not sent the 100 Trying on r_relay (when transaction is built) but on t_newtan().
Reported by MAxim Sobolev.

(cherry picked from commit 0db77896288e7ef093352fc0a08f4035c1191bf4)

* dialog: Lower log level of state change errors

Out-of-order SIP requests are a frequent occurence in high-traffic
environments. The dialog module should not consider these events as
being critical, but rather as warnings, so they can be easily
filtered out from the logs.

(cherry picked from commit e403a2bc150b7f9c79a011f4acbcf68e4ce9f77d)

* Merge pull request #823 from jarrodb/db_postgres

Add JSONOID to pg_type.h for supporting JSON return types as DB_STRING
(cherry picked from commit e6bb7acb66cdc8cc1869ba1f8b7ce3ce123d7b39)

* Fixed memory leak on checking disposition hdr.

Free the parsed disposition body all the time (on success and failure) as it is not attached to any structure, so it will leak if not explicitly be freed.
Credits for reporting this go to Jarrod Baumann.
Based on an original fix from Jarrod Baumann
Closes PR #825

(cherry picked from commit 4601e5653be202912a3732f08cdafc63d64afe7f)

* Fixed async jump for end2end ACKs.

As end2end ACKs do not create a sip transaction, force sync for all async operations (as we cannot suspend and resume).
Closes #819

* Fix crash when using $si in non SIP routes.

If using $si in event, timer or startup routes, return a NULL value.
Use a dummy AF_INET from src and dst IPs.
Prevent crashing while evaluating $si by checking return code of ip_addr2a()
Closes #817
Outdates #828

(cherry picked from commit 2d0cebc0be2491984ce357afd89d41212866bc06)

* Fixed $TH_callee_callid to reflect '=' being an invalid character in callids
Closes #800

* topology_hiding: prefent crash at shutdown

(cherry picked from commit 00632a0b5a93f84531bb391bda2939b2ba351013)

* Reset to 0 the whole branch if failed.

If we do not reset, on trying to add the next branch (on the same position), we will end up with dangling pointers.

(cherry picked from commit d5c3bd1eed5f40f7425562f8bb65fe2f5c9fc678)

* Fix extracting TO hdr.

Do not add '@' if username is not present.
Reported by @DMOsipov on GITHUB.
Closes #818

* Fixed usage of Prep Statement on failed CDRs.

The number of inserted columns is variable (n+m or n+m+2), so we need different statements for each.
Reported by @apsaras (on GITHUB)
Closes #821

* Fixed port param for lb_is_destination().

It must accept integer values also, not only variables.
Reported by @telephone-man on GITHUB
Closes #808.

* Accept XMLRPC requests without params node.

If there are no parameters, the params XML node is not required.
Repored by Nick Altmann
Closes #826

(cherry picked from commit d20b3d05409fc5f712c75b86223fe955e57ec5c4)

* Prevent async in local route.

The way local route is implemented (triggered and terminated in TM module) does not allow async resumes, so, for the moment, we simply force all the async triggers to be executed in a sync way in local route.

* scripts/opensipsctl: complete support for optional database port

(cherry picked from commit 04d8a84f00e375a0ecf7d41a6b4f421d64018930)

* Fixed 491 Pending scenario in B2B.

Generate 491 Pending reply to the correct transaction (the new incoming one) and drop the requests (do not forward it).
Credits for debugging, reporting and fixing go to @DMOsipov .
Closes #679

(cherry picked from commit ec7b4e54bf7f09fb6ff56e8f8497563cf13719e8)

* Proper handling of isolated EPOLLHUP events.

capture and handle EPOLLHUP or EPOLLERR events even if they are not in conjunction with EPOLLIN or EPOLLOUT.
Many thanks to @santhosh-kumar for reporting and helping with troubleshooting.

Closes #829

* Improve robustness of core URI copying functions

Namely set_ruri(), set_dst_uri(), set_path_vector().

This patch corrects the behaviour of the above functions when they are
fed strange/corrupt strings, such as {NULL, 5} or {0x7fb..., 0}.

There are still plenty of pieces of OpenSIPS code which assume such
strings should be correctly processed, e.g. next_branches(), which may
lead to a whole world of problems ranging from segfaults, double free
operations and dangling pointers all the way up to intermixed shm/pkg
memory pointers.

The best way of addressing this issue is to simply accept such input and
zeroize (and free) the concerned sip_msg attributes.

Many thanks to Ovidiu Sas <osas@voipembedded.com> for in-depth error
reporting and assistance in fixing this issue

(cherry picked from commit 2787308f68e6ee878dcf710cd7b36992af62aab9)

* drouting api: Fix a double free bug

Crashes / memory corruptions could ensue after running "fraud_reload" MI
commands or during OpenSIPS shutdown, if fraud_detection had some data
to work with.

(cherry picked from commit 2380bbdaeb0af4efdb293b42ee1ad09f40e3e67c)

* TLS: Fix misleading error logs on accept() failures

OpenSIPS would always log SSL_accept() failures as being "rejected by
client". This is entirely not the case, as the errors may as very well be
server-side, due to cipher mismatches, failed peer verifications, etc.

Reported by Nabeel Shikder on the "users" mailing list

* Fix bogus log

* cachedb_redis: Prevent crash when re-connect keeps failing

(cherry picked from commit b501df74a231a987babe6eeadb3c676d8823619c)

* pi_http: return "200 OK" instead of "0 Unknown"

(cherry picked from commit 73f8117f2f5f01560b6698ad845cce0b485df203)

* Fixed bogus pkg_free on pointer in data segment

Reported by @dzhou121
Closes #854

* MI library: Add comments regarding a known issue

Currently, MI arrays cannot contain objects with non-identical
"name" attributes.

This patch also quickfixes this issue in mi_list_all_profiles() by dropping
the array idea altogether, in favour of a top-most object.

(cherry picked from commit 6c105015c3a0a02c6f65822f5ce52e12bd0ae108)

* [tls_mgm] properly handle SSL_ERROR_SYSCALL on SSL_shutdown

(cherry picked from commit bdcee39ebf04f8a74b926dc6e6c311487d3ef601)

* regex: fix spell-check in package

(cherry picked from commit 647ea214f1892f8901f562bc45e0e1e33b699aba)

* ratelimit: initialize the length of the algorithm

(cherry picked from commit 0eebf1058574c622ba3532fb520908da1c1d94a5)

* Updated opensipsctl.base to also search /sbin

The md5 utility is located at /sbin/md5 on FreeBSD 8.3. An additional common location was added to allow the script to accommodate this.
(cherry picked from commit ca87f55ad071257aa3b891347aadb55a7729d25b)

* [dispatcher] fix double allocation issue

(cherry picked from commit d6891363e3b3b4047a1948eb03fb6b6bab285885)

* Fixed bogus memory operations.

Fixed bogus free (of uninit pointer) if parse_contact() fails
Fixed shm leak on errors after print_rr_body
Fixed shm leak on success if record_route is present.
Reported by John Nash.

* Fixed preserving 3xx Contacts in TH without dialog

Reported by Pete Kelly.
Closes #656.

(cherry picked from commit 6184b96c94d0fcc298dbe5bce1cd0ca9fb0445d3)

* Fix bogus timer ref counter during expire update.

Many thanks to Trevor Francis for reporting and helping with troubleshooting and testing.

(cherry picked from commit 047b1b3e32a9af30dd44f2487460975ed7b3a815)

* Process sequential messages received in CONFIRMED_NA state

Due to UDP race conditions, sequential messages may be received
before the ACK confirming the initial INVITE ( eg. Re-INVITE sent
immediately as the call is established in order to force
a specific codec ) - also push these requests through the whole
dialog processing in order to avoid any future issues ( eg. CSEQ
updating which, if left unprocessed, will lead to generating out
of order sequentials by OpenSIPS )

(cherry picked from commit bfaf02242a98c464dfbdcd3c3ebf3fbb555bcc47)

* Fix a string concatenation operator bug

This patch fixes an issue with string concatenation where any NULL
operand would cause all operands to its left to be ignored when
computing the result of the expression.

Reported by Ovidiu Sas
Closes #870

(cherry picked from commit a420752f436a1f952c255df8d5dbe9ea59b0d653)

* re-register topo hiding callbacks after restart

Thanks to Pete Kelly for reporting this

(cherry picked from commit 4c84bd84ad67e71f174b3297ff3432ca21bafab4)

* th: fix dlg flag check

(cherry picked from commit 1b5802d2e4876e0d63eeeec5a6edcb7a2321e9d0)

* Fixed bogus name of  "pkg-config"

* Added extra log message on openssl 1.0.1e-fips bug.

If CRYPTO_set_mem_functions() fails, make a note on the openssl 1.0.1e-fips bug, so users may have a hint on the actual issue.
See more  #834.
Closing  #834.

* [mmgeoip] allow chosing memory caching type

	Before GEOIP_MMAP_CACHE was used causing a segmentation
fault when database file was changed. Now users can choose between
reading the database directly from file, cahing it into memory with
the possibility to change the database file at runtime.

(cherry picked from commit ecf5032aaafbe5a93bbfc3562c4b3358548839e7)

* Revert "Accept TCP aliases by default"

This reverts commit d62bc967b0d6784d2baced88b895da57f3f4ab9a.

Firstly, TCP connection reusage (RFC 5923) should only be employed between
TLS endpoints - only TLS allows the endpoints to authenticate each other
during connection setup, preventing unauthorized connection hijacking.

Secondly, aside from any security considerations, RFC 5923 must
not be employed fanatically (Proxy-Proxy, Edge-UA, UA-Proxy) on any TCP
connection (especially disregarding the ";alias" Via parameter!), but
rather only between adjacent SIP entities who can both initiate a
connection towards each other, and also support the RFC. In the real
world, we're basically only talking about the Proxy-Proxy usage case, as
any SIP UA scenario will most likely involve some form of NAT and a
Proxy that cannot open connections backwards, towards the UA. In these
cases, TCP connection reusage is _completely_ out of the question, as a
single UA might end up receiving all calls of all users behind their
public IP.

Thanks to Jonas Borjesson for reporting the problem in the first place.

(cherry picked from commit 715339fdd25bc74797e6f978d164eb0c4d5669ce)

* TCP connection lookup: Add matching by transport

The fact that all currently supported TCP-oriented protocols have different
standard ports is not an excuse for not including the transport into the
match condition (i.e. dest IP address + dest port + dest transport).

This may very well prevent issues with messages being sent out over the
wrong TCP connection in a number of scenarios where we employ TCP connection
reusage over both plain TCP and TLS with a Proxy that specifies the same port
in the topmost Via header when it establishes each of the two connections.

(cherry picked from commit 13970bb65253f1b35156466c6f514a4c520d8893)

Conflicts:
	modules/proto_bin/proto_bin.c
	modules/proto_hep/proto_hep.c
	modules/proto_wss/proto_wss.c
	modules/tls_mgm/tls_mgm.c

* TCP alias lookup: Add matching by transport

Further improving commit 13970bb.

(cherry picked from commit ea699f0116a28cd03a0d1ff50da3fc6045ac3da5)

* mi_xmlrpc_ng: Fix a shared memory leak

(cherry picked from commit d047e1096e2f6624f776d9a031f92be3cc9a0a0d)

* mi_xmlrpc_ng: Remove an incorrect free operation

Completes commit d047e109

(cherry picked from commit 99f039e37cd79621b2dcc2b5ec2decc9e7c39670)

Conflicts:
	modules/mi_xmlrpc_ng/http_fnc.c

* Obey USE_SYSV_SEM and USE_PTHREAD_MUTEX.

If USE_SYSV_SEM or USE_PTHREAD_MUTEX are defined via Makefile.conf, do you force autodetection (based on arch type) of the locking support.

(cherry picked from commit 39592dc9f25ecee982156e365d160642bdde48e8)

* Fix bogus destroy of a RW lock.

(cherry picked from commit 83f394579a88a6a9185342cf5f92401ef5c18e5a)

* Proper support for USE_POSIX_SEM option in Makefile

(cherry picked from commit 5e40aaf9c3ed8ab4381d847f6a1f6a01a8113bf7)

* Fix bogus set locking functions.

It is used for SYSTEM V locking only, looks like a copy'n'paste error.

(cherry picked from commit 4bcdf4e6aee07ef965f6ae573b289f3fd082fdde)

* Fix warning in SYSTEM V locking functions

(cherry picked from commit 53b3f402a4d9fb0ff1ba30288d810d41d6b55b1b)

* call_center: obey lock_set interface

(cherry picked from commit 4a226ced3309a045b11f6e651bebd6b076faefa2)

* dialplan: Fix a rule tie-breaking bug

When an input string would match both a "string" rule and a "regex"
rule, the priority based tie-breaking was incorrect (now favouring
the bigger priority instead - opposite to default module behavior).

Thanks to @paolodepa for suggesting this fix
Fixes issue #696

(cherry picked from commit cbdd79ab3f6d772c6ef1fb7afc44990e9cad294e)

* fix bin crash if no listener defined

When using usrloc and dialog replication, if no bin_listen is defined,
OpenSIPS crashes. This fix ensures that if there are any replication
destinations defined, the binary listener exists.

Thanks go to Stas Kobzar for reporting this
Closes #652

* dialplan: Improve documentation

Added paragraphs regarding rule types along with explanations on
they way priorities and rule tie-breaking work.

(cherry picked from commit 46894f819d1d7d6092129b334e33956e89e5d4ea)

Conflicts:
	modules/dialplan/doc/dialplan_admin.xml

* dbtext: convert DBG to ERR for better debugging

(cherry picked from commit 0f08b26e40b31bb8af325ba62cfa32676c62ae86)

* Improve error reporting for unknown script vars

Fixes #574

(cherry picked from commit 97ace293dd4c7eb2fe8cd8fbee693455a5737861)

* Fixed missing MI reply on pua_publish.

Properly send an MI reply for the async pua_publish with Expires 0.
Many thanks to Damien Sandrs for invetigating and reporting.

Closing #657

(cherry picked from commit 60d01efe811ac7eeaa063032a309b1895c59e92f)

* add license to rw_locking.h header

(cherry picked from commit e3a57ac953259a0254a07198aabc88eaac9da9c2)

* Link the dialog cell into internally generated requests from the dialog module

Fixes #839

(cherry picked from commit 66937a2834d5680031f81c881719b43018fa06ad)

* Fixed bogus test when using POSIX or PTHREAD locks.

Reported by Steve Woolley.
(this was fixed on 2.2 and trunk when debug support was added for locks).

* Fixed proper cleanup on failure of tcpconn_new()

The chances for going for error cases are very low, still let's do it in the proper way

(cherry picked from commit 57c163b1b7680d3cc01227dbca7676e532aa7539)

* If POSIX sems are used, be sure to link against pthread lib

(cherry picked from commit f7de6406056cbae95ba9f7521d822d280afbe6a2)

* Fixed interface matching in loose_route()

If port is missing in Route URI, do not assume default 5060, but consider the schema and protocol (they may require a different default port).
Ex: sip:10.0.0.5;transport=tls was previously handled as sip:10.0.0.5:5060;transport=tls, which is wrong as the default TLS port is 5061
Reported on mailing list by Ravitez Dondeti.

(cherry picked from commit 3593a5f5b2e012154b1c9a00e1645c67c5ece91c)

* Fix invalid memory access with async MySQL queries

Due to the way the libmysqlclient query result strings were managed,
they would be freed by the library before OpenSIPS would copy them
into the output AVPs.

This patch fixes the issue by adding a new DB API function which handles
the cleanup of async query results.

Reported by Ovidiu Sas
Addresses issue #873

(cherry picked from commit 177c60a0e13471a87d80f21504894b883038ffa4)

Conflicts:
	db/db.h
	modules/avpops/avpops_impl.c
	modules/db_mysql/dbase.c
	modules/db_mysql/dbase.h
	modules/db_sqlite/db_sqlite.c
	modules/db_virtual/db_virtual.c
	modules/db_virtual/dbase.c
	modules/db_virtual/dbase.h
	modules/sipcapture/sipcapture.c

* Update version 2.1.3

* Update ChangeLog for 2.1.3

* httpd: properly treat select response

(cherry picked from commit b49d37494d77c81bdbf76406fc568f530cd66379)

* Fix documentation on former b2bl_key_avp module param

(cherry picked from commit ca21c6d2871e01d093c69371ddcc204c5af0355a)

* Proper handle the case of no usrloc domain registered.

Prevent get_next_udomain() crashing if there are no usrloc domains registered (reported by Qasim Akhan on users mailing list.
Do not enable the pinging support in nathelper if usrloc has no registered domains.

(cherry picked from commit 8f0c677be7dfd3fe6b17932173f14e049ae466a5)

* Fix error handling in DB writes.

If inserting/updating a dlg record in DB fails, do not exit with error, but continue with the rest of the dialogs.
Credits for finding and reporting this go to Rik Broers @ Motto

(cherry picked from commit 0ca6cf035471fc010366e4d29ced5d6fd63199ab)

* Removed unused "error" jump label

(cherry picked from commit 5819b0fa7033bf2a6daef824bc21dd4ba497ae1b)

* Removed wrong "NOT NULL" constraint over the contact DB fields

The code actually handles the case of NULL callee / caller contacts, so DB must allow NULL values.

* Removed compilation warning

implicit declaration of function â"sched_yield" [-Wimplicit-function-declaration]

(cherry picked from commit 8ef8d79701357b7412555519e166481e699e9833)

* Fix evaluating the SIP port from a SIP URI.

Use the new function get_uri_port() to evaluate the port and proto, in a SIP wise manner, form a SIP URI. If port/proto are not explicitly set in the URI, consider the default port for the used transpor proto. If protocol misses, we assume the default protos according to the URI schema.

NOTE: it is completly bogus (and dangerous) to assue 5061 if SIPS schema is used as:
1) SIPS can use used with WSS, which actually has 443 port
2) TLS can pe required via transport param in a SIP schema URI too

(cherry picked from commit 4c54bcd8bf0426f899b82505e493c97ef5378c79)

* Fixed forcing FAST LOCKS for arm6.

Use FAST locking support for arm6 too.
For Linux, use POSIX as default locking support.

(cherry picked from commit 058e16f2a76df9be4e48fa6866b096502981d530)

* Fix potential 100 Trying duplicates.

Added the "auto_100trying" module parameter to allow the script writter to take control (from script level) over when the 100 Trying reply is to be sent back.
By default, the reply is automatically generated when the INVITE transaction is created.
Fixes #833

(cherry picked from commit b023c93a8c476e70b1550da4f46c91d6e2679442)
(cherry picked from commit 71b527446b00fc4e3886d8d02c7d03d313dbee05)

* Fix memory corruption on $stat() vars

The $stat() var specs are kept in pkg, while the name (if stat not found) is kept in memeory. This means all the copies (form all procs) of the specs will point to a single shm block. It is not safet to free this block as you have no idea how many copies of the spec (from other processes) still refer the name.
Closes #902

(cherry picked from commit 4baead765179f6bfbc098b3e59791d7bbc4a8d42)

* Fixed failure to enable NAT pinging.

Commit 8f0c677 introduces a bug in testing is usrloc domains are available, and if not, to disable the NAT pinging in nathelper. The test is wrong as it is done in mod_init, while registrar module registerd the usrloc domain via fixup function, after the mod_init section.

Reported by Nick Altmann

(cherry picked from commit f150fb75611a6e61eabc134f266064bd23f1c850)

* Add support for SIP URIs without user part in 'avpops' module.

This module provides a set of avp_db_xxx functions which take pseudo
var and flag as first argument. Flag can be one of username, domain,
uri or uuid. Previosly avp_db_xxx functions used to return an error if
flag has been set to username, domain or uri and specifed pseudo var
did not contain username and host after parsing as SIP URI. This
behaviour seems to be strange because if flag is being set to
domain/username and sip URI contains domain/username we can still
load/store/delete this variable.

(cherry picked from commit 459f2e90ed277a0371a3325b27038213c5083e8c)

* Update rtpproxy.c

When building I/O vector for command to rtpproxy in "force_rtp_proxy_body", after an IPv6 address is detected and the "6" option is added, increase the length component in the I/O vector so it is passed correctly.
(cherry picked from commit 4e73871adba3f48b67a9ebbf20a2d9c60b823be8)

* Update rtpproxy.c

When moving stored parameters from Branch AVP to Dialog variable, make sure that the integer value "setid" is handled correctly so that it remains valid for the remainder of the dialog.
(cherry picked from commit e267e9eb83e2345ca716b897975c2fbfbb4e75ce)

* rtpproxy: no need to update the len for IPv6

(cherry picked from commit 5cfd916ca41ed60c9997f95d05694c9083b743b1)

* Fix proper testing of context content

If a STR is register to the context, a valid STR * will be always returned , so we need to test the content, not the pointer.

(cherry picked from commit 968a8a807c102a6d53f2bc831cde74c79ee754a9)

* Update version from 2.1.2 to 2.1.3 for specs

* init: use the specified CFGFILE in debian init

In case the CFGFILE changes in the init script, opensips will still start with
the compiled file instead of the one configured

(cherry picked from commit 030efef84d240646ed8e99616b8a6eb64f7d17d2)

* proto: always populate default values for protocols name and port

This allows you to print the protocol you received, and its associated port

(cherry picked from commit 0ae5ba280618e076a7ba658d15db32b877b55442)

* Allow proto modules to populate its name

(cherry picked from commit 00d052c18bd663e24769b7198a24aefbcd1963dc)

* Fix script varibles for providing port and proto (as part of SIP URI).

If the SIP URI does not have an explicit port or proto, determine the default port/proto in a SIP wise manner (rather than returning 5060 / UDP) (Ex: sip:example.com;transport=tls has default port 5061 and not 5060 ; or sips:example.com has default proto TLS and not UDP).

Affected variables are $dp, $rp, $op and $dP, $rP, $oP

(cherry picked from commit 6cc850e34dcd022f1ed354bd50d9a1809518fa1f)

* Fix compiler warning

Using gcc 4.8.4, we would get:

net/trans.c:43:2: warning: missing initializer for field ‘name’ of
‘struct proto_info’ [-Wmissing-field-initializers]
  { }, /* PROTO_NONE */
    ^

(cherry picked from commit 376579fa53abb6fc16de76a3070d082c9d958165)

* Fix dialplan module when using db_text backend.

The db_text makes no difference between NULL or "empty string" values in DB -> both are internally translated as NULL . The dialplan module, in a very abusive way, forces "not null" (in DB schema and in the code for data validation) even for columns that are optional (like subst_exp, repl_exp, timerec and attrs). Besides being bogus (if a column is not to be used, you have to set it to empty string rather than let it NULL), it makes impossible the usage of db_text with dialplan.
This fix allows (DB and code) the mentioned DB columns to be also NULL.
The change is backward compatible, it should not break any existing usage of the dialplan module.

(cherry picked from commit 8f548976389ee3968bf06f649b54d88db694f949)

* [siptrace][bugfix] fix bad macro in siptrace(trace local ip logic)

This commit closes #916
Thanks to @Tinet-AaronAn for reporting the issue

(cherry picked from commit 2a4f686d4997b814eeaa425dc23fe822cb8ef91a)

* permissions: fix get_source_group() return

In case a group is not found, return -1 instead of true

* acc: Fix incorrect Request-URI handling

If the config script does not include any Request-URI altering logic
(e.g. no lookup() or $ru manipulation), the acc module would incorrectly fill
in a "msg->new_uri" field which should NOT be freed into the SIP request
structure, leading to the memory pool being corrupted upon transaction release.

Credits to Guillaume Lacroix for reporting

(cherry picked from commit 02cb9f048d0a5e1f988aa9ccae1691216ed16ee5)

* Fixed compiling on arm6 with fastlocks

Partial revert of 058e16 as we need some extra asm code for fast locking on arm6.
See #923
Closes #912

(cherry picked from commit a69c32877b99fbd6eef736eff58c9b6ed8228166)

* Fix error message when a route is not defined.

Print the name of the route too - the ID is irrelevant for the script writter.

(cherry picked from commit 409481818148d7951e1520c9dd4eb715c2bec7c6)

* dialog: advance to next cell in case of error

(cherry picked from commit 70db2cfcdb0c74e6437db2aa9663fd0a5000ecdd)

* [acc][bugfix] check if database loaded before using its handler

(cherry picked from commit 8dd10d85b408947576223e75a67228ed7c7abd91)

* Fix populating blacklists.

When creating the blacklists, use the port and protocol of the destination too, otherwise the rules may conflict or be too wide to be used (like 2 destinations with same IP but different ports).

(cherry picked from commit 0495faa7d96f92da13102480ca43cd1befd37ba0)

* Fix populating blacklists.

When creating the blacklists, use the port and protocol of the destination too, otherwise the rules may conflict or be too wide to be used (like 2 destinations with same IP but different ports).

(cherry picked from commit 97f309c34c7333270a3f0f997868bdb9b94107f1)

* Fix populating blacklists.

When creating the blacklists, use the port and protocol of the destination too, otherwise the rules may conflict or be too wide to be used (like 2 destinations with same IP but different ports).

(cherry picked from commit 7fa9cee5037af26fd1c63b70710f2bc03e6a31f4)

* Fix advertised port and address per branch.

Before the advertised_port/address are preserved only in the UAS part of the transaction - that means it is only one value and it is from the setting done in Request Route; whatever later setting done in Failure Route or Branch Route are not preserved at transaction level (even if they are used on the spot, for sending out the INVITE).
So, when we have to build a local request (ACK or CANCEL), we do not remember which specific address/port were advertised for that particular UAC (branch).

Fixes #917.

(cherry picked from commit eb850a22f0af83bf75e75dfadbe1320e8b92784b)

* Fix building Via Branch in stateless mode

Instead of copying the branch value from a previous statefull Via header (which may lead to overflow as OpenSIPS has a maximum value for the built branch), we generate a new branch value based on the previous Via branch - in this way, we have full controll over the length of the resulting Branch and we also inherit the uniqueness of the branch value (from the prev Via hdr).

Reported by Gupta, Rahul and Elliott, Ray

(cherry picked from commit 482e643469b351d12418ff54c96beee7b27dca94)

* rest_client: Fix incorrect trim operation

(cherry picked from commit d8bf10da34152612e7835a64cedbb7593b8fc57b)

* permissions: allow any supported protocol

Before this commit, the protocol check was hardcoded in the module. This
commit allows to add in the permissions table any transport protocol
supported.

Thanks go to Kirill Galinurov for reporting this!

(cherry picked from commit 0eecff942dc3700e008a9941ac406a565325ef89)

* Update version to 2.1.4

* Update ChangeLog for 2.1.4

* Fix db_url setting - do not make it mandatory if no db is used

(cherry picked from commit 17beb2de8b5325e4363292bfbee9484809554f4a)

* Fixed memory leak on modules/drouting/drouting.c

This leak occures in function get_group_id() when do_routing is called without parameters in opensips.cfg.
In this case the dr_default_grp variable is not equal -1 and 'return dr_default_grp' is executed without freeing the res variable previously allocated for query execution.

(cherry picked from commit 65739943151f08aee18a7bc2125c7ac90ee84d00)

* Remove unnecessary test.

"res" cannot be null at that point

(cherry picked from commit 0b60681f0cc08ffd13fbac3dc5cbde17904ad177)
jnewman02 added a commit to Vocalocity/opensips that referenced this issue Jul 30, 2016
* Fixed some overlapping defines

* [nathelper] fix bad condintion for branch checking

* [siptrace]docfix - default trace_on param value

* Preserve 3xx contacts via TH

Do not change the contacts in 3xx replies to initial INVITE, as this breaks SIP redirect.
Reported by @petekelly
Issue OpenSIPS#656

* Proper handling of isolated EPOLLHUP events.

capture and handle EPOLLHUP or EPOLLERR events even if they are not in conjunction with EPOLLIN or EPOLLOUT.
Many thanks to @santhosh-kumar for reporting and helping with troubleshooting.

Fix for OpenSIPS#829

* Makefile.defs: new CC_OPTIMIZE_FLAG to define the compiler optimization level

* Makefile.defs: disable optimizations while debugging (DBG_MALLOC is set)

* [acc]flags used for accounting now replaced by do_accounting()

Introducing new do_accounting() function. It has 3 arguments,
first one is used to specify the type of accounting separated
by '|'(db, log, aaa, evi, diam), second one to specify the flags
used for accounting also separated by '|' (cdr, missed, failed -
failed_transaction_flag) and the third parameter represents the
name of the table used for accounting.

* [acc] updated docs for do_accounting()

* [sipcapture] special route for hep messages

hep_store_no_script parameter now changed into hep_route. Using
this parameter one can either do sip_capture() without going
through the script or define a route where messages can be
forwarded using hep_relay() function and modified if hep version
3 is used, withot parsing the sip message, or go through the
main request route as usual where the message will be parsed.
For the second version, the hep route, sip_capture() won't be
available since the message it's not parsed. This functionality
stands only for routing/modifying the message.

* [sipcapture] updated docs for hep_route parameter

* [sipcapture] Allow module starting without db url if db not used

* Improve logging when using "memlog"

    * blocks are more readable now (pkg vs. shm)
    * malloc vs. free vs. realloc operations are more distiguishable

* Improve robustness of core URI copying functions

Namely set_ruri(), set_dst_uri(), set_path_vector().

This patch corrects the behaviour of the above functions when they are
fed strange/corrupt strings, such as {NULL, 5} or {0x7fb..., 0}.

There are still plenty of pieces of OpenSIPS code which assume such
strings should be correctly processed, e.g. next_branches(), which may
lead to a whole world of problems ranging from segfaults, double free
operations and dangling pointers all the way up to intermixed shm/pkg
memory pointers.

The best way of addressing this issue is to simply accept such input and
zeroize (and free) the concerned sip_msg attributes.

Many thanks to Ovidiu Sas <osas@voipembedded.com> for in-depth error
reporting and assistance in fixing this issue

* F_MALLOC: Allow free(NULL) when debugging memory

* [sipcapture]fix dummy request building

* Updated the ACC documentation

* clusterer: Various coding style improvements

    * clean loops
    * shorter boolean test operators
    * avoid redundant global initializations
    * improve variable naming
    * fix bad log messages

* [acc]cancel_accounting function for acc

This function allows unsetting parameters set by do accounting
function. It has the same parameters excepting the table name.

* [acc]updated docs for cancel_accounting()

* [acc]change cancel_accounting() name to drop_accounting()

* [acc]fix docs for drop_accounting()

* sql_cacher: Add module dependencies

It should be loaded somewhere after all SQL and NoSQL drivers

* [acc]fix event registration issue

* Fix function name in docs

* Fixed function name in export.

* [acc] fix bugs in acc

* init all accounting methods data in mod_init as it was before;
cdr accounting initial data is loaded even if users don't use
CDRs but this shouldn't affect anything
* fix aaa bug - api was not loaded because it was badly included
in diameter define section
* fix event interface extra parameters - parsing extra parameters
for event interface was wrongly removed

* Make the s.int transformation more permissive

* Preserve sign on partially converted strings

* drouting api: Fix a double free bug

Crashes / memory corruptions could ensue after running "fraud_reload" MI
commands or during OpenSIPS shutdown, if fraud_detection had some data
to work with.

* [sipcapture hep] function to continue with the script after the hep route

* [sipcapture] update docs for new function

* clusterer: update README with a usage example

* clusterer: update html README layout

* TLS: Fix misleading error logs on accept() failures

OpenSIPS would always log SSL_accept() failures as being "rejected by
client". This is entirely not the case, as the errors may as very well be
server-side, due to cipher mismatches, failed peer verifications, etc.

Reported by Nabeel Shikder on the "users" mailing list

* Fixed bogus free of soring algorithms in DR.

* python: fix documentation links

* Update ws & tls modules documentation

* MYSQL DB migration updated.

SIP TRACE table changed, CALL CENTER tables added.

* Migrate cfg scripts to new acc interface.

* Fixed ilegal chars in XML

* Revert commit 1e1ea14

Do not automatically set db_url to the db_default_url as we have no idea if the default partition is gone be used. By forcing it we create some extra unwanted dependencies (like setting the version for the defaul table, even if not used).
Even if we break the backward compatibility, makes more sens to explicitly set the db_url if you use the default partition

* Revert commit d6cbbff

Do not automatically set db_url to the db_default_url as we have no idea if the default partition is gone be used. By forcing it we create some extra unwanted dependencies (like setting the version for the defaul table, even if not used).
Even if we break the backward compatibility, makes more sens to explicitly set the db_url if you use the default partition

* Fix bogus log

(cherry picked from commit 87c93b8)

* README files regenerated

* Fix extended Call-ID in B2B

The old CallID format did not ensure unicity across time, so we include now time info into the callid.
Closes  OpenSIPS#783 .

* Update CREDITS and AUTHORS

* Makefile: always put the minor in name

Even if it is redundant

* For beta release, enable malloc debugging

* Update version to beta

* Improve the AUTHORS file

(cherry picked from commit 32d0e1a)

* Update ChangeLog

* Update opensipsdbctl for 2.2

* Various doc improvements

(cherry picked from commit d932652)

Conflicts:
	scripts/opensipsdbctl
	scripts/opensipsdbctl.base

* Fix missing logs if debug_mode after log_stderror

(cherry picked from commit 29182c9)

* [dialog] repl_prof_add never increments the return buffer size for threshold comparison

(cherry picked from commit 52028bd)

* Fixed checking return code for pre raw callbacks

If the TH pre raw callbacks fails, it may return a NULL buffer, leading to a later crash when we want to parse the SIP message.

* [drouting] pvar for matched partition if wildcard operator used

fix missing functionality - return to script the matching partition

(cherry picked from commit 7551c66)

* [drouting] check if partition pvar is writable

(cherry picked from commit cf0945c)

* [drouting] docs updated for partition id variable

(cherry picked from commit 2013276)

* Fix typo in README example

(cherry picked from commit 983ad95)

* Fix missing GPL headers for mem files

(cherry picked from commit 8ffd592)

* cachedb_redis: Prevent crash when re-connect keeps failing

(cherry picked from commit b501df7)

* pi_http: return "200 OK" instead of "0 Unknown"

(cherry picked from commit 73f8117)

* Suppress "no free TCP receiver" logging noise

This was added long before async TCP support, and it is now
only useful to developers.

(cherry picked from commit 142e7e0)

* [acc] fix double free issue

Since callbacks were registered only at first, and aftewards only
flags were changed there was no way to know if tm is to free the
shmed flags from acc or dialog. For this a new flag was introduced
to indicate whether the flags shall be removed either by dialog or
tm.

(cherry picked from commit 6852bd4)

* Fix a PKG leak in the SIP message processing stack

Commit 7464a86ec introduced a processing context leak during the
handling of basically any SIP request in all protocol stacks
except for HEP.

Reported by Trevor Francis <trevor@46labs.com>

(cherry picked from commit 731719a)

* [acc][bugfix] register tm free function only once

(cherry picked from commit 92d2041)

*  [sipcapture][HOMERv5 incompatibility fix] HOMERv5 table rotation aware logic

    * HOMVERv5 allows rotating tables by having a prefix which is
    the fixed table name and a suffix which is a string containig
    timestamps
    * sip_capture now accepts table name as a parameter to sip_capture()
    function
    * both global table name and sip_capture table_name can have
    a prefix(string) and a suffix(strftime format string);
    * fixed bugs in async query building

(cherry picked from commit 074463f)

* [sipcapture][HOMERv5 incompatibility fix]generic capturing function

      Added new function called report_capture which allows
capturing hep packets in a generic format. It will be very
effective for the third version of the hep protocol for capturing
packets other than SIP. Also added a new table called rtcp_capture
for storing everything capture with report capture.

(cherry picked from commit c5700cc)

* [sipcapture][HOMERv5 incompatibility fix] updated docs for report_capture and new table name format

(cherry picked from commit 5d725a4)

* Fix typo in do_accounting() naming is cfg templates

(cherry picked from commit 7f8656e)

* Fixed bogus pkg_free on pointer in data segment

Reported by @dzhou121
Closes OpenSIPS#854

(cherry picked from commit b9aa873)

* MI library: Add comments regarding a known issue

Currently, MI arrays cannot contain objects with non-identical
"name" attributes.

This patch also quickfixes this issue in mi_list_all_profiles() by dropping
the array idea altogether, in favour of a top-most object.

(cherry picked from commit 6c10501)

* [tm]fix context functions header

(cherry picked from commit 59e5a41)

* [context][bugfix] each context has its own destroy functions vector

Credits to Razvan Crainea

(cherry picked from commit 53263b2)

* [siptrace][bugfix] sequential requests - set context for sl callbacks

(cherry picked from commit 943d901)

* [proto_hep][bugfix] check memory allocation

(cherry picked from commit f5ad753)

* tls_list() may be called even without DB support

Avoid locking if DB support was not enabled.

(cherry picked from commit e6944bb)

* exclude proto_wss, use QM_MALLOC

* Fixed default FIFO file name

(cherry picked from commit ffdbb97)

* Fixed MI nodes in 'sip_trace' command.

Formatting chars must not be included in the MI tree

(cherry picked from commit 7811e2d)

* [acc][bugfix] correctly store do_accounting() flags

	Flags are now moved from processing context into
transaction context when the transaction is created, this way
having visibility for the whole transaction.

(cherry picked from commit 41bcd25)

* [proto_hep][bugfix] fix bad sip payload size calculation

(cherry picked from commit eec5045)

* [sipcapture] remove time-consuming unnecessary chunk of code

(cherry picked from commit cc7a2ea)

* [sipcapture] fix incompatibilities with HOMERv5 db schema

(cherry picked from commit f756878)

* [siptrace][bugfix] avoid double free on cancelled transaction

(cherry picked from commit 3c6b693)

* [tls_mgm] properly handle SSL_ERROR_SYSCALL on SSL_shutdown

(cherry picked from commit bdcee39)

* Fixed arrays in clusterer_list MI command

(cherry picked from commit 31943a4)

* Fixed wrong MI tree in clusterer_list (related to previous commit)

(cherry picked from commit fa4e7f0)

* Avoid space in MI node name

* Enable debug_mode settings only if debug_mode gets set to enable.

(cherry picked from commit e7c14bc)

* [hep][bugfix] correctly store ports/addresses

(cherry picked from commit 51e6f102daac7d0de9a7ca4efea74d5c559746fe)

* Revert "[hep][bugfix] correctly store ports/addresses"

This reverts commit 7b1359a.

(cherry picked from commit ab22929)

* [proto_hep][bugfix] use the correct port when unpacking

(cherry picked from commit 3dda413)

* [siptrace][bugfix] use the correct sockaddr structure for storing

(cherry picked from commit 556f394)

* [drouting] bug fix and memory leak fix

* free gateways list for each carrier at reload
* use map_find instead of map_get to search an element in the tree

(cherry picked from commit f9f3b83ef621850c2c128b12b9bf6ab2e78e5ee1)

* [fix functional bug]allow a module to register multiple protocols

(cherry picked from commit 0873c14)

* [fix functional bug][hep] multiple versions/protocols can be used in the same time

Since commit 0873c14 multiple
network protocols can be used from one module. Proto_hep was changed
to be able to use both tcp and udp in the same time. Moreover, there
is no hep_version needed since we can receive HEPv1,v2 and v3 on any
UDP interface. Since HEPv1 and v2 are not compatible with TCP, only
HEPv3 will be support. For HEPv3, Sipcapture module can now relay
packets from TCP to UDP or the reverse way.
Siptrace module was also improved. Trace id's can now be defined with
hep version and transport protocol, in order to be able to do multiple
types of tracing with different HEP protocols and/or network transports.

(cherry picked from commit 45a3aef)

Conflicts:
	modules/siptrace/siptrace.c

* [hep] updated docs for previous commit

(cherry picked from commit f9c6cdd)

* [proto_hep] correctly name function

(cherry picked from commit 853b0bb)

* [fix functional bug][sipcapture] new HEPVERSION script variable

(cherry picked from commit 136fcb6)

* [sipcapture] updated docs for HEPVERSION

* [siptrace] fix bad cherry-pick conflict solving

* proto_bin: remove debug INFO message

(cherry picked from commit d388e80)

* [acc][bugfix] fix memory leak

* fix leak caused by missed calls - receiving a negative reply
caused flags not being freed

* regex: fix spell-check in package

(cherry picked from commit 647ea21)

* dialog and usrloc: broadcast replication data all time

This prevents clusterer module from marking a node as not reachable when there
is no traffic at all.

Fixes OpenSIPS#849

(cherry picked from commit 7f7f871)

* debian: add missing dependency

Ovewrite lintian warning

* Makefile.conf: add deps for tls_mgm and proto_wss

This prevents 'make menuconf' from deleting these modules from the generated
configuration file

(cherry picked from commit 616b2ba)

* ratelimit: initialize the length of the algorithm

(cherry picked from commit 0eebf10)

* [sipcapture] be able to set proto_type in report capture function

(cherry picked from commit e3466c4adecf11fa6d7da206359847c3a1c4b0f9)

* [sipcapture] fix bad conditions

(cherry picked from commit 4caa2ac)

* Updated opensipsctl.base to also search /sbin

The md5 utility is located at /sbin/md5 on FreeBSD 8.3. An additional common location was added to allow the script to accommodate this.
(cherry picked from commit ca87f55)

* [sipcapture][bugfix] invalid memory access

(cherry picked from commit 8056a984ce914d6585aef6054d727d82f72da3c6)

* dialog: Remove a chunk of dead code

(cherry picked from commit fd33057)

* [sipcapture][bugfix] invalid static vector size calculation

(cherry picked from commit b8a82b1)

* [siptrace][bugfix] fix trace_id parsing

(cherry picked from commit 2878741)

* [sipcapture][bugfix] fix bad string hex value parsing

(cherry picked from commit 5d6b927d41988e3170ab37889fb26c8026dce29d)

* [sipcapture] fix new hep proto names string

(cherry picked from commit 3c15d2d)

* [sipcapture] allow any hep version for hep_net variable

(cherry picked from commit bcbded5)

* [siptrace] fix hash calculus for extended hep trace_id

(cherry picked from commit 5e261d7)

* event_flatstore doc: Fix some typos

(cherry picked from commit 3cedcc4)

* event_virtual doc: Fix grammar/typos

(cherry picked from commit 3fd9686)

* [siptrace][bugfix] bad structre used when printing HEP trace_id via mi

(cherry picked from commit 8c6d9ba)

* [sipcapture] fix sip_capture table schema

(cherry picked from commit 8fd97163058c798f45d381b124cc465261e9e1e5)

* [nathelper] fix bad logic regarding the timer list

(cherry picked from commit a86d2c4)

* Update name to opensips-2.2.0-rc1

* Update ChangeLog for 2.2.0-rc1

* [dispatcher] fix double allocation issue

(cherry picked from commit d6891363e3b3b4047a1948eb03fb6b6bab285885)

* [sipcapture] fix bad time calculation

(cherry picked from commit d54dc2d)

* [sipcapture] fix possible data type loss

(cherry picked from commit 1c811ce)

* Fixed bogus memory operations.

Fixed bogus free (of uninit pointer) if parse_contact() fails
Fixed shm leak on errors after print_rr_body
Fixed shm leak on success if record_route is present.
Reported by John Nash.

(cherry picked from commit 4b0fca5)

* nathelper: ping WSS clients when using natping_tcp

See ticket OpenSIPS#875

(cherry picked from commit 54a306a)

* [mi_json] return code rework for errors

	Mi_json now returns only 200 OK as HTTP code. We have two
records for inspecting mi level errors, "code" for the error code
and "reason" for the error message.

(cherry picked from commit 644ea29)

* [mi_json] remove double inverted commas for internal error messages

(cherry picked from commit b5a51a9)

* [mi_json] return jsonrpc compliat error message

(cherry picked from commit 26a66f6aa2fb957a16ed000cc10360bf5f648e18)

* usrloc: Fix some uninitialized memory issues

Reported by Minh Phan
Closes OpenSIPS#878

(cherry picked from commit 38f525d)

* [mi_json] minor fixes in mi_json

(cherry picked from commit c091d068768d76fe34ea67ebb010b30082d55ca5)

* [mi_xmlrpc] return code rework for errors

Mi_xmlrpc_ng now returns only 200 OK as HTTP code. We have two
labels for inspecting mi level faults, "code" for the error code
and "message" for the error message. Check
http://www.tutorialspoint.com/xml-rpc/xml_rpc_fault.htm for
more details.

(cherry picked from commit 2bb871d0e77a739aac310235a1d042f3241d02e0)

* Fixed preserving 3xx Contacts in TH without dialog

Reported by Pete Kelly.
Closes OpenSIPS#656.

(cherry picked from commit 6184b96)

* [dispatcher] multiple fixes

* use pkg memory instead of shm for fixup variables
* fix int list building - avoid building a circular list

* Fix bogus timer ref counter during expire update.

Many thanks to Trevor Francis for reporting and helping with troubleshooting and testing.

(cherry picked from commit 047b1b3)

* Process sequential messages received in CONFIRMED_NA state

Due to UDP race conditions, sequential messages may be received
before the ACK confirming the initial INVITE ( eg. Re-INVITE sent
immediately as the call is established in order to force
a specific codec ) - also push these requests through the whole
dialog processing in order to avoid any future issues ( eg. CSEQ
updating which, if left unprocessed, will lead to generating out
of order sequentials by OpenSIPS )

(cherry picked from commit bfaf022)

* Fix a string concatenation operator bug

This patch fixes an issue with string concatenation where any NULL
operand would cause all operands to its left to be ignored when
computing the result of the expression.

Reported by Ovidiu Sas
Closes OpenSIPS#870

(cherry picked from commit a420752)

* clusterer: Fix bad doc example

Reported by "alias_neo" on IRC

(cherry picked from commit fd0ddaa)

* re-register topo hiding callbacks after restart

Thanks to Pete Kelly for reporting this

(cherry picked from commit 4c84bd8)

* th: fix dlg flag check

(cherry picked from commit 1b5802d)

* Fix invalid memory access with async MySQL queries

Due to the way the libmysqlclient query result strings were managed,
they would be freed by the library before OpenSIPS would copy them
into the output AVPs.

This patch fixes the issue by adding a new DB API function which handles
the cleanup of async query results.

Reported by Ovidiu Sas
Addresses issue OpenSIPS#873

(cherry picked from commit 177c60a)

* Upgrade to release candidate 2

* Update ChangeLog for OpenSIPS 2.2.0-rc2

* Added extra log message on openssl 1.0.1e-fips bug.

If CRYPTO_set_mem_functions() fails, make a note on the openssl 1.0.1e-fips bug, so users may have a hint on the actual issue.
See more  OpenSIPS#834.
Closes  OpenSIPS#834.

* Fix potential 100 Trying duplicates.

Added the "auto_100trying" module parameter to allow the script writter to take control (from script level) over when the 100 Trying reply is to be sent back.
By default, the reply is automatically generated when the INVITE transaction is created.
Fixes OpenSIPS#833

(cherry picked from commit b023c93)

* [mmgeoip] allow chosing memory caching type

	Before GEOIP_MMAP_CACHE was used causing a segmentation
fault when database file was changed. Now users can choose between
reading the database directly from file, cahing it into memory with
the possibility to change the database file at runtime.

(cherry picked from commit ecf5032aaafbe5a93bbfc3562c4b3358548839e7)

* Revert "Accept TCP aliases by default"

This reverts commit d62bc96.

Firstly, TCP connection reusage (RFC 5923) should only be employed between
TLS endpoints - only TLS allows the endpoints to authenticate each other
during connection setup, preventing unauthorized connection hijacking.

Secondly, aside from any security considerations, RFC 5923 must
not be employed fanatically (Proxy-Proxy, Edge-UA, UA-Proxy) on any TCP
connection (especially disregarding the ";alias" Via parameter!), but
rather only between adjacent SIP entities who can both initiate a
connection towards each other, and also support the RFC. In the real
world, we're basically only talking about the Proxy-Proxy usage case, as
any SIP UA scenario will most likely involve some form of NAT and a
Proxy that cannot open connections backwards, towards the UA. In these
cases, TCP connection reusage is _completely_ out of the question, as a
single UA might end up receiving all calls of all users behind their
public IP.

Thanks to Jonas Borjesson for reporting the problem in the first place.

(cherry picked from commit 715339f)

* TCP connection lookup: Add matching by transport

The fact that all currently supported TCP-oriented protocols have different
standard ports is not an excuse for not including the transport into the
match condition (i.e. dest IP address + dest port + dest transport).

This may very well prevent issues with messages being sent out over the
wrong TCP connection in a number of scenarios where we employ TCP connection
reusage over both plain TCP and TLS with a Proxy that specifies the same port
in the topmost Via header when it establishes each of the two connections.

(cherry picked from commit 13970bb)

* TCP alias lookup: Add matching by transport

Further improving commit 13970bb.

(cherry picked from commit ea699f0)

* mi_xmlrpc_ng: Fix a shared memory leak

(cherry picked from commit d047e10)

* mi_xmlrpc_ng: Fix NULL pointer dereference

Any MI tree with a topmost Array structure would have caused a crash

(cherry picked from commit 555fb8a)

* mi_xmlrpc_ng: Remove an incorrect free operation

Completes commit d047e10

(cherry picked from commit 99f039e)

* Fixed typo

(cherry picked from commit 1503ca6)

* Obey USE_SYSV_SEM and USE_PTHREAD_MUTEX.

If USE_SYSV_SEM or USE_PTHREAD_MUTEX are defined via Makefile.conf, do you force autodetection (based on arch type) of the locking support.

(cherry picked from commit 39592dc)

* Fix bogus destroy of a RW lock.

(cherry picked from commit 83f3945)

* Proper support for USE_POSIX_SEM option in Makefile

(cherry picked from commit 5e40aaf)

* Fix bogus set locking functions.

It is used for SYSTEM V locking only, looks like a copy'n'paste error.

(cherry picked from commit 4bcdf4e)

* Fix warning in SYSTEM V locking functions

(cherry picked from commit 53b3f40)

* call_center: obey lock_set interface

* acc: Remove deprecated modparam dependency

(cherry picked from commit d983d28)

* acc: properly detect parsing errors

(cherry picked from commit d6a44c0)

* dialplan: Fix a rule tie-breaking bug

When an input string would match both a "string" rule and a "regex"
rule, the priority based tie-breaking was incorrect (now favouring
the bigger priority instead - opposite to default module behavior).

Thanks to @paolodepa for suggesting this fix
Fixes issue OpenSIPS#696

(cherry picked from commit cbdd79a)

* Update makefile to support gcc 6.1

* dialplan: Improve documentation

Added paragraphs regarding rule types along with explanations on
they way priorities and rule tie-breaking work.

(cherry picked from commit 46894f8)

* dbtext: convert DBG to ERR for better debugging

(cherry picked from commit 0f08b26)

* clusterer: proper translation to bigint for dbtext

This creates the proper type for bigint in the clusterer table for dbtext

Thanks go to Trevor Francis from 46Labs for reporting this
Close OpenSIPS#699

(cherry picked from commit 5bae373)

* Improve error reporting for unknown script vars

Fixes OpenSIPS#574

(cherry picked from commit 97ace29)

* Fixed missing MI reply on pua_publish.

Properly send an MI reply for the async pua_publish with Expires 0.
Many thanks to Damien Sandrs for invetigating and reporting.

Closing OpenSIPS#657

(cherry picked from commit 60d01ef)

* add license to rw_locking.h header

(cherry picked from commit e3a57ac)

* Link the dialog cell into internally generated requests from the dialog module

Fixes OpenSIPS#839

(cherry picked from commit 66937a2)

* [acc] fix double free issue for multiple dlg callbacks

	The last byte in acc flag mask now holds a ref counter in
the last byte. The counter is increased each time a dialog callback
is invoked, and decreased for each free function corresponding to
a callback. When the ref counter reaches 0, flags can be freed.
The atomicity of the ref counter is based on the fact that
dialog callbacks and their free functions are called sequentially,
one after the other.
ACC_DIALOG_CONTEXT and ACC_CDR_REGISTERED flags where moved in the
7th byte of the flags.

(cherry picked from commit 7834aa5)

* promote 2.2.0-rc2 to stable

* Update ChangeLog with latest changes

* Disable QM and DBG for memory manager.

* Fixed proper cleanup on failure of tcpconn_new()

The chances for going for error cases are very low, still let's do it in the proper way

(cherry picked from commit 57c163b)

* If POSIX sems are used, be sure to link against pthread lib

(cherry picked from commit f7de640)

* Fixed interface matching in loose_route()

If port is missing in Route URI, do not assume default 5060, but consider the schema and protocol (they may require a different default port).
Ex: sip:10.0.0.5;transport=tls was previously handled as sip:10.0.0.5:5060;transport=tls, which is wrong as the default TLS port is 5061
Reported on mailing list by Ravitez Dondeti.

(cherry picked from commit 3593a5f)

* sync changelog for latest 2.2.0

* Fix documentation on former b2bl_key_avp module param

(cherry picked from commit ca21c6d)

* load_balancer: Fix a possible crash

Could have led to a segfault when OpenSIPS would run oom

Reported by Qasim Khan

(cherry picked from commit 4081fa3)

* Proper handle the case of no usrloc domain registered.

Prevent get_next_udomain() crashing if there are no usrloc domains registered (reported by Qasim Akhan on users mailing list.
Do not enable the pinging support in nathelper if usrloc has no registered domains.

* Fix error handling in DB writes.

If inserting/updating a dlg record in DB fails, do not exit with error, but continue with the rest of the dialogs.
Credits for finding and reporting this go to Rik Broers @ Motto

(cherry picked from commit 0ca6cf0)

* Removed unused "error" jump label

(cherry picked from commit 5819b0f)

* Removed wrong "NOT NULL" constraint over the contact DB fields

The code actually handles the case of NULL callee / caller contacts, so DB must allow NULL values.

* Removed compilation warning

implicit declaration of function â"sched_yield" [-Wimplicit-function-declaration]

* [mi_xmlrpc_ng] fix fault incompatibilities with xmlrpc standard

(cherry picked from commit d57c2fd)

* Consider WSS also a SIPS protocol

Reported by Varghese Paul ( @varghesepaul )
Closing OpenSIPS#899.

(cherry picked from commit 39e0deb)

* Fix evaluating the SIP port from a SIP URI.

Use the new function get_uri_port() to evaluate the port and proto, in a SIP wise manner, form a SIP URI. If port/proto are not explicitly set in the URI, consider the default port for the used transpor proto. If protocol misses, we assume the default protos according to the URI schema.

NOTE: it is completly bogus (and dangerous) to assue 5061 if SIPS schema is used as:
1) SIPS can use used with WSS, which actually has 443 port
2) TLS can pe required via transport param in a SIP schema URI too

(cherry picked from commit 4c54bcd)

* Fixed migration of Call Center tables

Reported by John Quick.

* Fixed forcing FAST LOCKS for arm6.

Use FAST locking support for arm6 too.
For Linux, use POSIX as default locking support.

(cherry picked from commit 058e16f)

* Fix docs on missing module dependency.

If replicate_contacts_to parameter is turned on, usrloc depends on the clusterer module.
Credits go to Sammy on mailing list.

(cherry picked from commit 735958d)

* [acc][bugfix] enable acc flags refcount only after dlg callbacks called

(cherry picked from commit a9a8fba51da95d3244ab46e22b3ed6cd8d0bea9e)

* Fix memory corruption on $stat() vars

The $stat() var specs are kept in pkg, while the name (if stat not found) is kept in memeory. This means all the copies (form all procs) of the specs will point to a single shm block. It is not safet to free this block as you have no idea how many copies of the spec (from other processes) still refer the name.
Closes OpenSIPS#902

(cherry picked from commit 4baead7)

* Fixed failure to enable NAT pinging.

Commit 8f0c677 introduces a bug in testing is usrloc domains are available, and if not, to disable the NAT pinging in nathelper. The test is wrong as it is done in mod_init, while registrar module registerd the usrloc domain via fixup function, after the mod_init section.

Reported by Nick Altmann

(cherry picked from commit f150fb7)

* Add support for SIP URIs without user part in 'avpops' module.

This module provides a set of avp_db_xxx functions which take pseudo
var and flag as first argument. Flag can be one of username, domain,
uri or uuid. Previosly avp_db_xxx functions used to return an error if
flag has been set to username, domain or uri and specifed pseudo var
did not contain username and host after parsing as SIP URI. This
behaviour seems to be strange because if flag is being set to
domain/username and sip URI contains domain/username we can still
load/store/delete this variable.

(cherry picked from commit 459f2e9)

* Update rtpproxy.c

When building I/O vector for command to rtpproxy in "force_rtp_proxy_body", after an IPv6 address is detected and the "6" option is added, increase the length component in the I/O vector so it is passed correctly.
(cherry picked from commit 4e73871)

* Update rtpproxy.c

When moving stored parameters from Branch AVP to Dialog variable, make sure that the integer value "setid" is handled correctly so that it remains valid for the remainder of the dialog.
(cherry picked from commit e267e9e)

* rtpproxy: no need to update the len for IPv6

(cherry picked from commit 5cfd916)

* Fix proper testing of context content

If a STR is register to the context, a valid STR * will be always returned , so we need to test the content, not the pointer.

* Update packaging to 2.2.0

* [sqlite][bugfix] free column names when freeing the result

(cherry picked from commit cf380773cec9f91ad08e343c03261154dabc36a5)

* init: use the specified CFGFILE in debian init

In case the CFGFILE changes in the init script, opensips will still start with
the compiled file instead of the one configured

(cherry picked from commit 030efef)

* Fix wrong number of columns when preloading via a DB backend without Fetch support.

* proto: always populate default values for protocols name and port

This allows you to print the protocol you received, and its associated port

(cherry picked from commit 0ae5ba2)

* Allow proto modules to populate its name

(cherry picked from commit 00d052c)

* Fix dialplan module when using db_text backend.

The db_text makes no difference between NULL or "empty string" values in DB -> both are internally translated as NULL . The dialplan module, in a very abusive way, forces "not null" (in DB schema and in the code for data validation) even for columns that are optional (like subst_exp, repl_exp, timerec and attrs). Besides being bogus (if a column is not to be used, you have to set it to empty string rather than let it NULL), it makes impossible the usage of db_text with dialplan.
This fix allows (DB and code) the mentioned DB columns to be also NULL.
The change is backward compatible, it should not break any existing usage of the dialplan module.

* Fix compiler warning

Using gcc 4.8.4, we would get:

net/trans.c:43:2: warning: missing initializer for field ‘name’ of
‘struct proto_info’ [-Wmissing-field-initializers]
  { }, /* PROTO_NONE */
    ^

(cherry picked from commit 376579f)

* [siptrace][bugfix] fix bad macro in siptrace(trace local ip logic)

This commit closes OpenSIPS#916
Thanks to @Tinet-AaronAn for reporting the issue

(cherry picked from commit 2a4f686d4997b814eeaa425dc23fe822cb8ef91a)

* module statistics: Properly update the "real_used" memory stat

(cherry picked from commit bc34043)

* Fix memory leak: after sqlite prepare was deleted stmt compiled, freed error message after sqlite exec, allocated rows was set to free and it also db_free_row was repaired.

* [db_sqlite] use DB_STRING type when the column value type is DB_STRING

(cherry picked from commit a2c7994)

Conflicts:
	modules/db_sqlite/row.c

* [db_sqlite] add explanation about implementation

(cherry picked from commit 3ab8237)

* [sqlite] fix warning

(cherry picked from commit 0b4cbaa)

* permissions: fix get_source_group() return

In case a group is not found, return -1 instead of true

* acc: Fix incorrect Request-URI handling

If the config script does not include any Request-URI altering logic
(e.g. no lookup() or $ru manipulation), the acc module would incorrectly fill
in a "msg->new_uri" field which should NOT be freed into the SIP request
structure, leading to the memory pool being corrupted upon transaction release.

Credits to Guillaume Lacroix for reporting

(cherry picked from commit 02cb9f0)

* fix core database engine bug introduced with commit 980f15e

(cherry picked from commit db37c5c411b529acd0cfeee4dfbc7925db6c2901)

* [db_sqlite] fix memory management bugs

* core free function was used to free starting with commit 980f15e
which was not freeing the memory correctly(result rows were
allocated all at once, but in the current version they were freed
once at a time);
* check if memory is allocated to prevent core dumps;

(cherry picked from commit bb506d2563c2670094537e70cc35b85d4ce4cd80)

* [db_sqlite] remove unnecessary file introduced in commit ccda718

(cherry picked from commit 450265ff4032e4d316d21fa6890946bed2866f87)

* Fix script varibles for providing port and proto (as part of SIP URI).

If the SIP URI does not have an explicit port or proto, determine the default port/proto in a SIP wise manner (rather than returning 5060 / UDP) (Ex: sip:example.com;transport=tls has default port 5061 and not 5060 ; or sips:example.com has default proto TLS and not UDP).

Affected variables are $dp, $rp, $op and $dP, $rP, $oP

(cherry picked from commit 6cc850e)

* Fixed compiling on arm6 with fastlocks

Partial revert of 058e16 as we need some extra asm code for fast locking on arm6.
See OpenSIPS#923
Closes OpenSIPS#912

(cherry picked from commit a69c328)

* Fix error message when a route is not defined.

Print the name of the route too - the ID is irrelevant for the script writter.

(cherry picked from commit 4094818)

* dialog: advance to next cell in case of error

(cherry picked from commit 70db2cf)

* [acc][bugfix] check if database loaded before using its handler

(cherry picked from commit 8dd10d85b408947576223e75a67228ed7c7abd91)

* Fix populating blacklists.

When creating the blacklists, use the port and protocol of the destination too, otherwise the rules may conflict or be too wide to be used (like 2 destinations with same IP but different ports).

(cherry picked from commit 0495faa)

* Fix populating blacklists.

When creating the blacklists, use the port and protocol of the destination too, otherwise the rules may conflict or be too wide to be used (like 2 destinations with same IP but different ports).

(cherry picked from commit 97f309c)

* Fix populating blacklists.

When creating the blacklists, use the port and protocol of the destination too, otherwise the rules may conflict or be too wide to be used (like 2 destinations with same IP but different ports).

(cherry picked from commit 7fa9cee)

* add debian packaging for proto_wss, proto_tls and tls_mgm

Reported by Rik Broers
Close OpenSIPS#931

* Fix advertised port and address per branch.

Before the advertised_port/address are preserved only in the UAS part of the transaction - that means it is only one value and it is from the setting done in Request Route; whatever later setting done in Failure Route or Branch Route are not preserved at transaction level (even if they are used on the spot, for sending out the INVITE).
So, when we have to build a local request (ACK or CANCEL), we do not remember which specific address/port were advertised for that particular UAC (branch).

Fixes OpenSIPS#917.

(cherry picked from commit eb850a2)

* Fix building Via Branch in stateless mode

Instead of copying the branch value from a previous statefull Via header (which may lead to overflow as OpenSIPS has a maximum value for the built branch), we generate a new branch value based on the previous Via branch - in this way, we have full controll over the length of the resulting Branch and we also inherit the uniqueness of the branch value (from the prev Via hdr).

Reported by Gupta, Rahul and Elliott, Ray

(cherry picked from commit 482e643)

* rest_client: Fix incorrect trim operation

(cherry picked from commit d8bf10d)

* permissions: allow any supported protocol

Before this commit, the protocol check was hardcoded in the module. This
commit allows to add in the permissions table any transport protocol
supported.

Thanks go to Kirill Galinurov for reporting this!

(cherry picked from commit 0eecff9)

* update version to 2.2.1

* Update ChangeLog for 2.2.1

* Fixed memory leak on modules/drouting/drouting.c

This leak occures in function get_group_id() when do_routing is called without parameters in opensips.cfg.
In this case the dr_default_grp variable is not equal -1 and 'return dr_default_grp' is executed without freeing the res variable previously allocated for query execution.

(cherry picked from commit 6573994)

* Remove unnecessary test.

"res" cannot be null at that point

(cherry picked from commit 0b60681)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants