jabberd2
2.7.0
|
Go to the source code of this file.
Data Structures | |
struct | _libwebsock_frame |
Macros | |
#define | MASK_LENGTH 4 |
#define | FRAME_CHUNK_LENGTH 1024 |
#define | WS_OPCODE_CONTINUE 0x0 |
#define | WS_OPCODE_TEXT 0x1 |
#define | WS_OPCODE_BINARY 0x2 |
#define | WS_OPCODE_CLOSE 0x8 |
#define | WS_OPCODE_PING 0x9 |
#define | WS_OPCODE_PONG 0xa |
#define | WS_FRAGMENT_FIN (1 << 7) |
#define | WS_CLOSE_NORMAL 1000 |
#define | WS_CLOSE_GOING_AWAY 1001 |
#define | WS_CLOSE_PROTOCOL_ERROR 1002 |
#define | WS_CLOSE_NOT_ALLOWED 1003 |
#define | WS_CLOSE_RESERVED 1004 |
#define | WS_CLOSE_NO_CODE 1005 |
#define | WS_CLOSE_DIRTY 1006 |
#define | WS_CLOSE_WRONG_TYPE 1007 |
#define | WS_CLOSE_POLICY_VIOLATION 1008 |
#define | WS_CLOSE_MESSAGE_TOO_BIG 1009 |
#define | WS_CLOSE_UNEXPECTED_ERROR 1011 |
Typedefs | |
typedef struct _libwebsock_frame | libwebsock_frame |
Enumerations | |
enum | WS_FRAME_STATE { sw_start = 0, sw_got_two, sw_got_short_len, sw_got_full_len, sw_loaded_mask } |
Functions | |
static int | libwebsock_read_header (libwebsock_frame *frame) |
sx_buf_t | libwebsock_fragment_buffer (const char *data, unsigned int len, int flags) |
int | libwebsock_close_with_reason (sx_t s, _sx_websocket_conn_t sc, unsigned short code, const char *reason) |
int | libwebsock_send_fragment (sx_t s, _sx_websocket_conn_t sc, const char *data, unsigned int len, int flags) |
int | libwebsock_close (sx_t s, _sx_websocket_conn_t sc) |
void | libwebsock_fail_connection (sx_t s, _sx_websocket_conn_t sc, unsigned short close_code) |
static int | _sx_websocket_http_header_field (http_parser *parser, const char *chars, size_t length) |
static int | _sx_websocket_http_header_value (http_parser *parser, const char *chars, size_t length) |
static int | _sx_websocket_http_headers_complete (http_parser *parser) |
static void | _sx_websocket_http_return (sx_t s, char *status, char *headers_format,...) |
static int | _sx_websocket_rio (sx_t s, sx_plugin_t p, sx_buf_t buf) |
static int | _sx_websocket_wio (sx_t s, sx_plugin_t p, sx_buf_t buf) |
static void | _sx_websocket_new (sx_t s, sx_plugin_t p) |
static void | _sx_websocket_free (sx_t s, sx_plugin_t p) |
cleanup More... | |
int | sx_websocket_init (sx_env_t env, sx_plugin_t p, va_list args) |
args: none More... | |
Variables | |
static const char | websocket_guid [] = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" |
this plugin implements WebSocket C2S access RFC 7395 : An Extensible Messaging and Presence Protocol (XMPP) Subprotocol for WebSocket http://tools.ietf.org/html/rfc7395 More... | |
static http_parser_settings | settings |
#define MASK_LENGTH 4 |
Definition at line 34 of file websocket.c.
Referenced by libwebsock_read_header().
#define FRAME_CHUNK_LENGTH 1024 |
Definition at line 35 of file websocket.c.
Referenced by _sx_websocket_rio().
#define WS_OPCODE_CONTINUE 0x0 |
Definition at line 37 of file websocket.c.
Referenced by _sx_websocket_rio().
#define WS_OPCODE_TEXT 0x1 |
Definition at line 38 of file websocket.c.
Referenced by _sx_websocket_rio(), and _sx_websocket_wio().
#define WS_OPCODE_BINARY 0x2 |
Definition at line 39 of file websocket.c.
#define WS_OPCODE_CLOSE 0x8 |
Definition at line 40 of file websocket.c.
Referenced by _sx_websocket_rio(), and libwebsock_close_with_reason().
#define WS_OPCODE_PING 0x9 |
Definition at line 41 of file websocket.c.
Referenced by _sx_websocket_rio().
#define WS_OPCODE_PONG 0xa |
Definition at line 42 of file websocket.c.
Referenced by _sx_websocket_rio().
#define WS_FRAGMENT_FIN (1 << 7) |
Definition at line 44 of file websocket.c.
Referenced by _sx_websocket_rio(), _sx_websocket_wio(), and libwebsock_close_with_reason().
#define WS_CLOSE_NORMAL 1000 |
Definition at line 46 of file websocket.c.
Referenced by libwebsock_close().
#define WS_CLOSE_GOING_AWAY 1001 |
Definition at line 47 of file websocket.c.
#define WS_CLOSE_PROTOCOL_ERROR 1002 |
Definition at line 48 of file websocket.c.
Referenced by _sx_websocket_rio(), and libwebsock_fail_connection().
#define WS_CLOSE_NOT_ALLOWED 1003 |
Definition at line 49 of file websocket.c.
#define WS_CLOSE_RESERVED 1004 |
Definition at line 50 of file websocket.c.
#define WS_CLOSE_NO_CODE 1005 |
Definition at line 51 of file websocket.c.
#define WS_CLOSE_DIRTY 1006 |
Definition at line 52 of file websocket.c.
#define WS_CLOSE_WRONG_TYPE 1007 |
Definition at line 53 of file websocket.c.
#define WS_CLOSE_POLICY_VIOLATION 1008 |
Definition at line 54 of file websocket.c.
#define WS_CLOSE_MESSAGE_TOO_BIG 1009 |
Definition at line 55 of file websocket.c.
#define WS_CLOSE_UNEXPECTED_ERROR 1011 |
Definition at line 56 of file websocket.c.
Referenced by _sx_websocket_wio(), and libwebsock_send_fragment().
typedef struct _libwebsock_frame libwebsock_frame |
enum WS_FRAME_STATE |
Enumerator | |
---|---|
sw_start | |
sw_got_two | |
sw_got_short_len | |
sw_got_full_len | |
sw_loaded_mask |
Definition at line 58 of file websocket.c.
|
inlinestatic |
Definition at line 81 of file websocket.c.
References _libwebsock_frame::fin, _libwebsock_frame::mask, MASK_LENGTH, _libwebsock_frame::mask_offset, _libwebsock_frame::opcode, _libwebsock_frame::payload_len, _libwebsock_frame::payload_len_short, _libwebsock_frame::payload_offset, _libwebsock_frame::rawdata, _libwebsock_frame::rawdata_idx, _libwebsock_frame::rawdata_sz, _libwebsock_frame::size, _libwebsock_frame::state, sw_got_full_len, sw_got_short_len, sw_got_two, sw_loaded_mask, and sw_start.
Referenced by _sx_websocket_rio().
sx_buf_t libwebsock_fragment_buffer | ( | const char * | data, |
unsigned int | len, | ||
int | flags | ||
) |
Definition at line 153 of file websocket.c.
References _sx_buffer_new(), _sx_debug, _sx_buf_st::data, and ZONE.
Referenced by _sx_websocket_wio(), and libwebsock_send_fragment().
int libwebsock_close_with_reason | ( | sx_t | s, |
_sx_websocket_conn_t | sc, | ||
unsigned short | code, | ||
const char * | reason | ||
) |
Definition at line 211 of file websocket.c.
References libwebsock_send_fragment(), sx_close(), WS_FRAGMENT_FIN, and WS_OPCODE_CLOSE.
Referenced by _sx_websocket_wio(), libwebsock_close(), and libwebsock_send_fragment().
int libwebsock_send_fragment | ( | sx_t | s, |
_sx_websocket_conn_t | sc, | ||
const char * | data, | ||
unsigned int | len, | ||
int | flags | ||
) |
Definition at line 201 of file websocket.c.
References _sx_event, event_WANT_WRITE, jqueue_push(), libwebsock_close_with_reason(), libwebsock_fragment_buffer(), _sx_st::want_write, _sx_st::wbufq, and WS_CLOSE_UNEXPECTED_ERROR.
Referenced by _sx_websocket_rio(), and libwebsock_close_with_reason().
int libwebsock_close | ( | sx_t | s, |
_sx_websocket_conn_t | sc | ||
) |
Definition at line 230 of file websocket.c.
References libwebsock_close_with_reason(), and WS_CLOSE_NORMAL.
Referenced by _sx_websocket_rio().
void libwebsock_fail_connection | ( | sx_t | s, |
_sx_websocket_conn_t | sc, | ||
unsigned short | close_code | ||
) |
Definition at line 235 of file websocket.c.
References _sx_buffer_new(), _sx_event, _sx_buf_st::data, event_WANT_WRITE, _sx_buf_st::len, sx_close(), _sx_st::want_write, and WS_CLOSE_PROTOCOL_ERROR.
Referenced by _sx_websocket_rio().
|
static |
Definition at line 250 of file websocket.c.
References _sx_debug, spool_escape(), spool_new(), spool_print(), strunescape(), xhash_put(), and ZONE.
Referenced by _sx_websocket_http_headers_complete(), and sx_websocket_init().
|
static |
Definition at line 265 of file websocket.c.
References _sx_debug, spool_escape(), spool_new(), and ZONE.
Referenced by sx_websocket_init().
|
static |
Definition at line 277 of file websocket.c.
References _sx_debug, _sx_websocket_http_header_field(), and ZONE.
Referenced by sx_websocket_init().
|
static |
Definition at line 287 of file websocket.c.
References _sx_buffer_new(), _sx_event, _sx_buf_st::data, event_WANT_WRITE, j_strlen(), jqueue_push(), _sx_buf_st::len, _sx_st::want_write, and _sx_st::wbufq.
Referenced by _sx_websocket_rio().
|
static |
Definition at line 314 of file websocket.c.
References _sx_buffer_clear(), _sx_buffer_set(), _sx_debug, _sx_websocket_http_return(), b64_encode(), _sx_buf_st::data, _libwebsock_frame::fin, _sx_st::flags, FRAME_CHUNK_LENGTH, _sx_plugin_st::index, j_atoi(), j_strcmp(), j_strlen(), _sx_buf_st::len, libwebsock_close(), libwebsock_fail_connection(), libwebsock_read_header(), libwebsock_send_fragment(), _libwebsock_frame::mask, _libwebsock_frame::mask_offset, _libwebsock_frame::opcode, _libwebsock_frame::payload_len, _libwebsock_frame::payload_offset, _sx_st::plugin_data, _sx_plugin_st::private, _libwebsock_frame::rawdata, _libwebsock_frame::rawdata_idx, _libwebsock_frame::rawdata_sz, settings, sha1_append(), sha1_finish(), sha1_init(), _libwebsock_frame::size, _libwebsock_frame::state, _sx_st::state, state_NONE, stream_err_BAD_FORMAT, sw_loaded_mask, sx_close(), sx_error(), SX_WEBSOCKET_WRAPPER, _sx_st::want_read, websocket_guid, WS_CLOSE_PROTOCOL_ERROR, WS_FRAGMENT_FIN, WS_OPCODE_CLOSE, WS_OPCODE_CONTINUE, WS_OPCODE_PING, WS_OPCODE_PONG, WS_OPCODE_TEXT, xhash_get(), and ZONE.
Referenced by sx_websocket_init().
|
static |
Definition at line 516 of file websocket.c.
References _sx_buffer_set(), _sx_debug, _sx_buf_st::data, _sx_st::flags, _sx_plugin_st::index, _sx_buf_st::len, libwebsock_close_with_reason(), libwebsock_fragment_buffer(), _sx_st::plugin_data, SX_WEBSOCKET_WRAPPER, WS_CLOSE_UNEXPECTED_ERROR, WS_FRAGMENT_FIN, WS_OPCODE_TEXT, and ZONE.
Referenced by sx_websocket_init().
|
static |
Definition at line 539 of file websocket.c.
References _sx_chain_io_plugin(), _sx_debug, _sx_plugin_st::index, _sx_st::plugin_data, pool_new, spool_new(), _sx_st::tag, xhash_new(), and ZONE.
Referenced by sx_websocket_init().
|
static |
cleanup
Definition at line 567 of file websocket.c.
References _sx_plugin_st::index, log_debug, _sx_st::plugin_data, pool_free(), and ZONE.
Referenced by sx_websocket_init().
int sx_websocket_init | ( | sx_env_t | env, |
sx_plugin_t | p, | ||
va_list | args | ||
) |
args: none
Definition at line 585 of file websocket.c.
References _sx_debug, _sx_websocket_free(), _sx_websocket_http_header_field(), _sx_websocket_http_header_value(), _sx_websocket_http_headers_complete(), _sx_websocket_new(), _sx_websocket_rio(), _sx_websocket_wio(), _sx_plugin_st::free, _sx_plugin_st::private, _sx_plugin_st::rio, _sx_plugin_st::server, settings, _sx_plugin_st::wio, and ZONE.
Referenced by JABBER_MAIN().
|
static |
this plugin implements WebSocket C2S access RFC 7395 : An Extensible Messaging and Presence Protocol (XMPP) Subprotocol for WebSocket http://tools.ietf.org/html/rfc7395
Definition at line 29 of file websocket.c.
Referenced by _sx_websocket_rio().
|
static |
Definition at line 31 of file websocket.c.
Referenced by _sx_websocket_rio(), and sx_websocket_init().