mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
PPP: update implementation
- Don't create a network interface when adding a new instance, so the network interface will only be managed with 'Device.IP.Interface.' object
- Fix Get/Set methods of 'PPP.Interface.{i}.LowerLayers'
- Added support for setting 'IP.Interface.{i}.LowerLayers' to 'PPP.Interface.'
- Added support for setting 'Ethernet.Link.{i}.LowerLayers' to 'ATM.Link.' or 'PTM.Link.'
This commit is contained in:
parent
2758c0380e
commit
587d5f14b8
4 changed files with 602 additions and 270 deletions
|
|
@ -167,6 +167,7 @@ static void add_new_dmmap_section(char *macaddr, char*interface, char *section_n
|
|||
dmuci_add_section_bbfdm(DMMAP, "link", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "mac", macaddr);
|
||||
dmuci_set_value_by_section(dmmap, "device", interface);
|
||||
dmuci_set_value_by_section(dmmap, "is_eth", (!strncmp(interface, "atm", 3) || !strncmp(interface, "ptm", 3)) ? "0" : "1");
|
||||
dmuci_set_value_by_section(dmmap, "section_name", section_name);
|
||||
}
|
||||
|
||||
|
|
@ -975,6 +976,14 @@ static int get_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void
|
|||
if (!linker || *linker == '\0')
|
||||
return 0;
|
||||
|
||||
adm_entry_get_linker_param(ctx, "Device.ATM.Link.", linker, value);
|
||||
if (*value != NULL && (*value)[0] != 0)
|
||||
return 0;
|
||||
|
||||
adm_entry_get_linker_param(ctx, "Device.PTM.Link.", linker, value);
|
||||
if (*value != NULL && (*value)[0] != 0)
|
||||
return 0;
|
||||
|
||||
// get device section mapped to this device name
|
||||
struct uci_section *br_device_s = ethernet___get_device_section(linker);
|
||||
|
||||
|
|
@ -1028,18 +1037,39 @@ static int set_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
if (!link_linker || link_linker[0] == 0) {
|
||||
dmuci_set_value_by_section((struct uci_section *)data, "device", "");
|
||||
} else if (strncmp(value, eth_interface, strlen(eth_interface)) == 0) {
|
||||
struct uci_section *s = NULL;
|
||||
char *int_name = NULL;
|
||||
} else if (strncmp(value, eth_interface, strlen(eth_interface)) == 0 ||
|
||||
strncmp(value, atm_link, strlen(atm_link)) == 0 ||
|
||||
strncmp(value, ptm_link, strlen(ptm_link)) == 0) {
|
||||
|
||||
char *iface_name = NULL;
|
||||
|
||||
dmuci_set_value_by_section((struct uci_section *)data, "device", link_linker);
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "section_name", &int_name);
|
||||
dmuci_set_value_by_section((struct uci_section *)data, "is_eth", !strncmp(value, eth_interface, strlen(eth_interface)) ? "1" : "0");
|
||||
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
if (strcmp(section_name(s), int_name) == 0) {
|
||||
// Check if there is a IP.Interface linked to this Ethernet.Link
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "section_name", &iface_name);
|
||||
if (DM_STRLEN(iface_name)) {
|
||||
struct uci_section *s = get_origin_section_from_config("network", "interface", iface_name);
|
||||
dmuci_set_value_by_section(s, "device", link_linker);
|
||||
break;
|
||||
}
|
||||
|
||||
// Check if there is a PPP.Interface linked to this Ethernet.Link
|
||||
struct uci_section *ppp_s = get_dup_section_in_dmmap_opt("dmmap_ppp", "interface", "device", link_linker);
|
||||
if (ppp_s == NULL) {
|
||||
char *default_linker = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "linker", &default_linker);
|
||||
ppp_s = get_dup_section_in_dmmap_opt("dmmap_ppp", "interface", "eth_link_linker", default_linker);
|
||||
}
|
||||
|
||||
if (ppp_s) {
|
||||
dmuci_get_value_by_section_string(ppp_s, "iface_name", &iface_name);
|
||||
if (DM_STRLEN(iface_name)) {
|
||||
struct uci_section *s = get_origin_section_from_config("network", "interface", iface_name);
|
||||
dmuci_set_value_by_section(s, "device", link_linker);
|
||||
}
|
||||
|
||||
dmuci_set_value_by_section(ppp_s, "device", link_linker);
|
||||
}
|
||||
} else if (strncmp(value, bridge_port, strlen(bridge_port)) == 0) {
|
||||
char br_linker[250] = {0};
|
||||
|
|
@ -1109,6 +1139,8 @@ static int set_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
dmuci_set_value_by_section((struct uci_section *)data, "device", device_name ? device_name : "");
|
||||
}
|
||||
|
||||
dmuci_set_value_by_section((struct uci_section *)data, "is_eth", "1");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -1353,9 +1385,13 @@ static int set_EthernetVLANTermination_LowerLayers(char *refparam, struct dmctx
|
|||
} else if (strncmp(value, eth_link, strlen(eth_link)) == 0) {
|
||||
char new_name[16] = {0}, *type;
|
||||
char *iface_name = NULL;
|
||||
char *old_name = NULL;
|
||||
char *vid = NULL;
|
||||
|
||||
// Get type option from device section
|
||||
// Get type, name and vid options from the current device section
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "type", &type);
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "name", &old_name);
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "vid", &vid);
|
||||
|
||||
if ((strcmp(type, "macvlan") == 0)) {
|
||||
/* type == macvlan */
|
||||
|
|
@ -1382,10 +1418,7 @@ static int set_EthernetVLANTermination_LowerLayers(char *refparam, struct dmctx
|
|||
} else {
|
||||
/* type != macvlan */
|
||||
struct uci_section *s = NULL;
|
||||
char *vid = NULL, *old_name = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "name", &old_name);
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "vid", &vid);
|
||||
if (vid && *vid != '\0')
|
||||
snprintf(new_name, sizeof(new_name), "%s.%s", vlan_linker, vid);
|
||||
else
|
||||
|
|
@ -1404,7 +1437,7 @@ static int set_EthernetVLANTermination_LowerLayers(char *refparam, struct dmctx
|
|||
}
|
||||
}
|
||||
|
||||
// Update interface->device option linked to this VLANTermination if exists
|
||||
// Check if there is an IP.Interface linked to this VLANTermination
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, "iface_name", &iface_name);
|
||||
if (iface_name && *iface_name != 0) {
|
||||
struct uci_section *s = get_origin_section_from_config("network", "interface", iface_name);
|
||||
|
|
@ -1412,6 +1445,27 @@ static int set_EthernetVLANTermination_LowerLayers(char *refparam, struct dmctx
|
|||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "iface_name", "");
|
||||
}
|
||||
|
||||
// Check if there is a PPP.Interface linked to this VLANTermination
|
||||
if (old_name && *old_name != 0) {
|
||||
struct uci_section *ppp_s = get_dup_section_in_dmmap_opt("dmmap_ppp", "interface", "device", old_name);
|
||||
if (ppp_s == NULL) {
|
||||
char *default_linker = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, "default_linker", &default_linker);
|
||||
ppp_s = get_dup_section_in_dmmap_opt("dmmap_ppp", "interface", "vlan_ter_linker", default_linker);
|
||||
}
|
||||
|
||||
if (ppp_s) {
|
||||
dmuci_get_value_by_section_string(ppp_s, "iface_name", &iface_name);
|
||||
if (DM_STRLEN(iface_name)) {
|
||||
struct uci_section *s = get_origin_section_from_config("network", "interface", iface_name);
|
||||
dmuci_set_value_by_section(s, "device", new_name);
|
||||
}
|
||||
|
||||
dmuci_set_value_by_section(ppp_s, "device", new_name);
|
||||
}
|
||||
}
|
||||
|
||||
// Set ifname and name options of device section
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ifname", vlan_linker);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "name", new_name);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "ppp.h"
|
||||
#include "ip.h"
|
||||
#include "dmentry.h"
|
||||
#ifdef BBF_TR143
|
||||
|
|
@ -315,6 +316,7 @@ static int delete_ip_intertace_instance(struct uci_section *s)
|
|||
struct uci_section *ss = NULL;
|
||||
struct uci_section *stmp = NULL;
|
||||
char *int_device = NULL;
|
||||
char *proto = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(int_ss, "device", &int_device);
|
||||
if (strcmp(section_name(int_ss), int_sec_name) != 0 && strcmp(int_device, buf) != 0)
|
||||
|
|
@ -364,20 +366,20 @@ static int delete_ip_intertace_instance(struct uci_section *s)
|
|||
dmuci_delete_by_section(ss, NULL, NULL);
|
||||
}
|
||||
|
||||
/* Remove "DHCPv4.Client.{i}.ReqOption." sections related to this "IP.Interface." object */
|
||||
uci_path_foreach_option_eq_safe(bbfdm, "dmmap_dhcp_client", "req_option", "section_name", section_name(int_ss), stmp, ss) {
|
||||
dmuci_delete_by_section(ss, NULL, NULL);
|
||||
}
|
||||
dmuci_get_value_by_section_string(int_ss, "proto", &proto);
|
||||
|
||||
/* Remove "DHCPv4.Client.{i}.SentOption." sections related to this "IP.Interface." object */
|
||||
uci_path_foreach_option_eq_safe(bbfdm, "dmmap_dhcp_client", "send_option", "section_name", section_name(int_ss), stmp, ss) {
|
||||
dmuci_delete_by_section(ss, NULL, NULL);
|
||||
if (strncmp(proto, "ppp", 3) == 0) {
|
||||
struct uci_section *ppp_s = get_dup_section_in_dmmap_opt("dmmap_ppp", "interface", "iface_name", section_name(int_ss));
|
||||
|
||||
if (ppp_s) {
|
||||
|
||||
/* Remove "PPP.Interface." section related to this "IP.Interface." object */
|
||||
dmuci_delete_by_section(ppp_s, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* remove interface section */
|
||||
dmuci_delete_by_section(int_ss, NULL, NULL);
|
||||
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1246,7 +1248,7 @@ static int get_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
|
|||
char *proto;
|
||||
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "proto", &proto);
|
||||
if (strstr(proto, "ppp")) {
|
||||
if (strncmp(proto, "ppp", 3) == 0) {
|
||||
snprintf(linker, sizeof(linker), "%s", section_name((struct uci_section *)data));
|
||||
adm_entry_get_linker_param(ctx, "Device.PPP.Interface.", linker, value);
|
||||
if (*value != NULL && (*value)[0] != 0)
|
||||
|
|
@ -1293,9 +1295,11 @@ static int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
|
|||
struct uci_section *dmmap_section = NULL;
|
||||
char eth_vlan_term[64] = "Device.Ethernet.VLANTermination.";
|
||||
char eth_link[32] = "Device.Ethernet.Link.";
|
||||
char ppp_iface[32] = "Device.PPP.Interface.";
|
||||
char *allowed_objects[] = {
|
||||
eth_vlan_term,
|
||||
eth_link,
|
||||
ppp_iface,
|
||||
NULL};
|
||||
char linker_buf[32] = {0};
|
||||
char *ip_linker = NULL;
|
||||
|
|
@ -1317,8 +1321,21 @@ static int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
|
|||
dmuci_set_value_by_section(dmmap_section, "LowerLayers", value);
|
||||
|
||||
if (!ip_linker || *ip_linker == 0) {
|
||||
char *curr_proto = NULL;
|
||||
|
||||
// Update device option
|
||||
dmuci_set_value_by_section((struct uci_section *)data, "device", "");
|
||||
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "proto", &curr_proto);
|
||||
if (strncmp(curr_proto, "ppp", 3) == 0) {
|
||||
struct uci_section *ppp_s = NULL;
|
||||
|
||||
ppp_s = get_dup_section_in_dmmap_opt("dmmap_ppp", "interface", "iface_name", section_name((struct uci_section *)data));
|
||||
dmuci_set_value_by_section_bbfdm(ppp_s, "iface_name", "");
|
||||
|
||||
dmuci_set_value_by_section((struct uci_section *)data, "proto", "none");
|
||||
ppp___reset_options((struct uci_section *)data);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1436,6 +1453,17 @@ static int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
|
|||
|
||||
set_ip_interface_device_option((struct uci_section *)data, linker_buf, instance, is_br_sec);
|
||||
}
|
||||
} else if (strncmp(value, ppp_iface, strlen(ppp_iface)) == 0) {
|
||||
struct uci_section *ppp_s = get_dup_section_in_dmmap_opt("dmmap_ppp", "interface", "name", linker_buf);
|
||||
if (ppp_s == NULL)
|
||||
ppp_s = get_dup_section_in_dmmap_opt("dmmap_ppp", "interface", "iface_name", linker_buf);
|
||||
|
||||
if (ppp_s == NULL)
|
||||
break;
|
||||
|
||||
dmuci_set_value_by_section_bbfdm(ppp_s, "iface_name", section_name((struct uci_section *)data));
|
||||
|
||||
ppp___update_sections(ppp_s, (struct uci_section *)data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -26,4 +26,7 @@ extern DMLEAF tPPPInterfaceIPCPParams[];
|
|||
extern DMLEAF tPPPInterfaceIPv6CPParams[];
|
||||
extern DMLEAF tPPPInterfaceStatsParams[];
|
||||
|
||||
void ppp___update_sections(struct uci_section *s_from, struct uci_section *s_to);
|
||||
void ppp___reset_options(struct uci_section *ppp_s);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue