Asterisk - The Open Source Telephony Project GIT-master-b023714
|
#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... | |
Macros | |
#define | COLON_LEN 1 |
#define | MAX_PORT_LEN 5 |
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 void | save_orig_contact_host (pjsip_rx_data *rdata, pjsip_sip_uri *uri) |
static int | transport_create (void *data) |
Create a pjsip transport. | |
static void | transport_dtor (void *arg) |
static int | transport_read (void *data) |
Pass WebSocket data into pjsip transport manager. | |
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. | |
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. | |
static void | websocket_outgoing_invite_request (struct ast_sip_session *session, struct pjsip_tx_data *tdata) |
Function called when an INVITE goes out. | |
static pj_status_t | ws_destroy (pjsip_transport *transport) |
Destroy the pjsip transport. | |
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. | |
static pj_status_t | ws_shutdown (pjsip_transport *transport) |
Shut down the pjsip transport. | |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "PJSIP WebSocket Transport Support" , .key = ASTERISK_GPL_KEY , .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. | |
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. | |
static int | ws_obj_name_serial |
#define COLON_LEN 1 |
#define MAX_PORT_LEN 5 |
|
static |
Definition at line 582 of file res_pjsip_transport_websocket.c.
|
static |
Definition at line 582 of file res_pjsip_transport_websocket.c.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 582 of file res_pjsip_transport_websocket.c.
|
static |
Definition at line 364 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 326 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, 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 537 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(), websocket_module, and websocket_supplement.
|
static |
Definition at line 435 of file res_pjsip_transport_websocket.c.
References ast_debug, COLON_LEN, and MAX_PORT_LEN.
Referenced by websocket_on_rx_msg().
|
static |
Create a pjsip transport.
Definition at line 161 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, ws_transport::rdata, 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, transport_create_data::ws_session, and ws_shutdown().
Referenced by load_module(), unload_module(), and websocket_cb().
|
static |
Definition at line 112 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 295 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 137 of file res_pjsip_transport_websocket.c.
References ao2_ref, and ws_transport::transport.
Referenced by websocket_cb().
|
static |
Definition at line 567 of file res_pjsip_transport_websocket.c.
References ast_sip_session_unregister_supplement(), ast_sip_unregister_service(), ast_websocket_remove_protocol(), websocket_cb(), websocket_module, and websocket_supplement.
|
static |
WebSocket connection handler.
Definition at line 375 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 464 of file res_pjsip_transport_websocket.c.
References ast_log, AST_SOCKADDR_BUFLEN, DEBUG_ATLEAST, LOG_DEBUG, NULL, save_orig_contact_host(), transport_type_wss, transport_type_wss_ipv6, and type.
|
static |
Function called when an INVITE goes out.
Definition at line 523 of file res_pjsip_transport_websocket.c.
References NULL, session, 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, and ws_transport::transport.
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(), ast_websocket::buf, len(), ws_transport::transport, and ws_transport::ws_session.
Referenced by transport_create().
|
static |
Shut down the pjsip transport.
Called by pjsip transport manager.
Definition at line 99 of file res_pjsip_transport_websocket.c.
References ast_websocket_close(), ast_websocket_fd(), ws_transport::transport, and ws_transport::ws_session.
Referenced by transport_create().
|
static |
Definition at line 582 of file res_pjsip_transport_websocket.c.
|
static |
Definition at line 582 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 514 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 531 of file res_pjsip_transport_websocket.c.
Referenced by load_module(), and unload_module().
|
static |
Used to ensure uniqueness among WS transport names
Definition at line 47 of file res_pjsip_transport_websocket.c.
Referenced by transport_create().