]> git.ipfire.org Git - thirdparty/asterisk.git/log
thirdparty/asterisk.git
9 years agochan_sip.c: fix websocket_write_timeout default value 68/1868/1
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

9 years agores_rtp_asterisk: rtp->ice check not wrapped in USE_PJPROJECT ifdef 50/1850/2
Kevin Harwell [Thu, 24 Dec 2015 16:10:53 +0000 (10:10 -0600)] 
res_rtp_asterisk: rtp->ice check not wrapped in USE_PJPROJECT ifdef

Change-Id: I19b49112e1b630bd04e859f14ccf96f8ebd6b151

9 years agoMerge "app_amd: Correct documentation to reflect functionality" into 11
Matt Jordan [Wed, 23 Dec 2015 02:22:15 +0000 (20:22 -0600)] 
Merge "app_amd: Correct documentation to reflect functionality" into 11

9 years agoapp_amd: Correct documentation to reflect functionality 44/1844/2
Dade Brandon [Mon, 21 Dec 2015 03:33:02 +0000 (19:33 -0800)] 
app_amd: Correct documentation to reflect functionality

Update documentation to reflect that maximum_number_of_words
has functionality inconsistent with the variable name (and inconsistent
with prior documentation.)

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

9 years agores_rtp_asterisk: Resolve further timing issues with DTLS negotiation 38/1838/2
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
ast_rtp_remote_address_set.

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

9 years agoapp_queue: update RT members when the 1st call joins a queue with no agents 43/1843/1
Carlos Oliva [Fri, 18 Dec 2015 15:54:41 +0000 (16:54 +0100)] 
app_queue: update RT members when the 1st call joins a queue with no agents

If a call enters on a queue and the members on that queue are updated in
realtime (ex: using mysql inserting a new agent) the queue members are
never refreshed and the call will stay in the queue until other event occurs.
This happens only if this is the first call of the queue and there is no
agents servicing.
This patch prevent this issue, ensuring realtime members are updated if
there is one call in the queue and no available agents

ASTERISK-25442 #close

Change-Id: If1e036d013a5c1d8b0bf60d71d48fe98694a8682

9 years agoMerge "AMI: Fixed OriginateResponse message" into 11
Matt Jordan [Wed, 16 Dec 2015 03:12:33 +0000 (21:12 -0600)] 
Merge "AMI: Fixed OriginateResponse message" into 11

9 years agoAMI: Fixed OriginateResponse message 16/1816/11
pchero [Wed, 9 Dec 2015 23:23:59 +0000 (00:23 +0100)] 
AMI: Fixed OriginateResponse message

When asterisk sends the OriginateResponse event message, it
doesn't send the correct information for origination to an
application.

ASTERISK-25624 #close

Change-Id: I8fb6bc533d7f812c66a24cc2b0354ddb09d0f640

9 years agores_rtp_asterisk.c: Fix DTLS negotiation delays. 13/1813/2
server-pandora [Mon, 14 Dec 2015 19:53:20 +0000 (11:53 -0800)] 
res_rtp_asterisk.c: Fix DTLS negotiation delays.

- Trigger pending DTLS packets to send out, once the RTP instance's remote
  address is set.
- Avoids locking the DTLS structure unnecessarily by only doing this if
  DTLS is passive.
- Add DTLS locks around the structurally sensitive calls in the SSL
  portion of __rtp_recvfrom, since dtls_srtp_check_pending does not lock
  inside of itself, and we're dealing with the SSL BIO in at least two
  threads.

WebRTC channels may receive a DTLS handshake before
ast_rtp_remote_address_set is called, which causes there to be a pending
response to send out.   Previous to 1ad827, this was handled by calling
dtls_srtp_check_pending on receipt of any RTP packet - a STUN or RTP
packet could trigger the pending handshake response.  Since that was
rightfully removed, whenever the DTLS handshake is received before the
remote address is set, we would have to wait until another SSL packet
arrives.

As of Chrome M47's optimizations to their handshake process, WebRTC
conversations between Chrome M47+ and Asterisk, where Asterisk is passive,
experience a 1 second delay without this patch, because the SSL handshake
is received before ICE negotation stores the remote_address, and the next
SSL packet isn't received until after a 1 second timeout in Chrome, which
causes a new handshake request.

ASTERISK-25614 #close

Change-Id: I547f1be7e302dbf71f6553dd8cbc0657b1d0b908

9 years agoMerge "main/utils: Don't emit an ERROR message if the read end of a pipe closes"...
Matt Jordan [Mon, 14 Dec 2015 12:44:58 +0000 (06:44 -0600)] 
Merge "main/utils: Don't emit an ERROR message if the read end of a pipe closes" into 11

9 years agomain/utils: Don't emit an ERROR message if the read end of a pipe closes 10/1810/3
Matt Jordan [Sun, 13 Dec 2015 19:13:55 +0000 (13:13 -0600)] 
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

9 years agochan_sip: Add TCP/TLS keepalive to TCP/TLS server 99/1799/2
Jonathan Rose [Thu, 10 Dec 2015 17:44:03 +0000 (11:44 -0600)] 
chan_sip: Add TCP/TLS keepalive to TCP/TLS server

Adds the TCP Keep Alive option to TCP and TLS server sockets. Previously
this option was only being set on session sockets.
http://www.tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/
According to the link above, the SO_KEEPALIVE option is useful for knowing
when a TCP connected endpoint has severed communication without indicating
it or has become unreachable for some reason. Without this patch, keep
alive is not set on the socket listening for incoming TCP sessions and
in Komatsu's report this resulted in the thread listening for TCP becoming
stuck in a waiting state.

ASTERISK-25364 #close
Reported by: Hiroaki Komatsu

Change-Id: I7ed7bcfa982b367dc64b4b73fbd962da49b9af36

9 years agoapp_meetme: Set default value for audio_buffers. 93/1793/2
Corey Farrell [Mon, 7 Dec 2015 19:07:32 +0000 (14:07 -0500)] 
app_meetme: Set default value for audio_buffers.

The default value was never set for audio_buffers, causing bad
audio quality.  This ensures the default is always set.

ASTERISK-25569 #close

Change-Id: I2d2ee3e644120b0f9f6ea6ab9286d7d590942a44

9 years agochan_sip: Check sip_pvt pointer in ast_channel_get_t38_state(c) 91/1791/1
Filip Jenicek [Tue, 8 Dec 2015 07:57:22 +0000 (08:57 +0100)] 
chan_sip: Check sip_pvt pointer in ast_channel_get_t38_state(c)

Asterisk may crash when calling ast_channel_get_t38_state(c)
on a locked channel which is being hung up.

ASTERISK-25609 #close

Change-Id: Ifaa707c04b865a290ffab719bd2e5c48ff667c7b

9 years agoMerge "chan_sip.c: Start ICE negotiation when response is sent or received." into 11
Joshua Colp [Wed, 9 Dec 2015 14:54:09 +0000 (08:54 -0600)] 
Merge "chan_sip.c: Start ICE negotiation when response is sent or received." into 11

9 years agochan_sip.c: Start ICE negotiation when response is sent or received. 51/1751/3
Eugene Voityuk [Wed, 2 Dec 2015 18:42:15 +0000 (20:42 +0200)] 
chan_sip.c: Start ICE negotiation when response is sent or received.

The current logic for ICE negotiation starts it
when receiving an SDP with ICE candidates. This is
incorrect as ICE negotiation can only start when each
call party have at least one pair of local and remote
candidate. Starting ICE negotiation early would result
in negotiation failure and ultimately no audio.

This change makes it so ICE negotiation is only started
when a response with SDP is received or when a response
with SDP is sent.

ASTERISK-24146

Change-Id: I55a632bde9e9827871b09141d82747e08379a8ca

9 years agoMerge "translate: Avoid a warning message when doing FEC within Opus Codec." into 11
Joshua Colp [Tue, 8 Dec 2015 19:14:36 +0000 (13:14 -0600)] 
Merge "translate: Avoid a warning message when doing FEC within Opus Codec." into 11

9 years agocodec_resample: Increase buffer for Opus Codec with FEC. 84/1784/1
Alexander Traud [Tue, 8 Dec 2015 14:39:03 +0000 (15:39 +0100)] 
codec_resample: Increase buffer for Opus Codec with FEC.

ASTERISK-25599 #close

Change-Id: Idbd187f711b2ec63dda949ca0f79aa0c1a0a0b6e

9 years agotranslate: Avoid a warning message when doing FEC within Opus Codec. 79/1779/1
Alexander Traud [Tue, 8 Dec 2015 09:46:21 +0000 (10:46 +0100)] 
translate: Avoid a warning message when doing FEC within Opus Codec.

ASTERISK-25616 #close

Change-Id: Ibe729aaf2e6e25506cff247cec5149ec1e589319

9 years agochan_sip: Fix crash involving the bogus peer during sip reload. 64/1764/2
Richard Mudgett [Fri, 4 Dec 2015 21:36:45 +0000 (15:36 -0600)] 
chan_sip: Fix crash involving the bogus peer during sip reload.

A crash happens sometimes when performing a CLI "sip reload".  The bogus
peer gets refreshed while it is in use by a new call which can cause the
crash.

* Protected the global bogus peer object with an ao2 global object
container.

ASTERISK-25610 #close

Change-Id: I5b528c742195681abcf713c6e1011ea65354eeed

9 years agoMerge "build: Fix building with newer GCC." into 11
Matt Jordan [Fri, 4 Dec 2015 17:34:26 +0000 (11:34 -0600)] 
Merge "build: Fix building with newer GCC." into 11

9 years agobuild: Fix building with newer GCC. 63/1763/2
Joshua Colp [Fri, 4 Dec 2015 14:22:08 +0000 (10:22 -0400)] 
build: Fix building with newer GCC.

Newer GCC is upset that the features flags are uninitialized.
Zero them out so it is less upset.

Change-Id: I05162699e1b36bce4145f58a63b47ad19c6975ac

9 years agoFix crash in audiohook translate to slin 62/1762/1
Joshua Colp [Fri, 4 Dec 2015 14:15:24 +0000 (10:15 -0400)] 
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

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

9 years agosched.c: Make not return a sched id of 0. 37/1737/2
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.

ASTERISK-25476

Change-Id: Ib19c7ebb44ec9fd393ef6646dea806d4f34e3a20

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

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

9 years agocodec_resample: Increase buffer for Opus Codec. 30/1730/1
Alexander Traud [Tue, 1 Dec 2015 14:13:13 +0000 (15:13 +0100)] 
codec_resample: Increase buffer for Opus Codec.

ASTERISK-25599 #close

Change-Id: I1f88a88c59fb4e1e62bbdbb100c7152d48e73f10

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

9 years agofastagi: record file closed after sending result 21/1721/1
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
size.

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

ASTERISK-25593 #close

Change-Id: I6b2b3be3ae37f7c7b18e672c419a89b3b8513cde

9 years agomain: Slight refactor of main. Improve color situation. 98/1698/6
Walter Doekes [Wed, 25 Nov 2015 19:29:30 +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.

ASTERISK-25585 #close

Change-Id: Ib641a0964c59ef9fe6f59efa8ccb481a9580c52f

9 years agohashtab: Add NULL check when destroying iterator. 32/1632/1
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

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

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

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

9 years agoFurther fixes to improper usage of scheduler 97/1597/2
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

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

9 years agortp_engine: Init a format-attribute module to its RFC defaults. 94/1594/1
Alexander Traud [Tue, 10 Nov 2015 15:29:35 +0000 (16:29 +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

9 years agofunc_callerid: Document that CALLERID(pres) is available. 84/1584/3
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),
CONNECTEDLINE(pres), REDIRECTING(orig-pres), REDIRECTING(to-pres) and
REDIRECTING(from-pres).

ASTERISK-25373 #close

Change-Id: I5614ae4ab7d3bbe9c791c1adf147e10de8698d7a

9 years agodocs: Fix a few typo's in app docs (more then, resourse). 79/1579/2
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

9 years agoxmldoc: Improve xmldoc wrapping of 'core show ...' output. 76/1576/1
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

9 years agoFix cli display of build options. 65/1565/1
Corey Farrell [Wed, 4 Nov 2015 14:25:52 +0000 (09:25 -0500)] 
Fix cli display of build options.

A previous commit reduced the AST_BUILDOPTS compiler define to
only include options that affected ABI.  This included some options
that were previously displayed by cli "core show settings".  This
change corrects the CLI display while still restricting buildopts.h
to ABI effecting options only.

ASTERISK-25434 #close
Reported by: Rusty Newton

Change-Id: Id07af6bedd1d7d325878023e403fbd9d3607e325

9 years agoMerge "build: GCC 5.1.x catches some new const, array bounds and missing paren issues...
Joshua Colp [Mon, 26 Oct 2015 16:27:44 +0000 (11:27 -0500)] 
Merge "build: GCC 5.1.x catches some new const, array bounds and missing paren issues" into 11

9 years agobuild: GCC 5.1.x catches some new const, array bounds and missing paren issues 25/1525/1
George Joseph [Sat, 24 Oct 2015 18:08:41 +0000 (12:08 -0600)] 
build: GCC 5.1.x catches some new const, array bounds and missing paren issues

Fixed 1 issue in each of the affected files.

ASTERISK-25494 #close
Reported-by: George Joseph
Tested-by: George Joseph
Change-Id: I818f149cd66a93b062df421e1c73c7942f5a4a77

9 years agoformat: Update the maximum packetization time for iLBC 30. 63/1463/2
Alexander Traud [Wed, 21 Oct 2015 13:06:29 +0000 (15:06 +0200)] 
format: Update the maximum packetization time for iLBC 30.

In September 2006, the maximum packetization time (ptime) were set to such a
low value, packetization was disabled for many codecs actually. This was fixed
for many codecs but not for iLBC 30. This enables packetization for iLBC which
can be enabled for example via allow=ilbc:60,gsm,alaw,ulaw in the file sip.conf.

ASTERISK-7803

Change-Id: I3ac61235097808216b6a15a1c7e321b3fdeb7ff1

9 years agoMerge topic 'ASTERISK-25461' into 11
Matt Jordan [Fri, 16 Oct 2015 15:35:53 +0000 (10:35 -0500)] 
Merge topic 'ASTERISK-25461' into 11

* changes:
  config.c: Fix off-nominal memory leak.
  config.c: Fix potential memory corruption after [section](+).
  config.c: Fix #include after [section](+).

9 years agoMerge "res_config_pgsql.c: Fix deadlock loading realtime configuration." into 11
Joshua Colp [Thu, 15 Oct 2015 19:41:46 +0000 (14:41 -0500)] 
Merge "res_config_pgsql.c: Fix deadlock loading realtime configuration." into 11

9 years agoMerge "Build: Add menuselect options for using compiler sanitizers" into 11
Joshua Colp [Thu, 15 Oct 2015 19:40:41 +0000 (14:40 -0500)] 
Merge "Build: Add menuselect options for using compiler sanitizers" into 11

9 years agores_config_pgsql.c: Fix deadlock loading realtime configuration. 39/1439/1
Richard Mudgett [Wed, 14 Oct 2015 19:15:53 +0000 (14:15 -0500)] 
res_config_pgsql.c: Fix deadlock loading realtime configuration.

On v13, loading several thousand PJSIP endpoints on Asterisk start causes
a deadlock most of the time.

Thanks to mdu113 for discovering that there was a call to pgsql_exec() not
protected by the pgsql_lock reentrancy lock.

{quote}
I believe a code path exists that attempts to use pgsql connection without
locking pgsql_lock.  I believe what happens during that deadlock that I
see is two concurrent threads are both attempting to send query to pgsql,
one of the thread is using a code path without locking pgsql_lock.  If
they managed to send queries at the same time, it seems postgres ignores
one of the queries and replies only to the one of them.  If it happens so
that the thread holding the lock didn't receive the reply it will wait for
it (and hold the lock) forever (or at least for very long time), thus
completely blocking all access to db.
{quote}

* Added missing reentrancy locking around pgsql_exec() in find_table().

* Moved unlock of pgsql_lock in unload_module() to avoid locking inversion
between the psql_tables list lock and the pgsql_lock.

ASTERISK-25455 #close
Reported by:  mdu113
Patches:
      res_config_pgsql.c-connlock2.diff (license #5543) patch uploaded by mdu113

Change-Id: Id9e7cdf8a3b65ff19964b0cf942ace567938c4e2

9 years agochannels/chan_sip: Set cause code to 44 on RTP timeout 32/1432/1
Matt Jordan [Tue, 13 Oct 2015 19:13:54 +0000 (14:13 -0500)] 
channels/chan_sip: Set cause code to 44 on RTP timeout

To quote Olle:

"When issuing a hangup due to RTP timeouts the cause code is not set. I have
selected 44 based on Cisco's implementation..."

ASTERISK-25135 #close
Reported by: Olle Johansson
patches:
  rtp-timeout-cause-1.8.diff uploaded by Olle Johansson (License 5267)

Change-Id: Ia62100c55077d77901caee0bcae299f8dc7375fc

9 years agoconfig.c: Fix off-nominal memory leak. 21/1421/1
Richard Mudgett [Mon, 12 Oct 2015 16:21:39 +0000 (11:21 -0500)] 
config.c: Fix off-nominal memory leak.

Change-Id: I06e346e9a5c63cc5071e7eda537310c4b43bffe0

9 years agoconfig.c: Fix potential memory corruption after [section](+). 20/1420/1
Richard Mudgett [Mon, 12 Oct 2015 16:20:29 +0000 (11:20 -0500)] 
config.c: Fix potential memory corruption after [section](+).

The memory corruption could happen if the [section](+) is the last section
in the file with trailing comments.  In this case process_text_line() has
left *last_cat is set to newcat and newcat is destroyed.

Change-Id: I0d1d999f553986f591becd000e7cc6ddfb978d93

9 years agoconfig.c: Fix #include after [section](+). 19/1419/1
Richard Mudgett [Mon, 12 Oct 2015 16:21:55 +0000 (11:21 -0500)] 
config.c: Fix #include after [section](+).

An #include right after a [section](+) would associate any variable
assignments before a new section in the #include with the wrong section.

* Fix section association by setting the current section to the appended
section.

* Fix '+' and '!' section flag interaction corner case depending upon
which flag came first.  If the '!' came first then it would be ignored.
If the '!' came after then it would affect the appended section.  The '!'
will now no longer be ignored.

ASTERISK-25461 #close
Reported by: Sean Pimental

Change-Id: Ic9d3191c8758048e2cbce6432f854b32531731c3

9 years agoBuild: Add menuselect options for using compiler sanitizers 17/1417/1
Ivan Poddubny [Sat, 10 Oct 2015 20:20:55 +0000 (23:20 +0300)] 
Build: Add menuselect options for using compiler sanitizers

This patch adds menuselect options for building Asterisk with
various sanitizers provided by gcc and clang.

When one of *SANITIZER flags is set in menuselect, the appropriate
option is added to CFLAGS ad LDFLAGS for the build.

Information on sanitizers in the project wiki:
https://github.com/google/sanitizers/wiki

GCC Manual:
https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html

Clang Compiler User's Manual:
http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation

ASTERISK-24718 #close
Reported by: Badalian Vyacheslav

Change-Id: Iafa51b792b7bcb20e848b99d16cf362d08590fa0

9 years agofunc_presencestate: Return "not_set" when no data is set in AstDB 10/1410/1
Ivan Poddubny [Wed, 7 Oct 2015 06:24:31 +0000 (09:24 +0300)] 
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

9 years agores/res_rtp_asterisk: Fix assignment after ao2 decrement 01/1401/1
Matt Jordan [Wed, 7 Oct 2015 01:43:58 +0000 (20:43 -0500)] 
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 60a9172d7ef2 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

9 years agochan_sip: Fix port parsing for IPv6 addresses in SIP Via headers. 91/1391/2
Florian Sauerteig [Tue, 6 Oct 2015 17:40:22 +0000 (19:40 +0200)] 
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

9 years agoFix improper usage of scheduler exposed by 5c713fdf18f 84/1384/2
Matt Jordan [Tue, 6 Oct 2015 02:34:41 +0000 (21:34 -0500)] 
Fix improper usage of scheduler exposed by 5c713fdf18f

When 5c713fdf18f 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

9 years agomanager: Fix GetConfigJSON returning invalid JSON 72/1372/1
Ivan Poddubny [Sat, 3 Oct 2015 11:27:27 +0000 (14:27 +0300)] 
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 [].

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

Change-Id: Ibbe93c6a227dff14d4a54b0d152341857bcf6ad8

9 years agoMerge "sched.c: Add warning about negative time interval request." into 11
Joshua Colp [Fri, 2 Oct 2015 21:27:02 +0000 (16:27 -0500)] 
Merge "sched.c: Add warning about negative time interval request." into 11

9 years agosched.c: Add warning about negative time interval request. 49/1349/1
Richard Mudgett [Mon, 28 Sep 2015 20:31:38 +0000 (15:31 -0500)] 
sched.c: Add warning about negative time interval request.

Change-Id: Ib91435fb45b7f5f7c0fc83d0eec20b88098707bc

9 years agores_rtp_asterisk: Move "Set role" warning to be debug. 46/1346/1
Joshua Colp [Wed, 30 Sep 2015 18:42:40 +0000 (15:42 -0300)] 
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

9 years agoMerge "channel.c: Fix NewCallerid AMI event not been sent on Caller ID change" into 11
Matt Jordan [Tue, 29 Sep 2015 02:05:18 +0000 (21:05 -0500)] 
Merge "channel.c: Fix NewCallerid AMI event not been sent on Caller ID change" into 11

9 years agochannel.c: Fix NewCallerid AMI event not been sent on Caller ID change 34/1334/3
Ivan Poddubny [Mon, 28 Sep 2015 06:36:30 +0000 (09:36 +0300)] 
channel.c: Fix NewCallerid AMI event not been sent on Caller ID change

Currently, NewCallerid is sent only when pointers to number or name
strings change, which is not always the case. The newly allocated string
may use the same memory, so pointers match, while the content
is different. As a result, Caller ID updates are often not reported.

With this patch, actual strings are compared, not the pointers.

ASTERISK-25427 #close
Reported by: Ivan Poddubny

Change-Id: I2a1ac3a842f0e092c6058d1cd3e35443bece1b36

9 years agoMerge "translate: Fix transcoding while different in frame size." into 11
Matt Jordan [Mon, 28 Sep 2015 16:20:38 +0000 (11:20 -0500)] 
Merge "translate: Fix transcoding while different in frame size." into 11

9 years agocore/logging: Fix logging to more than one syslog channel 93/1293/1
Elazar Broad [Mon, 21 Sep 2015 13:16:46 +0000 (09:16 -0400)] 
core/logging: Fix logging to more than one syslog channel

Currently, Asterisk will log to the last configured syslog
channel in logger.conf. This is due to the fact that the
final call to openlog() supersedes all of the previous calls.
This commit removes the call to openlog() and passes the
facility to ast_log_vsyslog(), along with utilizing the
LOG_MAKEPRI macro to ensure that the message is routed to
the correct facility and with the correct priority.

ASTERISK-25407 #close
Reported by: Elazar Broad
Tested by: Elazar Broad

Change-Id: Ie2a2416bc00cce1b04e99ef40917c2011953ddd2

9 years agoMerge "app_record: RECORDED_FILE variable not being populated" into 11
Matt Jordan [Tue, 22 Sep 2015 12:40:29 +0000 (07:40 -0500)] 
Merge "app_record: RECORDED_FILE variable not being populated" into 11

9 years agoMerge "pbx: Update device and presence state when changing a hint extension." into 11
Joshua Colp [Tue, 22 Sep 2015 10:29:42 +0000 (05:29 -0500)] 
Merge "pbx: Update device and presence state when changing a hint extension." into 11

9 years agoapp_record: RECORDED_FILE variable not being populated 91/1291/1
Kevin Harwell [Mon, 21 Sep 2015 23:06:15 +0000 (18:06 -0500)] 
app_record: RECORDED_FILE variable not being populated

The RECORDED_FILE variable is empty unless a '%d' is specified in the filename.
This patch makes it so the variable is always set to the filename.

ASTERISK-25410 #close

Change-Id: I4ec826d8eb582ae2ad184e717be8668b74d37653

9 years agopbx: Update device and presence state when changing a hint extension. 62/1262/3
Joshua Colp [Wed, 16 Sep 2015 13:22:35 +0000 (10:22 -0300)] 
pbx: Update device and presence state when changing a hint extension.

When changing a hint extension without removing the hint first the
device state and presence state is not updated. This causes the state
of the hint to be that of the previous extension and not the current
one. This state is kept until a state change occurs as a result of
something (presence state change, device state change).

This change updates the hint with the current device and presence
state of the new extension when it is changed. Any state callbacks
which may have been added before the hint extension is changed are
also informed of the new device and presence state if either have
changed.

ASTERISK-25394 #close

Change-Id: If268f1110290e502c73dd289c9e7e7b27bc8432f

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

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

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

ASTERISK-25396 #close

Change-Id: I33632baf024f01b6a00f8c7f35c91e5f68c40260

9 years agotranslate: Fix transcoding while different in frame size. 56/1156/5
Alexander Traud [Fri, 28 Aug 2015 21:06:02 +0000 (23:06 +0200)] 
translate: Fix transcoding while different in frame size.

When Asterisk translates between codecs each with a different frame size (for
example between iLBC 30 and Speex-WB), too large frames were created by
ast_trans_frameout. Now, ast_trans_frameout is called with the correct frame
length, creating several frames when necessary. Affects all transcoding modules
which used ast_trans_frameout: GSM, iLBC, LPC10, and Speex.

ASTERISK-25353 #close

Change-Id: I84b59f7a745955820f10e20f5999eb69495a68b9

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

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

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

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

Change-Id: I532708eef8f669d823457d7fefdad9a6078b99b2

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

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

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

ASTERISK-25227 #close
Reported by: Alexandr Dranchuk

Change-Id: I326ad13cb1db9a72b3fd902bafed3c28a3684203

9 years agoMerge "res_rtp_asterisk: Add more ICE debugging" into 11
Matt Jordan [Tue, 8 Sep 2015 21:41:52 +0000 (16:41 -0500)] 
Merge "res_rtp_asterisk: Add more ICE debugging" into 11

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

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

Change-Id: I950c6d8f13a41f14b3d6334b4cafe7d4e997be80

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

pthread_attr_init() defaults to PTHREAD_EXPLICIT_SCHED on FreeBSD
too.

ASTERISK-25310 #close
Reported by: Guido Falsi

Change-Id: Iae6befac9028b5b9795f86986a4a08a1ae6ab7c4

9 years ago chan_ooh323: call ast_rtp_instance_stop on ooh323_destroy 09/1209/1
Alexander Anikin [Mon, 7 Sep 2015 18:19:41 +0000 (22:19 +0400)] 
chan_ooh323: call ast_rtp_instance_stop on ooh323_destroy

    Call ast_rtp_instance_stop on ooh323_destroy to free resources
    allocated by rtp instance

    ASTERISK-25299 #close
    Report by: Alexandr Dranchuk

Change-Id: I455096bd7da016b871afe90af86067c2c7c9f33f

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

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

Change-Id: I0303d8e1ecb20a8de9fe629a3209d216c4028378

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

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

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

ASTERISK-25346 #close

Change-Id: I00ac2c269cee9e29586ee2c65e83c70e52a02cff

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

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

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

ASTERISK-25331 #close
Reported by: Kevin Harwell

Change-Id: I90efaf6a01914fea03f21e5cdbd91c348f44b0ec

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

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

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

NOTE: This may fix a consistency issue with realtime ringinuse
because the ordering of things was backported from v13.  It is
similar to how set_member_paused() treats realtime for paused.

Change-Id: Iecc1f4119c63347341d7ea6b65f5fc4963706306

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

Change-Id: I7294e13d27875851c2f4ef6818adba507509d224

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

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

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

NOTE: This may fix a consistency issue with the realtime paused setting
since how the value is set is controlled by set_member_paused() which
treats realtime a little better.

* Update QUEUE_MEMBER XML documentation.

* Fix error checking in QUEUE_MEMBER() write.

ASTERISK-25215 #close
Reported by: Lorne Gaetz

Change-Id: I3a016be8dc94d63a9cc155295ff9c9afa5f707cb

9 years agoMerge "chan_sip.c: wrong peer searched in sip_report_security_event" into 11
Mark Michelson [Thu, 13 Aug 2015 21:11:24 +0000 (16:11 -0500)] 
Merge "chan_sip.c: wrong peer searched in sip_report_security_event" into 11

9 years agochan_sip.c: wrong peer searched in sip_report_security_event 77/1077/3
Kevin Harwell [Wed, 12 Aug 2015 17:59:53 +0000 (12:59 -0500)] 
chan_sip.c: wrong peer searched in sip_report_security_event

In chan_sip, after handling an incoming invite a security event is raised
describing authorization (success, failure, etc...). However, it was doing
a lookup of the peer by extension. This is fine for register messages, but
in the case of an invite it may search and find the wrong peer, or a non
existent one (for instance, in the case of call pickup). Also, if the peers
are configured through realtime this may cause an unnecessary database lookup
when caching is enabled.

This patch makes it so that sip_report_security_event searches by IP address
when looking for a peer instead of by extension after an invite is processed.

ASTERISK-25320 #close

Change-Id: I9b3f11549efb475b6561c64f0e6da1a481d98bc4

9 years agoMerge "res_http_websocket: Forcefully terminate on write errors." into 11
Joshua Colp [Wed, 12 Aug 2015 18:43:11 +0000 (13:43 -0500)] 
Merge "res_http_websocket: Forcefully terminate on write errors." into 11

9 years agochan_dahdi.c: Flush the DAHDI write buffer after starting DTMF. 62/1062/1
Richard Mudgett [Mon, 10 Aug 2015 18:43:19 +0000 (13:43 -0500)] 
chan_dahdi.c: Flush the DAHDI write buffer after starting DTMF.

Pressing DTMF digits on a phone to go out on a DAHDI channel can result in
the digit not being recognized or even heard by the peer.

Phone -> Asterisk -> DAHDI/channel

Turns out the DAHDI behavior with DTMF generation (and any other generated
tones) is exposed by the "buffers=" setting in chan_dahdi.conf.  When
Asterisk requests to start sending DTMF then DAHDI waits until its write
buffer is empty before generating any samples for the DTMF tones.  When
Asterisk subsequently requests DAHDI to stop sending DTMF then DAHDI
immediately stops generating the DTMF samples.  As a result, the more
samples there are in the DAHDI write buffer the shorter the time DTMF
actually gets sent on the wire.  If there are more samples in the write
buffer than the time DTMF is supposed to be sent then no DTMF gets sent on
the wire.  With the "buffers=12,half" setting and each buffer representing
20 ms of samples then the DAHDI write buffer is going to contain around
120 ms of samples.  For DTMF to be recognized by the peer the actual sent
DTMF duration needs to be a minimum of 40 ms.  Therefore, the intended
duration needs to be a minimum of 160 ms for the peer to receive the
minimum DTMF digit duration to recognize it.

A simple and effective solution to work around the DAHDI behavior is for
Asterisk to flush the DAHDI write buffer when sending DTMF so the full
duration of DTMF is actually sent on the wire.  When someone is going to
send DTMF they are not likely to be talking before sending the tones so
the flushed write samples are expected to just contain silence.

* Made dahdi_digit_begin() flush the DAHDI write buffer after requesting
to send a DTMF digit.

ASTERISK-25315 #close
Reported by John Hardin

Change-Id: Ib56262c708cb7858082156bfc70ebd0a220efa6a

9 years agochan_dahdi.c: Lock private struct for ast_write(). 61/1061/1
Richard Mudgett [Wed, 5 Aug 2015 19:21:50 +0000 (14:21 -0500)] 
chan_dahdi.c: Lock private struct for ast_write().

There is a window of opportunity for DTMF to not go out if an audio frame
is in the process of being written to DAHDI while another thread starts
sending DTMF.  The thread sending the audio frame could be past the
currently dialing check before being preempted by another thread starting
a DTMF generation request.  When the thread sending the audio frame
resumes it will then cause DAHDI to stop the DTMF tone generation.  The
result is no DTMF goes out.

* Made dahdi_write() lock the private struct before writing to the DAHDI
file descriptor.

ASTERISK-25315
Reported by John Hardin

Change-Id: Ib4e0264cf63305ed5da701188447668e72ec9abb

9 years agores_http_websocket: Forcefully terminate on write errors. 72/1072/1
Joshua Colp [Tue, 11 Aug 2015 10:24:30 +0000 (07:24 -0300)] 
res_http_websocket: Forcefully terminate on write errors.

The res_http_websocket module will currently attempt to close
the WebSocket connection if fatal cases occur, such as when
attempting to write out data and being unable to. When the
fatal cases occur the code attempts to write a WebSocket close
frame out to have the remote side close the connection. If
writing this fails then the connection is not terminated.

This change forcefully terminates the connection if the
WebSocket is to be closed but is unable to send the close frame.

ASTERISK-25312 #close

Change-Id: I10973086671cc192a76424060d9ec8e688602845

9 years agoReplace htobe64 with htonll 50/1050/1
David M. Lee [Sat, 8 Aug 2015 03:11:03 +0000 (22:11 -0500)] 
Replace htobe64 with htonll

We don't have a compatability function to fill in a missing htobe64; but
we already have one for the identical htonll.

Change-Id: Ic0a95db1c5b0041e14e6b127432fb533b97e4cac

10 years agores_rtp_asterisk: Don't leak temporary key when enabling PFS. 35/1035/2
Joshua Colp [Wed, 5 Aug 2015 10:23:21 +0000 (07:23 -0300)] 
res_rtp_asterisk: Don't leak temporary key when enabling PFS.

A change recently went in which enabled perfect forward secrecy for
DTLS in res_rtp_asterisk. This was accomplished two different ways
depending on the availability of a feature in OpenSSL. The fallback
method created a temporary instance of a key but did not free it.
This change fixes that.

ASTERISK-25265

Change-Id: Iadc031b67a91410bbefb17ffb4218d615d051396

10 years agores/res_rtp_asterisk: Add ECDH support 29/1029/2
Mark Duncan [Tue, 28 Jul 2015 10:33:39 +0000 (19:33 +0900)] 
res/res_rtp_asterisk: Add ECDH support

This will add ECDH support to Asterisk. It will
detect auto ECDH support in OpenSSL
(1.0.2b and above) during ./configure. If this is
available, it will use it,
otherwise it will fall back to prime256v1 (this
behavior is consistent with
other projects such as Apache and nginx).

This fixes WebRTC being broken in Firefox 38+ due
to Firefox now only supporting
ciphers with perfect forward secrecy.

ASTERISK-25265 #close

Change-Id: I8c13b33a2a79c0bde2e69e4ba6afa5ab9351465b

10 years agochan_sip.c: Move NULL check to where it will do some good. 99/999/1
Richard Mudgett [Tue, 21 Jul 2015 20:41:29 +0000 (15:41 -0500)] 
chan_sip.c: Move NULL check to where it will do some good.

v11 only fix.

Change-Id: I340512f86cfd3a6f7703971fa8acfffc7d47132b

10 years agortp_engine.c: Fix off nominal ref leak and some minor tweaks. 98/998/1
Richard Mudgett [Fri, 17 Jul 2015 20:54:37 +0000 (15:54 -0500)] 
rtp_engine.c: Fix off nominal ref leak and some minor tweaks.

v11 only fix.

Change-Id: I97885946ebc7eda19f1c18d08698117cf6a7f14f

10 years agortp_engine.c: Tweak glue->update_peer() parameter nil value. 97/997/1
Richard Mudgett [Thu, 16 Jul 2015 22:40:18 +0000 (17:40 -0500)] 
rtp_engine.c: Tweak glue->update_peer() parameter nil value.

Change glue->update_peer() parameter from 0 to NULL to better indicate it
is a pointer.

Change-Id: Iefbf9d4a708f2b64b7ad2b4e6c33bfaa12ccfa9d

10 years agochan_sip.c: Tweak glue->update_peer() parameter nil value. 96/996/1
Richard Mudgett [Fri, 17 Jul 2015 21:23:53 +0000 (16:23 -0500)] 
chan_sip.c: Tweak glue->update_peer() parameter nil value.

Change glue->update_peer() parameter from 0 to NULL to better indicate it
is a pointer.

Change-Id: I8ff2e5087f0e19f6998e3488a712a2470cc823bd

10 years agores_http_websocket: Properly encode 64 bit payload 92/992/1
Mark Michelson [Wed, 29 Jul 2015 19:35:58 +0000 (14:35 -0500)] 
res_http_websocket: Properly encode 64 bit payload

A test agent was continuously failing all ARI tests when run against
Asterisk 13. As it turns out, the reason for this is that on those test
runs, for some reason we decided to use the super extended 64 bit
payload length for websocket text frames instead of the extended 16 bit
payload length. For 64-bit payloads, the expected byte order over the
network is

7, 6, 5, 4, 3, 2, 1, 0

However, we were sending the payload as

3, 2, 1, 0, 7, 6, 5, 4

This meant that we were saying to expect an absolutely MASSIVE payload
to arrive. Since we did not follow through on this expected payload
size, the client would sit patiently waiting for the rest of the payload
to arrive until the test would time out.

With this change, we use the htobe64() function instead of htonl() so
that a 64-bit byte-swap is performed instead of a 32 bit byte-swap.

Change-Id: Ibcd8552392845fbcdd017a8c8c1043b7fe35964a

10 years agoLocal channels: Alternate solution to ringback problem. 55/955/2
Mark Michelson [Thu, 23 Jul 2015 18:11:42 +0000 (13:11 -0500)] 
Local channels: Alternate solution to ringback problem.

Commit 54b25c80c8387aea9eb20f9f4f077486cbdf3e5d solved an issue where a
specific scenario involving local channels and a native local RTP bridge
could result in ringback still being heard on a calling channel even
after the call is bridged.

That commit caused many tests in the testsuite to fail with alarming
consequences, such as not sending DialBegin and DialEnd events, and
giving incorrect hangup causes during calls.

This commit reverts the previous commit and implements and alternate
solution. This new solution involves only passing AST_CONTROL_RINGING
frames across local channels if the local channel is in AST_STATE_RING.
Otherwise, the frame does not traverse the local channels. By doing
this, we can ensure that a playtones generator does not get started on
the calling channel but rather is started on the local channel on which
the ringing frame was initially indicated.

ASTERISK-25250 #close
Reported by Etienne Lessard

Change-Id: I3bc87a18a38eb2b68064f732d098edceb5c19f39