bbf: add support for the new IGMP vendor extension

This commit caters to support for IGMP.Snooping and IGMP.Proxy objects except
for reading statistics in the form of Snooping.ClientGroup and Proxy.ClientGroup
objects.

ToDo:
1. Implement enable parameter for filter.

This is what it looks like btw:
root@iopsys:~# cat /etc/config/mcast

config snooping 'msnoop_1'
	option enable '0'
	option proto 'igmp'
	option version '2'
	option robustness '2'
	option aggregation '0'
	list filter '2.2.2.2'
	list filter '2.2.2.1'
	option interface 'br-wan'

config proxy 'mproxy_1'
	option enable '0'
	option proto 'igmp'
	option version '2'
	option robustness '2'
	option aggregation '0'
	list filter '1.1.1.1'
	list filter '1.1.1.2'
	list snooping_interface 'br-wan'
	list proxy_interface 'wan'

and the output of usp get is:
root@iopsys:~# ubus call usp get '{"path":"Device.X_IOPSYS_EU_IGMP."}'
{
	"X_IOPSYS_EU_IGMP": {
		"Proxy": [
			{
				"Aggregation": false,
				"Enable": false,
				"Filter": [
					{
						"Enable": false,
						"IPAddress": "1.1.1.1"
					},
					{
						"Enable": false,
						"IPAddress": "1.1.1.2"
					}
				],
				"FilterNumberOfEntries": 2,
				"ImmediateLeave": false,
				"Interface": [
					{
						"Interface": "Device.IP.Interface.1.",
						"Upstream": false
					},
					{
						"Interface": "Device.Bridging.Bridge.1.Port.1.",
						"Upstream": false
					}
				],
				"InterfaceNumberOfEntries": 2,
				"LastMemberQueryInterval": 0,
				"QueryInterval": 0,
				"QueryResponseInterval": 0,
				"Robustness": 2,
				"Version": "V2"
			}
		],
		"ProxyNumberOfEntries": 1,
		"Snooping": [
			{
				"Aggregation": false,
				"Enable": false,
				"Filter": [
					{
						"Enable": false,
						"IPAddress": "2.2.2.2"
					},
					{
						"Enable": false,
						"IPAddress": "2.2.2.1"
					}
				],
				"FilterNumberOfEntries": 2,
				"Interface": "Device.Bridging.Bridge.1.Port.1.",
				"Robustness": 2,
				"Version": "V2"
			}
		],
		"SnoopingNumberOfEntries": 1
	}

All objects/parameters were set using usp so we know that works.
This commit is contained in:
Rahul 2020-04-08 15:49:34 +05:30
parent 073d2693f4
commit 1b16a14089
7 changed files with 1826 additions and 0 deletions

View file

@ -51,6 +51,7 @@ libbbfdm_la_SOURCES += \
../dmtree/tr181/managementserver.c \
../dmtree/tr181/times.c \
../dmtree/tr181/upnp.c \
../dmtree/tr181/x_iopsys_eu_igmp.c \
../dmtree/tr181/x_iopsys_eu_syslog.c \
../dmtree/tr181/x_iopsys_eu_dropbear.c \
../dmtree/tr181/x_iopsys_eu_owsd.c \

View file

@ -14,6 +14,7 @@
#include "managementserver.h"
#include "times.h"
#include "upnp.h"
#include "x_iopsys_eu_igmp.h"
#include "x_iopsys_eu_syslog.h"
#include "softwaremodules.h"
#include "xmpp.h"
@ -91,6 +92,7 @@ DMOBJ tRoot181ObjUPNPBBF[] = {
{"VoiceService", &DMREAD, NULL, NULL, NULL, browseVoiceServiceInst, NULL, NULL, tServicesVoiceServiceObj, tServicesVoiceServiceParams, NULL, BBFDM_BOTH},
#endif
{CUSTOM_PREFIX"Syslog", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_SyslogParam, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"IGMP", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE, NULL, X_IOPSYS_EU_IGMPObj, X_IOPSYS_EU_IGMPParams, NULL, BBFDM_BOTH},
{"SoftwareModules", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,tSoftwareModulesObj, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"OWSD", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,X_IOPSYS_EU_OWSDObj, X_IOPSYS_EU_OWSDParams, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"Dropbear", &DMWRITE, add_dropbear_instance, delete_dropbear_instance, NULL, browseXIopsysEuDropbear, NULL, &DMNONE, NULL, X_IOPSYS_EU_DropbearParams, NULL, BBFDM_BOTH},

View file

@ -15,6 +15,7 @@
#include "managementserver.h"
#include "times.h"
#include "upnp.h"
#include "x_iopsys_eu_igmp.h"
#include "x_iopsys_eu_syslog.h"
#include "xmpp.h"
#include "x_iopsys_eu_owsd.h"
@ -78,6 +79,7 @@ DMOBJ tRoot_181_Obj[] = {
#endif
{CUSTOM_PREFIX"Syslog", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE, NULL, NULL, tSe_SyslogParam, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"OWSD", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE, NULL, X_IOPSYS_EU_OWSDObj, X_IOPSYS_EU_OWSDParams, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"IGMP", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE, NULL, X_IOPSYS_EU_IGMPObj, X_IOPSYS_EU_IGMPParams, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"Dropbear", &DMWRITE, add_dropbear_instance, delete_dropbear_instance, NULL, browseXIopsysEuDropbear, NULL, &DMNONE, NULL, NULL, X_IOPSYS_EU_DropbearParams, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"Buttons", &DMREAD, NULL, NULL, NULL, browseXIopsysEuButton, NULL, &DMNONE, NULL, NULL, X_IOPSYS_EU_ButtonParams, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"WiFiLife", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE, NULL, X_IOPSYS_EU_WiFiLifeObj, X_IOPSYS_EU_WiFiLifeParams, NULL, BBFDM_BOTH},

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,36 @@
/*
* 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 Rahul Thakur <rahul.thakur@iopsys.eu>
*
*/
#ifndef __SE_IGMP_H
#define __SE_IGMP_H
#include <libbbf_api/dmcommon.h>
extern DMOBJ X_IOPSYS_EU_IGMPObj[];
extern DMLEAF X_IOPSYS_EU_IGMPParams[];
extern DMOBJ X_IOPSYS_EU_IGMPSnoopingObj[];
extern DMLEAF X_IOPSYS_EU_IGMPSnoopingParams[];
extern DMOBJ IGMPSnoopingCLientGroupObj[];
extern DMLEAF IGMPSnoopingClientGroupParams[];
extern DMLEAF IGMPSnoopingClientGroupStatsParams[];
extern DMLEAF IGMPSnoopingClientGroupAssociatedDeviceParams[];
extern DMLEAF IGMPSnoopingFilterParams[];
extern DMOBJ X_IOPSYS_EU_IGMPProxyObj[];
extern DMLEAF X_IOPSYS_EU_IGMPProxyParams[];
extern DMLEAF IGMPProxyInterfaceParams[];
extern DMOBJ IGMPProxyCLientGroupObj[];
extern DMLEAF IGMPProxyClientGroupParams[];
extern DMLEAF IGMPProxyClientGroupStatsParams[];
extern DMLEAF IGMPProxyClientGroupAssociatedDeviceParams[];
extern DMLEAF IGMPProxyFilterParams[];
#endif

View file

@ -778,6 +778,175 @@ struct uci_section *get_dup_section_in_dmmap_eq(char *dmmap_package, char* secti
return NULL;
}
void synchronize_specific_config_sections_with_dmmap_mcast_iface(char *package, char *section_type,
void *data, char *dmmap_package, char *dmmap_sec, char *proto,
struct list_head *dup_list)
{
struct uci_section *s, *dmmap_sect, *d_sec, *stmp;
char *v;
char *s_name;
dmmap_file_path_get(dmmap_package);
uci_foreach_sections(package, section_type, s) {
if (strcmp(section_name(s), section_name((struct uci_section *)data)) != 0)
continue;
// The list snooping_interface and proxy_interface in the uci file corresponds to the
// proxy_interface section in the dmmap. First, read the list of proxy interfaces
// and update the dmmap section accordingly. The do the same exercise for the list
// snooping_interface
struct uci_list *proxy_iface = NULL;
dmuci_get_value_by_section_list(s, "proxy_interface", &proxy_iface);
if (proxy_iface != NULL) {
struct uci_element *e;
uci_foreach_element(proxy_iface, e) {
char *p_ifname = strdup(e->name);
int found = 0;
uci_path_foreach_option_eq(bbfdm, dmmap_package, dmmap_sec, "ifname",
p_ifname, d_sec) {
dmuci_get_value_by_section_string(d_sec, "section_name", &s_name);
if (strcmp(s_name, section_name(s)) == 0) {
add_sectons_list_paramameter(dup_list, s, d_sec, NULL);
found = 1;
break;
}
}
if (found == 0) {
// add entry in dmmap for this
dmuci_add_section_bbfdm(dmmap_package, dmmap_sec, &d_sec, &v);
DMUCI_SET_VALUE_BY_SECTION(bbfdm, d_sec, "section_name",
section_name(s));
DMUCI_SET_VALUE_BY_SECTION(bbfdm, d_sec, "ifname",
p_ifname);
DMUCI_SET_VALUE_BY_SECTION(bbfdm, d_sec, "upstream",
"1");
add_sectons_list_paramameter(dup_list, s, d_sec, NULL);
}
}
}
struct uci_list *snooping_iface = NULL;
dmuci_get_value_by_section_list(s, "snooping_interface", &snooping_iface);
if (snooping_iface != NULL) {
struct uci_element *e;
uci_foreach_element(snooping_iface, e) {
char *s_ifname = strdup(e->name);
int found = 0;
uci_path_foreach_option_eq(bbfdm, dmmap_package, dmmap_sec, "ifname",
s_ifname, d_sec) {
dmuci_get_value_by_section_string(d_sec, "section_name", &s_name);
if (strcmp(s_name, section_name(s)) == 0) {
add_sectons_list_paramameter(dup_list, s, d_sec, NULL);
found = 1;
break;
}
}
if (found == 0) {
// add entry in dmmap for this
dmuci_add_section_bbfdm(dmmap_package, dmmap_sec, &d_sec, &v);
DMUCI_SET_VALUE_BY_SECTION(bbfdm, d_sec, "section_name",
section_name(s));
DMUCI_SET_VALUE_BY_SECTION(bbfdm, d_sec, "ifname",
s_ifname);
DMUCI_SET_VALUE_BY_SECTION(bbfdm, d_sec, "upstream",
"0");
add_sectons_list_paramameter(dup_list, s, d_sec, NULL);
}
}
}
char *f_ifname;
// There can be entries in the dmmap_mcast file that do not have an ifname set.
// For such entries, now add to dup_list
uci_path_foreach_option_eq(bbfdm, dmmap_package, dmmap_sec, "section_name",
section_name(s), dmmap_sect) {
dmuci_get_value_by_section_string(dmmap_sect, "ifname", &f_ifname);
if (strcmp(f_ifname, "") == 0)
add_sectons_list_paramameter(dup_list, s, dmmap_sect, NULL);
}
}
/*
* Delete unused dmmap sections
*/
uci_path_foreach_sections_safe(bbfdm, dmmap_package, dmmap_sec, stmp, s) {
dmuci_get_value_by_section_string(s, "section_name", &v);
if (get_origin_section_from_config(package, section_type, v) == NULL)
dmuci_delete_by_section_unnamed_bbfdm(s, NULL, NULL);
}
}
void synchronize_specific_config_sections_with_dmmap_filter(char *package, char *section_type, void *data,
char *dmmap_package, char *dmmap_sec, char *proto,
struct list_head *dup_list)
{
struct uci_section *s, *dmmap_sect, *d_sec, *stmp;
char *v;
char *s_name;
dmmap_file_path_get(dmmap_package);
uci_foreach_sections(package, section_type, s) {
if (strcmp(section_name(s), section_name((struct uci_section *)data)) != 0)
continue;
/*
* create/update corresponding dmmap section that have same config_section link and using param_value_array
*/
struct uci_list *l = NULL;
dmuci_get_value_by_section_list(s, "filter", &l);
if (l != NULL) {
struct uci_element *e;
uci_foreach_element(l, e) {
char *ip_addr = strdup(e->name);
int found = 0;
uci_path_foreach_option_eq(bbfdm, dmmap_package, dmmap_sec, "ipaddr",
ip_addr, d_sec) {
dmuci_get_value_by_section_string(d_sec, "section_name", &s_name);
if (strcmp(s_name, section_name(s)) == 0) {
add_sectons_list_paramameter(dup_list, s, d_sec, NULL);
found = 1;
break;
}
}
if (found == 0) {
// add entry in dmmap for this
dmuci_add_section_bbfdm(dmmap_package, dmmap_sec, &d_sec, &v);
DMUCI_SET_VALUE_BY_SECTION(bbfdm, d_sec, "section_name",
section_name(s));
DMUCI_SET_VALUE_BY_SECTION(bbfdm, d_sec, "ipaddr",
ip_addr);
add_sectons_list_paramameter(dup_list, s, d_sec, NULL);
}
}
}
char *f_ip;
// There can be entries in the dmmap_mcast file that do not have an IP address set.
// For such entries, now add to dup_list
uci_path_foreach_option_eq(bbfdm, dmmap_package, dmmap_sec, "section_name",
section_name(s), dmmap_sect) {
dmuci_get_value_by_section_string(dmmap_sect, "ipaddr", &f_ip);
if (strcmp(f_ip, "") == 0)
add_sectons_list_paramameter(dup_list, s, dmmap_sect, NULL);
}
}
/*
* Delete unused dmmap sections
*/
uci_path_foreach_sections_safe(bbfdm, dmmap_package, dmmap_sec, stmp, s) {
dmuci_get_value_by_section_string(s, "section_name", &v);
if (get_origin_section_from_config(package, section_type, v) == NULL)
dmuci_delete_by_section_unnamed_bbfdm(s, NULL, NULL);
}
}
void synchronize_specific_config_sections_with_dmmap(char *package, char *section_type, char *dmmap_package, struct list_head *dup_list)
{
struct uci_section *s, *stmp, *dmmap_sect;

View file

@ -270,6 +270,12 @@ int dmcommon_check_notification_value(char *value);
void hex_to_ip(char *address, char *ret);
void ip_to_hex(char *address, char *ret);
void free_dmmap_config_dup_list(struct list_head *dup_list);
void synchronize_specific_config_sections_with_dmmap_filter(char *package, char *section_type,
void *data, char *dmmap_package, char *dmmap_sec,
char *proto, struct list_head *dup_list);
void synchronize_specific_config_sections_with_dmmap_mcast_iface(char *package, char *section_type,
void *data, char *dmmap_package, char *dmmap_sec, char *proto,
struct list_head *dup_list);
void synchronize_specific_config_sections_with_dmmap(char *package, char *section_type, char *dmmap_package, struct list_head *dup_list);
void synchronize_multi_config_sections_with_dmmap_set(char *package, char *section_type, char *dmmap_package, char* dmmap_section, char* option_name, char* option_value, char *instance, char *br_key);
void synchronize_specific_config_sections_with_dmmap_eq(char *package, char *section_type, char *dmmap_package,char* option_name, char* option_value, struct list_head *dup_list);