mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
1920 lines
75 KiB
C
1920 lines
75 KiB
C
/*
|
|
* 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>
|
|
*
|
|
*/
|
|
|
|
#include "ethernet.h"
|
|
|
|
struct eth_port_args
|
|
{
|
|
struct dmmap_dup *sections;
|
|
char *ifname;
|
|
};
|
|
|
|
struct eth_rmon_args
|
|
{
|
|
struct dmmap_dup *sections;
|
|
json_object *eth_rmon_obj;
|
|
};
|
|
|
|
/*************************************************************
|
|
* INIT
|
|
**************************************************************/
|
|
static inline int init_eth_port(struct eth_port_args *args, struct dmmap_dup *s, char *ifname)
|
|
{
|
|
args->sections = s;
|
|
args->ifname = ifname;
|
|
return 0;
|
|
}
|
|
|
|
static inline int init_eth_rmon(struct eth_rmon_args *args, struct dmmap_dup *s, json_object *obj)
|
|
{
|
|
args->sections = s;
|
|
args->eth_rmon_obj = obj;
|
|
return 0;
|
|
}
|
|
|
|
/*************************************************************
|
|
* COMMON FUNCTIONS
|
|
**************************************************************/
|
|
bool ethernet___check_vlan_termination_section(const char *name)
|
|
{
|
|
struct uci_section *s = NULL;
|
|
|
|
uci_foreach_option_eq("network", "device", "type", "bridge", s) {
|
|
struct uci_list *uci_list = NULL;
|
|
|
|
dmuci_get_value_by_section_list(s, "ports", &uci_list);
|
|
|
|
if (uci_list == NULL)
|
|
continue;
|
|
|
|
if (value_exists_in_uci_list(uci_list, name))
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
static int eth_iface_sysfs(const struct uci_section *data, const char *name, char **value)
|
|
{
|
|
char *device;
|
|
|
|
dmuci_get_value_by_section_string((struct uci_section *)data, "device", &device);
|
|
return get_net_device_sysfs(device, name, value);
|
|
}
|
|
|
|
static int eth_port_sysfs(const struct eth_port_args *args, const char *name, char **value)
|
|
{
|
|
return get_net_device_sysfs(args->ifname, name, value);
|
|
}
|
|
|
|
static struct uci_section *is_ethernet_link_exist(char *device)
|
|
{
|
|
struct uci_section *s = NULL;
|
|
char *dev = NULL;
|
|
|
|
uci_path_foreach_sections(bbfdm, "dmmap_ethernet", "link", s) {
|
|
dmuci_get_value_by_section_string(s, "device", &dev);
|
|
if (DM_STRCMP(dev, device) == 0)
|
|
return s;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
bool ethernet___name_exists_in_devices(char *name)
|
|
{
|
|
struct uci_section *s = NULL;
|
|
|
|
uci_foreach_option_eq("network", "device", "name", name, s) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
static void add_ethernet_link_section(char *device, char *macaddr)
|
|
{
|
|
struct uci_section *dmmap_s = NULL;
|
|
|
|
dmuci_add_section_bbfdm("dmmap_ethernet", "link", &dmmap_s);
|
|
|
|
dmuci_set_value_by_section(dmmap_s, "mac", macaddr);
|
|
dmuci_set_value_by_section(dmmap_s, "device", device);
|
|
dmuci_set_value_by_section(dmmap_s, "is_eth", (!DM_LSTRNCMP(device, "atm", 3) || !DM_LSTRNCMP(device, "ptm", 3)) ? "0" : "1");
|
|
}
|
|
|
|
static void dmmap_synchronizeEthernetLink(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
|
{
|
|
struct uci_section *s = NULL;
|
|
char *proto = NULL;
|
|
char *macaddr = NULL;
|
|
char *device = NULL;
|
|
char dev_name[32] = {0};
|
|
|
|
uci_foreach_sections("network", "interface", s) {
|
|
|
|
// Skip this interface section if its proto option is empty
|
|
dmuci_get_value_by_section_string(s, "proto", &proto);
|
|
if (DM_STRLEN(proto) == 0)
|
|
continue;
|
|
|
|
// Skip this interface section if its name is equal to loopback
|
|
if (strcmp(section_name(s), "loopback") == 0)
|
|
continue;
|
|
|
|
// Skip this interface section if its device starts with prfix 'link_'
|
|
dmuci_get_value_by_section_string(s, "device", &device);
|
|
if (DM_STRNCMP(device, "link_", 5) == 0 || DM_STRNCMP(device, "iface", 5) == 0)
|
|
continue;
|
|
|
|
// Skip this interface section if its device is empty
|
|
device = get_device(section_name(s));
|
|
if (DM_STRLEN(device) == 0)
|
|
continue;
|
|
|
|
get_net_device_sysfs(device, "address", &macaddr);
|
|
|
|
DM_STRNCPY(dev_name, device, sizeof(dev_name));
|
|
|
|
char *has_vid = DM_STRCHR(dev_name, '.');
|
|
if (has_vid)
|
|
*has_vid = '\0';
|
|
|
|
char *is_mac_vlan = DM_STRCHR(dev_name, '_');
|
|
if (is_mac_vlan)
|
|
*is_mac_vlan = '\0';
|
|
|
|
if (is_ethernet_link_exist(dev_name))
|
|
continue;
|
|
|
|
/* Add new ethernet link section */
|
|
add_ethernet_link_section(dev_name, macaddr);
|
|
}
|
|
}
|
|
|
|
/*************************************************************
|
|
* ENTRY METHOD
|
|
**************************************************************/
|
|
/*#Device.Ethernet.Interface.{i}.!UCI:ports/ethport/dmmap_ports*/
|
|
static int browseEthernetInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
|
{
|
|
char *inst = NULL, *ifname;
|
|
struct eth_port_args curr_eth_port_args = {0};
|
|
struct dmmap_dup *p = NULL;
|
|
LIST_HEAD(dup_list);
|
|
|
|
synchronize_specific_config_sections_with_dmmap("ports", "ethport", "dmmap_ports", &dup_list);
|
|
list_for_each_entry(p, &dup_list, list) {
|
|
|
|
dmuci_get_value_by_section_string(p->config_section, "ifname", &ifname);
|
|
|
|
init_eth_port(&curr_eth_port_args, p, ifname);
|
|
|
|
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "eth_port_instance", "eth_port_alias");
|
|
|
|
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_eth_port_args, inst) == DM_STOP)
|
|
break;
|
|
}
|
|
free_dmmap_config_dup_list(&dup_list);
|
|
return 0;
|
|
}
|
|
|
|
static int browseEthernetLinkInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
|
{
|
|
struct uci_section *s = NULL;
|
|
char *inst = NULL;
|
|
|
|
dmmap_synchronizeEthernetLink(dmctx, NULL, NULL, NULL);
|
|
uci_path_foreach_sections(bbfdm, "dmmap_ethernet", "link", s) {
|
|
|
|
inst = handle_instance(dmctx, parent_node, s, "link_instance", "link_alias");
|
|
|
|
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, inst) == DM_STOP)
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.VLANTermination.{i}.!UCI:network/device/dmmap_network*/
|
|
static int browseEthernetVLANTerminationInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
|
{
|
|
char *type, *name, *inst = NULL;
|
|
struct dmmap_dup *p = NULL;
|
|
LIST_HEAD(dup_list);
|
|
|
|
synchronize_specific_config_sections_with_dmmap("network", "device", "dmmap_network", &dup_list);
|
|
list_for_each_entry(p, &dup_list, list) {
|
|
|
|
dmuci_get_value_by_section_string(p->config_section, "type", &type);
|
|
dmuci_get_value_by_section_string(p->config_section, "name", &name);
|
|
if (DM_LSTRCMP(type, "bridge") == 0 ||
|
|
DM_LSTRCMP(type, "macvlan") == 0 ||
|
|
(*name != 0 && !ethernet___check_vlan_termination_section(name)) ||
|
|
(*name == 0 && strncmp(section_name(p->config_section), "br_", 3) == 0))
|
|
continue;
|
|
|
|
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "vlan_term_instance", "vlan_term_alias");
|
|
|
|
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, inst) == DM_STOP)
|
|
break;
|
|
}
|
|
free_dmmap_config_dup_list(&dup_list);
|
|
return 0;
|
|
}
|
|
|
|
static int browseEthernetRMONStatsInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
|
{
|
|
char *inst = NULL, *ifname;
|
|
struct eth_rmon_args curr_eth_rmon_args = {0};
|
|
struct dmmap_dup *p = NULL;
|
|
json_object *res = NULL;
|
|
LIST_HEAD(dup_list);
|
|
|
|
synchronize_specific_config_sections_with_dmmap("ports", "ethport", "dmmap_eth_rmon", &dup_list);
|
|
list_for_each_entry(p, &dup_list, list) {
|
|
|
|
dmuci_get_value_by_section_string(p->config_section, "ifname", &ifname);
|
|
|
|
dmubus_call("ethernet", "rmonstats", UBUS_ARGS{{"ifname", ifname, String}}, 1, &res);
|
|
if (!res) continue;
|
|
|
|
init_eth_rmon(&curr_eth_rmon_args, p, res);
|
|
|
|
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "eth_rmon_instance", "eth_rmon_alias");
|
|
|
|
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_eth_rmon_args, inst) == DM_STOP)
|
|
break;
|
|
}
|
|
free_dmmap_config_dup_list(&dup_list);
|
|
return 0;
|
|
}
|
|
|
|
/*************************************************************
|
|
* LINKER
|
|
**************************************************************/
|
|
static int get_linker_interface(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
|
|
{
|
|
*linker = data ? ((struct eth_port_args *)data)->ifname : "";
|
|
return 0;
|
|
}
|
|
|
|
static int get_linker_link(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
|
|
{
|
|
dmuci_get_value_by_section_string((struct uci_section *)data, "device", linker);
|
|
return 0;
|
|
}
|
|
|
|
static int get_linker_vlan_term(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
|
|
{
|
|
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "name", linker);
|
|
return 0;
|
|
}
|
|
|
|
/*************************************************************
|
|
* ADD & DEL OBJ
|
|
**************************************************************/
|
|
static int addObjEthernetLink(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
|
{
|
|
struct uci_section *dmmap_link = NULL;
|
|
char eth_linker[32];
|
|
|
|
snprintf(eth_linker, sizeof(eth_linker), "link_%s", *instance);
|
|
|
|
/* Add link section in dmmap_ethernet file */
|
|
dmuci_add_section_bbfdm("dmmap_ethernet", "link", &dmmap_link);
|
|
dmuci_set_value_by_section(dmmap_link, "is_eth", "1");
|
|
dmuci_set_value_by_section(dmmap_link, "link_instance", *instance);
|
|
return 0;
|
|
}
|
|
|
|
static void update_all_interfaces(char *old_device)
|
|
{
|
|
struct uci_section *s = NULL;
|
|
char buf[32] = {0};
|
|
|
|
if (DM_STRLEN(old_device) == 0)
|
|
return;
|
|
|
|
snprintf(buf, sizeof(buf), "link_%s", old_device);
|
|
replace_special_char(buf, '_');
|
|
|
|
uci_foreach_option_eq("network", "interface", "device", old_device, s) {
|
|
dmuci_set_value_by_section(s, "device", buf);
|
|
}
|
|
}
|
|
|
|
static int delObjEthernetLink(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
|
|
{
|
|
struct uci_section *s = NULL, *stmp = NULL;
|
|
char *device_iface = NULL;
|
|
char *device = NULL;
|
|
|
|
switch (del_action) {
|
|
case DEL_INST:
|
|
dmuci_get_value_by_section_string((struct uci_section *)data, "device", &device);
|
|
if (DM_STRLEN(device)) {
|
|
uci_foreach_option_cont("network", "interface", "device", device, s) {
|
|
dmuci_get_value_by_section_string(s, "device", &device_iface);
|
|
update_all_interfaces(device_iface);
|
|
}
|
|
}
|
|
|
|
// Remove link section
|
|
dmuci_delete_by_section((struct uci_section *)data, NULL, NULL);
|
|
return 0;
|
|
case DEL_ALL:
|
|
uci_path_foreach_sections_safe(bbfdm, "dmmap_ethernet", "link", stmp, s) {
|
|
dmuci_get_value_by_section_string(s, "device", &device);
|
|
if (DM_STRLEN(device)) {
|
|
uci_foreach_option_cont("network", "interface", "device", device, s) {
|
|
dmuci_get_value_by_section_string(s, "device", &device_iface);
|
|
update_all_interfaces(device_iface);
|
|
}
|
|
}
|
|
|
|
// Remove link section
|
|
dmuci_delete_by_section(s, NULL, NULL);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int addObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
|
{
|
|
struct uci_section *s = NULL, *dmmap_network = NULL;
|
|
char device_name[32];
|
|
|
|
snprintf(device_name, sizeof(device_name), "vlan_ter_%s", *instance);
|
|
|
|
// Add device section
|
|
dmuci_add_section("network", "device", &s);
|
|
dmuci_rename_section_by_section(s, device_name);
|
|
dmuci_set_value_by_section(s, "type", "8021q");
|
|
|
|
// Add device section in dmmap_network file
|
|
dmuci_add_section_bbfdm("dmmap_network", "device", &dmmap_network);
|
|
dmuci_set_value_by_section(dmmap_network, "section_name", device_name);
|
|
dmuci_set_value_by_section(dmmap_network, "vlan_term_instance", *instance);
|
|
return 0;
|
|
}
|
|
|
|
static int delObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
|
|
{
|
|
struct uci_section *s_dev = NULL, *sdevtmp = NULL;
|
|
char *name, *type;
|
|
|
|
switch (del_action) {
|
|
case DEL_INST:
|
|
// Remove device section
|
|
dmuci_delete_by_section(((struct dmmap_dup *)data)->config_section, NULL, NULL);
|
|
|
|
// Remove device section in dmmap_network file
|
|
dmuci_delete_by_section(((struct dmmap_dup *)data)->dmmap_section, NULL, NULL);
|
|
break;
|
|
case DEL_ALL:
|
|
uci_foreach_sections_safe("network", "device", sdevtmp, s_dev) {
|
|
struct uci_section *dmmap_section = NULL;
|
|
|
|
get_dmmap_section_of_config_section("dmmap_network", "device", section_name(s_dev), &dmmap_section);
|
|
|
|
dmuci_get_value_by_section_string(s_dev, "type", &type);
|
|
dmuci_get_value_by_section_string(s_dev, "name", &name);
|
|
if (DM_LSTRCMP(type, "bridge") == 0 ||
|
|
(*name != 0 && !ethernet___check_vlan_termination_section(name)) ||
|
|
(*name == 0 && strncmp(section_name(s_dev), "br_", 3) == 0))
|
|
continue;
|
|
|
|
// Remove device section in dmmap_network file
|
|
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
|
|
|
// Remove device section
|
|
dmuci_delete_by_section(s_dev, NULL, NULL);
|
|
}
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/*************************************************************
|
|
* GET & SET PARAM
|
|
**************************************************************/
|
|
static int get_Ethernet_FlowControlSupported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = "1";
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.InterfaceNumberOfEntries!UCI:ports/ethport/*/
|
|
static int get_Ethernet_InterfaceNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
int cnt = get_number_of_entries(ctx, data, instance, browseEthernetInterfaceInst);
|
|
dmasprintf(value, "%d", cnt);
|
|
return 0;
|
|
}
|
|
|
|
static int get_Ethernet_LinkNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
int cnt = get_number_of_entries(ctx, data, instance, browseEthernetLinkInst);
|
|
dmasprintf(value, "%d", cnt);
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.VLANTerminationNumberOfEntries!UCI:network/device/*/
|
|
static int get_Ethernet_VLANTerminationNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
int cnt = get_number_of_entries(ctx, data, instance, browseEthernetVLANTerminationInst);
|
|
dmasprintf(value, "%d", cnt);
|
|
return 0;
|
|
}
|
|
|
|
static int get_Ethernet_RMONStatsNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
int cnt = get_number_of_entries(ctx, data, instance, browseEthernetRMONStatsInst);
|
|
dmasprintf(value, "%d", cnt);
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.Enable!UCI:ports/ethport,@i-1/enabled*/
|
|
static int get_EthernetInterface_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmuci_get_value_by_section_fallback_def((((struct eth_port_args *)data)->sections)->config_section, "enabled", "1");
|
|
return 0;
|
|
}
|
|
|
|
static int set_EthernetInterface_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
{
|
|
bool b;
|
|
|
|
switch (action) {
|
|
case VALUECHECK:
|
|
if (dm_validate_boolean(value))
|
|
return FAULT_9007;
|
|
return 0;
|
|
case VALUESET:
|
|
string_to_bool(value, &b);
|
|
dmuci_set_value_by_section((((struct eth_port_args *)data)->sections)->config_section, "enabled", b ? "1" : "0");
|
|
return 0;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.Status!SYSFS:/sys/class/net/@Name/operstate*/
|
|
static int get_EthernetInterface_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return get_net_device_status(((struct eth_port_args *)data)->ifname, value);
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.Alias!UCI:dmmap_ports/ethport,@i-1/eth_port_alias*/
|
|
static int get_EthernetInterface_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
dmuci_get_value_by_section_string((((struct eth_port_args *)data)->sections)->dmmap_section, "eth_port_alias", value);
|
|
if ((*value)[0] == '\0') {
|
|
dmuci_get_value_by_section_string((((struct eth_port_args *)data)->sections)->config_section, "name", value);
|
|
dmuci_set_value_by_section((((struct eth_port_args *)data)->sections)->dmmap_section, "eth_port_alias", *value);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int set_EthernetInterface_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
{
|
|
switch (action) {
|
|
case VALUECHECK:
|
|
if (dm_validate_string(value, -1, 64, NULL, NULL))
|
|
return FAULT_9007;
|
|
return 0;
|
|
case VALUESET:
|
|
dmuci_set_value_by_section((((struct eth_port_args *)data)->sections)->dmmap_section, "eth_port_alias", value);
|
|
return 0;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.Name!UCI:ports/ethport,@i-1/ifname*/
|
|
static int get_EthernetInterface_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
dmuci_get_value_by_section_string((((struct eth_port_args *)data)->sections)->config_section, "ifname", value);
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.LastChange!UBUS:network.interface/status/interface,@Name/uptime*/
|
|
static int get_EthernetInterface_LastChange(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
json_object *res = NULL;
|
|
struct uci_section *s = NULL, *dev_s = NULL;
|
|
struct uci_list *uci_list = NULL;
|
|
char *device;
|
|
int intf_found = 0;
|
|
|
|
*value ="0";
|
|
uci_foreach_sections("network", "interface", s) {
|
|
dmuci_get_value_by_section_string(s, "device", &device);
|
|
if (0 == DM_LSTRNCMP(device, "br-", 3)) {
|
|
uci_foreach_option_eq("network", "device", "name", device, dev_s) {
|
|
dmuci_get_value_by_section_list(dev_s, "ports", &uci_list);
|
|
if (value_exists_in_uci_list(uci_list, ((struct eth_port_args *)data)->ifname)) {
|
|
intf_found = 1;
|
|
}
|
|
}
|
|
} else {
|
|
if (DM_STRSTR(device, ((struct eth_port_args *)data)->ifname)) {
|
|
intf_found = 1;
|
|
}
|
|
}
|
|
|
|
if (1 == intf_found) {
|
|
char *if_name = section_name(s);
|
|
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");
|
|
if((*value)[0] == '\0')
|
|
*value = "0";
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
if((*value)[0] == '\0')
|
|
*value = "0";
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int get_EthernetInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = "";
|
|
return 0;
|
|
}
|
|
|
|
static int set_EthernetInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
{
|
|
switch (action) {
|
|
case VALUECHECK:
|
|
if (dm_validate_string_list(value, -1, -1, 1024, -1, -1, NULL, NULL))
|
|
return FAULT_9007;
|
|
|
|
if (*value != '\0')
|
|
return FAULT_9007;
|
|
|
|
break;
|
|
case VALUESET:
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.Upstream!UCI:ports/ethport,@i-1/uplink*/
|
|
static int get_EthernetInterface_Upstream(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmuci_get_value_by_section_fallback_def((((struct eth_port_args *)data)->sections)->config_section, "uplink", "0");
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.MACAddress!SYSFS:/sys/class/net/@Name/address*/
|
|
static int get_EthernetInterface_MACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_port_sysfs(data, "address", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.MaxBitRate!UCI:ports/ethport,@i-1/speed*/
|
|
static int get_EthernetInterface_MaxBitRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
char *autoneg = NULL;
|
|
|
|
dmuci_get_value_by_section_string((((struct eth_port_args *)data)->sections)->config_section, "autoneg", &autoneg);
|
|
|
|
if (autoneg && DM_LSTRCMP(autoneg, "0") == 0)
|
|
dmuci_get_value_by_section_string((((struct eth_port_args *)data)->sections)->config_section, "speed", value);
|
|
else
|
|
*value = "-1";
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int set_EthernetInterface_MaxBitRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
{
|
|
switch (action) {
|
|
case VALUECHECK:
|
|
if (dm_validate_int(value, RANGE_ARGS{{"-1",NULL}}, 1))
|
|
return FAULT_9007;
|
|
return 0;
|
|
case VALUESET:
|
|
if (DM_LSTRCMP(value, "-1") == 0)
|
|
dmuci_set_value_by_section((((struct eth_port_args *)data)->sections)->config_section, "autoneg", "1");
|
|
else {
|
|
dmuci_set_value_by_section((((struct eth_port_args *)data)->sections)->config_section, "autoneg", "0");
|
|
dmuci_set_value_by_section((((struct eth_port_args *)data)->sections)->config_section, "speed", value);
|
|
}
|
|
return 0;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.CurrentBitRate!UBUS:network.device/status/name,@Name/speed*/
|
|
static int get_EthernetInterface_CurrentBitRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
json_object *res = NULL;
|
|
int speed = 0;
|
|
|
|
dmubus_call("network.device", "status", UBUS_ARGS{{"name", ((struct eth_port_args *)data)->ifname, String}}, 1, &res);
|
|
DM_ASSERT(res, *value = "0");
|
|
*value = dmjson_get_value(res, 1, "speed");
|
|
sscanf(*value, "%d%*c", &speed);
|
|
dmasprintf(value, "%d", speed);
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.DuplexMode!UCI:ports/ethport,@i-1/duplex*/
|
|
static int get_EthernetInterface_DuplexMode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
char *autoneg = NULL;
|
|
|
|
dmuci_get_value_by_section_string((((struct eth_port_args *)data)->sections)->config_section, "autoneg", &autoneg);
|
|
|
|
if (autoneg && DM_LSTRCMP(autoneg, "0") == 0) {
|
|
char *duplex = NULL;
|
|
|
|
dmuci_get_value_by_section_string((((struct eth_port_args *)data)->sections)->config_section, "duplex", &duplex);
|
|
*value = (duplex && DM_LSTRCMP(duplex, "full") == 0) ? "Full" : "Half";
|
|
} else {
|
|
*value = "Auto";
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int set_EthernetInterface_DuplexMode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
{
|
|
switch (action) {
|
|
case VALUECHECK:
|
|
if (dm_validate_string(value, -1, -1, DuplexMode, NULL))
|
|
return FAULT_9007;
|
|
return 0;
|
|
case VALUESET:
|
|
if (DM_LSTRCMP(value, "Auto") == 0)
|
|
dmuci_set_value_by_section((((struct eth_port_args *)data)->sections)->config_section, "autoneg", "1");
|
|
else {
|
|
dmuci_set_value_by_section((((struct eth_port_args *)data)->sections)->config_section, "autoneg", "0");
|
|
dmuci_set_value_by_section((((struct eth_port_args *)data)->sections)->config_section, "duplex", (*value == 'F') ? "full" : "half");
|
|
}
|
|
return 0;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int get_EthernetInterface_EEECapability(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = "1";
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.EEEEnable!UCI:ports/ethport,@i-1/eee*/
|
|
static int get_EthernetInterface_EEEEnable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmuci_get_value_by_section_fallback_def((((struct eth_port_args *)data)->sections)->config_section, "eee", "1");
|
|
return 0;
|
|
}
|
|
|
|
static int set_EthernetInterface_EEEEnable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
{
|
|
bool b;
|
|
|
|
switch (action) {
|
|
case VALUECHECK:
|
|
if (dm_validate_boolean(value))
|
|
return FAULT_9007;
|
|
break;
|
|
case VALUESET:
|
|
string_to_bool(value, &b);
|
|
dmuci_set_value_by_section((((struct eth_port_args *)data)->sections)->config_section, "eee", b ? "1" : "0");
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.Stats.BytesSent!SYSFS:/sys/class/net/@Name/statistics/tx_bytes*/
|
|
static int get_EthernetInterfaceStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_port_sysfs(data, "statistics/tx_bytes", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.Stats.BytesReceived!SYSFS:/sys/class/net/@Name/statistics/rx_bytes*/
|
|
static int get_EthernetInterfaceStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_port_sysfs(data, "statistics/rx_bytes", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.Stats.PacketsSent!SYSFS:/sys/class/net/@Name/statistics/tx_packets*/
|
|
static int get_EthernetInterfaceStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_port_sysfs(data, "statistics/tx_packets", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.Stats.PacketsReceived!SYSFS:/sys/class/net/@Name/statistics/rx_packets*/
|
|
static int get_EthernetInterfaceStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_port_sysfs(data, "statistics/rx_packets", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.Stats.ErrorsSent!SYSFS:/sys/class/net/@Name/statistics/tx_errors*/
|
|
static int get_EthernetInterfaceStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_port_sysfs(data, "statistics/tx_errors", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.Stats.ErrorsReceived!SYSFS:/sys/class/net/@Name/statistics/rx_errors*/
|
|
static int get_EthernetInterfaceStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_port_sysfs(data, "statistics/rx_errors", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.Stats.DiscardPacketsSent!SYSFS:/sys/class/net/@Name/statistics/tx_dropped*/
|
|
static int get_EthernetInterfaceStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_port_sysfs(data, "statistics/tx_dropped", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.Stats.DiscardPacketsReceived!SYSFS:/sys/class/net/@Name/statistics/rx_dropped*/
|
|
static int get_EthernetInterfaceStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_port_sysfs(data, "statistics/rx_dropped", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.Stats.MulticastPacketsReceived!SYSFS:/sys/class/net/@Name/statistics/multicast*/
|
|
static int get_EthernetInterfaceStats_MulticastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_port_sysfs(data, "statistics/multicast", value);
|
|
}
|
|
|
|
static int eth_port_ubus(const struct eth_port_args *args, const char *name, char **value)
|
|
{
|
|
json_object *res = NULL;
|
|
|
|
if (args == NULL)
|
|
DM_ASSERT(res, *value = "0");
|
|
|
|
char *if_name = args->ifname;
|
|
dmubus_call("ethernet", "ifstats", UBUS_ARGS{{"ifname", if_name, String}}, 1, &res);
|
|
DM_ASSERT(res, *value = "0");
|
|
*value = dmjson_get_value(res, 1, name);
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.Stats.MulticastPacketsSent!UBUS:ethernet/ifstats/ifname,ifname/tx_multicast_packets*/
|
|
static int get_EthernetInterfaceStats_MulticastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_port_ubus(data, "tx_multicast_packets", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.Stats.UnicastPacketsSent!UBUS:ethernet/ifstats/ifname,ifname/tx_unicast_packets*/
|
|
static int get_EthernetInterfaceStats_UnicastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_port_ubus(data, "tx_unicast_packets", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.Stats.UnicastPacketsReceived!UBUS:ethernet/ifstats/ifname,ifname/rx_unicast_packets*/
|
|
static int get_EthernetInterfaceStats_UnicastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_port_ubus(data, "rx_unicast_packets", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.Stats.BroadcastPacketsSent!UBUS:ethernet/ifstats/ifname,ifname/tx_broadcast_packets*/
|
|
static int get_EthernetInterfaceStats_BroadcastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_port_ubus(data, "tx_broadcast_packets", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.Stats.BroadcastPacketsReceived!UBUS:ethernet/ifstats/ifname,ifname/rx_broadcast_packets*/
|
|
static int get_EthernetInterfaceStats_BroadcastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_port_ubus(data, "rx_broadcast_packets", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.Interface.{i}.Stats.UnknownProtoPacketsReceived!UBUS:ethernet/ifstats/ifname,ifname/rx_unknown_packets*/
|
|
static int get_EthernetInterfaceStats_UnknownProtoPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_port_ubus(data, "rx_unknown_packets", value);
|
|
}
|
|
|
|
static int get_EthernetLink_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = "1";
|
|
return 0;
|
|
}
|
|
|
|
static int set_EthernetLink_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
{
|
|
bool b;
|
|
|
|
switch (action) {
|
|
case VALUECHECK:
|
|
if (dm_validate_boolean(value))
|
|
return FAULT_9007;
|
|
break;
|
|
case VALUESET:
|
|
string_to_bool(value, &b);
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int get_EthernetLink_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
char *device = NULL;
|
|
|
|
dmuci_get_value_by_section_string((struct uci_section *)data, "device", &device);
|
|
return get_net_device_status(device, value);
|
|
}
|
|
|
|
static int get_EthernetLink_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
dmuci_get_value_by_section_string((struct uci_section *)data, "link_alias", value);
|
|
if ((*value)[0] == '\0')
|
|
dmasprintf(value, "cpe-%s", instance);
|
|
return 0;
|
|
}
|
|
|
|
static int set_EthernetLink_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
{
|
|
switch (action) {
|
|
case VALUECHECK:
|
|
if (dm_validate_string(value, -1, 64, NULL, NULL))
|
|
return FAULT_9007;
|
|
break;
|
|
case VALUESET:
|
|
dmuci_set_value_by_section((struct uci_section *)data, "link_alias", value);
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int get_EthernetLink_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
dmuci_get_value_by_section_string((struct uci_section *)data, "device", value);
|
|
return 0;
|
|
}
|
|
|
|
static int get_EthernetLink_LastChange(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
struct uci_section *s = NULL;
|
|
char *device = NULL;
|
|
|
|
dmuci_get_value_by_section_string((struct uci_section *)data, "device", &device);
|
|
if (DM_STRLEN(device) == 0)
|
|
return 0;
|
|
|
|
uci_foreach_option_cont("network", "interface", "device", device, s) {
|
|
json_object *res = NULL;
|
|
|
|
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(s), String}}, 1, &res);
|
|
DM_ASSERT(res, *value = "0");
|
|
*value = dmjson_get_value(res, 1, "uptime");
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int get_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
char *linker = NULL;
|
|
|
|
dmuci_get_value_by_section_string((struct uci_section *)data, "LowerLayers", value);
|
|
|
|
if ((*value)[0] == '\0') {
|
|
dmuci_get_value_by_section_string((struct uci_section *)data, "device", &linker);
|
|
if (!linker || *linker == '\0')
|
|
return 0;
|
|
|
|
adm_entry_get_linker_param(ctx, "Device.ATM.Link.", linker, value);
|
|
if (*value != NULL && (*value)[0] != 0)
|
|
return 0;
|
|
|
|
adm_entry_get_linker_param(ctx, "Device.PTM.Link.", linker, value);
|
|
if (*value != NULL && (*value)[0] != 0)
|
|
return 0;
|
|
|
|
adm_entry_get_linker_param(ctx, "Device.Bridging.Bridge.", linker, value);
|
|
if (*value != NULL && (*value)[0] != 0)
|
|
return 0;
|
|
|
|
adm_entry_get_linker_param(ctx, "Device.Ethernet.Interface.", linker, value);
|
|
} else {
|
|
adm_entry_get_linker_value(ctx, *value, &linker);
|
|
if (!linker || *linker == 0)
|
|
*value = "";
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int set_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
{
|
|
char *allowed_objects[] = {
|
|
"Device.Ethernet.Interface.",
|
|
"Device.Bridging.Bridge.*.Port.",
|
|
"Device.ATM.Link.",
|
|
"Device.PTM.Link.",
|
|
NULL};
|
|
char *linker = NULL;
|
|
|
|
switch (action) {
|
|
case VALUECHECK:
|
|
if (dm_validate_string_list(value, -1, -1, 1024, -1, -1, NULL, NULL))
|
|
return FAULT_9007;
|
|
|
|
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
|
|
return FAULT_9007;
|
|
|
|
break;
|
|
case VALUESET:
|
|
adm_entry_get_linker_value(ctx, value, &linker);
|
|
|
|
// Store LowerLayers value under dmmap section
|
|
dmuci_set_value_by_section((struct uci_section *)data, "LowerLayers", value);
|
|
|
|
dmuci_set_value_by_section((struct uci_section *)data, "is_eth", !DM_STRNCMP(value, "Device.Ethernet.", strlen("Device.Ethernet.")) ? "1" : "0");
|
|
|
|
if (match(value, "Device.Bridging.Bridge.*.Port.")) {
|
|
dmuci_set_value_by_section((struct uci_section *)data, "is_eth", "1");
|
|
|
|
// 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);
|
|
}
|
|
|
|
dmuci_set_value_by_section((struct uci_section *)data, "device", DM_STRLEN(linker) ? linker : "");
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int get_EthernetLink_MACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
dmuci_get_value_by_section_string((struct uci_section *)data, "mac", value);
|
|
return 0;
|
|
}
|
|
|
|
static int get_EthernetLink_FlowControl(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
struct uci_section *port_s = NULL;
|
|
char *device = NULL, *is_eth = NULL;
|
|
|
|
dmuci_get_value_by_section_string((struct uci_section *)data, "is_eth", &is_eth);
|
|
if (!is_eth || *is_eth == '0')
|
|
goto end;
|
|
|
|
dmuci_get_value_by_section_string((struct uci_section *)data, "device", &device);
|
|
if (!DM_STRLEN(device))
|
|
goto end;
|
|
|
|
char *is_bridge = DM_LSTRSTR(device, "br-");
|
|
if (is_bridge) {
|
|
/* Ethernet.Link.{i}. ---> Bridging.Bridge.{i}.Port.{i}. */
|
|
struct uci_list *ports_list = NULL;
|
|
|
|
struct uci_section *dev_s = get_dup_section_in_config_opt("network", "device", "name", device);
|
|
if (!dev_s)
|
|
goto end;
|
|
|
|
dmuci_get_value_by_section_list(dev_s, "ports", &ports_list);
|
|
if (ports_list != NULL) {
|
|
struct uci_element *e = NULL;
|
|
char *default_value = "0";
|
|
|
|
uci_foreach_element(ports_list, e) {
|
|
char buf[16] = {0};
|
|
|
|
DM_STRNCPY(buf, e->name, sizeof(buf));
|
|
|
|
char *is_tagged = DM_STRCHR(buf, '.');
|
|
if (is_tagged)
|
|
*is_tagged = 0;
|
|
|
|
port_s = get_dup_section_in_config_opt("ports", "ethport", "ifname", buf);
|
|
char *pause = port_s ? dmuci_get_value_by_section_fallback_def(port_s, "pause", "0") : "0";
|
|
char *curr_value = dmuci_string_to_boolean(pause) ? "1" : "0";
|
|
|
|
if (DM_STRCMP(curr_value, default_value) != 0) {
|
|
*value = "1";
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
*value = default_value;
|
|
return 0;
|
|
}
|
|
} else {
|
|
/* Ethernet.Link.{i}. ---> Ethernet.Interface.{i}. */
|
|
|
|
port_s = get_dup_section_in_config_opt("ports", "ethport", "ifname", device);
|
|
char *pause = port_s ? dmuci_get_value_by_section_fallback_def(port_s, "pause", "0") : "0";
|
|
*value = dmuci_string_to_boolean(pause) ? "1" : "0";
|
|
return 0;
|
|
}
|
|
|
|
end:
|
|
*value = "0";
|
|
return 0;
|
|
}
|
|
|
|
static int set_EthernetLink_FlowControl(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
{
|
|
struct uci_section *port_s = NULL;
|
|
char *device = NULL, *is_eth = NULL;
|
|
bool b;
|
|
|
|
switch (action) {
|
|
case VALUECHECK:
|
|
if (dm_validate_boolean(value))
|
|
return FAULT_9007;
|
|
break;
|
|
case VALUESET:
|
|
string_to_bool(value, &b);
|
|
|
|
dmuci_get_value_by_section_string((struct uci_section *)data, "is_eth", &is_eth);
|
|
if (!is_eth || *is_eth == '0')
|
|
break;
|
|
|
|
dmuci_get_value_by_section_string((struct uci_section *)data, "device", &device);
|
|
if (!DM_STRLEN(device))
|
|
break;
|
|
|
|
char *is_bridge = DM_LSTRSTR(device, "br-");
|
|
if (is_bridge) {
|
|
/* Ethernet.Link.{i}. ---> Bridging.Bridge.{i}.Port.{i}. */
|
|
|
|
struct uci_section *dev_s = get_dup_section_in_config_opt("network", "device", "name", device);
|
|
if (dev_s) {
|
|
struct uci_list *ports_list = NULL;
|
|
|
|
dmuci_get_value_by_section_list(dev_s, "ports", &ports_list);
|
|
if (ports_list != NULL) {
|
|
struct uci_element *e = NULL;
|
|
|
|
uci_foreach_element(ports_list, e) {
|
|
char buf[16] = {0};
|
|
|
|
DM_STRNCPY(buf, e->name, sizeof(buf));
|
|
|
|
char *is_tagged = DM_STRCHR(buf, '.');
|
|
if (is_tagged)
|
|
*is_tagged = 0;
|
|
|
|
port_s = get_dup_section_in_config_opt("ports", "ethport", "ifname", buf);
|
|
if (port_s)
|
|
dmuci_set_value_by_section(port_s, "pause", b ? "1" : "0");
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
/* Ethernet.Link.{i}. ---> Ethernet.Interface.{i}. */
|
|
|
|
port_s = get_dup_section_in_config_opt("ports", "ethport", "ifname", device);
|
|
if (port_s)
|
|
dmuci_set_value_by_section(port_s, "pause", b ? "1" : "0");
|
|
}
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int get_EthernetLinkStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_sysfs(data, "statistics/tx_bytes", value);
|
|
}
|
|
|
|
static int get_EthernetLinkStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_sysfs(data, "statistics/rx_bytes", value);
|
|
}
|
|
|
|
static int get_EthernetLinkStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_sysfs(data, "statistics/tx_packets", value);
|
|
}
|
|
|
|
static int get_EthernetLinkStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_sysfs(data, "statistics/rx_packets", value);
|
|
}
|
|
|
|
static int get_EthernetLinkStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_sysfs(data, "statistics/tx_errors", value);
|
|
}
|
|
|
|
static int get_EthernetLinkStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_sysfs(data, "statistics/rx_errors", value);
|
|
}
|
|
|
|
static int get_EthernetLinkStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_sysfs(data, "statistics/tx_dropped", value);
|
|
}
|
|
|
|
static int get_EthernetLinkStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_sysfs(data, "statistics/rx_dropped", value);
|
|
}
|
|
|
|
static int get_EthernetLinkStats_MulticastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_sysfs(data, "statistics/multicast", value);
|
|
}
|
|
|
|
static int eth_iface_ubus(struct uci_section *iface_s, const char *name, char **value)
|
|
{
|
|
json_object *res = NULL;
|
|
char *device = NULL;
|
|
|
|
dmuci_get_value_by_section_string(iface_s, "device", &device);
|
|
|
|
dmubus_call("ethernet", "ifstats", UBUS_ARGS{{"ifname", device, String}}, 1, &res);
|
|
DM_ASSERT(res, *value = "0");
|
|
*value = dmjson_get_value(res, 1, name);
|
|
return 0;
|
|
}
|
|
|
|
static int get_EthernetLinkStats_MulticastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_ubus(data, "tx_multicast_packets", value);
|
|
}
|
|
|
|
static int get_EthernetLinkStats_UnicastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_ubus(data, "tx_unicast_packets", value);
|
|
}
|
|
|
|
static int get_EthernetLinkStats_UnicastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_ubus(data, "rx_unicast_packets", value);
|
|
}
|
|
|
|
static int get_EthernetLinkStats_BroadcastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_ubus(data, "tx_broadcast_packets", value);
|
|
}
|
|
|
|
static int get_EthernetLinkStats_BroadcastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_ubus(data, "rx_broadcast_packets", value);
|
|
}
|
|
|
|
static int get_EthernetLinkStats_UnknownProtoPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_ubus(data, "rx_unknown_packets", value);
|
|
}
|
|
|
|
static int get_EthernetVLANTermination_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "enabled", "1");
|
|
return 0;
|
|
}
|
|
|
|
static int set_EthernetVLANTermination_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
{
|
|
bool b;
|
|
|
|
switch (action) {
|
|
case VALUECHECK:
|
|
if (dm_validate_boolean(value))
|
|
return FAULT_9007;
|
|
break;
|
|
case VALUESET:
|
|
string_to_bool(value, &b);
|
|
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "enabled", b ? "1" : "0");
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int get_EthernetVLANTermination_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
char *name = NULL;
|
|
|
|
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "name", &name);
|
|
return get_net_device_status(name, value);
|
|
}
|
|
|
|
/*#Device.Ethernet.VLANTermination.{i}.Alias!UCI:dmmap_network/device,@i-1/vlan_term_alias*/
|
|
static int get_EthernetVLANTermination_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, "vlan_term_alias", value);
|
|
if ((*value)[0] == '\0')
|
|
dmasprintf(value, "cpe-%s", instance);
|
|
return 0;
|
|
}
|
|
|
|
static int set_EthernetVLANTermination_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
{
|
|
switch (action) {
|
|
case VALUECHECK:
|
|
if (dm_validate_string(value, -1, 64, NULL, NULL))
|
|
return FAULT_9007;
|
|
return 0;
|
|
case VALUESET:
|
|
dmuci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "vlan_term_alias", value);
|
|
return 0;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int get_EthernetVLANTermination_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmstrdup(section_name(((struct dmmap_dup *)data)->config_section));
|
|
return 0;
|
|
}
|
|
|
|
static int get_EthernetVLANTermination_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, "LowerLayers", value);
|
|
|
|
if (DM_STRLEN(*value) == 0) {
|
|
char *type = NULL, *ifname = NULL;
|
|
|
|
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "type", &type);
|
|
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "ifname", &ifname);
|
|
|
|
if (DM_LSTRCMP(type, "8021ad") == 0) {
|
|
adm_entry_get_linker_param(ctx, "Device.Ethernet.VLANTermination.", ifname, value);
|
|
} else {
|
|
adm_entry_get_linker_param(ctx, "Device.Ethernet.Link.", ifname, value);
|
|
}
|
|
} else {
|
|
char *linker = NULL;
|
|
|
|
adm_entry_get_linker_value(ctx, *value, &linker);
|
|
if (!linker || *linker == 0)
|
|
*value = "";
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int set_EthernetVLANTermination_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
{
|
|
char *allowed_objects[] = {
|
|
"Device.Ethernet.VLANTermination.",
|
|
"Device.Ethernet.Link.",
|
|
NULL};
|
|
char *vlan_linker = NULL;
|
|
|
|
switch (action) {
|
|
case VALUECHECK:
|
|
if (dm_validate_string_list(value, -1, -1, 1024, -1, -1, NULL, NULL))
|
|
return FAULT_9007;
|
|
|
|
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
|
|
return FAULT_9007;
|
|
|
|
break;
|
|
case VALUESET:
|
|
adm_entry_get_linker_value(ctx, value, &vlan_linker);
|
|
|
|
// Store LowerLayers value under dmmap section
|
|
dmuci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "LowerLayers", value);
|
|
|
|
if (DM_STRLEN(vlan_linker) == 0) {
|
|
// Set ifname and name options of device section to empty value
|
|
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ifname", "");
|
|
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "name", "");
|
|
}
|
|
|
|
if (DM_STRNCMP(value, "Device.Ethernet.Link.", DM_STRLEN("Device.Ethernet.Link.")) == 0) {
|
|
char new_name[16] = {0};
|
|
char *old_name = NULL;
|
|
char *vid = NULL;
|
|
|
|
// Get name and vid options from the current device section
|
|
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "name", &old_name);
|
|
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "vid", &vid);
|
|
|
|
snprintf(new_name, sizeof(new_name), "%s%s%s", vlan_linker, DM_STRLEN(vid) ? "." : "", DM_STRLEN(vid) ? vid : "");
|
|
|
|
if (ethernet___name_exists_in_devices(new_name))
|
|
return -1;
|
|
|
|
if (DM_STRLEN(old_name)) {
|
|
{ // Check if there is a X_IOPSYS_EU_MACVLAN linked to this VLANTermination
|
|
struct uci_section *macvlan_s = NULL;
|
|
char *ifname = NULL;
|
|
|
|
uci_foreach_option_eq("network", "device", "type", "macvlan", macvlan_s) {
|
|
dmuci_set_value_by_section(macvlan_s, "ifname", ifname);
|
|
if (DM_STRLEN(ifname) == 0 || DM_STRCMP(ifname, old_name) != 0)
|
|
continue;
|
|
|
|
dmuci_set_value_by_section(macvlan_s, "ifname", new_name);
|
|
dmuci_set_value_by_section(macvlan_s, "name", new_name);
|
|
}
|
|
}
|
|
|
|
{ // Check if there is a PPP.Interface linked to this VLANTermination
|
|
struct uci_section *ppp_s = get_dup_section_in_dmmap_opt("dmmap_ppp", "interface", "device", old_name);
|
|
if (ppp_s) {
|
|
char *iface_name = NULL;
|
|
|
|
dmuci_get_value_by_section_string(ppp_s, "iface_name", &iface_name);
|
|
if (DM_STRLEN(iface_name)) {
|
|
struct uci_section *s = get_origin_section_from_config("network", "interface", iface_name);
|
|
dmuci_set_value_by_section(s, "device", new_name);
|
|
}
|
|
|
|
dmuci_set_value_by_section(ppp_s, "device", new_name);
|
|
}
|
|
}
|
|
|
|
{ // Check if there is an IP.Interface linked to this VLANTermination
|
|
struct uci_section *iface_s = get_dup_section_in_config_opt("network", "interface", "device", old_name);
|
|
dmuci_set_value_by_section(iface_s, "device", new_name);
|
|
}
|
|
}
|
|
|
|
// Set ifname and name options of device section
|
|
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ifname", vlan_linker);
|
|
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "name", new_name);
|
|
}
|
|
|
|
if (DM_STRNCMP(value, "Device.Ethernet.VLANTermination.", DM_STRLEN("Device.Ethernet.VLANTermination.")) == 0) {
|
|
char new_name[32] = {0};
|
|
char *vid = NULL;
|
|
|
|
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "vid", &vid);
|
|
|
|
snprintf(new_name, sizeof(new_name), "%s%s%s", vlan_linker, DM_STRLEN(vid) ? "." : "", DM_STRLEN(vid) ? vid : "");
|
|
|
|
if (ethernet___name_exists_in_devices(new_name))
|
|
return -1;
|
|
|
|
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ifname", vlan_linker);
|
|
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "name", new_name);
|
|
}
|
|
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.VLANTermination.{i}.VLANID!UCI:network/device,@i-1/vid*/
|
|
static int get_EthernetVLANTermination_VLANID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "vid", "1");
|
|
return 0;
|
|
}
|
|
|
|
static int set_EthernetVLANTermination_VLANID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
{
|
|
char *ifname = NULL;
|
|
char *vid = NULL;
|
|
|
|
switch (action) {
|
|
case VALUECHECK:
|
|
if (dm_validate_unsignedInt(value, RANGE_ARGS{{"1","4094"}}, 1))
|
|
return FAULT_9007;
|
|
return 0;
|
|
case VALUESET:
|
|
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "ifname", &ifname);
|
|
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "vid", &vid);
|
|
|
|
if (DM_STRLEN(ifname) != 0 && DM_STRLEN(vid) != 0) {
|
|
struct uci_section *uci_s = NULL;
|
|
char old_name[32] = {0};
|
|
char new_name[32] = {0};
|
|
char *name = NULL;
|
|
|
|
snprintf(old_name, sizeof(old_name), "%s.%s", ifname, vid);
|
|
snprintf(new_name, sizeof(new_name), "%s.%s", ifname, value);
|
|
|
|
if (ethernet___name_exists_in_devices(new_name))
|
|
return 0;
|
|
|
|
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "name", &name);
|
|
|
|
uci_foreach_option_eq("network", "device", "type", "8021ad", uci_s) {
|
|
char *curr_ifname = NULL;
|
|
|
|
dmuci_get_value_by_section_string(uci_s, "ifname", &curr_ifname);
|
|
|
|
if (DM_STRCMP(curr_ifname, name) == 0) {
|
|
char __new_name[32] = {0};
|
|
char *curr_name = NULL;
|
|
char *curr_vid = NULL;
|
|
|
|
dmuci_get_value_by_section_string(uci_s, "name", &curr_name);
|
|
dmuci_get_value_by_section_string(uci_s, "vid", &curr_vid);
|
|
|
|
snprintf(__new_name, sizeof(__new_name), "%s.%s.%s", ifname, value, curr_vid);
|
|
|
|
dmuci_set_value_by_section(uci_s, "ifname", new_name);
|
|
dmuci_set_value_by_section(uci_s, "name", __new_name);
|
|
|
|
struct uci_section *iface_s = get_dup_section_in_config_opt("network", "interface", "device", curr_name);
|
|
dmuci_set_value_by_section(iface_s, "device", __new_name);
|
|
}
|
|
}
|
|
|
|
// set device option of the corresponding interface section
|
|
uci_s = get_dup_section_in_config_opt("network", "interface", "device", old_name);
|
|
dmuci_set_value_by_section(uci_s, "device", new_name);
|
|
|
|
|
|
// set name option of the device section
|
|
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "name", new_name);
|
|
}
|
|
|
|
// set vid option of the device section
|
|
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "vid", value);
|
|
return 0;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.VLANTermination.{i}.TPID!UCI:network/device,@i-1/type*/
|
|
static int get_EthernetVLANTermination_TPID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "type", value);
|
|
if (DM_LSTRCMP(*value, "8021q") == 0)
|
|
*value = "33024";
|
|
else if (DM_LSTRCMP(*value, "8021ad") == 0)
|
|
*value = "34984";
|
|
else
|
|
*value = "37120";
|
|
return 0;
|
|
}
|
|
|
|
static int set_EthernetVLANTermination_TPID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
{
|
|
switch (action) {
|
|
case VALUECHECK:
|
|
if (dm_validate_unsignedInt(value, RANGE_ARGS{{NULL,NULL}}, 1))
|
|
return FAULT_9007;
|
|
return 0;
|
|
case VALUESET:
|
|
if (DM_LSTRCMP(value, "33024") == 0)
|
|
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "type", "8021q");
|
|
else if (DM_LSTRCMP(value, "34984") == 0)
|
|
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "type", "8021ad");
|
|
return 0;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.VLANTermination.{i}.Stats.BytesSent!SYSFS:/sys/class/net/@Name/statistics/tx_bytes*/
|
|
static int get_EthernetVLANTerminationStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_sysfs(((struct dmmap_dup *)data)->config_section, "statistics/tx_bytes", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.VLANTermination.{i}.Stats.BytesReceived!SYSFS:/sys/class/net/@Name/statistics/rx_bytes*/
|
|
static int get_EthernetVLANTerminationStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_sysfs(((struct dmmap_dup *)data)->config_section, "statistics/rx_bytes", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.VLANTermination.{i}.Stats.PacketsSent!SYSFS:/sys/class/net/@Name/statistics/tx_packets*/
|
|
static int get_EthernetVLANTerminationStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_sysfs(((struct dmmap_dup *)data)->config_section, "statistics/tx_packets", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.VLANTermination.{i}.Stats.PacketsReceived!SYSFS:/sys/class/net/@Name/statistics/rx_packets*/
|
|
static int get_EthernetVLANTerminationStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_sysfs(((struct dmmap_dup *)data)->config_section, "statistics/rx_packets", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.VLANTermination.{i}.Stats.ErrorsSent!SYSFS:/sys/class/net/@Name/statistics/tx_errors*/
|
|
static int get_EthernetVLANTerminationStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_sysfs(((struct dmmap_dup *)data)->config_section, "statistics/tx_errors", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.VLANTermination.{i}.Stats.ErrorsReceived!SYSFS:/sys/class/net/@Name/statistics/rx_errors*/
|
|
static int get_EthernetVLANTerminationStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_sysfs(((struct dmmap_dup *)data)->config_section, "statistics/rx_errors", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.VLANTermination.{i}.Stats.DiscardPacketsSent!SYSFS:/sys/class/net/@Name/statistics/tx_dropped*/
|
|
static int get_EthernetVLANTerminationStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_sysfs(((struct dmmap_dup *)data)->config_section, "statistics/tx_dropped", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.VLANTermination.{i}.Stats.DiscardPacketsReceived!SYSFS:/sys/class/net/@Name/statistics/rx_dropped*/
|
|
static int get_EthernetVLANTerminationStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_sysfs(((struct dmmap_dup *)data)->config_section, "statistics/rx_dropped", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.VLANTermination.{i}.Stats.MulticastPacketsReceived!SYSFS:/sys/class/net/@Name/statistics/multicast*/
|
|
static int get_EthernetVLANTerminationStats_MulticastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
return eth_iface_sysfs(((struct dmmap_dup *)data)->config_section, "statistics/multicast", value);
|
|
}
|
|
|
|
/*#Device.Ethernet.RMONStats.{i}.Enable!UCI:ports/ethport,@i-1/rmon*/
|
|
static int get_EthernetRMONStats_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmuci_get_value_by_section_fallback_def((((struct eth_rmon_args *)data)->sections)->config_section, "rmon", "1");
|
|
return 0;
|
|
}
|
|
|
|
static int set_EthernetRMONStats_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
{
|
|
bool b;
|
|
|
|
switch (action) {
|
|
case VALUECHECK:
|
|
if (dm_validate_boolean(value))
|
|
return FAULT_9007;
|
|
break;
|
|
case VALUESET:
|
|
string_to_bool(value, &b);
|
|
dmuci_set_value_by_section((((struct eth_rmon_args *)data)->sections)->config_section, "rmon", b ? "1" : "0");
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int get_EthernetRMONStats_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
char *ifname = NULL, *status = NULL;
|
|
|
|
dmuci_get_value_by_section_string((((struct eth_rmon_args *)data)->sections)->config_section, "ifname", &ifname);
|
|
get_net_device_status(ifname, &status);
|
|
|
|
if (strncmp(status, "Up", 2) == 0) {
|
|
*value = "Enabled";
|
|
} else if (strncmp(status, "Down", 4) == 0) {
|
|
*value = "Disabled";
|
|
} else {
|
|
*value = "Error";
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.RMONStats.{i}.Alias!UCI:dmmap_eth_rmon/ethport,@i-1/eth_rmon_alias*/
|
|
static int get_EthernetRMONStats_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
dmuci_get_value_by_section_string((((struct eth_rmon_args *)data)->sections)->dmmap_section, "eth_rmon_alias", value);
|
|
if ((*value)[0] == '\0')
|
|
dmasprintf(value, "cpe-%s", instance);
|
|
return 0;
|
|
}
|
|
|
|
static int set_EthernetRMONStats_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
{
|
|
switch (action) {
|
|
case VALUECHECK:
|
|
if (dm_validate_string(value, -1, 64, NULL, NULL))
|
|
return FAULT_9007;
|
|
break;
|
|
case VALUESET:
|
|
dmuci_set_value_by_section((((struct eth_rmon_args *)data)->sections)->dmmap_section, "eth_rmon_alias", value);
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.RMONStats.{i}.Name!UCI:ports/ethport,@i-1/ifname*/
|
|
static int get_EthernetRMONStats_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmjson_get_value(((struct eth_rmon_args *)data)->eth_rmon_obj, 1, "ifname");
|
|
return 0;
|
|
}
|
|
|
|
static int get_EthernetRMONStats_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
char *linker = NULL;
|
|
|
|
dmuci_get_value_by_section_string((((struct eth_rmon_args *)data)->sections)->config_section, "ifname", &linker);
|
|
adm_entry_get_linker_param(ctx, "Device.Ethernet.Interface.", linker, value);
|
|
return 0;
|
|
}
|
|
|
|
static int set_EthernetRMONStats_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
{
|
|
switch (action) {
|
|
case VALUECHECK:
|
|
if (dm_validate_string(value, -1, -1, NULL, NULL))
|
|
return FAULT_9007;
|
|
break;
|
|
case VALUESET:
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int get_EthernetRMONStats_VLANID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = "0";
|
|
return 0;
|
|
}
|
|
|
|
static int set_EthernetRMONStats_VLANID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
{
|
|
switch (action) {
|
|
case VALUECHECK:
|
|
if (dm_validate_unsignedInt(value, RANGE_ARGS{{"0","4094"}}, 1))
|
|
return FAULT_9007;
|
|
break;
|
|
case VALUESET:
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int get_EthernetRMONStats_AllQueues(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = "true";
|
|
return 0;
|
|
}
|
|
|
|
static int set_EthernetRMONStats_AllQueues(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
|
{
|
|
switch (action) {
|
|
case VALUECHECK:
|
|
if (dm_validate_boolean(value))
|
|
return FAULT_9007;
|
|
break;
|
|
case VALUESET:
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.RMONStats.{i}.Bytes!UBUS:ethernet/rmonstats/ifname,ifname/rx_bytes*/
|
|
static int get_EthernetRMONStats_Bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmjson_get_value(((struct eth_rmon_args *)data)->eth_rmon_obj, 1, "rx_bytes");
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.RMONStats.{i}.Packets!UBUS:ethernet/rmonstats/ifname,ifname/rx_packets*/
|
|
static int get_EthernetRMONStats_Packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmjson_get_value(((struct eth_rmon_args *)data)->eth_rmon_obj, 1, "rx_packets");
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.RMONStats.{i}.BroadcastPackets!UBUS:ethernet/rmonstats/ifname,ifname/rx_broadcast_packets*/
|
|
static int get_EthernetRMONStats_BroadcastPackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmjson_get_value(((struct eth_rmon_args *)data)->eth_rmon_obj, 1, "rx_broadcast_packets");
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.RMONStats.{i}.MulticastPackets!UBUS:ethernet/rmonstats/ifname,ifname/rx_multicast_packets*/
|
|
static int get_EthernetRMONStats_MulticastPackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmjson_get_value(((struct eth_rmon_args *)data)->eth_rmon_obj, 1, "rx_multicast_packets");
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.RMONStats.{i}.CRCErroredPackets!UBUS:ethernet/rmonstats/ifname,ifname/rx_crc_error_packets*/
|
|
static int get_EthernetRMONStats_CRCErroredPackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmjson_get_value(((struct eth_rmon_args *)data)->eth_rmon_obj, 1, "rx_crc_error_packets");
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.RMONStats.{i}.UndersizePackets!UBUS:ethernet/rmonstats/ifname,ifname/rx_undersize_packets*/
|
|
static int get_EthernetRMONStats_UndersizePackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmjson_get_value(((struct eth_rmon_args *)data)->eth_rmon_obj, 1, "rx_undersize_packets");
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.RMONStats.{i}.OversizePackets!UBUS:ethernet/rmonstats/ifname,ifname/rx_oversize_packets*/
|
|
static int get_EthernetRMONStats_OversizePackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmjson_get_value(((struct eth_rmon_args *)data)->eth_rmon_obj, 1, "rx_oversize_packets");
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.RMONStats.{i}.Packets64Bytes!UBUS:ethernet/rmonstats/ifname,ifname/rx_packets_64bytes*/
|
|
static int get_EthernetRMONStats_Packets64Bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmjson_get_value(((struct eth_rmon_args *)data)->eth_rmon_obj, 1, "rx_packets_64bytes");
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.RMONStats.{i}.Packets65to127Bytes!UBUS:ethernet/rmonstats/ifname,ifname/rx_packets_65to127bytes*/
|
|
static int get_EthernetRMONStats_Packets65to127Bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmjson_get_value(((struct eth_rmon_args *)data)->eth_rmon_obj, 1, "rx_packets_65to127bytes");
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.RMONStats.{i}.Packets128to255Bytes!UBUS:ethernet/rmonstats/ifname,ifname/rx_packets_128to255bytes*/
|
|
static int get_EthernetRMONStats_Packets128to255Bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmjson_get_value(((struct eth_rmon_args *)data)->eth_rmon_obj, 1, "rx_packets_128to255bytes");
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.RMONStats.{i}.Packets256to511Bytes!UBUS:ethernet/rmonstats/ifname,ifname/rx_packets_256to511bytes*/
|
|
static int get_EthernetRMONStats_Packets256to511Bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmjson_get_value(((struct eth_rmon_args *)data)->eth_rmon_obj, 1, "rx_packets_256to511bytes");
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.RMONStats.{i}.Packets512to1023Bytes!UBUS:ethernet/rmonstats/ifname,ifname/rx_packets_512to1023bytes*/
|
|
static int get_EthernetRMONStats_Packets512to1023Bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmjson_get_value(((struct eth_rmon_args *)data)->eth_rmon_obj, 1, "rx_packets_512to1023bytes");
|
|
return 0;
|
|
}
|
|
|
|
/*#Device.Ethernet.RMONStats.{i}.Packets1024to1518Bytes!UBUS:ethernet/rmonstats/ifname,ifname/rx_packets_1024to1518bytes*/
|
|
static int get_EthernetRMONStats_Packets1024to1518Bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
|
{
|
|
*value = dmjson_get_value(((struct eth_rmon_args *)data)->eth_rmon_obj, 1, "rx_packets_1024to1518bytes");
|
|
return 0;
|
|
}
|
|
|
|
/**********************************************************************************************************************************
|
|
* OBJ & PARAM DEFINITION
|
|
***********************************************************************************************************************************/
|
|
/* *** Device.Ethernet. *** */
|
|
DMOBJ tEthernetObj[] = {
|
|
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
|
|
{"Interface", &DMREAD, NULL, NULL, NULL, browseEthernetInterfaceInst, NULL, NULL, tEthernetInterfaceObj, tEthernetInterfaceParams, get_linker_interface, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}, "2.0"},
|
|
{"Link", &DMWRITE, addObjEthernetLink, delObjEthernetLink, NULL, browseEthernetLinkInst, NULL, NULL, tEthernetLinkObj, tEthernetLinkParams, get_linker_link, BBFDM_BOTH, LIST_KEY{"Name", "Alias", "MACAddress", NULL}, "2.0"},
|
|
{"VLANTermination", &DMWRITE, addObjEthernetVLANTermination, delObjEthernetVLANTermination, NULL, browseEthernetVLANTerminationInst, NULL, NULL, tEthernetVLANTerminationObj, tEthernetVLANTerminationParams, get_linker_vlan_term, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}, "2.0"},
|
|
{"RMONStats", &DMREAD, NULL, NULL, "file:/etc/config/ports;ubus:ethernet->rmonstats", browseEthernetRMONStatsInst, NULL, NULL, NULL, tEthernetRMONStatsParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", "Interface", "VLANID", NULL}, "2.4"},
|
|
{0}
|
|
};
|
|
|
|
DMLEAF tEthernetParams[] = {
|
|
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
|
|
{"FlowControlSupported", &DMREAD, DMT_BOOL, get_Ethernet_FlowControlSupported, NULL, BBFDM_BOTH, "2.14"},
|
|
{"InterfaceNumberOfEntries", &DMREAD, DMT_UNINT, get_Ethernet_InterfaceNumberOfEntries, NULL, BBFDM_BOTH, "2.0"},
|
|
{"LinkNumberOfEntries", &DMREAD, DMT_UNINT, get_Ethernet_LinkNumberOfEntries, NULL, BBFDM_BOTH, "2.0"},
|
|
{"VLANTerminationNumberOfEntries", &DMREAD, DMT_UNINT, get_Ethernet_VLANTerminationNumberOfEntries, NULL, BBFDM_BOTH, "2.0"},
|
|
{"RMONStatsNumberOfEntries", &DMREAD, DMT_UNINT, get_Ethernet_RMONStatsNumberOfEntries, NULL, BBFDM_BOTH, "2.4"},
|
|
{0}
|
|
};
|
|
|
|
/* *** Device.Ethernet.Interface.{i}. *** */
|
|
DMOBJ tEthernetInterfaceObj[] = {
|
|
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
|
|
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tEthernetInterfaceStatsParams, NULL, BBFDM_BOTH, NULL, "2.0"},
|
|
{0}
|
|
};
|
|
|
|
DMLEAF tEthernetInterfaceParams[] = {
|
|
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
|
|
{"Enable", &DMWRITE, DMT_BOOL, get_EthernetInterface_Enable, set_EthernetInterface_Enable, BBFDM_BOTH, "2.0"},
|
|
{"Status", &DMREAD, DMT_STRING, get_EthernetInterface_Status, NULL, BBFDM_BOTH, "2.0"},
|
|
{"Alias", &DMWRITE, DMT_STRING, get_EthernetInterface_Alias, set_EthernetInterface_Alias, BBFDM_BOTH, "2.0"},
|
|
{"Name", &DMREAD, DMT_STRING, get_EthernetInterface_Name, NULL, BBFDM_BOTH, "2.0"},
|
|
{"LastChange", &DMREAD, DMT_UNINT, get_EthernetInterface_LastChange, NULL, BBFDM_BOTH, "2.0"},
|
|
{"LowerLayers", &DMWRITE, DMT_STRING, get_EthernetInterface_LowerLayers, set_EthernetInterface_LowerLayers, BBFDM_BOTH, "2.0"},
|
|
{"Upstream", &DMREAD, DMT_BOOL, get_EthernetInterface_Upstream, NULL, BBFDM_BOTH, "2.0"},
|
|
{"MACAddress", &DMREAD, DMT_STRING, get_EthernetInterface_MACAddress, NULL, BBFDM_BOTH, "2.0"},
|
|
{"MaxBitRate", &DMWRITE, DMT_INT, get_EthernetInterface_MaxBitRate, set_EthernetInterface_MaxBitRate, BBFDM_BOTH, "2.0"},
|
|
{"CurrentBitRate", &DMREAD, DMT_UNINT, get_EthernetInterface_CurrentBitRate, NULL, BBFDM_BOTH, "2.7"},
|
|
{"DuplexMode", &DMWRITE, DMT_STRING, get_EthernetInterface_DuplexMode, set_EthernetInterface_DuplexMode, BBFDM_BOTH, "2.0"},
|
|
{"EEECapability", &DMREAD, DMT_BOOL, get_EthernetInterface_EEECapability, NULL, BBFDM_BOTH, "2.8"},
|
|
{"EEEEnable", &DMWRITE, DMT_BOOL, get_EthernetInterface_EEEEnable, set_EthernetInterface_EEEEnable, BBFDM_BOTH, "2.8"},
|
|
{0}
|
|
};
|
|
|
|
/* *** Device.Ethernet.Interface.{i}.Stats. *** */
|
|
DMLEAF tEthernetInterfaceStatsParams[] = {
|
|
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
|
|
{"BytesSent", &DMREAD, DMT_UNLONG, get_EthernetInterfaceStats_BytesSent, NULL, BBFDM_BOTH, "2.0"},
|
|
{"BytesReceived", &DMREAD, DMT_UNLONG, get_EthernetInterfaceStats_BytesReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
{"PacketsSent", &DMREAD, DMT_UNLONG, get_EthernetInterfaceStats_PacketsSent, NULL, BBFDM_BOTH, "2.0"},
|
|
{"PacketsReceived", &DMREAD, DMT_UNLONG, get_EthernetInterfaceStats_PacketsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
{"ErrorsSent", &DMREAD, DMT_UNINT, get_EthernetInterfaceStats_ErrorsSent, NULL, BBFDM_BOTH, "2.0"},
|
|
{"ErrorsReceived", &DMREAD, DMT_UNINT, get_EthernetInterfaceStats_ErrorsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
{"DiscardPacketsSent", &DMREAD, DMT_UNINT, get_EthernetInterfaceStats_DiscardPacketsSent, NULL, BBFDM_BOTH, "2.0"},
|
|
{"DiscardPacketsReceived", &DMREAD, DMT_UNINT, get_EthernetInterfaceStats_DiscardPacketsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
{"MulticastPacketsReceived", &DMREAD, DMT_UNLONG, get_EthernetInterfaceStats_MulticastPacketsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
{"MulticastPacketsSent", &DMREAD, DMT_UNLONG, get_EthernetInterfaceStats_MulticastPacketsSent, NULL, BBFDM_BOTH, "2.0"},
|
|
{"UnicastPacketsSent", &DMREAD, DMT_UNLONG, get_EthernetInterfaceStats_UnicastPacketsSent, NULL, BBFDM_BOTH, "2.0"},
|
|
{"UnicastPacketsReceived", &DMREAD, DMT_UNLONG, get_EthernetInterfaceStats_UnicastPacketsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
{"BroadcastPacketsSent", &DMREAD, DMT_UNLONG, get_EthernetInterfaceStats_BroadcastPacketsSent, NULL, BBFDM_BOTH, "2.0"},
|
|
{"BroadcastPacketsReceived", &DMREAD, DMT_UNLONG, get_EthernetInterfaceStats_BroadcastPacketsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
{"UnknownProtoPacketsReceived", &DMREAD, DMT_UNINT, get_EthernetInterfaceStats_UnknownProtoPacketsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
{0}
|
|
};
|
|
|
|
/* *** Device.Ethernet.Link.{i}. *** */
|
|
DMOBJ tEthernetLinkObj[] = {
|
|
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
|
|
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tEthernetLinkStatsParams, NULL, BBFDM_BOTH, NULL, "2.0"},
|
|
{0}
|
|
};
|
|
|
|
DMLEAF tEthernetLinkParams[] = {
|
|
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
|
|
{"Enable", &DMWRITE, DMT_BOOL, get_EthernetLink_Enable, set_EthernetLink_Enable, BBFDM_BOTH, "2.0"},
|
|
{"Status", &DMREAD, DMT_STRING, get_EthernetLink_Status, NULL, BBFDM_BOTH, "2.0"},
|
|
{"Alias", &DMWRITE, DMT_STRING, get_EthernetLink_Alias, set_EthernetLink_Alias, BBFDM_BOTH, "2.0"},
|
|
{"Name", &DMREAD, DMT_STRING, get_EthernetLink_Name, NULL, BBFDM_BOTH, "2.0"},
|
|
{"LastChange", &DMREAD, DMT_UNINT, get_EthernetLink_LastChange, NULL, BBFDM_BOTH, "2.0"},
|
|
{"LowerLayers", &DMWRITE, DMT_STRING, get_EthernetLink_LowerLayers, set_EthernetLink_LowerLayers, BBFDM_BOTH, "2.0"},
|
|
{"MACAddress", &DMREAD, DMT_STRING, get_EthernetLink_MACAddress, NULL, BBFDM_BOTH, "2.0"},
|
|
{"FlowControl", &DMWRITE, DMT_BOOL, get_EthernetLink_FlowControl, set_EthernetLink_FlowControl, BBFDM_BOTH, "2.14"},
|
|
{0}
|
|
};
|
|
|
|
/* *** Device.Ethernet.Link.{i}.Stats. *** */
|
|
DMLEAF tEthernetLinkStatsParams[] = {
|
|
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
|
|
{"BytesSent", &DMREAD, DMT_UNLONG, get_EthernetLinkStats_BytesSent, NULL, BBFDM_BOTH, "2.0"},
|
|
{"BytesReceived", &DMREAD, DMT_UNLONG, get_EthernetLinkStats_BytesReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
{"PacketsSent", &DMREAD, DMT_UNLONG, get_EthernetLinkStats_PacketsSent, NULL, BBFDM_BOTH, "2.0"},
|
|
{"PacketsReceived", &DMREAD, DMT_UNLONG, get_EthernetLinkStats_PacketsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
{"ErrorsSent", &DMREAD, DMT_UNINT, get_EthernetLinkStats_ErrorsSent, NULL, BBFDM_BOTH, "2.0"},
|
|
{"ErrorsReceived", &DMREAD, DMT_UNINT, get_EthernetLinkStats_ErrorsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
{"DiscardPacketsSent", &DMREAD, DMT_UNINT, get_EthernetLinkStats_DiscardPacketsSent, NULL, BBFDM_BOTH, "2.0"},
|
|
{"DiscardPacketsReceived", &DMREAD, DMT_UNINT, get_EthernetLinkStats_DiscardPacketsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
{"MulticastPacketsReceived", &DMREAD, DMT_UNLONG, get_EthernetLinkStats_MulticastPacketsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
{"MulticastPacketsSent", &DMREAD, DMT_UNLONG, get_EthernetLinkStats_MulticastPacketsSent, NULL, BBFDM_BOTH, "2.0"},
|
|
{"UnicastPacketsSent", &DMREAD, DMT_UNLONG, get_EthernetLinkStats_UnicastPacketsSent, NULL, BBFDM_BOTH, "2.0"},
|
|
{"UnicastPacketsReceived", &DMREAD, DMT_UNLONG, get_EthernetLinkStats_UnicastPacketsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
{"BroadcastPacketsSent", &DMREAD, DMT_UNLONG, get_EthernetLinkStats_BroadcastPacketsSent, NULL, BBFDM_BOTH, "2.0"},
|
|
{"BroadcastPacketsReceived", &DMREAD, DMT_UNLONG, get_EthernetLinkStats_BroadcastPacketsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
{"UnknownProtoPacketsReceived", &DMREAD, DMT_UNINT, get_EthernetLinkStats_UnknownProtoPacketsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
{0}
|
|
};
|
|
|
|
/* *** Device.Ethernet.VLANTermination.{i}. *** */
|
|
DMOBJ tEthernetVLANTerminationObj[] = {
|
|
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
|
|
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tEthernetVLANTerminationStatsParams, NULL, BBFDM_BOTH, NULL, "2.0"},
|
|
{0}
|
|
};
|
|
|
|
DMLEAF tEthernetVLANTerminationParams[] = {
|
|
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
|
|
{"Enable", &DMWRITE, DMT_BOOL, get_EthernetVLANTermination_Enable, set_EthernetVLANTermination_Enable, BBFDM_BOTH, "2.0"},
|
|
{"Status", &DMREAD, DMT_STRING, get_EthernetVLANTermination_Status, NULL, BBFDM_BOTH, "2.0"},
|
|
{"Alias", &DMWRITE, DMT_STRING, get_EthernetVLANTermination_Alias, set_EthernetVLANTermination_Alias, BBFDM_BOTH, "2.0"},
|
|
{"Name", &DMREAD, DMT_STRING, get_EthernetVLANTermination_Name, NULL, BBFDM_BOTH, "2.0"},
|
|
//{"LastChange", &DMREAD, DMT_UNINT, get_EthernetVLANTermination_LastChange, NULL, BBFDM_BOTH, "2.0"},
|
|
{"LowerLayers", &DMWRITE, DMT_STRING, get_EthernetVLANTermination_LowerLayers, set_EthernetVLANTermination_LowerLayers, BBFDM_BOTH, "2.0"},
|
|
{"VLANID", &DMWRITE, DMT_UNINT, get_EthernetVLANTermination_VLANID, set_EthernetVLANTermination_VLANID, BBFDM_BOTH, "2.0"},
|
|
{"TPID", &DMWRITE, DMT_UNINT, get_EthernetVLANTermination_TPID, set_EthernetVLANTermination_TPID, BBFDM_BOTH, "2.7"},
|
|
{0}
|
|
};
|
|
|
|
/* *** Device.Ethernet.VLANTermination.{i}.Stats. *** */
|
|
DMLEAF tEthernetVLANTerminationStatsParams[] = {
|
|
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
|
|
{"BytesSent", &DMREAD, DMT_UNLONG, get_EthernetVLANTerminationStats_BytesSent, NULL, BBFDM_BOTH, "2.0"},
|
|
{"BytesReceived", &DMREAD, DMT_UNLONG, get_EthernetVLANTerminationStats_BytesReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
{"PacketsSent", &DMREAD, DMT_UNLONG, get_EthernetVLANTerminationStats_PacketsSent, NULL, BBFDM_BOTH, "2.0"},
|
|
{"PacketsReceived", &DMREAD, DMT_UNLONG, get_EthernetVLANTerminationStats_PacketsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
{"ErrorsSent", &DMREAD, DMT_UNINT, get_EthernetVLANTerminationStats_ErrorsSent, NULL, BBFDM_BOTH, "2.0"},
|
|
{"ErrorsReceived", &DMREAD, DMT_UNINT, get_EthernetVLANTerminationStats_ErrorsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
//{"UnicastPacketsSent", &DMREAD, DMT_UNLONG, get_EthernetVLANTerminationStats_UnicastPacketsSent, NULL, BBFDM_BOTH, "2.0"},
|
|
//{"UnicastPacketsReceived", &DMREAD, DMT_UNLONG, get_EthernetVLANTerminationStats_UnicastPacketsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
{"DiscardPacketsSent", &DMREAD, DMT_UNINT, get_EthernetVLANTerminationStats_DiscardPacketsSent, NULL, BBFDM_BOTH, "2.0"},
|
|
{"DiscardPacketsReceived", &DMREAD, DMT_UNINT, get_EthernetVLANTerminationStats_DiscardPacketsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
//{"MulticastPacketsSent", &DMREAD, DMT_UNLONG, get_EthernetVLANTerminationStats_MulticastPacketsSent, NULL, BBFDM_BOTH, "2.0"},
|
|
{"MulticastPacketsReceived", &DMREAD, DMT_UNLONG, get_EthernetVLANTerminationStats_MulticastPacketsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
//{"BroadcastPacketsSent", &DMREAD, DMT_UNLONG, get_EthernetVLANTerminationStats_BroadcastPacketsSent, NULL, BBFDM_BOTH, "2.0"},
|
|
//{"BroadcastPacketsReceived", &DMREAD, DMT_UNLONG, get_EthernetVLANTerminationStats_BroadcastPacketsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
//{"UnknownProtoPacketsReceived", &DMREAD, DMT_UNINT, get_EthernetVLANTerminationStats_UnknownProtoPacketsReceived, NULL, BBFDM_BOTH, "2.0"},
|
|
{0}
|
|
};
|
|
|
|
/* *** Device.Ethernet.RMONStats.{i}. *** */
|
|
DMLEAF tEthernetRMONStatsParams[] = {
|
|
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
|
|
{"Enable", &DMWRITE, DMT_BOOL, get_EthernetRMONStats_Enable, set_EthernetRMONStats_Enable, BBFDM_BOTH, "2.4"},
|
|
{"Status", &DMREAD, DMT_STRING, get_EthernetRMONStats_Status, NULL, BBFDM_BOTH, "2.4"},
|
|
{"Alias", &DMWRITE, DMT_STRING, get_EthernetRMONStats_Alias, set_EthernetRMONStats_Alias, BBFDM_BOTH, "2.4"},
|
|
{"Name", &DMREAD, DMT_STRING, get_EthernetRMONStats_Name, NULL, BBFDM_BOTH, "2.4"},
|
|
{"Interface", &DMWRITE, DMT_STRING, get_EthernetRMONStats_Interface, set_EthernetRMONStats_Interface, BBFDM_BOTH, "2.4"},
|
|
{"VLANID", &DMWRITE, DMT_UNINT, get_EthernetRMONStats_VLANID, set_EthernetRMONStats_VLANID, BBFDM_BOTH, "2.4"},
|
|
//{"Queue", &DMWRITE, DMT_STRING, get_EthernetRMONStats_Queue, set_EthernetRMONStats_Queue, BBFDM_BOTH, "2.4"},
|
|
{"AllQueues", &DMWRITE, DMT_BOOL, get_EthernetRMONStats_AllQueues, set_EthernetRMONStats_AllQueues, BBFDM_BOTH, "2.4"},
|
|
//{"DropEvents", &DMREAD, DMT_UNINT, get_EthernetRMONStats_DropEvents, NULL, BBFDM_BOTH, "2.4"},
|
|
{"Bytes", &DMREAD, DMT_UNLONG, get_EthernetRMONStats_Bytes, NULL, BBFDM_BOTH, "2.4"},
|
|
{"Packets", &DMREAD, DMT_UNLONG, get_EthernetRMONStats_Packets, NULL, BBFDM_BOTH, "2.4"},
|
|
{"BroadcastPackets", &DMREAD, DMT_UNLONG, get_EthernetRMONStats_BroadcastPackets, NULL, BBFDM_BOTH, "2.4"},
|
|
{"MulticastPackets", &DMREAD, DMT_UNLONG, get_EthernetRMONStats_MulticastPackets, NULL, BBFDM_BOTH, "2.4"},
|
|
{"CRCErroredPackets", &DMREAD, DMT_UNINT, get_EthernetRMONStats_CRCErroredPackets, NULL, BBFDM_BOTH, "2.4"},
|
|
{"UndersizePackets", &DMREAD, DMT_UNINT, get_EthernetRMONStats_UndersizePackets, NULL, BBFDM_BOTH, "2.4"},
|
|
{"OversizePackets", &DMREAD, DMT_UNINT, get_EthernetRMONStats_OversizePackets, NULL, BBFDM_BOTH, "2.4"},
|
|
{"Packets64Bytes", &DMREAD, DMT_UNLONG, get_EthernetRMONStats_Packets64Bytes, NULL, BBFDM_BOTH, "2.4"},
|
|
{"Packets65to127Bytes", &DMREAD, DMT_UNLONG, get_EthernetRMONStats_Packets65to127Bytes, NULL, BBFDM_BOTH, "2.4"},
|
|
{"Packets128to255Bytes", &DMREAD, DMT_UNLONG, get_EthernetRMONStats_Packets128to255Bytes, NULL, BBFDM_BOTH, "2.4"},
|
|
{"Packets256to511Bytes", &DMREAD, DMT_UNLONG, get_EthernetRMONStats_Packets256to511Bytes, NULL, BBFDM_BOTH, "2.4"},
|
|
{"Packets512to1023Bytes", &DMREAD, DMT_UNLONG, get_EthernetRMONStats_Packets512to1023Bytes, NULL, BBFDM_BOTH, "2.4"},
|
|
{"Packets1024to1518Bytes", &DMREAD, DMT_UNLONG, get_EthernetRMONStats_Packets1024to1518Bytes, NULL, BBFDM_BOTH, "2.4"},
|
|
{0}
|
|
};
|