Asterisk - The Open Source Telephony Project GIT-master-c753fe4
http_websocket.h
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2012, Digium, Inc.
5 *
6 * Joshua Colp <jcolp@digium.com>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19#ifndef _ASTERISK_HTTP_WEBSOCKET_H
20#define _ASTERISK_HTTP_WEBSOCKET_H
21
22#include "asterisk/http.h"
24
25#include <errno.h>
26
27/*! \brief Default websocket write timeout, in ms */
28#define AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT 100
29
30/*! \brief Default websocket write timeout, in ms (as a string) */
31#define AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT_STR "100"
32
33/*!
34 * \file
35 *
36 * \brief Support for WebSocket connections within the Asterisk HTTP server and client
37 * WebSocket connections to a server.
38 *
39 * Supported WebSocket versions in server implementation:
40 * Version 7 defined in specification http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-07
41 * Version 8 defined in specification http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10
42 * Version 13 defined in specification http://tools.ietf.org/html/rfc6455
43 * Supported WebSocket versions in client implementation:
44 * Version 13 defined in specification http://tools.ietf.org/html/rfc6455
45 *
46 * \author Joshua Colp <jcolp@digium.com>
47 *
48 */
49
50/*! \brief WebSocket connection/configuration types.
51 *
52 * These may look like they overlap or are redundant, but
53 * they're shared by other modules like ari and chan_websocket
54 * and it didn't make sense to force them to define their
55 * own types.
56 */
64 AST_WS_TYPE_ANY = (0xFFFFFFFF),
65};
66
68
69
70/*! \brief WebSocket operation codes */
72 AST_WEBSOCKET_OPCODE_TEXT = 0x1, /*!< Text frame */
73 AST_WEBSOCKET_OPCODE_BINARY = 0x2, /*!< Binary frame */
74 AST_WEBSOCKET_OPCODE_PING = 0x9, /*!< Request that the other side respond with a pong */
75 AST_WEBSOCKET_OPCODE_PONG = 0xA, /*!< Response to a ping */
76 AST_WEBSOCKET_OPCODE_CLOSE = 0x8, /*!< Connection is being closed */
77 AST_WEBSOCKET_OPCODE_CONTINUATION = 0x0, /*!< Continuation of a previous frame */
78};
79
80/*!
81 * \brief Opaque structure for WebSocket server.
82 * \since 12
83 */
85
86/*!
87 * \brief Opaque structure for WebSocket sessions.
88 */
89struct ast_websocket;
90
91/*!
92 * \brief Callback from the HTTP request attempting to establish a websocket connection
93 *
94 * This callback occurs when an HTTP request is made to establish a websocket connection.
95 * Implementers of \ref ast_websocket_protocol can use this to deny a request, or to
96 * set up application specific data before invocation of \ref ast_websocket_callback.
97 *
98 * \param ser The TCP/TLS session
99 * \param parameters Parameters extracted from the request URI
100 * \param headers Headers included in the request
101 * \param session_id The id of the current session.
102 *
103 * \retval 0 The session should be accepted
104 * \retval -1 The session should be rejected. Note that the caller must send an error
105 * response using \ref ast_http_error.
106 * \since 13.5.0
107 */
108typedef int (*ast_websocket_pre_callback)(struct ast_tcptls_session_instance *ser, struct ast_variable *parameters, struct ast_variable *headers, const char *session_id);
109
110/*!
111 * \brief Callback for when a new connection for a sub-protocol is established
112 *
113 * \param session A WebSocket session structure
114 * \param parameters Parameters extracted from the request URI
115 * \param headers Headers included in the request
116 *
117 * \note Once called the ownership of the session is transferred to the sub-protocol handler. It
118 * is responsible for closing and cleaning up.
119 *
120 */
121typedef void (*ast_websocket_callback)(struct ast_websocket *session, struct ast_variable *parameters, struct ast_variable *headers);
122
123/*!
124 * \brief A websocket protocol implementation
125 *
126 * Users of the Websocket API can register themselves as a websocket
127 * protocol. See \ref ast_websocket_add_protocol2 and \ref ast_websocket_server_add_protocol2.
128 * Simpler implementations may use only \ref ast_websocket_add_protocol and
129 * \ref ast_websocket_server_add_protocol.
130 *
131 * \since 13.5.0
132 */
134 /*! \brief Name of the protocol */
135 char *name;
136/*!
137 * \brief Protocol version. This prevents dynamically loadable modules from registering
138 * if this struct is changed.
139 */
140#define AST_WEBSOCKET_PROTOCOL_VERSION 1
141 /*! \brief Protocol version. Should be set to /ref AST_WEBSOCKET_PROTOCOL_VERSION */
142 unsigned int version;
143 /*! \brief Callback called when a new session is attempted. Optional. */
145 /*! \brief Callback called when a new session is established. Mandatory. */
147};
148
149/*!
150 * \brief Creates a \ref ast_websocket_server
151 *
152 * \return New \ref ast_websocket_server instance
153 * \retval NULL on error
154 * \since 12
155 */
157
158/*!
159 * \brief Callback suitable for use with a \ref ast_http_uri.
160 *
161 * Set the data field of the ast_http_uri to \ref ast_websocket_server.
162 * \since 12
163 */
164AST_OPTIONAL_API(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), { return -1; });
165
166/*!
167 * \brief Allocate a websocket sub-protocol instance
168 *
169 * \return An instance of \ref ast_websocket_protocol on success
170 * \retval NULL on error
171 * \since 13.5.0
172 */
174
175/*!
176 * \brief Add a sub-protocol handler to the default /ws server
177 *
178 * \param name Name of the sub-protocol to register
179 * \param callback Callback called when a new connection requesting the sub-protocol is established
180 *
181 * \retval 0 success
182 * \retval -1 if sub-protocol handler could not be registered
183 */
185
186/*!
187 * \brief Add a sub-protocol handler to the default /ws server
188 *
189 * \param protocol The sub-protocol to register. Note that this must
190 * be allocated using /ref ast_websocket_sub_protocol_alloc.
191 *
192 * \note This method is reference stealing. It will steal the reference to \p protocol
193 * on success.
194 *
195 * \retval 0 success
196 * \retval -1 if sub-protocol handler could not be registered
197 * \since 13.5.0
198 */
199AST_OPTIONAL_API(int, ast_websocket_add_protocol2, (struct ast_websocket_protocol *protocol), {return -1;});
200
201/*!
202 * \brief Remove a sub-protocol handler from the default /ws server.
203 *
204 * \param name Name of the sub-protocol to unregister
205 * \param callback Session Established callback that was previously registered with the sub-protocol
206 *
207 * \retval 0 success
208 * \retval -1 if sub-protocol was not found or if callback did not match
209 */
211
212/*!
213 * \brief Add a sub-protocol handler to the given server.
214 *
215 * \param server The server to add the sub-protocol to
216 * \param name Name of the sub-protocol to register
217 * \param callback Callback called when a new connection requesting the sub-protocol is established
218 *
219 * \retval 0 success
220 * \retval -1 if sub-protocol handler could not be registered
221 * \since 12
222 */
224
225/*!
226 * \brief Add a sub-protocol handler to the given server.
227 *
228 * \param server The server to add the sub-protocol to.
229 * \param protocol The sub-protocol to register. Note that this must
230 * be allocated using /ref ast_websocket_sub_protocol_alloc.
231 *
232 * \note This method is reference stealing. It will steal the reference to \p protocol
233 * on success.
234 *
235 * \retval 0 success
236 * \retval -1 if sub-protocol handler could not be registered
237 * \since 13.5.0
238 */
239AST_OPTIONAL_API(int, ast_websocket_server_add_protocol2, (struct ast_websocket_server *server, struct ast_websocket_protocol *protocol), {return -1;});
240
241/*!
242 * \brief Remove a sub-protocol handler from the given server.
243 *
244 * \param server The server to unregister the sub-protocol from
245 * \param name Name of the sub-protocol to unregister
246 * \param callback Callback that was previously registered with the sub-protocol
247 *
248 * \retval 0 success
249 * \retval -1 if sub-protocol was not found or if callback did not match
250 * \since 12
251 */
253
254/*!
255 * \brief Read a WebSocket frame and handle it
256 *
257 * \param session Pointer to the WebSocket session
258 * \param payload Pointer to a char* which will be populated with a pointer to the payload if present
259 * \param payload_len Pointer to a uint64_t which will be populated with the length of the payload if present
260 * \param opcode Pointer to an enum which will be populated with the opcode of the frame
261 * \param fragmented Pointer to an int which is set to 1 if payload is fragmented and 0 if not
262 *
263 * \retval -1 on error
264 * \retval 0 on success
265 *
266 * \note Once an AST_WEBSOCKET_OPCODE_CLOSE opcode is received the socket will be closed
267 */
268AST_OPTIONAL_API(int, ast_websocket_read, (struct ast_websocket *session, char **payload, uint64_t *payload_len, enum ast_websocket_opcode *opcode, int *fragmented), { errno = ENOSYS; return -1;});
269
270/*!
271 * \brief Read a WebSocket frame containing string data.
272 *
273 * \note The caller is responsible for freeing the output "buf".
274 *
275 * \param ws pointer to the websocket
276 * \param buf string buffer to populate with data read from socket
277 * \retval -1 on error
278 * \return number of bytes read on success
279 *
280 * \note Once an AST_WEBSOCKET_OPCODE_CLOSE opcode is received the socket will be closed
281 */
283 (struct ast_websocket *ws, char **buf),
284 { errno = ENOSYS; return -1;});
285
286/*!
287 * \brief Construct and transmit a WebSocket frame
288 *
289 * \param session Pointer to the WebSocket session
290 * \param opcode WebSocket operation code to place in the frame
291 * \param payload Optional pointer to a payload to add to the frame
292 * \param payload_size Length of the payload (0 if no payload)
293 *
294 * \retval 0 if successfully written
295 * \retval -1 if error occurred
296 */
297AST_OPTIONAL_API(int, ast_websocket_write, (struct ast_websocket *session, enum ast_websocket_opcode opcode, char *payload, uint64_t payload_size), { errno = ENOSYS; return -1;});
298
299/*!
300 * \brief Construct and transmit a WebSocket frame containing string data.
301 *
302 * \param ws pointer to the websocket
303 * \param buf string data to write to socket
304 * \retval 0 if successfully written
305 * \retval -1 if error occurred
306 */
308 (struct ast_websocket *ws, const char *buf),
309 { errno = ENOSYS; return -1;});
310/*!
311 * \brief Close a WebSocket session by sending a message with the CLOSE opcode and an optional code
312 *
313 * \param session Pointer to the WebSocket session
314 * \param reason Reason code for closing the session as defined in the RFC
315 *
316 * \retval 0 if successfully written
317 * \retval -1 if error occurred
318 */
319AST_OPTIONAL_API(int, ast_websocket_close, (struct ast_websocket *session, uint16_t reason), { errno = ENOSYS; return -1;});
320
321/*!
322 * \brief Enable multi-frame reconstruction up to a certain number of bytes
323 *
324 * \param session Pointer to the WebSocket session
325 * \param bytes If a reconstructed payload exceeds the specified number of bytes the payload will be returned
326 * and upon reception of the next multi-frame a new reconstructed payload will begin.
327 */
328AST_OPTIONAL_API(void, ast_websocket_reconstruct_enable, (struct ast_websocket *session, size_t bytes), {return;});
329
330/*!
331 * \brief Disable multi-frame reconstruction
332 *
333 * \param session Pointer to the WebSocket session
334 *
335 * \note If reconstruction is disabled each message that is part of a multi-frame message will be sent up to
336 * the user when ast_websocket_read is called.
337 */
339
340/*!
341 * \brief Increase the reference count for a WebSocket session
342 *
343 * \param session Pointer to the WebSocket session
344 */
345AST_OPTIONAL_API(void, ast_websocket_ref, (struct ast_websocket *session), {return;});
346
347/*!
348 * \brief Decrease the reference count for a WebSocket session
349 *
350 * \param session Pointer to the WebSocket session
351 */
352AST_OPTIONAL_API(void, ast_websocket_unref, (struct ast_websocket *session), {return;});
353
354/*!
355 * \brief Get the file descriptor for a WebSocket session.
356 *
357 * \return file descriptor
358 *
359 * \note You must *not* directly read from or write to this file descriptor. It should only be used for polling.
360 */
361AST_OPTIONAL_API(int, ast_websocket_fd, (struct ast_websocket *session), { errno = ENOSYS; return -1;});
362
363/*!
364 * \brief Wait for the WebSocket session to be ready to be read.
365 * \since 16.8.0
366 * \since 17.2.0
367 *
368 * \param session Pointer to the WebSocket session
369 * \param timeout the number of milliseconds to wait
370 *
371 * \retval -1 if error occurred
372 * \retval 0 if the timeout expired
373 * \retval 1 if the WebSocket session is ready for reading
374 */
375AST_OPTIONAL_API(int, ast_websocket_wait_for_input, (struct ast_websocket *session, int timeout), { errno = ENOSYS; return -1; });
376
377/*!
378 * \brief Get the remote address for a WebSocket connected session.
379 *
380 * \return Remote address
381 */
383
384/*!
385 * \brief Get the local address for a WebSocket connection session.
386 *
387 * \return Local address
388 *
389 * \since 13.19.0
390 */
392
393/*!
394 * \brief Get whether the WebSocket session is using a secure transport or not.
395 *
396 * \retval 0 if unsecure
397 * \retval 1 if secure
398 */
399AST_OPTIONAL_API(int, ast_websocket_is_secure, (struct ast_websocket *session), { errno = ENOSYS; return -1;});
400
401/*!
402 * \brief Set the socket of a WebSocket session to be non-blocking.
403 *
404 * \retval 0 on success
405 * \retval -1 on failure
406 */
407AST_OPTIONAL_API(int, ast_websocket_set_nonblock, (struct ast_websocket *session), { errno = ENOSYS; return -1;});
408
409/*!
410 * \brief Get the session ID for a WebSocket session.
411 *
412 * \return session id
413 */
414AST_OPTIONAL_API(const char *, ast_websocket_session_id, (struct ast_websocket *session), { errno = ENOSYS; return NULL;});
415
416/*!
417 * \brief Result code for a websocket client.
418 */
420 WS_OK = 0,
435};
436
437/*!
438 * \brief Create, and connect, a websocket client.
439 *
440 * If the client websocket successfully connects, then the accepted protocol can be
441 * checked via a call to ast_websocket_client_accept_protocol.
442 *
443 * \note While connecting this *will* block until a response is
444 * received from the remote host.
445 * \note Expected uri form:
446 * \verbatim ws[s]://<address>[:port][/<path>] \endverbatim
447 * The address (can be a host name) and port are parsed out and used to connect
448 * to the remote server. If multiple IPs are returned during address
449 * resolution then the first one is chosen.
450 *
451 * \param uri uri to connect to
452 * \param protocols a comma separated string of supported protocols
453 * \param tls_cfg secure websocket credentials
454 * \param result result code set on client failure
455 * \return a client websocket.
456 * \retval NULL if object could not be created or connected
457 * \since 13
458 */
460 (const char *uri, const char *protocols,
461 struct ast_tls_config *tls_cfg,
462 enum ast_websocket_result *result), { return NULL;});
463
464/*!
465 * \brief Options used for a websocket client
466 */
468 /*!
469 * The URI to connect to
470 *
471 * Expected uri form:
472 * \verbatim ws[s]://<address>[:port][/<path>] \endverbatim
473 * The address (can be a host name) and port are parsed out and used to connect
474 * to the remote server. If multiple IPs are returned during address
475 * resolution then the first one is chosen.
476 */
477 const char *uri;
478 /*!
479 * A comma separated string of supported protocols
480 */
481 const char *protocols;
482 /*!
483 * Optional connection timeout
484 *
485 * How long (in milliseconds) to attempt to connect (-1 equals infinite)
486 */
488 /*!
489 * Secure websocket credentials
490 */
492 const char *username; /*!< Auth username */
493 const char *password; /*!< Auth password */
494 int suppress_connection_msgs; /*!< Suppress connection log messages */
495};
496
497/*!
498 * \brief Create, and connect, a websocket client using given options.
499 *
500 * If the client websocket successfully connects, then the accepted protocol can be
501 * checked via a call to ast_websocket_client_accept_protocol.
502 *
503 * \note While connecting this *will* block until a response is received
504 * from the remote host, or the connection timeout is reached
505 *
506 * \param options Websocket client options
507 * \param result result code set on client failure
508 *
509 * \return a client websocket.
510 * \retval NULL if object could not be created or connected
511 */
514 enum ast_websocket_result *result), { return NULL;});
515
516/*!
517 * \brief Retrieve the server accepted sub-protocol on the client.
518 *
519 * \param ws the websocket client
520 * \return the accepted client sub-protocol.
521 * \since 13
522 */
524 (struct ast_websocket *ws), { return NULL;});
525
526/*!
527 * \brief Set the timeout on a non-blocking WebSocket session.
528 *
529 * \since 11.11.0
530 * \since 12.4.0
531 *
532 * \retval 0 on success
533 * \retval -1 on failure
534 */
535AST_OPTIONAL_API(int, ast_websocket_set_timeout, (struct ast_websocket *session, int timeout), {return -1;});
536
537/*!
538 * \brief Convert a websocket result code to a string.
539 *
540 * \param result The result code to convert
541 *
542 * \return A string representation of the result code
543 */
545
546#endif
static struct ast_mansession session
static PGresult * result
Definition: cel_pgsql.c:84
static const char type[]
Definition: chan_ooh323.c:109
static struct ast_channel * callback(struct ast_channelstorage_instance *driver, ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags)
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static const char name[]
Definition: format_mp3.c:68
Support for Private Asterisk HTTP Servers.
ast_http_method
HTTP Request methods known by Asterisk.
Definition: http.h:58
struct ast_websocket_protocol * ast_websocket_sub_protocol_alloc(const char *name)
Allocate a websocket sub-protocol instance.
int ast_websocket_read_string(struct ast_websocket *ws, char **buf)
Read a WebSocket frame containing string data.
int ast_websocket_is_secure(struct ast_websocket *session)
Get whether the WebSocket session is using a secure transport or not.
void ast_websocket_reconstruct_disable(struct ast_websocket *session)
Disable multi-frame reconstruction.
int ast_websocket_remove_protocol(const char *name, ast_websocket_callback callback)
Remove a sub-protocol handler from the default /ws server.
int ast_websocket_set_timeout(struct ast_websocket *session, int timeout)
Set the timeout on a non-blocking WebSocket session.
int 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_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.
int ast_websocket_wait_for_input(struct ast_websocket *session, int timeout)
Wait for the WebSocket session to be ready to be read.
struct ast_websocket * 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_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_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_websocket_result_to_str(enum ast_websocket_result result)
Convert a websocket result code to a string.
ast_websocket_result
Result code for a websocket client.
@ WS_BAD_REQUEST
@ WS_URL_NOT_FOUND
@ WS_CLIENT_START_ERROR
@ WS_KEY_ERROR
@ WS_NOT_SUPPORTED
@ WS_ALLOCATE_ERROR
@ WS_HEADER_MISMATCH
@ WS_WRITE_ERROR
@ WS_UNAUTHORIZED
@ WS_URI_RESOLVE_ERROR
@ WS_OK
@ WS_INVALID_RESPONSE
@ WS_BAD_STATUS
@ WS_URI_PARSE_ERROR
@ WS_HEADER_MISSING
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.
struct ast_sockaddr * ast_websocket_local_address(struct ast_websocket *session)
Get the local address for a WebSocket connection session.
struct ast_websocket * 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.
void ast_websocket_ref(struct ast_websocket *session)
Increase the reference count for a WebSocket session.
const char * ast_websocket_type_to_str(enum ast_websocket_type type)
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
int ast_websocket_add_protocol2(struct ast_websocket_protocol *protocol)
Add a sub-protocol handler to the default /ws server.
void ast_websocket_unref(struct ast_websocket *session)
Decrease the reference count for a WebSocket session.
void ast_websocket_reconstruct_enable(struct ast_websocket *session, size_t bytes)
Enable multi-frame reconstruction up to a certain number of bytes.
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_server_add_protocol2(struct ast_websocket_server *server, struct ast_websocket_protocol *protocol)
Add a sub-protocol handler to the given server.
const char * ast_websocket_client_accept_protocol(struct ast_websocket *ws)
Retrieve the server accepted sub-protocol on the client.
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.
ast_websocket_type
WebSocket connection/configuration types.
@ AST_WS_TYPE_ANY
@ AST_WS_TYPE_CLIENT
@ AST_WS_TYPE_INBOUND
@ AST_WS_TYPE_CLIENT_PER_CALL_CONFIG
@ AST_WS_TYPE_SERVER
@ AST_WS_TYPE_CLIENT_PERSISTENT
@ AST_WS_TYPE_CLIENT_PER_CALL
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.
struct ast_websocket_server * ast_websocket_server_create(void)
Creates a ast_websocket_server.
int 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_websocket_add_protocol(const char *name, ast_websocket_callback callback)
Add a sub-protocol handler to the default /ws server.
int errno
Optional API function macros.
#define AST_OPTIONAL_API(result, name, proto, stub)
Declare an optional API function.
Definition: optional_api.h:230
const char * method
Definition: res_pjsip.c:1279
#define NULL
Definition: resample.c:96
Definition of a URI handler.
Definition: http.h:102
Socket address structure.
Definition: netsock2.h:97
describes a server instance
Definition: tcptls.h:151
Structure for variables, used for configurations and for channel variables.
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.
Structure definition for session.
static struct test_options options