]> git.ipfire.org Git - thirdparty/asterisk.git/log
thirdparty/asterisk.git
9 years agores_stasis_recording.c: Cleanup stasis_app_recording_find_by_name(). 02/2502/1
Richard Mudgett [Tue, 29 Mar 2016 19:29:53 +0000 (14:29 -0500)] 
res_stasis_recording.c: Cleanup stasis_app_recording_find_by_name().

Change-Id: Ic7d93c402c498677a122505558859c853d4e5ac7

9 years agoMerge "res_pjsip/pjsip_options: Fix From generation on outgoing OPTIONS" into 13
Joshua Colp [Wed, 30 Mar 2016 15:52:44 +0000 (10:52 -0500)] 
Merge "res_pjsip/pjsip_options:  Fix From generation on outgoing OPTIONS" into 13

9 years agochan_pjsip: Add 'pjsip show channelstats' 80/2480/2
George Joseph [Sun, 27 Mar 2016 03:33:14 +0000 (21:33 -0600)] 
chan_pjsip:  Add 'pjsip show channelstats'

Added the ability to show channel statistics to chan_pjsip (cli_functions.c)

Moved the existing 'pjsip show channel(s)' functionality from
pjsip_configuration to cli_functions.c.  The stats needed chan_pjsip's
private header so it made sense to move the existing channel commands as well.

Now using stasis_cache_dump to get the channel snapshots rather than retrieving
all endpoints, then getting each one's channel snapshots.  Much more efficient.

Change-Id: I03b114522126d27434030b285bf6d531ddd79869

9 years agoMerge "res_rtp_asterisk: Fix packet stats on bridged connection" into 13
zuul [Tue, 29 Mar 2016 19:28:36 +0000 (14:28 -0500)] 
Merge "res_rtp_asterisk:  Fix packet stats on bridged connection" into 13

9 years agores_pjsip/pjsip_options: Fix From generation on outgoing OPTIONS 73/2373/9
George Joseph [Fri, 11 Mar 2016 01:52:14 +0000 (18:52 -0700)] 
res_pjsip/pjsip_options:  Fix From generation on outgoing OPTIONS

No one seemed to notice but every time an OPTIONS goes out, it goes
out with a From of "asterisk" (or whatever the default from_user is set to),
even if you specify an endpoint.

The issue had several causes...
qualify_contact is only called with an endpoint if called from the CLI.
If the endpoint is NULL, qualify_contact only looks up the endpoint if
authenticate_qualify=yes. Even then, it never passes it on to
ast_sip_create_request where the From header is set.  Therefore From
is always "asterisk" (or whatever the default from_user is set to).
Even if ast_sip_create_request were to get an endpoint, it only sets
the From if endpoint->from_user is set.

The fix is 4 parts...

First, create_out_of_dialog_request was modified to use the endpoint id
if endpoint was specified and from_user is not set.

Second, qualify_contact was modified to always look up an endpoint if
one wasn't specified regardless of authenticate_qualify.  It then passes
the endpoint on to create_out_of_dialog_request.

Third (and most importantly), find_an_endpoint was modified to find
an endpoint by using an "aors LIKE %contact->aor%" predicate with
ast_sorcery_retrieve_by_fields.  As such, this patch will only work
if the sorcery realtime optimizations patch goes in.  Otherwise we'd
be pulling the entire endpoints database every time we send an OPTIONS.
Since we already know the contact's aor, the on_endpoint callback was also
modified to just check if the contact->aor is an exact match to one of
the endpoint's.

Finally, since we now have an endpoint for every OPTIONS request,
res_pjsip/endpt_send_request (which handles out-of-dialog reqests) was
updated to get the transport from the endpoint and set it on tdata.
Now the correct transport is used.

Change-Id: I2207e12bb435e373bd1e03ad091d82e5aba011af

9 years agoMerge "sorcery/res_pjsip: Refactor for realtime performance" into 13
Joshua Colp [Tue, 29 Mar 2016 18:16:17 +0000 (13:16 -0500)] 
Merge "sorcery/res_pjsip:  Refactor for realtime performance" into 13

9 years agoMerge "app_echo: forward and generate VIDUPDATE frames" into 13
Joshua Colp [Tue, 29 Mar 2016 17:46:38 +0000 (12:46 -0500)] 
Merge "app_echo: forward and generate VIDUPDATE frames" into 13

9 years agoMerge "res_parking: Misc fixes." into 13
zuul [Tue, 29 Mar 2016 13:53:45 +0000 (08:53 -0500)] 
Merge "res_parking: Misc fixes." into 13

9 years agoapp_echo: forward and generate VIDUPDATE frames 67/2467/3
Jacek Konieczny [Fri, 25 Mar 2016 15:42:12 +0000 (16:42 +0100)] 
app_echo: forward and generate VIDUPDATE frames

When using app_echo via WebRTC with VP8 video the video would appear
only after a few minutes, because there would be nothing to request
a full reference frame.

This fixes the problem in both ways:
- echos any VIDUPDATE frames received on the channel
- sends one such frame when first video frame is to be forwarded

This makes the echo work with Firefox and Chrome WebRTC implementation.

ASTERISK-25867 #close

Change-Id: I73bda87bf7532ee8bfb28d917045a21034908c1e

9 years agores_rtp_asterisk: Fix packet stats on bridged connection 78/2478/3
George Joseph [Sun, 27 Mar 2016 17:53:16 +0000 (11:53 -0600)] 
res_rtp_asterisk:  Fix packet stats on bridged connection

rxcount, txcount, rxoctetcount and txoctetcount weren't being calculated
for bridged streams because the calulations were being done after the
bridged short-circuit.  Actually, rxoctetcount wasn't ever being calculated.

Moved the calculations so they occur for all valid received packets and
all transmitted packets.  Also added rxoctetcount and txoctetcount to
ast_rtp_instance_stat.

Change-Id: I08fb06011a82d38c3b4068867a615068fbe59cbb

9 years agoMerge "res_parking: Fix blind transfer dynamic lots creation." into 13
Joshua Colp [Sat, 26 Mar 2016 19:25:53 +0000 (14:25 -0500)] 
Merge "res_parking: Fix blind transfer dynamic lots creation." into 13

9 years agoMerge "res_parking: Cleanup find_channel_parking_lot_name() usage." into 13
zuul [Sat, 26 Mar 2016 16:33:00 +0000 (11:33 -0500)] 
Merge "res_parking: Cleanup find_channel_parking_lot_name() usage." into 13

9 years agores_parking: Fix blind transfer dynamic lots creation. 69/2469/3
Richard Mudgett [Sat, 26 Mar 2016 04:19:22 +0000 (23:19 -0500)] 
res_parking: Fix blind transfer dynamic lots creation.

Blind transfers to a recognized parking extension need to use the parker's
channel variable values to create the dynamic parking lot.  This is
because there is always only one parker while the parkee may actually be a
multi-party bridge.  A multi-party bridge can never supply the needed
channel variables to create the dynamic parking lot.  In the multi-party
bridge blind transfer scenario, the parker's CHANNEL(parkinglot) value and
channel variables are inherited by the local channel used to park the
bridge.

* In park_common_setup(), make use the parker instead of the parkee to
supply the dynamic parking lot channel variable values.  In all but one
case, the parkee is the same as the parker.  However, in the recognized
parking extension blind transfer scenario for a two party bridge they are
different channels.  For consistency, we need to use the parker channel.

* In park_local_transfer(), pass the CHANNEL(parkinglot) value to the
local channel when blind transferring a multi-party bridge to a recognized
parking extension.

* When a local channel starts a call, the Local;2 side needs to inherit
the CHANNEL(parkinglot) value from Local;1.

The DTMF one-touch parking case wasn't even trying to create dynamic
parking lots before it aborted the attempt.

* In parking_park_call(), add missing code to create a dynamic parking
lot.

A DTMF bridge hook is documented as returning -1 to remove the hook.
Though the hook caller is really coded to accept non-zero.  See the
ast_bridge_hook_callback typedef.

* In feature_park_call(), don't remove the DTMF one-touch parking hook
because of an error.

ASTERISK-24605 #close
Reported by:  Philip Correia
Patches:
      call_park.patch (license #6672) patch uploaded by Philip Correia

Change-Id: I221d3a8fcc181877a1158d17004474d35d8016c9

9 years agosorcery/res_pjsip: Refactor for realtime performance 70/2370/15
George Joseph [Tue, 8 Mar 2016 21:55:30 +0000 (14:55 -0700)] 
sorcery/res_pjsip:  Refactor for realtime performance

There were a number of places in the res_pjsip stack that were getting
all endpoints or all aors, and then filtering them locally.

A good example is pjsip_options which, on startup, retrieves all
endpoints, then the aors for those endpoints, then tests the aors to see
if the qualify_frequency is > 0.  One issue was that it never did
anything with the endpoints other than retrieve the aors so we probably
could have skipped a step and just retrieved all aors. But nevermind.

This worked reasonably well with local config files but with a realtime
backend and thousands of objects, this was a nightmare.  The issue
really boiled down to the fact that while realtime supports predicates
that are passed to the database engine, the non-realtime sorcery
backends didn't.

They do now.

The realtime engines have a scheme for doing simple comparisons. They
take in an ast_variable (or list) for matching, and the name of each
variable can contain an operator.  For instance, a name of
"qualify_frequency >" and a value of "0" would create a SQL predicate
that looks like "where qualify_frequency > '0'".  If there's no operator
after the name, the engines add an '=' so a simple name of
"qualify_frequency" and a value of "10" would return exact matches.

The non-realtime backends decide whether to include an object in a
result set by calling ast_sorcery_changeset_create on every object in
the internal container.  However, ast_sorcery_changeset_create only does
exact string matches though so a name of "qualify_frequency >" and a
value of "0" returns nothing because the literal "qualify_frequency >"
doesn't match any name in the objset set.

So, the real task was to create a generic string matcher that can take a
left value, operator and a right value and perform the match. To that
end, strings.c has a new ast_strings_match(left, operator, right)
function.  Left and right are the strings to operate on and the operator
can be a string containing any of the following: = (or NULL or ""), !=,
>, >=, <, <=, like or regex.  If the operator is like or regex, the
right string should be a %-pattern or a regex expression.  If both left
and right can be converted to float, then a numeric comparison is
performed, otherwise a string comparison is performed.

To use this new function on ast_variables, 2 new functions were added to
config.c.  One that compares 2 ast_variables, and one that compares 2
ast_variable lists.  The former is useful when you want to compare 2
ast_variables that happen to be in a list but don't want to traverse the
list.  The latter will traverse the right list and return true if all
the variables in it match the left list.

Now, the backends' fields_cmp functions call ast_variable_lists_match
instead of ast_sorcery_changeset_create and they can now process the
same syntax as the realtime engines.  The realtime backend just passes
the variable list unaltered to the engine.  The only gotcha is that
there's no common realtime engine support for regex so that's been noted
in the api docs for ast_sorcery_retrieve_by_fields.

Only one more change to sorcery was done...  A new config flag
"allow_unqualified_fetch" was added to reg_sorcery_realtime.
"no": ignore fetches if no predicate fields were supplied.
"error": same as no but emit an error. (good for testing)
"yes": allow (the default);
"warn": allow but emit a warning. (good for testing)

Now on to res_pjsip...

pjsip_options was modified to retrieve aors with qualify_frequency > 0
rather than all endpoints then all aors.  Not only was this a big
improvement in realtime retrieval but even for config files there's an
improvement because we're not going through endpoints anymore.

res_pjsip_mwi was modified to retieve only endpoints with something in
the mailboxes field instead of all endpoints then testing mailboxes.

res_pjsip_registrar_expire was completely refactored.  It was retrieving
all contacts then setting up scheduler entries to check for expiration.
Now, it's a single thread (like keepalive) that periodically retrieves
only contacts whose expiration time is < now and deletes them.  A new
contact_expiration_check_interval was added to global with a default of
30 seconds.

Ross Beer reports that with this patch, his Asterisk startup time dropped
from around an hour to under 30 seconds.

There are still objects that can't be filtered at the database like
identifies, transports, and registrations.  These are not going to be
anywhere near as numerous as endpoints, aors, auths, contacts however.

Back to allow_unqualified_fetch.  If this is set to yes and you have a
very large number of objects in the database, the pjsip CLI commands
will attempt to retrive ALL of them if not qualified with a LIKE.
Worse, if you type "pjsip show endpoint <tab>" guess what's going to
happen? :)  Having a cache helps but all the objects will have to be
retrieved at least once to fill the cache.  Setting
allow_unqualified_fetch=no prevents the mass retrieve and should be used
on endpoints, auths, aors, and contacts.  It should NOT be used for
identifies, registrations and transports since these MUST be
retrieved in bulk.

Example sorcery.conf:

[res_pjsip]
endpoint=config,pjsip.conf,criteria=type=endpoint
endpoint=realtime,ps_endpoints,allow_unqualified_fetch=error

ASTERISK-25826 #close
Reported-by: Ross Beer
Tested-by: Ross Beer
Change-Id: Id2691e447db90892890036e663aaf907b2dc1c67

9 years agores_parking: Cleanup find_channel_parking_lot_name() usage. 75/2475/1
Richard Mudgett [Wed, 23 Mar 2016 19:24:49 +0000 (14:24 -0500)] 
res_parking: Cleanup find_channel_parking_lot_name() usage.

Change-Id: I8f7a8890aef27824301c642d4d15407ac83e6f02

9 years agores_parking: Misc fixes. 73/2473/3
Richard Mudgett [Fri, 18 Mar 2016 19:01:02 +0000 (14:01 -0500)] 
res_parking: Misc fixes.

res/parking/parking_applications.c:

* Add malloc fail checks in setup_park_common_datastore().

* Fix playing parking failed announcement to only happen on non-blind
transfers in park_app_exec().  It could never go out before because a test
was provedly always false.

res/parking/parking_bridge.c:

* Fix NULL tolerance in generate_parked_user() because
bridge_parking_push() can theoretically pass a NULL parker channel if the
parker channel went away for some reason.

* Clarify some weird code dealing with blind_transfer in
bridge_parking_push().

res/parking/parking_bridge_features.c:

* Made park_local_transfer() set BLINDTRANSFER on the Local;1 channel
which will be bulk copied to the Local;2 channel on the subsequent
ast_call().  The additional advantage is if the parker channel has the
BLINDTRANSFER and ATTENDEDTRANSFER variables set they are now guaranteed
to be overridden.

res/parking/parking_manager.c:

* Fix AMI Park action input range checking of the Timeout header in
manager_park().

* Reduced locking scope to where needed in manager_park().

res/res_parking.c:

* Fix some off nominal missing unlocks by eliminating the returns.

Change-Id: Ib64945bc285acb05a306dc12e6f16854898915ca

9 years agores_parking: Update parking documentation for dynamic parking lots. 71/2471/2
Philip Correia [Mon, 15 Dec 2014 11:23:53 +0000 (13:23 +0200)] 
res_parking: Update parking documentation for dynamic parking lots.

* Remove duplicate res_parking.conf courtesytone config option
documentation.

ASTERISK-24596 #close
Reported by:  Philip Correia

ASTERISK-24605
Reported by:  Philip Correia
Patches:
      call_park_app_doc.patch (license #6672) patch uploaded by Philip Correia

Change-Id: I90a92a891c6494dc08173e675856afcc4764c5b5

9 years agoMerge "pjproject-bundled: Cleanups for reported issues" into 13
zuul [Fri, 25 Mar 2016 23:11:37 +0000 (18:11 -0500)] 
Merge "pjproject-bundled:  Cleanups for reported issues" into 13

9 years agoMerge "progdocs: Exclude ./third-party from documentation generation" into 13
zuul [Fri, 25 Mar 2016 20:05:38 +0000 (15:05 -0500)] 
Merge "progdocs:  Exclude ./third-party from documentation generation" into 13

9 years agoMerge "core/logging: Fix broken syslog levels on older glibc." into 13
zuul [Fri, 25 Mar 2016 18:38:37 +0000 (13:38 -0500)] 
Merge "core/logging: Fix broken syslog levels on older glibc." into 13

9 years agoMerge "musiconhold: Only warn if music class is not found in memory and database...
zuul [Fri, 25 Mar 2016 02:13:57 +0000 (21:13 -0500)] 
Merge "musiconhold: Only warn if music class is not found in memory and database." into 13

9 years agoMerge "Restrict CLI/AMI commands on shutdown." into 13
zuul [Fri, 25 Mar 2016 00:55:49 +0000 (19:55 -0500)] 
Merge "Restrict CLI/AMI commands on shutdown." into 13

9 years agoMerge "config: fix flags in uint option handler" into 13
zuul [Thu, 24 Mar 2016 18:28:21 +0000 (13:28 -0500)] 
Merge "config: fix flags in uint option handler" into 13

9 years agoconfig: fix flags in uint option handler 45/2445/3
Gianluca Merlo [Sat, 19 Mar 2016 12:34:26 +0000 (13:34 +0100)] 
config: fix flags in uint option handler

The configuration unsigned integer option handler sets flags for the
parser as if the option should be a signed integer (PARSE_INT32),
leading to errors on "out of range" values. Fix flags (PARSE_UINT32).

A fix to res_pjsip is also present which stops invalid flags from
being passed when registering sorcery object fields for qualify
status.

ASTERISK-25612 #close

Change-Id: I96b539336275e0e72a8e8033487d2c3344debd3e

9 years agoRestrict CLI/AMI commands on shutdown. 72/2372/6
Mark Michelson [Thu, 10 Mar 2016 22:58:49 +0000 (16:58 -0600)] 
Restrict CLI/AMI commands on shutdown.

During stress testing, we have frequently seen crashes occur because a
CLI or AMI command attempts to access information that is in the process
of being destroyed.

When addressing how to fix this issue, we initially considered fixing
individual crashes we observed. However, the changes required to fix
those problems would introduce considerable overhead to the nominal
case. This is not reasonable in order to prevent a crash from occurring
while Asterisk is already shutting down.

Instead, this change makes it so AMI and CLI commands cannot be executed
if Asterisk is being shut down. For AMI, this is absolute. For CLI,
though, certain commands can be registered so that they may be run
during Asterisk shutdown.

ASTERISK-25825 #close

Change-Id: I8887e215ac352fadf7f4c1e082da9089b1421990

9 years agomusiconhold: Only warn if music class is not found in memory and database. 56/2456/1
Walter Doekes [Thu, 24 Mar 2016 12:45:06 +0000 (13:45 +0100)] 
musiconhold: Only warn if music class is not found in memory and database.

The log message when a MusicOnHold music class was not found was changed
from debug level to WARNING level in Asterisk 11.19 and 13.5.  For those
using realtime musiconhold, this message is wrong because it warns
before checking the database.

This changeset delays the warning until after the database has been
checked.

Reported-by: Conrad de Wet
ASTERISK-25444 #close

Change-Id: I6cfb2db2f9cfbd2bb3d30566ecae361c4abf6dbf

9 years agocore/logging: Fix broken syslog levels on older glibc. 52/2452/3
Walter Doekes [Thu, 24 Mar 2016 10:38:16 +0000 (11:38 +0100)] 
core/logging: Fix broken syslog levels on older glibc.

The fix to ASTERISK-25407 introduced the usage of LOG_MAKEPRI. However
this macro is broken in older glibc (< 2.17); it would left-shift the
facility a second time, causing the resultant priority to become
invalid.

The syslog manpage mentions nothing about LOG_MAKEPRI and suggests this:

    The priority argument is formed by ORing the facility and the level
    values [...].

ASTERISK-25510 #close
Reported by: Michael Newton

Change-Id: Ia89debe7fac5ad090c7ef595c0707f31bb1e3d03

9 years agopjproject-bundled: Cleanups for reported issues 49/2449/1
George Joseph [Wed, 23 Mar 2016 13:59:12 +0000 (07:59 -0600)] 
pjproject-bundled:  Cleanups for reported issues

PortAudio should no longer be required
PJSIP_MAX_PKT_LEN is now 6000
Older autoconf issue fixed. (CentOS 6)

Change-Id: I463fa9586cbe7c6b3b603289f535bd8e361611dd

9 years agochan_sip.c: Space after port causes unnecessary resolution attempt 47/2447/1
Francesco Castellano [Fri, 20 Nov 2015 14:02:48 +0000 (15:02 +0100)] 
chan_sip.c: Space after port causes unnecessary resolution attempt

check_via() already skips leading blanks where the sent-by address (with the
optional port) should be placed.

Since RFC 3261 allows for blanks between the port ant the Via parameters:
> https://tools.ietf.org/html/rfc3261#section-20.42
(actually it allows a lot of blanks more ;-)). I just switched from
ast_skip_blanks() to ast_strip() on the local copy of the string.

ASTERISK-21301 #close

Change-Id: Ie5b8fe5a07067b7c0dc9bcdd1707e99b23b02b06

9 years agoMerge "func_aes: fix misuse of strlen on binary data" into 13
zuul [Mon, 21 Mar 2016 20:19:01 +0000 (15:19 -0500)] 
Merge "func_aes: fix misuse of strlen on binary data" into 13

9 years agoprogdocs: Exclude ./third-party from documentation generation 41/2441/1
George Joseph [Sat, 19 Mar 2016 22:49:25 +0000 (16:49 -0600)] 
progdocs:  Exclude ./third-party from documentation generation

We don't need pjproject's documentation embedded in Asterisk's.

Change-Id: Iea6f5a621c0f4e3168dda3321eaab258d9f24a17

9 years agofunc_aes: fix misuse of strlen on binary data 39/2439/1
Gianluca Merlo [Sat, 19 Mar 2016 01:32:51 +0000 (02:32 +0100)] 
func_aes: fix misuse of strlen on binary data

The encryption code for AES_ENCRYPT evaluates the length of the data to
be encoded in base64 using strlen. The data is binary, thus the length
of it can be underestimated at the first NULL character.
Reuse the write pointer offset to evaluate it, instead.

ASTERISK-25857 #close

Change-Id: If686b5d570473eb926693c73461177b35b13b186

9 years agochan_pjsip: ref leak when checking direct_media_glare 36/2436/2
Kevin Harwell [Fri, 18 Mar 2016 19:31:12 +0000 (14:31 -0500)] 
chan_pjsip: ref leak when checking direct_media_glare

Fix the reference leak introduced in the following commit:

9444ddadf8525d1ce66a1faf1db97f9f6c265ca4

ASTERISK-25849

Change-Id: I5cfefd5ee6c1c3a1715c050330aaa10e4d2a5e85

9 years agochan_pjsip: transfers with direct media reinvite has wrong address/port 19/2419/5
Kevin Harwell [Wed, 16 Mar 2016 17:37:01 +0000 (12:37 -0500)] 
chan_pjsip: transfers with direct media reinvite has wrong address/port

During a transfer involving direct media a race occurs between when the
transferer channel is swapped out, initiating rtp changes/updates, and the
subsequent reinvites.

When Alice, after speaking with Charlie (Bob is on hold), connects Bob and
Charlie invites are sent to each in order to establish the call between them.
Bob is taken off hold and Charlie is told to have his media flow through
Asterisk. However, if before those invites go out the bridge updates Bob's
and/or Charlie's rtp information with direct media data (i.e. address, port)
then the invite(s) will contain the remote data in the SDP instead of the
Asterisk data.

The race occurs in the native bridge glue code when updating the peer. The
direct_media_address can get set twice before sending out the first invite
during call connection. This can happen because the checking/setting of the
direct_media_address happened in one thread while the sending of the invite(s)
happened in another thread.

This fix removes the race condition by moving the checking/setting of the
direct_media_address to be in the same thread as the sending of the invites(s).
This serializes the checking/setting and sending so they can no longer happen
out of order.

ASTERISK-25849 #close

Change-Id: Idfea590175e74f401929a601dba0c91ca1a7f873

9 years agoMerge "install_prereq: Check if is installed aptitude otherwise to install." into 13
zuul [Thu, 17 Mar 2016 22:42:41 +0000 (17:42 -0500)] 
Merge "install_prereq: Check if is installed aptitude otherwise to install." into 13

9 years agoMerge "install_prereq: Update repositories before install on Debian systems" into 13
zuul [Thu, 17 Mar 2016 22:31:13 +0000 (17:31 -0500)] 
Merge "install_prereq: Update repositories before install on Debian systems" into 13

9 years agoinstall_prereq: Update repositories before install on Debian systems 32/2432/1
Rodrigo Ramírez Norambuena [Mon, 19 Oct 2015 12:11:55 +0000 (09:11 -0300)] 
install_prereq: Update repositories before install on Debian systems

When to install packages the indexed local is more old of the
version of software on the repository they have been upgraded by security
update then get the package will give 404 not found.

The patch prevent by update local index to repository for aptitude before
install.

ASTERISK-25495 #close

Reporte by: Rodrigo Ramírez Norambuena

Change-Id: I645959e553aac542805ced394cac2dca964051fa
(cherry picked from commit 88f3dbaec9509bfba8bc1de7799aa0dc65304bb5)

9 years agoinstall_prereq: Check if is installed aptitude otherwise to install. 31/2431/1
Rodrigo Ramírez Norambuena [Thu, 4 Jun 2015 01:12:50 +0000 (21:12 -0400)] 
install_prereq: Check if is installed aptitude otherwise to install.

If in Debian or system based, dont have aptitude installed the script do
nothing. This patch checked if aptitude  installed, if not installed.

Also, if execute script with all packages installed yet, the script not show
nothing and return exit 1 because the command 'grep' get nothing from pipe from
'awk'.

ASTERISK-25113 #close
Reported By: Rodrigo Ramírez Norambuena <decipher.hk@gmail.com>

Change-Id: Iebdff55805d3917166e5e08e0a1e2176f36ff27f
(cherry picked from commit 6737ded0581a9e1256bdfe30c1d747e7ca93f8b3)

9 years agores_pjsip_refer.c: Fix seg fault in process of Refer-to header. 60/2360/3
Sergio Medina Toledo [Thu, 3 Mar 2016 10:43:59 +0000 (10:43 +0000)] 
res_pjsip_refer.c: Fix seg fault in process of Refer-to header.

The "Refer-to" header of an incoming REFER request is parsed by
pjsip_parse_uri().  That function requires the URI parameter to be NULL
terminated.  Unfortunately, the previous code added the NULL terminator by
overwriting memory that may not be safe.  The overwritten memory results
could be benign, memory corruption, or a segmentation fault.  Now the URI
is NULL terminated safely by copying the URI to a new chunk of memory with
the correct size to be NULL terminated.

ASTERISK-25814 #close

Change-Id: I32565496684a5a49c3278fce06474b8c94b37342

9 years agoMerge "Add initial support to build Docker images" into 13
zuul [Thu, 17 Mar 2016 17:34:02 +0000 (12:34 -0500)] 
Merge "Add initial support to build Docker images" into 13

9 years agochan_sip.c: Fix mwi resub deadlock potential. 01/2401/3
Richard Mudgett [Fri, 11 Mar 2016 18:22:48 +0000 (12:22 -0600)] 
chan_sip.c: Fix mwi resub deadlock potential.

This patch is part of a series to resolve deadlocks in chan_sip.c.

Stopping a scheduled event can result in a deadlock if the scheduled event
is running when you try to stop the event.  If you hold a lock needed by
the scheduled event while trying to stop the scheduled event then a
deadlock can happen.  The general strategy for resolving the deadlock
potential is to push the actual starting and stopping of the scheduled
events off onto the scheduler/do_monitor() thread by scheduling an
immediate one shot scheduled event.  Some restructuring may be needed
because the code may assume that the start/stop of the scheduled events is
immediate.

ASTERISK-25023 #close

Change-Id: I96d429c57a48861fd8bde63dd93db4e92dc3adb6

9 years agochan_sip.c: Fix registration timeout and expire deadlock potential. 00/2400/3
Richard Mudgett [Thu, 10 Mar 2016 23:01:12 +0000 (17:01 -0600)] 
chan_sip.c: Fix registration timeout and expire deadlock potential.

This patch is part of a series to resolve deadlocks in chan_sip.c.

Stopping a scheduled event can result in a deadlock if the scheduled event
is running when you try to stop the event.  If you hold a lock needed by
the scheduled event while trying to stop the scheduled event then a
deadlock can happen.  The general strategy for resolving the deadlock
potential is to push the actual starting and stopping of the scheduled
events off onto the scheduler/do_monitor() thread by scheduling an
immediate one shot scheduled event.  Some restructuring may be needed
because the code may assume that the start/stop of the scheduled events is
immediate.

ASTERISK-25023

Change-Id: I2e40de89efc8ae6e8850771d089ca44bc604b508

9 years agochan_sip.c: Fix t38id deadlock potential. 99/2399/3
Richard Mudgett [Thu, 10 Mar 2016 18:17:09 +0000 (12:17 -0600)] 
chan_sip.c: Fix t38id deadlock potential.

This patch is part of a series to resolve deadlocks in chan_sip.c.

Stopping a scheduled event can result in a deadlock if the scheduled event
is running when you try to stop the event.  If you hold a lock needed by
the scheduled event while trying to stop the scheduled event then a
deadlock can happen.  The general strategy for resolving the deadlock
potential is to push the actual starting and stopping of the scheduled
events off onto the scheduler/do_monitor() thread by scheduling an
immediate one shot scheduled event.  Some restructuring may be needed
because the code may assume that the start/stop of the scheduled events is
immediate.

ASTERISK-25023

Change-Id: If595e4456cd059d7171880c7f354e844c21b5f5f

9 years agochan_sip.c: Fix reinviteid deadlock potential. 98/2398/3
Richard Mudgett [Wed, 9 Mar 2016 22:34:53 +0000 (16:34 -0600)] 
chan_sip.c: Fix reinviteid deadlock potential.

This patch is part of a series to resolve deadlocks in chan_sip.c.

Stopping a scheduled event can result in a deadlock if the scheduled event
is running when you try to stop the event.  If you hold a lock needed by
the scheduled event while trying to stop the scheduled event then a
deadlock can happen.  The general strategy for resolving the deadlock
potential is to push the actual starting and stopping of the scheduled
events off onto the scheduler/do_monitor() thread by scheduling an
immediate one shot scheduled event.  Some restructuring may be needed
because the code may assume that the start/stop of the scheduled events is
immediate.

ASTERISK-25023

Change-Id: I9c11b9d597468f63916c99e1dabff9f4a46f84c1

9 years agochan_sip.c: Fix packet retransid deadlock potential. 97/2397/3
Richard Mudgett [Wed, 9 Mar 2016 22:32:28 +0000 (16:32 -0600)] 
chan_sip.c: Fix packet retransid deadlock potential.

This patch is part of a series to resolve deadlocks in chan_sip.c.

Stopping a scheduled event can result in a deadlock if the scheduled event
is running when you try to stop the event.  If you hold a lock needed by
the scheduled event while trying to stop the scheduled event then a
deadlock can happen.  The general strategy for resolving the deadlock
potential is to push the actual starting and stopping of the scheduled
events off onto the scheduler/do_monitor() thread by scheduling an
immediate one shot scheduled event.  Some restructuring may be needed
because the code may assume that the start/stop of the scheduled events is
immediate.

* Fix retrans_pkt() to call check_pendings() with both the owner channel
and the private objects locked as required.

* Refactor dialog retransmission packet list to safely remove packet
nodes.  The list nodes are now ao2 objects.  The list has a ref and the
scheduled entry has a ref.

ASTERISK-25023

Change-Id: I50926d81be53f4cd3d572a3292cd25f563f59641

9 years agochan_sip.c: Fix waitid deadlock potential. 96/2396/3
Richard Mudgett [Wed, 9 Mar 2016 22:26:26 +0000 (16:26 -0600)] 
chan_sip.c: Fix waitid deadlock potential.

This patch is part of a series to resolve deadlocks in chan_sip.c.

Stopping a scheduled event can result in a deadlock if the scheduled event
is running when you try to stop the event.  If you hold a lock needed by
the scheduled event while trying to stop the scheduled event then a
deadlock can happen.  The general strategy for resolving the deadlock
potential is to push the actual starting and stopping of the scheduled
events off onto the scheduler/do_monitor() thread by scheduling an
immediate one shot scheduled event.  Some restructuring may be needed
because the code may assume that the start/stop of the scheduled events is
immediate.

* Made always run check_pendings() under the scheduler thread so scheduler
ids can be checked safely.

ASTERISK-25023

Change-Id: Ia834d6edd5bdb47c163e4ecf884428a4a8b17d52

9 years agochan_sip.c: Fix session timers deadlock potential. 95/2395/3
Richard Mudgett [Tue, 8 Mar 2016 21:08:19 +0000 (15:08 -0600)] 
chan_sip.c: Fix session timers deadlock potential.

This patch is part of a series to resolve deadlocks in chan_sip.c.

Stopping a scheduled event can result in a deadlock if the scheduled event
is running when you try to stop the event.  If you hold a lock needed by
the scheduled event while trying to stop the scheduled event then a
deadlock can happen.  The general strategy for resolving the deadlock
potential is to push the actual starting and stopping of the scheduled
events off onto the scheduler/do_monitor() thread by scheduling an
immediate one shot scheduled event.  Some restructuring may be needed
because the code may assume that the start/stop of the scheduled events is
immediate.

ASTERISK-25023

Change-Id: I6d65269151ba95e0d8fe4e9e611881cde2ab4900

9 years agochan_sip.c: Fix autokillid deadlock potential. 94/2394/3
Richard Mudgett [Mon, 7 Mar 2016 19:21:44 +0000 (13:21 -0600)] 
chan_sip.c: Fix autokillid deadlock potential.

This patch is part of a series to resolve deadlocks in chan_sip.c.

Stopping a scheduled event can result in a deadlock if the scheduled event
is running when you try to stop the event.  If you hold a lock needed by
the scheduled event while trying to stop the scheduled event then a
deadlock can happen.  The general strategy for resolving the deadlock
potential is to push the actual starting and stopping of the scheduled
events off onto the scheduler/do_monitor() thread by scheduling an
immediate one shot scheduled event.  Some restructuring may be needed
because the code may assume that the start/stop of the scheduled events is
immediate.

* Fix clearing autokillid in __sip_autodestruct() even though we could
reschedule.

ASTERISK-25023

Change-Id: I450580dbf26e2e3952ee6628c735b001565c368f

9 years agochan_sip.c: Fix provisional_keepalive_sched_id deadlock. 93/2393/3
Richard Mudgett [Tue, 8 Mar 2016 00:28:58 +0000 (18:28 -0600)] 
chan_sip.c: Fix provisional_keepalive_sched_id deadlock.

This patch is part of a series to resolve deadlocks in chan_sip.c.

Stopping a scheduled event can result in a deadlock if the scheduled event
is running when you try to stop the event.  If you hold a lock needed by
the scheduled event while trying to stop the scheduled event then a
deadlock can happen.  The general strategy for resolving the deadlock
potential is to push the actual starting and stopping of the scheduled
events off onto the scheduler/do_monitor() thread by scheduling an
immediate one shot scheduled event.  Some restructuring may be needed
because the code may assume that the start/stop of the scheduled events is
immediate.

ASTERISK-25023

Change-Id: I98a694fd42bc81436c83aa92de03226e6e4e3f48

9 years agochan_sip.c: Adjust how dialog_unlink_all() stops scheduled events. 92/2392/3
Richard Mudgett [Wed, 9 Mar 2016 17:22:50 +0000 (11:22 -0600)] 
chan_sip.c: Adjust how dialog_unlink_all() stops scheduled events.

This patch is part of a series to resolve deadlocks in chan_sip.c.

* Make dialog_unlink_all() unschedule all items at once in the sched
thread.

ASTERISK-25023

Change-Id: I7743072fb228836e8228b72f6dc46c8cc50b3fb4

9 years agochan_sip.c: Clear scheduled immediate events on unload. 91/2391/3
Richard Mudgett [Fri, 11 Mar 2016 03:54:03 +0000 (21:54 -0600)] 
chan_sip.c: Clear scheduled immediate events on unload.

This patch is part of a series to resolve deadlocks in chan_sip.c.

The reordering of chan_sip's shutdown is to handle any immediate events
that get put onto the scheduler so resources aren't leaked.  The typical
immediate events at this time are going to be concerned with stopping
other scheduled events.

ASTERISK-25023

Change-Id: I3f6540717634f6f2e84d8531a054976f2bbb9d20

9 years agosip/dialplan_functions.c: Fix /channels/chan_sip/test_sip_rtpqos crash. 03/2403/2
Richard Mudgett [Tue, 15 Mar 2016 19:51:25 +0000 (14:51 -0500)] 
sip/dialplan_functions.c: Fix /channels/chan_sip/test_sip_rtpqos crash.

This patch is part of a series to resolve deadlocks in chan_sip.c.

Delaying destruction of the chan_sip sip_pvt structures caused the
/channels/chan_sip/test_sip_rtpqos unit test to crash.  That test
registers a special test ast_rtp_engine with the rtp engine module.  When
the unit test completes it cleans up by unregistering the test
ast_rtp_engine and exits.  Since the delayed destruction of the sip_pvt
happens after the unit test returns, the destructor tries to call the rtp
engine destroy callback of the test ast_rtp_engine auto variable which no
longer exists on the stack.

* Change the test ast_rtp_engine auto variable to a static variable.  Now
the variable can still exist after the unit test exits so the delayed
sip_pvt destruction can complete successfully.

ASTERISK-25023

Change-Id: I61e34a12d425189ef7e96fc69ae14993f82f3f13

9 years agoMerge "sched.c: Ensure oldest expiring entry runs first." into 13
zuul [Wed, 16 Mar 2016 19:28:38 +0000 (14:28 -0500)] 
Merge "sched.c: Ensure oldest expiring entry runs first." into 13

9 years agoMerge "app_stasis: Don't hang up if app is not registered" into 13
zuul [Wed, 16 Mar 2016 19:15:42 +0000 (14:15 -0500)] 
Merge "app_stasis: Don't hang up if app is not registered" into 13

9 years agoMerge "chan_sip.c: Simplify sip_pvt destructor call levels." into 13
zuul [Wed, 16 Mar 2016 17:14:23 +0000 (12:14 -0500)] 
Merge "chan_sip.c: Simplify sip_pvt destructor call levels." into 13

9 years agoapp_stasis: Don't hang up if app is not registered 02/2402/9
Andrew Nagy [Tue, 15 Mar 2016 18:31:19 +0000 (11:31 -0700)] 
app_stasis: Don't hang up if app is not registered

This prevents pbx_core from hanging up the channel if the app isn't
registered.

ASTERISK-25846 #close

Change-Id: I63216a61f30706d5362bc0906b50b6f0544aebce

9 years agoMerge "pjproject: Pass (dont_)optimize flags to pjproject and fix pjsua" into 13
zuul [Tue, 15 Mar 2016 22:29:12 +0000 (17:29 -0500)] 
Merge "pjproject:  Pass (dont_)optimize flags to pjproject and fix pjsua" into 13

9 years agoMerge "chan_sip.c: Made sip_reinvite_retry() call sip_pvt_lock_full()." into 13
zuul [Tue, 15 Mar 2016 22:29:10 +0000 (17:29 -0500)] 
Merge "chan_sip.c: Made sip_reinvite_retry() call sip_pvt_lock_full()." into 13

9 years agoMerge "build_system: Split COMPILE_DOUBLE from DONT_OPTIMIZE" into 13
zuul [Tue, 15 Mar 2016 20:22:54 +0000 (15:22 -0500)] 
Merge "build_system:  Split COMPILE_DOUBLE from DONT_OPTIMIZE" into 13

9 years agosched.c: Ensure oldest expiring entry runs first. 90/2390/2
Richard Mudgett [Mon, 7 Mar 2016 21:50:22 +0000 (15:50 -0600)] 
sched.c: Ensure oldest expiring entry runs first.

This patch is part of a series to resolve deadlocks in chan_sip.c.

* Updated sched unit test to check new behavior.

ASTERISK-25023

Change-Id: Ib69437327b3cda5e14c4238d9ff91b2531b34ef3

9 years agoMerge "build: Add configure check for proto field of PJSIP TLS transport setting...
zuul [Tue, 15 Mar 2016 15:26:59 +0000 (10:26 -0500)] 
Merge "build: Add configure check for proto field of PJSIP TLS transport setting." into 13

9 years agoMerge "res_pjsip_refer.c: Delay sending the initial SIP Notify with frag 100" into 13
Joshua Colp [Tue, 15 Mar 2016 13:47:37 +0000 (08:47 -0500)] 
Merge "res_pjsip_refer.c: Delay sending the initial SIP Notify with frag 100" into 13

9 years agochan_sip.c: Made sip_reinvite_retry() call sip_pvt_lock_full(). 84/2384/1
Richard Mudgett [Sat, 5 Mar 2016 00:25:21 +0000 (18:25 -0600)] 
chan_sip.c: Made sip_reinvite_retry() call sip_pvt_lock_full().

Change-Id: I90f04208a089f95488a2460185a8dbc3f6acca12

9 years agochan_sip.c: Simplify sip_pvt destructor call levels. 87/2387/1
Richard Mudgett [Tue, 8 Mar 2016 00:56:05 +0000 (18:56 -0600)] 
chan_sip.c: Simplify sip_pvt destructor call levels.

Remove destructor calling destroy_it calling really_destroy_it
for no benefit.  Just make the destructor the really_destroy_it
function.

Change-Id: Idea0d47b27dd74f2488db75bcc7f353d8fdc614a

9 years agobuild: Add configure check for proto field of PJSIP TLS transport setting. 82/2382/3
Joshua Colp [Mon, 14 Mar 2016 13:59:10 +0000 (10:59 -0300)] 
build: Add configure check for proto field of PJSIP TLS transport setting.

Older versions of PJSIP do not have the proto field on the TLS transport
setting structure. This change adds a configure check so even if it is
not present we will still be able to build.

Change-Id: Ibf3f47befb91ed1b8194bf63888baa6fee05aba9

9 years agobuild_system: Split COMPILE_DOUBLE from DONT_OPTIMIZE 80/2380/3
George Joseph [Sat, 12 Mar 2016 22:02:20 +0000 (15:02 -0700)] 
build_system:  Split COMPILE_DOUBLE from DONT_OPTIMIZE

I can't ever recall actually needing the intermediate files or the checking
that a double compile produces.  What I CAN remember is every DONT_OPTIMIZE
build needing 3 invocations of gcc instead of 1 just to do the checks and
produce those intermediate files.

Having said that, Richard pointed out that the reason for the double compile
was that there were cases in the past where a submitted patch failed to compile
because the submitter never tried it with the optimizations turned on.

To get the best of both worlds, COMPILE_DOUBLE has been split into its own
option.  If DONT_OPTIMIZE is turned on, COMPILE_DOUBLE will also be selected
BUT you can then turn it off if all you need are the debugging symbols.  This
way you have to make an informed decision about disabling COMPILE_DOUBLE.

To allow COMPILE_DOUBLE to be both auto-selected and turned off, a new feature
was added to menuselect.  The <use> element can now contain an "autoselect"
attribute which will turn the used member on but not create a hard dependency.
The cflags.xml implementation for COMPILE_DOUBLE looks like this...

<member name="DONT_OPTIMIZE" displayname="Disable Optimizations ...">
<use autoselect="yes">COMPILE_DOUBLE</use>
<support_level>core</support_level>
</member>
<member name="COMPILE_DOUBLE" displayname="Pre-compile with ...>
<depend>DONT_OPTIMIZE</depend>
<support_level>core</support_level>
</member>

When DONT_OPTIMIZE is turned on, COMPILE_DOUBLE is turned on because
of the use.
When DONT_OPTIMIZE is turned off, COMPILE_DOUBLE is turned off because
of the depend.
When COMPILE_DOUBLE is turned on, DONT_OPTIMIZE is turned on because
of the depend.
When COMPILE_DOUBLE is turned off, DONT_OPTIMIZE is left as is because
it only uses COMPILE_DOUBLE, it doesn't depend on it.

I also made a few tweaks to the ncurses implementation to move things
left a bit to allow longer descriptions.

Change-Id: Id49ca930ac4b5ec4fc2d8141979ad888da7b1611

9 years agopjproject: Pass (dont_)optimize flags to pjproject and fix pjsua 78/2378/1
George Joseph [Thu, 10 Mar 2016 19:09:13 +0000 (12:09 -0700)] 
pjproject:  Pass (dont_)optimize flags to pjproject and fix pjsua

The pjproject Makefile now uses the Asterisk optimization flags which
are determined by the setting of the DONT_OPTMIZE menuselect flag.
The Makefile was also restructured so a change to the top level
menuselect.makeopts will result in a rebuild of pjproject.

Also, "--disable-resample" was removed from the pjproject configure
options.  Without resample, pjsua (which is used by the testsuite)
can't make audio calls.  When it can't, it segfaults.

Change-Id: I24b0a4d0872acef00ed89b3c527a713ee4c2ccd4

9 years agoapp_chanspy: Fix occasional deadlock with ChanSpy and Local channels. 75/2375/3
Walter Doekes [Fri, 11 Mar 2016 22:03:08 +0000 (23:03 +0100)] 
app_chanspy: Fix occasional deadlock with ChanSpy and Local channels.

Channel masquerading had a conflict with autochannel locking.

When locking autochannel->channel, the channel is fetched from the
autochannel and then locked. During the fetch, the autochannel -- which
has no locks itself -- can be modified by someone who owns the channel
lock. That means that the value of autochan->channel cannot be trusted
until you hold the lock.

In practice, this caused problems with Local channels getting
masqueraded away while the ChanSpy attempted to get info from that
channel. The old channel which was about to get removed got locked, but
the new (replaced) channel got unlocked (no-op). Because the replaced
channel was now locked (and would never get unlocked), it couldn't get
removed from the channel list in a timely manner, and would now cause
deadlocks when iterating over the channel list.

This change checks the autochannel after locking the channel for changes
to the autochannel. If the channel had been changed, the lock is
reobtained on the new channel.

In theory it seems possible that after this fix, the lock attempt on the
old (wrong) channel can be on an already destroyed lock, maybe causing
a crash. But that hasn't been observed in the wild and is harder induce
than the current deadlock.

Thanks go to Filip Frank for suggesting a fix similar to this and
especially to IRC user hexanol for pointing out why this deadlock was
possible and testing this fix. And to Richard for catching my rookie
while loop mistake ;)

ASTERISK-25321 #close

Change-Id: I293ae0014e531cd0e675c3f02d1d118a98683def

9 years agoMerge "install_prereq: Add packages for bundled pjproject" into 13
Joshua Colp [Thu, 10 Mar 2016 13:35:14 +0000 (07:35 -0600)] 
Merge "install_prereq: Add packages for bundled pjproject" into 13

9 years agoMerge "res_pjsip_caller_id: Anonymize 'From' when caller id presentation is prohibite...
zuul [Wed, 9 Mar 2016 02:36:49 +0000 (20:36 -0600)] 
Merge "res_pjsip_caller_id: Anonymize 'From' when caller id presentation is prohibited" into 13

9 years agoMerge "pjproject_bundled: Remove --with-external-pa from configure options." into 13
zuul [Tue, 8 Mar 2016 23:04:57 +0000 (17:04 -0600)] 
Merge "pjproject_bundled: Remove --with-external-pa from configure options." into 13

9 years agopjproject_bundled: Remove --with-external-pa from configure options. 65/2365/1
George Joseph [Tue, 8 Mar 2016 03:34:12 +0000 (20:34 -0700)] 
pjproject_bundled: Remove --with-external-pa from configure options.

Not sure why it was there in the first place as we already specify
--disable-sound.

Change-Id: Ia80a40e8b1e1acc287955ab11ba1fbd0c7d4cff9

9 years agores_pjsip: Strip spaces from items parsed from comma-separated lists 58/2358/4
George Joseph [Sun, 6 Mar 2016 20:38:41 +0000 (13:38 -0700)] 
res_pjsip:  Strip spaces from items parsed from comma-separated lists

Configurations like "aors = a, b, c" were either ignoring everything after "a"
or trying to look up " b".  Same for mailboxes,  ciphers, contacts and a few
others.

To fix, all the strsep(&copy, ",") calls have been wrapped in ast_strip.  To
facilitate this, ast_strip, ast_skip_blanks and ast_skip_nonblanks were
updated to handle null pointers.

In some cases, an ast_strlen_zero() test was added to skip consecutive commas.

There was also an attempt to ast_free an ast_strdupa'd string in
ast_sip_for_each_aor which was causing a SEGV.  I removed it.

Although this issue was reported for realtime, the issue was in the res_pjsip
modules so all config mechanisms were affected.

ASTERISK-25829 #close
Reported-by: Mateusz Kowalski
Change-Id: I0b22a2cf22a7c1c50d4ecacbfa540155bec0e7a2

9 years agoinstall_prereq: Add packages for bundled pjproject 56/2356/2
George Joseph [Sat, 5 Mar 2016 02:37:44 +0000 (19:37 -0700)] 
install_prereq: Add packages for bundled pjproject

RedHat/CentOS needs python-devel
Debian/Ubuntu needs automake, libsrtp-dev and python-dev

Ubuntu also needed libncurses5-dev for cmenuselect so while not
needed for pjproject, I adedd it anyway.

Change-Id: Idf5fa16e2d87c687439621507e122cb9461d7089

9 years agoMerge "third_party/Makefile.rules: Replace unsupported != operator with $(shell...
zuul [Fri, 4 Mar 2016 13:04:13 +0000 (07:04 -0600)] 
Merge "third_party/Makefile.rules:  Replace unsupported != operator with $(shell ...)" into 13

9 years agoMerge "config_transport: Fix objects returned by ast_sip_get_transport_states" into 13
Joshua Colp [Fri, 4 Mar 2016 11:44:02 +0000 (05:44 -0600)] 
Merge "config_transport:  Fix objects returned by ast_sip_get_transport_states" into 13

9 years agoMerge "alembic: Fix downgrade and tweak for sqlite" into 13
zuul [Fri, 4 Mar 2016 03:05:30 +0000 (21:05 -0600)] 
Merge "alembic: Fix downgrade and tweak for sqlite" into 13

9 years agores_pjsip_caller_id: Anonymize 'From' when caller id presentation is prohibited 93/2293/5
George Joseph [Wed, 24 Feb 2016 23:25:09 +0000 (16:25 -0700)] 
res_pjsip_caller_id: Anonymize 'From' when caller id presentation is prohibited

Per RFC3325, the 'From' header is now anonymized on outgoing calls when
caller id presentation is prohibited.

TID = trust_id_outbound
PRO = Set(CALLERID(pres)=prohib)
USR = endpoint/from_user
DOM = endpoint/from_domain
PAI = YES(privacy=off), NO(not sent), PRI(privacy=full) (assumes send_pai=yes)

Conditions          |Result
--------------------|----------------------------------------------------
TID PRO USR DOM     |PAI    FROM
--------------------|----------------------------------------------------
Y   Y   abc def.ghi |PRI    "Anonymous" <sip:abc@def.ghi>
Y   Y   abc         |PRI    "Anonymous" <sip:abc@anonymous.invalid>
Y   Y       def.ghi |PRI    "Anonymous" <sip:anonymous@def.ghi>
Y   Y               |PRI    "Anonymous" <sip:anonymous@anonymous.invalid>

Y   N   abc def.ghi |YES    <sip:abc@def.ghi>
Y   N   abc         |YES    <sip:abc@<ip_address>>
Y   N       def.ghi |YES    "Caller Name" <sip:<caller_exten>@def.ghi>
Y   N               |YES    "Caller Name" <sip:<caller_exten>@<ip_address>>

N   Y   abc def.ghi |NO     "Anonymous" <sip:abc@def.ghi>
N   Y   abc         |NO     "Anonymous" <sip:abc@anonymous.invalid>
N   Y       def.ghi |NO     "Anonymous" <sip:anonymous@def.ghi>
N   Y               |NO     "Anonymous" <sip:anonymous@anonymous.invalid>

N   N   abc def.ghi |YES    <sip:abc@def.ghi>
N   N   abc         |YES    <sip:abc@<ip_address>>
N   N       def.ghi |YES    "Caller Name" <sip:<caller_exten>@def.ghi>
N   N               |YES    "Caller Name" <sip:<caller_exten>@<ip_address>>

ASTERISK-25791 #close
Reported-by: Anthony Messina
Change-Id: I2c82a5ca1413c2c00fb62ea95b0ae8e97af54dc9

9 years agoMerge "loader: Retry dlopen when loading fails" into 13
zuul [Fri, 4 Mar 2016 01:57:41 +0000 (19:57 -0600)] 
Merge "loader: Retry dlopen when loading fails" into 13

9 years agothird_party/Makefile.rules: Replace unsupported != operator with $(shell ...) 51/2351/6
George Joseph [Thu, 3 Mar 2016 23:34:51 +0000 (16:34 -0700)] 
third_party/Makefile.rules:  Replace unsupported != operator with $(shell ...)

Apparently the != operator is fairly new so I've replaced it with
the old $(shell ...) syntax.

Change-Id: I16b2e1878a4f91e7e9740abd427f9639f933c479
Reported-by: Richard Mudgett
9 years agoMerge "bridge.c: Crash during attended transfer when missing a local channel half...
zuul [Thu, 3 Mar 2016 22:42:04 +0000 (16:42 -0600)] 
Merge "bridge.c: Crash during attended transfer when missing a local channel half" into 13

9 years agoloader: Retry dlopen when loading fails 73/2073/8
George Joseph [Sat, 23 Jan 2016 21:50:57 +0000 (14:50 -0700)] 
loader: Retry dlopen when loading fails

Although we use the RTLD_LAZY flag when calling dlopen
the first time on a module, this only defers resolution
for function calls.  Pointer references to functions are
determined at link time so dlopen expects them to be there.
Since we don't cross-module link, pointers to functions
in other modules won't be available and dlopen will fail.

Doing a "hardened" build also causes problems because it
typically sets "-z now" on the ld command line which
overrides RTLD_LAZY at run time.

If the failing module isn't a GLOBAL_SYMBOLS module, then
dlopen will be called again after all the GLOBAL_SYMBOLS
modules have been loaded and they'll eventually resolve.

If the calling module IS a GLOBAL_SYMBOLS module itself
and a third module depends on it, then there's an issue
because the second time through the dlopen loop,
GLOBAL_SYMBOLS modules aren't given any special treatment
and since the order in which dlopen is called isn't
deterministic, the dependent may again be tried before the
module it needs is loaded.

Simple solution:  Save modules that fail load_resource
because of a dlopen error in a list and retry them
immediately after the first pass. Keep retrying until
the failed list is empty or we reach a #defined max
retries. Error messages are suppressed until the final
pass which also gets rid of those confusing error messages
about module failures that are later corrected.

Change-Id: Iddae1d97cd2f00b94e61662447432765755f64bb

9 years agoMerge "res_pjsip_dtmf_info: NULL terminate the message body." into 13
zuul [Thu, 3 Mar 2016 20:51:12 +0000 (14:51 -0600)] 
Merge "res_pjsip_dtmf_info: NULL terminate the message body." into 13

9 years agobridge.c: Crash during attended transfer when missing a local channel half 19/2319/3
Kevin Harwell [Tue, 1 Mar 2016 22:18:21 +0000 (16:18 -0600)] 
bridge.c: Crash during attended transfer when missing a local channel half

It's possible for the transferer channel to get hung up early during the
attended transfer process. For instance, a phone may send a "bye" immediately
upon receiving a sip notify that contains a sip frag 100 (I'm looking at you
Jitsi). When this occurs a race begins between the transferer being hung up
and completion of the transfer code.

If the channel hangs up too early during a transfer involving stasis bridging
for instance, then when the created local channel goes to look up its swap
channel (and associated datastore) it can't find it (since it is no longer in
the bridge) thus it fails to enter the stasis application. Consequently, the
created local channel(s) hang up as well. If the timing is just right then the
bridging code attempts to add the message link with missing local channel(s).
Hence the crash.

Unfortunately, there is no great way to solve the problem of the unexpected
"bye". While we can't guarantee we won't receive an early hangup, and in this
case still fail to enter the stasis application, we can make it so asterisk
does not crash.

This patch does just that by locking the local channel structure, checking
that the local channel's peer has not been lost, and then continuing. This
keeps the local channel's peer from being ripped out from underneath it by
the local/unreal hangup code while attempting to set the stasis message link.

ASTERISK-25771

Change-Id: Ie6d6061e34c7c95f07116fffac9a09e5d225c880

9 years agores_pjsip_refer.c: Delay sending the initial SIP Notify with frag 100 21/2321/3
Kevin Harwell [Wed, 2 Mar 2016 00:08:52 +0000 (18:08 -0600)] 
res_pjsip_refer.c: Delay sending the initial SIP Notify with frag 100

During the transfer process, some phones (okay it was the Jitsi softphone,
but maybe others are out there) send a "bye" immediately after receiving a
SIP Notify. When a "bye" is received early for some types of transfers the
transferer channel may no longer be available during late stage transfer
processing.

For instance, during an attended transfer involving stasis bridging at one
point the created local channel looks for an associated swap channel in
order to retrieve the stasis application name. If the transferer has hung
up then the local channel will fail to find it. The local channel then has
no way to know which stasis app to enter, so it fails and hangs up as well.
Thus the transfer does not complete as expected.

This patch delays the sending of the initial notify in order to give the
transfer process enough time to gather the necessary data for a successful
transfer.

ASTERISK-25771

Change-Id: I09cfc9a5d6ed4c007bc70625e0972b470393bf16

9 years agoMerge "build-system: Allow building with static pjproject" into 13
zuul [Thu, 3 Mar 2016 17:16:47 +0000 (11:16 -0600)] 
Merge "build-system: Allow building with static pjproject" into 13

9 years agores_pjsip_dtmf_info: NULL terminate the message body. 49/2349/2
Joshua Colp [Thu, 3 Mar 2016 14:26:10 +0000 (10:26 -0400)] 
res_pjsip_dtmf_info: NULL terminate the message body.

PJSIP does not ensure that when printing the message body the
buffer will be NULL terminated. This is problematic when searching
for the signal and duration values of the DTMF.

This change ensures the buffer is always NULL terminated.

Change-Id: I52653a1a60c93092d06af31a27408d569cc98968

9 years agoMerge "func_callerid.c: Update REDIRECTING reason documentation." into 13
Joshua Colp [Thu, 3 Mar 2016 14:47:43 +0000 (08:47 -0600)] 
Merge "func_callerid.c: Update REDIRECTING reason documentation." into 13

9 years agoMerge "SIP diversion: Fix REDIRECTING(reason) value inconsistencies." into 13
Joshua Colp [Thu, 3 Mar 2016 14:47:36 +0000 (08:47 -0600)] 
Merge "SIP diversion: Fix REDIRECTING(reason) value inconsistencies." into 13

9 years agoMerge "res_pjsip_send_to_voicemail.c: Fix off-nominal double channel unref." into 13
Joshua Colp [Thu, 3 Mar 2016 11:32:51 +0000 (05:32 -0600)] 
Merge "res_pjsip_send_to_voicemail.c: Fix off-nominal double channel unref." into 13

9 years agoMerge "res_pjsip_send_to_voicemail.c: Allow either quoted or not send_to_vm reason...
zuul [Thu, 3 Mar 2016 02:25:33 +0000 (20:25 -0600)] 
Merge "res_pjsip_send_to_voicemail.c: Allow either quoted or not send_to_vm reason." into 13

9 years agoMerge "CHAOS: cleanup possible null vars on msg alloc failure" into 13
Joshua Colp [Thu, 3 Mar 2016 00:11:59 +0000 (18:11 -0600)] 
Merge "CHAOS: cleanup possible null vars on msg alloc failure" into 13

9 years agoalembic: Fix downgrade and tweak for sqlite 29/2329/2
George Joseph [Wed, 2 Mar 2016 02:03:04 +0000 (19:03 -0700)] 
alembic: Fix downgrade and tweak for sqlite

Downgrade had a few issues.  First there was an errant 'update' statement in
add_auto_dtmf_mode that looks like it was a copy/paste error.  Second, we
weren't cleaning up the ENUMs so subsequent upgrades on postgres failed
because the types already existed.

For sqlite...  sqlite doesn't support ALTER or DROP COLUMN directly.
Fortunately alembic batch_operations takes care of this for us if we
use it so the alter and drops were converted to use batch operations.

Here's an example downgrade:

    with op.batch_alter_table('ps_endpoints') as batch_op:
        batch_op.drop_column('tos_audio')
        batch_op.drop_column('tos_video')
        batch_op.add_column(sa.Column('tos_audio', yesno_values))
        batch_op.add_column(sa.Column('tos_video', yesno_values))
        batch_op.drop_column('cos_audio')
        batch_op.drop_column('cos_video')
        batch_op.add_column(sa.Column('cos_audio', yesno_values))
        batch_op.add_column(sa.Column('cos_video', yesno_values))

    with op.batch_alter_table('ps_transports') as batch_op:
        batch_op.drop_column('tos')
        batch_op.add_column(sa.Column('tos', yesno_values))
    # Can't cast integers to YESNO_VALUES, so dropping and adding is required
        batch_op.drop_column('cos')
        batch_op.add_column(sa.Column('cos', yesno_values))

Upgrades from base to head and downgrades from head to base were tested
repeatedly for postgresql, mysql/mariadb, and sqlite3.

Change-Id: I862b0739eb3fd45ec3412dcc13c2340e1b7baef8

9 years agoconfig_transport: Fix objects returned by ast_sip_get_transport_states 46/2346/1
George Joseph [Wed, 2 Mar 2016 21:55:48 +0000 (14:55 -0700)] 
config_transport:  Fix objects returned by ast_sip_get_transport_states

ast_sip_get_transport_states was returning a container of internal_state
objects instead of ast_sip_transport_state objects.  This was causing
transport lookups to fail, most noticably in res_pjsip_nat, which
couldn't find the correct external addresses.  This was causing contacts
to go out with internal ip addresses.

ASTERISK-25830 #close
Reported-by: Sean Bright
Change-Id: I1aee6a2fd46c42e8dd0af72498d17de459ac750e

9 years agoCHAOS: cleanup possible null vars on msg alloc failure 44/2344/2
Scott Griepentrog [Wed, 2 Mar 2016 17:17:54 +0000 (11:17 -0600)] 
CHAOS: cleanup possible null vars on msg alloc failure

In message.c, if msg_alloc fails to init the string field,
vars may be null, so use a null tolerant cleanup.

In res_pjsip_messaging.c, if msg_data_create fails, mdata
will be null, so use a null tolerant cleanup.

ASTERISK-25323

Change-Id: Ic2d55c2c3750d5616e2a05ea92a19c717507ff56

9 years agoCHAOS: prevent crash on failed strdup 42/2342/2
Scott Griepentrog [Wed, 2 Mar 2016 15:34:10 +0000 (09:34 -0600)] 
CHAOS: prevent crash on failed strdup

This patch avoids crashing on a null pointer
if the strdup() allocation fails.

ASTERISK-25323

Change-Id: I3f67434820ba53b53663efd6cbb42749f4f6c0f5

9 years agofunc_callerid.c: Update REDIRECTING reason documentation. 27/2327/1
Richard Mudgett [Tue, 1 Mar 2016 00:11:33 +0000 (18:11 -0600)] 
func_callerid.c: Update REDIRECTING reason documentation.

Change-Id: I6e8d39b0711110a4bceafa652e58b30465e28386

9 years agoSIP diversion: Fix REDIRECTING(reason) value inconsistencies. 26/2326/1
Richard Mudgett [Sat, 27 Feb 2016 00:57:17 +0000 (18:57 -0600)] 
SIP diversion: Fix REDIRECTING(reason) value inconsistencies.

Previous chan_sip behavior:

Before this patch chan_sip would always strip any quotes from an incoming
reason and pass that value up as the REDIRECTING(reason).  For an outgoing
reason value, chan_sip would check the value against known values and
quote any it didn't recognize.  Incoming 480 response message reason text
was just assigned to the REDIRECTING(reason).

Previous chan_pjsip behavior:

Before this patch chan_pjsip would always pass the incoming reason value
up as the REDIRECTING(reason).  For an outgoing reason value, chan_pjsip
would send the reason value as passed down.

With this patch:

Both channel drivers match incoming reason values with values documented
by REDIRECTING(reason) and values documented by RFC5806 regardless of
whether they are quoted or not.  RFC5806 values are mapped to the
equivalent REDIRECTING(reason) documented value and is set in
REDIRECTING(reason).  e.g., an incoming RFC5806 'unconditional' value or a
quoted string version ('"unconditional"') is converted to
REDIRECTING(reason)'s 'cfu' value.  The user's dialplan only needs to deal
with 'cfu' instead of any of the aliases.

The incoming 480 response reason text supported by chan_sip checks for
known reason values and if not matched then puts quotes around the reason
string and assigns that to REDIRECTING(reason).

Both channel drivers send outgoing known REDIRECTING(reason) values as the
unquoted RFC5806 equivalent.  User custom values are either sent as is or
with added quotes if SIP doesn't allow a character within the value as
part of a RFC3261 Section 25.1 token.  Note that there are still
limitations on what characters can be put in a custom user value.  e.g.,
embedding quotes in the middle of the reason string is silly and just
going to cause you grief.

* Setting a REDIRECTING(reason) value now recognizes RFC5806 aliases.
e.g., Setting REDIRECTING(reason) to 'unconditional' is converted to the
'cfu' value.

* Added missing malloc() NULL return check in res_pjsip_diversion.c
set_redirecting_reason().

* Fixed potential read from a stale pointer in res_pjsip_diversion.c
add_diversion_header().  The reason string needed to be copied into the
tdata memory pool to ensure that the string would always be available.
Otherwise, if the reason string returned by reason_code_to_str() was a
user's reason string then the string could be freed later by another
thread.

Change-Id: Ifba83d23a195a9f64d55b9c681d2e62476b68a87

9 years agores_pjsip_send_to_voicemail.c: Allow either quoted or not send_to_vm reason. 25/2325/1
Richard Mudgett [Sat, 27 Feb 2016 00:54:53 +0000 (18:54 -0600)] 
res_pjsip_send_to_voicemail.c: Allow either quoted or not send_to_vm reason.

Change-Id: Id6350b3c7d4ec8df7ec89863566645e2b0f441fd

9 years agores_pjsip_send_to_voicemail.c: Fix off-nominal double channel unref. 23/2323/1
Richard Mudgett [Tue, 1 Mar 2016 02:41:55 +0000 (20:41 -0600)] 
res_pjsip_send_to_voicemail.c: Fix off-nominal double channel unref.

* Fix double unref of other_party channel in off nominal path.

* This is unlikely to be a real problem.  However, for safety,
in handle_incoming_request() keep the datastore ref with the
other_party channel ref until we are finished with the other_party
channel.

Change-Id: I78f22547bf0bb99fb20814ceab75952bd857f821