This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new ac81bebc0 netutils: introduce QUIC support through ngtcp2 library
ac81bebc0 is described below

commit ac81bebc089922e666c10d66b5dd59ab3944ed0b
Author: Andrei Gorneanu <[email protected]>
AuthorDate: Mon Nov 2 15:39:52 2026 +0200

    netutils: introduce QUIC support through ngtcp2 library
    
    This commit is adding support for ngtcp2, a QUIC implementation
    following the RFC9000. In order to benefit from the existing
    wolfssl crypto backend, the library build process was adapted
    to include QUIC support when the ngtcp2 flag is enabled.
    
    [skip-cmake-parity] - no CMake file implemented for wolfssl
    
    Signed-off-by: Andrei Gorneanu <[email protected]>
---
 crypto/wolfssl/Makefile        |  16 +++++-
 crypto/wolfssl/user_settings.h |  28 +++++++++-
 netutils/ngtcp2/.gitignore     |   1 +
 netutils/ngtcp2/CMakeLists.txt | 115 +++++++++++++++++++++++++++++++++++++++++
 netutils/ngtcp2/Kconfig        |  20 +++++++
 netutils/ngtcp2/Make.defs      |  26 ++++++++++
 netutils/ngtcp2/Makefile       | 114 ++++++++++++++++++++++++++++++++++++++++
 7 files changed, 317 insertions(+), 3 deletions(-)

diff --git a/crypto/wolfssl/Makefile b/crypto/wolfssl/Makefile
index 90b0f6390..185570851 100644
--- a/crypto/wolfssl/Makefile
+++ b/crypto/wolfssl/Makefile
@@ -108,6 +108,15 @@ CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/wc_port.c
 CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/wolfevent.c
 CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/wolfmath.c
 
+# QUIC support
+ifeq ($(CONFIG_NETUTILS_NGTCP2),y)
+
+CFLAGS += -DNETUTILS_NGTCP2
+CSRCS += $(WOLFSSL_UNPACKNAME)/src/quic.c
+CSRCS += $(WOLFSSL_UNPACKNAME)/wolfcrypt/src/evp.c
+
+endif
+
 CFLAGS += -DWOLFSSL_USER_SETTINGS
 
 ifneq ($(CONFIG_WOLFCRYPT_APPS),)
@@ -154,11 +163,14 @@ endif
 
 ifeq ($(CONFIG_WOLFSSL_APP_CLIENT_SERVER),y)
 wolfssl:
-       git clone [email protected]:wolfSSL/wolfssl.git $(WOLFSSL_UNPACKNAME)
+       git clone --depth 1 -b v$(WOLFSSL_VERSION)-stable 
[email protected]:wolfSSL/wolfssl.git $(WOLFSSL_UNPACKNAME)
        git clone [email protected]:wolfSSL/wolfssl-examples.git 
$(WOLFSSL_EXAMPLESNAME)
 else
 wolfssl:
-       git clone [email protected]:wolfSSL/wolfssl.git $(WOLFSSL_UNPACKNAME)
+       git clone --depth 1 -b v$(WOLFSSL_VERSION)-stable 
[email protected]:wolfSSL/wolfssl.git $(WOLFSSL_UNPACKNAME)
+ifeq ($(CONFIG_NETUTILS_NGTCP2),y)
+       touch $(WOLFSSL_UNPACKNAME)/wolfssl/options.h
+endif
 endif
 
 context:: wolfssl
diff --git a/crypto/wolfssl/user_settings.h b/crypto/wolfssl/user_settings.h
index 66427efdd..db8d24a12 100644
--- a/crypto/wolfssl/user_settings.h
+++ b/crypto/wolfssl/user_settings.h
@@ -19,6 +19,10 @@
  * under the License.
  ****************************************************************************/
 
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
 #include <nuttx/config.h>
 
 /* Library */
@@ -50,7 +54,8 @@
 #define WOLFSSL_BENCHMARK_FIXED_UNITS_MB
 
 /* Development */
-/*#define DEBUG_WOLFSSL*/
+
+/* #define DEBUG_WOLFSSL */
 
 #define HAVE_TLS_EXTENSIONS
 #define HAVE_SUPPORTED_CURVES
@@ -72,3 +77,24 @@
 #define HAVE_CHACHA
 #define HAVE_ENCRYPT_THEN_MAC
 #define NO_OLD_TLS
+
+#ifdef NETUTILS_NGTCP2
+    #define OPENSSL_ALL
+    #define OPENSSL_EXTRA
+    #define WOLFSSL_QUIC
+    #define WOLFSSL_OPTIONS_H
+
+    #define HAVE_ALPN
+    #define HAVE_CURVE25519
+    #define HAVE_LIMITS_H
+    #define HAVE_SESSION_TICKET
+    #define HAVE_SNI
+    #define WOLFSSL_AES_COUNTER
+    #define WOLFSSL_AES_DIRECT
+    #define WOLFSSL_AES_128
+    #define WOLFSSL_AES_256
+    #define WOLFSSL_EARLY_DATA
+
+    #define NO_INT128
+    #undef HAVE___UINT128_T
+#endif
diff --git a/netutils/ngtcp2/.gitignore b/netutils/ngtcp2/.gitignore
new file mode 100644
index 000000000..df5b26944
--- /dev/null
+++ b/netutils/ngtcp2/.gitignore
@@ -0,0 +1 @@
+/ngtcp2*
diff --git a/netutils/ngtcp2/CMakeLists.txt b/netutils/ngtcp2/CMakeLists.txt
new file mode 100644
index 000000000..bd6ef77f5
--- /dev/null
+++ b/netutils/ngtcp2/CMakeLists.txt
@@ -0,0 +1,115 @@
+# 
##############################################################################
+# apps/netutils/ngtcp2/CMakeLists.txt
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+# license agreements.  See the NOTICE file distributed with this work for
+# additional information regarding copyright ownership.  The ASF licenses this
+# file to you under the Apache License, Version 2.0 (the "License"); you may 
not
+# use this file except in compliance with the License.  You may obtain a copy 
of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+# 
##############################################################################
+
+if(CONFIG_NETUTILS_NGTCP2)
+  set(NGTCP2_DIR ${CMAKE_CURRENT_LIST_DIR}/ngtcp2)
+  set(NGTCP2_VERSION ${CONFIG_NETUTILS_NGTCP2_VERSION})
+
+  if(NOT EXISTS ${NGTCP2_DIR})
+    set(NGTCP2_URL https://github.com/ngtcp2/ngtcp2/releases/download)
+    FetchContent_Declare(
+      ngtcp2_fetch
+      URL ${NGTCP2_URL}/v${NGTCP2_VERSION}/ngtcp2-${NGTCP2_VERSION}.tar.bz2
+          SOURCE_DIR ${NGTCP2_DIR} BINARY_DIR
+          ${CMAKE_BINARY_DIR}/apps/netutils/ngtcp2
+      DOWNLOAD_NO_PROGRESS true
+      TIMEOUT 30)
+
+    FetchContent_GetProperties(ngtcp2_fetch)
+
+    if(NOT ngtcp2_fetch_POPULATED)
+      FetchContent_Populate(ngtcp2_fetch)
+    endif()
+  endif()
+
+  set(NGTCP2_INCDIR
+      ${CMAKE_CURRENT_LIST_DIR}
+      ${NGTCP2_DIR}/lib
+      ${NGTCP2_DIR}/lib/includes
+      ${NGTCP2_DIR}/crypto
+      ${NGTCP2_DIR}/crypto/includes
+      ${NUTTX_APPS_DIR}/crypto/wolfssl
+      ${NUTTX_APPS_DIR}/crypto/wolfssl/wolfssl
+      ${NUTTX_APPS_DIR}/crypto/wolfssl/openssl)
+
+  set(NGTCP2_FLAGS
+      -Wno-undef
+      -DNO_INT128
+      -DHAVE_WOLFSSL
+      -DBUILDING_NGTCP2
+      -DWOLFSSL_QUIC
+      -DOPENSSL_EXTRA
+      -DHAVE_AESGCM
+      -DHAVE_SESSION_TICKET)
+
+  target_include_directories(apps PUBLIC ${NGTCP2_INCDIR})
+  target_compile_options(apps PRIVATE ${NGTCP2_FLAGS})
+  target_sources(
+    apps
+    PRIVATE ${NGTCP2_DIR}/lib/ngtcp2_pkt.c
+            ${NGTCP2_DIR}/lib/ngtcp2_conv.c
+            ${NGTCP2_DIR}/lib/ngtcp2_str.c
+            ${NGTCP2_DIR}/lib/ngtcp2_vec.c
+            ${NGTCP2_DIR}/lib/ngtcp2_buf.c
+            ${NGTCP2_DIR}/lib/ngtcp2_conn.c
+            ${NGTCP2_DIR}/lib/ngtcp2_mem.c
+            ${NGTCP2_DIR}/lib/ngtcp2_pq.c
+            ${NGTCP2_DIR}/lib/ngtcp2_map.c
+            ${NGTCP2_DIR}/lib/ngtcp2_rob.c
+            ${NGTCP2_DIR}/lib/ngtcp2_ppe.c
+            ${NGTCP2_DIR}/lib/ngtcp2_crypto.c
+            ${NGTCP2_DIR}/lib/ngtcp2_err.c
+            ${NGTCP2_DIR}/lib/ngtcp2_range.c
+            ${NGTCP2_DIR}/lib/ngtcp2_acktr.c
+            ${NGTCP2_DIR}/lib/ngtcp2_rtb.c
+            ${NGTCP2_DIR}/lib/ngtcp2_frame_chain.c
+            ${NGTCP2_DIR}/lib/ngtcp2_strm.c
+            ${NGTCP2_DIR}/lib/ngtcp2_idtr.c
+            ${NGTCP2_DIR}/lib/ngtcp2_gaptr.c
+            ${NGTCP2_DIR}/lib/ngtcp2_ringbuf.c
+            ${NGTCP2_DIR}/lib/ngtcp2_log.c
+            ${NGTCP2_DIR}/lib/ngtcp2_qlog.c
+            ${NGTCP2_DIR}/lib/ngtcp2_cid.c
+            ${NGTCP2_DIR}/lib/ngtcp2_ksl.c
+            ${NGTCP2_DIR}/lib/ngtcp2_cc.c
+            ${NGTCP2_DIR}/lib/ngtcp2_bbr.c
+            ${NGTCP2_DIR}/lib/ngtcp2_addr.c
+            ${NGTCP2_DIR}/lib/ngtcp2_path.c
+            ${NGTCP2_DIR}/lib/ngtcp2_pv.c
+            ${NGTCP2_DIR}/lib/ngtcp2_pmtud.c
+            ${NGTCP2_DIR}/lib/ngtcp2_version.c
+            ${NGTCP2_DIR}/lib/ngtcp2_rst.c
+            ${NGTCP2_DIR}/lib/ngtcp2_window_filter.c
+            ${NGTCP2_DIR}/lib/ngtcp2_opl.c
+            ${NGTCP2_DIR}/lib/ngtcp2_balloc.c
+            ${NGTCP2_DIR}/lib/ngtcp2_objalloc.c
+            ${NGTCP2_DIR}/lib/ngtcp2_unreachable.c
+            ${NGTCP2_DIR}/lib/ngtcp2_transport_params.c
+            ${NGTCP2_DIR}/lib/ngtcp2_settings.c
+            ${NGTCP2_DIR}/lib/ngtcp2_callbacks.c
+            ${NGTCP2_DIR}/lib/ngtcp2_dcidtr.c
+            ${NGTCP2_DIR}/lib/ngtcp2_pcg.c
+            ${NGTCP2_DIR}/lib/ngtcp2_ratelim.c
+            ${NGTCP2_DIR}/lib/ngtcp2_conn_info.c
+            ${NGTCP2_DIR}/crypto/shared.c
+            ${NGTCP2_DIR}/crypto/wolfssl/wolfssl.c)
+endif()
diff --git a/netutils/ngtcp2/Kconfig b/netutils/ngtcp2/Kconfig
new file mode 100644
index 000000000..602775df8
--- /dev/null
+++ b/netutils/ngtcp2/Kconfig
@@ -0,0 +1,20 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+config NETUTILS_NGTCP2
+       bool "QUIC - ngtcp2 library"
+       default n
+       depends on CRYPTO_WOLFSSL
+       depends on LIBUV
+       ---help---
+               ngtcp2 is a C implementation of QUIC protocol based on RFC9000.
+
+if NETUTILS_NGTCP2
+
+config NETUTILS_NGTCP2_VERSION
+       string "QUIC - ngtcp2 version"
+       default "1.21.0"
+
+endif # NETUTILS_NGTCP2
diff --git a/netutils/ngtcp2/Make.defs b/netutils/ngtcp2/Make.defs
new file mode 100644
index 000000000..715324d5c
--- /dev/null
+++ b/netutils/ngtcp2/Make.defs
@@ -0,0 +1,26 @@
+############################################################################
+# apps/netutils/ngtcp2/Make.defs
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+ifneq ($(CONFIG_NETUTILS_NGTCP2),)
+CONFIGURED_APPS += $(APPDIR)/netutils/ngtcp2
+CFLAGS += 
${INCDIR_PREFIX}$(APPDIR)$(DELIM)netutils$(DELIM)ngtcp2$(DELIM)ngtcp2$(DELIM)include
+endif
diff --git a/netutils/ngtcp2/Makefile b/netutils/ngtcp2/Makefile
new file mode 100644
index 000000000..bf5518709
--- /dev/null
+++ b/netutils/ngtcp2/Makefile
@@ -0,0 +1,114 @@
+# 
##############################################################################
+# apps/netutils/ngtcp2/Makefile
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+# license agreements.  See the NOTICE file distributed with this work for
+# additional information regarding copyright ownership.  The ASF licenses this
+# file to you under the Apache License, Version 2.0 (the "License"); you may 
not
+# use this file except in compliance with the License.  You may obtain a copy 
of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+# 
##############################################################################
+
+include $(APPDIR)/Make.defs
+
+NGTCP2_UNPACKNAME = ngtcp2
+NGTCP2_VERSION = $(patsubst "%",%,$(strip $(CONFIG_NETUTILS_NGTCP2_VERSION)))
+
+# ngtcp2 library
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_pkt.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_conv.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_str.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_vec.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_buf.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_conn.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_mem.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_pq.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_map.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_rob.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_ppe.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_crypto.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_err.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_range.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_acktr.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_rtb.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_frame_chain.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_strm.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_idtr.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_gaptr.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_ringbuf.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_log.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_qlog.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_cid.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_ksl.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_cc.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_bbr.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_addr.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_path.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_pv.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_pmtud.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_version.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_rst.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_window_filter.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_opl.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_balloc.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_objalloc.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_unreachable.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_transport_params.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_settings.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_callbacks.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_dcidtr.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_pcg.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_ratelim.c
+CSRCS += $(NGTCP2_UNPACKNAME)/lib/ngtcp2_conn_info.c
+
+# ngtcp2 crypto layer
+CSRCS += $(NGTCP2_UNPACKNAME)/crypto/shared.c
+CSRCS += $(NGTCP2_UNPACKNAME)/crypto/wolfssl/wolfssl.c
+
+# ngtcp2 specific includes
+CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/netutils/ngtcp2
+CFLAGS += ${INCDIR_PREFIX}$(NGTCP2_UNPACKNAME)/lib
+CFLAGS += ${INCDIR_PREFIX}$(NGTCP2_UNPACKNAME)/lib/includes
+CFLAGS += ${INCDIR_PREFIX}$(NGTCP2_UNPACKNAME)/crypto
+CFLAGS += ${INCDIR_PREFIX}$(NGTCP2_UNPACKNAME)/crypto/includes
+
+# wolfssl specific includes
+CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/crypto/wolfssl
+CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/crypto/wolfssl/wolfssl
+CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/crypto/wolfssl/openssl
+
+CFLAGS += -Wno-undef
+CFLAGS += -DNO_INT128 -DHAVE_WOLFSSL -DBUILDING_NGTCP2 -DWOLFSSL_QUIC 
-DOPENSSL_EXTRA -DHAVE_AESGCM -DHAVE_SESSION_TICKET
+
+NGTCP2_URL ?= "https://github.com/ngtcp2/ngtcp2/releases/download";
+NGTCP2_TAR = ngtcp2-$(NGTCP2_VERSION).tar.bz2
+
+UNPACK ?= tar -xf
+
+$(NGTCP2_TAR):
+       @echo "Downloading: $(NGTCP2_URL)/v$(NGTCP2_VERSION)/$(NGTCP2_TAR)"
+       $(Q) curl -o $(NGTCP2_TAR) -L 
$(NGTCP2_URL)/v$(NGTCP2_VERSION)/$(NGTCP2_TAR)
+
+$(NGTCP2_UNPACKNAME): $(NGTCP2_TAR)
+       @echo "Unpacking: $(NGTCP2_TAR) -> $(NGTCP2_UNPACKNAME)"
+       $(Q) $(UNPACK) $(NGTCP2_TAR)
+       $(Q) mv ngtcp2-$(NGTCP2_VERSION) $(NGTCP2_UNPACKNAME)
+       
+distclean::
+       $(call DELDIR, $(NGTCP2_UNPACKNAME))
+       $(call DELFILE, $(NGTCP2_TAR))
+
+context:: $(NGTCP2_UNPACKNAME)
+
+include $(APPDIR)/Application.mk

Reply via email to