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;
118  const char *host;
120  const char *origin;
122  const char *protocol;
126  void *userdata;
128  const void *client_exts;
130  const char *method;
135  struct lws *parent_wsi;
139  const char *uri_replace_from;
142  const char *uri_replace_to;
144  struct lws_vhost *vhost;
146  struct lws **pwsi;
157  const char *iface;
160  const char *local_protocol_name;
167  const char *alpn;
174  struct lws_sequencer *seq;
201  uint8_t priority;
208 #if defined(LWS_ROLE_MQTT)
209  const lws_mqtt_client_connect_param_t *mqtt_cp;
210 #else
211  void *mqtt_cp;
212 #endif
213 
214 #if defined(LWS_WITH_SYS_FAULT_INJECTION)
215  lws_fi_ctx_t fic;
218 #endif
219  /* for convenience, available when FI disabled in build */
220  const char *fi_wsi_name;
225  uint16_t keep_warm_secs;
237  /* Add new things just above here ---^
238  * This is part of the ABI, don't needlessly break compatibility
239  *
240  * The below is to ensure later library versions with new
241  * members added above will see 0 (default) even if the app
242  * was not built against the newer headers.
243  */
244 
245  void *_unused[4];
246 };
247 
255 LWS_VISIBLE LWS_EXTERN struct lws *
257 
283 LWS_VISIBLE LWS_EXTERN int
285  struct lws_vhost *vhost);
306 LWS_VISIBLE LWS_EXTERN int
307 lws_http_client_read(struct lws *wsi, char **buf, int *len);
308 
320 LWS_VISIBLE LWS_EXTERN unsigned int
322 
334 LWS_VISIBLE LWS_EXTERN int
336  const uint8_t *der, size_t der_len);
337 
357 LWS_VISIBLE LWS_EXTERN void
358 lws_client_http_body_pending(struct lws *wsi, int something_left_to_send);
359 
374 LWS_VISIBLE LWS_EXTERN int
375 lws_client_http_multipart(struct lws *wsi, const char *name,
376  const char *filename, const char *content_type,
377  char **p, char *end);
378 
391 LWS_VISIBLE LWS_EXTERN int
392 lws_http_basic_auth_gen(const char *user, const char *pw, char *buf, size_t len);
393 
408 LWS_VISIBLE LWS_EXTERN int
409 lws_tls_session_is_reused(struct lws *wsi);
410 
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:139
struct lws ** pwsi
Definition: lws-client.h:146
const char * alpn
Definition: lws-client.h:167
const lws_retry_bo_t * retry_and_idle_policy
Definition: lws-client.h:186
int port
Definition: lws-client.h:112
lws_log_cx_t * log_cx
Definition: lws-client.h:231
const char * fi_wsi_name
Definition: lws-client.h:220
struct lws_vhost * vhost
Definition: lws-client.h:144
struct lws * parent_wsi
Definition: lws-client.h:135
int ietf_version_or_minus_one
Definition: lws-client.h:124
const char * path
Definition: lws-client.h:116
const char * origin
Definition: lws-client.h:120
void * userdata
Definition: lws-client.h:126
int ssl_connection
Definition: lws-client.h:114
const char * uri_replace_to
Definition: lws-client.h:142
const char * host
Definition: lws-client.h:118
void * opaque_user_data
Definition: lws-client.h:179
const char * address
Definition: lws-client.h:110
const char * method
Definition: lws-client.h:130
const void * client_exts
Definition: lws-client.h:128
uint8_t sys_tls_client_cert
Definition: lws-client.h:196
const char * protocol
Definition: lws-client.h:122
const char * local_protocol_name
Definition: lws-client.h:160
struct lws_sequencer * seq
Definition: lws-client.h:174
const char * iface
Definition: lws-client.h:157
void * _unused[4]
Definition: lws-client.h:245
int manual_initial_tx_credit
Definition: lws-client.h:191
uint8_t priority
Definition: lws-client.h:201
uint16_t keep_warm_secs
Definition: lws-client.h:225
struct lws_context * context
Definition: lws-client.h:108
Definition: lws-context-vhost.h:271
Definition: lws-logs.h:80
Definition: lws-mqtt.h:67
Definition: lws-retry.h:25