mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
clean more whitespace 4
Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
d478fb8c38
commit
dc8a3a817a
6 changed files with 179 additions and 206 deletions
39
lib/hpack.c
39
lib/hpack.c
|
@ -585,7 +585,8 @@ pre_data:
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int lws_http2_num(int starting_bits, unsigned long num, unsigned char **p, unsigned char *end)
|
||||
static int lws_http2_num(int starting_bits, unsigned long num,
|
||||
unsigned char **p, unsigned char *end)
|
||||
{
|
||||
int mask = (1 << starting_bits) - 1;
|
||||
|
||||
|
@ -610,12 +611,12 @@ static int lws_http2_num(int starting_bits, unsigned long num, unsigned char **p
|
|||
}
|
||||
|
||||
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)
|
||||
struct lws *wsi,
|
||||
const unsigned char *name,
|
||||
const unsigned char *value,
|
||||
int length,
|
||||
unsigned char **p,
|
||||
unsigned char *end)
|
||||
{
|
||||
int len;
|
||||
|
||||
|
@ -647,13 +648,10 @@ int lws_add_http2_header_by_name(struct lws_context *context,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int lws_add_http2_header_by_token(struct lws_context *context,
|
||||
struct lws *wsi,
|
||||
int 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)
|
||||
{
|
||||
const unsigned char *name;
|
||||
|
||||
|
@ -661,14 +659,13 @@ int lws_add_http2_header_by_token(struct lws_context *context,
|
|||
if (!name)
|
||||
return 1;
|
||||
|
||||
return lws_add_http2_header_by_name(context, wsi, name, value, length, p, end);
|
||||
return lws_add_http2_header_by_name(context, wsi, name, value,
|
||||
length, p, end);
|
||||
}
|
||||
|
||||
int lws_add_http2_header_status(struct lws_context *context,
|
||||
struct lws *wsi,
|
||||
unsigned int code,
|
||||
unsigned char **p,
|
||||
unsigned char *end)
|
||||
int lws_add_http2_header_status(struct lws_context *context, struct lws *wsi,
|
||||
unsigned int code, unsigned char **p,
|
||||
unsigned char *end)
|
||||
{
|
||||
unsigned char status[10];
|
||||
int n;
|
||||
|
@ -676,7 +673,9 @@ int lws_add_http2_header_status(struct lws_context *context,
|
|||
wsi->u.http2.send_END_STREAM = !!(code >= 400);
|
||||
|
||||
n = sprintf((char *)status, "%u", code);
|
||||
if (lws_add_http2_header_by_token(context, wsi, WSI_TOKEN_HTTP_COLON_STATUS, status, n, p, end))
|
||||
if (lws_add_http2_header_by_token(context, wsi,
|
||||
WSI_TOKEN_HTTP_COLON_STATUS, status,
|
||||
n, p, end))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -1009,15 +1009,13 @@ struct lws_extension;
|
|||
* 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
|
||||
/**
|
||||
|
@ -1078,15 +1076,13 @@ typedef int (callback_function)(struct lws_context *context,
|
|||
* 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
|
||||
|
@ -1251,9 +1247,9 @@ struct lws_context_creation_info {
|
|||
#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);
|
||||
|
@ -1310,7 +1306,8 @@ lws_add_http_header_status(struct lws_context *context,
|
|||
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);
|
||||
|
@ -1354,8 +1351,7 @@ enum pending_timeout {
|
|||
};
|
||||
|
||||
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!
|
||||
|
@ -1389,14 +1385,12 @@ lws_set_timeout(struct lws *wsi,
|
|||
* 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 *))
|
||||
|
@ -1410,31 +1404,29 @@ lws_set_timeout(struct lws *wsi,
|
|||
#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);
|
||||
|
@ -1486,37 +1478,26 @@ LWS_VISIBLE LWS_EXTERN size_t
|
|||
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);
|
||||
|
@ -1558,7 +1539,7 @@ lws_hdr_total_length(struct lws *wsi, enum lws_token_indexes h);
|
|||
|
||||
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
|
||||
|
|
|
@ -63,7 +63,8 @@
|
|||
|
||||
#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)) \
|
||||
|
@ -584,7 +585,8 @@ lws_libev_run(struct lws_context *context);
|
|||
#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
|
||||
|
@ -656,7 +658,6 @@ struct _lws_http_mode_related {
|
|||
unsigned int content_remain;
|
||||
};
|
||||
|
||||
|
||||
#ifdef LWS_USE_HTTP2
|
||||
|
||||
enum lws_http2_settings {
|
||||
|
@ -855,8 +856,7 @@ struct lws {
|
|||
#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;
|
||||
|
@ -923,37 +923,39 @@ LWS_EXTERN int log_level;
|
|||
|
||||
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);
|
||||
|
@ -977,8 +979,7 @@ delete_from_fd(struct lws_context *context, lws_sockfd_type fd);
|
|||
#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);
|
||||
|
@ -986,22 +987,21 @@ 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
|
||||
|
@ -1010,20 +1010,19 @@ lws_handle_POLLOUT_event(struct lws_context *context,
|
|||
#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)
|
||||
|
@ -1034,14 +1033,13 @@ lws_ext_callback_for_each_extension_type(
|
|||
|
||||
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);
|
||||
|
@ -1050,48 +1048,42 @@ LWS_EXTERN void
|
|||
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);
|
||||
|
@ -1124,14 +1116,13 @@ lws_change_pollfd(struct lws *wsi, int _and, int _or);
|
|||
#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)
|
||||
|
@ -1145,8 +1136,9 @@ LWS_EXTERN int get_daemonize_pid();
|
|||
#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);
|
||||
|
||||
|
@ -1184,20 +1176,20 @@ lws_ssl_capable_write(struct lws *wsi, unsigned char *buf, int len);
|
|||
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
|
||||
|
@ -1225,28 +1217,32 @@ LWS_EXTERN int
|
|||
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)
|
||||
|
@ -1254,9 +1250,9 @@ lws_ssl_pending_no_ssl(struct lws *wsi);
|
|||
#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
|
||||
|
@ -1271,21 +1267,19 @@ lws_zalloc(size_t size);
|
|||
#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
|
||||
|
|
|
@ -59,7 +59,8 @@ struct alpn_ctx {
|
|||
unsigned short len;
|
||||
};
|
||||
|
||||
static int npn_cb(SSL *s, const unsigned char **data, unsigned int *len, void *arg)
|
||||
static int
|
||||
npn_cb(SSL *s, const unsigned char **data, unsigned int *len, void *arg)
|
||||
{
|
||||
struct alpn_ctx *alpn_ctx = arg;
|
||||
|
||||
|
@ -70,15 +71,15 @@ static int npn_cb(SSL *s, const unsigned char **data, unsigned int *len, void *a
|
|||
return SSL_TLSEXT_ERR_OK;
|
||||
}
|
||||
|
||||
static int alpn_cb(SSL *s, const unsigned char **out,
|
||||
unsigned char *outlen, const unsigned char *in,
|
||||
unsigned int inlen, void *arg)
|
||||
static int
|
||||
alpn_cb(SSL *s, const unsigned char **out, unsigned char *outlen,
|
||||
const unsigned char *in, unsigned int inlen, void *arg)
|
||||
{
|
||||
struct alpn_ctx *alpn_ctx = arg;
|
||||
|
||||
if (SSL_select_next_proto((unsigned char **)out, outlen,
|
||||
alpn_ctx->data, alpn_ctx->len, in, inlen) !=
|
||||
OPENSSL_NPN_NEGOTIATED)
|
||||
if (SSL_select_next_proto((unsigned char **)out, outlen, alpn_ctx->data,
|
||||
alpn_ctx->len, in, inlen) !=
|
||||
OPENSSL_NPN_NEGOTIATED)
|
||||
return SSL_TLSEXT_ERR_NOACK;
|
||||
|
||||
return SSL_TLSEXT_ERR_OK;
|
||||
|
@ -89,10 +90,8 @@ LWS_VISIBLE void
|
|||
lws_context_init_http2_ssl(struct lws_context *context)
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
|
||||
static struct alpn_ctx protos = { (unsigned char *)
|
||||
"\x05h2-14"
|
||||
"\x08http/1.1",
|
||||
6 + 9 };
|
||||
static struct alpn_ctx protos = { (unsigned char *)"\x05h2-14"
|
||||
"\x08http/1.1", 6 + 9 };
|
||||
|
||||
SSL_CTX_set_next_protos_advertised_cb(context->ssl_ctx, npn_cb, &protos);
|
||||
|
||||
|
@ -110,9 +109,9 @@ void lws_http2_configure_if_upgraded(struct lws *wsi)
|
|||
{
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
|
||||
struct allocated_headers *ah;
|
||||
const char *method = "alpn";
|
||||
const unsigned char *name;
|
||||
unsigned len;
|
||||
const char *method = "alpn";
|
||||
|
||||
SSL_get0_alpn_selected(wsi->ssl, &name, &len);
|
||||
|
||||
|
@ -151,4 +150,4 @@ void lws_http2_configure_if_upgraded(struct lws *wsi)
|
|||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -329,7 +329,7 @@ int callback_http(struct lws_context *context, struct lws *wsi,
|
|||
n = m;
|
||||
|
||||
n = read(pss->fd, buffer + LWS_SEND_BUFFER_PRE_PADDING,
|
||||
n);
|
||||
n);
|
||||
/* problem reading, close conn */
|
||||
if (n < 0)
|
||||
goto bail;
|
||||
|
@ -343,9 +343,8 @@ int callback_http(struct lws_context *context, struct lws *wsi,
|
|||
* is handled by the library itself if you sent a
|
||||
* content-length header
|
||||
*/
|
||||
m = lws_write(wsi,
|
||||
buffer + LWS_SEND_BUFFER_PRE_PADDING,
|
||||
n, LWS_WRITE_HTTP);
|
||||
m = lws_write(wsi, buffer + LWS_SEND_BUFFER_PRE_PADDING,
|
||||
n, LWS_WRITE_HTTP);
|
||||
if (m < 0)
|
||||
/* write failed, close conn */
|
||||
goto bail;
|
||||
|
@ -360,9 +359,10 @@ int callback_http(struct lws_context *context, struct lws *wsi,
|
|||
|
||||
if (m) /* while still active, extend timeout */
|
||||
lws_set_timeout(wsi,
|
||||
PENDING_TIMEOUT_HTTP_CONTENT, 5);
|
||||
PENDING_TIMEOUT_HTTP_CONTENT, 5);
|
||||
|
||||
/* if we have indigestion, let him clear it before eating more */
|
||||
/* if we have indigestion, let him clear it
|
||||
* before eating more */
|
||||
if (lws_partial_buffered(wsi))
|
||||
break;
|
||||
|
||||
|
|
|
@ -259,8 +259,8 @@ int main(int argc, char **argv)
|
|||
lws_set_log_level(debug_level, lwsl_emit_syslog);
|
||||
|
||||
lwsl_notice("libwebsockets test server - "
|
||||
"(C) Copyright 2010-2015 Andy Green <andy@warmcat.com> - "
|
||||
"licensed under LGPL2.1\n");
|
||||
"(C) Copyright 2010-2015 Andy Green <andy@warmcat.com> - "
|
||||
"licensed under LGPL2.1\n");
|
||||
|
||||
printf("Using resource path \"%s\"\n", resource_path);
|
||||
#ifdef EXTERNAL_POLL
|
||||
|
@ -288,13 +288,13 @@ int main(int argc, char **argv)
|
|||
return -1;
|
||||
}
|
||||
sprintf(cert_path, "%s/libwebsockets-test-server.pem",
|
||||
resource_path);
|
||||
resource_path);
|
||||
if (strlen(resource_path) > sizeof(key_path) - 32) {
|
||||
lwsl_err("resource path too long\n");
|
||||
return -1;
|
||||
}
|
||||
sprintf(key_path, "%s/libwebsockets-test-server.key.pem",
|
||||
resource_path);
|
||||
resource_path);
|
||||
|
||||
info.ssl_cert_filepath = cert_path;
|
||||
info.ssl_private_key_filepath = key_path;
|
||||
|
|
Loading…
Add table
Reference in a new issue