Multiple updates

This commit is contained in:
Vivek Dutta 2025-11-04 21:24:58 +05:30 committed by IOPSYS Dev
parent ca5227149c
commit c73d9fa100
No known key found for this signature in database
9 changed files with 100 additions and 71 deletions

View file

@ -951,7 +951,7 @@
</tr> </tr>
<tr> <tr>
<td class="td_row_odd"> <td class="td_row_odd">
<div class="td_row_odd">fw_upgrade_keep_settings</div> <div class="td_row_odd">KeepConfig</div>
</td> </td>
<td class="td_row_odd"> <td class="td_row_odd">
<div class="td_row_odd">boolean</div> <div class="td_row_odd">boolean</div>
@ -963,7 +963,41 @@
<div class="td_row_odd">1</div> <div class="td_row_odd">1</div>
</td> </td>
<td class="td_row_odd"> <td class="td_row_odd">
<div class="td_row_odd">If set to **1**, icwmp will keep the uci setting while doing firmware upgrade using Download RPC with '1 Firmware Upgrade Image'.</div> <div class="td_row_odd">This values passes to opconf for handling config, check opconf documentation</div>
</td>
</tr>
<tr>
<td class="td_row_even">
<div class="td_row_even">KeepOpConf</div>
</td>
<td class="td_row_even">
<div class="td_row_even">boolean</div>
</td>
<td class="td_row_even">
<div class="td_row_even">no</div>
</td>
<td class="td_row_even">
<div class="td_row_even">1</div>
</td>
<td class="td_row_even">
<div class="td_row_even">This values passes to opconf for handling config, check opconf documentation</div>
</td>
</tr>
<tr>
<td class="td_row_odd">
<div class="td_row_odd">ConfigScope</div>
</td>
<td class="td_row_odd">
<div class="td_row_odd">string</div>
</td>
<td class="td_row_odd">
<div class="td_row_odd">no</div>
</td>
<td class="td_row_odd">
<div class="td_row_odd"></div>
</td>
<td class="td_row_odd">
<div class="td_row_odd">This values passes to opconf for handling config, check opconf documentation</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -1093,4 +1127,4 @@
</table> </table>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View file

@ -370,11 +370,25 @@
"description": "If set to 1, it forces the connectivity over v4 IP address." "description": "If set to 1, it forces the connectivity over v4 IP address."
}, },
{ {
"name": "fw_upgrade_keep_settings", "name": "KeepConfig",
"type": "boolean", "type": "boolean",
"required": "no", "required": "no",
"default": "1", "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", "name": "disable_datatype_check",

View file

@ -4,6 +4,7 @@ PROJECT(icwmpd)
ADD_DEFINITIONS(-Wall -Werror -Wformat -g) ADD_DEFINITIONS(-Wall -Werror -Wformat -g)
ADD_DEFINITIONS(-D_GNU_SOURCE) ADD_DEFINITIONS(-D_GNU_SOURCE)
ADD_DEFINITIONS(-DBBF_VENDOR_PREFIX="${BBF_VENDOR_PREFIX}")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${PROJECT_SOURCE_DIR}") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${PROJECT_SOURCE_DIR}")

View file

@ -150,13 +150,15 @@ typedef struct config {
int cr_timeout; int cr_timeout;
int clock_sync_timeout; int clock_sync_timeout;
bool force_ipv4; bool force_ipv4;
bool fw_upgrade_keep_settings; int cpe_keep_config;
int cpe_keep_opconf;
bool cpe_disable_datatype_check; bool cpe_disable_datatype_check;
bool lwn_enable; bool lwn_enable;
int lwn_port; int lwn_port;
char lwn_hostname[BUF_SIZE_256]; char lwn_hostname[BUF_SIZE_256];
char cpe_config_scope[BUF_SIZE_32];
char acs_url[BUF_SIZE_2048]; char acs_url[BUF_SIZE_2048];
char acs_userid[BUF_SIZE_256]; char acs_userid[BUF_SIZE_256];
char acs_passwd[BUF_SIZE_256]; char acs_passwd[BUF_SIZE_256];

View file

@ -301,27 +301,6 @@ void ubus_get_bank_status_callback(struct ubus_request *req, int type __attribut
bank->status = 0; 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 * 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; char *fault_code = NULL;
int e; int e;
struct blob_buf b = { 0 };
int bank_id = get_available_bank_id(); int bank_id = get_available_bank_id();
char buffer[32] = {0};
if (bank_id <= 0) if (bank_id <= 0)
return -1; return -1;
@ -475,17 +457,32 @@ int cwmp_apply_multiple_firmware()
snprintf(path, sizeof(path), "Device.DeviceInfo.FirmwareImage.%d.Download()", bank_id); snprintf(path, sizeof(path), "Device.DeviceInfo.FirmwareImage.%d.Download()", bank_id);
snprintf(url, sizeof(url), "file://%s", FIRMWARE_UPGRADE_IMAGE); snprintf(url, sizeof(url), "file://%s", FIRMWARE_UPGRADE_IMAGE);
struct blob_buf b = { 0 };
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf)); CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
blob_buf_init(&b, 0); blob_buf_init(&b, 0);
bb_add_string(&b, "path", path); bb_add_string(&b, "path", path);
void *tbl = blobmsg_open_table(&b, "input"); void *tbl = blobmsg_open_table(&b, "input");
bb_add_string(&b, "URL", url); 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); blobmsg_close_table(&b, tbl);
e = icwmp_ubus_invoke_timeout(BBFDM_OBJECT_NAME, "operate", b.head, fw_upgrade_callback, &fault_code, 120000); 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) { 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 : ""); CWMP_LOG(INFO, "fwbank upgrade ubus method failed: Ubus err code: %d, fault code: %s", e, fault_code ? fault_code : "");
FREE(fault_code); FREE(fault_code);
@ -494,6 +491,7 @@ int cwmp_apply_multiple_firmware()
//set /var/state 'switch_bank' option //set /var/state 'switch_bank' option
set_uci_path_value(VARSTATE_CONFIG, "icwmp.cpe.switch_bank", "1"); set_uci_path_value(VARSTATE_CONFIG, "icwmp.cpe.switch_bank", "1");
blob_buf_free(&b);
return CWMP_OK; return CWMP_OK;
} }
@ -644,11 +642,12 @@ int apply_downloaded_file(struct download *pdownload, char *download_file_name,
bkp_session_save(); bkp_session_save();
if (CWMP_STRCMP(pdownload->file_type, FIRMWARE_UPGRADE_IMAGE_FILE_TYPE) == 0) { if (CWMP_STRCMP(pdownload->file_type, FIRMWARE_UPGRADE_IMAGE_FILE_TYPE) == 0) {
set_uci_path_value(NULL, "cwmp.cpe.exec_download", "1"); 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; error = FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED;
snprintf(err_msg, sizeof(err_msg), "Failed in applying the downloaded firmware image, may be corrupted file"); 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) { if (error == FAULT_CPE_NO_FAULT) {
sleep(70); sleep(70);
error = FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED; 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; error = FAULT_CPE_NO_FAULT;
} else if (CWMP_STRCMP(pdownload->file_type, STORED_FIRMWARE_IMAGE_FILE_TYPE) == 0) { } 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) if (err == CWMP_OK)
error = FAULT_CPE_NO_FAULT; error = FAULT_CPE_NO_FAULT;
else { else {

View file

@ -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_download(struct rpc *rpc);
static int cwmp_handle_rpc_cpe_upload(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_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 cancel_transfer(char *key);
static int cwmp_handle_rpc_cpe_cancel_transfer(struct rpc *rpc); static int cwmp_handle_rpc_cpe_cancel_transfer(struct rpc *rpc);
static int cwmp_handle_rpc_cpe_schedule_inform(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 #ifdef ICWMP_ENABLE_SMM_SUPPORT
[RPC_CPE_CHANGE_DU_STATE] = { "ChangeDUState", cwmp_handle_rpc_cpe_change_du_state, AMD_3 }, [RPC_CPE_CHANGE_DU_STATE] = { "ChangeDUState", cwmp_handle_rpc_cpe_change_du_state, AMD_3 },
#endif #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 } [RPC_CPE_FAULT] = { "Fault", cwmp_handle_rpc_cpe_fault, AMD_1 }
}; };
@ -1566,31 +1564,6 @@ error:
return -1; 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 * [RPC CPE]: CancelTransfer
*/ */

View file

@ -821,12 +821,6 @@ int run_session_end_func(void)
exit(EXIT_SUCCESS); 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 // check if any interface reset request exists then take action
intf_reset_node *iter = NULL, *node = NULL; intf_reset_node *iter = NULL, *node = NULL;
list_for_each_entry_safe(iter, node, &intf_reset_list, list) { list_for_each_entry_safe(iter, node, &intf_reset_list, list) {

View file

@ -275,7 +275,9 @@ static void config_get_cpe_elements(struct uci_section *s)
UCI_CPE_JSON_CUSTOM_NOTIFY_FILE, UCI_CPE_JSON_CUSTOM_NOTIFY_FILE,
UCI_CPE_JSON_FORCED_INFORM_FILE, UCI_CPE_JSON_FORCED_INFORM_FILE,
UCI_CPE_FORCE_IPV4, 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_DEFAULT_WAN_IFACE,
UCI_CPE_INTERFACE, UCI_CPE_INTERFACE,
UCI_CPE_CLOCK_SYNC_TIMEOUT, 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_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_CON_REQ_TIMEOUT] = { .name = "cr_timeout", .type = UCI_TYPE_STRING },
[UCI_CPE_FORCE_IPV4] = { .name = "force_ipv4", .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_DEFAULT_WAN_IFACE] = { .name = "default_wan_interface", .type = UCI_TYPE_STRING },
[UCI_CPE_INTERFACE] = { .name = "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 }, [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_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_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_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 settings enable: %d", cwmp_ctx.conf.fw_upgrade_keep_settings); 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]); char *value = get_value_from_uci_option(cpe_tb[UCI_CPE_INTERFACE]);
if ((CWMP_STRLEN(cwmp_ctx.net.interface) == 0) && (CWMP_STRLEN(value) != 0)) { if ((CWMP_STRLEN(cwmp_ctx.net.interface) == 0) && (CWMP_STRLEN(value) != 0)) {

View file

@ -37,7 +37,7 @@ config cpe 'cpe'
option exec_download '0' option exec_download '0'
option periodic_notify_enable '1' option periodic_notify_enable '1'
option periodic_notify_interval '10' option periodic_notify_interval '10'
option fw_upgrade_keep_settings '1' option KeepConfig '1'
option path 'tr69' option path 'tr69'
config lwn 'lwn' config lwn 'lwn'