5 years agobuild: Fix ast_sockaddr initialization to be more portable
George Joseph [Thu, 9 Jun 2016 14:20:33 +0000 (08:20 -0600)]
build:  Fix ast_sockaddr initialization to be more portable

A change to glibc 2.22 changed the order of the sockadddr_storage
members which caused the places where we do an initialization of
ast_sockaddr with '{ { 0, 0, } }' to fail compilation.  Those
initializers (which we shouldn't have been using anyway) have been
replaced with memsets.

Change-Id: Idd1b3b320903d8771bfe221f0b015685de628fa4

5 years agoMerge "translate: Enables native Packet-Loss Concealment (PLC) for supporting codecs."
Joshua Colp [Thu, 9 Jun 2016 12:24:46 +0000 (07:24 -0500)]
Merge "translate: Enables native Packet-Loss Concealment (PLC) for supporting codecs."

5 years agoMerge "chan_sip: No rtpmap for static RTP payload IDs in SDP."
Joshua Colp [Thu, 9 Jun 2016 09:40:43 +0000 (04:40 -0500)]
Merge "chan_sip: No rtpmap for static RTP payload IDs in SDP."

5 years agoMerge "BuildSystem: Avoid 'ar cru' and use 'ar cr' instead."
Joshua Colp [Thu, 9 Jun 2016 09:40:37 +0000 (04:40 -0500)]
Merge "BuildSystem: Avoid 'ar cru' and use 'ar cr' instead."

5 years agoMerge "Detect and use proper libraries for musl toolchains"
Joshua Colp [Thu, 9 Jun 2016 09:40:30 +0000 (04:40 -0500)]
Merge "Detect and use proper libraries for musl toolchains"

5 years agoMerge "Fixes to include signal.h"
Joshua Colp [Thu, 9 Jun 2016 09:40:24 +0000 (04:40 -0500)]
Merge "Fixes to include signal.h"

5 years agoMerge "Make use of GLOB_BRACE and GLOB_NOMAGIC optional"
Joshua Colp [Thu, 9 Jun 2016 09:40:14 +0000 (04:40 -0500)]
Merge "Make use of GLOB_BRACE and GLOB_NOMAGIC optional"

5 years agoMerge "res_hep_{pjsip|rtcp}: Decline module loads if res_hep had not loaded"
Joshua Colp [Wed, 8 Jun 2016 22:17:38 +0000 (17:17 -0500)]
Merge "res_hep_{pjsip|rtcp}: Decline module loads if res_hep had not loaded"

5 years agoMerge "Fix res_search usage"
Joshua Colp [Wed, 8 Jun 2016 19:43:35 +0000 (14:43 -0500)]
Merge "Fix res_search usage"

5 years agoMerge "Fix #include poll.h and sys/cdefs.h"
Joshua Colp [Wed, 8 Jun 2016 19:43:13 +0000 (14:43 -0500)]
Merge "Fix #include poll.h and sys/cdefs.h"

5 years agoDetect and use proper libraries for musl toolchains
Timo Teräs [Fri, 3 Jun 2016 05:59:30 +0000 (08:59 +0300)]
Detect and use proper libraries for musl toolchains

Change-Id: I8d9b212f70813404b82918a3f99439e500d4bfcb

5 years agoFixes to include signal.h
Timo Teräs [Fri, 3 Jun 2016 05:57:02 +0000 (08:57 +0300)]
Fixes to include signal.h

POSIX defines signal.h. sys/signal.h should not be used as it is
c-library internal header which may or may not exist. Notably with
musl it generates warning of being incorrect.

Change-Id: Ia56b0aa1d84b5c590114867b1b384a624f39a6fc

5 years agores_hep_{pjsip|rtcp}: Decline module loads if res_hep had not loaded
Matt Jordan [Wed, 8 Jun 2016 17:26:29 +0000 (12:26 -0500)]
res_hep_{pjsip|rtcp}: Decline module loads if res_hep had not loaded

A crash can occur in res_hep_pjsip or res_hep_rtcp if res_hep has not
loaded and does not have a configuration file. Previously when this
occurred, checks were put in to see if the configuration was loaded
successfully. While this is a good idea - and has been added to the
offending function in res_hep - the reality is res_hep_pjsip and
res_hep_rtcp have no business running if res_hep isn't also running.

As such, this patch also adds a function to res_hep that returns whether
or not it successfully loaded. Oddly enough, ast_module_check returns
"everything is peachy" even if a module declined its load - so it cannot
be solely relied on. res_hep_pjsip and res_hep_rtcp now also check this
function to see if they should continue to load; if it fails, they
decline their load as well.

ASTERISK-26096 #close

Change-Id: I007e535fcc2e51c2ca48534f48c5fc2ac38935ea

5 years agoMerge "chan_rtp.c: Simplify options to UnicastRTP channel creation."
Joshua Colp [Wed, 8 Jun 2016 10:13:59 +0000 (05:13 -0500)]
Merge "chan_rtp.c: Simplify options to UnicastRTP channel creation."

5 years agoMerge "apps/app_voicemail.c and main/say.c: Add support for Icelandic language"
Joshua Colp [Wed, 8 Jun 2016 10:13:52 +0000 (05:13 -0500)]
Merge "apps/app_voicemail.c and main/say.c: Add support for Icelandic language"

5 years agoMerge "ari/resource_channels: Add 'formats' to channel create/originate"
Joshua Colp [Wed, 8 Jun 2016 10:13:37 +0000 (05:13 -0500)]
Merge "ari/resource_channels:  Add 'formats' to channel create/originate"

5 years agochan_sip: No rtpmap for static RTP payload IDs in SDP.
Alexander Traud [Wed, 8 Jun 2016 07:11:40 +0000 (09:11 +0200)]
chan_sip: No rtpmap for static RTP payload IDs in SDP.

This saves around 100 bytes when G.711, G.722, G.729, and GSM are advertised in
SDP. This reduces the chance to hit the MTU bearer of 1300 bytes for SIP over
UDP, if many codecs are allowed in Asterisk. This new feature is enabled
together with the optional feature compactheaders=yes via the file sip.conf.

ASTERISK-25578 #close

Change-Id: I16491b1937862de26f84fa0ffe679a6bab925044

5 years agoMerge "res_odbc: Implement a connection pool."
Joshua Colp [Tue, 7 Jun 2016 17:17:16 +0000 (12:17 -0500)]
Merge "res_odbc: Implement a connection pool."

5 years agores_odbc: Implement a connection pool.
Joshua Colp [Thu, 2 Jun 2016 17:04:45 +0000 (14:04 -0300)]
res_odbc: Implement a connection pool.

Testing has shown that our usage of UnixODBC is problematic
due to bugs within UnixODBC itself as well as the heavy weight
cost of connecting and disconnecting database connections, even
when pooling is enabled.

For users of UnixODBC 2.3.1 and earlier crashes would occur due
to insufficient protection of the disconnect operation. This was
fixed in UnixODBC 2.3.2 and above.

For users of UnixODBC 2.3.3 and higher a slow-down would occur
under heavy database use due to repeated connection establishment.
A regression is present where on each connection the database
configuration is cached again, with the cache growing out of

The connection pool implementation present in this change helps
to mitigate these issues by reducing how much we connect and
disconnect database connections. We also solve the issue of
crashes under UnixODBC 2.3.1 by defaulting the maximum number of
connections to 1, returning us to the previous working behavior.
For users who may have a fixed version the maximum concurrent
connection limit can be increased helping with performance.

The connection pool works by keeping a list of active connections.
If the connection limit has not been reached a new connection is
established. If the connection limit has been reached then the
request waits until a connection becomes available before

ASTERISK-26074 #close
ASTERISK-26054 #close

Change-Id: I6774bf4bac49a0b30242c76a09c403d2e856ecff

5 years agoapps/app_voicemail.c and main/say.c: Add support for Icelandic language
Örn Arnarson [Mon, 6 Jun 2016 16:13:01 +0000 (16:13 +0000)]
apps/app_voicemail.c and main/say.c: Add support for Icelandic language

Icelandic has some weird grammar rules when dealing with dates and
numbers. There are different genders used depending on which number
you're dealing with, and only a handful of numbers do change depending
on the gender. There is also an implied gender in several cases.

This patch was originally written for asterisk 1.6, and has been in use
for several years without crashes. I cleaned it up a bit and rewrote
what was necessary for Asterisk 13.

The functions were copied from other similar languages and modified
where appropriate. If i recall correctly, the German and Danish
functions were used as a base.

Reported by: Örn Arnarson
Tested by: Örn Arnarson

Change-Id: Ib7d8bd7b0fede5767921ed821315b5b508c0e665

5 years agores_srtp: Instead of libSRTP use OpenSSL as random source.
Alexander Traud [Tue, 7 Jun 2016 10:45:34 +0000 (12:45 +0200)]
res_srtp: Instead of libSRTP use OpenSSL as random source.

Since libSRTP 1.5, its Random Number Generator (RNG) is not maintained anymore.
Therefore, the symbol RAND_bytes is used instead of crypto_get_random.

ASTERISK-24436 #close

Change-Id: Iea0bae4d4e3c9aa0926ea442b6484b5159789d96

5 years agoBuildSystem: Avoid 'ar cru' and use 'ar cr' instead.
Alexander Traud [Tue, 7 Jun 2016 07:16:02 +0000 (09:16 +0200)]
BuildSystem: Avoid 'ar cru' and use 'ar cr' instead.

In several internal library projects, the files are archived with the help of
'ar cr'. Only the projects editline and the Objective Open H.323 stack
implementation in C (ooh323c) use 'ar cru' instead. Recently, some platforms
changed the default parameters of AR which creates "/usr/bin/ar: `u' modifier
ignored since `D' is the default (see `U')". For consistency and to avoid this
message all projects use 'ar cr' now.

ASTERISK-26091 #close

Change-Id: I710a9b1c01c1b5a1931a646098c044c8161ead40

5 years agochan_rtp.c: Simplify options to UnicastRTP channel creation.
Richard Mudgett [Wed, 1 Jun 2016 21:57:36 +0000 (16:57 -0500)]
chan_rtp.c: Simplify options to UnicastRTP channel creation.

Change the awkward and not as flexible UnicastRTP options format

Where <options> can be standard Asterisk flag options:
c(<codec>) - Specify which codec/format to use such as 'ulaw'.
e(<engine>) - Specify which RTP engine to use such as 'asterisk'.

More option flags can be easily added later such as the codec's RTP
payload type to use when the codec does not have a static payload type

Change-Id: I0c297aaf09e2ee515536cb7437bb8042ff8ff3c9

5 years agotranslate: Enables native Packet-Loss Concealment (PLC) for supporting codecs.
Jaco Kroon [Mon, 2 May 2016 10:57:03 +0000 (12:57 +0200)]
translate: Enables native Packet-Loss Concealment (PLC) for supporting codecs.

ASTERISK-25629 #close

Change-Id: Ibfcf0670e094e9718d82fd9920f1fb2dae122006

5 years agocore/dial: New channel variable FORWARDERNAME
Alexei Gradinari [Wed, 25 May 2016 15:34:42 +0000 (11:34 -0400)]
core/dial: New channel variable FORWARDERNAME

Added a new channel variable FORWARDERNAME which indicates which
channel was responsible for a forwarding requests received on dial attempt.

Fixed a bug in the app_queue: FORWARD_CONTEXT is not used.

ASTERISK-26059 #close

Change-Id: I34e93e8c1b5e17776a77b319703c48c8ca48e7b2

5 years agoari/resource_channels: Add 'formats' to channel create/originate
George Joseph [Fri, 27 May 2016 19:49:42 +0000 (13:49 -0600)]
ari/resource_channels:  Add 'formats' to channel create/originate

If you create a local channel and don't specify an originator channel
to take capabilities from, we automatically add all audio formats to
the new channel's capabilities. When we try to make the channel
compatible with another, the "best format" functions pick the best
format available, which in this case will be slin192.  While this is
great for preserving quality, it's the worst for performance and
overkill for the vast majority of applications.

In the absense of any other information, adding all formats is the
correct thing to do and it's not always possible to supply an
originator so a new parameter 'formats' has been added to the channel
create/originate functions. It's just a comma separated list of formats
to make availalble for the channel. Example: "ulaw,slin,slin16".
'formats' and 'originator' are mutually exclusive.

To facilitate determination of format names, the format name has been
added to "core show codecs".

ASTERISK-26070 #close

Change-Id: I091b23ecd41c1b4128d85028209772ee139f604b

5 years agoMerge "core/manager: Add uptime field to FullyBooted"
Joshua Colp [Fri, 3 Jun 2016 13:09:52 +0000 (08:09 -0500)]
Merge "core/manager: Add uptime field to FullyBooted"

5 years agoMake use of GLOB_BRACE and GLOB_NOMAGIC optional
Timo Teräs [Fri, 3 Jun 2016 05:39:02 +0000 (08:39 +0300)]
Make use of GLOB_BRACE and GLOB_NOMAGIC optional

These flags are non-portable GNU extensions. Make their use
optional. This fixes complication error on e.g. musl c-library
based systems.

Change-Id: I0aa06efc62aa8995f091445c8b762a75a91042f3

5 years agoFix res_search usage
Timo Teräs [Thu, 2 Jun 2016 19:57:49 +0000 (22:57 +0300)]
Fix res_search usage

Resolver state is not part of res_search API. This fixes
compilation error:

dns.c:261:8: error: too many arguments to function 'res_search'
  ret = res_search(&dns_state,

Change-Id: Ia600a58557040df83f744da3dde23225293845a5

5 years agoFix #include poll.h and sys/cdefs.h
Timo Teräs [Thu, 2 Jun 2016 19:53:39 +0000 (22:53 +0300)]
Fix #include poll.h and sys/cdefs.h

POSIX defines poll.h, sys/poll.h should not be used at is c-library
internal header which may or may not exist. Notable in musl it
generates warning of being incorrect. And add explict include of
sys/cdefs.h where needed.

Change-Id: I142930df53fe7585a06b854b6faddc5301e024be

5 years agocore/manager: Add uptime field to FullyBooted
Niklas Larsson [Wed, 25 May 2016 13:45:08 +0000 (15:45 +0200)]
core/manager: Add uptime field to FullyBooted

Add Uptime and LastReload to event FullyBooted.

ASTERISK-26058 #close
Reported by: Niklas Larsson

Change-Id: I909b330801c0990d78df9b272ab0adc95aecb15e

5 years agoalembic: Fix migration.
Joshua Colp [Thu, 2 Jun 2016 09:59:06 +0000 (06:59 -0300)]
alembic: Fix migration.

The script was attempting
to use UniqueConstraint and failing. It was not imported and after
importing it also continued to fail.

I've changed the script to use the explicit name of the constraint

Change-Id: I2438b0be90b7ce583b47dd27983c0c1a02cea5b9

5 years agoMerge "pjsip_distributor.c: Use correct rdata info access method (Part 2)."
Joshua Colp [Wed, 1 Jun 2016 23:15:53 +0000 (18:15 -0500)]
Merge "pjsip_distributor.c: Use correct rdata info access method (Part 2)."

5 years agoMerge "logging,cdr,cel: Fix stringfield memory leak."
Joshua Colp [Wed, 1 Jun 2016 21:51:55 +0000 (16:51 -0500)]
Merge "logging,cdr,cel: Fix stringfield memory leak."

5 years agoMerge "pjproject_bundled: Move to pjproject 2.5"
Joshua Colp [Wed, 1 Jun 2016 20:13:48 +0000 (15:13 -0500)]
Merge "pjproject_bundled:  Move to pjproject 2.5"

5 years agologging,cdr,cel: Fix stringfield memory leak.
Richard Mudgett [Wed, 1 Jun 2016 18:57:53 +0000 (13:57 -0500)]
logging,cdr,cel: Fix stringfield memory leak.

The stringfields refactor to allow adding stringfields to the end of a
structure (f6f4cf459f43f072604927209b39646f84aaa2e2) exposed some
incomplete cleanup code by some stringfield users.

The most noticeable leaker is the logging system where there is a leak for
every log message generated.

ASTERISK-26078 #close
Reported by:  Etienne Lessard
      jira_asterisk_26078_v13.patch (license #5621) patch uploaded
      by Richard Mudgett

Change-Id: If6a08b31336b492c3de6f9dfd07c447f8d5a8782

5 years agoMerge "Expand the scope of Dial Events"
Joshua Colp [Tue, 31 May 2016 21:36:35 +0000 (16:36 -0500)]
Merge "Expand the scope of Dial Events"

5 years agopjsip_distributor.c: Use correct rdata info access method (Part 2).
Richard Mudgett [Tue, 31 May 2016 18:02:15 +0000 (13:02 -0500)]
pjsip_distributor.c: Use correct rdata info access method (Part 2).

The pjproject doxygen for rdata-> says to call
pjsip_rx_data_get_info() instead of accessing the struct member directly.
You need to call the function mostly because the function will generate
the struct member value if it is not already setup.

Change-Id: I4d519385a577f3e9d9193a88125e493cf17fa799

5 years agoMerge "followme: allow disabling callee prompt"
Joshua Colp [Tue, 31 May 2016 18:20:49 +0000 (13:20 -0500)]
Merge "followme: allow disabling callee prompt"

5 years agoMerge "ARI: Re-implement the ARI dial command, allowing for early bridging."
zuul [Tue, 31 May 2016 17:39:53 +0000 (12:39 -0500)]
Merge "ARI: Re-implement the ARI dial command, allowing for early bridging."

5 years agoMerge "res_pjsip_mwi_body_generator: Re-order the body items"
zuul [Tue, 31 May 2016 17:39:51 +0000 (12:39 -0500)]
Merge "res_pjsip_mwi_body_generator:  Re-order the body items"

5 years agoExpand the scope of Dial Events
Mark Michelson [Mon, 9 May 2016 20:00:56 +0000 (15:00 -0500)]
Expand the scope of Dial Events

Dial events up to this point have come in two flavors
* A Dial event with no status to indicate that dialing has begun
* A Dial event with a status to indicate that dialing has ended

With this change, Dial events have been expanded to also give
intermediate events, such as "RINGING", "PROCEEDING", and "PROGRESS".
This is especially useful for ARI dialing, as it gives the application
writer the opportunity to place a channel into an early bridge when
early media is detected.

AMI handles these in-progress dial events by sending a new event called
"DialState" that simply indicates that dial state has changed but has
not ended. ARI never distinguished between DialBegin and DialEnd, so no
change was made to the event itself.

Another change here relates to dial forwards. A forward-related event
was previously only sent when a channel was successfully able to forward
a call to a new channel. With this set of changes, if forwarding is
blocked, we send a Dial event with a forwarding destination but no
forwarding channel, since we were prevented from creating one. This is
again useful for ARI since application writers can now handle call
forward attempts from within their own application.

ASTERISK-25925 #close
Reported by Mark Michelson

Change-Id: I42cbec7730d84640a434d143a0d172a740995543

5 years agoMerge "res_pjsip: add "via_addr", "via_port", "call_id" to contact"
Joshua Colp [Tue, 31 May 2016 13:23:12 +0000 (08:23 -0500)]
Merge "res_pjsip: add "via_addr", "via_port", "call_id" to contact"

5 years agoMerge "res_pjsip: Add clarifying documentation to PJSIP_HEADER help text"
zuul [Tue, 31 May 2016 11:59:58 +0000 (06:59 -0500)]
Merge "res_pjsip: Add clarifying documentation to PJSIP_HEADER help text"

5 years agoMerge "multicast RTP: Add dialing options"
zuul [Tue, 31 May 2016 11:53:38 +0000 (06:53 -0500)]
Merge "multicast RTP: Add dialing options"

5 years agoMerge "res_pjsip: chatty verbose messages"
zuul [Tue, 31 May 2016 11:52:15 +0000 (06:52 -0500)]
Merge "res_pjsip: chatty verbose messages"

5 years agores_pjsip_mwi_body_generator: Re-order the body items
George Joseph [Tue, 31 May 2016 00:27:35 +0000 (18:27 -0600)]
res_pjsip_mwi_body_generator:  Re-order the body items

Re-ordered the body items so Message-Account is second.

Messages-Waiting: no
Message-Account: sip:1571@<IP Removed>:5060
Voice-Message: 0/0 (0/0)

ASTERISK-26065 #close
Reported-by: Ross Beer

Change-Id: If5d35a64656eac98c2dd5e490cc0b2807bed80c3

5 years agopjproject_bundled: Move to pjproject 2.5
George Joseph [Mon, 30 May 2016 15:58:35 +0000 (09:58 -0600)]
pjproject_bundled:  Move to pjproject 2.5

Although all the patches we had against 2.4.5 were applied by Teluu,
a new bug was introduced preventing re-use of tcp and tls transports
This patch removes all the previous patches against 2.4.5, updates
the version to 2.5, and adds a new patch to correct the transport
re-use problem.

Change-Id: I0dc6c438c3910f7887418a5832ca186aea23d068

5 years agores_pjsip: Add clarifying documentation to PJSIP_HEADER help text
Rusty Newton [Fri, 27 May 2016 17:25:55 +0000 (12:25 -0500)]
res_pjsip: Add clarifying documentation to PJSIP_HEADER help text

Added notes about when you can read or write headers. Specifically
about being able to read on the inbound channel and write on an
outbound channel.

ASTERISK-26063 #close
Reported by: Private Name
Tested by: Rusty Newton

Change-Id: Ibeb64af17d1f6451028b3c29855a3f151a01d8c5

5 years agomulticast RTP: Add dialing options
Mark Michelson [Thu, 26 May 2016 20:14:50 +0000 (15:14 -0500)]
multicast RTP: Add dialing options

This adds a new parameter to the end of a multicast RTP dialing string.
This parameter defines the following options:

* i: Set the interface from which multicast RTP is sent
* l: Set whether multicast packets are looped back to the sender
* t: Set the TTL for multicast packets
* c: Set the codec to use for RTP

ASTERISK-26068 #close
Reported by Mark Michelson

Change-Id: I033b706b533f0aa635c342eb738e0bcefa07e219

5 years agoARI: Re-implement the ARI dial command, allowing for early bridging.
Mark Michelson [Mon, 9 May 2016 19:48:51 +0000 (14:48 -0500)]
ARI: Re-implement the ARI dial command, allowing for early bridging.

ARI dial had been implemented using the Dial API. This made great sense
when dialing was 100% separate from bridging. However, if a channel were
to be added to a bridge during the dial attempt, there would be a
conflict between the dialing thread and the bridging thread. Each would
be attempting to read frames from the dialed channel and act on them.

The initial attempt to make the two play nice was to have the Dial API
suspend the channel in the bridge and stay in charge of the channel
until the dial was complete. The problem with this was that it was
riddled with potential race conditions. It also was not well-suited for
the case where the channel changed which bridge it was in during the

This new approach removes the use of the Dial API altogether. Instead,
the channel we are dialing is placed into an invisible ARI dialing
bridge. The bridge channel thread handles incoming frames from the
channel. If the channel is added to a real bridge, it is departed from
the invisible bridge and then added to the real bridge. Similarly, if
the channel is removed from the real bridge, it is automatically added
back to the invisible bridge if the dial attempt is still active.

This approach keeps the threading simple by always having the channel
being handled by bridge channel threads.


Change-Id: I7750359ddf45fcd45eaec749c5b3822de4a8ddbb

5 years agoMerge "app_voicemail: fix bugs, imap mm_status log change to debug"
zuul [Thu, 26 May 2016 22:46:01 +0000 (17:46 -0500)]
Merge "app_voicemail: fix bugs, imap mm_status log change to debug"

5 years agores_pjsip: add "via_addr", "via_port", "call_id" to contact
Alexei Gradinari [Thu, 19 May 2016 19:56:26 +0000 (15:56 -0400)]
res_pjsip: add "via_addr", "via_port", "call_id" to contact

As res_pjsip_nat rewrites contact's address, only the last Via header
can contain the source address of registered endpoint.
Also Call-Id header may contain the source address of registered

Added "via_addr", "via_port", "call_id" to contact.
Added new fields ViaAddress, CallID to AMI event ContactStatus.


Change-Id: I36bcc0bf422b3e0623680152d80486aeafe4c576

5 years agores_pjsip: chatty verbose messages
Alexei Gradinari [Tue, 24 May 2016 21:56:49 +0000 (17:56 -0400)]
res_pjsip: chatty verbose messages

There are a lot of verbose messages about Endpoint and Contact status
changes if there are many dynamic endpoints.
The patch sets verbose level 2 for Endpoint status changes
and verbose level 3 for Contact status changes.

ASTERISK-26055 #close

Change-Id: Ie64e261ddbbc41bfff0f0190241152cc123fe6d7

5 years agoapp_voicemail: fix bugs, imap mm_status log change to debug
Alexei Gradinari [Fri, 20 May 2016 18:56:30 +0000 (14:56 -0400)]
app_voicemail: fix bugs, imap mm_status log change to debug

Fixed some bugs:
- create dirpath when save downloading message from IMAP storage.
- create IMAP folder if not exists when saving to IMAP storage
- check if file successfully opened before write to it
- some IMAP checks
- remove non-standard flag 'Unseen'

Change to debug IMAP mm_status log instead of verbose.

Remove unused X-Asterisk-VM-Caller-channel message header
for security reason. The clients should not know name of peer/endpoint.

ASTERISK-26045 #close

Change-Id: I7f83d88b69b36934e2539c114b9fb612deed971b

5 years agopjsip_distributor.c: Use correct rdata info access method.
Richard Mudgett [Wed, 25 May 2016 23:30:07 +0000 (18:30 -0500)]
pjsip_distributor.c: Use correct rdata info access method.

The pjproject doxygen for rdata-> says to call
pjsip_rx_data_get_info() instead of accessing the struct member directly.
You need to call the function mostly because the function will generate
the struct member value if it is not already setup.

Change-Id: Iafe8b01242b7deb0ebfdc36685e21374a43936d2

5 years agofollowme: allow disabling callee prompt
Tzafrir Cohen [Tue, 3 May 2016 16:11:20 +0000 (19:11 +0300)]
followme: allow disabling callee prompt

Add the option 'enable_callee_prompt' to followme.conf. Enabled by
default. If disabled, a callee is not prompted to accept or reject
the forwarded call.

ASTERISK-26064 #close

Change-Id: I0a8b19d4cf95c86a07c992813babb9e4a4acfff5
Signed-off-by: Tzafrir Cohen <>

5 years agoMerge "res_pjsip_outbound_publish: Ensure publish is valid when explicitly destroying."
zuul [Wed, 25 May 2016 13:38:22 +0000 (08:38 -0500)]
Merge "res_pjsip_outbound_publish: Ensure publish is valid when explicitly destroying."

5 years agoMerge "Bridging: introduce "invisible" bridges."
Joshua Colp [Wed, 25 May 2016 10:32:55 +0000 (05:32 -0500)]
Merge "Bridging: introduce "invisible" bridges."

5 years agoMerge "res_pjsip: Only check transaction on transaction state events."
zuul [Wed, 25 May 2016 00:09:13 +0000 (19:09 -0500)]
Merge "res_pjsip: Only check transaction on transaction state events."

5 years agothreadpool: Fix potential data race.
Corey Farrell [Fri, 12 Feb 2016 15:59:44 +0000 (10:59 -0500)]
threadpool: Fix potential data race.

worker_start checked for ZOMBIE status without holding a lock.  All
other read/write of worker status are performed with a lock, so this
check should do the same.

ASTERISK-25777 #close

Change-Id: I5e33685a5c26fdb300851989a3b82be8c4e03781

5 years agoMerge "func_odbc: single database connection should be optional"
Joshua Colp [Tue, 24 May 2016 14:28:03 +0000 (09:28 -0500)]
Merge "func_odbc: single database connection should be optional"

5 years agores_pjsip_outbound_publish: Ensure publish is valid when explicitly destroying.
Joshua Colp [Tue, 24 May 2016 10:28:17 +0000 (07:28 -0300)]
res_pjsip_outbound_publish: Ensure publish is valid when explicitly destroying.

Recent changes to res_pjsip_outbound_publish have introduced a
race condition at shutdown where an outbound publish may be shutdown
twice. In this case the first succeeds as a result of the unpublish.
In the second invocation since it's been unpublished a task is
queued to just destroy the client. This task holds no ref to the
publish and as a result the publish may be destroyed before the
task is run, causing a crash.

This explicit destruction task now holds a reference to the publish
to ensure it remains valid.

ASTERISK-26053 #close

Change-Id: I10789b98add3e50292ee3b33a55a1d9061cec94b

5 years agoMerge "ARI: Add the ability to download the media associated with a stored recording"
Joshua Colp [Mon, 23 May 2016 23:04:07 +0000 (18:04 -0500)]
Merge "ARI: Add the ability to download the media associated with a stored recording"

5 years agoMerge "chan_rtp.c: Cleanup ast_request() parameter parsing."
Joshua Colp [Mon, 23 May 2016 21:17:57 +0000 (16:17 -0500)]
Merge "chan_rtp.c: Cleanup ast_request() parameter parsing."

5 years agoMerge "Makefile: remove OSARCH check for init install"
zuul [Mon, 23 May 2016 21:16:04 +0000 (16:16 -0500)]
Merge "Makefile: remove OSARCH check for init install"

5 years agoBridging: introduce "invisible" bridges.
Mark Michelson [Mon, 9 May 2016 19:27:53 +0000 (14:27 -0500)]
Bridging: introduce "invisible" bridges.

Invisible bridges function the same as normal bridges, but they have the
following restrictions:

* They never show up in CLI, AMI, or ARI queries.
* They do not have Stasis messages published about them.

Invisible bridges' main use is for when use of the bridging system is
desired, but the bridge should not be known to users of the Asterisk


Change-Id: I804a209d3181d7c54e3d61a60eb462e7ce0e3670

5 years agoMerge "func_curl: Don't trim response text on non-ASCII characters"
Joshua Colp [Mon, 23 May 2016 14:43:20 +0000 (09:43 -0500)]
Merge "func_curl: Don't trim response text on non-ASCII characters"

5 years agoMerge "parking.h: Update ast_parking_park_call() doxygen to reality."
Joshua Colp [Mon, 23 May 2016 11:15:59 +0000 (06:15 -0500)]
Merge "parking.h: Update ast_parking_park_call() doxygen to reality."

5 years agores_pjsip: Only check transaction on transaction state events.
Joshua Colp [Sun, 22 May 2016 16:03:20 +0000 (13:03 -0300)]
res_pjsip: Only check transaction on transaction state events.

The send request callback function currently assumes that it
will only ever be called on transaction state changes. This is
not always true. If our own timer callback occurs we will call
the callback with a timer event instead of a transaction state
change event. In this case the transaction on the event is
invalid and accessing it will result in a crash.

ASTERISK-26049 #close

Change-Id: I623211c8533eb73056b0250b4580b49ad4174dfc

5 years agofunc_curl: Don't trim response text on non-ASCII characters
Ivan Poddubny [Sat, 21 May 2016 10:42:45 +0000 (13:42 +0300)]
func_curl: Don't trim response text on non-ASCII characters

The characters 0x80-0xFF were trimmed as well as 0x00-0x20 because of
a signed comparison.

ASTERISK-25669 #close
Reported by: Jesper
  strings.curl.trim.patch submitted by Jesper (License 5518)

Change-Id: Ia51e169f24e3252a7ebbaab3728630138ec6f60a

5 years agochan_rtp.c: Cleanup ast_request() parameter parsing.
Richard Mudgett [Sat, 21 May 2016 00:03:53 +0000 (19:03 -0500)]
chan_rtp.c: Cleanup ast_request() parameter parsing.

* Fixed NULL crash potential if parameters are missing.

* Reordered some operations so further diagnostic messages can be
more helpful.

Change-Id: Ibbdc67a2496508cbfbfef0cf19c35177ae2fbd70

5 years agoparking.h: Update ast_parking_park_call() doxygen to reality.
Richard Mudgett [Fri, 20 May 2016 21:59:52 +0000 (16:59 -0500)]
parking.h: Update ast_parking_park_call() doxygen to reality.


Change-Id: I2db14d102a48d3224010e6d1c69e856373cc1260

5 years agofunc_odbc: single database connection should be optional
Alexei Gradinari [Thu, 12 May 2016 20:18:22 +0000 (16:18 -0400)]
func_odbc: single database connection should be optional

func_odbc was changed in Asterisk 13.9.0
to make func_odbc use a single database connection per DSN
because of reported bug ASTERISK-25938

This is drawback in performance when func_odbc is used
very often in dialplan.

Single database connection should be optional.


Change-Id: I7091783a7150252de8eeb455115bd00514dfe843

5 years agores_pjsip: Match dialogs on responses better.
Mark Michelson [Fri, 20 May 2016 14:39:10 +0000 (09:39 -0500)]
res_pjsip: Match dialogs on responses better.

When receiving an incoming response to a dialog-starting INVITE, we were
not matching the response to the INVITE dialog. Since we had not
recorded the to-tag to the dialog structure, the PJSIP-provided method
to find the dialog did not match.

Most of the time, this was not a problem, because there is a fall-back
that makes the response get routed to the same serializer that the
request was sent on. However, in cases where an asynchronous DNS lookup
occurs in the PJSIP core, the thread that sends the INVITE is not
actually a threadpool serializer thread. This means we are unable to
record a serializer to handle the incoming response.

Now, imagine what happens when an INVITE is sent on a non-serialized
thread, and an error response (such as a 486) arrives. The 486 ends up
getting put on some random threadpool thread. Eventually, a hangup task
gets queued on the INVITE dialog serializer. Since the 486 is being
handled on a different thread, the hangup task can execute at the same
time that the 486 is being handled. The hangup task assumes that it is
the sole owner of the INVITE session and channel, so it ends up
potentially freeing the channel and NULLing the session's channel
pointer. The thread handling the 486 can crash as a result.

This change has the incoming response match the INVITE transaction, and
then get the dialog from that transaction. It's the same method we had
been using for matching incoming CANCEL requests. By doing this, we get
the INVITE dialog and can ensure that the 486 response ends up being
handled by the same thread as the hangup, ensuring that the hangup runs
after the 486 has been completely handled.

ASTERISK-25941 #close
Reported by Javier Riveros

Change-Id: I0d4cc5d07e2a8d03e9db704d34bdef2ba60794a0

5 years agoARI: Add the ability to download the media associated with a stored recording
Matt Jordan [Wed, 18 May 2016 11:19:58 +0000 (06:19 -0500)]
ARI: Add the ability to download the media associated with a stored recording

This patch adds a new feature to ARI that allows a client to download
the media associated with a stored recording. The new route is
/recordings/stored/{name}/file, and transmits the underlying binary file
using Asterisk's HTTP server's underlying file transfer facilities.

Because this REST route returns non-JSON, a few small enhancements had
to be made to the Python Swagger generation code, as well as the
mustache templates that generate the ARI bindings.

ASTERISK-26042 #close

Change-Id: I49ec5c4afdec30bb665d9c977ab423b5387e0181

5 years agores_sorcery_astdb: Filter fields to only the registered ones.
Joshua Colp [Thu, 19 May 2016 16:41:45 +0000 (13:41 -0300)]
res_sorcery_astdb: Filter fields to only the registered ones.

This change introduces the same filtering that is done in res_sorcery_realtime
to the res_sorcery_astdb module. This allows persisted sorcery objects
that may contain unknown fields to still be read in from the AstDB
and used. This is particularly useful when switching between different
versions of Asterisk that may have introduced additional fields.

ASTERISK-26014 #close

Change-Id: Ib655130485a3ccfd635b7ed5546010ca14690fb2

5 years agoMerge "res_pjsip_empty_info: Respond to empty SIP INFO packets"
Joshua Colp [Thu, 19 May 2016 19:46:11 +0000 (14:46 -0500)]
Merge "res_pjsip_empty_info: Respond to empty SIP INFO packets"

5 years agoMerge "res_pjsip: Endpoint IP Access Controls"
Joshua Colp [Thu, 19 May 2016 15:39:58 +0000 (10:39 -0500)]
Merge "res_pjsip: Endpoint IP Access Controls"

5 years agores_pjsip_empty_info: Respond to empty SIP INFO packets
snuffy [Tue, 10 May 2016 02:40:08 +0000 (12:40 +1000)]
res_pjsip_empty_info: Respond to empty SIP INFO packets

Some SBCs require responses to empty SIP INFO packets
after establishing call via INVITE, if not responded to
they may drop your call after unspecified timeout of X minutes.

They are identified by having no Content-Type, check for this
and respond with 200 - OK message.

ASTERISK-24986 #close
Reported-by: Ilya Trikoz, Federico Santulli

Change-Id: Ib27e4f07151e5aef28fa587e4ead36c5b87c43e0

5 years agoMerge "udptl: Don't eat sequence numbers until OK is received"
Joshua Colp [Thu, 19 May 2016 10:33:13 +0000 (05:33 -0500)]
Merge "udptl:  Don't eat sequence numbers until OK is received"

5 years agoMerge "logger: Support JSON logging with Verbose messages"
Joshua Colp [Thu, 19 May 2016 10:31:19 +0000 (05:31 -0500)]
Merge "logger: Support JSON logging with Verbose messages"

5 years agoMerge "res_hep: Provide an option to pick the UUID type"
Joshua Colp [Thu, 19 May 2016 10:26:57 +0000 (05:26 -0500)]
Merge "res_hep: Provide an option to pick the UUID type"

5 years agoMerge "res/res_hep_pjsip: Fix reported local IP address when bound to 'any'"
Joshua Colp [Thu, 19 May 2016 10:23:21 +0000 (05:23 -0500)]
Merge "res/res_hep_pjsip: Fix reported local IP address when bound to 'any'"

5 years agoMakefile: remove OSARCH check for init install
Tzafrir Cohen [Wed, 18 May 2016 15:58:20 +0000 (18:58 +0300)]
Makefile: remove OSARCH check for init install

There are more specific checks for the platform.

Specifically this allows installing OS/X init scripts.

ASTERISK-26038 #close

Change-Id: If08933621145b10362a0cfe73c079301d9c13f50
Signed-off-by: Tzafrir Cohen <>

5 years agores_pjsip_exten_state: Use the extension for publishing to.
Joshua Colp [Tue, 10 May 2016 16:28:04 +0000 (13:28 -0300)]
res_pjsip_exten_state: Use the extension for publishing to.

This change uses the newly added multi-user support for
outbound publish to publish to the specific user that an
extension state change is for.

This also extends the res_pjsip_outbound_publish support
to include the user specific From and To URI information in
the outbound publishing of extension state. Since the URI
is used when constructing the body it is important to ensure
that the correct local and remote URIs are used.

Finally the max string growths for the dialog-info+xml
body generator has been increased as through testing it has
proven to be too conservative.


Change-Id: I668fdf697b1e171d4c7e6f282b2e1590f8356ca1

5 years agores_pjsip_outbound_publish: Add multi-user support per configuration
Kevin Harwell [Tue, 3 May 2016 21:07:23 +0000 (16:07 -0500)]
res_pjsip_outbound_publish: Add multi-user support per configuration

Added a new multi_user option that when specified allows a particular
configuration to be used for multiple users. It does this by replacing
the user portion of the server uri with a dynamically created one.

Two new API calls have been added in order to make use of the new

ast_sip_publish_user_send - Sends an outgoing publish message based on the
given user. If state for the user already exists it uses that, otherwise
it dynamically creates new outbound publishing state for the user at that

ast_sip_publish_user_remove - Removes all outbound publish state objects
associated with the user. This essentially stops outbound publishing for
the user.

ASTERISK-25965 #close

Change-Id: Ib88dde024cc83c916424645d4f5bb84a0fa936cc

5 years agoMerge "CHANGES: Update formatting of items"
Joshua Colp [Wed, 18 May 2016 23:35:32 +0000 (18:35 -0500)]
Merge "CHANGES: Update formatting of items"

5 years agoMerge "ARI: Add the ability to play multiple media URIs in a single operation"
Joshua Colp [Wed, 18 May 2016 23:35:20 +0000 (18:35 -0500)]
Merge "ARI: Add the ability to play multiple media URIs in a single operation"

5 years agoMerge "chan_sip: Prevent extra Session-Expires headers from being added"
Joshua Colp [Wed, 18 May 2016 23:27:28 +0000 (18:27 -0500)]
Merge "chan_sip:  Prevent extra Session-Expires headers from being added"

5 years agoudptl: Don't eat sequence numbers until OK is received
George Joseph [Wed, 18 May 2016 12:54:14 +0000 (06:54 -0600)]
udptl:  Don't eat sequence numbers until OK is received

Local fax -> Asterisk w/ firewall -> Provider -> Remote fax

* Local fax starts rtp call to remote fax
* Remote fax starts t38 call back to local fax.
* Local fax sends t38 no-signal to Asterisk before sending an OK.
* udptl processes the frame and increments the expected sequence number.
* chan_sip drops the frame because the call isn't up so nothing goes out
  the external interface to open the port for incoming packets.
* Local fax sends OK and Asterisk sends OK to the remote fax.
* Remote fax sends t38 packets which are dropped by the firewall.
* Local fax re-sends t38 no-signal with the same sequence number.
* udptl drops the frame because it thinks it's a dup.
* Still no outgoing packets to open the firewall.
* t38 negotiation fails.

The patch drops frames t38 received before udptl sequence processing
when the call hasn't been answered yet.  The second no-signal frame
is then seen as new and is relayed out the external interface which
opens the port and allows negotiation to continue.

ASTERISK-26034 #close

Change-Id: I11744b39748bd2ecbbe8ea84cdb4f3c5943c5af9

5 years agoCHANGES: Update formatting of items
Matt Jordan [Sun, 15 May 2016 17:22:42 +0000 (12:22 -0500)]
CHANGES: Update formatting of items

* Provide consistent indenting of lines in bulleted paragraphs
* Respect the 80 character column width
* Group all like items together, e.g., all dialplan applications under
  "Applications", etc.
* Use a single blank line to break up functionality changes within a
  larger section
* Use two blanks lines to delineate larger sections

Change-Id: I0488554f5cb7c51da70003d69288a21c9aab9647

5 years agoARI: Add the ability to play multiple media URIs in a single operation
Matt Jordan [Mon, 18 Apr 2016 23:17:08 +0000 (18:17 -0500)]
ARI: Add the ability to play multiple media URIs in a single operation

Many ARI applications will want to play multiple media files in a row to
a resource. The most common use case is when building long-ish IVR prompts
made up of multiple, smaller sound files. Today, that requires building a
small state machine, listening for each PlaybackFinished event, and triggering
the next sound file to play. While not especially challenging, it is tedious
work. Since requiring developers to write tedious code to do normal activities
stinks, this patch adds the ability to play back a list of media files to a

Each of the 'play' operations on supported resources (channels and bridges)
now accepts a comma delineated list of media URIs to play. A single Playback
resource is created as a handle to the entire list. The operation of playing
a list is identical to playing a single media URI, save that a new event,
PlaybackContinuing, is raised instead of a PlaybackFinished for each non-final
media URI. When the entire list is finished being played, a PlaybackFinished
event is raised.

In order to help inform applications where they are in the list playback, the
Playback resource now includes a new, optional attribute, 'next_media_uri',
that contains the next URI in the list to be played.

It's important to note the following:
 - If an offset is provided to the 'play' operations, it only applies to the
   first media URI, as it would be weird to skip n seconds forward in every
   media resource.
 - Operations that control the position of the media only affect the current
   media being played. For example, once a media resource in the list
   completes, a 'reverse' operation on a subsequent media resource will not
   start a previously completed media resource at the appropiate offset.
 - This patch does not add any new operations to control the list. Hopefully,
   user feedback and/or future patches would add that if people want it.

ASTERISK-26022 #close

Change-Id: Ie1ea5356573447b8f51f2e7964915ea01792f16f

5 years agochan_sip: Prevent extra Session-Expires headers from being added
George Joseph [Tue, 17 May 2016 16:14:51 +0000 (10:14 -0600)]
chan_sip:  Prevent extra Session-Expires headers from being added

When chan_sip does a re-INVITE to refresh a session and authentication
is required, the INVITE with the Authorization header containes a
second Session-Expires header without the ";refersher=" parameter.
This is causing some proxies to return a 400.  Also, when Asterisk is
the uas and the refresher, it is including the Session-Expires and
Min-SE headers in OPTIONS messages which is not allowed per RFC4028.

This patch (based on the reporter's) Checks to see if a Session-Expires
header is already in the message before adding another one.  It also
checks that the method is INVITE or UPDATE.

ASTERISK-26030 #close

Change-Id: I58a7b07bab5a3177748d8a7034fb8ad8e11ce1d9

5 years agores_pjsip_outbound_registration: Clean up state when registration is deleted
George Joseph [Mon, 16 May 2016 20:29:38 +0000 (14:29 -0600)]
res_pjsip_outbound_registration:  Clean up state when registration is deleted

Nothing was cleaning up the registration state object when ast_sorcery_delete
was called on a registration.  So, the registration was deleted from sorcery
but the state object went right on refreshing the registration (or failing
to refresh the registration) with the peer.

* Added a 'deleted' observer on registration that removes the state object.

ASTERISK-25964 #close
Reported-by Matt Jordan

Change-Id: I2db792145cdb1f72ebbf57dd9099596dbbf12c23

5 years agoMerge "configs/samples/pjsip.conf.sample: Fix typo"
zuul [Mon, 16 May 2016 18:53:00 +0000 (13:53 -0500)]
Merge "configs/samples/pjsip.conf.sample: Fix typo"

5 years agores_pjsip: Set TCP_NODELAY on TCP transports
George Joseph [Mon, 16 May 2016 00:05:34 +0000 (18:05 -0600)]
res_pjsip:  Set TCP_NODELAY on TCP transports

Although it's perfectly legal to place multiple SIP messages in the same packet,
it can cause problems because the Linux default is to enable Path MTU Discovery
which sets the Don't Fragment bit on the packets. If adding a second message to
the packet causes the MTU to be exceeded, and the destination isn't equipped to
send a FRAGMENTATION NEEDED response to a large packet, the packet will just be

We can't specifically tell the stack to send only 1 message per packet, but we
can turn on TCP_NODELAY when we create the transport. This will at least tell
the stack to send packets as soon as possible.

ASTERISK-26005 #close
Reported-by: Ross Beer

Change-Id: I820f23227183f2416ca5e393bec510e8fe1c8fbd

5 years agologger: Support JSON logging with Verbose messages
Matt Jordan [Sat, 14 May 2016 12:24:07 +0000 (07:24 -0500)]
logger: Support JSON logging with Verbose messages

When 2d7a4a3357 was merged, it missed the fact that Verbose log messages
are formatted and handled by 'verbosers'. Verbosers are registered
functions that handle verbose messages only; they exist as a separate
class of callbacks. This was done to handle the 'magic' that must be
inserted into Verbose messages sent to remote consoles, so that the
consoles can format the messages correctly, i.e., the leading

In reality, verbosers are a weird appendage: they're a separate class of
formatters/message handlers outside of what handles all other log
messages in Asterisk. After some code inspection, it became clear that
simply passing a Verbose message along with its 'sublevel' importance
through the normal logging mechanisms removes the need for verbosers

This patch removes the verbosers, and makes the default log formatter
aware that, if the log channel is a console log, it should simply insert
the 'verbose magic' into the log messages itself. This allows the
console handlers to interpret and format the verbose message

This simplifies the code quite a lot, and should improve the performance
of printing verbose messages by a reasonable factor:
(1) It removes a number of memory allocations that were done on each
    verobse message
(2) It removes the need to strip the verbose magic out of the verbose
    log messages before passing them to non-console log channels
(3) It now performs fewer iterations over lists when handling verbose

Since verbose messages are now handled like other log messages (for the
most part), the JSON formatting of the messages works as well.


Change-Id: I21bf23f0a1e489b5102f8a035fe8871552ce4f96

5 years agoconfigs/samples/pjsip.conf.sample: Fix typo
Matt Jordan [Sun, 15 May 2016 02:48:56 +0000 (21:48 -0500)]
configs/samples/pjsip.conf.sample: Fix typo

A ':' is not a valid token for starting a comment.

Change-Id: I123592d93a83d1bdde3e352822881eb9da85e5ad

5 years agores/res_hep_pjsip: Fix reported local IP address when bound to 'any'
Matt Jordan [Thu, 12 May 2016 12:08:08 +0000 (07:08 -0500)]
res/res_hep_pjsip: Fix reported local IP address when bound to 'any'

When bound to an 'any' address, e.g.,, PJSIP reports as its
local address the 'any' address, as opposed to the IP address we
actually received the packet on. This can cause some confusion in Homer,
as it will dutifully report what we send it.

This patch uses the PJSIP inspection routines to determine which IP
address we probably received the packet on based on the remote party's
IP address. In the event that this fails, it falls back to the IP
address natively reported by the transport.

Change-Id: I076f835d2aef489e1ee1d01595b211eb2ce62da3