T#12829: Uci option to keep/remove settings with '1 Firmware Upgrade Image'

This commit is contained in:
Amin Ben Romdhane 2023-12-06 03:43:10 +00:00 committed by Vivek Kumar Dutta
parent 35228b84fb
commit 5c1970e571
6 changed files with 24 additions and 2 deletions

View file

@ -426,6 +426,15 @@
<div class="td_row_odd">If set to <b>1</b>, it forces the connectivity over v4 IP address.</div> <div class="td_row_odd">If set to <b>1</b>, it forces the connectivity over v4 IP address.</div>
</td> </td>
</tr> </tr>
<tr>
<td class="td_row_odd"><div class="td_row_odd">keep_settings</div></td>
<td class="td_row_odd"><div class="td_row_odd">boolean</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">1</div></td>
<td class="td_row_odd">
<div class="td_row_odd">If set to <b>1</b>, icwmp will keep the uci setting while doing firmware upgrade using Download RPC with '1 Firmware Upgrade Image'.</div>
</td>
</tr>
</tbody> </tbody>
</table> </table>
</td> </td>

View file

@ -340,6 +340,13 @@
"required": "no", "required": "no",
"default": "", "default": "",
"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": "keep_settings",
"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'."
} }
] ]
}, },

View file

@ -157,6 +157,7 @@ typedef struct config {
bool http_disable_100continue; bool http_disable_100continue;
int cr_timeout; int cr_timeout;
bool force_ipv4; bool force_ipv4;
bool keep_settings;
} config; } config;
struct deviceid { struct deviceid {

View file

@ -68,6 +68,7 @@ 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,
__MAX_NUM_UCI_CPE_ATTRS, __MAX_NUM_UCI_CPE_ATTRS,
}; };
@ -87,7 +88,8 @@ static void config_get_cpe_elements(struct uci_section *s)
[UCI_CPE_JSON_CUSTOM_NOTIFY_FILE] = { .name = "custom_notify_json", .type = UCI_TYPE_STRING }, [UCI_CPE_JSON_CUSTOM_NOTIFY_FILE] = { .name = "custom_notify_json", .type = UCI_TYPE_STRING },
[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 = "keep_settings", .type = UCI_TYPE_STRING }
}; };
struct uci_option *cpe_tb[__MAX_NUM_UCI_CPE_ATTRS]; struct uci_option *cpe_tb[__MAX_NUM_UCI_CPE_ATTRS];
@ -187,6 +189,8 @@ static void config_get_cpe_elements(struct uci_section *s)
cwmp_main->conf.force_ipv4 = uci_str_to_bool(get_value_from_uci_option(cpe_tb[UCI_CPE_FORCE_IPV4])); cwmp_main->conf.force_ipv4 = uci_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_main->conf.force_ipv4); CWMP_LOG(DEBUG, "CWMP CONFIG - cpe force ipv4 enable: %d", cwmp_main->conf.force_ipv4);
cwmp_main->conf.keep_settings = cpe_tb[UCI_CPE_KEEP_SETTINGS] ? uci_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_main->conf.keep_settings);
} }
static void config_get_acs_elements(struct uci_section *s) static void config_get_acs_elements(struct uci_section *s)

View file

@ -297,7 +297,7 @@ int cwmp_apply_firmware()
struct blob_buf b = { 0 }; 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);
blobmsg_add_u8(&b, "keep", true); blobmsg_add_u8(&b, "keep", cwmp_main->conf.keep_settings);
CWMP_LOG(INFO, "Apply downloaded image ..."); CWMP_LOG(INFO, "Apply downloaded image ...");
e = icwmp_ubus_invoke("rpc-sys", "upgrade_start", b.head, NULL, NULL); e = icwmp_ubus_invoke("rpc-sys", "upgrade_start", b.head, NULL, NULL);

View file

@ -37,6 +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 keep_settings '1'
config lwn 'lwn' config lwn 'lwn'
option enable '1' option enable '1'