mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-23 10:34:03 +08:00
Compare commits
1 Commits
ponmngr_do
...
mqtt_datam
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
293a8a27a0 |
@@ -5,11 +5,11 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=libbbfdm
|
||||
PKG_VERSION:=6.8.19
|
||||
PKG_VERSION:=6.8.9
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/bbf.git
|
||||
PKG_SOURCE_VERSION:=4e82190d88f73494dbc6d261e6eb507e348e10e3
|
||||
PKG_SOURCE_VERSION:=4ad900a9bb6b4a0dd38edc1d14e1b6cbfeaa8e9b
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
|
||||
@@ -158,10 +158,6 @@ define Package/libbbfdm/default/install
|
||||
$(CP) $(PKG_BUILD_DIR)/libbbfdm.so $(1)/lib/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/scripts/* $(1)/usr/share/bbfdm
|
||||
$(LN) /usr/share/bbfdm/bbf.diag $(1)/usr/libexec/rpcd/bbf.diag
|
||||
ifeq ($(CONFIG_PACKAGE_mosquitto-ssl),y)
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/01-mosquitto-config $(1)/etc/uci-defaults/
|
||||
endif
|
||||
endef
|
||||
|
||||
define Package/libbbfdm/default/prerm
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
]
|
||||
},
|
||||
"Port": {
|
||||
"type": "unsignedInt",
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"version": "2.0",
|
||||
@@ -50,11 +50,6 @@
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"range": [
|
||||
{
|
||||
"max": 65535
|
||||
}
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
|
||||
@@ -8,13 +8,13 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=dectmngr
|
||||
PKG_RELEASE:=3
|
||||
PKG_VERSION:=3.5.6
|
||||
PKG_VERSION:=3.5.5
|
||||
|
||||
LOCAL_DEV=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/dectmngr.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=81450033d98fcdb68911e2148f48d190492090a6
|
||||
PKG_SOURCE_VERSION:=cf4e91ffe0a1d83140fef5b41d16e581e5341cec
|
||||
PKG_MIRROR_HASH:=skip
|
||||
endif
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=dslmngr
|
||||
PKG_VERSION:=1.2.0
|
||||
PKG_VERSION:=1.1.2
|
||||
|
||||
LOCAL_DEV=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
@@ -68,10 +68,6 @@ define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/dslmngr/install
|
||||
$(CP) ./files/common/* $(1)/
|
||||
ifeq ($(CONFIG_TARGET_brcmbca),y)
|
||||
$(CP) ./files/broadcom/* $(1)/
|
||||
endif
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/dslmngr $(1)/sbin/
|
||||
endef
|
||||
|
||||
@@ -1,311 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
# ATM #
|
||||
check_pvc() {
|
||||
local vpi=$1
|
||||
local vci=$2
|
||||
local ret
|
||||
|
||||
ret=$(xtmctl operate conn --show | awk -v test="$vpi/$vci" '{if ($3==test ) print $5 }')
|
||||
|
||||
case $ret in
|
||||
''|*[!0-9]*) return 0 ;;
|
||||
*) return $ret ;;
|
||||
esac
|
||||
}
|
||||
|
||||
check_xtm_list() {
|
||||
local qclass=$1
|
||||
local pcr scr mbs
|
||||
local ret
|
||||
|
||||
case $# in
|
||||
1)
|
||||
pcr=0
|
||||
scr=0
|
||||
mbs=0
|
||||
;;
|
||||
2)
|
||||
pcr=$2
|
||||
scr=0
|
||||
mbs=0
|
||||
;;
|
||||
4)
|
||||
pcr=$2
|
||||
scr=$3
|
||||
mbs=$4
|
||||
;;
|
||||
esac
|
||||
|
||||
ret=$(xtmctl operate tdte --show | awk -v test="$qclass" -v pcr="$pcr" -v scr="$scr" -v mbs="$mbs" '{if ($2==test && $3==pcr && $4==scr && $5==mbs ) print $1 }')
|
||||
|
||||
case $ret in
|
||||
''|*[!0-9]*) return 0 ;;
|
||||
*) return $ret ;;
|
||||
esac
|
||||
}
|
||||
|
||||
configure_atm_device() {
|
||||
local name vpi vci device link_type encapsulation qos_class pcr mbs scr i
|
||||
|
||||
config_get name $1 name "ATM"
|
||||
config_get vpi $1 vpi "8"
|
||||
config_get vci $1 vci "35"
|
||||
config_get device $1 device "atm0"
|
||||
config_get link_type $1 link_type "eoa"
|
||||
config_get encapsulation $1 encapsulation "llc"
|
||||
config_get qos_class $1 qos_class "ubr"
|
||||
config_get pcr $1 pcr
|
||||
config_get mbs $1 mbs
|
||||
config_get scr $1 scr
|
||||
|
||||
check_pvc $vpi $vci
|
||||
ret=$?
|
||||
|
||||
if [ "$ret" -eq 0 ]; then
|
||||
check_xtm_list $qos_class $pcr $scr $mbs
|
||||
ret=$?
|
||||
|
||||
if [ "$ret" -eq 0 ]; then
|
||||
case $qos_class in # ubr, cbr, gfr, vbr-nrt, vbr-rt, ubr+, abr
|
||||
ubr)
|
||||
xtmctl operate tdte --add "$qos_class"
|
||||
;;
|
||||
ubr_pcr|ubr+)
|
||||
xtmctl operate tdte --add "$qos_class" $pcr
|
||||
;;
|
||||
cbr)
|
||||
xtmctl operate tdte --add "$qos_class" $pcr
|
||||
;;
|
||||
nrtvbr|vbr-nrt)
|
||||
xtmctl operate tdte --add "$qos_class" $pcr $scr $mbs
|
||||
;;
|
||||
rtvbr|vbr-rt)
|
||||
xtmctl operate tdte --add "$qos_class" $pcr $scr $mbs
|
||||
;;
|
||||
gfr)
|
||||
;;
|
||||
abr)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case $link_type in # EoA, IPoA, PPPoA, CIP
|
||||
EoA|eoa)
|
||||
[ $encapsulation == "vcmux" ] && encapsulation="vcmux_eth" || encapsulation="llcsnap_eth"
|
||||
;;
|
||||
PPPoA|pppoa)
|
||||
[ $encapsulation == "vcmux" ] && encapsulation="vcmux_pppoa" || encapsulation="llcencaps_ppp"
|
||||
;;
|
||||
IPoA|ipoa)
|
||||
[ $encapsulation == "vcmux" ] && encapsulation="vcmux_ipoa" || encapsulation="llcsnap_rtip"
|
||||
;;
|
||||
CIP|cip)
|
||||
;;
|
||||
esac
|
||||
|
||||
check_xtm_list $qos_class $pcr $scr $mbs
|
||||
ret="$?"
|
||||
|
||||
xtmctl operate conn --add 1.$vpi.$vci aal5 $encapsulation 0 1 $ret
|
||||
for i in `seq 0 7`; do
|
||||
xtmctl operate conn --addq 1.$vpi.$vci $i wrr 1 dt # queue priority 0-7
|
||||
done
|
||||
xtmctl operate conn --createnetdev 1.$vpi.$vci $device
|
||||
xtmctl operate intf --state 1 enable
|
||||
fi
|
||||
}
|
||||
|
||||
remove_atm_devices() {
|
||||
local vpi vci rest
|
||||
local vpivci=`xtmctl operate conn --show | grep "ATM\|mode" | awk '{if (NR!=1 && $1!="PTM") {print $3}}'`
|
||||
|
||||
for i in $vpivci
|
||||
do
|
||||
rest=${i#\/}
|
||||
vpi=${rest%%\/*}
|
||||
vci=${rest#*\/}
|
||||
echo "xtmctl operate conn --delete 1.$vpi.$vci"
|
||||
xtmctl operate conn --delete 1.$vpi.$vci
|
||||
echo "xtmctl operate conn --deletenetdev 1.$vpi.$vci"
|
||||
xtmctl operate conn --deletenetdev 1.$vpi.$vci
|
||||
done
|
||||
}
|
||||
|
||||
create_atm_devices() {
|
||||
echo "Creating ATM Device(s)"
|
||||
config_load dsl
|
||||
config_foreach configure_atm_device atm-device
|
||||
}
|
||||
# ATM END #
|
||||
|
||||
# PTM #
|
||||
check_ptm() {
|
||||
local ret
|
||||
local ptmprio=$1
|
||||
local dslat=$2
|
||||
|
||||
if [ "$ptmprio" -eq 2 ]; then
|
||||
ptmprio="high"
|
||||
else
|
||||
ptmprio="low"
|
||||
fi
|
||||
|
||||
ret=$(xtmctl operate conn --show | awk -v dslat="$dslat" -v ptmprio="$ptmprio" '{if ($2 == dslat && $3 == ptmprio ) print $2 }')
|
||||
|
||||
case $ret in
|
||||
''|*[!0-9]*) return 0 ;;
|
||||
*) return $ret ;;
|
||||
esac
|
||||
}
|
||||
|
||||
configure_ptm_device() {
|
||||
local name device priority portid i
|
||||
|
||||
config_get name $1 name "PTM"
|
||||
config_get device $1 device "ptm0"
|
||||
config_get priority $1 priority 1
|
||||
config_get portid $1 portid 1
|
||||
|
||||
check_ptm $priority $portid
|
||||
ret=$?
|
||||
|
||||
if [ "$ret" -eq 0 ]; then
|
||||
xtmctl operate conn --add $portid.$priority
|
||||
|
||||
for i in `seq 0 7`; do
|
||||
xtmctl operate conn --addq $portid.$priority $i wrr 1 dt -1 -1 3000 # queue priority 0-7
|
||||
done
|
||||
echo "xtmctl operate conn --createnetdev $portid.$priority $device"
|
||||
xtmctl operate conn --createnetdev $portid.$priority $device
|
||||
xtmctl operate intf --state 1 enable
|
||||
fi
|
||||
}
|
||||
|
||||
remove_ptm_devices() {
|
||||
local delptm
|
||||
local x=0
|
||||
|
||||
IFS=$'\n'
|
||||
for i in `xtmctl operate conn --show | grep "PTM\|mode"`
|
||||
do
|
||||
if [ $x -eq 1 ]; then
|
||||
delptm=$(echo $i | awk '{if ($1!="ATM") print $2"."$11}')
|
||||
echo "xtmctl operate conn --delete $delptm"
|
||||
xtmctl operate conn --delete $delptm
|
||||
xtmctl operate conn --deletenetdev $delptm
|
||||
fi
|
||||
x=1
|
||||
done
|
||||
unset IFS
|
||||
}
|
||||
|
||||
create_ptm_devices() {
|
||||
echo "Creating PTM Device(s)"
|
||||
config_load dsl
|
||||
config_foreach configure_ptm_device ptm-device
|
||||
}
|
||||
# PTM END #
|
||||
|
||||
prioritize_arp()
|
||||
{
|
||||
ebtables -t nat -D POSTROUTING -j mark --mark-or 0x7 -p ARP >/dev/null
|
||||
ebtables -t nat -A POSTROUTING -j mark --mark-or 0x7 -p ARP >/dev/null
|
||||
}
|
||||
|
||||
xtm_remove_devices() {
|
||||
remove_atm_devices
|
||||
remove_ptm_devices
|
||||
}
|
||||
|
||||
xtm_create_devices() {
|
||||
local tpstc="$(xdslctl info --show | grep TPS-TC)"
|
||||
if echo "$tpstc" | grep -q "ATM Mode"; then
|
||||
create_atm_devices
|
||||
elif echo "$tpstc" | grep -q "PTM Mode"; then
|
||||
create_ptm_devices
|
||||
fi
|
||||
}
|
||||
|
||||
xdsl_configure() {
|
||||
local VDSL=0
|
||||
local GFAST=0
|
||||
local mod=""
|
||||
local modes=""
|
||||
local profile=""
|
||||
|
||||
config_load dsl
|
||||
|
||||
# Modes
|
||||
config_get mode line mode
|
||||
for mod in $mode; do
|
||||
[ $mod == "gdmt" ] && modes="${modes}d"
|
||||
[ $mod == "glite" ] && modes="${modes}l"
|
||||
[ $mod == "t1413" ] && modes="${modes}t"
|
||||
[ $mod == "adsl2" ] && modes="${modes}2"
|
||||
[ $mod == "adsl2p" ] && modes="${modes}p"
|
||||
[ $mod == "annexl" ] && modes="${modes}e"
|
||||
[ $mod == "annexm" ] && modes="${modes}m"
|
||||
[ $mod == "vdsl2" ] && modes="${modes}v" && VDSL=1
|
||||
[ $mod == "gfast" ] && modes="${modes}f" && GFAST=1
|
||||
done
|
||||
|
||||
# VDSL Profiles
|
||||
config_get profile line profile
|
||||
# Capabilities
|
||||
config_get_bool bitswap line bitswap 1
|
||||
[ $bitswap -eq 1 ] && bitswap="on" || bitswap="off"
|
||||
config_get_bool sra line sra 1
|
||||
[ $sra -eq 1 ] && sra="on" || sra="off"
|
||||
# config_get_bool trellis line trellis 1
|
||||
config_get_bool sesdrop line sesdrop 0
|
||||
[ $sesdrop -eq 1 ] && sesdrop="on" || sesdrop="off"
|
||||
# VDSL2 only
|
||||
config_get_bool us0 line us0 1
|
||||
[ $us0 -eq 1 ] && us0="on" || us0="off"
|
||||
# config_get_bool dynamicd line dynamicd 1
|
||||
# config_get_bool dynamicf line dynamicf 1
|
||||
config_get_bool sos line sos 0
|
||||
[ $sos -eq 1 ] && sos="on" || sos="off"
|
||||
|
||||
config_get_bool phyReXmtUs line phyReXmtUs 0
|
||||
config_get_bool phyReXmtDs line phyReXmtDs 1
|
||||
phyReXmt=$(( $((phyReXmtUs<<1)) + phyReXmtDs))
|
||||
|
||||
if [ $VDSL -eq 1 -o $GFAST -eq 1 ]; then
|
||||
echo "xdslctl start --up --mod $modes --profile "$profile" --sra $sra --bitswap $bitswap --us0 $us0 --sesdrop $sesdrop --SOS $sos --phyReXmt $phyReXmt"
|
||||
xdslctl start --up --mod $modes --profile "$profile" --sra $sra --bitswap $bitswap --us0 $us0 --sesdrop $sesdrop --SOS $sos --phyReXmt $phyReXmt
|
||||
# G.Fast hardware to VDSL hardware, to set the driver bit kPhyCfg2EnableGfastVdslMMTimeOut0.
|
||||
# Enable V43 tone for GFAST.
|
||||
echo "xdslctl configure1 --phycfg 0 0 0 0 0 0 0 0 0 0 0 0x1400400 0x1400400"
|
||||
xdslctl configure1 --phycfg 0 0 0 0 0 0 0 0 0 0 0 0x1400400 0x1400400
|
||||
else
|
||||
echo "xdslctl start --up --mod $modes --sra $sra --bitswap $bitswap --sesdrop $sesdrop --SOS $sos --phyReXmt $phyReXmt"
|
||||
xdslctl start --up --mod $modes --sra $sra --bitswap $bitswap --sesdrop $sesdrop --SOS $sos --phyReXmt $phyReXmt
|
||||
fi
|
||||
|
||||
if [ $GFAST -eq 1 ]; then
|
||||
# G.Fast hardware to VDSL hardware, to set the driver bit kPhyCfg2EnableGfastVdslMMTimeOut0.
|
||||
# Enable V43 tone for GFAST.
|
||||
echo "xdslctl configure1 --phycfg 0 0 0 0 0 0 0 0 0 0 0 0x1400400 0x1400400"
|
||||
xdslctl configure1 --phycfg 0 0 0 0 0 0 0 0 0 0 0 0x1400400 0x1400400
|
||||
fi
|
||||
}
|
||||
|
||||
xdsl_stop() {
|
||||
# echo "Stopping DSL"
|
||||
# stop causes IRQ issues
|
||||
# xdslctl stop
|
||||
return 0
|
||||
}
|
||||
|
||||
xdsl_init() {
|
||||
prioritize_arp
|
||||
|
||||
echo "Starting DSL"
|
||||
|
||||
xtmctl start
|
||||
xtmctl operate intf --state 1 enable
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
# OEM specific parameters
|
||||
config oem-parameters 'oem'
|
||||
# option country_code "0000" # 2 bytes hex
|
||||
# option vendor_id "IO" # 4 bytes string
|
||||
# option vendor_suffix "0000" # 2 bytes hex
|
||||
# option sw_version "iopsys" # 16 bytes string
|
||||
# option serial_nr "00000000" # 32 bytes string
|
||||
|
||||
# DSL Modes
|
||||
config dsl-line line
|
||||
list mode gdmt
|
||||
list mode glite
|
||||
list mode t1413
|
||||
list mode adsl2
|
||||
list mode adsl2p
|
||||
list mode annexl
|
||||
list mode annexm
|
||||
list mode vdsl2
|
||||
# VDSL2 profiles
|
||||
list profile 8a
|
||||
list profile 8b
|
||||
list profile 8c
|
||||
list profile 8d
|
||||
list profile 12a
|
||||
list profile 12b
|
||||
list profile 17a
|
||||
list profile 30a
|
||||
option bitswap 1
|
||||
option sra 1
|
||||
option us0 1 # VDSL2 only
|
||||
option sesdrop 0
|
||||
option sos 0
|
||||
option phyReXmtUs 0
|
||||
option phyReXmtDs 1
|
||||
|
||||
config atm-device atm0
|
||||
option name 'ATM'
|
||||
option vpi '8'
|
||||
option vci '35'
|
||||
option device atm0
|
||||
option link_type 'eoa' # EoA, IPoA, PPPoA, CIP
|
||||
option encapsulation 'llc' # llc, vcmux
|
||||
option qos_class 'ubr' # ubr, cbr, gfr, vbr-nrt, vbr-rt, ubr+, abr
|
||||
# option pcr '512'
|
||||
# option scr '256'
|
||||
# option mbs '1024'
|
||||
|
||||
config ptm-device ptm0
|
||||
option name 'PTM'
|
||||
option device 'ptm0'
|
||||
option priority '1'
|
||||
option portid '1'
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
[ "$STATUS" == "up" -o "$STATUS" == "down" ] || exit 0
|
||||
|
||||
. /lib/functions.sh
|
||||
include /lib/dsl
|
||||
|
||||
xtm_remove_devices
|
||||
xtm_create_devices
|
||||
@@ -1,7 +0,0 @@
|
||||
if [ "$STATUS" == "up" ]; then
|
||||
ubus call led.dsl set '{"state":"ok"}'
|
||||
elif [ "$STATUS" == "down" ]; then
|
||||
ubus call led.dsl set '{"state":"off"}'
|
||||
elif [ "$STATUS" == "training" ]; then
|
||||
ubus call led.dsl set '{"state":"alert"}'
|
||||
fi
|
||||
@@ -1,48 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
. /lib/functions.sh
|
||||
include /lib/dsl
|
||||
|
||||
START=20
|
||||
USE_PROCD=1
|
||||
|
||||
DSLMNGR=$(which dslmngr)
|
||||
|
||||
start_service() {
|
||||
[ -n "$DSLMNGR" ] && {
|
||||
procd_open_instance
|
||||
procd_set_param command "$DSLMNGR"
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
xdsl_configure
|
||||
xtm_create_devices
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
[ -n "$DSLMNGR" ] && service_stop $DSLMNGR
|
||||
|
||||
xtm_remove_devices
|
||||
xdsl_stop
|
||||
}
|
||||
|
||||
boot() {
|
||||
local HASADSL="$(db -q get hw.board.hasAdsl)"
|
||||
local HASVDSL="$(db -q get hw.board.hasVdsl)"
|
||||
[ "$HASADSL" == "1" -o "$HASVDSL" == "1" ] || return
|
||||
|
||||
xdsl_init
|
||||
|
||||
start
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger dsl
|
||||
}
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=easy-soc-libs
|
||||
PKG_VERSION:=7.2.7
|
||||
PKG_VERSION:=6.8.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
LOCAL_DEV=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=3d6d1347668408e77c327ddf81602e70af8b3d98
|
||||
PKG_SOURCE_VERSION:=ddc7b272bec5e3b5c2a216a1f86cd5589a1a4a19
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/easy-soc-libs.git
|
||||
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu>
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
|
||||
@@ -59,10 +59,6 @@ else ifeq ($(CONFIG_TARGET_airoha),y)
|
||||
TARGET_PLATFORM=ECONET
|
||||
TARGET_WIFI_TYPE=MAC80211
|
||||
TARGET_CFLAGS +=-DIOPSYS_ECONET
|
||||
else ifeq ($(CONFIG_TARGET_ipq95xx),y)
|
||||
TARGET_PLATFORM=IPQ95XX
|
||||
TARGET_WIFI_TYPE=MAC80211
|
||||
TARGET_CFLAGS +=-DIPQ95XX
|
||||
else
|
||||
$(info Unexpected CONFIG_TARGET, use default MAC80211)
|
||||
TARGET_PLATFORM=MAC80211
|
||||
@@ -75,27 +71,13 @@ export TARGET_WIFI_TYPE
|
||||
|
||||
subdirs := \
|
||||
$(if $(CONFIG_PACKAGE_libeasy),libeasy) \
|
||||
$(if $(CONFIG_PACKAGE_libwifiutils),libwifi) \
|
||||
$(if $(CONFIG_PACKAGE_libwifi),libwifi) \
|
||||
$(if $(CONFIG_PACKAGE_libdsl),libdsl) \
|
||||
$(if $(CONFIG_PACKAGE_libethernet),libethernet) \
|
||||
$(if $(CONFIG_PACKAGE_libqos),libqos)
|
||||
|
||||
ifneq ($(CONFIG_PACKAGE_libwifi),)
|
||||
TARGET_CFLAGS +=-DHAS_WIFI
|
||||
endif
|
||||
|
||||
esl-pkgs := \
|
||||
$(if $(CONFIG_PACKAGE_libeasy),libeasy) \
|
||||
$(if $(CONFIG_PACKAGE_libwifiutils),libwifiutils) \
|
||||
$(if $(CONFIG_PACKAGE_libwifi),libwifi) \
|
||||
$(if $(CONFIG_PACKAGE_libdsl),libdsl) \
|
||||
$(if $(CONFIG_PACKAGE_libethernet),libethernet) \
|
||||
$(if $(CONFIG_PACKAGE_libqos),libqos)
|
||||
|
||||
esl-pkgs-all := \
|
||||
EASY_SOC_LIBS := \
|
||||
libeasy \
|
||||
libwifiutils \
|
||||
libwifi \
|
||||
libdsl \
|
||||
libethernet \
|
||||
@@ -145,15 +127,15 @@ define Build/Compile
|
||||
$(Build/Compile/rebuild)
|
||||
touch $(PKG_BUILD_DIR)/.config_$(CONFIG_TARGET_PROFILE)
|
||||
$(call Build/Compile/Default)
|
||||
$(foreach dir,$(esl-pkgs),$(call Build/Compile/$(dir)))
|
||||
$(foreach dir,$(subdirs),$(call Build/Compile/$(dir)))
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(foreach dir,$(esl-pkgs),$(call Build/InstallDev/$(dir),$(1),$(2));)
|
||||
$(foreach dir,$(subdirs),$(call Build/InstallDev/$(dir),$(1),$(2));)
|
||||
endef
|
||||
|
||||
define Package/easy-soc-libs/install
|
||||
:
|
||||
endef
|
||||
|
||||
$(eval $(foreach e,$(esl-pkgs-all),$(call BuildPackage,$(e))))
|
||||
$(eval $(foreach e,$(EASY_SOC_LIBS),$(call BuildPackage,$(e))))
|
||||
|
||||
@@ -1,49 +1,29 @@
|
||||
|
||||
define Package/libwifiutils
|
||||
$(call Package/easy-soc-libs)
|
||||
TITLE:= WiFi utility library (libwifiutils.so)
|
||||
DEPENDS+=+libnl +libnl-route +libeasy
|
||||
endef
|
||||
|
||||
define Build/InstallDev/libwifiutils
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libwifi/wifidefs.h $(1)/usr/include/
|
||||
$(CP) $(PKG_BUILD_DIR)/libwifi/wifiutils.h $(1)/usr/include/
|
||||
$(CP) $(PKG_BUILD_DIR)/libwifi/libwifiutils*.so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Package/libwifiutils/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libwifi/libwifiutils*.so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
|
||||
define Package/libwifi
|
||||
$(call Package/easy-soc-libs)
|
||||
TITLE:= WiFi library (libwifi)
|
||||
DEPENDS+=+libnl +libnl-route +libeasy +libwifiutils +TARGET_brcmbca:bcmkernel
|
||||
DEPENDS+=+libnl +libnl-route +libeasy +TARGET_brcmbca:bcmkernel
|
||||
endef
|
||||
|
||||
define Package/libwifi/config
|
||||
if PACKAGE_libwifi
|
||||
if PACKAGE_libdsl
|
||||
config LIBWIFI_DEBUG
|
||||
depends on PACKAGE_libwifi
|
||||
bool "Enable wifi debugging"
|
||||
default n
|
||||
|
||||
endif
|
||||
endef
|
||||
|
||||
|
||||
define Build/InstallDev/libwifi
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libwifi/wifiops.h $(1)/usr/include/
|
||||
$(CP) $(PKG_BUILD_DIR)/libwifi/wifi.h $(1)/usr/include/
|
||||
$(CP) $(PKG_BUILD_DIR)/libwifi/libwifi-7*.so* $(1)/usr/lib/
|
||||
$(CP) $(PKG_BUILD_DIR)/libwifi/libwifi*.so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Package/libwifi/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libwifi/libwifi-7*.so* $(1)/usr/lib/
|
||||
$(CP) $(PKG_BUILD_DIR)/libwifi/libwifi*.so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ LOCAL_DEV=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/endptmngr.git
|
||||
PKG_SOURCE_VERSION:=fb85081443c19b5062bede49c80b1802c0f05d34
|
||||
PKG_SOURCE_VERSION:=dc12712af8c4088f7873502ca845e51c68a1ada9
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ethmngr
|
||||
PKG_VERSION:=2.1.0
|
||||
PKG_VERSION:=2.0.1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=5a0ff3bc7c49dcb05129f423ef8e0c4929f6aa03
|
||||
@@ -23,7 +23,7 @@ define Package/ethmngr
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Ethernet status and configration utility
|
||||
DEPENDS:=+(TARGET_brcmbca||TARGET_airoha||TARGET_ipq95xx):libethernet +libuci +libubox +ubus +libpthread +libnl-genl
|
||||
DEPENDS:=+libethernet +libuci +libubox +ubus +libpthread +libnl-genl
|
||||
endef
|
||||
|
||||
define Package/ethmngr/description
|
||||
@@ -37,24 +37,10 @@ TARGET_CFLAGS += \
|
||||
-I$(STAGING_DIR)/usr/include/libnl3 \
|
||||
-D_GNU_SOURCE
|
||||
|
||||
ifeq ($(CONFIG_TARGET_brcmbca)$(CONFIG_TARGET_airoha)$(CONFIG_TARGET_ipq95xx),)
|
||||
define Build/Compile
|
||||
endef
|
||||
endif
|
||||
|
||||
define Package/ethmngr/install
|
||||
$(CP) ./files/common/* $(1)/
|
||||
ifneq ($(CONFIG_TARGET_brcmbca),)
|
||||
$(CP) ./files/broadcom/* $(1)/
|
||||
else ifneq ($(CONFIG_TARGET_airoha),)
|
||||
$(CP) ./files/airoha/* $(1)/
|
||||
else
|
||||
$(CP) ./files/linux/* $(1)/
|
||||
endif
|
||||
ifneq ($(CONFIG_TARGET_brcmbca)$(CONFIG_TARGET_airoha)$(CONFIG_TARGET_ipq95xx),)
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_DIR) $(1)/etc/init.d $(1)/usr/sbin
|
||||
$(INSTALL_BIN) ./files/ethmngr.init $(1)/etc/init.d/ethmngr
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ethmngr $(1)/usr/sbin/
|
||||
endif
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ethmngr))
|
||||
|
||||
@@ -1,208 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
unset -f switchmgr
|
||||
# alias for switchmgr
|
||||
switchmgr() {
|
||||
"/userfs/bin/switchmgr" "$@"
|
||||
}
|
||||
|
||||
unset -f tc3162_get_lan_port
|
||||
# get lan port port by ifname
|
||||
# arg1: port ifname, ex: eth0.1
|
||||
tc3162_get_lan_port() {
|
||||
[[ -z "$1" ]] && return 255
|
||||
|
||||
local ifname="$1"
|
||||
local if_idx=255
|
||||
|
||||
# only for tc3162 eth switch ports (eth0.x, 0 < x < 7)
|
||||
case "${ifname}" in
|
||||
eth0.*)
|
||||
;;
|
||||
*)
|
||||
logger -t "port-management" \
|
||||
"unsupported - ${ifname} is not tc3162 switch port"
|
||||
return 255
|
||||
;;
|
||||
esac
|
||||
|
||||
let "if_idx=$(echo "${ifname}" | cut -f2 -d'.')"
|
||||
[[ -z "${if_idx}" ]] && return 255
|
||||
[[ ${if_idx} -lt 1 || ${if_idx} -gt 6 ]] && {
|
||||
logger -t "port-management" \
|
||||
"incorrect tc3162 lan port index ${if_idx} picked from ifname ${ifname}"
|
||||
return 255
|
||||
}
|
||||
let "if_idx=${if_idx}-1"
|
||||
return ${if_idx}
|
||||
}
|
||||
|
||||
|
||||
unset -f tc3162_get_mapped_port
|
||||
# get mapped switch port by ifname
|
||||
# arg1: port ifname, ex: eth0.1
|
||||
tc3162_get_mapped_port() {
|
||||
[[ -z "$1" ]] && return 255
|
||||
|
||||
local ifname="$1"
|
||||
local if_idx=255
|
||||
local prtmap_procfile="/proc/tc3162/eth_portmap"
|
||||
local lan_prt=255
|
||||
local port=255
|
||||
local prtmap_out_line_num=4
|
||||
local prtmap_out_line=""
|
||||
|
||||
# check "lan port map" marker in portmap output string
|
||||
prtmap_out_line="$(sed -n "${prtmap_out_line_num}p" ${prtmap_procfile})"
|
||||
[[ ${prtmap_out_line} != "lan_port_map" ]] && return 255
|
||||
|
||||
tc3162_get_lan_port "${ifname}"
|
||||
let "if_idx=$?"
|
||||
[[ -z "${if_idx}" || ${if_idx} -eq 255 ]] && return
|
||||
|
||||
# get lan portmapping string "lan_port mapped_port" for ifname by it's index
|
||||
let "prtmap_out_line_num=${prtmap_out_line_num}+1+${if_idx}"
|
||||
prtmap_out_line="$(sed -n "${prtmap_out_line_num}p" ${prtmap_procfile})"
|
||||
|
||||
# get and check lan port index from lan portmapping string
|
||||
lan_prt=$(echo "${prtmap_out_line}" | cut -f 1 -d' ')
|
||||
[[ -z "${lan_prt}" || "${if_idx}" != "${lan_prt}" ]] && return 255
|
||||
|
||||
# get and check mapped port from lan portmapping string
|
||||
let "port=$(echo "${prtmap_out_line}" | cut -f 2 -d' ')"
|
||||
[[ ${port} -lt 0 || ${port} -gt 255 ]] && return 255
|
||||
|
||||
return ${port}
|
||||
}
|
||||
|
||||
unset -f get_max_port_speed
|
||||
# arg1: port ifname, ex: eth0.1
|
||||
get_max_port_speed() {
|
||||
[[ -z "$1" ]] && { echo 0; return; }
|
||||
|
||||
local ifname="$1"
|
||||
local port=255
|
||||
local speed=0
|
||||
|
||||
[[ -d "/sys/class/net/${ifname}" ]] || {
|
||||
logger -t "port-management" "interface ${ifname} is not found"
|
||||
return
|
||||
}
|
||||
|
||||
tc3162_get_lan_port "${ifname}"
|
||||
let "port=$?"
|
||||
[[ -z "${port}" || ${port} -eq 255 ]] && return
|
||||
|
||||
# tc3162 capability for all ports is 1Gbps
|
||||
speed=1000
|
||||
|
||||
echo $speed
|
||||
}
|
||||
|
||||
unset -f power_updown
|
||||
# arg1: port ifname, ex: eth0.1
|
||||
# arg2: port enabled, ex: 0/1/off/on/..
|
||||
power_updown() {
|
||||
[[ -z "$1" ]] && return
|
||||
[[ -z "$2" ]] && return
|
||||
|
||||
local ifname="$1"
|
||||
local enabled="$2"
|
||||
local port=255
|
||||
|
||||
[[ -d "/sys/class/net/${ifname}" ]] || {
|
||||
logger -t "port-management" "interface ${ifname} is not found"
|
||||
return
|
||||
}
|
||||
|
||||
let "enabled=$(get_bool "${enabled}" "-1")"
|
||||
[[ ${enabled} -eq -1 ]] && return
|
||||
|
||||
tc3162_get_lan_port "${ifname}"
|
||||
let "port=$?"
|
||||
[[ -z "${port}" || ${port} -eq 255 ]] && return
|
||||
|
||||
switchmgr phy admin "${port}" "${enabled}"
|
||||
}
|
||||
|
||||
unset -f set_port_settings
|
||||
# arg1: port ifname, ex: eth0.1
|
||||
# arg2: port enabled, ex: 0/1/off/on/..
|
||||
# arg3: port speed, ex: 1000
|
||||
# arg4: port duplex, ex: full
|
||||
# arg5: port autoneg, ex: 0/1/off/on/..
|
||||
# arg6: port eee, ex: 0/1/off/on/..
|
||||
# arg7: port pause, ex: 0/1/off/on/..
|
||||
set_port_settings() {
|
||||
[[ -z "$1" ]] && return
|
||||
[[ -z "$2" ]] && return
|
||||
[[ -z "$3" ]] && return
|
||||
[[ -z "$4" ]] && return
|
||||
[[ -z "$5" ]] && return
|
||||
[[ -z "$6" ]] && return
|
||||
[[ -z "$7" ]] && return
|
||||
|
||||
local ifname="$1"
|
||||
local enabled="$2"
|
||||
local speed="$3"
|
||||
local duplex="$4"
|
||||
local autoneg=$5
|
||||
local eee="$6"
|
||||
local pause="$7"
|
||||
local port=255
|
||||
local speedmode=1
|
||||
local last_speed=0
|
||||
|
||||
[[ -d "/sys/class/net/${ifname}" ]] || {
|
||||
logger -t "port-management" "interface ${ifname} is not found"
|
||||
return
|
||||
}
|
||||
|
||||
let "enabled=$(get_bool "${enabled}" "-1")"
|
||||
[[ ${enabled} -eq -1 ]] && return
|
||||
|
||||
let "autoneg=$(get_bool "${autoneg}" "-1")"
|
||||
[[ ${autoneg} -eq -1 ]] && return
|
||||
|
||||
let "eee=$(get_bool "${eee}" "-1")"
|
||||
[[ ${eee} -eq -1 ]] && return
|
||||
|
||||
let "pause=$(get_bool "${pause}" "-1")"
|
||||
[[ ${pause} -eq -1 ]] && return
|
||||
|
||||
duplex="$(echo "${duplex}" | awk '{print tolower($0)}')"
|
||||
[[ "${duplex}" != "half" && "${duplex}" != "full" ]] && return
|
||||
|
||||
tc3162_get_lan_port "${ifname}"
|
||||
let "port=$?"
|
||||
[[ -z "${port}" || ${port} -eq 255 ]] && return
|
||||
|
||||
last_speed="$(switchmgr phy maxspeed "${port}" | cut -f2 -d':')"
|
||||
[[ -z "${last_speed}" || "${last_speed}" == "*Down*" ]] \
|
||||
&& last_speed=${speed}
|
||||
|
||||
switchmgr phy pause "${port}" "${pause}"
|
||||
|
||||
# set speedmode: speed+duplex+autoneg
|
||||
# FIXME: switchmgr has no separate setting for 1Gbps speed - use autoneg instead
|
||||
if [[ ${autoneg} -eq 1 || ${speed} -gt 100 ]]; then
|
||||
switchmgr phy speedmode ${port} "1"
|
||||
else
|
||||
[[ ${speed} -gt 10 ]] && let "speedmode=2" || let "speedmode=4"
|
||||
[[ "${duplex}" == "half" ]] && let "speedmode=${speedmode}+1"
|
||||
switchmgr phy speedmode "${port}" "${speedmode}"
|
||||
fi
|
||||
|
||||
# TODO: implement MAC control register manipulations (mapped ports used) for
|
||||
# eee settings change
|
||||
# separate (tx/rx) pause (flow control) settings change
|
||||
# set speed to 1Gbps separately from autoneg mode
|
||||
|
||||
# FIXME: workaround for duplex/pause settings being not applied if speed is unchanged
|
||||
[[ ${last_speed} -eq ${speed} ]] && power_updown "${ifname}" 0
|
||||
|
||||
power_updown "${ifname}" ${enabled}
|
||||
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
# arg1: port ifname, ex: eth0
|
||||
get_max_port_speed() {
|
||||
if [ -z "$1" ]; then
|
||||
echo 0
|
||||
return
|
||||
fi
|
||||
|
||||
local ifname="$1"
|
||||
local phycap="$(ethctl $ifname media-type 2>/dev/null | grep 'PHY Capabilities' | awk '{print$NF}' | cut -d'|' -f1)"
|
||||
local speed=1000
|
||||
|
||||
case "$phycap" in
|
||||
10GFD) speed=10000 ;;
|
||||
5GFD) speed=5000 ;;
|
||||
2.5GFD) speed=2500 ;;
|
||||
1GFD|1GHD) speed=1000 ;;
|
||||
100MFD|100MHD) speed=100 ;;
|
||||
10MFD|10MHD) speed=10 ;;
|
||||
esac
|
||||
|
||||
echo $speed
|
||||
}
|
||||
|
||||
# arg1: port name, ex: eth0
|
||||
get_port_number() {
|
||||
[ -z "$1" ] && return
|
||||
local ports="0 1 2 3 4 5 6 7"
|
||||
local units="0 1"
|
||||
local port="$1"
|
||||
local ifname
|
||||
|
||||
for unit in $units; do
|
||||
for prt in $ports; do
|
||||
ifname="$(ethswctl getifname $unit $prt 2>/dev/null | awk '{print$NF}')"
|
||||
if [ "$ifname" == "$port" ]; then
|
||||
echo "$unit $prt"
|
||||
return
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
# arg1: port ifname, ex: eth0
|
||||
# arg2: port enabled, ex: 1
|
||||
power_updown() {
|
||||
local ifname="$1"
|
||||
local enabled=$2
|
||||
|
||||
local updown="up"
|
||||
[ $enabled -eq 0 ] && updown="down"
|
||||
ethctl $ifname phy-power $updown >/dev/null
|
||||
}
|
||||
|
||||
# arg1: port ifname, ex: eth0
|
||||
# arg2: port enabled, ex: 1
|
||||
# arg3: port speed, ex: 1000
|
||||
# arg4: port duplex, ex: full
|
||||
# arg5: port autoneg, ex: on
|
||||
# arg6: port eee, ex: 0
|
||||
# arg7: port pause, ex: 0
|
||||
set_port_settings() {
|
||||
local ifname="$1"
|
||||
local enabled=$2
|
||||
local speed="$3"
|
||||
local duplex=$4
|
||||
local autoneg=$5
|
||||
local eee=$6
|
||||
local pause=$7
|
||||
|
||||
[ -d /sys/class/net/$ifname ] || return
|
||||
|
||||
local unitport="$(get_port_number $ifname)"
|
||||
local unit=$(echo $unitport | cut -d ' ' -f 1)
|
||||
local port=$(echo $unitport | cut -d ' ' -f 2)
|
||||
|
||||
[ $autoneg -eq 1 ] && autoneg="on" || autoneg="off"
|
||||
[ "$duplex" == "half" ] && duplex=0 || duplex=1
|
||||
[ "$duplex" == 0 ] && dplx="HD" || dplx="FD"
|
||||
[ "$autoneg" == "on" ] && media_type="auto" || media_type="$speed$dplx"
|
||||
|
||||
phycrossbar="$(ethctl $ifname phy-crossbar | head -1)"
|
||||
crossbartype="$(echo $phycrossbar | awk '{print$2$3}')"
|
||||
# Take only the last PHY Endpoint (non-Serdes) into account as Serdes port number precedes
|
||||
[ "$crossbartype" == "oncrossbar" ] && pyhendpoint="$(echo $phycrossbar | awk '{print$NF}')"
|
||||
|
||||
phycaps="$(ethctl $ifname media-type ${pyhendpoint:+ port $pyhendpoint} | awk -F'PHY Capabilities: ' '{print$2}')"
|
||||
numofcaps="$(echo $phycaps | tr '|' ' ' | wc -w)"
|
||||
|
||||
if [ "$numofcaps" == "1" ]; then
|
||||
logger -t "port-management" "$ifname is capable of $phycaps only; not setting speed/duplex"
|
||||
else
|
||||
logger -t "port-management" "$ifname is capable of $phycaps; setting speed/duplex to $media_type"
|
||||
ethctl $ifname media-type $media_type ${pyhendpoint:+ port $pyhendpoint} &>/dev/null
|
||||
fi
|
||||
|
||||
[ $eee -eq 1 ] && eee="on" || eee="off"
|
||||
ethtool --set-eee $ifname eee $eee 2>/dev/null
|
||||
|
||||
case $pause in
|
||||
off|0)
|
||||
pause=0x0
|
||||
auto=off
|
||||
rx=off
|
||||
tx=off
|
||||
;;
|
||||
on|1)
|
||||
pause=0x2
|
||||
auto=off
|
||||
rx=on
|
||||
tx=on
|
||||
;;
|
||||
auto)
|
||||
pause=0x1
|
||||
auto=on
|
||||
rx=on
|
||||
tx=on
|
||||
;;
|
||||
tx)
|
||||
pause=0x3
|
||||
auto=off
|
||||
rx=off
|
||||
tx=on
|
||||
;;
|
||||
rx)
|
||||
pause=0x4
|
||||
auto=off
|
||||
rx=on
|
||||
tx=off
|
||||
;;
|
||||
esac
|
||||
if [ "$auto" == "on" ]; then
|
||||
# Use ethswctl utility to set pause autoneg
|
||||
# as ethtool is not setting it properly
|
||||
ethswctl -c pause -n $unit -p $port -v $pause 2>&1 >/dev/null
|
||||
else
|
||||
ethtool --pause $ifname autoneg $auto rx $rx tx $tx 2>/dev/null
|
||||
fi
|
||||
|
||||
power_updown $ifname $enabled
|
||||
}
|
||||
19
ethmngr/files/ethmngr.init
Normal file
19
ethmngr/files/ethmngr.init
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=95
|
||||
STOP=10
|
||||
|
||||
USE_PROCD=1
|
||||
PROG=/usr/sbin/ethmngr
|
||||
|
||||
start_service() {
|
||||
procd_open_instance
|
||||
procd_set_param command ${PROG}
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
# arg1: port ifname, ex: eth0
|
||||
get_max_port_speed() {
|
||||
if [ -z "$1" ]; then
|
||||
echo 0
|
||||
return
|
||||
fi
|
||||
|
||||
local ifname="$1"
|
||||
local phycap="$(ethtool $ifname | grep -A 10 "Supported link modes" | grep 000 | tail -n 1 | awk '{print$NF}')"
|
||||
local speed=1000
|
||||
|
||||
case "$phycap" in
|
||||
10000*) speed=10000 ;;
|
||||
5000*) speed=5000 ;;
|
||||
2500*) speed=2500 ;;
|
||||
1000*) speed=1000 ;;
|
||||
100*) speed=100 ;;
|
||||
10*) speed=10 ;;
|
||||
esac
|
||||
|
||||
echo $speed
|
||||
}
|
||||
|
||||
# arg1: port ifname, ex: eth0
|
||||
# arg2: port enabled, ex: 1
|
||||
power_updown() {
|
||||
local ifname="$1"
|
||||
local enabled=$2
|
||||
|
||||
local updown="up"
|
||||
[ $enabled -eq 0 ] && updown="down"
|
||||
ip link set dev $ifname $updown
|
||||
}
|
||||
|
||||
# arg1: port ifname, ex: eth0
|
||||
# arg2: port enabled, ex: 1
|
||||
# arg3: port speed, ex: 1000
|
||||
# arg4: port duplex, ex: full
|
||||
# arg5: port autoneg, ex: on
|
||||
# arg6: port eee, ex: 0
|
||||
# arg7: port pause, ex: 0
|
||||
set_port_settings() {
|
||||
local ifname="$1"
|
||||
local enabled=$2
|
||||
local speed="$3"
|
||||
local duplex=$4
|
||||
local autoneg=$5
|
||||
local eee=$6
|
||||
local pause=$7
|
||||
|
||||
[ -d /sys/class/net/$ifname ] || return
|
||||
|
||||
[ $autoneg -eq 1 ] && autoneg="on" || autoneg="off"
|
||||
ethtool --change $ifname speed $speed duplex $duplex autoneg $autoneg
|
||||
|
||||
[ $eee -eq 1 ] && eee="on" || eee="off"
|
||||
ethtool --set-eee $ifname eee $eee 2>/dev/null
|
||||
|
||||
case $pause in
|
||||
off|0)
|
||||
pause=0x0
|
||||
auto=off
|
||||
rx=off
|
||||
tx=off
|
||||
;;
|
||||
on|1)
|
||||
pause=0x2
|
||||
auto=off
|
||||
rx=on
|
||||
tx=on
|
||||
;;
|
||||
auto)
|
||||
pause=0x1
|
||||
auto=on
|
||||
rx=on
|
||||
tx=on
|
||||
;;
|
||||
tx)
|
||||
pause=0x3
|
||||
auto=off
|
||||
rx=off
|
||||
tx=on
|
||||
;;
|
||||
rx)
|
||||
pause=0x4
|
||||
auto=off
|
||||
rx=on
|
||||
tx=off
|
||||
;;
|
||||
esac
|
||||
|
||||
ethtool --pause $ifname autoneg $auto rx $rx tx $tx 2>/dev/null
|
||||
|
||||
power_updown $ifname $enabled
|
||||
}
|
||||
@@ -8,11 +8,11 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=icwmp
|
||||
PKG_VERSION:=9.1.6
|
||||
PKG_VERSION:=9.1.2
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/icwmp.git
|
||||
PKG_SOURCE_VERSION:=79284d1f4e16cf6077a7394f0c04a894b83a8a41
|
||||
PKG_SOURCE_VERSION:=b964edb3570797286584793dbadfbef323cddbeb
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
|
||||
@@ -93,8 +93,7 @@ define Package/icwmp/default/install
|
||||
$(INSTALL_DATA) ./files/lib/upgrade/keep.d/icwmp $(1)/lib/upgrade/keep.d/icwmp
|
||||
$(INSTALL_BIN) ./files/etc/icwmpd/update.sh $(1)/etc/icwmpd/update.sh
|
||||
$(INSTALL_DATA) ./files/etc/bbfdm/json/CWMPManagementServer.json $(1)/etc/bbfdm/json/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/files/etc/udhcpc.user.d/udhcpc_icwmp_opt125.user $(1)/etc/udhcpc.user.d/udhcpc_icwmp_opt125.user
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/files/etc/udhcpc.user.d/udhcpc_icwmp_opt43.user $(1)/etc/udhcpc.user.d/udhcpc_icwmp_opt43.user
|
||||
$(INSTALL_BIN) ./files/etc/udhcpc.user.d/udhcpc_icwmp.user $(1)/etc/udhcpc.user.d/udhcpc_icwmp.user
|
||||
endef
|
||||
|
||||
Package/icwmp-openssl/install = $(Package/icwmp/default/install)
|
||||
|
||||
@@ -205,16 +205,6 @@ enable_dnsmasq_option125() {
|
||||
fi
|
||||
}
|
||||
|
||||
set_vendor_id() {
|
||||
local wan="${1}"
|
||||
local proto="$(uci -q get network.$wan.proto)"
|
||||
|
||||
if [ "${proto}" == "dhcp" ]; then
|
||||
uci -q set network.$wan.vendorid="dslforum.org"
|
||||
ubus call uci commit '{"config":"network"}'
|
||||
fi
|
||||
}
|
||||
|
||||
enable_disable_dhcp_option125() {
|
||||
local wan="${1}"
|
||||
local action="${2}"
|
||||
@@ -250,7 +240,7 @@ enable_disable_dhcp_option125() {
|
||||
uci -q set network.$wan.reqopts="$newreqopts"
|
||||
network_uci_update=1
|
||||
fi
|
||||
.
|
||||
|
||||
if [ ${send125_present} -eq 0 ]; then
|
||||
configure_send_op125 "${sendopts}" "${wan}" "network"
|
||||
network_uci_update=1
|
||||
@@ -300,9 +290,8 @@ copy_cwmp_etc_files_to_varstate() {
|
||||
|
||||
if [ -f /etc/icwmpd/cwmp ]; then
|
||||
uci -q -c /etc/icwmpd delete cwmp.acs
|
||||
uci -q -c /etc/icwmpd delete cwmp.gatewayinfo
|
||||
uci -q -c /etc/icwmpd commit cwmp
|
||||
cat /etc/icwmpd/cwmp >> /var/state/cwmp
|
||||
cp -f /etc/icwmpd/cwmp /var/state/cwmp
|
||||
fi
|
||||
|
||||
if [ -f /etc/icwmpd/icwmpd_backup_session.xml ]; then
|
||||
@@ -405,23 +394,15 @@ validate_defaults() {
|
||||
}
|
||||
|
||||
boot() {
|
||||
local enable_cwmp="0"
|
||||
local dhcp_discovery="0"
|
||||
|
||||
config_load cwmp
|
||||
config_get_bool enable_cwmp cpe enable 1
|
||||
if [ "$enable_cwmp" = "0" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
config_get dhcp_discovery acs dhcp_discovery "0"
|
||||
config_get wan_interface cpe default_wan_interface "wan"
|
||||
|
||||
config_get wan_interface cpe default_wan_interface "wan"
|
||||
if [ "${dhcp_discovery}" == "enable" ] || [ "${dhcp_discovery}" == "1" ]; then
|
||||
# Set dhcp option 43 if not already configured
|
||||
enable_dhcp_option43 "${wan_interface}"
|
||||
# Set dhcp option 60
|
||||
set_vendor_id "${wan_interface}"
|
||||
fi
|
||||
|
||||
config_get lan_interface cpe default_lan_interface ""
|
||||
@@ -440,9 +421,6 @@ boot() {
|
||||
regenerate_ssl_link "${ssl_capath}"
|
||||
fi
|
||||
|
||||
# Copy backup data so that if it restart latter on, it gets the info
|
||||
copy_cwmp_etc_files_to_varstate
|
||||
|
||||
start
|
||||
}
|
||||
|
||||
@@ -465,6 +443,9 @@ start_service() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Copy backup data so that if it restart latter on it gets the info
|
||||
copy_cwmp_etc_files_to_varstate
|
||||
|
||||
procd_open_instance icwmp
|
||||
procd_set_param command "$PROG"
|
||||
procd_append_param command -b
|
||||
|
||||
122
icwmp/files/etc/udhcpc.user.d/udhcpc_icwmp.user
Normal file
122
icwmp/files/etc/udhcpc.user.d/udhcpc_icwmp.user
Normal file
@@ -0,0 +1,122 @@
|
||||
#!/bin/sh
|
||||
|
||||
CLASS=""
|
||||
OUI=""
|
||||
SERIAL=""
|
||||
|
||||
get_vivsoi() {
|
||||
# opt125 environment variable has data in below format
|
||||
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
# | enterprise-number1 |
|
||||
# | |
|
||||
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
# | data-len1 | |
|
||||
# +-+-+-+-+-+-+-+-+ option-data1 |
|
||||
# / /
|
||||
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -----
|
||||
# | enterprise-number2 | ^
|
||||
# | | |
|
||||
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
||||
# | data-len2 | | optional
|
||||
# +-+-+-+-+-+-+-+-+ option-data2 | |
|
||||
# / / |
|
||||
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
||||
# ~ ... ~ V
|
||||
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -----
|
||||
|
||||
# Enterprise Id Len Sub Op SLen Data Sub Op SLen Data Sub Op SLen Data
|
||||
# +-------------+-----+------+------+----+------+-----+----+-----+------+-----+----+
|
||||
# | id | n | 1 | n1 | D1 | 2 | n2 | D2 | ... | 6 | n6 | D6 |
|
||||
# +-------------+-----+------+------+----+------+-----+----+-----+------+-----+----+
|
||||
|
||||
local opt125="$1"
|
||||
local len="$2"
|
||||
local ent_id
|
||||
|
||||
#hex-string 2 character=1 Byte
|
||||
# length in hex string will be twice of actual Byte length
|
||||
[ "$len" -gt "8" ] || return
|
||||
|
||||
data="${opt125}"
|
||||
rem_len="${len}"
|
||||
while [ $rem_len -gt 0 ]; do
|
||||
ent_id=${data:0:8}
|
||||
ent_id=$(printf "%d\n" "0x$ent_id")
|
||||
|
||||
if [ $ent_id -ne 3561 ]; then
|
||||
len_val=${data:8:2}
|
||||
data_len=$(printf "%d\n" "0x$len_val")
|
||||
# add 4 byte for ent_id and 1 byte for len
|
||||
data_len=$(( data_len * 2 + 10 ))
|
||||
# move ahead data to next enterprise id
|
||||
data=${data:"${data_len}":"${rem_len}"}
|
||||
rem_len=$(( rem_len - $data_len ))
|
||||
continue
|
||||
fi
|
||||
|
||||
# read the length of enterprise data
|
||||
len_val=${data:8:2}
|
||||
opt_len=$(printf "%d\n" "0x$len_val")
|
||||
[ $opt_len -eq 0 ] && return
|
||||
|
||||
# populate the option data of enterprise id
|
||||
sub_data_len=$(( opt_len * 2))
|
||||
# starting 10 means ahead of length field
|
||||
sub_data=${data:10:"${sub_data_len}"}
|
||||
|
||||
# parsing of suboption of option 125
|
||||
while [ $sub_data_len -gt 0 ]; do
|
||||
# get the suboption id
|
||||
sub_opt_id=${sub_data:0:2}
|
||||
sub_opt_id=$(printf "%d\n" "0x$sub_opt_id")
|
||||
|
||||
# get the length of suboption
|
||||
sub_opt_len=${sub_data:2:2}
|
||||
sub_opt_len=$(printf "%d\n" "0x$sub_opt_len")
|
||||
sub_opt_len=$(( sub_opt_len * 2 ))
|
||||
|
||||
# get the value of sub option starting 4 means starting after length
|
||||
sub_opt_val=${sub_data:4:${sub_opt_len}}
|
||||
|
||||
# assign the value found in sub option
|
||||
case "${sub_opt_id}" in
|
||||
"4") OUI=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
|
||||
;;
|
||||
"5") SERIAL=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
|
||||
;;
|
||||
"6") CLASS=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
|
||||
;;
|
||||
esac
|
||||
|
||||
# add 2 bytes for sub_opt id and sub_opt len field
|
||||
sub_opt_end=$(( sub_opt_len + 4 ))
|
||||
|
||||
# fetch next sub option hex string
|
||||
sub_data=${sub_data:${sub_opt_end}:${sub_data_len}}
|
||||
|
||||
# update the remaining sub option hex string length
|
||||
sub_data_len=$((sub_data_len - sub_opt_end))
|
||||
done
|
||||
|
||||
break
|
||||
done
|
||||
}
|
||||
|
||||
wan_intf=$(uci -q get cwmp.cpe.default_wan_interface)
|
||||
if [ -n "${wan_intf}" ] && [ "${wan_intf}" == "${INTERFACE}" ]; then
|
||||
if [ -n "$opt125" ]; then
|
||||
len=$(printf "$opt125"|wc -c)
|
||||
get_vivsoi "$opt125" "$len"
|
||||
fi
|
||||
|
||||
sec=$(uci -q -c /var/state get cwmp.gatewayinfo)
|
||||
if [ -z "${sec}" ]; then
|
||||
sec=$(uci -q -c /var/state add cwmp gatewayinfo)
|
||||
uci -q -c /var/state rename cwmp."${sec}"="gatewayinfo"
|
||||
fi
|
||||
|
||||
uci -q -c /var/state set cwmp.gatewayinfo.class="$CLASS"
|
||||
uci -q -c /var/state set cwmp.gatewayinfo.oui="$OUI"
|
||||
uci -q -c /var/state set cwmp.gatewayinfo.serial="$SERIAL"
|
||||
uci -q -c /var/state commit cwmp
|
||||
fi
|
||||
@@ -5,12 +5,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ieee1905
|
||||
PKG_VERSION:=7.0.2
|
||||
PKG_VERSION:=6.0.16
|
||||
|
||||
LOCAL_DEV=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=47c04c502edf441fef9f14307be5f07541614049
|
||||
PKG_SOURCE_VERSION:=3b12bdd1b0e75f4e5b744e18f00ab5ac703382e6
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/ieee1905.git
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
|
||||
@@ -44,8 +44,7 @@ validate_ap_section() {
|
||||
uci_validate_section ieee1905 $section "${1}" \
|
||||
'band:or("2", "5", "60", "6")' \
|
||||
'ssid:string' \
|
||||
'encryption:or("psk2", "sae-mixed", "sae",
|
||||
"psk", "psk-mixed", "none", string)' \
|
||||
'encryption:or("psk2", "sae-mixed", "sae", string)' \
|
||||
'key:string' \
|
||||
'uuid:string' \
|
||||
'manufacturer:string' \
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
config_load ieee1905
|
||||
|
||||
ifname_to_list() {
|
||||
local section=$1
|
||||
|
||||
config_get ifname $section ifname # get list or option as space separated values
|
||||
ifname=${ifname//,/\ } # convert csv with space separation
|
||||
uci del ieee1905.${section}.ifname # delete entry
|
||||
for i in ${ifname}; do
|
||||
uci add_list ieee1905.${section}.ifname="$i" # writeback entry as list
|
||||
done
|
||||
}
|
||||
|
||||
config_foreach ifname_to_list al-iface
|
||||
@@ -56,8 +56,8 @@ CONFIG_LOCALMIRROR="https://download.iopsys.eu/iopsys/mirror/"
|
||||
|
||||
# EasySoC HAL #
|
||||
CONFIG_PACKAGE_inbd=y
|
||||
CONFIG_PACKAGE_qosmngr=y
|
||||
CONFIG_PACKAGE_libwifiutils=y
|
||||
CONFIG_PACKAGE_libwifi=y
|
||||
CONFIG_PACKAGE_port-management=y
|
||||
CONFIG_PACKAGE_wifimngr=y
|
||||
|
||||
# Multi-AP #
|
||||
@@ -153,7 +153,6 @@ CONFIG_PACKAGE_ip-bridge=y
|
||||
CONFIG_PACKAGE_ip-full=y
|
||||
CONFIG_PACKAGE_iperf3=y
|
||||
CONFIG_PACKAGE_ipset=y
|
||||
CONFIG_PACKAGE_ip6tables-zz-legacy=y
|
||||
CONFIG_PACKAGE_iptables-zz-legacy=y
|
||||
CONFIG_PACKAGE_iptables-mod-conntrack-extra=y
|
||||
CONFIG_PACKAGE_iptables-mod-filter=y
|
||||
|
||||
@@ -276,22 +276,11 @@ function genconfig {
|
||||
setup_dirs()
|
||||
{
|
||||
git remote -v | grep -q http || {
|
||||
CUSTBRANCH="$(git rev-parse --abbrev-ref HEAD)"
|
||||
if git ls-remote $CUSTREPO -q 2>/dev/null; then
|
||||
if [ ! -d "$CUSTPATH" ]; then
|
||||
echo "Cloning $CUSTBRANCH branch of $CUSTREPO"
|
||||
git clone -b "$CUSTBRANCH" "$CUSTREPO" "$CUSTPATH" 2>/dev/null || {
|
||||
DEFBRANCH="$(git remote show $CUSTREPO | grep 'HEAD branch' | cut -d' ' -f5)"
|
||||
echo "$CUSTBRANCH branch is not found, cloning $DEFBRANCH branch of $CUSTREPO"
|
||||
git clone "$CUSTREPO" "$CUSTPATH"
|
||||
}
|
||||
git clone "$CUSTREPO" "$CUSTPATH"
|
||||
elif [ $IMPORT -eq 1 ]; then
|
||||
cd $CUSTPATH
|
||||
echo "Checking out $CUSTBRANCH branch in $CUSTPATH"
|
||||
git checkout "$CUSTBRANCH" 2>/dev/null || {
|
||||
DEFBRANCH="$(git symbolic-ref refs/remotes/origin/HEAD | cut -d '/' -f4)"
|
||||
echo "Checking out $CUSTBRANCH branch has failed, using $DEFBRANCH branch in $CUSTPATH"
|
||||
}
|
||||
v "git pull"
|
||||
git pull
|
||||
cd - >/dev/null #go back
|
||||
@@ -351,7 +340,7 @@ function genconfig {
|
||||
echo "" >> .config
|
||||
fi
|
||||
|
||||
# Special handling for targets which use TARGET_DEVICES
|
||||
# Special handling for targets which use TARGET_DEVICES
|
||||
case "$target" in
|
||||
iopsys_ramips | airoha | iopsys_mediatek | brcmbca | ipq95xx)
|
||||
# This assumes the device name to be unique within one target,
|
||||
|
||||
@@ -192,6 +192,12 @@ function genconfig_min {
|
||||
|
||||
git remote -v | grep -qE '(git@|ssh://)' && {
|
||||
DEVELOPER=1
|
||||
|
||||
bcmAllowed=0
|
||||
endptAllowed=0
|
||||
|
||||
git ls-remote git@dev.iopsys.eu:broadcom/bcmcreator.git -q 2>/dev/null && bcmAllowed=1
|
||||
git ls-remote git@dev.iopsys.eu:iopsys/endptmngr.git -q 2>/dev/null && endptAllowed=1
|
||||
}
|
||||
|
||||
v() {
|
||||
|
||||
@@ -16,7 +16,7 @@ LOCAL_DEV=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/$(PKG_NAME).git
|
||||
PKG_SOURCE_VERSION:=d066c9d5c14757ab38e9ecb265ba24f5b33cdbce
|
||||
PKG_SOURCE_VERSION:=b53e93ca1a2fdda56ca9caffb6020e158e684f3d
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
endif
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=map-agent
|
||||
PKG_VERSION:=4.1.0.1
|
||||
PKG_VERSION:=2.10.4.11
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE_VERSION:=c708092f56110637f04d87d309dcbce8fd389b89
|
||||
PKG_SOURCE_VERSION:=0852c7803475f7fb919f680d02437ba9672c42fc
|
||||
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu>
|
||||
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
|
||||
@@ -104,11 +104,7 @@ validate_radio_section() {
|
||||
'include_sta_metric:bool:false' \
|
||||
'rcpi_hysteresis_margin:range(0,255)' \
|
||||
'report_util_threshold:range(0,255)' \
|
||||
'encryption:or("sae", "sae+aes", "psk2",
|
||||
"psk2+aes", "sae-mixed", "sae-mixed+aes",
|
||||
"none", "psk-mixed", "psk-mixed+aes",
|
||||
"wpa", "wpa+aes", "wpa2", "wpa2+aes",
|
||||
"psk", "psk+aes")' \
|
||||
'encryption:or("sae", "psk2", "sae-mixed")'
|
||||
|
||||
[ "$?" -ne 0 ] && {
|
||||
logger -s -t "mapagent" "Validation of radio section failed"
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=map-controller
|
||||
PKG_VERSION:=4.1.0.2
|
||||
PKG_VERSION:=2.11.0.20
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE_VERSION:=8b7bb003611247309b072350d7986e304b0d228b
|
||||
PKG_SOURCE_VERSION:=5ff7f037c040d337982a1e3a51693fb8e0682046
|
||||
|
||||
LOCAL_DEV=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
@@ -26,7 +26,7 @@ define Package/map-controller
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=WiFi Multi-AP Controller (EasyMesh R2)
|
||||
DEPENDS:=+libuci +libubox +ubus +libeasy +libwifiutils +libieee1905 +ieee1905 +map-plugin
|
||||
DEPENDS:=+libuci +libubox +ubus +libeasy +libieee1905 +ieee1905 +map-plugin
|
||||
endef
|
||||
|
||||
define Package/map-controller/description
|
||||
|
||||
@@ -45,13 +45,7 @@ validate_sta_steering_section() {
|
||||
'use_bcn_metrics:bool:false' \
|
||||
'use_usta_metrics:bool:false' \
|
||||
'bandsteer:bool:false' \
|
||||
'diffsnr:range(0,100)' \
|
||||
'rcpi_threshold_2g:range(0,220)' \
|
||||
'rcpi_threshold_5g:range(0,220)' \
|
||||
'rcpi_threshold_6g:range(0,220)' \
|
||||
'report_rcpi_threshold_2g:range(0,220)' \
|
||||
'report_rcpi_threshold_5g:range(0,220)' \
|
||||
'report_rcpi_threshold_6g:range(0,220)'
|
||||
'diffsnr:range(0,100)'
|
||||
|
||||
[ "$?" -ne 0 ] && {
|
||||
logger -s -t "mapcontroller" "Validation of sta_steering section failed"
|
||||
@@ -68,10 +62,7 @@ validate_ap_section() {
|
||||
'band:or("2", "5", "6")' \
|
||||
'ssid:string' \
|
||||
'encryption:or("sae", "sae+aes", "psk2",
|
||||
"psk2+aes", "sae-mixed", "sae-mixed+aes",
|
||||
"none", "psk-mixed", "psk-mixed+aes",
|
||||
"wpa", "wpa+aes", "wpa2", "wpa2+aes",
|
||||
"psk", "psk+aes")' \
|
||||
"psk2+aes", "sae-mixed", "sae-mixed+aes")' \
|
||||
'key:string' \
|
||||
'vid:range(1,65535):1' \
|
||||
'type:or("backhaul", "fronthaul", "combined")' \
|
||||
@@ -199,7 +190,7 @@ reload_service() {
|
||||
return
|
||||
fi
|
||||
|
||||
pidof "/usr/sbin/mapcontroller" > /dev/null
|
||||
pidof "mapcontroller" > /dev/null
|
||||
if [[ $? -ne 0 ]] ; then
|
||||
start
|
||||
return
|
||||
|
||||
@@ -6,11 +6,11 @@ include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=map-topology
|
||||
PKG_VERSION:=2.5.1.15
|
||||
PKG_VERSION:=2.5.1.13
|
||||
|
||||
LOCAL_DEV:=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_VERSION:=14ff07452aec4ff6f2268ef7bea9ff417252b7be
|
||||
PKG_SOURCE_VERSION:=aaa55a72e719184af32d57a9b40bec1c440774a9
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/map-topology.git
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz
|
||||
|
||||
@@ -4,4 +4,3 @@ config topology 'topology'
|
||||
option depth '8'
|
||||
option interval '60'
|
||||
option maxlog '32'
|
||||
option profile '2'
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
day=""
|
||||
IP_RULE=""
|
||||
|
||||
process_ac_schedule() {
|
||||
local acs_id="$1"
|
||||
local is_enabled
|
||||
local access_control
|
||||
local start_time=""
|
||||
local stop_time=""
|
||||
local mac=""
|
||||
|
||||
handle_day_list() {
|
||||
local value=$1
|
||||
|
||||
val=$(echo $value | cut -c 1-3)
|
||||
if [ -z $day ]; then
|
||||
day="$val"
|
||||
else
|
||||
day="$day,$val"
|
||||
fi
|
||||
}
|
||||
|
||||
config_list_foreach "$acs_id" "day" handle_day_list
|
||||
config_get is_enabled "$acs_id" "enable" 1
|
||||
config_get access_control "$acs_id" "dm_parent"
|
||||
|
||||
if [ "$is_enabled" == "0" ] || [ -z "$access_control" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
IP_RULE=""
|
||||
|
||||
mac=$(uci -q get hosts.$access_control.macaddr)
|
||||
access_policy=$(uci -q get hosts.$access_control.access_policy)
|
||||
|
||||
config_get start_time "$acs_id" "start_time"
|
||||
config_get duration "$acs_id" "duration"
|
||||
|
||||
if [ -z "$mac" ] && [ -z "$start_time" ] && [ -z "$duration" ] && [ -z "$day" ] && [ -z "$access_policy" ]; then
|
||||
return
|
||||
fi
|
||||
if [ -n "$mac" ]; then
|
||||
IP_RULE="$IP_RULE -m mac --mac-source $mac"
|
||||
fi
|
||||
|
||||
# as per iptables manual default starttime is 00:00
|
||||
# default stoptime is 23:59
|
||||
if [ -z "$start_time" ]; then
|
||||
start_time="0:0"
|
||||
fi
|
||||
|
||||
if [ -n "$duration" ]; then
|
||||
hh=$(echo $start_time | awk -F: '{ print $1 }')
|
||||
mm=$(echo $start_time | awk -F: '{ print $2 }')
|
||||
hh_s=`expr $hh \* 3600`
|
||||
mm_s=`expr $mm \* 60`
|
||||
ss=$(( hh_s + mm_s ))
|
||||
|
||||
stop_ss=$(( ss + duration ))
|
||||
hh=$(( stop_ss / 3600 ))
|
||||
if [ $hh -lt 24 ]; then
|
||||
rem_ss=$(( stop_ss % 3600 ))
|
||||
mm=$(( rem_ss / 60 ))
|
||||
ss=$(( rem_ss % 60 ))
|
||||
stop_time="$hh:$mm:$ss"
|
||||
else
|
||||
stop_time="23:59"
|
||||
fi
|
||||
else
|
||||
stop_time="23:59"
|
||||
fi
|
||||
|
||||
# conversion to utc
|
||||
zone=$(date +%z | cut -c 1)
|
||||
utc_h=$(date -u -d @$(date "+%s" -d "$start_time") +%H)
|
||||
local_h=$(echo $start_time | awk -F: '{ print $1 }')
|
||||
if [ "$zone" == "+" ] && [ $utc_h -gt $local_h ]; then
|
||||
start_utc="0:0"
|
||||
else
|
||||
start_utc=$(date -u -d @$(date "+%s" -d "$start_time") +%H:%M)
|
||||
fi
|
||||
|
||||
utc_h=$(date -u -d @$(date "+%s" -d "$stop_time") +%H)
|
||||
local_h=$(echo $stop_time | awk -F: '{ print $1 }')
|
||||
if [ "$zone" == "-" ] && [ $utc_h -lt $local_h ]; then
|
||||
stop_utc="23:59"
|
||||
else
|
||||
stop_utc=$(date -u -d @$(date "+%s" -d "$stop_time") +%H:%M)
|
||||
fi
|
||||
|
||||
|
||||
IP_RULE="$IP_RULE -m time --timestart $start_utc --timestop $stop_utc"
|
||||
if [ -n "$day" ]; then
|
||||
IP_RULE="$IP_RULE --weekdays $day"
|
||||
fi
|
||||
|
||||
if [ "$access_policy" == "Deny" ]; then
|
||||
IP_RULE="$IP_RULE -j DROP"
|
||||
else
|
||||
IP_RULE="$IP_RULE -j ACCEPT"
|
||||
fi
|
||||
|
||||
iptables -w -A hosts_forward ${IP_RULE}
|
||||
ip6tables -w -A hosts_forward ${IP_RULE}
|
||||
|
||||
day=""
|
||||
}
|
||||
|
||||
iptables -w -F hosts_forward
|
||||
ip6tables -w -F hosts_forward
|
||||
|
||||
iptables -w -t filter -N hosts_forward
|
||||
ret=$?
|
||||
[ $ret -eq 0 ] && iptables -w -t filter -I FORWARD -j hosts_forward
|
||||
ip6tables -w -t filter -N hosts_forward
|
||||
ret=$?
|
||||
[ $ret -eq 0 ] && ip6tables -w -t filter -I FORWARD -j hosts_forward
|
||||
|
||||
# Load /etc/config/hosts UCI file
|
||||
config_load hosts
|
||||
config_foreach process_ac_schedule ac_schedule
|
||||
|
||||
@@ -71,10 +71,6 @@ start_service() {
|
||||
config_load "hosts"
|
||||
validate_hosts_config || return 1;
|
||||
|
||||
if [ -f "/proc/sys/net/netfilter/nf_conntrack_timestamp" ]; then
|
||||
echo 1 >/proc/sys/net/netfilter/nf_conntrack_timestamp
|
||||
fi
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command "/usr/sbin/topologyd"
|
||||
procd_set_param respawn
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -f /etc/firewall.hosts ]; then
|
||||
uci -q get firewall.hosts || {
|
||||
uci -q set firewall.hosts=include
|
||||
uci -q set firewall.hosts.path="/etc/firewall.hosts"
|
||||
uci -q set firewall.hosts.reload=1
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
exit 0
|
||||
308
mqttmngr/LICENSE
Normal file
308
mqttmngr/LICENSE
Normal file
@@ -0,0 +1,308 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
uspd - USP Daemon exposing USP API over uBus
|
||||
Copyright (C) 2019 iopsys Software Solutions AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
44
mqttmngr/Makefile
Normal file
44
mqttmngr/Makefile
Normal file
@@ -0,0 +1,44 @@
|
||||
#
|
||||
# Copyright (C) 2022 IOPSYS
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=mqttmngr
|
||||
PKG_VERSION:=1.0.0
|
||||
PKG_RELEASE:=1
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||
PKG_LICENSE:=GPL-2.0-only
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/mqttmngr
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=TRx69
|
||||
DEPENDS:= +libbbf_api +mosquitto
|
||||
TITLE:=Package to add Device.MQTT. datamodel support
|
||||
endef
|
||||
|
||||
define Package/mqttmngr/description
|
||||
Package to add Device.MQTT. datamodel support
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) src/* $(PKG_BUILD_DIR)
|
||||
mkdir -p $(PKG_BUILD_DIR)/files
|
||||
$(CP) files/* $(PKG_BUILD_DIR)/files/
|
||||
endef
|
||||
|
||||
define Package/mqttmngr/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/bbfdm
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/libmqttmngr.so $(1)/usr/lib/bbfdm/libmqttmngr.so
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/files/etc/uci-defaults/01-mosquitto-config $(1)/etc/uci-defaults/01-mosquitto-config
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,mqttmngr))
|
||||
4
mqttmngr/README.md
Normal file
4
mqttmngr/README.md
Normal file
@@ -0,0 +1,4 @@
|
||||
# MQTTmngr
|
||||
MQTT manager is a lightweight program to manage MQTT broker. It also provides the TR181 datamodel object `Device.MQTT.` using libbbf DotSO plugin.
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ config_mosquitto_owrt() {
|
||||
fi
|
||||
|
||||
uci -q set mosquitto.owrt.use_uci="1"
|
||||
uci -q set mosquitto.owrt.write_pid="1"
|
||||
uci -q set mosquitto.owrt.write_pid="0"
|
||||
uci -q commit mosquitto
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ config_mosquitto_general() {
|
||||
fi
|
||||
|
||||
uci -q set mosquitto.mosquitto.log_dest="syslog"
|
||||
uci -q set mosquitto.mosquitto.include_dir="/etc/mosquitto/conf.d"
|
||||
uci -q set mosquitto.mosquitto.log_facility="5"
|
||||
uci -q set mosquitto.mosquitto.log_timestamp="1"
|
||||
uci -q set mosquitto.mosquitto.log_types="error warning notice"
|
||||
17
mqttmngr/src/Makefile
Normal file
17
mqttmngr/src/Makefile
Normal file
@@ -0,0 +1,17 @@
|
||||
LIB = libmqttmngr.so
|
||||
|
||||
LIB_OBJS = mqtt.o
|
||||
|
||||
PROG_CFLAGS = $(CFLAGS) -Wall -Werror -fPIC
|
||||
LIB_LDFLAGS = $(LDFLAGS)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(PROG_CFLAGS) $(FPIC) -c -o $@ $<
|
||||
|
||||
all: $(LIB)
|
||||
|
||||
$(LIB): $(LIB_OBJS)
|
||||
$(CC) $(PROG_CFLAGS) $(LIB_LDFLAGS) -shared -o $@ $^
|
||||
|
||||
clean:
|
||||
rm -f *.o $(LIB)
|
||||
334
mqttmngr/src/mqtt.c
Normal file
334
mqttmngr/src/mqtt.c
Normal file
@@ -0,0 +1,334 @@
|
||||
/*
|
||||
* Copyright (C) 2022 iopsys Software Solutions AB
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 2.1
|
||||
* as published by the Free Software Foundation
|
||||
*
|
||||
* Author: Suvendhu Hansa <suvendhu.hansa@iopsys.eu>
|
||||
*/
|
||||
|
||||
#include <libbbf_api.h>
|
||||
|
||||
#include "mqtt.h"
|
||||
|
||||
static bool duplicate_entry_exist(char *name, char *section_type)
|
||||
{
|
||||
bool exist = false;
|
||||
struct uci_section *s = NULL, *stmp = NULL;
|
||||
|
||||
uci_foreach_sections_safe("mosquitto", section_type, stmp, s) {
|
||||
if (DM_STRCMP(name, section_name(s)) == 0) {
|
||||
exist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return exist;
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
* ADD & DEL OBJ
|
||||
**************************************************************/
|
||||
static int addMQTTBroker(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
struct uci_section *s = NULL, *dmmap_broker = NULL;
|
||||
char sec_name[40];
|
||||
|
||||
snprintf(sec_name, sizeof(sec_name), "broker_%s", *instance);
|
||||
|
||||
if (bbf_uci_add_section("mosquitto", "listener", &s) == 0) {
|
||||
bbf_uci_rename_section(s, sec_name);
|
||||
bbf_uci_set_value_by_section(s, "enabled", "0");
|
||||
bbf_uci_add_section_bbfdm("dmmap_mqtt", "listener", &dmmap_broker);
|
||||
bbf_uci_set_value_by_section(dmmap_broker, "section_name", sec_name);
|
||||
bbf_uci_set_value_by_section(dmmap_broker, "listener_instance", *instance);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int delMQTTBroker(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
|
||||
{
|
||||
struct uci_section *s = NULL, *stmp = NULL;
|
||||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
bbf_uci_delete_section_by_section(((struct dmmap_dup *)data)->config_section, NULL, NULL);
|
||||
bbf_uci_delete_section_by_section(((struct dmmap_dup *)data)->dmmap_section, NULL, NULL);
|
||||
break;
|
||||
case DEL_ALL:
|
||||
bbf_uci_foreach_sections_safe("users", "user", stmp, s) {
|
||||
struct uci_section *dmmap_section = NULL;
|
||||
get_dmmap_section_of_config_section("dmmap_users", "user", section_name(s), &dmmap_section);
|
||||
bbf_uci_delete_section_by_section(s, NULL, NULL);
|
||||
bbf_uci_delete_section_by_section(dmmap_section, NULL, NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
* ENTRY METHOD
|
||||
*************************************************************/
|
||||
static int browseMQTTBrokerInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct dmmap_dup *p = NULL;
|
||||
char *inst = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
|
||||
synchronize_specific_config_sections_with_dmmap("mosquitto", "listener", "dmmap_mqtt", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "listener_instance", "listener_alias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, inst) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
free_dmmap_config_dup_list(&dup_list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
* GET & SET PARAM
|
||||
**************************************************************/
|
||||
static int get_MQTT_BrokerNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
int cnt = bbf_get_number_of_entries(ctx, data, instance, browseMQTTBrokerInst);
|
||||
dmasprintf(value, "%d", cnt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_MQTTBroker_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
bbf_uci_get_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "listener_alias", value);
|
||||
if ((*value)[0] == '\0')
|
||||
dmasprintf(value, "cpe-%s", instance);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_MQTTBroker_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (dm_validate_string(value, -1, 64, NULL, NULL))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
bbf_uci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "listener_alias", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_MQTTBroker_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = bbf_uci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "enabled", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_MQTTBroker_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
bool b;
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (dm_validate_boolean(value))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
bbf_uci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "enabled", b ? "1" : "0");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_MQTTBroker_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
bbf_uci_get_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "section_name", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_MQTTBroker_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *curr_name = NULL;
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (dm_validate_string(value, -1, 64, NULL, NULL))
|
||||
return FAULT_9007;
|
||||
|
||||
// Check if the value is empty
|
||||
if (*value == '\0')
|
||||
return FAULT_9007;
|
||||
|
||||
// Check if new name is same as current name
|
||||
curr_name = section_name(((struct dmmap_dup *)data)->config_section);
|
||||
if (DM_STRCMP(curr_name, value) == 0)
|
||||
break;
|
||||
|
||||
// check if duplicate entry already exists
|
||||
if (duplicate_entry_exist(value, "listener"))
|
||||
return FAULT_9001;
|
||||
|
||||
break;
|
||||
case VALUESET:
|
||||
// If new name is same as current name then nothing to do
|
||||
curr_name = section_name(((struct dmmap_dup *)data)->config_section);
|
||||
if (DM_STRCMP(curr_name, value) == 0)
|
||||
break;
|
||||
|
||||
// Update mosquitto config
|
||||
if (0 != bbf_uci_rename_section(((struct dmmap_dup *)data)->config_section, value))
|
||||
return FAULT_9001;
|
||||
|
||||
// Update dmmap_users file
|
||||
bbf_uci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "section_name", value);
|
||||
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_MQTTBroker_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = bbf_uci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "port", "1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_MQTTBroker_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (dm_validate_unsignedInt(value, RANGE_ARGS{{"1",NULL}}, 1))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
bbf_uci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "port", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_MQTTBroker_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *intf = NULL;
|
||||
|
||||
bbf_uci_get_value_by_section(((struct dmmap_dup *)data)->config_section, "interface", &intf);
|
||||
if (DM_STRLEN(intf) == 0)
|
||||
return 0;
|
||||
|
||||
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", intf, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_MQTTBroker_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
|
||||
char *iface = NULL;
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (dm_validate_string(value, -1, 256, NULL, NULL))
|
||||
return FAULT_9007;
|
||||
|
||||
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
|
||||
return FAULT_9007;
|
||||
|
||||
break;
|
||||
case VALUESET:
|
||||
adm_entry_get_linker_value(ctx, value, &iface);
|
||||
if (DM_STRLEN(iface) != 0)
|
||||
bbf_uci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "interface", iface);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_MQTTBroker_Username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
bbf_uci_get_value_by_section(((struct dmmap_dup *)data)->config_section, "username", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_MQTTBroker_Username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (dm_validate_string(value, -1, 64, NULL, NULL))
|
||||
return FAULT_9007;
|
||||
|
||||
// Check if the value is empty
|
||||
if (*value == '\0')
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
bbf_uci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "username", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_MQTTBroker_Password(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = "";
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_MQTTBroker_Password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (dm_validate_string(value, -1, 64, NULL, NULL))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
bbf_uci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "password", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************
|
||||
* OBJ & LEAF DEFINITION
|
||||
**********************************************************************************************************************************/
|
||||
DM_MAP_OBJ tDynamicObj[] = {
|
||||
/* parentobj, nextobject, parameter */
|
||||
{"Device.", tDeviceMQTTObj, NULL},
|
||||
{0}
|
||||
};
|
||||
|
||||
/* *** Device.MQTT. *** */
|
||||
DMOBJ tDeviceMQTTObj[] = {
|
||||
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
|
||||
{"MQTT", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tMQTTObj, tMQTTParams, NULL, BBFDM_BOTH, NULL, "2.10"},
|
||||
{0}
|
||||
};
|
||||
|
||||
/* *** Device.MQTT.Broker. *** */
|
||||
DMOBJ tMQTTObj[] = {
|
||||
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
|
||||
{"Broker", &DMWRITE, addMQTTBroker, delMQTTBroker, NULL, browseMQTTBrokerInst, NULL, NULL, NULL, tMQTTBrokerParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", "Name", NULL}, "2.10"},
|
||||
{0}
|
||||
};
|
||||
|
||||
DMLEAF tMQTTParams[] = {
|
||||
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
|
||||
{"BrokerNumberOfEntries", &DMREAD, DMT_UNINT, get_MQTT_BrokerNumberOfEntries, NULL, BBFDM_BOTH, "2.10"},
|
||||
{0}
|
||||
};
|
||||
|
||||
DMLEAF tMQTTBrokerParams[] = {
|
||||
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
|
||||
{"Enable", &DMWRITE, DMT_BOOL, get_MQTTBroker_Enable, set_MQTTBroker_Enable, BBFDM_BOTH, "2.10"},
|
||||
{"Alias", &DMWRITE, DMT_STRING, get_MQTTBroker_Alias, set_MQTTBroker_Alias, BBFDM_BOTH, "2.10"},
|
||||
{"Name", &DMWRITE, DMT_STRING, get_MQTTBroker_Name, set_MQTTBroker_Name, BBFDM_BOTH, "2.10"},
|
||||
//{"Status", &DMREAD, DMT_STRING, get_MQTTBroker_Status, NULL, BBFDM_BOTH, "2.10"},
|
||||
{"Port", &DMWRITE, DMT_UNINT, get_MQTTBroker_Port, set_MQTTBroker_Port, BBFDM_BOTH, "2.10"},
|
||||
{"Interface", &DMWRITE, DMT_STRING, get_MQTTBroker_Interface, set_MQTTBroker_Interface, BBFDM_BOTH, "2.10"},
|
||||
{"Username", &DMWRITE, DMT_STRING, get_MQTTBroker_Username, set_MQTTBroker_Username, BBFDM_BOTH, "2.10"},
|
||||
{"Password", &DMWRITE, DMT_STRING, get_MQTTBroker_Password, set_MQTTBroker_Password, BBFDM_BOTH, "2.10"},
|
||||
{0}
|
||||
};
|
||||
|
||||
20
mqttmngr/src/mqtt.h
Normal file
20
mqttmngr/src/mqtt.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2022 iopsys Software Solutions AB
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 2.1
|
||||
* as published by the Free Software Foundation
|
||||
*
|
||||
* Author: Suvendhu Hansa <suvendhu.hansa@iopsys.eu>
|
||||
*/
|
||||
|
||||
#ifndef _MQTT_H
|
||||
#define _MQTT_H
|
||||
|
||||
#include "libbbf_api/dmcommon.h"
|
||||
|
||||
extern DMOBJ tDeviceMQTTObj[];
|
||||
extern DMOBJ tMQTTObj[];
|
||||
extern DMLEAF tMQTTParams[];
|
||||
extern DMLEAF tMQTTBrokerParams[];
|
||||
#endif
|
||||
@@ -5,13 +5,13 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=obuspa
|
||||
PKG_VERSION:=7.0.0.1
|
||||
PKG_VERSION:=6.0.0.11
|
||||
|
||||
LOCAL_DEV:=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/fork/obuspa.git
|
||||
PKG_SOURCE_VERSION:=5d4bacd53a8ca27948108009bb48c2c6c9508c1d
|
||||
PKG_SOURCE_VERSION:=668748cd4801aa5af12d61d9b0837064b9f933cc
|
||||
PKG_MAINTAINER:=Vivek Dutta <vivek.dutta@iopsys.eu>
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
@@ -110,7 +110,6 @@ define Package/obuspa/install
|
||||
$(INSTALL_DATA) ./files/etc/bbfdm/json/USPAgent.json $(1)/etc/bbfdm/json/USPAgent.json
|
||||
$(INSTALL_DATA) ./files/etc/bbfdm/json/TransferComplete.json $(1)/etc/bbfdm/json/TransferComplete.json
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/01-fix-upgrade-uci $(1)/etc/uci-defaults/
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/50-add-mqtt-usp-test $(1)/etc/uci-defaults/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,obuspa))
|
||||
|
||||
@@ -11,22 +11,54 @@ config obuspa 'global'
|
||||
#option log_dest '/var/log/obuspa'
|
||||
|
||||
# Adds Device.LocalAgent.MTP.
|
||||
config mtp 'test_mtp'
|
||||
config mtp 'agent_mtp'
|
||||
option Protocol 'MQTT'
|
||||
option ResponseTopicConfigured '/usp/endpoint'
|
||||
option mqtt 'testmqtt'
|
||||
option mqtt 'localmqtt'
|
||||
|
||||
# Adds Device.MQTT.Client.
|
||||
config mqtt 'testmqtt'
|
||||
config mqtt 'localmqtt'
|
||||
option BrokerAddress '127.0.0.1'
|
||||
option BrokerPort '1883'
|
||||
option TransportProtocol 'TCP/IP'
|
||||
|
||||
# Adds Device.LocalAgent.Controller.
|
||||
config controller 'testcontroller'
|
||||
config controller 'localcontroller'
|
||||
option EndpointID 'proto::interop-usp-controller'
|
||||
option Protocol 'MQTT'
|
||||
option Topic '/usp/controller'
|
||||
option mqtt 'testmqtt'
|
||||
option mqtt 'localmqtt'
|
||||
option assigned_role_name 'full_access'
|
||||
|
||||
# Add Device.LocalAgent.Subscription.
|
||||
#config subscription 'sub_event'
|
||||
# option ID 'uci-sub-events'
|
||||
# option NotifType 'Event'
|
||||
# list ReferenceList 'Device.Boot!'
|
||||
# list ReferenceList 'Device.LocalAgent.TransferComplete!'
|
||||
# option Persistent 'true'
|
||||
# option controller 'localcontroller'
|
||||
|
||||
#config subscription 'sub_op_comp'
|
||||
# option ID 'uci-sub-op_complete'
|
||||
# option NotifType 'OperationComplete'
|
||||
# list ReferenceList 'Device.DeviceInfo.FirmwareImage.*.Download()'
|
||||
# list ReferenceList 'Device.DeviceInfo.FirmwareImage.*.Activate()'
|
||||
# option Persistent 'true'
|
||||
# option controller 'localcontroller'
|
||||
|
||||
#config challenge 'admin'
|
||||
# option Description 'Request to get Administrative access'
|
||||
# option role_name 'full_access'
|
||||
# option Enable '1'
|
||||
# option Value 'YWRtaW4='
|
||||
# option Retries 2
|
||||
# option LockoutPeriod 60
|
||||
|
||||
#config challenge 'user'
|
||||
# option Description 'Request to get User access'
|
||||
# option role_name 'user'
|
||||
# option Enable '1'
|
||||
# option Value 'dXNlcg=='
|
||||
# option Retries 3
|
||||
# option LockoutPeriod 30
|
||||
|
||||
@@ -314,7 +314,7 @@ publish_endpoint()
|
||||
{
|
||||
local AgentEndpointID serial oui user pass
|
||||
|
||||
if ! uci -q get obuspa.testmqtt; then
|
||||
if ! uci -q get obuspa.localmqtt; then
|
||||
return 0;
|
||||
fi
|
||||
|
||||
@@ -330,11 +330,11 @@ publish_endpoint()
|
||||
if [ -z "${AgentEndpointID}" ]; then
|
||||
serial=$(get_serial_from_db)
|
||||
oui=$(get_oui_from_db)
|
||||
AgentEndpointID="os::${oui}-${serial//+/%2B}"
|
||||
AgentEndpointID="os::${oui}-${serial}"
|
||||
fi
|
||||
|
||||
config_get user testmqtt Username
|
||||
config_get pass testmqtt Password
|
||||
config_get user localmqtt Username
|
||||
config_get pass localmqtt Password
|
||||
|
||||
# publish Agent's EndpointID in mosquito broker for discovery by usp-js
|
||||
# This is a work around till obuspa adds supports for mDNS discovery
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
add_usp_test()
|
||||
{
|
||||
if ! uci_get mosquitto usptest >/dev/null 2>&1; then
|
||||
uci_add mosquitto listener usptest
|
||||
uci_set mosquitto usptest enabled 1
|
||||
uci_set mosquitto usptest port '9001'
|
||||
uci_set mosquitto usptest protocol 'websockets'
|
||||
uci_set mosquitto usptest require_certificates '0'
|
||||
uci_set mosquitto usptest auth_plugin '/usr/lib/mosquitto_auth_shadow.so'
|
||||
fi
|
||||
}
|
||||
|
||||
uci_load mosquitto
|
||||
add_usp_test
|
||||
140
obuspa/patches/0001-validate-mtp-topic.patch
Normal file
140
obuspa/patches/0001-validate-mtp-topic.patch
Normal file
@@ -0,0 +1,140 @@
|
||||
diff --git a/src/core/device.h b/src/core/device.h
|
||||
index adf8fa6..072f953 100644
|
||||
--- a/src/core/device.h
|
||||
+++ b/src/core/device.h
|
||||
@@ -111,6 +111,7 @@ typedef struct
|
||||
// Following member variables only set if USP message was received over MQTT
|
||||
int mqtt_instance;
|
||||
char *mqtt_topic; // only set if reply_to was specified in the received MQTT packet
|
||||
+ char *mqtt_topic_recv;
|
||||
|
||||
|
||||
// Following member variables only set if USP message was received over CoAP
|
||||
@@ -252,7 +253,7 @@ void DEVICE_MTP_NotifyMqttConnDeleted(int mqtt_instance);
|
||||
int DEVICE_MTP_ValidateMqttReference(dm_req_t *req, char *value);
|
||||
void DEVICE_CONTROLLER_SetRolesFromMqtt(int mqtt_instance, ctrust_role_t role);
|
||||
char *DEVICE_CONTROLLER_GetControllerTopic(int mqtt_instance);
|
||||
-
|
||||
+int validate_controller_topic_by_endpointid(char *endpointid, mtp_protocol_t proto, char *recv_topic);
|
||||
//------------------------------------------------------------------------------
|
||||
// Tables used to convert to/from an enumeration to/from a string
|
||||
extern const enum_entry_t mtp_protocols[kMtpProtocol_Max];
|
||||
diff --git a/src/core/device_controller.c b/src/core/device_controller.c
|
||||
index 62c803f..103388d 100755
|
||||
--- a/src/core/device_controller.c
|
||||
+++ b/src/core/device_controller.c
|
||||
@@ -239,6 +239,41 @@ int Async_E2ESessionReset(dm_req_t *req, kv_vector_t *input_args, int request);
|
||||
extern const enum_entry_t e2e_session_modes[kE2EMode_Max];
|
||||
#endif
|
||||
|
||||
+
|
||||
+int validate_controller_topic_by_endpointid(char *endpointid, mtp_protocol_t proto, char *recv_topic)
|
||||
+{
|
||||
+ controller_t *cont = FindEnabledControllerByEndpointId(endpointid);
|
||||
+ if (cont == NULL)
|
||||
+ {
|
||||
+ USP_LOG_Error("not able to find the controller from endpointid [%s]", endpointid);
|
||||
+ return USP_ERR_PERMISSION_DENIED;
|
||||
+ }
|
||||
+#ifdef ENABLE_MQTT
|
||||
+ if (proto == kMtpProtocol_MQTT)
|
||||
+ {
|
||||
+ controller_mtp_t *mtp = FindFirstEnabledMtp(cont, proto);
|
||||
+
|
||||
+ if (mtp == NULL) {
|
||||
+ USP_LOG_Error("Not able to find mtp[%d] for endpointid [%s]", proto, endpointid);
|
||||
+ return USP_ERR_REQUEST_DENIED;
|
||||
+ }
|
||||
+
|
||||
+ if (mtp->protocol != proto) {
|
||||
+ USP_LOG_Error("No matching mtp[%d] for endpointid [%s]", proto, endpointid);
|
||||
+ return USP_ERR_REQUEST_DENIED;
|
||||
+ }
|
||||
+
|
||||
+ char *response_topic = DEVICE_MTP_GetAgentMqttResponseTopic(mtp->mqtt_connection_instance);
|
||||
+ if (response_topic && strcmp(response_topic, recv_topic) != 0 ) {
|
||||
+ USP_LOG_Error("Controller response topic[%s] and recv topic[%s] mismatch, probably a spoof message", response_topic, recv_topic);
|
||||
+ return USP_ERR_PERMISSION_DENIED;
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
+ return USP_ERR_OK;
|
||||
+}
|
||||
+
|
||||
/*********************************************************************//**
|
||||
**
|
||||
** DEVICE_CONTROLLER_Init
|
||||
diff --git a/src/core/dm_exec.c b/src/core/dm_exec.c
|
||||
index c0b95d8..6eb51e2 100755
|
||||
--- a/src/core/dm_exec.c
|
||||
+++ b/src/core/dm_exec.c
|
||||
@@ -624,6 +624,7 @@ void DM_EXEC_PostUspRecord(unsigned char *pbuf, int pbuf_len, ctrust_role_t role
|
||||
pur->mtp_reply_to.coap_encryption = mrt->coap_encryption;
|
||||
pur->mtp_reply_to.coap_reset_session_hint = mrt->coap_reset_session_hint;
|
||||
pur->mtp_reply_to.mqtt_topic = USP_STRDUP(mrt->mqtt_topic);
|
||||
+ pur->mtp_reply_to.mqtt_topic_recv = USP_STRDUP(mrt->mqtt_topic_recv);
|
||||
pur->mtp_reply_to.mqtt_instance = mrt->mqtt_instance;
|
||||
pur->mtp_reply_to.wsclient_cont_instance = mrt->wsclient_cont_instance;
|
||||
pur->mtp_reply_to.wsclient_mtp_instance = mrt->wsclient_mtp_instance;
|
||||
@@ -1144,6 +1145,7 @@ void ProcessMessageQueueSocketActivity(socket_set_t *set)
|
||||
USP_SAFE_FREE(mrt->coap_resource);
|
||||
USP_SAFE_FREE(mrt->mqtt_topic);
|
||||
USP_SAFE_FREE(mrt->cont_endpoint_id);
|
||||
+ USP_SAFE_FREE(mrt->mqtt_topic_recv);
|
||||
break;
|
||||
|
||||
#ifndef DISABLE_STOMP
|
||||
diff --git a/src/core/mqtt.c b/src/core/mqtt.c
|
||||
index 7dba9f4..3ee9c97 100644
|
||||
--- a/src/core/mqtt.c
|
||||
+++ b/src/core/mqtt.c
|
||||
@@ -3141,6 +3141,7 @@ void ReceiveMqttMessage(mqtt_client_t *client, const struct mosquitto_message *m
|
||||
mrt.mqtt_topic = response_topic;
|
||||
}
|
||||
|
||||
+ mrt.mqtt_topic_recv = message->topic;
|
||||
// Message may not be valid USP
|
||||
DM_EXEC_PostUspRecord(message->payload, message->payloadlen, client->role, &mrt);
|
||||
}
|
||||
diff --git a/src/core/msg_handler.c b/src/core/msg_handler.c
|
||||
index ce67626..4af9ade 100644
|
||||
--- a/src/core/msg_handler.c
|
||||
+++ b/src/core/msg_handler.c
|
||||
@@ -118,7 +118,7 @@ static enum_entry_t mtp_content_types[] = {
|
||||
//------------------------------------------------------------------------------
|
||||
// Forward declarations. Note these are not static, because we need them in the symbol table for USP_LOG_Callstack() to show them
|
||||
int HandleUspMessage(Usp__Msg *usp, char *controller_endpoint, mtp_reply_to_t *mrt);
|
||||
-int ValidateUspRecord(UspRecord__Record *rec);
|
||||
+int ValidateUspRecord(UspRecord__Record *rec, mtp_reply_to_t *mrt);
|
||||
char *MtpSendItemToString(mtp_send_item_t *msi);
|
||||
void CacheControllerRoleForCurMsg(char *endpoint_id, ctrust_role_t role, mtp_protocol_t protocol);
|
||||
int QueueUspNoSessionRecord(usp_send_item_t *usi, char *endpoint_id, char *usp_msg_id, mtp_reply_to_t *mrt, time_t expiry_time);
|
||||
@@ -172,7 +172,7 @@ int MSG_HANDLER_HandleBinaryRecord(unsigned char *pbuf, int pbuf_len, ctrust_rol
|
||||
#endif
|
||||
|
||||
// Exit if USP record failed validation
|
||||
- err = ValidateUspRecord(rec);
|
||||
+ err = ValidateUspRecord(rec, mrt);
|
||||
if (err != USP_ERR_OK)
|
||||
{
|
||||
goto exit;
|
||||
@@ -725,7 +725,7 @@ exit:
|
||||
** \return USP_ERR_OK if record is valid
|
||||
**
|
||||
**************************************************************************/
|
||||
-int ValidateUspRecord(UspRecord__Record *rec)
|
||||
+int ValidateUspRecord(UspRecord__Record *rec, mtp_reply_to_t *mrt)
|
||||
{
|
||||
char *endpoint_id;
|
||||
|
||||
@@ -806,6 +806,9 @@ int ValidateUspRecord(UspRecord__Record *rec)
|
||||
return USP_ERR_REQUEST_DENIED;
|
||||
}
|
||||
|
||||
+#if OBUSPA_CONTROLLER_MTP_VERIFY
|
||||
+ return validate_controller_topic_by_endpointid(rec->from_id, mrt->protocol, mrt->mqtt_topic_recv);
|
||||
+#endif
|
||||
// If the code gets here, then the USP record passed validation, and the encapsulated USP message may be processed
|
||||
return USP_ERR_OK;
|
||||
}
|
||||
@@ -39,8 +39,6 @@ ifneq ($(CONFIG_TARGET_brcmbca),)
|
||||
else ifneq ($(CONFIG_TARGET_airoha),)
|
||||
$(CP) ./files/airoha/* $(1)/
|
||||
endif
|
||||
$(INSTALL_DIR) $(1)/etc/bbfdm/json
|
||||
$(CP) ./files/etc/bbfdm/json/* $(1)/etc/bbfdm/json/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ponmngr))
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
<tbody><tr><td colspan="2"><div style="font-weight: bold">xpon</div><table style="width:100%"><tbody><tr><td><div style="font-weight: bold; font-size: 14px">section</div></td><td><div style="font-weight: bold; font-size: 14px">description</div></td><td><div style="font-weight: bold; font-size: 14px">multi</div></td><td><div style="font-weight: bold; font-size: 14px">options</div></td></tr><tr><td class="td_row_even"><div class="td_row_even">ani</div></td><td class="td_row_even"><div class="td_row_even">xpon ani configuration</div></td><td class="td_row_even"><div class="td_row_even">false</div></td><td class="td_row_even"><table style="width:100%"><tbody><tr><td><div style="font-weight: bold; font-size: 14px">name</div></td><td><div style="font-weight: bold; font-size: 14px">type</div></td><td><div style="font-weight: bold; font-size: 14px">required</div></td><td><div style="font-weight: bold; font-size: 14px">default</div></td><td><div style="font-weight: bold; font-size: 14px">description</div></td></tr><tr><td class="td_row_even"><div class="td_row_even">enable</div></td><td class="td_row_even"><div class="td_row_even">boolean</div></td><td class="td_row_even"><div class="td_row_even">yes</div></td><td class="td_row_even"><div class="td_row_even">false</div></td><td class="td_row_even"><div class="td_row_even">ONU is enabled as pon functionality.</div></td></tr><tr><td class="td_row_odd"><div class="td_row_odd">serial_number</div></td><td class="td_row_odd"><div class="td_row_odd">string</div></td><td class="td_row_odd"><div class="td_row_odd">yes</div></td><td class="td_row_odd"><div class="td_row_odd">null</div></td><td class="td_row_odd"><div class="td_row_odd">Serial number of ONU, Unique for each ONU.</div></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody>
|
||||
@@ -1,143 +0,0 @@
|
||||
# Function Specification
|
||||
|
||||
## Introduction
|
||||
|
||||
This will be a short description of how to setup ONU and enable ANI.
|
||||
|
||||
## Overview
|
||||
|
||||
ponmngr UCI Config
|
||||
|
||||
```
|
||||
config ani 'ani'
|
||||
option enable '1'
|
||||
option serial_number 'IOPS18000001'
|
||||
```
|
||||
|
||||
## Notes
|
||||
* `serial_number` is the unique for each ONU, In case `serial_number` has not
|
||||
* been set from production in that case `serial_number` is calculated using
|
||||
* the combination of vendor "IOPS" and last 4 octet of device mac address.
|
||||
* same serial number should avaibale in OLT for the corresponding ONU profile
|
||||
|
||||
After ubus starts the xpon methods can be invoked to get the status
|
||||
|
||||
For all available status the command can be used without parameters, such as
|
||||
|
||||
```
|
||||
root@iopsys:~# ubus call xpon status
|
||||
{
|
||||
"ONU": [
|
||||
{
|
||||
"Enable": true,
|
||||
"Version": "",
|
||||
"EquipmentID": "BVM4K00BRA",
|
||||
"softwareImage": [
|
||||
{
|
||||
"ID": 0,
|
||||
"Version": "7.2.0alpha0-5",
|
||||
"IsValid": true,
|
||||
"IsActive": false,
|
||||
"IsCommitted": false
|
||||
},
|
||||
{
|
||||
"ID": 1,
|
||||
"Version": "7.2.0alpha0-5",
|
||||
"IsValid": true,
|
||||
"IsActive": true,
|
||||
"IsCommitted": true
|
||||
}
|
||||
],
|
||||
"EthernetUNI": [
|
||||
{
|
||||
"Enable": true,
|
||||
"Status": "UP",
|
||||
"ANIs": "gpon0.0",
|
||||
"InterDomainID": "(VEIP,1025)",
|
||||
"InterDomainName": "VEIP",
|
||||
"Stats": {
|
||||
"BytesSent": 39891,
|
||||
"BytesReceived": 50296,
|
||||
"PacketsSent": 314,
|
||||
"PacketsReceived": 384
|
||||
}
|
||||
},
|
||||
{
|
||||
"Enable": true,
|
||||
"Status": "UP",
|
||||
"ANIs": "gpon0.0",
|
||||
"InterDomainID": "(VEIP,1025)",
|
||||
"InterDomainName": "VEIP",
|
||||
"Stats": {
|
||||
"BytesSent": 54499,
|
||||
"BytesReceived": 47908,
|
||||
"PacketsSent": 286,
|
||||
"PacketsReceived": 273
|
||||
}
|
||||
},
|
||||
{
|
||||
"Enable": false,
|
||||
"Status": "DOWN",
|
||||
"ANIs": "gpon0.0",
|
||||
"InterDomainID": "(VEIP,1025)",
|
||||
"InterDomainName": "VEIP",
|
||||
"Stats": {
|
||||
"BytesSent": 0,
|
||||
"BytesReceived": 0,
|
||||
"PacketsSent": 0,
|
||||
"PacketsReceived": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"Enable": false,
|
||||
"Status": "DOWN",
|
||||
"ANIs": "gpon0.0",
|
||||
"InterDomainID": "(VEIP,1025)",
|
||||
"InterDomainName": "VEIP",
|
||||
"Stats": {
|
||||
"BytesSent": 0,
|
||||
"BytesReceived": 0,
|
||||
"PacketsSent": 0,
|
||||
"PacketsReceived": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"ANI": [
|
||||
{
|
||||
"Enable": true,
|
||||
"Status": "Up",
|
||||
"PONMode": "GPON",
|
||||
"Stats": {
|
||||
"BytesSent": 228,
|
||||
"BytesReceived": 408394,
|
||||
"PacketsSent": 2,
|
||||
"PacketsReceived": 2328
|
||||
}
|
||||
}
|
||||
],
|
||||
"Transceiver": [
|
||||
{
|
||||
"ID": 0,
|
||||
"Identifier": 3,
|
||||
"ModuleVendor": "MENTECHOPTO",
|
||||
"ModuleName": "MSOG22-LDCC-ACCO",
|
||||
"ModuleVersion": "MNC221K90309",
|
||||
"ModuleFirmwareVersion": "1.0",
|
||||
"PONMode": "GPON",
|
||||
"TxPower": 16,
|
||||
"RxPower": -240,
|
||||
"Voltage": 3300,
|
||||
"Bias": 15744,
|
||||
"Temperature": 270
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
UCI to invoke pon manager to enable status of ani, such as
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"xpon":
|
||||
[
|
||||
{
|
||||
"section": "ani",
|
||||
"description": "xpon ani configuration",
|
||||
"multi": "false",
|
||||
"options": [
|
||||
{
|
||||
"name": "enable",
|
||||
"type": "boolean",
|
||||
"required": "yes",
|
||||
"default": "false",
|
||||
"description": "ONU is enabled as pon functionality."
|
||||
},{
|
||||
"name": "serial_number",
|
||||
"type": "string",
|
||||
"required": "yes",
|
||||
"default": null,
|
||||
"description": "Serial number of ONU, Unique for each ONU."
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,936 +0,0 @@
|
||||
{
|
||||
"json_plugin_version": 1,
|
||||
"Device.XPON.": {
|
||||
"type": "object",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"access": false,
|
||||
"array": false,
|
||||
"dependency": "file:/etc/config/xpon",
|
||||
"ONUNumberOfEntries": {
|
||||
"type": "unsignedInt",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedInt",
|
||||
"mapping": [
|
||||
{
|
||||
"type": "ubus",
|
||||
"ubus": {
|
||||
"object": "xpon",
|
||||
"method": "status",
|
||||
"args": {},
|
||||
"key": "ONU.@Count"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"Device.XPON.ONU.{i}.": {
|
||||
"type": "object",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"access": false,
|
||||
"array": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "ubus",
|
||||
"ubus": {
|
||||
"object": "xpon",
|
||||
"method": "status",
|
||||
"args": {},
|
||||
"key": "ONU"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enable": {
|
||||
"type": "boolean",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "boolean",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Enable"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Version": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"range": [
|
||||
{
|
||||
"max": 14
|
||||
}
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Version"
|
||||
}
|
||||
]
|
||||
},
|
||||
"EquipmentID": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"range": [
|
||||
{
|
||||
"max": 20
|
||||
}
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "EquipmentID"
|
||||
}
|
||||
]
|
||||
},
|
||||
"SoftwareImageNumberOfEntries": {
|
||||
"type": "unsignedInt",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedInt",
|
||||
"mapping": [
|
||||
{
|
||||
"type": "ubus",
|
||||
"ubus": {
|
||||
"object": "xpon",
|
||||
"method": "status",
|
||||
"args": {},
|
||||
"key": "ONU[@index].softwareImage.@Count"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"EthernetUNINumberOfEntries": {
|
||||
"type": "unsignedInt",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedInt",
|
||||
"mapping": [
|
||||
{
|
||||
"type": "ubus",
|
||||
"ubus": {
|
||||
"object": "xpon",
|
||||
"method": "status",
|
||||
"args": {},
|
||||
"key": "ONU[@index].EthernetUNI.@Count"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"ANINumberOfEntries": {
|
||||
"type": "unsignedInt",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedInt",
|
||||
"mapping": [
|
||||
{
|
||||
"type": "ubus",
|
||||
"ubus": {
|
||||
"object": "xpon",
|
||||
"method": "status",
|
||||
"args": {},
|
||||
"key": "ONU[@index].ANI.@Count"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"TransceiverNumberOfEntries": {
|
||||
"type": "unsignedInt",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedInt",
|
||||
"mapping": [
|
||||
{
|
||||
"type": "ubus",
|
||||
"ubus": {
|
||||
"object": "xpon",
|
||||
"method": "status",
|
||||
"args": {},
|
||||
"key": "ONU[@index].Transceiver.@Count"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"Device.XPON.ONU.{i}.SoftwareImage.{i}.": {
|
||||
"type": "object",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"access": false,
|
||||
"array": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "ubus",
|
||||
"ubus": {
|
||||
"object": "xpon",
|
||||
"method": "status",
|
||||
"args": {},
|
||||
"key": "ONU[@index].softwareImage"
|
||||
}
|
||||
}
|
||||
],
|
||||
"ID": {
|
||||
"type": "unsignedInt",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedInt",
|
||||
"range": [
|
||||
{
|
||||
"min": 0,
|
||||
"max": 1
|
||||
}
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "ID"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Version": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"range": [
|
||||
{
|
||||
"max": 14
|
||||
}
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Version"
|
||||
}
|
||||
]
|
||||
},
|
||||
"IsCommitted": {
|
||||
"type": "boolean",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "boolean",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "IsCommitted"
|
||||
}
|
||||
]
|
||||
},
|
||||
"IsActive": {
|
||||
"type": "boolean",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "boolean",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "IsActive"
|
||||
}
|
||||
]
|
||||
},
|
||||
"IsValid": {
|
||||
"type": "boolean",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "boolean",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "IsValid"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"Device.XPON.ONU.{i}.EthernetUNI.{i}.": {
|
||||
"type": "object",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"access": false,
|
||||
"array": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "ubus",
|
||||
"ubus": {
|
||||
"object": "xpon",
|
||||
"method": "status",
|
||||
"args": {},
|
||||
"key": "ONU[@index].EthernetUNI"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enable": {
|
||||
"type": "boolean",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "boolean",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Enable"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Status": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"enumerations": [
|
||||
"Up",
|
||||
"Down",
|
||||
"unknown",
|
||||
"Dormant",
|
||||
"NotPresent",
|
||||
"LowerLayerDown",
|
||||
"Error"
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Status"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ANIs": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"range": [
|
||||
{
|
||||
"max": 1024
|
||||
}
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "ANIs"
|
||||
}
|
||||
]
|
||||
},
|
||||
"InterdomainID": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"range": [
|
||||
{
|
||||
"max": 256
|
||||
}
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "InterDomainID"
|
||||
}
|
||||
]
|
||||
},
|
||||
"InterdomainName": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"range": [
|
||||
{
|
||||
"max": 25
|
||||
}
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "InterDomainName"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Device.XPON.ONU.{i}.EthernetUNI.{i}.Stats.": {
|
||||
"type": "object",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"access": false,
|
||||
"array": false,
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Stats"
|
||||
}
|
||||
],
|
||||
"BytesSent": {
|
||||
"type": "unsignedLong",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedLong",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Stats.BytesSent"
|
||||
}
|
||||
]
|
||||
},
|
||||
"BytesReceived": {
|
||||
"type": "unsignedLong",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedLong",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Stats.BytesReceived"
|
||||
}
|
||||
]
|
||||
},
|
||||
"PacketsSent": {
|
||||
"type": "unsignedLong",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedLong",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Stats.PacketsSent"
|
||||
}
|
||||
]
|
||||
},
|
||||
"PacketsReceived": {
|
||||
"type": "unsignedLong",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedLong",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Stats.PacketsReceived"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"Device.XPON.ONU.{i}.ANI.{i}.": {
|
||||
"type": "object",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"access": false,
|
||||
"array": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "ubus",
|
||||
"ubus": {
|
||||
"object": "xpon",
|
||||
"method": "status",
|
||||
"args": {},
|
||||
"key": "ONU[@index].ANI"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enable": {
|
||||
"type": "boolean",
|
||||
"read": true,
|
||||
"write": true,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "boolean",
|
||||
"mapping": [
|
||||
{
|
||||
"rpc": "get",
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Enable"
|
||||
},
|
||||
{
|
||||
"rpc": "set",
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "xpon",
|
||||
"section": {
|
||||
"name": "ani"
|
||||
},
|
||||
"option": {
|
||||
"name": "enable"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"Status": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"enumerations": [
|
||||
"Up",
|
||||
"Down",
|
||||
"Dormant",
|
||||
"Unknown",
|
||||
"NotPresent",
|
||||
"Error"
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Status"
|
||||
}
|
||||
]
|
||||
},
|
||||
"PONMode": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"enumerations": [
|
||||
"GPON",
|
||||
"XG-PON",
|
||||
"NG-PON2",
|
||||
"XGS-PON"
|
||||
],
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "PONMode"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Device.XPON.ONU.{i}.ANI.{i}.Stats.": {
|
||||
"type": "object",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"access": false,
|
||||
"array": false,
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Stats"
|
||||
}
|
||||
],
|
||||
"BytesSent": {
|
||||
"type": "unsignedLong",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedLong",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Stats.BytesSent"
|
||||
}
|
||||
]
|
||||
},
|
||||
"BytesReceived": {
|
||||
"type": "unsignedLong",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedLong",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Stats.BytesReceived"
|
||||
}
|
||||
]
|
||||
},
|
||||
"PacketsSent": {
|
||||
"type": "unsignedLong",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedLong",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Stats.PacketsSent"
|
||||
}
|
||||
]
|
||||
},
|
||||
"PacketsReceived": {
|
||||
"type": "unsignedLong",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedLong",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Stats.PacketsReceived"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"Device.XPON.ONU.{i}.Transceiver.{i}.": {
|
||||
"type": "object",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"access": false,
|
||||
"array": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "ubus",
|
||||
"ubus": {
|
||||
"object": "xpon",
|
||||
"method": "status",
|
||||
"args": {},
|
||||
"key": "ONU[@index].Transceiver"
|
||||
}
|
||||
}
|
||||
],
|
||||
"ID": {
|
||||
"type": "unsignedInt",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedInt",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "ID"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Identifier": {
|
||||
"type": "unsignedInt",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedInt",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Identifier"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ModuleVendor": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "ModuleVendor"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ModuleName": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "ModuleName"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ModuleVersion": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "ModuleVersion"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ModuleFirmwareVersion": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "ModuleFirmwareVersion"
|
||||
}
|
||||
]
|
||||
},
|
||||
"PONMode": {
|
||||
"type": "string",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "string",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "PONMode"
|
||||
}
|
||||
]
|
||||
},
|
||||
"RxPower": {
|
||||
"type": "int",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "int",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "RxPower"
|
||||
}
|
||||
]
|
||||
},
|
||||
"TxPower": {
|
||||
"type": "int",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "int",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "TxPower"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Voltage": {
|
||||
"type": "unsignedInt",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedInt",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Voltage"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Bias": {
|
||||
"type": "unsignedInt",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "unsignedInt",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Bias"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Temperature": {
|
||||
"type": "int",
|
||||
"read": true,
|
||||
"write": false,
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"datatype": "int",
|
||||
"mapping": [
|
||||
{
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "Temperature"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,300 +0,0 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "http://example.com/root.json",
|
||||
"type": "object",
|
||||
"title": "xpon",
|
||||
"object": "xpon",
|
||||
"properties": {
|
||||
"status": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"output": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
],
|
||||
"properties": {
|
||||
"ONU": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"Enable",
|
||||
"Version",
|
||||
"EquipmentID",
|
||||
"SoftwareImage",
|
||||
"EthernetUNI",
|
||||
"ANI",
|
||||
"Transceiver"
|
||||
],
|
||||
"properties": {
|
||||
"Enable": {
|
||||
"type": "boolean",
|
||||
"default": "false"
|
||||
},
|
||||
"Version": {
|
||||
"type": "string"
|
||||
},
|
||||
"EquipmentID": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 20
|
||||
},
|
||||
"SoftwareImage": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ID",
|
||||
"Version",
|
||||
"IsCommitted",
|
||||
"IsActive",
|
||||
"IsValid"
|
||||
],
|
||||
"properties": {
|
||||
"ID": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 1
|
||||
},
|
||||
"Version": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 14,
|
||||
"default": "7.2_BETA2"
|
||||
},
|
||||
"IsCommitted": {
|
||||
"type": "boolean",
|
||||
"default": "false"
|
||||
},
|
||||
"IsActive": {
|
||||
"type": "boolean",
|
||||
"default": "false"
|
||||
},
|
||||
"IsValid": {
|
||||
"type": "boolean",
|
||||
"default": "false"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"EthernetUNI": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"Enable",
|
||||
"Status",
|
||||
"ANIs",
|
||||
"InterdomainID",
|
||||
"InterdomainName",
|
||||
"Stats"
|
||||
],
|
||||
"properties": {
|
||||
"Enable": {
|
||||
"type": "boolean",
|
||||
"default": "false"
|
||||
},
|
||||
"Status": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Up",
|
||||
"Down",
|
||||
"unknown",
|
||||
"Dormant",
|
||||
"NotPresent",
|
||||
"LowerLayerDown",
|
||||
"Error"
|
||||
]
|
||||
},
|
||||
"ANIs": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 1024,
|
||||
"pattern": "gpon[0-9]\\.[0-9]"
|
||||
},
|
||||
"InterdomainID": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 256,
|
||||
"pattern": "(VEIP|PPTPEthernetUNI),(1025|257)"
|
||||
},
|
||||
"InterdomainName": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 25,
|
||||
"default": "VEIP"
|
||||
},
|
||||
"Stats": {
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"BytesSent",
|
||||
"BytesReceived",
|
||||
"PacketsSent",
|
||||
"PacketsReceived"
|
||||
],
|
||||
"properties": {
|
||||
"BytesSent": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"BytesReceived": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"PacketsSent": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"PacketsReceived": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ANI": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"Enable",
|
||||
"Status",
|
||||
"PONMode",
|
||||
"Stats"
|
||||
],
|
||||
"properties": {
|
||||
"Enable": {
|
||||
"type": "boolean",
|
||||
"default": "false"
|
||||
},
|
||||
"Status": {
|
||||
"type": "string",
|
||||
"enum":[
|
||||
"Up",
|
||||
"Down",
|
||||
"Dormant",
|
||||
"Unknown",
|
||||
"NotPresent",
|
||||
"Error"
|
||||
]
|
||||
},
|
||||
"PONMode": {
|
||||
"type": "string",
|
||||
"enum":[
|
||||
"GPON",
|
||||
"XG-PON",
|
||||
"NG-PON2",
|
||||
"XGS-PON"
|
||||
]
|
||||
},
|
||||
"Stats": {
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"BytesSent",
|
||||
"BytesReceived",
|
||||
"PacketsSent",
|
||||
"PacketsReceived"
|
||||
],
|
||||
"properties": {
|
||||
"BytesSent": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"BytesReceived": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"PacketsSent": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"PacketsReceived": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Transceiver": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ID",
|
||||
"Identifier",
|
||||
"ModuleVendor",
|
||||
"ModuleName",
|
||||
"ModuleVersion",
|
||||
"ModuleFirmwareVersion",
|
||||
"PONMode",
|
||||
"RxPower",
|
||||
"TxPower",
|
||||
"Voltage",
|
||||
"Bias",
|
||||
"Temperature"
|
||||
],
|
||||
"properties": {
|
||||
"ID": {
|
||||
"type": "integer",
|
||||
"default": 0
|
||||
},
|
||||
"Identier": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"ModuleVendor": {
|
||||
"type": "string"
|
||||
},
|
||||
"ModuleName": {
|
||||
"type": "string"
|
||||
},
|
||||
"ModuleVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"ModuleFirmwareVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"PONMode": {
|
||||
"type": "string",
|
||||
"enum":[
|
||||
"GPON",
|
||||
"XG-PON",
|
||||
"NG-PON2",
|
||||
"XGS-PON"
|
||||
]
|
||||
},
|
||||
"RxPower": {
|
||||
"type": "integer"
|
||||
},
|
||||
"TxPower": {
|
||||
"type": "integer"
|
||||
},
|
||||
"Voltage": {
|
||||
"type": "integer"
|
||||
},
|
||||
"Bias": {
|
||||
"type": "integer"
|
||||
},
|
||||
"Temperature": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
31
port-management/Makefile
Normal file
31
port-management/Makefile
Normal file
@@ -0,0 +1,31 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=port-management
|
||||
PKG_VERSION:=1.1.0
|
||||
PKG_RELEASE:=1
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
PKG_LICENSE:=GPL-2.0-only
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/port-management
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Port management tool
|
||||
endef
|
||||
|
||||
define Package/port-management/description
|
||||
Port configuration utility
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) ./files/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/port-management/install
|
||||
$(CP) ./files/* $(1)/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,port-management))
|
||||
@@ -1,15 +1,12 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=15
|
||||
STOP=90
|
||||
|
||||
USE_PROCD=1
|
||||
PROG=/usr/sbin/ethmngr
|
||||
|
||||
. /lib/functions.sh
|
||||
include /lib/ethernet
|
||||
include /lib/network
|
||||
|
||||
configure_ethernet_port(){
|
||||
configure_ports(){
|
||||
local cfg=$1
|
||||
local ifname enabled speed duplex autoneg eee pause
|
||||
|
||||
@@ -27,22 +24,11 @@ configure_ethernet_port(){
|
||||
}
|
||||
|
||||
start_service() {
|
||||
if [ -s /etc/config/ports ]; then
|
||||
config_load ports
|
||||
config_foreach configure_ethernet_port ethport
|
||||
fi
|
||||
[ -f /lib/network/port.sh ] || return
|
||||
|
||||
if [ -f $PROG ]; then
|
||||
procd_open_instance
|
||||
procd_set_param command ${PROG}
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
fi
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
config_load ports
|
||||
config_foreach configure_ports ethport
|
||||
config_foreach configure_ports sfpport
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
populate_config_from_db() {
|
||||
. /lib/functions.sh
|
||||
. /lib/network/utils.sh
|
||||
include /lib/ethernet
|
||||
include /lib/network
|
||||
|
||||
portorder="$(db -q get hw.board.ethernetPortOrder)"
|
||||
for port in $portorder; do
|
||||
@@ -27,7 +27,7 @@ define Package/qosmngr
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=QoS Manager
|
||||
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libqos +!(TARGET_brcmbca||TARGET_airoha):tc-full
|
||||
DEPENDS:=@(TARGET_brcmbca||TARGET_airoha) +libuci +libubox +libubus +libblobmsg-json +libjson-c +libqos
|
||||
endef
|
||||
|
||||
define Package/qosmngr/description
|
||||
@@ -40,17 +40,24 @@ define Build/Prepare
|
||||
endef
|
||||
endif
|
||||
|
||||
define Package/qosmngr/install
|
||||
define Package/qosmngr/install/common
|
||||
$(CP) ./files/common/* $(1)/
|
||||
ifneq ($(CONFIG_TARGET_brcmbca),)
|
||||
$(CP) ./files/broadcom/* $(1)/
|
||||
else ifneq ($(CONFIG_TARGET_airoha),)
|
||||
$(CP) ./files/airoha/* $(1)/
|
||||
else
|
||||
$(CP) ./files/linux/* $(1)/
|
||||
endif
|
||||
$(INSTALL_DIR) $(1)/usr
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/qosmngr $(1)/usr/sbin
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_TARGET_brcmbca),y)
|
||||
define Package/qosmngr/install
|
||||
$(CP) ./files/broadcom/* $(1)/
|
||||
$(call Package/qosmngr/install/common,$(1))
|
||||
endef
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_TARGET_airoha),y)
|
||||
define Package/qosmngr/install
|
||||
$(CP) ./files/airoha/* $(1)/
|
||||
$(call Package/qosmngr/install/common,$(1))
|
||||
endef
|
||||
endif
|
||||
$(eval $(call BuildPackage,qosmngr))
|
||||
|
||||
@@ -4,18 +4,6 @@
|
||||
|
||||
ethwan="$(db -q get hw.board.ethernetWanPort)"
|
||||
|
||||
populate_no_of_queue(){
|
||||
queue_num=4
|
||||
|
||||
# writing no. of queue per port into file and read on classify generate
|
||||
if [ ! -d "/tmp/qos" ]; then
|
||||
mkdir -p "/tmp/qos"
|
||||
fi
|
||||
no_queue_file="/tmp/qos/no_queue_per_port"
|
||||
touch "$no_queue_file"
|
||||
echo $queue_num >"$no_queue_file"
|
||||
}
|
||||
|
||||
generate_queue(){
|
||||
section="$1"
|
||||
|
||||
@@ -46,19 +34,15 @@ generate_queue(){
|
||||
uci commit qos
|
||||
}
|
||||
|
||||
populate_no_of_queue
|
||||
|
||||
if [ -s "/etc/config/qos" ]; then
|
||||
if uci -q get qos.@queue[0] >/dev/null; then
|
||||
# return if there is any valid content
|
||||
exit
|
||||
# return if there is any valid content
|
||||
exit
|
||||
else
|
||||
rm -f /etc/config/qos
|
||||
rm -f /etc/config/qos
|
||||
fi
|
||||
fi
|
||||
touch /etc/config/qos
|
||||
|
||||
# generate qos queue config
|
||||
config_load ports
|
||||
config_foreach generate_queue ethport
|
||||
|
||||
@@ -182,9 +182,9 @@ hw_commit_all() {
|
||||
|
||||
if [ "${glob_alg}" != "" ] ; then
|
||||
/userfs/bin/qosrule discpline $(hw_sc_alg2str ${glob_alg}) ${weight_list} \
|
||||
uplink-bandwidth ${shape_rate:-0} \
|
||||
${shape_rate:+uplink-bandwidth} $shape_rate \
|
||||
queuemask $queue_mask
|
||||
else
|
||||
/userfs/bin/qosrule discpline Enable 0
|
||||
/userfs/bin/qosrule discpline off
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
handle_classify() {
|
||||
cid="$1" #classify section ID
|
||||
|
||||
config_get is_enable "$cid" "enable" 1
|
||||
config_get is_enable "$cid" "enable"
|
||||
# no need to configure disabled classify rules
|
||||
if [ "$is_enable" == "0" ]; then
|
||||
if [ -z "$is_enable" ] || [ "$is_enable" == "0" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
@@ -80,10 +80,10 @@ handle_policer() {
|
||||
local p_sec="$1" # policer section ID
|
||||
local dir=1 # default direction, upstream
|
||||
|
||||
config_get is_enable "$p_sec" "enable" 1
|
||||
config_get is_enable "$p_sec" "enable"
|
||||
|
||||
# No need to configure disabled policer
|
||||
if [ "$is_enable" == "0" ] ; then
|
||||
if [ -z "$is_enable" ] || [ "$is_enable" == "0" ] ; then
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ handle_queue() {
|
||||
local qid="$1" #queue section ID
|
||||
local intf_name="$2"
|
||||
|
||||
config_get is_enable "$qid" "enable" 1
|
||||
config_get is_enable "$qid" "enable"
|
||||
|
||||
# no need to configure disabled queues
|
||||
if [ "${is_enable}" == "0" ]; then
|
||||
if [ -z "${is_enable}" ] || [ "${is_enable}" == "0" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
handle_shaper() {
|
||||
sid="$1" #queue section ID
|
||||
|
||||
config_get is_enable "$sid" "enable" 1
|
||||
config_get is_enable "$sid" "enable"
|
||||
# no need to configure disabled queues
|
||||
if [ "${is_enable}" == "0" ] ; then
|
||||
if [ -z "${is_enable}" ] || [ "${is_enable}" == "0" ] ; then
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# The entrypoint for the QoS setup library
|
||||
|
||||
. /lib/functions.sh
|
||||
include /lib/ethernet
|
||||
. /lib/network/port.sh
|
||||
|
||||
. /lib/qos/common/chains.sh
|
||||
. /lib/qos/common/chains.ebtables.sh
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
ethwan="$(db -q get hw.board.ethernetWanPort)"
|
||||
cpu_model="$(cat /proc/socinfo | grep 'SoC Name' | cut -d':' -f2)"
|
||||
|
||||
queue_num=8
|
||||
|
||||
populate_no_of_queue(){
|
||||
case $cpu_model in
|
||||
BCM68*) queue_num=4;;
|
||||
esac
|
||||
if grep -qE '[0-9]+ archer$' /proc/devices; then
|
||||
queue_num=4
|
||||
fi
|
||||
|
||||
# writing no. of queue per port into file and read on classify generate
|
||||
if [ ! -d "/tmp/qos" ]; then
|
||||
mkdir -p "/tmp/qos"
|
||||
fi
|
||||
no_queue_file="/tmp/qos/no_queue_per_port"
|
||||
touch "$no_queue_file"
|
||||
echo $queue_num >"$no_queue_file"
|
||||
}
|
||||
|
||||
generate_queue(){
|
||||
section="$1"
|
||||
|
||||
config_get ifname "$section" "ifname"
|
||||
|
||||
local is_lan=0
|
||||
if [ "$ifname" != "$ethwan" ]; then
|
||||
is_lan=1
|
||||
fi
|
||||
|
||||
local no_of_q="0 1 2 3 4 5 6 7"
|
||||
|
||||
if [ $is_lan -eq 1 ] -a [ $queue_num -eq 4 ]; then
|
||||
no_of_q="0 1 2 3"
|
||||
fi
|
||||
|
||||
i=0
|
||||
local total_q=$((${no_of_q##* } + 1))
|
||||
for i in $no_of_q; do
|
||||
order=$((total_q - i))
|
||||
uci add qos queue
|
||||
uci rename qos.@queue[-1]="q_${i}_${ifname}"
|
||||
uci set qos.@queue[-1].enable="1"
|
||||
uci set qos.@queue[-1].ifname="$ifname"
|
||||
uci set qos.@queue[-1].precedence="$order"
|
||||
uci set qos.@queue[-1].scheduling="SP"
|
||||
uci set qos.@queue[-1].rate="0"
|
||||
uci set qos.@queue[-1].burst_size="0"
|
||||
uci set qos.@queue[-1].weight="1"
|
||||
done
|
||||
|
||||
uci commit qos
|
||||
}
|
||||
|
||||
populate_no_of_queue
|
||||
|
||||
if [ -s "/etc/config/qos" ]; then
|
||||
if uci -q get qos.@queue[0] >/dev/null; then
|
||||
exit
|
||||
else
|
||||
rm -f /etc/config/qos
|
||||
fi
|
||||
fi
|
||||
touch /etc/config/qos
|
||||
|
||||
# generate qos queue config
|
||||
config_load ports
|
||||
config_foreach generate_queue ethport
|
||||
|
||||
@@ -3,26 +3,30 @@
|
||||
. /lib/functions.sh
|
||||
|
||||
ethwan="$(db -q get hw.board.ethernetWanPort)"
|
||||
|
||||
populate_no_of_queue(){
|
||||
queue_num=8
|
||||
|
||||
# writing no. of queue per port into file and read on classify generate
|
||||
if [ ! -d "/tmp/qos" ]; then
|
||||
mkdir -p "/tmp/qos"
|
||||
fi
|
||||
no_queue_file="/tmp/qos/no_queue_per_port"
|
||||
touch "$no_queue_file"
|
||||
echo $queue_num >"$no_queue_file"
|
||||
}
|
||||
cpu_model="$(cat /proc/socinfo | grep 'SoC Name' | cut -d':' -f2)"
|
||||
|
||||
generate_queue(){
|
||||
section="$1"
|
||||
|
||||
config_get ifname "$section" "ifname"
|
||||
|
||||
local is_lan=0
|
||||
if [ "$ifname" != "$ethwan" ]; then
|
||||
is_lan=1
|
||||
fi
|
||||
|
||||
local no_of_q="0 1 2 3 4 5 6 7"
|
||||
|
||||
if [ $is_lan -eq 1 ]; then
|
||||
case $cpu_model in
|
||||
BCM68*) no_of_q="0 1 2 3" ;;
|
||||
esac
|
||||
|
||||
if grep -qE '[0-9]+ archer$' /proc/devices; then
|
||||
no_of_q="0 1 2 3"
|
||||
fi
|
||||
fi
|
||||
|
||||
i=0
|
||||
local total_q=$((${no_of_q##* } + 1))
|
||||
for i in $no_of_q; do
|
||||
@@ -33,16 +37,14 @@ generate_queue(){
|
||||
uci set qos.@queue[-1].ifname="$ifname"
|
||||
uci set qos.@queue[-1].precedence="$order"
|
||||
uci set qos.@queue[-1].scheduling="SP"
|
||||
uci set qos.@queue[-1].rate="1000000"
|
||||
uci set qos.@queue[-1].burst_size="1500"
|
||||
uci set qos.@queue[-1].rate="0"
|
||||
uci set qos.@queue[-1].burst_size="0"
|
||||
uci set qos.@queue[-1].weight="1"
|
||||
done
|
||||
|
||||
uci commit qos
|
||||
}
|
||||
|
||||
populate_no_of_queue
|
||||
|
||||
if [ -s "/etc/config/qos" ]; then
|
||||
if uci -q get qos.@queue[0] >/dev/null; then
|
||||
# return if there is any valid content
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
. /lib/functions.sh
|
||||
include /lib/ethernet
|
||||
. /lib/network/port.sh
|
||||
|
||||
IP_RULE=""
|
||||
BR_RULE=""
|
||||
@@ -1070,7 +1070,7 @@ handle_classify() {
|
||||
local corder_file="/tmp/qos/classify.order"
|
||||
|
||||
while read -r line; do
|
||||
line_cid=$(echo $line | cut -d '_' -f 2)
|
||||
line_cid=${line: 2}
|
||||
|
||||
handle_ebtables_rules $line_cid
|
||||
handle_iptables_rules $line_cid
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
classify_no=0
|
||||
generate_dns_rule(){
|
||||
classify_no=$((classify_no + 1))
|
||||
uci add qos classify
|
||||
uci rename qos.@classify[-1]="c${classify_no}"
|
||||
uci set qos.@classify[-1].ifname="lo"
|
||||
uci set qos.@classify[-1].proto="udp"
|
||||
uci set qos.@classify[-1].ethertype="IPv4"
|
||||
uci set qos.@classify[-1].dest_port="53"
|
||||
uci set qos.@classify[-1].traffic_class="$1"
|
||||
}
|
||||
|
||||
generate_dhcp_rule(){
|
||||
classify_no=$((classify_no + 1))
|
||||
uci add qos classify
|
||||
uci rename qos.@classify[-1]="c${classify_no}"
|
||||
uci set qos.@classify[-1].ifname="lo"
|
||||
uci set qos.@classify[-1].proto="udp"
|
||||
uci set qos.@classify[-1].ethertype="IPv4"
|
||||
uci set qos.@classify[-1].dest_port="67"
|
||||
uci set qos.@classify[-1].dest_port_range="68"
|
||||
uci set qos.@classify[-1].traffic_class="$1"
|
||||
}
|
||||
|
||||
generate_igmp_rule(){
|
||||
classify_no=$((classify_no + 1))
|
||||
uci add qos classify
|
||||
uci rename qos.@classify[-1]="c${classify_no}"
|
||||
uci set qos.@classify[-1].ifname="lo"
|
||||
uci set qos.@classify[-1].proto="IGMP"
|
||||
uci set qos.@classify[-1].ethertype="IPv4"
|
||||
uci set qos.@classify[-1].traffic_class="$1"
|
||||
}
|
||||
|
||||
generate_icmp_rule(){
|
||||
classify_no=$((classify_no + 1))
|
||||
uci add qos classify
|
||||
uci rename qos.@classify[-1]="c${classify_no}"
|
||||
uci set qos.@classify[-1].ifname="lo"
|
||||
uci set qos.@classify[-1].proto="icmp"
|
||||
uci set qos.@classify[-1].ethertype="IPv4"
|
||||
uci set qos.@classify[-1].traffic_class="$1"
|
||||
|
||||
classify_no=$((classify_no + 1))
|
||||
uci add qos classify
|
||||
uci rename qos.@classify[-1]="c${classify_no}"
|
||||
uci set qos.@classify[-1].proto="icmp"
|
||||
uci set qos.@classify[-1].ethertype="IPv4"
|
||||
uci set qos.@classify[-1].traffic_class="$2"
|
||||
}
|
||||
|
||||
generate_classify(){
|
||||
|
||||
|
||||
no_queue_file="/tmp/qos/no_queue_per_port"
|
||||
queue_num=$(cat "$no_queue_file")
|
||||
rm -f "$no_queue_file"
|
||||
|
||||
# assign queue type
|
||||
if [ $queue_num -eq 8 ]; then
|
||||
q_def_queue="0"
|
||||
q_low="1"
|
||||
q_besteffort="2"
|
||||
q_normal="3"
|
||||
q_video="4"
|
||||
q_medium="5"
|
||||
q_high="6"
|
||||
q_highest="7"
|
||||
elif [ $queue_num -eq 4 ]; then
|
||||
q_def_queue="0"
|
||||
q_normal="1"
|
||||
q_medium="2"
|
||||
q_highest="3"
|
||||
fi
|
||||
|
||||
# Local generated DNS traffic goes to q_highest
|
||||
generate_dns_rule $q_highest
|
||||
# Local generated IGMP traffic goes to q_highest
|
||||
generate_igmp_rule $q_highest
|
||||
# Local generated DHCP traffic goes to q_highest
|
||||
generate_dhcp_rule $q_highest
|
||||
# Local generated ICMP traffic goes to q_highest rotue as q_normal
|
||||
generate_icmp_rule $q_highest $q_normal
|
||||
|
||||
# VLAN priority tag -> Queue priority
|
||||
for i in `seq 1 7`; do
|
||||
classify_no=$((classify_no + 1))
|
||||
uci add qos classify
|
||||
uci rename qos.@classify[-1]="c${classify_no}"
|
||||
uci set qos.@classify[-1].pcp_check="$i"
|
||||
uci set qos.@classify[-1].traffic_class="$i"
|
||||
done
|
||||
|
||||
uci commit qos
|
||||
}
|
||||
|
||||
if [ -s "/etc/config/qos" ]; then
|
||||
# cleaning up for upgrade same version that contain firewall.qos
|
||||
if [ -s "/etc/firewall.qos" ]; then
|
||||
rm -f "/etc/firewall.qos"
|
||||
if [ -s "/etc/config/firewall" ]; then
|
||||
uci delete firewall.qos
|
||||
fi
|
||||
generate_classify
|
||||
elif uci -q get qos.@classify[0] >/dev/null; then
|
||||
exit
|
||||
else
|
||||
generate_classify
|
||||
fi
|
||||
fi
|
||||
@@ -1,686 +0,0 @@
|
||||
#!/bin/sh
|
||||
. /lib/functions.sh
|
||||
#set -x
|
||||
|
||||
IP_RULE=""
|
||||
MAJOR=""
|
||||
|
||||
POLICER_COUNT=0
|
||||
Q_COUNT=0
|
||||
SP_Q_PRIO=7
|
||||
|
||||
#counter variable to assign classify order value if not added in config
|
||||
temp_order=1
|
||||
|
||||
# Function to handle a queue order and
|
||||
# update total number of queues
|
||||
handle_q_order() {
|
||||
local qid="$1" #queue section ID
|
||||
|
||||
config_get is_enable "$qid" "enable" 1
|
||||
|
||||
# No need to configure disabled queues
|
||||
if [ $is_enable == '0' ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
config_get ifname "$qid" "ifname"
|
||||
# If ifname is empty that is good enough to break
|
||||
if [ -z "$ifname" ];then
|
||||
return
|
||||
fi
|
||||
|
||||
# Create precedence file containing queue order per
|
||||
# interface.
|
||||
local precedence_file="/tmp/qos/$ifname/q_order"
|
||||
local q_no=$(cat /tmp/qos/$ifname/q_idx)
|
||||
|
||||
config_get precedence "$qid" "precedence"
|
||||
value=${precedence}_q${q_no}
|
||||
echo $value >> $precedence_file
|
||||
|
||||
# Update the number of queues per interface.
|
||||
q_no=$((q_no + 1))
|
||||
echo $q_no > /tmp/qos/$ifname/q_idx
|
||||
}
|
||||
|
||||
# Sort queue, lower value in uci means higher precedence, so this
|
||||
# function sorts the precedence in decending order
|
||||
sort_q_by_precedence() {
|
||||
ifname="$1"
|
||||
|
||||
local order_file="/tmp/qos/$ifname/q_order"
|
||||
local tmp_order_file="/tmp/qos/$ifname/q_order.tmp"
|
||||
|
||||
sort -n -k1 $order_file > $tmp_order_file
|
||||
cp $tmp_order_file $order_file
|
||||
rm -f $tmp_order_file
|
||||
}
|
||||
|
||||
sort_by_precedence() {
|
||||
for interf in $(db -q get hw.board.ethernetPortOrder); do
|
||||
sort_q_by_precedence $interf
|
||||
done
|
||||
}
|
||||
|
||||
# function to handle a queue section
|
||||
handle_queue() {
|
||||
local qid="$1" #queue section ID
|
||||
local port="$2"
|
||||
local port_bw="$3"
|
||||
local root="$4"
|
||||
local port_bs="$5"
|
||||
local priority=0
|
||||
config_get is_enable "$qid" "enable"
|
||||
|
||||
# no need to configure disabled queues
|
||||
if [ "$is_enable" == "0" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
config_get ifname "$qid" "ifname"
|
||||
# if ifname is empty that is good enough to break
|
||||
if [ -z "$ifname" ];then
|
||||
return
|
||||
fi
|
||||
|
||||
# This is to get the qid per interface.
|
||||
if [ "$port" != "$ifname" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
local precedence_file="/tmp/qos/$ifname/q_order"
|
||||
|
||||
local temp_order=0
|
||||
while read -r line; do
|
||||
line_qid=${line: -1}
|
||||
if [ "$line_qid" == "$Q_COUNT" ]; then
|
||||
break
|
||||
fi
|
||||
temp_order=$((temp_order + 1))
|
||||
done < "$precedence_file"
|
||||
|
||||
# precedence_file so the order is calculated accordingly.
|
||||
local order=`expr $SP_Q_PRIO - $temp_order`
|
||||
|
||||
config_get sc_alg "$qid" "scheduling"
|
||||
config_get wgt "$qid" "weight" 1
|
||||
config_get rate "$qid" "rate"
|
||||
config_get bs "$qid" "burst_size"
|
||||
config_get qsize "$qid" "queue_size" 1024
|
||||
|
||||
[ "$rate" == "0" ] && rate="$port_bw"
|
||||
[ "$bs" == "0" ] && bs="$port_bs"
|
||||
|
||||
local salg=1
|
||||
|
||||
case "$sc_alg" in
|
||||
"SP") salg=1
|
||||
;;
|
||||
"WRR") salg=2
|
||||
;;
|
||||
"WDRR") salg=3
|
||||
;;
|
||||
"WFQ") salg=4
|
||||
;;
|
||||
esac
|
||||
|
||||
# ignore precedence value in case of WRR, broadcom recommends that WRR queue should
|
||||
# always have precedence value set to 0
|
||||
if [ $salg -ne 2 ]; then
|
||||
priority=$order
|
||||
fi
|
||||
if [ $order -ne 0 ]; then
|
||||
if [ $salg -eq 2 ]; then
|
||||
tc class add dev $port parent ${root}: classid ${root}:$order cbq allot $bs bandwidth ${port_bw}kbit rate ${rate}kbit prio $priority weight $wgt avpkt 1500 bounded isolated
|
||||
else
|
||||
tc class add dev $port parent ${root}: classid ${root}:$order cbq allot $bs bandwidth ${port_bw}kbit rate ${rate}kbit prio $priority avpkt 1500 bounded isolated
|
||||
fi
|
||||
tc filter add dev $port parent ${root}:0 prio $order handle $order fw classid ${root}:$order
|
||||
fi
|
||||
Q_COUNT=$((Q_COUNT + 1))
|
||||
}
|
||||
|
||||
#function to handle a policer section
|
||||
handle_policer() {
|
||||
local p_sec="$1" # policer section ID
|
||||
local dir=1 # default direction, upstream
|
||||
|
||||
config_get is_enable "$p_sec" "enable"
|
||||
|
||||
#no need to configure disabled policer
|
||||
if [ $is_enable == '0' ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
POLICER_COUNT=$((POLICER_COUNT + 1))
|
||||
}
|
||||
|
||||
setup_qos() {
|
||||
if [ ! -d "/tmp/qos" ]; then
|
||||
mkdir -p /tmp/qos
|
||||
fi
|
||||
|
||||
ebtables -t broute -N qos
|
||||
ret=$?
|
||||
if [ $ret -eq 0 ]; then
|
||||
ebtables -t broute -I BROUTING -j qos
|
||||
else
|
||||
ebtables -t broute -D BROUTING -j qos
|
||||
ebtables -t broute -I BROUTING -j qos
|
||||
fi
|
||||
|
||||
iptables -w -t mangle -N qos_prerouting
|
||||
ret=$?
|
||||
[ $ret -eq 0 ] && iptables -w -t mangle -I PREROUTING -j qos_prerouting
|
||||
|
||||
iptables -w -t mangle -N qos_forward
|
||||
ret=$?
|
||||
[ $ret -eq 0 ] && iptables -w -t mangle -I FORWARD -j qos_forward
|
||||
|
||||
iptables -w -t mangle -N qos_output
|
||||
ret=$?
|
||||
[ $ret -eq 0 ] && iptables -w -t mangle -I OUTPUT -j qos_output
|
||||
|
||||
ip6tables -w -t mangle -N qos_prerouting
|
||||
ret=$?
|
||||
[ $ret -eq 0 ] && ip6tables -w -t mangle -I PREROUTING -j qos_prerouting
|
||||
|
||||
ip6tables -t mangle -N qos_forward
|
||||
ret=$?
|
||||
[ $ret -eq 0 ] && ip6tables -t mangle -I FORWARD -j qos_forward
|
||||
|
||||
ip6tables -t mangle -N qos_output
|
||||
ret=$?
|
||||
[ $ret -eq 0 ] && ip6tables -t mangle -I OUTPUT -j qos_output
|
||||
|
||||
}
|
||||
|
||||
flush_chains() {
|
||||
echo "iptables -w -t mangle -F qos_forward" > /tmp/qos/classify.iptables
|
||||
echo "iptables -w -t mangle -F qos_output" >> /tmp/qos/classify.iptables
|
||||
echo "iptables -w -t mangle -F qos_prerouting" >> /tmp/qos/classify.iptables
|
||||
|
||||
echo "ip6tables -w -t mangle -F qos_forward" > /tmp/qos/classify.ip6tables
|
||||
echo "ip6tables -w -t mangle -F qos_output" >> /tmp/qos/classify.ip6tables
|
||||
echo "ip6tables -w -t mangle -F qos_prerouting" >> /tmp/qos/classify.ip6tables
|
||||
}
|
||||
|
||||
init_iptables_rule() {
|
||||
IP_RULE=""
|
||||
}
|
||||
|
||||
iptables_filter_intf() {
|
||||
IP_RULE="$IP_RULE -i $1"
|
||||
}
|
||||
|
||||
iptables_filter_proto() {
|
||||
IP_RULE="$IP_RULE -p $1"
|
||||
}
|
||||
|
||||
iptables_filter_ip_src() {
|
||||
IP_RULE="$IP_RULE -s $1"
|
||||
}
|
||||
|
||||
iptables_filter_ip_dest() {
|
||||
IP_RULE="$IP_RULE -d $1"
|
||||
}
|
||||
|
||||
iptables_filter_port_dest() {
|
||||
IP_RULE="$IP_RULE --dport $1"
|
||||
}
|
||||
|
||||
iptables_filter_port_src() {
|
||||
IP_RULE="$IP_RULE --sport $1"
|
||||
}
|
||||
|
||||
iptables_filter_port_dest_range() {
|
||||
IP_RULE="$IP_RULE --dport $1:$2"
|
||||
}
|
||||
|
||||
iptables_filter_port_src_range() {
|
||||
IP_RULE="$IP_RULE --sport $1:$2"
|
||||
}
|
||||
|
||||
iptables_filter_dscp_filter() {
|
||||
IP_RULE="$IP_RULE -m dscp --dscp $1"
|
||||
}
|
||||
|
||||
iptables_filter_ip_len_min() {
|
||||
IP_RULE="$IP_RULE -m length --length $1"
|
||||
}
|
||||
|
||||
iptables_filter_ip_len_max() {
|
||||
IP_RULE="$IP_RULE:$1"
|
||||
}
|
||||
|
||||
iptables_set_dscp_mark() {
|
||||
IP_RULE="$IP_RULE -j DSCP --set-dscp $1"
|
||||
}
|
||||
|
||||
iptables_set_traffic_class() {
|
||||
IP_RULE="$IP_RULE -j MARK --set-mark $1"
|
||||
}
|
||||
|
||||
append_rule_to_mangle_table() {
|
||||
if [ $2 == 4 ]; then
|
||||
echo "iptables -w -t mangle -A $1 $IP_RULE" >> /tmp/qos/classify.iptables
|
||||
elif [ $2 == 6 ]; then
|
||||
echo "ip6tables -w -t mangle -A $1 $IP_RULE" >> /tmp/qos/classify.ip6tables
|
||||
elif [ $2 == 1 ]; then
|
||||
echo "iptables -w -t mangle -A $1 $IP_RULE" >> /tmp/qos/classify.iptables
|
||||
echo "ip6tables -w -t mangle -A $1 $IP_RULE" >> /tmp/qos/classify.ip6tables
|
||||
fi
|
||||
}
|
||||
|
||||
handle_iptables_rules() {
|
||||
cid=$1
|
||||
local ip_version=0
|
||||
local is_l3_rule=0
|
||||
|
||||
init_iptables_rule
|
||||
config_get proto "$cid" "proto"
|
||||
config_get traffic_class "$cid" "traffic_class"
|
||||
config_get dscp_mark "$cid" "dscp_mark"
|
||||
config_get dscp_filter "$cid" "dscp_filter"
|
||||
config_get dest_port "$cid" "dest_port"
|
||||
config_get dest_port_range "$cid" "dest_port_range"
|
||||
config_get src_port "$cid" "src_port"
|
||||
config_get src_port_range "$cid" "src_port_range"
|
||||
config_get dest_ip "$cid" "dest_ip"
|
||||
config_get src_ip "$cid" "src_ip"
|
||||
config_get ip_len_min "$cid" "ip_len_min"
|
||||
config_get ip_len_max "$cid" "ip_len_max"
|
||||
config_get ifname "$cid" "ifname"
|
||||
|
||||
#check version of ip
|
||||
case $src_ip$dest_ip in
|
||||
*.*)
|
||||
ip_version=4
|
||||
;;
|
||||
*:*)
|
||||
ip_version=6
|
||||
;;
|
||||
*)
|
||||
ip_version=1 #ip address not used
|
||||
esac
|
||||
|
||||
#filter interface
|
||||
if [ -n "$ifname" ]; then
|
||||
if [ "$ifname" != "lo" ]; then
|
||||
iptables_filter_intf $ifname
|
||||
fi
|
||||
fi
|
||||
|
||||
# filter proto
|
||||
if [ -n "$proto" ]; then
|
||||
iptables_filter_proto $proto
|
||||
is_l3_rule=1
|
||||
fi
|
||||
|
||||
#filter src. ip
|
||||
if [ -n "$src_ip" ]; then
|
||||
iptables_filter_ip_src $src_ip
|
||||
is_l3_rule=1
|
||||
fi
|
||||
|
||||
#filter dest. ip
|
||||
if [ -n "$dest_ip" ]; then
|
||||
iptables_filter_ip_dest $dest_ip
|
||||
is_l3_rule=1
|
||||
fi
|
||||
|
||||
#filter dest. port
|
||||
if [ -n "$dest_port" -a -z "$dest_port_range" ]; then
|
||||
iptables_filter_port_dest $dest_port
|
||||
is_l3_rule=1
|
||||
fi
|
||||
#filter src. port
|
||||
if [ -n "$src_port" -a -z "$src_port_range" ]; then
|
||||
iptables_filter_port_src $src_port
|
||||
is_l3_rule=1
|
||||
fi
|
||||
|
||||
#filter dest. port range
|
||||
if [ -n "$dest_port" -a -n "$dest_port_range" ]; then
|
||||
iptables_filter_port_dest_range $dest_port $dest_port_range
|
||||
is_l3_rule=1
|
||||
fi
|
||||
|
||||
#filter src. port range
|
||||
if [ -n "$src_port" -a -n "$src_port_range" ]; then
|
||||
iptables_filter_port_src_range $src_port $src_port_range
|
||||
is_l3_rule=1
|
||||
fi
|
||||
|
||||
#filter dscp
|
||||
if [ -n "$dscp_filter" ]; then
|
||||
iptables_filter_dscp_filter $dscp_filter
|
||||
is_l3_rule=1
|
||||
fi
|
||||
|
||||
#filter min. IP packet len.
|
||||
if [ -n "$ip_len_min" ]; then
|
||||
iptables_filter_ip_len_min $ip_len_min
|
||||
is_l3_rule=1
|
||||
fi
|
||||
#filter max. IP packet len.
|
||||
if [ -n "$ip_len_max" ]; then
|
||||
iptables_filter_ip_len_max $ip_len_max
|
||||
is_l3_rule=1
|
||||
fi
|
||||
|
||||
if [ $is_l3_rule -eq 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
#set dscp mark
|
||||
[ -n "$dscp_mark" ] && iptables_set_dscp_mark $dscp_mark
|
||||
|
||||
#set packet queue mark
|
||||
[ -n "$traffic_class" ] && iptables_set_traffic_class $traffic_class
|
||||
|
||||
#write iptables rule for dscp marking
|
||||
[ -n "$IP_RULE" -a -n "$dscp_mark" ] && append_rule_to_mangle_table "qos_forward" $ip_version
|
||||
if [ -n "$IP_RULE" -a -n "$traffic_class" ]; then
|
||||
if [ "$ifname" == "lo" ]; then
|
||||
#write iptables rule for putting WAN directed internal packets in different queue
|
||||
append_rule_to_mangle_table "qos_output" $ip_version
|
||||
else
|
||||
#write iptables rule for putting WAN directed LAN packets in different queue
|
||||
append_rule_to_mangle_table "qos_prerouting" $ip_version
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
handle_policer_rules() {
|
||||
local c_sec=$1
|
||||
local policer_name
|
||||
local ifname
|
||||
local pname
|
||||
local pindex=-1
|
||||
local ingress_rate=0
|
||||
local in_burst_size=0
|
||||
|
||||
config_get policer_name "$c_sec" "policer"
|
||||
if [ -z "$policer_name" ];then
|
||||
# no need to apply policer if policer not present in this
|
||||
# classification rule
|
||||
return
|
||||
fi
|
||||
|
||||
config_get ifname "$c_sec" "ifname"
|
||||
if [ -z "$ifname" ]; then
|
||||
# cannot associate policer as interface is not mentioned
|
||||
return
|
||||
fi
|
||||
|
||||
local i=0
|
||||
local max_policer_inst=$(cat /tmp/qos/max_policer_inst)
|
||||
while :
|
||||
do
|
||||
if [ $i -eq $max_policer_inst ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
pname="$(uci -q get qos.@policer[$i].name)"
|
||||
if [ "$policer_name" == "$pname" ]; then
|
||||
pindex=$i
|
||||
ingress_rate=$(uci -q get qos.@policer[$i].committed_rate)
|
||||
in_burst_rate=$(uci -q get qos.@policer[$i].committed_burst_size)
|
||||
break
|
||||
fi
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
if [ $pindex -lt 0 ]; then
|
||||
# policer not found, no need to proceed further
|
||||
return
|
||||
fi
|
||||
|
||||
config_ingress_rate_limit $ifname $ingress_rate $in_burst_size $pindex
|
||||
|
||||
}
|
||||
|
||||
config_ingress_rate_limit() {
|
||||
local ifname="$1"
|
||||
local ingress_rate=$2
|
||||
local in_burst_size=$3
|
||||
local pindex="$4"
|
||||
local wanport="$(db -q get hw.board.ethernetWanPort)"
|
||||
|
||||
# Unit in uci file is in bps while that accepted by ethswctl is kbits
|
||||
if [ $ingress_rate -lt 1000 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
ingress_rate=$((ingress_rate / 1000))
|
||||
|
||||
if [ $in_burst_size -eq 0 ]; then
|
||||
in_burst_size=$ingress_rate
|
||||
else
|
||||
in_burst_size=$((in_burst_size / 1000))
|
||||
fi
|
||||
|
||||
tc qdisc add dev $ifname ingress
|
||||
|
||||
tc filter add dev $ifname parent ffff: protocol ip prio $pindex u32 match ip src 0.0.0.0/0 police rate ${ingress_rate}kbit burst $in_burst_size drop flowid :$pindex
|
||||
|
||||
}
|
||||
|
||||
# Function to handle a classify order
|
||||
handle_classify_order() {
|
||||
local cid="$1" #classify section ID
|
||||
|
||||
config_get is_enable "$cid" "enable" 1
|
||||
|
||||
# No need to configure disabled classify
|
||||
if [ $is_enable == '0' ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# Create classify file containing classify order
|
||||
local corder_file="/tmp/qos/classify.order"
|
||||
|
||||
config_get c_order "$cid" "order"
|
||||
|
||||
if [ -z "$c_order" ]; then
|
||||
c_order=$temp_order;
|
||||
temp_order=$((temp_order + 1))
|
||||
fi
|
||||
|
||||
value=${c_order}_${cid}
|
||||
echo $value >> $corder_file
|
||||
|
||||
}
|
||||
|
||||
# Sort classify, lower value in uci means higher precedence, so this
|
||||
# function sorts the classify order in assending order
|
||||
sort_classify_by_order() {
|
||||
local corder_file="/tmp/qos/classify.order"
|
||||
local tmp_corder_file="/tmp/qos/tmp_classify.order"
|
||||
|
||||
sort -n -k1 $corder_file > $tmp_corder_file
|
||||
cp $tmp_corder_file $corder_file
|
||||
rm -f $tmp_corder_file
|
||||
}
|
||||
|
||||
#function to handle a classify section
|
||||
handle_classify() {
|
||||
local corder_file="/tmp/qos/classify.order"
|
||||
while read -r line; do
|
||||
line_cid=$(echo $line | cut -d '_' -f 2)
|
||||
handle_iptables_rules $line_cid
|
||||
handle_policer_rules $line_cid
|
||||
done < "$corder_file"
|
||||
}
|
||||
|
||||
configure_classify() {
|
||||
#processing classify section
|
||||
rm -f /tmp/qos/classify.iptables
|
||||
rm -f /tmp/qos/classify.ip6tables
|
||||
rm -f /tmp/qos/classify.order
|
||||
|
||||
# create files that will contain the rules if not present already
|
||||
mkdir -p /tmp/qos/
|
||||
touch /tmp/qos/classify.iptables
|
||||
touch /tmp/qos/classify.ip6tables
|
||||
touch /tmp/qos/classify.order
|
||||
|
||||
flush_chains
|
||||
|
||||
# Load UCI file
|
||||
config_load qos
|
||||
config_foreach handle_classify_order classify
|
||||
sort_classify_by_order
|
||||
handle_classify
|
||||
|
||||
sh /tmp/qos/classify.iptables
|
||||
sh /tmp/qos/classify.ip6tables
|
||||
|
||||
}
|
||||
|
||||
pre_configure_queue() {
|
||||
# Delete queues
|
||||
for intf in $(db get hw.board.ethernetPortOrder); do
|
||||
rm -rf /tmp/qos/$intf
|
||||
|
||||
mkdir -p /tmp/qos/$intf
|
||||
touch /tmp/qos/$intf/q_order
|
||||
touch /tmp/qos/$intf/q_idx
|
||||
echo 0 > /tmp/qos/$intf/q_idx
|
||||
|
||||
tc qdisc del dev $intf root
|
||||
tc qdisc del dev $intf ingress
|
||||
done
|
||||
}
|
||||
|
||||
get_link_rate() {
|
||||
intf="$1"
|
||||
speed=0
|
||||
config_load ports
|
||||
get_speed() {
|
||||
psid="$1"
|
||||
iname="$2"
|
||||
config_load ports
|
||||
config_get ifname "$psid" "ifname"
|
||||
if [ "$ifname" == "$iname" ]; then
|
||||
config_get speed "$psid" "speed"
|
||||
fi
|
||||
}
|
||||
config_foreach get_speed ethport $intf
|
||||
echo "$speed"
|
||||
}
|
||||
|
||||
configure_queue() {
|
||||
qdisc_idx=0
|
||||
local bs=1500
|
||||
local rate=0
|
||||
# Load UCI file
|
||||
config_load qos
|
||||
config_foreach handle_q_order queue
|
||||
sort_by_precedence
|
||||
|
||||
get_intf_shaper_config() {
|
||||
local b_size
|
||||
sid="$1" #shaper section ID
|
||||
|
||||
config_get is_enable "$sid" "enable"
|
||||
# no need to configure disabled queues
|
||||
if [ "$is_enable" == "0" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
config_get ifname "$sid" "ifname"
|
||||
# if ifname is empty that is good enough to break
|
||||
if [ -z "$ifname" ] || ! [ "$ifname" == "$2" ];then
|
||||
return
|
||||
fi
|
||||
|
||||
config_get rate "$sid" "rate"
|
||||
# Convert the rate from bps to kbps.
|
||||
if [ $rate -lt 1000 ];then
|
||||
return
|
||||
fi
|
||||
|
||||
rate=$(( rate / 1000 ))
|
||||
config_get b_size "$sid" "burst_size"
|
||||
if [ "$b_size" == "0" ]; then
|
||||
bs="$b_size"
|
||||
fi
|
||||
}
|
||||
local wanport="$(db -q get hw.board.ethernetWanPort)"
|
||||
for interf in $(db -q get hw.board.ethernetPortOrder); do
|
||||
Q_COUNT=0
|
||||
rate=0
|
||||
# sp queue have max priority value = no. of queue configured on the port
|
||||
# hence read and update SP_Q_PRIO here
|
||||
local q_no=$(cat /tmp/qos/$interf/q_idx)
|
||||
SP_Q_PRIO=`expr $q_no - 1`
|
||||
qdisc_idx=`expr $qdisc_idx + 1`
|
||||
# link_rate is in mbps and rate is in kbp
|
||||
link_rate=$(get_link_rate "$interf")
|
||||
# Read the shaper configuration for interface
|
||||
config_foreach get_intf_shaper_config shaper $interf
|
||||
if [ "$rate" == "0" ]; then
|
||||
rate=$(( link_rate * 1000 ))
|
||||
fi
|
||||
|
||||
# TODO using 1500 as allot and avpkt, if shaper config exist for interf get burst_size of shaper for actual value
|
||||
tc qdisc add dev $interf root handle ${qdisc_idx}: cbq allot $bs avpkt 1500 bandwidth ${rate}kbit
|
||||
# if qdisc_idx is the index corresponds to WAN port, then
|
||||
# it would be the MAJOR portion of the destination class ID.
|
||||
# under the same qdisc. We are programming for WAN port only.
|
||||
if [ "$interf" == "$wanport" ]; then
|
||||
MAJOR="$qdisc_idx"
|
||||
fi
|
||||
|
||||
config_foreach handle_queue queue $interf $rate $qdisc_idx $bs
|
||||
done
|
||||
}
|
||||
|
||||
configure_policer() {
|
||||
|
||||
# Delete policer
|
||||
local i=0
|
||||
local max_p_inst=0
|
||||
if [ -f "/tmp/qos/max_policer_inst" ]; then
|
||||
max_p_inst=$(cat /tmp/qos/max_policer_inst)
|
||||
fi
|
||||
|
||||
# reset the policer counter
|
||||
echo 0 > /tmp/qos/max_policer_inst
|
||||
# Load UCI file
|
||||
config_load qos
|
||||
config_foreach handle_policer policer
|
||||
echo $POLICER_COUNT > /tmp/qos/max_policer_inst
|
||||
}
|
||||
|
||||
|
||||
configure_qos() {
|
||||
pre_configure_queue
|
||||
configure_queue
|
||||
configure_classify
|
||||
configure_policer
|
||||
}
|
||||
|
||||
reload_qos() {
|
||||
local service_name="$1"
|
||||
|
||||
if [ -z "$service_name" ]; then
|
||||
configure_qos
|
||||
elif [ "$service_name" == "queue" ]; then
|
||||
pre_configure_queue
|
||||
configure_queue
|
||||
elif [ "$service_name" == "classify" ]; then
|
||||
configure_classify
|
||||
elif [ "$service_name" == "policer" ]; then
|
||||
configure_policer
|
||||
fi
|
||||
}
|
||||
|
||||
reload_qos_service() {
|
||||
reload_qos
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2022 OpenWrt.org
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ssdpd
|
||||
PKG_VERSION:=1.0.4
|
||||
|
||||
LOCAL_DEV:=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/miniupnp/miniupnp.git
|
||||
PKG_SOURCE_VERSION:=207cf440a22c075cb55fb067a850be4f9c204e6e
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
endif
|
||||
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ssdpd
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=+libnfnetlink +libpthread +libubox +libubus +libblobmsg-json +libcurl +mxml
|
||||
TITLE:=MiniSSDPd - SSDP daemon
|
||||
URL:=https://miniupnp.tuxfamily.org/minissdpd.html
|
||||
endef
|
||||
|
||||
MAKE_PATH:=minissdpd
|
||||
|
||||
TARGET_CFLAGS += \
|
||||
-D_GNU_SOURCE \
|
||||
-Wall -Wextra -Werror
|
||||
|
||||
TARGET_LDFLAGS += \
|
||||
-lpthread -lubox -lubus -lblobmsg_json -lcurl -lmxml
|
||||
|
||||
ifeq ($(LOCAL_DEV),1)
|
||||
define Build/Prepare
|
||||
$(CP) -rf ~/git/sspd/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
endif
|
||||
|
||||
define Package/ssdpd/install
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_CONF) ./files/etc/config/ssdpd $(1)/etc/config/ssdpd
|
||||
$(INSTALL_BIN) ./files/etc/init.d/ssdpd $(1)/etc/init.d/ssdpd
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/minissdpd/minissdpd $(1)/usr/sbin/ssdpd
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ssdpd))
|
||||
@@ -1,9 +0,0 @@
|
||||
|
||||
config ssdpd 'ssdp'
|
||||
option enabled '1'
|
||||
option ipv6_enabled '0'
|
||||
option socket_path '/var/run/minissdpd.sock'
|
||||
option ttl '2'
|
||||
option interface 'br-lan'
|
||||
option debug '0'
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
STOP=02
|
||||
|
||||
USE_PROCD=1
|
||||
PROG=/usr/sbin/ssdpd
|
||||
|
||||
log() {
|
||||
echo "${@}"|logger -t ssdpd.init -p info
|
||||
}
|
||||
|
||||
validate_ssdpd_ssdp_section()
|
||||
{
|
||||
uci_validate_section ssdpd ssdpd "ssdp" \
|
||||
'enabled:bool:true' \
|
||||
'debug:bool:false' \
|
||||
'ipv6_enabled:bool:false' \
|
||||
'socket_path:string' \
|
||||
'ttl:uinteger' \
|
||||
'interface:string'
|
||||
}
|
||||
|
||||
configure_ssdp()
|
||||
{
|
||||
local enabled ipv6_enabled socket_path ttl interface
|
||||
|
||||
config_load ssdpd
|
||||
|
||||
validate_ssdpd_ssdp_section || {
|
||||
log "Validation of ssdp section failed"
|
||||
return 1;
|
||||
}
|
||||
|
||||
[ ${enabled} -eq 0 ] && return 0
|
||||
|
||||
mkdir -p /tmp/ssdp/description/
|
||||
|
||||
procd_set_param command ${PROG}
|
||||
|
||||
if [ ${ipv6_enabled} -eq 1 ]; then
|
||||
procd_append_param command -6
|
||||
fi
|
||||
|
||||
if [ ${debug} -eq 1 ]; then
|
||||
procd_append_param command -d
|
||||
fi
|
||||
|
||||
if [ -n "${socket_path}" ]; then
|
||||
procd_append_param command -s ${socket_path}
|
||||
fi
|
||||
|
||||
if [ -n "${ttl}" ]; then
|
||||
procd_append_param command -t ${ttl}
|
||||
fi
|
||||
|
||||
# If no interface is given defaults for br-lan
|
||||
procd_append_param command -i ${interface:-br-lan}
|
||||
}
|
||||
|
||||
start_service() {
|
||||
procd_open_instance ssdp
|
||||
configure_ssdp
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers()
|
||||
{
|
||||
procd_add_reload_trigger "ssdpd"
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
--- a/minissdpd/openssdpsocket.c
|
||||
+++ b/minissdpd/openssdpsocket.c
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
+#include <sys/time.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <net/if.h>
|
||||
--- a/minissdpd/ifacewatch.c
|
||||
+++ b/minissdpd/ifacewatch.c
|
||||
@@ -130,6 +130,7 @@ ProcessInterfaceWatch(int s, int s_ssdp,
|
||||
/* case RTM_DELLINK: */
|
||||
case RTM_DELADDR:
|
||||
is_del = 1;
|
||||
+ // fall through
|
||||
case RTM_NEWADDR:
|
||||
/* http://linux-hacks.blogspot.fr/2009/01/sample-code-to-learn-netlink.html */
|
||||
ifa = (struct ifaddrmsg *)NLMSG_DATA(nlhdr);
|
||||
@@ -1,11 +0,0 @@
|
||||
--- a/minissdpd/Makefile
|
||||
+++ b/minissdpd/Makefile
|
||||
@@ -41,7 +41,7 @@ endif
|
||||
EXECUTABLES = minissdpd testminissdpd testcodelength \
|
||||
showminissdpdnotif
|
||||
MINISSDPDOBJS = minissdpd.o openssdpsocket.o daemonize.o upnputils.o \
|
||||
- ifacewatch.o getroute.o getifaddr.o asyncsendto.o
|
||||
+ ifacewatch.o getroute.o getifaddr.o asyncsendto.o ssdpd.o
|
||||
TESTMINISSDPDOBJS = testminissdpd.o printresponse.o
|
||||
SHOWMINISSDPDNOTIFOBJS = showminissdpdnotif.o printresponse.o
|
||||
|
||||
@@ -1,629 +0,0 @@
|
||||
--- /dev/null
|
||||
+++ b/minissdpd/ssdpd.c
|
||||
@@ -0,0 +1,626 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2022 iopsys Software Solutions AB
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU Lesser General Public License version 2.1
|
||||
+ * as published by the Free Software Foundation
|
||||
+ *
|
||||
+ * Author: Amin Ben Romdhane <amin.benromdhane@iopsys.eu>
|
||||
+ */
|
||||
+
|
||||
+#include <unistd.h>
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <stdbool.h>
|
||||
+#include <string.h>
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/socket.h>
|
||||
+#include <sys/un.h>
|
||||
+#include <net/if.h>
|
||||
+#include <syslog.h>
|
||||
+
|
||||
+#include <curl/curl.h>
|
||||
+#include <libubox/uloop.h>
|
||||
+#include <libubox/blobmsg_json.h>
|
||||
+#include <libubox/list.h>
|
||||
+#include <libubus.h>
|
||||
+#include <mxml.h>
|
||||
+
|
||||
+#include "codelength.h"
|
||||
+
|
||||
+struct UPNPDev {
|
||||
+ struct list_head list;
|
||||
+ char *descURL;
|
||||
+ char *st;
|
||||
+ char *usn;
|
||||
+};
|
||||
+
|
||||
+struct desc_list_elt {
|
||||
+ struct list_head list;
|
||||
+ char *url;
|
||||
+ char *desc_path;
|
||||
+ bool is_device_desc;
|
||||
+};
|
||||
+
|
||||
+#define UPNP_DESC_PATH "/etc/upnp/description"
|
||||
+#define UPNP_DISCOVER_TIMEOUT (30 * 1000)
|
||||
+
|
||||
+#ifndef MIN
|
||||
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
+#endif /* MIN */
|
||||
+
|
||||
+/* macros used to read from unix socket */
|
||||
+#define READ_BYTE_BUFFER(c) \
|
||||
+ if ((int)bufferindex >= n) { \
|
||||
+ n = read(s, buffer, sizeof(buffer)); \
|
||||
+ if (n <= 0) break; \
|
||||
+ bufferindex = 0; \
|
||||
+ } \
|
||||
+ c = buffer[bufferindex++];
|
||||
+
|
||||
+#define READ_COPY_BUFFER(dst, len) \
|
||||
+ for (l = len, p = (unsigned char *)dst; l > 0; ) { \
|
||||
+ unsigned int lcopy; \
|
||||
+ if ((int)bufferindex >= n) { \
|
||||
+ n = read(s, buffer, sizeof(buffer)); \
|
||||
+ if ( n<= 0) break; \
|
||||
+ bufferindex = 0; \
|
||||
+ } \
|
||||
+ lcopy = MIN(l, (n - bufferindex)); \
|
||||
+ memcpy(p, buffer + bufferindex, lcopy); \
|
||||
+ l -= lcopy; \
|
||||
+ p += lcopy; \
|
||||
+ bufferindex += lcopy; \
|
||||
+ }
|
||||
+
|
||||
+LIST_HEAD(dev_list);
|
||||
+LIST_HEAD(desc_list);
|
||||
+
|
||||
+char *ssdp_sockpath = NULL;
|
||||
+
|
||||
+static void upnp_discover_devices(struct uloop_timeout *timeout);
|
||||
+static struct uloop_timeout upnpdiscover_timer = { .cb = upnp_discover_devices };
|
||||
+
|
||||
+static void add_dev_to_dev_list(char *descURL, char *st, char *usn)
|
||||
+{
|
||||
+ struct UPNPDev *dev = NULL;
|
||||
+
|
||||
+ dev = calloc(1, sizeof(struct UPNPDev));
|
||||
+ list_add_tail(&dev->list, &dev_list);
|
||||
+
|
||||
+ dev->descURL = descURL;
|
||||
+ dev->st = st;
|
||||
+ dev->usn = usn;
|
||||
+}
|
||||
+
|
||||
+void free_all_dev_list(void)
|
||||
+{
|
||||
+ struct UPNPDev *dev = NULL;
|
||||
+
|
||||
+ while (dev_list.next != &dev_list) {
|
||||
+ dev = list_entry(dev_list.next, struct UPNPDev, list);
|
||||
+ free(dev->descURL);
|
||||
+ free(dev->st);
|
||||
+ free(dev->usn);
|
||||
+ free(dev);
|
||||
+ list_del(&dev->list);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int connectToMiniSSDPD(void)
|
||||
+{
|
||||
+ int s = 0;
|
||||
+ struct sockaddr_un addr;
|
||||
+
|
||||
+ s = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
+ if(s < 0)
|
||||
+ return -1;
|
||||
+
|
||||
+ char *ssdp_s = ssdp_sockpath ? ssdp_sockpath : "/var/run/minissdpd.sock";
|
||||
+
|
||||
+ memset(&addr, 0, sizeof(addr));
|
||||
+ addr.sun_family = AF_UNIX;
|
||||
+
|
||||
+ strncpy(addr.sun_path, ssdp_s, sizeof(addr.sun_path));
|
||||
+
|
||||
+ if(connect(s, (struct sockaddr *)&addr, sizeof(struct sockaddr_un)) < 0) {
|
||||
+ close(s);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ return s;
|
||||
+}
|
||||
+
|
||||
+static int disconnectFromMiniSSDPD(int s)
|
||||
+{
|
||||
+ if (close(s) < 0)
|
||||
+ return -1;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int requestDevicesFromMiniSSDPD(int s)
|
||||
+{
|
||||
+ unsigned char buffer[256];
|
||||
+ unsigned char *p = NULL;
|
||||
+ unsigned int stsize = 0, l = 0;
|
||||
+ char *devtype = "ssdp:all";
|
||||
+
|
||||
+ buffer[0] = 3; /* request type 3 : everything */
|
||||
+ stsize = strlen(devtype);
|
||||
+
|
||||
+ p = buffer + 1;
|
||||
+ l = stsize; CODELENGTH(l, p);
|
||||
+ if (p + stsize > buffer + sizeof(buffer))
|
||||
+ return -1;
|
||||
+
|
||||
+ memcpy(p, devtype, stsize);
|
||||
+ p += stsize;
|
||||
+ if (write(s, buffer, p - buffer) < 0)
|
||||
+ return -1;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int receiveDevicesFromMiniSSDPD(int s)
|
||||
+{
|
||||
+ unsigned char buffer[256];
|
||||
+ ssize_t n;
|
||||
+ unsigned char *p;
|
||||
+ unsigned int bufferindex;
|
||||
+ unsigned int i, ndev;
|
||||
+ unsigned int urlsize, stsize, usnsize, l;
|
||||
+ char *url, *st, *usn;
|
||||
+
|
||||
+ n = read(s, buffer, sizeof(buffer));
|
||||
+ if (n <= 0)
|
||||
+ return -1;
|
||||
+
|
||||
+ ndev = buffer[0];
|
||||
+ bufferindex = 1;
|
||||
+ for (i = 0; i < ndev; i++) {
|
||||
+ DECODELENGTH_READ(urlsize, READ_BYTE_BUFFER);
|
||||
+ if (n <= 0)
|
||||
+ return -1;
|
||||
+
|
||||
+ url = (char *)malloc(urlsize);
|
||||
+ if (url == NULL)
|
||||
+ return -1;
|
||||
+
|
||||
+ READ_COPY_BUFFER(url, urlsize);
|
||||
+ if (n <= 0)
|
||||
+ return -1;
|
||||
+
|
||||
+ DECODELENGTH_READ(stsize, READ_BYTE_BUFFER);
|
||||
+ if (n <= 0)
|
||||
+ goto free_url_and_return;
|
||||
+
|
||||
+ st = (char *)malloc(stsize);
|
||||
+ if (st == NULL)
|
||||
+ goto free_url_and_return;
|
||||
+
|
||||
+ READ_COPY_BUFFER(st, stsize);
|
||||
+ if (n <= 0)
|
||||
+ goto free_url_and_st_and_return;
|
||||
+
|
||||
+ DECODELENGTH_READ(usnsize, READ_BYTE_BUFFER);
|
||||
+ if (n <= 0)
|
||||
+ goto free_url_and_st_and_return;
|
||||
+
|
||||
+ usn = (char *)malloc(usnsize);
|
||||
+ if (usn == NULL)
|
||||
+ goto free_url_and_st_and_return;
|
||||
+
|
||||
+ READ_COPY_BUFFER(usn, usnsize);
|
||||
+ if (n <= 0)
|
||||
+ goto free_url_and_st_and_usn_and_return;
|
||||
+
|
||||
+ add_dev_to_dev_list(url, st, usn);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+free_url_and_st_and_usn_and_return:
|
||||
+ free(usn);
|
||||
+free_url_and_st_and_return:
|
||||
+ free(st);
|
||||
+free_url_and_return:
|
||||
+ free(url);
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+static int getDevicesFromMiniSSDPD(void)
|
||||
+{
|
||||
+ int s = 0;
|
||||
+ int res = 0;
|
||||
+
|
||||
+ s = connectToMiniSSDPD();
|
||||
+ if (s < 0)
|
||||
+ return -1;
|
||||
+
|
||||
+ res = requestDevicesFromMiniSSDPD(s);
|
||||
+ if (res < 0)
|
||||
+ goto close_socket_and_return;
|
||||
+
|
||||
+ res = receiveDevicesFromMiniSSDPD(s);
|
||||
+
|
||||
+close_socket_and_return:
|
||||
+ disconnectFromMiniSSDPD(s);
|
||||
+
|
||||
+ return res;
|
||||
+}
|
||||
+
|
||||
+static void download_file(char *file_path, const char *url)
|
||||
+{
|
||||
+ CURL *curl = curl_easy_init();
|
||||
+ if (curl) {
|
||||
+ curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, 500);
|
||||
+
|
||||
+ FILE *fp = fopen(file_path, "wb");
|
||||
+ if (fp) {
|
||||
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
|
||||
+ curl_easy_perform(curl);
|
||||
+ fclose(fp);
|
||||
+ }
|
||||
+
|
||||
+ curl_easy_cleanup(curl);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static bool is_desc_exist(const char *desc_url)
|
||||
+{
|
||||
+ struct desc_list_elt *desc_elt = NULL;
|
||||
+
|
||||
+ if (!desc_url)
|
||||
+ return false;
|
||||
+
|
||||
+ list_for_each_entry(desc_elt, &desc_list, list) {
|
||||
+ if (strcmp(desc_elt->url, desc_url) == 0)
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+static void get_desc_name(const char *desc_url, char *str, size_t len)
|
||||
+{
|
||||
+ if (!desc_url || !str || len == 0)
|
||||
+ return;
|
||||
+
|
||||
+ char *p = strstr(desc_url, "://");
|
||||
+
|
||||
+ snprintf(str, len, "%s", p ? p + 3 : desc_url);
|
||||
+
|
||||
+ for (int i = 0; str[i]; i++) {
|
||||
+ if (str[i] == '/')
|
||||
+ str[i] = '_';
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void add_desc_to_desc_list(const char *desc_path, const char *url, int is_device_desc)
|
||||
+{
|
||||
+ struct desc_list_elt *desc_elt;
|
||||
+
|
||||
+ desc_elt = calloc(1, sizeof(struct desc_list_elt));
|
||||
+ list_add_tail(&desc_elt->list, &desc_list);
|
||||
+
|
||||
+ desc_elt->desc_path = strdup(desc_path);
|
||||
+ desc_elt->url = strdup(url);
|
||||
+ desc_elt->is_device_desc = is_device_desc;
|
||||
+}
|
||||
+
|
||||
+static void free_all_desc_list(void)
|
||||
+{
|
||||
+ struct desc_list_elt *desc_elt = NULL;
|
||||
+
|
||||
+ while (desc_list.next != &desc_list) {
|
||||
+ desc_elt = list_entry(desc_list.next, struct desc_list_elt, list);
|
||||
+ free(desc_elt->desc_path);
|
||||
+ free(desc_elt->url);
|
||||
+ free(desc_elt);
|
||||
+ list_del(&desc_elt->list);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void __upnp_discover_devices(void)
|
||||
+{
|
||||
+ struct UPNPDev *dev = NULL;
|
||||
+ char desc_name[128] = {0};
|
||||
+ char file_path[256] = {0};
|
||||
+ int res = 0, is_device_desc = 0;
|
||||
+
|
||||
+ /*
|
||||
+ * Discover devices
|
||||
+ */
|
||||
+ if (!list_empty(&dev_list))
|
||||
+ free_all_dev_list();
|
||||
+
|
||||
+ res = getDevicesFromMiniSSDPD();
|
||||
+ if (res)
|
||||
+ goto end;
|
||||
+
|
||||
+ /*
|
||||
+ * Download description files
|
||||
+ */
|
||||
+ list_for_each_entry_reverse(dev, &dev_list, list) {
|
||||
+
|
||||
+ if (is_desc_exist(dev->descURL))
|
||||
+ continue;
|
||||
+
|
||||
+ get_desc_name(dev->descURL, desc_name, sizeof(desc_name));
|
||||
+ snprintf(file_path, sizeof(file_path), "%s/%s", UPNP_DESC_PATH, desc_name);
|
||||
+ is_device_desc = (dev->usn && strstr(dev->usn, ":service:")) ? 0 : 1;
|
||||
+
|
||||
+ // Download Description
|
||||
+ download_file(file_path, dev->descURL);
|
||||
+
|
||||
+ // Add description to descriptions list
|
||||
+ add_desc_to_desc_list(file_path, dev->descURL, is_device_desc);
|
||||
+ }
|
||||
+
|
||||
+end:
|
||||
+ uloop_timeout_set(&upnpdiscover_timer, UPNP_DISCOVER_TIMEOUT);
|
||||
+}
|
||||
+
|
||||
+static int upnp_discovery_res(struct ubus_context *ctx, struct ubus_object *obj __attribute__((unused)),
|
||||
+ struct ubus_request_data *req, const char *method __attribute__((unused)), struct blob_attr *msg __attribute__((unused)))
|
||||
+{
|
||||
+ struct blob_buf bb = {0};
|
||||
+ struct UPNPDev *dev = NULL;
|
||||
+
|
||||
+ memset(&bb,0,sizeof(struct blob_buf));
|
||||
+ blob_buf_init(&bb, 0);
|
||||
+
|
||||
+ void *devices_array = blobmsg_open_array(&bb, "devices");
|
||||
+ list_for_each_entry_reverse(dev, &dev_list, list) {
|
||||
+ // Parse Root device and devices
|
||||
+ if ((dev->st && strstr(dev->st, ":rootdevice") != NULL) || (dev->usn && strstr(dev->usn, ":device:") != NULL)) {
|
||||
+ void *device_obj = blobmsg_open_table(&bb, NULL);
|
||||
+ blobmsg_add_string(&bb, "descurl", dev->descURL);
|
||||
+ blobmsg_add_string(&bb, "st", dev->st);
|
||||
+ blobmsg_add_string(&bb, "usn", dev->usn);
|
||||
+ blobmsg_add_string(&bb, "is_root_device", dev->st && strstr(dev->st, ":rootdevice") ? "1" : "0");
|
||||
+ blobmsg_close_table(&bb, device_obj);
|
||||
+ }
|
||||
+ }
|
||||
+ blobmsg_close_array(&bb, devices_array);
|
||||
+
|
||||
+ void *services_array = blobmsg_open_array(&bb, "services");
|
||||
+ list_for_each_entry_reverse(dev, &dev_list, list) {
|
||||
+ // Parse Services
|
||||
+ if (dev->usn && strstr(dev->usn, ":service:") != NULL) {
|
||||
+ void *service_obj = blobmsg_open_table(&bb, NULL);
|
||||
+ blobmsg_add_string(&bb, "descurl", dev->descURL);
|
||||
+ blobmsg_add_string(&bb, "st", dev->st);
|
||||
+ blobmsg_add_string(&bb, "usn", dev->usn);
|
||||
+ blobmsg_close_table(&bb, service_obj);
|
||||
+ }
|
||||
+ }
|
||||
+ blobmsg_close_array(&bb, services_array);
|
||||
+
|
||||
+ ubus_send_reply(ctx, req, bb.head);
|
||||
+ blob_buf_free(&bb);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void fill_device_instances(struct blob_buf *bb, mxml_node_t *device)
|
||||
+{
|
||||
+ void *device_obj = NULL;
|
||||
+ mxml_node_t *b = device;
|
||||
+ char buf[64] = {0};
|
||||
+ bool new_device_discovery = false;
|
||||
+
|
||||
+ while (b) {
|
||||
+
|
||||
+ if (mxmlGetType(b) != MXML_ELEMENT) {
|
||||
+ b = mxmlWalkNext(b, device, MXML_DESCEND);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ const char *elm_name = mxmlGetElement(b);
|
||||
+ const char *elm_val = mxmlGetOpaque(b);
|
||||
+
|
||||
+ if (elm_name && strcmp(elm_name, "device") == 0) {
|
||||
+
|
||||
+ if (new_device_discovery && device_obj)
|
||||
+ blobmsg_close_table(bb, device_obj);
|
||||
+
|
||||
+ device_obj = blobmsg_open_table(bb, NULL);
|
||||
+ blobmsg_add_string(bb, "parent_dev", buf);
|
||||
+ new_device_discovery = true;
|
||||
+ }
|
||||
+
|
||||
+ if (elm_name && strcmp(elm_name, "deviceType") == 0 && new_device_discovery)
|
||||
+ blobmsg_add_string(bb, "deviceType", elm_val ? elm_val : "");
|
||||
+
|
||||
+ if (elm_name && strcmp(elm_name, "friendlyName") == 0 && new_device_discovery)
|
||||
+ blobmsg_add_string(bb, "friendlyName", elm_val ? elm_val : "");
|
||||
+
|
||||
+ if (elm_name && strcmp(elm_name, "manufacturer") == 0 && new_device_discovery)
|
||||
+ blobmsg_add_string(bb, "manufacturer", elm_val ? elm_val : "");
|
||||
+
|
||||
+ if (elm_name && strcmp(elm_name, "manufacturerURL") == 0 && new_device_discovery)
|
||||
+ blobmsg_add_string(bb, "manufacturerURL", elm_val ? elm_val : "");
|
||||
+
|
||||
+ if (elm_name && strcmp(elm_name, "modelDescription") == 0 && new_device_discovery)
|
||||
+ blobmsg_add_string(bb, "modelDescription", elm_val ? elm_val : "");
|
||||
+
|
||||
+ if (elm_name && strcmp(elm_name, "modelName") == 0 && new_device_discovery)
|
||||
+ blobmsg_add_string(bb, "modelName", elm_val ? elm_val : "");
|
||||
+
|
||||
+ if (elm_name && strcmp(elm_name, "modelNumber") == 0 && new_device_discovery)
|
||||
+ blobmsg_add_string(bb, "modelNumber", elm_val ? elm_val : "");
|
||||
+
|
||||
+ if (elm_name && strcmp(elm_name, "modelURL") == 0 && new_device_discovery)
|
||||
+ blobmsg_add_string(bb, "modelURL", elm_val ? elm_val : "");
|
||||
+
|
||||
+ if (elm_name && strcmp(elm_name, "serialNumber") == 0 && new_device_discovery)
|
||||
+ blobmsg_add_string(bb, "serialNumber", elm_val ? elm_val : "");
|
||||
+
|
||||
+ if (elm_name && strcmp(elm_name, "UDN") == 0 && new_device_discovery) {
|
||||
+ snprintf(buf, sizeof(buf), "%s", elm_val ? elm_val : "");
|
||||
+ blobmsg_add_string(bb, "UDN", buf);
|
||||
+ }
|
||||
+
|
||||
+ if (elm_name && strcmp(elm_name, "UPC") == 0 && new_device_discovery)
|
||||
+ blobmsg_add_string(bb, "UPC", elm_val ? elm_val : "");
|
||||
+
|
||||
+ b = mxmlWalkNext(b, device, MXML_DESCEND);
|
||||
+ }
|
||||
+
|
||||
+ if (new_device_discovery && device_obj)
|
||||
+ blobmsg_close_table(bb, device_obj);
|
||||
+}
|
||||
+
|
||||
+static void fill_service_element(struct blob_buf *bb, mxml_node_t *service)
|
||||
+{
|
||||
+ mxml_node_t *b = service;
|
||||
+ void *service_obj = NULL;
|
||||
+ char buf[64] = {0};
|
||||
+ bool new_srv_discovery = false;
|
||||
+
|
||||
+ while (b) {
|
||||
+
|
||||
+ if (mxmlGetType(b) != MXML_ELEMENT) {
|
||||
+ b = mxmlWalkNext(b, service, MXML_DESCEND);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ const char *elm_name = mxmlGetElement(b);
|
||||
+ const char *elm_val = mxmlGetOpaque(b);
|
||||
+
|
||||
+ if (elm_name && strcmp(elm_name, "UDN") == 0)
|
||||
+ snprintf(buf, sizeof(buf), "%s", elm_val ? elm_val : "");
|
||||
+
|
||||
+
|
||||
+ if (elm_name && strcmp(elm_name, "service") == 0) {
|
||||
+
|
||||
+ if (new_srv_discovery && service_obj)
|
||||
+ blobmsg_close_table(bb, service_obj);
|
||||
+
|
||||
+ service_obj = blobmsg_open_table(bb, NULL);
|
||||
+ blobmsg_add_string(bb, "parent_dev", buf);
|
||||
+ new_srv_discovery = true;
|
||||
+ }
|
||||
+
|
||||
+ if (elm_name && strcmp(elm_name, "serviceType") == 0 && new_srv_discovery)
|
||||
+ blobmsg_add_string(bb, "serviceType", elm_val ? elm_val : "");
|
||||
+
|
||||
+ if (elm_name && strcmp(elm_name, "serviceId") == 0 && new_srv_discovery)
|
||||
+ blobmsg_add_string(bb, "serviceId", elm_val ? elm_val : "");
|
||||
+
|
||||
+ if (elm_name && strcmp(elm_name, "SCPDURL") == 0 && new_srv_discovery)
|
||||
+ blobmsg_add_string(bb, "SCPDURL", elm_val ? elm_val : "");
|
||||
+
|
||||
+ if (elm_name && strcmp(elm_name, "controlURL") == 0 && new_srv_discovery)
|
||||
+ blobmsg_add_string(bb, "controlURL", elm_val ? elm_val : "");
|
||||
+
|
||||
+ if (elm_name && strcmp(elm_name, "eventSubURL") == 0 && new_srv_discovery)
|
||||
+ blobmsg_add_string(bb, "eventSubURL", elm_val ? elm_val : "");
|
||||
+
|
||||
+ b = mxmlWalkNext(b, service, MXML_DESCEND);
|
||||
+ }
|
||||
+
|
||||
+ if (new_srv_discovery && service_obj)
|
||||
+ blobmsg_close_table(bb, service_obj);
|
||||
+}
|
||||
+
|
||||
+static int upnp_description_res(struct ubus_context *ctx, struct ubus_object *obj __attribute__((unused)),
|
||||
+ struct ubus_request_data *req, const char *method __attribute__((unused)), struct blob_attr *msg __attribute__((unused)))
|
||||
+{
|
||||
+ struct desc_list_elt *desc_elt = NULL;
|
||||
+ struct blob_buf bb = {0};
|
||||
+
|
||||
+ memset(&bb,0,sizeof(struct blob_buf));
|
||||
+ blob_buf_init(&bb, 0);
|
||||
+
|
||||
+ void *desc_array = blobmsg_open_array(&bb, "descriptions");
|
||||
+ list_for_each_entry(desc_elt, &desc_list, list) {
|
||||
+ void *device_obj = blobmsg_open_table(&bb, NULL);
|
||||
+ blobmsg_add_string(&bb, "desc_url", desc_elt->url);
|
||||
+ blobmsg_add_u32(&bb, "is_device_desc", desc_elt->is_device_desc);
|
||||
+ blobmsg_close_table(&bb, device_obj);
|
||||
+
|
||||
+ }
|
||||
+ blobmsg_close_array(&bb, desc_array);
|
||||
+
|
||||
+ list_for_each_entry(desc_elt, &desc_list, list) {
|
||||
+
|
||||
+ FILE *fp = fopen(desc_elt->desc_path, "r");
|
||||
+ if (!fp)
|
||||
+ continue;
|
||||
+
|
||||
+ mxml_node_t *tree = mxmlLoadFile(NULL, fp, MXML_OPAQUE_CALLBACK);
|
||||
+ fclose(fp);
|
||||
+
|
||||
+ if (tree) {
|
||||
+ void *devices_array = blobmsg_open_array(&bb, "devices");
|
||||
+ mxml_node_t *device = mxmlFindElement(tree, tree, "device", NULL, NULL, MXML_DESCEND);
|
||||
+ fill_device_instances(&bb, device);
|
||||
+ blobmsg_close_array(&bb, devices_array);
|
||||
+
|
||||
+ void *services_array = blobmsg_open_array(&bb, "services");
|
||||
+ mxml_node_t *service = mxmlFindElement(tree, tree, "device", NULL, NULL, MXML_DESCEND);
|
||||
+ fill_service_element(&bb, service);
|
||||
+ blobmsg_close_array(&bb, services_array);
|
||||
+
|
||||
+ mxmlDelete(tree);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ ubus_send_reply(ctx, req, bb.head);
|
||||
+ blob_buf_free(&bb);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static struct ubus_method upnp_methods[] = {
|
||||
+ UBUS_METHOD_NOARG("discovery", upnp_discovery_res),
|
||||
+ UBUS_METHOD_NOARG("description", upnp_description_res),
|
||||
+};
|
||||
+
|
||||
+static struct ubus_object_type upnp_type = UBUS_OBJECT_TYPE("upnp", upnp_methods);
|
||||
+
|
||||
+static void upnp_discover_devices(struct uloop_timeout *timeout __attribute__((unused)))
|
||||
+{
|
||||
+ __upnp_discover_devices();
|
||||
+}
|
||||
+
|
||||
+static struct ubus_object upnp_object = {
|
||||
+ .name = "upnp",
|
||||
+ .type = &upnp_type,
|
||||
+ .methods = upnp_methods,
|
||||
+ .n_methods = ARRAY_SIZE(upnp_methods),
|
||||
+};
|
||||
+
|
||||
+void upnp_thread_discover_devices(void)
|
||||
+{
|
||||
+ struct ubus_context *ctx = NULL;
|
||||
+ const char *ubus_socket = NULL;
|
||||
+ int ret = 0;
|
||||
+
|
||||
+ uloop_init();
|
||||
+
|
||||
+ ctx = ubus_connect(ubus_socket);
|
||||
+ if (!ctx) {
|
||||
+ syslog(LOG_ERR, "Failed to connect to ubus\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ ubus_add_uloop(ctx);
|
||||
+
|
||||
+ __upnp_discover_devices();
|
||||
+
|
||||
+ ret = ubus_add_object(ctx, &upnp_object);
|
||||
+ if (ret) {
|
||||
+ syslog(LOG_ERR, "Failed to add 'upnp' ubus object: %s\n", ubus_strerror(ret));
|
||||
+ goto end;
|
||||
+ }
|
||||
+
|
||||
+ uloop_run();
|
||||
+
|
||||
+end:
|
||||
+ free_all_desc_list();
|
||||
+ free_all_dev_list();
|
||||
+ uloop_done();
|
||||
+ ubus_free(ctx);
|
||||
+}
|
||||
@@ -1,311 +0,0 @@
|
||||
--- a/minissdpd/minissdpd.c
|
||||
+++ b/minissdpd/minissdpd.c
|
||||
@@ -32,6 +32,8 @@
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#endif
|
||||
+/* for uloop thread */
|
||||
+#include <pthread.h>
|
||||
|
||||
/* LOG_PERROR does not exist on Solaris */
|
||||
#ifndef LOG_PERROR
|
||||
@@ -52,6 +54,10 @@
|
||||
#define MIN(x,y) (((x)<(y))?(x):(y))
|
||||
#endif
|
||||
|
||||
+extern char *ssdp_sockpath;
|
||||
+void upnp_thread_discover_devices(void);
|
||||
+void ssdpd_ubus_stop(void);
|
||||
+
|
||||
/* current request management structure */
|
||||
struct reqelem {
|
||||
int socket;
|
||||
@@ -1220,6 +1226,12 @@ static void ssdpDiscover(int s, int ipv6
|
||||
}
|
||||
}
|
||||
|
||||
+static void *thread_discover_devices(void *args __attribute__((unused)))
|
||||
+{
|
||||
+ upnp_thread_discover_devices();
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
/* main(): program entry point */
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
@@ -1264,6 +1276,7 @@ int main(int argc, char * * argv)
|
||||
unsigned char ttl = 2; /* UDA says it should default to 2 */
|
||||
const char * searched_device = NULL; /* if not NULL, search/filter a specific device type */
|
||||
int opt;
|
||||
+ pthread_t upnp_thread;
|
||||
|
||||
LIST_INIT(&reqlisthead);
|
||||
LIST_INIT(&servicelisthead);
|
||||
@@ -1309,6 +1322,7 @@ int main(int argc, char * * argv)
|
||||
break;
|
||||
case 's':
|
||||
sockpath = optarg;
|
||||
+ ssdp_sockpath = optarg;
|
||||
break;
|
||||
#ifndef NO_BACKGROUND_NO_PIDFILE
|
||||
case 'p':
|
||||
@@ -1496,6 +1510,11 @@ int main(int argc, char * * argv)
|
||||
if(s_ssdp6 >= 0)
|
||||
ssdpDiscover(s_ssdp6, 1, searched_device);
|
||||
|
||||
+ int err = pthread_create(&upnp_thread, NULL, &thread_discover_devices, NULL);
|
||||
+ if (err < 0) {
|
||||
+ syslog(LOG_ERR, "Error when creating upnp thread");
|
||||
+ }
|
||||
+
|
||||
/* Main loop */
|
||||
while(!quitting) {
|
||||
/* fill readfds fd_set */
|
||||
@@ -1704,6 +1723,8 @@ quit:
|
||||
if(unlink(pidfilename) < 0)
|
||||
syslog(LOG_ERR, "unlink(%s): %m", pidfilename);
|
||||
#endif
|
||||
+ ssdpd_ubus_stop();
|
||||
+ pthread_join(upnp_thread, NULL);
|
||||
closelog();
|
||||
return ret;
|
||||
}
|
||||
--- a/minissdpd/ssdpd.c
|
||||
+++ b/minissdpd/ssdpd.c
|
||||
@@ -39,10 +39,9 @@ struct desc_list_elt {
|
||||
struct list_head list;
|
||||
char *url;
|
||||
char *desc_path;
|
||||
- bool is_device_desc;
|
||||
};
|
||||
|
||||
-#define UPNP_DESC_PATH "/etc/upnp/description"
|
||||
+#define UPNP_DESC_PATH "/tmp/ssdp/description"
|
||||
#define UPNP_DISCOVER_TIMEOUT (30 * 1000)
|
||||
|
||||
#ifndef MIN
|
||||
@@ -282,6 +281,21 @@ static bool is_desc_exist(const char *de
|
||||
return false;
|
||||
}
|
||||
|
||||
+static bool is_device_exist(const char *dev_url)
|
||||
+{
|
||||
+ struct UPNPDev *dev = NULL;
|
||||
+
|
||||
+ if (!dev_url)
|
||||
+ return false;
|
||||
+
|
||||
+ list_for_each_entry(dev, &dev_list, list) {
|
||||
+ if (strcmp(dev->descURL, dev_url) == 0)
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
static void get_desc_name(const char *desc_url, char *str, size_t len)
|
||||
{
|
||||
if (!desc_url || !str || len == 0)
|
||||
@@ -297,7 +311,7 @@ static void get_desc_name(const char *de
|
||||
}
|
||||
}
|
||||
|
||||
-static void add_desc_to_desc_list(const char *desc_path, const char *url, int is_device_desc)
|
||||
+static void add_desc_to_desc_list(const char *desc_path, const char *url)
|
||||
{
|
||||
struct desc_list_elt *desc_elt;
|
||||
|
||||
@@ -306,7 +320,6 @@ static void add_desc_to_desc_list(const
|
||||
|
||||
desc_elt->desc_path = strdup(desc_path);
|
||||
desc_elt->url = strdup(url);
|
||||
- desc_elt->is_device_desc = is_device_desc;
|
||||
}
|
||||
|
||||
static void free_all_desc_list(void)
|
||||
@@ -324,10 +337,12 @@ static void free_all_desc_list(void)
|
||||
|
||||
static void __upnp_discover_devices(void)
|
||||
{
|
||||
+ struct desc_list_elt *desc_elt = NULL;
|
||||
+ struct desc_list_elt *desc_elt_tmp = NULL;
|
||||
struct UPNPDev *dev = NULL;
|
||||
char desc_name[128] = {0};
|
||||
char file_path[256] = {0};
|
||||
- int res = 0, is_device_desc = 0;
|
||||
+ int res = 0;
|
||||
|
||||
/*
|
||||
* Discover devices
|
||||
@@ -349,13 +364,26 @@ static void __upnp_discover_devices(void
|
||||
|
||||
get_desc_name(dev->descURL, desc_name, sizeof(desc_name));
|
||||
snprintf(file_path, sizeof(file_path), "%s/%s", UPNP_DESC_PATH, desc_name);
|
||||
- is_device_desc = (dev->usn && strstr(dev->usn, ":service:")) ? 0 : 1;
|
||||
|
||||
// Download Description
|
||||
download_file(file_path, dev->descURL);
|
||||
|
||||
// Add description to descriptions list
|
||||
- add_desc_to_desc_list(file_path, dev->descURL, is_device_desc);
|
||||
+ add_desc_to_desc_list(file_path, dev->descURL);
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * Remove unused descriptions
|
||||
+ */
|
||||
+ list_for_each_entry_safe(desc_elt, desc_elt_tmp, &desc_list, list) {
|
||||
+
|
||||
+ if (is_device_exist(desc_elt->url))
|
||||
+ continue;
|
||||
+
|
||||
+ free(desc_elt->desc_path);
|
||||
+ free(desc_elt->url);
|
||||
+ free(desc_elt);
|
||||
+ list_del(&desc_elt->list);
|
||||
}
|
||||
|
||||
end:
|
||||
@@ -371,15 +399,27 @@ static int upnp_discovery_res(struct ubu
|
||||
memset(&bb,0,sizeof(struct blob_buf));
|
||||
blob_buf_init(&bb, 0);
|
||||
|
||||
+ void *root_devices_array = blobmsg_open_array(&bb, "root_devices");
|
||||
+ list_for_each_entry_reverse(dev, &dev_list, list) {
|
||||
+ // Parse root device
|
||||
+ if (dev->st && strstr(dev->st, ":rootdevice") != NULL) {
|
||||
+ void *device_obj = blobmsg_open_table(&bb, NULL);
|
||||
+ blobmsg_add_string(&bb, "descurl", dev->descURL);
|
||||
+ blobmsg_add_string(&bb, "st", dev->st);
|
||||
+ blobmsg_add_string(&bb, "usn", dev->usn);
|
||||
+ blobmsg_close_table(&bb, device_obj);
|
||||
+ }
|
||||
+ }
|
||||
+ blobmsg_close_array(&bb, root_devices_array);
|
||||
+
|
||||
void *devices_array = blobmsg_open_array(&bb, "devices");
|
||||
list_for_each_entry_reverse(dev, &dev_list, list) {
|
||||
- // Parse Root device and devices
|
||||
- if ((dev->st && strstr(dev->st, ":rootdevice") != NULL) || (dev->usn && strstr(dev->usn, ":device:") != NULL)) {
|
||||
+ // Parse devices
|
||||
+ if (dev->usn && strstr(dev->usn, ":device:") != NULL) {
|
||||
void *device_obj = blobmsg_open_table(&bb, NULL);
|
||||
blobmsg_add_string(&bb, "descurl", dev->descURL);
|
||||
blobmsg_add_string(&bb, "st", dev->st);
|
||||
blobmsg_add_string(&bb, "usn", dev->usn);
|
||||
- blobmsg_add_string(&bb, "is_root_device", dev->st && strstr(dev->st, ":rootdevice") ? "1" : "0");
|
||||
blobmsg_close_table(&bb, device_obj);
|
||||
}
|
||||
}
|
||||
@@ -472,7 +512,7 @@ static void fill_device_instances(struct
|
||||
blobmsg_close_table(bb, device_obj);
|
||||
}
|
||||
|
||||
-static void fill_service_element(struct blob_buf *bb, mxml_node_t *service)
|
||||
+static void fill_service_instances(struct blob_buf *bb, mxml_node_t *service)
|
||||
{
|
||||
mxml_node_t *b = service;
|
||||
void *service_obj = NULL;
|
||||
@@ -525,6 +565,32 @@ static void fill_service_element(struct
|
||||
blobmsg_close_table(bb, service_obj);
|
||||
}
|
||||
|
||||
+static void fill_device_service_instances(struct blob_buf *bb, bool is_device)
|
||||
+{
|
||||
+ struct desc_list_elt *desc_elt = NULL;
|
||||
+
|
||||
+ list_for_each_entry(desc_elt, &desc_list, list) {
|
||||
+
|
||||
+ FILE *fp = fopen(desc_elt->desc_path, "r");
|
||||
+ if (!fp)
|
||||
+ continue;
|
||||
+
|
||||
+ mxml_node_t *tree = mxmlLoadFile(NULL, fp, MXML_OPAQUE_CALLBACK);
|
||||
+ fclose(fp);
|
||||
+
|
||||
+ if (tree) {
|
||||
+ mxml_node_t *node = mxmlFindElement(tree, tree, "device", NULL, NULL, MXML_DESCEND);
|
||||
+
|
||||
+ if (is_device)
|
||||
+ fill_device_instances(bb, node);
|
||||
+ else
|
||||
+ fill_service_instances(bb, node);
|
||||
+
|
||||
+ mxmlDelete(tree);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static int upnp_description_res(struct ubus_context *ctx, struct ubus_object *obj __attribute__((unused)),
|
||||
struct ubus_request_data *req, const char *method __attribute__((unused)), struct blob_attr *msg __attribute__((unused)))
|
||||
{
|
||||
@@ -534,39 +600,25 @@ static int upnp_description_res(struct u
|
||||
memset(&bb,0,sizeof(struct blob_buf));
|
||||
blob_buf_init(&bb, 0);
|
||||
|
||||
+ // Descriptions Array
|
||||
void *desc_array = blobmsg_open_array(&bb, "descriptions");
|
||||
list_for_each_entry(desc_elt, &desc_list, list) {
|
||||
void *device_obj = blobmsg_open_table(&bb, NULL);
|
||||
blobmsg_add_string(&bb, "desc_url", desc_elt->url);
|
||||
- blobmsg_add_u32(&bb, "is_device_desc", desc_elt->is_device_desc);
|
||||
blobmsg_close_table(&bb, device_obj);
|
||||
|
||||
}
|
||||
blobmsg_close_array(&bb, desc_array);
|
||||
|
||||
- list_for_each_entry(desc_elt, &desc_list, list) {
|
||||
-
|
||||
- FILE *fp = fopen(desc_elt->desc_path, "r");
|
||||
- if (!fp)
|
||||
- continue;
|
||||
-
|
||||
- mxml_node_t *tree = mxmlLoadFile(NULL, fp, MXML_OPAQUE_CALLBACK);
|
||||
- fclose(fp);
|
||||
-
|
||||
- if (tree) {
|
||||
- void *devices_array = blobmsg_open_array(&bb, "devices");
|
||||
- mxml_node_t *device = mxmlFindElement(tree, tree, "device", NULL, NULL, MXML_DESCEND);
|
||||
- fill_device_instances(&bb, device);
|
||||
- blobmsg_close_array(&bb, devices_array);
|
||||
-
|
||||
- void *services_array = blobmsg_open_array(&bb, "services");
|
||||
- mxml_node_t *service = mxmlFindElement(tree, tree, "device", NULL, NULL, MXML_DESCEND);
|
||||
- fill_service_element(&bb, service);
|
||||
- blobmsg_close_array(&bb, services_array);
|
||||
+ // Devices Array
|
||||
+ void *devices_array = blobmsg_open_array(&bb, "devices");
|
||||
+ fill_device_service_instances(&bb, true);
|
||||
+ blobmsg_close_array(&bb, devices_array);
|
||||
|
||||
- mxmlDelete(tree);
|
||||
- }
|
||||
- }
|
||||
+ // Services Array
|
||||
+ void *services_array = blobmsg_open_array(&bb, "services");
|
||||
+ fill_device_service_instances(&bb, false);
|
||||
+ blobmsg_close_array(&bb, services_array);
|
||||
|
||||
ubus_send_reply(ctx, req, bb.head);
|
||||
blob_buf_free(&bb);
|
||||
@@ -624,3 +676,8 @@ end:
|
||||
uloop_done();
|
||||
ubus_free(ctx);
|
||||
}
|
||||
+
|
||||
+void ssdpd_ubus_stop(void)
|
||||
+{
|
||||
+ uloop_end();
|
||||
+}
|
||||
+
|
||||
--- a/minissdpd/config.h
|
||||
+++ b/minissdpd/config.h
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
/* When NO_BACKGROUND_NO_PIDFILE is defined, minissdpd does not go to
|
||||
* background and does not create any pidfile */
|
||||
-/*#define NO_BACKGROUND_NO_PIDFILE*/
|
||||
+#define NO_BACKGROUND_NO_PIDFILE
|
||||
|
||||
/* define HAVE_IP_MREQN to use struct ip_mreqn instead of struct ip_mreq
|
||||
* for setsockopt(IP_MULTICAST_IF). Available with Linux 2.4+,
|
||||
@@ -9,13 +9,13 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=stunc
|
||||
PKG_RELEASE:=1
|
||||
PKG_VERSION:=1.1.15
|
||||
PKG_VERSION:=1.1.14
|
||||
|
||||
LOCAL_DEV:=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/stunc.git
|
||||
PKG_SOURCE_VERSION:=09f9868a79e1b5037a99a97fd4dee678869fe98a
|
||||
PKG_SOURCE_VERSION:=06b63878a448b593d907bb3e9c1381dc0e69bca6
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
endif
|
||||
|
||||
@@ -13,7 +13,7 @@ menu "SULU_CORE"
|
||||
|
||||
config SULU_CORE_VERSION
|
||||
string "SULU repo version"
|
||||
default "5380c46eefc7dc2907ca749e9b3aaa6321039ee8"
|
||||
default "c7e62f7f7cda1961012e8149d220ac1eb26d362f"
|
||||
endmenu
|
||||
|
||||
menu "SULU_PLUGIN_LCM"
|
||||
@@ -35,7 +35,7 @@ menu "SULU_PLUGIN_LCM"
|
||||
config SULU_PLUGIN_LCM_VERSION
|
||||
depends on SULU_PLUGIN_LCM_ENABLE
|
||||
string "Version"
|
||||
default "8e954f0adb3388e9ab2171df9c6bf85a1b82b020"
|
||||
default "ccd70b399b31530dc1af6a871eee94fbb179d794"
|
||||
endmenu
|
||||
|
||||
menu "SULU_PLUGIN_MULTIAP"
|
||||
@@ -57,7 +57,7 @@ menu "SULU_PLUGIN_MULTIAP"
|
||||
config SULU_PLUGIN_MULTIAP_VERSION
|
||||
depends on SULU_PLUGIN_MULTIAP_ENABLE
|
||||
string "Version"
|
||||
default "db3828affb373a9ca9bae0b07591ab5c417825a7"
|
||||
default "3c79d57bee453e7b62c7b7626e33bf273212bbc9"
|
||||
endmenu
|
||||
|
||||
menu "SULU_THEME_IOPSYS"
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=sulu-builder
|
||||
PKG_VERSION:=1.3.26
|
||||
PKG_VERSION:=1.3.16
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/websdk/sulu-builder.git
|
||||
PKG_SOURCE_VERSION:=6d6848119bffdbe0ec9b8116caf6375749299dc0
|
||||
PKG_SOURCE_VERSION:=81d4bb268914dc3822293e93519ae6adbd6ddbea
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
|
||||
@@ -40,7 +40,7 @@ define Download/sulu_core
|
||||
FILE:=$(SULU_DL_FILE)
|
||||
URL:=$(CONFIG_SULU_CORE_URL)
|
||||
PROTO:=git
|
||||
SUBDIR:=sulu
|
||||
SUBDIR:=core
|
||||
VERSION:=${CONFIG_SULU_CORE_VERSION}
|
||||
HASH:=skip
|
||||
endef
|
||||
@@ -139,10 +139,6 @@ ifeq ($(CONFIG_SULU_THEME_CUSTOM_ENABLE),y)
|
||||
endif
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
VERSION="v${PKG_VERSION}" $(MAKE) -C $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
define Package/${PKG_NAME}/install
|
||||
$(INSTALL_DIR) $(1)/sulu
|
||||
$(INSTALL_DIR) $(1)/sulu/config
|
||||
@@ -162,16 +158,20 @@ endif
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/etc/init.d/sulu $(1)/etc/init.d/sulu
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/mosquitto/conf.d/
|
||||
$(INSTALL_DATA) ./files/etc/mosquitto/conf.d/obuspa.conf $(1)/etc/mosquitto/conf.d/
|
||||
$(INSTALL_DATA) ./files/etc/mosquitto/conf.d/sulu.conf $(1)/etc/mosquitto/conf.d/
|
||||
$(INSTALL_DATA) ./files/etc/mosquitto/sulu.password $(1)/etc/mosquitto/sulu.password
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/nginx/conf.d
|
||||
$(INSTALL_DATA) ./files/etc/nginx/conf.d/sulu.conf $(1)/etc/nginx/conf.d/
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/sulu
|
||||
$(INSTALL_DATA) ./files/etc/sulu/roles.json $(1)/etc/sulu/
|
||||
$(INSTALL_BIN) ./files/etc/sulu/sulu.sh $(1)/etc/sulu/
|
||||
$(INSTALL_DATA) ./files/etc/sulu/nginx.locations $(1)/etc/sulu/
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/99-fix-sulu-config $(1)/etc/uci-defaults/
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/40-add-sulu-nginx-config $(1)/etc/uci-defaults/
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/01-update-nginx-uci-template $(1)/etc/uci-defaults/
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/10-add-mqtt-config $(1)/etc/uci-defaults/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,${PKG_NAME}))
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
config global 'global'
|
||||
option root '/sulu'
|
||||
option port '8080'
|
||||
option ws_port '9001'
|
||||
option enabled '1'
|
||||
option enable_system_credentials '1'
|
||||
option role_based_access '1'
|
||||
list user 'admin'
|
||||
list user 'user'
|
||||
|
||||
@@ -33,9 +33,9 @@ start_service() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
update_nginx_template
|
||||
configure_sulu "${enable_system_credentials}" "${role_based_access}" 1
|
||||
generate_sulu_conn_config "${role_based_access}"
|
||||
update_nginx_config "${enabled}" 1
|
||||
update_sulu_connection_port
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
@@ -46,5 +46,5 @@ reload_service() {
|
||||
|
||||
service_triggers()
|
||||
{
|
||||
procd_add_reload_trigger "sulu" "nginx"
|
||||
procd_add_reload_trigger "sulu"
|
||||
}
|
||||
|
||||
3
sulu-builder/files/etc/mosquitto/conf.d/obuspa.conf
Normal file
3
sulu-builder/files/etc/mosquitto/conf.d/obuspa.conf
Normal file
@@ -0,0 +1,3 @@
|
||||
listener 1883 127.0.0.1
|
||||
allow_anonymous true
|
||||
|
||||
4
sulu-builder/files/etc/mosquitto/conf.d/sulu.conf
Normal file
4
sulu-builder/files/etc/mosquitto/conf.d/sulu.conf
Normal file
@@ -0,0 +1,4 @@
|
||||
listener 9001
|
||||
protocol websockets
|
||||
require_certificate false
|
||||
allow_anonymous false
|
||||
1
sulu-builder/files/etc/mosquitto/sulu.password
Normal file
1
sulu-builder/files/etc/mosquitto/sulu.password
Normal file
@@ -0,0 +1 @@
|
||||
admin:$6$OmM9kU/lYct3KJ9j$iP0WK4ezEtRm8+EAggNp7WbJFoWO0p7IUdI0v/hr1WcVHyfFAC30Pb8Csn7GqwwqI2dcmnDOAITnimo2VNe6ug==
|
||||
27
sulu-builder/files/etc/nginx/conf.d/sulu.conf
Normal file
27
sulu-builder/files/etc/nginx/conf.d/sulu.conf
Normal file
@@ -0,0 +1,27 @@
|
||||
server {
|
||||
listen 8080;
|
||||
listen [::]:8080;
|
||||
server_name _sulu;
|
||||
root /sulu;
|
||||
location / {
|
||||
autoindex on;
|
||||
expires -1;
|
||||
|
||||
if ($request_method = 'OPTIONS') {
|
||||
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,Content-Type,Range';
|
||||
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
|
||||
add_header 'Content-Type' 'text/plain; charset=utf-8';
|
||||
add_header 'Content-Length' 0;
|
||||
return 204;
|
||||
}
|
||||
if ($request_method = 'GET') {
|
||||
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,Content-Type,Range' always;
|
||||
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
|
||||
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
error_page 497 301 =307 https://$host:$server_port$request_uri;
|
||||
|
||||
location /robots.txt {
|
||||
return 200 "User-agent: *\nDisallow: /\n";
|
||||
}
|
||||
|
||||
location /sitemap.xml {
|
||||
return 200 "User-agent: *\nDisallow: /\n";
|
||||
}
|
||||
|
||||
location /ws {
|
||||
proxy_pass_request_headers on;
|
||||
proxy_cache off;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Server $host;
|
||||
proxy_set_header X-Forwarded-Port $server_port;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,Content-Type,Range' always;
|
||||
proxy_pass http://websocket;
|
||||
}
|
||||
|
||||
location / {
|
||||
autoindex on;
|
||||
expires -1;
|
||||
|
||||
if ($request_method = 'OPTIONS') {
|
||||
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,Content-Type,Range';
|
||||
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
|
||||
add_header 'Content-Type' 'text/plain; charset=utf-8';
|
||||
add_header 'Content-Length' 0;
|
||||
return 204;
|
||||
}
|
||||
if ($request_method = 'GET') {
|
||||
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,Content-Type,Range' always;
|
||||
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
|
||||
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
ACL_FILE="/tmp/sulu/mqtt.acl"
|
||||
_RESTART_SERVICES="0"
|
||||
|
||||
mkdir -p /tmp/sulu/
|
||||
@@ -19,10 +20,9 @@ function _get_agent_id()
|
||||
if [ -z "${endpointid}" ]; then
|
||||
oui="$(db -q get device.deviceinfo.ManufacturerOUI)"
|
||||
serial="$(db -q get device.deviceinfo.SerialNumber)"
|
||||
echo "${oui}-${serial//+/%2B}"
|
||||
echo "${oui}-${serial}"
|
||||
else
|
||||
endpointid="$(echo "${endpointid/::/,}"|cut -d "," -f 2)"
|
||||
endpointid="${endpointid//+/%2B}"
|
||||
echo "$(echo "${endpointid/::/,}"|cut -d "," -f 2)"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ function _get_endpoint_id()
|
||||
if [ -z "${endpointid}" ]; then
|
||||
oui="$(db -q get device.deviceinfo.ManufacturerOUI)"
|
||||
serial="$(db -q get device.deviceinfo.SerialNumber)"
|
||||
echo "os::${oui}-${serial//+/%2B}"
|
||||
echo "os::${oui}-${serial}"
|
||||
else
|
||||
echo "${endpointid//+/%2B}"
|
||||
echo "${endpointid}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -49,47 +49,24 @@ function _get_sulu_root()
|
||||
{
|
||||
local root
|
||||
|
||||
root="$(uci -q get nginx._sulu_s.root)"
|
||||
root="$(uci -q get sulu.global.root)"
|
||||
echo "${root:-/sulu}"
|
||||
}
|
||||
|
||||
function _get_usp_upstream_port()
|
||||
function _get_sulu_port()
|
||||
{
|
||||
local port
|
||||
|
||||
port="$(uci -q get mosquitto.sulu.port)"
|
||||
echo "${port:-9009}"
|
||||
port="$(uci -q get sulu.global.port)"
|
||||
echo "${port:-8080}"
|
||||
}
|
||||
|
||||
function _get_sulu_acl_file()
|
||||
{
|
||||
local file
|
||||
|
||||
file="$(uci -q get mosquitto.sulu.acl_file)"
|
||||
echo "${file}"
|
||||
}
|
||||
|
||||
function _get_sulu_tls_port()
|
||||
{
|
||||
local port listen
|
||||
|
||||
listen="$(uci -q get nginx._sulu_s.listen)"
|
||||
port="$(echo $listen|grep -Eo '[0-9]+'|head -n 1)"
|
||||
|
||||
echo "${port:-8443}"
|
||||
}
|
||||
|
||||
function update_nginx_template()
|
||||
function _get_sulu_ws_port()
|
||||
{
|
||||
local port
|
||||
|
||||
UCI_TEMPLATE="/etc/nginx/uci.conf.template"
|
||||
port="$(_get_usp_upstream_port)"
|
||||
if ! grep -q "upstream websocket { server 127.0.0.1:${port}; }" ${UCI_TEMPLATE}; then
|
||||
sed -i "s/upstream websocket { server 127.0.0.1:[0-9]\+; }/upstream websocket { server 127.0.0.1:${var}; }/" ${UCI_TEMPLATE}
|
||||
log "Restarting nginx"
|
||||
ubus call uci commit '{"config":"nginx"}'
|
||||
fi
|
||||
port="$(uci -q get sulu.global.ws_port)"
|
||||
echo "${port:-9001}"
|
||||
}
|
||||
|
||||
function generate_sulu_conn_config()
|
||||
@@ -109,9 +86,8 @@ function generate_sulu_conn_config()
|
||||
json_add_object 'connections';
|
||||
json_add_object 'rbac';
|
||||
json_add_string 'toId' "$(_get_endpoint_id)";
|
||||
json_add_int 'port' "$(_get_sulu_tls_port)";
|
||||
json_add_string 'path' "/ws";
|
||||
json_add_string 'protocol' 'wss';
|
||||
json_add_int 'port' "$(_get_sulu_ws_port)";
|
||||
json_add_string 'protocol' 'ws';
|
||||
json_add_array 'auth';
|
||||
json_close_array;
|
||||
|
||||
@@ -130,9 +106,8 @@ function generate_sulu_conn_config()
|
||||
json_add_object 'main';
|
||||
json_add_string 'fromId' 'proto::interop-usp-controller';
|
||||
json_add_string 'toId' "$(_get_endpoint_id)";
|
||||
json_add_int 'port' "$(_get_sulu_tls_port)";
|
||||
json_add_string 'path' "/ws";
|
||||
json_add_string 'protocol' 'wss';
|
||||
json_add_int 'port' "$(_get_sulu_ws_port)";
|
||||
json_add_string 'protocol' 'ws';
|
||||
json_add_string 'publishEndpoint' "/usp/endpoint";
|
||||
json_add_string 'subscribeEndpoint' "/usp/controller";
|
||||
json_add_array 'auth';
|
||||
@@ -165,7 +140,7 @@ function update_sulu_connection_port()
|
||||
local port ws_port SCONF
|
||||
|
||||
SCONF="$(_get_sulu_root)/config/connectionConfig.json"
|
||||
ws_port="$(_get_sulu_tls_port)"
|
||||
ws_port="$(_get_sulu_ws_port)"
|
||||
|
||||
port="$(jq '.connections.rbac.port' ${SCONF})"
|
||||
if [ "${port}" -ne "${ws_port}" ]; then
|
||||
@@ -303,40 +278,78 @@ function _remove_obuspa_config_rbac()
|
||||
}
|
||||
|
||||
function _create_acl() {
|
||||
local agentid rbac users restart
|
||||
local ACL_FILE
|
||||
local agentid rbac users
|
||||
|
||||
rbac="${1:-0}"
|
||||
restart="0"
|
||||
|
||||
ACL_FILE="$(_get_sulu_acl_file)"
|
||||
if [ -z "${ACL_FILE}" -o "${rbac}" -eq "0" ]; then
|
||||
return 0
|
||||
[ -f "${ACL_FILE}" ] && rm -f "${ACL_FILE}"
|
||||
|
||||
if [ "${rbac}" -eq "0" ]; then
|
||||
return 0;
|
||||
fi
|
||||
|
||||
if [ -f "${ACL_FILE}" ]; then
|
||||
rm -f "${ACL_FILE}"
|
||||
agentid="$(_get_agent_id)"
|
||||
users="$(_get_sulu_users)"
|
||||
for f in ${users}; do
|
||||
echo "user ${f}" >> ${ACL_FILE}
|
||||
echo "topic read /usp/${agentid}/${f}/controller/reply-to/#" >> ${ACL_FILE}
|
||||
echo "topic write /usp/${agentid}/${f}/endpoint/#" >> ${ACL_FILE}
|
||||
echo "topic read /usp/${agentid}/${f}/controller/#" >> ${ACL_FILE}
|
||||
echo "" >> ${ACL_FILE}
|
||||
done
|
||||
}
|
||||
|
||||
function update_mosquitto_broker_config()
|
||||
{
|
||||
local system_cred rbac restart ws_port
|
||||
|
||||
MB_SULU_CONF="/etc/mosquitto/conf.d/sulu.conf"
|
||||
system_cred="${1}"
|
||||
rbac="${2}"
|
||||
restart=0
|
||||
ws_port="$(_get_sulu_ws_port)"
|
||||
|
||||
if [ "${system_cred}" -eq "1" ]; then
|
||||
if grep -q "password_file " ${MB_SULU_CONF}; then
|
||||
sed -i '/password_file /d' ${MB_SULU_CONF}
|
||||
restart=1
|
||||
fi
|
||||
if ! grep -q "plugin .*mosquitto_auth_shadow.so" ${MB_SULU_CONF}; then
|
||||
echo "plugin /usr/lib/mosquitto_auth_shadow.so" >> ${MB_SULU_CONF}
|
||||
restart=1
|
||||
fi
|
||||
else
|
||||
if grep -q 'plugin .*mosquitto_auth_shadow.so' ${MB_SULU_CONF}; then
|
||||
sed -i '/plugin .*mosquitto_auth_shadow.so/d' ${MB_SULU_CONF}
|
||||
restart=1
|
||||
fi
|
||||
if ! grep -q "password_file /etc/mosquitto/sulu.password" ${MB_SULU_CONF}; then
|
||||
echo "password_file /etc/mosquitto/sulu.password" >> ${MB_SULU_CONF}
|
||||
restart=1
|
||||
fi
|
||||
fi
|
||||
touch "${ACL_FILE}"
|
||||
|
||||
if [ "${rbac}" -eq "1" ]; then
|
||||
users="$(_get_sulu_users)"
|
||||
agentid="$(_get_agent_id)"
|
||||
for f in ${users}; do
|
||||
if ! grep -q "user $f" ${ACL_FILE}; then
|
||||
echo "user ${f}" >> ${ACL_FILE}
|
||||
echo "topic read /usp/${agentid}/${f}/controller/reply-to/#" >> ${ACL_FILE}
|
||||
echo "topic write /usp/${agentid}/${f}/endpoint/#" >> ${ACL_FILE}
|
||||
echo "topic read /usp/${agentid}/${f}/controller/#" >> ${ACL_FILE}
|
||||
echo "" >> ${ACL_FILE}
|
||||
restart="1"
|
||||
fi
|
||||
done
|
||||
_create_acl "${rbac}"
|
||||
if ! grep -q "acl_file ${ACL_FILE}" ${MB_SULU_CONF}; then
|
||||
echo "acl_file ${ACL_FILE}" >> ${MB_SULU_CONF}
|
||||
restart=1
|
||||
fi
|
||||
else
|
||||
if grep -q "acl_file ${ACL_FILE}" ${MB_SULU_CONF}; then
|
||||
sed -i '/acl_file /d' ${MB_SULU_CONF}
|
||||
restart=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${restart}" -gt "0" ]; then
|
||||
slog "Restarting mosquitto..."
|
||||
ubus call uci commit '{"config":"mosquitto"}'
|
||||
if ! grep -q "listener ${ws_port}" ${MB_SULU_CONF}; then
|
||||
sed -i "s/listener [0-9]\+/listener ${ws_port}/" ${MB_SULU_CONF}
|
||||
restart=1
|
||||
fi
|
||||
|
||||
if [ "${_RESTART_SERVICES}" -eq "1" -a "${restart}" -eq "1" ]; then
|
||||
slog "Restarting mqtt broker..."
|
||||
/etc/init.d/mosquitto restart &
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -367,6 +380,44 @@ function update_obuspa_config()
|
||||
fi
|
||||
}
|
||||
|
||||
function update_nginx_config()
|
||||
{
|
||||
local enabled restart port
|
||||
|
||||
NCONF="/etc/nginx/conf.d/sulu.conf"
|
||||
restart=0
|
||||
enabled="${1:-0}"
|
||||
_RESTART_SERVICES="${2:-0}"
|
||||
port="$(_get_sulu_port)"
|
||||
root="$(_get_sulu_root)"
|
||||
|
||||
if [ "${enabled}" -eq "1" ]; then
|
||||
if [ ! -f "${NCONF}" ]; then
|
||||
cp /etc/sulu/nginx.conf ${NCONF}
|
||||
restart=1
|
||||
fi
|
||||
if ! grep -q "listen ${port}" ${NCONF}; then
|
||||
sed -i "s/listen [0-9]\+/listen ${port}/" ${NCONF}
|
||||
sed -i "s/listen \[::\]:[0-9]\+/listen [::]:${port}/" ${NCONF}
|
||||
restart=1
|
||||
fi
|
||||
if ! grep -q "root ${root}" ${NCONF}; then
|
||||
sed -i "s/root .*;/root ${root//\//\\/};/" ${NCONF}
|
||||
restart=1
|
||||
fi
|
||||
else
|
||||
if [ -f "${NCONF}" ]; then
|
||||
rm -f ${NCONF}
|
||||
restart=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${_RESTART_SERVICES}" -eq "1" -a "${restart}" -eq "1" ]; then
|
||||
slog "Restarting nginx..."
|
||||
ubus call uci commit '{"config":"nginx"}'
|
||||
fi
|
||||
}
|
||||
|
||||
function configure_sulu()
|
||||
{
|
||||
local sys_cred rbac restart
|
||||
@@ -382,7 +433,7 @@ function configure_sulu()
|
||||
|
||||
_RESTART_SERVICES="${restart}"
|
||||
|
||||
update_mosquitto_broker_config "${sys_cred}" "${rbac}"
|
||||
set_sulu_connection_mode "${rbac}"
|
||||
update_obuspa_config "${rbac}"
|
||||
_create_acl "${rbac}"
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
UCI_TEMPLATE="/etc/nginx/uci.conf.template"
|
||||
update_nginx_uci_template()
|
||||
{
|
||||
if ! grep -q "upstream websocket" ${UCI_TEMPLATE}; then
|
||||
sed -i '/#UCI_HTTP_CONFIG$/i\ map $http_upgrade $connection_upgrade { default upgrade; "" close; }' ${UCI_TEMPLATE}
|
||||
sed -i '/#UCI_HTTP_CONFIG$/i\ upstream websocket { server 127.0.0.1:9009; }' ${UCI_TEMPLATE}
|
||||
fi
|
||||
}
|
||||
|
||||
update_nginx_uci_template
|
||||
@@ -1,37 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
if [ ! -f "/etc/config/mosquitto" ]; then
|
||||
echo "Local mosquitto broker not available"
|
||||
return 0
|
||||
fi
|
||||
|
||||
add_obuspa_config()
|
||||
{
|
||||
if ! uci_get mosquitto obuspa >/dev/null 2>&1; then
|
||||
uci_add mosquitto listener obuspa
|
||||
uci_set mosquitto obuspa enabled 1
|
||||
uci_set mosquitto obuspa port '1883'
|
||||
uci_set mosquitto obuspa no_remote_access '1'
|
||||
uci_set mosquitto obuspa allow_anonymous '1'
|
||||
fi
|
||||
}
|
||||
|
||||
add_sulu_config()
|
||||
{
|
||||
if ! uci_get mosquitto sulu >/dev/null 2>&1; then
|
||||
uci_add mosquitto listener sulu
|
||||
uci_set mosquitto sulu enabled 1
|
||||
uci_set mosquitto sulu port '9009'
|
||||
uci_set mosquitto sulu no_remote_access '1'
|
||||
uci_set mosquitto sulu protocol 'websockets'
|
||||
uci_set mosquitto sulu require_certificates '0'
|
||||
uci_set mosquitto sulu auth_plugin '/usr/lib/mosquitto_auth_shadow.so'
|
||||
uci_set mosquitto sulu acl_file '/tmp/sulu/mqtt.acl'
|
||||
fi
|
||||
}
|
||||
|
||||
uci_load mosquitto
|
||||
add_obuspa_config
|
||||
add_sulu_config
|
||||
@@ -1,35 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
add_sulu_nginx_uci()
|
||||
{
|
||||
uci_load nginx
|
||||
|
||||
if ! uci_get nginx _sulu_s >/dev/null 2>&1; then
|
||||
uci_add nginx server _sulu_s
|
||||
uci_set nginx _sulu_s root '/sulu'
|
||||
uci_add_list nginx _sulu_s listen "8443 http2 ssl"
|
||||
uci_add_list nginx _sulu_s listen "[::]:8443 http2 ssl"
|
||||
uci_set nginx _sulu_s server_name '_sulu_s'
|
||||
uci_add_list nginx _sulu_s include 'restrict_locally'
|
||||
uci_add_list nginx _sulu_s include '/etc/sulu/nginx.locations'
|
||||
uci_set nginx _sulu_s uci_manage_ssl 'self-signed'
|
||||
uci_set nginx _sulu_s ssl_certificate '/etc/nginx/conf.d/_lan.crt'
|
||||
uci_set nginx _sulu_s ssl_certificate_key '/etc/nginx/conf.d/_lan.key'
|
||||
uci_set nginx _sulu_s ssl_session_cache 'shared:SSL:32k'
|
||||
uci_set nginx _sulu_s ssl_session_timeout '64m'
|
||||
uci_set nginx _sulu_s access_log 'off; # logd openwrt'
|
||||
fi
|
||||
|
||||
if ! uci_get nginx _suluredirect >/dev/null 2>&1; then
|
||||
uci_add nginx server _suluredirect
|
||||
uci_add_list nginx _suluredirect listen "8080"
|
||||
uci_add_list nginx _suluredirect listen "[::]:8080"
|
||||
uci_set nginx _suluredirect server_name '_suluredirect'
|
||||
uci_set nginx _suluredirect return 'https://$host:8443$request_uri'
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
add_sulu_nginx_uci
|
||||
@@ -5,6 +5,7 @@
|
||||
config_load sulu
|
||||
config_get enable_system_credentials global enable_system_credentials 1
|
||||
config_get role_based_access global role_based_access 0
|
||||
config_get enabled global enabled 0
|
||||
|
||||
configure_sulu "${enable_system_credentials}" "${role_based_access}" 0
|
||||
generate_sulu_conn_config "${role_based_access}"
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=sulu
|
||||
PKG_VERSION:=1.3.26
|
||||
PKG_VERSION:=1.3.16
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/websdk/sulu.git
|
||||
PKG_SOURCE_VERSION:=6d6848119bffdbe0ec9b8116caf6375749299dc0
|
||||
PKG_SOURCE_VERSION:=81d4bb268914dc3822293e93519ae6adbd6ddbea
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_SOURCE_VERSION)
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
@@ -49,16 +49,20 @@ endif
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/etc/init.d/sulu $(1)/etc/init.d/sulu
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/mosquitto/conf.d/
|
||||
$(INSTALL_DATA) ./files/etc/mosquitto/conf.d/obuspa.conf $(1)/etc/mosquitto/conf.d/
|
||||
$(INSTALL_DATA) ./files/etc/mosquitto/conf.d/sulu.conf $(1)/etc/mosquitto/conf.d/
|
||||
$(INSTALL_DATA) ./files/etc/mosquitto/sulu.password $(1)/etc/mosquitto/sulu.password
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/nginx/conf.d
|
||||
$(INSTALL_DATA) ./files/etc/nginx/conf.d/sulu.conf $(1)/etc/nginx/conf.d/
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/sulu
|
||||
$(INSTALL_DATA) ./files/etc/sulu/roles.json $(1)/etc/sulu/
|
||||
$(INSTALL_BIN) ./files/etc/sulu/sulu.sh $(1)/etc/sulu/
|
||||
$(INSTALL_DATA) ./files/etc/sulu/nginx.locations $(1)/etc/sulu/
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/99-fix-sulu-config $(1)/etc/uci-defaults/
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/40-add-sulu-nginx-config $(1)/etc/uci-defaults/
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/01-update-nginx-uci-template $(1)/etc/uci-defaults/
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/10-add-mqtt-config $(1)/etc/uci-defaults/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,sulu))
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
config global 'global'
|
||||
option root '/sulu'
|
||||
option port '8080'
|
||||
option ws_port '9001'
|
||||
option enabled '1'
|
||||
option enable_system_credentials '1'
|
||||
option role_based_access '1'
|
||||
list user 'admin'
|
||||
list user 'user'
|
||||
|
||||
@@ -33,9 +33,9 @@ start_service() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
update_nginx_template
|
||||
configure_sulu "${enable_system_credentials}" "${role_based_access}" 1
|
||||
generate_sulu_conn_config "${role_based_access}"
|
||||
update_nginx_config "${enabled}" 1
|
||||
update_sulu_connection_port
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
@@ -46,5 +46,5 @@ reload_service() {
|
||||
|
||||
service_triggers()
|
||||
{
|
||||
procd_add_reload_trigger "sulu" "nginx"
|
||||
procd_add_reload_trigger "sulu"
|
||||
}
|
||||
|
||||
3
sulu/files/etc/mosquitto/conf.d/obuspa.conf
Normal file
3
sulu/files/etc/mosquitto/conf.d/obuspa.conf
Normal file
@@ -0,0 +1,3 @@
|
||||
listener 1883 127.0.0.1
|
||||
allow_anonymous true
|
||||
|
||||
4
sulu/files/etc/mosquitto/conf.d/sulu.conf
Normal file
4
sulu/files/etc/mosquitto/conf.d/sulu.conf
Normal file
@@ -0,0 +1,4 @@
|
||||
listener 9001
|
||||
protocol websockets
|
||||
require_certificate false
|
||||
allow_anonymous false
|
||||
1
sulu/files/etc/mosquitto/sulu.password
Normal file
1
sulu/files/etc/mosquitto/sulu.password
Normal file
@@ -0,0 +1 @@
|
||||
admin:$6$OmM9kU/lYct3KJ9j$iP0WK4ezEtRm8+EAggNp7WbJFoWO0p7IUdI0v/hr1WcVHyfFAC30Pb8Csn7GqwwqI2dcmnDOAITnimo2VNe6ug==
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user