27#ifndef LIBWEBSOCKET_H_3060898B846849FF9F88F5DB59B5950C
28#define LIBWEBSOCKET_H_3060898B846849FF9F88F5DB59B5950C
42#include "lws_config.h"
53#define LWS_US_PER_SEC ((lws_usec_t)1000000)
54#define LWS_MS_PER_SEC ((lws_usec_t)1000)
55#define LWS_US_PER_MS ((lws_usec_t)1000)
56#define LWS_NS_PER_US ((lws_usec_t)1000)
59#define LWS_MI (LWS_KI * 1024)
60#define LWS_GI (LWS_MI * 1024)
61#define LWS_TI ((uint64_t)LWS_GI * 1024)
62#define LWS_PI ((uint64_t)LWS_TI * 1024)
64#define LWS_US_TO_MS(x) ((x + (LWS_US_PER_MS / 2)) / LWS_US_PER_MS)
66#if defined(LWS_HAS_INTPTR_T)
68#define lws_intptr_t intptr_t
70typedef unsigned long long lws_intptr_t;
73#if defined(WIN32) || defined(_WIN32)
74#ifndef WIN32_LEAN_AND_MEAN
75#define WIN32_LEAN_AND_MEAN
86#define _O_RDONLY 0x0000
87#define O_RDONLY _O_RDONLY
90#define LWS_INLINE __inline
92#define LWS_WARN_UNUSED_RESULT
93#define LWS_WARN_DEPRECATED
94#define LWS_FORMAT(string_index)
96#if !defined(LWS_EXTERN)
99#define LWS_EXTERN extern __declspec(dllexport)
101#define LWS_EXTERN extern __declspec(dllimport)
106#define LWS_INVALID_FILE INVALID_HANDLE_VALUE
107#define LWS_SOCK_INVALID (INVALID_SOCKET)
108#define LWS_O_RDONLY _O_RDONLY
109#define LWS_O_WRONLY _O_WRONLY
110#define LWS_O_CREAT _O_CREAT
111#define LWS_O_TRUNC _O_TRUNC
114#define __func__ __FUNCTION__
119#if defined(LWS_HAVE_SYS_CAPABILITY_H) && defined(LWS_HAVE_LIBCAP)
120#include <sys/capability.h>
123#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__QNX__) || defined(__OpenBSD__)
124#include <sys/socket.h>
125#include <netinet/in.h>
128#define LWS_INLINE inline
129#define LWS_O_RDONLY O_RDONLY
130#define LWS_O_WRONLY O_WRONLY
131#define LWS_O_CREAT O_CREAT
132#define LWS_O_TRUNC O_TRUNC
134#if !defined(LWS_PLAT_OPTEE) && !defined(OPTEE_TA) && !defined(LWS_PLAT_FREERTOS)
137#define LWS_INVALID_FILE -1
138#define LWS_SOCK_INVALID (-1)
140#define getdtablesize() (30)
141#if defined(LWS_PLAT_FREERTOS)
142#define LWS_INVALID_FILE NULL
143#define LWS_SOCK_INVALID (-1)
145#define LWS_INVALID_FILE NULL
146#define LWS_SOCK_INVALID (-1)
153#if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
154#define LWS_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
156#define LWS_WARN_UNUSED_RESULT
159#define LWS_VISIBLE __attribute__((visibility("default")))
160#define LWS_WARN_DEPRECATED __attribute__ ((deprecated))
161#define LWS_FORMAT(string_index) __attribute__ ((format(printf, string_index, string_index+1)))
164#define LWS_WARN_UNUSED_RESULT
165#define LWS_WARN_DEPRECATED
166#define LWS_FORMAT(string_index)
169#if defined(__ANDROID__)
170#include <netinet/in.h>
176#if defined(LWS_WITH_LIBEV)
181#ifdef LWS_HAVE_UV_VERSION_H
182#include <uv-version.h>
184#ifdef LWS_HAVE_NEW_UV_VERSION_H
185#include <uv/version.h>
188#if defined(LWS_WITH_LIBEVENT)
189#include <event2/event.h>
193#define LWS_EXTERN extern
199#if !defined(LWS_PLAT_OPTEE)
205#if defined(LWS_WITH_TLS)
214#include <IDE/WIN/user_settings.h>
215#include <cyassl/ctaocrypt/settings.h>
217#include <cyassl/options.h>
219#include <cyassl/openssl/ssl.h>
220#include <cyassl/error-ssl.h>
228#include <IDE/WIN/user_settings.h>
229#include <wolfssl/wolfcrypt/settings.h>
231#include <wolfssl/options.h>
233#include <wolfssl/openssl/ssl.h>
234#include <wolfssl/error-ssl.h>
237#if defined(LWS_WITH_MBEDTLS)
238#if defined(LWS_PLAT_FREERTOS)
240#if !defined(LWS_AMAZON_RTOS)
242#undef MBEDTLS_CONFIG_FILE
243#define MBEDTLS_CONFIG_FILE <mbedtls/esp_config.h>
246#include <mbedtls/ssl.h>
247#include <mbedtls/entropy.h>
248#include <mbedtls/ctr_drbg.h>
250#include <openssl/ssl.h>
251#if !defined(LWS_WITH_MBEDTLS)
252#include <openssl/err.h>
269#define lws_pthread_mutex(name) pthread_mutex_t name;
271static LWS_INLINE
void
272lws_pthread_mutex_init(pthread_mutex_t *lock)
274 pthread_mutex_init(lock, NULL);
277static LWS_INLINE
void
278lws_pthread_mutex_destroy(pthread_mutex_t *lock)
280 pthread_mutex_destroy(lock);
283static LWS_INLINE
void
284lws_pthread_mutex_lock(pthread_mutex_t *lock)
286 pthread_mutex_lock(lock);
289static LWS_INLINE
void
290lws_pthread_mutex_unlock(pthread_mutex_t *lock)
292 pthread_mutex_unlock(lock);
296#define lws_pthread_mutex(name)
297#define lws_pthread_mutex_init(_a)
298#define lws_pthread_mutex_destroy(_a)
299#define lws_pthread_mutex_lock(_a)
300#define lws_pthread_mutex_unlock(_a)
304#define CONTEXT_PORT_NO_LISTEN -1
305#define CONTEXT_PORT_NO_LISTEN_SERVER -2
307#include <libwebsockets/lws-logs.h>
312#ifndef lws_container_of
313#define lws_container_of(P,T,M) ((T *)((char *)(P) - offsetof(T, M)))
315#define LWS_ALIGN_TO(x, bou) x += ((bou) - ((x) % (bou))) % (bou)
321#define LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_ARG
324#define LWS_FEATURE_PROTOCOLS_HAS_ID_FIELD
327#define LWS_FEATURE_PROTOCOLS_HAS_PEER_WRITE_ALLOWANCE
330#define LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_LEN
333#define LWS_FEATURE_FOPS
337#if !defined(LWS_WIN32_HANDLE_TYPES)
338typedef SOCKET lws_sockfd_type;
339typedef HANDLE lws_filefd_type;
347#define LWS_POLLHUP (FD_CLOSE)
348#define LWS_POLLIN (FD_READ | FD_ACCEPT)
349#define LWS_POLLOUT (FD_WRITE)
358#if defined(LWS_PLAT_FREERTOS)
359#include <libwebsockets/lws-freertos.h>
360#if defined(LWS_WITH_ESP32)
361#include <libwebsockets/lws-esp32.h>
364typedef int lws_sockfd_type;
365typedef int lws_filefd_type;
368#if defined(LWS_PLAT_OPTEE)
372 unsigned int tv_usec;
374#if defined(LWS_WITH_NETWORK)
376#define lws_pollfd pollfd
380int gettimeofday(
struct timeval *tv,
struct timezone *tz);
387typedef unsigned short sa_family_t;
388typedef unsigned short in_port_t;
389typedef uint32_t socklen_t;
391#include <libwebsockets/lws-optee.h>
393#if !defined(TEE_SE_READER_NAME_MAX)
399 socklen_t ai_addrlen;
400 struct sockaddr *ai_addr;
402 struct addrinfo *ai_next;
406ssize_t recv(
int sockfd,
void *buf,
size_t len,
int flags);
407ssize_t send(
int sockfd,
const void *buf,
size_t len,
int flags);
408ssize_t read(
int fd,
void *buf,
size_t count);
409int getsockopt(
int sockfd,
int level,
int optname,
410 void *optval, socklen_t *optlen);
411 int setsockopt(
int sockfd,
int level,
int optname,
412 const void *optval, socklen_t optlen);
413int connect(
int sockfd,
const struct sockaddr *addr,
418uint16_t ntohs(uint16_t netshort);
419uint16_t htons(uint16_t hostshort);
421int bind(
int sockfd,
const struct sockaddr *addr,
425#define MSG_NOSIGNAL 0x4000
428#define EWOULDBLOCK EAGAIN
437# define AI_PASSIVE 0x0001
438#define IPPROTO_UDP 17
443#define EINPROGRESS 115
444int shutdown(
int sockfd,
int how);
446int atoi(
const char *nptr);
447long long atoll(
const char *nptr);
449int socket(
int domain,
int type,
int protocol);
450 int getaddrinfo(
const char *node,
const char *service,
451 const struct addrinfo *hints,
452 struct addrinfo **res);
454 void freeaddrinfo(
struct addrinfo *res);
456#if !defined(TEE_SE_READER_NAME_MAX)
465int poll(
struct pollfd *fds,
int nfds,
int timeout);
467#define LWS_POLLHUP (0x18)
468#define LWS_POLLIN (1)
469#define LWS_POLLOUT (4)
475#define lws_pollfd pollfd
476#define LWS_POLLHUP (POLLHUP | POLLERR)
477#define LWS_POLLIN (POLLIN)
478#define LWS_POLLOUT (POLLOUT)
483#if (defined(WIN32) || defined(_WIN32)) && !defined(__MINGW32__)
485#define ssize_t SSIZE_T
488#if defined(WIN32) && defined(LWS_HAVE__STAT32I64)
489#include <sys/types.h>
493#if defined(LWS_HAVE_STDINT_H)
496#if defined(WIN32) || defined(_WIN32)
498typedef __int64 int64_t;
499typedef unsigned __int64 uint64_t;
500typedef __int32 int32_t;
501typedef unsigned __int32 uint32_t;
502typedef __int16 int16_t;
503typedef unsigned __int16 uint16_t;
504typedef unsigned __int8 uint8_t;
506typedef unsigned int uint32_t;
507typedef unsigned short uint16_t;
508typedef unsigned char uint8_t;
512typedef int64_t lws_usec_t;
513typedef unsigned long long lws_filepos_t;
514typedef long long lws_fileofs_t;
515typedef uint32_t lws_fop_flags_t;
517#define lws_concat_temp(_t, _l) (_t + sizeof(_t) - _l)
518#define lws_concat_used(_t, _l) (sizeof(_t) - _l)
529struct lws_token_limits;
536#include <libwebsockets/lws-dll2.h>
537#include <libwebsockets/lws-timeout-timer.h>
538#include <libwebsockets/lws-state.h>
539#include <libwebsockets/lws-retry.h>
540#include <libwebsockets/lws-adopt.h>
541#include <libwebsockets/lws-network-helper.h>
542#include <libwebsockets/lws-system.h>
543#include <libwebsockets/lws-detailed-latency.h>
544#include <libwebsockets/lws-ws-close.h>
545#include <libwebsockets/lws-callbacks.h>
546#include <libwebsockets/lws-ws-state.h>
547#include <libwebsockets/lws-ws-ext.h>
548#include <libwebsockets/lws-protocols-plugins.h>
549#include <libwebsockets/lws-plugin-generic-sessions.h>
550#include <libwebsockets/lws-context-vhost.h>
551#if defined(LWS_ROLE_MQTT)
552#include <libwebsockets/lws-mqtt.h>
554#include <libwebsockets/lws-client.h>
555#include <libwebsockets/lws-http.h>
556#include <libwebsockets/lws-spa.h>
557#include <libwebsockets/lws-purify.h>
558#include <libwebsockets/lws-misc.h>
559#include <libwebsockets/lws-dsh.h>
560#include <libwebsockets/lws-service.h>
561#include <libwebsockets/lws-write.h>
562#include <libwebsockets/lws-writeable.h>
563#include <libwebsockets/lws-ring.h>
564#include <libwebsockets/lws-sha1-base64.h>
565#include <libwebsockets/lws-x509.h>
566#include <libwebsockets/lws-cgi.h>
567#if defined(LWS_WITH_FILE_OPS)
568#include <libwebsockets/lws-vfs.h>
570#include <libwebsockets/lws-lejp.h>
571#include <libwebsockets/lws-stats.h>
572#include <libwebsockets/lws-struct.h>
573#include <libwebsockets/lws-threadpool.h>
574#include <libwebsockets/lws-tokenize.h>
575#include <libwebsockets/lws-lwsac.h>
576#include <libwebsockets/lws-fts.h>
577#include <libwebsockets/lws-diskcache.h>
578#include <libwebsockets/lws-sequencer.h>
579#include <libwebsockets/lws-secure-streams.h>
580#include <libwebsockets/lws-secure-streams-policy.h>
581#include <libwebsockets/lws-secure-streams-client.h>
583#if !defined(LWS_PLAT_FREERTOS)
584#include <libwebsockets/abstract/abstract.h>
586#include <libwebsockets/lws-test-sequencer.h>
588#include <libwebsockets/lws-async-dns.h>
590#if defined(LWS_WITH_TLS)
592#if defined(LWS_WITH_MBEDTLS)
593#include <mbedtls/md5.h>
594#include <mbedtls/sha1.h>
595#include <mbedtls/sha256.h>
596#include <mbedtls/sha512.h>
599#include <libwebsockets/lws-gencrypto.h>
600#include <libwebsockets/lws-genhash.h>
601#include <libwebsockets/lws-genrsa.h>
602#include <libwebsockets/lws-genaes.h>
603#include <libwebsockets/lws-genec.h>
605#include <libwebsockets/lws-jwk.h>
606#include <libwebsockets/lws-jose.h>
607#include <libwebsockets/lws-jws.h>
608#include <libwebsockets/lws-jwe.h>
Definition: libwebsockets.h:522
int events
Definition: libwebsockets.h:524
int prev_events
Definition: libwebsockets.h:525
lws_sockfd_type fd
Definition: libwebsockets.h:523