diff --git a/.github/workflows/cpp_workflow.yml b/.github/workflows/cpp_workflow.yml index 3ec7f9c1..ce682ad2 100644 --- a/.github/workflows/cpp_workflow.yml +++ b/.github/workflows/cpp_workflow.yml @@ -141,12 +141,12 @@ jobs: if: runner.os == 'macos' with: name: libppc-crypto-sdk-jni.dylib - path: ./cpp/ppc-crypto-c-sdk/bindings/java/src/main/resources/META-INF/native/libppc-crypto-sdk-jni.dylib + path: ./cpp/wedpr-component-sdk/bindings/java/src/main/resources/META-INF/native/libppc-crypto-sdk-jni.dylib - uses: actions/upload-artifact@v2 if: runner.os == 'Windows' with: name: libppc-crypto-sdk-jni.dylib - path: D:\a\WeDPR-Component\cpp\ppc-crypto-c-sdk\bindings\java\src\main\resources\META-INF\native\Release\ppc-crypto-sdk-jni.dll + path: D:\a\WeDPR-Component\cpp\wedpr-component-sdk\bindings\java\src\main\resources\META-INF\native\Release\ppc-crypto-sdk-jni.dll build_centos: name: build_centos full node @@ -221,4 +221,4 @@ jobs: - uses: actions/upload-artifact@v2 with: name: libppc-crypto-sdk-jni.so - path: ./cpp/ppc-crypto-c-sdk/bindings/java/src/main/resources/META-INF/native/libppc-crypto-sdk-jni.so \ No newline at end of file + path: ./cpp/wedpr-component-sdk/bindings/java/src/main/resources/META-INF/native/libppc-crypto-sdk-jni.so \ No newline at end of file diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 698343ec..75586dc4 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -63,8 +63,8 @@ include(TargetSettings) include(Dependencies) ########### set the sources ########### -set(JNI_SOURCE_PATH ppc-crypto-c-sdk/bindings/java/src/main/c) -set(SDK_SOURCE_LIST ppc-homo ppc-crypto-core ppc-crypto-c-sdk ${JNI_SOURCE_PATH}) +set(JNI_SOURCE_PATH wedpr-component-sdk/bindings/java/src/main/c) +set(SDK_SOURCE_LIST ppc-homo ppc-crypto-core wedpr-component-sdk ${JNI_SOURCE_PATH}) # Note: the udf depends on mysql, not enabled in the full node mode set(UDF_SOURCE_LIST ${SDK_SOURCE_LIST} ppc-udf) set(ALL_SOURCE_LIST @@ -79,6 +79,19 @@ if(BUILD_CEM) set(CEM_SOURCE "ppc-cem") endif() +if(BUILD_WEDPR_TOOLKIT) + # fetch the python dependencies + option(FETCH_PYTHON_DEPS "Install python required modules if not available" ON) + message(STATUS "Python fetch dependencies: ${FETCH_PYTHON_DEPS}") + include(python) + if(WIN32) + message(STATUS "Getting SWIG for Windows: ...") + include(swig) + message(STATUS "Getting SWIG for Windows: ...DONE") + endif() + add_subdirectory(wedpr-toolkit-wrapper) +endif() + if(BUILD_ALL) add_sources("${ALL_SOURCE_LIST}") elseif(BUILD_UDF) diff --git a/cpp/cmake/IncludeDirectories.cmake b/cpp/cmake/IncludeDirectories.cmake index c22d3cce..7bd1fb86 100644 --- a/cpp/cmake/IncludeDirectories.cmake +++ b/cpp/cmake/IncludeDirectories.cmake @@ -2,7 +2,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ppc-front) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ppc-gateway) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ppc-crypto-c-sdk) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wedpr-component-c-sdk) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ppc-tars-protocol) set(VCPKG_INCLUDE_PATH "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") diff --git a/cpp/cmake/Options.cmake b/cpp/cmake/Options.cmake index 1b4245ab..bf631af3 100644 --- a/cpp/cmake/Options.cmake +++ b/cpp/cmake/Options.cmake @@ -52,6 +52,7 @@ macro(configure_project) default_option(BUILD_ALL ON) default_option(BUILD_SDK OFF) default_option(BUILD_UDF OFF) + default_option(BUILD_WEDPR_TOOLKIT OFF) # Suffix like "-rc1" e.t.c. to append to versions wherever needed. if (NOT DEFINED VERSION_SUFFIX) diff --git a/cpp/cmake/TargetSettings.cmake b/cpp/cmake/TargetSettings.cmake index 61b17f44..da9e9626 100644 --- a/cpp/cmake/TargetSettings.cmake +++ b/cpp/cmake/TargetSettings.cmake @@ -85,17 +85,22 @@ if (ENABLE_CPU_FEATURES) set(CPU_FEATURES_LIB CpuFeatures::cpu_features) endif () -#====== ppc-crypto-c-sdk =========== +#====== wedpr-component-sdk =========== set(PPC_CRYPTO_C_SDK_STATIC_TARGET ppc-crypto-c-sdk-static) set(PPC_CRYPTO_C_SDK_TARGET ppc-crypto-c-sdk) +set(PPC_FRONT_C_SDK_STATIC_TARGET ppc-front-c-sdk-static) +set(PPC_FRONT_C_SDK_TARGET ppc-front-c-sdk) + # add suffix for arm if(ARCH_NATIVE) message(STATUS "Building arm architecture, CMAKE_HOST_SYSTEM_PROCESSOR => ${CMAKE_HOST_SYSTEM_PROCESSOR}") set(PPC_CRYPTO_C_SDK_STATIC_TARGET "ppc-crypto-c-sdk-aarch64") set(PPC_CRYPTO_C_SDK_TARGET "ppc-crypto-c-sdk-static-aarch64") + set(PPC_FRONT_C_SDK_STATIC_TARGET ppc-front-c-sdk-static-aarch64) + set(PPC_FRONT_C_SDK_TARGET ppc-front-c-sdk-aarch64) endif() -#====== ppc-crypto-c-sdk =========== +#====== wedpr-component-sdk =========== #====== ppc-crypto-sdk-jni =========== @@ -119,4 +124,7 @@ if(ARCH_NATIVE) endif() # ========== ppc-udf =========== -set(BOOST_UNIT_TEST Boost::unit_test_framework) \ No newline at end of file +set(BOOST_UNIT_TEST Boost::unit_test_framework) + +# ==== the swig wrapper ===== +set(WEDPR_PYTHON_TOOLKIT "wedpr_python_toolkit") \ No newline at end of file diff --git a/cpp/wedpr-component-c-sdk/CMakeLists.txt b/cpp/wedpr-component-sdk/CMakeLists.txt similarity index 74% rename from cpp/wedpr-component-c-sdk/CMakeLists.txt rename to cpp/wedpr-component-sdk/CMakeLists.txt index 474f39c6..8f389e80 100644 --- a/cpp/wedpr-component-c-sdk/CMakeLists.txt +++ b/cpp/wedpr-component-sdk/CMakeLists.txt @@ -1,4 +1,4 @@ -project(wedpr-component-c-sdk VERSION ${VERSION}) +project(wedpr-component-sdk VERSION ${VERSION}) # export windows dll symbol if(WIN32) @@ -6,10 +6,10 @@ if(WIN32) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS "ON") endif() add_subdirectory(ppc-crypto-c-sdk) -add_subdirectory(ppc-front-c-sdk) +add_subdirectory(wedpr-front-cpp-sdk) if (TESTS) enable_testing() set(CTEST_OUTPUT_ON_FAILURE TRUE) add_subdirectory(tests) -endif() \ No newline at end of file +endif() diff --git a/cpp/wedpr-component-c-sdk/bindings/java/build.gradle b/cpp/wedpr-component-sdk/bindings/java/build.gradle similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/build.gradle rename to cpp/wedpr-component-sdk/bindings/java/build.gradle diff --git a/cpp/wedpr-component-c-sdk/bindings/java/gradle/wrapper/gradle-wrapper.jar b/cpp/wedpr-component-sdk/bindings/java/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/gradle/wrapper/gradle-wrapper.jar rename to cpp/wedpr-component-sdk/bindings/java/gradle/wrapper/gradle-wrapper.jar diff --git a/cpp/wedpr-component-c-sdk/bindings/java/gradle/wrapper/gradle-wrapper.properties b/cpp/wedpr-component-sdk/bindings/java/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/gradle/wrapper/gradle-wrapper.properties rename to cpp/wedpr-component-sdk/bindings/java/gradle/wrapper/gradle-wrapper.properties diff --git a/cpp/wedpr-component-c-sdk/bindings/java/gradlew b/cpp/wedpr-component-sdk/bindings/java/gradlew similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/gradlew rename to cpp/wedpr-component-sdk/bindings/java/gradlew diff --git a/cpp/wedpr-component-c-sdk/bindings/java/gradlew.bat b/cpp/wedpr-component-sdk/bindings/java/gradlew.bat similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/gradlew.bat rename to cpp/wedpr-component-sdk/bindings/java/gradlew.bat diff --git a/cpp/wedpr-component-c-sdk/bindings/java/settings.gradle b/cpp/wedpr-component-sdk/bindings/java/settings.gradle similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/settings.gradle rename to cpp/wedpr-component-sdk/bindings/java/settings.gradle diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/jmh/java/com/webank/wedpr/sdk/jni/jmh/BenchmarkMain.java b/cpp/wedpr-component-sdk/bindings/java/src/jmh/java/com/webank/wedpr/sdk/jni/jmh/BenchmarkMain.java similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/jmh/java/com/webank/wedpr/sdk/jni/jmh/BenchmarkMain.java rename to cpp/wedpr-component-sdk/bindings/java/src/jmh/java/com/webank/wedpr/sdk/jni/jmh/BenchmarkMain.java diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/jmh/java/com/webank/wedpr/sdk/jni/jmh/PaillierBenchmark.java b/cpp/wedpr-component-sdk/bindings/java/src/jmh/java/com/webank/wedpr/sdk/jni/jmh/PaillierBenchmark.java similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/jmh/java/com/webank/wedpr/sdk/jni/jmh/PaillierBenchmark.java rename to cpp/wedpr-component-sdk/bindings/java/src/jmh/java/com/webank/wedpr/sdk/jni/jmh/PaillierBenchmark.java diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/c/CMakeLists.txt b/cpp/wedpr-component-sdk/bindings/java/src/main/c/CMakeLists.txt similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/c/CMakeLists.txt rename to cpp/wedpr-component-sdk/bindings/java/src/main/c/CMakeLists.txt diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/Common.cpp b/cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/Common.cpp similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/Common.cpp rename to cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/Common.cpp diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/Common.h b/cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/Common.h similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/Common.h rename to cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/Common.h diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/JNIException.cpp b/cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/JNIException.cpp similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/JNIException.cpp rename to cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/JNIException.cpp diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/JNIException.h b/cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/JNIException.h similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/JNIException.h rename to cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/JNIException.h diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_crypto_FastOre.cpp b/cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_crypto_FastOre.cpp similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_crypto_FastOre.cpp rename to cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_crypto_FastOre.cpp diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_crypto_FastOre.h b/cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_crypto_FastOre.h similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_crypto_FastOre.h rename to cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_crypto_FastOre.h diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_crypto_SymmetricEncryption.cpp b/cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_crypto_SymmetricEncryption.cpp similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_crypto_SymmetricEncryption.cpp rename to cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_crypto_SymmetricEncryption.cpp diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_crypto_SymmetricEncryption.h b/cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_crypto_SymmetricEncryption.h similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_crypto_SymmetricEncryption.h rename to cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_crypto_SymmetricEncryption.h diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativeFloatingIhc.cpp b/cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativeFloatingIhc.cpp similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativeFloatingIhc.cpp rename to cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativeFloatingIhc.cpp diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativeFloatingIhc.h b/cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativeFloatingIhc.h similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativeFloatingIhc.h rename to cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativeFloatingIhc.h diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativeFloatingPointPaillier.cpp b/cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativeFloatingPointPaillier.cpp similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativeFloatingPointPaillier.cpp rename to cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativeFloatingPointPaillier.cpp diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativeFloatingPointPaillier.h b/cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativeFloatingPointPaillier.h similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativeFloatingPointPaillier.h rename to cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativeFloatingPointPaillier.h diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativeIhc.h b/cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativeIhc.h similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativeIhc.h rename to cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativeIhc.h diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativePaillier.cpp b/cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativePaillier.cpp similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativePaillier.cpp rename to cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativePaillier.cpp diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativePaillier.h b/cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativePaillier.h similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativePaillier.h rename to cpp/wedpr-component-sdk/bindings/java/src/main/c/jni/com_webank_wedpr_sdk_jni_homo_NativePaillier.h diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/demo/GenerateKeys.java b/cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/demo/GenerateKeys.java similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/demo/GenerateKeys.java rename to cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/demo/GenerateKeys.java diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/codec/FloatingPointNumber.java b/cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/codec/FloatingPointNumber.java similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/codec/FloatingPointNumber.java rename to cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/codec/FloatingPointNumber.java diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/codec/NumberCodec.java b/cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/codec/NumberCodec.java similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/codec/NumberCodec.java rename to cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/codec/NumberCodec.java diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/codec/NumberCodecException.java b/cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/codec/NumberCodecException.java similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/codec/NumberCodecException.java rename to cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/codec/NumberCodecException.java diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/codec/NumberCodecImpl.java b/cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/codec/NumberCodecImpl.java similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/codec/NumberCodecImpl.java rename to cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/codec/NumberCodecImpl.java diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/common/JniException.java b/cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/common/JniException.java similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/common/JniException.java rename to cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/common/JniException.java diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/common/JniLibLoader.java b/cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/common/JniLibLoader.java similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/common/JniLibLoader.java rename to cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/common/JniLibLoader.java diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/common/Utilities.java b/cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/common/Utilities.java similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/common/Utilities.java rename to cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/common/Utilities.java diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/crypto/FastOre.java b/cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/crypto/FastOre.java similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/crypto/FastOre.java rename to cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/crypto/FastOre.java diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/crypto/SymmetricEncryption.java b/cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/crypto/SymmetricEncryption.java similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/crypto/SymmetricEncryption.java rename to cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/crypto/SymmetricEncryption.java diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/homo/NativeFloatingIhc.java b/cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/homo/NativeFloatingIhc.java similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/homo/NativeFloatingIhc.java rename to cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/homo/NativeFloatingIhc.java diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/homo/NativeFloatingPointPaillier.java b/cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/homo/NativeFloatingPointPaillier.java similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/homo/NativeFloatingPointPaillier.java rename to cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/homo/NativeFloatingPointPaillier.java diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/homo/NativePaillier.java b/cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/homo/NativePaillier.java similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/homo/NativePaillier.java rename to cpp/wedpr-component-sdk/bindings/java/src/main/java/com/webank/wedpr/sdk/jni/homo/NativePaillier.java diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/main/resources/META-INF/native/win/file.list b/cpp/wedpr-component-sdk/bindings/java/src/main/resources/META-INF/native/win/file.list similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/main/resources/META-INF/native/win/file.list rename to cpp/wedpr-component-sdk/bindings/java/src/main/resources/META-INF/native/win/file.list diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/test/java/com/webank/wedpr/sdk/jni/test/NativeFloatingIhcTest.java b/cpp/wedpr-component-sdk/bindings/java/src/test/java/com/webank/wedpr/sdk/jni/test/NativeFloatingIhcTest.java similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/test/java/com/webank/wedpr/sdk/jni/test/NativeFloatingIhcTest.java rename to cpp/wedpr-component-sdk/bindings/java/src/test/java/com/webank/wedpr/sdk/jni/test/NativeFloatingIhcTest.java diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/test/java/com/webank/wedpr/sdk/jni/test/NativeFloatingPointPaillierTest.java b/cpp/wedpr-component-sdk/bindings/java/src/test/java/com/webank/wedpr/sdk/jni/test/NativeFloatingPointPaillierTest.java similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/test/java/com/webank/wedpr/sdk/jni/test/NativeFloatingPointPaillierTest.java rename to cpp/wedpr-component-sdk/bindings/java/src/test/java/com/webank/wedpr/sdk/jni/test/NativeFloatingPointPaillierTest.java diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/test/java/com/webank/wedpr/sdk/jni/test/NativePaillierTest.java b/cpp/wedpr-component-sdk/bindings/java/src/test/java/com/webank/wedpr/sdk/jni/test/NativePaillierTest.java similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/test/java/com/webank/wedpr/sdk/jni/test/NativePaillierTest.java rename to cpp/wedpr-component-sdk/bindings/java/src/test/java/com/webank/wedpr/sdk/jni/test/NativePaillierTest.java diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/test/java/com/webank/wedpr/sdk/jni/test/NumberCodecTest.java b/cpp/wedpr-component-sdk/bindings/java/src/test/java/com/webank/wedpr/sdk/jni/test/NumberCodecTest.java similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/test/java/com/webank/wedpr/sdk/jni/test/NumberCodecTest.java rename to cpp/wedpr-component-sdk/bindings/java/src/test/java/com/webank/wedpr/sdk/jni/test/NumberCodecTest.java diff --git a/cpp/wedpr-component-c-sdk/bindings/java/src/test/java/com/webank/wedpr/sdk/jni/test/SymmetricEncryptionTest.java b/cpp/wedpr-component-sdk/bindings/java/src/test/java/com/webank/wedpr/sdk/jni/test/SymmetricEncryptionTest.java similarity index 100% rename from cpp/wedpr-component-c-sdk/bindings/java/src/test/java/com/webank/wedpr/sdk/jni/test/SymmetricEncryptionTest.java rename to cpp/wedpr-component-sdk/bindings/java/src/test/java/com/webank/wedpr/sdk/jni/test/SymmetricEncryptionTest.java diff --git a/cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/CMakeLists.txt b/cpp/wedpr-component-sdk/ppc-crypto-c-sdk/CMakeLists.txt similarity index 100% rename from cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/CMakeLists.txt rename to cpp/wedpr-component-sdk/ppc-crypto-c-sdk/CMakeLists.txt diff --git a/cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/fast_ore.cpp b/cpp/wedpr-component-sdk/ppc-crypto-c-sdk/fast_ore.cpp similarity index 100% rename from cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/fast_ore.cpp rename to cpp/wedpr-component-sdk/ppc-crypto-c-sdk/fast_ore.cpp diff --git a/cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/fast_ore.h b/cpp/wedpr-component-sdk/ppc-crypto-c-sdk/fast_ore.h similarity index 100% rename from cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/fast_ore.h rename to cpp/wedpr-component-sdk/ppc-crypto-c-sdk/fast_ore.h diff --git a/cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/floating_point_ihc.cpp b/cpp/wedpr-component-sdk/ppc-crypto-c-sdk/floating_point_ihc.cpp similarity index 100% rename from cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/floating_point_ihc.cpp rename to cpp/wedpr-component-sdk/ppc-crypto-c-sdk/floating_point_ihc.cpp diff --git a/cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/floating_point_ihc.h b/cpp/wedpr-component-sdk/ppc-crypto-c-sdk/floating_point_ihc.h similarity index 100% rename from cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/floating_point_ihc.h rename to cpp/wedpr-component-sdk/ppc-crypto-c-sdk/floating_point_ihc.h diff --git a/cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/floating_point_paillier.cpp b/cpp/wedpr-component-sdk/ppc-crypto-c-sdk/floating_point_paillier.cpp similarity index 100% rename from cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/floating_point_paillier.cpp rename to cpp/wedpr-component-sdk/ppc-crypto-c-sdk/floating_point_paillier.cpp diff --git a/cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/floating_point_paillier.h b/cpp/wedpr-component-sdk/ppc-crypto-c-sdk/floating_point_paillier.h similarity index 100% rename from cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/floating_point_paillier.h rename to cpp/wedpr-component-sdk/ppc-crypto-c-sdk/floating_point_paillier.h diff --git a/cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/homo_ihc.cpp b/cpp/wedpr-component-sdk/ppc-crypto-c-sdk/homo_ihc.cpp similarity index 100% rename from cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/homo_ihc.cpp rename to cpp/wedpr-component-sdk/ppc-crypto-c-sdk/homo_ihc.cpp diff --git a/cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/homo_ihc.h b/cpp/wedpr-component-sdk/ppc-crypto-c-sdk/homo_ihc.h similarity index 100% rename from cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/homo_ihc.h rename to cpp/wedpr-component-sdk/ppc-crypto-c-sdk/homo_ihc.h diff --git a/cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/homo_paillier.cpp b/cpp/wedpr-component-sdk/ppc-crypto-c-sdk/homo_paillier.cpp similarity index 100% rename from cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/homo_paillier.cpp rename to cpp/wedpr-component-sdk/ppc-crypto-c-sdk/homo_paillier.cpp diff --git a/cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/homo_paillier.h b/cpp/wedpr-component-sdk/ppc-crypto-c-sdk/homo_paillier.h similarity index 100% rename from cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/homo_paillier.h rename to cpp/wedpr-component-sdk/ppc-crypto-c-sdk/homo_paillier.h diff --git a/cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/symmetric_encryption.cpp b/cpp/wedpr-component-sdk/ppc-crypto-c-sdk/symmetric_encryption.cpp similarity index 100% rename from cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/symmetric_encryption.cpp rename to cpp/wedpr-component-sdk/ppc-crypto-c-sdk/symmetric_encryption.cpp diff --git a/cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/symmetric_encryption.h b/cpp/wedpr-component-sdk/ppc-crypto-c-sdk/symmetric_encryption.h similarity index 100% rename from cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/symmetric_encryption.h rename to cpp/wedpr-component-sdk/ppc-crypto-c-sdk/symmetric_encryption.h diff --git a/cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/utils/error.cpp b/cpp/wedpr-component-sdk/ppc-crypto-c-sdk/utils/error.cpp similarity index 100% rename from cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/utils/error.cpp rename to cpp/wedpr-component-sdk/ppc-crypto-c-sdk/utils/error.cpp diff --git a/cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/utils/error.h b/cpp/wedpr-component-sdk/ppc-crypto-c-sdk/utils/error.h similarity index 100% rename from cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/utils/error.h rename to cpp/wedpr-component-sdk/ppc-crypto-c-sdk/utils/error.h diff --git a/cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/utils/utilities.cpp b/cpp/wedpr-component-sdk/ppc-crypto-c-sdk/utils/utilities.cpp similarity index 100% rename from cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/utils/utilities.cpp rename to cpp/wedpr-component-sdk/ppc-crypto-c-sdk/utils/utilities.cpp diff --git a/cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/utils/utilities.h b/cpp/wedpr-component-sdk/ppc-crypto-c-sdk/utils/utilities.h similarity index 100% rename from cpp/wedpr-component-c-sdk/ppc-crypto-c-sdk/utils/utilities.h rename to cpp/wedpr-component-sdk/ppc-crypto-c-sdk/utils/utilities.h diff --git a/cpp/wedpr-component-c-sdk/tests/CMakeLists.txt b/cpp/wedpr-component-sdk/tests/CMakeLists.txt similarity index 100% rename from cpp/wedpr-component-c-sdk/tests/CMakeLists.txt rename to cpp/wedpr-component-sdk/tests/CMakeLists.txt diff --git a/cpp/wedpr-component-c-sdk/tests/TestFastOre.cpp b/cpp/wedpr-component-sdk/tests/TestFastOre.cpp similarity index 100% rename from cpp/wedpr-component-c-sdk/tests/TestFastOre.cpp rename to cpp/wedpr-component-sdk/tests/TestFastOre.cpp diff --git a/cpp/wedpr-component-c-sdk/tests/TestHomoPaillier.cpp b/cpp/wedpr-component-sdk/tests/TestHomoPaillier.cpp similarity index 100% rename from cpp/wedpr-component-c-sdk/tests/TestHomoPaillier.cpp rename to cpp/wedpr-component-sdk/tests/TestHomoPaillier.cpp diff --git a/cpp/wedpr-component-c-sdk/tests/main.cpp b/cpp/wedpr-component-sdk/tests/main.cpp similarity index 100% rename from cpp/wedpr-component-c-sdk/tests/main.cpp rename to cpp/wedpr-component-sdk/tests/main.cpp diff --git a/cpp/wedpr-component-sdk/wedpr-front-cpp-sdk/CMakeLists.txt b/cpp/wedpr-component-sdk/wedpr-front-cpp-sdk/CMakeLists.txt new file mode 100644 index 00000000..f2fbbf92 --- /dev/null +++ b/cpp/wedpr-component-sdk/wedpr-front-cpp-sdk/CMakeLists.txt @@ -0,0 +1,9 @@ +file(GLOB_RECURSE SRCS *.cpp *.c) + +# generate the static lib +add_library(${PPC_FRONT_C_SDK_STATIC_TARGET} ${SRCS}) +target_link_libraries(${PPC_FRONT_C_SDK_STATIC_TARGET} PUBLIC ${BCOS_UTILITIES_TARGET}) + +# generate the shared lib +add_library(${PPC_FRONT_C_SDK_TARGET} SHARED ${SRCS}) +target_link_libraries(${PPC_FRONT_C_SDK_TARGET} PUBLIC ${BCOS_UTILITIES_TARGET}) \ No newline at end of file diff --git a/cpp/wedpr-component-sdk/wedpr-front-cpp-sdk/wedpr_front_c.cpp b/cpp/wedpr-component-sdk/wedpr-front-cpp-sdk/wedpr_front_c.cpp new file mode 100644 index 00000000..e3b59381 --- /dev/null +++ b/cpp/wedpr-component-sdk/wedpr-front-cpp-sdk/wedpr_front_c.cpp @@ -0,0 +1,92 @@ +/** + * Copyright (C) 2023 WeDPR. + * SPDX-License-Identifier: Apache-2.0 + * Licensed 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. + * + * @file wedpr_front_c.h + * @author: yujiechen + * @date 2024-08-22 + */ +#include "wedpr_front_c.h" + +/** + * @brief create the wedpr_front using specified config + * + * @param config the config used to build the wedpr_front + * @return void* the created wedpr_front + */ +void* wedpr_front_create(struct wedpr_front_config* config) +{ + return nullptr; +} + +/** + * @brief start the wedpr_front + * + * @param front the front to start + */ +void wedpr_front_start(void* front) {} + +/** + * @brief stop the wedpr_front + * + * @param front the front to stop + */ +void wedpr_front_stop(void* front) {} + +/** + * @brief destroy the wedpr_front + * + * @param front the front to destroy + */ +void wedpr_front_destroy(void* front) {} + +/** + * @brief register the topic handler + * + * @param front the front object + * @param topic the topic + * @param callback the callback called when receive specified topic + */ +void register_topic_handler(void* front, InputBuffer const* topic, wedpr_msg_handler_cb callback) {} + +/** + * @brief async send message + * + * @param front the front to send the message + * @param routerPolicy the router policy: + * 0: route by nodeID + * 1: route by component + * 2: route by agency + * @param topic the topic + * @param dstInst the dst agency(must set when 'route by agency' and 'route by + * component') + * @param dstNodeID the dst nodeID(must set when 'route by nodeID') + * @param componentType the componentType(must set when 'route by component') + * @param payload the payload to send + * @param seq the message seq + * @param timeout timeout + * @param callback callback + */ +void async_send_message(void* front, int routerPolicy, InputBuffer const* topic, + InputBuffer const* dstInst, InputBuffer const* dstNodeID, uint8_t componentType, + InputBuffer const* payload, int seq, long timeout, wedpr_msg_handler_cb callback) +{} + +// the sync interface for async_send_message +wedpr_msg* push(void* front, int routerPolicy, InputBuffer const* topic, InputBuffer const* dstInst, + InputBuffer const* dstNodeID, uint8_t componentType, InputBuffer const* payload, int seq, + long timeout) +{ + return nullptr; +} diff --git a/cpp/wedpr-component-sdk/wedpr-front-cpp-sdk/wedpr_front_c.h b/cpp/wedpr-component-sdk/wedpr-front-cpp-sdk/wedpr_front_c.h new file mode 100644 index 00000000..ed918ce8 --- /dev/null +++ b/cpp/wedpr-component-sdk/wedpr-front-cpp-sdk/wedpr_front_c.h @@ -0,0 +1,98 @@ +/** + * Copyright (C) 2023 WeDPR. + * SPDX-License-Identifier: Apache-2.0 + * Licensed 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. + * + * @file wedpr_front_c.h + * @author: yujiechen + * @date 2024-08-22 + */ +#ifndef __WEDPR_FRONT_C_H__ +#define __WEDPR_FRONT_C_H__ +#include "ppc-framework/libwrapper/Buffer.h" +#include "wedpr_front_common.h" +#include "wedpr_front_config.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief create the wedpr_front using specified config + * + * @param config the config used to build the wedpr_front + * @return void* the created wedpr_front + */ +void* wedpr_front_create(struct wedpr_front_config* config); + +/** + * @brief start the wedpr_front + * + * @param front the front to start + */ +void wedpr_front_start(void* front); + +/** + * @brief stop the wedpr_front + * + * @param front the front to stop + */ +void wedpr_front_stop(void* front); + +/** + * @brief destroy the wedpr_front + * + * @param front the front to destroy + */ +void wedpr_front_destroy(void* front); + +/** + * @brief register the topic handler + * + * @param front the front object + * @param topic the topic + * @param callback the callback called when receive specified topic + */ +void register_topic_handler(void* front, InputBuffer const* topic, wedpr_msg_handler_cb callback); + +/** + * @brief async send message + * + * @param front the front to send the message + * @param routerPolicy the router policy: + * 0: route by nodeID + * 1: route by component + * 2: route by agency + * @param topic the topic + * @param dstInst the dst agency(must set when 'route by agency' and 'route by + * component') + * @param dstNodeID the dst nodeID(must set when 'route by nodeID') + * @param componentType the componentType(must set when 'route by component') + * @param payload the payload to send + * @param seq the message seq + * @param timeout timeout + * @param callback callback + */ +void async_send_message(void* front, int routerPolicy, InputBuffer const* topic, + InputBuffer const* dstInst, InputBuffer const* dstNodeID, uint8_t componentType, + InputBuffer const* payload, int seq, long timeout, wedpr_msg_handler_cb callback); + +// the sync interface for async_send_message +wedpr_msg* push(void* front, int routerPolicy, InputBuffer const* topic, InputBuffer const* dstInst, + InputBuffer const* dstNodeID, uint8_t componentType, InputBuffer const* payload, int seq, + long timeout); + +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file diff --git a/cpp/wedpr-component-sdk/wedpr-front-cpp-sdk/wedpr_front_common.h b/cpp/wedpr-component-sdk/wedpr-front-cpp-sdk/wedpr_front_common.h new file mode 100644 index 00000000..22473223 --- /dev/null +++ b/cpp/wedpr-component-sdk/wedpr-front-cpp-sdk/wedpr_front_common.h @@ -0,0 +1,28 @@ +/** + * Copyright (C) 2023 WeDPR. + * SPDX-License-Identifier: Apache-2.0 + * Licensed 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. + * + * @file wedpr_front_common.h + * @author: yujiechen + * @date 2024-08-22 + */ + +#ifndef __WEDPR_FRONT_COMMON_H__ +#define __WEDPR_FRONT_COMMON_H__ + +#include "wedpr_msg.h" + +typedef void (*wedpr_msg_handler_cb)(struct wedpr_msg* response, void* context); + +#endif diff --git a/cpp/wedpr-component-sdk/wedpr-front-cpp-sdk/wedpr_front_config.h b/cpp/wedpr-component-sdk/wedpr-front-cpp-sdk/wedpr_front_config.h new file mode 100644 index 00000000..cbe665d3 --- /dev/null +++ b/cpp/wedpr-component-sdk/wedpr-front-cpp-sdk/wedpr_front_config.h @@ -0,0 +1,56 @@ +/** + * Copyright (C) 2023 WeDPR. + * SPDX-License-Identifier: Apache-2.0 + * Licensed 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. + * + * @file wedpr_front_config.h + * @author: yujiechen + * @date 2024-08-22 + */ + +#ifndef __WEDPR_FRONT_CONFIG_H__ +#define __WEDPR_FRONT_CONFIG_H__ +#include "ppc-framework/libwrapper/Buffer.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief the gateway endpoint information + * + */ +struct wedpr_gateway_endpoint +{ + InputBuffer const* host; + uint16_t port; +}; + +struct wedpr_gateway_info +{ + struct wedpr_gateway_endpoint* gatewayEndpoints; + uint16_t gatewayCount; +}; + +struct wedpr_front_config +{ + int threadPoolSize; + // the agency id + InputBuffer const* agencyID; + // the gateway-endpoints + struct wedpr_gateway_info* gateway_info; +}; +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file diff --git a/cpp/wedpr-component-sdk/wedpr-front-cpp-sdk/wedpr_msg.h b/cpp/wedpr-component-sdk/wedpr-front-cpp-sdk/wedpr_msg.h new file mode 100644 index 00000000..ae6f280e --- /dev/null +++ b/cpp/wedpr-component-sdk/wedpr-front-cpp-sdk/wedpr_msg.h @@ -0,0 +1,81 @@ +/** + * Copyright (C) 2023 WeDPR. + * SPDX-License-Identifier: Apache-2.0 + * Licensed 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. + * + * @file wedpr_front_common.h + * @author: yujiechen + * @date 2024-08-22 + */ + +#ifndef __WEDPR_MSG_H__ +#define __WEDPR_MSG_H__ + +#include "ppc-framework/libwrapper/Buffer.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct gateway_optional_header +{ + // the componentType + uint8_t componentType; + // the source nodeID that send the message + OutputBuffer* srcNode; + // the target nodeID that should receive the message + OutputBuffer* dstNode; + // the target agency that need receive the message + OutputBuffer* dstInst; +}; + +struct gateway_msg_header +{ + // the msg version, used to support compatibility + uint8_t version; + // the traceID + OutputBuffer* traceID; + // the srcGwNode + OutputBuffer* srcGwNode; + // the dstGwNode + OutputBuffer* dstGwNode; + // the packetType + uint16_t packetType; + // the seq + uint32_t seq; + // the ttl + int16_t ttl; + // the ext(contains the router policy and response flag) + uint16_t ext; + //// the optional field(used to route between components and nodes) + struct gateway_optional_header* optionalFields; +}; + +struct front_payload +{ + // the front payload version, used to support compatibility + uint8_t version; + // the topic + OutputBuffer* topic; + OutputBuffer* data; +}; + +struct wedpr_msg +{ + gateway_msg_header* header; + front_payload* payload; +}; +#ifdef __cplusplus +} +#endif +#endif