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 struct lws_context *context;
233 };
234
235 struct lws_foreign_thread_pollfd {
236 struct lws_foreign_thread_pollfd *next;
237 int fd_index;
238 int _and;
239 int _or;
240 };
241 #endif
242
243 #if LWS_MAX_SMP > 1
244
245 struct lws_mutex_refcount {
246 pthread_mutex_t lock;
247 pthread_t lock_owner;
248 const char *last_lock_reason;
249 char lock_depth;
250 char metadata;
251 };
252
253 void
254 lws_mutex_refcount_init(struct lws_mutex_refcount *mr);
255
256 void
257 lws_mutex_refcount_destroy(struct lws_mutex_refcount *mr);
258
259 void
260 lws_mutex_refcount_lock(struct lws_mutex_refcount *mr, const char *reason);
261
262 void
263 lws_mutex_refcount_unlock(struct lws_mutex_refcount *mr);
264 #endif
265
266 #if defined(LWS_WITH_NETWORK)
267 #include "private-lib-core-net.h"
268 #endif
269
270 struct lws_deferred_free
271 {
272 struct lws_deferred_free *next;
273 time_t deadline;
274 void *payload;
275 };
276
277 struct lws_system_blob {
278 union {
279 struct lws_buflist *bl;
280 struct {
281 const uint8_t *ptr;
282 size_t len;
283 } direct;
284 } u;
285 char is_direct;
286 };
287
288
289 typedef struct lws_attach_item {
290 lws_dll2_t list;
291 lws_attach_cb_t cb;
292 void *opaque;
293 lws_system_states_t state;
294 } lws_attach_item_t;
295
296 /*
297 * the rest is managed per-context, that includes
298 *
299 * - processwide single fd -> wsi lookup
300 * - contextwide headers pool
301 */
302
303 struct lws_context {
304 #if defined(LWS_WITH_SERVER)
305 char canonical_hostname[96];
306 #endif
307
308 #if defined(LWS_WITH_FILE_OPS)
309 struct lws_plat_file_ops fops_platform;
310 #endif
311
312 #if defined(LWS_WITH_ZIP_FOPS)
313 struct lws_plat_file_ops fops_zip;
314 #endif
315
316 lws_system_blob_t system_blobs[LWS_SYSBLOB_TYPE_COUNT];
317
318 #if defined(LWS_WITH_NETWORK)
319 struct lws_context_per_thread pt[LWS_MAX_SMP];
320 lws_retry_bo_t default_retry;
321 lws_sorted_usec_list_t sul_system_state;
322
323 #if defined(LWS_PLAT_FREERTOS)
324 struct sockaddr_in frt_pipe_si;
325 #endif
326
327 #if defined(LWS_WITH_HTTP2)
328 struct http2_settings set;
329 #endif
330
331 #if defined(LWS_WITH_SERVER_STATUS)
332 struct lws_conn_stats conn_stats;
333 #endif
334 #if LWS_MAX_SMP > 1
335 struct lws_mutex_refcount mr;
336 #endif
337
338 #if defined(LWS_WITH_NETWORK)
339 #if defined(LWS_WITH_LIBEV)
340 struct lws_context_eventlibs_libev ev;
341 #endif
342 #if defined(LWS_WITH_LIBUV)
343 struct lws_context_eventlibs_libuv uv;
344 #endif
345 #if defined(LWS_WITH_LIBEVENT)
346 struct lws_context_eventlibs_libevent event;
347 #endif
348 #if defined(LWS_WITH_GLIB)
349 struct lws_context_eventlibs_glib glib;
350 #endif
351
352 #if defined(LWS_WITH_TLS)
353 struct lws_context_tls tls;
354 #endif
355
356 #if defined(LWS_WITH_SYS_ASYNC_DNS)
357 lws_async_dns_t async_dns;
358 #endif
359
360 #if defined(LWS_WITH_SECURE_STREAMS_SYS_AUTH_API_AMAZON_COM)
361 void *pol_args;
362 struct lws_ss_handle *hss_auth;
363 struct lws_ss_handle *hss_fetch_policy;
364 lws_sorted_usec_list_t sul_api_amazon_com;
365 lws_sorted_usec_list_t sul_api_amazon_com_kick;
366 #endif
367
368 lws_state_manager_t mgr_system;
369 lws_state_notify_link_t protocols_notify;
370 #if defined (LWS_WITH_SYS_DHCP_CLIENT)
371 lws_dll2_owner_t dhcpc_owner;
372 /**< list of ifaces with dhcpc */
373 #endif
374
375 /* pointers */
376
377 struct lws_vhost *vhost_list;
378 struct lws_vhost *no_listener_vhost_list;
379 struct lws_vhost *vhost_pending_destruction_list;
380 struct lws_vhost *vhost_system;
381
382 #if defined(LWS_WITH_SERVER)
383 const char *server_string;
384 #endif
385
386 struct lws_event_loop_ops *event_loop_ops;
387 #endif
388
389 #if defined(LWS_WITH_TLS)
390 const struct lws_tls_ops *tls_ops;
391 #endif
392
393 #if defined(LWS_WITH_DETAILED_LATENCY)
394 det_lat_buf_cb_t detailed_latency_cb;
395 #endif
396 #if defined(LWS_WITH_PLUGINS)
397 struct lws_plugin *plugin_list;
398 #endif
399 #ifdef _WIN32
400 /* different implementation between unix and windows */
401 struct lws_fd_hashtable fd_hashtable[FD_HASHTABLE_MODULUS];
402 #else
403 struct lws **lws_lookup;
404
405 #endif
406 #endif /* NETWORK */
407
408 #if defined(LWS_WITH_SECURE_STREAMS_PROXY_API)
409 const char *ss_proxy_bind;
410 const char *ss_proxy_address;
411 #endif
412
413 #if defined(LWS_WITH_FILE_OPS)
414 const struct lws_plat_file_ops *fops;
415 #endif
416
417 struct lws_context **pcontext_finalize;
418 const char *username, *groupname;
419 #if defined(LWS_WITH_DETAILED_LATENCY)
420 const char *detailed_latency_filepath;
421 #endif
422
423 #if defined(LWS_AMAZON_RTOS)
424 mbedtls_entropy_context mec;
425 mbedtls_ctr_drbg_context mcdc;
426 #endif
427
428 struct lws_deferred_free *deferred_free_list;
429
430 #if defined(LWS_WITH_THREADPOOL)
431 struct lws_threadpool *tp_list_head;
432 #endif
433
434 #if defined(LWS_WITH_PEER_LIMITS)
435 struct lws_peer **pl_hash_table;
436 struct lws_peer *peer_wait_list;
437 time_t next_cull;
438 #endif
439
440 const lws_system_ops_t *system_ops;
441
442 #if defined(LWS_WITH_SECURE_STREAMS)
443 const char *pss_policies_json;
444 const lws_ss_policy_t *pss_policies;
445 const lws_ss_plugin_t **pss_plugins;
446 struct lwsac *ac_policy;
447 #endif
448
449 void *external_baggage_free_on_destroy;
450 const struct lws_token_limits *token_limits;
451 void *user_space;
452 #if defined(LWS_WITH_SERVER)
453 const struct lws_protocol_vhost_options *reject_service_keywords;
454 lws_reload_func deprecation_cb;
455 #endif
456 void (*eventlib_signal_cb)(void *event_lib_handle, int signum);
457
458 #if defined(LWS_HAVE_SYS_CAPABILITY_H) && defined(LWS_HAVE_LIBCAP)
459 cap_value_t caps[4];
460 char count_caps;
461 #endif
462
463 lws_usec_t time_up; /* monotonic */
464
465 uint64_t options;
466
467 time_t last_ws_ping_pong_check_s;
468
469 #if defined(LWS_PLAT_FREERTOS)
470 unsigned long time_last_state_dump;
471 uint32_t last_free_heap;
472 #endif
473
474 int max_fds;
475 int count_event_loop_static_asset_handles;
476 #if !defined(LWS_NO_DAEMONIZE)
477 pid_t started_with_parent;
478 #endif
479 int uid, gid;
480
481 int fd_random;
482 #if defined(LWS_WITH_DETAILED_LATENCY)
483 int latencies_fd;
484 #endif
485 int count_wsi_allocated;
486 int count_cgi_spawned;
487 unsigned int fd_limit_per_thread;
488 unsigned int timeout_secs;
489 unsigned int pt_serv_buf_size;
490 int max_http_header_data;
491 int max_http_header_pool;
492 int simultaneous_ssl_restriction;
493 int simultaneous_ssl;
494 #if defined(LWS_WITH_PEER_LIMITS)
495 uint32_t pl_hash_elements; /* protected by context->lock */
496 uint32_t count_peers; /* protected by context->lock */
497 unsigned short ip_limit_ah;
498 unsigned short ip_limit_wsi;
499 #endif
500 unsigned int deprecated:1;
501 unsigned int inside_context_destroy:1;
502 unsigned int being_destroyed:1;
503 unsigned int being_destroyed1:1;
504 unsigned int being_destroyed2:1;
505 unsigned int requested_kill:1;
506 unsigned int protocol_init_done:1;
507 unsigned int doing_protocol_init:1;
508 unsigned int done_protocol_destroy_cb:1;
509 unsigned int finalize_destroy_after_internal_loops_stopped:1;
510 unsigned int max_fds_unrelated_to_ulimit:1;
511 unsigned int policy_updated:1;
512
513 short count_threads;
514 short plugin_protocol_count;
515 short plugin_extension_count;
516 short server_string_len;
517 unsigned short ws_ping_pong_interval;
518 unsigned short deprecation_pending_listen_close_count;
519 #if defined(LWS_WITH_SECURE_STREAMS_PROXY_API)
520 uint16_t ss_proxy_port;
521 #endif
522
523 uint8_t max_fi;
524 uint8_t udp_loss_sim_tx_pc;
525 uint8_t udp_loss_sim_rx_pc;
526
527 #if defined(LWS_WITH_STATS)
528 uint8_t updated;
529 #endif
530 };
531
532 int
533 lws_check_deferred_free(struct lws_context *context, int tsi, int force);
534
535 #define lws_get_context_protocol(ctx, x) ctx->vhost_list->protocols[x]
536 #define lws_get_vh_protocol(vh, x) vh->protocols[x]
537
538 int
539 lws_jws_base64_enc(const char *in, size_t in_len, char *out, size_t out_max);
540
541 void
542 lws_vhost_destroy1(struct lws_vhost *vh);
543
544
545 #if defined(LWS_PLAT_FREERTOS)
546 LWS_EXTERN int
547 lws_find_string_in_file(const char *filename, const char *str, int stringlen);
548 #endif
549
550 signed char char_to_hex(const char c);
551
552 #if defined(LWS_WITH_NETWORK)
553 int
554 lws_system_do_attach(struct lws_context_per_thread *pt);
555 #endif
556
557 struct lws_buflist {
558 struct lws_buflist *next;
559 size_t len;
560 size_t pos;
561 };
562
563 LWS_EXTERN char *
564 lws_strdup(const char *s);
565
566 LWS_EXTERN int log_level;
567
568 LWS_EXTERN int
569 lws_b64_selftest(void);
570
571
572 #ifndef LWS_NO_DAEMONIZE
573 LWS_EXTERN pid_t get_daemonize_pid();
574 #else
575 #define get_daemonize_pid() (0)
576 #endif
577
578 LWS_EXTERN void lwsl_emit_stderr(int level, const char *line);
579
580 #if !defined(LWS_WITH_TLS)
581 #define LWS_SSL_ENABLED(context) (0)
582 #define lws_context_init_server_ssl(_a, _b) (0)
583 #define lws_ssl_destroy(_a)
584 #define lws_context_init_alpn(_a)
585 #define lws_ssl_capable_read lws_ssl_capable_read_no_ssl
586 #define lws_ssl_capable_write lws_ssl_capable_write_no_ssl
587 #define lws_ssl_pending lws_ssl_pending_no_ssl
588 #define lws_server_socket_service_ssl(_b, _c) (0)
589 #define lws_ssl_close(_a) (0)
590 #define lws_ssl_context_destroy(_a)
591 #define lws_ssl_SSL_CTX_destroy(_a)
592 #define lws_ssl_remove_wsi_from_buffered_list(_a)
593 #define __lws_ssl_remove_wsi_from_buffered_list(_a)
594 #define lws_context_init_ssl_library(_a)
595 #define lws_context_deinit_ssl_library(_a)
596 #define lws_tls_check_all_cert_lifetimes(_a)
597 #define lws_tls_acme_sni_cert_destroy(_a)
598 #endif
599
600
601
602 #if LWS_MAX_SMP > 1
603 #define lws_context_lock(c, reason) lws_mutex_refcount_lock(&c->mr, reason)
604 #define lws_context_unlock(c) lws_mutex_refcount_unlock(&c->mr)
605
606 static LWS_INLINE void
lws_vhost_lock(struct lws_vhost * vhost)607 lws_vhost_lock(struct lws_vhost *vhost)
608 {
609 pthread_mutex_lock(&vhost->lock);
610 }
611
612 static LWS_INLINE void
lws_vhost_unlock(struct lws_vhost * vhost)613 lws_vhost_unlock(struct lws_vhost *vhost)
614 {
615 pthread_mutex_unlock(&vhost->lock);
616 }
617
618
619 #else
620 #define lws_pt_mutex_init(_a) (void)(_a)
621 #define lws_pt_mutex_destroy(_a) (void)(_a)
622 #define lws_pt_lock(_a, b) (void)(_a)
623 #define lws_pt_unlock(_a) (void)(_a)
624 #define lws_context_lock(_a, _b) (void)(_a)
625 #define lws_context_unlock(_a) (void)(_a)
626 #define lws_vhost_lock(_a) (void)(_a)
627 #define lws_vhost_unlock(_a) (void)(_a)
628 #define lws_pt_stats_lock(_a) (void)(_a)
629 #define lws_pt_stats_unlock(_a) (void)(_a)
630 #endif
631
632 LWS_EXTERN int LWS_WARN_UNUSED_RESULT
633 lws_ssl_capable_read_no_ssl(struct lws *wsi, unsigned char *buf, int len);
634
635 LWS_EXTERN int LWS_WARN_UNUSED_RESULT
636 lws_ssl_capable_write_no_ssl(struct lws *wsi, unsigned char *buf, int len);
637
638 LWS_EXTERN int LWS_WARN_UNUSED_RESULT
639 lws_ssl_pending_no_ssl(struct lws *wsi);
640
641 int
642 lws_tls_check_cert_lifetime(struct lws_vhost *vhost);
643
644 int lws_jws_selftest(void);
645 int lws_jwe_selftest(void);
646
647 int
648 lws_protocol_init(struct lws_context *context);
649
650 int
651 lws_bind_protocol(struct lws *wsi, const struct lws_protocols *p,
652 const char *reason);
653
654 const struct lws_protocol_vhost_options *
655 lws_vhost_protocol_options(struct lws_vhost *vh, const char *name);
656
657 const struct lws_http_mount *
658 lws_find_mount(struct lws *wsi, const char *uri_ptr, int uri_len);
659
660 /*
661 * custom allocator
662 */
663 LWS_EXTERN void *
664 lws_realloc(void *ptr, size_t size, const char *reason);
665
666 LWS_EXTERN void * LWS_WARN_UNUSED_RESULT
667 lws_zalloc(size_t size, const char *reason);
668
669 #ifdef LWS_PLAT_OPTEE
670 void *lws_malloc(size_t size, const char *reason);
671 void lws_free(void *p);
672 #define lws_free_set_NULL(P) do { lws_free(P); (P) = NULL; } while(0)
673 #else
674 #define lws_malloc(S, R) lws_realloc(NULL, S, R)
675 #define lws_free(P) lws_realloc(P, 0, "lws_free")
676 #define lws_free_set_NULL(P) do { lws_realloc(P, 0, "free"); (P) = NULL; } while(0)
677 #endif
678
679 int
680 lws_create_event_pipes(struct lws_context *context);
681
682 int
683 lws_plat_apply_FD_CLOEXEC(int n);
684
685 const struct lws_plat_file_ops *
686 lws_vfs_select_fops(const struct lws_plat_file_ops *fops, const char *vfs_path,
687 const char **vpath);
688
689 /* lws_plat_ */
690
691 LWS_EXTERN int
692 lws_plat_context_early_init(void);
693 LWS_EXTERN void
694 lws_plat_context_early_destroy(struct lws_context *context);
695 LWS_EXTERN void
696 lws_plat_context_late_destroy(struct lws_context *context);
697
698 LWS_EXTERN int
699 lws_plat_init(struct lws_context *context,
700 const struct lws_context_creation_info *info);
701 LWS_EXTERN int
702 lws_plat_drop_app_privileges(struct lws_context *context, int actually_drop);
703
704 #if defined(LWS_WITH_UNIX_SOCK)
705 int
706 lws_plat_user_colon_group_to_ids(const char *u_colon_g, uid_t *puid, gid_t *pgid);
707 #endif
708
709 int
710 lws_plat_ifname_to_hwaddr(int fd, const char *ifname, uint8_t *hwaddr, int len);
711
712 LWS_EXTERN int
713 lws_check_byte_utf8(unsigned char state, unsigned char c);
714 LWS_EXTERN int LWS_WARN_UNUSED_RESULT
715 lws_check_utf8(unsigned char *state, unsigned char *buf, size_t len);
716 LWS_EXTERN int alloc_file(struct lws_context *context, const char *filename,
717 uint8_t **buf, lws_filepos_t *amount);
718
719 void
720 lws_context_destroy2(struct lws_context *context);
721
722 #if !defined(PRIu64)
723 #define PRIu64 "llu"
724 #endif
725
726 #if defined(LWS_WITH_ABSTRACT)
727 #include "private-lib-abstract.h"
728 #endif
729
730 #ifdef __cplusplus
731 };
732 #endif
733
734 #endif
735