mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
Move network related datamodel to netmngr
This commit is contained in:
parent
3856d77dfd
commit
50dfaa491d
23 changed files with 29 additions and 10739 deletions
|
|
@ -1,158 +0,0 @@
|
||||||
# TR181 GRE datamodel
|
|
||||||
|
|
||||||
Aim of this document is to explain how the Device.GRE.Tunnel.{i}. and Device.GRE.Tunnel.{i}.Interface.{i}. datamodel objects are mapped to network UCI.
|
|
||||||
|
|
||||||
As per the definition in TR-181:
|
|
||||||
|
|
||||||
- Device.GRE.Tunnel.{i}. allows configuration of a tunnel with respect to a certain remote IP Address.
|
|
||||||
- Device.GRE.Tunnel.{i}.Interface.{i}. allows configuration of a tunnel interface, which will have to be LowerLayer of a Device.IP.Interface.{i}. object.
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
A tunnel can be set up in five broad steps:
|
|
||||||
- Add a Device.GRE.Tunnel. object.
|
|
||||||
- Set its Device.GRE.Tunnel.{i}.RemoteEndpoints parameter.
|
|
||||||
- Add a Device.GRE.Tunnel.{i}.Interface. object.
|
|
||||||
- Set Device.GRE.Tunnel.{i}.Interface.{i}.LowerLayers to the interface with whose address we want to bind this tunnel (default is wan).
|
|
||||||
- Set up a Device.IP.Interface object.
|
|
||||||
- Set appropriate Device.IP.Interface.{i}.LowerLayers to point to above added Device.GRE.Tunnel.{i}.Interface. object.
|
|
||||||
|
|
||||||
Please compare the data model values with *ip addr* state below for a clearer picture.
|
|
||||||
|
|
||||||
### Example data model configuration
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# add IP.Interface
|
|
||||||
obuspa -c add Device.IP.Interface.
|
|
||||||
obuspa -c add Device.IP.Interface.3.IPv4Address.
|
|
||||||
obuspa -c set Device.IP.Interface.3.IPv4Address.1.IPAddress 172.17.0.5
|
|
||||||
obuspa -c set Device.IP.Interface.3.IPv4Address.1.SubnetMask 255.255.255.0
|
|
||||||
obuspa -c set Device.IP.Interface.3.IPv4Address.1.Enable 1
|
|
||||||
obuspa -c set Device.IP.Interface.3.Enable 1
|
|
||||||
|
|
||||||
# add GRE.
|
|
||||||
obuspa -c add Device.GRE.Tunnel.
|
|
||||||
obuspa -c set Device.GRE.Tunnel.1.RemoteEndpoints 10.101.52.1
|
|
||||||
obuspa -c add Device.GRE.Tunnel.1.Interface.
|
|
||||||
obuspa -c set Device.GRE.Tunnel.1.Interface.1.LowerLayers Device.IP.Interface.2.
|
|
||||||
|
|
||||||
# set IP.Interface LowerLayer
|
|
||||||
obuspa -c set Device.IP.Interface.3.LowerLayers Device.GRE.Tunnel.1.Interface.1.
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
after the above config, the object should should look as follows:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
root@iopsys:~# obuspa -c get Device.GRE.
|
|
||||||
Device.GRE.TunnelNumberOfEntries => 1
|
|
||||||
Device.GRE.Tunnel.1.Enable => 1
|
|
||||||
Device.GRE.Tunnel.1.Status => Enabled
|
|
||||||
Device.GRE.Tunnel.1.Alias => cpe-1
|
|
||||||
Device.GRE.Tunnel.1.RemoteEndpoints => 10.101.52.1
|
|
||||||
Device.GRE.Tunnel.1.DeliveryHeaderProtocol => IPv4
|
|
||||||
Device.GRE.Tunnel.1.ConnectedRemoteEndpoint => 10.101.52.1
|
|
||||||
Device.GRE.Tunnel.1.InterfaceNumberOfEntries => 1
|
|
||||||
Device.GRE.Tunnel.1.Interface.1.Enable => 1
|
|
||||||
Device.GRE.Tunnel.1.Interface.1.Status => Unknown
|
|
||||||
Device.GRE.Tunnel.1.Interface.1.Alias => cpe-1
|
|
||||||
Device.GRE.Tunnel.1.Interface.1.Name => gre_d1i1
|
|
||||||
Device.GRE.Tunnel.1.Interface.1.LastChange => 227
|
|
||||||
Device.GRE.Tunnel.1.Interface.1.LowerLayers => Device.IP.Interface.2
|
|
||||||
Device.GRE.Tunnel.1.Interface.1.UseChecksum => 0
|
|
||||||
Device.GRE.Tunnel.1.Interface.1.UseSequenceNumber => 0
|
|
||||||
Device.GRE.Tunnel.1.Interface.1.Stats.BytesSent => 84
|
|
||||||
Device.GRE.Tunnel.1.Interface.1.Stats.BytesReceived => 84
|
|
||||||
Device.GRE.Tunnel.1.Interface.1.Stats.PacketsSent => 1
|
|
||||||
Device.GRE.Tunnel.1.Interface.1.Stats.PacketsReceived => 1
|
|
||||||
Device.GRE.Tunnel.1.Interface.1.Stats.ErrorsSent => 0
|
|
||||||
Device.GRE.Tunnel.1.Interface.1.Stats.ErrorsReceived => 0
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash
|
|
||||||
root@iopsys:~# obuspa -c get Device.IP.Interface.3.
|
|
||||||
Device.IP.Interface.3.Enable => 1
|
|
||||||
Device.IP.Interface.3.IPv6Enable => 1
|
|
||||||
Device.IP.Interface.3.ULAEnable => 1
|
|
||||||
Device.IP.Interface.3.Status => Down
|
|
||||||
Device.IP.Interface.3.Alias => cpe-3
|
|
||||||
Device.IP.Interface.3.Name => iface3
|
|
||||||
Device.IP.Interface.3.LastChange => 0
|
|
||||||
Device.IP.Interface.3.LowerLayers => Device.GRE.Tunnel.1.Interface.1
|
|
||||||
Device.IP.Interface.3.Router => Device.Routing.Router.1
|
|
||||||
Device.IP.Interface.3.Reset => 0
|
|
||||||
Device.IP.Interface.3.MaxMTUSize => 1500
|
|
||||||
Device.IP.Interface.3.Type => Normal
|
|
||||||
Device.IP.Interface.3.Loopback => 0
|
|
||||||
Device.IP.Interface.3.IPv4AddressNumberOfEntries => 1
|
|
||||||
Device.IP.Interface.3.IPv6AddressNumberOfEntries => 0
|
|
||||||
Device.IP.Interface.3.IPv6PrefixNumberOfEntries => 0
|
|
||||||
Device.IP.Interface.3.IPv4Address.1.Enable => 1
|
|
||||||
Device.IP.Interface.3.IPv4Address.1.Status => Enabled
|
|
||||||
Device.IP.Interface.3.IPv4Address.1.Alias => cpe-1
|
|
||||||
Device.IP.Interface.3.IPv4Address.1.IPAddress => 172.17.0.5
|
|
||||||
Device.IP.Interface.3.IPv4Address.1.SubnetMask => 255.255.255.0
|
|
||||||
Device.IP.Interface.3.IPv4Address.1.AddressingType => Static
|
|
||||||
Device.IP.Interface.3.Stats.BytesSent => 0
|
|
||||||
Device.IP.Interface.3.Stats.BytesReceived => 0
|
|
||||||
Device.IP.Interface.3.Stats.PacketsSent => 0
|
|
||||||
Device.IP.Interface.3.Stats.PacketsReceived => 0
|
|
||||||
Device.IP.Interface.3.Stats.ErrorsSent => 0
|
|
||||||
Device.IP.Interface.3.Stats.ErrorsReceived => 0
|
|
||||||
Device.IP.Interface.3.Stats.DiscardPacketsSent => 0
|
|
||||||
Device.IP.Interface.3.Stats.DiscardPacketsReceived => 0
|
|
||||||
Device.IP.Interface.3.Stats.MulticastPacketsReceived => 0
|
|
||||||
```
|
|
||||||
|
|
||||||
NOTE: The status might be down for *Device.IP.Interface.3.Status* but the IP will be assigned properly in ifconfig output.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
gre4-gre_d1i1 Link encap:UNSPEC HWaddr 0A-65-34-64-00-00-00-00-00-00-00-00-00-00-00-00
|
|
||||||
inet addr:172.17.0.5 P-t-P:172.17.0.5 Mask:255.255.255.0
|
|
||||||
inet6 addr: fe80::5efe:a65:3464/64 Scope:Link
|
|
||||||
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1280 Metric:1
|
|
||||||
RX packets:1 errors:0 dropped:0 overruns:0 frame:0
|
|
||||||
TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
|
|
||||||
collisions:0 txqueuelen:1000
|
|
||||||
RX bytes:84 (84.0 B) TX bytes:84 (84.0 B)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Network UCI with added new section for GRE Tunnel
|
|
||||||
|
|
||||||
```bash
|
|
||||||
config device 'gre_dev_1'
|
|
||||||
option name 'gre_dev_1'
|
|
||||||
option type 'tunnel'
|
|
||||||
option mode 'greip'
|
|
||||||
option remote '10.101.52.1'
|
|
||||||
|
|
||||||
config interface 'gre_d1i1'
|
|
||||||
option proto 'gre'
|
|
||||||
option device 'gre_dev_1'
|
|
||||||
option disabled '0'
|
|
||||||
option tunlink 'wan'
|
|
||||||
option peeraddr '10.101.52.1'
|
|
||||||
|
|
||||||
config interface 'gre_ll_1'
|
|
||||||
option proto 'static'
|
|
||||||
option ipaddr '172.17.0.5'
|
|
||||||
option netmask '255.255.255.0'
|
|
||||||
option device 'gre4-gre_d1i1'
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
### IP addr state
|
|
||||||
|
|
||||||
```bash
|
|
||||||
23: gre4-gre_d1i1@eth0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1280 qdisc noqueue state UNKNOWN group default qlen 1000
|
|
||||||
link/gre 10.101.52.100 peer 10.101.52.1
|
|
||||||
inet 172.17.0.5/24 brd 172.17.0.255 scope global gre4-gre_d1i1
|
|
||||||
valid_lft forever preferred_lft forever
|
|
||||||
inet6 fe80::5efe:c0a8:101/64 scope link
|
|
||||||
valid_lft forever preferred_lft forever
|
|
||||||
```
|
|
||||||
|
|
||||||
## Limitations
|
|
||||||
- Current system expects one to one mapping between Device.Tunnel.{i}. and Device.Tunnel.{i}.Interface and Device.IP.Interface.{i}.LowerLayer at a time, that is,
|
|
||||||
at the moment, we can only functionally support single value in Device.GRE.Tunnel.1.Interface.1.LowerLayers and not comma separated list of values.
|
|
||||||
- When Device.IP.Interface.{i}.LowerLayer is set to Device.GRE.Tunnel.{i}.Interface.{i}., the system finds the Linux generated tunnel name for the Tunnel and sets it to option device in the Device.IP.Interface.{i}. interface section, this is to avoid using "@" notation of referring to interfaces, which causes problems in processing of interfaces in the data model implementation.
|
|
||||||
- The lowerlayer of the GRE.Tunnel.Interface object maps to option tunlink in the UCI. If not specified, openwrt by default picks wan interface as tunlink. That means if you have a config interface 'wan' section in your UCI, then the IP.Interface object corresponding to this will automatically become the lowerlayer of Tunnel.Interface object. It is strongly recommended that you do not rely on this however, and for clarity, always specify the value of Tunnel.Interface.Lowerlayer parameter, even though, functionally, your tunnel may even be setup if you leave it as blank provided a config interface wan section exists in your network UCI. In such a scenario, even though you have left the Lowerlayer value as blank, the "wan" interface will be used internally as the default value for option tunlink.
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
# TR181 IP.Interface. Object
|
|
||||||
|
|
||||||
The purpose of this document is to describe what are the problems and limitation we have in managing IP.Interface. with their sub-objects and what is the best way for the customer to avoid these problems/limitations and can easily configure IP.Interface. with different IPv4/v6 addresses using static or dhcp server.
|
|
||||||
|
|
||||||
In fact, many TR181 objects are not mapped 1-to-1 with uci config which makes managing these objects so difficult and one of the important objects is IP.Interface.
|
|
||||||
|
|
||||||
# Problematics:
|
|
||||||
|
|
||||||
Actually, we find a lot of problems with the current implementation of IP.Interface object such as:
|
|
||||||
|
|
||||||
- If IP.Interface instance and IP.Interface.X.IPv4Address instance map to the same interface section, so there is no way to disable IPv4Address instance without affecting IP.Interface since both maps to the same interface section.
|
|
||||||
|
|
||||||
```
|
|
||||||
config interface 'wan' ---> used by Device.IP.Interface.X. and Device.IP.Interface.X.IPv4Address.X. instances
|
|
||||||
option disabled '0' ---> Disabling this IPv4Address.X. instance using Enable parameter(Device.IP.Interface.X.IPv4Address.X.Enable) will impact on IP.Interface.X. instance
|
|
||||||
option device 'ethx'
|
|
||||||
option proto 'static'
|
|
||||||
option ipaddr '10.100.17.39'
|
|
||||||
option netmask '255.255.255.0'
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
- If someone try to create a static route and bind it to an IP.Interface. instance which has an IPv4Address instance defined there so disabling IPv4Addres will cause IP.Interface instance to be disabled and therefore the static route will be automatically disabled from the system.
|
|
||||||
|
|
||||||
```
|
|
||||||
config interface 'wan' ---> used by Device.IP.Interface.1. and Device.IP.Interface.1.IPv4Address.1. instances
|
|
||||||
option disabled '1' ---> Disabling this IPv4Address.1. instance using Enable parameter(Device.IP.Interface.1.IPv4Address.1.Enable) will disable IP.Interface.1. and route section even if there are others section use the same device(wan_2)
|
|
||||||
option device 'ethx'
|
|
||||||
option proto 'dhcp'
|
|
||||||
|
|
||||||
config interface 'wan_2' ---> used by Device.IP.Interface.1.IPv4Address.2. instance
|
|
||||||
option disabled '0'
|
|
||||||
option device 'ethx'
|
|
||||||
option proto 'static'
|
|
||||||
option ipaddr '10.100.17.39'
|
|
||||||
option netmask '255.255.255.0'
|
|
||||||
|
|
||||||
config route
|
|
||||||
option interface 'wan'
|
|
||||||
option target '0.0.0.0/0'
|
|
||||||
option gateway '10.72.197.110'
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
# Solution:
|
|
||||||
|
|
||||||
To fix the above issues, we have updated our IP.Interface.X.IPv4Address implementation to store everything in dmmap, then based on each uci section, we decide how to manage their IP.Interface.X.IPv4Address parameters. but unfortunately, with this approach, the customer has to be aware of some limitations such as:
|
|
||||||
|
|
||||||
- If Data Model shows IP.Interface.{i}.IPv4Address.{i}. instance with DHCP type, then it's not allowed to disable this IP.Interface.{i}.IPv4Address.{i}. instance and the only way to disable it is to set their DHCPv4.Client.X.Interface parameter to empty.
|
|
||||||
|
|
||||||
- If Data Model shows IP.Interface.{i}.IPv6Address.{i}. instance with DHCP type, then it's not allowed to disable this IP.Interface.{i}.IPv6Address.{i}. instance and the only way to disable it is to set their DHCPv6.Client.X.Interface parameter to empty
|
|
||||||
|
|
||||||
- If the network uci defines an interface section which used by both IP.Interface.{i}. instance and DHCPv4.Client.{i}. instance, then it's not allowed to disable this DHCPv4.Client.{i}. instance using Enable parameter and the only way to disable it is to set their IP.Interface.X.Enable parameter to 0.
|
|
||||||
|
|
||||||
>Note: In future we might optimise it further to simplify the mapping between data model objects and uci, that might forgo some limitations.
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -279,25 +279,6 @@ void disable_entry_obj(DMOBJ *entryobj, char *obj_path, const char *parent_obj,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entryobj->nextdynamicobj) {
|
|
||||||
for (int i = 0; i < 2; i++) {
|
|
||||||
struct dm_dynamic_obj *next_dyn_array = entryobj->nextdynamicobj + i;
|
|
||||||
if (next_dyn_array->nextobj) {
|
|
||||||
for (int j = 0; next_dyn_array->nextobj[j]; j++) {
|
|
||||||
DMOBJ *jentryobj = next_dyn_array->nextobj[j];
|
|
||||||
for (; (jentryobj && jentryobj->obj); jentryobj++) {
|
|
||||||
|
|
||||||
if (DM_STRCMP(jentryobj->obj, obj_name) == 0) {
|
|
||||||
BBF_INFO("## Excluding [%s%s.] from the core tree and the same object will be exposed again using (%s) ##", parent_obj, obj_name, plugin_path);
|
|
||||||
jentryobj->bbfdm_type = BBFDM_NONE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void disable_entry_leaf(DMOBJ *entryobj, char *leaf_path, const char *parent_obj, const char *plugin_path)
|
void disable_entry_leaf(DMOBJ *entryobj, char *leaf_path, const char *parent_obj, const char *plugin_path)
|
||||||
|
|
@ -320,25 +301,6 @@ void disable_entry_leaf(DMOBJ *entryobj, char *leaf_path, const char *parent_obj
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entryobj->dynamicleaf) {
|
|
||||||
for (int i = 0; i < 2; i++) {
|
|
||||||
struct dm_dynamic_leaf *next_dyn_array = entryobj->dynamicleaf + i;
|
|
||||||
if (next_dyn_array->nextleaf) {
|
|
||||||
for (int j = 0; next_dyn_array->nextleaf[j]; j++) {
|
|
||||||
DMLEAF *jleaf = next_dyn_array->nextleaf[j];
|
|
||||||
for (; (jleaf && jleaf->parameter); jleaf++) {
|
|
||||||
|
|
||||||
if (DM_STRCMP(jleaf->parameter, leaf_name) == 0) {
|
|
||||||
BBF_INFO("## Excluding [%s%s] from the core tree and the same parameter will be exposed again using (%s) ##", parent_obj, leaf_name, plugin_path);
|
|
||||||
jleaf->bbfdm_type = BBFDM_NONE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_entry_obj_idx(DMOBJ *entryobj)
|
int get_entry_obj_idx(DMOBJ *entryobj)
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ int load_dotso_plugins(DMOBJ *entryobj, const char *plugin_path)
|
||||||
void *handle = dlopen(plugin_path, RTLD_LAZY);
|
void *handle = dlopen(plugin_path, RTLD_LAZY);
|
||||||
#endif
|
#endif
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
BBF_ERR("Plugin failed [%s]\n", dlerror());
|
BBF_ERR("Failed to add DotSo plugin '%s', [%s]\n", plugin_path, dlerror());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,8 +79,10 @@ int load_dotso_plugins(DMOBJ *entryobj, const char *plugin_path)
|
||||||
for (int i = 0; dynamic_obj[i].path; i++) {
|
for (int i = 0; dynamic_obj[i].path; i++) {
|
||||||
|
|
||||||
DMOBJ *dm_entryobj = find_entry_obj(entryobj, dynamic_obj[i].path);
|
DMOBJ *dm_entryobj = find_entry_obj(entryobj, dynamic_obj[i].path);
|
||||||
if (!dm_entryobj)
|
if (!dm_entryobj) {
|
||||||
|
BBF_ERR("Failed to add DotSo plugin '%s' to main tree with parent DM '%s'.", plugin_path, dynamic_obj[i].path);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
dotso_plugin_disable_requested_entries(dm_entryobj, dynamic_obj[i].root_obj, dynamic_obj[i].root_leaf, dynamic_obj[i].path, plugin_path);
|
dotso_plugin_disable_requested_entries(dm_entryobj, dynamic_obj[i].root_obj, dynamic_obj[i].root_leaf, dynamic_obj[i].path, plugin_path);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2095,7 +2095,7 @@ int load_json_plugins(DMOBJ *entryobj, const char *plugin_path)
|
||||||
|
|
||||||
dm_entryobj = find_entry_obj(entryobj, obj_prefix);
|
dm_entryobj = find_entry_obj(entryobj, obj_prefix);
|
||||||
if (!dm_entryobj) {
|
if (!dm_entryobj) {
|
||||||
BBF_DEBUG("ERROR: entry obj doesn't exist for (%s) Object", obj_prefix);
|
BBF_ERR("Failed to add JSON plugin '%s' to main tree with parent DM '%s'.", plugin_path, obj_prefix);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,13 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_SOURCE_DIR} -I${CMAKE_CURRENT_SOUR
|
||||||
|
|
||||||
OPTION(BBF_TR181 "build with tr181 datamodel" ON)
|
OPTION(BBF_TR181 "build with tr181 datamodel" ON)
|
||||||
|
|
||||||
SET(BBF_DM_SOURCES dmlayer.c)
|
|
||||||
|
|
||||||
IF(BBF_TR181)
|
IF(BBF_TR181)
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/dmtree/tr181")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/dmtree/tr181")
|
||||||
FILE(GLOB BBF_TR181_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dmtree/tr181/*.c)
|
FILE(GLOB BBF_TR181_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dmtree/tr181/*.c)
|
||||||
add_compile_definitions(BBF_TR181)
|
add_compile_definitions(BBF_TR181)
|
||||||
ENDIF(BBF_TR181)
|
ENDIF(BBF_TR181)
|
||||||
|
|
||||||
ADD_LIBRARY(bbfdm SHARED ${BBF_DM_SOURCES} ${BBF_TR181_SOURCES})
|
ADD_LIBRARY(bbfdm SHARED ${BBF_TR181_SOURCES})
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(bbfdm uci ubus ubox json-c blobmsg_json m bbfdm-api ssl crypto)
|
TARGET_LINK_LIBRARIES(bbfdm uci ubus ubox json-c blobmsg_json m bbfdm-api ssl crypto)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,492 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2023 iopsys Software Solutions AB
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License version 2.1
|
|
||||||
* as published by the Free Software Foundation
|
|
||||||
*
|
|
||||||
* Author: Amin Ben Romdhane <amin.benromdhane@iopsys.eu>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "dmlayer.h"
|
|
||||||
|
|
||||||
void ppp___update_sections(struct uci_section *s_from, struct uci_section *s_to)
|
|
||||||
{
|
|
||||||
char *proto = NULL;
|
|
||||||
char *device = NULL;
|
|
||||||
char *username = NULL;
|
|
||||||
char *password = NULL;
|
|
||||||
char *pppd_options = NULL;
|
|
||||||
char *service = NULL;
|
|
||||||
char *ac = NULL;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(s_from, "proto", &proto);
|
|
||||||
dmuci_get_value_by_section_string(s_from, "device", &device);
|
|
||||||
dmuci_get_value_by_section_string(s_from, "username", &username);
|
|
||||||
dmuci_get_value_by_section_string(s_from, "password", &password);
|
|
||||||
dmuci_get_value_by_section_string(s_from, "pppd_options", &pppd_options);
|
|
||||||
dmuci_get_value_by_section_string(s_from, "service", &service);
|
|
||||||
dmuci_get_value_by_section_string(s_from, "ac", &ac);
|
|
||||||
|
|
||||||
dmuci_set_value_by_section(s_to, "proto", proto);
|
|
||||||
dmuci_set_value_by_section(s_to, "device", DM_STRLEN(device) ? device : section_name(s_to));
|
|
||||||
dmuci_set_value_by_section(s_to, "username", username);
|
|
||||||
dmuci_set_value_by_section(s_to, "password", password);
|
|
||||||
dmuci_set_value_by_section(s_to, "pppd_options", pppd_options);
|
|
||||||
dmuci_set_value_by_section(s_to, "service", service);
|
|
||||||
dmuci_set_value_by_section(s_to, "ac", ac);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ppp___reset_options(struct uci_section *ppp_s)
|
|
||||||
{
|
|
||||||
dmuci_set_value_by_section(ppp_s, "device", section_name(ppp_s));
|
|
||||||
dmuci_set_value_by_section(ppp_s, "username", "");
|
|
||||||
dmuci_set_value_by_section(ppp_s, "password", "");
|
|
||||||
dmuci_set_value_by_section(ppp_s, "pppd_options", "");
|
|
||||||
dmuci_set_value_by_section(ppp_s, "service", "");
|
|
||||||
dmuci_set_value_by_section(ppp_s, "ac", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
void firewall__create_zone_section(char *s_name)
|
|
||||||
{
|
|
||||||
struct uci_section *s = NULL;
|
|
||||||
char *input = NULL;
|
|
||||||
char *output = NULL;
|
|
||||||
char *forward = NULL;
|
|
||||||
|
|
||||||
dmuci_get_option_value_string("firewall", "@defaults[0]", "input", &input);
|
|
||||||
dmuci_get_option_value_string("firewall", "@defaults[0]", "output", &output);
|
|
||||||
dmuci_get_option_value_string("firewall", "@defaults[0]", "forward", &forward);
|
|
||||||
|
|
||||||
dmuci_add_section("firewall", "zone", &s);
|
|
||||||
dmuci_rename_section_by_section(s, s_name);
|
|
||||||
dmuci_set_value_by_section(s, "name", s_name);
|
|
||||||
dmuci_set_value_by_section(s, "input", input);
|
|
||||||
dmuci_set_value_by_section(s, "output", output);
|
|
||||||
dmuci_set_value_by_section(s, "forward", forward);
|
|
||||||
|
|
||||||
dmuci_add_list_value_by_section(s, "network", s_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get the name that linux generates based on ifname of tunnel */
|
|
||||||
void gre___get_tunnel_system_name(struct uci_section *iface_section, char *device_str, size_t device_str_size)
|
|
||||||
{
|
|
||||||
char *proto = NULL;
|
|
||||||
|
|
||||||
if (!iface_section || !device_str_size)
|
|
||||||
return;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(iface_section, "proto", &proto);
|
|
||||||
|
|
||||||
// to generate appropriate device name
|
|
||||||
if (proto && !DM_LSTRCMP(proto, "grev6")) {
|
|
||||||
snprintf(device_str, device_str_size, "gre6-%s", section_name(iface_section));
|
|
||||||
} else {
|
|
||||||
snprintf(device_str, device_str_size, "gre4-%s", section_name(iface_section));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ip___is_gre_protocols(const char *proto)
|
|
||||||
{
|
|
||||||
if (!DM_LSTRCMP(proto, "gre"))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (!DM_LSTRCMP(proto, "grev6"))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (!DM_LSTRCMP(proto, "gretap"))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (!DM_LSTRCMP(proto, "grev6tap"))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ip___is_ip_interface_instance_exists(const char *sec_name, const char *device)
|
|
||||||
{
|
|
||||||
struct uci_section *s = NULL;
|
|
||||||
char *curr_dev = NULL;
|
|
||||||
|
|
||||||
if (DM_STRLEN(sec_name) == 0 ||
|
|
||||||
DM_STRLEN(device) == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
uci_foreach_sections("network", "interface", s) {
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(s, "device", &curr_dev);
|
|
||||||
if (DM_STRLEN(curr_dev) == 0 ||
|
|
||||||
DM_STRCMP(curr_dev, device) != 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
struct uci_section *dmmap_s = NULL;
|
|
||||||
char *ip_inst = NULL;
|
|
||||||
|
|
||||||
if ((dmmap_s = get_dup_section_in_dmmap("dmmap_network", "interface", section_name(s))) != NULL) {
|
|
||||||
dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &ip_inst);
|
|
||||||
|
|
||||||
if (strcmp(sec_name, section_name(s)) != 0 &&
|
|
||||||
DM_STRLEN(ip_inst) != 0)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ip___update_child_interfaces(char *device, char *option_name, char *option_value)
|
|
||||||
{
|
|
||||||
struct uci_section *s = NULL;
|
|
||||||
|
|
||||||
if (DM_STRLEN(device) == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
uci_foreach_option_eq("network", "interface", "device", device, s) {
|
|
||||||
dmuci_set_value_by_section(s, option_name, option_value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ip___Update_IP_Interface_Layer(char *path, char *linker)
|
|
||||||
{
|
|
||||||
struct uci_section *dmmap_s = NULL;
|
|
||||||
|
|
||||||
uci_path_foreach_option_eq(bbfdm, "dmmap_network", "interface", "LowerLayers", path, dmmap_s) {
|
|
||||||
struct uci_section *iface_s = NULL;
|
|
||||||
char *sec_name = NULL;
|
|
||||||
char *instance = NULL;
|
|
||||||
char *curr_device = NULL;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &instance);
|
|
||||||
if (!DM_STRLEN(instance))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(dmmap_s, "section_name", &sec_name);
|
|
||||||
if (!DM_STRLEN(sec_name))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
iface_s = get_origin_section_from_config("network", "interface", sec_name);
|
|
||||||
if (!iface_s)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(iface_s, "device", &curr_device);
|
|
||||||
|
|
||||||
ip___update_child_interfaces(curr_device, "device", DM_STRLEN(linker) ? linker : section_name(iface_s));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ppp___Update_PPP_Interface_Layer(char *path, char *linker)
|
|
||||||
{
|
|
||||||
struct uci_section *dmmap_s = NULL;
|
|
||||||
|
|
||||||
uci_path_foreach_option_eq(bbfdm, "dmmap_ppp", "interface", "LowerLayers", path, dmmap_s) {
|
|
||||||
struct uci_section *iface_s = NULL;
|
|
||||||
char *sec_name = NULL;
|
|
||||||
char *instance = NULL;
|
|
||||||
char curr_path[128] = {0};
|
|
||||||
char proto[8] = {0};
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(dmmap_s, "ppp_int_instance", &instance);
|
|
||||||
if (!DM_STRLEN(instance))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(dmmap_s, "iface_name", &sec_name);
|
|
||||||
if (!DM_STRLEN(sec_name))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
iface_s = get_origin_section_from_config("network", "interface", sec_name);
|
|
||||||
|
|
||||||
snprintf(proto, sizeof(proto), "ppp%s", (DM_STRLEN(linker)) ? (!DM_LSTRNCMP(linker, "atm", 3) || !DM_LSTRNCMP(linker, "ptm", 3)) ? "oa" : "oe" : "");
|
|
||||||
|
|
||||||
// Update proto option
|
|
||||||
dmuci_set_value_by_section(dmmap_s, "proto", proto);
|
|
||||||
if (iface_s) dmuci_set_value_by_section(iface_s, "proto", proto);
|
|
||||||
|
|
||||||
// Update device option
|
|
||||||
dmuci_set_value_by_section(dmmap_s, "device", linker);
|
|
||||||
if (iface_s) dmuci_set_value_by_section(iface_s, "device", linker);
|
|
||||||
|
|
||||||
snprintf(curr_path, sizeof(curr_path), "Device.PPP.Interface.%s", instance);
|
|
||||||
|
|
||||||
// Update IP Interface instance if exists
|
|
||||||
ip___Update_IP_Interface_Layer(curr_path, linker);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ppp___Update_PPP_Interface_Top_Layers(char *path, char *linker)
|
|
||||||
{
|
|
||||||
char *p = DM_STRRCHR(path, '.');
|
|
||||||
if (p) *p = 0;
|
|
||||||
|
|
||||||
// Update IP Interface instance if exists
|
|
||||||
ip___Update_IP_Interface_Layer(path, linker);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ethernet___Update_MAC_VLAN_Layer(char *path, char *linker)
|
|
||||||
{
|
|
||||||
struct uci_section *dmmap_s = NULL;
|
|
||||||
|
|
||||||
uci_path_foreach_option_eq(bbfdm, "dmmap_network", "device", "LowerLayers", path, dmmap_s) {
|
|
||||||
struct uci_section *dev_s = NULL;
|
|
||||||
char *sec_name = NULL;
|
|
||||||
char *instance = NULL;
|
|
||||||
char curr_path[128] = {0};
|
|
||||||
char name[32] = {0};
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(dmmap_s, "mac_vlan_instance", &instance);
|
|
||||||
if (!DM_STRLEN(instance))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(dmmap_s, "section_name", &sec_name);
|
|
||||||
if (!DM_STRLEN(sec_name))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
dev_s = get_origin_section_from_config("network", "device", sec_name);
|
|
||||||
if (!dev_s)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (DM_STRLEN(linker)) {
|
|
||||||
char *dev_name = ethernet___get_ethernet_interface_name(linker);
|
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "%s_%s", dev_name, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
dmuci_set_value_by_section(dev_s, "ifname", linker);
|
|
||||||
dmuci_set_value_by_section(dev_s, "name", name);
|
|
||||||
|
|
||||||
snprintf(curr_path, sizeof(curr_path), "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN.%s", instance);
|
|
||||||
|
|
||||||
// Update PPP Interface instance if exists
|
|
||||||
ppp___Update_PPP_Interface_Layer(curr_path, name);
|
|
||||||
|
|
||||||
// Update IP Interface instance if exists
|
|
||||||
ip___Update_IP_Interface_Layer(curr_path, name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ethernet___Update_MAC_VLAN_Top_Layers(char *path, char *linker)
|
|
||||||
{
|
|
||||||
char *p = DM_STRRCHR(path, '.');
|
|
||||||
if (p) *p = 0;
|
|
||||||
|
|
||||||
// Update PPP Interface instance if exists
|
|
||||||
ppp___Update_PPP_Interface_Layer(path, linker);
|
|
||||||
|
|
||||||
// Update IP Interface instance if exists
|
|
||||||
ip___Update_IP_Interface_Layer(path, linker);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ethernet___Update_VLAN_Termination_Layer(char *path, char *linker)
|
|
||||||
{
|
|
||||||
struct uci_section *dmmap_s = NULL;
|
|
||||||
|
|
||||||
uci_path_foreach_option_eq(bbfdm, "dmmap_network", "device", "LowerLayers", path, dmmap_s) {
|
|
||||||
struct uci_section *dev_s = NULL;
|
|
||||||
char *sec_name = NULL;
|
|
||||||
char *instance = NULL;
|
|
||||||
char curr_path[128] = {0};
|
|
||||||
char name[32] = {0};
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(dmmap_s, "vlan_term_instance", &instance);
|
|
||||||
if (!DM_STRLEN(instance))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(dmmap_s, "section_name", &sec_name);
|
|
||||||
if (!DM_STRLEN(sec_name))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
dev_s = get_origin_section_from_config("network", "device", sec_name);
|
|
||||||
if (!dev_s)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (DM_STRLEN(linker)) {
|
|
||||||
char *vid = NULL;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(dev_s, "vid", &vid);
|
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "%s%s%s", linker, DM_STRLEN(vid) ? "." : "", DM_STRLEN(vid) ? vid : "");
|
|
||||||
}
|
|
||||||
|
|
||||||
dmuci_set_value_by_section(dev_s, "ifname", linker);
|
|
||||||
dmuci_set_value_by_section(dev_s, "name", name);
|
|
||||||
|
|
||||||
snprintf(curr_path, sizeof(curr_path), "Device.Ethernet.VLANTermination.%s", instance);
|
|
||||||
|
|
||||||
// Update VLAN Termination instance if exists
|
|
||||||
ethernet___Update_VLAN_Termination_Layer(curr_path, name);
|
|
||||||
|
|
||||||
// Update MACVLAN instance if exists
|
|
||||||
ethernet___Update_MAC_VLAN_Layer(curr_path, name);
|
|
||||||
|
|
||||||
// Update PPP Interface instance if exists
|
|
||||||
ppp___Update_PPP_Interface_Layer(curr_path, name);
|
|
||||||
|
|
||||||
// Update IP Interface instance if exists
|
|
||||||
ip___Update_IP_Interface_Layer(curr_path, name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ethernet___Update_VLAN_Termination_Top_Layers(char *path, char *linker)
|
|
||||||
{
|
|
||||||
char *p = DM_STRRCHR(path, '.');
|
|
||||||
if (p) *p = 0;
|
|
||||||
|
|
||||||
// Update VLAN Termination instance if exists
|
|
||||||
ethernet___Update_VLAN_Termination_Layer(path, linker);
|
|
||||||
|
|
||||||
// Update MACVLAN instance if exists
|
|
||||||
ethernet___Update_MAC_VLAN_Layer(path, linker);
|
|
||||||
|
|
||||||
// Update PPP Interface instance if exists
|
|
||||||
ppp___Update_PPP_Interface_Layer(path, linker);
|
|
||||||
|
|
||||||
// Update IP Interface instance if exists
|
|
||||||
ip___Update_IP_Interface_Layer(path, linker);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ethernet___Update_Link_Layer(char *path, char *linker)
|
|
||||||
{
|
|
||||||
struct uci_section *dmmap_s = NULL;
|
|
||||||
|
|
||||||
char *p = DM_STRRCHR(path, '.');
|
|
||||||
if (p) *p = 0;
|
|
||||||
|
|
||||||
uci_path_foreach_option_eq(bbfdm, "dmmap_ethernet", "link", "LowerLayers", path, dmmap_s) {
|
|
||||||
char *instance = NULL;
|
|
||||||
char curr_path[128] = {0};
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(dmmap_s, "link_instance", &instance);
|
|
||||||
if (!DM_STRLEN(instance))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
dmuci_set_value_by_section(dmmap_s, "device", linker);
|
|
||||||
|
|
||||||
if (match(path, "Device.Bridging.Bridge.*.Port.", 0, NULL)) {
|
|
||||||
// Remove unused Interface section created by Bridge Object if it exists
|
|
||||||
struct uci_section *s = get_dup_section_in_config_opt("network", "interface", "device", linker);
|
|
||||||
dmuci_delete_by_section(s, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(curr_path, sizeof(curr_path), "Device.Ethernet.Link.%s", instance);
|
|
||||||
|
|
||||||
// Update IP Interface instance if exists
|
|
||||||
ip___Update_IP_Interface_Layer(curr_path, linker);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ethernet___Update_Link_Top_Layers(char *path, char *linker)
|
|
||||||
{
|
|
||||||
char *p = DM_STRRCHR(path, '.');
|
|
||||||
if (p) *p = 0;
|
|
||||||
|
|
||||||
// Update VLAN Termination instance if exists
|
|
||||||
ethernet___Update_VLAN_Termination_Layer(path, linker);
|
|
||||||
|
|
||||||
// Update MACVLAN instance if exists
|
|
||||||
ethernet___Update_MAC_VLAN_Layer(path, linker);
|
|
||||||
|
|
||||||
// Update PPP Interface instance if exists
|
|
||||||
ppp___Update_PPP_Interface_Layer(path, linker);
|
|
||||||
|
|
||||||
// Update IP Interface instance if exists
|
|
||||||
ip___Update_IP_Interface_Layer(path, linker);
|
|
||||||
}
|
|
||||||
|
|
||||||
void bridging___get_priority_list(struct uci_section *device_sec, char *uci_opt_name, void *data, char **value)
|
|
||||||
{
|
|
||||||
struct uci_list *uci_opt_list = NULL;
|
|
||||||
struct uci_element *e = NULL;
|
|
||||||
char uci_value[256] = {0};
|
|
||||||
unsigned pos = 0;
|
|
||||||
|
|
||||||
if (!data || !uci_opt_name)
|
|
||||||
return;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_list(device_sec, uci_opt_name, &uci_opt_list);
|
|
||||||
if (uci_opt_list == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
uci_value[0] = '\0';
|
|
||||||
/* traverse each list value and create comma separated output */
|
|
||||||
uci_foreach_element(uci_opt_list, e) {
|
|
||||||
|
|
||||||
//delimiting priority which is in the form of x:y where y is the priority
|
|
||||||
char *priority = strchr(e->name, ':');
|
|
||||||
if (priority)
|
|
||||||
pos += snprintf(&uci_value[pos], sizeof(uci_value) - pos, "%s,", priority + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pos)
|
|
||||||
uci_value[pos - 1] = 0;
|
|
||||||
|
|
||||||
dmasprintf(value, "%s", uci_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void bridging___set_priority_list(struct uci_section *device_sec, char *uci_opt_name, void *data, char *value)
|
|
||||||
{
|
|
||||||
char *pch = NULL, *pchr = NULL;
|
|
||||||
int idx = 0;
|
|
||||||
|
|
||||||
if (!data || !uci_opt_name || !value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* delete current list values */
|
|
||||||
dmuci_set_value_by_section(device_sec, uci_opt_name, "");
|
|
||||||
|
|
||||||
/* tokenize each value from received comma separated string and add it to uci file in the format x:y
|
|
||||||
x being priority and y being priority to be mapped to */
|
|
||||||
for (pch = strtok_r(value, ",", &pchr); pch != NULL; pch = strtok_r(NULL, ",", &pchr), idx++) {
|
|
||||||
char buf[16] = {0};
|
|
||||||
|
|
||||||
/* convert values to uci format (x:y) and add */
|
|
||||||
snprintf(buf, sizeof(buf), "%d%c%s", idx, ':', pch);
|
|
||||||
dmuci_add_list_value_by_section(device_sec, uci_opt_name, buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct uci_section *ethernet___get_ethernet_interface_section(const char *device_name)
|
|
||||||
{
|
|
||||||
struct uci_section *s = NULL;
|
|
||||||
|
|
||||||
uci_foreach_sections("network", "device", s) {
|
|
||||||
char *name = NULL;
|
|
||||||
|
|
||||||
if (!dmuci_is_option_value_empty(s, "type"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(s, "name", &name);
|
|
||||||
|
|
||||||
if (DM_STRCMP(name, device_name) == 0)
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *ethernet___get_ethernet_interface_name(char *device_name)
|
|
||||||
{
|
|
||||||
char *dev_name = dmstrdup(device_name);
|
|
||||||
|
|
||||||
if (!ethernet___get_ethernet_interface_section(dev_name)) {
|
|
||||||
struct uci_section *dev_s = NULL;
|
|
||||||
|
|
||||||
dev_s = get_dup_section_in_config_opt("network", "device", "name", dev_name);
|
|
||||||
|
|
||||||
char *has_vid = DM_STRRCHR(dev_name, '.');
|
|
||||||
if (has_vid)
|
|
||||||
*has_vid = '\0';
|
|
||||||
|
|
||||||
if (dev_s) { // Verify if the device has dual tags
|
|
||||||
char *type = NULL;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(dev_s, "type", &type);
|
|
||||||
if (DM_STRCMP(type, "8021ad") == 0) {
|
|
||||||
has_vid = DM_STRRCHR(dev_name, '.');
|
|
||||||
if (has_vid)
|
|
||||||
*has_vid = '\0';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return dev_name;
|
|
||||||
}
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2023 iopsys Software Solutions AB
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License version 2.1
|
|
||||||
* as published by the Free Software Foundation
|
|
||||||
*
|
|
||||||
* Author: Amin Ben Romdhane <amin.benromdhane@iopsys.eu>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __DMLAYER_H__
|
|
||||||
#define __DMLAYER_H__
|
|
||||||
|
|
||||||
#include "libbbfdm-api/dmcommon.h"
|
|
||||||
|
|
||||||
void gre___get_tunnel_system_name(struct uci_section *iface_section, char *device_str, size_t device_str_size);
|
|
||||||
|
|
||||||
bool ip___is_gre_protocols(const char *proto);
|
|
||||||
bool ip___is_ip_interface_instance_exists(const char *sec_name, const char *device);
|
|
||||||
void ip___update_child_interfaces(char *device, char *option_name, char *option_value);
|
|
||||||
|
|
||||||
void ppp___update_sections(struct uci_section *s_from, struct uci_section *s_to);
|
|
||||||
void ppp___reset_options(struct uci_section *ppp_s);
|
|
||||||
void ppp___Update_PPP_Interface_Top_Layers(char *path, char *linker);
|
|
||||||
|
|
||||||
void ethernet___Update_MAC_VLAN_Top_Layers(char *path, char *linker);
|
|
||||||
void ethernet___Update_VLAN_Termination_Top_Layers(char *path, char *linker);
|
|
||||||
void ethernet___Update_Link_Layer(char *path, char *linker);
|
|
||||||
void ethernet___Update_Link_Top_Layers(char *path, char *linker);
|
|
||||||
|
|
||||||
void bridging___get_priority_list(struct uci_section *device_sec, char *uci_opt_name, void *data, char **value);
|
|
||||||
void bridging___set_priority_list(struct uci_section *device_sec, char *uci_opt_name, void *data, char *value);
|
|
||||||
|
|
||||||
void firewall__create_zone_section(char *s_name);
|
|
||||||
|
|
||||||
struct uci_section *ethernet___get_ethernet_interface_section(const char *device_name);
|
|
||||||
char *ethernet___get_ethernet_interface_name(char *device_name);
|
|
||||||
|
|
||||||
#endif //__DMLAYER_H__
|
|
||||||
|
|
@ -12,26 +12,13 @@
|
||||||
|
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "deviceinfo.h"
|
#include "deviceinfo.h"
|
||||||
#include "ip.h"
|
|
||||||
#include "ppp.h"
|
|
||||||
#include "routing.h"
|
|
||||||
#include "interfacestack.h"
|
|
||||||
#include "gre.h"
|
|
||||||
#include "lanconfigsecurity.h"
|
#include "lanconfigsecurity.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "routeradvertisement.h"
|
|
||||||
#include "gatewayinfo.h"
|
#include "gatewayinfo.h"
|
||||||
|
|
||||||
/*************************************************************
|
/*************************************************************
|
||||||
* GET & SET PARAM
|
* GET & SET PARAM
|
||||||
**************************************************************/
|
**************************************************************/
|
||||||
static int get_Device_InterfaceStackNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
int cnt = get_number_of_entries(ctx, data, instance, browseInterfaceStackInst);
|
|
||||||
dmasprintf(value, "%d", cnt);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_Device_RootDataModelVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
static int get_Device_RootDataModelVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||||
{
|
{
|
||||||
*value = "2.17";
|
*value = "2.17";
|
||||||
|
|
@ -69,14 +56,8 @@ DM_MAP_OBJ tDynamicObj[] = {
|
||||||
DMOBJ tDeviceObj[] = {
|
DMOBJ tDeviceObj[] = {
|
||||||
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
|
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
|
||||||
{"DeviceInfo", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDeviceInfoObj, tDeviceInfoParams, NULL, BBFDM_BOTH, NULL},
|
{"DeviceInfo", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDeviceInfoObj, tDeviceInfoParams, NULL, BBFDM_BOTH, NULL},
|
||||||
{"IP", &DMREAD, NULL, NULL, "file:/etc/config/network", NULL, NULL, NULL, tIPObj, tIPParams, NULL, BBFDM_BOTH, NULL},
|
|
||||||
{"PPP", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/ppp.sh,/etc/config/network", NULL, NULL, NULL, tPPPObj, tPPPParams, NULL, BBFDM_BOTH, NULL},
|
|
||||||
{"Routing", &DMREAD, NULL, NULL, "file:/etc/config/network", NULL, NULL, NULL, tRoutingObj, tRoutingParams, NULL, BBFDM_BOTH, NULL},
|
|
||||||
{"InterfaceStack", &DMREAD, NULL, NULL, "file:/etc/config/network", browseInterfaceStackInst, NULL, NULL, NULL, tInterfaceStackParams, NULL, BBFDM_BOTH, NULL},
|
|
||||||
{"GRE", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/gre.sh,/etc/config/network", NULL, NULL, NULL, tGREObj, tGREParams, NULL, BBFDM_BOTH, NULL},
|
|
||||||
{"LANConfigSecurity", &DMREAD, NULL, NULL, "file:/etc/config/users", NULL, NULL, NULL, NULL, tLANConfigSecurityParams, NULL, BBFDM_BOTH, NULL},
|
{"LANConfigSecurity", &DMREAD, NULL, NULL, "file:/etc/config/users", NULL, NULL, NULL, NULL, tLANConfigSecurityParams, NULL, BBFDM_BOTH, NULL},
|
||||||
{"Security", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tSecurityObj, tSecurityParams, NULL, BBFDM_BOTH, NULL},
|
{"Security", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tSecurityObj, tSecurityParams, NULL, BBFDM_BOTH, NULL},
|
||||||
{"RouterAdvertisement", &DMREAD, NULL, NULL, "file:/etc/config/dhcp", NULL, NULL, NULL, tRouterAdvertisementObj, tRouterAdvertisementParams, NULL, BBFDM_BOTH, NULL},
|
|
||||||
{"Services", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, BBFDM_BOTH, NULL},
|
{"Services", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, BBFDM_BOTH, NULL},
|
||||||
{"GatewayInfo", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tGatewayInfoParams, NULL, BBFDM_CWMP, NULL},
|
{"GatewayInfo", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tGatewayInfoParams, NULL, BBFDM_CWMP, NULL},
|
||||||
{0}
|
{0}
|
||||||
|
|
@ -84,7 +65,6 @@ DMOBJ tDeviceObj[] = {
|
||||||
|
|
||||||
DMLEAF tDeviceParams[] = {
|
DMLEAF tDeviceParams[] = {
|
||||||
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
|
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
|
||||||
{"InterfaceStackNumberOfEntries", &DMREAD, DMT_UNINT, get_Device_InterfaceStackNumberOfEntries, NULL, BBFDM_BOTH},
|
|
||||||
{"RootDataModelVersion", &DMREAD, DMT_STRING, get_Device_RootDataModelVersion, NULL, BBFDM_BOTH},
|
{"RootDataModelVersion", &DMREAD, DMT_STRING, get_Device_RootDataModelVersion, NULL, BBFDM_BOTH},
|
||||||
{"Reboot()", &DMSYNC, DMT_COMMAND, NULL, operate_Device_Reboot, BBFDM_USP},
|
{"Reboot()", &DMSYNC, DMT_COMMAND, NULL, operate_Device_Reboot, BBFDM_USP},
|
||||||
{"FactoryReset()", &DMSYNC, DMT_COMMAND, NULL, operate_Device_FactoryReset, BBFDM_USP},
|
{"FactoryReset()", &DMSYNC, DMT_COMMAND, NULL, operate_Device_FactoryReset, BBFDM_USP},
|
||||||
|
|
|
||||||
|
|
@ -1,882 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2024 iopsys Software Solutions AB
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License version 2.1
|
|
||||||
* as published by the Free Software Foundation
|
|
||||||
*
|
|
||||||
* Author: Omar Kallel <omar.kallel@pivasoftware.com>
|
|
||||||
* Author: Mohd Husaam Mehdi <husaam.mehdi@iopsys.eu>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gre.h"
|
|
||||||
#include "dmlayer.h"
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* UTILITY METHODS
|
|
||||||
**************************************************************/
|
|
||||||
/* wrapper to avoid long lines */
|
|
||||||
static char *get_tunnel_name(struct uci_section *tunnel_section)
|
|
||||||
{
|
|
||||||
return dmuci_get_value_by_section_fallback_def(tunnel_section, "name", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* different family tunnels have different option proto */
|
|
||||||
static char *get_tunnel_dev_proto_family(struct uci_section *tunnel_section)
|
|
||||||
{
|
|
||||||
if (!tunnel_section) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
char *tunnel_dev_mode = dmuci_get_value_by_section_fallback_def(tunnel_section, "mode", "");
|
|
||||||
|
|
||||||
if (!DM_LSTRCMP(tunnel_dev_mode, "greip6")) {
|
|
||||||
return "grev6";
|
|
||||||
} else {
|
|
||||||
return "gre";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* delete sections from both main UCI and dmmap UCI */
|
|
||||||
static void delete_all_sections_with_opt_eq(char *package, char *section_type, char *option, char *value)
|
|
||||||
{
|
|
||||||
struct uci_section *s = NULL, *stmp = NULL, *dmmap_section = NULL;
|
|
||||||
|
|
||||||
if (!package || !section_type || !option || !value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uci_foreach_option_eq_safe(package, section_type, option, value, stmp, s) {
|
|
||||||
dmmap_section = NULL;
|
|
||||||
|
|
||||||
get_dmmap_section_of_config_section("dmmap_gre", section_type, section_name(s), &dmmap_section);
|
|
||||||
|
|
||||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
|
||||||
dmuci_delete_by_section(s, NULL, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set value in all sections in main UCI */
|
|
||||||
static void set_all_sections_with_opt_eq(char *package, char *section_type, char *option, char *value, char *set_option, char *set_value)
|
|
||||||
{
|
|
||||||
struct uci_section *s = NULL;
|
|
||||||
|
|
||||||
if (!package || !section_type || !option || !value || !set_option || !set_value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uci_foreach_option_eq(package, section_type, option, value, s) {
|
|
||||||
// do not remove device of interface section
|
|
||||||
if (!DM_LSTRCMP(set_option, "device") && !DM_LSTRCMP(set_value, "")) {
|
|
||||||
dmuci_set_value_by_section(s, set_option, section_name(s));
|
|
||||||
} else {
|
|
||||||
dmuci_set_value_by_section(s, set_option, set_value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* update interface sections corresponding to Tunnel.Interface.LowerLayer, as changed proto leads to changed dev name*/
|
|
||||||
static void update_all_interface_upper_layers(char *tunnel_dev_name, bool is_current_ipv6)
|
|
||||||
{
|
|
||||||
struct uci_section *s = NULL, *s_lower = NULL;
|
|
||||||
|
|
||||||
if (!tunnel_dev_name || !DM_STRLEN(tunnel_dev_name)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// for all interfaces that have this tunnel_dev
|
|
||||||
uci_foreach_option_eq("network", "interface", "device", tunnel_dev_name, s) {
|
|
||||||
s_lower = NULL;
|
|
||||||
// get the interface name
|
|
||||||
char *if_section_name = section_name(s);
|
|
||||||
char current_lower_layer_device[32] = {0};
|
|
||||||
char new_lower_layer_device[32] = {0};
|
|
||||||
|
|
||||||
if (is_current_ipv6) {
|
|
||||||
snprintf(current_lower_layer_device, sizeof(current_lower_layer_device), "gre6-%s", if_section_name);
|
|
||||||
snprintf(new_lower_layer_device, sizeof(new_lower_layer_device), "gre4-%s", if_section_name);
|
|
||||||
} else {
|
|
||||||
snprintf(current_lower_layer_device, sizeof(current_lower_layer_device), "gre4-%s", if_section_name);
|
|
||||||
snprintf(new_lower_layer_device, sizeof(new_lower_layer_device), "gre6-%s", if_section_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
// for all interfaces that have device set to the name generated from current tunnel.interface
|
|
||||||
uci_foreach_option_eq("network", "interface", "device", current_lower_layer_device, s_lower) {
|
|
||||||
// update device
|
|
||||||
dmuci_set_value_by_section(s_lower, "device", new_lower_layer_device);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *get_gre_tunnel_interface_statistics(json_object *json_stats, char *key)
|
|
||||||
{
|
|
||||||
char *value = NULL;
|
|
||||||
if (!json_stats || !key) {
|
|
||||||
return "0";
|
|
||||||
}
|
|
||||||
|
|
||||||
value = dmjson_get_value(json_stats, 2, "statistics", key);
|
|
||||||
return value ? value : "0";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* remove device section of interface sections corresponding to lowerlayer */
|
|
||||||
static void empty_all_upper_layers_of_interface(struct uci_section *iface_section)
|
|
||||||
{
|
|
||||||
char tunnel_system_name[32] = {0};
|
|
||||||
|
|
||||||
if (!iface_section)
|
|
||||||
return;
|
|
||||||
|
|
||||||
gre___get_tunnel_system_name(iface_section, &tunnel_system_name[0], sizeof(tunnel_system_name));
|
|
||||||
|
|
||||||
// remove tunnel system name from option device of the interface section of lower layers
|
|
||||||
// otherwise tunnel interface is not removed from the system
|
|
||||||
set_all_sections_with_opt_eq("network", "interface", "device", tunnel_system_name, "device", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void remove_all_interfaces_of_tunnel(char *tunnel_dev_name)
|
|
||||||
{
|
|
||||||
if (!tunnel_dev_name || !DM_STRLEN(tunnel_dev_name)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct uci_section *s = NULL;
|
|
||||||
|
|
||||||
// for all interfaces of this tunnel
|
|
||||||
uci_foreach_option_eq("network", "interface", "device", tunnel_dev_name, s) {
|
|
||||||
empty_all_upper_layers_of_interface(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete all sections corresponding to tunnel.interface
|
|
||||||
delete_all_sections_with_opt_eq("network", "interface", "device", tunnel_dev_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void remove_tunnel(struct uci_section *tunnel_section, struct uci_section *tunnel_dmmap_section)
|
|
||||||
{
|
|
||||||
if (!tunnel_section)
|
|
||||||
return;
|
|
||||||
|
|
||||||
char *tunnel_dev_name = NULL;
|
|
||||||
|
|
||||||
tunnel_dev_name = dmuci_get_value_by_section_fallback_def(tunnel_section, "name", "");
|
|
||||||
|
|
||||||
// delete all sections corresponding to Tunnel.Interface
|
|
||||||
remove_all_interfaces_of_tunnel(tunnel_dev_name);
|
|
||||||
|
|
||||||
// remove the tunnel dmmap section
|
|
||||||
if (tunnel_dmmap_section == NULL) {
|
|
||||||
struct uci_section *dmmap_section = NULL;
|
|
||||||
get_dmmap_section_of_config_section("dmmap_gre", "interface", section_name(tunnel_section), &dmmap_section);
|
|
||||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
|
||||||
} else {
|
|
||||||
dmuci_delete_by_section(tunnel_dmmap_section, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove tunnel network UCI section
|
|
||||||
dmuci_delete_by_section(tunnel_section, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void remove_all_tunnels(void)
|
|
||||||
{
|
|
||||||
struct uci_section *s = NULL, *stmp = NULL;
|
|
||||||
|
|
||||||
uci_foreach_option_eq_safe("network", "device", "mode", "greip", stmp, s) {
|
|
||||||
remove_tunnel(s, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
s = NULL, stmp = NULL;
|
|
||||||
uci_foreach_option_eq_safe("network", "device", "mode", "greip6", stmp, s) {
|
|
||||||
remove_tunnel(s, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*************************************************************
|
|
||||||
* ENTRY METHOD
|
|
||||||
*************************************************************/
|
|
||||||
static int browseGRETunnelInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
|
||||||
{
|
|
||||||
char *inst = NULL;
|
|
||||||
struct dm_data *curr_data = NULL;
|
|
||||||
LIST_HEAD(dup_list);
|
|
||||||
|
|
||||||
synchronize_specific_config_sections_with_dmmap_cont("network", "device", "dmmap_gre", "mode", "greip", &dup_list);
|
|
||||||
list_for_each_entry(curr_data, &dup_list, list) {
|
|
||||||
|
|
||||||
inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "gre_tunnel_instance", "gre_tunnel_alias");
|
|
||||||
|
|
||||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
free_dmmap_config_dup_list(&dup_list);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int browseGRETunnelInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
|
||||||
{
|
|
||||||
json_object *res = NULL;
|
|
||||||
char *inst = NULL;
|
|
||||||
struct dm_data *curr_data = NULL;
|
|
||||||
char *tunnel_dev_name = NULL;
|
|
||||||
char *tunnel_instance = NULL;
|
|
||||||
LIST_HEAD(dup_list);
|
|
||||||
|
|
||||||
tunnel_dev_name = dmuci_get_value_by_section_fallback_def(((struct dm_data *)prev_data)->config_section, "name", "");
|
|
||||||
if (!DM_STRLEN(tunnel_dev_name))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
tunnel_instance = dmuci_get_value_by_section_fallback_def(((struct dm_data *)prev_data)->dmmap_section, "gre_tunnel_instance", "");
|
|
||||||
|
|
||||||
dmubus_call("network.device", "status", UBUS_ARGS{0}, 0, &res);
|
|
||||||
|
|
||||||
synchronize_specific_config_sections_with_dmmap_eq("network", "interface", "dmmap_gre", "device", tunnel_dev_name, &dup_list);
|
|
||||||
list_for_each_entry(curr_data, &dup_list, list) {
|
|
||||||
// get system name for this interface
|
|
||||||
char tunnel_system_name[32] = {0};
|
|
||||||
gre___get_tunnel_system_name(curr_data->config_section, &tunnel_system_name[0], sizeof(tunnel_system_name));
|
|
||||||
|
|
||||||
// loop over all objects of network.device status
|
|
||||||
json_object_object_foreach(res, key, val) {
|
|
||||||
if (DM_LSTRCMP(key, tunnel_system_name) == 0) {
|
|
||||||
curr_data->json_object = json_object_get(val);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// set tunnel instance in dmmap gre interface section, needed for interfacestack
|
|
||||||
dmuci_set_value_by_section(curr_data->dmmap_section, "tunnel_instance", tunnel_instance);
|
|
||||||
|
|
||||||
inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "gre_iface_instance", "gre_iface_alias");
|
|
||||||
|
|
||||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
free_dmmap_config_dup_list(&dup_list);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* ADD & DEL OBJ
|
|
||||||
*************************************************************/
|
|
||||||
static int addObjGRETunnel(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
|
||||||
{
|
|
||||||
struct uci_section *dev_sec = NULL, *dmmap_sec = NULL;
|
|
||||||
char buf[32] = {0};
|
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "gre_dev_%s", *instance);
|
|
||||||
|
|
||||||
dmuci_add_section("network", "device", &dev_sec);
|
|
||||||
dmuci_rename_section_by_section(dev_sec, buf);
|
|
||||||
dmuci_set_value_by_section(dev_sec, "name", buf);
|
|
||||||
dmuci_set_value_by_section(dev_sec, "type", "tunnel");
|
|
||||||
dmuci_set_value_by_section(dev_sec, "mode", "greip");
|
|
||||||
|
|
||||||
dmuci_add_section_bbfdm("dmmap_gre", "device", &dmmap_sec);
|
|
||||||
dmuci_set_value_by_section(dmmap_sec, "section_name", buf);
|
|
||||||
dmuci_set_value_by_section(dmmap_sec, "gre_tunnel_instance", *instance);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int delObjGRETunnel(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
|
|
||||||
{
|
|
||||||
switch (del_action) {
|
|
||||||
case DEL_INST:
|
|
||||||
remove_tunnel(((struct dm_data *)data)->config_section, ((struct dm_data *)data)->dmmap_section);
|
|
||||||
break;
|
|
||||||
case DEL_ALL:
|
|
||||||
remove_all_tunnels();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int addObjGRETunnelInterface(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
|
||||||
{
|
|
||||||
struct uci_section *if_sec = NULL, *dmmap_sec = NULL;
|
|
||||||
char buf[32] = {0};
|
|
||||||
struct uci_section *tunnel_section = ((struct dm_data *)data)->config_section;
|
|
||||||
char *tunnel_instance = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->dmmap_section, "gre_tunnel_instance", "");
|
|
||||||
|
|
||||||
char *proto = get_tunnel_dev_proto_family(tunnel_section);
|
|
||||||
char *disabled = dmuci_get_value_by_section_fallback_def(tunnel_section, "disabled", "0");
|
|
||||||
char *remote = dmuci_get_value_by_section_fallback_def(tunnel_section, "remote", "");
|
|
||||||
|
|
||||||
// name is derived from tunnel number and intf number
|
|
||||||
snprintf(buf, sizeof(buf), "gre_d%si%s", tunnel_instance, *instance);
|
|
||||||
|
|
||||||
dmuci_add_section("network", "interface", &if_sec);
|
|
||||||
dmuci_rename_section_by_section(if_sec, buf);
|
|
||||||
dmuci_set_value_by_section(if_sec, "proto", proto);
|
|
||||||
dmuci_set_value_by_section(if_sec, "device", get_tunnel_name(tunnel_section));
|
|
||||||
dmuci_set_value_by_section(if_sec, "disabled", disabled);
|
|
||||||
|
|
||||||
if (DM_STRLEN(remote)) {
|
|
||||||
if (!DM_LSTRCMP(proto, "grev6")) {
|
|
||||||
dmuci_set_value_by_section(if_sec, "peer6addr", remote);
|
|
||||||
} else {
|
|
||||||
dmuci_set_value_by_section(if_sec, "peeraddr", remote);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dmuci_add_section_bbfdm("dmmap_gre", "interface", &dmmap_sec);
|
|
||||||
dmuci_set_value_by_section(dmmap_sec, "section_name", buf);
|
|
||||||
dmuci_set_value_by_section(dmmap_sec, "gre_iface_instance", *instance);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int delObjGRETunnelInterface(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
|
|
||||||
{
|
|
||||||
char *tunnel_dev_name = NULL;
|
|
||||||
|
|
||||||
switch (del_action) {
|
|
||||||
case DEL_INST:
|
|
||||||
empty_all_upper_layers_of_interface(((struct dm_data *)data)->config_section);
|
|
||||||
// Remove interface section in network UCI
|
|
||||||
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
|
|
||||||
// Remove interface section in dmmap_gre
|
|
||||||
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case DEL_ALL:
|
|
||||||
tunnel_dev_name = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "name", "");
|
|
||||||
remove_all_interfaces_of_tunnel(tunnel_dev_name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* GET & SET PARAM
|
|
||||||
*************************************************************/
|
|
||||||
|
|
||||||
static int get_GRE_TunnelNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
int cnt = get_number_of_entries(ctx, data, instance, browseGRETunnelInst);
|
|
||||||
dmasprintf(value, "%d", cnt);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_GRETunnel_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
char *disabled = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "disabled", "0");
|
|
||||||
|
|
||||||
if (!DM_STRCMP(disabled, "0") || !DM_STRCMP(disabled, "false"))
|
|
||||||
*value = "1";
|
|
||||||
else
|
|
||||||
*value = "0";
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_GRETunnel_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
struct uci_section *tunnel_section = ((struct dm_data *)data)->config_section;
|
|
||||||
bool b = true;
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_boolean(ctx, value))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
string_to_bool(value, &b);
|
|
||||||
char *disabled = b ? "0" : "1";
|
|
||||||
|
|
||||||
dmuci_set_value_by_section(tunnel_section, "disabled", disabled);
|
|
||||||
// disabling the device will have no effect so apply to all interfaces
|
|
||||||
set_all_sections_with_opt_eq("network", "interface", "device", get_tunnel_name(tunnel_section), "disabled", disabled );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_GRETunnel_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
char *disabled = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "disabled", "0");
|
|
||||||
|
|
||||||
if (!DM_STRCMP(disabled, "0") || !DM_STRCMP(disabled, "false")) {
|
|
||||||
*value = "Enabled";
|
|
||||||
} else {
|
|
||||||
*value = "Disabled";
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*#Device.GRE.Tunnel.{i}.Alias!UCI:dmmap_gre/interface,@i-1/gre_tunnel_alias*/
|
|
||||||
static int get_GRETunnel_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
return bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, "gre_tunnel_alias", instance, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_GRETunnel_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, "gre_tunnel_alias", instance, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_GRETunnel_DeliveryHeaderProtocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
char *proto = NULL;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "mode", &proto);
|
|
||||||
|
|
||||||
if (proto && !DM_LSTRCMP(proto, "greip6")) {
|
|
||||||
*value = "IPv6";
|
|
||||||
} else {
|
|
||||||
*value = "IPv4";
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_GRETunnel_DeliveryHeaderProtocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
char *DeliveryHeaderProtocol[] = {"IPv4", "IPv6", NULL};
|
|
||||||
char *current_delivery_header = NULL;
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_string(ctx, value, -1, -1, DeliveryHeaderProtocol, NULL))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
get_GRETunnel_DeliveryHeaderProtocol(refparam, ctx, data, instance, ¤t_delivery_header);
|
|
||||||
|
|
||||||
// if current delivery header and new delivery header are same, do nothing
|
|
||||||
// if different, find the device name for this tunnel
|
|
||||||
// for every interface that has device as this device name, update device name there
|
|
||||||
// delete current peeraddr or peer6addr as applicable
|
|
||||||
// and set a new empty one
|
|
||||||
// finally update the proto
|
|
||||||
if (DM_LSTRCMP(current_delivery_header, value)) {
|
|
||||||
struct uci_section *tunnel_section = ((struct dm_data *)data)->config_section;
|
|
||||||
char *current_proto = get_tunnel_dev_proto_family(tunnel_section);
|
|
||||||
char *tunnel_dev_name = get_tunnel_name(tunnel_section);
|
|
||||||
|
|
||||||
// changing from grev6 to gre
|
|
||||||
if (!DM_LSTRCMP(current_proto, "grev6")) {
|
|
||||||
// update mode in tunnel device section
|
|
||||||
dmuci_set_value_by_section(tunnel_section, "mode", "greip");
|
|
||||||
// remove remote because now we need different family's address
|
|
||||||
dmuci_set_value_by_section(tunnel_section, "remote", "");
|
|
||||||
|
|
||||||
// update proto to gre in all sections belonging to tunnel.interface
|
|
||||||
set_all_sections_with_opt_eq("network", "interface", "device", tunnel_dev_name, "proto", "gre");
|
|
||||||
// remove peer6addr because now we need peeraddr
|
|
||||||
set_all_sections_with_opt_eq("network", "interface", "device", tunnel_dev_name, "peer6addr", "");
|
|
||||||
// update device in all sections which have this tunnel.interface as lower layer
|
|
||||||
bool is_current_ipv6 = true;
|
|
||||||
update_all_interface_upper_layers(tunnel_dev_name, is_current_ipv6);
|
|
||||||
// changing from gre to grev6
|
|
||||||
} else {
|
|
||||||
// current is greip, new is greip6
|
|
||||||
// update mode in tunnel device section
|
|
||||||
dmuci_set_value_by_section(tunnel_section, "mode", "greip6");
|
|
||||||
// remove remote because now we need different family's address
|
|
||||||
dmuci_set_value_by_section(tunnel_section, "remote", "");
|
|
||||||
|
|
||||||
// update proto to grev6 in all sections belonging to tunnel.interface
|
|
||||||
set_all_sections_with_opt_eq("network", "interface", "device", tunnel_dev_name, "proto", "grev6");
|
|
||||||
// remove peeraddr because now we need peer6addr
|
|
||||||
set_all_sections_with_opt_eq("network", "interface", "device", tunnel_dev_name, "peeraddr", "");
|
|
||||||
// update device in all sections which have this tunnel.interface as lower layer
|
|
||||||
bool is_current_ipv6 = false;
|
|
||||||
update_all_interface_upper_layers(tunnel_dev_name, is_current_ipv6);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_GRETunnel_RemoteEndpoints(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
struct uci_section *tunnel_section = ((struct dm_data *)data)->config_section;
|
|
||||||
|
|
||||||
*value = dmuci_get_value_by_section_fallback_def(tunnel_section, "remote", "");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_GRETunnel_RemoteEndpoints(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
struct uci_section *tunnel_section = ((struct dm_data *)data)->config_section;
|
|
||||||
char *proto = NULL, *tunnel_dev_name = NULL;
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_string(ctx, value, -1, 45, NULL, IPAddress))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
proto = get_tunnel_dev_proto_family(tunnel_section);
|
|
||||||
tunnel_dev_name = get_tunnel_name(tunnel_section);
|
|
||||||
|
|
||||||
// set the option remote in tunnel device section
|
|
||||||
dmuci_set_value_by_section(tunnel_section, "remote", value);
|
|
||||||
|
|
||||||
if (!DM_LSTRCMP(proto, "grev6")) {
|
|
||||||
// set the peer6addr in all interfaces of this tunnel
|
|
||||||
set_all_sections_with_opt_eq("network", "interface", "device", tunnel_dev_name, "peer6addr", value);
|
|
||||||
} else {
|
|
||||||
set_all_sections_with_opt_eq("network", "interface", "device", tunnel_dev_name, "peeraddr", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_GRETunnel_ConnectedRemoteEndpoint(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
// current implementation restricts us to only have one possible value for peer address
|
|
||||||
// ConnectedRemoteEndpoint is same as RemoteEndpoint
|
|
||||||
get_GRETunnel_RemoteEndpoints(refparam, ctx, data, instance, value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_GRETunnel_InterfaceNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
int cnt = get_number_of_entries(ctx, data, instance, browseGRETunnelInterfaceInst);
|
|
||||||
dmasprintf(value, "%d", cnt);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_GRETunnelInterface_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
char *disabled = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "disabled", "0");
|
|
||||||
|
|
||||||
if (!DM_STRCMP(disabled, "0") || !DM_STRCMP(disabled, "false")) {
|
|
||||||
*value = "1";
|
|
||||||
} else {
|
|
||||||
*value = "0";
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_GRETunnelInterface_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
struct uci_section *tunnel_intf_section = ((struct dm_data *)data)->config_section;
|
|
||||||
bool b = true;
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_boolean(ctx, value))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
string_to_bool(value, &b);
|
|
||||||
char *disabled = b ? "0" : "1";
|
|
||||||
|
|
||||||
dmuci_set_value_by_section(tunnel_intf_section, "disabled", disabled);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_GRETunnelInterface_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
char *disabled = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "disabled", "0");
|
|
||||||
|
|
||||||
if (!DM_STRCMP(disabled, "1") || !DM_STRCMP(disabled, "true")) {
|
|
||||||
*value = "Down";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
char tunnel_system_name[32] = {0};
|
|
||||||
gre___get_tunnel_system_name(((struct dm_data *)data)->config_section, &tunnel_system_name[0], sizeof(tunnel_system_name));
|
|
||||||
|
|
||||||
return get_net_device_status(tunnel_system_name, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*#Device.GRE.Tunnel.{i}.Interface.{i}.Alias!UCI:dmmap_gre/interface,@i-1/gre_iface_alias*/
|
|
||||||
static int get_GRETunnelInterface_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
return bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, "gre_iface_alias", instance, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_GRETunnelInterface_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, "gre_iface_alias", instance, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_GRETunnelInterface_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
*value = dmstrdup(section_name(((struct dm_data *)data)->config_section));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_GRETunnelInterface_LastChange(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
json_object *res = NULL;
|
|
||||||
|
|
||||||
char *if_name = section_name(((struct dm_data *)data)->config_section);
|
|
||||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
|
||||||
DM_ASSERT(res, *value = "0");
|
|
||||||
*value = dmjson_get_value(res, 1, "uptime");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int get_GRETunnelInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "LowerLayers", value);
|
|
||||||
|
|
||||||
if ((*value)[0] == '\0') {
|
|
||||||
char *tunlink = NULL;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "tunlink", &tunlink);
|
|
||||||
|
|
||||||
_bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", tunlink, value);
|
|
||||||
|
|
||||||
// Store LowerLayers value
|
|
||||||
dmuci_set_value_by_section(((struct dm_data *)data)->dmmap_section, "LowerLayers", *value);
|
|
||||||
} else {
|
|
||||||
if (!adm_entry_object_exists(ctx, *value))
|
|
||||||
*value = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_GRETunnelInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
|
|
||||||
struct dm_reference reference = {0};
|
|
||||||
|
|
||||||
bbfdm_get_reference_linker(ctx, value, &reference);
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_string(ctx, reference.path, -1, -1, NULL, NULL))
|
|
||||||
return FAULT_9007;
|
|
||||||
|
|
||||||
if (dm_validate_allowed_objects(ctx, &reference, allowed_objects))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
// Store LowerLayers value under dmmap section
|
|
||||||
dmuci_set_value_by_section(((struct dm_data *)data)->dmmap_section, "LowerLayers", reference.path);
|
|
||||||
|
|
||||||
// Update tunlink option
|
|
||||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "tunlink", reference.value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_GRETunnelInterface_UseChecksum(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
struct uci_section *iface_section = ((struct dm_data *)data)->config_section;
|
|
||||||
char *ocsum = NULL;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(iface_section, "ocsum", &ocsum);
|
|
||||||
if (ocsum) {
|
|
||||||
if (!DM_STRCMP(ocsum, "1") || !DM_STRCMP(ocsum, "true"))
|
|
||||||
*value = "1";
|
|
||||||
else
|
|
||||||
*value = "0";
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_GRETunnelInterface_UseChecksum(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
struct uci_section *iface_section = ((struct dm_data *)data)->config_section;
|
|
||||||
bool b = true;
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_boolean(ctx, value))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
string_to_bool(value, &b);
|
|
||||||
dmuci_set_value_by_section(iface_section, "ocsum", b ? "1" : "0");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_GRETunnelInterface_UseSequenceNumber(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
struct uci_section *iface_section = ((struct dm_data *)data)->config_section;
|
|
||||||
char *oseqno = NULL;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(iface_section, "oseqno", &oseqno);
|
|
||||||
if (oseqno) {
|
|
||||||
if (!DM_STRCMP(oseqno, "1") || !DM_STRCMP(oseqno, "true"))
|
|
||||||
*value = "1";
|
|
||||||
else
|
|
||||||
*value = "0";
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_GRETunnelInterface_UseSequenceNumber(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
struct uci_section *iface_section = ((struct dm_data *)data)->config_section;
|
|
||||||
bool b = false;
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_boolean(ctx, value))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
string_to_bool(value, &b);
|
|
||||||
dmuci_set_value_by_section(iface_section, "oseqno", b ? "1" : "0");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_GRETunnelInterfaceStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
*value = get_gre_tunnel_interface_statistics(((struct dm_data *)data)->json_object, "tx_bytes");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_GRETunnelInterfaceStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
*value = get_gre_tunnel_interface_statistics(((struct dm_data *)data)->json_object, "rx_bytes");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_GRETunnelInterfaceStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
*value = get_gre_tunnel_interface_statistics(((struct dm_data *)data)->json_object, "tx_packets");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_GRETunnelInterfaceStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
*value = get_gre_tunnel_interface_statistics(((struct dm_data *)data)->json_object, "rx_packets");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_GRETunnelInterfaceStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
*value = get_gre_tunnel_interface_statistics(((struct dm_data *)data)->json_object, "tx_errors");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_GRETunnelInterfaceStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
*value = get_gre_tunnel_interface_statistics(((struct dm_data *)data)->json_object, "rx_errors");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************************************************************************************
|
|
||||||
* OBJ & PARAM DEFINITION
|
|
||||||
***********************************************************************************************************************************/
|
|
||||||
/* *** Device.GRE. *** */
|
|
||||||
DMOBJ tGREObj[] = {
|
|
||||||
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
|
|
||||||
{"Tunnel", &DMWRITE, addObjGRETunnel, delObjGRETunnel, NULL, browseGRETunnelInst, NULL, NULL, tGRETunnelObj, tGRETunnelParams, NULL, BBFDM_BOTH, NULL},
|
|
||||||
//{"Filter", &DMWRITE, addObjGREFilter, delObjGREFilter, NULL, browseGREFilterInst, NULL, NULL, NULL, tGREFilterParams, NULL, BBFDM_BOTH, NULL},
|
|
||||||
{0}
|
|
||||||
};
|
|
||||||
|
|
||||||
DMLEAF tGREParams[] = {
|
|
||||||
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version, version*/
|
|
||||||
{"TunnelNumberOfEntries", &DMREAD, DMT_UNINT, get_GRE_TunnelNumberOfEntries, NULL, BBFDM_BOTH},
|
|
||||||
//{"FilterNumberOfEntries", &DMREAD, DMT_UNINT, get_GRE_FilterNumberOfEntries, NULL, BBFDM_BOTH},
|
|
||||||
{0}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* *** Device.GRE.Tunnel.{i}. *** */
|
|
||||||
DMOBJ tGRETunnelObj[] = {
|
|
||||||
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
|
|
||||||
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tGRETunnelStatsParams, NULL, BBFDM_BOTH, NULL},
|
|
||||||
{"Interface", &DMWRITE, addObjGRETunnelInterface, delObjGRETunnelInterface, NULL, browseGRETunnelInterfaceInst, NULL, NULL, tGRETunnelInterfaceObj, tGRETunnelInterfaceParams, NULL, BBFDM_BOTH, NULL},
|
|
||||||
{0}
|
|
||||||
};
|
|
||||||
|
|
||||||
DMLEAF tGRETunnelParams[] = {
|
|
||||||
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
|
|
||||||
{"Enable", &DMWRITE, DMT_BOOL, get_GRETunnel_Enable, set_GRETunnel_Enable, BBFDM_BOTH},
|
|
||||||
{"Status", &DMREAD, DMT_STRING, get_GRETunnel_Status, NULL, BBFDM_BOTH},
|
|
||||||
{"Alias", &DMWRITE, DMT_STRING, get_GRETunnel_Alias, set_GRETunnel_Alias, BBFDM_BOTH, DM_FLAG_UNIQUE},
|
|
||||||
{"RemoteEndpoints", &DMWRITE, DMT_STRING, get_GRETunnel_RemoteEndpoints, set_GRETunnel_RemoteEndpoints, BBFDM_BOTH},
|
|
||||||
//{"KeepAlivePolicy", &DMWRITE, DMT_STRING, get_GRETunnel_KeepAlivePolicy, set_GRETunnel_KeepAlivePolicy, BBFDM_BOTH},
|
|
||||||
//{"KeepAliveTimeout", &DMWRITE, DMT_UNINT, get_GRETunnel_KeepAliveTimeout, set_GRETunnel_KeepAliveTimeout, BBFDM_BOTH},
|
|
||||||
//{"KeepAliveThreshold", &DMWRITE, DMT_UNINT, get_GRETunnel_KeepAliveThreshold, set_GRETunnel_KeepAliveThreshold, BBFDM_BOTH},
|
|
||||||
{"DeliveryHeaderProtocol", &DMWRITE, DMT_STRING, get_GRETunnel_DeliveryHeaderProtocol, set_GRETunnel_DeliveryHeaderProtocol, BBFDM_BOTH},
|
|
||||||
//{"DefaultDSCPMark", &DMWRITE, DMT_UNINT, get_GRETunnel_DefaultDSCPMark, set_GRETunnel_DefaultDSCPMark, BBFDM_BOTH},
|
|
||||||
{"ConnectedRemoteEndpoint", &DMREAD, DMT_STRING, get_GRETunnel_ConnectedRemoteEndpoint, NULL, BBFDM_BOTH},
|
|
||||||
{"InterfaceNumberOfEntries", &DMREAD, DMT_UNINT, get_GRETunnel_InterfaceNumberOfEntries, NULL, BBFDM_BOTH},
|
|
||||||
{0}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* no tunnel stats because there is no separate device section for tunnel
|
|
||||||
* and currently we only support only one interface per tunnel at a time
|
|
||||||
*/
|
|
||||||
/* *** Device.GRE.Tunnel.{i}.Stats. *** */
|
|
||||||
DMLEAF tGRETunnelStatsParams[] = {
|
|
||||||
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
|
|
||||||
//{"KeepAliveSent", &DMREAD, DMT_UNINT, get_GRETunnelStats_KeepAliveSent, NULL, BBFDM_BOTH},
|
|
||||||
//{"KeepAliveReceived", &DMREAD, DMT_UNINT, get_GRETunnelStats_KeepAliveReceived, NULL, BBFDM_BOTH},
|
|
||||||
//{"BytesSent", &DMREAD, DMT_UNINT, get_GRETunnelStats_BytesSent, NULL, BBFDM_BOTH},
|
|
||||||
//{"BytesReceived", &DMREAD, DMT_UNINT, get_GRETunnelStats_BytesReceived, NULL, BBFDM_BOTH},
|
|
||||||
//{"PacketsSent", &DMREAD, DMT_UNINT, get_GRETunnelStats_PacketsSent, NULL, BBFDM_BOTH},
|
|
||||||
//{"PacketsReceived", &DMREAD, DMT_UNINT, get_GRETunnelStats_PacketsReceived, NULL, BBFDM_BOTH},
|
|
||||||
//{"ErrorsSent", &DMREAD, DMT_UNINT, get_GRETunnelStats_ErrorsSent, NULL, BBFDM_BOTH},
|
|
||||||
//{"ErrorsReceived", &DMREAD, DMT_UNINT, get_GRETunnelStats_ErrorsReceived, NULL, BBFDM_BOTH},
|
|
||||||
{0}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* *** Device.GRE.Tunnel.{i}.Interface.{i}. *** */
|
|
||||||
DMOBJ tGRETunnelInterfaceObj[] = {
|
|
||||||
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
|
|
||||||
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tGRETunnelInterfaceStatsParams, NULL, BBFDM_BOTH, NULL},
|
|
||||||
{0}
|
|
||||||
};
|
|
||||||
|
|
||||||
DMLEAF tGRETunnelInterfaceParams[] = {
|
|
||||||
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
|
|
||||||
{"Enable", &DMWRITE, DMT_BOOL, get_GRETunnelInterface_Enable, set_GRETunnelInterface_Enable, BBFDM_BOTH},
|
|
||||||
{"Status", &DMREAD, DMT_STRING, get_GRETunnelInterface_Status, NULL, BBFDM_BOTH},
|
|
||||||
{"Alias", &DMWRITE, DMT_STRING, get_GRETunnelInterface_Alias, set_GRETunnelInterface_Alias, BBFDM_BOTH, DM_FLAG_UNIQUE},
|
|
||||||
{"Name", &DMREAD, DMT_STRING, get_GRETunnelInterface_Name, NULL, BBFDM_BOTH, DM_FLAG_UNIQUE|DM_FLAG_LINKER},
|
|
||||||
{"LastChange", &DMREAD, DMT_UNINT, get_GRETunnelInterface_LastChange, NULL, BBFDM_BOTH},
|
|
||||||
{"LowerLayers", &DMWRITE, DMT_STRING, get_GRETunnelInterface_LowerLayers, set_GRETunnelInterface_LowerLayers, BBFDM_BOTH, DM_FLAG_REFERENCE},
|
|
||||||
//{"ProtocolIdOverride", &DMWRITE, DMT_UNINT, get_GRETunnelInterface_ProtocolIdOverride, set_GRETunnelInterface_ProtocolIdOverride, BBFDM_BOTH},
|
|
||||||
{"UseChecksum", &DMWRITE, DMT_BOOL, get_GRETunnelInterface_UseChecksum, set_GRETunnelInterface_UseChecksum, BBFDM_BOTH},
|
|
||||||
//{"KeyIdentifierGenerationPolicy", &DMWRITE, DMT_STRING, get_GRETunnelInterface_KeyIdentifierGenerationPolicy, set_GRETunnelInterface_KeyIdentifierGenerationPolicy, BBFDM_BOTH},
|
|
||||||
//{"KeyIdentifier", &DMWRITE, DMT_UNINT, get_GRETunnelInterface_KeyIdentifier, set_GRETunnelInterface_KeyIdentifier, BBFDM_BOTH},
|
|
||||||
{"UseSequenceNumber", &DMWRITE, DMT_BOOL, get_GRETunnelInterface_UseSequenceNumber, set_GRETunnelInterface_UseSequenceNumber, BBFDM_BOTH},
|
|
||||||
{0}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* *** Device.GRE.Tunnel.{i}.Interface.{i}.Stats. *** */
|
|
||||||
DMLEAF tGRETunnelInterfaceStatsParams[] = {
|
|
||||||
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
|
|
||||||
{"BytesSent", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_BytesSent, NULL, BBFDM_BOTH},
|
|
||||||
{"BytesReceived", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_BytesReceived, NULL, BBFDM_BOTH},
|
|
||||||
{"PacketsSent", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_PacketsSent, NULL, BBFDM_BOTH},
|
|
||||||
{"PacketsReceived", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_PacketsReceived, NULL, BBFDM_BOTH},
|
|
||||||
{"ErrorsSent", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_ErrorsSent, NULL, BBFDM_BOTH},
|
|
||||||
{"ErrorsReceived", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_ErrorsReceived, NULL, BBFDM_BOTH},
|
|
||||||
//{"DiscardChecksumReceived", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_DiscardChecksumReceived, NULL, BBFDM_BOTH},
|
|
||||||
//{"DiscardSequenceNumberReceived", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_DiscardSequenceNumberReceived, NULL, BBFDM_BOTH},
|
|
||||||
{0}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* *** Device.GRE.Filter.{i}. *** */
|
|
||||||
DMLEAF tGREFilterParams[] = {
|
|
||||||
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
|
|
||||||
//{"Enable", &DMWRITE, DMT_BOOL, get_GREFilter_Enable, set_GREFilter_Enable, BBFDM_BOTH},
|
|
||||||
//{"Status", &DMREAD, DMT_STRING, get_GREFilter_Status, NULL, BBFDM_BOTH},
|
|
||||||
//{"Order", &DMWRITE, DMT_UNINT, get_GREFilter_Order, set_GREFilter_Order, BBFDM_BOTH},
|
|
||||||
//{"Alias", &DMWRITE, DMT_STRING, get_GREFilter_Alias, set_GREFilter_Alias, BBFDM_BOTH},
|
|
||||||
//{"Interface", &DMWRITE, DMT_STRING, get_GREFilter_Interface, set_GREFilter_Interface, BBFDM_BOTH},
|
|
||||||
//{"AllInterfaces", &DMWRITE, DMT_BOOL, get_GREFilter_AllInterfaces, set_GREFilter_AllInterfaces, BBFDM_BOTH},
|
|
||||||
//{"VLANIDCheck", &DMWRITE, DMT_INT, get_GREFilter_VLANIDCheck, set_GREFilter_VLANIDCheck, BBFDM_BOTH},
|
|
||||||
//{"VLANIDExclude", &DMWRITE, DMT_BOOL, get_GREFilter_VLANIDExclude, set_GREFilter_VLANIDExclude, BBFDM_BOTH},
|
|
||||||
//{"DSCPMarkPolicy", &DMWRITE, DMT_INT, get_GREFilter_DSCPMarkPolicy, set_GREFilter_DSCPMarkPolicy, BBFDM_BOTH},
|
|
||||||
{0}
|
|
||||||
};
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2019 iopsys Software Solutions AB
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License version 2.1
|
|
||||||
* as published by the Free Software Foundation
|
|
||||||
*
|
|
||||||
* Author: Omar Kallel <omar.kallel@pivasoftware.com>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GRE_H
|
|
||||||
#define __GRE_H
|
|
||||||
|
|
||||||
#include "libbbfdm-api/dmcommon.h"
|
|
||||||
|
|
||||||
extern DMOBJ tGREObj[];
|
|
||||||
extern DMLEAF tGREParams[];
|
|
||||||
extern DMOBJ tGRETunnelObj[];
|
|
||||||
extern DMLEAF tGRETunnelParams[];
|
|
||||||
extern DMLEAF tGRETunnelStatsParams[];
|
|
||||||
extern DMOBJ tGRETunnelInterfaceObj[];
|
|
||||||
extern DMLEAF tGRETunnelInterfaceParams[];
|
|
||||||
extern DMLEAF tGRETunnelInterfaceStatsParams[];
|
|
||||||
extern DMLEAF tGREFilterParams[];
|
|
||||||
|
|
||||||
#endif //__GRE_H
|
|
||||||
|
|
||||||
|
|
@ -1,328 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2023 iopsys Software Solutions AB
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License version 2.1
|
|
||||||
* as published by the Free Software Foundation
|
|
||||||
*
|
|
||||||
* Author: Amin Ben Romdhane <amin.benromdhane@iopsys.eu>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "interfacestack.h"
|
|
||||||
|
|
||||||
struct interfacestack_data
|
|
||||||
{
|
|
||||||
char *HigherLayer;
|
|
||||||
char *LowerLayer;
|
|
||||||
char *HigherAlias;
|
|
||||||
char *LowerAlias;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* COMMON FUNCTIONS
|
|
||||||
**************************************************************/
|
|
||||||
static struct uci_section *get_bridge_management_port_section(char *instance)
|
|
||||||
{
|
|
||||||
struct uci_section *s = NULL;
|
|
||||||
char *management = NULL;
|
|
||||||
|
|
||||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "br_inst", instance, s) {
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(s, "management", &management);
|
|
||||||
if (DM_STRCMP(management, "1") == 0)
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *get_lower_alias_value(const char *path)
|
|
||||||
{
|
|
||||||
struct uci_section *s = NULL;
|
|
||||||
char *alias_value = "";
|
|
||||||
|
|
||||||
if (DM_STRLEN(path) == 0)
|
|
||||||
return "";
|
|
||||||
|
|
||||||
char *instance = DM_STRRCHR(path, '.');
|
|
||||||
if (!instance)
|
|
||||||
return "";
|
|
||||||
|
|
||||||
if (DM_STRNCMP(path, "Device.IP.Interface.", strlen("Device.IP.Interface.")) == 0) {
|
|
||||||
get_dmmap_section_of_config_section_eq("dmmap_network", "interface", "ip_int_instance", instance + 1, &s);
|
|
||||||
dmuci_get_value_by_section_string(s, "ip_int_alias", &alias_value);
|
|
||||||
} else if (DM_STRNCMP(path, "Device.Ethernet.Link.", strlen("Device.Ethernet.Link.")) == 0) {
|
|
||||||
get_dmmap_section_of_config_section_eq("dmmap_ethernet", "link", "link_instance", instance + 1, &s);
|
|
||||||
dmuci_get_value_by_section_string(s, "link_alias", &alias_value);
|
|
||||||
} else if (DM_STRNCMP(path, "Device.Ethernet.Interface.", strlen("Device.Ethernet.Interface.")) == 0) {
|
|
||||||
get_dmmap_section_of_config_section_eq("dmmap_ethernet", "device", "eth_iface_instance", instance + 1, &s);
|
|
||||||
dmuci_get_value_by_section_string(s, "eth_iface_alias", &alias_value);
|
|
||||||
} else if (DM_STRNCMP(path, "Device.Bridging.Bridge.", strlen("Device.Bridging.Bridge.")) == 0 ||
|
|
||||||
DM_STRNCMP(path, "Device.GRE.Tunnel.", strlen("Device.GRE.Tunnel.")) == 0) {
|
|
||||||
regmatch_t pmatch[1] = {0};
|
|
||||||
char first_inst[8] = {0};
|
|
||||||
char *second_inst = NULL;
|
|
||||||
|
|
||||||
bool res = match(path, "([0-9]+)", 1, pmatch);
|
|
||||||
if (res) {
|
|
||||||
DM_STRNCPY(first_inst, &path[pmatch[0].rm_so], pmatch[0].rm_eo - pmatch[0].rm_so + 1);
|
|
||||||
if (DM_STRLEN(first_inst) == 0)
|
|
||||||
return "";
|
|
||||||
|
|
||||||
if (DM_STRNCMP(path, "Device.Bridging.Bridge.", strlen("Device.Bridging.Bridge.")) == 0) {
|
|
||||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "br_inst", first_inst, s) {
|
|
||||||
dmuci_get_value_by_section_string(s, "bridge_port_instance", &second_inst);
|
|
||||||
if (DM_STRCMP(second_inst, instance + 1) == 0) {
|
|
||||||
dmuci_get_value_by_section_string(s, "bridge_port_alias", &alias_value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (DM_STRNCMP(path, "Device.GRE.Tunnel.", strlen("Device.GRE.Tunnel.")) == 0) {
|
|
||||||
uci_path_foreach_option_eq(bbfdm, "dmmap_gre", "interface", "tunnel_instance", first_inst, s) {
|
|
||||||
dmuci_get_value_by_section_string(s, "gre_iface_instance", &second_inst);
|
|
||||||
if (DM_STRCMP(second_inst, instance + 1) == 0) {
|
|
||||||
dmuci_get_value_by_section_string(s, "gre_iface_alias", &alias_value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (DM_STRNCMP(path, "Device.WiFi.SSID.", strlen("Device.WiFi.SSID.")) == 0) {
|
|
||||||
get_dmmap_section_of_config_section_eq("dmmap_wireless", "ssid", "ssid_instance", instance + 1, &s);
|
|
||||||
dmuci_get_value_by_section_string(s, "ssid_alias", &alias_value);
|
|
||||||
} else if (DM_STRNCMP(path, "Device.WiFi.Radio.", strlen("Device.WiFi.Radio.")) == 0) {
|
|
||||||
get_dmmap_section_of_config_section_eq("dmmap_wireless", "wifi-device", "radioinstance", instance + 1, &s);
|
|
||||||
dmuci_get_value_by_section_string(s, "radioalias", &alias_value);
|
|
||||||
} else if (DM_STRNCMP(path, "Device.Ethernet.VLANTermination.", strlen("Device.Ethernet.VLANTermination.")) == 0) {
|
|
||||||
get_dmmap_section_of_config_section_eq("dmmap_network", "device", "vlan_term_instance", instance + 1, &s);
|
|
||||||
dmuci_get_value_by_section_string(s, "vlan_term_alias", &alias_value);
|
|
||||||
} else if (DM_STRNCMP(path, "Device.PPP.Interface.", strlen("Device.PPP.Interface.")) == 0) {
|
|
||||||
get_dmmap_section_of_config_section_eq("dmmap_ppp", "interface", "ppp_int_instance", instance + 1, &s);
|
|
||||||
dmuci_get_value_by_section_string(s, "ppp_int_alias", &alias_value);
|
|
||||||
} else if (DM_STRNCMP(path, "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN.", strlen("Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN.")) == 0) {
|
|
||||||
get_dmmap_section_of_config_section_eq("dmmap_network", "device", "mac_vlan_instance", instance + 1, &s);
|
|
||||||
dmuci_get_value_by_section_string(s, "mac_vlan_alias", &alias_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return alias_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int create_interface_stack_instance(struct dmctx *dmctx, DMNODE *parent_node,
|
|
||||||
struct interfacestack_data *data, struct uci_section *s,
|
|
||||||
char *path, char *inst_number, char *inst_alias, int *curr_inst)
|
|
||||||
{
|
|
||||||
struct dm_data curr_data = {0};
|
|
||||||
char *instance = NULL, *inst = NULL;
|
|
||||||
char *LowerLayer = NULL;
|
|
||||||
|
|
||||||
if (!s || !data || !path || !inst_number || !inst_alias)
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(s, inst_number, &instance);
|
|
||||||
if (DM_STRLEN(instance) == 0)
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
dmasprintf(&data->HigherLayer, "%s%s", path, instance);
|
|
||||||
dmuci_get_value_by_section_string(s, inst_alias, &data->HigherAlias);
|
|
||||||
dmuci_get_value_by_section_string(s, "LowerLayers", &LowerLayer);
|
|
||||||
|
|
||||||
data->LowerLayer = get_value_by_reference(dmctx, LowerLayer);
|
|
||||||
data->LowerAlias = get_lower_alias_value(data->LowerLayer);
|
|
||||||
|
|
||||||
inst = handle_instance_without_section(dmctx, parent_node, ++(*curr_inst));
|
|
||||||
|
|
||||||
curr_data.additional_data = (void *)data;
|
|
||||||
|
|
||||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, &curr_data, inst) == DM_STOP)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
end:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* ENTRY METHOD
|
|
||||||
**************************************************************/
|
|
||||||
int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
|
||||||
{
|
|
||||||
struct interfacestack_data curr_interfacestack_data = {0};
|
|
||||||
struct uci_section *s = NULL;
|
|
||||||
int idx = 0;
|
|
||||||
|
|
||||||
/* Higher Layer is Device.IP.Interface.{i}. */
|
|
||||||
uci_path_foreach_sections(bbfdm, "dmmap_network", "interface", s) {
|
|
||||||
|
|
||||||
if (create_interface_stack_instance(dmctx, parent_node, &curr_interfacestack_data, s,
|
|
||||||
"Device.IP.Interface.", "ip_int_instance", "ip_int_alias", &idx))
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Higher Layer is Device.GRE.Tunnel.{i}.Interface.{i}. */
|
|
||||||
uci_path_foreach_sections(bbfdm, "dmmap_gre", "interface", s) {
|
|
||||||
char *tunnel_inst = NULL;
|
|
||||||
char path[128] = {0};
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(s, "tunnel_instance", &tunnel_inst);
|
|
||||||
|
|
||||||
snprintf(path, sizeof(path), "Device.GRE.Tunnel.%s.Interface.", tunnel_inst);
|
|
||||||
|
|
||||||
if (create_interface_stack_instance(dmctx, parent_node, &curr_interfacestack_data, s,
|
|
||||||
path, "gre_iface_instance", "gre_iface_alias", &idx))
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Higher Layer is Device.PPP.Interface.{i}. */
|
|
||||||
uci_path_foreach_sections(bbfdm, "dmmap_ppp", "interface", s) {
|
|
||||||
|
|
||||||
if (create_interface_stack_instance(dmctx, parent_node, &curr_interfacestack_data, s,
|
|
||||||
"Device.PPP.Interface.", "ppp_int_instance", "ppp_int_alias", &idx))
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Higher Layer is Device.Ethernet.X_IOPSYS_EU_MACVLAN.{i}. */
|
|
||||||
uci_path_foreach_sections(bbfdm, "dmmap_network", "device", s) {
|
|
||||||
|
|
||||||
if (create_interface_stack_instance(dmctx, parent_node, &curr_interfacestack_data, s,
|
|
||||||
"Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN.", "mac_vlan_instance", "mac_vlan_alias", &idx))
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Higher Layer is Device.Ethernet.VLANTermination.{i}. */
|
|
||||||
uci_path_foreach_sections(bbfdm, "dmmap_network", "device", s) {
|
|
||||||
|
|
||||||
if (create_interface_stack_instance(dmctx, parent_node, &curr_interfacestack_data, s,
|
|
||||||
"Device.Ethernet.VLANTermination.", "vlan_term_instance", "vlan_term_alias", &idx))
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Higher Layer is Device.Ethernet.Link.{i}. */
|
|
||||||
uci_path_foreach_sections(bbfdm, "dmmap_ethernet", "link", s) {
|
|
||||||
|
|
||||||
if (create_interface_stack_instance(dmctx, parent_node, &curr_interfacestack_data, s,
|
|
||||||
"Device.Ethernet.Link.", "link_instance", "link_alias", &idx))
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Higher Layer is Device.Bridging.Bridge.{i}.Port.{i}.*/
|
|
||||||
uci_path_foreach_sections(bbfdm, "dmmap_bridge", "device", s) {
|
|
||||||
struct uci_section *port_s = NULL;
|
|
||||||
char *br_instance = NULL;
|
|
||||||
char *mg_port_instnace = NULL;
|
|
||||||
char *mg_port_alias = NULL;
|
|
||||||
char *inst = NULL;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(s, "bridge_instance", &br_instance);
|
|
||||||
if (DM_STRLEN(br_instance) == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
struct uci_section *mg_port_s = get_bridge_management_port_section(br_instance);
|
|
||||||
if (!mg_port_s)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(mg_port_s, "bridge_port_instance", &mg_port_instnace);
|
|
||||||
dmuci_get_value_by_section_string(mg_port_s, "bridge_port_alias", &mg_port_alias);
|
|
||||||
|
|
||||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "br_inst", br_instance, port_s) {
|
|
||||||
struct dm_data curr_data = {0};
|
|
||||||
char *management = NULL;
|
|
||||||
char *instance_value = NULL;
|
|
||||||
char *alias_value = NULL;
|
|
||||||
char *config = NULL;
|
|
||||||
char path[128] = {0};
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(port_s, "management", &management);
|
|
||||||
if (DM_STRCMP(management, "1") == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(port_s, "bridge_port_instance", &instance_value);
|
|
||||||
dmuci_get_value_by_section_string(port_s, "bridge_port_alias", &alias_value);
|
|
||||||
|
|
||||||
dmasprintf(&curr_interfacestack_data.HigherLayer, "Device.Bridging.Bridge.%s.Port.%s", br_instance, mg_port_instnace);
|
|
||||||
curr_interfacestack_data.HigherAlias = mg_port_alias;
|
|
||||||
dmasprintf(&curr_interfacestack_data.LowerLayer, "Device.Bridging.Bridge.%s.Port.%s", br_instance, instance_value);
|
|
||||||
curr_interfacestack_data.LowerAlias = alias_value;
|
|
||||||
|
|
||||||
inst = handle_instance_without_section(dmctx, parent_node, ++idx);
|
|
||||||
curr_data.additional_data = (void *)&curr_interfacestack_data;
|
|
||||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, &curr_data, inst) == DM_STOP)
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
/* Higher Layer is Device.Bridging.Bridge.{i}.Port.{i}.*/
|
|
||||||
snprintf(path, sizeof(path), "Device.Bridging.Bridge.%s.Port.", br_instance);
|
|
||||||
|
|
||||||
if (create_interface_stack_instance(dmctx, parent_node, &curr_interfacestack_data, port_s,
|
|
||||||
path, "bridge_port_instance", "bridge_port_alias", &idx))
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
/* Higher Layer is Device.WiFi.SSID.{i}.*/
|
|
||||||
dmuci_get_value_by_section_string(port_s, "config", &config);
|
|
||||||
if (DM_STRCMP(config, "wireless") == 0) {
|
|
||||||
struct uci_section *wl_s = NULL;
|
|
||||||
char *port = NULL;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(port_s, "port", &port);
|
|
||||||
wl_s = get_dup_section_in_config_opt("wireless", "wifi-iface", "ifname", port);
|
|
||||||
wl_s = get_dup_section_in_dmmap_opt("dmmap_wireless", "ssid", "ap_section_name", section_name(wl_s));
|
|
||||||
|
|
||||||
if (create_interface_stack_instance(dmctx, parent_node, &curr_interfacestack_data, wl_s,
|
|
||||||
"Device.WiFi.SSID.", "ssid_instance", "ssid_alias", &idx))
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
end:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* GET & SET PARAM
|
|
||||||
**************************************************************/
|
|
||||||
static int get_InterfaceStack_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
dmasprintf(value, "cpe-%s", instance);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_InterfaceStack_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_InterfaceStack_HigherLayer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
*value = ((struct interfacestack_data *)((struct dm_data *)data)->additional_data)->HigherLayer;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_InterfaceStack_LowerLayer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
*value = ((struct interfacestack_data *)((struct dm_data *)data)->additional_data)->LowerLayer;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_InterfaceStack_HigherAlias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
*value = ((struct interfacestack_data *)((struct dm_data *)data)->additional_data)->HigherAlias;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_InterfaceStack_LowerAlias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
*value = ((struct interfacestack_data *)((struct dm_data *)data)->additional_data)->LowerAlias;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************************************************************************************
|
|
||||||
* OBJ & PARAM DEFINITION
|
|
||||||
***********************************************************************************************************************************/
|
|
||||||
/* *** Device.InterfaceStack.{i}. *** */
|
|
||||||
DMLEAF tInterfaceStackParams[] = {
|
|
||||||
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
|
|
||||||
{"Alias", &DMWRITE, DMT_STRING, get_InterfaceStack_Alias, set_InterfaceStack_Alias, BBFDM_BOTH, DM_FLAG_UNIQUE},
|
|
||||||
{"HigherLayer", &DMREAD, DMT_STRING, get_InterfaceStack_HigherLayer, NULL, BBFDM_BOTH},
|
|
||||||
{"LowerLayer", &DMREAD, DMT_STRING, get_InterfaceStack_LowerLayer, NULL, BBFDM_BOTH},
|
|
||||||
{"HigherAlias", &DMREAD, DMT_STRING, get_InterfaceStack_HigherAlias, NULL, BBFDM_BOTH},
|
|
||||||
{"LowerAlias", &DMREAD, DMT_STRING, get_InterfaceStack_LowerAlias, NULL, BBFDM_BOTH},
|
|
||||||
{0}
|
|
||||||
};
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2023 iopsys Software Solutions AB
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License version 2.1
|
|
||||||
* as published by the Free Software Foundation
|
|
||||||
*
|
|
||||||
* Author: Amin Ben Romdhane <amin.benromdhane@iopsys.eu>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __INTERFACESTACK_H
|
|
||||||
#define __INTERFACESTACK_H
|
|
||||||
|
|
||||||
#include "libbbfdm-api/dmcommon.h"
|
|
||||||
|
|
||||||
extern DMLEAF tInterfaceStackParams[];
|
|
||||||
|
|
||||||
int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
|
|
||||||
|
|
||||||
#endif //__INTERFACESTACK_H
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,29 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2020 iopsys Software Solutions AB
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License version 2.1
|
|
||||||
* as published by the Free Software Foundation
|
|
||||||
*
|
|
||||||
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
|
|
||||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __IP_H
|
|
||||||
#define __IP_H
|
|
||||||
|
|
||||||
#include "libbbfdm-api/dmcommon.h"
|
|
||||||
|
|
||||||
extern DMOBJ tIPObj[];
|
|
||||||
extern DMLEAF tIPParams[];
|
|
||||||
extern DMOBJ tIPInterfaceObj[];
|
|
||||||
extern DMLEAF tIPInterfaceParams[];
|
|
||||||
extern DMLEAF tIPInterfaceIPv4AddressParams[];
|
|
||||||
extern DMLEAF tIPInterfaceIPv6AddressParams[];
|
|
||||||
extern DMLEAF tIPInterfaceIPv6PrefixParams[];
|
|
||||||
extern DMLEAF tIPInterfaceStatsParams[];
|
|
||||||
extern DMLEAF tIPActivePortParams[];
|
|
||||||
|
|
||||||
#endif //__IP_H
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,29 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2019 iopsys Software Solutions AB
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License version 2.1
|
|
||||||
* as published by the Free Software Foundation
|
|
||||||
*
|
|
||||||
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __PPP_H
|
|
||||||
#define __PPP_H
|
|
||||||
|
|
||||||
#include "libbbfdm-api/dmcommon.h"
|
|
||||||
|
|
||||||
#define IPCP 0
|
|
||||||
#define IPCPv6 1
|
|
||||||
|
|
||||||
extern DMOBJ tPPPObj[];
|
|
||||||
extern DMLEAF tPPPParams[];
|
|
||||||
extern DMOBJ tPPPInterfaceObj[];
|
|
||||||
extern DMLEAF tPPPInterfaceParams[];
|
|
||||||
extern DMLEAF tPPPInterfacePPPoEParams[];
|
|
||||||
extern DMLEAF tPPPInterfaceIPCPParams[];
|
|
||||||
extern DMLEAF tPPPInterfaceIPv6CPParams[];
|
|
||||||
extern DMLEAF tPPPInterfaceStatsParams[];
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,748 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2021 iopsys Software Solutions AB
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License version 2.1
|
|
||||||
* as published by the Free Software Foundation
|
|
||||||
*
|
|
||||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "routeradvertisement.h"
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* COMMON FUNCTIONS
|
|
||||||
**************************************************************/
|
|
||||||
/* Returns dnsmasq section name belonging to LAN network */
|
|
||||||
char *get_dhcp_dnsmasq_section_name(void)
|
|
||||||
{
|
|
||||||
struct uci_section *s = NULL;
|
|
||||||
|
|
||||||
uci_foreach_sections("dhcp", "dnsmasq", s) {
|
|
||||||
char *sec = section_name(s);
|
|
||||||
if (DM_STRCMP(sec, "dns_client") != 0)
|
|
||||||
return sec;
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
static int radv_get_option_value(struct uci_section *s, char *option_list, const char *option_value, char **value)
|
|
||||||
{
|
|
||||||
struct uci_list *uci_list = NULL;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_list(s, option_list, &uci_list);
|
|
||||||
*value = (value_exists_in_uci_list(uci_list, option_value)) ? "1" : "0";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int radv_set_option_value(struct uci_section *s, char *option_list, const char *option_value, bool b)
|
|
||||||
{
|
|
||||||
struct uci_list *uci_list = NULL;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_list(s, option_list, &uci_list);
|
|
||||||
if (b) {
|
|
||||||
if (!value_exists_in_uci_list(uci_list, option_value))
|
|
||||||
dmuci_add_list_value_by_section(s, option_list, (char *)option_value);
|
|
||||||
} else {
|
|
||||||
if (value_exists_in_uci_list(uci_list, option_value))
|
|
||||||
dmuci_del_list_value_by_section(s, option_list, (char *)option_value);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* ENTRY METHOD
|
|
||||||
**************************************************************/
|
|
||||||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.!UCI:dhcp/dhcp/dmmap_radv*/
|
|
||||||
static int browseRouterAdvertisementInterfaceSettingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
|
||||||
{
|
|
||||||
char *inst = NULL, *ignore = NULL;
|
|
||||||
struct dm_data *curr_data = NULL;
|
|
||||||
LIST_HEAD(dup_list);
|
|
||||||
|
|
||||||
synchronize_specific_config_sections_with_dmmap("dhcp", "dhcp", "dmmap_radv", &dup_list);
|
|
||||||
list_for_each_entry(curr_data, &dup_list, list) {
|
|
||||||
|
|
||||||
// skip the section if option ignore = '1'
|
|
||||||
dmuci_get_value_by_section_string(curr_data->config_section, "ignore", &ignore);
|
|
||||||
if (ignore && DM_LSTRCMP(ignore, "1") == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "radv_intf_instance", "radv_intf_alias");
|
|
||||||
|
|
||||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
free_dmmap_config_dup_list(&dup_list);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int browseRouterAdvertisementInterfaceSettingOptionInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
|
||||||
{
|
|
||||||
struct uci_section *dhcp_s = ((struct dm_data *)prev_data)->config_section;
|
|
||||||
struct uci_section *dhcp_dmmap_s = NULL;
|
|
||||||
struct dm_data curr_data = {0};
|
|
||||||
struct uci_list *dns_list = NULL;
|
|
||||||
char *inst = NULL, *option_value = NULL;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_list(dhcp_s, "dns", &dns_list);
|
|
||||||
|
|
||||||
if (dns_list != NULL) {
|
|
||||||
struct uci_element *e = NULL;
|
|
||||||
|
|
||||||
uci_foreach_element(dns_list, e) {
|
|
||||||
if ((dhcp_dmmap_s = get_dup_section_in_dmmap_eq("dmmap_radv", "radv_option", section_name(dhcp_s), "option_value", e->name)) == NULL) {
|
|
||||||
dmuci_add_section_bbfdm("dmmap_radv", "radv_option", &dhcp_dmmap_s);
|
|
||||||
dmuci_set_value_by_section_bbfdm(dhcp_dmmap_s, "option_value", e->name);
|
|
||||||
dmuci_set_value_by_section_bbfdm(dhcp_dmmap_s, "section_name", section_name(dhcp_s));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uci_path_foreach_option_eq(bbfdm, "dmmap_radv", "radv_option", "section_name", section_name(dhcp_s), dhcp_dmmap_s) {
|
|
||||||
dmuci_get_value_by_section_string(dhcp_dmmap_s, "option_value", &option_value);
|
|
||||||
|
|
||||||
curr_data.config_section = dhcp_s;
|
|
||||||
curr_data.dmmap_section = dhcp_dmmap_s;
|
|
||||||
curr_data.additional_data = (void *)option_value;
|
|
||||||
|
|
||||||
inst = handle_instance(dmctx, parent_node, dhcp_dmmap_s, "radv_option_instance", "radv_option_alias");
|
|
||||||
|
|
||||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_data, inst) == DM_STOP)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* ADD & DEL OBJ
|
|
||||||
**************************************************************/
|
|
||||||
static int addObjRouterAdvertisementInterfaceSetting(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
|
||||||
{
|
|
||||||
struct uci_section *dmmap = NULL, *s = NULL;
|
|
||||||
char ra_sname[32] = {0};
|
|
||||||
|
|
||||||
snprintf(ra_sname, sizeof(ra_sname), "ra_%s", *instance);
|
|
||||||
|
|
||||||
dmuci_add_section("dhcp", "dhcp", &s);
|
|
||||||
dmuci_rename_section_by_section(s, ra_sname);
|
|
||||||
dmuci_set_value_by_section(s, "ignore", "0");
|
|
||||||
dmuci_set_value_by_section(s, "ra", "disabled");
|
|
||||||
dmuci_set_value_by_section(s, "ra_flags", "none");
|
|
||||||
|
|
||||||
dmuci_add_section_bbfdm("dmmap_radv", "dhcp", &dmmap);
|
|
||||||
dmuci_set_value_by_section(dmmap, "section_name", ra_sname);
|
|
||||||
dmuci_set_value_by_section(dmmap, "radv_intf_instance", *instance);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int delObjRouterAdvertisementInterfaceSetting(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
|
|
||||||
{
|
|
||||||
struct uci_section *s = NULL, *stmp = NULL;
|
|
||||||
|
|
||||||
switch (del_action) {
|
|
||||||
case DEL_INST:
|
|
||||||
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
|
|
||||||
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
|
|
||||||
break;
|
|
||||||
case DEL_ALL:
|
|
||||||
uci_foreach_sections_safe("dhcp", "dhcp", stmp, s) {
|
|
||||||
struct uci_section *dmmap_section = NULL;
|
|
||||||
|
|
||||||
get_dmmap_section_of_config_section("dmmap_radv", "dhcp", section_name(s), &dmmap_section);
|
|
||||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
|
||||||
|
|
||||||
dmuci_delete_by_section(s, NULL, NULL);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int addObjRouterAdvertisementInterfaceSettingOption(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
|
||||||
{
|
|
||||||
struct uci_section *dmmap_sect = NULL;
|
|
||||||
|
|
||||||
dmuci_add_section_bbfdm("dmmap_radv", "radv_option", &dmmap_sect);
|
|
||||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(((struct dm_data *)data)->config_section));
|
|
||||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "option_tag", "23");
|
|
||||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "radv_option_instance", *instance);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int delObjRouterAdvertisementInterfaceSettingOption(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
|
|
||||||
{
|
|
||||||
struct uci_section *s = NULL, *stmp = NULL;
|
|
||||||
struct uci_list *dns_list = NULL;
|
|
||||||
|
|
||||||
switch (del_action) {
|
|
||||||
case DEL_INST:
|
|
||||||
dmuci_get_value_by_section_list(((struct dm_data *)data)->config_section, "dns", &dns_list);
|
|
||||||
if (value_exists_in_uci_list(dns_list, ((struct dm_data *)data)->additional_data))
|
|
||||||
dmuci_del_list_value_by_section(((struct dm_data *)data)->config_section, "dns", ((struct dm_data *)data)->additional_data);
|
|
||||||
|
|
||||||
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
|
|
||||||
break;
|
|
||||||
case DEL_ALL:
|
|
||||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "dns", "");
|
|
||||||
uci_path_foreach_sections_safe(bbfdm, "dmmap_radv", "radv_option", stmp, s) {
|
|
||||||
dmuci_delete_by_section(s, NULL, NULL);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* GET & SET PARAM
|
|
||||||
**************************************************************/
|
|
||||||
/*#Device.RouterAdvertisement.Enable!UCI:dhcp/dnsmasq,@dnsmasq[0]/raserver*/
|
|
||||||
static int get_RouterAdvertisement_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
char *sec = get_dhcp_dnsmasq_section_name();
|
|
||||||
|
|
||||||
if (DM_STRLEN(sec) == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
*value = dmuci_get_option_value_fallback_def("dhcp", sec, "raserver", "1");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_RouterAdvertisement_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
bool b;
|
|
||||||
char *sec;
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_boolean(ctx, value))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
sec = get_dhcp_dnsmasq_section_name();
|
|
||||||
if (DM_STRLEN(sec) == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
string_to_bool(value, &b);
|
|
||||||
dmuci_set_value("dhcp", sec, "raserver", b ? "1" : "0");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_RouterAdvertisement_InterfaceSettingNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
int cnt = get_number_of_entries(ctx, data, instance, browseRouterAdvertisementInterfaceSettingInst);
|
|
||||||
dmasprintf(value, "%d", cnt);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.Enable!UCI:dhcp/dhcp,@i-1/ra*/
|
|
||||||
static int get_RouterAdvertisementInterfaceSetting_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "ra", value);
|
|
||||||
*value = (*value && DM_LSTRCMP(*value, "disabled") == 0) ? "0" : "1";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_RouterAdvertisementInterfaceSetting_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
bool b;
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_boolean(ctx, value))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
string_to_bool(value, &b);
|
|
||||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ra", b ? "server" : "disabled");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.Status!UCI:dhcp/dhcp,@i-1/ra*/
|
|
||||||
static int get_RouterAdvertisementInterfaceSetting_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "ra", value);
|
|
||||||
*value = (*value && DM_LSTRCMP(*value, "disabled") == 0) ? "Disabled" : "Enabled";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_RouterAdvertisementInterfaceSetting_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
return bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, "radv_intf_alias", instance, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_RouterAdvertisementInterfaceSetting_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, "radv_intf_alias", instance, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.Interface!UCI:dhcp/dhcp,@i-1/interface*/
|
|
||||||
static int get_RouterAdvertisementInterfaceSetting_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
char *linker = NULL;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "interface", &linker);
|
|
||||||
_bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", linker, value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_RouterAdvertisementInterfaceSetting_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
|
|
||||||
struct dm_reference reference = {0};
|
|
||||||
|
|
||||||
bbfdm_get_reference_linker(ctx, value, &reference);
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_string(ctx, reference.path, -1, -1, NULL, NULL))
|
|
||||||
return FAULT_9007;
|
|
||||||
|
|
||||||
if (dm_validate_allowed_objects(ctx, &reference, allowed_objects))
|
|
||||||
return FAULT_9007;
|
|
||||||
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "interface", reference.value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_RouterAdvertisementInterfaceSetting_Prefixes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
json_object *res = NULL, *ipv6_prefix_obj = NULL, *arrobj = NULL;
|
|
||||||
char *interface = NULL, *ip_inst = NULL, list_val[512];
|
|
||||||
struct uci_section *dmmap_s = NULL;
|
|
||||||
int i = 0, pos = 0;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "interface", &interface);
|
|
||||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "ip_int_instance", &ip_inst);
|
|
||||||
|
|
||||||
list_val[0] = 0;
|
|
||||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", interface, String}}, 1, &res);
|
|
||||||
dmjson_foreach_obj_in_array(res, arrobj, ipv6_prefix_obj, i, 1, "ipv6-prefix-assignment") {
|
|
||||||
char ipv6_prefix[64], *ipv6_prefix_inst = NULL;
|
|
||||||
|
|
||||||
char *address = dmjson_get_value(ipv6_prefix_obj, 1, "address");
|
|
||||||
char *mask = dmjson_get_value(ipv6_prefix_obj, 1, "mask");
|
|
||||||
snprintf(ipv6_prefix, sizeof(ipv6_prefix), "%s/%s", address, mask);
|
|
||||||
|
|
||||||
uci_path_foreach_option_eq(bbfdm, "dmmap_network_ipv6_prefix", "intf_ipv6_prefix", "section_name", interface, dmmap_s) {
|
|
||||||
dmuci_get_value_by_section_string(dmmap_s, "address", &address);
|
|
||||||
if (address && DM_STRCMP(address, ipv6_prefix) == 0) {
|
|
||||||
dmuci_get_value_by_section_string(dmmap_s, "ipv6_prefix_instance", &ipv6_prefix_inst);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ip_inst && *ip_inst && ipv6_prefix_inst && *ipv6_prefix_inst)
|
|
||||||
pos += snprintf(&list_val[pos], sizeof(list_val) - pos, "Device.IP.Interface.%s.IPv6Prefix.%s,", ip_inst, ipv6_prefix_inst);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* cut tailing ',' */
|
|
||||||
if (pos)
|
|
||||||
list_val[pos - 1] = 0;
|
|
||||||
|
|
||||||
*value = dmstrdup(list_val);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.MaxRtrAdvInterval!UCI:dhcp/dhcp,@i-1/ra_maxinterval*/
|
|
||||||
static int get_RouterAdvertisementInterfaceSetting_MaxRtrAdvInterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "ra_maxinterval", "600");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_RouterAdvertisementInterfaceSetting_MaxRtrAdvInterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"4","1800"}}, 1))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ra_maxinterval", value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.MinRtrAdvInterval!UCI:dhcp/dhcp,@i-1/ra_mininterval*/
|
|
||||||
static int get_RouterAdvertisementInterfaceSetting_MinRtrAdvInterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "ra_mininterval", "200");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_RouterAdvertisementInterfaceSetting_MinRtrAdvInterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"3","1350"}}, 1))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ra_mininterval", value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.AdvDefaultLifetime!UCI:dhcp/dhcp,@i-1/ra_lifetime*/
|
|
||||||
static int get_RouterAdvertisementInterfaceSetting_AdvDefaultLifetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "ra_lifetime", "1800");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_RouterAdvertisementInterfaceSetting_AdvDefaultLifetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{NULL,"65535"}}, 1))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ra_lifetime", value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.AdvManagedFlag!UCI:dhcp/dhcp,@i-1/ra_flags*/
|
|
||||||
static int get_RouterAdvertisementInterfaceSetting_AdvManagedFlag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
return radv_get_option_value(((struct dm_data *)data)->config_section, "ra_flags", "managed-config", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_RouterAdvertisementInterfaceSetting_AdvManagedFlag(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
bool b;
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_boolean(ctx, value))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
string_to_bool(value, &b);
|
|
||||||
return radv_set_option_value(((struct dm_data *)data)->config_section, "ra_flags", "managed-config", b);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.AdvOtherConfigFlag!UCI:dhcp/dhcp,@i-1/ra_flags*/
|
|
||||||
static int get_RouterAdvertisementInterfaceSetting_AdvOtherConfigFlag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
return radv_get_option_value(((struct dm_data *)data)->config_section, "ra_flags", "other-config", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_RouterAdvertisementInterfaceSetting_AdvOtherConfigFlag(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
bool b;
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_boolean(ctx, value))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
string_to_bool(value, &b);
|
|
||||||
return radv_set_option_value(((struct dm_data *)data)->config_section, "ra_flags", "other-config", b);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.AdvMobileAgentFlag!UCI:dhcp/dhcp,@i-1/ra_flags*/
|
|
||||||
static int get_RouterAdvertisementInterfaceSetting_AdvMobileAgentFlag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
return radv_get_option_value(((struct dm_data *)data)->config_section, "ra_flags", "home-agent", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_RouterAdvertisementInterfaceSetting_AdvMobileAgentFlag(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
bool b;
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_boolean(ctx, value))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
string_to_bool(value, &b);
|
|
||||||
return radv_set_option_value(((struct dm_data *)data)->config_section, "ra_flags", "home-agent", b);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.AdvPreferredRouterFlag!UCI:dhcp/dhcp,@i-1/ra_preference*/
|
|
||||||
static int get_RouterAdvertisementInterfaceSetting_AdvPreferredRouterFlag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
char *preferenece = NULL;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "ra_preference", &preferenece);
|
|
||||||
*value = (preferenece && *preferenece == 'h') ? "High" : (preferenece && *preferenece == 'l') ? "Low" : "Medium";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_RouterAdvertisementInterfaceSetting_AdvPreferredRouterFlag(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
char *Adv_Preferred_RouterFlag[] = {"High", "Medium", "Low", NULL};
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_string(ctx, value, -1, -1, Adv_Preferred_RouterFlag, NULL))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ra_preference", (*value == 'H') ? "high" : (*value == 'L') ? "low" : "medium");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.AdvLinkMTU!UCI:dhcp/dhcp,@i-1/ra_mtu*/
|
|
||||||
static int get_RouterAdvertisementInterfaceSetting_AdvLinkMTU(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "ra_mtu", "0");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_RouterAdvertisementInterfaceSetting_AdvLinkMTU(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{NULL,NULL}}, 1))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ra_mtu", value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.AdvReachableTime!UCI:dhcp/dhcp,@i-1/ra_reachabletime*/
|
|
||||||
static int get_RouterAdvertisementInterfaceSetting_AdvReachableTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "ra_reachabletime", "0");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_RouterAdvertisementInterfaceSetting_AdvReachableTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{NULL,"3600000"}}, 1))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ra_reachabletime", value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.AdvRetransTimer!UCI:dhcp/dhcp,@i-1/ra_retranstime*/
|
|
||||||
static int get_RouterAdvertisementInterfaceSetting_AdvRetransTimer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "ra_retranstime", "0");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_RouterAdvertisementInterfaceSetting_AdvRetransTimer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{NULL,NULL}}, 1))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ra_retranstime", value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.AdvCurHopLimit!UCI:dhcp/dhcp,@i-1/ra_hoplimit*/
|
|
||||||
static int get_RouterAdvertisementInterfaceSetting_AdvCurHopLimit(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "ra_hoplimit", "0");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_RouterAdvertisementInterfaceSetting_AdvCurHopLimit(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{NULL,"255"}}, 1))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ra_hoplimit", value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_RouterAdvertisementInterfaceSetting_OptionNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
int cnt = get_number_of_entries(ctx, data, instance, browseRouterAdvertisementInterfaceSettingOptionInst);
|
|
||||||
dmasprintf(value, "%d", cnt);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_RouterAdvertisementInterfaceSettingOption_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
struct dm_data *radv_option_s = (struct dm_data *)data;
|
|
||||||
return radv_get_option_value(radv_option_s->config_section, "dns", radv_option_s->additional_data, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_RouterAdvertisementInterfaceSettingOption_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
struct dm_data *radv_option_s = (struct dm_data *)data;
|
|
||||||
bool b;
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_boolean(ctx, value))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
string_to_bool(value, &b);
|
|
||||||
return radv_set_option_value(radv_option_s->config_section, "dns", radv_option_s->additional_data, b);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_RouterAdvertisementInterfaceSettingOption_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
return bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, "radv_option_alias", instance, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_RouterAdvertisementInterfaceSettingOption_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, "radv_option_alias", instance, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_RouterAdvertisementInterfaceSettingOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
*value = "23";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_RouterAdvertisementInterfaceSettingOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"0","65535"}}, 1))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_RouterAdvertisementInterfaceSettingOption_Value(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
||||||
{
|
|
||||||
const char *option_value = ((struct dm_data *)data)->additional_data;
|
|
||||||
char hex[65535] = {0};
|
|
||||||
|
|
||||||
if (option_value && *option_value)
|
|
||||||
convert_string_to_hex(option_value, hex, sizeof(hex));
|
|
||||||
|
|
||||||
*value = (*hex) ? dmstrdup(hex) : "";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_RouterAdvertisementInterfaceSettingOption_Value(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
||||||
{
|
|
||||||
struct dm_data *radv_option_s = (struct dm_data *)data;
|
|
||||||
struct uci_list *dns_list = NULL;
|
|
||||||
char res[256] = {0};
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
case VALUECHECK:
|
|
||||||
if (bbfdm_validate_hexBinary(ctx, value, RANGE_ARGS{{"0","65535"}}, 1))
|
|
||||||
return FAULT_9007;
|
|
||||||
break;
|
|
||||||
case VALUESET:
|
|
||||||
convert_hex_to_string(value, res, sizeof(res));
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_list(radv_option_s->config_section, "dns", &dns_list);
|
|
||||||
if (value_exists_in_uci_list(dns_list, radv_option_s->additional_data)) {
|
|
||||||
dmuci_del_list_value_by_section(radv_option_s->config_section, "dns", radv_option_s->additional_data);
|
|
||||||
dmuci_add_list_value_by_section(radv_option_s->config_section, "dns", res);
|
|
||||||
}
|
|
||||||
|
|
||||||
dmuci_set_value_by_section_bbfdm(radv_option_s->dmmap_section, "option_value", res);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************************************************************************************
|
|
||||||
* OBJ & PARAM DEFINITION
|
|
||||||
***********************************************************************************************************************************/
|
|
||||||
/* *** Device.RouterAdvertisement. *** */
|
|
||||||
DMOBJ tRouterAdvertisementObj[] = {
|
|
||||||
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
|
|
||||||
{"InterfaceSetting", &DMWRITE, addObjRouterAdvertisementInterfaceSetting, delObjRouterAdvertisementInterfaceSetting, NULL, browseRouterAdvertisementInterfaceSettingInst, NULL, NULL, tRouterAdvertisementInterfaceSettingObj, tRouterAdvertisementInterfaceSettingParams, NULL, BBFDM_BOTH, NULL},
|
|
||||||
{0}
|
|
||||||
};
|
|
||||||
|
|
||||||
DMLEAF tRouterAdvertisementParams[] = {
|
|
||||||
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
|
|
||||||
{"Enable", &DMWRITE, DMT_BOOL, get_RouterAdvertisement_Enable, set_RouterAdvertisement_Enable, BBFDM_BOTH},
|
|
||||||
{"InterfaceSettingNumberOfEntries", &DMREAD, DMT_UNINT, get_RouterAdvertisement_InterfaceSettingNumberOfEntries, NULL, BBFDM_BOTH},
|
|
||||||
{0}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* *** Device.RouterAdvertisement.InterfaceSetting.{i}. *** */
|
|
||||||
DMOBJ tRouterAdvertisementInterfaceSettingObj[] = {
|
|
||||||
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
|
|
||||||
{"Option", &DMWRITE, addObjRouterAdvertisementInterfaceSettingOption, delObjRouterAdvertisementInterfaceSettingOption, NULL, browseRouterAdvertisementInterfaceSettingOptionInst, NULL, NULL, NULL, tRouterAdvertisementInterfaceSettingOptionParams, NULL, BBFDM_BOTH, NULL},
|
|
||||||
{0}
|
|
||||||
};
|
|
||||||
|
|
||||||
DMLEAF tRouterAdvertisementInterfaceSettingParams[] = {
|
|
||||||
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
|
|
||||||
{"Enable", &DMWRITE, DMT_BOOL, get_RouterAdvertisementInterfaceSetting_Enable, set_RouterAdvertisementInterfaceSetting_Enable, BBFDM_BOTH},
|
|
||||||
{"Status", &DMREAD, DMT_STRING, get_RouterAdvertisementInterfaceSetting_Status, NULL, BBFDM_BOTH},
|
|
||||||
{"Alias", &DMWRITE, DMT_STRING, get_RouterAdvertisementInterfaceSetting_Alias, set_RouterAdvertisementInterfaceSetting_Alias, BBFDM_BOTH, DM_FLAG_UNIQUE},
|
|
||||||
{"Interface", &DMWRITE, DMT_STRING, get_RouterAdvertisementInterfaceSetting_Interface, set_RouterAdvertisementInterfaceSetting_Interface, BBFDM_BOTH, DM_FLAG_UNIQUE|DM_FLAG_REFERENCE},
|
|
||||||
//{"ManualPrefixes", &DMWRITE, DMT_STRING, get_RouterAdvertisementInterfaceSetting_ManualPrefixes, set_RouterAdvertisementInterfaceSetting_ManualPrefixes, BBFDM_BOTH},
|
|
||||||
{"Prefixes", &DMREAD, DMT_STRING, get_RouterAdvertisementInterfaceSetting_Prefixes, NULL, BBFDM_BOTH},
|
|
||||||
{"MaxRtrAdvInterval", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_MaxRtrAdvInterval, set_RouterAdvertisementInterfaceSetting_MaxRtrAdvInterval, BBFDM_BOTH},
|
|
||||||
{"MinRtrAdvInterval", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_MinRtrAdvInterval, set_RouterAdvertisementInterfaceSetting_MinRtrAdvInterval, BBFDM_BOTH},
|
|
||||||
{"AdvDefaultLifetime", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_AdvDefaultLifetime, set_RouterAdvertisementInterfaceSetting_AdvDefaultLifetime, BBFDM_BOTH},
|
|
||||||
{"AdvManagedFlag", &DMWRITE, DMT_BOOL, get_RouterAdvertisementInterfaceSetting_AdvManagedFlag, set_RouterAdvertisementInterfaceSetting_AdvManagedFlag, BBFDM_BOTH},
|
|
||||||
{"AdvOtherConfigFlag", &DMWRITE, DMT_BOOL, get_RouterAdvertisementInterfaceSetting_AdvOtherConfigFlag, set_RouterAdvertisementInterfaceSetting_AdvOtherConfigFlag, BBFDM_BOTH},
|
|
||||||
{"AdvMobileAgentFlag", &DMWRITE, DMT_BOOL, get_RouterAdvertisementInterfaceSetting_AdvMobileAgentFlag, set_RouterAdvertisementInterfaceSetting_AdvMobileAgentFlag, BBFDM_BOTH},
|
|
||||||
{"AdvPreferredRouterFlag", &DMWRITE, DMT_STRING, get_RouterAdvertisementInterfaceSetting_AdvPreferredRouterFlag, set_RouterAdvertisementInterfaceSetting_AdvPreferredRouterFlag, BBFDM_BOTH},
|
|
||||||
//{"AdvNDProxyFlag", &DMWRITE, DMT_BOOL, get_RouterAdvertisementInterfaceSetting_AdvNDProxyFlag, set_RouterAdvertisementInterfaceSetting_AdvNDProxyFlag, BBFDM_BOTH},
|
|
||||||
{"AdvLinkMTU", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_AdvLinkMTU, set_RouterAdvertisementInterfaceSetting_AdvLinkMTU, BBFDM_BOTH},
|
|
||||||
{"AdvReachableTime", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_AdvReachableTime, set_RouterAdvertisementInterfaceSetting_AdvReachableTime, BBFDM_BOTH},
|
|
||||||
{"AdvRetransTimer", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_AdvRetransTimer, set_RouterAdvertisementInterfaceSetting_AdvRetransTimer, BBFDM_BOTH},
|
|
||||||
{"AdvCurHopLimit", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_AdvCurHopLimit, set_RouterAdvertisementInterfaceSetting_AdvCurHopLimit, BBFDM_BOTH},
|
|
||||||
{"OptionNumberOfEntries", &DMREAD, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_OptionNumberOfEntries, NULL, BBFDM_BOTH},
|
|
||||||
{0}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* *** Device.RouterAdvertisement.InterfaceSetting.{i}.Option.{i}. *** */
|
|
||||||
DMLEAF tRouterAdvertisementInterfaceSettingOptionParams[] = {
|
|
||||||
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
|
|
||||||
{"Enable", &DMWRITE, DMT_BOOL, get_RouterAdvertisementInterfaceSettingOption_Enable, set_RouterAdvertisementInterfaceSettingOption_Enable, BBFDM_BOTH},
|
|
||||||
{"Alias", &DMWRITE, DMT_STRING, get_RouterAdvertisementInterfaceSettingOption_Alias, set_RouterAdvertisementInterfaceSettingOption_Alias, BBFDM_BOTH, DM_FLAG_UNIQUE},
|
|
||||||
{"Tag", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSettingOption_Tag, set_RouterAdvertisementInterfaceSettingOption_Tag, BBFDM_BOTH, DM_FLAG_UNIQUE},
|
|
||||||
{"Value", &DMWRITE, DMT_HEXBIN, get_RouterAdvertisementInterfaceSettingOption_Value, set_RouterAdvertisementInterfaceSettingOption_Value, BBFDM_BOTH},
|
|
||||||
{0}
|
|
||||||
};
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2021 iopsys Software Solutions AB
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License version 2.1
|
|
||||||
* as published by the Free Software Foundation
|
|
||||||
*
|
|
||||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __ROUTERADVERTISEMENT_H
|
|
||||||
#define __ROUTERADVERTISEMENT_H
|
|
||||||
|
|
||||||
#include "libbbfdm-api/dmcommon.h"
|
|
||||||
|
|
||||||
extern DMOBJ tRouterAdvertisementObj[];
|
|
||||||
extern DMLEAF tRouterAdvertisementParams[];
|
|
||||||
extern DMOBJ tRouterAdvertisementInterfaceSettingObj[];
|
|
||||||
extern DMLEAF tRouterAdvertisementInterfaceSettingParams[];
|
|
||||||
extern DMLEAF tRouterAdvertisementInterfaceSettingOptionParams[];
|
|
||||||
|
|
||||||
#endif //__ROUTERADVERTISEMENT_H
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,28 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2019 iopsys Software Solutions AB
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License version 2.1
|
|
||||||
* as published by the Free Software Foundation
|
|
||||||
*
|
|
||||||
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
|
|
||||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __ROUTING_H
|
|
||||||
#define __ROUTING_H
|
|
||||||
|
|
||||||
#include "libbbfdm-api/dmcommon.h"
|
|
||||||
|
|
||||||
extern DMOBJ tRoutingObj[];
|
|
||||||
extern DMLEAF tRoutingParams[];
|
|
||||||
extern DMOBJ tRoutingRouterObj[];
|
|
||||||
extern DMLEAF tRoutingRouterParams[];
|
|
||||||
extern DMLEAF tRoutingRouterIPv4ForwardingParams[];
|
|
||||||
extern DMLEAF tRoutingRouterIPv6ForwardingParams[];
|
|
||||||
extern DMOBJ tRoutingRouteInformationObj[];
|
|
||||||
extern DMLEAF tRoutingRouteInformationParams[];
|
|
||||||
extern DMLEAF tRoutingRouteInformationInterfaceSettingParams[];
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -321,7 +321,29 @@
|
||||||
"bbf_plugin/x_iopsys_eu_mld.c"
|
"bbf_plugin/x_iopsys_eu_mld.c"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"repo": "https://dev.iopsys.eu/network/netmngr.git",
|
||||||
|
"proto": "git",
|
||||||
|
"version": "devel",
|
||||||
|
"dm_files": [
|
||||||
|
"src/interfacestack.c"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"repo": "https://dev.iopsys.eu/network/netmngr.git",
|
||||||
|
"proto": "git",
|
||||||
|
"version": "devel",
|
||||||
|
"dm_files": [
|
||||||
|
"src/net_plugin.c",
|
||||||
|
"src/gre.c",
|
||||||
|
"src/ip.c",
|
||||||
|
"src/ppp.c",
|
||||||
|
"src/routeradvertisement.c",
|
||||||
|
"src/routing.c",
|
||||||
|
"src/common.c"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
"repo": "https://dev.iopsys.eu/voice/tr104.git",
|
"repo": "https://dev.iopsys.eu/voice/tr104.git",
|
||||||
"proto": "git",
|
"proto": "git",
|
||||||
"version": "devel",
|
"version": "devel",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue