mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
igmp: Added function definition to get igmp snooping and proxy stats through bbf.
The main changes are in x_iopsys_eu_igmp.c file. Changes in other file is only to get reference to Device.Hosts.Host object for associated device host IP (linker function)
This commit is contained in:
parent
57ae1244cc
commit
32838bd17a
5 changed files with 170 additions and 15 deletions
|
|
@ -62,6 +62,15 @@ int os__browseHostsHostIPv6AddressInst(struct dmctx *dmctx, DMNODE *parent_node,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
* LINKER
|
||||
**************************************************************/
|
||||
int get_linker_host(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
|
||||
{
|
||||
*linker = dmjson_get_value((json_object *)data, 1, "ipaddr");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
* GET & SET PARAM
|
||||
**************************************************************/
|
||||
|
|
|
|||
|
|
@ -24,6 +24,14 @@ int os__browseHostsHostIPv6AddressInst(struct dmctx *dmctx, DMNODE *parent_node,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
* LINKER
|
||||
**************************************************************/
|
||||
int get_linker_host(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
* GET & SET PARAM
|
||||
**************************************************************/
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
/* *** Device.Hosts. *** */
|
||||
DMOBJ tHostsObj[] = {
|
||||
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextdynamicobj, nextobj, leaf, linker, bbfdm_type*/
|
||||
{"Host", &DMREAD, NULL, NULL, NULL, os__browseHostsHostInst, NULL, NULL, NULL, tHostsHostObj, tHostsHostParams, NULL, BBFDM_BOTH},
|
||||
{"Host", &DMREAD, NULL, NULL, NULL, os__browseHostsHostInst, NULL, NULL, NULL, tHostsHostObj, tHostsHostParams, get_linker_host, BBFDM_BOTH},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ int os__browseProcessEntriesInst(struct dmctx *dmctx, DMNODE *parent_node, void
|
|||
int os__browseHostsHostInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
|
||||
int os__browseHostsHostIPv4AddressInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
|
||||
int os__browseHostsHostIPv6AddressInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
|
||||
int get_linker_host(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
|
||||
int os__get_Hosts_HostNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int os__get_HostsHost_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int os__set_HostsHost_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
|
|
|
|||
|
|
@ -218,17 +218,41 @@ static int get_igmpp_no_of_entries(char *refparam, struct dmctx *ctx, void *data
|
|||
|
||||
static int browse_igmps_cgrp_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
//ToDo
|
||||
//perform ubus call to mcast stats and browse through each igmp group json object
|
||||
int i = 0, id = 0;
|
||||
json_object *res = NULL, *jobj = NULL, *arrobj = NULL, *group_obj = NULL;
|
||||
char *idx, *idx_last = NULL;
|
||||
|
||||
dmubus_call("mcast", "stats", UBUS_ARGS{}, 0, &res);
|
||||
if (res) {
|
||||
jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "snooping");
|
||||
dmjson_foreach_obj_in_array(jobj, arrobj, group_obj, i, 1, "groups") {
|
||||
idx = handle_update_instance(1, dmctx, &idx_last, update_instance_without_section, 1, ++id);
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)group_obj, idx) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int browse_igmpp_cgrp_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
//ToDo
|
||||
//perform ubus call to mcast stats and browse through each igmp group json object
|
||||
int i = 0, id = 0;
|
||||
json_object *res = NULL, *jobj = NULL, *arrobj = NULL, *group_obj = NULL;
|
||||
char *idx, *idx_last = NULL;
|
||||
|
||||
dmubus_call("mcast", "stats", UBUS_ARGS{}, 0, &res);
|
||||
if (res) {
|
||||
jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "snooping");
|
||||
dmjson_foreach_obj_in_array(jobj, arrobj, group_obj, i, 1, "groups") {
|
||||
idx = handle_update_instance(1, dmctx, &idx_last, update_instance_without_section, 1, ++id);
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)group_obj, idx) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int add_igmps_filter_obj(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
|
|
@ -328,6 +352,22 @@ static int get_igmps_filter_no_of_entries(char *refparam, struct dmctx *ctx, voi
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int get_igmps_cgrps_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
int i = 0, cnt = 0;
|
||||
json_object *res = NULL, *jobj = NULL, *arrobj = NULL, *group_obj = NULL;
|
||||
|
||||
dmubus_call("mcast", "stats", UBUS_ARGS{}, 0, &res);
|
||||
if (res) {
|
||||
jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "snooping");
|
||||
dmjson_foreach_obj_in_array(jobj, arrobj, group_obj, i, 1, "groups") {
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
dmasprintf(value, "%d", cnt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_igmps_filter_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct uci_section *f_sec;
|
||||
|
|
@ -973,13 +1013,33 @@ static int set_igmpp_filter_address(char *refparam, struct dmctx *ctx, void *dat
|
|||
|
||||
static int browse_igmps_cgrp_assoc_dev_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
//ToDo
|
||||
//parse and browse through prev_data(it will be json object containing group address and details of its clients)
|
||||
|
||||
int i = 0, id = 0;
|
||||
json_object *arrobj = NULL, *client_jobj = NULL;
|
||||
char *idx, *idx_last = NULL;
|
||||
|
||||
dmjson_foreach_obj_in_array((struct json_object *)prev_data, arrobj, client_jobj, i, 1, "clients") {
|
||||
idx = handle_update_instance(1, dmctx, &idx_last, update_instance_without_section, 1, ++id);
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)client_jobj, idx) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int browse_igmpp_cgrp_assoc_dev_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
//ToDo
|
||||
//parse and browse through prev_data(it will be json object containing group address and details of its clients)
|
||||
|
||||
int i = 0, id = 0;
|
||||
json_object *arrobj = NULL, *client_jobj = NULL;
|
||||
char *idx, *idx_last = NULL;
|
||||
|
||||
dmjson_foreach_obj_in_array((struct json_object *)prev_data, arrobj, client_jobj, i, 1, "clients") {
|
||||
idx = handle_update_instance(1, dmctx, &idx_last, update_instance_without_section, 1, ++id);
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)client_jobj, idx) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -996,37 +1056,93 @@ static int browse_igmpp_cgrp_stats_inst(struct dmctx *dmctx, DMNODE *parent_node
|
|||
}
|
||||
static int get_igmps_cgrp_gaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
//ToDo
|
||||
*value = dmjson_get_value((json_object *)data, 1, "groupaddr");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_igmpp_cgrp_gaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
//ToDo
|
||||
*value = dmjson_get_value((json_object *)data, 1, "groupaddr");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_igmps_cgrp_assoc_dev_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
//ToDo
|
||||
int i = 0, cnt = 0;
|
||||
json_object *arrobj = NULL, *client_obj = NULL;
|
||||
|
||||
dmjson_foreach_obj_in_array((json_object *)data, arrobj, client_obj, i, 1, "clients") {
|
||||
cnt++;
|
||||
}
|
||||
dmasprintf(value, "%d", cnt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_igmpp_cgrp_assoc_dev_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
//ToDo
|
||||
int i = 0, cnt = 0;
|
||||
json_object *arrobj = NULL, *client_obj = NULL;
|
||||
|
||||
dmjson_foreach_obj_in_array((json_object *)data, arrobj, client_obj, i, 1, "clients") {
|
||||
cnt++;
|
||||
}
|
||||
dmasprintf(value, "%d", cnt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_igmps_cgrp_adev_iface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
//ToDo
|
||||
char *ifname;
|
||||
ifname = dmjson_get_value((json_object *)data, 1, "device");
|
||||
|
||||
adm_entry_get_linker_param(ctx, dm_print_path("%s%cEthernet%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), ifname, value);
|
||||
if (*value == NULL)
|
||||
*value = "";
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_igmpp_cgrp_adev_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *ipaddr;
|
||||
ipaddr = dmjson_get_value((json_object *)data, 1, "ipaddr");
|
||||
|
||||
adm_entry_get_linker_param(ctx, dm_print_path("%s%cHosts%cHost%c", dmroot, dm_delim, dm_delim, dm_delim), ipaddr, value);
|
||||
if (*value == NULL)
|
||||
*value = "";
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_igmpp_cgrp_adev_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmjson_get_value((json_object *)data, 1, "timeout");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_igmps_cgrp_adev_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *ipaddr;
|
||||
ipaddr = dmjson_get_value((json_object *)data, 1, "ipaddr");
|
||||
|
||||
adm_entry_get_linker_param(ctx, dm_print_path("%s%cHosts%cHost%c", dmroot, dm_delim, dm_delim, dm_delim), ipaddr, value);
|
||||
if (*value == NULL)
|
||||
*value = "";
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_igmps_cgrp_adev_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmjson_get_value((json_object *)data, 1, "timeout");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_igmpp_cgrp_adev_iface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
//ToDo
|
||||
char *ifname;
|
||||
ifname = dmjson_get_value((json_object *)data, 1, "device");
|
||||
|
||||
adm_entry_get_linker_param(ctx, dm_print_path("%s%cEthernet%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), ifname, value);
|
||||
if (*value == NULL)
|
||||
*value = "";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1317,6 +1433,22 @@ static int set_igmp_proxy_aggregation(char *refparam, struct dmctx *ctx, void *d
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int get_igmpp_cgrps_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
int i = 0, cnt = 0;
|
||||
json_object *res = NULL, *jobj = NULL, *arrobj = NULL, *group_obj = NULL;
|
||||
|
||||
dmubus_call("mcast", "stats", UBUS_ARGS{}, 0, &res);
|
||||
if (res) {
|
||||
jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "snooping");
|
||||
dmjson_foreach_obj_in_array(jobj, arrobj, group_obj, i, 1, "groups") {
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
dmasprintf(value, "%d", cnt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_igmpp_filter_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
|
|
@ -1680,6 +1812,8 @@ DMLEAF IGMPSnoopingFilterParams[] = {
|
|||
|
||||
DMLEAF IGMPSnoopingClientGroupAssociatedDeviceParams[] = {
|
||||
{"Interface", &DMREAD, DMT_STRING, get_igmps_cgrp_adev_iface, NULL, NULL, NULL, BBFDM_BOTH},
|
||||
{"Host", &DMREAD, DMT_STRING, get_igmps_cgrp_adev_host, NULL, NULL, NULL, BBFDM_BOTH},
|
||||
{"Timeout", &DMREAD, DMT_UNINT, get_igmps_cgrp_adev_timeout, NULL, NULL, NULL, BBFDM_BOTH},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
|
@ -1701,13 +1835,13 @@ DMLEAF X_IOPSYS_EU_IGMPSnoopingParams[] = {
|
|||
{"Interface", &DMWRITE, DMT_STRING, get_igmp_snooping_interface, set_igmp_snooping_interface, NULL, NULL, BBFDM_BOTH},
|
||||
{"Mode", &DMWRITE, DMT_STRING, get_igmp_snooping_mode, set_igmp_snooping_mode, NULL, NULL, BBFDM_BOTH},
|
||||
{"FilterNumberOfEntries", &DMREAD, DMT_UNINT, get_igmps_filter_no_of_entries, NULL, NULL, NULL, BBFDM_BOTH},
|
||||
//{"ClientGroupNumberOfEntries", &DMREAD, DMT_UNINT, get_igmpp_cgrps_no_of_entries, NULL, NULL, NULL, BBFDM_BOTH},
|
||||
{"ClientGroupNumberOfEntries", &DMREAD, DMT_UNINT, get_igmps_cgrps_no_of_entries, NULL, NULL, NULL, BBFDM_BOTH},
|
||||
{0}
|
||||
};
|
||||
|
||||
DMOBJ X_IOPSYS_EU_IGMPProxyObj[] = {
|
||||
{"Interface", &DMWRITE, add_igmpp_interface_obj, del_igmpp_interface_obj, NULL, browse_igmpp_interface_inst, NULL, NULL, NULL, NULL, IGMPProxyInterfaceParams, NULL, BBFDM_BOTH},
|
||||
//{"ClientGroup", &DMREAD, NULL, NULL, NULL, browse_igmpp_cgrp_inst, NULL, NULL, NULL, IGMPProxyCLientGroupObj, IGMPProxyClientGroupParams, NULL, BBFDM_BOTH},
|
||||
{"ClientGroup", &DMREAD, NULL, NULL, NULL, browse_igmpp_cgrp_inst, NULL, NULL, NULL, IGMPProxyCLientGroupObj, IGMPProxyClientGroupParams, NULL, BBFDM_BOTH},
|
||||
{"Filter", &DMWRITE, add_igmpp_filter_obj, del_igmpp_filter_obj, NULL, browse_igmpp_filter_inst, NULL, NULL, NULL, NULL, IGMPProxyFilterParams, NULL, BBFDM_BOTH},
|
||||
{0}
|
||||
};
|
||||
|
|
@ -1732,6 +1866,8 @@ DMLEAF IGMPProxyFilterParams[] = {
|
|||
|
||||
DMLEAF IGMPProxyClientGroupAssociatedDeviceParams[] = {
|
||||
{"Interface", &DMREAD, DMT_STRING, get_igmpp_cgrp_adev_iface, NULL, NULL, NULL, BBFDM_BOTH},
|
||||
{"Host", &DMREAD, DMT_STRING, get_igmpp_cgrp_adev_host, NULL, NULL, NULL, BBFDM_BOTH},
|
||||
{"Timeout", &DMREAD, DMT_UNINT, get_igmpp_cgrp_adev_timeout, NULL, NULL, NULL, BBFDM_BOTH},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
|
@ -1761,6 +1897,7 @@ DMLEAF X_IOPSYS_EU_IGMPProxyParams[] = {
|
|||
{"ImmediateLeave", &DMWRITE, DMT_BOOL, get_igmp_proxy_fast_leave, set_igmp_proxy_fast_leave, NULL, NULL, BBFDM_BOTH},
|
||||
{"Robustness", &DMWRITE, DMT_UNINT, get_igmp_proxy_robustness, set_igmp_proxy_robustness, NULL, NULL, BBFDM_BOTH},
|
||||
{"Aggregation", &DMWRITE, DMT_BOOL, get_igmp_proxy_aggregation, set_igmp_proxy_aggregation, NULL, NULL, BBFDM_BOTH},
|
||||
{"ClientGroupNumberOfEntries", &DMREAD, DMT_UNINT, get_igmpp_cgrps_no_of_entries, NULL, NULL, NULL, BBFDM_BOTH},
|
||||
{"FilterNumberOfEntries", &DMREAD, DMT_UNINT, get_igmpp_filter_no_of_entries, NULL, NULL, NULL, BBFDM_BOTH},
|
||||
{"InterfaceNumberOfEntries", &DMREAD, DMT_UNINT, get_igmpp_interface_no_of_entries, NULL, NULL, NULL, BBFDM_BOTH},
|
||||
{0}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue