Asterisk - The Open Source Telephony Project GIT-master-7e7a603
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 "11.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};
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 */
225int 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 */
234int 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 */
243int 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*/
273int __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 */
278const 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 */
285struct ast_variable *astman_get_variables(const struct message *m);
286
291
292/*! \brief Get a linked list of the Variable: headers with order specified */
294
295/*! \brief Send error in manager transaction */
296void astman_send_error(struct mansession *s, const struct message *m, char *error);
297
298/*! \brief Send error in manager transaction (with va_args support) */
299void __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 */
302void astman_send_response(struct mansession *s, const struct message *m, char *resp, char *msg);
303
304/*! \brief Send ack in manager transaction */
305void 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 */
318void 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 */
336void 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/*!
354 * \brief Enable/disable the inclusion of 'dangerous' configurations outside
355 * of the ast_config_AST_CONFIG_DIR
356 *
357 * This function can globally enable/disable the loading of configuration files
358 * outside of ast_config_AST_CONFIG_DIR.
359 *
360 * \param new_live_dangerously If true, enable the access of files outside
361 * ast_config_AST_CONFIG_DIR from astman.
362 */
363void astman_live_dangerously(int new_live_dangerously);
364
365void __attribute__((format(printf, 2, 3))) astman_append(struct mansession *s, const char *fmt, ...);
366
367/*! \brief Determine if a manager session ident is authenticated */
368int astman_is_authed(uint32_t ident);
369
370/*!
371 * \brief Add a datastore to a session
372 *
373 * \retval 0 success
374 * \retval non-zero failure
375 * \since 1.6.1
376 */
377
378int astman_datastore_add(struct mansession *s, struct ast_datastore *datastore);
379
380/*!
381 * \brief Remove a datastore from a session
382 *
383 * \retval 0 success
384 * \retval non-zero failure
385 * \since 1.6.1
386 */
387int astman_datastore_remove(struct mansession *s, struct ast_datastore *datastore);
388
389/*!
390 * \brief Find a datastore on a session
391 *
392 * \return pointer to the datastore if found
393 * \retval NULL if not found
394 * \since 1.6.1
395 */
396struct ast_datastore *astman_datastore_find(struct mansession *s, const struct ast_datastore_info *info, const char *uid);
397
398/*!
399 * \brief append an event header to an ast string
400 * \since 12
401 *
402 * \param fields_string pointer to an ast_string pointer. It may be a pointer to a
403 * NULL ast_str pointer, in which case the ast_str will be initialized.
404 * \param header The header being applied
405 * \param value the value of the header
406 *
407 * \retval 0 if successful
408 * \retval non-zero on failure
409 */
410int ast_str_append_event_header(struct ast_str **fields_string,
411 const char *header, const char *value);
412
413/*! \brief Struct representing a snapshot of channel state */
415
416/*!
417 * \brief Generate the AMI message body from a channel snapshot
418 * \since 12
419 *
420 * \param snapshot the channel snapshot for which to generate an AMI message
421 * body
422 * \param prefix What to prepend to the channel fields
423 *
424 * \retval NULL on error
425 * \return ast_str* on success (must be ast_freed by caller)
426 */
428 const struct ast_channel_snapshot *snapshot,
429 const char *prefix);
430
431/*!
432 * \brief Generate the AMI message body from a channel snapshot
433 * \since 12
434 *
435 * \param snapshot the channel snapshot for which to generate an AMI message
436 * body
437 *
438 * \retval NULL on error
439 * \return ast_str* on success (must be ast_freed by caller)
440 */
442 const struct ast_channel_snapshot *snapshot);
443
444/*! \brief Struct representing a snapshot of bridge state */
446
447/*!
448 * \since 12
449 * \brief Callback used to determine whether a key should be skipped when converting a
450 * JSON object to a manager blob
451 * \param key Key from JSON blob to be evaluated
452 * \retval non-zero if the key should be excluded
453 * \retval zero if the key should not be excluded
454 */
455typedef int (*key_exclusion_cb)(const char *key);
456
457struct ast_json;
458
459/*!
460 * \since 12
461 * \brief Convert a JSON object into an AMI compatible string
462 *
463 * \param blob The JSON blob containing key/value pairs to convert
464 * \param exclusion_cb A \ref key_exclusion_cb pointer to a function that will exclude
465 * keys from the final AMI string
466 *
467 * \return A malloc'd \ref ast_str object. Callers of this function should free
468 * the returned \ref ast_str object
469 * \retval NULL on error
470 */
471struct ast_str *ast_manager_str_from_json_object(struct ast_json *blob, key_exclusion_cb exclusion_cb);
472
473/*!
474 * \brief Generate the AMI message body from a bridge snapshot
475 * \since 12
476 *
477 * \param snapshot the bridge snapshot for which to generate an AMI message
478 * body
479 * \param prefix What to prepend to the bridge fields
480 *
481 * \retval NULL on error
482 * \return ast_str* on success (must be ast_freed by caller)
483 */
485 const struct ast_bridge_snapshot *snapshot,
486 const char *prefix);
487
488/*!
489 * \brief Generate the AMI message body from a bridge snapshot
490 * \since 12
491 *
492 * \param snapshot the bridge snapshot for which to generate an AMI message
493 * body
494 *
495 * \retval NULL on error
496 * \return ast_str* on success (must be ast_freed by caller)
497 */
499 const struct ast_bridge_snapshot *snapshot);
500
501/*! \brief Struct containing info for an AMI event to send out. */
503 int event_flags; /*!< Flags the event should be raised with. */
504 const char *manager_event; /*!< The event to be raised, should be a string literal. */
506 AST_STRING_FIELD(extra_fields); /*!< Extra fields to include in the event. */
507 );
508};
509
510/*!
511 * \since 12
512 * \brief Construct a \ref ast_manager_event_blob.
513 *
514 * The returned object is AO2 managed, so clean up with ao2_cleanup().
515 *
516 * \param event_flags Flags the event should be raised with.
517 * \param manager_event The event to be raised, should be a string literal.
518 * \param extra_fields_fmt Format string for extra fields to include.
519 * Or NO_EXTRA_FIELDS for no extra fields.
520 *
521 * \return New \ref ast_manager_event_blob object.
522 * \retval NULL on error.
523 */
525__attribute__((format(printf, 3, 4)))
527 int event_flags,
528 const char *manager_event,
529 const char *extra_fields_fmt,
530 ...);
531
532/*! GCC warns about blank or NULL format strings. So, shenanigans! */
533#define NO_EXTRA_FIELDS "%s", ""
534
535/*!
536 * \since 12
537 * \brief Initialize support for AMI system events.
538 * \retval 0 on success
539 * \retval non-zero on error
540 */
541int manager_system_init(void);
542
543/*!
544 * \brief Initialize support for AMI channel events.
545 * \retval 0 on success.
546 * \retval non-zero on error.
547 * \since 12
548 */
549int manager_channels_init(void);
550
551/*!
552 * \since 12
553 * \brief Initialize support for AMI MWI events.
554 * \retval 0 on success
555 * \retval non-zero on error
556 */
557int manager_mwi_init(void);
558
559/*!
560 * \brief Initialize support for AMI channel events.
561 * \retval 0 on success.
562 * \retval non-zero on error.
563 * \since 12
564 */
565int manager_bridging_init(void);
566
567/*!
568 * \brief Initialize support for AMI endpoint events.
569 * \retval 0 on success.
570 * \retval non-zero on error.
571 * \since 12
572 */
573int manager_endpoints_init(void);
574
575/*!
576 * \since 12
577 * \brief Get the \ref stasis_message_type for generic messages
578 *
579 * A generic AMI message expects a JSON only payload. The payload must have the following
580 * structure:
581 * {type: s, class_type: i, event: [ {s: s}, ...] }
582 *
583 * - type is the AMI event type
584 * - class_type is the class authorization type for the event
585 * - event is a list of key/value tuples to be sent out in the message
586 *
587 * \return A \ref stasis_message_type for AMI messages
588 */
590
591/*!
592 * \since 12
593 * \brief Get the \ref stasis topic for AMI
594 *
595 * \return The \ref stasis topic for AMI
596 * \retval NULL on error
597 */
599
600/*!
601 * \since 12
602 * \brief Publish an event to AMI
603 *
604 * \param type The type of AMI event to publish
605 * \param class_type The class on which to publish the event
606 * \param obj The event data to be published.
607 *
608 * Publishes a message to the \ref stasis message bus solely for the consumption of AMI.
609 * The message will be of the type provided by \ref ast_manager_get_generic_type, and
610 * will be published to the topic provided by \ref ast_manager_get_topic. As such, the
611 * JSON must be constructed as defined by the \ref ast_manager_get_generic_type message.
612 */
613void ast_manager_publish_event(const char *type, int class_type, struct ast_json *obj);
614
615/*!
616 * \since 12
617 * \brief Get the \ref stasis_message_router for AMI
618 *
619 * \return The \ref stasis_message_router for AMI
620 * \retval NULL on error
621 */
623
624/*!
625 * \brief Callback used by ast_manager_hangup_helper
626 * that will actually hangup a channel
627 *
628 * \param chan The channel to hang up
629 * \param causecode Cause code to set on the channel
630 */
631typedef void (*manager_hangup_handler_t)(struct ast_channel *chan, int causecode);
632
633/*!
634 * \brief Callback used by ast_manager_hangup_helper
635 * that will validate the cause code.
636
637 * \param channel_name Mostly for displaying log messages
638 * \param cause Cause code string
639 *
640 * \returns integer cause code
641 */
642typedef int (*manager_hangup_cause_validator_t)(const char *channel_name,
643 const char *cause);
644
645/*!
646 * \brief A manager helper function that hangs up a channel using a supplied
647 * channel type specific hangup function and cause code validator
648 *
649 * This function handles the lookup of channel(s) and the AMI interaction
650 * but uses the supplied callbacks to actually perform the hangup. It can be
651 * used to implement a custom AMI 'Hangup' action without having to duplicate
652 * all the code in the standard Hangup action.
653 *
654 * \param s Session
655 * \param m Message
656 * \param handler Function that actually performs the hangup
657 * \param cause_validator Function that validates the cause code
658 *
659 * \retval 0 on success.
660 * \retval non-zero on error.
661 */
662int ast_manager_hangup_helper(struct mansession *s, const struct message *m,
664
665#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: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:8016
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:3423
int ast_manager_check_enabled(void)
Check if AMI is enabled.
Definition: manager.c:2101
int ast_webmanager_check_enabled(void)
Check if AMI/HTTP is enabled.
Definition: manager.c:2106
void astman_send_response(struct mansession *s, const struct message *m, char *resp, char *msg)
Send response in manager transaction.
Definition: manager.c:3376
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Definition: manager.c:3381
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:3386
void ast_manager_publish_event(const char *type, int class_type, struct ast_json *obj)
Publish an event to AMI.
Definition: manager.c:2055
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:3459
struct stasis_message_router * ast_manager_get_message_router(void)
Get the stasis_message_router for AMI.
Definition: manager.c:1877
struct stasis_topic * ast_manager_get_topic(void)
Get the Stasis Message Bus API topic for AMI.
Definition: manager.c:1872
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
Definition: manager.c:3413
struct ast_variable * astman_get_variables(const struct message *m)
Get a linked list of the Variable: headers.
Definition: manager.c:3128
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:1973
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:2094
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:3133
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:2086
const char * astman_get_header(const struct message *m, char *var)
Get header from manager transaction.
Definition: manager.c:3042
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:8167
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
Definition: manager.c:3467
void astman_append(struct mansession *s, const char *fmt,...)
Definition: manager.c:3302
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:3842
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:3159
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:4754
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
Definition: manager.c:8041
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:253
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:155
int astman_verify_session_writepermissions(uint32_t ident, int perm)
Verify a session's write permissions against a permission mask.
Definition: manager.c:8382
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:10499
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:10526
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:10487
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:10548
int astman_verify_session_readpermissions(uint32_t ident, int perm)
Verify a session's read permissions against a permission mask.
Definition: manager.c:8349
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:631
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:455
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:8333
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:642
int astman_datastore_remove(struct mansession *s, struct ast_datastore *datastore)
Remove a datastore from a session.
Definition: manager.c:10494
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:502
const char * manager_event
Definition: manager.h:504
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
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:1777
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