event_defs.h 10.0 KB

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