libwebsockets
Lightweight C library for HTML5 websockets
Loading...
Searching...
No Matches
lws-misc.h
Go to the documentation of this file.
1/*
2 * libwebsockets - small server side websockets and web server implementation
3 *
4 * Copyright (C) 2010 - 2021 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_WITH_SPAWN)
26
27#if defined(WIN32) || defined(_WIN32)
28#else
29#include <sys/wait.h>
30#include <sys/times.h>
31#endif
32#endif
33
34#if defined(__OpenBSD__)
35#include <sys/siginfo.h>
36#endif
37
44
45struct lws_buflist;
46
47/*
48 * lws_fragbuf: a large buffer that does not insist on being contiguous
49 *
50 * A decoder that wants tens of KB in one piece fails on a heap that has the
51 * space but not in one run - and on a small target, mixed in with the
52 * connections and parsers that are still live, that is the normal state of
53 * affairs rather than the exception.
54 *
55 * Where the consumer can work with the buffer in pieces, this takes the
56 * failure of the monolithic allocation as an invitation to try again in
57 * smaller ones. It still asks for the whole thing first, so when the heap
58 * can do it nothing is lost: the unit table is then simply a contiguous walk
59 * and lws_fragbuf_at() hands back the whole remainder at once.
60 *
61 * unit_size is the granularity the consumer needs contiguous, eg, a row pitch
62 * for image data: a unit is never split across allocations, so
63 * lws_fragbuf_unit() always hands back unit_size contiguous bytes.
64 *
65 * Every unit starts zeroed, whether it came in one piece or many.
66 */
67
68typedef struct lws_fragbuf lws_fragbuf_t;
69
79lws_fragbuf_create(size_t units, size_t unit_size);
80
98lws_fragbuf_create_cap(size_t units, size_t unit_size, size_t cap);
99
102
112lws_fragbuf_unit(const lws_fragbuf_t *fb, size_t unit);
113
125lws_fragbuf_at(const lws_fragbuf_t *fb, size_t ofs, size_t *avail);
126
132LWS_VISIBLE LWS_EXTERN unsigned int
134
145
146#define LWS_BUFLIST_OOM_LIMIT (2 * 1024 * 1024)
147
149lws_buflist_append_segment(struct lws_buflist **head, const uint8_t *buf,
150 size_t len);
151
164lws_buflist_append_segment_take_ownership(struct lws_buflist **head, uint8_t *buf, size_t len);
165
177lws_buflist_next_segment_len(struct lws_buflist **head, uint8_t **buf);
178
195lws_buflist_use_segment(struct lws_buflist **head, size_t len);
196
205lws_buflist_total_len(struct lws_buflist **head);
206
219lws_buflist_linear_copy(struct lws_buflist **head, size_t ofs, uint8_t *buf,
220 size_t len);
221
239lws_buflist_linear_use(struct lws_buflist **head, uint8_t *buf, size_t len);
240
264lws_buflist_fragment_use(struct lws_buflist **head, uint8_t *buf,
265 size_t len, char *frag_first, char *frag_fin);
266
276lws_buflist_destroy_all_segments(struct lws_buflist **head);
277
289lws_buflist_describe(struct lws_buflist **head, void *id, const char *reason);
290
304lws_buflist_get_frag_start_or_NULL(struct lws_buflist **head);
305
306
307/* --- lws_buflist2 (doubly-linked) --- */
308
314
315struct lws_buflist2;
316
329 size_t len);
330
344
357
375
383static LWS_INLINE size_t
384lws_buflist2_total_len(struct lws_buflist2_owner *owner) { return owner->total_len; }
385
410 size_t len, char *frag_first, char *frag_fin);
411
421
436
437
438
447lws_crc32(uint32_t crc, const void *buf, size_t len);
448
449
450
451struct lws_wsmsg_info;
452
453typedef void (*lws_wsmsg_transfer_cb)(struct lws_wsmsg_info *info);
454
455typedef struct lws_wsmsg_info {
456 struct lws_buflist **head_upstream; /* the upstream buflist */
457 struct lws_buflist **private_heads; /* the private reassembly heads */
458 int private_source_idx; /* which index to use in private_heads */
459 lws_wsmsg_transfer_cb optional_cb; /* optional transfer callback */
460 void *opaque; /* optional opaque pointer */
461 const uint8_t *buf; /* array to add */
462 size_t len; /* length of bytes in array */
463 unsigned int ss_flags; /* SS flags for SOM / EOM */
465
498
499/*
500 * lws_wsmsg_destroy() - free all allocations in private buflists
501 *
502 * \param private_heads: the private buflists
503 * \param count_private_heads: the number of private buflists
504 */
506lws_wsmsg_destroy(struct lws_buflist *private_heads[], size_t count_private_heads);
507
508
509
510/*
511 * Optional helpers for closely-managed stream flow control. These are useful
512 * when there is no memory for large rx buffers and instead tx credit is being
513 * used to regulate the server sending data.
514 *
515 * When combined with stateful consumption-on-demand, this can be very effective
516 * at managing data flows through restricted circumstances. These helpers
517 * implement a golden implementation that can be bound to a stream in its priv
518 * data.
519 *
520 * The helper is sophisticated enough to contain a buflist to manage overflows
521 * on heap and preferentially drain it. RX goes through heap to guarantee the
522 * consumer can exit cleanly at any time.
523 */
524
525enum {
526 LWSDLOFLOW_STATE_READ, /* default, we want input */
527 LWSDLOFLOW_STATE_READ_COMPLETED, /* we do not need further rx, every-
528 * thing is locally buffered or used */
529 LWSDLOFLOW_STATE_READ_FAILED, /* operation has fatal error */
530};
531
532struct lws_ss_handle;
533
534typedef struct lws_flow {
536
537 struct lws_ss_handle *h;
538 struct lws_buflist *bl;
539
540 const uint8_t *data;
541 size_t len; /* bytes left in data */
542 uint32_t blseglen; /* bytes issued */
543 int32_t window;
544
547
557
568
578#define lws_ptr_diff(head, tail) \
579 ((int)((char *)(head) - (char *)(tail)))
580
598#define lws_ptr_diff_size_t(head, tail) \
599 ((size_t)(ssize_t)((char *)(head) - (char *)(tail)))
600
619lws_snprintf(char *str, size_t size, const char *format, ...) LWS_FORMAT(3);
620
639lws_strncpy(char *dest, const char *src, size_t size);
640
651static LWS_INLINE size_t
652lws_strnncpy_size(size_t size1, size_t destsize)
653{
654 if (size1 == (size_t)-1)
655 /* size1 + 1 would wrap to 0, leaving dest unterminated */
656 return destsize;
657
658 return size1 + 1u < destsize ? size1 + 1u : destsize;
659}
660
661/*
662 * Variation where we want to use the smaller of two lengths, useful when the
663 * source string is not NUL terminated. \p size1 is the source length, ie, one
664 * less than the destination size it implies.
665 */
666#define lws_strnncpy(dest, src, size1, destsize) \
667 lws_strncpy(dest, src, lws_strnncpy_size((size_t)(size1), \
668 (size_t)(destsize)))
669
683LWS_VISIBLE LWS_EXTERN const char *
684lws_nstrstr(const char *buf, size_t len, const char *name, size_t nl);
685
708LWS_VISIBLE LWS_EXTERN const char *
709lws_json_simple_find(const char *buf, size_t len, const char *name, size_t *alen);
710
729lws_json_simple_strcmp(const char *buf, size_t len, const char *name, const char *comp);
730
749lws_hex_len_to_byte_array(const char *h, size_t hlen, uint8_t *dest, int max);
750
768lws_hex_to_byte_array(const char *h, uint8_t *dest, int max);
769
784lws_hex_from_byte_array(const uint8_t *src, size_t slen, char *dest, size_t len);
785
803lws_hex_random(struct lws_context *context, char *dest, size_t len);
804
805/*
806 * lws_timingsafe_bcmp(): constant time memcmp
807 *
808 * \param a: first buffer
809 * \param b: second buffer
810 * \param len: count of bytes to compare
811 *
812 * Return 0 if the two buffers are the same, else nonzero.
813 *
814 * Always compares all of the buffer before returning, so it can't be used as
815 * a timing oracle.
816 */
817
819lws_timingsafe_bcmp(const void *a, const void *b, uint32_t len);
820
832lws_get_random(struct lws_context *context, void *buf, size_t len);
841lws_daemonize(const char *_lock_path);
849
857lws_wsi_user(struct lws *wsi);
858
866lws_ensure_user_space(struct lws *wsi);
867
875lws_wsi_tsi(struct lws *wsi);
876
888lws_set_wsi_user(struct lws *wsi, void *user);
889
915lws_parse_uri(char *p, const char **prot, const char **ads, int *port,
916 const char **path) LWS_WARN_DEPRECATED;
917
918typedef struct lws_parse_uri {
919 const char *scheme;
920 const char *host;
921 const char *path;
925
943lws_parse_uri_create(const char *uri);
944
955
957 const char *sw;
958 const char *doc;
959};
960
962lws_switches_print_help(const char *prog, const struct lws_switches *switches, size_t count);
963
964
987LWS_VISIBLE LWS_EXTERN const char *
988lws_cmdline_option(int argc, const char **argv, const char *val);
989
1016LWS_VISIBLE LWS_EXTERN const char *
1017lws_cmdline_options(int argc, const char * const *argv, const char *val, const char *last);
1018
1047
1048LWS_VISIBLE LWS_EXTERN const char *
1049lws_cmdline_options_cx(const struct lws_context *cx, const char *val, const char *last);
1050
1075LWS_VISIBLE LWS_EXTERN const char *
1076lws_cmdline_option_cx(const struct lws_context *cx, const char *val);
1077
1086LWS_VISIBLE LWS_EXTERN const char *
1087lws_cmdline_option_cx_argv0(const struct lws_context *cx);
1088
1117lws_cmdline_option_handle_builtin(int argc, const char **argv,
1118 struct lws_context_creation_info *info);
1119
1134lws_parse_iso8601(const char *ads);
1135
1139LWS_VISIBLE LWS_EXTERN unsigned long
1141
1147
1158lws_get_context(const struct lws *wsi);
1159
1170lws_get_vhost_listen_port(struct lws_vhost *vhost);
1171
1182lws_get_count_threads(struct lws_context *context);
1183
1192lws_get_parent(const struct lws *wsi);
1193
1201lws_get_child(const struct lws *wsi);
1202
1216lws_get_effective_uid_gid(struct lws_context *context, uid_t *uid, gid_t *gid);
1217
1227lws_plat_user_to_uid(const char *username, uid_t *puid);
1228
1238lws_plat_group_to_gid(const char *groupname, gid_t *pgid);
1239
1241lws_get_opaque_parent_data(const struct lws *wsi);
1242
1244lws_set_opaque_parent_data(struct lws *wsi, void *data);
1245
1247lws_get_opaque_user_data(const struct lws *wsi);
1248
1250lws_set_opaque_user_data(struct lws *wsi, void *data);
1251
1263
1273
1275lws_get_close_length(struct lws *wsi);
1276
1277LWS_VISIBLE LWS_EXTERN unsigned char *
1278lws_get_close_payload(struct lws *wsi);
1279
1293struct lws *lws_get_network_wsi(struct lws *wsi);
1294
1303lws_set_allocator(void *(*realloc)(void *ptr, size_t size, const char *reason));
1304
1305/*
1306 * Reclaimable heap occupants
1307 *
1308 * Something that keeps bytes on the heap it could recreate from storage
1309 * later (a font's dictionary, an image's payload and decoder state) can
1310 * register as reclaimable. When an allocation fails, the allocator asks the
1311 * least recently used unpinned occupants to evict what they hold, and then
1312 * retries: the code that wanted the memory, however deep in the stack, sees
1313 * only a successful allocation. The occupant notices it is no longer
1314 * resident the next time it is touched and reloads then.
1315 *
1316 * evict() is called from inside the failed allocation, so it may only free
1317 * things, unlink list nodes and set flags: it must not allocate, and must
1318 * not destroy anything another part of the stack holds a pointer to. An
1319 * occupant that is in use right now (a decoder mid-row, glyphs attached to
1320 * text being rendered) pins itself for the duration so it is skipped.
1321 */
1322
1323typedef struct lws_reclaimable {
1324 lws_dll2_t list; /* LRU: oldest at the head */
1325
1329 size_t (*evict)(struct lws_reclaimable *r);
1330
1331 size_t resident; /* bytes evict() could free now */
1332 uint16_t pins; /* nonzero: in use, not evictable */
1334
1340
1346
1352
1358
1361
1372lws_reclaim(size_t want);
1373
1387
1388enum {
1389 /*
1390 * Flags for enable and disable rxflow with reason bitmap and with
1391 * backwards-compatible single bool
1392 */
1396
1403
1404};
1405
1426lws_rx_flow_control(struct lws *wsi, int enable);
1427
1438lws_rx_flow_allow_all_protocol(const struct lws_context *context,
1439 const struct lws_protocols *protocol);
1440
1464
1465#if defined(LWS_WITH_DIR)
1466
1467typedef enum {
1468 LDOT_UNKNOWN,
1469 LDOT_FILE,
1470 LDOT_DIR,
1471 LDOT_LINK,
1472 LDOT_FIFO,
1473 LDOTT_SOCKET,
1474 LDOT_CHAR,
1475 LDOT_BLOCK
1476} lws_dir_obj_type_t;
1477
1478struct lws_dir_entry {
1479 const char *name;
1480 lws_dir_obj_type_t type;
1481};
1482
1483typedef int
1484lws_dir_callback_function(const char *dirpath, void *user,
1485 struct lws_dir_entry *lde);
1486
1487struct lws_dir_info {
1488 const char *dirpath;
1489 void *user;
1490 lws_dir_callback_function *cb;
1491 unsigned char do_toplevel_cb:1;
1492};
1493
1516lws_dir(const char *dirpath, void *user, lws_dir_callback_function cb);
1517
1536lws_dir_via_info(struct lws_dir_info *info);
1537
1538
1551lws_dir_rm_rf_cb(const char *dirpath, void *user, struct lws_dir_entry *lde);
1552
1581lws_dir_symlink_rotate(const char *cur, const char *target,
1582 const char *cur_tag, const char *prev_tag);
1583
1584
1590
1591typedef struct lws_dir_du {
1592 uint64_t size_in_bytes;
1593 uint32_t count_files;
1594} lws_dir_du_t;
1595
1609lws_dir_du_cb(const char *dirpath, void *user, struct lws_dir_entry *lde);
1610
1611
1612/*
1613 * We pass every file in the base dir through a filter, and call back on the
1614 * ones that match. Directories are ignored.
1615 *
1616 * The original path filter string may look like, eg, "sai-*.deb" or "*.txt"
1617 */
1618
1619typedef int (*lws_dir_glob_cb_t)(void *data, const char *path);
1620
1621typedef struct lws_dir_glob {
1622 const char *filter;
1623 lws_dir_glob_cb_t cb;
1624 void *user;
1625} lws_dir_glob_t;
1626
1642lws_dir_glob_cb(const char *dirpath, void *user, struct lws_dir_entry *lde);
1643
1644#endif
1645
1663
1671lws_get_tsi(struct lws *wsi);
1672
1680lws_is_ssl(struct lws *wsi);
1687lws_is_cgi(struct lws *wsi);
1688
1704lws_tls_jit_trust_blob_queury_skid(const void *_blob, size_t blen,
1705 const uint8_t *skid, size_t skid_len,
1706 const uint8_t **prpder, size_t *prder_len);
1707
1719lws_open(const char *__file, int __oflag, ...);
1720
1721struct lws_wifi_scan { /* generic wlan scan item */
1723 char ssid[32];
1724 int32_t rssi; /* divide by .count to get db */
1729};
1730
1732lws_explicit_bzero(void *p, size_t len);
1733
1734typedef struct lws_humanize_unit {
1735 const char *name; /* array ends with NULL name */
1736 uint64_t factor;
1738
1742
1743#if defined(_DEBUG)
1745lws_assert_fourcc(uint32_t fourcc, uint32_t expected);
1746#else
1747#define lws_assert_fourcc(_a, _b) do { } while (0);
1748#endif
1749
1773
1775lws_humanize(char *buf, size_t len, uint64_t value,
1776 const lws_humanize_unit_t *schema);
1777
1779lws_humanize_pad(char *p, size_t len, uint64_t v,
1780 const lws_humanize_unit_t *schema);
1781
1784
1787
1789lws_ser_wu64be(uint8_t *b, uint64_t u64);
1790
1793
1796
1797LWS_VISIBLE LWS_EXTERN uint64_t
1799
1801lws_vbi_encode(uint64_t value, void *buf);
1802
1804lws_vbi_decode(const void *buf, uint64_t *value, size_t len);
1805
1807
1808#if defined(LWS_WITH_SPAWN)
1809
1810/* opaque internal struct */
1811struct lws_spawn_piped;
1812
1813#if defined(WIN32)
1814struct _lws_siginfo_t {
1815 int retcode;
1816};
1817typedef struct _lws_siginfo_t siginfo_t;
1818#endif
1819
1826typedef struct lws_spawn_resource_us {
1827 uint64_t us_cpu_user;
1828 uint64_t us_cpu_sys;
1829
1830 uint64_t peak_mem_rss;
1831 uint64_t peak_mem_virt;
1832} lws_spawn_resource_us_t;
1833
1834typedef void (*lsp_cb_t)(void *opaque, const lws_spawn_resource_us_t *res,
1835 siginfo_t *si, int we_killed_him);
1836
1837
1857struct lws_spawn_piped_info {
1858 struct lws_dll2_owner *owner;
1859 struct lws_vhost *vh;
1860 struct lws *opt_parent;
1861
1862 const char * const *exec_array;
1863 const char **env_array;
1864 const char *protocol_name;
1865 const char *chroot_path;
1866 const char *wd;
1867
1868 struct lws_spawn_piped **plsp;
1869
1870 void *opaque;
1871
1872 lsp_cb_t reap_cb;
1873
1874 lws_spawn_resource_us_t *res;
1875
1876 lws_usec_t timeout_us;
1877 int max_log_lines;
1878 int tsi;
1879
1880 const struct lws_role_ops *ops; /* NULL is raw file */
1881
1882 uint8_t disable_ctrlc;
1883 uint8_t pty_mode;
1884
1885 const char *cgroup_name_suffix;
1886 int *p_cgroup_ret;
1887};
1888
1910LWS_VISIBLE LWS_EXTERN struct lws_spawn_piped *
1911lws_spawn_piped(const struct lws_spawn_piped_info *lspi);
1912
1913/*
1914 * lws_spawn_piped_kill_child_process() - attempt to kill child process
1915 *
1916 * \p lsp: child object to kill
1917 *
1918 * Attempts to signal the child process in \p lsp to terminate.
1919 */
1921lws_spawn_piped_kill_child_process(struct lws_spawn_piped *lsp);
1922
1931lws_spawn_get_stdwsi_open_count(struct lws_spawn_piped *lsp);
1932
1949lws_spawn_stdwsi_closed(struct lws_spawn_piped *lsp, struct lws *wsi);
1950
1951/*
1952 * lws_spawn_closedown_stdwsis() - forcibly close the spawner side of stdwsi pipes
1953 *
1954 * \p lsp: the spawn object
1955 *
1956 * Closes the spawner side of all the stdwsi for an lsp that are still open.
1957 */
1959lws_spawn_closedown_stdwsis(struct lws_spawn_piped *lsp);
1960
1972lws_spawn_get_stdfd(struct lws *wsi);
1973
1984lws_spawn_get_fd_stdxxx(struct lws_spawn_piped *lsp, int std_idx);
1985
2004lws_spawn_prepare_self_cgroup(const char *user, const char *group);
2005
2018lws_spawn_get_self_cgroup(char *cgroup, size_t max);
2019
2020#endif
2021
2023 const char *layers_path; /* where layers live */
2024 const char *overlay_path; /* where overlay instantiations live */
2025
2026 char mp[256]; /* mountpoint path */
2027 char ovname[64]; /* unique name for mount instance */
2028 char distro[64]; /* unique name for layer source */
2029
2030#if defined(__linux__)
2031 const char *layers[4]; /* distro layers, like "base", "env" */
2032#endif
2033};
2034
2075
2090
2091#define LWS_MINILEX_FAIL -1
2092#define LWS_MINILEX_CONTINUE 0
2093#define LWS_MINILEX_MATCH 1
2094
2122lws_minilex_parse(const uint8_t *lex, int16_t *ps, const uint8_t c,
2123 int *match);
2124
2125/*
2126 * Reports the number of significant bits (from the left) that is needed to
2127 * represent u. So if u is 0x80, result is 8.
2128 */
2129
2130LWS_VISIBLE LWS_EXTERN unsigned int
2131lws_sigbits(uintptr_t u);
2132
2143lws_wol(struct lws_context *ctx, const char *ip_or_NULL, uint8_t *mac_6_bytes);
struct lws_dll2 lws_dll2_t
uint32_t blseglen
Definition lws-misc.h:542
int private_source_idx
Definition lws-misc.h:458
uint16_t port
Definition lws-misc.h:922
const uint8_t * data
Definition lws-misc.h:540
char ssid[32]
Definition lws-misc.h:1723
struct lws_buflist ** head_upstream
Definition lws-misc.h:456
const char * path
Definition lws-misc.h:921
size_t len
Definition lws-misc.h:541
struct lws_ss_handle * h
Definition lws-misc.h:537
uint8_t state
Definition lws-misc.h:545
struct lws_buflist * bl
Definition lws-misc.h:538
uint8_t channel
Definition lws-misc.h:1727
int32_t window
Definition lws-misc.h:543
const char * scheme
Definition lws-misc.h:919
const char * doc
Definition lws-misc.h:958
uint8_t authmode
Definition lws-misc.h:1728
unsigned int ss_flags
Definition lws-misc.h:463
uint8_t count
Definition lws-misc.h:1726
lws_dll2_t list
Definition lws-misc.h:1324
const uint8_t * buf
Definition lws-misc.h:461
size_t(* evict)(struct lws_reclaimable *r)
Definition lws-misc.h:1329
struct lws_dll2_owner owner
Definition lws-misc.h:310
uint16_t pins
Definition lws-misc.h:1332
struct lws_buflist ** private_heads
Definition lws-misc.h:457
struct lws_wifi_scan * next
Definition lws-misc.h:1722
lws_dll2_t list
Definition lws-misc.h:535
const char * name
Definition lws-misc.h:1735
lws_wsmsg_transfer_cb optional_cb
Definition lws-misc.h:459
void * opaque
Definition lws-misc.h:460
const char * sw
Definition lws-misc.h:957
uint8_t bssid[6]
Definition lws-misc.h:1725
const char * host
Definition lws-misc.h:920
int32_t rssi
Definition lws-misc.h:1724
LWS_VISIBLE LWS_EXTERN void lws_buflist2_destroy_all_segments(struct lws_buflist2_owner *owner)
LWS_VISIBLE LWS_EXTERN int lws_wsmsg_append(lws_wsmsg_info_t *info)
LWS_VISIBLE LWS_EXTERN lws_fragbuf_t * lws_fragbuf_create(size_t units, size_t unit_size)
LWS_VISIBLE LWS_EXTERN void lws_cmdline_option_handle_builtin(int argc, const char **argv, struct lws_context_creation_info *info)
LWS_VISIBLE LWS_EXTERN int lws_ensure_user_space(struct lws *wsi)
LWS_VISIBLE LWS_EXTERN int lws_hex_to_byte_array(const char *h, uint8_t *dest, int max)
LWS_VISIBLE LWS_EXTERN const char * lws_cmdline_option_cx(const struct lws_context *cx, const char *val)
LWS_VISIBLE LWS_EXTERN void * lws_buflist_get_frag_start_or_NULL(struct lws_buflist **head)
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_parse_uri(char *p, const char **prot, const char **ads, int *port, const char **path) LWS_WARN_DEPRECATED
LWS_VISIBLE LWS_EXTERN void lws_switches_print_help(const char *prog, const struct lws_switches *switches, size_t count)
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_buflist_append_segment_take_ownership(struct lws_buflist **head, uint8_t *buf, size_t len)
LWS_VISIBLE LWS_EXTERN void lws_buflist_describe(struct lws_buflist **head, void *id, const char *reason)
LWS_VISIBLE LWS_EXTERN int lws_open(const char *__file, int __oflag,...)
LWS_VISIBLE LWS_EXTERN size_t lws_buflist2_next_segment_len(struct lws_buflist2_owner *owner, uint8_t **buf)
LWS_VISIBLE LWS_EXTERN void lws_reclaimable_add(lws_reclaimable_t *r)
LWS_VISIBLE LWS_EXTERN void lws_reclaimable_touch(lws_reclaimable_t *r)
LWS_VISIBLE LWS_EXTERN int lws_wsi_tsi(struct lws *wsi)
LWS_VISIBLE LWS_EXTERN uint16_t lws_ser_ru16be(const uint8_t *b)
LWS_VISIBLE LWS_EXTERN void lws_clear_child_pending_on_writable(struct lws *wsi) LWS_WARN_DEPRECATED
LWS_VISIBLE LWS_EXTERN lws_usec_t lws_now_usecs(void)
LWS_VISIBLE LWS_EXTERN void lws_explicit_bzero(void *p, size_t len)
LWS_VISIBLE LWS_EXTERN_FOR_DATA const lws_humanize_unit_t humanize_schema_si_bytes[7]
Definition lws-misc.h:1740
LWS_VISIBLE LWS_EXTERN struct lws * lws_get_network_wsi(struct lws *wsi)
LWS_VISIBLE LWS_EXTERN int lws_snprintf(char *str, size_t size, const char *format,...) LWS_FORMAT(3)
LWS_VISIBLE LWS_EXTERN void lws_get_effective_uid_gid(struct lws_context *context, uid_t *uid, gid_t *gid)
void(* lws_wsmsg_transfer_cb)(struct lws_wsmsg_info *info)
Definition lws-misc.h:453
LWS_VISIBLE LWS_EXTERN int lws_is_ssl(struct lws *wsi)
LWS_VISIBLE LWS_EXTERN size_t lws_get_allocated_heap(void)
LWS_VISIBLE LWS_EXTERN const char * lws_cmdline_option(int argc, const char **argv, const char *val)
LWS_VISIBLE LWS_EXTERN_FOR_DATA const lws_humanize_unit_t humanize_schema_si[7]
Definition lws-misc.h:1739
LWS_VISIBLE LWS_EXTERN unsigned long lws_now_secs(void)
LWS_VISIBLE LWS_EXTERN void lws_wsmsg_destroy(struct lws_buflist *private_heads[], size_t count_private_heads)
LWS_VISIBLE LWS_EXTERN size_t lws_get_random(struct lws_context *context, void *buf, size_t len)
LWS_VISIBLE LWS_EXTERN const char * lws_cmdline_options(int argc, const char *const *argv, const char *val, const char *last)
LWS_VISIBLE LWS_EXTERN int lws_buflist_linear_copy(struct lws_buflist **head, size_t ofs, uint8_t *buf, size_t len)
LWS_VISIBLE LWS_EXTERN void lws_reclaimable_remove(lws_reclaimable_t *r)
LWS_VISIBLE LWS_EXTERN void lws_reclaimable_unpin(lws_reclaimable_t *r)
LWS_VISIBLE LWS_EXTERN void lws_heap_limit_set(size_t bytes)
LWS_VISIBLE LWS_EXTERN int lws_is_cgi(struct lws *wsi)
LWS_VISIBLE LWS_EXTERN unsigned char * lws_get_close_payload(struct lws *wsi)
LWS_VISIBLE LWS_EXTERN uint32_t lws_crc32(uint32_t crc, const void *buf, size_t len)
LWS_VISIBLE LWS_EXTERN int lws_hex_len_to_byte_array(const char *h, size_t hlen, uint8_t *dest, int max)
LWS_VISIBLE LWS_EXTERN const char * lws_json_simple_find(const char *buf, size_t len, const char *name, size_t *alen)
struct lws_parse_uri lws_parse_uri_t
LWS_VISIBLE LWS_EXTERN void lws_fragbuf_destroy(lws_fragbuf_t **fb)
LWS_VISIBLE LWS_EXTERN void lws_rx_flow_allow_all_protocol(const struct lws_context *context, const struct lws_protocols *protocol)
LWS_VISIBLE LWS_EXTERN size_t lws_buflist_next_segment_len(struct lws_buflist **head, uint8_t **buf)
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_get_count_threads(struct lws_context *context)
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_get_vhost_listen_port(struct lws_vhost *vhost)
LWS_VISIBLE LWS_EXTERN struct lws_context *LWS_WARN_UNUSED_RESULT lws_get_context(const struct lws *wsi)
LWS_VISIBLE LWS_EXTERN size_t lws_remaining_packet_payload(struct lws *wsi)
LWS_VISIBLE LWS_EXTERN int lws_humanize(char *buf, size_t len, uint64_t value, const lws_humanize_unit_t *schema)
LWS_VISIBLE LWS_EXTERN void lws_set_opaque_user_data(struct lws *wsi, void *data)
#define lws_assert_fourcc(_a, _b)
Definition lws-misc.h:1747
LWS_VISIBLE LWS_EXTERN struct lws *LWS_WARN_UNUSED_RESULT lws_get_child(const struct lws *wsi)
LWS_VISIBLE LWS_EXTERN uint32_t lws_ser_ru32be(const uint8_t *b)
LWS_VISIBLE LWS_EXTERN size_t lws_buflist_total_len(struct lws_buflist **head)
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_buflist2_append_segment_take_ownership(struct lws_buflist2_owner *owner, uint8_t *buf, size_t len)
LWS_VISIBLE LWS_EXTERN lws_stateful_ret_t lws_flow_feed(lws_flow_t *flow)
LWS_VISIBLE LWS_EXTERN void lws_ser_wu16be(uint8_t *b, uint16_t u)
LWS_VISIBLE LWS_EXTERN void lws_set_wsi_user(struct lws *wsi, void *user)
LWS_VISIBLE LWS_EXTERN lws_stateful_ret_t lws_flow_req(lws_flow_t *flow)
struct lws_wsmsg_info lws_wsmsg_info_t
LWS_VISIBLE LWS_EXTERN size_t lws_buflist_use_segment(struct lws_buflist **head, size_t len)
struct lws_flow lws_flow_t
struct lws_reclaimable lws_reclaimable_t
LWS_VISIBLE LWS_EXTERN void * lws_buflist2_get_frag_start_or_NULL(struct lws_buflist2_owner *owner)
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_buflist_append_segment(struct lws_buflist **head, const uint8_t *buf, size_t len)
LWS_VISIBLE LWS_EXTERN unsigned int lws_fragbuf_pieces(const lws_fragbuf_t *fb)
LWS_VISIBLE LWS_EXTERN const char * lws_cmdline_option_cx_argv0(const struct lws_context *cx)
LWS_VISIBLE LWS_EXTERN const char * lws_nstrstr(const char *buf, size_t len, const char *name, size_t nl)
LWS_VISIBLE LWS_EXTERN int lws_get_close_length(struct lws *wsi)
LWS_VISIBLE LWS_EXTERN int lws_tls_jit_trust_blob_queury_skid(const void *_blob, size_t blen, const uint8_t *skid, size_t skid_len, const uint8_t **prpder, size_t *prder_len)
LWS_VISIBLE LWS_EXTERN void lws_set_opaque_parent_data(struct lws *wsi, void *data)
LWS_VISIBLE LWS_EXTERN size_t lws_reclaim(size_t want)
LWS_VISIBLE LWS_EXTERN const char * lws_cmdline_options_cx(const struct lws_context *cx, const char *val, const char *last)
LWS_VISIBLE LWS_EXTERN int lws_json_simple_strcmp(const char *buf, size_t len, const char *name, const char *comp)
LWS_VISIBLE LWS_EXTERN const char *LWS_WARN_UNUSED_RESULT lws_get_library_version(void)
LWS_VISIBLE LWS_EXTERN void lws_reclaimable_pin(lws_reclaimable_t *r)
LWS_VISIBLE LWS_EXTERN int lws_get_child_pending_on_writable(const struct lws *wsi) LWS_WARN_DEPRECATED
LWS_VISIBLE LWS_EXTERN int lws_vbi_encode(uint64_t value, void *buf)
LWS_VISIBLE LWS_EXTERN uint64_t lws_ser_ru64be(const uint8_t *b)
LWS_VISIBLE LWS_EXTERN int lws_humanize_pad(char *p, size_t len, uint64_t v, const lws_humanize_unit_t *schema)
LWS_VISIBLE LWS_EXTERN int lws_get_tsi(struct lws *wsi)
LWS_VISIBLE LWS_EXTERN int lws_buflist_linear_use(struct lws_buflist **head, uint8_t *buf, size_t len)
LWS_VISIBLE LWS_EXTERN int lws_vbi_decode(const void *buf, uint64_t *value, size_t len)
LWS_VISIBLE LWS_EXTERN void lws_ser_wu64be(uint8_t *b, uint64_t u64)
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_daemonize(const char *_lock_path)
LWS_VISIBLE LWS_EXTERN void lws_hex_from_byte_array(const uint8_t *src, size_t slen, char *dest, size_t len)
LWS_VISIBLE LWS_EXTERN void lws_ser_wu32be(uint8_t *b, uint32_t u32)
LWS_VISIBLE LWS_EXTERN void * lws_get_opaque_parent_data(const struct lws *wsi)
struct lws_fragbuf lws_fragbuf_t
Definition lws-misc.h:68
LWS_VISIBLE LWS_EXTERN void lws_set_allocator(void *(*realloc)(void *ptr, size_t size, const char *reason))
LWS_VISIBLE LWS_EXTERN int lws_buflist_fragment_use(struct lws_buflist **head, uint8_t *buf, size_t len, char *frag_first, char *frag_fin)
LWS_VISIBLE LWS_EXTERN size_t lws_buflist2_use_segment(struct lws_buflist2_owner *owner, size_t len)
LWS_VISIBLE LWS_EXTERN int lws_rx_flow_control(struct lws *wsi, int enable)
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_buflist2_append_segment(struct lws_buflist2_owner *owner, const uint8_t *buf, size_t len)
LWS_VISIBLE LWS_EXTERN int lws_plat_group_to_gid(const char *groupname, gid_t *pgid)
LWS_VISIBLE LWS_EXTERN lws_fragbuf_t * lws_fragbuf_create_cap(size_t units, size_t unit_size, size_t cap)
LWS_VISIBLE LWS_EXTERN int lws_timingsafe_bcmp(const void *a, const void *b, uint32_t len)
LWS_VISIBLE LWS_EXTERN void * lws_get_opaque_user_data(const struct lws *wsi)
LWS_VISIBLE LWS_EXTERN int lws_plat_user_to_uid(const char *username, uid_t *puid)
LWS_VISIBLE LWS_EXTERN uint8_t * lws_fragbuf_at(const lws_fragbuf_t *fb, size_t ofs, size_t *avail)
LWS_VISIBLE LWS_EXTERN_FOR_DATA const lws_humanize_unit_t humanize_schema_us[8]
Definition lws-misc.h:1741
LWS_VISIBLE LWS_EXTERN lws_parse_uri_t *LWS_WARN_UNUSED_RESULT lws_parse_uri_create(const char *uri)
LWS_VISIBLE LWS_EXTERN void * lws_wsi_user(struct lws *wsi)
LWS_VISIBLE LWS_EXTERN char * lws_strncpy(char *dest, const char *src, size_t size)
LWS_VISIBLE LWS_EXTERN int lws_buflist2_fragment_use(struct lws_buflist2_owner *owner, uint8_t *buf, size_t len, char *frag_first, char *frag_fin)
LWS_VISIBLE LWS_EXTERN void lws_parse_uri_destroy(lws_parse_uri_t **pcuri)
struct lws_humanize_unit lws_humanize_unit_t
LWS_VISIBLE LWS_EXTERN lws_usec_t lws_parse_iso8601(const char *ads)
LWS_VISIBLE LWS_EXTERN int lws_hex_random(struct lws_context *context, char *dest, size_t len)
LWS_VISIBLE LWS_EXTERN void lws_buflist_destroy_all_segments(struct lws_buflist **head)
LWS_VISIBLE LWS_EXTERN struct lws *LWS_WARN_UNUSED_RESULT lws_get_parent(const struct lws *wsi)
LWS_VISIBLE LWS_EXTERN uint8_t * lws_fragbuf_unit(const lws_fragbuf_t *fb, size_t unit)
@ LWS_RXFLOW_REASON_APPLIES_DISABLE
Definition lws-misc.h:1401
@ LWS_RXFLOW_REASON_APPLIES
Definition lws-misc.h:1397
@ LWS_RXFLOW_REASON_USER_BOOL
Definition lws-misc.h:1393
@ LWS_RXFLOW_REASON_APPLIES_ENABLE_BIT
Definition lws-misc.h:1398
@ LWS_RXFLOW_REASON_APPLIES_ENABLE
Definition lws-misc.h:1399
@ LWS_RXFLOW_REASON_FLAG_PROCESS_NOW
Definition lws-misc.h:1402
@ LWS_RXFLOW_REASON_HTTP_RXBUFFER
Definition lws-misc.h:1394
@ LWS_RXFLOW_REASON_H2_PPS_PENDING
Definition lws-misc.h:1395
@ LWSDLOFLOW_STATE_READ
Definition lws-misc.h:526
@ LWSDLOFLOW_STATE_READ_COMPLETED
Definition lws-misc.h:527
@ LWSDLOFLOW_STATE_READ_FAILED
Definition lws-misc.h:529
#define LWS_EXTERN_FOR_DATA
unsigned short uint16_t
unsigned int uint32_t
#define LWS_WARN_DEPRECATED
#define LWS_INLINE
#define LWS_FORMAT(string_index)
#define LWS_EXTERN
int64_t lws_usec_t
unsigned char uint8_t
lws_stateful_ret_t
#define LWS_WARN_UNUSED_RESULT
#define LWS_VISIBLE
int lws_filefd_type
LWS_VISIBLE LWS_EXTERN int lws_fsmount_mount(struct lws_fsmount *fsm)
char mp[256]
Definition lws-misc.h:2026
LWS_VISIBLE LWS_EXTERN int lws_fsmount_unmount(struct lws_fsmount *fsm)
char ovname[64]
Definition lws-misc.h:2027
char distro[64]
Definition lws-misc.h:2028
LWS_VISIBLE LWS_EXTERN unsigned int lws_sigbits(uintptr_t u)
LWS_VISIBLE LWS_EXTERN int lws_minilex_parse(const uint8_t *lex, int16_t *ps, const uint8_t c, int *match)
const char * overlay_path
Definition lws-misc.h:2024
const char * layers_path
Definition lws-misc.h:2023
LWS_VISIBLE LWS_EXTERN int lws_wol(struct lws_context *ctx, const char *ip_or_NULL, uint8_t *mac_6_bytes)