aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwangyingdong <wangyingdong@xiaomi.com>2023-09-19 15:58:38 +0800
committerAndy Green <andy@warmcat.com>2023-09-21 13:08:16 +0100
commit07778789f4af037721174cfbe1f336dbb059e6c7 (patch)
treea602e85df4b7ab28e79bc798d4de16cfe18580c4
parenta6a7fa646e9c04f1322dbaae611f17529439d157 (diff)
downloadlibwebsockets-07778789f4af037721174cfbe1f336dbb059e6c7.tar.gz
Introducing libwebsockets support for nuttx
Signed-off-by: wangyingdong <wangyingdong@xiaomi.com>
-rw-r--r--include/libwebsockets.h2
-rw-r--r--lib/plat/unix/private-lib-plat-unix.h2
-rw-r--r--lib/plat/unix/unix-sockets.c9
-rw-r--r--lib/roles/ws/client-ws.c8
-rw-r--r--lib/secure-streams/system/auth-sigv4/sign.c2
5 files changed, 14 insertions, 9 deletions
diff --git a/include/libwebsockets.h b/include/libwebsockets.h
index 87ff2808..05ede8de 100644
--- a/include/libwebsockets.h
+++ b/include/libwebsockets.h
@@ -146,7 +146,7 @@ typedef int suseconds_t;
#include <sys/capability.h>
#endif
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__QNX__) || defined(__OpenBSD__)
+#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__QNX__) || defined(__OpenBSD__) || defined(__NuttX__)
#include <sys/socket.h>
#include <netinet/in.h>
#endif
diff --git a/lib/plat/unix/private-lib-plat-unix.h b/lib/plat/unix/private-lib-plat-unix.h
index 1aa9e807..7f84e6cb 100644
--- a/lib/plat/unix/private-lib-plat-unix.h
+++ b/lib/plat/unix/private-lib-plat-unix.h
@@ -123,7 +123,7 @@ typedef pthread_mutex_t lws_mutex_t;
#endif
-#if defined (__sun) || defined(__HAIKU__) || defined(__QNX__) || defined(__ANDROID__)
+#if defined (__sun) || defined(__HAIKU__) || defined(__QNX__) || defined(__ANDROID__) || defined(__NuttX__)
#include <syslog.h>
#if defined(__ANDROID__)
diff --git a/lib/plat/unix/unix-sockets.c b/lib/plat/unix/unix-sockets.c
index 47ad6a85..2a3069b5 100644
--- a/lib/plat/unix/unix-sockets.c
+++ b/lib/plat/unix/unix-sockets.c
@@ -171,7 +171,7 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, int fd, int unix_skt)
/* Disable Nagle */
optval = 1;
-#if defined (__sun) || defined(__QNX__)
+#if defined (__sun) || defined(__QNX__) || defined(__NuttX__)
if (!unix_skt && setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (const void *)&optval, optlen) < 0)
return 1;
#elif !defined(__APPLE__) && \
@@ -190,6 +190,7 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, int fd, int unix_skt)
return lws_plat_set_nonblocking(fd);
}
+#if !defined(__NuttX__)
static const int ip_opt_lws_flags[] = {
LCCSCF_IP_LOW_LATENCY, LCCSCF_IP_HIGH_THROUGHPUT,
LCCSCF_IP_HIGH_RELIABILITY
@@ -210,6 +211,7 @@ static const char *ip_opt_names[] = {
#endif
};
#endif
+#endif
int
lws_plat_set_socket_options_ip(lws_sockfd_type fd, uint8_t pri, int lws_flags)
@@ -237,7 +239,8 @@ lws_plat_set_socket_options_ip(lws_sockfd_type fd, uint8_t pri, int lws_flags)
!defined(__sun) && \
!defined(__HAIKU__) && \
!defined(__CYGWIN__) && \
- !defined(__QNX__)
+ !defined(__QNX__) && \
+ !defined(__NuttX__)
/* the BSDs don't have SO_PRIORITY */
@@ -270,6 +273,7 @@ lws_plat_set_socket_options_ip(lws_sockfd_type fd, uint8_t pri, int lws_flags)
}
+#if !defined(__NuttX__)
for (n = 0; n < 4; n++) {
if (!(lws_flags & ip_opt_lws_flags[n]))
continue;
@@ -287,6 +291,7 @@ lws_plat_set_socket_options_ip(lws_sockfd_type fd, uint8_t pri, int lws_flags)
lwsl_notice("%s: set ip flag %s\n", __func__,
ip_opt_names[n]);
}
+#endif
return ret;
}
diff --git a/lib/roles/ws/client-ws.c b/lib/roles/ws/client-ws.c
index bc2a8468..750aea96 100644
--- a/lib/roles/ws/client-ws.c
+++ b/lib/roles/ws/client-ws.c
@@ -257,15 +257,15 @@ lws_client_ws_upgrade(struct lws *wsi, const char **cce)
}
if (wsi->http.ah->http_response == 401) {
- lwsl_wsi_warn(wsi, "got bad HTTP response '%d'",
- wsi->http.ah->http_response);
+ lwsl_wsi_warn(wsi, "got bad HTTP response '%ld'",
+ (long)wsi->http.ah->http_response);
*cce = "HS: ws upgrade unauthorized";
goto bail3;
}
if (wsi->http.ah->http_response != 101) {
- lwsl_wsi_warn(wsi, "got bad HTTP response '%d'",
- wsi->http.ah->http_response);
+ lwsl_wsi_warn(wsi, "got bad HTTP response '%ld'",
+ (long)wsi->http.ah->http_response);
*cce = "HS: ws upgrade response not 101";
goto bail3;
}
diff --git a/lib/secure-streams/system/auth-sigv4/sign.c b/lib/secure-streams/system/auth-sigv4/sign.c
index 93f96db5..b797e157 100644
--- a/lib/secure-streams/system/auth-sigv4/sign.c
+++ b/lib/secure-streams/system/auth-sigv4/sign.c
@@ -464,7 +464,7 @@ lws_ss_sigv4_set_aws_key(struct lws_context* context, uint8_t idx,
#if defined(__linux__) || defined(__APPLE__) || defined(WIN32) || \
defined(__FreeBSD__) || defined(__NetBSD__) || defined(__ANDROID__) || \
- defined(__sun) || defined(__OpenBSD__)
+ defined(__sun) || defined(__OpenBSD__) || defined(__NuttX__)
/* ie, if we have filesystem ops */