summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/app_playback.c4
-rw-r--r--funcs/func_periodic_hook.c10
-rw-r--r--include/asterisk/event.h2
-rw-r--r--include/asterisk/http_websocket.h86
-rw-r--r--include/asterisk/rtp_engine.h2
-rw-r--r--include/asterisk/sem.h4
-rw-r--r--include/asterisk/stasis.h34
-rw-r--r--include/asterisk/stasis_test.h3
-rw-r--r--main/file.c4
-rw-r--r--main/logger.c26
-rw-r--r--main/sdp_srtp.c5
-rw-r--r--res/res_http_websocket.c109
-rw-r--r--res/res_resolver_unbound.c1
-rw-r--r--res/res_stasis_test.c3
-rw-r--r--tests/test_ari.c3
-rw-r--r--tests/test_endpoints.c3
-rw-r--r--tests/test_json.c3
-rw-r--r--tests/test_message.c9
-rw-r--r--tests/test_optional_api.c3
-rw-r--r--tests/test_res_stasis.c3
-rw-r--r--tests/test_stasis.c3
-rw-r--r--tests/test_stasis_channels.c3
-rw-r--r--tests/test_stasis_endpoints.c3
-rw-r--r--utils/extconf.c2
24 files changed, 227 insertions, 101 deletions
diff --git a/apps/app_playback.c b/apps/app_playback.c
index feb7b633d..2875ec2b4 100644
--- a/apps/app_playback.c
+++ b/apps/app_playback.c
@@ -490,7 +490,9 @@ static int playback_exec(struct ast_channel *chan, const char *data)
ast_stopstream(chan);
}
if (res) {
- ast_log(LOG_WARNING, "Playback failed on %s for %s\n", ast_channel_name(chan), (char *)data);
+ if (!ast_check_hangup(chan)) {
+ ast_log(LOG_WARNING, "Playback failed on %s for %s\n", ast_channel_name(chan), (char *)data);
+ }
res = 0;
mres = 1;
}
diff --git a/funcs/func_periodic_hook.c b/funcs/func_periodic_hook.c
index 6ddab5600..bb0ee0db7 100644
--- a/funcs/func_periodic_hook.c
+++ b/funcs/func_periodic_hook.c
@@ -446,13 +446,9 @@ static struct ast_custom_function hook_function = {
.write = hook_write,
};
-static struct ast_context *func_periodic_hook_context;
-
static int unload_module(void)
{
- if (func_periodic_hook_context) {
- ast_context_destroy(func_periodic_hook_context, AST_MODULE);
- }
+ ast_context_destroy(NULL, AST_MODULE);
return ast_custom_function_unregister(&hook_function);
}
@@ -461,9 +457,7 @@ static int load_module(void)
{
int res;
- func_periodic_hook_context = ast_context_find_or_create(NULL, NULL,
- context_name, AST_MODULE);
- if (!func_periodic_hook_context) {
+ if (!ast_context_find_or_create(NULL, NULL, context_name, AST_MODULE)) {
ast_log(LOG_ERROR, "Failed to create %s dialplan context.\n", context_name);
return AST_MODULE_LOAD_DECLINE;
}
diff --git a/include/asterisk/event.h b/include/asterisk/event.h
index 7eea0581d..dbc080da8 100644
--- a/include/asterisk/event.h
+++ b/include/asterisk/event.h
@@ -35,7 +35,7 @@
* modules in Asterisk.
* - CEL uses the \ref ast_event representation to pass information to registered
* backends.
- * - The \file res_corosync module publishes \ref ast_event representations of
+ * - The \file res_corosync.c module publishes \ref ast_event representations of
* information to other Asterisk instances in a cluster.
* - Security event represent their event types and data using this system.
* - Theoretically, any \ref stasis message can use this system to pass
diff --git a/include/asterisk/http_websocket.h b/include/asterisk/http_websocket.h
index 3e07e608b..5adc08925 100644
--- a/include/asterisk/http_websocket.h
+++ b/include/asterisk/http_websocket.h
@@ -68,6 +68,24 @@ struct ast_websocket_server;
struct ast_websocket;
/*!
+ * \brief 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 \ref ast_websocket_protocol can use this to deny a request, or to
+ * set up application specific data before invocation of \ref ast_websocket_callback.
+ *
+ * \param ser The TCP/TLS session
+ * \param parameters Parameters extracted from the request URI
+ * \param headers Headers included in the request
+ *
+ * \retval 0 The session should be accepted
+ * \retval -1 The session should be rejected. Note that the caller must send an error
+ * response using \ref ast_http_error.
+ * \since 13.5.0
+ */
+typedef int (*ast_websocket_pre_callback)(struct ast_tcptls_session_instance *ser, struct ast_variable *parameters, struct ast_variable *headers);
+
+/*!
* \brief Callback for when a new connection for a sub-protocol is established
*
* \param session A WebSocket session structure
@@ -81,6 +99,32 @@ struct ast_websocket;
typedef void (*ast_websocket_callback)(struct ast_websocket *session, struct ast_variable *parameters, struct ast_variable *headers);
/*!
+ * \brief A websocket protocol implementation
+ *
+ * Users of the Websocket API can register themselves as a websocket
+ * protocol. See \ref ast_websocket_add_protocol2 and \ref ast_websocket_server_add_protocol2.
+ * Simpler implementations may use only \ref ast_websocket_add_protocol and
+ * \ref ast_websocket_server_add_protocol.
+ *
+ * \since 13.5.0
+ */
+struct ast_websocket_protocol {
+ /*! \brief Name of the protocol */
+ char *name;
+/*!
+ * \brief Protocol version. This prevents dynamically loadable modules from registering
+ * if this struct is changed.
+ */
+#define AST_WEBSOCKET_PROTOCOL_VERSION 1
+ /*! \brief Protocol version. Should be set to /ref AST_WEBSOCKET_PROTOCOL_VERSION */
+ unsigned int version;
+ /*! \brief Callback called when a new session is attempted. Optional. */
+ ast_websocket_pre_callback session_attempted;
+ /* \brief Callback called when a new session is established. Mandatory. */
+ ast_websocket_callback session_established;
+};
+
+/*!
* \brief Creates a \ref websocket_server
*
* \retval New \ref websocket_server instance
@@ -98,6 +142,15 @@ AST_OPTIONAL_API(struct ast_websocket_server *, ast_websocket_server_create, (vo
AST_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; });
/*!
+ * \brief Allocate a websocket sub-protocol instance
+ *
+ * \retval An instance of \ref ast_websocket_protocol on success
+ * \retval NULL on error
+ * \since 13.5.0
+ */
+AST_OPTIONAL_API(struct ast_websocket_protocol *, ast_websocket_sub_protocol_alloc, (const char *name), {return NULL;});
+
+/*!
* \brief Add a sub-protocol handler to the default /ws server
*
* \param name Name of the sub-protocol to register
@@ -109,10 +162,25 @@ AST_OPTIONAL_API(int, ast_websocket_uri_cb, (struct ast_tcptls_session_instance
AST_OPTIONAL_API(int, ast_websocket_add_protocol, (const char *name, ast_websocket_callback callback), {return -1;});
/*!
+ * \brief Add a sub-protocol handler to the default /ws server
+ *
+ * \param protocol The 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 \ref protocol
+ * on success.
+ *
+ * \retval 0 success
+ * \retval -1 if sub-protocol handler could not be registered
+ * \since 13.5.0
+ */
+AST_OPTIONAL_API(int, ast_websocket_add_protocol2, (struct ast_websocket_protocol *protocol), {return -1;});
+
+/*!
* \brief Remove a sub-protocol handler from the default /ws server.
*
* \param name Name of the sub-protocol to unregister
- * \param callback Callback that was previously registered with the sub-protocol
+ * \param callback Session Established callback that was previously registered with the sub-protocol
*
* \retval 0 success
* \retval -1 if sub-protocol was not found or if callback did not match
@@ -132,6 +200,22 @@ AST_OPTIONAL_API(int, ast_websocket_remove_protocol, (const char *name, ast_webs
AST_OPTIONAL_API(int, ast_websocket_server_add_protocol, (struct ast_websocket_server *server, const char *name, ast_websocket_callback callback), {return -1;});
/*!
+ * \brief Add a sub-protocol handler to the given server.
+ *
+ * \param server The server to add the sub-protocol to.
+ * \param protocol The 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 \ref protocol
+ * on success.
+ *
+ * \retval 0 success
+ * \retval -1 if sub-protocol handler could not be registered
+ * \since 13.5.0
+ */
+AST_OPTIONAL_API(int, ast_websocket_server_add_protocol2, (struct ast_websocket_server *server, struct ast_websocket_protocol *protocol), {return -1;});
+
+/*!
* \brief Remove a sub-protocol handler from the given server.
*
* \param name Name of the sub-protocol to unregister
diff --git a/include/asterisk/rtp_engine.h b/include/asterisk/rtp_engine.h
index a94cb4213..c7f6511f9 100644
--- a/include/asterisk/rtp_engine.h
+++ b/include/asterisk/rtp_engine.h
@@ -2316,7 +2316,7 @@ struct stasis_message_type *ast_rtp_rtcp_received_type(void);
*/
struct stasis_topic *ast_rtp_topic(void);
-/* }@ */
+/* @} */
#if defined(__cplusplus) || defined(c_plusplus)
}
diff --git a/include/asterisk/sem.h b/include/asterisk/sem.h
index 6d655d63e..fcab82a5e 100644
--- a/include/asterisk/sem.h
+++ b/include/asterisk/sem.h
@@ -20,7 +20,9 @@
#define ASTERISK_SEMAPHORE_H
/*!
- * \file Asterisk semaphore API
+ * \file
+ *
+ * \brief Asterisk semaphore API
*
* This API is a thin wrapper around the POSIX semaphore API (when available),
* so see the POSIX documentation for further details.
diff --git a/include/asterisk/stasis.h b/include/asterisk/stasis.h
index 0b1b1e83f..aa681e13e 100644
--- a/include/asterisk/stasis.h
+++ b/include/asterisk/stasis.h
@@ -173,8 +173,6 @@
#include "asterisk/utils.h"
#include "asterisk/event.h"
-/*! @{ */
-
/*!
* \brief Metadata about a \ref stasis_message.
* \since 12
@@ -451,10 +449,6 @@ struct ast_manager_event_blob *stasis_message_to_ami(
struct ast_event *stasis_message_to_event(
struct stasis_message *message);
-/*! @} */
-
-/*! @{ */
-
/*!
* \brief A topic to which messages may be posted, and subscribers, well, subscribe
* \since 12
@@ -508,10 +502,6 @@ void stasis_publish(struct stasis_topic *topic, struct stasis_message *message);
*/
void stasis_publish_sync(struct stasis_subscription *sub, struct stasis_message *message);
-/*! @} */
-
-/*! @{ */
-
/*!
* \brief Callback function type for Stasis subscriptions.
* \param data Data field provided with subscription.
@@ -699,8 +689,6 @@ struct stasis_message_type *stasis_subscription_change_type(void);
/*! @} */
-/*! @{ */
-
/*!
* \brief Pool for topic aggregation
*/
@@ -723,8 +711,6 @@ struct stasis_topic_pool *stasis_topic_pool_create(struct stasis_topic *pooled_t
*/
struct stasis_topic *stasis_topic_pool_get_topic(struct stasis_topic_pool *pool, const char *topic_name);
-/*! @} */
-
/*! \addtogroup StasisTopicsAndMessages
* @{
*/
@@ -757,8 +743,6 @@ struct stasis_message_type *stasis_cache_clear_type(void);
/*! @} */
-/*! @{ */
-
/*!
* \brief A message cache, for use with \ref stasis_caching_topic.
* \since 12
@@ -1090,6 +1074,10 @@ struct ao2_container *stasis_cache_dump_by_eid(struct stasis_cache *cache, struc
*/
struct ao2_container *stasis_cache_dump_all(struct stasis_cache *cache, struct stasis_message_type *type);
+/*! \addtogroup StasisTopicsAndMessages
+ * @{
+ */
+
/*!
* \brief Object type code for multi user object snapshots
*/
@@ -1163,8 +1151,6 @@ void ast_multi_object_blob_single_channel_publish(struct ast_channel *chan, stru
/*! @} */
-/*! @{ */
-
/*!
* \internal
* \brief Log a message about invalid attempt to access a type.
@@ -1267,10 +1253,6 @@ void stasis_log_bad_type_access(const char *name);
_priv_ ## name = NULL; \
})
-/*! @} */
-
-/*! @{ */
-
/*!
* \brief Initialize the Stasis subsystem.
* \return 0 on success.
@@ -1279,10 +1261,6 @@ void stasis_log_bad_type_access(const char *name);
*/
int stasis_init(void);
-/*! @} */
-
-/*! @{ */
-
/*!
* \internal
* \brief called by stasis_init() for cache initialization.
@@ -1301,12 +1279,10 @@ int stasis_cache_init(void);
*/
int stasis_config_init(void);
-/*! @} */
-
/*!
* \defgroup StasisTopicsAndMessages Stasis topics, and their messages.
*
- * This group contains the topics, messages and corresponding message types
+ * \brief This group contains the topics, messages and corresponding message types
* found within Asterisk.
*/
diff --git a/include/asterisk/stasis_test.h b/include/asterisk/stasis_test.h
index ad4020a08..d9df1c97f 100644
--- a/include/asterisk/stasis_test.h
+++ b/include/asterisk/stasis_test.h
@@ -20,7 +20,8 @@
#define _ASTERISK_STASIS_TEST_H
/*!
- * \file \brief Test infrastructure for dealing with Stasis.
+ * \file
+ * \brief Test infrastructure for dealing with Stasis.
*
* \author David M. Lee, II <dlee@digium.com>
*
diff --git a/main/file.c b/main/file.c
index acd2cc6bc..bfad6e025 100644
--- a/main/file.c
+++ b/main/file.c
@@ -897,7 +897,7 @@ static enum fsread_res ast_readaudio_callback(struct ast_filestream *s)
if (!fr /* stream complete */ || ast_write(s->owner, fr) /* error writing */) {
if (fr) {
- ast_log(LOG_WARNING, "Failed to write frame\n");
+ ast_debug(2, "Failed to write frame\n");
ast_frfree(fr);
}
goto return_failure;
@@ -954,7 +954,7 @@ static enum fsread_res ast_readvideo_callback(struct ast_filestream *s)
if (!fr /* stream complete */ || ast_write(s->owner, fr) /* error writing */) {
if (fr) {
- ast_log(LOG_WARNING, "Failed to write frame\n");
+ ast_debug(2, "Failed to write frame\n");
ast_frfree(fr);
}
ast_channel_vstreamid_set(s->owner, -1);
diff --git a/main/logger.c b/main/logger.c
index 41f26e823..bdcd6c4f5 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -375,16 +375,25 @@ static int init_logger_chain(int locked, const char *altconf)
const char *s;
struct ast_flags config_flags = { 0 };
- display_callids = 1;
-
if (!(cfg = ast_config_load2(S_OR(altconf, "logger.conf"), "logger", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
cfg = NULL;
}
- /* delete our list of log channels */
if (!locked) {
AST_RWLIST_WRLOCK(&logchannels);
}
+
+ /* Set defaults */
+ hostname[0] = '\0';
+ display_callids = 1;
+ memset(&logfiles, 0, sizeof(logfiles));
+ logfiles.queue_log = 1;
+ ast_copy_string(dateformat, "%b %e %T", sizeof(dateformat));
+ ast_copy_string(queue_log_name, QUEUELOG, sizeof(queue_log_name));
+ exec_after_rotate[0] = '\0';
+ rotatestrategy = SEQUENTIAL;
+
+ /* delete our list of log channels */
while ((chan = AST_RWLIST_REMOVE_HEAD(&logchannels, list))) {
ast_free(chan);
}
@@ -424,17 +433,14 @@ static int init_logger_chain(int locked, const char *altconf)
ast_copy_string(hostname, "unknown", sizeof(hostname));
fprintf(stderr, "What box has no hostname???\n");
}
- } else
- hostname[0] = '\0';
- } else
- hostname[0] = '\0';
+ }
+ }
if ((s = ast_variable_retrieve(cfg, "general", "display_callids"))) {
display_callids = ast_true(s);
}
- if ((s = ast_variable_retrieve(cfg, "general", "dateformat")))
+ if ((s = ast_variable_retrieve(cfg, "general", "dateformat"))) {
ast_copy_string(dateformat, s, sizeof(dateformat));
- else
- ast_copy_string(dateformat, "%b %e %T", sizeof(dateformat));
+ }
if ((s = ast_variable_retrieve(cfg, "general", "queue_log"))) {
logfiles.queue_log = ast_true(s);
}
diff --git a/main/sdp_srtp.c b/main/sdp_srtp.c
index 8c86f1407..e576258c3 100644
--- a/main/sdp_srtp.c
+++ b/main/sdp_srtp.c
@@ -16,7 +16,7 @@
* at the top of the source tree.
*/
-/*! \file ast_sdp_crypto.c
+/*! \file
*
* \brief SRTP and SDP Security descriptions
*
@@ -238,7 +238,8 @@ int ast_sdp_crypto_process(struct ast_rtp_instance *rtp, struct ast_sdp_srtp *sr
return -1;
}
- if (sscanf(tag, "%30d", &crypto->tag) != 1 || crypto->tag <= 0 || crypto->tag > 9) {
+ /* RFC4568 9.1 - tag is 1-9 digits, greater than zero */
+ if (sscanf(tag, "%30d", &crypto->tag) != 1 || crypto->tag <= 0 || crypto->tag > 999999999) {
ast_log(LOG_WARNING, "Unacceptable a=crypto tag: %s\n", tag);
return -1;
}
diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c
index 046c76e81..40aedff72 100644
--- a/res/res_http_websocket.c
+++ b/res/res_http_websocket.c
@@ -88,16 +88,10 @@ struct ast_websocket {
struct websocket_client *client; /*!< Client object when connected as a client websocket */
};
-/*! \brief Structure definition for protocols */
-struct websocket_protocol {
- char *name; /*!< Name of the protocol */
- ast_websocket_callback callback; /*!< Callback called when a new session is established */
-};
-
/*! \brief Hashing function for protocols */
static int protocol_hash_fn(const void *obj, const int flags)
{
- const struct websocket_protocol *protocol = obj;
+ const struct ast_websocket_protocol *protocol = obj;
const char *name = obj;
return ast_str_case_hash(flags & OBJ_KEY ? name : protocol->name);
@@ -106,7 +100,7 @@ static int protocol_hash_fn(const void *obj, const int flags)
/*! \brief Comparison function for protocols */
static int protocol_cmp_fn(void *obj, void *arg, int flags)
{
- const struct websocket_protocol *protocol1 = obj, *protocol2 = arg;
+ const struct ast_websocket_protocol *protocol1 = obj, *protocol2 = arg;
const char *protocol = arg;
return !strcasecmp(protocol1->name, flags & OBJ_KEY ? protocol : protocol2->name) ? CMP_MATCH | CMP_STOP : 0;
@@ -115,7 +109,7 @@ static int protocol_cmp_fn(void *obj, void *arg, int flags)
/*! \brief Destructor function for protocols */
static void protocol_destroy_fn(void *obj)
{
- struct websocket_protocol *protocol = obj;
+ struct ast_websocket_protocol *protocol = obj;
ast_free(protocol->name);
}
@@ -182,54 +176,91 @@ static void session_destroy_fn(void *obj)
ast_free(session->payload);
}
+struct ast_websocket_protocol *AST_OPTIONAL_API_NAME(ast_websocket_sub_protocol_alloc)(const char *name)
+{
+ struct ast_websocket_protocol *protocol;
+
+ protocol = ao2_alloc(sizeof(*protocol), protocol_destroy_fn);
+ if (!protocol) {
+ return NULL;
+ }
+
+ protocol->name = ast_strdup(name);
+ if (!protocol->name) {
+ ao2_ref(protocol, -1);
+ return NULL;
+ }
+ protocol->version = AST_WEBSOCKET_PROTOCOL_VERSION;
+
+ return protocol;
+}
+
int AST_OPTIONAL_API_NAME(ast_websocket_server_add_protocol)(struct ast_websocket_server *server, const char *name, ast_websocket_callback callback)
{
- struct websocket_protocol *protocol;
+ struct ast_websocket_protocol *protocol;
if (!server->protocols) {
return -1;
}
- ao2_lock(server->protocols);
+ protocol = ast_websocket_sub_protocol_alloc(name);
+ if (!protocol) {
+ ao2_unlock(server->protocols);
+ return -1;
+ }
+ protocol->session_established = callback;
- /* Ensure a second protocol handler is not registered for the same protocol */
- if ((protocol = ao2_find(server->protocols, name, OBJ_KEY | OBJ_NOLOCK))) {
+ if (ast_websocket_server_add_protocol2(server, protocol)) {
ao2_ref(protocol, -1);
- ao2_unlock(server->protocols);
return -1;
}
- if (!(protocol = ao2_alloc(sizeof(*protocol), protocol_destroy_fn))) {
- ao2_unlock(server->protocols);
+ return 0;
+}
+
+int AST_OPTIONAL_API_NAME(ast_websocket_server_add_protocol2)(struct ast_websocket_server *server, struct ast_websocket_protocol *protocol)
+{
+ struct ast_websocket_protocol *existing;
+
+ if (!server->protocols) {
return -1;
}
- if (!(protocol->name = ast_strdup(name))) {
- ao2_ref(protocol, -1);
- ao2_unlock(server->protocols);
+ if (protocol->version != AST_WEBSOCKET_PROTOCOL_VERSION) {
+ ast_log(LOG_WARNING, "WebSocket could not register sub-protocol '%s': "
+ "expected version '%u', got version '%u'\n",
+ protocol->name, AST_WEBSOCKET_PROTOCOL_VERSION, protocol->version);
return -1;
}
- protocol->callback = callback;
+ ao2_lock(server->protocols);
+
+ /* Ensure a second protocol handler is not registered for the same protocol */
+ existing = ao2_find(server->protocols, protocol->name, OBJ_KEY | OBJ_NOLOCK);
+ if (existing) {
+ ao2_ref(existing, -1);
+ ao2_unlock(server->protocols);
+ return -1;
+ }
ao2_link_flags(server->protocols, protocol, OBJ_NOLOCK);
ao2_unlock(server->protocols);
- ao2_ref(protocol, -1);
- ast_verb(2, "WebSocket registered sub-protocol '%s'\n", name);
+ ast_verb(2, "WebSocket registered sub-protocol '%s'\n", protocol->name);
+ ao2_ref(protocol, -1);
return 0;
}
int AST_OPTIONAL_API_NAME(ast_websocket_server_remove_protocol)(struct ast_websocket_server *server, const char *name, ast_websocket_callback callback)
{
- struct websocket_protocol *protocol;
+ struct ast_websocket_protocol *protocol;
if (!(protocol = ao2_find(server->protocols, name, OBJ_KEY))) {
return -1;
}
- if (protocol->callback != callback) {
+ if (protocol->session_established != callback) {
ao2_ref(protocol, -1);
return -1;
}
@@ -600,7 +631,7 @@ int AST_OPTIONAL_API_NAME(ast_websocket_read)(struct ast_websocket *session, cha
/*!
* \brief If the server has exactly one configured protocol, return it.
*/
-static struct websocket_protocol *one_protocol(
+static struct ast_websocket_protocol *one_protocol(
struct ast_websocket_server *server)
{
SCOPED_AO2LOCK(lock, server->protocols);
@@ -643,7 +674,7 @@ int AST_OPTIONAL_API_NAME(ast_websocket_uri_cb)(struct ast_tcptls_session_instan
struct ast_variable *v;
char *upgrade = NULL, *key = NULL, *key1 = NULL, *key2 = NULL, *protos = NULL, *requested_protocols = NULL, *protocol = NULL;
int version = 0, flags = 1;
- struct websocket_protocol *protocol_handler = NULL;
+ struct ast_websocket_protocol *protocol_handler = NULL;
struct ast_websocket *session;
struct ast_websocket_server *server;
@@ -742,6 +773,14 @@ int AST_OPTIONAL_API_NAME(ast_websocket_uri_cb)(struct ast_tcptls_session_instan
}
session->timeout = AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT;
+ if (protocol_handler->session_attempted
+ && protocol_handler->session_attempted(ser, get_vars, headers)) {
+ ast_debug(3, "WebSocket connection from '%s' rejected by protocol handler '%s'\n",
+ ast_sockaddr_stringify(&ser->remote_address), protocol_handler->name);
+ ao2_ref(protocol_handler, -1);
+ return 0;
+ }
+
fprintf(ser->f, "HTTP/1.1 101 Switching Protocols\r\n"
"Upgrade: %s\r\n"
"Connection: Upgrade\r\n"
@@ -797,7 +836,7 @@ int AST_OPTIONAL_API_NAME(ast_websocket_uri_cb)(struct ast_tcptls_session_instan
/* Give up ownership of the socket and pass it to the protocol handler */
ast_tcptls_stream_set_exclusive_input(ser->stream_cookie, 0);
- protocol_handler->callback(session, get_vars, headers);
+ protocol_handler->session_established(session, get_vars, headers);
ao2_ref(protocol_handler, -1);
/*
@@ -881,6 +920,22 @@ int AST_OPTIONAL_API_NAME(ast_websocket_add_protocol)(const char *name, ast_webs
return res;
}
+int AST_OPTIONAL_API_NAME(ast_websocket_add_protocol2)(struct ast_websocket_protocol *protocol)
+{
+ struct ast_websocket_server *ws_server = websocketuri.data;
+
+ if (!ws_server) {
+ return -1;
+ }
+
+ if (ast_websocket_server_add_protocol2(ws_server, protocol)) {
+ return -1;
+ }
+
+ ast_module_ref(ast_module_info->self);
+ return 0;
+}
+
static int websocket_remove_protocol_internal(const char *name, ast_websocket_callback callback)
{
struct ast_websocket_server *ws_server = websocketuri.data;
diff --git a/res/res_resolver_unbound.c b/res/res_resolver_unbound.c
index 436a8ee35..a4e86a682 100644
--- a/res/res_resolver_unbound.c
+++ b/res/res_resolver_unbound.c
@@ -25,6 +25,7 @@
ASTERISK_REGISTER_FILE()
+#include <signal.h>
#include <unbound.h>
#include <arpa/nameser.h>
diff --git a/res/res_stasis_test.c b/res/res_stasis_test.c
index 9164293f5..efdbc4b52 100644
--- a/res/res_stasis_test.c
+++ b/res/res_stasis_test.c
@@ -17,7 +17,8 @@
*/
/*!
- * \file \brief Test infrastructure for dealing with Stasis.
+ * \file
+ * \brief Test infrastructure for dealing with Stasis.
*
* \author David M. Lee, II <dlee@digium.com>
*/
diff --git a/tests/test_ari.c b/tests/test_ari.c
index 55f44321a..efec810e1 100644
--- a/tests/test_ari.c
+++ b/tests/test_ari.c
@@ -17,7 +17,8 @@
*/
/*!
- * \file \brief Test ARI API.
+ * \file
+ * \brief Test ARI API.
* \author\verbatim David M. Lee, II <dlee@digium.com> \endverbatim
*
* \ingroup tests
diff --git a/tests/test_endpoints.c b/tests/test_endpoints.c
index d90cd3a05..d1239037b 100644
--- a/tests/test_endpoints.c
+++ b/tests/test_endpoints.c
@@ -17,7 +17,8 @@
*/
/*!
- * \file \brief Test endpoints.
+ * \file
+ * \brief Test endpoints.
*
* \author\verbatim David M. Lee, II <dlee@digium.com> \endverbatim
*
diff --git a/tests/test_json.c b/tests/test_json.c
index 7080face2..915578128 100644
--- a/tests/test_json.c
+++ b/tests/test_json.c
@@ -17,7 +17,8 @@
*/
/*!
- * \file \brief Test JSON API.
+ * \file
+ * \brief Test JSON API.
*
* While some of these tests are actually testing our JSON library wrapper, the bulk of
* them are exploratory tests to determine what the behavior of the underlying JSON
diff --git a/tests/test_message.c b/tests/test_message.c
index 26cd90a4d..2c9334ad9 100644
--- a/tests/test_message.c
+++ b/tests/test_message.c
@@ -51,8 +51,6 @@ ASTERISK_REGISTER_FILE()
/*! \brief The number of user events we should get in a dialplan test */
#define DEFAULT_EXPECTED_EVENTS 4
-static struct ast_context *test_message_context;
-
/*! \brief The current number of received user events */
static int received_user_events;
@@ -822,9 +820,7 @@ static int unload_module(void)
AST_TEST_UNREGISTER(test_message_has_destination_handler);
AST_TEST_UNREGISTER(test_message_msg_send);
- if (test_message_context) {
- ast_context_destroy(test_message_context, AST_MODULE);
- }
+ ast_context_destroy(NULL, AST_MODULE);
ast_manager_unregister_hook(&user_event_hook);
@@ -835,8 +831,7 @@ static int create_test_dialplan(void)
{
int res = 0;
- test_message_context = ast_context_find_or_create(NULL, NULL, TEST_CONTEXT, AST_MODULE);
- if (!test_message_context) {
+ if (!ast_context_find_or_create(NULL, NULL, TEST_CONTEXT, AST_MODULE)) {
return -1;
}
diff --git a/tests/test_optional_api.c b/tests/test_optional_api.c
index a89b46159..f7809d32b 100644
--- a/tests/test_optional_api.c
+++ b/tests/test_optional_api.c
@@ -17,7 +17,8 @@
*/
/*!
- * \file \brief Test optional API.
+ * \file
+ * \brief Test optional API.
*
* This tests exercise the underlying implementation functions. Acutal usage
* won't look anything like this; it would use the wrapper macros.
diff --git a/tests/test_res_stasis.c b/tests/test_res_stasis.c
index 7edc985e8..4e28d44c6 100644
--- a/tests/test_res_stasis.c
+++ b/tests/test_res_stasis.c
@@ -17,7 +17,8 @@
*/
/*!
- * \file \brief Test Stasis Application API.
+ * \file
+ * \brief Test Stasis Application API.
* \author\verbatim David M. Lee, II <dlee@digium.com> \endverbatim
*
* \ingroup tests
diff --git a/tests/test_stasis.c b/tests/test_stasis.c
index 7061b97b6..b5755c843 100644
--- a/tests/test_stasis.c
+++ b/tests/test_stasis.c
@@ -17,7 +17,8 @@
*/
/*!
- * \file \brief Test Stasis message bus.
+ * \file
+ * \brief Test Stasis message bus.
*
* \author\verbatim David M. Lee, II <dlee@digium.com> \endverbatim
*
diff --git a/tests/test_stasis_channels.c b/tests/test_stasis_channels.c
index f9bbb9621..fe320f29b 100644
--- a/tests/test_stasis_channels.c
+++ b/tests/test_stasis_channels.c
@@ -17,7 +17,8 @@
*/
/*!
- * \file \brief Test Stasis Channel messages and objects
+ * \file
+ * \brief Test Stasis Channel messages and objects
*
* \author\verbatim Matt Jordan <mjordan@digium.com> \endverbatim
*
diff --git a/tests/test_stasis_endpoints.c b/tests/test_stasis_endpoints.c
index 8e3907ffe..848d86b1c 100644
--- a/tests/test_stasis_endpoints.c
+++ b/tests/test_stasis_endpoints.c
@@ -17,7 +17,8 @@
*/
/*!
- * \file \brief Test endpoints.
+ * \file
+ * \brief Test endpoints.
*
* \author\verbatim David M. Lee, II <dlee@digium.com> \endverbatim
*
diff --git a/utils/extconf.c b/utils/extconf.c
index baca11bf5..4eaea3c2d 100644
--- a/utils/extconf.c
+++ b/utils/extconf.c
@@ -18,7 +18,7 @@
/*!
- * \file extconf
+ * \file
* A condensation of the pbx_config stuff, to read into exensions.conf, and provide an interface to the data there,
* for operations outside of asterisk. A huge, awful hack.
*