libwebsockets
Lightweight C library for HTML5 websockets
lws-client.h
1 /*
2  * libwebsockets - small server side websockets and web server implementation
3  *
4  * Copyright (C) 2010 - 2021 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 
31 
38  LCCSCF_USE_SSL = (1 << 0),
39  LCCSCF_ALLOW_SELFSIGNED = (1 << 1),
40  LCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK = (1 << 2),
41  LCCSCF_ALLOW_EXPIRED = (1 << 3),
42  LCCSCF_ALLOW_INSECURE = (1 << 4),
43  LCCSCF_H2_QUIRK_NGHTTP2_END_STREAM = (1 << 5),
44  LCCSCF_H2_QUIRK_OVERFLOWS_TXCR = (1 << 6),
45  LCCSCF_H2_AUTH_BEARER = (1 << 7),
46  LCCSCF_H2_HEXIFY_AUTH_TOKEN = (1 << 8),
47  LCCSCF_H2_MANUAL_RXFLOW = (1 << 9),
48  LCCSCF_HTTP_MULTIPART_MIME = (1 << 10),
49  LCCSCF_HTTP_X_WWW_FORM_URLENCODED = (1 << 11),
50  LCCSCF_HTTP_NO_FOLLOW_REDIRECT = (1 << 12),
51 
52  LCCSCF_PIPELINE = (1 << 16),
60  LCCSCF_MUXABLE_STREAM = (1 << 17),
61  LCCSCF_H2_PRIOR_KNOWLEDGE = (1 << 18),
62  LCCSCF_WAKE_SUSPEND__VALIDITY = (1 << 19),
63  /* our validity checks are important enough to wake from suspend */
64  LCCSCF_PRIORITIZE_READS = (1 << 20),
75  LCCSCF_SECSTREAM_CLIENT = (1 << 21),
77  LCCSCF_SECSTREAM_PROXY_LINK = (1 << 22),
82  LCCSCF_IP_LOW_LATENCY = (1 << 24),
84  LCCSCF_IP_HIGH_THROUGHPUT = (1 << 25),
87  LCCSCF_IP_HIGH_RELIABILITY = (1 << 26),
90  LCCSCF_IP_LOW_COST = (1 << 27),
93  LCCSCF_CONMON = (1 << 28),
99  LCCSCF_CACHE_COOKIES = (1 << 30),
102 };
103 
108  struct lws_context *context;
110  const char *address;
112  int port;
116  const char *path;
119  const char *host;
121  const char *origin;
123  const char *protocol;
127  void *userdata;
129  const void *client_exts;
131  const char *method;
136  struct lws *parent_wsi;
140  const char *uri_replace_from;
143  const char *uri_replace_to;
145  struct lws_vhost *vhost;
147  struct lws **pwsi;
158  const char *iface;
161  const char *local_protocol_name;
168  const char *alpn;
175  struct lws_sequencer *seq;
202  uint8_t priority;
209 #if defined(LWS_ROLE_MQTT)
210  const lws_mqtt_client_connect_param_t *mqtt_cp;
211 #else
212  void *mqtt_cp;
213 #endif
214 
215 #if defined(LWS_WITH_SYS_FAULT_INJECTION)
216  lws_fi_ctx_t fic;
219 #endif
220  /* for convenience, available when FI disabled in build */
221  const char *fi_wsi_name;
226  uint16_t keep_warm_secs;
238  /* Add new things just above here ---^
239  * This is part of the ABI, don't needlessly break compatibility
240  *
241  * The below is to ensure later library versions with new
242  * members added above will see 0 (default) even if the app
243  * was not built against the newer headers.
244  */
245 
246  void *_unused[4];
247 };
248 
256 LWS_VISIBLE LWS_EXTERN struct lws *
258 
284 LWS_VISIBLE LWS_EXTERN int
286  struct lws_vhost *vhost);
307 LWS_VISIBLE LWS_EXTERN int
308 lws_http_client_read(struct lws *wsi, char **buf, int *len);
309 
322 LWS_VISIBLE LWS_EXTERN unsigned int
324 
336 LWS_VISIBLE LWS_EXTERN int
338  const uint8_t *der, size_t der_len);
339 
359 LWS_VISIBLE LWS_EXTERN void
360 lws_client_http_body_pending(struct lws *wsi, int something_left_to_send);
361 
376 LWS_VISIBLE LWS_EXTERN int
377 lws_client_http_multipart(struct lws *wsi, const char *name,
378  const char *filename, const char *content_type,
379  char **p, char *end);
380 
393 LWS_VISIBLE LWS_EXTERN int
394 lws_http_basic_auth_gen(const char *user, const char *pw, char *buf, size_t len);
395 
410 LWS_VISIBLE LWS_EXTERN int
411 lws_tls_session_is_reused(struct lws *wsi);
412 
LWS_VISIBLE LWS_EXTERN void lws_client_http_body_pending(struct lws *wsi, int something_left_to_send)
LWS_VISIBLE LWS_EXTERN int lws_tls_session_is_reused(struct lws *wsi)
LWS_VISIBLE LWS_EXTERN int lws_http_basic_auth_gen(const char *user, const char *pw, char *buf, size_t len)
LWS_VISIBLE LWS_EXTERN int lws_http_client_read(struct lws *wsi, char **buf, int *len)
LWS_VISIBLE LWS_EXTERN int lws_client_http_multipart(struct lws *wsi, const char *name, const char *filename, const char *content_type, char **p, char *end)
LWS_VISIBLE LWS_EXTERN int lws_init_vhost_client_ssl(const struct lws_context_creation_info *info, struct lws_vhost *vhost)
LWS_VISIBLE LWS_EXTERN struct lws * lws_client_connect_via_info(const struct lws_client_connect_info *ccinfo)
LWS_VISIBLE LWS_EXTERN unsigned int lws_http_client_http_response(struct lws *wsi)
lws_client_connect_ssl_connection_flags
Definition: lws-client.h:37
LWS_VISIBLE LWS_EXTERN int lws_tls_client_vhost_extra_cert_mem(struct lws_vhost *vh, const uint8_t *der, size_t der_len)
@ LCCSCF_SECSTREAM_CLIENT
Definition: lws-client.h:75
@ LCCSCF_CACHE_COOKIES
Definition: lws-client.h:99
@ LCCSCF_IP_HIGH_RELIABILITY
Definition: lws-client.h:87
@ LCCSCF_CONMON
Definition: lws-client.h:93
@ LCCSCF_IP_LOW_LATENCY
Definition: lws-client.h:82
@ LCCSCF_IP_HIGH_THROUGHPUT
Definition: lws-client.h:84
@ LCCSCF_SECSTREAM_PROXY_LINK
Definition: lws-client.h:77
@ LCCSCF_PIPELINE
Definition: lws-client.h:52
@ LCCSCF_ACCEPT_TLS_DOWNGRADE_REDIRECTS
Definition: lws-client.h:96
@ LCCSCF_SECSTREAM_PROXY_ONWARD
Definition: lws-client.h:79
@ LCCSCF_PRIORITIZE_READS
Definition: lws-client.h:64
@ LCCSCF_IP_LOW_COST
Definition: lws-client.h:90
Definition: lws-client.h:107
const char * uri_replace_from
Definition: lws-client.h:140
struct lws ** pwsi
Definition: lws-client.h:147
const char * alpn
Definition: lws-client.h:168
const lws_retry_bo_t * retry_and_idle_policy
Definition: lws-client.h:187
int port
Definition: lws-client.h:112
lws_log_cx_t * log_cx
Definition: lws-client.h:232
const char * fi_wsi_name
Definition: lws-client.h:221
struct lws_vhost * vhost
Definition: lws-client.h:145
struct lws * parent_wsi
Definition: lws-client.h:136
int ietf_version_or_minus_one
Definition: lws-client.h:125
const char * path
Definition: lws-client.h:116
const char * origin
Definition: lws-client.h:121
void * userdata
Definition: lws-client.h:127
int ssl_connection
Definition: lws-client.h:114
const char * uri_replace_to
Definition: lws-client.h:143
const char * host
Definition: lws-client.h:119
void * opaque_user_data
Definition: lws-client.h:180
const char * address
Definition: lws-client.h:110
const char * method
Definition: lws-client.h:131
const void * client_exts
Definition: lws-client.h:129
uint8_t sys_tls_client_cert
Definition: lws-client.h:197
const char * protocol
Definition: lws-client.h:123
const char * local_protocol_name
Definition: lws-client.h:161
struct lws_sequencer * seq
Definition: lws-client.h:175
const char * iface
Definition: lws-client.h:158
void * _unused[4]
Definition: lws-client.h:246
int manual_initial_tx_credit
Definition: lws-client.h:192
uint8_t priority
Definition: lws-client.h:202
uint16_t keep_warm_secs
Definition: lws-client.h:226
struct lws_context * context
Definition: lws-client.h:108
Definition: lws-context-vhost.h:271
Definition: lws-logs.h:80
Definition: lws-mqtt.h:90
Definition: lws-retry.h:25