ABI
Tracker

(libwebsockets)




Headers diff: 2.1.1 vs 2.2.0



 libwebsockets.h (2.1.1)   libwebsockets.h (2.2.0) 
skipping to change at line 30 skipping to change at line 30
*/ */
/** @file */ /** @file */
#ifndef LIBWEBSOCKET_H_3060898B846849FF9F88F5DB59B5950C #ifndef LIBWEBSOCKET_H_3060898B846849FF9F88F5DB59B5950C
#define LIBWEBSOCKET_H_3060898B846849FF9F88F5DB59B5950C #define LIBWEBSOCKET_H_3060898B846849FF9F88F5DB59B5950C
#ifdef __cplusplus #ifdef __cplusplus
#include <cstddef> #include <cstddef>
#include <cstdarg> #include <cstdarg>
#ifdef MBED_OPERATORS #
#include "mbed-drivers/mbed.h"
#include "sal-iface-eth/EthernetInterface.h"
#include "sockets/TCPListener.h"
#include "sal-stack-lwip/lwipv4_init.h"
namespace {
}
using namespace mbed::Sockets::v0;
struct sockaddr_in;
struct lws;
class lws_conn {
public:
lws_conn():
ts(NULL),
wsi(NULL),
writeable(1),
awaiting_on_writeable(0)
{
}
public:
void set_wsi(struct lws *_wsi) { wsi = _wsi; }
int actual_onRX(Socket *s);
void onRX(Socket *s);
void onError(Socket *s, socket_error_t err);
void onDisconnect(TCPStream *s);
void onSent(Socket *s, uint16_t len);
void serialized_writeable(struct lws *wsi);
public:
TCPStream *ts;
public:
struct lws *wsi;
char writeable;
char awaiting_on_writeable;
};
class lws_conn_listener : lws_conn {
public:
lws_conn_listener():
srv(SOCKET_STACK_LWIP_IPV4)
{
srv.setOnError(TCPStream::ErrorHandler_t(this,
&lws_conn_listener::onError));
}
void start(const uint16_t port); /**< start listening */
protected:
void onRX(Socket *s); /**< incoming data ready */
void onError(Socket *s, socket_error_t err); /**< if error occurs */
void onIncoming(TCPListener *s, void *impl); /**< new connection */
void onDisconnect(TCPStream *s); /**< disconnection */
public:
TCPListener srv;
};
#endif
extern "C" { extern "C" {
#else #else
#include <stdarg.h> #include <stdarg.h>
#endif #endif
#if defined(MBED_OPERATORS) || defined(LWS_WITH_ESP8266) static inline int lws_is_be(void) {
const int probe = ~0xff;
return *(const char *)&probe;
}
#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" #include "lws_config.h"
#if defined(WIN32) || defined(_WIN32) #if defined(WIN32) || defined(_WIN32)
#ifndef WIN32_LEAN_AND_MEAN #ifndef WIN32_LEAN_AND_MEAN
skipping to change at line 169 skipping to change at line 112
#else /* NOT WIN32 */ #else /* NOT WIN32 */
#include <unistd.h> #include <unistd.h>
#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
#if !defined(MBED_OPERATORS) && !defined(LWS_WITH_ESP8266) #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() (20)
#if defined(LWS_WITH_ESP32)
#define LWS_INVALID_FILE NULL
#else
#define LWS_INVALID_FILE NULL #define LWS_INVALID_FILE NULL
#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 */
#if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) #if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
#define LWS_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) #define LWS_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
#else #else
#define LWS_WARN_UNUSED_RESULT #define LWS_WARN_UNUSED_RESULT
#endif #endif
skipping to change at line 221 skipping to change at line 168
#endif #endif
#endif /* LWS_USE_LIBUV */ #endif /* LWS_USE_LIBUV */
#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)
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h> #include <unistd.h>
#endif #endif
#endif
#ifdef LWS_OPENSSL_SUPPORT #ifdef LWS_OPENSSL_SUPPORT
#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_USE_POLARSSL)
#include <polarssl/ssl.h>
struct lws_polarssl_context {
x509_crt ca; /**< ca */
x509_crt certificate; /**< cert */
rsa_context key; /**< key */
};
typedef struct lws_polarssl_context SSL_CTX;
typedef ssl_context SSL;
#else
#if defined(LWS_USE_MBEDTLS)
#include <mbedtls/ssl.h>
#else
#include <openssl/ssl.h> #include <openssl/ssl.h>
#if !defined(LWS_WITH_ESP32)
#include <openssl/err.h> #include <openssl/err.h>
#endif /* not USE_MBEDTLS */ #endif
#endif /* not USE_POLARSSL */
#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
/** \defgroup log Logging /** \defgroup log Logging
* *
* ##Logging * ##Logging
* *
* Lws provides flexible and filterable logging facilities, which can be * Lws provides flexible and filterable logging facilities, which can be
* used inside lws and in user code. * used inside lws and in user code.
* *
* Log categories may be individually filtered bitwise, and directed to bui lt-in * Log categories may be individually filtered bitwise, and directed to bui lt-in
* sinks for syslog-compatible logging, or a user-defined function. * sinks for syslog-compatible logging, or a user-defined function.
skipping to change at line 281 skipping to change at line 218
LLL_ERR = 1 << 0, LLL_ERR = 1 << 0,
LLL_WARN = 1 << 1, LLL_WARN = 1 << 1,
LLL_NOTICE = 1 << 2, LLL_NOTICE = 1 << 2,
LLL_INFO = 1 << 3, LLL_INFO = 1 << 3,
LLL_DEBUG = 1 << 4, LLL_DEBUG = 1 << 4,
LLL_PARSER = 1 << 5, LLL_PARSER = 1 << 5,
LLL_HEADER = 1 << 6, LLL_HEADER = 1 << 6,
LLL_EXT = 1 << 7, LLL_EXT = 1 << 7,
LLL_CLIENT = 1 << 8, LLL_CLIENT = 1 << 8,
LLL_LATENCY = 1 << 9, LLL_LATENCY = 1 << 9,
LLL_USER = 1 << 10,
LLL_COUNT = 10 /* set to count of valid flags */ LLL_COUNT = 11 /* set to count of valid flags */
}; };
LWS_VISIBLE LWS_EXTERN void _lws_log(int filter, const char *format, ...) L WS_FORMAT(2); LWS_VISIBLE LWS_EXTERN void _lws_log(int filter, const char *format, ...) L WS_FORMAT(2);
LWS_VISIBLE LWS_EXTERN void _lws_logv(int filter, const char *format, va_li st vl); LWS_VISIBLE LWS_EXTERN void _lws_logv(int filter, const char *format, va_li st vl);
/** /**
* lwsl_timestamp: generate logging timestamp string * lwsl_timestamp: generate logging timestamp string
* *
* \param level: logging level * \param level: logging level
* \param p: char * buffer to take timestamp * \param p: char * buffer to take timestamp
* \param len: length of p * \param len: length of p
* *
* returns length written in p * returns length written in p
*/ */
LWS_VISIBLE LWS_EXTERN int LWS_VISIBLE LWS_EXTERN int
lwsl_timestamp(int level, char *p, int len); lwsl_timestamp(int level, char *p, int len);
/* these guys are unconditionally included */
#define lwsl_err(...) _lws_log(LLL_ERR, __VA_ARGS__) #define lwsl_err(...) _lws_log(LLL_ERR, __VA_ARGS__)
#define lwsl_user(...) _lws_log(LLL_USER, __VA_ARGS__)
#if !defined(LWS_WITH_NO_LOGS) #if !defined(LWS_WITH_NO_LOGS)
/* notice, warn and log are always compiled in */ /* notice and warn are usually included by being compiled in */
#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
/* /*
* weaker logging can be deselected at configure time using --disable-debu g * weaker logging can be deselected by telling CMake to build in RELEASE m ode
* that gets rid of the overhead of checking while keeping _warn and _err * that gets rid of the overhead of checking while keeping _warn and _err
* active * active
*/ */
#if defined(LWS_WITH_ESP8266) #if defined(LWS_WITH_ESP8266)
#undef _DEBUG #undef _DEBUG
#endif #endif
#ifdef _DEBUG #ifdef _DEBUG
#if defined(LWS_WITH_NO_LOGS) #if defined(LWS_WITH_NO_LOGS)
/* notice, warn and log are always compiled in */ /* notice, warn and log are always compiled in */
//#define lwsl_err(...) _lws_log(LLL_ERR, __VA_ARGS__)
#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) * lwsl_hexdump() - helper to hexdump a buffer (DEBUG builds only)
* *
* \param buf: buffer start to dump * \param buf: buffer start to dump
* \param len: length of buffer to dump * \param len: length of buffer to dump
*/ */
LWS_VISIBLE LWS_EXTERN void lwsl_hexdump(void *buf, size_t len); 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_err(...) do {} while(0)
#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)
skipping to change at line 381 skipping to change at line 320
* *
* \param level: one of LLL_ log level indexes * \param level: one of LLL_ log level indexes
* \param line: log string * \param line: log string
* *
* You use this by passing the function pointer to lws_set_log_level(), to set * You use this by passing the function pointer to lws_set_log_level(), to set
* it as the log emit function, it is not called directly. * it as the log emit function, it is not called directly.
*/ */
LWS_VISIBLE LWS_EXTERN void LWS_VISIBLE LWS_EXTERN void
lwsl_emit_syslog(int level, const char *line); lwsl_emit_syslog(int level, const char *line);
/**
* lwsl_visible() - returns true if the log level should be printed
*
* \param level: one of LLL_ log level indexes
*
* This is useful if you have to do work to generate the log content, you
* can skip the work if the log level used to print it is not actually
* enabled at runtime.
*/
LWS_VISIBLE LWS_EXTERN int
lwsl_visible(int level);
///@} ///@}
#include <stddef.h> #include <stddef.h>
#ifndef lws_container_of #ifndef lws_container_of
#define lws_container_of(P,T,M) ((T *)((char *)(P) - offsetof(T, M)) ) #define lws_container_of(P,T,M) ((T *)((char *)(P) - offsetof(T, M)) )
#endif #endif
struct lws; struct lws;
#ifndef ARRAY_SIZE #ifndef ARRAY_SIZE
skipping to change at line 424 skipping to change at line 375
struct lws_pollfd { struct lws_pollfd {
lws_sockfd_type fd; /**< file descriptor */ lws_sockfd_type fd; /**< file descriptor */
SHORT events; /**< which events to respond to */ SHORT events; /**< which events to respond to */
SHORT revents; /**< which events happened */ SHORT revents; /**< which events happened */
}; };
#define LWS_POLLHUP (FD_CLOSE) #define LWS_POLLHUP (FD_CLOSE)
#define LWS_POLLIN (FD_READ | FD_ACCEPT) #define LWS_POLLIN (FD_READ | FD_ACCEPT)
#define LWS_POLLOUT (FD_WRITE) #define LWS_POLLOUT (FD_WRITE)
#else #else
#if defined(MBED_OPERATORS)
/* it's a class lws_conn * */
typedef void * lws_sockfd_type;
typedef void * lws_filefd_type;
#define lws_sockfd_valid(sfd) (!!sfd)
struct pollfd {
lws_sockfd_type fd; /**< fd related to */
short events; /**< which POLL... events to respond to */
short revents; /**< which POLL... events occurred */
};
#define POLLIN 0x0001
#define POLLPRI 0x0002
#define POLLOUT 0x0004
#define POLLERR 0x0008
#define POLLHUP 0x0010
#define POLLNVAL 0x0020
struct lws;
void * mbed3_create_tcp_stream_socket(void);
void mbed3_delete_tcp_stream_socket(void *sockfd);
void mbed3_tcp_stream_bind(void *sock, int port, struct lws *);
void mbed3_tcp_stream_accept(void *sock, struct lws *);
#else
#if defined(LWS_WITH_ESP8266) #if defined(LWS_WITH_ESP8266)
#include <user_interface.h> #include <user_interface.h>
#include <espconn.h> #include <espconn.h>
typedef struct espconn * lws_sockfd_type; typedef struct espconn * lws_sockfd_type;
typedef void * lws_filefd_type; typedef void * lws_filefd_type;
#define lws_sockfd_valid(sfd) (!!sfd) #define lws_sockfd_valid(sfd) (!!sfd)
struct pollfd { struct pollfd {
lws_sockfd_type fd; /**< fd related to */ lws_sockfd_type fd; /**< fd related to */
skipping to change at line 514 skipping to change at line 441
/* ms, repeat */ /* ms, repeat */
os_timer_arm(t, first, !!rep); os_timer_arm(t, first, !!rep);
} }
static inline void uv_timer_stop(uv_timer_t *t) static inline void uv_timer_stop(uv_timer_t *t)
{ {
os_timer_disarm(t); os_timer_disarm(t);
} }
#else #else
#if defined(LWS_WITH_ESP32)
typedef int lws_sockfd_type;
typedef int lws_filefd_type;
#define lws_sockfd_valid(sfd) (sfd >= 0)
struct pollfd {
lws_sockfd_type fd; /**< fd related to */
short events; /**< which POLL... events to respond to */
short revents; /**< which POLL... events occurred */
};
#define POLLIN 0x0001
#define POLLPRI 0x0002
#define POLLOUT 0x0004
#define POLLERR 0x0008
#define POLLHUP 0x0010
#define POLLNVAL 0x0020
#include "freertos/timers.h"
#if !defined(CONFIG_FREERTOS_HZ)
#define CONFIG_FREERTOS_HZ 100
#endif
typedef TimerHandle_t uv_timer_t;
typedef void uv_cb_t(uv_timer_t *);
typedef void * uv_handle_t;
struct timer_mapping {
uv_cb_t *cb;
uv_timer_t *t;
};
#define UV_VERSION_MAJOR 1
#define lws_uv_getloop(a, b) (NULL)
static inline void uv_timer_init(void *l, uv_timer_t *t)
{
(void)l;
*t = NULL;
}
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)
{
struct timer_mapping *tm = malloc(sizeof(*tm));
if (!tm)
return;
tm->t = t;
tm->cb = cb;
*t = xTimerCreate("x", pdMS_TO_TICKS(first), !!rep, tm,
(TimerCallbackFunction_t)esp32_uvtimer_cb);
xTimerStart(*t, 0);
}
static inline void uv_timer_stop(uv_timer_t *t)
{
xTimerStop(*t, 0);
}
static inline void uv_close(uv_handle_t *h, void *v)
{
free(pvTimerGetTimerID((uv_timer_t)h));
xTimerDelete(*(uv_timer_t *)h, 0);
}
#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)
skipping to change at line 1015 skipping to change at line 1013
*/ */
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)
*/ */
LWS_CALLBACK_OPENSSL_PERFORM_SERVER_CERT_VERIFICATION = 58,
/**< Similar to LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATIO
N
* this callback is called during OpenSSL verification of the cert
* sent from the server to the client. It is sent to protocol[0]
* callback as no protocol has been negotiated on the connection yet
.
* Notice that the wsi is set because lws_client_connect_via_info wa
s
* successful.
*
* See http://www.openssl.org/docs/ssl/SSL_CTX_set_verify.html
* to understand more detail about the OpenSSL callback that
* generates this libwebsockets callback and the meanings of the
* arguments passed. In this callback, user is the x509_ctx,
* in is the ssl pointer and len is preverify_ok.
*
* THIS IS NOT RECOMMENDED BUT if a cert validation error shall be
* overruled and cert shall be accepted as ok,
* X509_STORE_CTX_set_error((X509_STORE_CTX*)user, X509_V_OK); must
be
* called and return value must be 0 to mean the cert is OK;
* returning 1 will fail the cert in any case.
*
* This also means that if you don't handle this callback then
* the default callback action of returning 0 will not accept the
* certificate in case of a validation error decided by the SSL lib.
*
* This is expected and secure behaviour when validating certificate
s.
*
* Note: LCCSCF_ALLOW_SELFSIGNED and
* LCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK still work without this
* callback being implemented.
*/
LWS_CALLBACK_RAW_RX = 59,
/**< RAW mode connection RX */
LWS_CALLBACK_RAW_CLOSE = 60,
/**< RAW mode connection is closing */
LWS_CALLBACK_RAW_WRITEABLE = 61,
/**< RAW mode connection may be written */
LWS_CALLBACK_RAW_ADOPT = 62,
/**< RAW mode connection was adopted (equivalent to 'wsi created') *
/
LWS_CALLBACK_RAW_ADOPT_FILE = 63,
/**< RAW mode file was adopted (equivalent to 'wsi created') */
LWS_CALLBACK_RAW_RX_FILE = 64,
/**< RAW mode file has something to read */
LWS_CALLBACK_RAW_WRITEABLE_FILE = 65,
/**< RAW mode file is writeable */
LWS_CALLBACK_RAW_CLOSE_FILE = 66,
/**< RAW mode wsi that adopted a file is closing */
/****** 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 clashe s */ /**< 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
* \param reason: The reason for the call * \param reason: The reason for the call
* \param user: Pointer to per-session user data allocated by librar y * \param user: Pointer to per-session user data allocated by librar y
* \param in: Pointer used for some callback reasons * \param in: Pointer used for some callback reasons
* \param len: Length set for some callback reasons * \param len: Length set for some callback reasons
* *
skipping to change at line 1378 skipping to change at line 1422
* 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);
LWS_VISIBLE LWS_EXTERN int
lws_protocol_init(struct lws_context *context);
#ifdef LWS_WITH_PLUGINS #ifdef LWS_WITH_PLUGINS
/* PLUGINS implies LIBUV */ /* PLUGINS implies LIBUV */
#define LWS_PLUGIN_API_MAGIC 180 #define LWS_PLUGIN_API_MAGIC 180
/** struct lws_plugin_capability - how a plugin introduces itself to lws */ /** struct lws_plugin_capability - how a plugin introduces itself to lws */
struct lws_plugin_capability { struct lws_plugin_capability {
unsigned int api_magic; /**< caller fills this in, plugin fills rest */ unsigned int api_magic; /**< caller fills this in, plugin fills rest */
const struct lws_protocols *protocols; /**< array of supported proto cols provided by plugin */ const struct lws_protocols *protocols; /**< array of supported proto cols provided by plugin */
skipping to change at line 1539 skipping to change at line 1586
LWS_SERVER_OPTION_IPV6_V6ONLY_MODIFY = (1 << 16), LWS_SERVER_OPTION_IPV6_V6ONLY_MODIFY = (1 << 16),
/**< (VH) Enable LWS_SERVER_OPTION_IPV6_V6ONLY_VALUE to take effect */ /**< (VH) Enable LWS_SERVER_OPTION_IPV6_V6ONLY_VALUE to take effect */
LWS_SERVER_OPTION_IPV6_V6ONLY_VALUE = (1 << 17), LWS_SERVER_OPTION_IPV6_V6ONLY_VALUE = (1 << 17),
/**< (VH) if set, only ipv6 allowed on the vhost */ /**< (VH) if set, only ipv6 allowed on the vhost */
LWS_SERVER_OPTION_UV_NO_SIGSEGV_SIGFPE_SPIN = (1 << 18), LWS_SERVER_OPTION_UV_NO_SIGSEGV_SIGFPE_SPIN = (1 << 18),
/**< (CTX) Libuv only: Do not spin on SIGSEGV / SIGFPE. A segfault /**< (CTX) Libuv only: Do not spin on SIGSEGV / SIGFPE. A segfault
* normally makes the lib spin so you can attach a debugger to it * normally makes the lib spin so you can attach a debugger to it
* even if it happened without a debugger in place. You can disable * even if it happened without a debugger in place. You can disable
* that by giving this option. * that by giving this option.
*/ */
LWS_SERVER_OPTION_JUST_USE_RAW_ORIGIN = (1 << 19),
/**< For backwards-compatibility reasons, by default
* lws prepends "http://" to the origin you give in the client
* connection info struct. If you give this flag when you create
* the context, only the string you give in the client connect
* info for .origin (if any) will be used directly.
*/
LWS_SERVER_OPTION_FALLBACK_TO_RAW = (1 << 20),
/**< (VH) if invalid http is coming in the first line, */
/****** 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_context_creation_info - parameters to create context and /or vhost with /** struct lws_context_creation_info - parameters to create context and /or vhost with
* *
* This is also used to create vhosts.... if LWS_SERVER_OPTION_EXPLICIT_VHO STS * This is also used to create vhosts.... if LWS_SERVER_OPTION_EXPLICIT_VHO STS
* is not given, then for backwards compatibility one vhost is created at * is not given, then for backwards compatibility one vhost is created at
* context-creation time using the info from this struct. * context-creation time using the info from this struct.
* *
* If LWS_SERVER_OPTION_EXPLICIT_VHOSTS is given, then no vhosts are create d * If LWS_SERVER_OPTION_EXPLICIT_VHOSTS is given, then no vhosts are create d
* at the same time as the context, they are expected to be created afterwa rds. * at the same time as the context, they are expected to be created afterwa rds.
*/ */
struct lws_context_creation_info { struct lws_context_creation_info {
int port; int port;
/**< VHOST: Port to listen on... you can use CONTEXT_PORT_NO_LISTEN /**< VHOST: Port to listen on. Use CONTEXT_PORT_NO_LISTEN to suppres
to s
* suppress listening on any port, that's what you want if you are * listening for a client. Use CONTEXT_PORT_NO_LISTEN_SERVER if you
* not running a websocket server at all but just using it as a are
* client */ * writing a server but you are using \ref sock-adopt instead of the
* built-in listener */
const char *iface; const char *iface;
/**< VHOST: NULL to bind the listen socket to all interfaces, or the /**< VHOST: NULL to bind the listen socket to all interfaces, or the
* interface name, eg, "eth2" * interface name, eg, "eth2"
* If options specifies LWS_SERVER_OPTION_UNIX_SOCK, this member is * If options specifies LWS_SERVER_OPTION_UNIX_SOCK, this member is
* the pathname of a UNIX domain socket. you can use the UNIX domain * the pathname of a UNIX domain socket. you can use the UNIX domain
* sockets in abstract namespace, by prepending an at symbol to the * sockets in abstract namespace, by prepending an at symbol to the
* socket name. */ * socket name. */
const struct lws_protocols *protocols; const struct lws_protocols *protocols;
/**< 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
skipping to change at line 1704 skipping to change at line 1762
* so a connection which always sends or receives something at inter vals * so a connection which always sends or receives something at inter vals
* less than the interval given here will never send PINGs / expect * less than the interval given here will never send PINGs / expect
* PONGs. Conversely as soon as the ws connection is established, a n * PONGs. Conversely as soon as the ws connection is established, a n
* idle connection will do the PING / PONG roundtrip as soon as * idle connection will do the PING / PONG roundtrip as soon as
* ws_ping_pong_interval seconds has passed without traffic * ws_ping_pong_interval seconds has passed without traffic
*/ */
const struct lws_protocol_vhost_options *headers; const struct lws_protocol_vhost_options *headers;
/**< VHOST: pointer to optional linked list of per-vhost /**< VHOST: pointer to optional linked list of per-vhost
* canned headers that are added to server responses */ * canned headers that are added to server responses */
const struct lws_protocol_vhost_options *reject_service_keywords;
/**< CONTEXT: Optional list of keywords and rejection codes + text.
*
* The keywords are checked for existing in the user agent string.
*
* Eg, "badrobot" "404 Not Found"
*/
void *external_baggage_free_on_destroy;
/**< CONTEXT: NULL, or pointer to something externally malloc'd, tha
t
* should be freed when the context is destroyed. This allows you t
o
* automatically sync the freeing action to the context destruction
* action, so there is no need for an external free() if the context
* 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;
/**< VHOST: NULL or the passphrase needed for the private key */
const char *client_ssl_cert_filepath;
/**< VHOST: If libwebsockets was compiled to use ssl, and you want
* to listen using SSL, set to the filepath to fetch the
* server cert from, otherwise NULL for unencrypted */
const char *client_ssl_private_key_filepath;
/**< VHOST: filepath to private key if wanting SSL mode;
* if this is set to NULL but sll_cert_filepath is set, the
* OPENSSL_CONTEXT_REQUIRES_PRIVATE_KEY callback is called
* to allow setting of the private key directly via openSSL
* library calls */
const char *client_ssl_ca_filepath;
/**< VHOST: CA certificate filepath or NULL */
const char *client_ssl_cipher_list;
/**< VHOST: List of valid ciphers to use (eg,
* "RC4-MD5:RC4-SHA:AES128-SHA:AES256-SHA:HIGH:!DSS:!aNULL"
* or you can leave it as NULL to get "DEFAULT" */
#endif
const struct lws_plat_file_ops *fops;
/**< CONTEXT: NULL, or pointer to an array of fops structs, terminat
ed
* by a sentinel with NULL .open.
*
* If NULL, lws provides just the platform file operations struct fo
r
* backwards compatibility.
*/
/* 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[8]; /**< dummy */ void *_unused[8]; /**< dummy */
}; };
skipping to change at line 1763 skipping to change at line 1867
* lws_context_destroy() - Destroy the websocket context * lws_context_destroy() - Destroy the websocket context
* \param context: Websocket context * \param context: Websocket context
* *
* This function closes any active connections and then frees the * This function closes any active connections and then frees the
* context. After calling this, any further use of the context is * context. After calling this, any further use of the context is
* undefined. * undefined.
*/ */
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_context_destroy2(struct lws_context *context);
typedef int (*lws_reload_func)(void);
/**
* lws_context_deprecate() - Deprecate the websocket context
* \param context: Websocket context
*
* This function is used on an existing context before superceding it
* with a new context.
*
* It closes any listen sockets in the context, so new connections are
* not possible.
*
* And it marks the context to be deleted when the number of active
* connections into it falls to zero.
*
* Otherwise if you attach the deprecated context to the replacement
* context when it has been created using lws_context_attach_deprecated
()
* both any deprecated and the new context will service their connectio
ns.
*
* This is aimed at allowing seamless configuration reloads.
*
* The callback cb will be called after the listen sockets are actually
* closed and may be reopened. In the callback the new context should
be
* configured and created. (With libuv, socket close happens async aft
er
* more loop events).
*/
LWS_VISIBLE LWS_EXTERN void
lws_context_deprecate(struct lws_context *context, lws_reload_func cb);
LWS_VISIBLE LWS_EXTERN int
lws_context_is_deprecated(struct lws_context *context);
/** /**
* lws_set_proxy() - Setups proxy to lws_context. * lws_set_proxy() - Setups proxy to lws_context.
* \param vhost: pointer to struct lws_vhost you want set proxy for * \param vhost: pointer to struct lws_vhost you want set proxy for
* \param proxy: pointer to c string containing proxy in format address:por t * \param proxy: pointer to c string containing proxy in format address:por t
* *
* Returns 0 if proxy string was parsed and proxy was setup. * Returns 0 if proxy string was parsed and proxy was setup.
* Returns -1 if proxy is NULL or has incorrect format. * Returns -1 if proxy is NULL or has incorrect format.
* *
* This is only required if your OS does not provide the http_proxy * This is only required if your OS does not provide the http_proxy
* environment variable (eg, OSX) * environment variable (eg, OSX)
skipping to change at line 1866 skipping to change at line 2005
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
*/ */
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);
/** /**
* 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.
*/ */
skipping to change at line 1951 skipping to change at line 2091
/**< max-age for reuse of client cache of files, seconds */ /**< max-age for reuse of client cache of files, seconds */
unsigned int auth_mask; unsigned int auth_mask;
/**< bits set here must be set for authorized client session */ /**< bits set here must be set for authorized client session */
unsigned int cache_reusable:1; /**< set if client cache may reuse th is */ unsigned int cache_reusable:1; /**< set if client cache may reuse th is */
unsigned int cache_revalidate:1; /**< set if client cache should rev alidate on use */ unsigned int cache_revalidate:1; /**< set if client cache should rev alidate on use */
unsigned int cache_intermediaries:1; /**< set if intermediaries are allowed to cache */ unsigned int cache_intermediaries:1; /**< set if intermediaries are allowed to cache */
unsigned char origin_protocol; /**< one of enum lws_mount_protocols */ unsigned char origin_protocol; /**< one of enum lws_mount_protocols */
unsigned char mountpoint_len; /**< length of mountpoint string */ unsigned char mountpoint_len; /**< length of mountpoint string */
const char *basic_auth_login_file;
/**<NULL, or filepath to use to check basic auth logins against */
/* 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[2]; /**< dummy */
}; };
///@} ///@}
///@} ///@}
/*! \defgroup client /*! \defgroup client
* \ingroup lwsapi * \ingroup lwsapi
* *
* ##Client releated functions * ##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),
LCCSCF_ALLOW_SELFSIGNED = (1 << 1), LCCSCF_ALLOW_SELFSIGNED = (1 << 1),
LCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK = (1 << 2) LCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK = (1 << 2),
LCCSCF_ALLOW_EXPIRED = (1 << 3)
}; };
/** struct lws_client_connect_info - parameters to connect with when using /** struct lws_client_connect_info - parameters to connect with when using
* lws_client_connect_via_info() */ * lws_client_connect_via_info() */
struct lws_client_connect_info { struct lws_client_connect_info {
struct lws_context *context; struct lws_context *context;
/**< lws context to create connection in */ /**< lws context to create connection in */
const char *address; const char *address;
/**< remote address to connect to */ /**< remote address to connect to */
skipping to change at line 1997 skipping to change at line 2151
const char *host; const char *host;
/**< content of host header */ /**< content of host header */
const char *origin; const char *origin;
/**< content of origin header */ /**< content of origin header */
const char *protocol; const char *protocol;
/**< list of ws protocols we could accept */ /**< list of ws protocols we could accept */
int ietf_version_or_minus_one; int ietf_version_or_minus_one;
/**< deprecated: currently leave at 0 or -1 */ /**< deprecated: currently leave at 0 or -1 */
void *userdata; void *userdata;
/**< if non-NULL, use this as wsi user_data instead of malloc it */ /**< if non-NULL, use this as wsi user_data instead of malloc it */
const struct lws_extension *client_exts; const void *client_exts;
/**< array of extensions that may be used on connection */ /**< UNUSED... provide in info.extensions at context creation time *
/
const char *method; const char *method;
/**< if non-NULL, do this http method instead of ws[s] upgrade. /**< if non-NULL, do this http method instead of ws[s] upgrade.
* use "GET" to be a simple http client connection */ * use "GET" to be a simple http client connection */
struct lws *parent_wsi; struct lws *parent_wsi;
/**< if another wsi is responsible for this connection, give it here . /**< if another wsi is responsible for this connection, give it here .
* this is used to make sure if the parent closes so do any * this is used to make sure if the parent closes so do any
* child connections first. */ * child connections first. */
const char *uri_replace_from; const char *uri_replace_from;
/**< if non-NULL, when this string is found in URIs in /**< if non-NULL, when this string is found in URIs in
* text/html content-encoding, it's replaced with uri_replace_to */ * text/html content-encoding, it's replaced with uri_replace_to */
skipping to change at line 2129 skipping to change at line 2283
* *
* You must create your vhost explicitly if you want to use this, so you ha ve * You must create your vhost explicitly if you want to use this, so you ha ve
* a pointer to the vhost. Create the context first with the option flag * a pointer to the vhost. Create the context first with the option flag
* LWS_SERVER_OPTION_EXPLICIT_VHOSTS and then call lws_create_vhost() with * LWS_SERVER_OPTION_EXPLICIT_VHOSTS and then call lws_create_vhost() with
* the same info struct. * the same info struct.
*/ */
LWS_VISIBLE LWS_EXTERN int LWS_VISIBLE LWS_EXTERN int
lws_init_vhost_client_ssl(const struct lws_context_creation_info *info, lws_init_vhost_client_ssl(const struct lws_context_creation_info *info,
struct lws_vhost *vhost); struct lws_vhost *vhost);
/**
* lws_http_client_read() - consume waiting received http client data
*
* \param wsi: client connection
* \param buf: pointer to buffer pointer - fill with pointer to your buffer
* \param len: pointer to chunk length - fill with max length of buffer
*
* This is called when the user code is notified client http data has arriv
ed.
* The user code may choose to delay calling it to consume the data, for ex
ample
* waiting until an onward connection is writeable.
*
* For non-chunked connections, up to len bytes of buf are filled with the
* received content. len is set to the actual amount filled before return.
*
* For chunked connections, the linear buffer content contains the chunking
* headers and it cannot be passed in one lump. Instead, this function wil
l
* call back LWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ with in pointing to the
* chunk start and len set to the chunk length. There will be as many call
s
* as there are chunks or partial chunks in the buffer.
*/
LWS_VISIBLE LWS_EXTERN int LWS_VISIBLE LWS_EXTERN int
lws_http_client_read(struct lws *wsi, char **buf, int *len); lws_http_client_read(struct lws *wsi, char **buf, int *len);
/**
* lws_http_client_http_response() - get last HTTP response code
*
* \param wsi: client connection
*
* Returns the last server response code, eg, 200 for client http connectio
ns.
*/
LWS_VISIBLE LWS_EXTERN unsigned int
lws_http_client_http_response(struct lws *wsi);
LWS_VISIBLE LWS_EXTERN void LWS_VISIBLE LWS_EXTERN void
lws_client_http_body_pending(struct lws *wsi, int something_left_to_send); lws_client_http_body_pending(struct lws *wsi, int something_left_to_send);
/** /**
* lws_client_http_body_pending() - control if client connection neeeds to send body * lws_client_http_body_pending() - control if client connection neeeds to send body
* *
* \param wsi: client connection * \param wsi: client connection
* \param something_left_to_send: nonzero if need to send more body, 0 (def ault) * \param something_left_to_send: nonzero if need to send more body, 0 (def ault)
* if nothing more to send * if nothing more to send
* *
skipping to change at line 2302 skipping to change at line 2486
* to 1 if you don't really have a poll timeout. * to 1 if you don't really have a poll timeout.
* \param tsi: thread service index * \param tsi: thread service index
* *
* Under some conditions connections may need service even though there is no * Under some conditions connections may need service even though there is no
* pending network action on them, this is "forced service". For default * pending network action on them, this is "forced service". For default
* poll() and libuv / libev, the library takes care of calling this and * poll() and libuv / libev, the library takes care of calling this and
* dealing with it for you. But for external poll() integration, you need * dealing with it for you. But for external poll() integration, you need
* access to the apis. * access to the apis.
* *
* 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_plat_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 */
* lws_plat_service_tsi() - Lowlevel platform-specific service api #define lws_plat_service_tsi lws_service_tsi
* \param context: Websocket context
* \param timeout_ms: The original poll timeout value. You can just set t
his
* to 1 if you don't really have a poll timeout.
* \param tsi: thread service index
*
* For default poll() and libuv/ev, lws takes care of using this for you. a
nd
* you can ignore it.
*
* But for external poll() integration, you need access to this api to serv
ice
* connections that need to be serviced but have no pending network activit
y.
*
* See lws_service_adjust_timeout() for more info.
*/
LWS_EXTERN LWS_VISIBLE int
lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi);
///@} ///@}
/*! \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
skipping to change at line 2376 skipping to change at line 2545
* *
* Returning <0 indicates error and the wsi should be closed. Returnin g * Returning <0 indicates error and the wsi should be closed. Returnin g
* >0 indicates the file was completely sent and * >0 indicates the file was completely sent and
* lws_http_transaction_completed() called on the wsi (and close if != 0) * lws_http_transaction_completed() called on the wsi (and close if != 0)
* ==0 indicates the file transfer is started and needs more service la ter, * ==0 indicates the file transfer is started and needs more service la ter,
* 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 /*! \defgroup html-chunked-substitution HTML Chunked Substitution
* \ingroup http * \ingroup http
* *
* ##HTML chunked Substitution * ##HTML chunked Substitution
* *
* APIs for receiving chunks of text, replacing a set of variable names via * APIs for receiving chunks of text, replacing a set of variable names via
* a callback, and then prepending and appending HTML chunked encoding * a callback, and then prepending and appending HTML chunked encoding
* headers. * headers.
*/ */
//@{ //@{
enum http_status { enum http_status {
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_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_BAD_REQUEST = 400, HTTP_STATUS_BAD_REQUEST = 400,
HTTP_STATUS_UNAUTHORIZED, HTTP_STATUS_UNAUTHORIZED,
HTTP_STATUS_PAYMENT_REQUIRED, HTTP_STATUS_PAYMENT_REQUIRED,
HTTP_STATUS_FORBIDDEN, HTTP_STATUS_FORBIDDEN,
HTTP_STATUS_NOT_FOUND, HTTP_STATUS_NOT_FOUND,
HTTP_STATUS_METHOD_NOT_ALLOWED, HTTP_STATUS_METHOD_NOT_ALLOWED,
HTTP_STATUS_NOT_ACCEPTABLE, HTTP_STATUS_NOT_ACCEPTABLE,
HTTP_STATUS_PROXY_AUTH_REQUIRED, HTTP_STATUS_PROXY_AUTH_REQUIRED,
HTTP_STATUS_REQUEST_TIMEOUT, HTTP_STATUS_REQUEST_TIMEOUT,
skipping to change at line 2591 skipping to change at line 2763
WSI_TOKEN_HTTP_WWW_AUTHENTICATE = 72, WSI_TOKEN_HTTP_WWW_AUTHENTICATE = 72,
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_CONNECT = 81,
/****** 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 2716 skipping to change at line 2889
* both HTTP/1.x and HTTP/2. * both HTTP/1.x and HTTP/2.
* *
* They each append to a buffer taking care about the buffer end, which is * They each append to a buffer taking care about the buffer end, which is
* passed in as a pointer. When data is written to the buffer, the current * passed in as a pointer. When data is written to the buffer, the current
* position p is updated accordingly. * position p is updated accordingly.
* *
* All of these apis are LWS_WARN_UNUSED_RESULT as they can run out of spac e * All of these apis are LWS_WARN_UNUSED_RESULT as they can run out of spac e
* and fail with nonzero return. * and fail with nonzero return.
*/ */
///@{ ///@{
#define LWSAHH_CODE_MASK ((1 << 16) - 1)
#define LWSAHH_FLAG_NO_SERVER_NAME (1 << 30)
/** /**
* lws_add_http_header_status() - add the HTTP response status code * lws_add_http_header_status() - add the HTTP response status code
* *
* \param wsi: the connection to check * \param wsi: the connection to check
* \param code: an HTTP code like 200, 404 etc (see enum http_status) * \param code: an HTTP code like 200, 404 etc (see enum http_status)
* \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
* *
* Adds the initial response code, so should be called first * Adds the initial response code, so should be called first.
*
* Code may additionally take OR'd flags:
*
* LWSAHH_FLAG_NO_SERVER_NAME: don't apply server name header this time
*/ */
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_add_http_header_status(struct lws *wsi, lws_add_http_header_status(struct lws *wsi,
unsigned int code, unsigned char **p, unsigned int code, unsigned char **p,
unsigned char *end); unsigned char *end);
/** /**
* lws_add_http_header_by_name() - append named header and value * lws_add_http_header_by_name() - append named header and value
* *
* \param wsi: the connection to check * \param wsi: the connection to check
* \param name: the hdr name, like "my-header" * \param name: the hdr name, like "my-header"
skipping to change at line 3070 skipping to change at line 3251
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);
LWS_VISIBLE LWS_EXTERN void
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);
#endif /* LWS_USE_LIBUV */ #endif /* LWS_USE_LIBUV */
///@} ///@}
skipping to change at line 3506 skipping to change at line 3690
* *
* 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.
* \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
* for vhost
* \param vhost: lws vhost
* \param accept_fd: fd of already-accepted socket to adopt
*
* Either returns new wsi bound to accept_fd, or closes accept_fd and
* 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
* to ws or just serve http.
*/
LWS_VISIBLE LWS_EXTERN struct lws *
lws_adopt_socket_vhost(struct lws_vhost *vh, lws_sockfd_type accept_fd);
typedef enum {
LWS_ADOPT_RAW_FILE_DESC = 0, /* convenience constant */
LWS_ADOPT_HTTP = 1, /* flag: absent implies RAW */
LWS_ADOPT_SOCKET = 2, /* flag: absent implies file descr *
/
LWS_ADOPT_ALLOW_SSL = 4 /* flag: if set requires LWS_ADOPT_S
OCKET */
} lws_adoption_type;
typedef union {
lws_sockfd_type sockfd;
lws_filefd_type filefd;
} lws_sock_file_fd_type;
/*
* lws_adopt_descriptor_vhost() - adopt foreign socket or file descriptor
* if socket descriptor, should already have been accepted from listen socke
t
*
* \param vhost: lws vhost
* \param type: OR-ed combinations of lws_adoption_type flags
* \param fd: union with either .sockfd or .filefd set
* \param vh_prot_name: NULL or vh protocol name to bind raw connection to
* \param parent: NULL or struct lws to attach new_wsi to as a child
*
* Either returns new wsi bound to accept_fd, or closes accept_fd and
* 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
* 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 of the new wsi created by this call.
*/
LWS_VISIBLE struct lws *
lws_adopt_descriptor_vhost(struct lws_vhost *vh, lws_adoption_type type,
lws_sock_file_fd_type fd, const char *vh_prot_nam
e,
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.
* \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
* accept_fd * accept_fd
* \param len: The length of the data held at \param readbuf * \param len: The length of the data held at \param readbuf
* *
* 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
skipping to change at line 3541 skipping to change at line 3778
* If your external code did not already read from the socket, you can use * If your external code did not already read from the socket, you can use
* lws_adopt_socket() instead. * lws_adopt_socket() instead.
* *
* This api is guaranteed to use the data at \param readbuf first, before r eading from * This api is guaranteed to use the data at \param readbuf first, before r eading from
* the socket. * the socket.
* *
* readbuf is limited to the size of the ah rx buf, currently 2048 bytes. * readbuf is limited to the size of the ah rx buf, currently 2048 bytes.
*/ */
LWS_VISIBLE LWS_EXTERN struct lws * LWS_VISIBLE LWS_EXTERN struct lws *
lws_adopt_socket_readbuf(struct lws_context *context, lws_sockfd_type accep t_fd, lws_adopt_socket_readbuf(struct lws_context *context, lws_sockfd_type accep t_fd,
const char *readbuf, size_t len); const char *readbuf, size_t len);
/**
* lws_adopt_socket_vhost_readbuf() - adopt foreign socket and first rx as
if listen socket
* accepted it for vhost.
* \param vhost: lws vhost
* \param accept_fd: fd of already-accepted socket to adopt
* \param readbuf: NULL or pointer to data that must be drained before
reading from
* accept_fd
* \param len: The length of the data held at \param readbuf
*
* Either returns new wsi bound to accept_fd, or closes accept_fd and
* 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
* to ws or just serve http.
*
* If your external code did not already read from the socket, you can use
* lws_adopt_socket() instead.
*
* This api is guaranteed to use the data at \param readbuf first, before r
eading from
* the socket.
*
* readbuf is limited to the size of the ah rx buf, currently 2048 bytes.
*/
LWS_VISIBLE LWS_EXTERN struct lws *
lws_adopt_socket_vhost_readbuf(struct lws_vhost *vhost, lws_sockfd_type acc
ept_fd,
const char *readbuf, size_t len);
///@} ///@}
/** \defgroup net Network related helper APIs /** \defgroup net Network related helper APIs
* ##Network related helper APIs * ##Network related helper APIs
* *
* These wrap miscellaneous useful network-related functions * These wrap miscellaneous useful network-related functions
*/ */
///@{ ///@{
/** /**
skipping to change at line 3593 skipping to change at line 3856
* *
* \param wsi: Local struct lws associated with * \param wsi: Local struct lws associated with
* \param name: Buffer to take client address name * \param name: Buffer to take client address name
* \param namelen: Length of client address name buffer * \param namelen: Length of client address name buffer
* *
* This provides a 123.123.123.123 type IP address in name from the * This provides a 123.123.123.123 type IP address in name from the
* peer that has connected to wsi * peer that has connected to wsi
*/ */
LWS_VISIBLE LWS_EXTERN const char * LWS_VISIBLE LWS_EXTERN const char *
lws_get_peer_simple(struct lws *wsi, char *name, int namelen); lws_get_peer_simple(struct lws *wsi, char *name, int namelen);
#ifndef LWS_WITH_ESP8266 #if !defined(LWS_WITH_ESP8266) && !defined(LWS_WITH_ESP32)
/** /**
* lws_interface_to_sa() - Convert interface name or IP to sockaddr struct * lws_interface_to_sa() - Convert interface name or IP to sockaddr struct
* *
* \param ipv6: Allow IPV6 addresses * \param ipv6: Allow IPV6 addresses
* \param ifname: Interface name or IP * \param ifname: Interface name or IP
* \param addr: struct sockaddr_in * to be written * \param addr: struct sockaddr_in * to be written
* \param addrlen: Length of addr * \param addrlen: Length of addr
* *
* This converts a textual network interface name to a sockaddr usable by * This converts a textual network interface name to a sockaddr usable by
* other network functions * other network functions
skipping to change at line 3646 skipping to change at line 3909
* \param buf: buffer to fill * \param buf: buffer to fill
* \param len: how much to fill * \param len: how much to fill
* *
* This is intended to be called from the LWS_CALLBACK_RECEIVE callback if * This is intended to be called from the LWS_CALLBACK_RECEIVE callback if
* it's interested to see if the frame it's dealing with was sent in binary * it's interested to see if the frame it's dealing with was sent in binary
* mode. * mode.
*/ */
LWS_VISIBLE LWS_EXTERN int LWS_VISIBLE LWS_EXTERN int
lws_get_random(struct lws_context *context, void *buf, int len); lws_get_random(struct lws_context *context, void *buf, int len);
/** /**
* lws_daemonize(): fill a buffer with platform random data * lws_daemonize(): make current process run in the background
* *
* \param _lock_path: the filepath to write the lock file * \param _lock_path: the filepath to write the lock file
* *
* Spawn lws as a background process, taking care of various things * Spawn lws as a background process, taking care of various things
*/ */
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_daemonize(const char *_lock_path); lws_daemonize(const char *_lock_path);
/** /**
* lws_get_library_version(): return string describing the version of lws * lws_get_library_version(): return string describing the version of lws
* *
skipping to change at line 3672 skipping to change at line 3935
/** /**
* lws_wsi_user() - get the user data associated with the connection * lws_wsi_user() - get the user data associated with the connection
* \param wsi: lws connection * \param wsi: lws connection
* *
* Not normally needed since it's passed into the callback * Not normally needed since it's passed into the callback
*/ */
LWS_VISIBLE LWS_EXTERN void * LWS_VISIBLE LWS_EXTERN void *
lws_wsi_user(struct lws *wsi); lws_wsi_user(struct lws *wsi);
/** /**
* lws_wsi_set_user() - set the user data associated with the client connec
tion
* \param wsi: lws connection
* \param user: user data
*
* By default lws allocates this and it's not legal to externally set it
* yourself. However client connections may have it set externally when th
e
* connection is created... if so, this api can be used to modify it at
* runtime additionally.
*/
LWS_VISIBLE LWS_EXTERN void
lws_set_wsi_user(struct lws *wsi, void *user);
/**
* lws_parse_uri: cut up prot:/ads:port/path into pieces * lws_parse_uri: cut up prot:/ads:port/path into pieces
* Notice it does so by dropping '\0' into input string * Notice it does so by dropping '\0' into input string
* and the leading / on the path is consequently lost * and the leading / on the path is consequently lost
* *
* \param p: incoming uri string.. will get written to * \param p: incoming uri string.. will get written to
* \param prot: result pointer for protocol part (https://) * \param prot: result pointer for protocol part (https://)
* \param ads: result pointer for address part * \param ads: result pointer for address part
* \param port: result pointer for port part * \param port: result pointer for port part
* \param path: result pointer for path part * \param path: result pointer for path part
*/ */
skipping to change at line 3830 skipping to change at line 4106
* checked (appears for client wsi told to skip check on connection) * checked (appears for client wsi told to skip check on connection)
*/ */
LWS_VISIBLE LWS_EXTERN int LWS_VISIBLE LWS_EXTERN int
lws_is_ssl(struct lws *wsi); lws_is_ssl(struct lws *wsi);
/** /**
* lws_is_cgi() - find out if this wsi is running a cgi process * lws_is_cgi() - find out if this wsi is running a cgi process
* \param wsi: lws connection * \param wsi: lws connection
*/ */
LWS_VISIBLE LWS_EXTERN int LWS_VISIBLE LWS_EXTERN int
lws_is_cgi(struct lws *wsi); lws_is_cgi(struct lws *wsi);
#ifdef LWS_OPENSSL_SUPPORT
/**
* lws_get_ssl() - Return wsi's SSL context structure
* \param wsi: websocket connection
*
* Returns pointer to the SSL library's context structure
*/
LWS_VISIBLE LWS_EXTERN SSL*
lws_get_ssl(struct lws *wsi);
#endif
///@} ///@}
/** \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
skipping to change at line 3966 skipping to change at line 4253
* The advantage from all this is user code can be portable for file operat ions * The advantage from all this is user code can be portable for file operat ions
* without having to deal with differences between platforms. * without having to deal with differences between platforms.
*/ */
//@{ //@{
/** struct lws_plat_file_ops - Platform-specific file operations /** struct lws_plat_file_ops - Platform-specific file operations
* *
* These provide platform-agnostic ways to deal with filesystem access in t he * These provide platform-agnostic ways to deal with filesystem access in t he
* library and in the user code. * library and in the user code.
*/ */
#if defined(LWS_WITH_ESP32)
/* sdk preprocessor defs? compiler issue? gets confused with member names *
/
#define LWS_FOP_OPEN _open
#define LWS_FOP_CLOSE _close
#define LWS_FOP_SEEK_CUR _seek_cur
#define LWS_FOP_READ _read
#define LWS_FOP_WRITE _write
#else
#define LWS_FOP_OPEN open
#define LWS_FOP_CLOSE close
#define LWS_FOP_SEEK_CUR seek_cur
#define LWS_FOP_READ read
#define LWS_FOP_WRITE write
#endif
#define LWS_FOP_FLAGS_MASK ((1 << 23) - 1)
#define LWS_FOP_FLAG_COMPR_ACCEPTABLE_GZIP (1 << 24)
#define LWS_FOP_FLAG_COMPR_IS_GZIP (1 << 25)
#define LWS_FOP_FLAG_MOD_TIME_VALID (1 << 26)
#define LWS_FOP_FLAG_VIRTUAL (1 << 27)
struct lws_plat_file_ops;
#if defined(WIN32) || defined(_WIN32)
/* ... */
#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 {
lws_filefd_type fd;
/**< real file descriptor related to the file... */
const struct lws_plat_file_ops *fops;
/**< fops that apply to this fop_fd */
void *filesystem_priv;
/**< ignored by lws; owned by the fops handlers */
lws_filepos_t pos;
/**< generic "position in file" */
lws_filepos_t len;
/**< generic "length of file" */
lws_fop_flags_t flags;
/**< copy of the returned flags */
uint32_t mod_time;
/**< optional "modification time of file", only valid if .open()
* set the LWS_FOP_FLAG_MOD_TIME_VALID flag */
};
typedef struct lws_fop_fd *lws_fop_fd_t;
struct lws_fops_index {
const char *sig; /* NULL or vfs signature, eg, ".zip/" */
uint8_t len; /* length of above string */
};
struct lws_plat_file_ops { struct lws_plat_file_ops {
lws_filefd_type (*open)(struct lws *wsi, const char *filename, lws_fop_fd_t (*LWS_FOP_OPEN)(const struct lws_plat_file_ops *fops,
unsigned long *filelen, int flags); const char *filename, const char *vpath
,
lws_fop_flags_t *flags);
/**< Open file (always binary access if plat supports it) /**< Open file (always binary access if plat supports it)
* filelen is filled on exit to be the length of the file * vpath may be NULL, or if the fops understands it, the point at wh
* flags should be set to O_RDONLY or O_RDWR */ ich
int (*close)(struct lws *wsi, lws_filefd_type fd); * the filename's virtual part starts.
/**< close file */ * *flags & LWS_FOP_FLAGS_MASK should be set to O_RDONLY or O_RDWR.
unsigned long (*seek_cur)(struct lws *wsi, lws_filefd_type fd, * If the file may be gzip-compressed,
long offset_from_cur_pos); * LWS_FOP_FLAG_COMPR_ACCEPTABLE_GZIP is set. If it actually is
* gzip-compressed, then the open handler should OR
* LWS_FOP_FLAG_COMPR_IS_GZIP on to *flags before returning.
*/
int (*LWS_FOP_CLOSE)(lws_fop_fd_t *fop_fd);
/**< close file AND set the pointer to NULL */
lws_fileofs_t (*LWS_FOP_SEEK_CUR)(lws_fop_fd_t fop_fd,
lws_fileofs_t offset_from_cur_pos)
;
/**< seek from current position */ /**< seek from current position */
int (*read)(struct lws *wsi, lws_filefd_type fd, unsigned long *amou int (*LWS_FOP_READ)(lws_fop_fd_t fop_fd, lws_filepos_t *amount,
nt, uint8_t *buf, lws_filepos_t len);
unsigned char *buf, unsigned long len);
/**< Read from file, on exit *amount is set to amount actually read */ /**< Read from file, on exit *amount is set to amount actually read */
int (*write)(struct lws *wsi, lws_filefd_type fd, unsigned long *amo int (*LWS_FOP_WRITE)(lws_fop_fd_t fop_fd, lws_filepos_t *amount,
unt, uint8_t *buf, lws_filepos_t len);
unsigned char *buf, unsigned long len);
/**< Write to file, on exit *amount is set to amount actually writte n */ /**< Write to file, on exit *amount is set to amount actually writte n */
struct lws_fops_index fi[3];
/**< vfs path signatures implying use of this fops */
const struct lws_plat_file_ops *next;
/**< NULL or next fops in list */
/* 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 */
}; };
/** /**
* lws_get_fops() - get current file ops * lws_get_fops() - get current file ops
* *
* \param context: context * \param context: context
*/ */
LWS_VISIBLE LWS_EXTERN struct lws_plat_file_ops * LWS_WARN_UNUSED_RESULT LWS_VISIBLE LWS_EXTERN struct lws_plat_file_ops * LWS_WARN_UNUSED_RESULT
lws_get_fops(struct lws_context *context); lws_get_fops(struct lws_context *context);
LWS_VISIBLE LWS_EXTERN void
lws_set_fops(struct lws_context *context, const struct lws_plat_file_ops *f
ops);
/**
* lws_vfs_tell() - get current file position
*
* \param fop_fd: fop_fd we are asking about
*/
LWS_VISIBLE LWS_EXTERN lws_filepos_t LWS_WARN_UNUSED_RESULT
lws_vfs_tell(lws_fop_fd_t fop_fd);
/**
* lws_vfs_get_length() - get current file total length in bytes
*
* \param fop_fd: fop_fd we are asking about
*/
LWS_VISIBLE LWS_EXTERN lws_filepos_t LWS_WARN_UNUSED_RESULT
lws_vfs_get_length(lws_fop_fd_t fop_fd);
/**
* lws_vfs_get_mod_time() - get time file last modified
*
* \param fop_fd: fop_fd we are asking about
*/
LWS_VISIBLE LWS_EXTERN uint32_t LWS_WARN_UNUSED_RESULT
lws_vfs_get_mod_time(lws_fop_fd_t fop_fd);
/**
* lws_vfs_file_seek_set() - seek relative to start of file
*
* \param fop_fd: fop_fd we are seeking in
* \param offset: offset from start of file
*/
LWS_VISIBLE LWS_EXTERN lws_fileofs_t
lws_vfs_file_seek_set(lws_fop_fd_t fop_fd, lws_fileofs_t offset);
/**
* lws_vfs_file_seek_end() - seek relative to end of file
*
* \param fop_fd: fop_fd we are seeking in
* \param offset: offset from start of file
*/
LWS_VISIBLE LWS_EXTERN lws_fileofs_t
lws_vfs_file_seek_end(lws_fop_fd_t fop_fd, lws_fileofs_t offset);
LWS_VISIBLE LWS_EXTERN struct lws_plat_file_ops fops_zip;
/** /**
* lws_plat_file_open() - file open operations * lws_plat_file_open() - open vfs filepath
* *
* \param wsi: connection doing the opening * \param fops: file ops struct that applies to this descriptor
* \param filename: filename to open * \param vfs_path: filename to open
* \param filelen: length of file (filled in by call) * \param flags: pointer to open flags
* \param flags: open flags *
* The vfs_path is scanned for known fops signatures, and the open directed
* to any matching fops open.
*
* User code should use this api to perform vfs opens.
*
* returns semi-opaque handle
*/ */
static LWS_INLINE lws_filefd_type LWS_WARN_UNUSED_RESULT LWS_VISIBLE LWS_EXTERN lws_fop_fd_t LWS_WARN_UNUSED_RESULT
lws_plat_file_open(struct lws *wsi, const char *filename, lws_vfs_file_open(const struct lws_plat_file_ops *fops, const char *vfs_pat
unsigned long *filelen, int flags) h,
{ lws_fop_flags_t *flags);
return lws_get_fops(lws_get_context(wsi))->open(wsi, filename,
filelen, flags);
}
/** /**
* lws_plat_file_close() - close file * lws_plat_file_close() - close file
* *
* \param wsi: connection opened by * \param fop_fd: file handle to close
* \param fd: file descriptor
*/ */
static LWS_INLINE int static LWS_INLINE int
lws_plat_file_close(struct lws *wsi, lws_filefd_type fd) lws_vfs_file_close(lws_fop_fd_t *fop_fd)
{ {
return lws_get_fops(lws_get_context(wsi))->close(wsi, fd); return (*fop_fd)->fops->LWS_FOP_CLOSE(fop_fd);
} }
/** /**
* lws_plat_file_seek_cur() - close file * lws_plat_file_seek_cur() - close file
* *
* \param wsi: connection opened by *
* \param fd: file descriptor * \param fop_fd: file handle
* \param offset: position to seek to * \param offset: position to seek to
*/ */
static LWS_INLINE unsigned long static LWS_INLINE lws_fileofs_t
lws_plat_file_seek_cur(struct lws *wsi, lws_filefd_type fd, long offset) lws_vfs_file_seek_cur(lws_fop_fd_t fop_fd, lws_fileofs_t offset)
{ {
return lws_get_fops(lws_get_context(wsi))->seek_cur(wsi, fd, offset) ; return fop_fd->fops->LWS_FOP_SEEK_CUR(fop_fd, offset);
} }
/** /**
* lws_plat_file_read() - read from file * lws_plat_file_read() - read from file
* *
* \param wsi: connection opened by * \param fop_fd: file handle
* \param fd: file descriptor
* \param amount: how much to read (rewritten by call) * \param amount: how much to read (rewritten by call)
* \param buf: buffer to write to * \param buf: buffer to write to
* \param len: max length * \param len: max length
*/ */
static LWS_INLINE int LWS_WARN_UNUSED_RESULT static LWS_INLINE int LWS_WARN_UNUSED_RESULT
lws_plat_file_read(struct lws *wsi, lws_filefd_type fd, unsigned long *amou lws_vfs_file_read(lws_fop_fd_t fop_fd, lws_filepos_t *amount,
nt, uint8_t *buf, lws_filepos_t len)
unsigned char *buf, unsigned long len)
{ {
return lws_get_fops(lws_get_context(wsi))->read(wsi, fd, amount, buf return fop_fd->fops->LWS_FOP_READ(fop_fd, amount, buf, len);
,
len);
} }
/** /**
* lws_plat_file_write() - write from file * lws_plat_file_write() - write from file
* *
* \param wsi: connection opened by * \param fop_fd: file handle
* \param fd: file descriptor
* \param amount: how much to write (rewritten by call) * \param amount: how much to write (rewritten by call)
* \param buf: buffer to read from * \param buf: buffer to read from
* \param len: max length * \param len: max length
*/ */
static LWS_INLINE int LWS_WARN_UNUSED_RESULT static LWS_INLINE int LWS_WARN_UNUSED_RESULT
lws_plat_file_write(struct lws *wsi, lws_filefd_type fd, unsigned long *amo lws_vfs_file_write(lws_fop_fd_t fop_fd, lws_filepos_t *amount,
unt, uint8_t *buf, lws_filepos_t len)
unsigned char *buf, unsigned long len)
{ {
return lws_get_fops(lws_get_context(wsi))->write(wsi, fd, amount, bu return fop_fd->fops->LWS_FOP_WRITE(fop_fd, amount, buf, len);
f,
len);
} }
/* these are the platform file operations implementations... they can
* be called directly and used in fops arrays
*/
LWS_VISIBLE LWS_EXTERN lws_fop_fd_t
_lws_plat_file_open(const struct lws_plat_file_ops *fops, const char *filen
ame,
const char *vpath, lws_fop_flags_t *flags);
LWS_VISIBLE LWS_EXTERN int
_lws_plat_file_close(lws_fop_fd_t *fop_fd);
LWS_VISIBLE LWS_EXTERN lws_fileofs_t
_lws_plat_file_seek_cur(lws_fop_fd_t fop_fd, lws_fileofs_t offset);
LWS_VISIBLE LWS_EXTERN int
_lws_plat_file_read(lws_fop_fd_t fop_fd, lws_filepos_t *amount,
uint8_t *buf, lws_filepos_t len);
LWS_VISIBLE LWS_EXTERN int
_lws_plat_file_write(lws_fop_fd_t fop_fd, lws_filepos_t *amount,
uint8_t *buf, lws_filepos_t len);
//@} //@}
/** \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
 End of changes. 76 change blocks. 
199 lines changed or deleted 665 lines changed or added


 lws_config.h (2.1.1)   lws_config.h (2.2.0) 
/* lws_config.h Generated from lws_config.h.in */ /* lws_config.h Generated from lws_config.h.in */
#ifndef NDEBUG #ifndef NDEBUG
#ifndef _DEBUG #ifndef _DEBUG
#define _DEBUG #define _DEBUG
#endif #endif
#endif #endif
#define LWS_INSTALL_DATADIR "/home/agreen/installed/libwebsockets/2.1.1/sha re" #define LWS_INSTALL_DATADIR "/home/agreen/installed/libwebsockets/2.2.0/sha re"
/* Define to 1 to use wolfSSL/CyaSSL as a replacement for OpenSSL. /* Define to 1 to use wolfSSL/CyaSSL as a replacement for OpenSSL.
* LWS_OPENSSL_SUPPORT needs to be set also for this to work. */ * LWS_OPENSSL_SUPPORT needs to be set also for this to work. */
/* #undef USE_WOLFSSL */ /* #undef USE_WOLFSSL */
/* Also define to 1 (in addition to USE_WOLFSSL) when using the /* Also define to 1 (in addition to USE_WOLFSSL) when using the
(older) CyaSSL library */ (older) CyaSSL library */
/* #undef USE_OLD_CYASSL */ /* #undef USE_OLD_CYASSL */
/* #undef LWS_USE_BORINGSSL */
/* #undef LWS_USE_MBEDTLS */ /* #undef LWS_USE_MBEDTLS */
/* #undef LWS_USE_POLARSSL */ /* #undef LWS_USE_POLARSSL */
/* #undef LWS_WITH_ESP8266 */ /* #undef LWS_WITH_ESP8266 */
/* #undef LWS_WITH_ESP32 */
/* #undef LWS_WITH_PLUGINS */ /* #undef LWS_WITH_PLUGINS */
/* #undef LWS_WITH_NO_LOGS */ /* #undef LWS_WITH_NO_LOGS */
/* The Libwebsocket version */ /* The Libwebsocket version */
#define LWS_LIBRARY_VERSION "2.1.1" #define LWS_LIBRARY_VERSION "2.2.0"
#define LWS_LIBRARY_VERSION_MAJOR 2 #define LWS_LIBRARY_VERSION_MAJOR 2
#define LWS_LIBRARY_VERSION_MINOR 1 #define LWS_LIBRARY_VERSION_MINOR 2
#define LWS_LIBRARY_VERSION_PATCH 1 #define LWS_LIBRARY_VERSION_PATCH 0
/* LWS_LIBRARY_VERSION_NUMBER looks like 1005001 for e.g. version 1.5.1 */ /* LWS_LIBRARY_VERSION_NUMBER looks like 1005001 for e.g. version 1.5.1 */
#define LWS_LIBRARY_VERSION_NUMBER (LWS_LIBRARY_VERSION_MAJOR*1000000)+(LWS _LIBRARY_VERSION_MINOR*1000)+LWS_LIBRARY_VERSION_PATCH #define LWS_LIBRARY_VERSION_NUMBER (LWS_LIBRARY_VERSION_MAJOR*1000000)+(LWS _LIBRARY_VERSION_MINOR*1000)+LWS_LIBRARY_VERSION_PATCH
/* The current git commit hash that we're building from */ /* The current git commit hash that we're building from */
#define LWS_BUILD_HASH "root@mail.warmcat.com-" #define LWS_BUILD_HASH "root@mail.warmcat.com-"
/* Build with OpenSSL support */ /* Build with OpenSSL support */
#define LWS_OPENSSL_SUPPORT #define LWS_OPENSSL_SUPPORT
/* The client should load and trust CA root certs it finds in the OS */ /* The client should load and trust CA root certs it finds in the OS */
skipping to change at line 102 skipping to change at line 104
/* CGI apis */ /* CGI apis */
/* #undef LWS_WITH_CGI */ /* #undef LWS_WITH_CGI */
/* whether the Openssl is recent enough, and / or built with, ecdh */ /* whether the Openssl is recent enough, and / or built with, ecdh */
#define LWS_HAVE_OPENSSL_ECDH_H #define LWS_HAVE_OPENSSL_ECDH_H
/* HTTP Proxy support */ /* HTTP Proxy support */
/* #undef LWS_WITH_HTTP_PROXY */ /* #undef LWS_WITH_HTTP_PROXY */
/* HTTP Ranges support */
#define LWS_WITH_RANGES
/* Http access log support */ /* Http access log support */
/* #undef LWS_WITH_ACCESS_LOG */ /* #undef LWS_WITH_ACCESS_LOG */
/* #undef LWS_WITH_SERVER_STATUS */ /* #undef LWS_WITH_SERVER_STATUS */
/* #undef LWS_WITH_STATEFUL_URLDECODE */ /* #undef LWS_WITH_STATEFUL_URLDECODE */
/* Maximum supported service threads */ /* Maximum supported service threads */
#define LWS_MAX_SMP 32 #define LWS_MAX_SMP 32
/* Lightweight JSON Parser */ /* Lightweight JSON Parser */
/* #undef LWS_WITH_LEJP */ /* #undef LWS_WITH_LEJP */
/* SMTP */ /* SMTP */
/* #undef LWS_WITH_SMTP */ /* #undef LWS_WITH_SMTP */
/* OPTEE */
/* #undef LWS_PLAT_OPTEE */
/* ZIP FOPS */
#define LWS_WITH_ZIP_FOPS
#define LWS_HAVE_STDINT_H
/* #undef LWS_FALLBACK_GETHOSTBYNAME */
 End of changes. 7 change blocks. 
4 lines changed or deleted 9 lines changed or added

This html diff was produced by rfcdiff 1.41.The latest version is available from http://tools.ietf.org/tools/rfcdiff/