Commit Graph

5140 Commits

Author SHA1 Message Date
Mark Michelson a146bde1f7 Merge "main: Use ast_strdup instead of strdup" 2016-01-08 14:46:51 -06:00
Corey Farrell 5d8c42c6d3 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
2016-01-07 10:39:19 -05:00
Diederik de Groot 7856762f2f main: Use ast_strdup instead of strdup
Fix compile error in main/utils.c because strdup was used in dummy_start

Change-Id: Id61a6cf4f3cbf235450441e10e7da101a6335793
2016-01-07 10:34:15 +01:00
Joshua Colp c8e786ff66 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.
2016-01-06 06:13:29 -06:00
Joshua Colp e00e6a606e Merge "main/pbx: Move timing routines to pbx_timing.c." 2016-01-06 06:09:48 -06:00
Matt Jordan f3a052667e Merge "main/pbx: Move variable routines to pbx_variables.c." 2016-01-05 13:38:45 -06:00
Corey Farrell 36f1eaf0b5 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
2016-01-05 12:08:40 -05:00
Matt Jordan 193ac48db0 Merge "Happy new year 2016." 2016-01-05 09:39:47 -06:00
Corey Farrell 3507494b8a 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
2016-01-04 20:46:25 -05:00
Corey Farrell 54a8f1a396 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
2016-01-04 19:20:35 -05:00
Corey Farrell c3c8b8e41d 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
2016-01-04 19:00:23 -05:00
George Joseph 6d18fe151c 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
2016-01-04 17:31:24 -06:00
Corey Farrell 5ee5c3739e 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
2016-01-04 17:15:14 -05:00
Matt Jordan 839f328601 Merge "main/cdr: Allow setting properties on a finalized CDR if it is the last one" 2016-01-04 09:02:54 -06:00
Matt Jordan 5201984ed6 Merge "main/cdr: Set the end time on a CDR if endbeforehexten is Yes" 2016-01-04 09:02:48 -06:00
Matt Jordan e9dd16364e 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
function.

ASTERISK-25458 #close

Change-Id: Icf3553c607b9f561152a41e6d8381d594ccdf4b9
2016-01-02 10:38:08 -06:00
Matt Jordan 153547a9b1 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.

ASTERISK-25458

Change-Id: I0c27b493861f9c13c43addbbb21257f79047a3b3
2016-01-02 10:36:10 -06:00
Corey Farrell f9bfc2450e 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
2016-01-01 13:48:36 -05:00
Rodrigo Ramírez Norambuena 3fd528dddf Happy new year 2016.
Change-Id: I22d3c90f6f27df82e915bbf81c1d91221f7a945e
2016-01-01 08:25:41 -03:00
George Joseph 5e67e51c6a 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
2015-12-30 20:24:02 -07:00
Joshua Colp 410c5ee0fc Merge "test_time: Provide a timeout when waiting." 2015-12-28 16:34:33 -06:00
Joshua Colp a05bb258b1 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
2015-12-28 14:11:14 -06:00
George Joseph 22db16fa81 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
messages.

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 <george.joseph@fairview5.com>
Tested-by: George Joseph <george.joseph@fairview5.com>

Change-Id: Ie47784adfb973ab0063e59fc18f390d7dd26d17b
2015-12-28 11:39:26 -06:00
Richard Mudgett 8eb5da0679 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
channel.

* Renamed some feature_blind_transfer() local variables for clarity.

ASTERISK-25641 #close
Reported by Dmitry Melekhov

Change-Id: I19bead9ffdc4aee8d58c654ca05a198da1e4b7ac
2015-12-24 17:39:30 -06:00
Joshua Colp 38bf1f3a71 Merge "json: Audit ast_json_* usage for thread safety." 2015-12-18 11:57:17 -06:00
Joshua Colp 902309fd04 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
2015-12-17 13:20:55 -06:00
Joshua Colp a2431f83ef 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
2015-12-17 10:31:57 -06:00
Joshua Colp d17d9a9288 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
2015-12-16 15:21:14 -06:00
pchero 52ca6fb94a AMI: Fixed OriginateResponse message
When the asterisk sending OriginateResponse message,
it doesn't set the "Uniqueid".
And it didn't support correct response message for
Application originate.

ASTERISK-25624 #close

Change-Id: I26f54f677ccfb0b7cfd4967a844a1657fd69b74d
2015-12-15 05:42:50 -06:00
Richard Mudgett eccdf2250b Fix sscanf() format string type mismatch.
ASTERISK-25615
Reported by: George Joseph

Change-Id: Ieff35307254ca193f3d473cff2e396ca57c7ce0b
2015-12-14 16:22:25 -06:00
Matt Jordan b47b632107 Merge "main/utils: Don't emit an ERROR message if the read end of a pipe closes" 2015-12-14 06:45:07 -06:00
Matt Jordan 9a96a86e2d main/utils: Don't emit an ERROR message if the read end of a pipe closes
An ERROR or WARNING message should generally indicate that something has gone
wrong in Asterisk. In the case of writing to a file descriptor, Asterisk is not
in control of when the far end closes its reading on a file descriptor. If the
far end does close the file descriptor in an unclean fashion, this isn't a bug
or error in Asterisk, particularly when the situation can be gracefully
handled in Asterisk.

Currently, when this happens, a user would see the following somewhat cryptic
ERROR message:

  "utils.c: write() returned error: Broken pipe"

There's a few problems with this:
(1) It doesn't provide any context, other than 'something broke a pipe'
(2) As noted, it isn't actually an error in Asterisk
(3) It can get rather spammy if the thing breaking the pipe occurs often, such
    as a FastAGI server
(4) Spammy ERROR messages make Asterisk appear to be having issues, or can even
    mask legitimate issues

This patch changes ast_carefulwrite to only log an ERROR if we actually had one
that was reasonably under our control. For debugging purposes, we still emit
a debug message if we detect that the far side has stopped reading.

Change-Id: Ia503bb1efcec685fa6f3017bedf98061f8e1b566
2015-12-13 13:26:29 -06:00
George Joseph 3e6637feb5 pjsip/config_transport: Check pjproject version at runtime for async ops
pjproject < 2.5.0 will segfault on a tls transport if async_operations
is greater than 1.  A runtime version check has been added to throw
an error if the version is < 2.5.0 and async_operations > 1.

To assist in the check, a new api "ast_compare_versions" was added
to utils which compares 2 major.minor.patch.extra version strings.

ASTERISK-25615 #close

Change-Id: I8e88bb49cbcfbca88d9de705496d6f6a8c938a98
Reported-by: George Joseph
Tested-by: George Joseph
2015-12-12 11:16:08 -06:00
George Joseph a987434564 res_pjsip: Add existence and readablity checks for tls related files
Both transport and endpoint now check for the existence and readability
of tls certificate and key files before passing them on to pjproject.
This will cause the object to not load rather than waiting for pjproject
to discover that there's a problem when a session is attempted.

NOTE: chan_sip also uses ast_rtp_dtls_cfg_parse but it's located
in build_peer which is gigantic and I didn't want to disturb it.
Error messages will emit but it won't interrupt chan_sip loading.

ASTERISK-25618 #close

Change-Id: Ie43f2c1d653ac1fda6a6f6faecb7c2ebadaf47c9
Reported-by: George Joseph
Tested-by: George Joseph
2015-12-08 18:04:33 -06:00
Alexander Traud 64f899e5f3 translate: Avoid a warning message when doing FEC within Opus Codec.
ASTERISK-25616 #close

Change-Id: Ibe729aaf2e6e25506cff247cec5149ec1e589319
2015-12-08 10:48:02 +01:00
Matt Jordan 8d79446a11 Merge "Fix crash in audiohook translate to slin" 2015-12-04 07:31:11 -06:00
Jonathan Rose 69457b8d61 Fix crash in audiohook translate to slin
This patch fixes a crash which would occur when an audiohook was
applied to a channel using an audio codec that could not be translated
to signed linear (such as when using pass-through codecs like OPUS or
when the codec translator module for the format in use is not loaded).

ASTERISK-25498 #close
Reported by: Ben Langfeld

Change-Id: Ib6ea7373fcc22e537cad373996136636201f4384
2015-12-03 15:31:28 -06:00
Joshua Colp b841b2fa11 Merge "sched.c: Make not return a sched id of 0." 2015-12-03 05:50:50 -06:00
Joshua Colp a4138550f1 Merge "Audit improper usage of scheduler exposed by 5c713fdf18f." 2015-12-03 05:49:27 -06:00
Jonathan Rose b5281b74e0 Unset BRIDGEPEER when leaving a bridge
Currently if a channel is transferred out of a bridge, the BRIDGEPEER
variable (also BRIDGEPVTCALLID) remain set even once the channel is
out of the bridge. This patch removes these variables when leaving
the bridge.

ASTERISK-25600 #close
Reported by: Mark Michelson

Change-Id: I753ead2fffbfc65427ed4e9244c7066610e546da
2015-12-01 17:34:04 -06:00
Richard Mudgett ef77439e39 sched.c: Make not return a sched id of 0.
According to the API doxygen a sched ID of 0 is valid.  Unfortunately, 0
was never returned historically and several users incorrectly coded usage
of the returned sched ID assuming that 0 was invalid.

ASTERISK-25476

Change-Id: Ib19c7ebb44ec9fd393ef6646dea806d4f34e3a20
2015-12-01 13:54:04 -06:00
Richard Mudgett fa20729032 Audit improper usage of scheduler exposed by 5c713fdf18.
channels/chan_iax2.c:
* Initialize struct chan_iax2_pvt scheduler ids earlier because of
iax2_destroy_helper().

channels/chan_sip.c:
channels/sip/config_parser.c:
* Fix initialization of scheduler id struct members.  Some off nominal
paths had 0 as a scheduler id to be destroyed when it was never started.

chan_skinny.c:
* Fix some scheduler id comparisons that excluded the valid 0 id.

channel.c:
* Fix channel initialization of the video stream scheduler id.

pbx_dundi.c:
* Fix channel initialization of the packet retransmission scheduler id.

ASTERISK-25476

Change-Id: I07a3449f728f671d326a22fcbd071f150ba2e8c8
2015-12-01 13:54:04 -06:00
George Joseph e5723d2776 dns: Change lookup failures from LOG_ERROR to debug 1.
dns.c and dns_system_resolver.c were spitting out errors for lookup
failures for things like not finding a SRV record even though
there was an A record.  Those have been changed to debug messages.
Logging not finding ANY record is left to the higher level caller.

Also, dns_system_resolver was using Windows line endings so I
converted them to Unix style.  The actual log changes are on lines
156 and 159.

Change-Id: I65be16ea15304b96f9dcb4d289dbd3e2286fc094
2015-11-30 10:13:35 -07:00
Walter Doekes 03759c5587 main: Slight refactor of main. Improve color situation.
Several issues are addressed here:
- main() is large, and half of it is only used if we're not rasterisk;
  fixed by spliting up the daemon part into a separate function.
- Call ast_term_init from rasterisk as well.
- Remove duplicate code reading/writing asterisk history file.
- Attempt to tackle background color issues and color changes that
  occur. Tested by starting asterisk -c until the colors stopped
  changing at odd locations.
- Remove unused term_prep() and term_prompt() functions.

ASTERISK-25585 #close

Change-Id: Ib641a0964c59ef9fe6f59efa8ccb481a9580c52f
2015-11-25 20:29:55 +01:00
Joshua Colp 7fa13cec78 Merge "translate: Provide translation modules the result of SDP negotiation." 2015-11-24 08:20:46 -06:00
Matt Jordan 9315a93757 main/cli: Use proper string methods to check existence of context/exten/app
Because the context, extension, and application are stored in stringfields,
checking for them being NULL doesn't work so well. This patch uses the
appropriate string library call, ast_strlen_zero, to see if there is a value
in the context/exten/app values.

Change-Id: Ie09623bfdf35f5a8d3b23dd596647fe3c97b9a23
2015-11-20 22:00:07 -06:00
Alexander Traud 8ccb1d2bed translate: Provide translation modules the result of SDP negotiation.
Previously, a trancoding module did not have access to the joint but cached
format. Therefore, the module did not have access to the attributes negotiated
via SDP (line fmtp). Now, a translation module receives the joint format.

ASTERISK-25545 #close

Change-Id: Id6878a989b50573298dab115d3371ea369e1a718
2015-11-19 10:47:31 +01:00
Matt Jordan f57da2ae90 Merge "format: Register format-attribute module with cached formats." 2015-11-17 14:35:22 -06:00
George Joseph 6919daab61 dns: Fix pointer increment in dns_parse_answer_ex
When dns_parse_answer_ex was iterating over the answers it
wasn't incrementing the answer pointer correctly after the first
answer.  The result was that no answers after the first
were being returned.  For results where multiple records should
have been sorted by priority, weight, etc., there was nothing
to sort so the only the first record was returned even if it
wouldn't have been the correct record based on the sort.

ASTERISK-25565 #close
Reported-by: Daniel Tryba
Tested-by George Joseph

Change-Id: I8622604fefdcd3c11e2c5609a6382e53b1467b0b
2015-11-16 15:10:20 -07:00
Joshua Colp a1fcf6f7b2 hashtab: Add NULL check when destroying iterator.
The hashtab API is pretty NULL tolerant which has resulted
in remaining callers not doing much checks themselves.
Unfortunately the function to destroy an iterator does not
do a NULL check and will result in a crash if passed NULL.
This change fixes that.

ASTERISK-25552 #close

Change-Id: Ic1bf8eec3639e5a440f1c941d3ae3893ac6ed619
2015-11-14 08:06:48 -05:00