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

473 commits

Author SHA1 Message Date
Andy Green
e3dca87f23 lws_display: add display list / DLO support
This adds optional display list support to lws_display, using DLOs (Display
List Objects).  DLOs for rectangle / rounded rectangle (with circle as the
degenerate case), PNGs, JPEG and compressed, antialiased bitmapped fonts
and text primitives are provided.

Logical DLOs are instantiated on heap and listed into an lws_display_list
owner, DLOs handle attributes like position, bounding box, colour +
opacity, and local error diffusion backing buffer.

When the display list is complete, it can be rasterized a line at a time,
with scoped error diffusion resolved, such that no allocation for the
framebuffer is required at any point.  DLOs are freed as the rasterization
moves beyond their bounding box.

Adds a platform registry binding names and other metadata to lws_display
fonts / PNGs / JPEGs.  Provides registration, destruction and best match
selection apis.
2022-03-25 08:18:29 +00:00
Andy Green
aa696773f0 lws_display: improve apis to use display_state and frac
Adapt disp ops to use lws_display_state_t instead of the const disp object.

Describe display area in pixels and mm using lws_fixed3232.
2022-03-25 08:13:48 +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
tjwalton
3070709f18 clean: Remove redundant redeclaration 2022-03-15 10:28:09 +00:00
Andy Green
843ee10205 mbedtls: v3.1 reverts privacy of mbedtls_net_context fd
mbedtls seemed to realize that they went overboard with the privacy stuff
on v3.0 and removed some of it.  Introduce support for those members that
are only private on exactly v3.0 and unprotected before and after.
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
wayneonway
73b61f6a2e route: extend lws_route_uidx_t from 1 byte to 2 bytes 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
Chunho Lee
3af7a16531 ss: mqtt: add support for retained message 2022-03-15 10:28:09 +00:00
Andy Green
d892b86b93 lws_flow helpers
Add a generic struct to manage a buflist with an incrementally-consumable
head, and helpers to deal with retiring the last segment and starting the
new head.

The lws_flow is added to using the buflist member directly, it autohandles
SS window management to try to keep the total buffered at the client to the
window member limit.
2022-02-22 14:37:31 +00:00
Andy Green
e5e1b34f84 logs: lock log context refcount changes
Enabling the locking requires -DLWS_MAX_SMP=2 or more.
2022-01-26 11:54:08 +00:00
Sylvian Saunier
38a39a3710 client: support socket source port setting 2022-01-16 10:48:16 +00:00
Sylvian Saunier
b3ec5a0a4e client: support socket reuseaddr 2022-01-16 10:48:16 +00:00
Michael Drake
c735a9f383 docs: add return value documentation for base64 decode 2022-01-10 14:20:26 +00:00
Andy Green
65768cf3eb dll2: add api for inserting afer existing member 2022-01-04 16:08:50 +00:00
Andy Green
8b16aa18c8 minilex: add improved generic version in misc
Leave the http minilex as it is, and add an improved version in lib/misc

 - get a list of strings from stdin and emit C header to stdout

 - support ambiguous terminals (xxx and xxx-something) correctly regardless
   of introduction order

 - add generic parser in lib/misc

minilex doesn't build as part of lws since it's only needed by developers,
there's a one-line build documented at a comment at the top of
lib/misc/minilex.c
2022-01-04 16:08:44 +00:00
chilL1n
1418042935 docs: lws_service_tsi 2021-12-13 20:32:50 +00:00
Joerg Wendel
fe8170dcdc http: server: added no-cache handling to mounts 2021-12-13 19:02:56 +00:00
Andy Green
ba89af373b async dns: allow multiple servers and public add remove apis 2021-11-17 14:50:08 +00:00
Ilya Smelykh
d425691d9f client: flag defeating default cache-control headers added 2021-11-11 16:55:20 +00:00
Andy Green
591d42ff67 windows: mingw file type is int 2021-11-11 08:34:02 +00:00
PW Hu
fe31dcd8ac docs: audit api return information
https://github.com/warmcat/libwebsockets/issues/2481
2021-11-07 10:08:00 +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
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
Felipe Gasper
b954aa8c21 docs: client: Add UNIX socket connection notes for clients 2021-10-26 06:54:02 +01:00
Andy Green
2761badd0f minimal: ss: embedded: RT595S ACM transport
Adds an example for NXP RT595S eval board, using serialized SS over CDC /
ACM USB composite device, one ttyACM for logs and the other for the SSS
link.
2021-10-24 16:50:39 +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
3ae573cf9b remove: ss plugins
These have been disabled via a preprocessor symbol with no UI to enable it
for a year or so, it looks like they are not going to be needed.

The model of in-tree auth selectable from cmake looks like it will do for
everything, or if not, the solution will probably look different to this.
2021-10-12 07:33:18 +01:00
Andy Green
f5edf9d75a remove: lws_sequencer
lws_sequencer and lws_abstract were both false starts trying to do the
functionality of secure streams.

Since Secure Streams does a better job for both and there are no known
out-of-tree users of them, let's remove them and focus on Secure Streams.
2021-10-12 07:33:15 +01:00
Andy Green
057d03997f jrpc: add support 2021-10-11 09:10:15 +01:00
Yichen Gu
e3544456d8 lecp: remove extra struct lws_lec_pctx fwd definitions
C++ compilers set to less than C11 may choke on it, it's anyway not needed
any more since no references between that and the actual definition.
2021-10-11 09:09:37 +01:00
Andy Green
8fd1ea6180 examples: move existing to m-e-lowlevel and start repoulating m-e with SS 2021-10-08 09:49:05 +01:00
Andy Green
2cfa260e62 sspc: refactor to allow different transports
This is a NOP for existing usecases.

At the moment the only implemented transport for serialized SS is wsi, it's
typically used with Unix Domain Sockets, but it also works over tcp the
same.

It generalizes the interface between serialized chunks and the
transport, separately for client and proxy.  The wsi transport is migrated
to use the new transport ops structs.

It will then be possible to "bring your own transport", so long as it is
reliable, and in-order, both for proxy and client / sspc.

We also adapt minimal-secure-streams-binance to build the -client variant
via SS proxy as well.

LWS_ONLY_SSPC is added so libwebsockets can be produced with just sspc
client support even for tiny targets.

A new embedded minimal example for rpi pico is also provided that
demonstrates using Serialized SS over a UART to an SS proxy, to implement
the SS Binance example on the pico, even though it has no networking itself.
2021-10-08 09:48:41 +01:00
Andy Green
135234bd39 plat: baremetal and rpi pico support 2021-10-08 09:48:41 +01:00
Andy Green
65f16d737e dsh-empty 2021-10-08 09:48:41 +01:00
Andy Green
43bb8aead0 dsh: coalesce 2021-10-08 09:48:41 +01:00
Chunho Lee
f440a67ec8 ss-mqtt: Add support for Birth message
This provides Birth message on SS policy. The Birth message is
a message published just after the MQTT connection has been
established.
2021-10-07 10:59:08 +01:00
Andy Green
19ba1998fa tls: evolve handshake serialization into simultaneous_ssl_handshake_restriction
This patch adapts the recent change about serializing the number of
simultaneous tls handshakes allowed to 1, so you can set the number in the
context creation info, and the accounting for it is handled by counters
same as the overally tls restriction.

The name of the context info var to control it changes to simultaneous_ssl_handshake_restriction
which is now a count, the default 0 means no limit.

The count rejects tls connection attempts when the tls borrow is attempted,
and separately hands back the hs borrow from the tls borrow when the
connection attempt fails or succeeds.
2021-10-05 07:40:17 +01:00
Andy Green
0fda90c40a ws-server-threads-smp: modernize 2021-10-05 07:40:03 +01:00
Andy Green
b6004e08c9 mqtt: allow indicating client_id is not on heap
Not sure why we don't leave any freeing to the caller, but since we don't
allow indicating that the provided client id should not be freed.
2021-10-05 07:09:47 +01:00
Austen Stone
f6954e432c http: custom hdr: add custom name iterator 2021-08-31 05:45:40 +01:00
Andy Green
81a3ca3e84 ss: port binance example 2021-08-31 05:45:40 +01:00
Andy Green
4db2ff872b cose: keys and signing + validation
Support for COSE keys and signing / validation

 - lws_cose_key_t and import / export / generation apis for EC / RSA / SYMMETRIC

 - cose_sign1 ES256/384/512,RS256/384/512 sign + validate, passes RFC8152 WG tests sign1-tests
 - cose_sign  ES256/384/512,RS256/384/512 sign + validate, passes RFC8152 WG tests sign-tests
 - cose_mac0  HS256/HS256_64/384/512      sign + validate, passes RFC8152 WG tests hmac-examples
 - cose_mac   HS256/HS256_64/384/512             validate, passes RFC8152 WG tests hmac-examples

 - lws-crypto-cose-key commandline tool for key / key set dumping and
   creation
 - lws-crypro-cose-sign commandline tool for signing / validation

 - lws-api-test-cose - large number of test vectors and tests from RFC8152
2021-08-31 05:45:35 +01:00
Andy Green
dcaa0013b4 lecp: add CBOR stream parser LECP like JSON LEJP
This provides very memory-efficient CBOR stream parsing
and writing.

The parser  converts pieces of CBOR into callbacks that define
the structure and collate string and blobs into buffer chunks
for extensible and easy access.

It is fragementation-safe and does not need all the CBOR in
the same place at one time, chunks of CBOR are parsed and
discarded as provided.

It does not allocate and just needs a few hundred bytes of
stack for even huge CBOR objects.  Huge strings and blobs
are handled without needing memory to hold them atomically.

Includes ./minimal-examples/api-tests/api-test-lecp that
unit tests it against 82 official example CBORs and
26 additional test vectors from COSE (just checking the CBOR
parsing).

The writing apis allow printf style semantics with a variety
of CBOR-aware %-formats.  The apis write into a context that
manages output buffer usage, if the output buffer fills,
then the apis return with an AGAIN code that lets you issue
and reset the output buffer and repeat the api all to issue
more output.  The subsequent calls can occur much later or
from a different function context, so this is perfect for
WRITEABLE-mediated output from the network parts of lws.

See ./READMEs/README.cbor-lecp.md
2021-08-21 17:44:40 +01:00