Asterisk - The Open Source Telephony Project  GIT-master-a24979a
manager.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2005, Digium, Inc.
5  *
6  * Mark Spencer <markster@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 #ifndef _ASTERISK_MANAGER_H
20 #define _ASTERISK_MANAGER_H
21 
22 #include "asterisk/network.h"
23 #include "asterisk/lock.h"
24 #include "asterisk/datastore.h"
25 #include "asterisk/xmldoc.h"
26 
27 /*!
28  \file
29  \brief The AMI - Asterisk Manager Interface - is a TCP protocol created to
30  manage Asterisk with third-party software.
31 
32  Manager protocol packages are text fields of the form a: b. There is
33  always exactly one space after the colon.
34 
35 \verbatim
36 
37  For Actions replies, the first line of the reply is a "Response:" header with
38  values "success", "error" or "follows". "Follows" implies that the
39  response is coming as separate events with the same ActionID. If the
40  Action request has no ActionID, it will be hard matching events
41  to the Action request in the manager client.
42 
43  The first header type is the "Event" header. Other headers vary from
44  event to event. Headers end with standard \\r\\n termination.
45  The last line of the manager response or event is an empty line.
46  (\\r\\n)
47 
48 \endverbatim
49 
50  \note Please try to \b re-use \b existing \b headers to simplify manager message parsing in clients.
51  Don't re-use an existing header with a new meaning, please.
52  You can find a reference of standard headers in doc/manager.txt
53 
54 - \ref manager.c Main manager code file
55  */
56 
57 #define AMI_VERSION "9.0.0"
58 #define DEFAULT_MANAGER_PORT 5038 /* Default port for Asterisk management via TCP */
59 #define DEFAULT_MANAGER_TLS_PORT 5039 /* Default port for Asterisk management via TCP */
60 
61 /*! \name Constant return values
62  * \note Currently, returning anything other than zero causes the session to terminate.
63  *
64  * @{
65  */
66 #define AMI_SUCCESS (0)
67 #define AMI_DESTROY (-1)
68 
69 /*! @} */
70 
71 /*! \name Manager event classes
72  *
73  * @{
74  */
75 #define EVENT_FLAG_SYSTEM (1 << 0) /* System events such as module load/unload */
76 #define EVENT_FLAG_CALL (1 << 1) /* Call event, such as state change, etc */
77 #define EVENT_FLAG_LOG (1 << 2) /* Log events */
78 #define EVENT_FLAG_VERBOSE (1 << 3) /* Verbose messages */
79 #define EVENT_FLAG_COMMAND (1 << 4) /* Ability to read/set commands */
80 #define EVENT_FLAG_AGENT (1 << 5) /* Ability to read/set agent info */
81 #define EVENT_FLAG_USER (1 << 6) /* Ability to read/set user info */
82 #define EVENT_FLAG_CONFIG (1 << 7) /* Ability to modify configurations */
83 #define EVENT_FLAG_DTMF (1 << 8) /* Ability to read DTMF events */
84 #define EVENT_FLAG_REPORTING (1 << 9) /* Reporting events such as rtcp sent */
85 #define EVENT_FLAG_CDR (1 << 10) /* CDR events */
86 #define EVENT_FLAG_DIALPLAN (1 << 11) /* Dialplan events (VarSet, NewExten) */
87 #define EVENT_FLAG_ORIGINATE (1 << 12) /* Originate a call to an extension */
88 #define EVENT_FLAG_AGI (1 << 13) /* AGI events */
89 #define EVENT_FLAG_HOOKRESPONSE (1 << 14) /* Hook Response */
90 #define EVENT_FLAG_CC (1 << 15) /* Call Completion events */
91 #define EVENT_FLAG_AOC (1 << 16) /* Advice Of Charge events */
92 #define EVENT_FLAG_TEST (1 << 17) /* Test event used to signal the Asterisk Test Suite */
93 #define EVENT_FLAG_SECURITY (1 << 18) /* Security Message as AMI Event */
94 /*XXX Why shifted by 30? XXX */
95 #define EVENT_FLAG_MESSAGE (1 << 30) /* MESSAGE events. */
96 
97 /*! @} */
98 
99 /*! \brief Export manager structures */
100 #define AST_MAX_MANHEADERS 128
101 
102 /*! \brief Manager Helper Function
103  *
104  * \param category The class authorization category of the event
105  * \param event The name of the event being raised
106  * \param body The body of the event
107  *
108  * \retval 0 Success
109  * \retval non-zero Error
110  */
111 typedef int (*manager_hook_t)(int category, const char *event, char *body);
112 
114  /*! Identifier */
115  char *file;
116  /*! helper function */
118  /*! Linked list information */
120 };
121 
122 /*! \brief Check if AMI is enabled */
123 int ast_manager_check_enabled(void);
124 
125 /*! \brief Check if AMI/HTTP is enabled */
127 
128 /*! Add a custom hook to be called when an event is fired
129  \param hook struct manager_custom_hook object to add
130 */
132 
133 /*! Delete a custom hook to be called when an event is fired
134  \param hook struct manager_custom_hook object to delete
135 */
137 
138 /*! \brief Registered hooks can call this function to invoke actions and they will receive responses through registered callback
139  * \param hook the file identifier specified in manager_custom_hook struct when registering a hook
140  * \param msg ami action mesage string e.g. "Action: SipPeers\r\n"
141 
142  * \retval 0 on Success
143  * \retval non-zero on Failure
144 */
145 int ast_hook_send_action(struct manager_custom_hook *hook, const char *msg);
146 
147 struct mansession;
148 
149 struct message {
150  unsigned int hdrcount;
152 };
153 
155  /*! Name of the action */
156  const char *action;
158  AST_STRING_FIELD(synopsis); /*!< Synopsis text (short description). */
159  AST_STRING_FIELD(description); /*!< Description (help text) */
160  AST_STRING_FIELD(syntax); /*!< Syntax text */
161  AST_STRING_FIELD(arguments); /*!< Description of each argument. */
162  AST_STRING_FIELD(seealso); /*!< See also */
163  );
164  /*! Possible list element response events. */
166  /*! Final response event. */
168  /*! Permission required for action. EVENT_FLAG_* */
170  /*! Function to be called */
171  int (*func)(struct mansession *s, const struct message *m);
172  struct ast_module *module; /*!< Module this action belongs to */
173  /*! Where the documentation come from. */
174  enum ast_doc_src docsrc;
175  /*! For easy linking */
177  /*!
178  * \brief TRUE if the AMI action is registered and the callback can be called.
179  *
180  * \note Needed to prevent a race between calling the callback
181  * function and unregistering the AMI action object.
182  */
183  unsigned int registered:1;
184 };
185 
186 /*! \brief External routines may register/unregister manager callbacks this way
187  * \note Use ast_manager_register2() to register with help text for new manager commands */
188 #define ast_manager_register(action, authority, func, synopsis) ast_manager_register2(action, authority, func, AST_MODULE_SELF, synopsis, NULL)
189 
190 /*! \brief Register a manager callback using XML documentation to describe the manager. */
191 #define ast_manager_register_xml(action, authority, func) ast_manager_register2(action, authority, func, AST_MODULE_SELF, NULL, NULL)
192 
193 /*!
194  * \brief Register a manager callback using XML documentation to describe the manager.
195  *
196  * \note For Asterisk core modules that are not independently
197  * loadable.
198  *
199  * \warning If you use ast_manager_register_xml() instead when
200  * you need to use this function, Asterisk will crash on load.
201  */
202 #define ast_manager_register_xml_core(action, authority, func) ast_manager_register2(action, authority, func, NULL, NULL, NULL)
203 
204 /*!
205  * \brief Register a manager command with the manager interface
206  * \param action Name of the requested Action:
207  * \param authority Required authority for this command
208  * \param func Function to call for this command
209  * \param module The module containing func. (NULL if module is part of core and not loadable)
210  * \param synopsis Help text (one line, up to 30 chars) for CLI manager show commands
211  * \param description Help text, several lines
212  */
214  const char *action,
215  int authority,
216  int (*func)(struct mansession *s, const struct message *m),
217  struct ast_module *module,
218  const char *synopsis,
219  const char *description);
220 
221 /*!
222  * \brief Unregister a registered manager command
223  * \param action Name of registered Action:
224  */
225 int ast_manager_unregister(const char *action);
226 
227 /*!
228  * \brief Verify a session's read permissions against a permission mask.
229  * \param ident session identity
230  * \param perm permission mask to verify
231  * \retval 1 if the session has the permission mask capabilities
232  * \retval 0 otherwise
233  */
234 int astman_verify_session_readpermissions(uint32_t ident, int perm);
235 
236 /*!
237  * \brief Verify a session's write permissions against a permission mask.
238  * \param ident session identity
239  * \param perm permission mask to verify
240  * \retval 1 if the session has the permission mask capabilities, otherwise 0
241  * \retval 0 otherwise
242  */
243 int astman_verify_session_writepermissions(uint32_t ident, int perm);
244 
245 /*! \brief External routines may send asterisk manager events this way
246  * \param category Event category, matches manager authorization
247  \param event Event name
248  \param contents Contents of event
249 */
250 
251 /* XXX the parser in gcc 2.95 gets confused if you don't put a space
252  * between the last arg before VA_ARGS and the comma */
253 #define manager_event(category, event, contents , ...) \
254  __ast_manager_event_multichan(category, event, 0, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__)
255 #define ast_manager_event(chan, category, event, contents , ...) \
256  do { \
257  struct ast_channel *_chans[] = { chan, }; \
258  __ast_manager_event_multichan(category, event, 1, _chans, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__); \
259  } while (0)
260 #define ast_manager_event_multichan(category, event, nchans, chans, contents , ...) \
261  __ast_manager_event_multichan(category, event, nchans, chans, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__);
262 
263 /*! External routines may send asterisk manager events this way
264  * \param category Event category, matches manager authorization
265  * \param event Event name
266  * \param chancount Number of channels in chans parameter
267  * \param chans A pointer to an array of channels involved in the event
268  * \param file, line, func
269  * \param contents Format string describing event
270  * \param ...
271  * \since 1.8
272 */
273 int __ast_manager_event_multichan(int category, const char *event, int chancount,
274  struct ast_channel **chans, const char *file, int line, const char *func,
275  const char *contents, ...) __attribute__((format(printf, 8, 9)));
276 
277 /*! \brief Get header from manager transaction */
278 const char *astman_get_header(const struct message *m, char *var);
279 
280 /*! \brief Get a linked list of the Variable: headers
281  *
282  * \note Order of variables is reversed from the order they are specified in
283  * the manager message
284  */
285 struct ast_variable *astman_get_variables(const struct message *m);
286 
290 };
291 
292 /*! \brief Get a linked list of the Variable: headers with order specified */
294 
295 /*! \brief Send error in manager transaction */
296 void astman_send_error(struct mansession *s, const struct message *m, char *error);
297 
298 /*! \brief Send error in manager transaction (with va_args support) */
299 void __attribute__((format(printf, 3, 4))) astman_send_error_va(struct mansession *s, const struct message *m, const char *fmt, ...);
300 
301 /*! \brief Send response in manager transaction */
302 void astman_send_response(struct mansession *s, const struct message *m, char *resp, char *msg);
303 
304 /*! \brief Send ack in manager transaction */
305 void astman_send_ack(struct mansession *s, const struct message *m, char *msg);
306 
307 /*!
308  * \brief Send ack in manager transaction to begin a list.
309  *
310  * \param s - AMI session control struct.
311  * \param m - AMI action request that started the list.
312  * \param msg - Message contents describing the list to follow.
313  * \param listflag - Should always be set to "start".
314  *
315  * \note You need to call astman_send_list_complete_start() and
316  * astman_send_list_complete_end() to send the AMI list completion event.
317  */
318 void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag);
319 
320 /*!
321  * \brief Start the list complete event.
322  * \since 13.2.0
323  *
324  * \param s - AMI session control struct.
325  * \param m - AMI action request that started the list.
326  * \param event_name - AMI list complete event name.
327  * \param count - Number of items in the list.
328  *
329  * \note You need to call astman_send_list_complete_end() to end
330  * the AMI list completion event.
331  *
332  * \note Between calling astman_send_list_complete_start() and
333  * astman_send_list_complete_end() you can add additonal headers
334  * using astman_append().
335  */
336 void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count);
337 
338 /*!
339  * \brief End the list complete event.
340  * \since 13.2.0
341  *
342  * \param s - AMI session control struct.
343  *
344  * \note You need to call astman_send_list_complete_start() to start
345  * the AMI list completion event.
346  *
347  * \note Between calling astman_send_list_complete_start() and
348  * astman_send_list_complete_end() you can add additonal headers
349  * using astman_append().
350  */
352 
353 void __attribute__((format(printf, 2, 3))) astman_append(struct mansession *s, const char *fmt, ...);
354 
355 /*! \brief Determine if a manager session ident is authenticated */
356 int astman_is_authed(uint32_t ident);
357 
358 /*!
359  * \brief Add a datastore to a session
360  *
361  * \retval 0 success
362  * \retval non-zero failure
363  * \since 1.6.1
364  */
365 
366 int astman_datastore_add(struct mansession *s, struct ast_datastore *datastore);
367 
368 /*!
369  * \brief Remove a datastore from a session
370  *
371  * \retval 0 success
372  * \retval non-zero failure
373  * \since 1.6.1
374  */
375 int astman_datastore_remove(struct mansession *s, struct ast_datastore *datastore);
376 
377 /*!
378  * \brief Find a datastore on a session
379  *
380  * \return pointer to the datastore if found
381  * \retval NULL if not found
382  * \since 1.6.1
383  */
384 struct ast_datastore *astman_datastore_find(struct mansession *s, const struct ast_datastore_info *info, const char *uid);
385 
386 /*!
387  * \brief append an event header to an ast string
388  * \since 12
389  *
390  * \param fields_string pointer to an ast_string pointer. It may be a pointer to a
391  * NULL ast_str pointer, in which case the ast_str will be initialized.
392  * \param header The header being applied
393  * \param value the value of the header
394  *
395  * \retval 0 if successful
396  * \retval non-zero on failure
397  */
398 int ast_str_append_event_header(struct ast_str **fields_string,
399  const char *header, const char *value);
400 
401 /*! \brief Struct representing a snapshot of channel state */
402 struct ast_channel_snapshot;
403 
404 /*!
405  * \brief Generate the AMI message body from a channel snapshot
406  * \since 12
407  *
408  * \param snapshot the channel snapshot for which to generate an AMI message
409  * body
410  * \param prefix What to prepend to the channel fields
411  *
412  * \retval NULL on error
413  * \return ast_str* on success (must be ast_freed by caller)
414  */
416  const struct ast_channel_snapshot *snapshot,
417  const char *prefix);
418 
419 /*!
420  * \brief Generate the AMI message body from a channel snapshot
421  * \since 12
422  *
423  * \param snapshot the channel snapshot for which to generate an AMI message
424  * body
425  *
426  * \retval NULL on error
427  * \return ast_str* on success (must be ast_freed by caller)
428  */
430  const struct ast_channel_snapshot *snapshot);
431 
432 /*! \brief Struct representing a snapshot of bridge state */
433 struct ast_bridge_snapshot;
434 
435 /*!
436  * \since 12
437  * \brief Callback used to determine whether a key should be skipped when converting a
438  * JSON object to a manager blob
439  * \param key Key from JSON blob to be evaluated
440  * \retval non-zero if the key should be excluded
441  * \retval zero if the key should not be excluded
442  */
443 typedef int (*key_exclusion_cb)(const char *key);
444 
445 struct ast_json;
446 
447 /*!
448  * \since 12
449  * \brief Convert a JSON object into an AMI compatible string
450  *
451  * \param blob The JSON blob containing key/value pairs to convert
452  * \param exclusion_cb A \ref key_exclusion_cb pointer to a function that will exclude
453  * keys from the final AMI string
454  *
455  * \return A malloc'd \ref ast_str object. Callers of this function should free
456  * the returned \ref ast_str object
457  * \retval NULL on error
458  */
459 struct ast_str *ast_manager_str_from_json_object(struct ast_json *blob, key_exclusion_cb exclusion_cb);
460 
461 /*!
462  * \brief Generate the AMI message body from a bridge snapshot
463  * \since 12
464  *
465  * \param snapshot the bridge snapshot for which to generate an AMI message
466  * body
467  * \param prefix What to prepend to the bridge fields
468  *
469  * \retval NULL on error
470  * \return ast_str* on success (must be ast_freed by caller)
471  */
473  const struct ast_bridge_snapshot *snapshot,
474  const char *prefix);
475 
476 /*!
477  * \brief Generate the AMI message body from a bridge snapshot
478  * \since 12
479  *
480  * \param snapshot the bridge snapshot for which to generate an AMI message
481  * body
482  *
483  * \retval NULL on error
484  * \return ast_str* on success (must be ast_freed by caller)
485  */
487  const struct ast_bridge_snapshot *snapshot);
488 
489 /*! \brief Struct containing info for an AMI event to send out. */
491  int event_flags; /*!< Flags the event should be raised with. */
492  const char *manager_event; /*!< The event to be raised, should be a string literal. */
494  AST_STRING_FIELD(extra_fields); /*!< Extra fields to include in the event. */
495  );
496 };
497 
498 /*!
499  * \since 12
500  * \brief Construct a \ref ast_manager_event_blob.
501  *
502  * The returned object is AO2 managed, so clean up with ao2_cleanup().
503  *
504  * \param event_flags Flags the event should be raised with.
505  * \param manager_event The event to be raised, should be a string literal.
506  * \param extra_fields_fmt Format string for extra fields to include.
507  * Or NO_EXTRA_FIELDS for no extra fields.
508  *
509  * \return New \ref ast_manager_event_blob object.
510  * \retval NULL on error.
511  */
512 struct ast_manager_event_blob *
513 __attribute__((format(printf, 3, 4)))
515  int event_flags,
516  const char *manager_event,
517  const char *extra_fields_fmt,
518  ...);
519 
520 /*! GCC warns about blank or NULL format strings. So, shenanigans! */
521 #define NO_EXTRA_FIELDS "%s", ""
522 
523 /*!
524  * \since 12
525  * \brief Initialize support for AMI system events.
526  * \retval 0 on success
527  * \retval non-zero on error
528  */
529 int manager_system_init(void);
530 
531 /*!
532  * \brief Initialize support for AMI channel events.
533  * \retval 0 on success.
534  * \retval non-zero on error.
535  * \since 12
536  */
537 int manager_channels_init(void);
538 
539 /*!
540  * \since 12
541  * \brief Initialize support for AMI MWI events.
542  * \retval 0 on success
543  * \retval non-zero on error
544  */
545 int manager_mwi_init(void);
546 
547 /*!
548  * \brief Initialize support for AMI channel events.
549  * \retval 0 on success.
550  * \retval non-zero on error.
551  * \since 12
552  */
553 int manager_bridging_init(void);
554 
555 /*!
556  * \brief Initialize support for AMI endpoint events.
557  * \retval 0 on success.
558  * \retval non-zero on error.
559  * \since 12
560  */
561 int manager_endpoints_init(void);
562 
563 /*!
564  * \since 12
565  * \brief Get the \ref stasis_message_type for generic messages
566  *
567  * A generic AMI message expects a JSON only payload. The payload must have the following
568  * structure:
569  * {type: s, class_type: i, event: [ {s: s}, ...] }
570  *
571  * - type is the AMI event type
572  * - class_type is the class authorization type for the event
573  * - event is a list of key/value tuples to be sent out in the message
574  *
575  * \return A \ref stasis_message_type for AMI messages
576  */
578 
579 /*!
580  * \since 12
581  * \brief Get the \ref stasis topic for AMI
582  *
583  * \return The \ref stasis topic for AMI
584  * \retval NULL on error
585  */
586 struct stasis_topic *ast_manager_get_topic(void);
587 
588 /*!
589  * \since 12
590  * \brief Publish an event to AMI
591  *
592  * \param type The type of AMI event to publish
593  * \param class_type The class on which to publish the event
594  * \param obj The event data to be published.
595  *
596  * Publishes a message to the \ref stasis message bus solely for the consumption of AMI.
597  * The message will be of the type provided by \ref ast_manager_get_generic_type, and
598  * will be published to the topic provided by \ref ast_manager_get_topic. As such, the
599  * JSON must be constructed as defined by the \ref ast_manager_get_generic_type message.
600  */
601 void ast_manager_publish_event(const char *type, int class_type, struct ast_json *obj);
602 
603 /*!
604  * \since 12
605  * \brief Get the \ref stasis_message_router for AMI
606  *
607  * \return The \ref stasis_message_router for AMI
608  * \retval NULL on error
609  */
611 
612 #endif /* _ASTERISK_MANAGER_H */
integer order
Definition: analys.c:66
#define var
Definition: ast_expr2f.c:614
static snd_pcm_format_t format
Definition: chan_alsa.c:106
static const char type[]
Definition: chan_ooh323.c:109
static int chancount
Definition: channel.c:93
Asterisk datastore objects.
static char * synopsis
Definition: func_enum.c:154
int __ast_manager_event_multichan(int category, const char *event, int chancount, struct ast_channel **chans, const char *file, int line, const char *func, const char *contents,...)
Definition: manager.c:7234
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager transaction to begin a list.
Definition: manager.c:3208
int ast_manager_check_enabled(void)
Check if AMI is enabled.
Definition: manager.c:1956
struct ast_variable * astman_get_variables(const struct message *m)
Get a linked list of the Variable: headers.
Definition: manager.c:2913
int ast_webmanager_check_enabled(void)
Check if AMI/HTTP is enabled.
Definition: manager.c:1961
void astman_send_response(struct mansession *s, const struct message *m, char *resp, char *msg)
Send response in manager transaction.
Definition: manager.c:3161
struct ast_str * ast_manager_str_from_json_object(struct ast_json *blob, key_exclusion_cb exclusion_cb)
Convert a JSON object into an AMI compatible string.
Definition: manager.c:1828
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Definition: manager.c:3166
void astman_send_error_va(struct mansession *s, const struct message *m, const char *fmt,...)
Send error in manager transaction (with va_args support)
Definition: manager.c:3171
void ast_manager_publish_event(const char *type, int class_type, struct ast_json *obj)
Publish an event to AMI.
Definition: manager.c:1910
struct stasis_topic * ast_manager_get_topic(void)
Get the Stasis Message Bus API topic for AMI.
Definition: manager.c:1727
void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count)
Start the list complete event.
Definition: manager.c:3244
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
Definition: manager.c:3198
void ast_manager_unregister_hook(struct manager_custom_hook *hook)
Delete a custom hook to be called when an event is fired.
Definition: manager.c:1949
void ast_manager_register_hook(struct manager_custom_hook *hook)
Add a custom hook to be called when an event is fired.
Definition: manager.c:1941
struct ast_variable * astman_get_variables_order(const struct message *m, enum variable_orders order)
Get a linked list of the Variable: headers with order specified.
Definition: manager.c:2918
int ast_manager_register2(const char *action, int authority, int(*func)(struct mansession *s, const struct message *m), struct ast_module *module, const char *synopsis, const char *description)
Register a manager command with the manager interface.
Definition: manager.c:7394
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
Definition: manager.c:3252
void astman_append(struct mansession *s, const char *fmt,...)
Definition: manager.c:3087
const char * astman_get_header(const struct message *m, char *var)
Get header from manager transaction.
Definition: manager.c:2827
int ast_hook_send_action(struct manager_custom_hook *hook, const char *msg)
Registered hooks can call this function to invoke actions and they will receive responses through reg...
Definition: manager.c:2944
struct stasis_message_router * ast_manager_get_message_router(void)
Get the stasis_message_router for AMI.
Definition: manager.c:1732
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
Definition: manager.c:7268
static char prefix[MAX_PREFIX]
Definition: http.c:144
#define AST_RWLIST_ENTRY
Definition: linkedlists.h:415
Asterisk locking-related definitions:
int(* manager_hook_t)(int category, const char *event, char *body)
Manager Helper Function.
Definition: manager.h:111
struct ast_datastore * astman_datastore_find(struct mansession *s, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a session.
Definition: manager.c:9711
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
Definition: manager.h:253
int manager_mwi_init(void)
Initialize support for AMI MWI events.
Definition: manager_mwi.c:155
int astman_verify_session_writepermissions(uint32_t ident, int perm)
Verify a session's write permissions against a permission mask.
Definition: manager.c:7609
struct ast_manager_event_blob * ast_manager_event_blob_create(int event_flags, const char *manager_event, const char *extra_fields_fmt,...)
Construct a ast_manager_event_blob.
Definition: manager.c:9760
int manager_bridging_init(void)
Initialize support for AMI channel events.
int ast_str_append_event_header(struct ast_str **fields_string, const char *header, const char *value)
append an event header to an ast string
Definition: manager.c:9738
variable_orders
Definition: manager.h:287
@ ORDER_NATURAL
Definition: manager.h:288
@ ORDER_REVERSE
Definition: manager.h:289
int astman_datastore_add(struct mansession *s, struct ast_datastore *datastore)
Add a datastore to a session.
Definition: manager.c:9699
int astman_verify_session_readpermissions(uint32_t ident, int perm)
Verify a session's read permissions against a permission mask.
Definition: manager.c:7576
struct ast_str * ast_manager_build_channel_state_string(const struct ast_channel_snapshot *snapshot)
Generate the AMI message body from a channel snapshot.
int manager_endpoints_init(void)
Initialize support for AMI endpoint events.
struct ast_str * ast_manager_build_bridge_state_string(const struct ast_bridge_snapshot *snapshot)
Generate the AMI message body from a bridge snapshot.
struct stasis_message_type * ast_manager_get_generic_type(void)
Get the stasis_message_type for generic messages.
int(* key_exclusion_cb)(const char *key)
Callback used to determine whether a key should be skipped when converting a JSON object to a manager...
Definition: manager.h:443
#define AST_MAX_MANHEADERS
Export manager structures.
Definition: manager.h:100
int manager_system_init(void)
Initialize support for AMI system events.
struct ast_str * ast_manager_build_channel_state_string_prefix(const struct ast_channel_snapshot *snapshot, const char *prefix)
Generate the AMI message body from a channel snapshot.
int manager_channels_init(void)
Initialize support for AMI channel events.
int astman_is_authed(uint32_t ident)
Determine if a manager session ident is authenticated.
Definition: manager.c:7560
struct ast_str * ast_manager_build_bridge_state_string_prefix(const struct ast_bridge_snapshot *snapshot, const char *prefix)
Generate the AMI message body from a bridge snapshot.
int astman_datastore_remove(struct mansession *s, struct ast_datastore *datastore)
Remove a datastore from a session.
Definition: manager.c:9706
def info(msg)
Wrapper for network related headers, masking differences between various operating systems....
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
Definition: stringfields.h:341
#define AST_STRING_FIELD(name)
Declare a string field.
Definition: stringfields.h:303
Structure that contains a snapshot of information about a bridge.
Definition: bridge.h:314
Structure representing a snapshot of channel state.
Main Channel structure associated with a channel.
Structure for a data store type.
Definition: datastore.h:31
Structure for a data store object.
Definition: datastore.h:64
Abstract JSON element (object, array, string, int, ...).
Struct containing info for an AMI event to send out.
Definition: manager.h:490
const char * manager_event
Definition: manager.h:492
Support for dynamic strings.
Definition: strings.h:604
Structure for variables, used for configurations and for channel variables.
Struct that contains the XML documentation for a particular item. Note that this is an ao2 ref counte...
Definition: xmldoc.h:56
Definition: astman.c:88
Definition: astman.c:222
const ast_string_field description
Definition: manager.h:163
struct ast_module * module
Definition: manager.h:172
struct ast_xml_doc_item * final_response
Definition: manager.h:167
const ast_string_field synopsis
Definition: manager.h:163
enum ast_doc_src docsrc
Definition: manager.h:174
int(* func)(struct mansession *s, const struct message *m)
Definition: manager.h:171
const char * action
Definition: manager.h:156
const ast_string_field seealso
Definition: manager.h:163
const ast_string_field syntax
Definition: manager.h:163
unsigned int registered
TRUE if the AMI action is registered and the callback can be called.
Definition: manager.h:183
const ast_string_field arguments
Definition: manager.h:163
struct ast_xml_doc_item * list_responses
Definition: manager.h:165
manager_hook_t helper
Definition: manager.h:117
In case you didn't read that giant block of text above the mansession_session struct,...
Definition: manager.c:1632
unsigned int hdrcount
Definition: manager.h:150
const char * headers[AST_MAX_MANHEADERS]
Definition: manager.h:151
int value
Definition: syslog.c:37
const char * contents
int error(const char *format,...)
Definition: utils/frame.c:999
Asterisk XML Documentation API.
ast_doc_src
From where the documentation come from, this structure is useful for use it inside application/functi...
Definition: xmldoc.h:30