* wsi lifecycle changes if it acquires the same lock for the
* duration of wsi dereference from the other thread context.
*/
-LWS_VISIBLE LWS_EXTERN int callback(struct lws_context *context,
- struct lws *wsi,
- enum lws_callback_reasons reason, void *user,
- void *in, size_t len);
+LWS_VISIBLE LWS_EXTERN int
+callback(struct lws_context *context, struct lws *wsi,
+ enum lws_callback_reasons reason, void *user, void *in, size_t len);
-typedef int (callback_function)(struct lws_context *context,
- struct lws *wsi,
- enum lws_callback_reasons reason, void *user,
- void *in, size_t len);
+typedef int (callback_function)(struct lws_context *context, struct lws *wsi,
+ enum lws_callback_reasons reason, void *user,
+ void *in, size_t len);
#ifndef LWS_NO_EXTENSIONS
/**
* buffer safely, it should copy the data into its own buffer and
* set the lws_tokens token pointer to it.
*/
-LWS_VISIBLE LWS_EXTERN int extension_callback(struct lws_context *context,
- struct lws_extension *ext,
- struct lws *wsi,
- enum lws_extension_callback_reasons reason,
- void *user, void *in, size_t len);
+LWS_VISIBLE LWS_EXTERN int
+extension_callback(struct lws_context *context, struct lws_extension *ext,
+ struct lws *wsi, enum lws_extension_callback_reasons reason,
+ void *user, void *in, size_t len);
typedef int (extension_callback_function)(struct lws_context *context,
- struct lws_extension *ext,
- struct lws *wsi,
+ struct lws_extension *ext, struct lws *wsi,
enum lws_extension_callback_reasons reason,
void *user, void *in, size_t len);
#endif
#endif
};
-LWS_VISIBLE LWS_EXTERN
-void lws_set_log_level(int level,
- void (*log_emit_function)(int level, const char *line));
+LWS_VISIBLE LWS_EXTERN void
+lws_set_log_level(int level,
+ void (*log_emit_function)(int level, const char *line));
LWS_VISIBLE LWS_EXTERN void
lwsl_emit_syslog(int level, const char *line);
unsigned char **p,
unsigned char *end);
-LWS_EXTERN int lws_http_transaction_completed(struct lws *wsi);
+LWS_EXTERN int
+lws_http_transaction_completed(struct lws *wsi);
#ifdef LWS_USE_LIBEV
typedef void (lws_ev_signal_cb)(EV_P_ struct ev_signal *w, int revents);
};
LWS_VISIBLE LWS_EXTERN void
-lws_set_timeout(struct lws *wsi,
- enum pending_timeout reason, int secs);
+lws_set_timeout(struct lws *wsi, enum pending_timeout reason, int secs);
/*
* IMPORTANT NOTICE!
* the big length style
*/
-// Pad LWS_SEND_BUFFER_PRE_PADDING to the CPU word size, so that word references
-// to the address immediately after the padding won't cause an unaligned access
-// error. Sometimes the recommended padding is even larger than the size of a void *.
-// For example, for the X86-64 architecture, in Intel's document
-// https://software.intel.com/en-us/articles/data-alignment-when-migrating-to-64-bit-intel-architecture
-// they recommend that structures larger than 16 bytes be aligned to 16-byte
-// boundaries.
-//
+/*
+ * Pad LWS_SEND_BUFFER_PRE_PADDING to the CPU word size, so that word references
+ * to the address immediately after the padding won't cause an unaligned access
+ * error. Sometimes for performance reasons the recommended padding is even
+ * larger than sizeof(void *).
+ */
#if !defined(LWS_SIZEOFPTR)
#define LWS_SIZEOFPTR (sizeof (void *))
#else
#define _LWS_PAD_SIZE LWS_SIZEOFPTR /* Size of a pointer on the target architecture */
#endif
-#define _LWS_PAD(n) (((n) % _LWS_PAD_SIZE) ? ((n) + (_LWS_PAD_SIZE - ((n) % _LWS_PAD_SIZE))) : (n))
+#define _LWS_PAD(n) (((n) % _LWS_PAD_SIZE) ? \
+ ((n) + (_LWS_PAD_SIZE - ((n) % _LWS_PAD_SIZE))) : (n))
#define LWS_SEND_BUFFER_PRE_PADDING _LWS_PAD(4 + 10 + (2 * MAX_MUX_RECURSION))
#define LWS_SEND_BUFFER_POST_PADDING 4
LWS_VISIBLE LWS_EXTERN int
lws_write(struct lws *wsi, unsigned char *buf, size_t len,
- enum lws_write_protocol protocol);
+ enum lws_write_protocol protocol);
/* helper for case where buffer may be const */
#define lws_write_http(wsi, buf, len) \
lws_write(wsi, (unsigned char *)(buf), len, LWS_WRITE_HTTP)
LWS_VISIBLE LWS_EXTERN int
-lws_serve_http_file(struct lws_context *context,
- struct lws *wsi, const char *file,
- const char *content_type, const char *other_headers,
- int other_headers_len);
+lws_serve_http_file(struct lws_context *context, struct lws *wsi,
+ const char *file, const char *content_type,
+ const char *other_headers, int other_headers_len);
LWS_VISIBLE LWS_EXTERN int
-lws_serve_http_file_fragment(struct lws_context *context,
- struct lws *wsi);
+lws_serve_http_file_fragment(struct lws_context *context, struct lws *wsi);
LWS_VISIBLE LWS_EXTERN int
-lws_return_http_status(struct lws_context *context,
- struct lws *wsi, unsigned int code,
- const char *html_body);
+lws_return_http_status(struct lws_context *context, struct lws *wsi,
+ unsigned int code, const char *html_body);
LWS_VISIBLE LWS_EXTERN const struct lws_protocols *
lws_get_protocol(struct lws *wsi);
lws_get_peer_write_allowance(struct lws *wsi);
LWS_VISIBLE LWS_EXTERN struct lws *
-lws_client_connect(struct lws_context *clients,
- const char *address,
- int port,
- int ssl_connection,
- const char *path,
- const char *host,
- const char *origin,
- const char *protocol,
- int ietf_version_or_minus_one);
+lws_client_connect(struct lws_context *clients, const char *address,
+ int port, int ssl_connection, const char *path,
+ const char *host, const char *origin, const char *protocol,
+ int ietf_version_or_minus_one);
LWS_VISIBLE LWS_EXTERN struct lws *
-lws_client_connect_extended(struct lws_context *clients,
- const char *address,
- int port,
- int ssl_connection,
- const char *path,
- const char *host,
- const char *origin,
- const char *protocol,
- int ietf_version_or_minus_one,
- void *userdata);
+lws_client_connect_extended(struct lws_context *clients, const char *address,
+ int port, int ssl_connection, const char *path,
+ const char *host, const char *origin,
+ const char *protocol, int ietf_version_or_minus_one,
+ void *userdata);
LWS_VISIBLE LWS_EXTERN const char *
lws_canonical_hostname(struct lws_context *context);
LWS_VISIBLE LWS_EXTERN void
-lws_get_peer_addresses(struct lws_context *context,
- struct lws *wsi, lws_sockfd_type fd,
- char *name, int name_len,
- char *rip, int rip_len);
+lws_get_peer_addresses(struct lws_context *context, struct lws *wsi,
+ lws_sockfd_type fd, char *name, int name_len,
+ char *rip, int rip_len);
LWS_VISIBLE LWS_EXTERN int
lws_get_random(struct lws_context *context, void *buf, int len);
LWS_VISIBLE LWS_EXTERN int
lws_hdr_copy(struct lws *wsi, char *dest, int len,
- enum lws_token_indexes h);
+ enum lws_token_indexes h);
/*
* Note: this is not normally needed as a user api. It's provided in case it is
#define compatible_close(fd) closesocket(fd)
#define compatible_file_close(fd) CloseHandle(fd)
-#define compatible_file_seek_cur(fd, offset) SetFilePointer(fd, offset, NULL, FILE_CURRENT)
+#define compatible_file_seek_cur(fd, offset) \
+ SetFilePointer(fd, offset, NULL, FILE_CURRENT)
#define compatible_file_read(amount, fd, buf, len) {\
DWORD _amount; \
if (!ReadFile(fd, buf, len, &_amount, NULL)) \
#endif
#ifdef LWS_USE_IPV6
-#define LWS_IPV6_ENABLED(context) (!(context->options & LWS_SERVER_OPTION_DISABLE_IPV6))
+#define LWS_IPV6_ENABLED(context) \
+ (!(context->options & LWS_SERVER_OPTION_DISABLE_IPV6))
#else
#define LWS_IPV6_ENABLED(context) (0)
#endif
unsigned int content_remain;
};
-
#ifdef LWS_USE_HTTP2
enum lws_http2_settings {
#endif /* LWS_USE_LIBEV */
const struct lws_protocols *protocol;
#ifndef LWS_NO_EXTENSIONS
- struct lws_extension *
- active_extensions[LWS_MAX_EXTENSIONS_ACTIVE];
+ struct lws_extension *active_extensions[LWS_MAX_EXTENSIONS_ACTIVE];
void *active_extensions_user[LWS_MAX_EXTENSIONS_ACTIVE];
unsigned char count_active_extensions;
unsigned int extension_data_pending:1;
LWS_EXTERN void
lws_close_and_free_session(struct lws_context *context,
- struct lws *wsi, enum lws_close_status);
+ struct lws *wsi, enum lws_close_status);
LWS_EXTERN int
-remove_wsi_socket_from_fds(struct lws_context *context,
- struct lws *wsi);
+remove_wsi_socket_from_fds(struct lws_context *context, struct lws *wsi);
LWS_EXTERN int
lws_rxflow_cache(struct lws *wsi, unsigned char *buf, int n, int len);
#ifndef LWS_LATENCY
-static inline void lws_latency(struct lws_context *context,
- struct lws *wsi, const char *action,
- int ret, int completion) { do { (void)context; (void)wsi; (void)action; (void)ret; (void)completion; } while (0); }
-static inline void lws_latency_pre(struct lws_context *context,
- struct lws *wsi) { do { (void)context; (void)wsi; } while (0); }
+static inline void
+lws_latency(struct lws_context *context, struct lws *wsi, const char *action,
+ int ret, int completion) {
+ do { (void)context; (void)wsi; (void)action; (void)ret; (void)completion;
+ } while (0);
+}
+static inline void
+lws_latency_pre(struct lws_context *context, struct lws *wsi) {
+ do { (void)context; (void)wsi; } while (0);
+}
#else
#define lws_latency_pre(_context, _wsi) lws_latency(_context, _wsi, NULL, 0, 0)
extern void
-lws_latency(struct lws_context *context,
- struct lws *wsi, const char *action,
- int ret, int completion);
+lws_latency(struct lws_context *context, struct lws *wsi, const char *action,
+ int ret, int completion);
#endif
-LWS_EXTERN void lws_set_protocol_write_pending(struct lws_context *context,
- struct lws *wsi,
- enum lws_pending_protocol_send pend);
+LWS_EXTERN void
+lws_set_protocol_write_pending(struct lws_context *context, struct lws *wsi,
+ enum lws_pending_protocol_send pend);
LWS_EXTERN int
lws_client_rx_sm(struct lws *wsi, unsigned char c);
LWS_EXTERN int
-lws_parse(struct lws_context *context,
- struct lws *wsi, unsigned char c);
+lws_parse(struct lws_context *context, struct lws *wsi, unsigned char c);
LWS_EXTERN int
lws_http_action(struct lws_context *context, struct lws *wsi);
#endif
LWS_EXTERN int
-insert_wsi_socket_into_fds(struct lws_context *context,
- struct lws *wsi);
+insert_wsi_socket_into_fds(struct lws_context *context, struct lws *wsi);
LWS_EXTERN int
lws_issue_raw(struct lws *wsi, unsigned char *buf, size_t len);
LWS_EXTERN int
lws_service_timeout_check(struct lws_context *context,
- struct lws *wsi, unsigned int sec);
+ struct lws *wsi, unsigned int sec);
LWS_EXTERN struct lws *
-lws_client_connect_2(struct lws_context *context,
- struct lws *wsi);
+lws_client_connect_2(struct lws_context *context, struct lws *wsi);
LWS_EXTERN struct lws *
lws_create_new_server_wsi(struct lws_context *context);
LWS_EXTERN char *
-lws_generate_client_handshake(struct lws_context *context,
- struct lws *wsi, char *pkt);
+lws_generate_client_handshake(struct lws_context *context, struct lws *wsi,
+ char *pkt);
LWS_EXTERN int
-lws_handle_POLLOUT_event(struct lws_context *context,
- struct lws *wsi, struct lws_pollfd *pollfd);
+lws_handle_POLLOUT_event(struct lws_context *context, struct lws *wsi,
+ struct lws_pollfd *pollfd);
/*
* EXTENSIONS
#ifndef LWS_NO_EXTENSIONS
LWS_VISIBLE void
lws_context_init_extensions(struct lws_context_creation_info *info,
- struct lws_context *context);
+ struct lws_context *context);
LWS_EXTERN int
-lws_any_extension_handled(struct lws_context *context,
- struct lws *wsi,
+lws_any_extension_handled(struct lws_context *context, struct lws *wsi,
enum lws_extension_callback_reasons r,
void *v, size_t len);
LWS_EXTERN int
lws_ext_callback_for_each_active(struct lws *wsi, int reason,
- void *buf, int len);
+ void *buf, int len);
LWS_EXTERN int
-lws_ext_callback_for_each_extension_type(
- struct lws_context *context, struct lws *wsi,
- int reason, void *arg, int len);
+lws_ext_callback_for_each_extension_type(struct lws_context *context,
+ struct lws *wsi, int reason,
+ void *arg, int len);
#else
#define lws_any_extension_handled(_a, _b, _c, _d, _e) (0)
#define lws_ext_callback_for_each_active(_a, _b, _c, _d) (0)
LWS_EXTERN int
lws_client_interpret_server_handshake(struct lws_context *context,
- struct lws *wsi);
+ struct lws *wsi);
LWS_EXTERN int
lws_rx_sm(struct lws *wsi, unsigned char c);
LWS_EXTERN int
-lws_issue_raw_ext_access(struct lws *wsi,
- unsigned char *buf, size_t len);
+lws_issue_raw_ext_access(struct lws *wsi, unsigned char *buf, size_t len);
LWS_EXTERN int
_lws_rx_flow_control(struct lws *wsi);
lws_union_transition(struct lws *wsi, enum connection_mode mode);
LWS_EXTERN int
-user_callback_handle_rxflow(callback_function,
- struct lws_context *context,
- struct lws *wsi,
- enum lws_callback_reasons reason, void *user,
- void *in, size_t len);
+user_callback_handle_rxflow(callback_function, struct lws_context *context,
+ struct lws *wsi, enum lws_callback_reasons reason,
+ void *user, void *in, size_t len);
#ifdef LWS_USE_HTTP2
LWS_EXTERN struct lws *lws_http2_get_network_wsi(struct lws *wsi);
struct lws * lws_http2_get_nth_child(struct lws *wsi, int n);
LWS_EXTERN int
-lws_http2_interpret_settings_payload(struct http2_settings *settings, unsigned char *buf, int len);
+lws_http2_interpret_settings_payload(struct http2_settings *settings,
+ unsigned char *buf, int len);
LWS_EXTERN void lws_http2_init(struct http2_settings *settings);
LWS_EXTERN int
lws_http2_parser(struct lws_context *context,
struct lws *wsi, unsigned char c);
-LWS_EXTERN int lws_http2_do_pps_send(struct lws_context *context, struct lws *wsi);
-LWS_EXTERN int lws_http2_frame_write(struct lws *wsi, int type, int flags, unsigned int sid, unsigned int len, unsigned char *buf);
+LWS_EXTERN int lws_http2_do_pps_send(struct lws_context *context,
+ struct lws *wsi);
+LWS_EXTERN int lws_http2_frame_write(struct lws *wsi, int type, int flags,
+ unsigned int sid, unsigned int len,
+ unsigned char *buf);
LWS_EXTERN struct lws *
lws_http2_wsi_from_id(struct lws *wsi, unsigned int sid);
LWS_EXTERN int lws_hpack_interpret(struct lws_context *context,
struct lws *wsi,
unsigned char c);
LWS_EXTERN int
-lws_add_http2_header_by_name(struct lws_context *context,
- struct lws *wsi,
- const unsigned char *name,
- const unsigned char *value,
- int length,
- unsigned char **p,
- unsigned char *end);
+lws_add_http2_header_by_name(struct lws_context *context, struct lws *wsi,
+ const unsigned char *name,
+ const unsigned char *value, int length,
+ unsigned char **p, unsigned char *end);
LWS_EXTERN int
-lws_add_http2_header_by_token(struct lws_context *context,
- struct lws *wsi,
+lws_add_http2_header_by_token(struct lws_context *context, struct lws *wsi,
enum lws_token_indexes token,
- const unsigned char *value,
- int length,
- unsigned char **p,
- unsigned char *end);
+ const unsigned char *value, int length,
+ unsigned char **p, unsigned char *end);
LWS_EXTERN int
-lws_add_http2_header_status(struct lws_context *context,
- struct lws *wsi,
- unsigned int code,
- unsigned char **p,
+lws_add_http2_header_status(struct lws_context *context, struct lws *wsi,
+ unsigned int code, unsigned char **p,
unsigned char *end);
LWS_EXTERN
void lws_http2_configure_if_upgraded(struct lws *wsi);
#ifndef LWS_NO_SERVER
int lws_context_init_server(struct lws_context_creation_info *info,
struct lws_context *context);
-LWS_EXTERN int handshake_0405(struct lws_context *context,
- struct lws *wsi);
LWS_EXTERN int
-lws_interpret_incoming_packet(struct lws *wsi,
- unsigned char *buf, size_t len);
+handshake_0405(struct lws_context *context, struct lws *wsi);
+LWS_EXTERN int
+lws_interpret_incoming_packet(struct lws *wsi, unsigned char *buf, size_t len);
LWS_EXTERN void
lws_server_get_canonical_hostname(struct lws_context *context,
- struct lws_context_creation_info *info);
+ struct lws_context_creation_info *info);
#else
#define lws_context_init_server(_a, _b) (0)
#define lws_interpret_incoming_packet(_a, _b, _c) (0)
#endif
#if !defined(MBED_OPERATORS)
-LWS_EXTERN int interface_to_sa(struct lws_context *context,
- const char *ifname, struct sockaddr_in *addr, size_t addrlen);
+LWS_EXTERN int
+interface_to_sa(struct lws_context *context, const char *ifname,
+ struct sockaddr_in *addr, size_t addrlen);
#endif
LWS_EXTERN void lwsl_emit_stderr(int level, const char *line);
LWS_EXTERN int
lws_ssl_pending(struct lws *wsi);
LWS_EXTERN int
-lws_server_socket_service_ssl(struct lws_context *context,
- struct lws **wsi, struct lws *new_wsi,
- lws_sockfd_type accept_fd, struct lws_pollfd *pollfd);
+lws_server_socket_service_ssl(struct lws_context *context, struct lws **wsi,
+ struct lws *new_wsi, lws_sockfd_type accept_fd,
+ struct lws_pollfd *pollfd);
LWS_EXTERN int
lws_ssl_close(struct lws *wsi);
LWS_EXTERN void
lws_ssl_context_destroy(struct lws_context *context);
LWS_VISIBLE void
lws_ssl_remove_wsi_from_buffered_list(struct lws_context *context,
- struct lws *wsi);
+ struct lws *wsi);
#ifndef LWS_NO_SERVER
LWS_EXTERN int
lws_context_init_server_ssl(struct lws_context_creation_info *info,
- struct lws_context *context);
+ struct lws_context *context);
#else
#define lws_context_init_server_ssl(_a, _b) (0)
#endif
lws_ssl_pending_no_ssl(struct lws *wsi);
#ifndef LWS_NO_CLIENT
- LWS_EXTERN int lws_client_socket_service(
- struct lws_context *context,
- struct lws *wsi, struct lws_pollfd *pollfd);
+LWS_EXTERN int lws_client_socket_service(struct lws_context *context,
+ struct lws *wsi,
+ struct lws_pollfd *pollfd);
#ifdef LWS_OPENSSL_SUPPORT
- LWS_EXTERN int lws_context_init_client_ssl(struct lws_context_creation_info *info,
+LWS_EXTERN int
+lws_context_init_client_ssl(struct lws_context_creation_info *info,
struct lws_context *context);
#else
#define lws_context_init_client_ssl(_a, _b) (0)
#endif
- LWS_EXTERN int lws_handshake_client(struct lws *wsi, unsigned char **buf, size_t len);
- LWS_EXTERN void
- lws_decode_ssl_error(void);
+LWS_EXTERN int
+lws_handshake_client(struct lws *wsi, unsigned char **buf, size_t len);
+LWS_EXTERN void
+lws_decode_ssl_error(void);
#else
#define lws_context_init_client_ssl(_a, _b) (0)
#define lws_handshake_client(_a, _b, _c) (0)
#endif
#ifndef LWS_NO_SERVER
- LWS_EXTERN int lws_server_socket_service(
- struct lws_context *context,
- struct lws *wsi, struct lws_pollfd *pollfd);
- LWS_EXTERN int _lws_rx_flow_control(struct lws *wsi);
- LWS_EXTERN int lws_handshake_server(struct lws_context *context,
+LWS_EXTERN int
+lws_server_socket_service(struct lws_context *context, struct lws *wsi,
+ struct lws_pollfd *pollfd);
+LWS_EXTERN int
+_lws_rx_flow_control(struct lws *wsi);
+LWS_EXTERN int
+lws_handshake_server(struct lws_context *context,
struct lws *wsi, unsigned char **buf, size_t len);
#else
#define lws_server_socket_service(_a, _b, _c) (0)
#define lws_handshake_server(_a, _b, _c, _d) (0)
#endif
-LWS_EXTERN int lws_get_addresses(struct lws_context *context,
- void *ads, char *name, int name_len,
- char *rip, int rip_len);
+LWS_EXTERN int
+lws_get_addresses(struct lws_context *context, void *ads, char *name,
+ int name_len, char *rip, int rip_len);
/*
* custom allocator
#define lws_free(P) lws_realloc(P, 0)
#define lws_free2(P) do { lws_realloc(P, 0); (P) = NULL; } while(0)
-/*
- * lws_plat_
- */
+/* lws_plat_ */
LWS_EXTERN void
lws_plat_delete_socket_from_fds(struct lws_context *context,
- struct lws *wsi, int m);
+ struct lws *wsi, int m);
LWS_EXTERN void
lws_plat_insert_socket_into_fds(struct lws_context *context,
- struct lws *wsi);
+ struct lws *wsi);
LWS_EXTERN void
lws_plat_service_periodic(struct lws_context *context);
LWS_EXTERN int
-lws_plat_change_pollfd(struct lws_context *context,
- struct lws *wsi, struct lws_pollfd *pfd);
+lws_plat_change_pollfd(struct lws_context *context, struct lws *wsi,
+ struct lws_pollfd *pfd);
LWS_EXTERN int
lws_plat_context_early_init(void);
LWS_EXTERN void