mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
twamp: Added TWAMP Light support
This commit is contained in:
parent
9675953bf6
commit
4ef7a8034b
5 changed files with 77 additions and 46 deletions
|
|
@ -8,17 +8,19 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=twamp
|
||||
PKG_VERSION:=1.0.1
|
||||
PKG_VERSION:=1.1.0
|
||||
|
||||
PKG_SOURCE_VERSION:=dbddaa0c4d826dfdf37bb92f98a2b2ad23035ca3
|
||||
LOCAL_DEV:=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=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_MIRROR_HASH:=skip
|
||||
endif
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_LICENSE:=GPL-2.0-only
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
|
|
@ -28,23 +30,36 @@ define Package/$(PKG_NAME)
|
|||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=TRx69
|
||||
TITLE:=BBF twamp feature
|
||||
DEPENDS:=+libuci +libbbf_api
|
||||
TITLE:=BBF TWAMP/TWAMP Light feature
|
||||
DEPENDS:=+libuci +libbbf_api +ubox +libubus
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
BBF twamp feature
|
||||
BBF TWAMP/TWAMP Light feature
|
||||
endef
|
||||
|
||||
TARGET_CFLAGS += \
|
||||
-D_GNU_SOURCE
|
||||
|
||||
ifeq ($(LOCAL_DEV),1)
|
||||
define Build/Prepare
|
||||
$(CP) -rf ~/git/twamp/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
endif
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(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_DIR) $(1)/usr/lib/bbfdm
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/*.so $(1)/usr/lib/bbfdm
|
||||
$(CP) ./files/* $(1)/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/libtwamp.so $(1)/usr/lib/bbfdm/libtwamp.so
|
||||
$(INSTALL_DATA) ./files/etc/config/twamp $(1)/etc/config/twamp
|
||||
$(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
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
|
||||
config twamp 'twamp'
|
||||
option id '1'
|
||||
option enable '1'
|
||||
option twamp_light '1'
|
||||
#Log levels: Critical=0, Warning=1, Notice=2, Info=3, Debug=4
|
||||
option log_level '3'
|
||||
|
||||
config twamp_reflector
|
||||
option id '1'
|
||||
config twamp_reflector 'reflector_1'
|
||||
option enable '0'
|
||||
option interface 'lan'
|
||||
option interface 'wan'
|
||||
option port '862'
|
||||
option max_ttl '1'
|
||||
|
||||
|
|
|
|||
31
twamp/files/etc/firewall.twamp
Normal file
31
twamp/files/etc/firewall.twamp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#!/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
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
#TWAMP Reflector software
|
||||
# Copyright (C) 2020 iopsys Software Solutions AB
|
||||
#Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
# TWAMP Reflector software
|
||||
# Copyright (C) 2020-2022 IOPSYS Software Solutions AB
|
||||
# Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
|
||||
START=99
|
||||
STOP=10
|
||||
|
|
@ -10,45 +10,18 @@ USE_PROCD=1
|
|||
PROG="/usr/sbin/twampd"
|
||||
|
||||
start_service() {
|
||||
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 "," " "`
|
||||
local enable=`uci -q get twamp.twamp.enable`
|
||||
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_set_param command "$PROG"
|
||||
procd_set_param respawn "3" "7" "0"
|
||||
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
|
||||
}
|
||||
|
||||
boot() {
|
||||
start
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
|
|
|
|||
12
twamp/files/etc/uci-defaults/92-twampfirewall
Normal file
12
twamp/files/etc/uci-defaults/92-twampfirewall
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#!/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
|
||||
|
||||
Loading…
Add table
Reference in a new issue