diff --git a/docs/api/uci/cwmp.md b/docs/api/uci/cwmp.md
index 12a3425..a496da9 100644
--- a/docs/api/uci/cwmp.md
+++ b/docs/api/uci/cwmp.md
@@ -951,7 +951,7 @@
|
- fw_upgrade_keep_settings
+ KeepConfig
|
boolean
@@ -963,7 +963,41 @@
1
|
- If set to **1**, icwmp will keep the uci setting while doing firmware upgrade using Download RPC with '1 Firmware Upgrade Image'.
+ This values passes to opconf for handling config, check opconf documentation
+ |
+
+
+ |
+ KeepOpConf
+ |
+
+ boolean
+ |
+
+ no
+ |
+
+ 1
+ |
+
+ This values passes to opconf for handling config, check opconf documentation
+ |
+
+
+ |
+ ConfigScope
+ |
+
+ string
+ |
+
+ no
+ |
+
+
+ |
+
+ This values passes to opconf for handling config, check opconf documentation
|
@@ -1093,4 +1127,4 @@
-
\ No newline at end of file
+
diff --git a/schemas/uci/cwmp.json b/schemas/uci/cwmp.json
index 24c4dfc..882d066 100644
--- a/schemas/uci/cwmp.json
+++ b/schemas/uci/cwmp.json
@@ -370,11 +370,25 @@
"description": "If set to 1, it forces the connectivity over v4 IP address."
},
{
- "name": "fw_upgrade_keep_settings",
+ "name": "KeepConfig",
"type": "boolean",
"required": "no",
"default": "1",
- "description": "If set to **1**, icwmp will keep the uci setting while doing firmware upgrade using Download RPC with '1 Firmware Upgrade Image'."
+ "description": "This values passes to opconf for handling config, check opconf documentation"
+ },
+ {
+ "name": "KeepOpConf",
+ "type": "boolean",
+ "required": "no",
+ "default": "1",
+ "description": "This values passes to opconf for handling config, check opconf documentation"
+ },
+ {
+ "name": "ConfigScope",
+ "type": "string",
+ "required": "no",
+ "default": "",
+ "description": "This values passes to opconf for handling config, check opconf documentation"
},
{
"name": "disable_datatype_check",
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index bedcb0f..38440bf 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -4,6 +4,7 @@ PROJECT(icwmpd)
ADD_DEFINITIONS(-Wall -Werror -Wformat -g)
ADD_DEFINITIONS(-D_GNU_SOURCE)
+ADD_DEFINITIONS(-DBBF_VENDOR_PREFIX="${BBF_VENDOR_PREFIX}")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${PROJECT_SOURCE_DIR}")
diff --git a/src/common.h b/src/common.h
index a05efd6..723125b 100644
--- a/src/common.h
+++ b/src/common.h
@@ -150,13 +150,15 @@ typedef struct config {
int cr_timeout;
int clock_sync_timeout;
bool force_ipv4;
- bool fw_upgrade_keep_settings;
+ int cpe_keep_config;
+ int cpe_keep_opconf;
bool cpe_disable_datatype_check;
bool lwn_enable;
int lwn_port;
char lwn_hostname[BUF_SIZE_256];
+ char cpe_config_scope[BUF_SIZE_32];
char acs_url[BUF_SIZE_2048];
char acs_userid[BUF_SIZE_256];
char acs_passwd[BUF_SIZE_256];
diff --git a/src/download.c b/src/download.c
index f0f5538..c80f919 100644
--- a/src/download.c
+++ b/src/download.c
@@ -301,27 +301,6 @@ void ubus_get_bank_status_callback(struct ubus_request *req, int type __attribut
bank->status = 0;
}
-/*
- * Apply the new firmware
- */
-int cwmp_apply_firmware()
-{
- int e;
- struct blob_buf b = { 0 };
- CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
- blob_buf_init(&b, 0);
- blobmsg_add_u8(&b, "keep", cwmp_ctx.conf.fw_upgrade_keep_settings);
-
- CWMP_LOG(INFO, "Apply downloaded image ...");
- e = icwmp_ubus_invoke("rpc-sys", "upgrade_start", b.head, NULL, NULL);
- if (e != 0) {
- CWMP_LOG(INFO, "rpc-sys upgrade_start ubus method failed: Ubus err code: %d", e);
- }
-
- blob_buf_free(&b);
- return e;
-}
-
/*
* Apply the web content
*/
@@ -463,11 +442,14 @@ void fw_upgrade_callback(struct ubus_request *req, int type __attribute__((unuse
}
}
-int cwmp_apply_multiple_firmware()
+static int cwmp_apply_multiple_firmware(bool auto_activate)
{
char *fault_code = NULL;
int e;
+ struct blob_buf b = { 0 };
int bank_id = get_available_bank_id();
+ char buffer[32] = {0};
+
if (bank_id <= 0)
return -1;
@@ -475,17 +457,32 @@ int cwmp_apply_multiple_firmware()
snprintf(path, sizeof(path), "Device.DeviceInfo.FirmwareImage.%d.Download()", bank_id);
snprintf(url, sizeof(url), "file://%s", FIRMWARE_UPGRADE_IMAGE);
- struct blob_buf b = { 0 };
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
blob_buf_init(&b, 0);
+
bb_add_string(&b, "path", path);
void *tbl = blobmsg_open_table(&b, "input");
bb_add_string(&b, "URL", url);
+ blobmsg_add_u8(&b, "AutoActivate", auto_activate);
+
+ if (cwmp_ctx.conf.cpe_keep_config != -1) {
+ snprintf(buffer, sizeof(buffer), "%s%s", BBF_VENDOR_PREFIX, "KeepConfig");
+ blobmsg_add_u8(&b, buffer, cwmp_ctx.conf.cpe_keep_config);
+ }
+
+ if (cwmp_ctx.conf.cpe_keep_opconf != -1) {
+ snprintf(buffer, sizeof(buffer), "%s%s", BBF_VENDOR_PREFIX, "KeepOpConf");
+ blobmsg_add_u8(&b, buffer, cwmp_ctx.conf.cpe_keep_opconf);
+ }
+
+ if (strlen(cwmp_ctx.conf.cpe_config_scope) != 0) {
+ snprintf(buffer, sizeof(buffer), "%s%s", BBF_VENDOR_PREFIX, "ConfigScope");
+ bb_add_string(&b, buffer, cwmp_ctx.conf.cpe_config_scope);
+ }
+
blobmsg_close_table(&b, tbl);
e = icwmp_ubus_invoke_timeout(BBFDM_OBJECT_NAME, "operate", b.head, fw_upgrade_callback, &fault_code, 120000);
- blob_buf_free(&b);
-
if (e != 0 || CWMP_STRLEN(fault_code) != 0) {
CWMP_LOG(INFO, "fwbank upgrade ubus method failed: Ubus err code: %d, fault code: %s", e, fault_code ? fault_code : "");
FREE(fault_code);
@@ -494,6 +491,7 @@ int cwmp_apply_multiple_firmware()
//set /var/state 'switch_bank' option
set_uci_path_value(VARSTATE_CONFIG, "icwmp.cpe.switch_bank", "1");
+ blob_buf_free(&b);
return CWMP_OK;
}
@@ -644,11 +642,12 @@ int apply_downloaded_file(struct download *pdownload, char *download_file_name,
bkp_session_save();
if (CWMP_STRCMP(pdownload->file_type, FIRMWARE_UPGRADE_IMAGE_FILE_TYPE) == 0) {
set_uci_path_value(NULL, "cwmp.cpe.exec_download", "1");
- if (cwmp_apply_firmware() != 0) {
+ if (cwmp_apply_multiple_firmware(true) != 0) {
error = FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED;
snprintf(err_msg, sizeof(err_msg), "Failed in applying the downloaded firmware image, may be corrupted file");
}
+ cwmp_reboot("FirmwareUpgrade");
if (error == FAULT_CPE_NO_FAULT) {
sleep(70);
error = FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED;
@@ -711,7 +710,7 @@ int apply_downloaded_file(struct download *pdownload, char *download_file_name,
error = FAULT_CPE_NO_FAULT;
} else if (CWMP_STRCMP(pdownload->file_type, STORED_FIRMWARE_IMAGE_FILE_TYPE) == 0) {
- int err = cwmp_apply_multiple_firmware();
+ int err = cwmp_apply_multiple_firmware(false);
if (err == CWMP_OK)
error = FAULT_CPE_NO_FAULT;
else {
diff --git a/src/rpc.c b/src/rpc.c
index b97b011..9da870b 100755
--- a/src/rpc.c
+++ b/src/rpc.c
@@ -41,7 +41,6 @@ static int cwmp_handle_rpc_cpe_reboot(struct rpc *rpc);
static int cwmp_handle_rpc_cpe_download(struct rpc *rpc);
static int cwmp_handle_rpc_cpe_upload(struct rpc *rpc);
static int cwmp_handle_rpc_cpe_factory_reset(struct rpc *rpc);
-static int cwmp_handle_rpc_cpe_x_factory_reset_soft(struct rpc *rpc);
static int cancel_transfer(char *key);
static int cwmp_handle_rpc_cpe_cancel_transfer(struct rpc *rpc);
static int cwmp_handle_rpc_cpe_schedule_inform(struct rpc *rpc);
@@ -79,7 +78,6 @@ const struct rpc_cpe_method rpc_cpe_methods[] = {
#ifdef ICWMP_ENABLE_SMM_SUPPORT
[RPC_CPE_CHANGE_DU_STATE] = { "ChangeDUState", cwmp_handle_rpc_cpe_change_du_state, AMD_3 },
#endif
- [RPC_CPE_X_FACTORY_RESET_SOFT] = { "X_FactoryResetSoft", cwmp_handle_rpc_cpe_x_factory_reset_soft, AMD_1 },
[RPC_CPE_FAULT] = { "Fault", cwmp_handle_rpc_cpe_fault, AMD_1 }
};
@@ -1566,31 +1564,6 @@ error:
return -1;
}
-/*
- * [RPC CPE]: X_FactoryResetSoft
- */
-int cwmp_handle_rpc_cpe_x_factory_reset_soft(struct rpc *rpc)
-{
- mxml_node_t *b;
-
- b = build_top_body_soap_response(cwmp_ctx.session->tree_out, "X_FactoryResetSoft");
-
- if (!b)
- goto fault;
-
- cwmp_set_end_session(END_SESSION_X_FACTORY_RESET_SOFT);
-
- return 0;
-
-fault:
- if (cwmp_create_fault_message(rpc, FAULT_CPE_INTERNAL_ERROR, ""))
- goto error;
- return 0;
-
-error:
- return -1;
-}
-
/*
* [RPC CPE]: CancelTransfer
*/
diff --git a/src/session.c b/src/session.c
index 9ed79ba..831551f 100644
--- a/src/session.c
+++ b/src/session.c
@@ -821,12 +821,6 @@ int run_session_end_func(void)
exit(EXIT_SUCCESS);
}
- if (end_session_flag & END_SESSION_X_FACTORY_RESET_SOFT) {
- CWMP_LOG(INFO, "Executing factory reset soft: end session request");
- cwmp_factory_reset();
- exit(EXIT_SUCCESS);
- }
-
// check if any interface reset request exists then take action
intf_reset_node *iter = NULL, *node = NULL;
list_for_each_entry_safe(iter, node, &intf_reset_list, list) {
diff --git a/src/uci_utils.c b/src/uci_utils.c
index dd2c5c0..11f8f9c 100644
--- a/src/uci_utils.c
+++ b/src/uci_utils.c
@@ -275,7 +275,9 @@ static void config_get_cpe_elements(struct uci_section *s)
UCI_CPE_JSON_CUSTOM_NOTIFY_FILE,
UCI_CPE_JSON_FORCED_INFORM_FILE,
UCI_CPE_FORCE_IPV4,
- UCI_CPE_KEEP_SETTINGS,
+ UCI_CPE_KEEP_CONFIG,
+ UCI_CPE_KEEP_OPCONF,
+ UCI_CPE_CONFIG_SCOPE,
UCI_CPE_DEFAULT_WAN_IFACE,
UCI_CPE_INTERFACE,
UCI_CPE_CLOCK_SYNC_TIMEOUT,
@@ -304,7 +306,9 @@ static void config_get_cpe_elements(struct uci_section *s)
[UCI_CPE_JSON_FORCED_INFORM_FILE] = { .name = "forced_inform_json", .type = UCI_TYPE_STRING },
[UCI_CPE_CON_REQ_TIMEOUT] = { .name = "cr_timeout", .type = UCI_TYPE_STRING },
[UCI_CPE_FORCE_IPV4] = { .name = "force_ipv4", .type = UCI_TYPE_STRING },
- [UCI_CPE_KEEP_SETTINGS] = { .name = "fw_upgrade_keep_settings", .type = UCI_TYPE_STRING },
+ [UCI_CPE_KEEP_CONFIG] = { .name = "KeepConfig", .type = UCI_TYPE_STRING },
+ [UCI_CPE_CONFIG_SCOPE] = { .name = "ConfigScope", .type = UCI_TYPE_STRING },
+ [UCI_CPE_KEEP_OPCONF] = { .name = "KeepOpConf", .type = UCI_TYPE_STRING },
[UCI_CPE_DEFAULT_WAN_IFACE] = { .name = "default_wan_interface", .type = UCI_TYPE_STRING },
[UCI_CPE_INTERFACE] = { .name = "interface", .type = UCI_TYPE_STRING },
[UCI_CPE_CLOCK_SYNC_TIMEOUT] = { .name = "clock_sync_timeout", .type = UCI_TYPE_STRING },
@@ -426,8 +430,16 @@ static void config_get_cpe_elements(struct uci_section *s)
cwmp_ctx.conf.force_ipv4 = str_to_bool(get_value_from_uci_option(cpe_tb[UCI_CPE_FORCE_IPV4]));
CWMP_LOG(DEBUG, "CWMP CONFIG - cpe force ipv4 enable: %d", cwmp_ctx.conf.force_ipv4);
- cwmp_ctx.conf.fw_upgrade_keep_settings = cpe_tb[UCI_CPE_KEEP_SETTINGS] ? str_to_bool(get_value_from_uci_option(cpe_tb[UCI_CPE_KEEP_SETTINGS])) : true;
- CWMP_LOG(DEBUG, "CWMP CONFIG - cpe keep settings enable: %d", cwmp_ctx.conf.fw_upgrade_keep_settings);
+ cwmp_ctx.conf.cpe_keep_config = cpe_tb[UCI_CPE_KEEP_CONFIG] ? str_to_bool(get_value_from_uci_option(cpe_tb[UCI_CPE_KEEP_CONFIG])) : -1;
+ CWMP_LOG(DEBUG, "CWMP CONFIG - cpe keep config enable: %d", cwmp_ctx.conf.cpe_keep_config);
+
+ cwmp_ctx.conf.cpe_keep_opconf = cpe_tb[UCI_CPE_KEEP_OPCONF] ? str_to_bool(get_value_from_uci_option(cpe_tb[UCI_CPE_KEEP_OPCONF])) : -1;
+ CWMP_LOG(DEBUG, "CWMP CONFIG - cpe keep opconf enable: %d", cwmp_ctx.conf.cpe_keep_opconf);
+
+ if (cpe_tb[UCI_CPE_CONFIG_SCOPE]) {
+ snprintf(cwmp_ctx.conf.cpe_config_scope, sizeof(cwmp_ctx.conf.cpe_config_scope), "%s", get_value_from_uci_option(cpe_tb[UCI_CPE_CONFIG_SCOPE]));
+ }
+ CWMP_LOG(DEBUG, "CWMP CONFIG - cpe keep config scope: %s", cwmp_ctx.conf.cpe_config_scope);
char *value = get_value_from_uci_option(cpe_tb[UCI_CPE_INTERFACE]);
if ((CWMP_STRLEN(cwmp_ctx.net.interface) == 0) && (CWMP_STRLEN(value) != 0)) {
diff --git a/test/files/etc/config/cwmp b/test/files/etc/config/cwmp
index 9e2646b..9837483 100644
--- a/test/files/etc/config/cwmp
+++ b/test/files/etc/config/cwmp
@@ -37,7 +37,7 @@ config cpe 'cpe'
option exec_download '0'
option periodic_notify_enable '1'
option periodic_notify_interval '10'
- option fw_upgrade_keep_settings '1'
+ option KeepConfig '1'
option path 'tr69'
config lwn 'lwn'