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 #if defined(__MINGW32__)
129 #define LWS_INVALID_FILE -1
131 #define LWS_INVALID_FILE INVALID_HANDLE_VALUE
133 #define LWS_SOCK_INVALID (INVALID_SOCKET)
134 #define LWS_O_RDONLY _O_RDONLY
135 #define LWS_O_WRONLY _O_WRONLY
136 #define LWS_O_CREAT _O_CREAT
137 #define LWS_O_TRUNC _O_TRUNC
140 #define __func__ __FUNCTION__
145 #if defined(LWS_HAVE_SYS_CAPABILITY_H) && defined(LWS_HAVE_LIBCAP)
146 #include <sys/capability.h>
149 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__QNX__) || defined(__OpenBSD__)
150 #include <sys/socket.h>
151 #include <netinet/in.h>
154 #define LWS_INLINE inline
155 #define LWS_O_RDONLY O_RDONLY
156 #define LWS_O_WRONLY O_WRONLY
157 #define LWS_O_CREAT O_CREAT
158 #define LWS_O_TRUNC O_TRUNC
160 #if !defined(LWS_PLAT_OPTEE) && !defined(OPTEE_TA) && !defined(LWS_PLAT_FREERTOS)
163 #define LWS_INVALID_FILE -1
164 #define LWS_SOCK_INVALID (-1)
166 #define getdtablesize() (30)
167 #if defined(LWS_PLAT_FREERTOS)
168 #define LWS_INVALID_FILE NULL
169 #define LWS_SOCK_INVALID (-1)
171 #define LWS_INVALID_FILE NULL
172 #define LWS_SOCK_INVALID (-1)
176 #if defined(__FreeBSD__)
177 #include <sys/signal.h>
179 #if defined(__GNUC__)
182 #if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
183 #define LWS_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
185 #define LWS_WARN_UNUSED_RESULT
188 #if defined(LWS_BUILDING_SHARED)
190 #define LWS_VISIBLE __attribute__((visibility("default")))
191 #define LWS_EXTERN extern
194 #if defined(WIN32) || defined(_WIN32) || defined(__MINGW32__)
196 #define LWS_EXTERN extern
208 #define LWS_WARN_DEPRECATED __attribute__ ((deprecated))
209 #define LWS_FORMAT(string_index) __attribute__ ((format(printf, string_index, string_index+1)))
213 #define LWS_WARN_UNUSED_RESULT
214 #define LWS_WARN_DEPRECATED
215 #define LWS_FORMAT(string_index)
216 #if !defined(LWS_EXTERN)
217 #define LWS_EXTERN extern
222 #if defined(__ANDROID__)
223 #include <netinet/in.h>
231 #if !defined(LWS_PLAT_OPTEE)
232 #include <sys/time.h>
237 #if defined(LWS_WITH_LIBUV_INTERNAL)
240 #ifdef LWS_HAVE_UV_VERSION_H
241 #include <uv-version.h>
244 #ifdef LWS_HAVE_NEW_UV_VERSION_H
245 #include <uv/version.h>
249 #if defined(LWS_WITH_TLS)
252 #ifdef USE_OLD_CYASSL
258 #include <IDE/WIN/user_settings.h>
259 #include <cyassl/ctaocrypt/settings.h>
261 #include <cyassl/options.h>
263 #include <cyassl/openssl/ssl.h>
264 #include <cyassl/error-ssl.h>
272 #include <IDE/WIN/user_settings.h>
273 #include <wolfssl/wolfcrypt/settings.h>
275 #include <wolfssl/options.h>
277 #include <wolfssl/openssl/ssl.h>
278 #include <wolfssl/error-ssl.h>
281 #if defined(LWS_WITH_MBEDTLS)
282 #if defined(LWS_PLAT_FREERTOS)
284 #if !defined(LWS_AMAZON_RTOS)
286 #undef MBEDTLS_CONFIG_FILE
287 #define MBEDTLS_CONFIG_FILE <mbedtls/esp_config.h>
290 #if defined(LWS_WITH_TLS)
291 #include <mbedtls/ssl.h>
292 #include <mbedtls/entropy.h>
293 #include <mbedtls/ctr_drbg.h>
294 #include <mbedtls/version.h>
296 #if !defined(MBEDTLS_PRIVATE)
297 #define MBEDTLS_PRIVATE(_q) _q
300 #if (MBEDTLS_VERSION_MAJOR == 3) && (MBEDTLS_VERSION_MINOR == 0)
301 #define MBEDTLS_PRIVATE_V30_ONLY(_q) MBEDTLS_PRIVATE(_q)
303 #define MBEDTLS_PRIVATE_V30_ONLY(_q) _q
308 #include <openssl/ssl.h>
309 #if !defined(LWS_WITH_MBEDTLS)
310 #include <openssl/err.h>
327 #define lws_pthread_mutex(name) pthread_mutex_t name;
329 static LWS_INLINE
void
330 lws_pthread_mutex_init(pthread_mutex_t *lock)
332 pthread_mutex_init(lock, NULL);
335 static LWS_INLINE
void
336 lws_pthread_mutex_destroy(pthread_mutex_t *lock)
338 pthread_mutex_destroy(lock);
341 static LWS_INLINE
void
342 lws_pthread_mutex_lock(pthread_mutex_t *lock)
344 pthread_mutex_lock(lock);
347 static LWS_INLINE
void
348 lws_pthread_mutex_unlock(pthread_mutex_t *lock)
350 pthread_mutex_unlock(lock);
354 #define lws_pthread_mutex(name)
355 #define lws_pthread_mutex_init(_a)
356 #define lws_pthread_mutex_destroy(_a)
357 #define lws_pthread_mutex_lock(_a)
358 #define lws_pthread_mutex_unlock(_a)
362 #define CONTEXT_PORT_NO_LISTEN -1
363 #define CONTEXT_PORT_NO_LISTEN_SERVER -2
365 #include <libwebsockets/lws-logs.h>
370 #ifndef lws_container_of
371 #define lws_container_of(P,T,M) ((T *)((char *)(P) - offsetof(T, M)))
373 #define LWS_ALIGN_TO(x, bou) x += ((bou) - ((x) % (bou))) % (bou)
379 #define LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_ARG
382 #define LWS_FEATURE_PROTOCOLS_HAS_ID_FIELD
385 #define LWS_FEATURE_PROTOCOLS_HAS_PEER_WRITE_ALLOWANCE
388 #define LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_LEN
391 #define LWS_FEATURE_FOPS
395 #if !defined(LWS_WIN32_HANDLE_TYPES)
396 typedef SOCKET lws_sockfd_type;
397 #if defined(__MINGW32__)
398 typedef int lws_filefd_type;
400 typedef HANDLE lws_filefd_type;
405 #define lws_pollfd pollfd
406 #define LWS_POLLHUP (POLLHUP)
407 #define LWS_POLLIN (POLLRDNORM | POLLRDBAND)
408 #define LWS_POLLOUT (POLLWRNORM)
413 #if defined(LWS_PLAT_FREERTOS)
414 #include <libwebsockets/lws-freertos.h>
416 typedef int lws_sockfd_type;
417 typedef int lws_filefd_type;
420 #if defined(LWS_PLAT_OPTEE)
424 unsigned int tv_usec;
426 #if defined(LWS_WITH_NETWORK)
428 #define lws_pollfd pollfd
432 int gettimeofday(
struct timeval *tv,
struct timezone *tz);
439 typedef unsigned short sa_family_t;
440 typedef unsigned short in_port_t;
441 typedef uint32_t socklen_t;
443 #include <libwebsockets/lws-optee.h>
445 #if !defined(TEE_SE_READER_NAME_MAX)
451 socklen_t ai_addrlen;
452 struct sockaddr *ai_addr;
454 struct addrinfo *ai_next;
458 ssize_t recv(
int sockfd,
void *buf,
size_t len,
int flags);
459 ssize_t send(
int sockfd,
const void *buf,
size_t len,
int flags);
460 ssize_t read(
int fd,
void *buf,
size_t count);
461 int getsockopt(
int sockfd,
int level,
int optname,
462 void *optval, socklen_t *optlen);
463 int setsockopt(
int sockfd,
int level,
int optname,
464 const void *optval, socklen_t optlen);
465 int connect(
int sockfd,
const struct sockaddr *addr,
470 uint16_t ntohs(uint16_t netshort);
471 uint16_t htons(uint16_t hostshort);
473 int bind(
int sockfd,
const struct sockaddr *addr,
477 #define MSG_NOSIGNAL 0x4000
480 #define EWOULDBLOCK EAGAIN
481 #define EADDRINUSE 98
487 #define SOCK_STREAM 1
489 # define AI_PASSIVE 0x0001
490 #define IPPROTO_UDP 17
495 #define EINPROGRESS 115
496 int shutdown(
int sockfd,
int how);
498 int atoi(
const char *nptr);
499 long long atoll(
const char *nptr);
501 int socket(
int domain,
int type,
int protocol);
502 int getaddrinfo(
const char *node,
const char *service,
503 const struct addrinfo *hints,
504 struct addrinfo **res);
506 void freeaddrinfo(
struct addrinfo *res);
508 #if !defined(TEE_SE_READER_NAME_MAX)
517 int poll(
struct pollfd *fds,
int nfds,
int timeout);
519 #define LWS_POLLHUP (0x18)
520 #define LWS_POLLIN (1)
521 #define LWS_POLLOUT (4)
527 #define lws_pollfd pollfd
528 #define LWS_POLLHUP (POLLHUP | POLLERR)
529 #define LWS_POLLIN (POLLIN)
530 #define LWS_POLLOUT (POLLOUT)
535 #if (defined(WIN32) || defined(_WIN32)) && !defined(__MINGW32__)
537 #define ssize_t SSIZE_T
540 #if defined(WIN32) && defined(LWS_HAVE__STAT32I64)
541 #include <sys/types.h>
542 #include <sys/stat.h>
545 #if defined(LWS_HAVE_STDINT_H)
548 #if defined(WIN32) || defined(_WIN32)
550 typedef __int64 int64_t;
551 typedef unsigned __int64 uint64_t;
552 typedef __int32 int32_t;
553 typedef unsigned __int32 uint32_t;
554 typedef __int16 int16_t;
555 typedef unsigned __int16 uint16_t;
556 typedef unsigned __int8 uint8_t;
558 typedef unsigned int uint32_t;
559 typedef unsigned short uint16_t;
560 typedef unsigned char uint8_t;
564 typedef int64_t lws_usec_t;
565 typedef unsigned long long lws_filepos_t;
566 typedef long long lws_fileofs_t;
567 typedef uint32_t lws_fop_flags_t;
569 #define lws_concat_temp(_t, _l) (_t + sizeof(_t) - _l)
570 #define lws_concat_used(_t, _l) (sizeof(_t) - _l)
588 #include <libwebsockets/lws-dll2.h>
589 #include <libwebsockets/lws-map.h>
591 #include <libwebsockets/lws-fault-injection.h>
592 #include <libwebsockets/lws-timeout-timer.h>
593 #include <libwebsockets/lws-cache-ttl.h>
594 #if defined(LWS_WITH_SYS_SMD)
595 #include <libwebsockets/lws-smd.h>
597 #include <libwebsockets/lws-state.h>
598 #include <libwebsockets/lws-retry.h>
599 #include <libwebsockets/lws-adopt.h>
600 #include <libwebsockets/lws-network-helper.h>
601 #include <libwebsockets/lws-metrics.h>
602 #include <libwebsockets/lws-system.h>
603 #include <libwebsockets/lws-ws-close.h>
604 #include <libwebsockets/lws-callbacks.h>
605 #include <libwebsockets/lws-ws-state.h>
606 #include <libwebsockets/lws-ws-ext.h>
607 #include <libwebsockets/lws-protocols-plugins.h>
609 #include <libwebsockets/lws-context-vhost.h>
611 #if defined(LWS_WITH_CONMON)
612 #include <libwebsockets/lws-conmon.h>
615 #if defined(LWS_ROLE_MQTT)
616 #include <libwebsockets/lws-mqtt.h>
618 #include <libwebsockets/lws-client.h>
619 #include <libwebsockets/lws-http.h>
620 #include <libwebsockets/lws-spa.h>
621 #include <libwebsockets/lws-purify.h>
622 #include <libwebsockets/lws-misc.h>
623 #include <libwebsockets/lws-dsh.h>
624 #include <libwebsockets/lws-service.h>
625 #include <libwebsockets/lws-write.h>
626 #include <libwebsockets/lws-writeable.h>
627 #include <libwebsockets/lws-ring.h>
628 #include <libwebsockets/lws-sha1-base64.h>
629 #include <libwebsockets/lws-x509.h>
630 #include <libwebsockets/lws-cgi.h>
631 #if defined(LWS_WITH_FILE_OPS)
632 #include <libwebsockets/lws-vfs.h>
634 #include <libwebsockets/lws-gencrypto.h>
636 #include <libwebsockets/lws-lejp.h>
637 #include <libwebsockets/lws-lecp.h>
638 #include <libwebsockets/lws-cose.h>
639 #include <libwebsockets/lws-struct.h>
640 #include <libwebsockets/lws-threadpool.h>
641 #include <libwebsockets/lws-tokenize.h>
642 #include <libwebsockets/lws-lwsac.h>
643 #include <libwebsockets/lws-fts.h>
644 #include <libwebsockets/lws-diskcache.h>
645 #include <libwebsockets/lws-sequencer.h>
646 #include <libwebsockets/lws-secure-streams.h>
647 #include <libwebsockets/lws-secure-streams-policy.h>
648 #include <libwebsockets/lws-secure-streams-client.h>
650 #if !defined(LWS_PLAT_FREERTOS)
651 #include <libwebsockets/abstract/abstract.h>
653 #include <libwebsockets/lws-test-sequencer.h>
655 #include <libwebsockets/lws-async-dns.h>
657 #if defined(LWS_WITH_TLS)
659 #include <libwebsockets/lws-tls-sessions.h>
661 #if defined(LWS_WITH_MBEDTLS)
662 #include <mbedtls/md5.h>
663 #include <mbedtls/sha1.h>
664 #include <mbedtls/sha256.h>
665 #include <mbedtls/sha512.h>
668 #include <libwebsockets/lws-genhash.h>
669 #include <libwebsockets/lws-genrsa.h>
670 #include <libwebsockets/lws-genaes.h>
671 #include <libwebsockets/lws-genec.h>
673 #include <libwebsockets/lws-jwk.h>
674 #include <libwebsockets/lws-jose.h>
675 #include <libwebsockets/lws-jws.h>
676 #include <libwebsockets/lws-jwe.h>
680 #include <libwebsockets/lws-eventlib-exports.h>
681 #include <libwebsockets/lws-i2c.h>
682 #include <libwebsockets/lws-spi.h>
683 #include <libwebsockets/lws-gpio.h>
684 #include <libwebsockets/lws-bb-i2c.h>
685 #include <libwebsockets/lws-bb-spi.h>
686 #include <libwebsockets/lws-button.h>
687 #include <libwebsockets/lws-led.h>
688 #include <libwebsockets/lws-pwm.h>
689 #include <libwebsockets/lws-display.h>
690 #include <libwebsockets/lws-ssd1306-i2c.h>
691 #include <libwebsockets/lws-ili9341-spi.h>
692 #include <libwebsockets/lws-settings.h>
693 #include <libwebsockets/lws-netdev.h>
Definition: lws-ws-ext.h:139
Definition: libwebsockets.h:574
int events
Definition: libwebsockets.h:576
int prev_events
Definition: libwebsockets.h:577
lws_sockfd_type fd
Definition: libwebsockets.h:575
Definition: lws-protocols-plugins.h:44
Definition: lws-http.h:369
Definition: lws-http.h:204