├── .gn ├── BUILD.gn ├── IoT Device SDK API Reference (C).pdf ├── IoT Device SDK API文档.pdf ├── LICENSE ├── Makefile ├── README.md ├── README_CN.md ├── build ├── BUILD.gn ├── BUILDCONFIG.gn └── toolchain │ └── BUILD.gn ├── conf ├── bsrootcert.pem └── rootcert.pem ├── demos ├── bootstrap_demo │ ├── bootstrap.c │ ├── bootstrap.h │ ├── bootstrap_groups_test.c │ └── bootstrap_test.c ├── bridge_demo │ ├── bridge_client_test.c │ ├── bridge_server_test.c │ ├── bridge_tcp_protocol.c │ └── bridge_tcp_protocol.h ├── device_demo │ ├── basic_test.c │ ├── command_test.c │ ├── device_config_test.c │ ├── device_rule_test.c │ ├── file_up_down_test.c │ ├── gmssl_test.c │ ├── log_report_test.c │ ├── message_test.c │ ├── mqttV5_test.c │ ├── ota_test.c │ ├── properties_test.c │ ├── reconnection_test.c │ ├── remote_login_test.c │ ├── report_device_info_test.c │ ├── shadow_test.c │ ├── sys_hal_test.c │ └── time_sync_test.c └── gateway_demo │ ├── gateway_client_test.c │ ├── gateway_server_test.c │ ├── generic_tcp_protocol.c │ └── generic_tcp_protocol.h ├── doc ├── doc_cn │ ├── 4_2.png │ ├── 4_3.png │ ├── 4_4.png │ ├── 4_5.png │ ├── 4_6.png │ ├── 4_7.png │ ├── 4_8.png │ ├── 4_config_device_rule.png │ ├── 4_create_rule.png │ ├── 4_observe_output.png │ ├── 4_select_device_rule.png │ ├── 4_send_msg_to_other_device_rule.png │ ├── access_mqtt.png │ ├── addFileStoreDeviceRule.png │ ├── addSubDevice.png │ ├── addsub.png │ ├── bootstrap.png │ ├── buffredMessages.png │ ├── cmdDown.png │ ├── deleteSubDevice.png │ ├── deviceProperties1.png │ ├── device_demo.png │ ├── device_online.png │ ├── device_rule.png │ ├── fileData.png │ ├── gcc.png │ ├── generic.PNG │ ├── generic_protocol.md │ ├── getDown.png │ ├── header_file.png │ ├── logLevel.png │ ├── logUp.png │ ├── login.png │ ├── makefile1.png │ ├── makefile2.png │ ├── messageDown.png │ ├── mode.png │ ├── no_asm.png │ ├── online.png │ ├── openssl.png │ ├── paho.png │ ├── paho64.png │ ├── paho_makefile1.png │ ├── paho_makefile2.png │ ├── profile1.png │ ├── profile2.png │ ├── profile3.png │ ├── profile4.png │ ├── sdk_file_content.PNG │ ├── sdk_file_content2.PNG │ ├── sdk_file_content3.png │ ├── setDown.png │ ├── so1.png │ ├── so2.png │ ├── so3.png │ ├── so4.png │ ├── ssh_1.png │ ├── ssh_2.png │ ├── sysHal.png │ ├── sysroot.png │ ├── untarPkg.png │ ├── updateSubDevice.png │ ├── 删除+重发.png │ ├── 存储.png │ ├── 端云安全通信1.png │ ├── 端云安全通信2.png │ ├── 网桥流程图.png │ └── 重连.png └── doc_en │ ├── 4_2.png │ ├── 4_3.png │ ├── 4_3_1.png │ ├── 4_4.png │ ├── 4_5.png │ ├── 4_6.png │ ├── 4_7.png │ ├── 4_8.png │ ├── 4_config_device_rule.png │ ├── 4_create_rule.png │ ├── 4_select_device_rule.png │ ├── Device-Cloud-Security-Communication1.png │ ├── Device-Cloud-Security-Communication2.png │ ├── access_mqtt.png │ ├── addSubDevice.png │ ├── bootstrap.png │ ├── cmdDown.png │ ├── deleteSubDevice.png │ ├── delete_and_resend.png │ ├── deviceProperties1.png │ ├── device_demo.png │ ├── generic.PNG │ ├── getDown.png │ ├── login.png │ ├── makefile1.png │ ├── makefile2.png │ ├── messageDown.png │ ├── no_asm.png │ ├── online.png │ ├── openssl.PNG │ ├── paho.png │ ├── paho64.png │ ├── paho_makefile1.png │ ├── paho_makefile2.png │ ├── profile1.png │ ├── profile2.png │ ├── profile3.png │ ├── profile4.PNG │ ├── reconnection.png │ ├── sdk_file_content2.PNG │ ├── setDown.png │ ├── so1.png │ ├── so2.png │ ├── so3.png │ ├── so4.png │ ├── ssh_1.png │ ├── ssh_2.png │ ├── storage.png │ ├── sysroot.png │ ├── untarPkg.png │ ├── upload_profile_1.png │ ├── upload_profile_2.png │ ├── upload_profile_3.png │ └── upload_profile_4.png ├── generatingLib ├── README.md ├── curl-8.4.0.tar.gz ├── generateOpenssl.sh ├── generateZlib.sh ├── gmtls.patch.zip ├── libboundscheck-master.zip ├── openssl-1.1.1h.tar.gz ├── paho.mqtt.c-1.3.9.tar.gz └── zlib-1.2.11.zip ├── include ├── agentlite │ ├── hw_type.h │ ├── iota_bridge.h │ ├── iota_cfg.h │ ├── iota_datatrans.h │ ├── iota_defaultCallback.h │ ├── iota_error_type.h │ ├── iota_init.h │ └── iota_login.h ├── base │ ├── MQTTAsync.h │ ├── MQTTClient.h │ ├── MQTTClientPersistence.h │ ├── MQTTProperties.h │ ├── MQTTReasonCodes.h │ ├── MQTTSubscribeOpts.h │ ├── hmac_sha256.h │ └── mqtt_base.h ├── curl │ ├── curl.h │ ├── curlver.h │ ├── easy.h │ ├── header.h │ ├── mprintf.h │ ├── multi.h │ ├── options.h │ ├── stdcheaders.h │ ├── system.h │ ├── typecheck-gcc.h │ ├── urlapi.h │ └── websockets.h ├── dconncaseone_interface.h ├── libssh │ ├── callbacks.h │ ├── legacy.h │ ├── libssh.h │ ├── libssh_version.h │ ├── libsshpp.hpp │ ├── server.h │ ├── sftp.h │ └── ssh2.h ├── nopoll │ ├── nopoll.h │ ├── nopoll_config.h │ ├── nopoll_conn.h │ ├── nopoll_conn_opts.h │ ├── nopoll_ctx.h │ ├── nopoll_decl.h │ ├── nopoll_handlers.h │ ├── nopoll_io.h │ ├── nopoll_listener.h │ ├── nopoll_log.h │ ├── nopoll_loop.h │ ├── nopoll_msg.h │ ├── nopoll_private.h │ └── nopoll_win32.h ├── openssl │ ├── asn1.h │ ├── asn1err.h │ ├── async.h │ ├── asyncerr.h │ ├── bio.h │ ├── bioerr.h │ ├── bn.h │ ├── bnerr.h │ ├── buffer.h │ ├── buffererr.h │ ├── comp.h │ ├── comperr.h │ ├── crypto.h │ ├── cryptoerr.h │ ├── ct.h │ ├── cterr.h │ ├── dh.h │ ├── dherr.h │ ├── dsa.h │ ├── dsaerr.h │ ├── dtls1.h │ ├── e_os2.h │ ├── ec.h │ ├── ecerr.h │ ├── err.h │ ├── evp.h │ ├── evperr.h │ ├── hmac.h │ ├── lhash.h │ ├── obj_mac.h │ ├── objects.h │ ├── objectserr.h │ ├── opensslconf.h │ ├── opensslv.h │ ├── ossl_typ.h │ ├── pem.h │ ├── pemerr.h │ ├── pkcs7.h │ ├── pkcs7err.h │ ├── rand.h │ ├── randerr.h │ ├── rsa.h │ ├── rsaerr.h │ ├── safestack.h │ ├── sha.h │ ├── srtp.h │ ├── ssl.h │ ├── ssl2.h │ ├── ssl3.h │ ├── sslerr.h │ ├── stack.h │ ├── symhacks.h │ ├── tls1.h │ ├── x509.h │ ├── x509_vfy.h │ └── x509err.h ├── protocol │ └── generic_tcp_protocol.h ├── service │ ├── base.h │ ├── bridge │ │ └── bridge_topic_data.h │ ├── callback_func.h │ ├── data_trans.h │ ├── detect_anomaly │ │ └── detect_anomaly.h │ ├── device_rule │ │ ├── rule_action.h │ │ ├── rule_condition.h │ │ ├── rule_execution.h │ │ ├── rule_info.h │ │ ├── rule_manager.h │ │ ├── rule_parser.h │ │ ├── rule_trans.h │ │ └── rule_util.h │ ├── login.h │ ├── soft_bus_datatrans.h │ ├── soft_bus_init.h │ ├── subscribe.h │ └── sys_hal │ │ └── sys_hal.h ├── third_party │ ├── cjson │ │ └── cJSON.h │ ├── libboundscheck │ │ ├── securec.h │ │ └── securectype.h │ └── zlib │ │ ├── zconf.h │ │ └── zlib.h ├── tunnel │ ├── ssh_client.h │ └── wss_client.h └── util │ ├── json_util.h │ ├── log_util.h │ ├── mqttv5_util.h │ └── string_util.h ├── lib ├── README.md └── X86-64 SYSV lib.zip └── src ├── agentlite ├── BUILD.gn ├── iota_bridge.c ├── iota_datatrans.c ├── iota_defaultCallback.c ├── iota_init.c ├── iota_login.c ├── iota_payload.c └── iota_payload.h ├── base ├── BUILD.gn ├── hmac_sha256.c └── mqtt_base.c ├── bootstrap_demo ├── BUILD.gn └── bootstrap_demo.c ├── dconncaseone_interface.c ├── device_demo ├── BUILD.gn └── device_demo.c ├── gateway_demo ├── BUILD.gn ├── gateway_client_demo.c ├── gateway_server_demo.c └── generic_tcp_protocol.c ├── service ├── BUILD.gn ├── base.c ├── bridge │ ├── BUILD.gn │ └── bridge_topic_data.c ├── callback_func.c ├── data_trans.c ├── detect_anomaly │ ├── BUILD.gn │ └── detect_anomaly.c ├── device_rule │ ├── BUILD.gn │ ├── rule_action.c │ ├── rule_condition.c │ ├── rule_execution.c │ ├── rule_info.c │ ├── rule_manager.c │ ├── rule_parser.c │ ├── rule_trans.c │ └── rule_util.c ├── login.c ├── soft_bus_datatrans.c ├── soft_bus_init.c ├── subscribe.c └── sys_hal │ ├── BUILD.gn │ ├── sys_hal.c │ └── sys_hal_imp.c ├── third_party └── cjson │ ├── BUILD.gn │ └── cJSON.c ├── tunnel ├── BUILD.gn ├── ssh_client.c └── wss_client.c └── util ├── BUILD.gn ├── json_util.c ├── log_util.c ├── mqttv5_util.c └── string_util.c /.gn: -------------------------------------------------------------------------------- 1 | # The location of the build configuration file. 2 | buildconfig = "//build/BUILDCONFIG.gn" 3 | 4 | -------------------------------------------------------------------------------- /BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2022 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 2 | # Redistribution and use in source and binary forms, with or without modification, 3 | # are permitted provided that the following conditions are met: 4 | # 1. Redistributions of source code must retain the above copyright notice, this list of 5 | # conditions and the following disclaimer. 6 | # 7 | # 2. Redistributions in binary form must reproduce the above copyright notice, this list 8 | # of conditions and the following disclaimer in the documentation and/or other materials 9 | # provided with the distribution. 10 | # 11 | # 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | # to endorse or promote products derived from this software without specific prior written 13 | # permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 17 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 19 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | #import("//build/ohos.gni") 28 | #import("//build/lite/config/component/lite_component.gni") 29 | 30 | 31 | declare_args() { 32 | test_demo = "device_demo" 33 | } 34 | 35 | executable("mqtt_device_demo") { 36 | 37 | deps = [ 38 | ":conf_copy", 39 | ":lib_copy", 40 | "src/util:util", 41 | "src/third_party/cjson:cjson", 42 | "src/service:service", 43 | "src/base:base", 44 | "src/agentlite:agentlite", 45 | "src/tunnel:tunnel", 46 | "src/service/device_rule:device_rule", 47 | "src/service/sys_hal:sys_hal", 48 | "src/service/detect_anomaly:detect_anomaly", 49 | "src/service/bridge:bridge_topic", 50 | ] 51 | 52 | if(test_demo == "device_demo"){ 53 | deps += ["src/device_demo:device_demo",] 54 | } 55 | 56 | libs = [ 57 | "./lib/libboundscheck.so", 58 | "./lib/libssl.so", 59 | "./lib/libcrypto.so", 60 | "./lib/libz.so", 61 | "./lib/libpaho-mqtt3as.so", 62 | "./lib/libssh.so", 63 | "./lib/libnopoll.so", 64 | "./lib/libcurl.so", 65 | "pthread", 66 | ] 67 | 68 | output_name = "MQTT_Demo" 69 | } 70 | 71 | copy("lib_copy") { 72 | sources = [ "lib" ] 73 | outputs = [ "$root_out_dir/{{source_file_part}}" ] 74 | } 75 | 76 | copy("conf_copy") { 77 | sources = [ "conf" ] 78 | outputs = [ "$root_out_dir/{{source_file_part}}"] 79 | } 80 | 81 | print("-----------------------> iot-device-sdk-c:$test_demo!") 82 | -------------------------------------------------------------------------------- /IoT Device SDK API Reference (C).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/IoT Device SDK API Reference (C).pdf -------------------------------------------------------------------------------- /IoT Device SDK API文档.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/IoT Device SDK API文档.pdf -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020-2022 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this list of 9 | conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, this list 12 | of conditions and the following disclaimer in the documentation and/or other materials 13 | provided with the distribution. 14 | 15 | 3. Neither the name of the copyright holder nor the names of its contributors may be used 16 | to endorse or promote products derived from this software without specific prior written 17 | permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 23 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /build/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | config("compiler_defaults") { 6 | if (current_os == "linux") { 7 | cflags = [ 8 | "-fPIC", 9 | "-pthread", 10 | "-w", 11 | ] 12 | } 13 | } 14 | 15 | config("executable_ldconfig") { 16 | if (!is_mac) { 17 | ldflags = [ 18 | "-Wl,-rpath=\$ORIGIN/", 19 | "-Wl,-rpath-link=", 20 | ] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /build/BUILDCONFIG.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | defines = [ 6 | "SSH_SWITCH = 1", 7 | "BRIDGE_SWITCH = 1", 8 | #"MQTTV5 = 1" 9 | ] 10 | 11 | if (target_os == "") { 12 | target_os = host_os 13 | } 14 | if (target_cpu == "") { 15 | target_cpu = host_cpu 16 | } 17 | if (current_cpu == "") { 18 | current_cpu = target_cpu 19 | } 20 | if (current_os == "") { 21 | current_os = target_os 22 | } 23 | 24 | is_linux = host_os == "linux" && current_os == "linux" && target_os == "linux" 25 | is_mac = host_os == "mac" && current_os == "mac" && target_os == "mac" 26 | 27 | # All binary targets will get this list of configs by default. 28 | _shared_binary_target_configs = [ "//build:compiler_defaults" ] 29 | 30 | # Apply that default list to the binary target types. 31 | set_defaults("executable") { 32 | configs = _shared_binary_target_configs 33 | 34 | # Executables get this additional configuration. 35 | configs += [ "//build:executable_ldconfig" ] 36 | } 37 | set_defaults("static_library") { 38 | configs = _shared_binary_target_configs 39 | } 40 | set_defaults("shared_library") { 41 | configs = _shared_binary_target_configs 42 | } 43 | set_defaults("source_set") { 44 | configs = _shared_binary_target_configs 45 | } 46 | 47 | set_default_toolchain("//build/toolchain:gcc") 48 | -------------------------------------------------------------------------------- /build/toolchain/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | toolchain("gcc") { 6 | tool("cc") { 7 | depfile = "{{output}}.d" 8 | command = "gcc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" 9 | depsformat = "gcc" 10 | description = "CC {{output}}" 11 | outputs = 12 | [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ] 13 | } 14 | 15 | tool("cxx") { 16 | depfile = "{{output}}.d" 17 | command = "g++ -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" 18 | depsformat = "gcc" 19 | description = "CXX {{output}}" 20 | outputs = 21 | [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ] 22 | } 23 | 24 | tool("alink") { 25 | command = "rm -f {{output}} && ar rcs {{output}} {{inputs}}" 26 | description = "AR {{target_output_name}}{{output_extension}}" 27 | 28 | outputs = 29 | [ "{{target_out_dir}}/{{target_output_name}}{{output_extension}}" ] 30 | default_output_extension = ".a" 31 | output_prefix = "lib" 32 | } 33 | 34 | tool("solink") { 35 | soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". 36 | sofile = "{{output_dir}}/$soname" 37 | rspfile = soname + ".rsp" 38 | if (is_mac) { 39 | os_specific_option = "-install_name @executable_path/$sofile" 40 | rspfile_content = "{{inputs}} {{solibs}} {{libs}}" 41 | } else { 42 | os_specific_option = "-Wl,-soname=$soname" 43 | rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive {{libs}}" 44 | } 45 | 46 | command = "g++ -shared {{ldflags}} -o $sofile $os_specific_option @$rspfile" 47 | 48 | description = "SOLINK $soname" 49 | 50 | # Use this for {{output_extension}} expansions unless a target manually 51 | # overrides it (in which case {{output_extension}} will be what the target 52 | # specifies). 53 | default_output_extension = ".so" 54 | 55 | # Use this for {{output_dir}} expansions unless a target manually overrides 56 | # it (in which case {{output_dir}} will be what the target specifies). 57 | default_output_dir = "{{root_out_dir}}" 58 | 59 | outputs = [ sofile ] 60 | link_output = sofile 61 | depend_output = sofile 62 | output_prefix = "lib" 63 | } 64 | 65 | tool("link") { 66 | outfile = "{{target_output_name}}{{output_extension}}" 67 | rspfile = "$outfile.rsp" 68 | if (is_mac) { 69 | command = "g++ {{ldflags}} -o $outfile @$rspfile {{solibs}} {{libs}}" 70 | } else { 71 | command = "g++ {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group {{libs}}" 72 | } 73 | description = "LINK $outfile" 74 | default_output_dir = "{{root_out_dir}}" 75 | rspfile_content = "{{inputs}}" 76 | outputs = [ outfile ] 77 | } 78 | 79 | tool("stamp") { 80 | command = "touch {{output}}" 81 | description = "STAMP {{output}}" 82 | } 83 | 84 | tool("copy") { 85 | command = "cp -af {{source}} {{output}}" 86 | description = "COPY {{source}} {{output}}" 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /demos/bootstrap_demo/bootstrap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2024 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef __BOOTSTREP_H 32 | #define __BOOTSTREP_H 33 | 34 | // Configure device groups 35 | typedef struct { 36 | char *scopeId; 37 | } BOOTSTEAP_GROUPS; 38 | 39 | // Configure certificates 40 | typedef struct { 41 | char *privateKeyPassword; 42 | } BOOTSTEAP_CERT; 43 | 44 | typedef struct { 45 | char *bootstrapAddress; 46 | char *port; 47 | char *deviceId; 48 | char *password; 49 | char *baseStrategyKeyword; 50 | BOOTSTEAP_GROUPS groups; 51 | BOOTSTEAP_CERT cert; 52 | } BOOTSTEAP_INIT; 53 | 54 | /** 55 | * @Description: bootstrap auth 56 | * @param parameter: BOOTSTEAP_INIT structure 57 | * @param bootstrapMode: 0 for Registered Devices, 1 for Registration Groups 58 | * @param authMode : 0 for secret, 1 for X.509 certificate 59 | * @return: IOTA_SUCCESS represents success, others represent specific failure 60 | */ 61 | int bootstrapAuth(BOOTSTEAP_INIT parameter, int bootstrapMode, int authMode); 62 | 63 | #endif /* __BOOTSTREP_H */ -------------------------------------------------------------------------------- /demos/bridge_demo/bridge_tcp_protocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2024 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | 32 | #ifndef GENERIC_TCP_PROTOCOL_H 33 | #define GENERIC_TCP_PROTOCOL_H 34 | 35 | #define TCP_SERVER_IP "127.0.0.1" 36 | #define TCP_SERVER_PORT 15615 37 | #define MAX_MESSAGE_BUF_LEN 125 38 | #define BACK_LOG 20 // Maximum length of sub device connection request 39 | #define WORK_PATH "." 40 | #define CONNECTED 0 41 | #define DISCONNECTED 1 42 | 43 | // ------------------------------ 44 | #define BRIDGE_TCP_LOGIN "Login:" 45 | #define BRIDGE_TCP_LOGOUT "Logout" 46 | #define BRIDGE_TCP_NEWSECRET "newSecret:" 47 | 48 | int CreateServerSocket(char *serverIp, int serverPort, int backlog); 49 | void ProcessMessageFromClient(int clientSocket, char *subDeviceId); 50 | char *getTcpDeviceId(void); 51 | int setTcpPassword(char *newSecret); 52 | 53 | void SendMessageToSubDevice(int clientSocket, char *payload); 54 | void SendCommandRspToIoTPlatform(char *BridgeDeviceId, char *requestId); 55 | 56 | char *EncodeCommandParas(EN_IOTA_COMMAND *command); 57 | #endif /* INCLUDE_PROTOCOL_GENERIC_TCP_PROTOCOL_H_ */ 58 | 59 | -------------------------------------------------------------------------------- /demos/device_demo/gmssl_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2024 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | /* 32 | * Currently, the SDK supports TLS access and data transmission. If OSCCA-approved encryption algorithms are used for communication, download the OpenSSL of the OSCCA-approved version. 33 | For details, see section 3.2. Compile openssl, 4th point. 34 | * To use TLS, you need to install a patch for the paho.mqtt.c-1.3.9/src/SSLSocket.c file in the paho_mqtt open-source library. 35 | * Decompress. Run the ./generatingLib/gmtls.patch.zip command to obtain the patch file gmtls.patch. 36 | * unzip ./generatingLib/gmtls.patch.zip 37 | * Patching paho.mqtt.c-1.3.9/src/SSLSocket.c Files 38 | * patch -b. /generatingLib/paho.mqtt.c-1.3.9/src/SSLSocket.c ./generatingLib/gmtls.patch 39 | */ 40 | 41 | /* 42 | * Use an absolute path to load the certificate 43 | * const char *signCert = "/volume/tassl/iot-device-sdk-c/conf/gmcert_s/CS.cert.pem"; 44 | * const char *signKey = "/volume/tassl/iot-device-sdk-c/conf/gmcert_s/CS.key.pem"; 45 | * const char *encCert = "/volume/tassl/iot-device-sdk-c/conf/gmcert_e/CE.cert.pem"; 46 | * const char *encKey = "/volume/tassl/iot-device-sdk-c/conf/gmcert_e/CE.key.pem"; 47 | * const char *caPath = "/volume/tassl/iot-device-sdk-c/conf/GMCert_GMCA01.cert.pem"; 48 | * const char *passWord = NULL; 49 | */ 50 | 51 | -------------------------------------------------------------------------------- /demos/gateway_demo/generic_tcp_protocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2024 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | 32 | #ifndef GENERIC_TCP_PROTOCOL_H 33 | #define GENERIC_TCP_PROTOCOL_H 34 | 35 | #define TCP_SERVER_IP "127.0.0.1" 36 | #define TCP_SERVER_PORT 15622 37 | #define MAX_MESSAGE_BUF_LEN 125 38 | #define BACK_LOG 20 // Maximum length of sub device connection request 39 | #define WORK_PATH "." 40 | #define CONNECTED 0 41 | #define DISCONNECTED 1 42 | 43 | int CreateServerSocket(char *serverIp, int serverPort, int backlog); 44 | void ProcessMessageFromClient(int clientSocket, char *subDeviceId, char *product_id); 45 | 46 | void SendCommandRspToIoTPlatform(char *requestId); 47 | void SendMessageToSubDevice(int clientSocket, char *payload); 48 | 49 | char *getTcpDeviceId(void); 50 | void UpdateSubDeviceStatus(char *deviceId, int isOnline); 51 | void HandleSubDeviceManagerEvents(EN_IOTA_SERVICE_EVENT *subDeviceServices); 52 | void HandleSubOTAEvents(EN_IOTA_SERVICE_EVENT *otaServices); 53 | char *EncodeCommandParas(EN_IOTA_COMMAND *command); 54 | #endif /* INCLUDE_PROTOCOL_GENERIC_TCP_PROTOCOL_H_ */ 55 | 56 | -------------------------------------------------------------------------------- /doc/doc_cn/4_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/4_2.png -------------------------------------------------------------------------------- /doc/doc_cn/4_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/4_3.png -------------------------------------------------------------------------------- /doc/doc_cn/4_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/4_4.png -------------------------------------------------------------------------------- /doc/doc_cn/4_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/4_5.png -------------------------------------------------------------------------------- /doc/doc_cn/4_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/4_6.png -------------------------------------------------------------------------------- /doc/doc_cn/4_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/4_7.png -------------------------------------------------------------------------------- /doc/doc_cn/4_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/4_8.png -------------------------------------------------------------------------------- /doc/doc_cn/4_config_device_rule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/4_config_device_rule.png -------------------------------------------------------------------------------- /doc/doc_cn/4_create_rule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/4_create_rule.png -------------------------------------------------------------------------------- /doc/doc_cn/4_observe_output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/4_observe_output.png -------------------------------------------------------------------------------- /doc/doc_cn/4_select_device_rule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/4_select_device_rule.png -------------------------------------------------------------------------------- /doc/doc_cn/4_send_msg_to_other_device_rule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/4_send_msg_to_other_device_rule.png -------------------------------------------------------------------------------- /doc/doc_cn/access_mqtt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/access_mqtt.png -------------------------------------------------------------------------------- /doc/doc_cn/addFileStoreDeviceRule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/addFileStoreDeviceRule.png -------------------------------------------------------------------------------- /doc/doc_cn/addSubDevice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/addSubDevice.png -------------------------------------------------------------------------------- /doc/doc_cn/addsub.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/addsub.png -------------------------------------------------------------------------------- /doc/doc_cn/bootstrap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/bootstrap.png -------------------------------------------------------------------------------- /doc/doc_cn/buffredMessages.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/buffredMessages.png -------------------------------------------------------------------------------- /doc/doc_cn/cmdDown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/cmdDown.png -------------------------------------------------------------------------------- /doc/doc_cn/deleteSubDevice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/deleteSubDevice.png -------------------------------------------------------------------------------- /doc/doc_cn/deviceProperties1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/deviceProperties1.png -------------------------------------------------------------------------------- /doc/doc_cn/device_demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/device_demo.png -------------------------------------------------------------------------------- /doc/doc_cn/device_online.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/device_online.png -------------------------------------------------------------------------------- /doc/doc_cn/device_rule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/device_rule.png -------------------------------------------------------------------------------- /doc/doc_cn/fileData.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/fileData.png -------------------------------------------------------------------------------- /doc/doc_cn/gcc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/gcc.png -------------------------------------------------------------------------------- /doc/doc_cn/generic.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/generic.PNG -------------------------------------------------------------------------------- /doc/doc_cn/generic_protocol.md: -------------------------------------------------------------------------------- 1 | 目前平台只支持MQTT/HTTP/LWM2M等标准协议接入,如果设备是其他协议(统称为第三方协议),我们推荐使用网关来完成协议转换,将第三方协议转成MQTT协议,从而实现泛协议接入华为物联网平台。原理请参考:。 2 | SDK提供了一个泛协议接入(tcp)的demo,可进入src/gateway_demo文件夹下,其中: 3 | 1. gateway_server_demo.c为泛协议网关demo,主要负责接收设备数据解码并上报到平台,同时可实现命令下发编码并发送到设备。 4 | 5 | 2. generic_tcp_protocol.c为tcp协议自定义编解码的规则,这里实现了收到平台下行各种数据自定义编码后发送给设备,以及设备的数据自定义解码后发送到平台。 6 | 7 | 3. gateway_client_demo.c为tcp设备(模拟客户端),主要负责上报数据与接收命令,上报的数据根据generic_tcp_protocol.c中定义的解码规则,通过gateway_server_demo.c上报到物联网平台;同时,物联网平台下发的命令通过generic_tcp_protocol.c中定义的编码规则,通过gateway_server_demo.c下发到设备。 8 | 9 | 体验步骤: 10 | 11 | 12 | 1. 将主目录下的产品模型(TTU_0916ca7d2bcd4ec98b2614062550b1c6_TTU01.zip)上传到物联网平台(可参考步骤3.4),并注册设备,保存设备ID和密钥。 13 | 14 | 2. 将保存的设备ID和密钥更新到gateway_server_demo.c中(跟device_demo同样的步骤)。 15 | 16 | 3. 将主目录下Makefile文件里OBJS中的device_demo.o注释掉,同时将generic_tcp_protocol.o gateway_server_demo.o放开。 17 | ![](./generic.PNG) 18 | 4. 编译 19 | 20 | make 21 | 22 | 5. 编译完成后导入lib 23 | 24 | export LD_LIBRARY_PATH=./lib/ 25 | 26 | 6. 运行网关 27 | 28 | ./MQTT_Demo 29 | 30 | 7. 进入到src/gateway_demo文件夹下,编译客户端 31 | 32 | gcc -o client.o gateway_client_demo.c 33 | 34 | 8. 运行客户端 35 | 36 | ./client.o 37 | 38 | 9、上报数据 39 | 40 | 运行客户端后,可在客户端控制台输入123,在网关控制台可以看到解码后的数据格式打印,同时在平台能看到上报的数据。可参考generic_tcp_protocol.c中的解码规则(DecodeServiceProperty函数,客户端上报的第一位为service,第二位为该service下的属性1的值,第三位为该service下的属性2的值。命令可参考EncodeCommandParas函数。)。 -------------------------------------------------------------------------------- /doc/doc_cn/getDown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/getDown.png -------------------------------------------------------------------------------- /doc/doc_cn/header_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/header_file.png -------------------------------------------------------------------------------- /doc/doc_cn/logLevel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/logLevel.png -------------------------------------------------------------------------------- /doc/doc_cn/logUp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/logUp.png -------------------------------------------------------------------------------- /doc/doc_cn/login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/login.png -------------------------------------------------------------------------------- /doc/doc_cn/makefile1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/makefile1.png -------------------------------------------------------------------------------- /doc/doc_cn/makefile2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/makefile2.png -------------------------------------------------------------------------------- /doc/doc_cn/messageDown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/messageDown.png -------------------------------------------------------------------------------- /doc/doc_cn/mode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/mode.png -------------------------------------------------------------------------------- /doc/doc_cn/no_asm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/no_asm.png -------------------------------------------------------------------------------- /doc/doc_cn/online.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/online.png -------------------------------------------------------------------------------- /doc/doc_cn/openssl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/openssl.png -------------------------------------------------------------------------------- /doc/doc_cn/paho.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/paho.png -------------------------------------------------------------------------------- /doc/doc_cn/paho64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/paho64.png -------------------------------------------------------------------------------- /doc/doc_cn/paho_makefile1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/paho_makefile1.png -------------------------------------------------------------------------------- /doc/doc_cn/paho_makefile2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/paho_makefile2.png -------------------------------------------------------------------------------- /doc/doc_cn/profile1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/profile1.png -------------------------------------------------------------------------------- /doc/doc_cn/profile2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/profile2.png -------------------------------------------------------------------------------- /doc/doc_cn/profile3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/profile3.png -------------------------------------------------------------------------------- /doc/doc_cn/profile4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/profile4.png -------------------------------------------------------------------------------- /doc/doc_cn/sdk_file_content.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/sdk_file_content.PNG -------------------------------------------------------------------------------- /doc/doc_cn/sdk_file_content2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/sdk_file_content2.PNG -------------------------------------------------------------------------------- /doc/doc_cn/sdk_file_content3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/sdk_file_content3.png -------------------------------------------------------------------------------- /doc/doc_cn/setDown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/setDown.png -------------------------------------------------------------------------------- /doc/doc_cn/so1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/so1.png -------------------------------------------------------------------------------- /doc/doc_cn/so2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/so2.png -------------------------------------------------------------------------------- /doc/doc_cn/so3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/so3.png -------------------------------------------------------------------------------- /doc/doc_cn/so4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/so4.png -------------------------------------------------------------------------------- /doc/doc_cn/ssh_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/ssh_1.png -------------------------------------------------------------------------------- /doc/doc_cn/ssh_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/ssh_2.png -------------------------------------------------------------------------------- /doc/doc_cn/sysHal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/sysHal.png -------------------------------------------------------------------------------- /doc/doc_cn/sysroot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/sysroot.png -------------------------------------------------------------------------------- /doc/doc_cn/untarPkg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/untarPkg.png -------------------------------------------------------------------------------- /doc/doc_cn/updateSubDevice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/updateSubDevice.png -------------------------------------------------------------------------------- /doc/doc_cn/删除+重发.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/删除+重发.png -------------------------------------------------------------------------------- /doc/doc_cn/存储.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/存储.png -------------------------------------------------------------------------------- /doc/doc_cn/端云安全通信1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/端云安全通信1.png -------------------------------------------------------------------------------- /doc/doc_cn/端云安全通信2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/端云安全通信2.png -------------------------------------------------------------------------------- /doc/doc_cn/网桥流程图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/网桥流程图.png -------------------------------------------------------------------------------- /doc/doc_cn/重连.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_cn/重连.png -------------------------------------------------------------------------------- /doc/doc_en/4_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/4_2.png -------------------------------------------------------------------------------- /doc/doc_en/4_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/4_3.png -------------------------------------------------------------------------------- /doc/doc_en/4_3_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/4_3_1.png -------------------------------------------------------------------------------- /doc/doc_en/4_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/4_4.png -------------------------------------------------------------------------------- /doc/doc_en/4_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/4_5.png -------------------------------------------------------------------------------- /doc/doc_en/4_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/4_6.png -------------------------------------------------------------------------------- /doc/doc_en/4_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/4_7.png -------------------------------------------------------------------------------- /doc/doc_en/4_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/4_8.png -------------------------------------------------------------------------------- /doc/doc_en/4_config_device_rule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/4_config_device_rule.png -------------------------------------------------------------------------------- /doc/doc_en/4_create_rule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/4_create_rule.png -------------------------------------------------------------------------------- /doc/doc_en/4_select_device_rule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/4_select_device_rule.png -------------------------------------------------------------------------------- /doc/doc_en/Device-Cloud-Security-Communication1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/Device-Cloud-Security-Communication1.png -------------------------------------------------------------------------------- /doc/doc_en/Device-Cloud-Security-Communication2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/Device-Cloud-Security-Communication2.png -------------------------------------------------------------------------------- /doc/doc_en/access_mqtt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/access_mqtt.png -------------------------------------------------------------------------------- /doc/doc_en/addSubDevice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/addSubDevice.png -------------------------------------------------------------------------------- /doc/doc_en/bootstrap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/bootstrap.png -------------------------------------------------------------------------------- /doc/doc_en/cmdDown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/cmdDown.png -------------------------------------------------------------------------------- /doc/doc_en/deleteSubDevice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/deleteSubDevice.png -------------------------------------------------------------------------------- /doc/doc_en/delete_and_resend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/delete_and_resend.png -------------------------------------------------------------------------------- /doc/doc_en/deviceProperties1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/deviceProperties1.png -------------------------------------------------------------------------------- /doc/doc_en/device_demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/device_demo.png -------------------------------------------------------------------------------- /doc/doc_en/generic.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/generic.PNG -------------------------------------------------------------------------------- /doc/doc_en/getDown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/getDown.png -------------------------------------------------------------------------------- /doc/doc_en/login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/login.png -------------------------------------------------------------------------------- /doc/doc_en/makefile1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/makefile1.png -------------------------------------------------------------------------------- /doc/doc_en/makefile2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/makefile2.png -------------------------------------------------------------------------------- /doc/doc_en/messageDown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/messageDown.png -------------------------------------------------------------------------------- /doc/doc_en/no_asm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/no_asm.png -------------------------------------------------------------------------------- /doc/doc_en/online.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/online.png -------------------------------------------------------------------------------- /doc/doc_en/openssl.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/openssl.PNG -------------------------------------------------------------------------------- /doc/doc_en/paho.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/paho.png -------------------------------------------------------------------------------- /doc/doc_en/paho64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/paho64.png -------------------------------------------------------------------------------- /doc/doc_en/paho_makefile1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/paho_makefile1.png -------------------------------------------------------------------------------- /doc/doc_en/paho_makefile2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/paho_makefile2.png -------------------------------------------------------------------------------- /doc/doc_en/profile1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/profile1.png -------------------------------------------------------------------------------- /doc/doc_en/profile2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/profile2.png -------------------------------------------------------------------------------- /doc/doc_en/profile3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/profile3.png -------------------------------------------------------------------------------- /doc/doc_en/profile4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/profile4.PNG -------------------------------------------------------------------------------- /doc/doc_en/reconnection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/reconnection.png -------------------------------------------------------------------------------- /doc/doc_en/sdk_file_content2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/sdk_file_content2.PNG -------------------------------------------------------------------------------- /doc/doc_en/setDown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/setDown.png -------------------------------------------------------------------------------- /doc/doc_en/so1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/so1.png -------------------------------------------------------------------------------- /doc/doc_en/so2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/so2.png -------------------------------------------------------------------------------- /doc/doc_en/so3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/so3.png -------------------------------------------------------------------------------- /doc/doc_en/so4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/so4.png -------------------------------------------------------------------------------- /doc/doc_en/ssh_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/ssh_1.png -------------------------------------------------------------------------------- /doc/doc_en/ssh_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/ssh_2.png -------------------------------------------------------------------------------- /doc/doc_en/storage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/storage.png -------------------------------------------------------------------------------- /doc/doc_en/sysroot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/sysroot.png -------------------------------------------------------------------------------- /doc/doc_en/untarPkg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/untarPkg.png -------------------------------------------------------------------------------- /doc/doc_en/upload_profile_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/upload_profile_1.png -------------------------------------------------------------------------------- /doc/doc_en/upload_profile_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/upload_profile_2.png -------------------------------------------------------------------------------- /doc/doc_en/upload_profile_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/upload_profile_3.png -------------------------------------------------------------------------------- /doc/doc_en/upload_profile_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/doc/doc_en/upload_profile_4.png -------------------------------------------------------------------------------- /generatingLib/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/generatingLib/README.md -------------------------------------------------------------------------------- /generatingLib/curl-8.4.0.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/generatingLib/curl-8.4.0.tar.gz -------------------------------------------------------------------------------- /generatingLib/generateOpenssl.sh: -------------------------------------------------------------------------------- 1 | tar -zxvf openssl-1.1.1h.tar.gz 2 | cd openssl-1.1.1h 3 | ./config shared 4 | make depend 5 | make 6 | make install 7 | -------------------------------------------------------------------------------- /generatingLib/generateZlib.sh: -------------------------------------------------------------------------------- 1 | unzip zlib-1.2.11.zip 2 | cd zlib-1.2.11 3 | ./configure 4 | make -------------------------------------------------------------------------------- /generatingLib/gmtls.patch.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/generatingLib/gmtls.patch.zip -------------------------------------------------------------------------------- /generatingLib/libboundscheck-master.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/generatingLib/libboundscheck-master.zip -------------------------------------------------------------------------------- /generatingLib/openssl-1.1.1h.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/generatingLib/openssl-1.1.1h.tar.gz -------------------------------------------------------------------------------- /generatingLib/paho.mqtt.c-1.3.9.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/generatingLib/paho.mqtt.c-1.3.9.tar.gz -------------------------------------------------------------------------------- /generatingLib/zlib-1.2.11.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/generatingLib/zlib-1.2.11.zip -------------------------------------------------------------------------------- /include/agentlite/hw_type.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef HW_TYPE_H 32 | #define HW_TYPE_H 33 | 34 | #if defined(WIN32) || defined(WIN64) && defined(EXPORT_AGENTLITE) 35 | #define HW_API_FUNC __declspec(dllexport) 36 | #else 37 | #define HW_API_FUNC 38 | #endif 39 | 40 | #define HW_TRUE 1 /**< Indicates true */ 41 | #define HW_FALSE 0 /**< Indicates false */ 42 | 43 | #define HW_SUCCESS 0 /**< Indicates success */ 44 | #define HW_FAILED 1 /**< Indicates failed */ 45 | #define HW_NULL ((void *)0) /**< Indicates null ptr */ 46 | 47 | typedef int HW_INT; /**< Indicates type of int. */ 48 | typedef unsigned int HW_UINT; /**< Indicates type of unsigned int. */ 49 | typedef char HW_CHAR; /**< Indicates type of char. */ 50 | typedef unsigned char HW_UCHAR;/**< Indicates type of unsigned char. */ 51 | typedef int HW_BOOL; /**< Indicates type of bool. */ 52 | typedef void HW_VOID; /**< Indicates type of void. */ 53 | typedef long HW_LONG; /**< Indicates type of bool. */ 54 | typedef double HW_DOUBLE; /**< Indicates type of bool. */ 55 | typedef long long HW_LLONG; /**< Indicates type of bool. */ 56 | 57 | /**< Indicates type of byte array. */ 58 | typedef struct { 59 | HW_UINT uiLen; /**< Indicates length of byte array */ 60 | HW_CHAR *pcByte; /**< Indicates byte value of byte array */ 61 | } HW_BYTES; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /include/agentlite/iota_defaultCallback.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2024 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef IOTA_CALLBACK_EXAMPLE 31 | #define IOTA_CALLBACK_EXAMPLE 32 | 33 | #define IOTA_DEFAULE_BACKOFF 1000 34 | #define IOTA_MIN_BACKOFF 1000 35 | #define IOTA_MAX_BACKOFF (30 * 1000) 36 | 37 | HW_API_FUNC HW_VOID IOTA_DefaultCallbackInit(); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /include/agentlite/iota_error_type.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef IOTA_ERROR_TYPE_H 32 | #define IOTA_ERROR_TYPE_H 33 | 34 | #define IOTA_SUCCESS (0) 35 | #define IOTA_FAILURE (-1) 36 | #define IOTA_PARAMETER_EMPTY (-101) 37 | #define IOTA_RESOURCE_NOT_AVAILABLE (-102) 38 | #define IOTA_INITIALIZATION_REPEATED (-103) 39 | #define IOTA_LIBRARY_LOAD_FAILED (-104) 40 | #define IOTA_SECRET_ENCRYPT_FAILED (-105) 41 | #define IOTA_MQTT_CONNECT_FAILED (-106) 42 | #define IOTA_MQTT_CONNECT_EXISTED (-107) 43 | #define IOTA_CERTIFICATE_NOT_FOUND (-108) 44 | #define IOTA_MQTT_DISCONNECT_FAILED (-109) 45 | #define IOTA_PARSE_JSON_FAILED (-110) 46 | #define IOTA_PARAMETER_ERROR (-111) 47 | #define IOTA_NUMBER_EXCEEDS (-112) 48 | #define IOTA_WSS_CONNECT_FAILED (-113) 49 | #define IOTA_THREAD_CREATE_FAILED (-114) 50 | 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /include/agentlite/iota_login.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef IOTA_LOGIN_H 32 | #define IOTA_LOGIN_H 33 | 34 | HW_API_FUNC HW_INT IOTA_Connect(void); 35 | HW_API_FUNC HW_INT IOTA_DisConnect(void); 36 | HW_API_FUNC HW_INT IOTA_IsConnected(void); 37 | 38 | /** 39 | * ----------------------------deprecated below--------------------------------------> 40 | */ 41 | #define IOTA_TOPIC_CONNECTED_NTY "IOTA_TOPIC_CONNECTED_NTY" 42 | #define IOTA_TOPIC_DISCONNECT_NTY "IOTA_TOPIC_DISCONNECT_NTY" 43 | 44 | /** Indicates notification parameters */ 45 | typedef enum { 46 | EN_IOTA_LGN_IE_REASON = 0, 47 | } EN_IOTA_LGN_IE_TYPE; 48 | 49 | typedef enum enum_IOTA_LOGIN_REASON_TYPE { 50 | EN_IOTA_LGN_REASON_NULL = 0, // EN_ULGN_REASON_NULL, 51 | EN_IOTA_LGN_REASON_CONNCET_ERR = 1, // 连接失败 = EN_ULGN_REASON_CONNCET_ERR, 52 | EN_IOTA_LGN_REASON_SERVER_BUSY = 2, // 服务器忙 = EN_ULGN_REASON_SERVER_BUSY, 53 | EN_IOTA_LGN_REASON_AUTH_FAILED = 3, // 鉴权失败 = EN_ULGN_REASON_AUTH_FAILED, 54 | EN_IOTA_LGN_REASON_NET_UNAVAILABLE = 5, // 网络不可用 = EN_ULGN_REASON_NET_UNAVAILABLE, 55 | EN_IOTA_LGN_REASON_DEVICE_NOEXIST = 12, // 设备不存在 = EN_ULGN_REASON_UNREG_USER, 56 | EN_IOTA_LGN_REASON_DEVICE_RMVED = 13, // 设备已删除 = EN_ULGN_REASON_RMVED_USER, 57 | EN_IOTA_LGN_REASON_UNKNOWN = 255 58 | } EN_IOTA_LGN_REASON_TYPE; 59 | 60 | #endif 61 | 62 | -------------------------------------------------------------------------------- /include/base/MQTTSubscribeOpts.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2018 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | * 13 | * Contributors: 14 | * Ian Craggs - initial API and implementation and/or initial documentation 15 | *******************************************************************************/ 16 | 17 | #if !defined(SUBOPTS_H) 18 | #define SUBOPTS_H 19 | 20 | /** The MQTT V5 subscribe options, apart from QoS which existed before V5. */ 21 | typedef struct MQTTSubscribe_options 22 | { 23 | /** The eyecatcher for this structure. Must be MQSO. */ 24 | char struct_id[4]; 25 | /** The version number of this structure. Must be 0. 26 | */ 27 | int struct_version; 28 | /** To not receive our own publications, set to 1. 29 | * 0 is the original MQTT behaviour - all messages matching the subscription are received. 30 | */ 31 | unsigned char noLocal; 32 | /** To keep the retain flag as on the original publish message, set to 1. 33 | * If 0, defaults to the original MQTT behaviour where the retain flag is only set on 34 | * publications sent by a broker if in response to a subscribe request. 35 | */ 36 | unsigned char retainAsPublished; 37 | /** 0 - send retained messages at the time of the subscribe (original MQTT behaviour) 38 | * 1 - send retained messages on subscribe only if the subscription is new 39 | * 2 - do not send retained messages at all 40 | */ 41 | unsigned char retainHandling; 42 | } MQTTSubscribe_options; 43 | 44 | #define MQTTSubscribe_options_initializer { {'M', 'Q', 'S', 'O'}, 0, 0, 0, 0 } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /include/base/hmac_sha256.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef HAMC_SHA256_H 32 | #define HAMC_SHA256_H 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /* failed return -1, success return 0 */ 39 | int EncryptWithHMac(const char *inputData, char **inputKey, int inEncryDataLen, char *outData, int checkTimestamp); 40 | unsigned char *base64_encode(unsigned char *str); 41 | unsigned char *base64_decode(unsigned char *code); 42 | 43 | #define TIME_STAMP_LENGTH 10 44 | #define TRY_MAX_TIME 100 45 | #define SHA256_ENCRYPTION_LENGRH 32 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* HAMC_SHA256_H */ 52 | -------------------------------------------------------------------------------- /include/curl/header.h: -------------------------------------------------------------------------------- 1 | #ifndef CURLINC_HEADER_H 2 | #define CURLINC_HEADER_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | * SPDX-License-Identifier: curl 24 | * 25 | ***************************************************************************/ 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | struct curl_header { 32 | char *name; /* this might not use the same case */ 33 | char *value; 34 | size_t amount; /* number of headers using this name */ 35 | size_t index; /* ... of this instance, 0 or higher */ 36 | unsigned int origin; /* see bits below */ 37 | void *anchor; /* handle privately used by libcurl */ 38 | }; 39 | 40 | /* 'origin' bits */ 41 | #define CURLH_HEADER (1<<0) /* plain server header */ 42 | #define CURLH_TRAILER (1<<1) /* trailers */ 43 | #define CURLH_CONNECT (1<<2) /* CONNECT headers */ 44 | #define CURLH_1XX (1<<3) /* 1xx headers */ 45 | #define CURLH_PSEUDO (1<<4) /* pseudo headers */ 46 | 47 | typedef enum { 48 | CURLHE_OK, 49 | CURLHE_BADINDEX, /* header exists but not with this index */ 50 | CURLHE_MISSING, /* no such header exists */ 51 | CURLHE_NOHEADERS, /* no headers at all exist (yet) */ 52 | CURLHE_NOREQUEST, /* no request with this number was used */ 53 | CURLHE_OUT_OF_MEMORY, /* out of memory while processing */ 54 | CURLHE_BAD_ARGUMENT, /* a function argument was not okay */ 55 | CURLHE_NOT_BUILT_IN /* if API was disabled in the build */ 56 | } CURLHcode; 57 | 58 | CURL_EXTERN CURLHcode curl_easy_header(CURL *easy, 59 | const char *name, 60 | size_t index, 61 | unsigned int origin, 62 | int request, 63 | struct curl_header **hout); 64 | 65 | CURL_EXTERN struct curl_header *curl_easy_nextheader(CURL *easy, 66 | unsigned int origin, 67 | int request, 68 | struct curl_header *prev); 69 | 70 | #ifdef __cplusplus 71 | } /* end of extern "C" */ 72 | #endif 73 | 74 | #endif /* CURLINC_HEADER_H */ 75 | -------------------------------------------------------------------------------- /include/curl/mprintf.h: -------------------------------------------------------------------------------- 1 | #ifndef CURLINC_MPRINTF_H 2 | #define CURLINC_MPRINTF_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | * SPDX-License-Identifier: curl 24 | * 25 | ***************************************************************************/ 26 | 27 | #include 28 | #include /* needed for FILE */ 29 | #include "curl.h" /* for CURL_EXTERN */ 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | #if (defined(__GNUC__) || defined(__clang__)) && \ 36 | defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ 37 | !defined(__MINGW32__) && !defined(CURL_NO_FMT_CHECKS) 38 | #define CURL_TEMP_PRINTF(a,b) __attribute__ ((format(printf, a, b))) 39 | #else 40 | #define CURL_TEMP_PRINTF(a,b) 41 | #endif 42 | 43 | CURL_EXTERN int curl_mprintf(const char *format, ...) CURL_TEMP_PRINTF(1, 2); 44 | CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...) 45 | CURL_TEMP_PRINTF(2, 3); 46 | CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...) 47 | CURL_TEMP_PRINTF(2, 3); 48 | CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength, 49 | const char *format, ...) CURL_TEMP_PRINTF(3, 4); 50 | CURL_EXTERN int curl_mvprintf(const char *format, va_list args) 51 | CURL_TEMP_PRINTF(1, 0); 52 | CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args) 53 | CURL_TEMP_PRINTF(2, 0); 54 | CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args) 55 | CURL_TEMP_PRINTF(2, 0); 56 | CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength, 57 | const char *format, va_list args) 58 | CURL_TEMP_PRINTF(3, 0); 59 | CURL_EXTERN char *curl_maprintf(const char *format, ...) 60 | CURL_TEMP_PRINTF(1, 2); 61 | CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args) 62 | CURL_TEMP_PRINTF(1, 0); 63 | 64 | #undef CURL_TEMP_PRINTF 65 | 66 | #ifdef __cplusplus 67 | } /* end of extern "C" */ 68 | #endif 69 | 70 | #endif /* CURLINC_MPRINTF_H */ 71 | -------------------------------------------------------------------------------- /include/curl/options.h: -------------------------------------------------------------------------------- 1 | #ifndef CURLINC_OPTIONS_H 2 | #define CURLINC_OPTIONS_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | * SPDX-License-Identifier: curl 24 | * 25 | ***************************************************************************/ 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | typedef enum { 32 | CURLOT_LONG, /* long (a range of values) */ 33 | CURLOT_VALUES, /* (a defined set or bitmask) */ 34 | CURLOT_OFF_T, /* curl_off_t (a range of values) */ 35 | CURLOT_OBJECT, /* pointer (void *) */ 36 | CURLOT_STRING, /* (char * to null-terminated buffer) */ 37 | CURLOT_SLIST, /* (struct curl_slist *) */ 38 | CURLOT_CBPTR, /* (void * passed as-is to a callback) */ 39 | CURLOT_BLOB, /* blob (struct curl_blob *) */ 40 | CURLOT_FUNCTION /* function pointer */ 41 | } curl_easytype; 42 | 43 | /* Flag bits */ 44 | 45 | /* "alias" means it is provided for old programs to remain functional, 46 | we prefer another name */ 47 | #define CURLOT_FLAG_ALIAS (1<<0) 48 | 49 | /* The CURLOPTTYPE_* id ranges can still be used to figure out what type/size 50 | to use for curl_easy_setopt() for the given id */ 51 | struct curl_easyoption { 52 | const char *name; 53 | CURLoption id; 54 | curl_easytype type; 55 | unsigned int flags; 56 | }; 57 | 58 | CURL_EXTERN const struct curl_easyoption * 59 | curl_easy_option_by_name(const char *name); 60 | 61 | CURL_EXTERN const struct curl_easyoption * 62 | curl_easy_option_by_id(CURLoption id); 63 | 64 | CURL_EXTERN const struct curl_easyoption * 65 | curl_easy_option_next(const struct curl_easyoption *prev); 66 | 67 | #ifdef __cplusplus 68 | } /* end of extern "C" */ 69 | #endif 70 | #endif /* CURLINC_OPTIONS_H */ 71 | -------------------------------------------------------------------------------- /include/curl/stdcheaders.h: -------------------------------------------------------------------------------- 1 | #ifndef CURLINC_STDCHEADERS_H 2 | #define CURLINC_STDCHEADERS_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | * SPDX-License-Identifier: curl 24 | * 25 | ***************************************************************************/ 26 | 27 | #include 28 | 29 | size_t fread(void *, size_t, size_t, FILE *); 30 | size_t fwrite(const void *, size_t, size_t, FILE *); 31 | 32 | int strcasecmp(const char *, const char *); 33 | int strncasecmp(const char *, const char *, size_t); 34 | 35 | #endif /* CURLINC_STDCHEADERS_H */ 36 | -------------------------------------------------------------------------------- /include/curl/websockets.h: -------------------------------------------------------------------------------- 1 | #ifndef CURLINC_WEBSOCKETS_H 2 | #define CURLINC_WEBSOCKETS_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | * SPDX-License-Identifier: curl 24 | * 25 | ***************************************************************************/ 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | struct curl_ws_frame { 32 | int age; /* zero */ 33 | int flags; /* See the CURLWS_* defines */ 34 | curl_off_t offset; /* the offset of this data into the frame */ 35 | curl_off_t bytesleft; /* number of pending bytes left of the payload */ 36 | size_t len; /* size of the current data chunk */ 37 | }; 38 | 39 | /* flag bits */ 40 | #define CURLWS_TEXT (1<<0) 41 | #define CURLWS_BINARY (1<<1) 42 | #define CURLWS_CONT (1<<2) 43 | #define CURLWS_CLOSE (1<<3) 44 | #define CURLWS_PING (1<<4) 45 | #define CURLWS_OFFSET (1<<5) 46 | 47 | /* 48 | * NAME curl_ws_recv() 49 | * 50 | * DESCRIPTION 51 | * 52 | * Receives data from the websocket connection. Use after successful 53 | * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. 54 | */ 55 | CURL_EXTERN CURLcode curl_ws_recv(CURL *curl, void *buffer, size_t buflen, 56 | size_t *recv, 57 | const struct curl_ws_frame **metap); 58 | 59 | /* flags for curl_ws_send() */ 60 | #define CURLWS_PONG (1<<6) 61 | 62 | /* 63 | * NAME curl_ws_send() 64 | * 65 | * DESCRIPTION 66 | * 67 | * Sends data over the websocket connection. Use after successful 68 | * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. 69 | */ 70 | CURL_EXTERN CURLcode curl_ws_send(CURL *curl, const void *buffer, 71 | size_t buflen, size_t *sent, 72 | curl_off_t fragsize, 73 | unsigned int flags); 74 | 75 | /* bits for the CURLOPT_WS_OPTIONS bitmask: */ 76 | #define CURLWS_RAW_MODE (1<<0) 77 | 78 | CURL_EXTERN const struct curl_ws_frame *curl_ws_meta(CURL *curl); 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | 84 | #endif /* CURLINC_WEBSOCKETS_H */ 85 | -------------------------------------------------------------------------------- /include/libssh/libssh_version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2020 by Heiko Thiery 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef _LIBSSH_VERSION_H 22 | #define _LIBSSH_VERSION_H 23 | 24 | /* libssh version macros */ 25 | #define SSH_VERSION_INT(a, b, c) ((a) << 16 | (b) << 8 | (c)) 26 | #define SSH_VERSION_DOT(a, b, c) a ##.## b ##.## c 27 | #define SSH_VERSION(a, b, c) SSH_VERSION_DOT(a, b, c) 28 | 29 | /* libssh version */ 30 | #define LIBSSH_VERSION_MAJOR 0 31 | #define LIBSSH_VERSION_MINOR 10 32 | #define LIBSSH_VERSION_MICRO 4 33 | 34 | #define LIBSSH_VERSION_INT SSH_VERSION_INT(LIBSSH_VERSION_MAJOR, \ 35 | LIBSSH_VERSION_MINOR, \ 36 | LIBSSH_VERSION_MICRO) 37 | #define LIBSSH_VERSION SSH_VERSION(LIBSSH_VERSION_MAJOR, \ 38 | LIBSSH_VERSION_MINOR, \ 39 | LIBSSH_VERSION_MICRO) 40 | 41 | #endif /* _LIBSSH_VERSION_H */ 42 | -------------------------------------------------------------------------------- /include/libssh/ssh2.h: -------------------------------------------------------------------------------- 1 | #ifndef __SSH2_H 2 | #define __SSH2_H 3 | 4 | #define SSH2_MSG_DISCONNECT 1 5 | #define SSH2_MSG_IGNORE 2 6 | #define SSH2_MSG_UNIMPLEMENTED 3 7 | #define SSH2_MSG_DEBUG 4 8 | #define SSH2_MSG_SERVICE_REQUEST 5 9 | #define SSH2_MSG_SERVICE_ACCEPT 6 10 | #define SSH2_MSG_EXT_INFO 7 11 | 12 | #define SSH2_MSG_KEXINIT 20 13 | #define SSH2_MSG_NEWKEYS 21 14 | 15 | #define SSH2_MSG_KEXDH_INIT 30 16 | #define SSH2_MSG_KEXDH_REPLY 31 17 | #define SSH2_MSG_KEX_ECDH_INIT 30 18 | #define SSH2_MSG_KEX_ECDH_REPLY 31 19 | #define SSH2_MSG_ECMQV_INIT 30 20 | #define SSH2_MSG_ECMQV_REPLY 31 21 | 22 | #define SSH2_MSG_KEX_DH_GEX_REQUEST_OLD 30 23 | #define SSH2_MSG_KEX_DH_GEX_GROUP 31 24 | #define SSH2_MSG_KEX_DH_GEX_INIT 32 25 | #define SSH2_MSG_KEX_DH_GEX_REPLY 33 26 | #define SSH2_MSG_KEX_DH_GEX_REQUEST 34 27 | #define SSH2_MSG_USERAUTH_REQUEST 50 28 | #define SSH2_MSG_USERAUTH_FAILURE 51 29 | #define SSH2_MSG_USERAUTH_SUCCESS 52 30 | #define SSH2_MSG_USERAUTH_BANNER 53 31 | #define SSH2_MSG_USERAUTH_PK_OK 60 32 | #define SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ 60 33 | #define SSH2_MSG_USERAUTH_INFO_REQUEST 60 34 | #define SSH2_MSG_USERAUTH_GSSAPI_RESPONSE 60 35 | #define SSH2_MSG_USERAUTH_INFO_RESPONSE 61 36 | #define SSH2_MSG_USERAUTH_GSSAPI_TOKEN 61 37 | #define SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE 63 38 | #define SSH2_MSG_USERAUTH_GSSAPI_ERROR 64 39 | #define SSH2_MSG_USERAUTH_GSSAPI_ERRTOK 65 40 | #define SSH2_MSG_USERAUTH_GSSAPI_MIC 66 41 | 42 | #define SSH2_MSG_GLOBAL_REQUEST 80 43 | #define SSH2_MSG_REQUEST_SUCCESS 81 44 | #define SSH2_MSG_REQUEST_FAILURE 82 45 | #define SSH2_MSG_CHANNEL_OPEN 90 46 | #define SSH2_MSG_CHANNEL_OPEN_CONFIRMATION 91 47 | #define SSH2_MSG_CHANNEL_OPEN_FAILURE 92 48 | #define SSH2_MSG_CHANNEL_WINDOW_ADJUST 93 49 | #define SSH2_MSG_CHANNEL_DATA 94 50 | #define SSH2_MSG_CHANNEL_EXTENDED_DATA 95 51 | #define SSH2_MSG_CHANNEL_EOF 96 52 | #define SSH2_MSG_CHANNEL_CLOSE 97 53 | #define SSH2_MSG_CHANNEL_REQUEST 98 54 | #define SSH2_MSG_CHANNEL_SUCCESS 99 55 | #define SSH2_MSG_CHANNEL_FAILURE 100 56 | 57 | #define SSH2_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT 1 58 | #define SSH2_DISCONNECT_PROTOCOL_ERROR 2 59 | #define SSH2_DISCONNECT_KEY_EXCHANGE_FAILED 3 60 | #define SSH2_DISCONNECT_HOST_AUTHENTICATION_FAILED 4 61 | #define SSH2_DISCONNECT_RESERVED 4 62 | #define SSH2_DISCONNECT_MAC_ERROR 5 63 | #define SSH2_DISCONNECT_COMPRESSION_ERROR 6 64 | #define SSH2_DISCONNECT_SERVICE_NOT_AVAILABLE 7 65 | #define SSH2_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED 8 66 | #define SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE 9 67 | #define SSH2_DISCONNECT_CONNECTION_LOST 10 68 | #define SSH2_DISCONNECT_BY_APPLICATION 11 69 | #define SSH2_DISCONNECT_TOO_MANY_CONNECTIONS 12 70 | #define SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER 13 71 | #define SSH2_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE 14 72 | #define SSH2_DISCONNECT_ILLEGAL_USER_NAME 15 73 | 74 | #define SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED 1 75 | #define SSH2_OPEN_CONNECT_FAILED 2 76 | #define SSH2_OPEN_UNKNOWN_CHANNEL_TYPE 3 77 | #define SSH2_OPEN_RESOURCE_SHORTAGE 4 78 | 79 | #define SSH2_EXTENDED_DATA_STDERR 1 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /include/nopoll/nopoll_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Nopoll Library nopoll_config.h 3 | * Platform dependant definitions. 4 | * 5 | * This is a generated file. Please modify 'configure.in' 6 | */ 7 | 8 | #ifndef __NOPOLL_CONFIG_H__ 9 | #define __NOPOLL_CONFIG_H__ 10 | 11 | /** 12 | * \addtogroup nopoll_decl_module 13 | * @{ 14 | */ 15 | 16 | /** 17 | * @brief Allows to convert integer value (including constant values) 18 | * into a pointer representation. 19 | * 20 | * Use the oposite function to restore the value from a pointer to a 21 | * integer: \ref PTR_TO_INT. 22 | * 23 | * @param integer The integer value to cast to pointer. 24 | * 25 | * @return A \ref noPollPtr reference. 26 | */ 27 | #ifndef INT_TO_PTR 28 | #define INT_TO_PTR(integer) ((noPollPtr) (long) ((int)integer)) 29 | #endif 30 | 31 | /** 32 | * @brief Allows to convert a pointer reference (\ref noPollPtr), 33 | * which stores an integer that was stored using \ref INT_TO_PTR. 34 | * 35 | * Use the oposite function to restore the pointer value stored in the 36 | * integer value. 37 | * 38 | * @param ptr The pointer to cast to a integer value. 39 | * 40 | * @return A int value. 41 | */ 42 | #ifndef PTR_TO_INT 43 | #define PTR_TO_INT(ptr) ((int) (long) (ptr)) 44 | #endif 45 | 46 | /** 47 | * @brief Allows to get current platform configuration. This is used 48 | * by Nopoll library but could be used by applications built on top of 49 | * Nopoll to change its configuration based on the platform information. 50 | */ 51 | #define NOPOLL_OS_UNIX (1) 52 | 53 | /** 54 | * @internal Allows to now if the platform support vasprintf 55 | * function. Do not use this macro as it is supposed to be for 56 | * internal use. 57 | */ 58 | #define NOPOLL_HAVE_VASPRINTF (1) 59 | 60 | /** 61 | * @brief Indicates that this platform have support for 64bits. 62 | */ 63 | #define NOPOLL_64BIT_PLATFORM (1) 64 | 65 | 66 | 67 | /** 68 | * @brief Indicates where we have support for SSL v3.0 support. The SSLv3 protocol is deprecated and should not be used. 69 | */ 70 | #define NOPOLL_HAVE_SSLv3_ENABLED (1) 71 | 72 | /** 73 | * @brief Indicates where we have support for TLSv1.0 support. 74 | */ 75 | #define NOPOLL_HAVE_TLSv10_ENABLED (1) 76 | 77 | /** 78 | * @brief Indicates where we have support for TLSv1.1 support. 79 | */ 80 | #define NOPOLL_HAVE_TLSv11_ENABLED (1) 81 | 82 | /** 83 | * @brief Indicates where we have support for TLSv1.2 support. 84 | */ 85 | #define NOPOLL_HAVE_TLSv12_ENABLED (1) 86 | 87 | /** 88 | * @brief Indicates where we have support for TLS flexible method where the highest TLS version will be negotiated. 89 | */ 90 | #define NOPOLL_HAVE_TLS_FLEXIBLE_ENABLED (1) 91 | 92 | /* @} */ 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /include/nopoll/nopoll_io.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LibNoPoll: A websocket library 3 | * Copyright (C) 2022 Advanced Software Production Line, S.L. 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public License 7 | * as published by the Free Software Foundation; either version 2.1 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this program; if not, write to the Free 17 | * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | * 02111-1307 USA 19 | * 20 | * You may find a copy of the license under this software is released 21 | * at COPYING file. This is LGPL software: you are welcome to develop 22 | * proprietary applications using this library without any royalty or 23 | * fee but returning back any change, improvement or addition in the 24 | * form of source code, project image, documentation patches, etc. 25 | * 26 | * For commercial support on build Websocket enabled solutions 27 | * contact us: 28 | * 29 | * Postal address: 30 | * Advanced Software Production Line, S.L. 31 | * Av. Juan Carlos I, Nº13, 2ºC 32 | * Alcalá de Henares 28806 Madrid 33 | * Spain 34 | * 35 | * Email address: 36 | * info@aspl.es - http://www.aspl.es/nopoll 37 | */ 38 | #ifndef __NOPOLL_IO_H__ 39 | #define __NOPOLL_IO_H__ 40 | 41 | #include 42 | 43 | BEGIN_C_DECLS 44 | 45 | noPollIoEngine * nopoll_io_get_engine (noPollCtx * ctx, noPollIoEngineType engine_type); 46 | 47 | void nopoll_io_release_engine (noPollIoEngine * engine); 48 | 49 | END_C_DECLS 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/nopoll/nopoll_loop.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LibNoPoll: A websocket library 3 | * Copyright (C) 2022 Advanced Software Production Line, S.L. 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public License 7 | * as published by the Free Software Foundation; either version 2.1 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this program; if not, write to the Free 17 | * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | * 02111-1307 USA 19 | * 20 | * You may find a copy of the license under this software is released 21 | * at COPYING file. This is LGPL software: you are welcome to develop 22 | * proprietary applications using this library without any royalty or 23 | * fee but returning back any change, improvement or addition in the 24 | * form of source code, project image, documentation patches, etc. 25 | * 26 | * For commercial support on build Websocket enabled solutions 27 | * contact us: 28 | * 29 | * Postal address: 30 | * Advanced Software Production Line, S.L. 31 | * Av. Juan Carlos I, Nº13, 2ºC 32 | * Alcalá de Henares 28806 Madrid 33 | * Spain 34 | * 35 | * Email address: 36 | * info@aspl.es - http://www.aspl.es/nopoll 37 | */ 38 | #ifndef __NOPOLL_LOOP_H__ 39 | #define __NOPOLL_LOOP_H__ 40 | 41 | #include 42 | 43 | BEGIN_C_DECLS 44 | 45 | int nopoll_loop_wait (noPollCtx * ctx, long timeout); 46 | 47 | void nopoll_loop_stop (noPollCtx * ctx); 48 | 49 | END_C_DECLS 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/nopoll/nopoll_msg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LibNoPoll: A websocket library 3 | * Copyright (C) 2022 Advanced Software Production Line, S.L. 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public License 7 | * as published by the Free Software Foundation; either version 2.1 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this program; if not, write to the Free 17 | * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | * 02111-1307 USA 19 | * 20 | * You may find a copy of the license under this software is released 21 | * at COPYING file. This is LGPL software: you are welcome to develop 22 | * proprietary applications using this library without any royalty or 23 | * fee but returning back any change, improvement or addition in the 24 | * form of source code, project image, documentation patches, etc. 25 | * 26 | * For commercial support on build Websocket enabled solutions 27 | * contact us: 28 | * 29 | * Postal address: 30 | * Advanced Software Production Line, S.L. 31 | * Av. Juan Carlos I, Nº13, 2ºC 32 | * Alcalá de Henares 28806 Madrid 33 | * Spain 34 | * 35 | * Email address: 36 | * info@aspl.es - http://www.aspl.es/nopoll 37 | */ 38 | #ifndef __NOPOLL_MSG_H__ 39 | #define __NOPOLL_MSG_H__ 40 | 41 | #include 42 | 43 | BEGIN_C_DECLS 44 | 45 | const unsigned char * nopoll_msg_get_payload (noPollMsg * msg); 46 | 47 | int nopoll_msg_get_payload_size (noPollMsg * msg); 48 | 49 | noPollMsg * nopoll_msg_new (void); 50 | 51 | nopoll_bool nopoll_msg_ref (noPollMsg * msg); 52 | 53 | int nopoll_msg_ref_count (noPollMsg * msg); 54 | 55 | nopoll_bool nopoll_msg_is_final (noPollMsg * msg); 56 | 57 | nopoll_bool nopoll_msg_is_fragment (noPollMsg * msg); 58 | 59 | noPollOpCode nopoll_msg_opcode (noPollMsg * msg); 60 | 61 | noPollMsg * nopoll_msg_join (noPollMsg * msg, noPollMsg * msg2); 62 | 63 | void nopoll_msg_unref (noPollMsg * msg); 64 | 65 | END_C_DECLS 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /include/nopoll/nopoll_win32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LibNoPoll: A websocket library 3 | * Copyright (C) 2022 Advanced Software Production Line, S.L. 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public License 7 | * as published by the Free Software Foundation; either version 2.1 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this program; if not, write to the Free 17 | * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | * 02111-1307 USA 19 | * 20 | * You may find a copy of the license under this software is released 21 | * at COPYING file. This is LGPL software: you are welcome to develop 22 | * proprietary applications using this library without any royalty or 23 | * fee but returning back any change, improvement or addition in the 24 | * form of source code, project image, documentation patches, etc. 25 | * 26 | * For commercial support on build Websocket enabled solutions 27 | * contact us: 28 | * 29 | * Postal address: 30 | * Advanced Software Production Line, S.L. 31 | * Av. Juan Carlos I, Nº13, 2ºC 32 | * Alcalá de Henares 28806 Madrid 33 | * Spain 34 | * 35 | * Email address: 36 | * info@aspl.es - http://www.aspl.es/nopoll 37 | */ 38 | 39 | #ifndef __NOPOLL_WIN32_H__ 40 | #define __NOPOLL_WIN32_H__ 41 | 42 | #include 43 | 44 | BEGIN_C_DECLS 45 | 46 | int nopoll_win32_init (noPollCtx * ctx); 47 | 48 | int nopoll_win32_nonblocking_enable (NOPOLL_SOCKET socket); 49 | 50 | int nopoll_win32_blocking_enable (NOPOLL_SOCKET socket); 51 | 52 | /* gettimeofday support on windows */ 53 | int nopoll_win32_gettimeofday (struct timeval *tv, noPollPtr notUsed); 54 | 55 | BOOL APIENTRY DllMain (HINSTANCE hInst, 56 | DWORD reason, 57 | LPVOID reserved); 58 | 59 | #if !defined(EINPROGRESS) 60 | #define EINPROGRESS (WSAEINPROGRESS) 61 | #endif 62 | 63 | END_C_DECLS 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /include/openssl/async.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #include 11 | 12 | #ifndef HEADER_ASYNC_H 13 | # define HEADER_ASYNC_H 14 | 15 | #if defined(_WIN32) 16 | # if defined(BASETYPES) || defined(_WINDEF_H) 17 | /* application has to include to use this */ 18 | #define OSSL_ASYNC_FD HANDLE 19 | #define OSSL_BAD_ASYNC_FD INVALID_HANDLE_VALUE 20 | # endif 21 | #else 22 | #define OSSL_ASYNC_FD int 23 | #define OSSL_BAD_ASYNC_FD -1 24 | #endif 25 | # include 26 | 27 | 28 | # ifdef __cplusplus 29 | extern "C" { 30 | # endif 31 | 32 | typedef struct async_job_st ASYNC_JOB; 33 | typedef struct async_wait_ctx_st ASYNC_WAIT_CTX; 34 | 35 | #define ASYNC_ERR 0 36 | #define ASYNC_NO_JOBS 1 37 | #define ASYNC_PAUSE 2 38 | #define ASYNC_FINISH 3 39 | 40 | int ASYNC_init_thread(size_t max_size, size_t init_size); 41 | void ASYNC_cleanup_thread(void); 42 | 43 | #ifdef OSSL_ASYNC_FD 44 | ASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void); 45 | void ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx); 46 | int ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key, 47 | OSSL_ASYNC_FD fd, 48 | void *custom_data, 49 | void (*cleanup)(ASYNC_WAIT_CTX *, const void *, 50 | OSSL_ASYNC_FD, void *)); 51 | int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key, 52 | OSSL_ASYNC_FD *fd, void **custom_data); 53 | int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd, 54 | size_t *numfds); 55 | int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd, 56 | size_t *numaddfds, OSSL_ASYNC_FD *delfd, 57 | size_t *numdelfds); 58 | int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key); 59 | #endif 60 | 61 | int ASYNC_is_capable(void); 62 | 63 | int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret, 64 | int (*func)(void *), void *args, size_t size); 65 | int ASYNC_pause_job(void); 66 | 67 | ASYNC_JOB *ASYNC_get_current_job(void); 68 | ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job); 69 | void ASYNC_block_pause(void); 70 | void ASYNC_unblock_pause(void); 71 | 72 | 73 | # ifdef __cplusplus 74 | } 75 | # endif 76 | #endif 77 | -------------------------------------------------------------------------------- /include/openssl/asyncerr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by util/mkerr.pl DO NOT EDIT 3 | * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. 4 | * 5 | * Licensed under the OpenSSL license (the "License"). You may not use 6 | * this file except in compliance with the License. You can obtain a copy 7 | * in the file LICENSE in the source distribution or at 8 | * https://www.openssl.org/source/license.html 9 | */ 10 | 11 | #ifndef HEADER_ASYNCERR_H 12 | # define HEADER_ASYNCERR_H 13 | 14 | # ifndef HEADER_SYMHACKS_H 15 | # include 16 | # endif 17 | 18 | # ifdef __cplusplus 19 | extern "C" 20 | # endif 21 | int ERR_load_ASYNC_strings(void); 22 | 23 | /* 24 | * ASYNC function codes. 25 | */ 26 | # define ASYNC_F_ASYNC_CTX_NEW 100 27 | # define ASYNC_F_ASYNC_INIT_THREAD 101 28 | # define ASYNC_F_ASYNC_JOB_NEW 102 29 | # define ASYNC_F_ASYNC_PAUSE_JOB 103 30 | # define ASYNC_F_ASYNC_START_FUNC 104 31 | # define ASYNC_F_ASYNC_START_JOB 105 32 | # define ASYNC_F_ASYNC_WAIT_CTX_SET_WAIT_FD 106 33 | 34 | /* 35 | * ASYNC reason codes. 36 | */ 37 | # define ASYNC_R_FAILED_TO_SET_POOL 101 38 | # define ASYNC_R_FAILED_TO_SWAP_CONTEXT 102 39 | # define ASYNC_R_INIT_FAILED 105 40 | # define ASYNC_R_INVALID_POOL_SIZE 103 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /include/openssl/buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_BUFFER_H 11 | # define HEADER_BUFFER_H 12 | 13 | # include 14 | # ifndef HEADER_CRYPTO_H 15 | # include 16 | # endif 17 | # include 18 | 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | # include 25 | # include 26 | 27 | /* 28 | * These names are outdated as of OpenSSL 1.1; a future release 29 | * will move them to be deprecated. 30 | */ 31 | # define BUF_strdup(s) OPENSSL_strdup(s) 32 | # define BUF_strndup(s, size) OPENSSL_strndup(s, size) 33 | # define BUF_memdup(data, size) OPENSSL_memdup(data, size) 34 | # define BUF_strlcpy(dst, src, size) OPENSSL_strlcpy(dst, src, size) 35 | # define BUF_strlcat(dst, src, size) OPENSSL_strlcat(dst, src, size) 36 | # define BUF_strnlen(str, maxlen) OPENSSL_strnlen(str, maxlen) 37 | 38 | struct buf_mem_st { 39 | size_t length; /* current number of bytes */ 40 | char *data; 41 | size_t max; /* size of buffer */ 42 | unsigned long flags; 43 | }; 44 | 45 | # define BUF_MEM_FLAG_SECURE 0x01 46 | 47 | BUF_MEM *BUF_MEM_new(void); 48 | BUF_MEM *BUF_MEM_new_ex(unsigned long flags); 49 | void BUF_MEM_free(BUF_MEM *a); 50 | size_t BUF_MEM_grow(BUF_MEM *str, size_t len); 51 | size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len); 52 | void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz); 53 | 54 | 55 | # ifdef __cplusplus 56 | } 57 | # endif 58 | #endif 59 | -------------------------------------------------------------------------------- /include/openssl/buffererr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by util/mkerr.pl DO NOT EDIT 3 | * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. 4 | * 5 | * Licensed under the OpenSSL license (the "License"). You may not use 6 | * this file except in compliance with the License. You can obtain a copy 7 | * in the file LICENSE in the source distribution or at 8 | * https://www.openssl.org/source/license.html 9 | */ 10 | 11 | #ifndef HEADER_BUFERR_H 12 | # define HEADER_BUFERR_H 13 | 14 | # ifndef HEADER_SYMHACKS_H 15 | # include 16 | # endif 17 | 18 | # ifdef __cplusplus 19 | extern "C" 20 | # endif 21 | int ERR_load_BUF_strings(void); 22 | 23 | /* 24 | * BUF function codes. 25 | */ 26 | # define BUF_F_BUF_MEM_GROW 100 27 | # define BUF_F_BUF_MEM_GROW_CLEAN 105 28 | # define BUF_F_BUF_MEM_NEW 101 29 | 30 | /* 31 | * BUF reason codes. 32 | */ 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /include/openssl/comp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_COMP_H 11 | # define HEADER_COMP_H 12 | 13 | # include 14 | 15 | # ifndef OPENSSL_NO_COMP 16 | # include 17 | # include 18 | # ifdef __cplusplus 19 | extern "C" { 20 | # endif 21 | 22 | 23 | 24 | COMP_CTX *COMP_CTX_new(COMP_METHOD *meth); 25 | const COMP_METHOD *COMP_CTX_get_method(const COMP_CTX *ctx); 26 | int COMP_CTX_get_type(const COMP_CTX* comp); 27 | int COMP_get_type(const COMP_METHOD *meth); 28 | const char *COMP_get_name(const COMP_METHOD *meth); 29 | void COMP_CTX_free(COMP_CTX *ctx); 30 | 31 | int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, 32 | unsigned char *in, int ilen); 33 | int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, 34 | unsigned char *in, int ilen); 35 | 36 | COMP_METHOD *COMP_zlib(void); 37 | 38 | #if OPENSSL_API_COMPAT < 0x10100000L 39 | #define COMP_zlib_cleanup() while(0) continue 40 | #endif 41 | 42 | # ifdef HEADER_BIO_H 43 | # ifdef ZLIB 44 | const BIO_METHOD *BIO_f_zlib(void); 45 | # endif 46 | # endif 47 | 48 | 49 | # ifdef __cplusplus 50 | } 51 | # endif 52 | # endif 53 | #endif 54 | -------------------------------------------------------------------------------- /include/openssl/comperr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by util/mkerr.pl DO NOT EDIT 3 | * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. 4 | * 5 | * Licensed under the OpenSSL license (the "License"). You may not use 6 | * this file except in compliance with the License. You can obtain a copy 7 | * in the file LICENSE in the source distribution or at 8 | * https://www.openssl.org/source/license.html 9 | */ 10 | 11 | #ifndef HEADER_COMPERR_H 12 | # define HEADER_COMPERR_H 13 | 14 | # ifndef HEADER_SYMHACKS_H 15 | # include 16 | # endif 17 | 18 | # include 19 | 20 | # ifndef OPENSSL_NO_COMP 21 | 22 | # ifdef __cplusplus 23 | extern "C" 24 | # endif 25 | int ERR_load_COMP_strings(void); 26 | 27 | /* 28 | * COMP function codes. 29 | */ 30 | # define COMP_F_BIO_ZLIB_FLUSH 99 31 | # define COMP_F_BIO_ZLIB_NEW 100 32 | # define COMP_F_BIO_ZLIB_READ 101 33 | # define COMP_F_BIO_ZLIB_WRITE 102 34 | # define COMP_F_COMP_CTX_NEW 103 35 | 36 | /* 37 | * COMP reason codes. 38 | */ 39 | # define COMP_R_ZLIB_DEFLATE_ERROR 99 40 | # define COMP_R_ZLIB_INFLATE_ERROR 100 41 | # define COMP_R_ZLIB_NOT_SUPPORTED 101 42 | 43 | # endif 44 | #endif 45 | -------------------------------------------------------------------------------- /include/openssl/cryptoerr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by util/mkerr.pl DO NOT EDIT 3 | * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. 4 | * 5 | * Licensed under the OpenSSL license (the "License"). You may not use 6 | * this file except in compliance with the License. You can obtain a copy 7 | * in the file LICENSE in the source distribution or at 8 | * https://www.openssl.org/source/license.html 9 | */ 10 | 11 | #ifndef HEADER_CRYPTOERR_H 12 | # define HEADER_CRYPTOERR_H 13 | 14 | # ifndef HEADER_SYMHACKS_H 15 | # include 16 | # endif 17 | 18 | # ifdef __cplusplus 19 | extern "C" 20 | # endif 21 | int ERR_load_CRYPTO_strings(void); 22 | 23 | /* 24 | * CRYPTO function codes. 25 | */ 26 | # define CRYPTO_F_CMAC_CTX_NEW 120 27 | # define CRYPTO_F_CRYPTO_DUP_EX_DATA 110 28 | # define CRYPTO_F_CRYPTO_FREE_EX_DATA 111 29 | # define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100 30 | # define CRYPTO_F_CRYPTO_MEMDUP 115 31 | # define CRYPTO_F_CRYPTO_NEW_EX_DATA 112 32 | # define CRYPTO_F_CRYPTO_OCB128_COPY_CTX 121 33 | # define CRYPTO_F_CRYPTO_OCB128_INIT 122 34 | # define CRYPTO_F_CRYPTO_SET_EX_DATA 102 35 | # define CRYPTO_F_FIPS_MODE_SET 109 36 | # define CRYPTO_F_GET_AND_LOCK 113 37 | # define CRYPTO_F_OPENSSL_ATEXIT 114 38 | # define CRYPTO_F_OPENSSL_BUF2HEXSTR 117 39 | # define CRYPTO_F_OPENSSL_FOPEN 119 40 | # define CRYPTO_F_OPENSSL_HEXSTR2BUF 118 41 | # define CRYPTO_F_OPENSSL_INIT_CRYPTO 116 42 | # define CRYPTO_F_OPENSSL_LH_NEW 126 43 | # define CRYPTO_F_OPENSSL_SK_DEEP_COPY 127 44 | # define CRYPTO_F_OPENSSL_SK_DUP 128 45 | # define CRYPTO_F_PKEY_HMAC_INIT 123 46 | # define CRYPTO_F_PKEY_POLY1305_INIT 124 47 | # define CRYPTO_F_PKEY_SIPHASH_INIT 125 48 | # define CRYPTO_F_SK_RESERVE 129 49 | 50 | /* 51 | * CRYPTO reason codes. 52 | */ 53 | # define CRYPTO_R_FIPS_MODE_NOT_SUPPORTED 101 54 | # define CRYPTO_R_ILLEGAL_HEX_DIGIT 102 55 | # define CRYPTO_R_ODD_NUMBER_OF_DIGITS 103 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /include/openssl/dsaerr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by util/mkerr.pl DO NOT EDIT 3 | * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. 4 | * 5 | * Licensed under the OpenSSL license (the "License"). You may not use 6 | * this file except in compliance with the License. You can obtain a copy 7 | * in the file LICENSE in the source distribution or at 8 | * https://www.openssl.org/source/license.html 9 | */ 10 | 11 | #ifndef HEADER_DSAERR_H 12 | # define HEADER_DSAERR_H 13 | 14 | # ifndef HEADER_SYMHACKS_H 15 | # include 16 | # endif 17 | 18 | # include 19 | 20 | # ifndef OPENSSL_NO_DSA 21 | 22 | # ifdef __cplusplus 23 | extern "C" 24 | # endif 25 | int ERR_load_DSA_strings(void); 26 | 27 | /* 28 | * DSA function codes. 29 | */ 30 | # define DSA_F_DSAPARAMS_PRINT 100 31 | # define DSA_F_DSAPARAMS_PRINT_FP 101 32 | # define DSA_F_DSA_BUILTIN_PARAMGEN 125 33 | # define DSA_F_DSA_BUILTIN_PARAMGEN2 126 34 | # define DSA_F_DSA_DO_SIGN 112 35 | # define DSA_F_DSA_DO_VERIFY 113 36 | # define DSA_F_DSA_METH_DUP 127 37 | # define DSA_F_DSA_METH_NEW 128 38 | # define DSA_F_DSA_METH_SET1_NAME 129 39 | # define DSA_F_DSA_NEW_METHOD 103 40 | # define DSA_F_DSA_PARAM_DECODE 119 41 | # define DSA_F_DSA_PRINT_FP 105 42 | # define DSA_F_DSA_PRIV_DECODE 115 43 | # define DSA_F_DSA_PRIV_ENCODE 116 44 | # define DSA_F_DSA_PUB_DECODE 117 45 | # define DSA_F_DSA_PUB_ENCODE 118 46 | # define DSA_F_DSA_SIGN 106 47 | # define DSA_F_DSA_SIGN_SETUP 107 48 | # define DSA_F_DSA_SIG_NEW 102 49 | # define DSA_F_OLD_DSA_PRIV_DECODE 122 50 | # define DSA_F_PKEY_DSA_CTRL 120 51 | # define DSA_F_PKEY_DSA_CTRL_STR 104 52 | # define DSA_F_PKEY_DSA_KEYGEN 121 53 | 54 | /* 55 | * DSA reason codes. 56 | */ 57 | # define DSA_R_BAD_Q_VALUE 102 58 | # define DSA_R_BN_DECODE_ERROR 108 59 | # define DSA_R_BN_ERROR 109 60 | # define DSA_R_DECODE_ERROR 104 61 | # define DSA_R_INVALID_DIGEST_TYPE 106 62 | # define DSA_R_INVALID_PARAMETERS 112 63 | # define DSA_R_MISSING_PARAMETERS 101 64 | # define DSA_R_MISSING_PRIVATE_KEY 111 65 | # define DSA_R_MODULUS_TOO_LARGE 103 66 | # define DSA_R_NO_PARAMETERS_SET 107 67 | # define DSA_R_PARAMETER_ENCODING_ERROR 105 68 | # define DSA_R_Q_NOT_PRIME 113 69 | # define DSA_R_SEED_LEN_SMALL 110 70 | 71 | # endif 72 | #endif 73 | -------------------------------------------------------------------------------- /include/openssl/dtls1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2018 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_DTLS1_H 11 | # define HEADER_DTLS1_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | # define DTLS1_VERSION 0xFEFF 18 | # define DTLS1_2_VERSION 0xFEFD 19 | # define DTLS_MIN_VERSION DTLS1_VERSION 20 | # define DTLS_MAX_VERSION DTLS1_2_VERSION 21 | # define DTLS1_VERSION_MAJOR 0xFE 22 | 23 | # define DTLS1_BAD_VER 0x0100 24 | 25 | /* Special value for method supporting multiple versions */ 26 | # define DTLS_ANY_VERSION 0x1FFFF 27 | 28 | /* lengths of messages */ 29 | /* 30 | * Actually the max cookie length in DTLS is 255. But we can't change this now 31 | * due to compatibility concerns. 32 | */ 33 | # define DTLS1_COOKIE_LENGTH 256 34 | 35 | # define DTLS1_RT_HEADER_LENGTH 13 36 | 37 | # define DTLS1_HM_HEADER_LENGTH 12 38 | 39 | # define DTLS1_HM_BAD_FRAGMENT -2 40 | # define DTLS1_HM_FRAGMENT_RETRY -3 41 | 42 | # define DTLS1_CCS_HEADER_LENGTH 1 43 | 44 | # define DTLS1_AL_HEADER_LENGTH 2 45 | 46 | /* Timeout multipliers (timeout slice is defined in apps/timeouts.h */ 47 | # define DTLS1_TMO_READ_COUNT 2 48 | # define DTLS1_TMO_WRITE_COUNT 2 49 | 50 | # define DTLS1_TMO_ALERT_COUNT 12 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | #endif 56 | -------------------------------------------------------------------------------- /include/openssl/hmac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_HMAC_H 11 | # define HEADER_HMAC_H 12 | 13 | # include 14 | 15 | # include 16 | 17 | # if OPENSSL_API_COMPAT < 0x10200000L 18 | # define HMAC_MAX_MD_CBLOCK 128 /* Deprecated */ 19 | # endif 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | size_t HMAC_size(const HMAC_CTX *e); 26 | HMAC_CTX *HMAC_CTX_new(void); 27 | int HMAC_CTX_reset(HMAC_CTX *ctx); 28 | void HMAC_CTX_free(HMAC_CTX *ctx); 29 | 30 | DEPRECATEDIN_1_1_0(__owur int HMAC_Init(HMAC_CTX *ctx, const void *key, int len, 31 | const EVP_MD *md)) 32 | 33 | /*__owur*/ int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, 34 | const EVP_MD *md, ENGINE *impl); 35 | /*__owur*/ int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, 36 | size_t len); 37 | /*__owur*/ int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, 38 | unsigned int *len); 39 | unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, 40 | const unsigned char *d, size_t n, unsigned char *md, 41 | unsigned int *md_len); 42 | __owur int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx); 43 | 44 | void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags); 45 | const EVP_MD *HMAC_CTX_get_md(const HMAC_CTX *ctx); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/openssl/objectserr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by util/mkerr.pl DO NOT EDIT 3 | * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. 4 | * 5 | * Licensed under the OpenSSL license (the "License"). You may not use 6 | * this file except in compliance with the License. You can obtain a copy 7 | * in the file LICENSE in the source distribution or at 8 | * https://www.openssl.org/source/license.html 9 | */ 10 | 11 | #ifndef HEADER_OBJERR_H 12 | # define HEADER_OBJERR_H 13 | 14 | # ifndef HEADER_SYMHACKS_H 15 | # include 16 | # endif 17 | 18 | # ifdef __cplusplus 19 | extern "C" 20 | # endif 21 | int ERR_load_OBJ_strings(void); 22 | 23 | /* 24 | * OBJ function codes. 25 | */ 26 | # define OBJ_F_OBJ_ADD_OBJECT 105 27 | # define OBJ_F_OBJ_ADD_SIGID 107 28 | # define OBJ_F_OBJ_CREATE 100 29 | # define OBJ_F_OBJ_DUP 101 30 | # define OBJ_F_OBJ_NAME_NEW_INDEX 106 31 | # define OBJ_F_OBJ_NID2LN 102 32 | # define OBJ_F_OBJ_NID2OBJ 103 33 | # define OBJ_F_OBJ_NID2SN 104 34 | # define OBJ_F_OBJ_TXT2OBJ 108 35 | 36 | /* 37 | * OBJ reason codes. 38 | */ 39 | # define OBJ_R_OID_EXISTS 102 40 | # define OBJ_R_UNKNOWN_NID 101 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /include/openssl/rand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_RAND_H 11 | # define HEADER_RAND_H 12 | 13 | # include 14 | # include 15 | # include 16 | # include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | struct rand_meth_st { 23 | int (*seed) (const void *buf, int num); 24 | int (*bytes) (unsigned char *buf, int num); 25 | void (*cleanup) (void); 26 | int (*add) (const void *buf, int num, double randomness); 27 | int (*pseudorand) (unsigned char *buf, int num); 28 | int (*status) (void); 29 | }; 30 | 31 | int RAND_set_rand_method(const RAND_METHOD *meth); 32 | const RAND_METHOD *RAND_get_rand_method(void); 33 | # ifndef OPENSSL_NO_ENGINE 34 | int RAND_set_rand_engine(ENGINE *engine); 35 | # endif 36 | 37 | RAND_METHOD *RAND_OpenSSL(void); 38 | 39 | # if OPENSSL_API_COMPAT < 0x10100000L 40 | # define RAND_cleanup() while(0) continue 41 | # endif 42 | int RAND_bytes(unsigned char *buf, int num); 43 | int RAND_priv_bytes(unsigned char *buf, int num); 44 | DEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num)) 45 | 46 | void RAND_seed(const void *buf, int num); 47 | void RAND_keep_random_devices_open(int keep); 48 | 49 | # if defined(__ANDROID__) && defined(__NDK_FPABI__) 50 | __NDK_FPABI__ /* __attribute__((pcs("aapcs"))) on ARM */ 51 | # endif 52 | void RAND_add(const void *buf, int num, double randomness); 53 | int RAND_load_file(const char *file, long max_bytes); 54 | int RAND_write_file(const char *file); 55 | const char *RAND_file_name(char *file, size_t num); 56 | int RAND_status(void); 57 | 58 | # ifndef OPENSSL_NO_EGD 59 | int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes); 60 | int RAND_egd(const char *path); 61 | int RAND_egd_bytes(const char *path, int bytes); 62 | # endif 63 | 64 | int RAND_poll(void); 65 | 66 | # if defined(_WIN32) && (defined(BASETYPES) || defined(_WINDEF_H)) 67 | /* application has to include in order to use these */ 68 | DEPRECATEDIN_1_1_0(void RAND_screen(void)) 69 | DEPRECATEDIN_1_1_0(int RAND_event(UINT, WPARAM, LPARAM)) 70 | # endif 71 | 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /include/openssl/srtp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | /* 11 | * DTLS code by Eric Rescorla 12 | * 13 | * Copyright (C) 2006, Network Resonance, Inc. Copyright (C) 2011, RTFM, Inc. 14 | */ 15 | 16 | #ifndef HEADER_D1_SRTP_H 17 | # define HEADER_D1_SRTP_H 18 | 19 | # include 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | # define SRTP_AES128_CM_SHA1_80 0x0001 26 | # define SRTP_AES128_CM_SHA1_32 0x0002 27 | # define SRTP_AES128_F8_SHA1_80 0x0003 28 | # define SRTP_AES128_F8_SHA1_32 0x0004 29 | # define SRTP_NULL_SHA1_80 0x0005 30 | # define SRTP_NULL_SHA1_32 0x0006 31 | 32 | /* AEAD SRTP protection profiles from RFC 7714 */ 33 | # define SRTP_AEAD_AES_128_GCM 0x0007 34 | # define SRTP_AEAD_AES_256_GCM 0x0008 35 | 36 | # ifndef OPENSSL_NO_SRTP 37 | 38 | __owur int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles); 39 | __owur int SSL_set_tlsext_use_srtp(SSL *ssl, const char *profiles); 40 | 41 | __owur STACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl); 42 | __owur SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s); 43 | 44 | # endif 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /include/openssl/ssl2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_SSL2_H 11 | # define HEADER_SSL2_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | # define SSL2_VERSION 0x0002 18 | 19 | # define SSL2_MT_CLIENT_HELLO 1 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | #endif 25 | -------------------------------------------------------------------------------- /include/openssl/symhacks.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved. 3 | * 4 | * Licensed under the OpenSSL license (the "License"). You may not use 5 | * this file except in compliance with the License. You can obtain a copy 6 | * in the file LICENSE in the source distribution or at 7 | * https://www.openssl.org/source/license.html 8 | */ 9 | 10 | #ifndef HEADER_SYMHACKS_H 11 | # define HEADER_SYMHACKS_H 12 | 13 | # include 14 | 15 | /* Case insensitive linking causes problems.... */ 16 | # if defined(OPENSSL_SYS_VMS) 17 | # undef ERR_load_CRYPTO_strings 18 | # define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings 19 | # undef OCSP_crlID_new 20 | # define OCSP_crlID_new OCSP_crlID2_new 21 | 22 | # undef d2i_ECPARAMETERS 23 | # define d2i_ECPARAMETERS d2i_UC_ECPARAMETERS 24 | # undef i2d_ECPARAMETERS 25 | # define i2d_ECPARAMETERS i2d_UC_ECPARAMETERS 26 | # undef d2i_ECPKPARAMETERS 27 | # define d2i_ECPKPARAMETERS d2i_UC_ECPKPARAMETERS 28 | # undef i2d_ECPKPARAMETERS 29 | # define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS 30 | 31 | /* This one clashes with CMS_data_create */ 32 | # undef cms_Data_create 33 | # define cms_Data_create priv_cms_Data_create 34 | 35 | # endif 36 | 37 | #endif /* ! defined HEADER_VMS_IDHACKS_H */ 38 | -------------------------------------------------------------------------------- /include/protocol/generic_tcp_protocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef GENERIC_TCP_PROTOCOL_H 32 | #define GENERIC_TCP_PROTOCOL_H 33 | 34 | #define TCP_SERVER_IP "127.0.0.1" 35 | #define TCP_SERVER_PORT 15623 36 | #define MAX_MESSAGE_BUF_LEN 30 37 | #define BACK_LOG 20 // Maximum length of sub device connection request 38 | #define WORK_PATH "." 39 | #define CONNECTED 0 40 | #define DISCONNECTED 1 41 | 42 | int CreateServerSocket(char *serverIp, int serverPort, int backlog); 43 | void TimeSleep(int ms); 44 | 45 | void ProcessMessageFromClient(int clientSocket); 46 | void SendReportToIoTPlatform(char *recvBuf); 47 | 48 | void SendCommandRspToIoTPlatform(char *requestId); 49 | void SendMessageToSubDevice(int clientSocket, char *payload); 50 | 51 | void HandleSubDeviceManagerEvents(EN_IOTA_SERVICE_EVENT *subDeviceServices); 52 | void AddSubDevice(EN_IOTA_DEVICE_PARAS *paras); 53 | void AddSubDevice(EN_IOTA_DEVICE_PARAS *paras); 54 | void DeleteSubDevice(EN_IOTA_DEVICE_PARAS *paras); 55 | 56 | void HandleOTAEvents(EN_IOTA_SERVICE_EVENT *otaServices); 57 | void QueryVersion(void); 58 | void UpgradeFirmware(EN_IOTA_OTA_PARAS *paras); 59 | void UpgradeSoftware(EN_IOTA_OTA_PARAS *paras); 60 | 61 | char *EncodeCommandParas(EN_IOTA_COMMAND *command); 62 | ST_IOTA_SERVICE_DATA_INFO *DecodeServiceProperty(char *recvBuf); 63 | 64 | #endif /* INCLUDE_PROTOCOL_GENERIC_TCP_PROTOCOL_H_ */ 65 | 66 | -------------------------------------------------------------------------------- /include/service/data_trans.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef DATATRANS_H 32 | #define DATATRANS_H 33 | #include "mqttv5_util.h" 34 | 35 | int ReportDeviceData(char *payload, char *topicParas, int compressFlag, void *context, void *properties); 36 | int ReportDeviceProperties(char *payload, int compressFlag, void *context, void *properties); 37 | int ReportBatchDeviceProperties(char *payload, int compressFlag, void *context, void *properties); 38 | int ReportData(char *topic, char *payload, void *context, void *properties); 39 | int ReportCommandReponse(char *requestId, char *commandResponse, void *context, void *properties); 40 | int ReportPropSetReponse(char *requestId, char *commandResponse, void *context); 41 | int ReportPropGetReponse(char *requestId, char *commandResponse, void *context); 42 | int GetPropertiesRequest(char *requestId, char *commandResponse, void *context); 43 | int ReportSubDeviceInfo(char *payload, void *context); 44 | int EventUp(char *payload, void *context); 45 | int ReportDevicePropertiesV3(char *payload, int codecMode, void *context); 46 | int BinaryReportV3(char *payload); 47 | int Bootstrap(char *payload); 48 | int OCM2MSendMsg(char *to, char *from, char *payload, char *requestId, char *context); 49 | 50 | #endif /* DATATRANS_H */ 51 | -------------------------------------------------------------------------------- /include/service/detect_anomaly/detect_anomaly.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef DETECT_ANOMALY_H 32 | #define DETECT_ANOMALY_H 33 | 34 | #include "cJSON.h" 35 | #include "sys_hal.h" 36 | #include "iota_init.h" 37 | 38 | typedef struct { 39 | int memoryThreshold; 40 | int cpuUsageThreshold; 41 | int diskSpaceThreshold; 42 | int batteryPercentageThreshold; 43 | } SecurityDetection; 44 | 45 | typedef struct { 46 | long used; // the amount of memory used 47 | long total; // the total memory size 48 | int leakAlarm; // the memory leak switch, 0:no, 1:yes 49 | } MemoryInfo; 50 | 51 | typedef struct { 52 | long diskSpaceUsed; 53 | long diskSpaceTotal; 54 | int diskSpaceAlarm; 55 | } DiskSpaceInfo; 56 | 57 | typedef struct { 58 | int cpuUsage; 59 | int cpuAlarm; 60 | } CpuUsageInfo; 61 | 62 | typedef struct { 63 | int batteryPct; // the value of batteryPercentage 64 | int batteryAlarm; // 1 means alarm, 0 means no alarm 65 | } BatteryInfo; 66 | 67 | /** 68 | * @brief get device shadow for "$security_detection_config" 69 | * 70 | * @return int 0:success, otherwise failed 71 | */ 72 | int Detect_GetShadowDetectAnomaly(void); 73 | 74 | /** 75 | * @brief deal with the properties from shadow or propertiesSet 76 | * 77 | * @param propertieDown the properties from shadow or propertiesSet 78 | */ 79 | void Detect_ParseShadowGetOrPropertiesSet(char *propertieDown); 80 | 81 | 82 | #endif /* DETECT_ANOMALY_H */ -------------------------------------------------------------------------------- /include/service/device_rule/rule_action.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef RULE_ACTION_H 32 | #define RULE_ACTION_H 33 | 34 | #include "rule_util.h" 35 | 36 | typedef struct { 37 | char *commandName; 38 | cJSON *commandBody; 39 | char *serviceId; 40 | } Command; 41 | 42 | HW_BOOL CommandCtor(Command *self); 43 | void CommandDtor(Command *self); 44 | 45 | typedef struct { 46 | char *type; 47 | char *status; 48 | char *deviceId; 49 | Command command; 50 | } Action; 51 | 52 | HW_BOOL ActionCtor(Action *self); 53 | void ActionDtor(Action *self); 54 | 55 | DECL_DYARRY_FUNC_UTIL(ActionList, Action, elements) 56 | 57 | #endif -------------------------------------------------------------------------------- /include/service/device_rule/rule_execution.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef RULE_EXECUTE_H 32 | #define RULE_EXECUTE_H 33 | 34 | #include 35 | #include "hw_type.h" 36 | #include "rule_info.h" 37 | 38 | typedef enum { 39 | PropertyValueDataTypeInt, 40 | PropertyValueDataTypeDouble, 41 | PropertyValueDataTypeFloat, 42 | PropertyValueDataTypeCStr, 43 | } PropertyValueDataType; 44 | 45 | typedef struct { 46 | PropertyValueDataType type; 47 | union { 48 | int i; 49 | double d; 50 | const char *cstr; 51 | } data; 52 | } PropertyValue; 53 | 54 | typedef HW_BOOL (*GetPropertyValueCallBack)(const char *serviceId, const char *property, PropertyValue *value); 55 | typedef void (*ExecuteCommandCallBack)(const char *deviceId, const Command *command); 56 | void PropertyValueSetInt(PropertyValue *dest, int val); 57 | void PropertyValueSetDouble(PropertyValue *dest, double val); 58 | void PropertyValueSetCStr(PropertyValue *dest, const char *val); 59 | HW_BOOL PropertyValueCompare(int *result, const PropertyValue *left, const PropertyValue *right); 60 | void CheckRuleInfoListAndExecute(RuleInfoList *list, const GetPropertyValueCallBack propertyCallback, 61 | const ExecuteCommandCallBack commandCalback, HW_BOOL isTimerRule, time_t epochTime); 62 | 63 | #endif -------------------------------------------------------------------------------- /include/service/device_rule/rule_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef RULE_INFO_H 32 | #define RULE_INFO_H 33 | 34 | #include "hw_type.h" 35 | #include "rule_action.h" 36 | #include "rule_condition.h" 37 | 38 | typedef struct { 39 | int startTime; 40 | int endTime; 41 | DaysOfWeekRecord daysOfWeek; 42 | } TimeRange; 43 | 44 | HW_BOOL TimeRangeCtor(TimeRange *self); 45 | void TimeRangeDtor(TimeRange *self); 46 | HW_BOOL TimeRangeIsNuLL(const TimeRange *self); 47 | 48 | typedef struct { 49 | char *ruleId; 50 | char *ruleName; 51 | char *logic; 52 | TimeRange timeRange; 53 | char *status; 54 | ConditionList conditions; 55 | ActionList actions; 56 | int ruleVersionInShadow; 57 | } RuleInfo; 58 | 59 | HW_BOOL RuleInfoCtor(RuleInfo *self); 60 | void RuleInfoDtor(RuleInfo *self); 61 | 62 | DECL_DYARRY_FUNC_UTIL(RuleInfoList, RuleInfo, elements) 63 | 64 | #endif -------------------------------------------------------------------------------- /include/service/device_rule/rule_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef RULE_PARSE_H 32 | #define RULE_PARSE_H 33 | 34 | #include "rule_info.h" 35 | 36 | typedef void (*ParseDeviceRuleHook)(void *target, HW_BOOL isRemove, const cJSON *rule); 37 | void ParseDeviceRuleWithHook(RuleInfoList *rules, const cJSON *paras, void *hookTarget, ParseDeviceRuleHook hook); 38 | void ParseDeviceRule(RuleInfoList *rules, const cJSON *paras); 39 | HW_BOOL GetRuleInfoList(RuleInfoList *list, const cJSON *const propertiesCJSON, RuleInfoList *delList, 40 | RuleInfoList *addList); 41 | void DeletRulesFromList(RuleInfoList *list, const RuleInfoList *targetRuleIds); 42 | void PrintRuleInfoList(const RuleInfoList *list, int indent); 43 | void PrintRuleInfoListIdVersion(const RuleInfoList *list); 44 | 45 | #endif -------------------------------------------------------------------------------- /include/service/device_rule/rule_trans.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef RULE_TRANS_H 32 | #define RULE_TRANS_H 33 | 34 | #include "cJSON.h" 35 | 36 | void RuleTrans_DeviceRuleUpdate(char *props); 37 | void RuleTrans_DeviceRuleUpdateByJSON(cJSON *properties); 38 | 39 | #endif -------------------------------------------------------------------------------- /include/service/login.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef LOGIN_H 32 | #define LOGIN_H 33 | 34 | void onConnectionLost(void *context, char *cause); 35 | int CreateConnection(void); 36 | int ReleaseConnection(void); 37 | int IsConnected(void); 38 | 39 | #endif /* LOGIN_H */ 40 | -------------------------------------------------------------------------------- /include/service/soft_bus_init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef SOFT_BUS_INIT_H 32 | #define SOFT_BUS_INIT_H 33 | 34 | #define SOFT_BUS_INIT_SERVICE_ID "M2MService" 35 | #define SOFT_BUS_INIT_COMMAND_NAME "SET_THING_SWITCH" 36 | #define SOFT_BUS_INIT_STATUS "STATUS" 37 | #define SOFT_BUS_INIT_CLIENT_OR_SERVER "CLIENT_OR_SERVER" 38 | 39 | int InitServerKit(char *ipAry); 40 | int InitClientKit(char *ipAry); 41 | void DestroyKit(void); 42 | 43 | #endif /* SOFT_BUS_INIT_H */ -------------------------------------------------------------------------------- /include/service/subscribe.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef SUBSCRIBE_H 32 | #define SUBSCRIBE_H 33 | 34 | int SubscribeM2m(void); 35 | int SubscribeCommand(void); 36 | void SubscribeAll(void); 37 | int SubscribeMessageDown(void); 38 | int SubscribePropSet(void); 39 | int SubscribePropget(void); 40 | int SubscribePropResp(void); 41 | int SubscribeSubDeviceEvent(void); 42 | int SubscribeUserTopic(char *topicParas); 43 | int SubscribeJsonCmdV3(void); 44 | int SubscribeBinaryCmdV3(void); 45 | int SubscribeBootstrap(void); 46 | 47 | 48 | // qos 49 | void SubscribeAllQos(int qos); 50 | int SubscribeCustomTopic(char *topic, const int qos); 51 | int SubscribeM2mQos(int qos); 52 | int SubscribeCommandQos(int qos); 53 | void SubscribeAllQos(int qos); 54 | int SubscribeMessageDownQos(int qos); 55 | int SubscribePropSetQos(int qos); 56 | int SubscribePropgetQos(int qos); 57 | int SubscribePropRespQos(int qos); 58 | int SubscribeSubDeviceEventQos(int qos); 59 | int SubscribeUserTopicQos(char *topicParas, int qos); 60 | int SubscribeJsonCmdV3Qos(int qos); 61 | int SubscribeBinaryCmdV3Qos(int qos); 62 | int SubscribeBootstrapQos(int qos); 63 | 64 | 65 | #endif /* SUBSCRIBE_H */ 66 | -------------------------------------------------------------------------------- /include/tunnel/ssh_client.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef SSH_CLIENT_H 32 | #define SSH_CLIENT_H 33 | 34 | #include "json_util.h" 35 | 36 | #define TUNNEL_SSH_RSPBUFF_LEN 2048 37 | #define TUNNEL_SSH_REQID_LENGTH 37 38 | #define TUNNEL_TERMINAL_WIDTH 128 39 | #define TUNNEL_TERMINAL_HEIGHT 30 40 | 41 | int SSHClientCreate(const JSON *root); 42 | void SSHClientRunCmd(JSON *root); 43 | void SSHClientSessionDestroy(void); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /include/tunnel/wss_client.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef WSS_CLIENT_H 32 | #define WSS_CLIENT_H 33 | 34 | #include 35 | 36 | #define TUNNEL_WSSCLIENT_CLOSE_NORMAL 1000 37 | #define TUNNEL_WSSCLIENT_AUTH_FAILED 1002 38 | #define TUNNEL_WSSCLIENT_REPEAT_CONN 4000 39 | 40 | #define TUNNEL_WSSCLIENT_CONN_RETRY_TIMES 10 41 | #define TUNNEL_WSSCLIENT_CONN_RETRY_DELAY 1000000 42 | #define TUNNEL_WSSCLIENT_PING_DELAY 20000000 43 | #define TUNNEL_WSSCLIENT_CONN_TIMEOUT 10 44 | 45 | #define TUNNEL_WSSCLIENT_RSPMSG_LEN 2304 46 | 47 | #define TUNNEL_WSSCLIENT_DEFAULT_PORT "443" 48 | #define TUNNEL_WSSCLIENT_DEFAULT_PORT_LEN 3 49 | 50 | typedef struct { 51 | char *site; 52 | char *port; 53 | char *path; 54 | char *token; 55 | } URL_INFO; 56 | 57 | int WssClientSplitUrl(URL_INFO *info, const char *url, const char *token); 58 | void WssClientCreate(const URL_INFO *info); 59 | void WssClientSendRsp(const char *reqId, const char *optype, char *buff, int len); 60 | void WssClientSendDisConn(const char *reqId, const char *code, const char *msg); 61 | #endif -------------------------------------------------------------------------------- /include/util/log_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef LOG_UTIL_H 32 | #define LOG_UTIL_H 33 | 34 | #include 35 | #define LOG_FILE_ENABLE 0 // If equal to 1, output to file; if equal to 0, output to log 36 | #define LOG_FILE_NAME "./client.log" // Mqtt debug output file address 37 | 38 | typedef void (*PRINTF_LOG_CALLBACK_HANDLER)(int level, char *format, va_list args); 39 | void SetPrintfLogCallback(PRINTF_LOG_CALLBACK_HANDLER callback); 40 | void PrintfLog(int logLevel, char *_Format, ...); 41 | 42 | // this compiling macro _SYS_LOG can only be used in Linux system 43 | #ifdef _SYS_LOG 44 | 45 | #include "syslog.h" 46 | 47 | void InitLogForLinux(); 48 | void SetLogLocalNumber(int logLocalNumber); 49 | void SetLogLevel(int logLevel); 50 | void DestoryLogForLinux(); 51 | 52 | typedef enum { 53 | EN_LOG_LEVEL_DEBUG = LOG_DEBUG, 54 | EN_LOG_LEVEL_INFO = LOG_INFO, 55 | EN_LOG_LEVEL_WARNING = LOG_WARNING, 56 | EN_LOG_LEVEL_ERROR = LOG_ERR, 57 | } LOGLEVEL; 58 | 59 | #else 60 | 61 | typedef enum enum_LOG_LEVEL { 62 | EN_LOG_LEVEL_DEBUG, 63 | EN_LOG_LEVEL_INFO, 64 | EN_LOG_LEVEL_WARNING, 65 | EN_LOG_LEVEL_ERROR, 66 | // for MQTT debug printing 67 | EN_LOG_LEVEL_MQTT_MAXIMUM = 8, 68 | EN_LOG_LEVEL_MQTT_MEDIUM, 69 | EN_LOG_LEVEL_MQTT_MINIMUM, 70 | EN_LOG_LEVEL_MQTT_PROTOCOL, 71 | EN_LOG_LEVEL_MQTT_ERROR, 72 | EN_LOG_LEVEL_MQTT_SEVERE, 73 | EN_LOG_LEVEL_MQTT_FATAL, 74 | } LOGLEVEL; 75 | #endif 76 | 77 | #endif /* LOG_UTIL_H */ 78 | -------------------------------------------------------------------------------- /include/util/string_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef STRING_UTIL_H 32 | #define STRING_UTIL_H 33 | 34 | #include 35 | 36 | #define SUB_STERING_MAX_LENGTH (20) 37 | #define EVENT_TIME_LENGTH (16) 38 | #define CLIENT_TIME_LENGTH (10) 39 | #define LONG_LONG_MAX_LENGTH (20) 40 | #define LOCAL_TIME_LENGTH (19) 41 | #define LOCAL_TIME_WITH_MS_LENGTH (LOCAL_TIME_LENGTH + 4) 42 | #define LOCAL_TIME_COMPACT_LENGTH (14) 43 | 44 | int StringLength(const char *str); 45 | char *StrInStr(const char *str, const char *subStr); 46 | int String2Int(const char *value); 47 | char *CombineStrings(int strAmount, const char *str1, ...); 48 | void StringMalloc(char **str, int length); 49 | int CopyStrValue(char **dst, const char *src, int length); 50 | char *GetClientTimesStamp(void); 51 | char *GetEventTimesStamp(void); 52 | char *Timeval2Str(const struct timeval *tv); 53 | char *Timeval2CompactStr(const struct timeval *tv); 54 | char *GetLocalTimeWithMs(void); 55 | char *PrependLocalTimeWithMs(const char *); 56 | int GetSubStrIndex(const char *str, const char *substr); 57 | unsigned long long getTime(void); 58 | int StrEndWith(const char *str, const char *suffix); 59 | long long getLLongValueFromStr(const char *str, const char *subStr); 60 | int gZIPCompress(const char *src, int srcLength, unsigned char *dest, int destLength); 61 | char *ReassignMemory(char *oldMemory, unsigned int resultLen); 62 | 63 | #define MemFree(ptr) \ 64 | do { \ 65 | free(*(ptr)); \ 66 | *(ptr) = NULL; \ 67 | } while (0) 68 | 69 | #endif /* STRING_UTIL_H */ 70 | -------------------------------------------------------------------------------- /lib/README.md: -------------------------------------------------------------------------------- 1 | put third party libraries at lib folder. 2 | If it is the X86-64 SYSV system, the file "X86-64 SYSV Lib.zip" can be decompressed 3 | 4 | 将三方库放到lib文件夹下。 5 | 若是为X86-64 SYSV 系统,可将文件X86-64 SYSV lib.zip解压 -------------------------------------------------------------------------------- /lib/X86-64 SYSV lib.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huaweicloud/huaweicloud-iot-device-sdk-c/ed744dd2c7c4d2adf988ffb98cd6489308079b67/lib/X86-64 SYSV lib.zip -------------------------------------------------------------------------------- /src/agentlite/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2022 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 2 | # Redistribution and use in source and binary forms, with or without modification, 3 | # are permitted provided that the following conditions are met: 4 | # 1. Redistributions of source code must retain the above copyright notice, this list of 5 | # conditions and the following disclaimer. 6 | # 7 | # 2. Redistributions in binary form must reproduce the above copyright notice, this list 8 | # of conditions and the following disclaimer in the documentation and/or other materials 9 | # provided with the distribution. 10 | # 11 | # 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | # to endorse or promote products derived from this software without specific prior written 13 | # permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 17 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 19 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | declare_args() { 28 | bridge = 1 29 | } 30 | 31 | static_library("agentlite") { 32 | sources = [ 33 | "iota_init.c", 34 | "iota_login.c", 35 | "iota_datatrans.c", 36 | "iota_payload.c", 37 | "iota_defaultCallback.c", 38 | ] 39 | 40 | cflags = [ "-Wno-unused-variable" ] 41 | cflags += [ "-Wno-unused-but-set-variable" ] 42 | cflags += [ "-Wno-unused-parameter" ] 43 | 44 | include_dirs = [ 45 | "../../include/service", 46 | "../../include/util", 47 | "../../include/openssl", 48 | "../../include/agentlite", 49 | "../../include/third_party/cjson", 50 | "../../include/third_party/libboundscheck", 51 | "../../include/service/device_rule", 52 | "../../include/", 53 | "../../include/curl", 54 | "../../include/service/bridge", 55 | "../../include/tunnel", 56 | "../../include/nopoll", 57 | ] 58 | 59 | if(bridge == 1){ 60 | sources += ["iota_bridge.c",] 61 | include_dirs += ["../../include/base",] 62 | } 63 | } 64 | print("-----------------------> agentlite!") 65 | 66 | -------------------------------------------------------------------------------- /src/agentlite/iota_login.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "base.h" 32 | #include "login.h" 33 | #include "hw_type.h" 34 | #include "iota_error_type.h" 35 | #include "iota_login.h" 36 | 37 | HW_API_FUNC HW_INT IOTA_Connect() 38 | { 39 | return CreateConnection(); 40 | } 41 | 42 | HW_API_FUNC HW_INT IOTA_DisConnect() 43 | { 44 | return ReleaseConnection(); 45 | } 46 | 47 | HW_API_FUNC HW_INT IOTA_IsConnected() 48 | { 49 | return IsConnected(); 50 | } -------------------------------------------------------------------------------- /src/base/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2022 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 2 | # Redistribution and use in source and binary forms, with or without modification, 3 | # are permitted provided that the following conditions are met: 4 | # 1. Redistributions of source code must retain the above copyright notice, this list of 5 | # conditions and the following disclaimer. 6 | # 7 | # 2. Redistributions in binary form must reproduce the above copyright notice, this list 8 | # of conditions and the following disclaimer in the documentation and/or other materials 9 | # provided with the distribution. 10 | # 11 | # 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | # to endorse or promote products derived from this software without specific prior written 13 | # permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 17 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 19 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | static_library("base") { 28 | sources = [ 29 | "hmac_sha256.c", 30 | "mqtt_base.c", 31 | ] 32 | 33 | cflags = [ "-Wno-unused-variable" ] 34 | cflags += [ "-Wno-unused-but-set-variable" ] 35 | cflags += [ "-Wno-unused-parameter" ] 36 | 37 | include_dirs = [ 38 | "../../include/base", 39 | "../../include/util", 40 | "../../include/agentlite", 41 | "../../include/third_party/cjson", 42 | "../../include/third_party/libboundscheck", 43 | "../../include/", 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /src/bootstrap_demo/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2022 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 2 | # Redistribution and use in source and binary forms, with or without modification, 3 | # are permitted provided that the following conditions are met: 4 | # 1. Redistributions of source code must retain the above copyright notice, this list of 5 | # conditions and the following disclaimer. 6 | # 7 | # 2. Redistributions in binary form must reproduce the above copyright notice, this list 8 | # of conditions and the following disclaimer in the documentation and/or other materials 9 | # provided with the distribution. 10 | # 11 | # 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | # to endorse or promote products derived from this software without specific prior written 13 | # permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 17 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 19 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | static_library("bootstrap_demo") { 28 | sources = [ 29 | "bootstrap_demo.c", 30 | ] 31 | 32 | cflags = [ "-Wno-unused-variable" ] 33 | cflags += [ "-Wno-unused-but-set-variable" ] 34 | cflags += [ "-Wno-unused-parameter" ] 35 | 36 | include_dirs = [ 37 | "../../include/protocol", 38 | "../../include/util", 39 | "../../include/agentlite", 40 | "../../include/base", 41 | "../../include/service", 42 | "../../include/third_party/cjson", 43 | "../../include", 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /src/dconncaseone_interface.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include 32 | #include 33 | #include "dconncaseone_interface.h" 34 | 35 | 36 | /** 37 | * @brief 初始化套件。 38 | * 39 | * @param type 初始化类型: INIT_SERVICE/INIT_CLIENT 40 | * @param ipAry IP地址字符串。初始化服务端时仅可传入一个 IP 地址,初始化客户端时可传入多个,以半角逗号分隔。 41 | * @param errorIp 第一个出错的 IP 地址,只有在返回值不为 OK 时有效。内存空间由调用方申请。 42 | * @return uint32_t 错误码。RESLUT_ENUM。在初始化客户端时,按输入顺序依次初始化,遇到第一个失败的 IP 地址则返回, 43 | * 后续的 IP 地址不会被处理。 44 | */ 45 | DCONN_API_PUBLIC uint32_t InitDConnCaseOne(uint32_t type, const char *ipAry, char *errorIp) {}; 46 | 47 | /** 48 | * @brief 注册回调函数 49 | * 50 | * @param callback 回调函数结构体 CallbackParam 51 | */ 52 | DCONN_API_PUBLIC void RegisterCallback(const CallbackParam *callback) {}; 53 | 54 | /** 55 | * @brief 发送数据 56 | * 57 | * @param targetDeviceId 目标设备 ID 58 | * @param data 待发送数据 59 | * @param dataLen 数据字节长度 60 | * @return int 发送结果。此处并不能代表发送成功,请通过回调函数获取结果。 61 | */ 62 | DCONN_API_PUBLIC uint32_t DConnSendData(const char *targetDeviceId, const char *data, uint32_t dataLen) {}; 63 | 64 | /** 65 | * @brief 取消注册回调函数 66 | * 67 | */ 68 | DCONN_API_PUBLIC void UnRegisterCallback(void) {}; 69 | 70 | /** 71 | * @brief 卸载套件。 72 | * 73 | */ 74 | DCONN_API_PUBLIC void CloseDConnCaseOne(void) {}; 75 | 76 | /** 77 | * @brief 获取套件版本号 78 | * 79 | * @return const* 字符串格式的版本号 80 | */ 81 | DCONN_API_PUBLIC const char *GetDConnVersion(void) {}; -------------------------------------------------------------------------------- /src/device_demo/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2022 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 2 | # Redistribution and use in source and binary forms, with or without modification, 3 | # are permitted provided that the following conditions are met: 4 | # 1. Redistributions of source code must retain the above copyright notice, this list of 5 | # conditions and the following disclaimer. 6 | # 7 | # 2. Redistributions in binary form must reproduce the above copyright notice, this list 8 | # of conditions and the following disclaimer in the documentation and/or other materials 9 | # provided with the distribution. 10 | # 11 | # 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | # to endorse or promote products derived from this software without specific prior written 13 | # permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 17 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 19 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | static_library("device_demo") { 28 | sources = [ 29 | "device_demo.c", 30 | ] 31 | 32 | cflags = [ "-Wno-unused-variable" ] 33 | cflags += [ "-Wno-unused-but-set-variable" ] 34 | cflags += [ "-Wno-unused-parameter" ] 35 | 36 | include_dirs = [ 37 | "../../include/protocol", 38 | "../../include/util", 39 | "../../include/agentlite", 40 | "../../include/base", 41 | "../../include/service", 42 | "../../include/third_party/cjson", 43 | "../../include", 44 | "../../include/nopoll", 45 | "../../include/third_party/libboundscheck", 46 | "../../include/service/device_rule", 47 | "../../include/tunnel", 48 | "../../include/util", 49 | ] 50 | } 51 | -------------------------------------------------------------------------------- /src/gateway_demo/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2022 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 2 | # Redistribution and use in source and binary forms, with or without modification, 3 | # are permitted provided that the following conditions are met: 4 | # 1. Redistributions of source code must retain the above copyright notice, this list of 5 | # conditions and the following disclaimer. 6 | # 7 | # 2. Redistributions in binary form must reproduce the above copyright notice, this list 8 | # of conditions and the following disclaimer in the documentation and/or other materials 9 | # provided with the distribution. 10 | # 11 | # 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | # to endorse or promote products derived from this software without specific prior written 13 | # permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 17 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 19 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | declare_args() { 28 | demo = "generic_tcp_protocol" 29 | } 30 | 31 | static_library("gateway_demo") { 32 | if(demo == "generic_tcp_protocol"){ 33 | sources = ["generic_tcp_protocol.c",] 34 | } 35 | if(demo == "gateway_server_demo") { 36 | sources = ["gateway_server_demo.c",] 37 | } 38 | if(demo == "gateway_client_demo") { 39 | sources = ["gateway_client_demo.c",] 40 | } 41 | 42 | cflags = [ "-Wno-unused-variable" ] 43 | cflags += [ "-Wno-unused-but-set-variable" ] 44 | cflags += [ "-Wno-unused-parameter" ] 45 | 46 | include_dirs = [ 47 | "../../include/protocol", 48 | "../../include/util", 49 | "../../include/agentlite", 50 | "../../include/base", 51 | "../../include/service", 52 | "../../include/third_party/cjson", 53 | "../../include", 54 | ] 55 | } 56 | print("-----------------------> $demo") -------------------------------------------------------------------------------- /src/service/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2022 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 2 | # Redistribution and use in source and binary forms, with or without modification, 3 | # are permitted provided that the following conditions are met: 4 | # 1. Redistributions of source code must retain the above copyright notice, this list of 5 | # conditions and the following disclaimer. 6 | # 7 | # 2. Redistributions in binary form must reproduce the above copyright notice, this list 8 | # of conditions and the following disclaimer in the documentation and/or other materials 9 | # provided with the distribution. 10 | # 11 | # 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | # to endorse or promote products derived from this software without specific prior written 13 | # permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 17 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 19 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | static_library("service") { 28 | sources = [ 29 | "base.c", 30 | "callback_func.c", 31 | "data_trans.c", 32 | "login.c", 33 | "subscribe.c", 34 | ] 35 | 36 | cflags = [ "-Wno-unused-variable" ] 37 | cflags += [ "-Wno-unused-but-set-variable" ] 38 | cflags += [ "-Wno-unused-parameter" ] 39 | 40 | include_dirs = [ 41 | "../../include/", 42 | "../../include/service", 43 | "../../include/util", 44 | "../../include/agentlite", 45 | "../../include/base", 46 | "../../include/third_party/cjson", 47 | "../../include/service/device_rule", 48 | "../../include/service/sys_hal", 49 | "../../include/service/detect_anomaly", 50 | "../../include/third_party/libboundscheck", 51 | ] 52 | 53 | } 54 | print("-----------------------> service!") 55 | -------------------------------------------------------------------------------- /src/service/base.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "base.h" 32 | #include "mqtt_base.h" 33 | #include "iota_error_type.h" 34 | 35 | int init(char *workPath) 36 | { 37 | return MqttBase_init(workPath); 38 | } 39 | 40 | int destory(void) 41 | { 42 | return MqttBase_destory(); 43 | } 44 | 45 | int SetConfig(int item, char *value) 46 | { 47 | return MqttBase_SetConfig(item, value); 48 | } 49 | 50 | char *GetConfig(int item) 51 | { 52 | return MqttBase_GetConfig(item); 53 | } 54 | -------------------------------------------------------------------------------- /src/service/bridge/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023-2024 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 2 | # Redistribution and use in source and binary forms, with or without modification, 3 | # are permitted provided that the following conditions are met: 4 | # 1. Redistributions of source code must retain the above copyright notice, this list of 5 | # conditions and the following disclaimer. 6 | # 7 | # 2. Redistributions in binary form must reproduce the above copyright notice, this list 8 | # of conditions and the following disclaimer in the documentation and/or other materials 9 | # provided with the distribution. 10 | # 11 | # 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | # to endorse or promote products derived from this software without specific prior written 13 | # permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 17 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 19 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | static_library("bridge_topic") { 28 | sources = [ 29 | "bridge_topic_data.c", 30 | ] 31 | 32 | cflags = [ "-Wno-unused-variable" ] 33 | cflags += [ "-Wno-unused-but-set-variable" ] 34 | cflags += [ "-Wno-unused-parameter" ] 35 | 36 | include_dirs = [ 37 | "../../../include/third_party/cjson", 38 | "../../../include/third_party/libboundscheck", 39 | "../../../include/agentlite", 40 | "../../../include/util", 41 | "../../../include/service/", 42 | "../../../include/service/sys_hal", 43 | "../../../include/service/bridge/", 44 | "../../../include/base", 45 | ] 46 | 47 | } 48 | print("-----------------------> bridge_topic!") 49 | -------------------------------------------------------------------------------- /src/service/detect_anomaly/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 2 | # Redistribution and use in source and binary forms, with or without modification, 3 | # are permitted provided that the following conditions are met: 4 | # 1. Redistributions of source code must retain the above copyright notice, this list of 5 | # conditions and the following disclaimer. 6 | # 7 | # 2. Redistributions in binary form must reproduce the above copyright notice, this list 8 | # of conditions and the following disclaimer in the documentation and/or other materials 9 | # provided with the distribution. 10 | # 11 | # 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | # to endorse or promote products derived from this software without specific prior written 13 | # permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 17 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 19 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | static_library("detect_anomaly") { 28 | sources = [ 29 | "detect_anomaly.c", 30 | ] 31 | 32 | cflags = [ "-Wno-unused-variable" ] 33 | cflags += [ "-Wno-unused-but-set-variable" ] 34 | cflags += [ "-Wno-unused-parameter" ] 35 | 36 | include_dirs = [ 37 | "../../../include/third_party/cjson", 38 | "../../../include/third_party/libboundscheck", 39 | "../../../include/agentlite", 40 | "../../../include/util", 41 | "../../../include/service/", 42 | "../../../include/service/sys_hal", 43 | "../../../include/service/detect_anomaly", 44 | "../../../include/", 45 | ] 46 | 47 | } 48 | print("-----------------------> detect_anomaly!") 49 | -------------------------------------------------------------------------------- /src/service/device_rule/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 2 | # Redistribution and use in source and binary forms, with or without modification, 3 | # are permitted provided that the following conditions are met: 4 | # 1. Redistributions of source code must retain the above copyright notice, this list of 5 | # conditions and the following disclaimer. 6 | # 7 | # 2. Redistributions in binary form must reproduce the above copyright notice, this list 8 | # of conditions and the following disclaimer in the documentation and/or other materials 9 | # provided with the distribution. 10 | # 11 | # 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | # to endorse or promote products derived from this software without specific prior written 13 | # permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 17 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 19 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | static_library("device_rule") { 28 | sources = [ 29 | "rule_action.c", 30 | "rule_condition.c", 31 | "rule_execution.c", 32 | "rule_info.c", 33 | "rule_manager.c", 34 | "rule_parser.c", 35 | "rule_trans.c", 36 | "rule_util.c", 37 | ] 38 | 39 | cflags = [ "-Wno-unused-variable" ] 40 | cflags += [ "-Wno-unused-but-set-variable" ] 41 | cflags += [ "-Wno-unused-parameter" ] 42 | cflags += ["-DEVICE_RULE_ENALBE", "-DCONFIG_ENALBE_DEVICE_RULE_FILE_STORAGE"] 43 | include_dirs = [ 44 | "../../../include/third_party/cjson", 45 | "../../../include/third_party/libboundscheck", 46 | "../../../include/agentlite", 47 | "../../../include/util", 48 | "../../../include/service/device_rule", 49 | "../../../include/base", 50 | "../../../include/service", 51 | "../../../include/", 52 | ] 53 | } 54 | print("-----------------------> device_rule!") 55 | -------------------------------------------------------------------------------- /src/service/device_rule/rule_action.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include 32 | #include "string_util.h" 33 | #include "securec.h" 34 | #include "rule_action.h" 35 | 36 | HW_BOOL CommandCtor(Command *self) 37 | { 38 | self->commandBody = NULL; 39 | return (memset_s(self, sizeof(*self), 0, sizeof(*self)) == EOK); 40 | } 41 | 42 | void CommandDtor(Command *self) 43 | { 44 | MemFree(&self->commandName); 45 | cJSON_Delete(self->commandBody); 46 | MemFree(&self->serviceId); 47 | } 48 | 49 | HW_BOOL ActionCtor(Action *self) 50 | { 51 | (void)memset_s(self, sizeof(*self), 0, sizeof(*self)); 52 | return CommandCtor(&self->command); 53 | } 54 | 55 | void ActionDtor(Action *self) 56 | { 57 | MemFree(&self->type); 58 | MemFree(&self->status); 59 | MemFree(&self->deviceId); 60 | CommandDtor(&self->command); 61 | } 62 | 63 | DECL_DYARRY_FUNC_UTIL_IMPL(ActionList, Action, elements, ActionCtor, ActionDtor) 64 | -------------------------------------------------------------------------------- /src/service/login.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "base.h" 32 | #include "mqtt_base.h" 33 | #include "iota_error_type.h" 34 | #include "login.h" 35 | 36 | int CreateConnection(void) 37 | { 38 | return MqttBase_CreateConnection(); 39 | } 40 | 41 | int ReleaseConnection(void) 42 | { 43 | return MqttBase_ReleaseConnection(); 44 | } 45 | 46 | int IsConnected(void) 47 | { 48 | return MqttBase_IsConnected(); 49 | } -------------------------------------------------------------------------------- /src/service/soft_bus_init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include 32 | #include 33 | #include "dconncaseone_interface.h" 34 | #include "soft_bus_init.h" 35 | 36 | // 初始化服务端 37 | int InitServerKit(char *ipAry) 38 | { 39 | if (ipAry == NULL) { 40 | return -1; 41 | } 42 | return InitDConnCaseOne(1, ipAry, NULL); 43 | } 44 | 45 | // 初始化客户端 46 | int InitClientKit(char *ipAry) 47 | { 48 | if (ipAry == NULL) { 49 | return -1; 50 | } 51 | return InitDConnCaseOne(0, ipAry, NULL); 52 | } 53 | 54 | // 销毁服务端/客户端 55 | void DestroyKit(void) 56 | { 57 | CloseDConnCaseOne(); 58 | } 59 | -------------------------------------------------------------------------------- /src/service/sys_hal/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2022 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 2 | # Redistribution and use in source and binary forms, with or without modification, 3 | # are permitted provided that the following conditions are met: 4 | # 1. Redistributions of source code must retain the above copyright notice, this list of 5 | # conditions and the following disclaimer. 6 | # 7 | # 2. Redistributions in binary form must reproduce the above copyright notice, this list 8 | # of conditions and the following disclaimer in the documentation and/or other materials 9 | # provided with the distribution. 10 | # 11 | # 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | # to endorse or promote products derived from this software without specific prior written 13 | # permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 17 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 19 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | static_library("sys_hal") { 28 | sources = [ 29 | "sys_hal.c", 30 | ] 31 | 32 | cflags = [ "-Wno-unused-variable" ] 33 | cflags += [ "-Wno-unused-but-set-variable" ] 34 | cflags += [ "-Wno-unused-parameter" ] 35 | 36 | include_dirs = [ 37 | "../../../include/util", 38 | "../../../include/service/sys_hal", 39 | ] 40 | 41 | } 42 | print("-----------------------> sys_hal!") 43 | -------------------------------------------------------------------------------- /src/third_party/cjson/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2022 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 2 | # Redistribution and use in source and binary forms, with or without modification, 3 | # are permitted provided that the following conditions are met: 4 | # 1. Redistributions of source code must retain the above copyright notice, this list of 5 | # conditions and the following disclaimer. 6 | # 7 | # 2. Redistributions in binary form must reproduce the above copyright notice, this list 8 | # of conditions and the following disclaimer in the documentation and/or other materials 9 | # provided with the distribution. 10 | # 11 | # 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | # to endorse or promote products derived from this software without specific prior written 13 | # permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 17 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 19 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | static_library("cjson") { 28 | sources = [ 29 | "cJSON.c", 30 | ] 31 | 32 | cflags = [ "-Wno-unused-variable" ] 33 | cflags += [ "-Wno-unused-but-set-variable" ] 34 | cflags += [ "-Wno-unused-parameter" ] 35 | 36 | include_dirs = [ 37 | "../../../include/third_party/cjson", 38 | ] 39 | } 40 | print("-----------------------> cjson!") -------------------------------------------------------------------------------- /src/tunnel/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2022 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 2 | # Redistribution and use in source and binary forms, with or without modification, 3 | # are permitted provided that the following conditions are met: 4 | # 1. Redistributions of source code must retain the above copyright notice, this list of 5 | # conditions and the following disclaimer. 6 | # 7 | # 2. Redistributions in binary form must reproduce the above copyright notice, this list 8 | # of conditions and the following disclaimer in the documentation and/or other materials 9 | # provided with the distribution. 10 | # 11 | # 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | # to endorse or promote products derived from this software without specific prior written 13 | # permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 17 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 19 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | static_library("tunnel") { 28 | sources = [ 29 | "ssh_client.c", 30 | "wss_client.c", 31 | ] 32 | 33 | cflags = [ "-Wno-unused-variable" ] 34 | cflags += [ "-Wno-unused-but-set-variable" ] 35 | cflags += [ "-Wno-unused-parameter" ] 36 | 37 | include_dirs = [ 38 | "../../include/util", 39 | "../../include/third_party/cjson", 40 | "../../include/third_party/libboundscheck", 41 | "../../include/nopoll", 42 | "../../include/agentlite", 43 | "../../include/tunnel", 44 | "../../include/libssh", 45 | "../../include/", 46 | ] 47 | } 48 | print("-----------------------> tunnel!") 49 | -------------------------------------------------------------------------------- /src/util/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2022 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 2 | # Redistribution and use in source and binary forms, with or without modification, 3 | # are permitted provided that the following conditions are met: 4 | # 1. Redistributions of source code must retain the above copyright notice, this list of 5 | # conditions and the following disclaimer. 6 | # 7 | # 2. Redistributions in binary form must reproduce the above copyright notice, this list 8 | # of conditions and the following disclaimer in the documentation and/or other materials 9 | # provided with the distribution. 10 | # 11 | # 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | # to endorse or promote products derived from this software without specific prior written 13 | # permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 17 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 19 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | static_library("util") { 28 | sources = [ 29 | "json_util.c", 30 | "log_util.c", 31 | "string_util.c", 32 | "mqttv5_util.c" 33 | ] 34 | 35 | cflags = [ "-Wno-unused-variable" ] 36 | cflags += [ "-Wno-unused-but-set-variable" ] 37 | cflags += [ "-Wno-unused-parameter" ] 38 | 39 | include_dirs = [ 40 | "../../include/util", 41 | "../../include/third_party/libboundscheck", 42 | "../../include/third_party/cjson", 43 | "../../include/third_party/zlib", 44 | "../../include/", 45 | ] 46 | } 47 | print("-----------------------> util!") 48 | 49 | -------------------------------------------------------------------------------- /src/util/mqttv5_util.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of 8 | * conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | * of conditions and the following disclaimer in the documentation and/or other materials 12 | * provided with the distribution. 13 | * 14 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include 32 | #include 33 | #include "mqttv5_util.h" 34 | 35 | #if defined(MQTTV5) 36 | // Linked list deletion 37 | void mqttV5_listFree(MQTTV5_USER_PRO *mqttData) 38 | { 39 | if (mqttData == NULL) { 40 | return; 41 | } 42 | MQTTV5_USER_PRO *propertiesA = mqttData; 43 | MQTTV5_USER_PRO *propertiesB = mqttData->nex; 44 | 45 | while (propertiesA != NULL) { 46 | free(propertiesA); 47 | propertiesA = propertiesB; 48 | if (propertiesA != NULL) { 49 | propertiesB = propertiesA->nex; 50 | } 51 | } 52 | } 53 | #endif --------------------------------------------------------------------------------