1d4afb5ceSopenharmony_ci/* 2d4afb5ceSopenharmony_ci * libwebsockets - small server side websockets and web server implementation 3d4afb5ceSopenharmony_ci * 4d4afb5ceSopenharmony_ci * Copyright (C) 2019 - 2020 Andy Green <andy@warmcat.com> 5d4afb5ceSopenharmony_ci * 6d4afb5ceSopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy 7d4afb5ceSopenharmony_ci * of this software and associated documentation files (the "Software"), to 8d4afb5ceSopenharmony_ci * deal in the Software without restriction, including without limitation the 9d4afb5ceSopenharmony_ci * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10d4afb5ceSopenharmony_ci * sell copies of the Software, and to permit persons to whom the Software is 11d4afb5ceSopenharmony_ci * furnished to do so, subject to the following conditions: 12d4afb5ceSopenharmony_ci * 13d4afb5ceSopenharmony_ci * The above copyright notice and this permission notice shall be included in 14d4afb5ceSopenharmony_ci * all copies or substantial portions of the Software. 15d4afb5ceSopenharmony_ci * 16d4afb5ceSopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17d4afb5ceSopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18d4afb5ceSopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19d4afb5ceSopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20d4afb5ceSopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21d4afb5ceSopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22d4afb5ceSopenharmony_ci * IN THE SOFTWARE. 23d4afb5ceSopenharmony_ci * 24d4afb5ceSopenharmony_ci * This is the headers for secure stream api variants that deal with clients in 25d4afb5ceSopenharmony_ci * different threads or even different processes. 26d4afb5ceSopenharmony_ci * 27d4afb5ceSopenharmony_ci * lws_ss_ when client is directly using the event loop 28d4afb5ceSopenharmony_ci * lws_sstc_ when client is in a different thread to the event loop 29d4afb5ceSopenharmony_ci * lws_sspc_ when client is in a different process to the event loop 30d4afb5ceSopenharmony_ci * 31d4afb5ceSopenharmony_ci * The client api is almost the same except the slightly diffent names. 32d4afb5ceSopenharmony_ci */ 33d4afb5ceSopenharmony_ci 34d4afb5ceSopenharmony_ci/* 35d4afb5ceSopenharmony_ci * lws_sspc_ apis... different process 36d4afb5ceSopenharmony_ci */ 37d4afb5ceSopenharmony_ci 38d4afb5ceSopenharmony_ci/* 39d4afb5ceSopenharmony_ci * Helper translation so user code written to lws_ss_ can be built for 40d4afb5ceSopenharmony_ci * lws_sspc_ in one step by #define LWS_SS_USE_SSPC before including 41d4afb5ceSopenharmony_ci */ 42d4afb5ceSopenharmony_ci 43d4afb5ceSopenharmony_cistruct lws_sspc_handle; 44d4afb5ceSopenharmony_ci 45d4afb5ceSopenharmony_ci#if defined(LWS_SS_USE_SSPC) 46d4afb5ceSopenharmony_ci#define lws_ss_handle lws_sspc_handle 47d4afb5ceSopenharmony_ci#define lws_ss_create lws_sspc_create 48d4afb5ceSopenharmony_ci#define lws_ss_destroy lws_sspc_destroy 49d4afb5ceSopenharmony_ci#define lws_ss_request_tx lws_sspc_request_tx 50d4afb5ceSopenharmony_ci#define lws_ss_request_tx_len lws_sspc_request_tx_len 51d4afb5ceSopenharmony_ci#define lws_ss_client_connect lws_sspc_client_connect 52d4afb5ceSopenharmony_ci#define lws_ss_get_sequencer lws_sspc_get_sequencer 53d4afb5ceSopenharmony_ci#define lws_ss_proxy_create lws_sspc_proxy_create 54d4afb5ceSopenharmony_ci#define lws_ss_get_context lws_sspc_get_context 55d4afb5ceSopenharmony_ci#define lws_ss_rideshare lws_sspc_rideshare 56d4afb5ceSopenharmony_ci#define lws_ss_set_metadata lws_sspc_set_metadata 57d4afb5ceSopenharmony_ci#define lws_ss_get_metadata lws_sspc_get_metadata 58d4afb5ceSopenharmony_ci#define lws_ss_add_peer_tx_credit lws_sspc_add_peer_tx_credit 59d4afb5ceSopenharmony_ci#define lws_ss_get_est_peer_tx_credit lws_sspc_get_est_peer_tx_credit 60d4afb5ceSopenharmony_ci#define lws_ss_start_timeout lws_sspc_start_timeout 61d4afb5ceSopenharmony_ci#define lws_ss_cancel_timeout lws_sspc_cancel_timeout 62d4afb5ceSopenharmony_ci#define lws_ss_to_user_object lws_sspc_to_user_object 63d4afb5ceSopenharmony_ci#define lws_ss_change_handlers lws_sspc_change_handlers 64d4afb5ceSopenharmony_ci#define lws_smd_ss_rx_forward lws_smd_sspc_rx_forward 65d4afb5ceSopenharmony_ci#define lws_ss_tag lws_sspc_tag 66d4afb5ceSopenharmony_ci#define _lws_fi_user_ss_fi _lws_fi_user_sspc_fi 67d4afb5ceSopenharmony_ci#define lwsl_ss_get_cx lwsl_sspc_get_cx 68d4afb5ceSopenharmony_ci 69d4afb5ceSopenharmony_ciLWS_VISIBLE LWS_EXTERN void 70d4afb5ceSopenharmony_cilws_log_prepend_sspc(struct lws_log_cx *cx, void *obj, char **p, char *e); 71d4afb5ceSopenharmony_ci 72d4afb5ceSopenharmony_ciLWS_VISIBLE LWS_EXTERN struct lws_log_cx * 73d4afb5ceSopenharmony_cilwsl_sspc_get_cx(struct lws_sspc_handle *ss); 74d4afb5ceSopenharmony_ci 75d4afb5ceSopenharmony_ci#undef lwsl_ss 76d4afb5ceSopenharmony_ci#define lwsl_ss lwsl_sspc 77d4afb5ceSopenharmony_ci 78d4afb5ceSopenharmony_ci#undef lwsl_hexdump_ss 79d4afb5ceSopenharmony_ci#define lwsl_hexdump_ss lwsl_hexdump_sspc 80d4afb5ceSopenharmony_ci#endif 81d4afb5ceSopenharmony_ci 82d4afb5ceSopenharmony_ci#define lwsl_sspc(_h, _fil, ...) \ 83d4afb5ceSopenharmony_ci _lws_log_cx(lwsl_sspc_get_cx(_h), lws_log_prepend_sspc, _h, \ 84d4afb5ceSopenharmony_ci _fil, __func__, __VA_ARGS__) 85d4afb5ceSopenharmony_ci 86d4afb5ceSopenharmony_ci#define lwsl_hexdump_sspc(_h, _fil, _buf, _len) \ 87d4afb5ceSopenharmony_ci lwsl_hexdump_level_cx(lwsl_sspc_get_cx(_h), \ 88d4afb5ceSopenharmony_ci lws_log_prepend_sspc, \ 89d4afb5ceSopenharmony_ci _h, _fil, _buf, _len) 90d4afb5ceSopenharmony_ci 91d4afb5ceSopenharmony_ci/* 92d4afb5ceSopenharmony_ci * lwsl_sspc 93d4afb5ceSopenharmony_ci */ 94d4afb5ceSopenharmony_ci 95d4afb5ceSopenharmony_ci#if (_LWS_ENABLED_LOGS & LLL_ERR) 96d4afb5ceSopenharmony_ci#define lwsl_sspc_err(_w, ...) lwsl_sspc(_w, LLL_ERR, __VA_ARGS__) 97d4afb5ceSopenharmony_ci#else 98d4afb5ceSopenharmony_ci#define lwsl_sspc_err(_w, ...) do {} while(0) 99d4afb5ceSopenharmony_ci#endif 100d4afb5ceSopenharmony_ci 101d4afb5ceSopenharmony_ci#if (_LWS_ENABLED_LOGS & LLL_WARN) 102d4afb5ceSopenharmony_ci#define lwsl_sspc_warn(_w, ...) lwsl_sspc(_w, LLL_WARN, __VA_ARGS__) 103d4afb5ceSopenharmony_ci#else 104d4afb5ceSopenharmony_ci#define lwsl_sspc_warn(_w, ...) do {} while(0) 105d4afb5ceSopenharmony_ci#endif 106d4afb5ceSopenharmony_ci 107d4afb5ceSopenharmony_ci#if (_LWS_ENABLED_LOGS & LLL_NOTICE) 108d4afb5ceSopenharmony_ci#define lwsl_sspc_notice(_w, ...) lwsl_sspc(_w, LLL_NOTICE, __VA_ARGS__) 109d4afb5ceSopenharmony_ci#else 110d4afb5ceSopenharmony_ci#define lwsl_sspc_notice(_w, ...) do {} while(0) 111d4afb5ceSopenharmony_ci#endif 112d4afb5ceSopenharmony_ci 113d4afb5ceSopenharmony_ci#if (_LWS_ENABLED_LOGS & LLL_INFO) 114d4afb5ceSopenharmony_ci#define lwsl_sspc_info(_w, ...) lwsl_sspc(_w, LLL_INFO, __VA_ARGS__) 115d4afb5ceSopenharmony_ci#else 116d4afb5ceSopenharmony_ci#define lwsl_sspc_info(_w, ...) do {} while(0) 117d4afb5ceSopenharmony_ci#endif 118d4afb5ceSopenharmony_ci 119d4afb5ceSopenharmony_ci#if (_LWS_ENABLED_LOGS & LLL_DEBUG) 120d4afb5ceSopenharmony_ci#define lwsl_sspc_debug(_w, ...) lwsl_sspc(_w, LLL_DEBUG, __VA_ARGS__) 121d4afb5ceSopenharmony_ci#else 122d4afb5ceSopenharmony_ci#define lwsl_sspc_debug(_w, ...) do {} while(0) 123d4afb5ceSopenharmony_ci#endif 124d4afb5ceSopenharmony_ci 125d4afb5ceSopenharmony_ci#if (_LWS_ENABLED_LOGS & LLL_PARSER) 126d4afb5ceSopenharmony_ci#define lwsl_sspc_parser(_w, ...) lwsl_sspc(_w, LLL_PARSER, __VA_ARGS__) 127d4afb5ceSopenharmony_ci#else 128d4afb5ceSopenharmony_ci#define lwsl_sspc_parser(_w, ...) do {} while(0) 129d4afb5ceSopenharmony_ci#endif 130d4afb5ceSopenharmony_ci 131d4afb5ceSopenharmony_ci#if (_LWS_ENABLED_LOGS & LLL_HEADER) 132d4afb5ceSopenharmony_ci#define lwsl_sspc_header(_w, ...) lwsl_sspc(_w, LLL_HEADER, __VA_ARGS__) 133d4afb5ceSopenharmony_ci#else 134d4afb5ceSopenharmony_ci#define lwsl_sspc_header(_w, ...) do {} while(0) 135d4afb5ceSopenharmony_ci#endif 136d4afb5ceSopenharmony_ci 137d4afb5ceSopenharmony_ci#if (_LWS_ENABLED_LOGS & LLL_EXT) 138d4afb5ceSopenharmony_ci#define lwsl_sspc_ext(_w, ...) lwsl_sspc(_w, LLL_EXT, __VA_ARGS__) 139d4afb5ceSopenharmony_ci#else 140d4afb5ceSopenharmony_ci#define lwsl_sspc_ext(_w, ...) do {} while(0) 141d4afb5ceSopenharmony_ci#endif 142d4afb5ceSopenharmony_ci 143d4afb5ceSopenharmony_ci#if (_LWS_ENABLED_LOGS & LLL_CLIENT) 144d4afb5ceSopenharmony_ci#define lwsl_sspc_client(_w, ...) lwsl_sspc(_w, LLL_CLIENT, __VA_ARGS__) 145d4afb5ceSopenharmony_ci#else 146d4afb5ceSopenharmony_ci#define lwsl_sspc_client(_w, ...) do {} while(0) 147d4afb5ceSopenharmony_ci#endif 148d4afb5ceSopenharmony_ci 149d4afb5ceSopenharmony_ci#if (_LWS_ENABLED_LOGS & LLL_LATENCY) 150d4afb5ceSopenharmony_ci#define lwsl_sspc_latency(_w, ...) lwsl_sspc(_w, LLL_LATENCY, __VA_ARGS__) 151d4afb5ceSopenharmony_ci#else 152d4afb5ceSopenharmony_ci#define lwsl_sspc_latency(_w, ...) do {} while(0) 153d4afb5ceSopenharmony_ci#endif 154d4afb5ceSopenharmony_ci 155d4afb5ceSopenharmony_ci#if (_LWS_ENABLED_LOGS & LLL_THREAD) 156d4afb5ceSopenharmony_ci#define lwsl_sspc_thread(_w, ...) lwsl_sspc(_w, LLL_THREAD, __VA_ARGS__) 157d4afb5ceSopenharmony_ci#else 158d4afb5ceSopenharmony_ci#define lwsl_sspc_thread(_w, ...) do {} while(0) 159d4afb5ceSopenharmony_ci#endif 160d4afb5ceSopenharmony_ci 161d4afb5ceSopenharmony_ci#if (_LWS_ENABLED_LOGS & LLL_USER) 162d4afb5ceSopenharmony_ci#define lwsl_sspc_user(_w, ...) lwsl_sspc(_w, LLL_USER, __VA_ARGS__) 163d4afb5ceSopenharmony_ci#else 164d4afb5ceSopenharmony_ci#define lwsl_sspc_user(_w, ...) do {} while(0) 165d4afb5ceSopenharmony_ci#endif 166d4afb5ceSopenharmony_ci 167d4afb5ceSopenharmony_ci#define lwsl_hexdump_sspc_err(_v, ...) lwsl_hexdump_sspc(_v, LLL_ERR, __VA_ARGS__) 168d4afb5ceSopenharmony_ci#define lwsl_hexdump_sspc_warn(_v, ...) lwsl_hexdump_sspc(_v, LLL_WARN, __VA_ARGS__) 169d4afb5ceSopenharmony_ci#define lwsl_hexdump_sspc_notice(_v, ...) lwsl_hexdump_sspc(_v, LLL_NOTICE, __VA_ARGS__) 170d4afb5ceSopenharmony_ci#define lwsl_hexdump_sspc_info(_v, ...) lwsl_hexdump_sspc(_v, LLL_INFO, __VA_ARGS__) 171d4afb5ceSopenharmony_ci#define lwsl_hexdump_sspc_debug(_v, ...) lwsl_hexdump_sspc(_v, LLL_DEBUG, __VA_ARGS__) 172d4afb5ceSopenharmony_ci 173d4afb5ceSopenharmony_ci 174d4afb5ceSopenharmony_ciLWS_VISIBLE LWS_EXTERN int 175d4afb5ceSopenharmony_cilws_sspc_create(struct lws_context *context, int tsi, const lws_ss_info_t *ssi, 176d4afb5ceSopenharmony_ci void *opaque_user_data, struct lws_sspc_handle **ppss, 177d4afb5ceSopenharmony_ci struct lws_sequencer *seq_owner, const char **ppayload_fmt); 178d4afb5ceSopenharmony_ci 179d4afb5ceSopenharmony_ci/** 180d4afb5ceSopenharmony_ci * lws_sspc_destroy() - Destroy secure stream 181d4afb5ceSopenharmony_ci * 182d4afb5ceSopenharmony_ci * \param ppss: pointer to lws_ss_t pointer to be destroyed 183d4afb5ceSopenharmony_ci * 184d4afb5ceSopenharmony_ci * Destroys the lws_ss_t pointed to by *ppss, and sets *ppss to NULL. 185d4afb5ceSopenharmony_ci */ 186d4afb5ceSopenharmony_ciLWS_VISIBLE LWS_EXTERN void 187d4afb5ceSopenharmony_cilws_sspc_destroy(struct lws_sspc_handle **ppss); 188d4afb5ceSopenharmony_ci 189d4afb5ceSopenharmony_ci/** 190d4afb5ceSopenharmony_ci * lws_sspc_request_tx() - Schedule stream for tx 191d4afb5ceSopenharmony_ci * 192d4afb5ceSopenharmony_ci * \param pss: pointer to lws_ss_t representing stream that wants to transmit 193d4afb5ceSopenharmony_ci * 194d4afb5ceSopenharmony_ci * Schedules a write on the stream represented by \p pss. When it's possible to 195d4afb5ceSopenharmony_ci * write on this stream, the *tx callback will occur with an empty buffer for 196d4afb5ceSopenharmony_ci * the stream owner to fill in. 197d4afb5ceSopenharmony_ci */ 198d4afb5ceSopenharmony_ciLWS_VISIBLE LWS_EXTERN lws_ss_state_return_t 199d4afb5ceSopenharmony_cilws_sspc_request_tx(struct lws_sspc_handle *pss); 200d4afb5ceSopenharmony_ci 201d4afb5ceSopenharmony_ci/** 202d4afb5ceSopenharmony_ci * lws_sspc_request_tx_len() - Schedule stream for tx with length hint 203d4afb5ceSopenharmony_ci * 204d4afb5ceSopenharmony_ci * \param h: pointer to handle representing stream that wants to transmit 205d4afb5ceSopenharmony_ci * \param len: the length of the write in bytes 206d4afb5ceSopenharmony_ci * 207d4afb5ceSopenharmony_ci * Schedules a write on the stream represented by \p pss. When it's possible to 208d4afb5ceSopenharmony_ci * write on this stream, the *tx callback will occur with an empty buffer for 209d4afb5ceSopenharmony_ci * the stream owner to fill in. 210d4afb5ceSopenharmony_ci * 211d4afb5ceSopenharmony_ci * This api variant should be used when it's possible the payload will go out 212d4afb5ceSopenharmony_ci * over h1 with x-web-form-urlencoded or similar Content-Type. 213d4afb5ceSopenharmony_ci * 214d4afb5ceSopenharmony_ci * The serialized, sspc type api actually serializes and forwards the length 215d4afb5ceSopenharmony_ci * hint to its upstream proxy, where it's available for use to produce the 216d4afb5ceSopenharmony_ci * internet-capable protocol framing. 217d4afb5ceSopenharmony_ci */ 218d4afb5ceSopenharmony_ciLWS_VISIBLE LWS_EXTERN lws_ss_state_return_t 219d4afb5ceSopenharmony_cilws_sspc_request_tx_len(struct lws_sspc_handle *h, unsigned long len); 220d4afb5ceSopenharmony_ci 221d4afb5ceSopenharmony_ci/** 222d4afb5ceSopenharmony_ci * lws_sspc_client_connect() - Attempt the client connect 223d4afb5ceSopenharmony_ci * 224d4afb5ceSopenharmony_ci * \param h: secure streams handle 225d4afb5ceSopenharmony_ci * 226d4afb5ceSopenharmony_ci * Starts the connection process for the secure stream. Returns 0. 227d4afb5ceSopenharmony_ci */ 228d4afb5ceSopenharmony_ciLWS_VISIBLE LWS_EXTERN lws_ss_state_return_t 229d4afb5ceSopenharmony_cilws_sspc_client_connect(struct lws_sspc_handle *h); 230d4afb5ceSopenharmony_ci 231d4afb5ceSopenharmony_ci/** 232d4afb5ceSopenharmony_ci * lws_sspc_get_sequencer() - Return parent sequencer pointer if any 233d4afb5ceSopenharmony_ci * 234d4afb5ceSopenharmony_ci * \param h: secure streams handle 235d4afb5ceSopenharmony_ci * 236d4afb5ceSopenharmony_ci * Returns NULL if the secure stream is not associated with a sequencer. 237d4afb5ceSopenharmony_ci * Otherwise returns a pointer to the owning sequencer. You can use this to 238d4afb5ceSopenharmony_ci * identify which sequencer to direct messages to, from the secure stream 239d4afb5ceSopenharmony_ci * callback. 240d4afb5ceSopenharmony_ci */ 241d4afb5ceSopenharmony_ciLWS_VISIBLE LWS_EXTERN struct lws_sequencer * 242d4afb5ceSopenharmony_cilws_sspc_get_sequencer(struct lws_sspc_handle *h); 243d4afb5ceSopenharmony_ci 244d4afb5ceSopenharmony_ci/** 245d4afb5ceSopenharmony_ci * lws_sspc_proxy_create() - Start a unix domain socket proxy for Secure Streams 246d4afb5ceSopenharmony_ci * 247d4afb5ceSopenharmony_ci * \param context: lws_context 248d4afb5ceSopenharmony_ci * 249d4afb5ceSopenharmony_ci * Creates a vhost that listens on an abstract namespace unix domain socket at 250d4afb5ceSopenharmony_ci * address "proxy.ss.lws". Client connections to this proxy to Secure Streams 251d4afb5ceSopenharmony_ci */ 252d4afb5ceSopenharmony_ciLWS_VISIBLE LWS_EXTERN int 253d4afb5ceSopenharmony_cilws_sspc_proxy_create(struct lws_context *context); 254d4afb5ceSopenharmony_ci 255d4afb5ceSopenharmony_ci/** 256d4afb5ceSopenharmony_ci * lws_ss_get_context() - convenience helper to recover the lws context 257d4afb5ceSopenharmony_ci * 258d4afb5ceSopenharmony_ci * \h: secure streams handle 259d4afb5ceSopenharmony_ci * 260d4afb5ceSopenharmony_ci * Returns the lws context. Dispenses with the need to pass a copy of it into 261d4afb5ceSopenharmony_ci * your secure streams handler. 262d4afb5ceSopenharmony_ci */ 263d4afb5ceSopenharmony_ci 264d4afb5ceSopenharmony_ciLWS_VISIBLE LWS_EXTERN struct lws_context * 265d4afb5ceSopenharmony_cilws_sspc_get_context(struct lws_sspc_handle *h); 266d4afb5ceSopenharmony_ci 267d4afb5ceSopenharmony_ciLWS_VISIBLE extern const struct lws_protocols lws_sspc_protocols[2]; 268d4afb5ceSopenharmony_ci 269d4afb5ceSopenharmony_ciLWS_VISIBLE LWS_EXTERN const char * 270d4afb5ceSopenharmony_cilws_sspc_rideshare(struct lws_sspc_handle *h); 271d4afb5ceSopenharmony_ci 272d4afb5ceSopenharmony_ci 273d4afb5ceSopenharmony_ci/** 274d4afb5ceSopenharmony_ci * lws_sspc_set_metadata() - allow user to bind external data to defined ss metadata 275d4afb5ceSopenharmony_ci * 276d4afb5ceSopenharmony_ci * \h: secure streams handle 277d4afb5ceSopenharmony_ci * \name: metadata name from the policy 278d4afb5ceSopenharmony_ci * \value: pointer to user-managed data to bind to name 279d4afb5ceSopenharmony_ci * \len: length of the user-managed data in value 280d4afb5ceSopenharmony_ci * 281d4afb5ceSopenharmony_ci * Binds user-managed data to the named metadata item from the ss policy. 282d4afb5ceSopenharmony_ci * If present, the metadata item is handled in a protocol-specific way using 283d4afb5ceSopenharmony_ci * the associated policy information. For example, in the policy 284d4afb5ceSopenharmony_ci * 285d4afb5ceSopenharmony_ci * "\"metadata\":" "[" 286d4afb5ceSopenharmony_ci * "{\"uptag\":" "\"X-Upload-Tag:\"}," 287d4afb5ceSopenharmony_ci * "{\"ctype\":" "\"Content-Type:\"}," 288d4afb5ceSopenharmony_ci * "{\"xctype\":" "\"X-Content-Type:\"}" 289d4afb5ceSopenharmony_ci * "]," 290d4afb5ceSopenharmony_ci * 291d4afb5ceSopenharmony_ci * when the policy is using h1 is interpreted to add h1 headers of the given 292d4afb5ceSopenharmony_ci * name with the value of the metadata on the left. 293d4afb5ceSopenharmony_ci * 294d4afb5ceSopenharmony_ci * Return 0 if OK, or nonzero if failed. 295d4afb5ceSopenharmony_ci */ 296d4afb5ceSopenharmony_ciLWS_VISIBLE LWS_EXTERN int 297d4afb5ceSopenharmony_cilws_sspc_set_metadata(struct lws_sspc_handle *h, const char *name, 298d4afb5ceSopenharmony_ci const void *value, size_t len); 299d4afb5ceSopenharmony_ci 300d4afb5ceSopenharmony_ciLWS_VISIBLE LWS_EXTERN int 301d4afb5ceSopenharmony_cilws_sspc_get_metadata(struct lws_sspc_handle *h, const char *name, 302d4afb5ceSopenharmony_ci const void **value, size_t *len); 303d4afb5ceSopenharmony_ci 304d4afb5ceSopenharmony_ciLWS_VISIBLE LWS_EXTERN int 305d4afb5ceSopenharmony_cilws_sspc_add_peer_tx_credit(struct lws_sspc_handle *h, int32_t add); 306d4afb5ceSopenharmony_ci 307d4afb5ceSopenharmony_ciLWS_VISIBLE LWS_EXTERN int 308d4afb5ceSopenharmony_cilws_sspc_get_est_peer_tx_credit(struct lws_sspc_handle *h); 309d4afb5ceSopenharmony_ci 310d4afb5ceSopenharmony_ciLWS_VISIBLE LWS_EXTERN void 311d4afb5ceSopenharmony_cilws_sspc_start_timeout(struct lws_sspc_handle *h, unsigned int timeout_ms); 312d4afb5ceSopenharmony_ci 313d4afb5ceSopenharmony_ciLWS_VISIBLE LWS_EXTERN void 314d4afb5ceSopenharmony_cilws_sspc_cancel_timeout(struct lws_sspc_handle *h); 315d4afb5ceSopenharmony_ci 316d4afb5ceSopenharmony_ciLWS_VISIBLE LWS_EXTERN void * 317d4afb5ceSopenharmony_cilws_sspc_to_user_object(struct lws_sspc_handle *h); 318d4afb5ceSopenharmony_ci 319d4afb5ceSopenharmony_ciLWS_VISIBLE LWS_EXTERN void 320d4afb5ceSopenharmony_cilws_sspc_change_handlers(struct lws_sspc_handle *h, 321d4afb5ceSopenharmony_ci lws_ss_state_return_t (*rx)(void *userobj, const uint8_t *buf, 322d4afb5ceSopenharmony_ci size_t len, int flags), 323d4afb5ceSopenharmony_ci lws_ss_state_return_t (*tx)(void *userobj, lws_ss_tx_ordinal_t ord, 324d4afb5ceSopenharmony_ci uint8_t *buf, size_t *len, int *flags), 325d4afb5ceSopenharmony_ci lws_ss_state_return_t (*state)(void *userobj, void *h_src 326d4afb5ceSopenharmony_ci /* ss handle type */, 327d4afb5ceSopenharmony_ci lws_ss_constate_t state, 328d4afb5ceSopenharmony_ci lws_ss_tx_ordinal_t ack)); 329d4afb5ceSopenharmony_ci 330d4afb5ceSopenharmony_ciconst char * 331d4afb5ceSopenharmony_cilws_sspc_tag(struct lws_sspc_handle *h); 332