libwebsockets
Lightweight C library for HTML5 websockets
lws-client.h
Go to the documentation of this file.
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),
52 
53  LCCSCF_ALLOW_REUSE_ADDR = (1 << 14),
64  LCCSCF_PIPELINE = (1 << 16),
72  LCCSCF_MUXABLE_STREAM = (1 << 17),
75  /* our validity checks are important enough to wake from suspend */
76  LCCSCF_PRIORITIZE_READS = (1 << 20),
87  LCCSCF_SECSTREAM_CLIENT = (1 << 21),
89  LCCSCF_SECSTREAM_PROXY_LINK = (1 << 22),
94  LCCSCF_IP_LOW_LATENCY = (1 << 24),
96  LCCSCF_IP_HIGH_THROUGHPUT = (1 << 25),
99  LCCSCF_IP_HIGH_RELIABILITY = (1 << 26),
102  LCCSCF_IP_LOW_COST = (1 << 27),
105  LCCSCF_CONMON = (1 << 28),
111  LCCSCF_CACHE_COOKIES = (1 << 30),
114 };
115 
120  struct lws_context *context;
122  const char *address;
124  int port;
128  const char *path;
131  const char *host;
133  const char *origin;
135  const char *protocol;
139  void *userdata;
141  const void *client_exts;
143  const char *method;
148  struct lws *parent_wsi;
152  const char *uri_replace_from;
155  const char *uri_replace_to;
157  struct lws_vhost *vhost;
159  struct lws **pwsi;
170  const char *iface;
176  const char *local_protocol_name;
183  const char *alpn;
219 #if defined(LWS_ROLE_MQTT)
221 #else
222  void *mqtt_cp;
223 #endif
224 
225 #if defined(LWS_WITH_SYS_FAULT_INJECTION)
226  lws_fi_ctx_t fic;
229 #endif
230  /* for convenience, available when FI disabled in build */
231  const char *fi_wsi_name;
247  const char *auth_username;
248  const char *auth_password;
249 
250 #if defined(LWS_ROLE_WS)
251  uint8_t allow_reserved_bits;
256  uint8_t allow_unknown_opcode;
260 #endif
261 
262  /* Add new things just above here ---^
263  * This is part of the ABI, don't needlessly break compatibility
264  *
265  * The below is to ensure later library versions with new
266  * members added above will see 0 (default) even if the app
267  * was not built against the newer headers.
268  */
269 
270  void *_unused[4];
271 };
272 
280 LWS_VISIBLE LWS_EXTERN struct lws *
282 
310  struct lws_vhost *vhost);
332 lws_http_client_read(struct lws *wsi, char **buf, int *len);
333 
346 LWS_VISIBLE LWS_EXTERN unsigned int
348 
362  const uint8_t *der, size_t der_len);
363 
384 lws_client_http_body_pending(struct lws *wsi, int something_left_to_send);
385 
401 lws_client_http_multipart(struct lws *wsi, const char *name,
402  const char *filename, const char *content_type,
403  char **p, char *end);
404 
418 lws_http_basic_auth_gen(const char *user, const char *pw, char *buf, size_t len);
419 
437 lws_http_basic_auth_gen2(const char *user, const void *pw, size_t pwd_len,
438  char *buf, size_t len);
439 
455 lws_tls_session_is_reused(struct lws *wsi);
456 
const char * uri_replace_from
Definition: lws-client.h:152
struct lws ** pwsi
Definition: lws-client.h:159
const lws_retry_bo_t * retry_and_idle_policy
Definition: lws-client.h:197
lws_log_cx_t * log_cx
Definition: lws-client.h:242
const char * auth_username
Definition: lws-client.h:247
const char * fi_wsi_name
Definition: lws-client.h:231
struct lws_vhost * vhost
Definition: lws-client.h:157
struct lws * parent_wsi
Definition: lws-client.h:148
const char * uri_replace_to
Definition: lws-client.h:155
const char * address
Definition: lws-client.h:122
const void * client_exts
Definition: lws-client.h:141
const char * protocol
Definition: lws-client.h:135
const char * local_protocol_name
Definition: lws-client.h:176
const char * auth_password
Definition: lws-client.h:248
struct lws_context * context
Definition: lws-client.h:120
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_basic_auth_gen2(const char *user, const void *pw, size_t pwd_len, 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:87
@ LCCSCF_CACHE_COOKIES
Definition: lws-client.h:111
@ LCCSCF_HTTP_MULTIPART_MIME
Definition: lws-client.h:48
@ LCCSCF_IPV6_PREFER_PUBLIC_ADDR
Definition: lws-client.h:59
@ LCCSCF_HTTP_X_WWW_FORM_URLENCODED
Definition: lws-client.h:49
@ LCCSCF_IP_HIGH_RELIABILITY
Definition: lws-client.h:99
@ LCCSCF_CONMON
Definition: lws-client.h:105
@ LCCSCF_IP_LOW_LATENCY
Definition: lws-client.h:94
@ LCCSCF_IP_HIGH_THROUGHPUT
Definition: lws-client.h:96
@ LCCSCF_ALLOW_EXPIRED
Definition: lws-client.h:41
@ LCCSCF_ALLOW_REUSE_ADDR
Definition: lws-client.h:53
@ LCCSCF_H2_QUIRK_OVERFLOWS_TXCR
Definition: lws-client.h:44
@ LCCSCF_H2_MANUAL_RXFLOW
Definition: lws-client.h:47
@ LCCSCF_H2_QUIRK_NGHTTP2_END_STREAM
Definition: lws-client.h:43
@ LCCSCF_SECSTREAM_PROXY_LINK
Definition: lws-client.h:89
@ LCCSCF_USE_SSL
Definition: lws-client.h:38
@ LCCSCF_H2_PRIOR_KNOWLEDGE
Definition: lws-client.h:73
@ LCCSCF_PIPELINE
Definition: lws-client.h:64
@ LCCSCF_ALLOW_INSECURE
Definition: lws-client.h:42
@ LCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK
Definition: lws-client.h:40
@ LCCSCF_H2_AUTH_BEARER
Definition: lws-client.h:45
@ LCCSCF_WAKE_SUSPEND__VALIDITY
Definition: lws-client.h:74
@ LCCSCF_ACCEPT_TLS_DOWNGRADE_REDIRECTS
Definition: lws-client.h:108
@ LCCSCF_HTTP_NO_FOLLOW_REDIRECT
Definition: lws-client.h:50
@ LCCSCF_SECSTREAM_PROXY_ONWARD
Definition: lws-client.h:91
@ LCCSCF_PRIORITIZE_READS
Definition: lws-client.h:76
@ LCCSCF_IP_LOW_COST
Definition: lws-client.h:102
@ LCCSCF_HTTP_NO_CACHE_CONTROL
Definition: lws-client.h:51
@ LCCSCF_H2_HEXIFY_AUTH_TOKEN
Definition: lws-client.h:46
@ LCCSCF_MUXABLE_STREAM
Definition: lws-client.h:72
@ LCCSCF_ALLOW_SELFSIGNED
Definition: lws-client.h:39
unsigned short uint16_t
#define LWS_EXTERN
unsigned char uint8_t
#define LWS_VISIBLE