Commit Graph

27236 Commits

Author SHA1 Message Date
Richard Mudgett ca030845ff configure: Fix check for libunbound to require v1.5.0 as minimum.
Versions of libunbound before v1.4.21 do not compile with Asterisk.
However, since v1.4.21 has a configure script bug that fails to detect the
ldns library (which is fixed in v1.4.22) and v1.4.22 is not an easily
detectable version we will require v1.5.0 as a minimum version of the
library to work with Asterisk.

ASTERISK-25108 #close
Reported by: Richard Mudgett

Change-Id: Ieb228bfb01467573fc121c7356a9dde27128894d
2015-10-08 16:43:10 -05:00
tcambron 2fe9f09705 StatsD: Write skeleton Asterisk application
Wrote the skeleton framework for the Asterisk StatsD dialplan
application. This includes a load function, unload function, a
callback for execution, and XML documentation.

ASTERISK-25419
Reported By: Ashley Sanders

Change-Id: I9597730e134c6e82c8a55ef4d5334b62dd473363
2015-10-08 14:14:14 -05:00
Joshua Colp 38519aeadf Merge "chan_pjsip: Fix crash on reINVITE before initial INVITE completes." 2015-10-08 13:48:33 -05:00
Richard Mudgett 34d7fa6c4a res_pjsip: Fix deadlock when sending out-of-dialog requests.
The struct send_request_wrapper has a pjsip lock associated with it that
is created non-recursive.  There is a code path for the struct
send_request_wrapper lock that will attempt to lock it recursively.  The
reporter's deadlock showed that the thread calling endpt_send_request()
deadlocked itself right after the wrapper object got created.

Out-of-dialog requests such as MESSAGE, qualify OPTIONS, and unsolicited
MWI NOTIFY messages can hit this deadlock.

* Replaced the struct send_request_wrapper pjsip lock with the mutex lock
that can come with an ao2 object since all of Asterisk's mutexes are
recursive.  Benefits include removal of code maintaining the pjsip
non-recursive lock since ao2 objects already know how to maintain their
own lock and the lock will show up in the CLI "core show locks" output.

ASTERISK-25435 #close
Reported by: Dmitriy Serov

Change-Id: I458e131dd1b9816f9e963f796c54136e9e84322d
2015-10-07 12:40:09 -05:00
Joshua Colp 7cbb091110 Merge "res/res_rtp_asterisk.c: Fix incorrect assignment of frame->subclass.frame_ending" 2015-10-07 11:58:58 -05:00
StefanEng86 cc131832aa res/res_rtp_asterisk.c: Fix incorrect assignment of frame->subclass.frame_ending
In ast_rtp_read, the value of the variable 'mark' which we try to assign to a
frame->subclass.frame_ending may be 0, 1 or (1<<23), but we should translate
it to 0 or 1.

ASTERISK-25451 #close
Change-Id: I53bdf5c026041730184a6a809009c028549ce626
2015-10-07 15:49:33 +02:00
Ivan Poddubny c944263e36 func_presencestate: Return "not_set" when no data is set in AstDB
Return AST_PRESENCE_NOT_SET when CustomPresence AstDB key does not
exist, i.e. when a new CustomPresence is added in the dialplan.

ASTERISK-25400 #close
Reported by: Andrew Nagy

Change-Id: I6fb17b16591b5a55fbffe96f3994ec26b1b1723a
2015-10-07 09:24:31 +03:00
Matt Jordan 4bf395e81e res/res_rtp_asterisk: Fix assignment after ao2 decrement
When we decide we will no longer schedule an RTCP write, we remove the
reference to the RTP instance, then assign -1 to the stored scheduler ID
in case something else comes along and wants to see if anything is scheduled.

That scheduler ID is on the RTP instance. After 60a9172d7e was merged to
fix the regression introduced by 3cf0f29310, this improper assignment on a
potentially destroyed object started getting tripped on the build agents.

Frankly, this should have been crashing a lot more often earlier. I can only
assume that the timing was changed just enough by both changes to start
actually hitting this problem.

As it is, simply moving the assignment prior to the ao2 deference is sufficient
to keep the RTP instance from being referenced when it is very, truly,
aboslutely dead.

(Note that it is still good practice to assign -1 to the scheduler ID when we
know we won't be scheduling it again, as the ao2 deref *may* not always destroy
the ao2 object.)

ASTERISK-25449

Change-Id: Ie6d3cb4adc7b1a6c078b1c38c19fc84cf787cda7
2015-10-06 20:51:48 -05:00
Florian Sauerteig 3ec9cf7d6a chan_sip: Fix port parsing for IPv6 addresses in SIP Via headers.
If a Via header containes an IPv6 address and a port number is ommitted,
as it is the standard port, we now leave the port empty and to not set it
to the value after the first colon of the IPv6 address.

ASTERISK-25443 #close

Change-Id: Ie3c2f05471cd006bf04ed15598589c09577b1e70
2015-10-06 16:34:34 -05:00
Richard Mudgett 8fe9350b68 chan_pjsip: Fix crash on reINVITE before initial INVITE completes.
Apparently some endpoints attempt to send a reINVITE before completing the
initial INVITE transaction.  In this case PJSIP responds appropriately to
the reINVITE with a 491 INVITE request pending.  Unfortunately chan_pjsip
is using the initial INVITE transaction state to determine if an INVITE is
the initial INVITE or a reINVITE.  Since the initial INVITE transaction
has not been confirmed yet chan_pjsip thinks the reINVITE is an initial
INVITE and starts another PBX thread on the channel.  The extra PBX thread
ensures that hilarity ensues.

* Fix checks for a reINVITE on incoming requests to look for the presence
of a to-tag instead of the initial INVITE transaction state.

* Made caller_id_incoming_request() determine what to do if there is a
channel on the session or not.  After a channel is created it is too late
to just store the new party id on the session because the session's party
id has already been copied to the channel's caller id.

ASTERISK-25404 #close
Reported by: Chet Stevens

Change-Id: Ie78201c304a2b13226f3a4ce59908beecc2c68be
2015-10-06 16:10:29 -05:00
Matt Jordan 52f413f709 Merge "Fix improper usage of scheduler exposed by 5c713fdf18f" 2015-10-06 08:30:13 -05:00
Matt Jordan 8cb614fe20 Fix improper usage of scheduler exposed by 5c713fdf18
When 5c713fdf18 was merged, it allowed for scheduled items to have an ID of
'0' returned. While this was valid per the documentation for the API, it was
apparently never returned previously. As a result, several users of the
scheduler API viewed the result as being invalid, causing them to reschedule
already scheduled items or otherwise fail in interesting ways.

This patch corrects the users such that they view '0' as valid, and a returned
ID of -1 as being invalid.

Note that the failing HEP RTCP tests now pass with this patch. These tests
failed due to a duplicate scheduling of the RTCP transmissions.

ASTERISK-25449 #close

Change-Id: I019a9aa8b6997584f66876331675981ac9e07e39
2015-10-06 07:40:29 -05:00
Debian Amtelco c6b0d60264 chan_pjsip: Add Referred-By header to the PJSIP REFER packet.
Some systems require the REFER packet to include a Referred-By header.
If the channel variable SIPREFERREDBYHDR is set, it passes that value as the
Referred-By header value.  Otherwise, it adds the current dialog’s local info.

Reported by: Dan Cropp
Tested by: Dan Cropp

Change-Id: I3d17912ce548667edf53cb549e88a25475eda245
2015-10-05 21:45:24 +00:00
Ivan Poddubny 89dec7675d manager: Fix GetConfigJSON returning invalid JSON
When GetConfigJSON was introduced back in 1.6, it returned each
section as an array of strings: ["key=value", "key2=value2"].
Afterwards, it was changed a few times and became
["key": "value", "key2": "value2"], which is not a correct JSON.
This patch fixes that by constructing a JSON object {} instead of
an array [].

Also, the keys "istemplate" and "tempates" that are used to
indicate templates and their inherited categories are now wrapped in
quotes.

ASTERISK-25391 #close
Reported by: Bojan Nemčić

Change-Id: Ibbe93c6a227dff14d4a54b0d152341857bcf6ad8
2015-10-03 15:15:52 +03:00
Joshua Colp ace043f4ea Merge "res_sorcery_memory_cache.c: Fix deadlock with scheduler." 2015-10-02 16:28:10 -05:00
Joshua Colp 45bba81f67 Merge "res_sorcery_memory_cache.c: Replace inline code with function." 2015-10-02 16:28:03 -05:00
Joshua Colp 40bc805b0d Merge "res_sorcery_memory_cache.c: Shutdown in a less crash potential order." 2015-10-02 16:27:57 -05:00
Joshua Colp 8804ad62ec Merge "res_sorcery_memory_cache.c: Misc tweaks." 2015-10-02 16:27:52 -05:00
Joshua Colp 9aac6d3595 Merge "res_sorcery_memory_cache.c: Made use OBJ_SEARCH_MASK." 2015-10-02 16:27:46 -05:00
Joshua Colp 4967a968ee Merge "sched.c: Add warning about negative time interval request." 2015-10-02 16:27:08 -05:00
Richard Mudgett 1b80dbeb60 res_sorcery_memory_cache.c: Fix deadlock with scheduler.
A deadlock can happen when a sorcery object is being expired from the
memory cache when at the same time another object is being placed into the
memory cache.  There are a couple other variations on this theme that
could cause the deadlock.  Basically if an object is being expired from
the sorcery memory cache at the same time as another thread tries to
update the next object expiration timer the deadlock can happen.

* Add a deadlock avoidance loop in expire_objects_from_cache() to check if
someone is trying to remove the scheduler callback from the scheduler.

ASTERISK-25441 #close

Change-Id: Iec7b0bdb81a72b39477727b1535b2539ad0cf4dc
2015-10-01 17:28:24 -05:00
Richard Mudgett 9c1ca287a4 res_sorcery_memory_cache.c: Replace inline code with function.
Make sorcery_memory_cache_close() call remove_all_from_cache() instead of
partially inlining it.

ASTERISK-25441

Change-Id: I1aa6cb425b1a4307096f3f914d17af8ec179a74c
2015-10-01 17:28:24 -05:00
Richard Mudgett 6554a3b25e res_sorcery_memory_cache.c: Shutdown in a less crash potential order.
Basically you should shutdown in the opposite order of how you setup since
later setup pieces likely depend on earlier setup pieces.  e.g.,
Registering your external API with the rest of the system should be the
last thing setup and the first thing unregistered during shutdown.

Change-Id: I5715765b723100c8d3c2642e9e72cc7ad5ad115e
2015-10-01 17:28:23 -05:00
Richard Mudgett 359394cc29 res_sorcery_memory_cache.c: Misc tweaks.
Change-Id: I8cd32dffbb4f33bb0c39518d6e4c991e73573160
2015-10-01 17:28:23 -05:00
Richard Mudgett 7942d1c2ff res_sorcery_memory_cache.c: Made use OBJ_SEARCH_MASK.
Change-Id: Ibca6574dc3c213b29cc93486e01ccd51f5caa46c
2015-10-01 17:28:23 -05:00
Joshua Colp 9f229d6a49 res_rtp_asterisk: Move "Set role" warning to be debug.
In practice the set_role API callback can be invoked even
when no ICE is present on an RTP instance. This can occur
if ICE has not been enabled on it.

ASTERISK-25438 #close

Change-Id: I0e17e4316f0f0d7f095c78c3d4fd73a913b6ba69
2015-09-30 13:46:00 -05:00
Richard Mudgett 9bc7386b7c sched.c: Add warning about negative time interval request.
Change-Id: Ib91435fb45b7f5f7c0fc83d0eec20b88098707bc
2015-09-30 10:47:12 -05:00
Richard Mudgett 12feec0bf7 res/ari/config.c: Fix user sort compare function.
Made use the ao2 sort compare template function and OBJ_SEARCH_xxx
identifiers.

Change-Id: Ic53005dc5aafa7a36c72300dd89b75fb63c92f4c
2015-09-29 12:10:45 -05:00
Richard Mudgett 3f4fa245e5 res/ari/config.c: Optimize conf_alloc() object init.
* Now conf_alloc() has more off nominal error checking.

* Eliminated RAII_VAR() use in conf_alloc().

* Eliminated a dubius shortcut when destroying cfg->general in
conf_destructor() that would cause a crash if cfg->general failed to get
allocated.

* Add some ACO registration section comments.

Change-Id: Ia40c2b1b2d0777d641605118ae019c5a73865e1a
2015-09-29 12:10:45 -05:00
Richard Mudgett aa00df62ee res/ari/config.c: Fix conf_alloc() object init.
Need to finish initializing the string fields in the ao2 object before
putting any default strings into them.

ASTERISK-25383 #close
Reported by:  yaron nahum

Change-Id: I9f7f3a03f0c4991a01593abf8697b9a587c0ea84
2015-09-29 12:10:45 -05:00
Matt Jordan 2d7a4a3357 main/logger: Add log formatters and JSON structured logs
When Asterisk is part of a larger distributed system, log files are often
gathered using tools (such as logstash) that prefer to consume information
and have it rendered using other tools (such as Kibana) that prefer a
structured format, e.g., JSON. This patch adds support for JSON formatted
logs by adding support for an optional log format specifier in Asterisk's
logging subsystem. By adding a format specifier of '[json]':

full => [json]debug,verbose,notice,warning,error

Log messages will be output to the 'full' channel in the following
format:

{
  "hostname": Hostname or name specified in asterisk.conf
  "timestamp": Date/Time
  "identifiers": {
    "lwp": Thread ID,
    "callid": Call Identifier
  }
  "logmsg": {
    "location": {
      "filename": Name of the file that generated the log statement
      "function": Function that generated the log statement
      "line": Line number that called the logging function
    }
    "level": Log level, e.g., DEBUG, VERBOSE, etc.
    "message": Actual text of the log message
  }
}

ASTERISK-25425 #close

Change-Id: I8649bfedf3fb7bf3138008cc11565553209cc238
2015-09-29 07:28:01 -05:00
Matt Jordan 9db74be3c0 Merge "app_queue.c: Force COLP update if outgoing channel name changed." 2015-09-29 07:27:50 -05:00
Matt Jordan 8bb8f99252 Merge "app_queue.c: Factor out a connected line update routine." 2015-09-29 07:27:13 -05:00
Matt Jordan e0d8b6a65d Merge "app_dial.c: Make 'A' option pass COLP updates." 2015-09-29 07:27:02 -05:00
Matt Jordan 360d076dfc Merge "app_dial.c: Force COLP update if outgoing channel name changed." 2015-09-29 07:26:20 -05:00
Matt Jordan df7cfc9ac9 Merge "translate: Fix transcoding while different in frame size." 2015-09-28 16:24:19 -05:00
Joshua Colp afabf9da7f Merge "app_dial.c: Factor out a connected line update routine." 2015-09-28 14:07:05 -05:00
Matt Jordan 5784675ee1 Merge "res/res_stasis: Fix accidental subscription to 'all' bridge topic" 2015-09-28 08:36:09 -05:00
Joshua Colp 96c26f497a Merge "Scripts: check file versions of Asterisk and dependencies" 2015-09-28 06:50:12 -05:00
Matt Jordan 9402f80726 res/res_stasis: Fix accidental subscription to 'all' bridge topic
When b99a705262 was merged, subscribing to a
NULL bridge will now cause app_subscribe_bridge to implicitly subscribe to
all bridges. Unfortunately, the res_stasis control loop did not check that
a bridge changing on a channel's control object was actually also non-NULL.
As a result, app_subscribe_bridge will be called with a NULL bridge when a
channel leaves a bridge. This causes a new subscription to be made to the
bridge. If an application has also subscribed to the bridge, the application
will now have two subscriptions:
(1) The explicit one created by the app
(2) The implicit one accidentally created by the control structure

As a result, the 'BridgeDestroyed' event can be sent multiple times. This
patch corrects the control loop such that it only subscribes an application
to a new bridge if the bridge pointer is non-NULL.

ASTERISK-24870

Change-Id: I3510e55f6bc36517c10597ead857b964463c9f4f
2015-09-27 20:45:50 -05:00
Scott Griepentrog d6472d96b3 Scripts: check file versions of Asterisk and dependencies
To help in diagnosing mismatched modules and libraries, this
script scans for version, repository, and source information
and reports what is found.

ASTERISK-25376 #close
Reported by: Ashley Sanders

Change-Id: Ib0642d0fb96712476f59760d6d137a24633fe2d6
2015-09-25 15:07:44 -05:00
Richard Mudgett 7c7a7ddd27 app_queue.c: Force COLP update if outgoing channel name changed.
* When a call is answered and the outgoing channel name has changed then
force a connected line update because the channel is no longer the same.
The channel was masqueraded into by another channel.  This is usually
because of a call pickup.

Note: Forwarded calls are handled in a controlled manner so the original
channel name is replaced with the forwarded channel.

ASTERISK-25423 #close
Reported by: John Hardin

Change-Id: Ie275ea9e99c092ad369db23e0feb08c44498c172
2015-09-25 12:40:31 -05:00
Richard Mudgett 145608bd81 app_queue.c: Factor out a connected line update routine.
Replace inlined code with update_connected_line_from_peer().

ASTERISK-25423
Reported by: John Hardin

Change-Id: I33bbd033596fcb0208d41d8970369b4e87b806f3
2015-09-25 12:40:31 -05:00
Richard Mudgett 1d394774b2 app_dial.c: Make 'A' option pass COLP updates.
While the 'A' option is playing the announcement file allow the caller and
peer to exchange COLP update frames.

ASTERISK-25423
Reported by: John Hardin

Change-Id: Iac6cf89b56d26452c6bb88e9363622bbf23895f9
2015-09-25 12:40:31 -05:00
Richard Mudgett 680b76eb25 app_dial.c: Force COLP update if outgoing channel name changed.
* When a call is answered and the outgoing channel name has changed then
force a connected line update because the channel is no longer the same.
The channel was masqueraded into by another channel.  This is usually
because of a call pickup.

Note: Forwarded calls are handled in a controlled manner so the original
channel name is replaced with the forwarded channel.

ASTERISK-25423
Reported by: John Hardin

Change-Id: I2e01f7a698fbbc8c26344a59c2be40c6cd98b00c
2015-09-25 12:40:31 -05:00
Richard Mudgett fdf0bcb04a app_dial.c: Factor out a connected line update routine.
Replace inlined code with update_connected_line_from_peer().

ASTERISK-25423
Reported by: John Hardin

Change-Id: Ia14f18def417645cd7fb453e1bdac682630a5091
2015-09-25 12:40:31 -05:00
Richard Mudgett c285879845 app_dial.c: Remove some no-op code.
Change-Id: Ice1884a94315d3cb7e3bbd47a9fba76a27276c54
2015-09-25 11:31:03 -05:00
Joshua Colp 6392fdf6dc Merge "logger: Prevent duplicate dynamic channels from being added." 2015-09-25 10:57:40 -05:00
Mark Michelson 3eefa07a39 logger: Prevent duplicate dynamic channels from being added.
There was a problem observed where the "logger add channel" CLI command
would allow for a channel with the same name to be added multiple times.
This would result in each message being written out to the same file
multiple times.

The problem was due to the difference in how logger channel filenames
are stored versus the format they are allowed to be presented when they
are added. For instance, if adding the logger channel "foo" through the
CLI, the result would be a logger channel with the file name
/var/log/asterisk/foo being stored. So when trying to add another "foo"
channel, "foo" would not match "/var/log/asterisk/foo" so we'd happily
add the duplicate channel.

The fix presented here is to introduce two new methods in the logger
code:
 * make_filename(): given a logger channel name, this creates the
   filename for that logger channel.
 * find_logchannel(): given a logger channel name, this calls
   make_filename() and then traverses the list of logchannels in order
   to find a match.

This change has made use of make_filename() and find_logchannel()
throughout to more consistently behave.

ASTERISK-25305 #close
Reported by Mark Michelson

Change-Id: I892d52954d6007d8bc453c3cbdd9235dec9c4a36
2015-09-24 15:05:13 -05:00
Mark Michelson f42084be09 Do not swallow frames on channels leaving bridges.
When leaving a bridge, indications on a channel could be swallowed by
the internal indication logic because it appears that the channel is on
its way to be hung up anyway. One such situation where this is
detrimental is when channels on hold are redirected out of a bridge. The
AST_CONTROL_UNHOLD indication from the bridging code is swallowed,
leaving the channel in question to still appear to be on hold.

The fix here is to modify the logic inside ast_indicate_data() to not
drop the indication if the channel is simply leaving a bridge. This way,
channels on hold redirected out of a bridge revert to their expected "in
use" state after the redirection.

ASTERISK-25418 #close
Reported by Mark Michelson

Change-Id: If6115204dfa0551c050974ee138fabd15f978949
2015-09-24 15:00:27 -05:00