Commit Graph

63 Commits

Author SHA1 Message Date
Jason Parker 22d58fbea8 Fix comparison of presence state in event subsystem.
Several new IEs were not given types (or names), causing the comparison
function to improperly succeed.  This adds those.

(closes issue AST-1128)
........

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@382391 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-03-04 21:14:30 +00:00
Matthew Jordan 8fb5bdce9a Prevent exhaustion of system resources through exploitation of event cache
Asterisk maintains an internal cache for devices in the event subsystem. The
device state cache holds the state of each device known to Asterisk, such that
consumers of device state information can query for the last known state for
a particular device, even if it is not part of an active call. The concept of
a device in Asterisk can include entities that do not have a physical
representation. One way that this occurred was when anonymous calls are allowed
in Asterisk. A device was automatically created and stored in the cache for
each anonymous call that occurred; this was possible in the SIP and IAX2
channel drivers and through channel drivers that utilized the
res_jabber/res_xmpp resource modules (Gtalk, Jingle, and Motif). These devices
are never removed from the system, allowing anonymous calls to potentially
exhaust a system's resources.

This patch changes the event cache subsystem and device state management to
no longer cache devices that are not associated with a physical entity.

(issue ASTERISK-20175)
Reported by: Russell Bryant, Leif Madsen, Joshua Colp
Tested by: kmoore
patches:
  event-cachability-3.diff uploaded by jcolp (license 5000)
........

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

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

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@378322 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-02 18:11:59 +00:00
Richard Mudgett 7990b03e4e Cleanup event on exit.
* Cleanup CLI commands on exit.

(issue ASTERISK-20649)
Reported by: Corey Farrell
Patches:
      event_shutdown-10-only.patch (license #5909) patch uploaded by Corey Farrell
      event_shutdown-1_8-11-trunk.patch (license #5909) patch uploaded by Corey Farrell
........

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

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

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@377711 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-11 01:04:50 +00:00
Matthew Jordan a094707d51 Fix a variety of ref counting issues
This patch resolves a number of ref leaks that occur primarily on Asterisk
shutdown.  It adds a variety of shutdown routines to core portions of
Asterisk such that they can reclaim resources allocate duringd initialization.

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

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

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

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@374197 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-10-02 01:47:16 +00:00
Russell Bryant 733b46022b Move event cache updates into event processing thread.
Prior to this patch, updating the device state cache was done by the thread
that originated the event.  It would update the cache and then queue the event
up for another thread to dispatch.  This thread moves the cache updating part
to be in the same thread as event dispatching.

I was working with someone on a heavily loaded Asterisk system and while
reviewing backtraces of the system while it was having problems, I noticed that
there were a lot of threads contending for the lock on the event cache.  By
simply moving this into a single thread, this helped performance *a lot* and
alleviated some deadlock-like symptoms.

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



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370664 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-31 20:33:57 +00:00
Kinsey Moore 9b16c8b0f6 Clean up and ensure proper usage of alloca()
This replaces all calls to alloca() with ast_alloca() which calls gcc's
__builtin_alloca() to avoid BSD semantics and removes all NULL checks
on memory allocated via ast_alloca() and ast_strdupa().

(closes issue ASTERISK-20125)
Review: https://reviewboard.asterisk.org/r/2032/
Patch-by: Walter Doekes (wdoekes)
........

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

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370655 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-31 20:21:43 +00:00
Russell Bryant fd11146592 Add a "corosync ping" CLI command.
This patch adds a new CLI command to the res_corosync module.  It is primarily
used as a debugging tool.  It lets you fire off an event which will cause
res_corosync on other nodes in the cluster to place messages into the logger if
everything is working ok.  It verifies that the corosync communication is
working as expected.

I didn't put anything in the CHANGES file for this, because this module is new
in Asterisk 11.  There is already a generic "res_corosync new module" entry in
there so I figure that covers it just fine.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370535 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-30 00:14:18 +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
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
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
Michael L. Young 255214c5da Add missing payload type to events API
The Security Events Framework API was changed while adding the generation of
security events in chan_sip.  A payload type and name was missed from being
added to struct ie_maps.

(closes issue ASTERISK-19759)
Reported by: Michael L. Young
Patches:
    issue-asterisk-19759.diff uploaded by Michael L. Young (license 5026)
........

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@362919 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-04-20 16:50:38 +00:00
Kinsey Moore c5b3db1956 Kill off red blobs in most of main/*
Everything still compiled after making these changes, so I assume these
whitespace-only changes didn't break anything (and shouldn't have).


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@360190 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-03-22 19:51:16 +00:00
Kinsey Moore 8d1bde49a9 Fix case-sensitivity for device-specific event subscriptions and CCSS
This change fixes case-sensitivity for device-specific subscriptions such that
the technology identifier is case-insensitive while the remainder of the device
string is still case-sensitive.  This should also preserve the original case of
the device string as passed in to the event system.  CCSS is the only feature
affected as it is the only consumer of device-specific event subscriptions.

The second part of this patch addresses similar case-sensitivity issues within
CCSS itself that prevented it from functioning correctly after the fix to the
events system.

This adds a unit test to verify that the event system works as expected.

(closes issue ASTERISK-19422)
Review: https://reviewboard.asterisk.org/r/1780/
........

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

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@357942 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-03-02 21:06:12 +00:00
Jonathan Rose 5982bdcb7c Merged revisions 337595,337597 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/10

........
  r337595 | jrose | 2011-09-22 10:35:50 -0500 (Thu, 22 Sep 2011) | 12 lines
  
  Generate Security events in chan_sip using new Security Events Framework
  
  Security Events Framework was added in 1.8 and support was added for AMI to generate
  events at that time. This patch adds support for chan_sip to generate security events.
  
  (closes issue ASTERISK-18264)
  Reported by: Michael L. Young
  Patches:
       security_events_chan_sip_v4.patch (license #5026) by Michael L. Young
  Review: https://reviewboard.asterisk.org/r/1362/
........
  r337597 | jrose | 2011-09-22 10:47:05 -0500 (Thu, 22 Sep 2011) | 10 lines
  
  Forgot to svn add new files to r337595
  
  Part of Generating security events for chan_sip
  
  (issue ASTERISK-18264)
  Reported by: Michael L. Young
  Patches:
      security_events_chan_sip_v4.patch (License #5026) by Michael L. Young
  Reviewboard: https://reviewboard.asterisk.org/r/1362/
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@337600 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-22 16:35:20 +00:00
Russell Bryant 2a25779d47 Merged revisions 335510 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/10

................
  r335510 | russell | 2011-09-13 02:24:34 -0500 (Tue, 13 Sep 2011) | 22 lines
  
  Merged revisions 335497 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.8
  
  ........
    r335497 | russell | 2011-09-13 02:11:36 -0500 (Tue, 13 Sep 2011) | 15 lines
    
    Fix a crash in res_ais.
    
    This patch resolves a crash observed in a load testing environment that
    involved the use of the res_ais module.  I observed some crashes where
    the event delivery callback would get called, but the length parameter
    incidcating how much data there was to read was 0.  The code assumed
    (with good reason I would think) that if this callback got called, there
    was an event available to read.  However, if the rare case that there's
    nothing there, catch it and return instead of blowing up.
    
    More specifically, the change always ensure that the size of the received
    event in the cluster is always big enough to be a real ast_event.
    
    Review: https://reviewboard.asterisk.org/r/1423/
  ........
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@335511 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-13 07:35:59 +00:00
Richard Mudgett b2d0ea5fea Merged revisions 323669-323670 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r323669 | rmudgett | 2011-06-15 11:43:18 -0500 (Wed, 15 Jun 2011) | 21 lines
  
  [regression] Voicemail MWI is no longer sent.
  
  When leaving a voicemail, the MWI message is never sent.  The same thing
  happens when checking a voicemail and marking it as read.
  
  If you restart Asterisk, everything comes up at that state correctly, but
  changes to the messages in voicemail causes the light to not be set
  appropriately.  Very easy to reproduce.
  
  * Made ast_event_check_subscriber() return TRUE if there are ANY
  subscribers to an event type when there are no restricting ie values
  passed.  This allows an event being queued to be queued.
  
  (closes issue ASTERISK-18002)
  Reported by: lmadsen
  Tested by: lmadsen, irroot
  Patches:
       jira_asterisk_18002_v1.8.patch uploaded by rmudgett (License #5621)
  
  (closes issue ASTERISK-18019)
........
  r323670 | rmudgett | 2011-06-15 11:43:31 -0500 (Wed, 15 Jun 2011) | 7 lines
  
  Add a test to the event unit tests to catch ASTERISK-18002.
  
  The new tests check to see if there are ANY subscribers to the event type
  when ast_event_check_subscriber() is not passed any specific ie values.
  
  (issue ASTERISK-18002)
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@323671 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-06-15 16:49:34 +00:00
Richard Mudgett 70d9527951 Merged revisions 323456 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r323456 | rmudgett | 2011-06-14 19:50:20 -0500 (Tue, 14 Jun 2011) | 1 line
  
  Add missing break in ast_event_get_cached().
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@323457 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-06-15 00:51:01 +00:00
Richard Mudgett 85aa126b34 Merged revisions 321871 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r321871 | rmudgett | 2011-06-03 15:58:13 -0500 (Fri, 03 Jun 2011) | 27 lines
  
  Event subscription fixes.
  
  Must commit the subscription fixes together with the integration
  subscription tests.  The subscription fixes cause an erroneously passing
  test to fail.  The new subscription tests detect errors without the
  subscription fixes.
  
  * Added missing event_names[] table entry.
  
  * Reworked ast_event_check_subscriber()/match_sub_ie_val_to_event() to
  correctly detect if a subscriber exists for the proposed event.
  
  * Made match_ie_val() and match_sub_ie_val_to_event() check the buffer
  length for RAW payload types.
  
  * Fixed error handling memory leak in ast_event_sub_activate(),
  ast_event_unsubscribe(), and ast_event_queue().
  
  * Made ast_event_new() and ast_event_check_subscriber() better protect
  themselves from an invalid payload type.
  
  * Added container lock protection between removing old cache events and
  adding the new cached event in
  ast_event_queue_and_cache()/event_update_cache().
  
  * Added new event subscription tests.
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@321872 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-06-03 21:02:32 +00:00
Richard Mudgett 397c379a7d Merged revisions 321812-321813 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r321812 | rmudgett | 2011-06-03 14:55:21 -0500 (Fri, 03 Jun 2011) | 1 line
  
  Correct IAX2 and SIP event subscription description string.
........
  r321813 | rmudgett | 2011-06-03 14:56:09 -0500 (Fri, 03 Jun 2011) | 1 line
  
  Constify subscription description parameter string.
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@321814 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-06-03 19:57:03 +00:00
Russell Bryant 9fbbdfb223 Merged revisions 295711 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

................
  r295711 | russell | 2010-11-19 18:50:00 -0600 (Fri, 19 Nov 2010) | 36 lines
  
  Merged revisions 295710 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.6.2
  
  ........
    r295710 | russell | 2010-11-19 18:45:51 -0600 (Fri, 19 Nov 2010) | 29 lines
    
    Fix cache of device state changes for multiple servers.
    
    This patch addresses a regression where device states across multiple servers
    were not being processing completely correctly.  The code works to determine
    the overall state by looking at the last known state of a device on each
    server.  However, there was a regression due to some invasive rewrites of how
    the cache works that led to the cache only storing the last device state change
    for a device, regardless of which server it was on.
    
    The code is set up to cache device state change events by ensuring that each
    event in the cache has a unique device name + entity ID (server ID).  The code
    that was responsible for comparing raw information elements (which EID is)
    always returned a match due to a memcmp() with a length of 0.
    
    There isn't much code to fix the actual bug.  This patch also introduces a new
    CLI command that was very useful for debugging this problem.  The command
    allows you to dump the contents of the event cache.
    
    (closes issue #18284)
    Reported by: klaus3000
    Patches:
          issue18284.rev1.txt uploaded by russell (license 2)
    Tested by: russell, klaus3000
    
    (closes issue #18280)
    Reported by: klaus3000
    
    Review: https://reviewboard.asterisk.org/r/1012/
  ........
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@295712 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-11-20 00:52:47 +00:00
Russell Bryant 05c46771ca Resolve an invalid memory read on an event.
Valgrind pointed out that attempting to get an IE value from an event that has
no IEs produces an invalid memory read past the end of the event.  Thanks to
mmichelson for pointing the problem out to me and then testing the fix.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@269417 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-06-09 21:11:43 +00:00
Russell Bryant 52a8ddba51 Add ast_event subscription unit test and fix some ast_event API bugs.
This patch introduces another test in test_event.c that exercises most of the
subscription related ast_event API calls.  I made some minor additions to the
existing event allocation test to increase API coverage by the test code.
Finally, I made a list in a comment of API calls not yet touched by the test
module as a to-do list for future test development.

During the development of this test code, I discovered a number of bugs in
the event API.

1) subscriptions to AST_EVENT_ALL were not handled appropriately in a couple
   of different places.  The API allows a subscription to all event types,
   but with IE parameters, just as if it was a subscription to a specific
   event type.  However, the parameters were being ignored.  This affected
   ast_event_check_subscriber() and event distribution to subscribers.

2) Some of the logic in ast_event_check_subscriber() for checking subscriptions
   against query parameters was wrong.

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@258632 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-04-22 21:06:53 +00:00
Russell Bryant 899f995703 Remove a debugging log entry.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@255240 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-03-29 05:10:41 +00:00
Russell Bryant 1321748c19 Add a test module for the event API, test_event.c.
This module includes a single test so far that creates events using two
different methods and does some verification on the result to make sure
the correct data can be retrieved from the event that was created.

One bug was found in the event API while developing this test, which makes
me happy.  :-)

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@246260 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-10 23:19:16 +00:00
Russell Bryant f2282722dd Fix return value of get_ie_str() and get_ie_str_hash() for non-existent IE.
I found this bug while developing a unit test for event allocation.  Testing
is awesome.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@245624 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-08 23:43:00 +00:00
Russell Bryant 86c57df84e Ensure payload type is properly checked when comparing against cached events.
(closes issue #16607)
Reported by: ddv2005
Patches:
      event.patch uploaded by ddv2005 (license 769)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@240411 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-01-15 20:41:11 +00:00
Tilghman Lesher c0b3c923a4 Fix various problems detected with Valgrind.
* chan_console accessed pvts after deallocation.
 * cdr_mysql stored a pointer that was freed by realloc()
 * The module loader did not check usecount on shutdown, which led to chan_iax2
 reading a timer that was already unloaded.
 * The event subsystem sometimes creates an event with no IEs.  Due to a corner
 condition, the code would read beyond the memory boundary.
 * res_pktccops did not correctly check whether its monitor thread was started.
(closes issue #16062)
 Reported by: alexanderheinz
 Patches: 
       20091109__issue16062.diff.txt uploaded by tilghman (license 14)
 Tested by: tilghman


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@228798 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-11-09 07:37:52 +00:00
Russell Bryant 1ca3ffd08c Fix ast_event_queue_and_cache() to actually do the cache() part.
(closes issue #15624)
Reported by: ffossard
Tested by: russell


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@209835 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-08-01 10:43:40 +00:00
Russell Bryant 68a05b14c6 Fix some places where ast_event_type was used instead of ast_event_ie_type.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@209711 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-07-31 21:53:31 +00:00
Russell Bryant 4cf8a968fd Add an API for reporting security events, and a security event logging module.
This commit introduces the security events API.  This API is to be used by
Asterisk components to report events that have security implications.
A simple example is when a connection is made but fails authentication.  These
events can be used by external tools manipulate firewall rules or something
similar after detecting unusual activity based on security events.

Inside of Asterisk, the events go through the ast_event API.  This means that
they have a binary encoding, and it is easy to write code to subscribe to these
events and do something with them.

One module is provided that is a subscriber to these events - res_security_log.
This module turns security events into a parseable text format and sends them
to the "security" logger level.  Using logger.conf, these log entries may be
sent to a file, or to syslog.

One service, AMI, has been fully updated for reporting security events.
AMI was chosen as it was a fairly straight forward service to convert.
The next target will be chan_sip.  That will be more complicated and will
be done as its own project as the next phase of security events work.

For more information on the security events framework, see the documentation
generated from doc/tex/.  "make asterisk.pdf"

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@206021 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-07-11 19:15:03 +00:00
Russell Bryant 0264eef115 Merge the new Channel Event Logging (CEL) subsystem.
CEL is the new system for logging channel events.  This was inspired after
facing many problems trying to represent what is possible to happen to a call
in Asterisk using CDR records.  For more information on CEL, see the built in
HTML or PDF documentation generated from the files in doc/tex/.

Many thanks to Steve Murphy (murf) and Brian Degenhardt (bmd) for their hard
work developing this code.  Also, thanks to Matt Nicholson (mnicholson) and
Sean Bright (seanbright) for their assistance in the final push to get this
code ready for Asterisk trunk.

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@203638 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-06-26 15:28:53 +00:00
Kevin P. Fleming 82fb56886e More 'static' qualifiers on module global variables.
The 'pglobal' tool is quite handy indeed :-)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@200620 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-06-15 17:34:30 +00:00
Kevin P. Fleming 73743b77b0 Add 'bitflags'-style information elements to event framework
This patch add a new payload type for information elements, a set
of bit flags. The payload is transported as a 32-bit unsigned integer
but when matching is performed between events and subscribers,
the matching is done by using a bitwise AND instead of numeric value
comparison.

Review: http://reviewboard.asterisk.org/r/242/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@191919 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-05-03 14:28:59 +00:00
Russell Bryant a398f9e0ac Do a bit of code cleanup.
- convert handling of IE PLTYPEs to switch statements
 - add braces to various small blocks
 - remove a bit of trailing whitespace
 - remove a couple of unnecessary ast_strdupa() uses


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@191848 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-05-02 21:15:18 +00:00
Russell Bryant b564b2105f Change g_eid to ast_eid_default.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@184630 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-27 14:00:18 +00:00
Russell Bryant 189a55f9f0 Remove unneeded AST_LIST_ENTRY() and comment on the purpose of ast_event_ref.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@184344 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-25 22:11:35 +00:00
Russell Bryant ee77b475f2 Improve performance of the ast_event cache functionality.
This code comes from svn/asterisk/team/russell/event_performance/.

Here is a summary of the changes that have been made, in order of both
invasiveness and performance impact, from smallest to largest.

1) Asterisk 1.6.1 introduces some additional logic to be able to handle
   distributed device state.  This functionality comes at a cost.
   One relatively minor change in this patch is that the extra processing
   required for distributed device state is now completely bypassed if
   it's not needed.

2) One of the things that I noticed when profiling this code was that a
   _lot_ of time was spent doing string comparisons.  I changed the way
   strings are represented in an event to include a hash value at the front.
   So, before doing a string comparison, we do an integer comparison on the
   hash.

3) Finally, the code that handles the event cache has been re-written.
   I tried to do this in a such a way that it had minimal impact on the API.
   I did have to change one API call, though - ast_event_queue_and_cache().
   However, the way it works now is nicer, IMO.  Each type of event that
   can be cached (MWI, device state) has its own hash table and rules for
   hashing and comparing objects.  This by far made the biggest impact on
   performance.

For additional details regarding this code and how it was tested, please see the
review request.

(closes issue #14738)
Reported by: russell

Review: http://reviewboard.digium.com/r/205/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@184339 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-25 21:57:19 +00:00
Kevin P. Fleming 887e28d7aa incorporates r159808 from branches/1.4:
------------------------------------------------------------------------
r159808 | kpfleming | 2008-11-29 10:58:29 -0600 (Sat, 29 Nov 2008) | 7 lines

update dev-mode compiler flags to match the ones used by default on Ubuntu Intrepid, so all developers will see the same warnings and errors

since this branch already had some printf format attributes, enable checking for them and tag functions that didn't have them

format attributes in a consistent way


------------------------------------------------------------------------

in addition:

move some format attributes from main/utils.c to the header files they belong in, and fix up references to the relevant functions based on new compiler warnings



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@159818 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-11-29 17:57:39 +00:00
Sean Bright b69c8e6ab5 Another big chunk of changes from the RSW branch. Bunch of stuff from main/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@137082 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-08-10 19:35:50 +00:00
Mark Michelson f0a019dbec Add an additional sanity check in case an event is passed between
Asterisk boxes with mismatched ie_maps.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@121649 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-06-10 19:52:21 +00:00
Russell Bryant 823d1c7ea9 Merge some more changes from team/russell/events
This commit pulls in a batch of improvements and additions to the event API.
Changes include:
 - the ability to dynamically build a subscription.  This is useful if you're
    building a subscription based on something you receive from the network,
    or from options in a configuration file.
 - Add tables of event types and IE types and the corresponding string
    representation for implementing text based protocols that use these
	events, for showing events on the CLI, reading configuration that
	references event information, among other things.
 - Add a table that maps IE types and the corresponding payload type.
 - an API call to get the total size of an event
 - an API call to get all events from the cache that match a subscription
 - a new IE payload type, raw, which I used for transporting the Entity ID in
    my code for handling distributed device state.
 - Code improvements to reduce code duplication
 - Include the Entity ID of the server that originated the event in every event
 - an additional event type, DEVICE_STATE_CHANGE, to help facilitate distributed
    device state.  DEVICE_STATE is a state change on one server, DEVICE_STATE_CHANGE
	is the aggregate device state change across all servers.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@121555 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-06-10 14:53:40 +00:00
Russell Bryant 7f29bc7bc6 Simplify code by using a taskprocessor for dispatching events in the Asterisk core.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@115324 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-05-05 22:01:56 +00:00
Steve Murphy 8b6d8da58c Introducing a small optimization to event_unsubscribe; events now use a Doubly-Linked list for events, gives fast deletions, for the sake of channel driver mwi events. From team/murf/bug11210.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@114183 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-16 20:28:08 +00:00
Mark Michelson 23fc97480e Fix a small logic error in ast_event_iterator_next. The previous logic allowed for the iterator
to indicate there was more data than there really was, causing the iterator read beyond the end
of the event structure. This led to invalid memory reads and potential crashes.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@103559 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-02-13 00:55:09 +00:00
Mark Michelson 9d683be81a Fix a problem regarding network vs. host byte order
in the event API.

ast_event_iterator_get_ie_type should return the ie type in
host byte order. Furthermore, ast_event_get_ie_raw should already
have its ie type argument in host byte order since it could be called
externally (and it in fact is called in this way by ast_event_get_cached).



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@103282 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-02-11 02:47:25 +00:00
Joshua Colp 4fe093b821 Goodbye again drumkilla.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@98435 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-01-11 23:09:31 +00:00
Joshua Colp e0532df614 drumkilla ftw.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@98434 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-01-11 23:00:21 +00:00
Russell Bryant f330fb4783 * In unaligned.h, remove some unnecessary casts and mark the arg of the
get_unaligned functions as const
* In event.c, use get_unaligned_uint32() in a couple of places to fix issues on
  architectures that don't allow unaligned access


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@92305 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-12-11 16:29:29 +00:00
Luigi Rizzo 915b97d300 move internal function declarations to include/asterisk/_private.h
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89465 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-20 22:18:21 +00:00
Luigi Rizzo fdb7f7ba3d Start untangling header inclusion in a way that does not affect
build times - tested, there is no measureable difference before and
after this commit.

In this change:

use asterisk/compat.h to include a small set of system headers:
inttypes.h, unistd.h, stddef.h, stddint.h, sys/types.h, stdarg.h,
stdlib.h, alloca.h, stdio.h

Where available, the inclusion is conditional on HAVE_FOO_H as determined
by autoconf.

Normally, source files should not include any of the above system headers,
and instead use either "asterisk.h" or "asterisk/compat.h" which does it
better. 

For the time being I have left alone second-level directories
(main/db1-ast, etc.).



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89333 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-16 20:04:58 +00:00