mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-24 11:05:02 +08:00
Compare commits
1 Commits
nw_firewal
...
CodecCap
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c5df8adbf |
31
bbf/Config_bbfdm.in
Normal file
31
bbf/Config_bbfdm.in
Normal file
@@ -0,0 +1,31 @@
|
||||
config BBF_VENDOR_EXTENSION
|
||||
bool "Enable Vendor Extension"
|
||||
default y
|
||||
|
||||
config BBF_VENDOR_LIST
|
||||
string "Vendor List"
|
||||
default "iopsys"
|
||||
|
||||
config BBF_VENDOR_PREFIX
|
||||
string "Vendor Prefix"
|
||||
default "X_IOPSYS_EU_"
|
||||
|
||||
config BBF_TR104
|
||||
bool "Enable TR-104 Data Model Support"
|
||||
default y
|
||||
|
||||
config BBF_TR143
|
||||
bool "Enable TR-143 Data Model Support"
|
||||
default y
|
||||
|
||||
config BBFDM_ENABLE_JSON_PLUGIN
|
||||
bool "Enable json plugin to extend datamodel"
|
||||
default y
|
||||
|
||||
config BBFDM_ENABLE_DOTSO_PLUGIN
|
||||
bool "Enable shared library plugin to extend datamodel"
|
||||
default y
|
||||
|
||||
config BBF_MAX_OBJECT_INSTANCES
|
||||
int "Maximum number of instances per object"
|
||||
default 255
|
||||
179
bbf/Makefile
Normal file
179
bbf/Makefile
Normal file
@@ -0,0 +1,179 @@
|
||||
#
|
||||
# Copyright (C) 2022 IOPSYS
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=libbbfdm
|
||||
PKG_VERSION:=6.8.33
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/bbf.git
|
||||
PKG_SOURCE_VERSION:=9bdcb1ac188c44fc2274bf01dd9dce46f572b967
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
|
||||
PKG_RELEASE=$(PKG_SOURCE_VERSION)
|
||||
|
||||
PKG_LICENSE:=LGPL-2.1
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/cmake.mk
|
||||
|
||||
define Package/libbbf_api
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=TRx69
|
||||
TITLE:=Library for libbbfdm API
|
||||
endef
|
||||
|
||||
define Package/libbbfdm/default
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=TRx69
|
||||
TITLE:=Library for broadband forum data model support
|
||||
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libtrace +libcurl
|
||||
endef
|
||||
|
||||
define Package/libbbfdm
|
||||
$(Package/libbbfdm/default)
|
||||
TITLE += (internal)
|
||||
VARIANT:=internal
|
||||
endef
|
||||
|
||||
define Package/libbbfdm-mbedtls
|
||||
$(Package/libbbfdm/default)
|
||||
TITLE += (mbedtls)
|
||||
DEPENDS += +PACKAGE_libbbfdm-mbedtls:libmbedtls
|
||||
VARIANT:=mbedtls
|
||||
DEFAULT_VARIANT:=1
|
||||
endef
|
||||
|
||||
define Package/libbbfdm-openssl
|
||||
$(Package/libbbfdm/default)
|
||||
TITLE += (openssl)
|
||||
DEPENDS += +PACKAGE_libbbfdm-openssl:libopenssl
|
||||
CONFLICTS := libbbfdm-mbedtls
|
||||
VARIANT:=openssl
|
||||
endef
|
||||
|
||||
define Package/libbbfdm-wolfssl
|
||||
$(Package/libbbfdm/default)
|
||||
TITLE += (wolfssl)
|
||||
DEPENDS += +PACKAGE_libbbfdm-wolfssl:libwolfssl
|
||||
CONFLICTS := libbbfdm-mbedtls libbbfdm-openssl
|
||||
VARIANT:=wolfssl
|
||||
endef
|
||||
|
||||
define Package/libbbfdm/config
|
||||
source "$(SOURCE)/Config_bbfdm.in"
|
||||
endef
|
||||
|
||||
define Package/libbbf_api/description
|
||||
Library contains the API(UCI, UBUS, JSON, CLI and Browse) of libbbfdm
|
||||
endef
|
||||
|
||||
define Package/libbbfdm/description
|
||||
Library contains the data model tree. It includes TR181, TR104 and TR143 data models
|
||||
endef
|
||||
|
||||
USE_LOCAL=$(shell ls ./src/ 2>/dev/null >/dev/null && echo 1)
|
||||
ifneq ($(USE_LOCAL),)
|
||||
define Build/Prepare
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
endif
|
||||
|
||||
CMAKE_OPTIONS += \
|
||||
-DBBF_TR181=ON
|
||||
|
||||
ifeq ($(CONFIG_BBF_TR104),y)
|
||||
CMAKE_OPTIONS += \
|
||||
-DBBF_TR104=ON
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BBF_TR143),y)
|
||||
CMAKE_OPTIONS += \
|
||||
-DBBF_TR143=ON
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BBF_VENDOR_EXTENSION),y)
|
||||
CMAKE_OPTIONS += \
|
||||
-DBBF_VENDOR_EXTENSION=ON
|
||||
|
||||
CMAKE_OPTIONS += \
|
||||
-DBBF_VENDOR_LIST:String="$(CONFIG_BBF_VENDOR_LIST)" \
|
||||
-DBBF_VENDOR_PREFIX:String="$(CONFIG_BBF_VENDOR_PREFIX)" \
|
||||
-DBBF_MAX_OBJECT_INSTANCES:Integer=$(CONFIG_BBF_MAX_OBJECT_INSTANCES)
|
||||
|
||||
endif ##CONFIG_BBF_VENDOR_EXTENSION
|
||||
|
||||
ifeq ($(CONFIG_BBFDM_ENABLE_JSON_PLUGIN),y)
|
||||
CMAKE_OPTIONS += \
|
||||
-DBBF_JSON_PLUGIN=ON
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BBFDM_ENABLE_DOTSO_PLUGIN),y)
|
||||
CMAKE_OPTIONS += \
|
||||
-DBBF_DOTSO_PLUGIN=ON
|
||||
endif
|
||||
|
||||
ifeq ($(BUILD_VARIANT),openssl)
|
||||
CMAKE_OPTIONS += -DWITH_OPENSSL=ON
|
||||
endif
|
||||
|
||||
ifeq ($(BUILD_VARIANT),wolfssl)
|
||||
CMAKE_OPTIONS += -DWITH_WOLFSSL=ON
|
||||
endif
|
||||
|
||||
ifeq ($(BUILD_VARIANT),mbedtls)
|
||||
CMAKE_OPTIONS += -DWITH_MBEDTLS=ON
|
||||
endif
|
||||
|
||||
define Package/libbbf_api/install
|
||||
$(INSTALL_DIR) $(1)/lib
|
||||
endef
|
||||
|
||||
define Package/libbbfdm/default/install
|
||||
$(INSTALL_DIR) $(1)/lib
|
||||
$(INSTALL_DIR) $(1)/usr/share/bbfdm
|
||||
$(INSTALL_DIR) $(1)/etc/bbfdm
|
||||
$(INSTALL_DIR) $(1)/etc/bbfdm/dmmap
|
||||
$(INSTALL_DIR) $(1)/etc/bbfdm/json
|
||||
$(INSTALL_DIR) $(1)/usr/lib/bbfdm
|
||||
$(CP) $(PKG_BUILD_DIR)/libbbfdm.so $(1)/lib/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/scripts/* $(1)/usr/share/bbfdm
|
||||
endef
|
||||
|
||||
define Package/libbbfdm/default/prerm
|
||||
#!/bin/sh
|
||||
rm -rf /etc/bbfdm/dmmap/*
|
||||
exit 0
|
||||
endef
|
||||
|
||||
Package/libbbfdm-openssl/prerm = $(Package/libbbfdm/default/prerm)
|
||||
Package/libbbfdm-wolfssl/prerm = $(Package/libbbfdm/default/prerm)
|
||||
Package/libbbfdm-mbedtls/prerm = $(Package/libbbfdm/default/prerm)
|
||||
|
||||
Package/libbbfdm-openssl/install = $(Package/libbbfdm/default/install)
|
||||
Package/libbbfdm-wolfssl/install = $(Package/libbbfdm/default/install)
|
||||
Package/libbbfdm-mbedtls/install = $(Package/libbbfdm/default/install)
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(INSTALL_DIR) $(1)/usr/include/libbbfdm
|
||||
$(INSTALL_DIR) $(1)/usr/include/libbbf_api
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/include/*.h $(1)/usr/include/
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/*.h $(1)/usr/include/libbbfdm/
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/libbbf_api/*.h $(1)/usr/include/libbbf_api/
|
||||
$(CP) $(PKG_BUILD_DIR)/libbbfdm.so $(1)/usr/lib/
|
||||
touch $(1)/usr/lib/libbbf_api.so
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,libbbf_api))
|
||||
$(eval $(call BuildPackage,libbbfdm))
|
||||
$(eval $(call BuildPackage,libbbfdm-openssl))
|
||||
$(eval $(call BuildPackage,libbbfdm-wolfssl))
|
||||
$(eval $(call BuildPackage,libbbfdm-mbedtls))
|
||||
@@ -1,23 +0,0 @@
|
||||
config BBF_VENDOR_LIST
|
||||
string "Vendor List"
|
||||
default "iopsys"
|
||||
|
||||
config BBF_VENDOR_PREFIX
|
||||
string "Vendor Prefix"
|
||||
default "X_IOPSYS_EU_"
|
||||
|
||||
config BBF_OBFUSCATION_KEY
|
||||
string "Obfuscation key"
|
||||
default "371d530c95a17d1ca223a29b7a6cdc97e1135c1e0959b51106cca91a0b148b5e42742d372a359760742803f2a44bd88fca67ccdcfaeed26d02ce3b6049cb1e04"
|
||||
|
||||
config BBF_TR143
|
||||
bool "Enable TR-143 Data Model Support"
|
||||
default y
|
||||
|
||||
config BBF_TR471
|
||||
bool "Enable TR-471 Data Model Support"
|
||||
default y
|
||||
|
||||
config BBF_MAX_OBJECT_INSTANCES
|
||||
int "Maximum number of instances per object"
|
||||
default 255
|
||||
161
bbfdm/Makefile
161
bbfdm/Makefile
@@ -1,161 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2023 IOPSYS
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=bbfdm
|
||||
PKG_VERSION:=1.8.1
|
||||
|
||||
USE_LOCAL:=0
|
||||
ifneq ($(USE_LOCAL),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/bbfdm.git
|
||||
PKG_SOURCE_VERSION:=63fad00eeed1a7c181ef51be43174d92be4ad00f
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
endif
|
||||
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/cmake.mk
|
||||
include bbfdm.mk
|
||||
|
||||
define Package/libbbfdm-api
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=TRx69
|
||||
TITLE:=BBF datamodel library, provides API to extend datamodel using DotSO plugins
|
||||
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libcurl
|
||||
ABI_VERSION:=1.0
|
||||
endef
|
||||
|
||||
define Package/libbbfdm
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=TRx69
|
||||
TITLE:=Library for broadband forum data model support
|
||||
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libbbfdm-api \
|
||||
+BBF_TR471:obudpst +libopenssl
|
||||
endef
|
||||
|
||||
define Package/bbfdmd
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=TRx69
|
||||
TITLE:=Datamodel ubus backend
|
||||
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libbbfdm-api +libbbfdm
|
||||
endef
|
||||
|
||||
define Package/libbbfdm/config
|
||||
source "$(SOURCE)/Config_bbfdm.in"
|
||||
endef
|
||||
|
||||
define Package/libbbfdm-api/description
|
||||
Library contains the API(UCI, UBUS, JSON, CLI and Browse) of libbbfdm
|
||||
endef
|
||||
|
||||
define Package/libbbfdm/description
|
||||
Library contains the data model tree. It includes TR181, TR143 data models
|
||||
endef
|
||||
|
||||
ifeq ($(USE_LOCAL),1)
|
||||
define Build/Prepare
|
||||
$(CP) ~/git/bbfdm/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
endif
|
||||
|
||||
CMAKE_OPTIONS += \
|
||||
-DBBF_TR181=ON
|
||||
-DBBF_WIFI_DATAELEMENTS=ON
|
||||
|
||||
ifeq ($(CONFIG_BBF_TR143),y)
|
||||
CMAKE_OPTIONS += \
|
||||
-DBBF_TR143=ON
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BBF_TR471),y)
|
||||
CMAKE_OPTIONS += \
|
||||
-DBBF_TR471=ON
|
||||
endif
|
||||
|
||||
CMAKE_OPTIONS += \
|
||||
-DBBF_VENDOR_LIST:String="$(CONFIG_BBF_VENDOR_LIST)" \
|
||||
-DBBF_VENDOR_PREFIX:String="$(CONFIG_BBF_VENDOR_PREFIX)" \
|
||||
-DBBF_MAX_OBJECT_INSTANCES:Integer=$(CONFIG_BBF_MAX_OBJECT_INSTANCES)
|
||||
|
||||
ifeq ($(CONFIG_PACKAGE_bbfdmd),y)
|
||||
CMAKE_OPTIONS += \
|
||||
-DBBFDMD_MAX_MSG_LEN:Integer=10485760
|
||||
endif
|
||||
|
||||
define Package/libbbfdm-api/install
|
||||
$(INSTALL_DIR) $(1)/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libbbfdm-api/libbbfdm-api.so $(1)/lib/
|
||||
$(INSTALL_DIR) $(1)/usr/libexec/rpcd
|
||||
$(CP) $(PKG_BUILD_DIR)/libbbfdm-api/scripts/bbf.secure $(1)/usr/libexec/rpcd/bbf.secure
|
||||
$(INSTALL_DIR) $(1)/etc/bbfdm
|
||||
echo "$(CONFIG_BBF_OBFUSCATION_KEY)" > $(1)/etc/bbfdm/.secure_hash
|
||||
$(INSTALL_DIR) $(1)/etc/bbfdm/certificates
|
||||
endef
|
||||
|
||||
define Package/libbbfdm/install
|
||||
$(INSTALL_DIR) $(1)/lib
|
||||
$(INSTALL_DIR) $(1)/etc/bbfdm
|
||||
$(INSTALL_DIR) $(1)/etc/bbfdm/dmmap
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_DIR) $(1)/lib/upgrade/keep.d
|
||||
$(INSTALL_DIR) $(1)/usr/share/bbfdm/
|
||||
$(CP) $(PKG_BUILD_DIR)/libbbfdm/libbbfdm.so $(1)/usr/share/bbfdm/libbbfdm.so
|
||||
$(INSTALL_DATA) ./files/lib/upgrade/keep.d/bbf $(1)/lib/upgrade/keep.d/bbf
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/95-portmap-firewall $(1)/etc/uci-defaults/95-portmap-firewall
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/97-firewall-service $(1)/etc/uci-defaults/97-firewall-service
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/99-link-core-plugins $(1)/etc/uci-defaults/99-link-core-plugins
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/90-remove-nonexisting-microservices $(1)/etc/uci-defaults/
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/91-fix-bbfdmd-enabled-option $(1)/etc/uci-defaults/
|
||||
$(INSTALL_BIN) ./files/etc/firewall.portmap $(1)/etc/firewall.portmap
|
||||
$(INSTALL_BIN) ./files/etc/firewall.service $(1)/etc/firewall.service
|
||||
ifeq ($(findstring iopsys,$(CONFIG_BBF_VENDOR_LIST)),iopsys)
|
||||
$(BBFDM_INSTALL_CORE_PLUGIN) $(PKG_BUILD_DIR)/libbbfdm/dmtree/vendor/iopsys/libbbfdm_iopsys_ext.so $(1)
|
||||
endif
|
||||
ifeq ($(CONFIG_BBF_TR143),y)
|
||||
$(INSTALL_DIR) $(1)/usr/share/bbfdm/scripts/
|
||||
$(INSTALL_DIR) $(1)/usr/libexec/rpcd
|
||||
$(CP) $(PKG_BUILD_DIR)/libbbfdm/scripts/* $(1)/usr/share/bbfdm/scripts/
|
||||
$(LN) /usr/share/bbfdm/scripts/bbf.diag $(1)/usr/libexec/rpcd/bbf.diag
|
||||
endif
|
||||
endef
|
||||
|
||||
define Package/libbbfdm/prerm
|
||||
#!/bin/sh
|
||||
rm -rf /etc/bbfdm/dmmap/*
|
||||
exit 0
|
||||
endef
|
||||
|
||||
define Package/bbfdmd/install
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DIR) $(1)/etc/bbfdm
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bbfdmd/ubus/bbfdmd $(1)/usr/sbin/
|
||||
$(INSTALL_DATA) ./files/etc/bbfdm/input.json $(1)/etc/bbfdm/
|
||||
$(INSTALL_BIN) ./files/etc/init.d/bbfdmd $(1)/etc/init.d/bbfdmd
|
||||
$(INSTALL_BIN) ./files/etc/init.d/bbfdm.services $(1)/etc/init.d/
|
||||
$(INSTALL_CONF) ./files/etc/config/bbfdm $(1)/etc/config/bbfdm
|
||||
$(INSTALL_BIN) ./files/etc/hotplug.d/iface/85-bbfdm-sysctl $(1)/etc/hotplug.d/iface/85-bbfdm-sysctl
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(INSTALL_DIR) $(1)/usr/include/libbbfdm-api
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/libbbfdm-api/*.h $(1)/usr/include/libbbfdm-api/
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/libbbfdm-api/include/*.h $(1)/usr/include/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,libbbfdm-api))
|
||||
$(eval $(call BuildPackage,libbbfdm))
|
||||
$(eval $(call BuildPackage,bbfdmd))
|
||||
@@ -1,40 +0,0 @@
|
||||
# BBFDM configuration options and utilities
|
||||
|
||||
bbfdm provides few compile time configuration options and compile time help utility called [bbfdm.mk](./bbfdm.mk), this document aimed to explain the available usages and best practices.
|
||||
|
||||
## Compilation options
|
||||
|
||||
| Configuration option | Description | Default Value |
|
||||
| ----------------------- | ------------- | ----------- |
|
||||
| CONFIG_BBF_VENDOR_LIST | List of vendor extension directories | iopsys |
|
||||
| CONFIG_BBF_VENDOR_PREFIX | Prefix for Vendor extension datamodel objects/parameters | X_IOPSYS_EU_ |
|
||||
| CONFIG_BBF_TR143 | Enable/Add TR-143 Data Model Support | y |
|
||||
| CONFIG_BBF_TR471 | Enable/Add TR-471 Data Model Support | y |
|
||||
| CONFIG_BBF_MAX_OBJECT_INSTANCES | Maximum number of instances per object | 255 |
|
||||
| BBF_OBFUSCATION_KEY | Hash used to encode/decode in `bbf.secure` object | 371d530c95a17d1ca223a29b7a6cdc97e1135c1e0959b51106cca91a0b148b5e42742d372a359760742803f2a44bd88fca67ccdcfaeed26d02ce3b6049cb1e04 |
|
||||
|
||||
|
||||
#### BBF_OBFUSCATION_KEY
|
||||
|
||||
`bbfdm` provides an ubus object called `bbf.secure` to allow encoding/decoding the values, `bbf.secure` currently support following methods internally to encode/decode
|
||||
|
||||
- Encode/Decode using a predefined SHA512 Hash key
|
||||
- Encode/Decode using a private/public RSA key pair
|
||||
|
||||
The `BBF_OBFUSCATION_KEY` compile time configuration option used to defined the SHA512 HASH, if this option is undefined, then it usages a default value as mention in the above table.
|
||||
|
||||
User must override this parameter with their own hash value, to generate a hash user can run below command and copy the hash value to this option.
|
||||
|
||||
ex: User wants to use 'Sup3rS3cur3Passw0rd' as passkey, then can get the SHA512 sum with
|
||||
|
||||
```bash
|
||||
$ echo -n "Sup3rS3cur3Passw0rd" | sha512sum
|
||||
371d530c95a17d1ca223a29b7a6cdc97e1135c1e0959b51106cca91a0b148b5e42742d372a359760742803f2a44bd88fca67ccdcfaeed26d02ce3b6049cb1e04 -
|
||||
```
|
||||
|
||||
> Note: Additionally, user can install RSA private key in '/etc/bbfdm/certificates/private_key.pem' path, if private key is present `bbf.secure` shall use rsa private certificate for encrypt/decrypt function. In case of key not present in the pre-defined path, hash will be used for the same.
|
||||
|
||||
## Helper utility (bbfdm.mk)
|
||||
|
||||
bbfdm provides a helper utility [bbfdm.mk](./bbfdm.mk) to install datamodel plugins in bbfdm core or in microservice directory.
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2023 IOPSYS
|
||||
#
|
||||
|
||||
BBFDM_BASE_DM_PATH=/usr/share/bbfdm
|
||||
BBFDM_INPUT_PATH=/etc/bbfdm/micro_services
|
||||
BBFDM_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
BBFDM_VERSION:=$(shell grep -oP '(?<=^PKG_VERSION:=).*' ${BBFDM_DIR}/Makefile)
|
||||
BBFDM_TOOLS:=$(BUILD_DIR)/bbfdm-$(BBFDM_VERSION)/tools
|
||||
|
||||
# Utility to install the plugin in bbfdm core path with priority.
|
||||
# Its now possible to overwrite/remove core datamodel with plugin, so, if some
|
||||
# datamodel objects/parameters are present in more than one plugin, order in
|
||||
# which they loaded into memory becomes crucial, this Utility help to configure
|
||||
# a priority order in which they gets loaded in memory.
|
||||
#
|
||||
# ARGS:
|
||||
# $1 => Plugin artifact
|
||||
# $2 => package install directory
|
||||
# $3 => Priority of the installed plugin (Optional)
|
||||
#
|
||||
# Note:
|
||||
# - Last loaded plugin gets the highest priority
|
||||
#
|
||||
# Example:
|
||||
# BBFDM_INSTALL_CORE_PLUGIN ./files/etc/bbfdm/json/CWMPManagementServer.json $(1)
|
||||
#
|
||||
# Example to install plugin with priority:
|
||||
# BBFDM_INSTALL_CORE_PLUGIN ./files/etc/bbfdm/json/CWMPManagementServer.json $(1) 01
|
||||
#
|
||||
BBFDM_INSTALL_CORE_PLUGIN:=$(BBFDM_DIR)/bbfdm.sh -t $(BBFDM_TOOLS) -p
|
||||
|
||||
|
||||
# Utility to install the micro-service datamodel
|
||||
# Use Case:
|
||||
# user wants to run a datamodel micro-service, it required to install the
|
||||
# DotSO/JSON plugin into a bbf shared directory, this utility helps in
|
||||
# installing the DotSO/JSON plugin in bbfdm shared directory, and auto-generate
|
||||
# input file for the micro-service
|
||||
#
|
||||
# ARGS:
|
||||
# $1 => DotSo or Json plugin with complete path
|
||||
# $2 => package install directory
|
||||
# $3 => service name
|
||||
#
|
||||
# Note:
|
||||
# - There could be only one main plugin file, so its bind to PKG_NAME
|
||||
# - Micro-service input.json will be auto generated with this call
|
||||
#
|
||||
# Example:
|
||||
# BBFDM_INSTALL_MS_DM $(PKG_BUILD_DIR)/libcwmp.so $(1) $(PKG_NAME)
|
||||
#
|
||||
BBFDM_INSTALL_MS_DM:=$(BBFDM_DIR)/bbfdm.sh -t $(BBFDM_TOOLS) -m
|
||||
|
||||
|
||||
# Utility to install a plugins in datamodel micro-service
|
||||
#
|
||||
# ARGS:
|
||||
# $1 => DotSo or Json plugin with complete path
|
||||
# $2 => package install directory
|
||||
# $3 => service name
|
||||
#
|
||||
# Note:
|
||||
# - Use the service_name/PKG_NAME of the service in which this has to run
|
||||
#
|
||||
# Example:
|
||||
# BBFDM_INSTALL_MS_PLUGIN $(PKG_BUILD_DIR)/libxmpp.so $(1) icwmp
|
||||
#
|
||||
BBFDM_INSTALL_MS_PLUGIN:=$(BBFDM_DIR)/bbfdm.sh -t $(BBFDM_TOOLS) -m -p
|
||||
|
||||
|
||||
# Deprecated functions errors
|
||||
define BbfdmInstallPluginInMicroservice
|
||||
$(warning # BbfdmInstallPluginInMicroservice function is deprecated, use BBFDM_INSTALL_MS_PLUGIN macro #)
|
||||
$(INSTALL_DIR) $(1)
|
||||
$(INSTALL_DATA) $(2) $(1)/
|
||||
endef
|
||||
|
||||
define BbfdmInstallMicroServiceInputFile
|
||||
$(warning # function BbfdmInstallMicroServiceInputFile deprecated, input file auto generated with BBFDM_INSTALL_MS_DM #)
|
||||
$(INSTALL_DIR) $(1)/etc/bbfdm/micro_services
|
||||
$(INSTALL_DATA) $(2) $(1)/etc/bbfdm/micro_services/$(PKG_NAME).json
|
||||
endef
|
||||
|
||||
define BbfdmInstallPlugin
|
||||
$(warning # function BbfdmInstallPlugin deprecated, use BBFDM_INSTALL_CORE_PLUGIN macro #)
|
||||
$(INSTALL_DIR) $(1)/etc/bbfdm/plugins
|
||||
$(INSTALL_DATA) $(2) $(1)/etc/bbfdm/plugins/
|
||||
endef
|
||||
|
||||
define BbfdmInstallPluginWithPriority
|
||||
$(warning # fucntion BbfdmInstallPluginWithPriority deprecated, use BBFDM_INSTALL_CORE_PLUGIN #)
|
||||
$(INSTALL_DIR) $(1)/etc/bbfdm/plugins
|
||||
$(INSTALL_DATA) $(3) $(1)/etc/bbfdm/plugins/$(2)_$(shell basename ${3})
|
||||
endef
|
||||
143
bbfdm/bbfdm.sh
143
bbfdm/bbfdm.sh
@@ -1,143 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
BBFDM_BASE_DM_PATH="usr/share/bbfdm"
|
||||
BBFDM_INPUT_PATH="etc/bbfdm/micro_services"
|
||||
INPUT_TEMPLATE='{"daemon":{"service_name":"template","config":{"loglevel":"1"}}}'
|
||||
|
||||
MICRO_SERVICE=0
|
||||
PLUGIN=0
|
||||
DEST=""
|
||||
TOOLS=""
|
||||
SRC=""
|
||||
|
||||
while getopts ":t:mp" opt; do
|
||||
case ${opt} in
|
||||
t)
|
||||
TOOLS="${OPTARG}"
|
||||
;;
|
||||
m)
|
||||
MICRO_SERVICE=1
|
||||
;;
|
||||
p)
|
||||
PLUGIN=1
|
||||
;;
|
||||
?)
|
||||
echo "Invalid option: ${OPTARG}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
|
||||
SRC="${1}"
|
||||
shift
|
||||
DEST="${1}"
|
||||
shift
|
||||
DATA="${1}"
|
||||
|
||||
install_bin() {
|
||||
if ! install -m0755 ${1} ${2}; then
|
||||
echo "Failed to install bin ${1} => ${2}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_dir() {
|
||||
if ! install -d -m0755 ${1}; then
|
||||
echo "Failed to create directory ${1}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_data() {
|
||||
if ! install -m0644 ${1} ${2}; then
|
||||
echo "Failed to install ${1} => ${2}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Installing datamodel
|
||||
bbfdm_install_dm()
|
||||
{
|
||||
local src dest priority minfile
|
||||
|
||||
src="$1"
|
||||
dest="$2"
|
||||
priority="${3}"
|
||||
minfile=""
|
||||
|
||||
if [ -z ${src} ] || [ -z "${dest}" ] || [ -z "${TOOLS}" ]; then
|
||||
echo "Invalid input option for install dm $@"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${src##*.}" = "json" ]; then
|
||||
echo "Compacting BBFDM JSON file"
|
||||
minfile=$(mktemp)
|
||||
jq -c 'del(..|.description?)' ${src} > ${minfile}
|
||||
|
||||
src=${minfile}
|
||||
if dpkg -s python3-jsonschema >/dev/null 2>&1; then
|
||||
echo "Verifying bbfdm Datamodel JSON file"
|
||||
if ! ${TOOLS}/validate_json_plugin.py ${src}; then
|
||||
echo "Validation of the plugin failed ${src}"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "## Install python3-jsonschema to verify datamodel plugins"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "${priority}" ]; then
|
||||
install_bin ${src} ${dest}/${priority}_$(basename ${src})
|
||||
else
|
||||
install_bin ${src} ${dest}
|
||||
fi
|
||||
|
||||
if [ -f "${minfile}" ]; then
|
||||
rm ${minfile}
|
||||
fi
|
||||
}
|
||||
|
||||
bbfdm_generate_input()
|
||||
{
|
||||
local dest ser
|
||||
|
||||
dest_dir=${1}
|
||||
ser=${2}
|
||||
dest=${dest_dir}/${ser}.json
|
||||
|
||||
echo ${INPUT_TEMPLATE} | jq --arg service "$ser" '.daemon.service_name = $service' > ${dest}
|
||||
chmod 466 ${dest}
|
||||
}
|
||||
|
||||
if [ -z "$SRC" ] || [ -z "${DEST}" ] ; then
|
||||
echo "# BBFDM Null value in src[${SRC}], dest[${DEST}]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${MICRO_SERVICE}" -eq "1" ]; then
|
||||
if [ -z "${DATA}" ]; then
|
||||
echo "# service_name[${DATA}] not provided"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${PLUGIN}" -ne "1" ]; then
|
||||
extn="$(basename ${SRC})"
|
||||
install_dir ${DEST}/${BBFDM_BASE_DM_PATH}/micro_services
|
||||
bbfdm_install_dm ${SRC} ${DEST}/${BBFDM_BASE_DM_PATH}/micro_services/${DATA}.${extn##*.}
|
||||
|
||||
# main micro-service datamodel plugin, create an input file as well
|
||||
install_dir ${DEST}/${BBFDM_INPUT_PATH}
|
||||
bbfdm_generate_input ${DEST}/${BBFDM_INPUT_PATH}/ ${DATA}
|
||||
else
|
||||
install_dir ${DEST}/${BBFDM_BASE_DM_PATH}/micro_services/${DATA}
|
||||
bbfdm_install_dm ${SRC} ${DEST}/${BBFDM_BASE_DM_PATH}/micro_services/${DATA}/$(basename ${SRC})
|
||||
fi
|
||||
else
|
||||
if [ "${PLUGIN}" -eq "1" ]; then
|
||||
install_dir ${DEST}/${BBFDM_BASE_DM_PATH}/plugins
|
||||
bbfdm_install_dm ${SRC} ${DEST}/${BBFDM_BASE_DM_PATH}/plugins/ ${DATA}
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"daemon": {
|
||||
"config": {
|
||||
},
|
||||
"input": {
|
||||
"type": "DotSo",
|
||||
"name": "/usr/share/bbfdm/libbbfdm.so",
|
||||
"plugin_dir": "/usr/share/bbfdm/plugins"
|
||||
},
|
||||
"output": {
|
||||
"type": "UBUS",
|
||||
"name": "bbfdm"
|
||||
}
|
||||
},
|
||||
"cli": {
|
||||
"config": {
|
||||
"proto": "both",
|
||||
"instance_mode": 0
|
||||
},
|
||||
"input": {
|
||||
"type": "UBUS",
|
||||
"name": "bbfdm"
|
||||
},
|
||||
"output": {
|
||||
"type": "CLI"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
config bbfdmd 'bbfdmd'
|
||||
option enable '1'
|
||||
option loglevel '1'
|
||||
option refresh_time '120'
|
||||
option transaction_timeout '30'
|
||||
option subprocess_level '2'
|
||||
|
||||
config micro_services 'micro_services'
|
||||
option enable '1'
|
||||
option enable_core '0'
|
||||
option enable_respawn '1'
|
||||
@@ -1,74 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
log() {
|
||||
echo "${@}"|logger -t firewall.dnat -p info
|
||||
}
|
||||
|
||||
exec_cmd() {
|
||||
if ! eval "$*"; then
|
||||
log "Failed to run [$*]"
|
||||
fi
|
||||
}
|
||||
|
||||
reorder_dnat_rules() {
|
||||
nat_chains=$(iptables -t nat -S | grep -E "^-N zone[a-zA-Z0-9_]+prerouting$" | cut -d' ' -f 2)
|
||||
|
||||
for chain in ${nat_chains}; do
|
||||
# Collect empty remote host & empty dport rules
|
||||
EMPTY_HOST_PORT=$(iptables -t nat -S ${chain} | grep -E "REDIRECT|DNAT" | grep -v "\-\-dport" | grep -v "\-s ")
|
||||
if [ -n "${EMPTY_HOST_PORT}" ]; then
|
||||
echo "${EMPTY_HOST_PORT}" | while read cmd; do
|
||||
cmd1="iptables -t nat $(echo $cmd | sed 's/-A /-D /g')"
|
||||
exec_cmd $cmd1
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect empty remote host but non empty dport rules
|
||||
EMPTY_HOST=$(iptables -t nat -S ${chain} | grep -E "REDIRECT|DNAT" | grep "\-\-dport" | grep -v "\-s ")
|
||||
if [ -n "${EMPTY_HOST}" ]; then
|
||||
echo "${EMPTY_HOST}" | while read cmd; do
|
||||
cmd1="iptables -t nat $(echo $cmd | sed 's/-A /-D /g')"
|
||||
exec_cmd $cmd1
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect non empty remote host but empty dport rules
|
||||
EMPTY_PORT=$(iptables -t nat -S ${chain} | grep -E "REDIRECT|DNAT" | grep -v "\-\-dport" | grep "\-s ")
|
||||
if [ -n "${EMPTY_PORT}" ]; then
|
||||
echo "${EMPTY_PORT}" | while read cmd; do
|
||||
cmd1="iptables -t nat $(echo $cmd | sed 's/-A /-D /g')"
|
||||
exec_cmd $cmd1
|
||||
done
|
||||
fi
|
||||
|
||||
# Now add rules as per datamodel precedence shown below
|
||||
## Non empty remote host, empty dport
|
||||
## empty remote host, non empty dport
|
||||
## empty remote host, empty dport
|
||||
if [ -n "${EMPTY_PORT}" ]; then
|
||||
echo "${EMPTY_PORT}" | while read cmd; do
|
||||
cmd1="iptables -t nat $(echo $cmd)"
|
||||
exec_cmd $cmd1
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -n "${EMPTY_HOST}" ]; then
|
||||
echo "${EMPTY_HOST}" | while read cmd; do
|
||||
cmd1="iptables -t nat $(echo $cmd)"
|
||||
exec_cmd $cmd1
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -n "${EMPTY_HOST_PORT}" ]; then
|
||||
echo "${EMPTY_HOST_PORT}" | while read cmd; do
|
||||
cmd1="iptables -t nat $(echo $cmd)"
|
||||
exec_cmd $cmd1
|
||||
done
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Re-order portmapping rules according to precedence hierarchy
|
||||
reorder_dnat_rules
|
||||
@@ -1,163 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
log() {
|
||||
echo "${@}"|logger -t firewall.service -p info
|
||||
}
|
||||
|
||||
exec_cmd() {
|
||||
if ! eval "$*"; then
|
||||
log "Failed to run [$*]"
|
||||
echo "-1"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "0"
|
||||
return 0
|
||||
}
|
||||
|
||||
add_iptable_rule() {
|
||||
chain_name=$1
|
||||
protocol=$2
|
||||
dest_port=$3
|
||||
icmp_type=$4
|
||||
family=$5
|
||||
src_prefix=$6
|
||||
action=$7
|
||||
res=-1
|
||||
|
||||
cmd="-I ${chain_name}"
|
||||
|
||||
if [ -n "${protocol}" ]; then
|
||||
cmd="${cmd} -p $protocol"
|
||||
|
||||
if [ "${protocol}" -eq 41 ] || [ "${protocol}" -eq 43 ] || [ "${protocol}" -eq 44 ] ||
|
||||
[ "${protocol}" -eq 58 ] || [ "${protocol}" -eq 59 ] || [ "${protocol}" -eq 60 ]; then
|
||||
# Explicit v6 protocols
|
||||
if [ "${family}" = "ipv4" ]; then
|
||||
echo $res
|
||||
return 0
|
||||
else
|
||||
family="ipv6"
|
||||
fi
|
||||
elif [ "${protocol}" -eq 1 ]; then
|
||||
# Explicit v4 protocols
|
||||
if [ "${family}" = "ipv6" ]; then
|
||||
echo $res
|
||||
return 0
|
||||
else
|
||||
family="ipv4"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Limitation:: iptables do not accept dport without specific protocol
|
||||
count=$(echo "${dest_port}" | sed -n "/-1/p" | wc -l)
|
||||
|
||||
if [ "${count}" -eq 0 ]; then
|
||||
# dest_port not contains -1 so need to have this match criteria
|
||||
count=$(echo "${dest_port}" | wc -w)
|
||||
if [ "${count}" -gt 1 ]; then
|
||||
# multiple ports present
|
||||
port=$(echo "${dest_port}" | sed "s/ /,/g")
|
||||
cmd="${cmd} -m multiport --dports ${port}"
|
||||
else
|
||||
cmd="${cmd} --dport ${dest_port}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${family}" = "ipv4" ] || [ "${family}" = "-1" ]; then
|
||||
if [ "${protocol}" -eq 1 ] && [ "${icmp_type}" -ge 0 ]; then
|
||||
cmd="${cmd} --icmp-type ${icmp_type}"
|
||||
fi
|
||||
|
||||
if [ -z "${src_prefix}" ]; then
|
||||
res=$(exec_cmd "iptables ${cmd} -m comment --comment IPtables_service_rule -j ${action}")
|
||||
else
|
||||
#Add ipv4 sources if any
|
||||
src_list=""
|
||||
for src in $src_prefix; do
|
||||
ret=$(echo $src | grep ":" | wc -l)
|
||||
if [ "${ret}" -eq 0 ]; then
|
||||
src_list="$src,$src_list"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$src_list" ]; then
|
||||
src_list=$(echo "${src_list}" | sed "s/,$//")
|
||||
res=$(exec_cmd "iptables -s $src_list ${cmd} -m comment --comment IPtables_service_rule -j ${action}")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${family}" = "ipv6" ] || [ "${family}" = "-1" ]; then
|
||||
if [ "${protocol}" -eq 58 ] && [ "${icmp_type}" -ge 0 ]; then
|
||||
cmd="${cmd} --icmpv6-type ${icmp_type}"
|
||||
fi
|
||||
|
||||
if [ -z "${src_prefix}" ]; then
|
||||
res=$(exec_cmd "ip6tables ${cmd} -m comment --comment IP6tables_service_rule -j ${action}")
|
||||
else
|
||||
#Add ipv6 sources if any
|
||||
src_list=""
|
||||
for src in $src_prefix; do
|
||||
ret=$(echo $src | grep ":" | wc -l)
|
||||
if [ "${ret}" -eq 1 ]; then
|
||||
src_list="$src,$src_list"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$src_list" ]; then
|
||||
src_list=$(echo "${src_list}" | sed "s/,$//")
|
||||
res=$(exec_cmd "ip6tables -s $src_list ${cmd} -m comment --comment IP6tables_service_rule -j ${action}")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echo $res
|
||||
}
|
||||
|
||||
add_service() {
|
||||
local enable proto family dest_port interface target icmp_type
|
||||
|
||||
config_get enable "$1" enable "0"
|
||||
config_get icmp_type "$1" icmp_type "-1"
|
||||
config_get target "$1" target "Accept"
|
||||
config_get interface "$1" interface ""
|
||||
config_get family "$1" family "-1"
|
||||
config_get dest_port "$1" dest_port "-1"
|
||||
config_get proto "$1" proto "-1"
|
||||
config_get src_prefix "$1" src_prefix ""
|
||||
|
||||
if [ "${enable}" -eq 0 ] || [ -z "${interface}" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
action=$(echo "${target}" | tr a-z A-Z)
|
||||
chain_name="zone_${interface}_input"
|
||||
res=0
|
||||
|
||||
count=$(echo "${proto}" | sed -n "/-1/p" | wc -l)
|
||||
|
||||
if [ "${count}" -eq 0 ]; then
|
||||
# proto not contains -1 so need to have this match criteria
|
||||
for protocol in $proto; do
|
||||
res=$(add_iptable_rule "$chain_name" "$protocol" "$dest_port" "$icmp_type" "$family" "$src_prefix" "$action")
|
||||
done
|
||||
else
|
||||
# proto contains -1 so no need to have this match criteria
|
||||
res=$(add_iptable_rule "$chain_name" "" "$dest_port" "$icmp_type" "$family" "$src_prefix" "$action")
|
||||
fi
|
||||
|
||||
if [ "${res}" -ne 0 ]; then
|
||||
uci -q set firewall."${1}".status="Error"
|
||||
else
|
||||
uci -q set firewall."${1}".status=""
|
||||
fi
|
||||
|
||||
uci commit firewall
|
||||
}
|
||||
|
||||
config_load firewall
|
||||
config_foreach add_service "service"
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ "$ACTION" = "ifup" ] || exit 0
|
||||
|
||||
apply_sysctl_configuration() {
|
||||
local sysctl_conf
|
||||
|
||||
sysctl_conf="/etc/bbfdm/sysctl.conf"
|
||||
|
||||
[ -f "${sysctl_conf}" ] || touch "${sysctl_conf}"
|
||||
|
||||
sysctl -e -p "${sysctl_conf}" >&-
|
||||
}
|
||||
|
||||
|
||||
ubus -t 10 wait_for network.device
|
||||
apply_sysctl_configuration
|
||||
@@ -1,106 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=40
|
||||
STOP=8
|
||||
|
||||
USE_PROCD=1
|
||||
PROG=/usr/sbin/bbfdmd
|
||||
|
||||
BBFDM_MICROSERVICE_DIR="/etc/bbfdm/micro_services"
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
log() {
|
||||
echo "${@}"|logger -t bbfdmd.services -p info
|
||||
}
|
||||
|
||||
validate_bbfdm_micro_service_section()
|
||||
{
|
||||
uci_validate_section bbfdm micro_services "micro_services" \
|
||||
'enable:bool:true' \
|
||||
'enable_core:bool:false' \
|
||||
'enable_respawn:bool:true'
|
||||
}
|
||||
|
||||
_add_microservice()
|
||||
{
|
||||
local name path
|
||||
local enable enable_core enable_respawn
|
||||
|
||||
# Check enable from micro-service
|
||||
path="${1}"
|
||||
enable_respawn="${2}"
|
||||
enable_core="${3}"
|
||||
|
||||
name="$(basename ${path})"
|
||||
name="${name//.json}"
|
||||
|
||||
enable="$(jq '.daemon.enable//1' ${path})"
|
||||
if [ "${enable}" -eq "0" ]; then
|
||||
log "datamodel micro-service ${name} not enabled"
|
||||
return 0
|
||||
fi
|
||||
|
||||
procd_open_instance "${name}"
|
||||
|
||||
procd_set_param command ${PROG}
|
||||
procd_append_param command -m "${name}"
|
||||
|
||||
if [ "${enable_core}" -eq "1" ]; then
|
||||
procd_set_param limits core="unlimited"
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
fi
|
||||
|
||||
if [ "${enable_respawn}" -eq "1" ]; then
|
||||
procd_set_param respawn "3600" "5" "5"
|
||||
fi
|
||||
procd_close_instance "${name}"
|
||||
}
|
||||
|
||||
configure_bbfdm_micro_services()
|
||||
{
|
||||
local enable enable_core enable_respawn
|
||||
|
||||
config_load bbfdm
|
||||
validate_bbfdm_micro_service_section || {
|
||||
log "Validation of micro_service section failed"
|
||||
return 1;
|
||||
}
|
||||
|
||||
[ "${enable}" -eq "0" ] && return 0
|
||||
|
||||
if [ -d "${BBFDM_MICROSERVICE_DIR}" ]; then
|
||||
FILES="$(ls -1 ${BBFDM_MICROSERVICE_DIR}/*.json)"
|
||||
|
||||
for file in $FILES;
|
||||
do
|
||||
[ -e "$file" ] || continue
|
||||
|
||||
_add_microservice $file "${enable_respawn}" "${enable_core}"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
_start_single_service()
|
||||
{
|
||||
local service file
|
||||
|
||||
service="${1}"
|
||||
|
||||
if [ -d "${BBFDM_MICROSERVICE_DIR}" ]; then
|
||||
file="$(ls -1 ${BBFDM_MICROSERVICE_DIR}/${service}.json)"
|
||||
[ -e "$file" ] || return
|
||||
|
||||
_add_microservice $file "0" "0"
|
||||
fi
|
||||
}
|
||||
|
||||
start_service()
|
||||
{
|
||||
if [ -n "${1}" ]; then
|
||||
_start_single_service "${1}"
|
||||
else
|
||||
configure_bbfdm_micro_services
|
||||
fi
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=65
|
||||
STOP=10
|
||||
|
||||
USE_PROCD=1
|
||||
PROG=/usr/sbin/bbfdmd
|
||||
|
||||
BBFDM_JSON_INPUT="/etc/bbfdm/input.json"
|
||||
BBFDM_TEMP_DIR="/tmp/bbfdm"
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
log() {
|
||||
echo "${@}"|logger -t bbfdmd.init -p info
|
||||
}
|
||||
|
||||
validate_bbfdm_bbfdmd_section()
|
||||
{
|
||||
uci_validate_section bbfdm bbfdmd "bbfdmd" \
|
||||
'enable:bool:true' \
|
||||
'sock:string' \
|
||||
'debug:bool:false' \
|
||||
'loglevel:uinteger:1' \
|
||||
'refresh_time:uinteger:0' \
|
||||
'transaction_timeout:uinteger:30' \
|
||||
'subprocess_level:uinteger'
|
||||
}
|
||||
|
||||
configure_bbfdmd()
|
||||
{
|
||||
local enable debug sock
|
||||
local jlog jrefresh jtimeout jlevel
|
||||
|
||||
config_load bbfdm
|
||||
validate_bbfdm_bbfdmd_section || {
|
||||
log "Validation of bbfdmd section failed"
|
||||
return 1;
|
||||
}
|
||||
|
||||
[ "${enable}" -eq 0 ] && return 0
|
||||
|
||||
if [ -f "${BBFDM_JSON_INPUT}" ]; then
|
||||
echo "$(jq --arg log ${loglevel} --arg tran ${transaction_timeout} --arg refresh ${refresh_time} --arg level ${subprocess_level} '.daemon.config += {"loglevel": $log, "refresh_time": $refresh, "transaction_timeout": $tran, "subprocess_level": $level}' ${BBFDM_JSON_INPUT})" > "${BBFDM_TEMP_DIR}/input.json"
|
||||
fi
|
||||
|
||||
procd_set_param command ${PROG}
|
||||
if [ "${debug}" -eq 1 ]; then
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
fi
|
||||
|
||||
if [ -f "${sock}" ]; then
|
||||
procd_append_param command -s "${sock}"
|
||||
fi
|
||||
}
|
||||
|
||||
start_service()
|
||||
{
|
||||
mkdir -p ${BBFDM_TEMP_DIR}
|
||||
|
||||
procd_open_instance "bbfdm"
|
||||
configure_bbfdmd
|
||||
procd_set_param respawn
|
||||
procd_close_instance "bbfdm"
|
||||
}
|
||||
|
||||
service_triggers()
|
||||
{
|
||||
procd_add_reload_trigger "bbfdm"
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/bin/sh
|
||||
. /lib/functions.sh
|
||||
|
||||
remove_nonexisting_microservice() {
|
||||
local input_json
|
||||
|
||||
config_get input_json "$1" input_json ""
|
||||
|
||||
if [ -z "${input_json}" ]; then
|
||||
uci_remove bbfdm "${1}"
|
||||
fi
|
||||
}
|
||||
|
||||
config_load bbfdm
|
||||
config_foreach remove_nonexisting_microservice "micro_service"
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# rename bbfdmd enabled option to enable
|
||||
val="$(uci -q get bbfdm.bbfdmd.enabled)"
|
||||
if [ -n "${val}" ]; then
|
||||
uci -q set bbfdm.bbfdmd.enabled=""
|
||||
uci -q set bbfdm.bbfdmd.enable="${val}"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOT
|
||||
delete firewall.port_hook
|
||||
set firewall.port_hook=include
|
||||
set firewall.port_hook.path=/etc/firewall.portmap
|
||||
set firewall.port_hook.reload=1
|
||||
commit firewall
|
||||
EOT
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
bbfdm_sysctl_conf="/etc/bbfdm/sysctl.conf"
|
||||
|
||||
update_device_section() {
|
||||
local section="${1}"
|
||||
local dev_name="${2}"
|
||||
local ipv6="${3}"
|
||||
local name
|
||||
|
||||
# Get name value
|
||||
config_get name "${section}" name
|
||||
|
||||
# Retrun if the name value is different to the dev_name value
|
||||
[ "${name}" != "${dev_name}" ] && return
|
||||
|
||||
if [ "${ipv6}" = "0" ]; then
|
||||
ipv6="1"
|
||||
else
|
||||
ipv6="0"
|
||||
fi
|
||||
|
||||
# Add ipv6 option
|
||||
uci -q set network.${section}.ipv6="${ipv6}"
|
||||
}
|
||||
|
||||
parse_bbfdm_sysctl_conf_file() {
|
||||
# Check if the file exists
|
||||
[ -f "${bbfdm_sysctl_conf}" ] || return
|
||||
|
||||
# Create a temporary file
|
||||
tmpfile=$(mktemp)
|
||||
|
||||
# Load network config
|
||||
config_load network
|
||||
|
||||
# Read each line of the file
|
||||
while read -r line; do
|
||||
if echo "$line" | grep -Eq '^net\.ipv6\.conf\.(.+)\.disable_ipv6=([0-1])$'; then
|
||||
name=$(echo "$line" | sed -n 's/^net\.ipv6\.conf\.\(.*\)\.disable_ipv6=[0-1]$/\1/p')
|
||||
value=$(echo "$line" | sed -n 's/^net\.ipv6\.conf\.\(.*\)\.disable_ipv6=\([0-1]\)$/\2/p')
|
||||
|
||||
config_foreach update_device_section device "${name}" "${value}"
|
||||
else
|
||||
# If the line doesn't match, preserve it in the temporary file
|
||||
echo "$line" >> "$tmpfile"
|
||||
fi
|
||||
done < "${bbfdm_sysctl_conf}"
|
||||
|
||||
# Replace the original file with the modified content
|
||||
mv "$tmpfile" "${bbfdm_sysctl_conf}"
|
||||
|
||||
# Apply the changes
|
||||
uci commit network
|
||||
sysctl -e -p "${bbfdm_sysctl_conf}" >&-
|
||||
}
|
||||
|
||||
parse_bbfdm_sysctl_conf_file
|
||||
|
||||
exit 0
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOT
|
||||
delete firewall.service_hook
|
||||
set firewall.service_hook=include
|
||||
set firewall.service_hook.path=/etc/firewall.service
|
||||
set firewall.service_hook.reload=1
|
||||
commit firewall
|
||||
EOT
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
UNIFIED_PATH="/usr/share/bbfdm/plugins/"
|
||||
|
||||
log() {
|
||||
echo "$@" | logger -t bbfdm.uci-default -p info
|
||||
}
|
||||
|
||||
# Link JSON plugins
|
||||
for f in `ls -1 /etc/bbfdm/json/*.json`; do
|
||||
log "# BBFDM JSON plugin ${f} not aligned #"
|
||||
ln -s ${f} "${UNIFIED_PATH}"
|
||||
done
|
||||
|
||||
# Link DotSo plugins
|
||||
for f in `ls -1 /usr/lib/bbfdm/*.so`; do
|
||||
log "# BBFDM DotSO plugin ${f} not aligned #"
|
||||
ln -s ${f} "${UNIFIED_PATH}"
|
||||
done
|
||||
|
||||
# Link JSON plugins
|
||||
for f in `ls -1 /etc/bbfdm/plugins/*.json`; do
|
||||
log "# BBFDM JSON plugin ${f} not aligned #"
|
||||
ln -s ${f} "${UNIFIED_PATH}"
|
||||
done
|
||||
|
||||
# Link DotSo plugins
|
||||
for f in `ls -1 /etc/bbfdm/plugins/*.so`; do
|
||||
log "# BBFDM DotSO plugin ${f} not aligned #"
|
||||
ln -s ${f} "${UNIFIED_PATH}"
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
/etc/bbfdm/sysctl.conf
|
||||
@@ -1,28 +1,33 @@
|
||||
#
|
||||
# Copyright (C) 2022 iopsys Software Solutions AB
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=bulkdata
|
||||
PKG_VERSION:=2.1.10
|
||||
PKG_VERSION:=2.0.5
|
||||
|
||||
LOCAL_DEV:=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/bulkdata.git
|
||||
PKG_SOURCE_VERSION:=e472e90feec31d9f318ea8c732ab564002e25db1
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/bulkdata.git
|
||||
PKG_SOURCE_VERSION:=33a6648de9ee0af33c44518656b56b0a30b6c1ab
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
endif
|
||||
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_LICENSE:=GPL-2.0-only
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
PKG_BUILD_DEPENDS:=bbf
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(TOPDIR)/feeds/iopsys/bbfdm/bbfdm.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=utils
|
||||
@@ -44,14 +49,10 @@ endif
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bulkdatad $(1)/usr/sbin/
|
||||
$(INSTALL_DATA) ./files/etc/config/bulkdata $(1)/etc/config/
|
||||
$(INSTALL_BIN) ./files/etc/init.d/bulkdatad $(1)/etc/init.d/
|
||||
$(INSTALL_DATA) ./files/etc/uci-defaults/95-bulkdata-translation-options $(1)/etc/uci-defaults/
|
||||
$(BBFDM_INSTALL_MS_DM) $(PKG_BUILD_DIR)/bbf_plugin/bulkdata.json $(1) $(PKG_NAME)
|
||||
$(INSTALL_DIR) $(1)/usr/lib/bbfdm
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bbf_plugin/*.so $(1)/usr/lib/bbfdm
|
||||
$(CP) ./files/* $(1)/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
|
||||
@@ -1,960 +0,0 @@
|
||||
{
|
||||
"json_plugin_version": 2,
|
||||
"Device.BulkData.": {
|
||||
"type": "object",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"access": false,
|
||||
"array": false,
|
||||
"Enable": {
|
||||
"type": "boolean",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "boolean",
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "bulkdata",
|
||||
"section": {
|
||||
"name": "bulkdata"
|
||||
},
|
||||
"option": {
|
||||
"name": "enable"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"Status": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"enumerations": [
|
||||
"Enabled",
|
||||
"Disabled",
|
||||
"Error"
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "bulkdata",
|
||||
"section": {
|
||||
"name": "bulkdata"
|
||||
},
|
||||
"option": {
|
||||
"name": "enable"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"MinReportingInterval": {
|
||||
"type": "unsignedInt",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"default": "0",
|
||||
"datatype": "unsignedInt",
|
||||
"unit": "seconds"
|
||||
},
|
||||
"Protocols": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"default": "HTTP",
|
||||
"list": {
|
||||
"datatype": "string",
|
||||
"enumerations": [
|
||||
"Streaming",
|
||||
"File",
|
||||
"HTTP",
|
||||
"MQTT"
|
||||
]
|
||||
}
|
||||
},
|
||||
"EncodingTypes": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"default": "JSON,CSV",
|
||||
"list": {
|
||||
"datatype": "string",
|
||||
"enumerations": [
|
||||
"XML",
|
||||
"XDR",
|
||||
"CSV",
|
||||
"JSON"
|
||||
]
|
||||
}
|
||||
},
|
||||
"ParameterWildCardSupported": {
|
||||
"type": "boolean",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"default": "1",
|
||||
"datatype": "boolean"
|
||||
},
|
||||
"MaxNumberOfProfiles": {
|
||||
"type": "int",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"default": "-1",
|
||||
"datatype": "int",
|
||||
"range": [
|
||||
{
|
||||
"min": -1
|
||||
}
|
||||
]
|
||||
},
|
||||
"MaxNumberOfParameterReferences": {
|
||||
"type": "int",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"default": "-1",
|
||||
"datatype": "int",
|
||||
"range": [
|
||||
{
|
||||
"min": -1
|
||||
}
|
||||
]
|
||||
},
|
||||
"ProfileNumberOfEntries": {
|
||||
"type": "unsignedInt",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedInt",
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "bulkdata",
|
||||
"section": {
|
||||
"type": "profile"
|
||||
},
|
||||
"option": {
|
||||
"name": "@Count"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"Device.BulkData.Profile.{i}.": {
|
||||
"type": "object",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"access": true,
|
||||
"array": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "bulkdata",
|
||||
"section": {
|
||||
"type": "profile"
|
||||
},
|
||||
"dmmapfile": "dmmap_bulkdata"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enable": {
|
||||
"type": "boolean",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "boolean",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "enable"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Alias": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "Alias",
|
||||
"range": [
|
||||
{
|
||||
"max": 64
|
||||
}
|
||||
],
|
||||
"flags": [
|
||||
"Unique"
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "alias"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Name": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"range": [
|
||||
{
|
||||
"max": 255
|
||||
}
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "name"
|
||||
}
|
||||
]
|
||||
},
|
||||
"NumberOfRetainedFailedReports": {
|
||||
"type": "int",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "int",
|
||||
"range": [
|
||||
{
|
||||
"min": -1
|
||||
}
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "nbre_of_retained_failed_reports"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Protocol": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"enumerations": [
|
||||
"Streaming",
|
||||
"File",
|
||||
"HTTP"
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "protocol"
|
||||
}
|
||||
]
|
||||
},
|
||||
"EncodingType": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"enumerations": [
|
||||
"XML",
|
||||
"XDR",
|
||||
"CSV",
|
||||
"JSON"
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "encoding_type"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ReportingInterval": {
|
||||
"type": "unsignedInt",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedInt",
|
||||
"range": [
|
||||
{
|
||||
"min": 1
|
||||
}
|
||||
],
|
||||
"unit": "seconds",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "reporting_interval"
|
||||
}
|
||||
]
|
||||
},
|
||||
"TimeReference": {
|
||||
"type": "dateTime",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "dateTime",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "time_reference"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ParameterNumberOfEntries": {
|
||||
"type": "unsignedInt",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedInt",
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "bulkdata",
|
||||
"section": {
|
||||
"type": "profile_parameter"
|
||||
},
|
||||
"option": {
|
||||
"name": "@Count"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"Device.BulkData.Profile.{i}.Parameter.{i}.": {
|
||||
"type": "object",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"access": true,
|
||||
"array": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "bulkdata",
|
||||
"section": {
|
||||
"type": "profile_parameter"
|
||||
},
|
||||
"dmmapfile": "dmmap_bulkdata"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Name": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"range": [
|
||||
{
|
||||
"max": 64
|
||||
}
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "name"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Reference": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"range": [
|
||||
{
|
||||
"max": 256
|
||||
}
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "reference"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"Device.BulkData.Profile.{i}.CSVEncoding.": {
|
||||
"type": "object",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"access": false,
|
||||
"array": false,
|
||||
"FieldSeparator": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "csv_encoding_field_separator"
|
||||
}
|
||||
]
|
||||
},
|
||||
"RowSeparator": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "csv_encoding_row_separator"
|
||||
}
|
||||
]
|
||||
},
|
||||
"EscapeCharacter": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "csv_encoding_escape_character"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ReportFormat": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"enumerations": [
|
||||
"ParameterPerRow",
|
||||
"ParameterPerColumn"
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "csv_encoding_report_format"
|
||||
}
|
||||
]
|
||||
},
|
||||
"RowTimestamp": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"enumerations": [
|
||||
"Unix-Epoch",
|
||||
"ISO-8601",
|
||||
"None"
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "csv_encoding_row_time_stamp"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"Device.BulkData.Profile.{i}.JSONEncoding.": {
|
||||
"type": "object",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"access": false,
|
||||
"array": false,
|
||||
"ReportFormat": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"enumerations": [
|
||||
"ObjectHierarchy",
|
||||
"NameValuePair"
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "json_encoding_report_format"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ReportTimestamp": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"enumerations": [
|
||||
"Unix-Epoch",
|
||||
"ISO-8601",
|
||||
"None"
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "json_encoding_report_time_stamp"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"Device.BulkData.Profile.{i}.HTTP.": {
|
||||
"type": "object",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"access": false,
|
||||
"array": false,
|
||||
"URL": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "URL",
|
||||
"range": [
|
||||
{
|
||||
"max": 2048
|
||||
}
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "http_url"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Username": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"range": [
|
||||
{
|
||||
"max": 256
|
||||
}
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "http_username"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Password": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"range": [
|
||||
{
|
||||
"max": 256
|
||||
}
|
||||
],
|
||||
"flags": [
|
||||
"Secure"
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "http_password"
|
||||
}
|
||||
]
|
||||
},
|
||||
"CompressionsSupported": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"default": "GZIP",
|
||||
"list": {
|
||||
"datatype": "string",
|
||||
"enumerations": [
|
||||
"GZIP",
|
||||
"Compress",
|
||||
"Deflate"
|
||||
]
|
||||
}
|
||||
},
|
||||
"Compression": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"enumerations": [
|
||||
"GZIP",
|
||||
"Compress",
|
||||
"Deflate"
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "http_compression"
|
||||
}
|
||||
]
|
||||
},
|
||||
"MethodsSupported": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"default": "POST,PUT",
|
||||
"list": {
|
||||
"datatype": "string",
|
||||
"enumerations": [
|
||||
"POST",
|
||||
"PUT"
|
||||
]
|
||||
}
|
||||
},
|
||||
"Method": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"enumerations": [
|
||||
"POST",
|
||||
"PUT"
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "http_method"
|
||||
}
|
||||
]
|
||||
},
|
||||
"UseDateHeader": {
|
||||
"type": "boolean",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "boolean",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "http_use_date_header"
|
||||
}
|
||||
]
|
||||
},
|
||||
"RetryEnable": {
|
||||
"type": "boolean",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "boolean",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "http_retry_enable"
|
||||
}
|
||||
]
|
||||
},
|
||||
"RetryMinimumWaitInterval": {
|
||||
"type": "unsignedInt",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedInt",
|
||||
"range": [
|
||||
{
|
||||
"min": 1,
|
||||
"max": 65535
|
||||
}
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "http_retry_minimum_wait_interval"
|
||||
}
|
||||
]
|
||||
},
|
||||
"RetryIntervalMultiplier": {
|
||||
"type": "unsignedInt",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedInt",
|
||||
"range": [
|
||||
{
|
||||
"min": 1000,
|
||||
"max": 65535
|
||||
}
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "http_retry_interval_multiplier"
|
||||
}
|
||||
]
|
||||
},
|
||||
"RequestURIParameterNumberOfEntries": {
|
||||
"type": "unsignedInt",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedInt",
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "bulkdata",
|
||||
"section": {
|
||||
"type": "profile_http_request_uri_parameter"
|
||||
},
|
||||
"option": {
|
||||
"name": "@Count"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"PersistAcrossReboot": {
|
||||
"type": "boolean",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "boolean",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "http_persist_across_reboot"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Device.BulkData.Profile.{i}.HTTP.RequestURIParameter.{i}.": {
|
||||
"type": "object",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"access": true,
|
||||
"array": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "bulkdata",
|
||||
"section": {
|
||||
"type": "profile_http_request_uri_parameter"
|
||||
},
|
||||
"dmmapfile": "dmmap_bulkdata"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Name": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"range": [
|
||||
{
|
||||
"max": 64
|
||||
}
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "name"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Reference": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"range": [
|
||||
{
|
||||
"max": 256
|
||||
}
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "reference"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,26 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=60
|
||||
START=99
|
||||
STOP=10
|
||||
|
||||
USE_PROCD=1
|
||||
PROG="/usr/sbin/bulkdatad"
|
||||
|
||||
start_service() {
|
||||
local enable
|
||||
local enable=$(uci -q get bulkdata.bulkdata.enable)
|
||||
|
||||
config_load bulkdata
|
||||
config_get_bool enable bulkdata enable 1
|
||||
|
||||
[ "$enable" -eq "1" ] && {
|
||||
procd_open_instance "bulkdata"
|
||||
procd_set_param command "$PROG"
|
||||
procd_set_param respawn
|
||||
procd_close_instance "bulkdata"
|
||||
[ "$enable" != "1" ] && {
|
||||
return 0
|
||||
}
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG"
|
||||
procd_set_param respawn "3" "7" "0"
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
boot() {
|
||||
start
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
|
||||
@@ -16,8 +16,8 @@ get_next_count()
|
||||
fi
|
||||
|
||||
while [ "${found}" -ne 1 ]; do
|
||||
uci -q get "${config}"."${default_name}"_${count} >/dev/null
|
||||
if [ "$?" -eq 0 ]; then
|
||||
uci -q get ${config}.${default_name}_${count} >/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
count=$((count + 1))
|
||||
else
|
||||
found=1;
|
||||
@@ -39,8 +39,8 @@ translate_profile_id_to_profile_name() {
|
||||
|
||||
[ "${curr_profile_id}" != "${profile_id}" ] && return
|
||||
|
||||
uci -q set bulkdata."${section}".profile_name="${profile_name}"
|
||||
uci -q set bulkdata."${section}".profile_id=""
|
||||
uci -q set bulkdata.${section}.profile_name="${profile_name}"
|
||||
uci -q set bulkdata.${section}.profile_id=""
|
||||
}
|
||||
|
||||
update_profile_sections() {
|
||||
@@ -54,7 +54,7 @@ update_profile_sections() {
|
||||
|
||||
case "${section}" in
|
||||
"cfg"*)
|
||||
profile_name="$(get_next_count bulkdata "${default}" ${PROFILE_COUNT})"
|
||||
profile_name="$(get_next_count bulkdata ${default} ${PROFILE_COUNT})"
|
||||
uci_rename bulkdata "${section}" "${profile_name}"
|
||||
;;
|
||||
esac
|
||||
@@ -62,7 +62,7 @@ update_profile_sections() {
|
||||
|
||||
[ -n "$profile_name" ] && section="${profile_name}"
|
||||
|
||||
uci -q set bulkdata."${section}".profile_id=""
|
||||
uci -q set bulkdata.${section}.profile_id=""
|
||||
|
||||
config_foreach translate_profile_id_to_profile_name profile_parameter "${profile_id}" "${profile_name}"
|
||||
config_foreach translate_profile_id_to_profile_name profile_http_request_uri_parameter "${profile_id}" "${profile_name}"
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=98
|
||||
STOP=20
|
||||
|
||||
USE_PROCD=1
|
||||
|
||||
start_service() {
|
||||
if [ -e "/etc/config/mapagent" -o -e "/etc/config/mapcontroller" ]; then
|
||||
config_load mapagent
|
||||
config_get_bool agent_enabled agent enabled 1
|
||||
config_load mapcontroller
|
||||
config_get_bool controller_enabled controller enabled 1
|
||||
|
||||
if [ $agent_enabled -eq 1 -o $controller_enabled -eq 1 ]; then
|
||||
procd_open_instance
|
||||
procd_set_param command "/usr/sbin/capiagent" "-p 9000"
|
||||
procd_set_param limits core="unlimited"
|
||||
#procd_set_param respawn
|
||||
#procd_set_param stdout 1
|
||||
#procd_set_param stderr 1
|
||||
procd_close_instance
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
service_triggers()
|
||||
{
|
||||
procd_add_reload_trigger "capiagent"
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2020-2024 IOPSYS Software Solutions AB
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=csmngr
|
||||
PKG_VERSION:=0.0.8
|
||||
|
||||
LOCAL_DEV=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=ca899eb18b5bec38f4b8b4d08b42d89fef965c13
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/csmngr.git
|
||||
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_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu>
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
PKG_CONFIG_DEPENDS := \
|
||||
CONFIG_PACKAGE_libwifiutils \
|
||||
CONFIG_PACKAGE_libwifi
|
||||
|
||||
PKG_BUILD_DEPENDS := libwifi
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
||||
MAKE_PATH:=src
|
||||
|
||||
define Package/csmngr
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=WiFi channel selection manager
|
||||
DEPENDS:=+libwifiutils +libwifi +libuci +libubox +ubus +libnl-genl
|
||||
endef
|
||||
|
||||
define Package/csmngr/description
|
||||
WiFi Auto Channel Selection manager.
|
||||
endef
|
||||
|
||||
TARGET_CFLAGS += \
|
||||
-I$(STAGING_DIR)/usr/include \
|
||||
-I$(STAGING_DIR)/usr/include/libnl3 \
|
||||
-D_GNU_SOURCE
|
||||
|
||||
ifeq ($(LOCAL_DEV),1)
|
||||
define Build/Prepare
|
||||
rsync -r --exclude=.* ~/git/csmngr/ $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
endif
|
||||
|
||||
define Package/csmngr/install
|
||||
$(CP) ./files/* $(1)/
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/csmngr $(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,csmngr))
|
||||
@@ -1,16 +0,0 @@
|
||||
if PACKAGE_ddnsmngr
|
||||
choice
|
||||
prompt "Select backend for dynamic DNS management"
|
||||
default DDNSMNGR_BACKEND_DDNSSCRIPT
|
||||
depends on PACKAGE_ddnsmngr
|
||||
help
|
||||
Select which package to use for dynamic DNS support
|
||||
|
||||
config DDNSMNGR_BACKEND_DDNSSCRIPT
|
||||
bool "Use ddns_script"
|
||||
|
||||
config DDNSMNGR_BACKEND_INADYN
|
||||
bool "Use inadyn"
|
||||
|
||||
endchoice
|
||||
endif
|
||||
@@ -1,77 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2024 IOPSYS
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ddnsmngr
|
||||
PKG_VERSION:=1.0.4
|
||||
|
||||
LOCAL_DEV:=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/network/ddnsmngr.git
|
||||
PKG_SOURCE_VERSION:=d0d37df44644ef2c1a0b11d3a4f92dc694ae1010
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
endif
|
||||
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
PKG_CONFIG_DEPENDS:=CONFIG_DDNSMNGR_BACKEND_DDNSSCRIPT CONFIG_DDNSMNGR_BACKEND_INADYN
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(TOPDIR)/feeds/iopsys/bbfdm/bbfdm.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=TRx69
|
||||
TITLE:=Dynamic DNS manager
|
||||
DEPENDS:=+libbbfdm-api +DDNSMNGR_BACKEND_DDNSSCRIPT:ddns-scripts +DDNSMNGR_BACKEND_INADYN:inadyn
|
||||
MENU:=1
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
MAKE_PATH:=src
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
Manage dynamic DNS updation and provides Device.DynamicDNS. datamodel object based on TR181-2.16
|
||||
endef
|
||||
|
||||
ifeq ($(LOCAL_DEV),1)
|
||||
define Build/Prepare
|
||||
$(CP) -rf ~/git/ddnsmngr/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
endif
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/etc/ddnsmngr/ddns
|
||||
$(INSTALL_DIR) $(1)/etc/ddnsmngr/servers
|
||||
$(INSTALL_DIR) $(1)/usr/lib/ddnsmngr
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_DIR) $(1)/usr/libexec/rpcd
|
||||
$(INSTALL_DATA) ./files/etc/config/ddnsmngr $(1)/etc/config/ddnsmngr
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/01-ddns-config-migrate $(1)/etc/uci-defaults/
|
||||
$(INSTALL_BIN) ./files/etc/init.d/ddnsmngr $(1)/etc/init.d/ddnsmngr
|
||||
ifeq ($(CONFIG_DDNSMNGR_BACKEND_DDNSSCRIPT),y)
|
||||
$(INSTALL_BIN) ./files/usr/lib/ddns_script/ddnsmngr_service.sh $(1)/usr/lib/ddnsmngr/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/files/ddns-script/usr/lib/ddnsmngr/ddnsmngr_updater.sh $(1)/usr/lib/ddnsmngr/
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/files/ddns-script/server/* $(1)/etc/ddnsmngr/servers
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/files/ddns-script/usr/libexec/rpcd/ddnsmngr $(1)/usr/libexec/rpcd/ddnsmngr
|
||||
endif
|
||||
ifeq ($(CONFIG_DDNSMNGR_BACKEND_INADYN),y)
|
||||
$(INSTALL_BIN) ./files/usr/lib/inadyn/ddnsmngr_service.sh $(1)/usr/lib/ddnsmngr/
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/files/inadyn/server/* $(1)/etc/ddnsmngr/servers
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/files/inadyn/usr/libexec/rpcd/ddnsmngr $(1)/usr/libexec/rpcd/ddnsmngr
|
||||
endif
|
||||
$(BBFDM_INSTALL_MS_DM) $(PKG_BUILD_DIR)/src/libddnsmngr.so $(1) $(PKG_NAME)
|
||||
endef
|
||||
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
@@ -1,23 +0,0 @@
|
||||
config ddnsmngr 'global'
|
||||
option configfile '/var/run/ddnsmngr/ddnsmngr.json'
|
||||
option ddns_dateformat '%F %R'
|
||||
option ddns_rundir '/var/run/ddnsmngr'
|
||||
option ddns_logdir '/var/log/ddnsmngr'
|
||||
option ddns_loglines '250'
|
||||
option upd_privateip '0'
|
||||
option use_curl '1'
|
||||
|
||||
config server 'ddns_server_1'
|
||||
option enabled '1'
|
||||
option service 'dynu.com'
|
||||
option name 'dynu.com'
|
||||
|
||||
config server 'ddns_server_2'
|
||||
option enabled '1'
|
||||
option service 'dyndns.org'
|
||||
option name 'dyndns.org'
|
||||
|
||||
config server 'ddns_server_3'
|
||||
option enabled '1'
|
||||
option service 'zoneedit.com'
|
||||
option name 'zoneedit.com'
|
||||
@@ -1,26 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=80
|
||||
STOP=10
|
||||
USE_PROCD=1
|
||||
|
||||
. /usr/lib/ddnsmngr/ddnsmngr_service.sh
|
||||
|
||||
start_service() {
|
||||
start_ddnsmngr_service
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
stop_ddnsmngr_service
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
sleep 1
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger ddnsmngr
|
||||
add_ddnsmngr_triggers
|
||||
}
|
||||
@@ -1,170 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
cl_id=1
|
||||
srv_id=1
|
||||
|
||||
function get_ddns_config_option() {
|
||||
local val
|
||||
|
||||
val="$(uci -q get ddns.${1}.${2})"
|
||||
|
||||
if [ -z "${val}" ] && [ -n "${3}" ]; then
|
||||
val="${3}"
|
||||
fi
|
||||
|
||||
echo "${val}"
|
||||
}
|
||||
|
||||
function config_supported_service() {
|
||||
if ! uci -q get ddnsmngr.global >/dev/null 2>&1; then
|
||||
uci -q set ddnsmngr.global="ddnsmngr"
|
||||
fi
|
||||
|
||||
servers=""
|
||||
|
||||
for i in $(find /etc/ddnsmngr/servers/ -name '*.json' | cut -d'/' -f 5 | sed "s/.json//")
|
||||
do
|
||||
if [ -z "${servers}" ]; then
|
||||
servers="${i}"
|
||||
else
|
||||
servers="${servers},${i}"
|
||||
fi
|
||||
done
|
||||
|
||||
uci -q set ddnsmngr.global.supported_services="${servers}"
|
||||
}
|
||||
|
||||
function migrate_service_section() {
|
||||
client_sec=""
|
||||
enabled="$(get_ddns_config_option ${1} enabled "0")"
|
||||
service_name="$(get_ddns_config_option ${1} service_name)"
|
||||
interface="$(get_ddns_config_option ${1} interface)"
|
||||
ip_network="$(get_ddns_config_option ${1} ip_network)"
|
||||
username="$(get_ddns_config_option ${1} username)"
|
||||
password="$(get_ddns_config_option ${1} password)"
|
||||
lookup_host="$(get_ddns_config_option ${1} lookup_host)"
|
||||
use_ipv6="$(get_ddns_config_option ${1} use_ipv6 "0")"
|
||||
force_ipversion="$(get_ddns_config_option ${1} force_ipversion "0")"
|
||||
use_https="$(get_ddns_config_option ${1} use_https "0")"
|
||||
force_dnstcp="$(get_ddns_config_option ${1} force_dnstcp "0")"
|
||||
|
||||
if [ -z "${service_name}" ]; then
|
||||
uci -q delete ddns."${1}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# check server file is present in device
|
||||
if [ ! -f "/etc/ddnsmngr/servers/${service_name}.json" ]; then
|
||||
uci -q delete ddns."${1}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Check if client section is already added for this service
|
||||
clients=$(uci -q show ddnsmngr | grep "=client")
|
||||
client_count=$(echo "${clients}" | wc -l)
|
||||
|
||||
tmp=0
|
||||
while [ $tmp -lt $client_count ]
|
||||
do
|
||||
mngr_serv="$(uci -q get ddnsmngr.@client[$tmp].service_name)"
|
||||
mngr_intf="$(uci -q get ddnsmngr.@client[$tmp].interface)"
|
||||
mngr_netw="$(uci -q get ddnsmngr.@client[$tmp].ip_network)"
|
||||
mngr_user="$(uci -q get ddnsmngr.@client[$tmp].username)"
|
||||
mngr_ipv6="$(uci -q get ddnsmngr.@client[$tmp].use_ipv6)"
|
||||
mngr_forceip="$(uci -q get ddnsmngr.@client[$tmp].force_ipversion)"
|
||||
mngr_https="$(uci -q get ddnsmngr.@client[$tmp].use_https)"
|
||||
mngr_dnstcp="$(uci -q get ddnsmngr.@client[$tmp].force_dnstcp)"
|
||||
|
||||
[ -z "${mngr_ipv6}" ] && mngr_ipv6="0"
|
||||
[ -z "${mngr_forceip}" ] && mngr_forceip="0"
|
||||
[ -z "${mngr_https}" ] && mngr_https="0"
|
||||
[ -z "${mngr_dnstcp}" ] && mngr_dnstcp="0"
|
||||
|
||||
if [ "${mngr_serv}" == "${service_name}" ] && [ "${mngr_intf}" == "${interface}" ] && \
|
||||
[ "${mngr_netw}" == "${ip_network}" ] && [ "${mngr_user}" == "${username}" ] && \
|
||||
[ "${mngr_ipv6}" == "${use_ipv6}" ] && [ "${mngr_forceip}" == "${force_ipversion}" ] && \
|
||||
[ "${mngr_https}" == "${use_https}" ] && [ "${mngr_dnstcp}" == "${force_dnstcp}" ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
tmp=$(( tmp + 1 ))
|
||||
done
|
||||
|
||||
if [ $tmp -ne $client_count ]; then
|
||||
i=0
|
||||
for client in $clients; do
|
||||
if [ $i -eq $tmp ]; then
|
||||
client_sec="$(echo $client | cut -d'=' -f 1 | cut -d'.' -f 2)"
|
||||
break
|
||||
fi
|
||||
i=$(( i + 1 ))
|
||||
done
|
||||
|
||||
if [ $enabled -eq 1 ]; then
|
||||
uci -q set ddnsmngr."${client_sec}".enabled="1"
|
||||
fi
|
||||
else
|
||||
client_sec=ddns_mig_client_"${cl_id}"
|
||||
|
||||
uci -q set ddnsmngr."${client_sec}"="client"
|
||||
uci -q set ddnsmngr."${client_sec}".enabled="${enabled}"
|
||||
uci -q set ddnsmngr."${client_sec}".service_name="${service_name}"
|
||||
uci -q set ddnsmngr."${client_sec}".interface="${interface}"
|
||||
uci -q set ddnsmngr."${client_sec}".ip_network="${ip_network}"
|
||||
uci -q set ddnsmngr."${client_sec}".username="${username}"
|
||||
uci -q set ddnsmngr."${client_sec}".password="${password}"
|
||||
uci -q set ddnsmngr."${client_sec}".use_ipv6="${use_ipv6}"
|
||||
uci -q set ddnsmngr."${client_sec}".force_ipversion="${force_ipversion}"
|
||||
uci -q set ddnsmngr."${client_sec}".use_https="${use_https}"
|
||||
uci -q set ddnsmngr."${client_sec}".force_dnstcp="${force_dnstcp}"
|
||||
|
||||
cl_id=$(( cl_id + 1 ))
|
||||
|
||||
# add server section if not added
|
||||
servers=$(uci -q show ddnsmngr | grep "service=\'${service_name}\'")
|
||||
if [ -z "${servers}" ]; then
|
||||
server_sec=ddns_mig_server_"${srv_id}"
|
||||
uci -q set ddnsmngr."${server_sec}"="server"
|
||||
uci -q set ddnsmngr."${server_sec}".enabled="1"
|
||||
uci -q set ddnsmngr."${server_sec}".service="${service_name}"
|
||||
uci -q set ddnsmngr."${server_sec}".name="${service_name}"
|
||||
|
||||
srv_id=$(( srv_id + 1 ))
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# if lookup_host is set then add host section
|
||||
if [ -n "${lookup_host}" ] && [ -n "${client_sec}" ]; then
|
||||
# check number of hosts present for this client
|
||||
host_count=$(uci -q show ddnsmngr | grep "dm_parent=\'${client_sec}\'" | wc -l)
|
||||
host_ix=$(( host_count + 1 ))
|
||||
host_sec="${client_sec}"_host_"${host_ix}"
|
||||
|
||||
uci -q set ddnsmngr."${host_sec}"="host"
|
||||
uci -q set ddnsmngr."${host_sec}".enabled="${enabled}"
|
||||
uci -q set ddnsmngr."${host_sec}".lookup_host="${lookup_host}"
|
||||
uci -q set ddnsmngr."${host_sec}".dm_parent="${client_sec}"
|
||||
fi
|
||||
|
||||
uci -q delete ddns."${1}"
|
||||
}
|
||||
|
||||
function migrate_ddns_config() {
|
||||
if [ ! -f "/etc/config/ddnsmngr" ]; then
|
||||
# Create ddnsmngr config file
|
||||
touch /etc/config/ddnsmngr
|
||||
fi
|
||||
|
||||
config_supported_service
|
||||
|
||||
config_load ddns
|
||||
config_foreach migrate_service_section service
|
||||
|
||||
uci -q commit ddns
|
||||
uci -q commit ddnsmngr
|
||||
}
|
||||
|
||||
migrate_ddns_config
|
||||
@@ -1,169 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
RUNDIR="/var/run/ddnsmngr"
|
||||
LOGDIR="/var/log/ddnsmngr"
|
||||
PROG="/usr/lib/ddnsmngr/ddnsmngr_updater.sh"
|
||||
CONFIGFILE="/var/run/ddnsmngr/ddnsmngr.json"
|
||||
CLIENT_INTFS=""
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
log() {
|
||||
echo "$*"|logger -t ddnsmngr.init -p debug
|
||||
}
|
||||
|
||||
validate_host_section() {
|
||||
uci_validate_section ddnsmngr host "${1}" \
|
||||
'enabled:bool:0' \
|
||||
'lookup_host:string' \
|
||||
'dm_parent:string'
|
||||
}
|
||||
|
||||
validate_client_section() {
|
||||
uci_validate_section ddnsmngr client "${1}" \
|
||||
'enabled:bool:0' \
|
||||
'service_name:string' \
|
||||
'interface:string' \
|
||||
'ip_network:string' \
|
||||
'username:string' \
|
||||
'password:string' \
|
||||
'use_https:bool:0' \
|
||||
'force_dnstcp:bool:0' \
|
||||
'use_ipv6:bool:0' \
|
||||
'force_ipversion:bool:0'
|
||||
}
|
||||
|
||||
add_object() {
|
||||
local enabled lookup_host dm_parent use_ipv6 force_ipversion proc_info_file
|
||||
local service_name interface ip_network username password use_https force_dnstcp
|
||||
|
||||
validate_host_section "${1}" || {
|
||||
log "Validation of host section failed"
|
||||
return 0
|
||||
}
|
||||
|
||||
if [ "${enabled}" -ne 1 ] || [ -z "${dm_parent}" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
validate_client_section "${dm_parent}" || {
|
||||
log "Validation of client section failed"
|
||||
return 0
|
||||
}
|
||||
|
||||
if [ "${enabled}" -ne 1 ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
service_name=$(uci -q get ddnsmngr.${dm_parent}.service_name)
|
||||
if [ -z "${service_name}" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
service_section=$(uci -q show ddnsmngr | grep "service=\'${service_name}\'" | cut -d'.' -f 2 | head -1)
|
||||
if [ -z "${service_section}" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
service_enabled=$(uci -q get ddnsmngr.${service_section}.enabled)
|
||||
if [ "${service_enabled}" -ne 1 ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
json_add_object
|
||||
json_add_string "interface" "${interface}"
|
||||
json_add_string "service_name" "${service_name}"
|
||||
json_add_string "username" "${username}"
|
||||
json_add_string "password" "${password}"
|
||||
json_add_string "lookup_host" "${lookup_host}"
|
||||
json_add_string "ip_network" "${ip_network}"
|
||||
json_add_string "proc_info_file" "${1}"
|
||||
json_add_string "use_ipv6" "${use_ipv6}"
|
||||
json_add_string "force_ipversion" "${force_ipversion}"
|
||||
json_add_string "use_https" "${use_https}"
|
||||
json_add_string "force_dnstcp" "${force_dnstcp}"
|
||||
json_close_object
|
||||
|
||||
if [ -z "${interface}" ]; then
|
||||
if [ "${use_ipv6}" -eq 0 ]; then
|
||||
interface="wan"
|
||||
else
|
||||
interface="wan6"
|
||||
fi
|
||||
fi
|
||||
|
||||
for intf in $CLIENT_INTFS; do
|
||||
if [ "${intf}" == "${interface}" ]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
CLIENT_INTFS="${CLIENT_INTFS} ${interface}"
|
||||
}
|
||||
|
||||
start_ddnsmngr_service() {
|
||||
run_dir=$(uci -q get ddnsmngr.global.ddns_rundir)
|
||||
log_dir=$(uci -q get ddnsmngr.global.ddns_logdir)
|
||||
|
||||
if [ -n "${run_dir}" ]; then
|
||||
RUNDIR="${run_dir}"
|
||||
fi
|
||||
|
||||
if [ -n "${log_dir}" ]; then
|
||||
LOGDIR="${log_dir}"
|
||||
fi
|
||||
|
||||
mkdir -p "${RUNDIR}"
|
||||
mkdir -p "${LOGDIR}"
|
||||
|
||||
conf_file=$(uci -q get ddnsmngr.global.configfile)
|
||||
if [ -n "${conf_file}" ]; then
|
||||
CONFIGFILE="${conf_file}"
|
||||
fi
|
||||
|
||||
touch "${CONFIGFILE}"
|
||||
|
||||
if [ ! -f "${CONFIGFILE}" ]; then
|
||||
log "Can not create ${CONFIGFILE}, exit"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
json_init
|
||||
json_add_array "services"
|
||||
|
||||
config_load ddnsmngr
|
||||
config_foreach add_object host
|
||||
|
||||
json_close_array
|
||||
json_dump > "${CONFIGFILE}"
|
||||
|
||||
procd_open_instance ddnsmngr
|
||||
procd_set_param command "$PROG"
|
||||
procd_append_param command -c "${CONFIGFILE}"
|
||||
procd_append_param command -- start
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
stop_ddnsmngr_service() {
|
||||
conf_file=$(uci -q get ddnsmngr.global.configfile)
|
||||
if [ -n "${conf_file}" ]; then
|
||||
CONFIGFILE="${conf_file}"
|
||||
fi
|
||||
|
||||
if [ ! -f "${CONFIGFILE}" ]; then
|
||||
log "${CONFIGFILE} not found, can't stop services if running any"
|
||||
fi
|
||||
|
||||
"$PROG" -c "${CONFIGFILE}" -- stop
|
||||
return 0
|
||||
}
|
||||
|
||||
add_ddnsmngr_triggers() {
|
||||
procd_open_trigger
|
||||
for intf in $CLIENT_INTFS; do
|
||||
# No need to handle other ifevents like ifupdate etc
|
||||
procd_add_interface_trigger "interface.*.up" $intf /etc/init.d/ddnsmngr restart
|
||||
procd_add_interface_trigger "interface.*.down" $intf /etc/init.d/ddnsmngr restart
|
||||
done
|
||||
procd_close_trigger
|
||||
}
|
||||
@@ -1,311 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
PROG="/usr/sbin/inadyn"
|
||||
CONFIGPATH="/tmp/inadyn_config"
|
||||
PIDPATH="/etc/inadyn_pid"
|
||||
CLIENT_INTFS=""
|
||||
CONFIG_FILES=""
|
||||
SERVER_PATH="/etc/ddnsmngr/servers"
|
||||
|
||||
FORMAT="custom [SECTION] {\n\tusername\t= [USER]\n\tpassword\t= [PWD]\n\tddns-server\t= [SERV]\n\tddns-path\t= [URI]\n\tssl\t\t= [SSL]\n\thostname\t= [NAME]\n\tcheckip-command\t= [CMD]\n\tddns-response\t= [RESPONSES]\n}"
|
||||
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
log() {
|
||||
echo "$*"|logger -t ddnsmngr.init -p debug
|
||||
}
|
||||
|
||||
get_service_data() {
|
||||
local provider="$1"
|
||||
shift
|
||||
local dir="$1"
|
||||
shift
|
||||
local ipv6="$1"
|
||||
shift
|
||||
|
||||
local name data url answer script
|
||||
|
||||
[ $# -ne 2 ] && {
|
||||
return 1
|
||||
}
|
||||
|
||||
[ -f "${dir}/${provider}.json" ] || {
|
||||
eval "$1=\"\""
|
||||
eval "$2=\"\""
|
||||
return 1
|
||||
}
|
||||
|
||||
json_load_file "${dir}/${provider}.json"
|
||||
json_get_var name "name"
|
||||
if [ "$ipv6" -eq "1" ]; then
|
||||
json_select "ipv6"
|
||||
else
|
||||
json_select "ipv4"
|
||||
fi
|
||||
json_get_var data "url"
|
||||
json_get_var answer "answer"
|
||||
json_select ".."
|
||||
json_cleanup
|
||||
|
||||
response=""
|
||||
if [ -n "${answer}" ]; then
|
||||
answer=$(echo "${answer}" | sed 's/|/ /g')
|
||||
for ans in $answer; do
|
||||
if [ -z "${response}" ]; then
|
||||
response="${ans}"
|
||||
else
|
||||
response="${response}, ${ans}"
|
||||
fi
|
||||
done
|
||||
response="{ ${response} }"
|
||||
fi
|
||||
|
||||
eval "$1=\"$data\""
|
||||
eval "$2=\"$response\""
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
generate_inadyn_config() {
|
||||
json_load "${1}"
|
||||
json_get_var service_name service_name
|
||||
json_get_var use_ipv6 use_ipv6
|
||||
json_get_var interface interface
|
||||
json_get_var username username
|
||||
json_get_var password password
|
||||
json_get_var host lookup_host
|
||||
json_get_var conf_file config_file
|
||||
json_get_var conf_dir config_dir
|
||||
json_get_var server_address server_address
|
||||
json_cleanup
|
||||
|
||||
if [ -z "${service_name}" ] || [ -z "${host}" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -z "${conf_file}" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -z "${conf_dir}" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# First look into custom path to load the url otherwise default path
|
||||
get_service_data "${service_name}" "${SERVER_PATH}" "${use_ipv6}" server_url server_answer
|
||||
|
||||
if [ -z "${server_url}" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Need to pick proto, server address and request uri separately from the url
|
||||
# format http://[server_address]/[update_Request_uri]
|
||||
proto=$(echo $server_url | cut -d':' -f 1)
|
||||
serv=$(echo $server_url | cut -d'/' -f 3 | cut -d'@' -f 2)
|
||||
uri=${server_url#*$serv}
|
||||
|
||||
if [ -z $proto ] || [ -z $serv ] || [ -z $uri ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
path=$(echo "$uri" | sed 's/&/\\&/g')
|
||||
update_uri=$(echo $path | sed -e "s#\[DOMAIN\]#%h#g" -e "s#\[PASSWORD\]#%p#g" \
|
||||
-e "s#\[USERNAME\]#%u#g" -e "s#\[IP\]#%i#g")
|
||||
|
||||
if [ -z "${interface}" ]; then
|
||||
if [ "${use_ipv6}" -eq 0 ]; then
|
||||
interface="wan"
|
||||
else
|
||||
interface="wan6"
|
||||
fi
|
||||
fi
|
||||
|
||||
# now get the physical interface name
|
||||
intf=$(ifstatus "${interface}" | jsonfilter -e '@.device')
|
||||
if [ -z "${intf}" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# command to get ip of the interface
|
||||
if [ "${use_ipv6}" -eq 0 ]; then
|
||||
get_ip="\"ifstatus ${interface} | jsonfilter -e '@[\\\\\"ipv4-address\\\\\"][0].address'\""
|
||||
else
|
||||
get_ip="\"ifstatus ${interface} | jsonfilter -e '@[\\\\\"ipv6-address\\\\\"][0].address'\""
|
||||
fi
|
||||
|
||||
if [ "${proto}" = "http" ]; then
|
||||
ssl="false"
|
||||
else
|
||||
ssl="true"
|
||||
fi
|
||||
|
||||
inadyn_ver=$(inadyn -v)
|
||||
user_agent="inadyn/${inadyn_ver}"
|
||||
|
||||
config_file="${conf_dir}/${conf_file}"
|
||||
touch "${config_file}"
|
||||
|
||||
echo "iface = ${intf}" > "${config_file}"
|
||||
echo "period = 600" >> "${config_file}"
|
||||
echo "user-agent = ${user_agent}" >> "${config_file}"
|
||||
|
||||
if [ "${use_ipv6}" -eq 1 ]; then
|
||||
echo "allow-ipv6 = true" >> "${config_file}"
|
||||
fi
|
||||
|
||||
if [ -z "${password}" ]; then
|
||||
FORMAT=$(echo "${FORMAT}" | sed 's/\\tpassword\\t= \[PWD\]\\n//g')
|
||||
fi
|
||||
|
||||
if [ -z "${server_answer}" ]; then
|
||||
FORMAT=$(echo "${FORMAT}" | sed 's/\\tddns-response\\t= \[RESPONSES\]\\n//g')
|
||||
fi
|
||||
|
||||
config=$(echo $FORMAT | sed -e "s#\[SECTION\]#$conf_file#g" -e "s#\[PWD\]#$password#g" \
|
||||
-e "s#\[USER\]#$username#g" -e "s#\[SERV\]#$serv#g" \
|
||||
-e "s#\[URI\]#\"$update_uri\"#g" -e "s#\[SSL\]#$ssl#g" \
|
||||
-e "s#\[NAME\]#$host#g" -e "s#\[CMD\]#$get_ip#g" \
|
||||
-e "s#\[RESPONSES\]#$server_answer#g")
|
||||
|
||||
echo -e "\n\n${config}" >> "${config_file}"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
validate_host_section() {
|
||||
uci_validate_section ddnsmngr host "${1}" \
|
||||
'enabled:bool:0' \
|
||||
'lookup_host:string' \
|
||||
'dm_parent:string'
|
||||
}
|
||||
|
||||
validate_client_section() {
|
||||
uci_validate_section ddnsmngr client "${1}" \
|
||||
'enabled:bool:0' \
|
||||
'service_name:string' \
|
||||
'interface:string' \
|
||||
'ip_network:string' \
|
||||
'username:string' \
|
||||
'password:string' \
|
||||
'use_https:bool:0' \
|
||||
'force_dnstcp:bool:0' \
|
||||
'use_ipv6:bool:0' \
|
||||
'force_ipversion:bool:0'
|
||||
}
|
||||
|
||||
add_object() {
|
||||
local enabled lookup_host dm_parent use_ipv6 force_ipversion
|
||||
local service_name interface ip_network username password use_https force_dnstcp
|
||||
|
||||
validate_host_section "${1}" || {
|
||||
log "Validation of host section failed"
|
||||
return
|
||||
}
|
||||
|
||||
if [ "${enabled}" -ne 1 ] || [ -z "${dm_parent}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
validate_client_section "${dm_parent}" || {
|
||||
log "Validation of client section failed"
|
||||
return
|
||||
}
|
||||
|
||||
if [ "${enabled}" -ne 1 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
service_name=$(uci -q get ddnsmngr.${dm_parent}.service_name)
|
||||
if [ -z "${service_name}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
service_section=$(uci show ddnsmngr | grep "service=\'${service_name}\'" | cut -d'.' -f 2 | head -1)
|
||||
if [ -z "${service_section}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
service_enabled=$(uci -q get ddnsmngr.${service_section}.enabled)
|
||||
if [ "${service_enabled}" -ne 1 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
json_init
|
||||
json_add_string "interface" "${interface}"
|
||||
json_add_string "service_name" "${service_name}"
|
||||
json_add_string "username" "${username}"
|
||||
json_add_string "password" "${password}"
|
||||
json_add_string "lookup_host" "${lookup_host}"
|
||||
json_add_string "ip_network" "${ip_network}"
|
||||
json_add_string "use_ipv6" "${use_ipv6}"
|
||||
json_add_string "force_ipversion" "${force_ipversion}"
|
||||
json_add_string "use_https" "${use_https}"
|
||||
json_add_string "force_dnstcp" "${force_dnstcp}"
|
||||
json_add_string "config_file" "${1}"
|
||||
json_add_string "config_dir" "${CONFIGPATH}"
|
||||
|
||||
json_str=$(json_dump)
|
||||
json_cleanup
|
||||
|
||||
generate_inadyn_config "${json_str}"
|
||||
|
||||
if [ "$?" -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
CONFIG_FILES="${CONFIG_FILES} ${1}"
|
||||
|
||||
if [ -z "${interface}" ]; then
|
||||
if [ "${use_ipv6}" -eq 0 ]; then
|
||||
interface="wan"
|
||||
else
|
||||
interface="wan6"
|
||||
fi
|
||||
fi
|
||||
|
||||
for intf in $CLIENT_INTFS; do
|
||||
if [ "${intf}" == "${interface}" ]; then
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
CLIENT_INTFS="${CLIENT_INTFS} ${interface}"
|
||||
}
|
||||
|
||||
start_ddnsmngr_service() {
|
||||
rm -rf $CONFIGPATH
|
||||
mkdir $CONFIGPATH
|
||||
mkdir -p $PIDPATH
|
||||
|
||||
config_load ddnsmngr
|
||||
config_foreach add_object host
|
||||
|
||||
i=1
|
||||
for conf in $CONFIG_FILES; do
|
||||
instance="ddnsmngr_${i}"
|
||||
i=$(( i + 1 ))
|
||||
|
||||
procd_open_instance $instance
|
||||
procd_set_param command "$PROG"
|
||||
procd_append_param command -f "${CONFIGPATH}/${conf}"
|
||||
procd_append_param command -l debug
|
||||
procd_append_param command -P "${PIDPATH}/${conf}"
|
||||
procd_append_param command -n -C
|
||||
procd_close_instance
|
||||
done
|
||||
}
|
||||
|
||||
stop_ddnsmngr_service() {
|
||||
rm -rf $CONFIGPATH
|
||||
return 0
|
||||
}
|
||||
|
||||
add_ddnsmngr_triggers() {
|
||||
procd_open_trigger
|
||||
for intf in $CLIENT_INTFS; do
|
||||
# No need to handle other ifevents like ifupdate etc
|
||||
procd_add_interface_trigger "interface.*.up" $intf /etc/init.d/ddnsmngr restart
|
||||
done
|
||||
procd_close_trigger
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
menu "Configuration"
|
||||
|
||||
config DECOLLECTOR_EASYMESH_VERSION
|
||||
int "Support Easymesh version"
|
||||
default 4
|
||||
|
||||
endmenu
|
||||
@@ -1,80 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2021-2023 IOPSYS Software Solutions AB
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=decollector
|
||||
PKG_VERSION:=4.4.0.5
|
||||
|
||||
LOCAL_DEV=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=b3e76eb2f03b13cc8d73b103277b7ad240460ec2
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/multi-ap/decollector.git
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
endif
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu>
|
||||
|
||||
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/decollector
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=WiFi DataElements Collector Proxy
|
||||
DEPENDS:=+libuci +libubox +ubus +libpthread +libnl-genl \
|
||||
+libeasy +libwifiutils +libieee1905 +ieee1905-map-plugin
|
||||
endef
|
||||
|
||||
define Package/decollector/description
|
||||
It implements the WiFi DataElements Agent as defined in the Wi-Fi Alliance's
|
||||
DataElements specification.
|
||||
endef
|
||||
|
||||
|
||||
define Package/decollector/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
ifneq (,$(findstring ALPHA,$(CONFIG_VERSION_CODE)))
|
||||
MAKE_FLAGS += DEBUG=1
|
||||
endif
|
||||
|
||||
ifneq (,$(findstring BETA,$(CONFIG_VERSION_CODE)))
|
||||
MAKE_FLAGS += DEBUG=1
|
||||
endif
|
||||
|
||||
TARGET_CFLAGS += \
|
||||
-I$(STAGING_DIR)/usr/include \
|
||||
-I$(STAGING_DIR)/usr/include/libnl3 \
|
||||
-D_GNU_SOURCE
|
||||
|
||||
ifeq ($(LOCAL_DEV),1)
|
||||
define Build/Prepare
|
||||
rsync -r --exclude=.* ~/git/decollector/ $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
endif
|
||||
|
||||
MAKE_PATH:=src
|
||||
|
||||
TARGET_CFLAGS += -DEASYMESH_VERSION=$(CONFIG_DECOLLECTOR_EASYMESH_VERSION)
|
||||
|
||||
EXECS := \
|
||||
$(if $(CONFIG_PACKAGE_decollector),decollector)
|
||||
|
||||
MAKE_FLAGS += EXECS="$(EXECS)"
|
||||
|
||||
define Package/decollector/install
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) ./files/decollector.init $(1)/etc/init.d/decollector
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/decollector $(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,decollector))
|
||||
@@ -1,14 +1,20 @@
|
||||
#
|
||||
# Copyright (C) 2021 IOPSYS Software Solutions AB
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=dectmngr
|
||||
PKG_RELEASE:=3
|
||||
PKG_VERSION:=3.6.5
|
||||
PKG_VERSION:=3.5.5
|
||||
|
||||
LOCAL_DEV=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/dectmngr.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=192e74db2082e3f89f6defe9d752d752b0b09079
|
||||
PKG_SOURCE_VERSION:=c5695bc92f7f22089c9a85d3e1f4dac7c12ca900
|
||||
PKG_MIRROR_HASH:=skip
|
||||
endif
|
||||
|
||||
@@ -28,7 +34,7 @@ include $(INCLUDE_DIR)/package.mk
|
||||
define Package/$(PKG_NAME)
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=DECT Manager
|
||||
DEPENDS:= +libubox +ubus +uci +libxml2 +libjson-c +gpiod-tools
|
||||
DEPENDS:= +libubox +ubus +uci +libxml2 +libjson-c
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
|
||||
Binary file not shown.
@@ -6,63 +6,31 @@ START=70
|
||||
STOP=12
|
||||
|
||||
USE_PROCD=1
|
||||
NAME=dectmngr
|
||||
PROG=/usr/sbin/dectmngr
|
||||
LOG_PATH=/var/log/dectmngr
|
||||
DB_PATH=/etc/dect
|
||||
DCX81_UART_DT_ALIAS=/proc/device-tree/aliases/dcx81-uart
|
||||
|
||||
DECT_GPIO="$(gpiofind DCX81_RSTN | cut -d ' ' -f 2 2>/dev/null)"
|
||||
DECT_GPIO=$(db -q get hw.board.dect_gpio)
|
||||
|
||||
# Ask dectmngr to exit nicely and wait for it to clean up, which is a slow process.
|
||||
stop_and_wait_dectmngr() {
|
||||
dect_pid=$(pidof $PROG)
|
||||
[ -n "$dect_pid" ] && kill $dect_pid
|
||||
pidof $NAME && killall -q $NAME
|
||||
|
||||
pidof $PROG > /dev/null 2>&1 && sleep 2 # wait for the process to stop gracefully
|
||||
while pidof $PROG > /dev/null 2>&1; do
|
||||
dect_pid=$(pidof $PROG)
|
||||
[ -n "$dect_pid" ] && kill -9 $dect_pid
|
||||
pidof $NAME && sleep 2 # wait for the process to stop gracefully
|
||||
while pidof $NAME; do
|
||||
killall -q -9 $NAME
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
has_dect() {
|
||||
[ -f "$DCX81_UART_DT_ALIAS" ]
|
||||
}
|
||||
|
||||
get_dcx81_device() {
|
||||
readonly dcx81_uart_dt_node="/proc/device-tree/$(cat "$DCX81_UART_DT_ALIAS" 2>/dev/null)"
|
||||
[ -e "$dcx81_uart_dt_node" ] || return 1
|
||||
for tty_dt_node in /sys/class/tty/*/device/of_node; do
|
||||
if [ "$tty_dt_node" -ef "$dcx81_uart_dt_node" ]; then
|
||||
readonly uevent_file="${tty_dt_node%%/device/of_node}/uevent"
|
||||
local device_name_line
|
||||
device_name_line="$(grep '^DEVNAME=' "$uevent_file")" || return 1
|
||||
readonly device="/dev/${device_name_line##DEVNAME=}"
|
||||
[ -c "$device" ] || return 1
|
||||
printf "%s" "$device"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
start_service() {
|
||||
local opt_ext=
|
||||
local rfpi=
|
||||
local model_id=
|
||||
local rxtun=
|
||||
|
||||
if ! has_dect; then
|
||||
logger -t "$PROG" "Not starting because no DECT hardware is available."
|
||||
return 0
|
||||
fi
|
||||
|
||||
local dcx81_uart_device
|
||||
if ! dcx81_uart_device="$(get_dcx81_device)"; then
|
||||
logger -t "$PROG" -p daemon.warning "Could not determine DCX81 UART device. Falling back to default ttyH0."
|
||||
dcx81_uart_device=/dev/ttyH0
|
||||
fi
|
||||
test $(db get hw.board.hasDect) = "0" && return
|
||||
|
||||
[ -n "$DECT_GPIO" ] && echo 1 > /sys/class/gpio/gpio${DECT_GPIO}/value
|
||||
|
||||
@@ -83,25 +51,18 @@ start_service() {
|
||||
config_get log_dect_cmbs global log_dect_cmbs syslog
|
||||
|
||||
procd_open_instance
|
||||
|
||||
# dectmngr takes expects device without /dev
|
||||
readonly dcx81_uart_device_wo_dev="${dcx81_uart_device##/dev/}"
|
||||
case "$log_dect_cmbs" in
|
||||
none)
|
||||
if [ "$log_dect_cmbs" = "none" ]; then
|
||||
echo "Starting dectmngr with cmbs logging disabled"
|
||||
procd_set_param command "$PROG" -comname "$dcx81_uart_device_wo_dev" $opt_ext
|
||||
procd_set_param command $PROG -comname ttyH0 $opt_ext
|
||||
rm -f $LOG_PATH/*
|
||||
;;
|
||||
file)
|
||||
elif [ "$log_dect_cmbs" = "file" ]; then
|
||||
echo "Starting dectmngr with cmbs logging enabled to file"
|
||||
procd_set_param command "$PROG" -comname "$dcx81_uart_device_wo_dev" -log $LOG_PATH/dect-cmbs.log $opt_ext
|
||||
;;
|
||||
*)
|
||||
procd_set_param command $PROG -comname ttyH0 -log $LOG_PATH/dect-cmbs.log $opt_ext
|
||||
else
|
||||
echo "Starting dectmngr with cmbs logging enabled to syslog"
|
||||
procd_set_param command "$PROG" -comname "$dcx81_uart_device_wo_dev" -syslog $opt_ext
|
||||
procd_set_param command $PROG -comname ttyH0 -syslog $opt_ext
|
||||
rm -f $LOG_PATH/*
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
procd_set_param respawn 6 2 3
|
||||
procd_set_param term_timeout 20
|
||||
@@ -110,7 +71,7 @@ start_service() {
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
has_dect || return 0
|
||||
test $(db get hw.board.hasDect) = "0" && return
|
||||
|
||||
[ -n "$DECT_GPIO" ] && echo 0 > /sys/class/gpio/gpio${DECT_GPIO}/value
|
||||
stop_and_wait_dectmngr
|
||||
@@ -120,7 +81,8 @@ reload_service() {
|
||||
ubus call dect reload
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
service_triggers()
|
||||
{
|
||||
procd_add_config_trigger "config.change" "asterisk" /etc/init.d/dectmngr restart
|
||||
procd_add_config_trigger "config.change" "dect" /etc/init.d/dectmngr reload
|
||||
}
|
||||
@@ -135,3 +97,4 @@ boot() {
|
||||
[ ! -d $DB_PATH ] && mkdir -p $DB_PATH
|
||||
start
|
||||
}
|
||||
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2022-2024 IOPSYS Software Solutions AB
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=dnsmngr
|
||||
PKG_VERSION:=1.0.3
|
||||
|
||||
LOCAL_DEV:=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/network/dnsmngr.git
|
||||
PKG_SOURCE_VERSION:=347070e096b98946ba660791e3c78d1646adc54a
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
endif
|
||||
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include ../bbfdm/bbfdm.mk
|
||||
|
||||
MAKE_PATH:=src
|
||||
|
||||
define Package/dnsmngr
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libbbfdm-api +dnsmasq +umdns
|
||||
TITLE:=Package to add Device.DNS. datamodel support
|
||||
endef
|
||||
|
||||
define Package/dnsmngr/description
|
||||
Package to add Device.DNS. datamodel support.
|
||||
endef
|
||||
|
||||
ifeq ($(LOCAL_DEV),1)
|
||||
define Build/Prepare
|
||||
$(CP) -rf ~/git/dnsmngr/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
endif
|
||||
|
||||
define Package/dnsmngr/install
|
||||
$(INSTALL_DIR) $(1)/etc/dnsmngr
|
||||
$(CP) $(PKG_BUILD_DIR)/src/libdnsmngr.so $(1)/etc/dnsmngr
|
||||
$(call BbfdmInstallMicroServiceInputFile,$(1),./files/etc/dnsmngr/input.json)
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,dnsmngr))
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"daemon": {
|
||||
"config": {
|
||||
"loglevel": "1"
|
||||
},
|
||||
"input": {
|
||||
"type": "DotSo",
|
||||
"name": "/etc/dnsmngr/libdnsmngr.so"
|
||||
},
|
||||
"output": {
|
||||
"type": "UBUS",
|
||||
"parent_dm": "Device.",
|
||||
"object": "DNS",
|
||||
"root_obj": "bbfdm"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2018-2024 iopsys Software Solutions AB
|
||||
# Copyright (C) 2018 iopsys Software Solutions AB
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
@@ -8,15 +8,14 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=dslmngr
|
||||
PKG_VERSION:=1.2.4
|
||||
PKG_VERSION:=1.1.2
|
||||
|
||||
LOCAL_DEV=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/hal/dslmngr.git
|
||||
PKG_SOURCE_VERSION:=d71bef278b8222dee1c278723f8264aa8faf5e40
|
||||
PKG_SOURCE_VERSION:=bb754ae620a9fc66fd6fc0745f0fead0708c7a17
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/dslmngr.git
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MAINTAINER:=Rahul Thakur <rahul.thakur@iopsys.eu>
|
||||
PKG_MIRROR_HASH:=skip
|
||||
endif
|
||||
|
||||
@@ -26,9 +25,8 @@ PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include ../bbfdm/bbfdm.mk
|
||||
|
||||
ifeq ($(CONFIG_TARGET_brcmbca),y)
|
||||
ifeq ($(CONFIG_TARGET_iopsys_brcm63xx_arm),y)
|
||||
TARGET_PLATFORM=BROADCOM
|
||||
else
|
||||
$(info Unexpected CONFIG_TARGET)
|
||||
@@ -40,7 +38,7 @@ define Package/dslmngr
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=XDSL status and configration utility
|
||||
DEPENDS:=+libdsl +libuci +libubox +ubus +libpthread +libnl-genl +libeasy +libbbfdm-api
|
||||
DEPENDS:=+libdsl +libuci +libubox +ubus +libpthread +libnl-genl +libeasy
|
||||
endef
|
||||
|
||||
define Package/dslmngr/description
|
||||
@@ -61,7 +59,7 @@ MAKE_FLAGS += \
|
||||
|
||||
ifeq ($(LOCAL_DEV),1)
|
||||
define Build/Prepare
|
||||
rsync -r --exclude=.* ./dslmngr/ $(PKG_BUILD_DIR)/
|
||||
rsync -r --exclude=.* ~/git/dslmngr/ $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
endif
|
||||
|
||||
@@ -70,14 +68,8 @@ define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/dslmngr/install
|
||||
$(INSTALL_DIR) $(1)/etc/dsl
|
||||
$(CP) ./files/common/* $(1)/
|
||||
ifeq ($(CONFIG_TARGET_brcmbca),y)
|
||||
$(CP) ./files/broadcom/* $(1)/
|
||||
endif
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/dslmngr $(1)/sbin/
|
||||
$(BBFDM_INSTALL_MS_DM) $(PKG_BUILD_DIR)/libbbfdsl.so $(1) $(PKG_NAME)
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,dslmngr))
|
||||
|
||||
@@ -1,313 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
# ATM #
|
||||
check_pvc() {
|
||||
local vpi=$1
|
||||
local vci=$2
|
||||
local ret
|
||||
|
||||
ret=$(xtmctl operate conn --show | awk -v test="$vpi/$vci" '{if ($3==test ) print $5 }')
|
||||
|
||||
case $ret in
|
||||
''|*[!0-9]*) return 0 ;;
|
||||
*) return $ret ;;
|
||||
esac
|
||||
}
|
||||
|
||||
check_xtm_list() {
|
||||
local qclass=$1
|
||||
local pcr scr mbs
|
||||
local ret
|
||||
|
||||
case $# in
|
||||
1)
|
||||
pcr=0
|
||||
scr=0
|
||||
mbs=0
|
||||
;;
|
||||
2)
|
||||
pcr=$2
|
||||
scr=0
|
||||
mbs=0
|
||||
;;
|
||||
4)
|
||||
pcr=$2
|
||||
scr=$3
|
||||
mbs=$4
|
||||
;;
|
||||
esac
|
||||
|
||||
ret=$(xtmctl operate tdte --show | awk -v test="$qclass" -v pcr="$pcr" -v scr="$scr" -v mbs="$mbs" '{if ($2==test && $3==pcr && $4==scr && $5==mbs ) print $1 }')
|
||||
|
||||
case $ret in
|
||||
''|*[!0-9]*) return 0 ;;
|
||||
*) return $ret ;;
|
||||
esac
|
||||
}
|
||||
|
||||
configure_atm_device() {
|
||||
local name vpi vci device link_type encapsulation qos_class pcr mbs scr i
|
||||
|
||||
config_get name $1 name "ATM"
|
||||
config_get vpi $1 vpi "8"
|
||||
config_get vci $1 vci "35"
|
||||
config_get device $1 device "atm0"
|
||||
config_get link_type $1 link_type "eoa"
|
||||
config_get encapsulation $1 encapsulation "llc"
|
||||
config_get qos_class $1 qos_class "ubr"
|
||||
config_get pcr $1 pcr
|
||||
config_get mbs $1 mbs
|
||||
config_get scr $1 scr
|
||||
|
||||
check_pvc $vpi $vci
|
||||
ret=$?
|
||||
|
||||
if [ "$ret" -eq 0 ]; then
|
||||
check_xtm_list $qos_class $pcr $scr $mbs
|
||||
ret=$?
|
||||
|
||||
if [ "$ret" -eq 0 ]; then
|
||||
case $qos_class in # ubr, cbr, gfr, vbr-nrt, vbr-rt, ubr+, abr
|
||||
ubr)
|
||||
xtmctl operate tdte --add "$qos_class"
|
||||
;;
|
||||
ubr_pcr|ubr+)
|
||||
xtmctl operate tdte --add "$qos_class" $pcr
|
||||
;;
|
||||
cbr)
|
||||
xtmctl operate tdte --add "$qos_class" $pcr
|
||||
;;
|
||||
nrtvbr|vbr-nrt)
|
||||
xtmctl operate tdte --add "$qos_class" $pcr $scr $mbs
|
||||
;;
|
||||
rtvbr|vbr-rt)
|
||||
xtmctl operate tdte --add "$qos_class" $pcr $scr $mbs
|
||||
;;
|
||||
gfr)
|
||||
;;
|
||||
abr)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case $link_type in # EoA, IPoA, PPPoA, CIP
|
||||
EoA|eoa)
|
||||
[ $encapsulation == "vcmux" ] && encapsulation="vcmux_eth" || encapsulation="llcsnap_eth"
|
||||
;;
|
||||
PPPoA|pppoa)
|
||||
[ $encapsulation == "vcmux" ] && encapsulation="vcmux_pppoa" || encapsulation="llcencaps_ppp"
|
||||
;;
|
||||
IPoA|ipoa)
|
||||
[ $encapsulation == "vcmux" ] && encapsulation="vcmux_ipoa" || encapsulation="llcsnap_rtip"
|
||||
;;
|
||||
CIP|cip)
|
||||
;;
|
||||
esac
|
||||
|
||||
check_xtm_list $qos_class $pcr $scr $mbs
|
||||
ret="$?"
|
||||
|
||||
xtmctl operate conn --add 1.$vpi.$vci aal5 $encapsulation 0 1 $ret
|
||||
for i in `seq 0 7`; do
|
||||
xtmctl operate conn --addq 1.$vpi.$vci $i wrr 1 dt # queue priority 0-7
|
||||
done
|
||||
xtmctl operate conn --createnetdev 1.$vpi.$vci $device
|
||||
xtmctl operate intf --state 1 enable
|
||||
fi
|
||||
}
|
||||
|
||||
remove_atm_devices() {
|
||||
local vpi vci rest
|
||||
local vpivci=`xtmctl operate conn --show | grep "ATM\|mode" | awk '{if (NR!=1 && $1!="PTM") {print $3}}'`
|
||||
|
||||
for i in $vpivci
|
||||
do
|
||||
rest=${i#\/}
|
||||
vpi=${rest%%\/*}
|
||||
vci=${rest#*\/}
|
||||
echo "xtmctl operate conn --delete 1.$vpi.$vci"
|
||||
xtmctl operate conn --delete 1.$vpi.$vci
|
||||
echo "xtmctl operate conn --deletenetdev 1.$vpi.$vci"
|
||||
xtmctl operate conn --deletenetdev 1.$vpi.$vci
|
||||
done
|
||||
}
|
||||
|
||||
create_atm_devices() {
|
||||
echo "Creating ATM Device(s)"
|
||||
config_load dsl
|
||||
config_foreach configure_atm_device atm-device
|
||||
}
|
||||
# ATM END #
|
||||
|
||||
# PTM #
|
||||
check_ptm() {
|
||||
local ret
|
||||
local ptmprio=$1
|
||||
local dslat=$2
|
||||
|
||||
if [ "$ptmprio" -eq 2 ]; then
|
||||
ptmprio="high"
|
||||
else
|
||||
ptmprio="low"
|
||||
fi
|
||||
|
||||
ret=$(xtmctl operate conn --show | awk -v dslat="$dslat" -v ptmprio="$ptmprio" '{if ($2 == dslat && $3 == ptmprio ) print $2 }')
|
||||
|
||||
case $ret in
|
||||
''|*[!0-9]*) return 0 ;;
|
||||
*) return $ret ;;
|
||||
esac
|
||||
}
|
||||
|
||||
configure_ptm_device() {
|
||||
local name device priority portid i
|
||||
|
||||
config_get name $1 name "PTM"
|
||||
config_get device $1 device "ptm0"
|
||||
config_get priority $1 priority 1
|
||||
config_get portid $1 portid 1
|
||||
|
||||
check_ptm $priority $portid
|
||||
ret=$?
|
||||
|
||||
if [ "$ret" -eq 0 ]; then
|
||||
xtmctl operate conn --add $portid.$priority
|
||||
|
||||
for i in `seq 0 7`; do
|
||||
xtmctl operate conn --addq $portid.$priority $i wrr 1 dt -1 -1 3000 # queue priority 0-7
|
||||
done
|
||||
echo "xtmctl operate conn --createnetdev $portid.$priority $device"
|
||||
xtmctl operate conn --createnetdev $portid.$priority $device
|
||||
xtmctl operate intf --state 1 enable
|
||||
fi
|
||||
}
|
||||
|
||||
remove_ptm_devices() {
|
||||
local delptm
|
||||
local x=0
|
||||
|
||||
IFS=$'\n'
|
||||
for i in `xtmctl operate conn --show | grep "PTM\|mode"`
|
||||
do
|
||||
if [ $x -eq 1 ]; then
|
||||
delptm=$(echo $i | awk '{if ($1!="ATM") print $2"."$11}')
|
||||
echo "xtmctl operate conn --delete $delptm"
|
||||
xtmctl operate conn --delete $delptm
|
||||
xtmctl operate conn --deletenetdev $delptm
|
||||
fi
|
||||
x=1
|
||||
done
|
||||
unset IFS
|
||||
}
|
||||
|
||||
create_ptm_devices() {
|
||||
echo "Creating PTM Device(s)"
|
||||
config_load dsl
|
||||
config_foreach configure_ptm_device ptm-device
|
||||
}
|
||||
# PTM END #
|
||||
|
||||
prioritize_arp()
|
||||
{
|
||||
ebtables -t nat -D POSTROUTING -j mark --mark-or 0x7 -p ARP >/dev/null
|
||||
ebtables -t nat -A POSTROUTING -j mark --mark-or 0x7 -p ARP >/dev/null
|
||||
}
|
||||
|
||||
xtm_remove_devices() {
|
||||
remove_atm_devices
|
||||
remove_ptm_devices
|
||||
}
|
||||
|
||||
xtm_create_devices() {
|
||||
local tpstc="$(xdslctl info --show | grep TPS-TC)"
|
||||
if echo "$tpstc" | grep -q "ATM Mode"; then
|
||||
create_atm_devices
|
||||
elif echo "$tpstc" | grep -q "PTM Mode"; then
|
||||
create_ptm_devices
|
||||
fi
|
||||
}
|
||||
|
||||
xdsl_configure() {
|
||||
local VDSL=0
|
||||
local GFAST=0
|
||||
local mod=""
|
||||
local modes=""
|
||||
local profile=""
|
||||
|
||||
config_load dsl
|
||||
|
||||
# Modes
|
||||
config_get mode line mode
|
||||
for mod in $mode; do
|
||||
[ $mod == "gdmt" ] && modes="${modes}d"
|
||||
[ $mod == "glite" ] && modes="${modes}l"
|
||||
[ $mod == "t1413" ] && modes="${modes}t"
|
||||
[ $mod == "adsl2" ] && modes="${modes}2"
|
||||
[ $mod == "adsl2p" ] && modes="${modes}p"
|
||||
[ $mod == "annexl" ] && modes="${modes}e"
|
||||
[ $mod == "annexm" ] && modes="${modes}m"
|
||||
[ $mod == "vdsl2" ] && modes="${modes}v" && VDSL=1
|
||||
[ $mod == "gfast" ] && modes="${modes}f" && GFAST=1
|
||||
done
|
||||
|
||||
# VDSL Profiles
|
||||
config_get profile line profile
|
||||
# Capabilities
|
||||
config_get_bool bitswap line bitswap 1
|
||||
[ $bitswap -eq 1 ] && bitswap="on" || bitswap="off"
|
||||
config_get_bool sra line sra 1
|
||||
[ $sra -eq 1 ] && sra="on" || sra="off"
|
||||
# config_get_bool trellis line trellis 1
|
||||
config_get_bool sesdrop line sesdrop 0
|
||||
[ $sesdrop -eq 1 ] && sesdrop="on" || sesdrop="off"
|
||||
# VDSL2 only
|
||||
config_get_bool us0 line us0 1
|
||||
[ $us0 -eq 1 ] && us0="on" || us0="off"
|
||||
# config_get_bool dynamicd line dynamicd 1
|
||||
# config_get_bool dynamicf line dynamicf 1
|
||||
config_get_bool sos line sos 0
|
||||
[ $sos -eq 1 ] && sos="on" || sos="off"
|
||||
|
||||
config_get_bool phyReXmtUs line phyReXmtUs 0
|
||||
config_get_bool phyReXmtDs line phyReXmtDs 1
|
||||
phyReXmt=$(( $((phyReXmtUs<<1)) + phyReXmtDs))
|
||||
|
||||
if [ $VDSL -eq 1 -o $GFAST -eq 1 ]; then
|
||||
echo "xdslctl start --up --mod $modes --profile "$profile" --sra $sra --bitswap $bitswap --us0 $us0 --sesdrop $sesdrop --SOS $sos --phyReXmt $phyReXmt"
|
||||
xdslctl start --up --mod $modes --profile "$profile" --sra $sra --bitswap $bitswap --us0 $us0 --sesdrop $sesdrop --SOS $sos --phyReXmt $phyReXmt
|
||||
# G.Fast hardware to VDSL hardware, to set the driver bit kPhyCfg2EnableGfastVdslMMTimeOut0.
|
||||
# Enable V43 tone for GFAST.
|
||||
echo "xdslctl configure1 --phycfg 0 0 0 0 0 0 0 0 0 0 0 0x1400400 0x1400400"
|
||||
xdslctl configure1 --phycfg 0 0 0 0 0 0 0 0 0 0 0 0x1400400 0x1400400
|
||||
else
|
||||
echo "xdslctl start --up --mod $modes --sra $sra --bitswap $bitswap --sesdrop $sesdrop --SOS $sos --phyReXmt $phyReXmt"
|
||||
xdslctl start --up --mod $modes --sra $sra --bitswap $bitswap --sesdrop $sesdrop --SOS $sos --phyReXmt $phyReXmt
|
||||
fi
|
||||
|
||||
if [ $GFAST -eq 1 ]; then
|
||||
# G.Fast hardware to VDSL hardware, to set the driver bit kPhyCfg2EnableGfastVdslMMTimeOut0.
|
||||
# Enable V43 tone for GFAST.
|
||||
echo "xdslctl configure1 --phycfg 0 0 0 0 0 0 0 0 0 0 0 0x1400400 0x1400400"
|
||||
xdslctl configure1 --phycfg 0 0 0 0 0 0 0 0 0 0 0 0x1400400 0x1400400
|
||||
fi
|
||||
}
|
||||
|
||||
xdsl_stop() {
|
||||
# echo "Stopping DSL"
|
||||
# stop causes IRQ issues
|
||||
# xdslctl stop
|
||||
return 0
|
||||
}
|
||||
|
||||
xdsl_init() {
|
||||
[ -d /sys/class/net/dsl0/ ] || exit
|
||||
|
||||
prioritize_arp
|
||||
|
||||
echo "Starting DSL"
|
||||
|
||||
xtmctl start
|
||||
xtmctl operate intf --state 1 enable
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
# OEM specific parameters
|
||||
config oem-parameters 'oem'
|
||||
# option country_code "0000" # 2 bytes hex
|
||||
# option vendor_id "IO" # 4 bytes string
|
||||
# option vendor_suffix "0000" # 2 bytes hex
|
||||
# option sw_version "iopsys" # 16 bytes string
|
||||
# option serial_nr "00000000" # 32 bytes string
|
||||
|
||||
# DSL Modes
|
||||
config dsl-line line
|
||||
list mode gdmt
|
||||
list mode glite
|
||||
list mode t1413
|
||||
list mode adsl2
|
||||
list mode adsl2p
|
||||
list mode annexl
|
||||
list mode annexm
|
||||
list mode vdsl2
|
||||
# VDSL2 profiles
|
||||
list profile 8a
|
||||
list profile 8b
|
||||
list profile 8c
|
||||
list profile 8d
|
||||
list profile 12a
|
||||
list profile 12b
|
||||
list profile 17a
|
||||
list profile 30a
|
||||
option bitswap 1
|
||||
option sra 1
|
||||
option us0 1 # VDSL2 only
|
||||
option sesdrop 0
|
||||
option sos 0
|
||||
option phyReXmtUs 0
|
||||
option phyReXmtDs 1
|
||||
|
||||
config atm-device atm0
|
||||
option name 'ATM'
|
||||
option vpi '8'
|
||||
option vci '35'
|
||||
option device atm0
|
||||
option link_type 'eoa' # EoA, IPoA, PPPoA, CIP
|
||||
option encapsulation 'llc' # llc, vcmux
|
||||
option qos_class 'ubr' # ubr, cbr, gfr, vbr-nrt, vbr-rt, ubr+, abr
|
||||
# option pcr '512'
|
||||
# option scr '256'
|
||||
# option mbs '1024'
|
||||
|
||||
config ptm-device ptm0
|
||||
option name 'PTM'
|
||||
option device 'ptm0'
|
||||
option priority '1'
|
||||
option portid '1'
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
[ "$STATUS" == "up" -o "$STATUS" == "down" ] || exit 0
|
||||
|
||||
. /lib/functions.sh
|
||||
include /lib/dsl
|
||||
|
||||
xtm_remove_devices
|
||||
xtm_create_devices
|
||||
@@ -1,7 +0,0 @@
|
||||
if [ "$STATUS" == "up" ]; then
|
||||
ubus call led.dsl set '{"state":"ok"}'
|
||||
elif [ "$STATUS" == "down" ]; then
|
||||
ubus call led.dsl set '{"state":"off"}'
|
||||
elif [ "$STATUS" == "training" ]; then
|
||||
ubus call led.dsl set '{"state":"alert"}'
|
||||
fi
|
||||
@@ -1,41 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
. /lib/functions.sh
|
||||
include /lib/dsl
|
||||
|
||||
START=20
|
||||
USE_PROCD=1
|
||||
|
||||
DSLMNGR=$(which dslmngr)
|
||||
|
||||
start_service() {
|
||||
[ -n "$DSLMNGR" ] && {
|
||||
procd_open_instance
|
||||
procd_set_param command "$DSLMNGR"
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
xdsl_configure
|
||||
xtm_create_devices
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
xtm_remove_devices
|
||||
xdsl_stop
|
||||
}
|
||||
|
||||
boot() {
|
||||
xdsl_init
|
||||
|
||||
start
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger dsl
|
||||
}
|
||||
@@ -19,7 +19,7 @@ define Package/easy-qos
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Easy QoS
|
||||
DEPENDS:=@(TARGET_brcmbca||TARGET_airoha)
|
||||
DEPENDS:=@(TARGET_iopsys_brcm63xx_arm||TARGET_iopsys_econet)
|
||||
endef
|
||||
|
||||
define Package/easy-qos/description
|
||||
|
||||
@@ -19,7 +19,7 @@ include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
-include $(TOPDIR)/.config
|
||||
|
||||
ifneq ($(CONFIG_TARGET_brcmbca),)
|
||||
ifneq ($(CONFIG_TARGET_iopsys_brcm63xx_arm),)
|
||||
LINUX_DIR=$(BUILD_DIR)/bcmkernel/bcm963xx/kernel/linux-4.1
|
||||
LINUX_VERSION := 4.1.52
|
||||
LINUXINCLUDE=-Iarch/$(LINUX_KARCH)/mach-bcm963xx/include
|
||||
@@ -85,7 +85,7 @@ define Build/Compile
|
||||
endef
|
||||
|
||||
|
||||
ifneq ($(CONFIG_TARGET_brcmbca),)
|
||||
ifneq ($(CONFIG_TARGET_iopsys_brcm63xx_arm),)
|
||||
define KernelPackage/easy-soc-events/install-extra
|
||||
cp $(PKG_BUILD_DIR)/easyevent.ko $(FS_DIR)/lib/modules/$(LINUX_VERSION)/extra
|
||||
endef
|
||||
|
||||
5
easy-soc-libs/Config.in
Normal file
5
easy-soc-libs/Config.in
Normal file
@@ -0,0 +1,5 @@
|
||||
# libeasy configuration
|
||||
|
||||
config LIBWIFI_USE_CTRL_IFACE
|
||||
bool "Use UNIX sockets"
|
||||
default n
|
||||
141
easy-soc-libs/Makefile
Normal file
141
easy-soc-libs/Makefile
Normal file
@@ -0,0 +1,141 @@
|
||||
#
|
||||
# Copyright (C) 2020 iopsys Software Solutions AB
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=easy-soc-libs
|
||||
PKG_VERSION:=6.6.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
LOCAL_DEV=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=c8c406568822b170e373a54fbf32323e960259ff
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/easy-soc-libs.git
|
||||
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu>
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
endif
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_LICENSE:=GPLv2
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/easy-soc-libs
|
||||
SECTION:=libs
|
||||
CATEGORY:=Libraries
|
||||
TITLE:=IOPSYS Easy SoC libraries
|
||||
SUBMENU:=IOPSYS Easy SoC libraries
|
||||
DEPENDS:=+libopenssl
|
||||
MENU:=1
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_TARGET_iopsys_brcm63xx_arm),y)
|
||||
TARGET_PLATFORM=BROADCOM
|
||||
TARGET_WIFI_TYPE=BROADCOM
|
||||
CHIP_ID=$(patsubst "%",%,$(CONFIG_BCM_CHIP_ID))
|
||||
TARGET_CFLAGS +=-DIOPSYS_BROADCOM -DCHIP_$(CHIP_ID) -DCONFIG_BCM9$(CHIP_ID) \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/userspace/public/include
|
||||
else ifeq ($(CONFIG_TARGET_iopsys_ramips),y)
|
||||
TARGET_PLATFORM=MEDIATEK
|
||||
TARGET_WIFI_TYPE=MAC80211
|
||||
TARGET_CFLAGS +=-DIOPSYS_MAC80211
|
||||
else ifeq ($(CONFIG_TARGET_iopsys_x86),y)
|
||||
TARGET_PLATFORM=TEST
|
||||
TARGET_WIFI_TYPE=TEST
|
||||
TARGET_CFLAGS +=-DIOPSYS_TEST
|
||||
else ifeq ($(CONFIG_TARGET_iopsys_armvirt),y)
|
||||
TARGET_PLATFORM=TEST
|
||||
TARGET_WIFI_TYPE=TEST
|
||||
TARGET_CFLAGS +=-DIOPSYS_TEST
|
||||
else ifeq ($(CONFIG_TARGET_iopsys_econet),y)
|
||||
TARGET_PLATFORM=ECONET
|
||||
TARGET_WIFI_TYPE=MAC80211
|
||||
TARGET_CFLAGS +=-DIOPSYS_ECONET
|
||||
else
|
||||
$(info Unexpected CONFIG_TARGET, use default MAC80211)
|
||||
TARGET_PLATFORM=MAC80211
|
||||
TARGET_WIFI_TYPE=MAC80211
|
||||
TARGET_CFLAGS +=-DIOPSYS_MAC80211
|
||||
endif
|
||||
|
||||
export TARGET_PLATFORM
|
||||
export TARGET_WIFI_TYPE
|
||||
|
||||
subdirs := \
|
||||
$(if $(CONFIG_PACKAGE_libeasy),libeasy) \
|
||||
$(if $(CONFIG_PACKAGE_libwifi),libwifi) \
|
||||
$(if $(CONFIG_PACKAGE_libdsl),libdsl) \
|
||||
$(if $(CONFIG_PACKAGE_libethernet),libethernet) \
|
||||
$(if $(CONFIG_PACKAGE_libqos),libqos)
|
||||
|
||||
EASY_SOC_LIBS := \
|
||||
libeasy \
|
||||
libwifi \
|
||||
libdsl \
|
||||
libethernet \
|
||||
libqos
|
||||
|
||||
ifeq ($(CONFIG_LIBWIFI_USE_CTRL_IFACE),y)
|
||||
TARGET_CFLAGS +=-DLIBWIFI_USE_CTRL_IFACE
|
||||
endif
|
||||
|
||||
TARGET_CFLAGS += \
|
||||
-I$(STAGING_DIR)/usr/include \
|
||||
-I$(STAGING_DIR)/usr/include/openssl \
|
||||
-I$(STAGING_DIR)/usr/include/libnl3
|
||||
|
||||
MAKE_FLAGS += \
|
||||
CFLAGS="$(TARGET_CFLAGS) -Wall -I./" \
|
||||
LDFLAGS="$(TARGET_LDFLAGS)" \
|
||||
FPIC="$(FPIC)" \
|
||||
PLATFORM="$(TARGET_PLATFORM)" \
|
||||
WIFI_TYPE="$(TARGET_WIFI_TYPE)" \
|
||||
subdirs="$(subdirs)"
|
||||
|
||||
ifeq ($(LOCAL_DEV),1)
|
||||
define Build/Prepare
|
||||
rsync -r --exclude=.* ~/git/easy-soc-libs/ $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
endif
|
||||
|
||||
include easy.mk
|
||||
include wifi.mk
|
||||
include dsl.mk
|
||||
include ethernet.mk
|
||||
include qos.mk
|
||||
|
||||
ifneq ($(wildcard $(PKG_BUILD_DIR)/.config_*),\
|
||||
$(PKG_BUILD_DIR)/.config_$(patsubst "%",%,$(CONFIG_TARGET_PROFILE)))
|
||||
define Build/Compile/rebuild
|
||||
$(FIND) $(PKG_BUILD_DIR) -name \*.o -or -name \*.so\* | $(XARGS) rm -f;
|
||||
$(if $(wildcard $(PKG_BUILD_DIR)/config_*), \
|
||||
rm -f $(PKG_BUILD_DIR)/.config_*)
|
||||
endef
|
||||
endif
|
||||
|
||||
STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell echo $(TARGET_CFLAGS) | mkhash md5)
|
||||
|
||||
define Build/Compile
|
||||
$(Build/Compile/rebuild)
|
||||
touch $(PKG_BUILD_DIR)/.config_$(CONFIG_TARGET_PROFILE)
|
||||
$(call Build/Compile/Default)
|
||||
$(foreach dir,$(subdirs),$(call Build/Compile/$(dir)))
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(foreach dir,$(subdirs),$(call Build/InstallDev/$(dir),$(1),$(2));)
|
||||
endef
|
||||
|
||||
define Package/easy-soc-libs/install
|
||||
:
|
||||
endef
|
||||
|
||||
$(eval $(foreach e,$(EASY_SOC_LIBS),$(call BuildPackage,$(e))))
|
||||
44
easy-soc-libs/dsl.mk
Normal file
44
easy-soc-libs/dsl.mk
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
define Package/libdsl
|
||||
$(call Package/easy-soc-libs)
|
||||
TITLE:= xDSL library (libdsl)
|
||||
endef
|
||||
|
||||
define Package/libdsl/config
|
||||
if PACKAGE_libdsl
|
||||
config LIBDSL_DEBUG
|
||||
depends on PACKAGE_libdsl
|
||||
bool "Enable dsl debugging"
|
||||
default n
|
||||
|
||||
config LIBDSL_TEST
|
||||
depends on PACKAGE_libdsl
|
||||
bool "Enable dsl test program"
|
||||
default n
|
||||
|
||||
endif
|
||||
endef
|
||||
|
||||
define Build/InstallDev/libdsl
|
||||
$(INSTALL_DIR) $(1)/usr/include/xdsl
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libdsl/xdsl.h $(1)/usr/include/xdsl
|
||||
$(CP) $(PKG_BUILD_DIR)/libdsl/xtm.h $(1)/usr/include/xdsl
|
||||
$(CP) $(PKG_BUILD_DIR)/libdsl/common.h $(1)/usr/include/xdsl
|
||||
$(CP) $(PKG_BUILD_DIR)/libdsl/libdsl.so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_LIBDSL_TEST),y)
|
||||
define Build/Compile/libdsl
|
||||
$(MAKE) -C "$(PKG_BUILD_DIR)/libdsl/test" $(MAKE_FLAGS)
|
||||
endef
|
||||
endif
|
||||
|
||||
define Package/libdsl/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(CP) $(PKG_BUILD_DIR)/libdsl/libdsl.so* $(1)/usr/lib/
|
||||
ifeq ($(CONFIG_LIBDSL_TEST),y)
|
||||
$(CP) $(PKG_BUILD_DIR)/libdsl/test/libdsl_test $(1)/usr/bin/
|
||||
endif
|
||||
endef
|
||||
29
easy-soc-libs/easy.mk
Normal file
29
easy-soc-libs/easy.mk
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
|
||||
define Package/libeasy
|
||||
$(call Package/easy-soc-libs)
|
||||
TITLE:= Common helper functions library (libeasy)
|
||||
DEPENDS+=+libnl +libnl-route
|
||||
endef
|
||||
|
||||
define Package/libeasy/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
define Build/InstallDev/libeasy
|
||||
$(INSTALL_DIR) $(1)/usr/include/easy
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libeasy/easy.h $(1)/usr/include/easy/
|
||||
$(CP) $(PKG_BUILD_DIR)/libeasy/event.h $(1)/usr/include/easy/
|
||||
$(CP) $(PKG_BUILD_DIR)/libeasy/utils.h $(1)/usr/include/easy/
|
||||
$(CP) $(PKG_BUILD_DIR)/libeasy/if_utils.h $(1)/usr/include/easy/
|
||||
$(CP) $(PKG_BUILD_DIR)/libeasy/debug.h $(1)/usr/include/easy/
|
||||
$(CP) $(PKG_BUILD_DIR)/libeasy/hlist.h $(1)/usr/include/easy/
|
||||
$(CP) $(PKG_BUILD_DIR)/libeasy/libeasy*.so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Package/libeasy/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libeasy/libeasy*.so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
27
easy-soc-libs/ethernet.mk
Normal file
27
easy-soc-libs/ethernet.mk
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
define Package/libethernet
|
||||
$(call Package/easy-soc-libs)
|
||||
TITLE:= Ethernet library (libethernet)
|
||||
DEPENDS+=+libnl +libnl-route +libeasy +TARGET_iopsys_ramips:swconfig +TARGET_iopsys_econet:ecnt_api
|
||||
endef
|
||||
|
||||
define Package/libethernet/config
|
||||
config LIBETHERNET_DEBUG
|
||||
depends on PACKAGE_libethernet
|
||||
bool "Enable ethernet debugging"
|
||||
default n
|
||||
|
||||
endef
|
||||
|
||||
define Build/InstallDev/libethernet
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libethernet/ethernet.h $(1)/usr/include/
|
||||
$(CP) $(PKG_BUILD_DIR)/libethernet/libethernet.so $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Package/libethernet/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libethernet/libethernet.so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
27
easy-soc-libs/qos.mk
Normal file
27
easy-soc-libs/qos.mk
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
define Package/libqos
|
||||
$(call Package/easy-soc-libs)
|
||||
TITLE:= QoS library (libqos)
|
||||
DEPENDS+=+libnl +libnl-route +libeasy
|
||||
endef
|
||||
|
||||
define Package/libqos/config
|
||||
config LIBQOS_DEBUG
|
||||
depends on PACKAGE_libqos
|
||||
bool "Enable qos debugging"
|
||||
default n
|
||||
|
||||
endef
|
||||
|
||||
define Build/InstallDev/libqos
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libqos/include/qos.h $(1)/usr/include/
|
||||
$(CP) $(PKG_BUILD_DIR)/libqos/libqos.so $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Package/libqos/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libqos/libqos*.so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
29
easy-soc-libs/wifi.mk
Normal file
29
easy-soc-libs/wifi.mk
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
define Package/libwifi
|
||||
$(call Package/easy-soc-libs)
|
||||
TITLE:= WiFi library (libwifi)
|
||||
DEPENDS+=+libnl +libnl-route +libeasy +TARGET_iopsys_brcm63xx_arm:bcmkernel
|
||||
endef
|
||||
|
||||
define Package/libwifi/config
|
||||
if PACKAGE_libdsl
|
||||
config LIBWIFI_DEBUG
|
||||
depends on PACKAGE_libwifi
|
||||
bool "Enable wifi debugging"
|
||||
default n
|
||||
|
||||
endif
|
||||
endef
|
||||
|
||||
define Build/InstallDev/libwifi
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libwifi/wifi.h $(1)/usr/include/
|
||||
$(CP) $(PKG_BUILD_DIR)/libwifi/libwifi*.so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Package/libwifi/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libwifi/libwifi*.so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
4
endptmngr/Config.in
Executable file
4
endptmngr/Config.in
Executable file
@@ -0,0 +1,4 @@
|
||||
|
||||
config ENDPT_OPEN
|
||||
bool "Use pre-compiled version for Open SDK"
|
||||
default n
|
||||
69
endptmngr/Makefile
Normal file
69
endptmngr/Makefile
Normal file
@@ -0,0 +1,69 @@
|
||||
#
|
||||
# Copyright (C) 2018 IOPSYS Software Solutions AB
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=endptmngr
|
||||
PKG_VERSION:=0.6
|
||||
|
||||
LOCAL_DEV=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/endptmngr.git
|
||||
PKG_SOURCE_VERSION:=0901382048bb7ce01fc1767fef75e54692f56743
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
endif
|
||||
|
||||
PKG_LICENSE:=PROPRIETARY
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
export BUILD_DIR
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
# All config variable that are passed to the make invocation, directly or
|
||||
# indirectly. This ensures that the package is rebuilt on config-changes.
|
||||
PKG_CONFIG_DEPENDS:=CONFIG_TARGET_BOARD
|
||||
|
||||
export CONFIG_BRCM_SDK_VER_504040
|
||||
export CONFIG_BCM_CHIP_ID
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/endptmngr/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
define Package/endptmngr
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Broadcom Voice Endpoint Manager
|
||||
URL:=
|
||||
DEPENDS:= +libubox +ubus +libpicoevent +uci +bcmkernel @TARGET_HAS_VOICE @BCM_VOICE
|
||||
endef
|
||||
|
||||
define Package/endptmngr/description
|
||||
endptmngr
|
||||
endef
|
||||
|
||||
ifeq ($(LOCAL_DEV),1)
|
||||
define Build/Prepare
|
||||
rsync -av --exclude=.* ~/git/endptmngr/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
endif
|
||||
|
||||
TARGET_CFLAGS += \
|
||||
-Wall \
|
||||
-Werror
|
||||
|
||||
define Package/endptmngr/install
|
||||
$(CP) ./files/* $(1)/
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/endptmngr $(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,endptmngr))
|
||||
@@ -4,15 +4,13 @@ START=68
|
||||
STOP=12
|
||||
|
||||
USE_PROCD=1
|
||||
NAME=voicemngr
|
||||
NAME=endptmngr
|
||||
|
||||
start_service() {
|
||||
[ "$(db -q get hw.board.hasVoice)" = "1" ] || return
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param env hw_board_hasDect="$(db get hw.board.hasDect)" \
|
||||
hw_board_VoicePortNames="$(db get hw.board.VoicePortNames)" \
|
||||
|
||||
procd_set_param env hw_board_hasDect=$(db get hw.board.hasDect)
|
||||
procd_set_param command $NAME
|
||||
procd_set_param respawn "5" "0" "3"
|
||||
procd_set_param nice -12
|
||||
@@ -25,5 +23,5 @@ reload_service() {
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger asterisk
|
||||
procd_add_reload_trigger asterisk
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
if (PACKAGE_ethmngr)
|
||||
|
||||
menu "Configurations"
|
||||
|
||||
config TR181_VENDOR_EXTENSIONS_MACVLAN
|
||||
bool "Use TR181 vendor extension MACVLAN"
|
||||
default y
|
||||
endmenu
|
||||
endif
|
||||
@@ -1,33 +1,29 @@
|
||||
#
|
||||
# Copyright (C) 2020-2024 Iopsys
|
||||
# Copyright (C) 2020 Iopsys
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ethmngr
|
||||
PKG_VERSION:=2.1.7
|
||||
PKG_VERSION:=2.0.1
|
||||
|
||||
LOCAL_DEV:=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/hal/ethmngr.git
|
||||
PKG_SOURCE_VERSION:=d029ce86fe99b7896f096f68eda3f6caa000ee5f
|
||||
PKG_MAINTAINER:=Rahul Thakur <rahul.thakur@iopsys.eu>
|
||||
PKG_SOURCE_VERSION:=5a0ff3bc7c49dcb05129f423ef8e0c4929f6aa03
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/ethmngr.git
|
||||
|
||||
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:=GPL-2.0-only
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include ../bbfdm/bbfdm.mk
|
||||
|
||||
define Package/ethmngr
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Ethernet status and configration utility
|
||||
DEPENDS:=+(TARGET_brcmbca||TARGET_airoha||TARGET_ipq95xx||TARGET_ipq53xx||TARGET_mediatek):libethernet +libuci +libubox +ubus +libpthread +libnl-genl +libeasy +libbbfdm-api
|
||||
DEPENDS:=+libethernet +libuci +libubox +ubus +libpthread +libnl-genl
|
||||
endef
|
||||
|
||||
define Package/ethmngr/description
|
||||
@@ -36,43 +32,15 @@ define Package/ethmngr/description
|
||||
It uses APIs from the libethernet.so library.
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
ifeq ($(LOCAL_DEV),1)
|
||||
define Build/Prepare
|
||||
$(CP) -rf ./ethmngr/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
endif
|
||||
|
||||
TARGET_CFLAGS += \
|
||||
-I$(STAGING_DIR)/usr/include \
|
||||
-I$(STAGING_DIR)/usr/include/libnl3 \
|
||||
-D_GNU_SOURCE \
|
||||
-DBBF_VENDOR_PREFIX=\\\"$(CONFIG_BBF_VENDOR_PREFIX)\\\"
|
||||
|
||||
ifeq ($(CONFIG_TR181_VENDOR_EXTENSIONS_MACVLAN),y)
|
||||
TARGET_CFLAGS += -DTR181_VENDOR_EXTENSIONS_MACVLAN
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_TARGET_brcmbca)$(CONFIG_TARGET_airoha)$(CONFIG_TARGET_ipq95xx)$(CONFIG_TARGET_ipq53xx)$(CONFIG_TARGET_mediatek),)
|
||||
define Build/Compile
|
||||
endef
|
||||
endif
|
||||
-D_GNU_SOURCE
|
||||
|
||||
define Package/ethmngr/install
|
||||
$(CP) ./files/* $(1)/
|
||||
$(INSTALL_DIR) $(1)/etc/ethmngr
|
||||
$(INSTALL_DIR) $(1)/etc/ethmngr/plugins
|
||||
ifneq ($(CONFIG_TARGET_brcmbca)$(CONFIG_TARGET_airoha)$(CONFIG_TARGET_ipq95xx)$(CONFIG_TARGET_ipq53xx)$(CONFIG_TARGET_mediatek),)
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_DIR) $(1)/etc/init.d $(1)/usr/sbin
|
||||
$(INSTALL_BIN) ./files/ethmngr.init $(1)/etc/init.d/ethmngr
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ethmngr $(1)/usr/sbin/
|
||||
endif
|
||||
$(BBFDM_INSTALL_MS_DM) $(PKG_BUILD_DIR)/libbbfethernet.so $(1) $(PKG_NAME)
|
||||
ifeq ($(CONFIG_TR181_VENDOR_EXTENSIONS_MACVLAN),y)
|
||||
$(BBFDM_INSTALL_MS_PLUGIN) $(PKG_BUILD_DIR)/libbbfethernetmacvlan.so $(1) $(PKG_NAME)
|
||||
endif
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ethmngr))
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ -n "$PORT" -a -n "$LINK" ] || exit 0
|
||||
|
||||
case "$PORT" in
|
||||
# do not generate ethport ubus event
|
||||
# for wifi, dsl and brige devices
|
||||
wl*|wds*|atm*|ptm*|br-*)
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
speed=0
|
||||
duplex=full
|
||||
|
||||
if [ "$LINK" = "up" ]; then
|
||||
devspeed="$(ubus -t 2 call network.device status "{\"name\":\"$PORT\"}" | jsonfilter -e @.speed)"
|
||||
speed=${devspeed:0:-1}
|
||||
duplex=${devspeed:0-1}
|
||||
[ "$duplex" == "H" ] && duplex="half" || duplex="full"
|
||||
fi
|
||||
|
||||
ubus send ethport "{\"ifname\":\"$PORT\",\"link\":\"$LINK\",\"speed\":\"$speed\",\"duplex\":\"$duplex\"}"
|
||||
@@ -1,28 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=15
|
||||
STOP=90
|
||||
|
||||
USE_PROCD=1
|
||||
PROG=/usr/sbin/ethmngr
|
||||
|
||||
. /lib/functions.sh
|
||||
include /lib/ethernet
|
||||
|
||||
start_service() {
|
||||
if [ -f $PROG ]; then
|
||||
procd_open_instance
|
||||
procd_set_param command ${PROG}
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
fi
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger network
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"ethport_update": {
|
||||
"if" : [
|
||||
{
|
||||
"event": "network.device"
|
||||
}
|
||||
],
|
||||
"then" : [
|
||||
{
|
||||
"cli": "/sbin/hotplug-call ethernet",
|
||||
"envs": {
|
||||
"PORT": "&network.device->ifname",
|
||||
"LINK": "&network.device->link"
|
||||
},
|
||||
"timeout": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
uci -q set ruleng.ethport=rule
|
||||
uci -q set ruleng.ethport.recipe='/etc/ruleng/ethport.json'
|
||||
6
csmngr/files/etc/init.d/csmngr → ethmngr/files/ethmngr.init
Executable file → Normal file
6
csmngr/files/etc/init.d/csmngr → ethmngr/files/ethmngr.init
Executable file → Normal file
@@ -4,13 +4,12 @@ START=95
|
||||
STOP=10
|
||||
|
||||
USE_PROCD=1
|
||||
PROG=/usr/sbin/csmngr
|
||||
PROG=/usr/sbin/ethmngr
|
||||
|
||||
start_service() {
|
||||
procd_open_instance
|
||||
procd_set_param command ${PROG}
|
||||
# procd_set_param stderr 1 #for debugging only
|
||||
# procd_set_param respawn
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
@@ -18,4 +17,3 @@ reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
107
evoice/Makefile
Normal file
107
evoice/Makefile
Normal file
@@ -0,0 +1,107 @@
|
||||
#
|
||||
# Copyright (C) 2022 IOPSYS Software Solutions AB
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=evoice
|
||||
PKG_VERSION:=0.2.29
|
||||
|
||||
LOCAL_DEV=0
|
||||
LOCAL_DEV_EVOICE_DIR=~/voip/evoice
|
||||
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/evoice.git
|
||||
PKG_SOURCE_VERSION:=ee4e9e00ec1c54b41e15a3de38f6a733634622dd
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
endif
|
||||
|
||||
PKG_LICENSE:=PROPRIETARY IOPSYS
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
PKG_BUILD_DEPENDS:=bbf
|
||||
# All config variable that are passed to the make invocation, directly or
|
||||
# indirectly. This ensures that the package is rebuilt on config-changes.
|
||||
#PKG_CONFIG_DEPENDS:=CONFIG_TARGET_BOARD
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Telephony
|
||||
TITLE:=Ensemble Voice
|
||||
URL:=
|
||||
DEPENDS:= +libubox +libubus +libpicoevent +libuci +libstdcpp +libopenssl +libjson-c\
|
||||
+TARGET_iopsys_brcm63xx_arm:bcmkernel\
|
||||
+TARGET_iopsys_econet:kmod-voip_driver\
|
||||
+TARGET_iopsys_econet:voip_app
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
Ensemble Voice. A stand alone SIP VoIP application.
|
||||
endef
|
||||
|
||||
ifeq ($(LOCAL_DEV),1)
|
||||
# If you want to build the code from your own local repositiory enable
|
||||
# LOCAL_DEV and set LOCAL_DEV_EVOICE_DIR to your own git repository.
|
||||
define Build/Prepare
|
||||
@echo "======================================================="
|
||||
@echo "DEVELOPMENT BUILD! rsync $(LOCAL_DEV_EVOICE_DIR) to $(PKG_BUILD_DIR)"
|
||||
@echo "======================================================="
|
||||
rsync -a $(LOCAL_DEV_EVOICE_DIR)/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
endif
|
||||
|
||||
IDIR = $(STAGING_DIR)/usr/include
|
||||
TONES_INI_REQUIRED=
|
||||
|
||||
ifeq ($(CONFIG_TARGET_iopsys_brcm63xx_arm),y)
|
||||
TARGET_PLATFORM=BROADCOM
|
||||
BDIR = bcm963xx/userspace/private/apps/voice
|
||||
CC_FLAGS = -I$(IDIR) -I$(IDIR)/$(BDIR)/inc\
|
||||
-I$(IDIR)/bcm963xx/xchg/bos/publicInc\
|
||||
-I$(IDIR)/bcm963xx/bcmdrivers/broadcom/include/bcm963xx
|
||||
TRG=SVrgBcmFxs
|
||||
JSONFILE=codecs_brcm.json
|
||||
else ifeq ($(CONFIG_TARGET_iopsys_econet),y)
|
||||
TARGET_PLATFORM=ECONET
|
||||
TONES_INI_REQUIRED=y
|
||||
TRG=SVrgMtekOwrt
|
||||
JSONFILE=codecs_airoha.json
|
||||
endif
|
||||
|
||||
# disable temporarily some not important warnings, force PIC
|
||||
CC_FLAGS_VS=$(CC_FLAGS) -Wno-unused-parameter -Wno-unused-function -fPIC
|
||||
|
||||
export TARGET_PLATFORM
|
||||
|
||||
#used and altered by BIDE makefiles
|
||||
export _XFLAGS
|
||||
|
||||
BIDE_MAKE_OPTS = -r -R -C $(PKG_BUILD_DIR) -f _bld/src/cdabs.mk\
|
||||
SWB=b_gxxqca6 HWA=a_openwrt HWC=c_hosted OSP=p_posix LIF=cerder DBG=dbg
|
||||
|
||||
define Build/Compile
|
||||
@echo "TARGET_PLATFORM=${TARGET_PLATFORM}"
|
||||
+$(MAKE) $(BIDE_MAKE_OPTS) CC_FLAGS="$(CC_FLAGS)" TRG=$(TRG)
|
||||
|
||||
@echo "clean libvoiceservice before building shared lib!"
|
||||
+$(MAKE) $(BIDE_MAKE_OPTS) CC_FLAGS="$(CC_FLAGS_VS)" TRG=libvoiceservice cleanall
|
||||
+$(MAKE) $(BIDE_MAKE_OPTS) CC_FLAGS="$(CC_FLAGS_VS)" TRG=libvoiceservice
|
||||
endef
|
||||
|
||||
define Package/evoice/install
|
||||
$(CP) ./files/* $(1)/
|
||||
$(if $(TONES_INI_REQUIRED),,$(RM) $(1)/etc/evoice/tones.ini)
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(CP) $(1)/lib/voice/$(JSONFILE) $(1)/lib/voice/codecs_evoice.json
|
||||
$(RM) $(1)/lib/voice/codecs_brcm.json
|
||||
$(RM) $(1)/lib/voice/codecs_airoha.json
|
||||
$(INSTALL_DIR) $(1)/usr/lib/bbfdm
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/_bin/a_openwrt/evoice $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/_bin/a_openwrt/libvoiceservice.so $(1)/usr/lib/bbfdm/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,evoice))
|
||||
327
evoice/files/etc/config/voice
Normal file
327
evoice/files/etc/config/voice
Normal file
@@ -0,0 +1,327 @@
|
||||
|
||||
config SIPClient 'Client1'
|
||||
option Enable '1'
|
||||
option RegisterMode 'RFC3261'
|
||||
option AuthUserName '51234'
|
||||
option AuthPassword '51234'
|
||||
option Network 'Network1'
|
||||
option MaxSessions '5'
|
||||
option RegisiterURI '51234@sip-proxy.iopsys.eu'
|
||||
option E164Format '1'
|
||||
|
||||
config SIPClient 'Client2'
|
||||
option Enable '1'
|
||||
option RegisterMode 'RFC3261'
|
||||
option AuthUserName '51235'
|
||||
option AuthPassword '51235'
|
||||
option Network 'Network1'
|
||||
option MaxSessions '5'
|
||||
option RegisiterURI '51235@sip-proxy.iopsys.eu'
|
||||
option E164Format '1'
|
||||
|
||||
config SIPNetwork 'Network1'
|
||||
option Enable '1'
|
||||
option ProxyServer 'sip-proxy.iopsys.eu'
|
||||
option ProxyServerPort '5060'
|
||||
option ProxyServerTransport 'UDP'
|
||||
option RegistrarServer 'sip-proxy.iopsys.eu'
|
||||
option RegistrarServerPort '5060'
|
||||
option RegistrarServerTransport 'UDP'
|
||||
option RegistrationPeriod '3240'
|
||||
option RegisterExpires '3600'
|
||||
option UserAgentDomain ' '
|
||||
option TimerRegistrationFailed '120'
|
||||
option TimerT1 '500'
|
||||
option VoIPProfile 'VoIPProfile1'
|
||||
list CodecList '1CodecProfile1'
|
||||
list CodecList '1CodecProfile2'
|
||||
list CodecList '1CodecProfile3'
|
||||
list CodecList '1CodecProfile5'
|
||||
list CodecList '1CodecProfile4'
|
||||
|
||||
config CodecProfile '1CodecProfile1'
|
||||
option Enable '1'
|
||||
option Codec 'G.711ALaw'
|
||||
option PacketizationPeriod '20'
|
||||
option SilenceSupression '1'
|
||||
|
||||
config CodecProfile '1CodecProfile2'
|
||||
option Enable '1'
|
||||
option Codec 'G.711MuLaw'
|
||||
option PacketizationPeriod '20'
|
||||
option SilenceSupression '1'
|
||||
|
||||
config CodecProfile '1CodecProfile3'
|
||||
option Enable '1'
|
||||
option Codec 'G.726'
|
||||
option PacketizationPeriod '20'
|
||||
option SilenceSupression '0'
|
||||
|
||||
config CodecProfile '1CodecProfile4'
|
||||
option Enable '1'
|
||||
option Codec 'G.722'
|
||||
option PacketizationPeriod '20'
|
||||
option SilenceSupression '0'
|
||||
|
||||
config CodecProfile '1CodecProfile5'
|
||||
option Enable '1'
|
||||
option Codec 'G.729'
|
||||
option PacketizationPeriod '20'
|
||||
option SilenceSupression '0'
|
||||
|
||||
config VoIPProfile 'VoIPProfile1'
|
||||
option Enable '1'
|
||||
option DTMFMethod 'RFC4733'
|
||||
option RTP '1RTP'
|
||||
|
||||
config RTP '1RTP'
|
||||
option LocalPortMin '10020'
|
||||
option LocalPortMax '10039'
|
||||
option JitterBufferType 'Static'
|
||||
|
||||
config FXXPorts 'POTS'
|
||||
option Region 'US'
|
||||
|
||||
config FXSPorts 'FXS1'
|
||||
option Enable '1'
|
||||
option DialType 'Tone'
|
||||
option TransmitGain '0'
|
||||
option ReceiveGain '0'
|
||||
option EchoCancellationEnable '1'
|
||||
|
||||
config FXSPorts 'FXS2'
|
||||
option Enable '1'
|
||||
option DialType 'Tone'
|
||||
option TransmitGain '0'
|
||||
option ReceiveGain '0'
|
||||
option EchoCancellationEnable '1'
|
||||
|
||||
config Extension 'Extension1'
|
||||
option Enable '1'
|
||||
option ExtensionNumber '10#'
|
||||
option Provider 'FXS1'
|
||||
option CallingFeatures 'Set1'
|
||||
option Name 'Phone 1'
|
||||
|
||||
config Extension 'Extension2'
|
||||
option Enable '1'
|
||||
option ExtensionNumber '11#'
|
||||
option Provider 'FXS2'
|
||||
option CallingFeatures 'Set1'
|
||||
option Name 'Phone 2'
|
||||
|
||||
config Line 'Line1'
|
||||
option Enable '1'
|
||||
option Provider 'Client1'
|
||||
option CallingFeatures 'Set1'
|
||||
|
||||
config Line 'Line2'
|
||||
option Enable '1'
|
||||
option Provider 'Client2'
|
||||
option CallingFeatures 'Set2'
|
||||
|
||||
config IncomingMap 'IncomingMap1'
|
||||
option Enable '1'
|
||||
option Extension 'Extension1'
|
||||
option Line 'Line1'
|
||||
|
||||
config IncomingMap 'IncomingMap2'
|
||||
option Enable '1'
|
||||
option Extension 'Extension2'
|
||||
option Line 'Line2'
|
||||
|
||||
config IncomingMap 'IncomingMap3'
|
||||
option Enable '0'
|
||||
option Extension 'Extension2'
|
||||
option Line 'Line1'
|
||||
|
||||
config OutgoingMap 'OutgoingMap1'
|
||||
option Enable '1'
|
||||
option Extension 'Extension1'
|
||||
option Line 'Line1'
|
||||
|
||||
config OutgoingMap 'OutgoingMap2'
|
||||
option Enable '1'
|
||||
option Extension 'Extension2'
|
||||
option Line 'Line2'
|
||||
|
||||
config CallingFeatures 'Set1'
|
||||
option CallerIDEnable '1'
|
||||
option CallerIDNameEnable '1'
|
||||
option CallForwardUnconditionalEnable '0'
|
||||
option CallForwardUnconditionalNumber ' '
|
||||
option CallForwardOnBusyEnable '0'
|
||||
option CallForwardOnBusyNumber ' '
|
||||
option CallForwardOnNoAnswerEnable '0'
|
||||
option CallForwardOnNoAnswerRingTimeout '24'
|
||||
option CallForwardOnNoAnswerNumber ' '
|
||||
option CallTransferEnable '1'
|
||||
option MWIEnable '1'
|
||||
option VMWIEnable '1'
|
||||
option LineMessagesWaiting '0'
|
||||
option AnonymousCallRejectionEnable '0'
|
||||
option AnonymousCallEnable '1'
|
||||
option DoNotDisturbEnable '1'
|
||||
option RepeatDialEnable '1'
|
||||
option VoiceMailEnable '1'
|
||||
option CallPickUpEnable '1'
|
||||
option CCBSEnable '1'
|
||||
option CallWaitingEnable '0'
|
||||
|
||||
config CallingFeatures 'Set2'
|
||||
option CallerIDEnable '1'
|
||||
option CallerIDNameEnable '1'
|
||||
option CallForwardUnconditionalEnable '0'
|
||||
option CallForwardUnconditionalNumber ' '
|
||||
option CallForwardOnBusyEnable '0'
|
||||
option CallForwardOnBusyNumber ' '
|
||||
option CallForwardOnNoAnswerEnable '0'
|
||||
option CallForwardOnNoAnswerRingTimeout '24'
|
||||
option CallForwardOnNoAnswerNumber ' '
|
||||
option CallTransferEnable '1'
|
||||
option MWIEnable '1'
|
||||
option VMWIEnable '1'
|
||||
option LineMessagesWaiting '0'
|
||||
option AnonymousCallRejectionEnable '0'
|
||||
option AnonymousCallEnable '1'
|
||||
option DoNotDisturbEnable '1'
|
||||
option RepeatDialEnable '1'
|
||||
option VoiceMailEnable '1'
|
||||
option CallPickUpEnable '1'
|
||||
option CCBSEnable '1'
|
||||
option CallWaitingEnable '1'
|
||||
|
||||
config NumberingPlan 'NumberingPlan1'
|
||||
option MinimumNumberOfDigits '1'
|
||||
option MaximumNumberOfDigits '15'
|
||||
option InterDigitTimerStd '2000'
|
||||
option InterDigitTimerOpen '2000'
|
||||
option TerminationDigit '#'
|
||||
|
||||
config NumberingPlan 'NumberingPlan2'
|
||||
option MinimumNumberOfDigits '5'
|
||||
option MaximumNumberOfDigits '15'
|
||||
option InterDigitTimerStd '2000'
|
||||
option InterDigitTimerOpen '2000'
|
||||
option TerminationDigit ' '
|
||||
list PrefixList '2PrefixInfo1'
|
||||
list PrefixList '2PrefixInfo2'
|
||||
list PrefixList '2PrefixInfo3'
|
||||
list PrefixList '2PrefixInfo4'
|
||||
list PrefixList '2PrefixInfo5'
|
||||
list PrefixList '2PrefixInfo6'
|
||||
list PrefixList '2PrefixInfo7'
|
||||
list PrefixList '2PrefixInfo8'
|
||||
list PrefixList '2PrefixInfo9'
|
||||
|
||||
config NumberingPlan 'NumberingPlan3'
|
||||
option MinimumNumberOfDigits '5'
|
||||
option MaximumNumberOfDigits '15'
|
||||
option InterDigitTimerStd '2000'
|
||||
option InterDigitTimerOpen '2000'
|
||||
option TerminationDigit '#'
|
||||
list PrefixList '3PrefixInfo1'
|
||||
|
||||
config PrefixInfo '2PrefixInfo1'
|
||||
option Enable '1'
|
||||
option PrefixRange '*43#'
|
||||
option PrefixMinNumberOfDigits '4'
|
||||
option PrefixMaxNumberOfDigits '4'
|
||||
option NumberOfDigitsToRemove '0'
|
||||
option PosOfDigitsToRemove '0'
|
||||
option FacilityAction 'CW_ACTIVATE'
|
||||
option FacilityActionArgument ' '
|
||||
|
||||
config PrefixInfo '2PrefixInfo2'
|
||||
option Enable '1'
|
||||
option PrefixRange '#43#'
|
||||
option PrefixMinNumberOfDigits '4'
|
||||
option PrefixMaxNumberOfDigits '4'
|
||||
option NumberOfDigitsToRemove '0'
|
||||
option PosOfDigitsToRemove '0'
|
||||
option FacilityAction 'CW_DEACTIVATE'
|
||||
option FacilityActionArgument ' '
|
||||
|
||||
config PrefixInfo '2PrefixInfo3'
|
||||
option Enable '1'
|
||||
option PrefixRange '*21*(X+)#'
|
||||
option PrefixMinNumberOfDigits '9'
|
||||
option PrefixMaxNumberOfDigits '9'
|
||||
option NumberOfDigitsToRemove '0'
|
||||
option PosOfDigitsToRemove '0'
|
||||
option FacilityAction 'CFU_ACTIVATE'
|
||||
option FacilityActionArgument ' '
|
||||
|
||||
config PrefixInfo '2PrefixInfo4'
|
||||
option Enable '1'
|
||||
option PrefixRange '#21#'
|
||||
option PrefixMinNumberOfDigits '4'
|
||||
option PrefixMaxNumberOfDigits '4'
|
||||
option NumberOfDigitsToRemove '0'
|
||||
option PosOfDigitsToRemove '0'
|
||||
option FacilityAction 'CFU_DEACTIVATE'
|
||||
option FacilityActionArgument ' '
|
||||
|
||||
config PrefixInfo '2PrefixInfo5'
|
||||
option Enable '1'
|
||||
option PrefixRange '*67*(X+)#'
|
||||
option PrefixMinNumberOfDigits '9'
|
||||
option PrefixMaxNumberOfDigits '9'
|
||||
option NumberOfDigitsToRemove '0'
|
||||
option PosOfDigitsToRemove '0'
|
||||
option FacilityAction 'CFB_ACTIVATE'
|
||||
option FacilityActionArgument ' '
|
||||
|
||||
config PrefixInfo '2PrefixInfo6'
|
||||
option Enable '1'
|
||||
option PrefixRange '#67#'
|
||||
option PrefixMinNumberOfDigits '4'
|
||||
option PrefixMaxNumberOfDigits '4'
|
||||
option NumberOfDigitsToRemove '0'
|
||||
option PosOfDigitsToRemove '0'
|
||||
option FacilityAction 'CFB_DEACTIVATE'
|
||||
option FacilityActionArgument ' '
|
||||
|
||||
config PrefixInfo '2PrefixInfo7'
|
||||
option Enable '1'
|
||||
option PrefixRange '*61*(X+(*X+)?)#'
|
||||
option PrefixMinNumberOfDigits '15'
|
||||
option PrefixMaxNumberOfDigits '15'
|
||||
option NumberOfDigitsToRemove '0'
|
||||
option PosOfDigitsToRemove '0'
|
||||
option FacilityAction 'CFNR_ACTIVATE'
|
||||
option FacilityActionArgument ' '
|
||||
|
||||
config PrefixInfo '2PrefixInfo8'
|
||||
option Enable '1'
|
||||
option PrefixRange '#61#'
|
||||
option PrefixMinNumberOfDigits '4'
|
||||
option PrefixMaxNumberOfDigits '4'
|
||||
option NumberOfDigitsToRemove '0'
|
||||
option PosOfDigitsToRemove '0'
|
||||
option FacilityAction 'CFNR_DEACTIVATE'
|
||||
option FacilityActionArgument ' '
|
||||
|
||||
config PrefixInfo '2PrefixInfo9'
|
||||
option Enable '1'
|
||||
option PrefixRange '*31*'
|
||||
option PrefixMinNumberOfDigits '4'
|
||||
option PrefixMaxNumberOfDigits '4'
|
||||
option NumberOfDigitsToRemove '0'
|
||||
option PosOfDigitsToRemove '0'
|
||||
option FacilityAction 'CA_ACTIVATE'
|
||||
option FacilityActionArgument ' '
|
||||
|
||||
config PrefixInfo '3PrefixInfo1'
|
||||
option Enable '1'
|
||||
option PrefixRange '110|112'
|
||||
option PrefixMinNumberOfDigits '7'
|
||||
option PrefixMaxNumberOfDigits '7'
|
||||
option NumberOfDigitsToRemove '0'
|
||||
option PosOfDigitsToRemove '0'
|
||||
option FacilityAction 'X_IOPSYS_EU_EMERGENCY'
|
||||
option FacilityActionArgument ' '
|
||||
|
||||
config DialPlan 'X_IOPSYS_EU_InternalNumber1'
|
||||
option RegExp '1X#'
|
||||
|
||||
1564
evoice/files/etc/evoice/tones.ini
Normal file
1564
evoice/files/etc/evoice/tones.ini
Normal file
File diff suppressed because it is too large
Load Diff
174
evoice/files/etc/evoice/voicedm
Normal file
174
evoice/files/etc/evoice/voicedm
Normal file
@@ -0,0 +1,174 @@
|
||||
# RO (Main)
|
||||
config account 'map_board'
|
||||
option HW_Has_Voice 'hw.board.hasVoice'
|
||||
option HW_Has_DECT 'hw.board.hasDect'
|
||||
option HW_Nr_Of_POTS_Ports 'hw.board.VoicePorts'
|
||||
option HW_VoiceDSP 'hw.board.VoiceDSP'
|
||||
option ProductID 'device.deviceinfo.ModelName'
|
||||
option I3_VERSION 'device.deviceinfo.SoftwareVersion'
|
||||
option SerialNumber 'device.deviceinfo.SerialNumber'
|
||||
|
||||
config account 'map_pots'
|
||||
option Country 'voice.POTS.Region'
|
||||
|
||||
# Voice Service navigation paths
|
||||
# Not used to initialize internal configuration
|
||||
config navigation 'map_vs'
|
||||
option Account 'voice.Client@.'
|
||||
option Network 'voice.Client@.Network'
|
||||
option VoIPProfile 'voice.Network@.VoIPProfile'
|
||||
option CfAccount 'voice.Line@.CallingFeatures'
|
||||
option CfPhone 'voice.Extension@.CallingFeatures'
|
||||
option CodecList 'voice.Network@.CodecList'
|
||||
option Codec 'voice.Codec@.Codec'
|
||||
option OutgoingMapEnabled 'voice.OutgoingMap@.Enable'
|
||||
option From_Phone 'voice.OutgoingMap@.Extension'
|
||||
option Extension 'voice.Extension@.Provider'
|
||||
option To_Account 'voice.OutgoingMap@.Line'
|
||||
option Line 'voice.Line@.Provider'
|
||||
option LineEnable 'voice.Line@.Enable'
|
||||
option LineProvider 'voice.Line@.Provider'
|
||||
option IncomingMapEnabled 'voice.IncomingMap@.Enable'
|
||||
option From_Account 'voice.IncomingMap@.Line'
|
||||
option To_Phone 'voice.IncomingMap@.Extension'
|
||||
option ExtensionEnable 'voice.Extension@.Enable'
|
||||
option ExtensionProvider 'voice.Extension@.Provider'
|
||||
|
||||
# Registration for account A-Z is associate with SIP.Clienti.Enable
|
||||
# All parameters in this table are written to internal configuration
|
||||
config account 'map_account'
|
||||
option Registration 'voice.Client@.Enable'
|
||||
option Display_Name ''
|
||||
option PhoneNumber 'voice.Client@.RegisiterURI'
|
||||
option Username 'voice.Client@.AuthUserName'
|
||||
option Password 'voice.Client@.AuthPassword'
|
||||
option SIP_Telephone_Syntax 'voice.Client@.E164Format'
|
||||
option Device_Description 'voice.Client@.UserAgent'
|
||||
|
||||
# Network stuff associated with an account.
|
||||
# All parameters in this table are written to internal configuration
|
||||
config network 'map_net'
|
||||
option Enable 'voice.Network@.Enable'
|
||||
option Registration_Server 'voice.Network@.RegistrarServer'
|
||||
option Outbound_Proxy 'voice.Network@.ProxyServer'
|
||||
option SIP_Port 'voice.Network@.RegistrarServerPort'
|
||||
option SIP_Transport 'voice.Network@.RegistrarServerTransport'
|
||||
option RegistrationPeriod 'voice.Network@.RegistrationPeriod'
|
||||
option Registration_Interval 'voice.Network@.RegisterExpires'
|
||||
option Reg_Failure_Interval 'voice.Network@.TimerRegistrationFailed'
|
||||
option T1 'voice.Network@.TimerT1'
|
||||
option UserAgentDomain 'voice.Network@.UserAgentDomain'
|
||||
|
||||
config VoIPProfile 'map_voip'
|
||||
option Enable 'voice.VoIPProfile@.Enable'
|
||||
option DTMF_Method 'voice.VoIPProfile@.DTMFMethod'
|
||||
option RTP 'voice.VoIPProfile@.RTP'
|
||||
|
||||
config RTP 'map_rtp'
|
||||
option RTP_Port_Base 'voice.@RTP@.LocalPortMin'
|
||||
option RTP_Port_End 'voice.@RTP@.LocalPortMax'
|
||||
|
||||
config codecs 'map_codec'
|
||||
option Codec 'voice.CodecProfile@.Codec'
|
||||
option enable 'voice.CodecProfile@.Enable'
|
||||
option ptime 'voice.CodecProfile@.PacketizationPeriod'
|
||||
option dtx 'voice.CodecProfile@.SilenceSupression'
|
||||
|
||||
config fxsinfo 'map_fxs'
|
||||
option Enable 'voice.FXS@.Enable'
|
||||
option DialType 'voice.FXS@.DialType'
|
||||
option TransmitGain 'voice.FXS@.TransmitGain'
|
||||
option ReceiveGain 'voice.FXS@.ReceiveGain'
|
||||
option EchoCancellationEnable 'voice.FXS@.EchoCancellationEnable'
|
||||
|
||||
config extensioninfo 'map_ext'
|
||||
option Enable 'voice.Extension@.Enable'
|
||||
option Internal_Number_Phone 'voice.Extension@.ExtensionNumber'
|
||||
option Display_Name_Phone 'voice.Extension@.Name'
|
||||
|
||||
config capabilities 'map_capa'
|
||||
option Call_Waiting_Enable 'voice.Capabilities@FacilityActions'
|
||||
option Enable_Call_Diversion 'voice.Capabilities@FacilityActions'
|
||||
|
||||
config cs_account 'map_set'
|
||||
option BusyCallWait 'voice.Set@.CallWaitingEnable'
|
||||
option AlwaysDivert 'voice.Set@.CallForwardUnconditionalEnable'
|
||||
option CFU_Number 'voice.Set@.CallForwardUnconditionalNumber'
|
||||
option BusyDivert 'voice.Set@.CallForwardOnBusyEnable'
|
||||
option CFB_Number 'voice.Set@.CallForwardOnBusyNumber'
|
||||
option NoAnswDivert 'voice.Set@.CallForwardOnNoAnswerEnable'
|
||||
option CFNR_Number 'voice.Set@.CallForwardOnNoAnswerNumber'
|
||||
option CFNR_Timeout 'voice.Set@.CallForwardOnNoAnswerRingTimeout'
|
||||
option Enable_Call_Transfer 'voice.Set@.CallTransferEnable'
|
||||
option AnonymousReject 'voice.Set@.AnonymousCallRejectionEnable'
|
||||
option AllowAnonymousConf 'voice.Set@.AnonymousCallEnable'
|
||||
option CallerIDEnable 'voice.Set@.CallerIDEnable'
|
||||
|
||||
config cs_xvendor 'map_np_cs'
|
||||
option np_sc_actCW 'voice.X_IOPSYS_EU_NpSc@.CW_ACT'
|
||||
option np_sc_actCW_output 'voice.X_IOPSYS_EU_NpSc@.CW_OUT'
|
||||
option np_sc_deactCW 'voice.X_IOPSYS_EU_NpSc@.CW_DEACT'
|
||||
option np_sc_isactCW 'voice.X_IOPSYS_EU_NpSc@.CW_ISACT'
|
||||
option np_sc_actCFU 'voice.X_IOPSYS_EU_NpSc@.CFU_ACT'
|
||||
option np_sc_actCFU_output 'voice.X_IOPSYS_EU_NpSc@.CFU_OUT'
|
||||
option np_sc_deactCFU 'voice.X_IOPSYS_EU_NpSc@.CFU_DEACT'
|
||||
option np_sc_actCFB 'voice.X_IOPSYS_EU_NpSc@.CFB_ACT'
|
||||
option np_sc_actCFB_output 'voice.X_IOPSYS_EU_NpSc@.CFB_OUT'
|
||||
option np_sc_deactCFB 'voice.X_IOPSYS_EU_NpSc@.CFB_DEACT'
|
||||
option np_sc_actCFNR 'voice.X_IOPSYS_EU_NpSc@.CFNR_ACT'
|
||||
option np_sc_actCFNR_output 'voice.X_IOPSYS_EU_NpSc@.CFNR_OUT'
|
||||
option np_sc_deactCFNR 'voice.X_IOPSYS_EU_NpSc@.CFNR_DEACT'
|
||||
option np_sc_actRA 'voice.X_IOPSYS_EU_NpSc@.RA_ACT'
|
||||
option np_sc_deactRA 'voice.X_IOPSYS_EU_NpSc@.RA_DEACT'
|
||||
option np_sc_actAC 'voice.X_IOPSYS_EU_NpSc@.AC_ACT'
|
||||
option np_sc_deactAC 'voice.X_IOPSYS_EU_NpSc@.AC_DEACT'
|
||||
option np_sc_actAA 'voice.X_IOPSYS_EU_NpSc@.AA_ACT'
|
||||
option np_sc_deactAA 'voice.X_IOPSYS_EU_NpSc@.AA_DEACT'
|
||||
option np_sc_actAD 'voice.X_IOPSYS_EU_NpSc@.AD_ACT'
|
||||
option np_sc_actAD_output 'voice.X_IOPSYS_EU_NpSc@.AD_OUT'
|
||||
option np_sc_deactAD 'voice.X_IOPSYS_EU_NpSc@.AD_DEACT'
|
||||
option np_sc_actMWSplash 'voice.X_IOPSYS_EU_NpSc@.MWI_SPLASH_ACT'
|
||||
option np_sc_deactMWSplash 'voice.X_IOPSYS_EU_NpSc@.MWI_SPLASH_DEACT'
|
||||
option np_sc_actMWTone 'voice.X_IOPSYS_EU_NpSc@.MWI_TONE_ACT'
|
||||
option np_sc_deactMWTone 'voice.X_IOPSYS_EU_NpSc@.MWI_TONE_DEACT'
|
||||
option np_sc_redial 'voice.X_IOPSYS_EU_NpSc@.REDIAL'
|
||||
option np_sc_setMiscConf 'voice.X_IOPSYS_EU_NpSc@.SET_MISC'
|
||||
|
||||
config cc_xvendor 'map_np_in'
|
||||
option np_in_limitExp 'voice.X_IOPSYS_EU_InternalNumber@.RegExp'
|
||||
|
||||
config cc_xvendor 'map_np_sh'
|
||||
option sh_no_str 'voice.X_IOPSYS_EU_ShortNumber@.RegExp'
|
||||
|
||||
config cc_xvendor 'map_np_eme'
|
||||
option np_eme 'voice.X_IOPSYS_EU_EmergencyNumber@.RegExp'
|
||||
option np_eme_out 'voice.X_IOPSYS_EU_EmergencyNumber@.OutStr'
|
||||
|
||||
config cc_xvendor 'map_np_rn'
|
||||
option np_rn 'voice.X_IOPSYS_EU_RegularNumber@.RegExp'
|
||||
option np_rn_out 'voice.X_IOPSYS_EU_RegularNumber@.OutStr'
|
||||
option np_rn_account 'voice.X_IOPSYS_EU_RegularNumber@.AccStr'
|
||||
|
||||
config cc_xvendor 'map_np_bn'
|
||||
option np_bn 'voice.X_IOPSYS_EU_BarredNumber@.RegExp'
|
||||
option np_bn_out 'voice.X_IOPSYS_EU_BarredNumber@.OutStr'
|
||||
|
||||
config TR104NumberingPlan 'map_np_tr'
|
||||
option min_digits 'voice.NumberingPlan@.MinimumNumberOfDigits'
|
||||
option max_digits 'voice.NumberingPlan@.MaximumNumberOfDigits'
|
||||
option tmo_std 'voice.NumberingPlan@.InterDigitTimerStd'
|
||||
option tmo_open 'voice.NumberingPlan@.InterDigitTimerOpen'
|
||||
option term_digit 'voice.NumberingPlan@.TerminationDigit'
|
||||
option prefix_list 'voice.NumberingPlan@.PrefixList'
|
||||
|
||||
config TR104NumberingPlanPrefix 'map_np_pf'
|
||||
option enable 'voice.@PrefixInfo@.Enable'
|
||||
option range 'voice.@PrefixInfo@.PrefixRange'
|
||||
option prefix_min_digits 'voice.@PrefixInfo@.PrefixMinNumberOfDigits'
|
||||
option prefix_max_digits 'voice.@PrefixInfo@.PrefixMaxNumberOfDigits'
|
||||
option remove_digits 'voice.@PrefixInfo@.NumberOfDigitsToRemove'
|
||||
option remove_pos 'voice.@PrefixInfo@.NumberOfDigitsToRemove'
|
||||
option facility_act 'voice.@PrefixInfo@.FacilityAction'
|
||||
option facility_arg 'voice.@PrefixInfo@.FacilityActionArgument'
|
||||
|
||||
|
||||
57
evoice/files/etc/evoice/voicero
Normal file
57
evoice/files/etc/evoice/voicero
Normal file
@@ -0,0 +1,57 @@
|
||||
config static_prm 'defaults'
|
||||
option Print_Control '4'
|
||||
option Print_UDP_Addr '192.168.1.3'
|
||||
option Print_UDP_Port '60000'
|
||||
option Verbosity 'On'
|
||||
option Failure_Log 'On'
|
||||
option Message_Log 'On'
|
||||
option Method_Trace 'Off'
|
||||
option Dial_Cache_Size '0'
|
||||
option Reverse_Fax_Detection '0'
|
||||
option DSP_24 '0'
|
||||
option DSP_36 '0'
|
||||
option DSP_43 '0'
|
||||
option Swap_Name_Nr_CID '0'
|
||||
option R_Button_Lower_Lim '100'
|
||||
option R_Button_Upper_Lim '800'
|
||||
option HookOn_Delay '0'
|
||||
option SupportLDD '0'
|
||||
option LDD_Min_Break_Time '41'
|
||||
option LDD_Max_Break_Time '94'
|
||||
option LDD_Percent_Break '55'
|
||||
option Tone_On_Hangup '1'
|
||||
option BusyTone_On_Hangup '1'
|
||||
option Enable_Analouge_Conf '0'
|
||||
option SIP_SessTmrEnable '0'
|
||||
option PrackUsage '1'
|
||||
option SIP_SupportedPath '0'
|
||||
option IMS_Access_Network_Info ' '
|
||||
option SIP_Reason_Protocol '0'
|
||||
option SIP_Body_QOST '0'
|
||||
option SIP_HistoryInfo '0'
|
||||
option Customer_Spec2 '1'
|
||||
option UTF8_Enable '0'
|
||||
option RFC3325 '0'
|
||||
option Accept_From_Registered '0'
|
||||
option Polarity_Reversal '0'
|
||||
option Closed_Dial_Plan '0'
|
||||
option Netw_Dial '0'
|
||||
option No_Answer_Tmo '180'
|
||||
option UPnP_Enabled '0'
|
||||
option NAT_Address ' '
|
||||
option NAT_Address_From_SIP '0'
|
||||
option HookOn_Transfer '0'
|
||||
option Enable_Call_Transfer '1'
|
||||
option CallerIDEnable '1'
|
||||
option Multiparty_Transp '0'
|
||||
option Presence_Indication '0'
|
||||
option Login_Note ' '
|
||||
option Login_Description ' '
|
||||
option Logout_Note ' '
|
||||
option Logout_Description ' '
|
||||
option Resolve_Every_Transaction '2'
|
||||
option Translate_Plus '1'
|
||||
option Mid_Call_Services '0'
|
||||
option Account_Restriction '0'
|
||||
option Answering_Machine_Enable '0'
|
||||
|
||||
32
evoice/files/etc/init.d/evoice
Executable file
32
evoice/files/etc/init.d/evoice
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=68
|
||||
STOP=12
|
||||
|
||||
USE_PROCD=1
|
||||
NAME=evoice
|
||||
VOICE_UCI_CONFIG=voice
|
||||
|
||||
start_service() {
|
||||
[ "$(db -q get hw.board.hasVoice)" = "1" ] || return
|
||||
|
||||
|
||||
which endptmngr >/dev/null 2>&1 && {
|
||||
echo "evoice can't be started since endptmngr is installed. Please remove endptmngr and retry"
|
||||
return
|
||||
}
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command $NAME
|
||||
procd_set_param respawn "5" "0" "3"
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger $VOICE_UCI_CONFIG
|
||||
}
|
||||
28
evoice/files/lib/voice/codecs_airoha.json
Normal file
28
evoice/files/lib/voice/codecs_airoha.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"G.711ALaw": {
|
||||
"BitRate": 64000,
|
||||
"PacketizationPeriod": "20",
|
||||
"SilenceSuppression": 0
|
||||
},
|
||||
"G.711MuLaw": {
|
||||
"BitRate": 64000,
|
||||
"PacketizationPeriod": "20",
|
||||
"SilenceSuppression": 0
|
||||
},
|
||||
"G.726": {
|
||||
"BitRate": 32000,
|
||||
"PacketizationPeriod": "20",
|
||||
"SilenceSuppression": 0
|
||||
},
|
||||
"G.729": {
|
||||
"BitRate": 8000,
|
||||
"PacketizationPeriod": "20",
|
||||
"SilenceSuppression": 0
|
||||
},
|
||||
"G.722": {
|
||||
"BitRate": 64000,
|
||||
"PacketizationPeriod": "20",
|
||||
"SilenceSuppression": 0
|
||||
}
|
||||
}
|
||||
|
||||
28
evoice/files/lib/voice/codecs_brcm.json
Normal file
28
evoice/files/lib/voice/codecs_brcm.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"G.711ALaw": {
|
||||
"BitRate": 64000,
|
||||
"PacketizationPeriod": "30",
|
||||
"SilenceSuppression": 1
|
||||
},
|
||||
"G.711MuLaw": {
|
||||
"BitRate": 64000,
|
||||
"PacketizationPeriod": "30",
|
||||
"SilenceSuppression": 1
|
||||
},
|
||||
"G.726": {
|
||||
"BitRate": 32000,
|
||||
"PacketizationPeriod": "30",
|
||||
"SilenceSuppression": 1
|
||||
},
|
||||
"G.729": {
|
||||
"BitRate": 8000,
|
||||
"PacketizationPeriod": "30",
|
||||
"SilenceSuppression": 1
|
||||
},
|
||||
"G.722": {
|
||||
"BitRate": 64000,
|
||||
"PacketizationPeriod": "30",
|
||||
"SilenceSuppression": 1
|
||||
}
|
||||
}
|
||||
|
||||
BIN
evoice/files/usr/share/evoice/sounds/activated.g711a
Normal file
BIN
evoice/files/usr/share/evoice/sounds/activated.g711a
Normal file
Binary file not shown.
1
evoice/files/usr/share/evoice/sounds/activated.g722
Normal file
1
evoice/files/usr/share/evoice/sounds/activated.g722
Normal file
File diff suppressed because one or more lines are too long
BIN
evoice/files/usr/share/evoice/sounds/deactivated.g711a
Normal file
BIN
evoice/files/usr/share/evoice/sounds/deactivated.g711a
Normal file
Binary file not shown.
1
evoice/files/usr/share/evoice/sounds/deactivated.g722
Normal file
1
evoice/files/usr/share/evoice/sounds/deactivated.g722
Normal file
File diff suppressed because one or more lines are too long
@@ -1,69 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2022-2024 IOPSYS Software Solutions AB
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=firewallmngr
|
||||
PKG_VERSION:=1.0.0
|
||||
|
||||
#LOCAL_DEV:=1
|
||||
#ifneq ($(LOCAL_DEV),1)
|
||||
#PKG_SOURCE_PROTO:=git
|
||||
#PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/firewallmngr.git
|
||||
#PKG_SOURCE_VERSION:=4f429e25c6e7a69c5171186731bc560befa5a660
|
||||
#PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
#PKG_MIRROR_HASH:=skip
|
||||
#endif
|
||||
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include ../bbfdm/bbfdm.mk
|
||||
|
||||
#MAKE_PATH:=src
|
||||
|
||||
define Package/firewallmngr
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=TRx69
|
||||
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libbbfdm-api +firewall
|
||||
TITLE:=Package to add Device.Firewall data model support.
|
||||
endef
|
||||
|
||||
define Package/firewallmngr/description
|
||||
Package to add Device.Firewall data model support.
|
||||
endef
|
||||
|
||||
#ifeq ($(LOCAL_DEV),0)
|
||||
#define Build/Prepare
|
||||
# $(CP) -rf ./src/* $(PKG_BUILD_DIR)/
|
||||
#endef
|
||||
#endif
|
||||
|
||||
define Package/firewallmngr/install
|
||||
$(INSTALL_DIR) $(1)/etc/firewallmngr
|
||||
$(INSTALL_DIR) $(1)/etc/firewallmngr/plugins
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_DIR) $(1)/lib/fwmngr
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/00-firewallmngr $(1)/etc/uci-defaults/00-firewallmngr
|
||||
$(INSTALL_DATA) ./files/etc/config/firewallmngr $(1)/etc/config/
|
||||
$(INSTALL_BIN) ./files/etc/init.d/firewallmngr $(1)/etc/init.d/
|
||||
$(INSTALL_DATA) ./files/lib/fwmngr/fwmngr.sh $(1)/lib/fwmngr/
|
||||
$(INSTALL_DATA) ./files/lib/fwmngr/fwmngr_functions.sh $(1)/lib/fwmngr/
|
||||
$(INSTALL_DATA) ./files/lib/fwmngr/uci_migration.sh $(1)/lib/fwmngr/
|
||||
$(INSTALL_BIN) ./files/lib/fwmngr/is_intf_bridge $(1)/lib/fwmngr/
|
||||
$(INSTALL_BIN) ./files/lib/fwmngr/firewallmngr_preconfig $(1)/lib/fwmngr/
|
||||
$(INSTALL_DATA) ./files/lib/fwmngr/fwmngr_twamp.sh $(1)/lib/fwmngr/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/firewallmngr $(1)/usr/sbin
|
||||
|
||||
$(call BbfdmInstallPluginInMicroservice, $(1)/etc/firewallmngr,./files/etc/firewallmngr/firewallmngr.json)
|
||||
$(call BbfdmInstallPluginInMicroservice, $(1)/etc/firewallmngr/plugins,$(PKG_BUILD_DIR)/libbbffirewall.so)
|
||||
$(call BbfdmInstallMicroServiceInputFile,$(1),./files/etc/bbfdm/micro_services/firewallmngr.json)
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,firewallmngr))
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"daemon": {
|
||||
"config": {
|
||||
"loglevel": "4"
|
||||
},
|
||||
"input": {
|
||||
"type": "JSON",
|
||||
"name": "/etc/firewallmngr/firewallmngr.json",
|
||||
"plugin_dir": "/etc/firewallmngr/plugins"
|
||||
},
|
||||
"output": {
|
||||
"type": "UBUS",
|
||||
"parent_dm": "Device.",
|
||||
"root_obj": "bbfdm",
|
||||
"multiple_objects": ["Firewall","NAT"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
config firewall 'firewall'
|
||||
option enable '1'
|
||||
option config 'Advanced'
|
||||
option advanced_level 'level1'
|
||||
|
||||
config level 'level1'
|
||||
option name 'level1'
|
||||
option chain 'chain1'
|
||||
option port_mapping_enabled '1'
|
||||
option default_policy 'reject'
|
||||
option default_log_policy '0'
|
||||
option enable '1'
|
||||
|
||||
config chain 'chain1'
|
||||
option enable '1'
|
||||
option name 'chain1'
|
||||
|
||||
config rule 'default_rule_0'
|
||||
option chain 'chain1'
|
||||
option enable '1'
|
||||
option order '1'
|
||||
option name 'Allow-DHCP-Renew'
|
||||
option target 'accept'
|
||||
option src 'wan'
|
||||
option family '4'
|
||||
option proto '17'
|
||||
option dest_port '68'
|
||||
|
||||
config rule 'default_rule_1'
|
||||
option chain 'chain1'
|
||||
option enable '1'
|
||||
option order '2'
|
||||
option name 'Allow-Ping'
|
||||
option target 'accept'
|
||||
option src 'wan'
|
||||
list icmp_type 'echo-request'
|
||||
option family '4'
|
||||
option proto '1'
|
||||
|
||||
config rule 'default_rule_2'
|
||||
option chain 'chain1'
|
||||
option enable '1'
|
||||
option order '3'
|
||||
option name 'Allow-IGMP'
|
||||
option target 'accept'
|
||||
option src 'wan'
|
||||
option family '4'
|
||||
option proto '2'
|
||||
|
||||
config rule 'default_rule_3'
|
||||
option chain 'chain1'
|
||||
option enable '1'
|
||||
option order '4'
|
||||
option name 'Allow-DHCPv6'
|
||||
option target 'accept'
|
||||
option src 'wan'
|
||||
option family '6'
|
||||
option proto '17'
|
||||
option dest_port '546'
|
||||
|
||||
config rule 'default_rule_4'
|
||||
option chain 'chain1'
|
||||
option enable '1'
|
||||
option order '5'
|
||||
option name 'Allow-MLD'
|
||||
option target 'accept'
|
||||
option src 'wan'
|
||||
option family '6'
|
||||
option src_ip 'fe80::'
|
||||
option source_mask 'fe80::/10'
|
||||
list icmp_type '130/0'
|
||||
list icmp_type '131/0'
|
||||
list icmp_type '132/0'
|
||||
list icmp_type '143/0'
|
||||
option proto '1'
|
||||
|
||||
config rule 'default_rule_5'
|
||||
option chain 'chain1'
|
||||
option enable '1'
|
||||
option order '6'
|
||||
option name 'Allow-ICMPv6-Input'
|
||||
option target 'accept'
|
||||
option src 'wan'
|
||||
option family '6'
|
||||
list icmp_type 'echo-request'
|
||||
list icmp_type 'echo-reply'
|
||||
list icmp_type 'destination-unreachable'
|
||||
list icmp_type 'packet-too-big'
|
||||
list icmp_type 'time-exceeded'
|
||||
list icmp_type 'bad-header'
|
||||
list icmp_type 'unknown-header-type'
|
||||
list icmp_type 'router-solicitation'
|
||||
list icmp_type 'neighbour-solicitation'
|
||||
list icmp_type 'router-advertisement'
|
||||
list icmp_type 'neighbour-advertisement'
|
||||
option limit '1000/sec'
|
||||
option proto '1'
|
||||
|
||||
config rule 'default_rule_6'
|
||||
option chain 'chain1'
|
||||
option enable '1'
|
||||
option order '7'
|
||||
option name 'Allow-ICMPv6-Forward'
|
||||
option target 'accept'
|
||||
option src 'wan'
|
||||
option dest_all_interface '1'
|
||||
option family '6'
|
||||
list icmp_type 'echo-request'
|
||||
list icmp_type 'echo-reply'
|
||||
list icmp_type 'destination-unreachable'
|
||||
list icmp_type 'packet-too-big'
|
||||
list icmp_type 'time-exceeded'
|
||||
list icmp_type 'bad-header'
|
||||
list icmp_type 'unknown-header-type'
|
||||
option limit '1000/sec'
|
||||
option proto '1'
|
||||
|
||||
config rule 'default_rule_7'
|
||||
option chain 'chain1'
|
||||
option enable '1'
|
||||
option order '8'
|
||||
option name 'Allow-IPSec-ESP'
|
||||
option target 'accept'
|
||||
option src 'wan'
|
||||
option dest 'lan'
|
||||
option proto '50'
|
||||
|
||||
config rule 'default_rule_8'
|
||||
option chain 'chain1'
|
||||
option enable '1'
|
||||
option order '9'
|
||||
option name 'Allow-ISAKMP'
|
||||
option target 'accept'
|
||||
option src 'wan'
|
||||
option dest 'lan'
|
||||
option proto '17'
|
||||
option dest_port '500'
|
||||
|
||||
config rule 'default_rule_9'
|
||||
option chain 'chain1'
|
||||
option enable '1'
|
||||
option order '10'
|
||||
option name 'Support-UDP-Traceroute'
|
||||
option target 'reject'
|
||||
option src 'wan'
|
||||
option family '4'
|
||||
option proto '17'
|
||||
option dest_port '33434'
|
||||
option dest_port_range_max '33689'
|
||||
|
||||
config rule 'default_forward_rule'
|
||||
option chain 'chain1'
|
||||
option enable '1'
|
||||
option order '65535'
|
||||
option name 'forward-rule'
|
||||
option src 'lan'
|
||||
option dest 'wan'
|
||||
option proto '-1'
|
||||
option target 'accept'
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,27 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=18
|
||||
USE_PROCD=1
|
||||
|
||||
USE_PROCD=1
|
||||
NAME=firewallmngr
|
||||
PROG=/usr/sbin/firewallmngr
|
||||
|
||||
. /lib/fwmngr/fwmngr.sh
|
||||
|
||||
|
||||
start_service() {
|
||||
configure_firewall
|
||||
procd_open_instance firewallmngr
|
||||
procd_set_param command ${PROG}
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
boot() {
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger firewallmngr
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/fwmngr/fwmngr_functions.sh
|
||||
. /lib/fwmngr/uci_migration.sh
|
||||
|
||||
|
||||
rule_sec=$(uci show firewall | grep "=rule")
|
||||
[ -z "$rule_sec" ] && return
|
||||
rule_sec=$(echo $rule_sec | grep "fwmngr")
|
||||
|
||||
if [ -z "$rule_sec" ]; then
|
||||
generate_firewallmngr_config
|
||||
fi
|
||||
if [ -f /etc/firewall.ddos ]; then
|
||||
uci -q get firewall.ddos || {
|
||||
uci -q set firewall.ddos=include
|
||||
uci -q set firewall.ddos.path="/etc/firewall.ddos"
|
||||
uci -q set firewall.ddos.reload=1
|
||||
fi
|
||||
if [ -f /etc/firewall.protect_port ]; then
|
||||
uci -q get firewall.protect_port || {
|
||||
uci -q set firewall.protect_port='include'
|
||||
uci -q set firewall.protect_port.path='/etc/firewall.protect_port'
|
||||
uci -q set firewall.protect_port.reload='1'
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
rule_max_order_val=0
|
||||
config_load firewallmngr
|
||||
|
||||
firewallmngr_generate_nat_interface_setting() {
|
||||
local intf="$1"
|
||||
local is_bridge="false"
|
||||
local masq="0"
|
||||
local intf_dev
|
||||
local type=""
|
||||
local nat_intf_setting=""
|
||||
|
||||
|
||||
type=$(uci -q get firewallmngr."$intf")
|
||||
[ "$type" = "natif" ] && return
|
||||
|
||||
nat_intf_setting=$(uci add "firewallmngr" "natif")
|
||||
uci set firewallmngr."$nat_intf_setting".interface="$intf"
|
||||
|
||||
if [ $(/lib/fwmngr/is_intf_bridge "$intf") -eq 1 ]; then
|
||||
uci set firewallmngr."$nat_intf_setting".enabled="0"
|
||||
else
|
||||
uci set firewallmngr."$nat_intf_setting".enabled="1"
|
||||
fi
|
||||
|
||||
uci rename firewallmngr."$nat_intf_setting"="$intf"
|
||||
}
|
||||
|
||||
firewallmngr_process_rule_interface() {
|
||||
local rule="$1"
|
||||
local src_intf=""
|
||||
local dest_intf=""
|
||||
|
||||
config_get src_intf "$rule" "src"
|
||||
config_get dest_intf "$rule" "dest"
|
||||
|
||||
[ -z "$src_intf" ] || firewallmngr_generate_nat_interface_setting "$src_intf"
|
||||
[ -z "$dest_intf" ] || firewallmngr_generate_nat_interface_setting "$dest_intf"
|
||||
}
|
||||
|
||||
firewallmngr_process_rule_param() {
|
||||
local order=""
|
||||
config_get order "$1" order
|
||||
|
||||
[ -z "$order" ] && return
|
||||
rule_max_order_val=$(( rule_max_order_val + 1 ))
|
||||
if [ ${order} -gt ${rule_max_order_val} ]; then
|
||||
uci -q set firewallmngr."$1".order="$rule_max_order_val"
|
||||
uci -q reorder firewallmngr."$1"=${rule_max_order_val}
|
||||
fi
|
||||
|
||||
firewallmngr_process_rule_interface "$1"
|
||||
}
|
||||
|
||||
firewallmngr_set_rule_order() {
|
||||
local order=""
|
||||
config_get order "$1" order
|
||||
|
||||
[ -n "$order" ] && return
|
||||
rule_max_order_val=$(( rule_max_order_val + 1 ))
|
||||
uci -q set firewallmngr."$1".order="$rule_max_order_val"
|
||||
uci -q reorder firewallmngr."$1"=${rule_max_order_val}
|
||||
}
|
||||
|
||||
config_foreach firewallmngr_process_rule_param rule
|
||||
config_foreach firewallmngr_set_rule_order rule
|
||||
|
||||
uci commit firewallmngr
|
||||
@@ -1,265 +0,0 @@
|
||||
#!/bin/sh
|
||||
#set -x
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/fwmngr/fwmngr_functions.sh
|
||||
|
||||
|
||||
fw_rule_sections=""
|
||||
fw_redirect_sections=""
|
||||
fw_include_sections=""
|
||||
|
||||
clean_expiry() {
|
||||
[ -f "/tmp/fw3.atjobs" ] || return
|
||||
for job in $(cat /tmp/fw3.atjobs); do
|
||||
atrm $job 2>/dev/null
|
||||
done
|
||||
rm -f /tmp/fw3.atjobs
|
||||
}
|
||||
|
||||
schedule_expiry() {
|
||||
|
||||
[ -f "/usr/bin/at" ] || return
|
||||
|
||||
expire_at() {
|
||||
local cfg=$1
|
||||
local expiry atdate
|
||||
|
||||
config_get expiry $cfg expiry
|
||||
|
||||
[ -n "$expiry" ] || return
|
||||
|
||||
atdate="$(date +'%Y%m%d%H%M.%S' -d @$expiry)"
|
||||
|
||||
[ -n "$atdate" ] || return
|
||||
|
||||
sec=$(echo $atdate | cut -d. -f2)
|
||||
at_date=$(echo $atdate | cut -d. -f1)
|
||||
|
||||
echo "sleep $sec && uci -q delete firewallmngr.$cfg; ubus call uci commit '{\"config\":\"firewallmngr\"}'" | \
|
||||
at -t $at_date 2>&1 | grep job | awk '{print$2}' >> /tmp/fw3.atjobs
|
||||
}
|
||||
|
||||
config_foreach expire_at rule
|
||||
config_foreach expire_at redirect
|
||||
}
|
||||
|
||||
firewall_cleanup() {
|
||||
local count=1
|
||||
|
||||
list=$(uci show firewall)
|
||||
section_list=$(echo "$list" | grep "fwmngr")
|
||||
|
||||
section_list=$(echo "$section_list" | awk -F. '{ print $2 }')
|
||||
section_list=$(echo "$section_list" | awk -F= '{ print $1 }')
|
||||
|
||||
fw_rule_sections=$(echo "$list" | grep -v fwmngr | grep "=rule")
|
||||
fw_rule_sections=$(echo "$fw_rule_sections" | awk -F= '{ print $1 }')
|
||||
fw_rule_sections=$(echo "$fw_rule_sections" | awk -F. '{ print $2 }')
|
||||
fw_redirect_sections=$(echo "$list" | grep -v fwmngr | grep "=redirect")
|
||||
fw_redirect_sections=$(echo "$fw_redirect_sections" | awk -F= '{ print $1 }')
|
||||
fw_redirect_sections=$(echo "$fw_redirect_sections" | awk -F. '{ print $2 }')
|
||||
fw_include_sections=$(echo "$list" | grep -v fwmngr | grep "=include")
|
||||
fw_include_sections=$(echo "$fw_include_sections" | awk -F= '{ print $1 }')
|
||||
fw_include_sections=$(echo "$fw_include_sections" | awk -F. '{ print $2 }')
|
||||
|
||||
for sec in $section_list; do
|
||||
uci -q delete firewall."$sec"
|
||||
done
|
||||
uci commit firewall
|
||||
}
|
||||
|
||||
firewallmngr_preload() {
|
||||
firewall_cleanup
|
||||
|
||||
/lib/fwmngr/firewallmngr_preconfig
|
||||
}
|
||||
|
||||
firewall_handle_section_dmz() {
|
||||
local dmz_cfg="$1"
|
||||
local dest_uci="$2"
|
||||
local dmz_sec=""
|
||||
local enable=""
|
||||
local origin=""
|
||||
local description=""
|
||||
local interface=""
|
||||
local dest_ip=""
|
||||
local source_prefix=""
|
||||
|
||||
config_get enable "$dmz_cfg" "enabled" 0
|
||||
[ "$enable" = "1" ] || return
|
||||
config_get dest_ip "$dmz_cfg" "dest_ip"
|
||||
config_get interface "$dmz_cfg" "interface"
|
||||
if [ -z "$dest_ip" ] || [ -z "$interface" ]; then
|
||||
return
|
||||
fi
|
||||
config_get origin "$dmz_cfg" "origin"
|
||||
config_get description "$dmz_cfg" "description"
|
||||
config_get source_prefix "$dmz_cfg" "source_prefix"
|
||||
|
||||
if [ "$dest_uci" = "firewall" ]; then
|
||||
zones=$(uci show firewall | grep "=zone")
|
||||
for zn in zones; do
|
||||
zn_arg=$(echo $zn | awk -F= '{ print $1 }')
|
||||
if [ "$interface" = "$(uci -q get $zn_arg.network)" ]; then
|
||||
zn_name=$(uci -q get "$zn_arg".name)
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
dmz_sec=$(uci add "$dest_uci" redirect)
|
||||
uci set "$dest_uci"."$dmz_sec".src="$zn_name"
|
||||
uci set "$dest_uci"."$dmz_sec".enabled="1"
|
||||
uci set "$dest_uci"."$dmz_sec".dest_ip="$dest_ip"
|
||||
uci set "$dest_uci"."$dmz_sec".origin="$origin"
|
||||
uci set "$dest_uci"."$dmz_sec".src_ip="$source_prefix"
|
||||
uci set "$dest_uci"."$dmz_sec".target="DNAT"
|
||||
|
||||
uci rename "$dest_uci"."$dmz_sec"="fwmngr_$dmz_cfg"
|
||||
}
|
||||
|
||||
|
||||
configure_cwmp_rule_option() {
|
||||
# default incoming rule is Port only
|
||||
local rule_sec="$1"
|
||||
local enabled="$2"
|
||||
local incoming_rule="$3"
|
||||
local ipaddr="$4"
|
||||
local family="$5"
|
||||
local port="$6"
|
||||
local zone_name="$7"
|
||||
|
||||
uci set firewall."$rule_sec".enabled="$enabled"
|
||||
uci set firewall."$rule_sec".src="$zone_name"
|
||||
if [ "$incoming_rule" == "ip_only" ]; then
|
||||
uci set firewall."$rule_sec".family="$family"
|
||||
uci set firewall."$rule_sec".src_ip="$ipaddr"
|
||||
elif [ "$incoming_rule" == "port_only" ]; then
|
||||
if [ -n "${port}" ]; then
|
||||
uci set firewall."$rule_sec".dest_port="$port"
|
||||
fi
|
||||
else
|
||||
uci set firewall."$rule_sec".family="$family"
|
||||
uci set firewall."$rule_sec".src_ip="$ipaddr"
|
||||
|
||||
if [ -n "${port}" ]; then
|
||||
uci set firewall."$rule_sec".dest_port="$port"
|
||||
fi
|
||||
fi
|
||||
uci set firewall."$rule_sec".name="Open_ACS_port"
|
||||
uci set firewall."$rule_sec".target="ACCEPT"
|
||||
}
|
||||
|
||||
handle_cwmp_rules() {
|
||||
get_firewall_zone() {
|
||||
zone="$(uci show firewall|grep network|grep ${1}|cut -d. -f 2)"
|
||||
zone="${zone:-wan}" # defaults to wan zone
|
||||
echo "$zone"
|
||||
}
|
||||
|
||||
enable="$(uci -q get cwmp.cpe.enable)"
|
||||
enable="${enable:-1}"
|
||||
|
||||
if [ "$enable" -eq 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
wan="$(uci -q get cwmp.cpe.default_wan_interface)"
|
||||
wan="${wan:-wan}"
|
||||
|
||||
zone_name="$(get_firewall_zone $wan)"
|
||||
|
||||
port=$(uci -q get cwmp.cpe.port)
|
||||
port="${port:-7547}"
|
||||
|
||||
incoming_rule=$(uci -q get cwmp.cpe.incoming_rule|awk '{print tolower($0)}')
|
||||
incoming_rule="${incoming_rule:-port_only}"
|
||||
|
||||
ipaddr=$(uci -c /var/state -q get icwmp.acs.ip)
|
||||
ip6addr=$(uci -c /var/state -q get icwmp.acs.ip6)
|
||||
|
||||
rule_sec=$(uci add "firewall" "rule")
|
||||
configure_cwmp_rule_option "$rule_Sec" "$enable" "$incoming_rule" "$ipaddr" "ipv4" "$port" "$zone_name"
|
||||
uci -q reorder firewall."$rule_sec"=0
|
||||
|
||||
rule_sec=$(uci add "firewall" "rule")
|
||||
configure_cwmp_rule_option "$rule_Sec" "$enable" "$incoming_rule" "$ip6addr" "ipv6" "$port" "$zone_name"
|
||||
uci -q reorder firewall."$rule_sec"=1
|
||||
}
|
||||
|
||||
handle_section_nat_interface_setting() {
|
||||
local nat_intf_cfg="$1"
|
||||
local interface=""
|
||||
local enable=""
|
||||
|
||||
config_get enable "$nat_intf_cfg" "enabled"
|
||||
[ -z "$enable" ] && return
|
||||
config_get interface "$nat_intf_cfg" "interface"
|
||||
if [ -n "$interface" ]; then
|
||||
create_firewall_zone_config "$interface" "$enable"
|
||||
fi
|
||||
}
|
||||
|
||||
generate_firewall_config() {
|
||||
local minus_one
|
||||
|
||||
|
||||
firewallmngr_preload
|
||||
uci commit firewallmngr
|
||||
fw_config="$(uci -q get firewallmngr.firewall.config)"
|
||||
[ -z "$fw_config" ] && return
|
||||
[ "$fw_config" = "Advanced" ] || return
|
||||
|
||||
#get active chain name
|
||||
chain_name=$(firewallmngr_get_active_chain)
|
||||
|
||||
#configure firewall global config
|
||||
global_exist=$(uci -q get firewall.globals)
|
||||
if [ -z "$global_exist" ]; then
|
||||
global_sec=$(uci add firewall globals)
|
||||
uci set firewall."$global_sec".enabled="1"
|
||||
uci rename firewall."$global_sec"="globals"
|
||||
fi
|
||||
|
||||
#configure firewall default config
|
||||
default_sec=$(uci add firewall defaults)
|
||||
uci set firewall."$default_sec".syn_flood="1"
|
||||
uci set firewall."$default_sec".input="$INPUT"
|
||||
uci set firewall."$default_sec".output="$OUTPUT"
|
||||
uci set firewall."$default_sec".forward="$FORWARD"
|
||||
uci rename firewall."$default_sec"="fwmngr_default"
|
||||
|
||||
config_load firewallmngr
|
||||
config_foreach handle_section_nat_interface_setting natif
|
||||
uci commit firewall
|
||||
#loop through rules in firewallmngr uci and write rule in firewall
|
||||
config_foreach handle_section_firewall_rule rule "$chain_name" "firewall"
|
||||
uci commit firewall
|
||||
|
||||
config_foreach handle_section_nat_port_mapping nat_portmapping "firewall"
|
||||
config_foreach firewall_handle_section_dmz dmz "firewall"
|
||||
config_foreach handle_section_service service "firewall"
|
||||
|
||||
#reorder sections to place rule created by user at the end
|
||||
minus_one=$((2**16))
|
||||
for sec in $fw_rule_sections; do
|
||||
uci -q reorder firewall."$sec"=${minus_one}
|
||||
done
|
||||
for sec in $fw_redirect_sections; do
|
||||
uci -q reorder firewall."$sec"=${minus_one}
|
||||
done
|
||||
for sec in $fw_include_sections; do
|
||||
uci -q reorder firewall."$sec"=${minus_one}
|
||||
done
|
||||
|
||||
ubus call uci commit '{"config":"firewall"}'
|
||||
schedule_expiry
|
||||
}
|
||||
|
||||
configure_firewall () {
|
||||
if ! [ -f "/etc/config/firewall" ]; then
|
||||
touch /etc/config/firewall
|
||||
fi
|
||||
touch /tmp/amit_debug
|
||||
generate_firewall_config
|
||||
}
|
||||
@@ -1,625 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
INPUT="REJECT"
|
||||
OUTPUT="ACCEPT"
|
||||
FORWARD="REJECT"
|
||||
|
||||
firewallmngr_get_active_chain() {
|
||||
local fw_level=""
|
||||
local chain_name=""
|
||||
local fw_level=""
|
||||
local chain=""
|
||||
|
||||
fw_level="$(uci -q get firewallmngr.firewall.advanced_level)"
|
||||
[ -z "$fw_level" ] && return
|
||||
enabled="$(uci -q get firewallmngr."${fw_level}".enable)"
|
||||
|
||||
[ "$enabled" = "1" ] || exit
|
||||
|
||||
chain="$(uci -q get firewallmngr."${fw_level}".chain)"
|
||||
[ -z "$chain" ] && exit
|
||||
|
||||
enabled="$(uci -q get firewallmngr."${chain}".enable)"
|
||||
chain_name="$(uci -q get firewallmngr."${chain}".name)"
|
||||
echo "$chain_name"
|
||||
}
|
||||
|
||||
|
||||
create_firewall_zone_config() {
|
||||
local intf="$1"
|
||||
local masq="$2"
|
||||
local is_bridge="false"
|
||||
local intf_dev=""
|
||||
local ntwrk=""
|
||||
local interface=$(echo "$intf" | awk -F" " '{ print $1 }')
|
||||
|
||||
type=$(uci -q get firewall."$interface")
|
||||
[ "$type" = "zone" ] && return
|
||||
|
||||
zone_sec=$(uci add "firewall" "zone")
|
||||
uci set firewall."$zone_sec".enabled="$masq"
|
||||
uci set firewall."$zone_sec".name="$interface"
|
||||
uci set firewall."$zone_sec".output="$OUTPUT"
|
||||
|
||||
if [ $(/lib/fwmngr/is_intf_bridge "$interface") -eq 1 ]; then
|
||||
uci set firewall."$zone_sec".input="ACCEPT"
|
||||
uci set firewall."$zone_sec".forward="ACCEPT"
|
||||
else
|
||||
if [ "$(uci -q get firewallmngr.globals.enabled)" = "0" ]; then
|
||||
uci set firewall."$zone_sec".input="ACCEPT"
|
||||
else
|
||||
uci set firewall."$zone_sec".input="REJECT"
|
||||
fi
|
||||
uci set firewall."$zone_sec".forward="REJECT"
|
||||
fi
|
||||
for ntwrk in $intf; do
|
||||
uci add_list firewall."$zone_sec".network="$ntwrk"
|
||||
done
|
||||
uci rename firewall."$zone_sec"="$interface"
|
||||
}
|
||||
|
||||
firewallmngr_set_ip() {
|
||||
local rule_sec="$1"
|
||||
local src_ip="$2"
|
||||
local dest_ip="$3"
|
||||
|
||||
mask=$(echo "$src_ip"|grep "/")
|
||||
if [ -z "$src_ip" ]; then
|
||||
uci set firewallmngr."$rule_sec".src_ip="$src_ip"
|
||||
else
|
||||
ip=$(echo "$src_ip" | awk -F"/" '{ print $0 }')
|
||||
mask=$(echo "$src_ip" | awk -F"/" '{ print $2 }')
|
||||
uci set firewallmngr."$rule_sec".src_ip="$ip"
|
||||
uci set firewallmngr."$rule_sec".source_mask="$mask"
|
||||
fi
|
||||
|
||||
mask=$(echo "$src_ip"|grep "/")
|
||||
if [ -z "$dest_ip" ]; then
|
||||
uci set firewallmngr."$rule_sec".dest_ip="$dest_ip"
|
||||
else
|
||||
ip=$(echo "$dest_ip" | awk -F"/" '{ print $0 }')
|
||||
mask=$(echo "$dest_ip" | awk -F"/" '{ print $2 }')
|
||||
uci set firewallmngr."$rule_sec".dest_ip="$ip"
|
||||
uci set firewallmngr."$rule_sec".dest_mask="$mask"
|
||||
fi
|
||||
}
|
||||
|
||||
firewall_set_ip() {
|
||||
local rule_sec="$1"
|
||||
local src_ip="$2"
|
||||
local dest_ip="$3"
|
||||
|
||||
uci set firewall."$rule_sec".src_ip="$src_ip"
|
||||
uci set firewall."$rule_sec".dest_ip="$dest_ip"
|
||||
}
|
||||
|
||||
firewallmngr_set_port() {
|
||||
local rule_sec="$1"
|
||||
local src_port="$2"
|
||||
local dest_port="$3"
|
||||
local src_port_range_max="$4"
|
||||
local dest_port_range_max="$5"
|
||||
|
||||
range=$(echo "$src_port" | grep ":")
|
||||
if [ -z "$range" ]; then
|
||||
uci set firewallmngr."$rule_sec".src_port="$src_port"
|
||||
else
|
||||
min_port=$(echo "$src_port" | awk -F":" '{ print $1 }')
|
||||
max_port=$(echo "$src_port" | awk -F":" '{ print $2 }')
|
||||
|
||||
uci set firewallmngr."$rule_sec".src_port="$min_port"
|
||||
uci set firewallmngr."$rule_sec".src_port_range_max="$max_port"
|
||||
fi
|
||||
range=$(echo "$dest_port" | grep ":")
|
||||
if [ -z "$range" ]; then
|
||||
uci set firewallmngr."$rule_sec".dest_port="$dest_port"
|
||||
else
|
||||
min_port=$(echo "$dest_port" | awk -F":" '{ print $1 }')
|
||||
max_port=$(echo "$dest_port" | awk -F":" '{ print $2 }')
|
||||
|
||||
uci set firewallmngr."$rule_sec".dest_port="$min_port"
|
||||
uci set firewallmngr."$rule_sec".dest_port_range_max="$max_port"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
firewall_set_port() {
|
||||
local rule_sec="$1"
|
||||
local src_port="$2"
|
||||
local dest_port="$3"
|
||||
local src_port_range_max="$4"
|
||||
local dest_port_range_max="$5"
|
||||
|
||||
if [ -z "$dest_port_range_max" ] || [ "$dest_port_range_max" = "-1" ]; then
|
||||
[ "$dest_port" == "-1" ] || uci set firewall."$rule_sec".dest_port="$dest_port"
|
||||
else
|
||||
uci set firewall."$rule_sec".dest_port="$dest_port:$dest_port_range_max"
|
||||
fi
|
||||
|
||||
if [ -z "$src_port_range_max" ] || [ "$src_port_range_max" = "-1" ]; then
|
||||
[ "$src_port" == "-1" ] || uci set firewall."$rule_sec".src_port="$src_port"
|
||||
else
|
||||
uci set firewall."$rule_sec".src_port="$src_port:$src_port_range_max"
|
||||
fi
|
||||
}
|
||||
|
||||
firewallmngr_set_interface() {
|
||||
local rule_sec="$1"
|
||||
local src_intf="$2"
|
||||
local dest_intf="$3"
|
||||
|
||||
if [ "$src_intf" = "*" ]; then
|
||||
uci set firewallmngr."$rule_sec".source_all_interfaces="1"
|
||||
else
|
||||
uci set firewallmngr."$rule_sec".source_all_interfaces="0"
|
||||
uci set firewallmngr."$rule_sec".src="$src_intf"
|
||||
fi
|
||||
if [ "$dest_intf" = "*" ]; then
|
||||
uci set firewallmngr."$rule_sec".dest_all_interfaces="1"
|
||||
else
|
||||
uci set firewallmngr."$rule_sec".dest_all_interfaces="0"
|
||||
uci set firewallmngr."$rule_sec".dest="$dest_intf"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
firewall_set_interface() {
|
||||
local rule_sec="$1"
|
||||
local src_intf="$2"
|
||||
local dest_intf="$3"
|
||||
uci set firewall."$rule_sec".src="$src_intf"
|
||||
uci set firewall."$rule_sec".dest="$dest_intf"
|
||||
}
|
||||
|
||||
|
||||
firewallmngr_get_rule_ip_family() {
|
||||
local version="$1"
|
||||
|
||||
if [ "$version" == "ipv4" ]; then
|
||||
echo "4"
|
||||
elif [ "$version" == "ipv6" ]; then
|
||||
echo "6"
|
||||
else
|
||||
echo "-1"
|
||||
fi
|
||||
}
|
||||
|
||||
firewall_get_rule_ip_family() {
|
||||
local version="$1"
|
||||
|
||||
if [ "$version" == "4" ]; then
|
||||
echo "ipv4"
|
||||
elif [ "$version" == "6" ]; then
|
||||
echo "ipv6"
|
||||
else
|
||||
echo "-1"
|
||||
fi
|
||||
}
|
||||
|
||||
firewallmngr_set_ip_family() {
|
||||
local rule_sec="$1"
|
||||
local ip_family="$2"
|
||||
|
||||
if [ -z "$ip_family" ]; then
|
||||
uci set firewallmngr."$rule_sec".family="-1"
|
||||
return
|
||||
fi
|
||||
uci set firewallmngr."$rule_sec".family="$ip_family"
|
||||
}
|
||||
|
||||
firewall_set_ip_family() {
|
||||
local rule_sec="$1"
|
||||
local ip_family="$2"
|
||||
|
||||
[ "$ip_family" == "-1" ] || uci set firewall."$rule_sec".family="$ip_family"
|
||||
}
|
||||
|
||||
firewallmngr_set_rule_target() {
|
||||
local rule_sec="$1"
|
||||
local target="$2"
|
||||
local targetchain="$3"
|
||||
local action
|
||||
if [ "$target" = "MARK" ]; then
|
||||
uci set firewallmngr."$rule_sec".target="Return"
|
||||
elif [ "$target" = "TargetChain" ]; then
|
||||
uci set firewallmngr."$rule_sec".target="$targetchain"
|
||||
else
|
||||
action=$(echo "$target" | awk '{for(i=1;i<=NF;i++){$i=toupper(substr($i,1,1)) substr($i,2)}} 1')
|
||||
uci set firewallmngr."$rule_sec".target="$action"
|
||||
fi
|
||||
}
|
||||
|
||||
firewall_set_rule_target() {
|
||||
local rule_sec="$1"
|
||||
local target="$2"
|
||||
local targetchain="$3"
|
||||
if [ "$target" = "Accept" ] || [ "$target" = "accept" ] || [ "$target" = "Reject" ] || [ "$target" = "reject" ] || [ "$target" = "Drop" ] || [ "$target" = "drop" ]; then
|
||||
uci set firewall."$rule_sec".target="$(echo $target | awk '{ print toupper($0) }')"
|
||||
elif [ "$target" = "Retrun" ]; then
|
||||
uci set firewall."$rule_sec".target="MARK"
|
||||
elif [ "$target" = "TargetChain" ]; then
|
||||
uci set firewall."$rule_sec".target="$targetchain"
|
||||
else
|
||||
uci set firewall."$rule_sec".target="DROP"
|
||||
fi
|
||||
}
|
||||
|
||||
set_rule_protocol() {
|
||||
local rule_sec="$1"
|
||||
local protocol="$2"
|
||||
local rule_rd="$3"
|
||||
local dest_uci="$4"
|
||||
|
||||
set_icmp_type() {
|
||||
uci add_list "$dest_uci"."$rule_sec".icmp_type="$1"
|
||||
}
|
||||
|
||||
if [ -z "$protocol" ] || [ "$protocol" = "0" ] || [ "$protocol" = "all" ] || [ "$protocol" = "-1" ]; then
|
||||
uci set "$dest_uci"."$rule_sec".proto="all"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ "$dest_uci" = "firewallmngr" ]; then
|
||||
protocol=$(grep -m 1 "$protocol" "/etc/protocols" | awk -F" " '{ print $2 }')
|
||||
fi
|
||||
uci set "$dest_uci"."$rule_sec".proto="$protocol"
|
||||
if [ "$protocol" = "1" ] || [ "$protocol" = "icmp" ]; then
|
||||
config_list_foreach "$rule_rd" "icmp_type" set_icmp_type
|
||||
fi
|
||||
}
|
||||
|
||||
handle_section_firewall_rule() {
|
||||
local rule="$1"
|
||||
local chain_name="$2"
|
||||
local dest_uci="$3"
|
||||
local chain=""
|
||||
local is_enable=""
|
||||
local src_intf=""
|
||||
local ip_version=""
|
||||
local ip_family=""
|
||||
local protocol=""
|
||||
local dest_intf=""
|
||||
local target=""
|
||||
local targetchain=""
|
||||
local desc=""
|
||||
local dest_port=""
|
||||
local src_port=""
|
||||
local src_port_range_max=""
|
||||
local dest_port_range_max=""
|
||||
local src_ip=""
|
||||
local dest_ip=""
|
||||
local source_mac=""
|
||||
local source_all_interfaces=""
|
||||
local dest_all_interfaces=""
|
||||
local source_mask=""
|
||||
local dest_mask=""
|
||||
local limit=""
|
||||
local expiry=""
|
||||
local order=""
|
||||
|
||||
config_get is_enable "$rule" "enable" 1
|
||||
[ "$is_enable" = "1" ] || return
|
||||
|
||||
if [ "$dest_uci" = "firewall" ]; then
|
||||
config_get chain "$rule" "chain"
|
||||
[ "$chain" = "$chain_name" ] || return
|
||||
fi
|
||||
|
||||
config_get desc "$rule" "name"
|
||||
config_get src_intf "$rule" "src"
|
||||
config_get dest_intf "$rule" "dest"
|
||||
config_get ip_version "$rule" "family"
|
||||
function="$dest_uci"_get_rule_ip_family
|
||||
ip_family="$($function $ip_version)"
|
||||
config_get protocol "$rule" "proto"
|
||||
config_get src_port "$rule" "src_port"
|
||||
config_get dest_port "$rule" "dest_port"
|
||||
config_get src_ip "$rule" "src_ip"
|
||||
config_get source_mask "$rule" "source_mask"
|
||||
[ -n "$source_mask" ] && src_ip="${src_ip}/$source_mask"
|
||||
config_get dest_ip "$rule" "dest_ip"
|
||||
config_get dest_mask "$rule" "dest_mask"
|
||||
[ -n "$dest_mask" ] && dest_ip="${dest_ip}/$dest_mask"
|
||||
config_get dest_port_range_max "$rule" "dest_port_range_max"
|
||||
config_get src_port_range_max "$rule" "src_port_range_max"
|
||||
config_get target "$rule" "target"
|
||||
config_get targetchain "$rule" "targetchain"
|
||||
config_get source_mac "$rule" "src_mac"
|
||||
config_get order "$rule" "order"
|
||||
config_get limit "$rule" "limit"
|
||||
config_get expiry "$rule" "expiry"
|
||||
config_get source_all_interfaces "$rule" "source_all_interfaces"
|
||||
[ "$source_all_interfaces" = "1" ] && src_intf="*"
|
||||
config_get dest_all_interfaces "$rule" "dest_all_interfaces"
|
||||
[ "$dest_all_interfaces" = "1" ] && dest_intf="*"
|
||||
|
||||
rule_sec=$(uci add "$dest_uci" rule)
|
||||
uci set "$dest_uci"."$rule_sec".chain="$chain_name"
|
||||
uci set "$dest_uci"."$rule_sec".enabled="1"
|
||||
uci set "$dest_uci"."$rule_sec".name="$desc"
|
||||
|
||||
"$dest_uci"_set_interface "$rule_sec" "$src_intf" "$dest_intf"
|
||||
"$dest_uci"_set_ip_family "$rule_sec" "$ip_family"
|
||||
"$dest_uci"_set_rule_target "$rule_sec" "$target" "$targetchain"
|
||||
set_rule_protocol "$rule_sec" "$protocol" "$rule" "$dest_uci"
|
||||
|
||||
"$dest_uci"_set_port "$rule_sec" "$src_port" "$dest_port" "$src_port_range_max" "$dest_port_range_max"
|
||||
|
||||
"$dest_uci"_set_ip "$rule_sec" "$src_ip" "$dest_ip"
|
||||
|
||||
uci set "$dest_uci"."$rule_sec".src_mac="$source_mac"
|
||||
uci set "$dest_uci"."$rule_sec".order="$order"
|
||||
uci set "$dest_uci"."$rule_sec".limit="$limit"
|
||||
uci set "$dest_uci"."$rule_sec".expiry="$expiry"
|
||||
|
||||
if [ "$dest_uci" = "firewall" ]; then
|
||||
uci rename "$dest_uci"."$rule_sec"="fwmngr_$rule"
|
||||
else
|
||||
uci rename "$dest_uci"."$rule_sec"="$rule"
|
||||
fi
|
||||
}
|
||||
|
||||
firewallmngr_configure_service_rule() {
|
||||
local interface="$1"
|
||||
local dest_port="$2"
|
||||
local ip_family="$3"
|
||||
local protocol="$4"
|
||||
local icmp_type="$5"
|
||||
local source_prefix="$6"
|
||||
local action="$7"
|
||||
local service_cfg="$8"
|
||||
local service_sec
|
||||
|
||||
service_sec_add_list_value() {
|
||||
for value in $1; do
|
||||
uci add_list firewallmngr."$service_sec"."$2"="$value"
|
||||
done
|
||||
}
|
||||
|
||||
service_sec=$(uci add firewall service)
|
||||
uci set firewallmngr."$service_sec".enabled="1"
|
||||
uci set firewallmngr."$service_sec".name="service rule"
|
||||
uci set firewallmngr."$service_sec".src="$interface"
|
||||
uci set firewallmngr."$service_sec".icmp_type="$icmp_type"
|
||||
uci set firewallmngr."$service_sec".family=$(firewallmngr_get_rule_ip_family "$ip_family")
|
||||
firewallmngr_set_rule_target "$service_sec" "$action" ""
|
||||
|
||||
service_sec_add_list_value "$dest_port" "dest_port"
|
||||
service_sec_add_list_value "$protocol" "protocol"
|
||||
service_sec_add_list_value "$source_prefix" "src_prefix"
|
||||
|
||||
uci rename firewallmngr."$service_sec"="${service_cfg}"
|
||||
}
|
||||
|
||||
firewall_configure_service_rule() {
|
||||
local interface="$1"
|
||||
local dest_port="$2"
|
||||
local ip_family="$3"
|
||||
local protocol="$4"
|
||||
local icmp_type="$5"
|
||||
local source_prefix="$6"
|
||||
local action="$7"
|
||||
local service_cfg="$8"
|
||||
local service_sec
|
||||
|
||||
service_sec=$(uci add firewall rule)
|
||||
uci set firewall."$service_sec".enabled="1"
|
||||
uci set firewall."$service_sec".name="service rule"
|
||||
uci set firewall."$service_sec".src="$interface"
|
||||
[ "$dest_port" == "-1" ] || uci set firewall."$service_sec".dest_port="$dest_port"
|
||||
uci set firewall."$service_sec".family=$(firewall_get_rule_ip_family "$ip_family")
|
||||
[ "$protocol" == "-1" ] || uci set firewall."$service_sec".proto="$protocol"
|
||||
[ "$icmp_type" == "-1" ] || uci set firewall."$service_sec".icmp_type="$icmp_type"
|
||||
uci set firewall."$service_sec".src_ip="$source_prefix"
|
||||
firewall_set_rule_target "$service_sec" "$action" ""
|
||||
|
||||
[ -z "$service_cfg" ] || uci rename firewall."$service_sec"="fwmngr_${service_cfg}"
|
||||
}
|
||||
|
||||
handle_section_service() {
|
||||
local service_cfg="$1"
|
||||
local dest_uci="$2"
|
||||
local service_sec=""
|
||||
local enable=""
|
||||
local interface=""
|
||||
local dest_port=""
|
||||
local protocol=""
|
||||
local icmp_type=""
|
||||
local source_prefix=""
|
||||
local action=""
|
||||
local ip_family=""
|
||||
|
||||
get_service_proto_list() {
|
||||
protocol="$protocol $1"
|
||||
}
|
||||
get_service_src_prefix_list() {
|
||||
source_prefix="$source_prefix $1"
|
||||
}
|
||||
get_service_dest_port_list() {
|
||||
dest_port="$dest_port $1"
|
||||
}
|
||||
|
||||
config_get enable "$service_cfg" "enable" 0
|
||||
[ "$enable" == "1" ] || return
|
||||
config_get interface "$service_cfg" "interface"
|
||||
[ -z "$interface" ] && return
|
||||
config_get ip_family "$service_cfg" "family"
|
||||
|
||||
config_list_foreach "$service_cfg" "proto" get_service_proto_list
|
||||
config_list_foreach "$service_cfg" "dest_port" get_service_dest_port_list
|
||||
config_list_foreach "$service_cfg" "src_prefix" get_service_src_prefix_list
|
||||
|
||||
config_get icmp_type "$service_cfg" "icmp_type"
|
||||
config_get action "$service_cfg" "target"
|
||||
|
||||
"$dest_uci"_configure_service_rule "$interface" "$dest_port" "$ip_family" "$protocol" "$icmp_type" "$source_prefix" "$action" "$service_cfg"
|
||||
|
||||
}
|
||||
|
||||
firewallmngr_set_all_intf_src_dip() {
|
||||
local redirect_section="$1"
|
||||
local zn_name="$2"
|
||||
local all_interface="$3"
|
||||
|
||||
config_get src_dip "$redirect_section" "src_dip"
|
||||
|
||||
if [ "$src_dip" = "*" ]; then
|
||||
uci set firewallmngr."$redirect_sec".all_interface="1"
|
||||
else
|
||||
uci set firewallmngr."$redirect_sec".all_interface="0"
|
||||
fi
|
||||
}
|
||||
|
||||
firewall_set_all_intf_src_dip() {
|
||||
local redirect_section="$1"
|
||||
local zn_name="$2"
|
||||
local all_interface="$3"
|
||||
|
||||
if [ "$all_interface" = "1" ]; then
|
||||
if [ -z "$zn_name" ]; then
|
||||
uci set firewall."$redirect_sec".src="wan"
|
||||
else
|
||||
uci set firewall."$redirect_sec".src="$zn_name"
|
||||
fi
|
||||
uci set firewall."$redirect_sec".src_dip="*"
|
||||
else
|
||||
uci set firewall."$redirect_sec".src="$zn_name"
|
||||
uci set firewall."$redirect_sec".src_dip=""
|
||||
fi
|
||||
}
|
||||
|
||||
firewallmngr_set_src_dport() {
|
||||
local redirect_sec="$1"
|
||||
lodcal external_port="$2"
|
||||
local external_port_end="$3"
|
||||
|
||||
range=$(echo "$external_port" | grep "-")
|
||||
if [ -z "$range" ]; then
|
||||
uci set firewallmngr."$redirect_sec".src_dport="$external_port"
|
||||
else
|
||||
min_port=$(echo "$external_port" | awk -F"-" '{ print $1 }')
|
||||
max_port=$(echo "$external_port" | awk -F"-" '{ print $2 }')
|
||||
|
||||
uci set firewallmngr."$redirect_sec".src_dport="$min_port"
|
||||
uci set firewallmngr."$redirect_sec".src_dport_end="$max_port"
|
||||
fi
|
||||
}
|
||||
|
||||
firewall_set_src_dport() {
|
||||
local redirect_sec="$1"
|
||||
local external_port="$2"
|
||||
local external_port_end="$3"
|
||||
|
||||
if [ "$external_port_end" = "0" ]; then
|
||||
if ! [ "$external_port" = "0" ]; then
|
||||
uci set firewall."$redirect_sec".src_dport="$external_port"
|
||||
fi
|
||||
else
|
||||
uci set firewall."$redirect_sec".src_dport="$external_port-$external_port_end"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# handling for firewallmngr to firewall
|
||||
handle_section_nat_port_mapping() {
|
||||
local nat_port_cfg="$1"
|
||||
local dest_uci="$2"
|
||||
local enable=""
|
||||
local interface=""
|
||||
local all_interface=""
|
||||
local lease_duration=""
|
||||
local remote_host=""
|
||||
local external_port=""
|
||||
local external_port_end=""
|
||||
local internal_port=""
|
||||
local protocol=""
|
||||
local internal_client=""
|
||||
local description=""
|
||||
local redirect_sec=""
|
||||
local epoch_sec=""
|
||||
local stop_epoch=""
|
||||
local stop_ymd=""
|
||||
local stop_hms=""
|
||||
local zn_name=""
|
||||
|
||||
config_get enable "$nat_port_cfg" "enabled"
|
||||
config_get interface "$nat_port_cfg" "src"
|
||||
|
||||
if [ "$dest_uci" = "firewall" ]; then
|
||||
zones=$(uci show firewall | grep "=zone")
|
||||
for zn in zones; do
|
||||
zn_arg=$(echo $zn | awk -F= '{ print $1 }')
|
||||
if [ "$interface" = "$(uci -q get $zn_arg.network)" ]; then
|
||||
zn_name=$(uci -q get "$zn_arg".name)
|
||||
masq=$(uci -q get "$zn_arg".masq)
|
||||
fi
|
||||
done
|
||||
if [ -z "$enable" ] && ! [ "$masq" = "1" ]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
config_get internal_client "$nat_port_cfg" "dest_ip"
|
||||
config_get all_interface "$nat_port_cfg" "all_interface"
|
||||
config_get lease_duration "$nat_port_cfg" "lease_duration"
|
||||
config_get remote_host "$nat_port_cfg" "src_ip"
|
||||
config_get external_port "$nat_port_cfg" "src_dport" "0"
|
||||
config_get external_port_end "$nat_port_cfg" "src_dport_end" "0"
|
||||
config_get internal_port "$nat_port_cfg" "dest_port"
|
||||
config_get protocol "$nat_port_cfg" "proto"
|
||||
protocol=$(echo $protocol | awk '{ print tolower($0) }')
|
||||
config_get description "$nat_port_cfg" "name"
|
||||
|
||||
redirect_sec=$(uci add "$dest_uci" redirect)
|
||||
|
||||
"dest_uci"_set_all_intf_src_dip "$redirect_sec" "$zn_name" "$all_interface"
|
||||
|
||||
if [ "$dest_uci" = "firewall" ]; then
|
||||
if [ -n "$lease_duration" ] && ! [ "$lease_duration" == "0" ]; then
|
||||
epoch_sec=$(date +%s)
|
||||
stop_epoch=$(( epoch_sec + lease_duration ))
|
||||
stop_ymd=$(date -d @${stop_epoh} +%Y-%m-%d)
|
||||
stop_hms=$(date -d @${stop_epoch} +%H:%M:%S)
|
||||
uci set "$dest_uci"."$redirect_sec".stop_date="$stop_ymd"
|
||||
uci set "$dest_uci"."$redirect_sec".stop_time="$stop_hms"
|
||||
fi
|
||||
fi
|
||||
|
||||
"$dest_uci"_set_src_dport "$redirect_section" "$external_port" "$external_port_end"
|
||||
|
||||
uci set "$dest_uci"."$redirect_sec".enabled="1"
|
||||
uci set "$dest_uci"."$redirect_sec".target="DNAT"
|
||||
uci set "$dest_uci"."$redirect_sec".dest_ip="$internal_client"
|
||||
[ -z "$protocol" ] || uci set "$dest_uci"."$redirect_sec".proto="$protocol"
|
||||
[ -z "$remote_host" ] || uci set "$dest_uci"."$redirect_sec".src_ip="$remote_host"
|
||||
[ -z "$internal_port" ] || uci set "$dest_uci"."$redirect_sec".dest_port="$internal_port"
|
||||
[ -z "$description" ] || uci set "$dest_uci"."$redirect_sec".name="$description"
|
||||
|
||||
if [ "$dest_uci" = "firewall" ]; then
|
||||
uci rename "$dest_uci"."$redirect_sec"="fwmngr_$nat_port_cfg"
|
||||
else
|
||||
uci rename "$dest_uci"."$redirect_sec"="$nat_port_cfg"
|
||||
fi
|
||||
}
|
||||
|
||||
handle_include_section() {
|
||||
local include_sec="$1"
|
||||
local dest_uci="$2"
|
||||
|
||||
config_get path "$include_sec" "path"
|
||||
config_get reload "$include_sec" "reload"
|
||||
config_get include_type "$include_sec" "type"
|
||||
|
||||
sec=$(uci add "$dest_uci" include)
|
||||
[ -z "$path" ] || uci set "$dest_uci"."$sec".path="$path"
|
||||
[ -z "$reload" ] || uci set "$dest_uci"."$sec".reload="$reload"
|
||||
[ -z "$include_type" ] || uci set "$dest_uci"."$sec".type="$include_type"
|
||||
if [ "$dest_uci" = "firewall" ]; then
|
||||
uci rename "$dest_uci"."$sec"="fwmngr_$include_sec"
|
||||
else
|
||||
uci rename "$dest_uci"."$sec"="$include_sec"
|
||||
fi
|
||||
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
active_chain=""
|
||||
remove_twamp_reflector_rules() {
|
||||
config_get name "$1" name
|
||||
|
||||
if [ "$name" = "Twamp Reflector Rule" ]; then
|
||||
uci delete firewallmngr."$1"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
handle_twamp_reflector_rules() {
|
||||
local twamp_cfg="$1"
|
||||
local sec_name=""
|
||||
local action="Acept"
|
||||
|
||||
config_get enable "$twamp_cfg" enable "1"
|
||||
config_get port "$twamp_cfg" port
|
||||
config_get interface "$twamp_cfg" interface
|
||||
|
||||
if [ "${enable}" -eq 0 ] || [ -z "$port" ] || [ -z "$interface" ]; then
|
||||
return
|
||||
fi
|
||||
sec_name="twamp_${interface}_${port}"
|
||||
rule_twamp=$(uci add firewallmngr rule)
|
||||
uci set firewallmngr."$rule_twamp".enable="1"
|
||||
uci set firewallmngr."$rule_twamp".chain="$active_chain"
|
||||
uci set firewallmngr."$rule_twamp".dest_port="$port"
|
||||
uci set firewallmngr."$rule_twamp".name="Twamp Reflector Rule"
|
||||
uci set firewallmngr."$rule_twamp".interface="$interface"
|
||||
uci set firewallmngr."$rule_twamp".ip_version="4"
|
||||
uci set firewallmngr."$rule_twamp".protocol="17"
|
||||
uci set firewallmngr."$rule_twamp".target="$action"
|
||||
uci rename firewallmngr."$rule_twamp"="fwmngr_$sec_name"
|
||||
}
|
||||
|
||||
firewallmngr_get_active_chain() {
|
||||
config_get creator "$1" creator
|
||||
[ "$creator" = "PortMapping" ] && return
|
||||
|
||||
config_get enable "$1" enable
|
||||
if [ -n "$enable" ] && [ "$enable" = "1" ]; then
|
||||
config_get active_chain "$1" name
|
||||
fi
|
||||
}
|
||||
|
||||
handle_twamp_rules() {
|
||||
twamp_enable=$(uci -q get twamp.twamp.enable)
|
||||
|
||||
config_load firewallmngr
|
||||
config_foreach firewallmngr_get_active_chain chain
|
||||
|
||||
config_foreach remove_twamp_reflector_rules rule
|
||||
config_load twamp
|
||||
if [ -n "$twamp_enable" ] && [ "$twamp_enable" == "1" ]; then
|
||||
config_foreach handle_twamp_reflector_rules twamp_reflector
|
||||
fi
|
||||
uci commit firewallmngr
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
#!/bin/sh
|
||||
. /lib/functions.sh
|
||||
|
||||
interface=$1
|
||||
intf_dev=""
|
||||
is_bridge=0
|
||||
|
||||
is_device_type_bridge() {
|
||||
local dev
|
||||
local dev_type
|
||||
|
||||
config_get dev "$1" "name"
|
||||
config_get dev_type "$1" "type"
|
||||
if [ "$dev" = "$intf_dev" ] && [ "$dev_type" = "bridge" ]; then
|
||||
is_bridge=1
|
||||
fi
|
||||
}
|
||||
|
||||
intf_dev=$(uci -q get network."$interface".device)
|
||||
config_load network
|
||||
config_foreach is_device_type_bridge device
|
||||
|
||||
echo $is_bridge
|
||||
@@ -1,158 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/fwmngr/fwmngr_functions.sh
|
||||
|
||||
uci_mig_include_sections=""
|
||||
include_deprecated_list="hosts cwmp dmz mcast twamp portmap service"
|
||||
final_include_cfg=""
|
||||
|
||||
|
||||
firewallmngr_zone_to_nat_interface_setting() {
|
||||
zone="$1"
|
||||
|
||||
config_get interface "$zone" "network"
|
||||
[ -n "$interface" ] || return
|
||||
config_get enable "$zone" "masq" "0"
|
||||
nat_intf_setting=$(uci add "firewallmngr" "natif")
|
||||
uci set firewallmngr."$nat_intf_setting".enabled="$enable"
|
||||
uci set firewallmngr."$nat_intf_setting".interface="$interface"
|
||||
|
||||
uci rename firewallmngr."$nat_intf_setting"=$(echo "$interface" | awk -F" " '{ print $1 }')
|
||||
}
|
||||
|
||||
handle_section_forwarding_rule() {
|
||||
local fwd="$1"
|
||||
local chain="$2"
|
||||
|
||||
config_get src_intf "$fwd" "src"
|
||||
config_get dest_intf "$fwd" "dest"
|
||||
|
||||
rule_sec=$(uci add "firewallmngr" rule)
|
||||
firewallmngr_set_interface "$rule_sec" "$src_intf" "$dest_intf"
|
||||
uci set firewallmngr."$rule_sec".chain="$chain"
|
||||
uci set firewallmngr."$rule_sec".name="$fwd"
|
||||
uci set firewallmngr."$rule_sec".target="accept"
|
||||
uci rename firewallmngr."$rule_sec"="fwmngr_$fwd"
|
||||
}
|
||||
|
||||
firewallmngr_handle_section_dmz() {
|
||||
local dmz_cfg="$1"
|
||||
local dest_uci="$2"
|
||||
local dmz_sec=""
|
||||
local enabled=""
|
||||
local origin=""
|
||||
local description=""
|
||||
local interface=""
|
||||
local dest_ip=""
|
||||
local source_prefix=""
|
||||
|
||||
config_get dest_ip "$dmz_cfg" "dest_ip"
|
||||
config_get interface "$dmz_cfg" "interface"
|
||||
config_get origin "$dmz_cfg" "origin"
|
||||
config_get source_prefix "$dmz_cfg" "source_prefix"
|
||||
config_get description "$dmz_cfg" "description"
|
||||
config_get enabled "$dmz_cfg" "enabled"
|
||||
|
||||
dmz_sec=$(uci add firewallmngr dmz)
|
||||
|
||||
uci set firewallmngr."$dmz_sec".enabled="$enabled"
|
||||
uci set firewallmngr."$dmz_sec".dest_ip="$dest_ip"
|
||||
uci set firewallmngr."$dmz_sec".interface="$interface"
|
||||
uci set firewallmngr."$dmz_sec".origin="$origin"
|
||||
uci set firewallmngr."$dmz_sec".description="$description"
|
||||
uci set firewallmngr."$dmz_sec".source_prefix="$source_prefix"
|
||||
|
||||
uci rename firewallmngr."$dmz_sec"="$dmz_cfg"
|
||||
}
|
||||
|
||||
#This call must be triggered from procd boot function
|
||||
cleanup_firewallmngr_rule_section() {
|
||||
rule_sec=$(uci show firewallmngr | grep "=rule")
|
||||
for sec in $rule_sec; do
|
||||
rule=$(echo "$sec" | awk -F= '{ print $1 }')
|
||||
uci delete "$rule"
|
||||
done
|
||||
uci commit firewallmngr
|
||||
}
|
||||
|
||||
firewallmngr_delete_install_dmz_rule() {
|
||||
local dmz_cfgs
|
||||
|
||||
dmz_cfgs=$(uci show firewall | grep "=dmz")
|
||||
for dmz in $dmz_cfgs; do
|
||||
dmz=$(echo $dmz | awk -F= '{ print $1 }')
|
||||
uci del "$dmz"
|
||||
done
|
||||
uci commit firewall
|
||||
}
|
||||
|
||||
firewall_delete_deprecated_include_section() {
|
||||
new_inc_list=""
|
||||
|
||||
inc_list=$(uci show firewall | grep "=include")
|
||||
for inc in $inc_list; do
|
||||
inc=$(echo "$inc"| awk -F"=" '{ print $1 }')
|
||||
|
||||
inc_name=$(echo "$inc" | awk -F. '{ print $2 }')
|
||||
inc_path=$(uci -q get "$inc".path | awk -F/ '{ print $NF }')
|
||||
inc_file=$(echo "$inc_path" | awk -F. '{ print $2 }')
|
||||
|
||||
inc_ignore=$(echo "$include_deprecated_list"| grep -w "$inc_name")
|
||||
if [ -z "$inc_ignore" ]; then
|
||||
inc_ignore=$(echo "$include_deprecated_list"| grep -w "$inc_file")
|
||||
fi
|
||||
[ -z "$inc_ignore" ] || uci delete "$inc"
|
||||
|
||||
done
|
||||
uci commit firewall
|
||||
|
||||
|
||||
}
|
||||
|
||||
firewall_backup_include_section() {
|
||||
list=$(uci show firewall)
|
||||
uci_mig_include_sections=$(echo "$list" | grep "=include")
|
||||
uci_mig_include_sections=$(echo "$fw_include_sections" | awk -F= '{ print $1 }')
|
||||
uci_mig_include_sections=$(echo "$fw_include_sections" | awk -F. '{ print $2 }')
|
||||
}
|
||||
|
||||
firewall_uci_cleanup() {
|
||||
# cleanup all sections of firewall uci, firewall uci will be generated by firewallmngr init
|
||||
section_cleanup () {
|
||||
local sec="$1"
|
||||
|
||||
rule_sec=$(uci show firewall | grep "$sec")
|
||||
for rule in $rule_sec; do
|
||||
rule=$(echo "$rule" | awk -F= '{ print $1 }')
|
||||
uci delete "$rule"
|
||||
done
|
||||
}
|
||||
|
||||
section_cleanup "=rule"
|
||||
section_cleanup "=zone"
|
||||
section_cleanup "=redirect"
|
||||
section_cleanup "=dmz"
|
||||
section_cleanup "=service"
|
||||
section_cleanup "=forwarding"
|
||||
section_cleanup "=defaults"
|
||||
section_cleanup "=globals"
|
||||
uci commit firewall
|
||||
}
|
||||
|
||||
generate_firewallmngr_config() {
|
||||
chain_name=$(firewallmngr_get_active_chain)
|
||||
cleanup_firewallmngr_rule_section
|
||||
config_load firewall
|
||||
config_foreach handle_section_firewall_rule rule "$chain_name" "firewallmngr"
|
||||
config_foreach firewallmngr_zone_to_nat_interface_setting zone
|
||||
config_foreach handle_section_nat_port_mapping redirect "firewallmngr"
|
||||
config_foreach firewallmngr_handle_section_dmz dmz "firewallmngr"
|
||||
config_foreach handle_section_service service "firewallmngr"
|
||||
config_foreach handle_section_forwarding_rule forwarding "$chain_name"
|
||||
|
||||
uci commit firewallmngr
|
||||
|
||||
firewall_uci_cleanup
|
||||
firewall_delete_deprecated_include_section
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
CC=gcc
|
||||
PROG = firewallmngr
|
||||
LIB_BBF = libbbffirewall.so
|
||||
SRC_DIR = .
|
||||
OBJS = $(addprefix $(SRC_DIR)/, firewallmngr.o)
|
||||
LIB_OBJS = ./bbf_plugin/firewall.o
|
||||
|
||||
DIAG_CFLAGS = -Wall -Wshadow -Wdouble-promotion -Wformat=2 -Wundef -fno-common -Wstrict-prototypes -Wno-declaration-after-statement
|
||||
PROG_CFLAGS = $(CFLAGS) $(DIAG_CFLAGS) -Werror -fstrict-aliasing -fPIC
|
||||
|
||||
# MUSL has the following issue in snprintf, so it is ignored:
|
||||
PROG_CFLAGS += -Wno-format-nonliteral
|
||||
|
||||
PROG_LDFLAGS = $(LDFLAGS)
|
||||
PROG_LIBS += -luci -lubus -lubox -ljson-c -lblobmsg_json
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(PROG_CFLAGS) $(FPIC) -c -o $@ $<
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: $(PROG) $(LIB_BBF)
|
||||
|
||||
$(PROG): $(OBJS)
|
||||
$(CC) $(PROG_LDFLAGS) -o $@ $^ $(PROG_LIBS)
|
||||
|
||||
$(LIB_BBF): $(LIB_OBJS)
|
||||
$(CC) $(PROG_LDFLAGS) -shared -o $@ $^
|
||||
|
||||
clean:
|
||||
rm -f *.o $(PROG)
|
||||
make -C bbf_plugin clean
|
||||
|
||||
.PHONY: clean
|
||||
@@ -1,21 +0,0 @@
|
||||
LIB_FIREWALL := libfirewallrule.so
|
||||
|
||||
OBJS := firewall.o
|
||||
|
||||
LIB_CFLAGS = $(CFLAGS) -Wall -Werror -fstrict-aliasing
|
||||
LIB_LDFLAGS = $(LDFLAGS)
|
||||
FPIC := -fPIC
|
||||
|
||||
.PHONY: all
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(LIB_CFLAGS) $(FPIC) -c -o $@ $<
|
||||
|
||||
all: $(LIB_FIREWALL)
|
||||
|
||||
$(LIB_FIREWALL): $(OBJS)
|
||||
$(CC) $(LIB_CFLAGS) $(LIB_LDFLAGS) -shared -o $@ $^
|
||||
|
||||
clean:
|
||||
rm -f *.o $(LIB_FIREWALL)
|
||||
|
||||
@@ -1,820 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 iopsys Software Solutions AB
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 2.1
|
||||
* as published by the Free Software Foundation
|
||||
*
|
||||
* Author: Husaam Mehdi <husaam.mehdi@iopsys.eu>
|
||||
*/
|
||||
|
||||
#include <libbbfdm-api/dmcommon.h>
|
||||
#include <libbbfdm_api.h>
|
||||
|
||||
|
||||
/*************************************************************
|
||||
* UTILITY METHODS
|
||||
**************************************************************/
|
||||
|
||||
static int browseFirewallChainRuleInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct dm_data *p = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
char *inst = NULL;
|
||||
char *parent_chain = NULL;
|
||||
|
||||
if (!(((struct dm_data *)prev_data)->config_section)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bbf_uci_get_value_by_section(((struct dm_data *)prev_data)->config_section, "name", &parent_chain);
|
||||
|
||||
if (!parent_chain) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
synchronize_specific_config_sections_with_dmmap("firewallmngr", "rule", "dmmap_firewallmngr", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
char *current_chain = NULL;
|
||||
|
||||
bbf_uci_get_value_by_section(p->config_section, "chain", ¤t_chain);
|
||||
if (!current_chain) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (DM_STRCMP(current_chain, parent_chain)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "firewall_rule_instance", "firewall_rule_alias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, inst) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
free_dmmap_config_dup_list(&dup_list);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************
|
||||
* ADD & DEL OBJ
|
||||
**************************************************************/
|
||||
|
||||
static int addObjFirewallChainRule(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
struct uci_section *dmmap_firewall_rule = NULL;
|
||||
char creation_date[32] = {0};
|
||||
char rule_name[32] = {0};
|
||||
char *parent_chain = NULL;
|
||||
time_t now = time(NULL);
|
||||
|
||||
if (!((struct dm_data *)data)->config_section)
|
||||
return 0;
|
||||
|
||||
bbf_uci_get_value_by_section(((struct dm_data *)data)->config_section, "name", &parent_chain);
|
||||
if (!parent_chain || !DM_STRLEN(parent_chain))
|
||||
return 0;
|
||||
|
||||
snprintf(rule_name, sizeof(rule_name), "%s_rule_%s", section_name(((struct dm_data *)data)->config_section), *instance);
|
||||
|
||||
// Add rule section
|
||||
dmuci_add_section("firewallmngr", "rule", &s);
|
||||
dmuci_rename_section_by_section(s, rule_name);
|
||||
dmuci_set_value_by_section(s, "name", rule_name);
|
||||
dmuci_set_value_by_section(s, "chain", parent_chain);
|
||||
dmuci_set_value_by_section(s, "target", "0");
|
||||
dmuci_set_value_by_section(s, "enable", "0");
|
||||
dmuci_set_value_by_section(s, "proto", "0");
|
||||
|
||||
// Add rule section in dmmap_firewallmngr file
|
||||
dmuci_add_section_bbfdm("dmmap_firewallmngr", "rule", &dmmap_firewall_rule);
|
||||
dmuci_set_value_by_section(dmmap_firewall_rule, "section_name", rule_name);
|
||||
dmuci_set_value_by_section(dmmap_firewall_rule, "firewall_rule_instance", *instance);
|
||||
|
||||
strftime(creation_date, sizeof(creation_date), "%Y-%m-%dT%H:%M:%SZ", gmtime(&now));
|
||||
dmuci_set_value_by_section(dmmap_firewall_rule, "creation_date", creation_date);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int delObjFirewallChainRule(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
|
||||
{
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
char buf[32] = {0};
|
||||
char *rule_name = NULL;
|
||||
char *rule_order = NULL;
|
||||
|
||||
|
||||
bbf_uci_get_value_by_section(((struct dm_data *)data)->config_section, "order", &rule_order);
|
||||
bbf_uci_get_value_by_section(((struct dm_data *)data)->config_section, "name", &rule_name);
|
||||
|
||||
|
||||
snprintf(buf, sizeof(buf), "%lu", DM_STRTOUL(rule_order) + 1);
|
||||
|
||||
|
||||
// Remove section
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
|
||||
|
||||
// Remove section in dmmap file
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
|
||||
|
||||
break;
|
||||
case DEL_ALL:
|
||||
//TODO
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
* GET & SET PARAM
|
||||
**************************************************************/
|
||||
|
||||
static int get_FirewallChain_RuleNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
int cnt = get_number_of_entries(ctx, data, instance, browseFirewallChainRuleInst);
|
||||
dmasprintf(value, "%d", cnt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = bbf_uci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "enable", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_boolean(ctx, value))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
bool b = true;
|
||||
string_to_bool(value, &b);
|
||||
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "enable", value);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
|
||||
*value = bbf_uci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "status", "Enabled");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_Order(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = bbf_uci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "order", "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_Order(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"1",NULL}}, 1))
|
||||
return FAULT_9007;
|
||||
|
||||
break;
|
||||
case VALUESET:
|
||||
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "order", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, "firewall_rule_alias", instance, value);
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, "firewall_rule_alias", instance, value);
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_Description(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = bbf_uci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "name", "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_Description(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, 256, NULL, NULL))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "name", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_Target(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *target_arr[] = {"Drop", "Accept", "Reject", "Return", "TargetChain", NULL};
|
||||
|
||||
char *target = NULL;
|
||||
|
||||
target = bbf_uci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "target", "0");
|
||||
|
||||
if (target) {
|
||||
int c = atoi(target);
|
||||
|
||||
if (c >=0 && c < 5)
|
||||
*value = target_arr[c];
|
||||
else
|
||||
*value = "Drop";//TODO verify default behaviour
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_Target(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *target_arr[] = {"Drop", "Accept", "Reject", "Return", "TargetChain", NULL};
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, target_arr, NULL))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
int i = 0;
|
||||
bool found = false;
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
if (!DM_STRCMP(value, target_arr[i])) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
char str[2] = {0};
|
||||
snprintf(str, 2, "%d", i);
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "target", str);
|
||||
} else {
|
||||
// TODO correct default behaviour?
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "target", "DROP");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_Log(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = bbf_uci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "log", "0");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_Log(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_boolean(ctx, value))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
bool b = false;
|
||||
string_to_bool(value, &b);
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "log", b ? "1" : "0");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_CreationDate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = bbf_uci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "creation_date", "0001-01-01T00:00:00Z");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_ExpiryDate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *expiry_date = NULL;
|
||||
|
||||
bbf_uci_get_value_by_section(((struct dm_data *)data)->config_section, "expiry", &expiry_date);
|
||||
|
||||
if (expiry_date && DM_STRLEN(expiry_date) != 0 && DM_STRTOL(expiry_date) > 0) {
|
||||
char expiry[sizeof "AAAA-MM-JJTHH:MM:SSZ"];
|
||||
time_t time_value = DM_STRTOL(expiry_date);
|
||||
|
||||
strftime(expiry, sizeof expiry, "%Y-%m-%dT%H:%M:%SZ", gmtime(&time_value));
|
||||
*value = dmstrdup(expiry);
|
||||
} else {
|
||||
*value = "9999-12-31T23:59:59Z";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_ExpiryDate(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char expiry_date[16];
|
||||
struct tm tm;
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_dateTime(ctx, value))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
strptime(value, "%Y-%m-%dT%H:%M:%SZ", &tm);
|
||||
snprintf(expiry_date, sizeof(expiry_date), "%lld", (long long)timegm(&tm));
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "expiry", expiry_date);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_SourceInterface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *linker = NULL;
|
||||
|
||||
bbf_uci_get_value_by_section(((struct dm_data *)data)->config_section, "src", &linker);
|
||||
bbf_get_reference_param("Device.IP.Interface.", "Name", linker, value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_SourceInterface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
|
||||
struct dm_reference reference = {0};
|
||||
|
||||
bbf_get_reference_args(value, &reference);
|
||||
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, reference.path, -1, 256, NULL, NULL)) {
|
||||
return FAULT_9007;
|
||||
}
|
||||
|
||||
|
||||
if (dm_validate_allowed_objects(ctx, &reference, allowed_objects))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
if (DM_STRLEN(reference.value)) {
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "src", reference.value);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_SourceAllInterfaces(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = bbf_uci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "source_all_interfaces", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_SourceAllInterfaces(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_boolean(ctx, value))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
bool b = false;
|
||||
string_to_bool(value, &b);
|
||||
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "source_all_interfaces", b ? "1" : "0");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_DestInterface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *linker = NULL;
|
||||
|
||||
bbf_uci_get_value_by_section(((struct dm_data *)data)->config_section, "dest", &linker);
|
||||
bbf_get_reference_param("Device.IP.Interface.", "Name", linker, value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_DestInterface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
|
||||
struct dm_reference reference = {0};
|
||||
|
||||
bbf_get_reference_args(value, &reference);
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, reference.path, -1, 256, NULL, NULL)) {
|
||||
return FAULT_9007;
|
||||
}
|
||||
|
||||
if (dm_validate_allowed_objects(ctx, &reference, allowed_objects))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
if (DM_STRLEN(reference.value)) {
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "dest", reference.value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_DestAllInterfaces(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = bbf_uci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "dest_all_interfaces", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_DestAllInterfaces(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_boolean(ctx, value))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
bool b = false;
|
||||
string_to_bool(value, &b);
|
||||
|
||||
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "dest_all_interfaces", b ? "1" : "0");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_IPVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *ipversion = NULL;
|
||||
|
||||
bbf_uci_get_value_by_section(((struct dm_data *)data)->config_section, "family", &ipversion);
|
||||
|
||||
if (!ipversion) {
|
||||
*value = "-1";
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strcasecmp(ipversion, "ipv4") == 0) {
|
||||
*value = "4";
|
||||
} else if (strcasecmp(ipversion, "ipv6") == 0) {
|
||||
*value = "6";
|
||||
} else {
|
||||
*value = "-1";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_IPVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_int(ctx, value, RANGE_ARGS{{"-1","15"}}, 1))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
if (DM_LSTRCMP(value, "4") == 0)
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "family", "ipv4");
|
||||
else if (DM_LSTRCMP(value, "6") == 0)
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "family", "ipv6");
|
||||
else if (DM_LSTRCMP(value, "-1") == 0)
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "family", "");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_DestIP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = bbf_uci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "dest_ip", "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_DestIP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, 45, NULL, IPAddress))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "dest_ip", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_DestMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = bbf_uci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "dest_mask", "");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_DestMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, 49, NULL, IPPrefix))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
char *pch = NULL;
|
||||
pch = DM_STRCHR(value, '/');
|
||||
if (pch == NULL)
|
||||
return 0;
|
||||
pch++;
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "dest_mask", pch);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_SourceIP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = bbf_uci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "src_ip", "");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_SourceIP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, 45, NULL, IPAddress))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "src_ip", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_SourceMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = bbf_uci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "source_mask", "");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_SourceMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, 49, NULL, IPPrefix))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
char *pch = NULL;
|
||||
pch = DM_STRCHR(value, '/');
|
||||
if (pch == NULL)
|
||||
return 0;
|
||||
pch++;
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "source_mask", pch);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_Protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *proto = NULL, buf[256], protocol[32], protocol_nbr[16];
|
||||
|
||||
bbf_uci_get_value_by_section(((struct dm_data *)data)->config_section, "proto", &proto);
|
||||
|
||||
if (!proto || DM_STRLEN(proto) == 0 || strchr(proto, ' ')) {
|
||||
*value = "255";
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (*proto == '0' || strcmp(proto, "all") == 0) {
|
||||
*value = "-1";
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (isdigit_str(proto)) {
|
||||
*value = proto;
|
||||
return 0;
|
||||
}
|
||||
|
||||
FILE *fp = fopen("/etc/protocols", "r");
|
||||
if (fp == NULL)
|
||||
return 0;
|
||||
|
||||
while (fgets (buf , 256 , fp) != NULL) {
|
||||
sscanf(buf, "%31s %15s", protocol, protocol_nbr);
|
||||
if (DM_STRCASECMP(protocol, proto) == 0) {
|
||||
*value = dmstrdup(protocol_nbr);
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_Protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_int(ctx, value, RANGE_ARGS{{"-1","255"}}, 1))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "proto", (*value == '-') ? "0" : value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_DestPort(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = bbf_uci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "dest_port", "-1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_DestPort(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_int(ctx, value, RANGE_ARGS{{"-1","65535"}}, 1))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "dest_port", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_DestPortRangeMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = bbf_uci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "dest_port_range_max", "-1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_DestPortRangeMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_int(ctx, value, RANGE_ARGS{{"-1","65535"}}, 1))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "dest_port_range_max", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_SourcePort(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = bbf_uci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "source_port", "-1");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_SourcePort(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_int(ctx, value, RANGE_ARGS{{"-1","65535"}}, 1))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "source_port", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_SourcePortRangeMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = bbf_uci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "source_port_range_max", "-1");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_SourcePortRangeMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_int(ctx, value, RANGE_ARGS{{"-1","65535"}}, 1))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "source_port_range_max", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_FirewallChainRule_SourceMAC(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = bbf_uci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "src_mac", "");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_FirewallChainRule_SourceMAC(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, 17, NULL, MACAddress))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "src_mac", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************
|
||||
* OBJ & PARAM DEFINITION
|
||||
***********************************************************************************************************************************/
|
||||
|
||||
/* *** Device.Firewall.Chain.{i}.Rule.{i}. *** */
|
||||
DMLEAF tFirewallChainRuleParams[] = {
|
||||
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type */
|
||||
{"Enable", &DMWRITE, DMT_BOOL, get_FirewallChainRule_Enable, set_FirewallChainRule_Enable, BBFDM_BOTH},
|
||||
{"Status", &DMREAD, DMT_STRING, get_FirewallChainRule_Status, NULL, BBFDM_BOTH},
|
||||
{"Order", &DMWRITE, DMT_STRING, get_FirewallChainRule_Order, set_FirewallChainRule_Order, BBFDM_BOTH},
|
||||
{"Alias", &DMWRITE, DMT_STRING, get_FirewallChainRule_Alias, set_FirewallChainRule_Alias, BBFDM_BOTH},
|
||||
{"Description", &DMWRITE, DMT_STRING, get_FirewallChainRule_Description, set_FirewallChainRule_Description, BBFDM_BOTH},
|
||||
{"Target", &DMWRITE, DMT_STRING, get_FirewallChainRule_Target, set_FirewallChainRule_Target, BBFDM_BOTH},
|
||||
/*{"TargetChain", &DMWRITE, DMT_STRING, get_FirewallChainRule_TargetChain, set_FirewallChainRule_TargetChain, BBFDM_BOTH, DM_FLAG_REFERENCE},*/
|
||||
{"Log", &DMWRITE, DMT_BOOL, get_FirewallChainRule_Log, set_FirewallChainRule_Log, BBFDM_BOTH},
|
||||
{"CreationDate", &DMREAD, DMT_TIME, get_FirewallChainRule_CreationDate, NULL, BBFDM_BOTH},
|
||||
{"ExpiryDate", &DMWRITE, DMT_TIME, get_FirewallChainRule_ExpiryDate, set_FirewallChainRule_ExpiryDate, BBFDM_BOTH},
|
||||
{"SourceInterface", &DMWRITE, DMT_STRING, get_FirewallChainRule_SourceInterface, set_FirewallChainRule_SourceInterface, BBFDM_BOTH, DM_FLAG_REFERENCE},
|
||||
/*{"SourceInterfaceExclude", &DMWRITE, DMT_BOOL, get_FirewallChainRule_SourceInterfaceExclude, set_FirewallChainRule_SourceInterfaceExclude, BBFDM_BOTH},*/
|
||||
{"SourceAllInterfaces", &DMWRITE, DMT_BOOL, get_FirewallChainRule_SourceAllInterfaces, set_FirewallChainRule_SourceAllInterfaces, BBFDM_BOTH},
|
||||
{"DestInterface", &DMWRITE, DMT_STRING, get_FirewallChainRule_DestInterface, set_FirewallChainRule_DestInterface, BBFDM_BOTH, DM_FLAG_REFERENCE},
|
||||
/*{"DestInterfaceExclude", &DMWRITE, DMT_BOOL, get_FirewallChainRule_DestInterfaceExclude, set_FirewallChainRule_DestInterfaceExclude, BBFDM_BOTH},*/
|
||||
{"DestAllInterfaces", &DMWRITE, DMT_BOOL, get_FirewallChainRule_DestAllInterfaces, set_FirewallChainRule_DestAllInterfaces, BBFDM_BOTH},
|
||||
{"IPVersion", &DMWRITE, DMT_INT, get_FirewallChainRule_IPVersion, set_FirewallChainRule_IPVersion, BBFDM_BOTH},
|
||||
{"DestIP", &DMWRITE, DMT_STRING, get_FirewallChainRule_DestIP, set_FirewallChainRule_DestIP, BBFDM_BOTH},
|
||||
{"DestMask", &DMWRITE, DMT_STRING, get_FirewallChainRule_DestMask, set_FirewallChainRule_DestMask, BBFDM_BOTH},
|
||||
/*{"DestIPExclude", &DMWRITE, DMT_BOOL, get_FirewallChainRule_DestIPExclude, set_FirewallChainRule_DestIPExclude, BBFDM_BOTH},*/
|
||||
{"SourceIP", &DMWRITE, DMT_STRING, get_FirewallChainRule_SourceIP, set_FirewallChainRule_SourceIP, BBFDM_BOTH},
|
||||
{"SourceMask", &DMWRITE, DMT_STRING, get_FirewallChainRule_SourceMask, set_FirewallChainRule_SourceMask, BBFDM_BOTH},
|
||||
/*{"SourceIPExclude", &DMWRITE, DMT_BOOL, get_FirewallChainRule_SourceIPExclude, set_FirewallChainRule_SourceIPExclude, BBFDM_BOTH},*/
|
||||
{"Protocol", &DMWRITE, DMT_INT, get_FirewallChainRule_Protocol, set_FirewallChainRule_Protocol, BBFDM_BOTH},
|
||||
/*{"ProtocolExclude", &DMWRITE, DMT_BOOL, get_FirewallChainRule_ProtocolExclude, set_FirewallChainRule_ProtocolExclude, BBFDM_BOTH},*/
|
||||
{"DestPort", &DMWRITE, DMT_INT, get_FirewallChainRule_DestPort, set_FirewallChainRule_DestPort, BBFDM_BOTH},
|
||||
{"DestPortRangeMax", &DMWRITE, DMT_INT, get_FirewallChainRule_DestPortRangeMax, set_FirewallChainRule_DestPortRangeMax, BBFDM_BOTH},
|
||||
/*{"DestPortExclude", &DMWRITE, DMT_BOOL, get_FirewallChainRule_DestPortExclude, set_FirewallChainRule_DestPortExclude, BBFDM_BOTH},*/
|
||||
{"SourcePort", &DMWRITE, DMT_INT, get_FirewallChainRule_SourcePort, set_FirewallChainRule_SourcePort, BBFDM_BOTH},
|
||||
{"SourcePortRangeMax", &DMWRITE, DMT_INT, get_FirewallChainRule_SourcePortRangeMax, set_FirewallChainRule_SourcePortRangeMax, BBFDM_BOTH},
|
||||
/*{"SourcePortExclude", &DMWRITE, DMT_BOOL, get_FirewallChainRule_SourcePortExclude, set_FirewallChainRule_SourcePortExclude, BBFDM_BOTH},*/
|
||||
/*{"DSCP", &DMWRITE, DMT_INT, get_FirewallChainRule_DSCP, set_FirewallChainRule_DSCP, BBFDM_BOTH},*/
|
||||
/*{"DSCPExclude", &DMWRITE, DMT_BOOL, get_FirewallChainRule_DSCPExclude, set_FirewallChainRule_DSCPExclude, BBFDM_BOTH},*/
|
||||
/*{"ConnectionState", &DMWRITE, DMT_STRING, get_FirewallChainRule_ConnectionState, set_FirewallChainRule_ConnectionState, BBFDM_BOTH},*/
|
||||
{"SourceMAC", &DMWRITE, DMT_STRING, get_FirewallChainRule_SourceMAC, set_FirewallChainRule_SourceMAC, BBFDM_BOTH},
|
||||
/*{"SourceMACExclude", &DMWRITE, DMT_BOOL, get_FirewallChainRule_SourceMACExclude, set_FirewallChainRule_SourceMACExclude, BBFDM_BOTH},*/
|
||||
{0}
|
||||
};
|
||||
|
||||
DMLEAF tDeviceFirewallChainRuleParam[] = {
|
||||
{"RuleNumberOfEntries", &DMREAD, DMT_UNINT, get_FirewallChain_RuleNumberOfEntries, NULL, BBFDM_BOTH},
|
||||
{0}
|
||||
};
|
||||
|
||||
/* *** Device.Firewall.Chain.{i}. *** */
|
||||
DMOBJ tDeviceFirewallChainRuleObj[] = {
|
||||
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys */
|
||||
{"Rule", &DMWRITE, addObjFirewallChainRule, delObjFirewallChainRule, NULL, browseFirewallChainRuleInst, NULL, NULL, NULL, tFirewallChainRuleParams, NULL, BBFDM_BOTH, NULL},
|
||||
{0}
|
||||
};
|
||||
|
||||
/* ********** DynamicObj ********** */
|
||||
DM_MAP_OBJ tDynamicObj[] = {
|
||||
/* parentobj, nextobject, parameter */
|
||||
{"Device.Firewall.Chain.", tDeviceFirewallChainRuleObj, tDeviceFirewallChainRuleParam},
|
||||
{0}
|
||||
};
|
||||
@@ -1,394 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <syslog.h>
|
||||
#include <libubox/blobmsg_json.h>
|
||||
#include <libubus.h>
|
||||
#include <uci.h>
|
||||
#include <json-c/json.h>
|
||||
|
||||
|
||||
|
||||
int nat_get_status(struct ubus_context *ctx, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method,
|
||||
struct blob_attr *msg);
|
||||
int firewallmngr_get_status(struct ubus_context *ctx_arg, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method,
|
||||
struct blob_attr *msg);
|
||||
|
||||
const char *ubus_socket;
|
||||
struct ubus_context *ctx = NULL;
|
||||
|
||||
enum {
|
||||
STATUS_POLICY_INSTANCE,
|
||||
STATUS_POLICY_MAX
|
||||
};
|
||||
|
||||
static const struct blobmsg_policy status_policy[STATUS_POLICY_MAX] = {
|
||||
[STATUS_POLICY_INSTANCE] = { .name = "instance", .type = BLOBMSG_TYPE_STRING },
|
||||
};
|
||||
|
||||
static const struct ubus_method nat_methods[] = {
|
||||
UBUS_METHOD("status", nat_get_status, status_policy),
|
||||
};
|
||||
|
||||
static struct ubus_object_type nat_object_type =
|
||||
UBUS_OBJECT_TYPE("nat", nat_methods);
|
||||
|
||||
static struct ubus_object nat_object = {
|
||||
.name = "nat",
|
||||
.type = &nat_object_type,
|
||||
.methods = nat_methods,
|
||||
.n_methods = ARRAY_SIZE(nat_methods),
|
||||
};
|
||||
|
||||
static const struct ubus_method firewallmngr_methods[] = {
|
||||
{ .name = "status", .handler = firewallmngr_get_status },
|
||||
};
|
||||
|
||||
static struct ubus_object_type firewallmngr_object_type =
|
||||
UBUS_OBJECT_TYPE("firewallmngr", firewallmngr_methods);
|
||||
|
||||
static struct ubus_object firewallmngr_object = {
|
||||
.name = "firewallmngr",
|
||||
.type = &firewallmngr_object_type,
|
||||
.methods = firewallmngr_methods,
|
||||
.n_methods = ARRAY_SIZE(firewallmngr_methods),
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To expose the firewallmngr object on ubus i.e., firewallmngr or nat with method status
|
||||
* @param context input parameter pointer to ubus context
|
||||
* retrun integer value 0 on success and -1 on failure
|
||||
*/
|
||||
static int firewallmngr_publish_object(struct ubus_context *context, struct ubus_object *obj)
|
||||
{
|
||||
int ret;
|
||||
ret = ubus_add_object(context, obj);
|
||||
if (ret) {
|
||||
syslog(LOG_ERR, "Failed to add firewallmngr ubus object: %s\n",
|
||||
ubus_strerror(ret));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void nat_get_interfacesetting_status(struct blob_buf *buf, struct uci_package *uci_pkg, struct blob_attr *msg)
|
||||
{
|
||||
char *status = "Disabled";
|
||||
struct uci_element *uci_elmnt = NULL;
|
||||
struct blob_attr *tb[STATUS_POLICY_MAX];
|
||||
char instance[20] = {0};
|
||||
|
||||
blobmsg_parse(status_policy, STATUS_POLICY_MAX, tb, blob_data(msg), (unsigned int)blob_len(msg));
|
||||
|
||||
if (!tb[STATUS_POLICY_INSTANCE])
|
||||
return;
|
||||
|
||||
strncpy(instance, blobmsg_data(tb[STATUS_POLICY_INSTANCE]), sizeof(instance)-1);
|
||||
|
||||
uci_foreach_element(&uci_pkg->sections, uci_elmnt) {
|
||||
struct uci_section *uci_sec = uci_to_section(uci_elmnt);
|
||||
|
||||
|
||||
if (uci_sec && !strcmp(uci_sec->type, "zone")) {
|
||||
struct uci_element *e = NULL;
|
||||
if (strcmp(instance, uci_sec->e.name))
|
||||
continue;
|
||||
|
||||
blobmsg_add_string(buf, "name", uci_sec->e.name);
|
||||
uci_foreach_element(&uci_sec->options, e) {
|
||||
struct uci_option *uci_opn = uci_to_option(e);
|
||||
syslog(LOG_INFO,"%s %d \n", __FUNCTION__, __LINE__);
|
||||
if (uci_opn && !strcmp(uci_opn->e.name, "enabled")) {
|
||||
status = (*(uci_opn->v.string) == 'n' || *(uci_opn->v.string) == '0' ) ? "Disabled" : "Enabled";
|
||||
break;
|
||||
}
|
||||
}
|
||||
blobmsg_add_string(buf, "Status", status);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void nat_get_portmapping_status(struct blob_buf *buf, struct uci_package *uci_pkg, struct blob_attr *msg)
|
||||
{
|
||||
char *status = "Disabled";
|
||||
struct uci_element *uci_elmnt = NULL;
|
||||
struct blob_attr *tb[STATUS_POLICY_MAX];
|
||||
char instance[20] = {0};
|
||||
|
||||
blobmsg_parse(status_policy, STATUS_POLICY_MAX, tb, blob_data(msg), (unsigned int)blob_len(msg));
|
||||
|
||||
if (!tb[STATUS_POLICY_INSTANCE])
|
||||
return;
|
||||
|
||||
strncpy(instance, blobmsg_data(tb[STATUS_POLICY_INSTANCE]), sizeof(instance)-1);
|
||||
|
||||
uci_foreach_element(&uci_pkg->sections, uci_elmnt) {
|
||||
struct uci_section *uci_sec = uci_to_section(uci_elmnt);
|
||||
|
||||
if (uci_sec && !strcmp(uci_sec->type, "redirect")) {
|
||||
struct uci_element *e = NULL;
|
||||
if (strcmp(instance, uci_sec->e.name))
|
||||
continue;
|
||||
|
||||
blobmsg_add_string(buf, "name", uci_sec->e.name);
|
||||
uci_foreach_element(&uci_sec->options, e) {
|
||||
struct uci_option *uci_opn = uci_to_option(e);
|
||||
if (uci_opn && !strcmp(uci_opn->e.name, "enabled")) {
|
||||
status = (*(uci_opn->v.string) == 'n' || *(uci_opn->v.string) == '0' ) ? "Disabled" : "Enabled";
|
||||
break;
|
||||
}
|
||||
}
|
||||
blobmsg_add_string(buf, "Status", status);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* nat_get_status function callback on ubus method nat_status
|
||||
* @param ctx input parameter pointer to ubus context
|
||||
* @param obj input parameter pointer to ubus object in out case nat
|
||||
* @param req input parameter pointer to ubus requested data
|
||||
* @param method input parameter pointer to char method i.e., nat_status
|
||||
* @param msg input parameter pointer containing
|
||||
* retrun integer value 0 on success and -1 on failure
|
||||
*/
|
||||
int nat_get_status(struct ubus_context *ctx_arg, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method,
|
||||
struct blob_attr *msg)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
struct blob_buf b = {0};
|
||||
struct uci_package *uci_pkg = NULL;
|
||||
struct uci_context *uci_ctx = uci_alloc_context();
|
||||
|
||||
uci_load(uci_ctx, "firewall", &uci_pkg);
|
||||
if (!uci_pkg) {
|
||||
syslog(LOG_ERR, "nat Failed to load configuration\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
blob_buf_init(&b, 0);
|
||||
|
||||
nat_get_interfacesetting_status(&b, uci_pkg, msg);
|
||||
nat_get_portmapping_status(&b, uci_pkg, msg);
|
||||
|
||||
ubus_send_reply(ctx_arg, req, b.head);
|
||||
|
||||
blob_buf_free(&b);
|
||||
uci_unload(uci_ctx, uci_pkg);
|
||||
done:
|
||||
uci_free_context(uci_ctx);
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
static void firewallmngr_get_service_status(struct blob_buf *buf, struct uci_package *uci_pkg, struct blob_attr *msg)
|
||||
{
|
||||
char *status = "Disabled";
|
||||
struct uci_element *uci_elmnt = NULL;
|
||||
struct blob_attr *tb[STATUS_POLICY_MAX];
|
||||
char instance[30] = {0};
|
||||
|
||||
blobmsg_parse(status_policy, STATUS_POLICY_MAX, tb, blob_data(msg), (unsigned int)blob_len(msg));
|
||||
|
||||
if (!tb[STATUS_POLICY_INSTANCE])
|
||||
return;
|
||||
|
||||
strcpy(instance,"fwmngr_");
|
||||
strncat(instance, blobmsg_data(tb[STATUS_POLICY_INSTANCE]), sizeof(instance)-1);
|
||||
|
||||
|
||||
uci_foreach_element(&uci_pkg->sections, uci_elmnt) {
|
||||
struct uci_section *uci_sec = uci_to_section(uci_elmnt);
|
||||
|
||||
if (uci_sec && !strcmp(uci_sec->type, "service")) {
|
||||
struct uci_element *e = NULL;
|
||||
if (strcmp(instance, uci_sec->e.name))
|
||||
continue;
|
||||
|
||||
blobmsg_add_string(buf, "name", uci_sec->e.name);
|
||||
uci_foreach_element(&uci_sec->options, e) {
|
||||
struct uci_option *uci_opn = uci_to_option(e);
|
||||
if (uci_opn && !strcmp(uci_opn->e.name, "enabled")) {
|
||||
status = (*(uci_opn->v.string) == 'n' || *(uci_opn->v.string) == '0' ) ? "Disabled" : "Enabled";
|
||||
break;
|
||||
}
|
||||
}
|
||||
blobmsg_add_string(buf, "Status", status);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void firewallmngr_get_dmz_status(struct blob_buf *buf, struct uci_package *uci_pkg, struct blob_attr *msg)
|
||||
{
|
||||
char *status = "Disabled";
|
||||
struct uci_element *uci_elmnt = NULL;
|
||||
struct blob_attr *tb[STATUS_POLICY_MAX];
|
||||
char instance[30] = {0};
|
||||
|
||||
blobmsg_parse(status_policy, STATUS_POLICY_MAX, tb, blob_data(msg), (unsigned int)blob_len(msg));
|
||||
|
||||
if (!tb[STATUS_POLICY_INSTANCE])
|
||||
return;
|
||||
|
||||
strcpy(instance,"fwmngr_");
|
||||
strncat(instance, blobmsg_data(tb[STATUS_POLICY_INSTANCE]), sizeof(instance)-1);
|
||||
|
||||
|
||||
uci_foreach_element(&uci_pkg->sections, uci_elmnt) {
|
||||
struct uci_section *uci_sec = uci_to_section(uci_elmnt);
|
||||
|
||||
if (uci_sec && !strcmp(uci_sec->type, "redirect")) {
|
||||
struct uci_element *e = NULL;
|
||||
if (strcmp(instance, uci_sec->e.name))
|
||||
continue;
|
||||
|
||||
blobmsg_add_string(buf, "name", uci_sec->e.name);
|
||||
uci_foreach_element(&uci_sec->options, e) {
|
||||
struct uci_option *uci_opn = uci_to_option(e);
|
||||
if (uci_opn && !strcmp(uci_opn->e.name, "enabled")) {
|
||||
status = (*(uci_opn->v.string) == 'n' || *(uci_opn->v.string) == '0' ) ? "Disabled" : "Enabled";
|
||||
break;
|
||||
}
|
||||
}
|
||||
blobmsg_add_string(buf, "Status", status);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void firewallmngr_get_rule_status(struct blob_buf *buf, struct uci_package *uci_pkg, struct blob_attr *msg)
|
||||
{
|
||||
char *status = "Disabled";
|
||||
struct uci_element *uci_elmnt = NULL;
|
||||
struct blob_attr *tb[STATUS_POLICY_MAX];
|
||||
char instance[30] = {0};
|
||||
|
||||
blobmsg_parse(status_policy, STATUS_POLICY_MAX, tb, blob_data(msg), (unsigned int)blob_len(msg));
|
||||
|
||||
if (!tb[STATUS_POLICY_INSTANCE])
|
||||
return;
|
||||
|
||||
strcpy(instance,"fwmngr_");
|
||||
strncat(instance, blobmsg_data(tb[STATUS_POLICY_INSTANCE]), sizeof(instance)-1);
|
||||
|
||||
uci_foreach_element(&uci_pkg->sections, uci_elmnt) {
|
||||
struct uci_section *uci_sec = uci_to_section(uci_elmnt);
|
||||
|
||||
if (uci_sec && !strcmp(uci_sec->type, "rule")) {
|
||||
struct uci_element *e = NULL;
|
||||
if (strcmp(instance, uci_sec->e.name))
|
||||
continue;
|
||||
|
||||
blobmsg_add_string(buf, "name", uci_sec->e.name);
|
||||
uci_foreach_element(&uci_sec->options, e) {
|
||||
struct uci_option *uci_opn = uci_to_option(e);
|
||||
if (uci_opn && !strcmp(uci_opn->e.name, "enabled")) {
|
||||
status = (*(uci_opn->v.string) == 'n' || *(uci_opn->v.string) == '0' ) ? "Disabled" : "Enabled";
|
||||
break;
|
||||
}
|
||||
}
|
||||
blobmsg_add_string(buf, "Status", status);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* firewallmngr_get_status function callback on ubus method firewallmngr_status
|
||||
* @param ctx input parameter pointer to ubus context
|
||||
* @param obj input parameter pointer to ubus object in out case firewallmngr
|
||||
* @param req input parameter pointer to ubus requested data
|
||||
* @param method input parameter pointer to char method i.e., firewallmngr_status
|
||||
* @param msg input parameter pointer containing
|
||||
* retrun integer value 0 on success and -1 on failure
|
||||
*/
|
||||
int firewallmngr_get_status(struct ubus_context *ctx_arg, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method,
|
||||
struct blob_attr *msg)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
struct blob_buf b = {0};
|
||||
struct uci_package *uci_pkg = NULL;
|
||||
struct uci_context *uci_ctx = uci_alloc_context();
|
||||
|
||||
blob_buf_init(&b, 0);
|
||||
uci_load(uci_ctx, "firewall", &uci_pkg);
|
||||
if (!uci_pkg) {
|
||||
syslog(LOG_ERR, "firewallmngr Failed to load configuration\n");
|
||||
uci_free_context(uci_ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
firewallmngr_get_rule_status(&b, uci_pkg, msg);
|
||||
firewallmngr_get_dmz_status(&b, uci_pkg, msg);
|
||||
firewallmngr_get_service_status(&b, uci_pkg, msg);
|
||||
|
||||
ubus_send_reply(ctx_arg, req, b.head);
|
||||
|
||||
blob_buf_free(&b);
|
||||
uci_unload(uci_ctx, uci_pkg);
|
||||
uci_free_context(uci_ctx);
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Main function for firewallmngr, everything starts here
|
||||
* @param argc input number of input arguments
|
||||
* @param argv input double pointer array of optional command line arguments
|
||||
* retrun integer value 0 on success and -1 on failure
|
||||
*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
int ch;
|
||||
|
||||
while ((ch = getopt(argc, argv, "s:e:")) != -1) {
|
||||
switch (ch) {
|
||||
case 's':
|
||||
ubus_socket = optarg;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
uloop_init();
|
||||
ctx = ubus_connect(ubus_socket);
|
||||
if (!ctx) {
|
||||
syslog(LOG_ERR, "nat Failed to connect to ubus\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ubus_add_uloop(ctx);
|
||||
ret = firewallmngr_publish_object(ctx, &nat_object);
|
||||
if (ret)
|
||||
goto out;
|
||||
ret = firewallmngr_publish_object(ctx, &firewallmngr_object);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
/* Main loop of firewallmngr */
|
||||
uloop_run();
|
||||
|
||||
out:
|
||||
ubus_free(ctx);
|
||||
uloop_done();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=fscryptctl
|
||||
PKG_VERSION:=1.1.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/google/fscryptctl.git
|
||||
PKG_SOURCE_VERSION:=v$(PKG_VERSION)
|
||||
|
||||
PKG_LICENSE:=Apache-2.0
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=Encryption
|
||||
TITLE:=Fscryptctl
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
fscryptctl is a low-level tool written in C that handles raw keys and manages policies for Linux filesystem encryption,
|
||||
specifically the "fscrypt" kernel interface which is supported by the ext4, f2fs, and UBIFS filesystems
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) -C $(PKG_BUILD_DIR) \
|
||||
CC="$(TARGET_CC)" \
|
||||
LDFLAGS="$(TARGET_LDFLAGS)" \
|
||||
fscryptctl
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/fscryptctl $(1)/usr/bin/fscryptctl
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
@@ -28,7 +28,7 @@ define KernelPackage/$(PKG_NAME)
|
||||
FILES:=$(PKG_BUILD_DIR)/$(PKG_NAME).$(LINUX_KMOD_SUFFIX)
|
||||
KCONFIG:=CONFIG_PACKAGE_kmod-gryphon-led-kernel-module=y
|
||||
AUTOLOAD:=$(call AutoLoad,60,$(PKG_NAME))
|
||||
DEPENDS:= +(TARGET_brcmbca):bcmkernel
|
||||
DEPENDS:= +(TARGET_iopsys_brcm63xx_arm):bcmkernel
|
||||
PKG_LICENSE:=GPLv2
|
||||
PKG_LICENSE_URL:=
|
||||
endef
|
||||
@@ -41,8 +41,32 @@ EXTRA_KCONFIG:= CONFIG_RGB_LED=m
|
||||
|
||||
MODULE_INCLUDE=-I$(PKG_BUILD_DIR)
|
||||
|
||||
# support compilation against BCM SDK kernel
|
||||
include ../../broadcom/bcmkernel/bcm-kernel-toolchain.mk
|
||||
|
||||
ifeq ($(CONFIG_TARGET_iopsys_brcm63xx_arm),y)
|
||||
LINUX_DIR:=$(BUILD_DIR)/bcmkernel/bcm963xx/kernel/linux-4.19
|
||||
# This assumes that the MODULES_SUBDIR set by OpenWrt is of the form
|
||||
# lib/modules/4.19.235-abcdef where 4.19.235 is the version of our fake bcmlinux kernel
|
||||
# and abcdef the git-commit.
|
||||
# The kernel compiled by the Broadcom SDK has a uname -r of 4.19.235, i.e. without the git-commit.
|
||||
# The assignment below removes the part after the - which puts modules in the right directory as
|
||||
# long as the bcmlinux version matches the kernel version in the BCM SDK.
|
||||
# So, this will only stop working in the time window where the BCM SDK has been updated
|
||||
# but bcmlinux has not yet been updated.
|
||||
MODULES_SUBDIR:=$(firstword $(subst -, ,$(MODULES_SUBDIR)))
|
||||
TARGET_CROSS:=$(CONFIG_BRCM_ALT_TOOLCHAIN_BASE)/$(CONFIG_BRCM_ALT_ARM_TOOLCHAIN_TOPDIR)/bin/$(CONFIG_BRCM_ALT_ARM_TOOLCHAIN_PREFIX)-
|
||||
|
||||
ifeq ($(CONFIG_BCM_CHIP_ID),$(filter $(CONFIG_BCM_CHIP_ID),"63158" "6856" "6858"))
|
||||
# These targets use a 64-bit kernel
|
||||
LINUX_KARCH:=arm64
|
||||
TARGET_CROSS:=$(CONFIG_BRCM_ALT_TOOLCHAIN_BASE)/$(CONFIG_BRCM_ALT_AARCH64_TOOLCHAIN_TOPDIR)/bin/$(CONFIG_BRCM_ALT_AARCH64_TOOLCHAIN_PREFIX)-
|
||||
else ifeq ($(CONFIG_BCM_CHIP_ID),$(filter $(CONFIG_BCM_CHIP_ID),"6855" "6756" "47622" "63148" "63178"))
|
||||
# These targets use a 32-bit arm-sfp kernel
|
||||
LINUX_KARCH:=arm
|
||||
TARGET_CROSS:=$(CONFIG_BRCM_ALT_TOOLCHAIN_BASE)/$(CONFIG_BRCM_ALT_ARMSFP_TOOLCHAIN_TOPDIR)/bin/$(CONFIG_BRCM_ALT_ARMSFP_TOOLCHAIN_PREFIX)-
|
||||
endif
|
||||
# For some reason, Broadcom's kernel does not set the include paths correctly when compiling out-of-tree modules
|
||||
EXTRA_KCPPFLAGS:="-I $(LINUX_DIR)/../bcmkernel/include -I $(LINUX_DIR)/arch/arm/mach-bcm963xx/include"
|
||||
endif
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)/kdevlinks/
|
||||
|
||||
@@ -220,6 +220,7 @@ static int canyon_led_probe(struct platform_device *pdev)
|
||||
if (IS_ERR(leds->clock_gpio)) {
|
||||
dev_err(&pdev->dev, "Failed to acquire clock GPIO %ld\n",
|
||||
PTR_ERR(leds->clock_gpio));
|
||||
leds->clock_gpio = NULL;
|
||||
return PTR_ERR(leds->clock_gpio);
|
||||
}
|
||||
|
||||
@@ -227,6 +228,7 @@ static int canyon_led_probe(struct platform_device *pdev)
|
||||
if (IS_ERR(leds->clock_gpio)) {
|
||||
dev_err(&pdev->dev, "Failed to acquire clock GPIO %ld\n",
|
||||
PTR_ERR(leds->clock_gpio));
|
||||
leds->clock_gpio = NULL;
|
||||
return PTR_ERR(leds->clock_gpio);
|
||||
} else {
|
||||
printk(KERN_INFO "Got clock gpio\n");
|
||||
@@ -244,6 +246,7 @@ static int canyon_led_probe(struct platform_device *pdev)
|
||||
if (IS_ERR(leds->data_gpio)) {
|
||||
dev_err(&pdev->dev, "Failed to acquire data GPIO %ld\n",
|
||||
PTR_ERR(leds->data_gpio));
|
||||
leds->data_gpio = NULL;
|
||||
return PTR_ERR(leds->data_gpio);
|
||||
}
|
||||
|
||||
@@ -251,6 +254,7 @@ static int canyon_led_probe(struct platform_device *pdev)
|
||||
if (IS_ERR(leds->data_gpio)) {
|
||||
dev_err(&pdev->dev, "Failed to acquire data GPIO %ld\n",
|
||||
PTR_ERR(leds->data_gpio));
|
||||
leds->data_gpio = NULL;
|
||||
return PTR_ERR(leds->data_gpio);
|
||||
} else {
|
||||
printk(KERN_INFO "Got data gpio\n");
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
if (PACKAGE_hostmngr)
|
||||
|
||||
menu "Configuration"
|
||||
|
||||
config HOSTMNGR_HOSTS_HISTORY
|
||||
bool "Keep history of hosts"
|
||||
default y
|
||||
|
||||
config HOSTMNGR_PLATFORM_HAS_WIFI
|
||||
bool "Platform has WiFi"
|
||||
default y if PACKAGE_libwifi
|
||||
|
||||
endmenu
|
||||
|
||||
endif
|
||||
@@ -1,76 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2020-2023 IOPSYS Software Solutions AB
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=hostmngr
|
||||
PKG_VERSION:=1.2.3
|
||||
|
||||
LOCAL_DEV=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=b4990b384461f2d1ff75a122a7fa5d9276f211bb
|
||||
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
|
||||
endif
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu>
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
||||
define Package/hostmngr
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Show and manage hosts in the network
|
||||
DEPENDS= +libubox +libuci +libubus +ubus +libeasy +libnl-genl \
|
||||
+libjson-c +libblobmsg-json +libnfnetlink +libmnl \
|
||||
+libnetfilter-conntrack \
|
||||
+HOSTMNGR_PLATFORM_HAS_WIFI:libwifi +libbbfdm-api \
|
||||
+libwifiutils
|
||||
|
||||
endef
|
||||
|
||||
define Package/hostmngr/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
define Package/hostmngr/description
|
||||
This package provides hostmngr that can detect and show host devices
|
||||
present in the network.
|
||||
endef
|
||||
|
||||
TARGET_CFLAGS += \
|
||||
-I$(STAGING_DIR)/usr/include \
|
||||
-I$(STAGING_DIR)/usr/include/libnl3 \
|
||||
-I$(STAGING_DIR)/usr/include/libnetfilter_conntrack \
|
||||
-D_GNU_SOURCE
|
||||
|
||||
ifeq ($(CONFIG_HOSTMNGR_PLATFORM_HAS_WIFI),y)
|
||||
TARGET_CFLAGS += -DHAS_WIFI
|
||||
endif
|
||||
|
||||
MAKE_PATH:=src
|
||||
|
||||
define Package/hostmngr/install
|
||||
$(CP) ./files/etc $(1)/
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_DIR) $(1)/etc/hostmngr/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/hostmngr $(1)/usr/sbin/
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/src/bbf_plugin/libhostmngr.so $(1)/etc/hostmngr/
|
||||
$(INSTALL_DIR) $(1)/usr/share/hostmngr
|
||||
$(INSTALL_DATA) ./files/scripts/hosts_acl.sh $(1)/usr/share/hostmngr/
|
||||
endef
|
||||
|
||||
ifeq ($(LOCAL_DEV),1)
|
||||
define Build/Prepare
|
||||
rsync -r --exclude=.* ~/git/hostmngr/ $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
endif
|
||||
|
||||
$(eval $(call BuildPackage,hostmngr))
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"daemon": {
|
||||
"config": {
|
||||
"loglevel": "1"
|
||||
},
|
||||
"input": {
|
||||
"type": "DotSo",
|
||||
"name": "/etc/hostmngr/libhostmngr.so"
|
||||
},
|
||||
"output": {
|
||||
"type": "UBUS",
|
||||
"parent_dm": "Device.",
|
||||
"object": "Hosts",
|
||||
"root_obj": "bbfdm"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user