Commit Graph

3895 Commits

Author SHA1 Message Date
George Joseph f62c9c42fa Revert "Revert "AGI: Only defer frames when in an interception routine.""
This reverts commit 6bce938c2f.

Change-Id: Iadbf462bf2a52e8b2fa9ebc75b37b1f688ba51d9
2016-11-14 14:14:28 -06:00
Joshua Colp d1739bcf07 Merge "res_pjsip.c: Rework endpt_send_request() req_wrapper code." 2016-11-14 13:21:22 -06:00
Sebastien Duthil c6d755de11 res_ari: Add support for channel variables in ARI events.
This works the same as for AMI manager variables. Set
"channelvars=foo,bar" in your ari.conf general section, and then the
channel variables "foo" and "bar" (along with their values), will
appear in every Stasis websocket channel event.

ASTERISK-26492 #close
patches:
  ari_vars.diff submitted by Mark Michelson

Change-Id: I5609ba239259577c0948645df776d7f3bc864229
2016-11-14 13:51:56 -05:00
Joshua Colp 7540036427 Merge "res_pjsip: Fix tdata leaks in off nominal paths." 2016-11-14 06:47:37 -06:00
Joshua Colp 1bd49040c4 res_pjsip_sdp_rtp: Reject offer of required SRTP without res_srtp.
When optimistic SRTP was on it was possible for us to still
set up a call without an audio stream if an offer was received
with required SRTP.

This change makes it so this scenario will now fail with a 488
response.

ASTERISK-26575

Change-Id: I7d14187037681f48879bd20319ac79d0877318f3
2016-11-11 08:17:55 -05:00
Joshua Colp e77aa78dc7 Merge "res_pjsip: Perform resolution when explicit IPv6 transport is used." 2016-11-11 04:37:15 -06:00
Richard Mudgett 338f35edcc res_pjsip.c: Rework endpt_send_request() req_wrapper code.
* Don't hold the req_wrapper lock too long in endpt_send_request().  We
could block the PJSIP monitor thread if the timeout timer expires.
sip_get_tpselector_from_endpoint() does a sorcery access that could take
awhile accessing a database.  pjsip_endpt_send_request() might take awhile
if selecting a transport.

* Shorten the time that the req_wrapper lock is held in the callback
functions.

* Simplify endpt_send_request() req_wrapper->timeout code.

* Removed some redundant req_wrapper->timeout_timer->id assignments.

Change-Id: I3195e3a8e0207bb8e7f49060ad2742cf21a6e4c9
2016-11-10 17:19:23 -05:00
Richard Mudgett bb196323f9 res_pjsip: Fix tdata leaks in off nominal paths.
Change-Id: Ie83e06e88c2d60157775263b07e40b61718ac97b
2016-11-10 17:15:59 -05:00
Richard Mudgett 9df59d9ff4 res_pjsip_registrar_expire.c: Remove extra linefeed in debug message.
Change-Id: I1f9adb911f23376503396ec8867e8005b755eb94
2016-11-10 16:59:41 -05:00
Joshua Colp bdb6d928c5 res_pjsip: Perform resolution when explicit IPv6 transport is used.
This change fixes the SIP resolver such that if an IPv6 transport
is explicitly used it will resolve NAPTR, SRV, and AAAA records.

You can explicitly use one by specifying it on an endpoint.

ASTERISK-26571

Change-Id: I2ed3ce81b43a6a8a937c0ebc1b8ed2da5ac2ef36
2016-11-10 10:11:13 -05:00
George Joseph 7efac7b3d0 Merge "Revert "AGI: Only defer frames when in an interception routine."" 2016-11-10 07:35:08 -06:00
George Joseph 6bce938c2f Revert "AGI: Only defer frames when in an interception routine."
This reverts commit 28926d1c81.
Multiple testsuite failures were detected after the fact.

Change-Id: I8d4f5ccbb421a351d616254844ae7e5a31053edb
2016-11-10 08:33:49 -05:00
Mark Michelson e5860ce07d res_pjsip_session: Do not call session supplements when it's too late.
res_pjsip_sesssion was hooking into transaction and invite state
changes. One of the reasons for doing so was due to the
PJSIP_EVENT_TX_MSG event. The idea was that we were hooking into the
message sending process, and so we should call session supplements to
alter the outgoing message.

In reality, this event was meant to indicate that the message either
a) had already been sent, or
b) required a DNS lookup and would be sent when the DNS query
completed.

In case (a), this meant we were altering an already-sent
request/response for no reason. In case (b), this potentially meant we
could be trying to alter a request/response at the same time that the
DNS resolution completed. In this case, it meant we might be stomping on
memory being used by the thread actually sending the message. This
caused potential crashes and memory corruption.

This patch removes the calls to session supplements from the case where
the PJSIP_EVENT_TX_MSG event occurs. In all of these cases, trying to
alter the message at this point is too late, and it can cause nothing
but harm to try to do it. Because there were no longer any calls to the
handle_outgoing() function, it has been removed.

Change-Id: Ibcc223fb1c3a237927f38754e0429e80ee301e92
2016-11-09 11:48:19 -05:00
Mark Michelson 28926d1c81 AGI: Only defer frames when in an interception routine.
AGI recently was modified to defer important frames. This was because
when AGI was used in a connected line interception routine, the
resulting connected line frame would end up getting discarded by the
AGI.

However, this caused bad behavior in other cases. Specifically, during a
transfer, if someone attempted to manually set the Caller ID on a
channel in an AGI, the deferred connected line frame would end up
overwriting what had been manually set in the AGI.

Since the initial issue was specific to interception routines, this
change removes the manual frame deferral from AGI and instead uses the
new frame deferral API in interception routines.

ASTERISK-26343 #close
Reported by Morton Tryfoss

Change-Id: Iab7d39436d0ee99bfe32ad55ef91e9bd88db4208
2016-11-08 07:06:44 -07:00
Joshua Colp 61af0e6704 Merge "res_http_websocket: Increase the buffer size for non-LOW_MEMORY systems" 2016-11-08 04:59:53 -06:00
Joshua Colp 3019dfd49f Merge "res_stasis: Don't unsubscribe from a NULL bridge." 2016-11-08 04:59:24 -06:00
Joshua Colp 1ab943a425 Merge "stasis_recording/stored: remove calls to deprecated readdir_r function." 2016-11-08 04:57:55 -06:00
Joshua Colp d30415bfa1 res_stasis: Don't unsubscribe from a NULL bridge.
A NULL bridge has special meaning in res_stasis for
unsubscribing. It means that a subscription to ALL
bridges should be removed. This should not be done
as part of the normal subscription management in
the res_stasis channel loop.

ASTERISK-26468

Change-Id: I6d5bea8246dd13a22ef86b736aefbf2a39c15af0
2016-11-07 10:02:25 -05:00
frahaase b2b5f9d897 ast_format: Adds an identifier for interleaved audio formats to the ast_format
Adds an identifier (with a getter and setter) to detect channels with
interleaved audio.
This is needed by the binaural bridge_softmix patch (ASTERISK-26292) and
was already discussed here:
http://lists.digium.com/pipermail/asterisk-dev/2016-October/075900.html
The identifier can be set during fmtp parsing (to be seen in the
res_format_attr_opus.c change).

ASTERISK-26292

Change-Id: I359801cc5f98c35671c48dabc81a7f4ee1183d63
2016-11-06 15:56:58 +01:00
Matt Jordan 367d4903cc res_http_websocket: Increase the buffer size for non-LOW_MEMORY systems
Not surprisingly, using Respoke (and possibly other systems) it is
possible to blow past the 16k limit for a WebSocket packet size. This
patch bumps it up to 32k, which, at least for Respoke, is sufficient.
For now.

Because 32k is laughable on a LOW_MEMORY system (as is 16k, for that
matter), this patch adds a LOW_MEMORY directive that sets the buffer to
8k for systems who have asked for their reduced memory availability to
be considered.

Change-Id: Id235902537091b58608196844dc4b045e383cd2e
2016-11-04 15:51:28 -05:00
Matt Jordan 7a449b6819 res_stasis: Set a video source mode on Stasis created bridges
When a bridge is created via ARI (through res_stasis), no video source
mode is set by default. As a result, any endpoint sending video media
won't ever see any video reflected back to it.

This patch defaults a bridge to a 'follow the talker' video mode.
Further work can be done to add routes that allow for the video mode to
be controlled through the /bridges resource.

Change-Id: I7e9d530a5d7a97a4524a9ee4e468e1a6b3443866
2016-11-04 15:51:03 -05:00
Kevin Harwell 70d5f90e3d stasis_recording/stored: remove calls to deprecated readdir_r function.
The readdir_r function has been deprecated and should no longer be used. This
patch removes the readdir_r dependency (replaced it with readdir) and also moves
the directory search code to a more centralized spot (file.c)

Also removed a strict dependency on the dirent structure's d_type field as it
is not portable. The code now checks to see if the value is available. If so,
it tries to use it, but defaults back to using the stats function if necessary.

Lastly, for most implementations of readdir it *should* be thread-safe to make
concurrent calls to it as long as different directory streams are specified.
glibc falls into this category. However, since it is possible that there exist
some implementations that are not safe, locking has been added for those other
than glibc.

ASTERISK-26412
ASTERISK-26509 #close

Change-Id: Id8f54689b1e2873e82a09d0d0d2faf41964e80ba
2016-11-04 13:56:42 -05:00
Joshua Colp a380bba1e3 Merge "res_pjsip_sdp_rtp: Limit number of formats to defined maximum." 2016-11-02 08:14:09 -05:00
Joshua Colp d94e2250c2 Merge "res_pjsip_outbound_publish: Fix crash when publishing device state." 2016-11-01 18:32:54 -05:00
Joshua Colp 6233e146c6 res_pjsip_sdp_rtp: Limit number of formats to defined maximum.
The res_pjsip_sdp_rtp module did not restrict the number of
formats added to a media stream in the SDP to the defined
limit. If allow=all was used with additional loaded codecs this
could result in the next media stream being overwritten some.

This change restricts the module to limit it to the defined
maximum and also increases the maximum in our bundled pjproject.

ASTERISK-26541 #close

Change-Id: I0dc5f59d3891246cafa2f3df5ec406f088559ee8
2016-11-01 13:21:12 -05:00
Matt Jordan c30d677333 res/stasis: Add CLI commands for displaying/debugging ARI apps
This patch adds three new CLI commands:
 - ari show apps: list the registered ARI applications
 - ari show app: show detailed information about an ARI application
 - ari set debug: dump events being sent to an ARI application

Note that while these CLI commands live in the res_stasis module, we use
the 'ari' family for these commands. This was done as most users of
Asterisk aren't aware of the semantic differences between ARI and
res_stasis, and some 'ari' CLI commands already exist.

ASTERISK-26488 #close

Change-Id: I51ad6ff0cabee0d69db06858c13f18b1c513c9f5
2016-11-01 09:43:46 -05:00
mkrokosz 9d8b9b6ca5 res_pjsip_outbound_publish: Fix crash when publishing device state.
While publishing device state between multiple instances of Asterisk,
a crash will sporadically occur under high CPS which looks to be a
race condition operating on the publisher queue.

ASTERISK-26506

Change-Id: I28da25d346deb358eff1d563485cabc433ce1ed6
2016-10-28 14:30:02 -04:00
zuul 0ec5abe592 Merge "Remove ASTERISK_REGISTER_FILE." 2016-10-27 22:23:00 -05:00
zuul 0fc942e7cd Merge "res_pjsip_sdp_rtp: Fix address family of explicit media_address." 2016-10-27 22:22:57 -05:00
Joshua Colp 24d0907849 Merge "pjsip: Fix a few media bugs with reinvites and asymmetric payloads." 2016-10-27 19:37:47 -05:00
Corey Farrell a6e5bae3ef Remove ASTERISK_REGISTER_FILE.
ASTERISK_REGISTER_FILE no longer has any purpose so this commit removes
all traces of it.

Previously exported symbols removed:
* __ast_register_file
* __ast_unregister_file
* ast_complete_source_filename

This also removes the mtx_prof static variable that was declared when
MTX_PROFILE was enabled.  This variable was only used in lock.c so it
is now initialized in that file only.

ASTERISK-26480 #close

Change-Id: I1074af07d71f9e159c48ef36631aa432c86f9966
2016-10-27 09:53:55 -04:00
Joshua Colp 6993f3c9c3 res_pjsip_caller_id: Fix crash on session timers UPDATE on inbound calls.
The res_pjsip_caller_id module wrongly assumed that a
saved From header would always exist on sessions. This
is true until an inbound call is received and a session
timer causes an UPDATE to be sent. In this case there will
be no saved From header and a crash will occur. This change
makes it fall back to the From header of the outgoing request
if no saved From header is present.

ASTERISK-26307 #close

Change-Id: Iccc3bc8d243b5ede9b81abf960292930c908d4fa
2016-10-27 08:30:36 -05:00
Joshua Colp aed6c219a3 pjsip: Fix a few media bugs with reinvites and asymmetric payloads.
When channel format changes occurred as a result of an RTP
re-negotiation the bridge was not informed this had happened.
As a result the bridge technology was not re-evaluated and the
channel may have been in a bridge technology that was incompatible
with its formats. The bridge is now unbridged and the technology
re-evaluated when this occurs.

The chan_pjsip module also allowed asymmetric codecs for sending
and receiving. This did not work with all devices and caused one
way audio problems. The default has been changed to NOT do this
but to match the sending codec to the receiving codec. For users
who want asymmetric codecs an option has been added, asymmetric_rtp_codec,
which will return chan_pjsip to the previous behavior.

The codecs returned by the chan_pjsip module when queried by
the bridge_native_rtp module were also not reflective of the
actual negotiated codecs. The nativeformats are now returned as
they reflect the actual negotiated codecs.

ASTERISK-26423 #close

Change-Id: I6ec88c6e3912f52c334f1a26983ccb8f267020dc
2016-10-26 12:48:57 +00:00
Joshua Colp 7925f60cd9 res_pjsip_sdp_rtp: Fix address family of explicit media_address.
When an explicit media_address is provided the address family
in the SDP needs to be set to reflect it.

ASTERISK-26309

Change-Id: Ib9350cc91c120eb2f96f0623d3907d12af67eb79
2016-10-26 06:33:18 -05:00
Joshua Colp 7c79b057dd Merge "pjsip: Support dual stack automatically." 2016-10-25 05:29:45 -05:00
Joshua Colp 403c4f5833 pjsip: Support dual stack automatically.
This change adds support for dual stack automatically. No
configuration is required and the IP address and version
in the SIP messages and SDP will be automatically changed
based on the transport over which the message is being
sent. RTP usage has also been changed to listen on both
IPv4 and IPv6 simultaneously to allow media to flow, and
to allow ICE support on both simultaneously. This also
allows failover between IPv6 and IPv4 to work as expected.

ASTERISK-26309 #close

Change-Id: I235a421d8f9a326606d861b449fa6fe3a030572d
2016-10-23 13:53:55 +00:00
Mark Michelson 3bd76dd679 ARI: Add duplicate channel ID checking for channel creation.
This is similar to what is done for origination, but for the 14 and up
channel creation method. When attempting to create a channel, if a
channel ID is specified and a channel already exists with that ID, then
a 409 is returned.

Change-Id: I77f9253278c6947939c418073b6b31065489187c
2016-10-20 13:00:10 -05:00
Mark Michelson e459b8dadf ARI: Detect duplicate channel IDs
ARI and AMI allow for an explicit channel ID to be specified
when originating channels. Unfortunately, there is nothing in
place to prevent someone from using the same ID for multiple
channels. Further complicating things, adding ID validation to channel
allocation makes it impossible for ARI to discern why channel allocation
failed, resulting in a vague error code being returned.

The fix for this is to institute a new method for channel errors to be
discerned. The method mirrors errno, in that when an error occurs, the
caller can consult the channel errno value to determine what the error
was. This initial iteration of the feature only introduces "unknown" and
"channel ID exists" errors. However, it's possible to add more errors as
needed.

ARI uses this feature to determine why channel allocation failed and can
return a 409 error during origination to show that a channel with the
given ID already exists.

ASTERISK-26421

Change-Id: Ibba7ae68842dab6df0c2e9c45559208bc89d3d06
2016-10-20 12:59:06 -05:00
Michael Walton 3e96d491d0 res_rtp_asterisk: Add ice_blacklist option
Introduces ice_blacklist configuration in rtp.conf. Subnets listed in the
form ice_blacklist = <subnet spec>, e.g. ice_blacklist =
192.168.1.0/255.255.255.0, are excluded from ICE host, srflx and relay
discovery. This is useful for optimizing the ICE process where a system
has multiple host address ranges and/or physical interfaces and certain
of them are not expected to be used for RTP. Multiple ice_blacklist
configuration lines may be used. If left unconfigured, all discovered
host addresses are used, as per previous behavior.

Documention in rtp.conf.sample.

ASTERISK-26418 #close

Change-Id: Ibee88f80d7693874fda1cceaef94a03bd86012c9
2016-10-19 07:15:20 -05:00
Joshua Colp f31772ec20 ari: Update model validator based on addition of asterisk_id.
ASTERISK-26470

Change-Id: I9c386f7a1c7d969161b28f189eb6298bbc5b7541
2016-10-18 11:52:44 -05:00
Matt Jordan dd5129d84a res/ari: Add the Asterisk EID field to outgoing events
This patch adds the Asterisk EID field to all outgoing ARI events.
Because this field should be added to all events as they are
transmitted, it is appended to the JSON message just prior to it being
handed off to the application message handler. This makes it somewhat
resilient to both new events being added to ARI, as well as other
potential event transport mechanisms.

ASTERISK-26470 #close

Change-Id: Ieff0ecc24464e83f3f44e9c3e7bd9a5d70b87a1d
2016-10-17 08:15:08 -05:00
Richard Mudgett 9c49b96374 Audit ast_json_pack() calls for needed UTF-8 checks.
Added needed UTF-8 checks before constructing json objects in various
files for strings obtained outside the system.  In this case string values
from a channel driver's peer and not from the user setting channel
variables.

* aoc.c: Fixed type mismatch in s_to_json() for time and granularity json
object construction.

ASTERISK-26466
Reported by: Richard Mudgett

Change-Id: Iac2d867fa598daba5c5dbc619b5464625a7f2096
2016-10-13 18:13:00 -05:00
Torrey Searle 20c3dba39e res_fax: Fix a tight race condition causing fax to crash in audio fallback
When T.38 gets rejected and G711 failback occurs there is a period of
time where neither AST_FAX_TECH_T38 nor AST_FAX_TECH_AUDIO is set,
leading to a crash.

Change-Id: Icc3f457b2292d48a9d7843dac0028347420cc982
2016-10-12 06:54:13 -05:00
zuul 3981bc2a54 Merge "res_calendar: Add support for fetching calendars when reloading" 2016-10-11 19:22:24 -05:00
Torrey Searle cc269766b8 res_rtp_asterisk: Fix infinite DTMF issue when switching to P2P bridge
If a bridge switched to P2P when a DTMF was in progress it
was possible for the DTMF to continue being sent indefinitely.

Change-Id: I7e2a3efe0d59d4b214ed50cd0b5d0317e2d92e29
2016-10-10 17:00:23 -05:00
Badalyan Vyacheslav 3ab7fae96b res_pjsip_config_wizard: Memory leak in module_unload
Fixed a memory leak. It removes only the first element.
Added a useful feature in vector.h to remove all items
under the CMP through a callback function / macro.

ASTERISK-26453 #close

Change-Id: I84508353463456d2495678f125738e20052da950
2016-10-10 12:01:20 -04:00
Ludovic Gasc (GMLudo) 9f62feca60 res_calendar: Add support for fetching calendars when reloading
We use a lot res_calendar, we are very happy with that, especially
because you use libical, the almost alone opensource library that
supports really ical format with all types of recurrency.

Nevertheless, some features are missed for our business use cases.

This first patch adds a new option in calendar.conf:
fetch_again_at_reload. Be my guest for a better name.

If it's true, when you'll launch "module reload res_calendar.so",
Asterisk will download again the calendar.

The business use case is that we have a WebUI with a scheduler planner,
we know when the calendars are modified.

For now, we need to define 1 minute of timeout to have a chance that
our user doesn't wait too long between the modification and the real
test.  But it generates a lot of useless HTTP traffic.


ASTERISK-26422 #close

Change-Id: I384b02ebfa42b142bbbd5b7221458c7f4dee7077
2016-10-10 10:43:53 -05:00
George Joseph c7e4e035a2 Merge "codec_opus: Replace res_format_attr_opus with the one from codec_opus" 2016-09-27 14:12:52 -05:00
George Joseph 5cc3c6679f codec_opus: Replace res_format_attr_opus with the one from codec_opus
Preparation

ASTERISK-26409

Change-Id: I9f20e7cce00c32464d9a180e81283d49d199d0a3
(cherry picked from commit 59f7662a93)
2016-09-27 13:42:02 -05:00
George Joseph 43901e9418 build_tools: Add ability to download variants to download_externals
Some external packages have multiple variants that apply to different
builds of asterisk.  The DPMA for instance has a "bundled" variant that
needs to be downloaded if asterisk was configured with
--with-pjproject-bundled.

There are 2 ways to specify variants:

If you need the user to make the decision about which variant to
download, simply create multiple menuselect "member" entries like so...

<member name="res_digium_phone" displayname="..snipped..">
  <support_level>external</support_level>
  <depend>xmlstarlet</depend>
  <depend>bash</depend>
  <defaultenabled>no</defaultenabled>
</member>

<member name="res_digium_phone-bundled" displayname="..snipped..">
  <support_level>external</support_level>
  <depend>xmlstarlet</depend>
  <depend>bash</depend>
  <defaultenabled>no</defaultenabled>
</member>

Note that the second entry has "-<variant>" appended to the name.
You can then use the existing menuselect facilities to restrict which
members to enable or disable.  Youy probably don't want the user to
enable multiple at the same time.

If you want to hide the details of the variants, the better way to
do it is to create 1 member with "variant" elements.

<member name="res_digium_phone" displayname="..snipped..">
  <support_level>external</support_level>
  <depend>xmlstarlet</depend>
  <depend>bash</depend>
  <defaultenabled>no</defaultenabled>
  <member_data>
    <downloader>
      <variants>
        <variant tag="bundled"
          condition='[[ "$PJPROJECT_BUNDLED" = "yes" ]]'/>
      </variants>
    </downloader>
  </member_data>
</member>

The condition must be a bash expression suitable for use with an "if"
statement.  Any environment variable can be used plus those available
in makeopts.

In this case, if asterisk was configured with --with-pjproject-bundled
the bundled variant will be automatically downloaded.  Otherwise the
normal version will be downloaded.

Change-Id: I4de23e06d4492b0a65e105c8369966547d0faa3e
2016-09-25 13:40:23 -05:00
Joshua Colp 077caf566e res_odbc: Make pooling option deprecation notice more useful.
This changes the notice for the deprecation of the old
pooling options to point to the new option for doing
pooling. This gives a clearer direction as to what to
look into.

ASTERISK-26389 #close

Change-Id: I2ca9cdfdcd75aec170a7db9d5ff69a4cd25b7c10
2016-09-21 11:05:56 -05:00
zuul 0df2373434 Merge "res_pjsip_multihomed: Change Contact port to listening port." 2016-09-20 12:45:16 -05:00
Richard Mudgett 2820b13393 res_config_odbc.c: Fix buffer size limitation creating invalid SQL.
Creating ODBC SQL queries resulted in queries too large to fit into the
supplied buffer.  The resulting truncated buffer contained an invalid SQL
query.

* Made SQL query generation code use a thread storage buffer that can
increase in size as needed.

* Fixed bad multi-line warning messages.

ASTERISK-26263 #close
Reported by: Jeppe Ryskov Larsen

Change-Id: I23f3cdd43c2dac80bed3ded4dd77d18cb17f21ae
2016-09-16 12:00:12 -05:00
Joshua Colp 9d894ee0a1 res_pjsip_multihomed: Change Contact port to listening port.
The res_pjsip_multihomed module determines what interface and transport
a request is going out on and updates the SIP message accordingly with
the address information. This currently incorrectly updates the Contact
header for connectionful protocols to the ephemeral connection port,
instead of the bound address for the listening socket which can actually
accept the connection back. If the remote side attempts to connect back on
the epehemeral port it will fail.

This change makes it so the port is updated to the bound port on
connectionful protocols and is maintained on UDP (as there can be
multiple of those).

ASTERISK-26374 #close

Change-Id: I50f8dab65b9f75117d73ba5f6bbcf6c9871854ab
2016-09-15 08:26:36 -05:00
zuul 95cf4f8d31 Merge "res_pjsip_transport_management: Convert time in log message to seconds." 2016-09-14 22:35:43 -05:00
Joshua Colp 89764f7ae9 rtp: Preserve timestamps on video frames.
Currently when receiving video over RTP we store only
a calculated samples on the frame. When starting the video
it can take some time for this calculation to actually yield
a value as it requires constant changing timestamps. As well
if a video frame passes over multiple RTP packets this calculation
will fail as the timestamp is the same as the previous RTP
packet and the number of samples calculated will be 0.

This change preserves the timestamp on the frame and allows
it to pass through the core. When sending the video this timestamp
is used instead of a new one being calculated.

ASTERISK-26367 #close

Change-Id: Iba8179fb5c14c9443aee4baf670d2185da3ecfbd
2016-09-14 12:58:10 -05:00
zuul cbd6f7001e Merge "res_pjsip: Add ignore_uri_user_options option." 2016-09-14 12:27:28 -05:00
Joshua Colp 5f54ac3a80 res_pjsip_transport_management: Convert time in log message to seconds.
ASTERISK-26375 #close

Change-Id: I46496af5cae41413e76d44d2068a7431279f09dc
2016-09-14 09:53:33 -05:00
zuul 87aa445559 Merge "res_pjsip: Don't assume a request will have any addresses." 2016-09-13 18:24:44 -05:00
zuul 8076e78d50 Merge "res_pjsip_messaging.c: Misc cleanups and fixes." 2016-09-13 09:04:02 -05:00
Joshua Colp e3487b9360 res_pjsip: Don't assume a request will have any addresses.
When performing DNS resolution the failover code present in
res_pjsip currently assumes that a request will always have
at least one viable address. In practice this is not true.
A domain may be used that has no records.

The code now checks that at least one address exists on the
request which prevents looping.

ASTERISK-26364 #close

Change-Id: Ic0761b0264864acd85915c94d878a81624940f4c
2016-09-13 06:10:06 -05:00
Richard Mudgett ba362822f3 res_pjsip: Add ignore_uri_user_options option.
This implements the chan_sip legacy_useroption_parsing option but with a
better name.

* Made the caller-id number and redirecting number strings obtained from
incoming SIP URI user fields always truncated at the first semicolon.
People don't care about anything after the semicolon showing up on their
displays even though the RFC allows the semicolon.

ASTERISK-26316 #close
Reported by: Kevin Harwell

Change-Id: Ib42b0e940dd34d84c7b14bc2e90d1ba392624f62
2016-09-09 17:13:02 -05:00
zuul 9d54dd04bb Merge "res/res_pjsip: Add preferred_codec_only config to pjsip endpoint." 2016-09-09 13:56:16 -05:00
Joshua Colp 901e612739 res_pjsip: Only invoke unidentified endpoint logic when unidentified.
The code was incorrectly invoking the unidentified logic when
an endpoint had actually been identified, causing log messages
to be output.

ASTERISK-26349 #close

Change-Id: Id8104fc9e3d138d5e8b6f6977ecc08765fd17d4f
2016-09-09 05:45:06 -05:00
Aaron An 2a50c29101 res/res_pjsip: Add preferred_codec_only config to pjsip endpoint.
This patch add config to pjsip by endpoint.
;preferred_codec_only=yes
; Respond to a SIP invite with the single most preferred codec
; rather than advertising all joint codec capabilities. This
; limits the other side's codec choice to exactly what we prefer.

ASTERISK-26317 #close
Reported by: AaronAn
Tested by: AaronAn

Change-Id: Iad04dc55055403bbf5ec050997aee2dadc4f0762
2016-09-09 05:36:19 -05:00
Mark Michelson 28b2aeba0b res_pjsip: Do not crash on ACKs from unknown endpoints.
The endpoint identification PJSIP module is intended to identify which
endpoint an incoming request is from. If an endpoint is not identified,
then an artificial endpoint is used in its place when proceeding.

The problem is that the ACK request type is an exception to the rule.
The artificial endpoint is not used when processing an ACK. This results
in the possibility of having a NULL endpoint being used further on.

The reason ACK is an exception is an attempt not to spam security logs
with unidentified requests. Presumably, you've already logged the
unidentified request on the preceeding INVITE.

Up until Asterisk 13.10, retrieving a NULL endpoint in this fashion
didn't cause an issue. A new change in 13.10 added endpoint ACL checking
shortly after endpoint identification. Because we are accessing a NULL
endpoint, this ACL check resulted in a crash.

The fix here is to be sure to retrieve the artificial endpoint for all
request types. ACKs still do not generate unidentified request security
events.

ASTERISK-26264 #close
Reported by nappsoft

AST-2016-006

Change-Id: Ie0c795ae2d72273decb972dd74b6a1489fb6b703
2016-09-09 10:33:52 +00:00
zuul 345253fb71 Merge "res_pjsip: Allow global headers to be overridden." 2016-09-08 13:25:57 -05:00
zuul c5fcb54e11 Merge "res/res_stasis_playback: Cancel the entire playlist when a stop occurs" 2016-09-07 19:26:27 -05:00
Richard Mudgett f369dbb705 res_pjsip_messaging.c: Misc cleanups and fixes.
* Eliminated RAII_VAR in get_outbound_endpoint().

* Simplify update_to() coding.  However, this function can only be a NoOp
because the To string can only be a URI and not a name-address formatted
string.

* Simplify update_from() coding.  Also fixed a code path modifying the
from string when the caller could still want to use the original string.

* Fixed msg_data_create() incompletely removing the "pjsip:" to then add
back the "sip:" string if needed.  The code didn't handle the "pjsip:sip:"
case because it left the colon after pjsip in the string.

Change-Id: I68a09a665f6d4daa9eaa59069045ab69122e28db
2016-09-07 16:04:33 -05:00
Joshua Colp 2e5da0c715 res_pjsip: Allow global headers to be overridden.
Currently when you add global headers from the dialplan both
the header in the dialplan and the globally configured header
are added to the resulting SIP INVITE. This change makes it
so the headers in the dialplan take precedence and are the
only ones added.

Change-Id: I36f864298f38db3632ad503edc11267cb8ffb3ad
2016-09-07 16:02:01 -05:00
zuul 004d3c32ba Merge "res_resolver_unbound: Fix config documentation." 2016-09-07 15:44:04 -05:00
zuul 51ec782372 Merge "res_pjsip_session: segfault on already disconnected session" 2016-09-07 14:41:27 -05:00
zuul edaba05fea Merge "build: Add download capability for external packages" 2016-09-07 08:19:40 -05:00
Joshua Colp baa7dba180 res_resolver_unbound: Fix config documentation.
The code was referencing the config section as 'globals'
instead of 'general'. This change swaps it over to 'general'.

Change-Id: I9dfe7788f41c4a6754c77e103880dc1a747de7fe
2016-09-07 06:01:44 -05:00
Joshua Colp 2ff853279f Merge "pjsip_configuration.c: Ignore repeated identify by methods." 2016-09-07 05:02:55 -05:00
zuul 43ef73ad45 Merge "resource_channels.c: add hangup reason "answered_elsewhere"." 2016-09-07 02:05:47 -05:00
zuul 7437467d94 Merge "res_pjsip_registrar.c: Reduce stack usage in find_aor_name()." 2016-09-06 22:47:50 -05:00
zuul d0beb475b4 Merge "config_global.c: Comments and a default expression adjustment." 2016-09-06 19:45:03 -05:00
Matt Jordan e769c19a31 res/res_stasis_playback: Cancel the entire playlist when a stop occurs
Prior to this patch, a stop issued by a delete of a Playback resource
(indicated by the control frame AST_CONTROL_STREAM_STOP) would only stop
the current media URI playing. Subsequent URIs specified by a playback
operation would then proceed on, even though we had just indicated to
the User that the Playback was finished *and* after they had just
'deleted' the resource. Whoops.

This patch corrects it by bailing out of the sequence of URIs to play if
one of them is terminated with an AST_CONTROL_STREAM_STOP indication.

ASTERISK-26341 #close

Change-Id: I2da9ec43545ba46cdfffe287c7e4907eae7fca42
2016-09-06 15:34:36 -05:00
George Joseph 6caf6bcdad build: Add download capability for external packages
The DPMA and g729a, silk, siren7 and siren14 codecs hosted at
http://downloads.digium.com/pub/telephony/ are now listed in the
"External" sections of the "Resource Modules" and "Codec Translators"
pages in menuselect.  Any that are selected will automatically be
downloaded and installed when "make install" is run.  Their LICENSE and
README (if avaialble) files will be installed to
ASTVARLIBDIR/documentation/thirdparty/<product_name>.

Example use with codecs:

The codecs/codecs.xml file is a menuselect style xml file that lists
the codecs to be included.  Their support levels are 'external', which
triggers the download and install, and defaultenabled is no.  Also
because codec_g729a is actually in a directory named codec_g729 on the
download server, the newly added 'member_data' element is used to
override the default of the directory name being the package name.  You
can use the 'directory_name' attribute to keep default base URL
(http://downloads.digium.com/pub/telephony/) but use the new directory,
or you use the 'remote_url' attribute to specify a full URL to the
download directory.  In this case, you must still follow the same
subdirectory naming conventions as that used for the packages located
at 'http://downloads.digium.com/pub/telephony'.

A new configure option '--with-externals-cache' was added and like
'--with-sounds-cache' it allows the installer to cache tarballs so
they're not downloaded every time.

To assist with the download and install process, each external package
now has a manifest.xml file that, among other things, contains a package
version and checksums for each file in the tarball.  The manifest is
saved to both the cache directory and ASTMODDIR and together with the
manifest.xml on the downloads site, tells the install scripts whether
a download and/or update is needed.

bash and xmlstarlet are required for downloader operation.  If they're
not installed, the external items in menuselect will be unavailable.

Change-Id: Id3dcf1289ffd3cb0bbd7dfab3cafbb87be60323a
2016-09-06 10:39:28 -05:00
Alexei Gradinari 7bb7f7b9d5 res_pjsip_session: segfault on already disconnected session
On heavy loaded system the TCP/TLS incoming calls could be
disconnected by pjproject while these calls are being
processed by asterisk which could use the session's memory pools.
If the session in the disconnected state then the session memory
pools were already freed, so we get segfault.

This patch adds a lifetime control on an INVITE session to pjproject.
The lifetime of the session is manipulated by calling
pjsip_inv_add_ref/pjsip_inv_dec_ref.
This patch uses these functions to inform pjproject that the
session is in use.

This patch adds check if the session state is not disconnected
and also checks if the memory pool is not NULL.

This patch also places tasks 'session_end' and 'session_end_completion'
into session's serializer to avoid race condition.

ASTERISK-26291 #close

Change-Id: I4d28b1fb3b91f0492a911d110049d670fdc3c8d7
2016-09-06 08:58:42 -05:00
Richard Mudgett 68c7694abb res_pjsip_registrar.c: Reduce stack usage in find_aor_name().
Change-Id: I8aebad1fdcf303bd115b59a4b57fbbd5b2267f09
2016-09-02 13:24:29 -05:00
Richard Mudgett 35ce4d25c7 pjsip_configuration.c: Ignore repeated identify by methods.
Change-Id: Ied0c06043d1dfef8fdc9c9a808cf89b118119838
2016-09-02 13:21:32 -05:00
Richard Mudgett c1e438fdf7 config_global.c: Comments and a default expression adjustment.
Change-Id: Ia6a58f8c73a30da6874b3f94364dce162d6f1ad3
2016-09-02 13:16:25 -05:00
Corey Farrell e875e1c12a sorcery: Create function ast_sorcery_lockable_alloc.
Create an alternative to ast_sorcery_generic_alloc which uses astobj2
shared locking. Use this new method for the 'struct ast_sip_aor' allocator.

Change-Id: I3f62f2ada64b622571950278fbb6ad57395b5d6f
2016-09-02 09:26:25 -04:00
Jean Aunis 91993ebaa5 resource_channels.c: add hangup reason "answered_elsewhere".
In ARI, the channels API allows to hangup a channel with a hangup reason.
This commit adds a new reason "answered_elsewhere".
When using a SIP channel, this will eventually allow Asterisk to add a proper
"Reason" header to a CANCEL message.

ASTERISK-26321

Change-Id: Ia97675bd4acd6a7f58eb467953dfb94559f6583d
2016-08-31 12:33:28 +02:00
Alexei Gradinari faf9bdebb7 res_pjsip: qualify/unqualify added/deleted realtime endpoints
If the PJSIP endpoint's AOR with the permanent contact
was deleted from the realtime storage the res_pjsip module
continues trying to qualify this contact.
The error 'Unable to find an endpoint to qualify contact'
appeares every 'qualify_frequency' seconds.
This patch deletes this contact in this case.

The PJSIP endpoint's AOR with the permanent contact
is never qualified if it is added to realtime storage
after asterisk started.
This patch adds qualifying for the AOR's permanent contacts
on the first handling of this AOR.

ASTERISK-26319 #close

Change-Id: Ib93dded9121edb113076903d1aa95402f799f8fe
2016-08-30 15:58:56 -05:00
Mark Michelson c98a047ee6 res_pjsip: Default endpoints to the "offline" status.
A recent change attempted to optimize startup by not updating contact
status. Instead, code responsible for qualifying contacts updates the
status as it becomes known. The code even accounts for contacts/AORs
that are not set to be qualified.

The problem, though, is when there are no contacts associated with an
endpoint. A common case is when an endpoint is set to register its
contacts but has not done so yet. In this case, prior to registration,
the endpoint's device state will appear to be "not in use" and hints
associated with that device will appear to be "idle". In actuality, the
device state and hint should both appear as "unavailable". The reason
for the failure is that the optimization change made all persistent
endpoint states set to "unknown".

The fix here is to change the hard-coded "unknown" to be "offline"
instead. The default state will be offline until the qualifying code
determines that the contact is actually online. This way, if there are
no contacts at all, then the state stays as offline, and device state
and hints appear correctly.

ASTERISK-26269 #close
Reported by nappsoft

Change-Id: Ie99b84169393983453076f5e9c0d35ff313a456a
2016-08-29 11:23:38 -05:00
zuul 90b7f7fdb5 Merge "res_pjsip: Cache global config options." 2016-08-26 22:17:40 -05:00
Richard Mudgett ea929d766d res_pjsip: Cache global config options.
We may check a global config option hundreds of times a second or more.
Asking sorcery for the global configuration from the config files backend
involves several allocations and container traversals.  Using realtime
without a memory cache is a lot worse because you have to lookup in the
realtime database each time to reconstitute the sorcery object.  With a
memory cache for realtime, there is about the same amount of overhead as
for config files.  Either way, it is still fairly expensive to access the
sorcery object that much.

* Cache the global config options so we can access them faster.  You must
now always perform a res_pjsip reload to change the global options.

Change-Id: Ice16c7a4cbca4614da344aaea21a072b86263ef7
2016-08-25 18:16:43 -05:00
Richard Mudgett 5eb6cb969f res_fax: Fix deadlock in ast_channel_get_t38_state().
ast_channel_get_t38_state() calls ast_channel_queryoption() with
AST_OPTION_T38_STATE.  If the passed in channel is a local channel then a
deadlock can happen if a channel lock is held when called.

* Made ast_channel_get_t38_state() callers not hold a channel lock before
calling.

* Update ast_channel_get_t38_state() doxygen to note that no channel locks
can be held when calling the function.

ASTERISK-26203 #close
Reported by: Etienne Lessard

ASTERISK-24822 #close
Reported by: David Brillert

ASTERISK-22732 #close
Reported by: Richard Mudgett

Change-Id: I49fd76fa9af628b4198009b5c0b82c8b03681214
2016-08-25 17:11:51 -05:00
Richard Mudgett 277a2d667a res_fax: Fix deadlock setting FAXMODE channel variable.
ASTERISK-25980 added the FAXMODE channel variable to res_fax.c.
Unfortunately, it also introduced a deadlock potential because
set_channel_variables() which sets FAXMODE can be called during a
masquerade.  The ast_channel_get_t38_state() which gets the value used to
set FAXMODE cannot be called with the channel locked.  As a result, local
channels can deadlock because of how they must acquire the locks necessary
to operate.

The intent of FAXMODE is for dialplan to know how a fax was transferred
after the fax completes.  However, the previous patch sets FAXMODE to the
channel's current T.38 state AFTER the fax has completed and where T.38
may have already disconnected.

* Set FAXMODE based upon T.38 negotiations exchanged either with the fax
applications or the fax framehooks.

ASTERISK-26203
Reported by: Etienne Lessard

ASTERISK-24822
Reported by: David Brillert

ASTERISK-22732
Reported by: Richard Mudgett

Change-Id: Id525747254b64c1efe8b1b5973d52ff9719c2ae1
2016-08-25 17:11:51 -05:00
Richard Mudgett edca14c8a5 res_fax.c: Fix deadlock in fax_gateway_indicate_t38().
fax_gateway_indicate_t38() calls ast_indicate_data() which cannot be
called with any channel locks already held.  A deadlock can happen if the
function is operating on a local channel.

* Made fax_gateway_indicate_t38() unlock the channel before calling
ast_indicate_data() since fax_gateway_indicate_t38() is always called with
the channel locked.

* Made fax_gateway_indicate_t38() return void since nothing cared about
its return value.

ASTERISK-26203
Reported by: Etienne Lessard

ASTERISK-24822
Reported by: David Brillert

ASTERISK-22732
Reported by: Richard Mudgett

Change-Id: I701ff2d26c5fc23e0d5a48a3fd98759a9fd09407
2016-08-25 17:11:51 -05:00
Richard Mudgett 141cd42880 res_fax.c: Add chan locked precondition comments.
Change-Id: Ic10ae434536bbf7fb7055d6ab36cc50b8748a4e7
2016-08-25 17:11:50 -05:00
Richard Mudgett b86771d1bf ast_framehook_detach() must be called with the channel locked.
The framehook container could become corrupted if the channel lock is not
held before calling.

Change-Id: If0a1c7ba0484ed3a191106a7516526b905952584
2016-08-25 17:11:50 -05:00
Richard Mudgett 5744f434f0 ast_framehook_attach() must be called with the channel locked.
The framehook container could become corrupted if the channel lock is not
held before calling.

Change-Id: I1a6b957a1f7b899eb29a186915f8cccab886a438
2016-08-25 17:11:50 -05:00
George Joseph e40aa40aca res_rtp_multicast: Fix SEGV in ast_multicast_rtp_create_options
ast_multicast_rtp_create_options now checks for NULL or empty options

Change-Id: Ib845eae46a67a9787e89a87ebd1027344e5e0362
2016-08-24 14:54:14 -05:00
zuul 27813c7439 Merge "compilation failed with -Werror=maybe-uninitialized" 2016-08-22 11:22:13 -05:00
zuul 47c9acb5b2 Merge "res_odbc_transaction: add dep on generic_odbc" 2016-08-22 09:57:09 -05:00
Alexei Gradinari 41ee14bfae compilation failed with -Werror=maybe-uninitialized
The compilation failed for devmode
--enable DONT_OPTIMIZE
--enable BETTER_BACKTRACES
--enable DO_CRASH
--enable TEST_FRAMEWORK

res_pjsip/pjsip_configuration.c: In function dtls_handler:
res_pjsip/pjsip_configuration.c:974:20: error:
back may be used uninitialized in this function [-Werror=maybe-uninitialized]
int size = strlen(front);
           ^
cc1: all warnings being treated as errors

Change-Id: I7f082ead0312792a577ec7c73015ba64dabca580
2016-08-22 08:56:11 -05:00
David M. Lee eb0c9c476f res_odbc_transaction: add dep on generic_odbc
When res_odbc_transaction depended on res_odbc, it got the generic_odbc
headers and libs implicitly. Now that it no longer depends on res_odbc,
its dependency on generic_odbc must be explicit.

Change-Id: I9db88f7af7388437f49903d3008ba8d4890d5911
2016-08-21 18:56:01 -05:00
Torrey Searle c1b6a79686 res_ari: Add http prefix to generated docs
updated the uri handler to include the url prefix of the http server
this enables res_ari to add it to the uris when generating docs

Change-Id: I279335a2625261a8492206c37219698f42591c2e
(cherry picked from commit 6f448f32fe)
2016-08-19 16:58:55 -05:00
zuul 2b057d6215 Merge "res_odbc: Correct the dependency relationship with res_odbc_transaction" 2016-08-19 15:52:36 -05:00
zuul 8932877044 Merge "rest-api: Swagger scripts were not replacing format variable in file brief" 2016-08-19 13:20:17 -05:00
zuul 22daced976 Merge "res_format_attr_g729: Add annexb=no format parameter to SDPs" 2016-08-19 11:03:39 -05:00
zuul d86ee51ca0 Merge "res_pjsip: Add contact_user to endpoint" 2016-08-19 10:08:11 -05:00
Kevin Harwell 53a2f7dc88 res_format_attr_g729: Add annexb=no format parameter to SDPs
Historically, Asterisk has always specified annexb=no for the g729 format.
However, when using res_pjsip no format attribute was specified. This patch
makes it so the SDP now contains a format attribute line with annexb=no.

Note, that this means only g729a is negotiated. Even for pass through support.
According to rfc7261 the type of annex used (a or b) is dependent upon the
answerer. However, Asterisk being a back to back user agent makes this tricky
to support at this time, thus we only allow annex 'a' for now.

ASTERISK-26228 #close
patches:
  res_format_attr_g729.c submitted by Jason Parker (license 4993)

Change-Id: I76bc20cc0a01af01536e9915afef319c269c22d0
2016-08-18 17:14:04 -05:00
Kevin Harwell 7ea133f2ab rest-api: Swagger scripts were not replacing format variable in file brief
Given resource paths did not have 'json' substituted in for the '{format}'. For
some auto generated documentation/comment strings it resulted in something like
the following:

"... REST handler for /api-docs/sounds.{format}"

This patch makes sure the resource api's path is properly substituted.

ASTERISK-25472 #close

Change-Id: Ie3e950a35db4043e284019d6c9061f3b03922e23
2016-08-18 17:02:24 -05:00
George Joseph c7ffd6111d res_odbc: Correct the dependency relationship with res_odbc_transaction
The MODULEINFO dependencies between these 2 modules was reversed.
res_odbc should depend on res_odbc_transaction, not the other way
around.

ASTERISK-25984 #close

Change-Id: Ifcfbb49c0b51cf6640a5446d47cd6c48caf1331f
2016-08-18 15:30:51 -05:00
George Joseph 534063fd67 res_pjsip: Add contact_user to endpoint
contact_user, when specified on an endpoint, will override the user
portion of the Contact header on outgoing requests.

Change-Id: Icd4ebfda2f2e44d3ac749d0b4066630e988407d4
2016-08-17 16:21:19 -05:00
Richard Mudgett 0b4fa65532 res_pjsip_session.c: Fix unbound srv failover tests.
Commit 1b666549f3 broke the srv failover
functionality if a TCP connection gets disconnected.  Under these
conditions, session_inv_on_state_changed() gets a
PJSIP_EVENT_TRANSPORT_ERROR and restarts the INVITE transaction on a new
transport.  Unfortunately, session_inv_on_tsx_state_changed() also gets
the same PJSIP_EVENT_TRANSPORT_ERROR event and unconditionally terminates
the session.

* Made session_inv_on_tsx_state_changed() complete terminating the session
on PJSIP_EVENT_TRANSPORT_ERROR only if the session state is still
PJSIP_INV_STATE_DISCONNECTED.

ASTERISK-26305 #close
Reported by: Richard Mudgett

Change-Id: If736e766b5c55b970fa38ca6c8a885caf27b897d
2016-08-17 16:14:11 -05:00
Corey Farrell 824a4e84d1 Refactor usage pattern of xmldoc info tag.
This updates func_channel.c and main/message.c to use a generic xpointer
include instead of including info from each channel driver.  Now the
name attribute of info is CHANNEL or CHANNEL_EXAMPLES to be included in
documentation for func_channel.  Setting the name attribute of info to
MessageToInfo or MessageFromInfo causes it to be included in the
MessageSend application and AMI action.

Change-Id: I89fd8276a3250824241a618009714267d3a8d1ea
2016-08-16 10:42:46 -05:00
zuul 9fc83f8ffd Merge "core: Entity ID is not set or invalid" 2016-08-16 10:03:20 -05:00
Joshua Colp 2e7100855d Merge "res_sorcery_config.c: Cleanup ao2 container usage idioms." 2016-08-16 08:24:38 -05:00
Alexei Gradinari e85adbd947 core: Entity ID is not set or invalid
The Exchanging Device and Mailbox States could not working
if the Entity ID (EID) is not set manually and can't be obtained
from ethernet interface.

This patch replaces debug message to warning
and addes missing description about option 'entityid' to
asterisk.conf.sample.

With this patch the asterisk also:
(1) decline loading the modules which won't work without EID:
    res_corosync and res_pjsip_publish_asterisk.
(2) warn if EID is empty on loading next modules:
    pbx_dundi, res_xmpp

Starting with v197 systemd/udev will automatically assign "predictable"
names for all local Ethernet interfaces.
This patch also addes some new ethernet prefixes "eno" and "ens".

ASTERISK-26164 #close

Change-Id: I72d712f1ad5b6f64571bb179c5cb12461e7c58c6
2016-08-15 13:35:59 -05:00
Richard Mudgett 13450c80ce res_sorcery_config.c: Cleanup ao2 container usage idioms.
Change-Id: Iad24b335fb121a2bc7f1d048ab7420569edcba5a
2016-08-15 13:15:02 -05:00
Matt Jordan 3269cf4c17 res_agi: Improve documentation
* Groups of AGI commands that have similar functionality now reference
  each other, and all reference the AGI application for ease of wiki
  reference.

* The documentation for the AGI application has been improved, in
  particular noting the various AGI types and how they are invoked.

* A warning message has been added to DeadAGI, noting that it is
  deprecated.

Change-Id: I479ccdee8a7393f01b18692c3d4ab7e6bdd1875d
2016-08-15 07:40:19 -05:00
Joshua Colp 8b1e919ae4 Merge "res_pjsip: Fail global load if debug or default_from_user are empty" 2016-08-12 17:38:14 -05:00
zuul 234d4a818e Merge "res_pjsip_caller_id: Copy header name to short header name" 2016-08-12 16:08:45 -05:00
Joshua Colp 23670f277f Merge "location.c: Misc fixes and cleanups." 2016-08-12 12:08:57 -05:00
Joshua Colp 088104b2ab Merge "res_pjsip res_pjsip_mwi: Misc fixes and cleanups." 2016-08-12 04:46:10 -05:00
zuul 5fad1f110b Merge "pjsip_distributor.c: Add missing allocation failure check." 2016-08-12 03:46:22 -05:00
zuul fb88244957 Merge "res_pjsip: Make aor named lock a mutex." 2016-08-11 23:27:15 -05:00
zuul 88e90db659 Merge "res_odbc: Show only when there a fail attempt of connection in CLI" 2016-08-11 21:04:35 -05:00
George Joseph d7534e016b res_pjsip_caller_id: Copy header name to short header name
When compact_headers was set, we were sending a zero-length header name
for PAI and RPID because we always forced the short header name length
to 0.  We did this because we cloned the header from "From" and wanted
to clear "f" from the sname.  By cloning however, we bypass pjproject's
automatic logic that sets sname to name if there's no compact form of
the header, which there isn't for PAI and RPID.  So now we force sname
to be the same as name right after we set name.

res_pjsip_diversion needed the same treatment for the Diversion header.

ASTERISK-26241 #close

Change-Id: I633ec139630cd83809aae00336cee4a10077e467
2016-08-11 14:17:42 -05:00
zuul 8d84c8edff Merge "res_resolver_unbound: Allow compilation with libunbound version < 1.5" 2016-08-11 13:49:45 -05:00
George Joseph aeb859dba9 res_pjsip: Fail global load if debug or default_from_user are empty
If debug was specified in the global configuration but left blank,
the logger would treat it as a wildcard and log all hosts.  If
default_from_user was empty, a crash would result.

The global apply handler now checks for empty strings.

ASTERISK-26239 #close
ASTERISK-26238 #close

Change-Id: Ie75727f5cd5808845d92cc81f5713842fb203336
2016-08-11 12:33:14 -05:00
Richard Mudgett 2275494e80 res_pjsip res_pjsip_mwi: Misc fixes and cleanups.
* Eliminated RAII_VAR() usage in
ast_sip_persistent_endpoint_update_state().

* Added a missing allocation failure check to
persistent_endpoint_find_or_create().

* Made persistent_endpoint_find_or_create() create the new object without
a lock as it isn't needed.

* Cleaned up some ao2 container allocation idioms.

* Reordered res_pjsip_mwi.c load_module() and unload_module()

Change-Id: If8ce88fbd82a0c72a37a2388f74f77237a6a36a8
2016-08-11 12:17:48 -05:00
Richard Mudgett d4ffbccef6 location.c: Misc fixes and cleanups.
* Eliminated most RAII_VAR() usage.

* Added several missing allocation failure checks.

* Made ast_sip_for_each_contact() allocate the wrapper ao2 object without
a lock as it is not needed.

Change-Id: Ie20913365156c95dd79e5d471cfd25e99ae880bc
2016-08-11 12:13:52 -05:00
Richard Mudgett 5ba6357be2 res_pjsip: Make aor named lock a mutex.
The named aor lock was always being locked for writes so a rwlock adds no
benefit and may be slower because rwlocks are biased toward read locking.

Change-Id: I8c5c2c780eb30ce5441832257beeb3506fd12b28
2016-08-11 11:58:38 -05:00
Richard Mudgett b6e03a5ff3 pjsip_distributor.c: Add missing allocation failure check.
Change-Id: I932ab2cea845e534d9ff318035b6de39972d3b28
2016-08-11 11:57:22 -05:00
zuul 74fffe9df2 Merge "res_srtp: Move SDP SRTP code from the core to res_srtp." 2016-08-11 06:19:33 -05:00
Richard Mudgett 41aba83ff6 res_srtp: Move SDP SRTP code from the core to res_srtp.
A patch made to the master branch (Now the 14 branch) inadvertently made
libsrtp a required dependency in order to compile Asterisk.  Rather than
create dummy defines to substitute for the defines supplied by libsrtp
when libsrtp is not available, most of the code in sdp_srtp.c is moved
into res_srtp.c.  This gets more code out of Asterisk's core that isn't
used when SRTP is not available.  This also makes another inadvertent
required dependency on libsrtp by Asterisk's core unlikely.

ASTERISK-26253 #close
Reported by: Ben Merrills

Change-Id: I0a46cde81501c0405399c2588633ae32706d1ee7
2016-08-10 17:43:15 -05:00
Alexei Gradinari 820879415f pjsip: Fix deadlock with suspend taskprocessor on masquerade
If both channels which should be masqueraded
are in the same serializer:
1st channel will be locked waiting condition 'complete'
2nd channel will be locked waiting condition 'suspended'

On heavy load system a chance that both channels will be in
the same serializer 'pjsip/distibutor' is very high.

To reproduce compile res_pjsip/pjsip_distributor.c with
DISTRIBUTOR_POOL_SIZE=1

Steps to reproduce:
1. Party A calls Party B (bridged call 'AB')
2. Party B places Party A on hold
3. Party B calls Voicemail app (non-bridged call 'BV')
4. Party B attended transfers Party A to voicemail using REFER.
5. When asterisk masquerades calls 'AB' and 'BV',
   a deadlock is happened.

This patch adds a suspension indicator to the taskprocessor.
When a session suspends/unsuspends the serializer
it sets the indicator to the appropriate state.
The session checks the suspension indicator before
suspend the serializer.

ASTERISK-26145 #close

Change-Id: Iaaebee60013a58c942ba47b1b4930a63e686663b
2016-08-10 15:14:38 -05:00
George Joseph 8d42ff784d res_resolver_unbound: Allow compilation with libunbound version < 1.5
libunbound at version 1.4.20 (which CentOS still uses) declared all
of their string function parameters as as 'char *'.  1.4.21 changed
them all to 'const char *'.  Thankfully 1.4.21 also introduced the
UNBOUND_VERSION_MAJOR define so configure now checks for that and
sets HAVE_UNBOUND_CONST_PARAMS.  res_resolver_unbound then checks
that and casts away the 'const' if it's not set.

Tested compile and testsuite on CentOS6 (1.4.20), Ubuntu14 (1.4.22) and
Fedora24 (1.5.4).  There are a few failing tests to be addressed though.

ASTERISK-26283 #close

Change-Id: Ib708b19b706c5d0ba7b7d5473e6df339d9ae4148
2016-08-10 12:09:51 -05:00
zuul d78fe8fed0 Merge "res_rtp_asterisk: Cache local RTCP address." 2016-08-10 10:22:49 -05:00
zuul 26921a5523 Merge "res_pjsip_mwi: fix unsolicited mwi blocks PJSIP stack" 2016-08-09 16:44:33 -05:00
Mark Michelson 8fe9f1f7f1 res_rtp_asterisk: Cache local RTCP address.
When an RTCP packet is sent or received, res_rtp_asterisk generates a
Stasis event that contains the RTCP report as well as the local and
remote addresses that the report pertains to.

The addresses are determined using ast_find_ourip(). For the local
address, this will typically result in a lookup of the hostname of the
server, and then a DNS lookup of that hostname. If you do not have the
host in /etc/hosts, then this results in a full DNS lookup, which can
potentially block for some time.

This is especially problematic when performing RTCP reads, since those
are done on the same thread responsible for reading and writing media.

This patch addresses the issue by performing a lookup of the local
address when RTCP is allocated. We then use this cached local address
for the Stasis events when necessary.

ASTERISK-26280 #close
Reported by Mark Michelson

Change-Id: I3dd61882c2e57036f09f0c390cf38f7c87e9b556
2016-08-09 16:22:56 -05:00
Alexei Gradinari 403b63571c res_pjsip_mwi: fix unsolicited mwi blocks PJSIP stack
The PJSIP taskprocessors could be overflowed on startup
if there are many (thousands) realtime endpoints
configured with unsolicited mwi.
The PJSIP stack could be totally unresponsive for a few minutes
after boot completed.

This patch creates a separate PJSIP serializers pool for mwi
and makes unsolicited mwi use serializers from this pool.
This patch also adds 2 new global options to tune taskprocessor
alert levels: 'mwi_tps_queue_high' and 'mwi_tps_queue_low'.

This patch also adds new global option 'mwi_disable_initial_unsolicited'
to disable sending unsolicited mwi to all endpoints on startup.
If disabled then unsolicited mwi will start processing
on next endpoint's contact update.

ASTERISK-26230 #close

Change-Id: I4c8ecb82c249eb887930980a800c9f87f28f861a
2016-08-08 13:57:58 -05:00
Rodrigo Ramírez Norambuena 0749f6e6f3 res_odbc: Show only when there a fail attempt of connection in CLI
When is executed CLI command "odbc show all" every time is show
information about variable last_negative_connect. If not there  a fail
attempt of connection will show date like "1969-12-31 21:00:00".

This patch fix there situation for to show only this information when
exists a fail attempt before.

Change-Id: I7c058b0be6f7642e922de75ee6b82c7276c9f113
2016-08-06 02:39:18 -04:00
Joshua Colp 54869e4823 res_pjsip_outbound_publish: Use a serializer shutdown group for unload.
This change replaces the custom unload process for the outbound
publish module with the common serializer shutdown group.

ASTERISK-25217 #close

Change-Id: I280a0384d860c486202d87d2d674394cca77ffb6
2016-08-05 06:31:14 -05:00
Kevin Harwell e711e57106 resource_channels: Sync with ARI stubs
This file was out of sync with the current ARI definitions.

Change-Id: Ie7cb7d6d3c2eeb9cc9d683ca87b43b117e713d0a
2016-08-04 10:29:38 -05:00
zuul 8878cedc0a Merge "res_pjsip: SIP/SDP origin (o=) contained square brackets on IP6 transports." 2016-08-02 17:38:14 -05:00
Joshua Colp 73bce50ef8 sorcery: Use more compatible regex for local expressions.
This changes the use of an empty regex for both res_sorcery_config
and res_sorcery_memory to "." instead. This is a more compatible
regular expression which also works on FreeBSD.

ASTERISK-26206 #close

Change-Id: Ia9166dd176f1597555ba22b6931180d0626c1388
2016-08-02 05:25:36 -05:00
Alexander Traud 3ff964c6b6 res_pjsip: SIP/SDP origin (o=) contained square brackets on IP6 transports.
ASTERISK-26256 #close

Change-Id: I3fd68df561f81fdb8c6c497d465b50c12422f058
2016-08-02 10:09:51 +02:00
zuul e2bfcb3e58 Merge "codecs: Add iLBC 20." 2016-07-26 10:52:35 -05:00
zuul 8e79e382b4 Merge "res_pjsip: Whitespace and comment cleanup." 2016-07-22 07:42:09 -05:00
Joshua Colp fd87c7a70c Merge "res_pjsip_pubsub: fixed a bug when pjsip_tx_data_dec_ref is called twice." 2016-07-22 04:51:12 -05:00
Alexander Traud 8fb807009f codecs: Add iLBC 20.
Asterisk already supported iLBC 30. This change adds iLBC 20. Now, Asterisk
defaults to iLBC 20 but falls back to iLBC 30, when the remote party requests
this.

ASTERISK-26218 #close
ASTERISK-26221 #close
Reported by: Aaron Meriwether

Change-Id: I07f523a3aa1338bb5217a1bf69c1eeb92adedffa
2016-07-22 10:09:08 +02:00
Richard Mudgett 4286a369a1 res_pjsip: Whitespace and comment cleanup.
Change-Id: I11139a4a95df34e223ba622aa6227e33ab8f6c38
2016-07-21 23:28:17 -05:00