mirror of
https://github.com/outbackdingo/parodus.git
synced 2026-01-27 18:20:04 +00:00
Compare commits
25 Commits
fixXmidtHe
...
5.2_p1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36775ba36a | ||
|
|
0fd3b76f27 | ||
|
|
48722ffa7c | ||
|
|
bf5d555d96 | ||
|
|
c02b141f7c | ||
|
|
9f40b7efe5 | ||
|
|
2a184e24c9 | ||
|
|
233a167cb4 | ||
|
|
5562d7ec48 | ||
|
|
49513df8f8 | ||
|
|
d0e6c5bd75 | ||
|
|
66f1f4d4fb | ||
|
|
19b4f56913 | ||
|
|
c30d5a3362 | ||
|
|
c98e2e2fb8 | ||
|
|
c78625f35a | ||
|
|
aeea6fbb03 | ||
|
|
d2d1590329 | ||
|
|
e693c09ca3 | ||
|
|
0b9f739323 | ||
|
|
d901efd10c | ||
|
|
824bcb81cf | ||
|
|
671fc5be59 | ||
|
|
4bf8683192 | ||
|
|
9300d76a8e |
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
|
||||
## [Unreleased]
|
||||
- Add additional HTTP headers for call to Themis from Convey
|
||||
- Add callback handler for initial cloud connection status change event
|
||||
- Fix Parodus connection stuck on interface up down received together
|
||||
- Update to use nopoll version 1.0.3
|
||||
|
||||
## [1.1.4]
|
||||
- on connect retry, requery jwt only if it failed before
|
||||
|
||||
@@ -43,6 +43,13 @@ include_directories(${INCLUDE_DIR}
|
||||
${INCLUDE_DIR}/cjwt
|
||||
)
|
||||
|
||||
if (ENABLE_WEBCFGBIN)
|
||||
include_directories(${INCLUDE_DIR}/rbus
|
||||
${INCLUDE_DIR}/rbus-core
|
||||
${INCLUDE_DIR}/rtmessage
|
||||
)
|
||||
endif (ENABLE_WEBCFGBIN)
|
||||
|
||||
# Get git commit hash
|
||||
#-------------------------------------------------------------------------------
|
||||
execute_process(
|
||||
@@ -86,7 +93,7 @@ add_dependencies(libtrower-base64 trower-base64)
|
||||
ExternalProject_Add(nopoll
|
||||
PREFIX ${PREFIX_DIR}/nopoll
|
||||
GIT_REPOSITORY https://github.com/Comcast/nopoll.git
|
||||
GIT_TAG "1.0.2"
|
||||
GIT_TAG "1.0.3"
|
||||
CONFIGURE_COMMAND COMMAND <SOURCE_DIR>/autogen.sh --prefix=${PREFIX}
|
||||
--includedir=${INCLUDE_DIR}
|
||||
--libdir=${LIBRARY_DIR}
|
||||
@@ -229,6 +236,51 @@ 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
|
||||
CMAKE_ARGS += -DBUILD_FOR_DESKTOP=ON -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DBUILD_TESTING=OFF
|
||||
)
|
||||
|
||||
add_library(librbus STATIC SHARED IMPORTED)
|
||||
add_dependencies(librbus rbus)
|
||||
endif (ENABLE_WEBCFGBIN)
|
||||
|
||||
if (BUILD_TESTING)
|
||||
# cmocka external dependency
|
||||
#-------------------------------------------------------------------------------
|
||||
@@ -253,6 +305,10 @@ if (FEATURE_DNS_QUERY)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFEATURE_DNS_QUERY ")
|
||||
endif (FEATURE_DNS_QUERY)
|
||||
|
||||
if (ENABLE_WEBCFGBIN)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_WEBCFGBIN ")
|
||||
endif (ENABLE_WEBCFGBIN)
|
||||
|
||||
link_directories ( ${LIBRARY_DIR} ${COMMON_LIBRARY_DIR} ${LIBRARY_DIR64} )
|
||||
add_subdirectory(src)
|
||||
if (BUILD_TESTING)
|
||||
|
||||
@@ -23,6 +23,9 @@ else()
|
||||
set(SOURCES ${SOURCES} seshat_interface_stub.c)
|
||||
endif (ENABLE_SESHAT)
|
||||
|
||||
if (ENABLE_WEBCFGBIN)
|
||||
set(SOURCES ${SOURCES} upstream_rbus.c)
|
||||
endif (ENABLE_WEBCFGBIN)
|
||||
|
||||
add_executable(parodus ${SOURCES})
|
||||
|
||||
@@ -53,5 +56,7 @@ if (ENABLE_SESHAT)
|
||||
target_link_libraries (parodus -llibseshat)
|
||||
endif (ENABLE_SESHAT)
|
||||
|
||||
|
||||
if (ENABLE_WEBCFGBIN)
|
||||
target_link_libraries (parodus -lrbus -lrbus-core)
|
||||
endif (ENABLE_WEBCFGBIN)
|
||||
install (TARGETS parodus DESTINATION bin)
|
||||
|
||||
@@ -161,7 +161,9 @@ int readFromFile(const char *file_name, char **data);
|
||||
void timespec_diff(struct timespec *start, struct timespec *stop,
|
||||
struct timespec *result);
|
||||
|
||||
|
||||
#ifdef ENABLE_WEBCFGBIN
|
||||
void subscribeRBUSevent();
|
||||
#endif
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* For interface_down_event Flag */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
|
||||
36
src/config.c
36
src/config.c
@@ -163,6 +163,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)
|
||||
{
|
||||
@@ -417,8 +449,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':
|
||||
|
||||
@@ -77,6 +77,7 @@ void createSocketConnection(void (* initKeypress)())
|
||||
server_list_t server_list;
|
||||
bool seshat_registered = false;
|
||||
int create_conn_rtn = 0;
|
||||
int nopoll_returnvalue = 0;
|
||||
unsigned int webpa_ping_timeout_ms = 1000 * get_parodus_cfg()->webpa_ping_timeout;
|
||||
unsigned int heartBeatTimer = 0;
|
||||
struct timespec start_svc_alive_timer;
|
||||
@@ -112,6 +113,9 @@ void createSocketConnection(void (* initKeypress)())
|
||||
UpStreamMsgQ = NULL;
|
||||
StartThread(handle_upstream, &upstream_tid);
|
||||
StartThread(processUpstreamMessage, &upstream_msg_tid);
|
||||
#ifdef ENABLE_WEBCFGBIN
|
||||
subscribeRBUSevent();
|
||||
#endif
|
||||
ParodusMsgQ = NULL;
|
||||
StartThread(messageHandlerTask, &downstream_tid);
|
||||
StartThread(serviceAliveTask, &svc_alive_tid);
|
||||
@@ -131,14 +135,17 @@ void createSocketConnection(void (* initKeypress)())
|
||||
struct timespec start, stop, diff;
|
||||
int time_taken_ms;
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &start);
|
||||
nopoll_loop_wait(ctx, 5000000);
|
||||
clock_gettime(CLOCK_REALTIME, &stop);
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
nopoll_returnvalue = nopoll_loop_wait(ctx, 5000000);
|
||||
clock_gettime(CLOCK_MONOTONIC, &stop);
|
||||
|
||||
timespec_diff(&start, &stop, &diff);
|
||||
time_taken_ms = diff.tv_sec * 1000 + (diff.tv_nsec / 1000000);
|
||||
|
||||
// ParodusInfo("nopoll_loop_wait() time %d msec\n", time_taken_ms);
|
||||
if(time_taken_ms/1000 != 5)
|
||||
{
|
||||
ParodusInfo("nopoll_loop_wait value %d,nopoll_loop_wait() time %d msec\n",nopoll_returnvalue, time_taken_ms);
|
||||
}
|
||||
ParodusPrint("webpa_ping_timeout_ms %d msec\n", webpa_ping_timeout_ms);
|
||||
heartBeatTimer = get_heartBeatTimer();
|
||||
if(heartBeatTimer >= webpa_ping_timeout_ms)
|
||||
{
|
||||
@@ -195,7 +202,8 @@ void createSocketConnection(void (* initKeypress)())
|
||||
}
|
||||
createNopollConnection(ctx, &server_list);
|
||||
}
|
||||
} while(!get_close_retry() && !g_shutdown);
|
||||
//process exit only when g_shutdown is true.
|
||||
} while(FOREVER() && !g_shutdown);
|
||||
|
||||
pthread_mutex_lock (get_global_svc_mut());
|
||||
pthread_cond_signal (get_global_svc_con());
|
||||
|
||||
@@ -62,6 +62,8 @@ enum {
|
||||
/* File Scoped Variables */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
parodusOnConnStatusChangeHandler on_conn_status_change;
|
||||
|
||||
parodusOnPingStatusChangeHandler on_ping_status_change;
|
||||
|
||||
pthread_mutex_t backoff_delay_mut=PTHREAD_MUTEX_INITIALIZER;
|
||||
@@ -697,7 +699,8 @@ int wait_while_interface_down()
|
||||
if (rtn != 0)
|
||||
ParodusError
|
||||
("Error on pthread_cond_wait (%d) in wait_while_interface_down\n", rtn);
|
||||
if ((rtn != 0) || g_shutdown) {
|
||||
if (g_shutdown) {
|
||||
ParodusInfo("Received g_shutdown during interface down wait, returning\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -717,6 +720,7 @@ int createNopollConnection(noPollCtx *ctx, server_list_t *server_list)
|
||||
struct timespec connect_time,*connectTimePtr;
|
||||
connectTimePtr = &connect_time;
|
||||
backoff_timer_t backoff_timer;
|
||||
static int init_conn_failure=1;
|
||||
|
||||
if(ctx == NULL) {
|
||||
return nopoll_false;
|
||||
@@ -752,6 +756,14 @@ int createNopollConnection(noPollCtx *ctx, server_list_t *server_list)
|
||||
}
|
||||
/* if we failed to connect, don't reuse the redirect server */
|
||||
free_server (&conn_ctx.server_list->redirect);
|
||||
|
||||
/* On initial connect failure, invoke conn status change event as "failed" only 1 time*/
|
||||
if((NULL != on_conn_status_change) && init && init_conn_failure)
|
||||
{
|
||||
on_conn_status_change("failed");
|
||||
init_conn_failure=0;
|
||||
}
|
||||
|
||||
#ifdef FEATURE_DNS_QUERY
|
||||
/* if we don't already have a valid jwt, look up server information */
|
||||
if (server_is_null (&conn_ctx.server_list->jwt))
|
||||
@@ -776,6 +788,12 @@ int createNopollConnection(noPollCtx *ctx, server_list_t *server_list)
|
||||
get_parodus_cfg()->cloud_status = CLOUD_STATUS_ONLINE;
|
||||
ParodusInfo("cloud_status set as %s after successful connection\n", get_parodus_cfg()->cloud_status);
|
||||
|
||||
/* On initial connect success, invoke conn status change event as "success" */
|
||||
if((NULL != on_conn_status_change) && init)
|
||||
{
|
||||
on_conn_status_change("success");
|
||||
}
|
||||
|
||||
// Invoke the ping status change event callback as "received" ping
|
||||
if(NULL != on_ping_status_change)
|
||||
{
|
||||
@@ -934,3 +952,8 @@ void registerParodusOnPingStatusChangeHandler(parodusOnPingStatusChangeHandler c
|
||||
on_ping_status_change = callback_func;
|
||||
}
|
||||
|
||||
void registerParodusOnConnStatusChangeHandler(parodusOnConnStatusChangeHandler callback_func)
|
||||
{
|
||||
on_conn_status_change = callback_func;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,15 @@ extern "C" {
|
||||
#define SHUTDOWN_REASON_SYSTEM_RESTART "system_restarting"
|
||||
#define SHUTDOWN_REASON_SIGTERM "SIGTERM"
|
||||
|
||||
/**
|
||||
* parodusOnConnStatusChangeHandler - Function pointer
|
||||
* Used to define callback function to do additional processing
|
||||
* when websocket cloud connection status change event
|
||||
* i.e. "cloud-conn-status" as "fail" or "success"
|
||||
*/
|
||||
typedef void (*parodusOnConnStatusChangeHandler) (char * status);
|
||||
extern parodusOnConnStatusChangeHandler on_conn_status_change;
|
||||
|
||||
/**
|
||||
* parodusOnPingStatusChangeHandler - Function pointer
|
||||
* Used to define callback function to do additional processing
|
||||
@@ -79,6 +88,9 @@ void set_cloud_disconnect_time(int disconnTime);
|
||||
void start_conn_in_progress (unsigned long start_time);
|
||||
void stop_conn_in_progress (void);
|
||||
|
||||
// To Register parodusOnConnStatusChangeHandler Callback function
|
||||
void registerParodusOnConnStatusChangeHandler(parodusOnConnStatusChangeHandler on_conn_status_change);
|
||||
|
||||
// To Register parodusOnPingStatusChangeHandler Callback function
|
||||
void registerParodusOnPingStatusChangeHandler(parodusOnPingStatusChangeHandler on_ping_status_change);
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ uint64_t getCurrentTimeInMicroSeconds(struct timespec *timer)
|
||||
ParodusPrint("timer->tv_sec : %lu\n",timer->tv_sec);
|
||||
ParodusPrint("timer->tv_nsec : %lu\n",timer->tv_nsec);
|
||||
systime = (uint64_t)timer->tv_sec * 1000000L + timer->tv_nsec/ 1000;
|
||||
return systime;
|
||||
return systime;
|
||||
}
|
||||
|
||||
long timeValDiff(struct timespec *starttime, struct timespec *finishtime)
|
||||
|
||||
@@ -47,6 +47,7 @@ typedef struct UpStreamMsg__
|
||||
void packMetaData();
|
||||
void *handle_upstream();
|
||||
void *processUpstreamMessage();
|
||||
void registerRBUSlistener();
|
||||
int getDeviceId(char **device_id, size_t *device_id_len);
|
||||
void sendUpstreamMsgToServer(void **resp_bytes, size_t resp_size);
|
||||
void getServiceNameAndSendResponse(wrp_msg_t *msg, void **msg_bytes, size_t msg_size);
|
||||
|
||||
125
src/upstream_rbus.c
Normal file
125
src/upstream_rbus.c
Normal file
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* Copyright 2021 Comcast Cable Communications Management, LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @file upstream_rbus.c
|
||||
*
|
||||
* @description This is used for parodus-RBUS communication
|
||||
* to send notification events upstream to cloud.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <rbus.h>
|
||||
#include "upstream.h"
|
||||
#include "ParodusInternal.h"
|
||||
#include "partners_check.h"
|
||||
|
||||
#define WEBCFG_UPSTREAM_EVENT "Webconfig.Upstream"
|
||||
|
||||
void processWebconfigUpstreamEvent(rbusHandle_t handle, rbusEvent_t const* event, rbusEventSubscription_t* subscription);
|
||||
|
||||
void subscribeAsyncHandler( rbusHandle_t handle, rbusEventSubscription_t* subscription, rbusError_t error);
|
||||
|
||||
/* API to register RBUS listener to receive messages from webconfig */
|
||||
void subscribeRBUSevent()
|
||||
{
|
||||
rbusError_t err;
|
||||
int rc = RBUS_ERROR_SUCCESS;
|
||||
rbusHandle_t rbus_Handle;
|
||||
err = rbus_open(&rbus_Handle, "parodus");
|
||||
if (err)
|
||||
{
|
||||
ParodusError("rbus_open failed :%s\n", rbusError_ToString(err));
|
||||
return;
|
||||
}
|
||||
rc = rbusEvent_SubscribeAsync(rbus_Handle,WEBCFG_UPSTREAM_EVENT,processWebconfigUpstreamEvent,subscribeAsyncHandler,"parodus",10*60);
|
||||
if(rc != RBUS_ERROR_SUCCESS)
|
||||
ParodusError("rbusEvent_Subscribe failed: %d, %s\n", rc, rbusError_ToString(rc));
|
||||
else
|
||||
ParodusInfo("rbusEvent_Subscribe was successful\n");
|
||||
}
|
||||
|
||||
void processWebconfigUpstreamEvent(rbusHandle_t handle, rbusEvent_t const* event, rbusEventSubscription_t* subscription)
|
||||
{
|
||||
(void)handle;
|
||||
(void)subscription;
|
||||
|
||||
int rv=-1;
|
||||
wrp_msg_t *event_msg;
|
||||
void *bytes;
|
||||
const uint8_t* bytesVal = NULL;
|
||||
int len;
|
||||
rbusValue_t value = NULL;
|
||||
|
||||
value = rbusObject_GetValue(event->data, "value");
|
||||
bytesVal = rbusValue_GetBytes(value, &len);
|
||||
|
||||
bytes = (void*) bytesVal;
|
||||
rv = wrp_to_struct( bytes, len, WRP_BYTES, &event_msg );
|
||||
if(rv > 0)
|
||||
{
|
||||
ParodusInfo(" Received upstream event data: dest '%s'\n", event_msg->u.event.dest);
|
||||
partners_t *partnersList = NULL;
|
||||
int j = 0;
|
||||
|
||||
int ret = validate_partner_id(event_msg, &partnersList);
|
||||
if(ret == 1)
|
||||
{
|
||||
wrp_msg_t *eventMsg = (wrp_msg_t *) malloc(sizeof(wrp_msg_t));
|
||||
eventMsg->msg_type = event_msg->msg_type;
|
||||
eventMsg->u.event.content_type=event_msg->u.event.content_type;
|
||||
eventMsg->u.event.source=event_msg->u.event.source;
|
||||
eventMsg->u.event.dest=event_msg->u.event.dest;
|
||||
eventMsg->u.event.payload=event_msg->u.event.payload;
|
||||
eventMsg->u.event.payload_size=event_msg->u.event.payload_size;
|
||||
eventMsg->u.event.headers=event_msg->u.event.headers;
|
||||
eventMsg->u.event.metadata=event_msg->u.event.metadata;
|
||||
eventMsg->u.event.partner_ids = partnersList;
|
||||
|
||||
int size = wrp_struct_to( eventMsg, WRP_BYTES, &bytes );
|
||||
if(size > 0)
|
||||
{
|
||||
sendUpstreamMsgToServer(&bytes, size);
|
||||
}
|
||||
free(eventMsg);
|
||||
free(bytes);
|
||||
bytes = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
sendUpstreamMsgToServer((void **)(&bytes), len);
|
||||
}
|
||||
if(partnersList != NULL)
|
||||
{
|
||||
for(j=0; j<(int)partnersList->count; j++)
|
||||
{
|
||||
if(NULL != partnersList->partner_ids[j])
|
||||
{
|
||||
free(partnersList->partner_ids[j]);
|
||||
}
|
||||
}
|
||||
free(partnersList);
|
||||
}
|
||||
partnersList = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void subscribeAsyncHandler( rbusHandle_t handle, rbusEventSubscription_t* subscription, rbusError_t error)
|
||||
{
|
||||
(void)handle;
|
||||
ParodusInfo("subscribeAsyncHandler event %s, error %d - %s\n",subscription->eventName, error, rbusError_ToString(error));
|
||||
}
|
||||
@@ -32,6 +32,10 @@ if (FEATURE_DNS_QUERY)
|
||||
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)
|
||||
endif (ENABLE_WEBCFGBIN)
|
||||
|
||||
if(NOT DISABLE_VALGRIND)
|
||||
set (MEMORY_CHECK valgrind --leak-check=full --show-reachable=yes -v)
|
||||
endif ()
|
||||
@@ -154,7 +158,11 @@ set(CLIST_SRC ${CLIST_SRC} ../src/seshat_interface.c)
|
||||
else()
|
||||
set(CLIST_SRC ${CLIST_SRC} ../src/seshat_interface_stub.c)
|
||||
endif (ENABLE_SESHAT)
|
||||
|
||||
|
||||
if (ENABLE_WEBCFGBIN)
|
||||
set(CLIST_SRC ${CLIST_SRC} ../src/upstream_rbus.c)
|
||||
endif (ENABLE_WEBCFGBIN)
|
||||
|
||||
add_executable(test_client_list ${CLIST_SRC})
|
||||
#target_link_libraries (test_client_list ${PARODUS_CONN_LIBS} ${PARODUS_COMMON_LIBS})
|
||||
target_link_libraries (test_client_list ${PARODUS_COMMON_LIBS} -lcurl -luuid)
|
||||
@@ -172,6 +180,10 @@ else()
|
||||
set(SVA_SRC ${SVA_SRC} ../src/seshat_interface_stub.c)
|
||||
endif (ENABLE_SESHAT)
|
||||
|
||||
if (ENABLE_WEBCFGBIN)
|
||||
set(SVA_SRC ${SVA_SRC} ../src/upstream_rbus.c)
|
||||
endif (ENABLE_WEBCFGBIN)
|
||||
|
||||
add_executable(test_service_alive ${SVA_SRC})
|
||||
#target_link_libraries (test_service_alive ${PARODUS_CONN_LIBS} ${PARODUS_COMMON_LIBS})
|
||||
target_link_libraries (test_service_alive ${PARODUS_COMMON_LIBS} -lcurl -luuid)
|
||||
@@ -294,6 +306,9 @@ set(CONIFC_SRC ${CONIFC_SRC} ../src/seshat_interface.c)
|
||||
else()
|
||||
set(CONIFC_SRC ${CONIFC_SRC} ../src/seshat_interface_stub.c)
|
||||
endif (ENABLE_SESHAT)
|
||||
if (ENABLE_WEBCFGBIN)
|
||||
set(CONIFC_SRC ${CONIFC_SRC} ../src/upstream_rbus.c)
|
||||
endif (ENABLE_WEBCFGBIN)
|
||||
add_executable(test_conn_interface ${CONIFC_SRC})
|
||||
target_link_libraries (test_conn_interface -lcmocka ${PARODUS_COMMON_LIBS} -lcurl -luuid )
|
||||
|
||||
@@ -340,6 +355,10 @@ else()
|
||||
set(TOKEN_SRC test_token_stub.c ${TOKEN_SRC})
|
||||
endif (FEATURE_DNS_QUERY)
|
||||
|
||||
if (ENABLE_WEBCFGBIN)
|
||||
set(TOKEN_SRC ${TOKEN_SRC} ../src/upstream_rbus.c)
|
||||
endif (ENABLE_WEBCFGBIN)
|
||||
|
||||
add_executable(test_token ${TOKEN_SRC} )
|
||||
#target_link_libraries (test_token ${PARODUS_COMMON_LIBS} ${PARODUS_JWT_LIBS} -lcmocka )
|
||||
target_link_libraries (test_token ${PARODUS_COMMON_LIBS} -lcmocka -lcurl -luuid)
|
||||
|
||||
@@ -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,
|
||||
@@ -469,6 +470,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;
|
||||
@@ -589,6 +598,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__),
|
||||
|
||||
@@ -44,7 +44,7 @@ pthread_mutex_t svc_mut=PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_cond_t svc_con=PTHREAD_COND_INITIALIZER;
|
||||
int numLoops;
|
||||
parodusOnPingStatusChangeHandler on_ping_status_change;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Mocks */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
@@ -172,6 +172,18 @@ int serviceAliveTask()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int validate_partner_id(wrp_msg_t *msg, partners_t **partnerIds)
|
||||
{
|
||||
UNUSED(msg); UNUSED(partnerIds);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sendUpstreamMsgToServer(void **resp_bytes, size_t resp_size)
|
||||
{
|
||||
UNUSED(resp_bytes); UNUSED(resp_size);
|
||||
return;
|
||||
}
|
||||
|
||||
int nopoll_loop_wait(noPollCtx * ctx,long timeout)
|
||||
{
|
||||
UNUSED(ctx); UNUSED(timeout);
|
||||
@@ -335,6 +347,7 @@ void test_createSocketConnection()
|
||||
|
||||
void test_createSocketConnection1()
|
||||
{
|
||||
numLoops =0;
|
||||
noPollCtx *ctx;
|
||||
ParodusCfg cfg;
|
||||
memset(&cfg,0, sizeof(ParodusCfg));
|
||||
@@ -364,11 +377,11 @@ void test_createSocketConnection1()
|
||||
expect_function_call(nopoll_ctx_unref);
|
||||
expect_function_call(nopoll_cleanup_library);
|
||||
createSocketConnection(NULL);
|
||||
|
||||
}
|
||||
|
||||
void test_PingMissIntervalTime()
|
||||
{
|
||||
numLoops = 6;
|
||||
noPollCtx *ctx;
|
||||
ParodusCfg cfg;
|
||||
memset(&cfg,0,sizeof(ParodusCfg));
|
||||
@@ -386,7 +399,6 @@ void test_PingMissIntervalTime()
|
||||
//Max ping timeout is 6 sec
|
||||
cfg.webpa_ping_timeout = 6;
|
||||
set_parodus_cfg(&cfg);
|
||||
|
||||
reset_close_retry();
|
||||
expect_function_call(nopoll_thread_handlers);
|
||||
|
||||
@@ -422,11 +434,11 @@ void test_PingMissIntervalTime()
|
||||
expect_function_call(nopoll_ctx_unref);
|
||||
expect_function_call(nopoll_cleanup_library);
|
||||
createSocketConnection(NULL);
|
||||
|
||||
}
|
||||
|
||||
void err_createSocketConnection()
|
||||
{
|
||||
numLoops =0;
|
||||
set_close_retry();
|
||||
reset_heartBeatTimer();
|
||||
expect_function_call(nopoll_thread_handlers);
|
||||
@@ -459,6 +471,7 @@ void err_createSocketConnection()
|
||||
|
||||
void test_createSocketConnection_cloud_disconn()
|
||||
{
|
||||
numLoops =0;
|
||||
ParodusCfg cfg;
|
||||
memset(&cfg,0,sizeof(ParodusCfg));
|
||||
cfg.cloud_disconnect = strdup("XPC");
|
||||
|
||||
Reference in New Issue
Block a user