res_corosync: Update module to work with Stasis (and compile)
[asterisk/asterisk.git] / include / asterisk / event_defs.h
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2007 - 2008, Digium, Inc.
5  *
6  * Russell Bryant <russell@digium.com>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18
19 /*!
20  * \file
21  * \author Russell Bryant <russell@digium.com>
22  * \brief Generic event system
23  */
24
25 #ifndef AST_EVENT_DEFS_H
26 #define AST_EVENT_DEFS_H
27
28 enum ast_event_type {
29         /*! Reserved to provide the ability to subscribe to all events.  A specific
30          *  event should never have a payload of 0. */
31         AST_EVENT_ALL                 = 0x00,
32         /*! This event type is reserved for use by third-party modules to create
33          *  custom events without having to modify this file.
34          *  \note There are no "custom" IE types, because IEs only have to be
35          *  unique to the event itself, not necessarily across all events. */
36         AST_EVENT_CUSTOM              = 0x01,
37         /*! Voicemail message waiting indication */
38         AST_EVENT_MWI                 = 0x02,
39         /*! Someone has subscribed to events */
40         AST_EVENT_SUB                 = 0x03,
41         /*! Someone has unsubscribed from events */
42         AST_EVENT_UNSUB               = 0x04,
43         /*! The aggregate state of a device across all servers configured to be
44          *  a part of a device state cluster has changed. */
45         AST_EVENT_DEVICE_STATE        = 0x05,
46         /*! The state of a device has changed on _one_ server.  This should not be used
47          *  directly, in general.  Use AST_EVENT_DEVICE_STATE instead. */
48         AST_EVENT_DEVICE_STATE_CHANGE = 0x06,
49         /*! Channel Event Logging events */
50         AST_EVENT_CEL                 = 0x07,
51         /*! A report of a security related event (see security_events.h) */
52         AST_EVENT_SECURITY            = 0x08,
53         /*! Used by res_stun_monitor to alert listeners to an exernal network address change. */
54         AST_EVENT_NETWORK_CHANGE      = 0x09,
55         /*! The presence state for a presence provider */
56         AST_EVENT_PRESENCE_STATE      = 0x0a,
57         /*! Used to alert listeners when a named ACL has changed. */
58         AST_EVENT_ACL_CHANGE          = 0x0b,
59         /*! Send out a ping for debugging distributed events */
60         AST_EVENT_PING                = 0x0c,
61         /*! Number of event types.  This should be the last event type + 1 */
62         AST_EVENT_TOTAL               = 0x0d,
63 };
64
65 /*! \brief Event Information Element types */
66 enum ast_event_ie_type {
67         /*! Used to terminate the arguments to event functions */
68         AST_EVENT_IE_END                 = -1,
69
70         /*!
71          * \brief Number of new messages
72          * Used by: AST_EVENT_MWI
73          * Payload type: UINT
74          */
75         AST_EVENT_IE_NEWMSGS             = 0x0001,
76         /*!
77          * \brief Number of
78          * Used by: AST_EVENT_MWI
79          * Payload type: UINT
80          */
81         AST_EVENT_IE_OLDMSGS             = 0x0002,
82         /*!
83          * \brief Mailbox name \verbatim (mailbox[@context]) \endverbatim
84          * Used by: AST_EVENT_MWI 
85          * Payload type: STR
86          */
87         AST_EVENT_IE_MAILBOX             = 0x0003,
88         /*!
89          * \brief Unique ID
90          * Used by: AST_EVENT_SUB, AST_EVENT_UNSUB
91          * Payload type: UINT
92          */
93         AST_EVENT_IE_UNIQUEID            = 0x0004,
94         /*!
95          * \brief Event type
96          * Used by: AST_EVENT_SUB, AST_EVENT_UNSUB
97          * Payload type: UINT
98          */
99         AST_EVENT_IE_EVENTTYPE           = 0x0005,
100         /*!
101          * \brief Hint that someone cares that an IE exists
102          * Used by: AST_EVENT_SUB
103          * Payload type: UINT (ast_event_ie_type)
104          */
105         AST_EVENT_IE_EXISTS              = 0x0006,
106         /*!
107          * \brief Device Name
108          * Used by AST_EVENT_DEVICE_STATE_CHANGE
109          * Payload type: STR
110          */
111         AST_EVENT_IE_DEVICE              = 0x0007,
112         /*!
113          * \brief Generic State IE
114          * Used by AST_EVENT_DEVICE_STATE_CHANGE
115          * Payload type: UINT
116          * The actual state values depend on the event which
117          * this IE is a part of.
118          */
119          AST_EVENT_IE_STATE              = 0x0008,
120         /*!
121          * \brief Context IE
122          * Used by AST_EVENT_MWI
123          * Payload type: str
124          */
125          AST_EVENT_IE_CONTEXT            = 0x0009,
126         /*!
127          * \brief Channel Event Type
128          * Used by: AST_EVENT_CEL
129          * Payload type: UINT
130          */
131         AST_EVENT_IE_CEL_EVENT_TYPE      = 0x000a,
132         /*!
133          * \brief Channel Event Time (seconds)
134          * Used by: AST_EVENT_CEL
135          * Payload type: UINT
136          */
137         AST_EVENT_IE_CEL_EVENT_TIME      = 0x000b,
138         /*!
139          * \brief Channel Event Time (micro-seconds)
140          * Used by: AST_EVENT_CEL
141          * Payload type: UINT
142          */
143         AST_EVENT_IE_CEL_EVENT_TIME_USEC = 0x000c,
144         /*!
145          * \brief Channel Event User Event Name
146          * Used by: AST_EVENT_CEL
147          * Payload type: STR
148          */
149         AST_EVENT_IE_CEL_USEREVENT_NAME  = 0x000d,
150         /*!
151          * \brief Channel Event CID name
152          * Used by: AST_EVENT_CEL
153          * Payload type: STR
154          */
155         AST_EVENT_IE_CEL_CIDNAME         = 0x000e,
156         /*!
157          * \brief Channel Event CID num
158          * Used by: AST_EVENT_CEL
159          * Payload type: STR
160          */
161         AST_EVENT_IE_CEL_CIDNUM          = 0x000f,
162         /*!
163          * \brief Channel Event extension name
164          * Used by: AST_EVENT_CEL
165          * Payload type: STR
166          */
167         AST_EVENT_IE_CEL_EXTEN           = 0x0010,
168         /*!
169          * \brief Channel Event context name
170          * Used by: AST_EVENT_CEL
171          * Payload type: STR
172          */
173         AST_EVENT_IE_CEL_CONTEXT         = 0x0011,
174         /*!
175          * \brief Channel Event channel name
176          * Used by: AST_EVENT_CEL
177          * Payload type: STR
178          */
179         AST_EVENT_IE_CEL_CHANNAME        = 0x0012,
180         /*!
181          * \brief Channel Event app name
182          * Used by: AST_EVENT_CEL
183          * Payload type: STR
184          */
185         AST_EVENT_IE_CEL_APPNAME         = 0x0013,
186         /*!
187          * \brief Channel Event app args/data
188          * Used by: AST_EVENT_CEL
189          * Payload type: STR
190          */
191         AST_EVENT_IE_CEL_APPDATA         = 0x0014,
192         /*!
193          * \brief Channel Event AMA flags
194          * Used by: AST_EVENT_CEL
195          * Payload type: UINT
196          */
197         AST_EVENT_IE_CEL_AMAFLAGS        = 0x0015,
198         /*!
199          * \brief Channel Event AccountCode
200          * Used by: AST_EVENT_CEL
201          * Payload type: STR
202          */
203         AST_EVENT_IE_CEL_ACCTCODE        = 0x0016,
204         /*!
205          * \brief Channel Event UniqueID
206          * Used by: AST_EVENT_CEL
207          * Payload type: STR
208          */
209         AST_EVENT_IE_CEL_UNIQUEID        = 0x0017,
210         /*!
211          * \brief Channel Event Userfield
212          * Used by: AST_EVENT_CEL
213          * Payload type: STR
214          */
215         AST_EVENT_IE_CEL_USERFIELD       = 0x0018,
216         /*!
217          * \brief Channel Event CID ANI field
218          * Used by: AST_EVENT_CEL
219          * Payload type: STR
220          */
221         AST_EVENT_IE_CEL_CIDANI          = 0x0019,
222         /*!
223          * \brief Channel Event CID RDNIS field
224          * Used by: AST_EVENT_CEL
225          * Payload type: STR
226          */
227         AST_EVENT_IE_CEL_CIDRDNIS        = 0x001a,
228         /*!
229          * \brief Channel Event CID dnid
230          * Used by: AST_EVENT_CEL
231          * Payload type: STR
232          */
233         AST_EVENT_IE_CEL_CIDDNID         = 0x001b,
234         /*!
235          * \brief Channel Event Peer -- for Things involving multiple channels, like BRIDGE
236          * Used by: AST_EVENT_CEL
237          * Payload type: STR
238          */
239         AST_EVENT_IE_CEL_PEER            = 0x001c,
240         /*!
241          * \brief Channel Event LinkedID
242          * Used by: AST_EVENT_CEL
243          * Payload type: STR
244          */
245         AST_EVENT_IE_CEL_LINKEDID        = 0x001d,
246         /*!
247          * \brief Channel Event peeraccount
248          * Used by: AST_EVENT_CEL
249          * Payload type: STR
250          */
251         AST_EVENT_IE_CEL_PEERACCT        = 0x001e,
252         /*!
253          * \brief Channel Event extra data
254          * Used by: AST_EVENT_CEL
255          * Payload type: STR
256          */
257         AST_EVENT_IE_CEL_EXTRA           = 0x001f,
258         /*!
259          * \brief Description
260          * Used by: AST_EVENT_SUB, AST_EVENT_UNSUB
261          * Payload type: STR
262          */
263         AST_EVENT_IE_DESCRIPTION         = 0x0020,
264         /*!
265          * \brief Entity ID
266          * Used by All events
267          * Payload type: RAW
268          * This IE indicates which server the event originated from
269          */
270         AST_EVENT_IE_EID                 = 0x0021,
271         AST_EVENT_IE_SECURITY_EVENT      = 0x0022,
272         AST_EVENT_IE_EVENT_VERSION       = 0x0023,
273         AST_EVENT_IE_SERVICE             = 0x0024,
274         AST_EVENT_IE_MODULE              = 0x0025,
275         AST_EVENT_IE_ACCOUNT_ID          = 0x0026,
276         AST_EVENT_IE_SESSION_ID          = 0x0027,
277         AST_EVENT_IE_SESSION_TV          = 0x0028,
278         AST_EVENT_IE_ACL_NAME            = 0x0029,
279         AST_EVENT_IE_LOCAL_ADDR          = 0x002a,
280         AST_EVENT_IE_REMOTE_ADDR         = 0x002b,
281         AST_EVENT_IE_EVENT_TV            = 0x002c,
282         AST_EVENT_IE_REQUEST_TYPE        = 0x002d,
283         AST_EVENT_IE_REQUEST_PARAMS      = 0x002e,
284         AST_EVENT_IE_AUTH_METHOD         = 0x002f,
285         AST_EVENT_IE_SEVERITY            = 0x0030,
286         AST_EVENT_IE_EXPECTED_ADDR       = 0x0031,
287         AST_EVENT_IE_CHALLENGE           = 0x0032,
288         AST_EVENT_IE_RESPONSE            = 0x0033,
289         AST_EVENT_IE_EXPECTED_RESPONSE   = 0x0034,
290         AST_EVENT_IE_RECEIVED_CHALLENGE  = 0x0035,
291         AST_EVENT_IE_RECEIVED_HASH       = 0x0036,
292         AST_EVENT_IE_USING_PASSWORD      = 0x0037,
293         AST_EVENT_IE_ATTEMPTED_TRANSPORT = 0x0038,
294         AST_EVENT_IE_PRESENCE_PROVIDER   = 0x0039,
295         AST_EVENT_IE_PRESENCE_STATE      = 0x003a,
296         AST_EVENT_IE_PRESENCE_SUBTYPE    = 0x003b,
297         AST_EVENT_IE_PRESENCE_MESSAGE    = 0x003c,
298
299         /*!
300          * \brief Event non-cachability flag
301          * Used by: All events
302          * Payload type: UINT
303          */
304         AST_EVENT_IE_CACHABLE            = 0x003d,
305         /*! \brief Must be the last IE value +1 */
306         AST_EVENT_IE_TOTAL               = 0x003e,
307 };
308
309 /*!
310  * \brief Payload types for event information elements
311  */
312 enum ast_event_ie_pltype {
313         AST_EVENT_IE_PLTYPE_UNKNOWN = -1,
314         /*! Just check if it exists, not the value */
315         AST_EVENT_IE_PLTYPE_EXISTS,
316         /*! Unsigned Integer (Can be used for signed, too ...) */
317         AST_EVENT_IE_PLTYPE_UINT,
318         /*! String */
319         AST_EVENT_IE_PLTYPE_STR,
320         /*! Raw data, compared with memcmp */
321         AST_EVENT_IE_PLTYPE_RAW,
322         /*! Bit flags (unsigned integer, compared using boolean logic) */
323         AST_EVENT_IE_PLTYPE_BITFLAGS,
324 };
325
326 /*!
327  * \brief Results for checking for subscribers
328  *
329  * \ref ast_event_check_subscriber()
330  */
331 enum ast_event_subscriber_res {
332         /*! No subscribers exist */
333         AST_EVENT_SUB_NONE,
334         /*! At least one subscriber exists */
335         AST_EVENT_SUB_EXISTS,
336 };
337
338 struct ast_event;
339 struct ast_event_ie;
340 struct ast_event_iterator;
341
342 /*!
343  * \brief supposed to be an opaque type
344  *
345  * This is only here so that it can be declared on the stack.
346  */
347 struct ast_event_iterator {
348         uint16_t event_len;
349         const struct ast_event *event;
350         struct ast_event_ie *ie;
351 };
352
353 #endif /* AST_EVENT_DEFS_H */