aboutsummaryrefslogtreecommitdiffstats
path: root/main/event.c
AgeCommit message (Collapse)AuthorFilesLines
2010-06-09Resolve an invalid memory read on an event.russell1-4/+13
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: http://svn.digium.com/svn/asterisk/trunk@269417 f38db490-d61c-443f-a65b-d21fe96a405b
2010-04-22Add ast_event subscription unit test and fix some ast_event API bugs.russell1-80/+100
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: http://svn.digium.com/svn/asterisk/trunk@258632 f38db490-d61c-443f-a65b-d21fe96a405b
2010-03-29Remove a debugging log entry.russell1-1/+0
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@255240 f38db490-d61c-443f-a65b-d21fe96a405b
2010-02-10Add a test module for the event API, test_event.c.russell1-2/+8
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: http://svn.digium.com/svn/asterisk/trunk@246260 f38db490-d61c-443f-a65b-d21fe96a405b
2010-02-08Fix return value of get_ie_str() and get_ie_str_hash() for non-existent IE.russell1-3/+3
I found this bug while developing a unit test for event allocation. Testing is awesome. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@245624 f38db490-d61c-443f-a65b-d21fe96a405b
2010-01-15Ensure payload type is properly checked when comparing against cached events.russell1-0/+1
(closes issue #16607) Reported by: ddv2005 Patches: event.patch uploaded by ddv2005 (license 769) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@240411 f38db490-d61c-443f-a65b-d21fe96a405b
2009-11-09Fix various problems detected with Valgrind.tilghman1-1/+3
* 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: http://svn.digium.com/svn/asterisk/trunk@228798 f38db490-d61c-443f-a65b-d21fe96a405b
2009-08-01Fix ast_event_queue_and_cache() to actually do the cache() part.russell1-2/+5
(closes issue #15624) Reported by: ffossard Tested by: russell git-svn-id: http://svn.digium.com/svn/asterisk/trunk@209835 f38db490-d61c-443f-a65b-d21fe96a405b
2009-07-31Fix some places where ast_event_type was used instead of ast_event_ie_type.russell1-9/+9
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@209711 f38db490-d61c-443f-a65b-d21fe96a405b
2009-07-11Add an API for reporting security events, and a security event logging module.russell1-74/+82
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: http://svn.digium.com/svn/asterisk/trunk@206021 f38db490-d61c-443f-a65b-d21fe96a405b
2009-06-26Merge the new Channel Event Logging (CEL) subsystem.russell1-15/+49
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: http://svn.digium.com/svn/asterisk/trunk@203638 f38db490-d61c-443f-a65b-d21fe96a405b
2009-06-15More 'static' qualifiers on module global variables.kpfleming1-1/+1
The 'pglobal' tool is quite handy indeed :-) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@200620 f38db490-d61c-443f-a65b-d21fe96a405b
2009-05-03Add 'bitflags'-style information elements to event frameworkkpfleming1-12/+96
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: http://svn.digium.com/svn/asterisk/trunk@191919 f38db490-d61c-443f-a65b-d21fe96a405b
2009-05-02Do a bit of code cleanup.russell1-54/+135
- 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: http://svn.digium.com/svn/asterisk/trunk@191848 f38db490-d61c-443f-a65b-d21fe96a405b
2009-03-27Change g_eid to ast_eid_default.russell1-1/+1
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@184630 f38db490-d61c-443f-a65b-d21fe96a405b
2009-03-25Remove unneeded AST_LIST_ENTRY() and comment on the purpose of ast_event_ref.russell1-1/+10
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@184344 f38db490-d61c-443f-a65b-d21fe96a405b
2009-03-25Improve performance of the ast_event cache functionality.russell1-136/+350
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: http://svn.digium.com/svn/asterisk/trunk@184339 f38db490-d61c-443f-a65b-d21fe96a405b
2008-11-29incorporates r159808 from branches/1.4:kpfleming1-2/+2
------------------------------------------------------------------------ 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: http://svn.digium.com/svn/asterisk/trunk@159818 f38db490-d61c-443f-a65b-d21fe96a405b
2008-08-10Another big chunk of changes from the RSW branch. Bunch of stuff from main/seanbright1-30/+30
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@137082 f38db490-d61c-443f-a65b-d21fe96a405b
2008-06-10Add an additional sanity check in case an event is passed between mmichelson1-0/+10
Asterisk boxes with mismatched ie_maps. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@121649 f38db490-d61c-443f-a65b-d21fe96a405b
2008-06-10Merge some more changes from team/russell/eventsrussell1-138/+420
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: http://svn.digium.com/svn/asterisk/trunk@121555 f38db490-d61c-443f-a65b-d21fe96a405b
2008-05-05Simplify code by using a taskprocessor for dispatching events in the ↵russell1-74/+48
Asterisk core. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@115324 f38db490-d61c-443f-a65b-d21fe96a405b
2008-04-16Introducing a small optimization to event_unsubscribe; events now use a ↵murf1-24/+25
Doubly-Linked list for events, gives fast deletions, for the sake of channel driver mwi events. From team/murf/bug11210. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@114183 f38db490-d61c-443f-a65b-d21fe96a405b
2008-02-13Fix a small logic error in ast_event_iterator_next. The previous logic ↵mmichelson1-1/+1
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: http://svn.digium.com/svn/asterisk/trunk@103559 f38db490-d61c-443f-a65b-d21fe96a405b
2008-02-11Fix a problem regarding network vs. host byte ordermmichelson1-3/+1
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: http://svn.digium.com/svn/asterisk/trunk@103282 f38db490-d61c-443f-a65b-d21fe96a405b
2008-01-11Goodbye again drumkilla.file1-1/+1
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@98435 f38db490-d61c-443f-a65b-d21fe96a405b
2008-01-11drumkilla ftw.file1-1/+1
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@98434 f38db490-d61c-443f-a65b-d21fe96a405b
2007-12-11* In unaligned.h, remove some unnecessary casts and mark the arg of the russell1-2/+3
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: http://svn.digium.com/svn/asterisk/trunk@92305 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-20move internal function declarations to include/asterisk/_private.hrizzo1-0/+1
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@89465 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-16Start untangling header inclusion in a way that does not affectrizzo1-3/+0
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: http://svn.digium.com/svn/asterisk/trunk@89333 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-08improve linked-list macros in two ways:kpfleming1-2/+2
- the *_CURRENT macros no longer need the list head pointer argument - add AST_LIST_MOVE_CURRENT to encapsulate the remove/add operation when moving entries between lists git-svn-id: http://svn.digium.com/svn/asterisk/trunk@89106 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-29Try to clarify the rules on changing ast_event and ast_event_ierussell1-2/+14
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@81356 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-29Fix parenthesis from my last commitrussell1-2/+2
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@81355 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-29Change pointer aritmetic on void * to char *russell1-5/+5
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@81354 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-29there is not actually code that sends these over the network in trunk yetrussell1-1/+1
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@81353 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-29Return ast_event_get_ie_raw to using an iterator and fix logic in ↵file1-13/+9
ast_event_iterator_next. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@81348 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-29This concludes bringing trunk back to a working state.file1-0/+1
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@81345 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-29To keep others happy... revert part of my additions so trunk works.file1-7/+13
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@81344 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-29Add API calls for iterating through an event. This should allow events to ↵file1-11/+44
have multiple information elements (while there was nothing preventing it before you could not actually access any except the first one). git-svn-id: http://svn.digium.com/svn/asterisk/trunk@81334 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-10Merge a set of device state improvements from team/russell/events.russell1-1/+2
The way a device state change propagates is kind of silly, in my opinion. A device state provider calls a function that indicates that the state of a device has changed. Then, another thread goes back and calls a callback for the device state provider to find out what the new state is before it can go send it off to whoever cares. I have changed it so that you can include the state that the device has changed to in the first function call from the device state provider. This removes the need to have to call the callback, which locks up critical containers to go find out what the state changed to. This change set changes the "simple" device state providers to use the new method. This includes parking, meetme, and SLA. I have also mostly converted chan_agent in my branch, but still have some more things to think through before presenting the plan for converting channel drivers to ensure all of the right events get generated ... git-svn-id: http://svn.digium.com/svn/asterisk/trunk@79027 f38db490-d61c-443f-a65b-d21fe96a405b
2007-06-06Issue 9869 - replace malloc and memset with ast_calloc, and other coding ↵tilghman1-6/+6
guidelines changes git-svn-id: http://svn.digium.com/svn/asterisk/trunk@67864 f38db490-d61c-443f-a65b-d21fe96a405b
2007-05-16This file really needs more documentation...oej1-1/+1
When we implement new API's - please include a small general overview in Doxygen git-svn-id: http://svn.digium.com/svn/asterisk/trunk@64496 f38db490-d61c-443f-a65b-d21fe96a405b
2007-04-28Merge changes from team/russell/eventsrussell1-0/+774
This set of changes introduces a new generic event API for use within Asterisk. I am still working on a way for events to be shared between servers, but this part is ready and can already be used inside of Asterisk. This set of changes introduces the first use of the API, as well. I have restructured the way that MWI (message waiting indication) is handled. It is now event based instead of polling based. For example, if there are a bunch of SIP phones subscribed to mailboxes, then chan_sip will not have to constantly poll the mailboxes for changes. app_voicemail will generate events when changes occur. See UPGRADE.txt and CHANGES for some more information on the effects of these changes from the user perspective. For developer information, see the text in include/asterisk/event.h. As always, additional feedback is welcome on the asterisk-dev mailing list. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@62292 f38db490-d61c-443f-a65b-d21fe96a405b