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_buflist2_owner *upstream; /* the upstream buflist */
457 struct lws_buflist2_owner *private_owners; /* array of private reassembly buflists */
458 int private_source_idx; /* which index to use in private_owners */
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
504
505/*
506 * lws_wsmsg_destroy() - free all allocations in private buflists
507 *
508 * \param private_owners: the array of private buflists
509 * \param count_private_owners: the number of private buflists
510 */
513 size_t count_private_owners);
514
515
516
517/*
518 * Optional helpers for closely-managed stream flow control. These are useful
519 * when there is no memory for large rx buffers and instead tx credit is being
520 * used to regulate the server sending data.
521 *
522 * When combined with stateful consumption-on-demand, this can be very effective
523 * at managing data flows through restricted circumstances. These helpers
524 * implement a golden implementation that can be bound to a stream in its priv
525 * data.
526 *
527 * The helper is sophisticated enough to contain a buflist to manage overflows
528 * on heap and preferentially drain it. RX goes through heap to guarantee the
529 * consumer can exit cleanly at any time.
530 */
531
532enum {
533 LWSDLOFLOW_STATE_READ, /* default, we want input */
534 LWSDLOFLOW_STATE_READ_COMPLETED, /* we do not need further rx, every-
535 * thing is locally buffered or used */
536 LWSDLOFLOW_STATE_READ_FAILED, /* operation has fatal error */
537};
538
539struct lws_ss_handle;
540
541typedef struct lws_flow {
543
544 struct lws_ss_handle *h;
545 struct lws_buflist *bl;
546
547 const uint8_t *data;
548 size_t len; /* bytes left in data */
549 uint32_t blseglen; /* bytes issued */
550 int32_t window;
551
554
564
575
585#define lws_ptr_diff(head, tail) \
586 ((int)((char *)(head) - (char *)(tail)))
587
605#define lws_ptr_diff_size_t(head, tail) \
606 ((size_t)(ssize_t)((char *)(head) - (char *)(tail)))
607
626lws_snprintf(char *str, size_t size, const char *format, ...) LWS_FORMAT(3);
627
646lws_strncpy(char *dest, const char *src, size_t size);
647
658static LWS_INLINE size_t
659lws_strnncpy_size(size_t size1, size_t destsize)
660{
661 if (size1 == (size_t)-1)
662 /* size1 + 1 would wrap to 0, leaving dest unterminated */
663 return destsize;
664
665 return size1 + 1u < destsize ? size1 + 1u : destsize;
666}
667
668/*
669 * Variation where we want to use the smaller of two lengths, useful when the
670 * source string is not NUL terminated. \p size1 is the source length, ie, one
671 * less than the destination size it implies.
672 */
673#define lws_strnncpy(dest, src, size1, destsize) \
674 lws_strncpy(dest, src, lws_strnncpy_size((size_t)(size1), \
675 (size_t)(destsize)))
676
693lws_check_utf8(unsigned char *state, const unsigned char *buf, size_t len);
694
711lws_utf8_trim_partial(char *s, size_t len);
712
726LWS_VISIBLE LWS_EXTERN const char *
727lws_nstrstr(const char *buf, size_t len, const char *name, size_t nl);
728
751LWS_VISIBLE LWS_EXTERN const char *
752lws_json_simple_find(const char *buf, size_t len, const char *name, size_t *alen);
753
772lws_json_simple_strcmp(const char *buf, size_t len, const char *name, const char *comp);
773
792lws_hex_len_to_byte_array(const char *h, size_t hlen, uint8_t *dest, int max);
793
811lws_hex_to_byte_array(const char *h, uint8_t *dest, int max);
812
827lws_hex_from_byte_array(const uint8_t *src, size_t slen, char *dest, size_t len);
828
846lws_hex_random(struct lws_context *context, char *dest, size_t len);
847
848/*
849 * lws_timingsafe_bcmp(): constant time memcmp
850 *
851 * \param a: first buffer
852 * \param b: second buffer
853 * \param len: count of bytes to compare
854 *
855 * Return 0 if the two buffers are the same, else nonzero.
856 *
857 * Always compares all of the buffer before returning, so it can't be used as
858 * a timing oracle.
859 */
860
862lws_timingsafe_bcmp(const void *a, const void *b, uint32_t len);
863
875lws_get_random(struct lws_context *context, void *buf, size_t len);
884lws_daemonize(const char *_lock_path);
892
900lws_wsi_user(struct lws *wsi);
901
909lws_ensure_user_space(struct lws *wsi);
910
918lws_wsi_tsi(struct lws *wsi);
919
931lws_set_wsi_user(struct lws *wsi, void *user);
932
958lws_parse_uri(char *p, const char **prot, const char **ads, int *port,
959 const char **path) LWS_WARN_DEPRECATED;
960
961typedef struct lws_parse_uri {
962 const char *scheme;
963 const char *host;
964 const char *path;
968
986lws_parse_uri_create(const char *uri);
987
998
1000 const char *sw;
1001 const char *doc;
1002};
1003
1005lws_switches_print_help(const char *prog, const struct lws_switches *switches, size_t count);
1006
1007
1030LWS_VISIBLE LWS_EXTERN const char *
1031lws_cmdline_option(int argc, const char **argv, const char *val);
1032
1059LWS_VISIBLE LWS_EXTERN const char *
1060lws_cmdline_options(int argc, const char * const *argv, const char *val, const char *last);
1061
1090
1091LWS_VISIBLE LWS_EXTERN const char *
1092lws_cmdline_options_cx(const struct lws_context *cx, const char *val, const char *last);
1093
1118LWS_VISIBLE LWS_EXTERN const char *
1119lws_cmdline_option_cx(const struct lws_context *cx, const char *val);
1120
1129LWS_VISIBLE LWS_EXTERN const char *
1130lws_cmdline_option_cx_argv0(const struct lws_context *cx);
1131
1164lws_cmdline_option_handle_builtin(int argc, const char **argv,
1165 struct lws_context_creation_info *info);
1166
1167#if defined(LWS_WITH_CRASH_BACKTRACE)
1190lws_crash_backtrace_install(void);
1191#endif
1192
1207lws_parse_iso8601(const char *ads);
1208
1212LWS_VISIBLE LWS_EXTERN unsigned long
1214
1220
1231lws_get_context(const struct lws *wsi);
1232
1243lws_get_vhost_listen_port(struct lws_vhost *vhost);
1244
1255lws_get_count_threads(struct lws_context *context);
1256
1265lws_get_parent(const struct lws *wsi);
1266
1274lws_get_child(const struct lws *wsi);
1275
1289lws_get_effective_uid_gid(struct lws_context *context, uid_t *uid, gid_t *gid);
1290
1300lws_plat_user_to_uid(const char *username, uid_t *puid);
1301
1311lws_plat_group_to_gid(const char *groupname, gid_t *pgid);
1312
1314lws_get_opaque_parent_data(const struct lws *wsi);
1315
1317lws_set_opaque_parent_data(struct lws *wsi, void *data);
1318
1320lws_get_opaque_user_data(const struct lws *wsi);
1321
1323lws_set_opaque_user_data(struct lws *wsi, void *data);
1324
1336
1346
1348lws_get_close_length(struct lws *wsi);
1349
1350LWS_VISIBLE LWS_EXTERN unsigned char *
1351lws_get_close_payload(struct lws *wsi);
1352
1381lws_wsi_close_cause(struct lws *wsi, char *buf, size_t len);
1382
1396struct lws *lws_get_network_wsi(struct lws *wsi);
1397
1406lws_set_allocator(void *(*realloc)(void *ptr, size_t size, const char *reason));
1407
1408/*
1409 * Reclaimable heap occupants
1410 *
1411 * Something that keeps bytes on the heap it could recreate from storage
1412 * later (a font's dictionary, an image's payload and decoder state) can
1413 * register as reclaimable. When an allocation fails, the allocator asks the
1414 * least recently used unpinned occupants to evict what they hold, and then
1415 * retries: the code that wanted the memory, however deep in the stack, sees
1416 * only a successful allocation. The occupant notices it is no longer
1417 * resident the next time it is touched and reloads then.
1418 *
1419 * evict() is called from inside the failed allocation, so it may only free
1420 * things, unlink list nodes and set flags: it must not allocate, and must
1421 * not destroy anything another part of the stack holds a pointer to. An
1422 * occupant that is in use right now (a decoder mid-row, glyphs attached to
1423 * text being rendered) pins itself for the duration so it is skipped.
1424 */
1425
1426typedef struct lws_reclaimable {
1427 lws_dll2_t list; /* LRU: oldest at the head */
1428
1432 size_t (*evict)(struct lws_reclaimable *r);
1433
1434 size_t resident; /* bytes evict() could free now */
1435 uint16_t pins; /* nonzero: in use, not evictable */
1437
1443
1449
1455
1461
1464
1475lws_reclaim(size_t want);
1476
1490
1491enum {
1492 /*
1493 * Flags for enable and disable rxflow with reason bitmap and with
1494 * backwards-compatible single bool. b5..b0 are the user's, the
1495 * reasons above them are the library's own.
1496 */
1501 /* b11..b9 are free for more library reasons */
1502
1509
1510};
1511
1532lws_rx_flow_control(struct lws *wsi, int enable);
1533
1544lws_rx_flow_allow_all_protocol(const struct lws_context *context,
1545 const struct lws_protocols *protocol);
1546
1570
1571#if defined(LWS_WITH_DIR)
1572
1573typedef enum {
1574 LDOT_UNKNOWN,
1575 LDOT_FILE,
1576 LDOT_DIR,
1577 LDOT_LINK,
1578 LDOT_FIFO,
1579 LDOTT_SOCKET,
1580 LDOT_CHAR,
1581 LDOT_BLOCK
1582} lws_dir_obj_type_t;
1583
1584struct lws_dir_entry {
1585 const char *name;
1586 lws_dir_obj_type_t type;
1587};
1588
1589typedef int
1590lws_dir_callback_function(const char *dirpath, void *user,
1591 struct lws_dir_entry *lde);
1592
1593struct lws_dir_info {
1594 const char *dirpath;
1595 void *user;
1596 lws_dir_callback_function *cb;
1597 unsigned char do_toplevel_cb:1;
1598};
1599
1625lws_dir(const char *dirpath, void *user, lws_dir_callback_function cb);
1626
1649lws_dir_via_info(struct lws_dir_info *info);
1650
1651
1675lws_dir_rm_rf_cb(const char *dirpath, void *user, struct lws_dir_entry *lde);
1676
1705lws_dir_symlink_rotate(const char *cur, const char *target,
1706 const char *cur_tag, const char *prev_tag);
1707
1708
1714
1715typedef struct lws_dir_du {
1716 uint64_t size_in_bytes;
1717 uint32_t count_files;
1718} lws_dir_du_t;
1719
1733lws_dir_du_cb(const char *dirpath, void *user, struct lws_dir_entry *lde);
1734
1735
1736/*
1737 * We pass every file in the base dir through a filter, and call back on the
1738 * ones that match. Directories are ignored.
1739 *
1740 * The original path filter string may look like, eg, "sai-*.deb" or "*.txt"
1741 */
1742
1743typedef int (*lws_dir_glob_cb_t)(void *data, const char *path);
1744
1745typedef struct lws_dir_glob {
1746 const char *filter;
1747 lws_dir_glob_cb_t cb;
1748 void *user;
1749} lws_dir_glob_t;
1750
1767lws_dir_glob_cb(const char *dirpath, void *user, struct lws_dir_entry *lde);
1768
1769#endif
1770
1788
1796lws_get_tsi(struct lws *wsi);
1797
1805lws_is_ssl(struct lws *wsi);
1812lws_is_cgi(struct lws *wsi);
1813
1829lws_tls_jit_trust_blob_queury_skid(const void *_blob, size_t blen,
1830 const uint8_t *skid, size_t skid_len,
1831 const uint8_t **prpder, size_t *prder_len);
1832
1844lws_open(const char *__file, int __oflag, ...);
1845
1846struct lws_wifi_scan { /* generic wlan scan item */
1848 char ssid[32];
1849 int32_t rssi; /* divide by .count to get db */
1854};
1855
1857lws_explicit_bzero(void *p, size_t len);
1858
1859typedef struct lws_humanize_unit {
1860 const char *name; /* array ends with NULL name */
1861 uint64_t factor;
1863
1867
1868#if defined(_DEBUG)
1870lws_assert_fourcc(uint32_t fourcc, uint32_t expected);
1871#else
1872#define lws_assert_fourcc(_a, _b) do { } while (0);
1873#endif
1874
1898
1900lws_humanize(char *buf, size_t len, uint64_t value,
1901 const lws_humanize_unit_t *schema);
1902
1904lws_humanize_pad(char *p, size_t len, uint64_t v,
1905 const lws_humanize_unit_t *schema);
1906
1909
1912
1914lws_ser_wu64be(uint8_t *b, uint64_t u64);
1915
1918
1921
1922LWS_VISIBLE LWS_EXTERN uint64_t
1924
1926lws_vbi_encode(uint64_t value, void *buf);
1927
1929lws_vbi_decode(const void *buf, uint64_t *value, size_t len);
1930
1932
1933#if defined(LWS_WITH_SPAWN)
1934
1935/* opaque internal struct */
1936struct lws_spawn_piped;
1937
1938#if defined(WIN32)
1939struct _lws_siginfo_t {
1940 int retcode;
1941};
1942typedef struct _lws_siginfo_t siginfo_t;
1943#endif
1944
1966typedef struct lws_spawn_resource_us {
1967 uint64_t us_cpu_user;
1968 uint64_t us_cpu_sys;
1969
1970 uint64_t peak_mem_rss;
1971 uint64_t peak_mem_virt;
1972} lws_spawn_resource_us_t;
1973
1974typedef void (*lsp_cb_t)(void *opaque, const lws_spawn_resource_us_t *res,
1975 siginfo_t *si, int we_killed_him);
1976
1977
1999struct lws_spawn_piped_info {
2000 struct lws_dll2_owner *owner;
2001 struct lws_vhost *vh;
2002 struct lws *opt_parent;
2003
2004 const char * const *exec_array;
2005 const char **env_array;
2006 const char *protocol_name;
2007 const char *chroot_path;
2008 const char *wd;
2009
2010 struct lws_spawn_piped **plsp;
2011
2012 void *opaque;
2013
2014 lsp_cb_t reap_cb;
2015
2016 lws_spawn_resource_us_t *res;
2017
2018 lws_usec_t timeout_us;
2019 int max_log_lines;
2020 int tsi;
2021
2022 const struct lws_role_ops *ops; /* NULL is raw file */
2023
2024 uint8_t disable_ctrlc;
2025 uint8_t pty_mode;
2026
2027 const char *cgroup_name_suffix;
2028 int *p_cgroup_ret;
2029};
2030
2052LWS_VISIBLE LWS_EXTERN struct lws_spawn_piped *
2053lws_spawn_piped(const struct lws_spawn_piped_info *lspi);
2054
2055/*
2056 * lws_spawn_piped_kill_child_process() - attempt to kill child process
2057 *
2058 * \p lsp: child object to kill
2059 *
2060 * Attempts to signal the child process in \p lsp to terminate.
2061 */
2063lws_spawn_piped_kill_child_process(struct lws_spawn_piped *lsp);
2064
2083lws_spawn_piped_destroy(struct lws_spawn_piped **lsp);
2084
2093lws_spawn_get_stdwsi_open_count(struct lws_spawn_piped *lsp);
2094
2111lws_spawn_stdwsi_closed(struct lws_spawn_piped *lsp, struct lws *wsi);
2112
2113/*
2114 * lws_spawn_closedown_stdwsis() - forcibly close the spawner side of stdwsi pipes
2115 *
2116 * \p lsp: the spawn object
2117 *
2118 * Closes the spawner side of all the stdwsi for an lsp that are still open.
2119 */
2121lws_spawn_closedown_stdwsis(struct lws_spawn_piped *lsp);
2122
2134lws_spawn_get_stdfd(struct lws *wsi);
2135
2146lws_spawn_get_fd_stdxxx(struct lws_spawn_piped *lsp, int std_idx);
2147
2166lws_spawn_prepare_self_cgroup(const char *user, const char *group);
2167
2180lws_spawn_get_self_cgroup(char *cgroup, size_t max);
2181
2182#endif
2183
2185 const char *layers_path; /* where layers live */
2186 const char *overlay_path; /* where overlay instantiations live */
2187
2188 char mp[256]; /* mountpoint path */
2189 char ovname[64]; /* unique name for mount instance */
2190 char distro[64]; /* unique name for layer source */
2191
2192#if defined(__linux__)
2193 const char *layers[4]; /* distro layers, like "base", "env" */
2194#endif
2195};
2196
2237
2252
2253#define LWS_MINILEX_FAIL -1
2254#define LWS_MINILEX_CONTINUE 0
2255#define LWS_MINILEX_MATCH 1
2256
2284lws_minilex_parse(const uint8_t *lex, int16_t *ps, const uint8_t c,
2285 int *match);
2286
2287/*
2288 * Reports the number of significant bits (from the left) that is needed to
2289 * represent u. So if u is 0x80, result is 8.
2290 */
2291
2292LWS_VISIBLE LWS_EXTERN unsigned int
2293lws_sigbits(uintptr_t u);
2294
2305lws_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:549
struct lws_buflist2_owner * upstream
Definition lws-misc.h:456
int private_source_idx
Definition lws-misc.h:458
uint16_t port
Definition lws-misc.h:965
const uint8_t * data
Definition lws-misc.h:547
char ssid[32]
Definition lws-misc.h:1848
const char * path
Definition lws-misc.h:964
size_t len
Definition lws-misc.h:548
struct lws_ss_handle * h
Definition lws-misc.h:544
uint8_t state
Definition lws-misc.h:552
struct lws_buflist * bl
Definition lws-misc.h:545
uint8_t channel
Definition lws-misc.h:1852
int32_t window
Definition lws-misc.h:550
const char * scheme
Definition lws-misc.h:962
const char * doc
Definition lws-misc.h:1001
uint8_t authmode
Definition lws-misc.h:1853
unsigned int ss_flags
Definition lws-misc.h:463
uint8_t count
Definition lws-misc.h:1851
struct lws_buflist2_owner * private_owners
Definition lws-misc.h:457
lws_dll2_t list
Definition lws-misc.h:1427
const uint8_t * buf
Definition lws-misc.h:461
size_t(* evict)(struct lws_reclaimable *r)
Definition lws-misc.h:1432
struct lws_dll2_owner owner
Definition lws-misc.h:310
uint16_t pins
Definition lws-misc.h:1435
struct lws_wifi_scan * next
Definition lws-misc.h:1847
lws_dll2_t list
Definition lws-misc.h:542
const char * name
Definition lws-misc.h:1860
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:1000
uint8_t bssid[6]
Definition lws-misc.h:1850
const char * host
Definition lws-misc.h:963
int32_t rssi
Definition lws-misc.h:1849
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:1865
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:1864
LWS_VISIBLE LWS_EXTERN unsigned long lws_now_secs(void)
LWS_VISIBLE LWS_EXTERN size_t lws_get_random(struct lws_context *context, void *buf, size_t len)
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_check_utf8(unsigned char *state, const unsigned char *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)
LWS_VISIBLE LWS_EXTERN size_t lws_utf8_trim_partial(char *s, size_t len)
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 void lws_wsmsg_destroy(struct lws_buflist2_owner *private_owners, size_t count_private_owners)
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:1872
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:1866
LWS_VISIBLE LWS_EXTERN int lws_wsi_close_cause(struct lws *wsi, char *buf, size_t len)
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_MQTT_ACK_TX
Definition lws-misc.h:1500
@ LWS_RXFLOW_REASON_APPLIES_DISABLE
Definition lws-misc.h:1507
@ LWS_RXFLOW_REASON_APPLIES
Definition lws-misc.h:1503
@ LWS_RXFLOW_REASON_USER_BOOL
Definition lws-misc.h:1497
@ LWS_RXFLOW_REASON_APPLIES_ENABLE_BIT
Definition lws-misc.h:1504
@ LWS_RXFLOW_REASON_APPLIES_ENABLE
Definition lws-misc.h:1505
@ LWS_RXFLOW_REASON_FLAG_PROCESS_NOW
Definition lws-misc.h:1508
@ LWS_RXFLOW_REASON_HTTP_RXBUFFER
Definition lws-misc.h:1498
@ LWS_RXFLOW_REASON_H2_PPS_PENDING
Definition lws-misc.h:1499
@ LWSDLOFLOW_STATE_READ
Definition lws-misc.h:533
@ LWSDLOFLOW_STATE_READ_COMPLETED
Definition lws-misc.h:534
@ LWSDLOFLOW_STATE_READ_FAILED
Definition lws-misc.h:536
#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:2188
LWS_VISIBLE LWS_EXTERN int lws_fsmount_unmount(struct lws_fsmount *fsm)
char ovname[64]
Definition lws-misc.h:2189
char distro[64]
Definition lws-misc.h:2190
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:2186
const char * layers_path
Definition lws-misc.h:2185
LWS_VISIBLE LWS_EXTERN int lws_wol(struct lws_context *ctx, const char *ip_or_NULL, uint8_t *mac_6_bytes)