Compare commits

..

1 Commits

Author SHA1 Message Date
Padmalochan Mohapatra
edd965f1f5 qos : Classification with tc+iptables for QoS on MTK_PANTHER
Description : For the tc classification, qos_postrouting
scheme has been chosen as the target in iptables.
This change set contains code changes for iptables
programming via qos.sh script modification for upstream
traffic classification on WAN port.
2022-12-29 17:47:48 +05:30
202 changed files with 5658 additions and 7045 deletions

View File

@@ -18,10 +18,6 @@ config BBF_TR143
bool "Enable TR-143 Data Model Support"
default y
config BBF_TR471
bool "Enable TR-471 Data Model Support"
default y
config BBFDM_ENABLE_JSON_PLUGIN
bool "Enable json plugin to extend datamodel"
default y

View File

@@ -1,30 +1,31 @@
#
# Copyright (C) 2023 IOPSYS
# Copyright (C) 2022 IOPSYS
#
include $(TOPDIR)/rules.mk
PKG_NAME:=bbfdm
PKG_VERSION:=1.0.4
PKG_NAME:=libbbfdm
PKG_VERSION:=6.8.16
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/bbfdm.git
PKG_SOURCE_VERSION:=96b305926f8fa8cafa0638e613879537da9b6086
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/bbf.git
PKG_SOURCE_VERSION:=0ef6169d86333b8727ed34c63f379b08254340e3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
PKG_LICENSE:=BSD-3-Clause
PKG_RELEASE=$(PKG_SOURCE_VERSION)
PKG_LICENSE:=LGPL-2.1
PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
define Package/libbbfdm-api
define Package/libbbf_api
SECTION:=utils
CATEGORY:=Utilities
SUBMENU:=TRx69
TITLE:=BBF datamodel library, provides API to extend datamodel using DotSO plugins
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c
ABI_VERSION:=1.0
endef
@@ -33,16 +34,13 @@ define Package/libbbfdm/default
CATEGORY:=Utilities
SUBMENU:=TRx69
TITLE:=Library for broadband forum data model support
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libcurl +libbbfdm-api \
+BBF_TR471:obudpst
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libcurl +libbbf_api
endef
define Package/libbbfdm
$(Package/libbbfdm/default)
TITLE += (default)
VARIANT:=default
DEPENDS += +PACKAGE_libbbfdm-openssl:libopenssl
DEFAULT_VARIANT:=1
TITLE += (internal)
VARIANT:=internal
endef
define Package/libbbfdm-mbedtls
@@ -50,33 +48,23 @@ define Package/libbbfdm-mbedtls
TITLE += (mbedtls)
DEPENDS += +PACKAGE_libbbfdm-mbedtls:libmbedtls
VARIANT:=mbedtls
CONFLICTS := libbbfdm libbbfdm-openssl libbbfdm-wolfssl
DEFAULT_VARIANT:=1
endef
define Package/libbbfdm-openssl
$(Package/libbbfdm/default)
TITLE += (openssl)
DEPENDS += +PACKAGE_libbbfdm-openssl:libopenssl
CONFLICTS := libbbfdm-mbedtls
VARIANT:=openssl
CONFLICTS := libbbfdm libbbfdm-mbedtls libbbfdm-wolfssl
endef
define Package/libbbfdm-wolfssl
$(Package/libbbfdm/default)
TITLE += (wolfssl)
DEPENDS += +PACKAGE_libbbfdm-wolfssl:libwolfssl
CONFLICTS := libbbfdm-mbedtls libbbfdm-openssl
VARIANT:=wolfssl
CONFLICTS := libbbfdm libbbfdm-mbedtls libbbfdm-openssl
endef
define Package/bbfdmd
SECTION:=utils
CATEGORY:=Utilities
SUBMENU:=TRx69
TITLE:=Datamodel ubus backend
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libbbfdm-api +PACKAGE_libbbfdm-mbedtls:libbbfdm-mbedtls \
+PACKAGE_libbbfdm-openssl:libbbfdm-openssl +PACKAGE_libbbfdm-wolfssl:libbbfdm-wolfssl \
+PACKAGE_libbbfdm:libbbfdm
endef
define Package/userinterface
@@ -87,14 +75,14 @@ define Package/userinterface
endef
define Package/userinterface/description
Package to add Device.UserInterface. datamodel support
Package to add Device.UserInterface. datamodel support using libbbf JSON Plugin
endef
define Package/libbbfdm/config
source "$(SOURCE)/Config_bbfdm.in"
endef
define Package/libbbfdm-api/description
define Package/libbbf_api/description
Library contains the API(UCI, UBUS, JSON, CLI and Browse) of libbbfdm
endef
@@ -122,11 +110,6 @@ CMAKE_OPTIONS += \
-DBBF_TR143=ON
endif
ifeq ($(CONFIG_BBF_TR471),y)
CMAKE_OPTIONS += \
-DBBF_TR471=ON
endif
ifeq ($(CONFIG_BBF_VENDOR_EXTENSION),y)
CMAKE_OPTIONS += \
-DBBF_VENDOR_EXTENSION=ON
@@ -148,10 +131,6 @@ CMAKE_OPTIONS += \
-DBBF_DOTSO_PLUGIN=ON
endif
ifeq ($(BUILD_VARIANT),default)
CMAKE_OPTIONS += -DWITH_OPENSSL=ON
endif
ifeq ($(BUILD_VARIANT),openssl)
CMAKE_OPTIONS += -DWITH_OPENSSL=ON
endif
@@ -164,35 +143,24 @@ ifeq ($(BUILD_VARIANT),mbedtls)
CMAKE_OPTIONS += -DWITH_MBEDTLS=ON
endif
ifeq ($(CONFIG_PACKAGE_bbfdmd),y)
CMAKE_OPTIONS += -DBBFDMD_ENABLED=ON
CMAKE_OPTIONS += \
-DBBFDMD_MAX_MSG_LEN:Integer=10485760
endif
define Package/libbbfdm-api/install
define Package/libbbf_api/install
$(INSTALL_DIR) $(1)/lib
$(CP) $(PKG_BUILD_DIR)/libbbfdm-api/libbbfdm-api.so $(1)/lib/
endef
define Package/libbbfdm/default/install
$(INSTALL_DIR) $(1)/lib
$(INSTALL_DIR) $(1)/etc/bbfdm
$(INSTALL_DIR) $(1)/etc/bbfdm/dmmap
$(INSTALL_DIR) $(1)/lib/upgrade/keep.d
$(CP) $(PKG_BUILD_DIR)/libbbfdm/libbbfdm.so $(1)/lib/
$(INSTALL_DATA) ./files/lib/upgrade/keep.d/bbf $(1)/lib/upgrade/keep.d/bbf
ifeq ($(CONFIG_BBF_TR143),y)
$(INSTALL_DIR) $(1)/usr/share/bbfdm
$(INSTALL_DIR) $(1)/usr/libexec/rpcd
$(INSTALL_BIN) $(PKG_BUILD_DIR)/libbbfdm/scripts/* $(1)/usr/share/bbfdm
$(LN) /usr/share/bbfdm/bbf.diag $(1)/usr/libexec/rpcd/bbf.diag
endif
ifeq ($(CONFIG_BBFDM_ENABLE_JSON_PLUGIN),y)
$(INSTALL_DIR) $(1)/etc/bbfdm/json
endif
ifeq ($(CONFIG_BBFDM_ENABLE_DOTSO_PLUGIN),y)
$(INSTALL_DIR) $(1)/usr/share/bbfdm
$(INSTALL_DIR) $(1)/usr/lib/bbfdm
$(INSTALL_DIR) $(1)/usr/libexec/rpcd
$(CP) $(PKG_BUILD_DIR)/libbbfdm.so $(1)/lib/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/scripts/* $(1)/usr/share/bbfdm
$(LN) /usr/share/bbfdm/bbf.diag $(1)/usr/libexec/rpcd/bbf.diag
ifeq ($(CONFIG_PACKAGE_mosquitto-ssl),y)
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/etc/uci-defaults/01-mosquitto-config $(1)/etc/uci-defaults/
endif
endef
@@ -202,34 +170,22 @@ define Package/libbbfdm/default/prerm
exit 0
endef
define Package/bbfdmd/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) ./files/etc/init.d/bbfdmd $(1)/etc/init.d/bbfdmd
$(INSTALL_CONF) ./files/etc/config/bbfdm $(1)/etc/config/bbfdm
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bbfdmd/src/bbfdmd $(1)/usr/sbin/
endef
define Package/userinterface/install
$(INSTALL_DIR) $(1)/etc/bbfdm/json
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/lib/upgrade/keep.d
$(INSTALL_DATA) ./files/etc/bbfdm/json/UserInterface.json $(1)/etc/bbfdm/json/
$(INSTALL_DATA) ./files/etc/config/userinterface $(1)/etc/config/userinterface
$(INSTALL_DATA) ./files/lib/upgrade/keep.d/userinterface $(1)/lib/upgrade/keep.d/userinterface
$(INSTALL_BIN) ./files/etc/init.d/userinterface $(1)/etc/init.d/userinterface
$(INSTALL_BIN) ./files/etc/uci-defaults/93-userinterface-firewall $(1)/etc/uci-defaults/93-userinterface-firewall
$(INSTALL_BIN) ./files/etc/uci-defaults/94-userinterface-json $(1)/etc/uci-defaults/94-userinterface-json
$(INSTALL_BIN) ./files/etc/firewall.userinterface $(1)/etc/firewall.userinterface
endef
Package/libbbfdm/prerm = $(Package/libbbfdm/default/prerm)
Package/libbbfdm-openssl/prerm = $(Package/libbbfdm/default/prerm)
Package/libbbfdm-wolfssl/prerm = $(Package/libbbfdm/default/prerm)
Package/libbbfdm-mbedtls/prerm = $(Package/libbbfdm/default/prerm)
Package/libbbfdm/install = $(Package/libbbfdm/default/install)
Package/libbbfdm-openssl/install = $(Package/libbbfdm/default/install)
Package/libbbfdm-wolfssl/install = $(Package/libbbfdm/default/install)
Package/libbbfdm-mbedtls/install = $(Package/libbbfdm/default/install)
@@ -238,22 +194,16 @@ define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_DIR) $(1)/usr/include
$(INSTALL_DIR) $(1)/usr/include/libbbfdm
$(INSTALL_DIR) $(1)/usr/include/libbbfdm-api
$(INSTALL_DIR) $(1)/usr/include/libbbf_api
$(INSTALL_DATA) $(PKG_BUILD_DIR)/libbbfdm-api/include/*.h $(1)/usr/include/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/libbbfdm/dmtree/tr181/device.h $(1)/usr/include/libbbfdm/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/libbbfdm/dmtree/vendor/vendor.h $(1)/usr/include/libbbfdm/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/libbbfdm-api/*.h $(1)/usr/include/libbbfdm-api/
# Work around for backward compatibility
$(INSTALL_DATA) $(PKG_BUILD_DIR)/libbbfdm-api/*.h $(1)/usr/include/libbbf_api/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/libbbfdm-api/include/libbbfdm_api.h $(1)/usr/include/libbbf_api.h
$(INSTALL_DATA) $(PKG_BUILD_DIR)/include/*.h $(1)/usr/include/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/*.h $(1)/usr/include/libbbfdm/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/libbbf_api/*.h $(1)/usr/include/libbbf_api/
$(CP) $(PKG_BUILD_DIR)/libbbfdm.so $(1)/usr/lib/
endef
$(eval $(call BuildPackage,libbbfdm-api))
$(eval $(call BuildPackage,userinterface))
$(eval $(call BuildPackage,libbbf_api))
$(eval $(call BuildPackage,libbbfdm))
$(eval $(call BuildPackage,libbbfdm-openssl))
$(eval $(call BuildPackage,libbbfdm-wolfssl))
$(eval $(call BuildPackage,libbbfdm-mbedtls))
$(eval $(call BuildPackage,bbfdmd))
$(eval $(call BuildPackage,userinterface))

View File

@@ -0,0 +1,117 @@
{
"Device.UserInterface.": {
"type": "object",
"version": "2.0",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": false,
"Device.UserInterface.RemoteAccess.": {
"type": "object",
"version": "2.0",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": false,
"Enable": {
"type": "boolean",
"read": true,
"write": true,
"version": "2.0",
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "userinterface",
"section": {
"name": "remote_access"
},
"option": {
"name": "enable"
}
}
}
]
},
"Port": {
"type": "unsignedInt",
"read": true,
"write": true,
"version": "2.0",
"protocols": [
"cwmp",
"usp"
],
"range": [
{
"max": 65535
}
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "userinterface",
"section": {
"name": "remote_access"
},
"option": {
"name": "port"
}
}
}
]
},
"SupportedProtocols": {
"type": "string",
"read": true,
"write": false,
"version": "2.0",
"protocols": [
"cwmp",
"usp"
],
"list": {
"datatype": "string",
"enumerations": [
"HTTP",
"HTTPS"
]
},
"default": "HTTP"
},
"Protocol": {
"type": "string",
"read": true,
"write": true,
"version": "2.0",
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "userinterface",
"section": {
"name": "remote_access"
},
"option": {
"name": "protocol"
}
}
}
]
}
}
}
}

View File

@@ -0,0 +1,6 @@
config userinterface 'remote_access'
option enable '0'
option interface 'wan'
option port '80'
option protocol 'HTTP'

View File

@@ -0,0 +1,88 @@
#!/bin/sh
#!/bin/sh
. /lib/functions.sh
IDENTIFIER="REMOTE-ACCESS-WAN"
log() {
echo "${@}"|logger -t firewall.userinterface -p info
}
if [ ! -f "/etc/config/userinterface" ]; then
exit 0;
fi
function exec_cmd()
{
if ! $@; then
log "Failed to run [$@]"
fi
}
function configure_firewall_rule()
{
local enable port protocol gui_port
local zone interface
config_load userinterface
config_get_bool enable remote_access enable 1
config_get port remote_access port
config_get interface remote_access interface
if [ "${enable}" -eq "0" -o -z "${port}" -o -z "${interface}" ]; then
return 0;
fi
zone="zone_${interface}_input"
iptables -w 1 -t filter -nL ${zone} 2>/dev/null 1>&2
if [ "$?" -eq 0 ]; then
iptables -w 1 -I ${zone} -p tcp -m multiport --dports ${port} -m conntrack --ctstate NEW,ESTABLISHED -m comment --comment "${IDENTIFIER}" -j ACCEPT
fi
zone="zone_${interface}_output"
iptables -w 1 -t filter -nL ${zone} 2>/dev/null 1>&2
if [ "$?" -eq 0 ]; then
iptables -w 1 -I ${zone} -p tcp -m multiport --dports ${port} -m conntrack --ctstate ESTABLISHED -m comment --comment "${IDENTIFIER}" -j ACCEPT
fi
}
function delete_firewall_rule()
{
local zone interface
local CMD
config_load userinterface
config_get interface remote_access interface
# Clean remote interface rules
if [ -z "${interface}" ]; then
return 0
fi
zone="zone_${interface}_input"
CMD="iptables -w 1 -t filter -L ${zone} --line-numbers"
while ${CMD} 2>/dev/null | grep "${IDENTIFIER}"; do
rule_num="$(${CMD} | grep "${IDENTIFIER}" | head -1|awk '{print $1}')"
if [ -n "${rule_num}" ]; then
exec_cmd iptables -w 1 -t filter -D ${zone} ${rule_num};
fi
done
zone="zone_${interface}_output"
CMD="iptables -w 1 -t filter -L ${zone} --line-numbers"
while ${CMD} 2>/dev/null | grep "${IDENTIFIER}"; do
rule_num="$(${CMD} | grep "${IDENTIFIER}" | head -1|awk '{print $1}')"
if [ -n "${rule_num}" ]; then
exec_cmd iptables -w 1 -t filter -D ${zone} ${rule_num};
fi
done
}
# Delete existing remote access rules
delete_firewall_rule
# Configure the User Interface rule
configure_firewall_rule

View File

@@ -0,0 +1,27 @@
#!/bin/sh /etc/rc.common
START=99
STOP=01
USE_PROCD=1
start_service() {
local enable
procd_open_instance usp
config_load userinterface
config_get_bool enable global enable 1
# Inject firewall rules
if [ "${enable}" -eq "1" ]; then
/etc/firewall.userinterface
fi
procd_close_instance
}
service_triggers()
{
procd_add_reload_trigger "userinterface"
}

View File

@@ -0,0 +1,46 @@
#!/bin/sh
config_mosquitto_owrt() {
sec=$(uci -q get mosquitto.owrt)
if [ -z "${sec}" ]; then
sec=$(uci -q add mosquitto owrt)
uci -q rename mosquitto."${sec}"="owrt"
fi
uci -q set mosquitto.owrt.use_uci="1"
uci -q set mosquitto.owrt.write_pid="1"
uci -q commit mosquitto
}
config_mosquitto_general() {
sec=$(uci -q get mosquitto.mosquitto)
if [ -z "${sec}" ]; then
sec=$(uci -q add mosquitto mosquitto)
uci -q rename mosquitto."${sec}"="mosquitto"
fi
uci -q set mosquitto.mosquitto.log_dest="syslog"
uci -q set mosquitto.mosquitto.log_facility="5"
uci -q set mosquitto.mosquitto.log_timestamp="1"
uci -q set mosquitto.mosquitto.log_types="error warning notice"
uci -q set mosquitto.mosquitto.per_listener_settings="1"
uci -q commit mosquitto
}
config_mosquitto_persistence() {
sec=$(uci -q get mosquitto.persistence)
if [ -z "${sec}" ]; then
sec=$(uci -q add mosquitto persistence)
uci -q rename mosquitto."${sec}"="persistence"
fi
uci -q set mosquitto.persistence.persistence="0"
uci -q set mosquitto.persistence.location="/var/run"
uci -q commit mosquitto
}
if [ -f "/etc/config/mosquitto" ]; then
config_mosquitto_owrt
config_mosquitto_general
config_mosquitto_persistence
fi

View File

@@ -1,5 +0,0 @@
config bbfdmd 'bbfdmd'
option loglevel '1'
option refresh_time '10'
option transaction_timeout '10'

View File

@@ -1,3 +0,0 @@
config userinterface 'global'
option enable '1'

View File

@@ -1,125 +0,0 @@
#!/bin/sh
. /lib/functions.sh
IDENTIFIER="UI-REMOTE-ACCESS-WAN"
log() {
echo "${@}"|logger -t firewall.userinterface -p info
}
if [ ! -f "/etc/config/userinterface" ] || [ ! -f "/etc/config/nginx" ]; then
exit 0;
fi
exec_cmd() {
if ! "$@"; then
log "Failed to run [$*]"
fi
}
delete_ui_firewall_rules() {
input_chains=$(iptables -S | grep -E "^-N zone[a-zA-Z0-9_]+input$" | cut -d' ' -f 2)
output_chains=$(iptables -S | grep -E "^-N zone[a-zA-Z0-9_]+output$" | cut -d' ' -f 2)
for chain in ${input_chains}; do
CMD="iptables -w 1 -t filter -nL ${chain} --line-numbers"
while ${CMD} 2>/dev/null | grep "${IDENTIFIER}"; do
rule_num="$(${CMD} | grep "${IDENTIFIER}" | head -1|awk '{print $1}')"
if [ -n "${rule_num}" ]; then
exec_cmd iptables -w 1 -t filter -D "${chain}" "${rule_num}";
fi
done
done
for chain in ${output_chains}; do
CMD="iptables -w 1 -t filter -nL ${chain} --line-numbers"
while ${CMD} 2>/dev/null | grep "${IDENTIFIER}"; do
rule_num="$(${CMD} | grep "${IDENTIFIER}" | head -1|awk '{print $1}')"
if [ -n "${rule_num}" ]; then
exec_cmd iptables -w 1 -t filter -D "${chain}" "${rule_num}";
fi
done
done
input6_chains=$(ip6tables -S | grep -E "^-N zone[a-zA-Z0-9_]+input$" | cut -d' ' -f 2)
output6_chains=$(ip6tables -S | grep -E "^-N zone[a-zA-Z0-9_]+output$" | cut -d' ' -f 2)
for chain in ${input6_chains}; do
CMD="ip6tables -w 1 -t filter -nL ${chain} --line-numbers"
while ${CMD} 2>/dev/null | grep "${IDENTIFIER}"; do
rule_num="$(${CMD} | grep "${IDENTIFIER}" | head -1|awk '{print $1}')"
if [ -n "${rule_num}" ]; then
exec_cmd ip6tables -w 1 -t filter -D "${chain}" "${rule_num}";
fi
done
done
for chain in ${output6_chains}; do
CMD="ip6tables -w 1 -t filter -nL ${chain} --line-numbers"
while ${CMD} 2>/dev/null | grep "${IDENTIFIER}"; do
rule_num="$(${CMD} | grep "${IDENTIFIER}" | head -1|awk '{print $1}')"
if [ -n "${rule_num}" ]; then
exec_cmd ip6tables -w 1 -t filter -D "${chain}" "${rule_num}";
fi
done
done
}
configure_ui_firewall_rule() {
local sec="${1}"
local enabled access interface
local port=""
config_get_bool enabled "${sec}" uci_enable '1'
config_get access "${sec}" uci_access ""
config_get interface "${sec}" uci_interface ""
if [ "${enabled}" -eq "1" ] && [ "${access}" == "remote" ] && [ -n "${interface}" ]; then
port_list=$(uci -q show nginx."${1}".listen|cut -d'=' -f 2|sed "s/'/ /g"|sed "s/\[\:\:\]\://g")
for item in ${port_list}; do
if [ -z "${item##[0-9]*}" ]; then
port="${item}"
break
fi
done
if [ -z "${port}" ]; then
return 0
fi
zone="zone_${interface}_input"
iptables -w 1 -t filter -nL ${zone} 2>/dev/null 1>&2
if [ "$?" -eq 0 ]; then
iptables -w 1 -I "${zone}" -p tcp -m multiport --dports "${port}" -m conntrack --ctstate NEW,ESTABLISHED -m comment --comment "${IDENTIFIER}" -j ACCEPT
fi
ip6tables -w 1 -t filter -nL ${zone} 2>/dev/null 1>&2
if [ "$?" -eq 0 ]; then
ip6tables -w 1 -I "${zone}" -p tcp -m multiport --dports "${port}" -m conntrack --ctstate NEW,ESTABLISHED -m comment --comment "${IDENTIFIER}" -j ACCEPT
fi
zone="zone_${interface}_output"
iptables -w 1 -t filter -nL "${zone}" 2>/dev/null 1>&2
if [ "$?" -eq 0 ]; then
iptables -w 1 -I "${zone}" -p tcp -m multiport --dports "${port}" -m conntrack --ctstate ESTABLISHED -m comment --comment "${IDENTIFIER}" -j ACCEPT
fi
ip6tables -w 1 -t filter -nL "${zone}" 2>/dev/null 1>&2
if [ "$?" -eq 0 ]; then
ip6tables -w 1 -I "${zone}" -p tcp -m multiport --dports "${port}" -m conntrack --ctstate ESTABLISHED -m comment --comment "${IDENTIFIER}" -j ACCEPT
fi
fi
}
# Delete existing remote access rules
delete_ui_firewall_rules
config_load userinterface
config_get_bool serv_enable global enable 1
if [ "${serv_enable}" -eq "1" ]; then
config_load nginx
# Configure the User Interface rule
config_foreach configure_ui_firewall_rule server
fi

View File

@@ -1,83 +0,0 @@
#!/bin/sh /etc/rc.common
START=96
STOP=10
USE_PROCD=1
PROG=/usr/sbin/bbfdmd
log() {
echo "${@}"|logger -t bbfdmd.init -p info
}
validate_bbfdm_bbfdmd_section()
{
uci_validate_section bbfdm bbfdmd "bbfdmd" \
'enabled:bool:true' \
'debug:bool:false' \
'loglevel:uinteger' \
'sock:string' \
'transaction_timeout:string'
}
configure_bbfdmd()
{
local enabled debug sock transaction_timeout
config_load bbfdm
validate_bbfdm_bbfdmd_section || {
log "Validation of bbfdmd section failed"
return 1;
}
[ "${enabled}" -eq 0 ] && return 0
procd_set_param command ${PROG}
if [ "${debug}" -eq 1 ]; then
procd_set_param stdout 1
procd_set_param stderr 1
fi
if [ -f "${sock}" ]; then
procd_append_param command -s "${sock}"
fi
if [ -n "${transaction_timeout}" ]; then
procd_append_param command -t "${transaction_timeout}"
fi
}
apply_sysctl_configuration() {
local sysctl_conf
sysctl_conf="/etc/bbfdm/sysctl.conf"
[ -f "${sysctl_conf}" ] || touch "${sysctl_conf}"
sysctl -e -p "${sysctl_conf}" >&-
}
start_service() {
local sysctl_reload
ubus -t 5 wait_for network.device
[ "$?" -eq 0 ] && sysctl_reload=1
procd_open_instance bbf
configure_bbfdmd
procd_set_param respawn
procd_close_instance
[ "${sysctl_reload}" -eq 1 ] && apply_sysctl_configuration
}
reload_service() {
ubus -t 5 wait_for network.device
apply_sysctl_configuration
}
service_triggers()
{
procd_add_reload_trigger "bbfdm" "network"
}

View File

@@ -1,33 +0,0 @@
#!/bin/sh /etc/rc.common
START=99
STOP=01
USE_PROCD=1
start_service() {
local enable
config_load userinterface
config_get_bool enable global enable 1
if [ ! -f "/etc/config/nginx" ]; then
return 0
fi
if [ "${enable}" -eq "1" ]; then
ubus call service state '{"name":"nginx", "spawn":true}'
else
ubus call service state '{"name":"nginx", "spawn":false}'
fi
# Inject firewall rules
procd_open_instance userinterface
/etc/firewall.userinterface
procd_close_instance
}
service_triggers()
{
procd_add_reload_trigger "userinterface" "nginx"
}

View File

@@ -1,9 +0,0 @@
#!/bin/sh
# This deletes the userinterface json plugin if exists in case of upgrade
if [ -f "/etc/bbfdm/json/UserInterface.json" ]; then
rm /etc/bbfdm/json/UserInterface.json
fi
exit 0

View File

@@ -1 +0,0 @@
/etc/bbfdm/sysctl.conf

View File

@@ -1 +0,0 @@
/etc/nginx/allow_host_*

View File

@@ -1,24 +1,28 @@
#
# Copyright (C) 2022 iopsys Software Solutions AB
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=bulkdata
PKG_VERSION:=2.1.0
PKG_VERSION:=2.0.9
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/bulkdata.git
PKG_SOURCE_VERSION:=2dd55d9c9eb01ed1b11e16bad9e2c3e8badfffeb
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/bulkdata.git
PKG_SOURCE_VERSION:=6e85d2032e66df581fae7c72cd83cc89367b8fc8
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif
PKG_LICENSE:=BSD-3-Clause
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_LICENSE:=GPL-2.0-only
PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk

View File

@@ -16,8 +16,8 @@ get_next_count()
fi
while [ "${found}" -ne 1 ]; do
uci -q get "${config}"."${default_name}"_${count} >/dev/null
if [ "$?" -eq 0 ]; then
uci -q get ${config}.${default_name}_${count} >/dev/null
if [ $? -eq 0 ]; then
count=$((count + 1))
else
found=1;
@@ -39,8 +39,8 @@ translate_profile_id_to_profile_name() {
[ "${curr_profile_id}" != "${profile_id}" ] && return
uci -q set bulkdata."${section}".profile_name="${profile_name}"
uci -q set bulkdata."${section}".profile_id=""
uci -q set bulkdata.${section}.profile_name="${profile_name}"
uci -q set bulkdata.${section}.profile_id=""
}
update_profile_sections() {
@@ -54,7 +54,7 @@ update_profile_sections() {
case "${section}" in
"cfg"*)
profile_name="$(get_next_count bulkdata "${default}" ${PROFILE_COUNT})"
profile_name="$(get_next_count bulkdata ${default} ${PROFILE_COUNT})"
uci_rename bulkdata "${section}" "${profile_name}"
;;
esac
@@ -62,7 +62,7 @@ update_profile_sections() {
[ -n "$profile_name" ] && section="${profile_name}"
uci -q set bulkdata."${section}".profile_id=""
uci -q set bulkdata.${section}.profile_id=""
config_foreach translate_profile_id_to_profile_name profile_parameter "${profile_id}" "${profile_name}"
config_foreach translate_profile_id_to_profile_name profile_http_request_uri_parameter "${profile_id}" "${profile_name}"

View File

@@ -1,78 +0,0 @@
#
# Copyright (C) 2021-2023 IOPSYS Software Solutions AB
#
include $(TOPDIR)/rules.mk
PKG_NAME:=decollector
PKG_VERSION:=4.0.2.0
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=162654487bfbff7d68d0c87ae9498a3def738d84
PKG_SOURCE_URL:=https://dev.iopsys.eu/multi-ap/decollector.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_LICENSE:=BSD-3-Clause
PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk
define Package/decollector
SECTION:=utils
CATEGORY:=Utilities
TITLE:=WiFi DataElements Collector Proxy
DEPENDS:=+libuci +libubox +ubus +libpthread +libnl-genl \
+libeasy +libwifiutils +libieee1905 +map-plugin
endef
define Package/decollector/description
It implements the WiFi DataElements Agent as defined in the Wi-Fi Alliance's
DataElements specification.
endef
define Package/decollector/config
source "$(SOURCE)/Config.in"
endef
ifneq (,$(findstring ALPHA,$(CONFIG_VERSION_CODE)))
MAKE_FLAGS += DEBUG=1
endif
ifneq (,$(findstring BETA,$(CONFIG_VERSION_CODE)))
MAKE_FLAGS += DEBUG=1
endif
TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include \
-I$(STAGING_DIR)/usr/include/libnl3 \
-D_GNU_SOURCE
ifeq ($(LOCAL_DEV),1)
define Build/Prepare
rsync -r --exclude=.* ~/git/decollector/ $(PKG_BUILD_DIR)/
endef
endif
MAKE_PATH:=src
TARGET_CFLAGS += -DEASYMESH_VERSION=$(CONFIG_DECOLLECTOR_EASYMESH_VERSION)
EXECS := \
$(if $(CONFIG_PACKAGE_decollector),decollector)
MAKE_FLAGS += EXECS="$(EXECS)"
define Package/decollector/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) ./files/decollector.init $(1)/etc/init.d/decollector
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/decollector $(1)/usr/sbin/
endef
$(eval $(call BuildPackage,decollector))

View File

@@ -8,13 +8,13 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=dectmngr
PKG_RELEASE:=3
PKG_VERSION:=3.5.7
PKG_VERSION:=3.5.5
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/dectmngr.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=83f89a83cf860bbcf2b7f2e030215db315a5bbbf
PKG_SOURCE_VERSION:=cf4e91ffe0a1d83140fef5b41d16e581e5341cec
PKG_MIRROR_HASH:=skip
endif
@@ -34,7 +34,7 @@ include $(INCLUDE_DIR)/package.mk
define Package/$(PKG_NAME)
CATEGORY:=Utilities
TITLE:=DECT Manager
DEPENDS:= +libubox +ubus +uci +libxml2 +libjson-c +gpiod-tools
DEPENDS:= +libubox +ubus +uci +libxml2 +libjson-c
endef
define Package/$(PKG_NAME)/description

View File

@@ -10,9 +10,8 @@ NAME=dectmngr
PROG=/usr/sbin/dectmngr
LOG_PATH=/var/log/dectmngr
DB_PATH=/etc/dect
DCX81_UART_DT_ALIAS=/proc/device-tree/aliases/dcx81-uart
DECT_GPIO="$(gpiofind DCX81_RSTN | cut -d ' ' -f 2 2>/dev/null)"
DECT_GPIO=$(db -q get hw.board.dect_gpio)
# Ask dectmngr to exit nicely and wait for it to clean up, which is a slow process.
stop_and_wait_dectmngr() {
@@ -20,48 +19,18 @@ stop_and_wait_dectmngr() {
pidof $NAME && sleep 2 # wait for the process to stop gracefully
while pidof $NAME; do
killall -q -9 $NAME
killall -q -9 $NAME
sleep 1
done
}
has_dect() {
[ -f "$DCX81_UART_DT_ALIAS" ]
}
get_dcx81_device() {
readonly dcx81_uart_dt_node="/proc/device-tree/$(cat "$DCX81_UART_DT_ALIAS" 2>/dev/null)"
[ -e "$dcx81_uart_dt_node" ] || return 1
for tty_dt_node in /sys/class/tty/*/device/of_node; do
if [ "$tty_dt_node" -ef "$dcx81_uart_dt_node" ]; then
readonly uevent_file="${tty_dt_node%%/device/of_node}/uevent"
local device_name_line
device_name_line="$(grep '^DEVNAME=' "$uevent_file")" || return 1
readonly device="/dev/${device_name_line##DEVNAME=}"
[ -c "$device" ] || return 1
printf "%s" "$device"
return 0
fi
done
return 1
}
start_service() {
local opt_ext=
local rfpi=
local model_id=
local rxtun=
if ! has_dect; then
logger -t "$PROG" "Not starting because no DECT hardware is available."
return 0
fi
local dcx81_uart_device
if ! dcx81_uart_device="$(get_dcx81_device)"; then
logger -t "$PROG" -p daemon.warning "Could not determine DCX81 UART device. Falling back to default ttyH0."
dcx81_uart_device=/dev/ttyH0
fi
test $(db get hw.board.hasDect) = "0" && return
[ -n "$DECT_GPIO" ] && echo 1 > /sys/class/gpio/gpio${DECT_GPIO}/value
@@ -82,25 +51,18 @@ start_service() {
config_get log_dect_cmbs global log_dect_cmbs syslog
procd_open_instance
# dectmngr takes expects device without /dev
readonly dcx81_uart_device_wo_dev="${dcx81_uart_device##/dev/}"
case "$log_dect_cmbs" in
none)
if [ "$log_dect_cmbs" = "none" ]; then
echo "Starting dectmngr with cmbs logging disabled"
procd_set_param command "$PROG" -comname "$dcx81_uart_device_wo_dev" $opt_ext
procd_set_param command $PROG -comname ttyH0 $opt_ext
rm -f $LOG_PATH/*
;;
file)
elif [ "$log_dect_cmbs" = "file" ]; then
echo "Starting dectmngr with cmbs logging enabled to file"
procd_set_param command "$PROG" -comname "$dcx81_uart_device_wo_dev" -log $LOG_PATH/dect-cmbs.log $opt_ext
;;
*)
procd_set_param command $PROG -comname ttyH0 -log $LOG_PATH/dect-cmbs.log $opt_ext
else
echo "Starting dectmngr with cmbs logging enabled to syslog"
procd_set_param command "$PROG" -comname "$dcx81_uart_device_wo_dev" -syslog $opt_ext
procd_set_param command $PROG -comname ttyH0 -syslog $opt_ext
rm -f $LOG_PATH/*
;;
esac
fi
procd_set_param respawn 6 2 3
procd_set_param term_timeout 20
@@ -109,7 +71,7 @@ start_service() {
}
stop_service() {
has_dect || return 0
test $(db get hw.board.hasDect) = "0" && return
[ -n "$DECT_GPIO" ] && echo 0 > /sys/class/gpio/gpio${DECT_GPIO}/value
stop_and_wait_dectmngr
@@ -119,7 +81,8 @@ reload_service() {
ubus call dect reload
}
service_triggers() {
service_triggers()
{
procd_add_config_trigger "config.change" "asterisk" /etc/init.d/dectmngr restart
procd_add_config_trigger "config.change" "dect" /etc/init.d/dectmngr reload
}
@@ -134,3 +97,4 @@ boot() {
[ ! -d $DB_PATH ] && mkdir -p $DB_PATH
start
}

View File

@@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=dslmngr
PKG_VERSION:=1.2.0
PKG_VERSION:=1.1.2
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
@@ -68,10 +68,6 @@ define Build/Compile
endef
define Package/dslmngr/install
$(CP) ./files/common/* $(1)/
ifeq ($(CONFIG_TARGET_brcmbca),y)
$(CP) ./files/broadcom/* $(1)/
endif
$(INSTALL_DIR) $(1)/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/dslmngr $(1)/sbin/
endef

View File

@@ -1,311 +0,0 @@
#!/bin/sh
. /lib/functions.sh
# ATM #
check_pvc() {
local vpi=$1
local vci=$2
local ret
ret=$(xtmctl operate conn --show | awk -v test="$vpi/$vci" '{if ($3==test ) print $5 }')
case $ret in
''|*[!0-9]*) return 0 ;;
*) return $ret ;;
esac
}
check_xtm_list() {
local qclass=$1
local pcr scr mbs
local ret
case $# in
1)
pcr=0
scr=0
mbs=0
;;
2)
pcr=$2
scr=0
mbs=0
;;
4)
pcr=$2
scr=$3
mbs=$4
;;
esac
ret=$(xtmctl operate tdte --show | awk -v test="$qclass" -v pcr="$pcr" -v scr="$scr" -v mbs="$mbs" '{if ($2==test && $3==pcr && $4==scr && $5==mbs ) print $1 }')
case $ret in
''|*[!0-9]*) return 0 ;;
*) return $ret ;;
esac
}
configure_atm_device() {
local name vpi vci device link_type encapsulation qos_class pcr mbs scr i
config_get name $1 name "ATM"
config_get vpi $1 vpi "8"
config_get vci $1 vci "35"
config_get device $1 device "atm0"
config_get link_type $1 link_type "eoa"
config_get encapsulation $1 encapsulation "llc"
config_get qos_class $1 qos_class "ubr"
config_get pcr $1 pcr
config_get mbs $1 mbs
config_get scr $1 scr
check_pvc $vpi $vci
ret=$?
if [ "$ret" -eq 0 ]; then
check_xtm_list $qos_class $pcr $scr $mbs
ret=$?
if [ "$ret" -eq 0 ]; then
case $qos_class in # ubr, cbr, gfr, vbr-nrt, vbr-rt, ubr+, abr
ubr)
xtmctl operate tdte --add "$qos_class"
;;
ubr_pcr|ubr+)
xtmctl operate tdte --add "$qos_class" $pcr
;;
cbr)
xtmctl operate tdte --add "$qos_class" $pcr
;;
nrtvbr|vbr-nrt)
xtmctl operate tdte --add "$qos_class" $pcr $scr $mbs
;;
rtvbr|vbr-rt)
xtmctl operate tdte --add "$qos_class" $pcr $scr $mbs
;;
gfr)
;;
abr)
;;
esac
fi
case $link_type in # EoA, IPoA, PPPoA, CIP
EoA|eoa)
[ $encapsulation == "vcmux" ] && encapsulation="vcmux_eth" || encapsulation="llcsnap_eth"
;;
PPPoA|pppoa)
[ $encapsulation == "vcmux" ] && encapsulation="vcmux_pppoa" || encapsulation="llcencaps_ppp"
;;
IPoA|ipoa)
[ $encapsulation == "vcmux" ] && encapsulation="vcmux_ipoa" || encapsulation="llcsnap_rtip"
;;
CIP|cip)
;;
esac
check_xtm_list $qos_class $pcr $scr $mbs
ret="$?"
xtmctl operate conn --add 1.$vpi.$vci aal5 $encapsulation 0 1 $ret
for i in `seq 0 7`; do
xtmctl operate conn --addq 1.$vpi.$vci $i wrr 1 dt # queue priority 0-7
done
xtmctl operate conn --createnetdev 1.$vpi.$vci $device
xtmctl operate intf --state 1 enable
fi
}
remove_atm_devices() {
local vpi vci rest
local vpivci=`xtmctl operate conn --show | grep "ATM\|mode" | awk '{if (NR!=1 && $1!="PTM") {print $3}}'`
for i in $vpivci
do
rest=${i#\/}
vpi=${rest%%\/*}
vci=${rest#*\/}
echo "xtmctl operate conn --delete 1.$vpi.$vci"
xtmctl operate conn --delete 1.$vpi.$vci
echo "xtmctl operate conn --deletenetdev 1.$vpi.$vci"
xtmctl operate conn --deletenetdev 1.$vpi.$vci
done
}
create_atm_devices() {
echo "Creating ATM Device(s)"
config_load dsl
config_foreach configure_atm_device atm-device
}
# ATM END #
# PTM #
check_ptm() {
local ret
local ptmprio=$1
local dslat=$2
if [ "$ptmprio" -eq 2 ]; then
ptmprio="high"
else
ptmprio="low"
fi
ret=$(xtmctl operate conn --show | awk -v dslat="$dslat" -v ptmprio="$ptmprio" '{if ($2 == dslat && $3 == ptmprio ) print $2 }')
case $ret in
''|*[!0-9]*) return 0 ;;
*) return $ret ;;
esac
}
configure_ptm_device() {
local name device priority portid i
config_get name $1 name "PTM"
config_get device $1 device "ptm0"
config_get priority $1 priority 1
config_get portid $1 portid 1
check_ptm $priority $portid
ret=$?
if [ "$ret" -eq 0 ]; then
xtmctl operate conn --add $portid.$priority
for i in `seq 0 7`; do
xtmctl operate conn --addq $portid.$priority $i wrr 1 dt -1 -1 3000 # queue priority 0-7
done
echo "xtmctl operate conn --createnetdev $portid.$priority $device"
xtmctl operate conn --createnetdev $portid.$priority $device
xtmctl operate intf --state 1 enable
fi
}
remove_ptm_devices() {
local delptm
local x=0
IFS=$'\n'
for i in `xtmctl operate conn --show | grep "PTM\|mode"`
do
if [ $x -eq 1 ]; then
delptm=$(echo $i | awk '{if ($1!="ATM") print $2"."$11}')
echo "xtmctl operate conn --delete $delptm"
xtmctl operate conn --delete $delptm
xtmctl operate conn --deletenetdev $delptm
fi
x=1
done
unset IFS
}
create_ptm_devices() {
echo "Creating PTM Device(s)"
config_load dsl
config_foreach configure_ptm_device ptm-device
}
# PTM END #
prioritize_arp()
{
ebtables -t nat -D POSTROUTING -j mark --mark-or 0x7 -p ARP >/dev/null
ebtables -t nat -A POSTROUTING -j mark --mark-or 0x7 -p ARP >/dev/null
}
xtm_remove_devices() {
remove_atm_devices
remove_ptm_devices
}
xtm_create_devices() {
local tpstc="$(xdslctl info --show | grep TPS-TC)"
if echo "$tpstc" | grep -q "ATM Mode"; then
create_atm_devices
elif echo "$tpstc" | grep -q "PTM Mode"; then
create_ptm_devices
fi
}
xdsl_configure() {
local VDSL=0
local GFAST=0
local mod=""
local modes=""
local profile=""
config_load dsl
# Modes
config_get mode line mode
for mod in $mode; do
[ $mod == "gdmt" ] && modes="${modes}d"
[ $mod == "glite" ] && modes="${modes}l"
[ $mod == "t1413" ] && modes="${modes}t"
[ $mod == "adsl2" ] && modes="${modes}2"
[ $mod == "adsl2p" ] && modes="${modes}p"
[ $mod == "annexl" ] && modes="${modes}e"
[ $mod == "annexm" ] && modes="${modes}m"
[ $mod == "vdsl2" ] && modes="${modes}v" && VDSL=1
[ $mod == "gfast" ] && modes="${modes}f" && GFAST=1
done
# VDSL Profiles
config_get profile line profile
# Capabilities
config_get_bool bitswap line bitswap 1
[ $bitswap -eq 1 ] && bitswap="on" || bitswap="off"
config_get_bool sra line sra 1
[ $sra -eq 1 ] && sra="on" || sra="off"
# config_get_bool trellis line trellis 1
config_get_bool sesdrop line sesdrop 0
[ $sesdrop -eq 1 ] && sesdrop="on" || sesdrop="off"
# VDSL2 only
config_get_bool us0 line us0 1
[ $us0 -eq 1 ] && us0="on" || us0="off"
# config_get_bool dynamicd line dynamicd 1
# config_get_bool dynamicf line dynamicf 1
config_get_bool sos line sos 0
[ $sos -eq 1 ] && sos="on" || sos="off"
config_get_bool phyReXmtUs line phyReXmtUs 0
config_get_bool phyReXmtDs line phyReXmtDs 1
phyReXmt=$(( $((phyReXmtUs<<1)) + phyReXmtDs))
if [ $VDSL -eq 1 -o $GFAST -eq 1 ]; then
echo "xdslctl start --up --mod $modes --profile "$profile" --sra $sra --bitswap $bitswap --us0 $us0 --sesdrop $sesdrop --SOS $sos --phyReXmt $phyReXmt"
xdslctl start --up --mod $modes --profile "$profile" --sra $sra --bitswap $bitswap --us0 $us0 --sesdrop $sesdrop --SOS $sos --phyReXmt $phyReXmt
# G.Fast hardware to VDSL hardware, to set the driver bit kPhyCfg2EnableGfastVdslMMTimeOut0.
# Enable V43 tone for GFAST.
echo "xdslctl configure1 --phycfg 0 0 0 0 0 0 0 0 0 0 0 0x1400400 0x1400400"
xdslctl configure1 --phycfg 0 0 0 0 0 0 0 0 0 0 0 0x1400400 0x1400400
else
echo "xdslctl start --up --mod $modes --sra $sra --bitswap $bitswap --sesdrop $sesdrop --SOS $sos --phyReXmt $phyReXmt"
xdslctl start --up --mod $modes --sra $sra --bitswap $bitswap --sesdrop $sesdrop --SOS $sos --phyReXmt $phyReXmt
fi
if [ $GFAST -eq 1 ]; then
# G.Fast hardware to VDSL hardware, to set the driver bit kPhyCfg2EnableGfastVdslMMTimeOut0.
# Enable V43 tone for GFAST.
echo "xdslctl configure1 --phycfg 0 0 0 0 0 0 0 0 0 0 0 0x1400400 0x1400400"
xdslctl configure1 --phycfg 0 0 0 0 0 0 0 0 0 0 0 0x1400400 0x1400400
fi
}
xdsl_stop() {
# echo "Stopping DSL"
# stop causes IRQ issues
# xdslctl stop
return 0
}
xdsl_init() {
prioritize_arp
echo "Starting DSL"
xtmctl start
xtmctl operate intf --state 1 enable
}

View File

@@ -1,53 +0,0 @@
# OEM specific parameters
config oem-parameters 'oem'
# option country_code "0000" # 2 bytes hex
# option vendor_id "IO" # 4 bytes string
# option vendor_suffix "0000" # 2 bytes hex
# option sw_version "iopsys" # 16 bytes string
# option serial_nr "00000000" # 32 bytes string
# DSL Modes
config dsl-line line
list mode gdmt
list mode glite
list mode t1413
list mode adsl2
list mode adsl2p
list mode annexl
list mode annexm
list mode vdsl2
# VDSL2 profiles
list profile 8a
list profile 8b
list profile 8c
list profile 8d
list profile 12a
list profile 12b
list profile 17a
list profile 30a
option bitswap 1
option sra 1
option us0 1 # VDSL2 only
option sesdrop 0
option sos 0
option phyReXmtUs 0
option phyReXmtDs 1
config atm-device atm0
option name 'ATM'
option vpi '8'
option vci '35'
option device atm0
option link_type 'eoa' # EoA, IPoA, PPPoA, CIP
option encapsulation 'llc' # llc, vcmux
option qos_class 'ubr' # ubr, cbr, gfr, vbr-nrt, vbr-rt, ubr+, abr
# option pcr '512'
# option scr '256'
# option mbs '1024'
config ptm-device ptm0
option name 'PTM'
option device 'ptm0'
option priority '1'
option portid '1'

View File

@@ -1,7 +0,0 @@
[ "$STATUS" == "up" -o "$STATUS" == "down" ] || exit 0
. /lib/functions.sh
include /lib/dsl
xtm_remove_devices
xtm_create_devices

View File

@@ -1,7 +0,0 @@
if [ "$STATUS" == "up" ]; then
ubus call led.dsl set '{"state":"ok"}'
elif [ "$STATUS" == "down" ]; then
ubus call led.dsl set '{"state":"off"}'
elif [ "$STATUS" == "training" ]; then
ubus call led.dsl set '{"state":"alert"}'
fi

View File

@@ -1,45 +0,0 @@
#!/bin/sh /etc/rc.common
. /lib/functions.sh
include /lib/dsl
START=20
USE_PROCD=1
DSLMNGR=$(which dslmngr)
start_service() {
[ -n "$DSLMNGR" ] && {
procd_open_instance
procd_set_param command "$DSLMNGR"
procd_set_param respawn
procd_close_instance
}
xdsl_configure
xtm_create_devices
}
stop_service() {
xtm_remove_devices
xdsl_stop
}
boot() {
local HASADSL="$(db -q get hw.board.hasAdsl)"
local HASVDSL="$(db -q get hw.board.hasVdsl)"
[ "$HASADSL" == "1" -o "$HASVDSL" == "1" ] || return
xdsl_init
start
}
reload_service() {
stop
start
}
service_triggers() {
procd_add_reload_trigger dsl
}

5
easy-soc-libs/Config.in Normal file
View File

@@ -0,0 +1,5 @@
# libeasy configuration
config LIBWIFI_USE_CTRL_IFACE
bool "Use UNIX sockets"
default n

141
easy-soc-libs/Makefile Normal file
View File

@@ -0,0 +1,141 @@
#
# Copyright (C) 2020 iopsys Software Solutions AB
#
# This is free software, licensed under the GNU General Public License v2.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=easy-soc-libs
PKG_VERSION:=6.8.0
PKG_RELEASE:=1
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=ddc7b272bec5e3b5c2a216a1f86cd5589a1a4a19
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/easy-soc-libs.git
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu>
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip
endif
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_LICENSE:=GPLv2
PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk
define Package/easy-soc-libs
SECTION:=libs
CATEGORY:=Libraries
TITLE:=IOPSYS Easy SoC libraries
SUBMENU:=IOPSYS Easy SoC libraries
DEPENDS:=+libopenssl
MENU:=1
endef
ifeq ($(CONFIG_TARGET_brcmbca),y)
TARGET_PLATFORM=BROADCOM
TARGET_WIFI_TYPE=BROADCOM
CHIP_ID=$(patsubst "%",%,$(CONFIG_BCM_CHIP_ID))
TARGET_CFLAGS +=-DIOPSYS_BROADCOM -DCHIP_$(CHIP_ID) -DCONFIG_BCM9$(CHIP_ID) \
-I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx \
-I$(STAGING_DIR)/usr/include/bcm963xx/userspace/public/include
else ifeq ($(CONFIG_TARGET_iopsys_ramips),y)
TARGET_PLATFORM=MEDIATEK
TARGET_WIFI_TYPE=MAC80211
TARGET_CFLAGS +=-DIOPSYS_MAC80211
else ifeq ($(CONFIG_TARGET_iopsys_x86),y)
TARGET_PLATFORM=TEST
TARGET_WIFI_TYPE=TEST
TARGET_CFLAGS +=-DIOPSYS_TEST
else ifeq ($(CONFIG_TARGET_iopsys_armvirt),y)
TARGET_PLATFORM=TEST
TARGET_WIFI_TYPE=TEST
TARGET_CFLAGS +=-DIOPSYS_TEST
else ifeq ($(CONFIG_TARGET_airoha),y)
TARGET_PLATFORM=ECONET
TARGET_WIFI_TYPE=MAC80211
TARGET_CFLAGS +=-DIOPSYS_ECONET
else
$(info Unexpected CONFIG_TARGET, use default MAC80211)
TARGET_PLATFORM=MAC80211
TARGET_WIFI_TYPE=MAC80211
TARGET_CFLAGS +=-DIOPSYS_MAC80211
endif
export TARGET_PLATFORM
export TARGET_WIFI_TYPE
subdirs := \
$(if $(CONFIG_PACKAGE_libeasy),libeasy) \
$(if $(CONFIG_PACKAGE_libwifi),libwifi) \
$(if $(CONFIG_PACKAGE_libdsl),libdsl) \
$(if $(CONFIG_PACKAGE_libethernet),libethernet) \
$(if $(CONFIG_PACKAGE_libqos),libqos)
EASY_SOC_LIBS := \
libeasy \
libwifi \
libdsl \
libethernet \
libqos
ifeq ($(CONFIG_LIBWIFI_USE_CTRL_IFACE),y)
TARGET_CFLAGS +=-DLIBWIFI_USE_CTRL_IFACE
endif
TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include \
-I$(STAGING_DIR)/usr/include/openssl \
-I$(STAGING_DIR)/usr/include/libnl3
MAKE_FLAGS += \
CFLAGS="$(TARGET_CFLAGS) -Wall -I./" \
LDFLAGS="$(TARGET_LDFLAGS)" \
FPIC="$(FPIC)" \
PLATFORM="$(TARGET_PLATFORM)" \
WIFI_TYPE="$(TARGET_WIFI_TYPE)" \
subdirs="$(subdirs)"
ifeq ($(LOCAL_DEV),1)
define Build/Prepare
rsync -r --exclude=.* ~/git/easy-soc-libs/ $(PKG_BUILD_DIR)/
endef
endif
include easy.mk
include wifi.mk
include dsl.mk
include ethernet.mk
include qos.mk
ifneq ($(wildcard $(PKG_BUILD_DIR)/.config_*),\
$(PKG_BUILD_DIR)/.config_$(patsubst "%",%,$(CONFIG_TARGET_PROFILE)))
define Build/Compile/rebuild
$(FIND) $(PKG_BUILD_DIR) -name \*.o -or -name \*.so\* | $(XARGS) rm -f;
$(if $(wildcard $(PKG_BUILD_DIR)/config_*), \
rm -f $(PKG_BUILD_DIR)/.config_*)
endef
endif
STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell echo $(TARGET_CFLAGS) | mkhash md5)
define Build/Compile
$(Build/Compile/rebuild)
touch $(PKG_BUILD_DIR)/.config_$(CONFIG_TARGET_PROFILE)
$(call Build/Compile/Default)
$(foreach dir,$(subdirs),$(call Build/Compile/$(dir)))
endef
define Build/InstallDev
$(foreach dir,$(subdirs),$(call Build/InstallDev/$(dir),$(1),$(2));)
endef
define Package/easy-soc-libs/install
:
endef
$(eval $(foreach e,$(EASY_SOC_LIBS),$(call BuildPackage,$(e))))

44
easy-soc-libs/dsl.mk Normal file
View File

@@ -0,0 +1,44 @@
define Package/libdsl
$(call Package/easy-soc-libs)
TITLE:= xDSL library (libdsl)
endef
define Package/libdsl/config
if PACKAGE_libdsl
config LIBDSL_DEBUG
depends on PACKAGE_libdsl
bool "Enable dsl debugging"
default n
config LIBDSL_TEST
depends on PACKAGE_libdsl
bool "Enable dsl test program"
default n
endif
endef
define Build/InstallDev/libdsl
$(INSTALL_DIR) $(1)/usr/include/xdsl
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libdsl/xdsl.h $(1)/usr/include/xdsl
$(CP) $(PKG_BUILD_DIR)/libdsl/xtm.h $(1)/usr/include/xdsl
$(CP) $(PKG_BUILD_DIR)/libdsl/common.h $(1)/usr/include/xdsl
$(CP) $(PKG_BUILD_DIR)/libdsl/libdsl.so* $(1)/usr/lib/
endef
ifeq ($(CONFIG_LIBDSL_TEST),y)
define Build/Compile/libdsl
$(MAKE) -C "$(PKG_BUILD_DIR)/libdsl/test" $(MAKE_FLAGS)
endef
endif
define Package/libdsl/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_DIR) $(1)/usr/bin
$(CP) $(PKG_BUILD_DIR)/libdsl/libdsl.so* $(1)/usr/lib/
ifeq ($(CONFIG_LIBDSL_TEST),y)
$(CP) $(PKG_BUILD_DIR)/libdsl/test/libdsl_test $(1)/usr/bin/
endif
endef

29
easy-soc-libs/easy.mk Normal file
View File

@@ -0,0 +1,29 @@
define Package/libeasy
$(call Package/easy-soc-libs)
TITLE:= Common helper functions library (libeasy)
DEPENDS+=+libnl +libnl-route
endef
define Package/libeasy/config
source "$(SOURCE)/Config.in"
endef
define Build/InstallDev/libeasy
$(INSTALL_DIR) $(1)/usr/include/easy
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libeasy/easy.h $(1)/usr/include/easy/
$(CP) $(PKG_BUILD_DIR)/libeasy/event.h $(1)/usr/include/easy/
$(CP) $(PKG_BUILD_DIR)/libeasy/utils.h $(1)/usr/include/easy/
$(CP) $(PKG_BUILD_DIR)/libeasy/if_utils.h $(1)/usr/include/easy/
$(CP) $(PKG_BUILD_DIR)/libeasy/debug.h $(1)/usr/include/easy/
$(CP) $(PKG_BUILD_DIR)/libeasy/hlist.h $(1)/usr/include/easy/
$(CP) $(PKG_BUILD_DIR)/libeasy/libeasy*.so* $(1)/usr/lib/
endef
define Package/libeasy/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libeasy/libeasy*.so* $(1)/usr/lib/
endef

27
easy-soc-libs/ethernet.mk Normal file
View File

@@ -0,0 +1,27 @@
define Package/libethernet
$(call Package/easy-soc-libs)
TITLE:= Ethernet library (libethernet)
DEPENDS+=+libnl +libnl-route +libeasy +TARGET_iopsys_ramips:swconfig +TARGET_airoha:ecnt_api
endef
define Package/libethernet/config
config LIBETHERNET_DEBUG
depends on PACKAGE_libethernet
bool "Enable ethernet debugging"
default n
endef
define Build/InstallDev/libethernet
$(INSTALL_DIR) $(1)/usr/include
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libethernet/ethernet.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/libethernet/libethernet.so $(1)/usr/lib/
endef
define Package/libethernet/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libethernet/libethernet.so* $(1)/usr/lib/
endef

27
easy-soc-libs/qos.mk Normal file
View File

@@ -0,0 +1,27 @@
define Package/libqos
$(call Package/easy-soc-libs)
TITLE:= QoS library (libqos)
DEPENDS+=+libnl +libnl-route +libeasy
endef
define Package/libqos/config
config LIBQOS_DEBUG
depends on PACKAGE_libqos
bool "Enable qos debugging"
default n
endef
define Build/InstallDev/libqos
$(INSTALL_DIR) $(1)/usr/include
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libqos/include/qos.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/libqos/libqos.so $(1)/usr/lib/
endef
define Package/libqos/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libqos/libqos*.so* $(1)/usr/lib/
endef

29
easy-soc-libs/wifi.mk Normal file
View File

@@ -0,0 +1,29 @@
define Package/libwifi
$(call Package/easy-soc-libs)
TITLE:= WiFi library (libwifi)
DEPENDS+=+libnl +libnl-route +libeasy +TARGET_brcmbca:bcmkernel
endef
define Package/libwifi/config
if PACKAGE_libdsl
config LIBWIFI_DEBUG
depends on PACKAGE_libwifi
bool "Enable wifi debugging"
default n
endif
endef
define Build/InstallDev/libwifi
$(INSTALL_DIR) $(1)/usr/include
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libwifi/wifi.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/libwifi/libwifi*.so* $(1)/usr/lib/
endef
define Package/libwifi/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libwifi/libwifi*.so* $(1)/usr/lib/
endef

4
endptmngr/Config.in Executable file
View File

@@ -0,0 +1,4 @@
config ENDPT_OPEN
bool "Use pre-compiled version for Open SDK"
default n

69
endptmngr/Makefile Normal file
View File

@@ -0,0 +1,69 @@
#
# Copyright (C) 2018 IOPSYS Software Solutions AB
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=endptmngr
PKG_VERSION:=0.6
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/endptmngr.git
PKG_SOURCE_VERSION:=dc12712af8c4088f7873502ca845e51c68a1ada9
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif
PKG_LICENSE:=PROPRIETARY
PKG_LICENSE_FILES:=LICENSE
export BUILD_DIR
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_BUILD_PARALLEL:=1
# All config variable that are passed to the make invocation, directly or
# indirectly. This ensures that the package is rebuilt on config-changes.
PKG_CONFIG_DEPENDS:=CONFIG_TARGET_BOARD
export CONFIG_BRCM_SDK_VER_504040
export CONFIG_BCM_CHIP_ID
include $(INCLUDE_DIR)/package.mk
define Package/endptmngr/config
source "$(SOURCE)/Config.in"
endef
define Package/endptmngr
CATEGORY:=Utilities
TITLE:=Broadcom Voice Endpoint Manager
URL:=
DEPENDS:= +libubox +ubus +libpicoevent +uci +bcmkernel @TARGET_HAS_VOICE @BCM_VOICE
endef
define Package/endptmngr/description
endptmngr
endef
ifeq ($(LOCAL_DEV),1)
define Build/Prepare
rsync -av --exclude=.* ~/git/endptmngr/* $(PKG_BUILD_DIR)/
endef
endif
TARGET_CFLAGS += \
-Wall \
-Werror
define Package/endptmngr/install
$(CP) ./files/* $(1)/
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/endptmngr $(1)/usr/sbin/
endef
$(eval $(call BuildPackage,endptmngr))

View File

@@ -0,0 +1,27 @@
#!/bin/sh /etc/rc.common
START=68
STOP=12
USE_PROCD=1
NAME=endptmngr
start_service() {
[ "$(db -q get hw.board.hasVoice)" = "1" ] || return
procd_open_instance
procd_set_param env hw_board_hasDect=$(db get hw.board.hasDect)
procd_set_param command $NAME
procd_set_param respawn "5" "0" "3"
procd_set_param nice -12
procd_close_instance
}
reload_service() {
stop
start
}
service_triggers() {
procd_add_reload_trigger asterisk
}

View File

@@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=ethmngr
PKG_VERSION:=2.1.0
PKG_VERSION:=2.0.1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=5a0ff3bc7c49dcb05129f423ef8e0c4929f6aa03
@@ -23,7 +23,7 @@ define Package/ethmngr
SECTION:=utils
CATEGORY:=Utilities
TITLE:=Ethernet status and configration utility
DEPENDS:=+(TARGET_brcmbca||TARGET_airoha||TARGET_ipq95xx||TARGET_iopsys_mediatek):libethernet +libuci +libubox +ubus +libpthread +libnl-genl
DEPENDS:=+libethernet +libuci +libubox +ubus +libpthread +libnl-genl
endef
define Package/ethmngr/description
@@ -37,22 +37,10 @@ TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include/libnl3 \
-D_GNU_SOURCE
ifeq ($(CONFIG_TARGET_brcmbca)$(CONFIG_TARGET_airoha)$(CONFIG_TARGET_ipq95xx)$(CONFIG_TARGET_iopsys_mediatek),)
define Build/Compile
endef
endif
define Package/ethmngr/install
$(CP) ./files/common/* $(1)/
ifneq ($(CONFIG_TARGET_brcmbca),)
$(CP) ./files/broadcom/* $(1)/
else
$(CP) ./files/linux/* $(1)/
endif
ifneq ($(CONFIG_TARGET_brcmbca)$(CONFIG_TARGET_airoha)$(CONFIG_TARGET_ipq95xx)$(CONFIG_TARGET_iopsys_mediatek),)
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/etc/init.d $(1)/usr/sbin
$(INSTALL_BIN) ./files/ethmngr.init $(1)/etc/init.d/ethmngr
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ethmngr $(1)/usr/sbin/
endif
endef
$(eval $(call BuildPackage,ethmngr))

View File

@@ -1,149 +0,0 @@
# arg1: port ifname, ex: eth0
get_max_port_speed() {
if [ -z "$1" ]; then
echo 0
return
fi
local ifname="$1"
local phycap="$(ethctl $ifname media-type 2>/dev/null | grep 'PHY Capabilities' | awk '{print$NF}' | cut -d'|' -f1)"
local speed=1000
case "$phycap" in
10GFD) speed=10000 ;;
5GFD) speed=5000 ;;
2.5GFD) speed=2500 ;;
1GFD|1GHD) speed=1000 ;;
100MFD|100MHD) speed=100 ;;
10MFD|10MHD) speed=10 ;;
esac
echo $speed
}
# arg1: port name, ex: eth0
get_port_number() {
[ -z "$1" ] && return
local ports="0 1 2 3 4 5 6 7 8"
local units="0 1"
local port="$1"
local ifname
for unit in $units; do
for prt in $ports; do
ifname="$(ethswctl getifname $unit $prt 2>/dev/null | awk '{print$NF}')"
if [ "$ifname" == "$port" ]; then
echo "$unit $prt"
return
fi
done
done
}
# arg1: port ifname, ex: eth0
reset_port() {
local ifname="$1"
ethctl $ifname phy-reset >/dev/null
}
# arg1: port ifname, ex: eth0
# arg2: port enabled, ex: 1
power_updown() {
local ifname="$1"
local enabled=$2
local updown="up"
[ $enabled -eq 0 ] && updown="down"
ethctl $ifname phy-power $updown >/dev/null
}
# arg1: port ifname, ex: eth0
# arg2: port enabled, ex: 1
# arg3: port speed, ex: 1000
# arg4: port duplex, ex: full
# arg5: port autoneg, ex: on
# arg6: port eee, ex: 0
# arg7: port pause, ex: 0
set_port_settings() {
local ifname="$1"
local enabled=$2
local speed="$3"
local duplex=$4
local autoneg=$5
local eee=$6
local pause=$7
[ -d /sys/class/net/$ifname ] || return
local unitport="$(get_port_number $ifname)"
local unit=$(echo $unitport | cut -d ' ' -f 1)
local port=$(echo $unitport | cut -d ' ' -f 2)
[ $autoneg -eq 1 ] && autoneg="on" || autoneg="off"
[ "$duplex" == "half" ] && duplex=0 || duplex=1
[ "$duplex" == 0 ] && dplx="HD" || dplx="FD"
[ "$autoneg" == "on" ] && media_type="auto" || media_type="$speed$dplx"
phycrossbar="$(ethctl $ifname phy-crossbar | head -1)"
crossbartype="$(echo $phycrossbar | awk '{print$2$3}')"
# Take only the last PHY Endpoint (non-Serdes) into account as Serdes port number precedes
[ "$crossbartype" == "oncrossbar" ] && pyhendpoint="$(echo $phycrossbar | awk '{print$NF}')"
phycaps="$(ethctl $ifname media-type ${pyhendpoint:+ port $pyhendpoint} | awk -F'PHY Capabilities: ' '{print$2}')"
numofcaps="$(echo $phycaps | tr '|' ' ' | wc -w)"
# Reset the port before setting new params
reset_port $ifname
if [ "$numofcaps" == "1" ]; then
logger -t "port-management" "$ifname is capable of $phycaps only; not setting speed/duplex"
else
logger -t "port-management" "$ifname is capable of $phycaps; setting speed/duplex to $media_type"
ethctl $ifname media-type $media_type ${pyhendpoint:+ port $pyhendpoint} &>/dev/null
fi
[ $eee -eq 1 ] && eee="on" || eee="off"
ethtool --set-eee $ifname eee $eee 2>/dev/null
case $pause in
off|0)
pause=0x0
auto=off
rx=off
tx=off
;;
on|1)
pause=0x2
auto=off
rx=on
tx=on
;;
auto)
pause=0x1
auto=on
rx=on
tx=on
;;
tx)
pause=0x3
auto=off
rx=off
tx=on
;;
rx)
pause=0x4
auto=off
rx=on
tx=off
;;
esac
if [ "$auto" == "on" ]; then
# Use ethswctl utility to set pause autoneg
# as ethtool is not setting it properly
ethswctl -c pause -n $unit -p $port -v $pause 2>&1 >/dev/null
else
ethtool --pause $ifname autoneg $auto rx $rx tx $tx 2>/dev/null
fi
power_updown $ifname $enabled
}

View File

@@ -0,0 +1,19 @@
#!/bin/sh /etc/rc.common
START=95
STOP=10
USE_PROCD=1
PROG=/usr/sbin/ethmngr
start_service() {
procd_open_instance
procd_set_param command ${PROG}
procd_set_param respawn
procd_close_instance
}
reload_service() {
stop
start
}

View File

@@ -1,95 +0,0 @@
# arg1: port ifname, ex: eth0
get_max_port_speed() {
if [ -z "$1" ]; then
echo 0
return
fi
local ifname="$1"
local phycap="$(ethtool $ifname | grep -A 10 "Supported link modes" | grep 00 | tail -n 1 | awk '{print$NF}')"
local speed=1000
case "$phycap" in
10000*) speed=10000 ;;
5000*) speed=5000 ;;
2500*) speed=2500 ;;
1000*) speed=1000 ;;
100*) speed=100 ;;
10*) speed=10 ;;
esac
echo $speed
}
# arg1: port ifname, ex: eth0
# arg2: port enabled, ex: 1
power_updown() {
local ifname="$1"
local enabled=$2
local updown="up"
[ $enabled -eq 0 ] && updown="down"
ip link set dev $ifname $updown
}
# arg1: port ifname, ex: eth0
# arg2: port enabled, ex: 1
# arg3: port speed, ex: 1000
# arg4: port duplex, ex: full
# arg5: port autoneg, ex: on
# arg6: port eee, ex: 0
# arg7: port pause, ex: 0
set_port_settings() {
local ifname="$1"
local enabled=$2
local speed="$3"
local duplex=$4
local autoneg=$5
local eee=$6
local pause=$7
[ -d /sys/class/net/$ifname ] || return
[ $autoneg -eq 1 ] && autoneg="on" || autoneg="off"
ethtool --change $ifname speed $speed duplex $duplex autoneg $autoneg
[ $eee -eq 1 ] && eee="on" || eee="off"
ethtool --set-eee $ifname eee $eee 2>/dev/null
case $pause in
off|0)
pause=0x0
auto=off
rx=off
tx=off
;;
on|1)
pause=0x2
auto=off
rx=on
tx=on
;;
auto)
pause=0x1
auto=on
rx=on
tx=on
;;
tx)
pause=0x3
auto=off
rx=off
tx=on
;;
rx)
pause=0x4
auto=off
rx=on
tx=off
;;
esac
ethtool --pause $ifname autoneg $auto rx $rx tx $tx 2>/dev/null
power_updown $ifname $enabled
}

View File

@@ -220,6 +220,7 @@ static int canyon_led_probe(struct platform_device *pdev)
if (IS_ERR(leds->clock_gpio)) {
dev_err(&pdev->dev, "Failed to acquire clock GPIO %ld\n",
PTR_ERR(leds->clock_gpio));
leds->clock_gpio = NULL;
return PTR_ERR(leds->clock_gpio);
}
@@ -227,6 +228,7 @@ static int canyon_led_probe(struct platform_device *pdev)
if (IS_ERR(leds->clock_gpio)) {
dev_err(&pdev->dev, "Failed to acquire clock GPIO %ld\n",
PTR_ERR(leds->clock_gpio));
leds->clock_gpio = NULL;
return PTR_ERR(leds->clock_gpio);
} else {
printk(KERN_INFO "Got clock gpio\n");
@@ -244,6 +246,7 @@ static int canyon_led_probe(struct platform_device *pdev)
if (IS_ERR(leds->data_gpio)) {
dev_err(&pdev->dev, "Failed to acquire data GPIO %ld\n",
PTR_ERR(leds->data_gpio));
leds->data_gpio = NULL;
return PTR_ERR(leds->data_gpio);
}
@@ -251,6 +254,7 @@ static int canyon_led_probe(struct platform_device *pdev)
if (IS_ERR(leds->data_gpio)) {
dev_err(&pdev->dev, "Failed to acquire data GPIO %ld\n",
PTR_ERR(leds->data_gpio));
leds->data_gpio = NULL;
return PTR_ERR(leds->data_gpio);
} else {
printk(KERN_INFO "Got data gpio\n");

View File

@@ -1,5 +1,5 @@
#
# Copyright (C) 2020-2023 IOPSYS Software Solutions AB
# Copyright (C) 2020-2022 IOPSYS Software Solutions AB
#
# This is free software, licensed under the BSD-3-Clause
# See /LICENSE for more information.
@@ -8,11 +8,11 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=icwmp
PKG_VERSION:=9.3.2
PKG_VERSION:=9.1.4
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/icwmp.git
PKG_SOURCE_VERSION:=a68417ec44251e9f619f2682618b06dae083bd32
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/icwmp.git
PKG_SOURCE_VERSION:=fb8b5b9da6cadd53a3d12e27af0ed800b149a9f2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
@@ -29,44 +29,33 @@ define Package/icwmp/default
CATEGORY:=Utilities
SUBMENU:=TRx69
TITLE:=TR069 CWMP client
DEPENDS:=+libuci +libubox +libblobmsg-json +libubus +libjson-c +libcurl +mxml +libuuid +libbbfdm-api
endef
define Package/icwmp
$(Package/icwmp/default)
VARIANT:=default
DEFAULT_VARIANT:=1
DEPENDS += +PACKAGE_icwmp-openssl:libopenssl
DEPENDS:=+libuci +libubox +libblobmsg-json +libubus +libjson-c +libcurl +mxml +libuuid
endef
define Package/icwmp-openssl
$(Package/icwmp/default)
TITLE += (openssl)
VARIANT:=openssl
DEPENDS += +PACKAGE_icwmp-openssl:libopenssl
CONFLICTS := icwmp icwmp-mbedtls icwmp-wolfssl
VARIANT:=openssl
endef
define Package/icwmp-wolfssl
$(Package/icwmp/default)
TITLE += (wolfssl)
VARIANT:=wolfssl
DEPENDS += +PACKAGE_icwmp-wolfssl:libwolfssl
CONFLICTS := icwmp icwmp-mbedtls icwmp-openssl
CONFLICTS := icwmp-openssl
VARIANT:=wolfssl
endef
define Package/icwmp-mbedtls
$(Package/icwmp/default)
TITLE += (mbedtls)
DEPENDS += +PACKAGE_icwmp-mbedtls:libmbedtls
CONFLICTS := icwmp-openssl icwmp-wolfssl
VARIANT:=mbedtls
CONFLICTS := icwmp icwmp-wolfssl icwmp-openssl
DEFAULT_VARIANT:=1
endef
ifeq ($(BUILD_VARIANT),default)
CMAKE_OPTIONS += -DWITH_OPENSSL=ON
endif
ifeq ($(BUILD_VARIANT),openssl)
CMAKE_OPTIONS += -DWITH_OPENSSL=ON
endif
@@ -95,8 +84,6 @@ define Package/icwmp/default/install
$(INSTALL_DIR) $(1)/lib/upgrade/keep.d
$(INSTALL_DIR) $(1)/etc/bbfdm/json/
$(INSTALL_DIR) $(1)/etc/udhcpc.user.d
$(INSTALL_DIR) $(1)/usr/lib/bbfdm
$(INSTALL_BIN) $(PKG_BUILD_DIR)/libcwmpdm.so $(1)/usr/lib/bbfdm/libcwmpdm.so
$(INSTALL_BIN) $(PKG_BUILD_DIR)/icwmpd $(1)/usr/sbin/icwmpd
$(INSTALL_DATA) ./files/etc/config/cwmp $(1)/etc/config/cwmp
$(INSTALL_BIN) ./files/etc/firewall.cwmp $(1)/etc/firewall.cwmp
@@ -106,16 +93,13 @@ define Package/icwmp/default/install
$(INSTALL_DATA) ./files/lib/upgrade/keep.d/icwmp $(1)/lib/upgrade/keep.d/icwmp
$(INSTALL_BIN) ./files/etc/icwmpd/update.sh $(1)/etc/icwmpd/update.sh
$(INSTALL_DATA) ./files/etc/bbfdm/json/CWMPManagementServer.json $(1)/etc/bbfdm/json/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/files/etc/udhcpc.user.d/udhcpc_icwmp_opt125.user $(1)/etc/udhcpc.user.d/udhcpc_icwmp_opt125.user
$(INSTALL_BIN) $(PKG_BUILD_DIR)/files/etc/udhcpc.user.d/udhcpc_icwmp_opt43.user $(1)/etc/udhcpc.user.d/udhcpc_icwmp_opt43.user
$(INSTALL_BIN) ./files/etc/udhcpc.user.d/udhcpc_icwmp.user $(1)/etc/udhcpc.user.d/udhcpc_icwmp.user
endef
Package/icwmp/install = $(Package/icwmp/default/install)
Package/icwmp-openssl/install = $(Package/icwmp/default/install)
Package/icwmp-wolfssl/install = $(Package/icwmp/default/install)
Package/icwmp-mbedtls/install = $(Package/icwmp/default/install)
$(eval $(call BuildPackage,icwmp))
$(eval $(call BuildPackage,icwmp-openssl))
$(eval $(call BuildPackage,icwmp-wolfssl))
$(eval $(call BuildPackage,icwmp-mbedtls))

View File

@@ -11,6 +11,8 @@ config acs 'acs'
option retry_min_wait_interval '5'
#­ possible configs interval :[1000:65535]
option retry_interval_multiplier '2000'
option ipv6_enable '0'
option ip_version '4'
config cpe 'cpe'
option enable '1'
@@ -36,7 +38,6 @@ config cpe 'cpe'
option periodic_notify_enable '1'
option periodic_notify_interval '10'
option incoming_rule 'Port_Only'
option active_notif_throttle '0'
config lwn 'lwn'
option enable '1'

View File

@@ -20,13 +20,13 @@ if [ -z "${zone_name}" ]; then
exit 0
elif [ "$zone_name" = "icwmp" ]; then
iptables -nL zone_icwmp_input 2> /dev/null
if [ "$?" != 0 ]; then
if [ $? != 0 ]; then
iptables -w 1 -N zone_icwmp_input
iptables -w 1 -t filter -A INPUT -j zone_icwmp_input
iptables -w 1 -I zone_icwmp_input -p tcp --dport "${port}" -j REJECT
iptables -w 1 -I zone_icwmp_input -p tcp --dport $port -j REJECT
else
iptables -w 1 -F zone_icwmp_input
iptables -w 1 -I zone_icwmp_input -p tcp --dport "${port}" -j REJECT
iptables -w 1 -I zone_icwmp_input -p tcp --dport $port -j REJECT
fi
else
iptables -w 1 -F zone_icwmp_input 2> /dev/null
@@ -64,13 +64,13 @@ else
fi
fi
echo "${cmd}"|grep -q "\-\-dport \|\-s "
echo ${cmd}|grep -q "\-\-dport \|\-s "
if [ "$?" -eq 0 ]; then
cmd="${cmd} -j ACCEPT -m comment --comment=Open_ACS_port"
${cmd}
fi
echo "${cmd6}"|grep -q "\-\-dport \|\-s "
echo ${cmd6}|grep -q "\-\-dport \|\-s "
if [ "$?" -eq 0 ]; then
cmd6="${cmd6} -j ACCEPT -m comment --comment=Open_ACS_port"
${cmd6}

View File

@@ -16,7 +16,7 @@ handle_icwmp_update() {
ret=$(ubus call service list '{"name":"icwmpd"}' | jsonfilter -qe '@.icwmpd.instances.icwmp.running')
if [ "$ret" = "true" ]; then
if [ "$ret" == "true" ]; then
# read status from var/state/cwmp
status=$(uci -q -c /var/state get cwmp.sess_status.current_status)
if [ "$status" != "running" ]; then
@@ -29,4 +29,4 @@ handle_icwmp_update() {
fi
}
handle_icwmp_update "$@"
handle_icwmp_update $@

View File

@@ -23,22 +23,22 @@ regenerate_ssl_link()
[ ! -d "${cert_dir}" ] && return 0;
### Generate all ssl link for pem certicates ###
all_file=$(ls "${cert_dir}"/*.pem 2>/dev/null)
all_file=$(ls $cert_dir/*.pem 2>/dev/null)
if [ -n "${all_file}" ]; then
for cfile in $all_file; do
rehash="$(openssl x509 -hash -noout -in "${cfile}")"
[ -f "${cert_dir}"/"${rehash}".0 ] || \
ln -s "${cfile}" "${cert_dir}"/"${rehash}".0
rehash="$(openssl x509 -hash -noout -in $cfile)"
[ -f ${cert_dir}/${rehash}.0 ] || \
ln -s $cfile $cert_dir/${rehash}.0
done
fi
### Generate all ssl link for crt certicates ###
all_file=$(ls "${cert_dir}"/*.crt 2>/dev/null)
all_file=$(ls $cert_dir/*.crt 2>/dev/null)
if [ -n "${all_file}" ]; then
for cfile in $all_file; do
rehash="$(openssl x509 -hash -noout -in "${cfile}")"
[ -f "${cert_dir}"/"${rehash}".0 ] || \
ln -s "${cfile}" "${cert_dir}"/"${rehash}".0
rehash="$(openssl x509 -hash -noout -in $cfile)"
[ -f ${cert_dir}/${rehash}.0 ] || \
ln -s $cfile $cert_dir/${rehash}.0
done
fi
}
@@ -47,8 +47,8 @@ enable_dhcp_option43() {
local wan="${1}"
### Ask for DHCP Option 43 only if CWMP is enabled ###
local reqopts="$(uci -q get network."${wan}".reqopts)"
local proto="$(uci -q get network."${wan}".proto)"
local reqopts="$(uci -q get network.$wan.reqopts)"
local proto="$(uci -q get network.$wan.proto)"
local newreqopts=""
local option43_present=0
@@ -64,8 +64,8 @@ enable_dhcp_option43() {
fi
newreqopts="$reqopts 43"
if [ "${proto}" = "dhcp" ]; then
uci -q set network."${wan}".reqopts="$newreqopts"
if [ "${proto}" == "dhcp" ]; then
uci -q set network.$wan.reqopts="$newreqopts"
uci commit network
ubus call network reload
fi
@@ -122,12 +122,12 @@ configure_send_op125() {
serial_len=$(echo -n "${serial}" | wc -m)
class_len=$(echo -n "${class}" | wc -m)
if [ "${oui_len}" -eq 0 ] || [ "${serial_len}" -eq 0 ]; then
if [ ${oui_len} -eq 0 ] || [ ${serial_len} -eq 0 ]; then
return 0
fi
opt125_len=$((oui_len + serial_len + class_len))
if [ "${class_len}" -gt 0 ]; then
if [ ${class_len} -gt 0 ]; then
opt125_len=$((opt125_len + 6))
else
opt125_len=$((opt125_len + 4))
@@ -159,7 +159,7 @@ configure_send_op125() {
opt125="${opt125}:05:${hex_serial_len}${hex_serial}"
fi
if [ "${class_len}" -gt 0 ]; then
if [ ${class_len} -gt 0 ]; then
hex_class=$(convert_to_hex "${class}")
if [ -z "${hex_class}" ]; then
return 0
@@ -176,9 +176,9 @@ configure_send_op125() {
if [ "${uci}" = "network" ]; then
new_send_opt="$sendopt $opt125"
uci -q set network."${intf}".sendopts="$new_send_opt"
uci -q set network.$intf.sendopts="$new_send_opt"
else
uci -q add_list dhcp."${intf}".dhcp_option="$opt125"
uci -q add_list dhcp.$intf.dhcp_option="$opt125"
fi
}
@@ -187,9 +187,9 @@ enable_dnsmasq_option125() {
local send125_present=0
local opt125="125,"
local proto="$(uci -q get dhcp."${lan}".dhcpv4)"
local proto="$(uci -q get dhcp.$lan.dhcpv4)"
if [ "${proto}" = "server" ]; then
opt_list="$(uci -q get dhcp."${lan}".dhcp_option)"
opt_list="$(uci -q get dhcp.$lan.dhcp_option)"
for sopt in $opt_list; do
if [[ "$sopt" == "$opt125"* ]]; then
@@ -205,27 +205,13 @@ enable_dnsmasq_option125() {
fi
}
set_vendor_id() {
enable_disable_dhcp_option125() {
local wan="${1}"
local proto="$(uci -q get network."${wan}".proto)"
local action="${2}"
if [ "${proto}" = "dhcp" ]; then
vendorid="$(uci -q get network."${wan}".vendorid)"
if [ -z "${vendorid}" ]; then
uci -q set network."${wan}".vendorid="dslforum.org"
ubus call uci commit '{"config":"network"}'
elif [[ $vendorid != *"dslforum.org"* ]]; then
uci -q set network."${wan}".vendorid="${vendorid},dslforum.org"
ubus call uci commit '{"config":"network"}'
fi
fi
}
enable_dhcp_option125() {
local wan="${1}"
local reqopts="$(uci -q get network."${wan}".reqopts)"
local sendopts="$(uci -q get network."${wan}".sendopts)"
local proto="$(uci -q get network."${wan}".proto)"
local reqopts="$(uci -q get network.$wan.reqopts)"
local sendopts="$(uci -q get network.$wan.sendopts)"
local proto="$(uci -q get network.$wan.proto)"
local newreqopts=""
local newsendopts=""
local req125_present=0
@@ -247,16 +233,35 @@ enable_dhcp_option125() {
fi
done
if [ "${proto}" = "dhcp" ]; then
if [ ${req125_present} -eq 0 ]; then
newreqopts="$reqopts 125"
uci -q set network."${wan}".reqopts="$newreqopts"
network_uci_update=1
fi
if [ "${proto}" == "dhcp" ]; then
if [ "${action}" == "enable" ]; then
if [ ${req125_present} -eq 0 ]; then
newreqopts="$reqopts 125"
uci -q set network.$wan.reqopts="$newreqopts"
network_uci_update=1
fi
if [ ${send125_present} -eq 0 ]; then
configure_send_op125 "${sendopts}" "${wan}" "network"
network_uci_update=1
if [ ${send125_present} -eq 0 ]; then
configure_send_op125 "${sendopts}" "${wan}" "network"
network_uci_update=1
fi
else
if [ ${req125_present} -eq 1 ]; then
newreqopts=$(echo ${reqopts/125/})
uci -q set network.$wan.reqopts="$newreqopts"
network_uci_update=1
fi
if [ ${send125_present} -eq 1 ]; then
for sopt in $sendopts; do
if [[ "$sopt" == "$opt125"* ]]; then
newsendopts=$(echo ${sendopts/"${sopt}"/})
uci -q set network.$wan.sendopts="$newreqopts"
network_uci_update=1
break
fi
done
fi
fi
fi
@@ -283,6 +288,13 @@ wait_for_resolvfile() {
copy_cwmp_etc_files_to_varstate() {
mkdir -p /var/run/icwmpd
if [ -f /etc/icwmpd/cwmp ]; then
uci -q -c /etc/icwmpd delete cwmp.acs
uci -q -c /etc/icwmpd delete cwmp.gatewayinfo
uci -q -c /etc/icwmpd commit cwmp
cat /etc/icwmpd/cwmp >> /var/state/cwmp
fi
if [ -f /etc/icwmpd/icwmpd_backup_session.xml ]; then
cp -f /etc/icwmpd/icwmpd_backup_session.xml /var/run/icwmpd/ 2>/dev/null
fi
@@ -301,6 +313,12 @@ copy_cwmp_varstate_files_to_etc() {
cp -f /var/run/icwmpd/dm_enabled_notify /etc/icwmpd/ 2>/dev/null
fi
if [ -f /var/state/cwmp ]; then
uci -q -c /var/state delete cwmp.sess_status
uci -q -c /var/state commit cwmp
cp -f /var/state/cwmp /etc/icwmpd/
fi
# move the successful custom notify import marker to persistent storage
if [ -f /var/run/icwmpd/icwmpd_notify_import_marker ]; then
cp -f /var/run/icwmpd/icwmpd_notify_import_marker /etc/icwmpd/
@@ -320,6 +338,7 @@ validate_acs_section()
'compression:or("GZIP","Deflate","Disabled")' \
'retry_min_wait_interval:range(1, 65535)' \
'retry_interval_multiplier:range(1000, 65535)' \
'ipv6_enable:bool' \
'ssl_capath:string'
}
@@ -376,33 +395,25 @@ validate_defaults() {
}
boot() {
local enable_cwmp="0"
local dhcp_discovery="0"
config_load cwmp
config_get_bool enable_cwmp cpe enable 1
local wan_interface=""
config_get wan_interface cpe default_wan_interface "wan"
if [ "$enable_cwmp" = "0" ]; then
return 0
fi
config_get dhcp_discovery acs dhcp_discovery "0"
if [ "${dhcp_discovery}" = "enable" ] || [ "${dhcp_discovery}" = "1" ]; then
config_get wan_interface cpe default_wan_interface "wan"
if [ "${dhcp_discovery}" == "enable" ] || [ "${dhcp_discovery}" == "1" ]; then
# Set dhcp option 43 if not already configured
enable_dhcp_option43 "${wan_interface}"
# Set dhcp option 60
set_vendor_id "${wan_interface}"
fi
config_get lan_interface cpe default_lan_interface ""
if [ -n "${lan_interface}" ]; then
# Set dhcp_option 125 if not already configured
enable_dhcp_option125 "${wan_interface}"
enable_disable_dhcp_option125 "${wan_interface}" "enable"
enable_dnsmasq_option125 "${lan_interface}"
else
# Remove dhcp option 125 if exists
enable_disable_dhcp_option125 "${wan_interface}" "disable"
fi
config_get ssl_capath acs ssl_capath
@@ -411,10 +422,8 @@ boot() {
regenerate_ssl_link "${ssl_capath}"
fi
# Copy backup data so that if it restart latter on, it gets the info
# Copy backup data so that if it restart latter on it gets the info
copy_cwmp_etc_files_to_varstate
mkdir -p /var/run/icwmpd/
touch /var/run/icwmpd/cwmp
start
}
@@ -449,6 +458,11 @@ start_service() {
procd_close_instance
}
service_stopped()
{
copy_cwmp_varstate_files_to_etc
}
stop_service()
{
copy_cwmp_varstate_files_to_etc
@@ -474,7 +488,7 @@ reload_service() {
return 0
fi
status="$(echo "${tr069_status}" | jsonfilter -qe '@.cwmp.status')"
status="$(echo $tr069_status | jsonfilter -qe '@.cwmp.status')"
ret="$?"
if [ "$status" = "up" ]; then
ubus -t 1 call tr069 command '{"command":"reload"}'

View File

@@ -0,0 +1,133 @@
#!/bin/sh
. /lib/functions.sh
CLASS=""
OUI=""
SERIAL=""
get_vivsoi() {
# opt125 environment variable has data in below format
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
# | enterprise-number1 |
# | |
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
# | data-len1 | |
# +-+-+-+-+-+-+-+-+ option-data1 |
# / /
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -----
# | enterprise-number2 | ^
# | | |
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
# | data-len2 | | optional
# +-+-+-+-+-+-+-+-+ option-data2 | |
# / / |
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
# ~ ... ~ V
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -----
# Enterprise Id Len Sub Op SLen Data Sub Op SLen Data Sub Op SLen Data
# +-------------+-----+------+------+----+------+-----+----+-----+------+-----+----+
# | id | n | 1 | n1 | D1 | 2 | n2 | D2 | ... | 6 | n6 | D6 |
# +-------------+-----+------+------+----+------+-----+----+-----+------+-----+----+
local opt125="$1"
local len="$2"
local ent_id
#hex-string 2 character=1 Byte
# length in hex string will be twice of actual Byte length
[ "$len" -gt "8" ] || return
data="${opt125}"
rem_len="${len}"
while [ $rem_len -gt 0 ]; do
ent_id=${data:0:8}
ent_id=$(printf "%d\n" "0x$ent_id")
if [ $ent_id -ne 3561 ]; then
len_val=${data:8:2}
data_len=$(printf "%d\n" "0x$len_val")
# add 4 byte for ent_id and 1 byte for len
data_len=$(( data_len * 2 + 10 ))
# move ahead data to next enterprise id
data=${data:"${data_len}":"${rem_len}"}
rem_len=$(( rem_len - $data_len ))
continue
fi
# read the length of enterprise data
len_val=${data:8:2}
opt_len=$(printf "%d\n" "0x$len_val")
[ $opt_len -eq 0 ] && return
# populate the option data of enterprise id
sub_data_len=$(( opt_len * 2))
# starting 10 means ahead of length field
sub_data=${data:10:"${sub_data_len}"}
# parsing of suboption of option 125
while [ $sub_data_len -gt 0 ]; do
# get the suboption id
sub_opt_id=${sub_data:0:2}
sub_opt_id=$(printf "%d\n" "0x$sub_opt_id")
# get the length of suboption
sub_opt_len=${sub_data:2:2}
sub_opt_len=$(printf "%d\n" "0x$sub_opt_len")
sub_opt_len=$(( sub_opt_len * 2 ))
# get the value of sub option starting 4 means starting after length
sub_opt_val=${sub_data:4:${sub_opt_len}}
# assign the value found in sub option
case "${sub_opt_id}" in
"4") OUI=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
;;
"5") SERIAL=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
;;
"6") CLASS=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
;;
esac
# add 2 bytes for sub_opt id and sub_opt len field
sub_opt_end=$(( sub_opt_len + 4 ))
# fetch next sub option hex string
sub_data=${sub_data:${sub_opt_end}:${sub_data_len}}
# update the remaining sub option hex string length
sub_data_len=$((sub_data_len - sub_opt_end))
done
break
done
}
config_load cwmp
config_get_bool enable_cwmp cpe enable 1
config_get wan_intf cpe default_wan_interface "wan"
if [ "$enable_cwmp" = "0" ]; then
return 0
fi
if [ "${wan_intf}" == "${INTERFACE}" ]; then
if [ -n "$opt125" ]; then
len=$(printf "$opt125"|wc -c)
get_vivsoi "$opt125" "$len"
fi
mkdir -p /var/state
touch /var/state/cwmp
sec=$(uci -q -c /var/state get cwmp.gatewayinfo)
if [ -z "${sec}" ]; then
sec=$(uci -q -c /var/state add cwmp gatewayinfo)
uci -q -c /var/state rename cwmp."${sec}"="gatewayinfo"
fi
uci -q -c /var/state set cwmp.gatewayinfo.class="$CLASS"
uci -q -c /var/state set cwmp.gatewayinfo.oui="$OUI"
uci -q -c /var/state set cwmp.gatewayinfo.serial="$SERIAL"
uci -q -c /var/state commit cwmp
fi

View File

@@ -5,13 +5,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=ieee1905
PKG_VERSION:=8.0.15
PKG_VERSION:=6.0.21
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=1717f97c054c232d393c91fa7e95a571bf893680
PKG_SOURCE_URL:=https://dev.iopsys.eu/multi-ap/ieee1905.git
PKG_SOURCE_VERSION:=29f58120eea9bf3c48fae98a74f0f4c9d3d902a8
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/ieee1905.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip
endif

View File

@@ -18,7 +18,12 @@ start_service() {
procd_close_instance
}
stop() {
service_stop imonitor
}
reload_service() {
stop
start
}

View File

@@ -56,8 +56,8 @@ CONFIG_LOCALMIRROR="https://download.iopsys.eu/iopsys/mirror/"
# EasySoC HAL #
CONFIG_PACKAGE_inbd=y
CONFIG_PACKAGE_qosmngr=y
CONFIG_PACKAGE_libwifiutils=y
CONFIG_PACKAGE_libwifi=y
CONFIG_PACKAGE_port-management=y
CONFIG_PACKAGE_wifimngr=y
# Multi-AP #
@@ -65,7 +65,7 @@ CONFIG_PACKAGE_ieee1905=y
CONFIG_PACKAGE_map-agent=m
CONFIG_PACKAGE_map-controller=m
CONFIG_PACKAGE_map-topology=y
CONFIG_PACKAGE_decollector=y
CONFIG_PACKAGE_wfadatad-collector=y
# Network #
CONFIG_PACKAGE_netmode=y
@@ -79,13 +79,12 @@ CONFIG_PACKAGE_rulengd=y
CONFIG_PACKAGE_usermngr=y
# TR-x69 #
CONFIG_PACKAGE_libbbfdm=y
CONFIG_PACKAGE_bbfdmd=y
CONFIG_PACKAGE_icwmp=y
CONFIG_PACKAGE_uspd-mbedtls=y
CONFIG_PACKAGE_icwmp-mbedtls=y
CONFIG_PACKAGE_obuspa=y
CONFIG_PACKAGE_bulkdata=y
CONFIG_PACKAGE_periodicstats=y
CONFIG_PACKAGE_stunc=m
CONFIG_PACKAGE_stunc-mbedtls=m
CONFIG_PACKAGE_swmodd=m
CONFIG_PACKAGE_twamp=m
CONFIG_PACKAGE_udpecho-client=m
@@ -109,8 +108,6 @@ CONFIG_PACKAGE_comgt=y
CONFIG_PACKAGE_comgt-directip=y
CONFIG_PACKAGE_comgt-ncm=y
CONFIG_PACKAGE_ds-lite=y
CONFIG_PACKAGE_firewall=y
# CONFIG_PACKAGE_firewall4 is not set
CONFIG_PACKAGE_gre=y
CONFIG_PACKAGE_map=y
CONFIG_PACKAGE_ntfs-3g=y
@@ -134,7 +131,7 @@ CONFIG_PACKAGE_atftp=m
CONFIG_PACKAGE_atftpd=m
CONFIG_PACKAGE_ddns-scripts=y
CONFIG_PACKAGE_dnsmasq=y
CONFIG_PACKAGE_ssdpd=y
CONFIG_PACKAGE_miniupnpd-iptables=y
CONFIG_PACKAGE_mosquitto-client-ssl=y
CONFIG_PACKAGE_mosquitto-ssl=y
CONFIG_PACKAGE_nginx=y
@@ -306,3 +303,10 @@ CONFIG_BUSYBOX_CONFIG_FEATURE_VOLUMEID_SQUASHFS=y
CONFIG_BUSYBOX_CONFIG_FEATURE_VOLUMEID_UBIFS=y
CONFIG_BUSYBOX_CONFIG_TIMEOUT=y
CONFIG_BUSYBOX_CONFIG_NOHUP=y
# Use fw3 iptables-based instead of newer nftables-based fw4
# TODO: for now we cannot build an image with fw3 and luci-app-firewall (i.e. fw3)
# Enabling luci-app-firewall enables fw4
# CONFIG_PACKAGE_luci-app-firewall is not set
CONFIG_PACKAGE_firewall=y
# CONFIG_PACKAGE_firewall4 is not set

View File

@@ -30,18 +30,23 @@ function feeds_update {
./scripts/feeds install -f -p openwrt_core -a
fi
(
echo '# DO NOT EDIT. Autogenerated file by ./iop feeds_update'
echo 'FEED_DEVICES_DIRS:='
find feeds -type f -name .is-feed-devices-dir -printf 'FEED_DEVICES_DIRS+=$(TOPDIR)/%h'
) > target/linux/feed-devices/feed-devices-list.mk
# targets need to be installed explicitly
for target in $(ls ./feeds/targets); do
rm -f target/linux/$target
./scripts/feeds install -p targets $target
done
# Workaround for bug in 22.03.0-rc4 where installed target path has been
# moved to target/linux/feeds but Config.in and Makefile from installed
# targets are not properly included from the new location.
# This hack is to be removed once the issues are fixed.
# Note that the above block of code might no longer necessary because
# targets no longer need to be installed explicitly.
echo "Working around installed-target-bug"
for f in target/linux/feeds/*; do
ln -vsf "feeds/$(basename "$f")" "target/linux/$(basename "$f")"
done
# install all packages
./scripts/feeds install -a

View File

@@ -14,6 +14,7 @@ function genconfig {
target="bogus"
target_config_path=""
brcmbca_feed="target/linux/feeds/brcmbca"
ramips_feed="target/linux/feeds/iopsys-ramips"
airoha_feed="target/linux/feeds/airoha"
x86_feed="target/linux/feeds/iopsys-x86"
armvirt_feed="target/linux/feeds/iopsys-armvirt"
@@ -110,6 +111,8 @@ function genconfig {
[ -e $brcmbca_feed/genconfig ] &&
brcmbca=$(cd $brcmbca_feed; ./genconfig)
[ -e $ramips_feed/genconfig ] &&
iopsys_ramips=$(cd $ramips_feed; ./genconfig)
[ -e $airoha_feed/genconfig ] &&
airoha=$(cd $airoha_feed; ./genconfig)
[ -e $x86_feed/genconfig ] &&
@@ -122,7 +125,7 @@ function genconfig {
ipq95xx=$(cd $qualcomm_ipq95xx_feed; ./genconfig)
if [ "$profile" == "LIST" ]; then
for list in brcmbca airoha iopsys_x86 iopsys_armvirt iopsys_mediatek ipq95xx; do
for list in brcmbca iopsys_ramips airoha iopsys_x86 iopsys_armvirt iopsys_mediatek ipq95xx; do
echo "$list based boards:"
for b in ${!list}; do
echo -e "\t$b"
@@ -139,6 +142,14 @@ function genconfig {
fi
done
for p in $iopsys_ramips; do
if [ $p == $profile ]; then
target="iopsys_ramips"
target_config_path="$ramips_feed/config"
return
fi
done
for p in $airoha; do
if [ $p == $profile ]; then
target="airoha"
@@ -265,22 +276,11 @@ function genconfig {
setup_dirs()
{
git remote -v | grep -q http || {
CUSTBRANCH="$(git rev-parse --abbrev-ref HEAD)"
if git ls-remote $CUSTREPO -q 2>/dev/null; then
if [ ! -d "$CUSTPATH" ]; then
echo "Cloning $CUSTBRANCH branch of $CUSTREPO"
git clone -b "$CUSTBRANCH" "$CUSTREPO" "$CUSTPATH" 2>/dev/null || {
DEFBRANCH="$(git remote show $CUSTREPO | grep 'HEAD branch' | cut -d' ' -f5)"
echo "$CUSTBRANCH branch is not found, cloning $DEFBRANCH branch of $CUSTREPO"
git clone "$CUSTREPO" "$CUSTPATH"
}
git clone "$CUSTREPO" "$CUSTPATH"
elif [ $IMPORT -eq 1 ]; then
cd $CUSTPATH
echo "Checking out $CUSTBRANCH branch in $CUSTPATH"
git checkout "$CUSTBRANCH" 2>/dev/null || {
DEFBRANCH="$(git symbolic-ref refs/remotes/origin/HEAD | cut -d '/' -f4)"
echo "Checking out $CUSTBRANCH branch has failed, using $DEFBRANCH branch in $CUSTPATH"
}
v "git pull"
git pull
cd - >/dev/null #go back
@@ -298,24 +298,6 @@ function genconfig {
fi
}
get_subtarget_for_device() {
readonly target="$1"
readonly device="$2"
readonly targetinfo_file="tmp/info/.targetinfo-feeds_$target"
readonly target_profile_line="Target-Profile: DEVICE_$device"
# We want to know after which Target: $target/$subtarget line
# our $target_profile_line appears
# This is a crude way to "parse" the file using shell 🤯
# 1. grep for both lines with line number output
# 2. grep again to determine the device profile line that we looked for
# but output one context line before as well to determine corresponding subtarget line
# 4. Use head and sed to extract the subtarget
grep "^Target: $target/\|^$target_profile_line" "$targetinfo_file" \
| grep -E -B1 "^$target_profile_line" \
| head -n1 \
| sed -E "s|^Target: $target/||"
}
create_and_copy_files()
{
local BOARDTYPE=$1
@@ -358,16 +340,17 @@ function genconfig {
echo "" >> .config
fi
# Special handling for targets which use TARGET_DEVICES
# Special handling for targets which use TARGET_DEVICES
case "$target" in
airoha | iopsys_mediatek | brcmbca | ipq95xx)
iopsys_ramips | airoha | iopsys_mediatek | brcmbca | ipq95xx)
# This assumes the device name to be unique within one target,
# which is a fair assumption to make.
local subtarget="$(get_subtarget_for_device "${target/_/-}" "$BOARDTYPE")"
if [ -z "$subtarget" ]; then
local mk_file="$(grep -Fx --files-with-matches "define Device/${BOARDTYPE}" "$target_config_path/../image/"*.mk)"
if [ -z "$mk_file" ]; then
echo "Error determining subtarget for $target / ${BOARDTYPE}"
return 1
fi
local subtarget="$(basename "${mk_file%.mk}")"
echo "CONFIG_TARGET_${target}=y" >> .config
echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config
echo "CONFIG_TARGET_DEVICE_${target}_${subtarget}_DEVICE_${BOARDTYPE}=y" >> .config

View File

@@ -13,6 +13,7 @@ function genconfig_min {
target="bogus"
target_config_path=""
brcmbca_feed="target/linux/feeds/brcmbca"
ramips_feed="target/linux/feeds/iopsys-ramips"
airoha_feed="target/linux/feeds/airoha"
x86_feed="target/linux/feeds/iopsys-x86"
armvirt_feed="target/linux/feeds/iopsys-armvirt"
@@ -109,6 +110,8 @@ function genconfig_min {
[ -e $brcmbca_feed/genconfig ] &&
brcmbca=$(cd $brcmbca_feed; ./genconfig)
[ -e $ramips_feed/genconfig ] &&
iopsys_ramips=$(cd $ramips_feed; ./genconfig)
[ -e $airoha_feed/genconfig ] &&
airoha=$(cd $airoha_feed; ./genconfig)
[ -e $x86_feed/genconfig ] &&
@@ -121,7 +124,7 @@ function genconfig_min {
ipq95xx=$(cd $qualcomm_ipq95xx_feed; ./genconfig)
if [ "$profile" == "LIST" ]; then
for list in brcmbca airoha iopsys_x86 iopsys_armvirt iopsys_mediatek ipq95xx; do
for list in brcmbca iopsys_ramips airoha iopsys_x86 iopsys_armvirt iopsys_mediatek ipq95xx; do
echo "$list based boards:"
for b in ${!list}; do
echo -e "\t$b"
@@ -138,6 +141,14 @@ function genconfig_min {
fi
done
for p in $iopsys_ramips; do
if [ $p == $profile ]; then
target="iopsys_ramips"
target_config_path="$ramips_feed/config"
return
fi
done
for p in $airoha; do
if [ $p == $profile ]; then
target="airoha"
@@ -181,6 +192,12 @@ function genconfig_min {
git remote -v | grep -qE '(git@|ssh://)' && {
DEVELOPER=1
bcmAllowed=0
endptAllowed=0
git ls-remote git@dev.iopsys.eu:broadcom/bcmcreator.git -q 2>/dev/null && bcmAllowed=1
git ls-remote git@dev.iopsys.eu:iopsys/endptmngr.git -q 2>/dev/null && endptAllowed=1
}
v() {
@@ -272,24 +289,6 @@ function genconfig_min {
fi
}
get_subtarget_for_device() {
readonly target="$1"
readonly device="$2"
readonly targetinfo_file="tmp/info/.targetinfo-feeds_$target"
readonly target_profile_line="Target-Profile: DEVICE_$device"
# We want to know after which Target: $target/$subtarget line
# our $target_profile_line appears
# This is a crude way to "parse" the file using shell 🤯
# 1. grep for both lines with line number output
# 2. grep again to determine the device profile line that we looked for
# but output one context line before as well to determine corresponding subtarget line
# 4. Use head and sed to extract the subtarget
grep "^Target: $target/\|^$target_profile_line" "$targetinfo_file" \
| grep -E -B1 "^$target_profile_line" \
| head -n1 \
| sed -E "s|^Target: $target/||"
}
create_and_copy_files()
{
local BOARDTYPE=$1
@@ -334,14 +333,15 @@ function genconfig_min {
# Special handling for targets which use TARGET_DEVICES
case "$target" in
airoha | iopsys_mediatek | brcmbca | ipq95xx)
iopsys_ramips | airoha | iopsys_mediatek | brcmbca | ipq95xx)
# This assumes the device name to be unique within one target,
# which is a fair assumption to make.
local subtarget="$(get_subtarget_for_device "${target/_/-}" "$BOARDTYPE")"
if [ -z "$subtarget" ]; then
local mk_file="$(grep -Fx --files-with-matches "define Device/${BOARDTYPE}" "$target_config_path/../image/"*.mk)"
if [ -z "$mk_file" ]; then
echo "Error determining subtarget for $target / ${BOARDTYPE}"
return 1
fi
local subtarget="$(basename "${mk_file%.mk}")"
echo "CONFIG_TARGET_${target}=y" >> .config
echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config
echo "CONFIG_TARGET_DEVICE_${target}_${subtarget}_DEVICE_${BOARDTYPE}=y" >> .config

View File

@@ -32,3 +32,8 @@ start_service() {
procd_set_param respawn
procd_close_instance
}
#stop() {
# service_stop /sbin/iwatchdog
#}

View File

@@ -1,95 +0,0 @@
#
# Copyright (C) 2020-2023 Iopsys
#
include $(TOPDIR)/rules.mk
PKG_NAME:=libdsl
PKG_VERSION:=7.2.99
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=54d53295b5e4ca74884045d0fa6bb0dc279ace3d
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/libdsl.git
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu>
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip
endif
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_LICENSE:=LGPL-2.1-only
PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk
ifeq ($(CONFIG_TARGET_brcmbca),y)
TARGET_PLATFORM=BROADCOM
CHIP_ID=$(patsubst "%",%,$(CONFIG_BCM_CHIP_ID))
TARGET_CFLAGS +=-DIOPSYS_BROADCOM -DCHIP_$(CHIP_ID) -DCONFIG_BCM9$(CHIP_ID) \
-I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx \
-I$(STAGING_DIR)/usr/include/bcm963xx/userspace/public/include
else ifeq ($(CONFIG_TARGET_iopsys_x86),y)
TARGET_PLATFORM=TEST
TARGET_CFLAGS +=-DIOPSYS_TEST
else ifeq ($(CONFIG_TARGET_iopsys_armvirt),y)
TARGET_PLATFORM=TEST
TARGET_CFLAGS +=-DIOPSYS_TEST
endif
define Package/libdsl
SECTION:=libs
CATEGORY:=Libraries
SUBMENU:=IOPSYS HAL libs
MENU:=1
TITLE:= xDSL library (libdsl)
endef
define Package/libdsl/description
Library provides xDSL/GFAST HAL APIs
endef
define Package/libdsl/config
if PACKAGE_libdsl
config LIBDSL_DEBUG
depends on PACKAGE_libdsl
bool "Enable dsl debugging"
default n
config LIBDSL_TEST
depends on PACKAGE_libdsl
bool "Enable dsl test program"
default n
endif
endef
define Build/InstallDev/libdsl
$(INSTALL_DIR) $(1)/usr/include/xdsl
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/xdsl.h $(1)/usr/include/xdsl
$(CP) $(PKG_BUILD_DIR)/xtm.h $(1)/usr/include/xdsl
$(CP) $(PKG_BUILD_DIR)/common.h $(1)/usr/include/xdsl
$(CP) $(PKG_BUILD_DIR)/libdsl.so* $(1)/usr/lib/
endef
define Build/InstallDev
$(call Build/InstallDev/libdsl,$(1),$(2))
endef
ifeq ($(CONFIG_LIBDSL_TEST),y)
define Build/Compile/libdsl
$(MAKE) -C "$(PKG_BUILD_DIR)/test" $(MAKE_FLAGS)
endef
endif
define Package/libdsl/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_DIR) $(1)/usr/bin
$(CP) $(PKG_BUILD_DIR)/libdsl.so* $(1)/usr/lib/
ifeq ($(CONFIG_LIBDSL_TEST),y)
$(CP) $(PKG_BUILD_DIR)/test/libdsl_test $(1)/usr/bin/
endif
endef
$(eval $(call BuildPackage,libdsl))

View File

@@ -1,68 +0,0 @@
#
# Copyright (C) 2020-2023 Iopsys
#
include $(TOPDIR)/rules.mk
PKG_NAME:=libeasy
PKG_VERSION:=7.2.99
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=bca982ba1e3c59fc900d297145b731dd0ad588a0
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/libeasy.git
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu>
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip
endif
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_LICENSE:=LGPL-2.1-only
PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk
TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include \
-I$(STAGING_DIR)/usr/include/openssl \
-I$(STAGING_DIR)/usr/include/libnl3
MAKE_FLAGS += \
CFLAGS="$(TARGET_CFLAGS) -Wall"
define Package/libeasy
SECTION:=libs
CATEGORY:=Libraries
SUBMENU:=IOPSYS HAL libs
MENU:=1
TITLE:= Common helper library (libeasy)
DEPENDS+=+libnl +libnl-route +libopenssl
endef
define Package/libeasy/description
Library provides common utility functions
endef
define Build/InstallDev/libeasy
$(INSTALL_DIR) $(1)/usr/include/easy
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/easy.h $(1)/usr/include/easy/
$(CP) $(PKG_BUILD_DIR)/event.h $(1)/usr/include/easy/
$(CP) $(PKG_BUILD_DIR)/utils.h $(1)/usr/include/easy/
$(CP) $(PKG_BUILD_DIR)/if_utils.h $(1)/usr/include/easy/
$(CP) $(PKG_BUILD_DIR)/debug.h $(1)/usr/include/easy/
$(CP) $(PKG_BUILD_DIR)/hlist.h $(1)/usr/include/easy/
$(CP) $(PKG_BUILD_DIR)/libeasy*.so* $(1)/usr/lib/
endef
define Build/InstallDev
$(call Build/InstallDev/libeasy,$(1),$(2))
endef
define Package/libeasy/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libeasy*.so* $(1)/usr/lib/
endef
$(eval $(call BuildPackage,libeasy))

View File

@@ -1,110 +0,0 @@
#
# Copyright (C) 2020-2023 Iopsys
#
include $(TOPDIR)/rules.mk
PKG_NAME:=libethernet
PKG_VERSION:=7.2.102
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=30df74671870acef99036217e002d1f4418c8d4f
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/libethernet.git
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu>
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip
endif
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_LICENSE:=LGPL-2.1-only
PKG_LICENSE_FILES:=LICENSE
PKG_BUILD_DEPENDS:=+TARGET_brcmbca:bcmkernel
include $(INCLUDE_DIR)/package.mk
ifeq ($(CONFIG_TARGET_brcmbca),y)
TARGET_PLATFORM=BROADCOM
CHIP_ID=$(patsubst "%",%,$(CONFIG_BCM_CHIP_ID))
TARGET_CFLAGS +=-DIOPSYS_BROADCOM -DCHIP_$(CHIP_ID) -DCONFIG_BCM9$(CHIP_ID) \
-I$(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx \
-I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx \
-I$(STAGING_DIR)/usr/include/bcm963xx/userspace/public/include
else ifeq ($(CONFIG_TARGET_iopsys_x86),y)
TARGET_PLATFORM=TEST
TARGET_CFLAGS +=-DIOPSYS_TEST
else ifeq ($(CONFIG_TARGET_iopsys_armvirt),y)
TARGET_PLATFORM=TEST
TARGET_CFLAGS +=-DIOPSYS_TEST
else ifeq ($(CONFIG_TARGET_airoha),y)
TARGET_PLATFORM=ECONET
TARGET_CFLAGS +=-DIOPSYS_ECONET
else ifeq ($(CONFIG_TARGET_ipq95xx),y)
TARGET_PLATFORM=IPQ95XX
TARGET_CFLAGS +=-DIPQ95XX
else ifeq ($(CONFIG_TARGET_iopsys_mediatek),y)
TARGET_PLATFORM=LINUX
TARGET_CFLAGS +=-DIOPSYS_LINUX
else
$(info Unexpected CONFIG_TARGET, use default LINUX)
TARGET_PLATFORM=LINUX
TARGET_CFLAGS +=-DIOPSYS_LINUX
endif
TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include \
-I$(STAGING_DIR)/usr/include/openssl \
-I$(STAGING_DIR)/usr/include/libnl3
MAKE_FLAGS += \
CFLAGS="$(TARGET_CFLAGS) -Wall -I./" \
LDFLAGS="$(TARGET_LDFLAGS)" \
FPIC="$(FPIC)" \
PLATFORM="$(TARGET_PLATFORM)" \
subdirs="$(subdirs)"
define Package/libethernet
SECTION:=libs
CATEGORY:=Libraries
SUBMENU:=IOPSYS HAL libs
MENU:=1
TITLE:= Ethernet library (libethernet)
DEPENDS+=+libnl +libnl-route +libeasy +TARGET_airoha:ecnt_api
endef
define Package/libethernet/description
Library provides ethernet HAL APIs
endef
define Package/libethernet/config
config LIBETHERNET_DEBUG
depends on PACKAGE_libethernet
bool "Enable ethernet debugging"
default n
endef
ifeq ($(LOCAL_DEV),1)
define Build/Prepare
$(CP) -rf ./libethernet/* $(PKG_BUILD_DIR)/
endef
endif
define Build/InstallDev/libethernet
$(INSTALL_DIR) $(1)/usr/include
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/ethernet.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/libethernet.so $(1)/usr/lib/
endef
define Build/InstallDev
$(call Build/InstallDev/libethernet,$(1),$(2))
endef
define Package/libethernet/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libethernet.so* $(1)/usr/lib/
endef
$(eval $(call BuildPackage,libethernet))

View File

@@ -1,52 +0,0 @@
#
# Copyright (C) 2006-2010 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_RELEASE:=1
PKG_VERSION:=0.3
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/libpicoevent.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=f446f186102539cceedaa15a95a33547ac3c1fd7
PKG_NAME:=libpicoevent-bcm
PKG_LICENSE:=LGPL-2.1-only
PKG_LICENSE_FILES:=LICENSE
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
include $(INCLUDE_DIR)/package.mk
define Package/libpicoevent-bcm
CATEGORY:=Libraries
TITLE:=Libpicoevent-bcm
URL:=
DEPENDS:= +TARGET_brcmbca:bcmkernel
include $(TOPDIR)/feeds/broadcom/bcmkernel/bcm-toolchain.mk
TARGET_CFLAGS := -Os -pipe -mfpu=vfpv3-d16 -mfloat-abi=softfp -DCONFIG_TARGET_brcmbca -g3 -fno-caller-saves -fno-plt -Wno-error=unused-but-set-variable -Wno-error=unused-result \
-mfloat-abi=soft -fmacro-prefix-map=$(BUILD_DIR)libpicoevent-bcm-0.3=libpicoevent-bcm-0.3 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 \
-Wl,-z,now -Wl,-z,relro -Wl,--build-i
endef
define Package/libpicoevent-bcm/description
Minimal event library
endef
define Package/libpicoevent-bcm/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_DIR) $(STAGING_DIR)/usr/lib
$(INSTALL_DIR) $(STAGING_DIR)/usr/lib/broadcom
$(INSTALL_DIR) $(STAGING_DIR)/usr/include
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx
$(CP) $(PKG_BUILD_DIR)/libpicoevent.h $(STAGING_DIR)/usr/include/bcm963xx
mkdir -p $(1)/usr/lib/broadcom
$(CP) $(PKG_BUILD_DIR)/libpicoevent.so $(STAGING_DIR)/usr/lib/broadcom
$(INSTALL_DATA) $(PKG_BUILD_DIR)/libpicoevent.so $(1)/usr/lib/broadcom
endef
$(eval $(call BuildPackage,libpicoevent-bcm))

View File

@@ -1,105 +0,0 @@
#
# Copyright (C) 2020-2023 Iopsys
#
include $(TOPDIR)/rules.mk
PKG_NAME:=libqos
PKG_VERSION:=7.2.100
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=3a37af002fee1c0d35da49cefee2d24ee92a5d0a
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/libqos.git
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu>
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip
endif
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_LICENSE:=LGPL-2.1-only
PKG_LICENSE_FILES:=LICENSE
PKG_BUILD_DEPENDS:=+TARGET_brcmbca:bcmkernel
include $(INCLUDE_DIR)/package.mk
ifeq ($(CONFIG_TARGET_brcmbca),y)
TARGET_PLATFORM=BROADCOM
CHIP_ID=$(patsubst "%",%,$(CONFIG_BCM_CHIP_ID))
TARGET_CFLAGS +=-DIOPSYS_BROADCOM -DCHIP_$(CHIP_ID) -DCONFIG_BCM9$(CHIP_ID) \
-I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx \
-I$(STAGING_DIR)/usr/include/bcm963xx/userspace/public/include
else ifeq ($(CONFIG_TARGET_iopsys_x86),y)
TARGET_PLATFORM=TEST
TARGET_CFLAGS +=-DIOPSYS_TEST
else ifeq ($(CONFIG_TARGET_iopsys_armvirt),y)
TARGET_PLATFORM=TEST
TARGET_CFLAGS +=-DIOPSYS_TEST
else ifeq ($(CONFIG_TARGET_airoha),y)
TARGET_PLATFORM=ECONET
TARGET_CFLAGS +=-DIOPSYS_ECONET
else ifeq ($(CONFIG_TARGET_ipq95xx),y)
TARGET_PLATFORM=IPQ95XX
TARGET_CFLAGS +=-DIPQ95XX
else ifeq ($(CONFIG_TARGET_iopsys_mediatek),y)
TARGET_PLATFORM=LINUX
TARGET_CFLAGS +=-DIOPSYS_LINUX
else
$(info Unexpected CONFIG_TARGET, use default LINUX)
TARGET_PLATFORM=LINUX
TARGET_CFLAGS +=-DIOPSYS_LINUX
endif
TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include \
-I$(STAGING_DIR)/usr/include/openssl \
-I$(STAGING_DIR)/usr/include/libnl3
MAKE_FLAGS += \
CFLAGS="$(TARGET_CFLAGS) -Wall -I./" \
LDFLAGS="$(TARGET_LDFLAGS)" \
FPIC="$(FPIC)" \
PLATFORM="$(TARGET_PLATFORM)" \
subdirs="$(subdirs)"
define Package/libqos
SECTION:=libs
CATEGORY:=Libraries
SUBMENU:=IOPSYS HAL libs
MENU:=1
TITLE:= QoS library (libqos)
DEPENDS+=+libnl +libnl-route +libeasy
endef
define Package/libqos/config
config LIBQOS_DEBUG
depends on PACKAGE_libqos
bool "Enable qos debugging"
default n
endef
ifeq ($(LOCAL_DEV),1)
define Build/Prepare
$(CP) -rf ./libqos/* $(PKG_BUILD_DIR)/
endef
endif
define Build/InstallDev/libqos
$(INSTALL_DIR) $(1)/usr/include
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/include/qos.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/libqos.so $(1)/usr/lib/
endef
define Build/InstallDev
$(call Build/InstallDev/libqos,$(1),$(2))
endef
define Package/libqos/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libqos*.so* $(1)/usr/lib/
endef
$(eval $(call BuildPackage,libqos))

View File

@@ -1,57 +0,0 @@
#
# Copyright (C) 2022 IOPSYS Software Solutions AB
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=libvoice-airoha
PKG_RELEASE:=1
PKG_VERSION:=1.0.0
PKG_LICENSE:=PROPRIETARY
PKG_LICENSE_FILES:=LICENSE
LOCAL_SRC_DIR:=~/git/voip/$(PKG_NAME)
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/$(PKG_NAME).git
PKG_SOURCE_VERSION:=2a6ef141747ad0f7b32a536b5b5bd174834a7af5
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif
# All config variable that are passed to the make invocation, directly or
# indirectly. This ensures that the package is rebuilt on config-changes.
PKG_CONFIG_DEPENDS:=CONFIG_TARGET_BOARD
LIBVOICE_PKG_BUILD_DIR := $(PKG_BUILD_DIR)
include $(INCLUDE_DIR)/package.mk
TARGET_CFLAGS += -Wall -Werror
define Package/$(PKG_NAME)
CATEGORY:=Utilities
TITLE:=IOPSYS libvoice for Airoha platform
URL:=
DEPENDS:=
endef
define Package/$(PKG_NAME)/description
Libvoice is a library that provides a uniform set of APIs and data types with hardware abstract layer for DSP/SLIC from different vendors
endef
ifeq ($(LOCAL_DEV),1)
define Build/Prepare
rsync -av --exclude=.* $(LOCAL_SRC_DIR)/* $(PKG_BUILD_DIR)/
endef
endif
define Package/$(PKG_NAME)/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,$(PKG_NAME)))

View File

@@ -1,59 +0,0 @@
{
"ulaw": {
"name": "G.711MuLaw",
"ptime_min": 10,
"ptime_max": 30,
"ptime_default": 20,
"ptime_increment": 10,
"bitrate": 64
},
"alaw": {
"name": "G.711ALaw",
"ptime_min": 10,
"ptime_max": 30,
"ptime_default": 20,
"ptime_increment": 10,
"bitrate": 64
},
"g726": {
"name": "G.726",
"ptime_min": 10,
"ptime_max": 30,
"ptime_default": 20,
"ptime_increment": 10,
"bitrate": 16
},
"g723": {
"name": "G.723.1",
"ptime_min": 10,
"ptime_max": 30,
"ptime_default": 30,
"ptime_increment": 30,
"bitrate": 5.3
},
"g729": {
"name": "G.729",
"ptime_min": 10,
"ptime_max": 30,
"ptime_default": 20,
"ptime_increment": 10,
"bitrate": 8
},
"ilbc": {
"name": "iLBC",
"ptime_min": 10,
"ptime_max": 30,
"ptime_default": 20,
"ptime_increment": 30,
"bitrate": 15.2
},
"gsm": {
"name": "GSM-AMR",
"ptime_min": 10,
"ptime_max": 30,
"ptime_default": 20,
"ptime_increment": 20,
"bitrate": 12.2
}
}

View File

@@ -7,8 +7,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=libvoice-broadcom
PKG_RELEASE:=1
PKG_VERSION:=1.0.0
PKG_VERSION:=0.1
PKG_LICENSE:=PROPRIETARY
PKG_LICENSE_FILES:=LICENSE
@@ -17,7 +16,7 @@ LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/$(PKG_NAME).git
PKG_SOURCE_VERSION:=401a392a72e2933f527eb92466faaf2907c38730
PKG_SOURCE_VERSION:=d066c9d5c14757ab38e9ecb265ba24f5b33cdbce
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif
@@ -28,6 +27,7 @@ PKG_CONFIG_DEPENDS:=CONFIG_TARGET_BOARD
LIBVOICE_PKG_BUILD_DIR := $(PKG_BUILD_DIR)
export CONFIG_BRCM_SDK_VER_504040
export CONFIG_BCM_CHIP_ID
include $(INCLUDE_DIR)/package.mk
@@ -52,7 +52,9 @@ endef
endif
define Package/$(PKG_NAME)/install
$(CP) ./files/* $(1)/
# Although there is nothing needs to be installed, but the install section must NOT be empty. Otherwise the package will be skipped as below.
# WARNING: skipping libvoice-broadcom -- package has no install section
$(INSTALL_DIR) $(1)/usr/lib
endef
$(eval $(call BuildPackage,$(PKG_NAME)))

View File

@@ -1,59 +0,0 @@
{
"ulaw": {
"name": "G.711MuLaw",
"ptime_min": 10,
"ptime_max": 30,
"ptime_default": 20,
"ptime_increment": 10,
"bitrate": 64
},
"alaw": {
"name": "G.711ALaw",
"ptime_min": 10,
"ptime_max": 30,
"ptime_default": 20,
"ptime_increment": 10,
"bitrate": 64
},
"g726": {
"name": "G.726",
"ptime_min": 10,
"ptime_max": 30,
"ptime_default": 20,
"ptime_increment": 10,
"bitrate": 16
},
"g723": {
"name": "G.723.1",
"ptime_min": 10,
"ptime_max": 30,
"ptime_default": 30,
"ptime_increment": 30,
"bitrate": 5.3
},
"g729": {
"name": "G.729",
"ptime_min": 10,
"ptime_max": 30,
"ptime_default": 20,
"ptime_increment": 10,
"bitrate": 8
},
"ilbc": {
"name": "iLBC",
"ptime_min": 10,
"ptime_max": 30,
"ptime_default": 20,
"ptime_increment": 30,
"bitrate": 15.2
},
"gsm": {
"name": "GSM-AMR",
"ptime_min": 10,
"ptime_max": 30,
"ptime_default": 20,
"ptime_increment": 20,
"bitrate": 12.2
}
}

View File

@@ -7,8 +7,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=libvoice-d2
PKG_RELEASE:=1
PKG_VERSION:=1.0.2
PKG_VERSION:=0.1
PKG_LICENSE:=PROPRIETARY
PKG_LICENSE_FILES:=LICENSE
@@ -17,7 +16,7 @@ LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/$(PKG_NAME).git
PKG_SOURCE_VERSION:=7ca102e62fa439a7188f2c5e4c72e3fcfd3fb28a
PKG_SOURCE_VERSION:=45e7d35f97f258f5e13c3afa0542db724bf59828
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif
@@ -26,9 +25,9 @@ endif
# indirectly. This ensures that the package is rebuilt on config-changes.
PKG_CONFIG_DEPENDS:=CONFIG_TARGET_BOARD
include $(INCLUDE_DIR)/package.mk
LIBVOICE_PKG_BUILD_DIR := $(PKG_BUILD_DIR)
export D2_VTSP_PLATFORM := $(shell echo $(CONFIG_D2_VTSP_PLATFORM))
include $(INCLUDE_DIR)/package.mk
TARGET_CFLAGS += -Wall -Werror
@@ -36,7 +35,7 @@ define Package/$(PKG_NAME)
CATEGORY:=Utilities
TITLE:=IOPSYS libvoice for D2 which is software DSP
URL:=
DEPENDS:=+d2-voice
DEPENDS:=
endef
define Package/$(PKG_NAME)/description
@@ -50,7 +49,9 @@ endef
endif
define Package/$(PKG_NAME)/install
$(CP) ./files/* $(1)/
# Although there is nothing needs to be installed, but the install section must NOT be empty. Otherwise the package will be skipped as below.
# WARNING: skipping libvoice-d2 -- package has no install section
$(INSTALL_DIR) $(1)/usr/lib
endef
$(eval $(call BuildPackage,$(PKG_NAME)))

View File

@@ -1,42 +0,0 @@
{
"ulaw": {
"name": "G.711MuLaw",
"ptime_min": 10,
"ptime_max": 40,
"ptime_default": 20,
"ptime_increment": 10,
"bitrate": 64
},
"alaw": {
"name": "G.711ALaw",
"ptime_min": 10,
"ptime_max": 40,
"ptime_default": 20,
"ptime_increment": 10,
"bitrate": 64
},
"g729a": {
"name": "G.729a",
"ptime_min": 10,
"ptime_max": 40,
"ptime_default": 20,
"ptime_increment": 10,
"bitrate": 64
},
"g729": {
"name": "G.729",
"ptime_min": 10,
"ptime_max": 40,
"ptime_default": 20,
"ptime_increment": 10,
"bitrate": 8
},
"g722": {
"name": "G.722",
"ptime_min": 10,
"ptime_max": 40,
"ptime_default": 20,
"ptime_increment": 10,
"bitrate": 56
}
}

View File

@@ -1,162 +0,0 @@
#
# Copyright (C) 2020-2023 Iopsys
#
include $(TOPDIR)/rules.mk
PKG_NAME:=libwifi
PKG_VERSION:=7.2.100
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=d6e14d7a0b747ca09d3f6843cea9ae3584d18dd3
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/libwifi.git
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu>
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip
endif
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_LICENSE:=LGPL-2.1-only
PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk
ifeq ($(CONFIG_TARGET_brcmbca),y)
TARGET_PLATFORM=BROADCOM
TARGET_WIFI_TYPE=BROADCOM
CHIP_ID=$(patsubst "%",%,$(CONFIG_BCM_CHIP_ID))
TARGET_CFLAGS +=-DIOPSYS_BROADCOM -DCHIP_$(CHIP_ID) -DCONFIG_BCM9$(CHIP_ID) \
-I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx \
-I$(STAGING_DIR)/usr/include/bcm963xx/userspace/public/include
else ifeq ($(CONFIG_TARGET_iopsys_x86),y)
TARGET_PLATFORM=TEST
TARGET_WIFI_TYPE=TEST
TARGET_CFLAGS +=-DIOPSYS_TEST
else ifeq ($(CONFIG_TARGET_iopsys_armvirt),y)
TARGET_PLATFORM=TEST
TARGET_WIFI_TYPE=TEST
TARGET_CFLAGS +=-DIOPSYS_TEST
else ifeq ($(CONFIG_TARGET_airoha),y)
TARGET_PLATFORM=ECONET
TARGET_WIFI_TYPE=MEDIATEK MAC80211
TARGET_CFLAGS +=-DIOPSYS_ECONET
else ifeq ($(CONFIG_TARGET_ipq95xx),y)
TARGET_PLATFORM=IPQ95XX
TARGET_WIFI_TYPE=MAC80211
TARGET_CFLAGS +=-DIPQ95XX
else ifeq ($(CONFIG_TARGET_iopsys_mediatek),y)
TARGET_PLATFORM=LINUX
TARGET_WIFI_TYPE=MAC80211
TARGET_CFLAGS +=-DIOPSYS_LINUX
else
$(info Unexpected CONFIG_TARGET, use default MAC80211)
TARGET_PLATFORM=MAC80211
TARGET_WIFI_TYPE=MAC80211
TARGET_CFLAGS +=-DIOPSYS_MAC80211
endif
ifneq ($(CONFIG_PACKAGE_libwifi),)
TARGET_CFLAGS +=-DHAS_WIFI
endif
ifeq ($(CONFIG_LIBWIFI_USE_CTRL_IFACE),y)
TARGET_CFLAGS +=-DLIBWIFI_USE_CTRL_IFACE
endif
TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include \
-I$(STAGING_DIR)/usr/include/openssl \
-I$(STAGING_DIR)/usr/include/libnl3
MAKE_FLAGS += \
CFLAGS="$(TARGET_CFLAGS) -Wall -I./" \
LDFLAGS="$(TARGET_LDFLAGS)" \
FPIC="$(FPIC)" \
PLATFORM="$(TARGET_PLATFORM)" \
WIFI_TYPE="$(TARGET_WIFI_TYPE)" \
subdirs="$(subdirs)"
ifeq ($(LOCAL_DEV),1)
define Build/Prepare
rsync -r --exclude=.* ~/git/libwifi/ $(PKG_BUILD_DIR)/
endef
endif
define Package/libwifi-common
SECTION:=libs
CATEGORY:=Libraries
TITLE:=libwifi
SUBMENU:=IOPSYS HAL libs
DEPENDS:=+libopenssl
MENU:=1
endef
define Package/libwifi/description
Library provides WiFi HAL APIs and WiFi common utility functions
endef
define Package/libwifiutils
$(call Package/libwifi-common)
TITLE:= WiFi utility library (libwifiutils.so)
DEPENDS+=+libnl +libnl-route +libeasy
endef
define Build/InstallDev/libwifiutils
$(INSTALL_DIR) $(1)/usr/include
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/wifidefs.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/wifiutils.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/libwifiutils*.so* $(1)/usr/lib/
endef
define Package/libwifiutils/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libwifiutils*.so* $(1)/usr/lib/
endef
define Package/libwifi
$(call Package/libwifi-common)
TITLE:= WiFi library (libwifi)
DEPENDS+=+libnl +libnl-route +libeasy +libwifiutils +TARGET_brcmbca:bcmkernel
endef
define Package/libwifi/config
if PACKAGE_libwifi
config LIBWIFI_DEBUG
depends on PACKAGE_libwifi
bool "Enable debugging in libwifi"
default n
config LIBWIFI_USE_CTRL_IFACE
bool "Create UNIX sockets to interface with hostapd/wpa_supplicant"
default n
endif
endef
define Build/InstallDev/libwifi
$(INSTALL_DIR) $(1)/usr/include
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/wifiops.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/wifi.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/libwifi-7*.so* $(1)/usr/lib/
endef
define Build/InstallDev
$(call Build/InstallDev/libwifiutils,$(1),$(2))
ifneq ($(CONFIG_PACKAGE_libwifi),)
$(call Build/InstallDev/libwifi,$(1),$(2))
endif
endef
define Package/libwifi/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libwifi-7*.so* $(1)/usr/lib/
endef
$(eval $(call BuildPackage,libwifiutils))
$(eval $(call BuildPackage,libwifi))

View File

@@ -20,6 +20,10 @@ start_service() {
fi
}
stop() {
service_stop /sbin/loop-detector
}
service_triggers()
{
procd_add_reload_trigger loop_detection
@@ -29,3 +33,4 @@ reload_service() {
stop
start
}

View File

@@ -33,17 +33,5 @@ config AGENT_EASYMESH_VENDOR_EXT_OUI
enabled through AGENT_EASYMESH_VENDOR_EXT. Please provide the Vendor's OUI
through which such features would be exposed.
config AGENT_UNAUTHORIZED_STA_IN_ASSOCLIST
bool "Create STA entry before authorization is completed"
config AGENT_CHANSWITCH_SKIP_DFS_UNAVAILABLE
bool "Skip DFS unavailable channels when channel switch"
config AGENT_LOCAL_ACS_SERVICE
bool "Enable loacal ACS daemon usage"
config AGENT_STRICT_OPER_CHANNEL_REPORT
bool "Report operation channel strictly, skip some unsolicited reports"
endmenu
endif

View File

@@ -5,9 +5,9 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=map-agent
PKG_VERSION:=4.3.1.1
PKG_VERSION:=2.10.4.17
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=a6c5d7cbbc6363e123cfacc9333e5ae507f6dcd7
PKG_SOURCE_VERSION:=098fef903c1e746776f88df3706337b8fc3899ac
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu>
PKG_LICENSE:=BSD-3-Clause
@@ -16,7 +16,7 @@ PKG_LICENSE_FILES:=LICENSE
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/multi-ap/map-agent
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/map-agent
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip
endif
@@ -78,21 +78,6 @@ TARGET_CFLAGS += -DEASYMESH_VENDOR_EXT_OUI=\\\"$(CONFIG_AGENT_EASYMESH_VENDOR_EX
TARGET_CFLAGS += -DEASYMESH_VENDOR_EXT
endif
ifeq ($(CONFIG_AGENT_UNAUTHORIZED_STA_IN_ASSOCLIST),y)
TARGET_CFLAGS += -DUNAUTHORIZED_STA_IN_ASSOCLIST
endif
ifeq ($(CONFIG_AGENT_CHANSWITCH_SKIP_DFS_UNAVAILABLE),y)
TARGET_CFLAGS += -DCHANSWITCH_SKIP_DFS_UNAVAILABLE
endif
ifeq ($(CONFIG_AGENT_LOCAL_ACS_SERVICE),y)
TARGET_CFLAGS += -DLOCAL_ACS_SERVICE
endif
ifeq ($(CONFIG_AGENT_STRICT_OPER_CHANNEL_REPORT),y)
TARGET_CFLAGS += -DSTRICT_OPER_CHANNEL_REPORT
endif
MAKE_PATH:=src

View File

@@ -25,7 +25,7 @@ validate_agent_section() {
uci_validate_section mapagent agent "agent" \
'enabled:bool:true' \
'debug:range(0,16)' \
'profile:range(1,4):2' \
'profile:range(1,2):2' \
'brcm_setup:bool:false' \
'controller_macaddr:macaddr' \
'al_bridge:string' \

View File

@@ -5,14 +5,14 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=map-controller
PKG_VERSION:=4.3.0.3
PKG_VERSION:=2.11.0.24
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=fb600940ac54456bcde650ccee7055f7c9bb785b
PKG_SOURCE_VERSION:=8944352f648643fa5c72cd216a76695a021b7851
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/multi-ap/map-controller
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/map-controller
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip
endif
@@ -26,7 +26,7 @@ define Package/map-controller
SECTION:=utils
CATEGORY:=Utilities
TITLE:=WiFi Multi-AP Controller (EasyMesh R2)
DEPENDS:=+libuci +libubox +ubus +libeasy +libwifiutils +libieee1905 +ieee1905 +map-plugin
DEPENDS:=+libuci +libubox +ubus +libeasy +libieee1905 +ieee1905 +map-plugin
endef
define Package/map-controller/description

View File

@@ -45,13 +45,7 @@ validate_sta_steering_section() {
'use_bcn_metrics:bool:false' \
'use_usta_metrics:bool:false' \
'bandsteer:bool:false' \
'diffsnr:range(0,100)' \
'rcpi_threshold_2g:range(0,220)' \
'rcpi_threshold_5g:range(0,220)' \
'rcpi_threshold_6g:range(0,220)' \
'report_rcpi_threshold_2g:range(0,220)' \
'report_rcpi_threshold_5g:range(0,220)' \
'report_rcpi_threshold_6g:range(0,220)'
'diffsnr:range(0,100)'
[ "$?" -ne 0 ] && {
logger -s -t "mapcontroller" "Validation of sta_steering section failed"
@@ -199,7 +193,7 @@ reload_service() {
return
fi
pidof "/usr/sbin/mapcontroller" > /dev/null
pidof "mapcontroller" > /dev/null
if [[ $? -ne 0 ]] ; then
start
return

View File

@@ -6,13 +6,13 @@ include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=map-topology
PKG_VERSION:=2.5.1.19
PKG_VERSION:=2.5.1.14
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_VERSION:=7b2f5dc086207dd74c5c56421dea65b7dabb6944
PKG_SOURCE_VERSION:=bacbffccabdc1a388a135daad58db4ca60676b05
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/multi-ap/map-topology.git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/map-topology.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip
endif

View File

@@ -4,4 +4,3 @@ config topology 'topology'
option depth '8'
option interval '60'
option maxlog '32'
option profile '2'

View File

@@ -71,10 +71,6 @@ start_service() {
config_load "hosts"
validate_hosts_config || return 1;
if [ -f "/proc/sys/net/netfilter/nf_conntrack_timestamp" ]; then
echo 1 >/proc/sys/net/netfilter/nf_conntrack_timestamp
fi
procd_open_instance
procd_set_param command "/usr/sbin/topologyd"
procd_set_param respawn

View File

@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=mcastmngr
PKG_VERSION:=1.1.0
PKG_VERSION:=1.0.2
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
@@ -16,9 +16,8 @@ PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk
define Package/mcastmngr
CATEGORY:=Utilities
TITLE:=Multicast Proxy/Snooping Manager
DEPENDS:=+!TARGET_brcmbca:mcproxy
CATEGORY:=Utilities
TITLE:=multicast packets manager daemon
endef
define Package/mcastmngr/description
@@ -33,12 +32,7 @@ define Build/Compile
endef
define Package/mcastmngr/install
$(CP) ./files/common/* $(1)/
ifneq ($(CONFIG_TARGET_brcmbca),)
$(CP) ./files/broadcom/* $(1)/
else
$(CP) ./files/linux/* $(1)/
endif
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,mcastmngr))

View File

@@ -1,254 +0,0 @@
#!/bin/sh
. /lib/functions.sh
. /usr/share/libubox/jshn.sh
. /lib/mcast/common.sh
include /lib/network
CONFFILE=/var/mcpd.conf
PROG_EXE=/usr/sbin/mcpd
proxdevs=""
ethwan="$(db -q get hw.board.ethernetWanPort)"
config_snooping_common_params() {
local protocol="$1"
echo "${protocol}-default-version $2" >> $CONFFILE
echo "${protocol}-robustness-value $3" >> $CONFFILE
echo "${protocol}-max-groups $max_groups" >> $CONFFILE
echo "${protocol}-max-sources $max_msf" >> $CONFFILE
echo "${protocol}-max-members $max_members" >> $CONFFILE
echo "${protocol}-snooping-enable $4" >> $CONFFILE
}
config_mcast_querier_params() {
local protocol="$1"
local query_interval=$2
local q_resp_interval=$3
local last_mem_q_int=$4
echo "${protocol}-query-interval $query_interval" >> $CONFFILE
echo "${protocol}-query-response-interval $q_resp_interval" >> $CONFFILE
echo "${protocol}-last-member-query-interval $last_mem_q_int" >> $CONFFILE
}
config_snooping_upstream_interface() {
local snooping_upstream_intf=""
json_load "$(devstatus $1)"
logger -t "mcastconf" "$(devstatus $1)"
itr=1
json_select bridge-members
# loop over the bridge and find the device on wan port
while json_get_var dev $itr; do
case "$dev" in
*.*)
port="$(echo "$dev" | cut -d'.' -f 1)"
if [ $port == $ethwan ]; then
ifconfig $dev | grep RUNNING >/dev/null && $snooping_upstream_intf="$dev" && break
fi
;;
esac
itr=$(($itr + 1))
done
json_select ..
# if none of the bridge members are on wan port, set the wan port itself
if [ -n "$snooping_upstream_intf" ]; then
echo "upstream-interface $snooping_upstream_intf" >>$CONFFILE
else
echo "upstream-interface $ethwan" >>$CONFFILE
fi
}
config_snooping_on_bridge() {
local protocol="$1"
local bcm_mcast_p=1
echo "${protocol}-snooping-interfaces $2" >> $CONFFILE
[ "$protocol" == "mld" ] && bcm_mcast_p=2
for snpif in $2; do
case "$snpif" in
br-*)
# set snooping mode on the bridge
bcmmcastctl mode -i $snpif -p $bcm_mcast_p -m $3
;;
esac
done
}
config_mcast_proxy_interface() {
local itr
local p1="$1"
local p_enable
if [ "$p1" == "igmp" ]; then
p_enable=$igmp_p_enable
else
p_enable=$mld_p_enable
fi
for proxif in $2; do
case "$proxif" in
br-*)
proxdevs="$proxdevs $proxif"
echo "upstream-interface $proxif" >>$CONFFILE
;;
*)
ifconfig $proxif | grep RUNNING >/dev/null && proxdevs="$proxdevs $proxif"
;;
esac
done
if [ $p_enable -eq 1 ]; then
echo "${p1}-proxy-interfaces $proxdevs" >> $CONFFILE
fi
# if proxdevs is empty set the wan port as mcast-interface
if [ -n "$proxdevs" ]; then
echo "${p1}-mcast-interfaces $proxdevs" >> $CONFFILE
else
echo "${p1}-mcast-interfaces $ethwan" >> $CONFFILE
fi
}
configure_mcpd_snooping() {
local protocol="$1"
local exceptions
local filter_ip=""
local fast_leave=0
# Configure snooping related params
if [ "$protocol" == "igmp" ]; then
config_snooping_common_params $protocol $igmp_s_version $igmp_s_robustness $igmp_s_mode
config_mcast_querier_params $protocol $igmp_s_query_interval $igmp_s_q_resp_interval $igmp_s_last_mem_q_int
config_snooping_upstream_interface "$igmp_s_iface"
config_snooping_on_bridge $protocol $igmp_s_iface $igmp_s_mode
exceptions=$igmp_s_exceptions
fast_leave=$igmp_s_fast_leave
elif [ "$protocol" == "mld" ]; then
config_snooping_common_params $protocol $mld_s_version $mld_s_robustness $mld_s_mode
config_mcast_querier_params $protocol $mld_s_query_interval $mld_s_q_resp_interval $mld_s_last_mem_q_int
config_snooping_upstream_interface "$mld_s_iface"
config_snooping_on_bridge $protocol $mld_s_iface $mld_s_mode
exceptions=$mld_s_exceptions
fast_leave=$mld_s_fast_leave
fi
echo "${protocol}-proxy-enable 0" >> $CONFFILE
echo "${protocol}-fast-leave $fast_leave" >> $CONFFILE
if [ -n "$exceptions" ]; then
IFS=" "
for excp in $exceptions; do
case $excp in
*/*)
tmp="$(ipcalc.sh $excp | grep IP | awk '{print substr($0,4)}')"
tmp1="$(ipcalc.sh $excp | grep NETMASK | awk '{print substr($0,9)}')"
filter_ip="$filter_ip $tmp/$tmp1"
;;
*)
filter_ip="$filter_ip $excp"
;;
esac
done
echo "${protocol}-mcast-snoop-exceptions $filter_ip" >> $CONFFILE
fi
}
configure_mcpd_proxy() {
local protocol="$1"
local fast_leave=0
local exceptions=""
# Configure snooping related params
if [ "$protocol" == "igmp" ]; then
config_snooping_common_params $protocol $igmp_p_version $igmp_p_robustness $igmp_p_mode
config_mcast_querier_params $protocol $igmp_query_interval $igmp_q_resp_interval $igmp_last_mem_q_int
config_mcast_proxy_interface $protocol "$igmp_p_up_interfaces"
config_snooping_on_bridge $protocol $igmp_p_down_interfaces $igmp_p_mode
fast_leave=$igmp_fast_leave
exceptions=$igmp_p_exceptions
elif [ "$protocol" == "mld" ]; then
config_snooping_common_params $protocol $mld_p_version $mld_p_robustness $mld_p_mode
config_mcast_querier_params $protocol $mld_query_interval $mld_q_resp_interval $mld_last_mem_q_int
config_mcast_proxy_interface $protocol "$mld_p_up_interfaces"
config_snooping_on_bridge $protocol $mld_p_down_interfaces $mld_p_mode
fast_leave=$mld_fast_leave
exceptions=$mld_p_exceptions
fi
# This function will only be hit in case proxy is enabled, so hard coding
# proxy enable should not be a problem
echo "${protocol}-proxy-enable 1" >> $CONFFILE
echo "${protocol}-fast-leave $fast_leave" >> $CONFFILE
if [ -n "$exceptions" ]; then
IFS=" "
for excp in $exceptions; do
case $excp in
*/*)
tmp="$(ipcalc.sh $excp | grep IP | awk '{print substr($0,4)}')"
tmp1="$(ipcalc.sh $excp | grep NETMASK | awk '{print substr($0,9)}')"
filter_ip="$filter_ip $tmp/$tmp1"
;;
*)
filter_ip="$filter_ip $excp"
;;
esac
done
echo "${protocol}-mcast-snoop-exceptions $filter_ip" >> $CONFFILE
fi
}
disable_snooping() {
local bcm_mcast_p=$1
for br in $(brctl show | grep 'br-' | awk '{print$1}' | tr '\n' ' '); do
bcmmcastctl mode -i $br -p $bcm_mcast_p -m 0 # disable snooping on all bridges
done
}
configure_mcpd() {
disable_snooping 1
disable_snooping 2
# BCM's mcpd does not allow configuration of proxy and L2 snooping simultaneously, hence
# here, if proxy is to be configured then the configuration params of snooping are ignored.
if [ "$igmp_p_enable" == "1" ]; then
configure_mcpd_proxy igmp
elif [ "$igmp_s_enable" == "1" ]; then
configure_mcpd_snooping igmp
fi
proxdevs=""
if [ "$mld_p_enable" == "1" ]; then
configure_mcpd_proxy mld
elif [ "$mld_s_enable" == "1" ]; then
configure_mcpd_snooping mld
fi
}
setup_mcast_mode() {
# set the mode at chip to allow both tagged and untagged multicast forwarding
bs /b/c iptv lookup_method=group_ip_src_ip
}
configure_mcast() {
rm -f $CONFFILE
touch $CONFFILE
# mcpd internally writes max_groups and max_msf, no need to modify
# here directly
config_global_params
read_mcast_snooping_params
read_mcast_proxy_params
configure_mcpd
}

View File

@@ -1,117 +0,0 @@
#!/bin/sh
. /lib/functions.sh
generate_igmp_global_params(){
uci add mcast igmp
uci rename mcast.@igmp[-1]="igmp"
uci set mcast.@igmp[-1].max_membership="20"
uci set mcast.@igmp[-1].max_msf="10"
uci set mcast.@igmp[-1].qrv="2"
uci set mcast.@igmp[-1].force_version="0"
uci add mcast mld
uci rename mcast.@mld[-1]="mld"
uci set mcast.@mld[-1].mldv1_unsolicited_report_interval="10"
uci set mcast.@mld[-1].mldv2_unsolicited_report_interval="1"
uci set mcast.@mld[-1].qrv="2"
uci set mcast.@mld[-1].force_version="0"
uci commit mcast
}
generate_mld_proxy_config(){
local u_itf="$1"
uci add mcast proxy
uci rename mcast.@proxy[-1]="mc_proxy_MLD"
uci set mcast.@proxy[-1].enable="1"
uci set mcast.@proxy[-1].proto="mld"
uci set mcast.@proxy[-1].version="2"
uci set mcast.@proxy[-1].robustness="2"
uci set mcast.@proxy[-1].query_interval="125"
uci set mcast.@proxy[-1].query_response_interval="100"
uci set mcast.@proxy[-1].last_member_query_interval="10"
uci set mcast.@proxy[-1].fast_leave="1"
uci set mcast.@proxy[-1].snooping_mode="2"
uci add_list mcast.@proxy[-1].downstream_interface="br-lan"
IFS=" "
for itf in $u_itf; do
uci add_list mcast.@proxy[-1].upstream_interface="$itf"
done
}
generate_igmp_proxy_config(){
local u_itf="$1"
uci add mcast proxy
uci rename mcast.@proxy[-1]="igmp_proxy_1"
uci set mcast.@proxy[-1].enable="1"
uci set mcast.@proxy[-1].proto="igmp"
uci set mcast.@proxy[-1].version="2"
uci set mcast.@proxy[-1].robustness="2"
uci set mcast.@proxy[-1].query_interval="125"
uci set mcast.@proxy[-1].query_response_interval="100"
uci set mcast.@proxy[-1].last_member_query_interval="10"
uci set mcast.@proxy[-1].fast_leave="1"
uci set mcast.@proxy[-1].snooping_mode="2"
uci add_list mcast.@proxy[-1].downstream_interface="br-lan"
IFS=" "
for itf in $u_itf; do
uci add_list mcast.@proxy[-1].upstream_interface="$itf"
done
uci add_list mcast.@proxy[-1].filter="239.0.0.0/8"
}
generate_mcast_config(){
up_itf="$(uci -q get network.wan.device)"
generate_igmp_proxy_config "$up_itf"
generate_mld_proxy_config "$up_itf"
uci commit mcast
}
interfaces_ok(){
local section_name=$1
local up_interf=$(uci -q get ${section_name}.upstream_interface)
[ -z "$up_interf" ] && return 1
local down_interf=$(uci -q get ${section_name}.downstream_interface)
[ -z "$down_interf" ] && return 1
# check if upstream untagged
IFS=" "
for itf in $up_interf; do
# check if there exist a device section for this upstream interface, if yes the
# do nothing, if no then split the it at . and use the native interface as
# upstream interface
dev_section=$(ubus call uci get '{"config":"network", "type":"device", "match":{"name":"'"$itf"'"}}' | jsonfilter -e @.values | jq keys[])
# mcast config is outdated, simply generate as per new logic
[ -z "$dev_section" ] && return 1
done
}
if [ -s "/etc/config/mcast" ]; then
if uci -q get mcast.@proxy[0] >/dev/null; then
interfaces_ok "mcast.@proxy[0]" && exit
elif uci -q get mcast.@snooping[0] >/dev/null; then
# return if there is any valid content
exit
fi
fi
rm -f /etc/config/mcast
touch /etc/config/mcast
generate_igmp_global_params
generate_mcast_config

View File

@@ -1,182 +0,0 @@
#!/bin/sh
. /lib/functions.sh
include /lib/network
# Parameters available in snooping configuration
igmp_s_enable=0
igmp_s_version=2
igmp_s_query_interval=125
igmp_s_q_resp_interval=100
igmp_s_last_mem_q_int=10
igmp_s_fast_leave=1
igmp_s_robustness=2
igmp_s_mode=0
igmp_s_iface=""
igmp_s_exceptions=""
mld_s_enable=0
mld_s_version=2
mld_s_robustness=2
mld_s_mode=0
mld_s_iface=""
mld_s_exceptions=""
# Global params
max_groups=25
max_msf=10
max_members=25
mldv1_unsolicited_report_interval=10
mldv2_unsolicited_report_interval=1
# Parameters available in proxy configuration
igmp_p_enable=0
igmp_p_version=2
igmp_query_interval=125
igmp_q_resp_interval=100
igmp_last_mem_q_int=10
igmp_fast_leave=1
igmp_p_robustness=2
igmp_p_mode=0
igmp_p_up_interfaces=""
igmp_p_down_interfaces=""
igmp_p_exceptions=""
mld_p_enable=0
mld_p_version=1
mld_query_interval=125
mld_q_resp_interval=100
mld_last_mem_q_int=10
mld_fast_leave=1
mld_p_robustness=2
mld_p_mode=0
mld_p_up_interfaces=""
mld_p_down_interfaces=""
mld_p_exceptions=""
read_snooping() {
local config="$1"
local sec_enable
local proto
config_get sec_enable "$config" enable 0
config_get proto "$config" proto
if [ "$sec_enable" == "0" ]; then
return
fi
if [ "$proto" == "igmp" ]; then
igmp_s_enable=$sec_enable
config_get igmp_s_version "$config" version 2
config_get igmp_s_query_interval "$config" query_interval 125
config_get igmp_s_q_resp_interval "$config" query_response_interval 100
config_get igmp_s_last_mem_q_int "$config" last_member_query_interval 10
config_get igmp_s_fast_leave "$config" fast_leave 1
config_get igmp_s_robustness "$config" robustness 2
config_get igmp_s_mode "$config" snooping_mode 0
config_get igmp_s_iface "$config" interface
config_get igmp_s_exceptions "$config" filter
return
fi
if [ "$proto" == "mld" ]; then
mld_s_enable=$sec_enable
config_get mld_s_version "$config" version 2
config_get mld_s_query_interval "$config" query_interval 125
config_get mld_s_q_resp_interval "$config" query_response_interval 100
config_get mld_s_last_mem_q_int "$config" last_member_query_interval 10
config_get mld_s_fast_leave "$config" fast_leave 1
config_get mld_s_robustness "$config" robustness 2
config_get mld_s_mode "$config" snooping_mode 0
config_get mld_s_iface "$config" interface
config_get mld_s_exceptions "$config" filter
return
fi
}
read_proxy() {
local config="$1"
local sec_enable
local proto
config_get sec_enable "$config" enable 0
config_get proto "$config" proto
if [ "$sec_enable" == "0" ]; then
return
fi
if [ "$proto" == "igmp" ]; then
igmp_p_enable=$sec_enable
config_get igmp_p_version "$config" version 2
config_get igmp_query_interval "$config" query_interval 125
config_get igmp_q_resp_interval "$config" query_response_interval 100
config_get igmp_last_mem_q_int "$config" last_member_query_interval 10
config_get igmp_fast_leave "$config" fast_leave 1
config_get igmp_p_robustness "$config" robustness 2
config_get igmp_p_mode "$config" snooping_mode 0
config_get igmp_p_up_interfaces "$config" upstream_interface
config_get igmp_p_down_interfaces "$config" downstream_interface
config_get igmp_p_exceptions "$config" filter
return
fi
if [ "$proto" == "mld" ]; then
mld_p_enable=$sec_enable
config_get mld_p_version "$config" version 2
config_get mld_query_interval "$config" query_interval 125
config_get mld_q_resp_interval "$config" query_response_interval 100
config_get mld_last_mem_q_int "$config" last_member_query_interval 10
config_get mld_fast_leave "$config" fast_leave 1
config_get mld_p_robustness "$config" robustness 2
config_get mld_p_mode "$config" snooping_mode 0
config_get mld_p_up_interfaces "$config" upstream_interface
config_get mld_p_down_interfaces "$config" downstream_interface
config_get mld_p_exceptions "$config" filter
return
fi
}
read_mcast_snooping_params() {
config_load mcast
config_foreach read_snooping snooping
}
read_mcast_proxy_params() {
config_load mcast
config_foreach read_proxy proxy
}
config_global_params() {
local igmp_qrv
local igmp_force_version
local mld_qrv
local mld_force_version
config_load mcast
config_get max_msf igmp max_msf 10
config_get max_groups igmp max_membership 25
config_get igmp_qrv igmp qrv 2
config_get igmp_force_version igmp force_version 0
config_get mld_qrv mld qrv 2
config_get mldv1_unsolicited_report_interval mld mldv1_unsolicited_report_interval 10
config_get mldv2_unsolicited_report_interval mld mldv2_unsolicited_report_interval 1
config_get mld_force_version mld force_version 0
if [ "$1" == "set_max_groups_and_sources" ]; then
echo $max_groups > /proc/sys/net/ipv4/igmp_max_memberships
echo $max_msf > /proc/sys/net/ipv4/igmp_max_msf
echo $max_msf > /proc/sys/net/ipv6/mld_max_msf
fi
echo $igmp_qrv > /proc/sys/net/ipv4/igmp_qrv
echo $igmp_force_version > /proc/sys/net/ipv4/conf/all/force_igmp_version
echo $mld_qrv > /proc/sys/net/ipv6/mld_qrv
echo $mld_force_version > /proc/sys/net/ipv6/conf/all/force_mld_version
echo $mldv1_unsolicited_report_interval > /proc/sys/net/ipv6/conf/all/mldv1_unsolicited_report_interval
echo $mldv2_unsolicited_report_interval > /proc/sys/net/ipv6/conf/all/mldv2_unsolicited_report_interval
}

View File

@@ -1,142 +0,0 @@
#!/bin/sh
. /usr/share/libubox/jshn.sh
. /lib/functions.sh
read_mcast_stats() {
cat /proc/net/igmp_snooping > /tmp/igmp_stats
local mcast_addrs=""
local ifaces=""
while read line; do
# reading each line
case $line in
br-*)
found_iface=0
snoop_iface="$(echo $line | awk -F ' ' '{ print $1 }')"
if [ -z "$ifaces" ]; then
ifaces="$snoop_iface"
continue
fi
IFS=" "
for ifx in $ifaces; do
if [ $ifx == $snoop_iface ]; then
found_iface=1
break
fi
done
if [ $found_iface -eq 0 ]; then
ifaces="$ifaces $snoop_iface"
continue
fi
;;
esac
done < /tmp/igmp_stats
while read line; do
# reading each line
case $line in
br-*)
found_ip=0
grp_ip="$(echo $line | awk -F ' ' '{ print $10 }')"
if [ -z "$mcast_addrs" ]; then
mcast_addrs="$grp_ip"
continue
fi
IFS=" "
for ip_addr in $mcast_addrs; do
if [ $ip_addr == $grp_ip ]; then
found_ip=1
break
fi
done
if [ $found_ip -eq 0 ]; then
mcast_addrs="$mcast_addrs $grp_ip"
continue
fi
;;
esac
done < /tmp/igmp_stats
json_init
json_add_array "snooping"
json_add_object ""
IFS=" "
for intf in $ifaces; do
while read line; do
# reading each line
case $line in
br-*)
snoop_iface="$(echo $line | awk -F ' ' '{ print $1 }')"
if [ "$snoop_iface" != "$intf" ]; then
continue
fi
json_add_string "interface" "$intf"
json_add_array "groups"
break
;;
esac
done < /tmp/igmp_stats
IFS=" "
for gip_addr in $mcast_addrs; do
grp_obj_added=0
while read line; do
# reading each line
case $line in
br-*)
snoop_iface="$(echo $line | awk -F ' ' '{ print $1 }')"
if [ "$snoop_iface" != "$intf" ]; then
continue
fi
grp_ip="$(echo $line | awk -F ' ' '{ print $10 }')"
if [ "$grp_ip" != "$gip_addr" ]; then
continue
fi
if [ $grp_obj_added -eq 0 ]; then
json_add_object ""
gip="$(ipcalc.sh $gip_addr | grep IP | awk '{print substr($0,4)}')"
json_add_string "groupaddr" "$gip"
json_add_array "clients"
grp_obj_added=1
fi
json_add_object ""
host_ip="$(echo $line | awk -F ' ' '{ print $14 }')"
h_ip="$(ipcalc.sh $host_ip | grep IP | awk '{print substr($0,4)}')"
json_add_string "ipaddr" "$h_ip"
src_port="$(echo $line | awk -F ' ' '{ print $2 }')"
json_add_string "device" "$src_port"
timeout="$(echo $line | awk -F ' ' '{ print $15 }')"
json_add_int "timeout" "$timeout"
json_close_object #close the associated device object
;;
esac
done < /tmp/igmp_stats
json_close_array #close the associated devices array
json_close_object # close the groups object
done # close the loop for group addresses
json_close_array #close the groups array
done # close the loop for interfaces
json_close_object # close the snooping object
json_close_array # close the snooping array
json_dump
rm -f /tmp/igmp_stats
}
case "$1" in
list)
echo '{ "stats":{} }'
;;
call)
case "$2" in
stats)
read_mcast_stats
;;
esac
;;
esac

View File

@@ -14,36 +14,15 @@ service_triggers() {
procd_add_reload_trigger network $NAME
}
start_mcast_service() {
local param=$@
procd_open_instance
procd_set_param command "${PROG_EXE}"
if [ -n "${param}" ]; then
procd_append_param command ${param}
fi
procd_set_param respawn
procd_close_instance
}
start_service() {
if [ -f "/etc/config/mcast" ]; then
configure_mcast
fi
if [ -z "${PROG_PARAMS}" ]; then
start_mcast_service
return
fi
local prev_IFS="${IFS}"
IFS=${PROG_PARAMS_SEPARATOR}
for param in ${PROG_PARAMS}; do
IFS="${prev_IFS}"
start_mcast_service ${param}
done
procd_open_instance
procd_set_param command "$PROG_EXE"
procd_set_param respawn
procd_close_instance
}
boot() {
@@ -51,7 +30,12 @@ boot() {
start
}
stop_service() {
service_stop $PROG_EXE
}
reload_service() {
stop
start
}

View File

@@ -0,0 +1,64 @@
#!/bin/sh
. /lib/functions.sh
generate_igmp_global_params(){
uci add mcast igmp
uci rename mcast.@igmp[-1]="igmp"
uci set mcast.@igmp[-1].max_membership="20"
uci set mcast.@igmp[-1].max_msf="10"
uci set mcast.@igmp[-1].qrv="2"
uci set mcast.@igmp[-1].force_version="0"
uci add mcast mld
uci rename mcast.@mld[-1]="mld"
uci set mcast.@mld[-1].mldv1_unsolicited_report_interval="10"
uci set mcast.@mld[-1].mldv2_unsolicited_report_interval="1"
uci set mcast.@mld[-1].qrv="2"
uci set mcast.@mld[-1].force_version="0"
uci commit mcast
}
generate_mcast_config(){
up_itf="$(uci -q get network.wan.device)"
uci add mcast proxy
uci rename mcast.@proxy[-1]="igmp_proxy_1"
uci set mcast.@proxy[-1].enable="1"
uci set mcast.@proxy[-1].proto="igmp"
uci set mcast.@proxy[-1].version="2"
uci set mcast.@proxy[-1].robustness="2"
uci set mcast.@proxy[-1].query_interval="125"
uci set mcast.@proxy[-1].query_response_interval="100"
uci set mcast.@proxy[-1].last_member_query_interval="10"
uci set mcast.@proxy[-1].fast_leave="1"
uci set mcast.@proxy[-1].snooping_mode="2"
uci add_list mcast.@proxy[-1].downstream_interface="br-lan"
IFS=" "
for itf in $up_itf; do
uci add_list mcast.@proxy[-1].upstream_interface="$itf"
done
uci add_list mcast.@proxy[-1].filter="239.0.0.0/8"
uci commit mcast
}
if [ -s "/etc/config/mcast" ]; then
if uci -q get mcast.@proxy[0] >/dev/null; then
# return if there is any valid content
exit
elif uci -q get mcast.@snooping[0] >/dev/null; then
# return if there is any valid content
exit
else
rm -f /etc/config/mcast
fi
fi
touch /etc/config/mcast
generate_igmp_global_params
generate_mcast_config

View File

@@ -0,0 +1,547 @@
#!/bin/sh
. /lib/functions.sh
. /usr/share/libubox/jshn.sh
include /lib/network
CONFFILE=/var/mcpd.conf
PROG_EXE=/usr/sbin/mcpd
# Parameters available in snooping configuration
igmp_s_enable=0
igmp_s_version=2
igmp_s_query_interval=125
igmp_s_q_resp_interval=100
igmp_s_last_mem_q_int=10
igmp_s_fast_leave=1
igmp_s_robustness=2
igmp_s_mode=0
igmp_s_iface=""
igmp_s_exceptions=""
mld_s_enable=0
mld_s_version=2
mld_s_robustness=2
mld_s_mode=0
mld_s_iface=""
mld_s_exceptions=""
# Global params
max_groups=25
max_msf=10
max_members=25
mldv1_unsolicited_report_interval=10
mldv2_unsolicited_report_interval=1
# Parameters available in proxy configuration
igmp_p_enable=0
igmp_p_version=2
igmp_query_interval=125
igmp_q_resp_interval=100
igmp_last_mem_q_int=10
igmp_fast_leave=1
igmp_p_robustness=2
igmp_p_mode=0
igmp_p_up_interfaces=""
igmp_p_down_interfaces=""
igmp_p_exceptions=""
mld_p_enable=0
mld_p_version=1
mld_query_interval=125
mld_q_resp_interval=100
mld_last_mem_q_int=10
mld_fast_leave=1
mld_p_robustness=2
mld_p_mode=0
mld_p_up_interfaces=""
mld_p_down_interfaces=""
mld_p_exceptions=""
proxdevs=""
ethwan="$(db -q get hw.board.ethernetWanPort)"
read_snooping() {
local config="$1"
local sec_enable
local proto
config_get sec_enable "$config" enable 0
config_get proto "$config" proto
if [ "$sec_enable" == "0" ]; then
return
fi
if [ "$proto" == "igmp" ]; then
igmp_s_enable=$sec_enable
config_get igmp_s_version "$config" version 2
config_get igmp_s_query_interval "$config" query_interval 125
config_get igmp_s_q_resp_interval "$config" query_response_interval 100
config_get igmp_s_last_mem_q_int "$config" last_member_query_interval 10
config_get igmp_s_fast_leave "$config" fast_leave 1
config_get igmp_s_robustness "$config" robustness 2
config_get igmp_s_mode "$config" snooping_mode 0
config_get igmp_s_iface "$config" interface
config_get igmp_s_exceptions "$config" filter
return
fi
if [ "$proto" == "mld" ]; then
mld_s_enable=$sec_enable
config_get mld_s_version "$config" version 2
config_get mld_s_query_interval "$config" query_interval 125
config_get mld_s_q_resp_interval "$config" query_response_interval 100
config_get mld_s_last_mem_q_int "$config" last_member_query_interval 10
config_get mld_s_fast_leave "$config" fast_leave 1
config_get mld_s_robustness "$config" robustness 2
config_get mld_s_mode "$config" snooping_mode 0
config_get mld_s_iface "$config" interface
config_get mld_s_exceptions "$config" filter
return
fi
}
read_proxy() {
local config="$1"
local sec_enable
local proto
config_get sec_enable "$config" enable 0
config_get proto "$config" proto
if [ "$sec_enable" == "0" ]; then
return
fi
if [ "$proto" == "igmp" ]; then
igmp_p_enable=$sec_enable
config_get igmp_p_version "$config" version 2
config_get igmp_query_interval "$config" query_interval 125
config_get igmp_q_resp_interval "$config" query_response_interval 100
config_get igmp_last_mem_q_int "$config" last_member_query_interval 10
config_get igmp_fast_leave "$config" fast_leave 1
config_get igmp_p_robustness "$config" robustness 2
config_get igmp_p_mode "$config" snooping_mode 0
config_get igmp_p_up_interfaces "$config" upstream_interface
config_get igmp_p_down_interfaces "$config" downstream_interface
config_get igmp_p_exceptions "$config" filter
return
fi
if [ "$proto" == "mld" ]; then
mld_p_enable=$sec_enable
config_get mld_p_version "$config" version 2
config_get mld_query_interval "$config" query_interval 125
config_get mld_q_resp_interval "$config" query_response_interval 100
config_get mld_last_mem_q_int "$config" last_member_query_interval 10
config_get mld_fast_leave "$config" fast_leave 1
config_get mld_p_robustness "$config" robustness 2
config_get mld_p_mode "$config" snooping_mode 0
config_get mld_p_up_interfaces "$config" upstream_interface
config_get mld_p_down_interfaces "$config" downstream_interface
config_get mld_p_exceptions "$config" filter
return
fi
}
config_snooping_common_params() {
local protocol="$1"
echo "${protocol}-default-version $2" >> $CONFFILE
echo "${protocol}-robustness-value $3" >> $CONFFILE
echo "${protocol}-max-groups $max_groups" >> $CONFFILE
echo "${protocol}-max-sources $max_msf" >> $CONFFILE
echo "${protocol}-max-members $max_members" >> $CONFFILE
echo "${protocol}-snooping-enable $4" >> $CONFFILE
}
config_mcast_querier_params() {
local protocol="$1"
local query_interval=$2
local q_resp_interval=$3
local last_mem_q_int=$4
echo "${protocol}-query-interval $query_interval" >> $CONFFILE
echo "${protocol}-query-response-interval $q_resp_interval" >> $CONFFILE
echo "${protocol}-last-member-query-interval $last_mem_q_int" >> $CONFFILE
}
config_snooping_upstream_interface() {
local snooping_upstream_intf=""
json_load "$(devstatus $1)"
logger -t "mcastconf" "$(devstatus $1)"
itr=1
json_select bridge-members
# loop over the bridge and find the device on wan port
while json_get_var dev $itr; do
case "$dev" in
*.*)
port="$(echo "$dev" | cut -d'.' -f 1)"
if [ $port == $ethwan ]; then
ifconfig $dev | grep RUNNING >/dev/null && $snooping_upstream_intf="$dev" && break
fi
;;
esac
itr=$(($itr + 1))
done
json_select ..
# if none of the bridge members are on wan port, set the wan port itself
if [ -n "$snooping_upstream_intf" ]; then
echo "upstream-interface $snooping_upstream_intf" >>$CONFFILE
else
echo "upstream-interface $ethwan" >>$CONFFILE
fi
}
config_snooping_on_bridge() {
local protocol="$1"
local bcm_mcast_p=1
echo "${protocol}-snooping-interfaces $2" >> $CONFFILE
[ "$protocol" == "mld" ] && bcm_mcast_p=2
for snpif in $2; do
case "$snpif" in
br-*)
# set snooping mode on the bridge
bcmmcastctl mode -i $snpif -p $bcm_mcast_p -m $3
;;
esac
done
}
config_mcast_proxy_interface() {
local itr
local p1="$1"
local p_enable
if [ "$p1" == "igmp" ]; then
p_enable=$igmp_p_enable
else
p_enable=$mld_p_enable
fi
for proxif in $2; do
case "$proxif" in
br-*)
proxdevs="$proxdevs $proxif"
echo "upstream-interface $proxif" >>$CONFFILE
;;
*)
ifconfig $proxif | grep RUNNING >/dev/null && proxdevs="$proxdevs $proxif"
;;
esac
done
if [ $p_enable -eq 1 ]; then
echo "${p1}-proxy-interfaces $proxdevs" >> $CONFFILE
fi
# if proxdevs is empty set the wan port as mcast-interface
if [ -n "$proxdevs" ]; then
echo "${p1}-mcast-interfaces $proxdevs" >> $CONFFILE
else
echo "${p1}-mcast-interfaces $ethwan" >> $CONFFILE
fi
}
configure_mcpd_snooping() {
local protocol="$1"
local exceptions
local filter_ip=""
local fast_leave=0
# Configure snooping related params
if [ "$protocol" == "igmp" ]; then
config_snooping_common_params $protocol $igmp_s_version $igmp_s_robustness $igmp_s_mode
config_mcast_querier_params $protocol $igmp_s_query_interval $igmp_s_q_resp_interval $igmp_s_last_mem_q_int
config_snooping_upstream_interface "$igmp_s_iface"
config_snooping_on_bridge $protocol $igmp_s_iface $igmp_s_mode
exceptions=$igmp_s_exceptions
fast_leave=$igmp_s_fast_leave
elif [ "$protocol" == "mld" ]; then
config_snooping_common_params $protocol $mld_s_version $mld_s_robustness $mld_s_mode
config_mcast_querier_params $protocol $mld_s_query_interval $mld_s_q_resp_interval $mld_s_last_mem_q_int
config_snooping_upstream_interface "$mld_s_iface"
config_snooping_on_bridge $protocol $mld_s_iface $mld_s_mode
exceptions=$mld_s_exceptions
fast_leave=$mld_s_fast_leave
fi
echo "${protocol}-proxy-enable 0" >> $CONFFILE
echo "${protocol}-fast-leave $fast_leave" >> $CONFFILE
if [ -n "$exceptions" ]; then
IFS=" "
for excp in $exceptions; do
case $excp in
*/*)
tmp="$(ipcalc.sh $excp | grep IP | awk '{print substr($0,4)}')"
tmp1="$(ipcalc.sh $excp | grep NETMASK | awk '{print substr($0,9)}')"
filter_ip="$filter_ip $tmp/$tmp1"
;;
*)
filter_ip="$filter_ip $excp"
;;
esac
done
echo "${protocol}-mcast-snoop-exceptions $filter_ip" >> $CONFFILE
fi
}
configure_mcpd_proxy() {
local protocol="$1"
local fast_leave=0
local exceptions=""
# Configure snooping related params
if [ "$protocol" == "igmp" ]; then
config_snooping_common_params $protocol $igmp_p_version $igmp_p_robustness $igmp_p_mode
config_mcast_querier_params $protocol $igmp_query_interval $igmp_q_resp_interval $igmp_last_mem_q_int
config_mcast_proxy_interface $protocol "$igmp_p_up_interfaces"
config_snooping_on_bridge $protocol $igmp_p_down_interfaces $igmp_p_mode
fast_leave=$igmp_fast_leave
exceptions=$igmp_p_exceptions
elif [ "$protocol" == "mld" ]; then
config_snooping_common_params $protocol $mld_p_version $mld_p_robustness $mld_p_mode
config_mcast_querier_params $protocol $mld_query_interval $mld_q_resp_interval $mld_last_mem_q_int
config_mcast_proxy_interface $protocol "$mld_p_up_interfaces"
config_snooping_on_bridge $protocol $mld_p_down_interfaces $mld_p_mode
fast_leave=$mld_fast_leave
exceptions=$mld_p_exceptions
fi
# This function will only be hit in case proxy is enabled, so hard coding
# proxy enable should not be a problem
echo "${protocol}-proxy-enable 1" >> $CONFFILE
echo "${protocol}-fast-leave $fast_leave" >> $CONFFILE
if [ -n "$exceptions" ]; then
IFS=" "
for excp in $exceptions; do
case $excp in
*/*)
tmp="$(ipcalc.sh $excp | grep IP | awk '{print substr($0,4)}')"
tmp1="$(ipcalc.sh $excp | grep NETMASK | awk '{print substr($0,9)}')"
filter_ip="$filter_ip $tmp/$tmp1"
;;
*)
filter_ip="$filter_ip $excp"
;;
esac
done
echo "${protocol}-mcast-snoop-exceptions $filter_ip" >> $CONFFILE
fi
}
disable_snooping() {
local bcm_mcast_p=$1
for br in $(brctl show | grep 'br-' | awk '{print$1}' | tr '\n' ' '); do
bcmmcastctl mode -i $br -p $bcm_mcast_p -m 0 # disable snooping on all bridges
done
}
configure_mcpd() {
disable_snooping 1
disable_snooping 2
# BCM's mcpd does not allow configuration of proxy and L2 snooping simultaneously, hence
# here, if proxy is to be configured then the configuration params of snooping are ignored.
if [ "$igmp_p_enable" == "1" ]; then
configure_mcpd_proxy igmp
elif [ "$igmp_s_enable" == "1" ]; then
configure_mcpd_snooping igmp
fi
proxdevs=""
if [ "$mld_p_enable" == "1" ]; then
configure_mcpd_proxy mld
elif [ "$mld_s_enable" == "1" ]; then
configure_mcpd_snooping mld
fi
}
read_mcast_snooping_params() {
config_load mcast
config_foreach read_snooping snooping
}
read_mcast_proxy_params() {
config_load mcast
config_foreach read_proxy proxy
}
config_global_params() {
local igmp_qrv
local igmp_force_version
local mld_qrv
local mld_force_version
config_load mcast
config_get max_msf igmp max_msf 10
config_get max_groups igmp max_membership 25
config_get igmp_qrv igmp qrv 2
config_get igmp_force_version igmp force_version 0
config_get mld_qrv mld qrv 2
config_get mldv1_unsolicited_report_interval mld mldv1_unsolicited_report_interval 10
config_get mldv2_unsolicited_report_interval mld mldv2_unsolicited_report_interval 1
config_get mld_force_version mld force_version 0
# mcpd internally writes max_groups and max_msf, no need to modify
# here directly
echo $igmp_qrv > /proc/sys/net/ipv4/igmp_qrv
echo $igmp_force_version > /proc/sys/net/ipv4/conf/all/force_igmp_version
echo $mld_qrv > /proc/sys/net/ipv6/mld_qrv
echo $mld_force_version > /proc/sys/net/ipv6/conf/all/force_mld_version
echo $mldv1_unsolicited_report_interval > /proc/sys/net/ipv6/conf/all/mldv1_unsolicited_report_interval
echo $mldv2_unsolicited_report_interval > /proc/sys/net/ipv6/conf/all/mldv2_unsolicited_report_interval
}
setup_mcast_mode() {
# set the mode at chip to allow both tagged and untagged multicast forwarding
bs /b/c iptv lookup_method=group_ip_src_ip
}
configure_mcast() {
rm -f $CONFFILE
touch $CONFFILE
config_global_params
read_mcast_snooping_params
read_mcast_proxy_params
configure_mcpd
}
read_mcast_stats() {
cat /proc/net/igmp_snooping > /tmp/igmp_stats
local mcast_addrs=""
local ifaces=""
while read line; do
# reading each line
case $line in
br-*)
found_iface=0
snoop_iface="$(echo $line | awk -F ' ' '{ print $1 }')"
if [ -z "$ifaces" ]; then
ifaces="$snoop_iface"
continue
fi
IFS=" "
for ifx in $ifaces; do
if [ $ifx == $snoop_iface ]; then
found_iface=1
break
fi
done
if [ $found_iface -eq 0 ]; then
ifaces="$ifaces $snoop_iface"
continue
fi
;;
esac
done < /tmp/igmp_stats
while read line; do
# reading each line
case $line in
br-*)
found_ip=0
grp_ip="$(echo $line | awk -F ' ' '{ print $10 }')"
if [ -z "$mcast_addrs" ]; then
mcast_addrs="$grp_ip"
continue
fi
IFS=" "
for ip_addr in $mcast_addrs; do
if [ $ip_addr == $grp_ip ]; then
found_ip=1
break
fi
done
if [ $found_ip -eq 0 ]; then
mcast_addrs="$mcast_addrs $grp_ip"
continue
fi
;;
esac
done < /tmp/igmp_stats
json_init
json_add_array "snooping"
json_add_object ""
IFS=" "
for intf in $ifaces; do
while read line; do
# reading each line
case $line in
br-*)
snoop_iface="$(echo $line | awk -F ' ' '{ print $1 }')"
if [ "$snoop_iface" != "$intf" ]; then
continue
fi
json_add_string "interface" "$intf"
json_add_array "groups"
break
;;
esac
done < /tmp/igmp_stats
IFS=" "
for gip_addr in $mcast_addrs; do
grp_obj_added=0
while read line; do
# reading each line
case $line in
br-*)
snoop_iface="$(echo $line | awk -F ' ' '{ print $1 }')"
if [ "$snoop_iface" != "$intf" ]; then
continue
fi
grp_ip="$(echo $line | awk -F ' ' '{ print $10 }')"
if [ "$grp_ip" != "$gip_addr" ]; then
continue
fi
if [ $grp_obj_added -eq 0 ]; then
json_add_object ""
gip="$(ipcalc.sh $gip_addr | grep IP | awk '{print substr($0,4)}')"
json_add_string "groupaddr" "$gip"
json_add_array "clients"
grp_obj_added=1
fi
json_add_object ""
host_ip="$(echo $line | awk -F ' ' '{ print $14 }')"
h_ip="$(ipcalc.sh $host_ip | grep IP | awk '{print substr($0,4)}')"
json_add_string "ipaddr" "$h_ip"
src_port="$(echo $line | awk -F ' ' '{ print $2 }')"
json_add_string "device" "$src_port"
timeout="$(echo $line | awk -F ' ' '{ print $15 }')"
json_add_int "timeout" "$timeout"
json_close_object #close the associated device object
;;
esac
done < /tmp/igmp_stats
json_close_array #close the associated devices array
json_close_object # close the groups object
done # close the loop for group addresses
json_close_array #close the groups array
done # close the loop for interfaces
json_close_object # close the snooping object
json_close_array # close the snooping array
json_dump
rm -f /tmp/igmp_stats
}

View File

@@ -1,2 +0,0 @@
# Forward multicast packets from wan to lan
iptables -t filter -A zone_wan_forward -p udp -d 224.0.0.0/240.0.0.0 -m comment --comment "!fw3: Allow-Multicast-UDP" -j zone_lan_dest_ACCEPT

View File

@@ -1,12 +0,0 @@
#!/bin/sh
. /lib/functions.sh
# Add firewall include instance
uci -q batch <<-EOT
delete firewall.mcast
set firewall.mcast=include
set firewall.mcast.path=/etc/firewall.mcast
set firewall.mcast.reload=1
commit firewall
EOT

View File

@@ -1,149 +0,0 @@
#!/bin/sh
. /lib/mcast/common.sh
include /lib/network
CONFFILE=
PROG_EXE=/usr/sbin/mcproxy
PROG_PARAMS=
PROG_PARAMS_SEPARATOR=:
setup_mcast_mode() {
unused(){ :;}
}
config_mcproxy_interfaces() {
local upstreams="$1"
local downstreams="$2"
local exceptions="$3"
local str_up=""
if [ -n "$upstreams" ]; then
for upstream in $upstreams; do
str_up="$str_up \"$upstream\""
done
fi
local str_down=""
if [ -n "$downstreams" ]; then
for downstream in $downstreams; do
str_down="$str_down \"$downstream\""
done
fi
if [ ! -z $downstream ]; then
echo -e "pinstance main:$str_up ==>$str_down;\n" >> $CONFFILE
fi
if [ -z "$exceptions" ] || [ -z "$upstreams" ]; then
return
fi
for upstream in $upstreams; do
local filter=""
for excp in $exceptions; do
case $excp in
*/*)
ip_start="$(ipcalc.sh $excp | grep IP | awk '{print substr($0,4)}')"
ip_end="$(ipcalc.sh $excp | grep BROADCAST | awk '{print substr($0,11)}')"
filter="$filter ($ip_start - $ip_end | *)"
;;
*)
filter="$filter ($excp | *)"
;;
esac
done
echo "pinstance main upstream \"$upstream\" in blacklist table{$filter };" >> $CONFFILE
echo "pinstance main upstream \"$upstream\" out blacklist table{$filter };" >> $CONFFILE
done
}
config_mcproxy_instance() {
local protocol="$1"
local version="$2"
local robustness=
local query_interval=
local q_resp_interval=
local last_mem_q_int=
local fast_leave=0
local exceptions=
local upstreams=
local downstreams=
CONFFILE=/var/etc/mcproxy_"$protocol".conf
rm -f $CONFFILE
touch $CONFFILE
if [ "$protocol" == "igmp" ]; then
case "$version" in
[1-3])
echo -e "protocol IGMPv${version};\n" >> $CONFFILE
;;
*)
echo -e "protocol IGMPv2;\n" >> $CONFFILE
;;
esac
robustness=$igmp_p_robustness
query_interval=$igmp_query_interval
q_resp_interval=$igmp_q_resp_interval
last_mem_q_int=$igmp_last_mem_q_int
fast_leave=$igmp_fast_leave
exceptions=$igmp_p_exceptions
upstreams=$igmp_p_up_interfaces
downstreams=$igmp_p_down_interfaces
elif [ "$protocol" == "mld" ]; then
case "$version" in
[1-2])
echo -e "protocol MLDv${version};\n" >> $CONFFILE
;;
*)
echo -e "protocol MLDv2;\n" >> $CONFFILE
;;
esac
robustness=$mld_p_robustness
query_interval=$mld_query_interval
q_resp_interval=$mld_q_resp_interval
last_mem_q_int=$mld_last_mem_q_int
fast_leave=$mld_fast_leave
exceptions=$mld_p_exceptions
upstreams=$mld_p_up_interfaces
downstreams=$mld_p_down_interfaces
fi
[ -n "$robustness" ] && echo -e "rv $robustness;" >> $CONFFILE
[ -n "$query_interval" ] && echo -e "qi $query_interval;" >> $CONFFILE
[ -n "$q_resp_interval" ] && echo -e "qri $q_resp_interval;" >> $CONFFILE
[ -n "$last_mem_q_int" ] && echo -e "lmqi $last_mem_q_int;" >> $CONFFILE
[ -n "$fast_leave" ] && echo -e "fastleave $fast_leave;\n" >> $CONFFILE
[ -n "$upstreams" ] && [ -n "$downstreams" ] &&
config_mcproxy_interfaces "$upstreams" "$downstreams" "$exceptions"
PROG_PARAMS="${PROG_PARAMS} -f ${CONFFILE}${PROG_PARAMS_SEPARATOR}"
}
config_mcproxy() {
if [ "$igmp_p_enable" == "1" ]; then
config_mcproxy_instance igmp "$igmp_p_version"
fi
if [ "$mld_p_enable" == "1" ]; then
config_mcproxy_instance mld "$mld_p_version"
fi
}
configure_mcast() {
config_global_params "set_max_groups_and_sources"
read_mcast_snooping_params
read_mcast_proxy_params
config_mcproxy
}

View File

@@ -0,0 +1,18 @@
#!/bin/sh
. /usr/share/libubox/jshn.sh
. /lib/functions.sh
include /lib/mcast
case "$1" in
list)
echo '{ "stats":{} }'
;;
call)
case "$2" in
stats)
read_mcast_stats
;;
esac
;;
esac

View File

@@ -6,22 +6,19 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=obudpst
PKG_VERSION:=7.5.1
PKG_VERSION:=7.2.1
PKG_SOURCE_VERSION:=9c448095c9773bd7e5cea143af07817ad9f3c6ba
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/BroadbandForum/obudpst.git
PKG_SOURCE_VERSION:=a8faf1925ea9189467e7f8d3b9d93c67c8b927bd
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
PKG_LICENSE:=BSD-3-Clause
PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
CMAKE_OPTIONS += -DDISABLE_INT_TIMER=ON
define Package/obudpst
CATEGORY:=Utilities
DEPENDS+=+libopenssl
@@ -42,10 +39,4 @@ define Package/obudpst/install
$(INSTALL_BIN) $(PKG_BUILD_DIR)/udpst $(1)/usr/sbin/udpst
endef
define Host/Install
$(INSTALL_DIR) $(STAGING_DIR_HOST)/obudpst
$(CP) $(HOST_BUILD_DIR)/udpst $(STAGING_DIR_HOST)/obudpst/
endef
$(eval $(call HostBuild))
$(eval $(call BuildPackage,obudpst))

View File

@@ -5,13 +5,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=obuspa
PKG_VERSION:=7.0.2.4
PKG_VERSION:=6.0.0.14
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/obuspa.git
PKG_SOURCE_VERSION:=902d7a9586c3faa16337fef71f538daa878a47b8
PKG_SOURCE_URL:=https://dev.iopsys.eu/fork/obuspa.git
PKG_SOURCE_VERSION:=3df3346238a9eef2168fddadcef01ebe311053e4
PKG_MAINTAINER:=Vivek Dutta <vivek.dutta@iopsys.eu>
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
@@ -110,6 +110,7 @@ define Package/obuspa/install
$(INSTALL_DATA) ./files/etc/bbfdm/json/USPAgent.json $(1)/etc/bbfdm/json/USPAgent.json
$(INSTALL_DATA) ./files/etc/bbfdm/json/TransferComplete.json $(1)/etc/bbfdm/json/TransferComplete.json
$(INSTALL_BIN) ./files/etc/uci-defaults/01-fix-upgrade-uci $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./files/etc/uci-defaults/50-add-mqtt-usp-test $(1)/etc/uci-defaults/
endef
$(eval $(call BuildPackage,obuspa))

View File

@@ -1,6 +1,6 @@
config obuspa 'global'
option enabled '1'
option debug '0'
option debug '1'
option log_level '1'
option prototrace '0'
option db_file '/etc/obuspa/usp.db'
@@ -10,3 +10,23 @@ config obuspa 'global'
#option client_cert '/etc/obuspa/client.pem'
#option log_dest '/var/log/obuspa'
# Adds Device.LocalAgent.MTP.
config mtp 'test_mtp'
option Protocol 'MQTT'
option ResponseTopicConfigured '/usp/endpoint'
option mqtt 'testmqtt'
# Adds Device.MQTT.Client.
config mqtt 'testmqtt'
option BrokerAddress '127.0.0.1'
option BrokerPort '1883'
option TransportProtocol 'TCP/IP'
# Adds Device.LocalAgent.Controller.
config controller 'testcontroller'
option EndpointID 'proto::interop-usp-controller'
option Protocol 'MQTT'
option Topic '/usp/controller'
option mqtt 'testmqtt'
option assigned_role_name 'full_access'

View File

@@ -300,6 +300,56 @@ validate_challenge_section()
'LockoutPeriod:uinteger:0'
}
get_oui_from_db()
{
db -q get device.deviceinfo.ManufacturerOUI
}
get_serial_from_db()
{
db -q get device.deviceinfo.SerialNumber
}
publish_endpoint()
{
local AgentEndpointID serial oui user pass
if ! uci -q get obuspa.testmqtt; then
return 0;
fi
# return if mosquitto_pub is not present
if [ ! "$(command -v mosquitto_pub)" ]; then
log "mosquitto_pub not present can't publish EndpointID"
return 0;
fi
# Get endpoint id from obuspa config first
config_load obuspa
config_get AgentEndpointID localagent EndpointID ""
if [ -z "${AgentEndpointID}" ]; then
serial=$(get_serial_from_db)
oui=$(get_oui_from_db)
AgentEndpointID="os::${oui}-${serial//+/%2B}"
fi
config_get user testmqtt Username
config_get pass testmqtt Password
# publish Agent's EndpointID in mosquito broker for discovery by usp-js
# This is a work around till obuspa adds supports for mDNS discovery
if [ -n "${user}" ] && [ -n "${pass}" ]; then
log "Publishing EndpointID ${AgentEndpointID} to local mqtt broker with username, password"
mosquitto_pub -r -t "obuspa/EndpointID" -m "${AgentEndpointID}" -u "${user}" -P "${pass}"
elif [ -n "${user}" ]; then
log "Publishing EndpointID ${AgentEndpointID} to local mqtt broker with username only"
mosquitto_pub -r -t "obuspa/EndpointID" -m "${AgentEndpointID}" -u "${user}"
else
log "Publishing EndpointID ${AgentEndpointID} to local mqtt broker"
mosquitto_pub -r -t "obuspa/EndpointID" -m "${AgentEndpointID}"
fi
}
configure_localagent()
{
local EndpointID
@@ -920,7 +970,7 @@ delete_sql_db_entry_with_pattern()
return 0;
fi
params="$(grep "${pattern}" ${DB_DUMP}|awk '{print $1}')"
params="$(grep ${pattern} ${DB_DUMP}|awk '{print $1}')"
for p in ${params}; do
db_del_sql "${p}"
done
@@ -931,7 +981,7 @@ check_n_delete_db()
local sec t r path
sec="${1}"
if uci -q get obuspa."${sec}" >/dev/null 2>&1; then
if uci -q get obuspa.${sec} >/dev/null 2>&1; then
return 0
fi
@@ -982,7 +1032,7 @@ db_init()
fi
# remove entries from db if deleted from uci
if [ -f "${DB_DUMP}" ] && [ "${reason}" = "update" ] && [ -f "/tmp/obuspa/obuspa" ]; then
if [ -f "${DB_DUMP}" ] && [ "${reason}" == "update" ] && [ -f "/tmp/obuspa/obuspa" ]; then
reverse_update_db_with_uci
fi
@@ -1025,10 +1075,14 @@ register_service()
"${respawn_threshold:-5}" \
"${respawn_timeout:-10}" "${respawn_retry:-3}"
procd_set_param watch bbfdm
procd_set_param watch usp.raw
procd_close_instance
}
service_running() {
publish_endpoint
}
start_service() {
local enabled
@@ -1059,7 +1113,7 @@ service_triggers() {
# Create a reload trigger if schema update avaialble
procd_open_trigger
json_add_array
json_add_string "" "bbfdm"
json_add_string "" "usp.raw"
json_add_array
json_add_string "" "if"
json_add_array

View File

@@ -1,5 +1,6 @@
{
"dmcaching_exclude": [
"Device.InterfaceStack.",
"Device.Hosts.Host.",
"Device.IEEE1905.",
"Device.WiFi.DataElements."

View File

@@ -5,10 +5,10 @@
fix_stomp_section() {
local encryption
config_get_bool encryption "${1}" encryption ""
config_get_bool encryption $1 encryption ""
if [ -n "${encryption}" ]; then
uci_set obuspa "${1}" encryption ""
uci_set obuspa "${1}" EnableEncryption "$encryption"
uci_set obuspa $1 encryption ""
uci_set obuspa $1 EnableEncryption "$encryption"
fi
}

View File

@@ -0,0 +1,14 @@
add_usp_test()
{
if ! uci_get mosquitto usptest >/dev/null 2>&1; then
uci_add mosquitto listener usptest
uci_set mosquitto usptest enabled 1
uci_set mosquitto usptest port '9001'
uci_set mosquitto usptest protocol 'websockets'
uci_set mosquitto usptest require_certificates '0'
uci_set mosquitto usptest auth_plugin '/usr/lib/mosquitto_auth_shadow.so'
fi
}
uci_load mosquitto
add_usp_test

View File

@@ -0,0 +1,140 @@
diff --git a/src/core/device.h b/src/core/device.h
index adf8fa6..072f953 100644
--- a/src/core/device.h
+++ b/src/core/device.h
@@ -111,6 +111,7 @@ typedef struct
// Following member variables only set if USP message was received over MQTT
int mqtt_instance;
char *mqtt_topic; // only set if reply_to was specified in the received MQTT packet
+ char *mqtt_topic_recv;
// Following member variables only set if USP message was received over CoAP
@@ -252,7 +253,7 @@ void DEVICE_MTP_NotifyMqttConnDeleted(int mqtt_instance);
int DEVICE_MTP_ValidateMqttReference(dm_req_t *req, char *value);
void DEVICE_CONTROLLER_SetRolesFromMqtt(int mqtt_instance, ctrust_role_t role);
char *DEVICE_CONTROLLER_GetControllerTopic(int mqtt_instance);
-
+int validate_controller_topic_by_endpointid(char *endpointid, mtp_protocol_t proto, char *recv_topic);
//------------------------------------------------------------------------------
// Tables used to convert to/from an enumeration to/from a string
extern const enum_entry_t mtp_protocols[kMtpProtocol_Max];
diff --git a/src/core/device_controller.c b/src/core/device_controller.c
index 62c803f..103388d 100755
--- a/src/core/device_controller.c
+++ b/src/core/device_controller.c
@@ -239,6 +239,41 @@ int Async_E2ESessionReset(dm_req_t *req, kv_vector_t *input_args, int request);
extern const enum_entry_t e2e_session_modes[kE2EMode_Max];
#endif
+
+int validate_controller_topic_by_endpointid(char *endpointid, mtp_protocol_t proto, char *recv_topic)
+{
+ controller_t *cont = FindEnabledControllerByEndpointId(endpointid);
+ if (cont == NULL)
+ {
+ USP_LOG_Error("not able to find the controller from endpointid [%s]", endpointid);
+ return USP_ERR_PERMISSION_DENIED;
+ }
+#ifdef ENABLE_MQTT
+ if (proto == kMtpProtocol_MQTT)
+ {
+ controller_mtp_t *mtp = FindFirstEnabledMtp(cont, proto);
+
+ if (mtp == NULL) {
+ USP_LOG_Error("Not able to find mtp[%d] for endpointid [%s]", proto, endpointid);
+ return USP_ERR_REQUEST_DENIED;
+ }
+
+ if (mtp->protocol != proto) {
+ USP_LOG_Error("No matching mtp[%d] for endpointid [%s]", proto, endpointid);
+ return USP_ERR_REQUEST_DENIED;
+ }
+
+ char *response_topic = DEVICE_MTP_GetAgentMqttResponseTopic(mtp->mqtt_connection_instance);
+ if (response_topic && strcmp(response_topic, recv_topic) != 0 ) {
+ USP_LOG_Error("Controller response topic[%s] and recv topic[%s] mismatch, probably a spoof message", response_topic, recv_topic);
+ return USP_ERR_PERMISSION_DENIED;
+ }
+ }
+#endif
+
+ return USP_ERR_OK;
+}
+
/*********************************************************************//**
**
** DEVICE_CONTROLLER_Init
diff --git a/src/core/dm_exec.c b/src/core/dm_exec.c
index c0b95d8..6eb51e2 100755
--- a/src/core/dm_exec.c
+++ b/src/core/dm_exec.c
@@ -624,6 +624,7 @@ void DM_EXEC_PostUspRecord(unsigned char *pbuf, int pbuf_len, ctrust_role_t role
pur->mtp_reply_to.coap_encryption = mrt->coap_encryption;
pur->mtp_reply_to.coap_reset_session_hint = mrt->coap_reset_session_hint;
pur->mtp_reply_to.mqtt_topic = USP_STRDUP(mrt->mqtt_topic);
+ pur->mtp_reply_to.mqtt_topic_recv = USP_STRDUP(mrt->mqtt_topic_recv);
pur->mtp_reply_to.mqtt_instance = mrt->mqtt_instance;
pur->mtp_reply_to.wsclient_cont_instance = mrt->wsclient_cont_instance;
pur->mtp_reply_to.wsclient_mtp_instance = mrt->wsclient_mtp_instance;
@@ -1144,6 +1145,7 @@ void ProcessMessageQueueSocketActivity(socket_set_t *set)
USP_SAFE_FREE(mrt->coap_resource);
USP_SAFE_FREE(mrt->mqtt_topic);
USP_SAFE_FREE(mrt->cont_endpoint_id);
+ USP_SAFE_FREE(mrt->mqtt_topic_recv);
break;
#ifndef DISABLE_STOMP
diff --git a/src/core/mqtt.c b/src/core/mqtt.c
index 7dba9f4..3ee9c97 100644
--- a/src/core/mqtt.c
+++ b/src/core/mqtt.c
@@ -3141,6 +3141,7 @@ void ReceiveMqttMessage(mqtt_client_t *client, const struct mosquitto_message *m
mrt.mqtt_topic = response_topic;
}
+ mrt.mqtt_topic_recv = message->topic;
// Message may not be valid USP
DM_EXEC_PostUspRecord(message->payload, message->payloadlen, client->role, &mrt);
}
diff --git a/src/core/msg_handler.c b/src/core/msg_handler.c
index ce67626..4af9ade 100644
--- a/src/core/msg_handler.c
+++ b/src/core/msg_handler.c
@@ -118,7 +118,7 @@ static enum_entry_t mtp_content_types[] = {
//------------------------------------------------------------------------------
// Forward declarations. Note these are not static, because we need them in the symbol table for USP_LOG_Callstack() to show them
int HandleUspMessage(Usp__Msg *usp, char *controller_endpoint, mtp_reply_to_t *mrt);
-int ValidateUspRecord(UspRecord__Record *rec);
+int ValidateUspRecord(UspRecord__Record *rec, mtp_reply_to_t *mrt);
char *MtpSendItemToString(mtp_send_item_t *msi);
void CacheControllerRoleForCurMsg(char *endpoint_id, ctrust_role_t role, mtp_protocol_t protocol);
int QueueUspNoSessionRecord(usp_send_item_t *usi, char *endpoint_id, char *usp_msg_id, mtp_reply_to_t *mrt, time_t expiry_time);
@@ -172,7 +172,7 @@ int MSG_HANDLER_HandleBinaryRecord(unsigned char *pbuf, int pbuf_len, ctrust_rol
#endif
// Exit if USP record failed validation
- err = ValidateUspRecord(rec);
+ err = ValidateUspRecord(rec, mrt);
if (err != USP_ERR_OK)
{
goto exit;
@@ -725,7 +725,7 @@ exit:
** \return USP_ERR_OK if record is valid
**
**************************************************************************/
-int ValidateUspRecord(UspRecord__Record *rec)
+int ValidateUspRecord(UspRecord__Record *rec, mtp_reply_to_t *mrt)
{
char *endpoint_id;
@@ -806,6 +806,9 @@ int ValidateUspRecord(UspRecord__Record *rec)
return USP_ERR_REQUEST_DENIED;
}
+#if OBUSPA_CONTROLLER_MTP_VERIFY
+ return validate_controller_topic_by_endpointid(rec->from_id, mrt->protocol, mrt->mqtt_topic_recv);
+#endif
// If the code gets here, then the USP record passed validation, and the encapsulated USP message may be processed
return USP_ERR_OK;
}

View File

@@ -20,7 +20,7 @@
void DM_PRIV_RequestInit(dm_req_t *req, dm_node_t *node, char *path, dm_instances_t *inst);
--- a/src/core/msg_handler.c
+++ b/src/core/msg_handler.c
@@ -893,6 +893,20 @@ char *MtpSendItemToString(mtp_send_item_
@@ -839,6 +839,20 @@ char *MtpSendItemToString(mtp_send_item_
/*********************************************************************//**
**

View File

@@ -1,20 +0,0 @@
--- a/src/core/data_model.c
+++ b/src/core/data_model.c
@@ -1239,7 +1239,7 @@ int DATA_MODEL_NotifyInstanceAdded(char
// Exit if instance already exists - nothing to do
if (exists)
{
- USP_ERR_SetMessage("%s: Object (%s) already exists in the data model", __FUNCTION__, path);
+ // USP_ERR_SetMessage("%s: Object (%s) already exists in the data model", __FUNCTION__, path);
return USP_ERR_CREATION_FAILURE;
}
@@ -1324,7 +1324,7 @@ int DATA_MODEL_NotifyInstanceDeleted(cha
// Exit if instance does not exist - nothing to do
if (exists == false)
{
- USP_ERR_SetMessage("%s: Object (%s) does not exist in the data model", __FUNCTION__, path);
+ // USP_ERR_SetMessage("%s: Object (%s) does not exist in the data model", __FUNCTION__, path);
return USP_ERR_OBJECT_DOES_NOT_EXIST;
}

View File

@@ -1,22 +0,0 @@
diff --git a/src/core/data_model.c b/src/core/data_model.c
index 2cf4b6c..b92cf59 100644
--- a/src/core/data_model.c
+++ b/src/core/data_model.c
@@ -136,6 +136,7 @@ void DumpDataModelNodeMap(void);
int GetVendorParam(dm_node_t *node, char *path, dm_instances_t *inst, char *buf, int len, dm_req_t *req);
int SetVendorParam(dm_node_t *node, char *path, dm_instances_t *inst, char *value, dm_req_t *req);
+extern bool is_running_cli_local_command;
/*********************************************************************//**
**
** DATA_MODEL_Init
@@ -223,7 +224,9 @@ int DATA_MODEL_Init(void)
}
// Set the default values of OUI, Serial Number and (LocalAgent) EndpointID, and cache EndpointID
+ if (is_running_cli_local_command == false) {
err = DEVICE_LOCAL_AGENT_SetDefaults();
+ }
if (err != USP_ERR_OK)
{
return err;

Some files were not shown because too many files have changed in this diff Show More