2 * libwebsockets - small server side websockets and web server implementation
4 * Copyright (C) 2010 - 2013 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 /* System introspection configs */
24 #include "lws_config.h"
26 #if defined(WIN32) || defined(_WIN32)
27 #define inline __inline
31 #endif /* not WIN32 */
32 #endif /* not CMAKE */
34 #ifdef HAVE_SYS_TYPES_H
35 #include <sys/types.h>
46 #ifdef HAVE_SYS_STAT_H
50 #if defined(WIN32) || defined(_WIN32)
51 #define LWS_NO_DAEMONIZE
52 #define LWS_ERRNO WSAGetLastError()
53 #define LWS_EAGAIN WSAEWOULDBLOCK
54 #define LWS_EALREADY WSAEALREADY
55 #define LWS_EINPROGRESS WSAEINPROGRESS
56 #define LWS_EINTR WSAEINTR
57 #define LWS_EISCONN WSAEISCONN
58 #define LWS_EWOULDBLOCK WSAEWOULDBLOCK
59 #define LWS_POLLHUP (FD_CLOSE)
60 #define LWS_POLLIN (FD_READ | FD_ACCEPT)
61 #define LWS_POLLOUT (FD_WRITE)
62 #define MSG_NOSIGNAL 0
63 #define SHUT_RDWR SD_BOTH
64 #define SOL_TCP IPPROTO_TCP
66 #define compatible_close(fd) closesocket(fd)
67 #define compatible_file_close(fd) CloseHandle(fd)
68 #define compatible_file_seek_cur(fd, offset) SetFilePointer(fd, offset, NULL, FILE_CURRENT)
69 #define compatible_file_read(amount, fd, buf, len) {\
71 if (!ReadFile(fd, buf, len, &_amount, NULL)) \
76 #define lws_set_blocking_send(wsi) wsi->sock_send_blocking = TRUE
86 #define __func__ __FUNCTION__
90 #define vsnprintf _vsnprintf
93 #define LWS_INVALID_FILE INVALID_HANDLE_VALUE
94 #else /* not windows --> */
101 #include <sys/types.h>
102 #include <sys/socket.h>
103 #ifdef LWS_BUILTIN_GETIFADDRS
104 #include <getifaddrs.h>
108 #include <sys/syslog.h>
110 #include <sys/socket.h>
113 #ifdef HAVE_SYS_PRCTL_H
114 #include <sys/prctl.h>
117 #include <netinet/in.h>
118 #include <netinet/tcp.h>
119 #include <arpa/inet.h>
123 #endif /* LWS_USE_LIBEV */
125 #include <sys/mman.h>
126 #include <sys/time.h>
128 #define LWS_ERRNO errno
129 #define LWS_EAGAIN EAGAIN
130 #define LWS_EALREADY EALREADY
131 #define LWS_EINPROGRESS EINPROGRESS
132 #define LWS_EINTR EINTR
133 #define LWS_EISCONN EISCONN
134 #define LWS_EWOULDBLOCK EWOULDBLOCK
135 #define LWS_INVALID_FILE -1
136 #define LWS_POLLHUP (POLLHUP|POLLERR)
137 #define LWS_POLLIN (POLLIN)
138 #define LWS_POLLOUT (POLLOUT)
139 #define compatible_close(fd) close(fd)
140 #define compatible_file_close(fd) close(fd)
141 #define compatible_file_seek_cur(fd, offset) lseek(fd, offset, SEEK_CUR)
142 #define compatible_file_read(amount, fd, buf, len) \
143 amount = read(fd, buf, len);
144 #define lws_set_blocking_send(wsi)
148 #define bzero(b, len) (memset((b), '\0', (len)), (void) 0)
151 #ifndef HAVE_STRERROR
152 #define strerror(x) ""
155 #ifdef LWS_OPENSSL_SUPPORT
157 #include <cyassl/openssl/ssl.h>
158 #include <cyassl/error.h>
160 SHA1(const unsigned char *d, size_t n, unsigned char *md);
162 #include <openssl/ssl.h>
163 #include <openssl/evp.h>
164 #include <openssl/err.h>
165 #include <openssl/md5.h>
166 #include <openssl/sha.h>
167 #endif /* not USE_CYASSL */
170 #include "libwebsockets.h"
172 #if defined(WIN32) || defined(_WIN32)
175 #define BIG_ENDIAN 4321 /* to show byte order (taken from gcc) */
177 #ifndef LITTLE_ENDIAN
178 #define LITTLE_ENDIAN 1234
181 #define BYTE_ORDER LITTLE_ENDIAN
183 typedef unsigned __int64 u_int64_t;
188 #define __P(protos) protos
190 #define __P(protos) ()
196 #include <sys/stat.h>
197 #include <sys/cdefs.h>
198 #include <sys/time.h>
200 #if defined(__APPLE__)
201 #include <machine/endian.h>
202 #elif defined(__FreeBSD__)
203 #include <sys/endian.h>
204 #elif defined(__linux__)
208 #if !defined(BYTE_ORDER)
209 # define BYTE_ORDER __BYTE_ORDER
211 #if !defined(LITTLE_ENDIAN)
212 # define LITTLE_ENDIAN __LITTLE_ENDIAN
214 #if !defined(BIG_ENDIAN)
215 # define BIG_ENDIAN __BIG_ENDIAN
221 * Mac OSX as well as iOS do not define the MSG_NOSIGNAL flag,
222 * but happily have something equivalent in the SO_NOSIGPIPE flag.
225 #define MSG_NOSIGNAL SO_NOSIGPIPE
228 #ifndef LWS_MAX_HEADER_LEN
229 #define LWS_MAX_HEADER_LEN 1024
231 #ifndef LWS_MAX_PROTOCOLS
232 #define LWS_MAX_PROTOCOLS 5
234 #ifndef LWS_MAX_EXTENSIONS_ACTIVE
235 #define LWS_MAX_EXTENSIONS_ACTIVE 3
237 #ifndef SPEC_LATEST_SUPPORTED
238 #define SPEC_LATEST_SUPPORTED 13
240 #ifndef AWAITING_TIMEOUT
241 #define AWAITING_TIMEOUT 5
243 #ifndef CIPHERS_LIST_STRING
244 #define CIPHERS_LIST_STRING "DEFAULT"
246 #ifndef LWS_SOMAXCONN
247 #define LWS_SOMAXCONN SOMAXCONN
250 #define MAX_WEBSOCKET_04_KEY_LEN 128
251 #define LWS_MAX_SOCKET_IO_BUF 4096
253 #ifndef SYSTEM_RANDOM_FILEPATH
254 #define SYSTEM_RANDOM_FILEPATH "/dev/urandom"
256 #ifndef LWS_MAX_ZLIB_CONN_BUFFER
257 #define LWS_MAX_ZLIB_CONN_BUFFER (64 * 1024)
261 * if not in a connection storm, check for incoming
262 * connections this many normal connection services
264 #define LWS_LISTEN_SERVICE_MODULO 10
266 enum lws_websocket_opcodes_07 {
267 LWS_WS_OPCODE_07__CONTINUATION = 0,
268 LWS_WS_OPCODE_07__TEXT_FRAME = 1,
269 LWS_WS_OPCODE_07__BINARY_FRAME = 2,
271 LWS_WS_OPCODE_07__NOSPEC__MUX = 7,
273 /* control extensions 8+ */
275 LWS_WS_OPCODE_07__CLOSE = 8,
276 LWS_WS_OPCODE_07__PING = 9,
277 LWS_WS_OPCODE_07__PONG = 0xa,
281 enum lws_connection_states {
283 WSI_STATE_HTTP_ISSUING_FILE,
284 WSI_STATE_HTTP_HEADERS,
286 WSI_STATE_DEAD_SOCKET,
287 WSI_STATE_ESTABLISHED,
288 WSI_STATE_CLIENT_UNCONNECTED,
289 WSI_STATE_RETURNED_CLOSE_ALREADY,
290 WSI_STATE_AWAITING_CLOSE_ACK,
291 WSI_STATE_FLUSHING_STORED_SEND_BEFORE_CLOSE,
299 enum http_connection_type {
300 HTTP_CONNECTION_CLOSE,
301 HTTP_CONNECTION_KEEP_ALIVE
304 enum lws_rx_parse_state {
307 LWS_RXPS_04_MASK_NONCE_1,
308 LWS_RXPS_04_MASK_NONCE_2,
309 LWS_RXPS_04_MASK_NONCE_3,
311 LWS_RXPS_04_FRAME_HDR_1,
312 LWS_RXPS_04_FRAME_HDR_LEN,
313 LWS_RXPS_04_FRAME_HDR_LEN16_2,
314 LWS_RXPS_04_FRAME_HDR_LEN16_1,
315 LWS_RXPS_04_FRAME_HDR_LEN64_8,
316 LWS_RXPS_04_FRAME_HDR_LEN64_7,
317 LWS_RXPS_04_FRAME_HDR_LEN64_6,
318 LWS_RXPS_04_FRAME_HDR_LEN64_5,
319 LWS_RXPS_04_FRAME_HDR_LEN64_4,
320 LWS_RXPS_04_FRAME_HDR_LEN64_3,
321 LWS_RXPS_04_FRAME_HDR_LEN64_2,
322 LWS_RXPS_04_FRAME_HDR_LEN64_1,
324 LWS_RXPS_07_COLLECT_FRAME_KEY_1,
325 LWS_RXPS_07_COLLECT_FRAME_KEY_2,
326 LWS_RXPS_07_COLLECT_FRAME_KEY_3,
327 LWS_RXPS_07_COLLECT_FRAME_KEY_4,
329 LWS_RXPS_PAYLOAD_UNTIL_LENGTH_EXHAUSTED
333 enum connection_mode {
334 LWS_CONNMODE_HTTP_SERVING,
335 LWS_CONNMODE_HTTP_SERVING_ACCEPTED, /* actual HTTP service going on */
336 LWS_CONNMODE_PRE_WS_SERVING_ACCEPT,
338 LWS_CONNMODE_WS_SERVING,
339 LWS_CONNMODE_WS_CLIENT,
341 /* transient, ssl delay hiding */
342 LWS_CONNMODE_SSL_ACK_PENDING,
344 /* transient modes */
345 LWS_CONNMODE_WS_CLIENT_WAITING_CONNECT,
346 LWS_CONNMODE_WS_CLIENT_WAITING_PROXY_REPLY,
347 LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE,
348 LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE2,
349 LWS_CONNMODE_WS_CLIENT_WAITING_SSL,
350 LWS_CONNMODE_WS_CLIENT_WAITING_SERVER_REPLY,
351 LWS_CONNMODE_WS_CLIENT_WAITING_EXTENSION_CONNECT,
352 LWS_CONNMODE_WS_CLIENT_PENDING_CANDIDATE_CHILD,
354 /* special internal types */
355 LWS_CONNMODE_SERVER_LISTENER,
359 LWS_RXFLOW_ALLOW = (1 << 0),
360 LWS_RXFLOW_PENDING_CHANGE = (1 << 1),
363 struct libwebsocket_protocols;
367 struct lws_io_watcher {
368 struct ev_io watcher;
369 struct libwebsocket_context* context;
372 struct lws_signal_watcher {
373 struct ev_signal watcher;
374 struct libwebsocket_context* context;
376 #endif /* LWS_USE_LIBEV */
378 struct libwebsocket_context {
382 struct libwebsocket_pollfd *fds;
383 struct libwebsocket **lws_lookup; /* fd to wsi */
386 struct ev_loop* io_loop;
387 struct lws_io_watcher w_accept;
388 struct lws_signal_watcher w_sigint;
389 #endif /* LWS_USE_LIBEV */
393 char http_proxy_address[128];
394 char canonical_hostname[128];
395 unsigned int http_proxy_port;
396 unsigned int options;
397 time_t last_timeout_check_s;
400 * usable by anything in the service code, but only if the scope
401 * does not last longer than the service action (since next service
402 * of any socket can likewise use it and overwrite)
404 unsigned char service_buffer[LWS_MAX_SOCKET_IO_BUF];
406 int started_with_parent;
409 int listen_service_modulo;
410 int listen_service_count;
411 int listen_service_fd;
412 int listen_service_extraseen;
415 * set to the Thread ID that's doing the service loop just before entry
416 * to poll indicates service thread likely idling in poll()
417 * volatile because other threads may check it as part of processing
418 * for pollfd event change.
420 volatile int service_tid;
422 int dummy_pipe_fds[2];
430 unsigned long worst_latency;
431 char worst_latency_info[256];
434 #ifdef LWS_OPENSSL_SUPPORT
436 int allow_non_ssl_on_ssl_port;
438 SSL_CTX *ssl_client_ctx;
440 struct libwebsocket_protocols *protocols;
442 #ifndef LWS_NO_EXTENSIONS
443 struct libwebsocket_extension *extensions;
445 struct lws_token_limits *token_limits;
450 LWS_EV_READ = (1 << 0),
451 LWS_EV_WRITE = (1 << 1),
452 LWS_EV_START = (1 << 2),
453 LWS_EV_STOP = (1 << 3),
457 #define LWS_LIBEV_ENABLED(context) (context->options & LWS_SERVER_OPTION_LIBEV)
458 LWS_EXTERN void lws_feature_status_libev(struct lws_context_creation_info *info);
460 lws_libev_accept(struct libwebsocket_context *context,
461 struct libwebsocket *new_wsi, int accept_fd);
463 lws_libev_io(struct libwebsocket_context *context,
464 struct libwebsocket *wsi, int flags);
466 lws_libev_init_fd_table(struct libwebsocket_context *context);
468 lws_libev_run(struct libwebsocket_context *context);
470 #define LWS_LIBEV_ENABLED(context) (0)
471 #define lws_feature_status_libev(_a) \
472 lwsl_notice("libev support not compiled in\n")
473 #define lws_libev_accept(_a, _b, _c) ((void) 0)
474 #define lws_libev_io(_a, _b, _c) ((void) 0)
475 #define lws_libev_init_fd_table(_a) (0)
476 #define lws_libev_run(_a) ((void) 0)
480 #define LWS_IPV6_ENABLED(context) (!(context->options & LWS_SERVER_OPTION_DISABLE_IPV6))
482 #define LWS_IPV6_ENABLED(context) (0)
485 enum uri_path_states {
488 URIPS_SEEN_SLASH_DOT,
489 URIPS_SEEN_SLASH_DOT_DOT,
493 enum uri_esc_states {
496 URIES_SEEN_PERCENT_H1,
500 * This is totally opaque to code using the library. It's exported as a
501 * forward-reference pointer-only declaration; the user can use the pointer with
502 * other APIs to get information out of it.
505 struct lws_fragments {
506 unsigned short offset;
508 unsigned char next_frag_index;
511 struct allocated_headers {
512 unsigned short next_frag_index;
514 unsigned char frag_index[WSI_TOKEN_COUNT];
515 struct lws_fragments frags[WSI_TOKEN_COUNT * 2];
516 char data[LWS_MAX_HEADER_LEN];
517 #ifndef LWS_NO_CLIENT
518 char initial_handshake_hash_base64[30];
519 unsigned short c_port;
523 struct _lws_http_mode_related {
524 struct allocated_headers *ah; /* mirroring _lws_header_related */
525 #if defined(WIN32) || defined(_WIN32)
530 unsigned long filepos;
531 unsigned long filelen;
533 enum http_version request_version;
534 enum http_connection_type connection_type;
539 struct _lws_header_related {
540 struct allocated_headers *ah;
542 unsigned short current_token_limit;
543 unsigned char parser_state; /* enum lws_token_indexes */
544 enum uri_path_states ups;
545 enum uri_esc_states ues;
549 struct _lws_websocket_related {
550 char *rx_user_buffer;
551 int rx_user_buffer_head;
552 unsigned char frame_masking_nonce_04[4];
553 unsigned char frame_mask_index;
554 size_t rx_packet_length;
555 unsigned char opcode;
556 unsigned int final:1;
558 unsigned int frame_is_binary:1;
559 unsigned int all_zero_nonce:1;
560 short close_reason; /* enum lws_close_status */
561 unsigned char *rxflow_buffer;
564 unsigned int rxflow_change_to:2;
565 unsigned int this_frame_masked:1;
566 unsigned int inside_frame:1; /* next write will be more of frame */
567 unsigned int clean_buffer:1; /* buffer not rewritten by extension */
570 struct libwebsocket {
572 /* lifetime members */
575 struct lws_io_watcher w_read;
576 struct lws_io_watcher w_write;
577 #endif /* LWS_USE_LIBEV */
578 const struct libwebsocket_protocols *protocol;
579 #ifndef LWS_NO_EXTENSIONS
580 struct libwebsocket_extension *
581 active_extensions[LWS_MAX_EXTENSIONS_ACTIVE];
582 void *active_extensions_user[LWS_MAX_EXTENSIONS_ACTIVE];
583 unsigned char count_active_extensions;
584 unsigned int extension_data_pending:1;
586 unsigned char ietf_spec_revision;
588 char mode; /* enum connection_mode */
589 char state; /* enum lws_connection_states */
590 char lws_rx_parse_state; /* enum lws_rx_parse_state */
591 char rx_frame_type; /* enum libwebsocket_write_protocol */
593 unsigned int hdr_parsing_completed:1;
594 unsigned int user_space_externally_allocated:1;
596 char pending_timeout; /* enum pending_timeout */
597 time_t pending_timeout_limit;
600 int position_in_fds_table;
602 unsigned long action_start;
603 unsigned long latency_start;
606 /* truncated send handling */
607 unsigned char *truncated_send_malloc; /* non-NULL means buffering in progress */
608 unsigned int truncated_send_allocation; /* size of malloc */
609 unsigned int truncated_send_offset; /* where we are in terms of spilling */
610 unsigned int truncated_send_len; /* how much is buffered */
614 /* members with mutually exclusive lifetimes are unionized */
617 struct _lws_http_mode_related http;
618 struct _lws_header_related hdr;
619 struct _lws_websocket_related ws;
622 #ifdef LWS_OPENSSL_SUPPORT
625 unsigned int use_ssl:2;
629 BOOL sock_send_blocking;
633 LWS_EXTERN int log_level;
636 libwebsocket_close_and_free_session(struct libwebsocket_context *context,
637 struct libwebsocket *wsi, enum lws_close_status);
640 remove_wsi_socket_from_fds(struct libwebsocket_context *context,
641 struct libwebsocket *wsi);
644 static inline void lws_latency(struct libwebsocket_context *context,
645 struct libwebsocket *wsi, const char *action,
646 int ret, int completion) { while (0); }
647 static inline void lws_latency_pre(struct libwebsocket_context *context,
648 struct libwebsocket *wsi) { while (0); }
650 #define lws_latency_pre(_context, _wsi) lws_latency(_context, _wsi, NULL, 0, 0)
652 lws_latency(struct libwebsocket_context *context,
653 struct libwebsocket *wsi, const char *action,
654 int ret, int completion);
658 libwebsocket_client_rx_sm(struct libwebsocket *wsi, unsigned char c);
661 libwebsocket_parse(struct libwebsocket_context *context,
662 struct libwebsocket *wsi, unsigned char c);
665 lws_b64_selftest(void);
667 LWS_EXTERN struct libwebsocket *
668 wsi_from_fd(struct libwebsocket_context *context, int fd);
671 insert_wsi_socket_into_fds(struct libwebsocket_context *context,
672 struct libwebsocket *wsi);
675 lws_issue_raw(struct libwebsocket *wsi, unsigned char *buf, size_t len);
679 libwebsocket_service_timeout_check(struct libwebsocket_context *context,
680 struct libwebsocket *wsi, unsigned int sec);
682 LWS_EXTERN struct libwebsocket *
683 libwebsocket_client_connect_2(struct libwebsocket_context *context,
684 struct libwebsocket *wsi);
686 LWS_EXTERN struct libwebsocket *
687 libwebsocket_create_new_server_wsi(struct libwebsocket_context *context);
690 libwebsockets_generate_client_handshake(struct libwebsocket_context *context,
691 struct libwebsocket *wsi, char *pkt);
694 lws_handle_POLLOUT_event(struct libwebsocket_context *context,
695 struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd);
700 #ifndef LWS_NO_EXTENSIONS
702 lws_context_init_extensions(struct lws_context_creation_info *info,
703 struct libwebsocket_context *context);
705 lws_any_extension_handled(struct libwebsocket_context *context,
706 struct libwebsocket *wsi,
707 enum libwebsocket_extension_callback_reasons r,
708 void *v, size_t len);
711 lws_ext_callback_for_each_active(struct libwebsocket *wsi, int reason,
714 lws_ext_callback_for_each_extension_type(
715 struct libwebsocket_context *context, struct libwebsocket *wsi,
716 int reason, void *arg, int len);
718 #define lws_any_extension_handled(_a, _b, _c, _d, _e) (0)
719 #define lws_ext_callback_for_each_active(_a, _b, _c, _d) (0)
720 #define lws_ext_callback_for_each_extension_type(_a, _b, _c, _d, _e) (0)
721 #define lws_issue_raw_ext_access lws_issue_raw
722 #define lws_context_init_extensions(_a, _b)
726 lws_client_interpret_server_handshake(struct libwebsocket_context *context,
727 struct libwebsocket *wsi);
730 libwebsocket_rx_sm(struct libwebsocket *wsi, unsigned char c);
733 lws_issue_raw_ext_access(struct libwebsocket *wsi,
734 unsigned char *buf, size_t len);
737 _libwebsocket_rx_flow_control(struct libwebsocket *wsi);
740 user_callback_handle_rxflow(callback_function,
741 struct libwebsocket_context *context,
742 struct libwebsocket *wsi,
743 enum libwebsocket_callback_reasons reason, void *user,
744 void *in, size_t len);
747 lws_plat_set_socket_options(struct libwebsocket_context *context, int fd);
750 lws_allocate_header_table(struct libwebsocket *wsi);
753 lws_hdr_simple_ptr(struct libwebsocket *wsi, enum lws_token_indexes h);
756 lws_hdr_simple_create(struct libwebsocket *wsi,
757 enum lws_token_indexes h, const char *s);
760 libwebsocket_ensure_user_space(struct libwebsocket *wsi);
763 lws_change_pollfd(struct libwebsocket *wsi, int _and, int _or);
765 #ifndef LWS_NO_SERVER
766 int lws_context_init_server(struct lws_context_creation_info *info,
767 struct libwebsocket_context *context);
768 LWS_EXTERN int handshake_0405(struct libwebsocket_context *context,
769 struct libwebsocket *wsi);
771 libwebsocket_interpret_incoming_packet(struct libwebsocket *wsi,
772 unsigned char *buf, size_t len);
774 lws_server_get_canonical_hostname(struct libwebsocket_context *context,
775 struct lws_context_creation_info *info);
777 #define lws_context_init_server(_a, _b) (0)
778 #define libwebsocket_interpret_incoming_packet(_a, _b, _c) (0)
779 #define lws_server_get_canonical_hostname(_a, _b)
782 #ifndef LWS_NO_DAEMONIZE
783 LWS_EXTERN int get_daemonize_pid();
785 #define get_daemonize_pid() (0)
788 LWS_EXTERN int interface_to_sa(struct libwebsocket_context *context,
789 const char *ifname, struct sockaddr_in *addr, size_t addrlen);
791 LWS_EXTERN void lwsl_emit_stderr(int level, const char *line);
794 LWS_EXTERN HANDLE lws_plat_open_file(const char* filename, unsigned long* filelen);
796 LWS_EXTERN int lws_plat_open_file(const char* filename, unsigned long* filelen);
799 enum lws_ssl_capable_status {
800 LWS_SSL_CAPABLE_ERROR = -1,
801 LWS_SSL_CAPABLE_MORE_SERVICE = -2,
804 #ifndef LWS_OPENSSL_SUPPORT
805 #define LWS_SSL_ENABLED(context) (0)
807 SHA1(const unsigned char *d, size_t n, unsigned char *md);
808 #define lws_context_init_server_ssl(_a, _b) (0)
809 #define lws_ssl_destroy(_a)
810 #define lws_context_init_http2_ssl(_a)
811 #define lws_ssl_pending(_a) (0)
812 #define lws_ssl_capable_read lws_ssl_capable_read_no_ssl
813 #define lws_ssl_capable_write lws_ssl_capable_write_no_ssl
814 #define lws_server_socket_service_ssl(_a, _b, _c, _d, _e) (0)
815 #define lws_ssl_close(_a) (0)
816 #define lws_ssl_context_destroy(_a)
818 #define LWS_SSL_ENABLED(context) (context->use_ssl)
819 LWS_EXTERN int lws_ssl_pending(struct libwebsocket *wsi);
820 LWS_EXTERN int openssl_websocket_private_data_index;
822 lws_ssl_capable_read(struct libwebsocket *wsi, unsigned char *buf, int len);
825 lws_ssl_capable_write(struct libwebsocket *wsi, unsigned char *buf, int len);
827 lws_server_socket_service_ssl(struct libwebsocket_context *context,
828 struct libwebsocket **wsi, struct libwebsocket *new_wsi,
829 int accept_fd, struct libwebsocket_pollfd *pollfd);
831 lws_ssl_close(struct libwebsocket *wsi);
833 lws_ssl_context_destroy(struct libwebsocket_context *context);
834 #ifndef LWS_NO_SERVER
836 lws_context_init_server_ssl(struct lws_context_creation_info *info,
837 struct libwebsocket_context *context);
839 #define lws_context_init_server_ssl(_a, _b) (0)
842 lws_ssl_destroy(struct libwebsocket_context *context);
848 lws_context_init_http2_ssl(struct libwebsocket_context *context);
850 #define lws_context_init_http2_ssl(_a)
855 lws_ssl_capable_read_no_ssl(struct libwebsocket *wsi, unsigned char *buf, int len);
858 lws_ssl_capable_write_no_ssl(struct libwebsocket *wsi, unsigned char *buf, int len);
860 #ifndef LWS_NO_CLIENT
861 LWS_EXTERN int lws_client_socket_service(
862 struct libwebsocket_context *context,
863 struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd);
864 #ifdef LWS_OPENSSL_SUPPORT
865 LWS_EXTERN int lws_context_init_client_ssl(struct lws_context_creation_info *info,
866 struct libwebsocket_context *context);
868 #define lws_context_init_client_ssl(_a, _b) (0)
870 LWS_EXTERN int lws_handshake_client(struct libwebsocket *wsi, unsigned char **buf, size_t len);
872 libwebsockets_decode_ssl_error(void);
874 #define lws_context_init_client_ssl(_a, _b) (0)
875 #define lws_handshake_client(_a, _b, _c) (0)
877 #ifndef LWS_NO_SERVER
878 LWS_EXTERN int lws_server_socket_service(
879 struct libwebsocket_context *context,
880 struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd);
881 LWS_EXTERN int _libwebsocket_rx_flow_control(struct libwebsocket *wsi);
882 LWS_EXTERN int lws_handshake_server(struct libwebsocket_context *context,
883 struct libwebsocket *wsi, unsigned char **buf, size_t len);
885 #define lws_server_socket_service(_a, _b, _c) (0)
886 #define _libwebsocket_rx_flow_control(_a) (0)
887 #define lws_handshake_server(_a, _b, _c, _d) (0)
894 lws_plat_delete_socket_from_fds(struct libwebsocket_context *context,
895 struct libwebsocket *wsi, int m);
897 lws_plat_insert_socket_into_fds(struct libwebsocket_context *context,
898 struct libwebsocket *wsi);
900 lws_plat_service_periodic(struct libwebsocket_context *context);
903 lws_plat_change_pollfd(struct libwebsocket_context *context,
904 struct libwebsocket *wsi, struct libwebsocket_pollfd *pfd);
906 lws_plat_context_early_init(void);
908 lws_plat_context_early_destroy(struct libwebsocket_context *context);
910 lws_plat_context_late_destroy(struct libwebsocket_context *context);
912 lws_poll_listen_fd(struct libwebsocket_pollfd *fd);
914 lws_plat_service(struct libwebsocket_context *context, int timeout_ms);
916 lws_plat_init_fd_tables(struct libwebsocket_context *context);
918 lws_plat_drop_app_privileges(struct lws_context_creation_info *info);
919 LWS_EXTERN unsigned long long
920 time_in_microseconds(void);
921 LWS_EXTERN const char *
922 lws_plat_inet_ntop(int af, const void *src, char *dst, int cnt);