2 * libwebsockets - small server side websockets and web server implementation
4 * Copyright (C) 2010 Andy Green <andy@warmcat.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation:
9 * version 2.1 of the License.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 #ifndef __LIBWEBSOCKET_H__
23 #define __LIBWEBSOCKET_H__
31 #ifndef WIN32_LEAN_AND_MEAN
32 #define WIN32_LEAN_AND_MEAN
36 #include "websock-w32.h"
38 #include "gettimeofday.h"
40 #define strcasecmp stricmp
44 #define LWS_EXTERN extern __declspec(dllexport)
46 #define LWS_EXTERN extern __declspec(dllimport)
55 #define LWS_EXTERN extern
58 #define CONTEXT_PORT_NO_LISTEN 0
59 #define MAX_MUX_RECURSION 2
61 enum libwebsocket_context_options {
62 LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK = 1,
63 LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT = 2,
66 enum libwebsocket_callback_reasons {
67 LWS_CALLBACK_ESTABLISHED,
68 LWS_CALLBACK_CLIENT_ESTABLISHED,
71 LWS_CALLBACK_CLIENT_RECEIVE,
72 LWS_CALLBACK_CLIENT_RECEIVE_PONG,
73 LWS_CALLBACK_CLIENT_WRITEABLE,
74 LWS_CALLBACK_SERVER_WRITEABLE,
76 LWS_CALLBACK_BROADCAST,
77 LWS_CALLBACK_FILTER_NETWORK_CONNECTION,
78 LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION,
79 LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS,
80 LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS,
81 LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION,
82 LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER,
83 LWS_CALLBACK_CONFIRM_EXTENSION_OKAY,
84 LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED,
85 /* external poll() management support */
86 LWS_CALLBACK_ADD_POLL_FD,
87 LWS_CALLBACK_DEL_POLL_FD,
88 LWS_CALLBACK_SET_MODE_POLL_FD,
89 LWS_CALLBACK_CLEAR_MODE_POLL_FD,
92 enum libwebsocket_extension_callback_reasons {
93 LWS_EXT_CALLBACK_SERVER_CONTEXT_CONSTRUCT,
94 LWS_EXT_CALLBACK_CLIENT_CONTEXT_CONSTRUCT,
95 LWS_EXT_CALLBACK_SERVER_CONTEXT_DESTRUCT,
96 LWS_EXT_CALLBACK_CLIENT_CONTEXT_DESTRUCT,
97 LWS_EXT_CALLBACK_CONSTRUCT,
98 LWS_EXT_CALLBACK_CLIENT_CONSTRUCT,
99 LWS_EXT_CALLBACK_CHECK_OK_TO_REALLY_CLOSE,
100 LWS_EXT_CALLBACK_CHECK_OK_TO_PROPOSE_EXTENSION,
101 LWS_EXT_CALLBACK_DESTROY,
102 LWS_EXT_CALLBACK_DESTROY_ANY_WSI_CLOSING,
103 LWS_EXT_CALLBACK_ANY_WSI_ESTABLISHED,
104 LWS_EXT_CALLBACK_PACKET_RX_PREPARSE,
105 LWS_EXT_CALLBACK_PACKET_TX_PRESEND,
106 LWS_EXT_CALLBACK_PACKET_TX_DO_SEND,
107 LWS_EXT_CALLBACK_HANDSHAKE_REPLY_TX,
108 LWS_EXT_CALLBACK_FLUSH_PENDING_TX,
109 LWS_EXT_CALLBACK_EXTENDED_PAYLOAD_RX,
110 LWS_EXT_CALLBACK_CAN_PROXY_CLIENT_CONNECTION,
111 LWS_EXT_CALLBACK_1HZ,
112 LWS_EXT_CALLBACK_REQUEST_ON_WRITEABLE,
113 LWS_EXT_CALLBACK_IS_WRITEABLE,
116 enum libwebsocket_write_protocol {
119 LWS_WRITE_CONTINUATION,
122 /* special 04+ opcodes */
130 LWS_WRITE_NO_FIN = 0x40,
132 * client packet payload goes out on wire unmunged
133 * only useful for security tests since normal servers cannot
134 * decode the content if used
136 LWS_WRITE_CLIENT_IGNORE_XOR_MASK = 0x80
140 * you need these to look at headers that have been parsed if using the
141 * LWS_CALLBACK_FILTER_CONNECTION callback. If a header from the enum
142 * list below is absent, .token = NULL and token_len = 0. Otherwise .token
143 * points to .token_len chars containing that header content.
151 enum lws_token_indexes {
154 WSI_TOKEN_CONNECTION,
169 WSI_TOKEN_EXTENSIONS,
171 /* client receives these */
177 /* always last real token index*/
179 /* parser state additions */
182 WSI_TOKEN_SKIPPING_SAW_CR,
183 WSI_PARSING_COMPLETE,
184 WSI_INIT_TOKEN_MUXURL,
191 1000 indicates a normal closure, meaning whatever purpose the
192 connection was established for has been fulfilled.
196 1001 indicates that an endpoint is "going away", such as a server
197 going down, or a browser having navigated away from a page.
201 1002 indicates that an endpoint is terminating the connection due
206 1003 indicates that an endpoint is terminating the connection
207 because it has received a type of data it cannot accept (e.g. an
208 endpoint that understands only text data may send this if it
209 receives a binary message.)
213 1004 indicates that an endpoint is terminating the connection
214 because it has received a message that is too large.
217 enum lws_close_status {
218 LWS_CLOSE_STATUS_NOSTATUS = 0,
219 LWS_CLOSE_STATUS_NORMAL = 1000,
220 LWS_CLOSE_STATUS_GOINGAWAY = 1001,
221 LWS_CLOSE_STATUS_PROTOCOL_ERR = 1002,
222 LWS_CLOSE_STATUS_UNACCEPTABLE_OPCODE = 1003,
223 LWS_CLOSE_STATUS_PAYLOAD_TOO_LARGE = 1004,
227 struct libwebsocket_context;
228 struct libwebsocket_extension;
230 /* document the generic callback (it's a fake prototype under this) */
232 * callback() - User server actions
233 * @context: Websockets context
234 * @wsi: Opaque websocket instance pointer
235 * @reason: The reason for the call
236 * @user: Pointer to per-session user data allocated by library
237 * @in: Pointer used for some callback reasons
238 * @len: Length set for some callback reasons
240 * This callback is the way the user controls what is served. All the
241 * protocol detail is hidden and handled by the library.
243 * For each connection / session there is user data allocated that is
244 * pointed to by "user". You set the size of this user data area when
245 * the library is initialized with libwebsocket_create_server.
247 * You get an opportunity to initialize user data when called back with
248 * LWS_CALLBACK_ESTABLISHED reason.
250 * LWS_CALLBACK_ESTABLISHED: after the server completes a handshake with
253 * LWS_CALLBACK_CLIENT_ESTABLISHED: after your client connection completed
254 * a handshake with the remote server
256 * LWS_CALLBACK_CLOSED: when the websocket session ends
258 * LWS_CALLBACK_BROADCAST: signal to send to client (you would use
259 * libwebsocket_write() taking care about the
260 * special buffer requirements
262 * LWS_CALLBACK_RECEIVE: data has appeared for this server endpoint from a
263 * remote client, it can be found at *in and is
266 * LWS_CALLBACK_CLIENT_RECEIVE_PONG: if you elected to see PONG packets,
267 * they appear with this callback reason. PONG
268 * packets only exist in 04+ protocol
270 * LWS_CALLBACK_CLIENT_RECEIVE: data has appeared from the server for the
271 * client connection, it can be found at *in and
274 * LWS_CALLBACK_HTTP: an http request has come from a client that is not
275 * asking to upgrade the connection to a websocket
276 * one. This is a chance to serve http content,
277 * for example, to send a script to the client
278 * which will then open the websockets connection.
279 * @in points to the URI path requested and
280 * libwebsockets_serve_http_file() makes it very
281 * simple to send back a file to the client.
283 * LWS_CALLBACK_CLIENT_WRITEABLE:
284 * LWS_CALLBACK_SERVER_WRITEABLE: If you call
285 * libwebsocket_callback_on_writable() on a connection, you will
286 * get one of these callbacks coming when the connection socket
287 * is able to accept another write packet without blocking.
288 * If it already was able to take another packet without blocking,
289 * you'll get this callback at the next call to the service loop
290 * function. Notice that CLIENTs get LWS_CALLBACK_CLIENT_WRITEABLE
291 * and servers get LWS_CALLBACK_SERVER_WRITEABLE.
293 * LWS_CALLBACK_FILTER_NETWORK_CONNECTION: called when a client connects to
294 * the server at network level; the connection is accepted but then
295 * passed to this callback to decide whether to hang up immediately
296 * or not, based on the client IP. @user contains the connection
297 * socket's descriptor. Return non-zero to terminate
298 * the connection before sending or receiving anything.
299 * Because this happens immediately after the network connection
300 * from the client, there's no websocket protocol selected yet so
301 * this callback is issued only to protocol 0.
303 * LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION: called when the handshake has
304 * been received and parsed from the client, but the response is
305 * not sent yet. Return non-zero to disallow the connection.
306 * @user is a pointer to an array of struct lws_tokens, you can
307 * use the header enums lws_token_indexes from libwebsockets.h
308 * to check for and read the supported header presence and
309 * content before deciding to allow the handshake to proceed or
310 * to kill the connection.
312 * LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS: if configured for
313 * including OpenSSL support, this callback allows your user code
314 * to perform extra SSL_CTX_load_verify_locations() or similar
315 * calls to direct OpenSSL where to find certificates the client
316 * can use to confirm the remote server identity. @user is the
319 * LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS: if configured for
320 * including OpenSSL support, this callback allows your user code
321 * to load extra certifcates into the server which allow it to
322 * verify the validity of certificates returned by clients. @user
323 * is the server's OpenSSL SSL_CTX*
325 * LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION: if the
326 * libwebsockets context was created with the option
327 * LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT, then this
328 * callback is generated during OpenSSL verification of the cert
329 * sent from the client. It is sent to protocol[0] callback as
330 * no protocol has been negotiated on the connection yet.
331 * Notice that the libwebsockets context and wsi are both NULL
332 * during this callback. See
333 * http://www.openssl.org/docs/ssl/SSL_CTX_set_verify.html
334 * to understand more detail about the OpenSSL callback that
335 * generates this libwebsockets callback and the meanings of the
336 * arguments passed. In this callback, @user is the x509_ctx,
337 * @in is the ssl pointer and @len is preverify_ok
338 * Notice that this callback maintains libwebsocket return
339 * conventions, return 0 to mean the cert is OK or 1 to fail it.
340 * This also means that if you don't handle this callback then
341 * the default callback action of returning 0 allows the client
344 * LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER: this callback happens
345 * when a client handshake is being compiled. @user is NULL,
346 * @in is a char **, it's pointing to a char * which holds the
347 * next location in the header buffer where you can add
348 * headers, and @len is the remaining space in the header buffer,
349 * which is typically some hundreds of bytes. So, to add a canned
350 * cookie, your handler code might look similar to:
352 * char **p = (char **)in;
357 * *p += sprintf(*p, "Cookie: a=b\x0d\x0a");
361 * Notice if you add anything, you just have to take care about
362 * the CRLF on the line you added. Obviously this callback is
363 * optional, if you don't handle it everything is fine.
365 * Notice the callback is coming to protocols[0] all the time,
366 * because there is no specific protocol handshook yet.
368 * LWS_CALLBACK_CONFIRM_EXTENSION_OKAY: When the server handshake code
369 * sees that it does support a requested extension, before
370 * accepting the extension by additing to the list sent back to
371 * the client it gives this callback just to check that it's okay
372 * to use that extension. It calls back to the requested protocol
373 * and with @in being the extension name, @len is 0 and @user is
374 * valid. Note though at this time the ESTABLISHED callback hasn't
375 * happened yet so if you initialize @user content there, @user
376 * content during this callback might not be useful for anything.
377 * Notice this callback comes to protocols[0].
379 * LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED: When a client
380 * connection is being prepared to start a handshake to a server,
381 * each supported extension is checked with protocols[0] callback
382 * with this reason, giving the user code a chance to suppress the
383 * claim to support that extension by returning non-zero. If
384 * unhandled, by default 0 will be returned and the extension
385 * support included in the header to the server. Notice this
386 * callback comes to protocols[0].
388 * The next four reasons are optional and only need taking care of if you
389 * will be integrating libwebsockets sockets into an external polling
392 * LWS_CALLBACK_ADD_POLL_FD: libwebsocket deals with its poll() loop
393 * internally, but in the case you are integrating with another
394 * server you will need to have libwebsocket sockets share a
395 * polling array with the other server. This and the other
396 * POLL_FD related callbacks let you put your specialized
397 * poll array interface code in the callback for protocol 0, the
398 * first protocol you support, usually the HTTP protocol in the
399 * serving case. This callback happens when a socket needs to be
400 * added to the polling loop: @user contains the fd, and
401 * @len is the events bitmap (like, POLLIN). If you are using the
402 * internal polling loop (the "service" callback), you can just
403 * ignore these callbacks.
405 * LWS_CALLBACK_DEL_POLL_FD: This callback happens when a socket descriptor
406 * needs to be removed from an external polling array. @user is
407 * the socket desricptor. If you are using the internal polling
408 * loop, you can just ignore it.
410 * LWS_CALLBACK_SET_MODE_POLL_FD: This callback happens when libwebsockets
411 * wants to modify the events for the socket descriptor in @user.
412 * The handler should OR @len on to the events member of the pollfd
413 * struct for this socket descriptor. If you are using the
414 * internal polling loop, you can just ignore it.
416 * LWS_CALLBACK_CLEAR_MODE_POLL_FD: This callback occurs when libwebsockets
417 * wants to modify the events for the socket descriptor in @user.
418 * The handler should AND ~@len on to the events member of the
419 * pollfd struct for this socket descriptor. If you are using the
420 * internal polling loop, you can just ignore it.
422 LWS_EXTERN int callback(struct libwebsocket_context * context,
423 struct libwebsocket *wsi,
424 enum libwebsocket_callback_reasons reason, void *user,
425 void *in, size_t len);
427 /* document the generic extension callback (it's a fake prototype under this) */
429 * extension_callback() - Hooks to allow extensions to operate
430 * @context: Websockets context
431 * @ext: This extension
432 * @wsi: Opaque websocket instance pointer
433 * @reason: The reason for the call
434 * @user: Pointer to per-session user data allocated by library
435 * @in: Pointer used for some callback reasons
436 * @len: Length set for some callback reasons
438 * Each extension that is active on a particular connection receives
439 * callbacks during the connection lifetime to allow the extension to
440 * operate on websocket data and manage itself.
442 * Libwebsockets takes care of allocating and freeing "user" memory for
443 * each active extension on each connection. That is what is pointed to
444 * by the @user parameter.
446 * LWS_EXT_CALLBACK_CONSTRUCT: called when the server has decided to
447 * select this extension from the list provided by the client,
448 * just before the server will send back the handshake accepting
449 * the connection with this extension active. This gives the
450 * extension a chance to initialize its connection context found
453 * LWS_EXT_CALLBACK_CLIENT_CONSTRUCT: same as LWS_EXT_CALLBACK_CONSTRUCT
454 * but called when client is instantiating this extension. Some
455 * extensions will work the same on client and server side and then
456 * you can just merge handlers for both CONSTRUCTS.
458 * LWS_EXT_CALLBACK_DESTROY: called when the connection the extension was
459 * being used on is about to be closed and deallocated. It's the
460 * last chance for the extension to deallocate anything it has
461 * allocated in the user data (pointed to by @user) before the
462 * user data is deleted. This same callback is used whether you
463 * are in client or server instantiation context.
465 * LWS_EXT_CALLBACK_PACKET_RX_PREPARSE: when this extension was active on
466 * a connection, and a packet of data arrived at the connection,
467 * it is passed to this callback to give the extension a chance to
468 * change the data, eg, decompress it. @user is pointing to the
469 * extension's private connection context data, @in is pointing
470 * to an lws_tokens struct, it consists of a char * pointer called
471 * token, and an int called token_len. At entry, these are
472 * set to point to the received buffer and set to the content
473 * length. If the extension will grow the content, it should use
474 * a new buffer allocated in its private user context data and
475 * set the pointed-to lws_tokens members to point to its buffer.
477 * LWS_EXT_CALLBACK_PACKET_TX_PRESEND: this works the same way as
478 * LWS_EXT_CALLBACK_PACKET_RX_PREPARSE above, except it gives the
479 * extension a chance to change websocket data just before it will
480 * be sent out. Using the same lws_token pointer scheme in @in,
481 * the extension can change the buffer and the length to be
482 * transmitted how it likes. Again if it wants to grow the
483 * buffer safely, it should copy the data into its own buffer and
484 * set the lws_tokens token pointer to it.
487 LWS_EXTERN int extension_callback(struct libwebsocket_context * context,
488 struct libwebsocket_extension *ext,
489 struct libwebsocket *wsi,
490 enum libwebsocket_callback_reasons reason, void *user,
491 void *in, size_t len);
495 * struct libwebsocket_protocols - List of protocols and handlers server
497 * @name: Protocol name that must match the one given in the client
498 * Javascript new WebSocket(url, 'protocol') name
499 * @callback: The service callback used for this protocol. It allows the
500 * service action for an entire protocol to be encapsulated in
501 * the protocol-specific callback
502 * @per_session_data_size: Each new connection using this protocol gets
503 * this much memory allocated on connection establishment and
504 * freed on connection takedown. A pointer to this per-connection
505 * allocation is passed into the callback in the 'user' parameter
506 * @owning_server: the server init call fills in this opaque pointer when
507 * registering this protocol with the server.
508 * @broadcast_socket_port: the server init call fills this in with the
509 * localhost port number used to forward broadcasts for this
511 * @broadcast_socket_user_fd: the server init call fills this in ... the main()
512 * process context can write to this socket to perform broadcasts
513 * (use the libwebsockets_broadcast() api to do this instead,
514 * it works from any process context)
515 * @protocol_index: which protocol we are starting from zero
517 * This structure represents one protocol supported by the server. An
518 * array of these structures is passed to libwebsocket_create_server()
519 * allows as many protocols as you like to be handled by one server.
522 struct libwebsocket_protocols {
524 int (*callback)(struct libwebsocket_context * context,
525 struct libwebsocket *wsi,
526 enum libwebsocket_callback_reasons reason, void *user,
527 void *in, size_t len);
528 size_t per_session_data_size;
531 * below are filled in on server init and can be left uninitialized,
532 * no need for user to use them directly either
535 struct libwebsocket_context *owning_server;
536 int broadcast_socket_port;
537 int broadcast_socket_user_fd;
542 * struct libwebsocket_extension - An extension we know how to cope with
544 * @name: Formal extension name, eg, "deflate-stream"
545 * @callback: Service callback
546 * @per_session_data_size: Libwebsockets will auto-malloc this much
547 * memory for the use of the extension, a pointer
548 * to it comes in the @user callback parameter
551 struct libwebsocket_extension {
553 int (*callback)(struct libwebsocket_context *context,
554 struct libwebsocket_extension *ext,
555 struct libwebsocket *wsi,
556 enum libwebsocket_extension_callback_reasons reason,
557 void *user, void *in, size_t len);
558 size_t per_session_data_size;
559 void * per_context_private_data;
564 LWS_EXTERN struct libwebsocket_context *
565 libwebsocket_create_context(int port, const char * interf,
566 struct libwebsocket_protocols *protocols,
567 struct libwebsocket_extension *extensions,
568 const char *ssl_cert_filepath,
569 const char *ssl_private_key_filepath, int gid, int uid,
570 unsigned int options);
573 libwebsocket_context_destroy(struct libwebsocket_context *context);
576 libwebsockets_fork_service_loop(struct libwebsocket_context *context);
579 libwebsocket_service(struct libwebsocket_context *context, int timeout_ms);
582 libwebsocket_service_fd(struct libwebsocket_context *context,
583 struct pollfd *pollfd);
588 * When sending with websocket protocol (LWS_WRITE_TEXT or LWS_WRITE_BINARY)
589 * the send buffer has to have LWS_SEND_BUFFER_PRE_PADDING bytes valid BEFORE
590 * buf, and LWS_SEND_BUFFER_POST_PADDING bytes valid AFTER (buf + len).
592 * This allows us to add protocol info before and after the data, and send as
593 * one packet on the network without payload copying, for maximum efficiency.
595 * So for example you need this kind of code to use libwebsocket_write with a
598 * char buf[LWS_SEND_BUFFER_PRE_PADDING + 128 + LWS_SEND_BUFFER_POST_PADDING];
600 * // fill your part of the buffer... for example here it's all zeros
601 * memset(&buf[LWS_SEND_BUFFER_PRE_PADDING], 0, 128);
603 * libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], 128);
605 * When sending LWS_WRITE_HTTP, there is no protocol addition and you can just
606 * use the whole buffer without taking care of the above.
610 * this is the frame nonce plus two header plus 8 length
611 * there's an additional two for mux extension per mux nesting level
612 * 2 byte prepend on close will already fit because control frames cannot use
613 * the big length style
616 #define LWS_SEND_BUFFER_PRE_PADDING (4 + 10 + (2 * MAX_MUX_RECURSION))
617 #define LWS_SEND_BUFFER_POST_PADDING 1
620 libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf, size_t len,
621 enum libwebsocket_write_protocol protocol);
624 libwebsockets_serve_http_file(struct libwebsocket *wsi, const char *file,
625 const char *content_type);
627 /* notice - you need the pre- and post- padding allocation for buf below */
630 libwebsockets_broadcast(const struct libwebsocket_protocols *protocol,
631 unsigned char *buf, size_t len);
633 LWS_EXTERN const struct libwebsocket_protocols *
634 libwebsockets_get_protocol(struct libwebsocket *wsi);
637 libwebsocket_callback_on_writable(struct libwebsocket_context *context,
638 struct libwebsocket *wsi);
641 libwebsocket_callback_on_writable_all_protocol(
642 const struct libwebsocket_protocols *protocol);
645 libwebsocket_get_socket_fd(struct libwebsocket *wsi);
648 libwebsocket_is_final_fragment(struct libwebsocket *wsi);
651 libwebsocket_rx_flow_control(struct libwebsocket *wsi, int enable);
654 libwebsockets_remaining_packet_payload(struct libwebsocket *wsi);
656 LWS_EXTERN struct libwebsocket *
657 libwebsocket_client_connect(struct libwebsocket_context *clients,
664 const char *protocol,
665 int ietf_version_or_minus_one);
667 LWS_EXTERN const char *
668 libwebsocket_canonical_hostname(struct libwebsocket_context *context);
672 libwebsockets_get_peer_addresses(int fd, char *name, int name_len,
673 char *rip, int rip_len);
676 libwebsockets_hangup_on_client(struct libwebsocket_context *context, int fd);
679 libwebsocket_close_and_free_session(struct libwebsocket_context *context,
680 struct libwebsocket *wsi, enum lws_close_status);
683 libwebsockets_get_random(struct libwebsocket_context *context,
687 lws_send_pipe_choked(struct libwebsocket *wsi);
689 LWS_EXTERN unsigned char *
690 libwebsockets_SHA1(const unsigned char *d, size_t n, unsigned char *md);
693 lws_b64_encode_string(const char *in, int in_len, char *out, int out_size);
696 lws_b64_decode_string(const char *in, char *out, int out_size);
698 LWS_EXTERN struct libwebsocket_extension libwebsocket_internal_extensions[];