27 #ifndef LIBWEBSOCKET_H_3060898B846849FF9F88F5DB59B5950C
28 #define LIBWEBSOCKET_H_3060898B846849FF9F88F5DB59B5950C
42 #include "lws_config.h"
44 #if defined(LWS_SUPPRESS_DEPRECATED_API_WARNINGS)
45 #define OPENSSL_USE_DEPRECATED
50 typedef struct lws_context * lws_ctx_t;
58 #define LWS_US_PER_SEC ((lws_usec_t)1000000)
59 #define LWS_MS_PER_SEC ((lws_usec_t)1000)
60 #define LWS_US_PER_MS ((lws_usec_t)1000)
61 #define LWS_NS_PER_US ((lws_usec_t)1000)
64 #define LWS_MI (LWS_KI * 1024)
65 #define LWS_GI (LWS_MI * 1024)
66 #define LWS_TI ((uint64_t)LWS_GI * 1024)
67 #define LWS_PI ((uint64_t)LWS_TI * 1024)
69 #define LWS_US_TO_MS(x) ((x + (LWS_US_PER_MS / 2)) / LWS_US_PER_MS)
71 #if defined(LWS_HAS_INTPTR_T)
73 #define lws_intptr_t intptr_t
75 typedef unsigned long long lws_intptr_t;
78 #if defined(WIN32) || defined(_WIN32)
79 #ifndef WIN32_LEAN_AND_MEAN
80 #define WIN32_LEAN_AND_MEAN
91 #define _O_RDONLY 0x0000
92 #define O_RDONLY _O_RDONLY
97 typedef unsigned short sa_family_t;
98 #if !defined(LWS_HAVE_SUSECONDS_T)
99 typedef unsigned int useconds_t;
100 typedef int suseconds_t;
103 #define LWS_INLINE __inline
105 #define LWS_WARN_UNUSED_RESULT
106 #define LWS_WARN_DEPRECATED
107 #define LWS_FORMAT(string_index)
109 #if !defined(LWS_EXTERN) && defined(LWS_BUILDING_SHARED)
112 #define LWS_EXTERN extern __declspec(dllexport)
114 #define LWS_EXTERN extern __declspec(dllimport)
119 #if !defined(LWS_INTERNAL) && !defined(LWS_EXTERN)
124 #if !defined(LWS_EXTERN)
128 #define LWS_INVALID_FILE INVALID_HANDLE_VALUE
129 #define LWS_SOCK_INVALID (INVALID_SOCKET)
130 #define LWS_O_RDONLY _O_RDONLY
131 #define LWS_O_WRONLY _O_WRONLY
132 #define LWS_O_CREAT _O_CREAT
133 #define LWS_O_TRUNC _O_TRUNC
136 #define __func__ __FUNCTION__
141 #if defined(LWS_HAVE_SYS_CAPABILITY_H) && defined(LWS_HAVE_LIBCAP)
142 #include <sys/capability.h>
145 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__QNX__) || defined(__OpenBSD__)
146 #include <sys/socket.h>
147 #include <netinet/in.h>
150 #define LWS_INLINE inline
151 #define LWS_O_RDONLY O_RDONLY
152 #define LWS_O_WRONLY O_WRONLY
153 #define LWS_O_CREAT O_CREAT
154 #define LWS_O_TRUNC O_TRUNC
156 #if !defined(LWS_PLAT_OPTEE) && !defined(OPTEE_TA) && !defined(LWS_PLAT_FREERTOS)
159 #define LWS_INVALID_FILE -1
160 #define LWS_SOCK_INVALID (-1)
162 #define getdtablesize() (30)
163 #if defined(LWS_PLAT_FREERTOS)
164 #define LWS_INVALID_FILE NULL
165 #define LWS_SOCK_INVALID (-1)
167 #define LWS_INVALID_FILE NULL
168 #define LWS_SOCK_INVALID (-1)
172 #if defined(__FreeBSD__)
173 #include <sys/signal.h>
175 #if defined(__GNUC__)
178 #if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
179 #define LWS_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
181 #define LWS_WARN_UNUSED_RESULT
184 #if defined(LWS_BUILDING_SHARED)
186 #define LWS_VISIBLE __attribute__((visibility("default")))
187 #define LWS_EXTERN extern
190 #if defined(WIN32) || defined(_WIN32) || defined(__MINGW32__)
192 #define LWS_EXTERN extern
204 #define LWS_WARN_DEPRECATED __attribute__ ((deprecated))
205 #define LWS_FORMAT(string_index) __attribute__ ((format(printf, string_index, string_index+1)))
209 #define LWS_WARN_UNUSED_RESULT
210 #define LWS_WARN_DEPRECATED
211 #define LWS_FORMAT(string_index)
212 #if !defined(LWS_EXTERN)
213 #define LWS_EXTERN extern
218 #if defined(__ANDROID__)
219 #include <netinet/in.h>
227 #if !defined(LWS_PLAT_OPTEE)
228 #include <sys/time.h>
233 #if defined(LWS_WITH_LIBUV_INTERNAL)
236 #ifdef LWS_HAVE_UV_VERSION_H
237 #include <uv-version.h>
240 #ifdef LWS_HAVE_NEW_UV_VERSION_H
241 #include <uv/version.h>
245 #if defined(LWS_WITH_TLS)
248 #ifdef USE_OLD_CYASSL
254 #include <IDE/WIN/user_settings.h>
255 #include <cyassl/ctaocrypt/settings.h>
257 #include <cyassl/options.h>
259 #include <cyassl/openssl/ssl.h>
260 #include <cyassl/error-ssl.h>
268 #include <IDE/WIN/user_settings.h>
269 #include <wolfssl/wolfcrypt/settings.h>
271 #include <wolfssl/options.h>
273 #include <wolfssl/openssl/ssl.h>
274 #include <wolfssl/error-ssl.h>
277 #if defined(LWS_WITH_MBEDTLS)
278 #if defined(LWS_PLAT_FREERTOS)
280 #if !defined(LWS_AMAZON_RTOS)
282 #undef MBEDTLS_CONFIG_FILE
283 #define MBEDTLS_CONFIG_FILE <mbedtls/esp_config.h>
286 #if defined(LWS_WITH_TLS)
287 #include <mbedtls/ssl.h>
288 #include <mbedtls/entropy.h>
289 #include <mbedtls/ctr_drbg.h>
291 #if !defined(MBEDTLS_PRIVATE)
292 #define MBEDTLS_PRIVATE(_q) _q
297 #include <openssl/ssl.h>
298 #if !defined(LWS_WITH_MBEDTLS)
299 #include <openssl/err.h>
316 #define lws_pthread_mutex(name) pthread_mutex_t name;
318 static LWS_INLINE
void
319 lws_pthread_mutex_init(pthread_mutex_t *lock)
321 pthread_mutex_init(lock, NULL);
324 static LWS_INLINE
void
325 lws_pthread_mutex_destroy(pthread_mutex_t *lock)
327 pthread_mutex_destroy(lock);
330 static LWS_INLINE
void
331 lws_pthread_mutex_lock(pthread_mutex_t *lock)
333 pthread_mutex_lock(lock);
336 static LWS_INLINE
void
337 lws_pthread_mutex_unlock(pthread_mutex_t *lock)
339 pthread_mutex_unlock(lock);
343 #define lws_pthread_mutex(name)
344 #define lws_pthread_mutex_init(_a)
345 #define lws_pthread_mutex_destroy(_a)
346 #define lws_pthread_mutex_lock(_a)
347 #define lws_pthread_mutex_unlock(_a)
351 #define CONTEXT_PORT_NO_LISTEN -1
352 #define CONTEXT_PORT_NO_LISTEN_SERVER -2
354 #include <libwebsockets/lws-logs.h>
359 #ifndef lws_container_of
360 #define lws_container_of(P,T,M) ((T *)((char *)(P) - offsetof(T, M)))
362 #define LWS_ALIGN_TO(x, bou) x += ((bou) - ((x) % (bou))) % (bou)
368 #define LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_ARG
371 #define LWS_FEATURE_PROTOCOLS_HAS_ID_FIELD
374 #define LWS_FEATURE_PROTOCOLS_HAS_PEER_WRITE_ALLOWANCE
377 #define LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_LEN
380 #define LWS_FEATURE_FOPS
384 #if !defined(LWS_WIN32_HANDLE_TYPES)
385 typedef SOCKET lws_sockfd_type;
386 typedef HANDLE lws_filefd_type;
390 #define lws_pollfd pollfd
391 #define LWS_POLLHUP (POLLHUP)
392 #define LWS_POLLIN (POLLRDNORM | POLLRDBAND)
393 #define LWS_POLLOUT (POLLWRNORM)
398 #if defined(LWS_PLAT_FREERTOS)
399 #include <libwebsockets/lws-freertos.h>
401 typedef int lws_sockfd_type;
402 typedef int lws_filefd_type;
405 #if defined(LWS_PLAT_OPTEE)
409 unsigned int tv_usec;
411 #if defined(LWS_WITH_NETWORK)
413 #define lws_pollfd pollfd
417 int gettimeofday(
struct timeval *tv,
struct timezone *tz);
424 typedef unsigned short sa_family_t;
425 typedef unsigned short in_port_t;
426 typedef uint32_t socklen_t;
428 #include <libwebsockets/lws-optee.h>
430 #if !defined(TEE_SE_READER_NAME_MAX)
436 socklen_t ai_addrlen;
437 struct sockaddr *ai_addr;
439 struct addrinfo *ai_next;
443 ssize_t recv(
int sockfd,
void *buf,
size_t len,
int flags);
444 ssize_t send(
int sockfd,
const void *buf,
size_t len,
int flags);
445 ssize_t read(
int fd,
void *buf,
size_t count);
446 int getsockopt(
int sockfd,
int level,
int optname,
447 void *optval, socklen_t *optlen);
448 int setsockopt(
int sockfd,
int level,
int optname,
449 const void *optval, socklen_t optlen);
450 int connect(
int sockfd,
const struct sockaddr *addr,
455 uint16_t ntohs(uint16_t netshort);
456 uint16_t htons(uint16_t hostshort);
458 int bind(
int sockfd,
const struct sockaddr *addr,
462 #define MSG_NOSIGNAL 0x4000
465 #define EWOULDBLOCK EAGAIN
466 #define EADDRINUSE 98
472 #define SOCK_STREAM 1
474 # define AI_PASSIVE 0x0001
475 #define IPPROTO_UDP 17
480 #define EINPROGRESS 115
481 int shutdown(
int sockfd,
int how);
483 int atoi(
const char *nptr);
484 long long atoll(
const char *nptr);
486 int socket(
int domain,
int type,
int protocol);
487 int getaddrinfo(
const char *node,
const char *service,
488 const struct addrinfo *hints,
489 struct addrinfo **res);
491 void freeaddrinfo(
struct addrinfo *res);
493 #if !defined(TEE_SE_READER_NAME_MAX)
502 int poll(
struct pollfd *fds,
int nfds,
int timeout);
504 #define LWS_POLLHUP (0x18)
505 #define LWS_POLLIN (1)
506 #define LWS_POLLOUT (4)
512 #define lws_pollfd pollfd
513 #define LWS_POLLHUP (POLLHUP | POLLERR)
514 #define LWS_POLLIN (POLLIN)
515 #define LWS_POLLOUT (POLLOUT)
520 #if (defined(WIN32) || defined(_WIN32)) && !defined(__MINGW32__)
522 #define ssize_t SSIZE_T
525 #if defined(WIN32) && defined(LWS_HAVE__STAT32I64)
526 #include <sys/types.h>
527 #include <sys/stat.h>
530 #if defined(LWS_HAVE_STDINT_H)
533 #if defined(WIN32) || defined(_WIN32)
535 typedef __int64 int64_t;
536 typedef unsigned __int64 uint64_t;
537 typedef __int32 int32_t;
538 typedef unsigned __int32 uint32_t;
539 typedef __int16 int16_t;
540 typedef unsigned __int16 uint16_t;
541 typedef unsigned __int8 uint8_t;
543 typedef unsigned int uint32_t;
544 typedef unsigned short uint16_t;
545 typedef unsigned char uint8_t;
549 typedef int64_t lws_usec_t;
550 typedef unsigned long long lws_filepos_t;
551 typedef long long lws_fileofs_t;
552 typedef uint32_t lws_fop_flags_t;
554 #define lws_concat_temp(_t, _l) (_t + sizeof(_t) - _l)
555 #define lws_concat_used(_t, _l) (sizeof(_t) - _l)
573 #include <libwebsockets/lws-dll2.h>
574 #include <libwebsockets/lws-map.h>
576 #include <libwebsockets/lws-fault-injection.h>
577 #include <libwebsockets/lws-timeout-timer.h>
578 #include <libwebsockets/lws-cache-ttl.h>
579 #if defined(LWS_WITH_SYS_SMD)
580 #include <libwebsockets/lws-smd.h>
582 #include <libwebsockets/lws-state.h>
583 #include <libwebsockets/lws-retry.h>
584 #include <libwebsockets/lws-adopt.h>
585 #include <libwebsockets/lws-network-helper.h>
586 #include <libwebsockets/lws-metrics.h>
587 #include <libwebsockets/lws-system.h>
588 #include <libwebsockets/lws-ws-close.h>
589 #include <libwebsockets/lws-callbacks.h>
590 #include <libwebsockets/lws-ws-state.h>
591 #include <libwebsockets/lws-ws-ext.h>
592 #include <libwebsockets/lws-protocols-plugins.h>
594 #include <libwebsockets/lws-context-vhost.h>
596 #if defined(LWS_WITH_CONMON)
597 #include <libwebsockets/lws-conmon.h>
600 #if defined(LWS_ROLE_MQTT)
601 #include <libwebsockets/lws-mqtt.h>
603 #include <libwebsockets/lws-client.h>
604 #include <libwebsockets/lws-http.h>
605 #include <libwebsockets/lws-spa.h>
606 #include <libwebsockets/lws-purify.h>
607 #include <libwebsockets/lws-misc.h>
608 #include <libwebsockets/lws-dsh.h>
609 #include <libwebsockets/lws-service.h>
610 #include <libwebsockets/lws-write.h>
611 #include <libwebsockets/lws-writeable.h>
612 #include <libwebsockets/lws-ring.h>
613 #include <libwebsockets/lws-sha1-base64.h>
614 #include <libwebsockets/lws-x509.h>
615 #include <libwebsockets/lws-cgi.h>
616 #if defined(LWS_WITH_FILE_OPS)
617 #include <libwebsockets/lws-vfs.h>
619 #include <libwebsockets/lws-lejp.h>
620 #include <libwebsockets/lws-lecp.h>
621 #include <libwebsockets/lws-struct.h>
622 #include <libwebsockets/lws-threadpool.h>
623 #include <libwebsockets/lws-tokenize.h>
624 #include <libwebsockets/lws-lwsac.h>
625 #include <libwebsockets/lws-fts.h>
626 #include <libwebsockets/lws-diskcache.h>
627 #include <libwebsockets/lws-sequencer.h>
628 #include <libwebsockets/lws-secure-streams.h>
629 #include <libwebsockets/lws-secure-streams-policy.h>
630 #include <libwebsockets/lws-secure-streams-client.h>
632 #if !defined(LWS_PLAT_FREERTOS)
633 #include <libwebsockets/abstract/abstract.h>
635 #include <libwebsockets/lws-test-sequencer.h>
637 #include <libwebsockets/lws-async-dns.h>
639 #if defined(LWS_WITH_TLS)
641 #include <libwebsockets/lws-tls-sessions.h>
643 #if defined(LWS_WITH_MBEDTLS)
644 #include <mbedtls/md5.h>
645 #include <mbedtls/sha1.h>
646 #include <mbedtls/sha256.h>
647 #include <mbedtls/sha512.h>
650 #include <libwebsockets/lws-gencrypto.h>
651 #include <libwebsockets/lws-genhash.h>
652 #include <libwebsockets/lws-genrsa.h>
653 #include <libwebsockets/lws-genaes.h>
654 #include <libwebsockets/lws-genec.h>
656 #include <libwebsockets/lws-jwk.h>
657 #include <libwebsockets/lws-jose.h>
658 #include <libwebsockets/lws-jws.h>
659 #include <libwebsockets/lws-jwe.h>
663 #include <libwebsockets/lws-eventlib-exports.h>
664 #include <libwebsockets/lws-i2c.h>
665 #include <libwebsockets/lws-spi.h>
666 #include <libwebsockets/lws-gpio.h>
667 #include <libwebsockets/lws-bb-i2c.h>
668 #include <libwebsockets/lws-bb-spi.h>
669 #include <libwebsockets/lws-button.h>
670 #include <libwebsockets/lws-led.h>
671 #include <libwebsockets/lws-pwm.h>
672 #include <libwebsockets/lws-display.h>
673 #include <libwebsockets/lws-ssd1306-i2c.h>
674 #include <libwebsockets/lws-ili9341-spi.h>
675 #include <libwebsockets/lws-settings.h>
676 #include <libwebsockets/lws-netdev.h>
Definition: lws-ws-ext.h:139
Definition: libwebsockets.h:559
int events
Definition: libwebsockets.h:561
int prev_events
Definition: libwebsockets.h:562
lws_sockfd_type fd
Definition: libwebsockets.h:560
Definition: lws-protocols-plugins.h:44
Definition: lws-http.h:369
Definition: lws-http.h:204