Sat Apr 26 2014 22:01:36

Asterisk developer's documentation


event_defs.h
Go to the documentation of this file.
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  * \brief Generic event system
00023  */
00024 
00025 #ifndef AST_EVENT_DEFS_H
00026 #define AST_EVENT_DEFS_H
00027 
00028 /*! \brief Event types
00029  * \note These values can *never* change. */
00030 enum ast_event_type {
00031    /*! Reserved to provide the ability to subscribe to all events.  A specific
00032     *  event should never have a payload of 0. */
00033    AST_EVENT_ALL                 = 0x00,
00034    /*! This event type is reserved for use by third-party modules to create
00035     *  custom events without having to modify this file. 
00036     *  \note There are no "custom" IE types, because IEs only have to be
00037     *  unique to the event itself, not necessarily across all events. */
00038    AST_EVENT_CUSTOM              = 0x01,
00039    /*! Voicemail message waiting indication */
00040    AST_EVENT_MWI                 = 0x02,
00041    /*! Someone has subscribed to events */
00042    AST_EVENT_SUB                 = 0x03,
00043    /*! Someone has unsubscribed from events */
00044    AST_EVENT_UNSUB               = 0x04,
00045    /*! The aggregate state of a device across all servers configured to be
00046     *  a part of a device state cluster has changed. */
00047    AST_EVENT_DEVICE_STATE        = 0x05,
00048    /*! The state of a device has changed on _one_ server.  This should not be used
00049     *  directly, in general.  Use AST_EVENT_DEVICE_STATE instead. */
00050    AST_EVENT_DEVICE_STATE_CHANGE = 0x06,
00051    /*! Channel Event Logging events */
00052    AST_EVENT_CEL                 = 0x07,
00053    /*! A report of a security related event (see security_events.h) */
00054    AST_EVENT_SECURITY            = 0x08,
00055    /*! Used by res_stun_monitor to alert listeners to an exernal network address change. */
00056    AST_EVENT_NETWORK_CHANGE      = 0x09,
00057    /*! The presence state for a presence provider */
00058    AST_EVENT_PRESENCE_STATE      = 0x0a,
00059    /*! Used to alert listeners when a named ACL has changed. */
00060    AST_EVENT_ACL_CHANGE          = 0x0b,
00061    /*! Send out a ping for debugging distributed events */
00062    AST_EVENT_PING                = 0x0c,
00063    /*! Number of event types.  This should be the last event type + 1 */
00064    AST_EVENT_TOTAL               = 0x0d,
00065 };
00066 
00067 /*! \brief Event Information Element types */
00068 enum ast_event_ie_type {
00069    /*! Used to terminate the arguments to event functions */
00070    AST_EVENT_IE_END                 = -1,
00071 
00072    /*! 
00073     * \brief Number of new messages
00074     * Used by: AST_EVENT_MWI 
00075     * Payload type: UINT
00076     */
00077    AST_EVENT_IE_NEWMSGS             = 0x0001,
00078    /*! 
00079     * \brief Number of
00080     * Used by: AST_EVENT_MWI 
00081     * Payload type: UINT
00082     */
00083    AST_EVENT_IE_OLDMSGS             = 0x0002,
00084    /*! 
00085     * \brief Mailbox name \verbatim (mailbox[@context]) \endverbatim
00086     * Used by: AST_EVENT_MWI 
00087     * Payload type: STR
00088     */
00089    AST_EVENT_IE_MAILBOX             = 0x0003,
00090    /*! 
00091     * \brief Unique ID
00092     * Used by: AST_EVENT_SUB, AST_EVENT_UNSUB
00093     * Payload type: UINT
00094     */
00095    AST_EVENT_IE_UNIQUEID            = 0x0004,
00096    /*! 
00097     * \brief Event type 
00098     * Used by: AST_EVENT_SUB, AST_EVENT_UNSUB
00099     * Payload type: UINT
00100     */
00101    AST_EVENT_IE_EVENTTYPE           = 0x0005,
00102    /*!
00103     * \brief Hint that someone cares that an IE exists
00104     * Used by: AST_EVENT_SUB
00105     * Payload type: UINT (ast_event_ie_type)
00106     */
00107    AST_EVENT_IE_EXISTS              = 0x0006,
00108    /*!
00109     * \brief Device Name
00110     * Used by AST_EVENT_DEVICE_STATE_CHANGE
00111     * Payload type: STR
00112     */
00113    AST_EVENT_IE_DEVICE              = 0x0007,
00114    /*!
00115     * \brief Generic State IE
00116     * Used by AST_EVENT_DEVICE_STATE_CHANGE
00117     * Payload type: UINT
00118     * The actual state values depend on the event which
00119     * this IE is a part of.
00120     */
00121     AST_EVENT_IE_STATE              = 0x0008,
00122     /*!
00123      * \brief Context IE
00124      * Used by AST_EVENT_MWI
00125      * Payload type: str
00126      */
00127     AST_EVENT_IE_CONTEXT            = 0x0009,
00128    /*! 
00129     * \brief Channel Event Type
00130     * Used by: AST_EVENT_CEL
00131     * Payload type: UINT
00132     */
00133    AST_EVENT_IE_CEL_EVENT_TYPE      = 0x000a,
00134    /*! 
00135     * \brief Channel Event Time (seconds)
00136     * Used by: AST_EVENT_CEL
00137     * Payload type: UINT
00138     */
00139    AST_EVENT_IE_CEL_EVENT_TIME      = 0x000b,
00140    /*! 
00141     * \brief Channel Event Time (micro-seconds)
00142     * Used by: AST_EVENT_CEL
00143     * Payload type: UINT
00144     */
00145    AST_EVENT_IE_CEL_EVENT_TIME_USEC = 0x000c,
00146    /*! 
00147     * \brief Channel Event User Event Name
00148     * Used by: AST_EVENT_CEL
00149     * Payload type: STR
00150     */
00151    AST_EVENT_IE_CEL_USEREVENT_NAME  = 0x000d,
00152    /*! 
00153     * \brief Channel Event CID name
00154     * Used by: AST_EVENT_CEL
00155     * Payload type: STR
00156     */
00157    AST_EVENT_IE_CEL_CIDNAME         = 0x000e,
00158    /*! 
00159     * \brief Channel Event CID num
00160     * Used by: AST_EVENT_CEL
00161     * Payload type: STR
00162     */
00163    AST_EVENT_IE_CEL_CIDNUM          = 0x000f,
00164    /*! 
00165     * \brief Channel Event extension name
00166     * Used by: AST_EVENT_CEL
00167     * Payload type: STR
00168     */
00169    AST_EVENT_IE_CEL_EXTEN           = 0x0010,
00170    /*! 
00171     * \brief Channel Event context name
00172     * Used by: AST_EVENT_CEL
00173     * Payload type: STR
00174     */
00175    AST_EVENT_IE_CEL_CONTEXT         = 0x0011,
00176    /*! 
00177     * \brief Channel Event channel name
00178     * Used by: AST_EVENT_CEL
00179     * Payload type: STR
00180     */
00181    AST_EVENT_IE_CEL_CHANNAME        = 0x0012,
00182    /*! 
00183     * \brief Channel Event app name
00184     * Used by: AST_EVENT_CEL
00185     * Payload type: STR
00186     */
00187    AST_EVENT_IE_CEL_APPNAME         = 0x0013,
00188    /*! 
00189     * \brief Channel Event app args/data
00190     * Used by: AST_EVENT_CEL
00191     * Payload type: STR
00192     */
00193    AST_EVENT_IE_CEL_APPDATA         = 0x0014,
00194    /*! 
00195     * \brief Channel Event AMA flags
00196     * Used by: AST_EVENT_CEL
00197     * Payload type: UINT
00198     */
00199    AST_EVENT_IE_CEL_AMAFLAGS        = 0x0015,
00200    /*! 
00201     * \brief Channel Event AccountCode
00202     * Used by: AST_EVENT_CEL
00203     * Payload type: STR
00204     */
00205    AST_EVENT_IE_CEL_ACCTCODE        = 0x0016,
00206    /*! 
00207     * \brief Channel Event UniqueID
00208     * Used by: AST_EVENT_CEL
00209     * Payload type: STR
00210     */
00211    AST_EVENT_IE_CEL_UNIQUEID        = 0x0017,
00212    /*! 
00213     * \brief Channel Event Userfield
00214     * Used by: AST_EVENT_CEL
00215     * Payload type: STR
00216     */
00217    AST_EVENT_IE_CEL_USERFIELD       = 0x0018,
00218    /*! 
00219     * \brief Channel Event CID ANI field
00220     * Used by: AST_EVENT_CEL
00221     * Payload type: STR
00222     */
00223    AST_EVENT_IE_CEL_CIDANI          = 0x0019,
00224    /*! 
00225     * \brief Channel Event CID RDNIS field
00226     * Used by: AST_EVENT_CEL
00227     * Payload type: STR
00228     */
00229    AST_EVENT_IE_CEL_CIDRDNIS        = 0x001a,
00230    /*! 
00231     * \brief Channel Event CID dnid
00232     * Used by: AST_EVENT_CEL
00233     * Payload type: STR
00234     */
00235    AST_EVENT_IE_CEL_CIDDNID         = 0x001b,
00236    /*! 
00237     * \brief Channel Event Peer -- for Things involving multiple channels, like BRIDGE
00238     * Used by: AST_EVENT_CEL
00239     * Payload type: STR
00240     */
00241    AST_EVENT_IE_CEL_PEER            = 0x001c,
00242    /*! 
00243     * \brief Channel Event LinkedID
00244     * Used by: AST_EVENT_CEL
00245     * Payload type: STR
00246     */
00247    AST_EVENT_IE_CEL_LINKEDID        = 0x001d,
00248    /*! 
00249     * \brief Channel Event peeraccount
00250     * Used by: AST_EVENT_CEL
00251     * Payload type: STR
00252     */
00253    AST_EVENT_IE_CEL_PEERACCT        = 0x001e,
00254    /*! 
00255     * \brief Channel Event extra data
00256     * Used by: AST_EVENT_CEL
00257     * Payload type: STR
00258     */
00259    AST_EVENT_IE_CEL_EXTRA           = 0x001f,
00260    /*!
00261     * \brief Description
00262     * Used by: AST_EVENT_SUB, AST_EVENT_UNSUB
00263     * Payload type: STR
00264     */
00265    AST_EVENT_IE_DESCRIPTION         = 0x0020,
00266    /*!
00267     * \brief Entity ID
00268     * Used by All events
00269     * Payload type: RAW
00270     * This IE indicates which server the event originated from
00271     */
00272    AST_EVENT_IE_EID                 = 0x0021,
00273    AST_EVENT_IE_SECURITY_EVENT      = 0x0022,
00274    AST_EVENT_IE_EVENT_VERSION       = 0x0023,
00275    AST_EVENT_IE_SERVICE             = 0x0024,
00276    AST_EVENT_IE_MODULE              = 0x0025,
00277    AST_EVENT_IE_ACCOUNT_ID          = 0x0026,
00278    AST_EVENT_IE_SESSION_ID          = 0x0027,
00279    AST_EVENT_IE_SESSION_TV          = 0x0028,
00280    AST_EVENT_IE_ACL_NAME            = 0x0029,
00281    AST_EVENT_IE_LOCAL_ADDR          = 0x002a,
00282    AST_EVENT_IE_REMOTE_ADDR         = 0x002b,
00283    AST_EVENT_IE_EVENT_TV            = 0x002c,
00284    AST_EVENT_IE_REQUEST_TYPE        = 0x002d,
00285    AST_EVENT_IE_REQUEST_PARAMS      = 0x002e,
00286    AST_EVENT_IE_AUTH_METHOD         = 0x002f,
00287    AST_EVENT_IE_SEVERITY            = 0x0030,
00288    AST_EVENT_IE_EXPECTED_ADDR       = 0x0031,
00289    AST_EVENT_IE_CHALLENGE           = 0x0032,
00290    AST_EVENT_IE_RESPONSE            = 0x0033,
00291    AST_EVENT_IE_EXPECTED_RESPONSE   = 0x0034,
00292    AST_EVENT_IE_RECEIVED_CHALLENGE  = 0x0035,
00293    AST_EVENT_IE_RECEIVED_HASH       = 0x0036,
00294    AST_EVENT_IE_USING_PASSWORD      = 0x0037,
00295    AST_EVENT_IE_ATTEMPTED_TRANSPORT = 0x0038,
00296    AST_EVENT_IE_PRESENCE_PROVIDER   = 0x0039,
00297    AST_EVENT_IE_PRESENCE_STATE      = 0x003a,
00298    AST_EVENT_IE_PRESENCE_SUBTYPE    = 0x003b,
00299    AST_EVENT_IE_PRESENCE_MESSAGE    = 0x003c,
00300 
00301    /*!
00302     * \brief Event non-cachability flag
00303     * Used by: All events
00304     * Payload type: UINT
00305     */
00306    AST_EVENT_IE_CACHABLE            = 0x003d,
00307    /*! \brief Must be the last IE value +1 */
00308    AST_EVENT_IE_TOTAL               = 0x003e,
00309 };
00310 
00311 /*!
00312  * \brief Payload types for event information elements
00313  */
00314 enum ast_event_ie_pltype {
00315    AST_EVENT_IE_PLTYPE_UNKNOWN = -1,
00316    /*! Just check if it exists, not the value */
00317    AST_EVENT_IE_PLTYPE_EXISTS,
00318    /*! Unsigned Integer (Can be used for signed, too ...) */
00319    AST_EVENT_IE_PLTYPE_UINT,
00320    /*! String */
00321    AST_EVENT_IE_PLTYPE_STR,
00322    /*! Raw data, compared with memcmp */
00323    AST_EVENT_IE_PLTYPE_RAW,
00324    /*! Bit flags (unsigned integer, compared using boolean logic) */
00325    AST_EVENT_IE_PLTYPE_BITFLAGS,
00326 };
00327 
00328 /*!
00329  * \brief Results for checking for subscribers
00330  *
00331  * \ref ast_event_check_subscriber()
00332  */
00333 enum ast_event_subscriber_res {
00334    /*! No subscribers exist */
00335    AST_EVENT_SUB_NONE,
00336    /*! At least one subscriber exists */
00337    AST_EVENT_SUB_EXISTS,
00338 };
00339 
00340 struct ast_event;
00341 struct ast_event_ie;
00342 struct ast_event_sub;
00343 struct ast_event_iterator;
00344 
00345 /*!
00346  * \brief supposed to be an opaque type
00347  *
00348  * This is only here so that it can be declared on the stack.
00349  */
00350 struct ast_event_iterator {
00351    uint16_t event_len;
00352    const struct ast_event *event;
00353    struct ast_event_ie *ie;
00354 };
00355 
00356 #endif /* AST_EVENT_DEFS_H */