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 - 2019 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),
96 };
97 
102  struct lws_context *context;
104  const char *address;
106  int port;
110  const char *path;
112  const char *host;
114  const char *origin;
116  const char *protocol;
120  void *userdata;
122  const void *client_exts;
124  const char *method;
129  struct lws *parent_wsi;
133  const char *uri_replace_from;
136  const char *uri_replace_to;
138  struct lws_vhost *vhost;
140  struct lws **pwsi;
151  const char *iface;
154  const char *local_protocol_name;
161  const char *alpn;
168  struct lws_sequencer *seq;
195  uint8_t priority;
202 #if defined(LWS_ROLE_MQTT)
203  const lws_mqtt_client_connect_param_t *mqtt_cp;
204 #else
205  void *mqtt_cp;
206 #endif
207 
208 #if defined(LWS_WITH_SYS_FAULT_INJECTION)
209  lws_fi_ctx_t fic;
212 #endif
213  /* for convenience, available when FI disabled in build */
214  const char *fi_wsi_name;
219  uint16_t keep_warm_secs;
225  /* Add new things just above here ---^
226  * This is part of the ABI, don't needlessly break compatibility
227  *
228  * The below is to ensure later library versions with new
229  * members added above will see 0 (default) even if the app
230  * was not built against the newer headers.
231  */
232 
233  void *_unused[4];
234 };
235 
243 LWS_VISIBLE LWS_EXTERN struct lws *
245 
271 LWS_VISIBLE LWS_EXTERN int
273  struct lws_vhost *vhost);
294 LWS_VISIBLE LWS_EXTERN int
295 lws_http_client_read(struct lws *wsi, char **buf, int *len);
296 
308 LWS_VISIBLE LWS_EXTERN unsigned int
310 
322 LWS_VISIBLE LWS_EXTERN int
324  const uint8_t *der, size_t der_len);
325 
345 LWS_VISIBLE LWS_EXTERN void
346 lws_client_http_body_pending(struct lws *wsi, int something_left_to_send);
347 
362 LWS_VISIBLE LWS_EXTERN int
363 lws_client_http_multipart(struct lws *wsi, const char *name,
364  const char *filename, const char *content_type,
365  char **p, char *end);
366 
379 LWS_VISIBLE LWS_EXTERN int
380 lws_http_basic_auth_gen(const char *user, const char *pw, char *buf, size_t len);
381 
396 LWS_VISIBLE LWS_EXTERN int
397 lws_tls_session_is_reused(struct lws *wsi);
398 
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_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_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:101
const char * uri_replace_from
Definition: lws-client.h:133
struct lws ** pwsi
Definition: lws-client.h:140
const char * alpn
Definition: lws-client.h:161
const lws_retry_bo_t * retry_and_idle_policy
Definition: lws-client.h:180
int port
Definition: lws-client.h:106
const char * fi_wsi_name
Definition: lws-client.h:214
struct lws_vhost * vhost
Definition: lws-client.h:138
struct lws * parent_wsi
Definition: lws-client.h:129
int ietf_version_or_minus_one
Definition: lws-client.h:118
const char * path
Definition: lws-client.h:110
const char * origin
Definition: lws-client.h:114
void * userdata
Definition: lws-client.h:120
int ssl_connection
Definition: lws-client.h:108
const char * uri_replace_to
Definition: lws-client.h:136
const char * host
Definition: lws-client.h:112
void * opaque_user_data
Definition: lws-client.h:173
const char * address
Definition: lws-client.h:104
const char * method
Definition: lws-client.h:124
const void * client_exts
Definition: lws-client.h:122
uint8_t sys_tls_client_cert
Definition: lws-client.h:190
const char * protocol
Definition: lws-client.h:116
const char * local_protocol_name
Definition: lws-client.h:154
struct lws_sequencer * seq
Definition: lws-client.h:168
const char * iface
Definition: lws-client.h:151
void * _unused[4]
Definition: lws-client.h:233
int manual_initial_tx_credit
Definition: lws-client.h:185
uint8_t priority
Definition: lws-client.h:195
uint16_t keep_warm_secs
Definition: lws-client.h:219
struct lws_context * context
Definition: lws-client.h:102
Definition: lws-context-vhost.h:271
Definition: lws-mqtt.h:64
Definition: lws-retry.h:25