Commit Graph

28529 Commits

Author SHA1 Message Date
Walter Doekes d80b28560c chan_sip: Don't refuse calls with "optional crypto"; fall back to RTP.
Certain SNOM phones send so-called "optional crypto" in their SDP body.
Regular SRTP setup looks like this:

    m=audio 64620 RTP/SAVP 8 0 9 99 3 18 4 101
    a=crypto:1 AES_CM_128_HMAC_SHA1_32 inline:...

SNOM-style "optional crypto" looks like this:

    m=audio 61438 RTP/AVP 8 0 9 99 3 18 4 101
    a=crypto:1 AES_CM_128_HMAC_SHA1_32 inline:...

A crypto line is supplied, but the m-line does not have SAVP.

When res_srtp.so is *not* loaded, then chan_sip.so treats the optional
crypto as regular RTP, but when res_srtp.so *is* loaded, it refuses the
incoming call with the following message:

    WARNING: process_sdp: Failed to receive SDP offer/answer with
    required SRTP crypto attributes for audio

For platforms that want to start providing SRTP this presents a
compatibility problem.

This changeset lets chan_sip handle the SDP as if no crypto-line was
supplied: i.e. accept the call as regular RTP, just like it did before
res_srtp was loaded.

Now you'll get this informative warning instead:

    WARNING: Ignoring crypto attribute in SDP because RTP transport is
    insecure

ASTERISK-23989 #close
Reported by: Olle Johansson

Change-Id: I91a15ae05a0296e398d6b65f53bb11afde1d80e2
2016-09-06 09:52:11 +02:00
Joshua Colp e34f299a96 Merge "codecs: Add Codec 2 mode 2400." 2016-09-04 14:11:34 -05:00
zuul f87008f11a Merge "app_mp3: Use correct buffer size and the same sample rate as the channel" 2016-09-04 12:54:47 -05:00
Matt Jordan 730cb3b0b7 apps/app_dial: Fix crash on non-connect call paths for Privacy/Screening option
In any scenario in which the callee is not connected to the caller, the
current code in app_dial will crash due to raising a Dial End Stasis
Message after the callee channel has been hung up. This patch corrects
the error by simply moving the explicit hangup of the callee (peer)
channel until after the dial end message.

ASTERISK-25691 #close

Change-Id: I816a414014424d0d8c80e2a3cbef13ef8c63798d
2016-09-03 16:07:36 -05:00
Matt Jordan 6e1a3b924e apps/app_dial: Set the DIALSTATUS to NOANSWER on privacy option 5
If the callee selects option '5' using the Dial application's privacy
(P) option, the DIALSTATUS is erroneously set to ANSWER. This option
reflects the callee sending the caller to VoiceMail one time; the call
is definitely *not* ANSWERed in such a scenario. With this patch, the
DIALSTATUS is instead set to NOANSWER, which is the same DIALSTATUS that
is set when the 'send to VoiceMail every time' option is set.

ASTERISK-25691

Change-Id: Iaf0c9f0fa00545e7366443875e2bb7d9a89a1358
2016-09-03 16:06:56 -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
Richard Mudgett edcf09e47c sip_to_pjsip.py: Map canreinvite as directmedia alias.
Change-Id: I48b8e150f96a3d2a24d8fc25fbe4f5aff9f4a6b2
2016-09-02 13:07:08 -05:00
Richard Mudgett 47336a0bdd sip_to_pjsip.py: Fix typo converting outboundproxy registration.
Change-Id: I6f30e5f9fcf8469ba0079fbf884047d54c2c0b15
2016-09-02 13:05:16 -05:00
Richard Mudgett dba02575fc sip_to_pjsip.py: Fix comment typo and tabs.
Change-Id: If35174614545727817d329c60ba4456c028941b5
2016-09-02 13:03:09 -05:00
Richard Mudgett 4aaa27e532 Sample configs: Eliminate false multiline comment block starts.
Change-Id: Ie627def9604ae30abd80754f9e6f09874825aec6
2016-09-02 13:01:13 -05:00
Richard Mudgett c3b965a2c0 format_cap.c: Fix CLI "core show channeltype Surrogate" crash.
* Make ast_format_cap_get_names() NULL tolerant.

ASTERISK-26331 #close
Reported by: CGI.NET

Change-Id: Id67e93936dc8ec2a33a9d33655843d43b59285a3
2016-09-02 12:56:21 -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
Corey Farrell 131baf70d6 named_locks: Use ao2_weakproxy to deal with cleanup from container.
This allows standard ao2 functions to be used to release references to
an ast_named_lock.  This change can cause less frequent locking of the
global named_locks container.  The container is no longer locked when a
named_lock reference is being release except when this causes the
named_lock to be destroyed.

Change-Id: I644e39c6d83a153d71b3fae77ec05599d725e7e6
2016-09-02 09:13:45 -04:00
Corey Farrell 0c5b6e9ff5 astobj2: Support using a separate object for locking.
Create ao2_alloc_with_lockobj function to support shared locking.

Change-Id: Iba687eb9843922be7e481e23a32c0700ecf88a80
2016-09-02 09:13:33 -04:00
zuul d3c4b901d4 Merge "res_pjsip: qualify/unqualify added/deleted realtime endpoints" 2016-09-01 13:21:54 -05:00
Joshua Colp cc26efece3 Merge "sip_to_pjsip: Migrate IPv4/IPv6 (Dual Stack) configurations." 2016-09-01 12:20:46 -05:00
Michael Kuron 48fd4c815c app_mp3: Use correct buffer size and the same sample rate as the channel
Previously, the buffer used for MP3 streamed from HTTP servers had a size of
1 MB. For 8 kHz mono audio at 16 bit resolution, such a buffer covers about 1
minute. Only when the buffer is full does audio start to play.
For MP3 files streamed from a server, that is usually not a big deal as long as
the connection to the server is fast enough to supply that much data within a
second or two. For MP3 live streams however, it takes 1 minute to download 1
minute of audio, so without this change, app_mp3 wasn't really usable for MP3
live streams.
This commit changes the buffer size so that it covers 6 seconds of an MP3 file
streamed from a server and 0.5 seconds of an MP3 live stream. The latter is
identified by the use of a .m3u file extension.

app_mp3 so far only supported 8 kHz audio.
Now it always runs at the sample rate of the channel.

ASTERISK-26085 #close

Change-Id: Id1ee274733cd804a0edecf7450329b72f1235af0
2016-09-01 13:16:40 +02: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
zuul e7d06a8097 Merge "res_pjsip: Default endpoints to the "offline" status." 2016-08-29 19:01:40 -05:00
zuul e91fc62f80 Merge "pjproject_bundled: Disable srtp use by pjmedia" 2016-08-29 18:06:38 -05:00
zuul b869bf0f38 Merge "pbx.c: Prevent infinite recursion in manager_show_dialplan_helper." 2016-08-29 16:50:23 -05:00
zuul 8bdd5b63df Merge "app_queue: Ensure member is removed from pending when hanging up." 2016-08-29 14:56:27 -05:00
zuul b0b480592a Merge "app_macro: Consider '~~s~~' as a macro start extension." 2016-08-29 13:16:45 -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
Etienne Lessard 5e0758575c pbx.c: Prevent infinite recursion in manager_show_dialplan_helper.
Previously, if context A was including context B and context B was including
context A, i.e. if there was a circular dependency between contexts, then
calling manager_show_dialplan_helper could lead to an infinite recursion,
resulting in a crash.

This commit applies the same solution as the one implemented in the
show_dialplan_helper function. The manager_show_dialplan_helper and
show_dialplan_helper functions contain lots of code in common, but the former
was missing the "infinite recursion avoidance" code.

ASTERISK-26226 #close

Change-Id: I1aea85133c21787226f4f8442253a93000aa0897
2016-08-29 08:07:38 -04:00
Joshua Colp c21e6764f1 app_queue: Ensure member is removed from pending when hanging up.
When dialing channels it is possible that they may not ever
leave the not in use state (Local channels in particular) by
the time we cancel them. If this occurs but we know they were
dialed we explicitly remove them from the pending members
container so that subsequent call attempts occur.

ASTERISK-26299 #close

Change-Id: I6ad0d17c36480c92cebf840626228ce3f7e4bd65
2016-08-27 05:21:58 -05:00
zuul 90b7f7fdb5 Merge "res_pjsip: Cache global config options." 2016-08-26 22:17:40 -05:00
zuul 4d06f4621a Merge "channel: No hung-up on failing security requirements." 2016-08-26 19:40:15 -05:00
George Joseph a7487e9261 pjproject_bundled: Disable srtp use by pjmedia
The reason for the disable is that while Asterisk works fine with older
libsrtp versions, newer versions of pjproject won't compile with them.
Debian 6 for instance, has libsrtp 1.4.4 which is older than what
pjproject is expecting.

We don't use most of pjmedia but we DO use it for SDP negotiation.
Luckily disabling srtp in pjmedia doesn't interfere with it's ability
to negitiate a secure channel.  The proper crypto attributes are
negotiated in both directions.

ASTERISK-26279 #close

Change-Id: Id25a92cdf3df97a26c53cffae65b6b82de33c8e2
2016-08-26 14:44:19 -05:00
Joshua Colp 4a8bdfc49b Merge "res_fax: Fix deadlock in ast_channel_get_t38_state()." 2016-08-26 14:03:10 -05:00
Joshua Colp 179e8c15c8 Merge "res_fax: Fix deadlock setting FAXMODE channel variable." 2016-08-26 14:03:05 -05:00
Joshua Colp 383b35fca7 Merge "res_fax.c: Fix deadlock in fax_gateway_indicate_t38()." 2016-08-26 14:02:59 -05:00
Joshua Colp 25e9356bb9 Merge "res_fax.c: Add chan locked precondition comments." 2016-08-26 14:02:54 -05:00
Joshua Colp 44b8cc8b48 Merge "ast_framehook_detach() must be called with the channel locked." 2016-08-26 14:02:45 -05:00
zuul 795532b2d5 Merge "ast_framehook_attach() must be called with the channel locked." 2016-08-26 13:27:16 -05:00
zuul c82cef8441 Merge "Fix checks for allocation debugging." 2016-08-26 12:55:22 -05:00
zuul e3e08e1131 Merge "Fix naming mismatch of allocator functions." 2016-08-26 12:55:19 -05:00
Alexander Traud 858fa5eb2c channel: No hung-up on failing security requirements.
In your Diaplan, if you specify
 same => n,Set(CHANNEL(secure_bridge_media)=1)
 same => n,Set(CHANNEL(secure_bridge_signaling)=1)
only the SIP channel driver chan_sip supports this. All other channels drivers
like res_pjsip fail. In case of failure, the original sRTP source code released
the whole channel, even if not hung-up, yet. This change does not release the
channel but instead hangs-up the channel.

ASTERISK-26306

Change-Id: I0489f0cb660fab6673b0db8af027d116e70a66db
2016-08-26 16:37:46 +02:00
Alexander Traud f35501b8c9 sip_to_pjsip: Migrate IPv4/IPv6 (Dual Stack) configurations.
When using the migration script sip_to_pjsip.py, and your sip.conf is
configured with bindaddr=::, two transports are written to pjsip.conf, one for
0.0.0.0 (IPv4) and one for [::] (IPv6). That way, PJProject listens on the IPv4
and IPv6 wildcards; a IPv4/IPv6 Dual Stack configuration on a single interface
like in chan_sip.

Furthermore, the script internal functions "build_host" and "split_hostport"
did not parse Literal IPv6 addresses as expected (like [::1]:5060). This change
makes sure, even such addresses are parsed correctly.

ASTERISK-26309

Change-Id: Ia4799a0f80fc30c0550fc373efc207c3330aeb48
2016-08-26 12:49:50 +02: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
chrisderock 93b7533d74 app_macro: Consider '~~s~~' as a macro start extension.
As described in issue ASTERISK-26282 the AEL parser creates macros with
extension '~~s~~'.  app_macro searches only for extension 's' so the
created extension cannot be found.  with this patch app_macro searches for
both extensions and performs the right extension.

ASTERISK-26282 #close

Change-Id: I939aa2a694148cc1054dd75ec0c47c47f47c90fb
2016-08-25 16:43:05 -05:00