From 7ba75e760ea38d3fdc83749b1d48f2a10cf8c161 Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Thu, 30 Dec 2021 13:19:03 +0530 Subject: [PATCH] Add nghttp2 - HTTP/2 C Library component --- .gitmodules | 3 ++ nghttp/CMakeLists.txt | 29 ++++++++++++++++ nghttp/LICENSE | 1 + nghttp/README.md | 1 + nghttp/idf_component.yml | 5 +++ nghttp/nghttp2 | 1 + nghttp/port/include/nghttp2/nghttp2ver.h | 42 ++++++++++++++++++++++++ nghttp/port/private_include/config.h | 29 ++++++++++++++++ 8 files changed, 111 insertions(+) create mode 100644 nghttp/CMakeLists.txt create mode 120000 nghttp/LICENSE create mode 120000 nghttp/README.md create mode 100644 nghttp/idf_component.yml create mode 160000 nghttp/nghttp2 create mode 100644 nghttp/port/include/nghttp2/nghttp2ver.h create mode 100644 nghttp/port/private_include/config.h diff --git a/.gitmodules b/.gitmodules index 082cd43..d231c21 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "cbor/tinycbor"] path = cbor/tinycbor url = https://github.com/intel/tinycbor.git +[submodule "nghttp/nghttp2"] + path = nghttp/nghttp2 + url = https://github.com/nghttp2/nghttp2.git diff --git a/nghttp/CMakeLists.txt b/nghttp/CMakeLists.txt new file mode 100644 index 0000000..25d013a --- /dev/null +++ b/nghttp/CMakeLists.txt @@ -0,0 +1,29 @@ +set(srcs + "nghttp2/lib/nghttp2_buf.c" + "nghttp2/lib/nghttp2_callbacks.c" + "nghttp2/lib/nghttp2_debug.c" + "nghttp2/lib/nghttp2_frame.c" + "nghttp2/lib/nghttp2_hd.c" + "nghttp2/lib/nghttp2_hd_huffman.c" + "nghttp2/lib/nghttp2_hd_huffman_data.c" + "nghttp2/lib/nghttp2_helper.c" + "nghttp2/lib/nghttp2_http.c" + "nghttp2/lib/nghttp2_map.c" + "nghttp2/lib/nghttp2_mem.c" + "nghttp2/lib/nghttp2_npn.c" + "nghttp2/lib/nghttp2_option.c" + "nghttp2/lib/nghttp2_outbound_item.c" + "nghttp2/lib/nghttp2_pq.c" + "nghttp2/lib/nghttp2_priority_spec.c" + "nghttp2/lib/nghttp2_queue.c" + "nghttp2/lib/nghttp2_rcbuf.c" + "nghttp2/lib/nghttp2_session.c" + "nghttp2/lib/nghttp2_stream.c" + "nghttp2/lib/nghttp2_submit.c" + "nghttp2/lib/nghttp2_version.c") + +idf_component_register(SRCS "${srcs}" + INCLUDE_DIRS port/include nghttp2/lib/includes + PRIV_INCLUDE_DIRS port/private_include) + +target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DHAVE_CONFIG_H") diff --git a/nghttp/LICENSE b/nghttp/LICENSE new file mode 120000 index 0000000..724a187 --- /dev/null +++ b/nghttp/LICENSE @@ -0,0 +1 @@ +nghttp2/COPYING \ No newline at end of file diff --git a/nghttp/README.md b/nghttp/README.md new file mode 120000 index 0000000..9d76154 --- /dev/null +++ b/nghttp/README.md @@ -0,0 +1 @@ +nghttp2/README.rst \ No newline at end of file diff --git a/nghttp/idf_component.yml b/nghttp/idf_component.yml new file mode 100644 index 0000000..104aae9 --- /dev/null +++ b/nghttp/idf_component.yml @@ -0,0 +1,5 @@ +version: "1.41.0" +description: "nghttp2 - HTTP/2 C Library" +url: https://github.com/espressif/idf-extra-components/tree/master/nghttp +dependencies: + idf: ">=5.0" diff --git a/nghttp/nghttp2 b/nghttp/nghttp2 new file mode 160000 index 0000000..8f7b008 --- /dev/null +++ b/nghttp/nghttp2 @@ -0,0 +1 @@ +Subproject commit 8f7b008b158e12de0e58247afd170f127dbb6456 diff --git a/nghttp/port/include/nghttp2/nghttp2ver.h b/nghttp/port/include/nghttp2/nghttp2ver.h new file mode 100644 index 0000000..ccbbfb3 --- /dev/null +++ b/nghttp/port/include/nghttp2/nghttp2ver.h @@ -0,0 +1,42 @@ +/* + * nghttp2 - HTTP/2 C Library + * + * Copyright (c) 2012, 2013 Tatsuhiro Tsujikawa + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef NGHTTP2VER_H +#define NGHTTP2VER_H + +/** + * @macro + * Version number of the nghttp2 library release + */ +#define NGHTTP2_VERSION "v1.22.0" + +/** + * @macro + * Numerical representation of the version number of the nghttp2 library + * release. This is a 24 bit number with 8 bits for major number, 8 bits + * for minor and 8 bits for patch. Version 1.2.3 becomes 0x010203. + */ +#define NGHTTP2_VERSION_NUM 0x012200 + +#endif /* NGHTTP2VER_H */ diff --git a/nghttp/port/private_include/config.h b/nghttp/port/private_include/config.h new file mode 100644 index 0000000..0aeefdc --- /dev/null +++ b/nghttp/port/private_include/config.h @@ -0,0 +1,29 @@ +#ifndef __HAVE_CONFIG_H_ +#define __HAVE_CONFIG_H_ + +#define _U_ + +#define SIZEOF_INT_P 2 + +#include "stdio.h" +#include "stdlib.h" +#include "string.h" + +#if (!defined(nghttp_unlikely)) +#define nghttp_unlikely(Expression) !!(Expression) +#endif + +#define nghttp_ASSERT(Expression) do{if (!(Expression)) printf("%d\n", __LINE__);}while(0) + +#define CU_ASSERT(a) nghttp_ASSERT(a) +#define CU_ASSERT_FATAL(a) nghttp_ASSERT(a) + +#define NGHTTP_PLATFORM_HTONS(_n) ((uint16_t)((((_n) & 0xff) << 8) | (((_n) >> 8) & 0xff))) +#define NGHTTP_PLATFORM_HTONL(_n) ((uint32_t)( (((_n) & 0xff) << 24) | (((_n) & 0xff00) << 8) | (((_n) >> 8) & 0xff00) | (((_n) >> 24) & 0xff) )) + +#define htons(x) NGHTTP_PLATFORM_HTONS(x) +#define ntohs(x) NGHTTP_PLATFORM_HTONS(x) +#define htonl(x) NGHTTP_PLATFORM_HTONL(x) +#define ntohl(x) NGHTTP_PLATFORM_HTONL(x) + +#endif // __HAVE_CONFIG_H_