Asterisk - The Open Source Telephony Project  21.4.1
Data Structures | Macros | Typedefs | Enumerations | Functions
http_websocket.h File Reference

Support for WebSocket connections within the Asterisk HTTP server and client WebSocket connections to a server. More...

#include "asterisk/http.h"
#include "asterisk/optional_api.h"
#include <errno.h>

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_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. More...
 
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. More...
 

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, 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
}
 Result code for a websocket client.
 

Functions

static void __dtor__ast_websocket_add_protocol (void)
 
static void __dtor__ast_websocket_add_protocol2 (void)
 
static void __dtor__ast_websocket_client_accept_protocol (void)
 
static void __dtor__ast_websocket_client_create (void)
 
static void __dtor__ast_websocket_client_create_with_options (void)
 
static void __dtor__ast_websocket_close (void)
 
static void __dtor__ast_websocket_fd (void)
 
static void __dtor__ast_websocket_is_secure (void)
 
static void __dtor__ast_websocket_local_address (void)
 
static void __dtor__ast_websocket_read (void)
 
static void __dtor__ast_websocket_read_string (void)
 
static void __dtor__ast_websocket_reconstruct_disable (void)
 
static void __dtor__ast_websocket_reconstruct_enable (void)
 
static void __dtor__ast_websocket_ref (void)
 
static void __dtor__ast_websocket_remote_address (void)
 
static void __dtor__ast_websocket_remove_protocol (void)
 
static void __dtor__ast_websocket_server_add_protocol (void)
 
static void __dtor__ast_websocket_server_add_protocol2 (void)
 
static void __dtor__ast_websocket_server_create (void)
 
static void __dtor__ast_websocket_server_remove_protocol (void)
 
static void __dtor__ast_websocket_session_id (void)
 
static void __dtor__ast_websocket_set_nonblock (void)
 
static void __dtor__ast_websocket_set_timeout (void)
 
static void __dtor__ast_websocket_sub_protocol_alloc (void)
 
static void __dtor__ast_websocket_unref (void)
 
static void __dtor__ast_websocket_uri_cb (void)
 
static void __dtor__ast_websocket_wait_for_input (void)
 
static void __dtor__ast_websocket_write (void)
 
static void __dtor__ast_websocket_write_string (void)
 
static void __init__ast_websocket_add_protocol (void)
 
static void __init__ast_websocket_add_protocol2 (void)
 
static void __init__ast_websocket_client_accept_protocol (void)
 
static void __init__ast_websocket_client_create (void)
 
static void __init__ast_websocket_client_create_with_options (void)
 
static void __init__ast_websocket_close (void)
 
static void __init__ast_websocket_fd (void)
 
static void __init__ast_websocket_is_secure (void)
 
static void __init__ast_websocket_local_address (void)
 
static void __init__ast_websocket_read (void)
 
static void __init__ast_websocket_read_string (void)
 
static void __init__ast_websocket_reconstruct_disable (void)
 
static void __init__ast_websocket_reconstruct_enable (void)
 
static void __init__ast_websocket_ref (void)
 
static void __init__ast_websocket_remote_address (void)
 
static void __init__ast_websocket_remove_protocol (void)
 
static void __init__ast_websocket_server_add_protocol (void)
 
static void __init__ast_websocket_server_add_protocol2 (void)
 
static void __init__ast_websocket_server_create (void)
 
static void __init__ast_websocket_server_remove_protocol (void)
 
static void __init__ast_websocket_session_id (void)
 
static void __init__ast_websocket_set_nonblock (void)
 
static void __init__ast_websocket_set_timeout (void)
 
static void __init__ast_websocket_sub_protocol_alloc (void)
 
static void __init__ast_websocket_unref (void)
 
static void __init__ast_websocket_uri_cb (void)
 
static void __init__ast_websocket_wait_for_input (void)
 
static void __init__ast_websocket_write (void)
 
static void __init__ast_websocket_write_string (void)
 
static int __stub__ast_websocket_add_protocol (const char *name, ast_websocket_callback callback)
 Add a sub-protocol handler to the default /ws server. More...
 
static int __stub__ast_websocket_add_protocol2 (struct ast_websocket_protocol *protocol)
 Add a sub-protocol handler to the default /ws server. More...
 
static const char * __stub__ast_websocket_client_accept_protocol (struct ast_websocket *ws)
 Retrieve the server accepted sub-protocol on the client. More...
 
static struct ast_websocket__stub__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. More...
 
static struct ast_websocket__stub__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. More...
 
static int __stub__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. More...
 
static int __stub__ast_websocket_fd (struct ast_websocket *session)
 Get the file descriptor for a WebSocket session. More...
 
static int __stub__ast_websocket_is_secure (struct ast_websocket *session)
 Get whether the WebSocket session is using a secure transport or not. More...
 
static struct ast_sockaddr__stub__ast_websocket_local_address (struct ast_websocket *session)
 Get the local address for a WebSocket connection session. More...
 
static int __stub__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. More...
 
static int __stub__ast_websocket_read_string (struct ast_websocket *ws, char **buf)
 Read a WebSocket frame containing string data. More...
 
static void __stub__ast_websocket_reconstruct_disable (struct ast_websocket *session)
 Disable multi-frame reconstruction. More...
 
static void __stub__ast_websocket_reconstruct_enable (struct ast_websocket *session, size_t bytes)
 Enable multi-frame reconstruction up to a certain number of bytes. More...
 
static void __stub__ast_websocket_ref (struct ast_websocket *session)
 Increase the reference count for a WebSocket session. More...
 
static struct ast_sockaddr__stub__ast_websocket_remote_address (struct ast_websocket *session)
 Get the remote address for a WebSocket connected session. More...
 
static int __stub__ast_websocket_remove_protocol (const char *name, ast_websocket_callback callback)
 Remove a sub-protocol handler from the default /ws server. More...
 
static int __stub__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. More...
 
static int __stub__ast_websocket_server_add_protocol2 (struct ast_websocket_server *server, struct ast_websocket_protocol *protocol)
 Add a sub-protocol handler to the given server. More...
 
static struct ast_websocket_server__stub__ast_websocket_server_create (void)
 Creates a ast_websocket_server. More...
 
static int __stub__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. More...
 
static const char * __stub__ast_websocket_session_id (struct ast_websocket *session)
 Get the session ID for a WebSocket session. More...
 
static int __stub__ast_websocket_set_nonblock (struct ast_websocket *session)
 Set the socket of a WebSocket session to be non-blocking. More...
 
static int __stub__ast_websocket_set_timeout (struct ast_websocket *session, int timeout)
 Set the timeout on a non-blocking WebSocket session. More...
 
static struct ast_websocket_protocol__stub__ast_websocket_sub_protocol_alloc (const char *name)
 Allocate a websocket sub-protocol instance. More...
 
static void __stub__ast_websocket_unref (struct ast_websocket *session)
 Decrease the reference count for a WebSocket session. More...
 
static int __stub__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. More...
 
static int __stub__ast_websocket_wait_for_input (struct ast_websocket *session, int timeout)
 Wait for the WebSocket session to be ready to be read. More...
 
static int __stub__ast_websocket_write (struct ast_websocket *session, enum ast_websocket_opcode opcode, char *payload, uint64_t payload_size)
 Construct and transmit a WebSocket frame. More...
 
static int __stub__ast_websocket_write_string (struct ast_websocket *ws, const char *buf)
 Construct and transmit a WebSocket frame containing string data. More...
 
static typeof (__stub__ast_websocket_server_create)*ast_websocket_server_create
 
static typeof (__stub__ast_websocket_uri_cb)*ast_websocket_uri_cb
 
static typeof (__stub__ast_websocket_sub_protocol_alloc)*ast_websocket_sub_protocol_alloc
 
static typeof (__stub__ast_websocket_add_protocol)*ast_websocket_add_protocol
 
static typeof (__stub__ast_websocket_add_protocol2)*ast_websocket_add_protocol2
 
static typeof (__stub__ast_websocket_remove_protocol)*ast_websocket_remove_protocol
 
static typeof (__stub__ast_websocket_server_add_protocol)*ast_websocket_server_add_protocol
 
static typeof (__stub__ast_websocket_server_add_protocol2)*ast_websocket_server_add_protocol2
 
static typeof (__stub__ast_websocket_server_remove_protocol)*ast_websocket_server_remove_protocol
 
static typeof (__stub__ast_websocket_read)*ast_websocket_read
 
static typeof (__stub__ast_websocket_read_string)*ast_websocket_read_string
 
static typeof (__stub__ast_websocket_write)*ast_websocket_write
 
static typeof (__stub__ast_websocket_write_string)*ast_websocket_write_string
 
static typeof (__stub__ast_websocket_close)*ast_websocket_close
 
static typeof (__stub__ast_websocket_reconstruct_enable)*ast_websocket_reconstruct_enable
 
static typeof (__stub__ast_websocket_reconstruct_disable)*ast_websocket_reconstruct_disable
 
static typeof (__stub__ast_websocket_ref)*ast_websocket_ref
 
static typeof (__stub__ast_websocket_unref)*ast_websocket_unref
 
static typeof (__stub__ast_websocket_fd)*ast_websocket_fd
 
static typeof (__stub__ast_websocket_wait_for_input)*ast_websocket_wait_for_input
 
static typeof (__stub__ast_websocket_remote_address)*ast_websocket_remote_address
 
static typeof (__stub__ast_websocket_local_address)*ast_websocket_local_address
 
static typeof (__stub__ast_websocket_is_secure)*ast_websocket_is_secure
 
static typeof (__stub__ast_websocket_set_nonblock)*ast_websocket_set_nonblock
 
static typeof (__stub__ast_websocket_session_id)*ast_websocket_session_id
 
static typeof (__stub__ast_websocket_client_create)*ast_websocket_client_create
 
static typeof (__stub__ast_websocket_client_create_with_options)*ast_websocket_client_create_with_options
 
static typeof (__stub__ast_websocket_client_accept_protocol)*ast_websocket_client_accept_protocol
 
static typeof (__stub__ast_websocket_set_timeout)*ast_websocket_set_timeout
 

Detailed Description

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

Author
Joshua Colp jcolp.nosp@m.@dig.nosp@m.ium.c.nosp@m.om

Definition in file http_websocket.h.

Typedef Documentation

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.

Parameters
sessionA WebSocket session structure
parametersParameters extracted from the request URI
headersHeaders included in the request
Note
Once called the ownership of the session is transferred to the sub-protocol handler. It is responsible for closing and cleaning up.

Definition at line 101 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.

Parameters
serThe TCP/TLS session
parametersParameters extracted from the request URI
headersHeaders included in the request
session_idThe id of the current session.
Return values
0The session should be accepted
-1The session should be rejected. Note that the caller must send an error response using ast_http_error.
Since
13.5.0

Definition at line 88 of file http_websocket.h.

Enumeration Type Documentation

WebSocket operation codes.

Enumerator
AST_WEBSOCKET_OPCODE_TEXT 

Text frame

AST_WEBSOCKET_OPCODE_BINARY 

Binary frame

AST_WEBSOCKET_OPCODE_PING 

Request that the other side respond with a pong

AST_WEBSOCKET_OPCODE_PONG 

Response to a ping

AST_WEBSOCKET_OPCODE_CLOSE 

Connection is being closed

AST_WEBSOCKET_OPCODE_CONTINUATION 

Continuation of a previous frame

Definition at line 51 of file http_websocket.h.

51  {
52  AST_WEBSOCKET_OPCODE_TEXT = 0x1, /*!< Text frame */
53  AST_WEBSOCKET_OPCODE_BINARY = 0x2, /*!< Binary frame */
54  AST_WEBSOCKET_OPCODE_PING = 0x9, /*!< Request that the other side respond with a pong */
55  AST_WEBSOCKET_OPCODE_PONG = 0xA, /*!< Response to a ping */
56  AST_WEBSOCKET_OPCODE_CLOSE = 0x8, /*!< Connection is being closed */
57  AST_WEBSOCKET_OPCODE_CONTINUATION = 0x0, /*!< Continuation of a previous frame */
58 };

Function Documentation

static int __stub__ast_websocket_add_protocol ( const char *  name,
ast_websocket_callback  callback 
)
static

Add a sub-protocol handler to the default /ws server.

Parameters
nameName of the sub-protocol to register
callbackCallback called when a new connection requesting the sub-protocol is established
Return values
0success
-1if sub-protocol handler could not be registered

Definition at line 164 of file http_websocket.h.

164 {return -1;});
static int __stub__ast_websocket_add_protocol2 ( struct ast_websocket_protocol protocol)
static

Add a sub-protocol handler to the default /ws server.

Parameters
protocolThe sub-protocol to register. Note that this must be allocated using /ref ast_websocket_sub_protocol_alloc.
Note
This method is reference stealing. It will steal the reference to protocol on success.
Return values
0success
-1if sub-protocol handler could not be registered
Since
13.5.0

Definition at line 179 of file http_websocket.h.

179 {return -1;});
static const char* __stub__ast_websocket_client_accept_protocol ( struct ast_websocket ws)
static

Retrieve the server accepted sub-protocol on the client.

Parameters
wsthe websocket client
Returns
the accepted client sub-protocol.
Since
13

Definition at line 500 of file http_websocket.h.

500 { return NULL;});
static struct ast_websocket* __stub__ast_websocket_client_create ( const char *  uri,
const char *  protocols,
struct ast_tls_config tls_cfg,
enum ast_websocket_result result 
)
static

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.

Note
While connecting this will block until a response is received from the remote host.
Expected uri form:
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.
Parameters
uriuri to connect to
protocolsa comma separated string of supported protocols
tls_cfgsecure websocket credentials
resultresult code set on client failure
Returns
a client websocket.
Return values
NULLif object could not be created or connected
Since
13

Definition at line 441 of file http_websocket.h.

441 { return NULL;});
static struct ast_websocket* __stub__ast_websocket_client_create_with_options ( struct ast_websocket_client_options options,
enum ast_websocket_result result 
)
static

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.

Note
While connecting this will block until a response is received from the remote host, or the connection timeout is reached
Parameters
optionsWebsocket client options
resultresult code set on client failure
Returns
a client websocket.
Return values
NULLif object could not be created or connected

Definition at line 490 of file http_websocket.h.

490 { return NULL;});
static int __stub__ast_websocket_close ( struct ast_websocket session,
uint16_t  reason 
)
static

Close a WebSocket session by sending a message with the CLOSE opcode and an optional code.

Parameters
sessionPointer to the WebSocket session
reasonReason code for closing the session as defined in the RFC
Return values
0if successfully written
-1if error occurred

Definition at line 299 of file http_websocket.h.

299 { errno = ENOSYS; return -1;});
static int __stub__ast_websocket_fd ( struct ast_websocket session)
static

Get the file descriptor for a WebSocket session.

Returns
file descriptor
Note
You must not directly read from or write to this file descriptor. It should only be used for polling.

Definition at line 341 of file http_websocket.h.

341 { errno = ENOSYS; return -1;});
static int __stub__ast_websocket_is_secure ( struct ast_websocket session)
static

Get whether the WebSocket session is using a secure transport or not.

Return values
0if unsecure
1if secure

Definition at line 379 of file http_websocket.h.

379 { errno = ENOSYS; return -1;});
static struct ast_sockaddr* __stub__ast_websocket_local_address ( struct ast_websocket session)
static

Get the local address for a WebSocket connection session.

Returns
Local address
Since
13.19.0

Definition at line 371 of file http_websocket.h.

371 {return NULL;});
static int __stub__ast_websocket_read ( struct ast_websocket session,
char **  payload,
uint64_t *  payload_len,
enum ast_websocket_opcode opcode,
int *  fragmented 
)
static

Read a WebSocket frame and handle it.

Parameters
sessionPointer to the WebSocket session
payloadPointer to a char* which will be populated with a pointer to the payload if present
payload_lenPointer to a uint64_t which will be populated with the length of the payload if present
opcodePointer to an enum which will be populated with the opcode of the frame
fragmentedPointer to an int which is set to 1 if payload is fragmented and 0 if not
Return values
-1on error
0on success
Note
Once an AST_WEBSOCKET_OPCODE_CLOSE opcode is received the socket will be closed

Definition at line 248 of file http_websocket.h.

248 { errno = ENOSYS; return -1;});
static int __stub__ast_websocket_read_string ( struct ast_websocket ws,
char **  buf 
)
static

Read a WebSocket frame containing string data.

Note
The caller is responsible for freeing the output "buf".
Parameters
wspointer to the websocket
bufstring buffer to populate with data read from socket
Return values
-1on error
Returns
number of bytes read on success
Note
Once an AST_WEBSOCKET_OPCODE_CLOSE opcode is received the socket will be closed

Definition at line 264 of file http_websocket.h.

264 { errno = ENOSYS; return -1;});
static void __stub__ast_websocket_reconstruct_disable ( struct ast_websocket session)
static

Disable multi-frame reconstruction.

Parameters
sessionPointer to the WebSocket session
Note
If reconstruction is disabled each message that is part of a multi-frame message will be sent up to the user when ast_websocket_read is called.

Definition at line 318 of file http_websocket.h.

318 {return;});
static void __stub__ast_websocket_reconstruct_enable ( struct ast_websocket session,
size_t  bytes 
)
static

Enable multi-frame reconstruction up to a certain number of bytes.

Parameters
sessionPointer to the WebSocket session
bytesIf 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 308 of file http_websocket.h.

308 {return;});
static void __stub__ast_websocket_ref ( struct ast_websocket session)
static

Increase the reference count for a WebSocket session.

Parameters
sessionPointer to the WebSocket session

Definition at line 325 of file http_websocket.h.

325 {return;});
static struct ast_sockaddr* __stub__ast_websocket_remote_address ( struct ast_websocket session)
static

Get the remote address for a WebSocket connected session.

Returns
Remote address

Definition at line 362 of file http_websocket.h.

362 {return NULL;});
static int __stub__ast_websocket_remove_protocol ( const char *  name,
ast_websocket_callback  callback 
)
static

Remove a sub-protocol handler from the default /ws server.

Parameters
nameName of the sub-protocol to unregister
callbackSession Established callback that was previously registered with the sub-protocol
Return values
0success
-1if sub-protocol was not found or if callback did not match

Definition at line 190 of file http_websocket.h.

190 {return -1;});
static int __stub__ast_websocket_server_add_protocol ( struct ast_websocket_server server,
const char *  name,
ast_websocket_callback  callback 
)
static

Add a sub-protocol handler to the given server.

Parameters
serverThe server to add the sub-protocol to
nameName of the sub-protocol to register
callbackCallback called when a new connection requesting the sub-protocol is established
Return values
0success
-1if sub-protocol handler could not be registered
Since
12

Definition at line 203 of file http_websocket.h.

203 {return -1;});
static int __stub__ast_websocket_server_add_protocol2 ( struct ast_websocket_server server,
struct ast_websocket_protocol protocol 
)
static

Add a sub-protocol handler to the given server.

Parameters
serverThe server to add the sub-protocol to.
protocolThe sub-protocol to register. Note that this must be allocated using /ref ast_websocket_sub_protocol_alloc.
Note
This method is reference stealing. It will steal the reference to protocol on success.
Return values
0success
-1if sub-protocol handler could not be registered
Since
13.5.0

Definition at line 219 of file http_websocket.h.

219 {return -1;});
static struct ast_websocket_server* __stub__ast_websocket_server_create ( void  )
static

Creates a ast_websocket_server.

Returns
New ast_websocket_server instance
Return values
NULLon error
Since
12

Definition at line 136 of file http_websocket.h.

136 { return NULL; });
static int __stub__ast_websocket_server_remove_protocol ( struct ast_websocket_server server,
const char *  name,
ast_websocket_callback  callback 
)
static

Remove a sub-protocol handler from the given server.

Parameters
serverThe server to unregister the sub-protocol from
nameName of the sub-protocol to unregister
callbackCallback that was previously registered with the sub-protocol
Return values
0success
-1if sub-protocol was not found or if callback did not match
Since
12

Definition at line 232 of file http_websocket.h.

232 {return -1;});
static const char* __stub__ast_websocket_session_id ( struct ast_websocket session)
static

Get the session ID for a WebSocket session.

Returns
session id

Definition at line 394 of file http_websocket.h.

394 { errno = ENOSYS; return NULL;});
static int __stub__ast_websocket_set_nonblock ( struct ast_websocket session)
static

Set the socket of a WebSocket session to be non-blocking.

Return values
0on success
-1on failure

Definition at line 387 of file http_websocket.h.

387 { errno = ENOSYS; return -1;});
static int __stub__ast_websocket_set_timeout ( struct ast_websocket session,
int  timeout 
)
static

Set the timeout on a non-blocking WebSocket session.

Since
11.11.0
12.4.0
Return values
0on success
-1on failure

Definition at line 511 of file http_websocket.h.

511 {return -1;});
static struct ast_websocket_protocol* __stub__ast_websocket_sub_protocol_alloc ( const char *  name)
static

Allocate a websocket sub-protocol instance.

Returns
An instance of ast_websocket_protocol on success
Return values
NULLon error
Since
13.5.0

Definition at line 153 of file http_websocket.h.

153 {return NULL;});
static void __stub__ast_websocket_unref ( struct ast_websocket session)
static

Decrease the reference count for a WebSocket session.

Parameters
sessionPointer to the WebSocket session

Definition at line 332 of file http_websocket.h.

332 {return;});
static int __stub__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 
)
static

Callback suitable for use with a ast_http_uri.

Set the data field of the ast_http_uri to ast_websocket_server.

Since
12

Definition at line 144 of file http_websocket.h.

144 { return -1; });
static int __stub__ast_websocket_wait_for_input ( struct ast_websocket session,
int  timeout 
)
static

Wait for the WebSocket session to be ready to be read.

Since
16.8.0
17.2.0
Parameters
sessionPointer to the WebSocket session
timeoutthe number of milliseconds to wait
Return values
-1if error occurred
0if the timeout expired
1if the WebSocket session is ready for reading

Definition at line 355 of file http_websocket.h.

355 { errno = ENOSYS; return -1; });
static int __stub__ast_websocket_write ( struct ast_websocket session,
enum ast_websocket_opcode  opcode,
char *  payload,
uint64_t  payload_size 
)
static

Construct and transmit a WebSocket frame.

Parameters
sessionPointer to the WebSocket session
opcodeWebSocket operation code to place in the frame
payloadOptional pointer to a payload to add to the frame
payload_sizeLength of the payload (0 if no payload)
Return values
0if successfully written
-1if error occurred

Definition at line 277 of file http_websocket.h.

277 { errno = ENOSYS; return -1;});
static int __stub__ast_websocket_write_string ( struct ast_websocket ws,
const char *  buf 
)
static

Construct and transmit a WebSocket frame containing string data.

Parameters
wspointer to the websocket
bufstring data to write to socket
Return values
0if successfully written
-1if error occurred

Definition at line 289 of file http_websocket.h.

289 { errno = ENOSYS; return -1;});