00001 /* 00002 * Asterisk -- An open source telephony toolkit. 00003 * 00004 * Copyright (C) 2007 - 2008, Digium, Inc. 00005 * 00006 * Russell Bryant <russell@digium.com> 00007 * 00008 * See http://www.asterisk.org for more information about 00009 * the Asterisk project. Please do not directly contact 00010 * any of the maintainers of this project for assistance; 00011 * the project provides a web site, mailing lists and IRC 00012 * channels for your use. 00013 * 00014 * This program is free software, distributed under the terms of 00015 * the GNU General Public License Version 2. See the LICENSE file 00016 * at the top of the source tree. 00017 */ 00018 00019 /*! 00020 * \file 00021 * \author Russell Bryant <russell@digium.com> 00022 * \ref AstGenericEvents 00023 */ 00024 00025 /*! 00026 * \page AstGenericEvents Generic event system 00027 * 00028 * The purpose of this API is to provide a generic way to share events between 00029 * Asterisk modules. Code can generate events, and other code can subscribe to 00030 * them. 00031 * 00032 * Events have an associated event type, as well as information elements. The 00033 * information elements are the meta data that go along with each event. For 00034 * example, in the case of message waiting indication, the event type is MWI, 00035 * and each MWI event contains at least three information elements: the 00036 * mailbox, the number of new messages, and the number of old messages. 00037 * 00038 * Subscriptions to events consist of an event type and information elements, 00039 * as well. Subscriptions can be to all events, or a certain subset of events. 00040 * If an event type is provided, only events of that type will be sent to this 00041 * subscriber. Furthermore, if information elements are supplied with the 00042 * subscription, only events that contain the specified information elements 00043 * with specified values will be sent to the subscriber. For example, when a 00044 * SIP phone subscribes to MWI for mailbox 1234, then chan_sip can subscribe 00045 * to internal Asterisk MWI events with the MAILBOX information element with 00046 * a value of "1234". 00047 * 00048 * Another key feature of this event system is the ability to cache events. 00049 * It is useful for some types of events to be able to remember the last known 00050 * value. These are usually events that indicate some kind of state change. 00051 * In the example of MWI, app_voicemail can instruct the event core to cache 00052 * these events based on the mailbox. So, the last known MWI state of each 00053 * mailbox will be cached, and other modules can retrieve this information 00054 * on demand without having to poll the mailbox directly. 00055 */ 00056 00057 #ifndef AST_EVENT_H 00058 #define AST_EVENT_H 00059 00060 #if defined(__cplusplus) || defined(c_plusplus) 00061 extern "C" { 00062 #endif 00063 00064 #include "asterisk/event_defs.h" 00065 00066 /*! 00067 * \brief Subscriber event callback type 00068 * 00069 * \param event the event being passed to the subscriber 00070 * \param userdata the data provider in the call to ast_event_subscribe() 00071 * 00072 * \return The event callbacks do not return anything. 00073 */ 00074 typedef void (*ast_event_cb_t)(const struct ast_event *event, void *userdata); 00075 00076 /*! 00077 * \brief Subscribe to events 00078 * 00079 * \param event_type The type of events to subscribe to 00080 * \param cb The function to be called with events 00081 * \param description Description of the subscription. 00082 * \param userdata data to be passed to the event callback 00083 * 00084 * The rest of the arguments to this function specify additional parameters for 00085 * the subscription to filter which events are passed to this subscriber. The 00086 * arguments must be in sets of: 00087 * \code 00088 * <enum ast_event_ie_type>, [enum ast_event_ie_pltype, [payload] ] 00089 * \endcode 00090 * and must end with AST_EVENT_IE_END. 00091 * 00092 * If the ie_type specified is *not* AST_EVENT_IE_END, then it must be followed 00093 * by a valid IE payload type. If the payload type specified is 00094 * AST_EVENT_IE_PLTYPE_EXISTS, then the 3rd argument should not be provided. 00095 * Otherwise, a payload must also be specified. 00096 * 00097 * \return This returns a reference to the subscription for use with 00098 * un-subscribing later. If there is a failure in creating the 00099 * subscription, NULL will be returned. 00100 * 00101 * Example usage: 00102 * 00103 * \code 00104 * peer->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb, peer, 00105 * AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, peer->mailbox, 00106 * AST_EVENT_IE_END); 00107 * \endcode 00108 * 00109 * This creates a subscription to AST_EVENT_MWI events that contain an 00110 * information element, AST_EVENT_IE_MAILBOX, with the same string value 00111 * contained in peer->mailbox. Also, the event callback will be passed a 00112 * pointer to the peer. 00113 * 00114 * \note A NULL description will cause this function to crash, so watch out! 00115 */ 00116 struct ast_event_sub *ast_event_subscribe(enum ast_event_type event_type, 00117 ast_event_cb_t cb, char *description, void *userdata, ...); 00118 00119 /*! 00120 * \brief Allocate a subscription, but do not activate it 00121 * 00122 * \param type the event type to subscribe to 00123 * \param cb the function to call when an event matches this subscription 00124 * \param userdata data to pass to the provided callback 00125 * 00126 * This function should be used when you want to dynamically build a 00127 * subscription. 00128 * 00129 * \return the allocated subscription, or NULL on failure 00130 * \since 1.6.1 00131 */ 00132 struct ast_event_sub *ast_event_subscribe_new(enum ast_event_type type, 00133 ast_event_cb_t cb, void *userdata); 00134 00135 /*! 00136 * \brief Destroy an allocated subscription 00137 * 00138 * \param sub the subscription to destroy 00139 * 00140 * This function should be used when a subscription is allocated with 00141 * ast_event_subscribe_new(), but for some reason, you want to destroy it 00142 * instead of activating it. This could be because of an error when 00143 * reading in the configuration for the dynamically built subscription. 00144 * \since 1.6.1 00145 */ 00146 void ast_event_sub_destroy(struct ast_event_sub *sub); 00147 00148 /*! 00149 * \brief Append a uint parameter to a subscription 00150 * 00151 * \param sub the dynamic subscription allocated with ast_event_subscribe_new() 00152 * \param ie_type the information element type for the parameter 00153 * \param uint the value that must be present in the event to match this subscription 00154 * 00155 * \retval 0 success 00156 * \retval non-zero failure 00157 * \since 1.6.1 00158 */ 00159 int ast_event_sub_append_ie_uint(struct ast_event_sub *sub, 00160 enum ast_event_ie_type ie_type, uint32_t uint); 00161 00162 /*! 00163 * \brief Append a bitflags parameter to a subscription 00164 * 00165 * \param sub the dynamic subscription allocated with ast_event_subscribe_new() 00166 * \param ie_type the information element type for the parameter 00167 * \param flags the flags that must be present in the event to match this subscription 00168 * 00169 * \retval 0 success 00170 * \retval non-zero failure 00171 * \since 1.6.3 00172 */ 00173 int ast_event_sub_append_ie_bitflags(struct ast_event_sub *sub, 00174 enum ast_event_ie_type ie_type, uint32_t flags); 00175 00176 /*! 00177 * \brief Append a string parameter to a subscription 00178 * 00179 * \param sub the dynamic subscription allocated with ast_event_subscribe_new() 00180 * \param ie_type the information element type for the parameter 00181 * \param str the string that must be present in the event to match this subscription 00182 * 00183 * \retval 0 success 00184 * \retval non-zero failure 00185 * \since 1.6.1 00186 */ 00187 int ast_event_sub_append_ie_str(struct ast_event_sub *sub, 00188 enum ast_event_ie_type ie_type, const char *str); 00189 00190 /*! 00191 * \brief Append a raw parameter to a subscription 00192 * 00193 * \param sub the dynamic subscription allocated with ast_event_subscribe_new() 00194 * \param ie_type the information element type for the parameter 00195 * \param raw the data that must be present in the event to match this subscription 00196 * 00197 * \retval 0 success 00198 * \retval non-zero failure 00199 * \since 1.6.1 00200 */ 00201 int ast_event_sub_append_ie_raw(struct ast_event_sub *sub, 00202 enum ast_event_ie_type ie_type, void *data, size_t raw_datalen); 00203 00204 /*! 00205 * \brief Append an 'exists' parameter to a subscription 00206 * 00207 * \param sub the dynamic subscription allocated with ast_event_subscribe_new() 00208 * \param ie_type the information element type that must be present in the event 00209 * for it to match this subscription. 00210 * 00211 * \retval 0 success 00212 * \retval non-zero failure 00213 * \since 1.6.1 00214 */ 00215 int ast_event_sub_append_ie_exists(struct ast_event_sub *sub, 00216 enum ast_event_ie_type ie_type); 00217 00218 /*! 00219 * \brief Activate a dynamically built subscription 00220 * 00221 * \param sub the subscription to activate that was allocated using 00222 * ast_event_subscribe_new() 00223 * 00224 * Once a dynamically built subscription has had all of the parameters added 00225 * to it, it should be activated using this function. 00226 * 00227 * \retval 0 success 00228 * \retval non-zero failure 00229 * \since 1.6.1 00230 */ 00231 int ast_event_sub_activate(struct ast_event_sub *sub); 00232 00233 /*! 00234 * \brief Un-subscribe from events 00235 * 00236 * \param event_sub This is the reference to the subscription returned by 00237 * ast_event_subscribe. 00238 * 00239 * This function will remove a subscription and free the associated data 00240 * structures. 00241 * 00242 * \return NULL for convenience. 00243 * \version 1.6.1 return changed to NULL 00244 */ 00245 struct ast_event_sub *ast_event_unsubscribe(struct ast_event_sub *event_sub); 00246 00247 /*! 00248 * \brief Get description for a subscription 00249 * 00250 * \param sub subscription 00251 * 00252 * \return string description of the subscription 00253 */ 00254 const char *ast_event_subscriber_get_description(struct ast_event_sub *sub); 00255 00256 /*! 00257 * \brief Check if subscribers exist 00258 * 00259 * \param event_type This is the type of event that the caller would like to 00260 * check for subscribers to. 00261 * 00262 * The rest of the arguments to this function specify additional parameters for 00263 * checking for subscriptions to subsets of an event type. The arguments must 00264 * in sets of: 00265 * \code 00266 * <enum ast_event_ie_type>, [enum ast_event_ie_pltype, [payload] ] 00267 * \endcode 00268 * and must end with AST_EVENT_IE_END. 00269 * 00270 * If the ie_type specified is *not* AST_EVENT_IE_END, then it must be followed 00271 * by a valid IE payload type. If the payload type specified is 00272 * AST_EVENT_IE_PLTYPE_EXISTS, then the 3rd argument should not be provided. 00273 * Otherwise, a payload must also be specified. 00274 * 00275 * \return This returns one of the values defined in the ast_event_subscriber_res 00276 * enum which will indicate if subscribers exist that match the given 00277 * criteria. 00278 * 00279 * Example usage: 00280 * 00281 * \code 00282 * if (ast_event_check_subscriber(AST_EVENT_MWI, 00283 * AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox, 00284 * AST_EVENT_IE_END) == AST_EVENT_SUB_NONE) { 00285 * return; 00286 * } 00287 * \endcode 00288 * 00289 * This example will check if there are any subscribers to MWI events for the 00290 * mailbox defined in the "mailbox" variable. 00291 */ 00292 enum ast_event_subscriber_res ast_event_check_subscriber(enum ast_event_type event_type, ...); 00293 00294 /*! 00295 * \brief Report current subscriptions to a subscription subscriber 00296 * 00297 * \arg sub the subscription subscriber 00298 * 00299 * \return nothing 00300 * 00301 * This reports all of the current subscribers to a subscriber of 00302 * subscribers to a specific event type. (Try saying that a few times fast). 00303 * 00304 * The idea here is that it is sometimes very useful for a module to know when 00305 * someone subscribes to events. However, when they first subscribe, this 00306 * provides that module the ability to request the event core report to them 00307 * all of the subscriptions to that event type that already exist. 00308 */ 00309 void ast_event_report_subs(const struct ast_event_sub *sub); 00310 00311 /*! 00312 * \brief Dump the event cache for the subscriber 00313 * \since 1.6.1 00314 */ 00315 void ast_event_dump_cache(const struct ast_event_sub *event_sub); 00316 00317 /*! 00318 * \brief Create a new event 00319 * 00320 * \param event_type The type of event to create 00321 * 00322 * The rest of the arguments to this function specify information elements to 00323 * add to the event. They are specified in the form: 00324 * \code 00325 * <enum ast_event_ie_type>, [enum ast_event_ie_pltype, [payload] ] 00326 * \endcode 00327 * and must end with AST_EVENT_IE_END. 00328 * 00329 * If the ie_type specified is *not* AST_EVENT_IE_END, then it must be followed 00330 * by a valid IE payload type. The payload type, EXISTS, should not be used here 00331 * because it makes no sense to do so. So, a payload must also be specified 00332 * after the IE payload type. 00333 * 00334 * \return This returns the event that has been created. If there is an error 00335 * creating the event, NULL will be returned. 00336 * 00337 * Example usage: 00338 * 00339 * \code 00340 * if (!(event = ast_event_new(AST_EVENT_MWI, 00341 * AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox, 00342 * AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, new, 00343 * AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, old, 00344 * AST_EVENT_IE_END))) { 00345 * return; 00346 * } 00347 * \endcode 00348 * 00349 * This creates a MWI event with 3 information elements, a mailbox which is 00350 * a string, and the number of new and old messages, specified as integers. 00351 */ 00352 struct ast_event *ast_event_new(enum ast_event_type event_type, ...); 00353 00354 /*! 00355 * \brief Destroy an event 00356 * 00357 * \param event the event to destroy 00358 * 00359 * \return Nothing 00360 * 00361 * \note Events that have been queued should *not* be destroyed by the code that 00362 * created the event. It will be automatically destroyed after being 00363 * dispatched to the appropriate subscribers. 00364 */ 00365 void ast_event_destroy(struct ast_event *event); 00366 00367 /*! 00368 * \brief Queue an event 00369 * 00370 * \param event the event to be queued 00371 * 00372 * \retval zero success 00373 * \retval non-zero failure. Note that the caller of this function is 00374 * responsible for destroying the event in the case of a failure. 00375 * 00376 * This function queues an event to be dispatched to all of the appropriate 00377 * subscribers. This function will not block while the event is being 00378 * dispatched because the event is queued up for a dispatching thread 00379 * to handle. 00380 */ 00381 int ast_event_queue(struct ast_event *event); 00382 00383 /*! 00384 * \brief Queue and cache an event 00385 * 00386 * \param event the event to be queued and cached 00387 * 00388 * \details 00389 * The purpose of caching events is so that the core can retain the last known 00390 * information for events that represent some sort of state. That way, when 00391 * code needs to find out the current state, it can query the cache. 00392 * 00393 * The event API already knows which events can be cached and how to cache them. 00394 * 00395 * \retval 0 success 00396 * \retval non-zero failure. If failure is returned, the event must be destroyed 00397 * by the caller of this function. 00398 */ 00399 int ast_event_queue_and_cache(struct ast_event *event); 00400 00401 /*! 00402 * \brief Retrieve an event from the cache 00403 * 00404 * \param ast_event_type The type of event to retrieve from the cache 00405 * 00406 * The rest of the arguments to this function specify information elements to 00407 * match for retrieving events from the cache. They are specified in the form: 00408 * \code 00409 * <enum ast_event_ie_type>, [enum ast_event_ie_pltype, [payload] ] 00410 * \endcode 00411 * and must end with AST_EVENT_IE_END. 00412 * 00413 * If the ie_type specified is *not* AST_EVENT_IE_END, then it must be followed 00414 * by a valid IE payload type. If the payload type specified is 00415 * AST_EVENT_IE_PLTYPE_EXISTS, then the 3rd argument should not be provided. 00416 * Otherwise, a payload must also be specified. 00417 * 00418 * \return A reference to an event retrieved from the cache. If no event was 00419 * found that matches the specified criteria, then NULL will be returned. 00420 * 00421 * \note If more than one event in the cache matches the specified criteria, only 00422 * one will be returned, and it is undefined which one it will be. 00423 * 00424 * \note The caller of this function *must* call ast_event_destroy() on the 00425 * returned event after it is done using it. 00426 * 00427 * Example Usage: 00428 * 00429 * \code 00430 * event = ast_event_get_cached(AST_EVENT_MWI, 00431 * AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox, 00432 * AST_EVENT_IE_END); 00433 * \endcode 00434 * 00435 * This example will check for an MWI event in the cache that matches the 00436 * specified mailbox. This would be the way to find out the last known state 00437 * of a mailbox without having to poll the mailbox directly. 00438 */ 00439 struct ast_event *ast_event_get_cached(enum ast_event_type, ...); 00440 00441 /*! 00442 * \brief Append an information element that has a string payload 00443 * 00444 * \param event the event that the IE will be appended to 00445 * \param ie_type the type of IE to append 00446 * \param str The string for the payload of the IE 00447 * 00448 * \retval 0 success 00449 * \retval -1 failure 00450 * 00451 * The pointer to the event will get updated with the new location for the event 00452 * that now contains the appended information element. If the re-allocation of 00453 * the memory for this event fails, it will be set to NULL. 00454 */ 00455 int ast_event_append_ie_str(struct ast_event **event, enum ast_event_ie_type ie_type, 00456 const char *str); 00457 00458 /*! 00459 * \brief Append an information element that has an integer payload 00460 * 00461 * \param event the event that the IE will be appended to 00462 * \param ie_type the type of IE to append 00463 * \param data The integer for the payload of the IE 00464 * 00465 * \retval 0 success 00466 * \retval -1 failure 00467 * 00468 * The pointer to the event will get updated with the new location for the event 00469 * that now contains the appended information element. If the re-allocation of 00470 * the memory for this event fails, it will be set to NULL. 00471 */ 00472 int ast_event_append_ie_uint(struct ast_event **event, enum ast_event_ie_type ie_type, 00473 uint32_t data); 00474 00475 /*! 00476 * \brief Append an information element that has a bitflags payload 00477 * 00478 * \param event the event that the IE will be appended to 00479 * \param ie_type the type of IE to append 00480 * \param flags the flags that are the payload of the IE 00481 * 00482 * \retval 0 success 00483 * \retval -1 failure 00484 * \since 1.6.3 00485 * 00486 * The pointer to the event will get updated with the new location for the event 00487 * that now contains the appended information element. If the re-allocation of 00488 * the memory for this event fails, it will be set to NULL. 00489 */ 00490 int ast_event_append_ie_bitflags(struct ast_event **event, enum ast_event_ie_type ie_type, 00491 uint32_t bitflags); 00492 00493 /*! 00494 * \brief Append an information element that has a raw payload 00495 * 00496 * \param event the event that the IE will be appended to 00497 * \param ie_type the type of IE to append 00498 * \param data A pointer to the raw data for the payload of the IE 00499 * \param data_len The amount of data to copy into the payload 00500 * 00501 * \retval 0 success 00502 * \retval -1 failure 00503 * 00504 * The pointer to the event will get updated with the new location for the event 00505 * that now contains the appended information element. If the re-allocation of 00506 * the memory for this event fails, it will be set to NULL. 00507 */ 00508 int ast_event_append_ie_raw(struct ast_event **event, enum ast_event_ie_type ie_type, 00509 const void *data, size_t data_len); 00510 00511 /*! 00512 * \brief Get the value of an information element that has an integer payload 00513 * 00514 * \param event The event to get the IE from 00515 * \param ie_type the type of information element to retrieve 00516 * 00517 * \return This returns the payload of the information element with the given type. 00518 * However, an IE with a payload of 0, and the case where no IE is found 00519 * yield the same return value. 00520 */ 00521 uint32_t ast_event_get_ie_uint(const struct ast_event *event, enum ast_event_ie_type ie_type); 00522 00523 /*! 00524 * \brief Get the value of an information element that has a bitflags payload 00525 * 00526 * \param event The event to get the IE from 00527 * \param ie_type the type of information element to retrieve 00528 * 00529 * \return This returns the payload of the information element with the given type. 00530 * However, an IE with a payload of 0, and the case where no IE is found 00531 * yield the same return value. 00532 */ 00533 uint32_t ast_event_get_ie_bitflags(const struct ast_event *event, enum ast_event_ie_type ie_type); 00534 00535 /*! 00536 * \brief Get the value of an information element that has a string payload 00537 * 00538 * \param event The event to get the IE from 00539 * \param ie_type the type of information element to retrieve 00540 * 00541 * \return This returns the payload of the information element with the given type. 00542 * If the information element isn't found, NULL will be returned. 00543 */ 00544 const char *ast_event_get_ie_str(const struct ast_event *event, enum ast_event_ie_type ie_type); 00545 00546 /*! 00547 * \brief Get the hash for the string payload of an IE 00548 * 00549 * \param event The event to get the IE from 00550 * \param ie_type the type of information element to retrieve the hash for 00551 * 00552 * \return This function returns the hash value as calculated by ast_str_hash() 00553 * for the string payload. This is stored in the event to avoid 00554 * unnecessary string comparisons. 00555 */ 00556 uint32_t ast_event_get_ie_str_hash(const struct ast_event *event, enum ast_event_ie_type ie_type); 00557 00558 /*! 00559 * \brief Get the value of an information element that has a raw payload 00560 * 00561 * \param event The event to get the IE from 00562 * \param ie_type the type of information element to retrieve 00563 * 00564 * \return This returns the payload of the information element with the given type. 00565 * If the information element isn't found, NULL will be returned. 00566 */ 00567 const void *ast_event_get_ie_raw(const struct ast_event *event, enum ast_event_ie_type ie_type); 00568 00569 /*! 00570 * \brief Get the string representation of an information element type 00571 * 00572 * \param ie_type the information element type to get the string representation of 00573 * 00574 * \return the string representation of the information element type 00575 * \since 1.6.1 00576 */ 00577 const char *ast_event_get_ie_type_name(enum ast_event_ie_type ie_type); 00578 00579 /*! 00580 * \brief Get the payload type for a given information element type 00581 * 00582 * \param ie_type the information element type to get the payload type of 00583 * 00584 * \return the payload type for the provided IE type 00585 * \since 1.6.1 00586 */ 00587 enum ast_event_ie_pltype ast_event_get_ie_pltype(enum ast_event_ie_type ie_type); 00588 00589 /*! 00590 * \brief Get the type for an event 00591 * 00592 * \param event the event to get the type for 00593 * 00594 * \return the event type as represented by one of the values in the 00595 * ast_event_type enum 00596 */ 00597 enum ast_event_type ast_event_get_type(const struct ast_event *event); 00598 00599 /*! 00600 * \brief Get the string representation of the type of the given event 00601 * 00602 * \arg event the event to get the type of 00603 * 00604 * \return the string representation of the event type of the provided event 00605 * \since 1.6.1 00606 */ 00607 const char *ast_event_get_type_name(const struct ast_event *event); 00608 00609 /*! 00610 * \brief Convert a string into an event type 00611 * 00612 * \param str the string to convert 00613 * \param event_type an output parameter for the event type 00614 * 00615 * \retval 0 success 00616 * \retval non-zero failure 00617 * \since 1.6.1 00618 */ 00619 int ast_event_str_to_event_type(const char *str, enum ast_event_type *event_type); 00620 00621 /*! 00622 * \brief Convert a string to an IE type 00623 * 00624 * \param str the string to convert 00625 * \param ie_type an output parameter for the IE type 00626 * 00627 * \retval 0 success 00628 * \retval non-zero failure 00629 * \since 1.6.1 00630 */ 00631 int ast_event_str_to_ie_type(const char *str, enum ast_event_ie_type *ie_type); 00632 00633 /*! 00634 * \brief Get the size of an event 00635 * 00636 * \param event the event to get the size of 00637 * 00638 * \return the number of bytes contained in the event 00639 * \since 1.6.1 00640 */ 00641 size_t ast_event_get_size(const struct ast_event *event); 00642 00643 /*! 00644 * \brief Initialize an event iterator instance 00645 * 00646 * \param iterator The iterator instance to initialize 00647 * \param event The event that will be iterated through 00648 * 00649 * \return Nothing 00650 */ 00651 void ast_event_iterator_init(struct ast_event_iterator *iterator, const struct ast_event *event); 00652 00653 /*! 00654 * \brief Move iterator instance to next IE 00655 * 00656 * \param iterator The iterator instance 00657 * 00658 * \retval 0 on success 00659 * \retval -1 if end is reached 00660 */ 00661 int ast_event_iterator_next(struct ast_event_iterator *iterator); 00662 00663 /*! 00664 * \brief Get the type of the current IE in the iterator instance 00665 * 00666 * \param iterator The iterator instance 00667 * 00668 * \return the ie type as represented by one of the value sin the 00669 * ast_event_ie_type enum 00670 */ 00671 enum ast_event_ie_type ast_event_iterator_get_ie_type(struct ast_event_iterator *iterator); 00672 00673 /*! 00674 * \brief Get the value of the current IE in the iterator as an integer payload 00675 * 00676 * \param iterator The iterator instance 00677 * 00678 * \return This returns the payload of the information element as a uint. 00679 */ 00680 uint32_t ast_event_iterator_get_ie_uint(struct ast_event_iterator *iterator); 00681 00682 /*! 00683 * \brief Get the value of the current IE in the iterator as a bitflags payload 00684 * 00685 * \param iterator The iterator instance 00686 * 00687 * \return This returns the payload of the information element as bitflags. 00688 */ 00689 uint32_t ast_event_iterator_get_ie_bitflags(struct ast_event_iterator *iterator); 00690 00691 /*! 00692 * \brief Get the value of the current IE in the iterator as a string payload 00693 * 00694 * \param iterator The iterator instance 00695 * 00696 * \return This returns the payload of the information element as a string. 00697 */ 00698 const char *ast_event_iterator_get_ie_str(struct ast_event_iterator *iterator); 00699 00700 /*! 00701 * \brief Get the value of the current IE in the iterator instance that has a raw payload 00702 * 00703 * \param iterator The iterator instance 00704 * 00705 * \return This returns the payload of the information element as type raw. 00706 */ 00707 void *ast_event_iterator_get_ie_raw(struct ast_event_iterator *iterator); 00708 00709 #if defined(__cplusplus) || defined(c_plusplus) 00710 } 00711 #endif 00712 00713 #endif /* AST_EVENT_H */
1.5.6