mirror of
https://github.com/outbackdingo/parodus.git
synced 2026-01-27 18:20:04 +00:00
Compare commits
95 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e66c984146 | ||
|
|
fb24b899f7 | ||
|
|
e04c5a106a | ||
|
|
34cacec824 | ||
|
|
96403b76b6 | ||
|
|
eb481cdd4b | ||
|
|
3077125fa9 | ||
|
|
1a7ae0b785 | ||
|
|
bc655cf9ba | ||
|
|
ad0491179d | ||
|
|
fa49a52a94 | ||
|
|
25baef78a8 | ||
|
|
9034ef9d10 | ||
|
|
9020089016 | ||
|
|
664690e6a6 | ||
|
|
4aed47b730 | ||
|
|
2f3f1424b4 | ||
|
|
91ae0e82e2 | ||
|
|
bfc2659bbb | ||
|
|
f9c2878cbf | ||
|
|
c84a1bdfad | ||
|
|
0b0309c3dd | ||
|
|
f4e358c179 | ||
|
|
c1fc8d877b | ||
|
|
581d7fc966 | ||
|
|
0673d2624e | ||
|
|
0f82e7c2d9 | ||
|
|
4acf7f63ba | ||
|
|
df67b95244 | ||
|
|
e6e37053d3 | ||
|
|
d5a9ff36f6 | ||
|
|
f4536b778e | ||
|
|
b65b3ab3b0 | ||
|
|
954080bbd1 | ||
|
|
c8a2c95ae4 | ||
|
|
59bba50bee | ||
|
|
3090e50b02 | ||
|
|
af4eeb9199 | ||
|
|
2dd392dac6 | ||
|
|
7eae3da3f2 | ||
|
|
6e5ecc87f9 | ||
|
|
893c1c7547 | ||
|
|
3e30328738 | ||
|
|
f7412f9710 | ||
|
|
2e11d7e3ba | ||
|
|
5ddac7dc47 | ||
|
|
79d8a84c2e | ||
|
|
6f7332d054 | ||
|
|
26d409d884 | ||
|
|
d3e758ccb4 | ||
|
|
4af1aaf418 | ||
|
|
8e00ec8e5e | ||
|
|
43f55f9a99 | ||
|
|
bf3ee65360 | ||
|
|
9ebe011cb0 | ||
|
|
2bfc0a3c32 | ||
|
|
37bb19eeaa | ||
|
|
2c4980cf9e | ||
|
|
2248f31658 | ||
|
|
b97643ec42 | ||
|
|
66b16aa58f | ||
|
|
d3a56df184 | ||
|
|
8b5346e69b | ||
|
|
2a28e5d3e8 | ||
|
|
33af3f3eec | ||
|
|
c9b34d3c3f | ||
|
|
4add1c07ca | ||
|
|
75c833e3a8 | ||
|
|
5359fc79cf | ||
|
|
623192e301 | ||
|
|
b6490ba5b3 | ||
|
|
20ccd81086 | ||
|
|
f9ac95642c | ||
|
|
ae5d027612 | ||
|
|
e139a2d6b6 | ||
|
|
f655d6382b | ||
|
|
267e0eb796 | ||
|
|
00251153a4 | ||
|
|
d328a56e1a | ||
|
|
1a169561e4 | ||
|
|
8019489b86 | ||
|
|
ee3e006908 | ||
|
|
797c9de17f | ||
|
|
0bf4d754e5 | ||
|
|
3d98b4a80b | ||
|
|
80a50dead6 | ||
|
|
dd69d5ec5d | ||
|
|
1b23de5a12 | ||
|
|
8ea342b537 | ||
|
|
124fc11232 | ||
|
|
32138613bb | ||
|
|
4cb167e8dd | ||
|
|
454ec26065 | ||
|
|
47af275929 | ||
|
|
193706c21c |
7
.github/workflows/push.yml
vendored
7
.github/workflows/push.yml
vendored
@@ -16,7 +16,6 @@ on:
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
|
||||
jobs:
|
||||
test:
|
||||
@@ -39,9 +38,9 @@ jobs:
|
||||
run: mkdir build
|
||||
|
||||
- name: Get Sonarcloud Binaries
|
||||
working-directory: build
|
||||
run: |
|
||||
../.github/scripts/get_sonarcloud.sh
|
||||
uses: xmidt-org/sonarcloud-installer-action@v1
|
||||
with:
|
||||
working-directory: build
|
||||
|
||||
- name: CMake
|
||||
working-directory: build
|
||||
|
||||
11
CHANGELOG.md
11
CHANGELOG.md
@@ -10,7 +10,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
- Fix Parodus connection stuck on interface up down received together
|
||||
- Update to use nopoll version 1.0.3
|
||||
|
||||
## [1.1.4]
|
||||
## [v1.1.5]
|
||||
- Add additional HTTP headers for call to Themis from Convey
|
||||
- Change default branch name to `main`
|
||||
|
||||
## [v1.1.4]
|
||||
- on connect retry, requery jwt only if it failed before
|
||||
- put two timestamps in connection health file; start conn and current
|
||||
- change health file update interval to 240sec
|
||||
@@ -105,8 +109,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
### Added
|
||||
- Initial creation
|
||||
|
||||
[Unreleased]: https://github.com/Comcast/parodus/compare/1.1.4...HEAD
|
||||
[1.1.4]: https://github.com/Comcast/parodus/compare/1.1.3...1.1.4
|
||||
[Unreleased]: https://github.com/Comcast/parodus/compare/v1.1.5...HEAD
|
||||
[1.1.5]: https://github.com/Comcast/parodus/compare/v1.1.4...v1.1.5
|
||||
[1.1.4]: https://github.com/Comcast/parodus/compare/1.1.3...v1.1.4
|
||||
[1.1.3]: https://github.com/Comcast/parodus/compare/1.1.2...1.1.3
|
||||
[1.1.2]: https://github.com/Comcast/parodus/compare/1.1.1...1.1.2
|
||||
[1.1.1]: https://github.com/Comcast/parodus/compare/1.0.4...1.1.1
|
||||
|
||||
102
CMakeLists.txt
102
CMakeLists.txt
@@ -12,9 +12,9 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.7)
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
#project(parodus VERSION 1.1.15)
|
||||
#project(parodus VERSION 1.1.5)
|
||||
project(parodus)
|
||||
|
||||
include(ExternalProject)
|
||||
@@ -44,12 +44,10 @@ include_directories(${INCLUDE_DIR}
|
||||
)
|
||||
|
||||
if (ENABLE_WEBCFGBIN)
|
||||
include_directories(${INCLUDE_DIR}/rbus
|
||||
${INCLUDE_DIR}/rbus-core
|
||||
${INCLUDE_DIR}/rtmessage
|
||||
)
|
||||
include_directories(${INCLUDE_DIR}/rbus)
|
||||
endif (ENABLE_WEBCFGBIN)
|
||||
|
||||
|
||||
# Get git commit hash
|
||||
#-------------------------------------------------------------------------------
|
||||
execute_process(
|
||||
@@ -66,9 +64,18 @@ add_definitions("-DGIT_COMMIT_TAG=\"${GIT_COMMIT_TAG}\"")
|
||||
add_definitions(-std=c99)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -DNOPOLL_LOGGER ")
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall -Wno-missing-field-initializers")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall")
|
||||
if (DEVICE_CAMERA)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=all -Wno-missing-field-initializers")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=all")
|
||||
add_definitions(-DDEVICE_CAMERA)
|
||||
else ()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=all -Wno-missing-field-initializers")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=all")
|
||||
endif (DEVICE_CAMERA)
|
||||
|
||||
if (INCLUDE_BREAKPAD)
|
||||
add_definitions(-DINCLUDE_BREAKPAD)
|
||||
endif (INCLUDE_BREAKPAD)
|
||||
|
||||
# pthread external dependency
|
||||
#-------------------------------------------------------------------------------
|
||||
@@ -173,7 +180,7 @@ ExternalProject_Add(wrp-c
|
||||
DEPENDS trower-base64 msgpack cimplog
|
||||
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/wrp-c
|
||||
GIT_REPOSITORY https://github.com/xmidt-org/wrp-c.git
|
||||
GIT_TAG "71f8a39fe39f98da007ed4cdabbb192be1da1685"
|
||||
GIT_TAG "b5ef4d10cb39905908788bc89ab3e4dab201db8a"
|
||||
CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
|
||||
-DMSGPACK_ENABLE_CXX=OFF
|
||||
-DMSGPACK_BUILD_EXAMPLES=OFF
|
||||
@@ -219,6 +226,42 @@ ExternalProject_Add(cjwt
|
||||
add_library(libcjwt STATIC SHARED IMPORTED)
|
||||
add_dependencies(libcjwt cjwt)
|
||||
|
||||
# libmsh3 external dependency
|
||||
#-------------------------------------------------------------------------------
|
||||
ExternalProject_Add(msh3
|
||||
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/msh3
|
||||
GIT_REPOSITORY https://github.com/nibanks/msh3.git
|
||||
GIT_TAG "v0.6.0"
|
||||
GIT_SUBMODULES_RECURSE true
|
||||
CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -G "Unix Makefiles" -DBUILD_TESTING=OFF
|
||||
)
|
||||
add_library(libmsh3 STATIC SHARED IMPORTED)
|
||||
add_dependencies(libmsh3 msh3)
|
||||
|
||||
|
||||
# libmsquic external dependency
|
||||
#-------------------------------------------------------------------------------
|
||||
# ExternalProject_Add(msquic
|
||||
# PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/msquic
|
||||
# GIT_REPOSITORY https://github.com/microsoft/msquic.git
|
||||
# GIT_TAG "v2.1.8"
|
||||
# CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DBUILD_TESTING=OFF
|
||||
# )
|
||||
# add_library(libmsquic STATIC SHARED IMPORTED)
|
||||
# add_dependencies(libmsquic msquic)
|
||||
|
||||
# # libnghttp3 external dependency
|
||||
# #-------------------------------------------------------------------------------
|
||||
# ExternalProject_Add(nghttp3
|
||||
# PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/nghttp3
|
||||
|
||||
# GIT_REPOSITORY https://github.com/ngtcp2/nghttp3.git
|
||||
# GIT_TAG "v0.10.0"
|
||||
# CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DBUILD_TESTING=OFF
|
||||
# )
|
||||
# add_library(libnghttp3 STATIC SHARED IMPORTED)
|
||||
# add_dependencies(libnghttp3 nghttp3)
|
||||
|
||||
if (FEATURE_DNS_QUERY)
|
||||
# libucresolv external dependency
|
||||
#-------------------------------------------------------------------------------
|
||||
@@ -237,46 +280,21 @@ include_directories(${INCLUDE_DIR}
|
||||
endif (FEATURE_DNS_QUERY)
|
||||
|
||||
if (ENABLE_WEBCFGBIN)
|
||||
# rtMessage external dependency
|
||||
#-------------------------------------------------------------------------------
|
||||
ExternalProject_Add(rtMessage
|
||||
DEPENDS cJSON
|
||||
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/rtMessage
|
||||
GIT_REPOSITORY https://github.com/rdkcmf/rdk-rtmessage.git
|
||||
GIT_TAG rdk-next
|
||||
CMAKE_ARGS += -DBUILD_RTMESSAGE_LIB=ON
|
||||
-DBUILD_RTMESSAGE_SAMPLE_APP=ON
|
||||
-DBUILD_FOR_DESKTOP=OFF
|
||||
-DCJSON_BUILD=OFF
|
||||
-DBUILD_DATAPROVIDER_LIB=ON
|
||||
-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DBUILD_TESTING=OFF
|
||||
)
|
||||
add_library(librtMessage STATIC SHARED IMPORTED)
|
||||
add_dependencies(librtMessage rtMessage)
|
||||
|
||||
# rbus-core external dependency
|
||||
#-------------------------------------------------------------------------------
|
||||
ExternalProject_Add(rbus-core
|
||||
DEPENDS rtMessage
|
||||
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/rbus-core
|
||||
GIT_REPOSITORY https://github.com/rdkcmf/rbuscore.git
|
||||
GIT_TAG rdk-next
|
||||
CMAKE_ARGS += -DBUILD_FOR_DESKTOP=ON -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
|
||||
-DBUILD_TESTING=OFF
|
||||
)
|
||||
add_library(librbus-core STATIC SHARED IMPORTED)
|
||||
add_dependencies(librbus-core rbus-core)
|
||||
|
||||
# rbus external dependency
|
||||
#-------------------------------------------------------------------------------
|
||||
ExternalProject_Add(rbus
|
||||
DEPENDS rtMessage rbus-core
|
||||
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/rbus
|
||||
GIT_REPOSITORY https://github.com/rdkcmf/rbus.git
|
||||
GIT_TAG rdk-next
|
||||
GIT_REPOSITORY https://github.com/rdkcentral/rbus.git
|
||||
GIT_TAG main
|
||||
CMAKE_ARGS += -DBUILD_FOR_DESKTOP=ON -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DBUILD_TESTING=OFF
|
||||
)
|
||||
|
||||
add_library(librbuscore STATIC SHARED IMPORTED)
|
||||
add_dependencies(librbuscore rbuscore)
|
||||
|
||||
add_library(librtMessage STATIC SHARED IMPORTED)
|
||||
add_dependencies(librtMessage rtMessage)
|
||||
|
||||
add_library(librbus STATIC SHARED IMPORTED)
|
||||
add_dependencies(librbus rbus)
|
||||
endif (ENABLE_WEBCFGBIN)
|
||||
|
||||
19
Dockerfile
Normal file
19
Dockerfile
Normal file
@@ -0,0 +1,19 @@
|
||||
# build stage
|
||||
FROM alpine:3.12
|
||||
|
||||
RUN \
|
||||
apk add --no-cache bsd-compat-headers linux-headers cmake autoconf make musl-dev gcc g++ openssl openssl-dev git cunit cunit-dev automake libtool util-linux-dev && \
|
||||
mkdir -p build
|
||||
|
||||
|
||||
COPY src src
|
||||
COPY patches patches
|
||||
COPY tests tests
|
||||
COPY CMakeLists.txt .
|
||||
COPY run.sh .
|
||||
|
||||
|
||||
RUN cd build && \
|
||||
cmake .. && make
|
||||
|
||||
CMD ["build/src/parodus"]
|
||||
78
run.sh
Executable file
78
run.sh
Executable file
@@ -0,0 +1,78 @@
|
||||
#!/bin/sh
|
||||
parodus_port=16014d
|
||||
|
||||
if [[ -z "${URL}" ]]; then
|
||||
URL="http://petasos:6400"
|
||||
fi
|
||||
|
||||
if [[ -z "${FIRMWARE}" ]]; then
|
||||
FIRMWARE="mock-rdkb-firmware"
|
||||
fi
|
||||
|
||||
if [[ -z "${BOOT_TIME}" ]]; then
|
||||
BOOT_TIME=$(date +%s)
|
||||
fi
|
||||
|
||||
if [[ -z "${HW_MANUFACTURER}" ]]; then
|
||||
HW_MANUFACTURER="Example Inc."
|
||||
fi
|
||||
|
||||
if [[ -z "${REBOOT_REASON}" ]]; then
|
||||
REBOOT_REASON="unknown"
|
||||
fi
|
||||
|
||||
if [[ -z "${SERIAL_NUMBER}" ]]; then
|
||||
SERIAL_NUMBER="mock-rdkb-simulator"
|
||||
fi
|
||||
|
||||
if [[ -z "${PARTNER_ID}" ]]; then
|
||||
PARTNER_ID="comcast"
|
||||
fi
|
||||
|
||||
if [[ -z "${CMAC}" ]]; then
|
||||
CMAC="112233445566"
|
||||
fi
|
||||
|
||||
if [[ -z "${TOKEN_SERVER_URL}" ]]; then
|
||||
TOKEN_SERVER_URL="http://themis:6501/issue"
|
||||
fi
|
||||
|
||||
if [[ -z "${SSL_CERT_PATH}" ]]; then
|
||||
SSL_CERT_PATH="/etc/ssl/certs/ca-certificates.crt"
|
||||
fi
|
||||
|
||||
#In this docker-compose cluster, themis has mtls disabled so
|
||||
#feel free to ignore the --client-cert-path flag value
|
||||
#it is required by parodus to fetch a token
|
||||
if [[ -z "${CLIENT_CERT_PATH}" ]]; then
|
||||
CLIENT_CERT_PATH="/etc/ssl/certs/ca-certificates.crt"
|
||||
fi
|
||||
|
||||
# MTLS_CLIENT_* is used to authenticate with talaria.
|
||||
if [[ -z "${MTLS_CLIENT_CERT_PATH}" ]]; then
|
||||
MTLS_CLIENT_CERT_PATH=""
|
||||
fi
|
||||
|
||||
if [[ -z "${MTLS_CLIENT_KEY_PATH}" ]]; then
|
||||
MTLS_CLIENT_KEY_PATH=""
|
||||
fi
|
||||
|
||||
build/src/parodus --hw-model=aker-testing \
|
||||
--ssl-cert-path=$SSL_CERT_PATH \
|
||||
--client-cert-path=$CLIENT_CERT_PATH \
|
||||
--mtls-client-cert-path=$MTLS_CLIENT_CERT_PATH \
|
||||
--mtls-client-key-path=$MTLS_CLIENT_KEY_PATH \
|
||||
--hw-serial-number=$SERIAL_NUMBER \
|
||||
--hw-manufacturer=$HW_MANUFACTURER \
|
||||
--hw-mac=$CMAC \
|
||||
--hw-last-reboot-reason=$REBOOT_REASON \
|
||||
--fw-name=$FIRMWARE \
|
||||
--boot-time=$BOOT_TIME \
|
||||
--partner-id=$PARTNER_ID \
|
||||
--parodus-local-url=tcp://127.0.0.1:$parodus_port \
|
||||
--webpa-ping-timeout=60 \
|
||||
--token-server-url=$TOKEN_SERVER_URL \
|
||||
--webpa-backoff-max=2 \
|
||||
--webpa-interface-used=eth0 \
|
||||
--webpa-url=$URL \
|
||||
--force-ipv4
|
||||
@@ -63,6 +63,6 @@ target_link_libraries (parodus -llibseshat)
|
||||
endif (ENABLE_SESHAT)
|
||||
|
||||
if (ENABLE_WEBCFGBIN)
|
||||
target_link_libraries (parodus -lrbus -lrbus-core -lrtMessage)
|
||||
target_link_libraries (parodus -lrbus)
|
||||
endif (ENABLE_WEBCFGBIN)
|
||||
install (TARGETS parodus DESTINATION bin)
|
||||
|
||||
@@ -164,6 +164,7 @@ void timespec_diff(struct timespec *start, struct timespec *stop,
|
||||
#ifdef ENABLE_WEBCFGBIN
|
||||
void subscribeRBUSevent();
|
||||
int regXmidtSendDataMethod();
|
||||
void registerRbusLogger();
|
||||
#endif
|
||||
#ifdef WAN_FAILOVER_SUPPORTED
|
||||
void setWebpaInterface(char *value);
|
||||
@@ -188,7 +189,9 @@ pthread_mutex_t *get_interface_down_mut();
|
||||
pthread_cond_t *get_global_cloud_status_cond(void);
|
||||
|
||||
pthread_mutex_t *get_global_cloud_status_mut(void);
|
||||
|
||||
|
||||
int cloud_status_is_online (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -223,8 +223,14 @@ void getAuthToken(ParodusCfg *cfg)
|
||||
* @param[in] nmemb size of delivered data
|
||||
* @param[out] data curl response data saved.
|
||||
*/
|
||||
#ifndef DEVICE_CAMERA
|
||||
size_t write_callback_fn(void *buffer, size_t size, size_t nmemb, struct token_data *data)
|
||||
{
|
||||
#else
|
||||
size_t write_callback_fn(void *buffer, size_t size, size_t nmemb, void *datain)
|
||||
{
|
||||
struct token_data *data = (struct token_data*) datain;
|
||||
#endif //DEVICE_CAMERA
|
||||
ParodusCfg *cfg;
|
||||
size_t max_data_size = sizeof (cfg->webpa_auth_token);
|
||||
size_t index = data->size;
|
||||
|
||||
@@ -47,7 +47,11 @@ struct token_data {
|
||||
|
||||
int requestNewAuthToken(char *newToken, size_t len, int r_count);
|
||||
void getAuthToken(ParodusCfg *cfg);
|
||||
#ifndef DEVICE_CAMERA
|
||||
size_t write_callback_fn(void *buffer, size_t size, size_t nmemb, struct token_data *data);
|
||||
#else
|
||||
size_t write_callback_fn(void *buffer, size_t size, size_t nmemb, void *data);
|
||||
#endif
|
||||
char* generate_trans_uuid();
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
66
src/config.c
66
src/config.c
@@ -41,7 +41,6 @@ pthread_cond_t cloud_status_cond=PTHREAD_COND_INITIALIZER;
|
||||
|
||||
char webpa_interface[64]={'\0'};
|
||||
|
||||
char cloud_status[32]={'\0'};
|
||||
static ParodusCfg parodusCfg;
|
||||
static unsigned int rsa_algorithms =
|
||||
(1<<alg_rs256) | (1<<alg_rs384) | (1<<alg_rs512);
|
||||
@@ -94,10 +93,14 @@ void set_cloud_status(char *status)
|
||||
|
||||
char *get_cloud_status(void)
|
||||
{
|
||||
char *status = NULL;
|
||||
pthread_mutex_lock(&config_mut);
|
||||
parStrncpy(cloud_status, get_parodus_cfg()->cloud_status, sizeof(cloud_status));
|
||||
pthread_mutex_unlock(&config_mut);
|
||||
return cloud_status;
|
||||
if(NULL != get_parodus_cfg()->cloud_status)
|
||||
{
|
||||
status = get_parodus_cfg()->cloud_status;
|
||||
}
|
||||
pthread_mutex_unlock(&config_mut);
|
||||
return status;
|
||||
}
|
||||
|
||||
const char *get_tok (const char *src, int delim, char *result, int resultsize)
|
||||
@@ -208,6 +211,38 @@ int parse_mac_address (char *target, const char *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int parse_serial_num(char *target, const char *arg)
|
||||
{
|
||||
char ch;
|
||||
if(arg != NULL)
|
||||
{
|
||||
if(strlen(arg) == 0)
|
||||
{
|
||||
ParodusError("Empty serial number, setting to default unknown\n");
|
||||
strcpy(target,"unknown");
|
||||
}
|
||||
for(int i=0; (ch = arg[i]) != '\0'; i++)
|
||||
{
|
||||
// check if character is ascii, a-z --> 97 to 122, A-Z --> 65 to 90, digits(0 to 9) --> 48 to 57
|
||||
if((ch >= 97 && ch <= 122) || (ch >= 65 && ch <= 90) || (ch >=48 && ch <= 57))
|
||||
{
|
||||
target[i] = ch;
|
||||
}
|
||||
else
|
||||
{
|
||||
ParodusError("Invalid serial number, setting to default unknown\n");
|
||||
strcpy(target,"unknown");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ParodusError("serial number argument is NULL\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int server_is_http (const char *full_url,
|
||||
const char **server_ptr)
|
||||
{
|
||||
@@ -400,6 +435,9 @@ int parseCommandLine(int argc,char **argv,ParodusCfg * cfg)
|
||||
{"webpa-backoff-max", required_argument, 0, 'o'},
|
||||
{"webpa-interface-used", required_argument, 0, 'i'},
|
||||
{"parodus-local-url", required_argument, 0, 'l'},
|
||||
#ifdef ENABLE_WEBCFGBIN
|
||||
{"max-queue-size", required_argument, 0, 'q'},
|
||||
#endif
|
||||
{"partner-id", required_argument, 0, 'p'},
|
||||
#ifdef ENABLE_SESHAT
|
||||
{"seshat-url", required_argument, 0, 'e'},
|
||||
@@ -447,7 +485,7 @@ int parseCommandLine(int argc,char **argv,ParodusCfg * cfg)
|
||||
/* getopt_long stores the option index here. */
|
||||
int option_index = 0;
|
||||
c = getopt_long (argc, argv,
|
||||
"m:s:f:d:r:n:b:u:t:o:i:l:p:e:D:j:a:k:c:T:w:J:46:C:S:R:K:M",
|
||||
"m:s:f:d:r:n:b:u:t:o:i:l:q:p:e:D:j:a:k:c:T:w:J:46:C:S:R:K:M",
|
||||
long_options, &option_index);
|
||||
|
||||
/* Detect the end of the options. */
|
||||
@@ -462,8 +500,8 @@ int parseCommandLine(int argc,char **argv,ParodusCfg * cfg)
|
||||
break;
|
||||
|
||||
case 's':
|
||||
parStrncpy(cfg->hw_serial_number,optarg,sizeof(cfg->hw_serial_number));
|
||||
ParodusInfo("hw_serial_number is %s\n",cfg->hw_serial_number);
|
||||
if(parse_serial_num(cfg->hw_serial_number, optarg) == 0)
|
||||
ParodusInfo ("hw_serial_number is %s\n",cfg->hw_serial_number);
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
@@ -533,6 +571,16 @@ int parseCommandLine(int argc,char **argv,ParodusCfg * cfg)
|
||||
parStrncpy(cfg->local_url, optarg,sizeof(cfg->local_url));
|
||||
ParodusInfo("parodus local_url is %s\n",cfg->local_url);
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_WEBCFGBIN
|
||||
case 'q':
|
||||
cfg->max_queue_size = parse_num_arg (optarg, "max-queue-size");
|
||||
if (cfg->max_queue_size == (unsigned int) -1)
|
||||
return -1;
|
||||
ParodusInfo("max_queue_size is %d\n",cfg->max_queue_size);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 'D':
|
||||
// like 'fabric' or 'test'
|
||||
// this parameter is used, along with the hw_mac parameter
|
||||
@@ -837,7 +885,9 @@ void loadParodusCfg(ParodusCfg * config,ParodusCfg *cfg)
|
||||
parStrncpy(cfg->cert_path, "\0", sizeof(cfg->cert_path));
|
||||
ParodusPrint("cert_path is NULL. set to empty\n");
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WEBCFGBIN
|
||||
cfg->max_queue_size = config->max_queue_size;
|
||||
#endif
|
||||
cfg->boot_time = config->boot_time;
|
||||
cfg->webpa_ping_timeout = config->webpa_ping_timeout;
|
||||
cfg->webpa_backoff_max = config->webpa_backoff_max;
|
||||
|
||||
@@ -88,6 +88,9 @@ typedef struct
|
||||
char webpa_uuid[64];
|
||||
unsigned int flags;
|
||||
char local_url[124];
|
||||
#ifdef ENABLE_WEBCFGBIN
|
||||
unsigned int max_queue_size;
|
||||
#endif
|
||||
char partner_id[64];
|
||||
#ifdef ENABLE_SESHAT
|
||||
char seshat_url[128];
|
||||
|
||||
@@ -99,7 +99,9 @@ void createSocketConnection(void (* initKeypress)())
|
||||
#endif
|
||||
|
||||
EventHandler();
|
||||
|
||||
#ifdef WAN_FAILOVER_SUPPORTED
|
||||
subscribeCurrentActiveInterfaceEvent();
|
||||
#endif
|
||||
set_server_list_null (&server_list);
|
||||
create_conn_rtn = createNopollConnection(ctx, &server_list);
|
||||
if(!create_conn_rtn)
|
||||
@@ -113,9 +115,6 @@ void createSocketConnection(void (* initKeypress)())
|
||||
UpStreamMsgQ = NULL;
|
||||
StartThread(handle_upstream, &upstream_tid);
|
||||
StartThread(processUpstreamMessage, &upstream_msg_tid);
|
||||
#ifdef WAN_FAILOVER_SUPPORTED
|
||||
subscribeCurrentActiveInterfaceEvent();
|
||||
#endif
|
||||
ParodusMsgQ = NULL;
|
||||
StartThread(messageHandlerTask, &downstream_tid);
|
||||
StartThread(serviceAliveTask, &svc_alive_tid);
|
||||
|
||||
@@ -239,7 +239,7 @@ void init_backoff_timer (backoff_timer_t *timer, int max_count)
|
||||
timer->count = 1;
|
||||
timer->max_count = max_count;
|
||||
timer->delay = 1;
|
||||
clock_gettime (CLOCK_REALTIME, &timer->ts);
|
||||
clock_gettime (CLOCK_MONOTONIC, &timer->ts);
|
||||
timer->start_time = time(NULL);
|
||||
}
|
||||
|
||||
@@ -325,8 +325,14 @@ static int backoff_delay (backoff_timer_t *timer)
|
||||
struct timespec ts;
|
||||
int rtn;
|
||||
|
||||
pthread_condattr_t backoff_delay_cond_attr;
|
||||
|
||||
pthread_condattr_init (&backoff_delay_cond_attr);
|
||||
pthread_condattr_setclock (&backoff_delay_cond_attr, CLOCK_MONOTONIC);
|
||||
pthread_cond_init (&backoff_delay_con, &backoff_delay_cond_attr);
|
||||
|
||||
// periodically update the health file.
|
||||
clock_gettime (CLOCK_REALTIME, &ts);
|
||||
clock_gettime (CLOCK_MONOTONIC, &ts);
|
||||
if ((ts.tv_sec - timer->ts.tv_sec) >= UPDATE_HEALTH_FILE_INTERVAL_SECS) {
|
||||
start_conn_in_progress (timer->start_time);
|
||||
timer->ts.tv_sec += UPDATE_HEALTH_FILE_INTERVAL_SECS;
|
||||
@@ -339,6 +345,8 @@ static int backoff_delay (backoff_timer_t *timer)
|
||||
rtn = pthread_cond_timedwait (&backoff_delay_con, &backoff_delay_mut, &ts);
|
||||
pthread_mutex_unlock (&backoff_delay_mut);
|
||||
|
||||
pthread_condattr_destroy(&backoff_delay_cond_attr);
|
||||
|
||||
if (g_shutdown)
|
||||
return BACKOFF_SHUTDOWN;
|
||||
if ((rtn != 0) && (rtn != ETIMEDOUT)) {
|
||||
@@ -775,8 +783,7 @@ int createNopollConnection(noPollCtx *ctx, server_list_t *server_list)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if(conn_ctx.current_server->allow_insecure <= 0)
|
||||
if(conn_ctx.current_server != NULL && conn_ctx.current_server->allow_insecure <= 0)
|
||||
{
|
||||
ParodusInfo("Connected to server over SSL\n");
|
||||
OnboardLog("Connected to server over SSL\n");
|
||||
|
||||
138
src/connection_http3.cpp
Normal file
138
src/connection_http3.cpp
Normal file
@@ -0,0 +1,138 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
Licensed under the MIT License.
|
||||
|
||||
--*/
|
||||
|
||||
#include "msh3.hpp"
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
|
||||
using namespace std;
|
||||
|
||||
char * host = "nginx";
|
||||
//char * path = "/api/v2/devices"
|
||||
char * path = "/"
|
||||
|
||||
struct Arguments {
|
||||
const char* Host { host };
|
||||
MsH3Addr Address {443};
|
||||
vector<const char*> Paths {path};
|
||||
bool Unsecure { true };
|
||||
bool Print { true };
|
||||
uint32_t Count { 1 };
|
||||
} Args;
|
||||
|
||||
void MSH3_CALL HeaderReceived(struct MsH3Request* , const MSH3_HEADER* Header) {
|
||||
if (Args.Print) {
|
||||
fwrite(Header->Name, 1, Header->NameLength, stdout);
|
||||
printf(":");
|
||||
fwrite(Header->Value, 1, Header->ValueLength, stdout);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
bool MSH3_CALL DataReceived(struct MsH3Request* , uint32_t* Length, const uint8_t* Data) {
|
||||
if (Args.Print) fwrite(Data, 1, *Length, stdout);
|
||||
return true;
|
||||
}
|
||||
|
||||
void MSH3_CALL Complete(struct MsH3Request* Request, bool Aborted, uint64_t AbortError) {
|
||||
const uint32_t Index = (uint32_t)(size_t)Request->AppContext;
|
||||
if (Args.Print) printf("\n");
|
||||
if (Aborted) printf("Request %u aborted: 0x%llx\n", Index, (long long unsigned)AbortError);
|
||||
else printf("Request %u complete\n", Index);
|
||||
}
|
||||
|
||||
void ParseArgs(int argc, char **argv) {
|
||||
if (argc < 2 || !strcmp(argv[1], "-?") || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
|
||||
printf("usage: %s <server[:port]> [options...]\n"
|
||||
" -c, --count <num> The number of times to query each path (def=1)\n"
|
||||
" -h, --help Prints this help text\n"
|
||||
" -p, --path <path(s)> The paths to query\n"
|
||||
" -u, --unsecure Allows unsecure connections\n"
|
||||
" -v, --verbose Enables verbose output\n"
|
||||
" -V, --version Prints out the version\n",
|
||||
argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// Parse the server[:port] argument.
|
||||
Args.Host = argv[1];
|
||||
char *port = strrchr(argv[1], ':');
|
||||
if (port) {
|
||||
*port = 0; port++;
|
||||
Args.Address.SetPort((uint16_t)atoi(port));
|
||||
}
|
||||
|
||||
// Parse options.
|
||||
for (int i = 2; i < argc; ++i) {
|
||||
if (!strcmp(argv[i], "--count") || !strcmp(argv[i], "-c")) {
|
||||
if (++i >= argc) { printf("Missing count value\n"); exit(-1); }
|
||||
Args.Count = (uint32_t)atoi(argv[i]);
|
||||
|
||||
} else if (!strcmp(argv[i], "--path") || !strcmp(argv[i], "-p")) {
|
||||
if (++i >= argc) { printf("Missing path value(s)\n"); exit(-1); }
|
||||
|
||||
char* Path = (char*)argv[i];
|
||||
do {
|
||||
char* End = strchr(Path, ',');
|
||||
if (End) *End = 0;
|
||||
Args.Paths.push_back(Path);
|
||||
if (!End) break;
|
||||
Path = End + 1;
|
||||
} while (true);
|
||||
|
||||
} else if (!strcmp(argv[i], "--unsecure") || !strcmp(argv[i], "-u")) {
|
||||
Args.Unsecure = true;
|
||||
|
||||
} else if (!strcmp(argv[i], "--verbose") || !strcmp(argv[i], "-v")) {
|
||||
Args.Print = true;
|
||||
|
||||
} else if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-V")) {
|
||||
uint32_t Version[4]; MsH3Version(Version);
|
||||
printf("Using msh3 v%u.%u.%u.%u\n", Version[0], Version[1], Version[2], Version[3]);
|
||||
}
|
||||
}
|
||||
|
||||
if (Args.Paths.empty()) {
|
||||
Args.Paths.push_back("/");
|
||||
}
|
||||
}
|
||||
|
||||
int MSH3_CALL init(int argc, char **argv) {
|
||||
ParseArgs(argc, argv);
|
||||
|
||||
MSH3_HEADER Headers[] = {
|
||||
{ ":method", 7, "GET", 3 },
|
||||
{ ":path", 5, Args.Paths[0], strlen(Args.Paths[0]) },
|
||||
{ ":scheme", 7, "https", 5 },
|
||||
{ ":authority", 10, Args.Host, strlen(Args.Host) },
|
||||
{ "user-agent", 10, "curl/7.82.0-DEV", 15 },
|
||||
{ "accept", 6, "*/*", 3 },
|
||||
};
|
||||
const size_t HeadersCount = sizeof(Headers)/sizeof(MSH3_HEADER);
|
||||
|
||||
MsH3Api Api;
|
||||
if (Api.IsValid()) {
|
||||
MsH3Connection Connection(Api, Args.Host, Args.Address, Args.Unsecure);
|
||||
if (Connection.IsValid()) {
|
||||
for (auto Path : Args.Paths) {
|
||||
printf("HTTP/3 GET https://%s%s\n", Args.Host, Path);
|
||||
Headers[1].Value = Path;
|
||||
Headers[1].ValueLength = strlen(Path);
|
||||
for (uint32_t i = 0; i < Args.Count; ++i) {
|
||||
auto Request = new (std::nothrow) MsH3Request(Connection, Headers, HeadersCount, MSH3_REQUEST_FLAG_FIN, (void*)(size_t)(i+1), HeaderReceived, DataReceived, Complete, CleanUpAutoDelete);
|
||||
if (!Request || !Request->IsValid()) {
|
||||
printf("Request %u failed to start\n", i+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Connection.ShutdownComplete.Wait();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -27,6 +27,9 @@
|
||||
#include "partners_check.h"
|
||||
#include "ParodusInternal.h"
|
||||
#include "crud_interface.h"
|
||||
#ifdef ENABLE_WEBCFGBIN
|
||||
#include "xmidtsend_rbus.h"
|
||||
#endif
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Function Prototypes */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
@@ -91,6 +94,7 @@ void listenerOnMessage(void * msg, size_t msgSize)
|
||||
{
|
||||
ParodusPrint("numOfClients registered is %d\n", get_numOfClients());
|
||||
int ret = validate_partner_id(message, NULL);
|
||||
ParodusPrint("validate_partner_id returns %d\n", ret);
|
||||
if(ret < 0)
|
||||
{
|
||||
response = cJSON_CreateObject();
|
||||
@@ -98,7 +102,6 @@ void listenerOnMessage(void * msg, size_t msgSize)
|
||||
cJSON_AddStringToObject(response, "message", "Invalid partner_id");
|
||||
}
|
||||
|
||||
|
||||
destVal = strdup(((WRP_MSG_TYPE__EVENT == msgType) ? message->u.event.dest :
|
||||
((WRP_MSG_TYPE__REQ == msgType) ? message->u.req.dest : message->u.crud.dest)));
|
||||
|
||||
@@ -120,10 +123,10 @@ void listenerOnMessage(void * msg, size_t msgSize)
|
||||
}
|
||||
ParodusInfo("Received downstream dest as :%s and transaction_uuid :%s\n", dest,
|
||||
((WRP_MSG_TYPE__REQ == msgType) ? message->u.req.transaction_uuid :
|
||||
((WRP_MSG_TYPE__EVENT == msgType) ? "NA" : message->u.crud.transaction_uuid)));
|
||||
((WRP_MSG_TYPE__EVENT == msgType) ? message->u.event.transaction_uuid : message->u.crud.transaction_uuid)));
|
||||
OnboardLog("%s\n",
|
||||
((WRP_MSG_TYPE__REQ == msgType) ? message->u.req.transaction_uuid :
|
||||
((WRP_MSG_TYPE__EVENT == msgType) ? "NA" : message->u.crud.transaction_uuid)));
|
||||
((WRP_MSG_TYPE__EVENT == msgType) ? message->u.event.transaction_uuid : message->u.crud.transaction_uuid)));
|
||||
|
||||
free(destVal);
|
||||
|
||||
@@ -168,13 +171,16 @@ void listenerOnMessage(void * msg, size_t msgSize)
|
||||
destFlag =1;
|
||||
}
|
||||
//if any unknown dest received sending error response to server
|
||||
if(destFlag ==0)
|
||||
{
|
||||
ParodusError("Unknown dest:%s\n", dest);
|
||||
response = cJSON_CreateObject();
|
||||
cJSON_AddNumberToObject(response, "statusCode", 531);
|
||||
cJSON_AddStringToObject(response, "message", "Service Unavailable");
|
||||
}
|
||||
if (WRP_MSG_TYPE__EVENT != msgType)
|
||||
{
|
||||
if(destFlag ==0)
|
||||
{
|
||||
ParodusError("Unknown dest:%s\n", dest);
|
||||
response = cJSON_CreateObject();
|
||||
cJSON_AddNumberToObject(response, "statusCode", 531);
|
||||
cJSON_AddStringToObject(response, "message", "Service Unavailable");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( (WRP_MSG_TYPE__EVENT != msgType) &&
|
||||
@@ -235,6 +241,37 @@ void listenerOnMessage(void * msg, size_t msgSize)
|
||||
}
|
||||
free(resp_msg);
|
||||
}
|
||||
#ifdef ENABLE_WEBCFGBIN
|
||||
//To handle cloud ack events received from server for the xmidt sent messages.
|
||||
if((WRP_MSG_TYPE__EVENT == msgType) && (ret >= 0))
|
||||
{
|
||||
if(get_parodus_cfg()->max_queue_size > 0)
|
||||
{
|
||||
//Process cloud ack only when qos > 24
|
||||
if(highQosValueCheck(message->u.event.qos))
|
||||
{
|
||||
if(message->u.event.transaction_uuid !=NULL)
|
||||
{
|
||||
ParodusInfo("Received cloud ack from server: transaction_uuid %s qos %d, rdr %d source %s\n", message->u.event.transaction_uuid, message->u.event.qos, message->u.event.rdr, message->u.event.source);
|
||||
addToCloudAckQ(message->u.event.transaction_uuid, message->u.event.qos, message->u.event.rdr, message->u.event.source);
|
||||
ParodusPrint("Added to cloud ack Q\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
ParodusError("cloud ack transaction id is NULL\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ParodusInfo("cloud ack received with low qos %d, ignoring it\n", message->u.event.qos);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ParodusInfo("cloud ack is ignored as max queue size is %d\n", get_parodus_cfg()->max_queue_size );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,12 +22,15 @@
|
||||
*/
|
||||
|
||||
#include "heartBeat.h"
|
||||
#include "time.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
volatile unsigned int heartBeatTimer = 0;
|
||||
volatile bool paused = false;
|
||||
volatile long long pingTimeStamp = 0;
|
||||
|
||||
pthread_mutex_t heartBeat_mut=PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_mutex_t ping_mut=PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
// Get value of heartBeatTimer
|
||||
unsigned int get_heartBeatTimer()
|
||||
@@ -73,5 +76,22 @@ void resume_heartBeatTimer()
|
||||
pthread_mutex_unlock (&heartBeat_mut);
|
||||
}
|
||||
|
||||
// Set ping received timeStamp
|
||||
void set_pingTimeStamp()
|
||||
{
|
||||
struct timespec ts;
|
||||
getCurrentTime(&ts);
|
||||
pthread_mutex_lock (&ping_mut);
|
||||
pingTimeStamp = (long long)ts.tv_sec;
|
||||
pthread_mutex_unlock (&ping_mut);
|
||||
}
|
||||
|
||||
|
||||
// Get ping received timeStamp
|
||||
long long get_pingTimeStamp()
|
||||
{
|
||||
long long tmp = 0;
|
||||
pthread_mutex_lock (&ping_mut);
|
||||
tmp = pingTimeStamp;
|
||||
pthread_mutex_unlock (&ping_mut);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,10 @@ void pause_heartBeatTimer();
|
||||
// Resume heartBeatTimer, i.e. resume incrementing
|
||||
void resume_heartBeatTimer();
|
||||
|
||||
void set_pingTimeStamp();
|
||||
|
||||
long long get_pingTimeStamp();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
15
src/main.c
15
src/main.c
@@ -24,7 +24,11 @@
|
||||
#include "parodus_log.h"
|
||||
#include <curl/curl.h>
|
||||
#ifdef INCLUDE_BREAKPAD
|
||||
#ifndef DEVICE_CAMERA
|
||||
#include "breakpad_wrapper.h"
|
||||
#else
|
||||
#include "breakpadwrap.h"
|
||||
#endif //DEVICE_CAMERA
|
||||
#endif
|
||||
#include "signal.h"
|
||||
#include "privilege.h"
|
||||
@@ -87,8 +91,17 @@ int main( int argc, char **argv)
|
||||
signal(SIGHUP, sig_handler);
|
||||
signal(SIGALRM, sig_handler);
|
||||
#ifdef INCLUDE_BREAKPAD
|
||||
#ifndef DEVICE_CAMERA
|
||||
/* breakpad handles the signals SIGSEGV, SIGBUS, SIGFPE, and SIGILL */
|
||||
breakpad_ExceptionHandler();
|
||||
#else
|
||||
/* breakpad handles the signals SIGSEGV, SIGBUS, SIGFPE, and SIGILL */
|
||||
BreakPadWrapExceptionHandler eh;
|
||||
eh = newBreakPadWrapExceptionHandler();
|
||||
if(NULL != eh) {
|
||||
ParodusInfo("Breakpad Initialized\n");
|
||||
}
|
||||
#endif //DEVICE_CAMERA
|
||||
#else
|
||||
signal(SIGSEGV, sig_handler);
|
||||
signal(SIGBUS, sig_handler);
|
||||
@@ -98,6 +111,7 @@ int main( int argc, char **argv)
|
||||
ParodusCfg *cfg;
|
||||
|
||||
ParodusInfo ("RAND_MAX is %ld (0x%lx)\n", RAND_MAX, RAND_MAX);
|
||||
ParodusInfo("TEST PRINT");
|
||||
srandom (getpid());
|
||||
|
||||
/* TODO not ideal, but it fixes a more major problem for now. */
|
||||
@@ -107,6 +121,7 @@ int main( int argc, char **argv)
|
||||
ParodusInfo("********** Starting component: Parodus **********\n ");
|
||||
drop_root_privilege();
|
||||
#ifdef ENABLE_WEBCFGBIN
|
||||
registerRbusLogger();
|
||||
subscribeRBUSevent();
|
||||
regXmidtSendDataMethod();
|
||||
#endif
|
||||
|
||||
@@ -149,6 +149,7 @@ void listenerOnPingMessage (noPollCtx * ctx, noPollConn * conn, noPollMsg * msg,
|
||||
if (nopoll_msg_opcode(msg) == NOPOLL_PING_FRAME)
|
||||
{
|
||||
reset_heartBeatTimer();
|
||||
set_pingTimeStamp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ void setMessageHandlers()
|
||||
nopoll_conn_set_on_close(get_global_conn(), (noPollOnCloseHandler)listenerOnCloseMessage, NULL);
|
||||
}
|
||||
|
||||
static int cloud_status_is_online (void)
|
||||
int cloud_status_is_online (void)
|
||||
{
|
||||
const char *status = get_cloud_status();
|
||||
if (NULL == status)
|
||||
|
||||
@@ -114,7 +114,7 @@ int validate_partner_id(wrp_msg_t *msg, partners_t **partnerIds)
|
||||
}
|
||||
|
||||
/* Commandline input partner_ids not matching with partner_ids from request, appending to request partner_ids*/
|
||||
if(matchFlag != 1)
|
||||
if(matchFlag != 1 && partnerIds !=NULL)
|
||||
{
|
||||
(*partnerIds) = (partners_t *) malloc(sizeof(partners_t) + (sizeof(char *) * (count+partnersList->count)));
|
||||
(*partnerIds)->count = count+partnersList->count;
|
||||
@@ -132,6 +132,23 @@ int validate_partner_id(wrp_msg_t *msg, partners_t **partnerIds)
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else if (matchFlag != 1 && partnerIds == NULL)
|
||||
{
|
||||
ParodusError("partner_id match not found: command line input %s , msg partner_id %s\n", temp, msg->u.event.partner_ids->partner_ids[0]);
|
||||
if(partnersList != NULL)
|
||||
{
|
||||
for(j=0; j<partnersList->count; j++)
|
||||
{
|
||||
if(NULL != partnersList->partner_ids[j])
|
||||
{
|
||||
free(partnersList->partner_ids[j]);
|
||||
}
|
||||
}
|
||||
free(partnersList);
|
||||
}
|
||||
free(partnerId);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "time.h"
|
||||
#include "parodus_log.h"
|
||||
#include <errno.h>
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* External Functions */
|
||||
@@ -24,7 +25,10 @@
|
||||
|
||||
void getCurrentTime(struct timespec *timer)
|
||||
{
|
||||
clock_gettime(CLOCK_REALTIME, timer);
|
||||
if( clock_gettime(CLOCK_REALTIME, timer) == -1 )
|
||||
{
|
||||
ParodusError("clock gettime returns errno %d\n", errno );
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t getCurrentTimeInMicroSeconds(struct timespec *timer)
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
void *metadataPack;
|
||||
size_t metaPackSize=-1;
|
||||
size_t metaPackSize=0;
|
||||
|
||||
|
||||
UpStreamMsg *UpStreamMsgQ = NULL;
|
||||
@@ -320,7 +320,10 @@ void *processUpstreamMessage()
|
||||
}
|
||||
else if(msgType == WRP_MSG_TYPE__EVENT)
|
||||
{
|
||||
ParodusInfo(" Received upstream event data: dest '%s'\n", msg->u.event.dest);
|
||||
(msg->u.event.headers != NULL && msg->u.event.headers->headers[0] != NULL && msg->u.event.headers->headers[1] != NULL) ? ParodusInfo(" Received upstream event data: dest '%s' traceParent: %s traceState: %s\n", msg->u.event.dest, msg->u.event.headers->headers[0], msg->u.event.headers->headers[1]) : ParodusInfo(" Received upstream event data: dest '%s'\n", msg->u.event.dest);
|
||||
if(msg->u.event.transaction_uuid != NULL) {
|
||||
ParodusInfo("transaction_uuid in event: %s\n", msg->u.event.transaction_uuid);
|
||||
}
|
||||
partners_t *partnersList = NULL;
|
||||
int j = 0;
|
||||
|
||||
@@ -379,7 +382,7 @@ void *processUpstreamMessage()
|
||||
//Sending to server for msgTypes 3, 5, 6, 7, 8.
|
||||
if( WRP_MSG_TYPE__REQ == msgType )
|
||||
{
|
||||
ParodusInfo(" Received upstream data with MsgType: %d dest: '%s' transaction_uuid: %s\n", msgType, msg->u.req.dest, msg->u.req.transaction_uuid );
|
||||
(msg->u.req.headers != NULL && msg->u.req.headers->headers[0] != NULL && msg->u.req.headers->headers[1] != NULL) ? ParodusInfo(" Received upstream data with MsgType: %d dest: '%s' transaction_uuid: %s traceParent: %s traceState: %s\n", msgType, msg->u.req.dest, msg->u.req.transaction_uuid, msg->u.req.headers->headers[0], msg->u.req.headers->headers[1]) : ParodusInfo(" Received upstream data with MsgType: %d dest: '%s' transaction_uuid: %s\n", msgType, msg->u.req.dest, msg->u.req.transaction_uuid);
|
||||
sendUpstreamMsgToServer(&message->msg, message->len);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -47,6 +47,38 @@ rbusHandle_t get_parodus_rbus_Handle(void)
|
||||
{
|
||||
return rbus_Handle;
|
||||
}
|
||||
|
||||
/* Enables rbus ERROR level logs in parodus. Modify RBUS_LOG_ERROR check if more debug logs are needed from rbus. */
|
||||
void rbus_log_handler(
|
||||
rbusLogLevel level,
|
||||
const char* file,
|
||||
int line,
|
||||
int threadId,
|
||||
char* message)
|
||||
{
|
||||
ParodusPrint("threadId %d\n", threadId);
|
||||
const char* slevel = "";
|
||||
|
||||
if(level < RBUS_LOG_ERROR)
|
||||
return;
|
||||
|
||||
switch(level)
|
||||
{
|
||||
case RBUS_LOG_DEBUG: slevel = "DEBUG"; break;
|
||||
case RBUS_LOG_INFO: slevel = "INFO"; break;
|
||||
case RBUS_LOG_WARN: slevel = "WARN"; break;
|
||||
case RBUS_LOG_ERROR: slevel = "ERROR"; break;
|
||||
case RBUS_LOG_FATAL: slevel = "FATAL"; break;
|
||||
}
|
||||
ParodusInfo("%5s %s:%d -- %s\n", slevel, file, line, message);
|
||||
}
|
||||
|
||||
void registerRbusLogger()
|
||||
{
|
||||
rbus_registerLogHandler(rbus_log_handler);
|
||||
ParodusPrint("Registered rbus log handler\n");
|
||||
}
|
||||
|
||||
#ifdef WAN_FAILOVER_SUPPORTED
|
||||
void eventReceiveHandler( rbusHandle_t rbus_Handle, rbusEvent_t const* event, rbusEventSubscription_t* subscription );
|
||||
#endif
|
||||
@@ -73,7 +105,7 @@ void subscribeRBUSevent()
|
||||
int subscribeCurrentActiveInterfaceEvent()
|
||||
{
|
||||
int rc = RBUS_ERROR_SUCCESS;
|
||||
ParodusPrint("Subscribing to Device.X_RDK_WanManager.CurrentActiveInterface Event\n");
|
||||
ParodusInfo("Subscribing to Device.X_RDK_WanManager.CurrentActiveInterface Event\n");
|
||||
rc = rbusEvent_SubscribeAsync(rbus_Handle,WEBPA_INTERFACE,eventReceiveHandler,subscribeAsyncHandler,"parodusInterface",10*20);
|
||||
if(rc != RBUS_ERROR_SUCCESS)
|
||||
{
|
||||
|
||||
1066
src/xmidtsend_rbus.c
1066
src/xmidtsend_rbus.c
File diff suppressed because it is too large
Load Diff
@@ -24,14 +24,22 @@
|
||||
#ifndef _XMIDTSEND_RBUS_H_
|
||||
#define _XMIDTSEND_RBUS_H_
|
||||
#include <rbus.h>
|
||||
#include "config.h"
|
||||
#include <uuid/uuid.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define XMIDT_SEND_METHOD "Device.X_RDK_Xmidt.SendData"
|
||||
#define MAX_QUEUE_SIZE 10
|
||||
#define INPARAMS_PATH "/tmp/inparams.txt"
|
||||
|
||||
#define CLOUD_ACK_TIMEOUT_SEC 7
|
||||
#define CRITICAL_QOS_EXPIRE_TIME 30*60
|
||||
#define HIGH_QOS_EXPIRE_TIME 25*60
|
||||
#define MEDIUM_QOS_EXPIRE_TIME 20*60
|
||||
#define LOW_QOS_EXPIRE_TIME 15*60
|
||||
|
||||
#define EXPIRY_CHECK_TIME 5*60 //To check expiry in every 5 mins when cloud connection is down.
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Data Structures */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
@@ -39,9 +47,21 @@ typedef struct XmidtMsg__
|
||||
{
|
||||
wrp_msg_t *msg;
|
||||
rbusMethodAsyncHandle_t asyncHandle;
|
||||
int state;
|
||||
long long enqueueTime;
|
||||
long long sentTime;
|
||||
struct XmidtMsg__ *next;
|
||||
} XmidtMsg;
|
||||
|
||||
typedef struct CloudAck__
|
||||
{
|
||||
char *transaction_id;
|
||||
int qos;
|
||||
int rdr;
|
||||
char *source;
|
||||
struct CloudAck__ *next;
|
||||
} CloudAck;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DELIVERED_SUCCESS = 0,
|
||||
@@ -56,8 +76,18 @@ typedef enum
|
||||
CLIENT_DISCONNECT = 101,
|
||||
QUEUE_SIZE_EXCEEDED = 102,
|
||||
WRP_ENCODE_FAILURE = 103,
|
||||
MSG_PROCESSING_FAILED = 104
|
||||
MSG_PROCESSING_FAILED = 104,
|
||||
QOS_SEMANTICS_DISABLED = 105,
|
||||
MSG_EXPIRED = 106,
|
||||
QUEUE_OPTIMIZED = 107
|
||||
} XMIDT_STATUS;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PENDING = 0,
|
||||
SENT,
|
||||
DELETE
|
||||
} MSG_STATUS;
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Function Prototypes */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
@@ -66,18 +96,28 @@ rbusHandle_t get_parodus_rbus_Handle(void);
|
||||
void addToXmidtUpstreamQ(wrp_msg_t * msg, rbusMethodAsyncHandle_t asyncHandle);
|
||||
void* processXmidtUpstreamMsg();
|
||||
void processXmidtData();
|
||||
int processData(wrp_msg_t * msg, rbusMethodAsyncHandle_t asyncHandle);
|
||||
void sendXmidtEventToServer(wrp_msg_t * msg, rbusMethodAsyncHandle_t asyncHandle);
|
||||
int processData(XmidtMsg *Datanode, wrp_msg_t * msg, rbusMethodAsyncHandle_t asyncHandle);
|
||||
int sendXmidtEventToServer(XmidtMsg *msgnode, wrp_msg_t * msg, rbusMethodAsyncHandle_t asyncHandle);
|
||||
int checkInputParameters(rbusObject_t inParams);
|
||||
char* generate_transaction_uuid();
|
||||
void parseRbusInparamsToWrp(rbusObject_t inParams, char *trans_id, wrp_msg_t **eventMsg);
|
||||
void createOutParamsandSendAck(wrp_msg_t *msg, rbusMethodAsyncHandle_t asyncHandle, char *errorMsg, int statuscode, rbusError_t error);
|
||||
void createOutParamsandSendAck(wrp_msg_t *msg, rbusMethodAsyncHandle_t asyncHandle, char *errorMsg, int statuscode, char *cloudsource, rbusError_t error);
|
||||
int validateXmidtData(wrp_msg_t * eventMsg, char **errorMsg, int *statusCode);
|
||||
void xmidtQDequeue();
|
||||
void printSendMsgData(char* status, int qos, char* dest, char* transaction_uuid);
|
||||
bool highQosValueCheck(int qos);
|
||||
void waitTillConnectionIsUp();
|
||||
void printRBUSParams(rbusObject_t params, char* file_path);
|
||||
void addToCloudAckQ(char *transaction_id, int qos, int rdr, char *source);
|
||||
int checkCloudACK(XmidtMsg *xmdnode, rbusMethodAsyncHandle_t asyncHandle);
|
||||
int updateXmidtState(XmidtMsg * temp, int state);
|
||||
void print_xmidMsg_list();
|
||||
int deleteCloudACKNode(char* trans_id);
|
||||
int deleteFromXmidtQ(XmidtMsg **next_node);
|
||||
int checkCloudConn();
|
||||
void checkMaxQandOptimize(XmidtMsg *xmdMsg);
|
||||
void checkMsgExpiry(XmidtMsg *xmdMsg);
|
||||
void mapXmidtStatusToStatusMessage(int status, char **message);
|
||||
int xmidtQOptmize();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -33,7 +33,7 @@ set (PARODUS_COMMON_LIBS ${PARODUS_COMMON_LIBS} -lucresolv -lresolv)
|
||||
endif (FEATURE_DNS_QUERY)
|
||||
|
||||
if (ENABLE_WEBCFGBIN)
|
||||
set (PARODUS_COMMON_LIBS ${PARODUS_COMMON_LIBS} -lrbus -lrbus-core)
|
||||
set (PARODUS_COMMON_LIBS ${PARODUS_COMMON_LIBS} -lrbus)
|
||||
endif (ENABLE_WEBCFGBIN)
|
||||
|
||||
if(NOT DISABLE_VALGRIND)
|
||||
@@ -46,7 +46,7 @@ link_directories ( ${LIBRARY_DIR} )
|
||||
# test_heartBeatTimer
|
||||
#-------------------------------------------------------------------------------
|
||||
add_test(NAME test_heartBeatTimer COMMAND ${MEMORY_CHECK} ./test_heartBeatTimer)
|
||||
add_executable(test_heartBeatTimer test_heartBeatTimer.c ../src/heartBeat.c)
|
||||
add_executable(test_heartBeatTimer test_heartBeatTimer.c ../src/heartBeat.c ../src/time.c)
|
||||
target_link_libraries (test_heartBeatTimer ${PARODUS_COMMON_LIBS} -lcmocka)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
@@ -61,7 +61,10 @@ target_link_libraries (test_close_retry ${PARODUS_COMMON_LIBS} -lcmocka)
|
||||
#-------------------------------------------------------------------------------
|
||||
add_test(NAME test_mutex COMMAND ${MEMORY_CHECK} ./test_mutex)
|
||||
add_executable(test_mutex test_mutex.c ../src/mutex.c)
|
||||
target_link_libraries (test_mutex ${PARODUS_COMMON_LIBS} -lcmocka)
|
||||
target_link_libraries (test_mutex gcov -lcunit -lcimplog -lwrp-c
|
||||
-luuid -lmsgpackc -lnopoll -lnanomsg -lpthread
|
||||
-Wl,--no-as-needed -lcjson -lcjwt -ltrower-base64
|
||||
-lssl -lcrypto -lrt -lm -lcmocka)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# test_networking
|
||||
@@ -74,8 +77,8 @@ target_link_libraries (test_networking ${PARODUS_COMMON_LIBS})
|
||||
# test_nopoll_helpers
|
||||
#-------------------------------------------------------------------------------
|
||||
add_test(NAME test_nopoll_helpers COMMAND ${MEMORY_CHECK} ./test_nopoll_helpers)
|
||||
add_executable(test_nopoll_helpers test_nopoll_helpers.c ../src/nopoll_helpers.c)
|
||||
target_link_libraries (test_nopoll_helpers -Wl,--no-as-needed -lrt -lcmocka -lcimplog -lnopoll)
|
||||
add_executable(test_nopoll_helpers test_nopoll_helpers.c ../src/nopoll_helpers.c ../src/string_helpers.c ../src/config.c)
|
||||
target_link_libraries (test_nopoll_helpers -Wl,--no-as-needed -lrt -lcmocka -lcimplog -lnopoll ${PARODUS_COMMON_LIBS})
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# test_time
|
||||
@@ -109,7 +112,7 @@ target_link_libraries (test_spin_thread_e ${PARODUS_COMMON_LIBS} )
|
||||
# test_nopoll_handlers
|
||||
#-------------------------------------------------------------------------------
|
||||
add_test(NAME test_nopoll_handlers COMMAND ${MEMORY_CHECK} ./test_nopoll_handlers)
|
||||
add_executable(test_nopoll_handlers test_nopoll_handlers.c ../src/nopoll_handlers.c ../src/heartBeat.c ../src/close_retry.c)
|
||||
add_executable(test_nopoll_handlers test_nopoll_handlers.c ../src/nopoll_handlers.c ../src/heartBeat.c ../src/close_retry.c ../src/time.c)
|
||||
target_link_libraries (test_nopoll_handlers -lnopoll -lcunit -lcimplog -Wl,--no-as-needed -lrt -lpthread -lm)
|
||||
|
||||
|
||||
@@ -117,7 +120,7 @@ target_link_libraries (test_nopoll_handlers -lnopoll -lcunit -lcimplog -Wl,--no-
|
||||
# test_nopoll_handlers_fragment
|
||||
#-------------------------------------------------------------------------------
|
||||
add_test(NAME test_nopoll_handlers_fragment COMMAND ${MEMORY_CHECK} ./test_nopoll_handlers_fragment)
|
||||
add_executable(test_nopoll_handlers_fragment test_nopoll_handlers_fragment.c ../src/nopoll_handlers.c ../src/heartBeat.c ../src/close_retry.c)
|
||||
add_executable(test_nopoll_handlers_fragment test_nopoll_handlers_fragment.c ../src/nopoll_handlers.c ../src/heartBeat.c ../src/close_retry.c ../src/time.c)
|
||||
target_link_libraries (test_nopoll_handlers_fragment -lnopoll -lcunit -lcimplog -Wl,--no-as-needed -lrt -lpthread -lm -lcmocka)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
@@ -212,7 +215,7 @@ target_link_libraries (test_auth_token -lcmocka
|
||||
# test_auth_token_more
|
||||
#-------------------------------------------------------------------------------
|
||||
add_test(NAME test_auth_token_more COMMAND ${MEMORY_CHECK} ./test_auth_token_more)
|
||||
add_executable(test_auth_token_more test_auth_token_more.c ../src/config.c ../src/auth_token.c ../src/string_helpers.c)
|
||||
add_executable(test_auth_token_more test_auth_token_more.c ../src/config.c ../src/auth_token.c ../src/string_helpers.c ../src/config.c)
|
||||
target_link_libraries (test_auth_token_more -lcmocka
|
||||
-Wl,--no-as-needed -lcimplog
|
||||
-lcjson -lcjwt -ltrower-base64 -lssl -lcrypto -lrt -lm -lcurl -luuid
|
||||
@@ -265,7 +268,7 @@ target_link_libraries (test_upstream_sock -lcmocka gcov -lcunit -lcimplog
|
||||
# test_downstream
|
||||
#-------------------------------------------------------------------------------
|
||||
add_test(NAME test_downstream COMMAND ${MEMORY_CHECK} ./test_downstream)
|
||||
add_executable(test_downstream test_downstream.c ../src/downstream.c ../src/string_helpers.c)
|
||||
add_executable(test_downstream test_downstream.c ../src/downstream.c ../src/string_helpers.c ../src/config.c)
|
||||
target_link_libraries (test_downstream -lcmocka gcov -lcunit -lcimplog
|
||||
-lwrp-c -luuid -lpthread -lmsgpackc -lnopoll
|
||||
-Wl,--no-as-needed -lcjson -lcjwt -ltrower-base64
|
||||
@@ -275,7 +278,7 @@ target_link_libraries (test_downstream -lcmocka gcov -lcunit -lcimplog
|
||||
# test_downstream_more
|
||||
#-------------------------------------------------------------------------------
|
||||
add_test(NAME test_downstream_more COMMAND ${MEMORY_CHECK} ./test_downstream_more)
|
||||
add_executable(test_downstream_more test_downstream_more.c ../src/downstream.c ../src/string_helpers.c)
|
||||
add_executable(test_downstream_more test_downstream_more.c ../src/downstream.c ../src/string_helpers.c ../src/config.c)
|
||||
target_link_libraries (test_downstream_more -lcmocka ${PARODUS_COMMON_LIBS} )
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
@@ -296,6 +299,7 @@ set(CONIFC_SRC test_conn_interface.c
|
||||
../src/token.c
|
||||
../src/string_helpers.c
|
||||
../src/mutex.c
|
||||
../src/time.c
|
||||
../src/heartBeat.c
|
||||
../src/close_retry.c
|
||||
../src/event_handler.c
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "../src/ParodusInternal.h"
|
||||
|
||||
extern int parse_mac_address (char *target, const char *arg);
|
||||
extern int parse_serial_num(char *target, const char *arg);
|
||||
extern int server_is_http (const char *full_url,
|
||||
const char **server_ptr);
|
||||
extern int parse_webpa_url__(const char *full_url,
|
||||
@@ -467,6 +468,14 @@ void test_parse_mac_address ()
|
||||
assert_int_equal (parse_mac_address (result, ""), -1);
|
||||
}
|
||||
|
||||
void test_parse_serial_num()
|
||||
{
|
||||
char result[14];
|
||||
assert_int_equal (parse_serial_num (result, "1234ABC00ab"), 0);
|
||||
assert_int_equal (parse_serial_num (result, "$@@"), 0);
|
||||
assert_int_equal (parse_serial_num (result, ""), 0);
|
||||
}
|
||||
|
||||
void test_server_is_http ()
|
||||
{
|
||||
const char *server_ptr;
|
||||
@@ -587,6 +596,7 @@ int main(void)
|
||||
cmocka_unit_test(err_loadParodusCfg),
|
||||
cmocka_unit_test(test_parse_num_arg),
|
||||
cmocka_unit_test(test_parse_mac_address),
|
||||
cmocka_unit_test(test_parse_serial_num),
|
||||
cmocka_unit_test(test_get_algo_mask),
|
||||
cmocka_unit_test(test_server_is_http),
|
||||
cmocka_unit_test(test_parse_webpa_url__),
|
||||
|
||||
@@ -71,7 +71,10 @@ void nopoll_log_set_handler (noPollCtx *ctx, noPollLogHandler handler, noPollPtr
|
||||
UNUSED(ctx); UNUSED(handler); UNUSED(user_data);
|
||||
function_called();
|
||||
}
|
||||
|
||||
int cloud_status_is_online (void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
void __report_log (noPollCtx * ctx, noPollDebugLevel level, const char * log_msg, noPollPtr user_data)
|
||||
{
|
||||
UNUSED(ctx); UNUSED(level); UNUSED(log_msg); UNUSED(user_data);
|
||||
@@ -144,6 +147,10 @@ void packMetaData()
|
||||
function_called();
|
||||
}
|
||||
|
||||
int get_parodus_init()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_cloud_disconnect_time(void)
|
||||
{
|
||||
|
||||
@@ -64,7 +64,18 @@ reg_list_item_t * get_global_node(void)
|
||||
void release_global_node (void)
|
||||
{
|
||||
}
|
||||
|
||||
void addToCloudAckQ(char *transaction_id, int qos, int rdr)
|
||||
{
|
||||
(void)transaction_id;
|
||||
(void)qos;
|
||||
(void)rdr;
|
||||
return;
|
||||
}
|
||||
bool highQosValueCheck(int qos)
|
||||
{
|
||||
(void)qos;
|
||||
return false;
|
||||
}
|
||||
ssize_t wrp_to_struct( const void *bytes, const size_t length,
|
||||
const enum wrp_format fmt, wrp_msg_t **msg )
|
||||
{
|
||||
|
||||
@@ -192,6 +192,20 @@ int validate_partner_id(wrp_msg_t *msg, partners_t **partnerIds)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void addToCloudAckQ(char *transaction_id, int qos, int rdr)
|
||||
{
|
||||
(void)transaction_id;
|
||||
(void)qos;
|
||||
(void)rdr;
|
||||
return;
|
||||
}
|
||||
|
||||
bool highQosValueCheck(int qos)
|
||||
{
|
||||
(void)qos;
|
||||
return false;
|
||||
}
|
||||
|
||||
ssize_t wrp_to_struct( const void *bytes, const size_t length, const enum wrp_format fmt,
|
||||
wrp_msg_t **msg )
|
||||
{
|
||||
|
||||
@@ -79,7 +79,6 @@ void test_mutexHeartBeatTimer() {
|
||||
ParodusInfo("heartBeatTimer reset to: %d\n", heartBeatTimer);
|
||||
assert_int_equal(heartBeatTimer, 0);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* External Functions */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
@@ -68,7 +68,6 @@ nopoll_bool nopoll_msg_is_final(noPollMsg *msg)
|
||||
function_called();
|
||||
return (nopoll_bool) mock();
|
||||
}
|
||||
|
||||
const unsigned char *nopoll_msg_get_payload(noPollMsg *msg)
|
||||
{
|
||||
(void)msg;
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
#include "../src/parodus_log.h"
|
||||
#include "../src/nopoll_helpers.h"
|
||||
#include "../src/config.h"
|
||||
#include <cjwt/cjwt.h>
|
||||
#include "../src/connection.h"
|
||||
#include "../src/ParodusInternal.h"
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Macros */
|
||||
@@ -34,7 +37,6 @@
|
||||
/* File Scoped Variables */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static noPollConn *conn = NULL;
|
||||
static ParodusCfg cfg;
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Mocks */
|
||||
@@ -57,12 +59,6 @@ nopoll_bool nopoll_conn_is_ready( noPollConn *conn )
|
||||
return (nopoll_bool)mock();
|
||||
}
|
||||
|
||||
ParodusCfg *get_parodus_cfg(void)
|
||||
{
|
||||
function_called();
|
||||
return &cfg;
|
||||
}
|
||||
|
||||
int __nopoll_conn_send_common (noPollConn * conn, const char * content, long length, nopoll_bool has_fin, long sleep_in_header, noPollOpCode frame_type)
|
||||
{
|
||||
UNUSED(has_fin); UNUSED(sleep_in_header); UNUSED(frame_type); UNUSED(content);
|
||||
@@ -131,10 +127,6 @@ bool get_interface_down_event()
|
||||
return false;
|
||||
}
|
||||
|
||||
char *get_cloud_status(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Tests */
|
||||
@@ -226,8 +218,7 @@ void test_sendMessage()
|
||||
{
|
||||
int len = strlen("Hello Parodus!");
|
||||
|
||||
cfg.cloud_status = CLOUD_STATUS_ONLINE;
|
||||
expect_function_calls (get_parodus_cfg, 1);
|
||||
get_parodus_cfg()->cloud_status = CLOUD_STATUS_ONLINE;
|
||||
|
||||
expect_value(__nopoll_conn_send_common, (intptr_t)conn, (intptr_t)conn);
|
||||
expect_value(__nopoll_conn_send_common, length, len);
|
||||
@@ -241,8 +232,7 @@ void test_sendMessageOffline()
|
||||
{
|
||||
int len = strlen("Hello Parodus!");
|
||||
|
||||
cfg.cloud_status = CLOUD_STATUS_OFFLINE;
|
||||
expect_function_calls (get_parodus_cfg, 1);
|
||||
get_parodus_cfg()->cloud_status = CLOUD_STATUS_OFFLINE;
|
||||
sendMessage(conn, "Hello Parodus!", len);
|
||||
|
||||
}
|
||||
@@ -251,8 +241,7 @@ void err_sendMessage()
|
||||
{
|
||||
int len = strlen("Hello Parodus!");
|
||||
|
||||
cfg.cloud_status = CLOUD_STATUS_ONLINE;
|
||||
expect_function_calls (get_parodus_cfg, 1);
|
||||
get_parodus_cfg()->cloud_status = CLOUD_STATUS_ONLINE;
|
||||
|
||||
expect_value(__nopoll_conn_send_common, (intptr_t)conn,(intptr_t) conn);
|
||||
expect_value(__nopoll_conn_send_common, length, len);
|
||||
@@ -271,8 +260,7 @@ void err_sendMessageConnNull()
|
||||
{
|
||||
int len = strlen("Hello Parodus!");
|
||||
|
||||
cfg.cloud_status = CLOUD_STATUS_ONLINE;
|
||||
expect_function_calls (get_parodus_cfg, 1);
|
||||
get_parodus_cfg()->cloud_status = CLOUD_STATUS_ONLINE;
|
||||
|
||||
expect_value(__nopoll_conn_send_common, (intptr_t)conn, NULL);
|
||||
expect_value(__nopoll_conn_send_common, length, len);
|
||||
|
||||
Reference in New Issue
Block a user