asterisk/asterisk.git
3 years agobuild-system: Allow building with static pjproject
George Joseph [Tue, 19 Jan 2016 03:54:28 +0000 (20:54 -0700)]
build-system: Allow building with static pjproject

Background here:
http://lists.digium.com/pipermail/asterisk-dev/2016-January/075266.html

From CHANGES:
 * To help insure that Asterisk is compiled and run with the same known
   version of pjproject, a new option (--with-pjproject-bundled) has been
   added to ./configure.  When specified, the version of pjproject specified
   in third-party/versions.mak will be downloaded and configured.  When you
   make Asterisk, the build process will also automatically build pjproject
   and Asterisk will be statically linked to it.  Once a particular version
   of pjproject is configured and built, it won't be configured or built
   again unless you run a 'make distclean'.

   To facilitate testing, when 'make install' is run, the pjsua and pjsystest
   utilities and the pjproject python bindings will be installed in
   ASTDATADIR/third-party/pjproject.

   The default behavior remains building with the shared pjproject
   installation, if any.

Building:

   All you have to do is include the --with-pjproject-bundled option on
   the ./configure command line (and remove any existing --with-pjproject
   option if specified).  Everything else is automatic.

Behind the scenes:

   The top-level Makefile was modified to include 'third-party' in the
   list of MOD_SUBDIRS.

   The third-party directory was created to contain any third party
   packages that may be needed in the future.  Its Makefile automatically
   iterates over any subdirectories passing on targets.

   The third-party/pjproject directory was created to house the pjproject
   source distribution.  Its Makefile contains targets to download, patch
   configure, generate dependencies, compile libs, apps and python bindings,
   sanitized build.mak and generate a symbols list.

   When bootstrap.sh is run, it automatically includes the configure.m4
   file in third-party/pjproject.  This file has a macro to download and
   conifgure pjproject and get and set PJPROJECT_INCLUDE, PJPROJECT_DIR
   and PJPROJECT_BUNDLED.  It also tests for the capabilities like
   PJ_TRANSACTION_GRP_LOCK by parsing preprocessor output as opposed to
   trying to compile.  Of course, bootstrap.sh is only run once and the
   configure file is incldued in the patch.

   When configure is run with the new options, the macro in configure.m4
   triggers the download, patch, conifgure and tests.  No compilation is
   performed at this time.  The downloaded tarball is cached in /tmp so
   it doesn't get downloaded again on a distclean.

   When make is run in the top-level Asterisk source directory, it will
   automatically descend all the subdirectories in third_party just as it
   does for addons, apps, etc.  The top-level Makefile makes sure that
   the 'third-party' is built before 'main' so that dependencies from the
   other directories are built first.

   When main does build, a new shared library (libasteriskpj) is created that
   links statically to the pjproject .a files and exports all their symbols.
   The asterisk binary links to that, just as it does with libasteriskssl.

   When Asterisk is installed, the pjsua and pjsystest apps, and the pjproject
   python bindings are installed in ASTDATADIR/third-party/pjproject.  This
   will facilitate testing, including running the testsuite which will be
   updated to check that directory for the pjsua module ahead of the system
   python library.

Modules should continue to depend on pjproject if they use pjproject APIs
directly.  They should not care about the implementation.  No changes to any
res_pjsip modules were made.

Change-Id: Ia7a60c28c2e9ba9537c5570f933c1ebcb20a3103

3 years agoMerge "chan_sip.c: Fix T.38 issues caused by leaving a bridge."
Joshua Colp [Tue, 1 Mar 2016 12:00:43 +0000 (06:00 -0600)]
Merge "chan_sip.c: Fix T.38 issues caused by leaving a bridge."

3 years agoMerge "res_pjsip_t38.c: Back out part of an earlier fix attempt."
Joshua Colp [Tue, 1 Mar 2016 12:00:35 +0000 (06:00 -0600)]
Merge "res_pjsip_t38.c: Back out part of an earlier fix attempt."

3 years agoMerge "bridge core: Add owed T.38 terminate when channel leaves a bridge."
Joshua Colp [Tue, 1 Mar 2016 12:00:27 +0000 (06:00 -0600)]
Merge "bridge core: Add owed T.38 terminate when channel leaves a bridge."

3 years agoMerge "channel api: Create is_t38_active accessor functions."
Joshua Colp [Tue, 1 Mar 2016 12:00:17 +0000 (06:00 -0600)]
Merge "channel api: Create is_t38_active accessor functions."

3 years agoMerge "bridge_channel: Don't settle owed events on an optimization."
Joshua Colp [Tue, 1 Mar 2016 12:00:03 +0000 (06:00 -0600)]
Merge "bridge_channel: Don't settle owed events on an optimization."

3 years agoMerge "channel.c: Route all control frames to a channel through the same code."
Joshua Colp [Tue, 1 Mar 2016 11:59:54 +0000 (05:59 -0600)]
Merge "channel.c: Route all control frames to a channel through the same code."

3 years agoMerge "res_pjsip_mwi: Turn some NOTICEs and WARNINGs into debug 1s."
zuul [Mon, 29 Feb 2016 22:55:33 +0000 (16:55 -0600)]
Merge "res_pjsip_mwi:  Turn some NOTICEs and WARNINGs into debug 1s."

3 years agochan_sip.c: Fix T.38 issues caused by leaving a bridge.
Richard Mudgett [Mon, 22 Feb 2016 22:59:40 +0000 (16:59 -0600)]
chan_sip.c: Fix T.38 issues caused by leaving a bridge.

chan_sip could not handle AST_T38_TERMINATED frames being sent to it when
the channel left the bridge.  The action resulted in overlapping outgoing
reINVITEs.  The testsuite tests/fax/sip/directmedia_reinvite_t38 was not
happy.

* Force T.38 to be remembered as locally bridged.  Now when the channel
leaves the native RTP bridge after T.38, the channel remembers that it has
already reINVITEed the media back to Asterisk.  It just needs to terminate
T.38 when the AST_T38_TERMINATED arrives.

* Prevent redundant AST_T38_TERMINATED from causing problems.  Redundant
AST_T38_TERMINATED frames could cause overlapping outgoing reINVITEs if
they happen before the T.38 state changes to disabled.  Now the T.38 state
is set to disabled before the reINVITE is sent.

ASTERISK-25582 #close

Change-Id: I53f5c6ce7d90b3f322a942af1a9bcab6d967b7ce

3 years agores_pjsip_t38.c: Back out part of an earlier fix attempt.
Richard Mudgett [Fri, 19 Feb 2016 00:27:02 +0000 (18:27 -0600)]
res_pjsip_t38.c: Back out part of an earlier fix attempt.

This backs out item 4 of the 4875e5ac32f5ccad51add6a4216947bfb385245d
commit.  Item 4 added the t38_bye_supplement.  Unfortunately, the frame
that it puts into the bridge may or may not be processed by the time the
bridged peer is kicked out of the bridge.  If it is processed then all is
well.  However, if it is not processed then that channel is stuck in fax
mode until it hangs up or maybe if it joins another bridge for T.38
faxing.

ASTERISK-25582

Change-Id: Ib20a03ecadf1bf8a0dcadfadf6c2f2e60919a9f7

3 years agobridge core: Add owed T.38 terminate when channel leaves a bridge.
Richard Mudgett [Mon, 22 Feb 2016 19:54:47 +0000 (13:54 -0600)]
bridge core: Add owed T.38 terminate when channel leaves a bridge.

The channel is now going to get T.38 terminated when it leaves the
bridging system and the bridged peers are going to get T.38 terminated as
well.

ASTERISK-25582

Change-Id: I77a9205979910210e3068e1ddff400dbf35c4ca7

3 years agochannel api: Create is_t38_active accessor functions.
Richard Mudgett [Fri, 19 Feb 2016 22:01:17 +0000 (16:01 -0600)]
channel api: Create is_t38_active accessor functions.

ASTERISK-25582

Change-Id: I69451920b122de7ee18d15bb231c80ea7067a22b

3 years agobridge_channel: Don't settle owed events on an optimization.
Richard Mudgett [Sat, 20 Feb 2016 01:06:14 +0000 (19:06 -0600)]
bridge_channel: Don't settle owed events on an optimization.

Local channel optimization could cause DTMF digits to be duplicated.
Pending DTMF end events would be posted to a bridge when the local channel
optimizes out and is replaced by the channel further down the chain.  When
the real digit ends, the channel would get another DTMF end posted to the
bridge.

A -- LocalA;1/n -- LocalA;2/n -- LocalB;1 -- LocalB;2 -- B

1) LocalA has the /n flag to prevent optimization.
2) B is sending DTMF to A through the local channel chain.
3) When LocalB optimizes out it can move B to the position of LocalB;1
4) Without this patch, when B swaps with LocalB;1 then LocalB;1 would
settle an owed DTMF end to the bridge toward LocalA;2.
5) When B finally ends its DTMF it sends the DTMF end down the chain.
6) Without this patch, A would hear the DTMF digit end when LocalB
optimizes out and when B ends the original digit.

ASTERISK-25582

Change-Id: I1bbd28b8b399c0fb54985a5747f330a4cd2aa251

3 years agochannel.c: Route all control frames to a channel through the same code.
Richard Mudgett [Mon, 22 Feb 2016 18:15:34 +0000 (12:15 -0600)]
channel.c: Route all control frames to a channel through the same code.

Frame hooks can conceivably return a control frame in exchange for an
audio frame inside ast_write().  Those returned control frames were not
handled quite the same as if they were sent to ast_indicate().  Now it
doesn't matter if you use ast_write() to send an AST_FRAME_CONTROL to a
channel or ast_indicate().

ASTERISK-25582

Change-Id: I5775f41421aca2b510128198e9b827bf9169629b

3 years agosorcery: Refactor create, update and delete to better deal with caches
George Joseph [Thu, 25 Feb 2016 21:13:19 +0000 (14:13 -0700)]
sorcery:  Refactor create, update and delete to better deal with caches

The ast_sorcery_create, update and delete function have been refactored
to better deal with caches and errors.

The action is now called on all non-caching wizards first. If ANY succeed,
the action is called on all caching wizards and the observers are notified.
This way we don't put something in the cache (or update or delete) before
knowing the action was performed in at least 1 backend and we only call the
observers once even if there were multiple writable backends.

ast_sorcery_create was never adding to caches in the first place which
was preventing contacts from getting added to a memory_cache when they
were created.  In turn this was causing memory_cache to emit errors if
the contact was deleted before being retrieved (which would have
populated the cache).

ASTERISK-25811 #close
Reported-by: Ross Beer

Change-Id: Id5596ce691685a79886e57b0865888458d6e7b46

3 years agores_pjsip_mwi: Turn some NOTICEs and WARNINGs into debug 1s.
George Joseph [Thu, 25 Feb 2016 21:39:54 +0000 (14:39 -0700)]
res_pjsip_mwi:  Turn some NOTICEs and WARNINGs into debug 1s.

There are a few cases where we're emitting notices or warnings
for things that really need neither, like a client retrying to subscribe
to mwi when they're not conifgured for it.  They get a 404 so there's no
need for non-debug messages.

Change-Id: I05e38a7ff6c2f2521146f4be6a79731b9864e61f

3 years agoMerge "res_pjsip/config_transport: Allow reloading transports."
Joshua Colp [Sat, 27 Feb 2016 16:18:26 +0000 (10:18 -0600)]
Merge "res_pjsip/config_transport: Allow reloading transports."

3 years agoMerge "res_sorcery_memory_cache: Fix SEGV in some CLI commands"
Joshua Colp [Sat, 27 Feb 2016 14:50:20 +0000 (08:50 -0600)]
Merge "res_sorcery_memory_cache:  Fix SEGV in some CLI commands"

3 years agoMerge "chan_sip: Optionally supply fromuser/fromdomain in SIP dial string."
zuul [Thu, 25 Feb 2016 23:56:42 +0000 (17:56 -0600)]
Merge "chan_sip: Optionally supply fromuser/fromdomain in SIP dial string."

3 years agores_sorcery_memory_cache: Fix SEGV in some CLI commands
George Joseph [Thu, 25 Feb 2016 20:17:04 +0000 (13:17 -0700)]
res_sorcery_memory_cache:  Fix SEGV in some CLI commands

A few of the CLI commands weren't checking for enough arguments
and were SEGVing.

Change-Id: Ie6494132ad2fe54b4f014bcdc112a37c36a9b413

3 years agoMerge "chan_sip.c: Suppress T.38 SDP c= line if addr is the same."
zuul [Thu, 25 Feb 2016 00:40:15 +0000 (18:40 -0600)]
Merge "chan_sip.c: Suppress T.38 SDP c= line if addr is the same."

3 years agoMerge "res_config_sqlite3: Fix crashes when reading peers from sqlite3 tables"
zuul [Thu, 25 Feb 2016 00:26:06 +0000 (18:26 -0600)]
Merge "res_config_sqlite3: Fix crashes when reading peers from sqlite3 tables"

3 years agoMerge "rtp_engine.h: Remove extraneous semicolons."
zuul [Wed, 24 Feb 2016 16:18:01 +0000 (10:18 -0600)]
Merge "rtp_engine.h: Remove extraneous semicolons."

3 years agoMerge "res_pjsip_config_wizard: Add command to export primitive objects"
zuul [Tue, 23 Feb 2016 23:41:35 +0000 (17:41 -0600)]
Merge "res_pjsip_config_wizard:  Add command to export primitive objects"

3 years agortp_engine.h: Remove extraneous semicolons.
Richard Mudgett [Tue, 23 Feb 2016 01:31:24 +0000 (19:31 -0600)]
rtp_engine.h: Remove extraneous semicolons.

Change-Id: Ib462633d396fa941379dfef648dcd2245e350084

3 years agochan_sip.c: Suppress T.38 SDP c= line if addr is the same.
Richard Mudgett [Tue, 23 Feb 2016 20:57:42 +0000 (14:57 -0600)]
chan_sip.c: Suppress T.38 SDP c= line if addr is the same.

Use the correct comparison function since we only care if the address
without the port is the same.

Change-Id: Ibf6c485f843a1be6dee58a47b33d81a7a8cbe3b0

3 years agoMerge "res_pjproject: Add ability to map pjproject log levels to Asterisk log levels"
Joshua Colp [Mon, 22 Feb 2016 16:55:03 +0000 (10:55 -0600)]
Merge "res_pjproject:  Add ability to map pjproject log levels to Asterisk log levels"

3 years agores_config_sqlite3: Fix crashes when reading peers from sqlite3 tables
Christof Lauber [Tue, 16 Feb 2016 14:14:15 +0000 (15:14 +0100)]
res_config_sqlite3: Fix crashes when reading peers from sqlite3 tables

Introduced realloaction of ast_str buf in sqlite3_escape functions in case
the returned buffer from threadstorage was actually too small.

Change-Id: I3c5eb43aaade93ee457943daddc651781954c445

3 years agores_pjsip/config_transport: Allow reloading transports.
George Joseph [Thu, 11 Feb 2016 17:01:05 +0000 (10:01 -0700)]
res_pjsip/config_transport: Allow reloading transports.

The 'reload' mechanism actually involves closing the underlying
socket and calling the appropriate udp, tcp or tls start functions
again.  Only outbound_registration, pubsub and session needed work
to reset the transport before sending requests to insure that the
pjsip transport didn't get pulled out from under them.

In my testing, no calls were dropped when a transport was changed
for any of the 3 transport types even if ip addresses or ports were
changed. To be on the safe side however, a new transport option was
added (allow_reload) which defaults to 'no'.  Unless it's explicitly
set to 'yes' for a transport, changes to that transport will be ignored
on a reload of res_pjsip.  This should preserve the current behavior.

Change-Id: I5e759850e25958117d4c02f62ceb7244d7ec9edf

3 years agochan_sip: Optionally supply fromuser/fromdomain in SIP dial string.
Walter Doekes [Fri, 19 Feb 2016 10:30:15 +0000 (11:30 +0100)]
chan_sip: Optionally supply fromuser/fromdomain in SIP dial string.

Previously you could add [!dnid] to the SIP dial string to alter the To:
header. This change allows you to alter the From header as well.

SIP dial string extra options now look like this:

    [![touser[@todomain]][![fromuser][@fromdomain]]]

INCOMPATIBLE CHANGE: If you were using an exclamation mark in your To:
header, that is no longer possible.

ASTERISK-25803 #close

Change-Id: I2457e9ba7a89eb1da22084bab5a4d4328e189db7

3 years agoMerge "Fix failing threadpool_auto_increment test."
zuul [Fri, 19 Feb 2016 00:28:50 +0000 (18:28 -0600)]
Merge "Fix failing threadpool_auto_increment test."

3 years agoMerge "res_pjsip_outbound_publish: Fix processing 412 response"
zuul [Thu, 18 Feb 2016 23:59:36 +0000 (17:59 -0600)]
Merge "res_pjsip_outbound_publish: Fix processing 412 response"

3 years agores_pjproject: Add ability to map pjproject log levels to Asterisk log levels
George Joseph [Sun, 7 Feb 2016 23:34:20 +0000 (16:34 -0700)]
res_pjproject:  Add ability to map pjproject log levels to Asterisk log levels

Warnings and errors in the pjproject libraries are generally handled by
Asterisk.  In many cases, Asterisk wouldn't even consider them to be warnings
or errors so the messages emitted by pjproject directly are either superfluous
or misleading.  A good exampe of this are the level-0 errors pjproject emits
when it can't open a TCP/TLS socket to a client to send an OPTIONS.  We don't
consider a failure to qualify a UDP client an "ERROR", why should a TCP/TLS
client be treated any differently?

A config file for res_pjproject has bene added (pjproject.conf) and a new
log_mappings object allows mapping pjproject levels to Asterisk levels
(or nothing).  The defaults if no pjproject.conf file is found are the same
as those that were hard-coded into res_pjproject initially: 0,1 = LOG_ERROR,
2 = LOG_WARNING, 3,4,5 = LOG_DEBUG<level>

Change-Id: Iba7bb349c70397586889b8f45b8c3d6c6c8c3898

3 years agoMerge "app_queue: fix Calculate talktime when is first call answered"
Joshua Colp [Thu, 18 Feb 2016 19:12:03 +0000 (13:12 -0600)]
Merge "app_queue: fix Calculate talktime when is first call answered"

3 years agores_pjsip_outbound_publish: Fix processing 412 response
Alexei Gradinari [Thu, 18 Feb 2016 16:55:39 +0000 (11:55 -0500)]
res_pjsip_outbound_publish: Fix processing 412 response

When Asterisk receives a 412 (Conditional Request Failed) response
it has to recreate publish session.
There is bug in res_pjsip_outbound_publish.c
The function sip_outbound_publish_client_alloc is called with wrong object
while processing 412 (Conditional Request Failed) response.
This patch fixes it.

ASTERISK-25229 #close

Change-Id: I3b62f2debf6bb1e5817cde7b13ea39ef2bf14359

3 years agoFix failing threadpool_auto_increment test.
Mark Michelson [Thu, 18 Feb 2016 17:15:22 +0000 (11:15 -0600)]
Fix failing threadpool_auto_increment test.

The threadpool_auto_increment test fails infrequently for a couple of
reasons
* The threadpool listener was notified of fewer tasks being pushed than
  were actually pushed
* The "was_empty" flag was set to an unexpected value.

The problem is that the test pushes three tasks into the threadpool.
Test expects the threadpool to essentially gather those three tasks, and
then distribute those to the threadpool threads. It also expects that as
the tasks are pushed in, the threadpool listener is alerted immediately
that the tasks have been pushed. In reality, a task can be distributed
to the threadpool threads quicker than expected, meaning that the
threadpool has already emptied by the time each subsequent task is
pushed. In addition, the internal threadpool queue can be delayed so
that the threadpool listener is not alerted that a task has been pushed
even after the task has been executed.

From the test's point of view, there's no way to be able to predict
exactly the order that task execution/listener notifications will occur,
and there is no way to know which listener notifications will indicate
that the threadpool was previously empty.

For this reason, the test has been updated to only check the things it
can check. It ensures that all tasks get executed, that the threads go
idle after the tasks are executed, and that the listener is told the
proper number of tasks that were pushed.

Change-Id: I7673120d74adad64ae6894594a606e102d9a1f2c

3 years agocel.c: Fix mismatch in ast_cel_track_event() return type.
Richard Mudgett [Wed, 17 Feb 2016 19:30:06 +0000 (13:30 -0600)]
cel.c: Fix mismatch in ast_cel_track_event() return type.

The return type of ast_cel_track_event() is not large enough to return all
64 potential bits of the event enable mask.  Fortunately, the defined CEL
events do not really need all 64 bits and the return value is only used to
determine if the requested CEL event is enabled.

* Made the ast_cel_track_event() return 0 or 1 only so the return value
can fit inside an int type instead of zero or a truncated 64 bit non-zero
value.

Change-Id: I783d932320db11a95c7bf7636a72b6fe2566904c

3 years agoapp_queue: fix Calculate talktime when is first call answered
Rodrigo Ramírez Norambuena [Wed, 17 Feb 2016 05:37:43 +0000 (02:37 -0300)]
app_queue: fix Calculate talktime when is first call answered

Fix calculate of average time for talktime is wrong when is completed the
first call beacuse the time for talked would be that call.

ASTERISK-25800 #close

Change-Id: I94f79028935913cd9174b090b52bb300b91b9492

3 years agores_odbc: Fix exports.in for missing symbols
George Joseph [Tue, 16 Feb 2016 22:37:48 +0000 (15:37 -0700)]
res_odbc: Fix exports.in for missing symbols

res_odbc.exports.in was missing a few symbols.
Changed to wildcards.

Change-Id: Ieadd76df24e43ea92577f651d478a0f7b742c30c

3 years agores_statsd: Fix exports.in for missing symbols
George Joseph [Tue, 16 Feb 2016 18:20:57 +0000 (11:20 -0700)]
res_statsd:  Fix exports.in for missing symbols

res_statsd.export.in was missing the _va variations of the log
functions causing Asterisk to crash in res_pjsip if OPTIONAL_API
wasn't enabled.

ASTERISK-25727 #close
Reported-by: Gergely Dömsödi

Change-Id: I395729f9f51bdd33c5ca757f5f96ebedad74077b

3 years agores_pjsip_config_wizard: Add command to export primitive objects
George Joseph [Tue, 16 Feb 2016 03:31:38 +0000 (20:31 -0700)]
res_pjsip_config_wizard:  Add command to export primitive objects

A new command (pjsip export config_wizard primitives) has been added that
will export all the pjsip objects it created to the console or a file
suitable for reuse in a pjsip.conf file.

ASTERISK-24919 #close
Reported-by: Ray Crumrine

Change-Id: Ica2a5f494244b4f8345b0437b16d06aa0484452b

3 years agores_pjsip_caller_id: Fix segfault when replacing rpid or pai header
George Joseph [Mon, 15 Feb 2016 21:37:30 +0000 (14:37 -0700)]
res_pjsip_caller_id: Fix segfault when replacing rpid or pai header

If the PJSIP_HEADER dialplan function adds a PAI or RPID header and send_rpid
or send_pai is set, res_pjsip_caller_id attemps to retrieve, parse and modify
the header added by the dialplan function.  Since the header added by the
dialplan function is generic string, there are no virtual functions to parse
the uri and we get a segfault when we try.  Since the modify, was really only
an overwrite, we now just delete the old header if it was type PJSIP_H_OTHER
and recreate it.

This raises a question for another time though:  What should happen with
duplicate headers?  Right now res_pjsip_header_funcs doesn't check for dups
so if it's session supplement is loaded after res_pjsip_caller_id's (or any
other module that adds headers), there'll be dups in the message.

ASTERISK-25337 #close

Change-Id: I5e296b52d30f106b822c0eb27c4c2b0e0f71c7fa

3 years agoMerge "Fix creation race of contact_status structures."
zuul [Mon, 15 Feb 2016 21:39:47 +0000 (15:39 -0600)]
Merge "Fix creation race of contact_status structures."

3 years agoFix creation race of contact_status structures.
Mark Michelson [Mon, 15 Feb 2016 19:08:22 +0000 (13:08 -0600)]
Fix creation race of contact_status structures.

It is possible when processing a SIP REGISTER request to have two
threads end up creating contact_status structures in sorcery.
contact_status is created using a "find or create" function. If two
threads call into this at the same time, each thread will fail to find
an existing contact_status, and so both will end up creating a new
contact status.

During testing, we would see sporadic failures because the
PJSIP_CONTACT() dialplan function would operate on a different
contact_status than what had been updated by res_pjsip/pjsip_options.

The fix here is two-fold:
1) The "find or create" function for contact_status now has a lock
around the entire operation. This way, if two threads attempt the
operation simultaneously, the first to get there will create the object,
and the second will find the object created by the first thread.

2) res_sorcery_memory has had its create callback updated so that it
will not allow for objects with duplicate IDs to be created.

Change-Id: I55b1460ff1eb0af0a3697b82d7c2bac9f6af5b97

3 years agores_pjsip_pubsub: Move where the subscription is stored to after initialized.
Joshua Colp [Mon, 15 Feb 2016 18:52:22 +0000 (14:52 -0400)]
res_pjsip_pubsub: Move where the subscription is stored to after initialized.

A problem arose when testing the AMI subscription listing actions where it
was possible for a subscription that had not been fully initialized to be
listed. This was problematic as the underlying listing code would crash.

This change makes it so the subscription tree is fully set up before it is
added to the list of subscriptions. This ensures that when the listing actions
get the subscription it is valid.

ASTERISK-25738 #close

Change-Id: Iace2b13641c31bbcc0d43a39f99aba1f340c0f48

3 years agoMerge "res_pjsip: Refactor load_module/unload_module"
zuul [Fri, 12 Feb 2016 22:50:18 +0000 (16:50 -0600)]
Merge "res_pjsip:  Refactor load_module/unload_module"

3 years agoMerge "res_pjsip: Handle pjsip_dlg_create_uas deprecation"
zuul [Fri, 12 Feb 2016 22:50:13 +0000 (16:50 -0600)]
Merge "res_pjsip:  Handle pjsip_dlg_create_uas deprecation"

3 years agores_pjsip: Refactor load_module/unload_module
George Joseph [Tue, 9 Feb 2016 23:34:05 +0000 (16:34 -0700)]
res_pjsip:  Refactor load_module/unload_module

load_module was just too hairy with every step having to clean up all
previous steps on failure.

Some of the pjproject init calls have now been moved to a separate
load_pjsip function and the unload_pjsip function was enhanced to clean
up everything if an error happened at any stage of the load process.

In the process, a bunch of missing pj_shutdowns, serializer_pool_shutdowns
and ast_threadpool_shutdowns were also corrected.

Change-Id: I5eec711b437c35b56605ed99537ebbb30463b302

3 years agoMerge "Resources/res_phoneprov: fix memory leak and heap-use-after-free"
zuul [Thu, 11 Feb 2016 23:04:50 +0000 (17:04 -0600)]
Merge "Resources/res_phoneprov: fix memory leak and heap-use-after-free"

3 years agoResources/res_phoneprov: fix memory leak and heap-use-after-free
Badalyan Vyacheslav [Wed, 10 Feb 2016 04:42:11 +0000 (04:42 +0000)]
Resources/res_phoneprov: fix memory leak and heap-use-after-free

* heap-use-after-free happens when we free "cfg"
but then use "value" which refers to it

* A memory leak occurs because in some cases
it is not released "defaults"

ASTERISK-25721 #close
Reported by: Badalyan Vyacheslav
Tested by: Badalyan Vyacheslav

Change-Id: I3807d3f4726df6864430ec144cf6265d3f538469

3 years agofunc_iconv: Ensure output strings are properly terminated.
Sean Bright [Thu, 11 Feb 2016 17:21:42 +0000 (12:21 -0500)]
func_iconv: Ensure output strings are properly terminated.

ASTERISK-25272 #close
Reported by: Etienne Lessard
patches:
 AST-25272.patch submitted by Etienne Lessard (license #6394)

Change-Id: Id75ad202300960a1e91afe15e319d992936ecc17

3 years agoMerge "res_pjsip: Fix infinite recursion when loading transports from realtime"
Joshua Colp [Thu, 11 Feb 2016 12:10:06 +0000 (06:10 -0600)]
Merge "res_pjsip:  Fix infinite recursion when loading transports from realtime"

3 years agores_pjsip: Handle pjsip_dlg_create_uas deprecation
George Joseph [Wed, 10 Feb 2016 22:16:46 +0000 (15:16 -0700)]
res_pjsip:  Handle pjsip_dlg_create_uas deprecation

Pjproject has deprecated pjsip_dlg_create_uas in 2.5 and replaced it with
pjsip_dlg_create_uas_and_inc_lock which, as the name implies, automatically
increments the lock on the returned dialog.  To account for this, configure.ac
now detects the presence of pjsip_dlg_create_uas_and_inc_lock and res_pjsip.c
has an #ifdef HAVE_PJSIP_DLG_CREATE_UAS_AND_INC_LOCK to decide whether to use
the original call or the new one.  If the new one was used, the ref count is
decremented before returning.

ASTERISK-25751 #close
Reported-by Josh Colp

Change-Id: I1be776b94761df03bd0693bc7795a75682615ca8

3 years agoMerge "res_config_pgsql: Show error message in reload if not connected."
Mark Michelson [Wed, 10 Feb 2016 21:35:01 +0000 (15:35 -0600)]
Merge "res_config_pgsql: Show error message in reload if not connected."

3 years agoMerge "Build: Fix menuselect USAN conflicts"
Joshua Colp [Wed, 10 Feb 2016 20:34:51 +0000 (14:34 -0600)]
Merge "Build: Fix menuselect USAN conflicts"

3 years agores_config_pgsql: Show error message in reload if not connected.
Rodrigo Ramírez Norambuena [Wed, 10 Feb 2016 02:13:07 +0000 (23:13 -0300)]
res_config_pgsql: Show error message in reload if not connected.

Change-Id: I9290115a1aaadb589eb1d02eaeb502eec01b31fa

3 years agoBuild: Added testing compiler to support the system sanitizes
Badalyan Vyacheslav [Wed, 10 Feb 2016 05:40:32 +0000 (05:40 +0000)]
Build: Added testing compiler to support the system sanitizes

In older versions of the compiler was not sanitizes.
Compilers other than GCC can not support the Usan and TSAN
or have other options for *FLAGS.

ASTERISK-25767 #close
Reported by: Badalyan Vyacheslav
Tested by: Badalyan Vyacheslav

Change-Id: Iefce6608221fa87884b82ae3cb5649b7b1804916

3 years agoBuild: Fix menuselect USAN conflicts
Badalyan Vyacheslav [Wed, 10 Feb 2016 02:57:38 +0000 (02:57 +0000)]
Build: Fix menuselect USAN conflicts

USAN can be used together with other sanitizers.

Reported by: Badalyan Vyacheslav
Tested by: Badalyan Vyacheslav

Change-Id: I3bffa350d70965c3026651dba3a12414d0aaa45f

3 years agoSimplify and fix conditional in FD_SET.
Corey Farrell [Tue, 9 Feb 2016 20:21:05 +0000 (15:21 -0500)]
Simplify and fix conditional in FD_SET.

FD_SET contains a conditional statement to protect against buffer
overruns.  The statement was overly complicated and prevented use
of the last array element of ast_fdset.  We now just verify the fd
is less than ast_FDMAX.

Change-Id: I41895c0b497b052aef5bf49d75c817c48b326f40

3 years agoMerge "res_config_pgsql: Add message on cli failed command status"
Joshua Colp [Tue, 9 Feb 2016 19:45:32 +0000 (13:45 -0600)]
Merge "res_config_pgsql: Add message on cli failed command status"

3 years agotests/test_sorcery_memory_cache_thrash: Improve termination process.
Joshua Colp [Tue, 9 Feb 2016 13:11:36 +0000 (09:11 -0400)]
tests/test_sorcery_memory_cache_thrash: Improve termination process.

When terminating the threads thrashing a sorcery memory cache each
would be told to stop and then we would wait on them. During at
least one thrashing test this was problematic due to the specific
usage pattern in use. It would take some time for termination of the
thread to occur.

This would occur due to contention between the threads retrieving
and the threads updating the cache. As the retrieving threads are
given priority it may be some time before the updating threads
are able to proceed.

This change makes it so all threads are told to stop and then each
are joined to ensure they stop. This way all the threads should
stop at around the same time instead of waiting for one to stop,
the next to stop, then the next, and so on. As a result of this
the execution time for each thrash test is much closer to their
expected value than previously seen as well.

Change-Id: I04a53470b0ea4170b8819180b0bd7475f3642827

3 years agores_pjsip: Fix infinite recursion when loading transports from realtime
George Joseph [Fri, 29 Jan 2016 23:56:42 +0000 (16:56 -0700)]
res_pjsip:  Fix infinite recursion when loading transports from realtime

Attempting to load a transport from realtime was forcing asterisk into an
infinite recursion loop.  The first thing transport_apply did was to do a
sorcery retrieve by id for an existing transport of the same name. For files,
this just returns the previous object from res_sorcery_config's internal
container, if any.  For realtime, the res_sourcery_realtime driver looks in the
database and finds the existing row but now it has to rehydrate it into a
sorcery object which means calling... transport_apply.  And so it goes.

The main issue with loading from realtime (apart from the loop) was that
transport stores structures and pointers directly in the ast_sip_transport
structure instead of the separate ast_transport_state structure.  This patch
separates those items into the ast_sip_transport_state structure.  The pattern
is roughly the same as res_pjsip_outbound_registration.

Although all current usages of ast_sip_transport and ast_sip_transport_state
were modified to use the new ast_sip_get_transport_state API, the original
items are left in ast_sip_transport and kept updated to maintain ABI
compatability for third-party modules.  They are marked as deprecated and
noted that they're now in ast_sip_transport_state.

ASTERISK-25606 #close
Reported-by: Martin Moučka

Change-Id: Ic7a836ea8e786e8def51fe3f8cce855ea54f5f19

3 years agoMerge "chan_misdn: Fix a few issues causing compile errors"
Joshua Colp [Mon, 8 Feb 2016 11:56:52 +0000 (05:56 -0600)]
Merge "chan_misdn: Fix a few issues causing compile errors"

3 years agores_config_pgsql: Add message on cli failed command status
Rodrigo Ramírez Norambuena [Sun, 7 Feb 2016 19:00:24 +0000 (16:00 -0300)]
res_config_pgsql: Add message on cli failed command status

In case failed of command "realtime show pgsql status" show a message the data
of connection to more clear information in error.

Change-Id: Ia8e9e2400466606e7118f52a46e05df0719b6a29

3 years agochan_misdn: Fix a few issues causing compile errors
George Joseph [Fri, 5 Feb 2016 16:29:00 +0000 (09:29 -0700)]
chan_misdn: Fix a few issues causing compile errors

Change-Id: I54b48c24d7ca88ed80496fdfd142d08772a7ab98

3 years agoapp_confbridge: Only use b_profile options from the conference.
Richard Mudgett [Mon, 25 Jan 2016 23:36:50 +0000 (17:36 -0600)]
app_confbridge: Only use b_profile options from the conference.

A user cannot set new bridge options after the conference is created by
the first user.  Attempting to do so is documented as undefined behavior.

This patch ensures that the bridge profile options used are from the
conference and not what a subsequent user may have tried to set.

Change-Id: I1b6383eba654679e5739d5a8de98199cf074a266

3 years agoMerge "pjsip/alembic: Add missing columns to system and registration"
Joshua Colp [Fri, 5 Feb 2016 17:50:35 +0000 (11:50 -0600)]
Merge "pjsip/alembic:  Add missing columns to system and registration"

3 years agoMerge "app_confbridge.c: Replace inlined code with existing function."
Joshua Colp [Fri, 5 Feb 2016 17:49:42 +0000 (11:49 -0600)]
Merge "app_confbridge.c: Replace inlined code with existing function."

3 years agoMerge topic 'ASTERISK-20987'
Joshua Colp [Fri, 5 Feb 2016 17:49:14 +0000 (11:49 -0600)]
Merge topic 'ASTERISK-20987'

* changes:
  app_confbridge: Add ability to get the muted conference state.
  app_confbridge.c: Update CONFBRIDGE and CONFBRIDGE_INFO documentation.
  app_confbridge: Make non-admin users join a muted conference muted.

3 years agoCheck for OpenSSL defines before trying to use them.
Mark Michelson [Thu, 4 Feb 2016 22:17:55 +0000 (16:17 -0600)]
Check for OpenSSL defines before trying to use them.

The SSL_OP_NO_TLSv1_1 and SSL_OP_NO_TLSv1_2 defines did not exist prior
to OpenSSL version 1.0.1. A recent commit attempts to, by default, set
these options, which can cause problems on systems with older OpenSSL
installations.

This commit adds a configure script check for those defines and will not
attempt to make use of those if they do not exist. We will print a
warning urging the user to upgrade their OpenSSL installation if those
defines are not present.

Change-Id: I6a2eb9a43fd0738b404d8f6f2cf4b5c22d9d752d

3 years agopjsip/alembic: Add missing columns to system and registration
George Joseph [Wed, 3 Feb 2016 20:25:23 +0000 (13:25 -0700)]
pjsip/alembic:  Add missing columns to system and registration

ps_systems needed disable_tcp_switch
ps_registrations needed line and endpoint

ASTERISK-25737 #close

Change-Id: Iaf9c2d69e62243d9fa53104c28c5339c47d4ac19

3 years agoMerge "logging: Remove/fix some message annoyances"
Mark Michelson [Thu, 4 Feb 2016 20:10:58 +0000 (14:10 -0600)]
Merge "logging: Remove/fix some message annoyances"

3 years agoMerge "res_stasis_device_state: Fix refcounting error."
Joshua Colp [Thu, 4 Feb 2016 18:35:37 +0000 (12:35 -0600)]
Merge "res_stasis_device_state: Fix refcounting error."

3 years agoMerge "app_queue: Add Lastpause field of queue member"
Joshua Colp [Thu, 4 Feb 2016 18:29:18 +0000 (12:29 -0600)]
Merge "app_queue: Add  Lastpause field of queue member"

3 years agoMerge "res_xmpp: Does not connect in component mode"
Joshua Colp [Thu, 4 Feb 2016 18:26:49 +0000 (12:26 -0600)]
Merge "res_xmpp: Does not connect in component mode"

3 years agores_stasis_device_state: Fix refcounting error.
Mark Michelson [Thu, 4 Feb 2016 17:39:10 +0000 (11:39 -0600)]
res_stasis_device_state: Fix refcounting error.

Device state subscription lifetimes were governed by when the
subscription was established and unsubscribed from. However, it is
possible that at the time of unsubscription, there could be device state
events still in flight. When those device state events occur, the device
state callback could attempt to dereference a freed pointer. Crash.

This change ensures that the lifetime of the device state subscription
does not end until the underlying stasis subscription has confirmed that
its final message has been sent.

Change-Id: I25a0f1472894c1a562252fb7129671478e25e9b2

3 years agores_rtp_asterisk: Allow ICE host candidates to be overriden
Sean Bright [Wed, 27 Jan 2016 16:44:10 +0000 (11:44 -0500)]
res_rtp_asterisk: Allow ICE host candidates to be overriden

During ICE negotiation the IPs of the local interfaces are sent to the remote
peer as host candidates. In many cases Asterisk is behind a static one-to-one
NAT, so these host addresses will be internal IP addresses.

To help in hiding the topology of the internal network, this patch adds the
ability to override the host candidates by matching them against a
user-defined list of replacements.

Change-Id: I1c9541af97b83a4c690c8150d19bf7202c8bff1f

3 years agoMerge "AST-2016-003 udptl.c: Fix uninitialized values."
Kevin Harwell [Wed, 3 Feb 2016 21:17:22 +0000 (15:17 -0600)]
Merge "AST-2016-003 udptl.c: Fix uninitialized values."

3 years agoMerge "AST-2016-002 chan_sip.c: Fix retransmission timeout integer overflow."
Kevin Harwell [Wed, 3 Feb 2016 21:14:53 +0000 (15:14 -0600)]
Merge "AST-2016-002 chan_sip.c: Fix retransmission timeout integer overflow."

3 years agoAST-2016-001 http: Provide greater control of TLS and set modern defaults.
Joshua Colp [Wed, 3 Feb 2016 18:05:20 +0000 (14:05 -0400)]
AST-2016-001 http: Provide greater control of TLS and set modern defaults.

This change exposes the configuration of various aspects of the TLS
support and sets the default to the modern standards.

The TLS cipher is now set to the best values according to the
Mozilla OpSec team, different TLS versions can now be disabled, and
the cipher order can be forced to be that of the server instead of
the client.

ASTERISK-24972 #close

Change-Id: I0a10f2883f7559af5e48dee0901251dbf30d45b8

3 years agoAST-2016-003 udptl.c: Fix uninitialized values.
Richard Mudgett [Mon, 7 Dec 2015 18:46:53 +0000 (12:46 -0600)]
AST-2016-003 udptl.c: Fix uninitialized values.

Sending UDPTL packets to Asterisk with the right amount of missing
sequence numbers and enough redundant 0-length IFP packets, can make
Asterisk crash.

ASTERISK-25603 #close
Reported by: Walter Doekes

ASTERISK-25742 #close
Reported by: Torrey Searle

Change-Id: I97df8375041be986f3f266ac1946a538023a5255

3 years agoAST-2016-002 chan_sip.c: Fix retransmission timeout integer overflow.
Richard Mudgett [Mon, 28 Sep 2015 22:07:42 +0000 (17:07 -0500)]
AST-2016-002 chan_sip.c: Fix retransmission timeout integer overflow.

Setting the sip.conf timert1 value to a value higher than 1245 can cause
an integer overflow and result in large retransmit timeout times.  These
large timeout times hold system file descriptors hostage and can cause the
system to run out of file descriptors.

NOTE: The default sip.conf timert1 value is 500 which does not expose the
vulnerability.

* The overflow is now detected and the previous timeout time is
calculated.

ASTERISK-25397 #close
Reported by: Alexander Traud

Change-Id: Ia7231f2f415af1cbf90b923e001b9219cff46290

3 years agologging: Remove/fix some message annoyances
George Joseph [Wed, 3 Feb 2016 20:07:07 +0000 (13:07 -0700)]
logging: Remove/fix some message annoyances

test_dlinklists doesn't need to NOTICE everyone that every macro worked.

res_phoneprov doesn't need to VERBOSE everyone that a phoneprov extension or
provider was registered.

res_odbc was missing a newline at the end of one message.

Change-Id: I6c06361518ef3711821795e535acd439782a995e

3 years agoMerge "res_sorcery_realtime: Fix regex regression."
Joshua Colp [Wed, 3 Feb 2016 16:14:45 +0000 (10:14 -0600)]
Merge "res_sorcery_realtime: Fix regex regression."

3 years agoMerge "cdr_pgsql.cl: REFACTOR Macro LENGTHEN_BUF"
Joshua Colp [Wed, 3 Feb 2016 12:20:18 +0000 (06:20 -0600)]
Merge "cdr_pgsql.cl: REFACTOR Macro LENGTHEN_BUF"

3 years agoMerge "app_queue: fix some tab format"
Joshua Colp [Wed, 3 Feb 2016 12:19:47 +0000 (06:19 -0600)]
Merge "app_queue: fix some tab format"

3 years agoMerge "README: Update year in copyright"
Joshua Colp [Wed, 3 Feb 2016 12:19:29 +0000 (06:19 -0600)]
Merge "README: Update year in copyright"

3 years agoMerge "app_queue: Fix preserved reason of pause when Asterisk is restared"
Joshua Colp [Wed, 3 Feb 2016 12:19:19 +0000 (06:19 -0600)]
Merge "app_queue: Fix preserved reason of pause when Asterisk is restared"

3 years agoMerge "app_queue.c: remove include for core_unreal.h not used in code."
Joshua Colp [Wed, 3 Feb 2016 12:18:58 +0000 (06:18 -0600)]
Merge "app_queue.c: remove include for core_unreal.h not used in code."

3 years agoMerge "chan_sip.c: AMI & CLI notify methods get different values of asterisk's own...
Mark Michelson [Tue, 2 Feb 2016 21:58:49 +0000 (15:58 -0600)]
Merge "chan_sip.c: AMI & CLI notify methods get different values of asterisk's own ip."

3 years agores_sorcery_realtime: Fix regex regression.
Mark Michelson [Tue, 2 Feb 2016 16:52:29 +0000 (10:52 -0600)]
res_sorcery_realtime: Fix regex regression.

A regression was introduced where searching for realtime PJSIP objects
by regex by starting the regex with a leading "^" would cause no items
to be returned.

This was due to a change which attempted to drop the requirement for a
leading "^" to be present due to how some CLI commands formulate their
regexes. However, the change, rather than simply eliminating the
requirement, caused any regexes that did begin with "^" to end up not
returning the expected results.

This change fixes the problem by inspecting the regex and formulating
the realtime query differently depending on if it begins with "^".

ASTERISK-25702 #close
Reported by Nic Colledge

Patches:
    realtime_retrieve_regex.patch submitted by Alexei Gradinari License #5691

Change-Id: I055df608a6e6a10732044fa737a9fe8dca602693

3 years agores_xmpp: Does not connect in component mode
Karsten Wemheuer [Tue, 2 Feb 2016 10:05:15 +0000 (11:05 +0100)]
res_xmpp: Does not connect in component mode

The module res_xmpp does not accept usernames in the form used in component
mode (XEP-0114). In component mode there is no @something in the name.
In component mode the connection is now not dropped anymore.

If the xmpp server sends out a "stream" tag before handshake is finished,
the connection gets dropped in res_xmpp. Now this tag will be ignored and
the connection will be established.

After connecting there will be an exchange of presence states. This does
not work as expected in component mode. The responsible function
"xmpp_pak_presence" is left before the states get sent out. Sending
presence states in component mode is now moved to the top of the function.

ASTERISK-25735 #close

Change-Id: I70e036f931c3124ebb2ad1e56f93ed35cfdd9d5c

3 years agoMerge "res_odbc: Remove connection management"
Joshua Colp [Tue, 2 Feb 2016 12:46:41 +0000 (06:46 -0600)]
Merge "res_odbc: Remove connection management"

3 years agobuild_system: Fix some warnings highlighted by clang
George Joseph [Mon, 1 Feb 2016 19:04:06 +0000 (12:04 -0700)]
build_system:  Fix some warnings highlighted by clang

Fix some warnings found with clang.

Change-Id: I5195b6189b148c2ee3ed4a19d015a6d4ef3e77bd

3 years agopjsip/alembic: Fix definition of qualify_timeout
George Joseph [Mon, 1 Feb 2016 02:13:58 +0000 (19:13 -0700)]
pjsip/alembic: Fix definition of qualify_timeout

A recent commit set qualify_timeout to Decimal which isn't supported.
This path corrects it to Float.

Change-Id: I038f5274ba8cb60f8518a5845ce448d49306aadf

3 years agochan_sip.c: AMI & CLI notify methods get different values of asterisk's own ip.
StefanEng86 [Fri, 29 Jan 2016 13:39:06 +0000 (14:39 +0100)]
chan_sip.c: AMI & CLI notify methods get different values of asterisk's own ip.

When I ask asterisk to send a SIP NOTIFY message to a sip peer using either a)
AMI action: SIPnotify or b) cli command: sip notify <cmd> <peer>, I expect
asterisk to include the same value for its own ip in both cases a) and b),
but it seems a) produces a contact header like Contact:
<sip:asterisk@192.168.1.227:8060> whereas b) produces a contact header like
<sip:asterisk@127.0.0.1:8060>. 0.0.0.0:8060 is my udpbindaddr in sip.conf

My guess is that manager_sipnotify should call
ast_sip_ouraddrfor(&p->sa, &p->ourip, p) the same way sip_cli_notify does,
because after applying this patch, both cases a) and b) produce
the contact header that I expect: <sip:asterisk@192.168.1.227:8060>

Reported by: Stefan Engström
Tested by: Stefan Engström

Change-Id: I86af5e209db64aab82c25417de6c768fb645f476

3 years agoMerge "build_system: Prevent goals needing makeopts from running when it's missing"
Joshua Colp [Fri, 29 Jan 2016 14:06:22 +0000 (08:06 -0600)]
Merge "build_system: Prevent goals needing makeopts from running when it's missing"

3 years agoMerge "config: Allow options to register when documentation is unavailable."
Mark Michelson [Thu, 28 Jan 2016 21:56:30 +0000 (15:56 -0600)]
Merge "config: Allow options to register when documentation is unavailable."

3 years agoconfig_options.c: Fix warning message wording.
Richard Mudgett [Thu, 28 Jan 2016 18:44:43 +0000 (12:44 -0600)]
config_options.c: Fix warning message wording.

Change-Id: I915ea437936320393afde0e7552cf0a980a6b2e4

3 years agoapp_confbridge.c: Replace inlined code with existing function.
Richard Mudgett [Mon, 25 Jan 2016 23:34:20 +0000 (17:34 -0600)]
app_confbridge.c: Replace inlined code with existing function.

Change-Id: Ida5594e9f8d7c1fc18eeb733a11f8fb96326da51