libwebsockets.h (2.3.0) | | libwebsockets.h (2.4.0) |
| | |
skipping to change at line 169 ¶ | | skipping to change at line 169 ¶ |
#define LWS_FORMAT(string_index) | | #define LWS_FORMAT(string_index) |
#endif | | #endif |
| | |
#if defined(__ANDROID__) | | #if defined(__ANDROID__) |
#include <unistd.h> | | #include <unistd.h> |
#define getdtablesize() sysconf(_SC_OPEN_MAX) | | #define getdtablesize() sysconf(_SC_OPEN_MAX) |
#endif | | #endif |
| | |
#endif | | #endif |
| | |
#ifdef LWS_USE_LIBEV | | #ifdef LWS_WITH_LIBEV |
#include <ev.h> | | #include <ev.h> |
#endif /* LWS_USE_LIBEV */ | | #endif /* LWS_WITH_LIBEV */ |
#ifdef LWS_USE_LIBUV | | #ifdef LWS_WITH_LIBUV |
#include <uv.h> | | #include <uv.h> |
#ifdef LWS_HAVE_UV_VERSION_H | | #ifdef LWS_HAVE_UV_VERSION_H |
#include <uv-version.h> | | #include <uv-version.h> |
#endif | | #endif |
#endif /* LWS_USE_LIBUV */ | | #endif /* LWS_WITH_LIBUV */ |
#ifdef LWS_USE_LIBEVENT | | #ifdef LWS_WITH_LIBEVENT |
#include <event2/event.h> | | #include <event2/event.h> |
#endif /* LWS_USE_LIBEVENT */ | | #endif /* LWS_WITH_LIBEVENT */ |
| | |
#ifndef LWS_EXTERN | | #ifndef LWS_EXTERN |
#define LWS_EXTERN extern | | #define LWS_EXTERN extern |
#endif | | #endif |
| | |
#ifdef _WIN32 | | #ifdef _WIN32 |
#define random rand | | #define random rand |
#else | | #else |
#if !defined(OPTEE_TA) | | #if !defined(OPTEE_TA) |
#include <sys/time.h> | | #include <sys/time.h> |
| | |
skipping to change at line 206 ¶ | | skipping to change at line 206 ¶ |
| | |
#ifdef USE_WOLFSSL | | #ifdef USE_WOLFSSL |
#ifdef USE_OLD_CYASSL | | #ifdef USE_OLD_CYASSL |
#include <cyassl/openssl/ssl.h> | | #include <cyassl/openssl/ssl.h> |
#include <cyassl/error-ssl.h> | | #include <cyassl/error-ssl.h> |
#else | | #else |
#include <wolfssl/openssl/ssl.h> | | #include <wolfssl/openssl/ssl.h> |
#include <wolfssl/error-ssl.h> | | #include <wolfssl/error-ssl.h> |
#endif /* not USE_OLD_CYASSL */ | | #endif /* not USE_OLD_CYASSL */ |
#else | | #else |
| | #if defined(LWS_WITH_MBEDTLS) |
| | #if defined(LWS_WITH_ESP32) |
| | /* this filepath is passed to us but without quotes or <> */ |
| | #undef MBEDTLS_CONFIG_FILE |
| | #define MBEDTLS_CONFIG_FILE <mbedtls/esp_config.h> |
| | #endif |
| | #include <mbedtls/ssl.h> |
| | #endif |
#include <openssl/ssl.h> | | #include <openssl/ssl.h> |
#if !defined(LWS_WITH_ESP32) | | #if !defined(LWS_WITH_MBEDTLS) |
#include <openssl/err.h> | | #include <openssl/err.h> |
#endif | | #endif |
#endif /* not USE_WOLFSSL */ | | #endif /* not USE_WOLFSSL */ |
#endif | | #endif |
| | |
#define CONTEXT_PORT_NO_LISTEN -1 | | #define CONTEXT_PORT_NO_LISTEN -1 |
#define CONTEXT_PORT_NO_LISTEN_SERVER -2 | | #define CONTEXT_PORT_NO_LISTEN_SERVER -2 |
| | |
/** \defgroup log Logging | | /** \defgroup log Logging |
* | | * |
| | |
skipping to change at line 291 ¶ | | skipping to change at line 299 ¶ |
#define lwsl_warn(...) _lws_log(LLL_WARN, __VA_ARGS__) | | #define lwsl_warn(...) _lws_log(LLL_WARN, __VA_ARGS__) |
#define lwsl_notice(...) _lws_log(LLL_NOTICE, __VA_ARGS__) | | #define lwsl_notice(...) _lws_log(LLL_NOTICE, __VA_ARGS__) |
#endif | | #endif |
#define lwsl_info(...) _lws_log(LLL_INFO, __VA_ARGS__) | | #define lwsl_info(...) _lws_log(LLL_INFO, __VA_ARGS__) |
#define lwsl_debug(...) _lws_log(LLL_DEBUG, __VA_ARGS__) | | #define lwsl_debug(...) _lws_log(LLL_DEBUG, __VA_ARGS__) |
#define lwsl_parser(...) _lws_log(LLL_PARSER, __VA_ARGS__) | | #define lwsl_parser(...) _lws_log(LLL_PARSER, __VA_ARGS__) |
#define lwsl_header(...) _lws_log(LLL_HEADER, __VA_ARGS__) | | #define lwsl_header(...) _lws_log(LLL_HEADER, __VA_ARGS__) |
#define lwsl_ext(...) _lws_log(LLL_EXT, __VA_ARGS__) | | #define lwsl_ext(...) _lws_log(LLL_EXT, __VA_ARGS__) |
#define lwsl_client(...) _lws_log(LLL_CLIENT, __VA_ARGS__) | | #define lwsl_client(...) _lws_log(LLL_CLIENT, __VA_ARGS__) |
#define lwsl_latency(...) _lws_log(LLL_LATENCY, __VA_ARGS__) | | #define lwsl_latency(...) _lws_log(LLL_LATENCY, __VA_ARGS__) |
/** | | |
* lwsl_hexdump() - helper to hexdump a buffer (DEBUG builds only) | | |
* | | |
* \param buf: buffer start to dump | | |
* \param len: length of buffer to dump | | |
*/ | | |
LWS_VISIBLE LWS_EXTERN void lwsl_hexdump(void *buf, size_t len); | | |
| | |
#else /* no debug */ | | #else /* no debug */ |
#if defined(LWS_WITH_NO_LOGS) | | #if defined(LWS_WITH_NO_LOGS) |
#define lwsl_warn(...) do {} while(0) | | #define lwsl_warn(...) do {} while(0) |
#define lwsl_notice(...) do {} while(0) | | #define lwsl_notice(...) do {} while(0) |
#endif | | #endif |
#define lwsl_info(...) do {} while(0) | | #define lwsl_info(...) do {} while(0) |
#define lwsl_debug(...) do {} while(0) | | #define lwsl_debug(...) do {} while(0) |
#define lwsl_parser(...) do {} while(0) | | #define lwsl_parser(...) do {} while(0) |
#define lwsl_header(...) do {} while(0) | | #define lwsl_header(...) do {} while(0) |
#define lwsl_ext(...) do {} while(0) | | #define lwsl_ext(...) do {} while(0) |
#define lwsl_client(...) do {} while(0) | | #define lwsl_client(...) do {} while(0) |
#define lwsl_latency(...) do {} while(0) | | #define lwsl_latency(...) do {} while(0) |
#define lwsl_hexdump(a, b) | | |
| | |
#endif | | #endif |
| | |
| | /** |
| | * lwsl_hexdump() - helper to hexdump a buffer |
| | * |
| | * \param level: one of LLL_ constants |
| | * \param buf: buffer start to dump |
| | * \param len: length of buffer to dump |
| | * |
| | * If \p level is visible, does a nice hexdump -C style dump of \p buf for |
| | * \p len bytes. This can be extremely convenient while debugging. |
| | */ |
| | LWS_VISIBLE LWS_EXTERN void |
| | lwsl_hexdump_level(int level, const void *vbuf, size_t len); |
| | |
| | /** |
| | * lwsl_hexdump() - helper to hexdump a buffer (DEBUG builds only) |
| | * |
| | * \param buf: buffer start to dump |
| | * \param len: length of buffer to dump |
| | * |
| | * Calls through to lwsl_hexdump_level(LLL_DEBUG, ... for compatability. |
| | * It's better to use lwsl_hexdump_level(level, ... directly so you can con |
| | trol |
| | * the visibility. |
| | */ |
| | LWS_VISIBLE LWS_EXTERN void |
| | lwsl_hexdump(const void *buf, size_t len); |
| | |
| | /** |
| | * lws_is_be() - returns nonzero if the platform is Big Endian |
| | */ |
static LWS_INLINE int lws_is_be(void) { | | static LWS_INLINE int lws_is_be(void) { |
const int probe = ~0xff; | | const int probe = ~0xff; |
| | |
return *(const char *)&probe; | | return *(const char *)&probe; |
} | | } |
| | |
/** | | /** |
* lws_set_log_level() - Set the logging bitfield | | * lws_set_log_level() - Set the logging bitfield |
* \param level: OR together the LLL_ debug contexts you want output
from | | * \param level: OR together the LLL_ debug contexts you want output
from |
* \param log_emit_function: NULL to leave it as it is, or a user-supplie
d | | * \param log_emit_function: NULL to leave it as it is, or a user-supplie
d |
* function to perform log string emission instead of | | * function to perform log string emission instead of |
* the default stderr one. | | * the default stderr one. |
* | | * |
* log level defaults to "err", "warn" and "notice" contexts enabled an
d | | * log level defaults to "err", "warn" and "notice" contexts enabled an
d |
* emission on stderr. | | * emission on stderr. If stderr is a tty (according to isatty()) then |
| | * the output is coloured according to the log level using ANSI escapes |
| | . |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN void | | LWS_VISIBLE LWS_EXTERN void |
lws_set_log_level(int level, | | lws_set_log_level(int level, |
void (*log_emit_function)(int level, const char *line)); | | void (*log_emit_function)(int level, const char *line)); |
| | |
/** | | /** |
* lwsl_emit_syslog() - helper log emit function writes to system log | | * lwsl_emit_syslog() - helper log emit function writes to system log |
* | | * |
* \param level: one of LLL_ log level indexes | | * \param level: one of LLL_ log level indexes |
* \param line: log string | | * \param line: log string |
| | |
skipping to change at line 633 ¶ | | skipping to change at line 663 ¶ |
}; | | }; |
| | |
struct lws_esp32_image { | | struct lws_esp32_image { |
uint32_t romfs; | | uint32_t romfs; |
uint32_t romfs_len; | | uint32_t romfs_len; |
uint32_t json; | | uint32_t json; |
uint32_t json_len; | | uint32_t json_len; |
}; | | }; |
| | |
extern struct lws_esp32 lws_esp32; | | extern struct lws_esp32 lws_esp32; |
| | struct lws_vhost; |
| | |
extern esp_err_t | | extern esp_err_t |
lws_esp32_event_passthru(void *ctx, system_event_t *event); | | lws_esp32_event_passthru(void *ctx, system_event_t *event); |
extern void | | extern void |
lws_esp32_wlan_config(void); | | lws_esp32_wlan_config(void); |
extern void | | extern void |
lws_esp32_wlan_start_ap(void); | | lws_esp32_wlan_start_ap(void); |
extern void | | extern void |
lws_esp32_wlan_start_station(void); | | lws_esp32_wlan_start_station(void); |
struct lws_context_creation_info; | | struct lws_context_creation_info; |
extern void | | extern void |
lws_esp32_set_creation_defaults(struct lws_context_creation_info *info); | | lws_esp32_set_creation_defaults(struct lws_context_creation_info *info); |
extern struct lws_context * | | extern struct lws_context * |
lws_esp32_init(struct lws_context_creation_info *); | | lws_esp32_init(struct lws_context_creation_info *, struct lws_vhost **pvh); |
extern int | | extern int |
lws_esp32_wlan_nvs_get(int retry); | | lws_esp32_wlan_nvs_get(int retry); |
extern esp_err_t | | extern esp_err_t |
lws_nvs_set_str(nvs_handle handle, const char* key, const char* value); | | lws_nvs_set_str(nvs_handle handle, const char* key, const char* value); |
extern void | | extern void |
lws_esp32_restart_guided(uint32_t type); | | lws_esp32_restart_guided(uint32_t type); |
extern const esp_partition_t * | | extern const esp_partition_t * |
lws_esp_ota_get_boot_partition(void); | | lws_esp_ota_get_boot_partition(void); |
extern int | | extern int |
lws_esp32_get_image_info(const esp_partition_t *part, struct lws_esp32_imag
e *i, char *json, int json_len); | | lws_esp32_get_image_info(const esp_partition_t *part, struct lws_esp32_imag
e *i, char *json, int json_len); |
| | |
skipping to change at line 1183 ¶ | | skipping to change at line 1214 ¶ |
LWS_CALLBACK_WS_PEER_INITIATED_CLOSE = 38, | | LWS_CALLBACK_WS_PEER_INITIATED_CLOSE = 38, |
/**< The peer has sent an unsolicited Close WS packet. in and | | /**< The peer has sent an unsolicited Close WS packet. in and |
* len are the optional close code (first 2 bytes, network | | * len are the optional close code (first 2 bytes, network |
* order) and the optional additional information which is not | | * order) and the optional additional information which is not |
* defined in the standard, and may be a string or non-human- readab
le data. | | * defined in the standard, and may be a string or non-human- readab
le data. |
* If you return 0 lws will echo the close and then close the | | * If you return 0 lws will echo the close and then close the |
* connection. If you return nonzero lws will just close the | | * connection. If you return nonzero lws will just close the |
* connection. */ | | * connection. */ |
| | |
LWS_CALLBACK_WS_EXT_DEFAULTS = 39, | | LWS_CALLBACK_WS_EXT_DEFAULTS = 39, |
/**< */ | | /**< Gives client connections an opportunity to adjust negotiated |
| | * extension defaults. `user` is the extension name that was |
| | * negotiated (eg, "permessage-deflate"). `in` points to a |
| | * buffer and `len` is the buffer size. The user callback can |
| | * set the buffer to a string describing options the extension |
| | * should parse. Or just ignore for defaults. */ |
| | |
LWS_CALLBACK_CGI = 40, | | LWS_CALLBACK_CGI = 40, |
/**< */ | | /**< CGI: CGI IO events on stdin / out / err are sent here on |
| | * protocols[0]. The provided `lws_callback_http_dummy()` |
| | * handles this and the callback should be directed there if |
| | * you use CGI. */ |
LWS_CALLBACK_CGI_TERMINATED = 41, | | LWS_CALLBACK_CGI_TERMINATED = 41, |
/**< */ | | /**< CGI: The related CGI process ended, this is called before |
| | * the wsi is closed. Used to, eg, terminate chunking. |
| | * The provided `lws_callback_http_dummy()` |
| | * handles this and the callback should be directed there if |
| | * you use CGI. The child PID that terminated is in len. */ |
LWS_CALLBACK_CGI_STDIN_DATA = 42, | | LWS_CALLBACK_CGI_STDIN_DATA = 42, |
/**< */ | | /**< CGI: Data is, to be sent to the CGI process stdin, eg from |
| | * a POST body. The provided `lws_callback_http_dummy()` |
| | * handles this and the callback should be directed there if |
| | * you use CGI. */ |
LWS_CALLBACK_CGI_STDIN_COMPLETED = 43, | | LWS_CALLBACK_CGI_STDIN_COMPLETED = 43, |
/**< */ | | /**< CGI: no more stdin is coming. The provided |
| | * `lws_callback_http_dummy()` handles this and the callback |
| | * should be directed there if you use CGI. */ |
LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP = 44, | | LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP = 44, |
/**< */ | | /**< The HTTP client connection has succeeded, and is now |
| | * connected to the server */ |
LWS_CALLBACK_CLOSED_CLIENT_HTTP = 45, | | LWS_CALLBACK_CLOSED_CLIENT_HTTP = 45, |
/**< */ | | /**< The HTTP client connection is closing */ |
LWS_CALLBACK_RECEIVE_CLIENT_HTTP = 46, | | LWS_CALLBACK_RECEIVE_CLIENT_HTTP = 46, |
/**< */ | | /**< This simply indicates data was received on the HTTP client |
| | * connection. It does NOT drain or provide the data. |
| | * This exists to neatly allow a proxying type situation, |
| | * where this incoming data will go out on another connection. |
| | * If the outgoing connection stalls, we should stall processing |
| | * the incoming data. So a handler for this in that case should |
| | * simply set a flag to indicate there is incoming data ready |
| | * and ask for a writeable callback on the outgoing connection. |
| | * In the writable callback he can check the flag and then get |
| | * and drain the waiting incoming data using lws_http_client_read(). |
| | * This will use callbacks to LWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ |
| | * to get and drain the incoming data, where it should be sent |
| | * back out on the outgoing connection. */ |
LWS_CALLBACK_COMPLETED_CLIENT_HTTP = 47, | | LWS_CALLBACK_COMPLETED_CLIENT_HTTP = 47, |
/**< */ | | /**< The client transaction completed... at the moment this |
| | * is the same as closing since transaction pipelining on |
| | * client side is not yet supported. */ |
LWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ = 48, | | LWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ = 48, |
/**< */ | | /**< This is generated by lws_http_client_read() used to drain |
| | * incoming data. In the case the incoming data was chunked, |
| | * it will be split into multiple smaller callbacks for each |
| | * chunk block, removing the chunk headers. If not chunked, |
| | * it will appear all in one callback. */ |
LWS_CALLBACK_HTTP_BIND_PROTOCOL = 49, | | LWS_CALLBACK_HTTP_BIND_PROTOCOL = 49, |
/**< */ | | /**< By default, all HTTP handling is done in protocols[0]. |
| | * However you can bind different protocols (by name) to |
| | * different parts of the URL space using callback mounts. This |
| | * callback occurs in the new protocol when a wsi is bound |
| | * to that protocol. Any protocol allocation related to the |
| | * http transaction processing should be created then. |
| | * These specific callbacks are necessary because with HTTP/1.1, |
| | * a single connection may perform at series of different |
| | * transactions at different URLs, thus the lifetime of the |
| | * protocol bind is just for one transaction, not connection. */ |
LWS_CALLBACK_HTTP_DROP_PROTOCOL = 50, | | LWS_CALLBACK_HTTP_DROP_PROTOCOL = 50, |
/**< */ | | /**< This is called when a transaction is unbound from a protocol. |
| | * It indicates the connection completed its transaction and may |
| | * do something different now. Any protocol allocation related |
| | * to the http transaction processing should be destroyed. */ |
LWS_CALLBACK_CHECK_ACCESS_RIGHTS = 51, | | LWS_CALLBACK_CHECK_ACCESS_RIGHTS = 51, |
/**< */ | | /**< This gives the user code a chance to forbid an http access. |
| | * `in` points to a `struct lws_process_html_args`, which |
| | * describes the URL, and a bit mask describing the type of |
| | * authentication required. If the callback returns nonzero, |
| | * the transaction ends with HTTP_STATUS_UNAUTHORIZED. */ |
LWS_CALLBACK_PROCESS_HTML = 52, | | LWS_CALLBACK_PROCESS_HTML = 52, |
/**< */ | | /**< This gives your user code a chance to mangle outgoing |
| | * HTML. `in` points to a `struct lws_process_html_args` |
| | * which describes the buffer containing outgoing HTML. |
| | * The buffer may grow up to `.max_len` (currently +128 |
| | * bytes per buffer). |
| | * */ |
LWS_CALLBACK_ADD_HEADERS = 53, | | LWS_CALLBACK_ADD_HEADERS = 53, |
/**< */ | | /**< This gives your user code a chance to add headers to a |
| | * transaction bound to your protocol. `in` points to a |
| | * `struct lws_process_html_args` describing a buffer and length |
| | * you can add headers into using the normal lws apis. |
| | * |
| | * Only `args->p` and `args->len` are valid, and `args->p` should |
| | * be moved on by the amount of bytes written, if any. Eg |
| | * |
| | * case LWS_CALLBACK_ADD_HEADERS: |
| | * |
| | * struct lws_process_html_args *args = |
| | * (struct lws_process_html_args *)in; |
| | * |
| | * if (lws_add_http_header_by_name(wsi, |
| | * (unsigned char *)"set-cookie:", |
| | * (unsigned char *)cookie, cookie_len, |
| | * (unsigned char **)&args->p, |
| | * (unsigned char *)args->p + args->max_len)) |
| | * return 1; |
| | * |
| | * break; |
| | */ |
LWS_CALLBACK_SESSION_INFO = 54, | | LWS_CALLBACK_SESSION_INFO = 54, |
/**< */ | | /**< This is only generated by user code using generic sessions. |
| | * It's used to get a `struct lws_session_info` filled in by |
| | * generic sessions with information about the logged-in user. |
| | * See the messageboard sample for an example of how to use. */ |
| | |
LWS_CALLBACK_GS_EVENT = 55, | | LWS_CALLBACK_GS_EVENT = 55, |
/**< */ | | /**< Indicates an event happened to the Generic Sessions session. |
| | * `in` contains a `struct lws_gs_event_args` describing the event. |
| | */ |
LWS_CALLBACK_HTTP_PMO = 56, | | LWS_CALLBACK_HTTP_PMO = 56, |
/**< per-mount options for this connection, called before | | /**< per-mount options for this connection, called before |
* the normal LWS_CALLBACK_HTTP when the mount has per-mount | | * the normal LWS_CALLBACK_HTTP when the mount has per-mount |
* options | | * options. |
*/ | | */ |
LWS_CALLBACK_CLIENT_HTTP_WRITEABLE = 57, | | LWS_CALLBACK_CLIENT_HTTP_WRITEABLE = 57, |
/**< when doing an HTTP type client connection, you can call | | /**< when doing an HTTP type client connection, you can call |
* lws_client_http_body_pending(wsi, 1) from | | * lws_client_http_body_pending(wsi, 1) from |
* LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER to get these callback
s | | * LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER to get these callback
s |
* sending the HTTP headers. | | * sending the HTTP headers. |
* | | * |
* From this callback, when you have sent everything, you should let | | * From this callback, when you have sent everything, you should let |
* lws know by calling lws_client_http_body_pending(wsi, 0) | | * lws know by calling lws_client_http_body_pending(wsi, 0) |
*/ | | */ |
| | |
skipping to change at line 1281 ¶ | | skipping to change at line 1394 ¶ |
/**< RAW mode file was adopted (equivalent to 'wsi created') */ | | /**< RAW mode file was adopted (equivalent to 'wsi created') */ |
LWS_CALLBACK_RAW_RX_FILE = 64, | | LWS_CALLBACK_RAW_RX_FILE = 64, |
/**< RAW mode file has something to read */ | | /**< RAW mode file has something to read */ |
LWS_CALLBACK_RAW_WRITEABLE_FILE = 65, | | LWS_CALLBACK_RAW_WRITEABLE_FILE = 65, |
/**< RAW mode file is writeable */ | | /**< RAW mode file is writeable */ |
LWS_CALLBACK_RAW_CLOSE_FILE = 66, | | LWS_CALLBACK_RAW_CLOSE_FILE = 66, |
/**< RAW mode wsi that adopted a file is closing */ | | /**< RAW mode wsi that adopted a file is closing */ |
LWS_CALLBACK_SSL_INFO = 67, | | LWS_CALLBACK_SSL_INFO = 67, |
/**< SSL connections only. An event you registered an | | /**< SSL connections only. An event you registered an |
* interest in at the vhost has occurred on a connection | | * interest in at the vhost has occurred on a connection |
* using the vhost. @in is a pointer to a | | * using the vhost. in is a pointer to a |
* struct lws_ssl_info containing information about the | | * struct lws_ssl_info containing information about the |
* event*/ | | * event*/ |
LWS_CALLBACK_CHILD_WRITE_VIA_PARENT = 68, | | LWS_CALLBACK_CHILD_WRITE_VIA_PARENT = 68, |
/**< Child has been marked with parent_carries_io attribute, so | | /**< Child has been marked with parent_carries_io attribute, so |
* lws_write directs the to this callback at the parent, | | * lws_write directs the to this callback at the parent, |
* @in is a struct lws_write_passthru containing the args | | * in is a struct lws_write_passthru containing the args |
* the lws_write() was called with. | | * the lws_write() was called with. |
*/ | | */ |
LWS_CALLBACK_CHILD_CLOSING = 69, | | LWS_CALLBACK_CHILD_CLOSING = 69, |
/**< Sent to parent to notify them a child is closing / being | | /**< Sent to parent to notify them a child is closing / being |
* destroyed. @in is the child wsi. | | * destroyed. in is the child wsi. |
*/ | | */ |
| | LWS_CALLBACK_CGI_PROCESS_ATTACH = 70, |
| | /**< CGI: Sent when the CGI process is spawned for the wsi. The |
| | * len parameter is the PID of the child process */ |
| | |
/****** add new things just above ---^ ******/ | | /****** add new things just above ---^ ******/ |
| | |
LWS_CALLBACK_USER = 1000, | | LWS_CALLBACK_USER = 1000, |
/**< user code can use any including above without fear of clashes
*/ | | /**< user code can use any including above without fear of clashes
*/ |
}; | | }; |
| | |
/** | | /** |
* typedef lws_callback_function() - User server actions | | * typedef lws_callback_function() - User server actions |
* \param wsi: Opaque websocket instance pointer | | * \param wsi: Opaque websocket instance pointer |
| | |
skipping to change at line 1319 ¶ | | skipping to change at line 1435 ¶ |
* This callback is the way the user controls what is served. All the | | * This callback is the way the user controls what is served. All the |
* protocol detail is hidden and handled by the library. | | * protocol detail is hidden and handled by the library. |
* | | * |
* For each connection / session there is user data allocated that is | | * For each connection / session there is user data allocated that is |
* pointed to by "user". You set the size of this user data area when | | * pointed to by "user". You set the size of this user data area when |
* the library is initialized with lws_create_server. | | * the library is initialized with lws_create_server. |
*/ | | */ |
typedef int | | typedef int |
lws_callback_function(struct lws *wsi, enum lws_callback_reasons reason, | | lws_callback_function(struct lws *wsi, enum lws_callback_reasons reason, |
void *user, void *in, size_t len); | | void *user, void *in, size_t len); |
| | |
| | #define LWS_CB_REASON_AUX_BF__CGI 1 |
| | #define LWS_CB_REASON_AUX_BF__PROXY 2 |
| | #define LWS_CB_REASON_AUX_BF__CGI_CHUNK_END 4 |
| | #define LWS_CB_REASON_AUX_BF__CGI_HEADERS 8 |
///@} | | ///@} |
| | |
/*! \defgroup extensions | | /*! \defgroup generic hash |
| | * ## Generic Hash related functions |
| | * |
| | * Lws provides generic hash / digest accessors that abstract the ones |
| | * provided by whatever OpenSSL library you are linking against. |
* | | * |
| | * It lets you use the same code if you build against mbedtls or OpenSSL |
| | * for example. |
| | */ |
| | ///@{ |
| | |
| | #ifdef LWS_OPENSSL_SUPPORT |
| | |
| | #if defined(LWS_WITH_MBEDTLS) |
| | #include <mbedtls/sha1.h> |
| | #include <mbedtls/sha256.h> |
| | #include <mbedtls/sha512.h> |
| | #endif |
| | |
| | #define LWS_GENHASH_TYPE_SHA1 0 |
| | #define LWS_GENHASH_TYPE_SHA256 1 |
| | #define LWS_GENHASH_TYPE_SHA512 2 |
| | |
| | struct lws_genhash_ctx { |
| | uint8_t type; |
| | #if defined(LWS_WITH_MBEDTLS) |
| | union { |
| | mbedtls_sha1_context sha1; |
| | mbedtls_sha256_context sha256; |
| | mbedtls_sha512_context sha512; |
| | } u; |
| | #else |
| | const EVP_MD *evp_type; |
| | EVP_MD_CTX *mdctx; |
| | #endif |
| | }; |
| | |
| | /** lws_genhash_size() - get hash size in bytes |
| | * |
| | * \param type: one of LWS_GENHASH_TYPE_... |
| | * |
| | * Returns number of bytes in this type of hash |
| | */ |
| | LWS_VISIBLE LWS_EXTERN size_t LWS_WARN_UNUSED_RESULT |
| | lws_genhash_size(int type); |
| | |
| | /** lws_genhash_init() - prepare your struct lws_genhash_ctx for use |
| | * |
| | * \param ctx: your struct lws_genhash_ctx |
| | * \param type: one of LWS_GENHASH_TYPE_... |
| | * |
| | * Initializes the hash context for the type you requested |
| | */ |
| | LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT |
| | lws_genhash_init(struct lws_genhash_ctx *ctx, int type); |
| | |
| | /** lws_genhash_update() - digest len bytes of the buffer starting at in |
| | * |
| | * \param ctx: your struct lws_genhash_ctx |
| | * \param in: start of the bytes to digest |
| | * \param len: count of bytes to digest |
| | * |
| | * Updates the state of your hash context to reflect digesting len bytes fr |
| | om in |
| | */ |
| | LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT |
| | lws_genhash_update(struct lws_genhash_ctx *ctx, const void *in, size_t len) |
| | ; |
| | |
| | /** lws_genhash_destroy() - copy out the result digest and destroy the ctx |
| | * |
| | * \param ctx: your struct lws_genhash_ctx |
| | * \param result: NULL, or where to copy the result hash |
| | * |
| | * Finalizes the hash and copies out the digest. Destroys any allocations |
| | such |
| | * that ctx can safely go out of scope after calling this. |
| | * |
| | * NULL result is supported so that you can destroy the ctx cleanly on erro |
| | r |
| | * conditions, where there is no valid result. |
| | */ |
| | LWS_VISIBLE LWS_EXTERN int |
| | lws_genhash_destroy(struct lws_genhash_ctx *ctx, void *result); |
| | |
| | #endif |
| | |
| | ///@} |
| | |
| | /*! \defgroup extensions Extension related functions |
* ##Extension releated functions | | * ##Extension releated functions |
* | | * |
* Ws defines optional extensions, lws provides the ability to implement t
hese | | * Ws defines optional extensions, lws provides the ability to implement t
hese |
* in user code if so desired. | | * in user code if so desired. |
* | | * |
* We provide one extensions permessage-deflate. | | * We provide one extensions permessage-deflate. |
*/ | | */ |
///@{ | | ///@{ |
| | |
/* | | /* |
| | |
skipping to change at line 1656 ¶ | | skipping to change at line 1861 ¶ |
* \param vhost: vhost the instance is related to | | * \param vhost: vhost the instance is related to |
* \param prot: protocol the instance is related to | | * \param prot: protocol the instance is related to |
* | | * |
* Recover a pointer to the allocated per-vhost storage for the protocol cr
eated | | * Recover a pointer to the allocated per-vhost storage for the protocol cr
eated |
* by lws_protocol_vh_priv_zalloc() earlier | | * by lws_protocol_vh_priv_zalloc() earlier |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN void * | | LWS_VISIBLE LWS_EXTERN void * |
lws_protocol_vh_priv_get(struct lws_vhost *vhost, const struct lws_protocol
s *prot); | | lws_protocol_vh_priv_get(struct lws_vhost *vhost, const struct lws_protocol
s *prot); |
| | |
/** | | /** |
| | * lws_adjust_protocol_psds - change a vhost protocol's per session data si |
| | ze |
| | * |
| | * \param wsi: a connection with the protocol to change |
| | * \param new_size: the new size of the per session data size for the proto |
| | col |
| | * |
| | * Returns user_space for the wsi, after allocating |
| | * |
| | * This should not be used except to initalize a vhost protocol's per sessi |
| | on |
| | * data size one time, before any connections are accepted. |
| | * |
| | * Sometimes the protocol wraps another protocol and needs to discover and |
| | set |
| | * its per session data size at runtime. |
| | */ |
| | LWS_VISIBLE LWS_EXTERN void * |
| | lws_adjust_protocol_psds(struct lws *wsi, size_t new_size); |
| | |
| | /** |
* lws_finalize_startup() - drop initial process privileges | | * lws_finalize_startup() - drop initial process privileges |
* | | * |
* \param context: lws context | | * \param context: lws context |
* | | * |
* This is called after the end of the vhost protocol initializations, but | | * This is called after the end of the vhost protocol initializations, but |
* you may choose to call it earlier | | * you may choose to call it earlier |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_finalize_startup(struct lws_context *context); | | lws_finalize_startup(struct lws_context *context); |
| | |
| | |
skipping to change at line 1756 ¶ | | skipping to change at line 1978 ¶ |
| | |
/** struct lws_gs_event_args */ | | /** struct lws_gs_event_args */ |
struct lws_gs_event_args { | | struct lws_gs_event_args { |
enum lws_gs_event event; /**< which event happened */ | | enum lws_gs_event event; /**< which event happened */ |
const char *username; /**< which username the event happened to */ | | const char *username; /**< which username the event happened to */ |
const char *email; /**< the email address of that user */ | | const char *email; /**< the email address of that user */ |
}; | | }; |
| | |
///@} | | ///@} |
| | |
/*! \defgroup context-and-vhost | | /*! \defgroup context-and-vhost context and vhost related functions |
| | * ##Context and Vhost releated functions |
* \ingroup lwsapi | | * \ingroup lwsapi |
* | | * |
* ##Context and Vhost releated functions | | |
* | | * |
* LWS requires that there is one context, in which you may define multipl
e | | * LWS requires that there is one context, in which you may define multipl
e |
* vhosts. Each vhost is a virtual host, with either its own listen port | | * vhosts. Each vhost is a virtual host, with either its own listen port |
* or sharing an existing one. Each vhost has its own SSL context that ca
n | | * or sharing an existing one. Each vhost has its own SSL context that ca
n |
* be set up individually or left disabled. | | * be set up individually or left disabled. |
* | | * |
* If you don't care about multiple "site" support, you can ignore it and | | * If you don't care about multiple "site" support, you can ignore it and |
* lws will create a single default vhost at context creation time. | | * lws will create a single default vhost at context creation time. |
*/ | | */ |
///@{ | | ///@{ |
| | |
skipping to change at line 1851 ¶ | | skipping to change at line 2073 ¶ |
LWS_SERVER_OPTION_ONLY_RAW = (1 << 22), | | LWS_SERVER_OPTION_ONLY_RAW = (1 << 22), |
/**< (VH) All connections to this vhost / port are RAW as soon as | | /**< (VH) All connections to this vhost / port are RAW as soon as |
* the connection is accepted, no HTTP is going to be coming. | | * the connection is accepted, no HTTP is going to be coming. |
*/ | | */ |
LWS_SERVER_OPTION_ALLOW_LISTEN_SHARE = (1 << 23), | | LWS_SERVER_OPTION_ALLOW_LISTEN_SHARE = (1 << 23), |
/**< (VH) Set to allow multiple listen sockets on one interface + | | /**< (VH) Set to allow multiple listen sockets on one interface + |
* address + port. The default is to strictly allow only one | | * address + port. The default is to strictly allow only one |
* listen socket at a time. This is automatically selected if you | | * listen socket at a time. This is automatically selected if you |
* have multiple service threads. | | * have multiple service threads. |
*/ | | */ |
| | LWS_SERVER_OPTION_CREATE_VHOST_SSL_CTX = (1 << 24), |
| | /**< (VH) Force setting up the vhost SSL_CTX, even though the user |
| | * code doesn't explicitly provide a cert in the info struct. It |
| | * implies the user code is going to provide a cert at the |
| | * LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS callback, whi |
| | ch |
| | * provides the vhost SSL_CTX * in the user parameter. |
| | */ |
| | |
/****** add new things just above ---^ ******/ | | /****** add new things just above ---^ ******/ |
}; | | }; |
| | |
#define lws_check_opt(c, f) (((c) & (f)) == (f)) | | #define lws_check_opt(c, f) (((c) & (f)) == (f)) |
| | |
struct lws_plat_file_ops; | | struct lws_plat_file_ops; |
| | |
/** struct lws_context_creation_info - parameters to create context and /or
vhost with | | /** struct lws_context_creation_info - parameters to create context and /or
vhost with |
* | | * |
| | |
skipping to change at line 1892 ¶ | | skipping to change at line 2121 ¶ |
/**< VHOST: Array of structures listing supported protocols and a pr
otocol- | | /**< VHOST: Array of structures listing supported protocols and a pr
otocol- |
* specific callback for each one. The list is ended with an | | * specific callback for each one. The list is ended with an |
* entry that has a NULL callback pointer. */ | | * entry that has a NULL callback pointer. */ |
const struct lws_extension *extensions; | | const struct lws_extension *extensions; |
/**< VHOST: NULL or array of lws_extension structs listing the | | /**< VHOST: NULL or array of lws_extension structs listing the |
* extensions this context supports. */ | | * extensions this context supports. */ |
const struct lws_token_limits *token_limits; | | const struct lws_token_limits *token_limits; |
/**< CONTEXT: NULL or struct lws_token_limits pointer which is initi
alized | | /**< CONTEXT: NULL or struct lws_token_limits pointer which is initi
alized |
* with a token length limit for each possible WSI_TOKEN_ */ | | * with a token length limit for each possible WSI_TOKEN_ */ |
const char *ssl_private_key_password; | | const char *ssl_private_key_password; |
/**< VHOST: NULL or the passphrase needed for the private key */ | | /**< VHOST: NULL or the passphrase needed for the private key. (For |
| | * backwards compatibility, this can also be used to pass the client |
| | * cert passphrase when setting up a vhost client SSL context, but i |
| | t is |
| | * preferred to use .client_ssl_private_key_password for that.) */ |
const char *ssl_cert_filepath; | | const char *ssl_cert_filepath; |
/**< VHOST: If libwebsockets was compiled to use ssl, and you want | | /**< VHOST: If libwebsockets was compiled to use ssl, and you want |
* to listen using SSL, set to the filepath to fetch the | | * to listen using SSL, set to the filepath to fetch the |
* server cert from, otherwise NULL for unencrypted */ | | * server cert from, otherwise NULL for unencrypted. (For backwards |
| | * compatibility, this can also be used to pass the client certifica |
| | te |
| | * when setting up a vhost client SSL context, but it is preferred t |
| | o |
| | * use .client_ssl_cert_filepath for that.) */ |
const char *ssl_private_key_filepath; | | const char *ssl_private_key_filepath; |
/**< VHOST: filepath to private key if wanting SSL mode; | | /**< VHOST: filepath to private key if wanting SSL mode; |
* if this is set to NULL but sll_cert_filepath is set, the | | * if this is set to NULL but ssl_cert_filepath is set, the |
* OPENSSL_CONTEXT_REQUIRES_PRIVATE_KEY callback is called | | * OPENSSL_CONTEXT_REQUIRES_PRIVATE_KEY callback is called |
* to allow setting of the private key directly via openSSL | | * to allow setting of the private key directly via openSSL |
* library calls */ | | * library calls. (For backwards compatibility, this can also be u |
| | sed |
| | * to pass the client cert private key filepath when setting up a |
| | * vhost client SSL context, but it is preferred to use |
| | * .client_ssl_private_key_filepath for that.) */ |
const char *ssl_ca_filepath; | | const char *ssl_ca_filepath; |
/**< VHOST: CA certificate filepath or NULL */ | | /**< VHOST: CA certificate filepath or NULL. (For backwards |
| | * compatibility, this can also be used to pass the client CA |
| | * filepath when setting up a vhost client SSL context, |
| | * but it is preferred to use .client_ssl_ca_filepath for that.) */ |
const char *ssl_cipher_list; | | const char *ssl_cipher_list; |
/**< VHOST: List of valid ciphers to use (eg, | | /**< VHOST: List of valid ciphers to use (eg, |
* "RC4-MD5:RC4-SHA:AES128-SHA:AES256-SHA:HIGH:!DSS:!aNULL" | | * "RC4-MD5:RC4-SHA:AES128-SHA:AES256-SHA:HIGH:!DSS:!aNULL" |
* or you can leave it as NULL to get "DEFAULT" */ | | * or you can leave it as NULL to get "DEFAULT" (For backwards |
| | * compatibility, this can also be used to pass the client cipher |
| | * list when setting up a vhost client SSL context, |
| | * but it is preferred to use .client_ssl_cipher_list for that.)*/ |
const char *http_proxy_address; | | const char *http_proxy_address; |
/**< VHOST: If non-NULL, attempts to proxy via the given address. | | /**< VHOST: If non-NULL, attempts to proxy via the given address. |
* If proxy auth is required, use format "username:password\@server:
port" */ | | * If proxy auth is required, use format "username:password\@server:
port" */ |
unsigned int http_proxy_port; | | unsigned int http_proxy_port; |
/**< VHOST: If http_proxy_address was non-NULL, uses this port */ | | /**< VHOST: If http_proxy_address was non-NULL, uses this port */ |
int gid; | | int gid; |
/**< CONTEXT: group id to change to after setting listen socket, or
-1. */ | | /**< CONTEXT: group id to change to after setting listen socket, or
-1. */ |
int uid; | | int uid; |
/**< CONTEXT: user id to change to after setting listen socket, or -
1. */ | | /**< CONTEXT: user id to change to after setting listen socket, or -
1. */ |
unsigned int options; | | unsigned int options; |
/**< VHOST + CONTEXT: 0, or LWS_SERVER_OPTION_... bitfields */ | | /**< VHOST + CONTEXT: 0, or LWS_SERVER_OPTION_... bitfields */ |
void *user; | | void *user; |
/**< CONTEXT: optional user pointer that can be recovered via the co | | /**< VHOST + CONTEXT: optional user pointer that will be associated |
ntext | | * with the context when creating the context (and can be retrieved |
* pointer using lws_context_user */ | | by |
| | * lws_context_user(context), or with the vhost when creating the vh |
| | ost |
| | * (and can be retrieved by lws_vhost_user(vhost)). You will need t |
| | o |
| | * use LWS_SERVER_OPTION_EXPLICIT_VHOSTS and create the vhost separa |
| | tely |
| | * if you care about giving the context and vhost different user poi |
| | nter |
| | * values. |
| | */ |
int ka_time; | | int ka_time; |
/**< CONTEXT: 0 for no TCP keepalive, otherwise apply this keepalive | | /**< CONTEXT: 0 for no TCP keepalive, otherwise apply this keepalive |
* timeout to all libwebsocket sockets, client or server */ | | * timeout to all libwebsocket sockets, client or server */ |
int ka_probes; | | int ka_probes; |
/**< CONTEXT: if ka_time was nonzero, after the timeout expires how
many | | /**< CONTEXT: if ka_time was nonzero, after the timeout expires how
many |
* times to try to get a response from the peer before giving up | | * times to try to get a response from the peer before giving up |
* and killing the connection */ | | * and killing the connection */ |
int ka_interval; | | int ka_interval; |
/**< CONTEXT: if ka_time was nonzero, how long to wait before each k
a_probes | | /**< CONTEXT: if ka_time was nonzero, how long to wait before each k
a_probes |
* attempt */ | | * attempt */ |
| | |
skipping to change at line 2033 ¶ | | skipping to change at line 2283 ¶ |
* Eg, "badrobot" "404 Not Found" | | * Eg, "badrobot" "404 Not Found" |
*/ | | */ |
void *external_baggage_free_on_destroy; | | void *external_baggage_free_on_destroy; |
/**< CONTEXT: NULL, or pointer to something externally malloc'd, tha
t | | /**< CONTEXT: NULL, or pointer to something externally malloc'd, tha
t |
* should be freed when the context is destroyed. This allows you t
o | | * should be freed when the context is destroyed. This allows you t
o |
* automatically sync the freeing action to the context destruction | | * automatically sync the freeing action to the context destruction |
* action, so there is no need for an external free() if the context | | * action, so there is no need for an external free() if the context |
* succeeded to create. | | * succeeded to create. |
*/ | | */ |
| | |
#ifdef LWS_OPENSSL_SUPPORT | | |
/**< CONTEXT: NULL or struct lws_token_limits pointer which is init | | |
ialized | | |
* with a token length limit for each possible WSI_TOKEN_ */ | | |
const char *client_ssl_private_key_password; | | const char *client_ssl_private_key_password; |
/**< VHOST: NULL or the passphrase needed for the private key */ | | /**< VHOST: Client SSL context init: NULL or the passphrase needed |
| | * for the private key */ |
const char *client_ssl_cert_filepath; | | const char *client_ssl_cert_filepath; |
/**< VHOST: If libwebsockets was compiled to use ssl, and you want | | /**< VHOST: Client SSL context init:T he certificate the client |
* to listen using SSL, set to the filepath to fetch the | | * should present to the peer on connection */ |
* server cert from, otherwise NULL for unencrypted */ | | |
const char *client_ssl_private_key_filepath; | | const char *client_ssl_private_key_filepath; |
/**< VHOST: filepath to private key if wanting SSL mode; | | /**< VHOST: Client SSL context init: filepath to client private key |
* if this is set to NULL but sll_cert_filepath is set, the | | * if this is set to NULL but client_ssl_cert_filepath is set, you |
* OPENSSL_CONTEXT_REQUIRES_PRIVATE_KEY callback is called | | * can handle the LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERT |
* to allow setting of the private key directly via openSSL | | S |
* library calls */ | | * callback of protocols[0] to allow setting of the private key dire |
| | ctly |
| | * via openSSL library calls */ |
const char *client_ssl_ca_filepath; | | const char *client_ssl_ca_filepath; |
/**< VHOST: CA certificate filepath or NULL */ | | /**< VHOST: Client SSL context init: CA certificate filepath or NULL
*/ |
const char *client_ssl_cipher_list; | | const char *client_ssl_cipher_list; |
/**< VHOST: List of valid ciphers to use (eg, | | /**< VHOST: Client SSL context init: List of valid ciphers to use (e
g, |
* "RC4-MD5:RC4-SHA:AES128-SHA:AES256-SHA:HIGH:!DSS:!aNULL" | | * "RC4-MD5:RC4-SHA:AES128-SHA:AES256-SHA:HIGH:!DSS:!aNULL" |
* or you can leave it as NULL to get "DEFAULT" */ | | * or you can leave it as NULL to get "DEFAULT" */ |
#endif | | |
| | |
const struct lws_plat_file_ops *fops; | | const struct lws_plat_file_ops *fops; |
/**< CONTEXT: NULL, or pointer to an array of fops structs, terminat
ed | | /**< CONTEXT: NULL, or pointer to an array of fops structs, terminat
ed |
* by a sentinel with NULL .open. | | * by a sentinel with NULL .open. |
* | | * |
* If NULL, lws provides just the platform file operations struct fo
r | | * If NULL, lws provides just the platform file operations struct fo
r |
* backwards compatibility. | | * backwards compatibility. |
*/ | | */ |
int simultaneous_ssl_restriction; | | int simultaneous_ssl_restriction; |
/**< CONTEXT: 0 (no limit) or limit of simultaneous SSL sessions pos
sible.*/ | | /**< CONTEXT: 0 (no limit) or limit of simultaneous SSL sessions pos
sible.*/ |
| | |
skipping to change at line 2093 ¶ | | skipping to change at line 2339 ¶ |
/**< VHOST: nonzero to strictly bind sockets to the interface name i
n | | /**< VHOST: nonzero to strictly bind sockets to the interface name i
n |
* .iface (eg, "eth2"), using SO_BIND_TO_DEVICE. | | * .iface (eg, "eth2"), using SO_BIND_TO_DEVICE. |
* | | * |
* Requires SO_BINDTODEVICE support from your OS and CAP_NET_RAW | | * Requires SO_BINDTODEVICE support from your OS and CAP_NET_RAW |
* capability. | | * capability. |
* | | * |
* Notice that common things like access network interface IP from | | * Notice that common things like access network interface IP from |
* your local machine use your lo / loopback interface and will be | | * your local machine use your lo / loopback interface and will be |
* disallowed by this. | | * disallowed by this. |
*/ | | */ |
| | |
/* Add new things just above here ---^ | | |
* This is part of the ABI, don't needlessly break compatibility | | |
* | | |
* The below is to ensure later library versions with new | | |
* members added above will see 0 (default) even if the app | | |
* was not built against the newer headers. | | |
*/ | | |
int ssl_info_event_mask; | | int ssl_info_event_mask; |
/**< VHOST: mask of ssl events to be reported on LWS_CALLBACK_SSL_IN
FO | | /**< VHOST: mask of ssl events to be reported on LWS_CALLBACK_SSL_IN
FO |
* callback for connections on this vhost. The mask values are of | | * callback for connections on this vhost. The mask values are of |
* the form SSL_CB_ALERT, defined in openssl/ssl.h. The default of | | * the form SSL_CB_ALERT, defined in openssl/ssl.h. The default of |
* 0 means no info events will be reported. | | * 0 means no info events will be reported. |
*/ | | */ |
unsigned int timeout_secs_ah_idle; | | unsigned int timeout_secs_ah_idle; |
/**< VHOST: seconds to allow a client to hold an ah without using it
. | | /**< VHOST: seconds to allow a client to hold an ah without using it
. |
* 0 defaults to 10s. */ | | * 0 defaults to 10s. */ |
| | unsigned short ip_limit_ah; |
| | /**< CONTEXT: max number of ah a single IP may use simultaneously |
| | * 0 is no limit. This is a soft limit: if the limit is |
| | * reached, connections from that IP will wait in the ah |
| | * waiting list and not be able to acquire an ah until |
| | * a connection belonging to the IP relinquishes one it |
| | * already has. |
| | */ |
| | unsigned short ip_limit_wsi; |
| | /**< CONTEXT: max number of wsi a single IP may use simultaneously. |
| | * 0 is no limit. This is a hard limit, connections from |
| | * the same IP will simply be dropped once it acquires th |
| | e |
| | * amount of simultaneous wsi / accepted connections |
| | * given here. |
| | */ |
| | uint32_t http2_settings[7]; |
| | /**< CONTEXT: after context creation http2_settings[1] thru [6] have |
| | * been set to the lws platform default values. |
| | * VHOST: if http2_settings[0] is nonzero, the values given in |
| | * http2_settings[1]..[6] are used instead of the lws |
| | * platform default values. |
| | * Just leave all at 0 if you don't care. |
| | */ |
| | |
| | /* Add new things just above here ---^ |
| | * This is part of the ABI, don't needlessly break compatibility |
| | * |
| | * The below is to ensure later library versions with new |
| | * members added above will see 0 (default) even if the app |
| | * was not built against the newer headers. |
| | */ |
| | |
void *_unused[8]; /**< dummy */ | | void *_unused[8]; /**< dummy */ |
}; | | }; |
| | |
/** | | /** |
* lws_create_context() - Create the websocket handler | | * lws_create_context() - Create the websocket handler |
* \param info: pointer to struct with parameters | | * \param info: pointer to struct with parameters |
* | | * |
* This function creates the listening socket (if serving) and takes ca
re | | * This function creates the listening socket (if serving) and takes ca
re |
* of all initialization in one step. | | * of all initialization in one step. |
| | |
skipping to change at line 2169 ¶ | | skipping to change at line 2438 ¶ |
LWS_VISIBLE LWS_EXTERN void | | LWS_VISIBLE LWS_EXTERN void |
lws_context_destroy(struct lws_context *context); | | lws_context_destroy(struct lws_context *context); |
| | |
LWS_VISIBLE LWS_EXTERN void | | LWS_VISIBLE LWS_EXTERN void |
lws_context_destroy2(struct lws_context *context); | | lws_context_destroy2(struct lws_context *context); |
| | |
typedef int (*lws_reload_func)(void); | | typedef int (*lws_reload_func)(void); |
| | |
/** | | /** |
* lws_context_deprecate() - Deprecate the websocket context | | * lws_context_deprecate() - Deprecate the websocket context |
| | * |
* \param context: Websocket context | | * \param context: Websocket context |
| | * \param cb: Callback notified when old context listen sockets are closed |
* | | * |
* This function is used on an existing context before superceding it | | * This function is used on an existing context before superceding it |
* with a new context. | | * with a new context. |
* | | * |
* It closes any listen sockets in the context, so new connections are | | * It closes any listen sockets in the context, so new connections are |
* not possible. | | * not possible. |
* | | * |
* And it marks the context to be deleted when the number of active | | * And it marks the context to be deleted when the number of active |
* connections into it falls to zero. | | * connections into it falls to zero. |
* | | * |
| | |
skipping to change at line 2253 ¶ | | skipping to change at line 2524 ¶ |
* | | * |
* This function creates a virtual server (vhost) using the vhost-related | | * This function creates a virtual server (vhost) using the vhost-related |
* members of the info struct. You can create many vhosts inside one conte
xt | | * members of the info struct. You can create many vhosts inside one conte
xt |
* if you created the context with the option LWS_SERVER_OPTION_EXPLICIT_VH
OSTS | | * if you created the context with the option LWS_SERVER_OPTION_EXPLICIT_VH
OSTS |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN struct lws_vhost * | | LWS_VISIBLE LWS_EXTERN struct lws_vhost * |
lws_create_vhost(struct lws_context *context, | | lws_create_vhost(struct lws_context *context, |
struct lws_context_creation_info *info); | | struct lws_context_creation_info *info); |
| | |
/** | | /** |
* lws_destroy_vhost() - Destroy a vhost (virtual server context) | | * lws_vhost_destroy() - Destroy a vhost (virtual server context) |
* \param vhost: pointer to result of lws_create_vhost() | | * |
| | * \param vh: pointer to result of lws_create_vhost() |
* | | * |
* This function destroys a vhost. Normally, if you just want to exit, | | * This function destroys a vhost. Normally, if you just want to exit, |
* then lws_destroy_context() will take care of everything. If you want | | * then lws_destroy_context() will take care of everything. If you want |
* to destroy an individual vhost and all connections and allocations, you | | * to destroy an individual vhost and all connections and allocations, you |
* can do it with this. | | * can do it with this. |
| | * |
| | * If the vhost has a listen sockets shared by other vhosts, it will be giv |
| | en |
| | * to one of the vhosts sharing it rather than closed. |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN void | | LWS_VISIBLE LWS_EXTERN void |
lws_vhost_destroy(struct lws_vhost *vh); | | lws_vhost_destroy(struct lws_vhost *vh); |
| | |
/** | | /** |
* lwsws_get_config_globals() - Parse a JSON server config file | | * lwsws_get_config_globals() - Parse a JSON server config file |
* \param info: pointer to struct with parameters | | * \param info: pointer to struct with parameters |
* \param d: filepath of the config file | | * \param d: filepath of the config file |
* \param config_strings: storage for the config strings extracted from JSO
N, | | * \param config_strings: storage for the config strings extracted from JSO
N, |
* the pointer is incremented as strings are stored | | * the pointer is incremented as strings are stored |
| | |
skipping to change at line 2330 ¶ | | skipping to change at line 2605 ¶ |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_json_dump_vhost(const struct lws_vhost *vh, char *buf, int len); | | lws_json_dump_vhost(const struct lws_vhost *vh, char *buf, int len); |
| | |
/** | | /** |
* lws_json_dump_context() - describe context state and stats in JSON | | * lws_json_dump_context() - describe context state and stats in JSON |
* | | * |
* \param context: the context | | * \param context: the context |
* \param buf: buffer to fill with JSON | | * \param buf: buffer to fill with JSON |
* \param len: max length of buf | | * \param len: max length of buf |
| | * \param hide_vhosts: nonzero to not provide per-vhost mount etc informati |
| | on |
| | * |
| | * Generates a JSON description of vhost state into buf |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_json_dump_context(const struct lws_context *context, char *buf, int len
, | | lws_json_dump_context(const struct lws_context *context, char *buf, int len
, |
int hide_vhosts); | | int hide_vhosts); |
| | |
/** | | /** |
| | * lws_vhost_user() - get the user data associated with the vhost |
| | * \param vhost: Websocket vhost |
| | * |
| | * This returns the optional user pointer that can be attached to |
| | * a vhost when it was created. Lws never dereferences this pointer, it on |
| | ly |
| | * sets it when the vhost is created, and returns it using this api. |
| | */ |
| | LWS_VISIBLE LWS_EXTERN void * |
| | lws_vhost_user(struct lws_vhost *vhost); |
| | |
| | /** |
* lws_context_user() - get the user data associated with the context | | * lws_context_user() - get the user data associated with the context |
* \param context: Websocket context | | * \param context: Websocket context |
* | | * |
* This returns the optional user allocation that can be attached to | | * This returns the optional user allocation that can be attached to |
* the context the sockets live in at context_create time. It's a way | | * the context the sockets live in at context_create time. It's a way |
* to let all sockets serviced in the same context share data without | | * to let all sockets serviced in the same context share data without |
* using globals statics in the user code. | | * using globals statics in the user code. |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN void * | | LWS_VISIBLE LWS_EXTERN void * |
lws_context_user(struct lws_context *context); | | lws_context_user(struct lws_context *context); |
| | |
skipping to change at line 2435 ¶ | | skipping to change at line 2724 ¶ |
* The below is to ensure later library versions with new | | * The below is to ensure later library versions with new |
* members added above will see 0 (default) even if the app | | * members added above will see 0 (default) even if the app |
* was not built against the newer headers. | | * was not built against the newer headers. |
*/ | | */ |
| | |
void *_unused[2]; /**< dummy */ | | void *_unused[2]; /**< dummy */ |
}; | | }; |
///@} | | ///@} |
///@} | | ///@} |
| | |
/*! \defgroup client | | /*! \defgroup client Client related functions |
| | * ##Client releated functions |
* \ingroup lwsapi | | * \ingroup lwsapi |
* | | * |
* ##Client releated functions | | |
* */ | | * */ |
///@{ | | ///@{ |
| | |
/** enum lws_client_connect_ssl_connection_flags - flags that may be used | | /** enum lws_client_connect_ssl_connection_flags - flags that may be used |
* with struct lws_client_connect_info ssl_connection member to control if | | * with struct lws_client_connect_info ssl_connection member to control if |
* and how SSL checks apply to the client connection being created | | * and how SSL checks apply to the client connection being created |
*/ | | */ |
| | |
enum lws_client_connect_ssl_connection_flags { | | enum lws_client_connect_ssl_connection_flags { |
LCCSCF_USE_SSL = (1 << 0), | | LCCSCF_USE_SSL = (1 << 0), |
| | |
skipping to change at line 2714 ¶ | | skipping to change at line 3003 ¶ |
* | | * |
* If you are calling it in a single-threaded app, you don't want it to | | * If you are calling it in a single-threaded app, you don't want it to |
* wait around blocking other things in your loop from happening, so yo
u | | * wait around blocking other things in your loop from happening, so yo
u |
* would call it with a timeout_ms of 0, so it returns immediately if | | * would call it with a timeout_ms of 0, so it returns immediately if |
* nothing is pending, or as soon as it services whatever was pending. | | * nothing is pending, or as soon as it services whatever was pending. |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_service(struct lws_context *context, int timeout_ms); | | lws_service(struct lws_context *context, int timeout_ms); |
| | |
/** | | /** |
* lws_service() - Service any pending websocket activity | | * lws_service_tsi() - Service any pending websocket activity |
* | | * |
* \param context: Websocket context | | * \param context: Websocket context |
* \param timeout_ms: Timeout for poll; 0 means return immediately if noth
ing needed | | * \param timeout_ms: Timeout for poll; 0 means return immediately if noth
ing needed |
* service otherwise block and service immediately, returning | | * service otherwise block and service immediately, returning |
* after the timeout if nothing needed service. | | * after the timeout if nothing needed service. |
| | * \param tsi: Thread service index, starting at 0 |
* | | * |
* Same as lws_service(), but for a specific thread service index. Only ne
eded | | * Same as lws_service(), but for a specific thread service index. Only ne
eded |
* if you are spawning multiple service threads. | | * if you are spawning multiple service threads. |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_service_tsi(struct lws_context *context, int timeout_ms, int tsi); | | lws_service_tsi(struct lws_context *context, int timeout_ms, int tsi); |
| | |
/** | | /** |
* lws_cancel_service_pt() - Cancel servicing of pending socket activity | | * lws_cancel_service_pt() - Cancel servicing of pending socket activity |
* on one thread | | * on one thread |
| | |
skipping to change at line 2882 ¶ | | skipping to change at line 3172 ¶ |
* the wsi should be left alone. | | * the wsi should be left alone. |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_serve_http_file(struct lws *wsi, const char *file, const char *content_
type, | | lws_serve_http_file(struct lws *wsi, const char *file, const char *content_
type, |
const char *other_headers, int other_headers_len); | | const char *other_headers, int other_headers_len); |
| | |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_serve_http_file_fragment(struct lws *wsi); | | lws_serve_http_file_fragment(struct lws *wsi); |
//@} | | //@} |
| | |
/*! \defgroup html-chunked-substitution HTML Chunked Substitution | | |
* \ingroup http | | |
* | | |
* ##HTML chunked Substitution | | |
* | | |
* APIs for receiving chunks of text, replacing a set of variable names via | | |
* a callback, and then prepending and appending HTML chunked encoding | | |
* headers. | | |
*/ | | |
//@{ | | |
| | |
enum http_status { | | enum http_status { |
| | HTTP_STATUS_CONTINUE = 100, |
| | |
HTTP_STATUS_OK = 200, | | HTTP_STATUS_OK = 200, |
HTTP_STATUS_NO_CONTENT = 204, | | HTTP_STATUS_NO_CONTENT = 204, |
HTTP_STATUS_PARTIAL_CONTENT = 206, | | HTTP_STATUS_PARTIAL_CONTENT = 206, |
| | |
HTTP_STATUS_MOVED_PERMANENTLY = 301, | | HTTP_STATUS_MOVED_PERMANENTLY = 301, |
HTTP_STATUS_FOUND = 302, | | HTTP_STATUS_FOUND = 302, |
HTTP_STATUS_SEE_OTHER = 303, | | HTTP_STATUS_SEE_OTHER = 303, |
HTTP_STATUS_NOT_MODIFIED = 304, | | HTTP_STATUS_NOT_MODIFIED = 304, |
| | |
HTTP_STATUS_BAD_REQUEST = 400, | | HTTP_STATUS_BAD_REQUEST = 400, |
| | |
skipping to change at line 2929 ¶ | | skipping to change at line 3210 ¶ |
HTTP_STATUS_REQ_RANGE_NOT_SATISFIABLE, | | HTTP_STATUS_REQ_RANGE_NOT_SATISFIABLE, |
HTTP_STATUS_EXPECTATION_FAILED, | | HTTP_STATUS_EXPECTATION_FAILED, |
| | |
HTTP_STATUS_INTERNAL_SERVER_ERROR = 500, | | HTTP_STATUS_INTERNAL_SERVER_ERROR = 500, |
HTTP_STATUS_NOT_IMPLEMENTED, | | HTTP_STATUS_NOT_IMPLEMENTED, |
HTTP_STATUS_BAD_GATEWAY, | | HTTP_STATUS_BAD_GATEWAY, |
HTTP_STATUS_SERVICE_UNAVAILABLE, | | HTTP_STATUS_SERVICE_UNAVAILABLE, |
HTTP_STATUS_GATEWAY_TIMEOUT, | | HTTP_STATUS_GATEWAY_TIMEOUT, |
HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED, | | HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED, |
}; | | }; |
| | /*! \defgroup html-chunked-substitution HTML Chunked Substitution |
| | * \ingroup http |
| | * |
| | * ##HTML chunked Substitution |
| | * |
| | * APIs for receiving chunks of text, replacing a set of variable names via |
| | * a callback, and then prepending and appending HTML chunked encoding |
| | * headers. |
| | */ |
| | //@{ |
| | |
struct lws_process_html_args { | | struct lws_process_html_args { |
char *p; /**< pointer to the buffer containing the data */ | | char *p; /**< pointer to the buffer containing the data */ |
int len; /**< length of the original data at p */ | | int len; /**< length of the original data at p */ |
int max_len; /**< maximum length we can grow the data to */ | | int max_len; /**< maximum length we can grow the data to */ |
int final; /**< set if this is the last chunk of the file */ | | int final; /**< set if this is the last chunk of the file */ |
}; | | }; |
| | |
typedef const char *(*lws_process_html_state_cb)(void *data, int index); | | typedef const char *(*lws_process_html_state_cb)(void *data, int index); |
| | |
| | |
skipping to change at line 3097 ¶ | | skipping to change at line 3388 ¶ |
WSI_TOKEN_PATCH_URI = 73, | | WSI_TOKEN_PATCH_URI = 73, |
WSI_TOKEN_PUT_URI = 74, | | WSI_TOKEN_PUT_URI = 74, |
WSI_TOKEN_DELETE_URI = 75, | | WSI_TOKEN_DELETE_URI = 75, |
| | |
WSI_TOKEN_HTTP_URI_ARGS = 76, | | WSI_TOKEN_HTTP_URI_ARGS = 76, |
WSI_TOKEN_PROXY = 77, | | WSI_TOKEN_PROXY = 77, |
WSI_TOKEN_HTTP_X_REAL_IP = 78, | | WSI_TOKEN_HTTP_X_REAL_IP = 78, |
WSI_TOKEN_HTTP1_0 = 79, | | WSI_TOKEN_HTTP1_0 = 79, |
WSI_TOKEN_X_FORWARDED_FOR = 80, | | WSI_TOKEN_X_FORWARDED_FOR = 80, |
WSI_TOKEN_CONNECT = 81, | | WSI_TOKEN_CONNECT = 81, |
| | WSI_TOKEN_HEAD_URI = 82, |
| | WSI_TOKEN_TE = 83, |
/****** add new things just above ---^ ******/ | | /****** add new things just above ---^ ******/ |
| | |
/* use token storage to stash these internally, not for | | /* use token storage to stash these internally, not for |
* user use */ | | * user use */ |
| | |
_WSI_TOKEN_CLIENT_SENT_PROTOCOLS, | | _WSI_TOKEN_CLIENT_SENT_PROTOCOLS, |
_WSI_TOKEN_CLIENT_PEER_ADDRESS, | | _WSI_TOKEN_CLIENT_PEER_ADDRESS, |
_WSI_TOKEN_CLIENT_URI, | | _WSI_TOKEN_CLIENT_URI, |
_WSI_TOKEN_CLIENT_HOST, | | _WSI_TOKEN_CLIENT_HOST, |
_WSI_TOKEN_CLIENT_ORIGIN, | | _WSI_TOKEN_CLIENT_ORIGIN, |
| | |
skipping to change at line 3128 ¶ | | skipping to change at line 3421 ¶ |
WSI_INIT_TOKEN_MUXURL, | | WSI_INIT_TOKEN_MUXURL, |
}; | | }; |
| | |
struct lws_token_limits { | | struct lws_token_limits { |
unsigned short token_limit[WSI_TOKEN_COUNT]; /**< max chars for this
token */ | | unsigned short token_limit[WSI_TOKEN_COUNT]; /**< max chars for this
token */ |
}; | | }; |
| | |
/** | | /** |
* lws_token_to_string() - returns a textual representation of a hdr token
index | | * lws_token_to_string() - returns a textual representation of a hdr token
index |
* | | * |
* \param: token index | | * \param token: token index |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN const unsigned char * | | LWS_VISIBLE LWS_EXTERN const unsigned char * |
lws_token_to_string(enum lws_token_indexes token); | | lws_token_to_string(enum lws_token_indexes token); |
| | |
/** | | /** |
* lws_hdr_total_length: report length of all fragments of a header totalle
d up | | * lws_hdr_total_length: report length of all fragments of a header totalle
d up |
* The returned length does not include the space for a | | * The returned length does not include the space for a |
* terminating '\0' | | * terminating '\0' |
* | | * |
* \param wsi: websocket connection | | * \param wsi: websocket connection |
| | |
skipping to change at line 3464 ¶ | | skipping to change at line 3757 ¶ |
* lws_urldecode() - like strncpy but with urldecoding | | * lws_urldecode() - like strncpy but with urldecoding |
* | | * |
* \param string: output buffer | | * \param string: output buffer |
* \param escaped: input buffer ('\0' terminated) | | * \param escaped: input buffer ('\0' terminated) |
* \param len: output buffer max length | | * \param len: output buffer max length |
* | | * |
* This is only useful for '\0' terminated strings | | * This is only useful for '\0' terminated strings |
* | | * |
* Since urldecoding only shrinks the output string, it is possible to | | * Since urldecoding only shrinks the output string, it is possible to |
* do it in-place, ie, string == escaped | | * do it in-place, ie, string == escaped |
| | * |
| | * Returns 0 if completed OK or nonzero for urldecode violation (non-hex ch |
| | ars |
| | * where hex required, etc) |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_urldecode(char *string, const char *escaped, int len); | | lws_urldecode(char *string, const char *escaped, int len); |
///@} | | ///@} |
/** | | /** |
* lws_return_http_status() - Return simple http status | | * lws_return_http_status() - Return simple http status |
* \param wsi: Websocket instance (available from user callback) | | * \param wsi: Websocket instance (available from user callback) |
* \param code: Status index, eg, 404 | | * \param code: Status index, eg, 404 |
* \param html_body: User-readable HTML description < 1KB, or NUL
L | | * \param html_body: User-readable HTML description < 1KB, or NUL
L |
* | | * |
| | |
skipping to change at line 3550 ¶ | | skipping to change at line 3846 ¶ |
///@} | | ///@} |
| | |
/*! \defgroup ev libev helpers | | /*! \defgroup ev libev helpers |
* | | * |
* ##libev helpers | | * ##libev helpers |
* | | * |
* APIs specific to libev event loop itegration | | * APIs specific to libev event loop itegration |
*/ | | */ |
///@{ | | ///@{ |
| | |
#ifdef LWS_USE_LIBEV | | #ifdef LWS_WITH_LIBEV |
typedef void (lws_ev_signal_cb_t)(EV_P_ struct ev_signal *w, int revents); | | typedef void (lws_ev_signal_cb_t)(EV_P_ struct ev_signal *w, int revents); |
| | |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_ev_sigint_cfg(struct lws_context *context, int use_ev_sigint, | | lws_ev_sigint_cfg(struct lws_context *context, int use_ev_sigint, |
lws_ev_signal_cb_t *cb); | | lws_ev_signal_cb_t *cb); |
| | |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_ev_initloop(struct lws_context *context, struct ev_loop *loop, int tsi)
; | | lws_ev_initloop(struct lws_context *context, struct ev_loop *loop, int tsi)
; |
| | |
LWS_VISIBLE LWS_EXTERN void | | LWS_VISIBLE LWS_EXTERN void |
lws_ev_sigint_cb(struct ev_loop *loop, struct ev_signal *watcher, int reven
ts); | | lws_ev_sigint_cb(struct ev_loop *loop, struct ev_signal *watcher, int reven
ts); |
#endif /* LWS_USE_LIBEV */ | | #endif /* LWS_WITH_LIBEV */ |
| | |
///@} | | ///@} |
| | |
/*! \defgroup uv libuv helpers | | /*! \defgroup uv libuv helpers |
* | | * |
* ##libuv helpers | | * ##libuv helpers |
* | | * |
* APIs specific to libuv event loop itegration | | * APIs specific to libuv event loop itegration |
*/ | | */ |
///@{ | | ///@{ |
#ifdef LWS_USE_LIBUV | | #ifdef LWS_WITH_LIBUV |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_uv_sigint_cfg(struct lws_context *context, int use_uv_sigint, | | lws_uv_sigint_cfg(struct lws_context *context, int use_uv_sigint, |
uv_signal_cb cb); | | uv_signal_cb cb); |
| | |
LWS_VISIBLE LWS_EXTERN void | | LWS_VISIBLE LWS_EXTERN void |
lws_libuv_run(const struct lws_context *context, int tsi); | | lws_libuv_run(const struct lws_context *context, int tsi); |
| | |
LWS_VISIBLE LWS_EXTERN void | | LWS_VISIBLE LWS_EXTERN void |
lws_libuv_stop(struct lws_context *context); | | lws_libuv_stop(struct lws_context *context); |
| | |
| | |
skipping to change at line 3598 ¶ | | skipping to change at line 3894 ¶ |
lws_uv_initloop(struct lws_context *context, uv_loop_t *loop, int tsi); | | lws_uv_initloop(struct lws_context *context, uv_loop_t *loop, int tsi); |
| | |
LWS_VISIBLE LWS_EXTERN uv_loop_t * | | LWS_VISIBLE LWS_EXTERN uv_loop_t * |
lws_uv_getloop(struct lws_context *context, int tsi); | | lws_uv_getloop(struct lws_context *context, int tsi); |
| | |
LWS_VISIBLE LWS_EXTERN void | | LWS_VISIBLE LWS_EXTERN void |
lws_uv_sigint_cb(uv_signal_t *watcher, int signum); | | lws_uv_sigint_cb(uv_signal_t *watcher, int signum); |
| | |
LWS_VISIBLE LWS_EXTERN void | | LWS_VISIBLE LWS_EXTERN void |
lws_close_all_handles_in_loop(uv_loop_t *loop); | | lws_close_all_handles_in_loop(uv_loop_t *loop); |
#endif /* LWS_USE_LIBUV */ | | #endif /* LWS_WITH_LIBUV */ |
///@} | | ///@} |
| | |
/*! \defgroup event libevent helpers | | /*! \defgroup event libevent helpers |
* | | * |
* ##libevent helpers | | * ##libevent helpers |
* | | * |
* APIs specific to libevent event loop itegration | | * APIs specific to libevent event loop itegration |
*/ | | */ |
///@{ | | ///@{ |
| | |
#ifdef LWS_USE_LIBEVENT | | #ifdef LWS_WITH_LIBEVENT |
typedef void (lws_event_signal_cb_t) (evutil_socket_t sock_fd, short revent
s, | | typedef void (lws_event_signal_cb_t) (evutil_socket_t sock_fd, short revent
s, |
void *ctx); | | void *ctx); |
| | |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_event_sigint_cfg(struct lws_context *context, int use_event_sigint, | | lws_event_sigint_cfg(struct lws_context *context, int use_event_sigint, |
lws_event_signal_cb_t cb); | | lws_event_signal_cb_t cb); |
| | |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_event_initloop(struct lws_context *context, struct event_base *loop, | | lws_event_initloop(struct lws_context *context, struct event_base *loop, |
int tsi); | | int tsi); |
| | |
LWS_VISIBLE LWS_EXTERN void | | LWS_VISIBLE LWS_EXTERN void |
lws_event_sigint_cb(evutil_socket_t sock_fd, short revents, | | lws_event_sigint_cb(evutil_socket_t sock_fd, short revents, |
void *ctx); | | void *ctx); |
#endif /* LWS_USE_LIBEVENT */ | | #endif /* LWS_WITH_LIBEVENT */ |
| | |
///@} | | ///@} |
| | |
/*! \defgroup timeout Connection timeouts | | /*! \defgroup timeout Connection timeouts |
| | |
APIs related to setting connection timeouts | | APIs related to setting connection timeouts |
*/ | | */ |
//@{ | | //@{ |
| | |
/* | | /* |
| | |
skipping to change at line 3667 ¶ | | skipping to change at line 3963 ¶ |
PENDING_TIMEOUT_CLIENT_ISSUE_PAYLOAD = 18, | | PENDING_TIMEOUT_CLIENT_ISSUE_PAYLOAD = 18, |
PENDING_TIMEOUT_AWAITING_SOCKS_GREETING_REPLY = 19, | | PENDING_TIMEOUT_AWAITING_SOCKS_GREETING_REPLY = 19, |
PENDING_TIMEOUT_AWAITING_SOCKS_CONNECT_REPLY = 20, | | PENDING_TIMEOUT_AWAITING_SOCKS_CONNECT_REPLY = 20, |
PENDING_TIMEOUT_AWAITING_SOCKS_AUTH_REPLY = 21, | | PENDING_TIMEOUT_AWAITING_SOCKS_AUTH_REPLY = 21, |
PENDING_TIMEOUT_KILLED_BY_SSL_INFO = 22, | | PENDING_TIMEOUT_KILLED_BY_SSL_INFO = 22, |
PENDING_TIMEOUT_KILLED_BY_PARENT = 23, | | PENDING_TIMEOUT_KILLED_BY_PARENT = 23, |
PENDING_TIMEOUT_CLOSE_SEND = 24, | | PENDING_TIMEOUT_CLOSE_SEND = 24, |
PENDING_TIMEOUT_HOLDING_AH = 25, | | PENDING_TIMEOUT_HOLDING_AH = 25, |
| | |
/****** add new things just above ---^ ******/ | | /****** add new things just above ---^ ******/ |
| | |
| | PENDING_TIMEOUT_USER_REASON_BASE = 1000 |
}; | | }; |
| | |
#define LWS_TO_KILL_ASYNC -1 | | #define LWS_TO_KILL_ASYNC -1 |
/**< If LWS_TO_KILL_ASYNC is given as the timeout sec in a lws_set_timeout(
) | | /**< If LWS_TO_KILL_ASYNC is given as the timeout sec in a lws_set_timeout(
) |
* call, then the connection is marked to be killed at the next timeout | | * call, then the connection is marked to be killed at the next timeout |
* check. This is how you should force-close the wsi being serviced if | | * check. This is how you should force-close the wsi being serviced if |
* you are doing it outside the callback (where you should close by nonzero | | * you are doing it outside the callback (where you should close by nonzero |
* return). | | * return). |
*/ | | */ |
#define LWS_TO_KILL_SYNC -2 | | #define LWS_TO_KILL_SYNC -2 |
| | |
skipping to change at line 3756 ¶ | | skipping to change at line 4054 ¶ |
LWS_WRITE_HTTP_FINAL = 7, | | LWS_WRITE_HTTP_FINAL = 7, |
| | |
/* HTTP2 */ | | /* HTTP2 */ |
| | |
LWS_WRITE_HTTP_HEADERS = 8, | | LWS_WRITE_HTTP_HEADERS = 8, |
/**< Send http headers (http2 encodes this payload and LWS_WRITE_HTT
P | | /**< Send http headers (http2 encodes this payload and LWS_WRITE_HTT
P |
* payload differently, http 1.x links also handle this correctly. s
o | | * payload differently, http 1.x links also handle this correctly. s
o |
* to be compatible with both in the future,header response part sho
uld | | * to be compatible with both in the future,header response part sho
uld |
* be sent using this regardless of http version expected) | | * be sent using this regardless of http version expected) |
*/ | | */ |
| | LWS_WRITE_HTTP_HEADERS_CONTINUATION = 9, |
| | /**< Continuation of http/2 headers |
| | */ |
| | |
/****** add new things just above ---^ ******/ | | /****** add new things just above ---^ ******/ |
| | |
/* flags */ | | /* flags */ |
| | |
LWS_WRITE_NO_FIN = 0x40, | | LWS_WRITE_NO_FIN = 0x40, |
/**< This part of the message is not the end of the message */ | | /**< This part of the message is not the end of the message */ |
| | |
| | LWS_WRITE_H2_STREAM_END = 0x80, |
| | /**< Flag indicates this packet should go out with STREAM_END if h2 |
| | * STREAM_END is allowed on DATA or HEADERS. |
| | */ |
| | |
LWS_WRITE_CLIENT_IGNORE_XOR_MASK = 0x80 | | LWS_WRITE_CLIENT_IGNORE_XOR_MASK = 0x80 |
/**< client packet payload goes out on wire unmunged | | /**< client packet payload goes out on wire unmunged |
* only useful for security tests since normal servers cannot | | * only useful for security tests since normal servers cannot |
* decode the content if used */ | | * decode the content if used */ |
}; | | }; |
| | |
/* used with LWS_CALLBACK_CHILD_WRITE_VIA_PARENT */ | | /* used with LWS_CALLBACK_CHILD_WRITE_VIA_PARENT */ |
| | |
struct lws_write_passthru { | | struct lws_write_passthru { |
struct lws *wsi; | | struct lws *wsi; |
| | |
skipping to change at line 3910 ¶ | | skipping to change at line 4216 ¶ |
* | | * |
* - Which: only this wsi | | * - Which: only this wsi |
* - When: when the individual connection becomes writeable | | * - When: when the individual connection becomes writeable |
* - What: LWS_CALLBACK_*_WRITEABLE | | * - What: LWS_CALLBACK_*_WRITEABLE |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_callback_on_writable(struct lws *wsi); | | lws_callback_on_writable(struct lws *wsi); |
| | |
/** | | /** |
* lws_callback_on_writable_all_protocol() - Request a callback for all | | * lws_callback_on_writable_all_protocol() - Request a callback for all |
* connections on same vhost using the given protocol w
hen it | | * connections using the given protocol when it |
* becomes possible to write to each socket without | | * becomes possible to write to each socket without |
* blocking in turn. | | * blocking in turn. |
* | | * |
* \param context: lws_context | | * \param context: lws_context |
* \param protocol: Protocol whose connections will get callbacks | | * \param protocol: Protocol whose connections will get callbacks |
* | | * |
* - Which: connections using this protocol on ANY VHOST | | * - Which: connections using this protocol on ANY VHOST |
* - When: when the individual connection becomes writeable | | * - When: when the individual connection becomes writeable |
* - What: LWS_CALLBACK_*_WRITEABLE | | * - What: LWS_CALLBACK_*_WRITEABLE |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_callback_on_writable_all_protocol(const struct lws_context *context, | | lws_callback_on_writable_all_protocol(const struct lws_context *context, |
const struct lws_protocols *protocol); | | const struct lws_protocols *protocol); |
| | |
/** | | /** |
* lws_callback_on_writable_all_protocol_vhost() - Request a callback for | | * lws_callback_on_writable_all_protocol_vhost() - Request a callback for |
* all connections using the given protocol when it | | * all connections on same vhost using the given protoc |
* becomes possible to write to each socket without | | ol |
| | * when it becomes possible to write to each socket wit |
| | hout |
* blocking in turn. | | * blocking in turn. |
* | | * |
* \param vhost: Only consider connections on this lws_vhost | | * \param vhost: Only consider connections on this lws_vhost |
* \param protocol: Protocol whose connections will get callbacks | | * \param protocol: Protocol whose connections will get callbacks |
* | | * |
* - Which: connections using this protocol on GIVEN VHOST ONLY | | * - Which: connections using this protocol on GIVEN VHOST ONLY |
* - When: when the individual connection becomes writeable | | * - When: when the individual connection becomes writeable |
* - What: LWS_CALLBACK_*_WRITEABLE | | * - What: LWS_CALLBACK_*_WRITEABLE |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
| | |
skipping to change at line 3964 ¶ | | skipping to change at line 4270 ¶ |
* This isn't normally what you want... normally any update of connection- | | * This isn't normally what you want... normally any update of connection- |
* specific information can wait until a network-related callback like rx, | | * specific information can wait until a network-related callback like rx, |
* writable, or close. | | * writable, or close. |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_callback_all_protocol(struct lws_context *context, | | lws_callback_all_protocol(struct lws_context *context, |
const struct lws_protocols *protocol, int reason); | | const struct lws_protocols *protocol, int reason); |
| | |
/** | | /** |
* lws_callback_all_protocol_vhost() - Callback all connections using | | * lws_callback_all_protocol_vhost() - Callback all connections using |
* the given protocol with the given reason | | * the given protocol with the given reason. This is |
| | * deprecated since v2.4: use lws_callback_all_protocol |
| | _vhost_args |
* | | * |
* \param vh: Vhost whose connections will get callbacks | | * \param vh: Vhost whose connections will get callbacks |
* \param protocol: Which protocol to match | | * \param protocol: Which protocol to match. NULL means all. |
* \param reason: Callback reason index | | * \param reason: Callback reason index |
* | | * |
* - Which: connections using this protocol on GIVEN VHOST ONLY | | * - Which: connections using this protocol on GIVEN VHOST ONLY |
* - When: now | | * - When: now |
* - What: reason | | * - What: reason |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_callback_all_protocol_vhost(struct lws_vhost *vh, | | lws_callback_all_protocol_vhost(struct lws_vhost *vh, |
const struct lws_protocols *protocol, int reason); | | const struct lws_protocols *protocol, int reason) |
| | LWS_WARN_DEPRECATED; |
| | |
| | /** |
| | * lws_callback_all_protocol_vhost_args() - Callback all connections using |
| | * the given protocol with the given reason and args |
| | * |
| | * \param vh: Vhost whose connections will get callbacks |
| | * \param protocol: Which protocol to match. NULL means all. |
| | * \param reason: Callback reason index |
| | * \param argp: Callback "in" parameter |
| | * \param len: Callback "len" parameter |
| | * |
| | * - Which: connections using this protocol on GIVEN VHOST ONLY |
| | * - When: now |
| | * - What: reason |
| | */ |
| | LWS_VISIBLE int |
| | lws_callback_all_protocol_vhost_args(struct lws_vhost *vh, |
| | const struct lws_protocols *protocol, int reason, |
| | void *argp, size_t len); |
| | |
/** | | /** |
* lws_callback_vhost_protocols() - Callback all protocols enabled on a vho
st | | * lws_callback_vhost_protocols() - Callback all protocols enabled on a vho
st |
* with the given reason | | * with the given reason |
* | | * |
* \param wsi: wsi whose vhost will get callbacks | | * \param wsi: wsi whose vhost will get callbacks |
* \param reason: Callback reason index | | * \param reason: Callback reason index |
* \param in: in argument to callback | | * \param in: in argument to callback |
* \param len: len argument to callback | | * \param len: len argument to callback |
* | | * |
| | |
skipping to change at line 4033 ¶ | | skipping to change at line 4360 ¶ |
* on this connection right now without the protocol complaining. | | * on this connection right now without the protocol complaining. |
* | | * |
* lws manages accounting for send window updates and payload writes | | * lws manages accounting for send window updates and payload writes |
* automatically, so this number reflects the situation at the peer or | | * automatically, so this number reflects the situation at the peer or |
* intermediary dynamically. | | * intermediary dynamically. |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN size_t | | LWS_VISIBLE LWS_EXTERN size_t |
lws_get_peer_write_allowance(struct lws *wsi); | | lws_get_peer_write_allowance(struct lws *wsi); |
///@} | | ///@} |
| | |
| | enum { |
| | /* |
| | * Flags for enable and disable rxflow with reason bitmap and with |
| | * backwards-compatible single bool |
| | */ |
| | LWS_RXFLOW_REASON_USER_BOOL = (1 << 0), |
| | LWS_RXFLOW_REASON_HTTP_RXBUFFER = (1 << 6), |
| | LWS_RXFLOW_REASON_H2_PPS_PENDING = (1 << 7), |
| | |
| | LWS_RXFLOW_REASON_APPLIES = (1 << 14), |
| | LWS_RXFLOW_REASON_APPLIES_ENABLE_BIT = (1 << 13), |
| | LWS_RXFLOW_REASON_APPLIES_ENABLE = LWS_RXFLOW_REASON_APPLIES |
| | | |
| | LWS_RXFLOW_REASON_APPLIES_ |
| | ENABLE_BIT, |
| | LWS_RXFLOW_REASON_APPLIES_DISABLE = LWS_RXFLOW_REASON_APPLIES, |
| | LWS_RXFLOW_REASON_FLAG_PROCESS_NOW = (1 << 12), |
| | |
| | }; |
| | |
/** | | /** |
* lws_rx_flow_control() - Enable and disable socket servicing for | | * lws_rx_flow_control() - Enable and disable socket servicing for |
* received packets. | | * received packets. |
* | | * |
* If the output side of a server process becomes choked, this allows flow | | * If the output side of a server process becomes choked, this allows flow |
* control for the input side. | | * control for the input side. |
* | | * |
* \param wsi: Websocket connection instance to get callback for | | * \param wsi: Websocket connection instance to get callback for |
* \param enable: 0 = disable read servicing for this connection, 1 =
enable | | * \param enable: 0 = disable read servicing for this connection, 1 =
enable |
| | * |
| | * If you need more than one additive reason for rxflow control, you can gi |
| | ve |
| | * iLWS_RXFLOW_REASON_APPLIES_ENABLE or _DISABLE together with one or more |
| | of |
| | * b5..b0 set to idicate which bits to enable or disable. If any bits are |
| | * enabled, rx on the connection is suppressed. |
| | * |
| | * LWS_RXFLOW_REASON_FLAG_PROCESS_NOW flag may also be given to force any |
| | change |
| | * in rxflowbstatus to benapplied immediately, this should be used when you |
| | are |
| | * changing a wsi flow control state from outside a callback on that wsi. |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_rx_flow_control(struct lws *wsi, int enable); | | lws_rx_flow_control(struct lws *wsi, int enable); |
| | |
/** | | /** |
* lws_rx_flow_allow_all_protocol() - Allow all connections with this proto
col to receive | | * lws_rx_flow_allow_all_protocol() - Allow all connections with this proto
col to receive |
* | | * |
* When the user server code realizes it can accept more input, it can | | * When the user server code realizes it can accept more input, it can |
* call this to have the RX flow restriction removed from all connections u
sing | | * call this to have the RX flow restriction removed from all connections u
sing |
* the given protocol. | | * the given protocol. |
| | |
skipping to change at line 4091 ¶ | | skipping to change at line 4445 ¶ |
* When integrating with an external app with its own event loop, these can | | * When integrating with an external app with its own event loop, these can |
* be used to accept connections from someone else's listening socket. | | * be used to accept connections from someone else's listening socket. |
* | | * |
* When using lws own event loop, these are not needed. | | * When using lws own event loop, these are not needed. |
*/ | | */ |
///@{ | | ///@{ |
| | |
/** | | /** |
* lws_adopt_socket() - adopt foreign socket as if listen socket accepted i
t | | * lws_adopt_socket() - adopt foreign socket as if listen socket accepted i
t |
* for the default vhost of context. | | * for the default vhost of context. |
| | * |
* \param context: lws context | | * \param context: lws context |
* \param accept_fd: fd of already-accepted socket to adopt | | * \param accept_fd: fd of already-accepted socket to adopt |
* | | * |
* Either returns new wsi bound to accept_fd, or closes accept_fd and | | * Either returns new wsi bound to accept_fd, or closes accept_fd and |
* returns NULL, having cleaned up any new wsi pieces. | | * returns NULL, having cleaned up any new wsi pieces. |
* | | * |
* LWS adopts the socket in http serving mode, it's ready to accept an upgr
ade | | * LWS adopts the socket in http serving mode, it's ready to accept an upgr
ade |
* to ws or just serve http. | | * to ws or just serve http. |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN struct lws * | | LWS_VISIBLE LWS_EXTERN struct lws * |
lws_adopt_socket(struct lws_context *context, lws_sockfd_type accept_fd); | | lws_adopt_socket(struct lws_context *context, lws_sockfd_type accept_fd); |
/** | | /** |
* lws_adopt_socket_vhost() - adopt foreign socket as if listen socket acce
pted it | | * lws_adopt_socket_vhost() - adopt foreign socket as if listen socket acce
pted it |
* for vhost | | * for vhost |
* \param vhost: lws vhost | | * |
| | * \param vh: lws vhost |
* \param accept_fd: fd of already-accepted socket to adopt | | * \param accept_fd: fd of already-accepted socket to adopt |
* | | * |
* Either returns new wsi bound to accept_fd, or closes accept_fd and | | * Either returns new wsi bound to accept_fd, or closes accept_fd and |
* returns NULL, having cleaned up any new wsi pieces. | | * returns NULL, having cleaned up any new wsi pieces. |
* | | * |
* LWS adopts the socket in http serving mode, it's ready to accept an upgr
ade | | * LWS adopts the socket in http serving mode, it's ready to accept an upgr
ade |
* to ws or just serve http. | | * to ws or just serve http. |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN struct lws * | | LWS_VISIBLE LWS_EXTERN struct lws * |
lws_adopt_socket_vhost(struct lws_vhost *vh, lws_sockfd_type accept_fd); | | lws_adopt_socket_vhost(struct lws_vhost *vh, lws_sockfd_type accept_fd); |
| | |
skipping to change at line 4510 ¶ | | skipping to change at line 4866 ¶ |
| | |
LWS_VISIBLE LWS_EXTERN void | | LWS_VISIBLE LWS_EXTERN void |
lws_clear_child_pending_on_writable(struct lws *wsi); | | lws_clear_child_pending_on_writable(struct lws *wsi); |
| | |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_get_close_length(struct lws *wsi); | | lws_get_close_length(struct lws *wsi); |
| | |
LWS_VISIBLE LWS_EXTERN unsigned char * | | LWS_VISIBLE LWS_EXTERN unsigned char * |
lws_get_close_payload(struct lws *wsi); | | lws_get_close_payload(struct lws *wsi); |
| | |
| | /** |
| | * lws_get_network_wsi() - Returns wsi that has the tcp connection for this |
| | wsi |
| | * |
| | * \param wsi: wsi you have |
| | * |
| | * Returns wsi that has the tcp connection (which may be the incoming wsi) |
| | * |
| | * HTTP/1 connections will always return the incoming wsi |
| | * HTTP/2 connections may return a different wsi that has the tcp connectio |
| | n |
| | */ |
| | LWS_VISIBLE LWS_EXTERN |
| | struct lws *lws_get_network_wsi(struct lws *wsi); |
| | |
/* | | /* |
* \deprecated DEPRECATED Note: this is not normally needed as a user api. | | * \deprecated DEPRECATED Note: this is not normally needed as a user api. |
* It's provided in case it is | | * It's provided in case it is |
* useful when integrating with other app poll loop service code. | | * useful when integrating with other app poll loop service code. |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_read(struct lws *wsi, unsigned char *buf, lws_filepos_t len); | | lws_read(struct lws *wsi, unsigned char *buf, lws_filepos_t len); |
| | |
/** | | /** |
* lws_set_allocator() - custom allocator support | | * lws_set_allocator() - custom allocator support |
* | | * |
* \param realloc | | * \param realloc |
* | | * |
* Allows you to replace the allocator (and deallocator) used by lws | | * Allows you to replace the allocator (and deallocator) used by lws |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN void | | LWS_VISIBLE LWS_EXTERN void |
lws_set_allocator(void *(*realloc)(void *ptr, size_t size)); | | lws_set_allocator(void *(*realloc)(void *ptr, size_t size, const char *reas
on)); |
///@} | | ///@} |
| | |
/** \defgroup wsstatus Websocket status APIs | | /** \defgroup wsstatus Websocket status APIs |
* ##Websocket connection status APIs | | * ##Websocket connection status APIs |
* | | * |
* These provide information about ws connection or message status | | * These provide information about ws connection or message status |
*/ | | */ |
///@{ | | ///@{ |
/** | | /** |
* lws_send_pipe_choked() - tests if socket is writable or not | | * lws_send_pipe_choked() - tests if socket is writable or not |
| | |
skipping to change at line 4627 ¶ | | skipping to change at line 4996 ¶ |
* lws_get_ssl() - Return wsi's SSL context structure | | * lws_get_ssl() - Return wsi's SSL context structure |
* \param wsi: websocket connection | | * \param wsi: websocket connection |
* | | * |
* Returns pointer to the SSL library's context structure | | * Returns pointer to the SSL library's context structure |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN SSL* | | LWS_VISIBLE LWS_EXTERN SSL* |
lws_get_ssl(struct lws *wsi); | | lws_get_ssl(struct lws *wsi); |
#endif | | #endif |
///@} | | ///@} |
| | |
| | /** \defgroup lws_ring LWS Ringbuffer APIs |
| | * ##lws_ring: generic ringbuffer struct |
| | * |
| | * Provides an abstract ringbuffer api supporting one head and one or an |
| | * unlimited number of tails. |
| | * |
| | * All of the members are opaque and manipulated by lws_ring_...() apis. |
| | * |
| | * The lws_ring and its buffer is allocated at runtime on the heap, using |
| | * |
| | * - lws_ring_create() |
| | * - lws_ring_destroy() |
| | * |
| | * It may contain any type, the size of the "element" stored in the ring |
| | * buffer and the number of elements is given at creation time. |
| | * |
| | * When you create the ringbuffer, you can optionally provide an element |
| | * destroy callback that frees any allocations inside the element. This is |
| | then |
| | * automatically called for elements with no tail behind them, ie, elements |
| | * which don't have any pending consumer are auto-freed. |
| | * |
| | * Whole elements may be inserted into the ringbuffer and removed from it, |
| | using |
| | * |
| | * - lws_ring_insert() |
| | * - lws_ring_consume() |
| | * |
| | * You can find out how many whole elements are free or waiting using |
| | * |
| | * - lws_ring_get_count_free_elements() |
| | * - lws_ring_get_count_waiting_elements() |
| | * |
| | * In addition there are special purpose optional byte-centric apis |
| | * |
| | * - lws_ring_next_linear_insert_range() |
| | * - lws_ring_bump_head() |
| | * |
| | * which let you, eg, read() directly into the ringbuffer without needing |
| | * an intermediate bounce buffer. |
| | * |
| | * The accessors understand that the ring wraps, and optimizes insertion a |
| | nd |
| | * consumption into one or two memcpy()s depending on if the head or tail |
| | * wraps. |
| | * |
| | * lws_ring only supports a single head, but optionally multiple tails wit |
| | h |
| | * an API to inform it when the "oldest" tail has moved on. You can give |
| | * NULL where-ever an api asks for a tail pointer, and it will use an inte |
| | rnal |
| | * single tail pointer for convenience. |
| | * |
| | * The "oldest tail", which is the only tail if you give it NULL instead o |
| | f |
| | * some other tail, is used to track which elements in the ringbuffer are |
| | * still unread by anyone. |
| | * |
| | * - lws_ring_update_oldest_tail() |
| | */ |
| | ///@{ |
| | struct lws_ring; |
| | |
| | /** |
| | * lws_ring_create(): create a new ringbuffer |
| | * |
| | * \param element_len: the size in bytes of one element in the ringbuffer |
| | * \param count: the number of elements the ringbuffer can contain |
| | * \param destroy_element: NULL, or callback to be called for each element |
| | * that is removed from the ringbuffer due to the |
| | * oldest tail moving beyond it |
| | * |
| | * Creates the ringbuffer and allocates the storage. Returns the new |
| | * lws_ring *, or NULL if the allocation failed. |
| | * |
| | * If non-NULL, destroy_element will get called back for every element that |
| | is |
| | * retired from the ringbuffer after the oldest tail has gone past it, and |
| | for |
| | * any element still left in the ringbuffer when it is destroyed. It repla |
| | ces |
| | * all other element destruction code in your user code. |
| | */ |
| | LWS_VISIBLE LWS_EXTERN struct lws_ring * |
| | lws_ring_create(size_t element_len, size_t count, |
| | void (*destroy_element)(void *element)); |
| | |
| | /** |
| | * lws_ring_destroy(): destroy a previously created ringbuffer |
| | * |
| | * \param ring: the struct lws_ring to destroy |
| | * |
| | * Destroys the ringbuffer allocation and the struct lws_ring itself. |
| | */ |
| | LWS_VISIBLE LWS_EXTERN void |
| | lws_ring_destroy(struct lws_ring *ring); |
| | |
| | /** |
| | * lws_ring_get_count_free_elements(): return how many elements can fit |
| | * in the free space |
| | * |
| | * \param ring: the struct lws_ring to report on |
| | * |
| | * Returns how much room is left in the ringbuffer for whole element insert |
| | ion. |
| | */ |
| | LWS_VISIBLE LWS_EXTERN size_t |
| | lws_ring_get_count_free_elements(struct lws_ring *ring); |
| | |
| | /** |
| | * lws_ring_get_count_waiting_elements(): return how many elements can be |
| | consumed |
| | * |
| | * \param ring: the struct lws_ring to report on |
| | * \param tail: a pointer to the tail struct to use, or NULL for single tai |
| | l |
| | * |
| | * Returns how many elements are waiting to be consumed from the perspectiv |
| | e |
| | * of the tail pointer given. |
| | */ |
| | LWS_VISIBLE LWS_EXTERN size_t |
| | lws_ring_get_count_waiting_elements(struct lws_ring *ring, uint32_t *tail); |
| | |
| | /** |
| | * lws_ring_insert(): attempt to insert up to max_count elements from src |
| | * |
| | * \param ring: the struct lws_ring to report on |
| | * \param src: the array of elements to be inserted |
| | * \param max_count: the number of available elements at src |
| | * |
| | * Attempts to insert as many of the elements at src as possible, up to the |
| | * maximum max_count. Returns the number of elements actually inserted. |
| | */ |
| | LWS_VISIBLE LWS_EXTERN size_t |
| | lws_ring_insert(struct lws_ring *ring, const void *src, size_t max_count); |
| | |
| | /** |
| | * lws_ring_consume(): attempt to copy out and remove up to max_count elem |
| | ents |
| | * to src |
| | * |
| | * \param ring: the struct lws_ring to report on |
| | * \param tail: a pointer to the tail struct to use, or NULL for single tai |
| | l |
| | * \param dest: the array of elements to be inserted. or NULL for no copy |
| | * \param max_count: the number of available elements at src |
| | * |
| | * Attempts to copy out as many waiting elements as possible into dest, fro |
| | m |
| | * the perspective of the given tail, up to max_count. If dest is NULL, th |
| | e |
| | * copying out is not done but the elements are logically consumed as usual |
| | . |
| | * NULL dest is useful in combination with lws_ring_get_element(), where yo |
| | u |
| | * can use the element direct from the ringbuffer and then call this with N |
| | ULL |
| | * dest to logically consume it. |
| | * |
| | * Increments the tail position according to how many elements could be |
| | * consumed. |
| | * |
| | * Returns the number of elements consumed. |
| | */ |
| | LWS_VISIBLE LWS_EXTERN size_t |
| | lws_ring_consume(struct lws_ring *ring, uint32_t *tail, void *dest, |
| | size_t max_count); |
| | |
| | /** |
| | * lws_ring_get_element(): get a pointer to the next waiting element for t |
| | ail |
| | * |
| | * \param ring: the struct lws_ring to report on |
| | * \param tail: a pointer to the tail struct to use, or NULL for single tai |
| | l |
| | * |
| | * Points to the next element that tail would consume, directly in the |
| | * ringbuffer. This lets you write() or otherwise use the element without |
| | * having to copy it out somewhere first. |
| | * |
| | * After calling this, you must call lws_ring_consume(ring, &tail, NULL, 1) |
| | * which will logically consume the element you used up and increment your |
| | * tail (tail may also be NULL there if you use a single tail). |
| | * |
| | * Returns NULL if no waiting element, or a const void * pointing to it. |
| | */ |
| | LWS_VISIBLE LWS_EXTERN const void * |
| | lws_ring_get_element(struct lws_ring *ring, uint32_t *tail); |
| | |
| | /** |
| | * lws_ring_update_oldest_tail(): free up elements older than tail for reu |
| | se |
| | * |
| | * \param ring: the struct lws_ring to report on |
| | * \param tail: a pointer to the tail struct to use, or NULL for single tai |
| | l |
| | * |
| | * If you are using multiple tails, you must use this API to inform the |
| | * lws_ring when none of the tails still need elements in the fifo any more |
| | , |
| | * by updating it when the "oldest" tail has moved on. |
| | */ |
| | LWS_VISIBLE LWS_EXTERN void |
| | lws_ring_update_oldest_tail(struct lws_ring *ring, uint32_t tail); |
| | |
| | /** |
| | * lws_ring_get_oldest_tail(): get current oldest available data index |
| | * |
| | * \param ring: the struct lws_ring to report on |
| | * |
| | * If you are initializing a new ringbuffer consumer, you can set its tail |
| | to |
| | * this to start it from the oldest ringbuffer entry still available. |
| | */ |
| | LWS_VISIBLE LWS_EXTERN uint32_t |
| | lws_ring_get_oldest_tail(struct lws_ring *ring); |
| | |
| | /** |
| | * lws_ring_next_linear_insert_range(): used to write directly into the ri |
| | ng |
| | * |
| | * \param ring: the struct lws_ring to report on |
| | * \param start: pointer to a void * set to the start of the next ringbuffe |
| | r area |
| | * \param bytes: pointer to a size_t set to the max length you may use from |
| | *start |
| | * |
| | * This provides a low-level, bytewise access directly into the ringbuffer |
| | * allowing direct insertion of data without having to use a bounce buffer. |
| | * |
| | * The api reports the position and length of the next linear range that ca |
| | n |
| | * be written in the ringbuffer, ie, up to the point it would wrap, and set |
| | s |
| | * *start and *bytes accordingly. You can then, eg, directly read() into |
| | * *start for up to *bytes, and use lws_ring_bump_head() to update the lws_ |
| | ring |
| | * with what you have done. |
| | * |
| | * Returns nonzero if no insertion is currently possible. |
| | */ |
| | LWS_VISIBLE LWS_EXTERN int |
| | lws_ring_next_linear_insert_range(struct lws_ring *ring, void **start, |
| | size_t *bytes); |
| | |
| | /** |
| | * lws_ring_bump_head(): used to write directly into the ring |
| | * |
| | * \param ring: the struct lws_ring to operate on |
| | * \param bytes: the number of bytes you inserted at the current head |
| | */ |
| | LWS_VISIBLE LWS_EXTERN void |
| | lws_ring_bump_head(struct lws_ring *ring, size_t bytes); |
| | ///@} |
| | |
/** \defgroup sha SHA and B64 helpers | | /** \defgroup sha SHA and B64 helpers |
* ##SHA and B64 helpers | | * ##SHA and B64 helpers |
* | | * |
* These provide SHA-1 and B64 helper apis | | * These provide SHA-1 and B64 helper apis |
*/ | | */ |
///@{ | | ///@{ |
#ifdef LWS_SHA1_USE_OPENSSL_NAME | | #ifdef LWS_SHA1_USE_OPENSSL_NAME |
#define lws_SHA1 SHA1 | | #define lws_SHA1 SHA1 |
#else | | #else |
/** | | /** |
| | |
skipping to change at line 4682 ¶ | | skipping to change at line 5275 ¶ |
| | |
/*! \defgroup cgi cgi handling | | /*! \defgroup cgi cgi handling |
* | | * |
* ##CGI handling | | * ##CGI handling |
* | | * |
* These functions allow low-level control over stdin/out/err of the cgi. | | * These functions allow low-level control over stdin/out/err of the cgi. |
* | | * |
* However for most cases, binding the cgi to http in and out, the default | | * However for most cases, binding the cgi to http in and out, the default |
* lws implementation already does the right thing. | | * lws implementation already does the right thing. |
*/ | | */ |
#ifdef LWS_WITH_CGI | | |
enum lws_enum_stdinouterr { | | enum lws_enum_stdinouterr { |
LWS_STDIN = 0, | | LWS_STDIN = 0, |
LWS_STDOUT = 1, | | LWS_STDOUT = 1, |
LWS_STDERR = 2, | | LWS_STDERR = 2, |
}; | | }; |
| | |
enum lws_cgi_hdr_state { | | enum lws_cgi_hdr_state { |
LCHS_HEADER, | | LCHS_HEADER, |
LCHS_CR1, | | LCHS_CR1, |
LCHS_LF1, | | LCHS_LF1, |
| | |
skipping to change at line 4709 ¶ | | skipping to change at line 5302 ¶ |
}; | | }; |
| | |
struct lws_cgi_args { | | struct lws_cgi_args { |
struct lws **stdwsi; /**< get fd with lws_get_socket_fd() */ | | struct lws **stdwsi; /**< get fd with lws_get_socket_fd() */ |
enum lws_enum_stdinouterr ch; /**< channel index */ | | enum lws_enum_stdinouterr ch; /**< channel index */ |
unsigned char *data; /**< for messages with payload */ | | unsigned char *data; /**< for messages with payload */ |
enum lws_cgi_hdr_state hdr_state; /**< track where we are in cgi hea
ders */ | | enum lws_cgi_hdr_state hdr_state; /**< track where we are in cgi hea
ders */ |
int len; /**< length */ | | int len; /**< length */ |
}; | | }; |
| | |
| | #ifdef LWS_WITH_CGI |
/** | | /** |
* lws_cgi: spawn network-connected cgi process | | * lws_cgi: spawn network-connected cgi process |
* | | * |
* \param wsi: connection to own the process | | * \param wsi: connection to own the process |
* \param exec_array: array of "exec-name" "arg1" ... "argn" NULL | | * \param exec_array: array of "exec-name" "arg1" ... "argn" NULL |
* \param script_uri_path_len: how many chars on the left of the uri are th | | * \param script_uri_path_len: how many chars on the left of the uri are th |
e path to the cgi | | e |
| | * path to the cgi, or -1 to spawn without URL-related env vars |
* \param timeout_secs: seconds script should be allowed to run | | * \param timeout_secs: seconds script should be allowed to run |
* \param mp_cgienv: pvo list with per-vhost cgi options to put in env | | * \param mp_cgienv: pvo list with per-vhost cgi options to put in env |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_cgi(struct lws *wsi, const char * const *exec_array, | | lws_cgi(struct lws *wsi, const char * const *exec_array, |
int script_uri_path_len, int timeout_secs, | | int script_uri_path_len, int timeout_secs, |
const struct lws_protocol_vhost_options *mp_cgienv); | | const struct lws_protocol_vhost_options *mp_cgienv); |
| | |
/** | | /** |
* lws_cgi_write_split_stdout_headers: write cgi output accounting for head
er part | | * lws_cgi_write_split_stdout_headers: write cgi output accounting for head
er part |
| | |
skipping to change at line 4738 ¶ | | skipping to change at line 5333 ¶ |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_cgi_write_split_stdout_headers(struct lws *wsi); | | lws_cgi_write_split_stdout_headers(struct lws *wsi); |
| | |
/** | | /** |
* lws_cgi_kill: terminate cgi process associated with wsi | | * lws_cgi_kill: terminate cgi process associated with wsi |
* | | * |
* \param wsi: connection to own the process | | * \param wsi: connection to own the process |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_cgi_kill(struct lws *wsi); | | lws_cgi_kill(struct lws *wsi); |
| | |
| | /** |
| | * lws_cgi_get_stdwsi: get wsi for stdin, stdout, or stderr |
| | * |
| | * \param wsi: parent wsi that has cgi |
| | * \param ch: which of LWS_STDIN, LWS_STDOUT or LWS_STDERR |
| | */ |
| | LWS_VISIBLE LWS_EXTERN struct lws * |
| | lws_cgi_get_stdwsi(struct lws *wsi, enum lws_enum_stdinouterr ch); |
| | |
#endif | | #endif |
///@} | | ///@} |
| | |
/*! \defgroup fops file operation wrapping | | /*! \defgroup fops file operation wrapping |
* | | * |
* ##File operation wrapping | | * ##File operation wrapping |
* | | * |
* Use these helper functions if you want to access a file from the perspec
tive | | * Use these helper functions if you want to access a file from the perspec
tive |
* of a specific wsi, which is usually the case. If you just want contextl
ess | | * of a specific wsi, which is usually the case. If you just want contextl
ess |
* file access, use the fops callbacks directly with NULL wsi instead of th
ese | | * file access, use the fops callbacks directly with NULL wsi instead of th
ese |
| | |
skipping to change at line 4984 ¶ | | skipping to change at line 5589 ¶ |
LWS_VISIBLE LWS_EXTERN lws_fileofs_t | | LWS_VISIBLE LWS_EXTERN lws_fileofs_t |
_lws_plat_file_seek_cur(lws_fop_fd_t fop_fd, lws_fileofs_t offset); | | _lws_plat_file_seek_cur(lws_fop_fd_t fop_fd, lws_fileofs_t offset); |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
_lws_plat_file_read(lws_fop_fd_t fop_fd, lws_filepos_t *amount, | | _lws_plat_file_read(lws_fop_fd_t fop_fd, lws_filepos_t *amount, |
uint8_t *buf, lws_filepos_t len); | | uint8_t *buf, lws_filepos_t len); |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
_lws_plat_file_write(lws_fop_fd_t fop_fd, lws_filepos_t *amount, | | _lws_plat_file_write(lws_fop_fd_t fop_fd, lws_filepos_t *amount, |
uint8_t *buf, lws_filepos_t len); | | uint8_t *buf, lws_filepos_t len); |
| | |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_alloc_vfs_file(struct lws_context *context, const char *filename, uint8 | | lws_alloc_vfs_file(struct lws_context *context, const char *filename, |
_t **buf, | | uint8_t **buf, lws_filepos_t *amount); |
lws_filepos_t *amount); | | |
//@} | | //@} |
| | |
/** \defgroup smtp | | /** \defgroup smtp SMTP related functions |
* \ingroup lwsapi | | |
* ##SMTP related functions | | * ##SMTP related functions |
| | * \ingroup lwsapi |
* | | * |
* These apis let you communicate with a local SMTP server to send email fr
om | | * These apis let you communicate with a local SMTP server to send email fr
om |
* lws. It handles all the SMTP sequencing and protocol actions. | | * lws. It handles all the SMTP sequencing and protocol actions. |
* | | * |
* Your system should have postfix, sendmail or another MTA listening on po
rt | | * Your system should have postfix, sendmail or another MTA listening on po
rt |
* 25 and able to send email using the "mail" commandline app. Usually dis
tro | | * 25 and able to send email using the "mail" commandline app. Usually dis
tro |
* MTAs are configured for this by default. | | * MTAs are configured for this by default. |
* | | * |
* It runs via its own libuv events if initialized (which requires giving i
t | | * It runs via its own libuv events if initialized (which requires giving i
t |
* a libuv loop to attach to). | | * a libuv loop to attach to). |
| | |
skipping to change at line 5132 ¶ | | skipping to change at line 5737 ¶ |
LWSSTATS_C_API_CLOSE, /**< count calls to close api */ | | LWSSTATS_C_API_CLOSE, /**< count calls to close api */ |
LWSSTATS_C_API_READ, /**< count calls to read from socket api */ | | LWSSTATS_C_API_READ, /**< count calls to read from socket api */ |
LWSSTATS_C_API_LWS_WRITE, /**< count calls to lws_write API */ | | LWSSTATS_C_API_LWS_WRITE, /**< count calls to lws_write API */ |
LWSSTATS_C_API_WRITE, /**< count calls to write API */ | | LWSSTATS_C_API_WRITE, /**< count calls to write API */ |
LWSSTATS_C_WRITE_PARTIALS, /**< count of partial writes */ | | LWSSTATS_C_WRITE_PARTIALS, /**< count of partial writes */ |
LWSSTATS_C_WRITEABLE_CB_REQ, /**< count of writable callback request
s */ | | LWSSTATS_C_WRITEABLE_CB_REQ, /**< count of writable callback request
s */ |
LWSSTATS_C_WRITEABLE_CB_EFF_REQ, /**< count of effective writable ca
llback requests */ | | LWSSTATS_C_WRITEABLE_CB_EFF_REQ, /**< count of effective writable ca
llback requests */ |
LWSSTATS_C_WRITEABLE_CB, /**< count of writable callbacks */ | | LWSSTATS_C_WRITEABLE_CB, /**< count of writable callbacks */ |
LWSSTATS_C_SSL_CONNECTIONS_FAILED, /**< count of failed SSL connecti
ons */ | | LWSSTATS_C_SSL_CONNECTIONS_FAILED, /**< count of failed SSL connecti
ons */ |
LWSSTATS_C_SSL_CONNECTIONS_ACCEPTED, /**< count of accepted SSL conn
ections */ | | LWSSTATS_C_SSL_CONNECTIONS_ACCEPTED, /**< count of accepted SSL conn
ections */ |
| | LWSSTATS_C_SSL_CONNECTIONS_ACCEPT_SPIN, /**< count of SSL_accept() a
ttempts */ |
LWSSTATS_C_SSL_CONNS_HAD_RX, /**< count of accepted SSL conns that h
ave had some RX */ | | LWSSTATS_C_SSL_CONNS_HAD_RX, /**< count of accepted SSL conns that h
ave had some RX */ |
LWSSTATS_C_TIMEOUTS, /**< count of timed-out connections */ | | LWSSTATS_C_TIMEOUTS, /**< count of timed-out connections */ |
LWSSTATS_C_SERVICE_ENTRY, /**< count of entries to lws service loop
*/ | | LWSSTATS_C_SERVICE_ENTRY, /**< count of entries to lws service loop
*/ |
LWSSTATS_B_READ, /**< aggregate bytes read */ | | LWSSTATS_B_READ, /**< aggregate bytes read */ |
LWSSTATS_B_WRITE, /**< aggregate bytes written */ | | LWSSTATS_B_WRITE, /**< aggregate bytes written */ |
LWSSTATS_B_PARTIALS_ACCEPTED_PARTS, /**< aggreate of size of accepte
d write data from new partials */ | | LWSSTATS_B_PARTIALS_ACCEPTED_PARTS, /**< aggreate of size of accepte
d write data from new partials */ |
LWSSTATS_MS_SSL_CONNECTIONS_ACCEPTED_DELAY, /**< aggregate delay in
accepting connection */ | | LWSSTATS_MS_SSL_CONNECTIONS_ACCEPTED_DELAY, /**< aggregate delay in
accepting connection */ |
LWSSTATS_MS_WRITABLE_DELAY, /**< aggregate delay between asking for
writable and getting cb */ | | LWSSTATS_MS_WRITABLE_DELAY, /**< aggregate delay between asking for
writable and getting cb */ |
LWSSTATS_MS_WORST_WRITABLE_DELAY, /**< single worst delay between as
king for writable and getting cb */ | | LWSSTATS_MS_WORST_WRITABLE_DELAY, /**< single worst delay between as
king for writable and getting cb */ |
LWSSTATS_MS_SSL_RX_DELAY, /**< aggregate delay between ssl accept co
mplete and first RX */ | | LWSSTATS_MS_SSL_RX_DELAY, /**< aggregate delay between ssl accept co
mplete and first RX */ |
| | LWSSTATS_C_PEER_LIMIT_AH_DENIED, /**< number of times we would have |
| | given an ah but for the peer limit */ |
| | LWSSTATS_C_PEER_LIMIT_WSI_DENIED, /**< number of times we would have |
| | given a wsi but for the peer limit */ |
| | |
/* Add new things just above here ---^ | | /* Add new things just above here ---^ |
* This is part of the ABI, don't needlessly break compatibility */ | | * This is part of the ABI, don't needlessly break compatibility */ |
LWSSTATS_SIZE | | LWSSTATS_SIZE |
}; | | }; |
| | |
#if defined(LWS_WITH_STATS) | | #if defined(LWS_WITH_STATS) |
| | |
LWS_VISIBLE LWS_EXTERN uint64_t | | LWS_VISIBLE LWS_EXTERN uint64_t |
lws_stats_get(struct lws_context *context, int index); | | lws_stats_get(struct lws_context *context, int index); |
| | |
End of changes. 103 change blocks. |
113 lines changed or deleted | | 791 lines changed or added |
|