1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00
Commit graph

52 commits

Author SHA1 Message Date
Andy Green
d67dd81b0e libsystemd: require LWS_WITH_SDEVENT for socketact example 2025-03-02 08:48:56 +00:00
Albert Ribes
1fccae47ed lejp: E implies float
Since eg, 1e-3 is a float without needing a decimal point, let's just
generally take it that anything with the exponent token is a float, ie, 1e3
is also a float despite it can be expressed as an integer.

This seems right also because E is itself not valid in an integer.

https://github.com/warmcat/libwebsockets/issues/3308
2025-01-10 13:59:09 +00:00
Andy Green
032adce8c3 minimal: add note about binding mount 2024-10-31 15:20:11 +00:00
Andy Green
36ff3b8d73 tls: if no ssl then skip ss-blob example 2024-01-16 07:33:40 +00:00
Andy Green
49bfef2ecd wol: portability
https://github.com/warmcat/libwebsockets/issues/3048
2024-01-13 08:53:55 +00:00
DomB
f88792df37 lecp: fix format_scan function for numeric longer than 2 digits and negative numbers 2024-01-08 08:25:59 +00:00
Andy Green
cc58c44aee systemd: add socket activation example 2024-01-04 11:41:27 +00:00
Andy Green
41eed87c79 cmake: upgrade everyone to 3.5 minimum version 2023-12-08 13:23:04 +00:00
Andy Green
dab8e1c4f8 mac length: switch to ETHER_ADDR_LEN
Long story, there's also minimal example to take care of.

This change should take care of anything with ETHER_ADDR_LEN in
net/ethernet.h plus windows, for both the lib and example.
2023-12-07 05:31:25 +00:00
Andy Green
4af988600f net: lws_wol() and lws_parse_mac()
Introduce a LWS_WITH_WOL and an api to wake a mac address, optionally with
an address bind to the local interface to go out on.

Add a helper to parse ascii mac addresses well, and add tests.

Also thanks to OgreTransporter
https://github.com/warmcat/libwebsockets/issues/3016
2023-11-24 05:44:42 +00:00
Andy Green
3454cd1f8a test: async dns: handle dynamic ads on warmcat
We use warmcat dns for testing, but for a while it has become dynamic
breaking the tests.

Fix up the affected tests with IPv4 addresses from getaddrinfo() so they
pass when they match these results.
2023-11-09 12:04:47 +00:00
Lorenzo Arena
fc58ddbdb1 minimal-examples-lowlevel: fix misleading comment for the conceal value 2022-09-18 08:17:25 +01:00
Andy Green
9700773296 tests: disable tests with jig rot
A couple of tests can't work because the peer setup they rely on has rotted
on the peer side.
2022-09-18 08:17:25 +01:00
Andy Green
31ff36e09d minimal: embedded lhp examples
Implements a carousel rendering and displaying remote HTML + JPEG + PNGs
on a variety of display devices, including several EPDs.
2022-05-04 08:43:26 +01:00
Andy Green
4a443c3e2e lhp: add DLO layout support
Add a dlo-based layout callback for use with lhp.

If lhp_dl_render() is used as the Lws Html/CSS parser callback, it
produces a display_list representation of the Html as DLOs, referencing the
appropriate CSS to drive the layout as best it can.

The display list can be rasterized on to an lws_display using the display's
state object

  lds->disp->blit(lds, (uint8_t *)&dl, &box);
2022-05-04 08:43:26 +01:00
Andy Green
63d2f844db lhp: Lightweight HTML Parser
Introduce a very lightweight html5 + css2.1+ stateful stream parser, along
the same lines as the lws json and cbor ones.

This is interesting primarily because of just how low-resource it is for
modest css + html, it uses an lwsac to hold the entirity of the css in
memory at once but the html is parsed in chunks without any need to keep
previous chunks around (chunks may be as small as 1 byte).

A user callback receives element entry and exit callbacks with payload and
all attributes parsed out, CSS related to the active element stack is
parsed to provide a list of active css attributes, which takes heap for the
duration of the parsing.

In effect this provides rich information about the html and css state to
the callback, which has the job of producing the layout in a user-defined
way.

As such, there is no DOM in memory at one time, there is only a stack of
active elements like <html><body><div>xxx with their associated attributes
(like class).  So as it is, it does not support DOM modification such as
JS changing elements after parsing, although elements with interesting IDs
could be kept around by the callback.  There is a corresponding tiny and
relatively flat heap usage regardless of html size.

Default CSS is specified as recommended in the CSS 2.1 standard.

Inline <style></style> elements are supported, but not pre-html5 style= in
element attributes, since these are incompatible with strict CSP.

What the attributes should mean on your system, eg, font-size, font-family
etc is left for the user callback to decide, along with how to lay out the
items using the CSS attributes, and render them.

Fixed point 32.32 constants are used (fraction expressed at parts in 100M)
instead of floating point.

If you have presentation needs, even on a constrained display on a
constrained microcontroller, this makes it feasible to use standardized
markup and styling instead of roll your own.
2022-05-04 08:43:26 +01:00
Nick
2dc148e3a3 clean: remove needless LWS_PRE
Several examples trim their buffer with an extra LWS_PRE from the end...
actually end should point to end the end of buf without a second LWS_PRE
reservation.

https://github.com/warmcat/libwebsockets/issues/2629
2022-05-04 08:43:26 +01:00
Chunho Lee
584dcfae79 minimal: ss: policy2c: update MQTT fields 2022-04-11 09:31:14 +01:00
Andy Green
047fb7bb21 tokenize: enhance to support chunked parsing
Add EXPECT_MORE flag to indicate that running out of input is not (yet)
indicating the end of the document.  The caller should remove this flag
when it identifies that it does not have the chunk with the end of the
document: the last chunk may be zero length.

Track line numbers so the caller can infer CR, absorb CRLF -> CR.

Also add COLON_NONTERM needed for ipv6 literal addresses.
2022-04-10 06:56:12 +01:00
Andy Green
b0041b32e6 raw: tls conns
Raw + tls needs a little extra handling during connect.
2022-04-10 06:56:12 +01:00
Andy Green
518e6c7cc0 examples: install useful examples 2022-03-25 08:18:29 +00:00
Andy Green
1d3ec6a3a1 lws-jpeg
Introduce a rewritten picojpeg that is able to operate statefully and
rasterize into an internal line ringbuffer, emitting a line of pixels
at a time to the caller.  This is the JPEG equivalent of the lws
PNG decoder.

JPEG is based around 8- or 16- line height MCU blocks, depending on
the chroma coding, mandating a corresponding internal line buffer
requirement.

Example total heap requirement for various kinds of 600px width jpeg
decoding:

  Grayscale:    6.5KB
  RGB 4:4:4:   16.4KB
  RGB 4:2:2v:  16.4KB
  RGB 4:4:2h:  31KB
  RGB 4:4:0:   31KB

No other allocations occur during decode.

Stateful stream parsing means decode can be paused for lack of input
at any time and resumed seamlessly when more input becomes available.
2022-03-25 08:13:48 +00:00
Andy Green
a74fe5d760 upng: split out gzip
The adapted upng has a very compact fully-stateful lws-aligned
implementation already.

Adapt it to also be buildable and operable standalone, and to
understand gzip headers.

Provide some apis to inflate gzip simply reusing opaque inflator
contexts from upng.

Provide an api test that inflates gzip files from stdin -> stdout
2022-03-25 08:13:48 +00:00
Andy Green
48907fca0a upng: rewrite for stateful stream decode
Add a rewritten version of upng that decodes statefully line by line, and so
does not require a bitmap buffer for the output.  This compares to original
upng approach that needs heap allocations for the input, the whole output
and intermediate allocations.

Instead of buffers for input, decompression and output, it only allocates
2 x lines of RGBA pixels (ie, a few KB), and 32KB of decompressed data for
backward references in the decoder, and decodes as needed into the 2-line
buffer to produce line rasterized results.  For a 600px width PNG, this is
just 40KB heap for the duration.
2022-03-16 12:59:48 +00:00
Andy Green
aadcd3c44a lws_fx: fixed point 3232 arithmetic
This introduces a fixed precision signed 32.32 fractional type that can
work on devices without an FPU.

The integer part works as an int32_t, the fractional part represents the
fractional proportion expressed as part of 100M, so 8 fractional decimal
digit precision which is more than enough for many applications.

Add and Sub are reasonably fast as they are scaled on to a combined
uint64_t, Multiply is a little slower as it takes four uint64_t multiplies
that are summed, and divide is expensive but accurate, done bitwise taking
up to 32 iterations involving uint64_t div and mod.
2022-03-15 10:28:09 +00:00
Andy Green
67931757f8 alloc: compressed backtrace instrumentation support
This adds apis that enable usage of compressed backtraces in heap
instrumentation.

A decompressor tool is also provided that emits a textual
call stack suitable for use with addr2line.
2022-03-15 10:28:09 +00:00
Andy Green
d7b912c539 gcc4: conceal typedef in public header
Modern toolchains are fine with giving a typedef as a forward reference,
but gcc 4.3 can't cope with that and then seeing the real definition in the
.c later.

Just conceal the typedef and use the struct form for the forward reference
resolution type in the public header so even senior toolchains are happy.
2022-03-15 10:28:09 +00:00
Andy Green
2de67dd0ae file_ops: vfs: support prefix matches and use of bound ops members
VFS needs some small updates... pass in the bound fops as well as the
context fops to the member callbacks.  ZIP_FOPS only cared about doing
operations on the platform / context vfs to walk the ZIP file, but other
uses are valid where we are doing operation inside the bound VFS itself.

Also, stash a cx pointer into file ops struct for convenience.
2022-03-15 10:28:09 +00:00
Andy Green
e4a556333a FILE_OPS: add deps for disabled case 2022-03-15 10:28:09 +00:00
Andy Green
c8b9ac4aaf seq: remove last vestiges
Sequencer went away a while ago, remove api tests and minimal examples.

Use Secure Streams to get an object with a lifetime longer than a wsi that
can autonomously retry.
2022-03-15 10:28:09 +00:00
Chunho Lee
3af7a16531 ss: mqtt: add support for retained message 2022-03-15 10:28:09 +00:00
Chunho Lee
f57d84f6fc minimal: ss: mqtt: update certificate
test.mosquitto.org mutual auth certs only have a 6mo lifetime...
2022-03-15 10:28:09 +00:00
Chunho Lee
a34e60581c minimal: ss: policy2c: add more MQTT related fields
This adds 'aws_iot', 'birth_topic', and 'birth_message'
on policy2c.
2022-03-15 10:28:09 +00:00
Andy Green
7e841130e0 coverity fixes 2022-01-16 10:48:11 +00:00
chenzhongaaron
27f8affcd0 qnx: toolchain file and adaptations
https://github.com/warmcat/libwebsockets/issues/2527
2021-12-15 13:28:23 +00:00
Joerg Wendel
fe8170dcdc http: server: added no-cache handling to mounts 2021-12-13 19:02:56 +00:00
Andy Green
3feddc06a4 examples: lgtm fixes now on by default 2021-11-29 15:18:15 +00:00
Chunho Lee
e2e020f954 ss: mqtt: add ss mqtt minimal example
Adds an example for Secure Stream MQTT.
2021-11-17 09:54:12 +00:00
Andy Green
53d195022f cmake: Enable WITH_MINIMAL_EXAMPLES by default
Although many of the examples must be run from the example directory as
cwd, everyone getting started probably wants to try the examples, cmake
knows how to do it, so let's enable it by default.
2021-11-11 11:52:46 +00:00
Andy Green
555503b202 lejp: allow leading wildcard
This lets us have path matches like "*[]"
2021-11-07 05:33:44 +00:00
Andy Green
c935df1e7e lejp: object indexes
This adds an optional feature LEJP_FLAG_FEAT_OBJECT_INDEXES that changes
lejp to treat { } items as indexable in ctx->i[] / ctx->ipos, since they
also can take commas.

This may break existing uses so it requires the default-off feature flag to
enable it.  The flags context field is zeroed by lejp_construct(), so any
flags should be set on ctx->flags after alling that.

There's also a flag LEJP_FLAG_LATEST available as an alias to enable any
desirable but not-backwards-compatible behaviour, including this.

Add the info to the README and adapt the unit test to do it both with and
without the FEAT_OBJECT_INDEXES flag.
2021-11-07 05:33:43 +00:00
Andy Green
9734cadf11 lejp: tighten api tests 2021-11-07 05:32:08 +00:00
Hannes Achleitner
1b7d6c80ff examples-lowlevel: ws client: add -n to README table 2021-11-02 07:12:47 +00:00
Andy Green
3755f56d5e examples-lowlevel: ws-server: pvo for WITH_PLUGINS 2021-11-02 07:11:59 +00:00
Andy Green
2ce2447397 minimal: ss: handle usleep in win32
AG: also take care of additional requirements for tests that need h2
2021-10-28 16:50:28 +01:00
Andy Green
67f532a8c6 cmake: bring tls include requirement out as PUBLIC
There's no problem for library build, also with LWS_WITH_MINIMAL_EXAMPLES,
but after install at least on OSX, there are problems finding the installed
lws include dir (concealed on most platforms by the path being in the
default search list for the toolchain), and the references in the lws
includes to the tls includes meaning that explicit paths for that must be
available at consuming cmakes.

This patch enhances the cmake config installed by lws to deal with adding
the lws include paths to CMAKE_REQUIRED_INCLUDES and include_directories,
so it can be found before the target is introduced.

The tls include is passed back up the CMakeLists layers and the lws targets
marked with target_include_directories(PUBLIC) with them, so they are
understood as needed by consumers.

More boilerplate is moved out of the example consuming cmakes.

After this, on machines with previous installs of older lws, you may have to
clean out the cmake install path, that is usually something like

/usr/local/lib/cmake/libwebsockets/*

before make installing lws and putting the latest content in there.
2021-10-28 08:12:48 +01:00
Chunho Lee
8e4336838a mqtt: allow indicating username and password are not on heap
Fix minimal-mqtt-client and minimal-mqtt-client-multi from crashes
by allowing indicating username and password are not on heap.
2021-10-27 16:52:38 +01:00
Andy Green
a3592cbe4f adns: api-test: add synthetic result parsing
Add some exports so the api test can inject results into the parser for
live queries, suppressing asking the server but otherwise following the
flow.

Provide two new suspect responses for injection and parsing in ctest.

Add a --cos option to minimal-http-client to force a close after the
connection has started the async dns.
2021-10-18 09:58:16 +01:00
Orefkov Aleksander
abef9ba252 http: spa: fetch any params
Added the ability to get additional form parameters with unknown names in the form parameters parser lws_spa. The example of using the form parameters parser has been updated. Fixed bug of double freeing memory in the example.
2021-10-15 08:47:52 +01:00
Andy Green
057d03997f jrpc: add support 2021-10-11 09:10:15 +01:00