• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
25 #if !defined(__LWS_PRIVATE_LIB_CORE_H__)
26 #define __LWS_PRIVATE_LIB_CORE_H__
27 
28 #include "lws_config.h"
29 #include "lws_config_private.h"
30 
31 #if defined(LWS_WITH_CGI) && defined(LWS_HAVE_VFORK) && \
32     !defined(NO_GNU_SOURCE_THIS_TIME) && !defined(_GNU_SOURCE)
33  #define  _GNU_SOURCE
34 #endif
35 
36 /*
37 #if !defined(_POSIX_C_SOURCE)
38 #define _POSIX_C_SOURCE 200112L
39 #endif
40 */
41 
42 #include <stdio.h>
43 #include <stdlib.h>
44 #include <string.h>
45 #include <time.h>
46 #include <ctype.h>
47 #include <limits.h>
48 #include <stdarg.h>
49 
50 #ifdef LWS_HAVE_INTTYPES_H
51 #include <inttypes.h>
52 #endif
53 
54 #include <assert.h>
55 
56 #ifdef LWS_HAVE_SYS_TYPES_H
57  #include <sys/types.h>
58 #endif
59 #if defined(LWS_HAVE_SYS_STAT_H) && !defined(LWS_PLAT_OPTEE)
60  #include <sys/stat.h>
61 #endif
62 
63 #if LWS_MAX_SMP > 1
64  #include <pthread.h>
65 #endif
66 
67 #ifndef LWS_DEF_HEADER_LEN
68 #define LWS_DEF_HEADER_LEN 4096
69 #endif
70 #ifndef LWS_DEF_HEADER_POOL
71 #define LWS_DEF_HEADER_POOL 4
72 #endif
73 #ifndef LWS_MAX_PROTOCOLS
74 #define LWS_MAX_PROTOCOLS 5
75 #endif
76 #ifndef LWS_MAX_EXTENSIONS_ACTIVE
77 #define LWS_MAX_EXTENSIONS_ACTIVE 1
78 #endif
79 #ifndef LWS_MAX_EXT_OFFERS
80 #define LWS_MAX_EXT_OFFERS 8
81 #endif
82 #ifndef SPEC_LATEST_SUPPORTED
83 #define SPEC_LATEST_SUPPORTED 13
84 #endif
85 #ifndef AWAITING_TIMEOUT
86 #define AWAITING_TIMEOUT 20
87 #endif
88 #ifndef CIPHERS_LIST_STRING
89 #define CIPHERS_LIST_STRING "DEFAULT"
90 #endif
91 #ifndef LWS_SOMAXCONN
92 #define LWS_SOMAXCONN SOMAXCONN
93 #endif
94 
95 #define MAX_WEBSOCKET_04_KEY_LEN 128
96 
97 #ifndef SYSTEM_RANDOM_FILEPATH
98 #define SYSTEM_RANDOM_FILEPATH "/dev/urandom"
99 #endif
100 
101 #define LWS_H2_RX_SCRATCH_SIZE 512
102 
103 #define lws_socket_is_valid(x) (x != LWS_SOCK_INVALID)
104 
105 #ifndef LWS_HAVE_STRERROR
106  #define strerror(x) ""
107 #endif
108 
109  /*
110   *
111   *  ------ private platform defines ------
112   *
113   */
114 
115 #if defined(LWS_PLAT_FREERTOS)
116  #include "private-lib-plat-freertos.h"
117 #else
118  #if defined(WIN32) || defined(_WIN32)
119   #include "private-lib-plat-windows.h"
120  #else
121   #if defined(LWS_PLAT_OPTEE)
122    #include "private-lib-plat.h"
123   #else
124    #include "private-lib-plat-unix.h"
125   #endif
126  #endif
127 #endif
128 
129  /*
130   *
131   *  ------ public api ------
132   *
133   */
134 
135 #include "libwebsockets.h"
136 
137 /*
138  * Generic bidi tx credit management
139  */
140 
141 struct lws_tx_credit {
142 	int32_t			tx_cr;		/* our credit to write peer */
143 	int32_t			peer_tx_cr_est; /* peer's credit to write us */
144 
145 	int32_t			manual_initial_tx_credit;
146 
147 	uint8_t			skint; /* unable to write anything */
148 	uint8_t			manual;
149 };
150 
151 
152 #include "private-lib-tls.h"
153 
154 #if defined(WIN32) || defined(_WIN32)
155 	 // Visual studio older than 2015 and WIN_CE has only _stricmp
156 	#if (defined(_MSC_VER) && _MSC_VER < 1900) || defined(_WIN32_WCE)
157 	#define strcasecmp _stricmp
158 	#define strncasecmp _strnicmp
159 	#elif !defined(__MINGW32__)
160 	#define strcasecmp stricmp
161 	#define strncasecmp strnicmp
162 	#endif
163 	#define getdtablesize() 30000
164 #endif
165 
166 #ifndef LWS_ARRAY_SIZE
167 #define LWS_ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
168 #endif
169 
170 #ifdef __cplusplus
171 extern "C" {
172 #endif
173 
174 
175 
176 #if defined(__clang__)
177 #define lws_memory_barrier() __sync_synchronize()
178 #elif defined(__GNUC__)
179 #define lws_memory_barrier() __sync_synchronize()
180 #else
181 #define lws_memory_barrier()
182 #endif
183 
184 
185 struct lws_ring {
186 	void *buf;
187 	void (*destroy_element)(void *element);
188 	uint32_t buflen;
189 	uint32_t element_len;
190 	uint32_t head;
191 	uint32_t oldest_tail;
192 };
193 
194 struct lws_protocols;
195 struct lws;
196 
197 #if defined(LWS_WITH_NETWORK)
198 #include "private-lib-event-libs.h"
199 
200 #if defined(LWS_WITH_SECURE_STREAMS)
201 #include "private-lib-secure-streams.h"
202 #endif
203 
204 struct lws_io_watcher {
205 #ifdef LWS_WITH_LIBEV
206 	struct lws_io_watcher_libev ev;
207 #endif
208 #ifdef LWS_WITH_LIBUV
209 	struct lws_io_watcher_libuv uv;
210 #endif
211 #ifdef LWS_WITH_LIBEVENT
212 	struct lws_io_watcher_libevent event;
213 #endif
214 #ifdef LWS_WITH_GLIB
215 	struct lws_io_watcher_glib glib;
216 #endif
217 	struct lws_context *context;
218 
219 	uint8_t actual_events;
220 };
221 
222 struct lws_signal_watcher {
223 #ifdef LWS_WITH_LIBEV
224 	struct lws_signal_watcher_libev ev;
225 #endif
226 #ifdef LWS_WITH_LIBUV
227 	struct lws_signal_watcher_libuv uv;
228 #endif
229 #ifdef LWS_WITH_LIBEVENT
230 	struct lws_signal_watcher_libevent event;
231 #endif
232 #ifdef LWS_WITH_GLIB
233 	struct lws_signal_watcher_glib glib;
234 #endif
235 	struct lws_context *context;
236 };
237 
238 struct lws_foreign_thread_pollfd {
239 	struct lws_foreign_thread_pollfd *next;
240 	int fd_index;
241 	int _and;
242 	int _or;
243 };
244 #endif
245 
246 #if LWS_MAX_SMP > 1
247 
248 struct lws_mutex_refcount {
249 	pthread_mutex_t lock;
250 	pthread_t lock_owner;
251 	const char *last_lock_reason;
252 	char lock_depth;
253 	char metadata;
254 };
255 
256 void
257 lws_mutex_refcount_init(struct lws_mutex_refcount *mr);
258 
259 void
260 lws_mutex_refcount_destroy(struct lws_mutex_refcount *mr);
261 
262 void
263 lws_mutex_refcount_lock(struct lws_mutex_refcount *mr, const char *reason);
264 
265 void
266 lws_mutex_refcount_unlock(struct lws_mutex_refcount *mr);
267 #endif
268 
269 #if defined(LWS_WITH_NETWORK)
270 #include "private-lib-core-net.h"
271 #endif
272 
273 struct lws_deferred_free
274 {
275 	struct lws_deferred_free *next;
276 	time_t deadline;
277 	void *payload;
278 };
279 
280 struct lws_system_blob {
281 	union {
282 		struct lws_buflist *bl;
283 		struct {
284 			const uint8_t *ptr;
285 			size_t len;
286 		} direct;
287 	} u;
288 	char	is_direct;
289 };
290 
291 
292 typedef struct lws_attach_item {
293 	lws_dll2_t			list;
294 	lws_attach_cb_t			cb;
295 	void				*opaque;
296 	lws_system_states_t		state;
297 } lws_attach_item_t;
298 
299 /*
300  * the rest is managed per-context, that includes
301  *
302  *  - processwide single fd -> wsi lookup
303  *  - contextwide headers pool
304  */
305 
306 struct lws_context {
307  #if defined(LWS_WITH_SERVER)
308 	char canonical_hostname[96];
309  #endif
310 
311 #if defined(LWS_WITH_FILE_OPS)
312 	struct lws_plat_file_ops fops_platform;
313 #endif
314 
315 #if defined(LWS_WITH_ZIP_FOPS)
316 	struct lws_plat_file_ops fops_zip;
317 #endif
318 
319 	lws_system_blob_t system_blobs[LWS_SYSBLOB_TYPE_COUNT];
320 
321 #if defined(LWS_WITH_NETWORK)
322 	struct lws_context_per_thread pt[LWS_MAX_SMP];
323 	lws_retry_bo_t	default_retry;
324 	lws_sorted_usec_list_t sul_system_state;
325 
326 #if defined(LWS_PLAT_FREERTOS)
327 	struct sockaddr_in frt_pipe_si;
328 #endif
329 
330 #if defined(LWS_WITH_HTTP2)
331 	struct http2_settings set;
332 #endif
333 
334 #if defined(LWS_WITH_SERVER_STATUS)
335 	struct lws_conn_stats conn_stats;
336 #endif
337 #if LWS_MAX_SMP > 1
338 	struct lws_mutex_refcount mr;
339 #endif
340 
341 #if defined(LWS_WITH_NETWORK)
342 #if defined(LWS_WITH_LIBEV)
343 	struct lws_context_eventlibs_libev ev;
344 #endif
345 #if defined(LWS_WITH_LIBUV)
346 	struct lws_context_eventlibs_libuv uv;
347 #endif
348 #if defined(LWS_WITH_LIBEVENT)
349 	struct lws_context_eventlibs_libevent event;
350 #endif
351 #if defined(LWS_WITH_GLIB)
352 	struct lws_context_eventlibs_glib glib;
353 #endif
354 
355 #if defined(LWS_WITH_TLS)
356 	struct lws_context_tls tls;
357 #endif
358 
359 #if defined(LWS_WITH_SYS_ASYNC_DNS)
360 	lws_async_dns_t		async_dns;
361 #endif
362 
363 #if defined(LWS_WITH_SECURE_STREAMS_SYS_AUTH_API_AMAZON_COM)
364 	void				*pol_args;
365 	struct lws_ss_handle		*hss_auth;
366 	struct lws_ss_handle		*hss_fetch_policy;
367 	lws_sorted_usec_list_t		sul_api_amazon_com;
368 	lws_sorted_usec_list_t		sul_api_amazon_com_kick;
369 #endif
370 
371 	lws_state_manager_t		mgr_system;
372 	lws_state_notify_link_t		protocols_notify;
373 #if defined (LWS_WITH_SYS_DHCP_CLIENT)
374 	lws_dll2_owner_t		dhcpc_owner;
375 					/**< list of ifaces with dhcpc */
376 #endif
377 
378 	/* pointers */
379 
380 	struct lws_vhost *vhost_list;
381 	struct lws_vhost *no_listener_vhost_list;
382 	struct lws_vhost *vhost_pending_destruction_list;
383 	struct lws_vhost *vhost_system;
384 
385 #if defined(LWS_WITH_SERVER)
386 	const char *server_string;
387 #endif
388 
389 	struct lws_event_loop_ops *event_loop_ops;
390 #endif
391 
392 #if defined(LWS_WITH_TLS)
393 	const struct lws_tls_ops *tls_ops;
394 #endif
395 
396 #if defined(LWS_WITH_DETAILED_LATENCY)
397 	det_lat_buf_cb_t detailed_latency_cb;
398 #endif
399 #if defined(LWS_WITH_PLUGINS)
400 	struct lws_plugin *plugin_list;
401 #endif
402 #ifdef _WIN32
403 /* different implementation between unix and windows */
404 	struct lws_fd_hashtable fd_hashtable[FD_HASHTABLE_MODULUS];
405 #else
406 	struct lws **lws_lookup;
407 
408 #endif
409 #endif /* NETWORK */
410 
411 #if defined(LWS_WITH_SECURE_STREAMS_PROXY_API)
412 	const char	*ss_proxy_bind;
413 	const char	*ss_proxy_address;
414 #endif
415 
416 #if defined(LWS_WITH_FILE_OPS)
417 	const struct lws_plat_file_ops *fops;
418 #endif
419 
420 	struct lws_context **pcontext_finalize;
421 	const char *username, *groupname;
422 #if defined(LWS_WITH_DETAILED_LATENCY)
423 	const char *detailed_latency_filepath;
424 #endif
425 
426 #if defined(LWS_AMAZON_RTOS)
427 	mbedtls_entropy_context mec;
428 	mbedtls_ctr_drbg_context mcdc;
429 #endif
430 
431 	struct lws_deferred_free *deferred_free_list;
432 
433 #if defined(LWS_WITH_THREADPOOL)
434 	struct lws_threadpool *tp_list_head;
435 #endif
436 
437 #if defined(LWS_WITH_PEER_LIMITS)
438 	struct lws_peer **pl_hash_table;
439 	struct lws_peer *peer_wait_list;
440 	time_t next_cull;
441 #endif
442 
443 	const lws_system_ops_t *system_ops;
444 
445 #if defined(LWS_WITH_SECURE_STREAMS)
446 	const char *pss_policies_json;
447 	const lws_ss_policy_t *pss_policies;
448 	const lws_ss_plugin_t **pss_plugins;
449 	struct lwsac *ac_policy;
450 #endif
451 
452 	void *external_baggage_free_on_destroy;
453 	const struct lws_token_limits *token_limits;
454 	void *user_space;
455 #if defined(LWS_WITH_SERVER)
456 	const struct lws_protocol_vhost_options *reject_service_keywords;
457 	lws_reload_func deprecation_cb;
458 #endif
459 	void (*eventlib_signal_cb)(void *event_lib_handle, int signum);
460 
461 #if defined(LWS_HAVE_SYS_CAPABILITY_H) && defined(LWS_HAVE_LIBCAP)
462 	cap_value_t caps[4];
463 	char count_caps;
464 #endif
465 
466 	lws_usec_t time_up; /* monotonic */
467 
468 	uint64_t options;
469 
470 	time_t last_ws_ping_pong_check_s;
471 
472 #if defined(LWS_PLAT_FREERTOS)
473 	unsigned long time_last_state_dump;
474 	uint32_t last_free_heap;
475 #endif
476 
477 	int max_fds;
478 	int count_event_loop_static_asset_handles;
479 #if !defined(LWS_NO_DAEMONIZE)
480 	pid_t started_with_parent;
481 #endif
482 	int uid, gid;
483 
484 	int fd_random;
485 #if defined(LWS_WITH_DETAILED_LATENCY)
486 	int latencies_fd;
487 #endif
488 	int count_wsi_allocated;
489 	int count_cgi_spawned;
490 	unsigned int fd_limit_per_thread;
491 	unsigned int timeout_secs;
492 	unsigned int pt_serv_buf_size;
493 	int max_http_header_data;
494 	int max_http_header_pool;
495 	int simultaneous_ssl_restriction;
496 	int simultaneous_ssl;
497 #if defined(LWS_WITH_PEER_LIMITS)
498 	uint32_t pl_hash_elements;	/* protected by context->lock */
499 	uint32_t count_peers;		/* protected by context->lock */
500 	unsigned short ip_limit_ah;
501 	unsigned short ip_limit_wsi;
502 #endif
503 	unsigned int deprecated:1;
504 	unsigned int inside_context_destroy:1;
505 	unsigned int being_destroyed:1;
506 	unsigned int being_destroyed1:1;
507 	unsigned int being_destroyed2:1;
508 	unsigned int requested_kill:1;
509 	unsigned int protocol_init_done:1;
510 	unsigned int doing_protocol_init:1;
511 	unsigned int done_protocol_destroy_cb:1;
512 	unsigned int finalize_destroy_after_internal_loops_stopped:1;
513 	unsigned int max_fds_unrelated_to_ulimit:1;
514 	unsigned int policy_updated:1;
515 
516 	short count_threads;
517 	short plugin_protocol_count;
518 	short plugin_extension_count;
519 	short server_string_len;
520 	unsigned short ws_ping_pong_interval;
521 	unsigned short deprecation_pending_listen_close_count;
522 #if defined(LWS_WITH_SECURE_STREAMS_PROXY_API)
523 	uint16_t	ss_proxy_port;
524 #endif
525 
526 	uint8_t max_fi;
527 	uint8_t udp_loss_sim_tx_pc;
528 	uint8_t udp_loss_sim_rx_pc;
529 
530 #if defined(LWS_WITH_STATS)
531 	uint8_t updated;
532 #endif
533 };
534 
535 int
536 lws_check_deferred_free(struct lws_context *context, int tsi, int force);
537 
538 #define lws_get_context_protocol(ctx, x) ctx->vhost_list->protocols[x]
539 #define lws_get_vh_protocol(vh, x) vh->protocols[x]
540 
541 int
542 lws_jws_base64_enc(const char *in, size_t in_len, char *out, size_t out_max);
543 
544 void
545 lws_vhost_destroy1(struct lws_vhost *vh);
546 
547 
548 #if defined(LWS_PLAT_FREERTOS)
549 LWS_EXTERN int
550 lws_find_string_in_file(const char *filename, const char *str, int stringlen);
551 #endif
552 
553 signed char char_to_hex(const char c);
554 
555 #if defined(LWS_WITH_NETWORK)
556 int
557 lws_system_do_attach(struct lws_context_per_thread *pt);
558 #endif
559 
560 struct lws_buflist {
561 	struct lws_buflist *next;
562 	size_t len;
563 	size_t pos;
564 };
565 
566 LWS_EXTERN char *
567 lws_strdup(const char *s);
568 
569 LWS_EXTERN int log_level;
570 
571 LWS_EXTERN int
572 lws_b64_selftest(void);
573 
574 
575 #ifndef LWS_NO_DAEMONIZE
576  LWS_EXTERN pid_t get_daemonize_pid();
577 #else
578  #define get_daemonize_pid() (0)
579 #endif
580 
581 LWS_EXTERN void lwsl_emit_stderr(int level, const char *line);
582 
583 #if !defined(LWS_WITH_TLS)
584  #define LWS_SSL_ENABLED(context) (0)
585  #define lws_context_init_server_ssl(_a, _b) (0)
586  #define lws_ssl_destroy(_a)
587  #define lws_context_init_alpn(_a)
588  #define lws_ssl_capable_read lws_ssl_capable_read_no_ssl
589  #define lws_ssl_capable_write lws_ssl_capable_write_no_ssl
590  #define lws_ssl_pending lws_ssl_pending_no_ssl
591  #define lws_server_socket_service_ssl(_b, _c) (0)
592  #define lws_ssl_close(_a) (0)
593  #define lws_ssl_context_destroy(_a)
594  #define lws_ssl_SSL_CTX_destroy(_a)
595  #define lws_ssl_remove_wsi_from_buffered_list(_a)
596  #define __lws_ssl_remove_wsi_from_buffered_list(_a)
597  #define lws_context_init_ssl_library(_a)
598  #define lws_context_deinit_ssl_library(_a)
599  #define lws_tls_check_all_cert_lifetimes(_a)
600  #define lws_tls_acme_sni_cert_destroy(_a)
601 #endif
602 
603 
604 
605 #if LWS_MAX_SMP > 1
606 #define lws_context_lock(c, reason) lws_mutex_refcount_lock(&c->mr, reason)
607 #define lws_context_unlock(c) lws_mutex_refcount_unlock(&c->mr)
608 
609 static LWS_INLINE void
lws_vhost_lock(struct lws_vhost * vhost)610 lws_vhost_lock(struct lws_vhost *vhost)
611 {
612 	pthread_mutex_lock(&vhost->lock);
613 }
614 
615 static LWS_INLINE void
lws_vhost_unlock(struct lws_vhost * vhost)616 lws_vhost_unlock(struct lws_vhost *vhost)
617 {
618 	pthread_mutex_unlock(&vhost->lock);
619 }
620 
621 
622 #else
623 #define lws_pt_mutex_init(_a) (void)(_a)
624 #define lws_pt_mutex_destroy(_a) (void)(_a)
625 #define lws_pt_lock(_a, b) (void)(_a)
626 #define lws_pt_unlock(_a) (void)(_a)
627 #define lws_context_lock(_a, _b) (void)(_a)
628 #define lws_context_unlock(_a) (void)(_a)
629 #define lws_vhost_lock(_a) (void)(_a)
630 #define lws_vhost_unlock(_a) (void)(_a)
631 #define lws_pt_stats_lock(_a) (void)(_a)
632 #define lws_pt_stats_unlock(_a) (void)(_a)
633 #endif
634 
635 LWS_EXTERN int LWS_WARN_UNUSED_RESULT
636 lws_ssl_capable_read_no_ssl(struct lws *wsi, unsigned char *buf, int len);
637 
638 LWS_EXTERN int LWS_WARN_UNUSED_RESULT
639 lws_ssl_capable_write_no_ssl(struct lws *wsi, unsigned char *buf, int len);
640 
641 LWS_EXTERN int LWS_WARN_UNUSED_RESULT
642 lws_ssl_pending_no_ssl(struct lws *wsi);
643 
644 int
645 lws_tls_check_cert_lifetime(struct lws_vhost *vhost);
646 
647 int lws_jws_selftest(void);
648 int lws_jwe_selftest(void);
649 
650 int
651 lws_protocol_init(struct lws_context *context);
652 
653 int
654 lws_bind_protocol(struct lws *wsi, const struct lws_protocols *p,
655 		  const char *reason);
656 
657 const struct lws_protocol_vhost_options *
658 lws_vhost_protocol_options(struct lws_vhost *vh, const char *name);
659 
660 const struct lws_http_mount *
661 lws_find_mount(struct lws *wsi, const char *uri_ptr, int uri_len);
662 
663 /*
664  * custom allocator
665  */
666 LWS_EXTERN void *
667 lws_realloc(void *ptr, size_t size, const char *reason);
668 
669 LWS_EXTERN void * LWS_WARN_UNUSED_RESULT
670 lws_zalloc(size_t size, const char *reason);
671 
672 #ifdef LWS_PLAT_OPTEE
673 void *lws_malloc(size_t size, const char *reason);
674 void lws_free(void *p);
675 #define lws_free_set_NULL(P)    do { lws_free(P); (P) = NULL; } while(0)
676 #else
677 #define lws_malloc(S, R)	lws_realloc(NULL, S, R)
678 #define lws_free(P)	lws_realloc(P, 0, "lws_free")
679 #define lws_free_set_NULL(P)	do { lws_realloc(P, 0, "free"); (P) = NULL; } while(0)
680 #endif
681 
682 int
683 lws_create_event_pipes(struct lws_context *context);
684 
685 int
686 lws_plat_apply_FD_CLOEXEC(int n);
687 
688 const struct lws_plat_file_ops *
689 lws_vfs_select_fops(const struct lws_plat_file_ops *fops, const char *vfs_path,
690 		    const char **vpath);
691 
692 /* lws_plat_ */
693 
694 LWS_EXTERN int
695 lws_plat_context_early_init(void);
696 LWS_EXTERN void
697 lws_plat_context_early_destroy(struct lws_context *context);
698 LWS_EXTERN void
699 lws_plat_context_late_destroy(struct lws_context *context);
700 
701 LWS_EXTERN int
702 lws_plat_init(struct lws_context *context,
703 	      const struct lws_context_creation_info *info);
704 LWS_EXTERN int
705 lws_plat_drop_app_privileges(struct lws_context *context, int actually_drop);
706 
707 #if defined(LWS_WITH_UNIX_SOCK)
708 int
709 lws_plat_user_colon_group_to_ids(const char *u_colon_g, uid_t *puid, gid_t *pgid);
710 #endif
711 
712 int
713 lws_plat_ifname_to_hwaddr(int fd, const char *ifname, uint8_t *hwaddr, int len);
714 
715 LWS_EXTERN int
716 lws_check_byte_utf8(unsigned char state, unsigned char c);
717 LWS_EXTERN int LWS_WARN_UNUSED_RESULT
718 lws_check_utf8(unsigned char *state, unsigned char *buf, size_t len);
719 LWS_EXTERN int alloc_file(struct lws_context *context, const char *filename,
720 			  uint8_t **buf, lws_filepos_t *amount);
721 
722 void
723 lws_context_destroy2(struct lws_context *context);
724 
725 #if !defined(PRIu64)
726 #define PRIu64 "llu"
727 #endif
728 
729 #if defined(LWS_WITH_ABSTRACT)
730 #include "private-lib-abstract.h"
731 #endif
732 
733 #ifdef __cplusplus
734 };
735 #endif
736 
737 #endif
738