summaryrefslogtreecommitdiff
path: root/include/asterisk
diff options
context:
space:
mode:
authorGeorge Joseph <gjoseph@digium.com>2017-01-19 08:05:36 -0700
committerGeorge Joseph <gjoseph@digium.com>2017-01-23 10:25:58 -0700
commit66916067236dc2f5cf54fadee33a5203d8716148 (patch)
tree963dec954768e5eb279af597ea3fc62d9b43af59 /include/asterisk
parente2da0021b99ace55a36ad5d1a497159a2d077025 (diff)
ari: Implement 'debug all' and request/response logging
The 'ari set debug' command has been enhanced to accept 'all' as an application name. This allows dumping of all apps even if an app hasn't registered yet. To accomplish this, a new global_debug global variable was added to res/stasis/app.c and new APIs were added to set and query the value. 'ari set debug' now displays requests and responses as well as events. This required refactoring the existing debug code. * The implementation for 'ari set debug' was moved from stasis/cli.{c,h} to ari/cli.{c,h}, and stasis/cli.{c,h} were deleted. * In order to print the body of incoming requests even if a request failed, the consumption of the body was moved from the ari stubs to ast_ari_callback in res_ari.c and the moustache templates were then regenerated. The body is now passed to ast_ari_invoke and then on to the handlers. This results in code savings since that template was inserted multiple times into all the stubs. An additional change was made to the ao2_str_container implementation to add partial key searching and a sort function. The existing cli code assumed it was already there when it wasn't so the tab completion was never working. Change-Id: Ief936f747ce47f1fb14035fbe61152cf766406bf (cherry picked from commit 1d890874f39a5a81b20da44358143ed9b54ab0fe)
Diffstat (limited to 'include/asterisk')
-rw-r--r--include/asterisk/ari.h14
-rw-r--r--include/asterisk/stasis_app.h50
2 files changed, 62 insertions, 2 deletions
diff --git a/include/asterisk/ari.h b/include/asterisk/ari.h
index 4019e94e3..865b4b00c 100644
--- a/include/asterisk/ari.h
+++ b/include/asterisk/ari.h
@@ -59,7 +59,8 @@ struct ast_ari_response;
typedef void (*stasis_rest_callback)(
struct ast_tcptls_session_instance *ser,
struct ast_variable *get_params, struct ast_variable *path_vars,
- struct ast_variable *headers, struct ast_ari_response *response);
+ struct ast_variable *headers, struct ast_json *body,
+ struct ast_ari_response *response);
/*!
* \brief Handler for a single RESTful path segment.
@@ -136,7 +137,7 @@ int ast_ari_remove_handler(struct stasis_rest_handlers *handler);
void ast_ari_invoke(struct ast_tcptls_session_instance *ser,
const char *uri, enum ast_http_method method,
struct ast_variable *get_params, struct ast_variable *headers,
- struct ast_ari_response *response);
+ struct ast_json *body, struct ast_ari_response *response);
/*!
* \internal
@@ -201,6 +202,15 @@ const char *ast_ari_websocket_session_id(
const struct ast_ari_websocket_session *session);
/*!
+ * \brief Get the remote address from an ARI WebSocket.
+ *
+ * \param session Session to write to.
+ * \return ast_sockaddr (does not have to be freed)
+ */
+struct ast_sockaddr *ast_ari_websocket_session_get_remote_addr(
+ struct ast_ari_websocket_session *session);
+
+/*!
* \brief The stock message to return when out of memory.
*
* The refcount is NOT bumped on this object, so ast_json_ref() if you want to
diff --git a/include/asterisk/stasis_app.h b/include/asterisk/stasis_app.h
index 137cbb945..e131833a9 100644
--- a/include/asterisk/stasis_app.h
+++ b/include/asterisk/stasis_app.h
@@ -903,6 +903,56 @@ int stasis_app_control_dial(struct stasis_app_control *control,
* allocated during the time that res_stasis was loaded.
*/
void stasis_app_control_shutdown(void);
+
+/*!
+ * \brief Enable/disable request/response and event logging on an application
+ *
+ * \param app The app to debug
+ * \param debug If non-zero, enable debugging. If zero, disable.
+ */
+void stasis_app_set_debug(struct stasis_app *app, int debug);
+
+/*!
+ * \brief Enable/disable request/response and event logging on an application
+ *
+ * \param app_name The app name to debug
+ * \param debug If non-zero, enable debugging. If zero, disable.
+ */
+void stasis_app_set_debug_by_name(const char *app_name, int debug);
+
+/*!
+ * \brief Get debug status of an application
+ *
+ * \param app The app to check
+ * \return The debug flag for the app || the global debug flag
+ */
+int stasis_app_get_debug(struct stasis_app *app);
+
+/*!
+ * \brief Get debug status of an application
+ *
+ * \param app_name The app_name to check
+ * \return The debug flag for the app || the global debug flag
+ */
+int stasis_app_get_debug_by_name(const char *app_name);
+
+/*!
+ * \brief Enable/disable request/response and event logging on all applications
+ *
+ * \param debug If non-zero, enable debugging. If zero, disable.
+ */
+void stasis_app_set_global_debug(int debug);
+
+struct ast_cli_args;
+
+/*!
+ * \brief Dump properties of a \c stasis_app to the CLI
+ *
+ * \param app The application
+ * \param a The CLI arguments
+ */
+void stasis_app_to_cli(const struct stasis_app *app, struct ast_cli_args *a);
+
/*! @} */
#endif /* _ASTERISK_STASIS_APP_H */