diff --git a/thirdparty/libpcap/HPKBUILD b/thirdparty/libpcap/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..1e53a8b81b4e0b34c0077b7cf5b396b332926f93 --- /dev/null +++ b/thirdparty/libpcap/HPKBUILD @@ -0,0 +1,68 @@ +# Contributor: liulihong +# Maintainer: liulihong + +pkgname=libpcap +pkgver=libpcap-1.10.3 +pkgrel=0 +pkgdesc="" +url="" +archs=("armeabi-v7a" "arm64-v8a") +license=("BSD") +depends=() +makedepends=() +install= +source="https://github.com/the-tcpdump-group/$pkgname/archive/refs/tags/$pkgver.tar.gz" +builddir=$pkgname-$pkgver +packagename=$builddir.tar.gz +buildtools="configure" + +source envset.sh +host= +prepare() { + mkdir -p $builddir/$ARCH-build + if [ $ARCH == "armeabi-v7a" ] + then + setarm32ENV + host=arm-linux + fi + if [ $ARCH == "arm64-v8a" ] + then + setarm64ENV + host=aarch64-linux + fi + cd $builddir + cd $OLDPWD +} + +build() { + + cd $builddir/$ARCH-build + ../configure "$@" --host=$host > `pwd`/build.log 2>&1 + make -j4 >> `pwd`/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $builddir/$ARCH-build + make install >> `pwd`/build.log 2>&1 + cd $OLDPWD + if [ $ARCH == "armeabi-v7a" ] + then + unsetarm32ENV + fi + if [ $ARCH == "arm64-v8a" ] + then + unsetarm64ENV + fi + unset host +} + +check() { + echo "The test must be on an OpenHarmony device!" +} + +cleanbuild(){ + rm -rf ${PWD}/$builddir #${PWD}/packagename +} diff --git a/thirdparty/libpcap/README.OpenSource b/thirdparty/libpcap/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..2c9623212ed28a61156dd3e806bdef7e024450f2 --- /dev/null +++ b/thirdparty/libpcap/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "libpcap", + "License": "BSD", + "License File": "notes.txt", + "Version Number": "libpcap-1.10.3", + "Owner": "llh_01129@163.com", + "Upstream URL": "https://github.com/the-tcpdump-group/libpcap/archive/refs/tags/libpcap-1.10.3.tar.gz", + "Description": "This directory contains source code for libpcap, a system-independent interface for user-level packet capture. libpcap provides a portable framework for low-level network monitoring." + } +] diff --git a/thirdparty/libpcap/README_zh.md b/thirdparty/libpcap/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..ef6411f5ae940c15dcd2ff751512862b74b12727 --- /dev/null +++ b/thirdparty/libpcap/README_zh.md @@ -0,0 +1,13 @@ +# libpcap三方库说明 +## 功能简介 +libpcap是unix/linux平台下的网络数据包捕获函数包,大多数网络监控软件都以它为基础。 + +## 使用约束 +- IDE版本:DevEco Studio 3.1 Beta2 +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:libpcap-1.10.3 +- 当前适配的功能:支持网络数据包捕获 +- [BSD](https://github.com/the-tcpdump-group/libpcap/blob/master/LICENSE) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/libpcap/SHA512SUM b/thirdparty/libpcap/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..60b6a958fba666ba3fde3480276c924943818f8c --- /dev/null +++ b/thirdparty/libpcap/SHA512SUM @@ -0,0 +1 @@ +3e872265d4d3d85637fa00c5851269f3b03035df7a93b9168bb49b7f3965765e000bac8e65b4c69f42c6090fd2cb7bde0304d37efb453cd71d214088dd37cd6b libpcap-libpcap-1.10.3.tar.gz diff --git a/thirdparty/libpcap/docs/hap_integrate.md b/thirdparty/libpcap/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..921f91ed251811543a822fa147c785038f5bf536 --- /dev/null +++ b/thirdparty/libpcap/docs/hap_integrate.md @@ -0,0 +1,69 @@ +# libpcap集成到应用hap +本库是在RK3568开发板上基于OpenHarmony3.2 Release版本的镜像验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 +## 开发环境 +- ubuntu20.04 +- [OpenHarmony3.2Release镜像](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fdayu200_standard_arm32.tar.gz) +- [ohos_sdk_public 3.2.11.9 (API Version 9 Release)](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fohos-sdk-windows_linux-public.tar.gz) +- [DevEco Studio 3.1 Beta2](https://gitee.com/link?target=https%3A%2F%2Fcontentcenter-vali-drcn.dbankcdn.cn%2Fpvt_2%2FDeveloperAlliance_package_901_9%2Ff3%2Fv3%2FuJyuq3syQ2ak4hE1QZmAug%2Fdevecostudio-windows-3.1.0.400.zip%3FHW-CC-KV%3DV1%26HW-CC-Date%3D20230408T013335Z%26HW-CC-Expire%3D315360000%26HW-CC-Sign%3D96262721EDC9B34E6F62E66884AB7AE2A94C2A7B8C28D6F7FC891F46EB211A70) +- [准备三方库构建环境](../../../tools/README.md#编译环境准备) +- [准备三方库测试环境](../../../tools/README.md#ci环境准备) +## 编译三方库 +- 下载本仓库 + ``` + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` +- 三方库目录结构 + ``` + tpc_c_cplusplus/thirdparty/libpcap #三方库libpcap的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将libpcap拷贝至tools/main目录下 + ``` + cd tpc_c_cplusplus + cp thirdparty/libpcap tools/main -rf + ``` +- 在tools目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + ``` + cd tools + ./build.sh libpcap + ``` +- 三方库头文件及生成的库 + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ``` + libpcap/arm64-v8a libpcap/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + ![thirdparty_install_dir](pic/libpcap_install_dir.png) +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ``` + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libpcap-${OHOS_ARCH}-install/lib/libpcap.a) + + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libpcap-${OHOS_ARCH}-install/include) + ``` + ![tinyxpath_usage](pic/libpcap_usage.png) +## 测试三方库 +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +进入到构建目录执行make testprogs,生成可执行测试文件,再去testprogs目录执行./capturetest进行抓包测试(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录,下图是设备联网后应用请求网络数据的抓包测试截图) + + ![tinyxpath_test](pic/libpcap_test.png) + +## 参考资料 +- [润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld) +- [OpenHarmony三方库地址](https://gitee.com/openharmony-tpc) +- [OpenHarmony知识体系](https://gitee.com/openharmony-sig/knowledge) +- [通过DevEco Studio开发一个NAPI工程](https://gitee.com/openharmony-sig/knowledge_demo_temp/blob/master/docs/napi_study/docs/hello_napi.md) diff --git a/thirdparty/libpcap/docs/pic/libpcap_install_dir.png b/thirdparty/libpcap/docs/pic/libpcap_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..54368c3c1355f1001d9e3ecd01a868c87645f0c1 Binary files /dev/null and b/thirdparty/libpcap/docs/pic/libpcap_install_dir.png differ diff --git a/thirdparty/libpcap/docs/pic/libpcap_test.png b/thirdparty/libpcap/docs/pic/libpcap_test.png new file mode 100644 index 0000000000000000000000000000000000000000..4acc51194583527dc6fb90505f161352ab0060a7 Binary files /dev/null and b/thirdparty/libpcap/docs/pic/libpcap_test.png differ diff --git a/thirdparty/libpcap/docs/pic/libpcap_usage.png b/thirdparty/libpcap/docs/pic/libpcap_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..b41bad2a7b93830b0677fc651355f6d64eca36c3 Binary files /dev/null and b/thirdparty/libpcap/docs/pic/libpcap_usage.png differ diff --git a/thirdparty/libpcap/docs/pic/tinyxpath_install_dir.png b/thirdparty/libpcap/docs/pic/tinyxpath_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..ccf3eb8adaaf3fa591c069aba9369e6d0607cf88 Binary files /dev/null and b/thirdparty/libpcap/docs/pic/tinyxpath_install_dir.png differ diff --git a/thirdparty/libpcap/docs/pic/tinyxpath_test.png b/thirdparty/libpcap/docs/pic/tinyxpath_test.png new file mode 100644 index 0000000000000000000000000000000000000000..6fd3a03d2fbe5e91163e504cee2f572df95b552b Binary files /dev/null and b/thirdparty/libpcap/docs/pic/tinyxpath_test.png differ diff --git a/thirdparty/libpcap/docs/pic/tinyxpath_usage.png b/thirdparty/libpcap/docs/pic/tinyxpath_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..676e188a6d5f14109bbb7c907d28ba345c904cfe Binary files /dev/null and b/thirdparty/libpcap/docs/pic/tinyxpath_usage.png differ diff --git a/thirdparty/libsrtp/HPKBUILD b/thirdparty/libsrtp/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..4110d310e78c5ba435d281a5feda8112acdd57a6 --- /dev/null +++ b/thirdparty/libsrtp/HPKBUILD @@ -0,0 +1,52 @@ +# Contributor: liulihong +# Maintainer: liulihong + +pkgname=libsrtp +pkgver=v2.5.0 +pkgrel=0 +pkgdesc="" +url="" +archs=("armeabi-v7a" "arm64-v8a") +license=("2001-2017 Cisco Systems, Inc") +depends=("openssl" "libpcap") +makedepends=() +install= +source="https://github.com/cisco/$pkgname/archive/refs/tags/$pkgver.tar.gz" +patchflag=true +builddir=$pkgname-${pkgver:1} +packagename=$builddir.tar.gz + +prepare() { + if $patchflag + then + cd $builddir + patch -p1 < `pwd`/../libsrtp_oh_pkg.patch + patchflag=false + cd $OLDPWD + fi + mkdir -p $builddir/$ARCH-build +} + +build() { + cd $builddir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake "$@" -DOHOS_ARCH=$ARCH -B$ARCH-build -S./ -L -DBUILD_WITH_WARNINGS=OFF -DENABLE_OPENSSL=ON > `pwd`/$ARCH-build/build.log 2>&1 + make -j4 -C $ARCH-build >> `pwd`/$ARCH-build/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret + +} + +package() { + cd "$builddir" + make -C $ARCH-build install >> `pwd`/$ARCH-build/build.log 2>&1 + cd $OLDPWD +} + +check() { + echo "The test must be on an OpenHarmony device!" +} + +cleanbuild(){ + rm -rf ${PWD}/$builddir #${PWD}/packagename +} diff --git a/thirdparty/libsrtp/README.OpenSource b/thirdparty/libsrtp/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..84a4ffed755ac869729e23d5dee1465ec36b30fb --- /dev/null +++ b/thirdparty/libsrtp/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "libsrtp", + "License": "2001-2017 Cisco Systems, Inc", + "License File": "notes.txt", + "Version Number": "v2.5.0", + "Owner": "llh_01129@163.com", + "Upstream URL": "https://github.com/cisco/libsrtp/archive/refs/tags/v2.5.0.tar.gz", + "Description": "libSRTP provides functions for protecting RTP and RTCP. RTP packets can be encrypted and authenticated (using the srtp_protect() function), turning them into SRTP packets." + } +] diff --git a/thirdparty/libsrtp/README_zh.md b/thirdparty/libsrtp/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..313031db21a3d5fd36cf0b1e3d68ed851143a624 --- /dev/null +++ b/thirdparty/libsrtp/README_zh.md @@ -0,0 +1,12 @@ +# libsrtp三方库说明 +## 功能简介 +libSRTP提供了保护RTP和RTCP的功能。RTP数据包可以进行加密和身份验证(使用srtp_protect()函数),将其转换为srtp数据包。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Beta2 +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:v2.5.0 +- 当前适配的功能:支持加密的rtp数据包传输 +- [2001-2017 Cisco Systems, Inc](https://github.com/cisco/libsrtp/blob/main/LICENSE) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/libsrtp/SHA512SUM b/thirdparty/libsrtp/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..2d96ec67c45eb454ded8a7e2e116fa0083f8bc6b --- /dev/null +++ b/thirdparty/libsrtp/SHA512SUM @@ -0,0 +1,2 @@ +bd679ab65ccf22ca30fe867b9649a0b84cfa6fad6e22eb10f081141632f6dd56479a04d525b865f11fd46007303ca211065d9c170e4820d6ea7055403702340a libsrtp-2.5.0.tar.gz +4ca9729bdc73526ba392571672b3f24de11c74cb98cd95f4e71bcceda9b33597d8b6166202fbb0d12f9abd7ec2a99faa955f1c7c9a64e4088fde7b4bd7b9fca9 libsrtp_oh_pkg.patch diff --git a/thirdparty/libsrtp/docs/hap_integrate.md b/thirdparty/libsrtp/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..19edfea971cd752d9b10a135230d3ea17b03a091 --- /dev/null +++ b/thirdparty/libsrtp/docs/hap_integrate.md @@ -0,0 +1,72 @@ +# libsrtp集成到应用hap +本库是在RK3568开发板上基于OpenHarmony3.2 Release版本的镜像验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 +## 开发环境 +- ubuntu20.04 +- [OpenHarmony3.2Release镜像](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fdayu200_standard_arm32.tar.gz) +- [ohos_sdk_public 3.2.11.9 (API Version 9 Release)](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fohos-sdk-windows_linux-public.tar.gz) +- [DevEco Studio 3.1 Beta2](https://gitee.com/link?target=https%3A%2F%2Fcontentcenter-vali-drcn.dbankcdn.cn%2Fpvt_2%2FDeveloperAlliance_package_901_9%2Ff3%2Fv3%2FuJyuq3syQ2ak4hE1QZmAug%2Fdevecostudio-windows-3.1.0.400.zip%3FHW-CC-KV%3DV1%26HW-CC-Date%3D20230408T013335Z%26HW-CC-Expire%3D315360000%26HW-CC-Sign%3D96262721EDC9B34E6F62E66884AB7AE2A94C2A7B8C28D6F7FC891F46EB211A70) +- [准备三方库构建环境](../../../tools/README.md#编译环境准备) +- [准备三方库测试环境](../../../tools/README.md#ci环境准备) +## 编译三方库 +- 下载本仓库 + ``` + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` +- 三方库目录结构 + ``` + tpc_c_cplusplus/thirdparty/libsrtp #三方库libsrtp的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ├── libsrtp_oh_pkg.patch #三方库libsrtp的patch文件 + ``` + +- 将libsrtp拷贝至tools/main目录下,并且将依赖的openssl和libpcap也拷贝至tools/main目录下 + ``` + cd tpc_c_cplusplus + cp thirdparty/libsrtp tools/main -rf + cp thirdparty/openssl tools/main -rf + cp thirdparty/libpcap tools/main -rf + ``` +- 在tools目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + ``` + cd tools + ./build.sh libsrtp openssl libpcap + ``` +- 三方库头文件及生成的库 + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ``` + libsrtp/arm64-v8a libsrtp/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + ![thirdparty_install_dir](pic/libsrtp_install_dir.png) +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ``` + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libsrtp-${OHOS_ARCH}-install/lib/libsrtp2.a) + + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libsrtp-${OHOS_ARCH}-install/include) + ``` + ![libsrtp_usage](pic/libsrtp_usage.png) +## 测试三方库 +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +进入到构建目录执行ctest运行测试用例(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) + + ![libsrtp_test](pic/libsrtp_test.png) + +## 参考资料 +- [润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld) +- [OpenHarmony三方库地址](https://gitee.com/openharmony-tpc) +- [OpenHarmony知识体系](https://gitee.com/openharmony-sig/knowledge) +- [通过DevEco Studio开发一个NAPI工程](https://gitee.com/openharmony-sig/knowledge_demo_temp/blob/master/docs/napi_study/docs/hello_napi.md) diff --git a/thirdparty/libsrtp/docs/pic/libsrtp_install_dir.png b/thirdparty/libsrtp/docs/pic/libsrtp_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..bb70458016b5706bc394e8d1bff2c384051862cc Binary files /dev/null and b/thirdparty/libsrtp/docs/pic/libsrtp_install_dir.png differ diff --git a/thirdparty/libsrtp/docs/pic/libsrtp_test.png b/thirdparty/libsrtp/docs/pic/libsrtp_test.png new file mode 100644 index 0000000000000000000000000000000000000000..8353e522c5fdb79e13a5078dc10a26813bdf2b82 Binary files /dev/null and b/thirdparty/libsrtp/docs/pic/libsrtp_test.png differ diff --git a/thirdparty/libsrtp/docs/pic/libsrtp_usage.png b/thirdparty/libsrtp/docs/pic/libsrtp_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..26d8112282014ad5eec9862ae81209abadbaf274 Binary files /dev/null and b/thirdparty/libsrtp/docs/pic/libsrtp_usage.png differ diff --git a/thirdparty/libsrtp/libsrtp_oh_pkg.patch b/thirdparty/libsrtp/libsrtp_oh_pkg.patch new file mode 100644 index 0000000000000000000000000000000000000000..9d1999c742352fa62d56c33846057fb3fc2de336 --- /dev/null +++ b/thirdparty/libsrtp/libsrtp_oh_pkg.patch @@ -0,0 +1,13 @@ +--- libsrtp-2.5.0/CMakeLists.txt 2023-02-01 15:25:02.000000000 +0800 ++++ CMakeLists.txt 2023-03-22 10:57:04.552717234 +0800 +@@ -289,7 +289,9 @@ + find_package(PCAP) + if (PCAP_FOUND) + add_executable(rtp_decoder test/rtp_decoder.c test/getopt_s.c test/util.c) +- target_link_libraries(rtp_decoder srtp2 ${PCAP_LIBRARY}) ++ target_link_libraries(rtp_decoder srtp2 ${PCAP_LIBRARY_TEMP}) ++ target_include_directories(rtp_decoder PRIVATE ${PCAP_INCLUDE_DIR_TEMP}) ++ + endif() + + if(NOT (BUILD_SHARED_LIBS AND WIN32)) diff --git a/thirdparty/openssl/HPKBUILD b/thirdparty/openssl/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..5877f7bfb4b68430bee222a21621a4fe5e4af17d --- /dev/null +++ b/thirdparty/openssl/HPKBUILD @@ -0,0 +1,79 @@ +# Contributor: Jeff Han +# Maintainer: Jeff Han +pkgname=openssl +pkgver=OpenSSL_1_1_1t +pkgrel=0 +pkgdesc="" +url="" +archs=("armeabi-v7a" "arm64-v8a") +license="Apache License 2.0" +depends=() +makedepends=() +install= +source="https://github.com/openssl/$pkgname/archive/refs/tags/$pkgver.zip" + +autounpack=true +downloadpackage=true +buildtools="configure" + +builddir=$pkgname-${pkgver} +packagename=$builddir.zip + +source envset.sh + +host= +prepare() { + mkdir -p $builddir/$ARCH-build + if [ $ARCH == "armeabi-v7a" ] + then + setarm32ENV + host=linux-generic32 + fi + if [ $ARCH == "arm64-v8a" ] + then + setarm64ENV + host=linux-aarch64 + fi +} + +#参数1 +build() { + cd $builddir/$ARCH-build + ../Configure "$@" $host > `pwd`/build.log 2>&1 + make -j4 >> `pwd`/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $builddir/$ARCH-build + make install >> `pwd`/build.log 2>&1 + cd $OLDPWD +} + +check() { + cd $builddir/$ARCH-build + make depend >> `pwd`/build.log 2>&1 + cd $OLDPWD + if [ $ARCH == "armeabi-v7a" ] + then + unsetarm32ENV + fi + if [ $ARCH == "arm64-v8a" ] + then + unsetarm64ENV + fi + unset host + echo "The test must be on an OpenHarmony device!" + # real test CMD + # 将编译目录加到 LD_LIBRARY_PATH 环境变量 + # make test + # 32 个用例错误判定为误报, 不同系统错误描述不同(实际为正常) + # 8 个 dlopen 用例错误, 进程退出时 signal 11. 可能是资源释放问题待 GDB 就位后定位 +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/$builddir #${PWD}/$packagename +} diff --git a/thirdparty/openssl/README.OpenSource b/thirdparty/openssl/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..56567a12715b19595898c1e42af2d4ccc5be3d61 --- /dev/null +++ b/thirdparty/openssl/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "openssl", + "License": "Apache License 2.0", + "License File": "notes.txt", + "Version Number": "OpenSSL_1_1_1t", + "Owner": "llh_01129@163.com", + "Upstream URL": "https://github.com/openssl/openssl/archive/refs/tags/OpenSSL_1_1_1t.zip", + "Description": "OpenSSL is a robust, commercial-grade, full-featured Open Source Toolkit for the Transport Layer Security (TLS) protocol formerly known as the Secure Sockets Layer (SSL) protocol." + } +] diff --git a/thirdparty/openssl/README_zh.md b/thirdparty/openssl/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..e1d613c2d05115ab330aff1834d28466494de7a9 --- /dev/null +++ b/thirdparty/openssl/README_zh.md @@ -0,0 +1,12 @@ +# openssl三方库说明 +## 功能简介 +OpenSSL是一个强大的、商业级的、功能齐全的用于传输层安全(TLS)协议的开源工具包,以前称为安全套接字层(SSL)协议,应用程序可以使用这个包来进行安全通信,避免窃听,同时确认另一端连接者的身份。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Beta2 +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:OpenSSL_1_1_1t +- 当前适配的功能:支持openssl加密传输功能 +- [Apache License 2.0](https://github.com/openssl/openssl) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/openssl/SHA512SUM b/thirdparty/openssl/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..ac9d12837a1ab017031792d7d46cb3c15ef2c624 --- /dev/null +++ b/thirdparty/openssl/SHA512SUM @@ -0,0 +1 @@ +ae7481ddf8df80b033810d92dac28a70342cc283ab715079239928ed3cb333300f10724317f759ca54a109a3faeeca168474353bee7586ec3f6baafd80fda3b1 openssl-OpenSSL_1_1_1t.zip \ No newline at end of file diff --git a/thirdparty/openssl/docs/hap_integrate.md b/thirdparty/openssl/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..b6b70463c8168d35fe1db280f4c3ed565c84ad8c --- /dev/null +++ b/thirdparty/openssl/docs/hap_integrate.md @@ -0,0 +1,73 @@ +# openssl集成到应用hap +本库是在RK3568开发板上基于OpenHarmony3.2 Release版本的镜像验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 +## 开发环境 +- ubuntu20.04 +- [OpenHarmony3.2Release镜像](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fdayu200_standard_arm32.tar.gz) +- [ohos_sdk_public 3.2.11.9 (API Version 9 Release)](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fohos-sdk-windows_linux-public.tar.gz) +- [DevEco Studio 3.1 Beta2](https://gitee.com/link?target=https%3A%2F%2Fcontentcenter-vali-drcn.dbankcdn.cn%2Fpvt_2%2FDeveloperAlliance_package_901_9%2Ff3%2Fv3%2FuJyuq3syQ2ak4hE1QZmAug%2Fdevecostudio-windows-3.1.0.400.zip%3FHW-CC-KV%3DV1%26HW-CC-Date%3D20230408T013335Z%26HW-CC-Expire%3D315360000%26HW-CC-Sign%3D96262721EDC9B34E6F62E66884AB7AE2A94C2A7B8C28D6F7FC891F46EB211A70) +- [准备三方库构建环境](../../../tools/README.md#编译环境准备) +- [准备三方库测试环境](../../../tools/README.md#ci环境准备) +## 编译三方库 +- 下载本仓库 + ``` + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` +- 三方库目录结构 + ``` + tpc_c_cplusplus/thirdparty/openssl #三方库openssl的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将openssl拷贝至tools/main目录下 + ``` + cd tpc_c_cplusplus + cp thirdparty/openssl tools/main -rf + ``` +- 在tools目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + ``` + cd tools + ./build.sh openssl + ``` +- 三方库头文件及生成的库 + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ``` + openssl/arm64-v8a openssl/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + ![thirdparty_install_dir](pic/openssl_install_dir.png) +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ``` + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/openssl-${OHOS_ARCH}-install/lib/libssl.a) + + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/openssl-${OHOS_ARCH}-install/include) + ``` + ![tinyxpath_usage](pic/openssl_usage.png) +## 测试三方库 +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +进入到构建目录执行make test 运行测试用例(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) + +![tinyxpath_test](pic/openssl_test.png) + +32个用例是错误判定为误判,不同系统错误描述不同,实际为正常 + +8个dlopen用例错误,进程退出是signal11,可能是资源释放问题已经提单待回复 + +## 参考资料 +- [润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld) +- [OpenHarmony三方库地址](https://gitee.com/openharmony-tpc) +- [OpenHarmony知识体系](https://gitee.com/openharmony-sig/knowledge) +- [通过DevEco Studio开发一个NAPI工程](https://gitee.com/openharmony-sig/knowledge_demo_temp/blob/master/docs/napi_study/docs/hello_napi.md) diff --git a/thirdparty/openssl/docs/pic/openssl_install_dir.png b/thirdparty/openssl/docs/pic/openssl_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..25c4cb03db7741a88e384abd636bafbf30e16dbd Binary files /dev/null and b/thirdparty/openssl/docs/pic/openssl_install_dir.png differ diff --git a/thirdparty/openssl/docs/pic/openssl_test.png b/thirdparty/openssl/docs/pic/openssl_test.png new file mode 100644 index 0000000000000000000000000000000000000000..43bff0f7a84e07bc35fa7fc957e384f4bb5f4638 Binary files /dev/null and b/thirdparty/openssl/docs/pic/openssl_test.png differ diff --git a/thirdparty/openssl/docs/pic/openssl_usage.png b/thirdparty/openssl/docs/pic/openssl_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..5145dda31d62114a332bc17a846560a8a9ab980d Binary files /dev/null and b/thirdparty/openssl/docs/pic/openssl_usage.png differ