Asterisk - The Open Source Telephony Project  18.5.0
event.c
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2007 - 2008, Digium, Inc.
5  *
6  * Russell Bryant <[email protected]>
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  *
21  * \brief Internal generic event system
22  *
23  * \author Russell Bryant <[email protected]>
24  */
25 
26 /*** MODULEINFO
27  <support_level>core</support_level>
28  ***/
29 
30 #include "asterisk.h"
31 
32 #include "asterisk/_private.h"
33 
34 #include "asterisk/event.h"
35 #include "asterisk/linkedlists.h"
36 #include "asterisk/dlinkedlists.h"
37 #include "asterisk/lock.h"
38 #include "asterisk/utils.h"
39 #include "asterisk/unaligned.h"
40 #include "asterisk/utils.h"
41 #include "asterisk/taskprocessor.h"
42 #include "asterisk/astobj2.h"
43 #include "asterisk/cli.h"
44 
45 /*!
46  * \brief An event information element
47  *
48  * \note The format of this structure is important. Since these events may
49  * be sent directly over a network, changing this structure will break
50  * compatibility with older versions. However, at this point, this code
51  * has not made it into a release, so it is still fair game for change.
52  */
53 struct ast_event_ie {
55  /*! Total length of the IE payload */
56  uint16_t ie_payload_len;
57  unsigned char ie_payload[0];
58 } __attribute__((packed));
59 
60 /*!
61  * \brief The payload for a string information element
62  */
64  /*! \brief A hash calculated with ast_str_hash(), to speed up comparisons */
65  uint32_t hash;
66  /*! \brief The actual string, null terminated */
67  char str[1];
68 } __attribute__((packed));
69 
70 /*!
71  * \brief An event
72  *
73  * An ast_event consists of an event header (this structure), and zero or
74  * more information elements defined by ast_event_ie.
75  *
76  * \note The format of this structure is important. Since these events may
77  * be sent directly over a network, changing this structure will break
78  * compatibility with older versions. However, at this point, this code
79  * has not made it into a release, so it is still fair game for change.
80  */
81 struct ast_event {
82  /*! Event type */
84  /*! Total length of the event */
85  uint16_t event_len:16;
86  /*! The data payload of the event, made up of information elements */
87  unsigned char payload[0];
88 } __attribute__((packed));
89 
90 
94  enum ast_event_ie_pltype ie_pltype;
95  union {
96  uint32_t uint;
97  struct {
98  uint32_t hash;
99  const char *str;
100  };
101  void *raw;
102  } payload;
103  size_t raw_datalen;
104 };
105 
106 /*!
107  * \brief Event Names
108  */
109 static const char * const event_names[AST_EVENT_TOTAL] = {
110  [AST_EVENT_ALL] = "All",
111  [AST_EVENT_CUSTOM] = "Custom",
112  [AST_EVENT_MWI] = "MWI",
113  [AST_EVENT_SUB] = "Subscription",
114  [AST_EVENT_UNSUB] = "Unsubscription",
115  [AST_EVENT_DEVICE_STATE] = "DeviceState",
116  [AST_EVENT_DEVICE_STATE_CHANGE] = "DeviceStateChange",
117  [AST_EVENT_CEL] = "CEL",
118  [AST_EVENT_SECURITY] = "Security",
119  [AST_EVENT_NETWORK_CHANGE] = "NetworkChange",
120  [AST_EVENT_PRESENCE_STATE] = "PresenceState",
121  [AST_EVENT_ACL_CHANGE] = "ACLChange",
122  [AST_EVENT_PING] = "Ping",
123 };
124 
125 /*!
126  * \brief IE payload types and names
127  */
128 static const struct ie_map {
129  enum ast_event_ie_pltype ie_pltype;
130  const char *name;
132  [AST_EVENT_IE_NEWMSGS] = { AST_EVENT_IE_PLTYPE_UINT, "NewMessages" },
133  [AST_EVENT_IE_OLDMSGS] = { AST_EVENT_IE_PLTYPE_UINT, "OldMessages" },
141  [AST_EVENT_IE_EID] = { AST_EVENT_IE_PLTYPE_RAW, "EntityID" },
145  [AST_EVENT_IE_CEL_USEREVENT_NAME] = { AST_EVENT_IE_PLTYPE_STR, "CELUserEventName" },
150  [AST_EVENT_IE_CEL_CHANNAME] = { AST_EVENT_IE_PLTYPE_STR, "CELChanName" },
154  [AST_EVENT_IE_CEL_ACCTCODE] = { AST_EVENT_IE_PLTYPE_STR, "CELAcctCode" },
155  [AST_EVENT_IE_CEL_UNIQUEID] = { AST_EVENT_IE_PLTYPE_STR, "CELUniqueID" },
156  [AST_EVENT_IE_CEL_USERFIELD] = { AST_EVENT_IE_PLTYPE_STR, "CELUserField" },
158  [AST_EVENT_IE_CEL_CIDRDNIS] = { AST_EVENT_IE_PLTYPE_STR, "CELCIDrdnis" },
161  [AST_EVENT_IE_CEL_LINKEDID] = { AST_EVENT_IE_PLTYPE_STR, "CELLinkedID" },
162  [AST_EVENT_IE_CEL_PEERACCT] = { AST_EVENT_IE_PLTYPE_STR, "CELPeerAcct" },
164  [AST_EVENT_IE_SECURITY_EVENT] = { AST_EVENT_IE_PLTYPE_UINT, "SecurityEvent" },
172  [AST_EVENT_IE_LOCAL_ADDR] = { AST_EVENT_IE_PLTYPE_STR, "LocalAddress" },
173  [AST_EVENT_IE_REMOTE_ADDR] = { AST_EVENT_IE_PLTYPE_STR, "RemoteAddress" },
175  [AST_EVENT_IE_REQUEST_TYPE] = { AST_EVENT_IE_PLTYPE_STR, "RequestType" },
176  [AST_EVENT_IE_REQUEST_PARAMS] = { AST_EVENT_IE_PLTYPE_STR, "RequestParams" },
179  [AST_EVENT_IE_EXPECTED_ADDR] = { AST_EVENT_IE_PLTYPE_STR, "ExpectedAddress" },
180  [AST_EVENT_IE_CHALLENGE] = { AST_EVENT_IE_PLTYPE_STR, "Challenge" },
182  [AST_EVENT_IE_EXPECTED_RESPONSE] = { AST_EVENT_IE_PLTYPE_STR, "ExpectedResponse" },
183  [AST_EVENT_IE_RECEIVED_CHALLENGE] = { AST_EVENT_IE_PLTYPE_STR, "ReceivedChallenge" },
184  [AST_EVENT_IE_RECEIVED_HASH] = { AST_EVENT_IE_PLTYPE_STR, "ReceivedHash" },
185  [AST_EVENT_IE_USING_PASSWORD] = { AST_EVENT_IE_PLTYPE_UINT, "UsingPassword" },
186  [AST_EVENT_IE_ATTEMPTED_TRANSPORT] = { AST_EVENT_IE_PLTYPE_STR, "AttemptedTransport" },
188  [AST_EVENT_IE_PRESENCE_PROVIDER] = { AST_EVENT_IE_PLTYPE_STR, "PresenceProvider" },
189  [AST_EVENT_IE_PRESENCE_STATE] = { AST_EVENT_IE_PLTYPE_UINT, "PresenceState" },
190  [AST_EVENT_IE_PRESENCE_SUBTYPE] = { AST_EVENT_IE_PLTYPE_STR, "PresenceSubtype" },
191  [AST_EVENT_IE_PRESENCE_MESSAGE] = { AST_EVENT_IE_PLTYPE_STR, "PresenceMessage" },
192 };
193 
194 const char *ast_event_get_type_name(const struct ast_event *event)
195 {
196  enum ast_event_type type;
197 
198  type = ast_event_get_type(event);
199 
200  if ((unsigned int)type >= ARRAY_LEN(event_names)) {
201  ast_log(LOG_ERROR, "Invalid event type - '%u'\n", type);
202  return "";
203  }
204 
205  return event_names[type];
206 }
207 
209 {
210  if (ie_type <= 0 || ie_type >= ARRAY_LEN(ie_maps)) {
211  ast_log(LOG_ERROR, "Invalid IE type - '%d'\n", ie_type);
212  return "";
213  }
214 
215  return ie_maps[ie_type].name;
216 }
217 
219 {
220  if (ie_type <= 0 || ie_type >= ARRAY_LEN(ie_maps)) {
221  ast_log(LOG_ERROR, "Invalid IE type - '%d'\n", ie_type);
223  }
224 
225  return ie_maps[ie_type].ie_pltype;
226 }
227 
228 size_t ast_event_get_size(const struct ast_event *event)
229 {
230  size_t res;
231 
232  res = ntohs(event->event_len);
233 
234  return res;
235 }
236 
237 /*! \brief Subscription event check list. */
240 };
241 
242 int ast_event_iterator_init(struct ast_event_iterator *iterator, const struct ast_event *event)
243 {
244  int res = 0;
245 
246  iterator->event_len = ast_event_get_size(event);
247  iterator->event = event;
248  if (iterator->event_len >= sizeof(*event) + sizeof(struct ast_event_ie)) {
249  iterator->ie = (struct ast_event_ie *) ( ((char *) event) + sizeof(*event) );
250  } else {
251  iterator->ie = NULL;
252  res = -1;
253  }
254 
255  return res;
256 }
257 
259 {
260  iterator->ie = (struct ast_event_ie *) ( ((char *) iterator->ie) + sizeof(*iterator->ie) + ntohs(iterator->ie->ie_payload_len));
261  return ((iterator->event_len <= (((char *) iterator->ie) - ((char *) iterator->event))) ? -1 : 0);
262 }
263 
265 {
266  return ntohs(iterator->ie->ie_type);
267 }
268 
270 {
271  return ntohl(get_unaligned_uint32(iterator->ie->ie_payload));
272 }
273 
275 {
276  const struct ast_event_ie_str_payload *str_payload;
277 
278  str_payload = (struct ast_event_ie_str_payload *) iterator->ie->ie_payload;
279 
280  return str_payload ? str_payload->str : NULL;
281 }
282 
283 static void *event_iterator_get_ie_raw(struct ast_event_iterator *iterator)
284 {
285  return iterator->ie->ie_payload;
286 }
287 
289 {
290  return ntohs(event->type);
291 }
292 
294 {
295  const uint32_t *ie_val;
296 
297  ie_val = ast_event_get_ie_raw(event, ie_type);
298 
299  return ie_val ? ntohl(get_unaligned_uint32(ie_val)) : 0;
300 }
301 
303 {
304  const struct ast_event_ie_str_payload *str_payload;
305 
306  str_payload = ast_event_get_ie_raw(event, ie_type);
307 
308  return str_payload ? str_payload->str : NULL;
309 }
310 
312 {
313  struct ast_event_iterator iterator;
314  int res;
315 
316  for (res = ast_event_iterator_init(&iterator, event); !res; res = ast_event_iterator_next(&iterator)) {
317  if (ast_event_iterator_get_ie_type(&iterator) == ie_type) {
318  return event_iterator_get_ie_raw(&iterator);
319  }
320  }
321 
322  return NULL;
323 }
324 
326 {
327  return ntohs(iterator->ie->ie_payload_len);
328 }
329 
331 {
332  struct ast_event_iterator iterator;
333  int res;
334 
335  for (res = ast_event_iterator_init(&iterator, event); !res; res = ast_event_iterator_next(&iterator)) {
336  if (ast_event_iterator_get_ie_type(&iterator) == ie_type) {
337  return event_iterator_get_ie_raw_payload_len(&iterator);
338  }
339  }
340 
341  return 0;
342 }
343 
344 
346  const char *str)
347 {
348  struct ast_event_ie_str_payload *str_payload;
349  size_t payload_len;
350 
351  payload_len = sizeof(*str_payload) + strlen(str);
352  str_payload = ast_alloca(payload_len);
353 
354  strcpy(str_payload->str, str);
355  str_payload->hash = ast_str_hash(str);
356 
357  return ast_event_append_ie_raw(event, ie_type, str_payload, payload_len);
358 }
359 
361  uint32_t data)
362 {
363  data = htonl(data);
364  return ast_event_append_ie_raw(event, ie_type, &data, sizeof(data));
365 }
366 
368  uint32_t flags)
369 {
370  flags = htonl(flags);
371  return ast_event_append_ie_raw(event, ie_type, &flags, sizeof(flags));
372 }
373 
375  const void *data, size_t data_len)
376 {
377  struct ast_event_ie *ie;
378  struct ast_event *old_event;
379  unsigned int extra_len;
380  uint16_t event_len;
381 
382  event_len = ntohs((*event)->event_len);
383  extra_len = sizeof(*ie) + data_len;
384 
385  old_event = *event;
386  *event = ast_realloc(*event, event_len + extra_len);
387  if (!*event) {
388  ast_free(old_event);
389  return -1;
390  }
391 
392  ie = (struct ast_event_ie *) ( ((char *) *event) + event_len );
393  ie->ie_type = htons(ie_type);
394  ie->ie_payload_len = htons(data_len);
395  memcpy(ie->ie_payload, data, data_len);
396 
397  (*event)->event_len = htons(event_len + extra_len);
398 
399  return 0;
400 }
401 
403 {
404  va_list ap;
405  struct ast_event *event;
407  struct ast_event_ie_val *ie_val;
409 
410  /* Invalid type */
411  if (type >= AST_EVENT_TOTAL) {
412  ast_log(LOG_WARNING, "Someone tried to create an event of invalid "
413  "type '%u'!\n", type);
414  return NULL;
415  }
416 
417  va_start(ap, type);
418  for (ie_type = va_arg(ap, enum ast_event_ie_type);
419  ie_type != AST_EVENT_IE_END;
420  ie_type = va_arg(ap, enum ast_event_ie_type))
421  {
422  struct ast_event_ie_val *ie_value = ast_malloc(sizeof(*ie_value));
423  int insert = 0;
424 
425  memset(ie_value, 0, sizeof(*ie_value));
426  ie_value->ie_type = ie_type;
427  ie_value->ie_pltype = va_arg(ap, enum ast_event_ie_pltype);
428 
429  switch (ie_value->ie_pltype) {
431  ie_value->payload.uint = va_arg(ap, uint32_t);
432  insert = 1;
433  break;
435  ie_value->payload.uint = va_arg(ap, uint32_t);
436  insert = 1;
437  break;
439  ie_value->payload.str = va_arg(ap, const char *);
440  insert = 1;
441  break;
443  {
444  void *data = va_arg(ap, void *);
445  size_t datalen = va_arg(ap, size_t);
446  ie_value->payload.raw = ast_malloc(datalen);
447  memcpy(ie_value->payload.raw, data, datalen);
448  ie_value->raw_datalen = datalen;
449  insert = 1;
450  break;
451  }
454  break;
455  }
456 
457  if (insert) {
458  AST_LIST_INSERT_TAIL(&ie_vals, ie_value, entry);
459  } else {
460  ast_log(LOG_WARNING, "Unsupported PLTYPE(%d)\n", ie_value->ie_pltype);
461  }
462  }
463  va_end(ap);
464 
465  if (!(event = ast_calloc(1, sizeof(*event)))) {
466  return NULL;
467  }
468 
469  event->type = htons(type);
470  event->event_len = htons(sizeof(*event));
471 
472  AST_LIST_TRAVERSE(&ie_vals, ie_val, entry) {
473  switch (ie_val->ie_pltype) {
475  ast_event_append_ie_str(&event, ie_val->ie_type, ie_val->payload.str);
476  break;
478  ast_event_append_ie_uint(&event, ie_val->ie_type, ie_val->payload.uint);
479  break;
481  ast_event_append_ie_bitflags(&event, ie_val->ie_type, ie_val->payload.uint);
482  break;
484  ast_event_append_ie_raw(&event, ie_val->ie_type,
485  ie_val->payload.raw, ie_val->raw_datalen);
486  break;
489  break;
490  }
491 
492  /* realloc inside one of the append functions failed */
493  if (!event) {
494  goto cleanup;
495  }
496  }
497 
498  if (!ast_event_get_ie_raw(event, AST_EVENT_IE_EID)) {
499  /* If the event is originating on this server, add the server's
500  * entity ID to the event. */
501  ast_event_append_eid(&event);
502  }
503 
504 cleanup:
505  AST_LIST_TRAVERSE_SAFE_BEGIN(&ie_vals, ie_val, entry) {
507 
508  if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_RAW) {
509  ast_free(ie_val->payload.raw);
510  }
511  ast_free(ie_val);
512  }
514 
515  return event;
516 }
517 
519 {
521  &ast_eid_default, sizeof(ast_eid_default));
522 }
523 
525 {
526  ast_free(event);
527 }
528 
530 {
531  return sizeof(struct ast_event);
532 }
const char * ast_event_iterator_get_ie_str(struct ast_event_iterator *iterator)
Get the value of the current IE in the iterator as a string payload.
Definition: event.c:274
static const char type[]
Definition: chan_ooh323.c:109
int ast_event_append_ie_uint(struct ast_event **event, enum ast_event_ie_type ie_type, uint32_t data)
Append an information element that has an integer payload.
Definition: event.c:360
Channel Event CID name Used by: AST_EVENT_CEL Payload type: STR.
Definition: event_defs.h:157
Channel Event app name Used by: AST_EVENT_CEL Payload type: STR.
Definition: event_defs.h:187
enum ast_event_ie_type ie_type
Definition: event.c:54
An event.
Definition: event.c:81
enum ast_event_type ast_event_get_type(const struct ast_event *event)
Get the type for an event.
Definition: event.c:288
Asterisk locking-related definitions:
struct ast_event_ie * ie
Definition: event_defs.h:359
Asterisk main include file. File version handling, generic pbx functions.
const char * ast_event_get_ie_type_name(enum ast_event_ie_type ie_type)
Get the string representation of an information element type.
Definition: event.c:208
#define ast_realloc(p, len)
A wrapper for realloc()
Definition: astmm.h:228
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
uint32_t hash
A hash calculated with ast_str_hash(), to speed up comparisons.
Definition: event.c:65
Channel Event extra data Used by: AST_EVENT_CEL Payload type: STR.
Definition: event_defs.h:259
ast_event_ie_pltype
Payload types for event information elements.
Definition: event_defs.h:321
enum ast_event_ie_pltype ie_pltype
Definition: event.c:94
uint16_t ie_payload_len
Definition: event.c:56
#define LOG_WARNING
Definition: logger.h:274
Must be the last IE value +1.
Definition: event_defs.h:315
Channel Event channel name Used by: AST_EVENT_CEL Payload type: STR.
Definition: event_defs.h:181
Hint that someone cares that an IE exists Used by: AST_EVENT_SUB Payload type: UINT (ast_event_ie_typ...
Definition: event_defs.h:107
Subscription event check list.
Definition: event.c:238
Channel Event UniqueID Used by: AST_EVENT_CEL Payload type: STR.
Definition: event_defs.h:211
Channel Event context name Used by: AST_EVENT_CEL Payload type: STR.
Definition: event_defs.h:175
uint32_t ast_event_iterator_get_ie_uint(struct ast_event_iterator *iterator)
Get the value of the current IE in the iterator as an integer payload.
Definition: event.c:269
Channel Event app args/data Used by: AST_EVENT_CEL Payload type: STR.
Definition: event_defs.h:193
Channel Event peeraccount Used by: AST_EVENT_CEL Payload type: STR.
Definition: event_defs.h:253
Channel Event Time (micro-seconds) Used by: AST_EVENT_CEL Payload type: UINT.
Definition: event_defs.h:145
Channel Event CID dnid Used by: AST_EVENT_CEL Payload type: STR.
Definition: event_defs.h:235
static uint16_t event_iterator_get_ie_raw_payload_len(struct ast_event_iterator *iterator)
Definition: event.c:325
enum ast_event_ie_pltype ast_event_get_ie_pltype(enum ast_event_ie_type ie_type)
Get the payload type for a given information element type.
Definition: event.c:218
Definition: astman.c:222
size_t raw_datalen
Definition: event.c:103
Number of new messages Used by: AST_EVENT_MWI Payload type: UINT.
Definition: event_defs.h:77
Number of Used by: AST_EVENT_MWI Payload type: UINT.
Definition: event_defs.h:83
const char * str
Definition: app_jack.c:147
char str[1]
The actual string, null terminated.
Definition: event.c:67
supposed to be an opaque type
Definition: event_defs.h:356
#define NULL
Definition: resample.c:96
static const char *const event_names[AST_EVENT_TOTAL]
Event Names.
Definition: event.c:109
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:614
Channel Event Type Used by: AST_EVENT_CEL Payload type: UINT.
Definition: event_defs.h:133
Entity ID Used by All events Payload type: RAW This IE indicates which server the event originated fr...
Definition: event_defs.h:272
uint32_t ast_event_get_ie_uint(const struct ast_event *event, enum ast_event_ie_type ie_type)
Get the value of an information element that has an integer payload.
Definition: event.c:293
Utility functions.
const char * str
Definition: event.c:99
Channel Event Time (seconds) Used by: AST_EVENT_CEL Payload type: UINT.
Definition: event_defs.h:139
Channel Event CID num Used by: AST_EVENT_CEL Payload type: STR.
Definition: event_defs.h:163
Channel Event extension name Used by: AST_EVENT_CEL Payload type: STR.
Definition: event_defs.h:169
int ast_event_append_ie_str(struct ast_event **event, enum ast_event_ie_type ie_type, const char *str)
Append an information element that has a string payload.
Definition: event.c:345
#define ast_log
Definition: astobj2.c:42
const void * ast_event_get_ie_raw(const struct ast_event *event, enum ast_event_ie_type ie_type)
Get the value of an information element that has a raw payload.
Definition: event.c:311
ast_event_ie_type
Event Information Element types.
Definition: event_defs.h:68
Handle unaligned data access.
ast_event_type
Definition: event_defs.h:28
Context IE Used by AST_EVENT_MWI Payload type: str.
Definition: event_defs.h:127
A set of macros to manage doubly-linked lists.
int ast_event_append_ie_bitflags(struct ast_event **event, enum ast_event_ie_type ie_type, uint32_t flags)
Append an information element that has a bitflags payload.
Definition: event.c:367
An event information element.
Definition: event.c:53
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:556
const char * name
Definition: event.c:130
const struct ast_event * event
Definition: event_defs.h:358
Channel Event Userfield Used by: AST_EVENT_CEL Payload type: STR.
Definition: event_defs.h:217
A set of macros to manage forward-linked lists.
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:193
AST_LIST_HEAD_NOLOCK(contactliststruct, contact)
Channel Event CID RDNIS field Used by: AST_EVENT_CEL Payload type: STR.
Definition: event_defs.h:229
static unsigned int get_unaligned_uint32(const void *p)
Definition: unaligned.h:38
Event non-cachability flag Used by: All events Payload type: UINT.
Definition: event_defs.h:306
static void * event_iterator_get_ie_raw(struct ast_event_iterator *iterator)
Definition: event.c:283
int ast_event_append_ie_raw(struct ast_event **event, enum ast_event_ie_type ie_type, const void *data, size_t data_len)
Append an information element that has a raw payload.
Definition: event.c:374
Event type Used by: AST_EVENT_SUB, AST_EVENT_UNSUB Payload type: UINT.
Definition: event_defs.h:101
int ast_event_iterator_init(struct ast_event_iterator *iterator, const struct ast_event *event)
Initialize an event iterator instance.
Definition: event.c:242
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:290
int ast_event_iterator_next(struct ast_event_iterator *iterator)
Move iterator instance to next IE.
Definition: event.c:258
#define AST_LIST_HEAD_NOLOCK_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
Definition: linkedlists.h:345
#define LOG_ERROR
Definition: logger.h:285
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:730
struct ast_event * ast_event_new(enum ast_event_type type,...)
Create a new event.
Definition: event.c:402
enum ast_event_ie_type ie_type
Definition: event.c:93
Channel Event User Event Name Used by: AST_EVENT_CEL Payload type: STR.
Definition: event_defs.h:151
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
Definition: linkedlists.h:409
void * raw
Definition: event.c:101
#define ast_free(a)
Definition: astmm.h:182
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
Channel Event Peer – for Things involving multiple channels, like BRIDGE Used by: AST_EVENT_CEL Payl...
Definition: event_defs.h:241
Channel Event CID ANI field Used by: AST_EVENT_CEL Payload type: STR.
Definition: event_defs.h:223
Prototypes for public functions only of internal interest,.
An API for managing task processing threads that can be shared across modules.
Channel Event AMA flags Used by: AST_EVENT_CEL Payload type: UINT.
Definition: event_defs.h:199
size_t ast_event_get_size(const struct ast_event *event)
Get the size of an event.
Definition: event.c:228
static void * cleanup(void *unused)
Definition: pbx_realtime.c:124
uint16_t event_len
Definition: event_defs.h:357
void ast_event_destroy(struct ast_event *event)
Destroy an event.
Definition: event.c:524
enum ast_event_type type
Definition: event.c:83
uint16_t event_len
Definition: event.c:85
struct ast_eid ast_eid_default
Global EID.
Definition: options.c:93
union ast_event_ie_val::@385 payload
Channel Event LinkedID Used by: AST_EVENT_CEL Payload type: STR.
Definition: event_defs.h:247
Standard Command Line Interface.
size_t ast_event_minimum_length(void)
Get the minimum length of an ast_event.
Definition: event.c:529
const char * ast_event_get_type_name(const struct ast_event *event)
Get the string representation of the type of the given event.
Definition: event.c:194
uint16_t ast_event_get_ie_raw_payload_len(const struct ast_event *event, enum ast_event_ie_type ie_type)
Get the length of the raw payload for a particular IE.
Definition: event.c:330
const char * ast_event_get_ie_str(const struct ast_event *event, enum ast_event_ie_type ie_type)
Get the value of an information element that has a string payload.
Definition: event.c:302
Unique ID Used by: AST_EVENT_SUB, AST_EVENT_UNSUB Payload type: UINT.
Definition: event_defs.h:95
Definition: search.h:40
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:528
uint32_t hash
Definition: event.c:98
enum ast_event_ie_pltype ie_pltype
Definition: event.c:129
Generic State IE Used by AST_EVENT_DEVICE_STATE_CHANGE Payload type: UINT The actual state values dep...
Definition: event_defs.h:121
static const struct ie_map ie_maps[AST_EVENT_IE_TOTAL]
Device Name Used by AST_EVENT_DEVICE_STATE_CHANGE Payload type: STR.
Definition: event_defs.h:113
IE payload types and names.
Definition: event.c:128
int ast_event_append_eid(struct ast_event **event)
Append the global EID IE.
Definition: event.c:518
uint32_t uint
Definition: event.c:96
Channel Event AccountCode Used by: AST_EVENT_CEL Payload type: STR.
Definition: event_defs.h:205
Mailbox name.
Definition: event_defs.h:89
unsigned char ie_payload[0]
Definition: event.c:57
enum ast_event_ie_type ast_event_iterator_get_ie_type(struct ast_event_iterator *iterator)
Get the type of the current IE in the iterator instance.
Definition: event.c:264
The payload for a string information element.
Definition: event.c:63
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
Definition: strings.h:1206