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
a83984d914
commit
6da9750f96
5 changed files with 40 additions and 40 deletions
|
|
@ -195,7 +195,7 @@ static int browseDHCPv6ServerPoolClientInst(struct dmctx *dmctx, DMNODE *parent_
|
|||
if (!jobj) break;
|
||||
init_dhcpv6_client_args(&curr_dhcp_client_args, jobj, NULL, 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)
|
||||
break;
|
||||
}
|
||||
|
|
@ -249,7 +249,7 @@ static int browseDHCPv6ServerPoolOptionInst(struct dmctx *dmctx, DMNODE *parent_
|
|||
browse_args.option = "section_name";
|
||||
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",
|
||||
check_browse_section, (void *)&browse_args);
|
||||
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ static int get_forwarding_last_inst()
|
|||
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 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();
|
||||
snprintf(buf, sizeof(buf), "%d", m+1);
|
||||
*find_max = false;
|
||||
} else if (last_inst == NULL) {
|
||||
} else if (max_inst == NULL) {
|
||||
snprintf(buf, sizeof(buf), "%d", 1);
|
||||
} 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);
|
||||
}
|
||||
*max_inst = instance;
|
||||
*last_inst = instance;
|
||||
if (action == INSTANCE_MODE_ALIAS) {
|
||||
dmuci_get_value_by_section_string(s, alias_opt, &alias);
|
||||
|
|
@ -220,7 +221,7 @@ static int get_forwarding6_last_inst()
|
|||
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 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();
|
||||
snprintf(buf, sizeof(buf), "%d", m+1);
|
||||
*find_max = false;
|
||||
} else if (last_inst == NULL) {
|
||||
} else if (max_inst == NULL) {
|
||||
snprintf(buf, sizeof(buf), "%d", 1);
|
||||
} 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);
|
||||
}
|
||||
*max_inst = instance;
|
||||
*last_inst = instance;
|
||||
if (action == INSTANCE_MODE_ALIAS) {
|
||||
dmuci_get_value_by_section_string(s, alias_opt, &alias);
|
||||
|
|
|
|||
|
|
@ -1196,7 +1196,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)
|
||||
{
|
||||
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",
|
||||
"section_name", section_name((struct uci_section *)data), f_sec) {
|
||||
dmuci_get_value_by_section_string(f_sec, "filter_instance", &f_inst);
|
||||
|
|
@ -1206,7 +1206,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";
|
||||
} else {
|
||||
*value = "false";
|
||||
|
|
@ -1247,23 +1247,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)
|
||||
{
|
||||
struct uci_section *d_sec;
|
||||
char *f_inst, *ip_addr;
|
||||
char *f_inst;
|
||||
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_filter",
|
||||
"section_name", section_name((struct uci_section *)data), d_sec) {
|
||||
dmuci_get_value_by_section_string(d_sec, "filter_instance", &f_inst);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (ip_addr[0] == '\0') {
|
||||
*value = "";
|
||||
} else {
|
||||
*value = dmstrdup(ip_addr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1946,7 +1940,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)
|
||||
{
|
||||
struct uci_section *d_sec;
|
||||
char *f_inst, *up;
|
||||
char *f_inst, *up = NULL;
|
||||
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface",
|
||||
"section_name", section_name((struct uci_section *)data), d_sec) {
|
||||
|
|
@ -1957,14 +1951,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;
|
||||
}
|
||||
|
||||
int get_mcastp_iface_snoop_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct uci_section *d_sec;
|
||||
char *f_inst, *val;
|
||||
char *f_inst, *val = NULL;
|
||||
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface",
|
||||
"section_name", section_name((struct uci_section *)data), d_sec) {
|
||||
|
|
@ -1975,9 +1969,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";
|
||||
else if (strcmp(val, "2") == 0)
|
||||
else if (val && strcmp(val, "2") == 0)
|
||||
*value = "Blocking";
|
||||
else
|
||||
*value = "Disabled";
|
||||
|
|
|
|||
|
|
@ -586,10 +586,10 @@ static int rootcmp(char *inparam, char *rootobj)
|
|||
/***************************
|
||||
* 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;
|
||||
char *instance;
|
||||
char *instance, *last_inst = NULL;;
|
||||
int i = 0;
|
||||
unsigned int action, pos = instance_ranck - 1;
|
||||
void *argv[argc+1];
|
||||
|
|
@ -610,19 +610,20 @@ char *handle_update_instance(int instance_ranck, struct dmctx *ctx, char **last_
|
|||
action = INSTANCE_UPDATE_NUMBER;
|
||||
}
|
||||
|
||||
instance = up_instance(action, last_inst, argv);
|
||||
if (*last_inst)
|
||||
ctx->inst_buf[pos] = dmstrdup(*last_inst);
|
||||
instance = up_instance(action, &last_inst, max_inst, argv);
|
||||
if (last_inst)
|
||||
ctx->inst_buf[pos] = dmstrdup(last_inst);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
char *update_instance(char *last_inst, int argc, ...)
|
||||
char *update_instance(char *max_inst, int argc, ...)
|
||||
{
|
||||
va_list arg;
|
||||
char *instance;
|
||||
int i = 0;
|
||||
void *argv[argc+1];
|
||||
char *last_inst;
|
||||
|
||||
va_start(arg, argc);
|
||||
for (i = 0; i < argc; i++) {
|
||||
|
|
@ -631,7 +632,7 @@ char *update_instance(char *last_inst, int argc, ...)
|
|||
argv[argc] = NULL;
|
||||
va_end(arg);
|
||||
|
||||
instance = update_instance_alias(0, &last_inst, argv);
|
||||
instance = update_instance_alias(0, &last_inst, &max_inst, argv);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
|
@ -656,7 +657,7 @@ static int get_max_instance(char *dmmap_package, char *section_type, char *inst_
|
|||
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 buf[64] = {0};
|
||||
|
|
@ -683,6 +684,7 @@ char *update_instance_alias(int action, char **max_inst, void *argv[])
|
|||
} else {
|
||||
dmasprintf(max_inst, "%d", max_instance);
|
||||
}
|
||||
*last_inst = instance;
|
||||
|
||||
if (action == INSTANCE_MODE_ALIAS) {
|
||||
dmuci_get_value_by_section_string(s, alias_opt, &alias);
|
||||
|
|
@ -696,18 +698,20 @@ char *update_instance_alias(int action, char **max_inst, void *argv[])
|
|||
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};
|
||||
int instnbr = (int)(long)argv[0];
|
||||
|
||||
snprintf(buf, sizeof(buf), "%d", instnbr);
|
||||
instance = dmstrdup(buf);
|
||||
*last_inst = instance;
|
||||
|
||||
if (action == INSTANCE_MODE_ALIAS) {
|
||||
snprintf(buf, sizeof(buf), "[cpe-%d]", instnbr);
|
||||
instance = dmstrdup(buf);
|
||||
} else {
|
||||
snprintf(buf, sizeof(buf), "%d", instnbr);
|
||||
instance = dmstrdup(buf);
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
|
@ -987,7 +991,7 @@ int update_param_instance_alias(struct dmctx *ctx, char *param, char **new_param
|
|||
i++;
|
||||
} else if (pch[0]== '[') {
|
||||
dmstrappendchr(p, dm_delim);
|
||||
dmstrappendstr(p, ctx->inst_buf[i]);
|
||||
dmstrappendstr(p, (ctx->inst_buf[i]) ? ctx->inst_buf[i] : "1");
|
||||
i++;
|
||||
} else {
|
||||
if (j > 0) {
|
||||
|
|
|
|||
|
|
@ -545,9 +545,9 @@ extern char dmroot[64];
|
|||
extern char *DMT_TYPE[];
|
||||
extern int bbfdatamodel_type;
|
||||
|
||||
char *update_instance(char *last_inst, int argc, ...);
|
||||
char *update_instance_alias(int action, char **last_inst , void *argv[]);
|
||||
char *update_instance_without_section(int action, char **last_inst, void *argv[]);
|
||||
char *update_instance(char *max_inst, int argc, ...);
|
||||
char *update_instance_alias(int action, char **last_inst, char **max_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);
|
||||
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);
|
||||
|
|
@ -594,7 +594,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_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 *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);
|
||||
char *dm_print_path(char *fpath, ...);
|
||||
int dm_link_inst_obj(struct dmctx *dmctx, DMNODE *parent_node, void *data, char *instance);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue