5 years agobridges/bridge_t38: Add a bridging module for managing T.38 state
Matt Jordan [Sat, 28 Nov 2015 14:46:02 +0000 (08:46 -0600)]
bridges/bridge_t38: Add a bridging module for managing T.38 state

When 4875e5ac32 was merged, it fixed several issues with a direct media bridge
transitioning to handling a T.38 fax. However, it uncovered a race condition
caused by the bridging core. When a channel involved in a T.38 fax leaves a
bridge, the frame queued by the channel driver that should inform the far side
that it is no longer in a T.38 fax may not make it across the bridge. The
bridging framework is *extremely* aggressive in tearing down the bridge, and
control frames that are currently in flight *may* get dropped.

This patch adds a new module to the bridging framework, bridge_t38. This module
maintains some notion of the T.38 state for the two channels in a bridge. When
the bridge detects that it is being torn down or when one of the two channels
leaves, it informs the respective channel(s) that they should stop faxing. This
ensures that channels switch back to audio if they survive and are ejected out
of a bridge while faxing.


Change-Id: If5b0bb478eb01c4607c9f4a7fc17c7957d260ea0

5 years agoMerge "res_pjsip: Use a MD5 hash for static Contact IDs"
Joshua Colp [Thu, 3 Dec 2015 21:51:56 +0000 (15:51 -0600)]
Merge "res_pjsip: Use a MD5 hash for static Contact IDs"

5 years agoMerge "res_pjsip: Update logging to show contact->uri in messages"
Joshua Colp [Thu, 3 Dec 2015 18:39:00 +0000 (12:39 -0600)]
Merge "res_pjsip:  Update logging to show contact->uri in messages"

5 years agoMerge "app_queue: Show reason of pause on CLI"
Joshua Colp [Thu, 3 Dec 2015 18:38:28 +0000 (12:38 -0600)]
Merge "app_queue: Show reason of pause on CLI"

5 years agoMerge "codec_resample: Increase buffer for Opus Codec."
Joshua Colp [Thu, 3 Dec 2015 18:38:01 +0000 (12:38 -0600)]
Merge "codec_resample: Increase buffer for Opus Codec."

5 years agores_pjsip: Use a MD5 hash for static Contact IDs
George Joseph [Thu, 3 Dec 2015 18:07:49 +0000 (11:07 -0700)]
res_pjsip: Use a MD5 hash for static Contact IDs

When 90d9a70789 was merged, it mostly tested dynamic contacts created as
a result of registering a PJSIP endpoint. Contacts generated in this
fashion typically have a long alphanumeric string as their object identifier,
which maps reasonably well for StatsD. Unfortunately, this doesn't work in the
general case. StatsD treats both '.' and ':' characters as special characters.
In particular, having a ':' appear in the middle of a StatsD metric will
result in the metric being rejected.

This causes some obvious issues with SIP URIs.

The StatsD API should not be responsible for escaping the metric name passed
to it. The metric is treated as a single long string, and it would be
challenging to know what to escape in the string passed to the function.
Likewise, we don't want to escape the metric in PJSIP, as that involves
overhead that is wasted when either res_statsd isn't loaded or enabled.

This patch takes an alternative approach. The Contact ID has been changed
to be "aor@@uri_hash" instead of "aor@@uri". This (a) won't contain any of the
aforementioned special characters, (b) can be done on Contact creation,
which has minimal impact on run-time performance, and (c) also conforms to an
earlier commit that changed the ID for dynamic contacts.

The downside of this is that StatsD users will have to map SHA1 hashes back to
the Contacts that are emitting the statistics. To that end, the CLI commands
have been updated to include the first 10 characters of the MD5 hash, which
should be enough to match what is shown in Graphite (or some other StatsD

ASTERISK-25595 #close

Change-Id: Ic674a3307280365b4a45864a3571c295b48a01e2
Reported-by: Matt Jordan
Tested-by: George Joseph

5 years agoMerge "Build System: Support include-what-you-use."
Joshua Colp [Thu, 3 Dec 2015 11:52:18 +0000 (05:52 -0600)]
Merge "Build System: Support include-what-you-use."

5 years agoMerge "res_sorcery_memory_cache.c: Fix off nominal ref leak."
Joshua Colp [Thu, 3 Dec 2015 11:51:23 +0000 (05:51 -0600)]
Merge "res_sorcery_memory_cache.c: Fix off nominal ref leak."

5 years agoMerge "sched.c: Make not return a sched id of 0."
Joshua Colp [Thu, 3 Dec 2015 11:50:50 +0000 (05:50 -0600)]
Merge "sched.c: Make not return a sched id of 0."

5 years agoMerge "Audit improper usage of scheduler exposed by 5c713fdf18f. (v13 additions)"
Joshua Colp [Thu, 3 Dec 2015 11:49:38 +0000 (05:49 -0600)]
Merge "Audit improper usage of scheduler exposed by 5c713fdf18f. (v13 additions)"

5 years agoMerge "Audit improper usage of scheduler exposed by 5c713fdf18f."
Joshua Colp [Thu, 3 Dec 2015 11:49:27 +0000 (05:49 -0600)]
Merge "Audit improper usage of scheduler exposed by 5c713fdf18f."

5 years agores_pjsip: Update logging to show contact->uri in messages
George Joseph [Tue, 1 Dec 2015 04:19:18 +0000 (21:19 -0700)]
res_pjsip:  Update logging to show contact->uri in messages

An earlier commit changed the id of dynamic contacts to contain
a hash instead of the uri.  This patch updates status change
logging to show the aor/uri instead of the id.  This required
adding the aor id to contact and contact_status and adding
uri to contact_status.  The aor id gets added to contact and
contact_status in their allocators and the uri gets added to
contact_status in pjsip_options when the contact_status is
created or updated.

ASTERISK-25598 #close

Reported-by: George Joseph
Tested-by: George Joseph

Change-Id: I56cbec1d2ddbe8461367dd8b6da8a6f47f6fe511

5 years agoUnset BRIDGEPEER when leaving a bridge
Jonathan Rose [Tue, 1 Dec 2015 22:11:07 +0000 (16:11 -0600)]
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

5 years agores_sorcery_memory_cache.c: Fix off nominal ref leak.
Richard Mudgett [Mon, 30 Nov 2015 20:22:55 +0000 (14:22 -0600)]
res_sorcery_memory_cache.c: Fix off nominal ref leak.

Change-Id: If83d63cf11cbc6df9b15251848b01feb570ade49

5 years agosched.c: Make not return a sched id of 0.
Richard Mudgett [Mon, 30 Nov 2015 22:42:47 +0000 (16:42 -0600)]
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.


Change-Id: Ib19c7ebb44ec9fd393ef6646dea806d4f34e3a20

5 years agoAudit improper usage of scheduler exposed by 5c713fdf18f. (v13 additions)
Richard Mudgett [Wed, 25 Nov 2015 18:23:47 +0000 (12:23 -0600)]
Audit improper usage of scheduler exposed by 5c713fdf18f. (v13 additions)

* Initialize mwi subscription scheduler ids earlier because of ASTOBJ to
ao2 conversion.

* Initialize register scheduler ids earlier because of ASTOBJ to ao2

* Fix more scheduler usage for the valid 0 id value.


Change-Id: If9f0e5d99638b2f9d102d1ebc9c5a14b2d706e95

5 years agoAudit improper usage of scheduler exposed by 5c713fdf18f.
Richard Mudgett [Tue, 24 Nov 2015 18:44:53 +0000 (12:44 -0600)]
Audit improper usage of scheduler exposed by 5c713fdf18f.

* Initialize struct chan_iax2_pvt scheduler ids earlier because of

* 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.

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

* Fix channel initialization of the video stream scheduler id.

* Fix channel initialization of the packet retransmission scheduler id.


Change-Id: I07a3449f728f671d326a22fcbd071f150ba2e8c8

5 years agocodec_resample: Increase buffer for Opus Codec.
Alexander Traud [Tue, 1 Dec 2015 13:55:13 +0000 (14:55 +0100)]
codec_resample: Increase buffer for Opus Codec.

ASTERISK-25599 #close

Change-Id: I1f88a88c59fb4e1e62bbdbb100c7152d48e73f10

5 years agodns: Change lookup failures from LOG_ERROR to debug 1.
George Joseph [Mon, 30 Nov 2015 17:13:35 +0000 (10:13 -0700)]
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

5 years agoBuild System: Support include-what-you-use.
Alexander Traud [Wed, 25 Nov 2015 16:42:31 +0000 (17:42 +0100)]
Build System: Support include-what-you-use.

ASTERISK-25591 #close

Change-Id: I8d3efa0826142ece9cbed2fd0d46f3b607fee6ae

5 years agoapp_queue: Show reason of pause on CLI
Rodrigo Ramírez Norambuena [Mon, 9 Nov 2015 05:49:08 +0000 (02:49 -0300)]
app_queue: Show reason of pause on CLI

Add value of pause reason when is paused on CLI command "queue show"

ASTERISK-25581 #close

Report by: Rodrigo Ramírez Norambuena

Change-Id: I887028a40cd97b350da9a3bb2719616b7fec9864

5 years agoCHANGES: Fix a typo
Niklas Larsson [Fri, 27 Nov 2015 13:39:22 +0000 (14:39 +0100)]
CHANGES: Fix a typo

Change-Id: Iceb3d9bb78140c376174a7bee197dfcf8ef9cda7

5 years agoMerge "fastagi: record file closed after sending result"
Matt Jordan [Thu, 26 Nov 2015 04:19:18 +0000 (22:19 -0600)]
Merge "fastagi: record file closed after sending result"

5 years agoMerge "main: Slight refactor of main. Improve color situation."
Matt Jordan [Thu, 26 Nov 2015 04:17:47 +0000 (22:17 -0600)]
Merge "main: Slight refactor of main. Improve color situation."

5 years agofastagi: record file closed after sending result
Kevin Harwell [Wed, 25 Nov 2015 21:26:35 +0000 (15:26 -0600)]
fastagi: record file closed after sending result

The fastagi record-file testsuite test sometimes fails reporting an empty
recorded file. This was happening because Asterisk was sending the agi result
notification prior to actually closing the file and the data, being buffered,
had not been written to the file yet when the test attempts to check the file

This patch makes it so the record file stream is closed prior to sending the
agi result notification.

ASTERISK-25593 #close

Change-Id: I6b2b3be3ae37f7c7b18e672c419a89b3b8513cde

5 years agomain: Slight refactor of main. Improve color situation.
Walter Doekes [Wed, 25 Nov 2015 19:29:55 +0000 (20:29 +0100)]
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

5 years agoMerge "Fixed some typos"
Matt Jordan [Wed, 25 Nov 2015 02:23:10 +0000 (20:23 -0600)]
Merge "Fixed some typos"

5 years agoFixed some typos
David M. Lee [Tue, 24 Nov 2015 19:54:54 +0000 (13:54 -0600)]
Fixed some typos

Fixes some minor typos in the CHANGES file, plus an embarrasing typo in
the StatsD API.

Change-Id: I9ca4858c64a4a07d2643b81baa64baebb27a4eb7

5 years agores_pjsip_notify: Fix CLI usage info
Corey Farrell [Tue, 24 Nov 2015 19:07:12 +0000 (14:07 -0500)]
res_pjsip_notify: Fix CLI usage info

The usage info for 'pjsip send notify' previously referenced the
chan_sip configuration sip_notify.conf.  Fix this to reference
the correct configuration pjsip_notify.conf.

ASTERISK-25590 #close

Change-Id: I3898271a8e8a8b1db201741e790ebe2c6bf5cdea

5 years agoMerge "translate: Provide translation modules the result of SDP negotiation."
Joshua Colp [Tue, 24 Nov 2015 14:20:46 +0000 (08:20 -0600)]
Merge "translate: Provide translation modules the result of SDP negotiation."

5 years agoMerge "res/res_endpoint_stats: Add module to emit endpoint StatsD statistics"
Matt Jordan [Tue, 24 Nov 2015 00:55:16 +0000 (18:55 -0600)]
Merge "res/res_endpoint_stats: Add module to emit endpoint StatsD statistics"

5 years agores/res_endpoint_stats: Add module to emit endpoint StatsD statistics
Matt Jordan [Wed, 18 Nov 2015 15:43:08 +0000 (09:43 -0600)]
res/res_endpoint_stats: Add module to emit endpoint StatsD statistics

This patch adds a module that emits StatsD statistics about Asterisk
endpoints. This includes:
 * A GAUGE statistic for endpoint states, tracking how many endpoints are in
   a particular state.
 * A GAUGE statistic for each endpoint, counting the number of channels
   currently associated with an endpoint.


Change-Id: If7e1333c5aeda8d136850b30c2101c0ee1c97305

5 years agores_sorcery_realtime.c: Fix crash from NULL sorcery object type.
Richard Mudgett [Mon, 23 Nov 2015 20:27:27 +0000 (14:27 -0600)]
res_sorcery_realtime.c: Fix crash from NULL sorcery object type.

If the sorcery object type is not found a NULL is returned.
Unfortunately, sorcery_realtime_filter_objectset() will crash after
complaining about not finding the object type and saying to expect errors.

* Use ao2_cleanup() instead of ao2_ref() to prevent the crash.

Reported by Corey Farrell

Change-Id: Ic3b64453ea3058cb68d5c26d97d4fe7b8eea2e97

5 years agoMerge "chan_pjsip: Handle T.38 faxes with direct media bridges"
Matt Jordan [Mon, 23 Nov 2015 19:33:04 +0000 (13:33 -0600)]
Merge "chan_pjsip: Handle T.38 faxes with direct media bridges"

5 years agoMerge "res_pjsip/pjsip_options: Add StatsD statistics for PJSIP contacts"
Matt Jordan [Mon, 23 Nov 2015 15:26:40 +0000 (09:26 -0600)]
Merge "res_pjsip/pjsip_options: Add StatsD statistics for PJSIP contacts"

5 years agores_pjsip/pjsip_options: Add StatsD statistics for PJSIP contacts
Matt Jordan [Wed, 18 Nov 2015 16:07:09 +0000 (10:07 -0600)]
res_pjsip/pjsip_options: Add StatsD statistics for PJSIP contacts

This patch adds the ability to send StatsD statistics related to the
state of PJSIP contacts. This includes:
 * A GUAGE statistic measuring the count of contacts in a particular state.
   This measures how many contacts are reachable, unreachable, etc.
 * The RTT time for each contact, if those contacts are qualified. This
   provides StatsD engines useful time-based data about each contact.


Change-Id: Ib8378d73afedfc622be0643b87c542557e0b332c

5 years agores/res_pjsip_outbound_registration: Add registration statistics for StatsD
Matt Jordan [Fri, 13 Nov 2015 16:34:03 +0000 (10:34 -0600)]
res/res_pjsip_outbound_registration: Add registration statistics for StatsD

This patch adds outbound registration statistics for StatsD. This includes
the following:
 * A GUAGE metric for the overall count of outbound registrations.
 * A GUAGE metric for each state an outbound registration can be in. As the
   outbound registrations change state, the overall count of how many
   outbound registrations are in the particular state is changed.

These statistics are particularly useful for systems with a large number of
SIP trunks, and where measuring the change in state of the trunks is useful
for monitoring.


Change-Id: Iba6ff248f5d1c1e01acbb63e9f0da1901692eb37

5 years agores_statsd: Add functions that support variable arguments
Matt Jordan [Wed, 18 Nov 2015 16:05:07 +0000 (10:05 -0600)]
res_statsd: Add functions that support variable arguments

Often, the metric names of statistics we are generating for StatsD have some
dynamic component to them. This can be the name of a particular resource, or
some internal status label in Asterisk. With the current set of functions,
callers of the statsd API must first build the metric name themselves, then
pass this to the API functions. This results in a large amount of boilerplate
code and usage of either fixed length static buffers or dynamic memory
allocation, neither of which is desireable.

This patch adds two new functions to the StatsD API that support a printf
style format specifier for constructing the metric name. A dynamic string,
allocated in threadstorage, is used to build the metric name. This eases
the burden on users of the StatsD API.

Change-Id: If533c72d1afa26d807508ea48b4d8c7b32f414ea

5 years agochan_pjsip: Handle T.38 faxes with direct media bridges
Matt Jordan [Sat, 21 Nov 2015 03:08:49 +0000 (21:08 -0600)]
chan_pjsip: Handle T.38 faxes with direct media bridges

When a channel is in a direct media bridge, a re-INVITE may arrive that forces
Asterisk to re-negotiate the media to a T.38 fax. When this occurs, the bridge
must change its technology to a simple bridge, and re-INVITE the media back
to Asterisk.

Generally, this logic mostly already exists in Asterisk. However, prior to this
patch, there were a few bugs:
(1) The T.38 framehook currently prevents a channel capable of T.38 faxes from
    ever entering into a direct media bridge. This applies even when the only
    media being passed over the channel is audio. This patch fixes this bug
    by having the framehook specify that it defers caring about any frame type.
    This allows the channels to enter into a direct media bridge, which will
    be broken when a re-INVITE is received.
(2) When a re-INVITE is received, nothing instructed the bridging layer to
    re-inspect the allowed bridging technology. This now occurs when either
    a re-INVITE is received from a peer, or when a response is received from
    the far end (that is, when the T.38 state changes to either
(3) chan_pjsip needs to do a small amount of work to prevent a direct media
    bridge from being chosen when a T.38 session is in progress. When a T.38
    session supplement has a t38 datastore - which is added when we detect
    we should start thinking about T.38 on a channel - we now refuse a native
    RTP bridge.
(4) When a BYE request is received, we don't terminate the T.38 session. If
    the other side of a T.38 fax survives the hangup (due to the 'g' flag
    in Dial, for example), we don't currently re-INVITE the media on the
    other channel back to audio. This patch now has res_pjsip_t38 intercept
    BYE requests and inform the far side that the T.38 session is terminated.
    This naturally causes the correct re-INVITEs to be sent.


Change-Id: Iabd6aa578e633d16e6b9f342091264e4324a79eb

5 years agoMerge "main/cli: Use proper string methods to check existence of context/exten/app"
Joshua Colp [Sat, 21 Nov 2015 17:36:42 +0000 (11:36 -0600)]
Merge "main/cli: Use proper string methods to check existence of context/exten/app"

5 years agoMerge "res/res_pjsip_t38: Add debug statements"
Joshua Colp [Sat, 21 Nov 2015 17:14:04 +0000 (11:14 -0600)]
Merge "res/res_pjsip_t38: Add debug statements"

5 years agoMerge "res_pjsip_outbound_registration.c: Be tolerant of short registration timeouts."
Matt Jordan [Sat, 21 Nov 2015 16:57:16 +0000 (10:57 -0600)]
Merge "res_pjsip_outbound_registration.c: Be tolerant of short registration timeouts."

5 years agomain/cli: Use proper string methods to check existence of context/exten/app
Matt Jordan [Thu, 22 Oct 2015 14:44:43 +0000 (09:44 -0500)]
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

5 years agores/res_pjsip_t38: Add debug statements
Matt Jordan [Sat, 21 Nov 2015 03:07:27 +0000 (21:07 -0600)]
res/res_pjsip_t38: Add debug statements

This patch adds some debug statements to res_pjsip_t38. These statements help
to determine which SDP negotiation callbacks are being executed, and, when
a particular callback exits, why a callback may not have applied its logic
to the local or remote SDP.

Change-Id: I61b3fb9183b7ebbb5da8e9f48b59a5d9d7042d77

5 years agoMerge "res_pjsip_outbound_registration.c: Fix 423 response handling."
Mark Michelson [Fri, 20 Nov 2015 19:03:35 +0000 (13:03 -0600)]
Merge "res_pjsip_outbound_registration.c: Fix 423 response handling."

5 years agoMerge "res_format_attr_h264: Do not reset string buffer."
Joshua Colp [Fri, 20 Nov 2015 15:20:43 +0000 (09:20 -0600)]
Merge "res_format_attr_h264: Do not reset string buffer."

5 years agoMerge "res/res_pjsip_outbound_registration: Apply configuration on object type load"
Matt Jordan [Fri, 20 Nov 2015 12:15:48 +0000 (06:15 -0600)]
Merge "res/res_pjsip_outbound_registration: Apply configuration on object type load"

5 years agoMerge "StatsD: Add sample rate compatibility"
Joshua Colp [Thu, 19 Nov 2015 16:27:07 +0000 (10:27 -0600)]
Merge "StatsD: Add sample rate compatibility"

5 years agores/res_pjsip_outbound_registration: Apply configuration on object type load
Matt Jordan [Thu, 19 Nov 2015 15:40:24 +0000 (09:40 -0600)]
res/res_pjsip_outbound_registration: Apply configuration on object type load

When Asterisk is configured to use a dynamic sorcery backend (such as
res_sorcery_astdb) with 'registration' objects, it will fail to create the
internal state objects associated with the registration objects on module
load. This is due to nothing actually querying for the specific objects
and calling their sorcery apply handler during module load.

This patch fixes that by calling get_registrations in the sorcery observer's
object_type_loaded handler. Doing this causes the sorcery backends to be
asked for the current state of all registration objects, which causes the
apply handler to be called and the internal run-time state to be created.

ASTERISK-25575 #close

Change-Id: Ie9306e797098c6d4da7bcf4a5434a15891508b23

5 years agotranslate: Provide translation modules the result of SDP negotiation.
Alexander Traud [Wed, 11 Nov 2015 12:29:24 +0000 (13:29 +0100)]
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

5 years agores_format_attr_h264: Do not reset string buffer.
Alexander Traud [Thu, 19 Nov 2015 07:03:54 +0000 (08:03 +0100)]
res_format_attr_h264: Do not reset string buffer.

When no parameter is present, Asterisk does not generate the line fmtp, as
expected. However, because a buffer was reset, even rtpmap and fmtp of previous
media codecs got removed. Now, Asterisk does not reset other codecs in case of
no parameter for H.264.

ASTERISK-25573 #close

Change-Id: I93811331f4a28c45418a9e14ee46c0debd47a286

5 years agoMerge "app_bridgeaddchan: ability to barge into existing call"
Matt Jordan [Thu, 19 Nov 2015 03:30:49 +0000 (21:30 -0600)]
Merge "app_bridgeaddchan: ability to barge into existing call"

5 years agoapp_bridgeaddchan: ability to barge into existing call
Alec Davis [Wed, 18 Nov 2015 08:25:15 +0000 (21:25 +1300)]
app_bridgeaddchan: ability to barge into existing call

To be able to barge into a call by dialling a prefix+extension that maps
to the extensions device.

Senario is that DECT headset users may be away from their desks and need
to transfer the call, the goal is that from any phone they dial a prefix
then their extension and are added to the bridge that they are in, from
there they can drop the headset call, as it's also on the handset,
and transfer the caller.

The dialplan would look like, where prefix=73, extension = 8512;
exten => _738512,1,BridgeAdd(SIP/cisco0001)

ASTERISK-25551 #close
Reported By: Alec Davis

Change-Id: I8eb5096a02168dcc8d7aeea416ef36ba4ed10540

5 years agoStatsD: Add sample rate compatibility
tcambron [Thu, 5 Nov 2015 21:37:59 +0000 (15:37 -0600)]
StatsD: Add sample rate compatibility

Implemented support for the StatsD sample rate parameter,
which is a parameter for determining when to send computed
statistics to a client.

Valid sample rate values are:
Less than or equal to 0.0 will never be sent.
Between 0.0 and 1.0 will randomly be sent.
Greater than or equal to 1.0 will always be sent.

Reported By: Ashley Sanders

Change-Id: I11d315d0a5034fffeae1178e650aa8264485ed52

5 years agores_pjsip_outbound_registration.c: Be tolerant of short registration timeouts.
Richard Mudgett [Tue, 17 Nov 2015 20:53:19 +0000 (14:53 -0600)]
res_pjsip_outbound_registration.c: Be tolerant of short registration timeouts.

Change-Id: Ie16f5053ebde0dc6507845393709b4d6a3ea526d

5 years agores_pjsip_outbound_registration.c: Fix 423 response handling.
Richard Mudgett [Tue, 17 Nov 2015 20:53:57 +0000 (14:53 -0600)]
res_pjsip_outbound_registration.c: Fix 423 response handling.

Receiving a 423 Interval Too Brief response after authentication for an
outbound registration attempt results in assuming that the registrar has
rejected the registration permanently.  If there are no configured retries
for fatal responses then the outbound registration is stopped for that

For registrations, PJSIP/PJPROJECT intercepts the handling of 423
responses and does not include any authentication in the updated
registration request.  When the updated request is challenged then the
Asterisk code assumes that we were challenged again because the peer
rejected the authentication we sent earlier.

* Made registration challenges keep track of the CSeq number to determine
if the received challenge response was for the request we thought we sent.
If the response's CSeq number differs from the CSeq number we last sent
with authentication then authenticate again because it is a challenge to a
different request.

Change-Id: I81b4bd36d1be095bab606e34b8b44e6302971b09

5 years agoMerge "res_pjsip_rfc3326.c: Fix crash when channel goes away."
Matt Jordan [Wed, 18 Nov 2015 13:33:57 +0000 (07:33 -0600)]
Merge "res_pjsip_rfc3326.c: Fix crash when channel goes away."

5 years agoapp_queue: (try_calling): mutex 'qe->chan' freed more times than we've locked!
Alec Davis [Wed, 18 Nov 2015 06:20:22 +0000 (19:20 +1300)]
app_queue: (try_calling): mutex 'qe->chan' freed more times than we've locked!

commit aae45acbd (Mark Michelson 2015-04-15 10:38:02 -0500 6525)
refer ASTERISK-24958

above commit removed ast_channel_lock(qe->chan);
but failed to remove corresponding ast_channel_unlock(qe->chan);

ASTERISK-25561 #close
Reported Alec Davis

Change-Id: Ie05f4e2d08912606178bf1fded57cc022c7a2e1a

5 years agoMerge "format: Register format-attribute module with cached formats."
Matt Jordan [Tue, 17 Nov 2015 20:35:22 +0000 (14:35 -0600)]
Merge "format: Register format-attribute module with cached formats."

5 years agoMerge "res/res_pjsip: Fix off nominal crash with requests that fail and have a timer"
Matt Jordan [Tue, 17 Nov 2015 18:59:35 +0000 (12:59 -0600)]
Merge "res/res_pjsip: Fix off nominal crash with requests that fail and have a timer"

5 years agoMerge "Confbridge: Add a user timeout option"
Joshua Colp [Tue, 17 Nov 2015 14:12:26 +0000 (08:12 -0600)]
Merge "Confbridge: Add a user timeout option"

5 years agodns: Fix pointer increment in dns_parse_answer_ex
George Joseph [Mon, 16 Nov 2015 22:10:20 +0000 (15:10 -0700)]
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

5 years agoConfbridge: Add a user timeout option
Mark Michelson [Fri, 13 Nov 2015 20:03:35 +0000 (14:03 -0600)]
Confbridge: Add a user timeout option

This option adds the ability to specify a timeout, in seconds, for a
participant in a ConfBridge. When the user's timeout has been reached,
the user is ejected from the conference with the CONFBRIDGE_RESULT
channel variable set to "TIMEOUT".

The rationale for this change is that there have been times where we
have seen channels get "stuck" in ConfBridge because a network issue
results in a SIP BYE not being received by Asterisk. While these
channels can be hung up manually via CLI/AMI/ARI, adding some sort of
automatic cleanup of the channels is a nice feature to have.

ASTERISK-25549 #close
Reported by Mark Michelson

Change-Id: I2996b6c5e16a3dda27595f8352abad0bda9c2d98

5 years agores/res_pjsip: Fix off nominal crash with requests that fail and have a timer
Matt Jordan [Mon, 16 Nov 2015 19:56:49 +0000 (13:56 -0600)]
res/res_pjsip: Fix off nominal crash with requests that fail and have a timer

When a request is sent using pjsip_endpt_send_request and fails, a condition
exists where the request wrapper, which is an AO2 object, may be de-ref'd
more times than it should. This occurs when the request's callback is called,
and, in the callback, the timer on the PJSIP heap is cancelled. When that
occurs, the request wrapper's lifetime is decremented. When
pjsip_endpt_send_request fails, we unilaterally decrement the lifetime of
the request wrapper again, even though we've already cancelled the reference
associated with the timer.

This patch checks the return result of pj_timer_heap_cancel_if_active before
removing the reference associated with the timer. We now only decrement it
in this case if a timer is cancelled as a result of the function call.

Change-Id: I21332343a1a019c1117076f9bf2df27be2850102

5 years agohashtab: Add NULL check when destroying iterator.
Joshua Colp [Sat, 14 Nov 2015 13:02:10 +0000 (09:02 -0400)]
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

5 years agores_pjsip_rfc3326.c: Fix crash when channel goes away.
Richard Mudgett [Fri, 13 Nov 2015 20:32:10 +0000 (14:32 -0600)]
res_pjsip_rfc3326.c: Fix crash when channel goes away.

If an authenticated incoming caller does not respond to our 200 OK INVITE
response with an ACK then PJSIP will hangup the call.  Unfortunately,
there is a chance that the session's channel will go away between one use
of the channel pointer and another when building the BYE request because
the BYE is being built by the monitor thread and not the call's serializer

* Added a check to ensure that the thread trying to add the Reason header
is the call's serializer thread.  This ensures that the channel will not
go away on us.

Change-Id: I866388d2b97ea2032eaae3f3ab3f1ca6cbd2df89

5 years agoTaskprocessors: Increase high-water mark
Mark Michelson [Fri, 13 Nov 2015 20:19:35 +0000 (14:19 -0600)]
Taskprocessors: Increase high-water mark

In practical tests, we have seen certain taskprocessors, specifically
Stasis subscription taskprocessors, cross the recently-added high-water
mark and emit a warning. This high-water mark warning is only intended
to be emitted when things have tanked on the system and things are
heading south quickly. In the practical tests, the Stasis taskprocessors
sometimes had a max depth of 180 tasks in them, and Asterisk wasn't in
any danger at all.

As such, this ups the high-water mark to 500 tasks instead. It also
redefines the SIP threadpool request denial number to be a multiple of
the taskprocessor high-water mark.

Change-Id: Ic8d3e9497452fecd768ac427bb6f58aa616eebce

5 years agoformat: Register format-attribute module with cached formats.
Alexander Traud [Wed, 11 Nov 2015 13:00:42 +0000 (14:00 +0100)]
format: Register format-attribute module with cached formats.

In Asterisk 13, cached formats are created before their corresponding format-
attribute module is registered. Cached formats are involved when a local
extension is called. Therefore, ast_format_generate_sdp_fmtp did not work
on local extensions. This change affects the Opus Codec, H.263 (Plus), H.264,
and format-attribute modules provided externally.

ASTERISK-25160 #close

Change-Id: I1ea1f0483e5261e2a050112e4ebdfc22057d1354

5 years agores_pjsip distributor: Don't send 503 response to responses.
Mark Michelson [Thu, 12 Nov 2015 17:17:51 +0000 (11:17 -0600)]
res_pjsip distributor: Don't send 503 response to responses.

When the SIP threadpool is backed up with tasks, we send 503 responses
to ensure that we don't try to overload ourselves. The problem is that
we were not insuring that we were not trying to send a 503 to an
incoming SIP response.

This change makes it so that we only send the 503 on incoming requests.

Change-Id: Ie2b418d89c0e453cc6c2b5c7d543651c981e1404

5 years agoMerge "res_pjsip: Deny requests when threadpool queue is backed up."
Joshua Colp [Thu, 12 Nov 2015 16:56:09 +0000 (10:56 -0600)]
Merge "res_pjsip: Deny requests when threadpool queue is backed up."

5 years agoMerge "format_cap: Don't append the 'none' format when appending all."
Matt Jordan [Thu, 12 Nov 2015 16:54:01 +0000 (10:54 -0600)]
Merge "format_cap: Don't append the 'none' format when appending all."

5 years agores_pjsip: Deny requests when threadpool queue is backed up.
Mark Michelson [Wed, 11 Nov 2015 23:11:53 +0000 (17:11 -0600)]
res_pjsip: Deny requests when threadpool queue is backed up.

We have observed situations where the SIP threadpool may become
deadlocked. However, because incoming traffic is still arriving, the SIP
threadpool's queue can continue to grow, eventually running the system
out of memory.

This change makes it so that incoming traffic gets rejected with a 503
response if the queue is backed up too much.

Change-Id: I4e736d48a2ba79fd1f8056c0dcd330e38e6a3816

5 years agoMerge "Further fixes to improper usage of scheduler"
Joshua Colp [Thu, 12 Nov 2015 13:56:36 +0000 (07:56 -0600)]
Merge "Further fixes to improper usage of scheduler"

5 years agoformat_cap: Don't append the 'none' format when appending all.
Joshua Colp [Thu, 12 Nov 2015 12:24:06 +0000 (08:24 -0400)]
format_cap: Don't append the 'none' format when appending all.

When appending all formats of a type all the codecs are iterated
and added. This operation was incorrectly adding the ast_format_none
format which is special in that it is supposed to be used when no
format is present. It shouldn't be appended.


Change-Id: I7b00f3bdf4a5f3022e483d6ece602b1e8b12827c

5 years agoFurther fixes to improper usage of scheduler
Steve Davies [Wed, 11 Nov 2015 10:16:22 +0000 (10:16 +0000)]
Further fixes to improper usage of scheduler

When ASTERISK-25449 was closed, a number of scheduler issues mentioned in
the comments were missed. These have since beed raised in ASTERISK-25476
and elsewhere.

This patch attempts to collect all of the scheduler issues discovered so
far and address them sensibly.

ASTERISK-25476 #close

Change-Id: I87a77d581e2e0d91d33b4b2fbff80f64a566d05b

5 years agothreadpool: Handle worker thread transitioning to dead when going active.
Joshua Colp [Wed, 11 Nov 2015 17:04:08 +0000 (13:04 -0400)]
threadpool: Handle worker thread transitioning to dead when going active.

This change adds handling of dead worker threads when moving them
to be active. When this happens the worker thread is removed from
both the active and idle threads container. If no threads are able
to be moved to active then the pool grows as configured.

A unit test has also been added which thrashes the idle timeout
and thread activation to exploit any race conditions between the

ASTERISK-25546 #close

Change-Id: I6c455f9a40de60d9e86458d447b548fb52ba1143

5 years agoMerge "rtp_engine: Init a format-attribute module to its RFC defaults."
Matt Jordan [Wed, 11 Nov 2015 14:19:39 +0000 (08:19 -0600)]
Merge "rtp_engine: Init a format-attribute module to its RFC defaults."

5 years agoMerge "Increase account code maximum length to 80."
Matt Jordan [Wed, 11 Nov 2015 14:09:18 +0000 (08:09 -0600)]
Merge "Increase account code maximum length to 80."

5 years agoMerge "dns: Use ntohl for ans->ttl in dns_parse_answer_ex"
Matt Jordan [Wed, 11 Nov 2015 14:09:06 +0000 (08:09 -0600)]
Merge "dns: Use ntohl for ans->ttl in dns_parse_answer_ex"

5 years agoMerge "res_pjsip_sdp_rtp: Enable Opus to be negotiated via SIP/SDP."
Matt Jordan [Wed, 11 Nov 2015 14:08:55 +0000 (08:08 -0600)]
Merge "res_pjsip_sdp_rtp: Enable Opus to be negotiated via SIP/SDP."

5 years agoMerge "ast_format_cap: Avoid format creation on module load, use cache instead."
Matt Jordan [Wed, 11 Nov 2015 14:08:02 +0000 (08:08 -0600)]
Merge "ast_format_cap: Avoid format creation on module load, use cache instead."

5 years agoMerge "xmldoc: Improve xmldoc wrapping of 'core show ...' output."
Matt Jordan [Wed, 11 Nov 2015 14:06:54 +0000 (08:06 -0600)]
Merge "xmldoc: Improve xmldoc wrapping of 'core show ...' output."

5 years agortp_engine: Init a format-attribute module to its RFC defaults.
Alexander Traud [Tue, 10 Nov 2015 15:24:31 +0000 (16:24 +0100)]
rtp_engine: Init a format-attribute module to its RFC defaults.

Previously, format-attribute modules relied on an existing fmtp line in SDP
negotiation. However, fmtp is optional for several formats like the Opus Codec.
Now, the format-attribute module is called with an empty fmtp, which allows the
module to initialise itself to RFC defaults. Furthermore now, Asterisk is able
to differentiate between internally and externally created formats.

ASTERISK-25537 #close

Change-Id: I28f680cef7fdf51c0969ff8da71548edad72ec52

5 years agoMerge "taskprocessor: Add high water mark warnings"
Joshua Colp [Wed, 11 Nov 2015 13:10:41 +0000 (07:10 -0600)]
Merge "taskprocessor: Add high water mark warnings"

5 years agoMerge "Remove ABI compatibility stub functions."
Joshua Colp [Tue, 10 Nov 2015 22:11:07 +0000 (16:11 -0600)]
Merge "Remove ABI compatibility stub functions."

5 years agoMerge "ast_format_cap_get_names: To display all formats, the buffer was increased."
Joshua Colp [Tue, 10 Nov 2015 20:58:17 +0000 (14:58 -0600)]
Merge "ast_format_cap_get_names: To display all formats, the buffer was increased."

5 years agoRemove ABI compatibility stub functions.
Corey Farrell [Tue, 10 Nov 2015 00:19:04 +0000 (19:19 -0500)]
Remove ABI compatibility stub functions.

ABI compatibility stubs existed for ast_app_separate_args and ast_verbose,
this is not needed in master.

Change-Id: I07b4d2c16079da3c2c6efa55df4a74368e0bd453

5 years agoRemove execute permission from dns_system_resolver.c
Corey Farrell [Tue, 10 Nov 2015 13:51:39 +0000 (08:51 -0500)]
Remove execute permission from dns_system_resolver.c

Change-Id: I3185735db42064bab00d3e073aed703385a00bf4

5 years agoMerge "func_callerid: Document that CALLERID(pres) is available."
Joshua Colp [Tue, 10 Nov 2015 16:04:50 +0000 (10:04 -0600)]
Merge "func_callerid: Document that CALLERID(pres) is available."

5 years agoast_format_cap_get_names: To display all formats, the buffer was increased.
Alexander Traud [Mon, 9 Nov 2015 09:01:41 +0000 (10:01 +0100)]
ast_format_cap_get_names: To display all formats, the buffer was increased.

ASTERISK-25533 #close

Change-Id: Ie1a9d1a6511b3f1a56b93d04475fbf8a4e40010a

5 years agoast_format_cap: Avoid format creation on module load, use cache instead.
Alexander Traud [Mon, 9 Nov 2015 13:04:43 +0000 (14:04 +0100)]
ast_format_cap: Avoid format creation on module load, use cache instead.

Since Asterisk 13, formats are immutable and cached. However while loading a
module like chan_sip, some formats were created instead using cached ones.

ASTERISK-25535 #close

Change-Id: I479cdc220d5617c840a98f3389b3bd91e91fbd9b

5 years agofunc_callerid: Document that CALLERID(pres) is available.
Walter Doekes [Fri, 6 Nov 2015 13:54:59 +0000 (14:54 +0100)]
func_callerid: Document that CALLERID(pres) is available.

CALLERPRES() says that it's deprecated in favor of CALLERID(num-pres)
and CALLERID(name-pres).  But for channel driver that don't make a
distinction between the two (e.g. SIP), it makes more sense to get/set
both at once.  This change reveals the availability of CALLERID(pres),

ASTERISK-25373 #close

Change-Id: I5614ae4ab7d3bbe9c791c1adf147e10de8698d7a

5 years agodocs: Fix a few typo's in app docs (more then, resourse).
Walter Doekes [Fri, 6 Nov 2015 13:52:00 +0000 (14:52 +0100)]
docs: Fix a few typo's in app docs (more then, resourse).

Change-Id: Iba57efadf6c0b822e762c7a001bc89611d98afd7

5 years agodns: Use ntohl for ans->ttl in dns_parse_answer_ex
George Joseph [Fri, 6 Nov 2015 20:19:11 +0000 (13:19 -0700)]
dns: Use ntohl for ans->ttl in dns_parse_answer_ex

dns_parse_answer_ex was not converting ans->ttl from network
by order to host byte order which was causing certain ttls
it to go negative. In turn this was causing answer edit checks
to fail.

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

Change-Id: I31505132d6321c46d2f39fd06c20ee808a864037

5 years agoxmldoc: Improve xmldoc wrapping of 'core show ...' output.
Walter Doekes [Fri, 6 Nov 2015 13:36:40 +0000 (14:36 +0100)]
xmldoc: Improve xmldoc wrapping of 'core show ...' output.

Previously, the wrapping did both lookahead and lookback, which,
together with color escape sequences, caused some lines to be wrapped
way earlier than other lines.  This led to inconsistent output.

This simplifies the wrapping code and makes it more sane: if maxcolumns
is hit, we simply jump back to the last space and wrap there.

ASTERISK-25527 #close

Change-Id: I56d01c6f9a812642b1b05535c98d4db48d17c957

5 years agores_pjsip_sdp_rtp: Enable Opus to be negotiated via SIP/SDP.
Alexander Traud [Fri, 6 Nov 2015 12:57:15 +0000 (13:57 +0100)]
res_pjsip_sdp_rtp: Enable Opus to be negotiated via SIP/SDP.

In SIP/SDP, Opus has two channels always (see RFC 7587 section 7). The actual
amount of channels is negotiated in-band. Therefore now, the Opus codec and its
attribute rtpmap are registered with two channels.

ASTERISK-24779 #close
Reported by: PowerPBX
Tested by: Alexander Traud
  asterisk-24779.patch submitted by Sean Bright (license #5060)

Change-Id: Ic7ac13cafa1d3450b4fa4987350924b42cbb657b

5 years agotaskprocessor: Add high water mark warnings
Jonathan Rose [Tue, 3 Nov 2015 22:19:43 +0000 (16:19 -0600)]
taskprocessor: Add high water mark warnings

If a taskprocessor's queue grows large, this can indicate that there
may be a problem with tasks not leaving the processor or else that
the number of available task processors for a given type of task is
too low. This patch makes it so that if a taskprocessor's task queue
grows above 100 queued tasks that it will emit a warning message.
Warning messages are emitted only once per task processor.

ASTERISK-25518 #close
Reported by: Jonathan Rose

Change-Id: Ib1607c35d18c1d6a0575b3f0e3ff5d932fd6600c

5 years agoIncrease account code maximum length to 80.
Corey Farrell [Tue, 3 Nov 2015 02:11:11 +0000 (21:11 -0500)]
Increase account code maximum length to 80.

This increases the maximum length of account code's to match
extensions.  This ensures it is always possible to set an
accountcode to ${EXTEN} without truncation.

Reported by: Ben Merrills

Change-Id: If122602304ce03362722eb213a3111b32da5eeb9

5 years agoMerge "StatsD: Add res_statsd compatibility"
Joshua Colp [Wed, 4 Nov 2015 23:47:09 +0000 (17:47 -0600)]
Merge "StatsD: Add res_statsd compatibility"

5 years agoStatsD: Add res_statsd compatibility
tcambron [Tue, 3 Nov 2015 20:36:43 +0000 (14:36 -0600)]
StatsD: Add res_statsd compatibility

Added a new api to res_statsd.c to allow it to receive a
character pointer for the value argument. This allows for a
'+' and a '-' to easily be sent with the value.

Reported By: Ashley Sanders

Change-Id: Id6bb53600943d27347d2bcae26c0bd5643567611