From 0bfd39135e970ed1273f2f935c581f213543c7ef Mon Sep 17 00:00:00 2001 From: Andy Green Date: Thu, 2 Jan 2020 08:32:23 +0000 Subject: [PATCH] cleaning --- CMakeLists.txt | 26 +-- README.md | 27 ++- cmake/lws_config.h.in | 1 + include/libwebsockets/lws-dsh.h | 2 +- include/libwebsockets/lws-system.h | 1 - lib/README.md | 3 +- lib/abstract/protocols/smtp/smtp-sequencer.c | 2 +- lib/abstract/protocols/smtp/smtp.c | 2 +- lib/core-net/adopt.c | 6 +- lib/core-net/client.c | 2 +- lib/core-net/connect.c | 45 ++++- lib/core-net/dummy-callback.c | 6 +- lib/core-net/network.c | 6 +- lib/core-net/pollfd.c | 6 +- lib/core-net/private-lib-core-net.h | 1 + lib/core-net/server.c | 8 +- lib/core-net/service.c | 15 +- lib/core-net/stats.c | 6 +- lib/core-net/vhost.c | 22 +-- lib/core-net/wsi-timeout.c | 2 +- lib/core-net/wsi.c | 84 ++++---- lib/core/context.c | 13 +- lib/core/libwebsockets.c | 2 +- lib/core/logs.c | 18 +- lib/core/vfs.c | 16 +- lib/event-libs/libev/libev.c | 2 +- lib/event-libs/libevent/libevent.c | 2 +- lib/event-libs/libuv/libuv.c | 16 +- lib/jose/jwe/enc/aeskw.c | 2 +- lib/jose/jwe/jwe-ecdh-es-aeskw.c | 4 +- lib/jose/jwe/jwe-rsa-aescbc.c | 2 +- lib/jose/jwe/jwe-rsa-aesgcm.c | 2 +- lib/jose/jwe/jwe.c | 12 +- lib/jose/jwk/jwk.c | 20 +- lib/jose/jws/jws.c | 36 ++-- lib/misc/base64-decode.c | 13 +- lib/misc/daemonize.c | 2 +- lib/misc/lws-ring.c | 24 +-- lib/misc/lws-struct-lejp.c | 3 +- lib/misc/sha-1.c | 2 +- lib/misc/threadpool/threadpool.c | 2 +- lib/plat/freertos/freertos-file.c | 16 +- lib/plat/freertos/freertos-misc.c | 4 +- lib/plat/freertos/freertos-service.c | 2 +- lib/plat/optee/network.c | 4 +- lib/plat/unix/android/android-resolv.c | 2 +- lib/plat/unix/unix-fds.c | 6 +- lib/plat/unix/unix-misc.c | 4 +- lib/plat/unix/unix-plugins.c | 7 +- lib/plat/windows/windows-misc.c | 4 +- lib/plat/windows/windows-service.c | 2 +- lib/plat/windows/windows-sockets.c | 4 +- lib/roles/cgi/cgi-server.c | 8 +- lib/roles/h1/ops-h1.c | 8 +- lib/roles/h2/http2.c | 89 +++++---- lib/roles/h2/minihuf.c | 4 +- lib/roles/h2/ops-h2.c | 5 +- lib/roles/http/client/client-handshake.c | 15 +- lib/roles/http/client/client-http.c | 47 +++-- lib/roles/http/compression/stream.c | 4 +- lib/roles/http/header.c | 6 +- lib/roles/http/minilex.c | 2 +- lib/roles/http/parsers.c | 20 +- lib/roles/http/server/lws-spa.c | 8 +- lib/roles/http/server/rewrite.c | 6 +- lib/roles/http/server/server.c | 181 +++++++++--------- lib/roles/listen/ops-listen.c | 3 + lib/roles/raw-skt/ops-raw-skt.c | 3 +- lib/roles/ws/ext/extension.c | 4 +- lib/roles/ws/ops-ws.c | 19 +- lib/system/ntpclient/ntpclient.c | 4 +- lib/tls/lws-gencrypto-common.c | 6 +- lib/tls/lws-genec-common.c | 4 +- lib/tls/mbedtls/lws-genaes.c | 8 +- lib/tls/mbedtls/lws-genec.c | 18 +- lib/tls/mbedtls/lws-genrsa.c | 22 +-- lib/tls/mbedtls/mbedtls-client.c | 11 +- lib/tls/mbedtls/mbedtls-server.c | 4 +- lib/tls/mbedtls/mbedtls-ssl.c | 14 +- lib/tls/openssl/lws-genaes.c | 6 +- lib/tls/openssl/lws-genec.c | 20 +- lib/tls/openssl/lws-genrsa.c | 20 +- lib/tls/openssl/openssl-client.c | 12 +- lib/tls/openssl/openssl-server.c | 9 +- lib/tls/openssl/openssl-ssl.c | 17 +- lib/tls/tls-client.c | 2 +- lib/tls/tls-network.c | 5 +- lib/tls/tls-server.c | 13 +- .../protocols/smtp-client/CMakeLists.txt | 1 + .../api-test-async-dns/CMakeLists.txt | 1 + .../api-tests/api-test-dhcpc/CMakeLists.txt | 1 + .../api-tests/api-test-fts/CMakeLists.txt | 1 + .../api-test-gencrypto/CMakeLists.txt | 1 + .../api-tests/api-test-jose/CMakeLists.txt | 1 + .../api-tests/api-test-lws_dsh/CMakeLists.txt | 1 + .../api-tests/api-test-lws_dsh/main.c | 4 +- .../api-test-lws_sequencer/CMakeLists.txt | 1 + .../api-test-lws_struct-json/CMakeLists.txt | 1 + .../api-test-lws_tokenize/CMakeLists.txt | 1 + .../api-tests/api-test-lwsac/CMakeLists.txt | 1 + .../api-test-smtp_client/CMakeLists.txt | 1 + .../minimal-ws-proxy/CMakeLists.txt | 1 + .../minimal-ws-proxy/protocol_lws_minimal.c | 4 +- .../crypto/minimal-crypto-jwe/CMakeLists.txt | 1 + .../crypto/minimal-crypto-jwk/CMakeLists.txt | 1 + .../crypto/minimal-crypto-jws/CMakeLists.txt | 1 + .../crypto/minimal-crypto-x509/CMakeLists.txt | 1 + .../minimal-dbus-client/CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../minimal-dbus-server/CMakeLists.txt | 1 + .../minimal-dbus-ws-proxy/CMakeLists.txt | 1 + .../protocol_lws_minimal_dbus_ws_proxy.c | 4 +- .../minimal-http-client-attach/CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../minimal-http-client-multi/CMakeLists.txt | 1 + .../minimal-http-client-multi.c | 1 - .../minimal-http-client-post/CMakeLists.txt | 1 + .../minimal-http-client/CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../minimal-http-server-cgi/CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../mount-origin/example.js | 2 +- .../CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../minimal-http-server-proxy/CMakeLists.txt | 1 + .../minimal-http-server-smp/CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../minimal-http-server-sse/CMakeLists.txt | 1 + .../minimal-http-server-tls-80/CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../mount-origin/example.js | 2 +- .../minimal-http-server-tls/CMakeLists.txt | 1 + .../mount-origin/example.js | 2 +- .../minimal-http-server/CMakeLists.txt | 1 + .../raw/minimal-raw-adopt-tcp/CMakeLists.txt | 1 + .../raw/minimal-raw-adopt-udp/CMakeLists.txt | 1 + .../raw/minimal-raw-audio/CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../raw/minimal-raw-file/CMakeLists.txt | 1 + .../raw/minimal-raw-netcat/CMakeLists.txt | 1 + .../minimal-raw-proxy-fallback/CMakeLists.txt | 1 + .../raw/minimal-raw-proxy/CMakeLists.txt | 1 + .../raw/minimal-raw-serial/CMakeLists.txt | 1 + .../raw/minimal-raw-vhost/CMakeLists.txt | 1 + .../raw/minimal-raw-vhost/minimal-raw-vhost.c | 2 +- .../minimal-ws-client-echo/CMakeLists.txt | 1 + .../protocol_lws_minimal_client_echo.c | 4 +- .../minimal-ws-client-ping/CMakeLists.txt | 1 + .../minimal-ws-client-pmd-bulk/CMakeLists.txt | 1 + .../protocol_lws_minimal_pmd_bulk.c | 4 +- .../minimal-ws-client-rx/CMakeLists.txt | 1 + .../minimal-ws-client-spam/CMakeLists.txt | 1 + .../minimal-ws-client-tx/CMakeLists.txt | 1 + .../minimal-ws-broker/CMakeLists.txt | 1 + .../minimal-ws-broker/protocol_lws_minimal.c | 4 +- .../minimal-ws-server-echo/CMakeLists.txt | 1 + .../protocol_lws_minimal_server_echo.c | 4 +- .../minimal-ws-server-pmd-bulk/CMakeLists.txt | 1 + .../protocol_lws_minimal_pmd_bulk.c | 4 +- .../CMakeLists.txt | 1 + .../protocol_lws_minimal.c | 4 +- .../minimal-ws-server-pmd/CMakeLists.txt | 1 + .../protocol_lws_minimal.c | 4 +- .../minimal-ws-server-ring/CMakeLists.txt | 1 + .../protocol_lws_minimal.c | 4 +- .../CMakeLists.txt | 1 + .../mount-origin/example.js | 5 +- .../protocol_lws_minimal_threadpool.c | 4 +- .../CMakeLists.txt | 1 + .../protocol_lws_minimal.c | 4 +- .../minimal-ws-server-threads/CMakeLists.txt | 1 + .../protocol_lws_minimal.c | 4 +- .../minimal-ws-server-timer/CMakeLists.txt | 1 + .../minimal-ws-server/CMakeLists.txt | 1 + .../minimal-ws-server/protocol_lws_minimal.c | 4 +- .../acme-client/protocol_lws_acme_client.c | 4 +- plugins/deaddrop/protocol_lws_deaddrop.c | 4 +- plugins/generic-sessions/handlers.c | 16 +- .../protocol_generic_sessions.c | 32 ++-- .../protocol_lws_messageboard.c | 4 +- .../generic-table/protocol_table_dirlisting.c | 4 +- plugins/protocol_client_loopback_test.c | 4 +- plugins/protocol_dumb_increment.c | 4 +- plugins/protocol_fulltext_demo.c | 4 +- plugins/protocol_lws_mirror.c | 4 +- plugins/protocol_lws_raw_test.c | 4 +- plugins/protocol_lws_server_status.c | 4 +- plugins/protocol_lws_sshd_demo.c | 4 +- plugins/protocol_lws_status.c | 4 +- plugins/protocol_post_demo.c | 4 +- plugins/raw-proxy/protocol_lws_raw_proxy.c | 4 +- plugins/ssh-base/crypto/sc25519.c | 4 +- plugins/ssh-base/sshd.c | 2 +- 209 files changed, 810 insertions(+), 604 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 737011b84..4a366e93c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,7 +108,8 @@ option(LWS_WITH_LEJP "With the Lightweight JSON Parser" ON) option(LWS_WITH_SQLITE3 "Require SQLITE3 support" OFF) option(LWS_WITH_STRUCT_JSON "Generic struct serialization to and from JSON" OFF) option(LWS_WITH_STRUCT_SQLITE3 "Generic struct serialization to and from SQLITE3" OFF) -option(LWS_WITH_SMTP "Provide SMTP support" OFF) +# broken atm +#option(LWS_WITH_SMTP "Provide SMTP support" OFF) if (WIN32 OR LWS_WITH_ESP32) option(LWS_WITH_DIR "Directory scanning api support" OFF) option(LWS_WITH_LEJP_CONF "With LEJP configuration parser as used by lwsws" OFF) @@ -424,7 +425,7 @@ endif() if (LWS_WITH_GENERIC_SESSIONS) set(LWS_WITH_SQLITE3 1) - set(LWS_WITH_SMTP 1) + # set(LWS_WITH_SMTP 1) set(LWS_WITH_STRUCT_SQLITE3 1) endif() @@ -737,9 +738,9 @@ endif() # using any abstract protocol enables LWS_WITH_ABSTRACT -if (LWS_WITH_SMTP) - set(LWS_WITH_ABSTRACT 1) -endif() +#if (LWS_WITH_SMTP) +# set(LWS_WITH_ABSTRACT 1) +#endif() @@ -1464,12 +1465,12 @@ if (LWS_WITH_ABSTRACT) lib/abstract/transports/unit-test.c) endif() -if (LWS_WITH_SMTP) - list(APPEND SOURCES - lib/abstract/protocols/smtp/smtp.c - lib/abstract/protocols/smtp/smtp-sequencer.c - ) -endif() +#if (LWS_WITH_SMTP) +# list(APPEND SOURCES +# lib/abstract/protocols/smtp/smtp.c +# lib/abstract/protocols/smtp/smtp-sequencer.c +# ) +#endif() if (LWS_WITH_RANGES) list(APPEND SOURCES @@ -2786,7 +2787,8 @@ message(" LWS_WITH_ACCESS_LOG = ${LWS_WITH_ACCESS_LOG}") message(" LWS_WITH_SERVER_STATUS = ${LWS_WITH_SERVER_STATUS}") message(" LWS_WITH_LEJP = ${LWS_WITH_LEJP}") message(" LWS_WITH_LEJP_CONF = ${LWS_WITH_LEJP_CONF}") -message(" LWS_WITH_SMTP = ${LWS_WITH_SMTP}") +# this is broken atm +#message(" LWS_WITH_SMTP = ${LWS_WITH_SMTP}") message(" LWS_WITH_GENERIC_SESSIONS = ${LWS_WITH_GENERIC_SESSIONS}") message(" LWS_STATIC_PIC = ${LWS_STATIC_PIC}") message(" LWS_WITH_RANGES = ${LWS_WITH_RANGES}") diff --git a/README.md b/README.md index e58e6ccea..62c86c868 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ lightweight, configurable, scalable and flexible way. It's easy to build and cross-build via cmake and is suitable for tasks from embedded RTOS through mass cloud serving. -[50 minimal examples](https://libwebsockets.org/git/libwebsockets/tree/minimal-examples) for +[70 independent minimal examples](https://libwebsockets.org/git/libwebsockets/tree/minimal-examples) for various scenarios, CC0-licensed (public domain) for cut-and-paste, allow you to get started quickly. ![overview](./doc-assets/lws-overview.png) @@ -16,6 +16,31 @@ various scenarios, CC0-licensed (public domain) for cut-and-paste, allow you to News ---- +## `lws_system` helper for attaching code to a single event loop from another thread + +`lws_system` ops struct now has a member that enables other threads (in the +same process) to request a callback they define from the lws event loop thread +context as soon as possible. From here, in the event loop thread context, +they can set up their lws functionality before returning and letting it +operate wholly from the lws event loop. The original thread calling the +api to request the callback returns immediately. + +## Improvements on tx credit + +H2 clients and servers can now modulate RX flow control on streams precisely, +ie, define the size of the first incoming data and hand out more tx credit +at timing of its choosing to throttle or completely quench the remote server +sending as it likes. + +The only RFC-compatible way to acheive this is set the initial tx credit to +0 and set it explicitly when sending the headers... client code can elect to +do this rather than automatically manage the credit by setting a new flag +LCCSCF_H2_MANUAL_RXFLOW and indicating the initial tx credit for that stream +in client connection info member manual_initial_tx_credit. A new public api +lws_wsi_tx_credit() allows dynamic get and add to local and estimated remote +peer credit for a connection. This api can be used without knowing if the +underlying connection is h2 or not. + ## `lws_system`: DHCP client DHCP client is now another network service that can be integrated into lws, with diff --git a/cmake/lws_config.h.in b/cmake/lws_config.h.in index 4b49422d0..3ef6bff99 100644 --- a/cmake/lws_config.h.in +++ b/cmake/lws_config.h.in @@ -96,6 +96,7 @@ #cmakedefine LWS_WITH_ABSTRACT #cmakedefine LWS_WITH_ACCESS_LOG #cmakedefine LWS_WITH_ACME +#cmakedefine LWS_WITH_ALSA #cmakedefine LWS_WITH_SYS_ASYNC_DNS #cmakedefine LWS_WITH_BORINGSSL #cmakedefine LWS_WITH_CGI diff --git a/include/libwebsockets/lws-dsh.h b/include/libwebsockets/lws-dsh.h index 137a6089d..ee7168bc2 100644 --- a/include/libwebsockets/lws-dsh.h +++ b/include/libwebsockets/lws-dsh.h @@ -116,7 +116,7 @@ LWS_VISIBLE LWS_EXTERN void lws_dsh_free(void **obj); /** - * lws_dsh_get_head() - free a suballocation from the dsh + * lws_dsh_get_head() - get the head allocation inside the dsh * * \param dsh: the dsh tracking the allocation * \param kind: the kind of allocation diff --git a/include/libwebsockets/lws-system.h b/include/libwebsockets/lws-system.h index b90f2eefd..f6bdb0df1 100644 --- a/include/libwebsockets/lws-system.h +++ b/include/libwebsockets/lws-system.h @@ -155,7 +155,6 @@ lws_system_get_state_manager(struct lws_context *context); /* wrappers handle NULL members or no ops struct set at all cleanly */ - #define LWSSYSGAUTH_HEX (1 << 0) /** diff --git a/lib/README.md b/lib/README.md index 2c0c900eb..41ae61876 100644 --- a/lib/README.md +++ b/lib/README.md @@ -5,11 +5,12 @@ Code that goes in the libwebsockets library itself lives down ./lib Path|Sources ---|--- lib/core|Core lws code related to generic fd and wsi servicing and management +lib/core-net|Core lws code that applies only if networking enabled lib/event-libs|Code containing optional event-lib specific adaptations lib/jose|JOSE / JWS / JWK / JWE implementations lib/misc|Code for various mostly optional miscellaneous features lib/plat|Platform-specific adaptation code lib/roles|Code for specific optional wsi roles, eg, http/1, h2, ws, raw, etc +lib/system|Code for system-level features, eg, dhcpclient lib/tls|Code supporting the various TLS libraries -libwebsockets.h|Public API header for the whole of lws diff --git a/lib/abstract/protocols/smtp/smtp-sequencer.c b/lib/abstract/protocols/smtp/smtp-sequencer.c index 26751c5dd..4b745aab1 100644 --- a/lib/abstract/protocols/smtp/smtp-sequencer.c +++ b/lib/abstract/protocols/smtp/smtp-sequencer.c @@ -120,7 +120,7 @@ lws_smtpc_kick_internal(lws_smtp_sequencer_t *s) } s->connstate = LSMTPSS_CONNECTING; - lws_sequencer_timeout(s->seq, 10); + lws_seq_timeout_us(s->seq, 10 * LWS_USEC_PER_SEC); return; } diff --git a/lib/abstract/protocols/smtp/smtp.c b/lib/abstract/protocols/smtp/smtp.c index 542c4fa32..e0a955596 100644 --- a/lib/abstract/protocols/smtp/smtp.c +++ b/lib/abstract/protocols/smtp/smtp.c @@ -187,7 +187,7 @@ lws_smtpc_abs_rx(lws_abs_protocol_inst_t *api, const uint8_t *buf, size_t len) * (and anything queued on it) */ - lws_strnncpy(dotstar, buf, len, sizeof(dotstar)); + lws_strnncpy(dotstar, (const char *)buf, len, sizeof(dotstar)); lwsl_err("%s: server: %s\n", __func__, dotstar); return 1; diff --git a/lib/core-net/adopt.c b/lib/core-net/adopt.c index 8421a50be..7c70beb16 100644 --- a/lib/core-net/adopt.c +++ b/lib/core-net/adopt.c @@ -382,7 +382,7 @@ lws_adopt_socket_vhost(struct lws_vhost *vh, lws_sockfd_type accept_fd) LWS_ADOPT_HTTP | LWS_ADOPT_ALLOW_SSL, fd, NULL, NULL); } -LWS_VISIBLE struct lws * +struct lws * lws_adopt_socket(struct lws_context *context, lws_sockfd_type accept_fd) { return lws_adopt_socket_vhost(context->vhost_list, accept_fd); @@ -693,7 +693,7 @@ bail: #endif #endif -LWS_VISIBLE struct lws * +struct lws * lws_adopt_socket_readbuf(struct lws_context *context, lws_sockfd_type accept_fd, const char *readbuf, size_t len) { @@ -701,7 +701,7 @@ lws_adopt_socket_readbuf(struct lws_context *context, lws_sockfd_type accept_fd, readbuf, len); } -LWS_VISIBLE struct lws * +struct lws * lws_adopt_socket_vhost_readbuf(struct lws_vhost *vhost, lws_sockfd_type accept_fd, const char *readbuf, size_t len) diff --git a/lib/core-net/client.c b/lib/core-net/client.c index 95b6a77bb..46efce6cb 100644 --- a/lib/core-net/client.c +++ b/lib/core-net/client.c @@ -26,7 +26,7 @@ #if defined(LWS_CLIENT_HTTP_PROXYING) -LWS_VISIBLE int +int lws_set_proxy(struct lws_vhost *vhost, const char *proxy) { char authstring[96]; diff --git a/lib/core-net/connect.c b/lib/core-net/connect.c index b31372d22..6f2a6191d 100644 --- a/lib/core-net/connect.c +++ b/lib/core-net/connect.c @@ -24,7 +24,7 @@ #include "private-lib-core.h" -LWS_VISIBLE struct lws * +struct lws * lws_client_connect_via_info(const struct lws_client_connect_info *i) { const char *local = i->protocol; @@ -157,7 +157,7 @@ lws_client_connect_via_info(const struct lws_client_connect_info *i) * role finalization */ - if (!wsi->user_space && i->userdata) { + if (i->userdata) { wsi->user_space_externally_allocated = 1; wsi->user_space = i->userdata; } @@ -308,11 +308,50 @@ lws_client_connect_via_info(const struct lws_client_connect_info *i) i->uri_replace_to); #endif - if (i->method && !strcmp(i->method, "RAW")) + if (i->method && (!strcmp(i->method, "RAW"))) { + +#if defined(LWS_WITH_TLS) + + wsi->tls.ssl = NULL; + + if (wsi->tls.use_ssl & LCCSCF_USE_SSL) { + + /* we can retry this... just cook the SSL BIO the first time */ + + if (lws_ssl_client_bio_create(wsi) < 0) { + lwsl_err("%s: bio_create failed\n", __func__); + goto bail3; + } + +#if !defined(LWS_WITH_SYS_ASYNC_DNS) + if (wsi->tls.use_ssl & LCCSCF_USE_SSL) { + n = lws_ssl_client_connect1(wsi); + if (!n) + return wsi; + if (n < 0) { + lwsl_err("%s: lws_ssl_client_connect1 failed\n", __func__); + goto bail3; + } + } +#endif + } + + + /* fallthru */ +#endif + lws_http_client_connect_via_info2(wsi); + } return wsi; +#if defined(LWS_WITH_TLS) +bail3: + lws_close_free_wsi(wsi, LWS_CLOSE_STATUS_NOSTATUS, "tls start fail"); + + return NULL; +#endif + bail1: lws_free_set_NULL(wsi->stash); diff --git a/lib/core-net/dummy-callback.c b/lib/core-net/dummy-callback.c index 851a2b128..af6492717 100644 --- a/lib/core-net/dummy-callback.c +++ b/lib/core-net/dummy-callback.c @@ -250,7 +250,7 @@ const struct lws_protocols lws_ws_proxy = { #endif -LWS_VISIBLE int +int lws_callback_http_dummy(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len) { @@ -333,10 +333,10 @@ lws_callback_http_dummy(struct lws *wsi, enum lws_callback_reasons reason, if (!wsi->mux_substream) { memcpy(buf + LWS_PRE, "0\x0d\x0a\x0d\x0a", 5); lwsl_debug("writing chunk term and exiting\n"); - n = lws_write(wsi, (unsigned char *)buf + + lws_write(wsi, (unsigned char *)buf + LWS_PRE, 5, LWS_WRITE_HTTP); } else - n = lws_write(wsi, (unsigned char *)buf + + lws_write(wsi, (unsigned char *)buf + LWS_PRE, 0, LWS_WRITE_HTTP_FINAL); diff --git a/lib/core-net/network.c b/lib/core-net/network.c index c53d4fb08..272ed6fa1 100644 --- a/lib/core-net/network.c +++ b/lib/core-net/network.c @@ -136,7 +136,7 @@ lws_get_peer_simple(struct lws *wsi, char *name, int namelen) } #endif -LWS_VISIBLE void +void lws_get_peer_addresses(struct lws *wsi, lws_sockfd_type fd, char *name, int name_len, char *rip, int rip_len) { @@ -189,7 +189,7 @@ bail: * LWS_ITOSA_BUSY: the port at the requested iface + port is already in use */ -LWS_EXTERN int +int lws_socket_bind(struct lws_vhost *vhost, lws_sockfd_type sockfd, int port, const char *iface, int ipv6_allowed) { @@ -432,7 +432,7 @@ lws_retry_sul_schedule_retry_wsi(struct lws *wsi, lws_sorted_usec_list_t *sul, } #if defined(LWS_WITH_IPV6) -LWS_EXTERN unsigned long +unsigned long lws_get_addr_scope(const char *ipaddr) { unsigned long scope = 0; diff --git a/lib/core-net/pollfd.c b/lib/core-net/pollfd.c index 7080838d7..9624b24aa 100644 --- a/lib/core-net/pollfd.c +++ b/lib/core-net/pollfd.c @@ -498,7 +498,7 @@ lws_change_pollfd(struct lws *wsi, int _and, int _or) return ret; } -LWS_VISIBLE int +int lws_callback_on_writable(struct lws *wsi) { struct lws_context_per_thread *pt; @@ -587,7 +587,7 @@ lws_same_vh_protocol_remove(struct lws *wsi) } -LWS_VISIBLE int +int lws_callback_on_writable_all_protocol_vhost(const struct lws_vhost *vhost, const struct lws_protocols *protocol) { @@ -617,7 +617,7 @@ lws_callback_on_writable_all_protocol_vhost(const struct lws_vhost *vhost, return 0; } -LWS_VISIBLE int +int lws_callback_on_writable_all_protocol(const struct lws_context *context, const struct lws_protocols *protocol) { diff --git a/lib/core-net/private-lib-core-net.h b/lib/core-net/private-lib-core-net.h index e52c0c6a3..3a3a19942 100644 --- a/lib/core-net/private-lib-core-net.h +++ b/lib/core-net/private-lib-core-net.h @@ -799,6 +799,7 @@ struct lws { unsigned int client_h2_alpn:1; unsigned int client_mux_substream:1; unsigned int client_mux_migrated:1; + unsigned int client_subsequent_mime_part:1; #endif #ifdef _WIN32 diff --git a/lib/core-net/server.c b/lib/core-net/server.c index f595de673..08acd98b6 100644 --- a/lib/core-net/server.c +++ b/lib/core-net/server.c @@ -48,7 +48,7 @@ lws_sum_stats(const struct lws_context *ctx, struct lws_conn_stats *cs) } } -LWS_EXTERN int +int lws_json_dump_vhost(const struct lws_vhost *vh, char *buf, int len) { #if defined(LWS_ROLE_H1) || defined(LWS_ROLE_H2) @@ -62,8 +62,8 @@ lws_json_dump_vhost(const struct lws_vhost *vh, char *buf, int len) "callback://" }; #endif - char *orig = buf, *end = buf + len - 1, first = 1; - int n = 0; + char *orig = buf, *end = buf + len - 1, first; + int n; if (len < 100) return 0; @@ -160,7 +160,7 @@ lws_json_dump_vhost(const struct lws_vhost *vh, char *buf, int len) } -LWS_EXTERN LWS_VISIBLE int +int lws_json_dump_context(const struct lws_context *context, char *buf, int len, int hide_vhosts) { diff --git a/lib/core-net/service.c b/lib/core-net/service.c index b0e5658fb..ad4a96a5e 100644 --- a/lib/core-net/service.c +++ b/lib/core-net/service.c @@ -42,7 +42,7 @@ lws_callback_as_writeable(struct lws *wsi) } #endif #if defined(LWS_WITH_DETAILED_LATENCY) - if (wsi->context->detailed_latency_cb) { + if (wsi->context->detailed_latency_cb && lwsi_state_est(wsi)) { lws_usec_t us = lws_now_usecs(); wsi->detlat.earliest_write_req_pre_write = @@ -53,7 +53,6 @@ lws_callback_as_writeable(struct lws *wsi) } #endif n = wsi->role_ops->writeable_cb[lwsi_role_server(wsi)]; - m = user_callback_handle_rxflow(wsi->protocol->callback, wsi, (enum lws_callback_reasons) n, wsi->user_space, NULL, 0); @@ -61,7 +60,7 @@ lws_callback_as_writeable(struct lws *wsi) return m; } -LWS_VISIBLE int +int lws_handle_POLLOUT_event(struct lws *wsi, struct lws_pollfd *pollfd) { volatile struct lws *vwsi = (volatile struct lws *)wsi; @@ -287,7 +286,7 @@ lws_rxflow_cache(struct lws *wsi, unsigned char *buf, int n, int len) * activity in poll() when we have something that already needs service */ -LWS_VISIBLE LWS_EXTERN int +int lws_service_adjust_timeout(struct lws_context *context, int timeout_ms, int tsi) { struct lws_context_per_thread *pt; @@ -570,7 +569,7 @@ lws_service_flag_pending(struct lws_context *context, int tsi) return forced; } -LWS_VISIBLE int +int lws_service_fd_tsi(struct lws_context *context, struct lws_pollfd *pollfd, int tsi) { @@ -698,13 +697,13 @@ handled: return 0; } -LWS_VISIBLE int +int lws_service_fd(struct lws_context *context, struct lws_pollfd *pollfd) { return lws_service_fd_tsi(context, pollfd, 0); } -LWS_VISIBLE int +int lws_service(struct lws_context *context, int timeout_ms) { struct lws_context_per_thread *pt; @@ -731,7 +730,7 @@ lws_service(struct lws_context *context, int timeout_ms) return n; } -LWS_VISIBLE int +int lws_service_tsi(struct lws_context *context, int timeout_ms, int tsi) { struct lws_context_per_thread *pt; diff --git a/lib/core-net/stats.c b/lib/core-net/stats.c index bf740be1a..82905f238 100644 --- a/lib/core-net/stats.c +++ b/lib/core-net/stats.c @@ -26,7 +26,7 @@ #if defined(LWS_WITH_STATS) -LWS_VISIBLE LWS_EXTERN uint64_t +uint64_t lws_stats_get(struct lws_context *context, int index) { struct lws_context_per_thread *pt = &context->pt[0]; @@ -113,7 +113,7 @@ quantify(struct lws_context *context, int tsi, char *p, int len, int idx, } -LWS_VISIBLE LWS_EXTERN void +void lws_stats_log_dump(struct lws_context *context) { struct lws_vhost *v = context->vhost_list; @@ -159,8 +159,6 @@ lws_stats_log_dump(struct lws_context *context) lwsl_notice("Live wsi: %8d\n", context->count_wsi_allocated); - context->updated = 1; - while (v) { if (v->lserv_wsi && v->lserv_wsi->position_in_fds_table != LWS_NO_FDS_POS) { diff --git a/lib/core-net/vhost.c b/lib/core-net/vhost.c index e38f79659..dc67ad958 100644 --- a/lib/core-net/vhost.c +++ b/lib/core-net/vhost.c @@ -204,7 +204,7 @@ lws_role_call_client_bind(struct lws *wsi, } #endif -LWS_VISIBLE void * +void * lws_protocol_vh_priv_zalloc(struct lws_vhost *vhost, const struct lws_protocols *prot, int size) { @@ -236,7 +236,7 @@ lws_protocol_vh_priv_zalloc(struct lws_vhost *vhost, return vhost->protocol_vh_privs[n]; } -LWS_VISIBLE void * +void * lws_protocol_vh_priv_get(struct lws_vhost *vhost, const struct lws_protocols *prot) { @@ -369,7 +369,7 @@ lws_protocol_init_vhost(struct lws_vhost *vh, int *any) * inform every vhost that hasn't already done it, that * his protocols are initializing */ -LWS_VISIBLE int +int lws_protocol_init(struct lws_context *context) { struct lws_vhost *vh = context->vhost_list; @@ -436,7 +436,7 @@ static const struct lws_protocols protocols_dummy[] = { #undef LWS_HAVE_GETENV #endif -LWS_VISIBLE struct lws_vhost * +struct lws_vhost * lws_create_vhost(struct lws_context *context, const struct lws_context_creation_info *info) { @@ -831,7 +831,7 @@ bail: return NULL; } -LWS_VISIBLE int +int lws_init_vhost_client_ssl(const struct lws_context_creation_info *info, struct lws_vhost *vhost) { @@ -843,13 +843,13 @@ lws_init_vhost_client_ssl(const struct lws_context_creation_info *info, return lws_context_init_client_ssl(&i, vhost); } -LWS_VISIBLE void +void lws_cancel_service_pt(struct lws *wsi) { lws_plat_pipe_signal(wsi); } -LWS_VISIBLE void +void lws_cancel_service(struct lws_context *context) { struct lws_context_per_thread *pt = &context->pt[0]; @@ -1269,7 +1269,7 @@ lws_check_deferred_free(struct lws_context *context, int tsi, int force) } -LWS_VISIBLE void +void lws_vhost_destroy(struct lws_vhost *vh) { struct lws_deferred_free *df = lws_malloc(sizeof(*df), "deferred free"); @@ -1308,20 +1308,20 @@ out: } -LWS_EXTERN void * +void * lws_vhost_user(struct lws_vhost *vhost) { return vhost->user; } -LWS_VISIBLE LWS_EXTERN int +int lws_get_vhost_listen_port(struct lws_vhost *vhost) { return vhost->listen_port; } #if defined(LWS_WITH_SERVER) -LWS_VISIBLE LWS_EXTERN void +void lws_context_deprecate(struct lws_context *context, lws_reload_func cb) { struct lws_vhost *vh = context->vhost_list, *vh1; diff --git a/lib/core-net/wsi-timeout.c b/lib/core-net/wsi-timeout.c index f3d14939b..cfbb7d2b1 100644 --- a/lib/core-net/wsi-timeout.c +++ b/lib/core-net/wsi-timeout.c @@ -64,7 +64,7 @@ __lws_set_timer_usecs(struct lws *wsi, lws_usec_t us) __lws_sul_insert(&pt->pt_sul_owner, &wsi->sul_hrtimer, us); } -LWS_VISIBLE void +void lws_set_timer_usecs(struct lws *wsi, lws_usec_t usecs) { __lws_set_timer_usecs(wsi, usecs); diff --git a/lib/core-net/wsi.c b/lib/core-net/wsi.c index 70bfe4476..172c08218 100644 --- a/lib/core-net/wsi.c +++ b/lib/core-net/wsi.c @@ -120,7 +120,7 @@ lws_vhost_name_to_protocol(struct lws_vhost *vh, const char *name) return NULL; } -LWS_VISIBLE int +int lws_callback_all_protocol(struct lws_context *context, const struct lws_protocols *protocol, int reason) { @@ -143,7 +143,7 @@ lws_callback_all_protocol(struct lws_context *context, return 0; } -LWS_VISIBLE int +int lws_callback_all_protocol_vhost_args(struct lws_vhost *vh, const struct lws_protocols *protocol, int reason, void *argp, size_t len) @@ -169,14 +169,14 @@ lws_callback_all_protocol_vhost_args(struct lws_vhost *vh, return 0; } -LWS_VISIBLE int +int lws_callback_all_protocol_vhost(struct lws_vhost *vh, const struct lws_protocols *protocol, int reason) { return lws_callback_all_protocol_vhost_args(vh, protocol, reason, NULL, 0); } -LWS_VISIBLE LWS_EXTERN int +int lws_callback_vhost_protocols(struct lws *wsi, int reason, void *in, int len) { int n; @@ -188,7 +188,7 @@ lws_callback_vhost_protocols(struct lws *wsi, int reason, void *in, int len) return 0; } -LWS_VISIBLE LWS_EXTERN int +int lws_callback_vhost_protocols_vhost(struct lws_vhost *vh, int reason, void *in, size_t len) { @@ -215,7 +215,7 @@ lws_callback_vhost_protocols_vhost(struct lws_vhost *vh, int reason, void *in, } -LWS_VISIBLE int +int lws_rx_flow_control(struct lws *wsi, int _enable) { struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi]; @@ -270,7 +270,7 @@ skip: return 0; } -LWS_VISIBLE void +void lws_rx_flow_allow_all_protocol(const struct lws_context *context, const struct lws_protocols *protocol) { @@ -306,7 +306,7 @@ int user_callback_handle_rxflow(lws_callback_function callback_function, return n; } -LWS_EXTERN int +int __lws_rx_flow_control(struct lws *wsi) { struct lws *wsic = wsi->child_list; @@ -359,7 +359,7 @@ __lws_rx_flow_control(struct lws *wsi) } -LWS_VISIBLE const struct lws_protocols * +const struct lws_protocols * lws_get_protocol(struct lws *wsi) { return wsi->protocol; @@ -388,7 +388,7 @@ lws_ensure_user_space(struct lws *wsi) return 0; } -LWS_VISIBLE void * +void * lws_adjust_protocol_psds(struct lws *wsi, size_t new_size) { ((struct lws_protocols *)lws_get_protocol(wsi))->per_session_data_size = @@ -400,13 +400,13 @@ lws_adjust_protocol_psds(struct lws *wsi, size_t new_size) return wsi->user_space; } -LWS_VISIBLE int +int lws_get_tsi(struct lws *wsi) { return (int)wsi->tsi; } -LWS_VISIBLE int +int lws_is_ssl(struct lws *wsi) { #if defined(LWS_WITH_TLS) @@ -418,20 +418,20 @@ lws_is_ssl(struct lws *wsi) } #if defined(LWS_WITH_TLS) && !defined(LWS_WITH_MBEDTLS) -LWS_VISIBLE lws_tls_conn* +lws_tls_conn* lws_get_ssl(struct lws *wsi) { return wsi->tls.ssl; } #endif -LWS_VISIBLE int +int lws_partial_buffered(struct lws *wsi) { return lws_has_buffered_out(wsi); } -LWS_VISIBLE lws_fileofs_t +lws_fileofs_t lws_get_peer_write_allowance(struct lws *wsi) { if (!wsi->role_ops->tx_credit) @@ -439,7 +439,7 @@ lws_get_peer_write_allowance(struct lws *wsi) return wsi->role_ops->tx_credit(wsi, LWSTXCR_US_TO_PEER, 0); } -LWS_VISIBLE void +void lws_role_transition(struct lws *wsi, enum lwsi_role role, enum lwsi_state state, const struct lws_role_ops *ops) { @@ -457,7 +457,7 @@ lws_role_transition(struct lws *wsi, enum lwsi_role role, enum lwsi_state state, #endif } -LWS_VISIBLE LWS_EXTERN int +int lws_parse_uri(char *p, const char **prot, const char **ads, int *port, const char **path) { @@ -513,7 +513,7 @@ lws_parse_uri(char *p, const char **prot, const char **ads, int *port, /* ... */ -LWS_VISIBLE LWS_EXTERN const char * +const char * lws_get_urlarg_by_name(struct lws *wsi, const char *name, char *buf, int len) { int n = 0, sl = (int)strlen(name); @@ -538,7 +538,7 @@ lws_get_urlarg_by_name(struct lws *wsi, const char *name, char *buf, int len) * extensions disabled. */ -LWS_VISIBLE int +int lws_extension_callback_pm_deflate(struct lws_context *context, const struct lws_extension *ext, struct lws *wsi, @@ -556,7 +556,7 @@ lws_extension_callback_pm_deflate(struct lws_context *context, return 0; } -LWS_EXTERN int +int lws_set_extension_option(struct lws *wsi, const char *ext_name, const char *opt_name, const char *opt_val) { @@ -564,7 +564,7 @@ lws_set_extension_option(struct lws *wsi, const char *ext_name, } #endif -LWS_VISIBLE LWS_EXTERN int +int lws_is_cgi(struct lws *wsi) { #ifdef LWS_WITH_CGI return !!wsi->http.cgi; @@ -626,13 +626,13 @@ lws_broadcast(struct lws_context_per_thread *pt, int reason, void *in, size_t le return ret; } -LWS_VISIBLE LWS_EXTERN void * +void * lws_wsi_user(struct lws *wsi) { return wsi->user_space; } -LWS_VISIBLE LWS_EXTERN void +void lws_set_wsi_user(struct lws *wsi, void *data) { if (wsi->user_space_externally_allocated) @@ -642,49 +642,49 @@ lws_set_wsi_user(struct lws *wsi, void *data) __func__); } -LWS_VISIBLE LWS_EXTERN struct lws * +struct lws * lws_get_parent(const struct lws *wsi) { return wsi->parent; } -LWS_VISIBLE LWS_EXTERN struct lws * +struct lws * lws_get_child(const struct lws *wsi) { return wsi->child_list; } -LWS_VISIBLE LWS_EXTERN void * +void * lws_get_opaque_parent_data(const struct lws *wsi) { return wsi->opaque_parent_data; } -LWS_VISIBLE LWS_EXTERN void +void lws_set_opaque_parent_data(struct lws *wsi, void *data) { wsi->opaque_parent_data = data; } -LWS_VISIBLE LWS_EXTERN void * +void * lws_get_opaque_user_data(const struct lws *wsi) { return wsi->opaque_user_data; } -LWS_VISIBLE LWS_EXTERN void +void lws_set_opaque_user_data(struct lws *wsi, void *data) { wsi->opaque_user_data = data; } -LWS_VISIBLE LWS_EXTERN int +int lws_get_child_pending_on_writable(const struct lws *wsi) { return wsi->parent_pending_cb_on_writable; } -LWS_VISIBLE LWS_EXTERN void +void lws_clear_child_pending_on_writable(struct lws *wsi) { wsi->parent_pending_cb_on_writable = 0; @@ -692,31 +692,31 @@ lws_clear_child_pending_on_writable(struct lws *wsi) -LWS_VISIBLE LWS_EXTERN const char * +const char * lws_get_vhost_name(struct lws_vhost *vhost) { return vhost->name; } -LWS_VISIBLE LWS_EXTERN int +int lws_get_vhost_port(struct lws_vhost *vhost) { return vhost->listen_port; } -LWS_VISIBLE LWS_EXTERN void * +void * lws_get_vhost_user(struct lws_vhost *vhost) { return vhost->user; } -LWS_VISIBLE LWS_EXTERN const char * +const char * lws_get_vhost_iface(struct lws_vhost *vhost) { return vhost->iface; } -LWS_VISIBLE lws_sockfd_type +lws_sockfd_type lws_get_socket_fd(struct lws *wsi) { if (!wsi) @@ -725,33 +725,33 @@ lws_get_socket_fd(struct lws *wsi) } -LWS_VISIBLE struct lws_vhost * +struct lws_vhost * lws_vhost_get(struct lws *wsi) { return wsi->vhost; } -LWS_VISIBLE struct lws_vhost * +struct lws_vhost * lws_get_vhost(struct lws *wsi) { return wsi->vhost; } -LWS_VISIBLE const struct lws_protocols * +const struct lws_protocols * lws_protocol_get(struct lws *wsi) { return wsi->protocol; } #if defined(LWS_WITH_UDP) -LWS_VISIBLE const struct lws_udp * +const struct lws_udp * lws_get_udp(const struct lws *wsi) { return wsi->udp; } #endif -LWS_VISIBLE LWS_EXTERN struct lws_context * +struct lws_context * lws_get_context(const struct lws *wsi) { return wsi->context; @@ -814,7 +814,7 @@ _lws_generic_transaction_completed_active_conn(struct lws *wsi) } #endif -LWS_VISIBLE int LWS_WARN_UNUSED_RESULT +int LWS_WARN_UNUSED_RESULT lws_raw_transaction_completed(struct lws *wsi) { if (lws_has_buffered_out(wsi)) { diff --git a/lib/core/context.c b/lib/core/context.c index 65e6d30ce..817591928 100644 --- a/lib/core/context.c +++ b/lib/core/context.c @@ -42,7 +42,7 @@ static uint32_t default_backoff_table[] = { 1000, 3000, 9000, 17000 }; * representing the library version followed by the git head hash it * was built from */ -LWS_VISIBLE const char * +const char * lws_get_library_version(void) { return library_version; @@ -151,7 +151,7 @@ lws_context_creation_completion_cb(lws_sorted_usec_list_t *sul) } #endif -LWS_VISIBLE struct lws_context * +struct lws_context * lws_create_context(const struct lws_context_creation_info *info) { struct lws_context *context = NULL; @@ -352,14 +352,13 @@ lws_create_context(const struct lws_context_creation_info *info) #else context->max_fds = sysconf(_SC_OPEN_MAX); #endif -#endif - if (context->max_fds < 0) { lwsl_err("%s: problem getting process max files\n", __func__); return NULL; } +#endif /* * deal with any max_fds override, if it's reducing (setting it to @@ -665,7 +664,7 @@ lws_create_context(const struct lws_context_creation_info *info) */ struct lws_context_creation_info ii; - const struct lws_protocols *pp[3]; + const struct lws_protocols *pp[4]; struct lws_vhost *vh; #if defined(LWS_WITH_SYS_ASYNC_DNS) extern const struct lws_protocols lws_async_dns_protocol; @@ -818,7 +817,7 @@ fail_event_libs: return NULL; } -LWS_VISIBLE LWS_EXTERN int +int lws_context_is_deprecated(struct lws_context *context) { return context->deprecated; @@ -1010,7 +1009,7 @@ lws_context_destroy2(struct lws_context *context) * Begin the context takedown */ -LWS_VISIBLE void +void lws_context_destroy(struct lws_context *context) { #if defined(LWS_WITH_NETWORK) diff --git a/lib/core/libwebsockets.c b/lib/core/libwebsockets.c index 2e39fc44e..ac5e8f2ce 100644 --- a/lib/core/libwebsockets.c +++ b/lib/core/libwebsockets.c @@ -659,7 +659,7 @@ lws_tokenize(struct lws_tokenize *ts) lws_tokenize_state state = LWS_TOKZS_LEADING_WHITESPACE; char c, flo = 0, d_minus = '-', d_dot = '.', s_minus = '\0', s_dot = '\0', skipping = 0; - signed char num = ts->flags & LWS_TOKENIZE_F_NO_INTEGERS ? 0 : -1; + signed char num = (ts->flags & LWS_TOKENIZE_F_NO_INTEGERS) ? 0 : -1; int utf8 = 0; /* for speed, compute the effect of the flags outside the loop */ diff --git a/lib/core/logs.c b/lib/core/logs.c index 43d40ae91..a1a241a8f 100644 --- a/lib/core/logs.c +++ b/lib/core/logs.c @@ -59,7 +59,7 @@ static const char * const log_level_names[] = { }; #endif -LWS_VISIBLE int +int lwsl_timestamp(int level, char *p, int len) { #ifndef LWS_PLAT_OPTEE @@ -130,7 +130,7 @@ static const char * const colours[] = { static char tty; -LWS_VISIBLE void +void lwsl_emit_stderr(int level, const char *line) { char buf[50]; @@ -153,7 +153,7 @@ lwsl_emit_stderr(int level, const char *line) fprintf(stderr, "%s%s", buf, line); } -LWS_VISIBLE void +void lwsl_emit_stderr_notimestamp(int level, const char *line) { int n, m = LWS_ARRAY_SIZE(colours) - 1; @@ -177,7 +177,7 @@ lwsl_emit_stderr_notimestamp(int level, const char *line) #endif #if !(defined(LWS_PLAT_OPTEE) && !defined(LWS_WITH_NETWORK)) -LWS_VISIBLE void _lws_logv(int filter, const char *format, va_list vl) +void _lws_logv(int filter, const char *format, va_list vl) { #if LWS_MAX_SMP == 1 static char buf[256]; @@ -205,7 +205,7 @@ LWS_VISIBLE void _lws_logv(int filter, const char *format, va_list vl) lwsl_emit(filter, buf); } -LWS_VISIBLE void _lws_log(int filter, const char *format, ...) +void _lws_log(int filter, const char *format, ...) { va_list ap; @@ -214,7 +214,7 @@ LWS_VISIBLE void _lws_log(int filter, const char *format, ...) va_end(ap); } #endif -LWS_VISIBLE void lws_set_log_level(int level, +void lws_set_log_level(int level, void (*func)(int level, const char *line)) { log_level = level; @@ -222,12 +222,12 @@ LWS_VISIBLE void lws_set_log_level(int level, lwsl_emit = func; } -LWS_VISIBLE int lwsl_visible(int level) +int lwsl_visible(int level) { return log_level & level; } -LWS_VISIBLE void +void lwsl_hexdump_level(int hexdump_level, const void *vbuf, size_t len) { unsigned char *buf = (unsigned char *)vbuf; @@ -280,7 +280,7 @@ lwsl_hexdump_level(int hexdump_level, const void *vbuf, size_t len) _lws_log(hexdump_level, "\n"); } -LWS_VISIBLE void +void lwsl_hexdump(const void *vbuf, size_t len) { #if defined(_DEBUG) diff --git a/lib/core/vfs.c b/lib/core/vfs.c index b66a9243c..8cd2a4611 100644 --- a/lib/core/vfs.c +++ b/lib/core/vfs.c @@ -24,31 +24,31 @@ #include "private-lib-core.h" -LWS_VISIBLE LWS_EXTERN void +void lws_set_fops(struct lws_context *context, const struct lws_plat_file_ops *fops) { context->fops = fops; } -LWS_VISIBLE LWS_EXTERN lws_filepos_t +lws_filepos_t lws_vfs_tell(lws_fop_fd_t fop_fd) { return fop_fd->pos; } -LWS_VISIBLE LWS_EXTERN lws_filepos_t +lws_filepos_t lws_vfs_get_length(lws_fop_fd_t fop_fd) { return fop_fd->len; } -LWS_VISIBLE LWS_EXTERN uint32_t +uint32_t lws_vfs_get_mod_time(lws_fop_fd_t fop_fd) { return fop_fd->mod_time; } -LWS_VISIBLE lws_fileofs_t +lws_fileofs_t lws_vfs_file_seek_set(lws_fop_fd_t fop_fd, lws_fileofs_t offset) { lws_fileofs_t ofs; @@ -59,7 +59,7 @@ lws_vfs_file_seek_set(lws_fop_fd_t fop_fd, lws_fileofs_t offset) } -LWS_VISIBLE lws_fileofs_t +lws_fileofs_t lws_vfs_file_seek_end(lws_fop_fd_t fop_fd, lws_fileofs_t offset) { return fop_fd->fops->LWS_FOP_SEEK_CUR(fop_fd, fop_fd->len + @@ -115,7 +115,7 @@ lws_vfs_select_fops(const struct lws_plat_file_ops *fops, const char *vfs_path, return fops; } -LWS_VISIBLE LWS_EXTERN lws_fop_fd_t LWS_WARN_UNUSED_RESULT +lws_fop_fd_t LWS_WARN_UNUSED_RESULT lws_vfs_file_open(const struct lws_plat_file_ops *fops, const char *vfs_path, lws_fop_flags_t *flags) { @@ -128,7 +128,7 @@ lws_vfs_file_open(const struct lws_plat_file_ops *fops, const char *vfs_path, } -LWS_VISIBLE struct lws_plat_file_ops * +struct lws_plat_file_ops * lws_get_fops(struct lws_context *context) { return (struct lws_plat_file_ops *)context->fops; diff --git a/lib/event-libs/libev/libev.c b/lib/event-libs/libev/libev.c index 568c2118a..e3ceccf19 100644 --- a/lib/event-libs/libev/libev.c +++ b/lib/event-libs/libev/libev.c @@ -104,7 +104,7 @@ lws_accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents) ev_idle_start(pt->ev.io_loop, &pt->ev.idle); } -LWS_VISIBLE void +void lws_ev_sigint_cb(struct ev_loop *loop, struct ev_signal *watcher, int revents) { struct lws_context *context = watcher->data; diff --git a/lib/event-libs/libevent/libevent.c b/lib/event-libs/libevent/libevent.c index 8a3f848e2..e14d54a68 100644 --- a/lib/event-libs/libevent/libevent.c +++ b/lib/event-libs/libevent/libevent.c @@ -131,7 +131,7 @@ lws_event_cb(evutil_socket_t sock_fd, short revents, void *ctx) evtimer_add(pt->event.idle_timer, &tv); } -LWS_VISIBLE void +void lws_event_sigint_cb(evutil_socket_t sock_fd, short revents, void *ctx) { struct lws_context_per_thread *pt = ctx; diff --git a/lib/event-libs/libuv/libuv.c b/lib/event-libs/libuv/libuv.c index d902209db..be00b0a2c 100644 --- a/lib/event-libs/libuv/libuv.c +++ b/lib/event-libs/libuv/libuv.c @@ -239,7 +239,7 @@ lws_uv_close_cb_sa(uv_handle_t *handle) * .... when the libuv object is created... */ -LWS_VISIBLE void +void lws_libuv_static_refcount_add(uv_handle_t *h, struct lws_context *context) { LWS_UV_REFCOUNT_STATIC_HANDLE_NEW(h, context); @@ -249,7 +249,7 @@ lws_libuv_static_refcount_add(uv_handle_t *h, struct lws_context *context) * ... and in the close callback when the object is closed. */ -LWS_VISIBLE void +void lws_libuv_static_refcount_del(uv_handle_t *h) { lws_uv_close_cb_sa(h); @@ -266,14 +266,14 @@ static void lws_uv_walk_cb(uv_handle_t *handle, void *arg) uv_close(handle, lws_uv_close_cb); } -LWS_VISIBLE void +void lws_close_all_handles_in_loop(uv_loop_t *loop) { uv_walk(loop, lws_uv_walk_cb, NULL); } -LWS_VISIBLE void +void lws_libuv_stop_without_kill(const struct lws_context *context, int tsi) { if (context->pt[tsi].uv.io_loop) @@ -282,7 +282,7 @@ lws_libuv_stop_without_kill(const struct lws_context *context, int tsi) -LWS_VISIBLE uv_loop_t * +uv_loop_t * lws_uv_getloop(struct lws_context *context, int tsi) { if (context->pt[tsi].uv.io_loop) @@ -367,8 +367,8 @@ lws_uv_plugins_init(struct lws_context *context, const char * const *d) #endif if (uv_dlsym(&lib, path, &v)) { uv_dlerror(&lib); - lwsl_err("Failed to get %s on %s: %s", path, - dent.name, lib.errmsg); + lwsl_err("%s: Failed to get '%s' on %s: %s\n", + __func__, path, dent.name, lib.errmsg); uv_dlclose(&lib); goto bail; } @@ -772,7 +772,7 @@ elops_destroy_pt_uv(struct lws_context *context, int tsi) * called again to bind the vhost */ -LWS_VISIBLE int +int elops_init_pt_uv(struct lws_context *context, void *_loop, int tsi) { struct lws_context_per_thread *pt = &context->pt[tsi]; diff --git a/lib/jose/jwe/enc/aeskw.c b/lib/jose/jwe/enc/aeskw.c index 28b5636ed..43bbbeb61 100644 --- a/lib/jose/jwe/enc/aeskw.c +++ b/lib/jose/jwe/enc/aeskw.c @@ -53,7 +53,7 @@ lws_jwe_encrypt_aeskw_cbc_hs(struct lws_jwe *jwe, char *temp, int *temp_len) /* create a b64 version of the JOSE header, needed for hashing */ if (lws_jws_encode_b64_element(&jwe->jws.map_b64, LJWE_JOSE, - temp + (ot - *temp_len), temp_len, + temp, temp_len, jwe->jws.map.buf[LJWE_JOSE], jwe->jws.map.len[LJWE_JOSE])) return -1; diff --git a/lib/jose/jwe/jwe-ecdh-es-aeskw.c b/lib/jose/jwe/jwe-ecdh-es-aeskw.c index bd33b5f74..154b543b5 100644 --- a/lib/jose/jwe/jwe-ecdh-es-aeskw.c +++ b/lib/jose/jwe/jwe-ecdh-es-aeskw.c @@ -334,9 +334,9 @@ lws_jwe_encrypt_ecdh(struct lws_jwe *jwe, char *temp, int *temp_len, /* rewrite the protected JOSE header to have the epk pieces */ - jwe->jws.map.buf[LJWE_JOSE] = temp + (ot - *temp_len); + jwe->jws.map.buf[LJWE_JOSE] = temp; - m = n = lws_snprintf(temp + (ot - *temp_len), *temp_len, + m = n = lws_snprintf(temp, *temp_len, "{\"alg\":\"%s\", \"enc\":\"%s\", \"epk\":", jwe->jose.alg->alg, jwe->jose.enc_alg->alg); *temp_len -= n; diff --git a/lib/jose/jwe/jwe-rsa-aescbc.c b/lib/jose/jwe/jwe-rsa-aescbc.c index 3a6e92690..4683772c1 100644 --- a/lib/jose/jwe/jwe-rsa-aescbc.c +++ b/lib/jose/jwe/jwe-rsa-aescbc.c @@ -63,7 +63,7 @@ lws_jwe_encrypt_rsa_aes_cbc_hs(struct lws_jwe *jwe, * Create a b64 version of the JOSE header, needed as aad */ if (lws_jws_encode_b64_element(&jwe->jws.map_b64, LJWE_JOSE, - temp + (ot - *temp_len), temp_len, + temp, temp_len, jwe->jws.map.buf[LJWE_JOSE], jwe->jws.map.len[LJWE_JOSE])) return -1; diff --git a/lib/jose/jwe/jwe-rsa-aesgcm.c b/lib/jose/jwe/jwe-rsa-aesgcm.c index 24814d1ec..d62940394 100644 --- a/lib/jose/jwe/jwe-rsa-aesgcm.c +++ b/lib/jose/jwe/jwe-rsa-aesgcm.c @@ -44,7 +44,7 @@ lws_jwe_encrypt_rsa_aes_gcm(struct lws_jwe *jwe, char *temp, int *temp_len) /* create the IV + CEK */ if (lws_jws_randomize_element(jwe->jws.context, &jwe->jws.map, LJWE_IV, - temp + (ot - *temp_len), temp_len, + temp, temp_len, LWS_AESGCM_IV, 0)) return -1; diff --git a/lib/jose/jwe/jwe.c b/lib/jose/jwe/jwe.c index bf43a1908..81ca014af 100644 --- a/lib/jose/jwe/jwe.c +++ b/lib/jose/jwe/jwe.c @@ -310,7 +310,7 @@ lws_jwa_concat_kdf(struct lws_jwe *jwe, int direct, uint8_t *out, return 0; } -LWS_VISIBLE void +void lws_jwe_be64(uint64_t c, uint8_t *p8) { int n; @@ -319,7 +319,7 @@ lws_jwe_be64(uint64_t c, uint8_t *p8) *p8++ = (uint8_t)((c >> n) & 0xff); } -LWS_VISIBLE int +int lws_jwe_auth_and_decrypt(struct lws_jwe *jwe, char *temp, int *temp_len) { int valid_aescbc_hmac, valid_aesgcm; @@ -380,7 +380,7 @@ lws_jwe_auth_and_decrypt(struct lws_jwe *jwe, char *temp, int *temp_len) return -1; } -LWS_VISIBLE int +int lws_jwe_encrypt(struct lws_jwe *jwe, char *temp, int *temp_len) { int valid_aescbc_hmac, valid_aesgcm, ot = *temp_len, ret = -1; @@ -474,7 +474,7 @@ bail: * - You can't emit Compact representation if there are multiple recipients */ -LWS_VISIBLE int +int lws_jwe_render_compact(struct lws_jwe *jwe, char *out, size_t out_len) { size_t orig = out_len; @@ -544,7 +544,7 @@ lws_jwe_render_compact(struct lws_jwe *jwe, char *out, size_t out_len) return orig - out_len; } -LWS_VISIBLE int +int lws_jwe_create_packet(struct lws_jwe *jwe, const char *payload, size_t len, const char *nonce, char *out, size_t out_len, struct lws_context *context) @@ -718,7 +718,7 @@ static int protected_idx[] = { * } */ -LWS_VISIBLE int +int lws_jwe_render_flattened(struct lws_jwe *jwe, char *out, size_t out_len) { char buf[3072], *p1, *end1, protected[128]; diff --git a/lib/jose/jwk/jwk.c b/lib/jose/jwk/jwk.c index bbf5031b8..7e39ef83a 100644 --- a/lib/jose/jwk/jwk.c +++ b/lib/jose/jwk/jwk.c @@ -164,7 +164,7 @@ static const char *ec_names[] = { }; static const char ec_b64[] = { 0, 1, 1, 1 }; -LWS_VISIBLE int +int lws_jwk_dump(struct lws_jwk *jwk) { const char **enames, *b64; @@ -287,7 +287,7 @@ lws_jwk_destroy_elements(struct lws_gencrypto_keyelem *el, int m) } } -LWS_VISIBLE void +void lws_jwk_destroy(struct lws_jwk *jwk) { lws_jwk_destroy_elements(jwk->e, LWS_ARRAY_SIZE(jwk->e)); @@ -550,7 +550,7 @@ lws_jwk_init_jps(struct lejp_ctx *jctx, struct lws_jwk_parse_state *jps, LWS_ARRAY_SIZE(jwk_tok)); } -LWS_VISIBLE int +int lws_jwk_dup_oct(struct lws_jwk *jwk, const void *key, int len) { jwk->e[LWS_GENCRYPTO_KTY_OCT].buf = lws_malloc(len, __func__); @@ -565,7 +565,7 @@ lws_jwk_dup_oct(struct lws_jwk *jwk, const void *key, int len) return 0; } -LWS_VISIBLE int +int lws_jwk_generate(struct lws_context *context, struct lws_jwk *jwk, enum lws_gencrypto_kty kty, int bits, const char *curve) { @@ -635,7 +635,7 @@ lws_jwk_generate(struct lws_context *context, struct lws_jwk *jwk, return 0; } -LWS_VISIBLE int +int lws_jwk_import(struct lws_jwk *jwk, lws_jwk_key_import_callback cb, void *user, const char *in, size_t len) { @@ -667,7 +667,7 @@ lws_jwk_import(struct lws_jwk *jwk, lws_jwk_key_import_callback cb, void *user, } -LWS_VISIBLE int +int lws_jwk_export(struct lws_jwk *jwk, int flags, char *p, int *len) { char *start = p, *end = &p[*len - 1]; @@ -812,7 +812,7 @@ lws_jwk_export(struct lws_jwk *jwk, int flags, char *p, int *len) return p - start; } -LWS_VISIBLE int +int lws_jwk_rfc7638_fingerprint(struct lws_jwk *jwk, char *digest32) { struct lws_genhash_ctx hash_ctx; @@ -846,7 +846,7 @@ bail: return -1; } -LWS_VISIBLE int +int lws_jwk_strdup_meta(struct lws_jwk *jwk, enum enum_jwk_meta_tok idx, const char *in, int len) { @@ -859,7 +859,7 @@ lws_jwk_strdup_meta(struct lws_jwk *jwk, enum enum_jwk_meta_tok idx, return 0; } -LWS_VISIBLE int +int lws_jwk_load(struct lws_jwk *jwk, const char *filename, lws_jwk_key_import_callback cb, void *user) { @@ -884,7 +884,7 @@ bail: return -1; } -LWS_VISIBLE int +int lws_jwk_save(struct lws_jwk *jwk, const char *filename) { int buflen = 4096; diff --git a/lib/jose/jws/jws.c b/lib/jose/jws/jws.c index 87b8e2eef..1a95e41ae 100644 --- a/lib/jose/jws/jws.c +++ b/lib/jose/jws/jws.c @@ -160,7 +160,7 @@ lws_jws_json_parse(struct lws_jws *jws, const uint8_t *buf, int len, return 0; } -LWS_VISIBLE void +void lws_jws_init(struct lws_jws *jws, struct lws_jwk *jwk, struct lws_context *context) { @@ -181,14 +181,14 @@ lws_jws_map_bzero(struct lws_jws_map *map) lws_explicit_bzero((void *)map->buf[n], map->len[n]); } -LWS_VISIBLE void +void lws_jws_destroy(struct lws_jws *jws) { lws_jws_map_bzero(&jws->map); jws->jwk = NULL; } -LWS_VISIBLE int +int lws_jws_dup_element(struct lws_jws_map *map, int idx, char *temp, int *temp_len, const void *in, size_t in_len, size_t actual_alloc) { @@ -208,7 +208,7 @@ lws_jws_dup_element(struct lws_jws_map *map, int idx, char *temp, int *temp_len, return 0; } -LWS_VISIBLE int +int lws_jws_encode_b64_element(struct lws_jws_map *map, int idx, char *temp, int *temp_len, const void *in, size_t in_len) @@ -230,7 +230,7 @@ lws_jws_encode_b64_element(struct lws_jws_map *map, int idx, return 0; } -LWS_VISIBLE int +int lws_jws_randomize_element(struct lws_context *context, struct lws_jws_map *map, int idx, char *temp, int *temp_len, size_t random_len, size_t actual_alloc) @@ -254,7 +254,7 @@ lws_jws_randomize_element(struct lws_context *context, struct lws_jws_map *map, return 0; } -LWS_VISIBLE int +int lws_jws_alloc_element(struct lws_jws_map *map, int idx, char *temp, int *temp_len, size_t len, size_t actual_alloc) { @@ -271,7 +271,7 @@ lws_jws_alloc_element(struct lws_jws_map *map, int idx, char *temp, return 0; } -LWS_VISIBLE int +int lws_jws_base64_enc(const char *in, size_t in_len, char *out, size_t out_max) { int n; @@ -292,7 +292,7 @@ lws_jws_base64_enc(const char *in, size_t in_len, char *out, size_t out_max) return n; } -LWS_VISIBLE int +int lws_jws_b64_compact_map(const char *in, int len, struct lws_jws_map *map) { int me = 0; @@ -320,7 +320,7 @@ lws_jws_b64_compact_map(const char *in, int len, struct lws_jws_map *map) * map_b64 set to b64 elements */ -LWS_VISIBLE int +int lws_jws_compact_decode(const char *in, int len, struct lws_jws_map *map, struct lws_jws_map *map_b64, char *out, int *out_len) @@ -387,7 +387,7 @@ lws_jws_compact_decode_map(struct lws_jws_map *map_b64, struct lws_jws_map *map, return 0; } -LWS_VISIBLE int +int lws_jws_encode_section(const char *in, size_t in_len, int first, char **p, char *end) { @@ -409,7 +409,7 @@ lws_jws_encode_section(const char *in, size_t in_len, int first, char **p, return (*p) - p_entry; } -LWS_VISIBLE int +int lws_jws_compact_encode(struct lws_jws_map *map_b64, /* b64-encoded */ const struct lws_jws_map *map, /* non-b64 */ char *buf, int *len) @@ -441,7 +441,7 @@ lws_jws_compact_encode(struct lws_jws_map *map_b64, /* b64-encoded */ * the JOSE header and signature, decoded versions too. */ -LWS_VISIBLE int +int lws_jws_sig_confirm(struct lws_jws_map *map_b64, struct lws_jws_map *map, struct lws_jwk *jwk, struct lws_context *context) { @@ -516,7 +516,7 @@ lws_jws_sig_confirm(struct lws_jws_map *map_b64, struct lws_jws_map *map, return -1; } - h_len = lws_genhash_size(jose.alg->hash_type); + // h_len = lws_genhash_size(jose.alg->hash_type); if (lws_genrsa_create(&rsactx, jwk->e, context, padding, LWS_GENHASH_TYPE_UNKNOWN)) { @@ -666,7 +666,7 @@ lws_jws_sig_confirm(struct lws_jws_map *map_b64, struct lws_jws_map *map, /* it's already a b64 map, we will make a temp plain version */ -LWS_VISIBLE int +int lws_jws_sig_confirm_compact_b64_map(struct lws_jws_map *map_b64, struct lws_jwk *jwk, struct lws_context *context, @@ -687,7 +687,7 @@ lws_jws_sig_confirm_compact_b64_map(struct lws_jws_map *map_b64, * plain version */ -LWS_VISIBLE int +int lws_jws_sig_confirm_compact_b64(const char *in, size_t len, struct lws_jws_map *map, struct lws_jwk *jwk, struct lws_context *context, @@ -708,7 +708,7 @@ lws_jws_sig_confirm_compact_b64(const char *in, size_t len, /* it's already plain, we will make a temp b64 version */ -LWS_VISIBLE int +int lws_jws_sig_confirm_compact(struct lws_jws_map *map, struct lws_jwk *jwk, struct lws_context *context, char *temp, int *temp_len) @@ -887,7 +887,7 @@ lws_jws_sign_from_b64(struct lws_jose *jose, struct lws_jws *jws, * } */ -LWS_VISIBLE int +int lws_jws_write_flattened_json(struct lws_jws *jws, char *flattened, size_t len) { size_t n = 0; @@ -922,7 +922,7 @@ lws_jws_write_flattened_json(struct lws_jws *jws, char *flattened, size_t len) return (n >= len - 1); } -LWS_VISIBLE int +int lws_jws_write_compact(struct lws_jws *jws, char *compact, size_t len) { size_t n = 0; diff --git a/lib/misc/base64-decode.c b/lib/misc/base64-decode.c index 3a88c84ee..9503eaa22 100644 --- a/lib/misc/base64-decode.c +++ b/lib/misc/base64-decode.c @@ -52,9 +52,7 @@ _lws_b64_encode_string(const char *encode, const char *in, int in_len, char *out, int out_size) { unsigned char triple[3]; - int i; - int line = 0; - int done = 0; + int i, done = 0; while (in_len) { int len = 0; @@ -78,7 +76,6 @@ _lws_b64_encode_string(const char *encode, const char *in, int in_len, *out++ = (len > 2 ? encode[triple[2] & 0x3f] : '='); done += 4; - line += 4; } if (done + 1 >= out_size) @@ -89,13 +86,13 @@ _lws_b64_encode_string(const char *encode, const char *in, int in_len, return done; } -LWS_VISIBLE int +int lws_b64_encode_string(const char *in, int in_len, char *out, int out_size) { return _lws_b64_encode_string(encode_orig, in, in_len, out, out_size); } -LWS_VISIBLE int +int lws_b64_encode_string_url(const char *in, int in_len, char *out, int out_size) { return _lws_b64_encode_string(encode_url, in, in_len, out, out_size); @@ -200,13 +197,13 @@ _lws_b64_decode_string(const char *in, int in_len, char *out, int out_size) return ol; } -LWS_VISIBLE int +int lws_b64_decode_string(const char *in, char *out, int out_size) { return _lws_b64_decode_string(in, -1, out, out_size); } -LWS_VISIBLE int +int lws_b64_decode_string_len(const char *in, int in_len, char *out, int out_size) { return _lws_b64_decode_string(in, in_len, out, out_size); diff --git a/lib/misc/daemonize.c b/lib/misc/daemonize.c index fe9630030..9a1f6135a 100644 --- a/lib/misc/daemonize.c +++ b/lib/misc/daemonize.c @@ -99,7 +99,7 @@ static void lws_daemon_closing(int sigact) * The process context you called from has been terminated then. */ -LWS_VISIBLE int +int lws_daemonize(const char *_lock_path) { struct sigaction act; diff --git a/lib/misc/lws-ring.c b/lib/misc/lws-ring.c index a7c0d6c6f..0fb53a077 100644 --- a/lib/misc/lws-ring.c +++ b/lib/misc/lws-ring.c @@ -24,7 +24,7 @@ #include "private-lib-core.h" -LWS_VISIBLE LWS_EXTERN struct lws_ring * +struct lws_ring * lws_ring_create(size_t element_len, size_t count, void (*destroy_element)(void *)) { @@ -49,7 +49,7 @@ lws_ring_create(size_t element_len, size_t count, return ring; } -LWS_VISIBLE LWS_EXTERN void +void lws_ring_destroy(struct lws_ring *ring) { if (ring->destroy_element) @@ -66,7 +66,7 @@ lws_ring_destroy(struct lws_ring *ring) lws_free(ring); } -LWS_VISIBLE LWS_EXTERN size_t +size_t lws_ring_get_count_free_elements(struct lws_ring *ring) { int f; @@ -96,7 +96,7 @@ lws_ring_get_count_free_elements(struct lws_ring *ring) return f / ring->element_len; } -LWS_VISIBLE LWS_EXTERN size_t +size_t lws_ring_get_count_waiting_elements(struct lws_ring *ring, uint32_t *tail) { int f; @@ -122,7 +122,7 @@ lws_ring_get_count_waiting_elements(struct lws_ring *ring, uint32_t *tail) return f / ring->element_len; } -LWS_VISIBLE LWS_EXTERN int +int lws_ring_next_linear_insert_range(struct lws_ring *ring, void **start, size_t *bytes) { @@ -147,13 +147,13 @@ lws_ring_next_linear_insert_range(struct lws_ring *ring, void **start, return 0; } -LWS_VISIBLE LWS_EXTERN void +void lws_ring_bump_head(struct lws_ring *ring, size_t bytes) { ring->head = (ring->head + (uint32_t)bytes) % ring->buflen; } -LWS_VISIBLE LWS_EXTERN size_t +size_t lws_ring_insert(struct lws_ring *ring, const void *src, size_t max_count) { const uint8_t *osrc = src; @@ -194,7 +194,7 @@ lws_ring_insert(struct lws_ring *ring, const void *src, size_t max_count) return (((uint8_t *)src + n) - osrc) / ring->element_len; } -LWS_VISIBLE LWS_EXTERN size_t +size_t lws_ring_consume(struct lws_ring *ring, uint32_t *tail, void *dest, size_t max_count) { @@ -250,7 +250,7 @@ lws_ring_consume(struct lws_ring *ring, uint32_t *tail, void *dest, return (((uint8_t *)dest + n) - odest) / ring->element_len; } -LWS_VISIBLE LWS_EXTERN const void * +const void * lws_ring_get_element(struct lws_ring *ring, uint32_t *tail) { if (!tail) @@ -262,7 +262,7 @@ lws_ring_get_element(struct lws_ring *ring, uint32_t *tail) return ((uint8_t *)ring->buf) + *tail; } -LWS_VISIBLE LWS_EXTERN void +void lws_ring_update_oldest_tail(struct lws_ring *ring, uint32_t tail) { if (!ring->destroy_element) { @@ -277,13 +277,13 @@ lws_ring_update_oldest_tail(struct lws_ring *ring, uint32_t tail) } } -LWS_VISIBLE LWS_EXTERN uint32_t +uint32_t lws_ring_get_oldest_tail(struct lws_ring *ring) { return ring->oldest_tail; } -LWS_VISIBLE LWS_EXTERN void +void lws_ring_dump(struct lws_ring *ring, uint32_t *tail) { if (tail == NULL) diff --git a/lib/misc/lws-struct-lejp.c b/lib/misc/lws-struct-lejp.c index a634211e0..3e033a58a 100644 --- a/lib/misc/lws-struct-lejp.c +++ b/lib/misc/lws-struct-lejp.c @@ -92,8 +92,8 @@ lws_struct_default_lejp_cb(struct lejp_ctx *ctx, char reason) lws_struct_args_t *args = (lws_struct_args_t *)ctx->user; const lws_struct_map_t *map, *pmap = NULL; uint8_t *ch; - char *u; size_t n; + char *u; if (reason == LEJPCB_ARRAY_END) { lejp_parser_pop(ctx); @@ -103,7 +103,6 @@ lws_struct_default_lejp_cb(struct lejp_ctx *ctx, char reason) if (reason == LEJPCB_ARRAY_START) { map = &args->map_st[ctx->pst_sp][ctx->path_match - 1]; - n = args->map_entries_st[ctx->pst_sp]; if (map->type == LSMT_LIST) lws_struct_lejp_push(ctx, args, map, NULL); diff --git a/lib/misc/sha-1.c b/lib/misc/sha-1.c index b38971ffb..109bfdb8d 100644 --- a/lib/misc/sha-1.c +++ b/lib/misc/sha-1.c @@ -281,7 +281,7 @@ sha1_result(struct sha1_ctxt *ctxt, void *digest0) * This should look and work like the libcrypto implementation */ -LWS_VISIBLE unsigned char * +unsigned char * lws_SHA1(const unsigned char *d, size_t n, unsigned char *md) { struct sha1_ctxt ctx; diff --git a/lib/misc/threadpool/threadpool.c b/lib/misc/threadpool/threadpool.c index 7415d6065..2a8bcbeaa 100644 --- a/lib/misc/threadpool/threadpool.c +++ b/lib/misc/threadpool/threadpool.c @@ -149,7 +149,7 @@ __lws_threadpool_task_dump(struct lws_threadpool_task *task, char *buf, int len) return; } - buf += lws_snprintf(buf, end - buf, + lws_snprintf(buf, end - buf, "task: %s, DONE state %d lived: %dms " "(queued %dms, on thread: %dms, " "ran: %d%%, synced: %d%%)", task->name, task->status, diff --git a/lib/plat/freertos/freertos-file.c b/lib/plat/freertos/freertos-file.c index cc5494421..e19f87fc9 100644 --- a/lib/plat/freertos/freertos-file.c +++ b/lib/plat/freertos/freertos-file.c @@ -30,7 +30,7 @@ int lws_plat_apply_FD_CLOEXEC(int n) } -LWS_VISIBLE lws_fop_fd_t IRAM_ATTR +lws_fop_fd_t IRAM_ATTR _lws_plat_file_open(const struct lws_plat_file_ops *fops, const char *filename, const char *vpath, lws_fop_flags_t *flags) { @@ -63,7 +63,7 @@ bail: return NULL; } -LWS_VISIBLE int IRAM_ATTR +int IRAM_ATTR _lws_plat_file_close(lws_fop_fd_t *fops_fd) { int fd = (*fops_fd)->fd; @@ -74,13 +74,13 @@ _lws_plat_file_close(lws_fop_fd_t *fops_fd) return close(fd); } -LWS_VISIBLE lws_fileofs_t IRAM_ATTR +lws_fileofs_t IRAM_ATTR _lws_plat_file_seek_cur(lws_fop_fd_t fops_fd, lws_fileofs_t offset) { return lseek(fops_fd->fd, offset, SEEK_CUR); } -LWS_VISIBLE int IRAM_ATTR +int IRAM_ATTR _lws_plat_file_read(lws_fop_fd_t fops_fd, lws_filepos_t *amount, uint8_t *buf, lws_filepos_t len) { @@ -97,7 +97,7 @@ _lws_plat_file_read(lws_fop_fd_t fops_fd, lws_filepos_t *amount, return 0; } -LWS_VISIBLE int IRAM_ATTR +int IRAM_ATTR _lws_plat_file_write(lws_fop_fd_t fops_fd, lws_filepos_t *amount, uint8_t *buf, lws_filepos_t len) { @@ -153,7 +153,7 @@ lws_find_string_in_file(const char *filename, const char *string, int stringlen) #endif #if !defined(LWS_AMAZON_RTOS) -LWS_VISIBLE int +int lws_plat_write_file(const char *filename, void *buf, int len) { nvs_handle nvh; @@ -177,7 +177,7 @@ lws_plat_write_file(const char *filename, void *buf, int len) /* we write vhostname.cert.pem and vhostname.key.pem, 0 return means OK */ -LWS_VISIBLE int +int lws_plat_write_cert(struct lws_vhost *vhost, int is_key, int fd, void *buf, int len) { @@ -189,7 +189,7 @@ lws_plat_write_cert(struct lws_vhost *vhost, int is_key, int fd, void *buf, return lws_plat_write_file(name, buf, len) < 0; } -LWS_VISIBLE int +int lws_plat_read_file(const char *filename, void *buf, int len) { nvs_handle nvh; diff --git a/lib/plat/freertos/freertos-misc.c b/lib/plat/freertos/freertos-misc.c index 0cf774ff6..78be49158 100644 --- a/lib/plat/freertos/freertos-misc.c +++ b/lib/plat/freertos/freertos-misc.c @@ -32,7 +32,7 @@ lws_now_usecs(void) return ((unsigned long long)tv.tv_sec * 1000000LL) + tv.tv_usec; } -LWS_VISIBLE int +int lws_get_random(struct lws_context *context, void *buf, int len) { #if defined(LWS_WITH_ESP32) @@ -69,7 +69,7 @@ lws_get_random(struct lws_context *context, void *buf, int len) } -LWS_VISIBLE void lwsl_emit_syslog(int level, const char *line) +void lwsl_emit_syslog(int level, const char *line) { lwsl_emit_stderr(level, line); } diff --git a/lib/plat/freertos/freertos-service.c b/lib/plat/freertos/freertos-service.c index dfbaf6c46..d36b1ec1e 100644 --- a/lib/plat/freertos/freertos-service.c +++ b/lib/plat/freertos/freertos-service.c @@ -37,7 +37,7 @@ lws_plat_service(struct lws_context *context, int timeout_ms) } -LWS_EXTERN int +int _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi) { struct lws_context_per_thread *pt; diff --git a/lib/plat/optee/network.c b/lib/plat/optee/network.c index 353bdda93..80a1c228b 100644 --- a/lib/plat/optee/network.c +++ b/lib/plat/optee/network.c @@ -42,7 +42,7 @@ lws_plat_pipe_close(struct lws *wsi) { } -LWS_VISIBLE int +int lws_send_pipe_choked(struct lws *wsi) { struct lws *wsi_eff; @@ -79,7 +79,7 @@ lws_poll_listen_fd(struct lws_pollfd *fd) } -LWS_EXTERN int +int _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi) { lws_usec_t timeout_us = timeout_ms * LWS_US_PER_MS; diff --git a/lib/plat/unix/android/android-resolv.c b/lib/plat/unix/android/android-resolv.c index db635485b..d28fb9cc1 100644 --- a/lib/plat/unix/android/android-resolv.c +++ b/lib/plat/unix/android/android-resolv.c @@ -28,7 +28,7 @@ lws_async_dns_server_check_t lws_plat_asyncdns_init(struct lws_context *context, lws_sockaddr46 *sa46) { - char d[PROP_VALUE_MAX], *p = d; + char d[PROP_VALUE_MAX], *p; uint32_t ip32; uint8_t i[4]; int n; diff --git a/lib/plat/unix/unix-fds.c b/lib/plat/unix/unix-fds.c index b1d3f1c07..3fee0abb9 100644 --- a/lib/plat/unix/unix-fds.c +++ b/lib/plat/unix/unix-fds.c @@ -81,7 +81,7 @@ insert_wsi(const struct lws_context *context, struct lws *wsi) /* confirm fd doesn't already exist */ - while (p != done && (!*p || (*p && (*p)->desc.sockfd != wsi->desc.sockfd))) + while (p != done && (!*p || (*p)->desc.sockfd != wsi->desc.sockfd)) p++; if (p != done) { @@ -126,7 +126,7 @@ delete_from_fd(const struct lws_context *context, int fd) /* find the match */ - while (p != done && (!*p || (*p && (*p)->desc.sockfd != fd))) + while (p != done && (!*p || (*p)->desc.sockfd != fd)) p++; if (p == done) @@ -136,7 +136,7 @@ delete_from_fd(const struct lws_context *context, int fd) #if defined(_DEBUG) p = context->lws_lookup; - while (p != done && (!*p || (*p && (*p)->desc.sockfd != fd))) + while (p != done && (!*p || (*p)->desc.sockfd != fd)) p++; if (p != done) { diff --git a/lib/plat/unix/unix-misc.c b/lib/plat/unix/unix-misc.c index 05b4d7ee1..59dac2cac 100644 --- a/lib/plat/unix/unix-misc.c +++ b/lib/plat/unix/unix-misc.c @@ -47,13 +47,13 @@ lws_now_usecs(void) #endif } -LWS_VISIBLE int +int lws_get_random(struct lws_context *context, void *buf, int len) { return read(context->fd_random, (char *)buf, len); } -LWS_VISIBLE void lwsl_emit_syslog(int level, const char *line) +void lwsl_emit_syslog(int level, const char *line) { int syslog_level = LOG_DEBUG; diff --git a/lib/plat/unix/unix-plugins.c b/lib/plat/unix/unix-plugins.c index 259a53d63..4e2e656f2 100644 --- a/lib/plat/unix/unix-plugins.c +++ b/lib/plat/unix/unix-plugins.c @@ -89,16 +89,15 @@ lws_plat_plugins_init(struct lws_context * context, const char * const *d) path[m - 3] = '\0'; /* snip the .so */ initfunc = dlsym(l, path); if (!initfunc) { - lwsl_err("Failed to get init on %s: %s", - namelist[i]->d_name, dlerror()); - dlclose(l); + lwsl_err("%s: Failed to get init '%s' on %s: %s\n", + __func__, path, namelist[i]->d_name, dlerror()); + goto skip; } lcaps.api_magic = LWS_PLUGIN_API_MAGIC; m = initfunc(context, &lcaps); if (m) { lwsl_err("Initializing %s failed %d\n", namelist[i]->d_name, m); - dlclose(l); goto skip; } diff --git a/lib/plat/windows/windows-misc.c b/lib/plat/windows/windows-misc.c index 7a7c824bb..6bbc56406 100644 --- a/lib/plat/windows/windows-misc.c +++ b/lib/plat/windows/windows-misc.c @@ -68,7 +68,7 @@ time_t time(time_t *t) } #endif -LWS_VISIBLE int +int lws_get_random(struct lws_context *context, void *buf, int len) { int n; @@ -81,7 +81,7 @@ lws_get_random(struct lws_context *context, void *buf, int len) } -LWS_VISIBLE void +void lwsl_emit_syslog(int level, const char *line) { lwsl_emit_stderr(level, line); diff --git a/lib/plat/windows/windows-service.c b/lib/plat/windows/windows-service.c index 9a0d01494..7c7fc8e35 100644 --- a/lib/plat/windows/windows-service.c +++ b/lib/plat/windows/windows-service.c @@ -55,7 +55,7 @@ _lws_plat_service_forced_tsi(struct lws_context *context, int tsi) } -LWS_EXTERN int +int _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi) { struct lws_context_per_thread *pt; diff --git a/lib/plat/windows/windows-sockets.c b/lib/plat/windows/windows-sockets.c index e9d40d59f..02c3ce8d0 100644 --- a/lib/plat/windows/windows-sockets.c +++ b/lib/plat/windows/windows-sockets.c @@ -28,7 +28,7 @@ #include "private-lib-core.h" -LWS_VISIBLE int +int lws_send_pipe_choked(struct lws *wsi) { struct lws *wsi_eff; @@ -138,7 +138,7 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, lws_sockfd_type fd, } -LWS_EXTERN int +int lws_interface_to_sa(int ipv6, const char *ifname, struct sockaddr_in *addr, size_t addrlen) { diff --git a/lib/roles/cgi/cgi-server.c b/lib/roles/cgi/cgi-server.c index a0f3bc891..075cf1f4a 100644 --- a/lib/roles/cgi/cgi-server.c +++ b/lib/roles/cgi/cgi-server.c @@ -114,7 +114,7 @@ lws_create_basic_wsi(struct lws_context *context, int tsi) return new_wsi; } -LWS_VISIBLE LWS_EXTERN int +int lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len, int timeout_secs, const struct lws_protocol_vhost_options *mp_cgienv) @@ -566,7 +566,7 @@ enum header_recode { HR_CRLF, }; -LWS_VISIBLE LWS_EXTERN int +int lws_cgi_write_split_stdout_headers(struct lws *wsi) { int n, m, cmd; @@ -1003,7 +1003,7 @@ agin: return 0; } -LWS_VISIBLE LWS_EXTERN int +int lws_cgi_kill(struct lws *wsi) { struct lws_cgi_args args; @@ -1215,7 +1215,7 @@ finish_him: return 0; } -LWS_VISIBLE LWS_EXTERN struct lws * +struct lws * lws_cgi_get_stdwsi(struct lws *wsi, enum lws_enum_stdinouterr ch) { if (!wsi->http.cgi) diff --git a/lib/roles/h1/ops-h1.c b/lib/roles/h1/ops-h1.c index 6007a1a06..0287eed8f 100644 --- a/lib/roles/h1/ops-h1.c +++ b/lib/roles/h1/ops-h1.c @@ -766,7 +766,7 @@ rops_write_role_protocol_h1(struct lws *wsi, unsigned char *buf, size_t len, #if defined(LWS_WITH_HTTP_STREAM_COMPRESSION) if (wsi->http.lcs && (((*wp) & 0x1f) == LWS_WRITE_HTTP_FINAL || ((*wp) & 0x1f) == LWS_WRITE_HTTP)) { - unsigned char mtubuf[1400 + LWS_PRE + + unsigned char mtubuf[1500 + LWS_PRE + LWS_HTTP_CHUNK_HDR_MAX_SIZE + LWS_HTTP_CHUNK_TRL_MAX_SIZE], *out = mtubuf + LWS_PRE + @@ -982,9 +982,13 @@ rops_client_bind_h1(struct lws *wsi, const struct lws_client_connect_info *i) /* * Clients that want to be h1, h2, or ws all start out as h1 - * (we don't yet know if the server supports h2 or ws) + * (we don't yet know if the server supports h2 or ws), unless their + * alpn is only "h2" */ +// if (i->alpn && !strcmp(i->alpn, "h2")) +// return 0; /* we are h1, he only wants h2 */ + if (!i->method) { /* websockets */ #if defined(LWS_ROLE_WS) if (lws_create_client_ws_object(i, wsi)) diff --git a/lib/roles/h2/http2.c b/lib/roles/h2/http2.c index 1332778ed..77df0b266 100644 --- a/lib/roles/h2/http2.c +++ b/lib/roles/h2/http2.c @@ -158,6 +158,9 @@ lws_h2_update_peer_txcredit(struct lws *wsi, int sid, int bump) assert(wsi); + if (!bump) + return 0; + if (sid == -1) sid = wsi->mux.my_sid; @@ -429,8 +432,8 @@ lws_h2_rst_stream(struct lws *wsi, uint32_t err, const char *reason) if (!pps) return 1; - lwsl_info("%s: RST_STREAM 0x%x, sid %d, REASON '%s'\n", __func__, (int)err, - wsi->mux.my_sid, reason); + lwsl_info("%s: RST_STREAM 0x%x, sid %d, REASON '%s'\n", __func__, + (int)err, wsi->mux.my_sid, reason); pps->u.rs.sid = wsi->mux.my_sid; pps->u.rs.err = err; @@ -518,6 +521,7 @@ lws_h2_settings(struct lws *wsi, struct http2_settings *settings, if (w->txc.tx_cr > 0 && w->txc.tx_cr <= (int32_t)(b - settings->s[a])) + lws_callback_on_writable(w); } lws_end_foreach_ll(w, mux.sibling_list); @@ -694,7 +698,9 @@ int lws_h2_do_pps_send(struct lws *wsi) for (n = 1; n < H2SET_COUNT; n++) if (h2n->our_set.s[n] != lws_h2_defaults.s[n]) { lwsl_debug("sending SETTING %d 0x%x\n", n, - (unsigned int)wsi->h2.h2n->our_set.s[n]); + (unsigned int) + wsi->h2.h2n->our_set.s[n]); + lws_h2_set_bin(wsi, n, &set[LWS_PRE + m]); m += sizeof(h2n->one_setting); } @@ -849,10 +855,10 @@ int lws_h2_do_pps_send(struct lws *wsi) break; case LWS_H2_PPS_UPDATE_WINDOW: - lwsl_debug("Issuing LWS_H2_PPS_UPDATE_WINDOW: sid %d: add %d\n", + lwsl_info("Issuing LWS_H2_PPS_UPDATE_WINDOW: sid %d: add %d\n", (int)pps->u.update_window.sid, (int)pps->u.update_window.credit); - *p++ = pps->u.update_window.credit >> 24; + *p++ = (pps->u.update_window.credit >> 24) & 0x7f; /* 31b */ *p++ = pps->u.update_window.credit >> 16; *p++ = pps->u.update_window.credit >> 8; *p++ = pps->u.update_window.credit; @@ -932,7 +938,8 @@ lws_h2_parse_frame_header(struct lws *wsi) * peer sent us something bigger than we told * it we would allow */ - lwsl_info("received oversize frame %d\n", (unsigned int)h2n->length); + lwsl_info("%s: received oversize frame %d\n", __func__, + (unsigned int)h2n->length); lws_h2_goaway(wsi, H2_ERR_FRAME_SIZE_ERROR, "Peer ignored our frame size setting"); return 1; @@ -1419,6 +1426,7 @@ lws_h2_parse_end_of_frame(struct lws *wsi) if (!wsi->h2.initialized) { wsi->txc.tx_cr = h2n->peer_set.s[H2SET_INITIAL_WINDOW_SIZE]; + lwsl_info("%s: initial tx credit for us to " "write on master %p: %d\n", __func__, wsi, wsi->txc.tx_cr); @@ -1493,11 +1501,10 @@ lws_h2_parse_end_of_frame(struct lws *wsi) h2n->swsi->hdr_parsing_completed = 1; #if defined(LWS_WITH_CLIENT) - if (h2n->swsi->client_mux_substream) { - if (lws_client_interpret_server_handshake(h2n->swsi)) { - lwsl_info("%s: cli int serv hs closed it\n", __func__); - break; - } + if (h2n->swsi->client_mux_substream && + lws_client_interpret_server_handshake(h2n->swsi)) { + lwsl_info("%s: cli int serv hs closed it\n", __func__); + break; } #endif @@ -1579,7 +1586,6 @@ lws_h2_parse_end_of_frame(struct lws *wsi) break; } - if (lws_hdr_extant(h2n->swsi, WSI_TOKEN_TE)) { n = lws_hdr_total_length(h2n->swsi, WSI_TOKEN_TE); @@ -1619,6 +1625,7 @@ lws_h2_parse_end_of_frame(struct lws *wsi) break; case LWS_H2_FRAME_TYPE_DATA: + lwsl_info("%s: DATA flags 0x%x\n", __func__, h2n->flags); if (!h2n->swsi) break; @@ -1677,9 +1684,10 @@ lws_h2_parse_end_of_frame(struct lws *wsi) break; case LWS_H2_FRAME_TYPE_PING: - if (h2n->flags & LWS_H2_FLAG_SETTINGS_ACK) { // ack + if (h2n->flags & LWS_H2_FLAG_SETTINGS_ACK) lws_validity_confirmed(wsi); - } else {/* they're sending us a ping request */ + else { + /* they're sending us a ping request */ struct lws_h2_protocol_send *pps = lws_h2_new_pps(LWS_H2_PPS_PONG); if (!pps) @@ -1694,6 +1702,9 @@ lws_h2_parse_end_of_frame(struct lws *wsi) break; case LWS_H2_FRAME_TYPE_WINDOW_UPDATE: + /* + * We only have an unsigned 31-bit (positive) increment possible + */ h2n->hpack_e_dep &= ~(1u << 31); lwsl_info("WINDOW_UPDATE: sid %u %u (0x%x)\n", (unsigned int)h2n->sid, @@ -1767,7 +1778,7 @@ lws_h2_parse_end_of_frame(struct lws *wsi) break; case LWS_H2_FRAME_TYPE_GOAWAY: - lwsl_info("GOAWAY: last sid %u, error 0x%08X, string '%s'\n", + lwsl_notice("GOAWAY: last sid %u, error 0x%08X, string '%s'\n", (unsigned int)h2n->goaway_last_sid, (unsigned int)h2n->goaway_err, h2n->goaway_str); @@ -1775,7 +1786,8 @@ lws_h2_parse_end_of_frame(struct lws *wsi) case LWS_H2_FRAME_TYPE_RST_STREAM: lwsl_info("LWS_H2_FRAME_TYPE_RST_STREAM: sid %u: reason 0x%x\n", - (unsigned int)h2n->sid, (unsigned int)h2n->hpack_e_dep); + (unsigned int)h2n->sid, + (unsigned int)h2n->hpack_e_dep); break; case LWS_H2_FRAME_TYPE_COUNT: /* IGNORING FRAME */ @@ -1885,7 +1897,8 @@ lws_h2_parser(struct lws *wsi, unsigned char *in, lws_filepos_t inlen, h2n->weight_temp = c; h2n->collected_priority = 1; lwsl_debug("PRI FL: dep 0x%x, weight 0x%02X\n", - (unsigned int)h2n->dep, h2n->weight_temp); + (unsigned int)h2n->dep, + h2n->weight_temp); break; /* we consumed this */ } if (h2n->padding && h2n->count > @@ -2005,8 +2018,8 @@ lws_h2_parser(struct lws *wsi, unsigned char *in, lws_filepos_t inlen, n = (int)inlen + 1; if (n > (int)(h2n->length - h2n->count + 1)) { n = h2n->length - h2n->count + 1; - lwsl_debug("---- restricting len to %d vs %ld\n", - n, (long)inlen + 1); + lwsl_debug("---- restricting len to %d " + "vs %ld\n", n, (long)inlen + 1); } #if defined(LWS_WITH_CLIENT) if (h2n->swsi->client_mux_substream) { @@ -2142,16 +2155,16 @@ do_windows: if (h2n->count <= 4) { h2n->dep <<= 8; h2n->dep |= c; - } else { - h2n->weight_temp = c; - lwsl_info("PRIORITY: dep 0x%x, weight 0x%02X\n", - (unsigned int)h2n->dep, h2n->weight_temp); + break; + } + h2n->weight_temp = c; + lwsl_info("PRIORITY: dep 0x%x, weight 0x%02X\n", + (unsigned int)h2n->dep, h2n->weight_temp); - if ((h2n->dep & ~(1u << 31)) == h2n->sid) { - lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR, - "cant depend on own sid"); - break; - } + if ((h2n->dep & ~(1u << 31)) == h2n->sid) { + lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR, + "cant depend on own sid"); + break; } break; @@ -2291,6 +2304,8 @@ lws_h2_client_handshake(struct lws *wsi) */ int sid = nwsi->h2.h2n->highest_sid_opened + 2; + lwsl_debug("%s\n", __func__); + nwsi->h2.h2n->highest_sid_opened = sid; wsi->mux.my_sid = sid; @@ -2353,8 +2368,8 @@ lws_h2_client_handshake(struct lws *wsi) if (wsi->flags & LCCSCF_HTTP_X_WWW_FORM_URLENCODED) { if (lws_add_http_header_by_token(wsi, WSI_TOKEN_HTTP_CONTENT_TYPE, - (unsigned char *)"application/x-www-form-urlencoded", - 33, &p, end)) + (unsigned char *)"application/x-www-form-urlencoded", + 33, &p, end)) goto fail_length; lws_client_http_body_pending(wsi, 1); } @@ -2369,8 +2384,6 @@ lws_h2_client_handshake(struct lws *wsi) if (lws_finalize_http_header(wsi, &p, end)) goto fail_length; - // lwsl_hexdump_notice(start, p - start); - #if defined(LWS_WITH_DETAILED_LATENCY) wsi->detlat.earliest_write_req_pre_write = lws_now_usecs(); #endif @@ -2383,6 +2396,8 @@ lws_h2_client_handshake(struct lws *wsi) m |= LWS_WRITE_H2_STREAM_END; #endif + // lwsl_hexdump_notice(start, p - start); + n = lws_write(wsi, start, p - start, m); if (n != (p - start)) { @@ -2409,6 +2424,9 @@ lws_h2_client_handshake(struct lws *wsi) lws_h2_state(wsi, LWS_H2_STATE_OPEN); lwsi_set_state(wsi, LRS_ESTABLISHED); + if (wsi->flags & LCCSCF_HTTP_MULTIPART_MIME) + lws_callback_on_writable(wsi); + return 0; fail_length: @@ -2451,9 +2469,8 @@ lws_h2_ws_handshake(struct lws *wsi) /* - it is not an empty string */ wsi->protocol->name && wsi->protocol->name[0]) { if (lws_add_http_header_by_token(wsi, WSI_TOKEN_PROTOCOL, - (unsigned char *)wsi->protocol->name, - (int)strlen(wsi->protocol->name), - &p, end)) + (unsigned char *)wsi->protocol->name, + (int)strlen(wsi->protocol->name), &p, end)) return -1; } } @@ -2520,7 +2537,6 @@ lws_read_h2(struct lws *wsi, unsigned char *buf, lws_filepos_t len) if (lws_is_flowcontrolled(wsi)) { lws_rxflow_cache(wsi, buf, 0, (int)len); buf += len; - len = 0; break; } @@ -2557,7 +2573,6 @@ lws_read_h2(struct lws *wsi, unsigned char *buf, lws_filepos_t len) if (m == 2) { /* swsi has been closed */ buf += body_chunk_len; - len -= body_chunk_len; break; } diff --git a/lib/roles/h2/minihuf.c b/lib/roles/h2/minihuf.c index cd51d593f..cad055483 100644 --- a/lib/roles/h2/minihuf.c +++ b/lib/roles/h2/minihuf.c @@ -334,7 +334,6 @@ int main(void) int saw; int y; int j; - int q; int pos = 0; int biggest = 0; int fails = 0; @@ -401,9 +400,8 @@ again: walk = 0; pos = 0; - q = 0; + for (n = 0; n < next; n++) { - q = pos; for (m = 0; m < 2; m++) { saw = state[n].state[m]; diff --git a/lib/roles/h2/ops-h2.c b/lib/roles/h2/ops-h2.c index 1ed50913f..03d7e115c 100644 --- a/lib/roles/h2/ops-h2.c +++ b/lib/roles/h2/ops-h2.c @@ -271,7 +271,6 @@ drain: if (n < 0) { /* we closed wsi */ - n = 0; return LWS_HPI_RET_WSI_ALREADY_DIED; } @@ -393,7 +392,7 @@ rops_write_role_protocol_h2(struct lws *wsi, unsigned char *buf, size_t len, base != LWS_WRITE_HTTP && base != LWS_WRITE_HTTP_FINAL && base != LWS_WRITE_HTTP_HEADERS_CONTINUATION && - base != LWS_WRITE_HTTP_HEADERS && + base != LWS_WRITE_HTTP_HEADERS && lwsi_state(wsi) != LRS_BODY && ((lwsi_state(wsi) != LRS_RETURNED_CLOSE && lwsi_state(wsi) != LRS_WAITING_TO_SEND_CLOSE && lwsi_state(wsi) != LRS_ESTABLISHED && @@ -718,8 +717,6 @@ rops_callback_on_writable_h2(struct lws *wsi) #endif int already; - //lwsl_notice("%s: %p (wsistate 0x%x)\n", __func__, wsi, wsi->wsistate); - // if (!lwsi_role_h2(wsi) && !lwsi_role_h2_ENCAPSULATION(wsi)) // return 0; diff --git a/lib/roles/http/client/client-handshake.c b/lib/roles/http/client/client-handshake.c index 937c14025..c875137d3 100644 --- a/lib/roles/http/client/client-handshake.c +++ b/lib/roles/http/client/client-handshake.c @@ -757,11 +757,16 @@ lws_client_connect_2_dnsreq(struct lws *wsi) case ACTIVE_CONNS_SOLO: break; case ACTIVE_CONNS_MUXED: - lwsl_info("%s: ACTIVE_CONNS_MUXED\n", __func__); - if (lwsi_role_h2(wsi) && wsi->protocol->callback(wsi, - LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP, - wsi->user_space, NULL, 0)) - goto failed1; + lwsl_notice("%s: ACTIVE_CONNS_MUXED\n", __func__); + if (lwsi_role_h2(wsi)) { + if (wsi->protocol->callback(wsi, + LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP, + wsi->user_space, NULL, 0)) + goto failed1; + + lwsi_set_state(wsi, LRS_H2_WAITING_TO_SEND_HEADERS); + lws_callback_on_writable(wsi); + } return wsi; case ACTIVE_CONNS_QUEUED: diff --git a/lib/roles/http/client/client-http.c b/lib/roles/http/client/client-http.c index de3357fd3..1d48bcda6 100644 --- a/lib/roles/http/client/client-http.c +++ b/lib/roles/http/client/client-http.c @@ -24,7 +24,7 @@ #include "private-lib-core.h" -LWS_VISIBLE LWS_EXTERN void +void lws_client_http_body_pending(struct lws *wsi, int something_left_to_send) { wsi->client_http_body_pending = !!something_left_to_send; @@ -91,7 +91,7 @@ lws_client_socket_service(struct lws *wsi, struct lws_pollfd *pollfd, lwsl_debug("%s: pollout HANDSHAKE2\n", __func__); /* - * We have a transaction queued that wants to pipeline. + * We have a transaction / stream queued that wants to pipeline. * * We have to allow it to send headers strictly in the order * that it was queued, ie, tail-first. @@ -102,7 +102,7 @@ lws_client_socket_service(struct lws *wsi, struct lws_pollfd *pollfd, struct lws *w = lws_container_of(d, struct lws, dll2_cli_txn_queue); - lwsl_debug("%s: %p states 0x%lx\n", __func__, w, + lwsl_notice("%s: %p states 0x%lx\n", __func__, w, (unsigned long)w->wsistate); if (lwsi_state(w) == LRS_H1C_ISSUE_HANDSHAKE2) wfound = w; @@ -113,9 +113,13 @@ lws_client_socket_service(struct lws *wsi, struct lws_pollfd *pollfd, wfound->detlat.earliest_write_req_pre_write = lws_now_usecs(); #endif /* - * pollfd has the master sockfd in it... we - * need to use that in HANDSHAKE2 to understand - * which wsi to actually write on + * pollfd has the nwsi sockfd in it... but we're a + * logical child stream sharing that... recurse with + * both the correct child stream wsi and the nwsi. + * + * Second time around wsi / child stream wsi is not + * going to trigger this as it has no pipelined queue + * children of its own */ if (lws_client_socket_service(wfound, pollfd, wsi) < 0) { /* closed */ @@ -127,8 +131,7 @@ lws_client_socket_service(struct lws *wsi, struct lws_pollfd *pollfd, lws_callback_on_writable(wsi); } else - lwsl_debug("%s: didn't find anything in txn q in HS2\n", - __func__); + lwsl_debug("%s: nothing in txn q in HS2\n", __func__); lws_vhost_unlock(wsi->vhost); @@ -684,18 +687,19 @@ lws_http_transaction_completed_client(struct lws *wsi) return 0; } -LWS_VISIBLE LWS_EXTERN unsigned int +unsigned int lws_http_client_http_response(struct lws *_wsi) { struct lws *wsi; - unsigned int resp; + unsigned int resp = 0; if (_wsi->http.ah && _wsi->http.ah->http_response) return _wsi->http.ah->http_response; lws_vhost_lock(_wsi->vhost); wsi = _lws_client_wsi_master(_wsi); - resp = wsi->http.ah->http_response; + if (wsi->http.ah) + resp = wsi->http.ah->http_response; lws_vhost_unlock(_wsi->vhost); return resp; @@ -860,7 +864,7 @@ lws_client_interpret_server_handshake(struct lws *wsi) port = wsi->c_port; /* +1 as lws_client_reset expects leading / omitted */ path = new_path + 1; - if (lws_hdr_simple_ptr(wsi,_WSI_TOKEN_CLIENT_URI)) + if (lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_URI)) lws_strncpy(new_path, lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_URI), sizeof(new_path)); else { @@ -888,11 +892,12 @@ lws_client_interpret_server_handshake(struct lws *wsi) } if (!lws_client_reset(&wsi, ssl, ads, port, path, ads)) { - /* there are two ways to fail out with NULL return... + /* + * There are two ways to fail out with NULL return... * simple, early problem where the wsi is intact, or * we went through with the reconnect attempt and the * wsi is already closed. In the latter case, the wsi - * has beet set to NULL additionally. + * has been set to NULL additionally. */ lwsl_err("Redirect failed\n"); cce = "HS: Redirect failed"; @@ -1101,7 +1106,7 @@ lws_http_multipart_headers(struct lws *wsi, uint8_t *p) wsi->http.multipart_boundary, sizeof(wsi->http.multipart_boundary)); - n = lws_snprintf(arg, sizeof(arg), "multipart/form-data;boundary=%s", + n = lws_snprintf(arg, sizeof(arg), "multipart/form-data; boundary=%s", wsi->http.multipart_boundary); if (lws_add_http_header_by_token(wsi, WSI_TOKEN_HTTP_CONTENT_TYPE, @@ -1109,6 +1114,7 @@ lws_http_multipart_headers(struct lws *wsi, uint8_t *p) return NULL; wsi->http.multipart = wsi->http.multipart_issue_boundary = 1; + lws_client_http_body_pending(wsi, 1); return p; } @@ -1132,7 +1138,11 @@ lws_client_http_multipart(struct lws *wsi, const char *name, return 0; } - *p += lws_snprintf((char *)(*p), lws_ptr_diff(end, p), "\xd\xa--%s\xd\xa" + if (wsi->client_subsequent_mime_part) + *p += lws_snprintf((char *)(*p), lws_ptr_diff(end, p), "\xd\xa"); + wsi->client_subsequent_mime_part = 1; + + *p += lws_snprintf((char *)(*p), lws_ptr_diff(end, p), "--%s\xd\xa" "Content-Disposition: form-data; " "name=\"%s\"", wsi->http.multipart_boundary, name); @@ -1283,6 +1293,9 @@ lws_generate_client_handshake(struct lws *wsi, char *pkt) p += lws_snprintf(p, 4, "\x0d\x0a"); + if (wsi->client_http_body_pending) + lws_callback_on_writable(wsi); + // puts(pkt); return p; @@ -1311,7 +1324,7 @@ lws_http_basic_auth_gen(const char *user, const char *pw, char *buf, size_t len) return 0; } -LWS_VISIBLE int +int lws_http_client_read(struct lws *wsi, char **buf, int *len) { struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi]; diff --git a/lib/roles/http/compression/stream.c b/lib/roles/http/compression/stream.c index 07761bd36..d6dc20d20 100644 --- a/lib/roles/http/compression/stream.c +++ b/lib/roles/http/compression/stream.c @@ -57,7 +57,7 @@ lws_http_compression_validate(struct lws *wsi) return 0; } -LWS_VISIBLE int +int lws_http_compression_apply(struct lws *wsi, const char *name, unsigned char **p, unsigned char *end, char decomp) { @@ -154,7 +154,7 @@ lws_http_compression_transform(struct lws *wsi, unsigned char *buf, *wp = LWS_WRITE_HTTP | ((*wp) & ~0x1f); } - if (ctx->buflist_comp || ctx->may_have_more) { + if (ctx->buflist_comp) { /* * we can't send this new stuff when we have old stuff * buffered and not compressed yet. Add it to the tail diff --git a/lib/roles/http/header.c b/lib/roles/http/header.c index 4929a49d6..666042c39 100644 --- a/lib/roles/http/header.c +++ b/lib/roles/http/header.c @@ -376,7 +376,7 @@ lws_add_http_header_status(struct lws *wsi, unsigned int _code, return 0; } -LWS_VISIBLE int +int lws_return_http_status(struct lws *wsi, unsigned int code, const char *html_body) { @@ -493,7 +493,7 @@ lws_return_http_status(struct lws *wsi, unsigned int code, return m != n; } -LWS_VISIBLE int +int lws_http_redirect(struct lws *wsi, int code, const unsigned char *loc, int len, unsigned char **p, unsigned char *end) { @@ -527,7 +527,7 @@ lws_http_redirect(struct lws *wsi, int code, const unsigned char *loc, int len, #endif #if !defined(LWS_WITH_HTTP_STREAM_COMPRESSION) -LWS_VISIBLE int +int lws_http_compression_apply(struct lws *wsi, const char *name, unsigned char **p, unsigned char *end, char decomp) { diff --git a/lib/roles/http/minilex.c b/lib/roles/http/minilex.c index c711dd6b4..ae184eb98 100644 --- a/lib/roles/http/minilex.c +++ b/lib/roles/http/minilex.c @@ -77,7 +77,7 @@ int lextable_decode(int pos, char c) int main(void) { int n = 0; - int m = 0; + int m; int prev; char c; int walk; diff --git a/lib/roles/http/parsers.c b/lib/roles/http/parsers.c index 4cae75e0a..6bba484c0 100644 --- a/lib/roles/http/parsers.c +++ b/lib/roles/http/parsers.c @@ -58,8 +58,8 @@ _lws_create_ah(struct lws_context_per_thread *pt, ah_data_idx_t data_size) ah->data_length = data_size; pt->http.ah_pool_length++; - lwsl_info("%s: created ah %p (size %d): pool length %ld\n", __func__, - ah, (int)data_size, (unsigned long)pt->http.ah_pool_length); + lwsl_info("%s: created ah %p (size %d): pool length %u\n", __func__, + ah, (int)data_size, (unsigned int)pt->http.ah_pool_length); return ah; } @@ -71,9 +71,9 @@ _lws_destroy_ah(struct lws_context_per_thread *pt, struct allocated_headers *ah) if ((*a) == ah) { *a = ah->next; pt->http.ah_pool_length--; - lwsl_info("%s: freed ah %p : pool length %ld\n", + lwsl_info("%s: freed ah %p : pool length %u\n", __func__, ah, - (unsigned long)pt->http.ah_pool_length); + (unsigned int)pt->http.ah_pool_length); if (ah->data) lws_free(ah->data); lws_free(ah); @@ -453,7 +453,7 @@ int lws_header_table_detach(struct lws *wsi, int autoservice) return n; } -LWS_VISIBLE int +int lws_hdr_fragment_length(struct lws *wsi, enum lws_token_indexes h, int frag_idx) { int n; @@ -473,7 +473,7 @@ lws_hdr_fragment_length(struct lws *wsi, enum lws_token_indexes h, int frag_idx) return 0; } -LWS_VISIBLE int lws_hdr_total_length(struct lws *wsi, enum lws_token_indexes h) +int lws_hdr_total_length(struct lws *wsi, enum lws_token_indexes h) { int n; int len = 0; @@ -496,7 +496,7 @@ LWS_VISIBLE int lws_hdr_total_length(struct lws *wsi, enum lws_token_indexes h) return len; } -LWS_VISIBLE int lws_hdr_copy_fragment(struct lws *wsi, char *dst, int len, +int lws_hdr_copy_fragment(struct lws *wsi, char *dst, int len, enum lws_token_indexes h, int frag_idx) { int n = 0; @@ -527,7 +527,7 @@ LWS_VISIBLE int lws_hdr_copy_fragment(struct lws *wsi, char *dst, int len, return wsi->http.ah->frags[f].len; } -LWS_VISIBLE int lws_hdr_copy(struct lws *wsi, char *dst, int len, +int lws_hdr_copy(struct lws *wsi, char *dst, int len, enum lws_token_indexes h) { int toklen = lws_hdr_total_length(wsi, h); @@ -570,7 +570,7 @@ LWS_VISIBLE int lws_hdr_copy(struct lws *wsi, char *dst, int len, } #if defined(LWS_WITH_CUSTOM_HEADERS) -LWS_VISIBLE int +int lws_hdr_custom_length(struct lws *wsi, const char *name, int nlen) { ah_data_idx_t ll; @@ -594,7 +594,7 @@ lws_hdr_custom_length(struct lws *wsi, const char *name, int nlen) return -1; } -LWS_VISIBLE int +int lws_hdr_custom_copy(struct lws *wsi, char *dst, int len, const char *name, int nlen) { diff --git a/lib/roles/http/server/lws-spa.c b/lib/roles/http/server/lws-spa.c index a48dafa92..7e79eb009 100644 --- a/lib/roles/http/server/lws-spa.c +++ b/lib/roles/http/server/lws-spa.c @@ -134,12 +134,11 @@ lws_urldecode_s_create(struct lws_spa *spa, struct lws *wsi, char *out, s->mime_boundary[m++] = '-'; s->mime_boundary[m++] = '-'; while (m < (int)sizeof(s->mime_boundary) - 1 && - *p && *p != ' ') + *p && *p != ' ' && *p != ';') s->mime_boundary[m++] = *p++; - s->mime_boundary[m] = '\0'; - lwsl_info("boundary '%s'\n", s->mime_boundary); + lwsl_notice("boundary '%s'\n", s->mime_boundary); } } } @@ -162,6 +161,7 @@ lws_urldecode_s_process(struct lws_urldecode_stateful *s, const char *in, s->pos = 0; } + switch (s->state) { /* states for url arg style */ @@ -568,7 +568,7 @@ lws_spa_create_via_info(struct lws *wsi, const lws_spa_create_info_t *i) goto bail5; } - lwsl_info("%s: Created SPA %p\n", __func__, spa); + lwsl_notice("%s: Created SPA %p\n", __func__, spa); return spa; diff --git a/lib/roles/http/server/rewrite.c b/lib/roles/http/server/rewrite.c index 272fb12f9..16aaabd35 100644 --- a/lib/roles/http/server/rewrite.c +++ b/lib/roles/http/server/rewrite.c @@ -2,7 +2,7 @@ #if defined(LWS_WITH_HUBBUB) -LWS_EXTERN struct lws_rewrite * +struct lws_rewrite * lws_rewrite_create(struct lws *wsi, hubbub_callback_t cb, const char *from, const char *to) { @@ -35,7 +35,7 @@ lws_rewrite_create(struct lws *wsi, hubbub_callback_t cb, const char *from, return r; } -LWS_EXTERN int +int lws_rewrite_parse(struct lws_rewrite *r, const unsigned char *in, int in_len) { @@ -45,7 +45,7 @@ lws_rewrite_parse(struct lws_rewrite *r, return 0; } -LWS_EXTERN void +void lws_rewrite_destroy(struct lws_rewrite *r) { hubbub_parser_destroy(r->parser); diff --git a/lib/roles/http/server/server.c b/lib/roles/http/server/server.c index c923138c0..c05b305f3 100644 --- a/lib/roles/http/server/server.c +++ b/lib/roles/http/server/server.c @@ -137,7 +137,8 @@ done_list: vhost->name, vhost->iface, vhost->listen_port); else return -1; - return (info->options & LWS_SERVER_OPTION_FAIL_UPON_UNABLE_TO_BIND) == LWS_SERVER_OPTION_FAIL_UPON_UNABLE_TO_BIND? + return (info->options & LWS_SERVER_OPTION_FAIL_UPON_UNABLE_TO_BIND) == + LWS_SERVER_OPTION_FAIL_UPON_UNABLE_TO_BIND? -1 : 1; case LWS_ITOSA_NOT_USABLE: /* can't add it */ @@ -146,7 +147,8 @@ done_list: vhost->name, vhost->iface, vhost->listen_port); else return -1; - return (info->options & LWS_SERVER_OPTION_FAIL_UPON_UNABLE_TO_BIND) == LWS_SERVER_OPTION_FAIL_UPON_UNABLE_TO_BIND? + return (info->options & LWS_SERVER_OPTION_FAIL_UPON_UNABLE_TO_BIND) == + LWS_SERVER_OPTION_FAIL_UPON_UNABLE_TO_BIND? -1 : 1; } } @@ -245,7 +247,8 @@ done_list: #endif lws_plat_set_socket_options(vhost, sockfd, 0); - is = lws_socket_bind(vhost, sockfd, vhost->listen_port, vhost->iface, 1); + is = lws_socket_bind(vhost, sockfd, vhost->listen_port, + vhost->iface, 1); if (is == LWS_ITOSA_BUSY) { /* treat as fatal */ compatible_close(sockfd); @@ -309,7 +312,8 @@ done_list: } } /* for each thread able to independently listen */ - if (!lws_check_opt(vhost->context->options, LWS_SERVER_OPTION_EXPLICIT_VHOSTS)) { + if (!lws_check_opt(vhost->context->options, + LWS_SERVER_OPTION_EXPLICIT_VHOSTS)) { #ifdef LWS_WITH_UNIX_SOCK if (LWS_UNIX_SOCK_ENABLED(vhost)) lwsl_info(" Listening on \"%s\"\n", vhost->iface); @@ -415,7 +419,7 @@ static const struct lws_mimetype { { ".json", "application/json" }, }; -LWS_VISIBLE LWS_EXTERN const char * +const char * lws_get_mimetype(const char *file, const struct lws_http_mount *m) { const struct lws_protocol_vhost_options *pvo; @@ -433,7 +437,8 @@ lws_get_mimetype(const char *file, const struct lws_http_mount *m) len = strlen(pvo->name); if (n > len && !strcasecmp(&file[n - len], pvo->name)) { - lwsl_info("%s: match to user mimetype: %s\n", __func__, pvo->value); + lwsl_info("%s: match to user mimetype: %s\n", __func__, + pvo->value); return pvo->value; } } @@ -444,14 +449,16 @@ lws_get_mimetype(const char *file, const struct lws_http_mount *m) len = strlen(mt->extension); if (n > len && !strcasecmp(&file[n - len], mt->extension)) { - lwsl_info("%s: match to server mimetype: %s\n", __func__, mt->mimetype); + lwsl_info("%s: match to server mimetype: %s\n", __func__, + mt->mimetype); return mt->mimetype; } } /* fallback to '*' if defined */ if (fallback_mimetype) { - lwsl_info("%s: match to any mimetype: %s\n", __func__, fallback_mimetype); + lwsl_info("%s: match to any mimetype: %s\n", __func__, + fallback_mimetype); return fallback_mimetype; } @@ -1177,7 +1184,8 @@ lws_http_proxy_start(struct lws *wsi, const struct lws_http_mount *hit, #if defined(LWS_WITH_HTTP2) || ( lws_hdr_simple_ptr(wsi, WSI_TOKEN_HTTP_COLON_METHOD) && - !strcmp(lws_hdr_simple_ptr(wsi, WSI_TOKEN_HTTP_COLON_METHOD), "post") + !strcmp(lws_hdr_simple_ptr(wsi, + WSI_TOKEN_HTTP_COLON_METHOD), "post") ) #endif ) @@ -1234,7 +1242,8 @@ lws_http_proxy_start(struct lws *wsi, const struct lws_http_mount *hit, wsi->proxied_ws_parent = 1; cwsi->h1_ws_proxied = 1; if (i.protocol) { - lwsl_debug("%s: (requesting '%s')\n", __func__, i.protocol); + lwsl_debug("%s: (requesting '%s')\n", + __func__, i.protocol); } } @@ -1655,77 +1664,72 @@ deal_body: * In any case, return 0 and let lws_read decide how to * proceed based on state */ - if (lwsi_state(wsi) != LRS_ISSUING_FILE) { - /* Prepare to read body if we have a content length: */ - lwsl_debug("wsi->http.rx_content_length %lld %d %d\n", - (long long)wsi->http.rx_content_length, - wsi->upgraded_to_http2, wsi->mux_substream); + if (lwsi_state(wsi) == LRS_ISSUING_FILE) + return 0; - if (wsi->http.content_length_explicitly_zero && - lws_hdr_total_length(wsi, WSI_TOKEN_POST_URI)) { + /* Prepare to read body if we have a content length: */ + lwsl_debug("wsi->http.rx_content_length %lld %d %d\n", + (long long)wsi->http.rx_content_length, + wsi->upgraded_to_http2, wsi->mux_substream); - /* - * POST with an explicit content-length of zero - * - * If we don't give the user code the empty HTTP_BODY - * callback, he may become confused to hear the - * HTTP_BODY_COMPLETION (due to, eg, instantiation of - * lws_spa never happened). - * - * HTTP_BODY_COMPLETION is responsible for sending the - * result status code and result body if any, and - * do the transaction complete processing. - */ - if (wsi->protocol->callback(wsi, - LWS_CALLBACK_HTTP_BODY, - wsi->user_space, NULL, 0)) - return 1; - if (wsi->protocol->callback(wsi, - LWS_CALLBACK_HTTP_BODY_COMPLETION, - wsi->user_space, NULL, 0)) - return 1; + if (wsi->http.content_length_explicitly_zero && + lws_hdr_total_length(wsi, WSI_TOKEN_POST_URI)) { - return 0; - } + /* + * POST with an explicit content-length of zero + * + * If we don't give the user code the empty HTTP_BODY callback, + * he may become confused to hear the HTTP_BODY_COMPLETION (due + * to, eg, instantiation of lws_spa never happened). + * + * HTTP_BODY_COMPLETION is responsible for sending the result + * status code and result body if any, and to do the transaction + * complete processing. + */ + if (wsi->protocol->callback(wsi, LWS_CALLBACK_HTTP_BODY, + wsi->user_space, NULL, 0)) + return 1; + if (wsi->protocol->callback(wsi, LWS_CALLBACK_HTTP_BODY_COMPLETION, + wsi->user_space, NULL, 0)) + return 1; - if (wsi->http.rx_content_length > 0) { + return 0; + } - if (lwsi_state(wsi) != LRS_DISCARD_BODY) { - lwsi_set_state(wsi, LRS_BODY); - lwsl_info("%s: %p: LRS_BODY state set (0x%x)\n", - __func__, wsi, wsi->wsistate); - } - wsi->http.rx_content_remain = - wsi->http.rx_content_length; + if (wsi->http.rx_content_length <= 0) + return 0; - /* - * At this point we have transitioned from deferred - * action to expecting BODY on the stream wsi, if it's - * in a bundle like h2. So if the stream wsi has its - * own buflist, we need to deal with that first. - */ + if (lwsi_state(wsi) != LRS_DISCARD_BODY) { + lwsi_set_state(wsi, LRS_BODY); + lwsl_info("%s: %p: LRS_BODY state set (0x%x)\n", __func__, wsi, + wsi->wsistate); + } + wsi->http.rx_content_remain = wsi->http.rx_content_length; - while (1) { - struct lws_tokens ebuf; - int m; + /* + * At this point we have transitioned from deferred + * action to expecting BODY on the stream wsi, if it's + * in a bundle like h2. So if the stream wsi has its + * own buflist, we need to deal with that first. + */ - ebuf.len = (int)lws_buflist_next_segment_len( - &wsi->buflist, - &ebuf.token); - if (!ebuf.len) - break; - lwsl_debug("%s: consuming %d\n", __func__, - (int)ebuf.len); - m = lws_read_h1(wsi, ebuf.token, - ebuf.len); - if (m < 0) - return -1; + while (1) { + struct lws_tokens ebuf; + int m; - if (lws_buflist_aware_finished_consuming(wsi, - &ebuf, m, 1, __func__)) - return -1; - } - } + ebuf.len = (int)lws_buflist_next_segment_len(&wsi->buflist, + &ebuf.token); + if (!ebuf.len) + break; + + lwsl_debug("%s: consuming %d\n", __func__, (int)ebuf.len); + m = lws_read_h1(wsi, ebuf.token, ebuf.len); + if (m < 0) + return -1; + + if (lws_buflist_aware_finished_consuming(wsi, &ebuf, m, 1, + __func__)) + return -1; } return 0; @@ -2122,8 +2126,7 @@ upgrade_h2c: wsi->http.ah = ah; if (!wsi->h2.h2n) { - wsi->h2.h2n = lws_zalloc(sizeof(*wsi->h2.h2n), - "h2n"); + wsi->h2.h2n = lws_zalloc(sizeof(*wsi->h2.h2n), "h2n"); if (!wsi->h2.h2n) return 1; } @@ -2132,7 +2135,7 @@ upgrade_h2c: /* HTTP2 union */ - lws_h2_settings(wsi, &wsi->h2.h2n->peer_set, (unsigned char *)tbuf, n); + lws_h2_settings(wsi, &wsi->h2.h2n->peer_set, (uint8_t *)tbuf, n); lws_hpack_dynamic_size(wsi, wsi->h2.h2n->peer_set.s[ H2SET_HEADER_TABLE_SIZE]); @@ -2364,14 +2367,14 @@ lws_http_transaction_completed(struct lws *wsi) lwsl_debug("acquired ah\n"); lwsl_debug("%s: %p: keep-alive await new transaction (state 0x%x)\n", - __func__, wsi, wsi->wsistate); + __func__, wsi, wsi->wsistate); lws_callback_on_writable(wsi); return 0; } #if defined(LWS_WITH_FILE_OPS) -LWS_VISIBLE int +int lws_serve_http_file(struct lws *wsi, const char *file, const char *content_type, const char *other_headers, int other_headers_len) { @@ -2674,7 +2677,7 @@ bail: #if defined(LWS_WITH_FILE_OPS) -LWS_VISIBLE int lws_serve_http_file_fragment(struct lws *wsi) +int lws_serve_http_file_fragment(struct lws *wsi) { struct lws_context *context = wsi->context; struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi]; @@ -2725,10 +2728,7 @@ LWS_VISIBLE int lws_serve_http_file_fragment(struct lws *wsi) goto all_sent; n = 0; - - pstart = pt->serv_buf + LWS_H2_FRAME_HEADER_LENGTH; - - p = pstart; + p = pstart = pt->serv_buf + LWS_H2_FRAME_HEADER_LENGTH; #if defined(LWS_WITH_RANGES) if (wsi->http.range.count_ranges && !wsi->http.range.inside) { @@ -2773,7 +2773,7 @@ LWS_VISIBLE int lws_serve_http_file_fragment(struct lws *wsi) poss = wsi->http.tx_content_remain; /* - * if there is a hint about how much we will do well to send at + * If there is a hint about how much we will do well to send at * one time, restrict ourselves to only trying to send that. */ if (wsi->protocol->tx_packet_size && @@ -2785,16 +2785,21 @@ LWS_VISIBLE int lws_serve_http_file_fragment(struct lws *wsi) wsi->role_ops->tx_credit(wsi, LWSTXCR_US_TO_PEER, 0); if (!txc) { - lwsl_info("%s: came here with no tx credit\n", - __func__); + /* + * We shouldn't've been able to get the + * WRITEABLE if we are skint + */ + lwsl_notice("%s: %p: no tx credit\n", __func__, + wsi); + return 0; } if (txc < poss) poss = txc; /* - * consumption of the actual payload amount sent will be - * handled when the role data frame is sent + * Tracking consumption of the actual payload amount + * will be handled when the role data frame is sent... */ } @@ -2953,7 +2958,7 @@ file_had_it: #endif #if defined(LWS_WITH_SERVER) -LWS_VISIBLE void +void lws_server_get_canonical_hostname(struct lws_context *context, const struct lws_context_creation_info *info) { diff --git a/lib/roles/listen/ops-listen.c b/lib/roles/listen/ops-listen.c index 4e16540c8..2c18cd418 100644 --- a/lib/roles/listen/ops-listen.c +++ b/lib/roles/listen/ops-listen.c @@ -34,6 +34,8 @@ rops_handle_POLLIN_listen(struct lws_context_per_thread *pt, struct lws *wsi, struct sockaddr_storage cli_addr; socklen_t clilen; + memset(&cli_addr, 0, sizeof(cli_addr)); + /* if our vhost is going down, ignore it */ if (wsi->vhost->being_destroyed) @@ -108,6 +110,7 @@ rops_handle_POLLIN_listen(struct lws_context_per_thread *pt, struct lws *wsi, #else { struct sockaddr_in sain; + memcpy(&sain, &cli_addr, sizeof(sain)); lwsl_debug("accepted new conn port %u on fd=%d\n", ntohs(sain.sin_port), diff --git a/lib/roles/raw-skt/ops-raw-skt.c b/lib/roles/raw-skt/ops-raw-skt.c index 0f957cdb4..b2a571825 100644 --- a/lib/roles/raw-skt/ops-raw-skt.c +++ b/lib/roles/raw-skt/ops-raw-skt.c @@ -231,7 +231,8 @@ rops_client_bind_raw_skt(struct lws *wsi, /* we are a fallback if nothing else matched */ - if (!i->local_protocol_name || strcmp(i->local_protocol_name, "raw-proxy")) + if (!i->local_protocol_name || + strcmp(i->local_protocol_name, "raw-proxy")) lws_role_transition(wsi, LWSIFR_CLIENT, LRS_UNCONNECTED, &role_ops_raw_skt); diff --git a/lib/roles/ws/ext/extension.c b/lib/roles/ws/ext/extension.c index 576cb140b..f6ea2e3e4 100644 --- a/lib/roles/ws/ext/extension.c +++ b/lib/roles/ws/ext/extension.c @@ -26,7 +26,7 @@ #include "extension-permessage-deflate.h" -LWS_VISIBLE void +void lws_context_init_extensions(const struct lws_context_creation_info *info, struct lws_context *context) { @@ -41,7 +41,7 @@ enum lws_ext_option_parser_states { LEAPS_SEEK_ARG_TERM }; -LWS_VISIBLE int +int lws_ext_parse_options(const struct lws_extension *ext, struct lws *wsi, void *ext_user, const struct lws_ext_options *opts, const char *in, int len) diff --git a/lib/roles/ws/ops-ws.c b/lib/roles/ws/ops-ws.c index 012448b99..38acc339d 100644 --- a/lib/roles/ws/ops-ws.c +++ b/lib/roles/ws/ops-ws.c @@ -749,13 +749,13 @@ illegal_ctl_length: } -LWS_VISIBLE size_t +size_t lws_remaining_packet_payload(struct lws *wsi) { return wsi->ws->rx_packet_length; } -LWS_VISIBLE int lws_frame_is_binary(struct lws *wsi) +int lws_frame_is_binary(struct lws *wsi) { return wsi->ws->frame_is_binary; } @@ -878,7 +878,7 @@ lws_server_init_wsi_for_ws(struct lws *wsi) -LWS_VISIBLE int +int lws_is_final_fragment(struct lws *wsi) { #if !defined(LWS_WITHOUT_EXTENSIONS) @@ -892,31 +892,31 @@ lws_is_final_fragment(struct lws *wsi) #endif } -LWS_VISIBLE int +int lws_is_first_fragment(struct lws *wsi) { return wsi->ws->first_fragment; } -LWS_VISIBLE unsigned char +unsigned char lws_get_reserved_bits(struct lws *wsi) { return wsi->ws->rsv; } -LWS_VISIBLE LWS_EXTERN int +int lws_get_close_length(struct lws *wsi) { return wsi->ws->close_in_ping_buffer_len; } -LWS_VISIBLE LWS_EXTERN unsigned char * +unsigned char * lws_get_close_payload(struct lws *wsi) { return &wsi->ws->ping_payload_buf[LWS_PRE]; } -LWS_VISIBLE LWS_EXTERN void +void lws_close_reason(struct lws *wsi, enum lws_close_status status, unsigned char *buf, size_t len) { @@ -1196,7 +1196,6 @@ drain: if (n < 0) { /* we closed wsi */ - n = 0; return LWS_HPI_RET_WSI_ALREADY_DIED; } //lws_buflist_describe(&wsi->buflist, wsi, __func__); @@ -1945,7 +1944,7 @@ rops_init_vhost_ws(struct lws_vhost *vh, { #if !defined(LWS_WITHOUT_EXTENSIONS) #ifdef LWS_WITH_PLUGINS - struct lws_plugin *plugin = vh->context->plugin_list; + struct lws_plugin *plugin; int m; if (vh->context->plugin_extension_count) { diff --git a/lib/system/ntpclient/ntpclient.c b/lib/system/ntpclient/ntpclient.c index c5849d9b9..1ab4cff42 100644 --- a/lib/system/ntpclient/ntpclient.c +++ b/lib/system/ntpclient/ntpclient.c @@ -182,11 +182,11 @@ callback_ntpc(struct lws *wsi, enum lws_callback_reasons reason, void *user, break; case LWS_CALLBACK_CLIENT_CONNECTION_ERROR: - lwsl_notice("%s: CONNECTION_ERROR\n", __func__); + lwsl_info("%s: CONNECTION_ERROR\n", __func__); goto do_close; case LWS_CALLBACK_RAW_CLOSE: - lwsl_notice("%s: LWS_CALLBACK_RAW_CLOSE\n", __func__); + lwsl_debug("%s: LWS_CALLBACK_RAW_CLOSE\n", __func__); do_close: v->wsi_udp = NULL; diff --git a/lib/tls/lws-gencrypto-common.c b/lib/tls/lws-gencrypto-common.c index 18722f37f..0deaf7ca2 100644 --- a/lib/tls/lws-gencrypto-common.c +++ b/lib/tls/lws-gencrypto-common.c @@ -570,7 +570,7 @@ static const struct lws_jose_jwe_alg lws_gencrypto_jwe_enc_map[] = { { 0, 0, 0, 0, NULL, NULL, 0, 0, 0 } /* sentinel */ }; -LWS_VISIBLE int +int lws_gencrypto_jws_alg_to_definition(const char *alg, const struct lws_jose_jwe_alg **jose) { @@ -588,7 +588,7 @@ lws_gencrypto_jws_alg_to_definition(const char *alg, return 1; } -LWS_VISIBLE int +int lws_gencrypto_jwe_alg_to_definition(const char *alg, const struct lws_jose_jwe_alg **jose) { @@ -606,7 +606,7 @@ lws_gencrypto_jwe_alg_to_definition(const char *alg, return 1; } -LWS_VISIBLE int +int lws_gencrypto_jwe_enc_to_definition(const char *enc, const struct lws_jose_jwe_alg **jose) { diff --git a/lib/tls/lws-genec-common.c b/lib/tls/lws-genec-common.c index b7fdd7fe9..3ff82287b 100644 --- a/lib/tls/lws-genec-common.c +++ b/lib/tls/lws-genec-common.c @@ -98,7 +98,7 @@ lws_genec_confirm_curve_allowed_by_tls_id(const char *allowed, int id, return -1; } -LWS_VISIBLE void +void lws_genec_destroy_elements(struct lws_gencrypto_keyelem *el) { int n; @@ -110,7 +110,7 @@ lws_genec_destroy_elements(struct lws_gencrypto_keyelem *el) static const char *enames[] = { "crv", "x", "d", "y" }; -LWS_VISIBLE int +int lws_genec_dump(struct lws_gencrypto_keyelem *el) { int n; diff --git a/lib/tls/mbedtls/lws-genaes.c b/lib/tls/mbedtls/lws-genaes.c index 9f51a7bb7..9c7e5ba45 100644 --- a/lib/tls/mbedtls/lws-genaes.c +++ b/lib/tls/mbedtls/lws-genaes.c @@ -29,7 +29,7 @@ static int operation_map[] = { MBEDTLS_AES_ENCRYPT, MBEDTLS_AES_DECRYPT }; -LWS_VISIBLE int +int lws_genaes_create(struct lws_genaes_ctx *ctx, enum enum_aes_operation op, enum enum_aes_modes mode, struct lws_gencrypto_keyelem *el, enum enum_aes_padding padding, void *engine) @@ -111,10 +111,10 @@ lws_genaes_create(struct lws_genaes_ctx *ctx, enum enum_aes_operation op, return n; } -LWS_VISIBLE int +int lws_genaes_destroy(struct lws_genaes_ctx *ctx, unsigned char *tag, size_t tlen) { - int n = 0; + int n; if (ctx->mode == LWS_GAESM_GCM) { n = mbedtls_gcm_finish(&ctx->u.ctx_gcm, tag, tlen); @@ -257,7 +257,7 @@ bail: return ret; } -LWS_VISIBLE int +int lws_genaes_crypt(struct lws_genaes_ctx *ctx, const uint8_t *in, size_t len, uint8_t *out, uint8_t *iv_or_nonce_ctr_or_data_unit_16, uint8_t *stream_block_16, size_t *nc_or_iv_off, int taglen) diff --git a/lib/tls/mbedtls/lws-genec.c b/lib/tls/mbedtls/lws-genec.c index 43106a8d0..88f660506 100644 --- a/lib/tls/mbedtls/lws-genec.c +++ b/lib/tls/mbedtls/lws-genec.c @@ -138,7 +138,7 @@ bail1: return ret; } -LWS_VISIBLE int +int lws_genecdh_create(struct lws_genec_ctx *ctx, struct lws_context *context, const struct lws_ec_curves *curve_table) { @@ -157,7 +157,7 @@ lws_genecdh_create(struct lws_genec_ctx *ctx, struct lws_context *context, return 0; } -LWS_VISIBLE int +int lws_genecdsa_create(struct lws_genec_ctx *ctx, struct lws_context *context, const struct lws_ec_curves *curve_table) { @@ -177,7 +177,7 @@ lws_genecdsa_create(struct lws_genec_ctx *ctx, struct lws_context *context, } -LWS_VISIBLE int +int lws_genecdh_set_key(struct lws_genec_ctx *ctx, struct lws_gencrypto_keyelem *el, enum enum_lws_dh_side side) { @@ -187,7 +187,7 @@ lws_genecdh_set_key(struct lws_genec_ctx *ctx, struct lws_gencrypto_keyelem *el, return lws_genec_keypair_import(ctx, side, el); } -LWS_VISIBLE int +int lws_genecdsa_set_key(struct lws_genec_ctx *ctx, struct lws_gencrypto_keyelem *el) { @@ -197,7 +197,7 @@ lws_genecdsa_set_key(struct lws_genec_ctx *ctx, return lws_genec_keypair_import(ctx, 0, el); } -LWS_VISIBLE void +void lws_genec_destroy(struct lws_genec_ctx *ctx) { switch (ctx->genec_alg) { @@ -220,7 +220,7 @@ lws_genec_destroy(struct lws_genec_ctx *ctx) } } -LWS_VISIBLE int +int lws_genecdh_new_keypair(struct lws_genec_ctx *ctx, enum enum_lws_dh_side side, const char *curve_name, struct lws_gencrypto_keyelem *el) @@ -304,7 +304,7 @@ bail1: return -1; } -LWS_VISIBLE int +int lws_genecdsa_new_keypair(struct lws_genec_ctx *ctx, const char *curve_name, struct lws_gencrypto_keyelem *el) { @@ -377,7 +377,7 @@ bail1: return -1; } -LWS_VISIBLE LWS_EXTERN int +int lws_genecdsa_hash_sign_jws(struct lws_genec_ctx *ctx, const uint8_t *in, enum lws_genhash_types hash_type, int keybits, uint8_t *sig, size_t sig_len) @@ -439,7 +439,7 @@ bail1: return -3; } -LWS_VISIBLE LWS_EXTERN int +int lws_genecdsa_hash_sig_verify_jws(struct lws_genec_ctx *ctx, const uint8_t *in, enum lws_genhash_types hash_type, int keybits, const uint8_t *sig, size_t sig_len) diff --git a/lib/tls/mbedtls/lws-genrsa.c b/lib/tls/mbedtls/lws-genrsa.c index 2134e001d..5b3b234a2 100644 --- a/lib/tls/mbedtls/lws-genrsa.c +++ b/lib/tls/mbedtls/lws-genrsa.c @@ -28,7 +28,7 @@ #include "private-lib-tls-mbedtls.h" #include -LWS_VISIBLE void +void lws_genrsa_destroy_elements(struct lws_gencrypto_keyelem *el) { int n; @@ -40,7 +40,7 @@ lws_genrsa_destroy_elements(struct lws_gencrypto_keyelem *el) static int mode_map[] = { MBEDTLS_RSA_PKCS_V15, MBEDTLS_RSA_PKCS_V21 }; -LWS_VISIBLE int +int lws_genrsa_create(struct lws_genrsa_ctx *ctx, struct lws_gencrypto_keyelem *el, struct lws_context *context, enum enum_genrsa_mode mode, enum lws_genhash_types oaep_hashid) @@ -109,7 +109,7 @@ _rngf(void *context, unsigned char *buf, size_t len) return -1; } -LWS_VISIBLE int +int lws_genrsa_new_keypair(struct lws_context *context, struct lws_genrsa_ctx *ctx, enum enum_genrsa_mode mode, struct lws_gencrypto_keyelem *el, int bits) @@ -167,7 +167,7 @@ cleanup_1: return -1; } -LWS_VISIBLE int +int lws_genrsa_public_decrypt(struct lws_genrsa_ctx *ctx, const uint8_t *in, size_t in_len, uint8_t *out, size_t out_max) { @@ -205,7 +205,7 @@ lws_genrsa_public_decrypt(struct lws_genrsa_ctx *ctx, const uint8_t *in, return olen; } -LWS_VISIBLE int +int lws_genrsa_private_decrypt(struct lws_genrsa_ctx *ctx, const uint8_t *in, size_t in_len, uint8_t *out, size_t out_max) { @@ -243,7 +243,7 @@ lws_genrsa_private_decrypt(struct lws_genrsa_ctx *ctx, const uint8_t *in, return olen; } -LWS_VISIBLE int +int lws_genrsa_public_encrypt(struct lws_genrsa_ctx *ctx, const uint8_t *in, size_t in_len, uint8_t *out) { @@ -278,7 +278,7 @@ lws_genrsa_public_encrypt(struct lws_genrsa_ctx *ctx, const uint8_t *in, return mbedtls_mpi_size(&ctx->ctx->N); } -LWS_VISIBLE int +int lws_genrsa_private_encrypt(struct lws_genrsa_ctx *ctx, const uint8_t *in, size_t in_len, uint8_t *out) { @@ -313,7 +313,7 @@ lws_genrsa_private_encrypt(struct lws_genrsa_ctx *ctx, const uint8_t *in, return mbedtls_mpi_size(&ctx->ctx->N); } -LWS_VISIBLE int +int lws_genrsa_hash_sig_verify(struct lws_genrsa_ctx *ctx, const uint8_t *in, enum lws_genhash_types hash_type, const uint8_t *sig, size_t sig_len) @@ -348,7 +348,7 @@ lws_genrsa_hash_sig_verify(struct lws_genrsa_ctx *ctx, const uint8_t *in, return n; } -LWS_VISIBLE int +int lws_genrsa_hash_sign(struct lws_genrsa_ctx *ctx, const uint8_t *in, enum lws_genhash_types hash_type, uint8_t *sig, size_t sig_len) @@ -391,7 +391,7 @@ lws_genrsa_hash_sign(struct lws_genrsa_ctx *ctx, const uint8_t *in, return ctx->ctx->len; } -LWS_VISIBLE int +int lws_genrsa_render_pkey_asn1(struct lws_genrsa_ctx *ctx, int _private, uint8_t *pkey_asn1, size_t pkey_asn1_len) { @@ -471,7 +471,7 @@ lws_genrsa_render_pkey_asn1(struct lws_genrsa_ctx *ctx, int _private, return n; } -LWS_VISIBLE void +void lws_genrsa_destroy(struct lws_genrsa_ctx *ctx) { if (!ctx->ctx) diff --git a/lib/tls/mbedtls/mbedtls-client.c b/lib/tls/mbedtls/mbedtls-client.c index 9358898d7..ec0443d4a 100644 --- a/lib/tls/mbedtls/mbedtls-client.c +++ b/lib/tls/mbedtls/mbedtls-client.c @@ -80,9 +80,14 @@ lws_ssl_client_bio_create(struct lws *wsi) if (wsi->vhost->tls.alpn) alpn_comma = wsi->vhost->tls.alpn; - if (lws_hdr_copy(wsi, hostname, sizeof(hostname), - _WSI_TOKEN_CLIENT_ALPN) > 0) - alpn_comma = hostname; + if (wsi->stash) { + lws_strncpy(hostname, wsi->stash->cis[CIS_HOST], sizeof(hostname)); + alpn_comma = wsi->stash->cis[CIS_ALPN]; + } else { + if (lws_hdr_copy(wsi, hostname, sizeof(hostname), + _WSI_TOKEN_CLIENT_ALPN) > 0) + alpn_comma = hostname; + } lwsl_info("%s: %p: client conn sending ALPN list '%s'\n", __func__, wsi, alpn_comma); diff --git a/lib/tls/mbedtls/mbedtls-server.c b/lib/tls/mbedtls/mbedtls-server.c index 5acb95557..c247ceb7b 100644 --- a/lib/tls/mbedtls/mbedtls-server.c +++ b/lib/tls/mbedtls/mbedtls-server.c @@ -462,7 +462,7 @@ static uint8_t ss_cert_leadin[] = { #define SAN_A_LENGTH 78 -LWS_VISIBLE int +int lws_tls_acme_sni_cert_create(struct lws_vhost *vhost, const char *san_a, const char *san_b) { @@ -621,7 +621,7 @@ static const char *x5[] = { "C", "ST", "L", "O", "CN" }; * CSR is output formatted as b64url(DER) * Private key is output as a PEM in memory */ -LWS_VISIBLE LWS_EXTERN int +int lws_tls_acme_sni_csr_create(struct lws_context *context, const char *elements[], uint8_t *dcsr, size_t csr_len, char **privkey_pem, size_t *privkey_len) diff --git a/lib/tls/mbedtls/mbedtls-ssl.c b/lib/tls/mbedtls/mbedtls-ssl.c index d2e410a6f..48000ac67 100644 --- a/lib/tls/mbedtls/mbedtls-ssl.c +++ b/lib/tls/mbedtls/mbedtls-ssl.c @@ -26,7 +26,7 @@ #include "private-lib-tls-mbedtls.h" -LWS_VISIBLE void +void lws_ssl_destroy(struct lws_vhost *vhost) { if (!lws_check_opt(vhost->context->options, @@ -42,7 +42,7 @@ lws_ssl_destroy(struct lws_vhost *vhost) X509_free(vhost->tls.x509_client_CA); } -LWS_VISIBLE int +int lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len) { struct lws_context *context = wsi->context; @@ -148,7 +148,7 @@ bail: return n; } -LWS_VISIBLE int +int lws_ssl_pending(struct lws *wsi) { if (!wsi->tls.ssl) @@ -157,7 +157,7 @@ lws_ssl_pending(struct lws *wsi) return SSL_pending(wsi->tls.ssl); } -LWS_VISIBLE int +int lws_ssl_capable_write(struct lws *wsi, unsigned char *buf, int len) { int n, m; @@ -222,7 +222,7 @@ lws_ssl_info_callback(const SSL *ssl, int where, int ret) } -LWS_VISIBLE int +int lws_ssl_close(struct lws *wsi) { lws_sockfd_type n; @@ -252,10 +252,6 @@ lws_ssl_close(struct lws *wsi) /* we made space and can do an accept */ lws_gate_accepts(wsi->context, 1); -#if defined(LWS_WITH_STATS) - wsi->context->updated = 1; -#endif - return 1; /* handled */ } diff --git a/lib/tls/openssl/lws-genaes.c b/lib/tls/openssl/lws-genaes.c index ffad7cd18..402f3a99e 100644 --- a/lib/tls/openssl/lws-genaes.c +++ b/lib/tls/openssl/lws-genaes.c @@ -32,7 +32,7 @@ * lws convention of 0 for success. */ -LWS_VISIBLE int +int lws_genaes_create(struct lws_genaes_ctx *ctx, enum enum_aes_operation op, enum enum_aes_modes mode, struct lws_gencrypto_keyelem *el, enum enum_aes_padding padding, void *engine) @@ -234,7 +234,7 @@ bail: return -1; } -LWS_VISIBLE int +int lws_genaes_destroy(struct lws_genaes_ctx *ctx, unsigned char *tag, size_t tlen) { int outl = 0, n = 0; @@ -282,7 +282,7 @@ lws_genaes_destroy(struct lws_genaes_ctx *ctx, unsigned char *tag, size_t tlen) return n; } -LWS_VISIBLE int +int lws_genaes_crypt(struct lws_genaes_ctx *ctx, const uint8_t *in, size_t len, uint8_t *out, uint8_t *iv_or_nonce_ctr_or_data_unit_16, diff --git a/lib/tls/openssl/lws-genec.c b/lib/tls/openssl/lws-genec.c index 23df7f7ca..a75b489a6 100644 --- a/lib/tls/openssl/lws-genec.c +++ b/lib/tls/openssl/lws-genec.c @@ -226,7 +226,7 @@ bail: return -9; } -LWS_VISIBLE int +int lws_genecdh_create(struct lws_genec_ctx *ctx, struct lws_context *context, const struct lws_ec_curves *curve_table) { @@ -239,7 +239,7 @@ lws_genecdh_create(struct lws_genec_ctx *ctx, struct lws_context *context, return 0; } -LWS_VISIBLE int +int lws_genecdsa_create(struct lws_genec_ctx *ctx, struct lws_context *context, const struct lws_ec_curves *curve_table) { @@ -252,7 +252,7 @@ lws_genecdsa_create(struct lws_genec_ctx *ctx, struct lws_context *context, return 0; } -LWS_VISIBLE int +int lws_genecdh_set_key(struct lws_genec_ctx *ctx, struct lws_gencrypto_keyelem *el, enum enum_lws_dh_side side) { @@ -262,7 +262,7 @@ lws_genecdh_set_key(struct lws_genec_ctx *ctx, struct lws_gencrypto_keyelem *el, return lws_genec_keypair_import(ctx, ctx->curve_table, &ctx->ctx[side], el); } -LWS_VISIBLE int +int lws_genecdsa_set_key(struct lws_genec_ctx *ctx, struct lws_gencrypto_keyelem *el) { @@ -286,7 +286,7 @@ lws_genec_keypair_destroy(EVP_PKEY_CTX **pctx) *pctx = NULL; } -LWS_VISIBLE void +void lws_genec_destroy(struct lws_genec_ctx *ctx) { if (ctx->ctx[0]) @@ -403,7 +403,7 @@ bail: return ret; } -LWS_VISIBLE int +int lws_genecdh_new_keypair(struct lws_genec_ctx *ctx, enum enum_lws_dh_side side, const char *curve_name, struct lws_gencrypto_keyelem *el) @@ -414,7 +414,7 @@ lws_genecdh_new_keypair(struct lws_genec_ctx *ctx, enum enum_lws_dh_side side, return lws_genec_new_keypair(ctx, side, curve_name, el); } -LWS_VISIBLE int +int lws_genecdsa_new_keypair(struct lws_genec_ctx *ctx, const char *curve_name, struct lws_gencrypto_keyelem *el) { @@ -425,7 +425,7 @@ lws_genecdsa_new_keypair(struct lws_genec_ctx *ctx, const char *curve_name, } #if 0 -LWS_VISIBLE LWS_EXTERN int +int lws_genecdsa_hash_sign(struct lws_genec_ctx *ctx, const uint8_t *in, enum lws_genhash_types hash_type, uint8_t *sig, size_t sig_len) @@ -471,7 +471,7 @@ bail: } #endif -LWS_VISIBLE LWS_EXTERN int +int lws_genecdsa_hash_sign_jws(struct lws_genec_ctx *ctx, const uint8_t *in, enum lws_genhash_types hash_type, int keybits, uint8_t *sig, size_t sig_len) @@ -553,7 +553,7 @@ bail: /* in is the JWS Signing Input hash */ -LWS_VISIBLE LWS_EXTERN int +int lws_genecdsa_hash_sig_verify_jws(struct lws_genec_ctx *ctx, const uint8_t *in, enum lws_genhash_types hash_type, int keybits, const uint8_t *sig, size_t sig_len) diff --git a/lib/tls/openssl/lws-genrsa.c b/lib/tls/openssl/lws-genrsa.c index 66fb0df8b..d2797e7ed 100644 --- a/lib/tls/openssl/lws-genrsa.c +++ b/lib/tls/openssl/lws-genrsa.c @@ -32,7 +32,7 @@ * lws convention of 0 for success. */ -LWS_VISIBLE void +void lws_genrsa_destroy_elements(struct lws_gencrypto_keyelem *el) { lws_gencrypto_destroy_elements(el, LWS_GENCRYPTO_RSA_KEYEL_COUNT); @@ -76,7 +76,7 @@ bail: return 1; } -LWS_VISIBLE int +int lws_genrsa_create(struct lws_genrsa_ctx *ctx, struct lws_gencrypto_keyelem *el, struct lws_context *context, enum enum_genrsa_mode mode, enum lws_genhash_types oaep_hashid) @@ -146,7 +146,7 @@ bail: return 1; } -LWS_VISIBLE int +int lws_genrsa_new_keypair(struct lws_context *context, struct lws_genrsa_ctx *ctx, enum enum_genrsa_mode mode, struct lws_gencrypto_keyelem *el, int bits) @@ -220,7 +220,7 @@ cleanup_1: * based padding modes */ -LWS_VISIBLE int +int lws_genrsa_public_encrypt(struct lws_genrsa_ctx *ctx, const uint8_t *in, size_t in_len, uint8_t *out) { @@ -235,7 +235,7 @@ lws_genrsa_public_encrypt(struct lws_genrsa_ctx *ctx, const uint8_t *in, return n; } -LWS_VISIBLE int +int lws_genrsa_private_encrypt(struct lws_genrsa_ctx *ctx, const uint8_t *in, size_t in_len, uint8_t *out) { @@ -250,7 +250,7 @@ lws_genrsa_private_encrypt(struct lws_genrsa_ctx *ctx, const uint8_t *in, return n; } -LWS_VISIBLE int +int lws_genrsa_public_decrypt(struct lws_genrsa_ctx *ctx, const uint8_t *in, size_t in_len, uint8_t *out, size_t out_max) { @@ -264,7 +264,7 @@ lws_genrsa_public_decrypt(struct lws_genrsa_ctx *ctx, const uint8_t *in, return n; } -LWS_VISIBLE int +int lws_genrsa_private_decrypt(struct lws_genrsa_ctx *ctx, const uint8_t *in, size_t in_len, uint8_t *out, size_t out_max) { @@ -279,7 +279,7 @@ lws_genrsa_private_decrypt(struct lws_genrsa_ctx *ctx, const uint8_t *in, return n; } -LWS_VISIBLE int +int lws_genrsa_hash_sig_verify(struct lws_genrsa_ctx *ctx, const uint8_t *in, enum lws_genhash_types hash_type, const uint8_t *sig, size_t sig_len) @@ -322,7 +322,7 @@ lws_genrsa_hash_sig_verify(struct lws_genrsa_ctx *ctx, const uint8_t *in, return 0; } -LWS_VISIBLE int +int lws_genrsa_hash_sign(struct lws_genrsa_ctx *ctx, const uint8_t *in, enum lws_genhash_types hash_type, uint8_t *sig, size_t sig_len) @@ -395,7 +395,7 @@ bail: return -1; } -LWS_VISIBLE void +void lws_genrsa_destroy(struct lws_genrsa_ctx *ctx) { if (!ctx->ctx) diff --git a/lib/tls/openssl/openssl-client.c b/lib/tls/openssl/openssl-client.c index a8ea728fc..1507cc81e 100644 --- a/lib/tls/openssl/openssl-client.c +++ b/lib/tls/openssl/openssl-client.c @@ -141,9 +141,13 @@ lws_ssl_client_bio_create(struct lws *wsi) int n; #endif - if (wsi->stash) + if (wsi->stash) { lws_strncpy(hostname, wsi->stash->cis[CIS_HOST], sizeof(hostname)); - else { +#if defined(LWS_HAVE_SSL_set_alpn_protos) && \ + defined(LWS_HAVE_SSL_get0_alpn_selected) + alpn_comma = wsi->stash->cis[CIS_ALPN]; +#endif + } else { #if defined(LWS_ROLE_H1) || defined(LWS_ROLE_H2) if (lws_hdr_copy(wsi, hostname, sizeof(hostname), _WSI_TOKEN_CLIENT_HOST) <= 0) @@ -262,13 +266,15 @@ lws_ssl_client_bio_create(struct lws *wsi) defined(LWS_HAVE_SSL_get0_alpn_selected) if (wsi->vhost->tls.alpn) alpn_comma = wsi->vhost->tls.alpn; + if (wsi->stash) + alpn_comma = wsi->stash->cis[CIS_ALPN]; #if defined(LWS_ROLE_H1) || defined(LWS_ROLE_H2) if (lws_hdr_copy(wsi, hostname, sizeof(hostname), _WSI_TOKEN_CLIENT_ALPN) > 0) alpn_comma = hostname; #endif - lwsl_info("client conn using alpn list '%s'\n", alpn_comma); + lwsl_info("%s client conn using alpn list '%s'\n", wsi->role_ops->name, alpn_comma); n = lws_alpn_comma_to_openssl(alpn_comma, openssl_alpn, sizeof(openssl_alpn) - 1); diff --git a/lib/tls/openssl/openssl-server.c b/lib/tls/openssl/openssl-server.c index a59d4e2a3..cf19dfd15 100644 --- a/lib/tls/openssl/openssl-server.c +++ b/lib/tls/openssl/openssl-server.c @@ -169,12 +169,11 @@ lws_tls_server_certs_load(struct lws_vhost *vhost, struct lws *wsi, unsigned long error; lws_filepos_t flen; uint8_t *p; +#if OPENSSL_VERSION_NUMBER >= 0x10100000L int ret; - +#endif int n = lws_tls_generic_cert_checks(vhost, cert, private_key), m; - (void)ret; - if (!cert && !private_key) n = LWS_TLS_EXTANT_ALTERNATIVE; @@ -711,7 +710,7 @@ struct lws_tls_ss_pieces { RSA *rsa; }; -LWS_VISIBLE LWS_EXTERN int +int lws_tls_acme_sni_cert_create(struct lws_vhost *vhost, const char *san_a, const char *san_b) { @@ -872,7 +871,7 @@ static int nid_list[] = { NID_pkcs9_emailAddress, /* LWS_TLS_REQ_ELEMENT_EMAIL */ }; -LWS_VISIBLE LWS_EXTERN int +int lws_tls_acme_sni_csr_create(struct lws_context *context, const char *elements[], uint8_t *csr, size_t csr_len, char **privkey_pem, size_t *privkey_len) diff --git a/lib/tls/openssl/openssl-ssl.c b/lib/tls/openssl/openssl-ssl.c index cc5e93993..131209f34 100644 --- a/lib/tls/openssl/openssl-ssl.c +++ b/lib/tls/openssl/openssl-ssl.c @@ -134,7 +134,7 @@ lws_ssl_destroy_client_ctx(struct lws_vhost *vhost) lws_free(tcr); } -LWS_VISIBLE void +void lws_ssl_destroy(struct lws_vhost *vhost) { if (!lws_check_opt(vhost->context->options, @@ -171,7 +171,7 @@ lws_ssl_destroy(struct lws_vhost *vhost) #endif } -LWS_VISIBLE int +int lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len) { struct lws_context *context = wsi->context; @@ -307,7 +307,7 @@ bail: return n; } -LWS_VISIBLE int +int lws_ssl_pending(struct lws *wsi) { if (!wsi->tls.ssl) @@ -316,11 +316,14 @@ lws_ssl_pending(struct lws *wsi) return SSL_pending(wsi->tls.ssl); } -LWS_VISIBLE int +int lws_ssl_capable_write(struct lws *wsi, unsigned char *buf, int len) { int n, m; + // lwsl_notice("%s: len %d\n", __func__, len); + // lwsl_hexdump_notice(buf, len); + if (!wsi->tls.ssl) return lws_ssl_capable_write_no_ssl(wsi, buf, len); @@ -390,7 +393,7 @@ lws_ssl_info_callback(const SSL *ssl, int where, int ret) } -LWS_VISIBLE int +int lws_ssl_close(struct lws *wsi) { lws_sockfd_type n; @@ -423,10 +426,6 @@ lws_ssl_close(struct lws *wsi) // wsi->context->simultaneous_ssl_restriction, // wsi->context->simultaneous_ssl); -#if defined(LWS_WITH_STATS) - wsi->context->updated = 1; -#endif - return 1; /* handled */ } diff --git a/lib/tls/tls-client.c b/lib/tls/tls-client.c index de37ce443..b1b2da767 100644 --- a/lib/tls/tls-client.c +++ b/lib/tls/tls-client.c @@ -50,7 +50,7 @@ lws_ssl_client_connect1(struct lws *wsi) int lws_ssl_client_connect2(struct lws *wsi, char *errbuf, int len) { - int n = 0; + int n; if (lwsi_state(wsi) == LRS_WAITING_SSL) { n = lws_tls_client_connect(wsi); diff --git a/lib/tls/tls-network.c b/lib/tls/tls-network.c index a6703e6de..95261ebd2 100644 --- a/lib/tls/tls-network.c +++ b/lib/tls/tls-network.c @@ -167,7 +167,7 @@ lws_tls_generic_cert_checks(struct lws_vhost *vhost, const char *cert, * update the cert for every vhost using the given path */ -LWS_VISIBLE int +int lws_tls_cert_updated(struct lws_context *context, const char *certpath, const char *keypath, const char *mem_cert, size_t len_mem_cert, @@ -226,6 +226,9 @@ lws_alpn_comma_to_openssl(const char *comma, uint8_t *os, int len) { uint8_t *oos = os, *plen = NULL; + if (!comma) + return 0; + while (*comma && len > 1) { if (!plen && *comma == ' ') { comma++; diff --git a/lib/tls/tls-server.c b/lib/tls/tls-server.c index 3af3e41a3..06ec65484 100644 --- a/lib/tls/tls-server.c +++ b/lib/tls/tls-server.c @@ -38,7 +38,7 @@ lws_sul_tls_cb(lws_sorted_usec_list_t *sul) (lws_usec_t)24 * 3600 * LWS_US_PER_SEC); } -LWS_VISIBLE int +int lws_context_init_server_ssl(const struct lws_context_creation_info *info, struct lws_vhost *vhost) { @@ -72,10 +72,8 @@ lws_context_init_server_ssl(const struct lws_context_creation_info *info, lwsl_notice(" SSL ciphers: '%s'\n", info->ssl_cipher_list); - if (vhost->tls.use_ssl) - lwsl_notice(" Using SSL mode\n"); - else - lwsl_notice(" Using non-SSL mode\n"); + lwsl_notice(" Vhost '%s' using %sTLS mode\n", + vhost->name, vhost->tls.use_ssl ? "" : "non-"); } /* @@ -124,17 +122,14 @@ lws_context_init_server_ssl(const struct lws_context_creation_info *info, } #endif -LWS_VISIBLE int +int lws_server_socket_service_ssl(struct lws *wsi, lws_sockfd_type accept_fd) { struct lws_context *context = wsi->context; struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi]; struct lws_vhost *vh; - char buf[256]; int n; - (void)buf; - if (!LWS_SSL_ENABLED(wsi->vhost)) return 0; diff --git a/minimal-examples/abstract/protocols/smtp-client/CMakeLists.txt b/minimal-examples/abstract/protocols/smtp-client/CMakeLists.txt index 43f424695..005a55b42 100644 --- a/minimal-examples/abstract/protocols/smtp-client/CMakeLists.txt +++ b/minimal-examples/abstract/protocols/smtp-client/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-api-test-smtp_client) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/api-tests/api-test-async-dns/CMakeLists.txt b/minimal-examples/api-tests/api-test-async-dns/CMakeLists.txt index 2d8d0c5c3..61a082762 100644 --- a/minimal-examples/api-tests/api-test-async-dns/CMakeLists.txt +++ b/minimal-examples/api-tests/api-test-async-dns/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-api-test-async-dns) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/api-tests/api-test-dhcpc/CMakeLists.txt b/minimal-examples/api-tests/api-test-dhcpc/CMakeLists.txt index 422cf4955..ade6249a6 100644 --- a/minimal-examples/api-tests/api-test-dhcpc/CMakeLists.txt +++ b/minimal-examples/api-tests/api-test-dhcpc/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-api-test-dhcpc) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/api-tests/api-test-fts/CMakeLists.txt b/minimal-examples/api-tests/api-test-fts/CMakeLists.txt index 023e837ad..aa4579fec 100644 --- a/minimal-examples/api-tests/api-test-fts/CMakeLists.txt +++ b/minimal-examples/api-tests/api-test-fts/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-api-test-fts) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/api-tests/api-test-gencrypto/CMakeLists.txt b/minimal-examples/api-tests/api-test-gencrypto/CMakeLists.txt index 4e9725211..cfeac8799 100644 --- a/minimal-examples/api-tests/api-test-gencrypto/CMakeLists.txt +++ b/minimal-examples/api-tests/api-test-gencrypto/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-api-test-gencrypto) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/api-tests/api-test-jose/CMakeLists.txt b/minimal-examples/api-tests/api-test-jose/CMakeLists.txt index 64e8bdecb..81c0cf89c 100644 --- a/minimal-examples/api-tests/api-test-jose/CMakeLists.txt +++ b/minimal-examples/api-tests/api-test-jose/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-api-test-jose) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/api-tests/api-test-lws_dsh/CMakeLists.txt b/minimal-examples/api-tests/api-test-lws_dsh/CMakeLists.txt index 936d61039..262b4f08b 100644 --- a/minimal-examples/api-tests/api-test-lws_dsh/CMakeLists.txt +++ b/minimal-examples/api-tests/api-test-lws_dsh/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-api-test-lws_dsh) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/api-tests/api-test-lws_dsh/main.c b/minimal-examples/api-tests/api-test-lws_dsh/main.c index 638f46855..dc0f7d710 100644 --- a/minimal-examples/api-tests/api-test-lws_dsh/main.c +++ b/minimal-examples/api-tests/api-test-lws_dsh/main.c @@ -114,7 +114,7 @@ test2(void) } dsh2 = lws_dsh_create(&owner, 4096, 2); - if (!dsh) { + if (!dsh2) { lwsl_err("%s: Failed to create dsh2\n", __func__); goto bail; @@ -193,7 +193,7 @@ test3(void) } dsh2 = lws_dsh_create(&owner, 4096, 2); - if (!dsh) { + if (!dsh2) { lwsl_err("%s: Failed to create dsh2\n", __func__); goto bail; diff --git a/minimal-examples/api-tests/api-test-lws_sequencer/CMakeLists.txt b/minimal-examples/api-tests/api-test-lws_sequencer/CMakeLists.txt index 7b15d25f1..07ff7c573 100644 --- a/minimal-examples/api-tests/api-test-lws_sequencer/CMakeLists.txt +++ b/minimal-examples/api-tests/api-test-lws_sequencer/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-api-test-lws_sequencer) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/api-tests/api-test-lws_struct-json/CMakeLists.txt b/minimal-examples/api-tests/api-test-lws_struct-json/CMakeLists.txt index 83e37da06..b931750fc 100644 --- a/minimal-examples/api-tests/api-test-lws_struct-json/CMakeLists.txt +++ b/minimal-examples/api-tests/api-test-lws_struct-json/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-api-test-lws_struct-json) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/api-tests/api-test-lws_tokenize/CMakeLists.txt b/minimal-examples/api-tests/api-test-lws_tokenize/CMakeLists.txt index 7bfc6f651..26b3f1f8a 100644 --- a/minimal-examples/api-tests/api-test-lws_tokenize/CMakeLists.txt +++ b/minimal-examples/api-tests/api-test-lws_tokenize/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-api-test-lws_tokenize) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/api-tests/api-test-lwsac/CMakeLists.txt b/minimal-examples/api-tests/api-test-lwsac/CMakeLists.txt index a73c6807e..c5ad3174e 100644 --- a/minimal-examples/api-tests/api-test-lwsac/CMakeLists.txt +++ b/minimal-examples/api-tests/api-test-lwsac/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-api-test-lwsac) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/api-tests/api-test-smtp_client/CMakeLists.txt b/minimal-examples/api-tests/api-test-smtp_client/CMakeLists.txt index 4c8e671ff..42c936335 100644 --- a/minimal-examples/api-tests/api-test-smtp_client/CMakeLists.txt +++ b/minimal-examples/api-tests/api-test-smtp_client/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-unit-tests-smtp-client) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/client-server/minimal-ws-proxy/CMakeLists.txt b/minimal-examples/client-server/minimal-ws-proxy/CMakeLists.txt index 626874798..d33d3971d 100644 --- a/minimal-examples/client-server/minimal-ws-proxy/CMakeLists.txt +++ b/minimal-examples/client-server/minimal-ws-proxy/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-ws-proxy) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/client-server/minimal-ws-proxy/protocol_lws_minimal.c b/minimal-examples/client-server/minimal-ws-proxy/protocol_lws_minimal.c index c51c3047f..0e72c5443 100644 --- a/minimal-examples/client-server/minimal-ws-proxy/protocol_lws_minimal.c +++ b/minimal-examples/client-server/minimal-ws-proxy/protocol_lws_minimal.c @@ -253,7 +253,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_MINIMAL }; -LWS_EXTERN LWS_VISIBLE int +int init_protocol_minimal(struct lws_context *context, struct lws_plugin_capability *c) { @@ -271,7 +271,7 @@ init_protocol_minimal(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +int destroy_protocol_minimal(struct lws_context *context) { return 0; diff --git a/minimal-examples/crypto/minimal-crypto-jwe/CMakeLists.txt b/minimal-examples/crypto/minimal-crypto-jwe/CMakeLists.txt index 05f737669..b780a7819 100644 --- a/minimal-examples/crypto/minimal-crypto-jwe/CMakeLists.txt +++ b/minimal-examples/crypto/minimal-crypto-jwe/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-crypto-jwe) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/crypto/minimal-crypto-jwk/CMakeLists.txt b/minimal-examples/crypto/minimal-crypto-jwk/CMakeLists.txt index fb8c3e372..045f10c9e 100644 --- a/minimal-examples/crypto/minimal-crypto-jwk/CMakeLists.txt +++ b/minimal-examples/crypto/minimal-crypto-jwk/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-crypto-jwk) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/crypto/minimal-crypto-jws/CMakeLists.txt b/minimal-examples/crypto/minimal-crypto-jws/CMakeLists.txt index ddf957969..3be49cbaf 100644 --- a/minimal-examples/crypto/minimal-crypto-jws/CMakeLists.txt +++ b/minimal-examples/crypto/minimal-crypto-jws/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-crypto-jws) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/crypto/minimal-crypto-x509/CMakeLists.txt b/minimal-examples/crypto/minimal-crypto-x509/CMakeLists.txt index 327cdcd96..5e37838af 100644 --- a/minimal-examples/crypto/minimal-crypto-x509/CMakeLists.txt +++ b/minimal-examples/crypto/minimal-crypto-x509/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-crypto-x509) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/dbus-client/minimal-dbus-client/CMakeLists.txt b/minimal-examples/dbus-client/minimal-dbus-client/CMakeLists.txt index cf3db473a..9d3f4515f 100644 --- a/minimal-examples/dbus-client/minimal-dbus-client/CMakeLists.txt +++ b/minimal-examples/dbus-client/minimal-dbus-client/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-dbus-client) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) include(CheckLibraryExists) diff --git a/minimal-examples/dbus-client/minimal-dbus-ws-proxy-testclient/CMakeLists.txt b/minimal-examples/dbus-client/minimal-dbus-ws-proxy-testclient/CMakeLists.txt index 29249796b..0ec0cca92 100644 --- a/minimal-examples/dbus-client/minimal-dbus-ws-proxy-testclient/CMakeLists.txt +++ b/minimal-examples/dbus-client/minimal-dbus-ws-proxy-testclient/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-dbus-ws-proxy-testclient) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) include(CheckLibraryExists) diff --git a/minimal-examples/dbus-server/minimal-dbus-server/CMakeLists.txt b/minimal-examples/dbus-server/minimal-dbus-server/CMakeLists.txt index 55dee1feb..37e49f0a9 100644 --- a/minimal-examples/dbus-server/minimal-dbus-server/CMakeLists.txt +++ b/minimal-examples/dbus-server/minimal-dbus-server/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-dbus-server) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) include(CheckLibraryExists) diff --git a/minimal-examples/dbus-server/minimal-dbus-ws-proxy/CMakeLists.txt b/minimal-examples/dbus-server/minimal-dbus-ws-proxy/CMakeLists.txt index 3e8a8b4b6..bd5148c23 100644 --- a/minimal-examples/dbus-server/minimal-dbus-ws-proxy/CMakeLists.txt +++ b/minimal-examples/dbus-server/minimal-dbus-ws-proxy/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-dbus-ws-proxy) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) include(CheckLibraryExists) diff --git a/minimal-examples/dbus-server/minimal-dbus-ws-proxy/protocol_lws_minimal_dbus_ws_proxy.c b/minimal-examples/dbus-server/minimal-dbus-ws-proxy/protocol_lws_minimal_dbus_ws_proxy.c index 693acc747..e3e01c3db 100644 --- a/minimal-examples/dbus-server/minimal-dbus-ws-proxy/protocol_lws_minimal_dbus_ws_proxy.c +++ b/minimal-examples/dbus-server/minimal-dbus-ws-proxy/protocol_lws_minimal_dbus_ws_proxy.c @@ -802,7 +802,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_MINIMAL_DBUS_WSPROXY }; -LWS_EXTERN LWS_VISIBLE int +int init_protocol_minimal_dbus_wsproxy(struct lws_context *context, struct lws_plugin_capability *c) { @@ -820,7 +820,7 @@ init_protocol_minimal_dbus_wsproxy(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +int destroy_protocol_minimal_dbus_wsproxy(struct lws_context *context) { return 0; diff --git a/minimal-examples/http-client/minimal-http-client-attach/CMakeLists.txt b/minimal-examples/http-client/minimal-http-client-attach/CMakeLists.txt index 56932e544..b38a68676 100644 --- a/minimal-examples/http-client/minimal-http-client-attach/CMakeLists.txt +++ b/minimal-examples/http-client/minimal-http-client-attach/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-client-attach) cmake_minimum_required(VERSION 2.8) include(CheckIncludeFile) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-client/minimal-http-client-certinfo/CMakeLists.txt b/minimal-examples/http-client/minimal-http-client-certinfo/CMakeLists.txt index 8f3462c41..b97fb1281 100644 --- a/minimal-examples/http-client/minimal-http-client-certinfo/CMakeLists.txt +++ b/minimal-examples/http-client/minimal-http-client-certinfo/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-client-certinfo) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-client/minimal-http-client-custom-headers/CMakeLists.txt b/minimal-examples/http-client/minimal-http-client-custom-headers/CMakeLists.txt index 4c3c525b5..09bb1de29 100644 --- a/minimal-examples/http-client/minimal-http-client-custom-headers/CMakeLists.txt +++ b/minimal-examples/http-client/minimal-http-client-custom-headers/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-client-custom-headers) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-client/minimal-http-client-h2-rxflow/CMakeLists.txt b/minimal-examples/http-client/minimal-http-client-h2-rxflow/CMakeLists.txt index 0289f114d..4b31f9d37 100644 --- a/minimal-examples/http-client/minimal-http-client-h2-rxflow/CMakeLists.txt +++ b/minimal-examples/http-client/minimal-http-client-h2-rxflow/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-client-h2-rxflow) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-client/minimal-http-client-hugeurl/CMakeLists.txt b/minimal-examples/http-client/minimal-http-client-hugeurl/CMakeLists.txt index 2e516d97c..b36eae40d 100644 --- a/minimal-examples/http-client/minimal-http-client-hugeurl/CMakeLists.txt +++ b/minimal-examples/http-client/minimal-http-client-hugeurl/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-client-hugeurl) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-client/minimal-http-client-multi/CMakeLists.txt b/minimal-examples/http-client/minimal-http-client-multi/CMakeLists.txt index 4fe5ceaa6..2f9c30536 100644 --- a/minimal-examples/http-client/minimal-http-client-multi/CMakeLists.txt +++ b/minimal-examples/http-client/minimal-http-client-multi/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-client-multi) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-client/minimal-http-client-multi/minimal-http-client-multi.c b/minimal-examples/http-client/minimal-http-client-multi/minimal-http-client-multi.c index 98fdcd164..f37affa57 100644 --- a/minimal-examples/http-client/minimal-http-client-multi/minimal-http-client-multi.c +++ b/minimal-examples/http-client/minimal-http-client-multi/minimal-http-client-multi.c @@ -341,7 +341,6 @@ int main(int argc, const char **argv) 100 * LWS_US_PER_MS); start = us(); - m = 0; while (n >= 0 && !interrupted) n = lws_service(context, 0); diff --git a/minimal-examples/http-client/minimal-http-client-post/CMakeLists.txt b/minimal-examples/http-client/minimal-http-client-post/CMakeLists.txt index 5dffbefd3..9c5780f55 100644 --- a/minimal-examples/http-client/minimal-http-client-post/CMakeLists.txt +++ b/minimal-examples/http-client/minimal-http-client-post/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-client-post) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-client/minimal-http-client/CMakeLists.txt b/minimal-examples/http-client/minimal-http-client/CMakeLists.txt index bb0dfbbfe..be0d758f8 100644 --- a/minimal-examples/http-client/minimal-http-client/CMakeLists.txt +++ b/minimal-examples/http-client/minimal-http-client/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-client) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-basicauth/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-basicauth/CMakeLists.txt index 1cd884d6a..28fdb5790 100644 --- a/minimal-examples/http-server/minimal-http-server-basicauth/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-basicauth/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-basicauth) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-cgi/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-cgi/CMakeLists.txt index 690f1b556..e0580c21c 100644 --- a/minimal-examples/http-server/minimal-http-server-cgi/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-cgi/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-cgi) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-custom-headers/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-custom-headers/CMakeLists.txt index 6df13d907..9e0c57f3f 100644 --- a/minimal-examples/http-server/minimal-http-server-custom-headers/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-custom-headers/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-custom-headers) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-deaddrop/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-deaddrop/CMakeLists.txt index bb84b7294..af98f2a88 100644 --- a/minimal-examples/http-server/minimal-http-server-deaddrop/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-deaddrop/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-deaddrop) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-dynamic/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-dynamic/CMakeLists.txt index c586a2132..f3a844744 100644 --- a/minimal-examples/http-server/minimal-http-server-dynamic/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-dynamic/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-dynamic) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-eventlib-demos/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-eventlib-demos/CMakeLists.txt index 5adef2977..c11deb6c0 100644 --- a/minimal-examples/http-server/minimal-http-server-eventlib-demos/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-eventlib-demos/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-eventlib-demos) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-eventlib-foreign/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-eventlib-foreign/CMakeLists.txt index 94a8b73c4..197e50737 100644 --- a/minimal-examples/http-server/minimal-http-server-eventlib-foreign/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-eventlib-foreign/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-eventlib-foreign) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-eventlib-smp/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-eventlib-smp/CMakeLists.txt index 1ef821349..c6515a05b 100644 --- a/minimal-examples/http-server/minimal-http-server-eventlib-smp/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-eventlib-smp/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-eventlib-smp) cmake_minimum_required(VERSION 2.8) include(CheckIncludeFile) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-eventlib/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-eventlib/CMakeLists.txt index 8824bc48b..e712b8a7b 100644 --- a/minimal-examples/http-server/minimal-http-server-eventlib/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-eventlib/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-eventlib) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-form-get/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-form-get/CMakeLists.txt index a4c9d9de6..b1dc6375f 100644 --- a/minimal-examples/http-server/minimal-http-server-form-get/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-form-get/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-form-get) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-form-post-file/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-form-post-file/CMakeLists.txt index 7382d5360..310e675eb 100644 --- a/minimal-examples/http-server/minimal-http-server-form-post-file/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-form-post-file/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-form-post-file) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-form-post-lwsac/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-form-post-lwsac/CMakeLists.txt index a00f5d634..a748c60ad 100644 --- a/minimal-examples/http-server/minimal-http-server-form-post-lwsac/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-form-post-lwsac/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-form-post-lwsac) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-form-post/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-form-post/CMakeLists.txt index dd5be12ac..ee9c76435 100644 --- a/minimal-examples/http-server/minimal-http-server-form-post/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-form-post/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-form-post) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-fulltext-search/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-fulltext-search/CMakeLists.txt index 8ea924e36..4a9c88621 100644 --- a/minimal-examples/http-server/minimal-http-server-fulltext-search/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-fulltext-search/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-fulltext-search) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-generic-sessions/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-generic-sessions/CMakeLists.txt index 973c8700f..b62fe168c 100644 --- a/minimal-examples/http-server/minimal-http-server-generic-sessions/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-generic-sessions/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-generic-sessions) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-generic-sessions/mount-origin/example.js b/minimal-examples/http-server/minimal-http-server-generic-sessions/mount-origin/example.js index d58154535..1bde61e46 100644 --- a/minimal-examples/http-server/minimal-http-server-generic-sessions/mount-origin/example.js +++ b/minimal-examples/http-server/minimal-http-server-generic-sessions/mount-origin/example.js @@ -16,6 +16,6 @@ document.addEventListener("DOMContentLoaded", function() { } } - if (transport_protocol == "h2") + if (transport_protocol === "h2") document.getElementById("transport").innerHTML = ""; }, false); \ No newline at end of file diff --git a/minimal-examples/http-server/minimal-http-server-h2-long-poll/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-h2-long-poll/CMakeLists.txt index 4a30f9cb2..21f45c9a0 100644 --- a/minimal-examples/http-server/minimal-http-server-h2-long-poll/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-h2-long-poll/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-h2-long-poll) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-mimetypes/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-mimetypes/CMakeLists.txt index bbccc01a2..d12e9f947 100644 --- a/minimal-examples/http-server/minimal-http-server-mimetypes/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-mimetypes/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-mimetypes) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-multivhost/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-multivhost/CMakeLists.txt index 3633cf1fd..fc813a37c 100644 --- a/minimal-examples/http-server/minimal-http-server-multivhost/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-multivhost/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-multivhost) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-proxy/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-proxy/CMakeLists.txt index b32a8b3fd..a54a4dc08 100644 --- a/minimal-examples/http-server/minimal-http-server-proxy/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-proxy/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-proxy) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-smp/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-smp/CMakeLists.txt index 36e615a84..08f839a39 100644 --- a/minimal-examples/http-server/minimal-http-server-smp/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-smp/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-smp) cmake_minimum_required(VERSION 2.8) include(CheckIncludeFile) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-sse-ring/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-sse-ring/CMakeLists.txt index d80867bff..596a9afd0 100644 --- a/minimal-examples/http-server/minimal-http-server-sse-ring/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-sse-ring/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-sse-ring) cmake_minimum_required(VERSION 2.8) include(CheckIncludeFile) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-sse/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-sse/CMakeLists.txt index 5719ee259..972fb9012 100644 --- a/minimal-examples/http-server/minimal-http-server-sse/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-sse/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-sse) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-tls-80/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-tls-80/CMakeLists.txt index d7ef0f273..60af8b5d9 100644 --- a/minimal-examples/http-server/minimal-http-server-tls-80/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-tls-80/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-tls-80) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-tls-mem/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-tls-mem/CMakeLists.txt index 43a3ff0c4..03bd1baa1 100644 --- a/minimal-examples/http-server/minimal-http-server-tls-mem/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-tls-mem/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-tls-mem) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-tls-mem/mount-origin/example.js b/minimal-examples/http-server/minimal-http-server-tls-mem/mount-origin/example.js index d797d3795..88c245aff 100644 --- a/minimal-examples/http-server/minimal-http-server-tls-mem/mount-origin/example.js +++ b/minimal-examples/http-server/minimal-http-server-tls-mem/mount-origin/example.js @@ -16,7 +16,7 @@ document.addEventListener("DOMContentLoaded", function() { } } - if (transport_protocol == "h2") + if (transport_protocol === "h2") document.getElementById("transport").innerHTML = ""; }, false); \ No newline at end of file diff --git a/minimal-examples/http-server/minimal-http-server-tls/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-tls/CMakeLists.txt index d4e8b2521..2f381daf8 100644 --- a/minimal-examples/http-server/minimal-http-server-tls/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-tls/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server-tls) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/http-server/minimal-http-server-tls/mount-origin/example.js b/minimal-examples/http-server/minimal-http-server-tls/mount-origin/example.js index 574ee9760..a90e44671 100644 --- a/minimal-examples/http-server/minimal-http-server-tls/mount-origin/example.js +++ b/minimal-examples/http-server/minimal-http-server-tls/mount-origin/example.js @@ -16,6 +16,6 @@ document.addEventListener("DOMContentLoaded", function() { } } - if (transport_protocol == "h2") + if (transport_protocol === "h2") document.getElementById("transport").innerHTML = ""; }, false); diff --git a/minimal-examples/http-server/minimal-http-server/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server/CMakeLists.txt index 8312e830e..483877fc0 100644 --- a/minimal-examples/http-server/minimal-http-server/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-http-server) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/raw/minimal-raw-adopt-tcp/CMakeLists.txt b/minimal-examples/raw/minimal-raw-adopt-tcp/CMakeLists.txt index b6327ab93..573d7985c 100644 --- a/minimal-examples/raw/minimal-raw-adopt-tcp/CMakeLists.txt +++ b/minimal-examples/raw/minimal-raw-adopt-tcp/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-raw-adopt-tcp) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/raw/minimal-raw-adopt-udp/CMakeLists.txt b/minimal-examples/raw/minimal-raw-adopt-udp/CMakeLists.txt index e3e4f5a97..a05e3397e 100644 --- a/minimal-examples/raw/minimal-raw-adopt-udp/CMakeLists.txt +++ b/minimal-examples/raw/minimal-raw-adopt-udp/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-raw-adopt-udp) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/raw/minimal-raw-audio/CMakeLists.txt b/minimal-examples/raw/minimal-raw-audio/CMakeLists.txt index d495893bd..7827dd407 100644 --- a/minimal-examples/raw/minimal-raw-audio/CMakeLists.txt +++ b/minimal-examples/raw/minimal-raw-audio/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-raw-audio) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/raw/minimal-raw-fallback-http-server/CMakeLists.txt b/minimal-examples/raw/minimal-raw-fallback-http-server/CMakeLists.txt index 4a7f1084d..ff417c2c6 100644 --- a/minimal-examples/raw/minimal-raw-fallback-http-server/CMakeLists.txt +++ b/minimal-examples/raw/minimal-raw-fallback-http-server/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-raw-fallback-http-server) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/raw/minimal-raw-file/CMakeLists.txt b/minimal-examples/raw/minimal-raw-file/CMakeLists.txt index 2164e6364..75d0bf25a 100644 --- a/minimal-examples/raw/minimal-raw-file/CMakeLists.txt +++ b/minimal-examples/raw/minimal-raw-file/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-raw-file) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/raw/minimal-raw-netcat/CMakeLists.txt b/minimal-examples/raw/minimal-raw-netcat/CMakeLists.txt index eeefc1328..b6b1124b1 100644 --- a/minimal-examples/raw/minimal-raw-netcat/CMakeLists.txt +++ b/minimal-examples/raw/minimal-raw-netcat/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-raw-netcat) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/raw/minimal-raw-proxy-fallback/CMakeLists.txt b/minimal-examples/raw/minimal-raw-proxy-fallback/CMakeLists.txt index c0f72cee4..426847872 100644 --- a/minimal-examples/raw/minimal-raw-proxy-fallback/CMakeLists.txt +++ b/minimal-examples/raw/minimal-raw-proxy-fallback/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-raw-proxy-fallback) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/raw/minimal-raw-proxy/CMakeLists.txt b/minimal-examples/raw/minimal-raw-proxy/CMakeLists.txt index da033dde9..c16c658f4 100644 --- a/minimal-examples/raw/minimal-raw-proxy/CMakeLists.txt +++ b/minimal-examples/raw/minimal-raw-proxy/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-raw-proxy) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/raw/minimal-raw-serial/CMakeLists.txt b/minimal-examples/raw/minimal-raw-serial/CMakeLists.txt index 714af81cc..523dc87af 100644 --- a/minimal-examples/raw/minimal-raw-serial/CMakeLists.txt +++ b/minimal-examples/raw/minimal-raw-serial/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-raw-serial) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/raw/minimal-raw-vhost/CMakeLists.txt b/minimal-examples/raw/minimal-raw-vhost/CMakeLists.txt index 9866d09a6..8da1a0ac4 100644 --- a/minimal-examples/raw/minimal-raw-vhost/CMakeLists.txt +++ b/minimal-examples/raw/minimal-raw-vhost/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-raw-vhost) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/raw/minimal-raw-vhost/minimal-raw-vhost.c b/minimal-examples/raw/minimal-raw-vhost/minimal-raw-vhost.c index 097abef9c..c5bb334d8 100644 --- a/minimal-examples/raw/minimal-raw-vhost/minimal-raw-vhost.c +++ b/minimal-examples/raw/minimal-raw-vhost/minimal-raw-vhost.c @@ -53,7 +53,7 @@ callback_raw_test(struct lws *wsi, enum lws_callback_reasons reason, switch (reason) { case LWS_CALLBACK_PROTOCOL_INIT: - vhd = lws_protocol_vh_priv_zalloc(lws_get_vhost(wsi), + lws_protocol_vh_priv_zalloc(lws_get_vhost(wsi), lws_get_protocol(wsi), sizeof(struct raw_vhd)); break; diff --git a/minimal-examples/ws-client/minimal-ws-client-echo/CMakeLists.txt b/minimal-examples/ws-client/minimal-ws-client-echo/CMakeLists.txt index ee2a6545d..a998ccbaf 100644 --- a/minimal-examples/ws-client/minimal-ws-client-echo/CMakeLists.txt +++ b/minimal-examples/ws-client/minimal-ws-client-echo/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-ws-client-echo) cmake_minimum_required(VERSION 2.8.9) include(CheckCSourceCompiles) diff --git a/minimal-examples/ws-client/minimal-ws-client-echo/protocol_lws_minimal_client_echo.c b/minimal-examples/ws-client/minimal-ws-client-echo/protocol_lws_minimal_client_echo.c index 7023e763d..3e895902c 100644 --- a/minimal-examples/ws-client/minimal-ws-client-echo/protocol_lws_minimal_client_echo.c +++ b/minimal-examples/ws-client/minimal-ws-client-echo/protocol_lws_minimal_client_echo.c @@ -302,7 +302,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_MINIMAL_CLIENT_ECHO }; -LWS_EXTERN LWS_VISIBLE int +int init_protocol_minimal_client_echo(struct lws_context *context, struct lws_plugin_capability *c) { @@ -320,7 +320,7 @@ init_protocol_minimal_client_echo(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +int destroy_protocol_minimal_client_echo(struct lws_context *context) { return 0; diff --git a/minimal-examples/ws-client/minimal-ws-client-ping/CMakeLists.txt b/minimal-examples/ws-client/minimal-ws-client-ping/CMakeLists.txt index e31b215f5..f3811eb7e 100644 --- a/minimal-examples/ws-client/minimal-ws-client-ping/CMakeLists.txt +++ b/minimal-examples/ws-client/minimal-ws-client-ping/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-ws-client-ping) cmake_minimum_required(VERSION 2.8) include(CheckIncludeFile) include(CheckCSourceCompiles) diff --git a/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/CMakeLists.txt b/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/CMakeLists.txt index 2fd52f2a2..e4a1e3128 100644 --- a/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/CMakeLists.txt +++ b/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-ws-client-pmd-bulk) cmake_minimum_required(VERSION 2.8.9) include(CheckCSourceCompiles) diff --git a/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/protocol_lws_minimal_pmd_bulk.c b/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/protocol_lws_minimal_pmd_bulk.c index a1b38c4a3..6726ca5b3 100644 --- a/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/protocol_lws_minimal_pmd_bulk.c +++ b/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/protocol_lws_minimal_pmd_bulk.c @@ -293,7 +293,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_MINIMAL_PMD_BULK }; -LWS_EXTERN LWS_VISIBLE int +int init_protocol_minimal_pmd_bulk(struct lws_context *context, struct lws_plugin_capability *c) { @@ -311,7 +311,7 @@ init_protocol_minimal_pmd_bulk(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +int destroy_protocol_minimal_pmd_bulk(struct lws_context *context) { return 0; diff --git a/minimal-examples/ws-client/minimal-ws-client-rx/CMakeLists.txt b/minimal-examples/ws-client/minimal-ws-client-rx/CMakeLists.txt index 740f267b6..31b51178b 100644 --- a/minimal-examples/ws-client/minimal-ws-client-rx/CMakeLists.txt +++ b/minimal-examples/ws-client/minimal-ws-client-rx/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-ws-client-rx) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/ws-client/minimal-ws-client-spam/CMakeLists.txt b/minimal-examples/ws-client/minimal-ws-client-spam/CMakeLists.txt index 0543bd8af..fa80cd47f 100644 --- a/minimal-examples/ws-client/minimal-ws-client-spam/CMakeLists.txt +++ b/minimal-examples/ws-client/minimal-ws-client-spam/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-ws-client-spam) cmake_minimum_required(VERSION 2.8) include(CheckIncludeFile) include(CheckCSourceCompiles) diff --git a/minimal-examples/ws-client/minimal-ws-client-tx/CMakeLists.txt b/minimal-examples/ws-client/minimal-ws-client-tx/CMakeLists.txt index fe0c67ef2..3dc1b151c 100644 --- a/minimal-examples/ws-client/minimal-ws-client-tx/CMakeLists.txt +++ b/minimal-examples/ws-client/minimal-ws-client-tx/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-ws-client-tx) cmake_minimum_required(VERSION 2.8) include(CheckIncludeFile) include(CheckCSourceCompiles) diff --git a/minimal-examples/ws-server/minimal-ws-broker/CMakeLists.txt b/minimal-examples/ws-server/minimal-ws-broker/CMakeLists.txt index ef741a461..4a1d95212 100644 --- a/minimal-examples/ws-server/minimal-ws-broker/CMakeLists.txt +++ b/minimal-examples/ws-server/minimal-ws-broker/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-ws-broker) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/ws-server/minimal-ws-broker/protocol_lws_minimal.c b/minimal-examples/ws-server/minimal-ws-broker/protocol_lws_minimal.c index 4ee8981f7..b13d4be0a 100644 --- a/minimal-examples/ws-server/minimal-ws-broker/protocol_lws_minimal.c +++ b/minimal-examples/ws-server/minimal-ws-broker/protocol_lws_minimal.c @@ -224,7 +224,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_MINIMAL }; -LWS_EXTERN LWS_VISIBLE int +int init_protocol_minimal(struct lws_context *context, struct lws_plugin_capability *c) { @@ -242,7 +242,7 @@ init_protocol_minimal(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +int destroy_protocol_minimal(struct lws_context *context) { return 0; diff --git a/minimal-examples/ws-server/minimal-ws-server-echo/CMakeLists.txt b/minimal-examples/ws-server/minimal-ws-server-echo/CMakeLists.txt index 0861125ed..d424d5939 100644 --- a/minimal-examples/ws-server/minimal-ws-server-echo/CMakeLists.txt +++ b/minimal-examples/ws-server/minimal-ws-server-echo/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-ws-server-echo) cmake_minimum_required(VERSION 2.8.9) include(CheckCSourceCompiles) diff --git a/minimal-examples/ws-server/minimal-ws-server-echo/protocol_lws_minimal_server_echo.c b/minimal-examples/ws-server/minimal-ws-server-echo/protocol_lws_minimal_server_echo.c index b2a55314b..d6075fb07 100644 --- a/minimal-examples/ws-server/minimal-ws-server-echo/protocol_lws_minimal_server_echo.c +++ b/minimal-examples/ws-server/minimal-ws-server-echo/protocol_lws_minimal_server_echo.c @@ -239,7 +239,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_MINIMAL_SERVER_ECHO }; -LWS_EXTERN LWS_VISIBLE int +int init_protocol_minimal_server_echo(struct lws_context *context, struct lws_plugin_capability *c) { @@ -257,7 +257,7 @@ init_protocol_minimal_server_echo(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +int destroy_protocol_minimal_server_echo(struct lws_context *context) { return 0; diff --git a/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/CMakeLists.txt b/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/CMakeLists.txt index 08585f2f6..35fa25640 100644 --- a/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/CMakeLists.txt +++ b/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-ws-server-pmd-bulk) cmake_minimum_required(VERSION 2.8.9) include(CheckCSourceCompiles) diff --git a/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/protocol_lws_minimal_pmd_bulk.c b/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/protocol_lws_minimal_pmd_bulk.c index 09e430709..2ee48b0ee 100644 --- a/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/protocol_lws_minimal_pmd_bulk.c +++ b/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/protocol_lws_minimal_pmd_bulk.c @@ -230,7 +230,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_MINIMAL_PMD_BULK }; -LWS_EXTERN LWS_VISIBLE int +int init_protocol_minimal_pmd_bulk(struct lws_context *context, struct lws_plugin_capability *c) { @@ -248,7 +248,7 @@ init_protocol_minimal_pmd_bulk(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +int destroy_protocol_minimal_pmd_bulk(struct lws_context *context) { return 0; diff --git a/minimal-examples/ws-server/minimal-ws-server-pmd-corner/CMakeLists.txt b/minimal-examples/ws-server/minimal-ws-server-pmd-corner/CMakeLists.txt index 3215a5504..8bc970637 100644 --- a/minimal-examples/ws-server/minimal-ws-server-pmd-corner/CMakeLists.txt +++ b/minimal-examples/ws-server/minimal-ws-server-pmd-corner/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-ws-server-pmd-corner) cmake_minimum_required(VERSION 2.8.9) include(CheckCSourceCompiles) diff --git a/minimal-examples/ws-server/minimal-ws-server-pmd-corner/protocol_lws_minimal.c b/minimal-examples/ws-server/minimal-ws-server-pmd-corner/protocol_lws_minimal.c index 1558b3737..9f11af505 100644 --- a/minimal-examples/ws-server/minimal-ws-server-pmd-corner/protocol_lws_minimal.c +++ b/minimal-examples/ws-server/minimal-ws-server-pmd-corner/protocol_lws_minimal.c @@ -278,7 +278,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_MINIMAL }; -LWS_EXTERN LWS_VISIBLE int +int init_protocol_minimal(struct lws_context *context, struct lws_plugin_capability *c) { @@ -296,7 +296,7 @@ init_protocol_minimal(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +int destroy_protocol_minimal(struct lws_context *context) { return 0; diff --git a/minimal-examples/ws-server/minimal-ws-server-pmd/CMakeLists.txt b/minimal-examples/ws-server/minimal-ws-server-pmd/CMakeLists.txt index aeacb143a..fe5582137 100644 --- a/minimal-examples/ws-server/minimal-ws-server-pmd/CMakeLists.txt +++ b/minimal-examples/ws-server/minimal-ws-server-pmd/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-ws-server-pmd) cmake_minimum_required(VERSION 2.8.9) include(CheckCSourceCompiles) diff --git a/minimal-examples/ws-server/minimal-ws-server-pmd/protocol_lws_minimal.c b/minimal-examples/ws-server/minimal-ws-server-pmd/protocol_lws_minimal.c index be72f824e..db07511f5 100644 --- a/minimal-examples/ws-server/minimal-ws-server-pmd/protocol_lws_minimal.c +++ b/minimal-examples/ws-server/minimal-ws-server-pmd/protocol_lws_minimal.c @@ -167,7 +167,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_MINIMAL }; -LWS_EXTERN LWS_VISIBLE int +int init_protocol_minimal(struct lws_context *context, struct lws_plugin_capability *c) { @@ -185,7 +185,7 @@ init_protocol_minimal(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +int destroy_protocol_minimal(struct lws_context *context) { return 0; diff --git a/minimal-examples/ws-server/minimal-ws-server-ring/CMakeLists.txt b/minimal-examples/ws-server/minimal-ws-server-ring/CMakeLists.txt index 78db63c4c..20bfc2e39 100644 --- a/minimal-examples/ws-server/minimal-ws-server-ring/CMakeLists.txt +++ b/minimal-examples/ws-server/minimal-ws-server-ring/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-ws-server-ring) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/ws-server/minimal-ws-server-ring/protocol_lws_minimal.c b/minimal-examples/ws-server/minimal-ws-server-ring/protocol_lws_minimal.c index 7b5106672..d8f683447 100644 --- a/minimal-examples/ws-server/minimal-ws-server-ring/protocol_lws_minimal.c +++ b/minimal-examples/ws-server/minimal-ws-server-ring/protocol_lws_minimal.c @@ -288,7 +288,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_MINIMAL }; -LWS_EXTERN LWS_VISIBLE int +int init_protocol_minimal(struct lws_context *context, struct lws_plugin_capability *c) { @@ -306,7 +306,7 @@ init_protocol_minimal(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +int destroy_protocol_minimal(struct lws_context *context) { return 0; diff --git a/minimal-examples/ws-server/minimal-ws-server-threadpool/CMakeLists.txt b/minimal-examples/ws-server/minimal-ws-server-threadpool/CMakeLists.txt index afd20c88f..00255da68 100644 --- a/minimal-examples/ws-server/minimal-ws-server-threadpool/CMakeLists.txt +++ b/minimal-examples/ws-server/minimal-ws-server-threadpool/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-ws-server-threadpool) cmake_minimum_required(VERSION 2.8) include(CheckIncludeFile) include(CheckCSourceCompiles) diff --git a/minimal-examples/ws-server/minimal-ws-server-threadpool/mount-origin/example.js b/minimal-examples/ws-server/minimal-ws-server-threadpool/mount-origin/example.js index 031eebf0f..01bdd1b5e 100644 --- a/minimal-examples/ws-server/minimal-ws-server-threadpool/mount-origin/example.js +++ b/minimal-examples/ws-server/minimal-ws-server-threadpool/mount-origin/example.js @@ -28,7 +28,7 @@ function get_appropriate_ws_url(extra_url) function new_ws(urlpath, protocol) { - if (typeof MozWebSocket != "undefined") + if (typeof MozWebSocket !== "undefined") return new MozWebSocket(urlpath, protocol); return new WebSocket(urlpath, protocol); @@ -68,7 +68,8 @@ document.addEventListener("DOMContentLoaded", function() { }; ws.onclose = function(){ - if (--alive === 0) + alive--; + if (alive === 0) document.getElementById("r").disabled = 1; }; } catch(exception) { diff --git a/minimal-examples/ws-server/minimal-ws-server-threadpool/protocol_lws_minimal_threadpool.c b/minimal-examples/ws-server/minimal-ws-server-threadpool/protocol_lws_minimal_threadpool.c index aea48e72d..9850072c4 100644 --- a/minimal-examples/ws-server/minimal-ws-server-threadpool/protocol_lws_minimal_threadpool.c +++ b/minimal-examples/ws-server/minimal-ws-server-threadpool/protocol_lws_minimal_threadpool.c @@ -317,7 +317,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_MINIMAL }; -LWS_EXTERN LWS_VISIBLE int +int init_protocol_minimal(struct lws_context *context, struct lws_plugin_capability *c) { @@ -335,7 +335,7 @@ init_protocol_minimal(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +int destroy_protocol_minimal(struct lws_context *context) { return 0; diff --git a/minimal-examples/ws-server/minimal-ws-server-threads-smp/CMakeLists.txt b/minimal-examples/ws-server/minimal-ws-server-threads-smp/CMakeLists.txt index 33434c2bf..1a97437da 100644 --- a/minimal-examples/ws-server/minimal-ws-server-threads-smp/CMakeLists.txt +++ b/minimal-examples/ws-server/minimal-ws-server-threads-smp/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-ws-server-threads-smp) cmake_minimum_required(VERSION 2.8) include(CheckIncludeFile) include(CheckCSourceCompiles) diff --git a/minimal-examples/ws-server/minimal-ws-server-threads-smp/protocol_lws_minimal.c b/minimal-examples/ws-server/minimal-ws-server-threads-smp/protocol_lws_minimal.c index 3943307b7..375530c13 100644 --- a/minimal-examples/ws-server/minimal-ws-server-threads-smp/protocol_lws_minimal.c +++ b/minimal-examples/ws-server/minimal-ws-server-threads-smp/protocol_lws_minimal.c @@ -307,7 +307,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_MINIMAL }; -LWS_EXTERN LWS_VISIBLE int +int init_protocol_minimal(struct lws_context *context, struct lws_plugin_capability *c) { @@ -325,7 +325,7 @@ init_protocol_minimal(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +int destroy_protocol_minimal(struct lws_context *context) { return 0; diff --git a/minimal-examples/ws-server/minimal-ws-server-threads/CMakeLists.txt b/minimal-examples/ws-server/minimal-ws-server-threads/CMakeLists.txt index 036dda93f..076da4fec 100644 --- a/minimal-examples/ws-server/minimal-ws-server-threads/CMakeLists.txt +++ b/minimal-examples/ws-server/minimal-ws-server-threads/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-ws-server-threads) cmake_minimum_required(VERSION 2.8) include(CheckIncludeFile) include(CheckCSourceCompiles) diff --git a/minimal-examples/ws-server/minimal-ws-server-threads/protocol_lws_minimal.c b/minimal-examples/ws-server/minimal-ws-server-threads/protocol_lws_minimal.c index 3abd727a3..f3d83dac6 100644 --- a/minimal-examples/ws-server/minimal-ws-server-threads/protocol_lws_minimal.c +++ b/minimal-examples/ws-server/minimal-ws-server-threads/protocol_lws_minimal.c @@ -300,7 +300,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_MINIMAL }; -LWS_EXTERN LWS_VISIBLE int +int init_protocol_minimal(struct lws_context *context, struct lws_plugin_capability *c) { @@ -318,7 +318,7 @@ init_protocol_minimal(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +int destroy_protocol_minimal(struct lws_context *context) { return 0; diff --git a/minimal-examples/ws-server/minimal-ws-server-timer/CMakeLists.txt b/minimal-examples/ws-server/minimal-ws-server-timer/CMakeLists.txt index acf34686d..1ad57a915 100644 --- a/minimal-examples/ws-server/minimal-ws-server-timer/CMakeLists.txt +++ b/minimal-examples/ws-server/minimal-ws-server-timer/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-ws-server-timer) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/ws-server/minimal-ws-server/CMakeLists.txt b/minimal-examples/ws-server/minimal-ws-server/CMakeLists.txt index 79d52f909..c4e2911c7 100644 --- a/minimal-examples/ws-server/minimal-ws-server/CMakeLists.txt +++ b/minimal-examples/ws-server/minimal-ws-server/CMakeLists.txt @@ -1,3 +1,4 @@ +project(lws-minimal-ws-server) cmake_minimum_required(VERSION 2.8) include(CheckCSourceCompiles) diff --git a/minimal-examples/ws-server/minimal-ws-server/protocol_lws_minimal.c b/minimal-examples/ws-server/minimal-ws-server/protocol_lws_minimal.c index 3c8160b1c..c1dd3f759 100644 --- a/minimal-examples/ws-server/minimal-ws-server/protocol_lws_minimal.c +++ b/minimal-examples/ws-server/minimal-ws-server/protocol_lws_minimal.c @@ -161,7 +161,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_MINIMAL }; -LWS_EXTERN LWS_VISIBLE int +int init_protocol_minimal(struct lws_context *context, struct lws_plugin_capability *c) { @@ -179,7 +179,7 @@ init_protocol_minimal(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +int destroy_protocol_minimal(struct lws_context *context) { return 0; diff --git a/plugins/acme-client/protocol_lws_acme_client.c b/plugins/acme-client/protocol_lws_acme_client.c index 42a19271b..c2b729544 100644 --- a/plugins/acme-client/protocol_lws_acme_client.c +++ b/plugins/acme-client/protocol_lws_acme_client.c @@ -1631,7 +1631,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_LWS_ACME_CLIENT }; -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int init_protocol_lws_acme_client(struct lws_context *context, struct lws_plugin_capability *c) { @@ -1649,7 +1649,7 @@ init_protocol_lws_acme_client(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int destroy_protocol_lws_acme_client(struct lws_context *context) { return 0; diff --git a/plugins/deaddrop/protocol_lws_deaddrop.c b/plugins/deaddrop/protocol_lws_deaddrop.c index 84a10bdc6..a55fee608 100644 --- a/plugins/deaddrop/protocol_lws_deaddrop.c +++ b/plugins/deaddrop/protocol_lws_deaddrop.c @@ -679,7 +679,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_DEADDROP }; -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int init_protocol_deaddrop(struct lws_context *context, struct lws_plugin_capability *c) { @@ -697,7 +697,7 @@ init_protocol_deaddrop(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int destroy_protocol_deaddrop(struct lws_context *context) { return 0; diff --git a/plugins/generic-sessions/handlers.c b/plugins/generic-sessions/handlers.c index 7924116ca..604841248 100644 --- a/plugins/generic-sessions/handlers.c +++ b/plugins/generic-sessions/handlers.c @@ -24,6 +24,8 @@ #include "private-lwsgs.h" +#if defined(LWS_WITH_SMTP) + static int lwsgs_smtp_client_done(struct lws_smtp_email *e, void *buf, size_t len) { @@ -55,6 +57,7 @@ lwsgs_smtp_client_done_sentvfy(struct lws_smtp_email *e, void *buf, size_t len) return 0; } +#endif /* handle account confirmation links */ @@ -407,7 +410,9 @@ lwsgs_handler_forgot_pw_form(struct per_vhost_data__gs *vhd, char esc[96], esc1[96], esc2[96], esc3[96], esc4[96]; char s[LWSGS_EMAIL_CONTENT_SIZE]; unsigned char sid_rand[32]; +#if defined(LWS_WITH_SMTP) lws_smtp_email_t *em; +#endif struct lwsgs_user u; lwsgw_hash hash; int n; @@ -489,7 +494,7 @@ lwsgs_handler_forgot_pw_form(struct per_vhost_data__gs *vhd, lws_sql_purify(esc2, u.email, sizeof(esc2) - 1), lws_sql_purify(esc3, u.username, sizeof(esc3) - 1), lws_sql_purify(esc4, pss->ip, sizeof(esc4) - 1)); - n += lws_snprintf(s + n, sizeof(s) - n, + lws_snprintf(s + n, sizeof(s) - n, "%s/lwsgs-forgot?token=%s" "&good=%s" "&bad=%s\n\n" @@ -509,6 +514,7 @@ lwsgs_handler_forgot_pw_form(struct per_vhost_data__gs *vhd, vhd->email_contact_person); puts(s); +#if defined(LWS_WITH_SMTP) em = lws_smtpc_alloc_email_helper(s, n, vhd->email_from, u.email, u.username, strlen(u.username), @@ -517,7 +523,7 @@ lwsgs_handler_forgot_pw_form(struct per_vhost_data__gs *vhd, return 1; if (lws_smtpc_add_email(vhd->smtp_client, em)) return 1; - +#endif return 0; } @@ -530,7 +536,9 @@ lwsgs_handler_register_form(struct per_vhost_data__gs *vhd, char esc[96], esc1[96], esc2[96], esc3[96], esc4[96]; char s[LWSGS_EMAIL_CONTENT_SIZE]; unsigned char sid_rand[32]; +#if defined(LWS_WITH_SMTP) lws_smtp_email_t *em; +#endif struct lwsgs_user u; lwsgw_hash hash; size_t n; @@ -636,6 +644,7 @@ lwsgs_handler_register_form(struct per_vhost_data__gs *vhd, vhd->email_confirm_url, hash.id, vhd->email_contact_person); +#if defined(LWS_WITH_SMTP) em = lws_smtpc_alloc_email_helper(s, n, vhd->email_from, lws_spa_get_string(pss->spa, FGS_EMAIL), lws_spa_get_string(pss->spa, FGS_USERNAME), @@ -646,6 +655,9 @@ lwsgs_handler_register_form(struct per_vhost_data__gs *vhd, if (lws_smtpc_add_email(vhd->smtp_client, em)) return 1; +#else + (void)n; +#endif return 0; } diff --git a/plugins/generic-sessions/protocol_generic_sessions.c b/plugins/generic-sessions/protocol_generic_sessions.c index 570eb2ca1..54cfb5976 100644 --- a/plugins/generic-sessions/protocol_generic_sessions.c +++ b/plugins/generic-sessions/protocol_generic_sessions.c @@ -142,7 +142,9 @@ callback_generic_sessions(struct lws *wsi, enum lws_callback_reasons reason, const char *cp, *cp1; sqlite3_stmt *sm; lwsgw_hash sid; +#if defined(LWS_WITH_SMTP) lws_abs_t abs; +#endif int n; switch (reason) { @@ -275,6 +277,8 @@ callback_generic_sessions(struct lws *wsi, enum lws_callback_reasons reason, return 1; } +#if defined(LWS_WITH_SMTP) + memset(&abs, 0, sizeof(abs)); abs.vh = lws_get_vhost(wsi); @@ -307,6 +311,7 @@ callback_generic_sessions(struct lws *wsi, enum lws_callback_reasons reason, return 1; lwsl_notice("%s: created SMTP client\n", __func__); +#endif break; case LWS_CALLBACK_PROTOCOL_DESTROY: @@ -315,8 +320,10 @@ callback_generic_sessions(struct lws *wsi, enum lws_callback_reasons reason, sqlite3_close(vhd->pdb); vhd->pdb = NULL; } +#if defined(LWS_WITH_SMTP) if (vhd->smtp_client) lws_abs_destroy_instance(&vhd->smtp_client); +#endif break; case LWS_CALLBACK_HTTP_WRITEABLE: @@ -366,25 +373,25 @@ callback_generic_sessions(struct lws *wsi, enum lws_callback_reasons reason, lwsgs_handler_confirm(vhd, wsi, pss); goto redirect_with_cookie; } - cp = strstr(cp, "lwsgs-check/"); - if (cp) { - lwsgs_handler_check(vhd, wsi, pss, cp + 12); + cp1 = strstr(cp, "lwsgs-check/"); + if (cp1) { + lwsgs_handler_check(vhd, wsi, pss, cp1 + 12); /* second, async part will complete transaction */ break; } - if (n >= 11 && !strcmp(cp + n - 11, "lwsgs-login")) + if (n >= 11 && cp && !strcmp(cp + n - 11, "lwsgs-login")) break; - if (n >= 12 && !strcmp(cp + n - 12, "lwsgs-logout")) + if (n >= 12 && cp && !strcmp(cp + n - 12, "lwsgs-logout")) break; - if (n >= 12 && !strcmp(cp + n - 12, "lwsgs-forgot")) + if (n >= 12 && cp && !strcmp(cp + n - 12, "lwsgs-forgot")) break; - if (n >= 12 && !strcmp(cp + n - 12, "lwsgs-change")) + if (n >= 12 && cp && !strcmp(cp + n - 12, "lwsgs-change")) break; /* if no legitimate url for GET, return 404 */ - lwsl_err("http doing 404 on %s\n", cp); + lwsl_err("%s: http doing 404 on %s\n", __func__, cp ? cp : "null"); lws_return_http_status(wsi, HTTP_STATUS_NOT_FOUND, NULL); return -1; @@ -561,8 +568,10 @@ callback_generic_sessions(struct lws *wsi, enum lws_callback_reasons reason, n = FGS_FORGOT_BAD; goto reg_done; } +#if defined(LWS_WITH_SMTP) /* get the email monitor to take a look */ lws_smtpc_kick(vhd->smtp_client); +#endif n = FGS_FORGOT_GOOD; goto reg_done; } @@ -582,9 +591,10 @@ callback_generic_sessions(struct lws *wsi, enum lws_callback_reasons reason, n = FGS_REG_BAD; else { n = FGS_REG_GOOD; - +#if defined(LWS_WITH_SMTP) /* get the email monitor to take a look */ lws_smtpc_kick(vhd->smtp_client); +#endif } reg_done: lws_snprintf(pss->onward, sizeof(pss->onward), @@ -877,7 +887,7 @@ static const struct lws_protocols protocols[] = { }, }; -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int init_protocol_generic_sessions(struct lws_context *context, struct lws_plugin_capability *c) { @@ -895,7 +905,7 @@ init_protocol_generic_sessions(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int destroy_protocol_generic_sessions(struct lws_context *context) { return 0; diff --git a/plugins/generic-sessions/protocol_lws_messageboard.c b/plugins/generic-sessions/protocol_lws_messageboard.c index 379fcc066..081d20cd2 100644 --- a/plugins/generic-sessions/protocol_lws_messageboard.c +++ b/plugins/generic-sessions/protocol_lws_messageboard.c @@ -413,7 +413,7 @@ static const struct lws_protocols protocols[] = { }, }; -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int init_protocol_lws_messageboard(struct lws_context *context, struct lws_plugin_capability *c) { @@ -431,7 +431,7 @@ init_protocol_lws_messageboard(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int destroy_protocol_lws_messageboard(struct lws_context *context) { return 0; diff --git a/plugins/generic-table/protocol_table_dirlisting.c b/plugins/generic-table/protocol_table_dirlisting.c index 22254b6f8..ef7f55785 100644 --- a/plugins/generic-table/protocol_table_dirlisting.c +++ b/plugins/generic-table/protocol_table_dirlisting.c @@ -372,7 +372,7 @@ static const struct lws_protocols protocols[] = { }, }; -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int init_protocol_lws_table_dirlisting(struct lws_context *context, struct lws_plugin_capability *c) { @@ -390,7 +390,7 @@ init_protocol_lws_table_dirlisting(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int destroy_protocol_lws_table_dirlisting(struct lws_context *context) { return 0; diff --git a/plugins/protocol_client_loopback_test.c b/plugins/protocol_client_loopback_test.c index 9a7a03193..2ccaacdb5 100644 --- a/plugins/protocol_client_loopback_test.c +++ b/plugins/protocol_client_loopback_test.c @@ -173,7 +173,7 @@ static const struct lws_protocols protocols[] = { }, }; -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int init_protocol_client_loopback_test(struct lws_context *context, struct lws_plugin_capability *c) { @@ -191,7 +191,7 @@ init_protocol_client_loopback_test(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int destroy_protocol_client_loopback_test(struct lws_context *context) { return 0; diff --git a/plugins/protocol_dumb_increment.c b/plugins/protocol_dumb_increment.c index 11d6fef02..357ba9f51 100644 --- a/plugins/protocol_dumb_increment.c +++ b/plugins/protocol_dumb_increment.c @@ -121,7 +121,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_DUMB_INCREMENT }; -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int init_protocol_dumb_increment(struct lws_context *context, struct lws_plugin_capability *c) { @@ -139,7 +139,7 @@ init_protocol_dumb_increment(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int destroy_protocol_dumb_increment(struct lws_context *context) { return 0; diff --git a/plugins/protocol_fulltext_demo.c b/plugins/protocol_fulltext_demo.c index 046fedc65..be581bfa0 100644 --- a/plugins/protocol_fulltext_demo.c +++ b/plugins/protocol_fulltext_demo.c @@ -266,7 +266,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_FULLTEXT_DEMO }; -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int init_protocol_fulltext_demo(struct lws_context *context, struct lws_plugin_capability *c) { @@ -284,7 +284,7 @@ init_protocol_fulltext_demo(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int destroy_protocol_fulltext_demo(struct lws_context *context) { return 0; diff --git a/plugins/protocol_lws_mirror.c b/plugins/protocol_lws_mirror.c index 70f501c4d..157045196 100644 --- a/plugins/protocol_lws_mirror.c +++ b/plugins/protocol_lws_mirror.c @@ -471,7 +471,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_MIRROR }; -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int init_protocol_lws_mirror(struct lws_context *context, struct lws_plugin_capability *c) { @@ -489,7 +489,7 @@ init_protocol_lws_mirror(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int destroy_protocol_lws_mirror(struct lws_context *context) { return 0; diff --git a/plugins/protocol_lws_raw_test.c b/plugins/protocol_lws_raw_test.c index 51dbe4fa4..255de8c3a 100644 --- a/plugins/protocol_lws_raw_test.c +++ b/plugins/protocol_lws_raw_test.c @@ -278,7 +278,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_RAW_TEST }; -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int init_protocol_lws_raw_test(struct lws_context *context, struct lws_plugin_capability *c) { @@ -296,7 +296,7 @@ init_protocol_lws_raw_test(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int destroy_protocol_lws_raw_test(struct lws_context *context) { return 0; diff --git a/plugins/protocol_lws_server_status.c b/plugins/protocol_lws_server_status.c index 2bed87373..0ff7ea850 100644 --- a/plugins/protocol_lws_server_status.c +++ b/plugins/protocol_lws_server_status.c @@ -209,7 +209,7 @@ static const struct lws_protocols protocols[] = { }, }; -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int init_protocol_lws_server_status(struct lws_context *context, struct lws_plugin_capability *c) { @@ -227,7 +227,7 @@ init_protocol_lws_server_status(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int destroy_protocol_lws_server_status(struct lws_context *context) { return 0; diff --git a/plugins/protocol_lws_sshd_demo.c b/plugins/protocol_lws_sshd_demo.c index 934d84b8c..e933de1b5 100644 --- a/plugins/protocol_lws_sshd_demo.c +++ b/plugins/protocol_lws_sshd_demo.c @@ -455,7 +455,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_LWS_SSHD_DEMO }; -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int init_protocol_lws_sshd_demo(struct lws_context *context, struct lws_plugin_capability *c) { @@ -473,7 +473,7 @@ init_protocol_lws_sshd_demo(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int destroy_protocol_lws_sshd_demo(struct lws_context *context) { return 0; diff --git a/plugins/protocol_lws_status.c b/plugins/protocol_lws_status.c index 8364be4a0..6d2c1fc75 100644 --- a/plugins/protocol_lws_status.c +++ b/plugins/protocol_lws_status.c @@ -244,7 +244,7 @@ static const struct lws_protocols protocols[] = { }; -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int init_protocol_lws_status(struct lws_context *context, struct lws_plugin_capability *c) { @@ -262,7 +262,7 @@ init_protocol_lws_status(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int destroy_protocol_lws_status(struct lws_context *context) { return 0; diff --git a/plugins/protocol_post_demo.c b/plugins/protocol_post_demo.c index 02503c3ae..d918ba4c3 100644 --- a/plugins/protocol_post_demo.c +++ b/plugins/protocol_post_demo.c @@ -287,7 +287,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_POST_DEMO }; -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int init_protocol_post_demo(struct lws_context *context, struct lws_plugin_capability *c) { @@ -305,7 +305,7 @@ init_protocol_post_demo(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int destroy_protocol_post_demo(struct lws_context *context) { return 0; diff --git a/plugins/raw-proxy/protocol_lws_raw_proxy.c b/plugins/raw-proxy/protocol_lws_raw_proxy.c index 26b9d33c5..6c15f3241 100644 --- a/plugins/raw-proxy/protocol_lws_raw_proxy.c +++ b/plugins/raw-proxy/protocol_lws_raw_proxy.c @@ -562,7 +562,7 @@ static const struct lws_protocols protocols[] = { LWS_PLUGIN_PROTOCOL_RAW_PROXY }; -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int init_protocol_lws_raw_proxy(struct lws_context *context, struct lws_plugin_capability *c) { @@ -580,7 +580,7 @@ init_protocol_lws_raw_proxy(struct lws_context *context, return 0; } -LWS_EXTERN LWS_VISIBLE int +LWS_VISIBLE int destroy_protocol_lws_raw_proxy(struct lws_context *context) { return 0; diff --git a/plugins/ssh-base/crypto/sc25519.c b/plugins/ssh-base/crypto/sc25519.c index fdb5a8065..7983d8e6c 100644 --- a/plugins/ssh-base/crypto/sc25519.c +++ b/plugins/ssh-base/crypto/sc25519.c @@ -68,8 +68,8 @@ static void barrett_reduce(sc25519 *r, const uint32_t x[64]) if(i+j >= 31) q2[i+j] += mu[i]*x[j+31]; carry = q2[31] >> 8; q2[32] += carry; - carry = q2[32] >> 8; - q2[33] += carry; + //carry = q2[32] >> 8; + //q2[33] += carry; for(i=0;i<33;i++)r1[i] = x[i]; for(i=0;i<32;i++) diff --git a/plugins/ssh-base/sshd.c b/plugins/ssh-base/sshd.c index 3cb45cbea..1b78019d8 100644 --- a/plugins/ssh-base/sshd.c +++ b/plugins/ssh-base/sshd.c @@ -2558,7 +2558,7 @@ bail: 1024, 0, NULL, 900 \ } -LWS_VISIBLE const struct lws_protocols protocols_sshd[] = { +const struct lws_protocols protocols_sshd[] = { LWS_PLUGIN_PROTOCOL_LWS_RAW_SSHD, { NULL, NULL, 0, 0, 0, NULL, 0 } /* terminator */ };