Merge "ari: Implement 'debug all' and request/response logging"

This commit is contained in:
George Joseph
2017-01-26 17:06:40 -06:00
committed by Gerrit Code Review
28 changed files with 527 additions and 1157 deletions

View File

@@ -121,6 +121,14 @@ res_pjsip_endpoint_identifier_ip
source IP addresses for requests. This is configurable using the
"srv_lookups" option on the identify and defaults to "yes".
ARI
------------------
* 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.
* 'ari set debug' now displays requests and responses as well as events.
------------------------------------------------------------------------------
--- Functionality changes from Asterisk 14.1.0 to Asterisk 14.2.0 ------------
------------------------------------------------------------------------------

View File

@@ -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
@@ -200,6 +201,15 @@ int ast_ari_websocket_session_write(struct ast_ari_websocket_session *session,
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.
*

View File

@@ -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 */

View File

@@ -184,15 +184,32 @@ static int str_hash(const void *obj, const int flags)
return ast_str_hash(obj);
}
static int str_sort(const void *lhs, const void *rhs, int flags)
{
if ((flags & OBJ_SEARCH_MASK) == OBJ_SEARCH_PARTIAL_KEY) {
return strncmp(lhs, rhs, strlen(rhs));
} else {
return strcmp(lhs, rhs);
}
}
static int str_cmp(void *lhs, void *rhs, int flags)
{
return strcmp(lhs, rhs) ? 0 : CMP_MATCH;
int cmp = 0;
if ((flags & OBJ_SEARCH_MASK) == OBJ_SEARCH_PARTIAL_KEY) {
cmp = strncmp(lhs, rhs, strlen(rhs));
} else {
cmp = strcmp(lhs, rhs);
}
return cmp ? 0 : CMP_MATCH;
}
//struct ao2_container *ast_str_container_alloc_options(enum ao2_container_opts opts, int buckets)
struct ao2_container *ast_str_container_alloc_options(enum ao2_alloc_opts opts, int buckets)
{
return ao2_container_alloc_options(opts, buckets, str_hash, str_cmp);
return ao2_container_alloc_hash(opts, 0, buckets, str_hash, str_sort, str_cmp);
}
int ast_str_container_add(struct ao2_container *str_container, const char *add)

View File

@@ -21,6 +21,7 @@
#include "asterisk/ari.h"
#include "asterisk/astobj2.h"
#include "asterisk/http_websocket.h"
#include "asterisk/stasis_app.h"
#include "internal.h"
/*! \file
@@ -137,6 +138,7 @@ struct ast_json *ast_ari_websocket_session_read(
ast_log(LOG_WARNING,
"WebSocket input failed to parse\n");
}
break;
default:
/* Ignore all other message types */
@@ -172,16 +174,20 @@ int ast_ari_websocket_session_write(struct ast_ari_websocket_session *session,
return -1;
}
#ifdef AST_DEVMODE
ast_debug(3, "Examining ARI event (length %u): \n%s\n", (unsigned int) strlen(str), str);
#endif
if (ast_websocket_write_string(session->ws_session, str)) {
ast_log(LOG_NOTICE, "Problem occurred during websocket write, websocket closed\n");
ast_log(LOG_NOTICE, "Problem occurred during websocket write to %s, websocket closed\n",
ast_sockaddr_stringify(ast_ari_websocket_session_get_remote_addr(session)));
return -1;
}
return 0;
}
struct ast_sockaddr *ast_ari_websocket_session_get_remote_addr(
struct ast_ari_websocket_session *session)
{
return ast_websocket_remote_address(session->ws_session);
}
void ari_handle_websocket(struct ast_websocket_server *ws_server,
struct ast_tcptls_session_instance *ser, const char *uri,
enum ast_http_method method, struct ast_variable *get_params,

View File

@@ -26,6 +26,7 @@
#include "asterisk/astobj2.h"
#include "asterisk/cli.h"
#include "asterisk/stasis_app.h"
#include "internal.h"
static char *ari_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
@@ -249,11 +250,185 @@ static char *ari_mkpasswd(struct ast_cli_entry *e, int cmd, struct ast_cli_args
return CLI_SUCCESS;
}
static char *ari_show_apps(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct ao2_container *apps;
struct ao2_iterator it_apps;
char *app;
switch (cmd) {
case CLI_INIT:
e->command = "ari show apps";
e->usage =
"Usage: ari show apps\n"
" Lists all registered applications.\n"
;
return NULL;
case CLI_GENERATE:
return NULL;
default:
break;
}
if (a->argc != 3) {
return CLI_SHOWUSAGE;
}
apps = stasis_app_get_all();
if (!apps) {
ast_cli(a->fd, "Unable to retrieve registered applications!\n");
return CLI_FAILURE;
}
ast_cli(a->fd, "Application Name \n");
ast_cli(a->fd, "=========================\n");
it_apps = ao2_iterator_init(apps, 0);
while ((app = ao2_iterator_next(&it_apps))) {
ast_cli(a->fd, "%-25.25s\n", app);
ao2_ref(app, -1);
}
ao2_iterator_destroy(&it_apps);
ao2_ref(apps, -1);
return CLI_SUCCESS;
}
struct app_complete {
/*! Nth app to search for */
int state;
/*! Which app currently on */
int which;
};
static int complete_ari_app_search(void *obj, void *arg, void *data, int flags)
{
struct app_complete *search = data;
if (++search->which > search->state) {
return CMP_MATCH;
}
return 0;
}
static char *complete_ari_app(struct ast_cli_args *a, int include_all)
{
RAII_VAR(struct ao2_container *, apps, stasis_app_get_all(), ao2_cleanup);
RAII_VAR(char *, app, NULL, ao2_cleanup);
struct app_complete search = {
.state = a->n,
};
if (a->pos != 3) {
return NULL;
}
if (!apps) {
ast_cli(a->fd, "Error getting ARI applications\n");
return CLI_FAILURE;
}
if (include_all && ast_strlen_zero(a->word)) {
ast_str_container_add(apps, " all");
}
app = ao2_callback_data(apps,
ast_strlen_zero(a->word) ? 0 : OBJ_SEARCH_PARTIAL_KEY,
complete_ari_app_search, (char*)a->word, &search);
return app ? ast_strdup(app) : NULL;
}
static char *ari_show_app(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
void *app;
switch (cmd) {
case CLI_INIT:
e->command = "ari show app";
e->usage =
"Usage: ari show app <application>\n"
" Provide detailed information about a registered application.\n"
;
return NULL;
case CLI_GENERATE:
return complete_ari_app(a, 0);
default:
break;
}
if (a->argc != 4) {
return CLI_SHOWUSAGE;
}
app = stasis_app_get_by_name(a->argv[3]);
if (!app) {
return CLI_FAILURE;
}
stasis_app_to_cli(app, a);
ao2_ref(app, -1);
return CLI_SUCCESS;
}
static char *ari_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
void *app;
int debug;
switch (cmd) {
case CLI_INIT:
e->command = "ari set debug";
e->usage =
"Usage: ari set debug <application|all> <on|off>\n"
" Enable or disable debugging on a specific application.\n"
;
return NULL;
case CLI_GENERATE:
return complete_ari_app(a, 1);
default:
break;
}
if (a->argc != 5) {
return CLI_SHOWUSAGE;
}
debug = !strcmp(a->argv[4], "on");
if (!strcmp(a->argv[3], "all")) {
stasis_app_set_global_debug(debug);
ast_cli(a->fd, "Debugging on all applications %s\n",
debug ? "enabled" : "disabled");
return CLI_SUCCESS;
}
app = stasis_app_get_by_name(a->argv[3]);
if (!app) {
return CLI_FAILURE;
}
stasis_app_set_debug(app, debug);
ast_cli(a->fd, "Debugging on '%s' %s\n",
stasis_app_name(app),
debug ? "enabled" : "disabled");
ao2_ref(app, -1);
return CLI_SUCCESS;
}
static struct ast_cli_entry cli_ari[] = {
AST_CLI_DEFINE(ari_show, "Show ARI settings"),
AST_CLI_DEFINE(ari_show_users, "List ARI users"),
AST_CLI_DEFINE(ari_show_user, "List single ARI user"),
AST_CLI_DEFINE(ari_mkpasswd, "Encrypts a password"),
AST_CLI_DEFINE(ari_show_apps, "List registered ARI applications"),
AST_CLI_DEFINE(ari_show_app, "Display details of a registered ARI application"),
AST_CLI_DEFINE(ari_set_debug, "Enable/disable debugging of an ARI application"),
};
int ast_ari_cli_register(void) {

View File

@@ -27,6 +27,7 @@
#include "resource_events.h"
#include "asterisk/astobj2.h"
#include "asterisk/http_websocket.h"
#include "asterisk/stasis_app.h"
#include "asterisk/vector.h"
@@ -108,6 +109,15 @@ static void stasis_app_message_handler(
msg_type,
msg_application);
} else {
if (stasis_app_get_debug_by_name(app_name)) {
char *str = ast_json_dump_string_format(message, ast_ari_json_format());
ast_verbose("<--- Sending ARI event to %s --->\n%s\n",
ast_sockaddr_stringify(ast_ari_websocket_session_get_remote_addr(session->ws_session)),
str);
ast_json_free(str);
}
/* We are ready to publish the message */
ast_ari_websocket_session_write(session->ws_session, message);
}

View File

@@ -148,6 +148,7 @@
#include "asterisk/astobj2.h"
#include "asterisk/module.h"
#include "asterisk/paths.h"
#include "asterisk/stasis_app.h"
#include <string.h>
#include <sys/stat.h>
@@ -491,7 +492,7 @@ static void handle_options(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)
{
RAII_VAR(struct stasis_rest_handlers *, root, NULL, ao2_cleanup);
struct stasis_rest_handlers *handler;
@@ -506,8 +507,10 @@ void ast_ari_invoke(struct ast_tcptls_session_instance *ser,
while ((path_segment = strsep(&path, "/")) && (strlen(path_segment) > 0)) {
struct stasis_rest_handlers *found_handler = NULL;
int i;
ast_uri_decode(path_segment, ast_uri_http_legacy);
ast_debug(3, "Finding handler for %s\n", path_segment);
for (i = 0; found_handler == NULL && i < handler->num_children; ++i) {
struct stasis_rest_handlers *child = handler->children[i];
@@ -569,7 +572,7 @@ void ast_ari_invoke(struct ast_tcptls_session_instance *ser,
return;
}
callback(ser, get_params, path_vars, headers, response);
callback(ser, get_params, path_vars, headers, body, response);
if (response->message == NULL && response->response_code == 0) {
/* Really should not happen */
ast_log(LOG_ERROR, "ARI %s %s not implemented\n",
@@ -879,6 +882,10 @@ static int ast_ari_callback(struct ast_tcptls_session_instance *ser,
RAII_VAR(struct ast_ari_conf_user *, user, NULL, ao2_cleanup);
struct ast_ari_response response = { .fd = -1, 0 };
RAII_VAR(struct ast_variable *, post_vars, NULL, ast_variables_destroy);
struct ast_variable *var;
const char *app_name = NULL;
RAII_VAR(struct ast_json *, body, ast_json_null(), ast_json_free);
int debug_app = 0;
if (!response_body) {
ast_http_request_close_on_completion(ser);
@@ -926,6 +933,25 @@ static int ast_ari_callback(struct ast_tcptls_session_instance *ser,
"Bad Request", "Error parsing request body");
goto request_failed;
}
/* Look for a JSON request entity only if there were no post_vars.
* If there were post_vars, then the request body would already have
* been consumed and can not be read again.
*/
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(&response, 413, "Request Entity Too Large", "Request body too large");
goto request_failed;
case ENOMEM:
ast_ari_response_error(&response, 500, "Internal Server Error", "Error processing request");
goto request_failed;
case EIO:
ast_ari_response_error(&response, 400, "Bad Request", "Error parsing request body");
goto request_failed;
}
}
}
if (get_params == NULL) {
get_params = post_vars;
@@ -942,6 +968,41 @@ static int ast_ari_callback(struct ast_tcptls_session_instance *ser,
get_params = post_vars;
}
/* At this point, get_params will contain post_vars (if any) */
app_name = ast_variable_find_in_list(get_params, "app");
if (!app_name) {
struct ast_json *app = ast_json_object_get(body, "app");
app_name = (app ? ast_json_string_get(app) : NULL);
}
/* stasis_app_get_debug_by_name returns an "||" of the app's debug flag
* and the global debug flag.
*/
debug_app = stasis_app_get_debug_by_name(app_name);
if (debug_app) {
struct ast_str *buf = ast_str_create(512);
char *str = ast_json_dump_string_format(body, ast_ari_json_format());
if (!buf) {
ast_http_request_close_on_completion(ser);
ast_http_error(ser, 500, "Server Error", "Out of memory");
goto request_failed;
}
ast_str_append(&buf, 0, "<--- ARI request received from: %s --->\n",
ast_sockaddr_stringify(&ser->remote_address));
for (var = headers; var; var = var->next) {
ast_str_append(&buf, 0, "%s: %s\n", var->name, var->value);
}
for (var = get_params; var; var = var->next) {
ast_str_append(&buf, 0, "%s: %s\n", var->name, var->value);
}
ast_verbose("%sbody:\n%s\n\n", ast_str_buffer(buf), str);
ast_json_free(str);
ast_free(buf);
}
user = authenticate_user(get_params, headers);
if (response.response_code > 0) {
/* POST parameter processing error. Do nothing. */
@@ -980,7 +1041,7 @@ static int ast_ari_callback(struct ast_tcptls_session_instance *ser,
}
} else {
/* Other RESTful resources */
ast_ari_invoke(ser, uri, method, get_params, headers,
ast_ari_invoke(ser, uri, method, get_params, headers, body,
&response);
}
@@ -992,6 +1053,7 @@ static int ast_ari_callback(struct ast_tcptls_session_instance *ser,
}
request_failed:
/* If you explicitly want to have no content, set message to
* ast_json_null().
*/
@@ -1014,8 +1076,13 @@ request_failed:
}
}
ast_debug(3, "Examining ARI response:\n%d %s\n%s\n%s\n", response.response_code,
response.response_text, ast_str_buffer(response.headers), ast_str_buffer(response_body));
if (debug_app) {
ast_verbose("<--- Sending ARI response to %s --->\n%d %s\n%s%s\n\n",
ast_sockaddr_stringify(&ser->remote_address), response.response_code,
response.response_text, ast_str_buffer(response.headers),
ast_str_buffer(response_body));
}
ast_http_send(ser, method, response.response_code,
response.response_text, response.headers, response_body,
response.fd != -1 ? response.fd : 0, 0);

View File

@@ -60,10 +60,9 @@
static void ast_ari_applications_list_cb(
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)
{
struct ast_ari_applications_list_args args = {};
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -111,11 +110,10 @@ fin: __attribute__((unused))
static void ast_ari_applications_get_cb(
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)
{
struct ast_ari_applications_get_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -208,11 +206,10 @@ int ast_ari_applications_subscribe_parse_body(
static void ast_ari_applications_subscribe_cb(
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)
{
struct ast_ari_applications_subscribe_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -270,21 +267,6 @@ static void ast_ari_applications_subscribe_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_applications_subscribe_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -374,11 +356,10 @@ int ast_ari_applications_unsubscribe_parse_body(
static void ast_ari_applications_unsubscribe_cb(
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)
{
struct ast_ari_applications_unsubscribe_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -436,21 +417,6 @@ static void ast_ari_applications_unsubscribe_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_applications_unsubscribe_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;

View File

@@ -60,11 +60,10 @@
static void ast_ari_asterisk_get_object_cb(
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)
{
struct ast_ari_asterisk_get_object_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -133,11 +132,10 @@ int ast_ari_asterisk_update_object_parse_body(
static void ast_ari_asterisk_update_object_cb(
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)
{
struct ast_ari_asterisk_update_object_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -155,21 +153,6 @@ static void ast_ari_asterisk_update_object_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
args.fields = body;
ast_ari_asterisk_update_object(headers, &args, response);
#if defined(AST_DEVMODE)
@@ -216,11 +199,10 @@ fin: __attribute__((unused))
static void ast_ari_asterisk_delete_object_cb(
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)
{
struct ast_ari_asterisk_delete_object_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -320,11 +302,10 @@ int ast_ari_asterisk_get_info_parse_body(
static void ast_ari_asterisk_get_info_cb(
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)
{
struct ast_ari_asterisk_get_info_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -376,21 +357,6 @@ static void ast_ari_asterisk_get_info_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_asterisk_get_info_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -439,10 +405,9 @@ fin: __attribute__((unused))
static void ast_ari_asterisk_list_modules_cb(
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)
{
struct ast_ari_asterisk_list_modules_args args = {};
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -490,11 +455,10 @@ fin: __attribute__((unused))
static void ast_ari_asterisk_get_module_cb(
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)
{
struct ast_ari_asterisk_get_module_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -550,11 +514,10 @@ fin: __attribute__((unused))
static void ast_ari_asterisk_load_module_cb(
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)
{
struct ast_ari_asterisk_load_module_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -609,11 +572,10 @@ fin: __attribute__((unused))
static void ast_ari_asterisk_unload_module_cb(
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)
{
struct ast_ari_asterisk_unload_module_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -669,11 +631,10 @@ fin: __attribute__((unused))
static void ast_ari_asterisk_reload_module_cb(
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)
{
struct ast_ari_asterisk_reload_module_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -729,10 +690,9 @@ fin: __attribute__((unused))
static void ast_ari_asterisk_list_log_channels_cb(
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)
{
struct ast_ari_asterisk_list_log_channels_args args = {};
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -793,11 +753,10 @@ int ast_ari_asterisk_add_log_parse_body(
static void ast_ari_asterisk_add_log_cb(
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)
{
struct ast_ari_asterisk_add_log_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -815,21 +774,6 @@ static void ast_ari_asterisk_add_log_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_asterisk_add_log_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -878,11 +822,10 @@ fin: __attribute__((unused))
static void ast_ari_asterisk_delete_log_cb(
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)
{
struct ast_ari_asterisk_delete_log_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -937,11 +880,10 @@ fin: __attribute__((unused))
static void ast_ari_asterisk_rotate_log_cb(
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)
{
struct ast_ari_asterisk_rotate_log_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -1009,11 +951,10 @@ int ast_ari_asterisk_get_global_var_parse_body(
static void ast_ari_asterisk_get_global_var_cb(
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)
{
struct ast_ari_asterisk_get_global_var_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -1025,21 +966,6 @@ static void ast_ari_asterisk_get_global_var_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_asterisk_get_global_var_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -1104,11 +1030,10 @@ int ast_ari_asterisk_set_global_var_parse_body(
static void ast_ari_asterisk_set_global_var_cb(
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)
{
struct ast_ari_asterisk_set_global_var_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -1123,21 +1048,6 @@ static void ast_ari_asterisk_set_global_var_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_asterisk_set_global_var_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;

View File

@@ -60,10 +60,9 @@
static void ast_ari_bridges_list_cb(
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)
{
struct ast_ari_bridges_list_args args = {};
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -132,11 +131,10 @@ int ast_ari_bridges_create_parse_body(
static void ast_ari_bridges_create_cb(
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)
{
struct ast_ari_bridges_create_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -154,21 +152,6 @@ static void ast_ari_bridges_create_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_bridges_create_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -232,11 +215,10 @@ int ast_ari_bridges_create_with_id_parse_body(
static void ast_ari_bridges_create_with_id_cb(
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)
{
struct ast_ari_bridges_create_with_id_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -257,21 +239,6 @@ static void ast_ari_bridges_create_with_id_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_bridges_create_with_id_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -318,11 +285,10 @@ fin: __attribute__((unused))
static void ast_ari_bridges_get_cb(
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)
{
struct ast_ari_bridges_get_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -377,11 +343,10 @@ fin: __attribute__((unused))
static void ast_ari_bridges_destroy_cb(
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)
{
struct ast_ari_bridges_destroy_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -478,11 +443,10 @@ int ast_ari_bridges_add_channel_parse_body(
static void ast_ari_bridges_add_channel_cb(
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)
{
struct ast_ari_bridges_add_channel_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -543,21 +507,6 @@ static void ast_ari_bridges_add_channel_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_bridges_add_channel_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -648,11 +597,10 @@ int ast_ari_bridges_remove_channel_parse_body(
static void ast_ari_bridges_remove_channel_cb(
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)
{
struct ast_ari_bridges_remove_channel_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -710,21 +658,6 @@ static void ast_ari_bridges_remove_channel_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_bridges_remove_channel_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -777,11 +710,10 @@ fin: __attribute__((unused))
static void ast_ari_bridges_set_video_source_cb(
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)
{
struct ast_ari_bridges_set_video_source_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -841,11 +773,10 @@ fin: __attribute__((unused))
static void ast_ari_bridges_clear_video_source_cb(
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)
{
struct ast_ari_bridges_clear_video_source_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -913,11 +844,10 @@ int ast_ari_bridges_start_moh_parse_body(
static void ast_ari_bridges_start_moh_cb(
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)
{
struct ast_ari_bridges_start_moh_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -935,21 +865,6 @@ static void ast_ari_bridges_start_moh_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_bridges_start_moh_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -998,11 +913,10 @@ fin: __attribute__((unused))
static void ast_ari_bridges_stop_moh_cb(
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)
{
struct ast_ari_bridges_stop_moh_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -1112,11 +1026,10 @@ int ast_ari_bridges_play_parse_body(
static void ast_ari_bridges_play_cb(
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)
{
struct ast_ari_bridges_play_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -1186,21 +1099,6 @@ static void ast_ari_bridges_play_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_bridges_play_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -1301,11 +1199,10 @@ int ast_ari_bridges_play_with_id_parse_body(
static void ast_ari_bridges_play_with_id_cb(
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)
{
struct ast_ari_bridges_play_with_id_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -1375,21 +1272,6 @@ static void ast_ari_bridges_play_with_id_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_bridges_play_with_id_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -1477,11 +1359,10 @@ int ast_ari_bridges_record_parse_body(
static void ast_ari_bridges_record_cb(
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)
{
struct ast_ari_bridges_record_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -1517,21 +1398,6 @@ static void ast_ari_bridges_record_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_bridges_record_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;

View File

@@ -60,10 +60,9 @@
static void ast_ari_channels_list_cb(
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)
{
struct ast_ari_channels_list_args args = {};
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -172,11 +171,10 @@ int ast_ari_channels_originate_parse_body(
static void ast_ari_channels_originate_cb(
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)
{
struct ast_ari_channels_originate_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -224,21 +222,6 @@ static void ast_ari_channels_originate_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
args.variables = body;
ast_ari_channels_originate(headers, &args, response);
#if defined(AST_DEVMODE)
@@ -321,11 +304,10 @@ int ast_ari_channels_create_parse_body(
static void ast_ari_channels_create_cb(
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)
{
struct ast_ari_channels_create_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -355,21 +337,6 @@ static void ast_ari_channels_create_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_channels_create_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -417,11 +384,10 @@ fin: __attribute__((unused))
static void ast_ari_channels_get_cb(
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)
{
struct ast_ari_channels_get_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -533,11 +499,10 @@ int ast_ari_channels_originate_with_id_parse_body(
static void ast_ari_channels_originate_with_id_cb(
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)
{
struct ast_ari_channels_originate_with_id_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -588,21 +553,6 @@ static void ast_ari_channels_originate_with_id_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
args.variables = body;
ast_ari_channels_originate_with_id(headers, &args, response);
#if defined(AST_DEVMODE)
@@ -661,11 +611,10 @@ int ast_ari_channels_hangup_parse_body(
static void ast_ari_channels_hangup_cb(
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)
{
struct ast_ari_channels_hangup_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -683,21 +632,6 @@ static void ast_ari_channels_hangup_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_channels_hangup_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -771,11 +705,10 @@ int ast_ari_channels_continue_in_dialplan_parse_body(
static void ast_ari_channels_continue_in_dialplan_cb(
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)
{
struct ast_ari_channels_continue_in_dialplan_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -802,21 +735,6 @@ static void ast_ari_channels_continue_in_dialplan_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_channels_continue_in_dialplan_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -879,11 +797,10 @@ int ast_ari_channels_redirect_parse_body(
static void ast_ari_channels_redirect_cb(
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)
{
struct ast_ari_channels_redirect_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -901,21 +818,6 @@ static void ast_ari_channels_redirect_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_channels_redirect_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -967,11 +869,10 @@ fin: __attribute__((unused))
static void ast_ari_channels_answer_cb(
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)
{
struct ast_ari_channels_answer_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -1028,11 +929,10 @@ fin: __attribute__((unused))
static void ast_ari_channels_ring_cb(
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)
{
struct ast_ari_channels_ring_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -1089,11 +989,10 @@ fin: __attribute__((unused))
static void ast_ari_channels_ring_stop_cb(
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)
{
struct ast_ari_channels_ring_stop_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -1179,11 +1078,10 @@ int ast_ari_channels_send_dtmf_parse_body(
static void ast_ari_channels_send_dtmf_cb(
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)
{
struct ast_ari_channels_send_dtmf_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -1213,21 +1111,6 @@ static void ast_ari_channels_send_dtmf_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_channels_send_dtmf_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -1291,11 +1174,10 @@ int ast_ari_channels_mute_parse_body(
static void ast_ari_channels_mute_cb(
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)
{
struct ast_ari_channels_mute_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -1313,21 +1195,6 @@ static void ast_ari_channels_mute_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_channels_mute_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -1390,11 +1257,10 @@ int ast_ari_channels_unmute_parse_body(
static void ast_ari_channels_unmute_cb(
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)
{
struct ast_ari_channels_unmute_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -1412,21 +1278,6 @@ static void ast_ari_channels_unmute_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_channels_unmute_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -1476,11 +1327,10 @@ fin: __attribute__((unused))
static void ast_ari_channels_hold_cb(
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)
{
struct ast_ari_channels_hold_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -1537,11 +1387,10 @@ fin: __attribute__((unused))
static void ast_ari_channels_unhold_cb(
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)
{
struct ast_ari_channels_unhold_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -1611,11 +1460,10 @@ int ast_ari_channels_start_moh_parse_body(
static void ast_ari_channels_start_moh_cb(
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)
{
struct ast_ari_channels_start_moh_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -1633,21 +1481,6 @@ static void ast_ari_channels_start_moh_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_channels_start_moh_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -1697,11 +1530,10 @@ fin: __attribute__((unused))
static void ast_ari_channels_stop_moh_cb(
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)
{
struct ast_ari_channels_stop_moh_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -1758,11 +1590,10 @@ fin: __attribute__((unused))
static void ast_ari_channels_start_silence_cb(
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)
{
struct ast_ari_channels_start_silence_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -1819,11 +1650,10 @@ fin: __attribute__((unused))
static void ast_ari_channels_stop_silence_cb(
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)
{
struct ast_ari_channels_stop_silence_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -1934,11 +1764,10 @@ int ast_ari_channels_play_parse_body(
static void ast_ari_channels_play_cb(
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)
{
struct ast_ari_channels_play_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -2008,21 +1837,6 @@ static void ast_ari_channels_play_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_channels_play_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -2124,11 +1938,10 @@ int ast_ari_channels_play_with_id_parse_body(
static void ast_ari_channels_play_with_id_cb(
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)
{
struct ast_ari_channels_play_with_id_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -2198,21 +2011,6 @@ static void ast_ari_channels_play_with_id_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_channels_play_with_id_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -2301,11 +2099,10 @@ int ast_ari_channels_record_parse_body(
static void ast_ari_channels_record_cb(
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)
{
struct ast_ari_channels_record_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -2341,21 +2138,6 @@ static void ast_ari_channels_record_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_channels_record_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -2419,11 +2201,10 @@ int ast_ari_channels_get_channel_var_parse_body(
static void ast_ari_channels_get_channel_var_cb(
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)
{
struct ast_ari_channels_get_channel_var_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -2441,21 +2222,6 @@ static void ast_ari_channels_get_channel_var_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_channels_get_channel_var_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -2522,11 +2288,10 @@ int ast_ari_channels_set_channel_var_parse_body(
static void ast_ari_channels_set_channel_var_cb(
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)
{
struct ast_ari_channels_set_channel_var_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -2547,21 +2312,6 @@ static void ast_ari_channels_set_channel_var_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_channels_set_channel_var_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -2640,11 +2390,10 @@ int ast_ari_channels_snoop_channel_parse_body(
static void ast_ari_channels_snoop_channel_cb(
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)
{
struct ast_ari_channels_snoop_channel_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -2674,21 +2423,6 @@ static void ast_ari_channels_snoop_channel_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_channels_snoop_channel_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -2762,11 +2496,10 @@ int ast_ari_channels_snoop_channel_with_id_parse_body(
static void ast_ari_channels_snoop_channel_with_id_cb(
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)
{
struct ast_ari_channels_snoop_channel_with_id_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -2796,21 +2529,6 @@ static void ast_ari_channels_snoop_channel_with_id_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_channels_snoop_channel_with_id_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -2876,11 +2594,10 @@ int ast_ari_channels_dial_parse_body(
static void ast_ari_channels_dial_cb(
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)
{
struct ast_ari_channels_dial_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -2901,21 +2618,6 @@ static void ast_ari_channels_dial_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_channels_dial_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;

View File

@@ -60,10 +60,9 @@
static void ast_ari_device_states_list_cb(
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)
{
struct ast_ari_device_states_list_args args = {};
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -111,11 +110,10 @@ fin: __attribute__((unused))
static void ast_ari_device_states_get_cb(
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)
{
struct ast_ari_device_states_get_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -182,11 +180,10 @@ int ast_ari_device_states_update_parse_body(
static void ast_ari_device_states_update_cb(
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)
{
struct ast_ari_device_states_update_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -204,21 +201,6 @@ static void ast_ari_device_states_update_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_device_states_update_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -267,11 +249,10 @@ fin: __attribute__((unused))
static void ast_ari_device_states_delete_cb(
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)
{
struct ast_ari_device_states_delete_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;

View File

@@ -60,10 +60,9 @@
static void ast_ari_endpoints_list_cb(
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)
{
struct ast_ari_endpoints_list_args args = {};
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -132,11 +131,10 @@ int ast_ari_endpoints_send_message_parse_body(
static void ast_ari_endpoints_send_message_cb(
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)
{
struct ast_ari_endpoints_send_message_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -154,21 +152,6 @@ static void ast_ari_endpoints_send_message_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
args.variables = body;
ast_ari_endpoints_send_message(headers, &args, response);
#if defined(AST_DEVMODE)
@@ -214,11 +197,10 @@ fin: __attribute__((unused))
static void ast_ari_endpoints_list_by_tech_cb(
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)
{
struct ast_ari_endpoints_list_by_tech_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -273,11 +255,10 @@ fin: __attribute__((unused))
static void ast_ari_endpoints_get_cb(
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)
{
struct ast_ari_endpoints_get_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -353,11 +334,10 @@ int ast_ari_endpoints_send_message_to_endpoint_parse_body(
static void ast_ari_endpoints_send_message_to_endpoint_cb(
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)
{
struct ast_ari_endpoints_send_message_to_endpoint_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -381,21 +361,6 @@ static void ast_ari_endpoints_send_message_to_endpoint_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
args.variables = body;
ast_ari_endpoints_send_message_to_endpoint(headers, &args, response);
#if defined(AST_DEVMODE)

View File

@@ -287,11 +287,10 @@ int ast_ari_events_user_event_parse_body(
static void ast_ari_events_user_event_cb(
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)
{
struct ast_ari_events_user_event_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -352,21 +351,6 @@ static void ast_ari_events_user_event_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
args.variables = body;
ast_ari_events_user_event(headers, &args, response);
#if defined(AST_DEVMODE)

View File

@@ -60,10 +60,9 @@
static void ast_ari_mailboxes_list_cb(
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)
{
struct ast_ari_mailboxes_list_args args = {};
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -111,11 +110,10 @@ fin: __attribute__((unused))
static void ast_ari_mailboxes_get_cb(
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)
{
struct ast_ari_mailboxes_get_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -187,11 +185,10 @@ int ast_ari_mailboxes_update_parse_body(
static void ast_ari_mailboxes_update_cb(
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)
{
struct ast_ari_mailboxes_update_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -212,21 +209,6 @@ static void ast_ari_mailboxes_update_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_mailboxes_update_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -274,11 +256,10 @@ fin: __attribute__((unused))
static void ast_ari_mailboxes_delete_cb(
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)
{
struct ast_ari_mailboxes_delete_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;

View File

@@ -60,11 +60,10 @@
static void ast_ari_playbacks_get_cb(
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)
{
struct ast_ari_playbacks_get_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -119,11 +118,10 @@ fin: __attribute__((unused))
static void ast_ari_playbacks_stop_cb(
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)
{
struct ast_ari_playbacks_stop_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -191,11 +189,10 @@ int ast_ari_playbacks_control_parse_body(
static void ast_ari_playbacks_control_cb(
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)
{
struct ast_ari_playbacks_control_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -213,21 +210,6 @@ static void ast_ari_playbacks_control_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_playbacks_control_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;

View File

@@ -60,10 +60,9 @@
static void ast_ari_recordings_list_stored_cb(
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)
{
struct ast_ari_recordings_list_stored_args args = {};
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -111,11 +110,10 @@ fin: __attribute__((unused))
static void ast_ari_recordings_get_stored_cb(
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)
{
struct ast_ari_recordings_get_stored_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -170,11 +168,10 @@ fin: __attribute__((unused))
static void ast_ari_recordings_delete_stored_cb(
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)
{
struct ast_ari_recordings_delete_stored_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -229,11 +226,10 @@ fin: __attribute__((unused))
static void ast_ari_recordings_get_stored_file_cb(
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)
{
struct ast_ari_recordings_get_stored_file_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -302,11 +298,10 @@ int ast_ari_recordings_copy_stored_parse_body(
static void ast_ari_recordings_copy_stored_cb(
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)
{
struct ast_ari_recordings_copy_stored_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -324,21 +319,6 @@ static void ast_ari_recordings_copy_stored_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_recordings_copy_stored_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -387,11 +367,10 @@ fin: __attribute__((unused))
static void ast_ari_recordings_get_live_cb(
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)
{
struct ast_ari_recordings_get_live_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -446,11 +425,10 @@ fin: __attribute__((unused))
static void ast_ari_recordings_cancel_cb(
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)
{
struct ast_ari_recordings_cancel_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -505,11 +483,10 @@ fin: __attribute__((unused))
static void ast_ari_recordings_stop_cb(
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)
{
struct ast_ari_recordings_stop_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -564,11 +541,10 @@ fin: __attribute__((unused))
static void ast_ari_recordings_pause_cb(
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)
{
struct ast_ari_recordings_pause_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -624,11 +600,10 @@ fin: __attribute__((unused))
static void ast_ari_recordings_unpause_cb(
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)
{
struct ast_ari_recordings_unpause_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -684,11 +659,10 @@ fin: __attribute__((unused))
static void ast_ari_recordings_mute_cb(
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)
{
struct ast_ari_recordings_mute_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -744,11 +718,10 @@ fin: __attribute__((unused))
static void ast_ari_recordings_unmute_cb(
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)
{
struct ast_ari_recordings_unmute_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;

View File

@@ -77,11 +77,10 @@ int ast_ari_sounds_list_parse_body(
static void ast_ari_sounds_list_cb(
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)
{
struct ast_ari_sounds_list_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;
@@ -96,21 +95,6 @@ static void ast_ari_sounds_list_cb(
} else
{}
}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
if (ast_ari_sounds_list_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
@@ -157,11 +141,10 @@ fin: __attribute__((unused))
static void ast_ari_sounds_get_cb(
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)
{
struct ast_ari_sounds_get_args args = {};
struct ast_variable *i;
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;

View File

@@ -65,7 +65,6 @@
#include "stasis/app.h"
#include "stasis/control.h"
#include "stasis/messaging.h"
#include "stasis/cli.h"
#include "stasis/stasis_bridge.h"
#include "asterisk/core_unreal.h"
#include "asterisk/musiconhold.h"
@@ -176,11 +175,6 @@ static struct ast_json *stasis_start_to_json(struct stasis_message *message,
STASIS_MESSAGE_TYPE_DEFN_LOCAL(start_message_type,
.to_json = stasis_start_to_json);
const char *stasis_app_name(const struct stasis_app *app)
{
return app_name(app);
}
/*! AO2 hash function for \ref app */
static int app_hash(const void *obj, const int flags)
{
@@ -956,7 +950,7 @@ static int send_start_msg_snapshots(struct ast_channel *chan, struct stasis_app
if (app_subscribe_channel(app, chan)) {
ast_log(LOG_ERROR, "Error subscribing app '%s' to channel '%s'\n",
app_name(app), ast_channel_name(chan));
stasis_app_name(app), ast_channel_name(chan));
return -1;
}
@@ -970,7 +964,7 @@ static int send_start_msg_snapshots(struct ast_channel *chan, struct stasis_app
payload->replace_channel = ao2_bump(replace_channel_snapshot);
json_blob = ast_json_pack("{s: s, s: o, s: []}",
"app", app_name(app),
"app", stasis_app_name(app),
"timestamp", ast_json_timeval(ast_tvnow(), NULL),
"args");
if (!json_blob) {
@@ -1040,7 +1034,7 @@ int app_send_end_msg(struct stasis_app *app, struct ast_channel *chan)
return 0;
}
blob = ast_json_pack("{s: s}", "app", app_name(app));
blob = ast_json_pack("{s: s}", "app", stasis_app_name(app));
if (!blob) {
ast_log(LOG_ERROR, "Error packing JSON for StasisEnd message\n");
return -1;
@@ -1486,10 +1480,6 @@ static struct stasis_app *find_app_by_name(const char *app_name)
res = ao2_find(apps_registry, app_name, OBJ_SEARCH_KEY);
}
if (!res) {
ast_log(LOG_WARNING, "Could not find app '%s'\n",
app_name ? : "(null)");
}
return res;
}
@@ -1970,8 +1960,6 @@ static int unload_module(void)
{
stasis_app_unregister_event_sources();
cli_cleanup();
messaging_cleanup();
cleanup();
@@ -2131,11 +2119,6 @@ static int load_module(void)
return AST_MODULE_LOAD_FAILURE;
}
if (cli_init()) {
unload_module();
return AST_MODULE_LOAD_FAILURE;
}
bridge_stasis_init();
stasis_app_register_event_sources();

View File

@@ -41,6 +41,9 @@
#define CHANNEL_ALL "__AST_CHANNEL_ALL_TOPIC"
#define ENDPOINT_ALL "__AST_ENDPOINT_ALL_TOPIC"
/*! Global debug flag. No need for locking */
int global_debug;
static int unsubscribe(struct stasis_app *app, const char *kind, const char *id, int terminate);
struct stasis_app {
@@ -840,15 +843,64 @@ static void bridge_default_handler(void *data, struct stasis_subscription *sub,
}
}
void app_set_debug(struct stasis_app *app, int debug)
void stasis_app_set_debug(struct stasis_app *app, int debug)
{
if (!app) {
return;
}
{
SCOPED_AO2LOCK(lock, app);
app->debug = debug;
app->debug = debug;
}
void stasis_app_set_debug_by_name(const char *app_name, int debug)
{
struct stasis_app *app = stasis_app_get_by_name(app_name);
if (!app) {
return;
}
app->debug = debug;
ao2_cleanup(app);
}
int stasis_app_get_debug(struct stasis_app *app)
{
return (app ? app->debug : 0) || global_debug;
}
int stasis_app_get_debug_by_name(const char *app_name)
{
RAII_VAR(struct stasis_app *, app, stasis_app_get_by_name(app_name), ao2_cleanup);
return (app ? app->debug : 0) || global_debug;
}
void stasis_app_set_global_debug(int debug)
{
global_debug = debug;
if (!global_debug) {
struct ao2_container *app_names = stasis_app_get_all();
struct ao2_iterator it_app_names;
char *app_name;
struct stasis_app *app;
if (!app_names || !ao2_container_count(app_names)) {
ao2_cleanup(app_names);
return;
}
it_app_names = ao2_iterator_init(app_names, 0);
while ((app_name = ao2_iterator_next(&it_app_names))) {
if ((app = stasis_app_get_by_name(app_name))) {
stasis_app_set_debug(app, 0);
}
ao2_cleanup(app_name);
ao2_cleanup(app);
}
ao2_iterator_cleanup(&it_app_names);
ao2_cleanup(app_names);
}
}
@@ -949,7 +1001,6 @@ struct stasis_topic *ast_app_get_topic(struct stasis_app *app)
void app_send(struct stasis_app *app, struct ast_json *message)
{
stasis_app_cb handler;
int debug;
char eid[20];
RAII_VAR(void *, data, NULL, ao2_cleanup);
@@ -962,7 +1013,6 @@ void app_send(struct stasis_app *app, struct ast_json *message)
/* Copy off mutable state with lock held */
{
SCOPED_AO2LOCK(lock, app);
debug = app->debug;
handler = app->handler;
if (app->data) {
ao2_ref(app->data, +1);
@@ -971,13 +1021,6 @@ void app_send(struct stasis_app *app, struct ast_json *message)
/* Name is immutable; no need to copy */
}
if (debug) {
char *dump = ast_json_dump_string_format(message, AST_JSON_PRETTY);
ast_verb(0, "Dispatching message to Stasis app '%s':\n%s\n",
app->name, dump);
ast_json_free(dump);
}
if (!handler) {
ast_verb(3,
"Inactive Stasis app '%s' missed message\n", app->name);
@@ -1050,7 +1093,7 @@ void app_update(struct stasis_app *app, stasis_app_cb handler, void *data)
app->data = data;
}
const char *app_name(const struct stasis_app *app)
const char *stasis_app_name(const struct stasis_app *app)
{
return app->name;
}
@@ -1067,7 +1110,7 @@ static int forwards_filter_by_type(void *obj, void *arg, int flags)
return 0;
}
void app_to_cli(const struct stasis_app *app, struct ast_cli_args *a)
void stasis_app_to_cli(const struct stasis_app *app, struct ast_cli_args *a)
{
struct ao2_iterator *channels;
struct ao2_iterator *endpoints;

View File

@@ -108,15 +108,6 @@ int app_is_finished(struct stasis_app *app);
*/
void app_update(struct stasis_app *app, stasis_app_cb handler, void *data);
/*!
* \brief Return an application's name.
*
* \param app Application.
* \return Name of the application.
* \return \c NULL is \a app is \c NULL.
*/
const char *app_name(const struct stasis_app *app);
/*!
* \brief Send a message to an application.
*
@@ -137,16 +128,6 @@ struct app_forwards;
*/
struct ast_json *app_to_json(const struct stasis_app *app);
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 app_to_cli(const struct stasis_app *app, struct ast_cli_args *a);
/*!
* \brief Subscribes an application to a channel.
*
@@ -300,12 +281,4 @@ char *app_get_replace_channel_app(struct ast_channel *chan);
*/
int app_send_end_msg(struct stasis_app *app, struct ast_channel *chan);
/*!
* \brief Enable/disable debugging on an application
*
* \param app The app to debug
* \param debug If non-zero, enable debugging. If zero, disable.
*/
void app_set_debug(struct stasis_app *app, int debug);
#endif /* _ASTERISK_RES_STASIS_APP_H */

View File

@@ -1,214 +0,0 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2016, Digium, Inc.
*
* Matt Jordan <mjordan@digium.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*! \file
*
* \brief Stasis CLI commands.
*
* \author Matt Jordan <mjordan@digium.com>
*/
#include "asterisk.h"
#include "asterisk/cli.h"
#include "asterisk/astobj2.h"
#include "cli.h"
#include "app.h"
static char *ari_show_apps(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct ao2_container *apps;
struct ao2_iterator it_apps;
char *app;
switch (cmd) {
case CLI_INIT:
e->command = "ari show apps";
e->usage =
"Usage: ari show apps\n"
" Lists all registered applications.\n"
;
return NULL;
case CLI_GENERATE:
return NULL;
default:
break;
}
if (a->argc != 3) {
return CLI_SHOWUSAGE;
}
apps = stasis_app_get_all();
if (!apps) {
ast_cli(a->fd, "Unable to retrieve registered applications!\n");
return CLI_FAILURE;
}
ast_cli(a->fd, "Application Name \n");
ast_cli(a->fd, "=========================\n");
it_apps = ao2_iterator_init(apps, 0);
while ((app = ao2_iterator_next(&it_apps))) {
ast_cli(a->fd, "%-25.25s\n", app);
ao2_ref(app, -1);
}
ao2_iterator_destroy(&it_apps);
ao2_ref(apps, -1);
return CLI_SUCCESS;
}
struct app_complete {
/*! Nth app to search for */
int state;
/*! Which app currently on */
int which;
};
static int complete_ari_app_search(void *obj, void *arg, void *data, int flags)
{
struct app_complete *search = data;
if (++search->which > search->state) {
return CMP_MATCH;
}
return 0;
}
static char *complete_ari_app(struct ast_cli_args *a)
{
RAII_VAR(struct ao2_container *, apps, stasis_app_get_all(), ao2_cleanup);
RAII_VAR(char *, app, NULL, ao2_cleanup);
struct app_complete search = {
.state = a->n,
};
if (!apps) {
ast_cli(a->fd, "Error getting ARI applications\n");
return CLI_FAILURE;
}
app = ao2_callback_data(apps,
ast_strlen_zero(a->word) ? 0 : OBJ_PARTIAL_KEY,
complete_ari_app_search, (char*)a->word, &search);
return app ? ast_strdup(app) : NULL;
}
static char *complete_ari_show_app(struct ast_cli_args *a)
{
if (a->pos == 3) {
return complete_ari_app(a);
}
return NULL;
}
static char *ari_show_app(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
void *app;
switch (cmd) {
case CLI_INIT:
e->command = "ari show app";
e->usage =
"Usage: ari show app <application>\n"
" Provide detailed information about a registered application.\n"
;
return NULL;
case CLI_GENERATE:
return complete_ari_show_app(a);
default:
break;
}
if (a->argc != 4) {
return CLI_SHOWUSAGE;
}
app = stasis_app_get_by_name(a->argv[3]);
if (!app) {
return CLI_FAILURE;
}
app_to_cli(app, a);
ao2_ref(app, -1);
return CLI_SUCCESS;
}
static char *ari_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
void *app;
int debug;
switch (cmd) {
case CLI_INIT:
e->command = "ari set debug";
e->usage =
"Usage: ari set debug <application> <on|off>\n"
" Enable or disable debugging on a specific application.\n"
;
return NULL;
case CLI_GENERATE:
return complete_ari_show_app(a);
default:
break;
}
if (a->argc != 5) {
return CLI_SHOWUSAGE;
}
app = stasis_app_get_by_name(a->argv[3]);
if (!app) {
return CLI_FAILURE;
}
debug = !strcmp(a->argv[4], "on");
app_set_debug(app, debug);
ast_cli(a->fd, "Debugging on '%s' %s\n",
app_name(app),
debug ? "enabled" : "disabled");
ao2_ref(app, -1);
return CLI_SUCCESS;
}
static struct ast_cli_entry cli_ari[] = {
AST_CLI_DEFINE(ari_show_apps, "List registered ARI applications"),
AST_CLI_DEFINE(ari_show_app, "Display details of a registered ARI application"),
AST_CLI_DEFINE(ari_set_debug, "Enable/disable debugging of an ARI application"),
};
int cli_init(void)
{
return ast_cli_register_multiple(cli_ari, ARRAY_LEN(cli_ari));
}
void cli_cleanup(void)
{
ast_cli_unregister_multiple(cli_ari, ARRAY_LEN(cli_ari));
}

View File

@@ -1,43 +0,0 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2016, Digium, Inc.
*
* Matt Jordan <mjordan@digium.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
#ifndef _ASTERISK_RES_STASIS_CLI_H
#define _ASTERISK_RES_STASIS_CLI_H
/*! \file
*
* \brief Internal API for Stasis application CLI commands
*
* \author Matt Jordan <mjordan@digium.com>
* \since 13.13.0
*/
/*!
* \brief Initialize the CLI commands
*
* \retval 0 on success
* \retval non-zero on error
*/
int cli_init(void);
/*!
* \brief Cleanup the CLI commands
*/
void cli_cleanup(void);
#endif /* _ASTERISK_RES_STASIS_CLI_H */

View File

@@ -155,13 +155,13 @@ static int bridge_stasis_push_peek(struct ast_bridge *self, struct ast_bridge_ch
}
to_be_replaced = ast_channel_snapshot_get_latest(ast_channel_uniqueid(swap->chan));
ast_debug(3, "Copying stasis app name %s from %s to %s\n", app_name(control_app(swap_control)),
ast_debug(3, "Copying stasis app name %s from %s to %s\n", stasis_app_name(control_app(swap_control)),
ast_channel_name(swap->chan), ast_channel_name(bridge_channel->chan));
ast_channel_lock(bridge_channel->chan);
/* copy the app name from the swap channel */
app_set_replace_channel_app(bridge_channel->chan, app_name(control_app(swap_control)));
app_set_replace_channel_app(bridge_channel->chan, stasis_app_name(control_app(swap_control)));
/* set the replace channel snapshot */
app_set_replace_channel_snapshot(bridge_channel->chan, to_be_replaced);

View File

@@ -85,21 +85,6 @@
{{/has_path_parameters}}
{{^is_websocket}}
{{#parse_body}}
/* Look for a JSON request entity */
body = ast_http_get_json(ser, headers);
if (!body) {
switch (errno) {
case EFBIG:
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
goto fin;
case ENOMEM:
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
goto fin;
case EIO:
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
goto fin;
}
}
{{#body_parameter}}
args.{{c_name}} = body;
{{/body_parameter}}

View File

@@ -76,13 +76,12 @@
static void ast_ari_{{c_name}}_{{c_nickname}}_cb(
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)
{
struct ast_ari_{{c_name}}_{{c_nickname}}_args args = {};
{{#has_parameters}}
struct ast_variable *i;
{{/has_parameters}}
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
#if defined(AST_DEVMODE)
int is_valid;
int code;

View File

@@ -61,6 +61,7 @@ static void handler(const char *name,
struct ast_variable *get_params,
struct ast_variable *path_vars,
struct ast_variable *headers,
struct ast_json *body,
struct ast_ari_response *response)
{
struct ast_json *message = ast_json_pack("{s: s, s: {}, s: {}, s: {}}",
@@ -98,9 +99,10 @@ static void handler(const char *name,
struct ast_variable *get_params, \
struct ast_variable *path_vars, \
struct ast_variable *headers, \
struct ast_json *body, \
struct ast_ari_response *response) \
{ \
handler(#name, response_code, get_params, path_vars, headers, response); \
handler(#name, response_code, get_params, path_vars, headers, body, response); \
}
HANDLER(bang_get, 200)
@@ -343,7 +345,8 @@ AST_TEST_DEFINE(invoke_get)
"head2", "head-two",
"path_vars");
ast_ari_invoke(NULL, "foo", AST_HTTP_GET, get_params, headers, response);
ast_ari_invoke(NULL, "foo", AST_HTTP_GET, get_params, headers,
ast_json_null(), response);
ast_test_validate(test, 1 == invocation_count);
ast_test_validate(test, 200 == response->response_code);
@@ -380,7 +383,8 @@ AST_TEST_DEFINE(invoke_wildcard)
"path_vars",
"bam", "foshizzle");
ast_ari_invoke(NULL, "foo/foshizzle", AST_HTTP_GET, get_params, headers, response);
ast_ari_invoke(NULL, "foo/foshizzle", AST_HTTP_GET, get_params, headers,
ast_json_null(), response);
ast_test_validate(test, 1 == invocation_count);
ast_test_validate(test, 200 == response->response_code);
@@ -417,7 +421,8 @@ AST_TEST_DEFINE(invoke_delete)
"path_vars",
"bam", "foshizzle");
ast_ari_invoke(NULL, "foo/foshizzle/bang", AST_HTTP_DELETE, get_params, headers, response);
ast_ari_invoke(NULL, "foo/foshizzle/bang", AST_HTTP_DELETE, get_params, headers,
ast_json_null(), response);
ast_test_validate(test, 1 == invocation_count);
ast_test_validate(test, 204 == response->response_code);
@@ -467,7 +472,8 @@ AST_TEST_DEFINE(invoke_post)
"head2", "head-two",
"path_vars");
ast_ari_invoke(NULL, "foo/bar", AST_HTTP_POST, get_params, headers, response);
ast_ari_invoke(NULL, "foo/bar", AST_HTTP_POST, get_params, headers,
ast_json_null(), response);
ast_test_validate(test, 1 == invocation_count);
ast_test_validate(test, 200 == response->response_code);
@@ -496,7 +502,8 @@ AST_TEST_DEFINE(invoke_bad_post)
fixture = setup_invocation_test();
response = response_alloc();
ast_ari_invoke(NULL, "foo", AST_HTTP_POST, get_params, headers, response);
ast_ari_invoke(NULL, "foo", AST_HTTP_POST, get_params, headers,
ast_json_null(), response);
ast_test_validate(test, 0 == invocation_count);
ast_test_validate(test, 405 == response->response_code);
@@ -524,7 +531,8 @@ AST_TEST_DEFINE(invoke_not_found)
fixture = setup_invocation_test();
response = response_alloc();
ast_ari_invoke(NULL, "foo/fizzle/i-am-not-a-resource", AST_HTTP_GET, get_params, headers, response);
ast_ari_invoke(NULL, "foo/fizzle/i-am-not-a-resource", AST_HTTP_GET, get_params, headers,
ast_json_null(), response);
ast_test_validate(test, 0 == invocation_count);
ast_test_validate(test, 404 == response->response_code);