mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-30 00:00:16 +01:00

This is a NOP for existing usecases. At the moment the only implemented transport for serialized SS is wsi, it's typically used with Unix Domain Sockets, but it also works over tcp the same. It generalizes the interface between serialized chunks and the transport, separately for client and proxy. The wsi transport is migrated to use the new transport ops structs. It will then be possible to "bring your own transport", so long as it is reliable, and in-order, both for proxy and client / sspc. We also adapt minimal-secure-streams-binance to build the -client variant via SS proxy as well. LWS_ONLY_SSPC is added so libwebsockets can be produced with just sspc client support even for tiny targets. A new embedded minimal example for rpi pico is also provided that demonstrates using Serialized SS over a UART to an SS proxy, to implement the SS Binance example on the pico, even though it has no networking itself.
38 lines
1.3 KiB
C
38 lines
1.3 KiB
C
/*
|
|
* lws-minimal-secure-streams-custom-proxy-transport
|
|
*
|
|
* Written in 2010-2021 by Andy Green <andy@warmcat.com>
|
|
* Kutoga <kutoga@user.github.invalid>
|
|
*
|
|
* This file is made available under the Creative Commons CC0 1.0
|
|
* Universal Public Domain Dedication.
|
|
*/
|
|
|
|
#define LWS_SS_USE_SSPC
|
|
#include <libwebsockets.h>
|
|
|
|
#define MAX_CUSTOM_POLLFDS 10
|
|
|
|
typedef struct custom_poll_ctx {
|
|
struct pollfd pollfds[MAX_CUSTOM_POLLFDS];
|
|
void *priv[MAX_CUSTOM_POLLFDS];
|
|
int count_pollfds;
|
|
struct lws_dll2_owner scheduler;
|
|
lws_transport_mux_t *tm;
|
|
} custom_poll_ctx_t;
|
|
|
|
extern custom_poll_ctx_t a_cpcx;
|
|
extern int interrupted, transport_fd, log_level;
|
|
|
|
extern const lws_transport_client_ops_t lws_sss_ops_client_serial;
|
|
extern const lws_ss_info_t ssi_binance;
|
|
extern int open_transport_file(custom_poll_ctx_t *cpcx, const char *filepath, void *priv);
|
|
|
|
extern int custom_poll_add_fd(custom_poll_ctx_t *cpcx, lws_sockfd_type fd,
|
|
int events, void *priv);
|
|
extern int custom_poll_del_fd(custom_poll_ctx_t *cpcx, lws_sockfd_type fd);
|
|
|
|
extern int custom_poll_change_fd(custom_poll_ctx_t *cpcx, lws_sockfd_type fd,
|
|
int events_add, int events_remove);
|
|
extern int custom_poll_run(custom_poll_ctx_t *cpcx);
|
|
extern int custom_transport_event(struct pollfd *pfd, void *priv);
|