asterisk/asterisk.git
4 years agoARI: Add the ability to subscribe to all events
Matt Jordan [Fri, 4 Sep 2015 17:25:07 +0000 (12:25 -0500)]
ARI: Add the ability to subscribe to all events

This patch adds the ability to subscribe to all events. There are two possible
ways to accomplish this:
(1) On initial WebSocket connection. This patch adds a new query parameter,
    'subscribeAll'. If present and True, Asterisk will subscribe the
    applications to all ARI events.
(2) Via the applications resource. When subscribing in this manner, an ARI
    client should merely specify a blank resource name, i.e., 'channels:'
    instead of 'channels:12354'. This will subscribe the application to all
    resources of the 'channels' type.

ASTERISK-24870 #close

Change-Id: I4a943b4db24442cf28bc64b24bfd541249790ad6

4 years agores/res_stasis_device_state: Allow for subscribing to 'all' device state
Matt Jordan [Fri, 4 Sep 2015 17:24:57 +0000 (12:24 -0500)]
res/res_stasis_device_state: Allow for subscribing to 'all' device state

This patch adds support for subscribing to all device state changes. This is
done either by subscribing to an empty device, e.g., 'eventSource=deviceState:',
or by the WebSocket connection specifying that it wants all state in the
system.

ASTERISK-24870

Change-Id: I9cfeca1c9e2231bd7ea73e45919111d44d2eda32

4 years agoARI: Add events for Contact and Peer Status changes
Matt Jordan [Fri, 4 Sep 2015 02:19:21 +0000 (21:19 -0500)]
ARI: Add events for Contact and Peer Status changes

This patch adds support for receiving events regarding Peer status changes
and Contact status changes. This is particularly useful in scenarios where
we are subscribed to all endpoints and channels, where we often want to know
more about the state of channel technology specific items than a single
endpoint's state.

ASTERISK-24870

Change-Id: I6137459cdc25ce27efc134ad58abf065653da4e9

4 years agoMerge "main/config_options: Check for existance of internal object before derefing"
Matt Jordan [Mon, 21 Sep 2015 13:08:36 +0000 (08:08 -0500)]
Merge "main/config_options: Check for existance of internal object before derefing"

4 years agoMerge "app_queue: AgentComplete event has wrong reason"
Matt Jordan [Sat, 19 Sep 2015 21:26:33 +0000 (16:26 -0500)]
Merge "app_queue: AgentComplete event has wrong reason"

4 years agoMerge "app_queue: Crash when transferring"
Matt Jordan [Sat, 19 Sep 2015 14:15:37 +0000 (09:15 -0500)]
Merge "app_queue: Crash when transferring"

4 years agoMerge "CHAOS: res_pjsip_diversion avoid crash if allocation fails"
Matt Jordan [Sat, 19 Sep 2015 14:15:21 +0000 (09:15 -0500)]
Merge "CHAOS: res_pjsip_diversion avoid crash if allocation fails"

4 years agoMerge "dr_adaptive_odbc.c, cel_odbc.c, cel_pgsql.c: REFACTOR Macro LENGTHEN_BUF"
Matt Jordan [Sat, 19 Sep 2015 14:15:02 +0000 (09:15 -0500)]
Merge "dr_adaptive_odbc.c, cel_odbc.c, cel_pgsql.c: REFACTOR Macro LENGTHEN_BUF"

4 years agoMerge "chan_sip: Fix From header truncation for extremely long CALLERID(name)."
Joshua Colp [Sat, 19 Sep 2015 13:31:52 +0000 (08:31 -0500)]
Merge "chan_sip: Fix From header truncation for extremely long CALLERID(name)."

4 years agoMerge "CHAOS: avoid crash if string create fails"
Joshua Colp [Sat, 19 Sep 2015 13:22:45 +0000 (08:22 -0500)]
Merge "CHAOS: avoid crash if string create fails"

4 years agoCHAOS: avoid crash if string create fails
Scott Griepentrog [Thu, 17 Sep 2015 21:34:41 +0000 (16:34 -0500)]
CHAOS: avoid crash if string create fails

Validate string buffer allocation before using them.

ASTERISK-25323

Change-Id: Ib9c338bdc1e53fb8b81366f0b39482b83ef56ce0

4 years agodr_adaptive_odbc.c, cel_odbc.c, cel_pgsql.c: REFACTOR Macro LENGTHEN_BUF
Rodrigo Ramírez Norambuena [Fri, 11 Sep 2015 06:52:15 +0000 (03:52 -0300)]
dr_adaptive_odbc.c, cel_odbc.c, cel_pgsql.c: REFACTOR Macro LENGTHEN_BUF

Remove repeated code on macro of assigned buffer to SQL vars

Change-Id: Icb19ad013124498e172ea1d0b29ccd0ed17deef0

4 years agochan_sip: Fix From header truncation for extremely long CALLERID(name).
Walter Doekes [Thu, 17 Sep 2015 09:52:09 +0000 (11:52 +0200)]
chan_sip: Fix From header truncation for extremely long CALLERID(name).

The CALLERID(num) and CALLERID(name) and other info are placed into the
`char from[256]` in initreqprep. If the name was too long, the addr-spec
and params wouldn't fit.

Code is moved around so the addr-spec with params is placed there first,
and then fitting in as much of the display-name as possible.

ASTERISK-25396 #close

Change-Id: I33632baf024f01b6a00f8c7f35c91e5f68c40260

4 years agoCHAOS: res_pjsip_diversion avoid crash if allocation fails
Richard Mudgett [Thu, 17 Sep 2015 21:59:18 +0000 (16:59 -0500)]
CHAOS: res_pjsip_diversion avoid crash if allocation fails

Validate ast_malloc buffer returned before using it in
set_redirecting_value().

ASTERISK-25323

Change-Id: I15d2ed7cb0546818264c0bf251aa40adeae83253

4 years agoapp_queue: AgentComplete event has wrong reason
Kevin Harwell [Thu, 17 Sep 2015 21:47:33 +0000 (16:47 -0500)]
app_queue: AgentComplete event has wrong reason

When a queued caller transfers an agent to another extension sometimes the
raised AgentComplete event has a reason of "caller" and sometimes "transfer".
Since a transfer has taken place this should always be transfer. This occurs
because sometimes the stasis hangup event arrives before the transfer event
thus writing a different reason out.

With this patch, when a hangup event is received during a transfer it will
check to see if the channel that is hanging up is part of a transfer. If so
it will return and let the subsequently received transfer event handler take
care of the cleanup.

ASTERISK-25399 #close

Change-Id: Ic63c49bd9a5ed463ea7a032fd2ea3d63bc81a50d

4 years agoPJSIP: avoid crash when getting rtp peer
Scott Griepentrog [Thu, 17 Sep 2015 18:09:56 +0000 (13:09 -0500)]
PJSIP: avoid crash when getting rtp peer

Although unlikely, if the tech private is returned as
a NULL, chan_pjsip_get_rtp_peer() would crash.

ASTERISK-25323

Change-Id: Ie231369bfa7da926fb2b9fdaac228261a3152e6a

4 years agoapp_queue: Crash when transferring
Kevin Harwell [Thu, 17 Sep 2015 16:31:15 +0000 (11:31 -0500)]
app_queue: Crash when transferring

During some transfer scenarios involving queues Asterisk would sometimes
crash when trying to obtain a channel snapshot (could happen on caller or
member channels). This occurred because the underlying channel had already
disappeared when trying to obtain the latest snapshot.

This patch adds a reference to both the member and caller channels that
extends to the lifetime of the queue'd call, thus making sure the channels
will always exist when retrieving the latest snapshots.

ASTERISK-25185 #close
Reported by: Etienne Lessard

Change-Id: Ic397fa68fb4ff35fbc378e745da9246a7b552128

4 years agores_pjsip_pubsub: Eliminate race during initial NOTIFY.
Mark Michelson [Wed, 16 Sep 2015 22:36:32 +0000 (17:36 -0500)]
res_pjsip_pubsub: Eliminate race during initial NOTIFY.

There is a slim chance of a race condition occurring where two threads
can both attempt to manipulate the same area.

Thread A can be handling an incoming initial SUBSCRIBE request. Thread A
lets the specific subscription handler know that the subscription has
been established.

At this point, Thread B may detect a state change on the subscribed
resource and queue up a notification task on Thread C, the subscription
serializer thread.

Now Thread A attempts to generate the initial NOTIFY request to send to
the subscriber at the same time that Thread C attempts to generate a
state change NOTIFY request to send to the subscriber.

The result is that Threads A and C can step on the same memory area,
resulting in a crash. The crash has been observed as happening when
attempting to allocate more space to hold the body for the NOTIFY.

The solution presented here is to queue the subscription establishment
and initial NOTIFY generation onto the subscription serializer thread
(Thread C in the above scenario). This way, there is no way that a state
change notification can occur before the initial NOTIFY is sent, and if
there is a quick succession of NOTIFYs, we can guarantee that the two
NOTIFY requests will be sent in succession.

Change-Id: I5a89a77b5f2717928c54d6efb9955e5f6f5cf815

4 years agoscheduler: Use queue for allocating sched IDs.
Mark Michelson [Thu, 10 Sep 2015 22:19:26 +0000 (17:19 -0500)]
scheduler: Use queue for allocating sched IDs.

It has been observed that on long-running busy systems, a scheduler
context can eventually hit INT_MAX for its assigned IDs and end up
overflowing into a very low negative number. When this occurs, this can
result in odd behaviors, because a negative return is interpreted by
callers as being a failure. However, the item actually was successfully
scheduled. The result may be that a freed item remains in the scheduler,
resulting in a crash at some point in the future.

The scheduler can overflow because every time that an item is added to
the scheduler, a counter is bumped and that counter's current value is
assigned as the new item's ID.

This patch introduces a new method for assigning scheduler IDs. Instead
of assigning from a counter, a queue of available IDs is maintained.
When assigning a new ID, an ID is pulled from the queue. When a
scheduler item is released, its ID is pushed back onto the queue. This
way, IDs may be reused when they become available, and the growth of ID
numbers is directly related to concurrent activity within a scheduler
context rather than the uptime of the system.

Change-Id: I532708eef8f669d823457d7fefdad9a6078b99b2

4 years agomain/config_options: Check for existance of internal object before derefing
Matt Jordan [Fri, 4 Sep 2015 02:15:13 +0000 (21:15 -0500)]
main/config_options: Check for existance of internal object before derefing

Asterisk can load and register an object type while still having an invalid
sorcery mapping. This can cause an issue when a creation call is invoked.
For example, mis-configuring PJSIP's endpoint identifier by IP address mapping
in sorcery.conf will cause the sorcery mechanism to be invalidated; however, a
subsequent ARI invocation to create the object will cause a crash, as the
internal type may not be registered as sorcery expects.

Merely checking for a NULL pointer here solves the issue.

Change-Id: I54079fb94a1440992f4735a9a1bbf1abb1c601ac

4 years agoMerge "res/res_pjsip_nat: Ignore REGISTER requests when looking for a Record-Route"
Matt Jordan [Fri, 11 Sep 2015 21:13:53 +0000 (16:13 -0500)]
Merge "res/res_pjsip_nat: Ignore REGISTER requests when looking for a Record-Route"

4 years agoMerge "chan_sip.c: Validation on module reload"
Matt Jordan [Fri, 11 Sep 2015 17:40:43 +0000 (12:40 -0500)]
Merge "chan_sip.c: Validation on module reload"

4 years agochan_sip.c: Validation on module reload
Rodrigo Ramírez Norambuena [Sat, 22 Aug 2015 02:50:31 +0000 (22:50 -0400)]
chan_sip.c: Validation on module reload

Change validation on reload module because now used the cli function for
reload. The sip_reload() function never fail and ever return NULL for this
reason on reload() now use the call the sip_reload() and return
AST_MODULE_LOAD_SUCCESS.

This problem is dectected on reload by PUT method on ARI, getting always
404 http code when the module is reloaded.

ASTERISK-25325 #close
Reporte by: Rodrigo Ramírez Norambuena

Change-Id: I41215877fb2cfc589e0d4d464000cf6825f4d7fb

4 years agores_pjsip_pubsub.c: Mark ast_sip_create_subscription() as not used.
Richard Mudgett [Fri, 21 Aug 2015 22:39:01 +0000 (17:39 -0500)]
res_pjsip_pubsub.c: Mark ast_sip_create_subscription() as not used.

Change-Id: I2b8db18eac36c01a5c7eb9467699124e203fd093

4 years agores_pjsip_pubsub.c: Add some notification comments.
Richard Mudgett [Wed, 9 Sep 2015 17:24:31 +0000 (12:24 -0500)]
res_pjsip_pubsub.c: Add some notification comments.

Change-Id: Ie62ff1f4b7adc1a12fa0303f53926af249b25e20

4 years agores_pjsip_pubsub.c: Set dlg_status code instead of sending SIP response.
Richard Mudgett [Fri, 21 Aug 2015 23:01:59 +0000 (18:01 -0500)]
res_pjsip_pubsub.c: Set dlg_status code instead of sending SIP response.

We should not try to send a SIP response message because we may be
restoring a persistent subscription where we are not responding to a SIP
request.

Change-Id: Id89167ef90320c5563f37e632db0dda6cb9e7dec

4 years agores_pjsip_pubsub.c: Fix off-nominal memory leak.
Richard Mudgett [Fri, 21 Aug 2015 22:40:39 +0000 (17:40 -0500)]
res_pjsip_pubsub.c: Fix off-nominal memory leak.

Fix off-nominal visited vector leak in build_resource_tree().

Change-Id: If0399c7941c9c0b1038bcfb7b9a371760977831c

4 years agores_pjsip_pubsub.c: Fix one byte buffer overrun error.
Richard Mudgett [Fri, 21 Aug 2015 20:26:30 +0000 (15:26 -0500)]
res_pjsip_pubsub.c: Fix one byte buffer overrun error.

ast_sip_pubsub_register_body_generator() did not account for the null
terminator set by sprintf() in the allocated output buffer.

Change-Id: I388688a132e479bca6ad1c19275eae0070969ae2

4 years agores_pjsip_pubsub.c: Use ast_alloca() instead of alloca().
Richard Mudgett [Fri, 21 Aug 2015 20:25:11 +0000 (15:25 -0500)]
res_pjsip_pubsub.c: Use ast_alloca() instead of alloca().

Change-Id: Ia396096b4fedc2874649ca11137612c3f55e83e3

4 years agores_pjsip_pubsub.c: Add missing error return in load_module().
Richard Mudgett [Fri, 21 Aug 2015 16:04:08 +0000 (11:04 -0500)]
res_pjsip_pubsub.c: Add missing error return in load_module().

Change-Id: I15debd0f717f16ee2f78e7f56151c3b3b97b72fc

4 years agores_pjsip/location.c: Use the builtin ao2_callback() match function instead.
Richard Mudgett [Fri, 21 Aug 2015 16:03:02 +0000 (11:03 -0500)]
res_pjsip/location.c: Use the builtin ao2_callback() match function instead.

Change-Id: I364906d6d2bad3472929986704a0286b9a2cbe3f

4 years agores_pjsip: Copy default_from_user to avoid crash.
Mark Michelson [Thu, 10 Sep 2015 14:49:45 +0000 (09:49 -0500)]
res_pjsip: Copy default_from_user to avoid crash.

The default_from_user retrieval function was pulling the
default_from_user from the global configuration struct in an unsafe way.
If using a database as a backend configuration store, the global
configuration struct is short-lived, so grabbing a pointer from it
results in referencing freed memory.

The fix here is to copy the default_from_user value out of the global
configuration struct.

Thanks go to John Hardin for discovering this problem and proposing the
patch on which this fix is based.

ASTERISK-25390 #close
Reported by Mark Michelson

Change-Id: I6b96067a495c1259da768f4012d44e03e7c6148c

4 years agores/res_pjsip_nat: Ignore REGISTER requests when looking for a Record-Route
Matt Jordan [Thu, 10 Sep 2015 13:39:21 +0000 (08:39 -0500)]
res/res_pjsip_nat: Ignore REGISTER requests when looking for a Record-Route

We will only rewrite the Contact header if there is no Record-Route header in
the received request. If a malfunctioning proxy places a Record-Route header
into a REGISTER request, we will decide that we shouldn't update the IP/port
in the Contact header, and we will end up storing a contact with an AoR that
contains the NAT'd IP address.

While it is nice to have the proxy *not* send a Record-Route in a REGISTER
request, it's also a good idea to not process the header in a non-dialog
message. This patch updates the code to explicitly ignore the Record-Route
header in REGISTER requests.

ASTERISK-25387 #close

Change-Id: I4bd3bcccc4003d460cc354d986b0dea2e433ef3f

4 years agoMerge "ParkAndAnnounce: Add variable inheritance"
Joshua Colp [Thu, 10 Sep 2015 12:25:02 +0000 (07:25 -0500)]
Merge "ParkAndAnnounce: Add variable inheritance"

4 years agoMerge "chan_ooh323: Add ProgressIndicator IE with inband info available"
Matt Jordan [Thu, 10 Sep 2015 00:12:09 +0000 (19:12 -0500)]
Merge "chan_ooh323: Add ProgressIndicator IE with inband info available"

4 years agoMerge "pjsip: avoid possible crash req_caps allocation failure"
Joshua Colp [Wed, 9 Sep 2015 22:22:22 +0000 (17:22 -0500)]
Merge "pjsip: avoid possible crash req_caps allocation failure"

4 years agochan_ooh323: Add ProgressIndicator IE with inband info available
Alexander Anikin [Wed, 9 Sep 2015 21:46:44 +0000 (01:46 +0400)]
chan_ooh323: Add ProgressIndicator IE with inband info available

Add ProgressIndicator IE with inband info present to Progress and
Alerting Q.931 message

ASTERISK-25227 #close
Reported by: Alexandr Dranchuk

Change-Id: I326ad13cb1db9a72b3fd902bafed3c28a3684203

4 years agopjsip: avoid possible crash req_caps allocation failure
Scott Griepentrog [Tue, 8 Sep 2015 15:35:57 +0000 (10:35 -0500)]
pjsip: avoid possible crash req_caps allocation failure

Make certain that the pjsip session has not failed to
allocate the format capabilities structure, which can
otherwise cause a crash when referenced.

ASTERISK-25323

Change-Id: I602790ba12714741165e441cc64a3ecde4cb5750

4 years agoMerge "res_pjsip: Use hash for contact object identity instead of Contact URI."
Joshua Colp [Wed, 9 Sep 2015 10:53:02 +0000 (05:53 -0500)]
Merge "res_pjsip: Use hash for contact object identity instead of Contact URI."

4 years agoMerge "res_rtp_asterisk: Add more ICE debugging"
Matt Jordan [Tue, 8 Sep 2015 21:33:29 +0000 (16:33 -0500)]
Merge "res_rtp_asterisk: Add more ICE debugging"

4 years agoMerge "Core/General: Add #ifdef needed on FreeBSD."
Joshua Colp [Tue, 8 Sep 2015 21:11:00 +0000 (16:11 -0500)]
Merge "Core/General: Add #ifdef needed on FreeBSD."

4 years agores_rtp_asterisk: Add more ICE debugging
David M. Lee [Fri, 4 Sep 2015 21:33:39 +0000 (16:33 -0500)]
res_rtp_asterisk: Add more ICE debugging

In working through a recent ICE negotiation bug, I found the debug
logging in res_rtp_asterisk to be lacking. This patch adds a number of
debug and warning statements that were helpful.

Change-Id: I950c6d8f13a41f14b3d6334b4cafe7d4e997be80

4 years agoMerge "res/res_pjsip: Purge contacts when an AoR is deleted"
Joshua Colp [Tue, 8 Sep 2015 19:03:42 +0000 (14:03 -0500)]
Merge "res/res_pjsip: Purge contacts when an AoR is deleted"

4 years agores_pjsip: Use hash for contact object identity instead of Contact URI.
Joshua Colp [Tue, 8 Sep 2015 12:21:11 +0000 (09:21 -0300)]
res_pjsip: Use hash for contact object identity instead of Contact URI.

In the wild it is possible for Contact URIs to be quite long as
parameters can exist on them. This can present a problem when storing
them in the AstDB as the URI is used as part of the object name and
there is a fixed length limit for the AstDB. This will cause
the contact to not get stored.

This change uses the MD5 hash of the Contact URI as part of the
object name instead. This has a fixed length which is guaranteed
to not exceed the AstDB length limit.

ASTERISK-25295 #close

Change-Id: Ie8252a75331ca00b41b9f308f42cc1fbdf701a02

4 years agochan_ooh323: call ast_rtp_instance_stop on ooh323_destroy
Alexander Anikin [Mon, 7 Sep 2015 18:19:41 +0000 (22:19 +0400)]
chan_ooh323: call ast_rtp_instance_stop on ooh323_destroy

    Call ast_rtp_instance_stop on ooh323_destroy to free resources
    allocated by rtp instance

    ASTERISK-25299 #close
    Report by: Alexandr Dranchuk

Change-Id: I455096bd7da016b871afe90af86067c2c7c9f33f

4 years agores/res_pjsip: Purge contacts when an AoR is deleted
Matt Jordan [Mon, 7 Sep 2015 16:15:59 +0000 (11:15 -0500)]
res/res_pjsip: Purge contacts when an AoR is deleted

When an AoR is deleted by an external mechanism, such as through ARI, we
currently do not remove dynamic contacts that were created for that AoR as a
result of a received REGISTER request. As a result, re-creating the AoR will
cause the dynamic contact to be interpreted as a persistent contact, leading
to some rather strange state being created for the contacts/endpoints.

This patch adds a sorcery observer for the 'aor' object. When a delete is
issued on the underlying sorcery object, the observer is called, and all
contacts created and persisted in sorcery for that AoR are also removed. Note
that we don't want to perform this action when an AO2 object that is an AoR is
destroyed, as the AoR can still exist in the backing storage (and we would
thus be removing valid contacts from an AoR that still "exists".)

ASTERISK-25381 #close

Change-Id: I6697e51ef6b2858b5d63401f35dc378bb0f90328

4 years agoMerge "endpoint snapshot: avoid second cleanup on alloc failure"
Matt Jordan [Sat, 5 Sep 2015 23:48:26 +0000 (18:48 -0500)]
Merge "endpoint snapshot: avoid second cleanup on alloc failure"

4 years agoMerge "channels/pjsip/dialplan_functions: Add an option for extracting the SIP call-id"
Matt Jordan [Sat, 5 Sep 2015 23:43:50 +0000 (18:43 -0500)]
Merge "channels/pjsip/dialplan_functions: Add an option for extracting the SIP call-id"

4 years agoMerge "res_pjsip: Change default from user value."
Joshua Colp [Sat, 5 Sep 2015 20:56:58 +0000 (15:56 -0500)]
Merge "res_pjsip: Change default from user value."

4 years agoMerge "Fix when remote candidates exceed PJ_ICE_MAX_CAND"
Joshua Colp [Sat, 5 Sep 2015 20:42:37 +0000 (15:42 -0500)]
Merge "Fix when remote candidates exceed PJ_ICE_MAX_CAND"

4 years agochannels/pjsip/dialplan_functions: Add an option for extracting the SIP call-id
Matt Jordan [Sat, 5 Sep 2015 19:58:41 +0000 (14:58 -0500)]
channels/pjsip/dialplan_functions: Add an option for extracting the SIP call-id

This patch adds a new option to the CHANNEL function that allows for the
extraction of the SIP call-id. It is used in conjunction with the 'pjsip'
option, and will return the Call-ID of the INVITE request that established
the PJSIP channel.

ASTERISK-25352

Change-Id: I278d1f8bcfe3a53c5aa1dadebc14e92b0abd476a

4 years agoFix when remote candidates exceed PJ_ICE_MAX_CAND
David M. Lee [Fri, 4 Sep 2015 21:06:39 +0000 (16:06 -0500)]
Fix when remote candidates exceed PJ_ICE_MAX_CAND

We were passing the wrong count into pj_ice_sess_create_check_list(),
causing the create to fail if we ever received more than PJ_ICE_MAX_CAND
candidates.

Change-Id: I0303d8e1ecb20a8de9fe629a3209d216c4028378

4 years agores_pjsip: Change default from user value.
Mark Michelson [Fri, 4 Sep 2015 19:40:38 +0000 (14:40 -0500)]
res_pjsip: Change default from user value.

When Asterisk sends an outbound SIP request, if there is no direct
reason to place a specific value for the username in the From header,
Asterisk would generate a UUID. For example, this would happen when
sending outbound OPTIONS requests when qualifying or when sending
outbound INVITE requests when originating (if no explicit caller ID were
provided). The issue is that some SIP providers reject these sorts of
requests with a "Name too long" error response.

This patch aims to fix this by changing the default outbound username in
From headers to "asterisk". This value can be overridden by changing the
default_from_user option in the global options if desired.

ASTERISK-25377 #close
Reported by Mark Michelson

Change-Id: I6a4d34a56ff73ff4f661b0075aeba5461b7f3190

4 years agoParkAndAnnounce: Add variable inheritance
Jonathan Rose [Thu, 3 Sep 2015 19:07:35 +0000 (14:07 -0500)]
ParkAndAnnounce: Add variable inheritance

In Asterisk 11, the announcer channel would receive channel variables
from the channel being parked by means of normal channel inheritance.
This functionality was lost during the big res_parking project in
Asterisk 12. This patch restores that functionality.

ASTERISK-25369 #close
Review: https://gerrit.asterisk.org/#/c/1180/

Change-Id: Ie47e618330114ad2ea91e2edcef1cb6f341eed6e

4 years agoendpoint snapshot: avoid second cleanup on alloc failure
Scott Griepentrog [Fri, 4 Sep 2015 14:26:46 +0000 (09:26 -0500)]
endpoint snapshot: avoid second cleanup on alloc failure

In ast_endpoint_snapshot_create(), a failure to init the
string fields results in two attempts to ao2_cleanup the
same pointer.  Removed RAII_VAR to eliminate problem.

ASTERISK-25375 #close
Reported by: Scott Griepentrog

Change-Id: If4d9dfb1bbe3836b623642ec690b6d49b25e8979

4 years agores/pjsip: Mark WSS transport as secure
Martin Tomec [Fri, 4 Sep 2015 10:33:47 +0000 (12:33 +0200)]
res/pjsip: Mark WSS transport as secure

Pjsip is refusing to use unsecure transport with "sips" in url.
WSS should be considered as secure transport.

ASTERISK-24602 #comment Partially fixed by setting WSS as secure

Change-Id: Iddac406c6deba6240c41a603b8859dfefe1a5353

4 years agoCore/General: Add #ifdef needed on FreeBSD.
Guido Falsi [Tue, 1 Sep 2015 15:16:55 +0000 (17:16 +0200)]
Core/General: Add #ifdef needed on FreeBSD.

pthread_attr_init() defaults to PTHREAD_EXPLICIT_SCHED on FreeBSD
too.

ASTERISK-25310 #close
Reported by: Guido Falsi

Change-Id: Iae6befac9028b5b9795f86986a4a08a1ae6ab7c4

4 years agores_pjsip: Fix contact refleak on stateful responses.
Mark Michelson [Wed, 2 Sep 2015 22:26:14 +0000 (17:26 -0500)]
res_pjsip: Fix contact refleak on stateful responses.

When sending a stateful response, creation of the transaction can fail,
most commonly because we are trying to create a transaction from a
retransmitted request. When creation of the transaction fails, we end up
leaking a reference to a contact that was bumped when the response was
created.

This patch adds the missing deref and fixes the reference leak.

Change-Id: I2f97ad512aeb1b17e87ca29ae0abacb4d6395f07

4 years agopbx: Fix crash when issuing "core show hints" with long pattern match.
Joshua Colp [Wed, 2 Sep 2015 17:41:10 +0000 (14:41 -0300)]
pbx: Fix crash when issuing "core show hints" with long pattern match.

When issuing the "core show hints" CLI command a combination of both
the hint extension and context is created. This uses a fixed size
buffer expecting that the extension will not exceed maximum extension
length. When the extension is actually a pattern match this constraint
does not hold true, and the extension may exceed the maximum extension
length. In this case extra characters are written past the end of the
fixed size buffer.

This change makes it so the construction of the combined hint extension
and context can not exceed the size of the buffer.

ASTERISK-25367 #close

Change-Id: Idfa1b95d0d4dc38e675be7c1de8900b3f981f499

4 years agores_pjsip_pubsub: re-re-fix persistent subscription storage.
Mark Michelson [Tue, 1 Sep 2015 14:05:34 +0000 (09:05 -0500)]
res_pjsip_pubsub: re-re-fix persistent subscription storage.

A recent change to res_pjsip_pubsub switched to using pjsip_msg_print as
a means of writing an appropriate packet to persistent storage. While
this partially solved the issue, it had its own problems.
pjsip_msg_print will always add a Content-Length header to the message
it prints. Frequent restarts of Asterisk can result in persistent
subscriptions being written with five or more Content-Length headers. In
addition, sometimes some apparent corruption of individual headers could
be seen.

This aims to fix the problem by not running a parsed message through an
interpreter but rather by taking the raw message and saving it. The
logic for what to save is going to be different depending on whether a
SUBSCRIBE was received from the wire or if it was pulled from
persistence. When receiving a packet from the wire, when using a
streaming transport, the rdata->pkt_info.packet may contain multiple SIP
messages or fragments. However, the rdata->msg_info.msg_buf will always
contain the current SIP message to be processed. When pulling from
persistence, though, the rdata->msg_info.msg_buf will be NULL since no
transport actually handled the packet. However, since we know that we
will always ever pull one SIP message from persistence, we are free to
save directly from rdata->pkt_info.packet instead.

ASTERISK-25365 #close
Reported by Mark Michelson

Change-Id: I33153b10d0b4dc8e3801aaaee2f48173b867855b

4 years agoMerge "taskprocessor: Fix race condition between unreferencing and finding."
Matt Jordan [Sat, 29 Aug 2015 17:31:58 +0000 (12:31 -0500)]
Merge "taskprocessor: Fix race condition between unreferencing and finding."

4 years agoMerge "res_pjsip_sdp_rtp: Fix multiple keepalive scheduled items."
Matt Jordan [Sat, 29 Aug 2015 17:30:59 +0000 (12:30 -0500)]
Merge "res_pjsip_sdp_rtp: Fix multiple keepalive scheduled items."

4 years agotaskprocessor: Fix race condition between unreferencing and finding.
Joshua Colp [Sat, 29 Aug 2015 15:36:35 +0000 (12:36 -0300)]
taskprocessor: Fix race condition between unreferencing and finding.

When unreferencing a taskprocessor its reference count is checked
to determine if it should be unlinked from the taskprocessors
container and its listener shut down. In between the time when the
reference count is checked and unlinking it is possible for
another thread to jump in, find it, and get a reference to it. If
the thread then uses the taskprocessor it may find that it is not
in the state it expects.

This change locks the taskprocessors container during almost the
entire unreference operation to ensure that any other thread which
may attempt to find the taskprocessor has to wait.

ASTERISK-25295

Change-Id: Icb842db82fe1cf238da55df92e95938a4419377c

4 years agores_pjsip_sdp_rtp: Fix multiple keepalive scheduled items.
Joshua Colp [Sat, 29 Aug 2015 01:22:45 +0000 (22:22 -0300)]
res_pjsip_sdp_rtp: Fix multiple keepalive scheduled items.

The keepalive support in res_pjsip_sdp_rtp currently assumes
that a stream will only be negotiated once. This is false.
If the stream is replaced and later added back it can be
negotiated again causing multiple keepalive scheduled items
to exist. This change explicitly deletes the existing
keepalive scheduled item before adding the new one.

The res_pjsip_sdp_rtp module also does not stop RTP
keepalives or timeout timer if the stream has been
replaced. This change adds a callback to the session media
interface to allow a media stream to be stopped without
the resources being destroyed. This allows the scheduled
items and RTP to be stopped when the stream no longer
exists.

ASTERISK-25356 #close

Change-Id: Ibe6a7cc0927c87326fd5f1c0d4ad889dbfbea1de

4 years agosched: ast_sched_del may return prematurely due to spurious wakeup
Joshua Colp [Sat, 29 Aug 2015 00:57:14 +0000 (21:57 -0300)]
sched: ast_sched_del may return prematurely due to spurious wakeup

When deleting a scheduled item if the item in question is currently
executing the ast_sched_del function waits until it has completed.
This is accomplished using ast_cond_wait. Unfortunately the
ast_cond_wait function can suffer from spurious wakeups so the
predicate needs to be checked after it returns to make sure it has
really woken up as a result of being signaled.

This change adds a loop around the ast_cond_wait to make sure that
it only exits when the executing task has really completed.

ASTERISK-25355 #close

Change-Id: I51198270eb0b637c956c61aa409f46283432be61

4 years agores_pjsip_session: Don't invoke session supplements twice for BYE requests.
Joshua Colp [Thu, 27 Aug 2015 17:26:09 +0000 (14:26 -0300)]
res_pjsip_session: Don't invoke session supplements twice for BYE requests.

When a BYE request is received the PJSIP invite session implementation
creates and sends a 200 OK response before we are aware of it. This
causes the INVITE session state callback to be called into and ultimately
the session supplements run on the BYE request. Once this response has
been sent the normal transaction state callback is invoked which
invokes the session supplements on the BYE request again. This can
be problematic in particular with res_pjsip_rfc3326 as it may
attempt to update the hangup cause code on the channel while it is
in the process of being hung up.

This change makes it so the session supplements are only invoked
once by the INVITE session state callback.

ASTERISK-25318 #close

Change-Id: I69c17df55ccbb61ef779ac38cc8c6b411376c19a

4 years agoMerge "res_pjsip: Add common ast_sip_get_host_ip API."
Joshua Colp [Thu, 27 Aug 2015 20:41:54 +0000 (15:41 -0500)]
Merge "res_pjsip: Add common ast_sip_get_host_ip API."

4 years agoMerge "Chaos: make hangup NULL tolerant"
Mark Michelson [Thu, 27 Aug 2015 19:53:45 +0000 (14:53 -0500)]
Merge "Chaos: make hangup NULL tolerant"

4 years agoChaos: handle failed allocation in get_media_encryption_type
Scott Griepentrog [Wed, 26 Aug 2015 20:26:00 +0000 (15:26 -0500)]
Chaos: handle failed allocation in get_media_encryption_type

If the ast_strndup() call fails to allocate a copy of the
transport string for parsing, fail gracefully.

ASTERISK-25323
Reported by: Scott Griepentrog

Change-Id: Ia4b905ce6d03da53fea526224455c1044b1a5a28

4 years agoChaos: make hangup NULL tolerant
Scott Griepentrog [Wed, 26 Aug 2015 19:25:42 +0000 (14:25 -0500)]
Chaos: make hangup NULL tolerant

In chan_pjsip_new, if allocation of the pvt
structure fails, ast_hangup is called.  But
it was written to assume pvt was valid, and
this change corrects that.

ASTERISK-25323
Reported by: Scott Griepentrog

Change-Id: I5f47860fe9cee4cd56abd3f79b108678ab72cc87

4 years agochan_sip: Allow call pickup to set the hangup cause.
Joshua Colp [Wed, 26 Aug 2015 10:40:32 +0000 (07:40 -0300)]
chan_sip: Allow call pickup to set the hangup cause.

The call pickup implementation in chan_sip currently sets the channel
hangup cause to "normal clearing" if call pickup is successfully
performed. This action overwrites the "answered elsewhere" hangup cause
set by the call pickup code and can result in the SIP device in
question showing a missed call when it should not.

This change sets the hangup cause to "normal clearing" as a
default initially but allows the call pickup to change it as
needed.

ASTERISK-25346 #close

Change-Id: I00ac2c269cee9e29586ee2c65e83c70e52a02cff

4 years agores_pjsip: Add common ast_sip_get_host_ip API.
Joshua Colp [Tue, 25 Aug 2015 12:17:34 +0000 (09:17 -0300)]
res_pjsip: Add common ast_sip_get_host_ip API.

Modules commonly used the pj_gethostip function for retrieving the
IP address of the host. This function does not cache the result and may
result in a DNS lookup occurring, or additional work. If the DNS
server is unreachable or network issues arise this can cause the
pj_gethostip function to block for a period of time.

This change adds an ast_sip_get_host_ip and ast_sip_get_host_ip_string
function which does the same thing but caches the host IP address at
module load time. This results in no additional work being done each
time the local host IP address is needed.

ASTERISK-25342 #close

Change-Id: I3205deb679b01fa5ac05a94b623bfd620a2abe1e

4 years agoMerge "res_pjsip_pubsub: On recreated notify fail deleted sub_tree is referenced"
Mark Michelson [Mon, 24 Aug 2015 22:16:48 +0000 (17:16 -0500)]
Merge "res_pjsip_pubsub: On recreated notify fail deleted sub_tree is referenced"

4 years agoMerge "bridge: Kick channel from bridge if hung up during action."
Mark Michelson [Mon, 24 Aug 2015 22:12:06 +0000 (17:12 -0500)]
Merge "bridge: Kick channel from bridge if hung up during action."

4 years agoMerge "res_pjsip/pjsip_configuration: Disregard empty auth values"
Joshua Colp [Mon, 24 Aug 2015 18:59:32 +0000 (13:59 -0500)]
Merge "res_pjsip/pjsip_configuration: Disregard empty auth values"

4 years agobridge: Kick channel from bridge if hung up during action.
Joshua Colp [Mon, 24 Aug 2015 11:21:37 +0000 (08:21 -0300)]
bridge: Kick channel from bridge if hung up during action.

When executing an action in a bridge it is possible for the
channel to be hung up without the bridge becoming aware of it.
This is most easily reproducible by hanging up when the bridge
is streaming DTMF due to a feature timeout. This change makes
it so after action execution the channel is checked to determine
if it has been hung up and if it has it is kicked from the bridge.

ASTERISK-25341 #close

Change-Id: I6dd8b0c3f5888da1c57afed9e8a802ae0a053062

4 years agores_pjsip_pubsub: On recreated notify fail deleted sub_tree is referenced
Joshua Colp [Mon, 24 Aug 2015 16:04:57 +0000 (13:04 -0300)]
res_pjsip_pubsub: On recreated notify fail deleted sub_tree is referenced

When recreating a subscription it is possible for a freed sub_tree
to be referenced when the initial NOTIFY fails to be created.

Change-Id: I681c215309aad01b21d611c2de47b3b0a6022788

4 years agores_pjsip/pjsip_configuration: Disregard empty auth values
Matt Jordan [Sun, 23 Aug 2015 23:26:50 +0000 (18:26 -0500)]
res_pjsip/pjsip_configuration: Disregard empty auth values

When an endpoint is backed by a non-static conf file backend (such as
the AstDB or Realtime), the 'auth' object may be returned as being an
empty string. Currently, res_pjsip will interpret that as being a valid
auth object, and will attempt to authenticate inbound requests. This
isn't desired; is an auth value is empty (which the name of an auth
object cannot be), we should instead interpret that as being an invalid
auth object and skip it.

ASTERISK-25339 #close

Change-Id: Ic32b0c6eb5575107d5164a8c40099e687cd722c7

4 years agoREADME*: Remove trailing whitespace
Rodrigo Ramírez Norambuena [Sat, 22 Aug 2015 04:37:23 +0000 (00:37 -0400)]
README*: Remove trailing whitespace

Change-Id: I18b7d75187548a9ed55b4f258d21aaaf29d08874

4 years agochan_sip.c: Set preferred rx payload type mapping on incoming offers.
Richard Mudgett [Tue, 28 Jul 2015 18:47:31 +0000 (13:47 -0500)]
chan_sip.c: Set preferred rx payload type mapping on incoming offers.

ASTERISK-25166
Reported by: Kevin Harwell

ASTERISK-17410
Reported by: Boris Fox

Change-Id: I7f04d5c8bee1126fee5fe6afbc39e45104469f4e

4 years agores_pjsip_sdp_rtp.c: Set preferred rx payload type mapping on incoming offers.
Richard Mudgett [Fri, 24 Jul 2015 23:46:09 +0000 (18:46 -0500)]
res_pjsip_sdp_rtp.c: Set preferred rx payload type mapping on incoming offers.

ASTERISK-25166
Reported by: Kevin Harwell

ASTERISK-17410
Reported by: Boris Fox

Change-Id: I97ecebc1ab9b5654fb918bf1f4c98c956b852369

4 years agortp_engine.c: Get current or create a needed rx payload type mapping.
Richard Mudgett [Tue, 28 Jul 2015 00:19:25 +0000 (19:19 -0500)]
rtp_engine.c: Get current or create a needed rx payload type mapping.

* Make ast_rtp_codecs_payload_code() get the current mapping or create a
rx payload type mapping.

ASTERISK-25166
Reported by: Kevin Harwell

ASTERISK-17410
Reported by: Boris Fox

Change-Id: Ia4b2d45877a8f004f6ce3840e3d8afe533384e56

4 years agortp_engine.c: Extract rtp_codecs_payload_replace_rx().
Richard Mudgett [Tue, 28 Jul 2015 00:15:07 +0000 (19:15 -0500)]
rtp_engine.c: Extract rtp_codecs_payload_replace_rx().

ASTERISK-25166
Reported by: Kevin Harwell

ASTERISK-17410
Reported by: Boris Fox

Change-Id: I34e23bf5b084c8570f9c3e6ccd19b95fe85af239

4 years agortp_engine.c: Initial split of payload types into rx and tx mappings.
Richard Mudgett [Fri, 24 Jul 2015 00:24:04 +0000 (19:24 -0500)]
rtp_engine.c: Initial split of payload types into rx and tx mappings.

There are numerous problems with the current implementation of the RTP
payload type mapping in Asterisk.  It uses only one mapping structure to
associate payload types to codecs.  The single mapping is overkill if all
of the payload type values are well known values.  Dynamic payload type
mappings do not work as well with the single mapping because RFC3264
allows each side of the link to negotiate different dynamic mappings for
what they want to receive.  Not only could you have the same codec mapped
for sending and receiving on different payload types you could wind up
with the same payload type mapped to different codecs for each direction.

1) An independent payload type mapping is needed for sending and
receiving.

2) The receive mapping needs to keep track of previous mappings because of
the slack to when negotiation happens and current packets in flight using
the old mapping arrive.

3) The transmit mapping only needs to keep track of the current negotiated
values since we are sending the packets and know when the switchover takes
place.

* Needed to create ast_rtp_codecs_payload_code_tx() and make some callers
use the new function because ast_rtp_codecs_payload_code() was used for
mappings in both directions.

* Needed to create ast_rtp_codecs_payloads_xover() for cases where we need
to pass preferred codec mappings to the peer channel for early media
bridging or when we need to prefer the offered mapping that RFC3264 says
we SHOULD use.

* ast_rtp_codecs_payloads_xover() and ast_rtp_codecs_payload_code_tx() are
the only new public functions created.  All the others were only used for
the tx or rx mapping direction so the function doxygen now reflects which
direction the function operates.

* chan_mgcp.c: Removed call to ast_rtp_codecs_payloads_clear() as doing
that makes no sense when processing an incoming SDP.  We would be wiping
out any mappings that we set for the possible outgoing SDP we sent
earlier.

ASTERISK-25166
Reported by: Kevin Harwell

ASTERISK-17410
Reported by: Boris Fox

Change-Id: Iaf6c227bca68cb7c414cf2fd4108a8ac98bd45ac

4 years agoMerge "res_ari_events: Fix shutdown ref leak."
Mark Michelson [Wed, 19 Aug 2015 22:06:51 +0000 (17:06 -0500)]
Merge "res_ari_events: Fix shutdown ref leak."

4 years agoMerge "app_queue.c: Extract some functions for simpler code."
Mark Michelson [Wed, 19 Aug 2015 22:03:35 +0000 (17:03 -0500)]
Merge "app_queue.c: Extract some functions for simpler code."

4 years agoMerge "res_http_websocket.c: Add missing unref on an off nominal path."
Mark Michelson [Wed, 19 Aug 2015 21:56:35 +0000 (16:56 -0500)]
Merge "res_http_websocket.c: Add missing unref on an off nominal path."

4 years agoMerge "ari/ari_websockets.c: Fix ast_debug parameter type mismatch."
Mark Michelson [Wed, 19 Aug 2015 21:55:48 +0000 (16:55 -0500)]
Merge "ari/ari_websockets.c: Fix ast_debug parameter type mismatch."

4 years agoari/ari_websockets.c: Fix ast_debug parameter type mismatch.
Richard Mudgett [Wed, 19 Aug 2015 17:10:12 +0000 (12:10 -0500)]
ari/ari_websockets.c: Fix ast_debug parameter type mismatch.

This is a type mismatch fix of the debugging commit
c63316eec10e1990a88bf4712238d6deb375bfa9 made to find out why
a testsuite test was failing only on one of the continuous
integration build agents.

Change-Id: Iba34f6e87cec331f6ac80e4daff6476ea6f00a75

4 years agocontrib: script install_prereq should install sqlite3
Scott Griepentrog [Wed, 19 Aug 2015 15:30:12 +0000 (10:30 -0500)]
contrib: script install_prereq should install sqlite3

Asterisk needs the sqlite 3 library, which is package
sqlite-devel in CentOS. By adding this package to the
script, a problem with configure failing is resolved.

ASTERISK-25331 #close
Reported by: Kevin Harwell

Change-Id: I90efaf6a01914fea03f21e5cdbd91c348f44b0ec

4 years agoMerge "res_http_websocket.c: Fix some off nominal path cleanup."
Matt Jordan [Wed, 19 Aug 2015 13:42:56 +0000 (08:42 -0500)]
Merge "res_http_websocket.c: Fix some off nominal path cleanup."

4 years agoMerge "app_queue.c: Fix setting QUEUE_MEMBER 'paused' and 'ringinuse'."
Matt Jordan [Wed, 19 Aug 2015 13:40:39 +0000 (08:40 -0500)]
Merge "app_queue.c: Fix setting QUEUE_MEMBER 'paused' and 'ringinuse'."

4 years agores_ari_events: Fix shutdown ref leak.
Richard Mudgett [Tue, 18 Aug 2015 20:07:49 +0000 (15:07 -0500)]
res_ari_events: Fix shutdown ref leak.

ASTERISK-25308 #close
Reported by: Joshua Colp

Change-Id: I592785bf70ff4b63d00e535b482f40da8e82a082

4 years agores_http_websocket.c: Add missing unref on an off nominal path.
Richard Mudgett [Tue, 18 Aug 2015 19:24:17 +0000 (14:24 -0500)]
res_http_websocket.c: Add missing unref on an off nominal path.

Change-Id: I228df6adecd4cb450d03e09e9a38c86bb566e811

4 years agores_http_websocket.c: Fix some off nominal path cleanup.
Richard Mudgett [Tue, 18 Aug 2015 21:06:54 +0000 (16:06 -0500)]
res_http_websocket.c: Fix some off nominal path cleanup.

* Remove extraneous unlock on off-nominal path.
* Add missing HTTP error reply.

Change-Id: I1f402bfe448fba8696b507477cab5f060ccd9b2b

4 years agores_ari.c: Add missing off nominal unlock and remove a RAII_VAR().
Richard Mudgett [Tue, 18 Aug 2015 19:46:46 +0000 (14:46 -0500)]
res_ari.c: Add missing off nominal unlock and remove a RAII_VAR().

Change-Id: I0c5e7b34057f26dadb39489c4dac3015c52f5dbf

4 years agoapp_queue.c: Fix setting QUEUE_MEMBER 'paused' and 'ringinuse'.
Richard Mudgett [Fri, 14 Aug 2015 17:55:28 +0000 (12:55 -0500)]
app_queue.c: Fix setting QUEUE_MEMBER 'paused' and 'ringinuse'.

Setting the 'paused' and 'ringinuse' options on a queue member using the
dialplan function QUEUE_MEMBER did not behave the same way as the
equivalent dialplan applications or AMI actions.

* Made queue_function_mem_write() call the set_member_paused() and
set_member_value() for the 'paused' and 'ringinuse' options respectively.
A beneficial side effect is that the queue name is now optional and sets
the value in all queues the interface is a member.

* Update QUEUE_MEMBER XML documentation.

* Fix error checking in QUEUE_MEMBER() write.

ASTERISK-25215 #close
Reported by: Lorne Gaetz

Change-Id: I3a016be8dc94d63a9cc155295ff9c9afa5f707cb

4 years agoapp_queue.c: Extract some functions for simpler code.
Richard Mudgett [Mon, 17 Aug 2015 21:41:19 +0000 (16:41 -0500)]
app_queue.c: Extract some functions for simpler code.

* Extract set_queue_member_pause() from set_member_paused() for simpler
and more consistent code.

* Extract set_queue_member_ringinuse() from
set_member_ringinuse_help_members() for simpler code.

Change-Id: Iecc1f4119c63347341d7ea6b65f5fc4963706306

4 years agoapp_queue.c: Fix error checking in QUEUE_MEMBER() read.
Richard Mudgett [Mon, 17 Aug 2015 18:34:15 +0000 (13:34 -0500)]
app_queue.c: Fix error checking in QUEUE_MEMBER() read.

Change-Id: I7294e13d27875851c2f4ef6818adba507509d224

4 years agoCHAOS: prevent sorcery object with null id
Scott Griepentrog [Mon, 17 Aug 2015 16:00:53 +0000 (11:00 -0500)]
CHAOS: prevent sorcery object with null id

When allocating a sorcery object, fail if the
id value was not allocated.

ASTERISK-25323
Reported by: Scott Griepentrog

Change-Id: I152133fb7545a4efcf7a0080ada77332d038669e