Asterisk - The Open Source Telephony Project GIT-master-80b953f
Loading...
Searching...
No Matches
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 "13.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 */
111typedef 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 */
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*/
145int ast_hook_send_action(struct manager_custom_hook *hook, const char *msg);
146
147struct mansession;
148
149struct 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. */
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 AST_STRING_FIELD_EXTENDED(since); /*!< Documentation "since" element */
185 AST_STRING_FIELD_EXTENDED(provided_by); /*!< Documentation "provided_by" element */
186};
187
188/*! \brief External routines may register/unregister manager callbacks this way
189 * \note Use ast_manager_register2() to register with help text for new manager commands */
190#define ast_manager_register(action, authority, func, synopsis) ast_manager_register2(action, authority, func, AST_MODULE_SELF, synopsis, NULL)
191
192/*! \brief Register a manager callback using XML documentation to describe the manager. */
193#define ast_manager_register_xml(action, authority, func) ast_manager_register2(action, authority, func, AST_MODULE_SELF, NULL, NULL)
194
195/*!
196 * \brief Register a manager callback using XML documentation to describe the manager.
197 *
198 * \note For Asterisk core modules that are not independently
199 * loadable.
200 *
201 * \warning If you use ast_manager_register_xml() instead when
202 * you need to use this function, Asterisk will crash on load.
203 */
204#define ast_manager_register_xml_core(action, authority, func) ast_manager_register2(action, authority, func, NULL, NULL, NULL)
205
206/*!
207 * \brief Register a manager command with the manager interface
208 * \param action Name of the requested Action:
209 * \param authority Required authority for this command
210 * \param func Function to call for this command
211 * \param module The module containing func. (NULL if module is part of core and not loadable)
212 * \param synopsis Help text (one line, up to 30 chars) for CLI manager show commands
213 * \param description Help text, several lines
214 */
216 const char *action,
217 int authority,
218 int (*func)(struct mansession *s, const struct message *m),
219 struct ast_module *module,
220 const char *synopsis,
221 const char *description);
222
223/*!
224 * \brief Unregister a registered manager command
225 * \param action Name of registered Action:
226 */
227int ast_manager_unregister(const char *action);
228
229/*!
230 * \brief Verify a session's read permissions against a permission mask.
231 * \param ident session identity
232 * \param perm permission mask to verify
233 * \retval 1 if the session has the permission mask capabilities
234 * \retval 0 otherwise
235 */
236int astman_verify_session_readpermissions(uint32_t ident, int perm);
237
238/*!
239 * \brief Verify a session's write permissions against a permission mask.
240 * \param ident session identity
241 * \param perm permission mask to verify
242 * \retval 1 if the session has the permission mask capabilities, otherwise 0
243 * \retval 0 otherwise
244 */
245int astman_verify_session_writepermissions(uint32_t ident, int perm);
246
247/*! \brief External routines may send asterisk manager events this way
248 * \param category Event category, matches manager authorization
249 \param event Event name
250 \param contents Contents of event
251*/
252
253/* XXX the parser in gcc 2.95 gets confused if you don't put a space
254 * between the last arg before VA_ARGS and the comma */
255#define manager_event(category, event, contents , ...) \
256 __ast_manager_event_multichan(category, event, 0, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__)
257#define ast_manager_event(chan, category, event, contents , ...) \
258 do { \
259 struct ast_channel *_chans[] = { chan, }; \
260 __ast_manager_event_multichan(category, event, 1, _chans, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__); \
261 } while (0)
262#define ast_manager_event_multichan(category, event, nchans, chans, contents , ...) \
263 __ast_manager_event_multichan(category, event, nchans, chans, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__);
264
265/*! External routines may send asterisk manager events this way
266 * \param category Event category, matches manager authorization
267 * \param event Event name
268 * \param chancount Number of channels in chans parameter
269 * \param chans A pointer to an array of channels involved in the event
270 * \param file, line, func
271 * \param contents Format string describing event
272 * \param ...
273 * \since 1.8
274*/
275int __ast_manager_event_multichan(int category, const char *event, int chancount,
276 struct ast_channel **chans, const char *file, int line, const char *func,
277 const char *contents, ...) __attribute__((format(printf, 8, 9)));
278
279/*! \brief Get header from manager transaction */
280const char *astman_get_header(const struct message *m, char *var);
281
282/*! \brief Get a linked list of the Variable: headers
283 *
284 * \note Order of variables is reversed from the order they are specified in
285 * the manager message
286 */
287struct ast_variable *astman_get_variables(const struct message *m);
288
293
294/*! \brief Get a linked list of the Variable: headers with order specified */
296
297/*! \brief Send error in manager transaction */
298void astman_send_error(struct mansession *s, const struct message *m, char *error);
299
300/*! \brief Send error in manager transaction (with va_args support) */
301void __attribute__((format(printf, 3, 4))) astman_send_error_va(struct mansession *s, const struct message *m, const char *fmt, ...);
302
303/*! \brief Send response in manager transaction */
304void astman_send_response(struct mansession *s, const struct message *m, char *resp, char *msg);
305
306/*! \brief Send ack in manager transaction */
307void astman_send_ack(struct mansession *s, const struct message *m, char *msg);
308
309/*!
310 * \brief Send ack in manager transaction to begin a list.
311 *
312 * \param s - AMI session control struct.
313 * \param m - AMI action request that started the list.
314 * \param msg - Message contents describing the list to follow.
315 * \param listflag - Should always be set to "start".
316 *
317 * \note You need to call astman_send_list_complete_start() and
318 * astman_send_list_complete_end() to send the AMI list completion event.
319 */
320void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag);
321
322/*!
323 * \brief Start the list complete event.
324 * \since 13.2.0
325 *
326 * \param s - AMI session control struct.
327 * \param m - AMI action request that started the list.
328 * \param event_name - AMI list complete event name.
329 * \param count - Number of items in the list.
330 *
331 * \note You need to call astman_send_list_complete_end() to end
332 * the AMI list completion event.
333 *
334 * \note Between calling astman_send_list_complete_start() and
335 * astman_send_list_complete_end() you can add additonal headers
336 * using astman_append().
337 */
338void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count);
339
340/*!
341 * \brief End the list complete event.
342 * \since 13.2.0
343 *
344 * \param s - AMI session control struct.
345 *
346 * \note You need to call astman_send_list_complete_start() to start
347 * the AMI list completion event.
348 *
349 * \note Between calling astman_send_list_complete_start() and
350 * astman_send_list_complete_end() you can add additonal headers
351 * using astman_append().
352 */
354
355/*!
356 * \brief Enable/disable the inclusion of 'dangerous' configurations outside
357 * of the ast_config_AST_CONFIG_DIR
358 *
359 * This function can globally enable/disable the loading of configuration files
360 * outside of ast_config_AST_CONFIG_DIR.
361 *
362 * \param new_live_dangerously If true, enable the access of files outside
363 * ast_config_AST_CONFIG_DIR from astman.
364 */
365void astman_live_dangerously(int new_live_dangerously);
366
367void __attribute__((format(printf, 2, 3))) astman_append(struct mansession *s, const char *fmt, ...);
368
369/*! \brief Determine if a manager session ident is authenticated */
370int astman_is_authed(uint32_t ident);
371
372/*!
373 * \brief Add a datastore to a session
374 *
375 * \retval 0 success
376 * \retval non-zero failure
377 * \since 1.6.1
378 */
379
380int astman_datastore_add(struct mansession *s, struct ast_datastore *datastore);
381
382/*!
383 * \brief Remove a datastore from a session
384 *
385 * \retval 0 success
386 * \retval non-zero failure
387 * \since 1.6.1
388 */
389int astman_datastore_remove(struct mansession *s, struct ast_datastore *datastore);
390
391/*!
392 * \brief Find a datastore on a session
393 *
394 * \return pointer to the datastore if found
395 * \retval NULL if not found
396 * \since 1.6.1
397 */
398struct ast_datastore *astman_datastore_find(struct mansession *s, const struct ast_datastore_info *info, const char *uid);
399
400/*!
401 * \brief append an event header to an ast string
402 * \since 12
403 *
404 * \param fields_string pointer to an ast_string pointer. It may be a pointer to a
405 * NULL ast_str pointer, in which case the ast_str will be initialized.
406 * \param header The header being applied
407 * \param value the value of the header
408 *
409 * \retval 0 if successful
410 * \retval non-zero on failure
411 */
412int ast_str_append_event_header(struct ast_str **fields_string,
413 const char *header, const char *value);
414
415/*! \brief Struct representing a snapshot of channel state */
417
418/*!
419 * \brief Generate the AMI message body from a channel snapshot
420 * \since 12
421 *
422 * \param snapshot the channel snapshot for which to generate an AMI message
423 * body
424 * \param prefix What to prepend to the channel fields
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 const char *prefix);
432
433/*!
434 * \brief Generate the AMI message body from a channel snapshot
435 * \since 12
436 *
437 * \param snapshot the channel snapshot for which to generate an AMI message
438 * body
439 *
440 * \retval NULL on error
441 * \return ast_str* on success (must be ast_freed by caller)
442 */
444 const struct ast_channel_snapshot *snapshot);
445
446/*! \brief Struct representing a snapshot of bridge state */
448
449/*!
450 * \since 12
451 * \brief Callback used to determine whether a key should be skipped when converting a
452 * JSON object to a manager blob
453 * \param key Key from JSON blob to be evaluated
454 * \retval non-zero if the key should be excluded
455 * \retval zero if the key should not be excluded
456 */
457typedef int (*key_exclusion_cb)(const char *key);
458
459struct ast_json;
460
461/*!
462 * \since 12
463 * \brief Convert a JSON object into an AMI compatible string
464 *
465 * \param blob The JSON blob containing key/value pairs to convert
466 * \param exclusion_cb A \ref key_exclusion_cb pointer to a function that will exclude
467 * keys from the final AMI string
468 *
469 * \return A malloc'd \ref ast_str object. Callers of this function should free
470 * the returned \ref ast_str object
471 * \retval NULL on error
472 */
473struct ast_str *ast_manager_str_from_json_object(struct ast_json *blob, key_exclusion_cb exclusion_cb);
474
475/*!
476 * \brief Generate the AMI message body from a bridge snapshot
477 * \since 12
478 *
479 * \param snapshot the bridge snapshot for which to generate an AMI message
480 * body
481 * \param prefix What to prepend to the bridge fields
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 const char *prefix);
489
490/*!
491 * \brief Generate the AMI message body from a bridge snapshot
492 * \since 12
493 *
494 * \param snapshot the bridge snapshot for which to generate an AMI message
495 * body
496 *
497 * \retval NULL on error
498 * \return ast_str* on success (must be ast_freed by caller)
499 */
501 const struct ast_bridge_snapshot *snapshot);
502
503/*! \brief Struct containing info for an AMI event to send out. */
505 int event_flags; /*!< Flags the event should be raised with. */
506 const char *manager_event; /*!< The event to be raised, should be a string literal. */
508 AST_STRING_FIELD(extra_fields); /*!< Extra fields to include in the event. */
509 );
510};
511
512/*!
513 * \since 12
514 * \brief Construct a \ref ast_manager_event_blob.
515 *
516 * The returned object is AO2 managed, so clean up with ao2_cleanup().
517 *
518 * \param event_flags Flags the event should be raised with.
519 * \param manager_event The event to be raised, should be a string literal.
520 * \param extra_fields_fmt Format string for extra fields to include.
521 * Or NO_EXTRA_FIELDS for no extra fields.
522 *
523 * \return New \ref ast_manager_event_blob object.
524 * \retval NULL on error.
525 */
527__attribute__((format(printf, 3, 4)))
529 int event_flags,
530 const char *manager_event,
531 const char *extra_fields_fmt,
532 ...);
533
534/*! GCC warns about blank or NULL format strings. So, shenanigans! */
535#define NO_EXTRA_FIELDS "%s", ""
536
537/*!
538 * \since 12
539 * \brief Initialize support for AMI system events.
540 * \retval 0 on success
541 * \retval non-zero on error
542 */
543int manager_system_init(void);
544
545/*!
546 * \brief Initialize support for AMI channel events.
547 * \retval 0 on success.
548 * \retval non-zero on error.
549 * \since 12
550 */
551int manager_channels_init(void);
552
553/*!
554 * \since 12
555 * \brief Initialize support for AMI MWI events.
556 * \retval 0 on success
557 * \retval non-zero on error
558 */
559int manager_mwi_init(void);
560
561/*!
562 * \brief Initialize support for AMI channel events.
563 * \retval 0 on success.
564 * \retval non-zero on error.
565 * \since 12
566 */
567int manager_bridging_init(void);
568
569/*!
570 * \brief Initialize support for AMI endpoint events.
571 * \retval 0 on success.
572 * \retval non-zero on error.
573 * \since 12
574 */
575int manager_endpoints_init(void);
576
577/*!
578 * \since 12
579 * \brief Get the \ref stasis_message_type for generic messages
580 *
581 * A generic AMI message expects a JSON only payload. The payload must have the following
582 * structure:
583 * {type: s, class_type: i, event: [ {s: s}, ...] }
584 *
585 * - type is the AMI event type
586 * - class_type is the class authorization type for the event
587 * - event is a list of key/value tuples to be sent out in the message
588 *
589 * \return A \ref stasis_message_type for AMI messages
590 */
592
593/*!
594 * \since 12
595 * \brief Get the \ref stasis topic for AMI
596 *
597 * \return The \ref stasis topic for AMI
598 * \retval NULL on error
599 */
601
602/*!
603 * \since 12
604 * \brief Publish an event to AMI
605 *
606 * \param type The type of AMI event to publish
607 * \param class_type The class on which to publish the event
608 * \param obj The event data to be published.
609 *
610 * Publishes a message to the \ref stasis message bus solely for the consumption of AMI.
611 * The message will be of the type provided by \ref ast_manager_get_generic_type, and
612 * will be published to the topic provided by \ref ast_manager_get_topic. As such, the
613 * JSON must be constructed as defined by the \ref ast_manager_get_generic_type message.
614 */
615void ast_manager_publish_event(const char *type, int class_type, struct ast_json *obj);
616
617/*!
618 * \since 12
619 * \brief Get the \ref stasis_message_router for AMI
620 *
621 * \return The \ref stasis_message_router for AMI
622 * \retval NULL on error
623 */
625
626/*!
627 * \brief Callback used by ast_manager_hangup_helper
628 * that will actually hangup a channel
629 *
630 * \param chan The channel to hang up
631 * \param causecode Cause code to set on the channel
632 */
633typedef void (*manager_hangup_handler_t)(struct ast_channel *chan, int causecode);
634
635/*!
636 * \brief Callback used by ast_manager_hangup_helper
637 * that will validate the cause code.
638
639 * \param channel_name Mostly for displaying log messages
640 * \param cause Cause code string
641 *
642 * \returns integer cause code
643 */
644typedef int (*manager_hangup_cause_validator_t)(const char *channel_name,
645 const char *cause);
646
647/*!
648 * \brief A manager helper function that hangs up a channel using a supplied
649 * channel type specific hangup function and cause code validator
650 *
651 * This function handles the lookup of channel(s) and the AMI interaction
652 * but uses the supplied callbacks to actually perform the hangup. It can be
653 * used to implement a custom AMI 'Hangup' action without having to duplicate
654 * all the code in the standard Hangup action.
655 *
656 * \param s Session
657 * \param m Message
658 * \param handler Function that actually performs the hangup
659 * \param cause_validator Function that validates the cause code
660 *
661 * \retval 0 on success.
662 * \retval non-zero on error.
663 */
664int ast_manager_hangup_helper(struct mansession *s, const struct message *m,
666
667#endif /* _ASTERISK_MANAGER_H */
integer order
Definition analys.c:66
#define var
Definition ast_expr2f.c:605
static const char type[]
static int chancount
Definition channel.c:97
Asterisk datastore objects.
static char * synopsis
Definition func_enum.c:166
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:7679
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:2030
int ast_manager_check_enabled(void)
Check if AMI is enabled.
Definition manager.c:680
int ast_webmanager_check_enabled(void)
Check if AMI/HTTP is enabled.
Definition manager.c:685
void astman_send_response(struct mansession *s, const struct message *m, char *resp, char *msg)
Send response in manager transaction.
Definition manager.c:1983
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Definition manager.c:1988
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:1993
void ast_manager_publish_event(const char *type, int class_type, struct ast_json *obj)
Publish an event to AMI.
Definition manager.c:634
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:2066
struct stasis_message_router * ast_manager_get_message_router(void)
Get the stasis_message_router for AMI.
Definition manager.c:455
struct stasis_topic * ast_manager_get_topic(void)
Get the Stasis Message Bus API topic for AMI.
Definition manager.c:450
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
Definition manager.c:2020
struct ast_variable * astman_get_variables(const struct message *m)
Get a linked list of the Variable: headers.
Definition manager.c:1735
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:551
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:673
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:1740
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:665
const char * astman_get_header(const struct message *m, char *var)
Get header from manager transaction.
Definition manager.c:1649
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:7830
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
Definition manager.c:2074
void astman_append(struct mansession *s, const char *fmt,...)
Definition manager.c:1909
void astman_live_dangerously(int new_live_dangerously)
Enable/disable the inclusion of 'dangerous' configurations outside of the ast_config_AST_CONFIG_DIR.
Definition manager.c:2449
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:1766
int ast_manager_hangup_helper(struct mansession *s, const struct message *m, manager_hangup_handler_t handler, manager_hangup_cause_validator_t cause_validator)
A manager helper function that hangs up a channel using a supplied channel type specific hangup funct...
Definition manager.c:3427
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
Definition manager.c:7704
static char prefix[MAX_PREFIX]
Definition http.c:145
#define AST_RWLIST_ENTRY
Asterisk locking-related definitions:
int(* manager_hook_t)(int category, const char *event, char *body)
Manager Helper Function.
Definition manager.h:111
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
Definition manager.h:255
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_mwi_init(void)
Initialize support for AMI MWI events.
int astman_verify_session_writepermissions(uint32_t ident, int perm)
Verify a session's write permissions against a permission mask.
Definition manager.c:8063
int manager_bridging_init(void)
Initialize support for AMI channel events.
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:10121
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:10148
variable_orders
Definition manager.h:289
@ ORDER_NATURAL
Definition manager.h:290
@ ORDER_REVERSE
Definition manager.h:291
int astman_datastore_add(struct mansession *s, struct ast_datastore *datastore)
Add a datastore to a session.
Definition manager.c:10109
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.
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:10170
int astman_verify_session_readpermissions(uint32_t ident, int perm)
Verify a session's read permissions against a permission mask.
Definition manager.c:8030
int manager_endpoints_init(void)
Initialize support for AMI endpoint events.
void(* manager_hangup_handler_t)(struct ast_channel *chan, int causecode)
Callback used by ast_manager_hangup_helper that will actually hangup a channel.
Definition manager.h:633
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:457
struct stasis_message_type * ast_manager_get_generic_type(void)
Get the stasis_message_type for generic messages.
#define AST_MAX_MANHEADERS
Export manager structures.
Definition manager.h:100
int manager_system_init(void)
Initialize support for AMI system events.
int manager_channels_init(void)
Initialize support for AMI channel 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.
int astman_is_authed(uint32_t ident)
Determine if a manager session ident is authenticated.
Definition manager.c:8014
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_hangup_cause_validator_t)(const char *channel_name, const char *cause)
Callback used by ast_manager_hangup_helper that will validate the cause code.
Definition manager.h:644
int astman_datastore_remove(struct mansession *s, struct ast_datastore *datastore)
Remove a datastore from a session.
Definition manager.c:10116
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.
#define AST_STRING_FIELD(name)
Declare a string field.
Structure that contains a snapshot of information about a bridge.
Definition bridge.h:318
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:504
const char * manager_event
Definition manager.h:506
Support for dynamic strings.
Definition strings.h:623
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
struct ast_module *enum ast_doc_src docsrc
Definition manager.h:174
struct manager_action::@249 list
const ast_string_field description
Definition manager.h:163
struct ast_xml_doc_item * final_response
Definition manager.h:167
const ast_string_field synopsis
Definition manager.h:163
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
AST_STRING_FIELD_EXTENDED(since)
AST_STRING_FIELD_EXTENDED(provided_by)
struct manager_custom_hook::@248 list
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:323
unsigned int hdrcount
Definition manager.h:150
const char * headers[AST_MAX_MANHEADERS]
Definition manager.h:151
int value
Definition syslog.c:37
static void handler(const char *name, int response_code, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Definition test_ari.c:59
const char * contents
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