mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
Revert "Ticket #6359: icwmp: Reduce I/O on filesystem"
This reverts commit 4e512e588e.
This commit is contained in:
parent
dc642082f9
commit
01d36c0edf
7 changed files with 46 additions and 28 deletions
|
|
@ -266,16 +266,14 @@ int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1,
|
|||
case CMD_ADD_OBJECT:
|
||||
fault = dm_entry_add_object(ctx);
|
||||
if (!fault) {
|
||||
dmuci_set_value_varstate("cwmp", "cpe", "ParameterKey", arg1 ? arg1 : "");
|
||||
dmuci_commit_package_varstate("cwmp");
|
||||
dmuci_set_value("cwmp", "acs", "ParameterKey", arg1 ? arg1 : "");
|
||||
dmuci_change_packages(&head_package_change);
|
||||
}
|
||||
break;
|
||||
case CMD_DEL_OBJECT:
|
||||
fault = dm_entry_delete_object(ctx);
|
||||
if (!fault) {
|
||||
dmuci_set_value_varstate("cwmp", "cpe", "ParameterKey", arg1 ? arg1 : "");
|
||||
dmuci_commit_package_varstate("cwmp");
|
||||
dmuci_set_value("cwmp", "acs", "ParameterKey", arg1 ? arg1 : "");
|
||||
dmuci_change_packages(&head_package_change);
|
||||
}
|
||||
break;
|
||||
|
|
@ -323,8 +321,7 @@ int dm_entry_apply(struct dmctx *ctx, int cmd, char *arg1)
|
|||
}
|
||||
}
|
||||
if (!fault) {
|
||||
dmuci_set_value_varstate("cwmp", "cpe", "ParameterKey", arg1 ? arg1 : "");
|
||||
dmuci_commit_package_varstate("cwmp");
|
||||
dmuci_set_value("cwmp", "acs", "ParameterKey", arg1 ? arg1 : "");
|
||||
dmuci_change_packages(&head_package_change);
|
||||
dmuci_save();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2691,8 +2691,8 @@
|
|||
"uci": {
|
||||
"file": "cwmp",
|
||||
"section": {
|
||||
"type": "cpe",
|
||||
"name": "cpe"
|
||||
"type": "acs",
|
||||
"name": "acs"
|
||||
},
|
||||
"option": {
|
||||
"name": "ParameterKey"
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ static int get_management_server_url(char *refparam, struct dmctx *ctx, void *da
|
|||
|
||||
dmuci_get_option_value_string("cwmp", "acs", "dhcp_discovery", &dhcp);
|
||||
dmuci_get_option_value_string("cwmp", "acs", "url", &url);
|
||||
dmuci_get_option_value_string_varstate("cwmp", "acs", "dhcp_url", &provisioning_value);
|
||||
varstate_get_value_string("cwmp", "acs", "dhcp_url", &provisioning_value);
|
||||
|
||||
if ( ((dhcp && strcmp(dhcp, "enable") == 0 ) || ((url == NULL) || (url[0] == '\0'))) && ((provisioning_value != NULL) && (provisioning_value[0] != '\0')) )
|
||||
*value = provisioning_value;
|
||||
|
|
@ -133,7 +133,7 @@ static int set_management_server_delay_reboot(char *refparam, struct dmctx *ctx,
|
|||
/*#Device.ManagementServer.ParameterKey!UCI:cwmp/acs,acs/ParameterKey*/
|
||||
static int get_management_server_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string_varstate("cwmp", "cpe", "ParameterKey", value);
|
||||
dmuci_get_option_value_string("cwmp", "acs", "ParameterKey", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@
|
|||
#include "dmmem.h"
|
||||
|
||||
static struct uci_context *uci_ctx = NULL;
|
||||
static struct uci_context *uci_varstate_ctx;
|
||||
static char *db_config = NULL;
|
||||
|
||||
NEW_UCI_PATH(bbfdm, BBFDM_CONFIG, BBFDM_SAVEDIR)
|
||||
NEW_UCI_PATH(varstate, VARSTATE_CONFDIR, NULL)
|
||||
|
||||
int dmuci_init(void)
|
||||
{
|
||||
|
|
@ -44,7 +44,9 @@ int bbf_uci_init(void)
|
|||
{
|
||||
dmuci_init();
|
||||
|
||||
dmuci_init_varstate();
|
||||
uci_varstate_ctx = uci_alloc_context();
|
||||
if (!uci_varstate_ctx)
|
||||
return -1;
|
||||
|
||||
dmuci_init_bbfdm();
|
||||
|
||||
|
|
@ -57,7 +59,9 @@ int bbf_uci_exit(void)
|
|||
{
|
||||
dmuci_exit();
|
||||
|
||||
dmuci_exit_varstate();
|
||||
if (uci_varstate_ctx)
|
||||
uci_free_context(uci_varstate_ctx);
|
||||
uci_varstate_ctx = NULL;
|
||||
|
||||
dmuci_exit_bbfdm();
|
||||
|
||||
|
|
@ -848,6 +852,27 @@ int db_get_value_string(char *package, char *section, char *option, char **value
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**** UCI GET /var/state *****/
|
||||
int varstate_get_value_string(char *package, char *section, char *option, char **value)
|
||||
{
|
||||
struct uci_ptr ptr = {0};
|
||||
|
||||
uci_add_delta_path(uci_varstate_ctx, uci_varstate_ctx->savedir);
|
||||
uci_set_confdir(uci_varstate_ctx, VARSTATE_CONFIG);
|
||||
|
||||
if (dmuci_lookup_ptr(uci_varstate_ctx, &ptr, package, section, option, NULL)) {
|
||||
*value = "";
|
||||
return -1;
|
||||
}
|
||||
if (ptr.o && ptr.o->v.string) {
|
||||
*value = ptr.o->v.string;
|
||||
} else {
|
||||
*value = "";
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void commit_and_free_uci_ctx_bbfdm(char *dmmap_config)
|
||||
{
|
||||
dmuci_commit_package_bbfdm(dmmap_config);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@
|
|||
#define BBFDM_CONFIG "/etc/bbfdm/dmmap"
|
||||
#define BBFDM_SAVEDIR "/tmp/.bbfdm"
|
||||
#define UCI_CONFIG_DIR "/etc/config/"
|
||||
#define VARSTATE_CONFDIR "/var/state/"
|
||||
|
||||
enum dm_uci_cmp {
|
||||
CMP_SECTION,
|
||||
|
|
@ -365,18 +364,14 @@ int dmuci_delete_by_section_bbfdm(struct uci_section *s, char *option, char *val
|
|||
int dmuci_commit_package_bbfdm(char *package);
|
||||
int dmuci_commit_bbfdm(void);
|
||||
int dmuci_revert_bbfdm(void);
|
||||
int dmuci_commit_package_varstate(char *package);
|
||||
struct uci_section *dmuci_walk_section_bbfdm(char *package, char *stype, void *arg1, void *arg2, int cmp , int (*filter)(struct uci_section *s, void *value), struct uci_section *prev_section, int walk);
|
||||
|
||||
int dmuci_init_bbfdm(void);
|
||||
void dmuci_exit_bbfdm(void);
|
||||
void commit_and_free_uci_ctx_bbfdm(char *dmmap_config);
|
||||
|
||||
int dmuci_init_varstate(void);
|
||||
void dmuci_exit_varstate(void);
|
||||
int db_get_value_string(char *package, char *section, char *option, char **value);
|
||||
int dmuci_get_option_value_string_varstate(char *package, char *section, char *option, char **value);
|
||||
char *dmuci_set_value_varstate(char *package, char *section, char *option, char *value);
|
||||
int varstate_get_value_string(char *package, char *section, char *option, char **value);
|
||||
|
||||
char *bbf_uci_get_value(char *path, char *package, char *section, char *option);
|
||||
char *bbf_uci_set_value(char *path, char *package, char *section, char *option, char *value);
|
||||
|
|
|
|||
|
|
@ -143,26 +143,26 @@ static void test_bbf_api_uci(void **state)
|
|||
assert_string_equal(value, "FirstClass");
|
||||
|
||||
/*
|
||||
* Test of dmuci_get_option_value_string_varstate function
|
||||
* Test of varstate_get_value_string function
|
||||
*/
|
||||
|
||||
// dmuci_get_option_value_string_varstate: test with correct section/option and wrong config name
|
||||
uci_res = dmuci_get_option_value_string_varstate("cwm", "acs", "dhcp_url", &value);
|
||||
// varstate_get_value_string: test with correct section/option and wrong config name
|
||||
uci_res = varstate_get_value_string("cwm", "acs", "dhcp_url", &value);
|
||||
assert_int_equal(uci_res, -1);
|
||||
assert_string_equal(value, "");
|
||||
|
||||
// dmuci_get_option_value_string_varstate: test with correct config/option and wrong section name
|
||||
uci_res = dmuci_get_option_value_string_varstate("cwmp", "acss", "dhcp_url", &value);
|
||||
// varstate_get_value_string: test with correct config/option and wrong section name
|
||||
uci_res = varstate_get_value_string("cwmp", "acss", "dhcp_url", &value);
|
||||
assert_int_equal(uci_res, -1);
|
||||
assert_string_equal(value, "");
|
||||
|
||||
// dmuci_get_option_value_string_varstate: test with correct config/section and wrong option name
|
||||
uci_res = dmuci_get_option_value_string_varstate("cwmp", "acs", "hcp_url", &value);
|
||||
// varstate_get_value_string: test with correct config/section and wrong option name
|
||||
uci_res = varstate_get_value_string("cwmp", "acs", "hcp_url", &value);
|
||||
assert_int_equal(uci_res, -1);
|
||||
assert_string_equal(value, "");
|
||||
|
||||
// dmuci_get_option_value_string_varstate: test correct config/section/option
|
||||
uci_res = dmuci_get_option_value_string_varstate("cwmp", "acs", "dhcp_url", &value);
|
||||
// varstate_get_value_string: test correct config/section/option
|
||||
uci_res = varstate_get_value_string("cwmp", "acs", "dhcp_url", &value);
|
||||
assert_int_equal(uci_res, 0);
|
||||
assert_string_equal(value, "http://192.168.1.123:8080/openacs");
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ config acs 'acs'
|
|||
option periodic_inform_enable 'true'
|
||||
option periodic_inform_interval '1800'
|
||||
option periodic_inform_time '0'
|
||||
option ParameterKey ''
|
||||
option dhcp_discovery 'enable'
|
||||
# compression possible configs: GZIP, Deflate, Disabled
|
||||
option compression 'Disabled'
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue