pass ext pointer in ext callback

Signed-off-by: Andy Green <andy@warmcat.com>
diff --git a/lib/extension-deflate-stream.c b/lib/extension-deflate-stream.c
index 7ea7c04..9b7b192 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 ff43b47..a8187bc 100644
--- a/lib/extension-deflate-stream.h
+++ b/lib/extension-deflate-stream.h
@@ -11,7 +11,8 @@
 };
 
 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 e89bd01..bac5f7f 100644
--- a/lib/handshake.c
+++ b/lib/handshake.c
@@ -435,7 +435,8 @@
 				/* 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 717f6c0..6a0ef37 100644
--- a/lib/libwebsockets.c
+++ b/lib/libwebsockets.c
@@ -182,7 +182,8 @@
 
 		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 @@
 		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 @@
 
 		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 @@
 				/* 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 @@
 			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 bb3444f..c247c3a 100644
--- a/lib/libwebsockets.h
+++ b/lib/libwebsockets.h
@@ -192,6 +192,7 @@
 
 struct libwebsocket;
 struct libwebsocket_context;
+struct libwebsocket_extension;
 
 /* document the generic callback (it's a fake prototype under this) */
 /**
@@ -394,6 +395,7 @@
 /**
  * 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 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_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 5b7a3bd..7e1e900 100644
--- a/lib/parsers.c
+++ b/lib/parsers.c
@@ -1379,7 +1379,8 @@
 
 		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 2a11c11..edaeaa9 100644
--- a/lib/private-libwebsockets.h
+++ b/lib/private-libwebsockets.h
@@ -228,7 +228,7 @@
 
 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 80e8504..bc0ce48 100644
--- a/libwebsockets-api-doc.html
+++ b/libwebsockets-api-doc.html
@@ -728,6 +728,7 @@
 <i>int</i>
 <b>extension_callback</b>
 (<i>struct libwebsocket_context *</i> <b>context</b>,
+<i>struct libwebsocket_extension *</i> <b>ext</b>,
 <i>struct libwebsocket *</i> <b>wsi</b>,
 <i>enum libwebsocket_callback_reasons</i> <b>reason</b>,
 <i>void *</i> <b>user</b>,
@@ -737,6 +738,8 @@
 <dl>
 <dt><b>context</b>
 <dd>Websockets context
+<dt><b>ext</b>
+<dd>This extension
 <dt><b>wsi</b>
 <dd>Opaque websocket instance pointer
 <dt><b>reason</b>
@@ -858,7 +861,7 @@
 <h2>struct libwebsocket_extension - An extension we know how to cope with</h2>
 <b>struct libwebsocket_extension</b> {<br>
 &nbsp; &nbsp; <i>const char *</i> <b>name</b>;<br>
-&nbsp; &nbsp; <i>int (*</i><b>callback</b>) <i>(struct libwebsocket_context *context,struct libwebsocket *wsi,enum libwebsocket_extension_callback_reasons reason,void *user, void *in, size_t len)</i>;<br>
+&nbsp; &nbsp; <i>int (*</i><b>callback</b>) <i>(struct libwebsocket_context *context,struct libwebsocket_extension *ext,struct libwebsocket *wsi,enum libwebsocket_extension_callback_reasons reason,void *user, void *in, size_t len)</i>;<br>
 &nbsp; &nbsp; <i>size_t</i> <b>per_session_data_size</b>;<br>
 };<br>
 <h3>Members</h3>