| Asterisk - The Open Source Telephony Project GIT-master-27fb039
    | 
Support for WebSocket connections within the Asterisk HTTP server and client WebSocket connections to a server. More...


Go to the source code of this file.
| Data Structures | |
| struct | ast_websocket_client_options | 
| Options used for a websocket client.  More... | |
| struct | ast_websocket_protocol | 
| A websocket protocol implementation.  More... | |
| Macros | |
| #define | AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT 100 | 
| Default websocket write timeout, in ms. | |
| #define | AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT_STR "100" | 
| Default websocket write timeout, in ms (as a string) | |
| #define | AST_WEBSOCKET_MAX_RX_PAYLOAD_SIZE 65535 | 
| Size of the pre-determined buffer for WebSocket frames. | |
| #define | AST_WEBSOCKET_PROTOCOL_VERSION 1 | 
| Protocol version. This prevents dynamically loadable modules from registering if this struct is changed. | |
| Typedefs | |
| typedef void(* | ast_websocket_callback) (struct ast_websocket *session, struct ast_variable *parameters, struct ast_variable *headers) | 
| Callback for when a new connection for a sub-protocol is established. | |
| typedef int(* | ast_websocket_pre_callback) (struct ast_tcptls_session_instance *ser, struct ast_variable *parameters, struct ast_variable *headers, const char *session_id) | 
| Callback from the HTTP request attempting to establish a websocket connection. | |
| Enumerations | |
| enum | ast_websocket_opcode { AST_WEBSOCKET_OPCODE_TEXT = 0x1 , AST_WEBSOCKET_OPCODE_BINARY = 0x2 , AST_WEBSOCKET_OPCODE_PING = 0x9 , AST_WEBSOCKET_OPCODE_PONG = 0xA , AST_WEBSOCKET_OPCODE_CLOSE = 0x8 , AST_WEBSOCKET_OPCODE_CONTINUATION = 0x0 } | 
| WebSocket operation codes.  More... | |
| enum | ast_websocket_result { WS_OK = 0 , WS_ALLOCATE_ERROR , WS_KEY_ERROR , WS_URI_PARSE_ERROR , WS_URI_RESOLVE_ERROR , WS_BAD_STATUS , WS_INVALID_RESPONSE , WS_BAD_REQUEST , WS_URL_NOT_FOUND , WS_HEADER_MISMATCH , WS_HEADER_MISSING , WS_NOT_SUPPORTED , WS_WRITE_ERROR , WS_CLIENT_START_ERROR , WS_UNAUTHORIZED } | 
| Result code for a websocket client.  More... | |
| enum | ast_websocket_type { AST_WS_TYPE_CLIENT_PERSISTENT = (1 << 0) , AST_WS_TYPE_CLIENT_PER_CALL_CONFIG = (1 << 1) , AST_WS_TYPE_CLIENT_PER_CALL = (1 << 2) , AST_WS_TYPE_CLIENT = (1 << 3) , AST_WS_TYPE_INBOUND = (1 << 4) , AST_WS_TYPE_SERVER = (1 << 5) , AST_WS_TYPE_ANY = (0xFFFFFFFF) } | 
| WebSocket connection/configuration types.  More... | |
| Functions | |
| int AST_OPTIONAL_API_NAME() | ast_websocket_add_protocol (const char *name, ast_websocket_callback callback) | 
| Add a sub-protocol handler to the default /ws server. | |
| int AST_OPTIONAL_API_NAME() | ast_websocket_add_protocol2 (struct ast_websocket_protocol *protocol) | 
| Add a sub-protocol handler to the default /ws server. | |
| const char *AST_OPTIONAL_API_NAME() | ast_websocket_client_accept_protocol (struct ast_websocket *ws) | 
| Retrieve the server accepted sub-protocol on the client. | |
| struct ast_websocket *AST_OPTIONAL_API_NAME() | ast_websocket_client_create (const char *uri, const char *protocols, struct ast_tls_config *tls_cfg, enum ast_websocket_result *result) | 
| Create, and connect, a websocket client. | |
| struct ast_websocket *AST_OPTIONAL_API_NAME() | ast_websocket_client_create_with_options (struct ast_websocket_client_options *options, enum ast_websocket_result *result) | 
| Create, and connect, a websocket client using given options. | |
| int AST_OPTIONAL_API_NAME() | ast_websocket_close (struct ast_websocket *session, uint16_t reason) | 
| Close a WebSocket session by sending a message with the CLOSE opcode and an optional code. | |
| int AST_OPTIONAL_API_NAME() | ast_websocket_fd (struct ast_websocket *session) | 
| Get the file descriptor for a WebSocket session. | |
| int AST_OPTIONAL_API_NAME() | ast_websocket_is_secure (struct ast_websocket *session) | 
| Get whether the WebSocket session is using a secure transport or not. | |
| struct ast_sockaddr *AST_OPTIONAL_API_NAME() | ast_websocket_local_address (struct ast_websocket *session) | 
| Get the local address for a WebSocket connection session. | |
| int AST_OPTIONAL_API_NAME() | 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. | |
| int AST_OPTIONAL_API_NAME() | ast_websocket_read_string (struct ast_websocket *ws, char **buf) | 
| Read a WebSocket frame containing string data. | |
| void AST_OPTIONAL_API_NAME() | ast_websocket_reconstruct_disable (struct ast_websocket *session) | 
| Disable multi-frame reconstruction. | |
| void AST_OPTIONAL_API_NAME() | ast_websocket_reconstruct_enable (struct ast_websocket *session, size_t bytes) | 
| Enable multi-frame reconstruction up to a certain number of bytes. | |
| void AST_OPTIONAL_API_NAME() | ast_websocket_ref (struct ast_websocket *session) | 
| Increase the reference count for a WebSocket session. | |
| struct ast_sockaddr *AST_OPTIONAL_API_NAME() | ast_websocket_remote_address (struct ast_websocket *session) | 
| Get the remote address for a WebSocket connected session. | |
| int AST_OPTIONAL_API_NAME() | ast_websocket_remove_protocol (const char *name, ast_websocket_callback callback) | 
| Remove a sub-protocol handler from the default /ws server. | |
| const char *AST_OPTIONAL_API_NAME() | ast_websocket_result_to_str (enum ast_websocket_result result) | 
| Convert a websocket result code to a string. | |
| int AST_OPTIONAL_API_NAME() | ast_websocket_server_add_protocol (struct ast_websocket_server *server, const char *name, ast_websocket_callback callback) | 
| Add a sub-protocol handler to the given server. | |
| int AST_OPTIONAL_API_NAME() | ast_websocket_server_add_protocol2 (struct ast_websocket_server *server, struct ast_websocket_protocol *protocol) | 
| Add a sub-protocol handler to the given server. | |
| struct ast_websocket_server *AST_OPTIONAL_API_NAME() | ast_websocket_server_create (void) | 
| Creates a ast_websocket_server. | |
| int AST_OPTIONAL_API_NAME() | ast_websocket_server_remove_protocol (struct ast_websocket_server *server, const char *name, ast_websocket_callback callback) | 
| Remove a sub-protocol handler from the given server. | |
| const char *AST_OPTIONAL_API_NAME() | ast_websocket_session_id (struct ast_websocket *session) | 
| Get the session ID for a WebSocket session. | |
| int AST_OPTIONAL_API_NAME() | ast_websocket_set_nonblock (struct ast_websocket *session) | 
| Set the socket of a WebSocket session to be non-blocking. | |
| int AST_OPTIONAL_API_NAME() | ast_websocket_set_timeout (struct ast_websocket *session, int timeout) | 
| Set the timeout on a non-blocking WebSocket session. | |
| struct ast_websocket_protocol *AST_OPTIONAL_API_NAME() | ast_websocket_sub_protocol_alloc (const char *name) | 
| Allocate a websocket sub-protocol instance. | |
| const char * | ast_websocket_type_to_str (enum ast_websocket_type type) | 
| void AST_OPTIONAL_API_NAME() | ast_websocket_unref (struct ast_websocket *session) | 
| Decrease the reference count for a WebSocket session. | |
| int AST_OPTIONAL_API_NAME() | 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_OPTIONAL_API_NAME() | ast_websocket_wait_for_input (struct ast_websocket *session, int timeout) | 
| Wait for the WebSocket session to be ready to be read. | |
| int AST_OPTIONAL_API_NAME() | ast_websocket_write (struct ast_websocket *session, enum ast_websocket_opcode opcode, char *payload, uint64_t payload_size) | 
| Construct and transmit a WebSocket frame. | |
| int AST_OPTIONAL_API_NAME() | ast_websocket_write_string (struct ast_websocket *ws, const char *buf) | 
| Construct and transmit a WebSocket frame containing string data. | |
Support for WebSocket connections within the Asterisk HTTP server and client WebSocket connections to a server.
Supported WebSocket versions in server implementation: Version 7 defined in specification http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-07 Version 8 defined in specification http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10 Version 13 defined in specification http://tools.ietf.org/html/rfc6455 Supported WebSocket versions in client implementation: Version 13 defined in specification http://tools.ietf.org/html/rfc6455
Definition in file http_websocket.h.
| #define AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT 100 | 
Default websocket write timeout, in ms.
Definition at line 28 of file http_websocket.h.
| #define AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT_STR "100" | 
Default websocket write timeout, in ms (as a string)
Definition at line 31 of file http_websocket.h.
| #define AST_WEBSOCKET_MAX_RX_PAYLOAD_SIZE 65535 | 
Size of the pre-determined buffer for WebSocket frames.
Definition at line 85 of file http_websocket.h.
| #define AST_WEBSOCKET_PROTOCOL_VERSION 1 | 
Protocol version. This prevents dynamically loadable modules from registering if this struct is changed.
Definition at line 148 of file http_websocket.h.
| typedef void(* ast_websocket_callback) (struct ast_websocket *session, struct ast_variable *parameters, struct ast_variable *headers) | 
Callback for when a new connection for a sub-protocol is established.
| session | A WebSocket session structure | 
| parameters | Parameters extracted from the request URI | 
| headers | Headers included in the request | 
Definition at line 129 of file http_websocket.h.
| typedef int(* ast_websocket_pre_callback) (struct ast_tcptls_session_instance *ser, struct ast_variable *parameters, struct ast_variable *headers, const char *session_id) | 
Callback from the HTTP request attempting to establish a websocket connection.
This callback occurs when an HTTP request is made to establish a websocket connection. Implementers of ast_websocket_protocol can use this to deny a request, or to set up application specific data before invocation of ast_websocket_callback.
| ser | The TCP/TLS session | 
| parameters | Parameters extracted from the request URI | 
| headers | Headers included in the request | 
| session_id | The id of the current session. | 
| 0 | The session should be accepted | 
| -1 | The session should be rejected. Note that the caller must send an error response using ast_http_error. | 
Definition at line 116 of file http_websocket.h.
| enum ast_websocket_opcode | 
WebSocket operation codes.
Definition at line 71 of file http_websocket.h.
| enum ast_websocket_result | 
Result code for a websocket client.
Definition at line 427 of file http_websocket.h.
| enum ast_websocket_type | 
WebSocket connection/configuration types.
These may look like they overlap or are redundant, but they're shared by other modules like ari and chan_websocket and it didn't make sense to force them to define their own types.
| Enumerator | |
|---|---|
| AST_WS_TYPE_CLIENT_PERSISTENT | |
| AST_WS_TYPE_CLIENT_PER_CALL_CONFIG | |
| AST_WS_TYPE_CLIENT_PER_CALL | |
| AST_WS_TYPE_CLIENT | |
| AST_WS_TYPE_INBOUND | |
| AST_WS_TYPE_SERVER | |
| AST_WS_TYPE_ANY | |
Definition at line 57 of file http_websocket.h.
| int AST_OPTIONAL_API_NAME() ast_websocket_add_protocol | ( | const char * | name, | 
| ast_websocket_callback | callback | ||
| ) | 
Add a sub-protocol handler to the default /ws server.
| name | Name of the sub-protocol to register | 
| callback | Callback called when a new connection requesting the sub-protocol is established | 
| 0 | success | 
| -1 | if sub-protocol handler could not be registered | 
Definition at line 1068 of file res_http_websocket.c.
References callback(), name, and websocket_add_protocol_internal().
Referenced by AST_TEST_DEFINE(), and load_module().
| int AST_OPTIONAL_API_NAME() ast_websocket_add_protocol2 | ( | struct ast_websocket_protocol * | protocol | ) | 
Add a sub-protocol handler to the default /ws server.
| protocol | The sub-protocol to register. Note that this must be allocated using /ref ast_websocket_sub_protocol_alloc. | 
protocol on success.| 0 | success | 
| -1 | if sub-protocol handler could not be registered | 
Definition at line 1073 of file res_http_websocket.c.
References ast_websocket_server_add_protocol2(), ast_http_uri::data, and websocketuri.
| const char *AST_OPTIONAL_API_NAME() ast_websocket_client_accept_protocol | ( | struct ast_websocket * | ws | ) | 
Retrieve the server accepted sub-protocol on the client.
| ws | the websocket client | 
Definition at line 1318 of file res_http_websocket.c.
References websocket_client::accept_protocol, and ast_websocket::client.
Referenced by AST_TEST_DEFINE().
| struct ast_websocket *AST_OPTIONAL_API_NAME() ast_websocket_client_create | ( | const char * | uri, | 
| const char * | protocols, | ||
| struct ast_tls_config * | tls_cfg, | ||
| enum ast_websocket_result * | result | ||
| ) | 
Create, and connect, a websocket client.
If the client websocket successfully connects, then the accepted protocol can be checked via a call to ast_websocket_client_accept_protocol.
ws[s]://<address>[:port][/<path>]The address (can be a host name) and port are parsed out and used to connect to the remote server. If multiple IPs are returned during address resolution then the first one is chosen.
| uri | uri to connect to | 
| protocols | a comma separated string of supported protocols | 
| tls_cfg | secure websocket credentials | 
| result | result code set on client failure | 
| NULL | if object could not be created or connected | 
Definition at line 1515 of file res_http_websocket.c.
References ast_websocket_client_create_with_options(), options, ast_websocket_client_options::protocols, result, ast_websocket_client_options::tls_cfg, and ast_websocket_client_options::uri.
Referenced by AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), and AST_TEST_DEFINE().
| struct ast_websocket *AST_OPTIONAL_API_NAME() ast_websocket_client_create_with_options | ( | struct ast_websocket_client_options * | options, | 
| enum ast_websocket_result * | result | ||
| ) | 
Create, and connect, a websocket client using given options.
If the client websocket successfully connects, then the accepted protocol can be checked via a call to ast_websocket_client_accept_protocol.
| options | Websocket client options | 
| result | result code set on client failure | 
| NULL | if object could not be created or connected | 
Definition at line 1529 of file res_http_websocket.c.
References ao2_ref, NULL, options, result, websocket_client_connect(), websocket_client_create(), and WS_OK.
Referenced by ast_websocket_client_connect(), ast_websocket_client_create(), and websocket_connect().
| int AST_OPTIONAL_API_NAME() ast_websocket_close | ( | struct ast_websocket * | session, | 
| uint16_t | reason | ||
| ) | 
Close a WebSocket session by sending a message with the CLOSE opcode and an optional code.
| session | Pointer to the WebSocket session | 
| reason | Reason code for closing the session as defined in the RFC | 
| 0 | if successfully written | 
| -1 | if error occurred | 
Close a WebSocket session by sending a message with the CLOSE opcode and an optional code.
Definition at line 324 of file res_http_websocket.c.
References ao2_lock, ao2_unlock, ast_iostream_close(), ast_iostream_set_timeout_disable(), ast_iostream_set_timeout_inactivity(), ast_iostream_write(), ast_sockaddr_stringify(), ast_verb, AST_WEBSOCKET_OPCODE_CLOSE, NULL, ast_websocket::opcode, put_unaligned_uint16(), session, and websocket_mask_payload().
Referenced by ast_websocket_read(), ast_websocket_write(), incoming_ws_established_cb(), outbound_session_apply_config(), outbound_session_handler_thread(), outbound_session_pc_close_thread(), outbound_sessions_load(), session_destroy_fn(), session_shutdown_cb(), webchan_hangup(), and ws_shutdown().
| int AST_OPTIONAL_API_NAME() ast_websocket_fd | ( | struct ast_websocket * | session | ) | 
Get the file descriptor for a WebSocket session.
Definition at line 477 of file res_http_websocket.c.
References ast_iostream_get_fd(), and session.
Referenced by incoming_ws_established_cb(), read_from_ws_and_queue(), session_read(), speech_test_server_cb(), webchan_call(), websocket_echo_callback(), websocket_read(), and ws_shutdown().
| int AST_OPTIONAL_API_NAME() ast_websocket_is_secure | ( | struct ast_websocket * | session | ) | 
Get whether the WebSocket session is using a secure transport or not.
| 0 | if unsecure | 
| 1 | if secure | 
Definition at line 497 of file res_http_websocket.c.
References session.
Referenced by transport_create().
| struct ast_sockaddr *AST_OPTIONAL_API_NAME() ast_websocket_local_address | ( | struct ast_websocket * | session | ) | 
Get the local address for a WebSocket connection session.
Definition at line 492 of file res_http_websocket.c.
References session.
Referenced by transport_create().
| int AST_OPTIONAL_API_NAME() 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.
| session | Pointer to the WebSocket session | 
| payload | Pointer to a char* which will be populated with a pointer to the payload if present | 
| payload_len | Pointer to a uint64_t which will be populated with the length of the payload if present | 
| opcode | Pointer to an enum which will be populated with the opcode of the frame | 
| fragmented | Pointer to an int which is set to 1 if payload is fragmented and 0 if not | 
| -1 | on error | 
| 0 | on success | 
Definition at line 618 of file res_http_websocket.c.
References ast_free, ast_log, ast_realloc, ast_websocket_close(), AST_WEBSOCKET_MAX_RX_PAYLOAD_SIZE, AST_WEBSOCKET_OPCODE_BINARY, AST_WEBSOCKET_OPCODE_CLOSE, AST_WEBSOCKET_OPCODE_CONTINUATION, AST_WEBSOCKET_OPCODE_PING, AST_WEBSOCKET_OPCODE_PONG, AST_WEBSOCKET_OPCODE_TEXT, ast_websocket_write(), frame_size, get_unaligned_uint16(), get_unaligned_uint64(), LOG_WARNING, MIN_WS_HDR_SZ, ntohll(), NULL, ast_websocket::opcode, ast_websocket::payload, ast_websocket::payload_len, session, and ws_safe_read().
Referenced by ast_websocket_read_string(), read_from_ws_and_queue(), session_read(), speech_test_server_cb(), websocket_cb(), websocket_echo_callback(), and websocket_read().
| int AST_OPTIONAL_API_NAME() ast_websocket_read_string | ( | struct ast_websocket * | ws, | 
| char ** | buf | ||
| ) | 
Read a WebSocket frame containing string data.
| ws | pointer to the websocket | 
| buf | string buffer to populate with data read from socket | 
| -1 | on error | 
Definition at line 1546 of file res_http_websocket.c.
References ast_log, ast_strndup, AST_WEBSOCKET_OPCODE_CLOSE, AST_WEBSOCKET_OPCODE_CONTINUATION, AST_WEBSOCKET_OPCODE_PING, AST_WEBSOCKET_OPCODE_TEXT, ast_websocket_read(), buf, LOG_ERROR, ast_websocket::opcode, ast_websocket::payload, and ast_websocket::payload_len.
Referenced by AST_TEST_DEFINE().
| void AST_OPTIONAL_API_NAME() ast_websocket_reconstruct_disable | ( | struct ast_websocket * | session | ) | 
Disable multi-frame reconstruction.
| session | Pointer to the WebSocket session | 
Definition at line 462 of file res_http_websocket.c.
References session.
| void AST_OPTIONAL_API_NAME() ast_websocket_reconstruct_enable | ( | struct ast_websocket * | session, | 
| size_t | bytes | ||
| ) | 
Enable multi-frame reconstruction up to a certain number of bytes.
| session | Pointer to the WebSocket session | 
| bytes | If a reconstructed payload exceeds the specified number of bytes the payload will be returned and upon reception of the next multi-frame a new reconstructed payload will begin. | 
Definition at line 457 of file res_http_websocket.c.
References MAXIMUM_RECONSTRUCTION_CEILING, MIN, and session.
| void AST_OPTIONAL_API_NAME() ast_websocket_ref | ( | struct ast_websocket * | session | ) | 
Increase the reference count for a WebSocket session.
| session | Pointer to the WebSocket session | 
Definition at line 467 of file res_http_websocket.c.
References ao2_ref, and session.
Referenced by transport_create().
| struct ast_sockaddr *AST_OPTIONAL_API_NAME() ast_websocket_remote_address | ( | struct ast_websocket * | session | ) | 
Get the remote address for a WebSocket connected session.
Definition at line 487 of file res_http_websocket.c.
References session.
Referenced by ari_websocket_send_event(), session_update(), session_write(), transport_create(), transport_read(), and websocket_established_cb().
| int AST_OPTIONAL_API_NAME() ast_websocket_remove_protocol | ( | const char * | name, | 
| ast_websocket_callback | callback | ||
| ) | 
Remove a sub-protocol handler from the default /ws server.
| name | Name of the sub-protocol to unregister | 
| callback | Session Established callback that was previously registered with the sub-protocol | 
| 0 | success | 
| -1 | if sub-protocol was not found or if callback did not match | 
Definition at line 1097 of file res_http_websocket.c.
References callback(), name, and websocket_remove_protocol_internal().
Referenced by AST_TEST_DEFINE(), and unload_module().
| const char *AST_OPTIONAL_API_NAME() ast_websocket_result_to_str | ( | enum ast_websocket_result | result | ) | 
Convert a websocket result code to a string.
| result | The result code to convert | 
Definition at line 1626 of file res_http_websocket.c.
References ARRAY_IN_BOUNDS, result, and websocket_result_string_map.
Referenced by ast_websocket_client_connect(), and webchan_call().
| int AST_OPTIONAL_API_NAME() ast_websocket_server_add_protocol | ( | struct ast_websocket_server * | server, | 
| const char * | name, | ||
| ast_websocket_callback | callback | ||
| ) | 
Add a sub-protocol handler to the given server.
| server | The server to add the sub-protocol to | 
| name | Name of the sub-protocol to register | 
| callback | Callback called when a new connection requesting the sub-protocol is established | 
| 0 | success | 
| -1 | if sub-protocol handler could not be registered | 
Definition at line 226 of file res_http_websocket.c.
References ao2_ref, ast_websocket_server_add_protocol2(), ast_websocket_sub_protocol_alloc(), callback(), name, ast_websocket_server::protocols, and ast_websocket_protocol::session_established.
Referenced by websocket_add_protocol_internal().
| int AST_OPTIONAL_API_NAME() ast_websocket_server_add_protocol2 | ( | struct ast_websocket_server * | server, | 
| struct ast_websocket_protocol * | protocol | ||
| ) | 
Add a sub-protocol handler to the given server.
| server | The server to add the sub-protocol to. | 
| protocol | The sub-protocol to register. Note that this must be allocated using /ref ast_websocket_sub_protocol_alloc. | 
protocol on success.| 0 | success | 
| -1 | if sub-protocol handler could not be registered | 
Definition at line 248 of file res_http_websocket.c.
References ao2_find, ao2_link_flags, ao2_lock, ao2_ref, ao2_unlock, ast_debug, ast_log, AST_WEBSOCKET_PROTOCOL_VERSION, LOG_WARNING, OBJ_KEY, OBJ_NOLOCK, and ast_websocket_server::protocols.
Referenced by ari_websocket_load_module(), ast_websocket_add_protocol2(), ast_websocket_server_add_protocol(), and load_module().
| struct ast_websocket_server *AST_OPTIONAL_API_NAME() ast_websocket_server_create | ( | void | ) | 
Creates a ast_websocket_server.
| NULL | on error | 
Definition at line 183 of file res_http_websocket.c.
References websocket_server_create_impl().
Referenced by ari_websocket_load_module(), and load_module().
| int AST_OPTIONAL_API_NAME() ast_websocket_server_remove_protocol | ( | struct ast_websocket_server * | server, | 
| const char * | name, | ||
| ast_websocket_callback | callback | ||
| ) | 
Remove a sub-protocol handler from the given server.
| server | The server to unregister the sub-protocol from | 
| name | Name of the sub-protocol to unregister | 
| callback | Callback that was previously registered with the sub-protocol | 
| 0 | success | 
| -1 | if sub-protocol was not found or if callback did not match | 
Definition at line 282 of file res_http_websocket.c.
References ao2_find, ao2_ref, ao2_unlink, ast_debug, callback(), name, OBJ_KEY, ast_websocket_server::protocols, and ast_websocket_protocol::session_established.
Referenced by websocket_remove_protocol_internal().
| const char *AST_OPTIONAL_API_NAME() ast_websocket_session_id | ( | struct ast_websocket * | session | ) | 
Get the session ID for a WebSocket session.
Definition at line 516 of file res_http_websocket.c.
References session.
Referenced by websocket_established_cb().
| int AST_OPTIONAL_API_NAME() ast_websocket_set_nonblock | ( | struct ast_websocket * | session | ) | 
Set the socket of a WebSocket session to be non-blocking.
| 0 | on success | 
| -1 | on failure | 
Definition at line 502 of file res_http_websocket.c.
References ast_iostream_nonblock(), ast_iostream_set_exclusive_input(), and session.
Referenced by session_update(), and websocket_cb().
| int AST_OPTIONAL_API_NAME() ast_websocket_set_timeout | ( | struct ast_websocket * | session, | 
| int | timeout | ||
| ) | 
Set the timeout on a non-blocking WebSocket session.
| 0 | on success | 
| -1 | on failure | 
Definition at line 509 of file res_http_websocket.c.
References session, and ast_websocket::timeout.
Referenced by session_update(), and websocket_cb().
| struct ast_websocket_protocol *AST_OPTIONAL_API_NAME() ast_websocket_sub_protocol_alloc | ( | const char * | name | ) | 
Allocate a websocket sub-protocol instance.
| NULL | on error | 
Definition at line 207 of file res_http_websocket.c.
References ao2_alloc, ao2_ref, ast_strdup, AST_WEBSOCKET_PROTOCOL_VERSION, name, ast_websocket_protocol::name, NULL, protocol_destroy_fn(), and ast_websocket_protocol::version.
Referenced by ari_websocket_load_module(), ast_websocket_server_add_protocol(), and load_module().
| const char * ast_websocket_type_to_str | ( | enum ast_websocket_type | type | ) | 
Definition at line 100 of file res_http_websocket.c.
References AST_WS_TYPE_ANY, AST_WS_TYPE_CLIENT, AST_WS_TYPE_CLIENT_PER_CALL, AST_WS_TYPE_CLIENT_PER_CALL_CONFIG, AST_WS_TYPE_CLIENT_PERSISTENT, AST_WS_TYPE_INBOUND, AST_WS_TYPE_SERVER, and type.
| void AST_OPTIONAL_API_NAME() ast_websocket_unref | ( | struct ast_websocket * | session | ) | 
Decrease the reference count for a WebSocket session.
| session | Pointer to the WebSocket session | 
Definition at line 472 of file res_http_websocket.c.
References ao2_cleanup, and session.
Referenced by incoming_ws_established_cb(), outbound_session_handler_thread(), session_dtor(), speech_test_server_cb(), transport_dtor(), webchan_hangup(), websocket_cb(), websocket_destructor(), websocket_disconnect(), websocket_echo_callback(), and websocket_established_cb().
| int AST_OPTIONAL_API_NAME() 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.
Set the data field of the ast_http_uri to ast_websocket_server.
Definition at line 806 of file res_http_websocket.c.
References ao2_alloc, ao2_find, ao2_ref, ast_debug, AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT, ast_getsockname(), ast_http_body_discard(), ast_http_error(), AST_HTTP_GET, ast_iostream_get_fd(), ast_iostream_get_ssl(), ast_iostream_printf(), ast_iostream_set_exclusive_input(), ast_log, ast_sockaddr_copy(), ast_sockaddr_stringify(), ast_strdupa, ast_strip(), ast_strlen_zero(), ast_uuid_generate_str(), AST_UUID_STR_LEN, base64, ast_http_uri::data, DEFAULT_RECONSTRUCTION_CEILING, LOG_WARNING, method, ast_variable::name, ast_websocket_protocol::name, ast_variable::next, NULL, OBJ_KEY, one_protocol(), ast_websocket_server::protocols, ast_tcptls_session_instance::remote_address, SCOPED_MODULE_USE, ast_module_info::self, session, ast_websocket_protocol::session_attempted, session_destroy_fn(), ast_websocket_protocol::session_established, ast_tcptls_session_instance::stream, strsep(), ast_variable::value, version, websocket_bad_request(), websocket_combine_key(), and WEBSOCKET_GUID.
Referenced by ari_handle_websocket(), and incoming_ws_http_callback().
| int AST_OPTIONAL_API_NAME() ast_websocket_wait_for_input | ( | struct ast_websocket * | session, | 
| int | timeout | ||
| ) | 
Wait for the WebSocket session to be ready to be read.
| session | Pointer to the WebSocket session | 
| timeout | the number of milliseconds to wait | 
| -1 | if error occurred | 
| 0 | if the timeout expired | 
| 1 | if the WebSocket session is ready for reading | 
Definition at line 482 of file res_http_websocket.c.
References ast_iostream_wait_for_input(), session, and ast_websocket::timeout.
Referenced by speech_test_server_cb(), websocket_cb(), websocket_echo_callback(), and websocket_read().
| int AST_OPTIONAL_API_NAME() ast_websocket_write | ( | struct ast_websocket * | session, | 
| enum ast_websocket_opcode | opcode, | ||
| char * | payload, | ||
| uint64_t | payload_size | ||
| ) | 
Construct and transmit a WebSocket frame.
| session | Pointer to the WebSocket session | 
| opcode | WebSocket operation code to place in the frame | 
| payload | Optional pointer to a payload to add to the frame | 
| payload_size | Length of the payload (0 if no payload) | 
| 0 | if successfully written | 
| -1 | if error occurred | 
Construct and transmit a WebSocket frame.
Definition at line 390 of file res_http_websocket.c.
References ao2_lock, ao2_unlock, ast_alloca, ast_debug, ast_iostream_set_timeout_disable(), ast_iostream_set_timeout_sequence(), ast_iostream_write(), ast_tvnow(), ast_websocket_close(), frame_size, htonll(), ast_websocket::opcode, ast_websocket::payload, put_unaligned_uint16(), put_unaligned_uint64(), session, websocket_mask_payload(), and websocket_opcode2str().
Referenced by ast_websocket_read(), ast_websocket_write_string(), speech_test_server_cb(), webchan_write(), websocket_echo_callback(), websocket_write(), and ws_send_msg().
| int AST_OPTIONAL_API_NAME() ast_websocket_write_string | ( | struct ast_websocket * | ws, | 
| const char * | buf | ||
| ) | 
Construct and transmit a WebSocket frame containing string data.
| ws | pointer to the websocket | 
| buf | string data to write to socket | 
| 0 | if successfully written | 
| -1 | if error occurred | 
Definition at line 1590 of file res_http_websocket.c.
References ast_debug, AST_WEBSOCKET_OPCODE_TEXT, ast_websocket_write(), buf, and len().
Referenced by AST_TEST_DEFINE(), dequeue_frame(), process_text_message(), queue_frame_from_buffer(), read_thread_handler(), session_write(), speech_test_server_handle_request(), and webchan_send_dtmf_text().