[asterisk-commits] file: branch 11 r373914 - in /branches/11: channels/ include/asterisk/ res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Sep 27 12:05:30 CDT 2012
Author: file
Date: Thu Sep 27 12:05:26 2012
New Revision: 373914
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=373914
Log:
Make res_http_websocket an optional dependency on supported platforms for chan_sip.
(closes issue ASTERISK-20439)
Reported by: sruffell
Patches:
0001-chan_sip-websocket-support-is-an-optional-API.patch uploaded by sruffell (license 5417)
Modified:
branches/11/channels/chan_sip.c
branches/11/include/asterisk/http_websocket.h
branches/11/res/res_http_websocket.c
Modified: branches/11/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/channels/chan_sip.c?view=diff&rev=373914&r1=373913&r2=373914
==============================================================================
--- branches/11/channels/chan_sip.c (original)
+++ branches/11/channels/chan_sip.c Thu Sep 27 12:05:26 2012
@@ -163,6 +163,7 @@
/*** MODULEINFO
<use type="module">res_crypto</use>
+ <use type="module">res_http_websocket</use>
<depend>chan_local</depend>
<support_level>core</support_level>
***/
@@ -33510,5 +33511,5 @@
.unload = unload_module,
.reload = reload,
.load_pri = AST_MODPRI_CHANNEL_DRIVER,
- .nonoptreq = "res_crypto,chan_local",
+ .nonoptreq = "res_crypto,chan_local,res_http_websocket",
);
Modified: branches/11/include/asterisk/http_websocket.h
URL: http://svnview.digium.com/svn/asterisk/branches/11/include/asterisk/http_websocket.h?view=diff&rev=373914&r1=373913&r2=373914
==============================================================================
--- branches/11/include/asterisk/http_websocket.h (original)
+++ branches/11/include/asterisk/http_websocket.h Thu Sep 27 12:05:26 2012
@@ -19,7 +19,7 @@
#ifndef _ASTERISK_HTTP_WEBSOCKET_H
#define _ASTERISK_HTTP_WEBSOCKET_H
-#include "asterisk/module.h"
+#include "asterisk/optional_api.h"
/*!
* \file http_websocket.h
@@ -66,7 +66,7 @@
* \retval 0 success
* \retval -1 if sub-protocol handler could not be registered
*/
-int ast_websocket_add_protocol(const char *name, ast_websocket_callback callback);
+AST_OPTIONAL_API(int, ast_websocket_add_protocol, (const char *name, ast_websocket_callback callback), {return -1;});
/*!
* \brief Remove a sub-protocol handler from the server
@@ -77,7 +77,7 @@
* \retval 0 success
* \retval -1 if sub-protocol was not found or if callback did not match
*/
-int ast_websocket_remove_protocol(const char *name, ast_websocket_callback callback);
+AST_OPTIONAL_API(int, ast_websocket_remove_protocol, (const char *name, ast_websocket_callback callback), {return -1;});
/*!
* \brief Read a WebSocket frame and handle it
@@ -93,7 +93,7 @@
*
* \note Once an AST_WEBSOCKET_OPCODE_CLOSE opcode is received the socket will be closed
*/
-int ast_websocket_read(struct ast_websocket *session, char **payload, uint64_t *payload_len, enum ast_websocket_opcode *opcode, int *fragmented);
+AST_OPTIONAL_API(int, ast_websocket_read, (struct ast_websocket *session, char **payload, uint64_t *payload_len, enum ast_websocket_opcode *opcode, int *fragmented), {return -1;});
/*!
* \brief Construct and transmit a WebSocket frame
@@ -106,7 +106,7 @@
* \retval 0 if successfully written
* \retval -1 if error occurred
*/
-int ast_websocket_write(struct ast_websocket *session, enum ast_websocket_opcode opcode, char *payload, uint64_t actual_length);
+AST_OPTIONAL_API(int, ast_websocket_write, (struct ast_websocket *session, enum ast_websocket_opcode opcode, char *payload, uint64_t actual_length), {return -1;});
/*!
* \brief Close a WebSocket session by sending a message with the CLOSE opcode and an optional code
@@ -117,7 +117,7 @@
* \retval 0 if successfully written
* \retval -1 if error occurred
*/
-int ast_websocket_close(struct ast_websocket *session, uint16_t reason);
+AST_OPTIONAL_API(int, ast_websocket_close, (struct ast_websocket *session, uint16_t reason), {return -1;});
/*!
* \brief Enable multi-frame reconstruction up to a certain number of bytes
@@ -126,7 +126,7 @@
* \param bytes If a reconstructed payload exceeds the specified number of bytes the payload will be returned
* and upon reception of the next multi-frame a new reconstructed payload will begin.
*/
-void ast_websocket_reconstruct_enable(struct ast_websocket *session, size_t bytes);
+AST_OPTIONAL_API(void, ast_websocket_reconstruct_enable, (struct ast_websocket *session, size_t bytes), {return;});
/*!
* \brief Disable multi-frame reconstruction
@@ -136,21 +136,21 @@
* \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.
*/
-void ast_websocket_reconstruct_disable(struct ast_websocket *session);
+AST_OPTIONAL_API(void, ast_websocket_reconstruct_disable, (struct ast_websocket *session), {return;});
/*!
* \brief Increase the reference count for a WebSocket session
*
* \param session Pointer to the WebSocket session
*/
-void ast_websocket_ref(struct ast_websocket *session);
+AST_OPTIONAL_API(void, ast_websocket_ref, (struct ast_websocket *session), {return;});
/*!
* \brief Decrease the reference count for a WebSocket session
*
* \param session Pointer to the WebSocket session
*/
-void ast_websocket_unref(struct ast_websocket *session);
+AST_OPTIONAL_API(void, ast_websocket_unref, (struct ast_websocket *session), {return;});
/*!
* \brief Get the file descriptor for a WebSocket session.
@@ -159,14 +159,14 @@
*
* \note You must *not* directly read from or write to this file descriptor. It should only be used for polling.
*/
-int ast_websocket_fd(struct ast_websocket *session);
+AST_OPTIONAL_API(int, ast_websocket_fd, (struct ast_websocket *session), {return -1;});
/*!
* \brief Get the remote address for a WebSocket connected session.
*
* \retval ast_sockaddr Remote address
*/
-struct ast_sockaddr *ast_websocket_remote_address(struct ast_websocket *session);
+AST_OPTIONAL_API(struct ast_sockaddr *, ast_websocket_remote_address, (struct ast_websocket *session), {return NULL;});
/*!
* \brief Get whether the WebSocket session is using a secure transport or not.
@@ -174,7 +174,7 @@
* \retval 0 if unsecure
* \retval 1 if secure
*/
-int ast_websocket_is_secure(struct ast_websocket *session);
+AST_OPTIONAL_API(int, ast_websocket_is_secure, (struct ast_websocket *session), {return -1;});
/*!
* \brief Set the socket of a WebSocket session to be non-blocking.
@@ -182,6 +182,6 @@
* \retval 0 on success
* \retval -1 on failure
*/
-int ast_websocket_set_nonblock(struct ast_websocket *session);
+AST_OPTIONAL_API(int, ast_websocket_set_nonblock, (struct ast_websocket *session), {return -1;});
#endif
Modified: branches/11/res/res_http_websocket.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/res/res_http_websocket.c?view=diff&rev=373914&r1=373913&r2=373914
==============================================================================
--- branches/11/res/res_http_websocket.c (original)
+++ branches/11/res/res_http_websocket.c Thu Sep 27 12:05:26 2012
@@ -37,6 +37,8 @@
#include "asterisk/strings.h"
#include "asterisk/file.h"
#include "asterisk/unaligned.h"
+
+#define AST_API_MODULE
#include "asterisk/http_websocket.h"
/*! \brief GUID used to compute the accept key, defined in the specifications */
@@ -116,7 +118,7 @@
ast_free(session->payload);
}
-int ast_websocket_add_protocol(const char *name, ast_websocket_callback callback)
+int AST_OPTIONAL_API_NAME(ast_websocket_add_protocol)(const char *name, ast_websocket_callback callback)
{
struct websocket_protocol *protocol;
@@ -151,7 +153,7 @@
return 0;
}
-int ast_websocket_remove_protocol(const char *name, ast_websocket_callback callback)
+int AST_OPTIONAL_API_NAME(ast_websocket_remove_protocol)(const char *name, ast_websocket_callback callback)
{
struct websocket_protocol *protocol;
@@ -173,7 +175,7 @@
}
/*! \brief Close function for websocket session */
-int ast_websocket_close(struct ast_websocket *session, uint16_t reason)
+int AST_OPTIONAL_API_NAME(ast_websocket_close)(struct ast_websocket *session, uint16_t reason)
{
char frame[4] = { 0, }; /* The header is 2 bytes and the reason code takes up another 2 bytes */
@@ -190,7 +192,7 @@
/*! \brief Write function for websocket traffic */
-int ast_websocket_write(struct ast_websocket *session, enum ast_websocket_opcode opcode, char *payload, uint64_t actual_length)
+int AST_OPTIONAL_API_NAME(ast_websocket_write)(struct ast_websocket *session, enum ast_websocket_opcode opcode, char *payload, uint64_t actual_length)
{
size_t header_size = 2; /* The minimum size of a websocket frame is 2 bytes */
char *frame;
@@ -232,42 +234,42 @@
return 0;
}
-void ast_websocket_reconstruct_enable(struct ast_websocket *session, size_t bytes)
+void AST_OPTIONAL_API_NAME(ast_websocket_reconstruct_enable)(struct ast_websocket *session, size_t bytes)
{
session->reconstruct = MIN(bytes, MAXIMUM_RECONSTRUCTION_CEILING);
}
-void ast_websocket_reconstruct_disable(struct ast_websocket *session)
+void AST_OPTIONAL_API_NAME(ast_websocket_reconstruct_disable)(struct ast_websocket *session)
{
session->reconstruct = 0;
}
-void ast_websocket_ref(struct ast_websocket *session)
+void AST_OPTIONAL_API_NAME(ast_websocket_ref)(struct ast_websocket *session)
{
ao2_ref(session, +1);
}
-void ast_websocket_unref(struct ast_websocket *session)
+void AST_OPTIONAL_API_NAME(ast_websocket_unref)(struct ast_websocket *session)
{
ao2_ref(session, -1);
}
-int ast_websocket_fd(struct ast_websocket *session)
+int AST_OPTIONAL_API_NAME(ast_websocket_fd)(struct ast_websocket *session)
{
return session->closing ? -1 : session->fd;
}
-struct ast_sockaddr *ast_websocket_remote_address(struct ast_websocket *session)
+struct ast_sockaddr * AST_OPTIONAL_API_NAME(ast_websocket_remote_address)(struct ast_websocket *session)
{
return &session->address;
}
-int ast_websocket_is_secure(struct ast_websocket *session)
+int AST_OPTIONAL_API_NAME(ast_websocket_is_secure)(struct ast_websocket *session)
{
return session->secure;
}
-int ast_websocket_set_nonblock(struct ast_websocket *session)
+int AST_OPTIONAL_API_NAME(ast_websocket_set_nonblock)(struct ast_websocket *session)
{
int flags;
@@ -284,7 +286,7 @@
return 0;
}
-int ast_websocket_read(struct ast_websocket *session, char **payload, uint64_t *payload_len, enum ast_websocket_opcode *opcode, int *fragmented)
+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)
{
char buf[MAXIMUM_FRAME_SIZE] = "";
size_t frame_size, expected = 2;
More information about the asterisk-commits
mailing list