libwebsockets
Lightweight C library for HTML5 websockets
lws-secure-streams-client.h
1 /*
2  * libwebsockets - small server side websockets and web server implementation
3  *
4  * Copyright (C) 2019 - 2020 Andy Green <andy@warmcat.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22  * IN THE SOFTWARE.
23  *
24  * This is the headers for secure stream api variants that deal with clients in
25  * different threads or even different processes.
26  *
27  * lws_ss_ when client is directly using the event loop
28  * lws_sstc_ when client is in a different thread to the event loop
29  * lws_sspc_ when client is in a different process to the event loop
30  *
31  * The client api is almost the same except the slightly diffent names.
32  */
33 
34 /*
35  * lws_sspc_ apis... different process
36  */
37 
38 /*
39  * Helper translation so user code written to lws_ss_ can be built for
40  * lws_sspc_ in one step by #define LWS_SS_USE_SSPC before including
41  */
42 
43 #if defined(LWS_SS_USE_SSPC)
44 #define lws_ss_handle lws_sspc_handle
45 #define lws_ss_create lws_sspc_create
46 #define lws_ss_destroy lws_sspc_destroy
47 #define lws_ss_request_tx lws_sspc_request_tx
48 #define lws_ss_request_tx_len lws_sspc_request_tx_len
49 #define lws_ss_client_connect lws_sspc_client_connect
50 #define lws_ss_get_sequencer lws_sspc_get_sequencer
51 #define lws_ss_proxy_create lws_sspc_proxy_create
52 #define lws_ss_get_context lws_sspc_get_context
53 #define lws_ss_rideshare lws_sspc_rideshare
54 #define lws_ss_set_metadata lws_sspc_set_metadata
55 #define lws_ss_get_metadata lws_sspc_get_metadata
56 #define lws_ss_add_peer_tx_credit lws_sspc_add_peer_tx_credit
57 #define lws_ss_get_est_peer_tx_credit lws_sspc_get_est_peer_tx_credit
58 #define lws_ss_start_timeout lws_sspc_start_timeout
59 #define lws_ss_cancel_timeout lws_sspc_cancel_timeout
60 #define lws_ss_to_user_object lws_sspc_to_user_object
61 #define lws_ss_change_handlers lws_sspc_change_handlers
62 #define lws_smd_ss_rx_forward lws_smd_sspc_rx_forward
63 #define lws_ss_tag lws_sspc_tag
64 #define _lws_fi_user_ss_fi _lws_fi_user_sspc_fi
65 #endif
66 
67 
68 struct lws_sspc_handle;
69 
70 LWS_VISIBLE LWS_EXTERN int
71 lws_sspc_create(struct lws_context *context, int tsi, const lws_ss_info_t *ssi,
72  void *opaque_user_data, struct lws_sspc_handle **ppss,
73  struct lws_sequencer *seq_owner, const char **ppayload_fmt);
74 
82 LWS_VISIBLE LWS_EXTERN void
83 lws_sspc_destroy(struct lws_sspc_handle **ppss);
84 
94 LWS_VISIBLE LWS_EXTERN lws_ss_state_return_t
95 lws_sspc_request_tx(struct lws_sspc_handle *pss);
96 
114 LWS_VISIBLE LWS_EXTERN lws_ss_state_return_t
115 lws_sspc_request_tx_len(struct lws_sspc_handle *h, unsigned long len);
116 
125 LWS_VISIBLE LWS_EXTERN lws_ss_state_return_t
126 lws_sspc_client_connect(struct lws_sspc_handle *h);
127 
138 LWS_VISIBLE LWS_EXTERN struct lws_sequencer *
139 lws_sspc_get_sequencer(struct lws_sspc_handle *h);
140 
149 LWS_VISIBLE LWS_EXTERN int
150 lws_sspc_proxy_create(struct lws_context *context);
151 
161 LWS_VISIBLE LWS_EXTERN struct lws_context *
162 lws_sspc_get_context(struct lws_sspc_handle *h);
163 
164 LWS_VISIBLE extern const struct lws_protocols lws_sspc_protocols[2];
165 
166 LWS_VISIBLE LWS_EXTERN const char *
167 lws_sspc_rideshare(struct lws_sspc_handle *h);
168 
169 
193 LWS_VISIBLE LWS_EXTERN int
194 lws_sspc_set_metadata(struct lws_sspc_handle *h, const char *name,
195  const void *value, size_t len);
196 
197 LWS_VISIBLE LWS_EXTERN int
198 lws_sspc_get_metadata(struct lws_sspc_handle *h, const char *name,
199  const void **value, size_t *len);
200 
201 LWS_VISIBLE LWS_EXTERN int
202 lws_sspc_add_peer_tx_credit(struct lws_sspc_handle *h, int32_t add);
203 
204 LWS_VISIBLE LWS_EXTERN int
205 lws_sspc_get_est_peer_tx_credit(struct lws_sspc_handle *h);
206 
207 LWS_VISIBLE LWS_EXTERN void
208 lws_sspc_start_timeout(struct lws_sspc_handle *h, unsigned int timeout_ms);
209 
210 LWS_VISIBLE LWS_EXTERN void
211 lws_sspc_cancel_timeout(struct lws_sspc_handle *h);
212 
213 LWS_VISIBLE LWS_EXTERN void *
214 lws_sspc_to_user_object(struct lws_sspc_handle *h);
215 
216 LWS_VISIBLE LWS_EXTERN void
217 lws_sspc_change_handlers(struct lws_sspc_handle *h,
218  lws_ss_state_return_t (*rx)(void *userobj, const uint8_t *buf,
219  size_t len, int flags),
220  lws_ss_state_return_t (*tx)(void *userobj, lws_ss_tx_ordinal_t ord,
221  uint8_t *buf, size_t *len, int *flags),
222  lws_ss_state_return_t (*state)(void *userobj, void *h_src
223  /* ss handle type */,
224  lws_ss_constate_t state,
225  lws_ss_tx_ordinal_t ack));
226 
227 const char *
228 lws_sspc_tag(struct lws_sspc_handle *h);
Definition: lws-protocols-plugins.h:44
const char * name
Definition: lws-protocols-plugins.h:45
Definition: lws-secure-streams.h:350