Ticket refs #2539: TR-181: Device.Hosts.Host.{i}.WANStats.

This commit is contained in:
Amin Ben Ramdhane 2020-06-08 12:43:16 +01:00
parent d71af3a2a0
commit cd31a6ca60
5 changed files with 92 additions and 4 deletions

View file

@ -270,3 +270,31 @@ int os__get_HostsHostIPv6Address_IPAddress(char *refparam, struct dmctx *ctx, vo
*value = (char *)data;
return 0;
}
/*#Device.Hosts.Host.{i}.WANStats.BytesSent!UBUS:router.network/hosts//hosts[@i-1].stats.tx_bytes*/
int os__get_HostsHostWANStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 2, "stats", "tx_bytes");
return 0;
}
/*#Device.Hosts.Host.{i}.WANStats.BytesReceived!UBUS:router.network/hosts//hosts[@i-1].stats.rx_bytes*/
int os__get_HostsHostWANStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 2, "stats", "rx_bytes");
return 0;
}
/*#Device.Hosts.Host.{i}.WANStats.PacketsSent!UBUS:router.network/hosts//hosts[@i-1].stats.tx_packets*/
int os__get_HostsHostWANStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 2, "stats", "tx_packets");
return 0;
}
/*#Device.Hosts.Host.{i}.WANStats.PacketsReceived!UBUS:router.network/hosts//hosts[@i-1].stats.rx_packets*/
int os__get_HostsHostWANStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 2, "stats", "rx_packets");
return 0;
}

View file

@ -29,6 +29,7 @@ DMOBJ tHostsHostObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextdynamicobj, nextobj, leaf, linker, bbfdm_type*/
{"IPv4Address", &DMREAD, NULL, NULL, NULL, os__browseHostsHostIPv4AddressInst, NULL, NULL, NULL, NULL, tHostsHostIPv4AddressParams, NULL, BBFDM_BOTH},
{"IPv6Address", &DMREAD, NULL, NULL, NULL, os__browseHostsHostIPv6AddressInst, NULL, NULL, NULL, NULL, tHostsHostIPv6AddressParams, NULL, BBFDM_BOTH},
{"WANStats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tHostsHostWANStatsParams, NULL, BBFDM_BOTH},
{0}
};
@ -67,3 +68,13 @@ DMLEAF tHostsHostIPv6AddressParams[] = {
{"IPAddress", &DMREAD, DMT_STRING, os__get_HostsHostIPv6Address_IPAddress, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.Hosts.Host.{i}.WANStats. *** */
DMLEAF tHostsHostWANStatsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"BytesSent", &DMREAD, DMT_UNINT, os__get_HostsHostWANStats_BytesSent, NULL, NULL, NULL, BBFDM_BOTH},
{"BytesReceived", &DMREAD, DMT_UNINT, os__get_HostsHostWANStats_BytesReceived, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsSent", &DMREAD, DMT_UNINT, os__get_HostsHostWANStats_PacketsSent, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNINT, os__get_HostsHostWANStats_PacketsReceived, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};

View file

@ -19,5 +19,6 @@ extern DMOBJ tHostsHostObj[];
extern DMLEAF tHostsHostParams[];
extern DMLEAF tHostsHostIPv4AddressParams[];
extern DMLEAF tHostsHostIPv6AddressParams[];
extern DMLEAF tHostsHostWANStatsParams[];
#endif //__HOSTS_H

View file

@ -56,6 +56,10 @@ int os__get_HostsHost_IPv4AddressNumberOfEntries(char *refparam, struct dmctx *c
int os__get_HostsHost_IPv6AddressNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_HostsHostIPv4Address_IPAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_HostsHostIPv6Address_IPAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_HostsHostWANStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_HostsHostWANStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_HostsHostWANStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_HostsHostWANStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
#include "wifi.h"

View file

@ -53010,7 +53010,18 @@
"cwmp",
"usp"
],
"datatype": "StatsCounter64"
"datatype": "StatsCounter64",
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "router.network",
"method": "hosts",
"args": {},
"key": "hosts[@i-1].stats.tx_bytes"
}
}
]
},
"BytesReceived": {
"type": "unsignedInt",
@ -53020,7 +53031,18 @@
"cwmp",
"usp"
],
"datatype": "StatsCounter64"
"datatype": "StatsCounter64",
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "router.network",
"method": "hosts",
"args": {},
"key": "hosts[@i-1].stats.rx_bytes"
}
}
]
},
"PacketsSent": {
"type": "unsignedInt",
@ -53030,7 +53052,18 @@
"cwmp",
"usp"
],
"datatype": "StatsCounter64"
"datatype": "StatsCounter64",
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "router.network",
"method": "hosts",
"args": {},
"key": "hosts[@i-1].stats.tx_packets"
}
}
]
},
"PacketsReceived": {
"type": "unsignedInt",
@ -53040,7 +53073,18 @@
"cwmp",
"usp"
],
"datatype": "StatsCounter64"
"datatype": "StatsCounter64",
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "router.network",
"method": "hosts",
"args": {},
"key": "hosts[@i-1].stats.rx_packets"
}
}
]
},
"ErrorsSent": {
"type": "unsignedInt",