diff --git a/lib/extension-deflate-stream.c b/lib/extension-deflate-stream.c index 7ea7c049..9b7b1920 100644 --- a/lib/extension-deflate-stream.c +++ b/lib/extension-deflate-stream.c @@ -7,7 +7,9 @@ int lws_extension_callback_deflate_stream( - struct libwebsocket_context *context, struct libwebsocket *wsi, + struct libwebsocket_context *context, + struct libwebsocket_extension *ext, + struct libwebsocket *wsi, enum libwebsocket_extension_callback_reasons reason, void *user, void *in, size_t len) { diff --git a/lib/extension-deflate-stream.h b/lib/extension-deflate-stream.h index ff43b47a..a8187bc3 100644 --- a/lib/extension-deflate-stream.h +++ b/lib/extension-deflate-stream.h @@ -11,7 +11,8 @@ struct lws_ext_deflate_stream_conn { }; extern int lws_extension_callback_deflate_stream( - struct libwebsocket_context *context, - struct libwebsocket *wsi, - enum libwebsocket_extension_callback_reasons reason, + struct libwebsocket_context *context, + struct libwebsocket_extension *ext, + struct libwebsocket *wsi, + enum libwebsocket_extension_callback_reasons reason, void *user, void *in, size_t len); diff --git a/lib/handshake.c b/lib/handshake.c index e89bd016..bac5f7f4 100644 --- a/lib/handshake.c +++ b/lib/handshake.c @@ -435,7 +435,8 @@ handshake_0405(struct libwebsocket *wsi) /* allow him to construct his context */ ext->callback(wsi->protocol->owning_server, - wsi, LWS_EXT_CALLBACK_CONSTRUCT, + ext, wsi, + LWS_EXT_CALLBACK_CONSTRUCT, wsi->active_extensions_user[ wsi->count_active_extensions], NULL, 0); diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 717f6c02..6a0ef37f 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -182,7 +182,8 @@ libwebsocket_close_and_free_session(struct libwebsocket_context *context, for (n = 0; n < wsi->count_active_extensions; n++) { m = wsi->active_extensions[n]->callback( - wsi->protocol->owning_server, wsi, + wsi->protocol->owning_server, + wsi->active_extensions[n], wsi, LWS_EXT_CALLBACK_FLUSH_PENDING_TX, wsi->active_extensions_user[n], &eff_buf, 0); if (m < 0) { @@ -285,9 +286,10 @@ just_kill_connection: if (!wsi->active_extensions[n]->callback) continue; - wsi->active_extensions[n]->callback(context, wsi, - LWS_EXT_CALLBACK_DESTROY, - wsi->active_extensions_user[n], NULL, 0); + wsi->active_extensions[n]->callback(context, + wsi->active_extensions[n], wsi, + LWS_EXT_CALLBACK_DESTROY, + wsi->active_extensions_user[n], NULL, 0); free(wsi->active_extensions_user[n]); } @@ -539,7 +541,8 @@ lws_handle_POLLOUT_event(struct libwebsocket_context *context, for (n = 0; n < wsi->count_active_extensions; n++) { m = wsi->active_extensions[n]->callback( - wsi->protocol->owning_server, wsi, + wsi->protocol->owning_server, + wsi->active_extensions[n], wsi, LWS_EXT_CALLBACK_PACKET_TX_PRESEND, wsi->active_extensions_user[n], &eff_buf, 0); if (m < 0) { @@ -1586,9 +1589,11 @@ select_protocol: /* allow him to construct his context */ ext->callback(wsi->protocol->owning_server, - wsi, LWS_EXT_CALLBACK_CLIENT_CONSTRUCT, + ext, wsi, + LWS_EXT_CALLBACK_CLIENT_CONSTRUCT, wsi->active_extensions_user[ - wsi->count_active_extensions], NULL, 0); + wsi->count_active_extensions], + NULL, 0); wsi->count_active_extensions++; @@ -1764,9 +1769,11 @@ bail2: more = 0; for (n = 0; n < wsi->count_active_extensions; n++) { - m = wsi->active_extensions[n]->callback(context, wsi, + m = wsi->active_extensions[n]->callback(context, + wsi->active_extensions[n], wsi, LWS_EXT_CALLBACK_PACKET_RX_PREPARSE, - wsi->active_extensions_user[n], &eff_buf, 0); + wsi->active_extensions_user[n], + &eff_buf, 0); if (m < 0) { fprintf(stderr, "Extension reports fatal error\n"); libwebsocket_close_and_free_session(context, wsi, diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h index bb3444f3..c247c3a7 100644 --- a/lib/libwebsockets.h +++ b/lib/libwebsockets.h @@ -192,6 +192,7 @@ enum lws_close_status { struct libwebsocket; struct libwebsocket_context; +struct libwebsocket_extension; /* document the generic callback (it's a fake prototype under this) */ /** @@ -394,6 +395,7 @@ extern int callback(struct libwebsocket_context * context, /** * extension_callback() - Hooks to allow extensions to operate * @context: Websockets context + * @ext: This extension * @wsi: Opaque websocket instance pointer * @reason: The reason for the call * @user: Pointer to per-session user data allocated by library @@ -450,6 +452,7 @@ extern int callback(struct libwebsocket_context * context, */ extern int extension_callback(struct libwebsocket_context * context, + struct libwebsocket_extension *ext, struct libwebsocket *wsi, enum libwebsocket_callback_reasons reason, void *user, void *in, size_t len); @@ -515,6 +518,7 @@ struct libwebsocket_protocols { struct libwebsocket_extension { const char *name; int (*callback)(struct libwebsocket_context *context, + struct libwebsocket_extension *ext, struct libwebsocket *wsi, enum libwebsocket_extension_callback_reasons reason, void *user, void *in, size_t len); diff --git a/lib/parsers.c b/lib/parsers.c index 5b7a3bd2..7e1e900b 100644 --- a/lib/parsers.c +++ b/lib/parsers.c @@ -1379,7 +1379,8 @@ send_raw: for (n = 0; n < wsi->count_active_extensions; n++) { m = wsi->active_extensions[n]->callback( - wsi->protocol->owning_server, wsi, + wsi->protocol->owning_server, + wsi->active_extensions[n], wsi, LWS_EXT_CALLBACK_PACKET_TX_PRESEND, wsi->active_extensions_user[n], &eff_buf, 0); if (m < 0) { diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h index 2a11c114..edaeaa9c 100644 --- a/lib/private-libwebsockets.h +++ b/lib/private-libwebsockets.h @@ -228,7 +228,7 @@ enum pending_timeout { struct libwebsocket { const struct libwebsocket_protocols *protocol; - const struct libwebsocket_extension * + struct libwebsocket_extension * active_extensions[LWS_MAX_EXTENSIONS_ACTIVE]; void * active_extensions_user[LWS_MAX_EXTENSIONS_ACTIVE]; int count_active_extensions; diff --git a/libwebsockets-api-doc.html b/libwebsockets-api-doc.html index 80e8504c..bc0ce48b 100644 --- a/libwebsockets-api-doc.html +++ b/libwebsockets-api-doc.html @@ -728,6 +728,7 @@ internal polling loop, you can just ignore it. int extension_callback (struct libwebsocket_context * context, +struct libwebsocket_extension * ext, struct libwebsocket * wsi, enum libwebsocket_callback_reasons reason, void * user, @@ -737,6 +738,8 @@ internal polling loop, you can just ignore it.