45#define WEBSOCKET_GUID "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
48#define CLIENT_KEY_SIZE 16
51#define MAX_PROTOCOL_BUCKETS 7
55#define MAXIMUM_FRAME_SIZE 8192
60#define DEFAULT_RECONSTRUCTION_CEILING 8192
63#define MAXIMUM_RECONSTRUCTION_CEILING 8192
66#define MAXIMUM_FRAME_SIZE 65535
71#define DEFAULT_RECONSTRUCTION_CEILING MAXIMUM_FRAME_SIZE
74#define MAXIMUM_RECONSTRUCTION_CEILING MAXIMUM_FRAME_SIZE
84#define MAX_WS_HDR_SZ 14
85#define MIN_WS_HDR_SZ 2
110 const char *
name = obj;
119 const char *protocol = arg;
154 if (!server->protocols) {
182 ast_verb(2,
"WebSocket connection %s '%s' closed\n",
session->client ?
"to" :
"from",
201 if (!protocol->
name) {
242 "expected version '%u', got version '%u'\n",
260 ast_verb(5,
"WebSocket registered sub-protocol '%s'\n", protocol->name);
282 ast_verb(5,
"WebSocket unregistered sub-protocol '%s'\n",
name);
293 uint8_t mask_key_idx;
295 uint8_t length = frame[1] & 0x7f;
298 mask_key_idx = length == 126 ? 4 : length == 127 ? 10 : 2;
300 for (i = 0; i < payload_size; i++) {
301 payload[i] ^= ((
char *)&mask_key)[i % 4];
313 char frame[8] = { 0, };
314 int header_size, fsize, res;
321 header_size =
session->client ? 6 : 2;
322 fsize = header_size + 2;
346 ast_verb(2,
"WebSocket connection %s '%s' forcefully closed due to fatal write error\n",
351 return res ==
sizeof(frame);
376 size_t header_size = 2;
381 ast_debug(3,
"Writing websocket %s frame, length %" PRIu64
"\n",
384 if (payload_size < 126) {
385 length = payload_size;
386 }
else if (payload_size < (1 << 16)) {
412 }
else if (length == 127) {
416 memcpy(&frame[header_size],
payload, payload_size);
430 ast_debug(1,
"Closing WS with 1011 because we can't fulfill a write request\n");
473 return &
session->remote_address;
478 return &
session->local_address;
551 errno = ECONNABORTED;
566 if (rlen < 0 &&
errno != EAGAIN) {
605 int mask_present = 0;
606 char *mask =
NULL, *new_payload =
NULL;
623 fin = (
session->buf[0] >> 7) & 1;
624 mask_present = (
session->buf[1] >> 7) & 1;
627 options_len += mask_present ? 4 : 0;
670 (*payload)[pos] ^= mask[pos % 4];
709 session->payload = new_payload;
767 unsigned combined_length = strlen(key) + strlen(
WEBSOCKET_GUID) + 1;
786 ast_str_set(&http_header, 0,
"Sec-WebSocket-Version: 7, 8, 13\r\n");
794 char *requested_protocols =
NULL, *protocol =
NULL;
804 ast_http_error(ser, 501,
"Not Implemented",
"Attempt to use unimplemented / unsupported method");
811 for (v = headers; v; v = v->
next) {
812 if (!strcasecmp(v->
name,
"Upgrade")) {
814 }
else if (!strcasecmp(v->
name,
"Sec-WebSocket-Key")) {
816 }
else if (!strcasecmp(v->
name,
"Sec-WebSocket-Key1")) {
818 }
else if (!strcasecmp(v->
name,
"Sec-WebSocket-Key2")) {
820 }
else if (!strcasecmp(v->
name,
"Sec-WebSocket-Protocol")) {
822 }
else if (!strcasecmp(v->
name,
"Sec-WebSocket-Version")) {
831 ast_log(
LOG_WARNING,
"WebSocket connection from '%s' could not be accepted - did not request WebSocket\n",
840 if (!protocol_handler) {
842 ast_log(
LOG_WARNING,
"WebSocket connection from '%s' could not be accepted - no protocols requested\n",
847 }
else if (key1 && key2) {
850 ast_log(
LOG_WARNING,
"WebSocket connection from '%s' could not be accepted - unsupported version '00/76' chosen\n",
856 if (!protocol_handler && protos) {
859 while (!protocol_handler && (protocol =
strsep(&requested_protocols,
","))) {
865 if (!protocol_handler) {
866 ast_log(
LOG_WARNING,
"WebSocket connection from '%s' could not be accepted - no protocols out of '%s' supported\n",
899 ast_log(
LOG_WARNING,
"WebSocket connection from '%s' could not be accepted - failed to generate a session id\n",
901 ast_http_error(ser, 500,
"Internal Server Error",
"Allocation failed");
908 ast_debug(3,
"WebSocket connection from '%s' rejected by protocol handler '%s'\n",
926 "HTTP/1.1 101 Switching Protocols\r\n"
928 "Connection: Upgrade\r\n"
929 "Sec-WebSocket-Accept: %s\r\n"
930 "Sec-WebSocket-Protocol: %s\r\n\r\n",
936 "HTTP/1.1 101 Switching Protocols\r\n"
938 "Connection: Upgrade\r\n"
939 "Sec-WebSocket-Accept: %s\r\n\r\n",
946 ast_log(
LOG_WARNING,
"WebSocket connection from '%s' could not be accepted - unsupported version '%d' chosen\n",
955 ast_log(
LOG_WARNING,
"WebSocket connection from '%s' could not be accepted - failed to enable keepalive\n",
965 ast_log(
LOG_WARNING,
"WebSocket connection from '%s' could not be accepted - failed to get local address\n",
999 .description =
"Asterisk HTTP WebSocket",
1011 ast_debug(1,
"Entering WebSocket echo loop\n");
1019 uint64_t payload_len;
1034 ast_debug(1,
"Ignored WebSocket opcode %u\n", opcode);
1039 ast_debug(1,
"Exiting WebSocket echo loop\n");
1128 if (
args->tls_cfg) {
1153 args->accept_fd = -1;
1155 args->name =
"websocket client";
1168 snprintf(
args->hostname,
sizeof(
args->hostname),
1170 (
int) strcspn(host,
":"), host);
1190 memcpy(key + i, &num,
sizeof(
long));
1278 return ws->client->accept_protocol;
1284 if (response_code <= 0) {
1288 switch (response_code) {
1312 int has_upgrade = 0;
1313 int has_connection = 0;
1315 int has_protocol = 0;
1328 buf,
"HTTP/1.1", 101))) !=
WS_OK) {
1357 name,
"upgrade",
value,
"websocket")) < 0) {
1359 }
else if (!has_connection &&
1361 name,
"connection",
value,
"upgrade")) < 0) {
1363 }
else if (!has_accept &&
1369 }
else if (!has_protocol &&
1372 if (has_protocol < 0) {
1376 }
else if (!strcasecmp(
name,
"sec-websocket-extensions")) {
1378 "supported by client\n");
1383 return has_upgrade && has_connection && has_accept ?
1390 char protocols[100] =
"";
1393 sprintf(protocols,
"Sec-WebSocket-Protocol: %s\r\n",
1398 "GET /%s HTTP/1.1\r\n"
1399 "Sec-WebSocket-Version: %d\r\n"
1400 "Upgrade: websocket\r\n"
1401 "Connection: Upgrade\r\n"
1403 "Sec-WebSocket-Key: %s\r\n"
1441 (
const char *uri,
const char *protocols,
struct ast_tls_config *tls_cfg,
1479 while (fragmented) {
1483 "error reading string data\n");
1503 "non string data received\n");
1518 uint64_t
len = strlen(
buf);
1520 ast_debug(3,
"Writing websocket string of length %" PRIu64
"\n",
len);
Asterisk main include file. File version handling, generic pbx functions.
static struct ast_mansession session
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_strndup(str, len)
A wrapper for strndup()
#define ast_realloc(p, len)
A wrapper for realloc()
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_malloc(len)
A wrapper for malloc()
@ AO2_ALLOC_OPT_LOCK_MUTEX
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define ao2_unlink(container, obj)
Remove an object from a container.
#define ao2_link_flags(container, obj, flags)
Add an object to a container.
#define ao2_find(container, arg, flags)
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
@ OBJ_NOLOCK
Assume that the ao2_container is already locked.
#define ao2_alloc(data_size, destructor_fn)
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
static char version[AST_MAX_EXTENSION]
Generic File Format Support. Should be included by clients of the file handling routines....
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Support for Private Asterisk HTTP Servers.
void ast_http_send(struct ast_tcptls_session_instance *ser, enum ast_http_method method, int status_code, const char *status_title, struct ast_str *http_header, struct ast_str *out, int fd, unsigned int static_content)
Generic function for sending HTTP/1.1 response.
ast_http_method
HTTP Request methods known by Asterisk.
int ast_http_header_parse(char *buf, char **name, char **value)
Parse a header into the given name/value strings.
int ast_http_header_match_in(const char *name, const char *expected_name, const char *value, const char *expected_value)
Check if the header name matches the expected header name. If so, then check to see if the value can ...
void ast_http_uri_unlink(struct ast_http_uri *urihandler)
Unregister a URI handler.
int ast_http_body_discard(struct ast_tcptls_session_instance *ser)
Read and discard any unread HTTP request body.
int ast_http_header_match(const char *name, const char *expected_name, const char *value, const char *expected_value)
Check if the header and value match (case insensitive) their associated expected values.
int ast_http_response_status_line(const char *buf, const char *version, int code)
Parse the http response status line.
void ast_http_request_close_on_completion(struct ast_tcptls_session_instance *ser)
Request the HTTP connection be closed after this HTTP request.
void ast_http_error(struct ast_tcptls_session_instance *ser, int status, const char *title, const char *text)
Send HTTP error message and close socket.
int ast_http_uri_link(struct ast_http_uri *urihandler)
Register a URI handler.
Support for WebSocket connections within the Asterisk HTTP server and client WebSocket connections to...
#define AST_WEBSOCKET_PROTOCOL_VERSION
Protocol version. This prevents dynamically loadable modules from registering if this struct is chang...
ast_websocket_result
Result code for a websocket client.
#define AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT
Default websocket write timeout, in ms.
ast_websocket_opcode
WebSocket operation codes.
@ AST_WEBSOCKET_OPCODE_PING
@ AST_WEBSOCKET_OPCODE_PONG
@ AST_WEBSOCKET_OPCODE_CONTINUATION
@ AST_WEBSOCKET_OPCODE_BINARY
@ AST_WEBSOCKET_OPCODE_CLOSE
@ AST_WEBSOCKET_OPCODE_TEXT
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.
uint64_t ntohll(uint64_t net64)
char * strsep(char **str, const char *delims)
uint64_t htonll(uint64_t host64)
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_verb(level,...)
ssize_t ast_iostream_printf(struct ast_iostream *stream, const char *format,...)
Write a formatted string to an iostream.
ssize_t ast_iostream_gets(struct ast_iostream *stream, char *buffer, size_t size)
Read a LF-terminated string from an iostream.
void ast_iostream_set_timeout_inactivity(struct ast_iostream *stream, int timeout)
Set the iostream inactivity timeout timer.
SSL * ast_iostream_get_ssl(struct ast_iostream *stream)
Get a pointer to an iostream's OpenSSL SSL structure.
ssize_t ast_iostream_write(struct ast_iostream *stream, const void *buffer, size_t count)
Write data to an iostream.
int ast_iostream_get_fd(struct ast_iostream *stream)
Get an iostream's file descriptor.
void ast_iostream_set_exclusive_input(struct ast_iostream *stream, int exclusive_input)
Set the iostream if it can exclusively depend upon the set timeouts.
ssize_t ast_iostream_read(struct ast_iostream *stream, void *buffer, size_t count)
Read data from an iostream.
void ast_iostream_set_timeout_sequence(struct ast_iostream *stream, struct timeval start, int timeout)
Set the iostream I/O sequence timeout timer.
void ast_iostream_nonblock(struct ast_iostream *stream)
Make an iostream non-blocking.
int ast_iostream_close(struct ast_iostream *stream)
Close an iostream.
void ast_iostream_set_timeout_disable(struct ast_iostream *stream)
Disable the iostream timeout timer.
int ast_iostream_wait_for_input(struct ast_iostream *stream, int timeout)
Wait for input on the iostream's file descriptor.
#define SCOPED_AO2LOCK(varname, obj)
scoped lock specialization for ao2 mutexes.
Asterisk module definitions.
#define SCOPED_MODULE_USE(module)
@ AST_MODFLAG_GLOBAL_SYMBOLS
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODPRI_CHANNEL_DEPEND
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
int ast_getsockname(int sockfd, struct ast_sockaddr *addr)
Wrapper around getsockname(2) that uses struct ast_sockaddr.
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
static void ast_sockaddr_copy(struct ast_sockaddr *dst, const struct ast_sockaddr *src)
Copies the data from one ast_sockaddr to another.
int ast_sockaddr_resolve(struct ast_sockaddr **addrs, const char *str, int flags, int family)
Parses a string with an IPv4 or IPv6 address and place results into an array.
#define AST_OPTIONAL_API_NAME(name)
Expands to the name of the implementation function.
void AST_OPTIONAL_API_NAME() ast_websocket_ref(struct ast_websocket *session)
Increase the reference count for a WebSocket session.
#define MAXIMUM_FRAME_SIZE
Size of the pre-determined buffer for WebSocket frames.
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.
const char *AST_OPTIONAL_API_NAME() ast_websocket_session_id(struct ast_websocket *session)
Get the session ID for a WebSocket session.
static void websocket_client_destroy(void *obj)
static enum ast_websocket_result websocket_client_handle_response_code(struct websocket_client *client, int response_code)
static void websocket_echo_callback(struct ast_websocket *session, struct ast_variable *parameters, struct ast_variable *headers)
Simple echo implementation which echoes received text and binary frames.
int AST_OPTIONAL_API_NAME() ast_websocket_write(struct ast_websocket *session, enum ast_websocket_opcode opcode, char *payload, uint64_t payload_size)
Write function for websocket traffic.
static void websocket_bad_request(struct ast_tcptls_session_instance *ser)
static struct ast_http_uri websocketuri
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.
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.
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.
static enum ast_websocket_result websocket_client_handshake_get_response(struct websocket_client *client)
static struct ast_websocket_protocol * one_protocol(struct ast_websocket_server *server)
If the server has exactly one configured protocol, return it.
static void websocket_client_args_destroy(void *obj)
static int ws_safe_read(struct ast_websocket *session, char *buf, size_t len, enum ast_websocket_opcode *opcode)
struct ast_sockaddr *AST_OPTIONAL_API_NAME() ast_websocket_local_address(struct ast_websocket *session)
Get the local address for a WebSocket connection session.
static enum ast_websocket_result websocket_client_connect(struct ast_websocket *ws, int timeout)
static int websocket_remove_protocol_internal(const char *name, ast_websocket_callback callback)
static struct ast_websocket * websocket_client_create(struct ast_websocket_client_options *options, enum ast_websocket_result *result)
#define MAX_PROTOCOL_BUCKETS
Number of buckets for registered protocols.
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_sockaddr *AST_OPTIONAL_API_NAME() ast_websocket_remote_address(struct ast_websocket *session)
Get the remote address for a WebSocket connected session.
static struct ast_websocket_server * websocket_server_internal_create(void)
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_is_secure(struct ast_websocket *session)
Get whether the WebSocket session is using a secure transport or not.
static void websocket_server_dtor(void *obj)
static enum ast_websocket_result websocket_client_handshake(struct websocket_client *client)
static void websocket_mask_payload(struct ast_websocket *session, char *frame, char *payload, uint64_t payload_size)
Perform payload masking for client sessions.
void AST_OPTIONAL_API_NAME() ast_websocket_reconstruct_disable(struct ast_websocket *session)
Disable multi-frame reconstruction.
static int protocol_cmp_fn(void *obj, void *arg, int flags)
Comparison function for protocols.
#define DEFAULT_RECONSTRUCTION_CEILING
Default reconstruction size for multi-frame payload reconstruction. If exceeded the next frame will s...
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.
static char * websocket_client_create_key(void)
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_fd(struct ast_websocket *session)
Get the file descriptor for a WebSocket session.
static void protocol_destroy_fn(void *obj)
Destructor function for protocols.
static char * websocket_combine_key(const char *key, char *res, int res_size)
static int websocket_client_parse_uri(const char *uri, char **host, struct ast_str **path)
Parse the given uri into a path and remote address.
static struct ast_websocket_server * websocket_server_create_impl(void)
const char *AST_OPTIONAL_API_NAME() ast_websocket_client_accept_protocol(struct ast_websocket *ws)
Retrieve the server accepted sub-protocol on the client.
static int protocol_hash_fn(const void *obj, const int flags)
Hashing function for protocols.
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_server_add_protocol(struct ast_websocket_server *server, const char *name, ast_websocket_callback callback)
Add a sub-protocol handler to the given server.
static int websocket_add_protocol_internal(const char *name, ast_websocket_callback callback)
#define CLIENT_KEY_SIZE
Length of a websocket's client key.
static int load_module(void)
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.
static int unload_module(void)
#define WEBSOCKET_GUID
GUID used to compute the accept key, defined in the specifications.
struct ast_websocket_protocol *AST_OPTIONAL_API_NAME() ast_websocket_sub_protocol_alloc(const char *name)
Allocate a websocket sub-protocol instance.
int AST_OPTIONAL_API_NAME() ast_websocket_set_timeout(struct ast_websocket *session, int timeout)
Set the timeout on a non-blocking WebSocket 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_close(struct ast_websocket *session, uint16_t reason)
Close function for websocket session.
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_remove_protocol(const char *name, ast_websocket_callback callback)
Remove a sub-protocol handler from the default /ws server.
static void session_destroy_fn(void *obj)
Destructor function for sessions.
void AST_OPTIONAL_API_NAME() ast_websocket_unref(struct ast_websocket *session)
Decrease the reference count for a WebSocket session.
static const char * websocket_opcode2str(enum ast_websocket_opcode opcode)
static const char * opcode_map[]
static struct ast_tcptls_session_args * websocket_client_args_create(const char *host, struct ast_tls_config *tls_cfg, enum ast_websocket_result *result)
int AST_OPTIONAL_API_NAME() ast_websocket_read_string(struct ast_websocket *ws, char **buf)
Read a WebSocket frame containing string data.
int AST_OPTIONAL_API_NAME() ast_websocket_add_protocol2(struct ast_websocket_protocol *protocol)
Add a sub-protocol handler to the default /ws server.
#define MAXIMUM_RECONSTRUCTION_CEILING
Maximum reconstruction size for multi-frame payload reconstruction.
String manipulation functions.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
static force_inline int attribute_pure ast_str_case_hash(const char *str)
Compute a hash value on a case-insensitive string.
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Definition of a URI handler.
ast_http_callback callback
Socket address structure.
Support for dynamic strings.
arguments for the accepting thread
struct ast_tls_config * tls_cfg
describes a server instance
struct ast_iostream * stream
struct ast_sockaddr remote_address
Stores parsed uri information.
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
Options used for a websocket client.
struct ast_tls_config * tls_cfg
A websocket protocol implementation.
ast_websocket_callback session_established
Callback called when a new session is established. Mandatory.
unsigned int version
Protocol version. Should be set to /ref AST_WEBSOCKET_PROTOCOL_VERSION.
char * name
Name of the protocol.
ast_websocket_pre_callback session_attempted
Callback called when a new session is attempted. Optional.
Structure for a WebSocket server.
struct ao2_container * protocols
Structure definition for session.
char buf[MAXIMUM_FRAME_SIZE]
struct ast_iostream * stream
struct websocket_client * client
struct ast_sockaddr local_address
uint16_t close_status_code
struct ast_sockaddr remote_address
char session_id[AST_UUID_STR_LEN]
enum ast_websocket_opcode opcode
struct ast_tcptls_session_args * args
struct ast_tcptls_session_instance * ser
struct ast_str * resource_name
void ast_ssl_teardown(struct ast_tls_config *cfg)
free resources used by an SSL server
struct ast_tcptls_session_instance * ast_tcptls_client_create(struct ast_tcptls_session_args *desc)
Creates a client connection's ast_tcptls_session_instance.
struct ast_tcptls_session_instance * ast_tcptls_client_start_timeout(struct ast_tcptls_session_instance *tcptls_session, int timeout)
Attempt to connect and start a tcptls session within the given timeout.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Handle unaligned data access.
static void put_unaligned_uint16(void *p, unsigned short datum)
static unsigned short get_unaligned_uint16(const void *p)
static void put_unaligned_uint64(void *p, uint64_t datum)
static void put_unaligned_uint32(void *p, unsigned int datum)
static uint64_t get_unaligned_uint64(const void *p)
const char * ast_uri_path(const struct ast_uri *uri)
Retrieve the uri path.
struct ast_uri * ast_uri_parse_websocket(const char *uri)
Parse the given websocket uri into a structure.
const char * ast_uri_query(const struct ast_uri *uri)
Retrieve the uri query parameters.
char * ast_uri_make_host_with_port(const struct ast_uri *uri)
Retrieve a string of the host and port.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
int ast_base64encode(char *dst, const unsigned char *src, int srclen, int max)
Encode data in base64.
long int ast_random(void)
#define ast_fd_set_flags(fd, flags)
Set flags on the given file descriptor.
void ast_sha1_hash_uint(uint8_t *digest, const char *input)
Produces SHA1 hash based on input string, stored in uint8_t array.
Universally unique identifier support.
char * ast_uuid_generate_str(char *buf, size_t size)
Generate a UUID string.