mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
refactor: move out extension lws members into ws and establish role structs for vhost content
This commit is contained in:
parent
7b227eb333
commit
8e9751e26e
14 changed files with 108 additions and 100 deletions
|
@ -566,10 +566,10 @@ lws_create_vhost(struct lws_context *context,
|
|||
lwsl_info("%s set to only support RAW\n", vh->name);
|
||||
|
||||
#if defined(LWS_WITH_HTTP2)
|
||||
vh->set = context->set;
|
||||
vh->h2.set = context->set;
|
||||
if (info->http2_settings[0])
|
||||
for (n = 1; n < LWS_H2_SETTINGS_LEN; n++)
|
||||
vh->set.s[n] = info->http2_settings[n];
|
||||
vh->h2.set.s[n] = info->http2_settings[n];
|
||||
#endif
|
||||
|
||||
vh->iface = info->iface;
|
||||
|
@ -752,17 +752,17 @@ lws_create_vhost(struct lws_context *context,
|
|||
* give the vhost a unified list of extensions including the
|
||||
* ones that came from plugins
|
||||
*/
|
||||
vh->extensions = lws_zalloc(sizeof(struct lws_extension) *
|
||||
vh->ws.extensions = lws_zalloc(sizeof(struct lws_extension) *
|
||||
(m + context->plugin_extension_count + 1),
|
||||
"extensions");
|
||||
if (!vh->extensions)
|
||||
if (!vh->ws.extensions)
|
||||
return NULL;
|
||||
|
||||
memcpy((struct lws_extension *)vh->extensions, info->extensions,
|
||||
memcpy((struct lws_extension *)vh->ws.extensions, info->extensions,
|
||||
sizeof(struct lws_extension) * m);
|
||||
plugin = context->plugin_list;
|
||||
while (plugin) {
|
||||
memcpy((struct lws_extension *)&vh->extensions[m],
|
||||
memcpy((struct lws_extension *)&vh->ws.extensions[m],
|
||||
plugin->caps.extensions,
|
||||
sizeof(struct lws_extension) *
|
||||
plugin->caps.count_extensions);
|
||||
|
@ -771,7 +771,7 @@ lws_create_vhost(struct lws_context *context,
|
|||
}
|
||||
} else
|
||||
#endif
|
||||
vh->extensions = info->extensions;
|
||||
vh->ws.extensions = info->extensions;
|
||||
#endif
|
||||
|
||||
vh->listen_port = info->port;
|
||||
|
@ -1599,7 +1599,7 @@ lws_vhost_destroy2(struct lws_vhost *vh)
|
|||
#ifdef LWS_WITH_PLUGINS
|
||||
#if !defined(LWS_WITHOUT_EXTENSIONS)
|
||||
if (context->plugin_extension_count)
|
||||
lws_free((void *)vh->extensions);
|
||||
lws_free((void *)vh->ws.extensions);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef LWS_WITH_ACCESS_LOG
|
||||
|
|
|
@ -2379,6 +2379,13 @@ lws_extension_callback_pm_deflate(struct lws_context *context,
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LWS_EXTERN int
|
||||
lws_set_extension_option(struct lws *wsi, const char *ext_name,
|
||||
const char *opt_name, const char *opt_val)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
LWS_EXTERN int
|
||||
|
@ -2894,16 +2901,6 @@ lws_pvo_search(const struct lws_protocol_vhost_options *pvo, const char *name)
|
|||
return pvo;
|
||||
}
|
||||
|
||||
#if defined(LWS_WITHOUT_EXTENSIONS)
|
||||
LWS_EXTERN int
|
||||
lws_set_extension_option(struct lws *wsi, const char *ext_name,
|
||||
const char *opt_name, const char *opt_val)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
lws_sum_stats(const struct lws_context *ctx, struct lws_conn_stats *cs)
|
||||
{
|
||||
|
|
|
@ -2264,16 +2264,6 @@ LWS_VISIBLE LWS_EXTERN int
|
|||
lws_set_extension_option(struct lws *wsi, const char *ext_name,
|
||||
const char *opt_name, const char *opt_val);
|
||||
|
||||
#if !defined(LWS_WITHOUT_EXTENSIONS)
|
||||
/* lws_get_internal_extensions() - DEPRECATED
|
||||
*
|
||||
* \Deprecated There is no longer a set internal extensions table. The table is provided
|
||||
* by user code along with application-specific settings. See the test
|
||||
* client and server for how to do.
|
||||
*/
|
||||
static LWS_INLINE LWS_WARN_DEPRECATED const struct lws_extension *
|
||||
lws_get_internal_extensions(void) { return NULL; }
|
||||
|
||||
/**
|
||||
* lws_ext_parse_options() - deal with parsing negotiated extension options
|
||||
*
|
||||
|
@ -2288,7 +2278,6 @@ LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT
|
|||
lws_ext_parse_options(const struct lws_extension *ext, struct lws *wsi,
|
||||
void *ext_user, const struct lws_ext_options *opts,
|
||||
const char *o, int len);
|
||||
#endif
|
||||
|
||||
/** lws_extension_callback_pm_deflate() - extension for RFC7692
|
||||
*
|
||||
|
|
|
@ -883,9 +883,14 @@ struct lws_vhost {
|
|||
#if LWS_MAX_SMP > 1
|
||||
pthread_mutex_t lock;
|
||||
#endif
|
||||
#if defined(LWS_WITH_HTTP2)
|
||||
struct http2_settings set;
|
||||
|
||||
#if defined(LWS_ROLE_H2)
|
||||
struct lws_vhost_role_h2 h2;
|
||||
#endif
|
||||
#if defined(LWS_ROLE_WS)
|
||||
struct lws_vhost_role_ws ws;
|
||||
#endif
|
||||
|
||||
#if defined(LWS_WITH_SOCKS5)
|
||||
char socks_proxy_address[128];
|
||||
char socks_user[96];
|
||||
|
@ -927,9 +932,7 @@ struct lws_vhost {
|
|||
#if defined(LWS_WITH_MBEDTLS)
|
||||
lws_tls_x509 *x509_client_CA;
|
||||
#endif
|
||||
#if !defined(LWS_WITHOUT_EXTENSIONS)
|
||||
const struct lws_extension *extensions;
|
||||
#endif
|
||||
|
||||
struct lws_timed_vh_protocol *timed_vh_protocol_list;
|
||||
void *user;
|
||||
|
||||
|
@ -1417,10 +1420,6 @@ struct lws {
|
|||
/* truncated send handling */
|
||||
unsigned char *trunc_alloc; /* non-NULL means buffering in progress */
|
||||
|
||||
#if !defined(LWS_WITHOUT_EXTENSIONS)
|
||||
const struct lws_extension *active_extensions[LWS_MAX_EXTENSIONS_ACTIVE];
|
||||
void *act_ext_user[LWS_MAX_EXTENSIONS_ACTIVE];
|
||||
#endif
|
||||
#if defined(LWS_WITH_TLS)
|
||||
lws_tls_conn *ssl;
|
||||
lws_tls_bio *client_bio;
|
||||
|
@ -1513,9 +1512,7 @@ struct lws {
|
|||
#ifdef LWS_WITH_HTTP_PROXY
|
||||
unsigned int perform_rewrite:1;
|
||||
#endif
|
||||
#if !defined(LWS_WITHOUT_EXTENSIONS)
|
||||
unsigned int extension_data_pending:1;
|
||||
#endif
|
||||
|
||||
#if defined(LWS_WITH_TLS)
|
||||
unsigned int use_ssl;
|
||||
#endif
|
||||
|
@ -1532,9 +1529,6 @@ struct lws {
|
|||
unsigned short pending_timeout_limit;
|
||||
|
||||
/* chars */
|
||||
#if !defined(LWS_WITHOUT_EXTENSIONS)
|
||||
uint8_t count_act_ext;
|
||||
#endif
|
||||
|
||||
char lws_rx_parse_state; /* enum lws_rx_parse_state */
|
||||
char rx_frame_type; /* enum lws_write_protocol */
|
||||
|
|
|
@ -594,12 +594,12 @@ lws_hpack_dynamic_size(struct lws *wsi, int size)
|
|||
dyn = &nwsi->h2.h2n->hpack_dyn_table;
|
||||
lwsl_info("%s: from %d to %d, lim %d\n", __func__,
|
||||
(int)dyn->num_entries, size,
|
||||
nwsi->vhost->set.s[H2SET_HEADER_TABLE_SIZE]);
|
||||
nwsi->vhost->h2.set.s[H2SET_HEADER_TABLE_SIZE]);
|
||||
|
||||
if (size > (int)nwsi->vhost->set.s[H2SET_HEADER_TABLE_SIZE]) {
|
||||
if (size > (int)nwsi->vhost->h2.set.s[H2SET_HEADER_TABLE_SIZE]) {
|
||||
lwsl_notice("rejecting hpack dyn size %u\n", size);
|
||||
//#if defined(LWS_WITH_ESP32)
|
||||
size = nwsi->vhost->set.s[H2SET_HEADER_TABLE_SIZE];
|
||||
size = nwsi->vhost->h2.set.s[H2SET_HEADER_TABLE_SIZE];
|
||||
//#else
|
||||
// lws_h2_goaway(nwsi, H2_ERR_COMPRESSION_ERROR,
|
||||
// "Asked for header table bigger than we told");
|
||||
|
|
|
@ -131,7 +131,7 @@ lws_h2_new_pps(enum lws_h2_protocol_send_type type)
|
|||
|
||||
void lws_h2_init(struct lws *wsi)
|
||||
{
|
||||
wsi->h2.h2n->set = wsi->vhost->set;
|
||||
wsi->h2.h2n->set = wsi->vhost->h2.set;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -196,7 +196,7 @@ lws_wsi_server_new(struct lws_vhost *vh, struct lws *parent_wsi,
|
|||
|
||||
wsi->h2.my_priority = 16;
|
||||
wsi->h2.tx_cr = nwsi->h2.h2n->set.s[H2SET_INITIAL_WINDOW_SIZE];
|
||||
wsi->h2.peer_tx_cr_est = nwsi->vhost->set.s[H2SET_INITIAL_WINDOW_SIZE];
|
||||
wsi->h2.peer_tx_cr_est = nwsi->vhost->h2.set.s[H2SET_INITIAL_WINDOW_SIZE];
|
||||
|
||||
lwsi_set_state(wsi, LRS_ESTABLISHED);
|
||||
lwsi_set_role(wsi, lwsi_role(parent_wsi));
|
||||
|
@ -254,7 +254,7 @@ lws_wsi_h2_adopt(struct lws *parent_wsi, struct lws *wsi)
|
|||
|
||||
wsi->h2.my_priority = 16;
|
||||
wsi->h2.tx_cr = nwsi->h2.h2n->set.s[H2SET_INITIAL_WINDOW_SIZE];
|
||||
wsi->h2.peer_tx_cr_est = nwsi->vhost->set.s[H2SET_INITIAL_WINDOW_SIZE];
|
||||
wsi->h2.peer_tx_cr_est = nwsi->vhost->h2.set.s[H2SET_INITIAL_WINDOW_SIZE];
|
||||
|
||||
if (lws_ensure_user_space(wsi))
|
||||
goto bail1;
|
||||
|
@ -463,7 +463,7 @@ lws_h2_settings(struct lws *wsi, struct http2_settings *settings,
|
|||
|
||||
break;
|
||||
case H2SET_MAX_FRAME_SIZE:
|
||||
if (b < wsi->vhost->set.s[H2SET_MAX_FRAME_SIZE]) {
|
||||
if (b < wsi->vhost->h2.set.s[H2SET_MAX_FRAME_SIZE]) {
|
||||
lws_h2_goaway(nwsi, H2_ERR_PROTOCOL_ERROR,
|
||||
"Frame size < initial");
|
||||
return 1;
|
||||
|
|
|
@ -438,7 +438,7 @@ rops_check_upgrades_h2(struct lws *wsi)
|
|||
* SETTINGS saying that we support it though.
|
||||
*/
|
||||
p = lws_hdr_simple_ptr(wsi, WSI_TOKEN_HTTP_COLON_METHOD);
|
||||
if (!wsi->vhost->set.s[H2SET_ENABLE_CONNECT_PROTOCOL] ||
|
||||
if (!wsi->vhost->h2.set.s[H2SET_ENABLE_CONNECT_PROTOCOL] ||
|
||||
!wsi->http2_substream || !p || strcmp(p, "CONNECT"))
|
||||
return LWS_UPG_RET_CONTINUE;
|
||||
|
||||
|
|
|
@ -41,6 +41,10 @@ struct http2_settings {
|
|||
uint32_t s[H2SET_COUNT];
|
||||
};
|
||||
|
||||
struct lws_vhost_role_h2 {
|
||||
struct http2_settings set;
|
||||
};
|
||||
|
||||
enum lws_h2_wellknown_frame_types {
|
||||
LWS_H2_FRAME_TYPE_DATA,
|
||||
LWS_H2_FRAME_TYPE_HEADERS,
|
||||
|
|
|
@ -106,7 +106,7 @@ int lws_ws_client_rx_sm(struct lws *wsi, unsigned char c)
|
|||
/* revisit if an extension wants them... */
|
||||
if (
|
||||
#if !defined(LWS_WITHOUT_EXTENSIONS)
|
||||
!wsi->count_act_ext &&
|
||||
!wsi->ws->count_act_ext &&
|
||||
#endif
|
||||
wsi->ws->rsv) {
|
||||
lwsl_info("illegal rsv bits set\n");
|
||||
|
|
|
@ -97,7 +97,7 @@ lws_generate_client_ws_handshake(struct lws *wsi, char *p)
|
|||
/* tell the server what extensions we could support */
|
||||
|
||||
#if !defined(LWS_WITHOUT_EXTENSIONS)
|
||||
ext = wsi->vhost->extensions;
|
||||
ext = wsi->vhost->ws.extensions;
|
||||
while (ext && ext->callback) {
|
||||
|
||||
n = wsi->vhost->protocols[0].callback(wsi,
|
||||
|
@ -399,7 +399,7 @@ check_extensions:
|
|||
lwsl_notice("checking client ext %s\n", ext_name);
|
||||
|
||||
n = 0;
|
||||
ext = wsi->vhost->extensions;
|
||||
ext = wsi->vhost->ws.extensions;
|
||||
while (ext && ext->callback) {
|
||||
if (strcmp(ext_name, ext->name)) {
|
||||
ext++;
|
||||
|
@ -411,13 +411,13 @@ check_extensions:
|
|||
|
||||
/* instantiate the extension on this conn */
|
||||
|
||||
wsi->active_extensions[wsi->count_act_ext] = ext;
|
||||
wsi->ws->active_extensions[wsi->ws->count_act_ext] = ext;
|
||||
|
||||
/* allow him to construct his ext instance */
|
||||
|
||||
if (ext->callback(lws_get_context(wsi), ext, wsi,
|
||||
LWS_EXT_CB_CLIENT_CONSTRUCT,
|
||||
(void *)&wsi->act_ext_user[wsi->count_act_ext],
|
||||
(void *)&wsi->ws->act_ext_user[wsi->ws->count_act_ext],
|
||||
(void *)&opts, 0)) {
|
||||
lwsl_info(" ext %s failed construction\n",
|
||||
ext_name);
|
||||
|
@ -439,8 +439,8 @@ check_extensions:
|
|||
}
|
||||
|
||||
if (ext_name[0] &&
|
||||
lws_ext_parse_options(ext, wsi, wsi->act_ext_user[
|
||||
wsi->count_act_ext], opts, ext_name,
|
||||
lws_ext_parse_options(ext, wsi, wsi->ws->act_ext_user[
|
||||
wsi->ws->count_act_ext], opts, ext_name,
|
||||
(int)strlen(ext_name))) {
|
||||
lwsl_err("%s: unable to parse user defaults '%s'",
|
||||
__func__, ext_name);
|
||||
|
@ -452,7 +452,7 @@ check_extensions:
|
|||
* give the extension the server options
|
||||
*/
|
||||
if (a && lws_ext_parse_options(ext, wsi,
|
||||
wsi->act_ext_user[wsi->count_act_ext],
|
||||
wsi->ws->act_ext_user[wsi->ws->count_act_ext],
|
||||
opts, a, lws_ptr_diff(c, a))) {
|
||||
lwsl_err("%s: unable to parse remote def '%s'",
|
||||
__func__, a);
|
||||
|
@ -462,7 +462,7 @@ check_extensions:
|
|||
|
||||
if (ext->callback(lws_get_context(wsi), ext, wsi,
|
||||
LWS_EXT_CB_OPTION_CONFIRM,
|
||||
wsi->act_ext_user[wsi->count_act_ext],
|
||||
wsi->ws->act_ext_user[wsi->ws->count_act_ext],
|
||||
NULL, 0)) {
|
||||
lwsl_err("%s: ext %s rejects server options %s",
|
||||
__func__, ext->name, a);
|
||||
|
@ -470,7 +470,7 @@ check_extensions:
|
|||
goto bail2;
|
||||
}
|
||||
|
||||
wsi->count_act_ext++;
|
||||
wsi->ws->count_act_ext++;
|
||||
|
||||
ext++;
|
||||
}
|
||||
|
|
|
@ -163,18 +163,21 @@ int lws_ext_cb_active(struct lws *wsi, int reason, void *arg, int len)
|
|||
{
|
||||
int n, m, handled = 0;
|
||||
|
||||
for (n = 0; n < wsi->count_act_ext; n++) {
|
||||
m = wsi->active_extensions[n]->callback(lws_get_context(wsi),
|
||||
wsi->active_extensions[n], wsi, reason,
|
||||
wsi->act_ext_user[n], arg, len);
|
||||
if (!wsi->ws)
|
||||
return 0;
|
||||
|
||||
for (n = 0; n < wsi->ws->count_act_ext; n++) {
|
||||
m = wsi->ws->active_extensions[n]->callback(lws_get_context(wsi),
|
||||
wsi->ws->active_extensions[n], wsi, reason,
|
||||
wsi->ws->act_ext_user[n], arg, len);
|
||||
if (m < 0) {
|
||||
lwsl_ext("Ext '%s' failed to handle callback %d!\n",
|
||||
wsi->active_extensions[n]->name, reason);
|
||||
wsi->ws->active_extensions[n]->name, reason);
|
||||
return -1;
|
||||
}
|
||||
/* valgrind... */
|
||||
if (reason == LWS_EXT_CB_DESTROY)
|
||||
wsi->act_ext_user[n] = NULL;
|
||||
wsi->ws->act_ext_user[n] = NULL;
|
||||
if (m > handled)
|
||||
handled = m;
|
||||
}
|
||||
|
@ -188,17 +191,17 @@ int lws_ext_cb_all_exts(struct lws_context *context, struct lws *wsi,
|
|||
int n = 0, m, handled = 0;
|
||||
const struct lws_extension *ext;
|
||||
|
||||
if (!wsi || !wsi->vhost)
|
||||
if (!wsi || !wsi->vhost || !wsi->ws)
|
||||
return 0;
|
||||
|
||||
ext = wsi->vhost->extensions;
|
||||
ext = wsi->vhost->ws.extensions;
|
||||
|
||||
while (ext && ext->callback && !handled) {
|
||||
m = ext->callback(context, ext, wsi, reason,
|
||||
(void *)(lws_intptr_t)n, arg, len);
|
||||
if (m < 0) {
|
||||
lwsl_ext("Ext '%s' failed to handle callback %d!\n",
|
||||
wsi->active_extensions[n]->name, reason);
|
||||
wsi->ws->active_extensions[n]->name, reason);
|
||||
return -1;
|
||||
}
|
||||
if (m)
|
||||
|
@ -290,7 +293,7 @@ lws_issue_raw_ext_access(struct lws *wsi, unsigned char *buf, size_t len)
|
|||
* when he is ready to send and take care of it there
|
||||
*/
|
||||
lws_callback_on_writable(wsi);
|
||||
wsi->extension_data_pending = 1;
|
||||
wsi->ws->extension_data_pending = 1;
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
|
@ -304,15 +307,18 @@ lws_any_extension_handled(struct lws *wsi, enum lws_extension_callback_reasons r
|
|||
struct lws_context *context = wsi->context;
|
||||
int n, handled = 0;
|
||||
|
||||
if (!wsi->ws)
|
||||
return 0;
|
||||
|
||||
/* maybe an extension will take care of it for us */
|
||||
|
||||
for (n = 0; n < wsi->count_act_ext && !handled; n++) {
|
||||
if (!wsi->active_extensions[n]->callback)
|
||||
for (n = 0; n < wsi->ws->count_act_ext && !handled; n++) {
|
||||
if (!wsi->ws->active_extensions[n]->callback)
|
||||
continue;
|
||||
|
||||
handled |= wsi->active_extensions[n]->callback(context,
|
||||
wsi->active_extensions[n], wsi,
|
||||
r, wsi->act_ext_user[n], v, len);
|
||||
handled |= wsi->ws->active_extensions[n]->callback(context,
|
||||
wsi->ws->active_extensions[n], wsi,
|
||||
r, wsi->ws->act_ext_user[n], v, len);
|
||||
}
|
||||
|
||||
return handled;
|
||||
|
@ -325,12 +331,15 @@ lws_set_extension_option(struct lws *wsi, const char *ext_name,
|
|||
struct lws_ext_option_arg oa;
|
||||
int idx = 0;
|
||||
|
||||
if (!wsi->ws)
|
||||
return 0;
|
||||
|
||||
/* first identify if the ext is active on this wsi */
|
||||
while (idx < wsi->count_act_ext &&
|
||||
strcmp(wsi->active_extensions[idx]->name, ext_name))
|
||||
while (idx < wsi->ws->count_act_ext &&
|
||||
strcmp(wsi->ws->active_extensions[idx]->name, ext_name))
|
||||
idx++;
|
||||
|
||||
if (idx == wsi->count_act_ext)
|
||||
if (idx == wsi->ws->count_act_ext)
|
||||
return -1; /* request ext not active on this wsi */
|
||||
|
||||
oa.option_name = opt_name;
|
||||
|
@ -338,7 +347,7 @@ lws_set_extension_option(struct lws *wsi, const char *ext_name,
|
|||
oa.start = opt_val;
|
||||
oa.len = 0;
|
||||
|
||||
return wsi->active_extensions[idx]->callback(
|
||||
wsi->context, wsi->active_extensions[idx], wsi,
|
||||
LWS_EXT_CB_NAMED_OPTION_SET, wsi->act_ext_user[idx], &oa, 0);
|
||||
return wsi->ws->active_extensions[idx]->callback(
|
||||
wsi->context, wsi->ws->active_extensions[idx], wsi,
|
||||
LWS_EXT_CB_NAMED_OPTION_SET, wsi->ws->act_ext_user[idx], &oa, 0);
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ handle_first:
|
|||
if (wsi->ws->rsv &&
|
||||
(
|
||||
#if !defined(LWS_WITHOUT_EXTENSIONS)
|
||||
!wsi->count_act_ext ||
|
||||
!wsi->ws->count_act_ext ||
|
||||
#endif
|
||||
(wsi->ws->rsv & ~0x40))) {
|
||||
lws_close_reason(wsi, LWS_CLOSE_STATUS_PROTOCOL_ERR,
|
||||
|
@ -859,7 +859,7 @@ lws_is_ws_with_ext(struct lws *wsi)
|
|||
#if defined(LWS_WITHOUT_EXTENSIONS)
|
||||
return 0;
|
||||
#else
|
||||
return lwsi_role_ws(wsi) && !!wsi->count_act_ext;
|
||||
return lwsi_role_ws(wsi) && !!wsi->ws->count_act_ext;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1268,7 +1268,7 @@ int rops_handle_POLLOUT_ws(struct lws *wsi)
|
|||
/* Priority 6: extensions
|
||||
*/
|
||||
#if !defined(LWS_WITHOUT_EXTENSIONS)
|
||||
if (!wsi->extension_data_pending)
|
||||
if (!wsi->ws->extension_data_pending)
|
||||
return LWS_HP_RET_USER_SERVICE;
|
||||
|
||||
/*
|
||||
|
@ -1353,7 +1353,7 @@ int rops_handle_POLLOUT_ws(struct lws *wsi)
|
|||
return LWS_HP_RET_BAIL_OK;
|
||||
}
|
||||
|
||||
wsi->extension_data_pending = 0;
|
||||
wsi->ws->extension_data_pending = 0;
|
||||
#endif
|
||||
|
||||
return LWS_HP_RET_USER_SERVICE;
|
||||
|
|
|
@ -73,8 +73,18 @@ enum lws_websocket_opcodes_07 {
|
|||
#define ALREADY_PROCESSED_IGNORE_CHAR 1
|
||||
#define ALREADY_PROCESSED_NO_CB 2
|
||||
|
||||
struct lws_vhost_role_ws {
|
||||
#if !defined(LWS_WITHOUT_EXTENSIONS)
|
||||
const struct lws_extension *extensions;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct _lws_websocket_related {
|
||||
char *rx_ubuf;
|
||||
#if !defined(LWS_WITHOUT_EXTENSIONS)
|
||||
const struct lws_extension *active_extensions[LWS_MAX_EXTENSIONS_ACTIVE];
|
||||
void *act_ext_user[LWS_MAX_EXTENSIONS_ACTIVE];
|
||||
#endif
|
||||
struct lws *rx_draining_ext_list;
|
||||
struct lws *tx_draining_ext_list;
|
||||
/* Also used for close content... control opcode == < 128 */
|
||||
|
@ -117,6 +127,11 @@ struct _lws_websocket_related {
|
|||
unsigned int send_check_ping:1;
|
||||
unsigned int first_fragment:1;
|
||||
unsigned int peer_has_sent_close:1;
|
||||
#if !defined(LWS_WITHOUT_EXTENSIONS)
|
||||
unsigned int extension_data_pending:1;
|
||||
|
||||
uint8_t count_act_ext;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !defined(LWS_WITHOUT_EXTENSIONS)
|
||||
|
|
|
@ -56,7 +56,7 @@ lws_extension_server_handshake(struct lws *wsi, char **p, int budget)
|
|||
|
||||
c = (char *)pt->serv_buf;
|
||||
lwsl_parser("WSI_TOKEN_EXTENSIONS = '%s'\n", c);
|
||||
wsi->count_act_ext = 0;
|
||||
wsi->ws->count_act_ext = 0;
|
||||
ignore = 0;
|
||||
n = 0;
|
||||
args = NULL;
|
||||
|
@ -109,7 +109,7 @@ lws_extension_server_handshake(struct lws *wsi, char **p, int budget)
|
|||
|
||||
/* check a client's extension against our support */
|
||||
|
||||
ext = wsi->vhost->extensions;
|
||||
ext = wsi->vhost->ws.extensions;
|
||||
|
||||
while (ext && ext->callback) {
|
||||
|
||||
|
@ -122,8 +122,8 @@ lws_extension_server_handshake(struct lws *wsi, char **p, int budget)
|
|||
* oh, we do support this one he asked for... but let's
|
||||
* confirm he only gave it once
|
||||
*/
|
||||
for (m = 0; m < wsi->count_act_ext; m++)
|
||||
if (wsi->active_extensions[m] == ext) {
|
||||
for (m = 0; m < wsi->ws->count_act_ext; m++)
|
||||
if (wsi->ws->active_extensions[m] == ext) {
|
||||
lwsl_info("extension mentioned twice\n");
|
||||
return 1; /* shenanigans */
|
||||
}
|
||||
|
@ -152,14 +152,14 @@ lws_extension_server_handshake(struct lws *wsi, char **p, int budget)
|
|||
|
||||
/* instantiate the extension on this conn */
|
||||
|
||||
wsi->active_extensions[wsi->count_act_ext] = ext;
|
||||
wsi->ws->active_extensions[wsi->ws->count_act_ext] = ext;
|
||||
|
||||
/* allow him to construct his context */
|
||||
|
||||
if (ext->callback(lws_get_context(wsi), ext, wsi,
|
||||
LWS_EXT_CB_CONSTRUCT,
|
||||
(void *)&wsi->act_ext_user[
|
||||
wsi->count_act_ext],
|
||||
(void *)&wsi->ws->act_ext_user[
|
||||
wsi->ws->count_act_ext],
|
||||
(void *)&opts, 0)) {
|
||||
lwsl_info("ext %s failed construction\n",
|
||||
ext_name);
|
||||
|
@ -211,8 +211,8 @@ lws_extension_server_handshake(struct lws *wsi, char **p, int budget)
|
|||
if (!ext->callback(lws_get_context(wsi),
|
||||
ext, wsi,
|
||||
LWS_EXT_CB_OPTION_SET,
|
||||
wsi->act_ext_user[
|
||||
wsi->count_act_ext],
|
||||
wsi->ws->act_ext_user[
|
||||
wsi->ws->count_act_ext],
|
||||
&oa, (end - *p))) {
|
||||
|
||||
*p += lws_snprintf(*p, (end - *p),
|
||||
|
@ -229,8 +229,8 @@ lws_extension_server_handshake(struct lws *wsi, char **p, int budget)
|
|||
args++;
|
||||
}
|
||||
|
||||
wsi->count_act_ext++;
|
||||
lwsl_parser("cnt_act_ext <- %d\n", wsi->count_act_ext);
|
||||
wsi->ws->count_act_ext++;
|
||||
lwsl_parser("cnt_act_ext <- %d\n", wsi->ws->count_act_ext);
|
||||
|
||||
if (args && *args == ',')
|
||||
more = 0;
|
||||
|
@ -583,7 +583,7 @@ lws_ws_frame_rest_is_payload(struct lws *wsi, uint8_t **buf, size_t len)
|
|||
*/
|
||||
|
||||
#if !defined(LWS_WITHOUT_EXTENSIONS)
|
||||
if (!wsi->count_act_ext)
|
||||
if (!wsi->ws->count_act_ext)
|
||||
#endif
|
||||
{
|
||||
if (wsi->protocol->rx_buffer_size)
|
||||
|
@ -675,7 +675,7 @@ lws_ws_frame_rest_is_payload(struct lws *wsi, uint8_t **buf, size_t len)
|
|||
|
||||
if (!ebuf.len && /* zero-length inflation output */
|
||||
!n && /* nothing left to drain from the inflator */
|
||||
wsi->count_act_ext && /* we are using pmd */
|
||||
wsi->ws->count_act_ext && /* we are using pmd */
|
||||
old_packet_length && /* we gave the inflator new input */
|
||||
!wsi->ws->rx_packet_length && /* raw ws packet payload all gone */
|
||||
wsi->ws->final && /* the raw ws packet is a FIN guy */
|
||||
|
|
Loading…
Add table
Reference in a new issue