Commit Graph

150 Commits

Author SHA1 Message Date
Jonathan Rose b90bba7a30 Stasis: Update security events to use Stasis
Also moves ACL messages to the security topic and gets rid of the
ACL topic

(closes issue ASTERISK-21103)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2496/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@388975 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-05-17 17:36:10 +00:00
David M. Lee e06e519a90 Initial support for endpoints.
An endpoint is an external device/system that may offer/accept
channels to/from Asterisk. While this is a very useful concept for end
users, it is surprisingly not a core concept within Asterisk itself.

This patch defines ast_endpoint as a separate object, which channel
drivers may use to expose their concept of an endpoint. As the channel
driver creates channels, it can use ast_endpoint_add_channel() to
associate channels to the endpoint. This updated the endpoint
appropriately, and forwards all of the channel's events to the
endpoint's topic.

In order to avoid excessive locking on the endpoint object itself, the
mutable state is not accessible via getters. Instead, you can create a
snapshot using ast_endpoint_snapshot_create() to get a consistent
snapshot of the internal state.

This patch also includes a set of topics and messages associated with
endpoints, and implementations of the endpoint-related RESTful
API. chan_sip was updated to create endpoints with SIP peers, but the
state of the endpoints is not updated with the state of the peer.

Along for the ride in this patch is a Stasis test API. This is a
stasis_message_sink object, which can be subscribed to a Stasis
topic. It has functions for blocking while waiting for conditions in
the message sink to be fulfilled.

(closes issue ASTERISK-21421)
Review: https://reviewboard.asterisk.org/r/2492/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@387932 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-05-08 13:39:08 +00:00
Alec L Davis f7f58b7bc2 chan_sip: Session-Expires: Set timer to correctly expire at (~2/3) of the interval when not the refresher
RFC 4028 Section 10
	if the side not performing refreshes does not receive a
	session refresh request before the session expiration, it SHOULD send
	a BYE to terminate the session, slightly before the session
	expiration.  The minimum of 32 seconds and one third of the session
	interval is RECOMMENDED.

Prior to this asterisk would refresh at 1/2 the Session-Expires interval,
or if the remote device was the refresher, asterisk would timeout at interval end.

Now, when not refresher, timeout as per RFC noted above.

(closes issue ASTERISK-21742)

Reported by: alecdavis
Tested by: alecdavis
alecdavis (license 585)

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

Merged revisions 387344 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@387369 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-05-02 08:24:31 +00:00
Matthew Jordan 0ffce56f1b AST-2013-003: Prevent username disclosure in SIP channel driver
When authenticating a SIP request with alwaysauthreject enabled, allowguest
disabled, and autocreatepeer disabled, Asterisk discloses whether a user
exists for INVITE, SUBSCRIBE, and REGISTER transactions in multiple ways. The
information is disclosed when:
 * A "407 Proxy Authentication Required" response is sent instead of a
   "401 Unauthorized" response
 * The presence or absence of additional tags occurs at the end of "403
   Forbidden" (such as "(Bad Auth)")
 * A "401 Unauthorized" response is sent instead of "403 Forbidden" response
   after a retransmission
 * Retransmission are sent when a matching peer did not exist, but not when a
   matching peer did exist.

This patch resolves these various vectors by ensuring that the responses sent
in all scenarios is the same, regardless of the presence of a matching peer.

This issue was reported by Walter Doekes, OSSO B.V. A substantial portion of
the testing and the solution to this problem was done by Walter as well - a
huge thanks to his tireless efforts in finding all the ways in which this
setting didn't work, providing automated tests, and working with Kinsey on
getting this fixed.

(closes issue ASTERISK-21013)
Reported by: wdoekes
Tested by: wdoekes, kmoore
patches:
  AST-2013-003-1.8 uploaded by kmoore, wdoekes (License 6273, 5674)
  AST-2013-003-10 uploaded by kmoore, wdoekes (License 6273, 5674)
  AST-2013-003-11 uploaded by kmoore, wdoekes (License 6273, 5674)
........

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@384019 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-03-27 15:27:31 +00:00
Kinsey Moore 99aa02d17f Transition MWI to Stasis-core
Remove MWI's dependency on the event system by moving it to
Stasis-core. This also introduces forwarding topic pools in Stasis-core
which aggregate many dynamically allocated topics into a single primary
topic.

Review: https://reviewboard.asterisk.org/r/2368/
(closes issue ASTERISK-21097)
Patch-by: Kinsey Moore


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@383284 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-03-16 15:45:58 +00:00
Kevin Harwell 09ecb25e08 Added an option to disallow music on hold
Added an option "discard_remote_hold_retrieval" (default "no") that if set does
not trigger the music on hold event.  This essentially stops telling the peer
to start music on hold.

(issue ABE-2899)
Reported by: Denis Alberto Martinez
Review: https://reviewboard.asterisk.org/r/2336/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@382787 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-03-11 15:22:02 +00:00
Matthew Jordan 8d5c36c9bb Add RFC 3327 Path header support to chan_sip
This patch adds support for RFC 3327 "Path" headers. This can be enabled in
sip.conf using the 'supportpath' setting, either on a global basis or on a
peer basis. This setting enables Asterisk to route outgoing out-of-dialog
requests via a set of proxies by using a pre-loaded route-set defined by the
Path headers in the REGISTER request. This patch also adds Realtime support
for dynamically updating the Path information for a peer.

A huge thank-you to Klaus Darillion and Olle E Johansson for their efforts
in writing this patch.

Review: https://reviewboard.asterisk.org/r/2235/
Review: https://reviewboard.asterisk.org/r/991/

(closes issue ASTERISK-16884)
Reported by: klaus3000
Tested by: klaus3000, oej, mjordan
patches:
  path-1.8.0-patch.txt uploaded by klaus3000 (License 5054)
  oolong-path-support-trunk in team branch by oej (License 5267)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@382440 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-03-05 13:14:43 +00:00
Kinsey Moore 81fa307af7 Fix some more REF_DEBUG-related build errors
When sip_ref_peer and sip_unref_peer were exported to be usable in
channels/sip/security_events.c, modifications to those functions when
building under REF_DEBUG were not taken into account. This change
moves the necessary defines into sip.h to make them accessible to
other parts of chan_sip that need them.
........

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@381285 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-02-12 20:18:21 +00:00
David M. Lee e06cd59e04 Corrected crypto tag in SDP ANSWER for SRTP. (again)
The original fix (r380043) for getting Asterisk to respond with the correct
tag overlooked some corner cases, and the fact that the same code is in 1.8.

This patch moves the building of the crypto line out of
sdp_crypto_process(). Instead, it merely copies the accepted tag. The call to
sdp_crypto_offer() will build the crypto line in all cases now, using a tag of
"1" in the case of sending offers.

(closes issue ASTERISK-20849)
Reported by: José Luis Millán
Review: https://reviewboard.asterisk.org/r/2295/
........

Merged revisions 380347 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@380383 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-29 17:46:30 +00:00
David M. Lee 14a9fb761b Corrected crypto tag in SDP ANSWER for SRTP.
When Asterisk responds with an SDP ANSWER for SRTP, it had the code to
correctly fill in the crypto data, which was overwritten by a call to
sdp_crypto_offer. Corrected the situation by changing sdp_crypto_offer
to not replacing crypto data if it already exists.

(closes issue ASTERISK-20849)
Reported by: José Luis Millán
Tested by: Iñaki Baz Castillo
Patches:
	fix_sdp_crypto_tags.diff uploaded by Pedro Kiefer (license 6407)
........

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@380044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-24 16:40:42 +00:00
David M. Lee be727bf0d2 Fix Record-Route parsing for large headers.
Record-Route parsing copied the header into a char[256] array, which can
be a problem if the header is longer than that. This patch parses the
header in place, without the copy, avoiding the issue.

In addition to the original patch, I added a unit test for the new
get_in_brackets_const function.

(closes issue ASTERISK-20837)
Reported by: Corey Farrell
Patches:
	chan_sip-build_route-optimized-rev1.patch uploaded by Corey Farrell (license 5909)
	(with minor changes by dlee)
........

Merged revisions 379392 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@379394 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-18 05:31:23 +00:00
Matthew Jordan 1fb06fde95 Resolve crashes due to large stack allocations when using TCP
Asterisk had several places where messages received over various network
transports may be copied in a single stack allocation. In the case of TCP,
since multiple packets in a stream may be concatenated together, this can
lead to large allocations that overflow the stack.

This patch modifies those portions of Asterisk using TCP to either
favor heap allocations or use an upper bound to ensure that the stack will not
overflow:
 * For SIP, the allocation now has an upper limit
 * For HTTP, the allocation is now a heap allocation instead of a stack
   allocation
 * For XMPP (in res_jabber), the allocation has been eliminated since it was
   unnecesary.

Note that the HTTP portion of this issue was independently found by Brandon
Edwards of Exodus Intelligence.

(issue ASTERISK-20658)
Reported by: wdoekes, Brandon Edwards
Tested by: mmichelson, wdoekes
patches:
  ASTERISK-20658_res_jabber.c.patch uploaded by mmichelson (license 5049)
  issueA20658_http_postvars_use_malloc2.patch uploaded by wdoekes (license 5674)
  issueA20658_limit_sip_packet_size3.patch uploaded by wdoekes (license 5674)
........

Merged revisions 378269 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 378286 from http://svn.asterisk.org/svn/asterisk/branches/10
........

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@378288 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-02 15:39:42 +00:00
Brent Eagles ab894d5af9 This change adds a SIP peer configuration feature to allow the peer's
configured codecs to take precedence on an outgoing call.

This change introduces a new peer configuration property named
'ignore_requested_pref' that causes the requested codec to be ignored when
determining the preferred codec for an outgoing call leg. The consequence is
that Asterisk's usual efforts to prefer avoiding transcoding can be overridden
on a peer-by-peer basis where appropriate. 


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@377971 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-13 15:22:27 +00:00
Mark Michelson b37ab7e673 Add "Require: timer" to 200 OK responses when appropriate.
The method by which the Require header is added to 200 responses is
inspired by the method that Olle Johansson uses in his darjeeling-prack
branch.

(closes issue ASTERISK-20570)
Reported by Matt Jordan, at the behest of Olle Johansson

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

Merged revisions 376521 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 376522 from http://svn.asterisk.org/svn/asterisk/branches/10
........

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@376551 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-11-20 19:09:37 +00:00
Terry Wilson b7233b18eb Properly handle UAC/UAS roles for SIP session timers
The SIP session timer mechanism contains a mandatory 'refresher' parameter
(included in the Session-Expires header) which is used in the session timer
offer/answer signaling within a SIP Invite dialog. It looks like asterisk is
interpreting the uac resp. uas role only as the initial role of client and
server (caller is uac, callee is uas). The standard rfc 4028 however assigns
the client role to the ((RE)-Invite) requester, the server role to the
((RE)-Invite) responder.

This patch has Asterisk track the actual refresher as "us" or "them" as opposed
to relying on just the configured "uas" or "uac" properties.

(closes issue AST-922)
Reported by: Thomas Airmont

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

Merged revisions 373652 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 373665 from http://svn.asterisk.org/svn/asterisk/branches/10
........

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@373691 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-09-25 19:08:02 +00:00
Andrew Latham 6f61cb50c5 Doxygen Updates - janitor work
Doxygen updates including mistakes, misspellings, missing parameters, updates for Doxygen style.  Some missing txt file links are removed but their content or essense will be included in some later updates.  A majority of the txt files were removed in the 1.6 era but never noted. The HR and EXTREF are simple changes that make the documentation more compatable with more versions of Doxygen.

Further updates coming.

(issue ASTERISK-20259)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@373330 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-09-21 17:14:59 +00:00
Joshua Colp e8380afc8a Add support for DTLS-SRTP to res_rtp_asterisk and chan_sip.
As mentioned on the review for this, WebRTC has moved towards choosing
DTLS-SRTP as the mechanism for key exchange for SRTP. This commit adds
support for this but makes it available for normal SIP clients as well.

Testing has been done to ensure that this introduces no regressions with
existing behavior and also that it functions as expected.

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

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@373234 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-09-20 18:27:28 +00:00
Matthew Jordan ae179ac5b4 Only re-create an SRTP session when needed
In r356604, SRTP handling was fixed to accomodate multiple crypto keys in an
SDP offer and the ability to re-create an SRTP session when the crypto keys
changed.  In certain circumstances - most notably when a phone is put on
hold after having been bridged for a significant amount of time - the act
of re-creating the SRTP session causes problems for certain models of phones.
The patch committed in r356604 always re-created the SRTP session regardless
of whether or not the cryptographic keys changed.  Since this is technically
not necessary, this patch modifies the behavior to only re-create the SRTP
session if Asterisk detects that the remote key has changed.  This allows
models of phones that do not handle the SRTP session changing to continue
to work, while also providing the behavior needed for those phones that do
re-negotiate cryptographic keys.

(issue ASTERISK-20194)
Reported by: Nicolo Mazzon
Tested by: Nicolo Mazzon

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

Merged revisions 372709 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 372710 from http://svn.asterisk.org/svn/asterisk/branches/10
........

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@372712 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-09-09 01:28:31 +00:00
Matthew Jordan 8018b879a2 Clean up doxygen warnings
This patch fixes numerous doxygen warnings across Asterisk.  It also updates
the makefile to regenerate the doxygen configuration on the local system
before running doxygen to help prevent warnings/errors on the local system.

Much thanks to Andrew for tackling one of the Asterisk janitor projects!

(issue ASTERISK-20259)
Reported by: Andrew Latham
Patches:
  doxygen_partial.diff uploaded by Andrew Latham (license 5985)
  make_progdocs.diff uploaded by Andrew Latham (license 5985)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@371989 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-08-30 14:23:28 +00:00
Mark Michelson 9ee8b3c0f6 Extend extension state callbacks to have more information.
Quote from review board:

This patch extends the extension state callbacks so that monitoring channels
(as chan_sip) get more information of the devices which are responsible for
an extension state change. The additional information is needed by chan_sip
to present names/numbers of the caller and callee in an early-state SIP
notification. Users of extenstion state callback not interested in the
additional information are not affected by the changes.

Motivation: to present the involved party's name/number in an early-state
nofification (used by the notified device as a pickup offer) one after another
so that a user can see which call he will pick up in an undirected pickup.
Such a pickup offer to a user shall indicate the same call (number/name-A calls
number/name-B) as the call which would be picked up when an undirected pickup
is executed.


Users interested in additional state info must use the new functions
ast_extension_state_add_extended() resp.
ast_extension_state_add_destroy_extended() to register an extended state
callback. When the callback is registered this way, an extra member
device_state_info of struct ast_state_cb_info is passed to the callback in
addition to the aggregated extension state. This container holds an object for
every device of the monitored extension hint consisting of the device name, the
device state and a channel reference to the channel which (presumably) caused
the device state.

The information is used by chan_sip for early-state notifications. When the
state of a device changes and the new state contains AST_EVENT_RINGING, an
early-state notification is sent to the subscribed devices with the
caller/callee names/numbers of the oldest ringing channel of the monitored
extension. The notified user may then invoke a direct pickup, which will pickup
exactly this channel.

Users of the old non-extended callbacks will only be called when the aggregated
state did change (same behavior as before). Users of the extended callback will
also be called when the state is unchanged but does contain AST_EVENT_RINGING.
That could be the case if two channels are ringing at one device and one of
them hangs up, so the aggregated state does not change. This way the monitoring
channel can create a new early-state notification with the now ringing
party-ids.

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

This contribution comes from Guenther Kelleter



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370979 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-08-09 14:52:16 +00:00
Matthew Jordan 5c4578f4ad Add named callgroups/pickupgroups
This patch adds named calledgroups/pickupgroups to Asterisk.  Named groups are
implemented in parallel to the existing numbered callgroup/pickupgroup
implementation.  However, unlike the existing implementation, which is limited
to a maximum of 64 defined groups, the number of defined groups allowed for
named callgroups/pickupgroups is effectively unlimited.

Named groups are configured with the keywords "namedcallgroup" and
"namedpickupgroup".  This corresponds to the numbered group definitions of
"callgroup" and "pickupgroup".  Note that as the implementation of named groups
coexists with the existing numbered implementation, a defined named group of
"4" does not equate to numbered group 4.

Support for the named groups has been added to the SIP, DAHDI, and mISDN channel
drivers.

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

Uploaded by:
	Guenther Kelleter(license #6372)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370831 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-08-07 12:46:36 +00:00
Mark Michelson 9f0127f087 Multiple revisions 370769-370771
........
  r370769 | mmichelson | 2012-08-03 16:35:00 -0500 (Fri, 03 Aug 2012) | 24 lines
  
  Fix error in the "IPorHost" section of a SIP dialstring.
  
  This is based on the review request posted by Walter Doekes
  (referenced lower in the commit message)
  
  The main fix here is to treat the IPorHost portion of the dial
  string as a temporary outbound proxy. This ensures requests
  get sent to the proper location.
  
  Due to the age of the request, some parts were no longer relevant.
  For instance, the request moved outbound proxy parsing code into
  a single method. This is done in a previous commit, so it was not
  necessary to do again.
  
  Also, the review request fixed some errors with regards to request
  routing for CANCEL and ACK requests. This has also been fixed in
  more recent commits.
  
  (closes issue ASTERISK-19677)
  reported by Walter Doekes
  
  Review https://reviewboard.asterisk.org/r/1859
........
  r370770 | mmichelson | 2012-08-03 16:39:35 -0500 (Fri, 03 Aug 2012) | 3 lines
  
  Remove unused variable.
........
  r370771 | mmichelson | 2012-08-03 16:43:52 -0500 (Fri, 03 Aug 2012) | 5 lines
  
  Seriously? Another compilation error fixed.
  
  Somebody beat me.
........

Merged revisions 370769-370771 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 370772 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370773 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-08-03 21:52:57 +00:00
Mark Michelson 4377d511ae Add headers from SIPAddHeader to outbound REFER requests.
This is a patch from kkm from review board.

This is useful for adding headers to REFER requests that
emanate from a Transfer() dialplan application call.

This also fixes some uses of the Referred-by header, removing
an extra set of angle brackets.

I've modified the reporter's original patch to not require
any additions to the sip_refer header and to just remove the
referred_by_name from sip_refer since it is no longer needed
or used.

(closes Issue ASTERISK-17639)
reported by Kirill Katsnelson
Patches:
	019059-sip-refer-addheaders-trunk-353549.diff
	uploaded by Kirill Katsnelson (license #5845)

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



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370691 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-31 22:28:16 +00:00
Kinsey Moore e5210366e4 Clean up chan_sip
This clean up was broken out from
https://reviewboard.asterisk.org/r/1976/ and addresses the following:
 - struct sip_refer converted to use the stringfields API.
 - sip_{refer|notify}_allocate -> sip_{notify|refer}_alloc to match
   other *alloc functions.
 - Replace get_msg_text, get_msg_text2 and get_pidf_body -> No, not
   get_pidf_msg_text_body3 but get_content, to match add_content.
 - get_body doesn't get the request body, renamed to get_content_line.
 - get_body_by_line doesn't get the body line, and is just a simple if
   test. Moved code inline and removed function.
 - Remove camelCase in struct sip_peer peer state variables,
   onHold -> onhold, inUse -> inuse, inRinging -> ringing.
 - Remove camelCase in struct sip_request rlPart1 -> rlpart1,
   rlPart2 -> rlpart2.
 - Rename instances of pvt->randdata to pvt->nonce because that is what
   it is, no need to update struct sip_pvt because _it already has a
   nonce field_.
 - Removed struct sip_pvt randdata stringfield.
 - Remove useless (and inconsistent) 'header' suffix on variables in
   handle_request_subscribe.
 - Use ast_strdupa on Event header in handle_request_subscribe to avoid
   overly complicated strncmp calls to find the event package.
 - Move get_destination check in handle_request_subscribe to avoid
   duplicate checking for packages that don't need it.
 - Move extension state callback management in handle_request_subscribe
   to avoid duplicate checking for packages that don't need it.
 - Remove duplicate append_date prototype.
 - Rename append_date -> add_date to match other add_xxx functions.
 - Added add_expires helper function, removed code that manually added
   expires header.
 - Remove _header suffix on add_diversion_header (no other header adding
   functions have this).
 - Don't pass req->debug to request handle_request_XXXXX handlers if req
   is also being passed.
 - Don't pass req->ignore to check_auth as req is already being passed.
 - Don't create a subscription in handle_request_subscribe if
   p->expiry == 0.
 - Don't walk of the back of referred_by_name when splitting string in
   get_refer_info
 - Remove duplicate check for no dialog in handle_incoming when
   sipmethod == SIP_REFER, handle_request_refer checks for that.

Review: https://reviewboard.asterisk.org/r/1993/
Patch-by: gareth


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370636 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-31 19:10:41 +00:00
Joshua Colp 4d6b524b61 Prevent multiple local candidates from being added with the same information and add support for disabling ICE on a per-peer basis.
(closes issue ASTERISK-20088)
Reported by: wimpy

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370347 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-22 17:03:24 +00:00
Joshua Colp e938737570 Add support for SIP over WebSocket.
This allows SIP traffic to be exchanged over a WebSocket connection which is useful for rtcweb.

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370072 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-16 12:35:04 +00:00
Jonathan Rose 10afdf3a2a Named ACLs: Introduces a system for creating and sharing ACLs
This patch adds Named ACL functionality to Asterisk. This allows system
administrators to define an ACL and refer to it by a unique name. Configurable
items can then refer to that name when specifying access control lists.
It also includes updates to all core supported consumers of ACLs. That includes
manager, chan_sip, and chan_iax2. This feature is based on the deluxepine-trunk
by Olle E. Johansson and provides a subset of the Named ACL functionality
implemented in that branch. For more information on this feature, see acl.conf
and/or the Asterisk wiki.

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369959 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-11 18:33:36 +00:00
Terry Wilson d97e6c1401 Better handle re-INVITEs with provisional but no final repsonses
A previous attempt at fixing this issue had negative side effects related
to attended transfers which this patch should resolve. Many thanks to
Steve Davies for all of the good suggestions and testing.

(closes issue ASTERISK-19992)
Reported by: Steve Davies
Tested by: Steve Davies, Terry Wilson
Review: https://reviewboard.asterisk.org/r/2009/
........

Merged revisions 369557 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 369558 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369559 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-03 14:49:19 +00:00
Terry Wilson 7d9e0158c3 AST-2012-010: Clean up after a reinvite that never gets a final response
The basic problem is that if a re-INVITE is sent by Asterisk and it receives a
provisional response, but no final response, then the dialog is never torn
down. In addition to leaking memory, this also leaks file descriptors and will
eventually lead to Asterisk no longer being able to process calls.

This patch just keeps track of whether there is an outstanding re-INVITE, and if
there is goes ahead and cleans up everything as though there was no outstanding
reinvite.

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

(closes issue ASTERISK-19992)
Reported by: Steve Davies
Tested by: Steve Davies, Terry Wilson
........

Merged revisions 369436 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 369437 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369449 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-27 21:21:27 +00:00
Mark Michelson e0883154cf Re-fix how local tag is generated when sending a 481 to an INVITE.
Match our local tag to whatever to-tag was sent in the initial INVITE.
Because the size of the to-tag may not fit in the buffer in the sip_pvt,
it has been changed to a string field.

(closes issue ASTERISK-19892)
reported by Walter Doekes

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

Merged revisions 369352 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 369353 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369367 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-25 19:26:31 +00:00
Kinsey Moore bf6ef69702 Allow chan_sip to decline unwanted media streams
This change replaces the static array of four representable media
streams with an AST_LIST so that chan_sip can keep track of offered
media streams.  This allows chan_sip to deal with offers containing
multiple same-type streams and many other situations without rejecting
the SDP offer in its entirety, yet still generating a valid response.
This also covers cases where Asterisk can not comprehend the offer if
it is in the correct format.

Previously, chan_sip would reject SDP offers or entirely ignore
individual stream offers in an effort to be more compatible which
would often result in invalid SDP responses.

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369028 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-15 17:13:20 +00:00
Kevin P. Fleming 166b4e2b30 Multiple revisions 369001-369002
........
  r369001 | kpfleming | 2012-06-15 10:56:08 -0500 (Fri, 15 Jun 2012) | 11 lines
  
  Add support-level indications to many more source files.
  
  Since we now have tools that scan through the source tree looking for files
  with specific support levels, we need to ensure that every file that is
  a component of a 'core' or 'extended' module (or the main Asterisk binary)
  is explicitly marked with its support level. This patch adds support-level
  indications to many more source files in tree, but avoids adding them to
  third-party libraries that are included in the tree and to source files
  that don't end up involved in Asterisk itself.
........
  r369002 | kpfleming | 2012-06-15 10:57:14 -0500 (Fri, 15 Jun 2012) | 3 lines
  
  Add a script to enable finding source files without support-levels defined.
........

Merged revisions 369001-369002 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 369005 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369013 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-15 16:20:16 +00:00
Kinsey Moore c6142cf2cc Fix coverity UNUSED_VALUE findings in core support level files
Most of these were just saving returned values without using them and
in some cases the variable being saved to could be removed as well.

(issue ASTERISK-19672)
........

Merged revisions 368738 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 368739 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368751 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-11 15:23:30 +00:00
Mark Michelson 14a985560e Merge changes dealing with support for Digium phones.
Presence support has been added. This is accomplished by
allowing for presence hints in addition to device state
hints. A dialplan function called PRESENCE_STATE has been
added to allow for setting and reading presence. Presence
can be transmitted to Digium phones using custom XML
elements in a PIDF presence document.

Voicemail has new APIs that allow for moving, removing,
forwarding, and playing messages. Messages have had a new
unique message ID added to them so that the APIs will work
reliably. The state of a voicemail mailbox can be obtained
using an API that allows one to get a snapshot of the mailbox.
A voicemail Dialplan App called VoiceMailPlayMsg has been
added to be able to play back a specific message.

Configuration hooks have been added. Configuration hooks
allow for a piece of code to be executed when a specific
configuration file is loaded by a specific module. This is
useful for modules that are dependent on the configuration
of other modules.

chan_sip now has a public method that allows for a custom
SIP INFO request to be sent mid-dialog. Digium phones use
this in order to display progress bars when files are played.

Messaging support has been expanded a bit. The main
visible difference is the addition of an AMI action
MessageSend.

Finally, a ParkingLots manager action has been added in order
to get a list of parking lots.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368435 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-04 20:26:12 +00:00
Mark Michelson 463f9d729a Help mitigate potential reinvite glare scenarios.
When Asterisk servers are set up back-to-back, and
direct media is to be used betweeen endpoints, it is
fairly common for the two Asterisk servers to send
direct media reinvites to each other simultaneously.
This results in 491s and ACKs being exchanged between
the servers. While the media eventually gets set up
properly, the problem is that there can be a noticeable
delay for the streams to stabilize.

This patch adds a new directmedia option called "outgoing".
With this set, an immediate direct media reinvite will only
be sent if the call direction is outgoing. For incoming
dialogs, an immediate direct media reinvite will not be sent,
but further "reactionary" direct media reinvites may be sent.

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



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368143 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-01 13:04:32 +00:00
Matthew Jordan f454dceaf3 Re-add LastMsgsSent value for SIP peers
Previously, MWI logic utilized a counter called 'lastmsgssent' to know whether
or not MWI NOTIFY requests had been sent to a specific peer.  When MWI
notifications were changed to use the internal event framework, this value was
no longer needed for its original purpose.  Hence, it was no longer updated
with the new/old message counts for a peer.  The value was previously removed
for Asterisk 10; however, since it was still present in Asterisk 1.8 and still
useful for reporting purposes, it was decided to re-add the value.

This patch re-adds the 'LastMsgsSent' field in the response to an AMI/CLI 'sip
show peer [peer]' command, and makes it so that the value of lastmsgssent is
updated appropriately. The value should now display the new/old message counts
for a particular peer.

(closes issue ASTERISK-17866)
Reported by: Steve Davies
patches by:
  ast-17866-rb1272.patch (License #5041 by irroot)
  Modified slightly for this commit

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

Merged revisions 367362 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 367369 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@367376 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-05-23 13:46:38 +00:00
Matthew Jordan 7b51320642 Fix a variety of memory leaks
This patch addresses a number of memory leaks in a variety of modules that were
found by a static analysis tool.  A brief summary of the changes:

* app_minivm:       free ast_str objects on off nominal paths
* app_page:         free the ast_dial object if the requested channel technology
                    cannot be appended to the dialing structure
* app_queue:        if a penalty rule failed to match any existing rule list
                    names, the created rule would not be inserted and its memory
                    would be leaked
* app_read:         dispose of the created silence detector in the presence of
                    off nominal circumstances
* app_voicemail:    dispose of an allocated unique ID field for MWI event
                    un-subscribe requests in off nominal paths; dispose of
                    configuration objects when using the secret.conf option
* chan_dahdi:       dispose of the allocated frame produced by ast_dsp_process
* chan_iax2:        properly unref peer in CLI command "iax2 unregister"
* chan_sip:         dispose of the allocated frame produced by sip_rtp_read's
                    call of ast_dsp_process; free memory in parse unit tests
* func_dialgroup:   properly deref ao2 object grhead in nominal path of
                    dialgroup_read
* func_odbc:        free resultset in off nominal paths of odbc_read
* cli:              free match_list in off nominal paths of CLI match completion
* config:           free comment_buffer/list_buffer when configuration file load
                    is unchanged; free the same buffers any time they were
                    created and config files were processed
* data:             free XML nodes in various places
* enum:             free context buffer in off nominal paths
* features:         free ast_call_feature in off nominal paths of applicationmap
                    config processing
* netsock2:         users of ast_sockaddr_resolve pass in an ast_sockaddr struct
                    that is allocated by the method.  Failures in
                    ast_sockaddr_resolve could result in the users of the method
                    not knowing whether or not the buffer was allocated.  The
                    method will now not allocate the ast_sockaddr struct if it
                    will return failure.
* pbx:              cleanup hash table traversals in off nominal paths; free
                    ignore pattern buffer if it already exists for the specified
                    context
* xmldoc:           cleanup various nodes when we no longer need them
* main/editline:    various cleanup of pointers not being freed before being
                    assigned to other memory, cleanup along off nominal paths
* menuselect/mxml:  cleanup of value buffer for an attribute when that attribute
                    did not specify a value
* res_calendar*:    responses are allocated via the various *_request method
                    returns and should not be allocated in the various
                    write_event methods; ensure attendee buffer is freed if no
                    data exists in the parsed node; ensure that calendar objects
                    are de-ref'd appropriately
* res_jabber:       free buffer in off nominal path
* res_musiconhold:  close the DIR* object in off nominal paths
* res_rtp_asterisk: if we run out of ports, close the rtp socket object and free
                    the rtp object
* res_srtp:         if we fail to create the session in libsrtp, destroy the
                    temporary ast_srtp object

(issue ASTERISK-19665)
Reported by: Matt Jordan

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

Merged revisions 366880 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 366881 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@366917 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-05-18 14:43:44 +00:00
Jonathan Rose 6fc8e9928d chan_sip: Fix a small TEST_FRAMEWORK related error that prevents compiling
Introduced with r366842, a function call made only with TEST_FRAMEWORK enabled
was missing an argument since the function arguments were changed.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@366896 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-05-18 14:27:01 +00:00
Kinsey Moore 54268bca4a Reorder and renumber tests appropriately
It appears that a patch did not apply properly when adding tests 12 and
13 and test 11 was duplicated.  These tests have been reordered and
renumbered such that they make sense.
........

Merged revisions 366882 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 366884 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@366888 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-05-18 14:21:37 +00:00
Jonathan Rose cd37bec058 logger: Adds additional support for call id logging and chan_sip specific stuff
This patch improves the handling of call id logging significantly with regard
to transfers and adding APIs to better handle specific aspects of logging.
Also, changes have been made to chan_sip in order to better handle the creation
of callids and to enable the monitor thread to bind itself to a particular
call id when a dialog is determined to be related to a callid. It then unbinds
itself before returning to normal monitoring.

review: https://reviewboard.asterisk.org/r/1886/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@366842 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-05-17 16:28:20 +00:00
Kinsey Moore dd81b047db Resolve FORWARD_NULL static analysis warnings
This resolves core findings from ASTERISK-19650 numbers 0-2, 6, 7, 9-11, 14-20,
22-24, 28, 30-32, 34-36, 42-56, 82-84, 87, 89-90, 93-102, 104, 105, 109-111,
and 115. Finding numbers 26, 33, and 29 were already resolved.  Those skipped
were either extended/deprecated or in areas of code that shouldn't be
disturbed.

(Closes issue ASTERISK-19650)
........

Merged revisions 366167 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 366168 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@366169 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-05-10 20:56:09 +00:00
Kinsey Moore 781f4657b9 Fix many issues from the NULL_RETURNS Coverity report
Most of the changes here are trivial NULL checks.  There are a couple
optimizations to remove the need to check for NULL and outboundproxy parsing
in chan_sip.c was rewritten to avoid use of strtok.  Additionally, a bug was
found and fixed with the parsing of outboundproxy when "outboundproxy=," was
set.

(Closes issue ASTERISK-19654)
........

Merged revisions 365398 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 365399 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@365400 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-05-04 22:17:38 +00:00
Joshua Colp ae1502be33 Add support for lightweight NAT keepalive.
If enabled using the keepalive option in sip.conf a small packet will be sent
at a regular interval to keep the NAT mapping open. This is lightweight as the
remote side does not need to parse and handle a SIP message.

(closes issue AST-783)
Review: https://reviewboard.asterisk.org/r/1756/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@364500 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-04-28 20:24:45 +00:00
Michael L. Young abf40d9b28 Add IPv6 address support to security events framework.
The current Security Events Framework API only supports IPv4 when it comes to
generating security events.  This patch does the following:

* Changes the Security Events Framework API to support IPV6 and updates
  the components that use this API.

* Eliminates an error message that was being generated since the current
  implementation was treating an IPv6 socket address as if it was IPv4.

* Some copyright dates were updated on files touched by this patch.

(closes issue ASTERISK-19447) 
Reported by: Michael L. Young 
Tested by: Michael L. Young 
Patches: 
  security_events_ipv6v3.diff uploaded by Michael L. Young (license 5026)

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@362200 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-04-16 21:20:50 +00:00
Alec L Davis 9ac6938e09 Missed lastinvite CSeq int to uint32_t change
from Review: https://reviewboard.asterisk.org/r/1699/
........

Merged revisions 359809 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 359810 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@359811 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-03-16 08:27:14 +00:00
Mark Michelson 1bef7695ce Add a security event for the case where fake authentication challenge is sent.
........

Merged revisions 357318 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@357319 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-02-28 18:52:13 +00:00
Jonathan Rose 299dd5d4fc Adds an option to sip.conf that prevents diversion headers from being added.
send_diversion=no will prevent Diversion headers from being added to SIP
requests. This doesn't prevent Diversion from being added with dialplan
such as with SIPAddHeader.

(closes issue ASTERISK-16862)
Reported by: rsw686
Review: https://reviewboard.asterisk.org/r/1769/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@356987 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-02-27 16:24:17 +00:00
Richard Mudgett ebe2c33b72 Fix worker thread resource leak in SIP TCP/TLS.
The SIP TCP/TLS worker threads were created joinable but noone could join
them if they died on their own.

* Fix the SIP TCP/TLS worker threads to not be created joinable.

* _sip_tcp_helper_thread() only needs one parameter since the pvt
parameter is only passed in as NULL and never used.

(closes issue ASTERISK-19203)
Reported by: Steve Davies

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

Merged revisions 356677 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 356690 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@356697 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-02-24 18:33:04 +00:00
Matthew Jordan 670797e5da Allow SRTP policies to be reloaded
Currently, when using res_srtp, once the SRTP policy has been added to the
current session the policy is locked into place.  Any attempt to replace an
existing policy, which would be needed if the remote endpoint negotiated a new
cryptographic key, is instead rejected in res_srtp.  This happens in particular
in transfer scenarios, where the endpoint that Asterisk is communicating with
changes but uses the same RTP session.

This patch modifies res_srtp to allow remote and local policies to be reloaded
in the underlying SRTP library.  From the perspective of users of the SRTP API,
the only change is that the adding of remote and local policies are now added
in a single method call, whereas they previously were added separately.  This
was changed to account for the differences in handling remote and local
policies in libsrtp.

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

(closes issue ASTERISK-19253)
Reported by: Thomas Arimont
Tested by: Thomas Arimont
Patches:
  srtp_renew_keys_2012_02_22.diff uploaded by Matt Jordan (license 6283)
  (with some small modifications for this check-in)
........

Merged revisions 356604 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 356605 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@356606 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-02-24 15:10:35 +00:00
Terry Wilson 57f42bd74f ast_channel opaquification of pointers and integral types
Review: https://reviewboard.asterisk.org/r/1753/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@356042 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-02-20 23:43:27 +00:00