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