mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
bbf: Fixed crash on QEMU
This commit is contained in:
parent
33ac58dd2f
commit
ec3b032d0f
5 changed files with 40 additions and 40 deletions
|
|
@ -195,7 +195,7 @@ static int browseDHCPv6ServerPoolClientInst(struct dmctx *dmctx, DMNODE *parent_
|
||||||
if (!jobj) break;
|
if (!jobj) break;
|
||||||
init_dhcpv6_client_args(&curr_dhcp_client_args, jobj, NULL, i);
|
init_dhcpv6_client_args(&curr_dhcp_client_args, jobj, NULL, i);
|
||||||
i++;
|
i++;
|
||||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_without_section, 1, i);
|
inst = handle_update_instance(2, dmctx, &max_inst, update_instance_without_section, 1, i);
|
||||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_dhcp_client_args, inst) == DM_STOP)
|
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_dhcp_client_args, inst) == DM_STOP)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -249,7 +249,7 @@ static int browseDHCPv6ServerPoolOptionInst(struct dmctx *dmctx, DMNODE *parent_
|
||||||
browse_args.option = "section_name";
|
browse_args.option = "section_name";
|
||||||
browse_args.value = section_name(curr_dhcp_args->dhcp_sec);
|
browse_args.value = section_name(curr_dhcp_args->dhcp_sec);
|
||||||
|
|
||||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 7,
|
inst = handle_update_instance(2, dmctx, &max_inst, update_instance_alias, 7,
|
||||||
dmmap_sect, "bbf_dhcpv6_servpool_option_instance", "bbf_dhcpv6_servpool_option_alias", "dmmap_dhcpv6", "servpool_option",
|
dmmap_sect, "bbf_dhcpv6_servpool_option_instance", "bbf_dhcpv6_servpool_option_alias", "dmmap_dhcpv6", "servpool_option",
|
||||||
check_browse_section, (void *)&browse_args);
|
check_browse_section, (void *)&browse_args);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ static int get_forwarding_last_inst()
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *forwarding_update_instance_alias_bbfdm(int action, char **last_inst, void *argv[])
|
static char *forwarding_update_instance_alias_bbfdm(int action, char **last_inst, char **max_inst, void *argv[])
|
||||||
{
|
{
|
||||||
char *instance, *alias;
|
char *instance, *alias;
|
||||||
char buf[64] = {0};
|
char buf[64] = {0};
|
||||||
|
|
@ -176,13 +176,14 @@ static char *forwarding_update_instance_alias_bbfdm(int action, char **last_inst
|
||||||
int m = get_forwarding_last_inst();
|
int m = get_forwarding_last_inst();
|
||||||
snprintf(buf, sizeof(buf), "%d", m+1);
|
snprintf(buf, sizeof(buf), "%d", m+1);
|
||||||
*find_max = false;
|
*find_max = false;
|
||||||
} else if (last_inst == NULL) {
|
} else if (max_inst == NULL) {
|
||||||
snprintf(buf, sizeof(buf), "%d", 1);
|
snprintf(buf, sizeof(buf), "%d", 1);
|
||||||
} else {
|
} else {
|
||||||
snprintf(buf, sizeof(buf), "%d", atoi(*last_inst)+1);
|
snprintf(buf, sizeof(buf), "%d", atoi(*max_inst)+1);
|
||||||
}
|
}
|
||||||
instance = dmuci_set_value_by_section_bbfdm(s, inst_opt, buf);
|
instance = dmuci_set_value_by_section_bbfdm(s, inst_opt, buf);
|
||||||
}
|
}
|
||||||
|
*max_inst = instance;
|
||||||
*last_inst = instance;
|
*last_inst = instance;
|
||||||
if (action == INSTANCE_MODE_ALIAS) {
|
if (action == INSTANCE_MODE_ALIAS) {
|
||||||
dmuci_get_value_by_section_string(s, alias_opt, &alias);
|
dmuci_get_value_by_section_string(s, alias_opt, &alias);
|
||||||
|
|
@ -220,7 +221,7 @@ static int get_forwarding6_last_inst()
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *forwarding6_update_instance_alias_bbfdm(int action, char **last_inst, void *argv[])
|
static char *forwarding6_update_instance_alias_bbfdm(int action, char **last_inst, char **max_inst, void *argv[])
|
||||||
{
|
{
|
||||||
char *instance, *alias;
|
char *instance, *alias;
|
||||||
char buf[64] = {0};
|
char buf[64] = {0};
|
||||||
|
|
@ -236,13 +237,14 @@ static char *forwarding6_update_instance_alias_bbfdm(int action, char **last_ins
|
||||||
int m = get_forwarding6_last_inst();
|
int m = get_forwarding6_last_inst();
|
||||||
snprintf(buf, sizeof(buf), "%d", m+1);
|
snprintf(buf, sizeof(buf), "%d", m+1);
|
||||||
*find_max = false;
|
*find_max = false;
|
||||||
} else if (last_inst == NULL) {
|
} else if (max_inst == NULL) {
|
||||||
snprintf(buf, sizeof(buf), "%d", 1);
|
snprintf(buf, sizeof(buf), "%d", 1);
|
||||||
} else {
|
} else {
|
||||||
snprintf(buf, sizeof(buf), "%d", atoi(*last_inst)+1);
|
snprintf(buf, sizeof(buf), "%d", atoi(*max_inst)+1);
|
||||||
}
|
}
|
||||||
instance = dmuci_set_value_by_section_bbfdm(s, inst_opt, buf);
|
instance = dmuci_set_value_by_section_bbfdm(s, inst_opt, buf);
|
||||||
}
|
}
|
||||||
|
*max_inst = instance;
|
||||||
*last_inst = instance;
|
*last_inst = instance;
|
||||||
if (action == INSTANCE_MODE_ALIAS) {
|
if (action == INSTANCE_MODE_ALIAS) {
|
||||||
dmuci_get_value_by_section_string(s, alias_opt, &alias);
|
dmuci_get_value_by_section_string(s, alias_opt, &alias);
|
||||||
|
|
|
||||||
|
|
@ -1205,7 +1205,7 @@ int get_mcastp_interface_no_of_entries(char *refparam, struct dmctx *ctx, void *
|
||||||
int get_mcastp_filter_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
int get_mcastp_filter_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||||
{
|
{
|
||||||
struct uci_section *f_sec;
|
struct uci_section *f_sec;
|
||||||
char *f_inst, *f_enable;
|
char *f_inst, *f_enable = NULL;
|
||||||
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_filter",
|
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_filter",
|
||||||
"section_name", section_name((struct uci_section *)data), f_sec) {
|
"section_name", section_name((struct uci_section *)data), f_sec) {
|
||||||
dmuci_get_value_by_section_string(f_sec, "filter_instance", &f_inst);
|
dmuci_get_value_by_section_string(f_sec, "filter_instance", &f_inst);
|
||||||
|
|
@ -1215,7 +1215,7 @@ int get_mcastp_filter_enable(char *refparam, struct dmctx *ctx, void *data, char
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(f_enable, "1") == 0) {
|
if (f_enable && strcmp(f_enable, "1") == 0) {
|
||||||
*value = "true";
|
*value = "true";
|
||||||
} else {
|
} else {
|
||||||
*value = "false";
|
*value = "false";
|
||||||
|
|
@ -1256,23 +1256,17 @@ int set_mcastp_filter_enable(char *refparam, struct dmctx *ctx, void *data, char
|
||||||
int get_mcastp_filter_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
int get_mcastp_filter_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||||
{
|
{
|
||||||
struct uci_section *d_sec;
|
struct uci_section *d_sec;
|
||||||
char *f_inst, *ip_addr;
|
char *f_inst;
|
||||||
|
|
||||||
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_filter",
|
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_filter",
|
||||||
"section_name", section_name((struct uci_section *)data), d_sec) {
|
"section_name", section_name((struct uci_section *)data), d_sec) {
|
||||||
dmuci_get_value_by_section_string(d_sec, "filter_instance", &f_inst);
|
dmuci_get_value_by_section_string(d_sec, "filter_instance", &f_inst);
|
||||||
if (strcmp(instance, f_inst) == 0) {
|
if (strcmp(instance, f_inst) == 0) {
|
||||||
dmuci_get_value_by_section_string(d_sec, "ipaddr", &ip_addr);
|
dmuci_get_value_by_section_string(d_sec, "ipaddr", value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ip_addr[0] == '\0') {
|
|
||||||
*value = "";
|
|
||||||
} else {
|
|
||||||
*value = dmstrdup(ip_addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1971,7 +1965,7 @@ static int set_igmpp_interface_upstream(char *refparam, struct dmctx *ctx, void
|
||||||
int get_mcastp_interface_upstream(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
int get_mcastp_interface_upstream(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||||
{
|
{
|
||||||
struct uci_section *d_sec;
|
struct uci_section *d_sec;
|
||||||
char *f_inst, *up;
|
char *f_inst, *up = NULL;
|
||||||
|
|
||||||
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface",
|
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface",
|
||||||
"section_name", section_name((struct uci_section *)data), d_sec) {
|
"section_name", section_name((struct uci_section *)data), d_sec) {
|
||||||
|
|
@ -1982,14 +1976,14 @@ int get_mcastp_interface_upstream(char *refparam, struct dmctx *ctx, void *data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*value = (strcmp(up, "1") == 0) ? "true" : "false";
|
*value = (up && strcmp(up, "1") == 0) ? "true" : "false";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_mcastp_iface_snoop_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
int get_mcastp_iface_snoop_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||||
{
|
{
|
||||||
struct uci_section *d_sec;
|
struct uci_section *d_sec;
|
||||||
char *f_inst, *val;
|
char *f_inst, *val = NULL;
|
||||||
|
|
||||||
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface",
|
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface",
|
||||||
"section_name", section_name((struct uci_section *)data), d_sec) {
|
"section_name", section_name((struct uci_section *)data), d_sec) {
|
||||||
|
|
@ -2000,9 +1994,9 @@ int get_mcastp_iface_snoop_mode(char *refparam, struct dmctx *ctx, void *data, c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(val, "1") == 0)
|
if (val && strcmp(val, "1") == 0)
|
||||||
*value = "Standard";
|
*value = "Standard";
|
||||||
else if (strcmp(val, "2") == 0)
|
else if (val && strcmp(val, "2") == 0)
|
||||||
*value = "Blocking";
|
*value = "Blocking";
|
||||||
else
|
else
|
||||||
*value = "Disabled";
|
*value = "Disabled";
|
||||||
|
|
|
||||||
|
|
@ -585,10 +585,10 @@ static int rootcmp(char *inparam, char *rootobj)
|
||||||
/***************************
|
/***************************
|
||||||
* update instance & alias
|
* update instance & alias
|
||||||
***************************/
|
***************************/
|
||||||
char *handle_update_instance(int instance_ranck, struct dmctx *ctx, char **last_inst, char * (*up_instance)(int action, char **last_inst, void *argv[]), int argc, ...)
|
char *handle_update_instance(int instance_ranck, struct dmctx *ctx, char **max_inst, char * (*up_instance)(int action, char **last_inst, char **max_inst, void *argv[]), int argc, ...)
|
||||||
{
|
{
|
||||||
va_list arg;
|
va_list arg;
|
||||||
char *instance;
|
char *instance, *last_inst = NULL;;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
unsigned int action, pos = instance_ranck - 1;
|
unsigned int action, pos = instance_ranck - 1;
|
||||||
void *argv[argc+1];
|
void *argv[argc+1];
|
||||||
|
|
@ -609,19 +609,20 @@ char *handle_update_instance(int instance_ranck, struct dmctx *ctx, char **last_
|
||||||
action = INSTANCE_UPDATE_NUMBER;
|
action = INSTANCE_UPDATE_NUMBER;
|
||||||
}
|
}
|
||||||
|
|
||||||
instance = up_instance(action, last_inst, argv);
|
instance = up_instance(action, &last_inst, max_inst, argv);
|
||||||
if (*last_inst)
|
if (last_inst)
|
||||||
ctx->inst_buf[pos] = dmstrdup(*last_inst);
|
ctx->inst_buf[pos] = dmstrdup(last_inst);
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *update_instance(char *last_inst, int argc, ...)
|
char *update_instance(char *max_inst, int argc, ...)
|
||||||
{
|
{
|
||||||
va_list arg;
|
va_list arg;
|
||||||
char *instance;
|
char *instance;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
void *argv[argc+1];
|
void *argv[argc+1];
|
||||||
|
char *last_inst;
|
||||||
|
|
||||||
va_start(arg, argc);
|
va_start(arg, argc);
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
|
|
@ -630,7 +631,7 @@ char *update_instance(char *last_inst, int argc, ...)
|
||||||
argv[argc] = NULL;
|
argv[argc] = NULL;
|
||||||
va_end(arg);
|
va_end(arg);
|
||||||
|
|
||||||
instance = update_instance_alias(0, &last_inst, argv);
|
instance = update_instance_alias(0, &last_inst, &max_inst, argv);
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
@ -655,7 +656,7 @@ static int get_max_instance(char *dmmap_package, char *section_type, char *inst_
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *update_instance_alias(int action, char **max_inst, void *argv[])
|
char *update_instance_alias(int action, char **last_inst, char **max_inst, void *argv[])
|
||||||
{
|
{
|
||||||
char *instance, *alias;
|
char *instance, *alias;
|
||||||
char buf[64] = {0};
|
char buf[64] = {0};
|
||||||
|
|
@ -682,6 +683,7 @@ char *update_instance_alias(int action, char **max_inst, void *argv[])
|
||||||
} else {
|
} else {
|
||||||
dmasprintf(max_inst, "%d", max_instance);
|
dmasprintf(max_inst, "%d", max_instance);
|
||||||
}
|
}
|
||||||
|
*last_inst = instance;
|
||||||
|
|
||||||
if (action == INSTANCE_MODE_ALIAS) {
|
if (action == INSTANCE_MODE_ALIAS) {
|
||||||
dmuci_get_value_by_section_string(s, alias_opt, &alias);
|
dmuci_get_value_by_section_string(s, alias_opt, &alias);
|
||||||
|
|
@ -695,18 +697,20 @@ char *update_instance_alias(int action, char **max_inst, void *argv[])
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *update_instance_without_section(int action, char **last_inst, void *argv[])
|
char *update_instance_without_section(int action, char **last_inst, char **max_inst, void *argv[])
|
||||||
{
|
{
|
||||||
char *instance, buf[64] = {0};
|
char *instance, buf[64] = {0};
|
||||||
int instnbr = (int)(long)argv[0];
|
int instnbr = (int)(long)argv[0];
|
||||||
|
|
||||||
|
snprintf(buf, sizeof(buf), "%d", instnbr);
|
||||||
|
instance = dmstrdup(buf);
|
||||||
|
*last_inst = instance;
|
||||||
|
|
||||||
if (action == INSTANCE_MODE_ALIAS) {
|
if (action == INSTANCE_MODE_ALIAS) {
|
||||||
snprintf(buf, sizeof(buf), "[cpe-%d]", instnbr);
|
snprintf(buf, sizeof(buf), "[cpe-%d]", instnbr);
|
||||||
instance = dmstrdup(buf);
|
instance = dmstrdup(buf);
|
||||||
} else {
|
|
||||||
snprintf(buf, sizeof(buf), "%d", instnbr);
|
|
||||||
instance = dmstrdup(buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -986,7 +990,7 @@ int update_param_instance_alias(struct dmctx *ctx, char *param, char **new_param
|
||||||
i++;
|
i++;
|
||||||
} else if (pch[0]== '[') {
|
} else if (pch[0]== '[') {
|
||||||
dmstrappendchr(p, dm_delim);
|
dmstrappendchr(p, dm_delim);
|
||||||
dmstrappendstr(p, ctx->inst_buf[i]);
|
dmstrappendstr(p, (ctx->inst_buf[i]) ? ctx->inst_buf[i] : "1");
|
||||||
i++;
|
i++;
|
||||||
} else {
|
} else {
|
||||||
if (j > 0) {
|
if (j > 0) {
|
||||||
|
|
|
||||||
|
|
@ -542,9 +542,9 @@ extern char dm_delim;
|
||||||
extern char dmroot[64];
|
extern char dmroot[64];
|
||||||
extern int bbfdatamodel_type;
|
extern int bbfdatamodel_type;
|
||||||
|
|
||||||
char *update_instance(char *last_inst, int argc, ...);
|
char *update_instance(char *max_inst, int argc, ...);
|
||||||
char *update_instance_alias(int action, char **last_inst , void *argv[]);
|
char *update_instance_alias(int action, char **last_inst, char **max_inst, void *argv[]);
|
||||||
char *update_instance_without_section(int action, char **last_inst, void *argv[]);
|
char *update_instance_without_section(int action, char **last_inst, char **max_inst, void *argv[]);
|
||||||
int get_empty(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
int get_empty(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||||
void add_list_paramameter(struct dmctx *ctx, char *param_name, char *param_data, char *param_type, char *param_version, unsigned int flags);
|
void add_list_paramameter(struct dmctx *ctx, char *param_name, char *param_data, char *param_type, char *param_version, unsigned int flags);
|
||||||
void api_del_list_parameter(struct dm_parameter *dm_parameter);
|
void api_del_list_parameter(struct dm_parameter *dm_parameter);
|
||||||
|
|
@ -591,7 +591,7 @@ char *get_last_instance_bbfdm(char *package, char *section, char *opt_inst);
|
||||||
char *get_last_instance_lev2(char *package, char *section, char *opt_inst, char *opt_check, char *value_check);
|
char *get_last_instance_lev2(char *package, char *section, char *opt_inst, char *opt_check, char *value_check);
|
||||||
char *get_last_instance_lev2_bbfdm_dmmap_opt(char* dmmap_package, char *section, char *opt_inst, char *opt_check, char *value_check);
|
char *get_last_instance_lev2_bbfdm_dmmap_opt(char* dmmap_package, char *section, char *opt_inst, char *opt_check, char *value_check);
|
||||||
char *get_last_instance_lev2_bbfdm(char *package, char *section, char* dmmap_package, char *opt_inst, char *opt_check, char *value_check);
|
char *get_last_instance_lev2_bbfdm(char *package, char *section, char* dmmap_package, char *opt_inst, char *opt_check, char *value_check);
|
||||||
char *handle_update_instance(int instance_ranck, struct dmctx *ctx, char **last_inst, char * (*up_instance)(int action, char **last_inst, void *argv[]), int argc, ...);
|
char *handle_update_instance(int instance_ranck, struct dmctx *ctx, char **max_inst, char * (*up_instance)(int action, char **last_inst, char **max_inst, void *argv[]), int argc, ...);
|
||||||
int dm_add_end_session(struct dmctx *ctx, void(*function)(struct execute_end_session *), int action, void *data);
|
int dm_add_end_session(struct dmctx *ctx, void(*function)(struct execute_end_session *), int action, void *data);
|
||||||
char *dm_print_path(char *fpath, ...);
|
char *dm_print_path(char *fpath, ...);
|
||||||
int dm_link_inst_obj(struct dmctx *dmctx, DMNODE *parent_node, void *data, char *instance);
|
int dm_link_inst_obj(struct dmctx *dmctx, DMNODE *parent_node, void *data, char *instance);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue