Compare commits

..

1 Commits

Author SHA1 Message Date
nevadita.chatterjee
282d1b7eb8 map-topology:Version 3.0.2 2021-10-28 17:28:07 +05:30
113 changed files with 1461 additions and 4002 deletions

View File

@@ -5,11 +5,11 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=libbbfdm PKG_NAME:=libbbfdm
PKG_VERSION:=6.4.27 PKG_VERSION:=6.1.3
PKG_FIXUP:=autoreconf PKG_FIXUP:=autoreconf
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/bbf.git PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/bbf.git
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=710485a57e311a5b4c5434efe3e79fc58cb6c429 PKG_SOURCE_VERSION:=aa17126d32043a0eb92250671e281b51b9205c0f
PKG_RELEASE=$(PKG_SOURCE_VERSION) PKG_RELEASE=$(PKG_SOURCE_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip PKG_MIRROR_HASH:=skip
@@ -125,10 +125,8 @@ endef
define Build/InstallDev define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/lib $(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_DIR) $(1)/usr/include
$(INSTALL_DIR) $(1)/usr/include/libbbfdm $(INSTALL_DIR) $(1)/usr/include/libbbfdm
$(INSTALL_DIR) $(1)/usr/include/libbbf_api $(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)/*.h $(1)/usr/include/libbbfdm/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/libbbf_api/*.h $(1)/usr/include/libbbf_api/ $(INSTALL_DATA) $(PKG_BUILD_DIR)/libbbf_api/*.h $(1)/usr/include/libbbf_api/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/.libs/libbbfdm.{a,so*} $(1)/usr/lib/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/.libs/libbbfdm.{a,so*} $(1)/usr/lib/

81
crun/Makefile Normal file
View File

@@ -0,0 +1,81 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=crun
PKG_VERSION:=0.20
PKG_RELEASE:=$(AUTORELEASE)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/containers/crun.git
PKG_SOURCE_DATE:=2021-06-07
PKG_SOURCE_VERSION:=8d6a8b5ab80461cfed19f020a36584af13c32038
PKG_MIRROR_HASH:=9ca1f0e530b33ce8820bd03329eb6731c5050d6e7f35bd2463d9a81cc00382e0
PKG_BUILD_DEPENDS:=argp-standalone
PKG_BUILD_PARALLEL:=1
PKG_FIXUP:=autoreconf
PKG_INSTALL:=1
PKG_MAINTAINER:=Oskari Rauta <oskari.rauta@gmail.com>
PKG_LICENSE:=GPL-2.0-or-later
PKG_LICENSE_FILES:=COPYING
include $(INCLUDE_DIR)/package.mk
define Package/crun
SECTION:=utils
CATEGORY:=Utilities
TITLE:=crun
URL:=https://github.com/containers/crun
DEPENDS:=@!arc +libseccomp +libcap
endef
define Package/crun/description
A fast and low-memory footprint OCI Container Runtime fully written in C.
endef
CONFIGURE_ARGS+= \
--disable-systemd \
--enable-embedded-yajl \
--enable-caps \
--enable-dl \
--enable-seccomp \
--enable-bpf
define Build/Prepare
$(call Build/Prepare/Default)
$(SED) '/#include <git-version.h>/d' $(PKG_BUILD_DIR)/src/crun.c
endef
define Build/Configure
$(call Build/Configure/Default)
$(SED) '/#define PACKAGE \"/d' $(PKG_BUILD_DIR)/config.h
$(SED) '/#define VERSION \"/d' $(PKG_BUILD_DIR)/config.h
$(SED) '/#define GIT_VERSION \"/d' $(PKG_BUILD_DIR)/config.h
$(SED) '/#define PACKAGE_BUGREPORT \"/d' $(PKG_BUILD_DIR)/config.h
$(SED) '/#define PACKAGE_NAME \"/d' $(PKG_BUILD_DIR)/config.h
$(SED) '/#define PACKAGE_STRING \"/d' $(PKG_BUILD_DIR)/config.h
$(SED) '/#define PACKAGE_TARNAME \"/d' $(PKG_BUILD_DIR)/config.h
$(SED) '/#define PACKAGE_VERSION \"/d' $(PKG_BUILD_DIR)/config.h
echo "#define PACKAGE \"$(PKG_NAME)\"" >> $(PKG_BUILD_DIR)/config.h
echo "#define VERSION \"$(PKG_VERSION)\"" >> $(PKG_BUILD_DIR)/config.h
echo "#define PACKAGE_NAME \"$(PKG_NAME)\"" >> $(PKG_BUILD_DIR)/config.h
echo "#define PACKAGE_VERSION \"$(PKG_VERSION)\"" >> $(PKG_BUILD_DIR)/config.h
echo "#define PACKAGE_STRING \"$(PKG_NAME) $(PKG_VERSION)\"" >> $(PKG_BUILD_DIR)/config.h
echo "#define PACKAGE_TARNAME \"$(PKG_NAME)\"" >> $(PKG_BUILD_DIR)/config.h
echo "#define PACKAGE_BUGREPORT \"bugs@openwrt.org\"" >> $(PKG_BUILD_DIR)/config.h
echo "#define GIT_VERSION \"$(PKG_SOURCE_VERSION)\"" >> $(PKG_BUILD_DIR)/config.h
endef
define Package/crun/install
$(INSTALL_DIR) $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/crun $(1)/usr/bin/
endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libcrun.* $(1)/usr/lib/
endef
$(eval $(call BuildPackage,crun))

View File

@@ -1,11 +0,0 @@
if PACKAGE_dectmngr
menu "Configuration"
config ENABLE_LINE_SETTINGS_EXTENSION
bool "Enable Line Settings List extension "
default y
endmenu
endif

View File

@@ -8,13 +8,13 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=dectmngr PKG_NAME:=dectmngr
PKG_RELEASE:=3 PKG_RELEASE:=3
PKG_VERSION:=3.5.1 PKG_VERSION:=3.1.18
LOCAL_DEV=0 LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1) ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/dectmngr.git PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/dectmngr.git
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=ef9d4c6124d0ca66f048f3d678d9a25f13aa4207 PKG_SOURCE_VERSION:=0e937cfb839f845cf28922c4dde0572ec2842f85
PKG_MIRROR_HASH:=skip PKG_MIRROR_HASH:=skip
endif endif
@@ -34,40 +34,29 @@ include $(INCLUDE_DIR)/package.mk
define Package/$(PKG_NAME) define Package/$(PKG_NAME)
CATEGORY:=Utilities CATEGORY:=Utilities
TITLE:=DECT Manager TITLE:=DECT Manager
DEPENDS:= +libubox +ubus +uci +libxml2 DEPENDS:= +libubox +ubus +uci
endef endef
define Package/$(PKG_NAME)/description define Package/$(PKG_NAME)/description
DECT manager is a daemon that provides UBUS RPC objects and sends UBUS events for communication with the DECT chip. DECT manager is a daemon that provides UBUS RPC objects and sends UBUS events for communication with the DECT chip.
endef endef
define Package/$(PKG_NAME)/config
source "$(SOURCE)/Config.in"
endef
ifeq ($(LOCAL_DEV),1) ifeq ($(LOCAL_DEV),1)
define Build/Prepare define Build/Prepare
rsync -av --exclude=.* ~/git/voip/dectmngr/* $(PKG_BUILD_DIR)/ rsync -av --exclude=.* ~/git/voip/dectmngr/* $(PKG_BUILD_DIR)/
endef endef
endif endif
TARGET_CFLAGS += \ MAKE_FLAGS += \
-Wall \ CFLAGS+="-Wall"
-I$(STAGING_DIR)/usr/include/libxml2
ifeq ($(CONFIG_ENABLE_LINE_SETTINGS_EXTENSION),y)
TARGET_CFLAGS += -DENABLE_LINE_SETTINGS_EXTENSION
endif
define Package/$(PKG_NAME)/install define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/etc $(INSTALL_DIR) $(1)/etc
$(INSTALL_DIR) $(1)/lib/upgrade/keep.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/app/dectmngr $(1)/usr/sbin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/app/dectmngr $(1)/usr/sbin/
$(STRIP) $(1)/usr/sbin/dectmngr $(STRIP) $(1)/usr/sbin/dectmngr
$(CP) ./files/etc/* $(1)/etc/ $(CP) ./files/etc/* $(1)/etc/
$(INSTALL_DATA) ./files/lib/upgrade/keep.d/dect $(1)/lib/upgrade/keep.d/dect
endef endef
$(eval $(call BuildPackage,$(PKG_NAME))) $(eval $(call BuildPackage,$(PKG_NAME)))

View File

@@ -1,3 +1,2 @@
config dect 'global' config dect 'global'
option log_dect_cmbs 'syslog' option log_dect_cmbs '0'
option log_level 'realtime,warning,error'

Binary file not shown.

Binary file not shown.

View File

@@ -26,7 +26,6 @@ start_service() {
local opt_ext= local opt_ext=
local rfpi= local rfpi=
local model_id= local model_id=
local rxtun=
test $(db get hw.board.hasDect) = "0" && return test $(db get hw.board.hasDect) = "0" && return
@@ -35,33 +34,24 @@ start_service() {
rfpi=$(db -q get hw.board.dect_rfpi) rfpi=$(db -q get hw.board.dect_rfpi)
[ -n "$rfpi" -a ${#rfpi} -eq 14 ] && opt_ext="$opt_ext -rfpi $rfpi" [ -n "$rfpi" -a ${#rfpi} -eq 14 ] && opt_ext="$opt_ext -rfpi $rfpi"
model_id=$(db -q get hw.board.dect_model_id) # model_id=$(db -q get hw.board.dect_model_id)
[ -n "$model_id" -a ${#model_id} -eq 8 ] || { # Setting model_id to 0x010203 is a workaround to reduce synchronisation time of some handset
echo "Invalid hw.board.dect_model_id:$model_id. Set to 30.3B.06" # TODO: remove below line and uncomment the line above to get value from db when the problem is solved
model_id="30.3B.06" model_id="01.02.03"
} [ -n "$model_id" -a ${#model_id} -eq 8 ] && opt_ext="$opt_ext -model $model_id"
opt_ext="$opt_ext -model $model_id"
rxtun=$(db -q get hw.board.dect_rxtun)
[ -n "$rxtun" -a ${#rxtun} -eq 2 ] && opt_ext="$opt_ext -rxtun $rxtun"
config_load dect config_load dect
config_get log_dect_cmbs global log_dect_cmbs syslog config_get_bool log_dect_cmbs global log_dect_cmbs 0
procd_open_instance procd_open_instance
if [ "$log_dect_cmbs" = "none" ]; then if [ $log_dect_cmbs -eq 0 ]; then
echo "Starting dectmngr with cmbs logging disabled" echo "Starting dectmngr with cmbs logging disabled"
procd_set_param command $PROG -comname ttyH0 $opt_ext procd_set_param command $PROG -comname ttyH0 $opt_ext
rm -f $LOG_PATH/* rm -f $LOG_PATH/*
elif [ "$log_dect_cmbs" = "file" ]; then
echo "Starting dectmngr with cmbs logging enabled to file"
procd_set_param command $PROG -comname ttyH0 -log $LOG_PATH/dect-cmbs.log $opt_ext
else else
echo "Starting dectmngr with cmbs logging enabled to syslog" echo "Starting dectmngr with cmbs logging enabled"
procd_set_param command $PROG -comname ttyH0 -syslog $opt_ext procd_set_param command $PROG -comname ttyH0 -log $LOG_PATH/dect-cmbs.log $opt_ext
rm -f $LOG_PATH/*
fi fi
procd_set_param respawn 6 2 3 procd_set_param respawn 6 2 3
procd_set_param term_timeout 20 procd_set_param term_timeout 20
procd_set_param triggers asterisk procd_set_param triggers asterisk
@@ -76,13 +66,13 @@ stop_service() {
} }
reload_service() { reload_service() {
ubus call dect reload stop_and_wait_dectmngr
start
} }
service_triggers() service_triggers()
{ {
procd_add_config_trigger "config.change" "asterisk" /etc/init.d/dectmngr restart procd_add_reload_trigger asterisk dect
procd_add_config_trigger "config.change" "dect" /etc/init.d/dectmngr reload
} }
boot() { boot() {

View File

@@ -1 +0,0 @@
/etc/dect/LA_DB

View File

@@ -33,7 +33,7 @@ exec_class_log() {
} }
get_priority() { get_priority() {
local prio=$(echo $1|tr 'A-Z' 'a-z'); local prio=$(echo $1|tr [A-Z] [a-z]);
case "${prio}" in case "${prio}" in
"lowest") "lowest")
echo 8;; echo 8;;
@@ -55,7 +55,7 @@ get_priority() {
} }
get_mark() { get_mark() {
local prio=$(echo $1|tr 'A-Z' 'a-z'); local prio=$(echo $1|tr [A-Z] [a-z]);
case "${prio}" in case "${prio}" in
"lowest") "lowest")
echo "0x41/0x3df";; echo "0x41/0x3df";;

View File

@@ -15,7 +15,7 @@ exec_log() {
} }
get_priority() { get_priority() {
local prio=$(echo $1|tr 'A-Z' 'a-z'); local prio=$(echo $1|tr [A-Z] [a-z]);
case "${prio}" in case "${prio}" in
"lowest") "lowest")
echo 0;; echo 0;;
@@ -98,7 +98,7 @@ manage_rule() {
return 1; return 1;
} }
protocol=$(echo ${proto}|tr 'A-Z' 'a-z') protocol=$(echo ${proto}|tr [A-Z] [a-z])
prio_num=$(get_priority ${priority}) prio_num=$(get_priority ${priority})
if [ -n "${macaddr}" -a -n "${prio_num}" ]; then if [ -n "${macaddr}" -a -n "${prio_num}" ]; then
for p in ${port}; do for p in ${port}; do

View File

@@ -19,7 +19,7 @@ exec_log() {
} }
get_priority() { get_priority() {
local prio=$(echo $1|tr 'A-Z' 'a-z'); local prio=$(echo $1|tr [A-Z] [a-z]);
case "${prio}" in case "${prio}" in
"lowest") "lowest")
echo 0;; echo 0;;

View File

@@ -7,13 +7,13 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=easy-soc-libs PKG_NAME:=easy-soc-libs
PKG_VERSION:=6.4.40 PKG_VERSION:=6.4.6
PKG_RELEASE:=1 PKG_RELEASE:=1
LOCAL_DEV=0 LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1) ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=699744d5ae9e043715c260f9b58bbc18747895f9 PKG_SOURCE_VERSION:=1ab8baa259d059cdb34e2f1fa95df51e1eafd1fc
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/easy-soc-libs.git PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/easy-soc-libs.git
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu> PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu>
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
@@ -32,6 +32,7 @@ define Package/easy-soc-libs
CATEGORY:=Libraries CATEGORY:=Libraries
TITLE:=IOPSYS Easy SoC libraries TITLE:=IOPSYS Easy SoC libraries
SUBMENU:=IOPSYS Easy SoC libraries SUBMENU:=IOPSYS Easy SoC libraries
DEPENDS:=+libopenssl
MENU:=1 MENU:=1
endef endef
@@ -78,6 +79,7 @@ endif
TARGET_CFLAGS += \ TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include \ -I$(STAGING_DIR)/usr/include \
-I$(STAGING_DIR)/usr/include/openssl \
-I$(STAGING_DIR)/usr/include/libnl3 -I$(STAGING_DIR)/usr/include/libnl3
MAKE_FLAGS += \ MAKE_FLAGS += \

View File

@@ -13,7 +13,7 @@ LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1) ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/endptmngr.git PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/endptmngr.git
PKG_SOURCE_VERSION:=3a71d4124061287783e0d4c763b1b20e925d2133 PKG_SOURCE_VERSION:=6d7b2e9c90234767cb56a1e7885f42825bd6287a
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip PKG_MIRROR_HASH:=skip
endif endif

View File

@@ -7,8 +7,6 @@ USE_PROCD=1
NAME=endptmngr NAME=endptmngr
start_service() { start_service() {
[ "$(db -q get hw.board.hasVoice)" = "1" ] || return
procd_open_instance procd_open_instance
procd_set_param env hw_board_hasDect=$(db get hw.board.hasDect) procd_set_param env hw_board_hasDect=$(db get hw.board.hasDect)
procd_set_param command $NAME procd_set_param command $NAME

View File

@@ -12,7 +12,7 @@ PKG_VERSION:=1.0
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/fdtextract.git PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/fdtextract.git
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=7e013f0afa68378d38a6bdc9b0c5a342bd3dd0a5 PKG_SOURCE_VERSION:=ef46eb3be68ae1216d8699234f237fb2243289f1
PKG_MIRROR_HASH:=skip PKG_MIRROR_HASH:=skip
PKG_LICENSE:=GPLv2 PKG_LICENSE:=GPLv2

View File

@@ -28,7 +28,6 @@ define KernelPackage/$(PKG_NAME)
FILES:=$(PKG_BUILD_DIR)/$(PKG_NAME).$(LINUX_KMOD_SUFFIX) FILES:=$(PKG_BUILD_DIR)/$(PKG_NAME).$(LINUX_KMOD_SUFFIX)
KCONFIG:=CONFIG_PACKAGE_kmod-gryphon-led-kernel-module=y KCONFIG:=CONFIG_PACKAGE_kmod-gryphon-led-kernel-module=y
AUTOLOAD:=$(call AutoLoad,60,$(PKG_NAME)) AUTOLOAD:=$(call AutoLoad,60,$(PKG_NAME))
DEPENDS:= +(TARGET_iopsys_brcm63xx_arm):bcmkernel
PKG_LICENSE:=GPLv2 PKG_LICENSE:=GPLv2
PKG_LICENSE_URL:= PKG_LICENSE_URL:=
endef endef
@@ -41,21 +40,6 @@ EXTRA_KCONFIG:= CONFIG_RGB_LED=m
MODULE_INCLUDE=-I$(PKG_BUILD_DIR) MODULE_INCLUDE=-I$(PKG_BUILD_DIR)
ifeq ($(CONFIG_TARGET_iopsys_brcm63xx_arm),y)
LINUX_DIR:=$(BUILD_DIR)/bcmkernel/bcm963xx/kernel/linux-4.19
MODULES_SUBDIR:=lib/modules/4.19.183
TARGET_CROSS:=$(CONFIG_BCM_TOOLCHAIN)/bin/$(CONFIG_BCM_TOOLTUPLE)
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:=/opt/toolchains/crosstools-aarch64-gcc-9.2-linux-4.19-glibc-2.30-binutils-2.32/bin/aarch64-buildroot-linux-gnu-
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 define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)/kdevlinks/ mkdir -p $(PKG_BUILD_DIR)/kdevlinks/
$(CP) -s `pwd`/src/* $(PKG_BUILD_DIR)/kdevlinks/ $(CP) -s `pwd`/src/* $(PKG_BUILD_DIR)/kdevlinks/

View File

@@ -8,11 +8,11 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=icwmp PKG_NAME:=icwmp
PKG_VERSION:=8.2.27 PKG_VERSION:=8.2.5-2021-10-26
PKG_FIXUP:=autoreconf PKG_FIXUP:=autoreconf
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/icwmp.git PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/icwmp.git
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=da88c8c28656b2db54ab205d26faccda68546c05 PKG_SOURCE_VERSION:=bf33885bf7a4c61fa32d19a96d48acf0abf92d25
PKG_RELEASE=$(PKG_SOURCE_VERSION) PKG_RELEASE=$(PKG_SOURCE_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip PKG_MIRROR_HASH:=skip
@@ -82,18 +82,19 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/etc/icwmpd $(INSTALL_DIR) $(1)/etc/icwmpd
$(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/etc/config $(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
$(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/uci-defaults $(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_DIR) $(1)/lib/upgrade/keep.d $(INSTALL_DIR) $(1)/lib/upgrade/keep.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/icwmpd $(1)/usr/sbin/icwmpd $(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/icwmpd $(1)/usr/sbin/icwmpd
$(INSTALL_DATA) ./files/etc/config/cwmp $(1)/etc/config/cwmp $(INSTALL_DATA) ./files/etc/config/cwmp $(1)/etc/config/cwmp
$(INSTALL_BIN) ./files/etc/firewall.cwmp $(1)/etc/firewall.cwmp $(INSTALL_BIN) ./files/etc/firewall.cwmp $(1)/etc/firewall.cwmp
$(INSTALL_BIN) ./files/etc/hotplug.d/iface/90-icwmp $(1)/etc/hotplug.d/iface/90-icwmp
$(INSTALL_BIN) ./files/etc/init.d/icwmpd $(1)/etc/init.d/icwmpd $(INSTALL_BIN) ./files/etc/init.d/icwmpd $(1)/etc/init.d/icwmpd
$(INSTALL_BIN) ./files/etc/uci-defaults/85-cwmp-set-userid $(1)/etc/uci-defaults/ $(INSTALL_BIN) ./files/etc/uci-defaults/85-cwmp-set-userid $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./files/etc/uci-defaults/90-cwmpfirewall $(1)/etc/uci-defaults/ $(INSTALL_BIN) ./files/etc/uci-defaults/90-cwmpfirewall $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./files/etc/uci-defaults/95-icwmp-generate-ssl $(1)/etc/uci-defaults/ $(INSTALL_BIN) ./files/etc/uci-defaults/90-icwmp-set-dhcp-reqopts $(1)/etc/uci-defaults/
$(INSTALL_DATA) ./files/lib/upgrade/keep.d/icwmp $(1)/lib/upgrade/keep.d/icwmp $(INSTALL_DATA) ./files/lib/upgrade/keep.d/icwmp $(1)/lib/upgrade/keep.d/icwmp
$(INSTALL_BIN) ./files/etc/icwmpd/update.sh $(1)/etc/icwmpd/update.sh
endef endef
$(eval $(call BuildPackage,$(PKG_NAME))) $(eval $(call BuildPackage,$(PKG_NAME)))

View File

@@ -1,9 +1,11 @@
config acs 'acs' config acs 'acs'
option url ''
option userid '' #$OUI-$SER option userid '' #$OUI-$SER
option passwd 'iopsys' option passwd 'iopsys'
option periodic_inform_enable 'true' option periodic_inform_enable 'true'
option periodic_inform_interval '1800' option periodic_inform_interval '1800'
option periodic_inform_time '0001-01-01T00:00:00Z' option periodic_inform_time '0001-01-01T00:00:00Z'
option ParameterKey ''
option dhcp_discovery 'enable' option dhcp_discovery 'enable'
# compression possible configs: GZIP, Deflate, Disabled # compression possible configs: GZIP, Deflate, Disabled
option compression 'Disabled' option compression 'Disabled'

View File

@@ -1,12 +1,6 @@
#!/bin/sh
#created by the icwmp package #created by the icwmp package
log() {
echo "${@}"|logger -t firewall.cwmp -p info
}
if [ ! -f "/var/state/cwmp" ]; then if [ ! -f "/var/state/cwmp" ]; then
touch "/var/state/cwmp"
exit 0; exit 0;
fi fi
@@ -14,25 +8,24 @@ zone_name=$(uci -c /var/state -q get cwmp.acs.zonename)
port=$(uci -q get cwmp.cpe.port) port=$(uci -q get cwmp.cpe.port)
ipaddr=$(uci -c /var/state -q get cwmp.acs.ip) ipaddr=$(uci -c /var/state -q get cwmp.acs.ip)
ip6addr=$(uci -c /var/state -q get cwmp.acs.ip6) ip6addr=$(uci -c /var/state -q get cwmp.acs.ip6)
incoming_rule=$(uci -q get cwmp.cpe.incoming_rule|tr 'A-Z' 'a-z') incoming_rule=$(uci -q get cwmp.cpe.incoming_rule|tr [A-Z] [a-z])
if [ -z "${zone_name}" ]; then if [ "$zone_name" = "" ]; then
log "empty firewall zone name"
exit 0 exit 0
elif [ "$zone_name" = "icwmp" ]; then elif [ "$zone_name" = "icwmp" ]; then
iptables -nL zone_icwmp_input 2> /dev/null iptables -nL zone_icwmp_input 2> /dev/null
if [ $? != 0 ]; then if [ $? != 0 ]; then
iptables -w 1 -N zone_icwmp_input iptables -N zone_icwmp_input
iptables -w 1 -t filter -A INPUT -j zone_icwmp_input iptables -t filter -A INPUT -j zone_icwmp_input
iptables -w 1 -I zone_icwmp_input -p tcp --dport $port -j REJECT iptables -I zone_icwmp_input -p tcp --dport $port -j REJECT
else else
iptables -w 1 -F zone_icwmp_input iptables -F zone_icwmp_input
iptables -w 1 -I zone_icwmp_input -p tcp --dport $port -j REJECT iptables -I zone_icwmp_input -p tcp --dport $port -j REJECT
fi fi
else else
iptables -w 1 -F zone_icwmp_input 2> /dev/null iptables -F zone_icwmp_input 2> /dev/null
iptables -w 1 -t filter -D INPUT -j zone_icwmp_input 2> /dev/null iptables -t filter -D INPUT -j zone_icwmp_input 2> /dev/null
iptables -w 1 -X zone_icwmp_input 2> /dev/null iptables -X zone_icwmp_input 2> /dev/null
fi fi
cmd="iptables -w 1 -I zone_${zone_name}_input -p tcp" cmd="iptables -w 1 -I zone_${zone_name}_input -p tcp"
@@ -76,6 +69,3 @@ if [ "$?" -eq 0 ]; then
cmd6="${cmd6} -j ACCEPT -m comment --comment=Open_ACS_port" cmd6="${cmd6} -j ACCEPT -m comment --comment=Open_ACS_port"
${cmd6} ${cmd6}
fi fi
uci -c /var/state -q set cwmp.cpe.firewall_restart="init"
uci -c /var/state -q commit cwmp

View File

@@ -0,0 +1,119 @@
#!/bin/sh
. /lib/functions/network.sh
[ "$ACTION" == "ifup" ] || exit 0
[ -f /etc/config/cwmp ] || exit 0
handle_icwmp_restart() {
[ -f /tmp/switching_mode ] && exit 0
[ -f /tmp/wificontrol.txt -a -f /tmp/netmode-conf.pid ] && exit 0
[ "$INTERFACE" == "loopback" ] && exit 0
local defwan=$(uci -q get cwmp.cpe.default_wan_interface)
[ -n "$defwan" -a "$(uci -q get network.$defwan)" == "interface" -a "$defwan" != "$INTERFACE" ] && exit 0
local islan="$(uci -q get network.$INTERFACE.is_lan)"
[ "$islan" == "1" ] && exit 0
local proto="$(uci -q get network.$INTERFACE.proto)"
[ "$proto" == "none" ] && exit 0
local ifname="$(uci -q get network.$INTERFACE.ifname)"
[ "${ifname:0:1}" == "@" ] && exit 0
mkdir -p /tmp/ipv4
network_flush_cache
local previpaddr=""
local curipaddr=""
local ipaddrfile=/tmp/ipv4/$INTERFACE-ipaddr
previpaddr=$(cat $ipaddrfile 2>/dev/null)
network_get_ipaddr curipaddr $INTERFACE
[ -n "$curipaddr" ] && echo $curipaddr > $ipaddrfile || rm -f $ipaddrfile
local prevgateway=""
local curgateway=""
local gatewayfile=/tmp/ipv4/$INTERFACE-gateway
prevgateway=$(cat $gatewayfile 2>/dev/null)
network_get_gateway curgateway $INTERFACE
[ -n "$curgateway" ] && echo $curgateway > $gatewayfile || rm -f $gatewayfile
local prevsubnets=""
local cursubnets=""
local subnetsfile=/tmp/ipv4/$INTERFACE-subnets
prevsubnets=$(cat $subnetsfile 2>/dev/null)
network_get_subnets cursubnets $INTERFACE
[ -n "$cursubnets" ] && echo $cursubnets > $subnetsfile || rm -f $subnetsfile
local prevdnsservers=""
local curdnsservers=""
local dnsserverfile=/tmp/ipv4/$INTERFACE-dnsservers
prevdnsservers=$(cat $dnsserverfile 2>/dev/null)
network_get_dnsserver curdnsservers $INTERFACE
[ -n "$curdnsservers" ] && echo $curdnsservers > $dnsserverfile || rm -f $dnsserverfile
local prevdev=""
local curdev=""
local devfile=/tmp/ipv4/$INTERFACE-dev
prevdev=$(cat $devfile 2>/dev/null)
network_get_device curdev $INTERFACE
[ -n "$curdev" ] && echo $curdev > $devfile || rm -f $devfile
local vendorspecinf=`ubus call network.interface.${defwan} status | jsonfilter -e "@.data.vendorspecinf"`
[ -n "$vendorspecinf" ] && {
local url=""
case $vendorspecinf in
http://*|https://*)
url="$vendorspecinf"
;;
*)
for optval in $vendorspecinf; do
case $optval in
1=*)
url="$(echo $optval | cut -d"=" -f2-)"
;;
esac
done
;;
esac
if [ ! -f /var/state/cwmp ]; then
touch /var/state/cwmp
fi
uci -q -c /var/state/ get cwmp.acs
if [ "$?" -ne 0 ]; then
unnamed=`uci -q -c /var/state/ add cwmp acs`
uci -c /var/state/ -q rename cwmp.$unnamed='acs'
fi
[ -n "$url" ] && uci -c /var/state -q set cwmp.acs.dhcp_url="$url"
uci -c /var/state commit cwmp
}
local prevopt43url=""
local curopt43url=""
local opt43urlfile=/tmp/ipv4/$INTERFACE-opt43url
prevopt43url=$(cat $opt43urlfile 2>/dev/null)
curopt43url="$(uci -c /var/state -q get cwmp.acs.dhcp_url)"
[ -n "$curopt43url" ] && echo $curopt43url > $opt43urlfile || rm -f $opt43urlfile
[ \
"$prevdev" == "$curdev" -a \
"$previpaddr" = "$curipaddr" -a \
"$prevgateway" = "$curgateway" -a \
"$prevsubnets" = "$cursubnets" -a \
"$prevdnsservers" = "$curdnsservers" \
] && {
[ "$prevopt43url" = "$curopt43url" ] && exit 0
[ -z "$prevopt43url" ] && exit 0
}
echo "Restarting icwmp"|logger -t cwmp.hotplug -p info
/etc/init.d/icwmpd reload &
}
handle_icwmp_restart

View File

@@ -1,43 +0,0 @@
#!/bin/sh
log() {
echo $@ |logger -t cwmp.update -p info
}
handle_icwmp_update() {
local defwan=$(uci -q get cwmp.cpe.default_wan_interface)
local vendorspecinf=`ifstatus ${defwan} | jsonfilter -e "@.data.vendorspecinf"`
log "Handling dhcp option value ${vendorspecinf}"
[ -n "$vendorspecinf" ] && {
local url=""
local old_url="$(uci -q get cwmp.acs.dhcp_url)"
case $vendorspecinf in
http://*|https://*)
url="${vendorspecinf}"
;;
*)
for optval in $vendorspecinf; do
case $optval in
1=*)
url="$(echo $optval | cut -d"=" -f2-)"
;;
esac
done
;;
esac
if [ -n "$url" ]; then
log "## icwmp url[${old_url}] changed to [${url}]"
if [ "${url}" != "${old_url}" ]; then
log "Restarting icwmp url[${old_url}] changed to [${url}]"
uci -q set cwmp.acs.dhcp_url="$url"
uci commit cwmp
ubus call uci commit '{"config":"cwmp"}'
fi
fi
}
}
handle_icwmp_update

View File

@@ -6,41 +6,125 @@ include /lib/network
. /usr/share/libubox/jshn.sh . /usr/share/libubox/jshn.sh
START=99 START=99
STOP=2 STOP=10
USE_PROCD=1 USE_PROCD=1
PROG="/usr/sbin/icwmpd" PROG="/usr/sbin/icwmpd"
EXTRA_HELP=" start [GetRPCMethods] Start icwmpd service and send GetRPCMethods"
log() { log() {
echo "${@}"|logger -t cwmp.init -p info echo "${@}"|logger -t cwmp.init -p info
} }
enable_dhcp_option43() { validate_url() {
local wan="${1}" # SCHEMA_LIST: contain list of possible schemas that could be present in the acs url
# Example: SCHEMA_LIST="http https"
SCHEMA_LIST="http"
### Ask for DHCP Option 43 only if CWMP is enabled ### for schema in $SCHEMA_LIST; do
local reqopts="$(uci -q get network.$wan.reqopts)" dest=`echo $1 | sed 's/$schema:\/\///g' | cut -f1 -d \/ | cut -f1 -d:`
local proto="$(uci -q get network.$wan.proto)" if [ "_$dest" != "_" ]; then
local newreqopts="" return 0
local option43_present=0 fi
for ropt in $reqopts; do
case $ropt in
43) option43_present=1 ;;
*) ;;
esac
done done
return 1
}
if [ ${option43_present} -eq 1 ]; then get_acs_url() {
return; local default_acs="http://10.10.1.6:8000/openacs/acs"
local acs_dhcp_discovery="$(uci -q get cwmp.acs.dhcp_discovery)"
local url="$(uci -q get cwmp.acs.url)"
local dhcp_url="$(uci -c /var/state -q get cwmp.acs.dhcp_url)"
if [ "$acs_dhcp_discovery" == "enable" -a -n "$dhcp_url" -o -z "$url" ]; then
url="$dhcp_url"
log "ACS URL from DHCP server: $url"
[ -n "$url" ] && uci -c /var/state -q set cwmp.acs.url="$url" || url="$default_acs"
elif [ -n "$url" ];then
url="$(uci -q get cwmp.acs.url)"
log "ACS URL from configuration: $url"
else
url="$default_acs"
log "Using default ACS URL: $url"
[ -n "$url" ] && uci -c /var/state -q set cwmp.acs.url="$url"
fi fi
newreqopts="$reqopts 43" validate_url "$url"
if [ "$?" != "0" ];then
echo "Invalid ACS URL: $url"
exit 1
fi
}
enable_dhcp_option43() {
local wan=$1
local discovery=0
case $2 in
enable|1) discovery=1 ;;
esac
### Ask for DHCP Option 43 only if CWMP is enabled ###
local enabled
local newreqopts=
local baseopts=
local reqopts="$(uci -q get network.$wan.reqopts)"
local proto="$(uci -q get network.$wan.proto)"
local tropts="43"
local oldreqopts="$reqopts"
local ropt iopt
for ropt in $reqopts; do
case $ropt in
43) ;;
*) baseopts="$baseopts $ropt" ;;
esac
done
ropt=""
reqopts="$baseopts $tropts"
for ropt in $reqopts; do
case $ropt in
43) [ $discovery -eq 1 ] && newreqopts="$newreqopts $ropt" ;;
*) newreqopts="$newreqopts $ropt" ;;
esac
done
if [ $proto == "dhcp" ]; then if [ $proto == "dhcp" ]; then
newreqopts="$(echo $newreqopts | tr ' ' '\n' | sort -n | tr '\n' ' ' | sed 's/^[ \t]*//;s/[ \t]*$//')"
oldreqopts="$(echo $oldreqopts | tr ' ' '\n' | sort -n | tr '\n' ' ' | sed 's/^[ \t]*//;s/[ \t]*$//')"
[ "$newreqopts" == "$oldreqopts" ] && return
uci -q set network.$wan.reqopts="$newreqopts" uci -q set network.$wan.reqopts="$newreqopts"
uci commit network uci commit network
ubus call network reload ubus call network reload
fi fi
########################################################
}
wait_for_option43() {
local time=$1
local default_wan_interface dhcp_discovery url
config_get default_wan_interface cpe default_wan_interface "wan"
config_get dhcp_discovery acs dhcp_discovery "0"
config_get url acs url
enable_dhcp_option43 $default_wan_interface $dhcp_discovery
local tm=0
if [ "$dhcp_discovery" == "enable" -o "$dhcp_discovery" == "1" ]
then
log "Waiting for discovery of ACS URL from dhcp server ..."
while [ $tm -le $time ]
do
acs_url=`uci -c /var/state -q get cwmp.acs.dhcp_url`
if [ "$acs_url" != "" ]
then
break
else
sleep 1
fi
tm=$((tm+1))
done
fi
} }
wait_for_resolvfile() { wait_for_resolvfile() {
@@ -58,215 +142,62 @@ wait_for_resolvfile() {
} }
set_wan_interface() { set_wan_interface() {
local wan_interface="${1}"
local l3_device="" local l3_device=""
local default_wan_interface=""
if [ -z "${wan_interface}" ]; then config_get default_wan_interface cpe default_wan_interface "wan"
return 0; json_load "$(ifstatus $default_wan_interface)"
fi
json_load "$(ifstatus ${wan_interface})"
json_get_var l3_device l3_device json_get_var l3_device l3_device
if [ -n "$l3_device" ]; then if [ "$l3_device" != "" ];then
uci -q set cwmp.cpe.interface="${l3_device}" uci -q set cwmp.cpe.interface="$l3_device"
uci -q commit cwmp uci -q commit cwmp
fi fi
} }
copy_cwmp_etc_files_to_varstate() { service_running() {
if [ ! -f /var/state/cwmp ] ubus wait_for usp.raw
then
if [ -f /etc/icwmpd/cwmp ]
then
uci -q -c /etc/icwmpd delete cwmp.acs
uci -q -c /etc/icwmpd commit cwmp
cp /etc/icwmpd/cwmp /var/state/cwmp
else
touch /var/state/cwmp
fi
fi
mkdir -p /var/run/icwmpd
if [ -f /etc/icwmpd/icwmpd_backup_session.xml ]
then
mv /etc/icwmpd/icwmpd_backup_session.xml /var/run/icwmpd 2>/dev/null
fi
if [ -f /etc/icwmpd/dm_enabled_notify.xml ]
then
mv /etc/icwmpd/dm_enabled_notify /var/run/icwmpd 2>/dev/null
fi
}
copy_cwmp_varstate_files_to_etc() {
if [ -f /var/state/cwmp ]
then
cp /var/state/cwmp /etc/icwmpd 2>/dev/null
fi
if [ -f /var/run/icwmpd/icwmpd_backup_session.xml ]
then
cp /var/run/icwmpd/icwmpd_backup_session.xml /etc/icwmpd 2>/dev/null
fi
if [ -f /var/run/icwmpd/dm_enabled_notify.xml ]
then
cp /var/run/icwmpd/dm_enabled_notify /etc/icwmpd 2>/dev/null
fi
}
validate_acs_section()
{
uci_validate_section cwmp acs "acs" \
'passwd:string' \
'periodic_inform_enable:bool' \
'periodic_inform_interval:uinteger' \
'periodic_inform_time:string' \
'url:string' \
'dhcp_url:string' \
'compression:or("GZIP","Deflate","Disabled")' \
'retry_min_wait_interval:range(1, 65535)' \
'retry_interval_multiplier:range(1000, 65535)' \
'https_ssl_capath:file' \
'ipv6_enable:bool'
}
validate_cpe_section()
{
uci_validate_section cwmp cpe "cpe" \
'interface:string' \
'default_wan_interface:string' \
'log_to_console:or("enable","disable")' \
'log_to_file:or("enable","disable")' \
'log_severity:or("EMERG", "ALERT", "CRITIC" ,"ERROR", "WARNING", "NOTICE", "INFO", "DEBUG")' \
'log_file_name:string' \
'log_max_size:uinteger' \
'userid:string' \
'passwd:string' \
'port:uinteger' \
'provisioning_code:string:""' \
'amd_version:range(1, 6)' \
'instance_mode:or("InstanceNumber","InstanceAlias")' \
'session_timeout:uinteger' \
'notification:bool' \
'exec_download:bool' \
'periodic_notify_enable:bool' \
'enable:bool' \
'periodic_notify_interval:uinteger'
}
validate_defaults() {
config_load cwmp
validate_acs_section || {
log "Validation of acs section failed"
return 1;
}
[ -z "${url}" -a -z "${dhcp_url}" ] && {
log "ACS url is empty can't start"
return 1;
}
validate_cpe_section || {
log "Validation of cpe section failed"
return 1;
}
[ -z "${default_wan_interface}" ] && {
log "Wan interface is empty"
return 1;
}
return 0;
}
boot() {
local dhcp_url=""
local discovery="1"
config_load cwmp
config_get_bool dhcp_discovery acs dhcp_discovery 1
config_get dhcp_url acs dhcp_url ""
if [ "${dhcp_discovery}" == "enable" -o "${dhcp_discovery}" == "1" ]; then
if [ -z "${dhcp_url}" ]; then
log "dhcp discovery enabled but no dhcp url, trigger update"
/etc/icwmpd/update.sh
fi
fi
start
} }
start_service() { start_service() {
local enable_cwmp if [ ! -f /tmp/.icwmpd_boot ]; then
local wan_interface touch /etc/icwmpd/.icwmpd_boot
local dhcp_discovery touch /tmp/.icwmpd_boot
else
[ -f /sbin/netifd ] && log "Waiting for Network to be started ..." && ubus -t 5 wait_for network.interface
[ -f /etc/config/wireless ] && log "Waiting for WiFi to be started ..." && ubus -t 5 wait_for network.wireless
[ -f /usr/sbin/dnsmasq ] && log "Waiting for DNS Proxy to be started ..." && ubus -t 5 wait_for dnsmasq
[ -f /etc/config/dhcp ] && log "Waiting for DNS Server(s) ..." && wait_for_resolvfile 20
[ -f /usr/sbin/asterisk ] && log "Waiting for Voice to be started ..." && ubus -t 5 wait_for asterisk
config_load cwmp log "Waiting for usp.raw to be started"
config_get_bool enable_cwmp cpe enable 1 ubus wait_for usp.raw
config_get dhcp_discovery acs dhcp_discovery
config_get wan_interface cpe default_wan_interface "wan"
if [ "$enable_cwmp" = "0" -o "$enable_cwmp" = "false" ]; then config_load cwmp
log "CWMP is not enabled" set_wan_interface
return 0 wait_for_option43 20
get_acs_url
procd_open_instance icwmp
procd_set_param command "$PROG"
if [ "$1" = "GetRPCMethods" ];then
procd_append_param command -g
elif [ -f /etc/icwmpd/.icwmpd_boot ]; then
procd_append_param command -b
fi
procd_set_param respawn \
${respawn_threshold:-5} \
${respawn_timeout:-10} ${respawn_retry:-3}
procd_close_instance
fi fi
# Set wan interface if not configured
set_wan_interface "${wan_interface}"
# Set dhcp option 43 if dhcp discovery enabled
if [ "${dhcp_discovery}" == "enable" -o "${dhcp_discovery}" == "1" ]; then
enable_dhcp_option43 "${wan_interface}"
fi
[ -f /sbin/netifd ] && log "Waiting for Network to be started ..." && ubus -t 5 wait_for network.interface
[ -f /usr/sbin/dnsmasq ] && log "Waiting for DNS Proxy to be started ..." && ubus -t 5 wait_for dnsmasq
[ -f /etc/config/dhcp ] && log "Waiting for DNS Server(s) ..." && wait_for_resolvfile 20
# Copy backup data so that if it restart latter on it gets the info
copy_cwmp_etc_files_to_varstate
validate_defaults || {
log "Validation of defaults failed"
return 1;
}
procd_open_instance icwmp
procd_set_param command "$PROG"
procd_append_param command -b
procd_set_param respawn \
${respawn_threshold:-5} \
${respawn_timeout:-10} ${respawn_retry:-3}
procd_set_param watch network.interface
procd_close_instance
}
stop_service()
{
copy_cwmp_varstate_files_to_etc
} }
reload_service() { reload_service() {
log "Restarting CWMP client"
stop stop
start start
} }
service_triggers() { service_triggers() {
procd_add_reload_trigger "cwmp" procd_add_config_trigger "config.change" "cwmp" /etc/init.d/icwmpd reload
procd_open_trigger
json_add_array
json_add_string "" "interface.update"
json_add_array
json_add_array
json_add_string "" "run_script"
json_add_string "" "/etc/icwmpd/update.sh"
json_close_array
json_close_array
json_add_int "" "2000"
json_close_array
procd_close_trigger
} }

View File

@@ -1,18 +1,18 @@
# Copy defaults by the factory to the cwmp UCI user section. # Copy defaults by the factory to the cwmp UCI user section.
# Get Manufacturer OUI.
oui=$(uci -q get cwmp.cpe.manufacturer_oui)
if [ -z "${oui}" ]; then
oui=$(db -q get device.deviceinfo.ManufacturerOUI)
fi
oui=$(echo "${oui}" | tr 'a-f' 'A-F') # Get factory base MAC.
baseMac=$(db -q get hw.board.basemac)
# Erase colon and space characters.
baseMac=${baseMac//:/}
baseMac=${baseMac// /}
# Caseing and fixed length string.
mac=$(printf "%12.12X" $((0x$baseMac)))
# Get system serial number. # Get system serial number.
serial=$(uci -q get cwmp.cpe.serial_number) serial=$(db -q get hw.board.serial_number)
if [ -z "${serial}" ]; then
serial=$(db -q get device.deviceinfo.SerialNumber)
fi
# Get userid values # Get userid values
acs_userid=$(uci -q get cwmp.acs.userid) acs_userid=$(uci -q get cwmp.acs.userid)
@@ -21,12 +21,12 @@ cpe_userid=$(uci -q get cwmp.cpe.userid)
# Only set if they are empty # Only set if they are empty
if [ -z "$acs_userid" ] if [ -z "$acs_userid" ]
then then
uci -q set cwmp.acs.userid="${oui}-${serial}" uci -q set cwmp.acs.userid="${mac:0:6}-${serial}"
fi fi
if [ -z "$cpe_userid" ] if [ -z "$cpe_userid" ]
then then
uci -q set cwmp.cpe.userid="${oui}-${serial}" uci -q set cwmp.cpe.userid="${mac:0:6}-${serial}"
fi fi
# No need for commit here, it is done by uci_apply_defaults(). # No need for commit here, it is done by uci_apply_defaults().

View File

@@ -0,0 +1,54 @@
#!/bin/sh
. /lib/functions.sh
set_cwmp_reqopts() {
### Ask for DHCP Option 43 only if CWMP is enabled ###
local wan=$(uci -q get cwmp.cpe.default_wan_interface)
local dhcp_discovery=$(uci -q get cwmp.acs.dhcp_discovery)
local discovery=0
case $dhcp_discovery in
enable|1) discovery=1 ;;
esac
local newreqopts=
local baseopts=
local reqopts="$(uci -q get network.$wan.reqopts)"
local proto="$(uci -q get network.$wan.proto)"
local tropts="43"
local oldreqopts="$reqopts"
local ropt iopt
for ropt in $reqopts; do
case $ropt in
43) ;;
*) baseopts="$baseopts $ropt" ;;
esac
done
ropt=""
reqopts="$baseopts $tropts"
for ropt in $reqopts; do
case $ropt in
43) [ $discovery -eq 1 ] && newreqopts="$newreqopts $ropt" ;;
*) newreqopts="$newreqopts $ropt" ;;
esac
done
if [ "$proto" == "dhcp" ]; then
newreqopts="$(echo $newreqopts | tr ' ' '\n' | sort -n | tr '\n' ' ' | sed 's/^[ \t]*//;s/[ \t]*$//')"
oldreqopts="$(echo $oldreqopts | tr ' ' '\n' | sort -n | tr '\n' ' ' | sed 's/^[ \t]*//;s/[ \t]*$//')"
[ "$newreqopts" == "$oldreqopts" ] && return
uci -q set network.$wan.reqopts="$newreqopts"
uci commit network
fi
}
regenerate_ssl_link(){
local cert_dir="/etc/ssl/certs"
local all_file=$(ls $cert_dir/*.pem)
for cfile in $all_file
do
ln -s $cfile $cert_dir/$(openssl x509 -hash -noout -in $cfile).0
done
}
set_cwmp_reqopts
regenerate_ssl_link

View File

@@ -1,18 +0,0 @@
#!/bin/sh
. /lib/functions.sh
regenerate_ssl_link(){
[ ! -d "/etc/ssl/certs" ] && return 0;
[ ! -f "/etc/ssl/certs/*.pem" ] && return 0;
local cert_dir="/etc/ssl/certs"
local all_file=$(ls $cert_dir/*.pem)
for cfile in $all_file
do
ln -s $cfile $cert_dir/$(openssl x509 -hash -noout -in $cfile).0
done
}
regenerate_ssl_link

View File

@@ -1 +1 @@
/var/run/icwmpd/icwmpd_backup_session.xml /etc/icwmpd/.icwmpd_backup_session.xml

View File

@@ -6,9 +6,5 @@ config IEEE1905_EXTENSION_ALLOWED
bool "Allow plugins to extend 1905 CMDUs and/or TLVs" bool "Allow plugins to extend 1905 CMDUs and/or TLVs"
default y default y
config IEEE1905_PLATFORM_HAS_WIFI
bool "Platform has WiFi"
default y if PACKAGE_libwifi
endmenu endmenu
endif endif

View File

@@ -1,14 +0,0 @@
if (PACKAGE_map-plugin)
menu "Configurations"
config MULTIAP_DYNAMIC_CNTLR_SYNC_CONFIG
bool "Sync configuration between dynamic controllers in the network"
default n
config MULTIAP_FUZZ_1905_CMDUS
bool "Include support to fuzz 1905 CMDUs for testing purpose"
default n
endmenu
endif

View File

@@ -5,12 +5,12 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=ieee1905 PKG_NAME:=ieee1905
PKG_VERSION:=4.6.19 PKG_VERSION:=4.0.4
LOCAL_DEV=0 LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1) ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=7267a76fafa264792415a1cdc697a9e47934a1e6 PKG_SOURCE_VERSION:=e99c9ad752ee165c37d40a3ac139e0906bf03e3c
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/ieee1905.git PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/ieee1905.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip PKG_MIRROR_HASH:=skip
@@ -37,30 +37,26 @@ endef
define Package/libieee1905 define Package/libieee1905
$(call Package/ieee1905/Default,$(1)) $(call Package/ieee1905/Default,$(1))
TITLE+= (library for CMDU and TLV handling) TITLE+= (library for CMDU and TLV handling)
DEPENDS= +libubox +libuci +libubus +libeasy +libnl-genl \ DEPENDS= +libubox +libuci +libubus +libeasy +libnl-genl +libwifi \
+libjson-c +libblobmsg-json +libopenssl +libjson-c +libblobmsg-json
endef endef
define Package/ieee1905 define Package/ieee1905
$(call Package/ieee1905/Default,$(1)) $(call Package/ieee1905/Default,$(1))
TITLE+= ieee1905d (daemon implementing 1905.1 and provides cli) TITLE+= ieee1905d (daemon implementing 1905.1 and provides cli)
DEPENDS= +libubox +libuci +libubus +libeasy +libnl-genl \ DEPENDS= +libubox +libuci +libubus +libeasy +libnl-genl +libwifi \
+libjson-c +libblobmsg-json +ubus +libpthread \ +libjson-c +libblobmsg-json +libwifi +ubus +libpthread \
+libieee1905 +IEEE1905_PLATFORM_HAS_WIFI:libwifi +libnl-genl +libieee1905
endef endef
define Package/map-plugin define Package/map-plugin
$(call Package/ieee1905/Default,$(1)) $(call Package/ieee1905/Default,$(1))
TITLE:=Multi-AP (Easymesh) plugin TITLE:=Multi-AP (Easymesh) plugin
DEPENDS= +libubox +libuci +libubus +libeasy +libnl-genl \ DEPENDS= +libubox +libuci +libubus +libeasy +libnl-genl +libwifi \
+libjson-c +libblobmsg-json +ieee1905 +libieee1905 +libjson-c +libblobmsg-json +ieee1905 +libieee1905
endef endef
define Package/map-plugin/config
source "$(SOURCE)/Config.map-plugin.in"
endef
define Package/ieee1905/description define Package/ieee1905/description
This package provides IEEE Std 1905.1 stack. This package provides IEEE Std 1905.1 stack.
endef endef
@@ -72,18 +68,8 @@ endef
TARGET_CFLAGS += \ TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include \ -I$(STAGING_DIR)/usr/include \
-I$(STAGING_DIR)/usr/include/libnl3 \ -I$(STAGING_DIR)/usr/include/libnl3 \
-I$(STAGING_DIR)/usr/include/openssl \
-D_GNU_SOURCE -D_GNU_SOURCE
ifeq ($(CONFIG_IEEE1905_PLATFORM_HAS_WIFI),y)
TARGET_CFLAGS += -DHAS_WIFI
endif
ifeq ($(CONFIG_MULTIAP_DYNAMIC_CNTLR_SYNC_CONFIG),y)
TARGET_CFLAGS += -DDYNAMIC_CNTLR_SYNC_CONFIG
endif
MAKE_PATH:=src MAKE_PATH:=src
@@ -114,7 +100,6 @@ define Build/InstallDev/map-plugin
$(INSTALL_DIR) $(1)/usr/lib/ieee1905 $(INSTALL_DIR) $(1)/usr/lib/ieee1905
$(CP) $(PKG_BUILD_DIR)/src/extensions/map/map2.h $(1)/usr/include/map2.h $(CP) $(PKG_BUILD_DIR)/src/extensions/map/map2.h $(1)/usr/include/map2.h
$(CP) $(PKG_BUILD_DIR)/src/extensions/map/map_module.h $(1)/usr/include/map_module.h $(CP) $(PKG_BUILD_DIR)/src/extensions/map/map_module.h $(1)/usr/include/map_module.h
$(CP) $(PKG_BUILD_DIR)/src/extensions/map/cntlrsync.h $(1)/usr/include/cntlrsync.h
$(CP) $(PKG_BUILD_DIR)/src/extensions/map/map.so $(1)/usr/lib/ieee1905/map.so $(CP) $(PKG_BUILD_DIR)/src/extensions/map/map.so $(1)/usr/lib/ieee1905/map.so
$(CP) $(PKG_BUILD_DIR)/src/extensions/map/libmaputil.so $(1)/usr/lib/libmaputil.so $(CP) $(PKG_BUILD_DIR)/src/extensions/map/libmaputil.so $(1)/usr/lib/libmaputil.so
endef endef
@@ -125,7 +110,6 @@ define Build/InstallDev/libieee1905
$(INSTALL_DIR) $(1)/usr/include $(INSTALL_DIR) $(1)/usr/include
$(INSTALL_DIR) $(1)/usr/lib/ieee1905 $(INSTALL_DIR) $(1)/usr/lib/ieee1905
$(CP) $(PKG_BUILD_DIR)/src/cmdu.h $(1)/usr/include/ $(CP) $(PKG_BUILD_DIR)/src/cmdu.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/src/cmdu_ackq.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/src/1905_tlvs.h $(1)/usr/include/ $(CP) $(PKG_BUILD_DIR)/src/1905_tlvs.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/src/i1905_wsc.h $(1)/usr/include/ $(CP) $(PKG_BUILD_DIR)/src/i1905_wsc.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/src/bufutil.h $(1)/usr/include/ $(CP) $(PKG_BUILD_DIR)/src/bufutil.h $(1)/usr/include/
@@ -139,11 +123,6 @@ define Build/InstallDev
$(call Build/InstallDev/map-plugin,$(1),$(2)) $(call Build/InstallDev/map-plugin,$(1),$(2))
endef endef
ifeq ($(LOCAL_DEV),1)
define Build/Prepare
rsync -r --exclude=.* ~/git/ieee1905/ $(PKG_BUILD_DIR)/
endef
endif
$(eval $(call BuildPackage,ieee1905)) $(eval $(call BuildPackage,ieee1905))
$(eval $(call BuildPackage,libieee1905)) $(eval $(call BuildPackage,libieee1905))

View File

@@ -5,82 +5,7 @@ STOP=21
USE_PROCD=1 USE_PROCD=1
IS_CFG_VALID=1
validate_ieee1905_section() {
uci_validate_section ieee1905 ieee1905 "ieee1905" \
'enabled:bool:true' \
'macaddress:or("auto",macaddr)' \
'registrar:string' \
'extension:bool:false' \
'extmodule:list(string)' \
[ "$?" -ne 0 ] && {
logger -s -t "ieee1905" "Validation of ieee1905 section failed"
IS_CFG_VALID=0
return 1
}
return 0
}
validate_ali_section() {
local section="$1"
uci_validate_section ieee1905 $section "${1}" \
'ifname:string' \
'type:or("bridge",string)'
[ "$?" -ne 0 ] && {
logger -s -t "ieee1905" "Validation of al-iface section $section failed"
IS_CFG_VALID=0
return 1
}
return 0
}
validate_ap_section() {
local section="$1"
uci_validate_section ieee1905 $section "${1}" \
'band:or("2", "5", "60")' \
'ssid:string' \
'encryption:or("psk2", "sae-mixed", "sae", string)' \
'key:string' \
'uuid:string' \
'manufacturer:string' \
'model_name:string' \
'device_name:string' \
'model_number:string' \
'serial_number:string' \
'device_type:string' \
'os_version:uinteger'
[ "$?" -ne 0 ] && {
logger -s -t "ieee1905" "Validation of ap section $section failed"
IS_CFG_VALID=0
return 1
}
return 0
}
validate_ieee1905_config() {
IS_CFG_VALID=1
validate_ieee1905_section &&
config_foreach validate_ali_section "al-iface" &&
config_foreach validate_ap_section ap
[ "$IS_CFG_VALID" -ne 1 ] && {
logger -s -t "ieee1905" "Validation of ieee1905 UCI file failed"
return 1
}
return 0
}
start_service() { start_service() {
config_load "ieee1905"
validate_ieee1905_config || return 1;
procd_open_instance procd_open_instance
procd_set_param command "/usr/sbin/ieee1905d" procd_set_param command "/usr/sbin/ieee1905d"
procd_set_param respawn procd_set_param respawn

View File

@@ -1,3 +1,4 @@
CONFIG_BUILD_NLS=y
CONFIG_BUSYBOX_CUSTOM=y CONFIG_BUSYBOX_CUSTOM=y
CONFIG_CCACHE=y CONFIG_CCACHE=y
CONFIG_DEBUG=y CONFIG_DEBUG=y
@@ -17,6 +18,7 @@ CONFIG_PACKAGE_ddns-scripts=y
CONFIG_PACKAGE_ds-lite=y CONFIG_PACKAGE_ds-lite=y
CONFIG_PACKAGE_ethtool=y CONFIG_PACKAGE_ethtool=y
CONFIG_PACKAGE_getopt=y CONFIG_PACKAGE_getopt=y
CONFIG_PACKAGE_glib2=y
CONFIG_PACKAGE_gre=y CONFIG_PACKAGE_gre=y
CONFIG_PACKAGE_icwmp=y CONFIG_PACKAGE_icwmp=y
CONFIG_PACKAGE_ieee1905=y CONFIG_PACKAGE_ieee1905=y
@@ -24,7 +26,6 @@ CONFIG_PACKAGE_map-topology=y
CONFIG_PACKAGE_mosquitto-client-ssl=y CONFIG_PACKAGE_mosquitto-client-ssl=y
CONFIG_PACKAGE_mosquitto-ssl=y CONFIG_PACKAGE_mosquitto-ssl=y
CONFIG_PACKAGE_wfadatad=y CONFIG_PACKAGE_wfadatad=y
CONFIG_PACKAGE_wfadatad-collector=y
CONFIG_PACKAGE_imonitor=m CONFIG_PACKAGE_imonitor=m
CONFIG_PACKAGE_inbd=y CONFIG_PACKAGE_inbd=y
CONFIG_PACKAGE_ip-full=y CONFIG_PACKAGE_ip-full=y
@@ -188,6 +189,8 @@ CONFIG_LIBCURL_CRYPTO_AUTH=y
CONFIG_LIBCURL_OPENSSL=y CONFIG_LIBCURL_OPENSSL=y
CONFIG_OPENVPN_openssl_ENABLE_IPROUTE2=y CONFIG_OPENVPN_openssl_ENABLE_IPROUTE2=y
# CONFIG_SIGNED_PACKAGES is not set # CONFIG_SIGNED_PACKAGES is not set
CONFIG_KERNEL_DEVTMPFS=y
CONFIG_KERNEL_DEVTMPFS_MOUNT=y
# CONFIG_BUSYBOX_CONFIG_IP is not set # CONFIG_BUSYBOX_CONFIG_IP is not set
CONFIG_LOCALMIRROR="https://download.iopsys.eu/iopsys/mirror/" CONFIG_LOCALMIRROR="https://download.iopsys.eu/iopsys/mirror/"

View File

@@ -13,9 +13,12 @@ function genconfig {
export DEVELOPER=0 export DEVELOPER=0
target="bogus" target="bogus"
target_config_path="" target_config_path=""
bcm27xx="target/linux/iopsys-bcm27xx"
brcm63xx_arm="target/linux/iopsys-brcm63xx-arm" brcm63xx_arm="target/linux/iopsys-brcm63xx-arm"
ramips="target/linux/iopsys-ramips" ramips="target/linux/iopsys-ramips"
mediatek="target/linux/iopsys-mediatek"
econet="target/linux/iopsys-econet" econet="target/linux/iopsys-econet"
intel_mips="target/linux/intel_mips"
x86="target/linux/iopsys-x86" x86="target/linux/iopsys-x86"
armvirt="target/linux/iopsys-armvirt" armvirt="target/linux/iopsys-armvirt"
@@ -111,15 +114,21 @@ function genconfig {
iopsys_brcm63xx_arm=$(cd $brcm63xx_arm; ./genconfig) iopsys_brcm63xx_arm=$(cd $brcm63xx_arm; ./genconfig)
[ -e $ramips/genconfig ] && [ -e $ramips/genconfig ] &&
iopsys_ramips=$(cd $ramips; ./genconfig) iopsys_ramips=$(cd $ramips; ./genconfig)
[ -e $mediatek/genconfig ] &&
iopsys_mediatek=$(cd $mediatek; ./genconfig)
[ -e $econet/genconfig ] && [ -e $econet/genconfig ] &&
iopsys_econet=$(cd $econet; ./genconfig) iopsys_econet=$(cd $econet; ./genconfig)
[ -e $intel_mips/genconfig ] &&
iopsys_intel_mips=$(cd $intel_mips; ./genconfig)
[ -e $x86/genconfig ] && [ -e $x86/genconfig ] &&
iopsys_x86=$(cd $x86; ./genconfig) iopsys_x86=$(cd $x86; ./genconfig)
[ -e $armvirt/genconfig ] && [ -e $armvirt/genconfig ] &&
iopsys_armvirt=$(cd $armvirt; ./genconfig) iopsys_armvirt=$(cd $armvirt; ./genconfig)
[ -e $bcm27xx/genconfig ] &&
iopsys_bcm27xx=$(cd $bcm27xx; ./genconfig)
if [ "$profile" == "LIST" ]; then if [ "$profile" == "LIST" ]; then
for list in iopsys_brcm63xx_arm iopsys_ramips iopsys_econet iopsys_x86 iopsys_armvirt; do for list in iopsys_brcm63xx_arm iopsys_ramips iopsys_mediatek iopsys_econet iopsys_intel_mips iopsys_x86 iopsys_armvirt iopsys_bcm27xx; do
echo "$list based boards:" echo "$list based boards:"
for b in ${!list}; do for b in ${!list}; do
echo -e "\t$b" echo -e "\t$b"
@@ -144,6 +153,14 @@ function genconfig {
fi fi
done done
for p in $iopsys_mediatek; do
if [ $p == $profile ]; then
target="iopsys_mediatek"
target_config_path="$mediatek/config"
return
fi
done
for p in $iopsys_econet; do for p in $iopsys_econet; do
if [ $p == $profile ]; then if [ $p == $profile ]; then
target="iopsys_econet" target="iopsys_econet"
@@ -152,6 +169,14 @@ function genconfig {
fi fi
done done
for p in $iopsys_intel_mips; do
if [ $p == $profile ]; then
target="intel_mips"
target_config_path="$intel_mips/config"
return
fi
done
for p in $iopsys_x86; do for p in $iopsys_x86; do
if [ $p == $profile ]; then if [ $p == $profile ]; then
target="iopsys_x86" target="iopsys_x86"
@@ -167,6 +192,15 @@ function genconfig {
return return
fi fi
done done
for p in $iopsys_bcm27xx; do
if [ $p == $profile ]; then
target="iopsys_bcm27xx"
target_config_path="$bcm27xx/config"
return
fi
done
} }
git remote -v | grep -qE '(git@|ssh://)' && { git remote -v | grep -qE '(git@|ssh://)' && {
@@ -318,16 +352,32 @@ function genconfig {
echo "" >> .config echo "" >> .config
fi fi
# Special handling for targets which use TARGET_DEVICES #special handling for intel_mips/iopsys_ramips which use TARGET_DEVICES
if [ "$target" = "iopsys_ramips" ]; then if [ "$target" = "intel_mips" ]; then
subtarget="xrx500"
echo "CONFIG_TARGET_${target}=y" >> .config
echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config
device=$(echo $BOARDTYPE | tr a-z A-Z)
echo "CONFIG_TARGET_DEVICE_${target}_${subtarget}_DEVICE_${device}=y" >> .config
elif [ "$target" = "iopsys_ramips" ]; then
subtarget="mt7621" subtarget="mt7621"
echo "CONFIG_TARGET_${target}=y" >> .config echo "CONFIG_TARGET_${target}=y" >> .config
echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config
echo "CONFIG_TARGET_DEVICE_${target}_${subtarget}_DEVICE_${BOARDTYPE}=y" >> .config echo "CONFIG_TARGET_DEVICE_${target}_${subtarget}_DEVICE_${BOARDTYPE}=y" >> .config
elif [ "$target" = "iopsys_mediatek" ]; then
subtarget="mt7622"
echo "CONFIG_TARGET_${target}=y" >> .config
echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config
echo "CONFIG_TARGET_${target}_${subtarget}_DEVICE_${BOARDTYPE}=y" >> .config
elif [ "$target" = "iopsys_econet" ]; then elif [ "$target" = "iopsys_econet" ]; then
subtarget="en7562" subtarget="en7562"
echo "CONFIG_TARGET_${target}=y" >> .config echo "CONFIG_TARGET_${target}=y" >> .config
echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config
elif [ "$target" = "iopsys_bcm27xx" ]; then
subtarget="iopsys_bcm2711"
echo "CONFIG_TARGET_${target}=y" >> .config
echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config
echo "CONFIG_TARGET_DEVICE_${target}_${subtarget}_DEVICE_${BOARDTYPE}=y" >> .config
else else
echo "CONFIG_TARGET_${target}=y" >> .config echo "CONFIG_TARGET_${target}=y" >> .config
echo "CONFIG_TARGET_${target}_${BOARDTYPE}=y" >> .config echo "CONFIG_TARGET_${target}_${BOARDTYPE}=y" >> .config

View File

@@ -12,9 +12,12 @@ function genconfig_min {
export DEVELOPER=0 export DEVELOPER=0
target="bogus" target="bogus"
target_config_path="" target_config_path=""
bcm27xx="target/linux/iopsys-bcm27xx"
brcm63xx_arm="target/linux/iopsys-brcm63xx-arm" brcm63xx_arm="target/linux/iopsys-brcm63xx-arm"
ramips="target/linux/iopsys-ramips" ramips="target/linux/iopsys-ramips"
mediatek="target/linux/iopsys-mediatek"
econet="target/linux/iopsys-econet" econet="target/linux/iopsys-econet"
intel_mips="target/linux/intel_mips"
x86="target/linux/iopsys-x86" x86="target/linux/iopsys-x86"
armvirt="target/linux/iopsys-armvirt" armvirt="target/linux/iopsys-armvirt"
@@ -110,15 +113,21 @@ function genconfig_min {
iopsys_brcm63xx_arm=$(cd $brcm63xx_arm; ./genconfig) iopsys_brcm63xx_arm=$(cd $brcm63xx_arm; ./genconfig)
[ -e $ramips/genconfig ] && [ -e $ramips/genconfig ] &&
iopsys_ramips=$(cd $ramips; ./genconfig) iopsys_ramips=$(cd $ramips; ./genconfig)
[ -e $mediatek/genconfig ] &&
iopsys_mediatek=$(cd $mediatek; ./genconfig)
[ -e $econet/genconfig ] && [ -e $econet/genconfig ] &&
iopsys_econet=$(cd $econet; ./genconfig) iopsys_econet=$(cd $econet; ./genconfig)
[ -e $intel_mips/genconfig ] &&
iopsys_intel_mips=$(cd $intel_mips; ./genconfig)
[ -e $x86/genconfig ] && [ -e $x86/genconfig ] &&
iopsys_x86=$(cd $x86; ./genconfig) iopsys_x86=$(cd $x86; ./genconfig)
[ -e $armvirt/genconfig ] && [ -e $armvirt/genconfig ] &&
iopsys_armvirt=$(cd $armvirt; ./genconfig) iopsys_armvirt=$(cd $armvirt; ./genconfig)
[ -e $bcm27xx/genconfig ] &&
iopsys_bcm27xx=$(cd $bcm27xx; ./genconfig)
if [ "$profile" == "LIST" ]; then if [ "$profile" == "LIST" ]; then
for list in iopsys_brcm63xx_arm iopsys_ramips iopsys_econet iopsys_x86 iopsys_armvirt; do for list in iopsys_brcm63xx_arm iopsys_ramips iopsys_mediatek iopsys_econet iopsys_intel_mips iopsys_x86 iopsys_armvirt iopsys_bcm27xx; do
echo "$list based boards:" echo "$list based boards:"
for b in ${!list}; do for b in ${!list}; do
echo -e "\t$b" echo -e "\t$b"
@@ -143,6 +152,14 @@ function genconfig_min {
fi fi
done done
for p in $iopsys_mediatek; do
if [ $p == $profile ]; then
target="iopsys_mediatek"
target_config_path="$mediatek/config"
return
fi
done
for p in $iopsys_econet; do for p in $iopsys_econet; do
if [ $p == $profile ]; then if [ $p == $profile ]; then
target="iopsys_econet" target="iopsys_econet"
@@ -151,6 +168,14 @@ function genconfig_min {
fi fi
done done
for p in $iopsys_intel_mips; do
if [ $p == $profile ]; then
target="intel_mips"
target_config_path="$intel_mips/config"
return
fi
done
for p in $iopsys_x86; do for p in $iopsys_x86; do
if [ $p == $profile ]; then if [ $p == $profile ]; then
target="iopsys_x86" target="iopsys_x86"
@@ -166,6 +191,15 @@ function genconfig_min {
return return
fi fi
done done
for p in $iopsys_bcm27xx; do
if [ $p == $profile ]; then
target="iopsys_bcm27xx"
target_config_path="$bcm27xx/config"
return
fi
done
} }
git remote -v | grep -qE '(git@|ssh://)' && { git remote -v | grep -qE '(git@|ssh://)' && {
@@ -309,16 +343,34 @@ function genconfig_min {
echo "" >> .config echo "" >> .config
fi fi
# Special handling for targets which use TARGET_DEVICES #special handling for intel_mips/iopsys_ramips which use TARGET_DEVICES
if [ "$target" = "iopsys_ramips" ]; then if [ "$target" = "intel_mips" ]; then
subtarget="xrx500"
echo "CONFIG_TARGET_${target}=y" >> .config
echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config
device=$(echo $BOARDTYPE | tr a-z A-Z)
echo "CONFIG_TARGET_DEVICE_${target}_${subtarget}_DEVICE_${device}=y" >> .config
elif [ "$target" = "iopsys_ramips" ]; then
subtarget="mt7621" subtarget="mt7621"
echo "CONFIG_TARGET_${target}=y" >> .config echo "CONFIG_TARGET_${target}=y" >> .config
echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config
echo "CONFIG_TARGET_DEVICE_${target}_${subtarget}_DEVICE_${BOARDTYPE}=y" >> .config echo "CONFIG_TARGET_DEVICE_${target}_${subtarget}_DEVICE_${BOARDTYPE}=y" >> .config
elif [ "$target" = "iopsys_mediatek" ]; then
subtarget="mt7622"
echo "CONFIG_TARGET_${target}=y" >> .config
echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config
echo "CONFIG_TARGET_${target}_${subtarget}_DEVICE_${BOARDTYPE}=y" >> .config
elif [ "$target" = "iopsys_econet" ]; then elif [ "$target" = "iopsys_econet" ]; then
subtarget="en7562" subtarget="en7562"
echo "CONFIG_TARGET_${target}=y" >> .config echo "CONFIG_TARGET_${target}=y" >> .config
echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config
elif [ "$target" = "iopsys_bcm27xx" ]; then
subtarget="iopsys_bcm2711"
echo "CONFIG_TARGET_${target}=y" >> .config
echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config
echo "CONFIG_TARGET_MULTI_PROFILE=y" >> .config
echo "CONFIG_TARGET_PER_DEVICE_ROOTFS=y" >> .config
echo "CONFIG_TARGET_DEVICE_${target}_${subtarget}_DEVICE_${BOARDTYPE}=y" >> .config
else else
echo "CONFIG_TARGET_${target}=y" >> .config echo "CONFIG_TARGET_${target}=y" >> .config
echo "CONFIG_TARGET_${target}_${BOARDTYPE}=y" >> .config echo "CONFIG_TARGET_${target}_${BOARDTYPE}=y" >> .config

View File

@@ -1,10 +0,0 @@
if (PACKAGE_map-agent)
menu "Configurations"
config AGENT_SYNC_DYNAMIC_CNTLR_CONFIG
bool "Support Dynamic Controller configuration sync"
default y if MULTIAP_DYNAMIC_CNTLR_SYNC_CONFIG
endmenu
endif

View File

@@ -5,21 +5,20 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=map-agent PKG_NAME:=map-agent
PKG_VERSION:=7.1.10 PKG_VERSION:=6.0.8
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=8d2fa1af3b0cbdb65f791b490e72c5925cccaa05 PKG_SOURCE_VERSION:=3f0bb9c156dd334df6927dc7e6d7fc2ebbc7d520
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu> PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu>
PKG_LICENSE:=PROPRIETARY IOPSYS PKG_LICENSE:=PROPRIETARY IOPSYS
PKG_LICENSE_FILES:=LICENSE PKG_LICENSE_FILES:=LICENSE
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/map-agent PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/map-agent
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip PKG_MIRROR_HASH:=skip
endif
PKG_BUILD_DEPENDS:=map-plugin
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
@@ -31,26 +30,12 @@ define Package/map-agent
+map-plugin +map-plugin
endef endef
define Package/dynbhd
SECTION:=utils
CATEGORY:=Utilities
TITLE:=Dynamic Backhaul Daemon
DEPENDS:=+libwifi +libuci +libubox +ubus +libeasy +libieee1905 +ieee1905 \
+map-plugin +map-agent
endef
define Package/map-agent/description define Package/map-agent/description
This package implements EasyMesh R2 compliant WiFi Agent. This package implements EasyMesh R2 compliant WiFi Agent.
endef endef
define Package/dynbhd/description
Dyanmic LAN/WAN port detection and loop avoidance.
endef
define Package/map-agent/config define Package/map-agent/config
source "$(SOURCE)/Config.in" #source "$(SOURCE)/Config.in"
endef endef
TARGET_CFLAGS += \ TARGET_CFLAGS += \
@@ -58,10 +43,6 @@ TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include/libnl3 \ -I$(STAGING_DIR)/usr/include/libnl3 \
-D_GNU_SOURCE -D_GNU_SOURCE
ifeq ($(CONFIG_AGENT_SYNC_DYNAMIC_CNTLR_CONFIG),y)
TARGET_CFLAGS += -DAGENT_SYNC_DYNAMIC_CNTLR_CONFIG
endif
MAKE_PATH:=src MAKE_PATH:=src
define Package/map-agent/install define Package/map-agent/install
@@ -72,21 +53,4 @@ define Package/map-agent/install
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/mapagent $(1)/usr/sbin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/mapagent $(1)/usr/sbin/
endef endef
define Package/dynbhd/install
$(INSTALL_DIR) $(1)/etc
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/lib/wifi/dynbhd
$(INSTALL_DIR) $(1)/etc/hotplug.d/ethernet
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/dynbh/dynbhd $(1)/usr/sbin/dynbhd
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/dynbh/api $(1)/lib/wifi/dynbhd/api
# $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/dynbh/map-dynamic-backhaul $(1)/etc/hotplug.d/ethernet/map-dynamic-backhaul
endef
ifeq ($(LOCAL_DEV),1)
define Build/Prepare
rsync -r --exclude=.* ~/git/map-agent/ $(PKG_BUILD_DIR)/
endef
endif
$(eval $(call BuildPackage,map-agent)) $(eval $(call BuildPackage,map-agent))
$(eval $(call BuildPackage,dynbhd))

View File

@@ -4,7 +4,7 @@ config agent 'agent'
option profile '2' option profile '2'
option al_bridge 'br-lan' option al_bridge 'br-lan'
#config ap #config fh-iface
# option ifname 'wl0' # option ifname 'wl0'
# option steer 'rssi bssload' # option steer 'rssi bssload'
# list exclude '00:11:22:33:44:55' # list exclude '00:11:22:33:44:55'
@@ -17,17 +17,15 @@ config agent 'agent'
# option steer_legacy_retry_secs '3600' # option steer_legacy_retry_secs '3600'
# option assoc_ctrl_secs '30' # option assoc_ctrl_secs '30'
# option band '2' # option band '2'
# option type 'fronthaul'
#config ap #config fh-iface
# option ifname 'wl1' # option ifname 'wl1'
# option steer 'rssi bssload' # option steer 'rssi bssload'
# list exclude '00:11:22:33:44:55' # list exclude '00:11:22:33:44:55'
# list exclude_btm '00:aa:bb:cc:dd:ee' # list exclude_btm '00:aa:bb:cc:dd:ee'
# option band '5' # option band '5'
# option type 'fronthaul'
#config bsta #config bk-iface
# option ifname 'apclii0' # option ifname 'apclii0'
# option enabled '1' # option enabled '1'
# option onboarded '0' # option onboarded '0'

View File

@@ -1,8 +1,6 @@
#!/bin/sh #!/bin/sh
wan=$(db -q get hw.board.ethernetWanPort) wan=$(db -q get hw.board.ethernetWanPort)
MAPFILE="/tmp/multiap.backhaul"
[ -z "$wan" ] && exit 1 # no configuration [ -z "$wan" ] && exit 1 # no configuration
[ "$PORT" != "$wan" ] && exit 0 [ "$PORT" != "$wan" ] && exit 0
@@ -34,16 +32,14 @@ update_bstas() {
} }
if [ "$LINK" = "up" ]; then if [ "$LINK" = "up" ]; then
#touch "$MAPFILE" touch /tmp/map.agent.bsta_global_disable
config_load "mapagent" config_load "mapagent"
bridge=$(uci get mapagent.agent.al_bridge | cut -d '-' -f2) bridge=$(uci get mapagent.agent.al_bridge | cut -d '-' -f2)
config_foreach remove_from_bridge bsta $bridge config_foreach remove_from_bridge bk-iface $bridge
config_foreach update_bstas bsta down config_foreach update_bstas bk-iface down
/lib/wifi/multiap set_uplink "eth" "$PORT"
else else
rm -f "$MAPFILE" rm -f /tmp/map.agent.bsta_global_disable
config_load "mapagent" config_load "mapagent"
config_foreach update_bstas bsta up config_foreach update_bstas bk-iface up
fi fi

View File

@@ -5,44 +5,32 @@ STOP=20
USE_PROCD=1 USE_PROCD=1
IS_CFG_VALID=1
MAP_DEV="map_dev" MAP_DEV="map_dev"
MAP_IF="map" MAP_IF="map"
MAP_VETH="lei"
create_map() { create_map() {
ip link add lei type veth peer name lei_map 2>/dev/null
ip link add link lei name lei_lan type vlan id 1 2>/dev/null
uci -q set network.${MAP_DEV}=device uci -q set network.${MAP_DEV}=device
uci -q set network.${MAP_DEV}.name=br-map uci -q set network.${MAP_DEV}.name=br-map
uci -q set network.${MAP_DEV}.type=bridge uci -q set network.${MAP_DEV}.type=bridge
uci -q set network.${MAP_DEV}.bridge_empty=1
uci -q show network.${MAP_DEV}.ports | grep -q lei_map || {
uci -q add_list network.${MAP_DEV}.ports='lei_map'
}
uci -q set network.${MAP_IF}=interface uci -q set network.${MAP_IF}=interface
uci -q set network.${MAP_IF}.device=br-map uci -q set network.${MAP_IF}.device=br-map
uci -q set network.${MAP_IF}.is_lan=1 uci -q set network.${MAP_IF}.is_lan=1
uci -q show network.br_lan.ports | grep -q lei_lan || {
uci -q add_list network.br_lan.ports="lei_lan"
}
uci -q set mapagent.agent.al_bridge=br-map uci -q set mapagent.agent.al_bridge=br-map
uci -q commit uci -q commit
ubus call network reload ubus call network reload
ubus -t 5 wait_for network.interface.map ubus -t 5 wait_for network.device
brctl addif br-map lei_map 2>/dev/null ip link add ${MAP_VETH} type veth peer name ${MAP_VETH}_lan 2>/dev/null
brctl addif br-lan lei_lan 2>/dev/null brctl addif br-map ${MAP_VETH} 2>/dev/null
brctl addif br-lan ${MAP_VETH}_lan 2>/dev/null
ip link set lei up 2>/dev/null ip link set ${MAP_VETH} up 2>/dev/null
ip link set lei_map up 2>/dev/null ip link set ${MAP_VETH}_lan up 2>/dev/null
ip link set lei_lan up 2>/dev/null
} }
remove_map() { remove_map() {
@@ -58,147 +46,8 @@ remove_map() {
ubus call network reload ubus call network reload
} }
start_dynbhd_service() {
rm -f /tmp/map.agent.bsta_global_disable
procd_open_instance
procd_set_param command "/usr/sbin/dynbhd"
procd_set_param respawn
# procd_set_param stdout 1
# procd_set_param stderr 1
procd_close_instance
}
validate_agent_section() {
uci_validate_section mapagent agent "agent" \
'enabled:bool:true' \
'debug:range(0,16)' \
'profile:range(1,2):2' \
'brcm_setup:bool:false' \
'controller_macaddr:macaddr' \
'al_bridge:string' \
'netdev:string' \
'vlan_segregation:bool:false' \
'resend_num:uinteger:0' \
'dyn_cntlr_sync:bool:true'
[ "$?" -ne 0 ] && {
logger -s -t "mapagent" "Validation of agent section failed"
IS_CFG_VALID=0
return 1
}
return 0
}
validate_cs_section() {
local section="$1"
uci_validate_section mapagent $section "${section}" \
'local:bool:false' \
'id:string' \
'probe_int:range(0,1000):20' \
'retry_int:range(0,255):3' \
'autostart:bool:false'
[ "$?" -ne 0 ] && {
logger -s -t "mapagent" "Validation of controller_select section failed"
IS_CFG_VALID=0
return 1
}
return 0
}
validate_ap_section() {
local section="$1"
uci_validate_section mapagent $section "${1}" \
'ifname:string' \
'device:string' \
'band:or("2", "5")' \
'enabled:bool:true' \
'onboarded:bool:false' \
'ssid:string' \
'key:string' \
'encryption:string' \
'disallow_bsta_p1:bool:false' \
'disallow_bsta_p2:bool:false'
[ "$?" -ne 0 ] && {
logger -s -t "mapagent" "Validation of ap section failed"
IS_CFG_VALID=0
return 1
}
return 0
}
validate_radio_section() {
local section="$1"
uci_validate_section mapagent $section "${1}" \
'device:string' \
'band:or("2", "5")' \
'configured:bool:false' \
'onboarded:bool:false' \
'dedicated_backhaul:bool:false' \
'steer_policy:range(0,255)' \
'util_threshold:range(0,255)' \
'rcpi_threshold:range(0,255)' \
'report_rcpi_threshold:range(0,255)' \
'include_sta_stats:bool:false' \
'include_sta_metric:bool:false' \
'rcpi_hysteresis_margin:range(0,255)' \
'report_util_threshold:range(0,255)'
[ "$?" -ne 0 ] && {
logger -s -t "mapagent" "Validation of radio section failed"
IS_CFG_VALID=0
return 1
}
return 0
}
validate_policy_section() {
local section="$1"
uci_validate_section mapagent $section "${1}" \
'report_interval:range(0,255)' \
'pvid:uinteger' \
'report_interval:range(0,255)' \
'pcp_default:range(0,255)' \
'report_scan:bool' \
'report_sta_assocfails:bool' \
'report_sta_assocfails_rate:uinteger' \
'steer_exclude:list(macaddr)' \
'steer_exclude_btm:list(macaddr)' \
[ "$?" -ne 0 ] && {
logger -s -t "mapagent" "Validation of policy section failed"
IS_CFG_VALID=0
return 1
}
return 0
}
validate_agent_config() {
IS_CFG_VALID=1
validate_agent_section &&
config_foreach validate_cs_section controller_select &&
config_foreach validate_ap_section ap &&
config_foreach validate_radio_section radio &&
config_foreach validate_policy_section policy
[ "$IS_CFG_VALID" -ne 1 ] && {
logger -s -t "mapagent" "Validation of mapagent UCI file failed"
return 1
}
return 0
}
start_service() { start_service() {
[ -f /usr/sbin/dynbhd ] && start_dynbhd_service
config_load "mapagent" config_load "mapagent"
validate_agent_config || return 1;
ubus -t 5 wait_for wifi ubus -t 5 wait_for wifi

View File

@@ -10,11 +10,7 @@
. /usr/share/libubox/jshn.sh . /usr/share/libubox/jshn.sh
. /lib/wifi/traffic_separation . /lib/wifi/traffic_separation
MAPFILE="/tmp/multiap.backhaul"
diff=0 diff=0
onbrd_bssid=0
onbrd_band=0
usage() { usage() {
cat <<EOF cat <<EOF
@@ -29,42 +25,12 @@ EOF
exit 1 exit 1
} }
type_to_multi_ap () {
type="$1"
if [ "$type" = "backhaul" ]; then
echo "1"
return
elif [ "$type" = "fronthaul" ]; then
echo "2"
return
elif [ "$type" = "combined" ]; then
echo "3"
return
fi
echo "0"
}
get_type_by_section() {
section="$1"
config_get type $section type "0"
echo "$(type_to_multi_ap $type)"
}
brcm_sync_credentials() { brcm_sync_credentials() {
bands="" bands=""
json_init
mapagent_process_fh() { mapagent_process_fh() {
local section=$1 local section=$1
local dev=$2 local dev=$2
multi_ap=$(get_type_by_section $section)
[ "$multi_ap" == "0" ] && return
config_get device $section device config_get device $section device
[ "$dev" != "$device" ] && return [ "$dev" != "$device" ] && return
@@ -81,17 +47,6 @@ brcm_sync_credentials() {
uci -q set ieee1905.${section}.ssid="$ssid" uci -q set ieee1905.${section}.ssid="$ssid"
uci -q set ieee1905.${section}.encryption=$encryption uci -q set ieee1905.${section}.encryption=$encryption
uci -q set ieee1905.${section}.key="$key" uci -q set ieee1905.${section}.key="$key"
json_select "$band" > /dev/null
if [ "$?" = "0" ]; then
json_get_keys keys
for key in ${keys};
do
json_get_var val "$key"
uci -q set ieee1905.${section}.$key="$val"
done
json_select ..
fi
} }
mapagent_process_radio() { mapagent_process_radio() {
@@ -109,43 +64,12 @@ brcm_sync_credentials() {
fi fi
done done
config_foreach mapagent_process_fh ap $device config_foreach mapagent_process_fh fh-iface $device
bands="$bands $band" bands="$bands $band"
} }
ieee1905_del_ap() { ieee1905_del_ap() {
append_value() {
local section=$1
local key=$2
shift
shift
while [ "$key" != "" ]; do
val=$(uci -q get ieee1905.$section.$key)
[ "$val" = "" ] && {
key=$1
shift
continue
}
json_add_string "$key" ${val}
key=$1
shift
done
}
local section=$1 local section=$1
local band
config_get band $section band
json_select "$band" > /dev/null
rc=$?
[ "$rc" != "0" ] && json_add_object "$band"
append_value $section "manufacturer" "model_name" "device_name" "model_number" "serial_number" "device_type" "os_version"
if [ "$rc" != "0" ]; then
json_close_object
else
json_select ..
fi
uci -q delete ieee1905.${section} uci -q delete ieee1905.${section}
} }
@@ -154,12 +78,12 @@ brcm_sync_credentials() {
config_foreach ieee1905_del_ap ap config_foreach ieee1905_del_ap ap
config_load mapagent config_load mapagent
config_foreach mapagent_process_radio radio config_foreach mapagent_process_radio wifi-radio
uci commit ieee1905 uci commit ieee1905
json_cleanup
} }
brcm_write_credentials() { brcm_write_credentials() {
config_load mapagent config_load mapagent
@@ -192,10 +116,8 @@ brcm_write_credentials() {
local bk_ssid="$3" local bk_ssid="$3"
local bk_key="$4" local bk_key="$4"
multi_ap=$(get_type_by_section $section)
[ "$multi_ap" == "0" ] && return
config_get device $section device config_get device $section device
config_get multi_ap $section multi_ap "0"
#echo found dev=$dev device=$device map=$multi_ap #echo found dev=$dev device=$device map=$multi_ap
@@ -214,10 +136,8 @@ brcm_write_credentials() {
local section=$1 local section=$1
local dev=$2 local dev=$2
multi_ap=$(get_type_by_section $section)
[ "$multi_ap" == "0" ] && return
config_get device $section device config_get device $section device
config_get multi_ap $section multi_ap "0"
config_get enabled $section enabled "1" config_get enabled $section enabled "1"
#echo found dev=$dev device=$device map=$multi_ap #echo found dev=$dev device=$device map=$multi_ap
@@ -231,7 +151,7 @@ brcm_write_credentials() {
#echo found ssid="$ssid" key="$key" #echo found ssid="$ssid" key="$key"
config_foreach mapagent_find_fbss ap $dev "$ssid" "$key" config_foreach mapagent_find_fbss fh-iface $dev "$ssid" "$key"
} }
mapagent_process_radio() { mapagent_process_radio() {
@@ -241,11 +161,11 @@ brcm_write_credentials() {
#echo found dev=$dev #echo found dev=$dev
config_foreach mapagent_find_bbss ap $device config_foreach mapagent_find_bbss fh-iface $device
} }
config_foreach mapagent_process_radio radio config_foreach mapagent_process_radio wifi-radio
uci commit wireless uci commit wireless
} }
@@ -280,7 +200,6 @@ write_bsta_config() {
#echo diff = $diff > /dev/console #echo diff = $diff > /dev/console
config_load mapagent config_load mapagent
mapagent_apply_wl_bsta() { mapagent_apply_wl_bsta() {
@@ -306,7 +225,6 @@ write_bsta_config() {
local section=$1 local section=$1
local bsta=$2 local bsta=$2
config_get ifname $section ifname config_get ifname $section ifname
#echo bsta = $bsta > /dev/console #echo bsta = $bsta > /dev/console
@@ -314,43 +232,15 @@ write_bsta_config() {
#echo found ifname=$ifname > /dev/console #echo found ifname=$ifname > /dev/console
config_get bssid $section bssid config_get bssid $section bssid
config_get band $section band
ret=$(mapagent_apply_wl_bsta $ifname $bssid) ret=$(mapagent_apply_wl_bsta $ifname $bssid)
[ "$ret" == "1" ] && { [ "$ret" == "1" ] && diff=1
diff=1
onbrd_bssid=$bssid
onbrd_band=$band
}
} }
mapagent_apply_bssid_same_band() {
apply_config() {
local section=$1
local bsta=$2
config_get ifname $section ifname config_foreach mapagent_process_bk bk-iface $ifname
[ "$bsta" == "$ifname" ] || return
uci -q set wireless.${section}.bssid=$bssid
}
config_get band $1 band
config_get onboarded $1 onboarded "0"
[ "$onbrd_band" != "$band" -o "$onboarded" = "1" ] && return
config_get ifname $1 ifname
config_load wireless
config_foreach apply_config wifi-iface $ifname $onbrd_bssid
uci commit wireless
}
config_foreach mapagent_process_bk bsta $ifname
#echo result diff = $diff > /dev/console #echo result diff = $diff > /dev/console
[ "$diff" == "1" ] && { [ "$diff" == "1" ] && {
config_foreach mapagent_apply_bssid_same_band bsta
ubus call uci commit '{"config":"wireless"}' ubus call uci commit '{"config":"wireless"}'
#echo reloading wireless > /dev/console #echo reloading wireless > /dev/console
} }
@@ -387,9 +277,6 @@ brcm_teardown_iface() {
local section=$1 local section=$1
local iface=$2 local iface=$2
multi_ap=$(get_type_by_section $section)
[ "$multi_ap" == "0" ] && return
config_get ifname $section ifname config_get ifname $section ifname
[ "$iface" != "$ifname" ] && return [ "$iface" != "$ifname" ] && return
@@ -404,7 +291,7 @@ brcm_teardown_iface() {
} }
config_foreach mapagent_teardown_bss ap $iface config_foreach mapagent_teardown_bss fh-iface $iface
uci commit wireless uci commit wireless
uci commit mapagent uci commit mapagent
@@ -429,7 +316,7 @@ brcm_bsta_to_wireless() {
local sec="" local sec=""
local prio="-1" local prio="-1"
config_foreach mapagent_process_bk bsta config_foreach mapagent_process_bk bk-iface
echo $sec echo $sec
} }
@@ -502,7 +389,7 @@ brcm_bsta_to_wireless() {
config_get enabled $1 enabled "0" config_get enabled $1 enabled "0"
if [ "$onboarded" = "0" ]; then if [ "$onboarded" = "0" ]; then
config_foreach mapagent_find_other_creds bsta $ifname $band $enabled config_foreach mapagent_find_other_creds bk-iface $ifname $band $enabled
else else
config_get ssid $1 ssid config_get ssid $1 ssid
config_get key $1 key config_get key $1 key
@@ -521,11 +408,11 @@ brcm_bsta_to_wireless() {
# sec="" # sec=""
# prio="" # prio=""
# #
# config_foreach mapagent_enable_best bsta $best # config_foreach mapagent_enable_best bk-iface $best
# uci commit mapagent # uci commit mapagent
config_load mapagent config_load mapagent
diff=$(config_foreach mapagent_bsta_to_wireless bsta) diff=$(config_foreach mapagent_bsta_to_wireless bk-iface)
# [ "$diff" != "" ] && { # [ "$diff" != "" ] && {
ubus call uci commit '{"config":"wireless"}' ubus call uci commit '{"config":"wireless"}'
@@ -637,7 +524,7 @@ bsta_scan_on_enabled() {
wpa_cli -i "$ifname" save_config > /dev/null 2>&1 wpa_cli -i "$ifname" save_config > /dev/null 2>&1
} }
config_foreach mapagent_enable_bk bsta config_foreach mapagent_enable_bk bk-iface
} }
bsta_enable_all() { bsta_enable_all() {
@@ -648,7 +535,7 @@ bsta_enable_all() {
config_load mapagent config_load mapagent
config_foreach mapagent_enable_bk bsta config_foreach mapagent_enable_bk bk-iface
uci commit mapagent uci commit mapagent
bsta_scan_on_enabled bsta_scan_on_enabled
} }
@@ -707,10 +594,10 @@ bsta_disable_lower_priority() {
local bsta=$1 local bsta=$1
prio=$(config_foreach mapagent_get_priority bsta $bsta) prio=$(config_foreach mapagent_get_priority bk-iface $bsta)
#echo bsta $bsta has prio $prio > /dev/console #echo bsta $bsta has prio $prio > /dev/console
config_foreach mapagent_disable_lower_bk bsta $bsta $prio config_foreach mapagent_disable_lower_bk bk-iface $bsta $prio
uci commit mapagent uci commit mapagent
# ubus call uci commit '{"config":"wireless"}' # ubus call uci commit '{"config":"wireless"}'
@@ -735,7 +622,7 @@ bsta_use_link() {
local bsta=$1 local bsta=$1
config_foreach mapagent_disable_bk bsta $bsta config_foreach mapagent_disable_bk bk-iface $bsta
} }
bsta_swap_to_link() { bsta_swap_to_link() {
@@ -747,35 +634,6 @@ bsta_swap_to_link() {
wpa_cli -i "$1" save_config > /dev/null wpa_cli -i "$1" save_config > /dev/null
} }
set_uplink_backhaul_info() {
local ul_1905id=$1
local ul_mac=$2
json_load "$(cat $MAPFILE)"
json_add_string "backhaul_device_id" "$ul_1905id"
json_add_string "backhaul_macddr" "$ul_mac"
json_dump > "$MAPFILE"
json_cleanup
}
set_uplink() {
local type=$1
local ifname=$2
local hwaddr
hwaddr="$(ifconfig $ifname | grep -i hwaddr | awk '{print $5}' | awk '{print tolower($0)}')"
json_init
json_add_string "type" "$type"
json_add_string "ifname" "$ifname"
json_add_string "macaddr" "$hwaddr"
json_dump > "$MAPFILE"
json_cleanup
}
unset_uplink() {
rm "$MAPFILE" > /dev/null 2>&1
}
func=$1 func=$1
shift shift
@@ -798,9 +656,6 @@ case "$func" in
bsta_scan_on_enabled) bsta_scan_on_enabled $@;; bsta_scan_on_enabled) bsta_scan_on_enabled $@;;
bsta_use_link) bsta_use_link $@;; bsta_use_link) bsta_use_link $@;;
bsta_swap_to_link) bsta_swap_to_link $@;; bsta_swap_to_link) bsta_swap_to_link $@;;
set_uplink) set_uplink $@;;
set_uplink_backhaul_info) set_uplink_backhaul_info $@;;
unset_uplink) unset_uplink $@;;
--help|help) usage;; --help|help) usage;;
*) usage; exit 1;; *) usage; exit 1;;
esac esac

View File

@@ -4,15 +4,11 @@
### Traffic Separation ### ### Traffic Separation ###
dbg() {
logger -t traffic_separation $@
}
ts_sub() { ts_sub() {
ts_usage() { ts_usage() {
cat <<EOF cat <<EOF
Usage: $0 [create|delete|populate|primary|reload] Usage: $0 [create|delete|populate]
Traffic Separation related functions. Traffic Separation related functions.
create fh <iface> <vid> - create vlan device and rules for wifi fronthaul create fh <iface> <vid> - create vlan device and rules for wifi fronthaul
create bh <iface> <vid> <profile> - create vlan device and rules for wifi backhaul create bh <iface> <vid> <profile> - create vlan device and rules for wifi backhaul
@@ -20,7 +16,7 @@ create eth <iface> <vid> <pbits> - create vlan device and rules for logical ethe
delete <iface> - delete vlan device delete <iface> - delete vlan device
populate eth <iface> <vid> - add secondary network rules for logical ethernet interface populate eth <iface> <vid> - add secondary network rules for logical ethernet interface
primary get <iface> - read primary VID for interface from driver (from Association Response frame IE) primary get <iface> - read primary VID for interface from driver (from Association Response frame IE)
reload - reload network with new configuration
EOF EOF
exit 1 exit 1
} }
@@ -30,102 +26,54 @@ EOF
echo $bridge echo $bridge
} }
set_wireless_bridge() {
config_load wireless
_set_network() {
local sec=$1
local iface=$2
local bridge=$3
config_get ifname $sec ifname
[ "$iface" != "$ifname" ] && continue
config_get mode $sec mode
config_get multi_ap $sec multi_ap "0"
[ "$mode" = "sta" -a "$multi_ap" = "1" ] && continue
config_get network $sec network
local new_network=${bridge##br-}
if [ "$new_network" != "$network" ] ; then
uci -q set wireless.${sec}.network=${new_network}
uci commit wireless
fi
brctl addif $bridge $iface &> /dev/null
}
config_foreach _set_network wifi-iface ${1} ${2}
}
ts_create() { ts_create() {
_create_vlan_dev() { _create_vlan_dev() {
iface=$1 # real iface iface=$1 # real iface
vid=$2 # Vlan ID vid=$2 # Vlan ID
bridge=$3 # bridge iface should be connected bridge="$(_get_bridge $iface)" # bridge iface is connected to
vlan_dev=$4 vlan_dev=${iface}_vlan${vid} # name of vlan device to create
old_bridge="$(_get_bridge $iface)" # bridge iface is connected to
# remove interface from bridge if it is in one # remove interface from bridge if it is in one
[ -n "$old_bridge" ] && brctl delif $old_bridge $iface &> /dev/null [ -n "$bridge" ] && brctl delif $bridge $iface &> /dev/null
# (re)create vlan device # create vlan device
ip link show $vlan_dev && vlanctl --if-delete $vlan_dev
vlanctl --mcast --if-create-name $iface $vlan_dev --if $iface --set-if-mode-rg vlanctl --mcast --if-create-name $iface $vlan_dev --if $iface --set-if-mode-rg
vlanctl --if $iface --tx --tags 0 --default-miss-drop
vlanctl --if $iface --tx --tags 1 --default-miss-drop
vlanctl --if $iface --tx --tags 2 --default-miss-drop
vlanctl --if $iface --rx --tags 0 --default-miss-drop
vlanctl --if $iface --rx --tags 1 --default-miss-drop
vlanctl --if $iface --rx --tags 2 --default-miss-drop
# bring the vlan device up and add back to bridge if it was in one # bring the vlan device up and add back to bridge if it was in one
brctl addif $bridge $vlan_dev &> /dev/null [ -n "$bridge" ] && brctl addif $bridge $vlan_dev &> /dev/null
ip link set dev $vlan_dev up
echo $vlan_dev
} }
ts_create_fh() { ts_create_fh() {
iface=$1 # fh iface iface=$1 # fh iface
vid=$2 # SSID specific (secondary) or primary vid vid=$2 # SSID specific (secondary) or primary vid
bridge=$3
[ -n "$iface" ] && [ -n "$vid" ] && [ -n "$bridge" ] || { [ -n "$iface" ] && [ -n "$vid" ] || {
cat <<EOF cat <<EOF
Adding FH device requires IFACE, VID and bridge Adding FH device requires IFACE and VID.
EOF EOF
exit 1 exit 1
} }
# create vlan device # create vlan device
#set_wireless_bridge $iface $bridge vlan_dev=$(_create_vlan_dev $iface $vid)
vlan_dev=${iface}_vlan${vid}
ip link set $vlan_dev down
_create_vlan_dev $iface $vid $bridge $vlan_dev
# add rules # add rules
# Note: removing these for now since these packets are read directly from the iface anyway
# vlanctl --if $iface --rx --tags 0 --filter-ethertype 0x888e --set-rxif $vlan_dev --rule-append # incoming EAPOL
# vlanctl --if $iface --rx --tags 0 --filter-ethertype 0x886c --set-rxif $vlan_dev --rule-append # incoming brcm # vlanctl --if $iface --rx --tags 0 --filter-ethertype 0x886c --set-rxif $vlan_dev --rule-append # incoming brcm
# EAPOL frames
vlanctl --if $iface --rx --tags 0 --filter-ethertype 34958 --set-rxif $vlan_dev --rule-append
vlanctl --if $iface --rx --tags 1 --filter-ethertype 34958 --pop-tag --set-rxif $vlan_dev --rule-append
vlanctl --if $iface --tx --tags 0 --filter-txif $vlan_dev --filter-ethertype 34958 --rule-append
# 8021q vlan id TAG/UNTAG
vlanctl --if $iface --rx --tags 0 --set-rxif $vlan_dev --push-tag --set-vid $vid 0 --rule-append vlanctl --if $iface --rx --tags 0 --set-rxif $vlan_dev --push-tag --set-vid $vid 0 --rule-append
vlanctl --if $iface --tx --tags 1 --filter-txif $vlan_dev --filter-vid $vid 0 --pop-tag --dscp2pbits 0 --rule-append vlanctl --if $iface --tx --tags 1 --filter-txif $vlan_dev --filter-vid $vid 0 --pop-tag --dscp2pbits 0 --rule-append
ip link set $iface up
ip link set $vlan_dev up
} }
# Note: Currently not used (will be needed for Profile 1)
ts_create_bh() { ts_create_bh() {
iface=$1 # bh iface iface=$1 # bh iface
vid=$2 # primary vid vid=$2 # primary vid
profile=$3 # agent profile (1 or 2) profile=$3 # agent profile (1 or 2)
bridge=$4 # bridge interface should be connected to
[ -n "$iface" ] && [ -n "$vid" ] && [ -n "$profile" ] || { [ -n "$iface" ] && [ -n "$vid" ] && [ -n "$profile" ] || {
cat <<EOF cat <<EOF
@@ -134,13 +82,40 @@ EOF
exit 1 exit 1
} }
#[ -n "$bridge" ] && set_wireless_bridge $iface $bridge # create vlan device
vlan_dev=$(_create_vlan_dev $iface $vid)
old_vid=$(wl -i $1 map_8021q_settings) # add rules
old_vid=${old_vid##* } case "$profile" in
old_profile=$(wl -i $1 map_profile | cut -d ' ' -f 3) 1 | profile_1 | profile1 | Profile_1 | Profile1)
vlanctl --if $iface --rx --tags 0 --set-rxif $vlan_dev --push-tag --set-vid $vid 0 --rule-append
vlanctl --if $iface --tx --tags 1 --filter-txif $vlan_dev --pop-tag --rule-append
;;
2 | profile_2 | profile2 | Profile_2 | Profile2)
vlanctl --if $iface --rx --tags 1 --set-rxif $vlan_dev --rule-append
vlanctl --if $iface --tx --tags 1 --filter-txif $vlan_dev --rule-append # note: already default
vlanctl --if $iface --tx --tags 0 --filter-ethertype 0x893a --filter-txif $vlan_dev --push-tag --set-vid $vid 0 --rule-append # note: outgoing IEEE1905.1
vlanctl --if $iface --tx --tags 0 --filter-ethertype 0x888e --filter-txif $vlan_dev --push-tag --set-vid $vid 0 --rule-append # note: outgoing EAPOL
;;
*)
ts_delete $iface
ts_usage
exit 1
;;
esac
}
[ "$old_vid" = "$vid" -a "$old_profile" = "$profile" ] && return ts_create_bh_drv() {
iface=$1 # bh iface
vid=$2 # primary vid
profile=$3 # agent profile (1 or 2)
[ -n "$iface" ] && [ -n "$vid" ] && [ -n "$profile" ] || {
cat <<EOF
Adding BH device requires IFACE, VID and PROFILE (1 or 2).
EOF
exit 1
}
wl vlan_mode 0 &> /dev/null # make sure this is OFF, else driver won't handle vlan wl vlan_mode 0 &> /dev/null # make sure this is OFF, else driver won't handle vlan
wl -i $iface down &> /dev/null wl -i $iface down &> /dev/null
@@ -149,118 +124,53 @@ EOF
wl -i $iface up &> /dev/null wl -i $iface up &> /dev/null
} }
ts_create_lei() { ts_create_eth() {
vid=$1 # primary vid
pbits=$2 # default pbits to apply
vlan_bridge=$3 # name of ts subsystem bridge
lan_bridge=$4 # name of node local bridge
[ -n "$vid" ] && [ -n "$pbits" ] && [ -n "$vlan_bridge" ] && [ -n "$lan_bridge" ] || { _ts_setup() {
cat <<EOF vlan_bridge=$1
Adding ETH device requires IFACE, VID, PBITS and name of vlan and lan bridges. lan_bridge=$2
EOF vlan_dev=$3
exit 1 lan_dev=${vlan_dev}_lan
ip link show $vlan_dev &> /dev/null || ip link add $vlan_dev type veth peer name $lan_dev
brctl addif $vlan_bridge $vlan_dev &> /dev/null
brctl addif $lan_bridge $lan_dev &> /dev/null
ip link set $vlan_dev up
ip link set $lan_dev up
} }
ip link show lei &> /dev/null || {
ip link add link lei name lei_lan type vlan id 1 2>/dev/null
}
old_vid=$(ip -d link show lei_lan | sed -n 's/vlan.*id \([0-9][0-9]*\) .*/\1/p')
[ "$old_vid" != "$vid" ] && {
ip link del lei_lan
ip link add link lei name lei_lan type vlan id ${vid}
}
brctl addif ${lan_bridge} lei_lan &>/dev/null
brctl addif ${vlan_bridge} lei_map &>/dev/null
ip link set lei up
ip link set lei_map up
ip link set lei_lan up
}
_create_eth() {
iface=$1 # Multi-AP Logical Ethernet Interface iface=$1 # Multi-AP Logical Ethernet Interface
vid=$2 # primary vid vid=$2 # primary vid
bridge=$3 # name of ts subsystem bridge pbits=$3 # default pbits to apply
pbits=0 vlan_bridge=$4 # name of ts subsystem bridge
lan_bridge=$5 # name of node local bridge
[ -n "$iface" ] && [ -n "$vid" ] && [ -n "$bridge" ] || { [ -n "$iface" ] && [ -n "$vid" ] && [ -n "$pbits" ] && [ -n "$vlan_bridge" ] && [ -n "$lan_bridge" ] || {
cat <<EOF cat <<EOF
Adding ETH device requires IFACE, VID, PBITS and name of vlan and lan bridges. Adding ETH device requires IFACE, VID, PBITS and name of vlan and lan bridges.
EOF EOF
exit 1 exit 1
} }
dbg create $@ # create virtual eth device between bridges (if it doesn't exist))
_ts_setup $vlan_bridge $lan_bridge $iface
ip link set $iface down # create vlan device
vlan_dev=$(_create_vlan_dev $iface $vid)
vlan_dev=${iface}_vlan${vid} # TODO: how to disable returning traffic back to incoming interface?
ip link set $vlan_dev down
_create_vlan_dev $iface $vid $bridge $vlan_dev
# add rules
vlanctl --if $iface --rx --tags 0 --set-rxif $vlan_dev --push-tag --set-vid $vid 0 --set-pbits $pbits 0 --rule-append vlanctl --if $iface --rx --tags 0 --set-rxif $vlan_dev --push-tag --set-vid $vid 0 --set-pbits $pbits 0 --rule-append
vlanctl --if $iface --tx --tags 1 --filter-vid $vid 0 --filter-txif $vlan_dev --pop-tag --rule-append vlanctl --if $iface --tx --tags 1 --filter-vid $vid 0 --filter-txif $vlan_dev --pop-tag --rule-append
[ $# -le 3 ] && exit 0
shift 3
while [ -n "$1" ] ; do
vid=$1
vlanctl --if $iface --rx --tags 1 --filter-vid $vid 0 --set-rxif $vlan_dev --rule-append
vlanctl --if $iface --tx --tags 1 --filter-vid $vid 0 --filter-txif $vlan_dev --rule-append
shift
done
ip link set $iface up
ip link set $vlan_dev up
}
ts_create_eths() {
pvid=$1 # primary vid
bridge=$2 # name of ts subsystem bridge
shift 2
# TODO use ieee1905 bridge
for iface in $(uci get network.br_lan.ports) ; do
[ "$iface" = "lei_lan" ] && continue
_create_eth $iface $pvid $bridge $@
ubus call ieee1905 del_interface "{\"ifname\":\"$iface\"}"
done
} }
ts_create_dhcp() { ts_create_dhcp() {
local diff=""
_net_setup() {
local name=$1
local devname=$2
local vid=$3
[ -z "$(uci -q get network.${name})" ] && {
uci -q set network.${name}="interface"
uci -q set network.${name}.device="$devname"
uci -q set network.${name}.is_lan="1"
uci -q set network.${name}.proto="static"
# TODO vid > 255
local ip_addr="192.168.${vid}.1"
[ "${vid}" = "1" ] && ip_addr="192.168.${vid}.2"
uci -q set network.${name}.ipaddr="${ip_addr}"
uci -q set network.${name}.netmask="255.255.255.0"
diff="1"
}
[ "$diff" = "1" ] && uci -q commit network
}
_br_setup() { _br_setup() {
local name=$1 local name=$1
local sinkname=$2 local sinkname=$2
local vid=$3 local vid=$3
local diff=""
[ -z "$(uci -q get network.${name}_dev)" ] && { [ -z "$(uci -q get network.${name}_dev)" ] && {
uci -q set network.${name}_dev="device" uci -q set network.${name}_dev="device"
@@ -283,7 +193,11 @@ EOF
diff="1" diff="1"
} }
[ "$diff" = "1" ] && uci -q commit network [ "$diff" = "1" ] && {
uci -q commit network
ubus call network reload
ubus -t 5 wait_for network.device
}
} }
_dhcp_setup() { _dhcp_setup() {
@@ -303,44 +217,43 @@ EOF
uci -q add_list dhcp.${name}.ra_flags="managed-config" uci -q add_list dhcp.${name}.ra_flags="managed-config"
uci -q add_list dhcp.${name}.ra_flags="other-config" uci -q add_list dhcp.${name}.ra_flags="other-config"
diff="1"
uci -q commit dhcp uci -q commit dhcp
ubus call uci commit '{"config":"dhcp"}'
} }
_firewall_setup() { _wan_setup() {
local name=$1 local name=$1
local network=$2
local zone_exist=0
config_load firewall config_load firewall
_process_zone() { _process_zone() {
local section=$1 local section=$1
local new_name=$2 local sink=$2
local name local name
local exists=false
config_get name $section name config_get name $section name
[ "$name" == "$new_name" ] && zone_exist=1 [ "$name" == "lan" ] || return
_process_list() {
local value=$1
[ "$value" == "$sink" ] && exists=true && return 1
}
config_list_foreach "$section" network _process_list
[ $exists = false ] && {
uci -q add_list firewall.${section}.network="${sink}"
uci -q commit firewall
ubus call uci commit '{"config":"firewall"}'
}
return 1
} }
config_foreach _process_zone zone $name config_foreach _process_zone zone $name
[ "$zone_exist" != "0" ] && return
uci -q add firewall zone
uci -q set firewall.@zone[-1].name="$name"
uci -q add_list firewall.@zone[-1].network="$network"
uci -q set firewall.@zone[-1].input='ACCEPT'
uci -q set firewall.@zone[-1].output='ACCEPT'
uci -q set firewall.@zone[-1].forward='ACCEPT'
uci -q add firewall forwarding
uci -q set firewall.@forwarding[-1].src="$name"
uci -q set firewall.@forwarding[-1].dest="wan"
diff="1"
uci -q commit firewall
} }
vid=$1 # primary vid vid=$1 # primary vid
@@ -352,26 +265,20 @@ EOF
exit 1 exit 1
} }
ip link show sink${vid} || { br_dev=sink_vlan${vid} # name of vlan device to create
ip link add sink${vid} type veth peer name sink${vid}_vlan
ip link add link sink${vid} name sink${vid}_peer type vlan id ${vid}
}
ip link set sink${vid} up
ip link set sink${vid}_peer up
ip link set sink${vid}_vlan up
diff="" ip l a sink1_vlan${vid} type veth peer name sink2_vlan${vid}
_net_setup sink${vid} sink${vid}_peer ${vid} vlanctl --mcast --if-create-name sink2_vlan${vid} sink3_vlan${vid} --if sink2_vlan${vid} --set-if-mode-rg
_dhcp_setup sink${vid} vlanctl --if sink2_vlan${vid} --rx --tags 1 --filter-vid ${vid} 0 --set-rxif sink3_vlan${vid} --pop-tag --rule-append
_firewall_setup lan${vid} sink${vid} vlanctl --if sink2_vlan${vid} --tx --tags 0 --filter-txif sink3_vlan${vid} --push-tag --set-vid ${vid} 0 --rule-append
ip l s sink1_vlan${vid} up
ip l s sink2_vlan${vid} up
ip l s sink3_vlan${vid} up
[ "$diff" = "1" ] && { _br_setup $br_dev sink3_vlan${vid} $vid
ubus call network reload _dhcp_setup $br_dev
ubus -t 5 wait_for network.interface.sink${vid} _wan_setup $br_dev
}
brctl addif br-map sink${vid}_vlan &> /dev/null
} }
local type=$1 local type=$1
@@ -379,9 +286,9 @@ EOF
case "$type" in case "$type" in
fh) ts_create_fh $@;; fh) ts_create_fh $@;;
bh) ts_create_bh $@;; # bh) ts_create_bh $@;;
lei) ts_create_lei $@;; bh) ts_create_bh_drv $@;;
eths) ts_create_eths $@;; eth) ts_create_eth $@;;
dhcp) ts_create_dhcp $@;; dhcp) ts_create_dhcp $@;;
--help|help) ts_usage;; --help|help) ts_usage;;
*) ts_usage; exit 1;; *) ts_usage; exit 1;;
@@ -393,15 +300,12 @@ EOF
path=$(ls -d /sys/class/net/${iface}/upper_*) path=$(ls -d /sys/class/net/${iface}/upper_*)
[ -z "$path" ] && exit 0 [ -z "$path" ] && exit 0
vlan_dev=${path##*upper_} vlan_dev=${path##*upper_}
bridge="$(_get_bridge $vlan_dev)" bridge="$(_get_bridge $vlan_dev)"
[ -n "$bridge" ] && { vlanctl --if-delete $vlan_dev # note: also removes rules and removes from bridge
vlanctl --if-delete $vlan_dev # note: also removes rules and removes from bridge
brctl addif $bridge $iface &> /dev/null # needed to add again
}
brctl addif $bridge $iface &> /dev/null
} }
ts_populate() { ts_populate() {
@@ -423,8 +327,8 @@ EOF
vlan_dev=${path##*upper_} vlan_dev=${path##*upper_}
# add rules # add rules
#vlanctl --if $iface --rx --tags 1 --filter-vid $vid 0 --set-rxif $vlan_dev --rule-append # note: retain secondary vids vlanctl --if $iface --rx --tags 1 --filter-vid $vid 0 --set-rxif $vlan_dev --rule-append # note: retain secondary vids
#vlanctl --if $iface --tx --tags 1 --filter-vid $vid 0 --filter-txif $vlan_dev --rule-append # note: already default vlanctl --if $iface --tx --tags 1 --filter-vid $vid 0 --filter-txif $vlan_dev --rule-append # note: already default
} }
ts_primary() { ts_primary() {
@@ -461,50 +365,16 @@ EOF
ebtables -t broute -I BROUTING -i "$iface" -d 01:80:C2:00:00:13 -p 0x893a -j DROP ebtables -t broute -I BROUTING -i "$iface" -d 01:80:C2:00:00:13 -p 0x893a -j DROP
} }
ts_reload() {
local dhcp_reload=$1
# workaround for missing backhaul wifi.ap.* ubus obj's:
# iterate in config and setup bh
config_load wireless
_setup_bh_iface() {
local sec=$1
local iface=$2
local bridge=$3
config_get ifname $sec ifname
config_get mode $sec mode
config_get multi_ap $sec multi_ap "0"
[ "$mode" = "ap" -a "$multi_ap" = "1" ] && {
ts_create bh $ifname 1 2 br-map
}
}
config_foreach _setup_bh_iface wifi-iface
[ -n "dhcp_reload" ] && /etc/init.d/dnsmasq reload
# another workaround for netif? removed
# sink devices for br-map bridge
for sink in $(ubus list network.interface.sink*) ; do
local sink_vlan=${sink/network.interface./}_vlan
brctl addif br-map $sink_vlan &> /dev/null
done
}
local func=$1 local func=$1
shift shift
case "$func" in case "$func" in
create) dbg "create $@"; ts_create $@;; create) ts_create $@;;
delete) dbg "delete $@"; ts_delete $@;; delete) ts_delete $@;;
populate) dbg "populate $@"; ts_populate $@;; populate) ts_populate $@;;
primary) dbg "primary $@"; ts_primary $@;; primary) ts_primary $@;;
unicast) dbg "unicast $@"; ts_unicast $@;; unicast) ts_unicast $@;;
multicast) dbg "multicast $@"; ts_multicast $@;; multicast) ts_multicast $@;;
reload) dbg "reload $@"; ts_reload $@;;
--help|help) ts_usage;; --help|help) ts_usage;;
*) ts_usage; exit 1;; *) ts_usage; exit 1;;
esac esac

View File

@@ -1,10 +0,0 @@
if (PACKAGE_map-controller)
menu "Configurations"
config CONTROLLER_SYNC_DYNAMIC_CNTLR_CONFIG
bool "Support Dynamic Controller configuration sync"
default y if MULTIAP_DYNAMIC_CNTLR_SYNC_CONFIG
endmenu
endif

View File

@@ -5,20 +5,20 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=map-controller PKG_NAME:=map-controller
PKG_VERSION:=6.0.5 PKG_VERSION:=5.0.3
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=3562b7f774e6dffda2e58ad2acb382fc439273fb PKG_SOURCE_VERSION:=40fbe4dfd9634bf06e0cab1cb2fc6a811487b5b4
PKG_LICENSE:=PROPRIETARY IOPSYS PKG_LICENSE:=PROPRIETARY IOPSYS
PKG_LICENSE_FILES:=LICENSE PKG_LICENSE_FILES:=LICENSE
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/map-controller PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/map-controller
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip PKG_MIRROR_HASH:=skip
endif
PKG_BUILD_DEPENDS:=map-plugin
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
@@ -34,7 +34,7 @@ define Package/map-controller/description
endef endef
define Package/map-controller/config define Package/map-controller/config
source "$(SOURCE)/Config.in" #source "$(SOURCE)/Config.in"
endef endef
TARGET_CFLAGS += \ TARGET_CFLAGS += \
@@ -44,10 +44,6 @@ TARGET_CFLAGS += \
MAKE_PATH:=src MAKE_PATH:=src
ifeq ($(CONFIG_CONTROLLER_SYNC_DYNAMIC_CNTLR_CONFIG),y)
TARGET_CFLAGS += -DCONTROLLER_SYNC_DYNAMIC_CNTLR_CONFIG
endif
define Package/map-controller/install define Package/map-controller/install
$(INSTALL_DIR) $(1)/etc $(INSTALL_DIR) $(1)/etc
$(CP) ./files/* $(1)/ $(CP) ./files/* $(1)/
@@ -55,10 +51,4 @@ define Package/map-controller/install
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/mapcontroller $(1)/usr/sbin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/mapcontroller $(1)/usr/sbin/
endef endef
ifeq ($(LOCAL_DEV),1)
define Build/Prepare
rsync -r --exclude=.* ~/git/map-controller/ $(PKG_BUILD_DIR)/
endef
endif
$(eval $(call BuildPackage,map-controller)) $(eval $(call BuildPackage,map-controller))

View File

@@ -5,8 +5,6 @@ STOP=20
USE_PROCD=1 USE_PROCD=1
IS_CFG_VALID=1
handle_controller_select() { handle_controller_select() {
local section="$1" local section="$1"
@@ -14,122 +12,10 @@ handle_controller_select() {
return 1 return 1
} }
validate_controller_section() {
uci_validate_section mapcontroller controller "controller" \
'enabled:bool:true' \
'registrar:string' \
'debug:range(0,16)' \
'resend_num:uinteger:0' \
'enable_sta_steer:bool:false' \
'enable_bsta_steer:bool:false' \
'use_bcn_metrics:bool:false' \
'use_usta_metrics:bool:false'
[ "$?" -ne 0 ] && {
logger -s -t "mapcontroller" "Validation of controller section failed"
IS_CFG_VALID=0
return 1
}
return 0
}
validate_ap_section() {
local section="$1"
uci_validate_section mapcontroller $section "${1}" \
'band:or("2", "5")' \
'ssid:string' \
'encryption:or("sae", "sae+aes", "psk2",
"psk2+aes", "sae-mixed", "sae-mixed+aes")' \
'key:string' \
'vid:range(1,65535):1' \
'type:or("backhaul", "fronthaul", "combined")' \
'disallow_bsta:list(range(0,255)):0' \
'enabled:bool:true'
[ "$?" -ne 0 ] && {
logger -s -t "mapcontroller" "Validation of ap section $section failed"
IS_CFG_VALID=0
return 1
}
return 0
}
validate_node_section() {
local section="$1"
uci_validate_section mapcontroller $section "${1}" \
'agent_id:macaddr' \
'backhaul_ul_macaddr:macaddr' \
'backhaul_dl_macaddr:macaddr' \
'backhaul_type:or("none")' \
'primary_vid:range(0,255):1' \
'primary_pcp:range(0,255):0' \
'report_sta_assocfails:bool:false' \
'report_sta_assocfails_rate:uinteger' \
'report_metric_periodic:range(0,255)' \
'report_scan:bool:false' \
'steer_exclude:list(macaddr)' \
'steer_exclude_btm:list(macaddr)' \
'steer_disallow:bool:false' \
'coordinated_cac:bool:false' \
'traffic_separation:bool:false' \
'sta_steer:bool:false'
[ "$?" -ne 0 ] && {
logger -s -t "mapcontroller" "Validation of node section $section failed"
IS_CFG_VALID=0
return 1
}
return 0
}
validate_radio_section() {
local section="$1"
uci_validate_section mapcontroller $section "${1}" \
'agent_id:macaddr' \
'macaddr:macaddr' \
'band:or("2", "5")' \
'steer_policy:range(0,2)' \
'util_threshold:range(0,255)' \
'rcpi_threshold:range(0,255)' \
'report_rcpi_threshold:range(0,255)' \
'report_util_threshold:range(0,255)' \
'report_rcpi_hysteresis_margin:range(0,255)' \
'include_sta_stats:bool:false' \
'include_sta_metric:bool:false'
[ "$?" -ne 0 ] && {
logger -s -t "mapcontroller" "Validation of radio section $section failed"
IS_CFG_VALID=0
return 1
}
return 0
}
validate_controller_config() {
IS_CFG_VALID=1
validate_controller_section &&
config_foreach validate_ap_section ap &&
config_foreach validate_node_section node &&
config_foreach validate_radio_section radio
[ "$IS_CFG_VALID" -ne 1 ] && {
logger -s -t "mapcontroller" "Validation of mapcontroller UCI file failed"
return 1
}
return 0
}
start_service() { start_service() {
local enabled local enabled
config_load "mapcontroller" config_load "mapcontroller"
validate_controller_config || return 1;
config_get_bool enabled controller enabled 1 config_get_bool enabled controller enabled 1
[ "$enabled" -eq 0 ] && return [ "$enabled" -eq 0 ] && return

View File

@@ -6,11 +6,11 @@ include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=map-topology PKG_NAME:=map-topology
PKG_VERSION:=3.2.5 PKG_VERSION:=3.0.2
LOCAL_DEV:=0 LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1) ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_VERSION:=ddf78cca217ebfa83733a532bdd2d17b6c3af54e PKG_SOURCE_VERSION:=4f4932e294afa68ca65fd23c469c0a1f3737d825
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/map-topology.git PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/map-topology.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz
@@ -30,9 +30,7 @@ define Package/map-topology
endef endef
TARGET_CFLAGS += \ TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include \ -I$(STAGING_DIR)/usr/include
-I$(STAGING_DIR)/usr/include/libnl3 \
-D_GNU_SOURCE
define Package/map-topology/description define Package/map-topology/description
Constructs network topology and show it as json structure over UBUS Constructs network topology and show it as json structure over UBUS

View File

@@ -5,72 +5,7 @@ STOP=21
USE_PROCD=1 USE_PROCD=1
IS_CFG_VALID=1
validate_topology_config() {
uci_validate_section topology topology "topology" \
'enabled:bool:true' \
'depth:range(0,16)' \
'interval:range(0,65535)' \
'maxlog:range(0,128)' \
[ "$?" -ne 0 ] && {
logger -s -t "topology" "Validation of topology UCI file failed"
return 1
}
return 0
}
validate_global_section() {
uci_validate_section hosts global "global" \
'ageing_timer:uinteger' \
'reboot_persistent:bool'
[ "$?" -ne 0 ] && {
logger -s -t "hosts" "Validation of global section failed"
IS_CFG_VALID=0
return 1
}
return 0
}
validate_host_section() {
local section="$1"
uci_validate_section hosts $section "${1}" \
'macaddr:macaddr' \
'interface_type:or("wifi","eth")' \
'active:bool' \
'active_last_change:string'
[ "$?" -ne 0 ] && {
logger -s -t "hosts" "Validation of host section $section failed"
IS_CFG_VALID=0
return 1
}
return 0
}
validate_hosts_config() {
IS_CFG_VALID=1
validate_global_section &&
config_foreach validate_host_section host
[ "$IS_CFG_VALID" -ne 1 ] && {
logger -s -t "topology" "Validation of hosts UCI file failed"
return 1
}
return 0
}
start_service() { start_service() {
config_load "topology"
validate_topology_config || return 1;
config_load "hosts"
validate_hosts_config || return 1;
procd_open_instance procd_open_instance
procd_set_param command "/usr/sbin/topologyd" procd_set_param command "/usr/sbin/topologyd"
procd_set_param respawn procd_set_param respawn

View File

@@ -59,6 +59,9 @@ mld_p_up_interfaces=""
mld_p_down_interfaces="" mld_p_down_interfaces=""
mld_p_exceptions="" mld_p_exceptions=""
# Standard parameters need by BCM's multicast daemon
allow_brdevice=0
proxdevs="" proxdevs=""
ethwan="$(db -q get hw.board.ethernetWanPort)" ethwan="$(db -q get hw.board.ethernetWanPort)"
@@ -167,36 +170,6 @@ config_mcast_querier_params() {
echo "${protocol}-last-member-query-interval $last_mem_q_int" >> $CONFFILE echo "${protocol}-last-member-query-interval $last_mem_q_int" >> $CONFFILE
} }
config_snooping_upstream_interface() {
local snooping_upstream_intf=""
json_load "$(devstatus $1)"
logger -t "mcastconf" "$(devstatus $1)"
itr=1
json_select bridge-members
# loop over the bridge and find the device on wan port
while json_get_var dev $itr; do
case "$dev" in
*.*)
port="$(echo "$dev" | cut -d'.' -f 1)"
if [ $port == $ethwan ]; then
ifconfig $dev | grep RUNNING >/dev/null && $snooping_upstream_intf="$dev" && break
fi
;;
esac
itr=$(($itr + 1))
done
json_select ..
# if none of the bridge members are on wan port, set the wan port itself
if [ -n "$snooping_upstream_intf" ]; then
echo "upstream-interface $snooping_upstream_intf" >>$CONFFILE
else
echo "upstream-interface $ethwan" >>$CONFFILE
fi
}
config_snooping_on_bridge() { config_snooping_on_bridge() {
local protocol="$1" local protocol="$1"
local bcm_mcast_p=1 local bcm_mcast_p=1
@@ -214,6 +187,39 @@ config_snooping_on_bridge() {
done done
} }
handle_bridged_proxy_interface() {
local p2="$1"
local p_enable=0
if [ "$p2" == "igmp" ]; then
p_enable=$igmp_p_enable
else
p_enable=$mld_p_enable
fi
if [ $p_enable -eq 1 -a $allow_brdevice -eq 1 ]
then
proxdevs="$proxdevs $2"
echo "upstream-interface $2" >>$CONFFILE
else
json_load "$(devstatus $2)"
itr=1
json_select bridge-members
while json_get_var dev $itr; do
case "$dev" in
*.*)
port="$(echo "$dev" | cut -d'.' -f 1)"
if [ $port == $ethwan ]; then
ifconfig $dev | grep RUNNING >/dev/null && proxdevs="$proxdevs $dev" && break
fi
;;
esac
itr=$(($itr + 1))
done
json_select ..
fi
}
config_mcast_proxy_interface() { config_mcast_proxy_interface() {
local itr local itr
local p1="$1" local p1="$1"
@@ -228,8 +234,7 @@ config_mcast_proxy_interface() {
for proxif in $2; do for proxif in $2; do
case "$proxif" in case "$proxif" in
br-*) br-*)
proxdevs="$proxdevs $proxif" handle_bridged_proxy_interface $p1 $proxif
echo "upstream-interface $proxif" >>$CONFFILE
;; ;;
*) *)
ifconfig $proxif | grep RUNNING >/dev/null && proxdevs="$proxdevs $proxif" ifconfig $proxif | grep RUNNING >/dev/null && proxdevs="$proxdevs $proxif"
@@ -241,12 +246,7 @@ config_mcast_proxy_interface() {
echo "${p1}-proxy-interfaces $proxdevs" >> $CONFFILE echo "${p1}-proxy-interfaces $proxdevs" >> $CONFFILE
fi fi
# if proxdevs is empty set the wan port as mcast-interface [ -n "$proxdevs" ] && echo "${p1}-mcast-interfaces $proxdevs" >> $CONFFILE
if [ -n "$proxdevs" ]; then
echo "${p1}-mcast-interfaces $proxdevs" >> $CONFFILE
else
echo "${p1}-mcast-interfaces $ethwan" >> $CONFFILE
fi
} }
configure_mcpd_snooping() { configure_mcpd_snooping() {
@@ -259,14 +259,14 @@ configure_mcpd_snooping() {
if [ "$protocol" == "igmp" ]; then if [ "$protocol" == "igmp" ]; then
config_snooping_common_params $protocol $igmp_s_version $igmp_s_robustness $igmp_s_mode config_snooping_common_params $protocol $igmp_s_version $igmp_s_robustness $igmp_s_mode
config_mcast_querier_params $protocol $igmp_s_query_interval $igmp_s_q_resp_interval $igmp_s_last_mem_q_int config_mcast_querier_params $protocol $igmp_s_query_interval $igmp_s_q_resp_interval $igmp_s_last_mem_q_int
config_snooping_upstream_interface "$igmp_s_iface" config_mcast_proxy_interface $protocol "$igmp_s_iface"
config_snooping_on_bridge $protocol $igmp_s_iface $igmp_s_mode config_snooping_on_bridge $protocol $igmp_s_iface $igmp_s_mode
exceptions=$igmp_s_exceptions exceptions=$igmp_s_exceptions
fast_leave=$igmp_s_fast_leave fast_leave=$igmp_s_fast_leave
elif [ "$protocol" == "mld" ]; then elif [ "$protocol" == "mld" ]; then
config_snooping_common_params $protocol $mld_s_version $mld_s_robustness $mld_s_mode config_snooping_common_params $protocol $mld_s_version $mld_s_robustness $mld_s_mode
config_mcast_querier_params $protocol $mld_s_query_interval $mld_s_q_resp_interval $mld_s_last_mem_q_int config_mcast_querier_params $protocol $mld_s_query_interval $mld_s_q_resp_interval $mld_s_last_mem_q_int
config_snooping_upstream_interface "$mld_s_iface" config_mcast_proxy_interface $protocol "$mld_s_iface"
config_snooping_on_bridge $protocol $mld_s_iface $mld_s_mode config_snooping_on_bridge $protocol $mld_s_iface $mld_s_mode
exceptions=$mld_s_exceptions exceptions=$mld_s_exceptions
fast_leave=$mld_s_fast_leave fast_leave=$mld_s_fast_leave
@@ -458,7 +458,7 @@ read_mcast_stats() {
case $line in case $line in
br-*) br-*)
found_ip=0 found_ip=0
grp_ip="$(echo $line | awk -F ' ' '{ print $10 }')" grp_ip="$(echo $line | awk -F ' ' '{ print $9 }')"
if [ -z "$mcast_addrs" ]; then if [ -z "$mcast_addrs" ]; then
mcast_addrs="$grp_ip" mcast_addrs="$grp_ip"
continue continue
@@ -510,7 +510,7 @@ read_mcast_stats() {
if [ "$snoop_iface" != "$intf" ]; then if [ "$snoop_iface" != "$intf" ]; then
continue continue
fi fi
grp_ip="$(echo $line | awk -F ' ' '{ print $10 }')" grp_ip="$(echo $line | awk -F ' ' '{ print $9 }')"
if [ "$grp_ip" != "$gip_addr" ]; then if [ "$grp_ip" != "$gip_addr" ]; then
continue continue
fi fi
@@ -523,12 +523,12 @@ read_mcast_stats() {
fi fi
json_add_object "" json_add_object ""
host_ip="$(echo $line | awk -F ' ' '{ print $14 }')" host_ip="$(echo $line | awk -F ' ' '{ print $13 }')"
h_ip="$(ipcalc.sh $host_ip | grep IP | awk '{print substr($0,4)}')" h_ip="$(ipcalc.sh $host_ip | grep IP | awk '{print substr($0,4)}')"
json_add_string "ipaddr" "$h_ip" json_add_string "ipaddr" "$h_ip"
src_port="$(echo $line | awk -F ' ' '{ print $2 }')" src_port="$(echo $line | awk -F ' ' '{ print $2 }')"
json_add_string "device" "$src_port" json_add_string "device" "$src_port"
timeout="$(echo $line | awk -F ' ' '{ print $15 }')" timeout="$(echo $line | awk -F ' ' '{ print $14 }')"
json_add_int "timeout" "$timeout" json_add_int "timeout" "$timeout"
json_close_object #close the associated device object json_close_object #close the associated device object
;; ;;

View File

@@ -8,26 +8,35 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=netmode PKG_NAME:=netmode
PKG_VERSION:=0.3.0 PKG_VERSION:=0.2.0
PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) PKG_SOURCE_VERSION:=5c8abbdf86e4651c7c6f14f784cfb52e69979f96
PKG_LICENSE:=GPL-2.0-only PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/netmoded
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_LICENSE:=GPLv2
PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
define Package/netmode define Package/netmode
CATEGORY:=Utilities CATEGORY:=Base system
TITLE:=Network Modes and Utils DEPENDS:=+fping +ubus +libubox +libuci
TITLE:=Predefined Network Modes
endef endef
define Package/netmode/description define Package/netmode/description
Network Modes and Utils Predefined Network Modes
endef
define Build/Compile
endef endef
define Package/netmode/install define Package/netmode/install
$(CP) ./files/* $(1)/ $(CP) ./files/* $(1)/
$(INSTALL_DIR) $(1)/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/netmoded $(1)/sbin/
endef endef
$(eval $(call BuildPackage,netmode)) $(eval $(call BuildPackage,netmode))

View File

@@ -1,10 +1,8 @@
config netmode global config netmoded 'netmoded'
option enabled 0 option enabled '0'
config setup 'setup'
option enabled '0'
option dir '/etc/netmodes'
# option mode 'router' # option mode 'router'
#config testnet testnet
# option enabled 1
# option destination '8.8.8.8'
#config shiftrange shiftrange
# option enabled 1

View File

@@ -1,16 +1,16 @@
#!/bin/sh #!/bin/sh
# do not start testnet if the feature is explicitly disabled
[ "$(uci -q get netmode.testnet.enabled)" = "0" ] && exit 0
[ "$ACTION" == "ifup" -o "$ACTION" == "ifdown" ] || exit 0 [ "$ACTION" == "ifup" -o "$ACTION" == "ifdown" ] || exit 0
interface_check() { interface_check() {
[ "$(uci -q get network.$INTERFACE.is_lan)" = "1" ] && exit 0 local islan="$(uci -q get network.$INTERFACE.is_lan)"
[ "$islan" == "1" ] && exit 0
[ "$(uci -q get network.$INTERFACE.proto)" = "none" ] && exit 0 local proto="$(uci -q get network.$INTERFACE.proto)"
[ "$proto" == "none" ] && exit 0
[ "$(uci -q get network.$INTERFACE.defaultroute)" = "0" ] && exit 0 local defroute="$(uci -q get network.$INTERFACE.defaultroute)"
[ "$defroute" == "0" ] && exit 0
} }
interface_check interface_check
@@ -19,3 +19,4 @@ if [ -n "$(pgrep -f testnet)" ]; then
else else
testnet & testnet &
fi fi

View File

@@ -2,9 +2,6 @@
# this scripts shifts the lan network prefixes # this scripts shifts the lan network prefixes
# if a wan interface has the same network prefix. # if a wan interface has the same network prefix.
# do not shift range if the feature is explicitly disabled
[ "$(uci -q get netmode.shiftrange.enabled)" == "0" ] && exit 0
. /lib/functions.sh . /lib/functions.sh
. /lib/functions/network.sh . /lib/functions/network.sh

View File

@@ -3,71 +3,44 @@
START=10 START=10
USE_PROCD=1 USE_PROCD=1
NETMODED="/sbin/netmoded"
. /lib/functions.sh . /lib/functions.sh
. /lib/functions/netmode.sh
MODEDIR="/etc/netmodes" start_netmoded() {
config_load netmode
libnetmode_exec() { config_get enabled netmoded enabled 0
when="$1" if [ "$enabled" != "1" ]; then
# Execute /lib/netmode scripts return
if [ -d /lib/netmode/$when ]; then
logger -s -p user.info -t "netmode" "Executing /lib/netmode/$when scripts"
for script in $(ls /lib/netmode/$when/); do
sh /lib/netmode/$when/$script
done
fi fi
procd_open_instance
procd_set_param command $NETMODED
procd_append_param command --verbose warning -i macaddr
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param respawn
procd_close_instance
} }
start_service() { start_service() {
[ -f /etc/config/netmode ] || return populate_netmodes
config_load netmode start_netmoded
}
config_get_bool enabled global enabled '0' reload_service() {
[ $enabled -eq 0 ] && return switch_netmode
# Get the desired netmode from config start_netmoded
config_get mode global mode
# Check if netmode is set as boot environment parameter
[ -n "$mode" ] || mode="$(fw_printenv -n netmode 2>/dev/null)"
# Return if mode is not set
[ -n "$mode" ] || return
# Get the last saved mode
lastmode="$(cat /etc/netmodes/.last_mode 2>/dev/null)"
# Return if desired mode is same as last saved mode
[ "$mode" == "$lastmode" ] && return
# Save mode as last mode
echo "$mode" > /etc/netmodes/.last_mode
logger -s -p user.info -t "netmode" "Switching to $mode Mode" >/dev/console
# Execute netmode generic pre-mode-switch scripts
libnetmode_exec "pre"
# Copy netmode UCI config files
if [ -d $MODEDIR/$mode/uci ]; then
logger -s -p user.info -t "netmode" "Copying $MODEDIR/$mode/uci/* to /etc/config/"
cp $MODEDIR/$mode/uci/* /etc/config/ 2>/dev/null
fi
# Execute netmode generic scripts
libnetmode_exec
# Execute mode specific scripts
if [ -d $MODEDIR/$mode/scripts ]; then
logger -s -p user.info -t "netmode" "Executing $MODEDIR/$mode/scripts/* scripts"
for script in $(ls $MODEDIR/$mode/scripts/); do
sh $MODEDIR/$mode/scripts/$script
done
fi
# Execute netmode generic post-mode-switch scripts
libnetmode_exec "post"
} }
service_triggers() service_triggers()
{ {
procd_add_reload_trigger netmode procd_add_reload_trigger netmode
} }

View File

@@ -0,0 +1,9 @@
{
"description": [
{ "en" : "Bridge Mode" }
],
"explanation": [
{ "en" : "NAT is disabled." }
],
"reboot" : 0
}

View File

@@ -0,0 +1,92 @@
#!/bin/sh
. /usr/share/libubox/jshn.sh
. /lib/functions.sh
BRIDGEPORTS=""
get_vlan() {
local device="$1"
for section in $(uci show network | grep "=device" | cut -d '=' -f1); do
if [ "$(uci -q get $section.ifname)" == "$device" ]; then
uci -q get $section.name
break
fi
done
}
add_wifi_devs()
{
add_wdev()
{
local cfg=$1
# local disabled
# config_get_bool disabled $cfg disabled 0
# config_get_bool ifname $cfg ifname
# if [ $disabled -eq 0 -a -n "$ifname" ]; then
# BRIDGEPORTS="$ifname"
# fi
uci -q set wireless.$cfg.network="wan"
}
config_load wireless
config_foreach add_wdev "wifi-iface"
uci -q commit wireless
}
add_xtm_devs() {
local section device vlan
for section in $(uci show dsl | grep "=.*tm-device" | cut -d'=' -f1); do
if [ -n "$(uci -q get $section.device)" ]; then
vlan="$(get_vlan $device)"
[ -n "$vlan" ] && device="$vlan"
if [ -n "$device" ]; then
BRIDGEPORTS="$BRIDGEPORTS $device"
fi
fi
done
}
add_eth_ports() {
add_port()
{
local cfg=$1
local ifname vlan
config_get ifname $cfg ifname
vlan="$(get_vlan $ifname)"
[ -n "$vlan" ] && ifname="$vlan"
if [ -n "$ifname" ]; then
BRIDGEPORTS="$BRIDGEPORTS $ifname"
fi
}
config_load ports
config_foreach add_port "ethport"
}
add_xtm_devs
add_eth_ports
add_wifi_devs
BRIDGEPORTS="$(echo $BRIDGEPORTS | sed -e 's/[[:space:]]*$//')"
uci -q set network.wan.type="bridge"
uci -q set network.wan.ifname="$BRIDGEPORTS"
uci -q set network.wan6.ifname="@wan"
uci -q delete network.lan.ifname
ubus call uci commit '{"config":"network"}'

View File

@@ -0,0 +1,9 @@
{
"description": [
{ "en" : "Router Mode" }
],
"explanation": [
{ "en" : "NAT is enabled." }
],
"reboot" : 0
}

View File

@@ -0,0 +1,94 @@
#!/bin/sh
. /usr/share/libubox/jshn.sh
. /lib/functions.sh
WANPORTS=""
LANPORTS=""
get_vlan() {
local device="$1"
for section in $(uci show network | grep "=device" | cut -d '=' -f1); do
if [ "$(uci -q get $section.ifname)" == "$device" ]; then
uci -q get $section.name
break
fi
done
}
add_wifi_devs()
{
add_wdev()
{
local cfg=$1
config_get mode $cfg mode "ap"
if [ "$mode" == "ap" ]; then
uci -q set wireless.$cfg.network="lan"
fi
}
config_load wireless
config_foreach add_wdev "wifi-iface"
uci -q commit wireless
}
add_xtm_devs() {
local section device vlan
for section in $(uci show dsl | grep "=.*tm-device" | cut -d'=' -f1); do
device="$(uci -q get $section.device)"
if [ -n "$device" ]; then
vlan="$(get_vlan $device)"
[ -n "$vlan" ] && device="$vlan"
if [ -n "$device" ]; then
WANPORTS="$WANPORTS $device"
fi
fi
done
}
add_eth_ports() {
add_port()
{
local cfg=$1
local uplink ifname vlan
config_get ifname $cfg ifname
config_get_bool uplink $cfg uplink 0
vlan="$(get_vlan $ifname)"
[ -n "$vlan" ] && ifname="$vlan"
if [ $uplink -eq 1 ]; then
WANPORTS="$WANPORTS $ifname"
else
LANPORTS="$LANPORTS $ifname"
fi
}
config_load ports
config_foreach add_port "ethport"
}
add_xtm_devs
add_eth_ports
add_wifi_devs
WANPORTS="$(echo $WANPORTS | sed -e 's/[[:space:]]*$//')"
LANPORTS="$(echo $LANPORTS | sed -e 's/[[:space:]]*$//')"
uci -q set network.wan.type="anywan"
uci -q set network.wan.ifname="$WANPORTS"
uci -q set network.wan6.ifname="@wan"
uci -q set network.lan.type="bridge"
uci -q set network.lan.ifname="$LANPORTS"
ubus call uci commit '{"config":"network"}'

View File

@@ -0,0 +1,13 @@
#!/bin/sh
. /lib/functions.sh
add_owsd_ubusproxy_object_netmode() {
local netmd=$(uci -q get owsd.ubusproxy.object | grep netmode)
if [ -z "$netmd" ]; then
uci -q add_list owsd.ubusproxy.object="netmode"
uci commit owsd
fi
}
add_owsd_ubusproxy_object_netmode

View File

@@ -0,0 +1,150 @@
#!/bin/sh
. /lib/functions.sh
. /usr/share/libubox/jshn.sh
MODEDIR=$(uci -q get netmode.setup.dir)
[ -n "$MODEDIR" ] || MODEDIR="/etc/netmodes"
run_netmode_scripts() {
local mode=$1
local when=$2
local script
local path
path=$(readlink -f /etc/netmodes/$mode/)
[ "${path:0:14}" == "/etc/netmodes/" ] || exit
if [ -d /etc/netmodes/$mode/scripts/$when ]; then
logger -s -p user.info -t "netmode" "Executing $when netmode scripts" >/dev/console
for script in $(ls /etc/netmodes/$mode/scripts/$when/); do
sh /etc/netmodes/$mode/scripts/$when/$script
done
fi
}
switch_netmode() {
[ -f /etc/config/netmode -a -d $MODEDIR ] || return
config_load netmode
local enabled
config_get_bool enabled setup enabled '0'
[ $enabled -eq 0 ] && return
local mode
config_get mode setup mode
[ -d "/etc/netmodes/$mode" ] || return
logger -s -p user.info -t "netmode" "Switching to $mode Mode" >/dev/console
run_netmode_scripts $mode "pre"
local reboot=$(uci -q get netmode.$mode.reboot)
if [ "$reboot" == "1" ]; then
#run_netmode_scripts $mode "post"
reboot &
exit
fi
#run_netmode_scripts $mode "post"
}
populate_netmodes() {
[ -f /etc/config/netmode -a -d $MODEDIR ] || return
config_load netmode
local enabled
config_get_bool enabled setup enabled '0'
[ $enabled -eq 0 ] && return
delete_netmode() {
uci delete netmode.$1
}
config_foreach delete_netmode netmode
uci commit netmode
local hardware=$(db -q get hw.board.model_name)
local keys lang desc exp exclude support
for mode in $(ls $MODEDIR); do
lang=""
desc=""
exp=""
uci -q set netmode.$mode=netmode
json_load "$(cat $MODEDIR/$mode/DETAILS)"
if json_select excluded_boards; then
exclude=0
_i=1
while json_get_var board $_i; do
case "$hardware" in
$board)
uci -q delete netmode.$mode
exclude=1
break
;;
esac
_i=$((_i+1))
done
json_select ..
[ $exclude -eq 1 ] && continue
elif json_select supported_boards; then
support=0
_i=1
while json_get_var board $_i; do
case "$hardware" in
$board)
support=1
break
;;
esac
_i=$((_i+1))
done
json_select ..
[ $support -eq 1 ] || {
uci -q delete netmode.$mode
continue
}
fi
json_select description
json_get_keys keys
for k in $keys; do
json_get_keys lang $k
lang=$(echo $lang | sed 's/^[ \t]*//;s/[ \t]*$//')
json_select $k
json_get_var desc $lang
uci -q set netmode.$mode."desc_$lang"="$desc"
[ "$lang" == "en" ] && uci -q set netmode.$mode."desc"="$desc"
json_select ..
done
json_select ..
json_select explanation
json_get_keys keys
for k in $keys; do
json_get_keys lang $k
lang=$(echo $lang | sed 's/^[ \t]*//;s/[ \t]*$//')
json_select $k
json_get_var exp $lang
uci -q set netmode.$mode."exp_$lang"="$exp"
[ "$lang" == "en" ] && uci -q set netmode.$mode."exp"="$exp"
json_select ..
done
json_select ..
json_get_var cred credentials
uci -q set netmode.$mode.askcred="$cred"
json_get_var ulb uplink_band
uci -q set netmode.$mode.uplink_band="$ulb"
json_get_var reboot reboot
uci -q set netmode.$mode.reboot="$reboot"
done
uci commit netmode
}

View File

@@ -31,10 +31,7 @@ test_connection() {
internet_test() { internet_test() {
local link dest local link dest
# use the destination address given in config for connectivity check dest="$(uci -q get diagnostics.@connectivity[0].destination)"
dest="$(uci -q get netmode.testnet.destination)"
# for backwards compatibility
[ -n "$dest" ] || dest="$(uci -q get diagnostics.@connectivity[0].destination)"
test_connection $dest test_connection $dest

View File

@@ -5,12 +5,12 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=obuspa PKG_NAME:=obuspa
PKG_VERSION:=4.1.0.18 PKG_VERSION:=4.1.0.9
LOCAL_DEV:=0 LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1) ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=af3d4663d66942e3b0e3253375c5620629769aa5 PKG_SOURCE_VERSION:=a52205791ef71cb54fa468064075ff85c7f5a638
PKG_SOURCE_URL:=https://dev.iopsys.eu/fork/obuspa.git PKG_SOURCE_URL:=https://dev.iopsys.eu/fork/obuspa.git
PKG_MAINTAINER:=Vivek Dutta <vivek.dutta@iopsys.eu> PKG_MAINTAINER:=Vivek Dutta <vivek.dutta@iopsys.eu>
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
@@ -81,11 +81,13 @@ define Package/obuspa/install
$(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/config $(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/obuspa $(INSTALL_DIR) $(1)/etc/obuspa
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
$(INSTALL_BIN) $(PKG_BUILD_DIR)/obuspa $(1)/usr/sbin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/obuspa $(1)/usr/sbin/
$(INSTALL_BIN) ./files/etc/init.d/obuspa $(1)/etc/init.d/ $(INSTALL_BIN) ./files/etc/init.d/obuspa $(1)/etc/init.d/
$(INSTALL_DATA) ./files/etc/config/obuspa $(1)/etc/config/ $(INSTALL_DATA) ./files/etc/config/obuspa $(1)/etc/config/
$(INSTALL_DATA) ./files/etc/obuspa/roles.json $(1)/etc/obuspa/roles.json $(INSTALL_DATA) ./files/etc/obuspa/roles.json $(1)/etc/obuspa/roles.json
$(INSTALL_DATA) ./files/etc/obuspa/dmcaching_exclude.json $(1)/etc/obuspa/dmcaching_exclude.json $(INSTALL_DATA) ./files/etc/obuspa/dmcaching_exclude.json $(1)/etc/obuspa/dmcaching_exclude.json
$(INSTALL_BIN) ./files/etc/hotplug.d/iface/85-obuspa $(1)/etc/hotplug.d/iface/
endef endef
$(eval $(call BuildPackage,obuspa)) $(eval $(call BuildPackage,obuspa))

View File

@@ -1,10 +1,9 @@
config obuspa 'global' config obuspa 'global'
option enabled '1' option enabled '1'
option interface 'loopback' option interface 'wan'
#option ifname 'lo' #option ifname 'eth0.1'
option debug '1' option debug '0'
option log_level '1' option log_level '1'
option prototrace '0'
#option db_file '/etc/obuspa/usp.db' #option db_file '/etc/obuspa/usp.db'
#option role_file '/etc/obuspa/roles.json' #option role_file '/etc/obuspa/roles.json'
option dm_caching_exclude '/etc/obuspa/dmcaching_exclude.json' option dm_caching_exclude '/etc/obuspa/dmcaching_exclude.json'
@@ -47,7 +46,7 @@ config subscription
# option Description 'Request to get Administrative access' # option Description 'Request to get Administrative access'
# option role_name 'full_access' # option role_name 'full_access'
# option Enable '1' # option Enable '1'
# option Value 'YWRtaW4=' # option Value 'admin'
# option Retries 2 # option Retries 2
# option LockoutPeriod 60 # option LockoutPeriod 60
@@ -55,6 +54,6 @@ config subscription
# option Description 'Request to get User access' # option Description 'Request to get User access'
# option role_name 'user' # option role_name 'user'
# option Enable '1' # option Enable '1'
# option Value 'dXNlcg==' # option Value 'user'
# option Retries 3 # option Retries 3
# option LockoutPeriod 30 # option LockoutPeriod 30

View File

@@ -0,0 +1,11 @@
#!/bin/sh
[ "$(uci -q get obuspa.global.interface)" == "$INTERFACE" ] || exit 0
[ "$ACTION" = ifup -o "$ACTION" = ifupdate ] || exit 0
[ "$ACTION" = ifupdate -a -z "$IFUPDATE_ADDRESSES" ] && exit 0
echo "Restarting obuspa"|logger -t obuspa.hotplug -p debug
/etc/init.d/obuspa reload

View File

@@ -67,7 +67,7 @@ get_role_index_from_json() {
local num=0 local num=0
# In case of role is empty or file not present # In case of role is empty or file not present
if [ -z "${role}" -o ! -f "${role_def_file}" ]; then if [ -z "${role}" -o ! -f ${role_def_file} ]; then
return 0 return 0
fi fi
@@ -98,7 +98,7 @@ get_role_index_from_json() {
get_uci_ref_index() { get_uci_ref_index() {
local val; local val;
[ -f "${USP_TEMP_FILE}" ] && rm -f ${USP_TEMP_FILE} [ -f ${USP_TEMP_FILE} ] && rm -f ${USP_TEMP_FILE}
index=0 index=0
config_load $CONFIGURATION config_load $CONFIGURATION
@@ -123,7 +123,6 @@ validate_obuspa_section()
'interface:string' \ 'interface:string' \
'ifname:string:br-lan' \ 'ifname:string:br-lan' \
'debug:bool:false' \ 'debug:bool:false' \
'prototrace:bool:false' \
'log_level:uinteger' \ 'log_level:uinteger' \
'log_dest:string' \ 'log_dest:string' \
'db_file:string' \ 'db_file:string' \
@@ -134,6 +133,7 @@ validate_localagent_section()
{ {
uci_validate_section ${CONFIGURATION} localagent "${1}" \ uci_validate_section ${CONFIGURATION} localagent "${1}" \
'Enable:bool:true' \ 'Enable:bool:true' \
'ParameterName:string:Device.DeviceInfo.SoftwareVersion' \
'EndpointID:string' 'EndpointID:string'
} }
@@ -153,7 +153,6 @@ validate_controller_section()
'Reference:string' \ 'Reference:string' \
'Destination:string:controller-notify-dest' \ 'Destination:string:controller-notify-dest' \
'Topic:string' \ 'Topic:string' \
'ParameterName:list(string)' \
'coap_host:host' \ 'coap_host:host' \
'coap_path:string' \ 'coap_path:string' \
'coap_port:port' \ 'coap_port:port' \
@@ -223,55 +222,9 @@ validate_mqtt_client_section()
'ConnectRetryMaxInterval:uinteger:60' 'ConnectRetryMaxInterval:uinteger:60'
} }
get_oui_from_db() {
local oui="$(db get device.deviceinfo.ManufacturerOUI)"
echo "${oui}"
}
get_serial_from_db() {
local serial="$(db get device.deviceinfo.SerialNumber)"
# this can encoded further
echo "${serial}"
}
publish_endpoint() {
local AgentEndpointID serial oui user pass
local opt=""
# return if mosquitto_pub is not present
if [ ! "$(which mosquitto_pub)" ]; then
log "mosquitto_pub not present can't publish EndpointID"
return 0;
fi
# Get endpoint id from obuspa config first
config_load obuspa
config_get AgentEndpointID localagent EndpointID ""
if [ -z "${AgentEndpointID}" ]; then
serial=$(get_serial_from_db)
oui=$(get_oui_from_db)
AgentEndpointID="os::${oui}-${serial}"
fi
config_get user localmqtt Username
if [ -n "${user}" ]; then
opt="-u ${user}"
fi
config_get pass localmqtt Password
if [ -n "${pass}" ]; then
opt="${opt} -P ${pass}"
fi
# publish Agent's EndpointID in mosquito broker for discovery by usp-js
# This is a work around till obuspa adds supports for mDNS discovery
log "Publishing EndpointID ${AgentEndpointID} to local mqtt broker"
mosquitto_pub -r -t "obuspa/EndpointID" -m "${AgentEndpointID}" ${opt}
}
configure_localagent() { configure_localagent() {
local Enable ParameterName EndpointID local Enable ParameterName EndpointID
local _num
validate_localagent_section 'localagent' || { validate_localagent_section 'localagent' || {
log "Validation of localagent section failed" log "Validation of localagent section failed"
@@ -282,6 +235,14 @@ configure_localagent() {
db_set Device.LocalAgent.EndpointID "${EndpointID}" db_set Device.LocalAgent.EndpointID "${EndpointID}"
fi fi
_num=1
while [ ${_num} -le ${controller_num} ]
do
db_set Device.LocalAgent.Controller.${_num}.BootParameter.1.Enable "${Enable}"
db_set Device.LocalAgent.Controller.${_num}.BootParameter.1.ParameterName "${ParameterName}"
_num=$(( ${_num} + 1 ))
done
db_set db_set
} }
@@ -305,17 +266,17 @@ configure_controller() {
return 1; return 1;
fi fi
if [ -z "${Reference}" ]; then if [ -z ${Reference} ]; then
if [ "${Protocol}" = "STOMP" ]; then if [ ${Protocol} = "STOMP" ]; then
val=$(get_uci_ref_index stomp ${stomp}) val=$(get_uci_ref_index stomp ${stomp})
if [ "${val}" -eq 0 ]; then if [ ${val} -eq 0 ]; then
log "Not able to find the referred stomp section" log "Not able to find the referred stomp section"
return 1; return 1;
fi fi
Reference="Device.STOMP.Connection.${val}" Reference="Device.STOMP.Connection.${val}"
elif [ "${Protocol}" = "MQTT" ]; then elif [ ${Protocol} = "MQTT" ]; then
val=$(get_uci_ref_index mqtt ${mqtt}) val=$(get_uci_ref_index mqtt ${mqtt})
if [ "${val}" -eq 0 ]; then if [ ${val} -eq 0 ]; then
log "Not able to find the referred mqtt section" log "Not able to find the referred mqtt section"
return 1; return 1;
fi fi
@@ -365,17 +326,6 @@ configure_controller() {
log "Unsupported Protocol ${Protocol}" log "Unsupported Protocol ${Protocol}"
fi fi
local param
local _pnum=1
for param in ${ParameterName}
do
db_set Device.LocalAgent.Controller.${controller_num}.BootParameter.${_pnum}.Alias "cpe-${_pnum}"
db_set Device.LocalAgent.Controller.${controller_num}.BootParameter.${_pnum}.Enable "${Enable}"
db_set Device.LocalAgent.Controller.${controller_num}.BootParameter.${_pnum}.ParameterName "${param}"
_pnum=$(( ${_pnum} + 1 ))
done
db_set db_set
} }
@@ -392,9 +342,9 @@ configure_subscription(){
log "No recipient for subscription" log "No recipient for subscription"
fi fi
if [ -z "${Recipient}" ]; then if [ -z ${Recipient} ]; then
val=$(get_uci_ref_index controller ${controller}) val=$(get_uci_ref_index controller ${controller})
if [ "${val}" -eq 0 ]; then if [ ${val} -eq 0 ]; then
log "Not able to find the referred controller section" log "Not able to find the referred controller section"
return 1; return 1;
fi fi
@@ -428,9 +378,9 @@ validate_challenge_section()
check_json_load() check_json_load()
{ {
local ret=0 local ret=0
if [ -f "${role_def_file}" ]; then if [ -f ${role_def_file} ]; then
json_init json_init
json_load_file "${role_def_file}" 2>&1 |grep -q Failed json_load_file ${role_def_file} 2>&1 |grep -q Failed
if [ $? -eq 0 ]; then # In case of invalid json file if [ $? -eq 0 ]; then # In case of invalid json file
log "failed to load [${role_def_file}]" log "failed to load [${role_def_file}]"
ret=1 ret=1
@@ -474,7 +424,7 @@ configure_challenges() {
exit 1; exit 1;
} }
if [ -z "${role_name}" -a -z "${Role}" ]; then if [ -z "${role_name}" -a -z ${Role} ]; then
log "Either role_name or Role must defined for a challenge"; log "Either role_name or Role must defined for a challenge";
return 1; return 1;
fi fi
@@ -510,17 +460,17 @@ configure_mtp() {
return 1; return 1;
} }
if [ -z "${Reference}" ]; then if [ -z ${Reference} ]; then
if [ "${Protocol}" = "STOMP" ]; then if [ ${Protocol} = "STOMP" ]; then
val=$(get_uci_ref_index stomp ${stomp}) val=$(get_uci_ref_index stomp ${stomp})
if [ "${val}" -eq 0 ]; then if [ ${val} -eq 0 ]; then
log "Referred stomp section not found" log "Referred stomp section not found"
return 1; return 1;
fi fi
Reference="Device.STOMP.Connection.${val}" Reference="Device.STOMP.Connection.${val}"
elif [ "${Protocol}" = "MQTT" ]; then elif [ ${Protocol} = "MQTT" ]; then
val=$(get_uci_ref_index mqtt ${mqtt}) val=$(get_uci_ref_index mqtt ${mqtt})
if [ "${val}" -eq 0 ]; then if [ ${val} -eq 0 ]; then
log "Referred mqtt section not found" log "Referred mqtt section not found"
return 1; return 1;
fi fi
@@ -616,7 +566,7 @@ configure_mqtt_client(){
configure_obuspa() { configure_obuspa() {
local enabled trust_cert ifname interface debug prototrace log_level db_file log_dest role_file local enabled trust_cert ifname interface debug log_level db_file log_dest role_file
validate_obuspa_section "global" || { validate_obuspa_section "global" || {
log "Validation of global section failed" log "Validation of global section failed"
@@ -625,18 +575,15 @@ configure_obuspa() {
role_def_file="${role_file}" role_def_file="${role_file}"
if [ "${debug}" -eq 1 ]; then if [ ${debug} -eq 1 ]; then
# Forward stdout of the command to logd # Forward stdout of the command to logd
procd_set_param stdout 1 procd_set_param stdout 1
# Same for stderr # Same for stderr
procd_set_param stderr 1 procd_set_param stderr 1
fi
if [ "${debug}" -eq 1 -a "${prototrace}" -eq 1 ]; then
procd_append_param command -p procd_append_param command -p
fi fi
if [ "${debug}" -eq 1 -a -n "${log_level}" ]; then if [ -n ${log_level} ]; then
procd_append_param command -v ${log_level} procd_append_param command -v ${log_level}
fi fi
@@ -646,6 +593,7 @@ configure_obuspa() {
if [ -n "${interface}" ]; then if [ -n "${interface}" ]; then
network_get_physdev ifname ${interface} network_get_physdev ifname ${interface}
log "ifname from ${interface} is ${ifname}"
fi fi
# Set this variable for root user and obuspa -c tool # Set this variable for root user and obuspa -c tool
@@ -700,10 +648,6 @@ db_init() {
db_set Internal.Reboot.Cause "LocalFactoryReset" db_set Internal.Reboot.Cause "LocalFactoryReset"
} }
service_running() {
publish_endpoint
}
start_service() { start_service() {
local enabled local enabled
@@ -715,6 +659,8 @@ start_service() {
return 0; return 0;
fi fi
ubus wait_for usp.raw
procd_open_instance ${CONFIGURATION} procd_open_instance ${CONFIGURATION}
procd_set_param command ${PROG} procd_set_param command ${PROG}
db_init db_init
@@ -739,8 +685,8 @@ stop_service() {
db_file="/tmp/usp.db" db_file="/tmp/usp.db"
fi fi
[ -f "${db_file}" ] && rm -f ${db_file} [ -f ${db_file} ] && rm -f ${db_file}
[ -f "${PARAM_FILE}" ] && rm -f ${PARAM_FILE} [ -f ${PARAM_FILE} ] && rm -f ${PARAM_FILE}
} }
reload_service() { reload_service() {

View File

@@ -289,8 +289,8 @@ parser_timeout()
#data format is digital with time unit #data format is digital with time unit
#10s-10 seconds 10m-10 minutes 10h-10 hours 10d-10 days #10s-10 seconds 10m-10 minutes 10h-10 hours 10d-10 days
if [ -n "$1" ]; then if [ -n "$1" ]; then
flag=$(echo "$1"| tr -d '0-9' | tr 'A-Z' 'a-z') flag=$(echo "$1"| tr -d [0-9] | tr '[A-Z]' '[a-z]')
data=$(echo "$1"| tr -cd '0-9') data=$(echo "$1"| tr -cd [0-9])
case $flag in case $flag in
m) m)

View File

@@ -5,12 +5,12 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=periodicstats PKG_NAME:=periodicstats
PKG_VERSION:=1.1.0 PKG_VERSION:=1.0.3
LOCAL_DEV:=0 LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1) ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=7426c7458f792cc66920c206d62869c5620f1400 PKG_SOURCE_VERSION:=312573b91b2ae10d0fe04a4d11ae37898f526fdb
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/periodicstats.git PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/periodicstats.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip PKG_MIRROR_HASH:=skip
@@ -26,7 +26,7 @@ define Package/periodicstats
SECTION:=utils SECTION:=utils
CATEGORY:=Utilities CATEGORY:=Utilities
TITLE:=Periodic Statistics Daemon TITLE:=Periodic Statistics Daemon
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libbbf_api DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libbbfdm +libbbf_api +uspd
endef endef
define Package/periodicstats/description define Package/periodicstats/description

View File

@@ -4,23 +4,26 @@ START=99
STOP=10 STOP=10
USE_PROCD=1 USE_PROCD=1
NAME=periodicstatsd
PROG=/usr/sbin/periodicstatsd PROG=/usr/sbin/periodicstatsd
service_running() { . /lib/functions.sh
ubus -t 10 wait_for usp.raw
}
start_service() { start_service() {
enable=$(uci -q get periodicstats.globals.enable) ubus wait_for usp
if [ -f "/etc/config/periodicstats" ]; then
if [ "$(enable)" != "1" ]; then if [ "$(uci -q get periodicstats.globals.enable)" == "1" ]; then
return 0; procd_open_instance periodicstatsd
procd_set_param command ${PROG}
procd_set_param respawn
procd_close_instance
fi
fi fi
}
procd_open_instance periodicstatsd stop() {
procd_set_param command ${PROG} #stop_service() is called after procd killed the service
procd_set_param respawn echo ;
procd_close_instance
} }
service_triggers() { service_triggers() {

View File

@@ -12,7 +12,7 @@ PKG_NAME:=peripheral_manager
PKG_VERSION:=1.0.6 PKG_VERSION:=1.0.6
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_SOURCE_VERSION:=15ba90f01914113e7c5e8f8a6df6279c882e8265 PKG_SOURCE_VERSION:=785166a9861a119623556163179915727896156b
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/peripheral-manager PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/peripheral-manager

View File

@@ -6,11 +6,11 @@ usage () {
} }
[ $# -ne 1 ] && usage [ $# -ne 1 ] && usage
ledstate=$(echo $1 | tr 'A-Z' 'a-z') ledstate=$(echo $1 | tr '[A-Z]' '[a-z]')
case $ledstate in case $ledstate in
normal|test|allon|alloff|production) normal|test|allon|alloff|production)
ubus call leds set "{\"state\" : \"$ledstate\"}" ubus call leds set "{\"state\" : \"$ledstate\"}"
;; ;;
*) *)
usage usage

View File

@@ -1,38 +0,0 @@
#
# Copyright (C) 2013-2021 iopsys
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=ponmngr
PKG_VERSION:=1.0.0
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_LICENSE:=GPL-2.0-only
PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk
define Package/ponmngr
CATEGORY:=Utilities
TITLE:=ponmngr packets manager daemon
endef
define Package/ponmngr/description
Configures pon
endef
#define Build/Prepare
# $(CP) -rf ./ponmngr/* $(PKG_BUILD_DIR)/
#endef
define Build/Compile
endef
define Package/ponmngr/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,ponmngr))

View File

@@ -1,36 +0,0 @@
#!/bin/sh /etc/rc.common
START=98
STOP=10
USE_PROCD=1
NAME=ponmngr
PROG="/usr/sbin/omcid start"
include /lib/pon
start_service() {
if [ -f "/etc/config/pon" ]; then
procd_open_instance $NAME
procd_set_param command ${PROG}
procd_set_param respawn
procd_close_instance
start_gpon
fi
}
boot() {
start
}
stop_service() {
service_stop ${PROG}
stop_gpon
}
reload_service() {
stop
start
}

View File

@@ -1,27 +0,0 @@
#!/bin/sh
basemac="$(db -q get hw.board.basemac | tr -d ':')"
if [ -s "/etc/config/pon" ]; then
if uci -q get pon.globals >/dev/null; then
# return if there is any valid content
exit
else
rm -f /etc/config/pon
fi
fi
touch /etc/config/pon
mac=''
if [ -z "$basemac" ]; then
mac="12345678"
else
# read last 8 characters of basemac without :
mac=${basemac: -8}
fi
uci set pon.globals=globals
uci set pon.globals.enabled="1"
uci set pon.globals.serial_number="BRCM$mac"
uci commit pon

View File

@@ -1,70 +0,0 @@
#!/bin/sh
. /lib/functions.sh
. /usr/share/libubox/jshn.sh
configure_snpwd() {
local serial_no password
serial_no="$1"
password="$2"
# serial number comprises of 2 parts, vendor id and vendor specific, the vendor id is
# a string while the vendor specific is a hex, so split the 2 and set accordingly
local vendor_id vendor_specific
vendor_id=${serial_no:0:4}
vendor_specific=${serial_no: -8}
# attempt to conver vendor_id from string to hex
vendor_id=$(echo $vendor_id | hexdump -e '4/1 "%02X" "\n"')
vendor_id=${vendor_id:0:8}
bdmf_shell -c `cat /var/bdmf_sh_id` -cmd /b/configure gpon onu_sn={vendor_id=$vendor_id,vendor_specific=$vendor_specific}
if [ -n "$password" ]; then
password=$(echo $password | hexdump -n ${#password} -e '16/1 "%02X""\n"')
bdmf_shell -c `cat /var/bdmf_sh_id` -cmd /b/configure gpon password=$password
fi
}
configure_gpon() {
local enabled serial_no password
config_load pon
config_get enabled globals "enabled"
if [ "$enabled" == "0" ]; then
exit
fi
config_get serial_no globals "serial_number"
config_get password globals "password"
configure_snpwd $serial_no $password
}
start_gpon() {
if [ -n "$(which gponctl)" ]; then
configure_gpon
gponctl start
fi
}
stop_gpon() {
if [ -n "$(which gponctl)" ]; then
gponctl stop
fi
}
get_gpon_status() {
json_init
status="$(gponctl getstate)"
admin_status="$(echo $status | head -n1 | awk '{print $8;}')"
json_add_string "admin_status" "$admin_status"
op_status="$(echo $status | head -n1 | awk '{print $12;}')"
case $op_status in
NUMBER)
op_status="$(echo $status | head -n1 | awk '{print $13;}')"
;;
esac
op_status=${op_status:1:2}
json_add_string "operational_status" "$op_status"
json_dump
}

View File

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

View File

@@ -1,9 +1,19 @@
#!/bin/sh #!/bin/sh
populate_config_from_db() { . /lib/network/utils.sh
. /lib/network/utils.sh
portorder="$(db -q get hw.board.ethernetPortOrder)" populate_config(){
if [ -s "/etc/config/ports" ]; then
if uci -q get ports.@ethport[0] >/dev/null; then
# return if there is any valid content
return 0
else
rm -f /etc/config/ports
fi
fi
touch /etc/config/ports
local portorder="$(db -q get hw.board.ethernetPortOrder)"
for port in $portorder; do for port in $portorder; do
uci add ports ethport uci add ports ethport
uci rename ports.@ethport[-1]="$(get_port_name $port)" uci rename ports.@ethport[-1]="$(get_port_name $port)"
@@ -25,44 +35,4 @@ populate_config_from_db() {
uci commit ports uci commit ports
} }
populate_config_from_device_tree() { [ -f /sbin/db -a -f /etc/board-db/config/hw ] && populate_config
for port in $(find /proc/device-tree/ -name "port@*"); do
port="$(cat $port/label)"
[ -n "$port" ] || continue
[ "$port" = "cpu" ] && continue
PORT="$(echo $port | tr '[a-z]' '[A-Z]')"
uci add ports ethport
uci rename ports.@ethport[-1]="$PORT"
uci set ports.@ethport[-1].enabled=1
uci set ports.@ethport[-1].name="$PORT"
uci set ports.@ethport[-1].ifname="$port"
uci set ports.@ethport[-1].speed=1000
uci set ports.@ethport[-1].duplex="full"
uci set ports.@ethport[-1].autoneg=1
uci set ports.@ethport[-1].eee=0
if [ "$port" = "wan" ]; then
uci set ports.@ethport[-1].pause=1
uci set ports.@ethport[-1].uplink=1
else
uci set ports.@ethport[-1].pause=0
fi
done
uci commit ports
}
if [ -s "/etc/config/ports" ]; then
if uci -q get ports.@ethport[0] >/dev/null; then
# exit if there is any valid content
exit 0
else
rm -f /etc/config/ports
fi
fi
touch /etc/config/ports
if [ -f /sbin/db ] && [ -f /etc/board-db/config/hw ]; then
populate_config_from_db
elif [ -d /proc/device-tree/ ]; then
populate_config_from_device_tree
fi

View File

@@ -6,12 +6,12 @@ include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=qosmngr PKG_NAME:=qosmngr
PKG_VERSION:=1.0.4 PKG_VERSION:=1.0.2
LOCAL_DEV:=0 LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1) ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=e3d608e4bacd367fed99bcdd7f56b3fba7b02891 PKG_SOURCE_VERSION:=460327011d932580f55c7b70acb1e652dd3c95a3
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/qosmngr.git PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/qosmngr.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip PKG_MIRROR_HASH:=skip

View File

@@ -21,10 +21,6 @@ generate_queue(){
case $cpu_model in case $cpu_model in
68*) no_of_q="0 1 2 3" ;; 68*) no_of_q="0 1 2 3" ;;
esac esac
if grep -qE '[0-9]+ archer$' /proc/devices; then
no_of_q="0 1 2 3"
fi
fi fi
i=0 i=0

View File

@@ -327,15 +327,6 @@ broute_filter_on_ether_type() {
BR_RULE="$BR_RULE --proto $1" BR_RULE="$BR_RULE --proto $1"
} }
broute_filter_on_dscp() {
# The broadcom option --ip-dscp-extend actually accepts tos
# and not dscp and that too in hex, hence, perform the conversion
# from dscp in uci to tos first and then convert to hex
tos_val=$(($1<<2))
tos_hex=$(printf "%x" $tos_val)
BR_RULE="$BR_RULE --ip-dscp-extend $tos_hex"
}
broute_filter_on_vid() { broute_filter_on_vid() {
case "$BR_RULE" in case "$BR_RULE" in
*proto*) *proto*)
@@ -366,7 +357,6 @@ handle_ebtables_rules() {
config_get src_if "$sid" "ifname" config_get src_if "$sid" "ifname"
config_get src_mac "$sid" "src_mac" config_get src_mac "$sid" "src_mac"
config_get dst_mac "$sid" "dst_mac" config_get dst_mac "$sid" "dst_mac"
config_get dscp_filter "$sid" "dscp_filter"
config_get pcp_check "$sid" "pcp_check" config_get pcp_check "$sid" "pcp_check"
config_get eth_type "$sid" "ethertype" config_get eth_type "$sid" "ethertype"
config_get vid "$sid" "vid_check" config_get vid "$sid" "vid_check"
@@ -405,13 +395,6 @@ handle_ebtables_rules() {
is_l2_rule=1 is_l2_rule=1
fi fi
if [ -n "$dscp_filter" ]; then
# filter on ethertype and proto is same thing
broute_filter_on_ether_type IPv4
broute_filter_on_dscp $dscp_filter
is_l2_rule=1
fi
if [ -n "$eth_type" ]; then if [ -n "$eth_type" ]; then
broute_filter_on_ether_type $eth_type broute_filter_on_ether_type $eth_type
is_l2_rule=1 is_l2_rule=1
@@ -842,7 +825,7 @@ configure_classify() {
fcctl flush fcctl flush
} }
pre_configure_queue() { configure_queue() {
# Delete queues # Delete queues
rm -rf /tmp/qos/queue_stats rm -rf /tmp/qos/queue_stats
@@ -856,15 +839,12 @@ pre_configure_queue() {
for i in 0 1 2 3 4 5 6 7; do for i in 0 1 2 3 4 5 6 7; do
tmctl delqcfg --devtype 0 --if $intf --qid $i &>/dev/null tmctl delqcfg --devtype 0 --if $intf --qid $i &>/dev/null
done done
tmctl porttminit --devtype 0 --if $intf --flag 0 --numqueues 8
mkdir -p /tmp/qos/$intf mkdir -p /tmp/qos/$intf
touch /tmp/qos/$intf/q_order touch /tmp/qos/$intf/q_order
touch /tmp/qos/$intf/q_precedence touch /tmp/qos/$intf/q_precedence
done done
}
configure_queue() {
# Load UCI file # Load UCI file
config_load qos config_load qos
config_foreach handle_q_order queue config_foreach handle_q_order queue
@@ -915,7 +895,6 @@ configure_qos() {
#queue configuration is being done after shaper configuration, #queue configuration is being done after shaper configuration,
#If port shapingrate configuration on DISC device is called after queue configuration then #If port shapingrate configuration on DISC device is called after queue configuration then
#driver overwrites the queue shaping rate with default value of port shaping rate. #driver overwrites the queue shaping rate with default value of port shaping rate.
pre_configure_queue
configure_shaper configure_shaper
configure_queue configure_queue
configure_policer configure_policer
@@ -935,7 +914,6 @@ reload_qos() {
elif [ "$service_name" == "shaper" ]; then elif [ "$service_name" == "shaper" ]; then
configure_shaper configure_shaper
elif [ "$service_name" == "queue" ]; then elif [ "$service_name" == "queue" ]; then
pre_configure_queue
configure_queue configure_queue
elif [ "$service_name" == "classify" ]; then elif [ "$service_name" == "classify" ]; then
configure_classify configure_classify

View File

@@ -6,9 +6,9 @@ include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=questd PKG_NAME:=questd
PKG_VERSION:=5.2.3 PKG_VERSION:=5.2.2
PKG_SOURCE_VERSION:=cf54bd65ec821ac67f3aa1caeebcd3ea9aae07ad PKG_SOURCE_VERSION:=cd05311b505cc5025a8559c616b55e9fb4d1857d
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/questd PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/questd

View File

@@ -1,55 +0,0 @@
#
# Copyright (c) 2020 Genexis B.V.
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=quickjs-websocket
PKG_LICENSE:=MIT
PKG_VERSION:=1
PKG_RELEASE:=1
PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
define Package/quickjs-websocket
SECTION:=libs
CATEGORY:=Libraries
TITLE:=WebSocket API for QuickJS
MAINTAINER:=Erik Karlsson <erik.karlsson@genexis.eu>
DEPENDS:=+quickjs +libwebsockets
endef
define Package/quickjs-websocket/description
Implementation of the W3C WebSocket API in QuickJS on top of the
libwebsockets C library.
endef
define Package/quickjs-websocket/install
$(INSTALL_DIR) $(1)/usr/lib/quickjs
$(CP) $(PKG_BUILD_DIR)/lws-client.so $(1)/usr/lib/quickjs/
$(CP) $(PKG_BUILD_DIR)/websocket.js $(1)/usr/lib/quickjs/
endef
$(eval $(call BuildPackage,quickjs-websocket))

View File

@@ -1,23 +0,0 @@
WebSocket API for QuickJS
===============
Introduction
------------
This is an implementation of the W3C WebSocket API for the QuickJS
JavaScript engine on top of the libwebsockets C library.
Usage
------------
import { WebSocket } from '/usr/lib/quickjs/websocket.js'
const w = new WebSocket('wss://example.com/', ['protocol1', 'protocol2'])
globalThis.WebSocket = WebSocket // To make the API available globally
Limitations
------------
Events emitted by WebSocket objects do not implement the full DOM
event specification. Only a subset of properties is available. The
EventTarget interface, i.e. addEventListener/removeEventListener, is
unimplemented. The onopen/onerror/onclose/onmesseage handlers have to
be used instead.

View File

@@ -1,38 +0,0 @@
#
# Copyright (c) 2020 Genexis B.V.
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
TARGETS = lws-client.so
CFLAGS += -Os -Wall -Werror
all: $(TARGETS)
%.pic.o: %.c
$(CC) $(CFLAGS) -fPIC -c -o $@ $<
lws-client.so: lws-client.pic.o
$(CC) $(LDFLAGS) -shared -o $@ $^ -lwebsockets
clean:
rm -f *.o $(TARGETS)

View File

@@ -1,958 +0,0 @@
/*
* Copyright (c) 2020 Genexis B.V.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <stdint.h>
#include <string.h>
#include <quickjs/quickjs.h>
#include <quickjs/quickjs-libc.h>
#include <libwebsockets.h>
#define countof(x) (sizeof(x) / sizeof((x)[0]))
#define CDEF(name) JS_PROP_INT32_DEF(#name, name, JS_PROP_CONFIGURABLE)
#if LWS_LIBRARY_VERSION_NUMBER < 3002000
#define MAX_WAIT 1000
#else
#define MAX_WAIT INT32_MAX
#ifndef LWS_WITH_EXTERNAL_POLL
#error "LWS_WITH_EXTERNAL_POLL is needed for LWS versions >= 3.2.0"
#endif
#if LWS_LIBRARY_VERSION_NUMBER < 4001002
#error "External poll is broken for 3.2.0 <= LWS version < 4.1.2"
#endif
#endif
#define WSI_DATA_USE_OBJECT (1 << 0)
#define WSI_DATA_USE_LINKED (1 << 1)
typedef struct js_lws_wsi_data {
struct js_lws_wsi_data *next;
struct lws *wsi;
JSValue object;
JSValue context;
JSValue user;
uint8_t in_use;
} js_lws_wsi_data_t;
typedef struct {
struct lws_context *context;
JSContext *ctx;
JSValue callback;
js_lws_wsi_data_t *wsi_list;
} js_lws_context_data_t;
static JSClassID js_lws_context_class_id;
static JSClassID js_lws_wsi_class_id;
static void free_wsi_data_rt(JSRuntime *rt, js_lws_wsi_data_t *data)
{
JS_FreeValueRT(rt, data->object);
JS_FreeValueRT(rt, data->context);
JS_FreeValueRT(rt, data->user);
js_free_rt(rt, data);
}
static void unlink_wsi_rt(JSRuntime *rt, js_lws_context_data_t *data,
js_lws_wsi_data_t *wsi_data)
{
js_lws_wsi_data_t **p;
for (p = &data->wsi_list; *p; p = &(*p)->next) {
if (*p == wsi_data) {
*p = (*p)->next;
break;
}
}
wsi_data->next = NULL;
wsi_data->wsi = NULL;
JS_FreeValueRT(rt, wsi_data->object);
wsi_data->object = JS_UNDEFINED;
wsi_data->in_use &= ~WSI_DATA_USE_LINKED;
if (wsi_data->in_use == 0)
free_wsi_data_rt(rt, wsi_data);
}
static void unlink_wsi(JSContext *ctx, js_lws_context_data_t *data,
js_lws_wsi_data_t *wsi_data)
{
unlink_wsi_rt(JS_GetRuntime(ctx), data, wsi_data);
}
static JSValue convert_pollargs(JSContext *ctx, const struct lws_pollargs *pa)
{
JSValue obj;
if (pa == NULL)
return JS_NULL;
obj = JS_NewObject(ctx);
if (JS_IsException(obj))
return obj;
if (JS_SetPropertyStr(ctx, obj, "fd", JS_NewInt32(ctx, pa->fd)) < 0
|| JS_SetPropertyStr(ctx, obj, "events",
JS_NewInt32(ctx, pa->events)) < 0
|| JS_SetPropertyStr(ctx, obj, "prev_events",
JS_NewInt32(ctx, pa->prev_events)) < 0) {
JS_FreeValue(ctx, obj);
return JS_EXCEPTION;
}
return obj;
}
static JSValue convert_close_payload(JSContext *ctx,
uint8_t *payload, size_t len)
{
JSValue array;
uint16_t status;
JSValue reason;
if (payload == NULL || len < 2)
return JS_NULL;
array = JS_NewArray(ctx);
if (JS_IsException(array))
return array;
status = (payload[0] << 8) | payload[1];
if (JS_SetPropertyUint32(ctx, array, 0, JS_NewInt32(ctx, status)) < 0) {
JS_FreeValue(ctx, array);
return JS_EXCEPTION;
}
reason = JS_NewStringLen(ctx, (const char *)(payload + 2), len - 2);
if (JS_IsException(reason)
|| JS_SetPropertyUint32(ctx, array, 1, reason) < 0) {
JS_FreeValue(ctx, array);
return JS_EXCEPTION;
}
return array;
}
static int client_callback(struct lws *wsi, enum lws_callback_reasons reason,
void *user, void *in, size_t len)
{
js_lws_context_data_t *data = lws_context_user(lws_get_context(wsi));
js_lws_wsi_data_t *wsi_data = lws_wsi_user(wsi);
JSContext *ctx;
JSValue args[3];
JSValue ret;
int32_t ret_int;
int i;
if (data == NULL || data->ctx == NULL || JS_IsUndefined(data->callback))
return 0;
ctx = data->ctx;
args[0] = wsi_data ? JS_DupValue(ctx, wsi_data->object) : JS_NULL;
args[1] = JS_NewInt32(ctx, reason);
args[2] = JS_NULL;
switch (reason) {
case LWS_CALLBACK_ADD_POLL_FD:
case LWS_CALLBACK_DEL_POLL_FD:
case LWS_CALLBACK_CHANGE_MODE_POLL_FD:
args[2] = convert_pollargs(ctx, in);
break;
case LWS_CALLBACK_CLIENT_CONNECTION_ERROR:
if (in)
args[2] = JS_NewStringLen(ctx, in, len);
break;
case LWS_CALLBACK_WS_PEER_INITIATED_CLOSE:
args[2] = convert_close_payload(ctx, in, len);
break;
case LWS_CALLBACK_RECEIVE:
case LWS_CALLBACK_CLIENT_RECEIVE:
if (in)
args[2] = JS_NewArrayBufferCopy(ctx, in, len);
break;
case LWS_CALLBACK_WSI_DESTROY:
if (wsi_data)
unlink_wsi(ctx, data, wsi_data);
break;
default:
break;
}
if (JS_IsException(args[2]))
ret = JS_EXCEPTION;
else
ret = JS_Call(ctx, data->callback, JS_UNDEFINED, countof(args), args);
if (JS_IsException(ret) || JS_ToInt32(ctx, &ret_int, ret) < 0) {
js_std_dump_error(ctx);
ret_int = -1;
}
JS_FreeValue(ctx, ret);
for (i = 0; i < countof(args); i++) {
JS_FreeValue(ctx, args[i]);
}
return ret_int;
}
static const struct lws_protocols client_protocols[] = {
{ "lws-client", client_callback, 0, 0, 0, NULL, 0 },
{ NULL, NULL, 0, 0, 0, NULL, 0 }
};
static JSValue js_decode_utf8(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
size_t size;
uint8_t *ptr = JS_GetArrayBuffer(ctx, &size, argv[0]);
if (ptr == NULL)
return JS_EXCEPTION;
return JS_NewStringLen(ctx, (const char *)ptr, size);
}
static JSValue js_lws_set_log_level(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
int32_t level;
if (JS_ToInt32(ctx, &level, argv[0]) < 0)
return JS_EXCEPTION;
lws_set_log_level(level, NULL);
return JS_UNDEFINED;
}
static JSValue js_lws_create_context(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
int secure;
JSValue obj;
js_lws_context_data_t *data;
struct lws_context_creation_info info;
struct lws_context *context;
if (!JS_IsFunction(ctx, argv[0]))
return JS_ThrowTypeError(ctx, "not a function");
secure = JS_ToBool(ctx, argv[1]);
if (secure < 0)
return JS_EXCEPTION;
obj = JS_NewObjectClass(ctx, js_lws_context_class_id);
if (JS_IsException(obj))
return obj;
data = js_mallocz(ctx, sizeof(js_lws_context_data_t));
if (data == NULL) {
JS_FreeValue(ctx, obj);
return JS_EXCEPTION;
}
data->callback = JS_UNDEFINED;
memset(&info, 0, sizeof(info));
info.port = CONTEXT_PORT_NO_LISTEN;
info.protocols = client_protocols;
info.gid = -1;
info.uid = -1;
info.options = secure ? LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT : 0;
info.user = data;
context = lws_create_context(&info);
if (context == NULL) {
JS_FreeValue(ctx, obj);
js_free(ctx, data);
return JS_ThrowOutOfMemory(ctx);
}
data->context = context;
data->ctx = JS_DupContext(ctx);
data->callback = JS_DupValue(ctx, argv[0]);
JS_SetOpaque(obj, data);
return obj;
}
static void js_lws_context_finalizer(JSRuntime *rt, JSValue val)
{
js_lws_context_data_t *data = JS_GetOpaque(val, js_lws_context_class_id);
if (data) {
JS_FreeContext(data->ctx);
data->ctx = NULL;
JS_FreeValueRT(rt, data->callback);
data->callback = JS_UNDEFINED;
lws_context_destroy(data->context);
while (data->wsi_list) {
unlink_wsi_rt(rt, data, data->wsi_list);
}
js_free_rt(rt, data);
}
}
static void js_lws_context_mark(JSRuntime *rt, JSValue val,
JS_MarkFunc *mark_func)
{
js_lws_context_data_t *data = JS_GetOpaque(val, js_lws_context_class_id);
if (data) {
js_lws_wsi_data_t *wd;
mark_func(rt, (JSGCObjectHeader *)data->ctx);
JS_MarkValue(rt, data->callback, mark_func);
for (wd = data->wsi_list; wd; wd = wd->next) {
JS_MarkValue(rt, wd->object, mark_func);
}
}
}
static JSValue js_lws_context_get_connections(JSContext *ctx,
JSValueConst this_val)
{
js_lws_context_data_t *data = JS_GetOpaque2(ctx, this_val,
js_lws_context_class_id);
int32_t connections = 0;
js_lws_wsi_data_t *wd;
if (data == NULL)
return JS_EXCEPTION;
for (wd = data->wsi_list; wd; wd = wd->next) {
connections++;
}
return JS_NewInt32(ctx, connections);
}
static JSValue js_lws_client_connect(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
js_lws_context_data_t *data = JS_GetOpaque2(ctx, this_val,
js_lws_context_class_id);
const char *address = NULL;
int32_t port;
int secure;
const char *path = NULL, *host = NULL, *origin = NULL, *protocol = NULL;
JSValue obj = JS_UNDEFINED, ret = JS_EXCEPTION;
js_lws_wsi_data_t *wsi_data;
struct lws_client_connect_info info;
if (data == NULL)
return JS_EXCEPTION;
address = JS_ToCString(ctx, argv[0]);
if (address == NULL)
goto exception;
if (JS_ToInt32(ctx, &port, argv[1]) < 0)
goto exception;
if (port < 1 || port > 65535) {
JS_ThrowRangeError(ctx, "port must be between 1 and 65535");
goto exception;
}
secure = JS_ToBool(ctx, argv[2]);
if (secure < 0)
goto exception;
path = JS_ToCString(ctx, argv[3]);
if (path == NULL)
goto exception;
host = JS_ToCString(ctx, argv[4]);
if (host == NULL)
goto exception;
if (!JS_IsUndefined(argv[5]) && !JS_IsNull(argv[5])) {
origin = JS_ToCString(ctx, argv[5]);
if (origin == NULL)
goto exception;
}
if (!JS_IsUndefined(argv[6]) && !JS_IsNull(argv[6])) {
protocol = JS_ToCString(ctx, argv[6]);
if (protocol == NULL)
goto exception;
}
obj = JS_NewObjectClass(ctx, js_lws_wsi_class_id);
if (JS_IsException(obj))
goto exception;
wsi_data = js_mallocz(ctx, sizeof(js_lws_wsi_data_t));
if (wsi_data == NULL)
goto exception;
wsi_data->next = data->wsi_list;
wsi_data->object = JS_DupValue(ctx, obj);
wsi_data->context = JS_DupValue(ctx, this_val);
wsi_data->user = JS_DupValue(ctx, argv[7]);
wsi_data->in_use = WSI_DATA_USE_OBJECT | WSI_DATA_USE_LINKED;
data->wsi_list = wsi_data;
JS_SetOpaque(obj, wsi_data);
memset(&info, 0, sizeof(info));
info.context = data->context;
info.address = address;
info.port = port;
info.ssl_connection = secure ? LCCSCF_USE_SSL : 0;
info.local_protocol_name = "lws-client";
info.path = path;
info.host = host;
info.origin = origin;
info.protocol = protocol;
info.ietf_version_or_minus_one = -1;
info.userdata = wsi_data;
info.pwsi = &wsi_data->wsi;
lws_client_connect_via_info(&info);
if (wsi_data->wsi) {
ret = JS_DupValue(ctx, obj);
} else {
unlink_wsi(ctx, data, wsi_data);
JS_ThrowReferenceError(ctx, "cannot connect to [%s]:%d (%s)",
address, port, secure ? "wss" : "ws");
}
exception:
JS_FreeCString(ctx, address);
JS_FreeCString(ctx, path);
JS_FreeCString(ctx, host);
JS_FreeCString(ctx, origin);
JS_FreeCString(ctx, protocol);
JS_FreeValue(ctx, obj);
return ret;
}
static JSValue js_lws_service_fd(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
js_lws_context_data_t *data = JS_GetOpaque2(ctx, this_val,
js_lws_context_class_id);
int32_t fd, events, revents;
struct lws_pollfd pfd;
if (data == NULL)
return JS_EXCEPTION;
if (JS_ToInt32(ctx, &fd, argv[0]) < 0)
return JS_EXCEPTION;
if (JS_ToInt32(ctx, &events, argv[1]) < 0)
return JS_EXCEPTION;
if (JS_ToInt32(ctx, &revents, argv[2]) < 0)
return JS_EXCEPTION;
pfd.fd = fd;
pfd.events = events;
pfd.revents = revents;
lws_service_fd(data->context, &pfd);
return JS_NewInt32(ctx,
lws_service_adjust_timeout(data->context, MAX_WAIT, 0));
}
static JSValue js_lws_service_periodic(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
js_lws_context_data_t *data = JS_GetOpaque2(ctx, this_val,
js_lws_context_class_id);
int timeout;
if (data == NULL)
return JS_EXCEPTION;
#if LWS_LIBRARY_VERSION_NUMBER < 3002000
lws_service_fd(data->context, NULL);
#endif
timeout = lws_service_adjust_timeout(data->context, MAX_WAIT, 0);
if (timeout == 0) {
lws_service(data->context, -1);
timeout = lws_service_adjust_timeout(data->context, MAX_WAIT, 0);
}
return JS_NewInt32(ctx, timeout);
}
static void js_lws_wsi_finalizer(JSRuntime *rt, JSValue val)
{
js_lws_wsi_data_t *data = JS_GetOpaque(val, js_lws_wsi_class_id);
if (data) {
JS_FreeValueRT(rt, data->context);
data->context = JS_UNDEFINED;
JS_FreeValueRT(rt, data->user);
data->user = JS_UNDEFINED;
data->in_use &= ~WSI_DATA_USE_OBJECT;
if (data->in_use == 0)
free_wsi_data_rt(rt, data);
}
}
static void js_lws_wsi_mark(JSRuntime *rt, JSValue val,
JS_MarkFunc *mark_func)
{
js_lws_wsi_data_t *data = JS_GetOpaque(val, js_lws_wsi_class_id);
if (data) {
JS_MarkValue(rt, data->context, mark_func);
JS_MarkValue(rt, data->user, mark_func);
}
}
static JSValue js_lws_wsi_get_context(JSContext *ctx, JSValueConst this_val)
{
js_lws_wsi_data_t *data = JS_GetOpaque2(ctx, this_val, js_lws_wsi_class_id);
if (data == NULL)
return JS_EXCEPTION;
return JS_DupValue(ctx, data->context);
}
static JSValue js_lws_wsi_get_user(JSContext *ctx, JSValueConst this_val)
{
js_lws_wsi_data_t *data = JS_GetOpaque2(ctx, this_val, js_lws_wsi_class_id);
if (data == NULL)
return JS_EXCEPTION;
return JS_DupValue(ctx, data->user);
}
static JSValue js_lws_wsi_get_hdr(JSContext *ctx, JSValueConst this_val,
int magic)
{
js_lws_wsi_data_t *data = JS_GetOpaque2(ctx, this_val, js_lws_wsi_class_id);
int len;
char *str;
JSValue ret;
if (data == NULL)
return JS_EXCEPTION;
if (data->wsi == NULL)
return JS_ThrowTypeError(ctx, "defunct WSI");
len = lws_hdr_total_length(data->wsi, magic);
if (len < 0)
return JS_ThrowReferenceError(ctx, "HTTP headers unavailable");
len++;
str = js_mallocz(ctx, len);
if (str == NULL)
return JS_EXCEPTION;
len = lws_hdr_copy(data->wsi, str, len, magic);
if (len < 0)
ret = JS_ThrowReferenceError(ctx, "HTTP headers unavailable");
else
ret = JS_NewStringLen(ctx, str, len);
js_free(ctx, str);
return ret;
}
static JSValue js_lws_is_final_fragment(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
js_lws_wsi_data_t *data = JS_GetOpaque2(ctx, this_val, js_lws_wsi_class_id);
if (data == NULL)
return JS_EXCEPTION;
if (data->wsi == NULL)
return JS_ThrowTypeError(ctx, "defunct WSI");
return JS_NewBool(ctx, lws_is_final_fragment(data->wsi));
}
static JSValue js_lws_is_first_fragment(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
js_lws_wsi_data_t *data = JS_GetOpaque2(ctx, this_val, js_lws_wsi_class_id);
if (data == NULL)
return JS_EXCEPTION;
if (data->wsi == NULL)
return JS_ThrowTypeError(ctx, "defunct WSI");
return JS_NewBool(ctx, lws_is_first_fragment(data->wsi));
}
static JSValue js_lws_frame_is_binary(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
js_lws_wsi_data_t *data = JS_GetOpaque2(ctx, this_val, js_lws_wsi_class_id);
if (data == NULL)
return JS_EXCEPTION;
if (data->wsi == NULL)
return JS_ThrowTypeError(ctx, "defunct WSI");
return JS_NewBool(ctx, lws_frame_is_binary(data->wsi));
}
static JSValue js_lws_callback_on_writable(JSContext *ctx,
JSValueConst this_val,
int argc, JSValueConst *argv)
{
js_lws_wsi_data_t *data = JS_GetOpaque2(ctx, this_val, js_lws_wsi_class_id);
if (data == NULL)
return JS_EXCEPTION;
if (data->wsi == NULL)
return JS_ThrowTypeError(ctx, "defunct WSI");
lws_callback_on_writable(data->wsi);
return JS_UNDEFINED;
}
static JSValue js_lws_write(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
js_lws_wsi_data_t *data = JS_GetOpaque2(ctx, this_val, js_lws_wsi_class_id);
const char *str = NULL;
const uint8_t *ptr;
uint8_t *buf;
size_t size;
enum lws_write_protocol protocol;
int ret;
if (data == NULL)
return JS_EXCEPTION;
if (data->wsi == NULL)
return JS_ThrowTypeError(ctx, "defunct WSI");
if (JS_IsString(argv[0])) {
str = JS_ToCStringLen(ctx, &size, argv[0]);
if (str == NULL)
return JS_EXCEPTION;
ptr = (const uint8_t *)str;
protocol = LWS_WRITE_TEXT;
} else {
ptr = JS_GetArrayBuffer(ctx, &size, argv[0]);
if (ptr == NULL)
return JS_EXCEPTION;
protocol = LWS_WRITE_BINARY;
}
buf = js_malloc(ctx, LWS_PRE + size);
if (buf)
memcpy(buf + LWS_PRE, ptr, size);
if (str)
JS_FreeCString(ctx, str);
if (buf == NULL)
return JS_EXCEPTION;
ret = lws_write(data->wsi, buf + LWS_PRE, size, protocol);
js_free(ctx, buf);
if (ret < 0)
return JS_ThrowTypeError(ctx, "WSI not writable");
return JS_UNDEFINED;
}
static JSValue js_lws_close_reason(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
js_lws_wsi_data_t *data = JS_GetOpaque2(ctx, this_val, js_lws_wsi_class_id);
int32_t status;
const char *reason = NULL;
size_t len = 0;
if (data == NULL)
return JS_EXCEPTION;
if (data->wsi == NULL)
return JS_ThrowTypeError(ctx, "defunct WSI");
if (JS_ToInt32(ctx, &status, argv[0]) < 0)
return JS_EXCEPTION;
if (status < 0 || status > 65535)
return JS_ThrowRangeError(ctx, "status must be between 0 and 65535");
if (!JS_IsUndefined(argv[1])) {
reason = JS_ToCStringLen(ctx, &len, argv[1]);
if (reason == NULL)
return JS_EXCEPTION;
if (len > 123) {
JS_FreeCString(ctx, reason);
return JS_ThrowTypeError(ctx, "reason too long (%zu > 123)", len);
}
}
lws_close_reason(data->wsi, status, (uint8_t *)reason, len);
if (reason)
JS_FreeCString(ctx, reason);
return JS_UNDEFINED;
}
static const JSCFunctionListEntry js_lws_funcs[] = {
CDEF(LLL_ERR),
CDEF(LLL_WARN),
CDEF(LLL_NOTICE),
CDEF(LLL_INFO),
CDEF(LLL_DEBUG),
CDEF(LLL_PARSER),
CDEF(LLL_HEADER),
CDEF(LLL_EXT),
CDEF(LLL_CLIENT),
CDEF(LLL_LATENCY),
CDEF(LLL_USER),
CDEF(LLL_THREAD),
CDEF(LLL_COUNT),
CDEF(LWS_CALLBACK_PROTOCOL_INIT),
CDEF(LWS_CALLBACK_PROTOCOL_DESTROY),
CDEF(LWS_CALLBACK_WSI_CREATE),
CDEF(LWS_CALLBACK_WSI_DESTROY),
CDEF(LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS),
CDEF(LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS),
CDEF(LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION),
CDEF(LWS_CALLBACK_OPENSSL_CONTEXT_REQUIRES_PRIVATE_KEY),
CDEF(LWS_CALLBACK_SSL_INFO),
CDEF(LWS_CALLBACK_OPENSSL_PERFORM_SERVER_CERT_VERIFICATION),
CDEF(LWS_CALLBACK_SERVER_NEW_CLIENT_INSTANTIATED),
CDEF(LWS_CALLBACK_HTTP),
CDEF(LWS_CALLBACK_HTTP_BODY),
CDEF(LWS_CALLBACK_HTTP_BODY_COMPLETION),
CDEF(LWS_CALLBACK_HTTP_FILE_COMPLETION),
CDEF(LWS_CALLBACK_HTTP_WRITEABLE),
CDEF(LWS_CALLBACK_CLOSED_HTTP),
CDEF(LWS_CALLBACK_FILTER_HTTP_CONNECTION),
CDEF(LWS_CALLBACK_ADD_HEADERS),
CDEF(LWS_CALLBACK_CHECK_ACCESS_RIGHTS),
CDEF(LWS_CALLBACK_PROCESS_HTML),
CDEF(LWS_CALLBACK_HTTP_BIND_PROTOCOL),
CDEF(LWS_CALLBACK_HTTP_DROP_PROTOCOL),
CDEF(LWS_CALLBACK_HTTP_CONFIRM_UPGRADE),
CDEF(LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP),
CDEF(LWS_CALLBACK_CLOSED_CLIENT_HTTP),
CDEF(LWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ),
CDEF(LWS_CALLBACK_RECEIVE_CLIENT_HTTP),
CDEF(LWS_CALLBACK_COMPLETED_CLIENT_HTTP),
CDEF(LWS_CALLBACK_CLIENT_HTTP_WRITEABLE),
CDEF(LWS_CALLBACK_CLIENT_HTTP_BIND_PROTOCOL),
CDEF(LWS_CALLBACK_CLIENT_HTTP_DROP_PROTOCOL),
CDEF(LWS_CALLBACK_ESTABLISHED),
CDEF(LWS_CALLBACK_CLOSED),
CDEF(LWS_CALLBACK_SERVER_WRITEABLE),
CDEF(LWS_CALLBACK_RECEIVE),
CDEF(LWS_CALLBACK_RECEIVE_PONG),
CDEF(LWS_CALLBACK_WS_PEER_INITIATED_CLOSE),
CDEF(LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION),
CDEF(LWS_CALLBACK_CONFIRM_EXTENSION_OKAY),
CDEF(LWS_CALLBACK_WS_SERVER_BIND_PROTOCOL),
CDEF(LWS_CALLBACK_WS_SERVER_DROP_PROTOCOL),
CDEF(LWS_CALLBACK_CLIENT_CONNECTION_ERROR),
CDEF(LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH),
CDEF(LWS_CALLBACK_CLIENT_ESTABLISHED),
CDEF(LWS_CALLBACK_CLIENT_CLOSED),
CDEF(LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER),
CDEF(LWS_CALLBACK_CLIENT_RECEIVE),
CDEF(LWS_CALLBACK_CLIENT_RECEIVE_PONG),
CDEF(LWS_CALLBACK_CLIENT_WRITEABLE),
CDEF(LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED),
CDEF(LWS_CALLBACK_WS_EXT_DEFAULTS),
CDEF(LWS_CALLBACK_FILTER_NETWORK_CONNECTION),
CDEF(LWS_CALLBACK_WS_CLIENT_BIND_PROTOCOL),
CDEF(LWS_CALLBACK_WS_CLIENT_DROP_PROTOCOL),
CDEF(LWS_CALLBACK_GET_THREAD_ID),
CDEF(LWS_CALLBACK_ADD_POLL_FD),
CDEF(LWS_CALLBACK_DEL_POLL_FD),
CDEF(LWS_CALLBACK_CHANGE_MODE_POLL_FD),
CDEF(LWS_CALLBACK_LOCK_POLL),
CDEF(LWS_CALLBACK_UNLOCK_POLL),
CDEF(LWS_CALLBACK_CGI),
CDEF(LWS_CALLBACK_CGI_TERMINATED),
CDEF(LWS_CALLBACK_CGI_STDIN_DATA),
CDEF(LWS_CALLBACK_CGI_STDIN_COMPLETED),
CDEF(LWS_CALLBACK_CGI_PROCESS_ATTACH),
CDEF(LWS_CALLBACK_SESSION_INFO),
CDEF(LWS_CALLBACK_GS_EVENT),
CDEF(LWS_CALLBACK_HTTP_PMO),
CDEF(LWS_CALLBACK_RAW_RX),
CDEF(LWS_CALLBACK_RAW_CLOSE),
CDEF(LWS_CALLBACK_RAW_WRITEABLE),
CDEF(LWS_CALLBACK_RAW_ADOPT),
CDEF(LWS_CALLBACK_RAW_SKT_BIND_PROTOCOL),
CDEF(LWS_CALLBACK_RAW_SKT_DROP_PROTOCOL),
CDEF(LWS_CALLBACK_RAW_ADOPT_FILE),
CDEF(LWS_CALLBACK_RAW_RX_FILE),
CDEF(LWS_CALLBACK_RAW_WRITEABLE_FILE),
CDEF(LWS_CALLBACK_RAW_CLOSE_FILE),
CDEF(LWS_CALLBACK_RAW_FILE_BIND_PROTOCOL),
CDEF(LWS_CALLBACK_RAW_FILE_DROP_PROTOCOL),
CDEF(LWS_CALLBACK_TIMER),
CDEF(LWS_CALLBACK_EVENT_WAIT_CANCELLED),
CDEF(LWS_CALLBACK_CHILD_CLOSING),
CDEF(LWS_CALLBACK_VHOST_CERT_AGING),
CDEF(LWS_CALLBACK_VHOST_CERT_UPDATE),
CDEF(LWS_CALLBACK_USER),
CDEF(LWS_POLLHUP),
CDEF(LWS_POLLIN),
CDEF(LWS_POLLOUT),
JS_CFUNC_DEF("decode_utf8", 1, js_decode_utf8),
JS_CFUNC_DEF("set_log_level", 1, js_lws_set_log_level),
JS_CFUNC_DEF("create_context", 2, js_lws_create_context),
};
static const JSClassDef js_lws_context_class = {
"Context",
.finalizer = js_lws_context_finalizer,
.gc_mark = js_lws_context_mark,
};
static const JSCFunctionListEntry js_lws_context_proto_funcs[] = {
JS_CGETSET_DEF("connections", js_lws_context_get_connections, NULL),
JS_CFUNC_DEF("client_connect", 8, js_lws_client_connect),
JS_CFUNC_DEF("service_fd", 3, js_lws_service_fd),
JS_CFUNC_DEF("service_periodic", 0, js_lws_service_periodic),
};
static const JSClassDef js_lws_wsi_class = {
"WSI",
.finalizer = js_lws_wsi_finalizer,
.gc_mark = js_lws_wsi_mark,
};
#define HDRGET(name) JS_CGETSET_MAGIC_DEF(#name, js_lws_wsi_get_hdr, NULL, name)
static const JSCFunctionListEntry js_lws_wsi_proto_funcs[] = {
JS_CGETSET_DEF("context", js_lws_wsi_get_context, NULL),
JS_CGETSET_DEF("user", js_lws_wsi_get_user, NULL),
HDRGET(WSI_TOKEN_GET_URI),
HDRGET(WSI_TOKEN_POST_URI),
HDRGET(WSI_TOKEN_OPTIONS_URI),
HDRGET(WSI_TOKEN_HOST),
HDRGET(WSI_TOKEN_CONNECTION),
HDRGET(WSI_TOKEN_UPGRADE),
HDRGET(WSI_TOKEN_ORIGIN),
HDRGET(WSI_TOKEN_DRAFT),
HDRGET(WSI_TOKEN_CHALLENGE),
HDRGET(WSI_TOKEN_EXTENSIONS),
HDRGET(WSI_TOKEN_KEY1),
HDRGET(WSI_TOKEN_KEY2),
HDRGET(WSI_TOKEN_PROTOCOL),
HDRGET(WSI_TOKEN_ACCEPT),
HDRGET(WSI_TOKEN_NONCE),
HDRGET(WSI_TOKEN_HTTP),
HDRGET(WSI_TOKEN_HTTP2_SETTINGS),
HDRGET(WSI_TOKEN_HTTP_ACCEPT),
HDRGET(WSI_TOKEN_HTTP_AC_REQUEST_HEADERS),
HDRGET(WSI_TOKEN_HTTP_IF_MODIFIED_SINCE),
HDRGET(WSI_TOKEN_HTTP_IF_NONE_MATCH),
HDRGET(WSI_TOKEN_HTTP_ACCEPT_ENCODING),
HDRGET(WSI_TOKEN_HTTP_ACCEPT_LANGUAGE),
HDRGET(WSI_TOKEN_HTTP_PRAGMA),
HDRGET(WSI_TOKEN_HTTP_CACHE_CONTROL),
HDRGET(WSI_TOKEN_HTTP_AUTHORIZATION),
HDRGET(WSI_TOKEN_HTTP_COOKIE),
HDRGET(WSI_TOKEN_HTTP_CONTENT_LENGTH),
HDRGET(WSI_TOKEN_HTTP_CONTENT_TYPE),
HDRGET(WSI_TOKEN_HTTP_DATE),
HDRGET(WSI_TOKEN_HTTP_RANGE),
HDRGET(WSI_TOKEN_HTTP_REFERER),
HDRGET(WSI_TOKEN_KEY),
HDRGET(WSI_TOKEN_VERSION),
HDRGET(WSI_TOKEN_SWORIGIN),
HDRGET(WSI_TOKEN_HTTP_COLON_AUTHORITY),
HDRGET(WSI_TOKEN_HTTP_COLON_METHOD),
HDRGET(WSI_TOKEN_HTTP_COLON_PATH),
HDRGET(WSI_TOKEN_HTTP_COLON_SCHEME),
HDRGET(WSI_TOKEN_HTTP_COLON_STATUS),
HDRGET(WSI_TOKEN_HTTP_ACCEPT_CHARSET),
HDRGET(WSI_TOKEN_HTTP_ACCEPT_RANGES),
HDRGET(WSI_TOKEN_HTTP_ACCESS_CONTROL_ALLOW_ORIGIN),
HDRGET(WSI_TOKEN_HTTP_AGE),
HDRGET(WSI_TOKEN_HTTP_ALLOW),
HDRGET(WSI_TOKEN_HTTP_CONTENT_DISPOSITION),
HDRGET(WSI_TOKEN_HTTP_CONTENT_ENCODING),
HDRGET(WSI_TOKEN_HTTP_CONTENT_LANGUAGE),
HDRGET(WSI_TOKEN_HTTP_CONTENT_LOCATION),
HDRGET(WSI_TOKEN_HTTP_CONTENT_RANGE),
HDRGET(WSI_TOKEN_HTTP_ETAG),
HDRGET(WSI_TOKEN_HTTP_EXPECT),
HDRGET(WSI_TOKEN_HTTP_EXPIRES),
HDRGET(WSI_TOKEN_HTTP_FROM),
HDRGET(WSI_TOKEN_HTTP_IF_MATCH),
HDRGET(WSI_TOKEN_HTTP_IF_RANGE),
HDRGET(WSI_TOKEN_HTTP_IF_UNMODIFIED_SINCE),
HDRGET(WSI_TOKEN_HTTP_LAST_MODIFIED),
HDRGET(WSI_TOKEN_HTTP_LINK),
HDRGET(WSI_TOKEN_HTTP_LOCATION),
HDRGET(WSI_TOKEN_HTTP_MAX_FORWARDS),
HDRGET(WSI_TOKEN_HTTP_PROXY_AUTHENTICATE),
HDRGET(WSI_TOKEN_HTTP_PROXY_AUTHORIZATION),
HDRGET(WSI_TOKEN_HTTP_REFRESH),
HDRGET(WSI_TOKEN_HTTP_RETRY_AFTER),
HDRGET(WSI_TOKEN_HTTP_SERVER),
HDRGET(WSI_TOKEN_HTTP_SET_COOKIE),
HDRGET(WSI_TOKEN_HTTP_STRICT_TRANSPORT_SECURITY),
HDRGET(WSI_TOKEN_HTTP_TRANSFER_ENCODING),
HDRGET(WSI_TOKEN_HTTP_USER_AGENT),
HDRGET(WSI_TOKEN_HTTP_VARY),
HDRGET(WSI_TOKEN_HTTP_VIA),
HDRGET(WSI_TOKEN_HTTP_WWW_AUTHENTICATE),
HDRGET(WSI_TOKEN_PATCH_URI),
HDRGET(WSI_TOKEN_PUT_URI),
HDRGET(WSI_TOKEN_DELETE_URI),
HDRGET(WSI_TOKEN_HTTP_URI_ARGS),
HDRGET(WSI_TOKEN_PROXY),
HDRGET(WSI_TOKEN_HTTP_X_REAL_IP),
HDRGET(WSI_TOKEN_HTTP1_0),
HDRGET(WSI_TOKEN_X_FORWARDED_FOR),
HDRGET(WSI_TOKEN_CONNECT),
HDRGET(WSI_TOKEN_HEAD_URI),
HDRGET(WSI_TOKEN_TE),
HDRGET(WSI_TOKEN_REPLAY_NONCE),
HDRGET(WSI_TOKEN_COLON_PROTOCOL),
HDRGET(WSI_TOKEN_X_AUTH_TOKEN),
JS_CFUNC_DEF("is_final_fragment", 0, js_lws_is_final_fragment),
JS_CFUNC_DEF("is_first_fragment", 0, js_lws_is_first_fragment),
JS_CFUNC_DEF("frame_is_binary", 0, js_lws_frame_is_binary),
JS_CFUNC_DEF("callback_on_writable", 0, js_lws_callback_on_writable),
JS_CFUNC_DEF("write", 1, js_lws_write),
JS_CFUNC_DEF("close_reason", 2, js_lws_close_reason),
};
static int js_lws_init(JSContext *ctx, JSModuleDef *m)
{
JSValue proto;
JS_NewClassID(&js_lws_context_class_id);
JS_NewClass(JS_GetRuntime(ctx), js_lws_context_class_id,
&js_lws_context_class);
proto = JS_NewObject(ctx);
JS_SetPropertyFunctionList(ctx, proto, js_lws_context_proto_funcs,
countof(js_lws_context_proto_funcs));
JS_SetClassProto(ctx, js_lws_context_class_id, proto);
JS_NewClassID(&js_lws_wsi_class_id);
JS_NewClass(JS_GetRuntime(ctx), js_lws_wsi_class_id, &js_lws_wsi_class);
proto = JS_NewObject(ctx);
JS_SetPropertyFunctionList(ctx, proto, js_lws_wsi_proto_funcs,
countof(js_lws_wsi_proto_funcs));
JS_SetClassProto(ctx, js_lws_wsi_class_id, proto);
return JS_SetModuleExportList(ctx, m, js_lws_funcs, countof(js_lws_funcs));
}
JSModuleDef *js_init_module(JSContext *ctx, const char *module_name)
{
JSModuleDef *m = JS_NewCModule(ctx, module_name, js_lws_init);
if (m == NULL)
return NULL;
JS_AddModuleExportList(ctx, m, js_lws_funcs, countof(js_lws_funcs));
return m;
}

View File

@@ -1,415 +0,0 @@
/*
* Copyright (c) 2020 Genexis B.V.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import * as os from 'os'
import * as lws from './lws-client.so'
const CONNECTING = 0
const OPEN = 1
const CLOSING = 2
const CLOSED = 3
const CLOSING1 = 0x10 | CLOSING
const CLOSING2 = 0x20 | CLOSING
function serviceScheduler (context) {
let running = false
let timeout = null
function schedule (time) {
if (timeout) os.clearTimeout(timeout)
timeout = running ? os.setTimeout(callback, time) : null
}
function callback () {
schedule(context.service_periodic())
}
return {
start: function () {
running = true
schedule(0)
},
stop: function () {
running = false
schedule(0)
},
reschedule: schedule
}
}
function fdHandler (fd, events, revents) {
return function () {
service.reschedule(context.service_fd(fd, events, revents))
}
}
function contextCallback (wsi, reason, arg) {
switch (reason) {
case lws.LWS_CALLBACK_ADD_POLL_FD:
service.start()
// fallthrough
case lws.LWS_CALLBACK_CHANGE_MODE_POLL_FD:
os.setReadHandler(
arg.fd,
(arg.events & lws.LWS_POLLIN)
? fdHandler(arg.fd, arg.events, lws.LWS_POLLIN)
: null
)
os.setWriteHandler(
arg.fd,
(arg.events & lws.LWS_POLLOUT)
? fdHandler(arg.fd, arg.events, lws.LWS_POLLOUT)
: null
)
break
case lws.LWS_CALLBACK_DEL_POLL_FD:
os.setReadHandler(arg.fd, null)
os.setWriteHandler(arg.fd, null)
break
case lws.LWS_CALLBACK_CLIENT_CONNECTION_ERROR:
wsi.user.error(typeof arg === 'string' ? arg : '')
break
case lws.LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH:
if (wsi.user.readyState !== CONNECTING) {
return -1
}
wsi.user.protocol = wsi.WSI_TOKEN_PROTOCOL
wsi.user.extensions = wsi.WSI_TOKEN_EXTENSIONS
break
case lws.LWS_CALLBACK_CLIENT_ESTABLISHED:
if (wsi.user.readyState !== CONNECTING) {
return -1
}
wsi.user.wsi = wsi
wsi.user.open()
break
case lws.LWS_CALLBACK_WS_PEER_INITIATED_CLOSE:
if (wsi.user.readyState === CLOSED) {
return -1
}
if (arg instanceof Array) {
wsi.user.closeEvent.code = arg[0]
wsi.user.closeEvent.reason = arg[1]
} else {
wsi.user.closeEvent.code = 1005
wsi.user.closeEvent.reason = ''
}
wsi.user.readyState = CLOSING2
break
case lws.LWS_CALLBACK_CLIENT_CLOSED:
wsi.user.close()
break
case lws.LWS_CALLBACK_CLIENT_RECEIVE:
if (!(arg instanceof ArrayBuffer) ||
wsi.user.readyState === CONNECTING ||
wsi.user.readyState === CLOSED) {
return -1
}
if (wsi.is_first_fragment()) {
wsi.user.inbuf = []
}
wsi.user.inbuf.push(arg)
if (wsi.is_final_fragment()) {
wsi.user.message(wsi.frame_is_binary())
}
break
case lws.LWS_CALLBACK_CLIENT_WRITEABLE:
if ((wsi.user.readyState === OPEN || wsi.user.readyState === CLOSING1) &&
wsi.user.outbuf.length > 0) {
const msg = wsi.user.outbuf.shift()
if (msg === null) {
wsi.user.readyState = CLOSING2
return -1
}
wsi.write(msg)
if (wsi.user.outbuf.length > 0) {
wsi.callback_on_writable()
}
}
break
case lws.LWS_CALLBACK_WSI_DESTROY:
if (wsi.context.connections === 0) service.stop()
break
}
return 0
}
lws.set_log_level(lws.LLL_ERR | lws.LLL_WARN)
const context = lws.create_context(contextCallback, true)
const service = serviceScheduler(context)
function arrayBufferJoin (bufs) {
if (!(bufs instanceof Array)) {
throw new TypeError('Array expected')
}
if (!bufs.every(function (val) { return val instanceof ArrayBuffer })) {
throw new TypeError('ArrayBuffer expected')
}
const len = bufs.reduce(function (acc, val) {
return acc + val.byteLength
}, 0)
const array = new Uint8Array(len)
let offset = 0
for (const b of bufs) {
array.set(new Uint8Array(b), offset)
offset += b.byteLength
}
return array.buffer
}
export function WebSocket (url, protocols) {
const pattern = /^(ws|wss):\/\/([^/?#]*)([^#]*)$/i
const match = pattern.exec(url)
if (match === null) {
throw new TypeError('invalid WebSocket URL')
}
const secure = match[1].toLowerCase() === 'wss'
const host = match[2]
const path = match[3].startsWith('/') ? match[3] : '/' + match[3]
const hostPattern = /^(?:([a-z\d.-]+)|\[([\da-f:]+:[\da-f.]*)\])(?::(\d*))?$/i
const hostMatch = hostPattern.exec(host)
if (hostMatch === null) {
throw new TypeError('invalid WebSocket URL')
}
const address = hostMatch[1] || hostMatch[2]
const port = hostMatch[3] ? parseInt(hostMatch[3]) : (secure ? 443 : 80)
const validPath = /^\/[A-Za-z0-9_.!~*'()%:@&=+$,;/?-]*$/
if (!validPath.test(path)) {
throw new TypeError('invalid WebSocket URL')
}
if (!(port >= 1 && port <= 65535)) {
throw new RangeError('port must be between 1 and 65535')
}
if (protocols === undefined) {
protocols = []
} else if (!(protocols instanceof Array)) {
protocols = [protocols]
}
const validProto = /^[A-Za-z0-9!#$%&'*+.^_|~-]+$/
if (!protocols.every(function (val) { return validProto.test(val) })) {
throw new TypeError('invalid WebSocket subprotocol name')
}
const proto = protocols.length > 0 ? protocols.join(', ') : null
const self = this
const state = {
url: url,
readyState: CONNECTING,
extensions: '',
protocol: '',
onopen: null,
onerror: null,
onclose: null,
onmessage: null,
wsi: null,
inbuf: [],
outbuf: [],
closeEvent: {
type: 'close',
code: 1005,
reason: '',
wasClean: false
},
open: function () {
if (state.readyState === CONNECTING) {
state.readyState = OPEN
if (state.onopen) {
state.onopen.call(self, { type: 'open' })
}
}
},
error: function (e) {
if (state.readyState !== CLOSED) {
state.closeEvent.code = 1006
state.closeEvent.reason = String(e)
state.readyState = CLOSED
try {
if (state.onerror) {
state.onerror.call(self, { type: 'error' })
}
} finally {
if (state.onclose) {
state.onclose.call(self, Object.assign({}, state.closeEvent))
}
}
}
},
close: function () {
if (state.readyState !== CLOSED) {
state.closeEvent.wasClean = true
state.readyState = CLOSED
if (state.onclose) {
state.onclose.call(self, Object.assign({}, state.closeEvent))
}
}
},
message: function (binary) {
if (state.inbuf.length > 0) {
const msg = state.inbuf.length === 1
? state.inbuf[0]
: arrayBufferJoin(state.inbuf)
state.inbuf = []
if (state.readyState === OPEN && state.onmessage) {
state.onmessage.call(self, {
type: 'messasge',
data: binary ? msg : lws.decode_utf8(msg)
})
}
}
}
}
this._wsState = state
os.setTimeout(function () {
try {
context.client_connect(
address, port, secure, path, host, null, proto, state
)
} catch (e) {
state.error(e)
}
}, 0)
}
const readyStateConstants = {
CONNECTING: { value: CONNECTING },
OPEN: { value: OPEN },
CLOSING: { value: CLOSING },
CLOSED: { value: CLOSED }
}
Object.defineProperties(WebSocket, readyStateConstants)
Object.defineProperties(WebSocket.prototype, readyStateConstants)
function checkNullOrFunction (val) {
if (val !== null && typeof val !== 'function') {
throw new TypeError('null or Function expected')
}
}
Object.defineProperties(WebSocket.prototype, {
url: { get: function () { return this._wsState.url } },
readyState: { get: function () { return this._wsState.readyState & 0xf } },
extensions: { get: function () { return this._wsState.extensions } },
protocol: { get: function () { return this._wsState.protocol } },
bufferedAmount: {
get: function () {
return this._wsState.outbuf.reduce(function (acc, val) {
if (val instanceof ArrayBuffer) {
acc += val.byteLength
} else if (typeof val === 'string') {
acc += val.length
}
return acc
}, 0)
}
},
binaryType: {
get: function () { return 'arraybuffer' },
set: function (val) {
if (val !== 'arraybuffer') {
throw new TypeError('only "arraybuffer" allowed for "binaryType"')
}
}
},
onopen: {
get: function () { return this._wsState.onopen },
set: function (val) {
checkNullOrFunction(val)
this._wsState.onopen = val
}
},
onerror: {
get: function () { return this._wsState.onerror },
set: function (val) {
checkNullOrFunction(val)
this._wsState.onerror = val
}
},
onclose: {
get: function () { return this._wsState.onclose },
set: function (val) {
checkNullOrFunction(val)
this._wsState.onclose = val
}
},
onmessage: {
get: function () { return this._wsState.onmessage },
set: function (val) {
checkNullOrFunction(val)
this._wsState.onmessage = val
}
}
})
WebSocket.prototype.close = function (code, reason) {
if (code !== undefined) {
code = Math.trunc(code)
reason = reason === undefined ? '' : String(reason)
if (code !== 1000 && !(code >= 3000 && code <= 4999)) {
throw new RangeError('code must be 1000 or between 3000 and 4999')
}
}
const state = this._wsState
if (state.readyState === OPEN) {
if (code !== undefined) {
state.wsi.close_reason(code, reason)
state.closeEvent.code = code
state.closeEvent.reason = reason
}
state.readyState = CLOSING1
state.outbuf.push(null)
state.wsi.callback_on_writable()
} else if (state.readyState === CONNECTING) {
state.readyState = CLOSING2
}
}
WebSocket.prototype.send = function (msg) {
const state = this._wsState
if (state.readyState === CONNECTING) {
throw new TypeError('send() not allowed in CONNECTING state')
}
if (msg instanceof ArrayBuffer) {
state.outbuf.push(msg.slice(0))
} else if (ArrayBuffer.isView(msg)) {
state.outbuf.push(
msg.buffer.slice(msg.byteOffset, msg.byteOffset + msg.byteLength)
)
} else {
state.outbuf.push(String(msg))
}
if (state.readyState === OPEN) {
state.wsi.callback_on_writable()
}
}

View File

@@ -1,55 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=quickjs
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/bellard/quickjs.git
PKG_SOURCE_DATE:=2020-11-08
PKG_SOURCE_VERSION:=204682fb87ab9312f0cf81f959ecd181180457bc
PKG_MIRROR_HASH:=skip
PKG_LICENSE:=MIT
PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
define Package/quickjs
SECTION:=lang
CATEGORY:=Languages
TITLE:=QuickJS Javascript engine
URL:=https://bellard.org/quickjs/
MAINTAINER:=Erik Karlsson <erik.karlsson@genexis.eu>
DEPENDS:=+libatomic
endef
define Package/quickjs/description
QuickJS is a small and embeddable Javascript engine. It supports
the ES2020 specification including modules, asynchronous
generators, proxies and BigInt.
endef
MAKE_VARS += \
LIBS="-latomic"
MAKE_FLAGS = \
prefix=/usr \
CONFIG_SMALL=y \
CROSS_PREFIX="$(TARGET_CROSS)"
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/lib/quickjs
$(CP) $(PKG_INSTALL_DIR)/usr/lib/quickjs/libquickjs.a $(1)/usr/lib/quickjs/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/quickjs/libquickjs.lto.a $(1)/usr/lib/quickjs/
$(INSTALL_DIR) $(1)/usr/include/quickjs
$(CP) $(PKG_INSTALL_DIR)/usr/include/quickjs/quickjs.h $(1)/usr/include/quickjs/
$(CP) $(PKG_INSTALL_DIR)/usr/include/quickjs/quickjs-libc.h $(1)/usr/include/quickjs/
endef
define Package/quickjs/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/qjs $(1)/usr/bin/
endef
$(eval $(call BuildPackage,quickjs))

View File

@@ -1,96 +0,0 @@
diff --git a/Makefile b/Makefile
index e6ae827..bbd3ce8 100644
--- a/Makefile
+++ b/Makefile
@@ -33,6 +33,8 @@ CONFIG_LTO=y
#CONFIG_WERROR=y
# force 32 bit build for some utilities
#CONFIG_M32=y
+# build with -Os instead of -O2
+#CONFIG_SMALL=y
ifdef CONFIG_DARWIN
# use clang instead of gcc
@@ -52,6 +54,13 @@ CONFIG_BIGNUM=y
OBJDIR=.obj
+CFLAGS_ENV:=$(CFLAGS)
+LDFLAGS_ENV:=$(LDFLAGS)
+
+HOST_BUILD=
+CFLAGS=$(if $(HOST_BUILD),,$(CFLAGS_ENV))
+LDFLAGS=$(if $(HOST_BUILD),,$(LDFLAGS_ENV))
+
ifdef CONFIG_WIN32
ifdef CONFIG_M32
CROSS_PREFIX=i686-w64-mingw32-
@@ -66,7 +75,7 @@ endif
ifdef CONFIG_CLANG
HOST_CC=clang
CC=$(CROSS_PREFIX)clang
- CFLAGS=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d
+ CFLAGS += -g -Wall -MMD -MF $(OBJDIR)/$(@F).d
CFLAGS += -Wextra
CFLAGS += -Wno-sign-compare
CFLAGS += -Wno-missing-field-initializers
@@ -87,7 +96,7 @@ ifdef CONFIG_CLANG
else
HOST_CC=gcc
CC=$(CROSS_PREFIX)gcc
- CFLAGS=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d
+ CFLAGS += -g -Wall -MMD -MF $(OBJDIR)/$(@F).d
CFLAGS += -Wno-array-bounds -Wno-format-truncation
ifdef CONFIG_LTO
AR=$(CROSS_PREFIX)gcc-ar
@@ -110,9 +119,13 @@ endif
CFLAGS+=$(DEFINES)
CFLAGS_DEBUG=$(CFLAGS) -O0
CFLAGS_SMALL=$(CFLAGS) -Os
+ifdef CONFIG_SMALL
+CFLAGS_OPT=$(CFLAGS) -Os
+else
CFLAGS_OPT=$(CFLAGS) -O2
+endif
CFLAGS_NOLTO:=$(CFLAGS_OPT)
-LDFLAGS=-g
+LDFLAGS+=-g
ifdef CONFIG_LTO
CFLAGS_SMALL+=-flto
CFLAGS_OPT+=-flto
@@ -175,7 +188,7 @@ QJS_OBJS+=$(OBJDIR)/qjscalc.o
endif
HOST_LIBS=-lm -ldl -lpthread
-LIBS=-lm
+LIBS+=-lm
ifndef CONFIG_WIN32
LIBS+=-ldl -lpthread
endif
@@ -194,6 +207,8 @@ qjsc$(EXE): $(OBJDIR)/qjsc.o $(QJS_LIB_OBJS)
ifneq ($(CROSS_PREFIX),)
+$(QJSC): HOST_BUILD=1
+
$(QJSC): $(OBJDIR)/qjsc.host.o \
$(patsubst %.o, %.host.o, $(QJS_LIB_OBJS))
$(HOST_CC) $(LDFLAGS) -o $@ $^ $(HOST_LIBS)
@@ -261,6 +276,8 @@ run-test262-32: $(patsubst %.o, %.m32.o, $(OBJDIR)/run-test262.o $(QJS_LIB_OBJS)
$(OBJDIR)/%.o: %.c | $(OBJDIR)
$(CC) $(CFLAGS_OPT) -c -o $@ $<
+$(OBJDIR)/%.host.o: HOST_BUILD=1
+
$(OBJDIR)/%.host.o: %.c | $(OBJDIR)
$(HOST_CC) $(CFLAGS_OPT) -c -o $@ $<
@@ -285,6 +302,8 @@ $(OBJDIR)/%.check.o: %.c | $(OBJDIR)
regexp_test: libregexp.c libunicode.c cutils.c
$(CC) $(LDFLAGS) $(CFLAGS) -DTEST -o $@ libregexp.c libunicode.c cutils.c $(LIBS)
+unicode_gen: HOST_BUILD=1
+
unicode_gen: $(OBJDIR)/unicode_gen.host.o $(OBJDIR)/cutils.host.o libunicode.c unicode_gen_def.h
$(HOST_CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJDIR)/unicode_gen.host.o $(OBJDIR)/cutils.host.o

View File

@@ -1,106 +0,0 @@
diff --git a/quickjs.c b/quickjs.c
index a39ff8f..635c506 100644
--- a/quickjs.c
+++ b/quickjs.c
@@ -65,6 +65,16 @@
#define CONFIG_PRINTF_RNDN
#endif
+#ifdef CONFIG_PRINTF_RNDN
+#if !defined(FE_DOWNWARD) || !defined(FE_UPWARD)
+#ifdef CONFIG_BIGNUM
+#define CONFIG_DTOA_LIBBF
+#else
+#error "CONFIG_BIGNUM required if printf is RNDN and there is no fenv support"
+#endif
+#endif
+#endif
+
/* define to include Atomics.* operations which depend on the OS
threads */
#if !defined(EMSCRIPTEN)
@@ -11253,6 +11263,11 @@ static char *i64toa(char *buf_end, int64_t n, unsigned int base)
return q;
}
+/* maximum buffer size for js_dtoa */
+#define JS_DTOA_BUF_SIZE 128
+
+#ifndef CONFIG_DTOA_LIBBF
+
/* buf1 contains the printf result */
static void js_ecvt1(double d, int n_digits, int *decpt, int *sign, char *buf,
int rounding_mode, char *buf1, int buf1_size)
@@ -11272,9 +11287,6 @@ static void js_ecvt1(double d, int n_digits, int *decpt, int *sign, char *buf,
*decpt = atoi(buf1 + n_digits + 2 + (n_digits > 1)) + 1;
}
-/* maximum buffer size for js_dtoa */
-#define JS_DTOA_BUF_SIZE 128
-
/* needed because ecvt usually limits the number of digits to
17. Return the number of digits. */
static int js_ecvt(double d, int n_digits, int *decpt, int *sign, char *buf,
@@ -11383,6 +11395,8 @@ static void js_fcvt(char *buf, int buf_size, double d, int n_digits)
js_fcvt1(buf, buf_size, d, n_digits, rounding_mode);
}
+#endif /* CONFIG_DTOA_LIBBF */
+
/* radix != 10 is only supported with flags = JS_DTOA_VAR_FORMAT */
/* use as many digits as necessary */
#define JS_DTOA_VAR_FORMAT (0 << 0)
@@ -11396,8 +11410,10 @@ static void js_fcvt(char *buf, int buf_size, double d, int n_digits)
/* XXX: slow and maybe not fully correct. Use libbf when it is fast enough.
XXX: radix != 10 is only supported for small integers
*/
-static void js_dtoa1(char *buf, double d, int radix, int n_digits, int flags)
+static JSValue js_dtoa(JSContext *ctx,
+ double d, int radix, int n_digits, int flags)
{
+ char buf[JS_DTOA_BUF_SIZE];
char *q;
if (!isfinite(d)) {
@@ -11419,6 +11435,25 @@ static void js_dtoa1(char *buf, double d, int radix, int n_digits, int flags)
ptr = i64toa(buf1 + sizeof(buf1), i64, radix);
strcpy(buf, ptr);
} else {
+#ifdef CONFIG_DTOA_LIBBF
+ bf_flags_t bf_flags;
+ generic_conv:
+ bf_flags = BF_RNDNA;
+ switch (flags & 3) {
+ case JS_DTOA_VAR_FORMAT:
+ bf_flags |= BF_FTOA_FORMAT_FREE_MIN;
+ break;
+ case JS_DTOA_FIXED_FORMAT:
+ bf_flags |= BF_FTOA_FORMAT_FIXED;
+ break;
+ case JS_DTOA_FRAC_FORMAT:
+ bf_flags |= BF_FTOA_FORMAT_FRAC;
+ break;
+ }
+ if (flags & JS_DTOA_FORCE_EXP)
+ bf_flags |= BF_FTOA_FORCE_EXP;
+ return js_ftoa(ctx, JS_NewFloat64(ctx, d), radix, n_digits, bf_flags);
+#else /* CONFIG_DTOA_LIBBF */
if (d == 0.0)
d = 0.0; /* convert -0 to 0 */
if (flags == JS_DTOA_FRAC_FORMAT) {
@@ -11482,14 +11517,8 @@ static void js_dtoa1(char *buf, double d, int radix, int n_digits, int flags)
sprintf(q, "%d", p);
}
}
+#endif /* CONFIG_DTOA_LIBBF */
}
-}
-
-static JSValue js_dtoa(JSContext *ctx,
- double d, int radix, int n_digits, int flags)
-{
- char buf[JS_DTOA_BUF_SIZE];
- js_dtoa1(buf, d, radix, n_digits, flags);
return JS_NewString(ctx, buf);
}

View File

@@ -5,14 +5,14 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=rulengd PKG_NAME:=rulengd
PKG_VERSION:=1.2.6 PKG_VERSION:=1.2.3
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_BUILD_PARALLEL:=1 PKG_BUILD_PARALLEL:=1
PKG_INSTALL:=1 PKG_INSTALL:=1
PKG_SOURCE_PROTO=git PKG_SOURCE_PROTO=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/rulengd.git PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/rulengd.git
PKG_SOURCE_VERSION:=e323bebe85cd7fb4eeb6cee535188227bc9b81e3 PKG_SOURCE_VERSION:=f5ded45562189a05f3912182d708bcb1427912f8
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip PKG_MIRROR_HASH:=skip
PKG_SOURCE_SUBDIR:=${PKG_NAME}-${PKG_VERSION} PKG_SOURCE_SUBDIR:=${PKG_NAME}-${PKG_VERSION}

View File

@@ -8,9 +8,9 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=stunc PKG_NAME:=stunc
PKG_VERSION:=1.0.4 PKG_VERSION:=1.0.2
PKG_SOURCE_VERSION:=9c585888cae94180d715f46f6602090f328240d4 PKG_SOURCE_VERSION:=d578df0c8e4e7d1b642a5cf037ce468379270534
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/stunc.git PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/stunc.git

View File

@@ -5,11 +5,11 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=sulu PKG_NAME:=sulu
PKG_VERSION:=0.2.29 PKG_VERSION:=0.2.20
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/sulu.git PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/sulu.git
PKG_SOURCE_VERSION:=5c722ca387ffdd28ac2a2e01f27dba12015fc2e7 PKG_SOURCE_VERSION:=1cb1723f36718997968e923732fd6327a354689a
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_SOURCE_VERSION) PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_SOURCE_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz
@@ -37,10 +37,7 @@ endef
define Package/sulu/install define Package/sulu/install
$(INSTALL_DIR) $(1)/sulu $(INSTALL_DIR) $(1)/sulu
$(INSTALL_DIR) $(1)/sulu/config
$(INSTALL_DIR) $(1)/etc/nginx/
$(CP) $(PKG_BUILD_DIR)/dist/* $(1)/sulu $(CP) $(PKG_BUILD_DIR)/dist/* $(1)/sulu
$(CP) $(PKG_BUILD_DIR)/config/* $(1)/sulu/config
$(CP) ./files/* $(1)/ $(CP) ./files/* $(1)/
endef endef

View File

@@ -9,9 +9,45 @@ log() {
echo "${@}"|logger -t sulu.init -p debug echo "${@}"|logger -t sulu.init -p debug
} }
publish_endpoint() {
local AgentEndpointID serial oui user pass
local opt=""
# return if mosquitto_pub is not present
if ! which mosquitto_pub; then
log "mosquitto_pub not present can't publish endpointid"
return 0;
fi
ubus -t 10 wait_for usp.raw
# Get endpoint id from obuspa config first
config_load obuspa
config_get AgentEndpointID localagent EndpointID ""
if [ -z "${AgentEndpointID}" ]; then
serial=$(ubus -t 1 call usp.raw get '{"path":"Device.DeviceInfo.SerialNumber"}'|jsonfilter -e '@["parameters"][0].value')
oui=$(ubus -t 1 call usp.raw get '{"path":"Device.DeviceInfo.ManufacturerOUI"}'|jsonfilter -e '@["parameters"][0].value')
AgentEndpointID="os::${oui}-${serial}"
fi
config_get user localmqtt Username
if [ -n "${user}" ]; then
opt="-u ${user}"
fi
config_get pass localmqtt Password
if [ -n "${pass}" ]; then
opt="${opt} -P ${pass}"
fi
# publish Agent's EndpointID in mosquito broker for discovery
# This is a work around till obuspa does not support advertising
log "Publishing EndpointID ${AgentEndpointID} to local mqtt broker"
mosquitto_pub -r -t "obuspa/EndpointID" -m "${AgentEndpointID}" ${opt}
}
start_service() { start_service() {
procd_open_instance sulu procd_open_instance sulu
# append sulu connection injection publish_endpoint
procd_close_instance procd_close_instance
} }

View File

@@ -1,18 +1,18 @@
location /config/ { # proxy required for nginx to save the file
autoindex on; location /upload_proxy {
if ($request_method = 'OPTIONS') { return 200 "File upload is successful \n";
add_header 'Access-Control-Allow-Origin' '*'; }
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; location /upload {
add_header 'Access-Control-Max-Age' 1728000; limit_except POST { deny all; }
add_header 'Content-Type' 'text/plain; charset=utf-8'; client_body_temp_path /tmp/sulu; # the directory to which uploads will be saved, make sure to create the directory you wish to use
add_header 'Content-Length' 0; client_body_in_file_only on;
return 204; client_body_buffer_size 128K;
} client_max_body_size 50M;
if ($request_method = 'GET') { proxy_pass_request_headers on;
add_header 'Access-Control-Allow-Origin' '*' always; proxy_set_header X-FILE $request_body_file;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; proxy_set_body $request_body_file;
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always; proxy_redirect off;
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; #proxy_pass is necessary. body is only stored when being passed to middleware, so we are providing a proxy that just returns 200.
} proxy_pass http://127.0.0.1:8080/upload_proxy;
} }

View File

@@ -5,6 +5,6 @@ uci -q get nginx._sulu && exit 0
uci -q set nginx._sulu=server uci -q set nginx._sulu=server
uci -q add_list nginx._sulu.listen='8080' uci -q add_list nginx._sulu.listen='8080'
uci -q add_list nginx._sulu.listen='[::]:8080' uci -q add_list nginx._sulu.listen='[::]:8080'
uci -q add_list nginx._sulu.include='conf.d/sulu.locations'
uci -q set nginx._sulu.root='/sulu' uci -q set nginx._sulu.root='/sulu'
uci -q set nginx._sulu.server_name='_sulu' uci -q set nginx._sulu.server_name='_sulu'
uci -q add_list nginx._sulu.include='conf.d/sulu.locations'

View File

@@ -1,9 +0,0 @@
if PACKAGE_swmodd
menu "Configuration"
config SWMOD_HOST_IS_EXECENV
bool "Enable host system as execution environment"
default n
endmenu
endif

View File

@@ -6,12 +6,12 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=swmodd PKG_NAME:=swmodd
PKG_VERSION:=2.0.21 PKG_VERSION:=2.0.9
LOCAL_DEV:=0 LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1) ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=78b54d0ed0223a9787133597d3beaa5e97d97520 PKG_SOURCE_VERSION:=2283abeca8f6beb58cbbbe5c4865ed329832f957
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/swmodd.git PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/swmodd.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip PKG_MIRROR_HASH:=skip
@@ -26,7 +26,7 @@ define Package/swmodd
CATEGORY:=Utilities CATEGORY:=Utilities
SUBMENU:=TRx69 SUBMENU:=TRx69
TITLE:= Software Modules Daemon TITLE:= Software Modules Daemon
DEPENDS:=+libuci +libubox +ubus +libuuid +libbbf_api +opkg +libcurl \ DEPENDS:=+libuci +libubox +ubus +libuuid +libbbf_api +opkg \
+PACKAGE_liblxc:liblxc +PACKAGE_liblxc:cgroupfs-mount \ +PACKAGE_liblxc:liblxc +PACKAGE_liblxc:cgroupfs-mount \
+@BUSYBOX_CONFIG_BUSYBOX +@BUSYBOX_CONFIG_FEATURE_SHOW_SCRIPT +@BUSYBOX_CONFIG_BUSYBOX +@BUSYBOX_CONFIG_FEATURE_SHOW_SCRIPT
endef endef
@@ -35,10 +35,6 @@ define Package/swmodd/description
Software module daemon to manage software/deployment units using TR181 datamodel. Software module daemon to manage software/deployment units using TR181 datamodel.
endef endef
define Package/swmodd/config
source "$(SOURCE)/Config.in"
endef
TARGET_CFLAGS += \ TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include \ -I$(STAGING_DIR)/usr/include \
-D_GNU_SOURCE -D_GNU_SOURCE
@@ -48,11 +44,6 @@ MAKE_FLAGS += \
SWMOD_LXC="yes" SWMOD_LXC="yes"
endif endif
ifeq ($(CONFIG_SWMOD_HOST_IS_EXECENV),y)
MAKE_FLAGS += \
SWMOD_HOST_IS_EXECENV="yes"
endif
ifeq ($(LOCAL_DEV),1) ifeq ($(LOCAL_DEV),1)
define Build/Prepare define Build/Prepare
$(CP) -rf ~/git/swmodd/* $(PKG_BUILD_DIR)/ $(CP) -rf ~/git/swmodd/* $(PKG_BUILD_DIR)/

View File

@@ -8,19 +8,17 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=twamp PKG_NAME:=twamp
PKG_VERSION:=1.1.0 PKG_VERSION:=1.0.1
LOCAL_DEV:=0 PKG_SOURCE_VERSION:=dbddaa0c4d826dfdf37bb92f98a2b2ad23035ca3
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/twamp.git PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/twamp.git
PKG_SOURCE_VERSION:=a0f7355afea41dbafd443d119cb394e038e70dc6
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip PKG_MIRROR_HASH:=skip
endif
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_LICENSE:=GPL-2.0-only PKG_LICENSE:=GPL-2.0-only
PKG_LICENSE_FILES:=LICENSE PKG_LICENSE_FILES:=LICENSE
@@ -30,36 +28,23 @@ define Package/$(PKG_NAME)
SECTION:=utils SECTION:=utils
CATEGORY:=Utilities CATEGORY:=Utilities
SUBMENU:=TRx69 SUBMENU:=TRx69
TITLE:=BBF TWAMP/TWAMP Light feature TITLE:=BBF twamp feature
DEPENDS:=+libuci +libbbf_api +ubox +libubus DEPENDS:=+libuci +libbbf_api
endef endef
define Package/$(PKG_NAME)/description define Package/$(PKG_NAME)/description
BBF TWAMP/TWAMP Light feature BBF twamp feature
endef endef
TARGET_CFLAGS += \ TARGET_CFLAGS += \
-D_GNU_SOURCE -D_GNU_SOURCE
ifeq ($(LOCAL_DEV),1)
define Build/Prepare
$(CP) -rf ~/git/twamp/* $(PKG_BUILD_DIR)/
endef
endif
define Package/$(PKG_NAME)/install define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/usr/lib/bbfdm
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/twampd $(1)/usr/sbin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/twampd $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/usr/lib/bbfdm $(INSTALL_DIR) $(1)/usr/lib/bbfdm
$(INSTALL_BIN) $(PKG_BUILD_DIR)/libtwamp.so $(1)/usr/lib/bbfdm/libtwamp.so $(INSTALL_BIN) $(PKG_BUILD_DIR)/*.so $(1)/usr/lib/bbfdm
$(INSTALL_DATA) ./files/etc/config/twamp $(1)/etc/config/twamp $(CP) ./files/* $(1)/
$(INSTALL_BIN) ./files/etc/init.d/twampd $(1)/etc/init.d/twampd
$(INSTALL_BIN) ./files/etc/firewall.twamp $(1)/etc/firewall.twamp
$(INSTALL_BIN) ./files/etc/uci-defaults/92-twampfirewall $(1)/etc/uci-defaults/92-twampfirewall
endef endef
$(eval $(call BuildPackage,$(PKG_NAME))) $(eval $(call BuildPackage,$(PKG_NAME)))

View File

@@ -1,13 +1,13 @@
config twamp 'twamp' config twamp 'twamp'
option enable '1' option id '1'
option twamp_light '1'
#Log levels: Critical=0, Warning=1, Notice=2, Info=3, Debug=4 #Log levels: Critical=0, Warning=1, Notice=2, Info=3, Debug=4
option log_level '3' option log_level '3'
config twamp_reflector 'reflector_1' config twamp_reflector
option id '1'
option enable '0' option enable '0'
option interface 'wan' option interface 'lan'
option port '862' option port '862'
option max_ttl '1' option max_ttl '1'

View File

@@ -1,31 +0,0 @@
#!/bin/sh
. /lib/functions.sh
#created by the icwmp package
log() {
echo "${@}"|logger -t firewall.twamp -p info
}
if [ ! -f "/etc/config/twamp" ]; then
exit 0;
fi
function configure_firewall()
{
local enable port interface
config_get enable ${1} enable "0"
config_get port ${1} port
config_get interface ${1} interface
if [ "$enable" -eq 0 -o -z "${port}" -o -z "${interface}" ]; then
return 0;
fi
iptables -w 1 -nL zone_${interface}_input 2>/dev/null 1>&2
if [ "$?" -eq 0 ]; then
iptables -w 1 -I zone_${interface}_input -p udp --dport "${port}" -j ACCEPT -m comment --comment "TWAMP reflector port"
fi
}
config_load twamp
config_foreach configure_firewall twamp_reflector

View File

@@ -1,7 +1,7 @@
#!/bin/sh /etc/rc.common #!/bin/sh /etc/rc.common
# TWAMP Reflector software #TWAMP Reflector software
# Copyright (C) 2020-2022 IOPSYS Software Solutions AB # Copyright (C) 2020 iopsys Software Solutions AB
# Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com> #Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
START=99 START=99
STOP=10 STOP=10
@@ -10,18 +10,45 @@ USE_PROCD=1
PROG="/usr/sbin/twampd" PROG="/usr/sbin/twampd"
start_service() { start_service() {
local enable=`uci -q get twamp.twamp.enable` local id=`uci -q get twamp.twamp.id`
local connection=`uci show twamp | grep "twamp.@twamp_reflector.*id=\'$id\'" | cut -d "." -f 2`
local enable=`uci -q get twamp.$connection.enable`
local interface=`uci -q get twamp.$connection.interface`
local port=`uci -q get twamp.$connection.port`
local port_list=`uci -q get twamp.$connection.port_list`
port_list=`echo $port_list | tr "," " "`
if [ "$enable" = "1" ]; then if [ "$enable" = "1" ]; then
if [ $interface = "wan" ]; then
for str in $port_list; do
if [ "${str/-}" != "$str" ] ; then
str=`echo $str | tr "-" ":"`
fi
iptables -I zone_wan_input -p udp --dport "$str" -j ACCEPT -m comment --comment "Open UDP allowed port"
iptables -I zone_wan_input -p tcp --dport "$port" -j ACCEPT -m comment --comment "Open TCP allowed port"
done
fi
procd_open_instance procd_open_instance
procd_set_param command "$PROG" procd_set_param command "$PROG"
procd_set_param respawn "3" "7" "0" procd_set_param respawn "3" "7" "0"
procd_close_instance procd_close_instance
else
if [ $interface = "wan" ]; then
if [ "${str/-}" != "$str" ] ; then
str=`echo $str | tr "-" ":"`
fi
iptables -I zone_wan_input -p udp --dport "$str" -j REJECT -m comment --comment "Close UDP allowed port"
iptables -I zone_wan_input -p tcp --dport "$port" -j REJECT -m comment --comment "Close TCP allowed port"
fi
fi fi
} }
boot() {
start
}
reload_service() { reload_service() {
stop stop
start start
} }
service_triggers() { service_triggers() {

View File

@@ -1,12 +0,0 @@
#!/bin/sh
uci -q batch <<-EOT
delete firewall.twamp
set firewall.twamp=include
set firewall.twamp.path=/etc/firewall.twamp
set firewall.twamp.reload=1
commit firewall
EOT
exit 0

View File

@@ -18,12 +18,9 @@ PKG_SOURCE_PROTO:=git
ifdef CONFIG_TARGET_intel_mips ifdef CONFIG_TARGET_intel_mips
PKG_SOURCE_URL:=https://dev.iopsys.eu/intel/uboot.git PKG_SOURCE_URL:=https://dev.iopsys.eu/intel/uboot.git
PKG_SOURCE_VERSION:=feed838bd1bfeeb57a9afb93b4d704971f423d92 PKG_SOURCE_VERSION:=feed838bd1bfeeb57a9afb93b4d704971f423d92
else ifdef CONFIG_TARGET_iopsys_econet
PKG_SOURCE_URL:=https://dev.iopsys.eu/ensemble/u-boot.git
PKG_SOURCE_VERSION:=1b320f0656bfc8504fa4f771dd77d8e403ed00e0
else else
PKG_SOURCE_URL:=https://dev.iopsys.eu/fork/uboot.git PKG_SOURCE_URL:=https://dev.iopsys.eu/fork/uboot.git
PKG_SOURCE_VERSION:=826af23a7723ee05dc9bc023d12a83f44aa649f4 PKG_SOURCE_VERSION:=670ad7a30f3c6871b6c8a972e19ca2dd78ea8c9b
endif endif
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION) PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
@@ -58,13 +55,6 @@ define uboot/ex400
PKG_RELEASE:=7 PKG_RELEASE:=7
endef endef
define uboot/en7562
TITLE:=U-Boot for the en7562
CONFIG:=econet-en7562-ram
DEPENDS:=@TARGET_iopsys_econet
UBOOT_IMG:=u-boot-nand.bin
endef
define uboot/sdx810_ap define uboot/sdx810_ap
TITLE:=U-Boot for the sdx810_ap TITLE:=U-Boot for the sdx810_ap
DEPENDS:=@TARGET_iopsys_ramips DEPENDS:=@TARGET_iopsys_ramips
@@ -95,7 +85,6 @@ endef
UBOOTS := \ UBOOTS := \
ex400 \ ex400 \
en7562 \
sdx810_ap \ sdx810_ap \
grx500 \ grx500 \
grx500_speedport_smart3 \ grx500_speedport_smart3 \

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