Asterisk - The Open Source Telephony Project
18.5.0
|
#include "asterisk.h"
#include <pjsip.h>
#include <pjsip_ua.h>
#include "asterisk/module.h"
#include "asterisk/http_websocket.h"
#include "asterisk/res_pjsip.h"
#include "asterisk/res_pjsip_session.h"
#include "asterisk/taskprocessor.h"
Go to the source code of this file.
Data Structures | |
struct | transport_create_data |
struct | transport_read_data |
struct | ws_transport |
Wrapper for pjsip_transport, for storing the WebSocket session. More... | |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static struct ast_taskprocessor * | create_websocket_serializer (void) |
static int | get_write_timeout (void) |
static int | load_module (void) |
static int | transport_create (void *data) |
Create a pjsip transport. More... | |
static void | transport_dtor (void *arg) |
static int | transport_read (void *data) |
Pass WebSocket data into pjsip transport manager. More... | |
static int | transport_shutdown (void *data) |
static int | unload_module (void) |
static void | websocket_cb (struct ast_websocket *session, struct ast_variable *parameters, struct ast_variable *headers) |
WebSocket connection handler. More... | |
static pj_bool_t | websocket_on_rx_msg (pjsip_rx_data *rdata) |
Store the transport a message came in on, so it can be used for outbound messages to that contact. More... | |
static void | websocket_outgoing_invite_request (struct ast_sip_session *session, struct pjsip_tx_data *tdata) |
Function called when an INVITE goes out. More... | |
static pj_status_t | ws_destroy (pjsip_transport *transport) |
Destroy the pjsip transport. More... | |
static pj_status_t | ws_send_msg (pjsip_transport *transport, pjsip_tx_data *tdata, const pj_sockaddr_t *rem_addr, int addr_len, void *token, pjsip_transport_callback callback) |
Send a message over the WebSocket connection. More... | |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "PJSIP WebSocket Transport Support" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND, .requires = "res_pjsip,res_http_websocket", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static int | transport_type_wss |
WebSocket transport module. More... | |
static int | transport_type_wss_ipv6 |
static pjsip_module | websocket_module |
static struct ast_sip_session_supplement | websocket_supplement |
Supplement for adding Websocket functionality to dialog. More... | |
static int | ws_obj_name_serial |
|
static |
Definition at line 535 of file res_pjsip_transport_websocket.c.
|
static |
Definition at line 535 of file res_pjsip_transport_websocket.c.
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 535 of file res_pjsip_transport_websocket.c.
|
static |
Definition at line 349 of file res_pjsip_transport_websocket.c.
References ast_sip_create_serializer(), ast_taskprocessor_build_name(), and AST_TASKPROCESSOR_MAX_NAME.
Referenced by websocket_cb().
|
static |
Definition at line 311 of file res_pjsip_transport_websocket.c.
References ao2_cleanup, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ast_debug, AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT, ast_sip_get_sorcery(), ast_sip_get_transport_states(), ast_sorcery_retrieve_by_id(), AST_TRANSPORT_WS, AST_TRANSPORT_WSS, ast_sip_transport_state::id, MAX, ws_transport::transport, transport_states, ast_sip_transport_state::type, ast_sip_transport::type, and ast_sip_transport::write_timeout.
Referenced by websocket_cb().
|
static |
Definition at line 490 of file res_pjsip_transport_websocket.c.
References AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_sip_register_service(), ast_sip_session_register_supplement, ast_sip_session_unregister_supplement(), ast_sip_unregister_service(), ast_websocket_add_protocol(), transport_type_wss, transport_type_wss_ipv6, websocket_cb(), and websocket_module.
Referenced by unload_module().
|
static |
Create a pjsip transport.
Definition at line 149 of file res_pjsip_transport_websocket.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_cleanup, ao2_ref, ao2_t_alloc_options, ast_atomic_fetchadd_int(), ast_debug, ast_log, ast_sip_get_pjsip_endpoint(), ast_sockaddr_port, ast_sockaddr_stringify(), ast_sockaddr_stringify_addr(), ast_websocket_is_secure(), ast_websocket_local_address(), ast_websocket_ref(), ast_websocket_remote_address(), buf, LOG_ERROR, NULL, pool, status, ws_transport::transport, transport_create_data::transport, transport_dtor(), transport_type_wss, transport_type_wss_ipv6, ws_destroy(), ws_obj_name_serial, ws_send_msg(), ws_transport::ws_session, and transport_create_data::ws_session.
Referenced by websocket_cb().
|
static |
Definition at line 100 of file res_pjsip_transport_websocket.c.
References ast_websocket_unref(), ws_transport::rdata, ws_transport::transport, and ws_transport::ws_session.
Referenced by transport_create().
|
static |
Pass WebSocket data into pjsip transport manager.
Definition at line 280 of file res_pjsip_transport_websocket.c.
References ast_sockaddr_port, ast_sockaddr_stringify(), ast_sockaddr_stringify_addr(), ast_websocket_remote_address(), buf, transport_read_data::payload, transport_read_data::payload_len, ws_transport::rdata, session, transport_read_data::transport, and ws_transport::ws_session.
Referenced by websocket_cb().
|
static |
Definition at line 125 of file res_pjsip_transport_websocket.c.
References ao2_ref, and ws_transport::transport.
Referenced by websocket_cb().
|
static |
Definition at line 520 of file res_pjsip_transport_websocket.c.
References AST_MODFLAG_LOAD_ORDER, AST_MODPRI_APP_DEPEND, AST_MODULE_INFO(), AST_MODULE_SUPPORT_CORE, ast_sip_session_unregister_supplement(), ast_sip_unregister_service(), ast_websocket_remove_protocol(), ASTERISK_GPL_KEY, load_module(), websocket_cb(), and websocket_module.
|
static |
WebSocket connection handler.
Definition at line 360 of file res_pjsip_transport_websocket.c.
References ast_log, ast_sip_push_task_wait_serializer(), ast_taskprocessor_unreference(), AST_WEBSOCKET_OPCODE_BINARY, AST_WEBSOCKET_OPCODE_CLOSE, AST_WEBSOCKET_OPCODE_TEXT, ast_websocket_read(), ast_websocket_set_nonblock(), ast_websocket_set_timeout(), ast_websocket_unref(), ast_websocket_wait_for_input(), create_websocket_serializer(), get_write_timeout(), LOG_ERROR, transport_read_data::payload, transport_read_data::payload_len, session, ws_transport::transport, transport_create_data::transport, transport_read_data::transport, transport_create(), transport_read(), transport_shutdown(), and transport_create_data::ws_session.
Referenced by load_module(), and unload_module().
|
static |
Store the transport a message came in on, so it can be used for outbound messages to that contact.
Definition at line 421 of file res_pjsip_transport_websocket.c.
References ast_log, AST_SOCKADDR_BUFLEN, DEBUG_ATLEAST, LOG_DEBUG, NULL, transport_type_wss, transport_type_wss_ipv6, and type.
|
static |
Function called when an INVITE goes out.
Definition at line 476 of file res_pjsip_transport_websocket.c.
References ast_sip_session::inv_session, NULL, and websocket_module.
|
static |
Destroy the pjsip transport.
Called by pjsip transport manager.
Definition at line 85 of file res_pjsip_transport_websocket.c.
References ao2_ref, ast_websocket_close(), ast_websocket_fd(), and ws_transport::ws_session.
Referenced by transport_create().
|
static |
Send a message over the WebSocket connection.
Called by pjsip transport manager.
Definition at line 63 of file res_pjsip_transport_websocket.c.
References AST_WEBSOCKET_OPCODE_TEXT, ast_websocket_write(), len(), and ws_transport::ws_session.
Referenced by transport_create().
|
static |
Definition at line 535 of file res_pjsip_transport_websocket.c.
|
static |
Definition at line 535 of file res_pjsip_transport_websocket.c.
|
static |
WebSocket transport module.
Definition at line 41 of file res_pjsip_transport_websocket.c.
Referenced by load_module(), transport_create(), and websocket_on_rx_msg().
|
static |
Definition at line 42 of file res_pjsip_transport_websocket.c.
Referenced by load_module(), transport_create(), and websocket_on_rx_msg().
|
static |
Definition at line 467 of file res_pjsip_transport_websocket.c.
Referenced by load_module(), unload_module(), and websocket_outgoing_invite_request().
|
static |
Supplement for adding Websocket functionality to dialog.
Definition at line 484 of file res_pjsip_transport_websocket.c.
|
static |
Used to ensure uniqueness among WS transport names
Definition at line 47 of file res_pjsip_transport_websocket.c.
Referenced by transport_create().