libwebsockets.h (2.2.2) | | libwebsockets.h (2.3.0) |
| | |
skipping to change at line 36 ¶ | | skipping to change at line 36 ¶ |
| | |
#ifdef __cplusplus | | #ifdef __cplusplus |
#include <cstddef> | | #include <cstddef> |
#include <cstdarg> | | #include <cstdarg> |
# | | # |
extern "C" { | | extern "C" { |
#else | | #else |
#include <stdarg.h> | | #include <stdarg.h> |
#endif | | #endif |
| | |
| | #include "lws_config.h" |
| | |
| | /* |
| | * CARE: everything using cmake defines needs to be below here |
| | */ |
| | |
#if defined(LWS_WITH_ESP8266) | | #if defined(LWS_WITH_ESP8266) |
struct sockaddr_in; | | struct sockaddr_in; |
#define LWS_POSIX 0 | | #define LWS_POSIX 0 |
#else | | #else |
#define LWS_POSIX 1 | | #define LWS_POSIX 1 |
#endif | | #endif |
| | |
#include "lws_config.h" | | #if defined(LWS_HAS_INTPTR_T) |
| | #include <stdint.h> |
| | #define lws_intptr_t intptr_t |
| | #else |
| | typedef unsigned long long lws_intptr_t; |
| | #endif |
| | |
#if defined(WIN32) || defined(_WIN32) | | #if defined(WIN32) || defined(_WIN32) |
#ifndef WIN32_LEAN_AND_MEAN | | #ifndef WIN32_LEAN_AND_MEAN |
#define WIN32_LEAN_AND_MEAN | | #define WIN32_LEAN_AND_MEAN |
#endif | | #endif |
| | |
#include <winsock2.h> | | #include <winsock2.h> |
#include <ws2tcpip.h> | | #include <ws2tcpip.h> |
#include <stddef.h> | | #include <stddef.h> |
#include <basetsd.h> | | #include <basetsd.h> |
| | |
skipping to change at line 87 ¶ | | skipping to change at line 98 ¶ |
#define LWS_EXTERN extern __declspec(dllexport) | | #define LWS_EXTERN extern __declspec(dllexport) |
#else | | #else |
#define LWS_EXTERN extern __declspec(dllimport) | | #define LWS_EXTERN extern __declspec(dllimport) |
#endif | | #endif |
#else | | #else |
#define LWS_EXTERN | | #define LWS_EXTERN |
#endif | | #endif |
| | |
#define LWS_INVALID_FILE INVALID_HANDLE_VALUE | | #define LWS_INVALID_FILE INVALID_HANDLE_VALUE |
#define LWS_O_RDONLY _O_RDONLY | | #define LWS_O_RDONLY _O_RDONLY |
| | #define LWS_O_WRONLY _O_WRONLY |
| | #define LWS_O_CREAT _O_CREAT |
| | #define LWS_O_TRUNC _O_TRUNC |
| | |
#if !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER < 1900) /* Vis
ual Studio 2015 already defines this in <stdio.h> */ | | #if !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER < 1900) /* Vis
ual Studio 2015 already defines this in <stdio.h> */ |
#define lws_snprintf _snprintf | | #define lws_snprintf _snprintf |
#endif | | #endif |
| | |
#ifndef __func__ | | #ifndef __func__ |
#define __func__ __FUNCTION__ | | #define __func__ __FUNCTION__ |
#endif | | #endif |
| | |
#if !defined(__MINGW32__) &&(!defined(_MSC_VER) || _MSC_VER < 1900) && !def
ined(snprintf) | | #if !defined(__MINGW32__) &&(!defined(_MSC_VER) || _MSC_VER < 1900) && !def
ined(snprintf) |
#define snprintf(buf,len, format,...) _snprintf_s(buf, len,len, format, __V
A_ARGS__) | | #define snprintf(buf,len, format,...) _snprintf_s(buf, len,len, format, __V
A_ARGS__) |
#endif | | #endif |
| | |
#else /* NOT WIN32 */ | | #else /* NOT WIN32 */ |
#include <unistd.h> | | #include <unistd.h> |
| | #if defined(LWS_HAVE_SYS_CAPABILITY_H) && defined(LWS_HAVE_LIBCAP) |
| | #include <sys/capability.h> |
| | #endif |
| | |
#if defined(__NetBSD__) || defined(__FreeBSD__) | | #if defined(__NetBSD__) || defined(__FreeBSD__) |
#include <netinet/in.h> | | #include <netinet/in.h> |
#endif | | #endif |
| | |
#define LWS_INLINE inline | | #define LWS_INLINE inline |
#define LWS_O_RDONLY O_RDONLY | | #define LWS_O_RDONLY O_RDONLY |
| | #define LWS_O_WRONLY O_WRONLY |
| | #define LWS_O_CREAT O_CREAT |
| | #define LWS_O_TRUNC O_TRUNC |
| | |
#if !defined(LWS_WITH_ESP8266) && !defined(OPTEE_TA) && !defined(LWS_WITH_E
SP32) | | #if !defined(LWS_WITH_ESP8266) && !defined(OPTEE_TA) && !defined(LWS_WITH_E
SP32) |
#include <poll.h> | | #include <poll.h> |
#include <netdb.h> | | #include <netdb.h> |
#define LWS_INVALID_FILE -1 | | #define LWS_INVALID_FILE -1 |
#else | | #else |
#define getdtablesize() (20) | | #define getdtablesize() (30) |
#if defined(LWS_WITH_ESP32) | | #if defined(LWS_WITH_ESP32) |
#define LWS_INVALID_FILE NULL | | #define LWS_INVALID_FILE NULL |
#else | | #else |
#define LWS_INVALID_FILE NULL | | #define LWS_INVALID_FILE NULL |
#endif | | #endif |
#endif | | #endif |
| | |
#if defined(__GNUC__) | | #if defined(__GNUC__) |
| | |
/* warn_unused_result attribute only supported by GCC 3.4 or later */ | | /* warn_unused_result attribute only supported by GCC 3.4 or later */ |
| | |
skipping to change at line 158 ¶ | | skipping to change at line 178 ¶ |
| | |
#ifdef LWS_USE_LIBEV | | #ifdef LWS_USE_LIBEV |
#include <ev.h> | | #include <ev.h> |
#endif /* LWS_USE_LIBEV */ | | #endif /* LWS_USE_LIBEV */ |
#ifdef LWS_USE_LIBUV | | #ifdef LWS_USE_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_USE_LIBUV */ |
| | #ifdef LWS_USE_LIBEVENT |
| | #include <event2/event.h> |
| | #endif /* LWS_USE_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 501 ¶ | | skipping to change at line 524 ¶ |
static inline void uv_timer_init(void *l, uv_timer_t *t) | | static inline void uv_timer_init(void *l, uv_timer_t *t) |
{ | | { |
(void)l; | | (void)l; |
*t = NULL; | | *t = NULL; |
} | | } |
| | |
extern void esp32_uvtimer_cb(TimerHandle_t t); | | extern void esp32_uvtimer_cb(TimerHandle_t t); |
| | |
static inline void uv_timer_start(uv_timer_t *t, uv_cb_t *cb, int first, in
t rep) | | static inline void uv_timer_start(uv_timer_t *t, uv_cb_t *cb, int first, in
t rep) |
{ | | { |
struct timer_mapping *tm = malloc(sizeof(*tm)); | | struct timer_mapping *tm = (struct timer_mapping *)malloc(sizeof(*tm
)); |
| | |
if (!tm) | | if (!tm) |
return; | | return; |
| | |
tm->t = t; | | tm->t = t; |
tm->cb = cb; | | tm->cb = cb; |
| | |
*t = xTimerCreate("x", pdMS_TO_TICKS(first), !!rep, tm, | | *t = xTimerCreate("x", pdMS_TO_TICKS(first), !!rep, tm, |
(TimerCallbackFunction_t)esp32_uvtimer_cb); | | (TimerCallbackFunction_t)esp32_uvtimer_cb); |
xTimerStart(*t, 0); | | xTimerStart(*t, 0); |
| | |
skipping to change at line 527 ¶ | | skipping to change at line 550 ¶ |
} | | } |
| | |
static inline void uv_close(uv_handle_t *h, void *v) | | static inline void uv_close(uv_handle_t *h, void *v) |
{ | | { |
free(pvTimerGetTimerID((uv_timer_t)h)); | | free(pvTimerGetTimerID((uv_timer_t)h)); |
xTimerDelete(*(uv_timer_t *)h, 0); | | xTimerDelete(*(uv_timer_t *)h, 0); |
} | | } |
| | |
/* ESP32 helper declarations */ | | /* ESP32 helper declarations */ |
| | |
| | #include <mdns.h> |
| | #include <esp_partition.h> |
| | |
#define LWS_PLUGIN_STATIC | | #define LWS_PLUGIN_STATIC |
| | #define LWS_MAGIC_REBOOT_TYPE_ADS 0x50001ffc |
| | #define LWS_MAGIC_REBOOT_TYPE_REQ_FACTORY 0xb00bcafe |
| | #define LWS_MAGIC_REBOOT_TYPE_FORCED_FACTORY 0xfaceb00b |
| | #define LWS_MAGIC_REBOOT_TYPE_FORCED_FACTORY_BUTTON 0xf0cedfac |
| | |
/* user code provides these */ | | /* user code provides these */ |
| | |
extern char lws_esp32_model[16]; | | |
| | |
extern int | | |
lws_esp32_is_booting_in_ap_mode(void); | | |
extern void | | extern void |
lws_esp32_identify_physical_device(void); | | lws_esp32_identify_physical_device(void); |
| | |
/* lws-plat-esp32 provides these */ | | /* lws-plat-esp32 provides these */ |
| | |
extern void (*lws_cb_scan_done)(void *); | | typedef void (*lws_cb_scan_done)(uint16_t count, wifi_ap_record_t *recs, vo |
extern void *lws_cb_scan_done_arg; | | id *arg); |
| | |
extern char lws_esp32_serial[], lws_esp32_force_ap, lws_esp32_region; | | enum genled_state { |
| | LWSESP32_GENLED__INIT, |
| | LWSESP32_GENLED__LOST_NETWORK, |
| | LWSESP32_GENLED__NO_NETWORK, |
| | LWSESP32_GENLED__CONN_AP, |
| | LWSESP32_GENLED__GOT_IP, |
| | LWSESP32_GENLED__OK, |
| | }; |
| | |
| | struct lws_group_member { |
| | struct lws_group_member *next; |
| | uint64_t last_seen; |
| | char model[16]; |
| | char role[16]; |
| | char host[32]; |
| | char mac[20]; |
| | int width, height; |
| | struct ip4_addr addr; |
| | struct ip6_addr addrv6; |
| | uint8_t flags; |
| | }; |
| | |
| | #define LWS_SYSTEM_GROUP_MEMBER_ADD 1 |
| | #define LWS_SYSTEM_GROUP_MEMBER_CHANGE 2 |
| | #define LWS_SYSTEM_GROUP_MEMBER_REMOVE 3 |
| | |
| | #define LWS_GROUP_FLAG_SELF 1 |
| | |
| | struct lws_esp32 { |
| | char sta_ip[16]; |
| | char sta_mask[16]; |
| | char sta_gw[16]; |
| | char serial[16]; |
| | char opts[16]; |
| | char model[16]; |
| | char group[16]; |
| | char role[16]; |
| | char ssid[4][16]; |
| | char password[4][32]; |
| | char active_ssid[32]; |
| | char access_pw[16]; |
| | char hostname[32]; |
| | char mac[20]; |
| | mdns_server_t *mdns; |
| | char region; |
| | char inet; |
| | char conn_ap; |
| | |
| | enum genled_state genled; |
| | uint64_t genled_t; |
| | |
| | lws_cb_scan_done scan_consumer; |
| | void *scan_consumer_arg; |
| | struct lws_group_member *first; |
| | int extant_group_members; |
| | }; |
| | |
| | struct lws_esp32_image { |
| | uint32_t romfs; |
| | uint32_t romfs_len; |
| | uint32_t json; |
| | uint32_t json_len; |
| | }; |
| | |
| | extern struct lws_esp32 lws_esp32; |
| | |
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(void); | | lws_esp32_wlan_start_ap(void); |
| | extern void |
| | lws_esp32_wlan_start_station(void); |
struct lws_context_creation_info; | | struct lws_context_creation_info; |
| | extern void |
| | 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 *, unsigned int _romfs); | | lws_esp32_init(struct lws_context_creation_info *); |
| | extern int |
| | lws_esp32_wlan_nvs_get(int retry); |
| | extern esp_err_t |
| | lws_nvs_set_str(nvs_handle handle, const char* key, const char* value); |
| | extern void |
| | lws_esp32_restart_guided(uint32_t type); |
| | extern const esp_partition_t * |
| | lws_esp_ota_get_boot_partition(void); |
| | extern int |
| | lws_esp32_get_image_info(const esp_partition_t *part, struct lws_esp32_imag |
| | e *i, char *json, int json_len); |
| | extern int |
| | lws_esp32_leds_network_indication(void); |
| | |
| | extern uint32_t lws_esp32_get_reboot_type(void); |
| | extern uint16_t lws_esp32_sine_interp(int n); |
| | |
| | /* required in external code by esp32 plat (may just return if no leds) */ |
| | extern void lws_esp32_leds_timer_cb(TimerHandle_t th); |
#else | | #else |
typedef int lws_sockfd_type; | | typedef int lws_sockfd_type; |
typedef int lws_filefd_type; | | typedef int lws_filefd_type; |
#define lws_sockfd_valid(sfd) (sfd >= 0) | | #define lws_sockfd_valid(sfd) (sfd >= 0) |
#endif | | #endif |
#endif | | #endif |
| | |
#define lws_pollfd pollfd | | #define lws_pollfd pollfd |
#define LWS_POLLHUP (POLLHUP|POLLERR) | | #define LWS_POLLHUP (POLLHUP|POLLERR) |
#define LWS_POLLIN (POLLIN) | | #define LWS_POLLIN (POLLIN) |
#define LWS_POLLOUT (POLLOUT) | | #define LWS_POLLOUT (POLLOUT) |
#endif | | #endif |
| | |
| | #if (defined(WIN32) || defined(_WIN32)) && !defined(__MINGW32__) |
| | /* ... */ |
| | #define ssize_t SSIZE_T |
| | #endif |
| | |
| | #if defined(WIN32) && defined(LWS_HAVE__STAT32I64) |
| | #include <sys/types.h> |
| | #include <sys/stat.h> |
| | #endif |
| | |
| | #if defined(LWS_HAVE_STDINT_H) |
| | #include <stdint.h> |
| | #else |
| | #if defined(WIN32) || defined(_WIN32) |
| | /* !!! >:-[ */ |
| | typedef unsigned __int32 uint32_t; |
| | typedef unsigned __int16 uint16_t; |
| | typedef unsigned __int8 uint8_t; |
| | #else |
| | typedef unsigned int uint32_t; |
| | typedef unsigned short uint16_t; |
| | typedef unsigned char uint8_t; |
| | #endif |
| | #endif |
| | |
| | typedef unsigned long long lws_filepos_t; |
| | typedef long long lws_fileofs_t; |
| | typedef uint32_t lws_fop_flags_t; |
| | |
/** struct lws_pollargs - argument structure for all external poll related
calls | | /** struct lws_pollargs - argument structure for all external poll related
calls |
* passed in via 'in' */ | | * passed in via 'in' */ |
struct lws_pollargs { | | struct lws_pollargs { |
lws_sockfd_type fd; /**< applicable socket descriptor */ | | lws_sockfd_type fd; /**< applicable socket descriptor */ |
int events; /**< the new event mask */ | | int events; /**< the new event mask */ |
int prev_events; /**< the previous event mask */ | | int prev_events; /**< the previous event mask */ |
}; | | }; |
| | |
struct lws_tokens; | | struct lws_tokens; |
struct lws_token_limits; | | struct lws_token_limits; |
| | |
skipping to change at line 684 ¶ | | skipping to change at line 823 ¶ |
lws_close_reason(struct lws *wsi, enum lws_close_status status, | | lws_close_reason(struct lws *wsi, enum lws_close_status status, |
unsigned char *buf, size_t len); | | unsigned char *buf, size_t len); |
| | |
///@} | | ///@} |
| | |
struct lws; | | struct lws; |
struct lws_context; | | struct lws_context; |
/* needed even with extensions disabled for create context */ | | /* needed even with extensions disabled for create context */ |
struct lws_extension; | | struct lws_extension; |
| | |
| | /*! \defgroup lwsmeta lws-meta |
| | * |
| | * ##lws-meta protocol |
| | * |
| | * The protocol wraps other muxed connections inside one tcp connection. |
| | * |
| | * Commands are assigned from 0x41 up (so they are valid unicode) |
| | */ |
| | ///@{ |
| | |
| | enum lws_meta_commands { |
| | LWS_META_CMD_OPEN_SUBCHANNEL = 'A', |
| | /**< Client requests to open new subchannel |
| | */ |
| | LWS_META_CMD_OPEN_RESULT, |
| | /**< Result of client request to open new subchannel */ |
| | LWS_META_CMD_CLOSE_NOTIFY, |
| | /**< Notification of subchannel closure */ |
| | LWS_META_CMD_CLOSE_RQ, |
| | /**< client requests to close a subchannel */ |
| | LWS_META_CMD_WRITE, |
| | /**< connection writes something to specific channel index */ |
| | |
| | /****** add new things just above ---^ ******/ |
| | }; |
| | |
| | /* channel numbers are transported offset by 0x20 so they are valid unicode |
| | */ |
| | |
| | #define LWS_META_TRANSPORT_OFFSET 0x20 |
| | |
| | ///@} |
| | |
/*! \defgroup usercb User Callback | | /*! \defgroup usercb User Callback |
* | | * |
* ##User protocol callback | | * ##User protocol callback |
* | | * |
* The protocol callback is the primary way lws interacts with | | * The protocol callback is the primary way lws interacts with |
* user code. For one of a list of a few dozen reasons the callback gets | | * user code. For one of a list of a few dozen reasons the callback gets |
* called at some event to be handled. | | * called at some event to be handled. |
* | | * |
* All of the events can be ignored, returning 0 is taken as "OK" and retur
ning | | * All of the events can be ignored, returning 0 is taken as "OK" and retur
ning |
* nonzero in most cases indicates that the connection should be closed. | | * nonzero in most cases indicates that the connection should be closed. |
*/ | | */ |
///@{ | | ///@{ |
| | |
| | struct lws_ssl_info { |
| | int where; |
| | int ret; |
| | }; |
| | |
/* | | /* |
* NOTE: These public enums are part of the abi. If you want to add one, | | * NOTE: These public enums are part of the abi. If you want to add one, |
* add it at where specified so existing users are unaffected. | | * add it at where specified so existing users are unaffected. |
*/ | | */ |
/** enum lws_callback_reasons - reason you're getting a protocol callback *
/ | | /** enum lws_callback_reasons - reason you're getting a protocol callback *
/ |
enum lws_callback_reasons { | | enum lws_callback_reasons { |
LWS_CALLBACK_ESTABLISHED = 0, | | LWS_CALLBACK_ESTABLISHED = 0, |
/**< (VH) after the server completes a handshake with an incoming | | /**< (VH) after the server completes a handshake with an incoming |
* client. If you built the library with ssl support, in is a | | * client. If you built the library with ssl support, in is a |
* pointer to the ssl struct associated with the connection or NULL.
*/ | | * pointer to the ssl struct associated with the connection or NULL.
*/ |
| | |
skipping to change at line 916 ¶ | | skipping to change at line 1092 ¶ |
* because there is no specific protocol negotiated yet. */ | | * because there is no specific protocol negotiated yet. */ |
LWS_CALLBACK_CONFIRM_EXTENSION_OKAY = 25, | | LWS_CALLBACK_CONFIRM_EXTENSION_OKAY = 25, |
/**< When the server handshake code | | /**< When the server handshake code |
* sees that it does support a requested extension, before | | * sees that it does support a requested extension, before |
* accepting the extension by additing to the list sent back to | | * accepting the extension by additing to the list sent back to |
* the client it gives this callback just to check that it's okay | | * the client it gives this callback just to check that it's okay |
* to use that extension. It calls back to the requested protocol | | * to use that extension. It calls back to the requested protocol |
* and with in being the extension name, len is 0 and user is | | * and with in being the extension name, len is 0 and user is |
* valid. Note though at this time the ESTABLISHED callback hasn't | | * valid. Note though at this time the ESTABLISHED callback hasn't |
* happened yet so if you initialize user content there, user | | * happened yet so if you initialize user content there, user |
* content during this callback might not be useful for anything. | | * content during this callback might not be useful for anything. */ |
* Notice this callback comes to protocols[0]. */ | | |
LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED = 26, | | LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED = 26, |
/**< When a client | | /**< When a client |
* connection is being prepared to start a handshake to a server, | | * connection is being prepared to start a handshake to a server, |
* each supported extension is checked with protocols[0] callback | | * each supported extension is checked with protocols[0] callback |
* with this reason, giving the user code a chance to suppress the | | * with this reason, giving the user code a chance to suppress the |
* claim to support that extension by returning non-zero. If | | * claim to support that extension by returning non-zero. If |
* unhandled, by default 0 will be returned and the extension | | * unhandled, by default 0 will be returned and the extension |
* support included in the header to the server. Notice this | | * support included in the header to the server. Notice this |
* callback comes to protocols[0]. */ | | * callback comes to protocols[0]. */ |
LWS_CALLBACK_PROTOCOL_INIT = 27, | | LWS_CALLBACK_PROTOCOL_INIT = 27, |
| | |
skipping to change at line 1103 ¶ | | skipping to change at line 1278 ¶ |
LWS_CALLBACK_RAW_ADOPT = 62, | | LWS_CALLBACK_RAW_ADOPT = 62, |
/**< RAW mode connection was adopted (equivalent to 'wsi created') *
/ | | /**< RAW mode connection was adopted (equivalent to 'wsi created') *
/ |
LWS_CALLBACK_RAW_ADOPT_FILE = 63, | | LWS_CALLBACK_RAW_ADOPT_FILE = 63, |
/**< 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, |
| | /**< SSL connections only. An event you registered an |
| | * interest in at the vhost has occurred on a connection |
| | * using the vhost. @in is a pointer to a |
| | * struct lws_ssl_info containing information about the |
| | * event*/ |
| | LWS_CALLBACK_CHILD_WRITE_VIA_PARENT = 68, |
| | /**< Child has been marked with parent_carries_io attribute, so |
| | * lws_write directs the to this callback at the parent, |
| | * @in is a struct lws_write_passthru containing the args |
| | * the lws_write() was called with. |
| | */ |
| | LWS_CALLBACK_CHILD_CLOSING = 69, |
| | /**< Sent to parent to notify them a child is closing / being |
| | * destroyed. @in is the child wsi. |
| | */ |
| | |
/****** 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 1383 ¶ | | skipping to change at line 1574 ¶ |
/**< Each new connection using this protocol gets | | /**< Each new connection using this protocol gets |
* this much memory allocated on connection establishment and | | * this much memory allocated on connection establishment and |
* freed on connection takedown. A pointer to this per-connection | | * freed on connection takedown. A pointer to this per-connection |
* allocation is passed into the callback in the 'user' parameter */ | | * allocation is passed into the callback in the 'user' parameter */ |
size_t rx_buffer_size; | | size_t rx_buffer_size; |
/**< lws allocates this much space for rx data and informs callback | | /**< lws allocates this much space for rx data and informs callback |
* when something came. Due to rx flow control, the callback may no
t | | * when something came. Due to rx flow control, the callback may no
t |
* be able to consume it all without having to return to the event | | * be able to consume it all without having to return to the event |
* loop. That is supported in lws. | | * loop. That is supported in lws. |
* | | * |
* This also controls how much may be sent at once at the moment, | | * If .tx_packet_size is 0, this also controls how much may be sent |
* although this is likely to change. | | at once |
| | * for backwards compatibility. |
*/ | | */ |
unsigned int id; | | unsigned int id; |
/**< ignored by lws, but useful to contain user information bound | | /**< ignored by lws, but useful to contain user information bound |
* to the selected protocol. For example if this protocol was | | * to the selected protocol. For example if this protocol was |
* called "myprotocol-v2", you might set id to 2, and the user | | * called "myprotocol-v2", you might set id to 2, and the user |
* code that acts differently according to the version can do so by | | * code that acts differently according to the version can do so by |
* switch (wsi->protocol->id), user code might use some bits as | | * switch (wsi->protocol->id), user code might use some bits as |
* capability flags based on selected protocol version, etc. */ | | * capability flags based on selected protocol version, etc. */ |
void *user; /**< ignored by lws, but user code can pass a pointer | | void *user; /**< ignored by lws, but user code can pass a pointer |
here it can later access from the protocol callback
*/ | | here it can later access from the protocol callback
*/ |
| | size_t tx_packet_size; |
| | /**< 0 indicates restrict send() size to .rx_buffer_size for backwar |
| | ds- |
| | * compatibility. |
| | * If greater than zero, a single send() is restricted to this amoun |
| | t |
| | * and any remainder is buffered by lws and sent afterwards also in |
| | * these size chunks. Since that is expensive, it's preferable |
| | * to restrict one fragment you are trying to send to match this |
| | * size. |
| | */ |
| | |
/* 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 */ |
}; | | }; |
| | |
struct lws_vhost; | | struct lws_vhost; |
| | |
/** | | /** |
* lws_vhost_name_to_protocol() - get vhost's protocol object from its name | | * lws_vhost_name_to_protocol() - get vhost's protocol object from its name |
* | | * |
| | |
skipping to change at line 1639 ¶ | | skipping to change at line 1839 ¶ |
*/ | | */ |
LWS_SERVER_OPTION_JUST_USE_RAW_ORIGIN = (1 << 19), | | LWS_SERVER_OPTION_JUST_USE_RAW_ORIGIN = (1 << 19), |
/**< For backwards-compatibility reasons, by default | | /**< For backwards-compatibility reasons, by default |
* lws prepends "http://" to the origin you give in the client | | * lws prepends "http://" to the origin you give in the client |
* connection info struct. If you give this flag when you create | | * connection info struct. If you give this flag when you create |
* the context, only the string you give in the client connect | | * the context, only the string you give in the client connect |
* info for .origin (if any) will be used directly. | | * info for .origin (if any) will be used directly. |
*/ | | */ |
LWS_SERVER_OPTION_FALLBACK_TO_RAW = (1 << 20), | | LWS_SERVER_OPTION_FALLBACK_TO_RAW = (1 << 20), |
/**< (VH) if invalid http is coming in the first line, */ | | /**< (VH) if invalid http is coming in the first line, */ |
| | LWS_SERVER_OPTION_LIBEVENT = (1 << 21), |
| | /**< (CTX) Use libevent event loop */ |
| | LWS_SERVER_OPTION_ONLY_RAW = (1 << 22), |
| | /**< (VH) All connections to this vhost / port are RAW as soon as |
| | * the connection is accepted, no HTTP is going to be coming. |
| | */ |
| | LWS_SERVER_OPTION_ALLOW_LISTEN_SHARE = (1 << 23), |
| | /**< (VH) Set to allow multiple listen sockets on one interface + |
| | * address + port. The default is to strictly allow only one |
| | * listen socket at a time. This is automatically selected if you |
| | * have multiple service threads. |
| | */ |
| | |
/****** 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 1710 ¶ | | skipping to change at line 1922 ¶ |
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
ntext | | /**< CONTEXT: optional user pointer that can be recovered via the co
ntext |
* pointer using lws_context_user */ | | * pointer using lws_context_user */ |
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 1851 ¶ | | skipping to change at line 2063 ¶ |
* or you can leave it as NULL to get "DEFAULT" */ | | * or you can leave it as NULL to get "DEFAULT" */ |
#endif | | #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; |
| | /**< CONTEXT: 0 (no limit) or limit of simultaneous SSL sessions pos |
| | sible.*/ |
| | const char *socks_proxy_address; |
| | /**< VHOST: If non-NULL, attempts to proxy via the given address. |
| | * If proxy auth is required, use format "username:password\@server: |
| | port" */ |
| | unsigned int socks_proxy_port; |
| | /**< VHOST: If socks_proxy_address was non-NULL, uses this port */ |
| | #if defined(LWS_HAVE_SYS_CAPABILITY_H) && defined(LWS_HAVE_LIBCAP) |
| | cap_value_t caps[4]; |
| | /**< CONTEXT: array holding Linux capabilities you want to |
| | * continue to be available to the server after it transitions |
| | * to a noprivileged user. Usually none are needed but for, eg, |
| | * .bind_iface, CAP_NET_RAW is required. This gives you a way |
| | * to still have the capability but drop root. |
| | */ |
| | char count_caps; |
| | /**< CONTEXT: count of Linux capabilities in .caps[]. 0 means |
| | * no capabilities will be inherited from root (the default) */ |
| | #endif |
| | int bind_iface; |
| | /**< VHOST: nonzero to strictly bind sockets to the interface name i |
| | n |
| | * .iface (eg, "eth2"), using SO_BIND_TO_DEVICE. |
| | * |
| | * Requires SO_BINDTODEVICE support from your OS and CAP_NET_RAW |
| | * capability. |
| | * |
| | * Notice that common things like access network interface IP from |
| | * your local machine use your lo / loopback interface and will be |
| | * disallowed by this. |
| | */ |
| | |
/* 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 |
* | | * |
* 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. |
*/ | | */ |
| | int ssl_info_event_mask; |
| | /**< 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 |
| | * the form SSL_CB_ALERT, defined in openssl/ssl.h. The default of |
| | * 0 means no info events will be reported. |
| | */ |
| | unsigned int timeout_secs_ah_idle; |
| | /**< VHOST: seconds to allow a client to hold an ah without using it |
| | . |
| | * 0 defaults to 10s. */ |
| | |
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 1966 ¶ | | skipping to change at line 2217 ¶ |
* | | * |
* IMPORTANT! You should call this function right after creation of the | | * IMPORTANT! You should call this function right after creation of the |
* lws_context and before call to connect. If you call this | | * lws_context and before call to connect. If you call this |
* function after connect behavior is undefined. | | * function after connect behavior is undefined. |
* This function will override proxy settings made on lws_context | | * This function will override proxy settings made on lws_context |
* creation with genenv() call. | | * creation with genenv() call. |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_set_proxy(struct lws_vhost *vhost, const char *proxy); | | lws_set_proxy(struct lws_vhost *vhost, const char *proxy); |
| | |
| | /** |
| | * lws_set_socks() - Setup socks to lws_context. |
| | * \param vhost: pointer to struct lws_vhost you want set socks for |
| | * \param socks: pointer to c string containing socks in format address:por |
| | t |
| | * |
| | * Returns 0 if socks string was parsed and socks was setup. |
| | * Returns -1 if socks is NULL or has incorrect format. |
| | * |
| | * This is only required if your OS does not provide the socks_proxy |
| | * environment variable (eg, OSX) |
| | * |
| | * IMPORTANT! You should call this function right after creation of the |
| | * lws_context and before call to connect. If you call this |
| | * function after connect behavior is undefined. |
| | * This function will override proxy settings made on lws_context |
| | * creation with genenv() call. |
| | */ |
| | LWS_VISIBLE LWS_EXTERN int |
| | lws_set_socks(struct lws_vhost *vhost, const char *socks); |
| | |
struct lws_vhost; | | struct lws_vhost; |
| | |
/** | | /** |
* lws_create_vhost() - Create a vhost (virtual server context) | | * lws_create_vhost() - Create a vhost (virtual server context) |
* \param context: pointer to result of lws_create_context() | | * \param context: pointer to result of lws_create_context() |
* \param info: pointer to struct with parameters | | * \param info: pointer to struct with parameters |
* | | * |
* 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_EXTERN LWS_VISIBLE 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) |
| | * \param vhost: pointer to result of lws_create_vhost() |
| | * |
| | * This function destroys a vhost. Normally, if you just want to exit, |
| | * then lws_destroy_context() will take care of everything. If you want |
| | * to destroy an individual vhost and all connections and allocations, you |
| | * can do it with this. |
| | */ |
| | LWS_VISIBLE LWS_EXTERN void |
| | 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 |
* \param len: pointer to the remaining length left in config_strin
gs | | * \param len: pointer to the remaining length left in config_strin
gs |
* the value is decremented as strings are stored | | * the value is decremented as strings are stored |
* | | * |
* This function prepares a n lws_context_creation_info struct with global | | * This function prepares a n lws_context_creation_info struct with global |
* settings from a file d. | | * settings from a file d. |
| | |
skipping to change at line 2088 ¶ | | skipping to change at line 2371 ¶ |
const struct lws_protocol_vhost_options *options; /**< child linked-
list of more options for this node */ | | const struct lws_protocol_vhost_options *options; /**< child linked-
list of more options for this node */ |
const char *name; /**< name of name=value pair */ | | const char *name; /**< name of name=value pair */ |
const char *value; /**< value of name=value pair */ | | const char *value; /**< value of name=value pair */ |
}; | | }; |
| | |
/** enum lws_mount_protocols | | /** enum lws_mount_protocols |
* This specifies the mount protocol for a mountpoint, whether it is to be | | * This specifies the mount protocol for a mountpoint, whether it is to be |
* served from a filesystem, or it is a cgi etc. | | * served from a filesystem, or it is a cgi etc. |
*/ | | */ |
enum lws_mount_protocols { | | enum lws_mount_protocols { |
LWSMPRO_HTTP = 0, /**< not supported yet */ | | LWSMPRO_HTTP = 0, /**< http reverse proxy */ |
LWSMPRO_HTTPS = 1, /**< not supported yet */ | | LWSMPRO_HTTPS = 1, /**< https reverse proxy */ |
LWSMPRO_FILE = 2, /**< serve from filesystem directory */ | | LWSMPRO_FILE = 2, /**< serve from filesystem directory */ |
LWSMPRO_CGI = 3, /**< pass to CGI to handle */ | | LWSMPRO_CGI = 3, /**< pass to CGI to handle */ |
LWSMPRO_REDIR_HTTP = 4, /**< redirect to http:// url */ | | LWSMPRO_REDIR_HTTP = 4, /**< redirect to http:// url */ |
LWSMPRO_REDIR_HTTPS = 5, /**< redirect to https:// url */ | | LWSMPRO_REDIR_HTTPS = 5, /**< redirect to https:// url */ |
LWSMPRO_CALLBACK = 6, /**< hand by named protocol's callback
*/ | | LWSMPRO_CALLBACK = 6, /**< hand by named protocol's callback
*/ |
}; | | }; |
| | |
/** struct lws_http_mount | | /** struct lws_http_mount |
* | | * |
* arguments for mounting something in a vhost's url namespace | | * arguments for mounting something in a vhost's url namespace |
| | |
skipping to change at line 2222 ¶ | | skipping to change at line 2505 ¶ |
/**< if not NULL, store the new wsi here early in the connection | | /**< if not NULL, store the new wsi here early in the connection |
* process. Although we return the new wsi, the call to create the | | * process. Although we return the new wsi, the call to create the |
* client connection does progress the connection somewhat and may | | * client connection does progress the connection somewhat and may |
* meet an error that will result in the connection being scrubbed a
nd | | * meet an error that will result in the connection being scrubbed a
nd |
* NULL returned. While the wsi exists though, he may process a | | * NULL returned. While the wsi exists though, he may process a |
* callback like CLIENT_CONNECTION_ERROR with his wsi: this gives th
e | | * callback like CLIENT_CONNECTION_ERROR with his wsi: this gives th
e |
* user callback a way to identify which wsi it is that faced the er
ror | | * user callback a way to identify which wsi it is that faced the er
ror |
* even before the new wsi is returned and even if ultimately no wsi | | * even before the new wsi is returned and even if ultimately no wsi |
* is returned. | | * is returned. |
*/ | | */ |
| | const char *iface; |
| | /**< NULL to allow routing on any interface, or interface name or IP |
| | * to bind the socket to */ |
| | |
/* 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 |
* | | * |
* 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[4]; /**< dummy */ | | void *_unused[4]; /**< dummy */ |
| | |
skipping to change at line 2539 ¶ | | skipping to change at line 2824 ¶ |
* If anybody needs "forced service", returned timeout is zero. In that ca
se, | | * If anybody needs "forced service", returned timeout is zero. In that ca
se, |
* you can call lws_service_tsi() with a timeout of -1 to only service | | * you can call lws_service_tsi() with a timeout of -1 to only service |
* guys who need forced service. | | * guys who need forced service. |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_service_adjust_timeout(struct lws_context *context, int timeout_ms, int
tsi); | | lws_service_adjust_timeout(struct lws_context *context, int timeout_ms, int
tsi); |
| | |
/* Backwards compatibility */ | | /* Backwards compatibility */ |
#define lws_plat_service_tsi lws_service_tsi | | #define lws_plat_service_tsi lws_service_tsi |
| | |
| | LWS_VISIBLE LWS_EXTERN int |
| | lws_handle_POLLOUT_event(struct lws *wsi, struct lws_pollfd *pollfd); |
| | |
///@} | | ///@} |
| | |
/*! \defgroup http HTTP | | /*! \defgroup http HTTP |
| | |
Modules related to handling HTTP | | Modules related to handling HTTP |
*/ | | */ |
//@{ | | //@{ |
| | |
/*! \defgroup httpft HTTP File transfer | | /*! \defgroup httpft HTTP File transfer |
* \ingroup http | | * \ingroup http |
| | |
skipping to change at line 2820 ¶ | | skipping to change at line 3108 ¶ |
| | |
/* 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, |
_WSI_TOKEN_CLIENT_METHOD, | | _WSI_TOKEN_CLIENT_METHOD, |
| | _WSI_TOKEN_CLIENT_IFACE, |
| | |
/* always last real token index*/ | | /* always last real token index*/ |
WSI_TOKEN_COUNT, | | WSI_TOKEN_COUNT, |
| | |
/* parser state additions, no storage associated */ | | /* parser state additions, no storage associated */ |
WSI_TOKEN_NAME_PART, | | WSI_TOKEN_NAME_PART, |
WSI_TOKEN_SKIPPING, | | WSI_TOKEN_SKIPPING, |
WSI_TOKEN_SKIPPING_SAW_CR, | | WSI_TOKEN_SKIPPING_SAW_CR, |
WSI_PARSING_COMPLETE, | | WSI_PARSING_COMPLETE, |
WSI_INIT_TOKEN_MUXURL, | | WSI_INIT_TOKEN_MUXURL, |
| | |
skipping to change at line 2989 ¶ | | skipping to change at line 3278 ¶ |
* \param end: pointer to end of buffer | | * \param end: pointer to end of buffer |
* | | * |
* Appends name=value to the headers, but is able to take advantage of bett
er | | * Appends name=value to the headers, but is able to take advantage of bett
er |
* HTTP/2 coding mechanisms where possible. | | * HTTP/2 coding mechanisms where possible. |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT | | LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT |
lws_add_http_header_by_token(struct lws *wsi, enum lws_token_indexes token, | | lws_add_http_header_by_token(struct lws *wsi, enum lws_token_indexes token, |
const unsigned char *value, int length, | | const unsigned char *value, int length, |
unsigned char **p, unsigned char *end); | | unsigned char **p, unsigned char *end); |
/** | | /** |
* lws_add_http_header_by_name() - append content-length helper | | * lws_add_http_header_content_length() - append content-length helper |
* | | * |
* \param wsi: the connection to check | | * \param wsi: the connection to check |
* \param content_length: the content length to use | | * \param content_length: the content length to use |
* \param p: pointer to current position in buffer pointer | | * \param p: pointer to current position in buffer pointer |
* \param end: pointer to end of buffer | | * \param end: pointer to end of buffer |
* | | * |
* Appends content-length: content_length to the headers | | * Appends content-length: content_length to the headers |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT | | LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT |
lws_add_http_header_content_length(struct lws *wsi, | | lws_add_http_header_content_length(struct lws *wsi, |
unsigned long content_length, | | lws_filepos_t content_length, |
unsigned char **p, unsigned char *end); | | unsigned char **p, unsigned char *end); |
/** | | /** |
* lws_finalize_http_header() - terminate header block | | * lws_finalize_http_header() - terminate header block |
* | | * |
* \param wsi: the connection to check | | * \param wsi: the connection to check |
* \param p: pointer to current position in buffer pointer | | * \param p: pointer to current position in buffer pointer |
* \param end: pointer to end of buffer | | * \param end: pointer to end of buffer |
* | | * |
* Indicates no more headers will be added | | * Indicates no more headers will be added |
*/ | | */ |
| | |
skipping to change at line 3306 ¶ | | skipping to change at line 3595 ¶ |
lws_libuv_stop_without_kill(const struct lws_context *context, int tsi); | | lws_libuv_stop_without_kill(const struct lws_context *context, int tsi); |
| | |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
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_close_all_handles_in_loop(uv_loop_t *loop); |
#endif /* LWS_USE_LIBUV */ | | #endif /* LWS_USE_LIBUV */ |
///@} | | ///@} |
| | |
| | /*! \defgroup event libevent helpers |
| | * |
| | * ##libevent helpers |
| | * |
| | * APIs specific to libevent event loop itegration |
| | */ |
| | ///@{ |
| | |
| | #ifdef LWS_USE_LIBEVENT |
| | typedef void (lws_event_signal_cb_t) (evutil_socket_t sock_fd, short revent |
| | s, |
| | void *ctx); |
| | |
| | LWS_VISIBLE LWS_EXTERN int |
| | lws_event_sigint_cfg(struct lws_context *context, int use_event_sigint, |
| | lws_event_signal_cb_t cb); |
| | |
| | LWS_VISIBLE LWS_EXTERN int |
| | lws_event_initloop(struct lws_context *context, struct event_base *loop, |
| | int tsi); |
| | |
| | LWS_VISIBLE LWS_EXTERN void |
| | lws_event_sigint_cb(evutil_socket_t sock_fd, short revents, |
| | void *ctx); |
| | #endif /* LWS_USE_LIBEVENT */ |
| | |
| | ///@} |
| | |
/*! \defgroup timeout Connection timeouts | | /*! \defgroup timeout Connection timeouts |
| | |
APIs related to setting connection timeouts | | APIs related to setting connection timeouts |
*/ | | */ |
//@{ | | //@{ |
| | |
/* | | /* |
* NOTE: These public enums are part of the abi. If you want to add one, | | * NOTE: These public enums are part of the abi. If you want to add one, |
* add it at where specified so existing users are unaffected. | | * add it at where specified so existing users are unaffected. |
*/ | | */ |
| | |
skipping to change at line 3339 ¶ | | skipping to change at line 3658 ¶ |
PENDING_TIMEOUT_SSL_ACCEPT = 9, | | PENDING_TIMEOUT_SSL_ACCEPT = 9, |
PENDING_TIMEOUT_HTTP_CONTENT = 10, | | PENDING_TIMEOUT_HTTP_CONTENT = 10, |
PENDING_TIMEOUT_AWAITING_CLIENT_HS_SEND = 11, | | PENDING_TIMEOUT_AWAITING_CLIENT_HS_SEND = 11, |
PENDING_FLUSH_STORED_SEND_BEFORE_CLOSE = 12, | | PENDING_FLUSH_STORED_SEND_BEFORE_CLOSE = 12, |
PENDING_TIMEOUT_SHUTDOWN_FLUSH = 13, | | PENDING_TIMEOUT_SHUTDOWN_FLUSH = 13, |
PENDING_TIMEOUT_CGI = 14, | | PENDING_TIMEOUT_CGI = 14, |
PENDING_TIMEOUT_HTTP_KEEPALIVE_IDLE = 15, | | PENDING_TIMEOUT_HTTP_KEEPALIVE_IDLE = 15, |
PENDING_TIMEOUT_WS_PONG_CHECK_SEND_PING = 16, | | PENDING_TIMEOUT_WS_PONG_CHECK_SEND_PING = 16, |
PENDING_TIMEOUT_WS_PONG_CHECK_GET_PONG = 17, | | PENDING_TIMEOUT_WS_PONG_CHECK_GET_PONG = 17, |
PENDING_TIMEOUT_CLIENT_ISSUE_PAYLOAD = 18, | | PENDING_TIMEOUT_CLIENT_ISSUE_PAYLOAD = 18, |
| | PENDING_TIMEOUT_AWAITING_SOCKS_GREETING_REPLY = 19, |
| | PENDING_TIMEOUT_AWAITING_SOCKS_CONNECT_REPLY = 20, |
| | PENDING_TIMEOUT_AWAITING_SOCKS_AUTH_REPLY = 21, |
| | PENDING_TIMEOUT_KILLED_BY_SSL_INFO = 22, |
| | PENDING_TIMEOUT_KILLED_BY_PARENT = 23, |
| | PENDING_TIMEOUT_CLOSE_SEND = 24, |
| | PENDING_TIMEOUT_HOLDING_AH = 25, |
| | |
/****** add new things just above ---^ ******/ | | /****** add new things just above ---^ ******/ |
}; | | }; |
| | |
| | #define LWS_TO_KILL_ASYNC -1 |
| | /**< 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 |
| | * 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 |
| | * return). |
| | */ |
| | #define LWS_TO_KILL_SYNC -2 |
| | /**< If LWS_TO_KILL_SYNC is given as the timeout sec in a lws_set_timeout() |
| | * call, then the connection is closed before returning (which may delete |
| | * the wsi). This should only be used where the wsi being closed is not th |
| | e |
| | * wsi currently being serviced. |
| | */ |
/** | | /** |
* lws_set_timeout() - marks the wsi as subject to a timeout | | * lws_set_timeout() - marks the wsi as subject to a timeout |
* | | * |
* You will not need this unless you are doing something special | | * You will not need this unless you are doing something special |
* | | * |
* \param wsi: Websocket connection instance | | * \param wsi: Websocket connection instance |
* \param reason: timeout reason | | * \param reason: timeout reason |
* \param secs: how many seconds | | * \param secs: how many seconds. You may set to LWS_TO_KILL_ASYNC |
| | to |
| | * force the connection to timeout at the next opportunity, or |
| | * LWS_TO_KILL_SYNC to close it synchronously if you know the |
| | * wsi is not the one currently being serviced. |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN void | | LWS_VISIBLE LWS_EXTERN void |
lws_set_timeout(struct lws *wsi, enum pending_timeout reason, int secs); | | lws_set_timeout(struct lws *wsi, enum pending_timeout reason, int secs); |
///@} | | ///@} |
| | |
/*! \defgroup sending-data Sending data | | /*! \defgroup sending-data Sending data |
| | |
APIs related to writing data on a connection | | APIs related to writing data on a connection |
*/ | | */ |
//@{ | | //@{ |
| | |
skipping to change at line 3375 ¶ | | skipping to change at line 3717 ¶ |
#define u_int64_t unsigned long long | | #define u_int64_t unsigned long long |
#endif | | #endif |
| | |
#if defined(__x86_64__) | | #if defined(__x86_64__) |
#define _LWS_PAD_SIZE 16 /* Intel recommended for best performance */ | | #define _LWS_PAD_SIZE 16 /* Intel recommended for best performance */ |
#else | | #else |
#define _LWS_PAD_SIZE LWS_SIZEOFPTR /* Size of a pointer on the target ar
ch */ | | #define _LWS_PAD_SIZE LWS_SIZEOFPTR /* Size of a pointer on the target ar
ch */ |
#endif | | #endif |
#define _LWS_PAD(n) (((n) % _LWS_PAD_SIZE) ? \ | | #define _LWS_PAD(n) (((n) % _LWS_PAD_SIZE) ? \ |
((n) + (_LWS_PAD_SIZE - ((n) % _LWS_PAD_SIZE))) : (n)) | | ((n) + (_LWS_PAD_SIZE - ((n) % _LWS_PAD_SIZE))) : (n)) |
#define LWS_PRE _LWS_PAD(4 + 10) | | /* last 2 is for lws-meta */ |
| | #define LWS_PRE _LWS_PAD(4 + 10 + 2) |
/* used prior to 1.7 and retained for backward compatibility */ | | /* used prior to 1.7 and retained for backward compatibility */ |
#define LWS_SEND_BUFFER_PRE_PADDING LWS_PRE | | #define LWS_SEND_BUFFER_PRE_PADDING LWS_PRE |
#define LWS_SEND_BUFFER_POST_PADDING 0 | | #define LWS_SEND_BUFFER_POST_PADDING 0 |
| | |
/* | | /* |
* NOTE: These public enums are part of the abi. If you want to add one, | | * NOTE: These public enums are part of the abi. If you want to add one, |
* add it at where specified so existing users are unaffected. | | * add it at where specified so existing users are unaffected. |
*/ | | */ |
enum lws_write_protocol { | | enum lws_write_protocol { |
LWS_WRITE_TEXT = 0, | | LWS_WRITE_TEXT = 0, |
| | |
skipping to change at line 3427 ¶ | | skipping to change at line 3770 ¶ |
| | |
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_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 */ |
| | |
| | struct lws_write_passthru { |
| | struct lws *wsi; |
| | unsigned char *buf; |
| | size_t len; |
| | enum lws_write_protocol wp; |
| | }; |
| | |
/** | | /** |
* lws_write() - Apply protocol then write data to client | | * lws_write() - Apply protocol then write data to client |
* \param wsi: Websocket instance (available from user callback) | | * \param wsi: Websocket instance (available from user callback) |
* \param buf: The data to send. For data being sent on a websocket | | * \param buf: The data to send. For data being sent on a websocket |
* connection (ie, not default http), this buffer MUST have | | * connection (ie, not default http), this buffer MUST have |
* LWS_PRE bytes valid BEFORE the pointer. | | * LWS_PRE bytes valid BEFORE the pointer. |
* This is so the protocol header data can be added in-situ. | | * This is so the protocol header data can be added in-situ. |
* \param len: Count of the data bytes in the payload starting from buf | | * \param len: Count of the data bytes in the payload starting from buf |
* \param protocol: Use LWS_WRITE_HTTP to reply to an http connection, a
nd one | | * \param protocol: Use LWS_WRITE_HTTP to reply to an http connection, a
nd one |
* of LWS_WRITE_BINARY or LWS_WRITE_TEXT to send appropriate | | * of LWS_WRITE_BINARY or LWS_WRITE_TEXT to send appropriate |
| | |
skipping to change at line 3769 ¶ | | skipping to change at line 4121 ¶ |
* 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); |
| | |
typedef enum { | | typedef enum { |
LWS_ADOPT_RAW_FILE_DESC = 0, /* convenience constant */ | | LWS_ADOPT_RAW_FILE_DESC = 0, /* convenience constant */ |
LWS_ADOPT_HTTP = 1, /* flag: absent implies RAW */ | | LWS_ADOPT_HTTP = 1, /* flag: absent implies RAW */ |
LWS_ADOPT_SOCKET = 2, /* flag: absent implies file descr *
/ | | LWS_ADOPT_SOCKET = 2, /* flag: absent implies file descr *
/ |
LWS_ADOPT_ALLOW_SSL = 4 /* flag: if set requires LWS_ADOPT_S | | LWS_ADOPT_ALLOW_SSL = 4, /* flag: if set requires LWS_ADOPT_S |
OCKET */ | | OCKET */ |
| | LWS_ADOPT_WS_PARENTIO = 8, /* flag: ws mode parent handles IO |
| | * if given must be only flag |
| | * wsi put directly into ws mode |
| | */ |
} lws_adoption_type; | | } lws_adoption_type; |
| | |
typedef union { | | typedef union { |
lws_sockfd_type sockfd; | | lws_sockfd_type sockfd; |
lws_filefd_type filefd; | | lws_filefd_type filefd; |
} lws_sock_file_fd_type; | | } lws_sock_file_fd_type; |
| | |
/* | | /* |
* lws_adopt_descriptor_vhost() - adopt foreign socket or file descriptor | | * lws_adopt_descriptor_vhost() - adopt foreign socket or file descriptor |
* if socket descriptor, should already have been accepted from listen socke
t | | * if socket descriptor, should already have been accepted from listen socke
t |
| | |
skipping to change at line 3796 ¶ | | skipping to change at line 4152 ¶ |
* | | * |
* 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. |
* | | * |
* If LWS_ADOPT_SOCKET is set, LWS adopts the socket in http serving mode, i
t's | | * If LWS_ADOPT_SOCKET is set, LWS adopts the socket in http serving mode, i
t's |
* ready to accept an upgrade to ws or just serve http. | | * ready to accept an upgrade to ws or just serve http. |
* | | * |
* parent may be NULL, if given it should be an existing wsi that will becom
e the | | * parent may be NULL, if given it should be an existing wsi that will becom
e the |
* parent of the new wsi created by this call. | | * parent of the new wsi created by this call. |
*/ | | */ |
LWS_VISIBLE struct lws * | | LWS_VISIBLE LWS_EXTERN struct lws * |
lws_adopt_descriptor_vhost(struct lws_vhost *vh, lws_adoption_type type, | | lws_adopt_descriptor_vhost(struct lws_vhost *vh, lws_adoption_type type, |
lws_sock_file_fd_type fd, const char *vh_prot_nam
e, | | lws_sock_file_fd_type fd, const char *vh_prot_nam
e, |
struct lws *parent); | | struct lws *parent); |
| | |
/** | | /** |
* lws_adopt_socket_readbuf() - adopt foreign socket and first rx as if lis
ten socket accepted it | | * lws_adopt_socket_readbuf() - adopt foreign socket and first rx as if lis
ten socket accepted it |
* 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 |
* \param readbuf: NULL or pointer to data that must be drained before
reading from | | * \param readbuf: NULL or pointer to data that must be drained before
reading from |
| | |
skipping to change at line 3930 ¶ | | skipping to change at line 4286 ¶ |
#endif | | #endif |
| | |
/** \defgroup misc Miscellaneous APIs | | /** \defgroup misc Miscellaneous APIs |
* ##Miscellaneous APIs | | * ##Miscellaneous APIs |
* | | * |
* Various APIs outside of other categories | | * Various APIs outside of other categories |
*/ | | */ |
///@{ | | ///@{ |
| | |
/** | | /** |
| | * lws_start_foreach_ll(): linkedlist iterator helper start |
| | * |
| | * \param type: type of iteration, eg, struct xyz * |
| | * \param it: iterator var name to create |
| | * \param start: start of list |
| | * |
| | * This helper creates an iterator and starts a while (it) { |
| | * loop. The iterator runs through the linked list starting at start and |
| | * ends when it gets a NULL. |
| | * The while loop should be terminated using lws_start_foreach_ll(). |
| | */ |
| | #define lws_start_foreach_ll(type, it, start)\ |
| | { \ |
| | type it = start; \ |
| | while (it) { |
| | |
| | /** |
| | * lws_end_foreach_ll(): linkedlist iterator helper end |
| | * |
| | * \param it: same iterator var name given when starting |
| | * \param nxt: member name in the iterator pointing to next list element |
| | * |
| | * This helper is the partner for lws_start_foreach_ll() that ends the |
| | * while loop. |
| | */ |
| | |
| | #define lws_end_foreach_ll(it, nxt) \ |
| | it = it->nxt; \ |
| | } \ |
| | } |
| | |
| | /** |
| | * lws_start_foreach_llp(): linkedlist pointer iterator helper start |
| | * |
| | * \param type: type of iteration, eg, struct xyz ** |
| | * \param it: iterator var name to create |
| | * \param start: start of list |
| | * |
| | * This helper creates an iterator and starts a while (it) { |
| | * loop. The iterator runs through the linked list starting at the |
| | * address of start and ends when it gets a NULL. |
| | * The while loop should be terminated using lws_start_foreach_llp(). |
| | * |
| | * This helper variant iterates using a pointer to the previous linked-list |
| | * element. That allows you to easily delete list members by rewriting the |
| | * previous pointer to the element's next pointer. |
| | */ |
| | #define lws_start_foreach_llp(type, it, start)\ |
| | { \ |
| | type it = &(start); \ |
| | while (*(it)) { |
| | |
| | /** |
| | * lws_end_foreach_llp(): linkedlist pointer iterator helper end |
| | * |
| | * \param it: same iterator var name given when starting |
| | * \param nxt: member name in the iterator pointing to next list element |
| | * |
| | * This helper is the partner for lws_start_foreach_llp() that ends the |
| | * while loop. |
| | */ |
| | |
| | #define lws_end_foreach_llp(it, nxt) \ |
| | it = &(*(it))->nxt; \ |
| | } \ |
| | } |
| | |
| | /** |
* lws_snprintf(): snprintf that truncates the returned length too | | * lws_snprintf(): snprintf that truncates the returned length too |
* | | * |
* \param str: destination buffer | | * \param str: destination buffer |
* \param size: bytes left in destination buffer | | * \param size: bytes left in destination buffer |
* \param format: format string | | * \param format: format string |
* \param ...: args for format | | * \param ...: args for format |
* | | * |
* This lets you correctly truncate buffers by concatenating lengths, if yo
u | | * This lets you correctly truncate buffers by concatenating lengths, if yo
u |
* reach the limit the reported length doesn't exceed the limit. | | * reach the limit the reported length doesn't exceed the limit. |
*/ | | */ |
| | |
skipping to change at line 4059 ¶ | | skipping to change at line 4483 ¶ |
| | |
/** | | /** |
* lws_get_child() - get child wsi or NULL | | * lws_get_child() - get child wsi or NULL |
* \param wsi: lws connection | | * \param wsi: lws connection |
* | | * |
* Allows you to find a related wsi from the parent wsi. | | * Allows you to find a related wsi from the parent wsi. |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT | | LWS_VISIBLE LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT |
lws_get_child(const struct lws *wsi); | | lws_get_child(const struct lws *wsi); |
| | |
| | /** |
| | * lws_parent_carries_io() - mark wsi as needing to send messages via paren |
| | t |
| | * |
| | * \param wsi: child lws connection |
| | */ |
| | |
| | LWS_VISIBLE LWS_EXTERN void |
| | lws_set_parent_carries_io(struct lws *wsi); |
| | |
| | LWS_VISIBLE LWS_EXTERN void * |
| | lws_get_opaque_parent_data(const struct lws *wsi); |
| | |
| | LWS_VISIBLE LWS_EXTERN void |
| | lws_set_opaque_parent_data(struct lws *wsi, void *data); |
| | |
| | LWS_VISIBLE LWS_EXTERN int |
| | lws_get_child_pending_on_writable(const struct lws *wsi); |
| | |
| | LWS_VISIBLE LWS_EXTERN void |
| | lws_clear_child_pending_on_writable(struct lws *wsi); |
| | |
| | LWS_VISIBLE LWS_EXTERN int |
| | lws_get_close_length(struct lws *wsi); |
| | |
| | LWS_VISIBLE LWS_EXTERN unsigned char * |
| | lws_get_close_payload(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, size_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)); |
| | |
skipping to change at line 4095 ¶ | | skipping to change at line 4546 ¶ |
* lws_send_pipe_choked() - tests if socket is writable or not | | * lws_send_pipe_choked() - tests if socket is writable or not |
* \param wsi: lws connection | | * \param wsi: lws connection |
* | | * |
* Allows you to check if you can write more on the socket | | * Allows you to check if you can write more on the socket |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT | | LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT |
lws_send_pipe_choked(struct lws *wsi); | | lws_send_pipe_choked(struct lws *wsi); |
| | |
/** | | /** |
* lws_is_final_fragment() - tests if last part of ws message | | * lws_is_final_fragment() - tests if last part of ws message |
| | * |
* \param wsi: lws connection | | * \param wsi: lws connection |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
lws_is_final_fragment(struct lws *wsi); | | lws_is_final_fragment(struct lws *wsi); |
| | |
/** | | /** |
| | * lws_is_first_fragment() - tests if first part of ws message |
| | * |
| | * \param wsi: lws connection |
| | */ |
| | LWS_VISIBLE LWS_EXTERN int |
| | lws_is_first_fragment(struct lws *wsi); |
| | |
| | /** |
* lws_get_reserved_bits() - access reserved bits of ws frame | | * lws_get_reserved_bits() - access reserved bits of ws frame |
* \param wsi: lws connection | | * \param wsi: lws connection |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN unsigned char | | LWS_VISIBLE LWS_EXTERN unsigned char |
lws_get_reserved_bits(struct lws *wsi); | | lws_get_reserved_bits(struct lws *wsi); |
| | |
/** | | /** |
* lws_partial_buffered() - find out if lws buffered the last write | | * lws_partial_buffered() - find out if lws buffered the last write |
* \param wsi: websocket connection to check | | * \param wsi: websocket connection to check |
* | | * |
| | |
skipping to change at line 4235 ¶ | | skipping to change at line 4695 ¶ |
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, |
LCHS_CR2, | | LCHS_CR2, |
LCHS_LF2, | | LCHS_LF2, |
| | LHCS_RESPONSE, |
| | LHCS_DUMP_HEADERS, |
LHCS_PAYLOAD, | | LHCS_PAYLOAD, |
LCHS_SINGLE_0A, | | LCHS_SINGLE_0A, |
}; | | }; |
| | |
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 */ |
| | |
skipping to change at line 4325 ¶ | | skipping to change at line 4787 ¶ |
#endif | | #endif |
| | |
#define LWS_FOP_FLAGS_MASK ((1 << 23) - 1) | | #define LWS_FOP_FLAGS_MASK ((1 << 23) - 1) |
#define LWS_FOP_FLAG_COMPR_ACCEPTABLE_GZIP (1 << 24) | | #define LWS_FOP_FLAG_COMPR_ACCEPTABLE_GZIP (1 << 24) |
#define LWS_FOP_FLAG_COMPR_IS_GZIP (1 << 25) | | #define LWS_FOP_FLAG_COMPR_IS_GZIP (1 << 25) |
#define LWS_FOP_FLAG_MOD_TIME_VALID (1 << 26) | | #define LWS_FOP_FLAG_MOD_TIME_VALID (1 << 26) |
#define LWS_FOP_FLAG_VIRTUAL (1 << 27) | | #define LWS_FOP_FLAG_VIRTUAL (1 << 27) |
| | |
struct lws_plat_file_ops; | | struct lws_plat_file_ops; |
| | |
#if (defined(WIN32) || defined(_WIN32)) && !defined(__MINGW32__) | | |
/* ... */ | | |
#if !defined(ssize_t) | | |
typedef SSIZE_T ssize_t; | | |
#endif | | |
#endif | | |
| | |
#if defined(LWS_HAVE_STDINT_H) | | |
#include <stdint.h> | | |
#else | | |
#if defined(WIN32) || defined(_WIN32) | | |
/* !!! >:-[ */ | | |
typedef unsigned __int32 uint32_t; | | |
typedef unsigned __int16 uint16_t; | | |
typedef unsigned __int8 uint8_t; | | |
#else | | |
typedef unsigned int uint32_t; | | |
typedef unsigned short uint16_t; | | |
typedef unsigned char uint8_t; | | |
#endif | | |
#endif | | |
| | |
typedef size_t lws_filepos_t; | | |
typedef ssize_t lws_fileofs_t; | | |
typedef uint32_t lws_fop_flags_t; | | |
| | |
struct lws_fop_fd { | | struct lws_fop_fd { |
lws_filefd_type fd; | | lws_filefd_type fd; |
/**< real file descriptor related to the file... */ | | /**< real file descriptor related to the file... */ |
const struct lws_plat_file_ops *fops; | | const struct lws_plat_file_ops *fops; |
/**< fops that apply to this fop_fd */ | | /**< fops that apply to this fop_fd */ |
void *filesystem_priv; | | void *filesystem_priv; |
/**< ignored by lws; owned by the fops handlers */ | | /**< ignored by lws; owned by the fops handlers */ |
lws_filepos_t pos; | | lws_filepos_t pos; |
/**< generic "position in file" */ | | /**< generic "position in file" */ |
lws_filepos_t len; | | lws_filepos_t len; |
| | |
skipping to change at line 4547 ¶ | | skipping to change at line 4983 ¶ |
_lws_plat_file_close(lws_fop_fd_t *fop_fd); | | _lws_plat_file_close(lws_fop_fd_t *fop_fd); |
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_alloc_vfs_file(struct lws_context *context, const char *filename, uint8 |
| | _t **buf, |
| | lws_filepos_t *amount); |
//@} | | //@} |
| | |
/** \defgroup smtp | | /** \defgroup smtp |
* \ingroup lwsapi | | * \ingroup lwsapi |
* ##SMTP related functions | | * ##SMTP related functions |
* | | * |
* 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 |
| | |
skipping to change at line 4672 ¶ | | skipping to change at line 5111 ¶ |
* \param email: the struct lws_email context | | * \param email: the struct lws_email context |
* | | * |
* Stop sending email using email and free allocations | | * Stop sending email using email and free allocations |
*/ | | */ |
LWS_VISIBLE LWS_EXTERN void | | LWS_VISIBLE LWS_EXTERN void |
lws_email_destroy(struct lws_email *email); | | lws_email_destroy(struct lws_email *email); |
| | |
#endif | | #endif |
//@} | | //@} |
| | |
| | /* |
| | * Stats are all uint64_t numbers that start at 0. |
| | * Index names here have the convention |
| | * |
| | * _C_ counter |
| | * _B_ byte count |
| | * _MS_ millisecond count |
| | */ |
| | |
| | enum { |
| | LWSSTATS_C_CONNECTIONS, /**< count incoming connections */ |
| | LWSSTATS_C_API_CLOSE, /**< count calls to close 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_WRITE, /**< count calls to write API */ |
| | LWSSTATS_C_WRITE_PARTIALS, /**< count of partial writes */ |
| | 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, /**< count of writable callbacks */ |
| | 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_CONNS_HAD_RX, /**< count of accepted SSL conns that h |
| | ave had some RX */ |
| | LWSSTATS_C_TIMEOUTS, /**< count of timed-out connections */ |
| | LWSSTATS_C_SERVICE_ENTRY, /**< count of entries to lws service loop |
| | */ |
| | LWSSTATS_B_READ, /**< aggregate bytes read */ |
| | LWSSTATS_B_WRITE, /**< aggregate bytes written */ |
| | 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_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_SSL_RX_DELAY, /**< aggregate delay between ssl accept co |
| | mplete and first RX */ |
| | |
| | /* Add new things just above here ---^ |
| | * This is part of the ABI, don't needlessly break compatibility */ |
| | LWSSTATS_SIZE |
| | }; |
| | |
| | #if defined(LWS_WITH_STATS) |
| | |
| | LWS_VISIBLE LWS_EXTERN uint64_t |
| | lws_stats_get(struct lws_context *context, int index); |
| | LWS_VISIBLE LWS_EXTERN void |
| | lws_stats_log_dump(struct lws_context *context); |
| | #else |
| | static LWS_INLINE uint64_t |
| | lws_stats_get(struct lws_context *context, int index) { return 0; } |
| | static LWS_INLINE void |
| | lws_stats_log_dump(struct lws_context *context) { } |
| | #endif |
| | |
#ifdef __cplusplus | | #ifdef __cplusplus |
} | | } |
#endif | | #endif |
| | |
#endif | | #endif |
| | |
End of changes. 55 change blocks. |
54 lines changed or deleted | | 573 lines changed or added |
|