Skip to content

Commit eb455fc

Browse files
authored
Merge pull request #165 from suvi-123/wan_restore_update_2
Webconfig to resync with cloud on wan restore
2 parents e2f2851 + 0d2631a commit eb455fc

File tree

8 files changed

+68
-9
lines changed

8 files changed

+68
-9
lines changed

src/CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ if (WEBCONFIG_BIN_SUPPORT)
1818
add_definitions(-DWEBCONFIG_BIN_SUPPORT)
1919
endif (WEBCONFIG_BIN_SUPPORT)
2020

21+
if (WAN_FAILOVER_SUPPORTED)
22+
add_definitions(-DWAN_FAILOVER_SUPPORTED)
23+
endif (WAN_FAILOVER_SUPPORTED)
24+
2125
if (FEATURE_SUPPORT_AKER)
2226
add_definitions(-DFEATURE_SUPPORT_AKER)
2327
endif (FEATURE_SUPPORT_AKER)
@@ -28,9 +32,14 @@ else()
2832
message(STATUS "WEBCONFIG_BIN_SUPPORT is not supported")
2933
endif (WEBCONFIG_BIN_SUPPORT)
3034

35+
if (WAN_FAILOVER_SUPPORTED)
36+
message(STATUS "WAN_FAILOVER_SUPPORTED is supported")
37+
else()
38+
message(STATUS "WAN_FAILOVER_SUPPORTED is not supported")
39+
endif (WAN_FAILOVER_SUPPORTED)
3140

32-
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)
33-
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)
41+
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)
42+
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)
3443

3544
if (FEATURE_SUPPORT_AKER)
3645
set(HEADERS ${HEADERS} webcfg_aker.h)

src/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "webcfg_log.h"
2929
#include "webcfg_generic.h"
3030
#include "webcfg_rbus.h"
31+
#include "webcfg_wanhandle.h"
3132
#include "webcfg_privilege.h"
3233
#include <unistd.h>
3334
#include <pthread.h>
@@ -97,6 +98,8 @@ int main()
9798
snprintf(systemReadyTime, sizeof(systemReadyTime),"%d", (int)cTime.tv_sec);
9899
WebcfgInfo("systemReadyTime is %s\n", systemReadyTime);
99100
set_global_systemReadyTime(systemReadyTime);
101+
WebcfgInfo("Registering WanEventHandler sysevents\n");
102+
WanEventHandler();
100103
// wait for upstream subscriber for 5mins
101104
waitForUpstreamEventSubscribe(300);
102105
ret = rbus_GetValueFromDB( PARAM_RFC_ENABLE, &strValue );

src/webcfg.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include "webcfg_event.h"
3535
#include "webcfg_blob.h"
3636
#include "webcfg_timer.h"
37-
3837
#ifdef FEATURE_SUPPORT_AKER
3938
#include "webcfg_aker.h"
4039
#endif

src/webcfg_rbus.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,7 +2092,16 @@ static void eventReceiveHandler(
20922092
}
20932093
if(newValue !=NULL && oldValue!=NULL && get_global_interface()!=NULL) {
20942094
WebcfgInfo("New Value: %s Old Value: %s New Interface Value: %s\n", rbusValue_GetString(newValue, NULL), rbusValue_GetString(oldValue, NULL), get_global_interface());
2095-
}
2095+
if(get_webcfgReady())
2096+
{
2097+
WebcfgInfo("Trigger force sync with cloud on wan restore event\n");
2098+
trigger_webcfg_forcedsync();
2099+
}
2100+
else
2101+
{
2102+
WebcfgInfo("wan restore force sync is skipped as webcfg is not ready\n");
2103+
}
2104+
}
20962105
}
20972106

20982107
static void subscribeAsyncHandler(
@@ -2122,15 +2131,14 @@ int subscribeTo_CurrentActiveInterface_Event()
21222131
WebcfgError("%s subscribe failed : %d - %s\n", WEBCFG_INTERFACE_PARAM, rc, rbusError_ToString(rc));
21232132
}
21242133
return rc;
2125-
}
2134+
}
21262135
#endif
21272136

21282137
/*Trigger force sync with cloud from webconfig client.*/
21292138
void trigger_webcfg_forcedsync()
21302139
{
21312140
char *str = NULL;
2132-
int status = 0;
2133-
2141+
int status = 0;
21342142
str = strdup("root");
21352143
//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.
21362144
set_global_webcfg_forcedsync_needed(1);

src/webcfg_wanhandle.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2023 Comcast Cable Communications Management, LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/* This is a stub file that will be overridden in a patch */
18+
19+
#include "webcfg_wanhandle.h"
20+
21+
void WanEventHandler()
22+
{
23+
}

src/webcfg_wanhandle.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright 2023 Comcast Cable Communications Management, LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
void WanEventHandler();
18+
#define LOGGING_INTERVAL_SECS ( 60 * 60 )

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ target_link_libraries (test_multipart_unittest gcov -Wl,--no-as-needed )
253253
#-------------------------------------------------------------------------------
254254
if (WEBCONFIG_BIN_SUPPORT)
255255
add_test(NAME test_rbus_fr COMMAND ${MEMORY_CHECK} ./test_rbus_fr)
256-
add_executable(test_rbus_fr test_rbus_fr.c ../src/webcfg_rbus.c )
256+
add_executable(test_rbus_fr test_rbus_fr.c ../src/webcfg_rbus.c ../src/webcfg_wanhandle.c)
257257
target_link_libraries (test_rbus_fr -lcunit -lwrp-c -lcimplog -lmsgpackc -lcurl -lpthread -lm -luuid -ltrower-base64 -lwdmp-c -lcjson -lrbus)
258258

259259
target_link_libraries (test_rbus_fr gcov -Wl,--no-as-needed )

tests/test_rbus_fr.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ int get_global_supplementarySync()
7373
return 0;
7474
}
7575

76-
7776
int Get_Supplementary_URL( char *name, char *pString)
7877
{
7978
UNUSED(name);

0 commit comments

Comments
 (0)