libwebsockets
Lightweight C library for HTML5 websockets
lws-ws-ext.h
1 /*
2  * libwebsockets - small server side websockets and web server implementation
3  *
4  * Copyright (C) 2010 - 2019 Andy Green <andy@warmcat.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22  * IN THE SOFTWARE.
23  */
24 
33 
35 /*
36  * NOTE: These public enums are part of the abi. If you want to add one,
37  * add it at where specified so existing users are unaffected.
38  */
39 enum lws_extension_callback_reasons {
40  LWS_EXT_CB_CONSTRUCT = 4,
41  LWS_EXT_CB_CLIENT_CONSTRUCT = 5,
42  LWS_EXT_CB_DESTROY = 8,
43  LWS_EXT_CB_PACKET_TX_PRESEND = 12,
44  LWS_EXT_CB_PAYLOAD_TX = 21,
45  LWS_EXT_CB_PAYLOAD_RX = 22,
46  LWS_EXT_CB_OPTION_DEFAULT = 23,
47  LWS_EXT_CB_OPTION_SET = 24,
48  LWS_EXT_CB_OPTION_CONFIRM = 25,
49  LWS_EXT_CB_NAMED_OPTION_SET = 26,
50 
51  /****** add new things just above ---^ ******/
52 };
53 
60  /* Add new things just above here ---^
61  * This is part of the ABI, don't needlessly break compatibility */
62 };
63 
69  const char *name;
72  /* Add new things just above here ---^
73  * This is part of the ABI, don't needlessly break compatibility */
74 };
75 
78  const char *option_name;
80  const char *start;
81  int len;
82 };
83 
132 typedef int
133 lws_extension_callback_function(struct lws_context *context,
134  const struct lws_extension *ext, struct lws *wsi,
135  enum lws_extension_callback_reasons reason,
136  void *user, void *in, size_t len);
137 
140  const char *name;
142  const char *client_offer;
144  /* Add new things just above here ---^
145  * This is part of the ABI, don't needlessly break compatibility */
146 };
147 
156 LWS_VISIBLE LWS_EXTERN int
157 lws_set_extension_option(struct lws *wsi, const char *ext_name,
158  const char *opt_name, const char *opt_val);
159 
170 LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT
171 lws_ext_parse_options(const struct lws_extension *ext, struct lws *wsi,
172  void *ext_user, const struct lws_ext_options *opts,
173  const char *o, int len);
174 
187 LWS_EXTERN int
188 lws_extension_callback_pm_deflate(struct lws_context *context,
189  const struct lws_extension *ext,
190  struct lws *wsi,
191  enum lws_extension_callback_reasons reason,
192  void *user, void *in, size_t len);
193 
194 /*
195  * The internal exts are part of the public abi
196  * If we add more extensions, publish the callback here ------v
197  */
Definition: lws-ws-ext.h:58
Definition: lws-ws-ext.h:56
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)
int lws_extension_callback_function(struct lws_context *context, const struct lws_extension *ext, struct lws *wsi, enum lws_extension_callback_reasons reason, void *user, void *in, size_t len)
Definition: lws-ws-ext.h:133
int len
Definition: lws-ws-ext.h:81
const char * option_name
Definition: lws-ws-ext.h:78
Definition: lws-ws-ext.h:57
Definition: lws-ws-ext.h:139
int option_index
Definition: lws-ws-ext.h:79
lws_ext_options_types
Definition: lws-ws-ext.h:55
const char * start
Definition: lws-ws-ext.h:80
LWS_VISIBLE LWS_EXTERN int lws_set_extension_option(struct lws *wsi, const char *ext_name, const char *opt_name, const char *opt_val)
Definition: lws-ws-ext.h:68
Definition: lws-ws-ext.h:77
const char * client_offer
Definition: lws-ws-ext.h:142
const char * name
Definition: lws-ws-ext.h:69
const char * name
Definition: lws-ws-ext.h:140
lws_extension_callback_function * callback
Definition: lws-ws-ext.h:141
LWS_EXTERN int lws_extension_callback_pm_deflate(struct lws_context *context, const struct lws_extension *ext, struct lws *wsi, enum lws_extension_callback_reasons reason, void *user, void *in, size_t len)
enum lws_ext_options_types type
Definition: lws-ws-ext.h:70