4 years agopjsip: Add option global/regcontext
Daniel Journo [Sun, 10 Jan 2016 22:22:12 +0000 (22:22 +0000)]
pjsip:  Add option global/regcontext

Added new global option (regcontext) to pjsip. When set, Asterisk will
dynamically create and destroy a NoOp priority 1 extension
for a given endpoint who registers or unregisters with us.

ASTERISK-25670 #close
Reported-by: Daniel Journo

Change-Id: Ib1530c5b45340625805c057f8ff1fb240a43ea62

4 years agoMerge "res_pjsip_log_forwarder.c: Add CLI "pjsip show buildopts"."
Mark Michelson [Wed, 13 Jan 2016 15:48:57 +0000 (09:48 -0600)]
Merge "res_pjsip_log_forwarder.c: Add CLI "pjsip show buildopts"."

4 years agores_musiconhold: Prevent multiple simultaneous reloads.
Sean Bright [Wed, 13 Jan 2016 13:20:24 +0000 (08:20 -0500)]
res_musiconhold: Prevent multiple simultaneous reloads.

There are two ways in which the reload() function in res_musiconhold can be
called from the CLI:

  * module reload
  * moh reload

In the former case, the module loader holds a lock that prevents multiple
concurrent calls, but in the latter there is no such protection.

This patch changes the 'moh reload' CLI command to invoke the module loader
directly, rather than call reload() explicitly.

ASTERISK-25687 #close

Change-Id: I408968b4c8932864411b7f9ad88cfdc7b9ba711c

4 years agores_pjsip_log_forwarder.c: Add CLI "pjsip show buildopts".
Richard Mudgett [Tue, 12 Jan 2016 20:25:09 +0000 (14:25 -0600)]
res_pjsip_log_forwarder.c: Add CLI "pjsip show buildopts".

PJPROJECT has a function available to dump the compile time
options used when building the library.

* Add CLI "pjsip show buildopts" command.

* Update contrib/scripts/autosupport to get pjproject information.

Change-Id: Id93a6a916d765b2a2e5a1aeb54caaf83206be748

4 years agoMerge "pjsip_sdp_rtp: Add option endpoint/bind_rtp_to_media_address"
Joshua Colp [Wed, 13 Jan 2016 01:45:27 +0000 (19:45 -0600)]
Merge "pjsip_sdp_rtp:  Add option endpoint/bind_rtp_to_media_address"

4 years agoMerge "res_pjsip: Create human friendly serializer names."
Joshua Colp [Tue, 12 Jan 2016 19:59:48 +0000 (13:59 -0600)]
Merge "res_pjsip: Create human friendly serializer names."

4 years agoMerge "res_sorcery_realtime: Remove leading ^ requirement."
Joshua Colp [Tue, 12 Jan 2016 19:59:26 +0000 (13:59 -0600)]
Merge "res_sorcery_realtime: Remove leading ^ requirement."

4 years agoMerge topic 'update_taskprocessor_commands'
Joshua Colp [Tue, 12 Jan 2016 19:25:48 +0000 (13:25 -0600)]
Merge topic 'update_taskprocessor_commands'

* changes:
  Sorcery: Create human friendly serializer names.
  Stasis: Create human friendly taskprocessor/serializer names.
  taskprocessor.c: New API for human friendly taskprocessor names.
  taskprocessor.c: Sort CLI "core show taskprocessors" output.

4 years agoMerge "taskprocessor.c: Fix CLI "core show taskprocessors" output format."
Joshua Colp [Tue, 12 Jan 2016 19:18:58 +0000 (13:18 -0600)]
Merge "taskprocessor.c: Fix CLI "core show taskprocessors" output format."

4 years agoMerge topic 'update_taskprocessor_commands'
Joshua Colp [Tue, 12 Jan 2016 19:18:35 +0000 (13:18 -0600)]
Merge topic 'update_taskprocessor_commands'

* changes:
  taskprocessor.c: Fix CLI "core show taskprocessors" unref.
  taskprocessor.c: Add CLI "core ping taskprocessor" missing unlock.

4 years agoMerge "ccss.c: Replace space in taskprocessor name."
Joshua Colp [Tue, 12 Jan 2016 19:17:54 +0000 (13:17 -0600)]
Merge "ccss.c: Replace space in taskprocessor name."

4 years agores_sorcery_realtime: Remove leading ^ requirement.
Mark Michelson [Tue, 12 Jan 2016 16:36:15 +0000 (10:36 -0600)]
res_sorcery_realtime: Remove leading ^ requirement.

res_sorcery_realtime's search-by-regex callback performed a check to
ensure that the passed-in regex began with a caret (^). If it did not,
then no results would be returned.

This callback only started to become used when "like" support was added
to PJSIP CLI commands. The CLI command for listing objects would pass an
empty regex ("") to the sorcery backend if no "like" statement was
present. For most sorcery backends, this resulted in returning all
objects. However, for realtime, this resulted in returning no objects.

This commit seeks to fix the regression by removing the requirement from
res_sorcery_realtime for the passed-in-regex to begin with a caret.

ASTERISK-25689 #close
Reported by Marcelo Terres

Change-Id: I22b4dc5d7f3f11bb29ac2e42ef94682e9bab3b20

4 years agoMerge "app_queue: Add member flag "in_call" to prevent reading wrong lastcall time"
Joshua Colp [Tue, 12 Jan 2016 12:05:30 +0000 (06:05 -0600)]
Merge "app_queue: Add member flag "in_call" to prevent reading wrong lastcall time"

4 years agopjsip_sdp_rtp: Add option endpoint/bind_rtp_to_media_address
George Joseph [Thu, 7 Jan 2016 17:57:01 +0000 (10:57 -0700)]
pjsip_sdp_rtp:  Add option endpoint/bind_rtp_to_media_address

On a system with multiple ip addresses in the same subnet, if a
transport is bound to a specific ip address and endpoint/media_address
 is set, the SIP/SDP will have the correct address in all fields but
the rtp stream MAY still originate from one of the other ip addresses,
most probably the "primary" ip address.  This happens because
 res_pjsip_sdp_rtp/create_rtp always calls ast_instance_new with
the "all" ip address ( or ::).

The new option causes res_pjsip_sdp_rtp/create_rtp to call
ast_rtp_instance_new with the endpoint's media_address (if specified)
instead of the "all" address.  This causes the packets to originate from
the specified address.

Reported-by: Olivier Krief
Reported-by: Dan Journo

Change-Id: I3dfaa079e54ba7fb7c4fd1f5f7bd9509bbf8bd88

4 years agoMerge "Revert "pjsip_location: Delete contact_status object when contact is deleted""
Mark Michelson [Mon, 11 Jan 2016 23:43:39 +0000 (17:43 -0600)]
Merge "Revert "pjsip_location: Delete contact_status object when contact is deleted""

4 years agoMerge "pbx: Deadlock between contexts container and context_merge locks"
Joshua Colp [Mon, 11 Jan 2016 23:37:18 +0000 (17:37 -0600)]
Merge "pbx: Deadlock between contexts container and context_merge locks"

4 years agoMerge "Alembic: Increase column size of PJSIP AOR "contact"."
Joshua Colp [Mon, 11 Jan 2016 22:59:10 +0000 (16:59 -0600)]
Merge "Alembic: Increase column size of PJSIP AOR "contact"."

4 years agoMerge "Alembic: Add PJSIP global keep_alive_interval."
Joshua Colp [Mon, 11 Jan 2016 22:59:04 +0000 (16:59 -0600)]
Merge "Alembic: Add PJSIP global keep_alive_interval."

4 years agoMerge "pbx_dundi: Run cleanup on failed load."
Joshua Colp [Mon, 11 Jan 2016 22:54:56 +0000 (16:54 -0600)]
Merge "pbx_dundi: Run cleanup on failed load."

4 years agoMerge "res_crypto: Perform cleanup at shutdown."
Joshua Colp [Mon, 11 Jan 2016 22:35:03 +0000 (16:35 -0600)]
Merge "res_crypto: Perform cleanup at shutdown."

4 years agoMerge "res_calendar: Cleanup scheduler context at unload."
Joshua Colp [Mon, 11 Jan 2016 20:35:50 +0000 (14:35 -0600)]
Merge "res_calendar: Cleanup scheduler context at unload."

4 years agoMerge "manager: Cleanup manager_channelvars during shutdown."
Joshua Colp [Mon, 11 Jan 2016 20:35:13 +0000 (14:35 -0600)]
Merge "manager: Cleanup manager_channelvars during shutdown."

4 years agoMerge "devicestate: Cleanup engine thread during graceful shutdown."
Joshua Colp [Mon, 11 Jan 2016 20:34:55 +0000 (14:34 -0600)]
Merge "devicestate: Cleanup engine thread during graceful shutdown."

4 years agopbx: Deadlock between contexts container and context_merge locks
Kevin Harwell [Fri, 8 Jan 2016 22:59:44 +0000 (16:59 -0600)]
pbx: Deadlock between contexts container and context_merge locks

Recent changes (ASTERISK-25394 commit 2bd27d12223fe33b58c453965ed5c6ed3af7c4f5)
introduced the possibility of a deadlock. Due to the mentioned modifications
ast_change_hints now needs to keep both merge/delete and state callbacks from
occurring while it executes. Unfortunately, sometimes ast_change_hints can be
called with the contexts container locked. When this happens it's possible for
another thread to grab the context_merge_lock before the thread calling into
ast_change_hints does and then try to obtain the contexts container lock. This
of course causes a deadlock between the two threads. The thread calling into
ast_change_hints waits for the other thread to release context_merge_lock and
the other thread is waiting on that one to release the contexts container lock.

Unfortunately, there is not a great way to fix this problem. When hints change,
the subsequent state callbacks cannot run at the same time as a merge/delete,
nor when the usual state callbacks do. This patch alleviates the problem by
having those particular callbacks (the ones run after a hint change) occur in a
serialized task. By moving the context_merge_lock to a task it can now safely be
attempted or held without a deadlock occurring.

ASTERISK-25640 #close
Reported by: Krzysztof Trempala

Change-Id: If2210ea241afd1585dc2594c16faff84579bf302

4 years agodevicestate: Cleanup engine thread during graceful shutdown.
Corey Farrell [Sun, 10 Jan 2016 23:08:16 +0000 (18:08 -0500)]
devicestate: Cleanup engine thread during graceful shutdown.

ASTERISK-25681 #close

Change-Id: I64337c70f0ebd8c77f70792042684607c950c8f1

4 years agomanager: Cleanup manager_channelvars during shutdown.
Corey Farrell [Sun, 10 Jan 2016 19:51:00 +0000 (14:51 -0500)]
manager: Cleanup manager_channelvars during shutdown.

ASTERISK-25680 #close

Change-Id: I3251d781cbc3f48a6a7e1b969ac4983f552b2446

4 years agores_calendar: Cleanup scheduler context at unload.
Corey Farrell [Sun, 10 Jan 2016 19:27:57 +0000 (14:27 -0500)]
res_calendar: Cleanup scheduler context at unload.

ASTERISK-25679 #close

Change-Id: I839159bf6882cccc1b23494c7aa2bc2a2624613f

4 years agores_rtp_asterisk: Revert DTLS negotiation changes.
Joshua Colp [Fri, 8 Jan 2016 17:49:02 +0000 (13:49 -0400)]
res_rtp_asterisk: Revert DTLS negotiation changes.

Due to locking issues within pjnath these changes are being
reverted until pjnath can be changed.


Revert "res_rtp_asterisk.c: Fix DTLS negotiation delays."

This reverts commit 24ae124e4f7310cfa64c187b944b2ffc060da28d.

Change-Id: I2986cfb2c43dc14455c1bcaf92c3804f9da49705

Revert "res_rtp_asterisk: Resolve further timing issues with DTLS negotiation"

This reverts commit 965a0eee46d24321f74c244e23c5a5f45e67e12b.

Change-Id: Ie68fafde27dad4b03cb7a1e27ce2a8502c3f7bbe

4 years agoRevert "pjsip_location: Delete contact_status object when contact is deleted"
George Joseph [Sat, 9 Jan 2016 23:57:45 +0000 (16:57 -0700)]
Revert "pjsip_location: Delete contact_status object when contact is deleted"

This reverts commit 0a9941de9d24093b5ff44096d1d7406f29d11e45.


This patch causes another problem and should not have been needed.
Before this patch, persistent_endpoint_contact_deleted_observer WAS
deleting the contact_status when ast_sip_location_delete_contact was
called.  By deleting it yourself in ast_sip_location_delete_contact
it was gone before the observer could run and the observer therefore
was throwing an error and not sending stasis/AMI/statsd messages.

So, I don't think this was the cause of your original issue.  I also
had verified the contact AMI and statsd lifecycle and it was working.
I'll double check now though.

Reported-by: Daniel Journo

Change-Id: Ib586a6b7f90acb641b0c410f659743ab90e84f1a

4 years agopbx_dundi: Run cleanup on failed load.
Corey Farrell [Sun, 10 Jan 2016 00:04:34 +0000 (19:04 -0500)]
pbx_dundi: Run cleanup on failed load.

During failed startup of pbx_dundi no cleanup was performed.  Add a call
to unload_module before returning AST_MODULE_LOAD_DECLINE.

ASTERISK-25677 #close

Change-Id: I8ffa226fda4365ee7068ac1f464473f1a4ebbb29

4 years agores_crypto: Perform cleanup at shutdown.
Corey Farrell [Sat, 9 Jan 2016 19:28:31 +0000 (14:28 -0500)]
res_crypto: Perform cleanup at shutdown.

This change causes res_crypto to unregister CLI at shutdown while still
preventing the module from being unloaded.

ASTERISK-25673 #close

Change-Id: Ie5d57338dc2752abfc0dd05d0eec86413f2304fc

4 years agoMerge "include/asterisk/time.h: Renamed global declaration:tv"
Joshua Colp [Sat, 9 Jan 2016 17:15:22 +0000 (11:15 -0600)]
Merge "include/asterisk/time.h: Renamed global declaration:tv"

4 years agores_pjsip: Create human friendly serializer names.
Richard Mudgett [Thu, 7 Jan 2016 01:10:16 +0000 (19:10 -0600)]
res_pjsip: Create human friendly serializer names.

PJSIP name formats:
pjsip/aor/<aor>-<seq> -- registrar thread pool serializer
pjsip/default-<seq> -- default thread pool serializer
pjsip/messaging -- messaging thread pool serializer
pjsip/outreg/<registration>-<seq> -- outbound registration thread pool
pjsip/pubsub/<endpoint>-<seq> -- pubsub thread pool serializer
pjsip/refer/<endpoint>-<seq> -- REFER thread pool serializer
pjsip/session/<endpoint>-<seq> -- session thread pool serializer
pjsip/websocket-<seq> -- websocket thread pool serializer

Change-Id: Iff9df8da3ddae1132cb2ef65f64df0c465c5e084

4 years agoSorcery: Create human friendly serializer names.
Richard Mudgett [Thu, 7 Jan 2016 01:09:43 +0000 (19:09 -0600)]
Sorcery: Create human friendly serializer names.

Sorcery name formats:
sorcery/<type>-<seq> -- Sorcery thread pool serializer

Change-Id: Idc2e5d3dbab15c825b97c38c028319a0d2315c47

4 years agoStasis: Create human friendly taskprocessor/serializer names.
Richard Mudgett [Thu, 7 Jan 2016 01:09:59 +0000 (19:09 -0600)]
Stasis: Create human friendly taskprocessor/serializer names.

Stasis name formats:
subm:<topic>-<seq> -- Stasis subscription mailbox task processor
subp:<topic>-<seq> -- Stasis subscription thread pool serializer

Change-Id: Id19234b306e3594530bb040bc95d977f18ac7bfd

4 years agotaskprocessor.c: New API for human friendly taskprocessor names.
Richard Mudgett [Thu, 7 Jan 2016 22:15:35 +0000 (16:15 -0600)]
taskprocessor.c: New API for human friendly taskprocessor names.

* Add new API call to get a sequence number for use in human friendly
taskprocessor names.

* Add new API call to create a taskprocessor name in a given buffer and
append a sequence number.

Change-Id: Iac458f05b45232315ed64aa31b1df05b875537a9

4 years agotaskprocessor.c: Fix CLI "core show taskprocessors" output format.
Richard Mudgett [Wed, 6 Jan 2016 23:19:19 +0000 (17:19 -0600)]
taskprocessor.c: Fix CLI "core show taskprocessors" output format.

Update the CLI "core show taskprocessors" output format to not be
distorted because UUID names are longer than previously used taskprocessor

Change-Id: I1a5c82ce3e8f765a0627796aba87f8f7be077601

4 years agotaskprocessor.c: Fix CLI "core show taskprocessors" unref.
Richard Mudgett [Fri, 8 Jan 2016 03:07:49 +0000 (21:07 -0600)]
taskprocessor.c: Fix CLI "core show taskprocessors" unref.

Change-Id: I1d9f4e532caa6dfabe034745dd16d06134efdce5

4 years agoccss.c: Replace space in taskprocessor name.
Richard Mudgett [Thu, 7 Jan 2016 01:00:27 +0000 (19:00 -0600)]
ccss.c: Replace space in taskprocessor name.

The CLI "core ping taskprocessor" command does not work very
well with taskprocessor names that have spaces in them.  You
have to put quotes around the name so using tab completion
becomes awkward.

Change-Id: I29e806dd0a8a0256f4e2e0a7ab88c9e19ab0eda0

4 years agotaskprocessor.c: Sort CLI "core show taskprocessors" output.
Richard Mudgett [Fri, 8 Jan 2016 02:44:18 +0000 (20:44 -0600)]
taskprocessor.c: Sort CLI "core show taskprocessors" output.

Change-Id: I71e7bf57c7b908c8b8c71f1816348ed7c5a5d51e

4 years agotaskprocessor.c: Add CLI "core ping taskprocessor" missing unlock.
Richard Mudgett [Tue, 5 Jan 2016 22:54:06 +0000 (16:54 -0600)]
taskprocessor.c: Add CLI "core ping taskprocessor" missing unlock.

Change-Id: I78247e0faf978bf850b5ba4e9f4933ab3c59d17b

4 years agoMerge "main: Use ast_strdup instead of strdup"
Mark Michelson [Fri, 8 Jan 2016 20:46:51 +0000 (14:46 -0600)]
Merge "main: Use ast_strdup instead of strdup"

4 years agoAlembic: Add PJSIP global keep_alive_interval.
Mark Michelson [Wed, 16 Dec 2015 17:25:13 +0000 (11:25 -0600)]
Alembic: Add PJSIP global keep_alive_interval.

The keep_alive_interval option was added about a year ago, but no
alembic revision was created to add the appropriate column to the

This commit fixes the problem and adds the column. This was discovered
by running the testsuite with automatic conversion to realtime enabled.

Change-Id: If3ef92a7c4f4844d08f8aae170d2178aec5c4c1a

4 years agoinclude/asterisk/time.h: Renamed global declaration:tv
Diederik de Groot [Thu, 7 Jan 2016 09:21:03 +0000 (10:21 +0100)]
include/asterisk/time.h: Renamed global declaration:tv

Renamed global declaration:tv to dummy_tv_var_for_types,
which would oltherwise cause 'shadow' warnings when 'tv'
was declared as a local variable elsewhere.

Added comment to note that dummy_tv_var_for_types is never
really exported and only used as a place holder.

ASTERISK-25627 #close

Change-Id: I9a6e17995006584f3627efe8988e3f8aa0f5dc28

4 years agoPJSIP: Prevent deadlock due to dialog/transaction lock inversion.
Mark Michelson [Thu, 7 Jan 2016 21:37:36 +0000 (15:37 -0600)]
PJSIP: Prevent deadlock due to dialog/transaction lock inversion.

A deadlock was observed where the monitor thread was stuck, therefore
resulting in no incoming SIP traffic being processed.

The problem occurred when two 200 OK responses arrived in response to a
terminating NOTIFY request sent from Asterisk. The first 200 OK was
dispatched to a threadpool worker, who locked the corresponding
transaction. The second 200 OK arrived, resulting in the monitor thread
locking the dialog. At this point, the two threads are at odds, because
the monitor thread attempts to lock the transaction, and the threadpool
thread loops attempting to try to lock the dialog.

In this case, the fix is to not have the monitor thread attempt to hold
both the dialog and transaction locks at the same time. Instead, we
release the dialog lock before attempting to lock the transaction.

There have also been some debug messages added to the process in an
attempt to make it more clear what is going on in the process.

ASTERISK-25668 #close
Reported by Mark Michelson

Change-Id: I4db0705f1403737b4360e33a8e6276805d086d4a

4 years agoast_format_cap_append_by_type: Resolve codec reference leak.
Corey Farrell [Thu, 7 Jan 2016 15:39:19 +0000 (10:39 -0500)]
ast_format_cap_append_by_type: Resolve codec reference leak.

This resolves a reference leak caused by ASTERISK-25535.  The pointer
returned by ast_format_get_codec is saved so it can be released.

ASTERISK-25664 #close

Change-Id: If9941b1bf4320b2c59056546d6bce9422726d1ec

4 years agomain: Use ast_strdup instead of strdup
Diederik de Groot [Thu, 7 Jan 2016 09:33:02 +0000 (10:33 +0100)]
main: Use ast_strdup instead of strdup

Fix compile error in main/utils.c because strdup was used in dummy_start

Change-Id: Id61a6cf4f3cbf235450441e10e7da101a6335793

4 years agoMerge "cel/cel_radius: Fix wrong pointer."
Joshua Colp [Wed, 6 Jan 2016 18:02:36 +0000 (12:02 -0600)]
Merge "cel/cel_radius: Fix wrong pointer."

4 years agoMerge "Add sipp-sendfax.xml and to contrib/scripts."
Joshua Colp [Wed, 6 Jan 2016 16:55:06 +0000 (10:55 -0600)]
Merge "Add sipp-sendfax.xml and to contrib/scripts."

4 years agoAdd sipp-sendfax.xml and to contrib/scripts.
Walter Doekes [Wed, 6 Jan 2016 13:12:40 +0000 (14:12 +0100)]
Add sipp-sendfax.xml and to contrib/scripts.

The creates pcap files from fax.log files, generated
through 'fax set debug on' when receiving a fax. An example fax.log is
included as spandspflow2pcap.log.

The sipp-sendfax.xml SIPp scenario can be used to replay that fax with a
recent version of SIPp.

ASTERISK-25660 #close

Change-Id: I4de8f28b084055b482ab8a5b28d28b605b0ed526

4 years agoMerge topic 'pbx-split'
Joshua Colp [Wed, 6 Jan 2016 12:13:29 +0000 (06:13 -0600)]
Merge topic 'pbx-split'

* changes:
  main/pbx: Move hangup handler routines to pbx_hangup_handler.c.
  main/pbx: Move dialplan application management routines to pbx_app.c.
  main/pbx: Move switch routines to pbx_switch.c.

4 years agoMerge "main/pbx: Move timing routines to pbx_timing.c."
Joshua Colp [Wed, 6 Jan 2016 12:09:48 +0000 (06:09 -0600)]
Merge "main/pbx: Move timing routines to pbx_timing.c."

4 years agocel/cel_radius: Fix wrong pointer.
Aaron An [Mon, 4 Jan 2016 10:26:55 +0000 (18:26 +0800)]
cel/cel_radius: Fix wrong pointer.

The macro ADD_VENDOR_CODE defined in the cel_radius.c should use the parameter
y not the address of y.

I capture the radius UDP packet via tcpdump, and the AV pairs are not correct,
then i review the source code and compare it with cdr/cdr_radius.c. Fix it and
 it works.

ASTERISK-25647 #close
Reported by: Aaron An
Tested by: Aaron An

Change-Id: I72889bccd8fde120d47aa659edc0e7e6d4d019f0

4 years agoMerge "main/pbx: Move variable routines to pbx_variables.c."
Matt Jordan [Tue, 5 Jan 2016 19:38:45 +0000 (13:38 -0600)]
Merge "main/pbx: Move variable routines to pbx_variables.c."

4 years agomain/pbx: Move hangup handler routines to pbx_hangup_handler.c.
Corey Farrell [Tue, 5 Jan 2016 02:23:01 +0000 (21:23 -0500)]
main/pbx: Move hangup handler routines to pbx_hangup_handler.c.

This is the sixth patch in a series meant to reduce the bulk of pbx.c.
This moves hangup handler management functions to their own source.

Change-Id: Ib25a75aa57fc7d5c4294479e5cc46775912fb104

4 years agoapp_queue: Add member flag "in_call" to prevent reading wrong lastcall time
Martin Tomec [Mon, 21 Dec 2015 17:07:14 +0000 (18:07 +0100)]
app_queue: Add member flag "in_call" to prevent reading wrong lastcall time

Member lastcall time is updated later than member status. There was chance to
check wrapuptime for available member with wrong (old) lastcall time.
New boolean flag "in_call" is set to true right before connecting call, and
reset to false after update of lastcall time. Members with "in_call" set to true
are treat as unavailable.

ASTERISK-19820 #close

Change-Id: I1923230cf9859ee51563a8ed420a0628b4d2e500

4 years agoMerge "Happy new year 2016."
Matt Jordan [Tue, 5 Jan 2016 15:39:47 +0000 (09:39 -0600)]
Merge "Happy new year 2016."

4 years agoMerge "voicemail: Move app_voicemail / res_mwi_external conflict to runtime"
Joshua Colp [Tue, 5 Jan 2016 11:55:55 +0000 (05:55 -0600)]
Merge "voicemail: Move app_voicemail / res_mwi_external conflict to runtime"

4 years agomain/pbx: Move dialplan application management routines to pbx_app.c.
Corey Farrell [Tue, 5 Jan 2016 01:46:25 +0000 (20:46 -0500)]
main/pbx: Move dialplan application management routines to pbx_app.c.

This is the sixth patch in a series meant to reduce the bulk of pbx.c.
This moves dialplan application management functions to their own source.

Change-Id: I444c10fb90a3cdf9f3047605d6a8aad49c22c44c

4 years agomain/pbx: Move switch routines to pbx_switch.c.
Corey Farrell [Tue, 5 Jan 2016 00:20:35 +0000 (19:20 -0500)]
main/pbx: Move switch routines to pbx_switch.c.

This is the fifth patch in a series meant to reduce the bulk of pbx.c.
This moves ast_switch functions to their own source.

Change-Id: Ic2592a18a5c4d8a3c2dcf9786c9a6f650a8c628e

4 years agomain/pbx: Move timing routines to pbx_timing.c.
Corey Farrell [Tue, 5 Jan 2016 00:00:23 +0000 (19:00 -0500)]
main/pbx: Move timing routines to pbx_timing.c.

This is the fourth patch in a series meant to reduce the bulk of pbx.c.
This moves pbx timing functions to their own source.

Change-Id: I05c45186cb11edfc901e95f6be4e6a8abf129cd6

4 years agovoicemail: Move app_voicemail / res_mwi_external conflict to runtime
George Joseph [Wed, 30 Dec 2015 16:49:03 +0000 (09:49 -0700)]
voicemail: Move app_voicemail / res_mwi_external conflict to runtime

The menuselect conflict between app_voicemail and res_mwi_external
makes it hard to package 1 version of Asterisk.  There no actual
build dependencies between the 2 so moving this check to runtime
seems like a better solution.

The ast_vm_register and ast_vm_greeter_register functions in app.c
were modified to return AST_MODULE_LOAD_DECLINE instead of -1 if there
is already a voicemail module registered. The modules' load_module
functions were then modified to return DECLINE instead of -1 to the
loader.  Since -1 is interpreted by the loader as AST_MODULE_LOAD_FAILURE,
the modules were incorrectly causing Asterisk to stop so this needed
to be cleaned up anyway.

Now you can build both and use modules.conf to decide which voicemail
implementation to load.

The default menuselect options still build app_voicemail and not
res_mwi_external but if both ARE built, res_mwi_external will load
first and become the voicemail provider unless modules.conf rules
prevent it.  This is noted in CHANGES.

Change-Id: I7d98d4e8a3b87b8df9e51c2608f0da6ddfb89247

4 years agomain/pbx: Move variable routines to pbx_variables.c.
Corey Farrell [Mon, 4 Jan 2016 22:15:14 +0000 (17:15 -0500)]
main/pbx: Move variable routines to pbx_variables.c.

This is the third patch in a series meant to reduce the bulk of pbx.c.
This moves channel and global variable routines to their own source.

Change-Id: Ibe8fb4647db11598591d443a99e3f99200a56bc6

4 years agoapp_dial: Immediately exit dial if the caller is already hung up.
Richard Mudgett [Fri, 4 Dec 2015 23:22:29 +0000 (17:22 -0600)]
app_dial: Immediately exit dial if the caller is already hung up.

If a caller hangs up before dial is executed within an AGI then the AGI
has likely eaten all queued frames before executing the dial in DeadAGI
mode.  With the caller hung up and no pending frames from the caller's
read queue, dial would not know that the call has hung up until a called
channel answers.  It is rather annoying to whoever just answered the
non-existent call.

Dial should not continue execution in DeadAGI mode, hangup handlers, or
the h exten.

* Added a check early in dial to abort dialing if the caller has hungup.

ASTERISK-25307 #close
Reported by: David Cunningham

Change-Id: Icd1bc0764726ef8c809f76743ca008d0f102f418

4 years agoMerge "main/cdr: Allow setting properties on a finalized CDR if it is the last one"
Matt Jordan [Mon, 4 Jan 2016 15:02:53 +0000 (09:02 -0600)]
Merge "main/cdr: Allow setting properties on a finalized CDR if it is the last one"

4 years agoMerge "main/cdr: Set the end time on a CDR if endbeforehexten is Yes"
Matt Jordan [Mon, 4 Jan 2016 15:02:47 +0000 (09:02 -0600)]
Merge "main/cdr: Set the end time on a CDR if endbeforehexten is Yes"

4 years agomain/cdr: Allow setting properties on a finalized CDR if it is the last one
Matt Jordan [Sat, 2 Jan 2016 16:26:04 +0000 (10:26 -0600)]
main/cdr: Allow setting properties on a finalized CDR if it is the last one

Prior to this patch, we explicitly disallowed setting any properties on a
finalized CDR. This seemed like a good idea at the time; in practice, it was
more restrictive.

There are weird and strange scenarios where setting a property on a finalized
CDR is definitely wrong. For example, we may Fork a CDR, finalizing the
previous one, then change a property. In said case, the old CDR is supposed
to now be 'immutable' (so to speak), and should not be updated. From the
perspective of the code, a forked CDR that is finalized is just finalized.
Hence why we decided these should not be updated.

In practice, it is much more common to want to set a property on a CDR in
the h extension or in a hangup handler. Disallowing a common scenario to make
an esoteric behaviour work isn't good. This patch fixes this by allowing
callers to set a property IF we are the last CDR in the chain. This preserves
the finalized CDR if it was forked, while allowing the more common case to

ASTERISK-25458 #close

Change-Id: Icf3553c607b9f561152a41e6d8381d594ccdf4b9

4 years agomain/cdr: Set the end time on a CDR if endbeforehexten is Yes
Matt Jordan [Sat, 2 Jan 2016 16:23:39 +0000 (10:23 -0600)]
main/cdr: Set the end time on a CDR if endbeforehexten is Yes

Prior to this patch, the CDR engine attempted to set the end time on a CDR
that was executing hangup logic and with endbeforehexten set to Yes by
calling a function that inspects the properties on the Party A snapshot to
determine if we are ready to set the end time. That always failed. This is
because a Party A snapshot is not updated for CDRs that are executing hangup
logic with endbeforehexten=Yes.

Instead of calling a function that looks at the Party A snapshot, we just
simply set the end time on the CDR. This is safe to call multiple times, and is
safe to call at this point as we know that (a) we are executing hangup logic,
and (b) we are supposed to set the end time at this point.


Change-Id: I0c27b493861f9c13c43addbbb21257f79047a3b3

4 years agomain/pbx: Move custom function routines to pbx_functions.c.
Corey Farrell [Thu, 31 Dec 2015 02:51:47 +0000 (21:51 -0500)]
main/pbx: Move custom function routines to pbx_functions.c.

This is the second patch in a series meant to reduce the bulk of pbx.c.
This moves custom function management routines to their own source.

Change-Id: I34a6190282f781cdbbd3ce9d3adeac3c3805e177

4 years agoMerge "main/pbx: Move pbx_builtin dialplan applications to pbx_builtins.c"
Matt Jordan [Fri, 1 Jan 2016 15:25:41 +0000 (09:25 -0600)]
Merge "main/pbx: Move pbx_builtin dialplan applications to pbx_builtins.c"

4 years agoHappy new year 2016.
Rodrigo Ramírez Norambuena [Fri, 1 Jan 2016 11:25:41 +0000 (08:25 -0300)]
Happy new year 2016.

Change-Id: I22d3c90f6f27df82e915bbf81c1d91221f7a945e

4 years agoMerge "res_pjsip_history: Add a module that provides PJSIP history for debugging"
Matt Jordan [Fri, 1 Jan 2016 04:42:26 +0000 (22:42 -0600)]
Merge "res_pjsip_history: Add a module that provides PJSIP history for debugging"

4 years agores_pjsip_history: Add a module that provides PJSIP history for debugging
Matt Jordan [Sun, 13 Dec 2015 19:09:42 +0000 (13:09 -0600)]
res_pjsip_history: Add a module that provides PJSIP history for debugging

This patch adds a new module, res_pjsip_history, that provides a slightly
better way of debugging SIP message traffic on a busy Asterisk system. The
existing mechanisms all rely on passively dumping a SIP message to the CLI.
While this is perfectly fine for logging purposes and well controlled
environments, on many installations, the amount of SIP messages Asterisk
receives will quickly swamp the CLI. This makes it difficult to view/capture
those messages that you want to diagnose in real time.

This patch provides another way of handling this. When enabled, the module
will store SIP message traffic in memory. This traffic can then be queried
at leisure.

In order to make the querying useful, a CLI command has been implemented,
'pjsip show history', that supports a basic expression syntax similar to
SQL or other query languages. A small number of useful fields have been
added in this initial patch; additional fields can easily be added in
later improvements. Those fields are:
 - number: The entry index in the history
 - timestamp: The time the message was recieved
 - addr: The source/destination address of the message
 - sip.msg.request.method: The request method
 - The Call-ID header

Note - this is a resurrection of the module initially proposed on Review Board

Change-Id: I39bd74ce998e99ad5ebc0aab3e84df3a150f8e36

4 years agomain/pbx: Move pbx_builtin dialplan applications to pbx_builtins.c
George Joseph [Tue, 29 Dec 2015 01:18:01 +0000 (18:18 -0700)]
main/pbx: Move pbx_builtin dialplan applications to pbx_builtins.c

We joked about splitting pbx.c into multiple files but this first step was
fairly easy.  All of the pbx_builtin dialplan applications have been moved
into pbx_builtins.c and a new pbx_private.h file was added. load_pbx_builtins()
is called by asterisk.c just after load_pbx().

A few functions were renamed and are cross-exposed between the 2 source files.

Change-Id: I87066be3dbf7f5822942ac1449d98cc43fc7561a

4 years agoMerge "res_http_websocket.c: prevent avoidable disconnections caused by write errors"
Joshua Colp [Thu, 31 Dec 2015 00:43:34 +0000 (18:43 -0600)]
Merge "res_http_websocket.c: prevent avoidable disconnections caused by write errors"

4 years agoMerge "test_time: Provide a timeout when waiting."
Joshua Colp [Mon, 28 Dec 2015 22:34:32 +0000 (16:34 -0600)]
Merge "test_time: Provide a timeout when waiting."

4 years agoMerge "endpoint/stasis: Eliminate duplicate events on endpoint status change"
Matt Jordan [Mon, 28 Dec 2015 21:11:06 +0000 (15:11 -0600)]
Merge "endpoint/stasis: Eliminate duplicate events on endpoint status change"

4 years agotest_time: Provide a timeout when waiting.
Joshua Colp [Mon, 28 Dec 2015 20:02:19 +0000 (16:02 -0400)]
test_time: Provide a timeout when waiting.

The test_timezone_watch unit test is written to expect a
condition to be signaled when the inotify daemon thread runs.
There exists a small window where the test_timezone_watch
thread can signal the inotify daemon thread while it is not
reading on the underlying file descriptor. If this occurs
the test_timezone_watch thread will wait indefinitely for a
signal that will never arrive.

This change adds a timeout to the condition so it will return
regardless after a period of time.

Change-Id: Ifed981879df6de3d93acd3ee0a70f92546517390

4 years agotests/test_stasis_endpoints: Remove expected duplicate events
Matt Jordan [Fri, 25 Dec 2015 02:26:46 +0000 (20:26 -0600)]
tests/test_stasis_endpoints: Remove expected duplicate events

The cache_clear test was written to expect duplicate Stasis messages
sent from the technology endpoint to the all caching topic. This patch
fixes the test to no longer expect these duplicate messages.


Change-Id: I58075d70d6cdf42e792e0fb63ba624720bfce981

4 years agores_http_websocket.c: prevent avoidable disconnections caused by write errors
Dade Brandon [Fri, 25 Dec 2015 04:19:59 +0000 (20:19 -0800)]
res_http_websocket.c: prevent avoidable disconnections caused by write errors

Updated ast_websocket_write to encode the entire frame in to one
write operation, to ensure that we don't end up with a situation
where the websocket header has been sent, while the body can not
be written.

Previous to August's patch in commit b9bd3c14, certain network
conditions could cause the header to be written, and then the
sub-sequent body to fail - which would cause the next successful
write to contain a new header, and a new body (resulting in
the peer receiving two headers - the second of which would be
read as part of the body for the first header).

This was patched to have both write operations individually fail
by closing the websocket.

In a case available to the submitter of this patch, the same
body which would consistently fail to write, would succeed
if written at the same time as the header.

This update merges the two operations in to one, adds debug messages
indicating the reason for a websocket connection being closed during
a write operation, and clarifies some variable names for code legibility.

Change-Id: I4db7a586af1c7a57184c31d3d55bf146f1a40598

4 years agoendpoint/stasis: Eliminate duplicate events on endpoint status change
George Joseph [Wed, 27 May 2015 18:22:39 +0000 (12:22 -0600)]
endpoint/stasis: Eliminate duplicate events on endpoint status change

When an endpoint is created, its messages are forwarded to both the tech
endpoint topic and the all endpoints topic. This is done so that various
parties interested in endpoint messages can subscribe to just the tech
endpoint and receive all messages associated with that particular technology,
as opposed to subscribing to the all endpoints topic. Unfortunately, when the
tech endpoint is created, it also forwards all of its messages to the all
topic. This results in duplicate messages whenever an endpoint publishes its

This patch resolves the duplicate message issue by creating a new function
for Stasis caching topics, stasis_cp_sink_create. In most respects, this acts
as a normal caching topic, save that it no longer forwards messages it receives
to the all endpoints topic. This allows it to act as an aggregation "sink",
while preserving the necessary caching behaviour.

ASTERISK-25137 #close
Reported-by: Vitezslav Novy

ASTERISK-25116 #close
Reported-by: George Joseph <>
Tested-by: George Joseph <>

Change-Id: Ie47784adfb973ab0063e59fc18f390d7dd26d17b

4 years agoMerge "bridge_basic.c: Fix GOTO_ON_BLINDXFR"
Matt Jordan [Mon, 28 Dec 2015 15:44:27 +0000 (09:44 -0600)]
Merge "bridge_basic.c: Fix GOTO_ON_BLINDXFR"

4 years agoMerge "chan_sip.c: fix websocket_write_timeout default value"
Matt Jordan [Mon, 28 Dec 2015 15:44:13 +0000 (09:44 -0600)]
Merge "chan_sip.c: fix websocket_write_timeout default value"

4 years agoMerge "res/res_pjsip_location: Delete contact_status object when contact is deleted"
Joshua Colp [Mon, 28 Dec 2015 15:02:24 +0000 (09:02 -0600)]
Merge "res/res_pjsip_location: Delete contact_status object when contact is deleted"

4 years agoRemove res_jabber file that was left behind.
Corey Farrell [Mon, 28 Dec 2015 04:38:37 +0000 (23:38 -0500)]
Remove res_jabber file that was left behind.

Change-Id: I9d88fac0394d5bbaff0900a2ee911c4e4478846b

4 years agochan_sip.c: fix websocket_write_timeout default value
Dade Brandon [Fri, 25 Dec 2015 15:56:44 +0000 (07:56 -0800)]
chan_sip.c: fix websocket_write_timeout default value

websocket_write_timeout was not being set to its default value
during sip config reload, which meant that prior to this commit,
1) the default value of 100 was not used, unless an invalid value
(or 1) was specified in sip.conf for websocket_write_timeout, and
2) if the websocket_write_timeout directive was removed from sip.conf
without a full restart of asterisk, then the previous value would
continue to be used indefinitely.

This essentially lead to a 0ms write timeout (the first write attempt
in ast_careful_fwrite must have succeeded) in websocket write requests
from chan_sip, unless websocket_write_timeout was explicitely set in sip.conf.

Changes to websocket_write_timeout still only apply to new websocket
sessions, after the sip reload -- timeouts on existing sessions are
not adjusted during sip reload.

Change-Id: Ibed3816ed29cc354af6564c5ab3e75eab72cb953

4 years agobridge_basic.c: Fix GOTO_ON_BLINDXFR
Richard Mudgett [Wed, 23 Dec 2015 23:40:39 +0000 (17:40 -0600)]
bridge_basic.c: Fix GOTO_ON_BLINDXFR

Use of GOTO_ON_BLINDXFR would not work at all.  The target location would
never be executed by the transferring channel.

* Made feature_blind_transfer() call ast_bridge_set_after_go_on() with
valid context, exten, and priority parameters from the transferring

* Renamed some feature_blind_transfer() local variables for clarity.

ASTERISK-25641 #close
Reported by Dmitry Melekhov

Change-Id: I19bead9ffdc4aee8d58c654ca05a198da1e4b7ac

4 years agores/res_pjsip_location: Delete contact_status object when contact is deleted
Matt Jordan [Thu, 24 Dec 2015 18:19:51 +0000 (12:19 -0600)]
res/res_pjsip_location: Delete contact_status object when contact is deleted

In 450579e908, a change was made that removed the deletion of the
'contact_status' object when a 'contact' object is deleted in sorcery.
This unfortunately means that the 'contact_status' object persists, even when
something has explicitly removed a contact. The result is that the state of
the contact will not be regenerated if that contact is re-created, and the
stale state will be reported/used for that contact. It also results in
no ContactStatusChanged events being generated for either ARI or AMI.

This patch restores the deletion logic that was removed. Doing so now
results in the expected events being generated again.

Change-Id: I28789a112e845072308b5b34522690e3faf58f07

4 years agores_rtp_asterisk: rtp->ice check not wrapped in HAVE_PJPROJECT ifdef
Kevin Harwell [Thu, 24 Dec 2015 16:18:22 +0000 (10:18 -0600)]
res_rtp_asterisk: rtp->ice check not wrapped in HAVE_PJPROJECT ifdef

Change-Id: I19b49112e1b630bd04e859f14ccf96f8ebd6b151

4 years agoMerge "app_amd: Correct maximum_number_of_words functionality & documentation"
Matt Jordan [Wed, 23 Dec 2015 02:22:26 +0000 (20:22 -0600)]
Merge "app_amd: Correct maximum_number_of_words functionality & documentation"

4 years agoapp_amd: Correct maximum_number_of_words functionality & documentation
Dade Brandon [Mon, 21 Dec 2015 03:33:02 +0000 (19:33 -0800)]
app_amd: Correct maximum_number_of_words functionality & documentation

- The maximum_number_of_words was previously documented as being
the number of words that when exceeded, would result in the AMD
application returning that the audio represents a machine.

This was inconsistent with its actual functionality - it was
a number of words that when REACHED, would result in determination
as a machine.

This update corrects the functionality to match the previously
documented functionality.  This is a backwards incompatible change
in configuration file, and has been added to UPGRADE.txt as a result.

The sample configuration file and application defaults have been updated
so that the default value is now 2, which reflects the same default
functionality as previous versions.

- Update documentation for silence_threshold, which previously implied
that it was measuring time, rather than noise averages in the sample.

- Update the comments in amd.conf.sample.

ASTERISK-25639 #close
Change-Id: I4b1451e5dc9cb3cb06d59b6ab872f5275ba79093

4 years agores_rtp_asterisk: Resolve further timing issues with DTLS negotiation
Dade Brandon [Fri, 18 Dec 2015 01:05:00 +0000 (17:05 -0800)]
res_rtp_asterisk: Resolve further timing issues with DTLS negotiation

Resolves an edge case dtls negotiation delay for certain networks which
somehow manage to drop the rtcp side's packet when these are both sent
ast_rtp_remote_address_set, causing it to have to time-out and restart
the handshake.

Move dtls pending bio flush in to it's own function, and call it from
ast_rtp_on_ice_complete, when we're rtp->ice, rather than when

Keep the existing flush from the recent change to res_rtp_remote_address_set
if ice is not being used.

ASTERISK-25614 #close
Reported-by: XenCALL
Tested by: XenCALL

Change-Id: Ie2caedbdee1783159f375589b6fd3845c8577ba5

4 years agoMerge "app_queue: update RT members when the 1st call joins a queue with no agents"
Matt Jordan [Sat, 19 Dec 2015 16:47:57 +0000 (10:47 -0600)]
Merge "app_queue: update RT members when the 1st call joins a queue with no agents"

4 years agoMerge "json: Audit ast_json_* usage for thread safety."
Joshua Colp [Fri, 18 Dec 2015 17:57:17 +0000 (11:57 -0600)]
Merge "json: Audit ast_json_* usage for thread safety."

4 years agores_sorcery_memory_cache: Add support for a full backend cache.
Joshua Colp [Sat, 5 Dec 2015 16:01:55 +0000 (12:01 -0400)]
res_sorcery_memory_cache: Add support for a full backend cache.

This change introduces the configuration option 'full_backend_cache'
which changes the cache to be a full mirror of the backend instead
of a per-object cache. This allows all sorcery retrieval operations
to be carried out against it and is useful for object types which
are used in a "retrieve all" or "retrieve some" pattern.

ASTERISK-25625 #close

Change-Id: Ie2993487e9c19de563413ad5561c7403b48caab5

4 years agoMerge "rtp_engine: Ignore empty filenames in DTLS configuration."
Joshua Colp [Thu, 17 Dec 2015 18:50:06 +0000 (12:50 -0600)]
Merge "rtp_engine: Ignore empty filenames in DTLS configuration."

4 years agortp_engine: Ignore empty filenames in DTLS configuration.
Joshua Colp [Thu, 17 Dec 2015 16:25:47 +0000 (12:25 -0400)]
rtp_engine: Ignore empty filenames in DTLS configuration.

When applying an empty DTLS configuration the filenames in the
configuration will be empty. This is actually valid to do and
each filename should simply be ignored.

Change-Id: Ib761dc235638a3fb701df337952f831fc3e69539

4 years agochan_sip: Enable WebSocket support by default.
Joshua Colp [Thu, 17 Dec 2015 14:10:43 +0000 (10:10 -0400)]
chan_sip: Enable WebSocket support by default.

Per the documentation the WebSocket support in chan_sip is
supposed to be enabled by default but is not. This change
corrects that.

Change-Id: Icb02bbcad47b11a795c14ce20a9bf29649a54423

4 years agojson: Audit ast_json_* usage for thread safety.
Joshua Colp [Mon, 14 Dec 2015 18:04:15 +0000 (14:04 -0400)]
json: Audit ast_json_* usage for thread safety.

The JSON library Asterisk uses, jansson, is not thread
safe for us in a few ways. To help with this wrappers for JSON
object reference count increasing and decreasing were added
which use a global lock to ensure they don't clobber over
each other. This does not extend to reference count manipulation
within the jansson library itself. This means you can't safely
use the object borrowing specifier (O) in ast_json_pack and
you can't share JSON instances between objects.

This change removes uses of the O specifier and replaces them
with the o specifier and an explicit ast_json_ref. Some cases
of instance sharing have also been removed.

ASTERISK-25601 #close

Change-Id: I06550d8b0cc1bfeb56cab580a4e608ae4f1ec7d1

4 years agoAlembic: Increase column size of PJSIP AOR "contact".
Mark Michelson [Wed, 16 Dec 2015 17:28:14 +0000 (11:28 -0600)]
Alembic: Increase column size of PJSIP AOR "contact".

When running the PJSIP AMI "show_endpoint" test with automatic
conversion to realtime, the test would fail. This was because the AOR
"contact" column was sized at 40, and the configured contact was larger
than that.

This commit increases the size of the contact column to 255 characters.

Change-Id: Ia65bc7fd37699b7c0eaef9629a1a31eab9a24ba1