Compare commits

..

4 Commits

Author SHA1 Message Date
Xiaofeng Meng
0ce30139ae update Makefile 2025-07-22 10:04:01 +02:00
Meng
72d977eef0 adapt for bbfdm/files/etc/init.d/bbfdm.services 2025-07-22 09:12:04 +02:00
Xiaofeng Meng
a9f246fe62 remomve bridgemngr 2025-07-22 01:10:37 +02:00
Meng
6704dab39f dm-framework package and bbfdm adaption change 2025-07-22 00:50:22 +02:00
175 changed files with 2753 additions and 3643 deletions

View File

@@ -5,13 +5,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=bbfdm
PKG_VERSION:=1.18.10
PKG_VERSION:=1.16.8
USE_LOCAL:=0
ifneq ($(USE_LOCAL),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/bbfdm.git
PKG_SOURCE_VERSION:=1a86b8a4432a2c3a9d41a9b18ccfc830bd0083cb
PKG_SOURCE_VERSION:=1615b42e405faceceac825f9c0387a58b90785ae
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif
@@ -55,7 +55,7 @@ define Package/dm-service
CATEGORY:=Utilities
SUBMENU:=TRx69
TITLE:=Datamodel ubus backend to expose micro-service tree
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libbbfdm-api +libbbfdm-ubus +bbf_configmngr +libeasy
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libbbfdm-api +libbbfdm-ubus +bbf_configmngr
endef
define Package/bbf_configmngr
@@ -183,7 +183,6 @@ define Package/bbf_configmngr/install
$(INSTALL_BIN) ./files/etc/init.d/bbf_configd $(1)/etc/init.d/bbf_configd
$(INSTALL_BIN) $(PKG_BUILD_DIR)/utilities/files/usr/share/bbfdm/scripts/bbf_config_notify.sh $(1)/usr/share/bbfdm/scripts/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/utilities/files/usr/share/bbfdm/scripts/bbf_default_reload.sh $(1)/etc/bbfdm/
$(INSTALL_DATA) ./files/etc/bbfdm/critical_services.json $(1)/etc/bbfdm/
endef

View File

@@ -1,51 +1,23 @@
{
"usp": [
"/etc/config/firewall",
"/etc/bbfdm/dmmap/dmmap_firewall",
"/etc/config/network",
"/etc/bbfdm/dmmap/IP",
"/etc/bbfdm/dmmap/Ethernet",
"/etc/bbfdm/dmmap/GRE",
"/etc/bbfdm/dmmap/IPv6rd",
"/etc/bbfdm/dmmap/PPP",
"/etc/bbfdm/dmmap/Routing",
"/etc/config/dhcp",
"/etc/bbfdm/dmmap/dmmap_dhcp",
"/etc/bbfdm/dmmap/dmmap_dhcp_client",
"/etc/bbfdm/dmmap/dmmap_dhcp_relay",
"/etc/bbfdm/dmmap/dmmap_dhcpv6",
"/etc/config/time",
"/etc/bbfdm/dmmap/dmmap_time",
"/etc/config/mapcontroller",
"/etc/config/wireless",
"/etc/bbfdm/dmmap/WiFi",
"/etc/config/ieee1905",
"/etc/config/mosquitto",
"/etc/config/nginx",
"/etc/config/netmode",
"/etc/bbfdm/dmmap/dmmap_netmode"
"firewall",
"network",
"dhcp",
"time",
"wireless",
"ieee1905",
"mapcontroller",
"mosquitto",
"nginx",
"netmode"
],
"cwmp": [
"/etc/config/firewall",
"/etc/bbfdm/dmmap/dmmap_firewall",
"/etc/config/network",
"/etc/bbfdm/dmmap/IP",
"/etc/bbfdm/dmmap/Ethernet",
"/etc/bbfdm/dmmap/GRE",
"/etc/bbfdm/dmmap/IPv6rd",
"/etc/bbfdm/dmmap/PPP",
"/etc/bbfdm/dmmap/Routing",
"/etc/config/dhcp",
"/etc/bbfdm/dmmap/dmmap_dhcp",
"/etc/bbfdm/dmmap/dmmap_dhcp_client",
"/etc/bbfdm/dmmap/dmmap_dhcp_relay",
"/etc/bbfdm/dmmap/dmmap_dhcpv6",
"/etc/config/mapcontroller",
"/etc/config/wireless",
"/etc/bbfdm/dmmap/WiFi",
"/etc/config/time",
"/etc/bbfdm/dmmap/dmmap_time",
"/etc/config/netmode",
"/etc/bbfdm/dmmap/dmmap_netmode"
"firewall",
"network",
"dhcp",
"mapcontroller",
"wireless",
"time",
"netmode"
]
}

View File

@@ -27,6 +27,6 @@ start_service()
service_triggers() {
for config_file in /etc/config/*; do
config_name=$(basename "$config_file")
procd_add_config_trigger "config.change" "$config_name" /usr/share/bbfdm/scripts/bbf_config_notify.sh "$config_name"
procd_add_config_trigger "config.change" "$config_name" /usr/share/bbfdm/scripts/bbf_config_notify.sh
done
}

View File

@@ -5,6 +5,7 @@ STOP=05
USE_PROCD=1
PROG=/usr/sbin/dm-service
DM_AGENT_PROG=/usr/sbin/dm-agent
BBFDM_MICROSERVICE_DIR="/etc/bbfdm/services"
@@ -24,7 +25,8 @@ validate_bbfdm_micro_service_section()
_add_microservice()
{
local name path loglevel
local enable enable_core unified_daemon
local enable enable_core unified_daemon dm_framework
local daemon_prog
# Check enable from micro-service
path="${1}"
@@ -47,14 +49,25 @@ _add_microservice()
return 0
fi
json_get_var dm_framework dm-framework 0
if [ "${dm_framework}" -eq "1" ] || [ "${dm_framework}" = "true" ]; then
daemon_prog="${DM_AGENT_PROG}"
else
daemon_prog="${PROG}"
fi
json_select config
json_get_var loglevel loglevel 4
procd_open_instance "${name}"
procd_set_param command ${PROG}
procd_append_param command -m "${name}"
procd_append_param command -l "${loglevel}"
procd_set_param command ${daemon_prog}
# Only add parameters for dm-service, not for dm-agent
if [ "${daemon_prog}" = "${PROG}" ]; then
procd_append_param command -m "${name}"
procd_append_param command -l "${loglevel}"
fi
if [ "${enable_core}" -eq "1" ]; then
procd_set_param limits core="unlimited"

View File

@@ -1,17 +0,0 @@
if PACKAGE_bridgemngr
config BRIDGEMNGR_BRIDGE_VLAN
bool "Use bridge-vlan backend"
help
Set this option to use bridge-vlan as backend for VLAN objects.
config BRIDGEMNGR_BRIDGE_VENDOR_EXT
bool "Use bridge BBF vendor extensions"
default y
help
Set this option to use bridge BBF vendor extensions.
config BRIDGEMNGR_BRIDGE_VENDOR_PREFIX
string "Package specific datamodel Vendor Prefix for TR181 extensions"
default ""
endif

View File

@@ -1,75 +0,0 @@
#
# Copyright (C) 2020-2024 iopsys
#
include $(TOPDIR)/rules.mk
PKG_NAME:=bridgemngr
PKG_VERSION:=1.1.4
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/network/bridgemngr.git
PKG_SOURCE_VERSION:=e5e0d9adfc919c25d88a867d42a9c500cb09f834
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif
PKG_LICENSE:=GPL-2.0-only
PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk
include ../bbfdm/bbfdm.mk
define Package/bridgemngr
CATEGORY:=Utilities
TITLE:=Bridge Manager
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json
DEPENDS+=+libbbfdm-api +libbbfdm-ubus +dm-service
endef
define Package/bridgemngr/description
Package to add Device.Bridging. data model support.
endef
define Package/$(PKG_NAME)/config
source "$(SOURCE)/Config.in"
endef
MAKE_PATH:=src
ifeq ($(CONFIG_BRIDGEMNGR_BRIDGE_VENDOR_PREFIX),"")
VENDOR_PREFIX = $(CONFIG_BBF_VENDOR_PREFIX)
else
VENDOR_PREFIX = $(CONFIG_BRIDGEMNGR_BRIDGE_VENDOR_PREFIX)
endif
TARGET_CFLAGS += -DBBF_VENDOR_PREFIX=\\\"$(VENDOR_PREFIX)\\\"
ifeq ($(CONFIG_BRIDGEMNGR_BRIDGE_VLAN),y)
TARGET_CFLAGS += -DBRIDGE_VLAN_BACKEND
endif
define Package/bridgemngr/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/config
$(BBFDM_REGISTER_SERVICES) ./bbfdm_service.json $(1) $(PKG_NAME)
$(BBFDM_INSTALL_MS_DM) $(PKG_BUILD_DIR)/src/libbridgemngr.so $(1) $(PKG_NAME)
ifeq ($(CONFIG_BRIDGEMNGR_BRIDGE_VENDOR_EXT), y)
$(BBFDM_INSTALL_MS_PLUGIN) $(PKG_BUILD_DIR)/src/libbridgeext.so $(1) $(PKG_NAME) 10
$(BBFDM_INSTALL_MS_PLUGIN) -v ${VENDOR_PREFIX} ./files/VLAN_Filtering_Extension.json $(1) $(PKG_NAME) 11
endif
$(INSTALL_BIN) ./files/etc/init.d/bridging $(1)/etc/init.d/
$(INSTALL_DATA) ./files/etc/config/bridging $(1)/etc/config/
endef
ifeq ($(LOCAL_DEV),1)
define Build/Prepare
$(CP) ~/git/bridgemngr/* $(PKG_BUILD_DIR)/
endef
endif
$(eval $(call BuildPackage,bridgemngr))

View File

@@ -1,31 +0,0 @@
{
"json_plugin_version": 2,
"Device.Bridging.Bridge.{i}.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": true,
"array": true,
"{BBF_VENDOR_PREFIX}VLANFiltering": {
"type": "boolean",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "boolean",
"description": "Enable or disable VLAN Filtering on this bridge.",
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "vlan_filtering"
}
]
}
}
}

View File

@@ -7,13 +7,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=bulkdata
PKG_VERSION:=2.1.23
PKG_VERSION:=2.1.20
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/bulkdata.git
PKG_SOURCE_VERSION:=f54550f2d587a701c0a8d5cac4a0910a99ce92cf
PKG_SOURCE_VERSION:=a5e57962938ca143ede65d92be90b6e9fce66e15
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif

View File

@@ -4,16 +4,4 @@ config DECOLLECTOR_EASYMESH_VERSION
int "Support Easymesh version"
default 6
config DECOLLECTOR_BUILD_TR181_PLUGIN
bool "Build TR-181 mapping module (responsible for Device.WiFi.DataElements.)"
default y
config DECOLLECTOR_VENDOR_EXTENSIONS
bool "Iopsys vendor extensions for Device.WiFi.DataElements."
default y
config DECOLLECTOR_VENDOR_PREFIX
string "Package specific datamodel Vendor Prefix for TR181 extensions"
default ""
endmenu

View File

@@ -6,12 +6,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=decollector
PKG_VERSION:=6.2.2.4
PKG_VERSION:=6.2.1.7
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=b632ef13fed94c683d65dedcbc91afdee9ee980f
PKG_SOURCE_VERSION:=ca92325ece080389ffb405c95048b64071eda653
PKG_SOURCE_URL:=https://dev.iopsys.eu/multi-ap/decollector.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
@@ -24,7 +24,6 @@ PKG_LICENSE:=BSD-3-Clause
PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/iopsys/bbfdm/bbfdm.mk
define Package/decollector
SECTION:=utils
@@ -67,18 +66,6 @@ MAKE_PATH:=src
TARGET_CFLAGS += -DEASYMESH_VERSION=$(CONFIG_DECOLLECTOR_EASYMESH_VERSION)
ifeq ($(CONFIG_DECOLLECTOR_BUILD_TR181_PLUGIN),y)
MAKE_FLAGS += DECOLLECTOR_BUILD_TR181_PLUGIN=y
ifeq ($(CONFIG_DECOLLECTOR_VENDOR_EXTENSIONS),y)
TARGET_CFLAGS += -DDECOLLECTOR_VENDOR_EXTENSIONS
ifeq ($(CONFIG_DECOLLECTOR_VENDOR_PREFIX),"")
TARGET_CFLAGS += -DCUSTOM_PREFIX=\\\"$(CONFIG_BBF_VENDOR_PREFIX)\\\"
else
TARGET_CFLAGS += -DCUSTOM_PREFIX=\\\"$(CONFIG_DECOLLECTOR_VENDOR_PREFIX)\\\"
endif
endif
endif
EXECS := \
$(if $(CONFIG_PACKAGE_decollector),decollector)
@@ -89,7 +76,6 @@ define Package/decollector/install
$(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/
$(BBFDM_REGISTER_SERVICES) ./bbfdm_service.json $(1) $(PKG_NAME)
endef
$(eval $(call BuildPackage,decollector))

View File

@@ -1,26 +0,0 @@
{
"daemon": {
"enable": "1",
"service_name": "decollector",
"unified_daemon": true,
"services": [
{
"parent_dm": "Device.WiFi.",
"object": "DataElements"
}
],
"config": {
"loglevel": "3"
},
"apply_handler": {
"uci": [
{
"file": [
"mapcontroller"
],
"external_handler": "/etc/wifidmd/bbf_config_reload.sh"
}
]
}
}
}

View File

@@ -2,13 +2,13 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=dectmngr
PKG_RELEASE:=3
PKG_VERSION:=3.7.11
PKG_VERSION:=3.7.10
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/dectmngr.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=815ee44808169b8e1efa2cac44bd7d238ad33cdc
PKG_SOURCE_VERSION:=1f851980a6ba616df54f79930225f8bcd563b711
PKG_MIRROR_HASH:=skip
endif

207
dm-framework/Makefile Executable file
View File

@@ -0,0 +1,207 @@
#
# Copyright (c) 2023 Genexis B.V. All rights reserved.
# This Software and its content are protected by the Dutch Copyright Act
# ('Auteurswet'). All and any copying and distribution of the software
# and its content without authorization by Genexis B.V. is
# prohibited. The prohibition includes every form of reproduction and
# distribution.
#
#
include $(TOPDIR)/rules.mk
PKG_NAME:=dm-framework
PKG_VERSION:=1.0.0
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/lcm/dm-framework.git
PKG_SOURCE_VERSION:=e9978675399c5fdc7233645a9192443e41c41904
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
# Build directories for each component
DATAMODELS_BUILD_DIR:=$(PKG_BUILD_DIR)/datamodels-build
DMAPI_BUILD_DIR:=$(PKG_BUILD_DIR)/dm-api-build
DMAGENT_BUILD_DIR:=$(PKG_BUILD_DIR)/dm-agent-build
include $(INCLUDE_DIR)/package.mk
-include $(TOPDIR)/feeds/iopsys/bbfdm/bbfdm.mk
#
# Datamodels Package Definition
#
define Package/datamodels
SECTION:=utils
CATEGORY:=Genexis
TITLE:=dm-framework Datamodel
URL:=http://www.genexis.eu
PKG_LICENSE:=GENEXIS
PKG_LICENSE_URL:=
endef
define Package/datamodels/description
This package contains dm-framework datamodel.
endef
#
# DM-API Package Definition
#
define Package/dm-api
CATEGORY:=Genexis
TITLE:=dm-api
PKG_BUILD_DEPENDS:=datamodels
DEPENDS:=+libsqlite3 \
+libjson-c +libstdcpp +quickjs \
+libubus +libubox +libuci
URL:=http://www.genexis.eu
PKG_LICENSE:=GENEXIS
PKG_LICENSE_URL:=
endef
define Package/dm-api/description
This package contains api for the dm-framework
endef
#
# DM-Agent Package Definition
#
define Package/dm-agent
DEPENDS:=+dm-api +datamodels +libubox +libubus +ubus
CATEGORY:=Genexis
TITLE:=dm-framework agent
URL:=http://www.genexis.eu
PKG_LICENSE:=GENEXIS
PKG_LICENSE_URL:=
endef
define Package/dm-agent/description
This package contains dm-framework agent.
endef
#
# Build Preparation
#
define Build/Prepare
$(call Build/Prepare/Default)
# Prepare datamodels
mkdir -p $(DATAMODELS_BUILD_DIR)
$(CP) -rf $(PKG_BUILD_DIR)/datamodels/* $(DATAMODELS_BUILD_DIR)/
# Copy scripts from top-level scripts directory
mkdir -p $(DATAMODELS_BUILD_DIR)/scripts
$(CP) -rf $(PKG_BUILD_DIR)/scripts/* $(DATAMODELS_BUILD_DIR)/scripts/
cd $(DATAMODELS_BUILD_DIR); \
npm install better-sqlite3 quickjs && \
node ./scripts/json2code.js && \
node ./scripts/qjs-handlers-validate.js
# Prepare dm-api
mkdir -p $(DMAPI_BUILD_DIR)
$(CP) -rf $(PKG_BUILD_DIR)/dm-api/* $(DMAPI_BUILD_DIR)/
# Prepare dm-agent
mkdir -p $(DMAGENT_BUILD_DIR)
$(CP) -rf $(PKG_BUILD_DIR)/dm-agent/* $(DMAGENT_BUILD_DIR)/
endef
TARGET_CFLAGS += $(FPIC)
#
# Build Compilation
#
define Build/Compile
# Build datamodels first (dependency for others)
$(MAKE) -C $(DATAMODELS_BUILD_DIR)\
PROJECT_ROOT="$(DATAMODELS_BUILD_DIR)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
ARCH="$(LINUX_KARCH)" \
EXTRA_CFLAGS="$(TARGET_CFLAGS) -I$(DATAMODELS_BUILD_DIR)" \
all
# Build dm-api (depends on datamodels)
$(MAKE) -C $(DMAPI_BUILD_DIR)\
PROJECT_ROOT="$(DMAPI_BUILD_DIR)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
ARCH="$(LINUX_KARCH)" \
EXTRA_CFLAGS="$(TARGET_CFLAGS) -I$(DMAPI_BUILD_DIR)" \
all
# Build dm-agent (depends on both)
$(MAKE) -C $(DMAGENT_BUILD_DIR)\
PROJECT_ROOT="$(DMAGENT_BUILD_DIR)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
ARCH="$(LINUX_KARCH)" \
EXTRA_CFLAGS="$(TARGET_CFLAGS) -I$(DMAGENT_BUILD_DIR)" \
all
endef
#
# Development Installation (headers and libraries)
#
define Build/InstallDev
# Datamodels development files
$(INSTALL_DIR) $(1)/usr/include
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(DATAMODELS_BUILD_DIR)/dm.h $(1)/usr/include/
$(CP) $(DATAMODELS_BUILD_DIR)/libdm.so $(1)/usr/lib/
# DM-API development files - headers are now in dm-api/include/
$(CP) $(DMAPI_BUILD_DIR)/include/dm_types.h $(1)/usr/include/
$(CP) $(DMAPI_BUILD_DIR)/include/dm_node.h $(1)/usr/include/
$(CP) $(DMAPI_BUILD_DIR)/core/dm_api.h $(1)/usr/include/
$(CP) $(DMAPI_BUILD_DIR)/core/dm_linker.h $(1)/usr/include/
$(CP) $(DMAPI_BUILD_DIR)/core/dbmgr.h $(1)/usr/include/
$(CP) $(DMAPI_BUILD_DIR)/include/dm_log.h $(1)/usr/include/
$(CP) $(DMAPI_BUILD_DIR)/utils/dm_list.h $(1)/usr/include/
$(CP) $(DMAPI_BUILD_DIR)/libdmapi.so $(1)/usr/lib/
endef
#
# Package Installation - Datamodels
#
define Package/datamodels/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/bbfdm
$(INSTALL_DIR) $(1)/usr/lib/dmf_handlers
$(INSTALL_BIN) $(DATAMODELS_BUILD_DIR)/default.db $(1)/etc/bbfdm/default_dm.db
$(INSTALL_BIN) $(DATAMODELS_BUILD_DIR)/libdm.so $(1)/usr/lib/
# Copy handler files from datamodels directory (new structure)
# Copy .js files from root datamodels directory
( cd $(DATAMODELS_BUILD_DIR); \
find . -maxdepth 1 -type f -name '*.js' -not -path './.*' -exec $(INSTALL_BIN) {} $(1)/usr/lib/dmf_handlers/{} \; )
# Copy .js files from subdirectories, preserving folder structure (skip hidden files/folders)
( cd $(DATAMODELS_BUILD_DIR); \
find . -type d -mindepth 1 -not -path './.*' -not -path './scripts*' -exec $(INSTALL_DIR) $(1)/usr/lib/dmf_handlers/{} \; ; \
find . -type f -name '*.js' -mindepth 2 -not -path './.*' -not -path './scripts*' -exec $(INSTALL_BIN) {} $(1)/usr/lib/dmf_handlers/{} \; )
endef
#
# Package Installation - DM-API
#
define Package/dm-api/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_DIR) $(1)/sbin/
$(INSTALL_BIN) $(DMAPI_BUILD_DIR)/libdmapi.so $(1)/usr/lib/
endef
#
# Package Installation - DM-Agent
#
define Package/dm-agent/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_BIN) ./files/etc/init.d/bridging $(1)/etc/init.d/
$(INSTALL_DATA) ./files/etc/config/bridging $(1)/etc/config/
$(BBFDM_REGISTER_SERVICES) ./bbfdm_service.json $(1) dm-agent
$(INSTALL_BIN) $(DMAGENT_BUILD_DIR)/dm-agent $(1)/usr/sbin
endef
# Register all three packages
$(eval $(call BuildPackage,datamodels))
$(eval $(call BuildPackage,dm-api))
$(eval $(call BuildPackage,dm-agent))

View File

@@ -2,6 +2,7 @@
"daemon": {
"enable": "1",
"service_name": "bridgemngr",
"dm-framework": true,
"unified_daemon": false,
"services": [
{

View File

@@ -77,6 +77,7 @@ handle_ebtables_rule() {
}
start_service() {
ubus -t 30 wait_for network.device uci
config_load bridging
config_foreach handle_ebtables_chain chain
config_foreach handle_ebtables_rule rule

View File

@@ -5,8 +5,6 @@ source "/lib/functions/network.sh"
source "/lib/functions/system.sh"
PREVLINK=""
LINK=""
LINKSPEED=""
PREVWANMODE=""
WANMODE=""
CONFIGURED=0
@@ -62,7 +60,7 @@ create_atm_devices() {
}
configure_line() {
local mode profile bitswap sra us0 sesdrop sos roc ginp gvector mod prof
local mode profile bitswap sra us0 sesdrop sos ginp mod prof
local adsl1_flag=0 issue2_flag=0 Glite_flag=0 adsl2_flag=0 adsl2p_flag=0 vdsl2_flag=0
local pro_8a_flag=0 pro_8b_flag=0 pro_8c_flag=0 pro_8d_flag=0 pro_12a_flag=0 pro_12b_flag=0 pro_17a_flag=0 pro_30a_flag=0 pro_35b_flag=0
@@ -72,9 +70,8 @@ configure_line() {
config_get sra $1 sra "1"
config_get us0 $1 us0 "1"
config_get sos $1 sos "0"
config_get roc $1 roc "0"
config_get ginp $1 ginp "1"
config_get gvector $1 gvector "1"
config_get sos $1 roc "0"
config_get sos $1 ginp "0"
for mod in $mode; do
[ "$mod" = "gdmt" ] && adsl1_flag=1
@@ -99,7 +96,6 @@ configure_line() {
/userfs/bin/blapi_cmd xdsl set_adsl_profile "$pro_8a_flag" "$pro_8b_flag" "$pro_8c_flag" "$pro_8d_flag" "$pro_12a_flag" "$pro_12b_flag" "$pro_17a_flag" "$pro_30a_flag" "$pro_35b_flag"
/userfs/bin/blapi_cmd xdsl set_adsl_mode "$adsl1_flag" "$issue2_flag" "$Glite_flag" "$adsl2_flag" "$adsl2p_flag" "$vdsl2_flag"
/userfs/bin/blapi_cmd xdsl set_adsl_gvector "$((!gvector))"
/userfs/bin/blapi_cmd xdsl set_adsl_ginp "$((!ginp))"
/userfs/bin/blapi_cmd xdsl set_adsl_sos_roc "$((!sos))" "$((!roc))"
/userfs/bin/blapi_cmd xdsl set_adsl_us0 "$((!us0))"
@@ -152,12 +148,6 @@ while [ true ]; do
if [ "$LINK" != "$PREVLINK" -a \( "$LINK" = "down" -o "$LINK" = "up" \) ]; then
if [ "$LINK" = "down" ]; then
if [ ! -s /tmp/qos/wan_link_shape_rate ]; then
rm -rf /tmp/qos/wan_link_shape_rate
rm -rf /tmp/qos/wan_link_speed
/usr/sbin/qos-uplink-bandwidth
fi
[ "$CONFIGURED" -eq 0 ] && configure_lines # Needs to be done once the slave SoC is in down state and we've not been able to auto-sync.
if [ -n "$WANMODE" ]; then
if [ "$WANMODE" = "PTM" ]; then
@@ -234,26 +224,6 @@ while [ true ]; do
call_wan_hotplug "up" "$WANPORT"
PREVWANMODE="$WANMODE"
if [ ! -s /tmp/qos/wan_link_shape_rate ]; then
LINKSPEED="$(awk '/far-end interleaved channel bit rate/{print $6}' /proc/tc3162/adsl_stats)"
LINKSPEED=$((LINKSPEED))
if [ "$LINKSPEED" -eq 0 ]; then
LINKSPEED="$(awk '/far-end fast channel bit rate/{print $6}' /proc/tc3162/adsl_stats)"
LINKSPEED=$((LINKSPEED))
fi
if [ "$LINKSPEED" -ne 0 ]; then
mkdir -p /tmp/qos
touch /tmp/qos/wan_link_shape_rate
/userfs/bin/qosrule discpline Rate uplink-bandwidth ${LINKSPEED}
hw_nat -! > /dev/null 2>&1
else
rm -rf /tmp/qos/wan_link_speed
/usr/sbin/qos-uplink-bandwidth
fi
fi
fi
# Toggle link state

View File

@@ -5,13 +5,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=ethmngr
PKG_VERSION:=3.1.3
PKG_VERSION:=3.0.8
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/hal/ethmngr.git
PKG_SOURCE_VERSION:=7bc8297e1a74adb522f7635bab4f93a1a2620216
PKG_SOURCE_VERSION:=c73e5b15718ca40b2740bbe6151dfbb2bcca16df
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip
endif

View File

@@ -10,14 +10,19 @@ PKG_NAME:=fdtextract
PKG_RELEASE:=1
PKG_VERSION:=1.0
PKG_SOURCE_URL:=https://dev.iopsys.eu/system/fdtextract.git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/fdtextract.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=7917dbcb29724476cd46164eec29848df1e5fb67
PKG_SOURCE_VERSION:=e3cefda3b26c9aea3021b20725ce7b31b33eebc4
PKG_MIRROR_HASH:=skip
PKG_LICENSE:=GPLv2
PKG_LICENSE_FILES:=LICENSE
RSTRIP:=true
export BUILD_DIR
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_BUILD_PARALLEL:=1
@@ -35,7 +40,9 @@ endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/fdtextract $(1)/usr/sbin/
$(STRIP) $(1)/usr/sbin/fdtextract
endef
$(eval $(call BuildPackage,$(PKG_NAME)))

View File

@@ -0,0 +1,45 @@
diff --git a/plugins/out_file/file.c b/plugins/out_file/file.c
index 2e47c9666..95d28e438 100644
--- a/plugins/out_file/file.c
+++ b/plugins/out_file/file.c
@@ -27,6 +27,7 @@
#include <msgpack.h>
#include <stdio.h>
+#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -55,6 +56,7 @@ struct flb_file_conf {
int csv_column_names;
int mkdir;
struct flb_output_instance *ins;
+ char hostname[256];
};
static char *check_delimiter(const char *str)
@@ -141,6 +143,9 @@ static int cb_file_init(struct flb_output_instance *ins,
}
}
+ if (gethostname(ctx->hostname, sizeof(ctx->hostname)) != 0)
+ snprintf(ctx->hostname, sizeof(ctx->hostname), "%s", "localhost");
+
tmp = flb_output_get_property("delimiter", ins);
ret_str = check_delimiter(tmp);
if (ret_str != NULL) {
@@ -233,12 +238,8 @@ static int template_output_write(struct flb_file_conf *ctx,
int i;
msgpack_object_kv *kv;
- /*
- * Right now we treat "{time}" specially and fill the placeholder
- * with the metadata timestamp (formatted as float).
- */
- if (!strncmp(key, "time", size)) {
- fprintf(fp, "%f", flb_time_to_double(tm));
+ if (!strncmp(key, "hostname", size)) {
+ fprintf(fp, "%s", ctx->hostname);
return 0;
}

View File

@@ -1,27 +0,0 @@
diff --git a/plugins/out_file/file.c b/plugins/out_file/file.c
index 77baf6be8..04c519d5a 100644
--- a/plugins/out_file/file.c
+++ b/plugins/out_file/file.c
@@ -238,10 +238,20 @@ static int template_output_write(struct flb_file_conf *ctx,
/*
* Right now we treat "{time}" specially and fill the placeholder
- * with the metadata timestamp (formatted as float).
+ * with the metadata timestamp.
*/
if (!strncmp(key, "time", size)) {
- fprintf(fp, "%f", flb_time_to_double(tm));
+ struct tm tm_local;
+ char buf[32];
+ if (localtime_r(&tm->tm.tv_sec, &tm_local) == NULL) {
+ flb_plg_error(ctx->ins, "localtime_r failed");
+ return -1;
+ }
+ if (strftime(buf, sizeof(buf), "%b %d %H:%M:%S", &tm_local) == 0) {
+ flb_plg_error(ctx->ins, "strftime failed");
+ return -1;
+ }
+ fputs(buf, fp);
return 0;
}

View File

@@ -0,0 +1,32 @@
diff --git a/plugins/in_kmsg/in_kmsg.c b/plugins/in_kmsg/in_kmsg.c
index cd5c4cd17..9524cf194 100644
--- a/plugins/in_kmsg/in_kmsg.c
+++ b/plugins/in_kmsg/in_kmsg.c
@@ -165,6 +165,15 @@ static inline int process_line(const char *line,
flb_time_set(&ts, ctx->boot_time.tv_sec + tv.tv_sec, tv.tv_usec * 1000);
+ /* Format syslog timestamp: "Jul 03 10:31:53" */
+ time_t real_time = ctx->boot_time.tv_sec + tv.tv_sec;
+ struct tm tm_info;
+ char syslog_ts[32];
+
+ localtime_r(&real_time, &tm_info);
+ strftime(syslog_ts, sizeof(syslog_ts), "%b %d %H:%M:%S", &tm_info);
+ int syslog_ts_len = strlen(syslog_ts);
+
/* Now process the human readable message */
p = strchr(p, ';');
if (!p) {
@@ -198,7 +207,10 @@ static inline int process_line(const char *line,
FLB_LOG_EVENT_UINT64_VALUE(tv.tv_usec),
FLB_LOG_EVENT_CSTRING_VALUE("msg"),
- FLB_LOG_EVENT_STRING_VALUE((char *) p, line_len - 1));
+ FLB_LOG_EVENT_STRING_VALUE((char *) p, line_len - 1),
+
+ FLB_LOG_EVENT_CSTRING_VALUE("syslog_ts"),
+ FLB_LOG_EVENT_STRING_VALUE(syslog_ts, syslog_ts_len));
}
if (ret == FLB_EVENT_ENCODER_SUCCESS) {

View File

@@ -1,73 +0,0 @@
diff --git a/plugins/in_kmsg/in_kmsg.c b/plugins/in_kmsg/in_kmsg.c
index cd5c4cd17..15f105451 100644
--- a/plugins/in_kmsg/in_kmsg.c
+++ b/plugins/in_kmsg/in_kmsg.c
@@ -36,7 +36,6 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <inttypes.h>
-#include <time.h>
#include "in_kmsg.h"
@@ -123,12 +122,17 @@ static inline int process_line(const char *line,
ctx->buffer_id++;
errno = 0;
- val = strtol(p, &end, 10);
- if ((errno == ERANGE && (val == INT_MAX || val == INT_MIN))
+ val = strtoul(p, &end, 10);
+ if ((errno == ERANGE && val == ULONG_MAX)
|| (errno != 0 && val == 0)) {
goto fail;
}
+ /* ensure something was consumed */
+ if (end == p) {
+ goto fail;
+ }
+
/* Priority */
priority = FLB_KLOG_PRI(val);
@@ -144,24 +148,35 @@ static inline int process_line(const char *line,
}
p++;
- val = strtoul(p, &end, 10);
- if ((errno == ERANGE && (val == INT_MAX || val == INT_MIN))
+ val = strtoull(p, &end, 10);
+ if ((errno == ERANGE && val == ULLONG_MAX)
|| (errno != 0 && val == 0)) {
goto fail;
}
+ /* make sure strtoull consumed something */
+ /* after the sequence number, the next char must be ',' */
+ if (end == p || *end != ',') {
+ goto fail;
+ }
+
sequence = val;
p = ++end;
/* Timestamp */
- val = strtoul(p, &end, 10);
- if ((errno == ERANGE && (val == INT_MAX || val == INT_MIN))
+ val = strtoull(p, &end, 10);
+ if ((errno == ERANGE && val == ULLONG_MAX)
|| (errno != 0 && val == 0)) {
goto fail;
}
+ /* ensure something was consumed */
+ if (end == p) {
+ goto fail;
+ }
+
tv.tv_sec = val/1000000;
- tv.tv_usec = val - (tv.tv_sec * 1000000);
+ tv.tv_usec = val - ((uint64_t)tv.tv_sec * 1000000);
flb_time_set(&ts, ctx->boot_time.tv_sec + tv.tv_sec, tv.tv_usec * 1000);

View File

@@ -40,22 +40,22 @@ get_vivsoi() {
#hex-string 2 character=1 Byte
# length in hex string will be twice of actual Byte length
[ "${len}" -gt 8 ] || return
[ "$len" -gt "8" ] || return
data="${opt125}"
rem_len="${len}"
while [ "${rem_len}" -gt 0 ]; do
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
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 ))
rem_len=$(( rem_len - $data_len ))
continue
fi
@@ -66,7 +66,7 @@ get_vivsoi() {
data_len=$(( data_len * 2 + 10 ))
opt_len=$(printf "%d\n" "0x$len_val")
[ "${opt_len}" -eq 0 ] && return
[ $opt_len -eq 0 ] && return
# populate the option data of enterprise id
sub_data_len=$(( opt_len * 2))
@@ -74,7 +74,7 @@ get_vivsoi() {
sub_data=${data:10:"${sub_data_len}"}
# parsing of suboption of option 125
while [ "${sub_data_len}" -gt 0 ]; do
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")
@@ -85,20 +85,20 @@ get_vivsoi() {
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}"}
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 '')
OUI=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
GW_DISCOVERED=1
;;
"5")
SERIAL=$(echo -n "${sub_opt_val}" | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
SERIAL=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
GW_DISCOVERED=1
;;
"6")
CLASS=$(echo -n "${sub_opt_val}" | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
CLASS=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
GW_DISCOVERED=1
;;
esac
@@ -110,7 +110,7 @@ get_vivsoi() {
sub_data_len=$((sub_data_len - sub_opt_end))
# fetch next sub option hex string
sub_data=${sub_data:"${sub_opt_end}":"${sub_data_len}"}
sub_data=${sub_data:${sub_opt_end}:${sub_data_len}}
done
# move ahead data to next enterprise id
@@ -131,13 +131,15 @@ send_host_query() {
sleep 5
json_load "$(ubus call umdns browse)"
if ! json_select discovered_services; then
json_select discovered_services
if [ "${?}" -ne 0 ]; then
json_cleanup
loop=$(( loop - 1 ))
continue
fi
if ! json_select _usp-agt-mqtt._tcp; then
json_select _usp-agt-mqtt._tcp
if [ "${?}" -ne 0 ]; then
json_cleanup
loop=$(( loop - 1 ))
continue
@@ -154,7 +156,7 @@ send_host_query() {
json_get_keys keys
for key in $keys; do
json_select "${key}"
json_select $key
json_get_var _host host ""
if [ -z "${_host}" ] || [[ "${sent_host}" =~ " ${_host}" ]]; then
@@ -164,10 +166,9 @@ send_host_query() {
sent_host="${sent_host} ${_host}"
cmd="ubus call umdns query '{\"question\":\"$_host\",\"interface\":\"$intf\"}'"
sh -c "${cmd}"
eval $cmd
resp=0
json_select ..
sleep 2 # umdns query sometime takes time to resolve so adding some sleep
done
json_cleanup
@@ -184,29 +185,32 @@ get_usp_agent_id() {
fi
json_load "$(ubus call umdns browse)"
if ! json_select discovered_services; then
json_select discovered_services
if [ "${?}" -ne 0 ]; then
json_cleanup
echo "${ID}"
echo ${ID}
return 0
fi
if ! json_select _usp-agt-mqtt._tcp; then
json_select _usp-agt-mqtt._tcp
if [ "${?}" -ne 0 ]; then
json_cleanup
echo "${ID}"
echo ${ID}
return 0
fi
json_get_keys keys
for key in $keys; do
json_select "${key}"
if ! json_select "${family}"; then
json_select $key
json_select $family
if [ "${?}" -ne 0 ]; then
json_select ..
continue
fi
json_get_keys ips
for ip in $ips; do
json_get_var ip_val "${ip}"
json_get_var ip_val $ip
if [ "${ip_val}" != "${dhcp_ip}" ]; then
continue
fi
@@ -215,8 +219,8 @@ get_usp_agent_id() {
json_select txt
json_get_keys txts
for _txt in $txts; do
json_get_var text_val "${_txt}"
if [[ "${text_val:0:3}" = "ID=" ]]; then
json_get_var text_val $_txt
if [[ "${text_val:0:3}" == "ID=" ]]; then
ID="${text_val:3}"
break
fi
@@ -234,16 +238,16 @@ get_usp_agent_id() {
done
json_cleanup
echo "${ID}"
echo ${ID}
}
get_mac_address() {
ip="${1}"
device="${2}"
mac=$(grep "${ip}" /proc/net/arp | awk '{print $4}')
mac="$(cat /proc/net/arp | grep $ip | awk '{print $4}')"
if [ -z "${mac}" ]; then
arp_resp=$(arping -b -f -c 5 -I "${device}" "${ip}" | grep 'Unicast reply from' | awk '{print $5}')
arp_resp="$(arping -b -f -c 5 -I $device $ip | grep 'Unicast reply from' | awk '{print $5}')"
if [ -n "${arp_resp}" ]; then
mac=${arp_resp:1:-1}
fi
@@ -256,7 +260,7 @@ send_unknown_gw_event() {
mac="${1}"
cmd="ubus -t 5 send gateway-info.gateway.unknown '{\"hwaddr\":\"$mac\"}'"
sh -c "${cmd}"
eval $cmd
}
send_cwmp_gw_event() {
@@ -265,14 +269,14 @@ send_cwmp_gw_event() {
serial="${3}"
cmd="ubus -t 5 send gateway-info.gateway.cwmp '{\"oui\":\"$oui\",\"class\":\"$class\",\"serial\":\"$serial\"}'"
sh -c "${cmd}"
eval $cmd
}
send_usp_gw_event() {
endpoint="${1}"
cmd="ubus -t 5 send gateway-info.gateway.usp '{\"endpoint\":\"$endpoint\"}'"
sh -c "${cmd}"
eval $cmd
}
config_load gateway
@@ -283,13 +287,13 @@ if [ "${enable}" -eq 0 ]; then
return 0
fi
if [ "${wan_intf}" = "${INTERFACE}" ]; then
if [ "${1}" = "deconfig" ]; then
if [ "${wan_intf}" == "${INTERFACE}" ]; then
if [ "${1}" == "deconfig" ]; then
rm -rf /var/state/gwinfo
return 0
fi
json_load "$(ifstatus "${INTERFACE}")"
json_load "$(ifstatus ${INTERFACE})"
json_get_var dev_name device ""
json_select data
json_get_var dhcp_ip dhcpserver ""
@@ -299,7 +303,7 @@ if [ "${wan_intf}" = "${INTERFACE}" ]; then
return 0
fi
MAC=$(get_mac_address "${dhcp_ip}" "${dev_name}")
MAC="$(get_mac_address $dhcp_ip $dev_name)"
mkdir -p /var/state
touch /var/state/gwinfo
@@ -322,8 +326,8 @@ if [ "${wan_intf}" = "${INTERFACE}" ]; then
return 0
fi
len=$(echo -n "${opt125}" | wc -c)
get_vivsoi "${opt125}" "${len}"
len=$(printf "$opt125"|wc -c)
get_vivsoi "$opt125" "$len"
if [ "${GW_DISCOVERED}" -eq 0 ]; then
send_unknown_gw_event "${MAC}"
@@ -337,18 +341,19 @@ if [ "${wan_intf}" = "${INTERFACE}" ]; then
uci -q -c /var/state commit gwinfo
# Check for USP parameters
if ! ubus -t 15 wait_for umdns; then
ubus -t 15 wait_for umdns
if [ "${?}" -ne 0 ]; then
send_cwmp_gw_event "${OUI}" "${CLASS}" "${SERIAL}"
return 0
fi
resp=$(send_host_query "${dev_name}")
resp=$(send_host_query $dev_name)
if [ "${resp}" -ne 0 ]; then
send_cwmp_gw_event "${OUI}" "${CLASS}" "${SERIAL}"
return 0
fi
ID=$(get_usp_agent_id "${dhcp_ip}")
ID="$(get_usp_agent_id $dhcp_ip)"
if [ -z "${ID}" ]; then
send_cwmp_gw_event "${OUI}" "${CLASS}" "${SERIAL}"
return 0

View File

@@ -5,12 +5,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=hostmngr
PKG_VERSION:=1.4.0
PKG_VERSION:=1.3.1
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=230d55ae6769e1ebde02cef3f718e6c4cf1b1962
PKG_SOURCE_VERSION:=3663ca4d001508509774115d6797b932f9ed4f69
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/hostmngr.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip

View File

@@ -8,13 +8,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=icwmp
PKG_VERSION:=9.10.5
PKG_VERSION:=9.9.10
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/icwmp.git
PKG_SOURCE_VERSION:=7f4a159f6ff49584655e57bb801218eb083fba67
PKG_SOURCE_VERSION:=1a842e0a3836f616973e6a92f0b0b6ca82ec39bb
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif

View File

@@ -28,9 +28,9 @@ config cpe 'cpe'
option log_severity 'WARNING'
option log_file_name '/var/log/icwmpd.log'
option log_max_size '102400'
option bind_retries '5'
option userid '' #$OUI-$SER
option passwd ''
option port '7547'
option provisioning_code ''
option amd_version '5'
# compression possible configs: InstanceNumber, InstanceAlias

View File

@@ -133,56 +133,9 @@ add_firewall_rule() {
fi
}
remove_port_protection() {
local enabled chain rule rule_num
config_get enabled "${1}" "${2}"
if [ "${enabled}" -eq 1 ]; then
config_get zonename "$1" name
[ -n "$zonename" ] || return 0
chain='prerouting_'$zonename'_rule'
while rule=$(iptables -w -t nat -nL "$chain" --line-numbers | grep -m 1 -w CWMP_Port_protection); do
rule_num=${rule%%[$' \t']*}
iptables -w -t nat -D "$chain" "$rule_num"
done
fi
}
cleanup_port_protection() {
config_load firewall
config_foreach remove_port_protection zone masq
}
install_port_protection() {
local PORT="${3}"
local enabled zonename chain
config_get enabled "${1}" "${2}"
if [ "${enabled}" -eq 1 ]; then
config_get zonename "${1}" name
[ -n "$zonename" ] || return 0
chain='prerouting_'$zonename'_rule'
iptables -w -t nat -I "$chain" -p tcp --dport "$PORT" -j ACCEPT -m comment --comment=CWMP_Port_protection
iptables -w -t nat -I "$chain" -p udp --dport "$PORT" -j ACCEPT -m comment --comment=CWMP_Port_protection
fi
}
add_port_protection() {
config_load firewall
config_foreach install_port_protection zone masq "${1}"
}
configure_connection_req_rules() {
app="${1}"
cleanup_port_protection
wan="$(uci -q get cwmp.cpe.default_wan_interface)"
wan="${wan:-wan}"
@@ -222,11 +175,8 @@ configure_connection_req_rules() {
fi
fi
port=$(uci -q -c /var/state get icwmp.cpe.port)
if [ -z "${port}" ]; then
log "cwmp cpe port not configured"
exit 0
fi
port=$(uci -q get cwmp.cpe.port)
port="${port:-7547}"
ipaddr=$(uci -q get cwmp.cpe.allowed_cr_ip)
if [ -n "${ipaddr}" ]; then
@@ -247,8 +197,6 @@ configure_connection_req_rules() {
# Close the ACS port at Lan side
close_downstream_acs_port "${lan}" "${port}"
fi
add_port_protection "${port}"
}
load_zone_names

View File

@@ -5,6 +5,7 @@ uci -q batch <<-EOT
set firewall.cwmp=include
set firewall.cwmp.path=/etc/icwmpd/firewall.cwmp
set firewall.cwmp.reload=1
commit firewall
EOT
exit 0

View File

@@ -16,12 +16,12 @@ get_opt43() {
local opt43="$1"
local len="$2"
[ "${len}" -gt 2 ] || return
[ "$len" -gt "2" ] || return
first_byte=${opt43:0:2}
first_byte=$(printf "%d\n" "0x$first_byte")
if [ "${len}" -ge 4 ] && [ "${first_byte}" -ge 1 ] && [ "${first_byte}" -le 4 ]; then
if [ $len -ge 4 ] && [ $first_byte -ge 1 ] && [ $first_byte -le 4 ]; then
# it is in encapsulated form
# opt43 encapsulated vendor-specific option has data in below format
# Code Len Data item Code Len Data item Code
@@ -35,7 +35,7 @@ get_opt43() {
data="${opt43}"
rem_len="${len}"
# parsing of suboption of option 43
while [ "${rem_len}" -gt 0 ]; do
while [ $rem_len -gt 0 ]; do
# get the suboption id
sub_opt_id=${data:0:2}
sub_opt_id=$(printf "%d\n" "0x$sub_opt_id")
@@ -50,13 +50,13 @@ get_opt43() {
# assign the value found in sub option
case "${sub_opt_id}" in
"1") DHCP_ACS_URL=$(echo -n "${sub_opt_val}" | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
"1") DHCP_ACS_URL=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
;;
"2") DHCP_PROV_CODE=$(echo -n "${sub_opt_val}" | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
"2") DHCP_PROV_CODE=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
;;
"3") MIN_WAIT_INVL=$(echo -n "${sub_opt_val}" | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
"3") MIN_WAIT_INVL=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
;;
"4") INVL_MULTIPLIER=$(echo -n "${sub_opt_val}" | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
"4") INVL_MULTIPLIER=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
;;
esac
@@ -70,14 +70,13 @@ get_opt43() {
rem_len=$((rem_len - sub_opt_end))
done
else
DHCP_ACS_URL=$(echo -n "${opt43}" | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
DHCP_ACS_URL=$(echo -n $opt43 | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
fi
}
config_load cwmp
config_get wan_intf cpe default_wan_interface "wan"
config_get dhcp_discovery acs dhcp_discovery "0"
config_get_bool insecure_enable acs insecure_enable "0"
config_get dhcp_url acs dhcp_url ""
config_get min_wait_intvl acs dhcp_retry_min_wait_interval "0"
config_get intvl_multi acs dhcp_retry_interval_multiplier "0"
@@ -93,9 +92,9 @@ if [ "$discovery_enable" = "0" ]; then
return 0
fi
if [ "${wan_intf}" = "${INTERFACE}" ]; then
if [ "${wan_intf}" == "${INTERFACE}" ]; then
if [ -n "$opt43" ]; then
len=$(echo -n "$opt43"|wc -c)
len=$(printf "$opt43"|wc -c)
get_opt43 "$opt43" "$len"
fi
@@ -103,17 +102,6 @@ if [ "${wan_intf}" = "${INTERFACE}" ]; then
return 0
fi
if [ "${insecure_enable}" -eq "0" ]; then
case $DHCP_ACS_URL in
https://*)
log "ACS url $DHCP_ACS_URL has https"
;;
*)
return 0
;;
esac
fi
sec=$(uci -q get cwmp.acs)
if [ -z "${sec}" ]; then

View File

@@ -6,12 +6,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=ieee1905
PKG_VERSION:=8.7.38
PKG_VERSION:=8.7.33
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=c685111f87aaca4dc17cc03b0d34e20b47c83a03
PKG_SOURCE_VERSION:=cb5b8f76c854b89607cd1750d3a4052ecd71ac9d
PKG_SOURCE_URL:=https://dev.iopsys.eu/multi-ap/ieee1905.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip

View File

@@ -33,7 +33,6 @@ define Package/$(PKG_NAME)
DEPENDS+= \
+@PACKAGE_syslog-ng:SYSLOGNG_LOGROTATE \
+PACKAGE_fluent-bit:logrotate \
+@DMCLI_REMOTE_CONNECTION
endef

View File

@@ -5,13 +5,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=libdsl
PKG_VERSION:=7.3.2
PKG_VERSION:=7.3.0
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/hal/libdsl.git
PKG_SOURCE_VERSION:=1aa9c40f9503311652e562617b1e15533257adcc
PKG_SOURCE_VERSION:=2a7a49fac35c3d8078ffe051594c0425d355cacd
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip
endif

View File

@@ -1,28 +1,32 @@
#
# Copyright (C) 2025 Genexis Sweden AB
# Copyright (C) 2020-2023 Iopsys
#
include $(TOPDIR)/rules.mk
PKG_NAME:=libeasy
PKG_VERSION:=7.5.0
PKG_VERSION:=7.4.6
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=18f93677bb4d33ebb6249324a5043294f0eae16c
PKG_SOURCE_URL:=https://dev.iopsys.eu/hal/libeasy.git
PKG_SOURCE_VERSION:=ca7b20068c9d373e41045a2e899a9c697576262c
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:=
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@genexis.eu>
PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include \
-I$(STAGING_DIR)/usr/include/openssl \
-I$(STAGING_DIR)/usr/include/libnl3
ifeq ($(LOCAL_DEV),1)
define Build/Prepare
@@ -30,6 +34,9 @@ define Build/Prepare
endef
endif
MAKE_FLAGS += \
CFLAGS="$(TARGET_CFLAGS) -Wall"
define Package/libeasy
SECTION:=libs
CATEGORY:=Libraries
@@ -40,7 +47,7 @@ define Package/libeasy
endef
define Package/libeasy/description
This package provides libeasy.so for common utility functions.
Library provides common utility functions
endef
define Build/InstallDev/libeasy
@@ -60,7 +67,6 @@ define Build/InstallDev/libeasy
endef
define Build/InstallDev
$(call Build/InstallDev/cmake,$(1))
$(call Build/InstallDev/libeasy,$(1),$(2))
endef

View File

@@ -1,32 +1,27 @@
#
# Copyright (C) 2019-2024 Iopsys
# Copyright (C) 2025 Genexis Sweden AB
# Copyright (C) 2020-2023 Iopsys
#
include $(TOPDIR)/rules.mk
PKG_NAME:=libwifi
PKG_VERSION:=7.22.4
PKG_VERSION:=7.13.7
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=fadbe86a2ea05037ee9df6040b74bec683a6ca66
PKG_SOURCE_URL:=https://dev.iopsys.eu/hal/libwifi.git
PKG_SOURCE_VERSION:=65a7cd643c07e3f0a11d5b20225d4d87b8646513
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:=
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@genexis.eu>
MAKE_VERBOSE := 1
PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/cmake.mk
ifeq ($(CONFIG_TARGET_brcmbca),y)
TARGET_PLATFORM=BROADCOM
@@ -47,20 +42,10 @@ else ifeq ($(CONFIG_TARGET_armvirt),y)
else ifeq ($(CONFIG_TARGET_airoha),y)
TARGET_PLATFORM=ECONET
TARGET_WIFI_TYPE=MEDIATEK
TARGET_CFLAGS +=-DIOPSYS_ECONET -I$(LINUX_DIR)/include/uapi/linux/mtk_nl80211_inc
TARGET_CFLAGS +=-DIOPSYS_ECONET
ifeq ($(CONFIG_TARGET_airoha_an7581),y)
TARGET_CFLAGS +=-DCONFIG_MTK
endif
else ifeq ($(CONFIG_TARGET_mediatek),y)
TARGET_PLATFORM=MEDIATEK
TARGET_WIFI_TYPE=MAC80211
ifeq ($(CONFIG_TARGET_DEVICE_mediatek_filogic_DEVICE_cx750),y)
TARGET_WIFI_TYPE=MEDIATEK
TARGET_CFLAGS +=-DCONFIG_MTK -I$(LINUX_DIR)/include/uapi/linux/mtk_nl80211_inc
else ifeq ($(CONFIG_TARGET_DEVICE_mediatek_filogic_DEVICE_mediatek_mt7987a-spim-nand-an8801sb),y)
TARGET_WIFI_TYPE=MEDIATEK
TARGET_CFLAGS +=-DCONFIG_MTK -I$(LINUX_DIR)/include/uapi/linux/mtk_nl80211_inc
endif
else ifeq ($(CONFIG_TARGET_ipq95xx),y)
TARGET_PLATFORM=IPQ95XX
TARGET_WIFI_TYPE=QUALCOMM
@@ -76,13 +61,13 @@ else
endif
ifneq ($(CONFIG_PACKAGE_kmod-mt7915e_en7523),)
TARGET_CFLAGS +=-DMT7915_VENDOR_EXT
TARGET_CFLAGS=-DMT7915_VENDOR_EXT
endif
PKG_BUILD_DEPENDS:=PACKAGE_kmod-mt7915e_en7523:mt76_en7523
ifneq ($(CONFIG_PACKAGE_libwifi),)
CMAKE_OPTIONS +=-DHAS_WIFI=ON
TARGET_CFLAGS +=-DHAS_WIFI
endif
ifeq ($(CONFIG_LIBWIFI_USE_CTRL_IFACE),y)
@@ -93,8 +78,18 @@ ifeq ($(CONFIG_LIBWIFI_SKIP_PROBES),y)
TARGET_CFLAGS +=-DLIBWIFI_BRCM_SKIP_PROBES
endif
TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include \
-I$(STAGING_DIR)/usr/include/openssl \
-I$(STAGING_DIR)/usr/include/libnl3
CMAKE_OPTIONS += -DPLATFORM=$(TARGET_PLATFORM) -DWIFI_TYPE=$(TARGET_WIFI_TYPE)
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
@@ -102,39 +97,43 @@ define Build/Prepare
endef
endif
define Package/libwifiutils
SECTION:=libs
CATEGORY:=Libraries
TITLE:= WiFi utility library (libwifiutils.so)
DEPENDS+=+libnl +libnl-route +libeasy +libopenssl
endef
define Package/libwifiutils/description
Library provides WiFi utility functions
endef
define Package/libwifi
SECTION:=libs
CATEGORY:=Libraries
TITLE:= WiFi HAL library (libwifi-7.so.m)
DEPENDS+=+libnl +libnl-route +libeasy +libwifiutils +TARGET_brcmbca:bcm963xx-bsp
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
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)/libwifiutils/wifidefs.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/libwifiutils/wifiutils.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/libwifiutils/libwifiutils*.so* $(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/libwifiutils*.so* $(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:bcm963xx-bsp
endef
define Package/libwifi/config
@@ -155,12 +154,13 @@ define Package/libwifi/config
endif
endef
define Build/InstallDev/libwifi
$(INSTALL_DIR) $(1)/usr/include
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libwifi/wifiops.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/libwifi/wifi.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/libwifi/libwifi-7*.so* $(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
@@ -173,7 +173,7 @@ endef
define Package/libwifi/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libwifi/libwifi-7*.so* $(1)/usr/lib/
$(CP) $(PKG_BUILD_DIR)/libwifi-7*.so* $(1)/usr/lib/
endef
$(eval $(call BuildPackage,libwifiutils))

View File

@@ -31,8 +31,8 @@ MESON_ARGS += \
define Package/linux-pam/install
$(INSTALL_DIR) $(1)/usr/lib/security
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./linux_pam.init $(1)/etc/init.d/linux_pam
$(INSTALL_DIR) $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./files/pam_faillock.uci_default $(1)/etc/uci-defaults/99-add_pam_faillock
endef
$(eval $(call BuildPackage,linux-pam))

View File

@@ -0,0 +1,43 @@
#!/bin/sh
create_faillock_files()
{
# also create files needed by pam_faillock
touch /var/log/faillock
chmod 700 /var/log/faillock
touch /var/log/btmp
chmod 700 /var/log/btmp
}
update_pam_common_auth()
{
local file="/etc/pam.d/common-auth"
local deny=6
local unlock_time=300
# update pam_unix.so line
sed -i -E 's|^.*pam_unix\.so.*|auth\t sufficient\tpam_unix.so nullok_secure|' "$file"
# Insert pam_faillock lines before and after pam_unix.so
sed -i -E "/pam_unix.so nullok_secure/i auth required pam_faillock.so preauth deny=$deny even_deny_root unlock_time=$unlock_time" "$file"
sed -i -E "/pam_unix.so nullok_secure/a auth [default=die] pam_faillock.so authfail audit deny=$deny even_deny_root unlock_time=$unlock_time" "$file"
}
update_pam_common_account()
{
# update account file
sed -i "/pam_unix.so/ i account required pam_faillock.so" /etc/pam.d/common-account
}
if [ -f "/usr/lib/security/pam_faillock.so" ]; then
update_pam_common_auth
update_pam_common_account
create_faillock_files
fi
if [ -f /etc/config/sshd ]; then
uci -q set sshd.@sshd[0].UsePAM=1
uci commit sshd
fi
exit 0

View File

@@ -1,18 +0,0 @@
#!/bin/sh /etc/rc.common
START=11
STOP=90
USE_PROCD=1
create_faillock_files()
{
# also create files needed by pam_faillock
touch /var/log/faillock
chmod 700 /var/log/faillock
touch /var/log/btmp
chmod 700 /var/log/btmp
}
boot() {
create_faillock_files
}

View File

@@ -1,5 +1,4 @@
if PACKAGE_logmngr
choice
prompt "Select backend for syslog management"
default LOGMNGR_BACKEND_FLUENTBIT
@@ -32,5 +31,4 @@ config LOGMNGR_VENDOR_LOG_FILE
default y
help
It adds support for Device.DeviceInfo.VendorLogFile. Object.
endif

View File

@@ -5,13 +5,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=logmngr
PKG_VERSION:=1.1.4
PKG_VERSION:=1.0.17
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/system/logmngr.git
PKG_SOURCE_VERSION:=62441fdfe14a39bff8fff7c62307bd7b54d7240f
PKG_SOURCE_VERSION:=ad2636c642d56967e78c0c84bf82cb0e2b6311f2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif
@@ -52,35 +52,29 @@ endif
define Package/logmngr/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_BIN) ./files/logmngr.init $(1)/etc/init.d/logmngr
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/10-logmngr_config_generate $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./files/etc/init.d/logmngr $(1)/etc/init.d/
$(INSTALL_DATA) ./files/etc/config/logmngr $(1)/etc/config/
$(INSTALL_DATA) ./files/etc/uci-defaults/10-logmngr_config_migrate $(1)/etc/uci-defaults/
$(BBFDM_INSTALL_MS_PLUGIN) $(PKG_BUILD_DIR)/bbf_plugin/libbbfsyslog.so $(1) core 10
# Install logmngr service backend
$(INSTALL_DIR) $(1)/lib/logmngr
ifeq ($(CONFIG_LOGMNGR_BACKEND_FLUENTBIT),y)
$(INSTALL_DATA) ./files/lib/logmngr/fluent-bit.sh $(1)/lib/logmngr/
$(INSTALL_DIR) $(1)/sbin
$(INSTALL_BIN) ./files/logread $(1)/sbin/
$(INSTALL_DATA) ./files/lib/logmngr/fluent-bit.sh $(1)/lib/logmngr/
else ifeq ($(CONFIG_LOGMNGR_BACKEND_SYSLOG_NG),y)
endif
ifeq ($(CONFIG_LOGMNGR_BACKEND_SYSLOG_NG),y)
$(INSTALL_DATA) ./files/lib/logmngr/syslog-ng.sh $(1)/lib/logmngr/
endif
$(BBFDM_INSTALL_MS_PLUGIN) $(PKG_BUILD_DIR)/bbf_plugin/libbbfsyslog.so $(1) core 10
ifeq ($(CONFIG_LOGMNGR_LOGROTATE),y)
$(INSTALL_BIN) ./files/11-logmngr_logrotate_config_generate $(1)/etc/uci-defaults/
$(INSTALL_DATA) ./files/lib/logmngr/logrotate.sh $(1)/lib/logmngr/
$(INSTALL_DATA) ./files/etc/uci-defaults/11-logmngr_logrotate_syslog $(1)/etc/uci-defaults/
$(BBFDM_INSTALL_MS_PLUGIN) $(PKG_BUILD_DIR)/bbf_plugin/libbbflogrotate.so $(1) sysmngr 11
endif
ifeq ($(CONFIG_LOGMNGR_VENDOR_LOG_FILE),y)
$(BBFDM_INSTALL_MS_PLUGIN) $(PKG_BUILD_DIR)/bbf_plugin/libbbfvendorlog.so $(1) sysmngr 12
endif
endef
$(eval $(call BuildPackage,logmngr))

View File

@@ -0,0 +1,26 @@
#!/bin/sh
if uci -q get logmngr.@globals[0] >/dev/null; then
# return if there is any valid content
exit 0
else
rm -f /etc/config/logmngr
fi
touch /etc/config/logmngr
uci set logmngr.globals=globals
uci set logmngr.globals.enable=1
uci set logmngr.a1=action
uci set logmngr.a1.name="ac1"
uci set logmngr.lf1=log_file
uci set logmngr.lf1.enable=1
uci set logmngr.lf1.action="ac1"
uci set logmngr.lf1.file="/var/log/messages"
uci set logmngr.lr1=log_remote
uci set logmngr.lr1.enable=0
uci set logmngr.lr1.action="ac1"
uci set logmngr.lr1.port="514"

View File

@@ -1,7 +1,7 @@
#!/bin/sh
# Adds a default log rotate policy if none exists
if uci -q get logmngr.lro1 >/dev/null; then
if uci -q get logmngr.@log_rotate[0] >/dev/null; then
# return if there is any valid content
exit 0
fi

View File

@@ -1,26 +0,0 @@
config globals 'globals'
option enable '1'
config source 'default_source'
option name 'default_source'
option system_messages '1'
option kernel_messages '1'
config template 'default_template'
option name 'default_template'
option expression '{time} {hostname} {ident}[{pid}]: {message}'
config action 'default_action'
option name 'default_action'
list source 'default_source'
option template 'default_template'
config log_file 'lf1'
option enable '1'
option action 'default_action'
option file '/var/log/messages'
config log_remote 'lr1'
option enable '0'
option action 'default_action'
option port '514'

View File

@@ -1,36 +0,0 @@
#!/bin/sh
# check if this is a new type UCI or old type UCI
if ! uci -q get logmngr.default_source > /dev/null; then
uci -q set logmngr.default_source=source
uci -q set logmngr.default_source.name='default_source'
uci -q set logmngr.default_source.system_messages='1'
uci -q set logmngr.default_source.kernel_messages='1'
fi
if ! uci -q get logmngr.default_template > /dev/null; then
uci -q set logmngr.default_template=template
uci -q set logmngr.default_template.name='default_template'
uci -q set logmngr.default_template.expression='{time} {hostname} {ident}[{pid}]: {message}'
fi
if uci -q get logmngr.a1 >/dev/null; then
uci -q rename logmngr.a1='default_action'
uci -q set logmngr.default_action.name='default_action'
uci -q set logmngr.default_action.template='default_template'
uci -q delete logmngr.default_action.source
uci -q add_list logmngr.default_action.source='default_source'
fi
if uci -q get logmngr.lf1 >/dev/null; then
uci -q rename logmngr.lf1='default_logfile'
uci -q set logmngr.default_logfile.action='default_action'
fi
if uci -q get logmngr.lr1 >/dev/null; then
uci -q rename logmngr.lr1='default_logremote'
uci -q set logmngr.default_logremote.action='default_action'
fi
exit 0

View File

@@ -6,37 +6,6 @@
CONF_FILE=/etc/fluent-bit/fluent-bit.conf
TMP_CONF_FILE=/tmp/fluent-bit/fluent-bit.conf
FLUENT_BIT_CONF_DIR=/etc/fluent-bit/conf.d
PROCESSED_SYSLOG_TAGS=""
PROCESSED_KMSG_TAGS=""
# check if syslog source section is already processed
# and add it to the list of processed source sections
syslog_tag_already_processed() {
local tag="$1"
for t in $PROCESSED_SYSLOG_TAGS; do
[ "$t" = "$tag" ] && return 0
done
PROCESSED_SYSLOG_TAGS="$tag $PROCESSED_SYSLOG_TAGS"
return 1
}
# check if kmsg source section is already processed
# and add it to the list of processed source sections
# two separate functions used because we want to populate
# appropriate PROCESSED variable
kmsg_tag_already_processed() {
local tag="$1"
for t in $PROCESSED_KMSG_TAGS; do
[ "$t" = "$tag" ] && return 0
done
PROCESSED_KMSG_TAGS="$tag $PROCESSED_KMSG_TAGS"
return 1
}
append_conf() {
echo "$*" >> ${TMP_CONF_FILE}
@@ -51,282 +20,219 @@ create_config_file() {
# also, if no file is found then fluent-bit aborts
# so only add include if any file is present in the FLUENT_BIT_CONF_DIR
if [ -d "$FLUENT_BIT_CONF_DIR" ] && [ "$(ls -A "$FLUENT_BIT_CONF_DIR")" ]; then
append_conf "@INCLUDE ${FLUENT_BIT_CONF_DIR}/*"
echo "@INCLUDE ${FLUENT_BIT_CONF_DIR}/*" >> ${TMP_CONF_FILE}
fi
append_conf ""
echo "" >> ${TMP_CONF_FILE}
}
create_service_section() {
# the service section of the fluent-bit.conf file has hardcoded values,
# no need to lookup any uci section to configure this section
append_conf "[SERVICE]"
append_conf " flush 1"
append_conf " daemon off"
append_conf " log_level info"
append_conf " coro_stack_size 24576"
append_conf " parsers_file /etc/fluent-bit/parsers.conf"
append_conf " hot_reload on"
append_conf ""
}
echo "[SERVICE]" >> ${TMP_CONF_FILE}
echo " flush 1" >> ${TMP_CONF_FILE}
echo " daemon off" >> ${TMP_CONF_FILE}
echo " log_level info" >> ${TMP_CONF_FILE}
echo " coro_stack_size 24576" >> ${TMP_CONF_FILE}
echo " parsers_file /etc/fluent-bit/parsers.conf" >> ${TMP_CONF_FILE}
echo " hot_reload on" >> ${TMP_CONF_FILE}
echo "" >> ${TMP_CONF_FILE}
create_default_filters() {
append_conf "[FILTER]"
append_conf " name modify"
append_conf " match KM*"
append_conf " add ident kernel"
append_conf " rename msg message"
append_conf ""
# Generate default input for kmsg
echo "[INPUT]" >> ${TMP_CONF_FILE}
echo " name kmsg" >> ${TMP_CONF_FILE}
echo " Tag KMSG" >> ${TMP_CONF_FILE}
echo "" >> ${TMP_CONF_FILE}
append_conf "[FILTER]"
append_conf " name modify"
append_conf " match *"
append_conf " add pid 0"
append_conf ""
append_conf "[FILTER]"
append_conf " name sysinfo"
append_conf " match *"
append_conf " hostname_key hostname"
append_conf ""
echo "[OUTPUT]" >> ${TMP_CONF_FILE}
echo " name file" >> ${TMP_CONF_FILE}
echo " match KMSG" >> ${TMP_CONF_FILE}
echo " file /var/log/messages" >> ${TMP_CONF_FILE}
echo " format template" >> ${TMP_CONF_FILE}
echo " template {syslog_ts} {hostname} kernel: {msg}" >> ${TMP_CONF_FILE}
echo "" >> ${TMP_CONF_FILE}
}
create_input_section() {
local tag="$1"
[ -z "$tag" ] && return
# check if this source section has already been processed
syslog_tag_already_processed "$tag" && return
append_conf "[INPUT]"
append_conf " name syslog"
append_conf " unix_perm 0666"
append_conf " tag $tag"
append_conf " path /dev/log"
append_conf ""
# the input in our case is always syslog, hence, this section of the
# fluent-bit.conf file has hardcoded values as well that do not depend
# on any uci value
echo "[INPUT]" >> ${TMP_CONF_FILE}
echo " name syslog" >> ${TMP_CONF_FILE}
echo " tag $tag" >> ${TMP_CONF_FILE}
echo " path /dev/log" >> ${TMP_CONF_FILE}
echo "" >> ${TMP_CONF_FILE}
}
populate_allowed_logs() {
local facility_level sev_level
local section="$1"
generate_facility_regex() {
local facility_level=$1
local pri=0
[ -z "$section" ] && return
# reset
match_pattern=""
facilities=""
all_facilities=0
kern_facility=0
severities=""
sev_compare=1
sev_action=0
# read config
config_get match_pattern $section pattern_match
config_get facility_level $section facility_level
config_get sev_level $section severity_level
config_get sev_compare $section severity_compare 1
config_get sev_action $section severity_action 0
# normalize facilities
if [ -n "$facility_level" ]; then
for f in $facility_level; do
if [ "$f" = "24" ]; then
all_facilities=1
# xargs is used to convert from new line separated numbers to space separated numbers
facilities="$(seq 0 23 | xargs)"
break
fi
if [ "$f" = "0" ]; then
kern_facility=1
fi
done
if [ "$all_facilities" -eq 0 ]; then
facilities="$facility_level"
fi
else
# default to "all facilities" when unset
all_facilities=1
facilities="$(seq 0 23 | xargs)"
fi
# normalize severities
case "$sev_level" in
8) # all severities
severities="$(seq 0 7 | xargs)"
;;
9) # none
severities="none"
;;
"") # unset, treat as "all"
severities="$(seq 0 7 | xargs)"
;;
*)
if [ "$sev_compare" = "0" ]; then
# equal
severities="$sev_level"
else
# equl or higher
severities="$(seq 0 $sev_level | xargs)"
fi
;;
esac
}
create_filter_section() {
local match_regex="$1"
local pattern="$2"
[ -z "$match_regex" ] && return
append_conf "[FILTER]"
append_conf " name grep"
append_conf " match_regex $match_regex"
# we need "logical_op or" only in non-pattern sections
if [ "$pattern" = "0" ]; then
append_conf " logical_op or" # handle multiple filters
fi
}
create_kmsg_input_section() {
local tag="$1"
local max_sev=7
[ -z "$tag" ] && return
kmsg_tag_already_processed "$tag" && return
if [ -c "/dev/kmsg" ]; then
append_conf "[INPUT]"
append_conf " name kmsg"
append_conf " tag $tag"
# check kern facility (0)
if [ "$all_facilities" -eq 1 ] || [ "$kern_facility" -eq 1 ]; then
if [ "$severities" != "none" ]; then
# severity filtering
# only EqualOrHigher is supported by Prio_Level
# and only Log action is supported
# so set Prio_Level = max severity
if [ "$sev_action" = "0" ] && [ "$sev_compare" = "1" ]; then
if [ -n "$severities" ]; then
max_sev=$(echo $severities | tr ' ' '\n' | sort -n | tail -1)
fi
append_conf " prio_level $max_sev"
fi
fi
fi
append_conf ""
# if severities is none, or
# if kern facility has been excluded
# then we need to stop kernel logs
# sev_action and sev_compare is being checked because we don't want to work with rules that exclude logs
if [ "$severities" = "none" ] || { [ "$kern_facility" -eq 0 ] && [ "$all_facilities" -eq 0 ] && [ "$sev_action" = "0" ] && [ "$sev_compare" = "1" ]; }; then
# block all
# create a filter section that matches on KM* tag
# and excludes all messages
create_filter_section "KM*" "0"
append_conf " exclude message ^.*$"
append_conf ""
fi
fi
}
generate_syslog_filter() {
local param="regex"
[ "$sev_action" = "1" ] && param="exclude"
# start adding the fluent-bit filter section
create_filter_section "SL*" "0"
if [ "$severities" = "none" ]; then
append_conf " exclude pri ^.*$"
if [ "$facility_level" == "24" ]; then
# value 24 means all facility level, which is as good as not
# generating a filter section, so return
return
fi
for fval in $facilities; do
for sval in $severities; do
local pri=$((fval * 8 + sval))
append_conf " $param pri ^${pri}$"
# facility_level is a list value, hence, generate regex for
# each value
IFS=" "
for val in $facility_level; do
# as per rfc 5424 and 3164, pri in syslog msg is
# facility*8+severity. Severity value can range from 0-7 hence
# generate regex for each.
for sval in 0 1 2 3 4 5 6 7; do
pri=`expr $val \* 8 + $sval`
echo " regex pri $pri" >> ${TMP_CONF_FILE}
done
done
append_conf ""
}
generate_pattern_filter() {
local match_regex="$1"
local match_pattern="$2"
generate_severity_regex() {
local sev_level="$1"
local sev_compare="$2"
local sev_action="$3"
[ -z "$match_regex" ] && return
[ -z "$match_pattern" ] && return
local pri=0
local param="exclude"
# start adding the fluent-bit filter section
create_filter_section "$match_regex" "1"
append_conf " regex message $match_pattern"
append_conf ""
if [ "$sev_action" == "0" ]; then
param="regex"
fi
local fval=0
if [ "$sev_compare" == "0" ]; then
# generate regex for all facility values, with severity=sev_level
while [ $fval -le 23 ] ; do
pri=`expr $fval \* 8 + $sev_level`
echo " $param pri $pri" >> ${TMP_CONF_FILE}
fval=$((fval + 1))
done
elif [ "$sev_compare" == "1" ]; then
# generate regex for all severity value greater than or equal to
# sev_level. please, lower value have higher precedence, so sev_level
# 0 which is emergency has higher precedence than error which is 3
while [ $fval -le 23 ] ; do
sval=0
while [ $sev_level -ge $sval ]; do
pri=`expr $fval \* 8 + $sval`
echo " $param pri $pri" >> ${TMP_CONF_FILE}
sval=$((sval + 1))
done
fval=$((fval + 1))
done
fi
}
handle_filter_conf() {
local section="$1" # config filter
local filter_name="$2"
local name
# no need to proceed if name of filter section is not one of the values
# listed in option filter in config action section
config_get name $section name
if [ "$name" != "$filter_name" ]; then
return
fi
# as per data model, at a time either facility_level or severity_level can
# be specified along with pattern_match. hence, first process and generate
# regex for pattern_match which is common in both condition. Next, we will
# process facility_level and return if facility level is defined and not
# process severity related params at all.
local pattern_match
config_get pattern_match $section pattern_match
if [ -n "$pattern_match" ]; then
echo " regex $pattern_match" >> ${TMP_CONF_FILE}
fi
local facility_level
config_get facility_level $section facility_level
if [ -n "$facility_level" ]; then
generate_facility_regex $facility_level
# return from here since if facility_level is defined, then no
# need to process severity_level
return
fi
local sev_level
local sev_compare
local sev_action
config_get sev_level $section severity_level
if [ -n "$sev_level" ]; then
# value 1 of severity compare corresponds to data model
# and system default which is EqualorHigher
config_get sev_compare $section severity_compare 1
# value 0 of severity action corresponds to data model
# and system default that is log
config_get sev_action $section severity_action 0
generate_severity_regex $sev_level $sev_compare $sev_action
fi
}
create_filter_section() {
local match="$1"
echo "[FILTER]" >> ${TMP_CONF_FILE}
echo " name grep" >> ${TMP_CONF_FILE}
echo " match $match" >> ${TMP_CONF_FILE}
echo " logical_op or" >> ${TMP_CONF_FILE} # handle multiple filters
}
handle_filter_ref() {
local filter_name="$1"
config_foreach handle_filter_conf filter "$filter_name"
}
handle_log_file() {
local section="$1" # out_file section
local linker="$2"
local match_regex="$3"
local template="$4"
local match="$2"
local action_ref
config_get action_ref $section action
if [ "$action_ref" != "$linker" ]; then
if [ "$action_ref" != "$match" ]; then
return
fi
local enabled
config_get_bool enabled $section enable
if [ "$enabled" = "0" ]; then
config_get enabled $section enable
if [ "$enabled" == 0 ]; then
return
fi
local file
config_get file $section file
if [ -z "$file" ] || [ -z "$match_regex" ]; then
if [ -z "$file" ]; then
return
fi
append_conf "[OUTPUT]"
append_conf " name file"
append_conf " workers 2"
append_conf " match_regex $match_regex"
append_conf " file $file"
if [ -n "$template" ]; then
append_conf " format template"
append_conf " template ${template}"
fi
append_conf ""
echo "[OUTPUT]" >> ${TMP_CONF_FILE}
echo " name file" >> ${TMP_CONF_FILE}
echo " match $match" >> ${TMP_CONF_FILE}
echo " file $file" >> ${TMP_CONF_FILE}
echo " format template" >> ${TMP_CONF_FILE}
echo " template {time} {hostname} {ident}: {message}" >> ${TMP_CONF_FILE}
}
handle_log_remote() {
local section="$1"
local linker="$2"
local match_regex="$3"
local match="$2"
local action_ref
config_get action_ref $section action
if [ "$action_ref" != "$linker" ]; then
if [ "$action_ref" != "$match" ]; then
return
fi
local enabled
config_get_bool enabled $section enable
if [ "$enabled" = "0" ]; then
config_get enabled $section enable
if [ "$enabled" == 0 ]; then
return
fi
@@ -336,167 +242,83 @@ handle_log_remote() {
return
fi
append_conf "[OUTPUT]"
append_conf " name syslog"
append_conf " match_regex $match_regex"
append_conf " host $address"
echo "[OUTPUT]" >> ${TMP_CONF_FILE}
echo " name syslog" >> ${TMP_CONF_FILE}
echo " match $match" >> ${TMP_CONF_FILE}
echo " host $address" >> ${TMP_CONF_FILE}
append_conf " syslog_appname_key ident"
append_conf " syslog_procid_key pid"
append_conf " syslog_message_key message"
append_conf " syslog_hostname_key hostname"
local hostname="$(uci -q get 'system.@system[0].hostname')"
if [ -n "${hostname}" ]; then
append_conf " syslog_hostname_preset ${hostname}"
fi
local proto # holds value tcp or udp
config_get proto ${section} proto
if [ -n "$proto" ]; then
if [ "$proto" == "tls" ]; then
append_conf " mode tcp"
append_conf " tls on"
echo " mode tcp" >> ${TMP_CONF_FILE}
echo " tls on" >> ${TMP_CONF_FILE}
else
append_conf " mode $proto"
echo " mode $proto" >> ${TMP_CONF_FILE}
fi
fi
local port
config_get port $section port
if [ -n "$port" ]; then
append_conf " port $port"
echo " port $port" >> ${TMP_CONF_FILE}
fi
local cert
local peer_verify
config_get cert $section cert
if [ -n "$cert" ]; then
append_conf " tls.crt_file $cert"
echo " tls.crt_file $cert" >> ${TMP_CONF_FILE}
config_get_bool peer_verify $section peer_verify
if [ "$peer_verify" = "1" ]; then
append_conf " tls.verify on"
config_get peer_verify $section peer_verify
if [ "$peer_verify" == "1" ]; then
echo " tls.verify on" >> ${TMP_CONF_FILE}
fi
fi
append_conf ""
}
resolve_source_section() {
local src_section="$1"
local linker="$2"
local src_name syslog_en kernel_en
config_get src_name "$src_section" name
[ "$src_name" = "$linker" ] || return
config_get_bool syslog_en "$src_section" system_messages 1
config_get_bool kernel_en "$src_section" kernel_messages 1
# create an input section using /dev/log or kmsg
# and store the tag in a variable
# so that later a regex can be made to match this tag
# which will be used in output section
if [ "$syslog_en" = "1" ]; then
source_tag_syslog="SL$src_name"
create_input_section "$source_tag_syslog"
fi
if [ "$kernel_en" = "1" ]; then
source_tag_kmsg="KM$src_name"
create_kmsg_input_section "$source_tag_kmsg"
fi
}
# get the value of option expression from the relevant section
resolve_template_section() {
local tmpl_section="$1"
local tmpl_name
config_get tmpl_name "$tmpl_section" name
[ "$tmpl_name" = "$template_ref" ] || return
config_get template_expr "$tmpl_section" expression
[ -n "$template_expr" ] && echo "$template_expr"
}
# loop over template sections and get the value of option expression from the relevant section
get_template_expression() {
local template_ref="$1"
[ -n "$template_ref" ] && config_foreach resolve_template_section template
}
# build a regex that will match all the tags supplied to this function
build_match_regex() {
local tags="$1"
local first=1
local regex="^("
for tag in $tags; do
[ "$first" -eq 1 ] && first=0 || regex="$regex|"
regex="$regex$tag"
done
regex="$regex)\$"
echo "$regex"
}
handle_filter_conf() {
local section="$1" # config filter
local filter_name="$2"
local name
config_get name $section name
[ "$name" = "$filter_name" ] || return
populate_allowed_logs "$filter_name"
}
handle_action() {
local tag_regex filter source_ref template_ref source_sec log_template finst
local action_section="$1"
local source_tag_syslog source_tag_kmsg
local section="$1"
# shared variables set by populate_allowed_logs
match_pattern=""
facilities=""
all_facilities=0
kern_facility=1
severities=""
sev_compare=1
sev_action=0
local filter
config_get filter $section filter
config_get action_name "$action_section" name
config_get filter "$action_section" filter
config_get source_ref "$action_section" source
config_get template_ref "$action_section" template
# use config action option name as tag for input
local tag
config_get tag $section name
if [ -z "$tag" ]; then
return
fi
[ -z "$action_name" ] && return
[ -z "$source_ref" ] && return
# read filter section and populate relevant variables
# these variables will be used by create_kmsg_input_section
# generate_syslog_filter, and generate_pattern_filter functions
create_input_section $tag
if [ -n "$filter" ]; then
# the only fluentbit filter that is useful for the datamodel is
# grep. Also, fluentbit does not seem to handle multiple instances
# of FILTER of same kind. Hence, each filter section corresponding
# to an action entry in the uci would translate for us into a set of
# regex/exclude values instead of individual FILTER section per uci
# section filter is a list, treat according
create_filter_section $tag
IFS=" "
for finst in $filter; do
config_foreach handle_filter_conf filter "$finst"
handle_filter_ref $finst
done
fi
# Resolve referenced source sections
for source_sec in $source_ref; do
config_foreach resolve_source_section source "$source_sec"
done
# build a regex that will match all the sources for this action
tag_regex=$(build_match_regex "$source_tag_syslog $source_tag_kmsg")
if [ -n "$filter" ]; then
generate_pattern_filter "$tag_regex" "$match_pattern"
generate_syslog_filter
fi
# get the template expression if any is present
log_template="$(get_template_expression "$template_ref")"
# handle output, each action can be associated with an out_log and out_syslog
# handle output, each action can be associated with a out_log and out_syslog
# section so figure out if any out_log or out_syslog section is associated
# with this and action and setup output accordingly.
config_foreach handle_log_file log_file "$action_name" "$tag_regex" "$log_template"
config_foreach handle_log_remote log_remote "$action_name" "$tag_regex"
config_foreach handle_log_file log_file "$tag"
config_foreach handle_log_remote log_remote "$tag"
}
handle_action_section() {
@@ -512,14 +334,13 @@ logmngr_init() {
create_config_file
create_service_section
create_default_filters
handle_action_section
if [ -f /lib/logmngr/logrotate.sh ]; then
logrotate_init
fi
if [ "$enabled" = "0" ]; then
if [ "$enabled" == "0" ]; then
return
fi

View File

@@ -55,20 +55,12 @@ config AGENT_OPER_CHANNEL_CHANGE_RELAY_MCAST
config AGENT_USE_LIBDPP
bool "Depend on libdpp for DPP EasyConnect"
config AGENT_ZEROTOUCH_DPP
bool "Enable Zero-touch DPP bootstrapping. Depends on libztdpp.so"
default n
config AGENT_CHECK_PARTIAL_WIFI_RELOAD
bool "Option that allow SSID/PSK simple reload"
default y
config DYNBH
bool "Enable map-agent dynamic Ethernet backhaul management"
default n
config DYNBH_DYNAMICALLY_PERSIST_CONTROLLER
bool "Let map-agent through AP-Autoconfiguration Search and DHCP Discovery determine the controller or agent role"
config DYNBHD_DYNAMICALLY_PERSIST_CONTROLLER
bool "Let dynbhd through AP-Autoconfiguration Search and DHCP Discovery determine the controller or agent role"
config AGENT_UNASSOC_STA_CONT_MONITOR
bool "Enable continuos monitoring of unassociated clients"

View File

@@ -1,14 +1,13 @@
#
# Copyright (C) 2020-2024 IOPSYS Software Solutions AB
# Copyright (C) 2025 Genexis Sweden AB
# Copyright (C) 2020-2023 IOPSYS Software Solutions AB
#
include $(TOPDIR)/rules.mk
PKG_NAME:=map-agent
PKG_VERSION:=6.4.3.5
PKG_VERSION:=6.3.6.7
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=eeea7b39112717639046ac347e30ed0991ca490f
PKG_SOURCE_VERSION:=f611be0c05e3f4fb3d35a5a1ad51f5a4ad6406ca
PKG_MAINTAINER:=Jakob Olsson <jakob.olsson@iopsys.eu>
PKG_LICENSE:=BSD-3-Clause
@@ -27,7 +26,7 @@ include $(INCLUDE_DIR)/package.mk
define Package/map-agent
SECTION:=utils
CATEGORY:=Utilities
TITLE:=Wi-Fi Multi-AP Agent (EasyMesh R6)
TITLE:=WiFi multi-AP Agent (EasyMesh R2)
DEPENDS:=+libwifi +libuci +libubox +ubus +libeasy +libieee1905 +ieee1905 \
+ieee1905-map-plugin +ip-bridge +AGENT_USE_LIBDPP:libdpp \
+uuidgen +openssl-util +!TARGET_brcmbca:ebtables-legacy \
@@ -38,12 +37,21 @@ ifeq ($(CONFIG_AGENT_USE_LIBDPP),y)
TARGET_CFLAGS += -DUSE_LIBDPP
endif
ifeq ($(CONFIG_AGENT_ZEROTOUCH_DPP),y)
TARGET_CFLAGS += -DZEROTOUCH_DPP
endif
define Package/dynbhd
SECTION:=utils
CATEGORY:=Utilities
TITLE:=Dynamic Backhaul Daemon
DEPENDS:=+libwifi +libuci +libubox +ubus +libeasy +libieee1905 +ieee1905 \
+ieee1905-map-plugin +map-agent
endef
define Package/map-agent/description
This package provides EasyMesh R6 compliant Wi-Fi Multi-AP Agent.
This package implements EasyMesh R2 compliant WiFi Agent.
endef
define Package/dynbhd/description
Dyanmic LAN/WAN port detection and loop avoidance.
endef
define Package/map-agent/config
@@ -103,11 +111,7 @@ ifeq ($(CONFIG_AGENT_CHECK_PARTIAL_WIFI_RELOAD),y)
TARGET_CFLAGS += -DCHECK_PARTIAL_WIFI_RELOAD
endif
ifeq ($(CONFIG_DYNBH),y)
TARGET_CFLAGS += -DDYNBH
endif
ifeq ($(CONFIG_DYNBH_DYNAMICALLY_PERSIST_CONTROLLER),y)
ifeq ($(CONFIG_DYNBHD_DYNAMICALLY_PERSIST_CONTROLLER),y)
TARGET_CFLAGS += -DPERSIST_CONTROLLER
endif
@@ -120,10 +124,6 @@ MAKE_PATH:=src
define Package/map-agent/install
$(INSTALL_DIR) $(1)/etc
$(CP) ./files/* $(1)/
ifeq ($(CONFIG_DYNBH),y)
$(RM) $(1)/etc/hotplug.d/ethernet/map-dynamic-backhaul
$(RM) $(1)/etc/hotplug.d/ethernet/map-topology-discovery
endif
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/lib/wifi
@@ -131,6 +131,15 @@ endif
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/mapagent $(1)/usr/sbin/
endef
define Package/dynbhd/install
$(INSTALL_DIR) $(1)/etc
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/lib/wifi/dynbhd
$(INSTALL_DIR) $(1)/etc/hotplug.d/ethernet
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/dynbh/dynbhd $(1)/usr/sbin/dynbhd
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/dynbh/api $(1)/lib/wifi/dynbhd/api
# $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/dynbh/map-dynamic-backhaul $(1)/etc/hotplug.d/ethernet/map-dynamic-backhaul
endef
ifeq ($(LOCAL_DEV),1)
define Build/Prepare
@@ -139,3 +148,4 @@ endef
endif
$(eval $(call BuildPackage,map-agent))
$(eval $(call BuildPackage,dynbhd))

View File

@@ -17,7 +17,7 @@ config dynamic_backhaul
option missing_bh_reconfig_timer '1800'
config controller_select
option mode 'auto'
option id 'auto'
option probe_int '20'
option retry_int '9'
option autostart '1'

View File

@@ -27,6 +27,11 @@ done
al_brnet="${al_bridge:3}"
[ "$(uci -q get network.${al_brnet}.proto)" == "dhcp" ] || exit 0
############## Dynamic Backhaul Daemon ##############
if [ -n "$(which dynbhd)" ]; then
exit 0
fi
########################################################
################ Dedicated ETH WAN Port ################
wanport="$(jsonfilter -i /etc/board.json -e @.network.wan.device)"
@@ -90,8 +95,7 @@ if [ "$LINK" = "up" ]; then
config_foreach remove_from_bridge bsta
config_foreach update_bstas bsta down
hwaddr="$(ifconfig $PORT | grep -i hwaddr | awk '{print $5}' | awk '{print tolower($0)}')"
/lib/wifi/multiap set_uplink "eth" "$PORT" "$hwaddr"
/lib/wifi/multiap set_uplink "eth" "$PORT"
else
/lib/wifi/multiap unset_uplink "eth"
#rm -f "$map_bh_file"

View File

@@ -7,6 +7,20 @@ USE_PROCD=1
IS_CFG_VALID=1
MAP_DEV="map_dev"
MAP_IF="map"
start_dynbhd_service() {
rm -f /var/run/multiap/multiap.backhaul
procd_open_instance
procd_set_param command "/usr/sbin/dynbhd"
procd_set_param respawn
# procd_set_param stdout 1
# procd_set_param stderr 1
procd_close_instance
}
validate_agent_section() {
uci_validate_section mapagent agent "agent" \
'enabled:bool:true' \
@@ -37,7 +51,7 @@ validate_cs_section() {
uci_validate_section mapagent $section "${section}" \
'local:bool:false' \
'mode:string' \
'id:string' \
'probe_int:range(0,1000):20' \
'retry_int:range(0,255):3' \
'autostart:bool:false'
@@ -165,6 +179,17 @@ create_dir() {
}
start_service() {
if [ -f /usr/sbin/dynbhd ]; then
# Start dynbhd only if the device is operating in extender/repeater mode
al_bridge="$(uci -q get mapagent.agent.al_bridge)"
if [ "${al_bridge:0:3}" = "br-" ]; then
al_brnet="${al_bridge:3}"
if [ "$(uci -q get network.${al_brnet}.proto)" == "dhcp" ]; then
start_dynbhd_service
fi
fi
fi
config_load "mapagent"
validate_agent_config || return 1;

View File

@@ -1,15 +0,0 @@
#!/bin/sh
. /lib/functions.sh
adapt_cntlr_sel() {
local section=$1
id=$(uci -q get mapagent.@controller_select[0].id)
uci -q del mapagent.@controller_select[0].id
# re-apply any custom value
[ -z "${id}" ] || uci -q set mapagent.@controller_select[0].mode="${id}"
}
adapt_cntlr_sel

View File

@@ -10,11 +10,6 @@ network_mode="$(fw_printenv -n netmode)" # default is layer3
multiap_mode="$(fw_printenv -n multiap_mode)" # default is full
disable_mlo="$(fw_printenv -n disable_mlo)"
is_logan() {
[ -d /sys/module/mt_wifi ] && return 0
return 1
}
is_airoha() {
[ -f /proc/device-tree/compatible ] || return
strings /proc/device-tree/compatible | grep -qE '^(econet,|airoha,)'; return
@@ -49,16 +44,19 @@ generate_multiap_config() {
2g)
mode_band=2
priority=2
dpp_chan="81/1"
channels="1 6 11"
;;
5g)
mode_band=5
priority=1
dpp_chan="128/36"
channels="36-64 100-112"
;;
6g)
mode_band=6
priority=0
dpp_chan="133/49"
;;
esac
@@ -69,44 +67,45 @@ generate_multiap_config() {
device="$dev"
ifprefix_radio=""
if is_logan; then
uci set mapagent.agent.mld_prefix="bss"
ifname_sta=""
case "$band" in
2g)
ifprefix="ra%"
ifname="ra0"
ifname_bh="ra1"
ifname_sta="apcli0"
;;
5g)
ifprefix="rai%"
ifname="rai0"
ifname_bh="rai1"
ifname_sta="apclii0"
;;
6g)
ifprefix="rax%"
ifname="rax0"
ifname_bh="rax1"
ifname_sta="apclix0"
;;
esac
ifprefix_radio="${ifprefix}"
if [ "${network_mode}" == "extender" ]; then
ifname="${ifname_sta}"
fi
[ "$disable_mlo" == "1" ] || {
uci set wireless.$dev.mlo="1"
uci set wireless.$dev.mlo_capable="1"
}
elif is_airoha; then
if is_airoha; then
if [ -d "/sys/module/mt76" ]; then
ifprefix="wlan%_%"
ifname="wlan${devidx}_0"
ifname_bh="wlan${devidx}_1"
else
uci set mapagent.agent.mld_prefix="bss"
ifname_sta=""
case "$band" in
2g)
ifprefix="ra%"
ifname="ra0"
ifname_bh="ra1"
ifname_sta="apcli0"
;;
5g)
ifprefix="rai%"
ifname="rai0"
ifname_bh="rai1"
ifname_sta="apclii0"
;;
6g)
ifprefix="rax%"
ifname="rax0"
ifname_bh="rax1"
ifname_sta="apclix0"
;;
esac
ifprefix_radio="${ifprefix}"
if [ "${network_mode}" == "extender" ]; then
ifname="${ifname_sta}"
fi
[ "$disable_mlo" == "1" ] || {
uci set wireless.$dev.mlo="1"
uci set wireless.$dev.mlo_capable="1"
}
fi
uci set wireless.$dev.channels="$channels"
uci commit wireless
elif is_broadcom; then
@@ -159,17 +158,13 @@ generate_multiap_config() {
uci set mapagent.@bsta[-1].band="$mode_band"
uci set mapagent.@bsta[-1].priority="$priority"
# add dpp_chirp section for 2.4GHz bSTA
if [ $mode_band -eq 2 ]; then
uci add mapagent dpp_chirp
uci set mapagent.@dpp_chirp[-1].type="qrcode"
uci set mapagent.@dpp_chirp[-1].device="$device"
uci set mapagent.@dpp_chirp[-1].ifname="$ifname"
uci set mapagent.@dpp_chirp[-1].band="$mode_band"
for channel in $channels; do
uci add_list mapagent.@dpp_chirp[-1].channel="$channel"
done
fi
#uci add mapagent dpp_uri
#uci set mapagent.@dpp_uri[-1].type="qrcode"
#uci set mapagent.@dpp_uri[-1].device="$device"
#uci set mapagent.@dpp_uri[-1].ifname="$ifname"
#uci set mapagent.@dpp_uri[-1].band="$mode_band"
#uci set mapagent.@dpp_uri[-1].chirp_interval="10"
#uci add_list mapagent.@dpp_uri[-1].dpp_chan="$dpp_chan"
if [ $generate_wireless_sta_config -eq 1 ]; then
secname="default_sta_${device}"
@@ -263,6 +258,6 @@ map_genconf () {
config_foreach mapcontroller_remove_mld_id ap
}
fi
ubus -t 5 call uci commit '{"config":"mapcontroller"}'
uci -q commit mapcontroller
fi
}

View File

@@ -39,10 +39,6 @@ config CONTROLLER_EASYMESH_VENDOR_EXT_OUI
config CONTROLLER_USE_LIBDPP
bool "Depend on libdpp for DPP EasyConnect"
config CONTROLLER_ZEROTOUCH_DPP
bool "Enable Zero-touch DPP bootstrapping via passphrase."
default n
config CONTROLLER_PROPAGATE_PROBE_REQ
depends on CONTROLLER_EASYMESH_VENDOR_EXT
bool "Enable publishing probe requests vendor specific messages as UBUS events"

View File

@@ -6,9 +6,9 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=map-controller
PKG_VERSION:=6.4.4.4
PKG_VERSION:=6.4.0.12
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=3d10c21efbb0b0da7206435a1ecfeed107d55e83
PKG_SOURCE_VERSION:=ae10f447f8d83ed6b98d2b82da2dda64be2c3183
PKG_MAINTAINER:=Jakob Olsson <jakob.olsson@genexis.eu>
LOCAL_DEV=0
@@ -36,9 +36,6 @@ ifeq ($(CONFIG_CONTROLLER_USE_LIBDPP),y)
TARGET_CFLAGS += -DUSE_LIBDPP
endif
ifeq ($(CONFIG_CONTROLLER_ZEROTOUCH_DPP),y)
TARGET_CFLAGS += -DZEROTOUCH_DPP
endif
define Package/map-controller/description
This package provides WiFi MultiAP Controller as per the EasyMesh-R2 specs.
@@ -84,7 +81,6 @@ define Build/InstallDev
$(CP) $(PKG_BUILD_DIR)/src/cntlr_commands_impl.h $(1)/usr/include/map-controller
$(CP) $(PKG_BUILD_DIR)/src/cntlr_commands.h $(1)/usr/include/map-controller
$(CP) $(PKG_BUILD_DIR)/src/cntlr_apis.h $(1)/usr/include/map-controller
$(CP) $(PKG_BUILD_DIR)/src/cntlr_plugin.h $(1)/usr/include/map-controller
$(CP) $(PKG_BUILD_DIR)/src/wifi_opclass.h $(1)/usr/include/map-controller
$(CP) $(PKG_BUILD_DIR)/src/steer_module.h $(1)/usr/include/map-controller
$(CP) $(PKG_BUILD_DIR)/src/timer.h $(1)/usr/include/map-controller

View File

@@ -2,16 +2,16 @@ config controller 'controller'
option enabled '1' # may be modified by other package start-up scripts (i.e. map-agent)
option profile '3'
option registrar '2 5 6'
option debug '2'
option debug '0'
option bcn_metrics_max_num '10'
option initial_channel_scan '0'
option enable_ts '0'
option primary_vid '1'
option primary_pcp '0'
option stale_sta_timeout '20d'
option stale_sta_timeout '30d'
option de_collect_interval '60'
list plugin 'zerotouch'
config sta_steering 'sta_steering'
config sta_steering
option enable_sta_steer '1'
option enable_bsta_steer '0'
option rcpi_threshold_2g '70'
@@ -23,10 +23,8 @@ config sta_steering 'sta_steering'
option plugins_enabled '1'
option plugins_policy 'any'
list plugins 'rcpi'
list plugins 'rate'
list plugins 'bsteer'
config channel_plan 'channel_plan'
config channel_plan
option preclear_dfs '0'
option acs '0'

View File

@@ -20,6 +20,7 @@ validate_controller_section() {
'registrar:string' \
'debug:range(0,16)' \
'bcn_metrics_max_num:range(1,256)' \
'initial_channel_scan:bool:true' \
'resend_num:uinteger:0' \
'allow_bgdfs:range(0,2629744)' \
'stale_sta_timeout:string' \

View File

@@ -1,18 +0,0 @@
#!/bin/sh
. /lib/functions.sh
cfg=mapcontroller
# singleton sections
sections="channel_plan sta_steering"
for sec in $sections; do
# find unnamed section of given type, only index 0
s=$(uci show $cfg | grep -oE "@${sec}\[0\]" | sort -u)
[ "$s" = "" ] && continue
uci rename $cfg.$s=$sec
done
uci commit $cfg

View File

@@ -5,12 +5,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=map-plugins
PKG_VERSION:=1.2.2
PKG_VERSION:=0.0.4
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=03524191711a50a07b9c26f3be2c16b845140e49
PKG_SOURCE_VERSION:=74bf151851112ecee731d447af016c8dc668adcf
PKG_SOURCE_URL:=https://dev.iopsys.eu/multi-ap/map-plugins.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip
@@ -27,18 +27,11 @@ include $(INCLUDE_DIR)/package.mk
include $(wildcard plugins/*.mk)
TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include \
-I$(STAGING_DIR)/usr/include/libnl3 \
-D_GNU_SOURCE
MAKE_FLAGS += \
CFLAGS="$(TARGET_CFLAGS) -Wall"
plugins := \
$(if $(CONFIG_PACKAGE_map-plugins-steer-rate),steer-rate) \
$(if $(CONFIG_PACKAGE_map-plugins-bsteer),bsteer) \
$(if $(CONFIG_PACKAGE_map-plugins-zero-touch),zero-touch)
$(if $(CONFIG_PACKAGE_map-plugins-steer-rate),steer-rate)
ppkg:=$(patsubst plugins/%.mk,map-plugins-%,$(wildcard plugins/*.mk))
@@ -59,8 +52,7 @@ define Package/map-plugins
endef
define Package/map-plugins/description
Provides extra Multi-AP services viz. steering, channel-planning,
self-organizing network, zero-touch onboarding etc.
Provides extra Multi-AP services viz. steering, channel-planning etc.
endef
define Package/map-plugins/install
@@ -68,8 +60,9 @@ define Package/map-plugins/install
endef
define Build/Compile
$(foreach p,$(plugins),$(call Build/Compile/map-plugins-$(p), $(1)))
$(foreach p,$(ppkg),$(call Build/Compile/$(p),$(1)))
endef
$(eval $(call BuildPackage,map-plugins))
$(eval $(foreach p,$(ppkg),$(call BuildPackage,$(p))))

View File

@@ -1,20 +0,0 @@
define Package/map-plugins-bsteer
$(call Package/map-plugins/Default)
TITLE:=Wi-Fi backhaul steering plugin based on maximizing backhaul throughput
DEPENDS= +libubox +libuci +libubus +libeasy +libnl-genl \
+libjson-c +libblobmsg-json +map-controller \
+map-plugins
endef
define Package/map-plugins-bsteer/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_DIR) $(1)/usr/lib/mapcontroller
$(CP) $(PKG_BUILD_DIR)/steer/bsteer/bsteer.so $(1)/usr/lib/mapcontroller/bsteer.so
endef
define Build/Compile/map-plugins-bsteer
$(MAKE) -C $(PKG_BUILD_DIR)/steer/bsteer \
CC="$(TARGET_CC)" \
CFLAGS="$(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)";
endef

View File

@@ -16,5 +16,5 @@ define Build/Compile/map-plugins-steer-rate
$(MAKE) -C $(PKG_BUILD_DIR)/steer/rate \
CC="$(TARGET_CC)" \
CFLAGS="$(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)";
LDFLAGS="$(TARGET_LDFLAGS)"
endef

View File

@@ -1,22 +0,0 @@
define Package/map-plugins-zero-touch
$(call Package/map-plugins/Default)
TITLE:=Full Zero-touch bootstrapping of Wi-Fi Repeater device(s)
DEPENDS= +libubox +libuci +libubus +libeasy +libnl-genl \
+libjson-c +libblobmsg-json +map-controller \
+map-plugins
endef
define Package/map-plugins-zero-touch/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_DIR) $(1)/usr/lib/mapcontroller
$(CP) $(PKG_BUILD_DIR)/zero-touch/zerotouch.so $(1)/usr/lib/mapcontroller/zerotouch.so
$(CP) $(PKG_BUILD_DIR)/zero-touch/libztdpp.so $(1)/usr/lib/libztdpp.so
endef
define Build/Compile/map-plugins-zero-touch
$(MAKE) -C $(PKG_BUILD_DIR)/zero-touch \
CC="$(TARGET_CC)" \
CFLAGS="$(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)";
endef

View File

@@ -32,7 +32,7 @@ define Package/mcastmngr
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json
DEPENDS+=+!TARGET_brcmbca:mcproxy +!TARGET_brcmbca:sipcalc
DEPENDS+=+libbbfdm-api +libbbfdm-ubus +dm-service +!TARGET_brcmbca:kmod-ebt-igmpsnooping +!TARGET_brcmbca:kmod-ebt-mldsnooping
DEPENDS+=+!TARGET_brcmbca:ebtables-legacy +bridgemngr
DEPENDS+=+!TARGET_brcmbca:ebtables-legacy +dm-agent
endef
define Package/mcastmngr/description

View File

@@ -1,7 +0,0 @@
if PACKAGE_mosquitto-auth-plugin
config MOSQUITTO_AUTH_PAM_SUPPORT
bool "Enable support of Linux PAM module for Authentication"
default y
endif

View File

@@ -1,530 +0,0 @@
/*
* Copyright (c) 2022 Genexis B.V.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Erik Karlsson - initial implementation
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <shadow.h>
#include <crypt.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <mosquitto.h>
#include <mosquitto_broker.h>
#include <mosquitto_plugin.h>
#ifdef ENABLE_PAM_SUPPORT
#include <security/pam_appl.h>
#endif
#define MAX_USERS 256
#define MAX_SUBNETS_PER_USER 32
typedef struct {
uint32_t network;
uint32_t netmask;
} subnet_t;
typedef struct {
char username[64];
subnet_t allow_subnets[MAX_SUBNETS_PER_USER];
int allow_count;
subnet_t deny_subnets[MAX_SUBNETS_PER_USER];
int deny_count;
} user_acl_t;
typedef struct {
user_acl_t users[MAX_USERS];
int user_count;
mosquitto_plugin_id_t *identifier;
} plugin_data_t;
/* Parse CIDR notation (e.g., "192.168.1.0/24") */
static int parse_subnet(const char *cidr, subnet_t *subnet)
{
char ip_str[64];
char *slash;
int prefix_len;
struct in_addr addr;
strncpy(ip_str, cidr, sizeof(ip_str) - 1);
ip_str[sizeof(ip_str) - 1] = '\0';
slash = strchr(ip_str, '/');
if (slash == NULL) {
/* No prefix length, assume /32 */
prefix_len = 32;
} else {
*slash = '\0';
prefix_len = atoi(slash + 1);
if (prefix_len < 0 || prefix_len > 32)
return -1;
}
if (inet_pton(AF_INET, ip_str, &addr) != 1)
return -1;
subnet->network = ntohl(addr.s_addr);
subnet->netmask = prefix_len == 0 ? 0 : (~0U << (32 - prefix_len));
subnet->network &= subnet->netmask;
return 0;
}
/* Check if IP is in subnet */
static int ip_in_subnet(uint32_t ip, const subnet_t *subnet)
{
return (ip & subnet->netmask) == subnet->network;
}
/* Check if IP is in any subnet in the list */
static int ip_in_subnet_list(uint32_t ip, const subnet_t *subnets, int count)
{
for (int i = 0; i < count; i++) {
if (ip_in_subnet(ip, &subnets[i]))
return 1;
}
return 0;
}
/* Find or create user ACL entry */
static user_acl_t* find_or_create_user_acl(plugin_data_t *pdata, const char *username)
{
user_acl_t *user;
/* Find existing user */
for (int i = 0; i < pdata->user_count; i++) {
if (strcmp(pdata->users[i].username, username) == 0)
return &pdata->users[i];
}
/* Create new user if not found */
if (pdata->user_count >= MAX_USERS) {
mosquitto_log_printf(MOSQ_LOG_ERR,
"subnet_acl: Max users exceeded");
return NULL;
}
user = &pdata->users[pdata->user_count];
strncpy(user->username, username, sizeof(user->username) - 1);
user->username[sizeof(user->username) - 1] = '\0';
user->allow_count = 0;
user->deny_count = 0;
pdata->user_count++;
return user;
}
/* Parse subnet ACL file
* Format:
* # Comment lines
* subnet allow <username> <cidr>
* subnet deny <username> <cidr>
*/
static int load_subnet_acl_config(plugin_data_t *pdata, const char *config_file)
{
FILE *fp;
char line[512];
int line_num = 0;
if (config_file == NULL) {
mosquitto_log_printf(MOSQ_LOG_INFO,
"subnet_acl: No subnet ACL file specified, subnet filtering disabled");
return 0;
}
fp = fopen(config_file, "r");
if (fp == NULL) {
mosquitto_log_printf(MOSQ_LOG_WARNING,
"subnet_acl: Could not open subnet ACL file %s, subnet filtering disabled",
config_file);
return 0; /* Non-fatal */
}
pdata->user_count = 0;
while (fgets(line, sizeof(line), fp) != NULL) {
char *token, *saveptr;
char *action, *username, *cidr;
user_acl_t *user;
subnet_t subnet;
line_num++;
/* Remove newline and comments */
line[strcspn(line, "\r\n")] = '\0';
char *comment = strchr(line, '#');
if (comment)
*comment = '\0';
/* Trim leading whitespace */
char *line_start = line;
while (*line_start == ' ' || *line_start == '\t')
line_start++;
/* Skip empty lines */
if (*line_start == '\0')
continue;
/* Parse: subnet allow|deny <username> <cidr> */
token = strtok_r(line_start, " \t", &saveptr);
if (token == NULL)
continue;
/* Must start with "subnet" */
if (strcmp(token, "subnet") != 0) {
mosquitto_log_printf(MOSQ_LOG_WARNING,
"subnet_acl: Unknown directive '%s' at line %d (expected 'subnet')",
token, line_num);
continue;
}
/* Get allow/deny */
action = strtok_r(NULL, " \t", &saveptr);
if (action == NULL) {
mosquitto_log_printf(MOSQ_LOG_WARNING,
"subnet_acl: Missing allow/deny at line %d", line_num);
continue;
}
if (strcmp(action, "allow") != 0 && strcmp(action, "deny") != 0) {
mosquitto_log_printf(MOSQ_LOG_WARNING,
"subnet_acl: Unknown action '%s' at line %d (use 'allow' or 'deny')",
action, line_num);
continue;
}
/* Get username */
username = strtok_r(NULL, " \t", &saveptr);
if (username == NULL) {
mosquitto_log_printf(MOSQ_LOG_WARNING,
"subnet_acl: Missing username at line %d", line_num);
continue;
}
/* Get CIDR */
cidr = strtok_r(NULL, " \t", &saveptr);
if (cidr == NULL) {
mosquitto_log_printf(MOSQ_LOG_WARNING,
"subnet_acl: Missing CIDR at line %d", line_num);
continue;
}
/* Parse subnet */
if (parse_subnet(cidr, &subnet) != 0) {
mosquitto_log_printf(MOSQ_LOG_WARNING,
"subnet_acl: Invalid CIDR '%s' at line %d", cidr, line_num);
continue;
}
/* Find or create user */
user = find_or_create_user_acl(pdata, username);
if (user == NULL) {
mosquitto_log_printf(MOSQ_LOG_ERR,
"subnet_acl: Failed to create user at line %d", line_num);
continue;
}
/* Add to appropriate list */
if (strcmp(action, "allow") == 0) {
if (user->allow_count >= MAX_SUBNETS_PER_USER) {
mosquitto_log_printf(MOSQ_LOG_WARNING,
"subnet_acl: Max allow subnets exceeded for user '%s' at line %d",
user->username, line_num);
continue;
}
user->allow_subnets[user->allow_count] = subnet;
user->allow_count++;
mosquitto_log_printf(MOSQ_LOG_DEBUG,
"subnet_acl: User '%s' allow subnet %s",
user->username, cidr);
} else { /* deny */
if (user->deny_count >= MAX_SUBNETS_PER_USER) {
mosquitto_log_printf(MOSQ_LOG_WARNING,
"subnet_acl: Max deny subnets exceeded for user '%s' at line %d",
user->username, line_num);
continue;
}
user->deny_subnets[user->deny_count] = subnet;
user->deny_count++;
mosquitto_log_printf(MOSQ_LOG_DEBUG,
"subnet_acl: User '%s' deny subnet %s",
user->username, cidr);
}
}
fclose(fp);
/* Log summary */
for (int i = 0; i < pdata->user_count; i++) {
user_acl_t *user = &pdata->users[i];
if (user->allow_count > 0 || user->deny_count > 0) {
mosquitto_log_printf(MOSQ_LOG_INFO,
"subnet_acl: User '%s' has %d allow and %d deny subnet rules",
user->username, user->allow_count, user->deny_count);
}
}
mosquitto_log_printf(MOSQ_LOG_NOTICE,
"subnet_acl: Loaded subnet restrictions for %d user(s)", pdata->user_count);
return 0;
}
/* Find user ACL entry */
static const user_acl_t* find_user_acl(const plugin_data_t *pdata, const char *username)
{
for (int i = 0; i < pdata->user_count; i++) {
if (strcmp(pdata->users[i].username, username) == 0)
return &pdata->users[i];
}
return NULL;
}
/* ACL check for subnet validation */
static int acl_check_callback(int event, void *event_data, void *userdata)
{
struct mosquitto_evt_acl_check *ed = event_data;
plugin_data_t *pdata = userdata;
const user_acl_t *user_acl;
const char *client_address;
const char *username;
struct in_addr addr;
uint32_t client_ip;
/* Skip if no subnet config loaded */
if (pdata == NULL || pdata->user_count == 0) {
return MOSQ_ERR_PLUGIN_DEFER;
}
/* Get username from client */
username = mosquitto_client_username(ed->client);
/* Skip anonymous users */
if (username == NULL) {
return MOSQ_ERR_PLUGIN_DEFER;
}
/* Find user's subnet ACL */
user_acl = find_user_acl(pdata, username);
/* If user not in config or has no subnet rules, allow */
if (user_acl == NULL || (user_acl->allow_count == 0 && user_acl->deny_count == 0)) {
return MOSQ_ERR_PLUGIN_DEFER;
}
/* Get client IP address */
client_address = mosquitto_client_address(ed->client);
if (client_address == NULL) {
mosquitto_log_printf(MOSQ_LOG_WARNING,
"subnet_acl: Could not get client address for user '%s'", username);
return MOSQ_ERR_PLUGIN_DEFER;
}
/* Skip localhost checks - always allow */
if (strcmp(client_address, "127.0.0.1") == 0 || strcmp(client_address, "::1") == 0) {
return MOSQ_ERR_PLUGIN_DEFER;
}
/* Parse client IP */
if (inet_pton(AF_INET, client_address, &addr) != 1) {
mosquitto_log_printf(MOSQ_LOG_DEBUG,
"subnet_acl: Non-IPv4 address '%s' for user '%s', allowing",
client_address, username);
/* For IPv6 or parse errors, defer to other plugins */
return MOSQ_ERR_PLUGIN_DEFER;
}
client_ip = ntohl(addr.s_addr);
/* Check deny list first - deny takes precedence */
if (user_acl->deny_count > 0) {
if (ip_in_subnet_list(client_ip, user_acl->deny_subnets, user_acl->deny_count)) {
mosquitto_log_printf(MOSQ_LOG_NOTICE,
"subnet_acl: User '%s' from %s DENIED (matches deny rule)",
username, client_address);
return MOSQ_ERR_ACL_DENIED;
}
}
/* If there are allow rules, IP must match one of them */
if (user_acl->allow_count > 0) {
if (ip_in_subnet_list(client_ip, user_acl->allow_subnets, user_acl->allow_count)) {
mosquitto_log_printf(MOSQ_LOG_DEBUG,
"subnet_acl: User '%s' from %s allowed (matches allow rule)",
username, client_address);
return MOSQ_ERR_PLUGIN_DEFER;
} else {
mosquitto_log_printf(MOSQ_LOG_NOTICE,
"subnet_acl: User '%s' from %s DENIED (no matching allow rule)",
username, client_address);
return MOSQ_ERR_ACL_DENIED;
}
}
/* No subnet rules for this user - allow */
return MOSQ_ERR_PLUGIN_DEFER;
}
#ifdef ENABLE_PAM_SUPPORT
static int pam_conversation(int num_msg, const struct pam_message **msg,
struct pam_response **resp, void *appdata_ptr)
{
int i;
const char *pass = (const char *)appdata_ptr;
*resp = calloc(num_msg, sizeof(struct pam_response));
if (*resp == NULL) {
mosquitto_log_printf(MOSQ_LOG_ERR, "pam failed to allocate buffer for validation");
return PAM_BUF_ERR;
}
if (pass == NULL)
return PAM_SUCCESS;
for (i = 0; i < num_msg; ++i) {
if (msg[i]->msg_style == PAM_PROMPT_ECHO_OFF) {
(*resp)[i].resp = strdup(pass);
if ((*resp)[i].resp == NULL) {
for (int j = 0; j < i ; j++)
free((*resp)[j].resp);
free(*resp);
*resp = NULL;
mosquitto_log_printf(MOSQ_LOG_ERR, "pam failed in strdup");
return PAM_BUF_ERR;
}
}
}
return PAM_SUCCESS;
}
static int process_pam_auth_callback(struct mosquitto_evt_basic_auth *ed)
{
struct pam_conv conv;
int retval;
pam_handle_t *pamh = NULL;
conv.conv = pam_conversation;
conv.appdata_ptr = (void *)ed->password;
retval = pam_start("mosquitto", ed->username, &conv, &pamh);
if (retval != PAM_SUCCESS) {
mosquitto_log_printf(MOSQ_LOG_ERR, "pam start failed: %s", pam_strerror(pamh, retval));
return MOSQ_ERR_AUTH;
}
retval = pam_authenticate(pamh, 0);
pam_end(pamh, retval);
if (retval == PAM_SUCCESS) {
mosquitto_log_printf(MOSQ_LOG_NOTICE, "pam user [%s] logged in", ed->username);
return MOSQ_ERR_SUCCESS;
}
mosquitto_log_printf(MOSQ_LOG_NOTICE, "pam user [%s] failed authentication, err [%s]",
ed->username, pam_strerror(pamh, retval));
return MOSQ_ERR_AUTH;
}
#else
static int process_shadow_auth_callback(struct mosquitto_evt_basic_auth *ed)
{
struct spwd spbuf, *sp = NULL;
char buf[256];
struct crypt_data data;
char *hash;
getspnam_r(ed->username, &spbuf, buf, sizeof(buf), &sp);
if (sp == NULL || sp->sp_pwdp == NULL)
return MOSQ_ERR_AUTH;
/* Empty string as hash means password is not required */
if (sp->sp_pwdp[0] == 0)
return MOSQ_ERR_SUCCESS;
if (ed->password == NULL)
return MOSQ_ERR_AUTH;
memset(&data, 0, sizeof(data));
hash = crypt_r(ed->password, sp->sp_pwdp, &data);
if (hash == NULL)
return MOSQ_ERR_AUTH;
if (strcmp(hash, sp->sp_pwdp) == 0)
return MOSQ_ERR_SUCCESS;
return MOSQ_ERR_AUTH;
}
#endif
static int basic_auth_callback(int event, void *event_data, void *userdata)
{
struct mosquitto_evt_basic_auth *ed = event_data;
/* Let other plugins or broker decide about anonymous login */
if (ed->username == NULL)
return MOSQ_ERR_PLUGIN_DEFER;
#ifdef ENABLE_PAM_SUPPORT
return process_pam_auth_callback(ed);
#else
return process_shadow_auth_callback(ed);
#endif
}
int mosquitto_plugin_version(int supported_version_count,
const int *supported_versions)
{
return 5;
}
int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier,
void **user_data,
struct mosquitto_opt *opts, int opt_count)
{
plugin_data_t *pdata;
const char *config_file = NULL;
/* Find subnet config file option */
for (int i = 0; i < opt_count; i++) {
if (strcmp(opts[i].key, "subnet_acl_file") == 0) {
config_file = opts[i].value;
break;
}
}
pdata = calloc(1, sizeof(plugin_data_t));
if (pdata == NULL)
return MOSQ_ERR_NOMEM;
pdata->identifier = identifier;
*user_data = pdata;
/* Load subnet ACL configuration */
if (load_subnet_acl_config(pdata, config_file) != 0) {
free(pdata);
return MOSQ_ERR_UNKNOWN;
}
/* Register both authentication and ACL callbacks */
mosquitto_callback_register(identifier, MOSQ_EVT_BASIC_AUTH,
basic_auth_callback, NULL, pdata);
mosquitto_callback_register(identifier, MOSQ_EVT_ACL_CHECK,
acl_check_callback, NULL, pdata);
mosquitto_log_printf(MOSQ_LOG_INFO,
"subnet_acl: Plugin initialized with %d user(s)", pdata->user_count);
return MOSQ_ERR_SUCCESS;
}
int mosquitto_plugin_cleanup(void *user_data,
struct mosquitto_opt *opts, int opt_count)
{
plugin_data_t *pdata = user_data;
if (pdata) {
mosquitto_callback_unregister(pdata->identifier, MOSQ_EVT_BASIC_AUTH,
basic_auth_callback, NULL);
mosquitto_callback_unregister(pdata->identifier, MOSQ_EVT_ACL_CHECK,
acl_check_callback, NULL);
free(pdata);
}
return MOSQ_ERR_SUCCESS;
}

View File

@@ -13,42 +13,33 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mosquitto-auth-plugin
PKG_VERSION:=1.2.0
PKG_NAME:=mosquitto-auth-shadow
PKG_VERSION:=1.0.1
PKG_MAINTAINER:=Erik Karlsson <erik.karlsson@genexis.eu>
PKG_LICENSE:=EPL-2.0
PKG_BUILD_PARALLEL:=1
PKG_CONFIG_DEPENDS:=CONFIG_MOSQUITTO_AUTH_PAM_SUPPORT
include $(INCLUDE_DIR)/package.mk
define Package/mosquitto-auth-plugin
define Package/mosquitto-auth-shadow
SECTION:=net
CATEGORY:=Network
TITLE:=mosquitto - /etc/shadow authentication plugin
DEPENDS:=+mosquitto-ssl +MOSQUITTO_AUTH_PAM_SUPPORT:libpam
DEPENDS:=+mosquitto-ssl
USERID:=mosquitto=200:mosquitto=200 mosquitto=200:shadow=11
endef
define Package/mosquitto-auth-plugin/description
define Package/mosquitto-auth-shadow/description
Plugin for the mosquitto MQTT message broker that authenticates
users using /etc/shadow
endef
define Package/mosquitto-auth-plugin/config
source "$(SOURCE)/Config.in"
endef
ifeq ($(CONFIG_MOSQUITTO_AUTH_PAM_SUPPORT),y)
TARGET_CFLAGS+=-DENABLE_PAM_SUPPORT
endif
define Package/mosquitto-auth-plugin/install
define Package/mosquitto-auth-shadow/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/mosquitto_auth_shadow.so $(1)/usr/lib/
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,mosquitto-auth-plugin))
$(eval $(call BuildPackage,mosquitto-auth-shadow))

View File

@@ -11,15 +11,15 @@
# Erik Karlsson - initial implementation
#
TARGETS = mosquitto_auth_plugin.so
TARGETS = mosquitto_auth_shadow.so
all: $(TARGETS)
%.pic.o: %.c
$(CC) $(CFLAGS) -Wall -Werror -fPIC -c -o $@ $<
mosquitto_auth_plugin.so: mosquitto_auth_plugin.pic.o
$(CC) $(LDFLAGS) -shared -o $@ $^ $(if $(filter -DENABLE_PAM_SUPPORT,$(CFLAGS)),-lpam)
mosquitto_auth_shadow.so: mosquitto_auth_shadow.pic.o
$(CC) $(LDFLAGS) -shared -o $@ $^
clean:
rm -f *.o $(TARGETS)

View File

@@ -0,0 +1,81 @@
/*
* Copyright (c) 2022 Genexis B.V.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Erik Karlsson - initial implementation
*/
#define _GNU_SOURCE
#include <string.h>
#include <shadow.h>
#include <crypt.h>
#include <mosquitto.h>
#include <mosquitto_broker.h>
#include <mosquitto_plugin.h>
static int basic_auth_callback(int event, void *event_data, void *userdata)
{
struct mosquitto_evt_basic_auth *ed = event_data;
struct spwd spbuf, *sp = NULL;
char buf[256];
struct crypt_data data;
char *hash;
/* Let other plugins or broker decide about anonymous login */
if (ed->username == NULL)
return MOSQ_ERR_PLUGIN_DEFER;
getspnam_r(ed->username, &spbuf, buf, sizeof(buf), &sp);
if (sp == NULL || sp->sp_pwdp == NULL)
return MOSQ_ERR_AUTH;
/* Empty string as hash means password is not required */
if (sp->sp_pwdp[0] == 0)
return MOSQ_ERR_SUCCESS;
if (ed->password == NULL)
return MOSQ_ERR_AUTH;
memset(&data, 0, sizeof(data));
hash = crypt_r(ed->password, sp->sp_pwdp, &data);
if (hash == NULL)
return MOSQ_ERR_AUTH;
if (strcmp(hash, sp->sp_pwdp) == 0)
return MOSQ_ERR_SUCCESS;
return MOSQ_ERR_AUTH;
}
int mosquitto_plugin_version(int supported_version_count,
const int *supported_versions)
{
return 5;
}
int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier,
void **user_data,
struct mosquitto_opt *opts, int opt_count)
{
*user_data = identifier;
return mosquitto_callback_register(identifier, MOSQ_EVT_BASIC_AUTH,
basic_auth_callback, NULL, NULL);
}
int mosquitto_plugin_cleanup(void *user_data,
struct mosquitto_opt *opts, int opt_count)
{
mosquitto_plugin_id_t *identifier = user_data;
return mosquitto_callback_unregister(identifier, MOSQ_EVT_BASIC_AUTH,
basic_auth_callback, NULL);
}

View File

@@ -5,13 +5,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=netmngr
PKG_VERSION:=1.2.0
PKG_VERSION:=1.1.8
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/network/netmngr.git
PKG_SOURCE_VERSION:=ff08a8cc5c860056a022e5376a973dee5a323595
PKG_SOURCE_VERSION:=6310f32b80f8abeccbf99ad55ce88792b19342d6
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif

View File

@@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=netmode
PKG_VERSION:=1.1.7
PKG_VERSION:=1.1.5
PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_LICENSE:=GPL-2.0-only
@@ -18,7 +18,6 @@ include $(TOPDIR)/feeds/iopsys/bbfdm/bbfdm.mk
define Package/netmode
CATEGORY:=Utilities
TITLE:=Network Modes and Utils
DEPENDS:=+dm-service
endef
define Package/netmode/description

View File

@@ -58,7 +58,7 @@
"name": "mode"
}
},
"linker_obj": "Device.{BBF_VENDOR_PREFIX}NetMode.SupportedModes.*.Name"
"linker_obj": "Device.{BBF_VENDOR_PREFIX}NetMode.SupportedModes.[Name==@key]."
}
]
},

View File

@@ -1,2 +1,2 @@
config netmode global
option enabled 1
option enabled 0

View File

@@ -17,8 +17,6 @@ l3_mcast_config() {
l3_network_config() {
logger -s -p user.info -t "netmode" "Generating L3 network configuration"
wandev="$(uci -q get network.WAN.ifname)"
# Configure L3 Network Mode
uci -q set network.lan=interface
uci -q set network.lan.device='br-lan'
@@ -38,35 +36,11 @@ l3_network_config() {
uci -q delete network.wan.disabled
uci -q delete network.wan.username
uci -q delete network.wan.password
uci -q delete network.wan.ipaddr
uci -q delete network.wan.gateway
uci -q delete network.wan.netmask
uci -q set network.wan6=interface
uci -q set network.wan6.proto='dhcpv6'
uci -q delete network.wan6.disabled
if [ -n "$wandev" ] && echo "$NETMODE_vlanid" | grep -Eq '^[0-9]+$' && [ "$NETMODE_vlanid" -ge 1 ]; then
uci -q set network.vlan_${NETMODE_vlanid}=device
uci -q set network.vlan_${NETMODE_vlanid}.type="8021q"
uci -q set network.vlan_${NETMODE_vlanid}.name="$wandev.$NETMODE_vlanid"
uci -q set network.vlan_${NETMODE_vlanid}.ifname="$wandev"
uci -q set network.vlan_${NETMODE_vlanid}.vid=$NETMODE_vlanid
wandev="$wandev.$NETMODE_vlanid"
fi
uci -q set network.wan.device="$wandev"
uci -q set network.wan6.device="$wandev"
uci -q delete network.wan.dns
if [ -n "$NETMODE_dns_servers" ]; then
dns_servers="$(echo $NETMODE_dns_servers | tr ',' ' ')"
for server in $dns_servers; do
uci -q add_list network.wan.dns=$server
done
fi
uci -q delete network.br_lan.ports
uci -q set network.br_lan.bridge_empty='1'
@@ -87,6 +61,12 @@ l3_network_config() {
[ -n "$device" ] && uci add_list network.br_lan.ports="$device"
fi
json_select ..
json_select wan 2>/dev/null
json_get_var device device
if [ -n "$device" ]; then
uci -q set network.wan.device="$device"
uci -q set network.wan6.device="$device"
fi
json_cleanup
fi

View File

@@ -17,8 +17,6 @@ l3_mcast_config() {
l3_network_pppoe_config() {
logger -s -p user.info -t "netmode" "Generating L3 network configuration"
wandev="$(uci -q get network.WAN.ifname)"
# Configure L3 Network Mode
uci -q set network.lan=interface
uci -q set network.lan.device='br-lan'
@@ -38,33 +36,9 @@ l3_network_pppoe_config() {
uci -q set network.wan.username="$NETMODE_username"
uci -q set network.wan.password="$NETMODE_password"
uci -q delete network.wan.disabled
uci -q delete network.wan.ipaddr
uci -q delete network.wan.gateway
uci -q delete network.wan.netmask
uci -q set network.wan6.disabled='1'
if [ -n "$wandev" ] && echo "$NETMODE_vlanid" | grep -Eq '^[0-9]+$' && [ "$NETMODE_vlanid" -ge 1 ]; then
uci -q set network.vlan_${NETMODE_vlanid}=device
uci -q set network.vlan_${NETMODE_vlanid}.type="8021q"
uci -q set network.vlan_${NETMODE_vlanid}.name="$wandev.$NETMODE_vlanid"
uci -q set network.vlan_${NETMODE_vlanid}.ifname="$wandev"
uci -q set network.vlan_${NETMODE_vlanid}.vid=$NETMODE_vlanid
wandev="$wandev.$NETMODE_vlanid"
fi
uci -q set network.wan.device="$wandev"
uci -q set network.wan6.device="$wandev"
uci -q delete network.wan.dns
if [ -n "$NETMODE_dns_servers" ]; then
dns_servers="$(echo $NETMODE_dns_servers | tr ',' ' ')"
for server in $dns_servers; do
uci -q add_list network.wan.dns=$server
done
fi
uci -q delete network.br_lan.ports
uci -q set network.br_lan.bridge_empty='1'
@@ -85,6 +59,12 @@ l3_network_pppoe_config() {
[ -n "$device" ] && uci add_list network.br_lan.ports="$device"
fi
json_select ..
json_select wan 2>/dev/null
json_get_var device device
if [ -n "$device" ]; then
uci -q set network.wan.device="$device"
uci -q set network.wan6.device="$device"
fi
json_cleanup
fi

View File

@@ -1,127 +0,0 @@
#!/bin/sh
. /lib/functions.sh
. /usr/share/libubox/jshn.sh
source "/etc/device_info"
l3_mcast_config() {
# configure L3 mcast config
logger -s -p user.info -t "netmode" "Generating L3 mcast configuration"
rm -f /etc/config/mcast
sh /rom/etc/uci-defaults/61-mcast_config_generate
uci -q commit mcast
}
l3_network_config() {
logger -s -p user.info -t "netmode" "Generating L3 network configuration"
wandev="$(uci -q get network.WAN.ifname)"
# Configure L3 Network Mode
uci -q set network.lan=interface
uci -q set network.lan.device='br-lan'
uci -q set network.lan.proto='static'
uci -q set network.lan.ipaddr='192.168.1.1'
uci -q set network.lan.netmask='255.255.255.0'
uci -q set network.lan.ip6assign='60'
uci -q delete network.lan.vendorid
uci -q delete network.lan.clientid
uci -q delete network.lan.reqopts
uci -q delete network.lan.sendopts
uci -q delete network.lan6
uci -q set network.wan=interface
uci -q set network.wan.device="$wandev"
uci -q set network.wan.proto='static'
uci -q set network.wan.ipaddr="$NETMODE_ipaddr"
uci -q set network.wan.gateway="$NETMODE_gateway"
uci -q set network.wan.netmask="$NETMODE_netmask"
uci -q delete network.wan.disabled
uci -q delete network.wan.username
uci -q delete network.wan.password
uci -q set network.wan6.disabled='1'
if [ -n "$wandev" ] && echo "$NETMODE_vlanid" | grep -Eq '^[0-9]+$' && [ "$NETMODE_vlanid" -ge 1 ]; then
uci -q set network.vlan_${NETMODE_vlanid}=device
uci -q set network.vlan_${NETMODE_vlanid}.type="8021q"
uci -q set network.vlan_${NETMODE_vlanid}.name="$wandev.$NETMODE_vlanid"
uci -q set network.vlan_${NETMODE_vlanid}.ifname="$wandev"
uci -q set network.vlan_${NETMODE_vlanid}.vid=$NETMODE_vlanid
wandev="$wandev.$NETMODE_vlanid"
fi
uci -q set network.wan.device="$wandev"
uci -q set network.wan6.device="$wandev"
uci -q delete network.wan.dns
if [ -n "$NETMODE_dns_servers" ]; then
dns_servers="$(echo $NETMODE_dns_servers | tr ',' ' ')"
for server in $dns_servers; do
uci -q add_list network.wan.dns=$server
done
fi
uci -q delete network.br_lan.ports
uci -q set network.br_lan.bridge_empty='1'
add_port_to_br_lan() {
port="$1"
[ -n "$port" -a -d /sys/class/net/$port ] || continue
uci add_list network.br_lan.ports="$port"
}
if [ -f /etc/board.json ]; then
json_load_file /etc/board.json
json_select network
json_select lan
if json_is_a ports array; then
json_for_each_item add_port_to_br_lan ports
else
json_get_var device device
[ -n "$device" ] && uci add_list network.br_lan.ports="$device"
fi
json_select ..
json_cleanup
fi
uci -q commit network
# Enable DHCP Server
uci -q set dhcp.lan.ignore=0
uci -q set dhcp.wan.ignore=1
uci -q commit dhcp
/etc/init.d/odhcpd enable
# Enable SSDPD
uci -q set ssdpd.ssdp.enabled="1"
uci -q commit ssdpd
# Update CWMP Agent WAN Interface
uci -q set cwmp.cpe.default_wan_interface="wan"
uci -q commit cwmp
# Update gateway WAN Interface
uci -q set gateway.global.wan_interface="wan"
uci -q commit gateway
# Enable firewall
uci -q set firewall.globals.enabled="1"
uci -q commit firewall
}
l3_network_config
l3_mcast_config
# If device is already boot-up, assume netmode changed during runtime
if [ -f /var/run/boot_complete ]; then
/etc/init.d/odhcpd restart 2>/dev/null
for config in network dhcp ssdpd cwmp gateway firewall mcast; do
ubus call uci commit "{\"config\":\"$config\"}"
sleep 1
done
fi

View File

@@ -3,90 +3,25 @@
"supported_modes": [
{
"name": "routed-dhcp",
"description": "DHCP",
"supported_args": [
{
"name": "vlanid",
"description": "VLAN ID",
"required": false,
"type": "integer"
},
{
"name": "dns_servers",
"description": "DNS Servers",
"required": false,
"type": "string"
}
]
"description": "WAN with DHCP proto (Layer 3)"
},
{
"name": "routed-pppoe",
"description": "PPPoE",
"description": "WAN with PPPoE (Layer 3)",
"supported_args": [
{
"name": "username",
"description": "PPPoE Username",
"description": "PPPoE username",
"required": true,
"type": "string",
"type": "string",
"#value": "TestUser"
},
{
"name": "password",
"description": "PPPoE Password",
"description": "PPPoE password",
"required": true,
"type": "string",
"type": "string",
"#value": "TestPassword"
},
{
"name": "vlanid",
"description": "VLAN ID",
"required": false,
"type": "integer"
},
{
"name": "dns_servers",
"description": "DNS Servers",
"required": false,
"type": "string"
}
]
},
{
"name": "routed-static",
"description": "Static",
"supported_args": [
{
"name": "ipaddr",
"description": "IP Address",
"required": true,
"type": "string",
"#value": "93.21.0.104"
},
{
"name": "netmask",
"description": "Subnet Mask",
"required": true,
"type": "string",
"#value": "255.255.255.0"
},
{
"name": "gateway",
"description": "Default Gateway",
"required": true,
"type": "string",
"#value": "93.21.0.1"
},
{
"name": "vlanid",
"description": "VLAN ID",
"required": false,
"type": "integer"
},
{
"name": "dns_servers",
"description": "DNS Servers",
"required": false,
"type": "string"
}
]
}

View File

@@ -1,29 +0,0 @@
#!/bin/sh
enabled="$(uci -q get netmode.global.enabled)"
[ "$enabled" == "1" ] || exit 0
mode="$(uci -q get netmode.global.mode)"
[ -n "$mode" ] && exit 0
[ -f /etc/netmodes/supported_modes.json ] || exit 0
# NetMode is enabled without a Mode being set
# Figure out the current mode from network config
wanproto=$(uci -q get network.wan.proto)
curmode=""
case "$wanproto" in
dhcp) curmode="routed-dhcp" ;;
pppoe) curmode="routed-pppoe" ;;
static) curmode="routed-static" ;;
esac
found=0
for md in $(jsonfilter -i /etc/netmodes/supported_modes.json -e "@.supported_modes.*.name"); do
[ "$md" == "$curmode" ] && found=1
done
if [ $found -eq 1 ]; then
uci -q set netmode.global.mode="$curmode"
echo "$curmode" > /etc/netmodes/.last_mode
fi

View File

@@ -19,3 +19,7 @@ fi
if [ -x "/etc/init.d/bbfdmd" ]; then
/etc/init.d/bbfdmd restart
fi
if [ -x "/etc/init.d/obuspa" ]; then
/etc/init.d/obuspa restart
fi

View File

@@ -19,8 +19,13 @@ config OBUSPA_CONTROLLER_MTP_VERIFY
bool "Enable verification of controller MTP before processing the message"
default n
config OBUSPA_LOCAL_MQTT_LISTENER
bool "Configures local mqtt broker for local usp connections"
config OBUSPA_ENABLE_TEST_CONTROLLER
bool "Adds a test controller by default"
default n
select OBUSPA_ENABLE_TEST_CONTROLLER_LOCAL
config OBUSPA_ENABLE_TEST_CONTROLLER_LOCAL
bool "Adds a test controller by default (local access only)"
default n
config OBUSPA_MAX_CONTROLLERS_NUM

View File

@@ -5,13 +5,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=obuspa
PKG_VERSION:=10.0.7.5
PKG_VERSION:=10.0.4.1
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/obuspa.git
PKG_SOURCE_VERSION:=f3b5b79476adadc55830de9466361c0eeced473e
PKG_SOURCE_VERSION:=6b888812299de0d836a8dcf33bc899ec8ff16030
PKG_MAINTAINER:=Vivek Dutta <vivek.dutta@iopsys.eu>
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
@@ -32,9 +32,9 @@ define Package/obuspa
SUBMENU:=TRx69
TITLE:=USP agent
MENU:=1
DEPENDS:=+libopenssl +libcurl +libsqlite3 +libmosquitto-ssl +libwebsockets-openssl
DEPENDS+=+libjson-c +libubox +libubus +libuci +libblobmsg-json
DEPENDS+=+ca-certificates +OBUSPA_LOCAL_MQTT_LISTENER:mosquitto-ssl
DEPENDS:=+libopenssl +libuci +libblobmsg-json +libcurl +libsqlite3 +libubox +libubus +libmosquitto-ssl +libwebsockets-openssl +ca-certificates \
+OBUSPA_ENABLE_TEST_CONTROLLER_LOCAL:mosquitto-ssl +OBUSPA_ENABLE_TEST_CONTROLLER_LOCAL:mosquitto-client-ssl \
+OBUSPA_ENABLE_TEST_CONTROLLER:mosquitto-auth-shadow +libjson-c
DEPENDS+=+libbbfdm-api +libbbfdm-ubus +dm-service
endef
@@ -132,23 +132,27 @@ define Package/obuspa/install
$(INSTALL_DATA) ./files/etc/users/roles/*.json $(1)/etc/users/roles/
$(INSTALL_DATA) ./files/etc/obuspa/usp_utils.sh $(1)/etc/obuspa/
echo "$(VENDOR_PREFIX)" > $(1)/etc/obuspa/vendor_prefix
$(INSTALL_DATA) ./files/etc/uci-defaults/01-fix-upgrade-uci $(1)/etc/uci-defaults/
$(INSTALL_DATA) ./files/etc/uci-defaults/60-generate-ctrust-defaults $(1)/etc/uci-defaults/
$(INSTALL_DATA) ./files/etc/uci-defaults/obuspa-set-dhcp-option $(1)/etc/uci-defaults/
$(INSTALL_DATA) ./files/etc/uci-defaults/92-obuspa_firewall $(1)/etc/uci-defaults/
$(INSTALL_DATA) ./files/etc/uci-defaults/93-obuspa_mdns_adv $(1)/etc/uci-defaults/
$(INSTALL_DATA) ./files/etc/uci-defaults/94-obuspa_set_credential $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./files/etc/uci-defaults/01-fix-upgrade-uci $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./files/etc/uci-defaults/60-generate-ctrust-defaults $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./files/etc/uci-defaults/obuspa-set-dhcp-option $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./files/etc/uci-defaults/92-obuspa_firewall $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./files/etc/uci-defaults/93-obuspa_mdns_adv $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./files/etc/uci-defaults/94-obuspa_set_credential $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./files/etc/firewall.usp $(1)/etc/
$(INSTALL_BIN) ./files/etc/udhcpc.user.d/udhcpc_obuspa_opt125.user $(1)/etc/udhcpc.user.d/
$(INSTALL_BIN) ./files/etc/udhcpc.user.d/udhcpc_obuspa_opt125.user $(1)/etc/udhcpc.user.d/udhcpc_obuspa_opt125.user
ifeq ($(CONFIG_OBUSPA_CWMP_DATAMODEL_SUPPORT),y)
$(BBFDM_REGISTER_SERVICES) ./bbfdm_service.json $(1) $(PKG_NAME)
$(BBFDM_INSTALL_MS_DM) $(PKG_BUILD_DIR)/libuspagentdm.so $(1) $(PKG_NAME)
endif
ifeq ($(CONFIG_OBUSPA_LOCAL_MQTT_LISTENER),y)
$(INSTALL_DATA) ./files/etc/uci-defaults/55-obuspa-local-mqtt-usp-connection $(1)/etc/uci-defaults/
ifeq ($(CONFIG_OBUSPA_ENABLE_TEST_CONTROLLER),y)
$(INSTALL_BIN) ./files/etc/uci-defaults/54-test-usp-remote $(1)/etc/uci-defaults/
endif
ifeq ($(CONFIG_OBUSPA_ENABLE_TEST_CONTROLLER_LOCAL),y)
$(INSTALL_BIN) ./files/etc/init.d/usptest $(1)/etc/init.d/
$(INSTALL_BIN) ./files/etc/uci-defaults/55-test-usp-controller $(1)/etc/uci-defaults/
endif
ifeq ($(CONFIG_OBUSPA_OVERRIDE_CT_ROLE),y)
$(INSTALL_DATA) ./files/etc/uci-defaults/61-override-ct-roles $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./files/etc/uci-defaults/61-override-ct-roles $(1)/etc/uci-defaults/
endif
endef

View File

@@ -6,18 +6,19 @@ USE_PROCD=1
PROG=/usr/sbin/obuspa
CONFIGURATION=obuspa
ENV_PROFILE="/root/.profile"
KEEP_FILE="/lib/upgrade/keep.d/obuspa"
RESET_FILE="/tmp/obuspa/fw_defaults"
OBUSPA_BOOT_MARKER="/etc/obuspa/.boot"
SQL_DB_FILE="/tmp/obuspa/usp.db"
DB_DUMP="/tmp/obuspa/usp.dump_$(date +%s)"
BASEPATH=""
INSTANCE_COUNT=0
CLIENT_ID_PREFIX=""
. /lib/functions/network.sh
. /usr/share/libubox/jshn.sh
. /etc/obuspa/usp_utils.sh
global_init()
@@ -29,7 +30,6 @@ global_init()
log()
{
echo "$*"|logger -t obuspa.init -p debug
echo "$*" >/dev/console
}
db_set_reset_file()
@@ -47,9 +47,37 @@ db_set_reset_file()
fi
}
db_set_sql()
{
local param value
param="${1}"
shift
value="$*"
if [ -n "${param}" ] && [ -n "${value}" ]; then
if grep -q "${param} " ${DB_DUMP}; then
value="${value//\//\\/}"
sed -i "s/${param} .*/${param} \"${value}\"/g" ${DB_DUMP}
else
echo "${param} \"${value}\"" >> ${DB_DUMP}
fi
fi
}
db_set()
{
db_set_reset_file "$@"
# if sql db dump file present, update it
if [ -f "${DB_DUMP}" ]; then
db_set_sql "$@"
else
db_set_reset_file "$@"
fi
}
dump_db()
{
${PROG} -v0 -f ${SQL_DB_FILE} -c show database |grep "^Internal.\|^Device."|sed '{s/=> /"/g;s/$/"/g}' | sort > ${DB_DUMP}
}
# if db present then check if it matches with existing instances
@@ -64,6 +92,21 @@ get_base_path()
path=""
count=0
if [ -f "${DB_DUMP}" ]; then
path=$(grep -E "${refpath}\d+.Alias \"${value}\"" ${DB_DUMP})
path=${path%.*}
if [ -z "${path}" ]; then
path=$(grep -oE "${refpath}\d+" ${DB_DUMP} |sort -r|head -n 1)
if [ -n "${path}" ]; then
count=${path##*.}
count=$(( count + 1 ))
else
count=1
fi
path="${refpath}${count}"
fi
fi
if [ -z "${path}" ]; then
INSTANCE_COUNT=$(( INSTANCE_COUNT + 1 ))
path="${refpath}${INSTANCE_COUNT}"
@@ -79,7 +122,9 @@ get_refrence_path()
value="${2}"
path=""
if [ -f "${RESET_FILE}" ]; then
if [ -f "${DB_DUMP}" ]; then
path=$(grep -E "${dmref}\d+.Alias " ${DB_DUMP}|grep -w "${value}")
elif [ -f "${RESET_FILE}" ]; then
path=$(grep -E "${dmref}\d+.Alias " ${RESET_FILE}|grep -w "${value}")
fi
path=${path%.*}
@@ -91,7 +136,7 @@ update_keep()
file=${1}
if [ -z "${file}" ]; then
return 0
return;
fi
if [ ! -f "${KEEP_FILE}" ]; then
@@ -218,7 +263,7 @@ configure_localagent()
validate_localagent_section "${1}" || {
log "Validation of localagent section failed"
return 0
return 0;
}
db_set Device.LocalAgent.EndpointID "${EndpointID}"
@@ -226,7 +271,7 @@ configure_localagent()
update_reset_reason()
{
[ -f "/tmp/reset_reason" ] || return 0
[ -f "/tmp/reset_reason" ] || return 0;
if grep -qwi "defaultreset" /tmp/reset_reason; then
db_set Internal.Reboot.Cause "FactoryReset"
@@ -265,6 +310,10 @@ get_role_index()
val="$(grep "Device.LocalAgent.ControllerTrust.Role.\d.Name" ${CTRUST_RESET_FILE} |grep $name)"
val="$(echo ${val/.Name /,}|cut -d, -f 1)"
echo "$val"
elif [ -f "${DB_DUMP}" ]; then
val="$(grep "Device.LocalAgent.ControllerTrust.Role.\d.Name" ${DB_DUMP} |grep $name)"
val="$(echo ${val/.Name /,}|cut -d, -f 1)"
echo "$val"
else
log "Not able to get role ${name}, use Untrusted role"
echo "${drole}"
@@ -282,19 +331,19 @@ configure_controller()
sec="${1}"
validate_controller_section "${1}" || {
log "Validation of controller section failed"
return 1
return 1;
}
sec="${sec/controller_/cpe-}"
get_base_path "Device.LocalAgent.Controller." "${sec}"
if [ -z "${BASEPATH}" ]; then
log "Failed to get path [$BASEPATH]"
return 1
return 1;
fi
if [ -z "${Protocol}" ]; then
log "controller:: Protocol cannot be empty"
return 1
return 1;
fi
dm_ref=""
@@ -390,14 +439,14 @@ configure_subscription()
sec="${1}"
validate_subscription_section "${1}" || {
log "Validation of subscription section failed"
return 1
return 1;
}
sec="${sec/sub_/cpe-}"
get_base_path "Device.LocalAgent.Subscription." "sub_${1}"
if [ -z "${BASEPATH}" ]; then
log "Failed to get path [$BASEPATH]"
return 1
return 1;
fi
if [ -n "${controller}" ]; then
@@ -434,12 +483,12 @@ configure_challenges()
get_base_path "Device.LocalAgent.ControllerTrust.Challenge." "${sec}"
if [ -z "${BASEPATH}" ]; then
log "Failed to get path [$BASEPATH]"
return 1
return 1;
fi
if [ -z "${role_name}" ] && [ -z "${Role}" ]; then
log "Either role_name or Role must defined for a challenge"
return 1
log "Either role_name or Role must defined for a challenge";
return 1;
fi
db_set "${BASEPATH}.Alias" "${sec}"
@@ -466,18 +515,18 @@ configure_mtp() {
sec="${1}"
validate_mtp_section "${1}" || {
log "Validation of mtp section failed"
return 1
return 1;
}
sec="${sec/mtp_/cpe-}"
get_base_path "Device.LocalAgent.MTP." "${sec}"
if [ -z "${BASEPATH}" ]; then
log "Failed to get path [$BASEPATH]"
return 1
return 1;
fi
if [ -z "${Protocol}" ]; then
log "Protocol not defined for the mtp[${1}] section"
return 1
return 1;
fi
dm_ref=""
@@ -535,14 +584,14 @@ configure_stomp_connection() {
sec="${1}"
validate_stomp_connection_section "${1}" || {
log "Validation of stomp section failed"
return 1
return 1;
}
sec="${sec/stomp_/cpe-}"
get_base_path "Device.STOMP.Connection." "${sec}"
if [ -z "${BASEPATH}" ]; then
log "Failed to get path [$BASEPATH]"
return 1
return 1;
fi
db_set "${BASEPATH}.Alias" "${sec}"
@@ -565,18 +614,14 @@ configure_mqtt_client() {
sec="${1}"
validate_mqtt_client_section "${1}" || {
log "Validation of mqtt section failed"
return 1
return 1;
}
sec="${sec/mqtt_/cpe-}"
get_base_path "Device.MQTT.Client." "${sec}"
if [ -z "${BASEPATH}" ]; then
log "Failed to get path [$BASEPATH]"
return 1
fi
if [ -z "${ClientID}" ]; then
ClientID="${CLIENT_ID_PREFIX}-${sec}"
return 1;
fi
db_set "${BASEPATH}.Alias" "${sec}"
@@ -603,9 +648,6 @@ configure_obuspa() {
fi
if [ -n "${log_level}" ]; then
if [ "${log_level}" -gt "4" ]; then
log_level="4"
fi
procd_append_param command -v "${log_level}"
fi
@@ -634,13 +676,13 @@ configure_obuspa() {
if [ -n "${db_file}" ]; then
update_keep "${db_file}"
procd_append_param command -f "${db_file}"
if [ -f "${db_file}-journal" ]; then
log "SQL Journal detected ..."
fi
procd_append_param command -f "${SQL_DB_FILE}"
fi
if [ -f "${RESET_FILE}" ]; then
if [ -f "${SQL_DB_FILE}" ]; then
mv ${SQL_DB_FILE} ${SQL_DB_FILE}.old
fi
procd_append_param command -r ${RESET_FILE}
fi
@@ -659,34 +701,301 @@ configure_obuspa() {
fi
}
# Create factory reset file
db_init()
get_instances_from_db_dump()
{
local reason
local obj inst
reason="${1}"
# remove usp.db, in case of reload
if [ -f "${OBUSPA_BOOT_MARKER}" ] && [ "${reason}" = "update" ]; then
log "Deleting ${OBUSPA_BOOT_MARKER} in order to enforce values from UCI..."
rm -f "${OBUSPA_BOOT_MARKER}"
obj="${1}\d+"
if [ ! -f "${DB_DUMP}" ]; then
echo ""
return 0;
fi
if [ -f "${OBUSPA_BOOT_MARKER}" ]; then
inst="$(grep -oE "${obj}" "${DB_DUMP}"|uniq)"
echo "$inst"
}
get_param_value_from_dump()
{
local param value
param="${1}"
if [ -z "${param}" ] || [ ! -f "${DB_DUMP}" ]; then
log "error getting param"
echo ""
return 0
fi
# Remove reset file if present
[ -f "${RESET_FILE}" ] && rm ${RESET_FILE}
value="$(grep "^${param} " ${DB_DUMP}|awk '{print $2}')"
CLIENT_ID_PREFIX="$(db -q get device.deviceinfo.ManufacturerOUI)"
CLIENT_ID_PREFIX="${CLIENT_ID_PREFIX}-$(db -q get device.deviceinfo.SerialNumber)"
CLIENT_ID_PREFIX="${CLIENT_ID_PREFIX//+/%2b}"
echo "${value//\"/}"
}
update_uci_sec()
{
local sec tmp
sec="${1}"
stype="${2}"
if [ -z "$sec" ] || [ -z "$stype" ]; then
log "No section name, error"
return 0
fi
tmp="$(uci_get obuspa "${sec}")"
if [ "$tmp" != "$stype" ]; then
uci_add obuspa "${stype}" "${sec}"
fi
}
sync_db_controller()
{
local cntrs copts sec pvalue protocol
copts="Enable EndpointID PeriodicNotifInterval"
popts="Destination Topic Host Port Path EnableEncryption"
cntrs="$(get_instances_from_db_dump Device.LocalAgent.Controller.)"
for cntr in $cntrs; do
sec="$(get_param_value_from_dump "${cntr}".Alias)"
sec="${sec/cpe-/controller_}"
sec="${sec/-/_}"
update_uci_sec "${sec}" controller
for param in ${copts}; do
pvalue="$(get_param_value_from_dump "${cntr}"."${param}")"
uci_set obuspa "${sec}" "${param}" "${pvalue}"
done
uci_set obuspa "${sec}" "_sync" "1"
protocol="$(get_param_value_from_dump "${cntr}".MTP.1.Protocol)"
if [ -z "${protocol}" ]; then
break;
fi
uci_set obuspa "${sec}" "Protocol" "${protocol}"
for param in ${popts}; do
pvalue="$(get_param_value_from_dump "${cntr}".MTP.1."${protocol}"."${param}")"
uci_set obuspa "${sec}" "${param}" "${pvalue}"
done
done
}
sync_db_localagent_mtp()
{
local mtps opts popts sec pvalue protocol
opts="Enable"
popts="ResponseTopicConfigured Destination Port Path EnableEncryption PublishQoS"
mtps="$(get_instances_from_db_dump Device.LocalAgent.MTP.)"
for inst in $mtps; do
sec="$(get_param_value_from_dump "${inst}".Alias)"
sec="${sec/cpe-/mtp_}"
sec="${sec/-/_}"
update_uci_sec "${sec}" mtp
for param in ${opts}; do
pvalue="$(get_param_value_from_dump "${inst}"."${param}")"
uci_set obuspa "${sec}" "${param}" "${pvalue}"
done
uci_set obuspa "${sec}" "_sync" "1"
protocol="$(get_param_value_from_dump "${inst}".Protocol)"
if [ -z "${protocol}" ]; then
break;
fi
uci_set obuspa "${sec}" "Protocol" "${protocol}"
for param in ${popts}; do
pvalue="$(get_param_value_from_dump "${inst}"."${protocol}"."${param}")"
uci_set obuspa "${sec}" "${param}" "${pvalue}"
done
done
}
sync_db_mqtt_client()
{
local mtps copts sec pvalue protocol
opts="Enable BrokerAddress BrokerPort Username ProtocolVersion TransportProtocol ClientID"
mtps="$(get_instances_from_db_dump Device.MQTT.Client.)"
for inst in $mtps; do
sec="$(get_param_value_from_dump "${inst}".Alias)"
sec="${sec/cpe-/mqtt_}"
sec="${sec/-/_}"
update_uci_sec "${sec}" mqtt
for param in ${opts}; do
pvalue="$(get_param_value_from_dump "${inst}"."${param}")"
uci_set obuspa "${sec}" "${param}" "${pvalue}"
done
uci_set obuspa "${sec}" "_sync" "1"
done
}
sync_db_stomp_connection()
{
local mtps copts sec pvalue protocol
opts="Enable Host Port Username EnableEncryption EnableHeartbeats VirtualHost"
mtps="$(get_instances_from_db_dump Device.STOMP.Connection.)"
for inst in $mtps; do
sec="$(get_param_value_from_dump "${inst}".Alias)"
sec="${sec/cpe-/stomp_}"
sec="${sec/-/_}"
update_uci_sec "${sec}" stomp
for param in ${opts}; do
pvalue="$(get_param_value_from_dump "${inst}"."${param}")"
uci_set obuspa "${sec}" "${param}" "${pvalue}"
done
uci_set obuspa "${sec}" "_sync" "1"
done
}
sync_update_sec()
{
local _sync
config_get _sync "${1}" _sync ""
if [ -z "${_sync}" ]; then
uci_remove obuspa "${1}"
log "Deleting obuspa.${1} section ..."
else
uci_remove obuspa "${1}" _sync
fi
}
sync_uci_with_db()
{
if [ ! -f "${DB_DUMP}" ]; then
return 0;
fi
config_load obuspa
sync_db_controller
sync_db_localagent_mtp
sync_db_mqtt_client
sync_db_stomp_connection
uci_commit obuspa
config_load obuspa
config_foreach sync_update_sec controller
config_foreach sync_update_sec mtp
config_foreach sync_update_sec mqtt
config_foreach sync_update_sec stomp
uci_commit obuspa
}
delete_sql_db_entry_with_pattern()
{
local params pattern
pattern="${1}"
if [ ! -f "${DB_DUMP}" ]; then
return 0;
fi
if [ "${#pattern}" -lt 7 ]; then
return 0;
fi
#log "Deleting with pattern [${pattern}] from ${DB_DUMP}"
sed -i "/${pattern}/d" ${DB_DUMP}
}
check_n_delete_db()
{
local sec t r path
sec="${1}"
if uci -q get obuspa."${sec}" >/dev/null 2>&1; then
return 0
fi
t="${2}"
r="${3}"
sec="${sec/${t}_/cpe-}"
path=$(grep -E "${r}\d+.Alias \"${sec}\"" ${DB_DUMP})
path=${path%.*}
delete_sql_db_entry_with_pattern "${path}"
}
workaround_remove_download_pattern()
{
local inst
inst="$(cat ${DB_DUMP} |grep -E "Device.DeviceInfo.FirmwareImage.\d.Download()"|grep -oE "Device.LocalAgent.Request.\d.")"
if [ -n "${inst}" ]; then
log "Workaround to remove the old download Request [$inst]"
delete_sql_db_entry_with_pattern "${inst}"
fi
}
reverse_update_db_with_uci()
{
if [ ! -f "${DB_DUMP}" ]; then
return 0;
fi
export UCI_CONFIG_DIR="/tmp/obuspa"
config_load obuspa
config_foreach check_n_delete_db controller controller "Device.LocalAgent.Controller."
config_foreach check_n_delete_db mtp mtp "Device.LocalAgent.MTP."
config_foreach check_n_delete_db mqtt mqtt "Device.MQTT.Client."
config_foreach check_n_delete_db stomp stomp "Device.STOMP.Connection."
unset UCI_CONFIG_DIR
}
# Create factory reset file
db_init()
{
local reason role_file
reason="${1}"
mkdir -p /tmp/obuspa/
# Load configuration
config_load $CONFIGURATION
config_get SQL_DB_FILE global db_file "/tmp/obuspa/usp.db"
config_get role_file global role_file ""
if [ -f "${SQL_DB_FILE}.old" ] && [ ! -f "${SQL_DB_FILE}" ]; then
log "Copying old db, since new db not present ..."
mv ${SQL_DB_FILE}.old ${SQL_DB_FILE}
fi
# Dump datamodel parameters from DB
if [ -f "${SQL_DB_FILE}" ]; then
dump_db
fi
# In case of Reboot or service restart update the uci
# from usp.db file
if [ -f "${DB_DUMP}" ] && [ "${reason}" != "update" ]; then
# Only do this if db have reasonable data
val="$(awk 'END{print NR}' ${DB_DUMP})"
if [ "$val" -gt 15 ]; then
log "Syncing obuspa uci with usp.db ...."
sync_uci_with_db
fi
fi
# remove entries from db if deleted from uci, only in case of reload
if [ -f "${DB_DUMP}" ] && [ "${reason}" = "update" ] && [ -f "/tmp/obuspa/obuspa" ]; then
log "Deleting entries from usp.db if uci not present ...."
reverse_update_db_with_uci
fi
# Remove reset file if present
[ -f "${RESET_FILE}" ] && mv ${RESET_FILE} ${RESET_FILE}.old
#log "Create reset file ...."
config_load $CONFIGURATION
config_get dualstack_pref global dualstack_pref "IPv6"
log "Enforcing UCI values, no boot marker found."
global_init
config_foreach configure_localagent localagent
global_init
@@ -702,12 +1011,21 @@ db_init()
global_init
config_foreach configure_challenges challenge
# enforce ctrust only on upgrades, not on reloads
if [ -f "${CTRUST_RESET_FILE}" ] && [ -z "${reason}" ]; then
cat ${CTRUST_RESET_FILE} >> ${RESET_FILE}
fi
update_reset_reason
update_dual_stack_pref "${dualstack_pref}"
uci_commit ${CONFIGURATION}
cp /etc/config/obuspa /tmp/obuspa/
if [ -f "${DB_DUMP}" ]; then
workaround_remove_download_pattern
mv ${DB_DUMP} ${RESET_FILE}
fi
if [ -f "${CTRUST_RESET_FILE}" ]; then
cat ${CTRUST_RESET_FILE} >> ${RESET_FILE}
rm ${CTRUST_RESET_FILE}
fi
}
start_service() {
@@ -719,18 +1037,21 @@ start_service() {
procd_open_instance ${CONFIGURATION}
if [ "${enabled}" -eq 1 ]; then
procd_set_param command ${PROG}
db_init "${1}"
procd_set_param command ${PROG}
configure_obuspa
procd_set_param respawn \
"${respawn_threshold:-10}" \
"${respawn_timeout:-10}" "${respawn_retry:-5}"
#procd_set_param limits core="unlimited"
fi
procd_close_instance ${CONFIGURATION}
}
stop_service() {
${PROG} -c stop
if command -v timeout >/dev/null 2>&1; then
timeout 5 ${PROG} -c stop
fi
}
reload_service() {
@@ -739,6 +1060,5 @@ reload_service() {
}
service_triggers() {
export PROCD_RELOAD_DELAY=3000
procd_add_reload_trigger "obuspa"
}

75
obuspa/files/etc/init.d/usptest Executable file
View File

@@ -0,0 +1,75 @@
#!/bin/sh /etc/rc.common
START=99
STOP=01
USE_PROCD=1
log()
{
echo "$*"|logger -t usptest -p debug
}
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
sleep 2
# 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
}
start_service() {
procd_open_instance usptest
publish_endpoint
procd_close_instance
}
reload_service() {
publish_endpoint
}
service_triggers() {
procd_add_reload_trigger "mosquitto" "obuspa"
}

View File

@@ -1,12 +1,10 @@
#!/bin/sh
CTRUST_RESET_FILE="/etc/obuspa/ctrust_reset"
CTRUST_RESET_FILE="/tmp/obuspa/ctrust_reset"
VENDOR_PREFIX_FILE="/etc/obuspa/vendor_prefix"
FW_DEFAULT_ROLE_DIR="/etc/users/roles"
SECURE_ROLES=""
CTRUST_RESET_FILE_TEMP="/tmp/obuspa/ctrust_reset"
mkdir -p /tmp/obuspa/
# include jshn.sh
@@ -25,9 +23,9 @@ db_add()
value="$*"
if [ -n "${param}" ] && [ -n "${value}" ]; then
echo "${param} \"${value}\"">>${CTRUST_RESET_FILE_TEMP}
echo "${param} \"${value}\"">>${CTRUST_RESET_FILE}
else
echo >>${CTRUST_RESET_FILE_TEMP}
echo >>${CTRUST_RESET_FILE}
fi
}
@@ -254,10 +252,7 @@ configure_ctrust_role()
if [ -n "${SECURE_ROLES}" ]; then
db_add Device.LocalAgent.ControllerTrust.SecuredRoles "${SECURE_ROLES}"
fi
if [ -f "${CTRUST_RESET_FILE_TEMP}" ]; then
mv -f "${CTRUST_RESET_FILE_TEMP}" "${CTRUST_RESET_FILE}"
fi
}
# configure_ctrust_role "${@}"

View File

@@ -0,0 +1,20 @@
#!/bin/sh
. /lib/functions.sh
if [ ! -f "/etc/config/mosquitto" ]; then
echo "Local mosquitto broker not available"
return 0
fi
add_usp_test()
{
uci_add mosquitto listener usptest
uci_set mosquitto usptest enabled 1
uci_set mosquitto usptest port '9004'
uci_set mosquitto usptest protocol 'websockets'
uci_set mosquitto usptest auth_plugin '/usr/lib/mosquitto_auth_shadow.so'
}
# Install test MQTT over WS listener
add_usp_test

View File

@@ -1,21 +0,0 @@
#!/bin/sh
. /lib/functions.sh
if [ ! -f "/etc/config/mosquitto" ]; then
echo "Local mosquitto broker not available"
return 0
fi
add_mqtt_obuspa_listener()
{
uci_add mosquitto listener obuspa
uci_set mosquitto obuspa enabled 1
uci_set mosquitto obuspa port '1883'
uci_set mosquitto obuspa no_remote_access '1'
uci_set mosquitto obuspa allow_anonymous '1'
}
# Add mosquitto listener for obuspa connection
# apps/controller should add controller definitions separately
add_mqtt_obuspa_listener

View File

@@ -0,0 +1,57 @@
#!/bin/sh
. /lib/functions.sh
if [ ! -f "/etc/config/obuspa" ]; then
echo "Local obuspa not available"
return 0
fi
if [ ! -f "/etc/config/mosquitto" ]; then
echo "Local mosquitto broker not available"
return 0
fi
add_obuspa_test_mtp()
{
uci_add obuspa mtp test_mtp
uci_set obuspa test_mtp Protocol 'MQTT'
uci_set obuspa test_mtp ResponseTopicConfigured '/usp/endpoint'
uci_set obuspa test_mtp mqtt 'testmqtt'
}
add_obuspa_test_mqtt()
{
# Adds Device.MQTT.Client.
uci_add obuspa mqtt testmqtt
uci_set obuspa testmqtt BrokerAddress '127.0.0.1'
uci_set obuspa testmqtt BrokerPort '1883'
uci_set obuspa testmqtt TransportProtocol 'TCP/IP'
}
add_obuspa_test_controller()
{
# Adds Device.LocalAgent.Controller.
uci_add obuspa controller testcontroller
uci_set obuspa testcontroller EndpointID 'proto::interop-usp-controller'
uci_set obuspa testcontroller Protocol 'MQTT'
uci_set obuspa testcontroller Topic '/usp/controller'
uci_set obuspa testcontroller mqtt 'testmqtt'
uci_set obuspa testcontroller assigned_role_name 'full_access'
}
add_obuspa_config()
{
uci_add mosquitto listener obuspa
uci_set mosquitto obuspa enabled 1
uci_set mosquitto obuspa port '1883'
uci_set mosquitto obuspa no_remote_access '1'
uci_set mosquitto obuspa allow_anonymous '1'
}
# Install test usp controller config
add_obuspa_config
add_obuspa_test_mtp
add_obuspa_test_mqtt
add_obuspa_test_controller

View File

@@ -4,3 +4,5 @@
. /etc/obuspa/usp_utils.sh
configure_ctrust_role
exit 0

View File

@@ -8,7 +8,6 @@ RETRY_MIN_INTERVAL="5"
RETRY_INTERVAL_MUL="2000"
ENDPOINT_ID=""
CONTROLLER_DISCOVERED=0
OBUSPA_BOOT_MARKER="/etc/obuspa/.boot"
log()
{
@@ -58,18 +57,18 @@ get_vivsoi() {
data="${opt125}"
rem_len="${len}"
while [ "${rem_len}" -gt 0 ]; do
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
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 ))
rem_len=$(( rem_len - $data_len ))
continue
fi
@@ -80,7 +79,7 @@ get_vivsoi() {
data_len=$(( data_len * 2 + 10 ))
opt_len=$(printf "%d\n" "0x$len_val")
[ "${opt_len}" -eq 0 ] && return
[ $opt_len -eq 0 ] && return
# populate the option data of enterprise id
sub_data_len=$(( opt_len * 2))
@@ -99,28 +98,28 @@ get_vivsoi() {
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}"}
sub_opt_val=${sub_data:4:${sub_opt_len}}
# assign the value found in sub option
case "${sub_opt_id}" in
"25")
URL=$(echo -n "${sub_opt_val}" | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
URL=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
CONTROLLER_DISCOVERED=1
;;
"26")
PROV_CODE=$(echo -n "${sub_opt_val}" | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
PROV_CODE=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
CONTROLLER_DISCOVERED=1
;;
"27")
RETRY_MIN_INTERVAL=$(echo -n "${sub_opt_val}" | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
RETRY_MIN_INTERVAL=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
CONTROLLER_DISCOVERED=1
;;
"28")
RETRY_INTERVAL_MUL=$(echo -n "${sub_opt_val}" | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
RETRY_INTERVAL_MUL=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
CONTROLLER_DISCOVERED=1
;;
"29")
ENDPOINT_ID=$(echo -n "${sub_opt_val}" | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
ENDPOINT_ID=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
CONTROLLER_DISCOVERED=1
;;
esac
@@ -132,7 +131,7 @@ get_vivsoi() {
sub_data_len=$((sub_data_len - sub_opt_end))
# fetch next sub option hex string
sub_data=${sub_data:"${sub_opt_end}":"${sub_data_len}"}
sub_data=${sub_data:${sub_opt_end}:${sub_data_len}}
done
# move ahead data to next enterprise id
@@ -147,7 +146,7 @@ get_access_role()
lan_proto="$(uci -q get network.lan.proto)"
if [ "${lan_proto}" = "dhcp" ]; then
if [ "${lan_proto}" == "dhcp" ]; then
mode="extender"
else
mode="full_access"
@@ -175,7 +174,7 @@ config_get_bool enable_obuspa global enabled 1
config_get wan_intf global interface
config_get_bool dhcp_discovery global dhcp_discovery 1
if [ "${enable_obuspa}" -eq 0 ] || [ "${dhcp_discovery}" -eq 0 ]; then
if [ "$enable_obuspa" = "0" ] || [ "$dhcp_discovery" = "0" ]; then
return 0
fi
@@ -191,9 +190,9 @@ if [ -z "${wan_intf}" ]; then
fi
fi
if [ "${wan_intf}" = "${INTERFACE}" ]; then
if [ "${wan_intf}" == "${INTERFACE}" ]; then
if [ -n "$opt125" ]; then
len=$(echo -n "${opt125}"|wc -c)
len=$(printf "$opt125"|wc -c)
get_vivsoi "$opt125" "$len"
fi
@@ -229,10 +228,10 @@ if [ "${wan_intf}" = "${INTERFACE}" ]; then
;;
*)
# This is an FQDN, perform DNS query
nslookup "${URL}" > /tmp/fqdn_ip
nslookup -type=ptr "${URL}" > /tmp/fqdn_ptr
nslookup -type=srv "${URL}" > /tmp/fqdn_srv
nslookup -type=txt "${URL}" > /tmp/fqdn_srv
nslookup $URL > /tmp/fqdn_ip
nslookup -type=ptr $URL > /tmp/fqdn_ptr
nslookup -type=srv $URL > /tmp/fqdn_srv
nslookup -type=txt $URL > /tmp/fqdn_srv
# TODO extend to collect information from dns-sd records
;;
@@ -248,16 +247,16 @@ if [ "${wan_intf}" = "${INTERFACE}" ]; then
fi
fi
if [ "${proto}" = "mqtt" ] || [ "${proto}" = "mqtts" ]; then
if [ "${proto}" == "mqtt" ] || [ "${proto}" == "mqtts" ]; then
offered_proto="MQTT"
if [ "${proto}" = "mqtt" ]; then
if [ "${proto}" == "mqtt" ]; then
mtp_encrypt="TCP/IP"
else
mtp_encrypt="TLS"
fi
elif [ "${proto}" = "ws" ] || [ "${proto}" = "wss" ]; then
elif [ "${proto}" == "ws" ] || [ "${proto}" == "wss" ]; then
offered_proto="WebSocket"
if [ "${proto}" = "wss" ]; then
if [ "${proto}" == "wss" ]; then
mtp_encrypt="1"
else
mtp_encrypt="0"
@@ -266,46 +265,35 @@ if [ "${wan_intf}" = "${INTERFACE}" ]; then
controllers=$(uci -q show obuspa | grep "=controller" | cut -d'=' -f1 | cut -d'.' -f2)
for controller in $controllers; do
dhcp_disc=$(uci -q get obuspa."${controller}".dhcp_discovered)
dhcp_disc=$(uci -q get obuspa.$controller.dhcp_discovered)
if [ "${dhcp_disc}" -eq 1 ]; then
dhcp_controller="${controller}"
break
fi
done
# Check if any of the existing controller section matches with the endpointid
if [ -z "${dhcp_controller}" ] && [ -n "${ENDPOINT_ID}" ]; then
for controller in $controllers; do
endpointid=$(uci -q get obuspa."${controller}".EndpointID)
if [ "${endpointid}" = "${ENDPOINT_ID}" ]; then
dhcp_controller="${controller}"
break
fi
done
fi
if [ -n "${dhcp_controller}" ]; then
cont_proto=$(uci -q get obuspa."${dhcp_controller}".Protocol)
if [ "${cont_proto}" = "MQTT" ]; then
dhcp_mqtt=$(uci -q get obuspa."${dhcp_controller}".mqtt)
cont_proto="$(uci -q get obuspa.$dhcp_controller.Protocol)"
if [ "${cont_proto}" == "MQTT" ]; then
dhcp_mqtt="$(uci -q get obuspa.$dhcp_controller.mqtt)"
mtps=$(uci -q show obuspa | grep "=mtp" | cut -d'=' -f1 | cut -d'.' -f2)
for mtp in $mtps; do
mtp_mqtt=$(uci -q get obuspa."${mtp}".mqtt)
if [ "${mtp_mqtt}" = "${dhcp_mqtt}" ]; then
mtp_mqtt="$(uci -q get obuspa.$mtp.mqtt)"
if [ "${mtp_mqtt}" == "${dhcp_mqtt}" ]; then
dhcp_mtp="${mtp}"
break
fi
done
elif [ "${cont_proto}" = "WebSocket" ]; then
cont_port=$(uci -q get obuspa."${dhcp_controller}".Port)
cont_encr=$(uci -q get obuspa."${dhcp_controller}".EnableEncryption)
elif [ "${cont_proto}" == "WebSocket" ]; then
cont_port="$(uci -q get obuspa.$dhcp_controller.Port)"
cont_encr="$(uci -q get obuspa.$dhcp_controller.EnableEncryption)"
mtps=$(uci -q show obuspa | grep "=mtp" | cut -d'=' -f1 | cut -d'.' -f2)
for mtp in $mtps; do
mtp_port=$(uci -q get obuspa."${mtp}".Port)
mtp_encr=$(uci -q get obuspa."${mtp}".EnableEncryption)
if [ "${mtp_port}" = "${cont_port}" ] && [ "${mtp_encr}" = "${cont_encr}" ]; then
mtp_port="$(uci -q get obuspa.$mtp.Port)"
mtp_encr="$(uci -q get obuspa.$mtp.EnableEncryption)"
if [ "${mtp_port}" == "${cont_port}" ] && [ "${mtp_encr}" == "${cont_encr}" ]; then
dhcp_mtp="${mtp}"
break
fi
@@ -318,43 +306,43 @@ if [ "${wan_intf}" = "${INTERFACE}" ]; then
if [ -n "${dhcp_controller}" ]; then
## Handling of controller section
ct_endpoint=$(uci -q get obuspa."${dhcp_controller}".EndpointID)
ct_proto=$(uci -q get obuspa."${dhcp_controller}".Protocol)
ct_prov=$(uci -q get obuspa."${dhcp_controller}".ProvisioningCode)
ct_endpoint=$(uci -q get obuspa.$dhcp_controller.EndpointID)
ct_proto=$(uci -q get obuspa.$dhcp_controller.Protocol)
ct_prov=$(uci -q get obuspa.$dhcp_controller.ProvisioningCode)
if [ "${ct_proto}" = "MQTT" ]; then
ct_topic=$(uci -q get obuspa."${dhcp_controller}".Topic)
ct_topic=$(uci -q get obuspa.$dhcp_controller.Topic)
else
ct_topic=$(uci -q get obuspa."${dhcp_controller}".Path)
ct_topic=$(uci -q get obuspa.$dhcp_controller.Path)
fi
if [ -n "${ENDPOINT_ID}" ] && [ "${ct_endpoint}" != "${ENDPOINT_ID}" ]; then
uci -q set obuspa."${dhcp_controller}".EndpointID="${ENDPOINT_ID}"
uci -q set obuspa.$dhcp_controller.EndpointID="${ENDPOINT_ID}"
uci_change=1
fi
if [ -n "${offered_proto}" ] && [ "${ct_proto}" != "${offered_proto}" ]; then
uci -q set obuspa."${dhcp_controller}".Protocol="${offered_proto}"
uci -q set obuspa.$dhcp_controller.Protocol="${offered_proto}"
if [ "${offered_proto}" != "MQTT" ]; then
uci -q delete obuspa."${dhcp_controller}".mqtt
uci -q delete obuspa."${dhcp_controller}".Topic
uci -q set obuspa."${dhcp_controller}".Host="${ip}"
uci -q set obuspa."${dhcp_controller}".Port="${port}"
uci -q set obuspa."${dhcp_controller}".Path="${ct_topic}"
uci -q set obuspa."${dhcp_controller}".EnableEncryption="${mtp_encrypt}"
uci -q set obuspa.$dhcp_controller.mqtt=""
uci -q set obuspa.$dhcp_controller.Topic=""
uci -q set obuspa.$dhcp_controller.Host="${ip}"
uci -q set obuspa.$dhcp_controller.Port="${port}"
uci -q set obuspa.$dhcp_controller.Path="${ct_topic}"
uci -q set obuspa.$dhcp_controller.EnableEncryption="${mtp_encrypt}"
else
uci -q delete obuspa."${dhcp_controller}".EnableEncryption
uci -q delete obuspa."${dhcp_controller}".Path
uci -q delete obuspa."${dhcp_controller}".Host
uci -q delete obuspa."${dhcp_controller}".Port
uci -q set obuspa.$dhcp_controller.EnableEncryption=""
uci -q set obuspa.$dhcp_controller.Path=""
uci -q set obuspa.$dhcp_controller.Host=""
uci -q set obuspa.$dhcp_controller.Port=""
if [ -z "${dhcp_mqtt}" ]; then
uci -q set obuspa."${dhcp_controller}".mqtt='dhcpmqtt'
uci -q set obuspa.$dhcp_controller.mqtt='dhcpmqtt'
else
uci -q set obuspa."${dhcp_controller}".mqtt="${dhcp_mqtt}"
uci -q set obuspa.$dhcp_controller.mqtt="${dhcp_mqtt}"
fi
uci -q set obuspa."${dhcp_controller}".Topic="${ct_topic}"
uci -q set obuspa.$dhcp_controller.Topic="${ct_topic}"
fi
proto_changed=1
@@ -367,37 +355,38 @@ if [ "${wan_intf}" = "${INTERFACE}" ]; then
protocol="${offered_proto}"
fi
if [ "${protocol}" = "MQTT" ]; then
uci -q set obuspa."${dhcp_controller}".Topic="${topic}"
if [ "${protocol}" == "MQTT" ]; then
uci -q set obuspa.$dhcp_controller.Topic="${topic}"
else
uci -q set obuspa."${dhcp_controller}".Path="${topic}"
uci -q set obuspa.$dhcp_controller.Path="${topic}"
fi
uci_change=1
fi
if [ -n "${PROV_CODE}" ] && [ "${ct_prov}" != "${PROV_CODE}" ]; then
uci -q set obuspa."${dhcp_controller}".ProvisioningCode="${PROV_CODE}"
uci -q set obuspa.$dhcp_controller.ProvisioningCode="${PROV_CODE}"
uci_change=1
fi
if [ "${proto_changed}" -eq 1 ]; then
if [ "${offered_proto}" = "WebSocket" ]; then
if [ "${offered_proto}" == "WebSocket" ]; then
if [ -n "${dhcp_mqtt}" ]; then
uci -q delete obuspa."${dhcp_mqtt}"
uci -q del obuspa.$dhcp_mqtt
fi
if [ -z "${dhcp_mtp}" ]; then
uci -q set obuspa.dhcpmtp="mtp"
sec=$(uci -q add obuspa mtp)
uci -q rename obuspa."${sec}"='dhcpmtp'
dhcp_mtp="dhcpmtp"
uci -q set obuspa."${dhcp_mtp}".Enable='1'
uci -q set obuspa.$dhcp_mtp.Enable='1'
fi
uci -q set obuspa."${dhcp_mtp}".mqtt=''
uci -q set obuspa."${dhcp_mtp}".ResponseTopicConfigured=''
uci -q set obuspa."${dhcp_mtp}".Protocol='WebSocket'
uci -q set obuspa."${dhcp_mtp}".Port="${port}"
uci -q set obuspa."${dhcp_mtp}".EnableEncryption="${mtp_encrypt}"
uci -q set obuspa.$dhcp_mtp.mqtt=''
uci -q set obuspa.$dhcp_mtp.ResponseTopicConfigured=''
uci -q set obuspa.$dhcp_mtp.Protocol='WebSocket'
uci -q set obuspa.$dhcp_mtp.Port="${port}"
uci -q set obuspa.$dhcp_mtp.EnableEncryption="${mtp_encrypt}"
uci_change=1
else
@@ -405,135 +394,137 @@ if [ "${wan_intf}" = "${INTERFACE}" ]; then
user="$(uci -q get obuspa.global.username)"
pass="$(uci -q get obuspa.global.password)"
uci -q set obuspa.dhcpmqtt="mqtt"
sec=$(uci -q add obuspa mqtt)
uci -q rename obuspa."${sec}"='dhcpmqtt'
dhcp_mqtt="dhcpmqtt"
uci -q set obuspa."${dhcp_mqtt}".Enable='1'
uci -q set obuspa."${dhcp_mqtt}".Username="${user}"
uci -q set obuspa."${dhcp_mqtt}".Password="${pass}"
uci -q set obuspa.$dhcp_mqtt.Enable='1'
uci -q set obuspa.$dhcp_mqtt.Username="${user}"
uci -q set obuspa.$dhcp_mqtt.Password="${pass}"
fi
uci -q set obuspa."${dhcp_mqtt}".BrokerAddress="${ip}"
uci -q set obuspa."${dhcp_mqtt}".BrokerPort="${port}"
uci -q set obuspa."${dhcp_mqtt}".TransportProtocol="${mtp_encrypt}"
uci -q set obuspa."${dhcp_mqtt}".ProtocolVersion='5.0'
uci -q set obuspa.$dhcp_mqtt.BrokerAddress="${ip}"
uci -q set obuspa.$dhcp_mqtt.BrokerPort="${port}"
uci -q set obuspa.$dhcp_mqtt.TransportProtocol="${mtp_encrypt}"
uci -q set obuspa.$dhcp_mqtt.ProtocolVersion='5.0'
if [ -z "${dhcp_mtp}" ]; then
uci -q set obuspa.dhcpmtp="mtp"
sec=$(uci -q add obuspa mtp)
uci -q rename obuspa."${sec}"='dhcpmtp'
dhcp_mtp="dhcpmtp"
uci -q set obuspa."${dhcp_mtp}".Enable='1'
uci -q set obuspa.$dhcp_mtp.Enable='1'
fi
agent_topic=$(get_agent_topic)
uci -q delete obuspa."${dhcp_mtp}".Port
uci -q delete obuspa."${dhcp_mtp}".EnableEncryption
uci -q set obuspa."${dhcp_mtp}".Protocol='MQTT'
uci -q set obuspa."${dhcp_mtp}".ResponseTopicConfigured="${agent_topic}"
uci -q set obuspa."${dhcp_mtp}".mqtt="${dhcp_mqtt}"
uci -q set obuspa.$dhcp_mtp.Port=""
uci -q set obuspa.$dhcp_mtp.EnableEncryption=""
uci -q set obuspa.$dhcp_mtp.Protocol='MQTT'
uci -q set obuspa.$dhcp_mtp.ResponseTopicConfigured="${agent_topic}"
uci -q set obuspa.$dhcp_mtp.mqtt="${dhcp_mqtt}"
uci_change=1
fi
else
if [ "${ct_proto}" = "WebSocket" ]; then
conf_ip="$(uci -q get obuspa."${dhcp_controller}".Host)"
conf_port="$(uci -q get obuspa."${dhcp_mtp}".Port)"
conf_encr="$(uci -q get obuspa."${dhcp_mtp}".EnableEncryption)"
if [ "${ct_proto}" == "WebSocket" ]; then
conf_ip="$(uci -q get obuspa.$dhcp_controller.Host)"
conf_port="$(uci -q get obuspa.$dhcp_mtp.Port)"
conf_encr="$(uci -q get obuspa.$dhcp_mtp.EnableEncryption)"
if [ -n "${ip}" ] && [ "${conf_ip}" != "${ip}" ]; then
uci -q set obuspa."${dhcp_controller}".Host="${ip}"
uci -q set obuspa.$dhcp_controller.Host="${ip}"
uci_change=1
fi
if [ -n "${port}" ] && [ "${conf_port}" != "${port}" ]; then
uci -q set obuspa."${dhcp_mtp}".Port="${port}"
uci -q set obuspa."${dhcp_controller}".Port="${port}"
uci -q set obuspa.$dhcp_mtp.Port="${port}"
uci -q set obuspa.$dhcp_controller.Port="${port}"
uci_change=1
fi
if [ -n "${mtp_encrypt}" ] && [ "${conf_encr}" != "${mtp_encrypt}" ]; then
uci -q set obuspa."${dhcp_mtp}".EnableEncryption="${mtp_encrypt}"
uci -q set obuspa."${dhcp_controller}".EnableEncryption="${mtp_encrypt}"
uci -q set obuspa.$dhcp_mtp.EnableEncryption="${mtp_encrypt}"
uci -q set obuspa.$dhcp_controller.EnableEncryption="${mtp_encrypt}"
uci_change=1
fi
else
conf_ip=$(uci -q get obuspa."${dhcp_mqtt}".BrokerAddress)
conf_port=$(uci -q get obuspa."${dhcp_mqtt}".BrokerPort)
conf_encr=$(uci -q get obuspa."${dhcp_mqtt}".TransportProtocol)
conf_ip="$(uci -q get obuspa.$dhcp_mqtt.BrokerAddress)"
conf_port="$(uci -q get obuspa.$dhcp_mqtt.BrokerPort)"
conf_encr="$(uci -q get obuspa.$dhcp_mqtt.TransportProtocol)"
if [ -n "${port}" ] && [ "${conf_port}" != "${port}" ]; then
uci -q set obuspa."${dhcp_mqtt}".BrokerPort="${port}"
uci -q set obuspa.$dhcp_mqtt.BrokerPort="${port}"
uci_change=1
fi
if [ -n "${mtp_encrypt}" ] && [ "${conf_encr}" != "${mtp_encrypt}" ]; then
uci -q set obuspa."${dhcp_mqtt}".TransportProtocol="${mtp_encrypt}"
uci -q set obuspa.$dhcp_mqtt.TransportProtocol="${mtp_encrypt}"
uci_change=1
fi
if [ -n "${ip}" ] && [ "${conf_ip}" != "${ip}" ]; then
uci -q set obuspa."${dhcp_mqtt}".BrokerAddress="${ip}"
uci -q set obuspa.$dhcp_mqtt.BrokerAddress="${ip}"
uci_change=1
fi
fi
fi
else
# Only setup a new controller, only if mandatory param present
if [ -n "${ENDPOINT_ID}" ] && [ -n "${URL}" ]; then
uci -q delete obuspa.dhcpmtp
uci -q delete obuspa.dhcpmqtt
uci -q del obuspa.dhcpmtp
uci -q del obuspa.dhcpmqtt
uci -q set obuspa.dhcpcontroller="controller"
uci -q set obuspa.dhcpcontroller.dhcp_discovered="1"
uci -q set obuspa.dhcpcontroller.EndpointID="${ENDPOINT_ID}"
uci -q set obuspa.dhcpcontroller.ProvisioningCode="${PROV_CODE}"
uci -q set obuspa.dhcpcontroller.Protocol="${offered_proto}"
uci -q set obuspa.dhcpcontroller.assigned_role_name="$(get_access_role)"
uci -q set obuspa.dhcpcontroller.Enable='1'
sec=$(uci -q add obuspa controller)
uci -q rename obuspa."${sec}"='dhcpcontroller'
uci -q set obuspa.dhcpcontroller.dhcp_discovered="1"
uci -q set obuspa.dhcpcontroller.EndpointID="${ENDPOINT_ID}"
uci -q set obuspa.dhcpcontroller.ProvisioningCode="${PROV_CODE}"
uci -q set obuspa.dhcpcontroller.Protocol="${offered_proto}"
uci -q set obuspa.dhcpcontroller.assigned_role_name="$(get_access_role)"
uci -q set obuspa.dhcpcontroller.Enable='1'
if [ -n "${offered_proto}" ]; then
if [ "${offered_proto}" = "MQTT" ]; then
user="$(uci -q get obuspa.global.username)"
pass="$(uci -q get obuspa.global.password)"
if [ -n "${offered_proto}" ]; then
if [ "${offered_proto}" == "MQTT" ]; then
user="$(uci -q get obuspa.global.username)"
pass="$(uci -q get obuspa.global.password)"
uci -q set obuspa.dhcpcontroller.Topic="${topic}"
uci -q set obuspa.dhcpcontroller.mqtt='dhcpmqtt'
uci -q set obuspa.dhcpcontroller.Topic="${topic}"
uci -q set obuspa.dhcpcontroller.mqtt='dhcpmqtt'
uci -q set obuspa.dhcpmqtt="mqtt"
uci -q set obuspa.dhcpmqtt.BrokerAddress="${ip}"
uci -q set obuspa.dhcpmqtt.BrokerPort="${port}"
uci -q set obuspa.dhcpmqtt.TransportProtocol="${mtp_encrypt}"
uci -q set obuspa.dhcpmqtt.Enable='1'
uci -q set obuspa.dhcpmqtt.ProtocolVersion='5.0'
uci -q set obuspa.dhcpmqtt.Username="${user}"
uci -q set obuspa.dhcpmqtt.Password="${pass}"
sec=$(uci -q add obuspa mqtt)
uci -q rename obuspa."${sec}"='dhcpmqtt'
uci -q set obuspa.dhcpmqtt.BrokerAddress="${ip}"
uci -q set obuspa.dhcpmqtt.BrokerPort="${port}"
uci -q set obuspa.dhcpmqtt.TransportProtocol="${mtp_encrypt}"
uci -q set obuspa.dhcpmqtt.Enable='1'
uci -q set obuspa.dhcpmqtt.ProtocolVersion='5.0'
uci -q set obuspa.dhcpmqtt.Username="${user}"
uci -q set obuspa.dhcpmqtt.Password="${pass}"
agent_topic=$(get_agent_topic)
uci -q set obuspa.dhcpmtp="mtp"
uci -q set obuspa.dhcpmtp.Protocol='MQTT'
uci -q set obuspa.dhcpmtp.ResponseTopicConfigured="${agent_topic}"
uci -q set obuspa.dhcpmtp.Enable='1'
uci -q set obuspa.dhcpmtp.mqtt='dhcpmqtt'
else
uci -q set obuspa.dhcpcontroller.Path="${topic}"
uci -q set obuspa.dhcpcontroller.Host="${ip}"
uci -q set obuspa.dhcpcontroller.Port="${port}"
uci -q set obuspa.dhcpcontroller.EnableEncryption="${mtp_encrypt}"
agent_topic=$(get_agent_topic)
sec=$(uci -q add obuspa mtp)
uci -q rename obuspa."${sec}"='dhcpmtp'
uci -q set obuspa.dhcpmtp.Protocol='MQTT'
uci -q set obuspa.dhcpmtp.ResponseTopicConfigured="${agent_topic}"
uci -q set obuspa.dhcpmtp.Enable='1'
uci -q set obuspa.dhcpmtp.mqtt='dhcpmqtt'
else
uci -q set obuspa.dhcpcontroller.Path="${topic}"
uci -q set obuspa.dhcpcontroller.Host="${ip}"
uci -q set obuspa.dhcpcontroller.Port="${port}"
uci -q set obuspa.dhcpcontroller.EnableEncryption="${mtp_encrypt}"
uci -q set obuspa.dhcpmtp="mtp"
uci -q set obuspa.dhcpmtp.Protocol='WebSocket'
uci -q set obuspa.dhcpmtp.Port="${port}"
uci -q set obuspa.dhcpmtp.Enable='1'
uci -q set obuspa.dhcpmtp.EnableEncryption="${mtp_encrypt}"
fi
sec=$(uci -q add obuspa mtp)
uci -q rename obuspa."${sec}"='dhcpmtp'
uci -q set obuspa.dhcpmtp.Protocol='WebSocket'
uci -q set obuspa.dhcpmtp.Port="${port}"
uci -q set obuspa.dhcpmtp.Enable='1'
uci -q set obuspa.dhcpmtp.EnableEncryption="${mtp_encrypt}"
fi
uci_change=1
fi
uci_change=1
fi
if [ ${uci_change} -eq 1 ]; then
if [ -f "${OBUSPA_BOOT_MARKER}" ]; then
rm -f "${OBUSPA_BOOT_MARKER}"
fi
log "# Reloading obuspa as dhcp config changed"
ubus call uci commit '{"config":"obuspa"}'
fi

View File

@@ -1,8 +1,8 @@
Index: obuspa-10.0.5.0/src/core/device_controller.c
Index: obuspa-10.0.4.0/src/core/device_controller.c
===================================================================
--- obuspa-10.0.5.0.orig/src/core/device_controller.c
+++ obuspa-10.0.5.0/src/core/device_controller.c
@@ -4223,6 +4223,14 @@ int ProcessControllerAdded(int cont_inst
--- obuspa-10.0.4.0.orig/src/core/device_controller.c
+++ obuspa-10.0.4.0/src/core/device_controller.c
@@ -4214,6 +4214,14 @@ int ProcessControllerAdded(int cont_inst
goto exit;
}
@@ -17,7 +17,7 @@ Index: obuspa-10.0.5.0/src/core/device_controller.c
// Exit if unable to get the object instance numbers present in this controller's MTP table
USP_SNPRINTF(path, sizeof(path), "%s.%d.MTP", device_cont_root, cont_instance);
err = DATA_MODEL_GetInstances(path, &iv);
@@ -4264,14 +4272,6 @@ int ProcessControllerAdded(int cont_inst
@@ -4255,14 +4263,6 @@ int ProcessControllerAdded(int cont_inst
DEVICE_MQTT_UpdateControllerTopics();
#endif

View File

@@ -1,7 +1,7 @@
Index: obuspa-10.0.5.0/src/core/expr_vector.c
Index: obuspa-10.0.4.0/src/core/expr_vector.c
===================================================================
--- obuspa-10.0.5.0.orig/src/core/expr_vector.c
+++ obuspa-10.0.5.0/src/core/expr_vector.c
--- obuspa-10.0.4.0.orig/src/core/expr_vector.c
+++ obuspa-10.0.4.0/src/core/expr_vector.c
@@ -59,6 +59,7 @@ char *expr_op_2_str[kExprOp_Max] =
"<", // kExprOp_LessThan
">", // kExprOp_GreaterThan
@@ -26,10 +26,10 @@ Index: obuspa-10.0.5.0/src/core/expr_vector.c
// Exit if found the "<" operator
op = strchr(buf, '<');
Index: obuspa-10.0.5.0/src/core/path_resolver.c
Index: obuspa-10.0.4.0/src/core/path_resolver.c
===================================================================
--- obuspa-10.0.5.0.orig/src/core/path_resolver.c
+++ obuspa-10.0.5.0/src/core/path_resolver.c
--- obuspa-10.0.4.0.orig/src/core/path_resolver.c
+++ obuspa-10.0.4.0/src/core/path_resolver.c
@@ -1088,7 +1088,7 @@ int ResolveUniqueKey(char *resolved, cha
char temp[MAX_DM_PATH];
bool is_match;
@@ -38,7 +38,7 @@ Index: obuspa-10.0.5.0/src/core/path_resolver.c
+ expr_op_t valid_ops[] = {kExprOp_Equal, kExprOp_NotEqual, kExprOp_LessThanOrEqual, kExprOp_GreaterThanOrEqual, kExprOp_LessThan, kExprOp_GreaterThan, kExprOp_Contains};
// Exit if unable to find the end of the unique key
p = TEXT_UTILS_StrStr(unresolved, "]");
p = strchr(unresolved, ']');
@@ -1754,6 +1754,67 @@ int DoUniqueKeysMatch(int index, search_
}
USP_ASSERT(gge->value != NULL); // GROUP_GET_VECTOR_GetValues() should have set an error message if the vendor hook didn't set a value for the parameter
@@ -107,10 +107,10 @@ Index: obuspa-10.0.5.0/src/core/path_resolver.c
// Determine the function to call to perform the comparison
if (type_flags & (DM_INT | DM_UINT | DM_ULONG | DM_LONG | DM_DECIMAL))
{
Index: obuspa-10.0.5.0/src/include/usp_api.h
Index: obuspa-10.0.4.0/src/include/usp_api.h
===================================================================
--- obuspa-10.0.5.0.orig/src/include/usp_api.h
+++ obuspa-10.0.5.0/src/include/usp_api.h
--- obuspa-10.0.4.0.orig/src/include/usp_api.h
+++ obuspa-10.0.4.0/src/include/usp_api.h
@@ -106,6 +106,7 @@ typedef enum
kExprOp_LessThan, // '<'
kExprOp_GreaterThan, // '>'

View File

@@ -1,40 +1,40 @@
Index: obuspa-10.0.5.0/src/core/device.h
Index: obuspa-10.0.4.0/src/core/device.h
===================================================================
--- obuspa-10.0.5.0.orig/src/core/device.h
+++ obuspa-10.0.5.0/src/core/device.h
@@ -311,6 +311,9 @@ int DEVICE_CTRUST_InstSelToRoleInstance(
--- obuspa-10.0.4.0.orig/src/core/device.h
+++ obuspa-10.0.4.0/src/core/device.h
@@ -310,6 +310,8 @@ void DEVICE_CTRUST_ApplyPermissionsToSub
char *DEVICE_CTRUST_InstSelToPermTarget(int role_index, void *is, int *perm_instance);
int DEVICE_CTRUST_SetRoleParameter(int instance, char *param_name, char *new_value);
int DEVICE_CTRUST_SetPermissionParameter(int instance1, int instance2, char *param_name, char *new_value);
+
+bool DEVICE_CTRUST_IsControllerSecured(void);
+
int DEVICE_CTRUST_DumpPermissionSelectors(int role_instance, char *path);
int DEVICE_REQUEST_Init(void);
int DEVICE_REQUEST_Add(char *path, char *command_key, int *instance);
Index: obuspa-10.0.5.0/src/core/device_ctrust.c
void DEVICE_REQUEST_OperationComplete(int instance, int err_code, char *err_msg, kv_vector_t *output_args);
Index: obuspa-10.0.4.0/src/core/device_ctrust.c
===================================================================
--- obuspa-10.0.5.0.orig/src/core/device_ctrust.c
+++ obuspa-10.0.5.0/src/core/device_ctrust.c
@@ -246,6 +246,7 @@ credential_t *FindCredentialByCertInstan
--- obuspa-10.0.4.0.orig/src/core/device_ctrust.c
+++ obuspa-10.0.4.0/src/core/device_ctrust.c
@@ -236,6 +236,7 @@ credential_t *FindCredentialByCertInstan
int Get_CredentialRole(dm_req_t *req, char *buf, int len);
int Get_CredentialCertificate(dm_req_t *req, char *buf, int len);
int Get_CredentialNumEntries(dm_req_t *req, char *buf, int len);
+int Validate_SecuredRoles(dm_req_t *req, char *value);
void ApplySearchExpressionPermissions(char *path, inst_sel_t *sel);
bool ValidateDataModelPathSegment(char *segment, bool is_last, char *path);
@@ -293,6 +294,9 @@ int DEVICE_CTRUST_Init(void)
// Create a timer which will be used to apply all modified permissions to the data model, after processing a USP Message
SYNC_TIMER_Add(ApplyModifiedPermissions, 0, END_OF_TIME);
#ifndef REMOVE_DEVICE_SECURITY
int InitChallengeTable();
@@ -355,6 +356,10 @@ int DEVICE_CTRUST_Init(void)
challenge_response_input_args, NUM_ELEM(challenge_response_input_args),
NULL, 0);
#endif
+
+ // Register Device.LocalAgent.ControllerTrust.SecuredRoles parameter
+ err |= USP_REGISTER_DBParam_ReadWrite(DEVICE_CTRUST_ROOT ".SecuredRoles", "", Validate_SecuredRoles, NULL, DM_STRING);
+
// Register parameters implemented by this component
// Device.LocalAgent.ControllerTrust.Role.{i}
err |= USP_REGISTER_Object(DEVICE_ROLE_ROOT, ValidateAdd_CTrustRole, NULL, Notify_CTrustRoleAdded,
@@ -3533,3 +3537,139 @@ exit:
// Exit if any errors occurred
if (err != USP_ERR_OK)
{
@@ -2939,3 +2944,139 @@ exit:
return err;
}
#endif // REMOVE_DEVICE_SECURITY

View File

@@ -1,8 +1,8 @@
Index: obuspa-10.0.7.0/src/core/cli_server.c
Index: obuspa-10.0.0.2/src/core/cli_server.c
===================================================================
--- obuspa-10.0.7.0.orig/src/core/cli_server.c
+++ obuspa-10.0.7.0/src/core/cli_server.c
@@ -726,10 +726,6 @@ int ExecuteCli_Get(str_vector_t *args)
--- obuspa-10.0.0.2.orig/src/core/cli_server.c
+++ obuspa-10.0.0.2/src/core/cli_server.c
@@ -724,10 +724,6 @@ int ExecuteCli_Get(str_vector_t *args)
USP_ASSERT(gge->value != NULL);
SendCliResponse("%s => %s\n", gge->path, gge->value);
}
@@ -13,11 +13,11 @@ Index: obuspa-10.0.7.0/src/core/cli_server.c
}
GROUP_GET_VECTOR_Destroy(&ggv);
Index: obuspa-10.0.7.0/src/core/data_model.c
Index: obuspa-10.0.0.2/src/core/data_model.c
===================================================================
--- obuspa-10.0.7.0.orig/src/core/data_model.c
+++ obuspa-10.0.7.0/src/core/data_model.c
@@ -1398,7 +1398,7 @@ int DATA_MODEL_NotifyInstanceAdded(char
--- obuspa-10.0.0.2.orig/src/core/data_model.c
+++ obuspa-10.0.0.2/src/core/data_model.c
@@ -1321,7 +1321,7 @@ int DATA_MODEL_NotifyInstanceAdded(char
// Exit if instance already exists - nothing to do
if (exists)
{
@@ -26,7 +26,7 @@ Index: obuspa-10.0.7.0/src/core/data_model.c
return USP_ERR_CREATION_FAILURE;
}
@@ -1486,7 +1486,7 @@ int DATA_MODEL_NotifyInstanceDeleted(cha
@@ -1409,7 +1409,7 @@ int DATA_MODEL_NotifyInstanceDeleted(cha
// Exit if instance does not exist - nothing to do
if (exists == false)
{
@@ -35,11 +35,11 @@ Index: obuspa-10.0.7.0/src/core/data_model.c
return USP_ERR_OBJECT_DOES_NOT_EXIST;
}
Index: obuspa-10.0.7.0/src/core/mqtt.c
===================================================================
--- obuspa-10.0.7.0.orig/src/core/mqtt.c
+++ obuspa-10.0.7.0/src/core/mqtt.c
@@ -4070,7 +4070,7 @@ void MessageV5Callback(struct mosquitto
diff --git a/src/core/mqtt.c b/src/core/mqtt.c
index 388697a..444b4da 100644
--- a/src/core/mqtt.c
+++ b/src/core/mqtt.c
@@ -4020,7 +4020,7 @@ void MessageV5Callback(struct mosquitto *mosq, void *userdata, const struct mosq
if (mosquitto_property_read_string(props, RESPONSE_TOPIC,
&response_info_ptr, false) == NULL)
{

View File

@@ -4,11 +4,11 @@ Date: Wed Apr 30 17:18:27 2025 +0530
1001-use-datamodel-caching.patch
Index: obuspa-10.0.7.0/src/core/cli_server.c
===================================================================
--- obuspa-10.0.7.0.orig/src/core/cli_server.c
+++ obuspa-10.0.7.0/src/core/cli_server.c
@@ -513,6 +513,7 @@ int CLI_SERVER_ExecuteCliCommand(char *c
diff --git a/src/core/cli_server.c b/src/core/cli_server.c
index da61c6f..abac7cb 100644
--- a/src/core/cli_server.c
+++ b/src/core/cli_server.c
@@ -511,6 +511,7 @@ int CLI_SERVER_ExecuteCliCommand(char *cmd_line)
SendCliResponse("WARNING: Discarding unused args: %s\n", args.vector[cli_cmd->max_args+1]);
}
@@ -16,7 +16,7 @@ Index: obuspa-10.0.7.0/src/core/cli_server.c
// Process command
err = cli_cmd->exec_cmd(&args);
print_help = false;
@@ -672,6 +673,11 @@ int ExecuteCli_Version(str_vector_t *arg
@@ -670,6 +671,11 @@ int ExecuteCli_Version(str_vector_t *args)
int ExecuteCli_Get(str_vector_t *args)
{
combined_role_t *combined_role;
@@ -28,22 +28,22 @@ Index: obuspa-10.0.7.0/src/core/cli_server.c
#ifndef REMOVE_USP_BROKER
char *arg1;
Index: obuspa-10.0.7.0/src/core/data_model.h
===================================================================
--- obuspa-10.0.7.0.orig/src/core/data_model.h
+++ obuspa-10.0.7.0/src/core/data_model.h
@@ -417,5 +417,6 @@ int DM_PRIV_ReRegister_DBParam_Default(c
diff --git a/src/core/data_model.h b/src/core/data_model.h
index 7564127..2736d7c 100755
--- a/src/core/data_model.h
+++ b/src/core/data_model.h
@@ -405,5 +405,6 @@ int DM_PRIV_ReRegister_DBParam_Default(char *path, char *value);
bool DM_PRIV_IsChildNodeOf(dm_node_t *node, dm_node_t *parent_node);
void DM_PRIV_GetAllEventsAndCommands(dm_node_t *node, str_vector_t *events, str_vector_t *commands);
+int vendor_create_dm_cache(char *paths[], int num_paths);
#endif
Index: obuspa-10.0.7.0/src/core/handle_get.c
===================================================================
--- obuspa-10.0.7.0.orig/src/core/handle_get.c
+++ obuspa-10.0.7.0/src/core/handle_get.c
@@ -129,6 +129,7 @@ void MSG_HANDLER_HandleGet(Usp__Msg *usp
diff --git a/src/core/handle_get.c b/src/core/handle_get.c
index d9d3e9e..c263978 100644
--- a/src/core/handle_get.c
+++ b/src/core/handle_get.c
@@ -129,6 +129,7 @@ void MSG_HANDLER_HandleGet(Usp__Msg *usp, char *controller_endpoint, mtp_conn_t
goto exit;
}
@@ -51,11 +51,11 @@ Index: obuspa-10.0.7.0/src/core/handle_get.c
// Calculate the number of hierarchical levels to traverse in the data model when performing partial path resolution
// NOTE: protocol buffer has depth as an unsigned quantity, but internally we use a signed number, so limit range to that of a signed number
depth = usp->body->request->get->max_depth;
Index: obuspa-10.0.7.0/src/core/msg_handler.c
===================================================================
--- obuspa-10.0.7.0.orig/src/core/msg_handler.c
+++ obuspa-10.0.7.0/src/core/msg_handler.c
@@ -987,6 +987,8 @@ int HandleUspMessage(Usp__Msg *usp, char
diff --git a/src/core/msg_handler.c b/src/core/msg_handler.c
index 647591d..b7498d8 100755
--- a/src/core/msg_handler.c
+++ b/src/core/msg_handler.c
@@ -863,6 +863,8 @@ int HandleUspMessage(Usp__Msg *usp, char *endpoint_id, mtp_conn_t *mtpc)
MSG_HANDLER_UspMsgTypeToString(usp->header->msg_type),
iso8601_cur_time(buf, sizeof(buf)) );

View File

@@ -1,8 +1,8 @@
Index: obuspa-10.0.7.0/src/core/data_model.c
Index: obuspa-10.0.0.2/src/core/data_model.c
===================================================================
--- obuspa-10.0.7.0.orig/src/core/data_model.c
+++ obuspa-10.0.7.0/src/core/data_model.c
@@ -5519,7 +5519,7 @@ int RegisterDefaultControllerTrust(void)
--- obuspa-10.0.0.2.orig/src/core/data_model.c
+++ obuspa-10.0.0.2/src/core/data_model.c
@@ -5347,7 +5347,7 @@ int RegisterDefaultControllerTrust(void)
int err = USP_ERR_OK;
// Register 'Full Access' role

View File

@@ -1,8 +1,8 @@
Index: obuspa-10.0.6.0/src/core/device.h
Index: obuspa-10.0.4.0/src/core/device.h
===================================================================
--- obuspa-10.0.6.0.orig/src/core/device.h
+++ obuspa-10.0.6.0/src/core/device.h
@@ -355,6 +355,10 @@ void DEVICE_CONTROLLER_SetInheritedRole(
--- obuspa-10.0.4.0.orig/src/core/device.h
+++ obuspa-10.0.4.0/src/core/device.h
@@ -352,6 +352,10 @@ void DEVICE_CONTROLLER_SetInheritedRole(
int DEVICE_CONTROLLER_CountEnabledWebsockClientConnections(void);
#endif
@@ -13,11 +13,11 @@ Index: obuspa-10.0.6.0/src/core/device.h
#ifndef REMOVE_USP_BROKER
int DEVICE_SUBSCRIPTION_RouteNotification(Usp__Msg *usp, int instance, char *subscribed_path);
bool DEVICE_SUBSCRIPTION_MarkVendorLayerSubs(int broker_instance, subs_notify_t notify_type, char *path, int group_id);
Index: obuspa-10.0.6.0/src/core/device_controller.c
Index: obuspa-10.0.4.0/src/core/device_controller.c
===================================================================
--- obuspa-10.0.6.0.orig/src/core/device_controller.c
+++ obuspa-10.0.6.0/src/core/device_controller.c
@@ -969,6 +969,78 @@ int DEVICE_CONTROLLER_QueueBinaryMessage
--- obuspa-10.0.4.0.orig/src/core/device_controller.c
+++ obuspa-10.0.4.0/src/core/device_controller.c
@@ -968,6 +968,78 @@ int DEVICE_CONTROLLER_QueueBinaryMessage
return USP_ERR_OK;
}
@@ -96,11 +96,11 @@ Index: obuspa-10.0.6.0/src/core/device_controller.c
/*********************************************************************//**
**
** DEVICE_CONTROLLER_IsMTPConfigured
Index: obuspa-10.0.6.0/src/core/msg_handler.c
Index: obuspa-10.0.4.0/src/core/msg_handler.c
===================================================================
--- obuspa-10.0.6.0.orig/src/core/msg_handler.c
+++ obuspa-10.0.6.0/src/core/msg_handler.c
@@ -1344,6 +1344,15 @@ int ValidateUspRecord(UspRecord__Record
--- obuspa-10.0.4.0.orig/src/core/msg_handler.c
+++ obuspa-10.0.4.0/src/core/msg_handler.c
@@ -1220,6 +1220,15 @@ int ValidateUspRecord(UspRecord__Record
usp_service_instance = USP_BROKER_GetUspServiceInstance(rec->from_id, 0);
#endif

View File

@@ -1,8 +1,8 @@
Index: obuspa-10.0.6.0/src/core/mqtt.c
Index: obuspa-10.0.0.1/src/core/mqtt.c
===================================================================
--- obuspa-10.0.6.0.orig/src/core/mqtt.c
+++ obuspa-10.0.6.0/src/core/mqtt.c
@@ -265,6 +265,8 @@ void SaveMqttPublishErrMsg(const char *f
--- obuspa-10.0.0.1.orig/src/core/mqtt.c
+++ obuspa-10.0.0.1/src/core/mqtt.c
@@ -259,6 +259,8 @@ void MqttSubscriptionDestroy(mqtt_subscr
#define DEFINE_MQTT_TrustCertVerifyCallbackIndex(index) \
int MQTT_TrustCertVerifyCallback_##index (int preverify_ok, X509_STORE_CTX *x509_ctx) \
{\
@@ -11,7 +11,7 @@ Index: obuspa-10.0.6.0/src/core/mqtt.c
return DEVICE_SECURITY_TrustCertVerifyCallbackWithCertChain(preverify_ok, x509_ctx, &mqtt_clients[index].cert_chain);\
}
@@ -275,6 +277,11 @@ DEFINE_MQTT_TrustCertVerifyCallbackIndex
@@ -269,6 +271,11 @@ DEFINE_MQTT_TrustCertVerifyCallbackIndex
DEFINE_MQTT_TrustCertVerifyCallbackIndex(2);
DEFINE_MQTT_TrustCertVerifyCallbackIndex(3);
DEFINE_MQTT_TrustCertVerifyCallbackIndex(4);
@@ -23,7 +23,7 @@ Index: obuspa-10.0.6.0/src/core/mqtt.c
// Add more, with incrementing indexes here, if you change MAX_MQTT_CLIENTS
//------------------------------------------------------------------------------------
@@ -285,10 +292,15 @@ ssl_verify_callback_t* mqtt_verify_callb
@@ -279,10 +286,15 @@ ssl_verify_callback_t* mqtt_verify_callb
MQTT_TrustCertVerifyCallbackIndex(2),
MQTT_TrustCertVerifyCallbackIndex(3),
MQTT_TrustCertVerifyCallbackIndex(4),

View File

@@ -1,7 +1,7 @@
Index: obuspa-10.0.7.0/src/core/mqtt.c
===================================================================
--- obuspa-10.0.7.0.orig/src/core/mqtt.c
+++ obuspa-10.0.7.0/src/core/mqtt.c
diff --git a/src/core/mqtt.c b/src/core/mqtt.c
index 70978501b1..96119fe080 100644
--- a/src/core/mqtt.c
+++ b/src/core/mqtt.c
@@ -53,6 +53,7 @@
#include <openssl/bio.h>
#include <openssl/err.h>
@@ -10,7 +10,7 @@ Index: obuspa-10.0.7.0/src/core/mqtt.c
#include <mosquitto.h>
#include "mqtt.h"
@@ -206,8 +207,9 @@ int EnableMosquitto(mqtt_client_t *clien
@@ -201,8 +202,9 @@ int EnableMosquitto(mqtt_client_t *client);
void SetupCallbacks(mqtt_client_t *client);
void QueueUspConnectRecord_MQTT(mqtt_client_t *client, mtp_send_item_t *msi, char *controller_topic, time_t expiry_time);
int SendQueueHead(mqtt_client_t *client);
@@ -21,7 +21,7 @@ Index: obuspa-10.0.7.0/src/core/mqtt.c
int ConnectSetEncryption(mqtt_client_t *client);
void ConnectCallback(struct mosquitto *mosq, void *userdata, int result);
void ConnectV5Callback(struct mosquitto *mosq, void *userdata, int result, int flags, const mosquitto_property *props);
@@ -250,7 +252,7 @@ void HandleMqttReconnect(mqtt_client_t *
@@ -245,7 +247,7 @@ void HandleMqttReconnect(mqtt_client_t *client);
void HandleMqttReconnectAfterDisconnect(mqtt_client_t *client);
void HandleMqttDisconnect(mqtt_client_t *client);
void DisconnectIfAllSubscriptionsFailed(mqtt_client_t *client);
@@ -30,7 +30,7 @@ Index: obuspa-10.0.7.0/src/core/mqtt.c
void RemoveMqttQueueItem(mqtt_client_t *client, mqtt_send_item_t *queued_msg);
void RemoveExpiredMqttMessages(mqtt_client_t *client);
void ParseSubscribeTopicsFromConnack(mqtt_client_t *client, mosquitto_property *prop);
@@ -2380,6 +2382,143 @@ int SendQueueHead(mqtt_client_t *client)
@@ -2350,6 +2352,143 @@ int SendQueueHead(mqtt_client_t *client)
return err;
}
@@ -174,7 +174,7 @@ Index: obuspa-10.0.7.0/src/core/mqtt.c
/*********************************************************************//**
**
** IsMqttBrokerUp
@@ -2394,109 +2533,92 @@ int SendQueueHead(mqtt_client_t *client)
@@ -2364,109 +2503,92 @@ int SendQueueHead(mqtt_client_t *client)
** \return true if the MQTT Broker is up, false otherwise
**
**************************************************************************/
@@ -343,7 +343,7 @@ Index: obuspa-10.0.7.0/src/core/mqtt.c
}
return result;
@@ -2517,18 +2639,20 @@ void Connect(mqtt_client_t *client)
@@ -2487,18 +2609,20 @@ void Connect(mqtt_client_t *client)
{
int err = USP_ERR_OK;
bool is_up;
@@ -367,7 +367,7 @@ Index: obuspa-10.0.7.0/src/core/mqtt.c
// Exit if failed to connect
if (err != USP_ERR_OK)
@@ -2561,7 +2685,7 @@ exit:
@@ -2531,7 +2655,7 @@ exit:
** \return USP_ERR_INTERNAL_ERROR if failed to connect (and should retry)
**
**************************************************************************/
@@ -376,7 +376,7 @@ Index: obuspa-10.0.7.0/src/core/mqtt.c
{
int version;
mosquitto_property *proplist = NULL;
@@ -2631,19 +2755,19 @@ int PerformMqttClientConnect(mqtt_client
@@ -2601,19 +2725,19 @@ int PerformMqttClientConnect(mqtt_client_t *client)
// We do this to prevent the data model thread from potentially being blocked, whilst the connect call is taking place
OS_UTILS_UnlockMutex(&mqtt_access_mutex);

View File

@@ -1,28 +0,0 @@
diff --git a/src/core/database.c b/src/core/database.c
index 7ad9dae..edebd7c 100644
--- a/src/core/database.c
+++ b/src/core/database.c
@@ -955,6 +955,7 @@ void DATABASE_Dump(void)
int OpenUspDatabase(char *db_file)
{
int err;
+ char *err_msg = 0;
// Exit if unable to open the database
err = sqlite3_open(db_file, &db_handle);
@@ -965,6 +966,15 @@ int OpenUspDatabase(char *db_file)
return USP_ERR_INTERNAL_ERROR;
}
+ // Execute the PRAGMA statement
+ const char *sql = "PRAGMA journal_mode = MEMORY;";
+ err = sqlite3_exec(db_handle, sql, 0, 0, &err_msg);
+ if (err != SQLITE_OK) {
+ USP_LOG_Error("%s: Failed to set journal_mode: %s", __func__, err_msg);
+ sqlite3_free(err_msg);
+ return USP_ERR_INTERNAL_ERROR;
+ }
+
// Exit if unable to create the data model parameter table (if it does not already exist)
#define CREATE_TABLE_STR "create table if not exists data_model (hash integer, instances text, value text, primary key (hash, instances));"
err = sqlite3_exec(db_handle, CREATE_TABLE_STR, NULL, NULL, NULL);

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