libwebsockets
Lightweight C library for HTML5 websockets
Loading...
Searching...
No Matches
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
36
117
118/*
119 * All lws_tls...() functions must return this type, converting the
120 * native backend result and doing the extra work to determine which one
121 * as needed.
122 *
123 * Native TLS backend return codes are NOT ALLOWED outside the backend.
124 *
125 * Non-SSL mode also uses these types.
126 */
128 LWS_SSL_CAPABLE_ERROR = -1, /* it failed */
129 LWS_SSL_CAPABLE_DONE = 0, /* it succeeded */
130 LWS_SSL_CAPABLE_MORE_SERVICE_READ = -2, /* retry WANT_READ */
131 LWS_SSL_CAPABLE_MORE_SERVICE_WRITE = -3, /* retry WANT_WRITE */
132};
133
136
138 struct lws_context *context;
140 const char *address;
142 int port;
146 const char *path;
149 const char *host;
151 const char *origin;
153 const char *protocol;
157 void *userdata;
159 const void *client_exts;
161 const char *method;
166 struct lws *parent_wsi;
170 const char *uri_replace_from;
173 const char *uri_replace_to;
175 struct lws_vhost *vhost;
177 struct lws **pwsi;
188 const char *iface;
201 const char *alpn;
207
214
219
224
229
236
237#if defined(LWS_ROLE_MQTT)
239#else
240 void *mqtt_cp;
241#endif
242
243#if defined(LWS_WITH_SYS_FAULT_INJECTION)
244 lws_fi_ctx_t fic;
247#endif
248 /* for convenience, available when FI disabled in build */
249 const char *fi_wsi_name;
253
259
265 const char *auth_username;
266 const char *auth_password;
267
268#if defined(LWS_ROLE_WS)
269 uint8_t allow_reserved_bits;
273
274 uint8_t allow_unknown_opcode;
278#endif
279
280 /* Add new things just above here ---^
281 * This is part of the ABI, don't needlessly break compatibility
282 *
283 * The below is to ensure later library versions with new
284 * members added above will see 0 (default) even if the app
285 * was not built against the newer headers.
286 */
287
288 void *_unused[4];
289};
290
298LWS_VISIBLE LWS_EXTERN struct lws *
300
328 struct lws_vhost *vhost);
350lws_http_client_read(struct lws *wsi, char **buf, int *len);
351
364LWS_VISIBLE LWS_EXTERN unsigned int
366
380 const uint8_t *der, size_t der_len);
381
402lws_client_http_body_pending(struct lws *wsi, int something_left_to_send);
403
421lws_client_http_multipart(struct lws *wsi, const char *name,
422 const char *filename, const char *content_type,
423 char **p, char *end);
424
425struct lws_http_mp_sm;
426typedef int (*lws_http_mp_sm_cb_t)(struct lws_context *cx, char *ft, size_t ft_len, const char **last);
427
439LWS_VISIBLE LWS_EXTERN struct lws_http_mp_sm *
441
450lws_http_mp_sm_destroy(struct lws_http_mp_sm **pphms);
451
466lws_http_mp_sm_fill(struct lws_http_mp_sm *phms, uint8_t **p, uint8_t *end);
467
468
482lws_http_basic_auth_gen(const char *user, const char *pw, char *buf, size_t len);
483
501lws_http_basic_auth_gen2(const char *user, const void *pw, size_t pwd_len,
502 char *buf, size_t len);
503
520
534lws_tls_client_connect(struct lws *wsi, char *errbuf, size_t len);
535
547lws_tls_client_upgrade(struct lws *wsi, int ssl_flags);
548
const char * uri_replace_from
Definition lws-client.h:170
const lws_retry_bo_t * retry_and_idle_policy
Definition lws-client.h:215
lws_log_cx_t * log_cx
Definition lws-client.h:260
const char * auth_username
Definition lws-client.h:265
const char * fi_wsi_name
Definition lws-client.h:249
struct lws_vhost * vhost
Definition lws-client.h:175
struct lws * parent_wsi
Definition lws-client.h:166
const char * uri_replace_to
Definition lws-client.h:173
const void * client_exts
Definition lws-client.h:159
const char * local_protocol_name
Definition lws-client.h:194
const char * auth_password
Definition lws-client.h:266
struct lws_context * context
Definition lws-client.h:138
LWS_VISIBLE LWS_EXTERN struct lws_http_mp_sm * lws_http_mp_sm_init(struct lws *wsi, lws_http_mp_sm_cb_t cb, uint8_t **p, uint8_t *end)
LWS_VISIBLE LWS_EXTERN void lws_client_http_body_pending(struct lws *wsi, int something_left_to_send)
LWS_VISIBLE LWS_EXTERN enum lws_ssl_capable_status lws_tls_client_connect(struct lws *wsi, char *errbuf, size_t len)
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)
int(* lws_http_mp_sm_cb_t)(struct lws_context *cx, char *ft, size_t ft_len, const char **last)
Definition lws-client.h:426
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 int lws_http_mp_sm_fill(struct lws_http_mp_sm *phms, uint8_t **p, uint8_t *end)
LWS_VISIBLE LWS_EXTERN unsigned int lws_http_client_http_response(struct lws *wsi)
LWS_VISIBLE LWS_EXTERN struct lws * lws_client_connect_via_info(const struct lws_client_connect_info *ccinfo)
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)
LWS_VISIBLE LWS_EXTERN int lws_tls_client_upgrade(struct lws *wsi, int ssl_flags)
lws_ssl_capable_status
Definition lws-client.h:127
LWS_VISIBLE LWS_EXTERN void lws_http_mp_sm_destroy(struct lws_http_mp_sm **pphms)
@ 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_ALLOW_EARLY_DATA
Definition lws-client.h:114
@ 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
@ LWS_SSL_CAPABLE_MORE_SERVICE_READ
Definition lws-client.h:130
@ LWS_SSL_CAPABLE_MORE_SERVICE_WRITE
Definition lws-client.h:131
@ LWS_SSL_CAPABLE_ERROR
Definition lws-client.h:128
@ LWS_SSL_CAPABLE_DONE
Definition lws-client.h:129
struct lws_log_cx lws_log_cx_t
unsigned short uint16_t
#define LWS_EXTERN
unsigned char uint8_t
#define LWS_VISIBLE
struct lws_mqtt_client_connect_param_s lws_mqtt_client_connect_param_t
struct lws_retry_bo lws_retry_bo_t