Compare commits

...

102 Commits

Author SHA1 Message Date
shilpa24balaji
9abb37a005 Merge pull request #398 from Thanusha-D/log_change
Added NULL checks in value change event & Logging transaction_uuid in msg send
2022-06-17 12:17:47 +05:30
Thanusha D
c0edaaf31c Added logs for debugging 2022-06-16 21:16:00 +05:30
shilpa24balaji
34802d329d Merge pull request #394 from sadhyama/xmd_content
Add content_type validation for Xmidt method profiles
2022-05-27 23:07:53 +05:30
Sadhyama Vengilat
0297d994b5 Reduce debug log 2022-05-27 19:47:39 +05:30
Sadhyama Vengilat
ee7033c36c Add contentType list and validate 2022-05-27 12:59:38 +05:30
Sadhyama Vengilat
e35221efd2 Add content_type validation for Xmidt method profiles 2022-05-26 20:36:11 +05:30
sadhyama
c898fe6d0e Merge pull request #393 from sadhyama/def_profile
Handle Xmidt default profile events received before connection
2022-05-13 18:55:25 +05:30
Sadhyama Vengilat
0017e48f7d Remove content_type modification 2022-05-13 18:48:30 +05:30
Sadhyama Vengilat
285a461f42 Disable debug logs 2022-05-11 18:16:25 +05:30
Sadhyama Vengilat
bb0f49a8b3 Added delay on parodus init 2022-05-10 19:26:33 +05:30
Sadhyama Vengilat
ee20e1fcb8 Handle xmidt default profiles received before initial cloud connection 2022-05-09 20:31:07 +05:30
sadhyama
becacd8990 Merge pull request #392 from sadhyama/parodus_highqos
set cloud_status online after close_retry reset to fix Xmidt sendMsg failure
2022-04-20 16:13:53 +05:30
Sadhyama Vengilat
b05bfbe1fa Merge remote-tracking branch 'upstream/master' into parodus_highqos 2022-04-20 16:13:10 +05:30
sadhyama
9fb3f118b7 Merge pull request #391 from guruchandru/xmd_send
Error Number value change
2022-04-20 16:11:22 +05:30
Sadhyama Vengilat
a124aafc5f set cloud_status online after close_retry reset to fix sendMsg failure 2022-04-20 13:09:57 +05:30
Guru Chandru
0c4a2f407a Error Number value change 2022-04-18 12:25:20 +05:30
shilpa24balaji
523c9cc0d2 Merge pull request #390 from guruchandru/xmd_send
Changes to Send Success and Error ACK
2022-04-13 18:51:33 +05:30
Guru Chandru
58492950d6 Review comment changes 2022-04-13 13:18:21 +05:30
Guru Chandru
29906511b8 Changes to Send ACK for Success and Error Case 2022-04-12 17:56:34 +05:30
shilpa24balaji
c6fa4b2ce8 Merge pull request #388 from shilpa24balaji/wan_failover
Reconnect to cloud on every wan failover event
2022-04-12 16:43:59 +05:30
sadhyama
0640f3516f Merge pull request #386 from xmidt-org/xmidt_send
Xmidt send RBUS method to send events upstream
2022-04-08 20:35:23 +05:30
Sadhyama Vengilat
60c37daa18 Wrp-c git tag update 2022-04-08 20:30:03 +05:30
Sadhyama Vengilat
f51b4ef9c2 Fix valgrind leaks 2022-04-08 18:14:40 +05:30
Sadhyama Vengilat
254c9f6763 Start xmidt consumer only when method register is success 2022-04-08 13:31:24 +05:30
sadhyama
8876fa9239 Merge pull request #387 from guruchandru/xmd_send
Transaction uuid Crash Fix
2022-04-08 13:03:42 +05:30
Guru Chandru
42fc9eb26e Transaction uuid Crash Fix 2022-04-08 12:37:58 +05:30
sadhyama
e8e652b076 Merge pull request #385 from sadhyama/xmd_new
Log reduction and format
2022-04-07 21:09:05 +05:30
Sadhyama Vengilat
dc935f9a09 Debug log reduction and formatting 2022-04-07 21:04:55 +05:30
Sadhyama Vengilat
d1462de56a Convert device mac to lowercase 2022-04-07 15:03:00 +05:30
Shilpa Seshadri
13309a737e Reconnect to cloud on every wan failover event 2022-04-07 12:40:21 +05:30
Guru Chandru
223e7db81c Valgrind leak fix for cloud status and device_id 2022-04-05 20:00:19 +05:30
sadhyama
cd763823fc Merge pull request #383 from guruchandru/xmd_send
High QOS and ACK
2022-04-05 14:08:38 +05:30
Guru Chandru
8537f27ece Review comment changes 2022-04-05 14:04:21 +05:30
Guru Chandru
6381d9c55f Local PC Unit Test Build Failure Fix 2022-04-04 15:15:18 +05:30
Guru Chandru
980b7a88db Review comment Changes on ACK and Cloud status Cond signal 2022-04-04 15:05:24 +05:30
Guru Chandru
e3c37b6764 Review comment Changes 2022-04-04 12:10:30 +05:30
Guru Chandru
67d58441ef Revised changes 2022-04-04 11:02:21 +05:30
Guru Chandru
f6ffda05ad Merge remote-tracking branch 'upstream/xmidt_send' into xmd_send 2022-04-01 17:54:33 +05:30
Guru Chandru
6aee851944 Removing tempAsyncHandle 2022-04-01 14:59:29 +05:30
Sadhyama Vengilat
aaa93e137d Merge remote-tracking branch 'upstream/master' into xmidt_send 2022-04-01 14:17:36 +05:30
Sadhyama Vengilat
21e8c74f23 Add transaction id in outParams & fix PC build issues 2022-04-01 14:07:57 +05:30
Guru Chandru
0248e7b241 removed LTE distro in mutex 2022-03-31 17:10:28 +05:30
Guru Chandru
da019382c6 Async response 2022-03-31 14:01:55 +05:30
Guru Chandru
aecbd885d5 Remove wrp_free in Dequeue 2022-03-30 12:08:52 +05:30
Guru Chandru
0443c45924 Merge remote-tracking branch 'upstream/master' into xmd_send 2022-03-30 10:38:20 +05:30
sadhyama
314c840755 Merge pull request #382 from Thanusha-D/lte_wanfail
Support Wan failover/restore events for LTE backup
2022-03-29 18:54:44 +05:30
Guru Chandru
69f7e3eba0 Adding NULL checks for wrp struct free 2022-03-29 18:41:11 +05:30
Thanusha D
e643f9e2fc Support Wan failover/restore events for LTE backup 2022-03-29 18:14:29 +05:30
Guru Chandru
7d2e9733d0 Debug logs 2022-03-29 15:23:20 +05:30
Guru Chandru
23c18da03e Fix for Crash due to frequent ACK response trigger 2022-03-29 13:30:01 +05:30
Guru Chandru
2218637f2c Added ACK and Cond wait signal for connection not OK 2022-03-28 21:41:42 +05:30
Guru Chandru
54f9983eff High Qos Event ACK and Enqueue changes 2022-03-28 15:39:30 +05:30
Guru Chandru
a577854172 Merge remote-tracking branch 'upstream/parodusUS' into xmd_send 2022-03-28 13:11:40 +05:30
Guru Chandru
e054ef580f Merge remote-tracking branch 'upstream/xmd_send' into xmd_send 2022-03-28 13:04:05 +05:30
Sadhyama Vengilat
79eb7ba6ef To fix send ack crash due to OutParams NULL issue 2022-03-28 12:49:18 +05:30
Guru Chandru
a291b047b6 Enqueue option to add High Qos Events after Failure 2022-03-28 12:27:38 +05:30
Sadhyama Vengilat
656b1b0b58 To fix send ack crash due to OutParams NULL issue 2022-03-28 12:10:19 +05:30
vasuki01
22ecf0ef76 Review comments updated for wan fail over support 2022-03-25 19:40:00 +05:30
Sadhyama Vengilat
c97a3a3a20 Rbus async ack handling for xmidt send requests 2022-03-25 14:36:38 +05:30
Vasuki
46273d9766 Add cloud status mutex locks for Parodus send data US subtask 2022-03-23 14:57:39 +05:30
Sadhyama Vengilat
7efed14c20 Enable WAN_FAILOVER_SUPPORTED and fix build issues 2022-03-18 14:01:40 +05:30
Vasuki
6d39163d47 Parodus changes for Wanifailover support-2 2022-03-17 11:46:13 +05:30
sadhyama
5b0d3e19f3 Merge pull request #381 from sadhyama/xmd_send
Xmidt sendData method provider to send upstream events
2022-03-17 11:41:30 +05:30
Sadhyama Vengilat
0d8bb960f6 Merge remote-tracking branch 'upstream/master' into xmd_send 2022-03-17 11:13:23 +05:30
Sadhyama Vengilat
5d537fb139 Disabled async ack inParams release 2022-03-16 20:18:37 +05:30
Sadhyama Vengilat
47fcd6bdae Add rbusObject in xmidt queue 2022-03-16 17:29:11 +05:30
Sadhyama Vengilat
24e1790ccb Rbus inParams check method validation 2022-03-16 16:44:23 +05:30
Sadhyama Vengilat
89fdd97d44 Add more debug logs 2022-03-16 16:13:17 +05:30
Sadhyama Vengilat
5ae2325fb6 Parse rbus inParams into wrp event and send to server 2022-03-15 20:50:30 +05:30
Sadhyama Vengilat
9bad1142ab Xmidt Upstream queue to receive events from components 2022-03-08 19:58:05 +05:30
Vasuki
339b93cfd3 Merge remote-tracking branch 'upstream/master' into wanfailsupport 2022-03-03 14:30:51 +05:30
Vasuki
a34db44c90 Parodus changes for Wanifailover support-2 2022-03-02 19:13:44 +05:30
shilpa24balaji
bdec80dd07 Merge pull request #379 from Thanusha-D/time_diff
ConnectTime value in parodus in terms of device uptime
2022-02-28 19:23:17 +05:30
Vasuki
1833c30e83 Parodus changes for Wanifailover support 2022-02-28 15:57:02 +05:30
Thanusha D
5b26fe38f5 Time value in parodus is higher 2022-02-28 15:16:53 +05:30
Sadhyama Vengilat
f3a4daeb74 To extract inParams received from consumer 2022-02-23 19:49:38 +05:30
Sadhyama Vengilat
aaeb1f6612 To send parodus ack response back to caller 2022-02-11 17:52:16 +05:30
Sadhyama Vengilat
0fb6288255 Parodus to support rbus xmidtSendData provider 2022-01-21 17:10:55 +05:30
shilpa24balaji
0fd3b76f27 Merge pull request #375 from sadhyama/webcfg_binON
Fix parodus PC build issues when webconfig bin is ON
2021-12-07 10:22:13 +05:30
Sadhyama Vengilat
48722ffa7c Fix parodus PC build issues when webconfig bin is ON 2021-12-06 19:57:29 +05:30
shilpa24balaji
bf5d555d96 Merge pull request #374 from xmidt-org/webcfg_bin
Changes to support webconfig as separate binary in RBUS mode
2021-11-30 20:09:56 +05:30
Shilpa Seshadri
c02b141f7c Fixed license in new c file 2021-11-30 19:59:42 +05:30
shilpa24balaji
9f40b7efe5 Merge pull request #371 from krishnangnair/monotonic_clock
Use monotonic clock for heartBeat timer calculation.
2021-11-26 12:13:50 +05:30
shilpa24balaji
2a184e24c9 Merge pull request #372 from shilpa24balaji/webcfg_bin
Use rbus subscribe API instead of addListener API
2021-11-25 23:26:19 +05:30
Shilpa Seshadri
233a167cb4 Use rbus subscribe API instead of addListener API 2021-11-23 22:47:28 +05:30
knair410
5562d7ec48 Use monotonic clock for heartBeat timer calculation. 2021-11-10 23:15:07 +05:30
sadhyama
49513df8f8 Merge pull request #370 from Sreedevi29/bin_flag
Move webcfgbin distro flage to outside of BUILD_YOCTO check.
2021-09-29 10:58:18 +05:30
Sreedevi V
d0e6c5bd75 Move webcfgbin distro flage to outside of BUILD_YOCTO check. 2021-09-29 16:18:38 +05:30
sadhyama
66f1f4d4fb Merge pull request #368 from Sreedevi29/distro_check
Listener for webconfig upstream events when bin distro is on
2021-09-28 14:17:20 +05:30
sadhyama
19b4f56913 Merge pull request #367 from shilpa24balaji/notify_upstream
Listener for webconfig upstream events
2021-09-27 20:16:30 +05:30
Sreedevi V
c30d5a3362 Listener for webconfig upstream events when bin distro is on 2021-09-23 22:08:19 +05:30
Shilpa Seshadri
c98e2e2fb8 Listener for webconfig upstream events 2021-09-23 00:00:32 +05:30
Shilpa Seshadri
c78625f35a Update to use nopoll version 1.0.3 2021-09-22 12:53:53 +05:30
shilpa24balaji
aeea6fbb03 Merge pull request #366 from sadhyama/conn_retry
Fix Parodus connection stuck on interface up down received together
2021-09-02 12:40:16 +05:30
Sadhyama Vengilat
d2d1590329 Fix unit tests on conn_interface 2021-09-01 22:58:17 +05:30
Sadhyama Vengilat
e693c09ca3 Fix Parodus connection stuck on interface up down received together 2021-08-30 20:02:14 +05:30
shilpa24balaji
0b9f739323 Merge pull request #365 from shilpa24balaji/conn_event
Invoke conn status change event only one time on failure
2021-08-25 22:28:17 +05:30
Shilpa Seshadri
d901efd10c Invoke conn status change event only one time on failure 2021-08-25 15:02:19 +05:30
shilpa24balaji
824bcb81cf Merge pull request #364 from shilpa24balaji/conn_event
To fix brackets in conn event check
2021-08-19 22:31:33 +05:30
Shilpa Seshadri
671fc5be59 To fix brackets in conn event check 2021-08-17 23:38:58 +05:30
shilpa24balaji
4bf8683192 Merge pull request #363 from shilpa24balaji/conn_event
Add callback handler for initial connection status change event
2021-08-09 23:46:50 +05:30
Shilpa Seshadri
9300d76a8e Add callback handler for initial connection status change event 2021-07-27 20:06:26 +05:30
31 changed files with 1558 additions and 65 deletions

View File

@@ -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

View File

@@ -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}
@@ -165,8 +172,8 @@ add_dependencies(libcimplog cimplog)
ExternalProject_Add(wrp-c
DEPENDS trower-base64 msgpack cimplog
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/wrp-c
GIT_REPOSITORY https://github.com/Comcast/wrp-c.git
GIT_TAG "1.0.1"
GIT_REPOSITORY https://github.com/xmidt-org/wrp-c.git
GIT_TAG "71f8a39fe39f98da007ed4cdabbb192be1da1685"
CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
-DMSGPACK_ENABLE_CXX=OFF
-DMSGPACK_BUILD_EXAMPLES=OFF
@@ -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,14 @@ 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)
if (WAN_FAILOVER_SUPPORTED)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWAN_FAILOVER_SUPPORTED ")
endif (WAN_FAILOVER_SUPPORTED)
link_directories ( ${LIBRARY_DIR} ${COMMON_LIBRARY_DIR} ${LIBRARY_DIR64} )
add_subdirectory(src)
if (BUILD_TESTING)

View File

@@ -23,6 +23,15 @@ else()
set(SOURCES ${SOURCES} seshat_interface_stub.c)
endif (ENABLE_SESHAT)
if (ENABLE_WEBCFGBIN)
set(SOURCES ${SOURCES} upstream_rbus.c xmidtsend_rbus.c)
endif (ENABLE_WEBCFGBIN)
if (WAN_FAILOVER_SUPPORTED)
message(STATUS "WAN_FAILOVER_SUPPORTED is supported")
else()
message(STATUS "WAN_FAILOVER_SUPPORTED is not supported")
endif (WAN_FAILOVER_SUPPORTED)
add_executable(parodus ${SOURCES})
@@ -53,5 +62,7 @@ if (ENABLE_SESHAT)
target_link_libraries (parodus -llibseshat)
endif (ENABLE_SESHAT)
if (ENABLE_WEBCFGBIN)
target_link_libraries (parodus -lrbus -lrbus-core -lrtMessage)
endif (ENABLE_WEBCFGBIN)
install (TARGETS parodus DESTINATION bin)

View File

@@ -69,9 +69,9 @@ char* getWebpaConveyHeader()
cJSON_AddStringToObject(response, WEBPA_PROTOCOL, get_parodus_cfg()->webpa_protocol);
}
if(strlen(get_parodus_cfg()->webpa_interface_used)!=0)
if(strlen(getWebpaInterface())!=0)
{
cJSON_AddStringToObject(response, WEBPA_INTERFACE, get_parodus_cfg()->webpa_interface_used);
cJSON_AddStringToObject(response, WEBPA_INTERFACE, getWebpaInterface());
}
if(strlen(get_parodus_cfg()->hw_last_reboot_reason)!=0)

View File

@@ -161,7 +161,13 @@ 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();
int regXmidtSendDataMethod();
#endif
#ifdef WAN_FAILOVER_SUPPORTED
void setWebpaInterface(char *value);
#endif
/*------------------------------------------------------------------------------*/
/* For interface_down_event Flag */
/*------------------------------------------------------------------------------*/
@@ -178,8 +184,11 @@ void set_interface_down_event();
pthread_cond_t *get_interface_down_con();
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);
#ifdef __cplusplus
}
#endif

View File

@@ -64,6 +64,7 @@ int requestNewAuthToken(char *newToken, size_t len, int r_count)
struct curl_slist *list = NULL;
struct curl_slist *headers_list = NULL;
char webpa_interface[64]={'\0'};
double total;
struct token_data data;
@@ -80,9 +81,10 @@ int requestNewAuthToken(char *newToken, size_t len, int r_count)
curl_easy_setopt(curl, CURLOPT_URL, get_parodus_cfg()->token_server_url);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, CURL_TIMEOUT_SEC);
if(get_parodus_cfg()->webpa_interface_used !=NULL && strlen(get_parodus_cfg()->webpa_interface_used) >0)
parStrncpy(webpa_interface, getWebpaInterface(), sizeof(webpa_interface));
if(webpa_interface !=NULL && strlen(webpa_interface) >0)
{
curl_easy_setopt(curl, CURLOPT_INTERFACE, get_parodus_cfg()->webpa_interface_used);
curl_easy_setopt(curl, CURLOPT_INTERFACE, webpa_interface);
}
/* set callback for writing received data */
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback_fn);
@@ -304,7 +306,7 @@ void createCurlheader(struct curl_slist *list, struct curl_slist **header_list)
snprintf(buf, MAX_BUF_SIZE, "X-Midt-Protocol: %s", get_parodus_cfg()->webpa_protocol);
list = curl_slist_append(list, buf);
snprintf(buf, MAX_BUF_SIZE, "X-Midt-Interface-Used: %s", get_parodus_cfg()->webpa_interface_used);
snprintf(buf, MAX_BUF_SIZE, "X-Midt-Interface-Used: %s", getWebpaInterface());
list = curl_slist_append(list, buf);
snprintf(buf, MAX_BUF_SIZE, "X-Midt-Last-Reboot-Reason: %s", get_parodus_cfg()->hw_last_reboot_reason);

View File

@@ -33,13 +33,30 @@
/*----------------------------------------------------------------------------*/
/* File Scoped Variables */
/*----------------------------------------------------------------------------*/
pthread_mutex_t config_mut=PTHREAD_MUTEX_INITIALIZER;
//For sending cond signal when cloud status is ONLINE
pthread_mutex_t cloud_status_mut=PTHREAD_MUTEX_INITIALIZER;
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);
/*----------------------------------------------------------------------------*/
/* External Functions */
/*----------------------------------------------------------------------------*/
pthread_cond_t *get_global_cloud_status_cond(void)
{
return &cloud_status_cond;
}
pthread_mutex_t *get_global_cloud_status_mut(void)
{
return &cloud_status_mut;
}
ParodusCfg *get_parodus_cfg(void)
{
@@ -61,6 +78,27 @@ void reset_cloud_disconnect_reason(ParodusCfg *cfg)
cfg->cloud_disconnect = NULL;
}
void set_cloud_status(char *status)
{
if(status != NULL)
{
pthread_mutex_lock(&config_mut);
get_parodus_cfg()->cloud_status = status;
if(strcmp (status, CLOUD_STATUS_ONLINE) == 0)
{
pthread_cond_signal(&cloud_status_cond);
}
pthread_mutex_unlock(&config_mut);
}
}
char *get_cloud_status(void)
{
pthread_mutex_lock(&config_mut);
parStrncpy(cloud_status, get_parodus_cfg()->cloud_status, sizeof(cloud_status));
pthread_mutex_unlock(&config_mut);
return cloud_status;
}
const char *get_tok (const char *src, int delim, char *result, int resultsize)
{
@@ -146,9 +184,9 @@ void read_key_from_file (const char *fname, char *buf, size_t buflen)
int parse_mac_address (char *target, const char *arg)
{
int count = 0;
int i;
int i, j;
char c;
char *mac = target;
for (i=0; (c=arg[i]) != 0; i++) {
if (c !=':')
count++;
@@ -160,6 +198,13 @@ int parse_mac_address (char *target, const char *arg)
*(target++) = c;
}
*target = 0; // terminating null
//convert mac to lowercase
for(j = 0; mac[j]; j++)
{
mac[j] = tolower(mac[j]);
}
ParodusPrint("mac in lowercase is %s\n", mac);
return 0;
}
@@ -724,7 +769,7 @@ void loadParodusCfg(ParodusCfg * config,ParodusCfg *cfg)
}
if(strlen(config->webpa_interface_used )!=0)
{
parStrncpy(cfg->webpa_interface_used, config->webpa_interface_used,sizeof(cfg->webpa_interface_used));
parStrncpy(getWebpaInterface(), config->webpa_interface_used,sizeof(getWebpaInterface()));
}
else
{
@@ -848,4 +893,26 @@ void loadParodusCfg(ParodusCfg * config,ParodusCfg *cfg)
}
}
#ifdef WAN_FAILOVER_SUPPORTED
void setWebpaInterface(char *value)
{
pthread_mutex_lock (&config_mut);
parStrncpy(get_parodus_cfg()->webpa_interface_used, value, sizeof(get_parodus_cfg()->webpa_interface_used));
pthread_mutex_unlock (&config_mut);
}
#endif
char *getWebpaInterface(void)
{
#ifdef WAN_FAILOVER_SUPPORTED
ParodusPrint("WAN_FAILOVER_SUPPORTED mode \n");
pthread_mutex_lock (&config_mut);
parStrncpy(webpa_interface, get_parodus_cfg()->webpa_interface_used, sizeof(webpa_interface));
pthread_mutex_unlock (&config_mut);
#else
parStrncpy(webpa_interface, get_parodus_cfg()->webpa_interface_used, sizeof(webpa_interface));
#endif
ParodusPrint("webpa_interface:%s\n", webpa_interface);
return webpa_interface;
}

View File

@@ -24,6 +24,7 @@
#ifndef _CONFIG_H_
#define _CONFIG_H_
#include <pthread.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -139,6 +140,10 @@ void set_parodus_cfg(ParodusCfg *);
char *get_token_application(void) ;
void set_cloud_disconnect_reason(ParodusCfg *cfg, char *disconn_reason);
void reset_cloud_disconnect_reason(ParodusCfg *cfg);
char *getWebpaInterface(void);
void set_cloud_status(char *status);
char *get_cloud_status(void);
int get_parodus_init();
/**
* parse a webpa url. Extract the server address, the port
* and return whether it's secure or not

View File

@@ -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 WAN_FAILOVER_SUPPORTED
subscribeCurrentActiveInterfaceEvent();
#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());

View File

@@ -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;
@@ -130,7 +132,10 @@ void set_cloud_disconnect_time(int disconnTime)
cloud_disconnect_max_time = disconnTime;
}
int get_parodus_init()
{
return init;
}
//--------------------------------------------------------------------
// createNopollConnection_logic:
@@ -697,7 +702,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;
}
}
@@ -714,9 +720,9 @@ int createNopollConnection(noPollCtx *ctx, server_list_t *server_list)
{
create_connection_ctx_t conn_ctx;
int max_retry_count;
struct timespec connect_time,*connectTimePtr;
connectTimePtr = &connect_time;
backoff_timer_t backoff_timer;
static int init_conn_failure=1;
struct sysinfo l_sSysInfo;
if(ctx == NULL) {
return nopoll_false;
@@ -752,6 +758,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))
@@ -761,7 +775,7 @@ int createNopollConnection(noPollCtx *ctx, server_list_t *server_list)
}
#endif
}
if(conn_ctx.current_server->allow_insecure <= 0)
{
ParodusInfo("Connected to server over SSL\n");
@@ -772,9 +786,12 @@ int createNopollConnection(noPollCtx *ctx, server_list_t *server_list)
ParodusInfo("Connected to server\n");
OnboardLog("Connected to server\n");
}
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)
@@ -782,9 +799,9 @@ int createNopollConnection(noPollCtx *ctx, server_list_t *server_list)
on_ping_status_change("received");
}
if((get_parodus_cfg()->boot_time != 0) && init) {
getCurrentTime(connectTimePtr);
ParodusInfo("connect_time-diff-boot_time=%d\n", connectTimePtr->tv_sec - get_parodus_cfg()->boot_time);
if(init) {
sysinfo(&l_sSysInfo);
ParodusInfo("connect_time-diff-boot_time=%ld\n", l_sSysInfo.uptime);
init = 0; //set init to 0 so that this is logged only during process start up and not during reconnect
}
@@ -800,6 +817,9 @@ int createNopollConnection(noPollCtx *ctx, server_list_t *server_list)
ParodusPrint("LastReasonStatus reset after successful connection\n");
setMessageHandlers();
stop_conn_in_progress ();
ParodusPrint("set cloud_status\n");
set_cloud_status(CLOUD_STATUS_ONLINE);
ParodusInfo("cloud_status set as %s after successful connection\n", get_cloud_status());
return nopoll_true;
}
@@ -844,7 +864,7 @@ static noPollConnOpts * createConnOpts (char * extra_headers, bool secure)
nopoll_conn_opts_ssl_peer_verify (opts, nopoll_true);
nopoll_conn_opts_set_ssl_protocol (opts, NOPOLL_METHOD_TLSV1_2);
}
nopoll_conn_opts_set_interface (opts,get_parodus_cfg()->webpa_interface_used);
nopoll_conn_opts_set_interface (opts,getWebpaInterface());
nopoll_conn_opts_set_extra_headers (opts,extra_headers);
return opts;
}
@@ -884,8 +904,8 @@ void close_and_unref_connection(noPollConn *conn, bool is_shutting_down)
{
if (conn) {
close_conn (conn, is_shutting_down);
get_parodus_cfg()->cloud_status = CLOUD_STATUS_OFFLINE;
ParodusInfo("cloud_status set as %s after connection close\n", get_parodus_cfg()->cloud_status);
set_cloud_status(CLOUD_STATUS_OFFLINE);
ParodusInfo("cloud_status set as %s after connection close\n", get_cloud_status());
}
}
@@ -934,3 +954,8 @@ void registerParodusOnPingStatusChangeHandler(parodusOnPingStatusChangeHandler c
on_ping_status_change = callback_func;
}
void registerParodusOnConnStatusChangeHandler(parodusOnConnStatusChangeHandler callback_func)
{
on_conn_status_change = callback_func;
}

View File

@@ -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);

View File

@@ -537,13 +537,13 @@ int retrieveFromMemory(char *keyName, cJSON **jsonresponse)
}
else if(strcmp(WEBPA_INTERFACE, keyName)==0)
{
if((get_parodus_cfg()->webpa_interface_used !=NULL)&& (strlen(get_parodus_cfg()->fw_name)==0))
if((getWebpaInterface() !=NULL)&& (strlen(get_parodus_cfg()->fw_name)==0))
{
ParodusError("retrieveFromMemory: webpa_interface_used value is NULL\n");
return -1;
}
ParodusInfo("retrieveFromMemory: keyName:%s value:%s\n",keyName,get_parodus_cfg()->webpa_interface_used);
cJSON_AddItemToObject( *jsonresponse, WEBPA_INTERFACE , cJSON_CreateString(get_parodus_cfg()->webpa_interface_used));
ParodusInfo("retrieveFromMemory: keyName:%s value:%s\n",keyName,getWebpaInterface());
cJSON_AddItemToObject( *jsonresponse, WEBPA_INTERFACE , cJSON_CreateString(getWebpaInterface()));
}
else if(strcmp(WEBPA_URL, keyName)==0)
{
@@ -577,20 +577,20 @@ int retrieveFromMemory(char *keyName, cJSON **jsonresponse)
}
else if(strcmp(CLOUD_STATUS, keyName)==0)
{
if(get_parodus_cfg()->cloud_status ==NULL)
if(get_cloud_status() ==NULL)
{
ParodusError("retrieveFromMemory: cloud_status value is NULL\n");
return -1;
}
else if((get_parodus_cfg()->cloud_status !=NULL) && (strlen(get_parodus_cfg()->cloud_status)==0))
else if((get_cloud_status() !=NULL) && (strlen(get_cloud_status())==0))
{
ParodusError("retrieveFromMemory: cloud_status value is empty\n");
return -1;
}
else
{
ParodusInfo("retrieveFromMemory: keyName:%s value:%s\n", keyName, get_parodus_cfg()->cloud_status);
cJSON_AddItemToObject( *jsonresponse, CLOUD_STATUS , cJSON_CreateString(get_parodus_cfg()->cloud_status));
ParodusInfo("retrieveFromMemory: keyName:%s value:%s\n", keyName, get_cloud_status());
cJSON_AddItemToObject( *jsonresponse, CLOUD_STATUS , cJSON_CreateString(get_cloud_status()));
}
}
else if(strcmp(BOOT_TIME, keyName)==0)

View File

@@ -106,6 +106,10 @@ int main( int argc, char **argv)
ParodusInfo("********** Starting component: Parodus **********\n ");
drop_root_privilege();
#ifdef ENABLE_WEBCFGBIN
subscribeRBUSevent();
regXmidtSendDataMethod();
#endif
setDefaultValuesToCfg(cfg);
if (0 != parseCommandLine(argc,argv,cfg)) {
abort();

View File

@@ -52,7 +52,7 @@ void setMessageHandlers()
static int cloud_status_is_online (void)
{
const char *status = get_parodus_cfg()->cloud_status;
const char *status = get_cloud_status();
if (NULL == status)
return false;
return (strcmp (status, CLOUD_STATUS_ONLINE) == 0);
@@ -60,14 +60,14 @@ static int cloud_status_is_online (void)
/** To send upstream msgs to server ***/
void sendMessage(noPollConn *conn, void *msg, size_t len)
int sendMessage(noPollConn *conn, void *msg, size_t len)
{
int bytesWritten = 0;
if (!cloud_status_is_online ()) {
ParodusError("Failed to send msg upstream as connection is not OK\n");
OnboardLog("Failed to send msg upstream as connection is not OK\n");
return;
return 1;
}
ParodusInfo("sendMessage length %zu\n", len);
@@ -77,7 +77,9 @@ void sendMessage(noPollConn *conn, void *msg, size_t len)
if (bytesWritten != (int) len)
{
ParodusError("Failed to send bytes %zu, bytes written were=%d (errno=%d, %s)..\n", len, bytesWritten, errno, strerror(errno));
return 1;
}
return 0;
}
int sendResponse(noPollConn * conn, void * buffer, size_t length)

View File

@@ -41,7 +41,7 @@ extern "C" {
*/
int sendResponse(noPollConn * conn,void *str, size_t bufferSize);
void setMessageHandlers();
void sendMessage(noPollConn *conn, void *msg, size_t len);
int sendMessage(noPollConn *conn, void *msg, size_t len);
/**
* @brief __report_log Nopoll log handler

View File

@@ -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)

View File

@@ -83,7 +83,6 @@ void packMetaData()
//Pack the metadata initially to reuse for every upstream msg sending to server
ParodusPrint("-------------- Packing metadata ----------------\n");
sprintf(boot_time, "%d", get_parodus_cfg()->boot_time);
struct data meta_pack[METADATA_COUNT] = {
{HW_MODELNAME, get_parodus_cfg()->hw_model},
{HW_SERIALNUMBER, get_parodus_cfg()->hw_serial_number},
@@ -95,10 +94,9 @@ void packMetaData()
{LAST_RECONNECT_REASON, get_global_reconnect_reason()},
{WEBPA_PROTOCOL, get_parodus_cfg()->webpa_protocol},
{WEBPA_UUID,get_parodus_cfg()->webpa_uuid},
{WEBPA_INTERFACE, get_parodus_cfg()->webpa_interface_used},
{WEBPA_INTERFACE, getWebpaInterface()},
{PARTNER_ID, get_parodus_cfg()->partner_id}
};
const data_t metapack = {METADATA_COUNT, meta_pack};
metaPackSize = wrp_pack_metadata( &metapack , &metadataPack );
@@ -330,6 +328,7 @@ void *processUpstreamMessage()
if(ret == 1)
{
wrp_msg_t *eventMsg = (wrp_msg_t *) malloc(sizeof(wrp_msg_t));
memset( eventMsg, 0, sizeof( wrp_msg_t ) );
eventMsg->msg_type = msgType;
eventMsg->u.event.content_type=msg->u.event.content_type;
eventMsg->u.event.source=msg->u.event.source;
@@ -339,6 +338,15 @@ void *processUpstreamMessage()
eventMsg->u.event.headers=msg->u.event.headers;
eventMsg->u.event.metadata=msg->u.event.metadata;
eventMsg->u.event.partner_ids = partnersList;
if(msg->u.event.transaction_uuid)
{
ParodusPrint("Inside Trans id in PARODUS\n");
}
else
{
ParodusPrint("Assigning NULL to trans id\n");
eventMsg->u.event.transaction_uuid = NULL;
}
int size = wrp_struct_to( eventMsg, WRP_BYTES, &bytes );
if(size > 0)
@@ -596,11 +604,12 @@ void getServiceNameAndSendResponse(wrp_msg_t *msg, void **msg_bytes, size_t msg_
}
}
void sendUpstreamMsgToServer(void **resp_bytes, size_t resp_size)
int sendUpstreamMsgToServer(void **resp_bytes, size_t resp_size)
{
void *appendData;
size_t encodedSize;
bool close_retry = false;
int sendRetStatus = 1;
//appending response with metadata
if(metaPackSize > 0)
{
@@ -615,12 +624,13 @@ void sendUpstreamMsgToServer(void **resp_bytes, size_t resp_size)
//TODO: Upstream and downstream messages in queue should be handled and queue should be empty before parodus forcefully disconnect from cloud.
if(!close_retry || (get_parodus_cfg()->cloud_disconnect !=NULL))
{
sendMessage(get_global_conn(),appendData, encodedSize);
sendRetStatus = sendMessage(get_global_conn(),appendData, encodedSize);
}
else
{
ParodusInfo("close_retry is %d, unable to send response as connection retry is in progress\n", close_retry);
OnboardLog("close_retry is %d, unable to send response as connection retry is in progress\n", close_retry);
sendRetStatus = 1;
}
free(appendData);
appendData =NULL;
@@ -628,6 +638,9 @@ void sendUpstreamMsgToServer(void **resp_bytes, size_t resp_size)
else
{
ParodusError("Failed to send upstream as metadata packing is not successful\n");
sendRetStatus = 1;
}
ParodusPrint("sendRetStatus is %d\n", sendRetStatus);
return sendRetStatus;
}

View File

@@ -47,11 +47,15 @@ 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);
int sendUpstreamMsgToServer(void **resp_bytes, size_t resp_size);
void getServiceNameAndSendResponse(wrp_msg_t *msg, void **msg_bytes, size_t msg_size);
void createUpstreamRetrieveMsg(wrp_msg_t *message, wrp_msg_t **retrieve_msg);
void set_global_UpStreamMsgQ(UpStreamMsg * UpStreamQ);
#ifdef WAN_FAILOVER_SUPPORTED
int subscribeCurrentActiveInterfaceEvent();
#endif
UpStreamMsg * get_global_UpStreamMsgQ(void);
pthread_cond_t *get_global_nano_con(void);
pthread_mutex_t *get_global_nano_mut(void);

211
src/upstream_rbus.c Normal file
View File

@@ -0,0 +1,211 @@
/**
* 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"
#include "close_retry.h"
#include "connection.h"
#include "heartBeat.h"
#define WEBCFG_UPSTREAM_EVENT "Webconfig.Upstream"
#ifdef WAN_FAILOVER_SUPPORTED
#define WEBPA_INTERFACE "Device.X_RDK_WanManager.CurrentActiveInterface"
#endif
rbusHandle_t rbus_Handle;
rbusError_t err;
void processWebconfigUpstreamEvent(rbusHandle_t handle, rbusEvent_t const* event, rbusEventSubscription_t* subscription);
void subscribeAsyncHandler( rbusHandle_t handle, rbusEventSubscription_t* subscription, rbusError_t error);
rbusHandle_t get_parodus_rbus_Handle(void)
{
return rbus_Handle;
}
#ifdef WAN_FAILOVER_SUPPORTED
void eventReceiveHandler( rbusHandle_t rbus_Handle, rbusEvent_t const* event, rbusEventSubscription_t* subscription );
#endif
/* API to register RBUS listener to receive messages from webconfig */
void subscribeRBUSevent()
{
int rc = RBUS_ERROR_SUCCESS;
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");
}
#ifdef WAN_FAILOVER_SUPPORTED
/* API to subscribe Active Interface name on value change event*/
int subscribeCurrentActiveInterfaceEvent()
{
int rc = RBUS_ERROR_SUCCESS;
ParodusPrint("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)
{
ParodusError("%s subscribe failed : %d - %s\n", WEBPA_INTERFACE, rc, rbusError_ToString(rc));
}
return rc;
}
#endif
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));
memset( eventMsg, 0, 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;
if(event_msg->u.event.transaction_uuid)
{
ParodusPrint("Inside Trans id in PARODUS_rbus\n");
}
else
{
ParodusPrint("Assigning NULL to trans id RBUS\n");
eventMsg->u.event.transaction_uuid = NULL;
}
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));
}
#ifdef WAN_FAILOVER_SUPPORTED
void eventReceiveHandler( rbusHandle_t rbus_Handle, rbusEvent_t const* event, rbusEventSubscription_t* subscription )
{
(void)subscription;
ParodusPrint("Handling event inside eventReceiveHandler\n");
(void)rbus_Handle;
char * interface = NULL;
rbusValue_t newValue = rbusObject_GetValue(event->data, "value");
rbusValue_t oldValue = rbusObject_GetValue(event->data, "oldValue");
ParodusInfo("Consumer received ValueChange event for param %s\n", event->name);
if(newValue) {
interface = (char *) rbusValue_GetString(newValue, NULL);
setWebpaInterface(interface);
}
else {
ParodusError("newValue is NULL\n");
}
if(newValue !=NULL && oldValue!=NULL && interface!=NULL) {
ParodusInfo("New Value: %s Old Value: %s New Interface Value: %s\n", rbusValue_GetString(newValue, NULL), rbusValue_GetString(oldValue, NULL), interface);
// If interface is already down then reset it and reconnect cloud conn as wan failover event is received
if(get_interface_down_event())
{
reset_interface_down_event();
ParodusInfo("Interface_down_event is reset\n");
resume_heartBeatTimer();
}
// Close cloud conn and reconnect with the new interface as wan failover event is received
set_global_reconnect_reason("WAN_FAILOVER");
set_global_reconnect_status(true);
set_close_retry();
}
else {
if(oldValue == NULL) {
ParodusError("oldValue is NULL\n");
}
if(interface == NULL) {
ParodusError("interface is NULL\n");
}
}
}
#endif

881
src/xmidtsend_rbus.c Normal file
View File

@@ -0,0 +1,881 @@
/**
* Copyright 2022 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 xmidtsend_rbus.c
*
* @ To provide Xmidt send RBUS method to send events upstream.
*
*/
#include <stdlib.h>
#include <rbus.h>
#include "upstream.h"
#include "ParodusInternal.h"
#include "partners_check.h"
#include "xmidtsend_rbus.h"
#include "config.h"
static pthread_t processThreadId = 0;
static int XmidtQsize = 0;
XmidtMsg *XmidtMsgQ = NULL;
pthread_mutex_t xmidt_mut=PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t xmidt_con=PTHREAD_COND_INITIALIZER;
const char * contentTypeList[]={
"application/json",
"avro/binary",
"application/msgpack",
"application/binary"
};
void printSendMsgData(char* status, int qos, char* dest, char* transaction_uuid) {
ParodusInfo("status: %s, qos: %d, dest: %s, transaction_uuid: %s\n", (status!=NULL)?status:"NULL", qos, (dest!=NULL)?dest:"NULL", (transaction_uuid!=NULL)?transaction_uuid:"NULL");
}
bool highQosValueCheck(int qos)
{
if(qos > 24)
{
ParodusInfo("The qos value is high\n");
return true;
}
else
{
ParodusPrint("The qos value is low\n");
}
return false;
}
/*
* @brief To handle xmidt rbus messages received from various components.
*/
void addToXmidtUpstreamQ(wrp_msg_t * msg, rbusMethodAsyncHandle_t asyncHandle)
{
XmidtMsg *message;
ParodusPrint("XmidtQsize is %d\n" , XmidtQsize);
if(XmidtQsize == MAX_QUEUE_SIZE)
{
char * errorMsg = strdup("Max Queue Size Exceeded");
ParodusError("Queue Size Exceeded\n");
createOutParamsandSendAck(msg, asyncHandle, errorMsg , QUEUE_SIZE_EXCEEDED, RBUS_ERROR_INVALID_RESPONSE_FROM_DESTINATION);
wrp_free_struct(msg);
return;
}
ParodusPrint ("Add Xmidt Upstream message to queue\n");
message = (XmidtMsg *)malloc(sizeof(XmidtMsg));
if(message)
{
message->msg = msg;
message->asyncHandle =asyncHandle;
//Increment queue size to handle max queue limit
XmidtQsize++;
message->next=NULL;
pthread_mutex_lock (&xmidt_mut);
//Producer adds the rbus msg into queue
if(XmidtMsgQ == NULL)
{
XmidtMsgQ = message;
ParodusPrint("Producer added xmidt message\n");
pthread_cond_signal(&xmidt_con);
pthread_mutex_unlock (&xmidt_mut);
ParodusPrint("mutex unlock in xmidt producer\n");
}
else
{
XmidtMsg *temp = XmidtMsgQ;
while(temp->next)
{
temp = temp->next;
}
temp->next = message;
pthread_mutex_unlock (&xmidt_mut);
}
}
else
{
char * errorMsg = strdup("Unable to enqueue");
ParodusError("failure in allocation for xmidt message\n");
createOutParamsandSendAck(msg, asyncHandle, errorMsg , ENQUEUE_FAILURE, RBUS_ERROR_INVALID_RESPONSE_FROM_DESTINATION);
wrp_free_struct(msg);
}
return;
}
//Xmidt consumer thread to process the rbus events.
void processXmidtData()
{
int err = 0;
err = pthread_create(&processThreadId, NULL, processXmidtUpstreamMsg, NULL);
if (err != 0)
{
ParodusError("Error creating processXmidtData thread :[%s]\n", strerror(err));
}
else
{
ParodusInfo("processXmidtData thread created Successfully\n");
}
}
//Consumer to Parse and process rbus data.
void* processXmidtUpstreamMsg()
{
int rv = 0;
while(FOREVER())
{
if(get_parodus_init())
{
ParodusInfo("Initial cloud connection is not established, Xmidt wait till connection up\n");
pthread_mutex_lock(get_global_cloud_status_mut());
pthread_cond_wait(get_global_cloud_status_cond(), get_global_cloud_status_mut());
pthread_mutex_unlock(get_global_cloud_status_mut());
ParodusInfo("Received cloud status signal proceed to event processing\n");
}
pthread_mutex_lock (&xmidt_mut);
ParodusPrint("mutex lock in xmidt consumer thread\n");
if(XmidtMsgQ != NULL)
{
XmidtMsg *Data = XmidtMsgQ;
pthread_mutex_unlock (&xmidt_mut);
ParodusPrint("mutex unlock in xmidt consumer thread\n");
rv = processData(Data->msg, Data->asyncHandle);
if(!rv)
{
ParodusPrint("Data->msg wrp free\n");
wrp_free_struct(Data->msg);
}
else
{
free(Data->msg);
}
free(Data);
Data = NULL;
}
else
{
if (g_shutdown)
{
pthread_mutex_unlock (&xmidt_mut);
break;
}
ParodusPrint("Before cond wait in xmidt consumer thread\n");
pthread_cond_wait(&xmidt_con, &xmidt_mut);
pthread_mutex_unlock (&xmidt_mut);
ParodusPrint("mutex unlock in xmidt thread after cond wait\n");
}
}
return NULL;
}
//To validate and send events upstream
int processData(wrp_msg_t * msg, rbusMethodAsyncHandle_t asyncHandle)
{
int rv = 0;
char *errorMsg = "none";
int statuscode =0;
wrp_msg_t * xmidtMsg = msg;
if (xmidtMsg == NULL)
{
ParodusError("xmidtMsg is NULL\n");
errorMsg = strdup("Unable to enqueue");
createOutParamsandSendAck(xmidtMsg, asyncHandle, errorMsg, ENQUEUE_FAILURE, RBUS_ERROR_INVALID_RESPONSE_FROM_DESTINATION);
xmidtQDequeue();
return rv;
}
rv = validateXmidtData(xmidtMsg, &errorMsg, &statuscode);
ParodusPrint("validateXmidtData, errorMsg %s statuscode %d\n", errorMsg, statuscode);
if(rv)
{
ParodusPrint("validation successful, send event to server\n");
sendXmidtEventToServer(xmidtMsg, asyncHandle);
return rv;
}
else
{
ParodusError("validation failed, send failure ack\n");
createOutParamsandSendAck(xmidtMsg, asyncHandle, errorMsg , statuscode, RBUS_ERROR_INVALID_INPUT);
xmidtQDequeue();
}
return rv;
}
//To remove an event from Queue
void xmidtQDequeue()
{
pthread_mutex_lock (&xmidt_mut);
if(XmidtMsgQ != NULL)
{
XmidtMsgQ = XmidtMsgQ->next;
XmidtQsize -= 1;
}
else
{
ParodusError("XmidtMsgQ is NULL\n");
}
pthread_mutex_unlock (&xmidt_mut);
}
int validateXmidtData(wrp_msg_t * eventMsg, char **errorMsg, int *statusCode)
{
if(eventMsg == NULL)
{
ParodusError("eventMsg is NULL\n");
return 0;
}
if(eventMsg->msg_type != WRP_MSG_TYPE__EVENT)
{
*errorMsg = strdup("Message format is invalid");
*statusCode = INVALID_MSG_TYPE;
ParodusError("errorMsg: %s, statusCode: %d\n", *errorMsg, *statusCode);
return 0;
}
if(eventMsg->u.event.source == NULL)
{
*errorMsg = strdup("Missing source");
*statusCode = MISSING_SOURCE;
ParodusError("errorMsg: %s, statusCode: %d\n", *errorMsg, *statusCode);
return 0;
}
if(eventMsg->u.event.dest == NULL)
{
*errorMsg = strdup("Missing dest");
*statusCode = MISSING_DEST;
ParodusError("errorMsg: %s, statusCode: %d\n", *errorMsg, *statusCode);
return 0;
}
if(eventMsg->u.event.content_type == NULL)
{
*errorMsg = strdup("Missing content_type");
*statusCode = MISSING_CONTENT_TYPE;
ParodusError("errorMsg: %s, statusCode: %d\n", *errorMsg, *statusCode);
return 0;
}
else
{
int i =0, count = 0, valid = 0;
count = sizeof(contentTypeList)/sizeof(contentTypeList[0]);
for(i = 0; i<count; i++)
{
if (strcmp(eventMsg->u.event.content_type, contentTypeList[i]) == 0)
{
ParodusPrint("content_type is valid %s\n", contentTypeList[i]);
valid = 1;
break;
}
}
if (!valid)
{
ParodusError("content_type is not valid, %s\n", eventMsg->u.event.content_type);
*errorMsg = strdup("Invalid content_type");
*statusCode = INVALID_CONTENT_TYPE;
ParodusError("errorMsg: %s, statusCode: %d\n", *errorMsg, *statusCode);
return 0;
}
}
if(eventMsg->u.event.payload == NULL)
{
*errorMsg = strdup("Missing payload");
*statusCode = MISSING_PAYLOAD;
ParodusError("errorMsg: %s, statusCode: %d\n", *errorMsg, *statusCode);
return 0;
}
if(eventMsg->u.event.payload_size == 0)
{
*errorMsg = strdup("Missing payloadlen");
*statusCode = MISSING_PAYLOADLEN;
ParodusError("errorMsg: %s, statusCode: %d\n", *errorMsg, *statusCode);
return 0;
}
ParodusPrint("validateXmidtData success. errorMsg %s statusCode %d\n", *errorMsg, *statusCode);
return 1;
}
void sendXmidtEventToServer(wrp_msg_t * msg, rbusMethodAsyncHandle_t asyncHandle)
{
wrp_msg_t *notif_wrp_msg = NULL;
ssize_t msg_len;
void *msg_bytes;
int ret = -1;
char sourceStr[64] = {'\0'};
char *device_id = NULL;
size_t device_id_len = 0;
int sendRetStatus = 1;
char *errorMsg = NULL;
int qos = 0;
notif_wrp_msg = (wrp_msg_t *)malloc(sizeof(wrp_msg_t));
if(notif_wrp_msg != NULL)
{
memset(notif_wrp_msg, 0, sizeof(wrp_msg_t));
notif_wrp_msg->msg_type = WRP_MSG_TYPE__EVENT;
ParodusPrint("msg->u.event.source: %s\n",msg->u.event.source);
if(msg->u.event.source !=NULL)
{
//To get device_id in the format "mac:112233445xxx"
ret = getDeviceId(&device_id, &device_id_len);
if(ret == 0)
{
ParodusPrint("device_id %s device_id_len %lu\n", device_id, device_id_len);
snprintf(sourceStr, sizeof(sourceStr), "%s/%s", device_id, msg->u.event.source);
ParodusPrint("sourceStr formed is %s\n" , sourceStr);
notif_wrp_msg->u.event.source = strdup(sourceStr);
ParodusInfo("source:%s\n", notif_wrp_msg->u.event.source);
}
else
{
ParodusError("Failed to get device_id\n");
}
if(device_id != NULL)
{
free(device_id);
device_id = NULL;
}
}
if(msg->u.event.dest != NULL)
{
notif_wrp_msg->u.event.dest = msg->u.event.dest;
ParodusInfo("destination: %s\n", notif_wrp_msg->u.event.dest);
}
if(msg->u.event.transaction_uuid != NULL)
{
notif_wrp_msg->u.event.transaction_uuid = msg->u.event.transaction_uuid;
ParodusPrint("Notification transaction_uuid %s\n", notif_wrp_msg->u.event.transaction_uuid);
}
if(msg->u.event.content_type != NULL)
{
notif_wrp_msg->u.event.content_type = msg->u.event.content_type;
ParodusInfo("content_type is %s\n",notif_wrp_msg->u.event.content_type);
}
if(msg->u.event.payload != NULL)
{
ParodusInfo("Notification payload: %s\n",msg->u.event.payload);
notif_wrp_msg->u.event.payload = (void *)msg->u.event.payload;
notif_wrp_msg->u.event.payload_size = msg->u.event.payload_size;
ParodusPrint("payload size %lu\n", notif_wrp_msg->u.event.payload_size);
}
if(msg->u.event.qos != 0)
{
notif_wrp_msg->u.event.qos = msg->u.event.qos;
qos = notif_wrp_msg->u.event.qos;
ParodusInfo("Notification qos: %d\n",notif_wrp_msg->u.event.qos);
}
msg_len = wrp_struct_to (notif_wrp_msg, WRP_BYTES, &msg_bytes);
ParodusPrint("Encoded xmidt wrp msg, msg_len %lu\n", msg_len);
if(msg_len > 0)
{
ParodusPrint("sendUpstreamMsgToServer\n");
printSendMsgData("send to server", notif_wrp_msg->u.event.qos, notif_wrp_msg->u.event.dest, notif_wrp_msg->u.event.transaction_uuid);
sendRetStatus = sendUpstreamMsgToServer(&msg_bytes, msg_len);
}
else
{
ParodusError("wrp msg_len is zero\n");
errorMsg = strdup("Wrp message encoding failed");
createOutParamsandSendAck(msg, asyncHandle, errorMsg, WRP_ENCODE_FAILURE, RBUS_ERROR_INVALID_RESPONSE_FROM_DESTINATION);
xmidtQDequeue();
ParodusPrint("wrp_free_struct\n");
if(notif_wrp_msg != NULL)
{
wrp_free_struct(notif_wrp_msg);
}
if(msg_bytes != NULL)
{
free(msg_bytes);
msg_bytes = NULL;
}
return;
}
while(sendRetStatus) //If SendMessage is failed condition
{
ParodusError("sendXmidtEventToServer is Failed\n");
if(highQosValueCheck(qos))
{
ParodusPrint("The event is having high qos retry again\n");
ParodusInfo("Wait till connection is Up\n");
pthread_mutex_lock(get_global_cloud_status_mut());
pthread_cond_wait(get_global_cloud_status_cond(), get_global_cloud_status_mut());
pthread_mutex_unlock(get_global_cloud_status_mut());
ParodusInfo("Received cloud status signal proceed to retry\n");
printSendMsgData("send to server after cloud reconnect", notif_wrp_msg->u.event.qos, notif_wrp_msg->u.event.dest, notif_wrp_msg->u.event.transaction_uuid);
}
else
{
errorMsg = strdup("send failed due to client disconnect");
ParodusInfo("The event is having low qos proceed to dequeue\n");
printSendMsgData(errorMsg, notif_wrp_msg->u.event.qos, notif_wrp_msg->u.event.dest, notif_wrp_msg->u.event.transaction_uuid);
createOutParamsandSendAck(msg, asyncHandle, errorMsg, CLIENT_DISCONNECT, RBUS_ERROR_INVALID_RESPONSE_FROM_DESTINATION);
xmidtQDequeue();
break;
}
sendRetStatus = sendUpstreamMsgToServer(&msg_bytes, msg_len);
}
if(sendRetStatus == 0)
{
errorMsg = strdup("send to server success");
createOutParamsandSendAck(msg, asyncHandle, errorMsg, DELIVERED_SUCCESS, RBUS_ERROR_SUCCESS);
xmidtQDequeue();
}
ParodusPrint("B4 notif wrp_free_struct\n");
if(notif_wrp_msg != NULL)
{
wrp_free_struct(notif_wrp_msg);
}
if(msg_bytes != NULL)
{
free(msg_bytes);
msg_bytes = NULL;
}
}
else
{
errorMsg = strdup("Memory allocation failed");
ParodusError("Memory allocation failed\n");
createOutParamsandSendAck(msg, asyncHandle, errorMsg, MSG_PROCESSING_FAILED, RBUS_ERROR_INVALID_RESPONSE_FROM_DESTINATION);
xmidtQDequeue();
}
if(msg->u.event.source !=NULL)
{
free(msg->u.event.source);
msg->u.event.source = NULL;
}
}
void createOutParamsandSendAck(wrp_msg_t *msg, rbusMethodAsyncHandle_t asyncHandle, char *errorMsg, int statuscode, rbusError_t error)
{
rbusObject_t outParams;
rbusError_t err;
rbusValue_t value;
char qosstring[20] = "";
rbusValue_Init(&value);
rbusValue_SetString(value, "event");
rbusObject_Init(&outParams, NULL);
rbusObject_SetValue(outParams, "msg_type", value);
rbusValue_Release(value);
ParodusPrint("statuscode %d errorMsg %s\n", statuscode, errorMsg);
rbusValue_Init(&value);
rbusValue_SetInt32(value, statuscode);
rbusObject_SetValue(outParams, "status", value);
rbusValue_Release(value);
if(errorMsg !=NULL)
{
rbusValue_Init(&value);
rbusValue_SetString(value, errorMsg);
rbusObject_SetValue(outParams, "error_message", value);
rbusValue_Release(value);
free(errorMsg);
}
if(msg != NULL)
{
if(msg->u.event.source !=NULL)
{
ParodusPrint("msg->u.event.source is %s\n", msg->u.event.source);
rbusValue_Init(&value);
rbusValue_SetString(value, msg->u.event.source);
rbusObject_SetValue(outParams, "source", value);
rbusValue_Release(value);
}
if(msg->u.event.dest !=NULL)
{
rbusValue_Init(&value);
rbusValue_SetString(value, msg->u.event.dest);
rbusObject_SetValue(outParams, "dest", value);
rbusValue_Release(value);
}
if(msg->u.event.content_type !=NULL)
{
rbusValue_Init(&value);
rbusValue_SetString(value, msg->u.event.content_type);
rbusObject_SetValue(outParams, "content_type", value);
rbusValue_Release(value);
}
rbusValue_Init(&value);
snprintf(qosstring, sizeof(qosstring), "%d", msg->u.event.qos);
ParodusPrint("qosstring is %s\n", qosstring);
rbusValue_SetString(value, qosstring);
rbusObject_SetValue(outParams, "qos", value);
rbusValue_Release(value);
if(msg->u.event.transaction_uuid !=NULL)
{
rbusValue_Init(&value);
rbusValue_SetString(value, msg->u.event.transaction_uuid);
rbusObject_SetValue(outParams, "transaction_uuid", value);
rbusValue_Release(value);
ParodusPrint("outParams msg->u.event.transaction_uuid %s\n", msg->u.event.transaction_uuid);
}
}
if(outParams !=NULL)
{
//rbusObject_fwrite(outParams, 1, stdout);
if(asyncHandle == NULL)
{
ParodusError("asyncHandle is NULL\n");
return;
}
err = rbusMethod_SendAsyncResponse(asyncHandle, error, outParams);
if(err != RBUS_ERROR_SUCCESS)
{
ParodusError("rbusMethod_SendAsyncResponse failed err: %d\n", err);
}
else
{
ParodusInfo("rbusMethod_SendAsyncResponse success: %d\n", err);
}
rbusObject_Release(outParams);
}
else
{
ParodusError("Failed to create outParams\n");
}
return;
}
/*
* @brief This function handles check method call from t2 before the actual inParams SET and to not proceed with inParams processing.
*/
int checkInputParameters(rbusObject_t inParams)
{
rbusValue_t check = rbusObject_GetValue(inParams, "check");
if(check)
{
ParodusPrint("Rbus check method. Not proceeding to process this inparam\n");
return 0;
}
return 1;
}
//To generate unique transaction id for xmidt send requests
char* generate_transaction_uuid()
{
char *transID = NULL;
uuid_t transaction_Id;
char *trans_id = NULL;
trans_id = (char *)malloc(37);
uuid_generate_random(transaction_Id);
uuid_unparse(transaction_Id, trans_id);
if(trans_id !=NULL)
{
transID = trans_id;
}
return transID;
}
void parseRbusInparamsToWrp(rbusObject_t inParams, char *trans_id, wrp_msg_t **eventMsg)
{
char *msg_typeStr = NULL;
char *sourceVal = NULL;
char *destStr = NULL, *contenttypeStr = NULL;
char *payloadStr = NULL, *qosVal = NULL;
unsigned int payloadlength = 0;
wrp_msg_t *msg = NULL;
msg = ( wrp_msg_t * ) malloc( sizeof( wrp_msg_t ) );
if(msg == NULL)
{
ParodusError("Wrp msg allocation failed\n");
return;
}
memset( msg, 0, sizeof( wrp_msg_t ) );
rbusValue_t msg_type = rbusObject_GetValue(inParams, "msg_type");
if(msg_type)
{
if(rbusValue_GetType(msg_type) == RBUS_STRING)
{
msg_typeStr = (char *) rbusValue_GetString(msg_type, NULL);
ParodusPrint("msg_type value received is %s\n", msg_typeStr);
if(msg_typeStr !=NULL)
{
if(strcmp(msg_typeStr, "event") ==0)
{
msg->msg_type = WRP_MSG_TYPE__EVENT;
}
else
{
ParodusError("msg_type received is not event : %s\n", msg_typeStr);
}
}
}
}
else
{
ParodusError("msg_type is empty\n");
}
rbusValue_t source = rbusObject_GetValue(inParams, "source");
if(source)
{
if(rbusValue_GetType(source) == RBUS_STRING)
{
sourceVal = (char *)rbusValue_GetString(source, NULL);
if(sourceVal !=NULL)
{
ParodusInfo("source value received is %s\n", sourceVal);
msg->u.event.source = strdup(sourceVal);
}
ParodusPrint("msg->u.event.source is %s\n", msg->u.event.source);
}
}
else
{
ParodusError("source is empty\n");
}
rbusValue_t dest = rbusObject_GetValue(inParams, "dest");
if(dest)
{
if(rbusValue_GetType(dest) == RBUS_STRING)
{
destStr = (char *)rbusValue_GetString(dest, NULL);
if(destStr !=NULL)
{
ParodusPrint("dest value received is %s\n", destStr);
msg->u.event.dest = strdup(destStr);
ParodusPrint("msg->u.event.dest is %s\n", msg->u.event.dest);
}
}
}
else
{
ParodusError("dest is empty\n");
}
rbusValue_t contenttype = rbusObject_GetValue(inParams, "content_type");
if(contenttype)
{
if(rbusValue_GetType(contenttype) == RBUS_STRING)
{
contenttypeStr = (char *)rbusValue_GetString(contenttype, NULL);
if(contenttypeStr !=NULL)
{
ParodusPrint("contenttype value received is %s\n", contenttypeStr);
msg->u.event.content_type = strdup(contenttypeStr);
ParodusPrint("msg->u.event.content_type is %s\n", msg->u.event.content_type);
}
}
}
else
{
ParodusError("contenttype is empty\n");
}
rbusValue_t payload = rbusObject_GetValue(inParams, "payload");
if(payload)
{
if((rbusValue_GetType(payload) == RBUS_STRING))
{
payloadStr = (char *)rbusValue_GetString(payload, NULL);
if(payloadStr !=NULL)
{
ParodusPrint("payload received is %s\n", payloadStr);
msg->u.event.payload = strdup(payloadStr);
ParodusPrint("msg->u.event.payload is %s\n", msg->u.event.payload);
}
else
{
ParodusError("payloadStr is empty\n");
}
}
}
else
{
ParodusError("payload is empty\n");
}
rbusValue_t payloadlen = rbusObject_GetValue(inParams, "payloadlen");
if(payloadlen)
{
if(rbusValue_GetType(payloadlen) == RBUS_INT32)
{
ParodusPrint("payloadlen type %d RBUS_INT32 %d\n", rbusValue_GetType(payloadlen), RBUS_INT32);
payloadlength = rbusValue_GetInt32(payloadlen);
ParodusPrint("payloadlen received is %lu\n", payloadlength);
msg->u.event.payload_size = (size_t) payloadlength;
ParodusPrint("msg->u.event.payload_size is %lu\n", msg->u.event.payload_size);
}
}
else
{
ParodusError("payloadlen is empty\n");
}
ParodusPrint("check qos\n");
rbusValue_t qos = rbusObject_GetValue(inParams, "qos");
if(qos)
{
if(rbusValue_GetType(qos) == RBUS_STRING)
{
ParodusPrint("qos type %d RBUS_STRING %d\n", rbusValue_GetType(qos), RBUS_STRING);
qosVal = (char *)rbusValue_GetString(qos, NULL);
ParodusPrint("qos received is %s\n", qosVal);
if(qosVal !=NULL)
{
msg->u.event.qos = atoi(qosVal);
ParodusPrint("msg->u.event.qos is %d\n", msg->u.event.qos);
}
}
}
if(trans_id !=NULL)
{
ParodusPrint("Add trans_id %s to wrp message\n", trans_id);
msg->u.event.transaction_uuid = strdup(trans_id);
free(trans_id);
trans_id = NULL;
ParodusPrint("msg->u.event.transaction_uuid is %s\n", msg->u.event.transaction_uuid);
}
else
{
ParodusError("transaction_uuid is empty\n");
}
*eventMsg = msg;
ParodusPrint("parseRbusInparamsToWrp End\n");
}
static rbusError_t sendDataHandler(rbusHandle_t handle, char const* methodName, rbusObject_t inParams, rbusObject_t outParams, rbusMethodAsyncHandle_t asyncHandle)
{
(void) handle;
(void) outParams;
int inStatus = 0;
char *transaction_uuid = NULL;
wrp_msg_t *wrpMsg= NULL;
ParodusInfo("methodHandler called: %s\n", methodName);
//printRBUSParams(inParams, INPARAMS_PATH);
if((methodName !=NULL) && (strcmp(methodName, XMIDT_SEND_METHOD) == 0))
{
inStatus = checkInputParameters(inParams);
if(inStatus)
{
//generate transaction id to create outParams and send ack
transaction_uuid = generate_transaction_uuid();
ParodusInfo("xmidt transaction_uuid generated is %s\n", transaction_uuid);
parseRbusInparamsToWrp(inParams, transaction_uuid, &wrpMsg);
//xmidt send producer
addToXmidtUpstreamQ(wrpMsg, asyncHandle);
ParodusInfo("sendDataHandler returned %d\n", RBUS_ERROR_ASYNC_RESPONSE);
return RBUS_ERROR_ASYNC_RESPONSE;
}
else
{
ParodusPrint("check method call received, ignoring input\n");
}
}
else
{
ParodusError("Method %s received is not supported\n", methodName);
return RBUS_ERROR_BUS_ERROR;
}
ParodusPrint("send RBUS_ERROR_SUCCESS\n");
return RBUS_ERROR_SUCCESS;
}
int regXmidtSendDataMethod()
{
int rc = RBUS_ERROR_SUCCESS;
rbusDataElement_t dataElements[1] = { { XMIDT_SEND_METHOD, RBUS_ELEMENT_TYPE_METHOD, { NULL, NULL, NULL, NULL, NULL, sendDataHandler } } };
rbusHandle_t rbus_handle = get_parodus_rbus_Handle();
ParodusPrint("Registering xmidt sendData method %s\n", XMIDT_SEND_METHOD);
if(!rbus_handle)
{
ParodusError("regXmidtSendDataMethod failed as rbus_handle is empty\n");
return -1;
}
rc = rbus_regDataElements(rbus_handle, 1, dataElements);
if(rc != RBUS_ERROR_SUCCESS)
{
ParodusError("Register xmidt sendData method failed: %d\n", rc);
}
else
{
ParodusInfo("Register xmidt sendData method %s success\n", XMIDT_SEND_METHOD);
//start xmidt queue consumer thread .
processXmidtData();
}
return rc;
}
//To print and store params output to a file
void printRBUSParams(rbusObject_t params, char* file_path)
{
if( NULL != params )
{
FILE *fd = fopen(file_path, "w+");
rbusObject_fwrite(params, 1, fd);
fclose(fd);
}
else
{
ParodusError("Params is NULL\n");
}
}

87
src/xmidtsend_rbus.h Normal file
View File

@@ -0,0 +1,87 @@
/**
* Copyright 2022 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 xmidtsend_rbus.h
*
* @description This header defines functions required to manage xmidt send messages via rbus.
*
*/
#ifndef _XMIDTSEND_RBUS_H_
#define _XMIDTSEND_RBUS_H_
#include <rbus.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"
/*----------------------------------------------------------------------------*/
/* Data Structures */
/*----------------------------------------------------------------------------*/
typedef struct XmidtMsg__
{
wrp_msg_t *msg;
rbusMethodAsyncHandle_t asyncHandle;
struct XmidtMsg__ *next;
} XmidtMsg;
typedef enum
{
DELIVERED_SUCCESS = 0,
INVALID_MSG_TYPE,
MISSING_SOURCE,
MISSING_DEST,
MISSING_CONTENT_TYPE,
MISSING_PAYLOAD,
MISSING_PAYLOADLEN,
INVALID_CONTENT_TYPE,
ENQUEUE_FAILURE = 100,
CLIENT_DISCONNECT = 101,
QUEUE_SIZE_EXCEEDED = 102,
WRP_ENCODE_FAILURE = 103,
MSG_PROCESSING_FAILED = 104
} XMIDT_STATUS;
/*----------------------------------------------------------------------------*/
/* Function Prototypes */
/*----------------------------------------------------------------------------*/
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 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);
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);
#ifdef __cplusplus
}
#endif
#endif /* _XMIDTSEND_RBUS_H_ */

View File

@@ -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 ../src/xmidtsend_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 ../src/xmidtsend_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 ../src/xmidtsend_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 ../src/xmidtsend_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)

View File

@@ -92,7 +92,7 @@ void test_set_parodus_cfg()
CU_ASSERT_STRING_EQUAL(cfg.hw_last_reboot_reason,get_parodus_cfg()->hw_last_reboot_reason);
CU_ASSERT_STRING_EQUAL(cfg.fw_name,get_parodus_cfg()->fw_name);
CU_ASSERT_STRING_EQUAL(cfg.webpa_url, get_parodus_cfg()->webpa_url);
CU_ASSERT_STRING_EQUAL(cfg.webpa_interface_used , get_parodus_cfg()->webpa_interface_used);
CU_ASSERT_STRING_EQUAL(cfg.webpa_interface_used , getWebpaInterface());
CU_ASSERT_STRING_EQUAL(cfg.webpa_protocol, get_parodus_cfg()->webpa_protocol);
CU_ASSERT_EQUAL(cfg.boot_time, get_parodus_cfg()->boot_time);
CU_ASSERT_EQUAL(cfg.webpa_ping_timeout, get_parodus_cfg()->webpa_ping_timeout);
@@ -113,7 +113,7 @@ void test_getWebpaConveyHeader()
CU_ASSERT_STRING_EQUAL(get_parodus_cfg()->hw_manufacturer, cJSON_GetObjectItem(payload, HW_MANUFACTURER)->valuestring);
CU_ASSERT_STRING_EQUAL(get_parodus_cfg()->hw_last_reboot_reason, cJSON_GetObjectItem(payload, HW_LAST_REBOOT_REASON)->valuestring);
CU_ASSERT_STRING_EQUAL(get_parodus_cfg()->fw_name, cJSON_GetObjectItem(payload, FIRMWARE_NAME)->valuestring);
CU_ASSERT_STRING_EQUAL(get_parodus_cfg()->webpa_interface_used, cJSON_GetObjectItem(payload, WEBPA_INTERFACE)->valuestring);
CU_ASSERT_STRING_EQUAL(getWebpaInterface(), cJSON_GetObjectItem(payload, WEBPA_INTERFACE)->valuestring);
CU_ASSERT_STRING_EQUAL(get_parodus_cfg()->webpa_protocol, cJSON_GetObjectItem(payload, WEBPA_PROTOCOL)->valuestring);
CU_ASSERT_EQUAL((int)get_parodus_cfg()->boot_time, cJSON_GetObjectItem(payload, BOOT_TIME)->valueint);

View File

@@ -103,7 +103,7 @@ void test_setParodusConfig()
assert_string_equal(cfg.hw_last_reboot_reason, temp->hw_last_reboot_reason);
assert_string_equal(cfg.webpa_path_url, temp->webpa_path_url);
assert_string_equal(cfg.webpa_url, temp->webpa_url);
assert_string_equal(cfg.webpa_interface_used, temp->webpa_interface_used);
assert_string_equal(cfg.webpa_interface_used, getWebpaInterface());
assert_string_equal(cfg.webpa_protocol, temp->webpa_protocol);
assert_string_equal(cfg.webpa_uuid, temp->webpa_uuid);
assert_string_equal(cfg.partner_id, temp->partner_id);
@@ -208,13 +208,11 @@ void test_parseCommandLine()
ParodusCfg parodusCfg;
memset(&parodusCfg,0,sizeof(parodusCfg));
#ifdef FEATURE_DNS_QUERY
write_key_to_file ("../../tests/jwt_key.tst", jwt_key);
#endif
create_token_script("/tmp/token.sh");
assert_int_equal (parseCommandLine(argc,command,&parodusCfg), 0);
assert_string_equal( parodusCfg.hw_model, "TG1682");
assert_string_equal( parodusCfg.hw_serial_number, "Fer23u948590");
assert_string_equal( parodusCfg.hw_manufacturer, "ARRISGroup,Inc.");

View File

@@ -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 */
/*----------------------------------------------------------------------------*/
@@ -103,6 +103,11 @@ void set_global_shutdown_reason(char *reason)
UNUSED(reason);
}
int getDeviceId(char **device_id, size_t *device_id_len)
{
UNUSED(device_id); UNUSED(device_id_len);
return 0;
}
void start_conn_in_progress (unsigned long start_time)
{
UNUSED(start_time);
@@ -172,6 +177,18 @@ int serviceAliveTask()
return 0;
}
int validate_partner_id(wrp_msg_t *msg, partners_t **partnerIds)
{
UNUSED(msg); UNUSED(partnerIds);
return 0;
}
int sendUpstreamMsgToServer(void **resp_bytes, size_t resp_size)
{
UNUSED(resp_bytes); UNUSED(resp_size);
return 0;
}
int nopoll_loop_wait(noPollCtx * ctx,long timeout)
{
UNUSED(ctx); UNUSED(timeout);
@@ -335,6 +352,7 @@ void test_createSocketConnection()
void test_createSocketConnection1()
{
numLoops =0;
noPollCtx *ctx;
ParodusCfg cfg;
memset(&cfg,0, sizeof(ParodusCfg));
@@ -364,11 +382,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 +404,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 +439,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 +476,7 @@ void err_createSocketConnection()
void test_createSocketConnection_cloud_disconn()
{
numLoops =0;
ParodusCfg cfg;
memset(&cfg,0,sizeof(ParodusCfg));
cfg.cloud_disconnect = strdup("XPC");

View File

@@ -341,7 +341,7 @@ void test_createConnection()
int ret = createNopollConnection(ctx);
assert_int_equal(ret, nopoll_true);
assert_string_equal(get_parodus_cfg()->cloud_status, CLOUD_STATUS_ONLINE);
assert_string_equal(get_cloud_status(), CLOUD_STATUS_ONLINE);
free(cfg);
if (g_jwt_server_ip !=NULL)
{

View File

@@ -125,6 +125,10 @@ int processCrudRequest(wrp_msg_t *reqMsg, wrp_msg_t **responseMsg )
return (int)mock();
}
char* getWebpaInterface(void)
{
return NULL;
}
/*----------------------------------------------------------------------------*/
/* Tests */
/*----------------------------------------------------------------------------*/

View File

@@ -1530,7 +1530,7 @@ void test_retrieveObject_cloud_status()
ret = retrieveObject(reqMsg, &respMsg);
assert_int_equal (respMsg->u.crud.status, 200);
assert_int_equal (ret, 0);
assert_string_equal(get_parodus_cfg()->cloud_status, CLOUD_STATUS_ONLINE);
assert_string_equal(get_cloud_status(), CLOUD_STATUS_ONLINE);
assert_int_equal (respMsg->u.crud.payload_size, 25);
fp = fopen(cfg.crud_config_file, "r");

View File

@@ -131,6 +131,11 @@ bool get_interface_down_event()
return false;
}
char *get_cloud_status(void)
{
return NULL;
}
/*----------------------------------------------------------------------------*/
/* Tests */
/*----------------------------------------------------------------------------*/

View File

@@ -44,10 +44,12 @@ extern size_t metaPackSize;
extern UpStreamMsg *UpStreamMsgQ;
int numLoops = 1;
int deviceIDNull =0;
char webpa_interface[64]={'\0'};
wrp_msg_t *temp = NULL;
extern pthread_mutex_t nano_mut;
extern pthread_cond_t nano_con;
static int crud_test = 0;
pthread_mutex_t config_mut=PTHREAD_MUTEX_INITIALIZER;
/*----------------------------------------------------------------------------*/
/* Mocks */
/*----------------------------------------------------------------------------*/
@@ -116,6 +118,27 @@ ParodusCfg *get_parodus_cfg(void)
return &parodusCfg;
}
char *getWebpaInterface(void)
{
ParodusCfg cfg;
memset(&cfg,0,sizeof(cfg));
#ifdef WAN_FAILOVER_SUPPORTED
parStrncpy(cfg.webpa_interface_used , "wl0", sizeof(cfg.webpa_interface_used));
#else
parStrncpy(cfg.webpa_interface_used , "eth0", sizeof(cfg.webpa_interface_used));
#endif
set_parodus_cfg(&cfg);
#ifdef WAN_FAILOVER_SUPPORTED
ParodusPrint("WAN_FAILOVER_SUPPORTED mode \n");
pthread_mutex_lock (&config_mut);
parStrncpy(webpa_interface, get_parodus_cfg()->webpa_interface_used, sizeof(webpa_interface));
pthread_mutex_unlock (&config_mut);
#else
parStrncpy(webpa_interface, get_parodus_cfg()->webpa_interface_used, sizeof(webpa_interface));
#endif
return webpa_interface;
}
ssize_t wrp_pack_metadata( const data_t *packData, void **data )
{
(void) packData; (void) data;

View File

@@ -46,10 +46,11 @@ extern size_t metaPackSize;
extern UpStreamMsg *UpStreamMsgQ;
int numLoops = 1;
int deviceIDNull =0;
char webpa_interface[64]={'\0'};
wrp_msg_t *reg_msg = NULL;
extern pthread_mutex_t nano_mut;
extern pthread_cond_t nano_con;
pthread_mutex_t config_mut=PTHREAD_MUTEX_INITIALIZER;
/*----------------------------------------------------------------------------*/
/* Mocks */
/*----------------------------------------------------------------------------*/
@@ -101,6 +102,27 @@ ParodusCfg *get_parodus_cfg(void)
return &parodusCfg;
}
char *getWebpaInterface(void)
{
ParodusCfg cfg;
memset(&cfg,0,sizeof(cfg));
#ifdef WAN_FAILOVER_SUPPORTED
parStrncpy(cfg.webpa_interface_used , "wl0", sizeof(cfg.webpa_interface_used));
#else
parStrncpy(cfg.webpa_interface_used , "eth0", sizeof(cfg.webpa_interface_used));
#endif
set_parodus_cfg(&cfg);
#ifdef WAN_FAILOVER_SUPPORTED
ParodusPrint("WAN_FAILOVER_SUPPORTED mode \n");
pthread_mutex_lock (&config_mut);
parStrncpy(webpa_interface, get_parodus_cfg()->webpa_interface_used, sizeof(webpa_interface));
pthread_mutex_unlock (&config_mut);
#else
parStrncpy(webpa_interface, get_parodus_cfg()->webpa_interface_used, sizeof(webpa_interface));
#endif
return webpa_interface;
}
/*-------------------------------------------
int nn_connect (int s, const char *addr)
{