B#12156: Hub is missing from IEEE1905Device

This commit is contained in:
Amin Ben Romdhane 2023-09-29 12:20:37 +00:00
parent 60171c8817
commit 718ca85d51
2 changed files with 362 additions and 84 deletions

View file

@ -11,12 +11,27 @@
#include "ieee1905.h"
struct ieee1905_device_args
{
char *mac_addr;
json_object *dev_obj;
};
struct ieee1905_device_nonieee1905neighbor_args
{
char *mac_addr;
char *neighbor;
};
struct ieee1905_device_ieee1905neighbor_args
{
char *mac_addr;
char *neighbor_device_id;
char *neighbor_macaddress;
char *num_metrics;
json_object *dev_obj;
};
/**************************************************************************
* LINKER
***************************************************************************/
@ -110,56 +125,112 @@ static int browseIEEE1905ALNetworkTopologyIEEE1905DeviceInst(struct dmctx *dmctx
int id = 0, i = 0;
dmubus_call("ieee1905", "info", UBUS_ARGS{0}, 0, &res);
if (!res)
return 0;
// Self node in the network
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)res, inst) == DM_STOP)
return 0;
// Discovered 1905 Devices in the network
dmjson_foreach_obj_in_array(res, arrobj, device_obj, i, 2, "topology", "device") {
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)device_obj, inst) == DM_STOP)
break;
}
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IPv4Address.{i}.!UBUS:ieee1905/info//topology.device[@i-1].ipv4_address*/
static int browseIEEE1905ALNetworkTopologyIEEE1905DeviceIPv4AddressInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
json_object *arrobj = NULL, *ipv4_address = NULL, *device = (json_object *)prev_data;
json_object *ip4arrobj = NULL, *ipv4_address = NULL, *ifacearrobj = NULL, *interface = NULL;
struct ieee1905_device_args curr_ipv4address_args = {0};
char *inst = NULL;
int id = 0, i = 0;
int id = 0, i = 0, j = 0;
dmjson_foreach_obj_in_array(device, arrobj, ipv4_address, i, 1, "ipv4_address") {
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)ipv4_address, inst) == DM_STOP)
break;
if (DM_STRCMP(prev_instance, "1") == 0) { // Self node in the network
dmjson_foreach_obj_in_array((json_object *)prev_data, ifacearrobj, interface, i, 1, "interface") {
curr_ipv4address_args.mac_addr = dmjson_get_value(interface, 1, "macaddress");
dmjson_foreach_obj_in_array(interface, ip4arrobj, ipv4_address, j, 1, "ipv4_address") {
curr_ipv4address_args.dev_obj = ipv4_address;
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_ipv4address_args, inst) == DM_STOP)
goto end;
}
}
} else { // Discovered 1905 Devices in the network
dmjson_foreach_obj_in_array((json_object *)prev_data, ip4arrobj, ipv4_address, i, 1, "ipv4_address") {
curr_ipv4address_args.mac_addr = dmjson_get_value(ipv4_address, 1, "macaddress");
curr_ipv4address_args.dev_obj = ipv4_address;
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_ipv4address_args, inst) == DM_STOP)
break;
}
}
end:
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IPv6Address.{i}.!UBUS:ieee1905/info//topology.device[@i-1].ipv6_address*/
static int browseIEEE1905ALNetworkTopologyIEEE1905DeviceIPv6AddressInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
json_object *arrobj = NULL, *ipv6_address = NULL, *device = (json_object *)prev_data;
json_object *ip6arrobj = NULL, *ipv6_address = NULL, *ifacearrobj = NULL, *interface = NULL;
struct ieee1905_device_args curr_ipv6address_args = {0};
char *inst = NULL;
int id = 0, i = 0;
int id = 0, i = 0, j = 0;
dmjson_foreach_obj_in_array(device, arrobj, ipv6_address, i, 1, "ipv6_address") {
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)ipv6_address, inst) == DM_STOP)
break;
if (DM_STRCMP(prev_instance, "1") == 0) { // Self node in the network
dmjson_foreach_obj_in_array((json_object *)prev_data, ifacearrobj, interface, i, 1, "interface") {
curr_ipv6address_args.mac_addr = dmjson_get_value(interface, 1, "macaddress");
dmjson_foreach_obj_in_array(interface, ip6arrobj, ipv6_address, j, 1, "ipv6_address") {
curr_ipv6address_args.dev_obj = ipv6_address;
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_ipv6address_args, inst) == DM_STOP)
goto end;
}
}
} else { // Discovered 1905 Devices in the network
dmjson_foreach_obj_in_array((json_object *)prev_data, ip6arrobj, ipv6_address, i, 1, "ipv6_address") {
curr_ipv6address_args.mac_addr = dmjson_get_value(ipv6_address, 1, "macaddress");
curr_ipv6address_args.dev_obj = ipv6_address;
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_ipv6address_args, inst) == DM_STOP)
break;
}
}
end:
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.VendorProperties.{i}.!UBUS:ieee1905/info//topology.device[@i-1].vendor_properties*/
static int browseIEEE1905ALNetworkTopologyIEEE1905DeviceVendorPropertiesInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
json_object *arrobj = NULL, *vendor_properties = NULL, *device = (json_object *)prev_data;
json_object *arrobj = NULL, *vendor_properties = NULL, *ifacearrobj = NULL, *interface = NULL;
char *inst = NULL;
int id = 0, i = 0;
int id = 0, i = 0, j = 0;
dmjson_foreach_obj_in_array(device, arrobj, vendor_properties, i, 1, "vendor_properties") {
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)vendor_properties, inst) == DM_STOP)
break;
if (DM_STRCMP(prev_instance, "1") == 0) { // Self node in the network
dmjson_foreach_obj_in_array((json_object *)prev_data, ifacearrobj, interface, i, 1, "interface") {
dmjson_foreach_obj_in_array(interface, arrobj, vendor_properties, j, 1, "properties") {
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)vendor_properties, inst) == DM_STOP)
goto end;
}
}
} else { // Discovered 1905 Devices in the network
dmjson_foreach_obj_in_array((json_object *)prev_data, arrobj, vendor_properties, i, 1, "vendor_properties") {
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)vendor_properties, inst) == DM_STOP)
break;
}
}
end:
return 0;
}
@ -181,22 +252,30 @@ static int browseIEEE1905ALNetworkTopologyIEEE1905DeviceInterfaceInst(struct dmc
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.NonIEEE1905Neighbor.{i}.!UBUS:ieee1905/info//topology.device[@i-1].non1905_neighbors*/
static int browseIEEE1905ALNetworkTopologyIEEE1905DeviceNonIEEE1905NeighborInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
json_object *arrobj = NULL, *non1905_neighbor = NULL, *device = (json_object *)prev_data;
json_object *non1905arrobj = NULL, *non1905 = NULL, *ifacearrobj = NULL, *interface = NULL, *neighbor_val = NULL;
struct ieee1905_device_nonieee1905neighbor_args curr_nonieee1905neighbor_args = {0};
char *inst = NULL;
int id = 0, i = 0;
char *inst = NULL, *neighbor = NULL;
int id = 0, i = 0, j = 0;
dmjson_foreach_obj_in_array(device, arrobj, non1905_neighbor, i, 1, "non1905_neighbors") {
json_object *neighbor_val = NULL;
char *neighbor = NULL;
int j = 0;
curr_nonieee1905neighbor_args.mac_addr = dmjson_get_value(non1905_neighbor, 1, "interface_macaddress");
dmjson_foreach_value_in_array(non1905_neighbor, neighbor_val, neighbor, j, 1, "neighbors") {
curr_nonieee1905neighbor_args.neighbor = neighbor;
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_nonieee1905neighbor_args, inst) == DM_STOP)
goto end;
if (DM_STRCMP(prev_instance, "1") == 0) { // Self node in the network
dmjson_foreach_obj_in_array((json_object *)prev_data, ifacearrobj, interface, i, 1, "interface") {
curr_nonieee1905neighbor_args.mac_addr = dmjson_get_value(interface, 1, "macaddress");
dmjson_foreach_value_in_array(non1905, neighbor_val, neighbor, j, 1, "non1905_neighbors") {
curr_nonieee1905neighbor_args.neighbor = neighbor;
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_nonieee1905neighbor_args, inst) == DM_STOP)
goto end;
}
}
} else { // Discovered 1905 Devices in the network
dmjson_foreach_obj_in_array((json_object *)prev_data, non1905arrobj, non1905, i, 1, "non1905_neighbors") {
curr_nonieee1905neighbor_args.mac_addr = dmjson_get_value(non1905, 1, "interface_macaddress");
dmjson_foreach_value_in_array(non1905, neighbor_val, neighbor, j, 1, "neighbors") {
curr_nonieee1905neighbor_args.neighbor = neighbor;
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_nonieee1905neighbor_args, inst) == DM_STOP)
goto end;
}
}
}
@ -215,15 +294,36 @@ static int browseIEEE1905ALNetworkTopologyIEEE1905DeviceL2NeighborInst(struct dm
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905Neighbor.{i}.!UBUS:ieee1905/info//topology.device[@i-1].ieee1905_neighbors*/
static int browseIEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
json_object *arrobj = NULL, *ieee1905_neighbors = NULL, *device = (json_object *)prev_data;
json_object *ieee1905_neighborsarrobj = NULL, *ieee1905_neighbors = NULL, *ifacearrobj = NULL, *interface = NULL;
struct ieee1905_device_ieee1905neighbor_args curr_ieee1905_neighbors_args = {0};
char *inst = NULL;
int id = 0, i = 0;
int id = 0, i = 0, j = 0;
dmjson_foreach_obj_in_array(device, arrobj, ieee1905_neighbors, i, 1, "ieee1905_neighbors") {
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)ieee1905_neighbors, inst) == DM_STOP)
break;
if (DM_STRCMP(prev_instance, "1") == 0) { // Self node in the network
dmjson_foreach_obj_in_array((json_object *)prev_data, ifacearrobj, interface, i, 1, "interface") {
curr_ieee1905_neighbors_args.mac_addr = dmjson_get_value(interface, 1, "macaddress");
dmjson_foreach_obj_in_array(interface, ieee1905_neighborsarrobj, ieee1905_neighbors, j, 1, "links") {
curr_ieee1905_neighbors_args.neighbor_device_id = dmjson_get_value(ieee1905_neighbors, 1, "ieee1905id");
curr_ieee1905_neighbors_args.num_metrics = "1";
curr_ieee1905_neighbors_args.dev_obj = ieee1905_neighbors;
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_ieee1905_neighbors_args, inst) == DM_STOP)
goto end;
}
}
} else { // Discovered 1905 Devices in the network
dmjson_foreach_obj_in_array((json_object *)prev_data, ieee1905_neighborsarrobj, ieee1905_neighbors, i, 1, "ieee1905_neighbors") {
curr_ieee1905_neighbors_args.mac_addr = dmjson_get_value(ieee1905_neighbors, 1, "macaddress");
curr_ieee1905_neighbors_args.neighbor_device_id = dmjson_get_value(ieee1905_neighbors, 1, "neighbor_device_id");
curr_ieee1905_neighbors_args.num_metrics = dmjson_get_value(ieee1905_neighbors, 1, "num_metrics");
curr_ieee1905_neighbors_args.dev_obj = ieee1905_neighbors;
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_ieee1905_neighbors_args, inst) == DM_STOP)
break;
}
}
end:
return 0;
}
@ -245,19 +345,30 @@ static int browseIEEE1905ALNetworkTopologyIEEE1905DeviceBridgingTupleInst(struct
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905Neighbor.{i}.Metric.{i}.!UBUS:ieee1905/info//topology.device[@i-1].ieee1905_neighbors[@i-1].metric*/
static int browseIEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetricInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
json_object *arrobj = NULL, *metric = NULL, *ieee1905_neighbors = (json_object *)prev_data;
struct ieee1905_device_ieee1905neighbor_args *ieee1905neighbor_arg = (struct ieee1905_device_ieee1905neighbor_args *)prev_data;
json_object *arrobj = NULL, *metric = NULL, *ieee1905_neighbors = ieee1905neighbor_arg->dev_obj;
char *inst = NULL;
int id = 0, i = 0;
dmjson_foreach_obj_in_array(ieee1905_neighbors, arrobj, metric, i, 1, "metric") {
json_object_object_get_ex(ieee1905_neighbors, "metric", &metric);
if (metric && json_object_get_type(metric) == json_type_array) { // Discovered 1905 Devices in the network
dmjson_foreach_obj_in_array(ieee1905_neighbors, arrobj, metric, i, 1, "metric") {
ieee1905neighbor_arg->neighbor_macaddress = dmjson_get_value(metric, 1, "neighbor_macaddress");
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, prev_data, inst) == DM_STOP)
break;
}
} else { // Self node in the network
ieee1905neighbor_arg->neighbor_macaddress = dmjson_get_value(ieee1905_neighbors, 1, "macaddress");
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)metric, inst) == DM_STOP)
break;
if (DM_LINK_INST_OBJ(dmctx, parent_node, prev_data, inst) == DM_STOP)
goto end;
}
end:
return 0;
}
/*************************************************************
* ADD & DEL OBJ
**************************************************************/
@ -439,11 +550,12 @@ static int get_IEEE1905ALInterface_LowerLayers(char *refparam, struct dmctx *ctx
char *linker = dmjson_get_value((json_object *)data, 1, "ifname");
adm_entry_get_linker_param(ctx, "Device.Ethernet.Interface.", linker, value);
if (!(*value) || (*value)[0] == 0)
adm_entry_get_linker_param(ctx, "Device.WiFi.AccessPoint.", linker, value);
if (!(*value) || (*value)[0] == 0)
if (!(*value) || (*value)[0] == 0) {
struct uci_section *s = get_dup_section_in_config_opt("wireless", "wifi-iface", "ifname", linker);
dmuci_get_value_by_section_string(s, "device", &linker);
adm_entry_get_linker_param(ctx, "Device.WiFi.Radio.", linker, value);
}
return 0;
}
@ -1021,7 +1133,9 @@ static int get_IEEE1905ALNetworkTopology_LastChange(char *refparam, struct dmctx
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905DeviceNumberOfEntries!UBUS:ieee1905/info//topology.num_device*/
static int get_IEEE1905ALNetworkTopology_IEEE1905DeviceNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ubus_ieee1905_info_options("topology", "num_device", value);
int cnt = get_number_of_entries(ctx, data, instance, browseIEEE1905ALNetworkTopologyIEEE1905DeviceInst);
dmasprintf(value, "%d", cnt);
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.ChangeLogNumberOfEntries!UBUS:ieee1905/info//topology.num_changelog*/
@ -1128,28 +1242,32 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905Device_AssocWiFiNetworkDeviceRef
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.VendorPropertiesNumberOfEntries!UBUS:ieee1905/info//topology.device[@i-1].num_vendor_properties*/
static int get_IEEE1905ALNetworkTopologyIEEE1905Device_VendorPropertiesNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "num_vendor_properties");
int cnt = get_number_of_entries(ctx, data, instance, browseIEEE1905ALNetworkTopologyIEEE1905DeviceVendorPropertiesInst);
dmasprintf(value, "%d", cnt);
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IPv4AddressNumberOfEntries!UBUS:ieee1905/info//topology.device[@i-1].num_ipv4*/
static int get_IEEE1905ALNetworkTopologyIEEE1905Device_IPv4AddressNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "num_ipv4");
int cnt = get_number_of_entries(ctx, data, instance, browseIEEE1905ALNetworkTopologyIEEE1905DeviceIPv4AddressInst);
dmasprintf(value, "%d", cnt);
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IPv6AddressNumberOfEntries!UBUS:ieee1905/info//topology.device[@i-1].num_ipv6*/
static int get_IEEE1905ALNetworkTopologyIEEE1905Device_IPv6AddressNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "num_ipv6");
int cnt = get_number_of_entries(ctx, data, instance, browseIEEE1905ALNetworkTopologyIEEE1905DeviceIPv6AddressInst);
dmasprintf(value, "%d", cnt);
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.InterfaceNumberOfEntries!UBUS:ieee1905/info//topology.device[@i-1].num_interface*/
static int get_IEEE1905ALNetworkTopologyIEEE1905Device_InterfaceNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "num_interface");
int cnt = get_number_of_entries(ctx, data, instance, browseIEEE1905ALNetworkTopologyIEEE1905DeviceInterfaceInst);
dmasprintf(value, "%d", cnt);
return 0;
}
@ -1164,7 +1282,8 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905Device_NonIEEE1905NeighborNumber
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905NeighborNumberOfEntries!UBUS:ieee1905/info//topology.device[@i-1].num_neighbor_1905*/
static int get_IEEE1905ALNetworkTopologyIEEE1905Device_IEEE1905NeighborNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "num_neighbor_1905");
int cnt = get_number_of_entries(ctx, data, instance, browseIEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborInst);
dmasprintf(value, "%d", cnt);
return 0;
}
@ -1185,56 +1304,56 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905Device_BridgingTupleNumberOfEntr
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IPv4Address.{i}.MACAddress!UBUS:ieee1905/info//topology.device[@i-1].ipv4_address[@i-1].macaddress*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv4Address_MACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "macaddress");
*value = ((struct ieee1905_device_args *)data)->mac_addr;
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IPv4Address.{i}.IPv4Address!UBUS:ieee1905/info//topology.device[@i-1].ipv4_address[@i-1].ip*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv4Address_IPv4Address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "ip");
*value = dmjson_get_value(((struct ieee1905_device_args *)data)->dev_obj, 1, "ip");
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IPv4Address.{i}.IPv4AddressType!UBUS:ieee1905/info//topology.device[@i-1].ipv4_address[@i-1].type*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv4Address_IPv4AddressType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "type");
*value = dmjson_get_value(((struct ieee1905_device_args *)data)->dev_obj, 1, "type");
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IPv4Address.{i}.DHCPServer!UBUS:ieee1905/info//topology.device[@i-1].ipv4_address[@i-1].dhcpserver*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv4Address_DHCPServer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "dhcpserver");
*value = dmjson_get_value(((struct ieee1905_device_args *)data)->dev_obj, 1, "dhcpserver");
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IPv6Address.{i}.MACAddress!UBUS:ieee1905/info//topology.device[@i-1].ipv6_address[@i-1].macaddress*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv6Address_MACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "macaddress");
*value = ((struct ieee1905_device_args *)data)->mac_addr;
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IPv6Address.{i}.IPv6Address!UBUS:ieee1905/info//topology.device[@i-1].ipv6_address[@i-1].ip*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv6Address_IPv6Address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "ip");
*value = dmjson_get_value(((struct ieee1905_device_args *)data)->dev_obj, 1, "ip");
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IPv6Address.{i}.IPv6AddressType!UBUS:ieee1905/info//topology.device[@i-1].ipv6_address[@i-1].type*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv6Address_IPv6AddressType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "type");
*value = dmjson_get_value(((struct ieee1905_device_args *)data)->dev_obj, 1, "type");
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IPv6Address.{i}.IPv6AddressOrigin!UBUS:ieee1905/info//topology.device[@i-1].ipv6_address[@i-1].dhcpserver*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv6Address_IPv6AddressOrigin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "dhcpserver");
*value = dmjson_get_value(((struct ieee1905_device_args *)data)->dev_obj, 1, "dhcpserver");
return 0;
}
#if 0
@ -1429,7 +1548,7 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceL2Neighbor_BehindInterface
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905Neighbor.{i}.LocalInterface!UBUS:ieee1905/info//topology.device[@i-1].ieee1905_neighbors[@i-1].macaddress*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905Neighbor_LocalInterface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *linker = dmjson_get_value((json_object *)data, 1, "macaddress");
char *linker = ((struct ieee1905_device_ieee1905neighbor_args *)data)->mac_addr;
adm_entry_get_linker_param(ctx, "Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.", linker, value);
return 0;
}
@ -1437,84 +1556,84 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905Neighbor_LocalInte
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905Neighbor.{i}.NeighborDeviceId!UBUS:ieee1905/info//topology.device[@i-1].ieee1905_neighbors[@i-1].neighbor_device_id*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905Neighbor_NeighborDeviceId(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "neighbor_device_id");
*value = ((struct ieee1905_device_ieee1905neighbor_args *)data)->neighbor_device_id;
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905Neighbor.{i}.MetricNumberOfEntries!UBUS:ieee1905/info//topology.device[@i-1].ieee1905_neighbors[@i-1].num_metrics*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905Neighbor_MetricNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "num_metrics");
*value = ((struct ieee1905_device_ieee1905neighbor_args *)data)->num_metrics;
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905Neighbor.{i}.Metric.{i}.NeighborMACAddress!UBUS:ieee1905/info//topology.device[@i-1].ieee1905_neighbors[@i-1].metric[@i-1].neighbor_macaddress*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_NeighborMACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "neighbor_macaddress");
*value = ((struct ieee1905_device_ieee1905neighbor_args *)data)->neighbor_macaddress;
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905Neighbor.{i}.Metric.{i}.IEEE802dot1Bridge!UBUS:ieee1905/info//topology.device[@i-1].ieee1905_neighbors[@i-1].metric[@i-1].has_bridge*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_IEEE802dot1Bridge(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "has_bridge");
*value = dmjson_get_value(((struct ieee1905_device_ieee1905neighbor_args *)data)->dev_obj, 2, "metric", "has_bridge");
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905Neighbor.{i}.Metric.{i}.PacketErrors!UBUS:ieee1905/info//topology.device[@i-1].ieee1905_neighbors[@i-1].metric[@i-1].tx_errors*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_PacketErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "tx_errors");
*value = dmjson_get_value(((struct ieee1905_device_ieee1905neighbor_args *)data)->dev_obj, 2, "metric", "tx_errors");
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905Neighbor.{i}.Metric.{i}.PacketErrorsReceived!UBUS:ieee1905/info//topology.device[@i-1].ieee1905_neighbors[@i-1].metric[@i-1].rx_errors*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_PacketErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "rx_errors");
*value = dmjson_get_value(((struct ieee1905_device_ieee1905neighbor_args *)data)->dev_obj, 2, "metric", "rx_errors");
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905Neighbor.{i}.Metric.{i}.TransmittedPackets!UBUS:ieee1905/info//topology.device[@i-1].ieee1905_neighbors[@i-1].metric[@i-1].tx_packets*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_TransmittedPackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "tx_packets");
*value = dmjson_get_value(((struct ieee1905_device_ieee1905neighbor_args *)data)->dev_obj, 2, "metric", "tx_packets");
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905Neighbor.{i}.Metric.{i}.PacketsReceived!UBUS:ieee1905/info//topology.device[@i-1].ieee1905_neighbors[@i-1].metric[@i-1].rx_packets*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "rx_packets");
*value = dmjson_get_value(((struct ieee1905_device_ieee1905neighbor_args *)data)->dev_obj, 2, "metric", "rx_packets");
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905Neighbor.{i}.Metric.{i}.MACThroughputCapacity!UBUS:ieee1905/info//topology.device[@i-1].ieee1905_neighbors[@i-1].metric[@i-1].max_macrate*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_MACThroughputCapacity(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "max_macrate");
*value = dmjson_get_value(((struct ieee1905_device_ieee1905neighbor_args *)data)->dev_obj, 2, "metric", "max_macrate");
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905Neighbor.{i}.Metric.{i}.LinkAvailability!UBUS:ieee1905/info//topology.device[@i-1].ieee1905_neighbors[@i-1].metric[@i-1].link_available*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_LinkAvailability(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "link_available");
*value = dmjson_get_value(((struct ieee1905_device_ieee1905neighbor_args *)data)->dev_obj, 2, "metric", "link_available");
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905Neighbor.{i}.Metric.{i}.PHYRate!UBUS:ieee1905/info//topology.device[@i-1].ieee1905_neighbors[@i-1].metric[@i-1].max_phyrate*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_PHYRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "max_phyrate");
*value = dmjson_get_value(((struct ieee1905_device_ieee1905neighbor_args *)data)->dev_obj, 2, "metric", "max_phyrate");
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905Neighbor.{i}.Metric.{i}.RSSI!UBUS:ieee1905/info//topology.device[@i-1].ieee1905_neighbors[@i-1].metric[@i-1].rssi*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_RSSI(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "rssi");
*value = dmjson_get_value(((struct ieee1905_device_ieee1905neighbor_args *)data)->dev_obj, 2, "metric", "rssi");
return 0;
}

View file

@ -2,6 +2,10 @@
"version": "1905.1a",
"ieee1905id": "62:8d:26:c4:96:f7",
"status": "enabled",
"name": "1905Device",
"manufacturer": "IOPSYS",
"model": "1905-SampleDev",
"url": "",
"registrar": true,
"registrar_band": [
"5GHz",
@ -20,6 +24,22 @@
"num_vendor_properties": 0,
"properties": [
],
"num_ipv4": 1,
"ipv4_address": [
{
"ip": "192.168.7.89",
"type": "Unknown",
"dhcpserver": "0.0.0.0"
}
],
"num_ipv6": 0,
"ipv6_address": [
],
"num_neighbor_non1905": 0,
"non1905_neighbors": [
],
"num_links": 0,
"links": [
@ -38,6 +58,19 @@
"num_vendor_properties": 0,
"properties": [
],
"num_ipv4": 0,
"ipv4_address": [
],
"num_ipv6": 0,
"ipv6_address": [
],
"num_neighbor_non1905": 2,
"non1905_neighbors": [
"6c:24:08:0d:20:66",
"78:24:08:9d:54:78"
],
"num_links": 0,
"links": [
@ -56,6 +89,22 @@
"num_vendor_properties": 0,
"properties": [
],
"num_ipv4": 1,
"ipv4_address": [
{
"ip": "192.168.5.40",
"type": "Unknown",
"dhcpserver": "0.0.0.0"
}
],
"num_ipv6": 0,
"ipv6_address": [
],
"num_neighbor_non1905": 0,
"non1905_neighbors": [
],
"num_links": 0,
"links": [
@ -74,6 +123,18 @@
"num_vendor_properties": 0,
"properties": [
],
"num_ipv4": 0,
"ipv4_address": [
],
"num_ipv6": 0,
"ipv6_address": [
],
"num_neighbor_non1905": 0,
"non1905_neighbors": [
],
"num_links": 0,
"links": [
@ -92,6 +153,22 @@
"num_vendor_properties": 0,
"properties": [
],
"num_ipv4": 0,
"ipv4_address": [
],
"num_ipv6": 1,
"ipv6_address": [
{
"ip": "fe80::ee6c:9aff:fe79:fd7b",
"type": "Unknown",
"dhcpserver": "::"
}
],
"num_neighbor_non1905": 0,
"non1905_neighbors": [
],
"num_links": 0,
"links": [
@ -110,6 +187,22 @@
"num_vendor_properties": 0,
"properties": [
],
"num_ipv4": 0,
"ipv4_address": [
],
"num_ipv6": 1,
"ipv6_address": [
{
"ip": "fe80::ec6c:9aff:fe79:fd7c",
"type": "Unknown",
"dhcpserver": "::"
}
],
"num_neighbor_non1905": 0,
"non1905_neighbors": [
],
"num_links": 0,
"links": [
@ -128,6 +221,22 @@
"num_vendor_properties": 0,
"properties": [
],
"num_ipv4": 0,
"ipv4_address": [
],
"num_ipv6": 1,
"ipv6_address": [
{
"ip": "fe80::ee6c:9aff:fe79:fd7c",
"type": "Unknown",
"dhcpserver": "::"
}
],
"num_neighbor_non1905": 0,
"non1905_neighbors": [
],
"num_links": 0,
"links": [
@ -146,6 +255,22 @@
"num_vendor_properties": 0,
"properties": [
],
"num_ipv4": 0,
"ipv4_address": [
],
"num_ipv6": 1,
"ipv6_address": [
{
"ip": "fe80::f06c:9aff:fe79:fd7d",
"type": "Unknown",
"dhcpserver": "::"
}
],
"num_neighbor_non1905": 0,
"non1905_neighbors": [
],
"num_links": 0,
"links": [
@ -164,6 +289,18 @@
"num_vendor_properties": 0,
"properties": [
],
"num_ipv4": 0,
"ipv4_address": [
],
"num_ipv6": 0,
"ipv6_address": [
],
"num_neighbor_non1905": 0,
"non1905_neighbors": [
],
"num_links": 1,
"links": [{
@ -175,12 +312,12 @@
"genphy_url": "",
"metric": {
"has_bridge": true,
"tx_errors": 0,
"rx_errors": 0,
"tx_errors": 7,
"rx_errors": 8,
"tx_packets": 902711,
"rx_packets": 0,
"max_macrate": 0,
"max_phyrate": 0,
"rx_packets": 7,
"max_macrate": 4,
"max_phyrate": 12,
"rssi": 255
}
}]
@ -197,6 +334,18 @@
"num_vendor_properties": 0,
"properties": [
],
"num_ipv4": 0,
"ipv4_address": [
],
"num_ipv6": 0,
"ipv6_address": [
],
"num_neighbor_non1905": 0,
"non1905_neighbors": [
],
"num_links": 1,
"links": [{
@ -208,17 +357,27 @@
"genphy_url": "",
"metric": {
"has_bridge": true,
"tx_errors": 0,
"rx_errors": 0,
"tx_errors": 1,
"rx_errors": 2,
"tx_packets": 37840,
"rx_packets": 0,
"max_macrate": 0,
"max_phyrate": 0,
"rssi": 255
"rx_packets": 4,
"max_macrate": 7,
"max_phyrate": 9,
"rssi": 254
}
}]
}
],
"bridge_tuples": [
{
"tuple": [
"60:8d:26:c4:96:f8",
"e2:8d:26:c4:96:f9",
"60:8d:26:c4:96:f7",
"60:8d:26:c4:96:f8"
]
}
],
"topology": {
"enabled": false,
"status": "available",