mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2026-03-04 08:24:01 +01:00
Ticket refs #14406: TR-069: Move TR related UCI options from original config to /etc/icwmpd/dmmap (Device.PPP.Interface.x. Device.NAT.InterfaceSetting.x. Device.WiFi.SSID.x)
This commit is contained in:
parent
6ca126e85f
commit
fb4f27b589
5 changed files with 95 additions and 35 deletions
|
|
@ -1061,3 +1061,17 @@ void get_dmmap_section_of_config_section(char* dmmap_package, char* section_type
|
|||
}
|
||||
*dmmap_section= NULL;
|
||||
}
|
||||
|
||||
void check_create_dmmap_package(char *dmmap_package){
|
||||
FILE *fp;
|
||||
char *dmmap_file_path;
|
||||
|
||||
dmasprintf(&dmmap_file_path, "/etc/icwmpd/%s", dmmap_package);
|
||||
if (access(dmmap_file_path, F_OK)) {
|
||||
/*
|
||||
*File does not exist
|
||||
**/
|
||||
fp = fopen(dmmap_file_path, "w"); // new empty file
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,5 +155,6 @@ void free_dmmap_config_dup_list(struct list_head *dup_list);
|
|||
void synchronize_specific_config_sections_with_dmmap(char *package, char *section_type, char *dmmap_package, struct list_head *dup_list);
|
||||
void synchronize_specific_config_sections_with_dmmap_eq(char *package, char *section_type, char *dmmap_package,char* option_name, char* option_value, struct list_head *dup_list);
|
||||
void get_dmmap_section_of_config_section(char* dmmap_package, char* section_type, char *section_name, struct uci_section **dmmap_section);
|
||||
void check_create_dmmap_package(char *dmmap_package);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -42,19 +42,23 @@ int get_nat_enable(char *refparam, struct dmctx *ctx, void *data, char *instance
|
|||
|
||||
int get_nat_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct uci_section *int_sec = (struct uci_section *)data;
|
||||
dmuci_get_value_by_section_string(int_sec, "natalias", value);
|
||||
struct uci_section *dmmap_section;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name((struct uci_section *)data), &dmmap_section);
|
||||
dmuci_get_value_by_section_string(dmmap_section, "natalias", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_nat_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct uci_section *int_sec = (struct uci_section *)data;
|
||||
struct uci_section *dmmap_section;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name((struct uci_section *)data), &dmmap_section);
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(int_sec, "natalias", value);
|
||||
dmuci_set_value_by_section(dmmap_section, "natalias", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -78,7 +82,7 @@ int get_nat_last_inst()
|
|||
struct uci_section *s;
|
||||
int cnt = 0;
|
||||
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
uci_foreach_sections("dmmap_network", "interface", s) {
|
||||
dmuci_get_value_by_section_string(s, "natinstance", &tmp);
|
||||
if (tmp[0] == '\0')
|
||||
continue;
|
||||
|
|
@ -114,14 +118,14 @@ char *nat_update_instance_alias(int action, char **last_inst, void *argv[])
|
|||
else {
|
||||
sprintf(buf, "%d", atoi(*last_inst)+1);
|
||||
}
|
||||
instance = dmuci_set_value_by_section(s, inst_opt, buf);
|
||||
instance= DMUCI_SET_VALUE_BY_SECTION(icwmpd, s, inst_opt, buf);
|
||||
}
|
||||
*last_inst = instance;
|
||||
if (action == INSTANCE_MODE_ALIAS) {
|
||||
dmuci_get_value_by_section_string(s, alias_opt, &alias);
|
||||
if (alias[0] == '\0') {
|
||||
sprintf(buf, "cpe-%s", instance);
|
||||
alias = dmuci_set_value_by_section(s, alias_opt, buf);
|
||||
alias = DMUCI_SET_VALUE_BY_SECTION(icwmpd, s, alias_opt, buf);
|
||||
}
|
||||
sprintf(buf, "[%s]", alias);
|
||||
instance = dmstrdup(buf);
|
||||
|
|
@ -136,22 +140,27 @@ char *nat_update_instance_alias(int action, char **last_inst, void *argv[])
|
|||
|
||||
int browseInterfaceSettingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct uci_section *net_sec = NULL, *s = NULL;
|
||||
char *nat = NULL;
|
||||
char *nati, *nati_last = NULL;
|
||||
struct uci_section *net_sec = NULL, *s = NULL, *dmmap_sect;
|
||||
char *nat = NULL, *instance= NULL;
|
||||
char *nati, *nati_last = NULL, *v= NULL, *stmp= NULL;
|
||||
int id = 0;
|
||||
bool find_max = true;
|
||||
uci_foreach_sections("network", "interface", net_sec) {
|
||||
uci_foreach_list_cont("firewall", "zone", "network", section_name(net_sec), s) {
|
||||
struct dmmap_dup *p;
|
||||
LIST_HEAD(dup_list);
|
||||
|
||||
synchronize_specific_config_sections_with_dmmap("network", "interface", "dmmap_network", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
uci_foreach_list_cont("firewall", "zone", "network", section_name(p->config_section), s) {
|
||||
dmuci_get_value_by_section_string(s, "masq", &nat);
|
||||
if(nat[0] == '1') {
|
||||
nati = handle_update_instance(1, dmctx, &nati_last, nat_update_instance_alias, 4, net_sec, "natinstance", "natalias", &find_max);
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)net_sec, nati) == DM_STOP)
|
||||
nati = handle_update_instance(1, dmctx, &nati_last, nat_update_instance_alias, 4, p->dmmap_section, "natinstance", "natalias", &find_max);
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, nati) == DM_STOP)
|
||||
goto end;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
free_dmmap_config_dup_list(&dup_list);
|
||||
end:
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,17 +62,23 @@ DMLEAF tStatsParam[] = {
|
|||
|
||||
int get_ppp_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct uci_section *)data), "ppp_int_alias", value);
|
||||
struct uci_section *dmmap_section;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name((struct uci_section *)data), &dmmap_section);
|
||||
dmuci_get_value_by_section_string(dmmap_section, "ppp_int_alias", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_ppp_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 uci_section *)data), &dmmap_section);
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct uci_section *)data), "ppp_int_alias", value);
|
||||
dmuci_set_value_by_section(dmmap_section, "ppp_int_alias", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -252,15 +258,19 @@ int browseInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_dat
|
|||
struct uci_section *net_sec = NULL;
|
||||
char *ppp_int = NULL, *ppp_int_last = NULL;
|
||||
char *proto;
|
||||
struct dmmap_dup *p;
|
||||
LIST_HEAD(dup_list);
|
||||
|
||||
uci_foreach_sections("network", "interface", net_sec) {
|
||||
dmuci_get_value_by_section_string(net_sec, "proto", &proto);
|
||||
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, "proto", &proto);
|
||||
if (!strstr(proto, "ppp"))
|
||||
continue;
|
||||
ppp_int = handle_update_instance(1, dmctx, &ppp_int_last, update_instance_alias, 3, net_sec, "ppp_int_instance", "ppp_int_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)net_sec, ppp_int) == DM_STOP)
|
||||
ppp_int = handle_update_instance(1, dmctx, &ppp_int_last, update_instance_alias, 3, p->dmmap_section, "ppp_int_instance", "ppp_int_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, ppp_int) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
free_dmmap_config_dup_list(&dup_list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1475,17 +1475,23 @@ static int set_radio_alias(char *refparam, struct dmctx *ctx, void *data, char *
|
|||
|
||||
int get_ssid_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct wifi_ssid_args *)data)->wifi_ssid_sec, "ssidalias", value);
|
||||
struct uci_section *dmmap_section;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_wireless", "wifi-iface", section_name(((struct wifi_ssid_args *)data)->wifi_ssid_sec), &dmmap_section);
|
||||
dmuci_get_value_by_section_string(dmmap_section, "ssidalias", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_ssid_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_wireless", "wifi-iface", section_name(((struct wifi_ssid_args *)data)->wifi_ssid_sec), &dmmap_section);
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct wifi_ssid_args *)data)->wifi_ssid_sec, "ssidalias", value);
|
||||
dmuci_set_value_by_section(dmmap_section, "ssidalias", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -1556,12 +1562,13 @@ int get_ap_ssid_ref(char *refparam, struct dmctx *ctx, void *data, char *instanc
|
|||
/*************************************************************/
|
||||
int add_wifi_ssid(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *value;
|
||||
char *value, *v;
|
||||
char ssid[16] = {0};
|
||||
char *inst;
|
||||
struct uci_section *s = NULL;
|
||||
|
||||
inst = get_last_instance("wireless", "wifi-iface", "ssidinstance");
|
||||
struct uci_section *dmmap_wifi=NULL;
|
||||
check_create_dmmap_package("dmmap_wireless");
|
||||
inst = get_last_instance_icwmpd("dmmap_wireless", "wifi-iface", "ssidinstance");
|
||||
sprintf(ssid, "Inteno_%d", inst ? (atoi(inst)+1) : 1);
|
||||
dmuci_add_section("wireless", "wifi-iface", &s, &value);
|
||||
dmuci_set_value_by_section(s, "device", "wl0");
|
||||
|
|
@ -1569,7 +1576,10 @@ int add_wifi_ssid(char *refparam, struct dmctx *ctx, void *data, char **instance
|
|||
dmuci_set_value_by_section(s, "macfilter", "0");
|
||||
dmuci_set_value_by_section(s, "mode", "ap");
|
||||
dmuci_set_value_by_section(s, "ssid", ssid);
|
||||
*instance = update_instance(s, inst, "ssidinstance");
|
||||
|
||||
dmuci_add_section_icwmpd("dmmap_wireless", "wifi-iface", &dmmap_wifi, &v);
|
||||
dmuci_set_value_by_section(dmmap_wifi, "section_name", section_name(s));
|
||||
*instance = update_instance_icwmpd(dmmap_wifi, inst, "ssidinstance");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1578,20 +1588,32 @@ int delete_wifi_ssid(char *refparam, struct dmctx *ctx, void *data, char *instan
|
|||
int found = 0;
|
||||
char *lan_name;
|
||||
struct uci_section *s = NULL;
|
||||
struct uci_section *ss = NULL;
|
||||
struct uci_section *ss = NULL, *dmmap_section= NULL;
|
||||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
get_dmmap_section_of_config_section("dmmap_wireless", "wifi-iface", section_name(((struct wifi_ssid_args *)data)->wifi_ssid_sec), &dmmap_section);
|
||||
if(dmmap_section != NULL)
|
||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct wifi_ssid_args *)data)->wifi_ssid_sec, NULL, NULL);
|
||||
break;
|
||||
case DEL_ALL:
|
||||
uci_foreach_sections("wireless", "wifi-iface", s) {
|
||||
if (found != 0)
|
||||
dmuci_delete_by_section(ss, NULL, NULL);
|
||||
if (found != 0){
|
||||
get_dmmap_section_of_config_section("dmmap_wireless", "wifi-iface", section_name(ss), &dmmap_section);
|
||||
if(dmmap_section != NULL)
|
||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
||||
dmuci_delete_by_section(ss, NULL, NULL);
|
||||
}
|
||||
ss = s;
|
||||
found++;
|
||||
}
|
||||
if (ss != NULL)
|
||||
if (ss != NULL){
|
||||
get_dmmap_section_of_config_section("dmmap_wireless", "wifi-iface", section_name(ss), &dmmap_section);
|
||||
if(dmmap_section != NULL)
|
||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
||||
dmuci_delete_by_section(ss, NULL, NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -1626,15 +1648,19 @@ int browseWifiSsidInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data
|
|||
struct uci_section *ss = NULL;
|
||||
json_object *res;
|
||||
struct wifi_ssid_args curr_wifi_ssid_args = {0};
|
||||
struct dmmap_dup *p;
|
||||
LIST_HEAD(dup_list);
|
||||
|
||||
uci_foreach_sections("wireless", "wifi-iface", ss) {
|
||||
dmuci_get_value_by_section_string(ss, "ifname", &ifname);
|
||||
dmuci_get_value_by_section_string(ss, "device", &linker);
|
||||
init_wifi_ssid(&curr_wifi_ssid_args, ss, ifname, linker);
|
||||
wnum = handle_update_instance(1, dmctx, &ssid_last, update_instance_alias, 3, ss, "ssidinstance", "ssidalias");
|
||||
synchronize_specific_config_sections_with_dmmap("wireless", "wifi-iface", "dmmap_wireless", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
dmuci_get_value_by_section_string(p->config_section, "ifname", &ifname);
|
||||
dmuci_get_value_by_section_string(p->config_section, "device", &linker);
|
||||
init_wifi_ssid(&curr_wifi_ssid_args, p->config_section, ifname, linker);
|
||||
wnum = handle_update_instance(1, dmctx, &ssid_last, update_instance_alias, 3, p->dmmap_section, "ssidinstance", "ssidalias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_wifi_ssid_args, wnum) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
free_dmmap_config_dup_list(&dup_list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue