74 "ARI web socket failed to set nonblock; closing: %s\n",
81 config->general->write_timeout);
109 uint64_t payload_len;
123 &payload_len, &opcode, &fragmented);
139 "WebSocket input failed to parse\n");
152#define VALIDATION_FAILED \
154 " \"error\": \"InvalidMessage\"," \
155 " \"message\": \"Message validation failed\"" \
178 ast_log(
LOG_NOTICE,
"Problem occurred during websocket write to %s, websocket closed\n",
Asterisk RESTful API hooks.
enum ast_json_encoding_format ast_ari_json_format(void)
Configured encoding format for JSON output.
struct ast_ari_websocket_session * ast_ari_websocket_session_create(struct ast_websocket *ws_session, int(*validator)(struct ast_json *))
Create an ARI WebSocket session.
static int null_validator(struct ast_json *json)
Validator that always succeeds.
struct ast_json * ast_ari_websocket_session_read(struct ast_ari_websocket_session *session)
Read a message from an ARI WebSocket.
static void websocket_session_dtor(void *obj)
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, struct ast_variable *headers)
Wrapper for invoking the websocket code for an incoming connection.
const char * ast_ari_websocket_session_id(const struct ast_ari_websocket_session *session)
Get the Session ID for an ARI WebSocket.
struct ast_sockaddr * ast_ari_websocket_session_get_remote_addr(struct ast_ari_websocket_session *session)
Get the remote address from an ARI WebSocket.
int ast_ari_websocket_session_write(struct ast_ari_websocket_session *session, struct ast_json *message)
Send a message to an ARI WebSocket.
#define VALIDATION_FAILED
Asterisk main include file. File version handling, generic pbx functions.
static struct ast_mansession session
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_alloc(data_size, destructor_fn)
static const char config[]
ast_http_method
HTTP Request methods known by Asterisk.
Support for WebSocket connections within the Asterisk HTTP server and client WebSocket connections to...
int ast_websocket_set_timeout(struct ast_websocket *session, int timeout)
Set the timeout on a non-blocking WebSocket session.
int ast_websocket_set_nonblock(struct ast_websocket *session)
Set the socket of a WebSocket session to be non-blocking.
const char * ast_websocket_session_id(struct ast_websocket *session)
Get the session ID for a WebSocket session.
int ast_websocket_read(struct ast_websocket *session, char **payload, uint64_t *payload_len, enum ast_websocket_opcode *opcode, int *fragmented)
Read a WebSocket frame and handle it.
struct ast_sockaddr * ast_websocket_remote_address(struct ast_websocket *session)
Get the remote address for a WebSocket connected session.
ast_websocket_opcode
WebSocket operation codes.
@ AST_WEBSOCKET_OPCODE_CLOSE
@ AST_WEBSOCKET_OPCODE_TEXT
void ast_websocket_unref(struct ast_websocket *session)
Decrease the reference count for a WebSocket session.
int ast_websocket_uri_cb(struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_vars, struct ast_variable *headers)
Callback suitable for use with a ast_http_uri.
int ast_websocket_write_string(struct ast_websocket *ws, const char *buf)
Construct and transmit a WebSocket frame containing string data.
int ast_websocket_fd(struct ast_websocket *session)
Get the file descriptor for a WebSocket session.
#define ast_debug(level,...)
Log a DEBUG message.
Internal API's for res_ari.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
void ast_json_free(void *p)
Asterisk's custom JSON allocator. Exposed for use by unit tests.
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
struct ast_json * ast_json_load_buf(const char *buffer, size_t buflen, struct ast_json_error *error)
Parse buffer with known length into a JSON object or array.
char * ast_json_dump_string_format(struct ast_json *root, enum ast_json_encoding_format format)
Encode a JSON value to a string.
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
struct ast_ari_conf * ast_ari_config_get(void)
Get the current ARI configuration.
Stasis Application API. See Stasis Application API for detailed documentation.
All configuration options for ARI.
struct ast_websocket * ws_session
int(* validator)(struct ast_json *)
Definition of a URI handler.
Abstract JSON element (object, array, string, int, ...).
Socket address structure.
describes a server instance
Structure for variables, used for configurations and for channel variables.
Structure for a WebSocket server.
Structure definition for session.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
int ast_wait_for_input(int fd, int ms)