diff --git a/CMakeLists.txt b/CMakeLists.txt index b4966747e..9993779a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,11 @@ # IN THE SOFTWARE. # -cmake_minimum_required(VERSION 2.8.12) +if (PICO_SDK_PATH) + cmake_minimum_required(VERSION 3.13) +else() + cmake_minimum_required(VERSION 2.8.12) +endif() include(CheckFunctionExists) include(CheckSymbolExists) include(CheckIncludeFile) @@ -30,6 +34,10 @@ include(CheckIncludeFiles) include(CheckLibraryExists) include(CheckTypeSize) include(CheckCSourceCompiles) +if (PICO_SDK_PATH) + include(cmake/pico_sdk_import.cmake) +endif() + if (POLICY CMP0048) cmake_policy(SET CMP0048 NEW) @@ -66,6 +74,10 @@ endif() project(libwebsockets C CXX) include(CTest) +if (PICO_SDK_PATH) + pico_sdk_init() +endif() + if (ESP_PLATFORM) include_directories( $ENV{IDF_PATH}/components/esp_hw_support/include/soc/ @@ -221,6 +233,7 @@ option(LWS_WITH_ESP32 "Build for ESP32" OFF) option(LWS_PLAT_OPTEE "Build for OPTEE" OFF) option(LWS_PLAT_FREERTOS "Build for FreeRTOS" OFF) option(LWS_PLAT_ANDROID "Android flavour of unix platform" OFF) +option(LWS_PLAT_BAREMETAL "Build for deeply embedded baremetal" OFF) # # Client / Server / Test Apps build control @@ -557,6 +570,10 @@ CHECK_C_SOURCE_COMPILES( int main(int argc, char **argv) { return (int)malloc_usable_size((void *)0); } " LWS_HAVE_MALLOC_USABLE_SIZE) +if (PICO_SDK_PATH) + set(CMAKE_REQUIRED_DEFINITIONS "-Dxxexit=exit") +endif() + CHECK_FUNCTION_EXISTS(fork LWS_HAVE_FORK) CHECK_FUNCTION_EXISTS(getenv LWS_HAVE_GETENV) CHECK_FUNCTION_EXISTS(malloc LWS_HAVE_MALLOC) @@ -583,6 +600,26 @@ CHECK_FUNCTION_EXISTS(getgrnam_r LWS_HAVE_GETGRNAM_R) CHECK_FUNCTION_EXISTS(getpwuid_r LWS_HAVE_GETPWUID_R) CHECK_FUNCTION_EXISTS(getpwnam_r LWS_HAVE_GETPWNAM_R) CHECK_FUNCTION_EXISTS(timegm LWS_HAVE_TIMEGM) +CHECK_C_SOURCE_COMPILES("#include \nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_IN6ADDR_H) +CHECK_C_SOURCE_COMPILES("#include \nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_MEMORY_H) +CHECK_C_SOURCE_COMPILES("#include \nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_NETINET_IN_H) +CHECK_C_SOURCE_COMPILES("#include \nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_STDINT_H) +CHECK_C_SOURCE_COMPILES("#include \nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_STDLIB_H) +CHECK_C_SOURCE_COMPILES("#include \nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_STRINGS_H) +CHECK_C_SOURCE_COMPILES("#include \nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_STRING_H) +CHECK_C_SOURCE_COMPILES("#include \nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_SYS_PRCTL_H) +CHECK_C_SOURCE_COMPILES("#include \nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_SYS_SOCKET_H) +CHECK_C_SOURCE_COMPILES("#include \nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_SYS_SOCKIO_H) +CHECK_C_SOURCE_COMPILES("#include \nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_SYS_STAT_H) +CHECK_C_SOURCE_COMPILES("#include \nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_SYS_TYPES_H) +CHECK_C_SOURCE_COMPILES("#include \nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_UNISTD_H) +CHECK_C_SOURCE_COMPILES("#include \nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_VFORK_H) +CHECK_C_SOURCE_COMPILES("#include \nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_SYS_CAPABILITY_H) +CHECK_C_SOURCE_COMPILES("#include \nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_MALLOC_H) +CHECK_C_SOURCE_COMPILES("#include \nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_PTHREAD_H) +CHECK_C_SOURCE_COMPILES("#include \nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_INTTYPES_H) +CHECK_C_SOURCE_COMPILES("#include \nvoid main(void) { while(1) ; } void xxexit(void){}" LWS_HAVE_SYS_RESOURCE_H) + if(CMAKE_SYSTEM_NAME MATCHES "Darwin") if(CMAKE_OSX_DEPLOYMENT_TARGET LESS "10.12") @@ -623,26 +660,6 @@ if (LWS_WITH_PLUGINS_API AND UNIX AND CMAKE_DL_LIBS AND NOT (${CMAKE_SYSTEM_NAME endif() -CHECK_INCLUDE_FILE(in6addr.h LWS_HAVE_IN6ADDR_H) -CHECK_INCLUDE_FILE(memory.h LWS_HAVE_MEMORY_H) -CHECK_INCLUDE_FILE(netinet/in.h LWS_HAVE_NETINET_IN_H) -CHECK_INCLUDE_FILE(stdint.h LWS_HAVE_STDINT_H) -CHECK_INCLUDE_FILE(stdlib.h LWS_HAVE_STDLIB_H) -CHECK_INCLUDE_FILE(strings.h LWS_HAVE_STRINGS_H) -CHECK_INCLUDE_FILE(string.h LWS_HAVE_STRING_H) -CHECK_INCLUDE_FILE(sys/prctl.h LWS_HAVE_SYS_PRCTL_H) -CHECK_INCLUDE_FILE(sys/socket.h LWS_HAVE_SYS_SOCKET_H) -CHECK_INCLUDE_FILE(sys/sockio.h LWS_HAVE_SYS_SOCKIO_H) -CHECK_INCLUDE_FILE(sys/stat.h LWS_HAVE_SYS_STAT_H) -CHECK_INCLUDE_FILE(sys/types.h LWS_HAVE_SYS_TYPES_H) -CHECK_INCLUDE_FILE(unistd.h LWS_HAVE_UNISTD_H) -CHECK_INCLUDE_FILE(vfork.h LWS_HAVE_VFORK_H) -CHECK_INCLUDE_FILE(sys/capability.h LWS_HAVE_SYS_CAPABILITY_H) -CHECK_INCLUDE_FILE(malloc.h LWS_HAVE_MALLOC_H) -CHECK_INCLUDE_FILE(pthread.h LWS_HAVE_PTHREAD_H) -CHECK_INCLUDE_FILE(inttypes.h LWS_HAVE_INTTYPES_H) -CHECK_INCLUDE_FILE(sys/resource.h LWS_HAVE_SYS_RESOURCE_H) - if (WIN32 OR MSVC) CHECK_C_SOURCE_COMPILES("#include #include @@ -795,6 +812,10 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG) set(CMAKE_C_FLAGS "-Wall -Wsign-compare ${VISIBILITY_FLAG} ${GCOV_FLAGS} ${CMAKE_C_FLAGS}" ) endif() + if (PICO_SDK_PATH) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wconversion -Wsign-compare -Wstrict-aliasing -Wundef -nolibc") + endif() + if ("${DISABLE_WERROR}" STREQUAL "OFF") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") endif() @@ -992,6 +1013,10 @@ if (NOT LWS_WITH_PLUGINS_BUILTIN) add_subdirectory(plugins) endif() add_subdirectory(lwsws) +if (PICO_SDK_PATH) + link_libraries(pico_stdlib PRIVATE) +endif() + # Generate the lws_config.h that includes all the public compilation settings. configure_file( diff --git a/cmake/lws_config.h.in b/cmake/lws_config.h.in index f3f4a9d79..b973f9300 100644 --- a/cmake/lws_config.h.in +++ b/cmake/lws_config.h.in @@ -101,6 +101,7 @@ #cmakedefine LWS_HAVE_SSL_SESSION_up_ref #cmakedefine LWS_HAVE__STAT32I64 #cmakedefine LWS_HAVE_STDINT_H +#cmakedefine LWS_HAVE_SYS_TYPES_H #cmakedefine LWS_HAVE_SYS_CAPABILITY_H #cmakedefine LWS_HAVE_TIMEGM #cmakedefine LWS_HAVE_TLS_CLIENT_METHOD @@ -122,6 +123,7 @@ #cmakedefine LWS_PLAT_OPTEE #cmakedefine LWS_PLAT_UNIX #cmakedefine LWS_PLAT_FREERTOS +#cmakedefine LWS_PLAT_BAREMETAL #cmakedefine LWS_ROLE_CGI #cmakedefine LWS_ROLE_DBUS #cmakedefine LWS_ROLE_H1 @@ -237,4 +239,5 @@ #cmakedefine LWS_WITH_LIBUV_INTERNAL #cmakedefine LWS_WITH_PLUGINS_API #cmakedefine LWS_HAVE_RTA_PREF +#cmakedefine PICO_SDK_PATH diff --git a/cmake/lws_config_private.h.in b/cmake/lws_config_private.h.in index 7f61e4fcd..2f7500a20 100644 --- a/cmake/lws_config_private.h.in +++ b/cmake/lws_config_private.h.in @@ -92,11 +92,11 @@ */ #undef LT_OBJDIR // We're not using libtool -/* Define to rpl_malloc if the replacement function should be used. */ -#cmakedefine malloc +///* Define to rpl_malloc if the replacement function should be used. */ +//#cmakedefine malloc /* Define to rpl_realloc if the replacement function should be used. */ -#cmakedefine realloc +//#cmakedefine realloc /* Define to 1 if we have getifaddrs */ #cmakedefine LWS_HAVE_GETIFADDRS diff --git a/cmake/pico_sdk_import.cmake b/cmake/pico_sdk_import.cmake new file mode 100644 index 000000000..28efe9eab --- /dev/null +++ b/cmake/pico_sdk_import.cmake @@ -0,0 +1,62 @@ +# This is a copy of /external/pico_sdk_import.cmake + +# This can be dropped into an external project to help locate this SDK +# It should be include()ed prior to project() + +if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH)) + set(PICO_SDK_PATH $ENV{PICO_SDK_PATH}) + message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')") +endif () + +if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT)) + set(PICO_SDK_FETCH_FROM_GIT $ENV{PICO_SDK_FETCH_FROM_GIT}) + message("Using PICO_SDK_FETCH_FROM_GIT from environment ('${PICO_SDK_FETCH_FROM_GIT}')") +endif () + +if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH)) + set(PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH}) + message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')") +endif () + +set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK") +set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable") +set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK") + +if (NOT PICO_SDK_PATH) + if (PICO_SDK_FETCH_FROM_GIT) + include(FetchContent) + set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR}) + if (PICO_SDK_FETCH_FROM_GIT_PATH) + get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}") + endif () + FetchContent_Declare( + pico_sdk + GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk + GIT_TAG master + ) + if (NOT pico_sdk) + message("Downloading Raspberry Pi Pico SDK") + FetchContent_Populate(pico_sdk) + set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR}) + endif () + set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE}) + else () + message(FATAL_ERROR + "SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git." + ) + endif () +endif () + +get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") +if (NOT EXISTS ${PICO_SDK_PATH}) + message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found") +endif () + +set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake) +if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE}) + message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the Raspberry Pi Pico SDK") +endif () + +set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE) + +include(${PICO_SDK_INIT_CMAKE_FILE}) diff --git a/include/libwebsockets.h b/include/libwebsockets.h index 759f3d61f..321929597 100644 --- a/include/libwebsockets.h +++ b/include/libwebsockets.h @@ -36,10 +36,16 @@ extern "C" { #include #endif +#include "lws_config.h" + +#ifdef LWS_HAVE_SYS_TYPES_H +#include +#endif + +#include #include #include -#include "lws_config.h" #if defined(LWS_SUPPRESS_DEPRECATED_API_WARNINGS) #define OPENSSL_USE_DEPRECATED @@ -153,7 +159,7 @@ typedef int suseconds_t; #define LWS_O_CREAT O_CREAT #define LWS_O_TRUNC O_TRUNC -#if !defined(LWS_PLAT_OPTEE) && !defined(OPTEE_TA) && !defined(LWS_PLAT_FREERTOS) +#if !defined(LWS_PLAT_OPTEE) && !defined(OPTEE_TA) && !defined(LWS_PLAT_FREERTOS) && !defined(LWS_PLAT_BAREMETAL) #include #include #define LWS_INVALID_FILE -1 @@ -562,6 +568,25 @@ struct lws_pollargs { int prev_events; /**< the previous event mask */ }; +#if !defined(LWS_SIZEOFPTR) +#define LWS_SIZEOFPTR ((int)sizeof (void *)) +#endif + +#if defined(__x86_64__) +#define _LWS_PAD_SIZE 16 /* Intel recommended for best performance */ +#else +#define _LWS_PAD_SIZE LWS_SIZEOFPTR /* Size of a pointer on the target arch */ +#endif +#define _LWS_PAD(n) (((n) % _LWS_PAD_SIZE) ? \ + ((n) + (_LWS_PAD_SIZE - ((n) % _LWS_PAD_SIZE))) : (n)) +/* last 2 is for lws-meta */ +#define LWS_PRE _LWS_PAD(4 + 10 + 2) +/* used prior to 1.7 and retained for backward compatibility */ +#define LWS_SEND_BUFFER_PRE_PADDING LWS_PRE +#define LWS_SEND_BUFFER_POST_PADDING 0 + + + struct lws_extension; /* needed even with ws exts disabled for create context */ struct lws_token_limits; struct lws_protocols; @@ -581,18 +606,23 @@ struct lws; #endif #include #include +#if defined(LWS_WITH_NETWORK) #include #include #include +#endif + #include +#if defined(LWS_WITH_NETWORK) #include #include #include #include #include - +#endif #include +#if defined(LWS_WITH_NETWORK) #if defined(LWS_WITH_CONMON) #include #endif @@ -603,16 +633,21 @@ struct lws; #include #include #include +#endif #include #include #include +#if defined(LWS_WITH_NETWORK) #include #include #include +#endif #include #include #include +#if defined(LWS_WITH_NETWORK) #include +#endif #if defined(LWS_WITH_FILE_OPS) #include #endif @@ -662,7 +697,9 @@ struct lws; #endif +#if defined(LWS_WITH_NETWORK) #include +#endif #include #include #include @@ -675,8 +712,9 @@ struct lws; #include #include #include +#if defined(LWS_WITH_NETWORK) #include - +#endif #ifdef __cplusplus } #endif diff --git a/include/libwebsockets/lws-context-vhost.h b/include/libwebsockets/lws-context-vhost.h index b3de140b5..8ca460174 100644 --- a/include/libwebsockets/lws-context-vhost.h +++ b/include/libwebsockets/lws-context-vhost.h @@ -255,9 +255,11 @@ struct lws_metric_policy; typedef int (*lws_context_ready_cb_t)(struct lws_context *context); +#if defined(LWS_WITH_NETWORK) typedef int (*lws_peer_limits_notify_t)(struct lws_context *ctx, lws_sockfd_type sockfd, lws_sockaddr46 *sa46); +#endif /** struct lws_context_creation_info - parameters to create context and /or vhost with * diff --git a/include/libwebsockets/lws-logs.h b/include/libwebsockets/lws-logs.h index 3f21b8100..512d6fa2c 100644 --- a/include/libwebsockets/lws-logs.h +++ b/include/libwebsockets/lws-logs.h @@ -133,13 +133,16 @@ LWS_VISIBLE LWS_EXTERN struct lws_log_cx * lwsl_wsi_get_cx(struct lws *wsi); #if defined(LWS_WITH_SECURE_STREAMS) struct lws_ss_handle; -struct lws_sspc_handle; LWS_VISIBLE LWS_EXTERN struct lws_log_cx * lwsl_ss_get_cx(struct lws_ss_handle *ss); +#endif +#if defined(LWS_WITH_SECURE_STREAMS_PROXY_API) +struct lws_sspc_handle; LWS_VISIBLE LWS_EXTERN struct lws_log_cx * lwsl_sspc_get_cx(struct lws_sspc_handle *ss); #endif + LWS_VISIBLE LWS_EXTERN void lws_log_emit_cx_file(struct lws_log_cx *cx, int level, const char *line, size_t len); @@ -156,6 +159,8 @@ lws_log_prepend_wsi(struct lws_log_cx *cx, void *obj, char **p, char *e); #if defined(LWS_WITH_SECURE_STREAMS) LWS_VISIBLE LWS_EXTERN void lws_log_prepend_ss(struct lws_log_cx *cx, void *obj, char **p, char *e); +#endif +#if defined(LWS_WITH_SECURE_STREAMS_PROXY_API) LWS_VISIBLE LWS_EXTERN void lws_log_prepend_sspc(struct lws_log_cx *cx, void *obj, char **p, char *e); #endif diff --git a/include/libwebsockets/lws-secure-streams-client.h b/include/libwebsockets/lws-secure-streams-client.h index adca1db16..f644ab5ae 100644 --- a/include/libwebsockets/lws-secure-streams-client.h +++ b/include/libwebsockets/lws-secure-streams-client.h @@ -265,7 +265,9 @@ lws_sspc_proxy_create(struct lws_context *context); LWS_VISIBLE LWS_EXTERN struct lws_context * lws_sspc_get_context(struct lws_sspc_handle *h); -LWS_VISIBLE extern const struct lws_protocols lws_sspc_protocols[2]; +#if defined(LWS_WITH_NETWORK) +extern const struct lws_protocols lws_sspc_protocols[2]; +#endif LWS_VISIBLE LWS_EXTERN const char * lws_sspc_rideshare(struct lws_sspc_handle *h); diff --git a/include/libwebsockets/lws-system.h b/include/libwebsockets/lws-system.h index 07900e02b..ec9432311 100644 --- a/include/libwebsockets/lws-system.h +++ b/include/libwebsockets/lws-system.h @@ -187,11 +187,12 @@ typedef struct lws_system_ops { * by calling lws_captive_portal_detect_result() api */ +#if defined(LWS_WITH_NETWORK) int (*metric_report)(lws_metric_pub_t *mdata); /**< metric \p item is reporting an event of kind \p rpt, * held in \p mdata... return 0 to leave the metric object as it is, * or nonzero to reset it. */ - +#endif int (*jit_trust_query)(struct lws_context *cx, const uint8_t *skid, size_t skid_len, void *got_opaque); /**< user defined trust store search, if we do trust a cert with SKID @@ -309,6 +310,7 @@ enum { _LWSDH_SA46_COUNT, }; +#if defined(LWS_WITH_NETWORK) typedef struct lws_dhcpc_ifstate { char ifname[16]; char domain[64]; @@ -397,3 +399,6 @@ lws_system_cpd_set(struct lws_context *context, lws_cpd_result_t result); */ LWS_EXTERN LWS_VISIBLE lws_cpd_result_t lws_system_cpd_state_get(struct lws_context *context); + +#endif + diff --git a/include/libwebsockets/lws-write.h b/include/libwebsockets/lws-write.h index 5fffb4d01..40877f923 100644 --- a/include/libwebsockets/lws-write.h +++ b/include/libwebsockets/lws-write.h @@ -27,23 +27,6 @@ APIs related to writing data on a connection */ //@{ -#if !defined(LWS_SIZEOFPTR) -#define LWS_SIZEOFPTR ((int)sizeof (void *)) -#endif - -#if defined(__x86_64__) -#define _LWS_PAD_SIZE 16 /* Intel recommended for best performance */ -#else -#define _LWS_PAD_SIZE LWS_SIZEOFPTR /* Size of a pointer on the target arch */ -#endif -#define _LWS_PAD(n) (((n) % _LWS_PAD_SIZE) ? \ - ((n) + (_LWS_PAD_SIZE - ((n) % _LWS_PAD_SIZE))) : (n)) -/* last 2 is for lws-meta */ -#define LWS_PRE _LWS_PAD(4 + 10 + 2) -/* used prior to 1.7 and retained for backward compatibility */ -#define LWS_SEND_BUFFER_PRE_PADDING LWS_PRE -#define LWS_SEND_BUFFER_POST_PADDING 0 - #define LWS_WRITE_RAW LWS_WRITE_HTTP /* diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 88f14fa19..da64e4af3 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -74,13 +74,17 @@ if (LWS_PLAT_FREERTOS) endif() else() - if (LWS_PLAT_OPTEE) - add_subdir_include_dirs(plat/optee) + if (LWS_PLAT_BAREMETAL) + add_subdir_include_dirs(plat/baremetal) else() - if (WIN32) - add_subdir_include_dirs(plat/windows) + if (LWS_PLAT_OPTEE) + add_subdir_include_dirs(plat/optee) else() - add_subdir_include_dirs(plat/unix) + if (WIN32) + add_subdir_include_dirs(plat/windows) + else() + add_subdir_include_dirs(plat/unix) + endif() endif() endif() endif() diff --git a/lib/core/context.c b/lib/core/context.c index ab6afa382..0656581f2 100644 --- a/lib/core/context.c +++ b/lib/core/context.c @@ -403,8 +403,9 @@ lws_create_context(const struct lws_context_creation_info *info) #endif size = sizeof(struct lws_context); #endif - +#if !defined(LWS_PLAT_BAREMETAL) int n; +#endif unsigned int lpf = info->fd_limit_per_thread; #if defined(LWS_WITH_EVLIB_PLUGINS) && defined(LWS_WITH_EVENT_LIBS) struct lws_plugin *evlib_plugin_list = NULL; @@ -921,7 +922,7 @@ lws_create_context(const struct lws_context_creation_info *info) context->options = info->options; -#if !defined(LWS_PLAT_FREERTOS) && !defined(LWS_PLAT_OPTEE) && !defined(WIN32) +#if !defined(LWS_PLAT_FREERTOS) && !defined(LWS_PLAT_OPTEE) && !defined(WIN32) && !defined(LWS_PLAT_BAREMETAL) /* * If asked, try to set the rlimit / ulimit for process sockets / files. * We read the effective limit in a moment, so we will find out the @@ -1072,7 +1073,9 @@ lws_create_context(const struct lws_context_creation_info *info) } #endif +#if !defined(LWS_PLAT_BAREMETAL) n = 0; +#endif #if defined(LWS_WITH_NETWORK) context->default_retry.retry_ms_table = default_backoff_table; diff --git a/lib/core/libwebsockets.c b/lib/core/libwebsockets.c index 1c66e8b80..713066f8b 100644 --- a/lib/core/libwebsockets.c +++ b/lib/core/libwebsockets.c @@ -195,7 +195,7 @@ lws_hex_random(struct lws_context *context, char *dest, size_t len) return 0; } -#if !defined(LWS_PLAT_OPTEE) +#if !defined(LWS_PLAT_OPTEE) && !defined(LWS_PLAT_BAREMETAL) #if defined(LWS_WITH_FILE_OPS) int lws_open(const char *__file, int __oflag, ...) diff --git a/lib/core/logs.c b/lib/core/logs.c index 377dcb08a..9e3ea0ff6 100644 --- a/lib/core/logs.c +++ b/lib/core/logs.c @@ -302,7 +302,7 @@ lwsl_emit_stderr_notimestamp(int level, const char *line) _lwsl_emit_stderr(level, line); } -#if !defined(LWS_PLAT_FREERTOS) && !defined(LWS_PLAT_OPTEE) +#if !defined(LWS_PLAT_FREERTOS) && !defined(LWS_PLAT_OPTEE) && !defined(LWS_PLAT_BAREMETAL) /* * Helper to emit to a file diff --git a/lib/core/private-lib-core.h b/lib/core/private-lib-core.h index c867ebacd..07c29c499 100644 --- a/lib/core/private-lib-core.h +++ b/lib/core/private-lib-core.h @@ -40,6 +40,16 @@ #endif */ +#ifdef LWS_HAVE_SYS_TYPES_H +#include +#endif +#if !defined(PICO_SDK_PATH) +#ifdef LWS_HAVE_INTTYPES_H +#include +#endif +#endif + +//#include #include #include #include @@ -49,15 +59,8 @@ #include #include -#ifdef LWS_HAVE_INTTYPES_H -#include -#endif - #include -#ifdef LWS_HAVE_SYS_TYPES_H - #include -#endif #if defined(LWS_HAVE_SYS_STAT_H) && !defined(LWS_PLAT_OPTEE) #include #endif @@ -117,16 +120,19 @@ * */ -#if defined(LWS_PLAT_FREERTOS) - #include "private-lib-plat-freertos.h" +#if defined(LWS_PLAT_BAREMETAL) #else - #if defined(WIN32) || defined(_WIN32) - #include "private-lib-plat-windows.h" + #if defined(LWS_PLAT_FREERTOS) + #include "private-lib-plat-freertos.h" #else - #if defined(LWS_PLAT_OPTEE) - #include "private-lib-plat.h" + #if defined(WIN32) || defined(_WIN32) + #include "private-lib-plat-windows.h" #else - #include "private-lib-plat-unix.h" + #if defined(LWS_PLAT_OPTEE) + #include "private-lib-plat.h" + #else + #include "private-lib-plat-unix.h" + #endif #endif #endif #endif @@ -311,10 +317,14 @@ struct lws_ring { struct lws_protocols; struct lws; +#if defined(LWS_WITH_SECURE_STREAMS_PROXY_API) +#include "private-lib-secure-streams.h" +#endif + #if defined(LWS_WITH_NETWORK) /* network */ #include "private-lib-event-libs.h" -#if defined(LWS_WITH_SECURE_STREAMS) +#if defined(LWS_WITH_SECURE_STREAMS) || defined(LWS_WITH_SECURE_STREAMS_PROXY_API) #include "private-lib-secure-streams.h" #endif diff --git a/lib/misc/CMakeLists.txt b/lib/misc/CMakeLists.txt index 337367aae..a305381e9 100644 --- a/lib/misc/CMakeLists.txt +++ b/lib/misc/CMakeLists.txt @@ -76,7 +76,7 @@ if (LWS_WITH_FSMOUNT AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") list(APPEND SOURCES misc/fsmount.c) endif() -if (LWS_WITH_DIR) +if (LWS_WITH_DIR AND NOT LWS_PLAT_BAREMETAL) list(APPEND SOURCES misc/dir.c) endif() @@ -92,7 +92,7 @@ endif() if (LWS_WITH_LWSAC) list(APPEND SOURCES misc/lwsac/lwsac.c) - if (NOT LWS_PLAT_FREERTOS) + if (NOT LWS_PLAT_FREERTOS AND NOT LWS_PLAT_BAREMETAL) list(APPEND SOURCES misc/lwsac/cached-file.c) endif() diff --git a/lib/secure-streams/private-lib-secure-streams.h b/lib/secure-streams/private-lib-secure-streams.h index ebfa7efa0..9c0ac5351 100644 --- a/lib/secure-streams/private-lib-secure-streams.h +++ b/lib/secure-streams/private-lib-secure-streams.h @@ -22,6 +22,9 @@ * IN THE SOFTWARE. */ +#if !defined(__LWS_PRIVATE_SS_H__) +#define __LWS_PRIVATE_SS_H__ + /* current SS Serialization protocol version */ #define LWS_SSS_CLIENT_PROTOCOL_VERSION 1 @@ -560,14 +563,18 @@ lws_ss_assert_extant(struct lws_context *cx, int tsi, struct lws_ss_handle *h); #define lws_ss_assert_extant(_a, _b, _c) #endif +#if defined(LWS_WITH_SECURE_STREAMS) typedef int (* const secstream_protocol_connect_munge_t)(lws_ss_handle_t *h, char *buf, size_t len, struct lws_client_connect_info *i, union lws_ss_contemp *ct); +#endif typedef int (* const secstream_protocol_add_txcr_t)(lws_ss_handle_t *h, int add); typedef int (* const secstream_protocol_get_txcr_t)(lws_ss_handle_t *h); +#if defined(LWS_WITH_SECURE_STREAMS) + struct ss_pcols { const char *name; const char *alpn; @@ -576,6 +583,7 @@ struct ss_pcols { secstream_protocol_add_txcr_t tx_cr_add; secstream_protocol_get_txcr_t tx_cr_est; }; +#endif /* * Because both sides of the connection share the conn, we allocate it