Commit Graph

8727 Commits

Author SHA1 Message Date
Corey Farrell 606ae3484a Add missing menuselect dependencies.
This adds menuselect dependencies for modules that use symbols of other
modules.

ASTERISK-27390

Change-Id: Ia2d2849f5b87a72af7324a82edc3f283eafb5385
2017-11-02 02:57:52 -04:00
Corey Farrell 6474de5f72 chan_sip: Fix SUBSCRIBE with missing "Expires" header.
When chan_sip receives a SUBSCRIBE request with no "Expires" header it
processes the request as an unsubscribe.  This is incorrect, per RFC3264
when the "Expires" header is missing a default expiry should be used.

ASTERISK-18140

Change-Id: Ibf6dcd4fdd07a32c2bc38be1dd557981f08188b5
2017-10-24 11:57:53 -04:00
Alexander Traud 840e08716b chan_sip: Crypto attribute not last but first on SDP media level.
This matches the behavior of the other SIP channel driver, chan_pjsip.

ASTERISK-27365

Change-Id: I8f23a51290a58b75816da2999ed1965441dfc5d6
2017-10-21 10:44:21 +02:00
Corey Farrell c9e19b31f5 chan_sip: Fix output of 'sip set debug off'.
When sip.conf contains 'sipdebug=yes' it is impossible to disable it
using CLI 'sip set debug off'.  This corrects the output of that CLI
command to instruct the user to turn sipdebug off in the configuration
file.

ASTERISK-23462 #close

Change-Id: I1cceade9caa9578e1b060feb832e3495ef5ad318
2017-10-18 13:04:29 -04:00
Guido Falsi c4f40b778a chan_dahdi: wrap include file which is not present on BSD systems in #ifdef
The sys/sysmacros.h include file does not exist in BSD systems and
is not required to build this module there.
Since an "#if defined(__NetBSD__) || defined(__FreeBSD__)" section
already exist I moved that include line inside it's #else branch.

ASTERISK-27343 #close

Change-Id: Ibfb64f4e9a0ce8b6eda7a7695cfe57916f175dc1
2017-10-14 14:36:07 +02:00
George Joseph ab4d36533c chan_vpb: Fix a gcc 7 out-of-bounds complaint
chan_vpb was trying to use sizeof(*p->play_dtmf), where
p->play_dtmf is defined as char[16], to get the length of the array
but since p->play_dtmf is an actual array, sizeof(*p->play_dtmf)
returns the size of the first array element, which is 1.  gcc7
validly complains because the context in which it's used could
cause an out-of-bounds condition.

Change-Id: If9c4bfdb6b02fa72d39e0c09bf88900663c000ba
2017-10-11 07:10:45 -05:00
Daniel Tryba 59b6e8467a res_pjsip_caller_id chan_sip: Comply to RFC 3323 values for privacy
Currently privacy requests are only granted if the Privacy header
value is exactly "id" (defined in RFC 3325). It ignores any other
possible value (or a combination there of). This patch reverses the
logic from testing for "id" to grant privacy, to testing for "none" and
granting privacy for any other value. "none" must not be used in
combination with any other value (RFC 3323 section 4.2).

ASTERISK-27284 #close

Change-Id: If438a21f31a962da32d7a33ff33bdeb1e776fe56
2017-10-05 07:53:03 -05:00
George Joseph 4275ca16a1 build: A few gcc 7 error fixes
Change-Id: I7b5300fbf1af7d88d47129db13ad6dbdc9b553ec
2017-09-25 07:32:14 -05:00
Joshua Colp f2985e3106 bridge: Change participant SFU streams when source streams change.
Some endpoints do not like a stream being reused for a new
media stream. The frame/jitterbuffer can rely on underlying
attributes of the media stream in order to order the packets.
When a new stream takes its place without any notice the
buffer can get confused and the media ends up getting dropped.

This change uses the SSRC change to determine that a new source
is reusing an existing stream and then bridge_softmix renegotiates
each participant such that they see a new media stream. This
causes the frame/jitterbuffer to start fresh and work as expected.

ASTERISK-27277

Change-Id: I30ccbdba16ca073d7f31e0e59ab778c153afae07
2017-09-21 12:20:02 -05:00
Jenkins2 b9da3d643c Merge "chan_sip: Expose read-only access to the full SIP INVITE Request-URI" 2017-09-21 11:11:15 -05:00
George Joseph b6aa728a58 chan_pjsip: Ignore AST_CONTROL_STREAM_TOPOLOGY_CHANGED for now
chan_pjsip_indicate was missing a case for the recently added
AST_CONTROL_STREAM_TOPOLOGY_CHANGED condition and was returning an
error and causing the call to be hung up instead of just ignoring
it.

ASTERISK-27260
Reported by: Daniel Heckl

Change-Id: I4fecbb00a0b8a853da85155065c1a6bddf235e80
2017-09-20 11:13:47 -05:00
David J. Pryke a5f1d58fe1 chan_sip: Expose read-only access to the full SIP INVITE Request-URI
Provide a way to get the contents of the the Request URI from the initial SIP
INVITE in dial plan function call. (In this case "${CHANNEL(ruri)}")

ASTERISK-27278
Reported by: David J. Pryke
Tested by: David J. Pryke

Change-Id: I1dd4d6988eed1b6c98a9701e0e833a15ef0dac3e
2017-09-19 12:24:33 -05:00
Sean Bright eec0396395 chan_rtp: Use μ-law by default instead of signed linear
Multicast/Unicast RTP do not use SDP so we need to use a format that
cleanly maps to one of the static RTP payload types. Without this
change, an Originate to a Multicast or Unicast channel without a format
specified would produce no audio on the receiving device.

ASTERISK-21399 #close
Reported by: Tzafrir Cohen

Change-Id: I97e332b566e85da04b0004b9b0daae746cfca0e3
2017-09-13 09:40:56 -05:00
Jenkins2 68b506caaa Merge "chan_sip: when getting sip pvt return failure if not found" 2017-09-08 10:24:08 -05:00
Scott Griepentrog 5553644284 chan_sip: when getting sip pvt return failure if not found
In handle_request_invite, when processing a pickup, a call
is made to get_sip_pvt_from_replaces to locate the pvt for
the subscription. The pvt is assumed to be valid when zero
is returned indicating no error, and is dereferenced which
can cause a crash if it was not found.

This change checks the not found case and returns -1 which
allows the calling code to fail appropriately.

ASTERISK-27217 #close
Reported-by: Bryan Walters

Change-Id: I6bee92b8b8b85fcac3fd66f8c00ab18bc1765612
2017-09-06 17:05:32 -04:00
Vitezslav Novy 67a2ca31f5 chan_sip: Do not change IP address in SDP origin line (o=) in SIP reINVITE
If directmedia=yes is configured, when call is answered, Asterisk sends reINVITE
to both parties to set up media path directly between the endpoints.
In this reINVITE msg SDP origin line (o=) contains IP address of endpoint
instead of IP of asterisk. This behavior violates RFC3264, sec 8:
"When issuing an offer that modifies the session,
the "o=" line of the new SDP MUST be identical to that in the
previous SDP, except that the version in the origin field MUST
increment by one from the previous SDP."
This patch assures IP address of Asterisk is always sent in
SDP origin line.

ASTERISK-17540
Reported by:  saghul

Change-Id: I533a047490c43dcff32eeca8378b2ba02345b64e
2017-09-06 10:08:06 -05:00
Ben Ford bfc29de3ea chan_pjsip: Suppress frame warnings.
When rtp_keepalive is on for a PJSIP endpoint dialing to another
Asterisk instance also using PJSIP, Asterisk will continue to print
warning messages about not being able to send frames of a certain
type. This suppresses that warning message.

Change-Id: I0332a05519d7bda9cacfa26d433909ff1909be67
2017-09-05 17:20:47 -05:00
Andre Nazario 71be8d5bbe chan_pjsip: Add tag info in CHANNEL function
Create local_tag and remote_tag in CHANNEL info to get tag from From and
To headers of a SIP dialog.

ASTERISK-27220

Change-Id: I59b16c4b928896fcbde02ad88f0e98922b15d524
2017-08-30 07:52:24 -05:00
Joshua Colp 9d0c3564ee Merge "res/res_pjsip_session: allow SDP answer to be regenerated" 2017-08-28 07:34:47 -05:00
Torrey Searle 33a648d4c6 res/res_pjsip_session: allow SDP answer to be regenerated
If an SDP answer hasn't been sent yet, it's legal to change it.
This is required for PJSIP_DTMF_MODE to work correctly, and can
also have use in the future for updating codecs too.

ASTERISK-27209 #close

Change-Id: Idbbfb7cb3f72fbd96c94d10d93540f69bd51e7a1
2017-08-25 14:27:24 +02:00
Richard Mudgett 850a3fd017 chan_pjsip.c: Fix topology refresh response code accuracy.
There are other 1xx and 2xx codes than 100 and 200 respectively.

Change-Id: I680db0997343256add1478714f5bf5b5569aee17
2017-08-22 11:33:25 -05:00
Torrey Searle a2dde59154 res_rtp_asterisk: Make P2P bridge Asymmetric codec aware
Introduce a new property to rtp-engine to make it aware of
the desire for assymetric codecs or not.  If asymmetric codecs
is not allowed, the bridge will compare read/write formats
and shut down the p2p bridge if needed

ASTERISK-26745 #close

Change-Id: I0d9c83e5356df81661e58d40a8db565833501a6f
2017-08-09 08:57:50 -05:00
kkm 4b58609c33 chan_sip: Access incoming REFER headers in dialplan
This adds a way to access information passed along with SIP headers in
a REFER message that initiates a transfer. Headers matching a dialplan
variable GET_TRANSFERRER_DATA in the transferrer channel are added to
a HASH object TRANSFER_DATA to be accessed with functions HASHKEY and HASH.

The variable GET_TRANSFERRER_DATA is interpreted to be a prefix for
headers that should be put into the hash. If not set, no headers are
included. If set to a string (perhaps 'X-' in a typical case), all headers
starting this string are added. Empty string matches all headers.

If there are multiple of the same header, only the latest occurrence in
the REFER message is available in the hash.

Obviously, the variable GET_TRANSFERRER_DATA must be inherited by the
referrer channel, and should be set with the '_' or '__' prefix.

I avoided a specific reference to SIP or REFER, as in my mind the mechanism
can be generalized to other channel techs.

ASTERISK-27162

Change-Id: I73d7a1e95981693bc59aa0d5093c074b555f708e
2017-08-07 11:17:39 +00:00
Joshua Colp 1f01106cfc Merge "chan_sip: Add dialplan function SIP_HEADERS" 2017-08-04 12:57:58 -05:00
Jenkins2 38c8080cdd Merge "Fix compile error for old versions of GCC." 2017-08-04 12:03:23 -05:00
Corey Farrell 7f8f3ca4dd Correct some leaks in unit tests.
* chan_sip: channel in test_sip_rtpqos_1.
* test_config: config hook, config info and global config holder.
* test_core_format: format in format_attribute_set_without_interface.
* test_stream: unneeded frame duplication.
* test_taskprocessor: task_data.

Change-Id: I94d364d195cf3b3b5de2bf3ad565343275c7ad31
2017-08-03 22:09:28 -04:00
kkm 4c0798e91d chan_sip: Add dialplan function SIP_HEADERS
Syntax: SIP_HEADERS([prefix])

If the argument is specified, only the headers matching the given prefix
are returned.

The function returns a comma-separated list of SIP header names from an
incoming INVITE message. Multiple headers with the same name are included
in the list only once. The returned list can be iterated over using the
functions POP() and SIP_HEADER().

For example, '${SIP_HEADERS(Co)}' might return the string
'Contact,Content-Length,Content-Type'.

Practical use is rather '${SIP_HEADERS(X-)}' to enumerate optional
extended headers sent by a peer.

ASTERISK-27163

Change-Id: I2076d3893d03a2f82429f393b5b46db6cf68a267
2017-08-02 19:19:29 -05:00
Corey Farrell 4b03eb5c38 Fix compile error for old versions of GCC.
Use -Wno-format-truncation only if supported by compiler.

ASTERISK-27171 #close

Change-Id: Iac0aed7a5bcaa16c21b7d62c4e4678d244c4ccb6
2017-08-02 18:10:57 -04:00
Corey Farrell 58d032112b Fix compiler warnings on Fedora 26 / GCC 7.
GCC 7 has added capability to produce warnings, this fixes most of those
warnings.  The specific warnings are disabled in a few places:

* app_voicemail.c: truncation of paths more than 4096 chars in many places.
* chan_mgcp.c: callid truncated to 80 chars.
* cdr.c: two userfields are combined to cdr copy, fix would break ABI.
* tcptls.c: ignore use of deprecated method SSLv3_client_method().

ASTERISK-27156 #close

Change-Id: I65f280e7d3cfad279d16f41823a4d6fddcbc4c88
2017-08-01 15:42:38 -06:00
Torrey Searle 65c560894d chan_pjsip: add a new function PJSIP_DTMF_MODE
This function is a replica of SIPDtmfMode, allowing the DTMF mode of a
PJSIP call to be modified on a per-call basis

ASTERISK-27085 #close

Change-Id: I20eef5da3e5d1d3e58b304416bc79683f87e7612
2017-08-01 15:41:53 -06:00
Joshua Colp a6eb9ee7d2 core: Add VP9 passthrough support.
This change adds VP9 as a known codec and creates a cached
"vp9" media format for use.

Change-Id: I025a93ed05cf96153d66f36db1839109cc24c5cc
2017-07-24 18:30:59 +00:00
Jenkins2 647f539e15 Merge "res_pjsip: Add "webrtc" configuration option" 2017-07-17 15:16:30 -05:00
Sergej Kasumovic d3f5b265c7 chan_iax2: On reload make sure to check for existing MWI subscription
On every reload of chan_iax2 module, MWI subscription was added, which
results in additional taskprocessors being accumulated over time.

This commit fixes it by making sure we check for existing subscription
first.

This was verified with 'core show taskprocessors' CLI command.

ASTERISK-27122 #close

Change-Id: Ie2ef528fd5ca01b933eeb88188cc10967899cfb9
2017-07-14 01:22:31 -05:00
Kevin Harwell 7da6ddda30 res_pjsip: Add "webrtc" configuration option
This patch creates a new configuration option called "webrtc". When enabled it
defaults and enables the following options that are needed in order for webrtc
to work in Asterisk:

  rtcp-mux, use_avpf, ice_support, and use_received_transport=enabled
  media_encryption=dtls
  dtls_verify=fingerprint
  dtls_setup=actpass

When "webrtc" is enabled, this patch also parses the "msid" media level
attribute from an SDP. It will also appropriately add it onto the outgoing
session when applicable.

Lastly, when "webrtc" is enabled h264 RTCP FIR feedback frames are now sent.

ASTERISK-27119 #close

Change-Id: I5ec02e07c5d5b9ad86a34fdf31bf2f9da9aac6fd
2017-07-13 18:19:35 -05:00
Jenkins2 0f45c979a3 Merge "res_rtp_asterisk / res_pjsip: Add support for BUNDLE." 2017-07-13 14:40:11 -05:00
Joshua Colp 065c3005ad res_rtp_asterisk / res_pjsip: Add support for BUNDLE.
BUNDLE is a specification used in WebRTC to allow multiple
streams to use the same underlying transport. This reduces
the number of ICE and DTLS negotiations that has to occur
to 1 normally.

This change implements this by adding support for it to
the RTP SDP module in PJSIP. BUNDLE can be turned on using
the "bundle" option and on an offer we will offer to
bundle streams together. On an answer we will accept any
bundle groups provided. Once accepted each stream is bundled
to another RTP instance for transport.

For the res_rtp_asterisk changes the ability to bundle
an RTP instance to another based on the SSRC received
from the remote side has been added. For outgoing traffic
if an RTP instance is bundled to another we will use the
other RTP instance for any transport related things. For
incoming traffic received from the transport instance we
look up the correct instance based on the SSRC and use it
for any non-transport related data.

ASTERISK-27118

Change-Id: I96c0920b9f9aca7382256484765a239017973c11
2017-07-13 14:47:50 +00:00
Jenkins2 d6c08cc559 Merge "core: Remove 'Data Retrieval API'" 2017-07-07 15:42:56 -05:00
Jenkins2 75022f6b11 Merge "chan_sip: Fix a typo for tlsbindaddr in autodomain (SIP Domain Support)." 2017-07-05 16:37:39 -05:00
Jenkins2 2ec388680b Merge "chan_sip: Only when different, add TCP|TLS in autodomain (SIP Domain Support)." 2017-07-05 16:29:45 -05:00
Jenkins2 d2b32cd009 Merge "chan_pjsip: Fix ability to send UPDATE on COLP" 2017-07-05 14:17:23 -05:00
Sean Bright 325eeced6a core: Remove 'Data Retrieval API'
This API was not actively maintained, was not added to new modules
(such as res_pjsip), and there exist better alternatives to acquire the
same information, such as the ARI.

Change-Id: I4b2185a83aeb74798b4ad43ff8f89f971096aa83
2017-07-05 11:25:58 -05:00
Alexander Traud 910c05455d chan_sip: Only when different, add TCP|TLS in autodomain (SIP Domain Support).
When sip.conf contained tcpenable=yes and autodomain=yes, the TCP domain was
added in any case, because of a local Boolean-negation error of the return value
of ast_sockaddr_cmp. After fixing this error for TCP and TLS, the TLS domain was
still always added with tlsenable=yes, because the domains were not compared
just on the address but also on the port – and TLS is always on a different port
than UDP/TCP.

ASTERISK-27106

Change-Id: I14fe9e319e238320b094016980445ef3a5b3337c
2017-07-03 17:59:43 +02:00
Alexander Traud 4398aa8fa4 chan_sip: Fix a typo for tlsbindaddr in autodomain (SIP Domain Support).
Because of a copy-and-paste error when the struct ast_sockaddr changed,
tlsbindaddr was not added, when sip.conf contained autodomain=yes; see
"show sip domains" on the command-line interface (CLI) of Asterisk.

ASTERISK-27106

Change-Id: I3d0957150017c223136968ef1266f275d0d6695e
2017-07-03 17:38:32 +02:00
George Joseph c0c99c7618 chan_pjsip: Fix ability to send UPDATE on COLP
When connected_line_method is "invite", we're supposed to determine
if the client can support UPDATE and if it can, send UPDATE instead
of INVITE to avoid the SDP renegotiation.  Not only was pjproject
not setting the PJSIP_INV_SUPPORT_UPDATE flag, we were testing
that invite_tsx wasn't NULL which isn't always the case.

* Updated chan_pjsip/update_connected_line_information to drop the
  requirement that invite_tsx isn't NULL.
* Submitted patch to pjproject sip_inv.c that sets the
  PJSIP_INV_SUPPORT_UPDATE flag correctly.
* Updated pjsip.conf.sample to clarify what happens when "invite"
  is specified.

ASTERISK-27095

Change-Id: Ic2381b3567b8052c616d96fbe79564c530e81560
2017-06-29 15:45:58 -05:00
Torrey Searle fb7247c57c res_pjsip: Add DTMF INFO Failback mode
The existing auto dtmf mode reverts to inband if 4733 fails to be
negotiated.  This patch adds a new mode auto_info which will
switch to INFO instead of inband if 4733 is not available.

ASTERISK-27066 #close

Change-Id: Id185b11e84afd9191a2f269e8443019047765e91
2017-06-29 07:57:01 -06:00
Mark Michelson 45df25a579 chan_pjsip: Add support for multiple streams of the same type.
The stream topology (list of streams and order) is now stored with the
configured PJSIP endpoints and used during the negotiation process.

Media negotiation state information has been changed to be stored
in a separate object. Two of these objects exist at any one time
on a session. The active media state information is what was previously
negotiated and the pending media state information is what the
media state will become if negotiation succeeds. Streams and other
state information is stored in this object using the index (or
position) of each individual stream for easy lookup.

The ability for a media type handler to specify a callback for
writing has been added as well as the ability to add file
descriptors with a callback which is invoked when data is available
to be read on them. This allows media logic to live outside of
the chan_pjsip module.

Direct media has been changed so that only the first audio and
video stream are directly connected. In the future once the RTP
engine glue API has been updated to know about streams each individual
stream can be directly connected as appropriate.

Media negotiation itself will currently answer all the provided streams
on an offer within configured limits and on an offer will use the
topology created as a result of the disallow/allow codec lines.

If a stream has been removed or declined we will now mark it as such
within the resulting SDP.

Applications can now also request that the stream topology change.
If we are told to do so we will limit any provided formats to the ones
configured on the endpoint and send a re-invite with the new topology.

Two new configuration options have also been added to PJSIP endpoints:

max_audio_streams: determines the maximum number of audio streams to
offer/accept from an endpoint. Defaults to 1.

max_video_streams: determines the maximum number of video streams to
offer/accept from an endpoint. Defaults to 1.

ASTERISK-27076

Change-Id: I8afd8dd2eb538806a39b887af0abd046266e14c7
2017-06-28 18:36:29 +00:00
Richard Mudgett 11ec2945c7 chan_pjsip: Fix PJSIP_MEDIA_OFFER dialplan function read.
The construction of the returned string assumed incorrectly that the
supplied buffer would always be initialized as an empty string.  If it is
not an empty string we could overrun the supplied buffer by the length of
the non-empty buffer string plus one.  It is also theoreticaly possible
for the supplied buffer to be overrun by a string terminator during a read
operation even if the supplied buffer is an empty string.

* Fix the assumption that the supplied buffer would already be an empty
string.  The buffer is not guaranteed to contain an empty string by all
possible callers.

* Fix string terminator buffer overrun potential.

Change-Id: If6a0806806527678c8554b1dcb34fd7808aa95c9
2017-06-15 12:35:53 -05:00
Jenkins2 abe1dd3039 Merge "pjsip: Extend 'asymmetric_rtp_codec' option to include us changing." 2017-06-13 09:17:10 -05:00
Joshua Colp 5b80496b42 chan_pjsip: Update device state when in early media.
The chan_pjsip module uses a calculation approach for
determining device state. This means that in situations
where we would expect device state to change we need to
tell the core to query. A scenario that was missed is
when early media was signaled.

This change adds the notification for the core to
query device state when we are told that early media
is being provided.

ASTERISK-27039

Change-Id: Iafebfd152894966344ff2e950a3cee9f59a3eb6f
2017-06-07 15:23:14 -05:00
Joshua Colp d3e951edf5 pjsip: Extend 'asymmetric_rtp_codec' option to include us changing.
PJSIP support in Asterisk differs from chan_sip in that it
allows media to be sent as-is without transcoding provided
the codecs were negotiated in the SDP. This is allowed
according to the RFC. Support for this differs quite a lot
though and some endpoints do not handle it well.

This change extends the 'asymmetric_rtp_codec' option to
also cover this case. When set to no (the default) the code
behaves as chan_sip does - the best codec is selected and
we will only ever send that, unless we change what we are
sending if the remote side changes. When set to yes we
will send media as-is without transcoding if the codec
has been negotiated in the SDP.

ASTERISK-26996

Change-Id: Ib1647f6902a0843e8c435946f831c2159e8d1d51
2017-06-07 13:34:58 +00:00
Joshua Colp 861984eac0 res_pjsip: Add support for returning only reachable contacts and use it.
This introduces the ability for PJSIP code to specify filtering flags
when retrieving PJSIP contacts. The first flag for use causes the
query code to only retrieve contacts that are not unreachable. This
change has been leveraged by both the Dial() process and the
PJSIP_DIAL_CONTACTS dialplan function so they will now only attempt
calls to contacts which are not unreachable.

ASTERISK-26281

Change-Id: I8233b4faa21ba3db114f5a42e946e4b191446f6c
2017-06-06 09:46:39 -05:00
Sean Bright 0f487978a9 chan_sip: Better ICE handling for RTCP-MUX
If we are offered or are offering RTCP-MUX, don't consider RTCP ICE
candidates. This confuses certain browsers (current Firefox for
example) and causes intial audio setup delays.

ASTERISK-26982 #close

Change-Id: Ifeaf47e83972fe8dbe58b7fb3d6d1823400cfb91
2017-05-22 09:01:57 -05:00
George Joseph 949e9147bf AST-2017-004: chan_skinny: Add EOF check in skinny_session
The while(1) loop in skinny_session wasn't checking for EOF so
a packet that was longer than a header but still truncated
would spin the while loop infinitely.  Not only does this
permanently tie up a thread and drive a core to 100% utilization,
the call of ast_log() in such a tight loop eats all available
process memory.

Added poll with timeout to top of read loop

ASTERISK-26940 #close
Reported-by: Sandro Gauci

Change-Id: I2ce65f3c5cb24b4943a9f75b64d545a1e2cd2898
2017-05-19 11:19:09 -05:00
Vitezslav Novy 93b7f84c1a chan_sip: Change sip_get_codec() to return correct codec list
Return cahnnel nativeformats to fix bridge technology selection process.
Same approach as in pjsip module.

ASTERISK-26143
Reported-by: Henning Holtschneider

Change-Id: I64e863753954d6ad67a9e722df2ebc328705ad48
2017-05-12 04:33:12 -05:00
Joshua Colp bdec0852b9 Merge "channels/chan_sip.c: use binding IP address for outgoing TCP SIP connections" 2017-05-03 11:05:35 -05:00
Jenkins2 09cde039a3 Merge "chan_vpb.cc: Fix compile error." 2017-04-28 10:38:22 -05:00
George Joseph 07164d04a6 Merge "chan_sip: Trigger reinvite if the SDP answer is included in the SIP ACK" 2017-04-27 19:17:09 -05:00
Richard Mudgett bad091b317 chan_vpb.cc: Fix compile error.
Change-Id: I6d9edd34d8b2474222c86f44e379ead61e57a54f
2017-04-27 19:08:05 -05:00
George Joseph d6b2a58736 res_pjsip_session: Add cleanup to ast_sip_session_terminate
If you use ast_request to create a PJSIP channel but then hang it
up without causing a transaction to be sent, the session will
never be destroyed.  This is due ot the fact that it's pjproject
that triggers the session cleanup when the transaction ends.
app_chanisavail was doing this to get more granular channel state
and it's also possible for this to happen via ARI.

* ast_sip_session_terminate was modified to explicitly call the
  cleanup tasks and unreference session if the invite state is NULL
  AND invite_tsx is NULL (meaning we never sent a transaction).

* chan_pjsip/hangup was modified to bump session before it calls
  ast_sip_session_terminate to insure that session stays valid
  while it does its own cleanup.

* Added test events to session_destructor for a future testsuite
  test.

ASTERISK-26908 #close
Reported-by: Richard Mudgett

Change-Id: I52daf6f757184e5544c261f64f6fe9602c4680a9
2017-04-27 10:43:32 -05:00
Jenkins2 e478d2eb94 Merge "res_pjsip_sdp_rtp: No rtpmap for static RTP payload IDs in SDP." 2017-04-26 10:44:00 -05:00
Thierry Magnien 585f9405b1 channels/chan_sip.c: use binding IP address for outgoing TCP SIP connections
For outgoing TCP connections, Asterisk uses the first IP address of the
interface instead of the IP address we asked him to bind to.

ASTERISK-26922 #close
Reported-by: Ksenia

Change-Id: I43c71ca89211dbf1838e5bcdb9be8d06d98e54eb
2017-04-26 14:58:44 +02:00
Jean Aunis b4b1943c5d chan_sip: Trigger reinvite if the SDP answer is included in the SIP ACK
Some equipments may send a re-INVITE containing an SDP in the final ACK
request. If this happens in the context of direct media, the remote end
should be updated with a re-INVITE.
This patch queues an "update RTP peer" frame to trigger the re-INVITE,
instead of the "source change" frame wich was used previously.

ASTERISK-26951

Change-Id: I3644d2025f20e086ea9f8f62b486172c52b5b2e6
2017-04-20 09:13:13 +02:00
Alexander Traud 72c5f3b0ba res_pjsip_sdp_rtp: 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 compact_headers=yes via the file pjsip.conf.

ASTERISK-26932 #close

Change-Id: Iaa556ab4c8325cd34c334387ab2847fab07b1689
2017-04-13 11:05:25 +02:00
George Joseph 747beb1ed1 modules: change module LOAD_FAILUREs to LOAD_DECLINES
In all non-pbx modules, AST_MODULE_LOAD_FAILURE has been changed
to AST_MODULE_LOAD_DECLINE.  This prevents asterisk from exiting
if a module can't be loaded.  If the user wishes to retain the
FAILURE behavior for a specific module, they can use the "require"
or "preload-require" keyword in modules.conf.

A new API was added to logger: ast_is_logger_initialized().  This
allows asterisk.c/check_init() to print to the error log once the
logger subsystem is ready instead of just to stdout.  If something
does fail before the logger is initialized, we now print to stderr
instead of stdout.

Change-Id: I5f4b50623d9b5a6cb7c5624a8c5c1274c13b2b25
2017-04-12 15:57:21 -06:00
Alexander Traud 4fc22c7673 chan_sip: Session Timers required but refused wrongly.
SIP user-agents indicate which protocol extensions are allowed in headers
like Supported and Required. Such protocol extensions are Session Timers
(RFC 4028) for example. Session Timers are supported since Mantis-10665.
Since ASTERISK-21721, not only the first but multiple Supported/Required
headers in a message are parsed. In that change, an existing variable was
re-used within a newly added do-loop. Currently, at the end of that loop,
that variable is an empty string always. Previously, that variable was used
within log output. However, the log output was not changed.

ASTERISK-26915 #close

Change-Id: I09315f31b4d78fb214bb2a9fb6c0f5e143eae990
2017-04-03 09:30:43 +02:00
Richard Mudgett e8b1bb3041 chan_vpb.cc: Fix compiler error.
Added missing channel technology read/write stream callback
initialization.

Change-Id: I829043a327d987e0d964485dd3d27964bebbd623
2017-03-31 13:14:05 -05:00
Sean Bright fc71c18a9b thread safety: Don't use getprotobyname()
POSIX does not require getprotobyname() to be thread safe and some
implementations use static memory which causes issues when multiple
threads are used.

Further, our usage of it today is just to ultimately get IPPROTO_TCP
for calls to setsockopt(). So instead we just use IPPROTO_TCP directly.

Change-Id: I2e14e58674808f7ce99b2f5e900d0f90d0d8da48
2017-03-20 08:55:05 -04:00
Sean Bright 15aa3c0a23 chan_sip: Add rtcp-mux support
ASTERISK-26846 #close

Change-Id: I541a1602ff55ab73684e9f8002edb9e0e745d639
2017-03-17 07:36:06 -06:00
Joshua Colp aec2a087ed Merge "chan_iax2: Reload of iax peer results in loss of host address/port" 2017-03-16 05:23:37 -05:00
zuul 3fe1d8afba Merge "core: Add stream topology changing primitives with tests." 2017-03-15 17:23:30 -05:00
Richard Begg 0dc007e94d chan_iax2: Reload of iax peer results in loss of host address/port
When using a non-dynamic peer address, build_peer() invalidates the
peer address structure by setting the address family to unspecified.
However, if dnsmgr is enabled, the subsequent call to ast_dnsmgr_lookup()
will not amend the peer address if the cache is still valid, resulting
in peer connectivity failures.
To fix this, we call ast_dnsmgr_refresh() instead.

ASTERISK-26865

Change-Id: Id8a89a2f771ebbaf32255a35fe596a6dcb97a082
2017-03-14 16:01:04 -06:00
zuul 2b611a8d93 Merge "chan_pjsip: Don't assume a session will have a channel." 2017-03-14 14:07:51 -05:00
Joshua Colp 578bc33f6f Merge "chan_sip: Call not cancelled after receiving a 422 response" 2017-03-14 11:47:30 -05:00
Joshua Colp 12460b05c1 chan_pjsip: Don't assume a session will have a channel.
When querying for PJSIP specific information using the dialplan
function CHANNEL() it is possible that the underlying session
will no longer have a channel associated with it. This is
most likely to occur when the RTCP HEP module attempts to get
the channel name. If this happens then a crash will occur.

This change just adds a check that the channel exists on the
session before querying it.

ASTERISK-26857

Change-Id: I113479cffff6ae64cf8ed089e9e1565223426f01
2017-03-13 12:37:55 -06:00
Daniel Journo 36fed72614 pjsip/cli_commands: pjsip show channelstats shows wrong codec
* cli_commands.c Fixed CLI output

ASTERISK-26822 #close

Change-Id: I3889ef6a8f6738fc312fab42db5efacd6e452b01
2017-03-09 15:45:48 -06:00
Jean Aunis d51ca4b406 chan_sip: Call not cancelled after receiving a 422 response
When receiving a 422 response, the invitestate variable must be reset to
INV_CALLING.

ASTERISK-26841

Change-Id: Ia0502d6b02192664cefa4e75bafdd2645ce56099
2017-03-07 15:26:54 +01:00
Joshua Colp 3ed05badb9 core: Add stream topology changing primitives with tests.
This change adds a few things to facilitate stream topology changing:

1. Control frame types have been added for use by the channel driver
to notify the application that the channel wants to change the stream
topology or that a stream topology change has been accepted. They are
also used by the indicate interface to the channel that the application
uses to indicate it wants to do the same.

2. Legacy behavior has been adopted in ast_read() such that if a
channel requests a stream topology change it is denied automatically
and the current stream topology is preserved if the application is
not capable of handling streams.

Tests have also been written which confirm the multistream and
non-multistream behavior.

ASTERISK-26839

Change-Id: Ia68ef22bca8e8457265ca4f0f9de600cbcc10bc9
2017-03-07 12:08:51 +00:00
Richard Mudgett c9296b23d1 core: Cleanup ast_get_hint() usage.
* manager.c:manager_state_cb() Fix potential use of uninitialized hint[]
if a hint does not exist for the requested extension.  Ran into this when
developing a testsuite test.  The AMI event ExtensionStatus came out with
the hint header value containing garbage.  The AMI event PresenceStatus
also had the same issue.

* manager.c:action_extensionstate() no need to completely initialize the
hint[].  Only initialize the first element.

* pbx.c:ast_add_hint() Remove unnecessary assignment.

* chan_sip.c: Eliminate an unneeded hint[] local variable.  We only care
about the return value of ast_get_hint() there.

Change-Id: Ia9a8786f01f93f1f917200f0a50bead0319af97b
2017-03-02 21:46:51 -06:00
Igor Goncharovsky 135bea931c chan_unistim: fix char type to have consistent behavior on ARM
There is difference exists in behaviour of char type on x86 and ARM.
On x86 by default char variable type means signed char, but in ARM
unsigned char used. This make binary calculations and negative values
works wrong on ARM.

This patch change type of char variables used for store negative
values and binary calculations to signed char.

ASTERISK-26714

Change-Id: Id78716dee9568a58419d4ef63c038affc3dfc7ab
2017-02-15 23:43:04 -06:00
zuul 182c737353 Merge "cli: Fix various CLI documentation and completion issues" 2017-02-14 14:34:03 -06:00
Joshua Colp 72845bd4b5 Merge "core: Cleanup some channel snapshot staging anomalies." 2017-02-14 07:14:51 -06:00
Sean Bright 3f94373778 cli: Fix various CLI documentation and completion issues
* app_minivm: Use built-in completion facilities to complete optional
arguments.

* app_voicemail: Use built-in completion facilities to complete
optional arguments.

* app_confbridge: Add missing colons after 'Usage' text.

* chan_alsa: Use built-in completion facilities to complete optional
arguments.

* chan_sip: Use built-in completion facilities to complete optional
arguments. Add completions for 'load' for 'sip show user', 'sip show
peer', and 'sip qualify peer.'

* chan_skinny: Correct and extend completions for 'skinny reset' and
'skinny show line.'

* func_odbc: Correct completions for 'odbc read' and 'odbc write'

* main/astmm: Use built-in completion facilities to complete arguments
for 'memory' commands.

* main/bridge: Correct completions for 'bridge kick.'

* main/ccss: Use built-in completion facilities to complete arguments
for 'cc cancel' command.

* main/cli: Add 'all' completion for 'channel request hangup.' Correct
completions for 'core set debug channel.' Correct completions for 'core
show calls.'

* main/pbx_app: Remove redundant completions for 'core show
applications.'

* main/pbx_hangup_handler: Remove unused completions for 'core show
hanguphandlers all.'

* res_sorcery_memory_cache: Add completion for 'reload' argument of
'sorcery memory cache stale' and properly implement.

Change-Id: Iee58c7392f6fec34ad9d596109117af87697bbca
2017-02-13 11:33:15 -05:00
Norbert Varga 75f8167e66 chan_pjsip: Multidomain endpoint finding on call
When PJSIP tries to call an endpoint with a domain (e.g. 1000@test.com),
the user part is stripped down as it would be a trunk with a specified user,
and only the host part is called as a PJSIP endpoint and can't be found.
This is not correct in the case of a multidomain SIP account, so the stripping
after the @ sign is done only if the whole endpoint (in multidomain case
1000@test.com) can't be found.

ASTERISK-26248

Change-Id: I3a2dd6f57f3bd042df46b961eccd81d31ab202e6
2017-02-13 06:05:52 -06:00
Richard Mudgett 16fdb11bc3 core: Cleanup some channel snapshot staging anomalies.
We shouldn't unlock the channel after starting a snapshot staging because
another thread may interfere and do its own snapshot staging.

* app_dial.c:dial_exec_full() made hold the channel lock while setting up
the outgoing channel staging.  Made hold the channel lock after the called
party answers while updating the caller channel staging.

* chan_sip.c:sip_new() completed the channel staging on off-nominal exit.
Also we need to use ast_hangup() instead of ast_channel_unref() at that
location.

* channel.c:__ast_channel_alloc_ap() added a comment about not needing to
complete the channel snapshot staging on off-nominal exit paths.

* rtp_engine.c:ast_rtp_instance_set_stats_vars() made hold the channel
locks while staging the channels for the stats channel variables.

Change-Id: Iefb6336893163f6447bad65568722ad5d5d8212a
2017-02-10 12:05:56 -06:00
George Joseph ef4deb8ecd debug_utilities: Add ast_logescalator
The escalator works by creating a set of startup commands in cli.conf
that set up logger channels and issue the debug commands for the
subsystems specified.  If asterisk is running when it is executed,
the same commands will be issued to the running instance.  The original
cli.conf is saved before any changes are made and can be restored by
executing '$prog --reset'.

The log output will be stored in...
$astlogdir/message.$uniqueid
$astlogdir/debug.$uniqueid
$astlogdir/dtmf.$uniqueid
$astlogdir/fax.$uniqueid
$astlogdir/security.$uniqueid
$astlogdir/pjsip_history.$uniqueid
$astlogdir/sip_history.$uniqueid

Some minor tweaks were made to chan_sip, and res_pjsip_history
so their history output could be send to a log channel as packets
are captured.

A minor tweak was also made to manager so events are output to verbose
when "manager set debug on" is issued.

Change-Id: I799f8e5013b86dc5282961b27383d134bf09e543
2017-01-27 15:10:02 -06:00
Richard Mudgett d87f81ddb1 chan_oss.c: Fix format ref leak in oss_read().
Change-Id: I0a5d56c7dcf327d60f86a4c25a23571733709fd0
2017-01-24 13:39:27 -06:00
zuul acc7f3c243 Merge "chan_sip: Remember SDP negotiation on SIP_CODEC_INBOUND." 2017-01-09 08:38:46 -06:00
Joshua Colp 38b4189643 Merge changes from topic 'ASTERISK-26672'
* changes:
  res_rtp_asterisk.c: Fix uninitialized memory crash.
  chan_rtp.c: Fix uninitialized memory crash.
  res_rtp_asterisk.c: Initialize ourip passed to ast_find_ourip().
2017-01-09 07:22:42 -06:00
Alexander Traud e220c11bec chan_sip: Remember SDP negotiation on SIP_CODEC_INBOUND.
After a SIP_CODEC_INBOUND in the dialplan, do not continue with cached formats
but remember the joint format. Cached formats contain default parameters,
often create an empty fmtp line. However, a joint format might have passed
format_get_joint(.) in a res_format_attr_* module (like Opus Codec) and
contain the resulting format parameters from a SDP negotiation.

ASTERISK-26691 #close

Change-Id: I35712d98a793d4c3efdd156cec57deab9014b1dc
2017-01-04 12:50:11 +01:00
Joshua Colp ae57652983 chan_pjsip: Use session for retrieving CHANNEL() information.
The CHANNEL() dialplan function implementation for PJSIP allows
querying of PJSIP specific information. This used the channel
passed in to get the PJSIP session and associated information.
It is possible for this channel to be masqueraded and end
up as a different channel type by the time the information
request is actually acted upon.

This change retrieves the PJSIP session safely and accesses
data from it (including channel). This provides a guarantee
that the session and channel will not be altered when the
request is being acted upon.

ASTERISK-26673

Change-Id: I335e12b89e1820cafdd92b3e7526b8ba649eb7e6
2017-01-03 05:47:05 -06:00
Richard Mudgett 67b47191e9 chan_rtp.c: Fix uninitialized memory crash.
unicast_rtp_request() could pass an uninitialized 'us' parameter to
ast_ouraddrfor().  If ast_ouraddrfor() returns an error then the 'us'
parameter may not get initialized.  Thus when the code tries to save the
'us' parameter to the local address we could try to copy a ridiculous
sized memory buffer and segfault.

* Made pass an initialized 'us' parameter to ast_ouraddrfor() and abort
the UnicastRTP channel request if it fails.

ASTERISK-26672

Change-Id: I1ef7a7c09f4da4f15dcb6de660d2bcac5f2a95c0
2016-12-22 12:25:15 -06:00
Joshua Colp 1943ece514 Merge "chan_dahdi.c: Fix bounds check regression." 2016-12-19 19:48:31 -06:00
Corey Farrell 8fbb384ea2 chan_sip: Reorder unload_module to deal with stuck TCP threads.
In some situations TCP threads may become frozen.  This creates the
possibility that Asterisk could segfault if they become unfrozen after
chan_sip has been dlclose'd.  This reorders the unload_module process to
allow abort if threads do not exit within 5 seconds.

High level order as follows:
1) Unregister from the core to stop new requests.
2) Signal threads to stop
3) Clear config based tables (but do not free the table itself).
4) Verify that threads have shutdown, cancel unload if not.
5) Clean all remaining resources.

ASTERISK-26586

Change-Id: Ie23692041d838fbd35ece61868f4c640960ff882
2016-12-17 11:25:40 -05:00
Richard Mudgett 9404efa6f4 chan_dahdi.c: Fix bounds check regression.
Caused by ASTERISK-25494

Change-Id: I1fc408c1a083745ff59da5c4113041bbfce54bcb
2016-12-14 14:24:18 -06:00
Joshua Colp 963735dfce Merge "Fix typo in chan_sip" 2016-12-09 05:32:44 -06:00
Joshua Colp b8a0770d74 Merge "chan_sip: Delete unneeded check" 2016-12-09 05:31:46 -06:00
Badalyan Vyacheslav 4c6ba1dbba Fix typo in chan_sip
The conditional expressions of the 'if' operators
situated alongside each other are identical.

Change-Id: I652b6dcddb3be007e669a6aa8107edb31a1ddafb
2016-12-08 16:53:56 -06:00
Badalyan Vyacheslav 51118e7d70 chan_sip: Delete unneeded check
P is always true. We check it before

Change-Id: Iee61cda002a9f61aee26b9f66c5f9b59e3389efb
2016-12-08 13:17:40 -06:00
Badalyan Vyacheslav fe5be81821 Small code cleanup in chan_sip
The conditional expressions of the 'if' operators situated
alongside each other are identical.

Change-Id: I2cf7c317b106ec14440c7f1b5dcfbf03639f748a
2016-12-08 18:58:19 +00:00
Walter Doekes c796f00c35 chan_sip: Do not allow non-SP/HTAB between header key and colon.
RFC says SIP headers look like:

    HCOLON  =  *( SP / HTAB ) ":" SWS
    SWS     =  [LWS]                    ; sep whitespace
    LWS     =  [*WSP CRLF] 1*WSP        ; linear whitespace
    WSP     =  SP / HTAB                ; from rfc2234

chan_sip implemented this:

    HCOLON  =  *( LOWCTL / SP ) ":" SWS
    LOWCTL  = %x00-1F                   ; CTL without DEL

This discrepancy meant that SIP proxies in front of Asterisk with
chan_sip could pass on unknown headers with \x00-\x1F in them, which
would be treated by Asterisk as a different (known) header.  For
example, the "To\x01:" header would gladly be forwarded by some proxies
as irrelevant, but chan_sip would treat it as the relevant "To:" header.

Those relying on a SIP proxy to scrub certain headers could mistakenly
get unexpected and unvalidated data fed to Asterisk.

This change fixes so chan_sip only considers SP/HTAB as valid tokens
before the colon, making it agree on the headers with other speakers of
SIP.

ASTERISK-26433 #close
AST-2016-009

Change-Id: I78086fbc524ac733b8f7f78cb423c91075fd489b
2016-12-08 08:19:38 -06:00
Joshua Colp 2a415187c5 Merge "res_pjsip/chan_sip: Advertise 'ws' in the SIP URI transport parameter" 2016-12-02 12:27:52 -06:00
zuul a0c0b1c9cb Merge "chan_pjsip: fix switching sending codec when asymmetric_rtp_codec=no" 2016-11-30 10:49:14 -06:00
Alexei Gradinari e5e887be53 chan_pjsip: fix switching sending codec when asymmetric_rtp_codec=no
The sending codec is switched to the receiving codec and then
is switched back to the best native codec on EVERY receiving RTP packets.
This is because after call of ast_channel_set_rawwriteformat there is call
of ast_set_write_format which calls set_format which sets rawwriteformat
to the best native format.

This patch adds a new function ast_set_write_format_path which set
specific write path on channel and uses this function to switch
the sending codec.

ASTERISK-26603 #close

Change-Id: I5b7d098f8b254ce8f45546e6c36e5d324737f71d
2016-11-30 07:55:24 -05:00
Matt Jordan 0e15760795 res_pjsip/chan_sip: Advertise 'ws' in the SIP URI transport parameter
Per RFC 7118 5.2, the SIP URI 'transport' parameter should advertise
'ws' when WebSockets are to be used as the transport. This applies to
both secure and insecure WebSockets.

There were two bugs in Asterisk with respect to this:

(1) The most egregious occurs in res_pjsip. There, we advertise 'ws' for
    insecure websockets and 'wss' for secure websockets. While this
    would seem to make sense - since 'WS' and 'WSS' are used for the Via
    Transport parameter - this is not the case for the SIP URI. This
    patch corrects that by registering the secure websockets with
    pjproject using the shorthand 'WS', and by returning 'ws' when asked
    for the transport parameter. Note that in pjproject, it is perfectly
    valid to have multiple transports use the same shorthand.

(2) In chan_sip, we return an upper-case version of the transport 'WS'
    instead of 'ws'. Since we should be strict in what we send and
    liberal in what we accept (within reason), this patch lower-cases
    the transport before appending it to the parameter.

ASTERISK-24330 #close
Reported by: cervajs, Inaki Baz Castillo

Change-Id: Iff77b645f8cc3b7cd35168a6676c26b147f22f42
2016-11-28 14:37:50 -05:00
Michael Kuron 0b588778c0 chan_sip: Fix segfault during module unload
If a TCP/TLS connection was pending (not accepted and not timed out) during
unload of chan_sip, Asterisk would segfault when trying to send a signal to
a thread whose thread ID hadn't been recorded yet. This commit fixes that by
recording the thread ID before calling the blocking connect() syscall.
This was a regression introduced by 776a14386a.

The above wasn't enough to fix the segfault, which was now delayed to the
point where connect() timed out. Therefore, it was necessary to also remove
the SA_RESTART flag from the SIGURG sigaction so that pthread_kill() could be
used to interruput the connect() syscall.
This was a regression introduced by 5d313f51b9.

ASTERISK-26586 #close

Change-Id: I76fd9d47d56e4264e2629bce8ec15fecba673e7b
2016-11-26 18:20:06 +01:00
Joshua Colp d3dba74017 Merge "Implement internal abstraction for iostreams" 2016-11-17 11:07:06 -06:00
Timo Teräs 070a51bf7c Implement internal abstraction for iostreams
fopencookie/funclose is a non-standard API and should not be used
in portable software. Additionally, the way FILE's fd is used in
non-blocking mode is undefined behaviour and cannot be relied on.

This introduces internal abstraction for io streams, that allows
implementing the desired virtualization of read/write operations
with necessary timeout handling.

ASTERISK-24515 #close
ASTERISK-24517 #close

Change-Id: Id916aef418b665ced6a7489aef74908b6e376e85
2016-11-15 22:25:14 +02:00
Igor Goncharovskiy dfb951817f Fix closing rtp ports after call finished in chan_unistim.
Fix ASTERISK-26565 by adding ast_rtp_instance_stop before
rtp instance destroy for chan_unistim. Also several fixes
for displayed text translation.

Change-Id: If42a03eea09bd1633471406bdc829cf98bf6affc
2016-11-11 11:50:37 +03:00
C.J. Collier 73524bde9c chan_sip: Fix typo and re-wrap surrounding docs
Correct typo of end-pints to end-points
Re-wrap session timer parameter docs to max 80 chars wide; this
eases reading on terminals with lower resolution, commonly the case
for those with visual impairments.

ASTERISK-26573

Change-Id: I22c94459f4bb6b8a2f6713cfd22e87c32f204e6b
Signed-off-by: C.J. Collier <cjcollier@linuxfoundation.org>
2016-11-10 15:16:02 -05:00
Kevin Harwell bf01ff53f8 Revert "chan_sip: Fix lastrtprx always updated"
This reverts commit 93332cb1d0.

Unfortunately, the aforementioned commit caused a regression (incoming calls
would eventually disconnect). Thus it is being removed.

ASTERISK-26523 #close
ASTERISK-25270

Change-Id: Ibf5586adc303073a8eac667a4cbfdb6be184a64d
2016-11-04 11:00:27 -05:00
Joshua Colp a1bbdabb8e Merge "chan_sip: add missing account code" 2016-11-03 05:39:33 -05:00
zuul 673964d330 Merge "chan_dahdi: remove by_name support" 2016-11-02 10:51:59 -05:00
Sebastian Gutierrez 0904c1f4cc chan_sip: add missing account code
Added missing account to AMI event of sip show peers

ASTERISK-26176 #close

Change-Id: Ieb6c2c80a838a1b59c82103eba4c63ba238dc482
2016-11-02 10:45:31 -05:00
Grachev Sergey 2526dff94d chan_sip: Incorrect display option Outbound reg. retry 403
If in sip.conf (general section) set option register_retry_403=no,
the command "sip show settings" return value:
Outbound reg. retry 403:0
If in sip.conf (general section) set option register_retry_403=yes,
the command "sip show settings" return value:
Outbound reg. retry 403:-1

* In static char "sip show settings" for "Outbound.reg. retry 403"
option use AST_CLI_YESNO

ASTERISK-26476 #close

Change-Id: I3c14272f05f1067bd2aeaa8b3ef9cf8fcb12dcf9
2016-11-01 17:01:25 +03:00
zuul 0ec5abe592 Merge "Remove ASTERISK_REGISTER_FILE." 2016-10-27 22:23:00 -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
Tzafrir Cohen 0646b48ece chan_dahdi: remove by_name support
Support for referring to DAHDI channels by logical names was added in
(FIXME: when? Asterisk 11? 1.8?) and was intended to be part of support
of refering to channels by name.

While technically usable, it has never been properly supported in
dahdi-tools, as using it would require many changes at the Asterisk
level. Instead logical mapping was added at the kernel level.

Thus it seems that refering to DAHDI channels by name is not really used
by anyone, and therefore should probably be removed.

Change-Id: I7d50bbfd9d957586f5cd06570244ef87bd54b485
2016-10-27 23:46:00 +03: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 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
Alexei Gradinari 2b9ad3a5f7 chan_pjsip: 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.

This patch uses functions pjsip_inv_add_ref/pjsip_inv_dec_ref
to inform pjproject that an INVITE session is in use.

ASTERISK-26482 #close

Change-Id: Ia2e3e2f75358cdb530252a9ce158af3d5d9fdf33
2016-10-25 10:21:28 -05:00
Joshua Colp 1843b7fa0c Merge "chan_sip: Support nat=auto_comedia or nat=force_rport,auto_comedia." 2016-10-19 11:06:41 -05:00
Joshua Colp 8b2b8be4e3 Merge "chan_rtp: Set a sane default rtp engine for unicast." 2016-10-18 11:38:13 -05:00
Moises Silva 2b03017022 chan_rtp: Set a sane default rtp engine for unicast.
ASTERISK-26439

Change-Id: I7f5ee2eeba8906e9ecb3293dbe3a747770bb5011
2016-10-17 08:14:22 -05:00
Michael Kuron e9315791b3 chan_sip: Only send video on outgoing channel if incoming channel supports it
Previously, the settings videosupport=always and videosupport=yes behaved
identically and unconditionally caused a video offer to be sent in the SDP on
an outgoing call. This was a regression introduced with commit
5a1d90e1fb in Asterisk 1.6.1.

This commit restores correct behavior: videosupport=always causes a video offer
to be sent unconditionally, while videosupport=yes will only offer video on an
outbound channel if the incoming channel it is bridged to also supports video.
That way, the device receiving the outgoing call can display the correct user
interface elements for audio or video and will not unnecessarily show a blank
video window on an audio-only call.

ASTERISK-17470 #close

Change-Id: I782f4409d436114dbc97061c3570c0cd24f7c3ae
2016-10-15 05:17:54 -05:00
Alexander Traud 4f7f8a7e95 chan_sip: Support nat=auto_comedia or nat=force_rport,auto_comedia.
In the SIP channel driver chan_sip, auto_comedia was expected to be used in
tandem with auto_force_rport. Or stated differently: Only when auto_force_rport
was chosen (the default), auto_comedia worked. This change allows auto_comedia
to be set independently of the state of (auto_)force_rport. For example,
nat=force_rport,auto_comedia is useful for IPv4/IPv6 Dual Stack deployments
when IPv6 clients are behind a Firewall.

ASTERISK-26457 #close

Change-Id: Ib29d66c6dbb61648e371e01fc36c6978ddae5bc2
2016-10-11 13:55:13 +02:00
Alexander Traud c4268ec734 chan_sip: Honor support of Symmetric Response (rport) for SIP requests.
In the SIP channel driver chan_sip, the default is "auto_force_rport". When no
NAT was detected, for example in case of IPv6, Asterisk uses the IP address
from the headers within the SIP-REGISTER for subsequent SIP signaling. When
the remote party specifies support for Symmetric Response (RFC 3581) via the
parameter "rport", Asterisk should not extract the port from the SIP headers
but reuse the port of the transport. This did not happen because of a typo.

ASTERISK-26438 #close

Change-Id: If6e7891848aaf96666dee5305695f7c6667cd5a6
2016-10-05 11:25:11 +02:00
zuul 3f62485ba7 Merge "chan_sip: Resolve externhost not to IPv6; instead go for IPv4." 2016-09-27 14:30:46 -05:00
zuul eeeff9487f Merge "chan_sip: Address runaway when realtime peers subscribe to mailboxes" 2016-09-23 16:59:59 -05:00
Alexander Traud 5dd99465d3 chan_sip: Resolve externhost not to IPv6; instead go for IPv4.
For the channel driver chan_sip, you specify externhost=example.com in sip.conf
when your Asterisk is behind a NAT and your IP address is assigned dynamically.
Or stated differently: You do not have a static IP address to use "externaddr"
directly. This NAT support is quite handy but just about IPv4. Previously,
Asterisk resolved "externhost" to any IP version. When the first DNS answer
resolved to an IPv6, Asterisk sent an IPv6 in SIP/SDP for origin (o=) and
connection (c=). This happened in outgoing SIP-REGISTER and while answering
SIP-INVITE. If the remote peer is IPv4-only, it might not handle o=/c= with an
IPv6. This change makes sure, no IPv6 is resolved anymore for "externhost".

ASTERISK-18232 #close
Reported by: Jacek Kowalski
Tested by: Alexander Traud
patches:
 changes.patch submitted by Alessandro Crespi

Change-Id: If68eedbeff65bd1c1d8a9ed921c02ba464b32dac
2016-09-23 16:54:28 +02:00
George Joseph d425971009 chan_sip: Address runaway when realtime peers subscribe to mailboxes
Users upgrading from asterisk 13.5 to a later version and who use
realtime with peers that have mailboxes were experiencing runaway
situations that manifested as a continuous stream of taskprocessor
congestion errors, memory leaks and an unresponsive chan_sip.

A related issue was that setting rtcachefriends=no NEVER worked in
asterisk 13 (since the move to stasis).  In 13.5 and earlier, when a
peer tried to register, all of the stasis threads would block and
chan_sip would again become unresponsive.  After 13.5, the runaway
would happen.

There were a number of causes...
* mwi_event_cb was (indirectly) calling build_peer even though calls to
  mwi_event_cb are often caused by build_peer.
* In an effort to prevent chan_sip from being unloaded while messages
  were still in flight, destroy_mailboxes was calling
  stasis_unsubscribe_and_join but in some cases waited forever for the
  final message.
* add_peer_mailboxes wasn't properly marking the existing mailboxes
  on a peer as "keep" so build_peer would always delete them all.
* add_peer_mwi_subs was unsubscribing existing mailbox subscriptions
  then just creating them again.

All of this was causing a flood of subscribes and unsubscribes on
multiple threads all for the same peer and mailbox.

Fixes...
* add_peer_mailboxes now marks mailboxes correctly and build_peer only
  deletes the ones that really are no longer needed by the peer.
* add_peer_mwi_subs now only adds subscriptions marked as "new" instead
  of unsubscribing and resubscribing everything.  It also adds the peer
  object's address to the mailbox instead of its name to the subscription
  userdata so mwi_event_cb doesn't have to call build_peer.

With these changes, with rtcachefriends=yes (the most common setting),
there are no leaks, locks, loops or crashes at shutdown.

rtcachefriends=no still causes leaks but at least it doesn't lock, loop
or crash.  Since making rtcachefriends=no work wasnt in scope for this
issue, further work will have to be deferred to a separate patch.

Side fixes...
 * The ast_lock_track structure had a member named "thread" which gdb
   doesn't like since it conflicts with it's "thread" command.  That
   member was renamed to "thread_id".

ASTERISK-25468 #close

Change-Id: I07519ef7f092629e1e844f855abd279d6475cdd0
2016-09-23 07:53:31 -05:00
Aaron An 18a8ca06eb channels/chan_pjsip: fix HANGUPCAUSE function bug.
HANGUPCAUSE not return 'SIP 200 Ok' when dialed channel answered.
This patch change the call order of ast_queue_control_data
and ast_queue_control in chan_pjsip_incoming_response.

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

Change-Id: Ide2d31723d8d425961e985de7de625694580be61
2016-09-22 14:42:39 +08:00
zuul 544fe73811 Merge "chan_sip: Fix session timeout on retransmit of non-UDP packets" 2016-09-14 19:42:21 -05:00
Steve Davies 6ba68b486e chan_sip: Fix session timeout on retransmit of non-UDP packets
Change-Id I1cd33453c77c56c8e1394cd60a6f17bb61c1d957 Enable Session-Timers for
SIP over TCP (and TLS) also disables SIP retransmits in chan_sip for non-UDP
connections, allowing the TCP layer to handle the retransmits. Unfortunately,
this caused sessions to be terminated with a retransmit timeout becasue it
stopped at the point of the first retrans call.

This patch waits for the 64*T1 timer to expire instead.

ASTERISK-19968

Change-Id: I844f26801aada10bc94e9bebe6e151f0a8443204
2016-09-13 10:55:58 -05:00
Walter Doekes 740292e6ae chan_sip: Allow target refresh (Contact update) on re-INVITE.
Previously, the Contact was stored only on initial INVITE and on any
18X and 200. That meant that after re-INVITEs from *us* the Contact
could get updated, but after re-INVITEs from the *peer*, it did not.

This changeset fixes this inconsistency, properly allowing target
refreshes through re-INVITES (RFC3261, 12.2).

If your strictrtp setting allows it, this change allows you to switch
the source IP of a connected/calling device mid-call with a simple
re-INVITE from the new IP.

ASTERISK-26358 #close

Change-Id: Ibb8512054ab27c8c3d2514022568fde943bf2435
2016-09-12 03:39:48 -05:00
Joshua Colp 82a3d659dc chan_sip: Don't allocate new RTP instances on top of old ones.
In some scenarios dialog_initialize_rtp can be called multiple times on
the same dialog.  This can cause RTP instances to be leaked along with
multiple file descriptors for each instance.

This change makes it so the existing RTP instances are destroyed and
not overwritten, stopping the memory leak.

ASTERISK-26272 #close
patches:
  ASTERISK-26272-13.patch submitted by Corey Farrell (license 5909)

Change-Id: Id529de1184c68f2f4d254ab41a1f458dafdb5f73
2016-09-09 10:33:47 +00:00
Alexander Traud 7a12355dbd chan_sip: Allow Preferred sRTP.
Following the Encrypt-all-the-things paradigm:

The user enters his SIP-URI and password. Thanks to DNS-NAPTR, the phone
determines SIP-over-TLS as preferred transport. In SIP/SDP, the phone starts
the call with a crypto attribute, but not as RTP/sAVP but the RTP/AVP profile
(sRTP is preferred aka optional; not mandatory). If the VoIP server does not
support sRTP and TLS, the phone shows an open padlock icon.

This paradigm is supported by several VoIP/SIP clients on default. Some
implementations even cannot be changed to RTP/sAVP. Therefore here, this
change allows Preferred sRTP for ingress. For egress, please, create a dial
plan which starts with RTP/SAVP, and when rejected tries again with RTP/AVP.

ASTERISK-20234 #close
Reported by: tootai
Tested by: tootai, Alexander Traud
patches:
 srtp_patches.diff submitted by Matt Jordan

Change-Id: I42cb779df3a9c7b3dd03a629fb3a296aa4ceb0fd
2016-09-07 11:45:23 +00:00
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
varnav d2e03c252d chan_iax2: Set plaintext auth to deprecated as per ASTERISK-22820
Starting from draft 2 of RFC 5456 (October 23, 2006) plaintext auth
is not supported in IAX2 protocol. Please refer to section 8.6.13 of
RFC 5456.

But plaintext auth is still supported by Asterisk implementation of IAX2.
This support should be dropped.

Patch, based on asterisk-dev discussion, adds deprecation warning on
startup if 'auth' is set to 'plaintext', changes default values of
'auth' from 'md5, plaintext' to 'md5'.

Patch is safe in terms of backwards compatibility, will work even if
remote peers have auth=plaintext and we have defaults.

auth=plaintext setting will remain deprecated in Asterisk 14 and 15,
and IAX2 plaintext support will be removed in Asterisk 16.

ASTERISK-22820 #close

Change-Id: I5d2f3830cb57645604818f87518916e8a5c317bf
2016-08-25 11:25:55 +03: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
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
Joshua Colp 4f0067293e Merge "chan_sip: Fix lastrtprx always updated" 2016-08-16 10:26:27 -05:00
cjack 957df73301 chan_sip: Fix lastrtprx always updated
Packets are read regulary, when there is no data in buffer fr->frametype
is AST_FRAME_NULL. There was no check of frametype and lastrtprx always 
updated and, therefore, rtptimeout did not work at all.

ASTERISK-25270 #close

Change-Id: If3b5ca0dbb822582a86eb7d01dcae4e83448c41d
2016-08-15 16:56:00 -05:00
Matt Jordan ddab42e296 func_channel: Reorganize documentation
* Following the example of the PJSIP channel driver, the channel
  technology specific documentation has been moved to the respective
  channel drivers that provide that functionality. This has the benefit
  of locating the documentation of items with those modules that provide
  it.

* Examples of using the CHANNEL function for both standard items as well
  as for PJSIP have been added.

* The 'max_forwards' standard item has been documented.

Change-Id: Ifaa79a232c8ac99cf8da6ef6cc7815d398b1b79b
2016-08-15 07:39:19 -05:00
Matt Jordan c315460abb channels/chan_pjsip: Add PJSIP_SEND_SESSION_REFRESH
This patch adds a new PJSIP specific dialplan function,
PJSIP_SEND_SESSION_REFRESH. When invoked on a PJSIP channel, the media
session will be refreshed via either an UPDATE or re-INVITE request.
When used in conjunction with the PJSIP_MEDIA_OFFER dialplan function,
the formats in use on a PJSIP channel can be re-negotiated and changed
dynamically after call setup.

ASTERISK-26277 #close

Change-Id: Ib98fe09ba889aafe26d58d32f0fd1323f8fd9b1b
(cherry picked from commit eec60dd773)
2016-08-10 11:30:01 -05:00
zuul 7cfd9bf104 Merge "chan_sip: Enable Session-Timers for SIP over TCP (and TLS)." 2016-07-22 16:55:15 -05:00
Alexander Traud 9be69c1636 chan_sip: Enable Session-Timers for SIP over TCP (and TLS).
Asterisk defaults to timers=accept/refresher=uas. In that scenario, only in that
scenario, Sessions-Timers (RFC 4028) had no effect via TCP. This change enables
Session-Timers for SIP over TCP (and for SIP over TLS).

However with longer international calls via TCP, the SIP channel might break,
because all hops on the Internet route must stay online (have not a single power
outage, for example). Therefore with Session-Timers enabled (which are enabled
at default), you might see dropped calls. Consequently even with this change,
you might be better-off going for session-timers=refuse in your sip.conf.

ASTERISK-19968 #close

Change-Id: I1cd33453c77c56c8e1394cd60a6f17bb61c1d957
2016-07-22 11:11:55 +02:00
zuul 075f7c4aea Merge "chan_sip: Prevent deadlock when issuing "sip show channels"" 2016-07-22 00:33:47 -05:00
zuul 9473818659 Merge "res_srtp: Enable AES-256 and AES-GCM." 2016-07-21 21:11:07 -05:00
zuul 9372fe1b95 Merge "chan_dahdi.c: Fix deadlock potential in fax redirection." 2016-07-21 20:47:33 -05:00
zuul a58f15ee4b Merge "chan_sip.c: Fix deadlock potential in fax redirection." 2016-07-21 20:36:30 -05:00
zuul ba2da66bd5 Merge "chan_pjsip.c: Fix deadlock potential in fax redirection." 2016-07-21 20:34:44 -05:00
Joshua Colp 4ffffa8bc4 Merge "chan_dahdi: Add faxdetect_timeout option." 2016-07-21 18:25:52 -05:00
Joshua Colp 0933f0cf96 Merge "res_pjsip: Add fax_detect_timeout endpoint option." 2016-07-21 18:25:47 -05:00
George Joseph 1b4922466b chan_sip: Prevent deadlock when issuing "sip show channels"
sip_show_channels locks the dialogs container first then locks each
sip_pvt so it can spit out the details.  The rest of sip dialog
processing locks the sip_pvt first then locks the dialogs container
if it needs to.  Both lock in the order they need but deadlocks can
result.  To fix, sip_show_channels and sip_show_channelstats have
been converted to use an iterator rather than ao2_callback.  This way
the container is locked only while getting the next entry and is
unlocked when the callback is called.

ASTERISK-23013 #close

Change-Id: Id9980419909e811f89484950ed46ef117b9eb990
2016-07-21 17:11:28 -05:00
Alexander Traud 1d2173c7ae res_srtp: Enable AES-256 and AES-GCM.
ASTERISK-26190 #close

Change-Id: I11326d80edd656524a51a19450e586c583aa0a0b
2016-07-21 16:25:41 +02:00
Richard Mudgett 3d62f317dd chan_dahdi.c: Fix deadlock potential in fax redirection.
The dahdi_handle_dtmf() and my_handle_dtmf() have the potential to
deadlock if an incoming fax happens during the Playback or similar
application.

* Fixed the potential deadlock by not calling ast_async_goto() with the
channel lock held.

ASTERISK-26216 #close
Reported by: Richard Mudgett

Change-Id: I9144b84ade5f96690996624ec8a2d40c56af40aa
2016-07-19 13:31:51 -05:00
Richard Mudgett db4979fa79 chan_sip.c: Fix deadlock potential in fax redirection.
The sip_read() has the potential to deadlock if an incoming fax happens
during the Playback or similar application.

* Fixed the potential deadlock by not calling ast_async_goto() with the
channel lock held.

* Made always eat the fax detection frame whether there is a fax extension
or not.

ASTERISK-26216
Reported by: Richard Mudgett

Change-Id: I6d3f5cccd4b77c3aa6ffc1a54c0f6bde61c9278e
2016-07-19 13:31:51 -05:00
Richard Mudgett 3db468ea9e chan_pjsip.c: Fix deadlock potential in fax redirection.
The chan_pjsip_cng_tone_detected() has the potential to deadlock if an
incoming fax happens during the Playback or similar application.

* Fixed the potential deadlock by not calling ast_async_goto() with the
channel lock held.

* Made always eat the fax detection frame whether there is a fax extension
or not.

ASTERISK-26216
Reported by: Richard Mudgett

Change-Id: I32aecbb4818af646dc5a619f0dc040e9b1f222e5
2016-07-19 13:31:50 -05:00
Richard Mudgett 0d1744e132 chan_dahdi: Add faxdetect_timeout option.
The new option allows the channel driver's faxdetect option to timeout on
a call after the specified number of seconds into a call.  The new feature
is disabled if the timeout is set to zero.  The option is disabled by
default.

* Don't clear dsp_features after passing them to the dsp code in
my_pri_ss7_open_media().  We should still remember them especially for the
new faxdetect_timeout option.

ASTERISK-26214
Reported by: Richard Mudgett

Change-Id: Ieffd3fe788788d56282844774365546dce8ac810
2016-07-19 10:33:45 -05:00
Richard Mudgett e739888d99 res_pjsip: Add fax_detect_timeout endpoint option.
The new endpoint option allows the PJSIP channel driver's fax_detect
endpoint option to timeout on a call after the specified number of
seconds into a call.  The new feature is disabled if the timeout is set
to zero.  The option is disabled by default.

ASTERISK-26214
Reported by: Richard Mudgett

Change-Id: Id5a87375fb2c4f9dc1d4b44c78ec8735ba65453d
2016-07-19 10:33:45 -05:00
Corey Farrell cf1188a1be Unit tests: Use AST_TEST_DEFINE in conditional code only.
If AST_TEST_DEFINE is not conditional to TEST_FRAMEWORK it produces dead
code.  This places all existing unit tests into a conditional block if
they weren't already.

ASTERISK-26211 #close

Change-Id: I8ef83ee11cbc991b07b7a37ecb41433e8c734686
2016-07-18 19:40:22 -04:00
Corey Farrell f73ddde7d4 chan_sip: Fix reference leak in mwi_event_cb
Cleanup the peer reference when stasis_subscription_final_message is
true.  Also free peer_name even if peer exists, after reload a new
peer_name will be allocated.

ASTERISK-26193 #close

Change-Id: If7ecd52facdc5c227f701c760841e3f6ca53cc69
2016-07-13 14:10:41 -05:00
Corey Farrell ad30d60c69 chan_sip: Fix reference leaks in error paths.
* get_sip_pvt_from_replaces leaks sip_pvt_ptr on any error.
* build_peer leaks peer on failure to allocate the endpoint.

This patch fixes get_sip_pvt by using an RAII_VAR, build_peer is fixed
with an unref in the appropriate place.

ASTERISK-26184 #close

Change-Id: I728b424648ad041409f7d90880f4c28b3ce2ca12
2016-07-09 13:39:01 -05:00
Joshua Colp 302be4809a chan_sip/res_pjsip_t38: Handle a request to negotiate T.38 after it is enabled.
Some T.38 implementations may send another re-invite after the initial
one which adds additional negotiation details (such as the max bitrate).
Currently this will fail when passthrough is being done in chan_sip as we
do nothing if T.38 is already active.

Other handlers of T.38 inside of Asterisk (such as res_fax) handle this
scenario so this change adds support for it to chan_sip and res_pjsip_t38.
If a request to negotiate is received while T.38 is already enabled a
new re-INVITE is sent and negotiation is done again.

ASTERISK-26179 #close

Change-Id: I0298494d3da6df3219bbfa4be9aa04015043145c
2016-07-07 11:46:18 -05:00
Richard Mudgett 656ed73ac6 res_pjsip: Add missing NULL checks when using pjsip_inv_end_session().
pjsip_inv_end_session() is documented as being able to return the
passed in tdata parameter set to NULL on success.

Change-Id: I09d53725c49b7183c41bfa1be3ff225f3a8d3047
2016-06-30 15:40:38 -05:00
zuul ba872766fa Merge "siren: Add format attribute modules for Siren7 and Siren14." 2016-06-29 11:30:53 -05:00
George Joseph 651290a809 BuildSystem: Fix a few issues hightlighted by gcc 6.x
gcc 6.1.1 caught a few more issues.
Made sure the unit tests still pass for the func_env and stdtime
issues.

ASTERISK-26157 #close

Change-Id: I6664d8f34a45bc1481d2a854481c7878b0c1cf8e
2016-06-28 12:40:49 -05:00
Joshua Colp 75818b4084 siren: Add format attribute modules for Siren7 and Siren14.
This change removes hardcoded SDP parsing and generation for
Siren7 and Siren14 from chan_sip and moves it to format attribute
modules so it can also be used by chan_pjsip.

With this the fmtp lines for both are added with the bitrate
information.

ASTERISK-26021

Change-Id: Ibb004eda37a14c0a35ef0613f6237977fc800037
2016-06-23 10:23:05 -03:00
George Joseph c7309a5254 chan_unistim: Fix memcpy in get_to_address
A code block only enabled when HAVE_PKTINFO is not defined (FreeBSD)
was using a pointer to a pointer as the destination of a memcpy and a
'&' instead of '*' in the sizeof.

ASTERISK-26138 #close

Change-Id: Id4927ff256c0e470bdf7bcfc025146a2f656e708
2016-06-22 13:31:58 -05:00
zuul 947f76a971 Merge "chan_sip: bigger buffers for headers, better failure mode" 2016-06-16 17:59:32 -05:00
zuul 88dfcd21b2 Merge "chan_sip: Support auth username for callbackextension feature" 2016-06-09 21:35:42 -05:00
zuul 0388c40b8c Merge "chan_pjsip: Lock channel when checking for RTP changes." 2016-06-09 13:53:58 -05:00
Mark Michelson cdb7edbe7b chan_pjsip: Lock channel when checking for RTP changes.
bridge_native_rtp can call into an RTP-capable channel driver in order
for the driver to update information about who the channel is
communicating with. For SIP channel drivers, this means deactivating
RTCP and sending a reinvite so that the endpoints can communicate
directly.

bridge_native_rtp does the right thing and has the channel locked when
calling into the channel driver. chan_pjsip can't alter session
properties in this thread, though. chan_pjsip queues a task on the
session serializer in order to update properties there.

The problem is that this queued task was not locking the channel. This
meant that the queued task could attempt to deactivate RTCP at the same
time that the channel thread was attempting to process an incoming RTCP
packet. This could lead to a crash.

This patch fixes the issue by locking the channel in the queued task
when altering RTP properties.

ASTERISK-26092 #close
Reported by Niklas Larsson

Change-Id: I3464e226a3c41f6b915f97891e07fa1599e2a159
2016-06-09 10:43:46 -05:00
George Joseph d21a77b325 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
2016-06-09 09:50:31 -05:00
Joshua Colp 2525563438 Merge "chan_sip: No rtpmap for static RTP payload IDs in SDP." 2016-06-09 04:40:43 -05:00
Joshua Colp 5c949d009e Merge "Fixes to include signal.h" 2016-06-09 04:40:24 -05:00
Timo Teräs 39b69ab537 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
2016-06-08 20:37:08 +03:00
Alexander Traud 784c18128b 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
2016-06-08 09:13:01 +02:00
Vasil Kolev 80ff7912a1 chan_sip: bigger buffers for headers, better failure mode
Currently chan_sip can give weird messages if the contacts don't
fit in the From: or To: headers. This fix changes the from,to and
invite variables to use ast_str, allocates and deallocates them and
resizes them if needed.

ASTERISK-26069 #close

Change-Id: I1b68fcbddca6f6cc7d7a92fe1cb0d5430282b2b3
2016-06-07 15:10:13 +03:00
Richard Mudgett dca052e531 chan_rtp.c: Simplify options to UnicastRTP channel creation.
Change the awkward and not as flexible UnicastRTP options format
From:
Dial(UnicastRTP/127.0.0.1[/[<engine>][/[<codec>]]])
To:
Dial(UnicastRTP/127.0.0.1[/[<options>]])

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

Change-Id: I0c297aaf09e2ee515536cb7437bb8042ff8ff3c9
2016-06-06 17:05:43 -05:00
Timo Teräs 538c6415c6 chan_sip: Support auth username for callbackextension feature
ASTERISK-20527 #close

Change-Id: I659cf7f00836a09d09d146ad226a40477d731239
2016-06-03 09:35:53 +03:00
Mark Michelson bb0f4a6310 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
2016-05-27 11:00:09 -05:00
Richard Mudgett 2a77af9ed0 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
2016-05-20 19:28:05 -05:00
George Joseph 5bd1bf2816 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
2016-05-17 11:59:35 -05:00
Joshua Colp 1e41d14822 Merge "chan_sip: Make autocreated peers send PeerStatus events" 2016-04-29 11:44:11 -05:00
Joshua Colp c480159045 chan_sip: Give more time for TCP/TLS threads to stop.
The unload process currently tells each TCP/TLS to terminate but
does not wait for them to do so. This introduces a race condition
where the container holding the threads may be destroyed before
the threads are able to remove themselves from it. When they
finally do the container is invalid and can't be used causing a
crash.

A previous change existed which waited a bit to wait for any
stranglers to finish. This change extends this and waits longer.

ASTERISK-25961 #close

Change-Id: Idc6262b670ca49ede32061159e323b7b63c6f3c6
2016-04-26 11:16:36 -05:00
kkm 41ecf22587 chan_sip: Make autocreated peers send PeerStatus events
Since Stasis has been introduced, an attempt to send AMI messages by an
autocreated peer caused a crash, and all events from autocreated peers were
semi-inadvertently disabled altogether in 0b83761. This change restores the
disabled functionality.

ASTERISK-25950

Change-Id: Iecc350f23db603fadb2f302064643ebe9664e974
2016-04-22 14:00:55 -07:00
Jaco Kroon f06ce7f90a chan_sip: Don't verify table if rtupdate=no
If rtupdate=no do not verify sipregs/peers table has updatable fields.

ASTERISK-25934 #close

Change-Id: Iaa2c53037b93daccc7e7333c40d61861847b856d
2016-04-18 05:34:59 -05:00
Richard Mudgett 6138a75e8e pbx.h: Make ast_state_cb_type take more const.
This eliminates some casts that I made a note saying v10 and above
would no longer need them.

Better late than never :)

Change-Id: I346cdb3032b6478ceb40eb6fe732978b54035572
2016-04-07 17:20:17 -05:00
zuul a04a62586f Merge "chan_sip: Do not send all codecs on INVITE. Do not break on Session-Timers." 2016-03-31 17:35:23 -05:00
George Joseph c4064727d2 chan_pjsip: Add 'pjsip show channelstats'
Added the ability to show channel statistics to chan_pjsip (cli_functions.c)

Moved the existing 'pjsip show channel(s)' functionality from
pjsip_configuration to cli_functions.c.  The stats needed chan_pjsip's
private header so it made sense to move the existing channel commands as well.

Now using stasis_cache_dump to get the channel snapshots rather than retrieving
all endpoints, then getting each one's channel snapshots.  Much more efficient.

Change-Id: I03b114522126d27434030b285bf6d531ddd79869
2016-03-29 14:35:31 -05:00
Alexander Traud 3f720155b7 chan_sip: Do not send all codecs on INVITE. Do not break on Session-Timers.
Asterisk 13.7.0 included a fix for ASTERISK-24543, not to send all those
codecs, which the caller did not request/support. That fix was not complete
because on the second Session Timer all codecs were sent again. Some VoIP/SIP
clients interpreted that complete codec-list as a change in the SIP session.
Because of that, Asterisk did not send the RTP audio via NAT anymore which
created a non-audio scenario after the second Session Timer fired.

ASTERISK-24543 #close

Change-Id: I1881827816ab7fd47eb4287a95961179b34a0b66
2016-03-24 20:21:22 +01:00
Francesco Castellano ac66999971 chan_sip.c: Space after port causes unnecessary resolution attempt
check_via() already skips leading blanks where the sent-by address (with the
optional port) should be placed.

Since RFC 3261 allows for blanks between the port ant the Via parameters:
> https://tools.ietf.org/html/rfc3261#section-20.42
(actually it allows a lot of blanks more ;-)). I just switched from
ast_skip_blanks() to ast_strip() on the local copy of the string.

ASTERISK-21301 #close

Change-Id: Ie5b8fe5a07067b7c0dc9bcdd1707e99b23b02b06
2016-03-22 10:29:31 -05:00
Kevin Harwell a3c9a74a02 chan_pjsip: ref leak when checking direct_media_glare
Fix the reference leak introduced in the following commit:

c534bd5807

ASTERISK-25849

Change-Id: I5cfefd5ee6c1c3a1715c050330aaa10e4d2a5e85
2016-03-18 15:09:39 -05:00
zuul 4aaf8f2ace Merge "chan_pjsip: transfers with direct media reinvite has wrong address/port" 2016-03-18 12:47:14 -05:00
Kevin Harwell c534bd5807 chan_pjsip: transfers with direct media reinvite has wrong address/port
During a transfer involving direct media a race occurs between when the
transferer channel is swapped out, initiating rtp changes/updates, and the
subsequent reinvites.

When Alice, after speaking with Charlie (Bob is on hold), connects Bob and
Charlie invites are sent to each in order to establish the call between them.
Bob is taken off hold and Charlie is told to have his media flow through
Asterisk. However, if before those invites go out the bridge updates Bob's
and/or Charlie's rtp information with direct media data (i.e. address, port)
then the invite(s) will contain the remote data in the SDP instead of the
Asterisk data.

The race occurs in the native bridge glue code when updating the peer. The
direct_media_address can get set twice before sending out the first invite
during call connection. This can happen because the checking/setting of the
direct_media_address happened in one thread while the sending of the invite(s)
happened in another thread.

This fix removes the race condition by moving the checking/setting of the
direct_media_address to be in the same thread as the sending of the invites(s).
This serializes the checking/setting and sending so they can no longer happen
out of order.

ASTERISK-25849 #close

Change-Id: Idfea590175e74f401929a601dba0c91ca1a7f873
2016-03-18 11:15:56 -05:00
Joshua Colp 7d63b4499e Merge "chan_sip.c: Made sip_reinvite_retry() call sip_pvt_lock_full()." 2016-03-17 11:19:23 -05:00
Richard Mudgett 810f92c9dc chan_sip.c: Fix mwi resub deadlock potential.
This patch is part of a series to resolve deadlocks in chan_sip.c.

Stopping a scheduled event can result in a deadlock if the scheduled event
is running when you try to stop the event.  If you hold a lock needed by
the scheduled event while trying to stop the scheduled event then a
deadlock can happen.  The general strategy for resolving the deadlock
potential is to push the actual starting and stopping of the scheduled
events off onto the scheduler/do_monitor() thread by scheduling an
immediate one shot scheduled event.  Some restructuring may be needed
because the code may assume that the start/stop of the scheduled events is
immediate.

ASTERISK-25023 #close

Change-Id: I96d429c57a48861fd8bde63dd93db4e92dc3adb6
2016-03-16 14:44:52 -05:00
Richard Mudgett 72c444ba37 chan_sip.c: Fix registration timeout and expire deadlock potential.
This patch is part of a series to resolve deadlocks in chan_sip.c.

Stopping a scheduled event can result in a deadlock if the scheduled event
is running when you try to stop the event.  If you hold a lock needed by
the scheduled event while trying to stop the scheduled event then a
deadlock can happen.  The general strategy for resolving the deadlock
potential is to push the actual starting and stopping of the scheduled
events off onto the scheduler/do_monitor() thread by scheduling an
immediate one shot scheduled event.  Some restructuring may be needed
because the code may assume that the start/stop of the scheduled events is
immediate.

ASTERISK-25023

Change-Id: I2e40de89efc8ae6e8850771d089ca44bc604b508
2016-03-16 14:44:52 -05:00
Richard Mudgett 7ea1e181dc chan_sip.c: Fix waitid deadlock potential.
This patch is part of a series to resolve deadlocks in chan_sip.c.

Stopping a scheduled event can result in a deadlock if the scheduled event
is running when you try to stop the event.  If you hold a lock needed by
the scheduled event while trying to stop the scheduled event then a
deadlock can happen.  The general strategy for resolving the deadlock
potential is to push the actual starting and stopping of the scheduled
events off onto the scheduler/do_monitor() thread by scheduling an
immediate one shot scheduled event.  Some restructuring may be needed
because the code may assume that the start/stop of the scheduled events is
immediate.

* Made always run check_pendings() under the scheduler thread so scheduler
ids can be checked safely.

ASTERISK-25023

Change-Id: Ia834d6edd5bdb47c163e4ecf884428a4a8b17d52
2016-03-16 14:44:51 -05:00
Richard Mudgett fbf8e04aed chan_sip.c: Fix t38id deadlock potential.
This patch is part of a series to resolve deadlocks in chan_sip.c.

Stopping a scheduled event can result in a deadlock if the scheduled event
is running when you try to stop the event.  If you hold a lock needed by
the scheduled event while trying to stop the scheduled event then a
deadlock can happen.  The general strategy for resolving the deadlock
potential is to push the actual starting and stopping of the scheduled
events off onto the scheduler/do_monitor() thread by scheduling an
immediate one shot scheduled event.  Some restructuring may be needed
because the code may assume that the start/stop of the scheduled events is
immediate.

ASTERISK-25023

Change-Id: If595e4456cd059d7171880c7f354e844c21b5f5f
2016-03-16 14:44:51 -05:00
Richard Mudgett 02458cc6fd chan_sip.c: Fix session timers deadlock potential.
This patch is part of a series to resolve deadlocks in chan_sip.c.

Stopping a scheduled event can result in a deadlock if the scheduled event
is running when you try to stop the event.  If you hold a lock needed by
the scheduled event while trying to stop the scheduled event then a
deadlock can happen.  The general strategy for resolving the deadlock
potential is to push the actual starting and stopping of the scheduled
events off onto the scheduler/do_monitor() thread by scheduling an
immediate one shot scheduled event.  Some restructuring may be needed
because the code may assume that the start/stop of the scheduled events is
immediate.

ASTERISK-25023

Change-Id: I6d65269151ba95e0d8fe4e9e611881cde2ab4900
2016-03-16 14:44:51 -05:00
Richard Mudgett c7fdff2e37 chan_sip.c: Fix reinviteid deadlock potential.
This patch is part of a series to resolve deadlocks in chan_sip.c.

Stopping a scheduled event can result in a deadlock if the scheduled event
is running when you try to stop the event.  If you hold a lock needed by
the scheduled event while trying to stop the scheduled event then a
deadlock can happen.  The general strategy for resolving the deadlock
potential is to push the actual starting and stopping of the scheduled
events off onto the scheduler/do_monitor() thread by scheduling an
immediate one shot scheduled event.  Some restructuring may be needed
because the code may assume that the start/stop of the scheduled events is
immediate.

ASTERISK-25023

Change-Id: I9c11b9d597468f63916c99e1dabff9f4a46f84c1
2016-03-16 14:44:51 -05:00
Richard Mudgett 69810b306d chan_sip.c: Fix autokillid deadlock potential.
This patch is part of a series to resolve deadlocks in chan_sip.c.

Stopping a scheduled event can result in a deadlock if the scheduled event
is running when you try to stop the event.  If you hold a lock needed by
the scheduled event while trying to stop the scheduled event then a
deadlock can happen.  The general strategy for resolving the deadlock
potential is to push the actual starting and stopping of the scheduled
events off onto the scheduler/do_monitor() thread by scheduling an
immediate one shot scheduled event.  Some restructuring may be needed
because the code may assume that the start/stop of the scheduled events is
immediate.

* Fix clearing autokillid in __sip_autodestruct() even though we could
reschedule.

ASTERISK-25023

Change-Id: I450580dbf26e2e3952ee6628c735b001565c368f
2016-03-16 14:44:51 -05:00
Richard Mudgett f484ddbdfe chan_sip.c: Fix packet retransid deadlock potential.
This patch is part of a series to resolve deadlocks in chan_sip.c.

Stopping a scheduled event can result in a deadlock if the scheduled event
is running when you try to stop the event.  If you hold a lock needed by
the scheduled event while trying to stop the scheduled event then a
deadlock can happen.  The general strategy for resolving the deadlock
potential is to push the actual starting and stopping of the scheduled
events off onto the scheduler/do_monitor() thread by scheduling an
immediate one shot scheduled event.  Some restructuring may be needed
because the code may assume that the start/stop of the scheduled events is
immediate.

* Fix retrans_pkt() to call check_pendings() with both the owner channel
and the private objects locked as required.

* Refactor dialog retransmission packet list to safely remove packet
nodes.  The list nodes are now ao2 objects.  The list has a ref and the
scheduled entry has a ref.

ASTERISK-25023

Change-Id: I50926d81be53f4cd3d572a3292cd25f563f59641
2016-03-16 14:44:51 -05:00
Richard Mudgett 67c79c326d chan_sip.c: Fix provisional_keepalive_sched_id deadlock.
This patch is part of a series to resolve deadlocks in chan_sip.c.

Stopping a scheduled event can result in a deadlock if the scheduled event
is running when you try to stop the event.  If you hold a lock needed by
the scheduled event while trying to stop the scheduled event then a
deadlock can happen.  The general strategy for resolving the deadlock
potential is to push the actual starting and stopping of the scheduled
events off onto the scheduler/do_monitor() thread by scheduling an
immediate one shot scheduled event.  Some restructuring may be needed
because the code may assume that the start/stop of the scheduled events is
immediate.

ASTERISK-25023

Change-Id: I98a694fd42bc81436c83aa92de03226e6e4e3f48
2016-03-16 14:44:51 -05:00
Richard Mudgett 76be7093cd chan_sip.c: Adjust how dialog_unlink_all() stops scheduled events.
This patch is part of a series to resolve deadlocks in chan_sip.c.

* Make dialog_unlink_all() unschedule all items at once in the sched
thread.

ASTERISK-25023

Change-Id: I7743072fb228836e8228b72f6dc46c8cc50b3fb4
2016-03-16 14:44:50 -05:00
Richard Mudgett 52f0932e4c chan_sip.c: Clear scheduled immediate events on unload.
This patch is part of a series to resolve deadlocks in chan_sip.c.

The reordering of chan_sip's shutdown is to handle any immediate events
that get put onto the scheduler so resources aren't leaked.  The typical
immediate events at this time are going to be concerned with stopping
other scheduled events.

ASTERISK-25023

Change-Id: I3f6540717634f6f2e84d8531a054976f2bbb9d20
2016-03-16 14:44:43 -05:00
Richard Mudgett 0987a11cce sip/dialplan_functions.c: Fix /channels/chan_sip/test_sip_rtpqos crash.
This patch is part of a series to resolve deadlocks in chan_sip.c.

Delaying destruction of the chan_sip sip_pvt structures caused the
/channels/chan_sip/test_sip_rtpqos unit test to crash.  That test
registers a special test ast_rtp_engine with the rtp engine module.  When
the unit test completes it cleans up by unregistering the test
ast_rtp_engine and exits.  Since the delayed destruction of the sip_pvt
happens after the unit test returns, the destructor tries to call the rtp
engine destroy callback of the test ast_rtp_engine auto variable which no
longer exists on the stack.

* Change the test ast_rtp_engine auto variable to a static variable.  Now
the variable can still exist after the unit test exits so the delayed
sip_pvt destruction can complete successfully.

ASTERISK-25023

Change-Id: I61e34a12d425189ef7e96fc69ae14993f82f3f13
2016-03-16 14:22:19 -05:00
Richard Mudgett cb97198ca6 chan_sip.c: Simplify sip_pvt destructor call levels.
Remove destructor calling destroy_it calling really_destroy_it
for no benefit.  Just make the destructor the really_destroy_it
function.

Change-Id: Idea0d47b27dd74f2488db75bcc7f353d8fdc614a
2016-03-14 14:10:10 -05:00
Richard Mudgett 8be01398d9 chan_sip.c: Made sip_reinvite_retry() call sip_pvt_lock_full().
Change-Id: I90f04208a089f95488a2460185a8dbc3f6acca12
2016-03-14 12:57:52 -06:00
George Joseph d2eb65f71e res_pjsip: Strip spaces from items parsed from comma-separated lists
Configurations like "aors = a, b, c" were either ignoring everything after "a"
or trying to look up " b".  Same for mailboxes,  ciphers, contacts and a few
others.

To fix, all the strsep(&copy, ",") calls have been wrapped in ast_strip.  To
facilitate this, ast_strip, ast_skip_blanks and ast_skip_nonblanks were
updated to handle null pointers.

In some cases, an ast_strlen_zero() test was added to skip consecutive commas.

There was also an attempt to ast_free an ast_strdupa'd string in
ast_sip_for_each_aor which was causing a SEGV.  I removed it.

Although this issue was reported for realtime, the issue was in the res_pjsip
modules so all config mechanisms were affected.

ASTERISK-25829 #close
Reported-by: Mateusz Kowalski

Change-Id: I0b22a2cf22a7c1c50d4ecacbfa540155bec0e7a2
2016-03-07 13:16:41 -06:00
Richard Mudgett 25de01f301 SIP diversion: Fix REDIRECTING(reason) value inconsistencies.
Previous chan_sip behavior:

Before this patch chan_sip would always strip any quotes from an incoming
reason and pass that value up as the REDIRECTING(reason).  For an outgoing
reason value, chan_sip would check the value against known values and
quote any it didn't recognize.  Incoming 480 response message reason text
was just assigned to the REDIRECTING(reason).

Previous chan_pjsip behavior:

Before this patch chan_pjsip would always pass the incoming reason value
up as the REDIRECTING(reason).  For an outgoing reason value, chan_pjsip
would send the reason value as passed down.

With this patch:

Both channel drivers match incoming reason values with values documented
by REDIRECTING(reason) and values documented by RFC5806 regardless of
whether they are quoted or not.  RFC5806 values are mapped to the
equivalent REDIRECTING(reason) documented value and is set in
REDIRECTING(reason).  e.g., an incoming RFC5806 'unconditional' value or a
quoted string version ('"unconditional"') is converted to
REDIRECTING(reason)'s 'cfu' value.  The user's dialplan only needs to deal
with 'cfu' instead of any of the aliases.

The incoming 480 response reason text supported by chan_sip checks for
known reason values and if not matched then puts quotes around the reason
string and assigns that to REDIRECTING(reason).

Both channel drivers send outgoing known REDIRECTING(reason) values as the
unquoted RFC5806 equivalent.  User custom values are either sent as is or
with added quotes if SIP doesn't allow a character within the value as
part of a RFC3261 Section 25.1 token.  Note that there are still
limitations on what characters can be put in a custom user value.  e.g.,
embedding quotes in the middle of the reason string is silly and just
going to cause you grief.

* Setting a REDIRECTING(reason) value now recognizes RFC5806 aliases.
e.g., Setting REDIRECTING(reason) to 'unconditional' is converted to the
'cfu' value.

* Added missing malloc() NULL return check in res_pjsip_diversion.c
set_redirecting_reason().

* Fixed potential read from a stale pointer in res_pjsip_diversion.c
add_diversion_header().  The reason string needed to be copied into the
tdata memory pool to ensure that the string would always be available.
Otherwise, if the reason string returned by reason_code_to_str() was a
user's reason string then the string could be freed later by another
thread.

Change-Id: Ifba83d23a195a9f64d55b9c681d2e62476b68a87
2016-03-01 20:21:58 -06:00
Richard Mudgett 2dae4a1ccf chan_sip.c: Fix T.38 issues caused by leaving a bridge.
chan_sip could not handle AST_T38_TERMINATED frames being sent to it when
the channel left the bridge.  The action resulted in overlapping outgoing
reINVITEs.  The testsuite tests/fax/sip/directmedia_reinvite_t38 was not
happy.

* Force T.38 to be remembered as locally bridged.  Now when the channel
leaves the native RTP bridge after T.38, the channel remembers that it has
already reINVITEed the media back to Asterisk.  It just needs to terminate
T.38 when the AST_T38_TERMINATED arrives.

* Prevent redundant AST_T38_TERMINATED from causing problems.  Redundant
AST_T38_TERMINATED frames could cause overlapping outgoing reINVITEs if
they happen before the T.38 state changes to disabled.  Now the T.38 state
is set to disabled before the reINVITE is sent.

ASTERISK-25582 #close

Change-Id: I53f5c6ce7d90b3f322a942af1a9bcab6d967b7ce
2016-02-29 12:56:20 -06:00
zuul 170941990b Merge "chan_sip: Optionally supply fromuser/fromdomain in SIP dial string." 2016-02-25 17:56:42 -06:00
Richard Mudgett 886ee09471 chan_sip.c: Suppress T.38 SDP c= line if addr is the same.
Use the correct comparison function since we only care if the address
without the port is the same.

Change-Id: Ibf6c485f843a1be6dee58a47b33d81a7a8cbe3b0
2016-02-23 16:40:32 -06:00
Walter Doekes c00082329e chan_sip: Optionally supply fromuser/fromdomain in SIP dial string.
Previously you could add [!dnid] to the SIP dial string to alter the To:
header. This change allows you to alter the From header as well.

SIP dial string extra options now look like this:

    [![touser[@todomain]][![fromuser][@fromdomain]]]

INCOMPATIBLE CHANGE: If you were using an exclamation mark in your To:
header, that is no longer possible.

ASTERISK-25803 #close

Change-Id: I2457e9ba7a89eb1da22084bab5a4d4328e189db7
2016-02-19 11:30:15 +01:00
George Joseph b69729dde5 chan_misdn: Fix a few issues causing compile errors
Change-Id: I54b48c24d7ca88ed80496fdfd142d08772a7ab98
2016-02-05 11:58:54 -06:00
Richard Mudgett a877e0d94b AST-2016-002 chan_sip.c: Fix retransmission timeout integer overflow.
Setting the sip.conf timert1 value to a value higher than 1245 can cause
an integer overflow and result in large retransmit timeout times.  These
large timeout times hold system file descriptors hostage and can cause the
system to run out of file descriptors.

NOTE: The default sip.conf timert1 value is 500 which does not expose the
vulnerability.

* The overflow is now detected and the previous timeout time is
calculated.

ASTERISK-25397 #close
Reported by: Alexander Traud

Change-Id: Ia7231f2f415af1cbf90b923e001b9219cff46290
2016-02-03 15:04:08 -06:00
Mark Michelson d89f0b09de Merge "chan_sip.c: AMI & CLI notify methods get different values of asterisk's own ip." 2016-02-02 15:58:50 -06:00
George Joseph 40da6434c1 build_system: Fix some warnings highlighted by clang
Fix some warnings found with clang.

Change-Id: I5195b6189b148c2ee3ed4a19d015a6d4ef3e77bd
2016-02-01 19:22:40 -06:00
StefanEng86 55a7367ad4 chan_sip.c: AMI & CLI notify methods get different values of asterisk's own ip.
When I ask asterisk to send a SIP NOTIFY message to a sip peer using either a)
AMI action: SIPnotify or b) cli command: sip notify <cmd> <peer>, I expect
asterisk to include the same value for its own ip in both cases a) and b),
but it seems a) produces a contact header like Contact:
<sip:asterisk@192.168.1.227:8060> whereas b) produces a contact header like
<sip:asterisk@127.0.0.1:8060>. 0.0.0.0:8060 is my udpbindaddr in sip.conf

My guess is that manager_sipnotify should call
ast_sip_ouraddrfor(&p->sa, &p->ourip, p) the same way sip_cli_notify does,
because after applying this patch, both cases a) and b) produce
the contact header that I expect: <sip:asterisk@192.168.1.227:8060>

Reported by: Stefan Engström
Tested by: Stefan Engström

Change-Id: I86af5e209db64aab82c25417de6c768fb645f476
2016-01-31 10:23:56 -06:00
Corey Farrell 830f8933c2 chan_sip: Fix buffer overrun in sip_sipredirect.
sip_sipredirect uses sscanf to copy up to 256 characters to a stacked buffer
of 256 characters.  This patch reduces the copy to 255 characters to leave
room for the string null terminator.

ASTERISK-25722 #close

Change-Id: Id6c3a629a609e94153287512c59aa1923e8a03ab
2016-01-25 11:13:11 -06:00
Mark Michelson 53570e2c6f Merge "chan_sip: option 'notifyringing' change and doc fix" 2016-01-21 15:22:53 -06:00
Ward van Wanrooij d4b10cfb3e chan_sip: option 'notifyringing' change and doc fix
In the sample sip.conf this is written with regard to notifyringing:
;notifyringing = no ; Control whether subscriptions already INUSE get sent
RINGING when another call is sent (default: yes)

However, this setting changes whether or not any RINGING indications are sent
to subscriptions. There is no separate configurable setting that allows
to control whether INUSE subscriptions also get sent RINGING. This is however
a useful option, to see (using BLF) if somebody else is able to handle an
incoming call or if everybody is busy.

This patch corrects the documentation for notifyringing (so the documentation
matches the functionality) and make notifyringing a tri-state option, by adding
the value 'notinuse' (in addition to 'yes' and 'no'). When notifyringing =
notinuse, only subscriptions that are not INUSE are sent the RINGING signal.

The default setting for notifyringing remains set to yes, so the default
behaviour is not affected.

ASTERISK-25558

Change-Id: I88f7036ee084bb3f43b74f15612695c6708f74aa
2015-12-26 16:24:09 +01:00
Dade Brandon 6dc21bbf00 chan_sip.c: fix websocket_write_timeout default value
websocket_write_timeout was not being set to its default value
during sip config reload, which meant that prior to this commit,
1) the default value of 100 was not used, unless an invalid value
(or 1) was specified in sip.conf for websocket_write_timeout, and
2) if the websocket_write_timeout directive was removed from sip.conf
without a full restart of asterisk, then the previous value would
continue to be used indefinitely.

This essentially lead to a 0ms write timeout (the first write attempt
in ast_careful_fwrite must have succeeded) in websocket write requests
from chan_sip, unless websocket_write_timeout was explicitely set in sip.conf.

Changes to websocket_write_timeout still only apply to new websocket
sessions, after the sip reload -- timeouts on existing sessions are
not adjusted during sip reload.

Change-Id: Ibed3816ed29cc354af6564c5ab3e75eab72cb953
2015-12-25 08:08:07 -08:00
Joshua Colp d2c8614122 chan_sip: Enable WebSocket support by default.
Per the documentation the WebSocket support in chan_sip is
supposed to be enabled by default but is not. This change
corrects that.

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

ASTERISK-25364 #close
Reported by: Hiroaki Komatsu

Change-Id: I7ed7bcfa982b367dc64b4b73fbd962da49b9af36
2015-12-10 14:13:19 -06:00
Matt Jordan 259fa9c901 Merge "chan_sip: Check sip_pvt pointer in ast_channel_get_t38_state(c)" 2015-12-09 12:40:58 -06:00
Eugene Voityuk be693539c3 chan_sip.c: Start ICE negotiation when response is sent or received.
The current logic for ICE negotiation starts it
when receiving an SDP with ICE candidates. This is
incorrect as ICE negotiation can only start when each 
call party have at least one pair of local and remote 
candidate. Starting ICE negotiation early would result 
in negotiation failure and ultimately no audio.

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

ASTERISK-24146

Change-Id: I55a632bde9e9827871b09141d82747e08379a8ca
2015-12-08 17:19:18 -06:00
Filip Jenicek 59a91c350a chan_sip: Check sip_pvt pointer in ast_channel_get_t38_state(c)
Asterisk may crash when calling ast_channel_get_t38_state(c)
on a locked channel which is being hung up.

ASTERISK-25609 #close

Change-Id: Ifaa707c04b865a290ffab719bd2e5c48ff667c7b
2015-12-08 12:23:30 -06:00
Richard Mudgett 65c8147952 chan_sip: Fix crash involving the bogus peer during sip reload.
A crash happens sometimes when performing a CLI "sip reload".  The bogus
peer gets refreshed while it is in use by a new call which can cause the
crash.

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

ASTERISK-25610 #close

Change-Id: I5b528c742195681abcf713c6e1011ea65354eeed
2015-12-07 10:59:14 -06:00
Christof Lauber 48c065e46d chan_sip: Support parsing of Q.850 reason header in SIP BYE and CANCEL requests.
Current support for reason header did work only in SIP responses.
According to RFC3336 the reason header might appear in any SIP request.
But it seems to make most sence in BYE and CANCEL so parasing is done
there too (if use_q850_reason=yes).

Change-Id: Ib6be7b34c23a76d0e98dfd0816c89931000ac790
2015-12-07 10:04:42 -04:00
Richard Mudgett 145d10a5d0 Audit improper usage of scheduler exposed by 5c713fdf18. (v13 additions)
chan_sip.c:
* Initialize mwi subscription scheduler ids earlier because of ASTOBJ to
ao2 conversion.

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

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

ASTERISK-25476

Change-Id: If9f0e5d99638b2f9d102d1ebc9c5a14b2d706e95
2015-12-01 13:54:04 -06:00
Richard Mudgett fa20729032 Audit improper usage of scheduler exposed by 5c713fdf18.
channels/chan_iax2.c:
* Initialize struct chan_iax2_pvt scheduler ids earlier because of
iax2_destroy_helper().

channels/chan_sip.c:
channels/sip/config_parser.c:
* Fix initialization of scheduler id struct members.  Some off nominal
paths had 0 as a scheduler id to be destroyed when it was never started.

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

channel.c:
* Fix channel initialization of the video stream scheduler id.

pbx_dundi.c:
* Fix channel initialization of the packet retransmission scheduler id.

ASTERISK-25476

Change-Id: I07a3449f728f671d326a22fcbd071f150ba2e8c8
2015-12-01 13:54:04 -06:00
Matt Jordan 726ee873a6 chan_pjsip: Handle T.38 faxes with direct media bridges
When a channel is in a direct media bridge, a re-INVITE may arrive that forces
Asterisk to re-negotiate the media to a T.38 fax. When this occurs, the bridge
must change its technology to a simple bridge, and re-INVITE the media back
to Asterisk.

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

ASTERISK-25582

Change-Id: Iabd6aa578e633d16e6b9f342091264e4324a79eb
2015-11-22 22:37:29 -06:00
Steve Davies d982b99e71 Further fixes to improper usage of scheduler
When ASTERISK-25449 was closed, a number of scheduler issues mentioned in
the comments were missed. These have since beed raised in ASTERISK-25476
and elsewhere.

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

ASTERISK-25476 #close

Change-Id: I87a77d581e2e0d91d33b4b2fbff80f64a566d05b
2015-11-12 11:46:43 +00:00
Alexander Traud cf79b62778 ast_format_cap_get_names: To display all formats, the buffer was increased.
ASTERISK-25533 #close

Change-Id: Ie1a9d1a6511b3f1a56b93d04475fbf8a4e40010a
2015-11-09 16:58:52 +01:00
Corey Farrell 40574a2ea3 chan_sip: Allow websockets to be disabled.
This patch adds a new setting "websockets_enabled" to sip.conf.
Setting this to false allows chan_sip to be used without causing
conflicts with res_pjsip_transport_websocket.

ASTERISK-24106 #close
Reported by: Andrew Nagy

Change-Id: I04fe8c4f2d57b2d7375e0e25826c91a72e93bea7
2015-11-03 08:53:00 -05:00
Matt Jordan a186c9ee30 Merge "chan_sip: Do not send all codecs on INVITE." 2015-10-29 08:26:39 -05:00
Alexander Traud d343a25173 chan_sip: Do not send all codecs on INVITE.
Since version 13, Asterisk sent all allowed codecs as callee, even when the
caller did not request/support them. In case of dynamic RTP payloads, this led
to the same ID for different codecs, which is not allowed by SIP/SDP. Now, the
intersection between the requested and the supported codecs is send again.

ASTERISK-24543 #close

Change-Id: Ie90cb8bf893b0895f8d505e77343de3ba152a287
2015-10-26 17:44:18 +01:00
George Joseph 4328d320c2 build: GCC 5.1.x catches some new const, array bounds and missing paren issues
Fixed 1 issue in each of the affected files.

ASTERISK-25494 #close
Reported-by: George Joseph
Tested-by: George Joseph

Change-Id: I818f149cd66a93b062df421e1c73c7942f5a4a77
2015-10-24 16:08:54 -05:00
Alexander Traud f3b2b3d1b3 chan_sip: Fix autoframing=yes.
With Asterisk 13, the structures ast_format and ast_codec changed. Because of
that, the paketization timing (framing) of the RTP channel moved away from the
formats/codecs. In the course of that change, the ptime of the callee was not
honored anymore, when the optional autoframing was enabled.

ASTERISK-25484 #close

Change-Id: Ic600ccaa125e705922f89c72212c698215d239b4
2015-10-21 16:51:55 +02:00
Matt Jordan 13229037d1 channels/chan_sip: Set cause code to 44 on RTP timeout
To quote Olle:

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

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

Change-Id: Ia62100c55077d77901caee0bcae299f8dc7375fc
2015-10-13 14:27:57 -05:00
Joshua Colp 38519aeadf Merge "chan_pjsip: Fix crash on reINVITE before initial INVITE completes." 2015-10-08 13:48:33 -05:00
Florian Sauerteig 3ec9cf7d6a chan_sip: Fix port parsing for IPv6 addresses in SIP Via headers.
If a Via header containes an IPv6 address and a port number is ommitted,
as it is the standard port, we now leave the port empty and to not set it
to the value after the first colon of the IPv6 address.

ASTERISK-25443 #close

Change-Id: Ie3c2f05471cd006bf04ed15598589c09577b1e70
2015-10-06 16:34:34 -05:00
Richard Mudgett 8fe9350b68 chan_pjsip: Fix crash on reINVITE before initial INVITE completes.
Apparently some endpoints attempt to send a reINVITE before completing the
initial INVITE transaction.  In this case PJSIP responds appropriately to
the reINVITE with a 491 INVITE request pending.  Unfortunately chan_pjsip
is using the initial INVITE transaction state to determine if an INVITE is
the initial INVITE or a reINVITE.  Since the initial INVITE transaction
has not been confirmed yet chan_pjsip thinks the reINVITE is an initial
INVITE and starts another PBX thread on the channel.  The extra PBX thread
ensures that hilarity ensues.

* Fix checks for a reINVITE on incoming requests to look for the presence
of a to-tag instead of the initial INVITE transaction state.

* Made caller_id_incoming_request() determine what to do if there is a
channel on the session or not.  After a channel is created it is too late
to just store the new party id on the session because the session's party
id has already been copied to the channel's caller id.

ASTERISK-25404 #close
Reported by: Chet Stevens

Change-Id: Ie78201c304a2b13226f3a4ce59908beecc2c68be
2015-10-06 16:10:29 -05:00
Matt Jordan 52f413f709 Merge "Fix improper usage of scheduler exposed by 5c713fdf18f" 2015-10-06 08:30:13 -05:00
Matt Jordan 8cb614fe20 Fix improper usage of scheduler exposed by 5c713fdf18
When 5c713fdf18 was merged, it allowed for scheduled items to have an ID of
'0' returned. While this was valid per the documentation for the API, it was
apparently never returned previously. As a result, several users of the
scheduler API viewed the result as being invalid, causing them to reschedule
already scheduled items or otherwise fail in interesting ways.

This patch corrects the users such that they view '0' as valid, and a returned
ID of -1 as being invalid.

Note that the failing HEP RTCP tests now pass with this patch. These tests
failed due to a duplicate scheduling of the RTCP transmissions.

ASTERISK-25449 #close

Change-Id: I019a9aa8b6997584f66876331675981ac9e07e39
2015-10-06 07:40:29 -05:00
Debian Amtelco c6b0d60264 chan_pjsip: Add Referred-By header to the PJSIP REFER packet.
Some systems require the REFER packet to include a Referred-By header.
If the channel variable SIPREFERREDBYHDR is set, it passes that value as the
Referred-By header value.  Otherwise, it adds the current dialog’s local info.

Reported by: Dan Cropp
Tested by: Dan Cropp

Change-Id: I3d17912ce548667edf53cb549e88a25475eda245
2015-10-05 21:45:24 +00:00
Joshua Colp 9f673544a4 Merge "chan_sip: Fix From header truncation for extremely long CALLERID(name)." 2015-09-19 08:31:52 -05:00
Walter Doekes e4df271a3e chan_sip: Fix From header truncation for extremely long CALLERID(name).
The CALLERID(num) and CALLERID(name) and other info are placed into the
`char from[256]` in initreqprep. If the name was too long, the addr-spec
and params wouldn't fit.

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

ASTERISK-25396 #close

Change-Id: I33632baf024f01b6a00f8c7f35c91e5f68c40260
2015-09-18 03:05:03 -05:00
Scott Griepentrog 87f04d5acf PJSIP: avoid crash when getting rtp peer
Although unlikely, if the tech private is returned as
a NULL, chan_pjsip_get_rtp_peer() would crash.

ASTERISK-25323

Change-Id: Ie231369bfa7da926fb2b9fdaac228261a3152e6a
2015-09-17 13:14:11 -05:00
Matt Jordan b1f9c998ed Merge "chan_sip.c: Validation on module reload" 2015-09-11 12:40:43 -05:00
Rodrigo Ramírez Norambuena 34aa96bef4 chan_sip.c: Validation on module reload
Change validation on reload module because now used the cli function for
reload. The sip_reload() function never fail and ever return NULL for this
reason on reload() now use the call the sip_reload() and return
AST_MODULE_LOAD_SUCCESS.

This problem is dectected on reload by PUT method on ARI, getting always
404 http code when the module is reloaded.

ASTERISK-25325 #close
Reporte by: Rodrigo Ramírez Norambuena

Change-Id: I41215877fb2cfc589e0d4d464000cf6825f4d7fb
2015-09-10 18:00:58 -03:00
Matt Jordan b16c7ef0ed Merge "channels/pjsip/dialplan_functions: Add an option for extracting the SIP call-id" 2015-09-05 18:43:50 -05:00
Matt Jordan 86b02228f5 channels/pjsip/dialplan_functions: Add an option for extracting the SIP call-id
This patch adds a new option to the CHANNEL function that allows for the
extraction of the SIP call-id. It is used in conjunction with the 'pjsip'
option, and will return the Call-ID of the INVITE request that established
the PJSIP channel.

ASTERISK-25352

Change-Id: I278d1f8bcfe3a53c5aa1dadebc14e92b0abd476a
2015-09-05 15:25:44 -05:00
Mark Michelson 4a540721d1 Merge "Chaos: make hangup NULL tolerant" 2015-08-27 14:53:46 -05:00
Scott Griepentrog 490db8ba94 Chaos: make hangup NULL tolerant
In chan_pjsip_new, if allocation of the pvt
structure fails, ast_hangup is called.  But
it was written to assume pvt was valid, and
this change corrects that.

ASTERISK-25323
Reported by: Scott Griepentrog

Change-Id: I5f47860fe9cee4cd56abd3f79b108678ab72cc87
2015-08-26 14:34:18 -05:00
Joshua Colp d03d09aad3 chan_sip: Allow call pickup to set the hangup cause.
The call pickup implementation in chan_sip currently sets the channel
hangup cause to "normal clearing" if call pickup is successfully
performed. This action overwrites the "answered elsewhere" hangup cause
set by the call pickup code and can result in the SIP device in
question showing a missed call when it should not.

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

ASTERISK-25346 #close

Change-Id: I00ac2c269cee9e29586ee2c65e83c70e52a02cff
2015-08-26 06:08:43 -05:00
Richard Mudgett 857923d9c7 chan_sip.c: Set preferred rx payload type mapping on incoming offers.
ASTERISK-25166
Reported by: Kevin Harwell

ASTERISK-17410
Reported by: Boris Fox

Change-Id: I7f04d5c8bee1126fee5fe6afbc39e45104469f4e
2015-08-20 11:56:14 -05:00
Richard Mudgett 1a549ed134 rtp_engine.c: Initial split of payload types into rx and tx mappings.
There are numerous problems with the current implementation of the RTP
payload type mapping in Asterisk.  It uses only one mapping structure to
associate payload types to codecs.  The single mapping is overkill if all
of the payload type values are well known values.  Dynamic payload type
mappings do not work as well with the single mapping because RFC3264
allows each side of the link to negotiate different dynamic mappings for
what they want to receive.  Not only could you have the same codec mapped
for sending and receiving on different payload types you could wind up
with the same payload type mapped to different codecs for each direction.

1) An independent payload type mapping is needed for sending and
receiving.

2) The receive mapping needs to keep track of previous mappings because of
the slack to when negotiation happens and current packets in flight using
the old mapping arrive.

3) The transmit mapping only needs to keep track of the current negotiated
values since we are sending the packets and know when the switchover takes
place.

* Needed to create ast_rtp_codecs_payload_code_tx() and make some callers
use the new function because ast_rtp_codecs_payload_code() was used for
mappings in both directions.

* Needed to create ast_rtp_codecs_payloads_xover() for cases where we need
to pass preferred codec mappings to the peer channel for early media
bridging or when we need to prefer the offered mapping that RFC3264 says
we SHOULD use.

* ast_rtp_codecs_payloads_xover() and ast_rtp_codecs_payload_code_tx() are
the only new public functions created.  All the others were only used for
the tx or rx mapping direction so the function doxygen now reflects which
direction the function operates.

* chan_mgcp.c: Removed call to ast_rtp_codecs_payloads_clear() as doing
that makes no sense when processing an incoming SDP.  We would be wiping
out any mappings that we set for the possible outgoing SDP we sent
earlier.

ASTERISK-25166
Reported by: Kevin Harwell

ASTERISK-17410
Reported by: Boris Fox

Change-Id: Iaf6c227bca68cb7c414cf2fd4108a8ac98bd45ac
2015-08-19 17:09:58 -05:00
Kevin Harwell 43bdddfc26 chan_sip.c: wrong peer searched in sip_report_security_event
In chan_sip, after handling an incoming invite a security event is raised
describing authorization (success, failure, etc...). However, it was doing
a lookup of the peer by extension. This is fine for register messages, but
in the case of an invite it may search and find the wrong peer, or a non
existent one (for instance, in the case of call pickup). Also, if the peers
are configured through realtime this may cause an unnecessary database lookup
when caching is enabled.

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

ASTERISK-25320 #close

Change-Id: I9b3f11549efb475b6561c64f0e6da1a481d98bc4
2015-08-13 15:01:58 -05:00
Mark Michelson 58edd2dddc Merge "chan_dahdi.c: Lock private struct for ast_write()." 2015-08-12 13:37:33 -05:00
Mark Michelson 318b97fd1e Merge "chan_dahdi.c: Flush the DAHDI write buffer after starting DTMF." 2015-08-12 13:37:14 -05:00
Richard Mudgett 87c92d2aee chan_dahdi.c: Flush the DAHDI write buffer after starting DTMF.
Pressing DTMF digits on a phone to go out on a DAHDI channel can result in
the digit not being recognized or even heard by the peer.

Phone -> Asterisk -> DAHDI/channel

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

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

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

ASTERISK-25315 #close
Reported by John Hardin

Change-Id: Ib56262c708cb7858082156bfc70ebd0a220efa6a
2015-08-11 16:58:32 -05:00
Richard Mudgett b9b957d4e9 chan_dahdi.c: Lock private struct for ast_write().
There is a window of opportunity for DTMF to not go out if an audio frame
is in the process of being written to DAHDI while another thread starts
sending DTMF.  The thread sending the audio frame could be past the
currently dialing check before being preempted by another thread starting
a DTMF generation request.  When the thread sending the audio frame
resumes it will then cause DAHDI to stop the DTMF tone generation.  The
result is no DTMF goes out.

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

ASTERISK-25315
Reported by John Hardin

Change-Id: Ib4e0264cf63305ed5da701188447668e72ec9abb
2015-08-11 16:58:11 -05:00
Alexander Traud 991d4da1eb chan_sip: Fix negotiation of iLBC 30.
iLBC 20 was advertised in a SIP/SDP negotiation. However, only iLBC 30 is
supported. Removes "a=fmtp:x mode=y" from SDP. Because of RFC 3952 section 5,
only iLBC 30 is negotiated now.

ASTERISK-25309 #close

Change-Id: I92d724600a183eec3114da0ac607b994b1a793da
2015-08-11 14:49:01 +02:00
Mark Michelson 35a98161df res_http_websocket: Avoid passing strlen() to ast_websocket_write().
We have seen a rash of test failures on a 32-bit build agent. Commit
48698a5e21 solved an obvious problem where
we were not encoding a 64-bit value correctly over the wire. This
commit, however, did not solve the test failures.

In the failing tests, ARI is attempting to send a 537 byte text frame
over a websocket. When sending a frame this small, 16 bits are all that
is required in order to encode the payload length on the websocket
frame. However, ast_websocket_write() thinks that the payload length is
greater than 65535 and therefore writes out a 64 bit payload length.
Inspecting this payload length, the lower 32 bits are exactly what we
would expect it to be, 537 in hex. The upper 32 bits, are junk values
that are not expected to be there.

In the failure, we are passing the result of strlen() to a function that
expects a uint64_t parameter to be passed in. strlen() returns a size_t,
which on this 32-bit machine is 32 bits wide. Normally, passing a 32-bit
unsigned value to somewhere where a 64-bit unsigned value is expected
would cause no problems. In fact, in manual runs of failing tests, this
works just fine. However, ast_websocket_write() uses the Asterisk
optional API, which means that rather than a simple function call, there
are a series of macros that are used for its declaration and
implementation. These macros may be causing some sort of error to occur
when converting from a 32 bit quantity to a 64 bit quantity.

This commit changes the logic by making existing ast_websocket_write()
calls use ast_websocket_write_string() instead. Within
ast_websocket_write_string(), the 64-bit converted strlen is saved in a
local variable, and that variable is passed to ast_websocket_write()
instead.

Note that this commit message is full of speculation rather than
certainty. This is because the observed test failures, while always
present in automated test runs, never occur when tests are manually
attempted on the same test agent. The idea behind this commit is to fix
a theoretical issue by performing changes that should, at the least,
cause no harm. If it turns out that this change does not fix the failing
tests, then this commit should be reverted.

Change-Id: I4458dd87d785ca322b89c152b223a540a3d23e67
2015-08-03 11:23:29 -05:00
Richard Mudgett d122c1e50b chan_sip.c: Tweak glue->update_peer() parameter nil value.
Change glue->update_peer() parameter from 0 to NULL to better indicate it
is a pointer.

Change-Id: I8ff2e5087f0e19f6998e3488a712a2470cc823bd
2015-07-30 17:11:57 -05:00
Joshua Colp 309dd2a409 pjsip: Add rtp_timeout and rtp_timeout_hold endpoint options.
This change adds support for the 'rtp_timeout' and 'rtp_timeout_hold'
endpoint options. These allow the channel to be hung up if RTP
is not received from the remote endpoint for a specified number of
seconds.

ASTERISK-25259 #close

Change-Id: I3f39daaa7da2596b5022737b77799d16204175b9
2015-07-24 12:43:43 -03:00
Matt Jordan 6741eedece Merge "chan_pjsip: Don't change formats when frame of unsupported format is received." 2015-07-20 07:31:43 -05:00
Joshua Colp 649460aa44 chan_pjsip: Don't change formats when frame of unsupported format is received.
Receipt of an RTP packet currently causes the formats on an PJSIP channel to
change to the format of the RTP packet. In some off-nominal cases it's possible
for this to be a format that has not been configured or negotiated. This change
makes it so only formats explicitly configured on the endpoint are allowed.

ASTERISK-25258 #close

Change-Id: If93d641fb6418a285928839300d7854cab8c1020
2015-07-17 12:37:17 -05:00
Patric Marschall 7908ae4934 sig_pri.h: force_restart_unavailable_chans in wrong scope
In channels/sig_pri.h, struct sig_pri_span, the field
force_restart_unavailable_chans is only defined if

#if defined(HAVE_PRI_MCID) is true.

All other occurences of force_restart_unavailable_chans are outside of the

#if defined(HAVE_PRI_MCID)
endif

scope.

ASTERISK-25257 #close
Reported by: Patric Marschall

Change-Id: I071de89cc2cd0d85927a013036e235851f672549
2015-07-17 11:02:24 -05:00
Joshua Colp 987548413d Merge "chan_sip: Fix early call pickup channel leak." 2015-07-04 19:08:59 -05:00
Matt Jordan 2c17515f3c Makefile: Remove coverage files on 'make clean'
This patch updates a variety of Makefiles in Asterisk's build system to
remove .gcda and .gcno files when 'make clean' is executed. These files
are generated when '--enable-coverage' is passed to the Asterisk
configure script.

Change-Id: Ib70b41eea2ee2908885bff02e80faf9f40c84602
2015-07-04 07:47:06 -05:00
Joshua Colp fa4dd9755a Merge "chan_vpb.cc: Fix compiler warning Jenkins found." 2015-07-02 09:47:58 -05:00
Walter Doekes 34323f9f95 chan_sip: Fix early call pickup channel leak.
When handle_invite_replaces() was called, and either ast_bridge_impart()
failed or there was no bridge (because the channel we're picking up was
still ringing), chan_sip would leak a channel.

Thanks Matt and Corey for checking the bridge path.

ASTERISK-25226 #close

Change-Id: Ie736bb182170a73eef5bcef0ab0376f645c260c8
2015-07-02 09:16:09 -05:00
Walter Doekes 6fbb58c7f7 chan_mgcp: Don't call close on fd -1.
ASTERISK-25220 #close

Change-Id: Ic48f3a82f51ada87f2fb0e016c9efe0ad56f1ee3
2015-07-02 06:22:18 -05:00
Richard Mudgett 41610df8d5 chan_vpb.cc: Fix compiler warning Jenkins found.
Change-Id: I0ec7fd10d56d90d5a60b12b5a7d6807f265ac5e0
2015-07-01 17:25:31 -05:00
Alexander Traud 1ad9a6b6b6 chan_sip: Reload peer without its old capabilities.
On reload, previously allowed codecs were not removed. Therefore, it was not
possible to remove codecs while Asterisk was running. Furthermore, newly added
codecs got appended behind the previous codecs. Therefore, it was not possible
to add a codec with a priority of #1. This change removes the old capabilities
before the current ones are added.

ASTERISK-25182 #close
Reported by: Alexander Traud
patches:
 asterisk_13_allow_codec_reload.patch uploaded by Alexander Traud (License 6520)

Change-Id: I62a06bcf15e08e8c54a35612195f97179ebe5802
2015-06-22 16:47:07 +02:00
Joshua Colp 5caefc98a1 chan_sip: Destroy peers without holding peers container lock.
Due to the use of stasis_unsubscribe_and_join in the peer destructor
it is possible for a deadlock to occur when an event callback is
occurring at the same time.

This happens because the peer may be destroyed while holding the
peers container lock. If this occurs the event callback will never
be able to acquire the container lock and the unsubscribe will
never complete.

This change makes it so the peers that have been removed from the
peers container are not destroyed with the container lock held.

ASTERISK-25163 #close

Change-Id: Ic6bf1d9da4310142a4d196c45ddefb99317d9a33
2015-06-20 19:48:34 -05:00
Damian Ivereigh 19f60d9412 chan_sip.c: Update dialog fromtag after request with auth
If a client sends and INVITE which is 401 rejected, then subsequently
sends a new INVITE with the auth info and uses a different fromtag
from the first INVITE, Asterisk will accept the new INVITE as part of
the original dialog - match_req_to_dialog() specifically ignores the
fromtag. However it does not update the stored dialog with the new
fromtag.

This results in Asterisk being unable to match future packets that are
part of this dialog (such as the ACK to the OK or the OK to the BYE),
and the call is dropped.

This problem was originally found when using an NEC-i SV8100-GE (NEC SIP
Card).

* After a successful match of a packet to the dialog, if the packet is
  not a SIP_RESPONSE, authentication is present and the fromtags are
  different, the stored fromtag is updated with the one from the recent
  INVITE.

ASTERISK-25154 #close
Reported by: Damian Ivereigh
Tested by: Damian Ivereigh

Change-Id: I5c16cf3b409e5ef9f2b2fe974b6bd2a45a6aa17e
2015-06-12 09:02:34 -05:00
Matt Jordan bb00b26f35 chan_pjsip: Set the context and extension on the channel when created
Prior to this patch, chan_pjsip was failing to pass the endpoint's
context and the desired extension to the ast_channel_alloc_* routine.
This caused a new channel snapshot to be issued without a context and
extension, which can cause some reporting issues for users of AMI, CEL,
and other APIs. The channel driver would later set the context and
extension on the channel such that the channel would start in the
correct location in the dialplan, but the information reported in the
initial event would be incorrect.

This patch modifies the channel driver such that it now passes the
context and extension directly into the allocation routine. This
provides the information in the new channel snapshot published over
Stasis.

ASTERISK-25156 #close
Reported by: cloos

Change-Id: Ic6f8542836e596db8f662071d118e8f934fdf25e
2015-06-11 19:07:22 -05:00
Mark Michelson 339f965cbe Merge "chan_iax2: Prevent deadlock between hangup and sending lagrq/ping" 2015-06-10 12:06:02 -05:00
Corey Farrell 80621ce3c5 Fix unsafe uses of ast_context pointers.
Although ast_context_find, ast_context_find_or_create and
ast_context_destroy perform locking of the contexts table,
any context pointer can become invalid at any time that the
contexts table is unlocked. This change adds locking around
all complete operations involving these functions.

Places where ast_context_find was followed by ast_context_destroy
have been replaced with calls ast_context_destroy_by_name.

ASTERISK-25094 #close
Reported by: Corey Farrell

Change-Id: I1866b6787730c9c4f3f836b6133ffe9c820734fa
2015-06-08 11:09:57 -04:00
Corey Farrell 50044fdc15 Stasis: Fix unsafe use of stasis_unsubscribe in modules.
Many uses of stasis_unsubscribe in modules can be reached through unload.
These have been switched to stasis_unsubscribe_and_join.

Some subscription callbacks do nothing, for these I've created a noop
callback function in stasis.c.  This is used by some modules that monitor
MWI topics in order to enable cache, since the callback does not become
invalid after dlclose it is safe to use stasis_unsubscribe on these, even
during module unload.

ASTERISK-25121 #close

Change-Id: Ifc2549fbd8eef7d703c222978e8f452e2972189c
2015-05-22 22:30:22 -05:00
Yousf Ateya 83ff268b9e chan_iax2: Prevent deadlock between hangup and sending lagrq/ping
channels/chan_iax.c: Prevent the deadlock between iax2_hangup and send_lagrq/
send_ping. This deadlock happens because the scheduled task send_lagrq(or
send_ping) starts execution after the call hangup procedure starts but before
it deletes the tasks in the scheduler.

The solution is to delete scheduled lagrq (and ping) task asynchronously
(i.e. schedule AST_SCHED_DEL for these tasks); By this, AST_SCHED_DEL will
be called in a new context (doesn't have callno locked).

This commit also cleans up the procedure of sending LAGRQ and PING.

main/sched.c: Do not assert when deleting non existant entry from scheduler.
This assert seems to be the reason for a lot of awkward code to avoid it.

ASTERISK-24983 #close
Reported by: Y Ateya

Change-Id: I03bec1fc8faacb89630269e935fa667c6d6c080c
2015-05-20 23:27:42 +02:00
snuffy 17129d2c29 chan_pjsip: Fix crash during off-nominal when no endpoint specified.
Add missing return -1 when no endpoint name is specified.

ASTERISK-25086 #close
Reported by: snuffy

Change-Id: I9de76c2935a1f4e3f0cffe97a670106f5605e89e
2015-05-17 07:43:34 -05:00
Joshua Colp 35ff01823b Merge "AST_MODULE_INFO: Format corrections to the usages of AST_MODULE_INFO macro." 2015-05-14 05:03:43 -05:00
Rodrigo Ramírez Norambuena eec010829a AST_MODULE_INFO: Format corrections to the usages of AST_MODULE_INFO macro.
Change-Id: Icf88f9f861c6b2a16e5f626ff25795218a6f2723
2015-05-13 16:34:23 -05:00
Richard Mudgett 0bb0d4a603 chan_dahdi/sig_pri: Fix crash on ISDN call hangup collision.
If an ISDN call is hungup by both sides at the same time a crash could
happen.

* Added missing NULL checks for the owner channel after calling
pri_queue_pvt_cause_data() in two places.  Code after those calls need to
check the owner channel pointer for NULL before use because
pri_queue_pvt_cause_data() needs to do deadlock avoidance to lock the
owner and the owner may get hung up.

ASTERISK-21893 #close
Reported by:  Alexandr Gordeev

Change-Id: Ica3e266ebc7a894b41d762326f08653e1904bb9a
2015-05-12 17:43:35 -05:00
Matt Jordan f451af65c4 Merge topics 'ASTERISK-25049', 'ASTERISK-25056'
* changes:
  CLI: Enable automatic references to modules.
  Modules: Make ast_module_info->self available to auxiliary sources.
2015-05-07 07:04:43 -05:00
Joshua Colp bebf0b9b27 chan_unistim: Fix build failure due to ACL changes.
Change-Id: I57081045c72b9fcf12d5c84493278f9272c31b32
2015-05-05 17:01:31 -03:00
Joshua Colp f45833c9ad Merge "Restrict functionality when ACLs are misconfigured." 2015-05-05 10:13:23 -05:00
Corey Farrell a8bfa9e104 Modules: Make ast_module_info->self available to auxiliary sources.
ast_module_info->self is often needed to register items with the core.  Many
modules have ad-hoc code to make this pointer available to auxiliary sources.
This change updates the module build process to make the needed information
available to all sources in a module.

ASTERISK-25056 #close
Reported by: Corey Farrell

Change-Id: I18c8cd58fbcb1b708425f6757becaeca9fa91815
2015-05-04 20:47:01 -04:00
Corey Farrell c3ec5da156 Remove unneeded uses of optional_api providers.
A few cases exist where headers of optional_api provders are included but
not needed.  This causes unneeded calls to ast_optional_api_use.

* Don't include optional_api.h from sip_api.h.
* Move 'struct ast_channel_monitor' to channel.h.
* Don't include monitor.h from chan_sip.c, channel.c or features.c.

The move of struct ast_channel_monitor is needed since channel.c depends on
it.  This has no effect on users of monitor.h since channel.h is included
from monitor.h.

ASTERISK-25051 #close
Reported by: Corey Farrell

Change-Id: I53ea65a9fc9693c89f8bcfd6120649bfcfbc3478
2015-05-02 19:31:12 -05:00
Mark Michelson 11ffcf662f Restrict functionality when ACLs are misconfigured.
This patch has two main purposes:

1) Improve warning messages when ACLs are configured improperly.
2) Prevent misconfigured ACLs from allowing potentially unwanted
traffic.

To acomplish point (2) in most cases, whatever configuration object that
the ACL belonged to was not allowed to load.

The one exception is res_pjsip_acl. In that case, ACLs are their own
configuration object. Furthermore, the module loading code has no
indication that a ACL configuration had a failure. So the tactic taken
here is to create an ACL that just blocks everything.

ASTERISK-24969
Reported by Corey Farrell

Change-Id: I2ebcb6959cefad03cea4d81401be946203fcacae
2015-04-30 10:43:51 -05:00
Richard Mudgett 03c51cf525 chan_dahdi: Add the chan_dahdi.conf force_restart_unavailable_chans option.
Some telco switches occasionally ignore ISDN RESTART requests.  The fix
for ASTERISK-19608 added an escape clause for B channels in the restarting
state if the telco ignores a RESTART request.  If the telco fails to
acknowledge the RESTART then Asterisk will assume the telco acknowledged
the RESTART on the second call attempt requesting the B channel by the
telco.  The escape clause is good for dealing with RESTART requests in
general but it does cause the next call for the restarting B channel to be
rejected if the telco insists the call must go on that B channel.

chan_dahdi doesn't really need to issue a RESTART request in response to
receiving a cause 44 (Requested channel not available) code.  Sending the
RESTART in such a situation is not required (nor prohibited) by the
standards.  I think chan_dahdi does this for historical reasons to deal
with buggy peers to get channels unstuck in a similar fashion as the
chan_dahdi.conf resetinterval option.

* Add the chan_dahdi.conf force_restart_unavailable_chans compatability
option that when disabled will prevent chan_dahdi from trying to RESTART
the channel in response to a cause 44 code.

ASTERISK-25034 #close
Reported by: Richard Mudgett

Change-Id: Ib8b17a438799920f4a2038826ff99a1884042f65
2015-04-30 10:24:57 -05:00
Joshua Colp 78ff328b0b Merge "chan_iax2: Ensure that IAX flags are 64 bits." 2015-04-29 05:31:05 -05:00
Yousf Ateya 5ebfed8ef3 chan_iax2: Ensure that IAX flags are 64 bits.
Flags are 64 bits.  Without LLU suffix the value of 1<<31 is negative.
Although it doesn't have an effect on the current implementation, it will
be problem if more flags are added.

Change-Id: Ic290c81cfbbbf062872392d99d3322932cc49487
2015-04-28 14:59:18 -05:00
Richard Mudgett 0bbe2c35cf chan_vpb: Fix compile error due to use of ASTERISK_FILE_VERSION.
Change-Id: I51179e2a83937423676da522b766f1126de4059e
2015-04-28 12:22:33 -05:00
Corey Farrell 5c1d07baf0 Astobj2: Allow reference debugging to be enabled/disabled by config.
* The REF_DEBUG compiler flag no longer has any effect on code that uses
  Astobj2.  It is used to determine if reference debugging is enabled by
  default.  Reference debugging can be enabled or disabled in asterisk.conf.
* Caller information is provided in logger errors for ao2 bad magic numbers.
* Optimizes AO2 by merging internal functions with the public counterpart.
  This was possible now that we no longer require a dual ABI.

ASTERISK-24974 #close
Reported by: Corey Farrell

Change-Id: Icf3552721fe999365ba8a8cf00a965aa6b897cc1
2015-04-27 18:37:26 -04:00
Matt Jordan d7f4788341 channels/chan_skinny: Fix compilation error introduced in f8e21a1adf
A typo in commit f8e21a1adf resulted in a compilation error in
chan_skinny. This patch fixes the typo.

ASTERISK-24917

Change-Id: Id7f4ad1fe948eb2408622e80c27936ce4516c33c
2015-04-26 17:21:15 -05:00
Diederik de Groot f8e21a1adf Clang: Fix some more tautological-compare warnings.
clang can warn about a so called tautological-compare, when it finds
comparisons which are logically always true, and are therefor deemed
unnecessary.

Exanple:
unsigned int x = 4;
if (x > 0)    // x is always going to be bigger than 0

Enum Case:
Each enumeration is its own type. Enums are an integer type but they
do not have to be *signed*. C leaves it up to the compiler as an
implementation option what to consider the integer type of a particu-
lar enumeration is. Gcc treats an enum without negative values as
an int while clang treats this enum as an unsigned int.

rmudgett & mmichelson: cast the enum to (unsigned int) in assert.
The cast does have an effect. For gcc, which seems to treat all enums
as int, the cast to unsigned int will eliminate the possibility of
negative values being allowed. For clang, which seems to treat enums
without any negative members as unsigned int, the cast will have no
effect. If for some reason in the future a negative value is ever
added to the enum the assert will still catch the negative value.

ASTERISK-24917
Change-Id: Ief23ef68916192b9b72dabe702b543ecfeca0b62
2015-04-24 09:48:44 -05:00
Richard Mudgett 614f506690 chan_dahdi/sig_pri: Make post AMI HangupRequest events on PRI channels.
The chan_dahdi channel driver is a very old driver.  The ability for it to
support ISDN was added well after the initial analog support.  Setting the
softhangup flags is a carry over from the original analog code.  The
driver was not updated to call ast_queue_hangup() which will post the AMI
HangupRequest event.

* Changed sig_pri.c to call ast_queue_hangup() instead of setting the
softhangup flag when the remote party initiates a hangup.

ASTERISK-24895 #close
Reported by: Andrew Zherdin

Change-Id: I5fe2e48556507785fd8ab8e1c960683fd5d20325
2015-04-20 19:07:57 -05:00
Corey Farrell 62508d6891 Build System: Create Makefile macro MOD_ADD_SOURCE.
This new macro allows a single line to add all additional
sources to a module.  This helps prevent modules from
missing steps, and makes future changes easier since
they can be made in a single place.

ASTERISK-24960 #close
Reported by: Corey Farrell

Change-Id: I38f12d8b72c5e7bb37a879b2fb51761a2855eb4b
2015-04-14 12:53:03 -04:00
Matt Jordan 4a58261694 git migration: Refactor the ASTERISK_FILE_VERSION macro
Git does not support the ability to replace a token with a version
string during check-in. While it does have support for replacing a
token on clone, this is somewhat sub-optimal: the token is replaced
with the object hash, which is not particularly easy for human
consumption. What's more, in practice, the source file version was often
not terribly useful. Generally, when triaging bugs, the overall version
of Asterisk is far more useful than an individual SVN version of a file. As a
result, this patch removes Asterisk's support for showing source file
versions.

Specifically, it does the following:

* Rename ASTERISK_FILE_VERSION macro to ASTERISK_REGISTER_FILE, and
  remove passing the version in with the macro. Other facilities
  than 'core show file version' make use of the file names, such as
  setting a debug level only on a specific file. As such, the act of
  registering source files with the Asterisk core still has use. The
  macro rename now reflects the new macro purpose.

* main/asterisk:
  - Refactor the file_version structure to reflect that it no longer
    tracks a version field.
  - Remove the "core show file version" CLI command. Without the file
    version, it is no longer useful.
  - Remove the ast_file_version_find function. The file version is no
    longer tracked.
  - Rename ast_register_file_version/ast_unregister_file_version to
    ast_register_file/ast_unregister_file, respectively.

* main/manager: Remove value from the Version key of the ModuleCheck
  Action. The actual key itself has not been removed, as doing so would
  absolutely constitute a backwards incompatible change. However, since
  the file version is no longer tracked, there is no need to attempt to
  include it in the Version key.

* UPGRADE: Add notes for:
  - Modification to the ModuleCheck AMI Action
  - Removal of the "core show file version" CLI command

Change-Id: I6cf0ff280e1668bf4957dc21f32a5ff43444a40e
2015-04-13 03:48:57 -04:00
Richard Mudgett c499cabf53 chan_pjsip/res_pjsip/bridge_softmix/core: Improve translation path choices.
With this patch, chan_pjsip/res_pjsip now sets the native formats to the
codecs negotiated by a call.

* The changes in chan_pjsip.c and res_pjsip_sdp_rtp.c set the native
formats to include all the negotiated audio codecs instead of only the
initial preferred audio codec and later the currently received audio
codec.

* The audio frame handling in channel.c:ast_read() is more streamlined and
will automatically adjust to changes in received frame formats.  The new
policy is to remove translation and pass the new frame format to the
receiver except if the translation was to a signed linear format.  A more
long winded version is commented in ast_read() along with some caveats.

* The audio frame handling in channel.c:ast_write() is more streamlined
and will automatically adjust any needed translation to changes in the
frame formats sent.  Frame formats sent can change for many reasons such
as a recording is being played back or the bridged peer changed the format
it sends.  Since it is a normal expectation that sent formats can change,
the codec mismatch warning message is demoted to a debug message.

* Removed the short circuit check in
channel.c:ast_channel_make_compatible_helper().  Two party bridges need to
make channels compatible with each other.  However, transfers and moving
channels among bridges can result in otherwise compatible channels having
sub-optimal translation paths if the make compatible check is short
circuited.  A result of forcing the reevaluation of channel compatibility
is that the asterisk.conf:transcode_via_slin and codecs.conf:genericplc
options take effect consistently now.  It is unfortunate that these two
options are enabled by default and negate some of the benefits to the
changes in channel.c:ast_read() by forcing translation through signed
linear on a two party bridge.

* Improved the softmix bridge technology to better control the translation
of frames to the bridge.  All of the incoming translation is now normally
handled by ast_read() instead of splitting any translation steps between
ast_read() and the slin factory.  If any frame comes in with an unexpected
format then the translation path in ast_read() is updated for the next
frame and the slin factory handles the current frame translation.

This is the final patch in a series of patches aimed at improving
translation path choices.  The other patches are on the following reviews:
https://reviewboard.asterisk.org/r/4600/
https://reviewboard.asterisk.org/r/4605/

ASTERISK-24841 #close
Reported by: Matt Jordan

Review: https://reviewboard.asterisk.org/r/4609/
........

Merged revisions 434671 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-04-10 23:37:20 +00:00
Kevin Harwell 66f3fd0028 chan_sip: make progressinband default to no
After the "progressinband" value setting of "never" was updated to never send a
183 this separated its use from the "no" value. Since "never" was the default,
but most users probably expect "no" this patch updates the default for the
"progressinband" setting to "no."

ASTERISK-24835 #close
Reported by: Andrew Nagy
Review: https://reviewboard.asterisk.org/r/4606/
........

Merged revisions 434654 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434655 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-04-10 21:06:23 +00:00
Matthew Jordan 8bae18ab93 res_pjsip: Add an 'auto' option for DTMF Mode
This patch adds support for automatically detecting the type of DTMF that a
PJSIP endpoint supports. When the 'dtmf_mode' endpoint option is set to 'auto',
the channel created for an endpoint will attempt to determine if RFC 4733
DTMF is supported. If so, it will use that DTMF type. If not, the DTMF type
for the channel will be set to inband.

Review: https://reviewboard.asterisk.org/r/4438

ASTERISK-24706 #close
Reported by: yaron nahum
patches:
  yaron_patch_3_Feb.diff submitted by yaron nahum (License 6676)
........

Merged revisions 434637 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434638 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-04-10 17:56:47 +00:00
Matthew Jordan 80c443bea4 channels/chan_iax2: Improve POKE expiration time calculation for lossy networks
POKE is used to check for peer availability; however, in networks with packet
loss, the current calculations may result in POKE expiration times that are too
short. This patch alters the expiration/retry time logic to take into account
the last known qualify round trip time, as opposed to always using a static
value for each peer.

Review: https://reviewboard.asterisk.org/r/4536

ASTERISK-22352 #close
Reported by: Frederic Van Espen

ASTERISK-24894 #close
Reported by: Y Ateya
patches:
  poke_noanswer_duration.diff submitted by Y Ateya (License 6693)
........

Merged revisions 434564 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 434565 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434566 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-04-10 12:40:36 +00:00
Matthew Jordan b3d01f1fbf channels/chan_iax2: Add a configuration parameter for call token expiration
This patch adds a new configuration parameter, 'calltokenexpiration', that
controls how long before an authentication call token is expired. The default
maintains the RFC specified 10 seconds. Setting it to a higher value may be
useful in lossy networks.

Review: https://reviewboard.asterisk.org/r/4588

ASTERISK-24939 #close
Reported by: Y Ateya
patches:
  ctoken_configuration.diff submitted by Y Ateya (License 6693)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434563 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-04-10 12:23:42 +00:00
Richard Mudgett b2b1f24af6 chan_iax2.c: Fix ref leak in iax2_request().
* Increased warning message format capability string buffer size in
iax2_request().

Review: https://reviewboard.asterisk.org/r/4601/
........

Merged revisions 434510 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434511 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-04-09 16:09:58 +00:00
Matthew Jordan ea0098724e clang compiler warnings: Fix autological comparisons
This fixes autological comparison warnings in the following:
 * chan_skinny: letohl may return a signed or unsigned value, depending on the
   macro chosen
 * func_curl: Provide a specific cast to CURLoption to prevent mismatch
 * cel: Fix enum comparisons where the enum can never be negative
 * enum: Fix comparison of return result of dn_expand, which returns a signed
   int value
 * event: Fix enum comparisons where the enum can never be negative
 * indications: tone_data.freq1 and freq2 are unsigned, and hence can never be
   negative
 * presencestate: Use the actual enum value for INVALID state
 * security_events: Fix enum comparisons where the enum can never be negative
 * udptl: Don't bother to check if the return value from encode_length is less
   than 0, as it returns an unsigned int
 * translate: Since the parameters are unsigned int, don't bother checking
   to see if they are negative. The cast to unsigned int would already blow
   past the matrix bounds.
 * res_pjsip_exten_state: Use a temporary value to cache the return of
   ast_hint_presence_state
 * res_stasis_playback: Fix enum comparisons where the enum can never be
   negative
 * res_stasis_recording: Add an enum value for the case where the recording
   operation is in error; fix enum comparisons
 * resource_bridges: Use enum value as opposed to -1
 * resource_channels: Use enum value as opposed to -1

Review: https://reviewboard.asterisk.org/r/4533
ASTERISK-24917
Reported by: dkdegroot
patches:
  rb4533.patch submitted by dkdegroot (License 6600)
........

Merged revisions 434469 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 434470 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434471 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-04-09 12:57:21 +00:00
Richard Mudgett 09df34d880 Bridging: Eliminate the unnecessary make channel compatible with bridge operation.
When a channel enters the bridging system it is first made compatible with
the bridge and then the bridge technology makes the channel compatible
with the technology.  For all but the DAHDI native and softmix bridge
technologies the make channel compatible with the bridge step is an
effective noop because the other technologies allow all audio formats.
For the DAHDI native bridge technology it doesn't matter because it is not
an initial bridge technology and chan_dahdi allows only one native format
per channel.  For the softmix bridge technology, it is a noop at best and
harmful at worst because the wrong translation path could be setup if the
channel's native formats allow more than one audio format.

This is an intermediate patch for a series of patches aimed at improving
translation path choices.

* Removed code dealing with the unnecessary step of making the channel
compatible with the bridge.

ASTERISK-24841
Reported by: Matt Jordan

Review: https://reviewboard.asterisk.org/r/4600/
........

Merged revisions 434424 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434430 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-04-08 18:20:26 +00:00
Matthew Jordan 3f54af689f chan_iax2: Fix compilation issue due to funky merge
Don't mix declarations and code!


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434294 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-04-08 12:02:37 +00:00
Matthew Jordan a9b6a62461 chan_iax2: Fix crash caused by unprotected access to iaxs[peer->callno]
This patch fixes an access to the peer callnumber that is unprotected by a
corresponding mutex. The peer->callno value can be changed by multiple threads,
and all data inside the iaxs array must be procted by a corresponding lock
of iaxsl.

The patch moves the unprotected access to a location where the mutex is
safely obtained.

Review: https://reviewboard.asterisk.org/r/4599/

ASTERISK-21211 #close
Reported by: Jaco Kroon
patches:
  asterisk-11.2.1-iax2_poke-segfault.diff submitted by Jaco Kroon (License 5671)
........

Merged revisions 434291 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 434292 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434293 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-04-08 12:00:35 +00:00
Matthew Jordan 477536ef25 chan_sip: Handle IPv4 mapped IPv6 clients when NAT is enabled
When udpbindaddr is set to the IPv6 bind all address of '::', Asterisk will
attempt to handle both IPv4 and IPv6 addresses, although the information will
be stored in a struct with an AF_INET6 address type. However, the current
NAT handling code won't handle the IPv4 mapped IPv6 addresses correctly.
This patch adds an additional check for the mapped address case, allowing
the NAT code to handle clients even when the address is IPv6.

Review: https://reviewboard.asterisk.org/r/4563/

ASTERISK-18032 #close
Reported by: Christoph Timm
patches:
  nat_with_ipv6.diff submitted by Valentin Vidić (License 6697)
........

Merged revisions 434288 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 434289 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434290 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-04-08 11:54:09 +00:00
Matthew Jordan b8fa8aa775 clang compiler warnings: Fix pointer-bool-converesion warnings
This patch fixes several warnings pointed out by the clang compiler.
* chan_pjsip: Removed check for data->text, as it will always be non-NULL.
* app_minivm: Fixed evaluation of etemplate->locale, which will always
  evaluate to 'true'. This patch changes the evaluation to use
  ast_strlen_zero.
* app_queue:
  - Fixed evaluation of qe->parent->monfmt, which always evaluates to
    true. Instead, we just check to see if the dereferenced pointer
    evaluates to true.
  - Fixed evaluation of mem->state_interface, wrapping it with a call to
    ast_strlen_zero.
* res_smdi: Wrapped search_msg->mesg_desk_term with calls to ast_strlen_zero.

Review: https://reviewboard.asterisk.org/r/4541

ASTERISK-24917
Reported by: dkdegroot
patches:
  rb4541.patch submitted by dkdegroot (License 6600)
........

Merged revisions 434285 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 434286 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434287 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-04-08 11:45:05 +00:00
Matthew Jordan c1cfe3fae2 clang compiler warnings: Fix non-literal-null-conversion warnings
Clang will flag errors when a char pointer is set to '\0', as opposed to a
value that the char pointer points to. This patch fixes this warning
in a variety of locations.

Review: https://reviewboard.asterisk.org/r/4551

ASTERISK-24917
Reported by: dkdegroot
patches:
  rb4551.patch submitted by dkdegroot (License 6600)
........

Merged revisions 434187 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 434188 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434189 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-04-07 02:03:48 +00:00
George Joseph e48f2e7897 build: Fixes for gcc 5 compilation
These are fixes for compilation under gcc 5.0...

chan_sip.c:    In parse_request needed to make 'lim' unsigned.
inline_api.h:  Needed to add a check for '__GNUC_STDC_INLINE__' to detect C99 
               inline semantics (same as clang).
ccss.c:        In ast_cc_set_parm, needed to fix weird comparison.
dsp.c:         Needed to work around a possible compiler bug.  It was throwing 
               an array-bounds error but neither
               sgriepentrog, rmudgett nor I could figure out why.
manager.c:     In action_atxfer, needed to correct an array allocation.

This patch will go to 11, 13, trunk.

Review: https://reviewboard.asterisk.org/r/4581/
Reported-by: Jeffrey Ollie
Tested-by: George Joseph
ASTERISK-24932 #close
........

Merged revisions 434113 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 434114 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434115 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-04-06 19:04:32 +00:00
Richard Mudgett 2d28fa678e chan_sip: Fix expression in unit test /channels/chan_sip/test_sip_rtpqos.
Fix misplaced parentheses in original fabs() expression.
........

Merged revisions 433816 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 433817 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433818 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-31 17:04:18 +00:00
Matthew Jordan 7bc2345fb1 clang compiler warnings: Fix -Wabsolute-value warnings
This patch fixes several warnings caught by clang - in this case, usage of the
abs function on non-integer values. This patch uses labs and fabs, as
appropriate, in the various affected files.

Review: https://reviewboard.asterisk.org/r/4525

ASTERISK-24917
Reported by: dkdegroot
patches:
  rb4525.patch submitted by dkdegroot (License 6600)
........

Merged revisions 433749 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 433750 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433751 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-30 02:45:29 +00:00
Matthew Jordan ce59fabd5c clang compiler warnings: Fix invalid enum conversion
This patch fixes some invalid enum conversion warnings caught by clang. In
particular:
* chan_sip: Several functions mixed usage of the st_refresher_param
  enum and st_refresher enum. This patch corrects the functions to use the
  right enum.
* chan_pjsip: Fixed mixed usage of ast_sip_session_t38state and ast_t38_state.
* strings: Fixed incorrect usage of AO2 flags with strings container.
* res_stasis: Change a return enumeration to stasis_app_user_event_res.

Review: https://reviewboard.asterisk.org/r/4535

ASTERISK-24917
Reported by: dkdegroot
patches:
  rb4535.patch submitted by dkdegroot (License 6600)
........

Merged revisions 433746 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 433747 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433748 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-30 02:39:57 +00:00
Matthew Jordan d2776d4d45 clang compiler warnings: Fix a variety of "unused" warnings
This patch fixes the -Wunused-value -Wunused-variable -Wunused-const-variable
errors caught by clang. Specifically:

* apps/app_queue.c: removed unused qpm_cmd_usage[], qum_cmd_usage[],
                    qsmp_cmd_usage[]
* cel/cel_sqlite3_custom.c: removed unused name[] = "cel_sqlite3_custom"
* channels/chan_pjsip.c: removed unused desc[] = "PJSIP Channel"
* codecs/gsm/src/gsm_create.c: removed unused ident[] = "$Header$"
* funcs/func_env.c:729: Fixed ast_str_append_substr.
* main/editline/np/strlcat.c: removed unused rcsid variable
* main/editline/np/strlcpy.c: removed unused rcsid variable
* main/security_events.c: removed unused TIMESTAMP_STR_LEN
* utils/conf2ael.c: removed unused cfextension_states
* utils/extconf.c: removed unused cfextension_states

Review: https://reviewboard.asterisk.org/r/4526

ASTERISK-24917
Reported by: dkdegroot
patches:
  rb4526.patch submitted by dkdegroot (License 6600)
........

Merged revisions 433693 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 433694 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433695 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-28 12:56:43 +00:00
Matthew Jordan fd50e5bfb5 clang compiler warnings: Fix -Wbitfield-constant-conversion warning
In chan_iax2, we attempt to assign a -1 to a bitfield. This gets caught by
clang, as it will truncate the -1 to a 1 implicitly.

Instead, we just assign the value a '1'.

Review: https://reviewboard.asterisk.org/r/4537/

ASTERISK-24917
Reported by: dkdegroot
patches:
  rb4537.patch submitted by dkdegroot (License 6600)
........

Merged revisions 433683 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 433684 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433686 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-28 12:33:21 +00:00
Matthew Jordan d6173cd1d0 clang compiler warnings: Fix -Wunused-function; make inline function static
This patch fixes clang compilers warnings for unused functions. Specifically:
 * channels/chan_iax2: removed user_ref function
 * main/dsp.c: removed goertzel_update function
 * main/config.c: made variable_list_switch static

Review: https://reviewboard.asterisk.org/r/4527

ASTERISK-24917
Reported by: dkdegroot
patches:
  rb4527.patch submitted by dkdegroot (License 6600)
........

Merged revisions 433678 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 433680 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433681 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-28 12:20:26 +00:00
Richard Mudgett 4c2fc5b811 chan_pjsip: Add "rpid_immediate" option to prevent unnecessary "180 Ringing" messages.
Incoming PJSIP call legs that have not been answered yet send unnecessary
"180 Ringing" or "183 Progress" messages every time a connected line
update happens.  If the outgoing channel is also PJSIP then the incoming
channel will always send a "180 Ringing" or "183 Progress" message when
the outgoing channel sends the INVITE.

Consequences of these unnecessary messages:

* The caller can start hearing ringback before the far end even gets the
call.

* Many phones tend to grab the first connected line information and refuse
to update the display if it changes.  The first information is not likely
to be correct if the call goes to an endpoint not under the control of the
first Asterisk box.

When connected line first went into Asterisk in v1.8, chan_sip received an
undocumented option "rpid_immediate" that defaults to disabled.  When
enabled, the option immediately passes connected line update information
to the caller in "180 Ringing" or "183 Progress" messages as described
above.

* Added "rpid_immediate" option to prevent unnecessary "180 Ringing" or
"183 Progress" messages.  The default is "no" to disable sending the
unnecessary messages.

ASTERISK-24781 #close
Reported by: Richard Mudgett

Review: https://reviewboard.asterisk.org/r/4473/
........

Merged revisions 433338 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433339 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-24 19:41:36 +00:00
Corey Farrell d486659502 chan_sip: Simplify dialog/peer references, improve REF_DEBUG output.
* Replace functions for ref/undef of dialogs and peers with macro's
  to call ao2_t_bump/ao2_t_cleanup.
* Enable passthough of REF_DEBUG caller information to sip_alloc and
  find_call.

ASTERISK-24882 #close 
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4189/
........

Merged revisions 433115 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433116 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-19 09:57:59 +00:00
Corey Farrell 2c83ac4364 chan_sip: Fix dialog reference leaked to scheduler for reinvite_timeout.
Release the scheduler reference to the dialog for reinvite timeout during
dialog_unlink_all.

ASTERISK-24876 #close 
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4491/
........

Merged revisions 433112 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 433113 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433114 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-19 09:46:06 +00:00
Richard Mudgett 636d82f4d8 chan_pjsip/res_pjsip_callerid: Make Party ID handling simpler and consistent.
The res_pjsip modules were manually checking both name and number
presentation values when there is a function that determines the combined
presentation for a party ID struct.  The function takes into account if
the name or number components are valid while the manual code rarely
checked if the data was even valid.

* Made use ast_party_id_presentation() rather than manually checking party
ID presentation values.

* Ensure that set_id_from_pai() and set_id_from_rpid() will not return
presentation values other than what is pulled out of the SIP headers.  It
is best if the code doesn't assume that AST_PRES_ALLOWED and
AST_PRES_USER_NUMBER_UNSCREENED are zero.

* Fixed copy paste error in add_privacy_params() dealing with RPID
privacy.

* Pulled the id->number.valid test from add_privacy_header() and
add_privacy_params() up into the parent function add_id_headers() to skip
adding PAI/RPID headers earlier.

* Made update_connected_line_information() not send out connected line
updates if the connected line number is invalid.  Lower level code would
not add the party ID information and thus the sent message would be
unnecessary.

* Eliminated RAII_VAR usage in send_direct_media_request().

Review: https://reviewboard.asterisk.org/r/4472/
........

Merged revisions 432892 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432893 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-13 16:37:17 +00:00
Corey Farrell c08fd275bf Logger: Convert 'struct ast_callid' to unsigned int.
Switch logger callid's from AO2 objects to simple integers.
This helps in two ways.  Copying integers is faster than
referencing AO2 objects, so this will result in a small
reduction in logger overhead.  This also erases the possibility
of an infinate loop caused by an invalid callid in
threadstorage.

ASTERISK-24833 #comment Committed callid conversion to trunk. 
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4466/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432834 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-13 01:12:35 +00:00
Richard Mudgett c7cc1b3059 chan_dahdi/sig_analog: Fix distinctive ring detection to suck less.
The distinctive ring feature interferes with detecting Caller ID and
appears to have been broken for years.  What happens is if you have a
ring-ring cadence as used in the UK you get too many DAHDI events for the
distinctive ring pattern array and Caller ID detection is aborted.  I
think when Zapata/DAHDI added the ring begin event it broke distinctive
ring.  More events happen than before and the code does no filtering of
which event times are recorded in the pattern array.

* Made distinctive ring only record the ringt count when the ring ends
instead of on just any DAHDI event.  Distinctive ring can be ring,
ring-ring, ring-ring-ring, or different ring durations for the up to three
rings.

* Fixed the distinctive ring detection enable (chan_dahdi.conf option
usedistinctiveringdetection) to be per port instead of somewhat per port
and somewhat global.  This has been broken since v1.8.

* Fixed using the default distinctive ring context when the detected
pattern does not match any configured dringX patterns.  The default
context did not get set when the previous call was a matched distinctive
ring pattern and the current call is not matched.  This has been broken
since v1.8.

* Made distinctive ring have no effect on Caller ID detection when it is
disabled.  Caller ID detection just monitors for 10 seconds before giving
up.

* Fixed leak of struct callerid_state memory when a polarity reversal
during Caller ID detection causes the incoming call to be aborted.

DAHDI-1143
AST-1545
ASTERISK-24825 #close
Reported by: Richard Mudgett

ASTERISK-17588
Reported by: Daniel Flounders

Review: https://reviewboard.asterisk.org/r/4444/
........

Merged revisions 432530 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432534 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432551 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-06 20:24:58 +00:00
Richard Mudgett f1ab2c5e8b chan_sip: Fix realtime locking inversion when poking a just built peer.
When a realtime peer is built it can cause a locking inversion when the
just built peer is poked.  If the CLI command "sip show channels" is
periodically executed then a deadlock can happen because of the locking
inversion.

* Push the peer poke off onto the scheduler thread to avoid the locking
inversion of the just built realtime peer.

AST-1540
ASTERISK-24838 #close
Reported by: Richard Mudgett

Review: https://reviewboard.asterisk.org/r/4454/
........

Merged revisions 432526 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432528 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432529 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-06 19:34:35 +00:00
Matthew Jordan 8a16c2f0c2 make: Remove 'res_features' from libraries to link against with cygwin/mingw32
Both the apps and channels Makefiles still listed 'res_features' as modules to
link against when compiling for cygwin or mingw32. This module hasn't existed
for quite some time.

ASTERISK-18105 #close
Reported by: feyfre
........

Merged revisions 432341 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432342 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432343 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-26 04:58:38 +00:00
Matthew Jordan 3725173b9e channels/chan_sip: Don't send a BYE after final response when PBX thread fails
When Asterisk fails to start a PBX thread for a new channel - for example, when
the maxcalls setting in asterisk.conf is exceeded - we currently send a final
response, and then attempt to send a BYE request to the UA. Since that's all
sorts of wrong, this patch fixes that by setting sipalreadygone on the sip_pvt
such that we don't get stuck sending BYE requests to something that does not
want it.

Note that this patch is a slight modification of the one on ASTERISK-15434.
For clarity, it explicitly calls sipalreadygone with the calls to transmit a
final response.

ASTERISK-21845
ASTERISK-15434 #close
Reported by: Makoto Dei
Tested by: Matt Jordan
patches:
  sip-pbxstart-failed.patch uploaded by Makoto Dei (License 5027)
........

Merged revisions 432320 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432321 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432322 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-26 03:03:39 +00:00
Matthew Jordan 4b63da7f7d channels/chan_sip: Clarify WARNING message in mismatched SRTP scenario
When we receive an SDP as part of an offer/answer for a peer/friend has been
configured to require encryption, and that SDP offer/answer failed to provide
acceptable crypto attributes, we currently issue a WARNING that uses the phrase
"we" and "requested". In this case, both of those terms are ambiguous - the
user will probably think "we" is Asterisk (it most likely isn't) and it may
not be a "request", so much as an SDP that was received in some fashion.

This patch makes the WARNING messages slightly less bad and a bit more
accurate as well.

ASTERISK-23214 #close
Reported by: Rusty Newton
........

Merged revisions 432277 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432278 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432279 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-25 23:05:40 +00:00
Matthew Jordan 8574c4d197 channels/chan_sip: Fix crash when transmitting packet after thread shutdown
When the monitor thread is stopped, its pthread ID is set to a specific value
(AST_PTHREADT_STOP) so that later portions of the code can determine whether
or not it is safe to manipulate the thread. Unfortunately, __sip_reliable_xmit
failed to check for that value, checking instead only for AST_PTHREAD_STOP.
Passing the invalid yet very specific value to pthread_kill causes a crash.

This patch adds a check for AST_PTHREADT_STOP in __sip_reliable_xmit such that
it doesn't attempt to poke the thread if the thread has already been stopped.

ASTERISK-24800 #close
Reported by: JoshE
........

Merged revisions 432198 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432199 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432200 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-24 22:14:44 +00:00
Matthew Jordan a528dfc9a7 ARI/PJSIP: Apply requesting channel's format cap to created channels
This patch addresses the following problems:
* ari/resource_channels: In ARI, we currently create a format capability
  structure of SLIN and apply it to the new channel being created. This was
  originally done when the PBX core was used to create the channel, as there
  was a condition where a newly created channel could be created without any
  formats. Unfortunately, now that the Dial API is being used, this has two
  drawbacks:
  (a) SLIN, while it will ensure audio will flows, can cause a lot of
      needless transcodings to occur, particularly when a Local channel is
      created to the dialplan. When no format capabilities are available, the
      Dial API handles this better by handing all audio formats to the requsted
      channels. As such, we defer to that API to provide the format
      capabilities.
  (b) If a channel (requester) is causing this channel to be created, we
      currently don't use its format capabilities as we are passing in our own.
      However, the Dial API will use the requester channel's formats if none
      are passed into it, and the requester channel exists and has format
      capabilities. This is the "best" scenario, as it is the most likely to
      create a media path that minimizes transcoding.
  Fixing this simply entails removing the providing of the format capabilities
  structure to the Dial API.

* chan_pjsip: Rather than blindly picking the first format in the format
  capability structure - which actually *can* be a video or text format - we
  select an audio format, and only pick the first format if that fails. That
  minimizes the weird scenario where we attempt to transcode between video/audio.

* res_pjsip_sdp_rtp: Applied the joint capapbilites to the format structure.
  Since ast_request already limits us down to one format capability once the
  format capabilities are passed along, there's no reason to squelch it here.

* channel: Fixed a comment. The reason we have to minimize our requested
  format capabilities down to a single format is due to Asterisk's inability
  to convey the format to be used back "up" a channel chain. Consider the
  following:

    PJSIP/A => L;1 <=> L;2 => PJSIP/B
    g,u,a     g,u,a    g,u,a      u

  That is, we have PJSIP/A dialing a Local channel, where the Local;2 dials
  PJSIP/B. PJSIP/A has native format capabilities g722,ulaw,alaw; the Local
  channel has inherited those format capabilities down the line; PJSIP/B
  supports only ulaw. According to these format capabilities, ulaw is
  acceptable and should be selected across all the channels, and no
  transcoding should occur. However, there is no way to convey this: when L;2
  and PJSIP/B are put into a bridge, we will select ulaw, but that is not
  conveyed to PJSIP/A and L;1. Thus, we end up with:

    PJSIP/A <=> L;1 <=> L;2 <=> PJSIP/B
      g          g   X   u        u

  Which causes g722 to be written to PJSIP/B.

  Even if we can convey the 'ulaw' choice back up the chain (which through
  some severe hacking in Local channels was accomplished), such that the chain
  looks like:

    PJSIP/A <=> L;1 <=> L;2 <=> PJSIP/B
      u          u       u         u

  We have no way to tell PJSIP/A's *channel driver* to Answer in the SDP back
  with only 'ulaw'. This results in all the channel structures being set up
  correctly, but PJSIP/A *still* sending g722 and causing the chain to fall
  apart.

  There's a lot of difficulty just in setting this up, as there are numerous
  race conditions in the act of bridging, and no clean mechanism to pass the
  selected format backwards down an established channel chain. As such, the
  best that can be done at this point in time is clarifying the comment.

Review: https://reviewboard.asterisk.org/r/4434/

ASTERISK-24812 #close
Reported by: Matt Jordan
........

Merged revisions 432195 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432196 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-24 22:00:51 +00:00
Richard Mudgett bb06603d5f chan_dahdi/sig_analog: Put log message strings on one line.
With the log messages on one line, you can search for the log message seen
in the log and expect to find it.
........

Merged revisions 432032 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432034 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432036 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-20 17:55:41 +00:00
Richard Mudgett 05cc6d6d55 chan_dahdi: Remove some dead code.
........

Merged revisions 431992 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 431993 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431994 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-19 21:26:55 +00:00
Corey Farrell a4774ceaa5 Create work around for scheduler leaks during shutdown.
* Added ast_sched_clean_by_callback for cleanup of scheduled events
  that have not yet fired.
* Run all pending peercnt_remove_cb and replace_callno events in chan_iax2.
  Cleanup of replace_callno events is only run 11, since it no longer
  releases any references or allocations in 13+.

ASTERISK-24451 #close
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4425/
........

Merged revisions 431916 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 431917 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431918 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-19 02:03:01 +00:00
Joshua Colp cc96e4a7ef Multiple revisions 431751-431752
........
  r431751 | file | 2015-02-14 14:19:07 -0400 (Sat, 14 Feb 2015) | 5 lines
  
  chan_pjsip: Fix crash when CHANNEL dialplan function is invoked with pjsip argument and no type.
  
  ASTERISK-24771 #close
  Reported by: Niklas Larsson
........
  r431752 | file | 2015-02-14 14:20:27 -0400 (Sat, 14 Feb 2015) | 2 lines
  
  'information' ends with an 'n'.
........

Merged revisions 431751-431752 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431753 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-14 18:21:02 +00:00
Matthew Jordan 29f66b0429 ARI/PJSIP: Add the ability to redirect (transfer) a channel in a Stasis app
This patch adds a new feature to ARI to redirect a channel to another server,
and fixes a few bugs in PJSIP's handling of the Transfer dialplan
application/ARI redirect capability.

*New Feature*
A new operation has been added to the ARI channels resource, redirect. With
this, a channel in a Stasis application can be redirected to another endpoint
of the same underlying channel technology.

*Bug fixes*
In the process of writing this new feature, two bugs were fixed in the PJSIP
stack:
(1) The existing .transfer channel callback had the limitation that it could
    only transfer channels to a SIP URI, i.e., you had to pass
    'PJSIP/sip:foo@my_provider.com' to the dialplan application. While this is
    still supported, it is somewhat unintuitive - particularly in a world full
    of endpoints. As such, we now also support specifying the PJSIP endpoint to
    transfer to.
(2) res_pjsip_multihomed was, unfortunately, trying to 'help' a 302 redirect by
    updating its Contact header. Alas, that resulted in the forwarding
    destination set by the dialplan application/ARI resource/whatever being
    rewritten with very incorrect information. Hence, we now don't bother
    updating an outgoing response if it is a 302. Since this took a looong time
    to find, some additional debug statements have been added to those modules
    that update the Contact headers.

Review: https://reviewboard.asterisk.org/r/4316/

ASTERISK-24015 #close
Reported by: Private Name

ASTERISK-24703 #close
Reported by: Matt Jordan
........

Merged revisions 431717 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431718 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-12 20:34:37 +00:00
Richard Mudgett e2d3215b83 HTTP: Stop accepting requests on final system shutdown.
There are three CLI commands to stop and restart Asterisk each.

1) core stop/restart now - Hangup all calls and stop or restart Asterisk.
New channels are prevented while the shutdown request is pending.

2) core stop/restart gracefully - Stop or restart Asterisk when there are
no calls remaining in the system.  New channels are prevented while the
shutdown request is pending.

3) core stop/restart when convenient - Stop or restart Asterisk when there
are no calls in the system.  New calls are not prevented while the
shutdown request is pending.

ARI has made stopping/restarting Asterisk more problematic.  While a
shutdown request is pending it is desirable to continue to process ARI
HTTP requests for current calls.  To handle the current calls while a
shutdown request is pending, a new committed to shutdown phase is needed
so ARI applications can deal with the calls until the system is fully
committed to shutdown.

* Added a new shutdown committed phase so ARI applications can deal with
calls until the final committed to shutdown phase is reached.

* Made refuse new HTTP requests when the system has reached the final
system shutdown phase.  Starting anything while the system is actively
releasing resources and unloading modules is not a good thing.

* Split the bridging framework shutdown to not cleanup the global bridging
containers when shutting down in a hurry.  This is similar to how other
modules prevent crashes on rapid system shutdown.

* Moved ast_begin_shutdown(), ast_cancel_shutdown(), and
ast_shutting_down().  You should not have to include channel.h just to
access these system functions.

ASTERISK-24752 #close
Reported by: Matthew Jordan

Review: https://reviewboard.asterisk.org/r/4399/
........

Merged revisions 431692 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431694 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-11 17:39:13 +00:00
Matthew Jordan 5a17ed7a38 channels/chan_sip: Fix RealTime error during SIP unregistration with MariaDB
When a SIP device that has its registration stored in RealTime unregisters,
the entry for that device is updated with blank values, i.e., "", indicating
that it is no longer registered. Unfortunately, one of those values that is
'blanked' is the device's port. If the column type for the port is not a
string datatype (the recommended type is integer), an ODBC or database error
will be thrown. MariaDB does not coerce empty strings to a valid integer value.

This patch updates the query run from chan_sip such that it replaces the port
value with a value of '0', as opposed to a blank value. This is the value that
other database backends coerce the empty string ("") to already, and the
handling of reading a RealTime registration value from a backend already
anticipates receiving a port of '0' from the backends.

ASTERISK-24772 #close
Reported by: Richard Miller
patches:
  chan_sip.diff uploaded by Richard Miller (License 5685)
........

Merged revisions 431673 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 431674 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431675 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-11 17:13:28 +00:00
Mark Michelson bd0bdf1e41 Fix some memory leaks.
These memory leaks were found and fixed by John Hardin. I'm just
committing them for him.

ASTERISK-24736 #close
Reported by Mark Michelson

Review: https://reviewboard.asterisk.org/r/4389
........

Merged revisions 431468 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431469 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-30 16:49:59 +00:00
Mark Michelson fe76d4829f Use SIPS URIs in Contact headers when appropriate.
RFC 3261 sections 8.1.1.8 and 12.1.1 dictate specific
scenarios when we are required to use SIPS URIs in Contact
headers. Asterisk's non-compliance with this could actually
cause calls to get dropped when communicating with clients
that are strict about checking the Contact header.

Both of the SIP stacks in Asterisk suffered from this issue.
This changeset corrects the behavior in chan_sip.

ASTERISK-24646 #close
Reported by Stephan Eisvogel

Review: https://reviewboard.asterisk.org/r/4346
........

Merged revisions 431423 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 431424 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431425 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-29 20:54:46 +00:00
Kevin Harwell 3b0f03ef7b chan_sip: stale nonce causes failure
When refreshing (with a small expiration) a registration that was sent to
chan_sip the nonce would be considered stale and reject the registration.
What was happening was that the initial registration's "dialog" still existed
in the dialogs container and upon refresh the dialog match algorithm would
choose that as the "dialog" instead of the newly created one. This occurred
because the algorithm did not check to see if the from tag matched if
authentication info was available after the 401. So, it ended up assuming
the original "dialog" was a match and stopped the search. The old "dialog"
of course had an old nonce, thus the stale nonce message.

This fix attempts to leave the original functionality alone except in the case
of a REGISTER. If a REGISTER is received if searches for an existing "dialog"
matching only on the callid. If the expires value is low enough it will reuse
dialog that is there, otherwise it will create a new one.

ASTERISK-24715 #close
Reported by: John Bigelow
Review: https://reviewboard.asterisk.org/r/4367/
........

Merged revisions 431187 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 431194 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431197 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-27 19:22:41 +00:00