mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2026-03-09 10:47:22 +01:00
Ticket refs #14406: TR-069: Move TR related UCI options from original config to /etc/icwmpd/dmmap (InternetGatewayDevice.Layer2Bridging.Bridge.x. Device.IP.Interface.x.)
This commit is contained in:
parent
5697b33274
commit
7cb6898b6d
3 changed files with 154 additions and 45 deletions
|
|
@ -630,6 +630,28 @@ void update_section_option_list(char *config, char *section, char *option, char
|
|||
}
|
||||
}
|
||||
|
||||
void update_section_list_icwmpd(char *config, char *section, char *option, int number, char *filter, char *option1, char *val1, char *option2, char *val2){
|
||||
char *add_value;
|
||||
struct uci_section *s = NULL;
|
||||
int i = 0;
|
||||
|
||||
if (option) {
|
||||
uci_path_foreach_option_eq(icwmpd, config, section, option, filter, s) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
uci_path_foreach_sections(icwmpd, config, section, s) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
while (i < number) {
|
||||
DMUCI_ADD_SECTION(icwmpd, config, section, &s, &add_value);
|
||||
if (option)DMUCI_SET_VALUE_BY_SECTION(icwmpd, s, option, filter);
|
||||
if (option1)DMUCI_SET_VALUE_BY_SECTION(icwmpd, s, option1, val1);
|
||||
if (option2)DMUCI_SET_VALUE_BY_SECTION(icwmpd, s, option2, val2);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void update_section_list(char *config, char *section, char *option, int number, char *filter, char *option1, char *val1, char *option2, char *val2)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -86,6 +86,10 @@ DMLEAF tbridge_vlanParam[] = {
|
|||
};
|
||||
|
||||
|
||||
void set_network_interface_bridge(struct uci_section *dmmap_bridge_section){
|
||||
DMUCI_SET_VALUE_BY_SECTION(icwmpd, dmmap_bridge_section, "type", "bridge");
|
||||
}
|
||||
|
||||
int browselayer2_availableinterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
int i = 0;
|
||||
|
|
@ -162,14 +166,19 @@ int browselayer2_bridgeInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev
|
|||
char *bridge_instance = NULL, *bridge_instance_last = NULL;
|
||||
struct uci_section *bridge_s;
|
||||
struct args_layer2 curr_args = {0};
|
||||
struct dmmap_dup *p;
|
||||
LIST_HEAD(dup_list);
|
||||
|
||||
dmuci_get_option_value_string("ports", "WAN", "ifname", &wan_baseifname);
|
||||
uci_foreach_option_eq("network", "interface", "type", "bridge", bridge_s) {
|
||||
bridge_instance = handle_update_instance(1, dmctx, &bridge_instance_last, update_instance_alias, 3, bridge_s, "bridge_instance", "bridge_alias");
|
||||
init_args_layer2(&curr_args, bridge_s, NULL, NULL, bridge_instance_last, NULL, NULL);
|
||||
synchronize_specific_config_sections_with_dmmap_eq("network", "interface", "dmmap_network", "type", "bridge", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
set_network_interface_bridge(p->dmmap_section);
|
||||
bridge_instance = handle_update_instance(1, dmctx, &bridge_instance_last, update_instance_alias, 3, p->dmmap_section, "bridge_instance", "bridge_alias");
|
||||
init_args_layer2(&curr_args, p->config_section, NULL, NULL, bridge_instance_last, NULL, NULL);
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_args, bridge_instance) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
free_dmmap_config_dup_list(&dup_list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1113,11 +1122,13 @@ struct uci_section *update_availableinterface_list(struct dmctx *ctx, char *ifac
|
|||
|
||||
int add_layer2bridging_bridge(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *last_instance;
|
||||
char *last_instance, *v;
|
||||
char bridge_name[16], ib[8];
|
||||
char *p = bridge_name;
|
||||
struct uci_section *dmmap_network;
|
||||
|
||||
last_instance = get_last_instance_lev2("network", "interface", "bridge_instance", "type", "bridge");
|
||||
check_create_dmmap_package("dmmap_network");
|
||||
last_instance = get_last_instance_lev2_icwmpd("network", "interface", "dmmap_network", "bridge_instance", "type", "bridge");
|
||||
sprintf(ib, "%d", last_instance ? atoi(last_instance)+1 : 1);
|
||||
dmstrappendstr(p, "bridge_0_");
|
||||
dmstrappendstr(p, ib);
|
||||
|
|
@ -1125,21 +1136,25 @@ int add_layer2bridging_bridge(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
dmuci_set_value("network", bridge_name, "", "interface");
|
||||
dmuci_set_value("network", bridge_name, "type", "bridge");
|
||||
dmuci_set_value("network", bridge_name, "proto", "dhcp");
|
||||
*instance = dmuci_set_value("network", bridge_name, "bridge_instance", ib);
|
||||
|
||||
dmuci_add_section_icwmpd("dmmap_network", "interface", &dmmap_network, &v);
|
||||
dmuci_set_value_by_section(dmmap_network, "section_name", bridge_name);
|
||||
*instance = dmuci_set_value_by_section(dmmap_network, "bridge_instance", ib);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int delete_layer2bridging_bridge(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
|
||||
{
|
||||
struct args_layer2 *args_bridge = (struct args_layer2 *)data;
|
||||
struct uci_section *bridge_s, *vlan_s, *prev_s = NULL;
|
||||
struct uci_section *bridge_s, *vlan_s, *prev_s = NULL, *dmmap_section= NULL;
|
||||
char *bridgekey = NULL, *bridge_instance;
|
||||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
dmuci_get_value_by_section_string(args_bridge->layer2section, "bridge_instance", &bridge_instance);
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(args_bridge->layer2section), &dmmap_section);
|
||||
dmuci_get_value_by_section_string(dmmap_section, "bridge_instance", &bridge_instance);
|
||||
dmuci_set_value_by_section(args_bridge->layer2section, "type", "");
|
||||
dmuci_set_value_by_section(args_bridge->layer2section, "bridge_instance", "");
|
||||
DMUCI_DELETE_BY_SECTION(icwmpd, dmmap_section, NULL, NULL);
|
||||
uci_path_foreach_option_eq(icwmpd, "dmmap", "vlan_bridge", "bridgekey", bridge_instance, vlan_s) {
|
||||
if (prev_s)
|
||||
DMUCI_DELETE_BY_SECTION(icwmpd, prev_s, NULL, NULL);
|
||||
|
|
@ -1150,8 +1165,9 @@ int delete_layer2bridging_bridge(char *refparam, struct dmctx *ctx, void *data,
|
|||
return 0;
|
||||
case DEL_ALL:
|
||||
uci_foreach_option_eq("network", "interface", "type", "bridge", bridge_s) {
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(bridge_s), &dmmap_section);
|
||||
dmuci_set_value_by_section(bridge_s, "type", "");
|
||||
dmuci_set_value_by_section(bridge_s, "bridge_instance", "");
|
||||
DMUCI_DELETE_BY_SECTION(icwmpd, dmmap_section, NULL, NULL);
|
||||
}
|
||||
uci_path_foreach_sections(icwmpd, "dmmap", "vlan_bridge", vlan_s) {
|
||||
if(prev_s != NULL && bridgekey[0] != '\0')
|
||||
|
|
@ -1395,17 +1411,23 @@ int set_marking_alias(char *refparam, struct dmctx *ctx, void *data, char *insta
|
|||
|
||||
int get_bridge_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct args_layer2 *)data)->layer2section, "bridge_alias", value);
|
||||
struct uci_section *dmmap_section;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct args_layer2 *)data)->layer2section), &dmmap_section);
|
||||
dmuci_get_value_by_section_string(dmmap_section, "bridge_alias", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_bridge_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct uci_section *dmmap_section;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct args_layer2 *)data)->layer2section), &dmmap_section);
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct args_layer2 *)data)->layer2section, "bridge_alias", value);
|
||||
dmuci_set_value_by_section(dmmap_section, "bridge_alias", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -745,12 +745,18 @@ int set_ip_int_alias(char *refparam, struct dmctx *ctx, void *data, char *instan
|
|||
|
||||
int get_ipv4_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "ipv4_alias", value);
|
||||
struct uci_section *dmmap_section;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct ip_args *)data)->ip_sec), &dmmap_section);
|
||||
dmuci_get_value_by_section_string(dmmap_section, "ipv4_alias", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_ipv4_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct uci_section *dmmap_section;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct ip_args *)data)->ip_sec), &dmmap_section);
|
||||
char *proto;
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
|
|
@ -758,7 +764,7 @@ int set_ipv4_alias(char *refparam, struct dmctx *ctx, void *data, char *instance
|
|||
case VALUESET:
|
||||
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "proto", &proto);
|
||||
if(strcmp(proto, "static") == 0)
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipv4_alias", value);
|
||||
dmuci_set_value_by_section(dmmap_section, "ipv4_alias", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -766,20 +772,26 @@ int set_ipv4_alias(char *refparam, struct dmctx *ctx, void *data, char *instance
|
|||
|
||||
int get_ipv6_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "ipv6_alias", value);
|
||||
struct uci_section *dmmap_section;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct ip_args *)data)->ip_sec), &dmmap_section);
|
||||
dmuci_get_value_by_section_string(dmmap_section, "ipv6_alias", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_ipv6_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *proto;
|
||||
struct uci_section *dmmap_section;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct ip_args *)data)->ip_sec), &dmmap_section);
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "proto", &proto);
|
||||
if(strcmp(proto, "static") == 0)
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipv6_alias", value);
|
||||
dmuci_set_value_by_section(dmmap_section, "ipv6_alias", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -787,51 +799,87 @@ int set_ipv6_alias(char *refparam, struct dmctx *ctx, void *data, char *instance
|
|||
/*************************************************************
|
||||
* ADD & DEL OBJ
|
||||
/*************************************************************/
|
||||
char *get_last_instance_cond(char *package, char *section, char *opt_inst, char *opt_cond, char *cond_val, char *opt_filter, char *filter_val)
|
||||
char *get_last_instance_cond(char* dmmap_package, char *package, char *section, char *opt_inst, char *opt_cond, char *cond_val, char *opt_filter, char *filter_val, char *refused_interface)
|
||||
{
|
||||
struct uci_section *s;
|
||||
struct uci_section *s, *dmmap_section;
|
||||
char *inst = NULL, *val, *val_f;
|
||||
char *type, *ipv4addr = "", *ipv6addr = "", *proto;
|
||||
json_object *res, *jobj;
|
||||
|
||||
uci_foreach_sections(package, section, s) {
|
||||
if (opt_cond) dmuci_get_value_by_section_string(s, opt_cond, &val);
|
||||
if (opt_filter) dmuci_get_value_by_section_string(s, opt_filter, &val_f);
|
||||
if(opt_cond && opt_filter && (strcmp(val, cond_val) == 0 || strcmp(val_f, filter_val) == 0))
|
||||
continue;
|
||||
inst = update_instance(s, inst, opt_inst);
|
||||
if (strcmp(section_name(s), refused_interface)==0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "ipaddr", &ipv4addr);
|
||||
if (ipv4addr[0] == '\0') {
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(s), String}}, 1, &res);
|
||||
if (res)
|
||||
{
|
||||
jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address");
|
||||
ipv4addr = dmjson_get_value(jobj, 1, "address");
|
||||
}
|
||||
}
|
||||
dmuci_get_value_by_section_string(s, "ip6addr", &ipv6addr);
|
||||
if (ipv6addr[0] == '\0') {
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(s), String}}, 1, &res);
|
||||
if (res)
|
||||
{
|
||||
jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv6-address");
|
||||
ipv6addr = dmjson_get_value(jobj, 1, "address");
|
||||
}
|
||||
}
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
if (ipv4addr[0] == '\0' && ipv6addr[0] == '\0' && strcmp(proto, "dhcp") != 0 && strcmp(proto, "dhcpv6") != 0 && strcmp(val, "bridge") != 0) {
|
||||
continue;
|
||||
}
|
||||
get_dmmap_section_of_config_section(dmmap_package, section, section_name(s), &dmmap_section);
|
||||
inst = update_instance_icwmpd(dmmap_section, inst, opt_inst);
|
||||
}
|
||||
return inst;
|
||||
}
|
||||
|
||||
int add_ip_interface(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *last_inst;
|
||||
char *last_inst, *v;
|
||||
char ip_name[32], ib[8];
|
||||
char *p = ip_name;
|
||||
struct uci_section *dmmap_ip_interface, *dmmap_section;
|
||||
|
||||
last_inst = get_last_instance_cond("network", "interface", "ip_int_instance", "type", "alias", "proto", "");
|
||||
last_inst = get_last_instance_cond("dmmap_network", "network", "interface", "ip_int_instance", "type", "alias", "proto", "", "loopback");
|
||||
sprintf(ib, "%d", last_inst ? atoi(last_inst)+1 : 1);
|
||||
dmstrappendstr(p, "ip_interface_");
|
||||
dmstrappendstr(p, ib);
|
||||
dmstrappendend(p);
|
||||
dmuci_set_value("network", ip_name, "", "interface");
|
||||
dmuci_set_value("network", ip_name, "proto", "dhcp");
|
||||
*instance = dmuci_set_value("network", ip_name, "ip_int_instance", ib);
|
||||
|
||||
dmuci_add_section_icwmpd("dmmap_network", "interface", &dmmap_ip_interface, &v);
|
||||
dmuci_set_value_by_section(dmmap_ip_interface, "section_name", ip_name);
|
||||
*instance = update_instance_icwmpd(dmmap_ip_interface, last_inst, "ip_int_instance");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int delete_ip_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
|
||||
{
|
||||
struct uci_section *dmmap_section;
|
||||
|
||||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "proto", "");
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "type", "");
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "bridge_instance", "");
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ip_int_instance", "");
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipv4_instance", "");
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipv6_instance", "");
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ifname", "");
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipaddr", "");
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ip6addr", "");
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct ip_args *)data)->ip_sec), &dmmap_section);
|
||||
dmuci_set_value_by_section(dmmap_section, "ip_int_instance", "");
|
||||
dmuci_set_value_by_section(dmmap_section, "ipv4_instance", "");
|
||||
dmuci_set_value_by_section(dmmap_section, "ipv6_instance", "");
|
||||
break;
|
||||
case DEL_ALL:
|
||||
return FAULT_9005;
|
||||
|
|
@ -842,11 +890,13 @@ int delete_ip_interface(char *refparam, struct dmctx *ctx, void *data, char *ins
|
|||
int add_ipv4(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
|
||||
{
|
||||
char *instance;
|
||||
struct uci_section *dmmap_section;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "ipv4_instance", &instance);
|
||||
*instancepara = update_instance(((struct ip_args *)data)->ip_sec, instance, "ipv4_instance");
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct ip_args *)data)->ip_sec), &dmmap_section);
|
||||
dmuci_get_value_by_section_string(dmmap_section, "ipv4_instance", &instance);
|
||||
*instancepara = update_instance_icwmpd(dmmap_section, instance, "ipv4_instance");
|
||||
if(instance[0] == '\0') {
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipv4_instance", *instancepara);
|
||||
dmuci_set_value_by_section(dmmap_section, "ipv4_instance", *instancepara);
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipaddr", "0.0.0.0");
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "proto", "static");
|
||||
}
|
||||
|
|
@ -855,10 +905,13 @@ int add_ipv4(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
|
|||
|
||||
int delete_ipv4(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
|
||||
{
|
||||
struct uci_section *dmmap_section;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct ip_args *)data)->ip_sec), &dmmap_section);
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipaddr", "");
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipv4_instance", "");
|
||||
dmuci_set_value_by_section(dmmap_section, "ipv4_instance", "");
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "proto", "");
|
||||
break;
|
||||
case DEL_ALL:
|
||||
|
|
@ -870,12 +923,14 @@ int delete_ipv4(char *refparam, struct dmctx *ctx, void *data, char *instance, u
|
|||
int add_ipv6(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
|
||||
{
|
||||
char *instance;
|
||||
struct uci_section *dmmap_section;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct ip_args *)data)->ip_sec), &dmmap_section);
|
||||
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "ipv6_instance", &instance);
|
||||
*instancepara = update_instance(((struct ip_args *)data)->ip_sec, instance, "ipv6_instance");
|
||||
if(instance[0] == '\0') {
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipv6_instance", *instancepara);
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ip6addr", "::");
|
||||
dmuci_set_value_by_section(dmmap_section, "ip6addr", "::");
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "proto", "static");
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -883,10 +938,13 @@ int add_ipv6(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
|
|||
|
||||
int delete_ipv6(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
|
||||
{
|
||||
struct uci_section *dmmap_section;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct ip_args *)data)->ip_sec), &dmmap_section);
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ip6addr", "");
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipv6_instance", "");
|
||||
dmuci_set_value_by_section(dmmap_section, "ipv6_instance", "");
|
||||
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "proto", "");
|
||||
break;
|
||||
case DEL_ALL:
|
||||
|
|
@ -917,36 +975,39 @@ int browseIPIfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data,
|
|||
char *type, *ipv4addr = "", *ipv6addr = "", *proto, *inst;
|
||||
json_object *res, *jobj;
|
||||
struct ip_args curr_ip_args = {0};
|
||||
struct dmmap_dup *p;
|
||||
LIST_HEAD(dup_list);
|
||||
|
||||
uci_foreach_sections("network", "interface", net_sec) {
|
||||
dmuci_get_value_by_section_string(net_sec, "type", &type);
|
||||
if (!strcmp(type, "alias") || !strcmp(section_name(net_sec), "loopback"))
|
||||
synchronize_specific_config_sections_with_dmmap("network", "interface", "dmmap_network", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
dmuci_get_value_by_section_string(p->config_section, "type", &type);
|
||||
if (strcmp(type, "alias") == 0 || strcmp(section_name(p->config_section), "loopback")==0)
|
||||
continue;
|
||||
dmuci_get_value_by_section_string(net_sec, "ipaddr", &ipv4addr);
|
||||
dmuci_get_value_by_section_string(p->config_section, "ipaddr", &ipv4addr);
|
||||
if (ipv4addr[0] == '\0') {
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(net_sec), String}}, 1, &res);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(p->config_section), String}}, 1, &res);
|
||||
if (res)
|
||||
{
|
||||
jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address");
|
||||
ipv4addr = dmjson_get_value(jobj, 1, "address");
|
||||
}
|
||||
}
|
||||
dmuci_get_value_by_section_string(net_sec, "ip6addr", &ipv6addr);
|
||||
dmuci_get_value_by_section_string(p->config_section, "ip6addr", &ipv6addr);
|
||||
if (ipv6addr[0] == '\0') {
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(net_sec), String}}, 1, &res);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(p->config_section), String}}, 1, &res);
|
||||
if (res)
|
||||
{
|
||||
jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv6-address");
|
||||
ipv6addr = dmjson_get_value(jobj, 1, "address");
|
||||
}
|
||||
}
|
||||
dmuci_get_value_by_section_string(net_sec, "proto", &proto);
|
||||
dmuci_get_value_by_section_string(net_sec, "ip_int_instance", &inst);
|
||||
dmuci_get_value_by_section_string(p->config_section, "proto", &proto);
|
||||
dmuci_get_value_by_section_string(p->config_section, "ip_int_instance", &inst);
|
||||
if (ipv4addr[0] == '\0' && ipv6addr[0] == '\0' && strcmp(proto, "dhcp") != 0 && strcmp(proto, "dhcpv6") != 0 && strcmp(inst, "") == 0 && strcmp(type, "bridge") != 0) {
|
||||
continue;
|
||||
}
|
||||
init_ip_args(&curr_ip_args, net_sec, ipv4addr, ipv6addr);
|
||||
ip_int = handle_update_instance(1, dmctx, &ip_int_last, update_instance_alias, 3, net_sec, "ip_int_instance", "ip_int_alias");
|
||||
init_ip_args(&curr_ip_args, p->config_section, ipv4addr, ipv6addr);
|
||||
ip_int = handle_update_instance(1, dmctx, &ip_int_last, update_instance_alias, 3, p->dmmap_section, "ip_int_instance", "ip_int_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_ip_args, ip_int) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
|
|
@ -956,9 +1017,11 @@ int browseIPIfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data,
|
|||
int browseIfaceIPv4Inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
char *ipv4_inst = NULL, *ipv4_inst_last = NULL;
|
||||
struct uci_section *dmmap_section;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct ip_args *)prev_data)->ip_sec), &dmmap_section);
|
||||
if(((struct ip_args *)prev_data)->ip_4address[0] != '\0') {
|
||||
ipv4_inst = handle_update_instance(2, dmctx, &ipv4_inst_last, update_instance_alias, 3, ((struct ip_args *)prev_data)->ip_sec, "ipv4_instance", "ipv4_alias");
|
||||
ipv4_inst = handle_update_instance(2, dmctx, &ipv4_inst_last, update_instance_alias, 3, dmmap_section, "ipv4_instance", "ipv4_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, prev_data, ipv4_inst) == DM_STOP)
|
||||
goto end;
|
||||
}
|
||||
|
|
@ -969,9 +1032,11 @@ end:
|
|||
int browseIfaceIPv6Inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
char *ipv6_inst = NULL, *ipv6_inst_last = NULL;
|
||||
struct uci_section *dmmap_section;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct ip_args *)prev_data)->ip_sec), &dmmap_section);
|
||||
if (((struct ip_args *)prev_data)->ip_6address[0] != '\0') {
|
||||
ipv6_inst = handle_update_instance(2, dmctx, &ipv6_inst_last, update_instance_alias, 3, ((struct ip_args *)prev_data)->ip_sec, "ipv6_instance", "ipv6_alias");
|
||||
ipv6_inst = handle_update_instance(2, dmctx, &ipv6_inst_last, update_instance_alias, 3, dmmap_section, "ipv6_instance", "ipv6_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, prev_data, ipv6_inst) == DM_STOP)
|
||||
goto end;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue