Skip to content

Commit

Permalink
Merge pull request #165 from suvi-123/wan_restore_update_2
Browse files Browse the repository at this point in the history
Webconfig to resync with cloud on wan restore
  • Loading branch information
sadhyama authored Jul 13, 2023
2 parents e2f2851 + 0d2631a commit eb455fc
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 9 deletions.
13 changes: 11 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ if (WEBCONFIG_BIN_SUPPORT)
add_definitions(-DWEBCONFIG_BIN_SUPPORT)
endif (WEBCONFIG_BIN_SUPPORT)

if (WAN_FAILOVER_SUPPORTED)
add_definitions(-DWAN_FAILOVER_SUPPORTED)
endif (WAN_FAILOVER_SUPPORTED)

if (FEATURE_SUPPORT_AKER)
add_definitions(-DFEATURE_SUPPORT_AKER)
endif (FEATURE_SUPPORT_AKER)
Expand All @@ -28,9 +32,14 @@ else()
message(STATUS "WEBCONFIG_BIN_SUPPORT is not supported")
endif (WEBCONFIG_BIN_SUPPORT)

if (WAN_FAILOVER_SUPPORTED)
message(STATUS "WAN_FAILOVER_SUPPORTED is supported")
else()
message(STATUS "WAN_FAILOVER_SUPPORTED is not supported")
endif (WAN_FAILOVER_SUPPORTED)

set(HEADERS webcfg.h webcfg_param.h webcfg_pack.h webcfg_multipart.h webcfg_auth.h webcfg_notify.h webcfg_generic.h webcfg_db.h webcfg_log.h webcfg_blob.h webcfg_event.h webcfg_metadata.h webcfg_timer.h webcfg_privilege.h)
set(SOURCES webcfg_helpers.c webcfg.c webcfg_param.c webcfg_pack.c webcfg_multipart.c webcfg_auth.c webcfg_notify.c webcfg_db.c webcfg_blob.c webcfg_event.c webcfg_metadata.c webcfg_timer.c webcfg_privilege.c)
set(HEADERS webcfg.h webcfg_param.h webcfg_pack.h webcfg_multipart.h webcfg_auth.h webcfg_notify.h webcfg_generic.h webcfg_db.h webcfg_log.h webcfg_blob.h webcfg_event.h webcfg_metadata.h webcfg_timer.h webcfg_privilege.h webcfg_wanhandle.h)
set(SOURCES webcfg_helpers.c webcfg.c webcfg_param.c webcfg_pack.c webcfg_multipart.c webcfg_auth.c webcfg_notify.c webcfg_db.c webcfg_blob.c webcfg_event.c webcfg_metadata.c webcfg_timer.c webcfg_privilege.c webcfg_wanhandle.c)

if (FEATURE_SUPPORT_AKER)
set(HEADERS ${HEADERS} webcfg_aker.h)
Expand Down
3 changes: 3 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "webcfg_log.h"
#include "webcfg_generic.h"
#include "webcfg_rbus.h"
#include "webcfg_wanhandle.h"
#include "webcfg_privilege.h"
#include <unistd.h>
#include <pthread.h>
Expand Down Expand Up @@ -97,6 +98,8 @@ int main()
snprintf(systemReadyTime, sizeof(systemReadyTime),"%d", (int)cTime.tv_sec);
WebcfgInfo("systemReadyTime is %s\n", systemReadyTime);
set_global_systemReadyTime(systemReadyTime);
WebcfgInfo("Registering WanEventHandler sysevents\n");
WanEventHandler();
// wait for upstream subscriber for 5mins
waitForUpstreamEventSubscribe(300);
ret = rbus_GetValueFromDB( PARAM_RFC_ENABLE, &strValue );
Expand Down
1 change: 0 additions & 1 deletion src/webcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "webcfg_event.h"
#include "webcfg_blob.h"
#include "webcfg_timer.h"

#ifdef FEATURE_SUPPORT_AKER
#include "webcfg_aker.h"
#endif
Expand Down
16 changes: 12 additions & 4 deletions src/webcfg_rbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -2092,7 +2092,16 @@ static void eventReceiveHandler(
}
if(newValue !=NULL && oldValue!=NULL && get_global_interface()!=NULL) {
WebcfgInfo("New Value: %s Old Value: %s New Interface Value: %s\n", rbusValue_GetString(newValue, NULL), rbusValue_GetString(oldValue, NULL), get_global_interface());
}
if(get_webcfgReady())
{
WebcfgInfo("Trigger force sync with cloud on wan restore event\n");
trigger_webcfg_forcedsync();
}
else
{
WebcfgInfo("wan restore force sync is skipped as webcfg is not ready\n");
}
}
}

static void subscribeAsyncHandler(
Expand Down Expand Up @@ -2122,15 +2131,14 @@ int subscribeTo_CurrentActiveInterface_Event()
WebcfgError("%s subscribe failed : %d - %s\n", WEBCFG_INTERFACE_PARAM, rc, rbusError_ToString(rc));
}
return rc;
}
}
#endif

/*Trigger force sync with cloud from webconfig client.*/
void trigger_webcfg_forcedsync()
{
char *str = NULL;
int status = 0;

int status = 0;
str = strdup("root");
//webcfg_forcedsync_needed is set initially whenever force sync set is detected, but this does not guarantee the force sync to happen immediately when previous sync is in progress, cloud sync will be retried once previous sync is completed.
set_global_webcfg_forcedsync_needed(1);
Expand Down
23 changes: 23 additions & 0 deletions src/webcfg_wanhandle.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2023 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.
*/

/* This is a stub file that will be overridden in a patch */

#include "webcfg_wanhandle.h"

void WanEventHandler()
{
}
18 changes: 18 additions & 0 deletions src/webcfg_wanhandle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright 2023 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.
*/

void WanEventHandler();
#define LOGGING_INTERVAL_SECS ( 60 * 60 )
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ target_link_libraries (test_multipart_unittest gcov -Wl,--no-as-needed )
#-------------------------------------------------------------------------------
if (WEBCONFIG_BIN_SUPPORT)
add_test(NAME test_rbus_fr COMMAND ${MEMORY_CHECK} ./test_rbus_fr)
add_executable(test_rbus_fr test_rbus_fr.c ../src/webcfg_rbus.c )
add_executable(test_rbus_fr test_rbus_fr.c ../src/webcfg_rbus.c ../src/webcfg_wanhandle.c)
target_link_libraries (test_rbus_fr -lcunit -lwrp-c -lcimplog -lmsgpackc -lcurl -lpthread -lm -luuid -ltrower-base64 -lwdmp-c -lcjson -lrbus)

target_link_libraries (test_rbus_fr gcov -Wl,--no-as-needed )
Expand Down
1 change: 0 additions & 1 deletion tests/test_rbus_fr.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ int get_global_supplementarySync()
return 0;
}


int Get_Supplementary_URL( char *name, char *pString)
{
UNUSED(name);
Expand Down

0 comments on commit eb455fc

Please sign in to comment.