mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
cleaning
This commit is contained in:
parent
7dcb4eeaa6
commit
0bfd39135e
209 changed files with 810 additions and 604 deletions
|
@ -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}")
|
||||
|
|
27
README.md
27
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.
|
||||
|
||||

|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "private-lib-tls-mbedtls.h"
|
||||
#include <mbedtls/rsa.h>
|
||||
|
||||
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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 */
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 */
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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++;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
project(lws-api-test-smtp_client)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
include(CheckCSourceCompiles)
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
project(lws-api-test-async-dns)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
include(CheckCSourceCompiles)
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
project(lws-api-test-dhcpc)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
include(CheckCSourceCompiles)
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
project(lws-api-test-fts)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
include(CheckCSourceCompiles)
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
project(lws-api-test-gencrypto)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
include(CheckCSourceCompiles)
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
project(lws-api-test-jose)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
include(CheckCSourceCompiles)
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
project(lws-api-test-lws_dsh)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
include(CheckCSourceCompiles)
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
project(lws-api-test-lws_sequencer)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
include(CheckCSourceCompiles)
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
project(lws-api-test-lws_struct-json)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
include(CheckCSourceCompiles)
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
project(lws-api-test-lws_tokenize)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
include(CheckCSourceCompiles)
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
project(lws-api-test-lwsac)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
include(CheckCSourceCompiles)
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue