24 #ifndef LIBWEBSOCKET_H_3060898B846849FF9F88F5DB59B5950C
25 #define LIBWEBSOCKET_H_3060898B846849FF9F88F5DB59B5950C
39 #include "lws_config.h"
45 #if defined(LWS_HAS_INTPTR_T)
47 #define lws_intptr_t intptr_t
49 typedef unsigned long long lws_intptr_t;
52 #if defined(WIN32) || defined(_WIN32)
53 #ifndef WIN32_LEAN_AND_MEAN
54 #define WIN32_LEAN_AND_MEAN
65 #define _O_RDONLY 0x0000
66 #define O_RDONLY _O_RDONLY
69 #define LWS_INLINE __inline
71 #define LWS_WARN_UNUSED_RESULT
72 #define LWS_WARN_DEPRECATED
73 #define LWS_FORMAT(string_index)
75 #if !defined(LWS_EXTERN)
78 #define LWS_EXTERN extern __declspec(dllexport)
80 #define LWS_EXTERN extern __declspec(dllimport)
87 #define LWS_INVALID_FILE INVALID_HANDLE_VALUE
88 #define LWS_O_RDONLY _O_RDONLY
89 #define LWS_O_WRONLY _O_WRONLY
90 #define LWS_O_CREAT _O_CREAT
91 #define LWS_O_TRUNC _O_TRUNC
94 #define __func__ __FUNCTION__
99 #if defined(LWS_HAVE_SYS_CAPABILITY_H) && defined(LWS_HAVE_LIBCAP)
100 #include <sys/capability.h>
103 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__QNX__) || defined(__OpenBSD__)
104 #include <sys/socket.h>
105 #include <netinet/in.h>
108 #define LWS_INLINE inline
109 #define LWS_O_RDONLY O_RDONLY
110 #define LWS_O_WRONLY O_WRONLY
111 #define LWS_O_CREAT O_CREAT
112 #define LWS_O_TRUNC O_TRUNC
114 #if !defined(LWS_PLAT_OPTEE) && !defined(OPTEE_TA) && !defined(LWS_WITH_ESP32)
117 #define LWS_INVALID_FILE -1
119 #define getdtablesize() (30)
120 #if defined(LWS_WITH_ESP32)
121 #define LWS_INVALID_FILE NULL
123 #define LWS_INVALID_FILE NULL
127 #if defined(__GNUC__)
130 #if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
131 #define LWS_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
133 #define LWS_WARN_UNUSED_RESULT
136 #define LWS_VISIBLE __attribute__((visibility("default")))
137 #define LWS_WARN_DEPRECATED __attribute__ ((deprecated))
138 #define LWS_FORMAT(string_index) __attribute__ ((format(printf, string_index, string_index+1)))
141 #define LWS_WARN_UNUSED_RESULT
142 #define LWS_WARN_DEPRECATED
143 #define LWS_FORMAT(string_index)
146 #if defined(__ANDROID__)
147 #include <netinet/in.h>
153 #if defined(LWS_WITH_LIBEV)
156 #ifdef LWS_WITH_LIBUV
158 #ifdef LWS_HAVE_UV_VERSION_H
159 #include <uv-version.h>
161 #ifdef LWS_HAVE_NEW_UV_VERSION_H
162 #include <uv/version.h>
165 #if defined(LWS_WITH_LIBEVENT)
166 #include <event2/event.h>
170 #define LWS_EXTERN extern
176 #if !defined(OPTEE_TA)
177 #include <sys/time.h>
182 #if defined(LWS_WITH_TLS)
185 #ifdef USE_OLD_CYASSL
191 #include <IDE/WIN/user_settings.h>
192 #include <cyassl/ctaocrypt/settings.h>
194 #include <cyassl/options.h>
196 #include <cyassl/openssl/ssl.h>
197 #include <cyassl/error-ssl.h>
205 #include <IDE/WIN/user_settings.h>
206 #include <wolfssl/wolfcrypt/settings.h>
208 #include <wolfssl/options.h>
210 #include <wolfssl/openssl/ssl.h>
211 #include <wolfssl/error-ssl.h>
214 #if defined(LWS_WITH_MBEDTLS)
215 #if defined(LWS_WITH_ESP32)
217 #if !defined(LWS_AMAZON_RTOS)
219 #undef MBEDTLS_CONFIG_FILE
220 #define MBEDTLS_CONFIG_FILE <mbedtls/esp_config.h>
223 #include <mbedtls/ssl.h>
224 #include <mbedtls/entropy.h>
225 #include <mbedtls/ctr_drbg.h>
227 #include <openssl/ssl.h>
228 #if !defined(LWS_WITH_MBEDTLS)
229 #include <openssl/err.h>
246 #define lws_pthread_mutex(name) pthread_mutex_t name;
248 static LWS_INLINE
void
249 lws_pthread_mutex_init(pthread_mutex_t *lock)
251 pthread_mutex_init(lock, NULL);
254 static LWS_INLINE
void
255 lws_pthread_mutex_destroy(pthread_mutex_t *lock)
257 pthread_mutex_destroy(lock);
260 static LWS_INLINE
void
261 lws_pthread_mutex_lock(pthread_mutex_t *lock)
263 pthread_mutex_lock(lock);
266 static LWS_INLINE
void
267 lws_pthread_mutex_unlock(pthread_mutex_t *lock)
269 pthread_mutex_unlock(lock);
273 #define lws_pthread_mutex(name)
274 #define lws_pthread_mutex_init(_a)
275 #define lws_pthread_mutex_destroy(_a)
276 #define lws_pthread_mutex_lock(_a)
277 #define lws_pthread_mutex_unlock(_a)
281 #define CONTEXT_PORT_NO_LISTEN -1
282 #define CONTEXT_PORT_NO_LISTEN_SERVER -2
284 #include <libwebsockets/lws-logs.h>
289 #ifndef lws_container_of
290 #define lws_container_of(P,T,M) ((T *)((char *)(P) - offsetof(T, M)))
297 #define LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_ARG
300 #define LWS_FEATURE_PROTOCOLS_HAS_ID_FIELD
303 #define LWS_FEATURE_PROTOCOLS_HAS_PEER_WRITE_ALLOWANCE
306 #define LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_LEN
309 #define LWS_FEATURE_FOPS
313 #if !defined(LWS_WIN32_HANDLE_TYPES)
314 typedef SOCKET lws_sockfd_type;
315 typedef HANDLE lws_filefd_type;
323 #define LWS_POLLHUP (FD_CLOSE)
324 #define LWS_POLLIN (FD_READ | FD_ACCEPT)
325 #define LWS_POLLOUT (FD_WRITE)
329 #if defined(LWS_WITH_ESP32)
330 #include <libwebsockets/lws-esp32.h>
332 typedef int lws_sockfd_type;
333 typedef int lws_filefd_type;
336 #define lws_pollfd pollfd
337 #define LWS_POLLHUP (POLLHUP|POLLERR)
338 #define LWS_POLLIN (POLLIN)
339 #define LWS_POLLOUT (POLLOUT)
343 #if (defined(WIN32) || defined(_WIN32)) && !defined(__MINGW32__)
345 #define ssize_t SSIZE_T
348 #if defined(WIN32) && defined(LWS_HAVE__STAT32I64)
349 #include <sys/types.h>
350 #include <sys/stat.h>
353 #if defined(LWS_HAVE_STDINT_H)
356 #if defined(WIN32) || defined(_WIN32)
358 typedef __int64 int64_t;
359 typedef unsigned __int64 uint64_t;
360 typedef __int32 int32_t;
361 typedef unsigned __int32 uint32_t;
362 typedef __int16 int16_t;
363 typedef unsigned __int16 uint16_t;
364 typedef unsigned __int8 uint8_t;
366 typedef unsigned int uint32_t;
367 typedef unsigned short uint16_t;
368 typedef unsigned char uint8_t;
372 typedef int64_t lws_usec_t;
373 typedef unsigned long long lws_filepos_t;
374 typedef long long lws_fileofs_t;
375 typedef uint32_t lws_fop_flags_t;
392 #include <libwebsockets/lws-ws-close.h>
393 #include <libwebsockets/lws-callbacks.h>
394 #include <libwebsockets/lws-ws-state.h>
395 #include <libwebsockets/lws-ws-ext.h>
396 #include <libwebsockets/lws-protocols-plugins.h>
397 #include <libwebsockets/lws-plugin-generic-sessions.h>
398 #include <libwebsockets/lws-context-vhost.h>
399 #include <libwebsockets/lws-client.h>
400 #include <libwebsockets/lws-http.h>
401 #include <libwebsockets/lws-spa.h>
402 #include <libwebsockets/lws-purify.h>
403 #include <libwebsockets/lws-timeout-timer.h>
404 #include <libwebsockets/lws-service.h>
405 #include <libwebsockets/lws-write.h>
406 #include <libwebsockets/lws-writeable.h>
407 #include <libwebsockets/lws-adopt.h>
408 #include <libwebsockets/lws-network-helper.h>
409 #include <libwebsockets/lws-misc.h>
410 #include <libwebsockets/lws-ring.h>
411 #include <libwebsockets/lws-sha1-base64.h>
412 #include <libwebsockets/lws-x509.h>
413 #include <libwebsockets/lws-cgi.h>
414 #include <libwebsockets/lws-vfs.h>
415 #include <libwebsockets/lws-lejp.h>
416 #include <libwebsockets/lws-stats.h>
417 #include <libwebsockets/lws-threadpool.h>
418 #include <libwebsockets/lws-tokenize.h>
419 #include <libwebsockets/lws-lwsac.h>
420 #include <libwebsockets/lws-fts.h>
421 #include <libwebsockets/lws-diskcache.h>
423 #if defined(LWS_WITH_TLS)
425 #if defined(LWS_WITH_MBEDTLS)
426 #include <mbedtls/sha1.h>
427 #include <mbedtls/sha256.h>
428 #include <mbedtls/sha512.h>
431 #include <libwebsockets/lws-genhash.h>
432 #include <libwebsockets/lws-genrsa.h>
433 #include <libwebsockets/lws-jwk.h>
434 #include <libwebsockets/lws-jws.h>