forked from freifunk-franken/firmware
Compare commits
12 Commits
master
...
multi-clie
Author | SHA1 | Date |
---|---|---|
Fabian Bläse | 5107859331 | |
Fabian Bläse | 68f90abe3e | |
Fabian Bläse | 7dfb71fc18 | |
Fabian Bläse | 1fdba9da60 | |
Fabian Bläse | 4f3b35fbf9 | |
Fabian Bläse | 7cdd32f6ca | |
Fabian Bläse | 75abee0ec7 | |
Fabian Bläse | aa15ac7812 | |
Fabian Bläse | f8e3ef38d4 | |
Fabian Bläse | 1b6ec0a6d8 | |
Fabian Bläse | 03e661376f | |
Fabian Bläse | 8ec17a34d7 |
|
@ -2,8 +2,7 @@
|
|||
. /lib/functions/fff/babel
|
||||
|
||||
#load board specific properties
|
||||
BOARD="$(uci get board.model.name)"
|
||||
. /etc/network.$BOARD
|
||||
. /lib/functions/fff/interfaces
|
||||
|
||||
configure() {
|
||||
## babelpeer
|
||||
|
|
|
@ -17,10 +17,6 @@ uci batch >/dev/null <<EOF
|
|||
set dhcp.@dnsmasq[-1].leasefile='/tmp/dhcp.leases'
|
||||
set dhcp.@dnsmasq[-1].noresolv='1'
|
||||
set dhcp.@dnsmasq[-1].localservice='1'
|
||||
|
||||
set dhcp.client=dhcp
|
||||
set dhcp.client.interface='client'
|
||||
set dhcp.client.leasetime='1h'
|
||||
EOF
|
||||
|
||||
uci commit dhcp
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
. /lib/functions.sh
|
||||
|
||||
# load board specific properties
|
||||
BOARD="$(uci get board.model.name)"
|
||||
. /etc/network.$BOARD
|
||||
. /lib/functions/fff/cpuport
|
||||
. /lib/functions/fff/interfaces
|
||||
|
||||
|
||||
configure() {
|
||||
|
|
|
@ -1,63 +1,114 @@
|
|||
# load board specific properties
|
||||
BOARD="$(uci get board.model.name)"
|
||||
. /etc/network.$BOARD
|
||||
|
||||
# load uci functions
|
||||
. /lib/functions.sh
|
||||
|
||||
. /lib/functions/system.sh
|
||||
|
||||
. /lib/functions/fff/interfaces
|
||||
. /lib/functions/fff/routermac
|
||||
|
||||
configure() {
|
||||
# ipaddr
|
||||
#remove old ipaddr
|
||||
uci -q del network.client.ipaddr
|
||||
#set new ipaddr
|
||||
if ipaddr=$(uci -q get gateway.@client[0].ipaddr); then
|
||||
for ip in $ipaddr; do
|
||||
uci add_list network.client.ipaddr=$ip
|
||||
done
|
||||
else
|
||||
echo "WARNING: No client ipaddr set!"
|
||||
fi
|
||||
#put interface routes from set addresses into fff table
|
||||
uci set network.client.ip4table='fff'
|
||||
add_clientif() {
|
||||
local name="$1"
|
||||
|
||||
# ip6addr
|
||||
#remove old ip6addr
|
||||
for ip in $(uci get network.client.ip6addr); do
|
||||
if echo "$ip" | grep -v -e "fdff:" -e "fe80::1/64" > /dev/null; then
|
||||
uci del_list network.client.ip6addr="$ip"
|
||||
uci set network.$name=interface
|
||||
uci set network.$name.fff_clientif="1"
|
||||
|
||||
uci set network.$name.type=bridge
|
||||
uci set network.$name.proto=static
|
||||
uci set network.$name.auto=1
|
||||
|
||||
[ -n "$ROUTERMAC" ] || ROUTERMAC=$(get_mac_label)
|
||||
uci set network.$name.macaddr="$ROUTERMAC"
|
||||
|
||||
# ipaddr
|
||||
#remove old ipaddr
|
||||
uci -q del network.$name.ipaddr
|
||||
#set new ipaddr
|
||||
if ipaddr=$(uci -q get gateway.$name.ipaddr); then
|
||||
for ip in $ipaddr; do
|
||||
uci add_list network.$name.ipaddr=$ip
|
||||
done
|
||||
else
|
||||
echo "WARNING: No ipaddr for client interface \"$name\" set!"
|
||||
fi
|
||||
done
|
||||
#set new ip6addr
|
||||
if ip6addr=$(uci -q get gateway.@client[0].ip6addr); then
|
||||
for ip in $ip6addr; do
|
||||
uci add_list network.client.ip6addr=$ip
|
||||
#put interface routes from set addresses into fff table
|
||||
uci set network.$name.ip4table='fff'
|
||||
|
||||
# ip6addr
|
||||
#remove old ip6addr
|
||||
for ip in $(uci -q get network.$name.ip6addr); do
|
||||
if echo "$ip" | grep -v -e "fdff:" -e "fe80::1/64" > /dev/null; then
|
||||
uci del_list network.$name.ip6addr="$ip"
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "WARNING: No client ip6addr set!"
|
||||
fi
|
||||
#put interface routes from set addresses into fff table
|
||||
uci set network.client.ip6table='fff'
|
||||
#set new ip6addr
|
||||
if ip6addr=$(uci -q get gateway.$name.ip6addr); then
|
||||
for ip in $ip6addr; do
|
||||
uci add_list network.$name.ip6addr=$ip
|
||||
done
|
||||
else
|
||||
echo "WARNING: No ip6addr for client interface \"$name\" set!"
|
||||
fi
|
||||
#put interface routes from set addresses into fff table
|
||||
uci set network.$name.ip6table='fff'
|
||||
|
||||
# dhcp
|
||||
uci -q del dhcp.client.start
|
||||
uci -q del dhcp.client.limit
|
||||
if dhcp_start=$(uci -q get gateway.@client[0].dhcp_start); then
|
||||
uci set dhcp.client=dhcp
|
||||
uci set dhcp.client.interface=client
|
||||
uci set dhcp.client.start=$dhcp_start
|
||||
uci set dhcp.client.limit=$(uci -q get gateway.@client[0].dhcp_limit)
|
||||
else
|
||||
echo "WARNING: No DHCP range start and/or limit set!"
|
||||
# dhcp
|
||||
uci -q set dhcp.$name=dhcp
|
||||
uci -q set dhcp.$name.interface=$name
|
||||
uci -q set dhcp.$name.leasetime='1h'
|
||||
|
||||
uci -q del dhcp.$name.start
|
||||
uci -q del dhcp.$name.limit
|
||||
if dhcp_start=$(uci -q get gateway.$name.dhcp_start); then
|
||||
uci set dhcp.$name=dhcp
|
||||
uci set dhcp.$name.interface=client
|
||||
uci set dhcp.$name.start=$dhcp_start
|
||||
uci set dhcp.$name.limit=$(uci -q get gateway.$name.dhcp_limit)
|
||||
else
|
||||
echo "WARNING: No DHCP range start and/or limit for client interface \"$name\" set!"
|
||||
fi
|
||||
|
||||
# ra
|
||||
uci -q set dhcp.$name.ra='server'
|
||||
uci -q set dhcp.$name.ra_default='2'
|
||||
uci -q set dhcp.$name.ra_management='0'
|
||||
|
||||
# set interface
|
||||
#remove all eth interfaces
|
||||
if vlan=$(uci -q get gateway.$name.vlan); then
|
||||
uci set network.$name.ifname="${SWITCHDEV}.$vlan"
|
||||
elif iface=$(uci -q get gateway.$name.iface); then
|
||||
uci set network.$name.ifname="$iface"
|
||||
else
|
||||
echo "WARNING: No ifname/vlan for client interface \"$name\" specified"
|
||||
fi
|
||||
}
|
||||
|
||||
remove_clientif() {
|
||||
local name="$1"
|
||||
|
||||
# only remove interfaces created by this script
|
||||
[ "$(uci -q get network.$name.fff_clientif)" == "1" ] || return
|
||||
|
||||
# only remove interfaces that disappeared from gwconfig
|
||||
[ "$(uci -q get gateway.$name)" == "client" ] && return
|
||||
|
||||
uci -q del network.$name
|
||||
uci -q del dhcp.$name
|
||||
}
|
||||
|
||||
if [ "$(uci -q get gateway.client)" != "client" ]; then
|
||||
echo "ERROR: A client interface named \"client\" is required"
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# set interface
|
||||
#remove all eth interfaces
|
||||
ifaces=$(uci get network.client.ifname | sed 's/\beth[^ ]* *//g' | sed 's/\bswitch[^ ]* *//g')
|
||||
if vlan=$(uci -q get gateway.@client[0].vlan); then
|
||||
uci set network.client.ifname="${SWITCHDEV}.$vlan $ifaces"
|
||||
elif iface=$(uci -q get gateway.@client[0].iface); then
|
||||
uci set network.client.ifname="$iface $ifaces"
|
||||
else
|
||||
echo "WARNING: No Interface for client specified"
|
||||
fi
|
||||
config_load network
|
||||
config_foreach remove_clientif interface
|
||||
|
||||
config_load gateway
|
||||
config_foreach add_clientif client
|
||||
}
|
||||
|
||||
apply() {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# load board specific properties
|
||||
BOARD="$(uci get board.model.name)"
|
||||
. /etc/network.$BOARD
|
||||
|
||||
. /lib/functions/fff/interfaces
|
||||
|
||||
configure() {
|
||||
if vlan=$(uci -q get gateway.@wan[0].vlan); then
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/fff/switchports
|
||||
|
||||
# skip if gateway configuration already exists
|
||||
if [ -s /etc/config/gateway ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
touch /etc/config/gateway
|
||||
|
||||
essid='noservice.freifunk'
|
||||
chan2ghz='1'
|
||||
chan5ghz='36'
|
||||
|
||||
uci batch <<EOF
|
||||
set gateway.meta='gateway'
|
||||
set gateway.meta.config_version='2'
|
||||
|
||||
set gateway.client=client
|
||||
set gateway.client.vlan='1'
|
||||
set gateway.client.essid='$essid'
|
||||
set gateway.client.chan2ghz='$chan2ghz'
|
||||
set gateway.client.chan5ghz='$chan5ghz'
|
||||
|
||||
add gateway wan
|
||||
set gateway.@wan[0].vlan='2'
|
||||
|
||||
set gateway.1=vlan
|
||||
set gateway.1.comment='client'
|
||||
set gateway.1.ports='$BATMAN_PORTS $CLIENT_PORTS'
|
||||
set gateway.2=vlan
|
||||
set gateway.2.comment='wan'
|
||||
set gateway.2.ports='$WAN_PORTS'
|
||||
|
||||
add gateway dns
|
||||
add_list gateway.@dns[0].server='fd43:5602:29bd:ffff:1:1:1:1'
|
||||
EOF
|
||||
|
||||
# TODO: one-port
|
||||
# TODO: two-port
|
||||
# TODO: dsa
|
||||
|
||||
uci commit gateway
|
||||
|
||||
exit 0
|
|
@ -14,6 +14,7 @@ define Package/fff-layer3
|
|||
+fff-babeld \
|
||||
+fff-boardname \
|
||||
+fff-dhcp \
|
||||
+fff-firewall \
|
||||
+fff-layer3-config \
|
||||
+fff-mqtt-monitoring \
|
||||
+fff-network \
|
||||
|
|
|
@ -8,12 +8,11 @@ include $(INCLUDE_DIR)/package.mk
|
|||
define Package/$(PKG_NAME)
|
||||
SECTION:=base
|
||||
CATEGORY:=Freifunk
|
||||
TITLE:=Freifunk-Franken network configuration
|
||||
TITLE:=Freifunk-Franken base network configuration
|
||||
URL:=https://www.freifunk-franken.de
|
||||
DEPENDS:= \
|
||||
+owipcalc \
|
||||
+fff-boardname \
|
||||
+fff-firewall
|
||||
+fff-boardname
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
|
@ -26,7 +25,6 @@ endef
|
|||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(CP) ./files/* $(1)/
|
||||
test -d ./$(ARCH) && $(CP) ./$(ARCH)/* $(1)/etc/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="0t 3 4"
|
||||
WAN_PORTS="0t 5"
|
||||
BATMAN_PORTS="0t 1 2"
|
|
@ -1,5 +0,0 @@
|
|||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="0t 1 2"
|
||||
WAN_PORTS="0t 5"
|
||||
BATMAN_PORTS="0t 3 4"
|
|
@ -1,30 +0,0 @@
|
|||
config globals 'globals'
|
||||
option packet_steering '1'
|
||||
|
||||
config interface 'loopback'
|
||||
option ifname 'lo'
|
||||
option proto 'static'
|
||||
option ipaddr '127.0.0.1'
|
||||
option netmask '255.0.0.0'
|
||||
|
||||
config interface 'client'
|
||||
option type 'bridge'
|
||||
option auto '1'
|
||||
|
||||
config interface 'wan'
|
||||
option proto 'none'
|
||||
option ifname 'eth2'
|
||||
|
||||
config interface 'wan4'
|
||||
option proto 'dhcp'
|
||||
option ifname '@wan'
|
||||
|
||||
config interface 'wan6'
|
||||
option proto 'dhcpv6'
|
||||
option reqprefix 'no'
|
||||
option sourcefilter '0'
|
||||
option ifname '@wan'
|
||||
|
||||
config interface 'ethmesh'
|
||||
option proto 'batadv_hardif'
|
||||
option master 'bat0'
|
|
@ -0,0 +1,80 @@
|
|||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
. /lib/functions/system.sh
|
||||
. /lib/functions/fff/interfaces
|
||||
. /lib/functions/fff/network
|
||||
. /lib/functions/fff/meshmac
|
||||
. /lib/functions/fff/routermac
|
||||
. /lib/functions/fff/switchports
|
||||
|
||||
[ -n "$ROUTERMAC" ] || ROUTERMAC=$(get_mac_label)
|
||||
|
||||
## Clear possibly existing network configuration
|
||||
> /etc/config/network
|
||||
|
||||
## Add basic network configuration
|
||||
uci batch <<-__EOF__
|
||||
set network.loopback='interface'
|
||||
set network.loopback.ifname='lo'
|
||||
set network.loopback.proto='static'
|
||||
set network.loopback.ipaddr='127.0.0.1'
|
||||
set network.loopback.netmask='255.0.0.0'
|
||||
|
||||
set network.client='interface'
|
||||
set network.client.type='bridge'
|
||||
set network.client.proto='static'
|
||||
set network.client.auto='1'
|
||||
|
||||
set network.wan='interface'
|
||||
set network.wan.proto='none'
|
||||
set network.wan.ifname='eth2'
|
||||
|
||||
set network.wan4='interface'
|
||||
set network.wan4.proto='dhcp'
|
||||
set network.wan4.ifname='@wan'
|
||||
|
||||
set network.wan6='interface'
|
||||
set network.wan6.proto='dhcpv6'
|
||||
set network.wan6.reqprefix='no'
|
||||
set network.wan6.sourcefilter='0'
|
||||
set network.wan6.ifname='@wan'
|
||||
__EOF__
|
||||
|
||||
## Add switch configuration
|
||||
SWITCHHW=$(swconfig list | awk '{ print $4 }')
|
||||
if [ -n "$SWITCHHW" ]; then
|
||||
uci batch <<-__EOF__
|
||||
set network.$SWITCHDEV=switch
|
||||
set network.$SWITCHDEV.name=$SWITCHHW
|
||||
set network.$SWITCHDEV.enable=1
|
||||
set network.$SWITCHDEV.reset=1
|
||||
set network.$SWITCHDEV.enable_vlan=1
|
||||
__EOF__
|
||||
fi
|
||||
|
||||
## Set router label mac address on client interface
|
||||
if [ -n "$ROUTERMAC" ]; then
|
||||
uci set network.client.macaddr=$ROUTERMAC
|
||||
uci commit network
|
||||
fi
|
||||
|
||||
## Set default ip addresses
|
||||
prefix="fdff::/64"
|
||||
addr_def=$(owipcalc "$prefix" add ::1)
|
||||
addr_mac=$(owipcalc "$prefix" add "::$(ipMacSuffix "$ROUTERMAC")")
|
||||
addr_eui=$(owipcalc "$prefix" add "::$(ipEUISuffix "$ROUTERMAC")")
|
||||
|
||||
uci batch <<-__EOF__
|
||||
set network.globals=globals
|
||||
set network.globals.ula_prefix=$prefix
|
||||
|
||||
add_list network.client.ip6addr=$addr_def
|
||||
add_list network.client.ip6addr=$addr_mac
|
||||
add_list network.client.ip6addr=$addr_eui
|
||||
__EOF__
|
||||
|
||||
uci commit network
|
||||
[ -s /etc/init.d/fff-uradvd ] && /etc/init.d/fff-uradvd restart
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,61 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
BOARD="$(uci get board.model.name)"
|
||||
|
||||
case "$BOARD" in
|
||||
avm,fritzbox-4040|\
|
||||
tplink,archer-c50-v3|\
|
||||
tplink,archer-c50-v4|\
|
||||
tplink,archer-c7-v5|\
|
||||
tplink,c2600|\
|
||||
tplink,tl-wdr3600-v1|\
|
||||
tplink,tl-wdr4300-v1|\
|
||||
tplink,tl-wdr4310-v1|\
|
||||
tplink,tl-wdr4900-v1|\
|
||||
tplink,tl-wr1043nd-v2|\
|
||||
tplink,tl-wr1043nd-v3|\
|
||||
tplink,tl-wr1043nd-v4|\
|
||||
tplink,tl-wr1043n-v5|\
|
||||
tplink,tl-wr841n-v13|\
|
||||
xiaomi,mi-router-4a-100m)
|
||||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
;;
|
||||
glinet,gl-ar150|\
|
||||
tplink,archer-c25-v1|\
|
||||
tplink,archer-c60-v1|\
|
||||
tplink,archer-c60-v2|\
|
||||
tplink,cpe210-v1|\
|
||||
tplink,tl-wdr3500-v1)
|
||||
WANDEV=eth1
|
||||
SWITCHDEV=eth0
|
||||
;;
|
||||
tplink,archer-c7-v2)
|
||||
WANDEV=eth1
|
||||
SWITCHDEV=eth1
|
||||
;;
|
||||
tplink,cpe210-v1|\
|
||||
tplink,cpe510-v1)
|
||||
WANDEV=eth1
|
||||
SWITCHDEV=eth0
|
||||
TWO_PORT=YES
|
||||
;;
|
||||
network.ubnt,unifi|\
|
||||
network.ubnt,unifiac-mesh|\
|
||||
tplink,cpe210-v2|\
|
||||
tplink,cpe210-v3|\
|
||||
ubnt,nanostation-loco-m-xw)
|
||||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
ONE_PORT=YES
|
||||
;;
|
||||
netgear,r6220|\
|
||||
ubnt,edgerouter-4|\
|
||||
ubnt,edgerouter-x-sfp|\
|
||||
ubnt,edgerouter-x|\
|
||||
xiaomi,mi-router-4a-gigabit)
|
||||
WANDEV=switch0
|
||||
SWITCHDEV=switch0
|
||||
DSA=1
|
||||
;;
|
||||
esac
|
|
@ -0,0 +1,44 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/system.sh
|
||||
. /lib/functions/fff/network
|
||||
|
||||
BOARD="$(uci get board.model.name)"
|
||||
|
||||
case "$BOARD" in
|
||||
tplink,archer-c7-v2|\
|
||||
tplink,archer-c25-v1)
|
||||
ETHMESHMAC=$(cat /sys/class/net/eth0/address)
|
||||
;;
|
||||
tplink,archer-c60-v1|\
|
||||
tplink,archer-c60-v2)
|
||||
ETHMESHMAC=$(cat /sys/class/net/eth1/address)
|
||||
;;
|
||||
glinet,gl-ar150|\
|
||||
netgear,r6220|\
|
||||
tplink,archer-c50-v3|\
|
||||
tplink,archer-c50-v4)
|
||||
ETHMESHMAC="$(macFlipLocalBit $(cat /sys/class/net/eth0/address))"
|
||||
;;
|
||||
tplink,archer-c7-v5|\
|
||||
tplink,tl-wdr4900-v1)
|
||||
# use mac address from phy1 with 'locally administered' bit set to '1'
|
||||
# only possible, because wXmesh is created first and therefore gets the 'universally administered address'
|
||||
ETHMESHMAC=$(macFlipLocalBit "$(cat /sys/class/ieee80211/phy1/macaddress)")
|
||||
;;
|
||||
tplink,tl-wdr3600-v1|\
|
||||
tplink,tl-wdr4300-v1|\
|
||||
tplink,tl-wdr4310-v1)
|
||||
ETHMESHMAC=$(macaddr_add $(cat /sys/class/ieee80211/phy1/macaddress) 1)
|
||||
;;
|
||||
tplink,tl-wr1043nd-v4|\
|
||||
tplink,tl-wr1043n-v5)
|
||||
# Load second MAC address from flash because we haven't any interface with this
|
||||
# address where we can copy it from
|
||||
ETHMESHMAC=$(macaddr_add $(mtd_get_mac_binary info 8) 1)
|
||||
;;
|
||||
tplink,tl-wr841n-v13)
|
||||
ETHMESHMAC=$(macaddr_setbit_la $(cat /sys/class/net/eth0/address))
|
||||
;;
|
||||
esac
|
|
@ -0,0 +1,9 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
BOARD="$(uci get board.model.name)"
|
||||
|
||||
case "$BOARD" in
|
||||
ubnt,edgerouter-4)
|
||||
ROUTERMAC=$(cat /sys/class/net/lan3/address)
|
||||
;;
|
||||
esac
|
|
@ -0,0 +1,88 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
BOARD="$(uci get board.model.name)"
|
||||
|
||||
case "$BOARD" in
|
||||
tplink,c2600|\
|
||||
tplink,tl-wr1043nd-v2|\
|
||||
tplink,tl-wr1043nd-v3|\
|
||||
tplink,tl-wr1043nd-v4|\
|
||||
tplink,tl-wr1043n-v5)
|
||||
CLIENT_PORTS="1 2"
|
||||
BATMAN_PORTS="3 4"
|
||||
WAN_PORTS="5"
|
||||
;;
|
||||
avm,fritzbox-4040)
|
||||
CLIENT_PORTS="3 4"
|
||||
BATMAN_PORTS="1 2"
|
||||
WAN_PORTS="5"
|
||||
;;
|
||||
tplink,archer-c7-v2|\
|
||||
tplink,archer-c7-v5|\
|
||||
tplink,tl-wdr3600-v1|\
|
||||
tplink,tl-wdr4300-v1|\
|
||||
tplink,tl-wdr4310-v1|\
|
||||
tplink,tl-wdr4900-v1)
|
||||
CLIENT_PORTS="4 5"
|
||||
BATMAN_PORTS="2 3"
|
||||
WAN_PORTS="1"
|
||||
;;
|
||||
tplink,archer-c50-v3|\
|
||||
tplink,archer-c50-v4|\
|
||||
tplink,tl-wr1043nd-v1|\
|
||||
tplink,tl-wr841n-v13)
|
||||
CLIENT_PORTS="3 4"
|
||||
BATMAN_PORTS="1 2"
|
||||
WAN_PORTS="0"
|
||||
;;
|
||||
xiaomi,mi-router-4a-100m)
|
||||
CLIENT_PORTS="4"
|
||||
BATMAN_PORTS="2"
|
||||
WAN_PORTS="0"
|
||||
;;
|
||||
ubnt,edgerouter-4)
|
||||
CLIENT_PORTS="lan2"
|
||||
BATMAN_PORTS="lan1"
|
||||
WAN_PORTS="lan0"
|
||||
;;
|
||||
ubnt,edgerouter-x|\
|
||||
ubnt,edgerouter-x-sfp)
|
||||
CLIENT_PORTS="eth3 eth4"
|
||||
BATMAN_PORTS="eth1 eth2"
|
||||
WAN_PORTS="eth0"
|
||||
;;
|
||||
netgear,r6220)
|
||||
CLIENT_PORTS="lan1 lan2"
|
||||
BATMAN_PORTS="lan3 lan4"
|
||||
WAN_PORTS="wan"
|
||||
;;
|
||||
xiaomi,mi-router-4a-gigabit)
|
||||
CLIENT_PORTS="lan2"
|
||||
BATMAN_PORTS="lan1"
|
||||
WAN_PORTS="wan"
|
||||
;;
|
||||
tplink,archer-c25-v1|\
|
||||
tplink,archer-c60-v1|\
|
||||
tplink,archer-c60-v2|\
|
||||
tplink,tl-wdr3500-v1|\
|
||||
tplink,tl-wr740n-v4|\
|
||||
tplink,tl-wr741-v1|\
|
||||
tplink,tl-wr841-v10|\
|
||||
tplink,tl-wr841-v11|\
|
||||
tplink,tl-wr841-v12|\
|
||||
tplink,tl-wr841-v7|\
|
||||
tplink,tl-wr841-v9)
|
||||
CLIENT_PORTS="1 2"
|
||||
BATMAN_PORTS="3 4"
|
||||
;;
|
||||
tplink,tl-wr741nd-v4|\
|
||||
tplink,tl-wr841-v8|\
|
||||
tplink,tl-wr842n-v2)
|
||||
CLIENT_PORTS="1 4"
|
||||
BATMAN_PORTS="2 3"
|
||||
;;
|
||||
tplink,tl-wr710n-v1)
|
||||
CLIENT_PORTS="3"
|
||||
BATMAN_PORTS=""
|
||||
;;
|
||||
esac
|
|
@ -1,259 +0,0 @@
|
|||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
. /lib/functions/system.sh
|
||||
. /lib/functions/fff/network
|
||||
|
||||
BOARD="$(uci get board.model.name)"
|
||||
. /etc/network.$BOARD
|
||||
[ -n "$ROUTERMAC" ] || ROUTERMAC=$(get_mac_label)
|
||||
|
||||
if [ -s /etc/network.config ] ; then
|
||||
. /etc/network.config
|
||||
else
|
||||
# Write network.config
|
||||
if [ "$ONE_PORT" = "YES" ] || [ -n "$ETHPORT" ] ; then
|
||||
echo "ETHMODE='$ETHMODE' # use BATMAN, CLIENT or WAN" >> /etc/network.config
|
||||
fi
|
||||
if [ -n "$TWO_PORT" ] ; then
|
||||
echo "LAN0MODE='$LAN0MODE' # use BATMAN, CLIENT or WAN" >> /etc/network.config
|
||||
echo "LAN1MODE='$LAN1MODE' # use BATMAN, CLIENT or WAN" >> /etc/network.config
|
||||
fi
|
||||
echo "FORCEPARSE='0' # Parse at: 0=first boot only, 1=every reboot, 2=next reboot (once)" >> /etc/network.config
|
||||
fi
|
||||
|
||||
if [ "$FORCEPARSE" = '2' ] ; then
|
||||
sed -i '/^FORCEPARSE/d' /etc/network.config
|
||||
echo "FORCEPARSE='0' # Parse at: 0=first boot only, 1=every reboot, 2=next reboot (once)" >> /etc/network.config
|
||||
FORCEPARSE='1'
|
||||
fi
|
||||
|
||||
if [ "$ONE_PORT" = "YES" ]; then
|
||||
if ! uci -q get network.$SWITCHDEV.ifname || [ "$FORCEPARSE" = '1' ] ; then
|
||||
uci set network.$SWITCHDEV=interface
|
||||
uci set network.$SWITCHDEV.ifname=$SWITCHDEV
|
||||
if [ "$ETHMODE" = "WAN" ]; then
|
||||
uci set network.client.ifname="bat0"
|
||||
uci set network.wan.ifname="$WANDEV"
|
||||
uci del network.ethmesh.ifname
|
||||
uci del network.${SWITCHDEV}.macaddr
|
||||
elif [ "$ETHMODE" = "CLIENT" ] ; then
|
||||
uci set network.client.ifname="bat0 $SWITCHDEV"
|
||||
uci set network.wan.ifname="eth2" #eth2 because it is default in config file
|
||||
uci del network.ethmesh.ifname
|
||||
uci del network.${SWITCHDEV}.macaddr
|
||||
elif [ "$ETHMODE" = "BATMAN" ] ; then
|
||||
uci set network.client.ifname="bat0"
|
||||
uci set network.wan.ifname="eth2" #eth2 because it is default in config file
|
||||
uci set network.ethmesh.ifname="$SWITCHDEV"
|
||||
ETH0DEV="$SWITCHDEV"
|
||||
ETH0MAC="w2ap"
|
||||
fi
|
||||
uci commit network
|
||||
fi
|
||||
elif [ "$TWO_PORT" = "YES" ]; then
|
||||
if ! uci -q get network.$WANDEV.ifname || [ "$FORCEPARSE" = '1' ] ; then
|
||||
uci set network.$WANDEV=interface
|
||||
uci set network.$WANDEV.ifname="$WANDEV"
|
||||
uci set network.$SWITCHDEV=interface
|
||||
uci set network.$SWITCHDEV.ifname="$SWITCHDEV"
|
||||
# Only one WAN possible, second port will be unset if both are WAN
|
||||
if [ "$LAN0MODE" = "WAN" ]; then
|
||||
if [ "$LAN1MODE" = "CLIENT" ]; then
|
||||
uci set network.client.ifname="bat0 $SWITCHDEV"; else
|
||||
uci set network.client.ifname=bat0; fi
|
||||
# WAN
|
||||
uci set network.wan.ifname="$WANDEV"
|
||||
if [ "$LAN1MODE" = "BATMAN" ]; then
|
||||
uci set network.ethmesh.ifname="$SWITCHDEV"; else
|
||||
uci del network.ethmesh.ifname; fi
|
||||
# Two client ports are possible
|
||||
elif [ "$LAN0MODE" = "CLIENT" ]; then
|
||||
if [ "$LAN1MODE" = "CLIENT" ]; then
|
||||
uci set network.client.ifname="bat0 $WANDEV $SWITCHDEV"; else
|
||||
uci set network.client.ifname="bat0 $WANDEV"; fi
|
||||
if [ "$LAN1MODE" = "WAN" ]; then
|
||||
uci set network.wan.ifname="$SWITCHDEV"; else
|
||||
uci set network.wan.ifname=eth2; fi #eth2 because it is default in config file
|
||||
if [ "$LAN1MODE" = "BATMAN" ]; then
|
||||
uci set network.ethmesh.ifname="$SWITCHDEV"; else
|
||||
uci del network.ethmesh.ifname; fi
|
||||
# Only one BATMAN port possible, second port will be unset if both are BATMAN
|
||||
elif [ "$LAN0MODE" = "BATMAN" ] ; then
|
||||
if [ "$LAN1MODE" = "CLIENT" ]; then
|
||||
uci set network.client.ifname="bat0 $SWITCHDEV"; else
|
||||
uci set network.client.ifname=bat0; fi
|
||||
if [ "$LAN1MODE" = "WAN" ]; then
|
||||
uci set network.wan.ifname="$SWITCHDEV"; else
|
||||
uci set network.wan.ifname=eth2; fi #eth2 because it is default in config file
|
||||
# BATMAN
|
||||
uci set network.ethmesh.ifname="$WANDEV"
|
||||
fi
|
||||
if [ "$LAN0MODE" = "BATMAN" ]; then
|
||||
ETH0DEV="$WANDEV" # only needed for setting macaddr
|
||||
ETH0MAC=w2ap
|
||||
uci del network.$SWITCHDEV.macaddr
|
||||
elif [ "$LAN1MODE" = "BATMAN" ]; then
|
||||
# $WANDEV will win if both are set to BATMAN, as above
|
||||
ETH0DEV="$SWITCHDEV" # only needed for setting macaddr
|
||||
ETH0MAC=w2ap
|
||||
uci del network.$WANDEV.macaddr
|
||||
else
|
||||
uci del network.$WANDEV.macaddr
|
||||
uci del network.$SWITCHDEV.macaddr
|
||||
fi
|
||||
|
||||
uci commit network
|
||||
fi
|
||||
else
|
||||
if ! uci -q get network.$SWITCHDEV > /dev/null ; then
|
||||
|
||||
if [ "$DSA" = "1" ]; then
|
||||
uci set network.$SWITCHDEV=device
|
||||
uci set network.$SWITCHDEV.name=$SWITCHDEV
|
||||
uci set network.$SWITCHDEV.type=bridge
|
||||
# temporary workaround for netifd bug present in OpenWrt 21.02.0 (FS#4104)
|
||||
uci set network.$SWITCHDEV.bridge_empty='1'
|
||||
|
||||
uci set network.${SWITCHDEV}_1=bridge-vlan
|
||||
uci set network.${SWITCHDEV}_1.device=$SWITCHDEV
|
||||
uci set network.${SWITCHDEV}_1.vlan=1
|
||||
uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS"
|
||||
|
||||
if [ "$WANDEV" = "$SWITCHDEV" ] || ! [ -z "$WAN_PORTS" ]; then
|
||||
uci set network.${SWITCHDEV}_2=bridge-vlan
|
||||
uci set network.${SWITCHDEV}_2.device=$SWITCHDEV
|
||||
uci set network.${SWITCHDEV}_2.vlan=2
|
||||
uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS"
|
||||
fi
|
||||
|
||||
uci set network.${SWITCHDEV}_3=bridge-vlan
|
||||
uci set network.${SWITCHDEV}_3.device=$SWITCHDEV
|
||||
uci set network.${SWITCHDEV}_3.vlan=3
|
||||
uci set network.${SWITCHDEV}_3.ports="$BATMAN_PORTS"
|
||||
else
|
||||
SWITCHHW=$(swconfig list | awk '{ print $4 }')
|
||||
|
||||
uci set network.$SWITCHDEV=switch
|
||||
uci set network.$SWITCHDEV.name=$SWITCHHW
|
||||
uci set network.$SWITCHDEV.enable=1
|
||||
uci set network.$SWITCHDEV.reset=1
|
||||
uci set network.$SWITCHDEV.enable_vlan=1
|
||||
|
||||
uci set network.${SWITCHDEV}_1=switch_vlan
|
||||
uci set network.${SWITCHDEV}_1.device=$SWITCHHW
|
||||
uci set network.${SWITCHDEV}_1.vlan=1
|
||||
uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS"
|
||||
|
||||
if [ "$WANDEV" = "$SWITCHDEV" ] || [ -n "$WAN_PORTS" ]; then
|
||||
uci set network.${SWITCHDEV}_2=switch_vlan
|
||||
uci set network.${SWITCHDEV}_2.device=$SWITCHHW
|
||||
uci set network.${SWITCHDEV}_2.vlan=2
|
||||
uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS"
|
||||
fi
|
||||
|
||||
uci set network.${SWITCHDEV}_3=switch_vlan
|
||||
uci set network.${SWITCHDEV}_3.device=$SWITCHHW
|
||||
uci set network.${SWITCHDEV}_3.vlan=3
|
||||
uci set network.${SWITCHDEV}_3.ports="$BATMAN_PORTS"
|
||||
fi
|
||||
|
||||
uci set network.client.ifname="$SWITCHDEV.1 bat0"
|
||||
|
||||
uci set network.ethmesh.ifname="$SWITCHDEV.3"
|
||||
|
||||
if [ "$WANDEV" = "$SWITCHDEV" ]; then
|
||||
uci set network.wan.ifname=$WANDEV.2
|
||||
else
|
||||
uci set network.wan.ifname=$WANDEV
|
||||
fi
|
||||
|
||||
uci commit network
|
||||
fi
|
||||
fi
|
||||
|
||||
/etc/init.d/network restart
|
||||
|
||||
if [ -n "$ETHMESHMAC" ]; then
|
||||
if uci get network.ethmesh.macaddr
|
||||
then
|
||||
echo "MAC for ethmesh is set already"
|
||||
else
|
||||
echo "Fixing MAC on $SWITCHDEV.3 (ethmesh)"
|
||||
sleep 10
|
||||
|
||||
uci set network.ethmesh.macaddr=$ETHMESHMAC
|
||||
uci commit network
|
||||
|
||||
ifconfig $SWITCHDEV.3 down
|
||||
ifconfig $SWITCHDEV.3 hw ether $ETHMESHMAC
|
||||
ifconfig $SWITCHDEV.3 up
|
||||
/etc/init.d/network restart
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$ROUTERMAC" ]; then
|
||||
if uci get network.client.macaddr
|
||||
then
|
||||
echo "MAC for client is set already"
|
||||
else
|
||||
echo "Fixing MAC on br-client"
|
||||
sleep 10
|
||||
|
||||
uci set network.client.macaddr=$ROUTERMAC
|
||||
uci commit network
|
||||
|
||||
ifconfig br-client down
|
||||
ifconfig br-client hw ether $ROUTERMAC
|
||||
ifconfig br-client up
|
||||
/etc/init.d/network restart
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$ETH0MAC" ]; then
|
||||
echo "Fixing MAC on $ETH0DEV"
|
||||
sleep 10
|
||||
NEW_MACADDR=$(cat "/sys/class/net/${ETH0MAC}/address")
|
||||
uci set network.$ETH0DEV.macaddr=$NEW_MACADDR
|
||||
uci commit network
|
||||
ifconfig $ETH0DEV down
|
||||
ifconfig $ETH0DEV hw ether $NEW_MACADDR
|
||||
ifconfig $ETH0DEV up
|
||||
/etc/init.d/network restart
|
||||
fi
|
||||
|
||||
if uci -q get "network.client.ip6addr" > /dev/null
|
||||
then
|
||||
echo "IPv6 for client is set already"
|
||||
else
|
||||
echo "Setting IPv6 addresses"
|
||||
# Some time needed :(
|
||||
sleep 5
|
||||
|
||||
for ip in $(ip -6 addr show br-client | awk '/fdff/{ print $2 }'); do
|
||||
ip -6 addr del $ip dev br-client
|
||||
done
|
||||
|
||||
prefix="fdff::/64"
|
||||
# Set $prefix::MAC as IP
|
||||
addr=$(owipcalc "$prefix" add "::$(ipMacSuffix "$ROUTERMAC")")
|
||||
ip -6 addr add $addr dev br-client
|
||||
|
||||
uci -q set network.globals.ula_prefix=$prefix
|
||||
uci -q add_list network.client.ip6addr=$addr
|
||||
uci -q set network.client.proto=static
|
||||
|
||||
# Set $prefix::1 as IP
|
||||
addr=$(owipcalc "$prefix" add ::1)
|
||||
ip -6 addr add $addr dev br-client
|
||||
uci -q add_list network.client.ip6addr=$addr
|
||||
|
||||
# Set $prefix::link-local as IP
|
||||
addr=$(owipcalc "$prefix" add "::$(ipEUISuffix "$ROUTERMAC")")
|
||||
ip -6 addr add $addr dev br-client
|
||||
uci -q add_list network.client.ip6addr=$addr
|
||||
|
||||
uci -q commit network
|
||||
|
||||
[ -s /etc/init.d/fff-uradvd ] && /etc/init.d/fff-uradvd restart
|
||||
fi
|
|
@ -1,13 +0,0 @@
|
|||
. /lib/functions/fff/network
|
||||
|
||||
WANDEV=eth1
|
||||
SWITCHDEV=eth0
|
||||
WAN_PORTS=
|
||||
BATMAN_PORTS="0t"
|
||||
CLIENT_PORTS="0t"
|
||||
|
||||
ETHMESHMAC="$(macFlipLocalBit $(cat /sys/class/net/eth0/address))"
|
||||
|
||||
. /etc/network.mode
|
||||
|
||||
ETHPORT=1
|
|
@ -1,30 +0,0 @@
|
|||
################
|
||||
## This file is used to configure the behavior of network interfaces
|
||||
## if the routers interfaces differ from the standard WAN+4LAN-Ports
|
||||
## +2Wireless APs.
|
||||
## If you want to change their behavior, you should edit the file
|
||||
## /etc/network.config
|
||||
## After that you have to reboot the router with following command.
|
||||
#reboot
|
||||
#
|
||||
### The canonical syntax of this file is:
|
||||
#SPECIFIER="MODE"
|
||||
### MODES
|
||||
## Generally there are 3 operating modes for network interfaces in fff.
|
||||
#BATMAN: The interface is used to mesh with other fff-nodes
|
||||
#WAN: The interface is used to connect to supernodes via vpn and
|
||||
# ordinary internet.
|
||||
#CLIENT: The interface is used to connect clients to the fff-net
|
||||
##
|
||||
### SPECIFIER
|
||||
## For devices only including one ethernet port the specifier is called
|
||||
## ETHMODE. The default mode for these devices is "BATMAN".
|
||||
## For example this is the case for: gl-ar150, tl-mr3020-v1, tl-wa850re-v1,
|
||||
## tl-wa860re-v1, tl-wa901nd-v2, ubnt-bullet-m, ubnt-loco-m-xw, ubnt-nano-m,
|
||||
## ubnt-unifi
|
||||
ETHMODE="CLIENT"
|
||||
## Devices featuring 2 ethernet ports are configured by SPECIFIERs ressembling
|
||||
## the labels on the PORT itself. For the cpe210 these are called LAN0 and LAN1.
|
||||
## Therefore they are configured as follows:
|
||||
LAN0MODE="WAN"
|
||||
LAN1MODE="CLIENT"
|
|
@ -1,7 +0,0 @@
|
|||
WANDEV=eth1
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="1 2 0t"
|
||||
WAN_PORTS=""
|
||||
BATMAN_PORTS="3 4 0t"
|
||||
|
||||
ETHMESHMAC=$(cat /sys/class/net/eth0/address)
|
|
@ -1,6 +0,0 @@
|
|||
WANDEV=eth1
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="1 2 0t"
|
||||
BATMAN_PORTS="3 4 0t"
|
||||
|
||||
ETHMESHMAC=$(cat /sys/class/net/eth1/address)
|
|
@ -1,6 +0,0 @@
|
|||
WANDEV=eth1
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="1 2 0t"
|
||||
BATMAN_PORTS="3 4 0t"
|
||||
|
||||
ETHMESHMAC=$(cat /sys/class/net/eth1/address)
|
|
@ -1,7 +0,0 @@
|
|||
WANDEV=eth1
|
||||
SWITCHDEV=eth1
|
||||
CLIENT_PORTS="4 5 0t"
|
||||
WAN_PORTS="1 0t"
|
||||
BATMAN_PORTS="2 3 0t"
|
||||
|
||||
ETHMESHMAC=$(cat /sys/class/net/eth0/address)
|
|
@ -1,12 +0,0 @@
|
|||
. /lib/functions/fff/network
|
||||
|
||||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="4 5 0t"
|
||||
WAN_PORTS="1 0t"
|
||||
BATMAN_PORTS="2 3 0t"
|
||||
|
||||
# use mac address from phy1 with 'locally administered' bit set to '1'
|
||||
# only possible, because wXmesh is created first and therefore gets the 'universally administered address'
|
||||
|
||||
ETHMESHMAC=$(macFlipLocalBit "$(cat /sys/class/ieee80211/phy1/macaddress)")
|
|
@ -1,5 +0,0 @@
|
|||
WANDEV=eth1
|
||||
SWITCHDEV=eth0
|
||||
TWO_PORT=YES
|
||||
|
||||
. /etc/network.mode
|
|
@ -1,5 +0,0 @@
|
|||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
ONE_PORT="YES"
|
||||
|
||||
. /etc/network.mode
|
|
@ -1,5 +0,0 @@
|
|||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
ONE_PORT="YES"
|
||||
|
||||
. /etc/network.mode
|
|
@ -1,5 +0,0 @@
|
|||
WANDEV=eth1
|
||||
SWITCHDEV=eth0
|
||||
TWO_PORT=YES
|
||||
|
||||
. /etc/network.mode
|
|
@ -1,5 +0,0 @@
|
|||
WANDEV=eth1
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="0t 1 2"
|
||||
WAN_PORTS=
|
||||
BATMAN_PORTS="0t 3 4"
|
|
@ -1,9 +0,0 @@
|
|||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="0t 4 5"
|
||||
WAN_PORTS="0t 1"
|
||||
BATMAN_PORTS="0t 2 3"
|
||||
|
||||
. /lib/functions/system.sh
|
||||
|
||||
ETHMESHMAC=$(macaddr_add $(cat /sys/class/ieee80211/phy1/macaddress) 1)
|
|
@ -1,9 +0,0 @@
|
|||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="0t 4 5"
|
||||
WAN_PORTS="0t 1"
|
||||
BATMAN_PORTS="0t 2 3"
|
||||
|
||||
. /lib/functions/system.sh
|
||||
|
||||
ETHMESHMAC=$(macaddr_add $(cat /sys/class/ieee80211/phy1/macaddress) 1)
|
|
@ -1,9 +0,0 @@
|
|||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="0t 4 5"
|
||||
WAN_PORTS="0t 1"
|
||||
BATMAN_PORTS="0t 2 3"
|
||||
|
||||
. /lib/functions/system.sh
|
||||
|
||||
ETHMESHMAC=$(macaddr_add $(cat /sys/class/ieee80211/phy1/macaddress) 1)
|
|
@ -1,13 +0,0 @@
|
|||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="1 2 0t"
|
||||
WAN_PORTS="5 0t"
|
||||
BATMAN_PORTS="3 4 0t"
|
||||
|
||||
. /lib/functions/system.sh
|
||||
. /lib/functions.sh
|
||||
|
||||
# Load second MAC address from flash because we haven't any interface with this
|
||||
# address where we can copy it from
|
||||
|
||||
ETHMESHMAC=$(macaddr_add $(mtd_get_mac_binary info 8) 1)
|
|
@ -1,5 +0,0 @@
|
|||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="1 2 6t"
|
||||
WAN_PORTS="5 6t"
|
||||
BATMAN_PORTS="3 4 6t"
|
|
@ -1,5 +0,0 @@
|
|||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="1 2 6t"
|
||||
WAN_PORTS="5 6t"
|
||||
BATMAN_PORTS="3 4 6t"
|
|
@ -1,13 +0,0 @@
|
|||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="1 2 0t"
|
||||
WAN_PORTS="5 0t"
|
||||
BATMAN_PORTS="3 4 0t"
|
||||
|
||||
. /lib/functions/system.sh
|
||||
. /lib/functions.sh
|
||||
|
||||
# Load second MAC address from flash because we haven't any interface with this
|
||||
# address where we can copy it from
|
||||
|
||||
ETHMESHMAC=$(macaddr_add $(mtd_get_mac_binary info 8) 1)
|
|
@ -1,8 +0,0 @@
|
|||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS=""
|
||||
WAN_PORTS=""
|
||||
BATMAN_PORTS=""
|
||||
ONE_PORT="YES"
|
||||
|
||||
. /etc/network.mode
|
|
@ -1,8 +0,0 @@
|
|||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS=""
|
||||
WAN_PORTS=""
|
||||
BATMAN_PORTS=""
|
||||
ONE_PORT="YES"
|
||||
|
||||
. /etc/network.mode
|
|
@ -1,8 +0,0 @@
|
|||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS=""
|
||||
WAN_PORTS=""
|
||||
BATMAN_PORTS=""
|
||||
ONE_PORT="YES"
|
||||
|
||||
. /etc/network.mode
|
|
@ -1,10 +0,0 @@
|
|||
. /lib/functions/fff/network
|
||||
|
||||
WANDEV=switch0
|
||||
SWITCHDEV=switch0
|
||||
CLIENT_PORTS="lan2"
|
||||
WAN_PORTS="lan0"
|
||||
BATMAN_PORTS="lan1"
|
||||
DSA=1
|
||||
|
||||
ROUTERMAC=$(cat /sys/class/net/lan3/address)
|
|
@ -1,10 +0,0 @@
|
|||
. /lib/functions/fff/network
|
||||
|
||||
WANDEV=switch0
|
||||
SWITCHDEV=switch0
|
||||
CLIENT_PORTS="lan1 lan2"
|
||||
WAN_PORTS="wan"
|
||||
BATMAN_PORTS="lan3 lan4"
|
||||
DSA=1
|
||||
|
||||
ETHMESHMAC=$(macFlipLocalBit "$(cat /sys/class/net/eth0/address)")
|
|
@ -1,9 +0,0 @@
|
|||
. /lib/functions/fff/network
|
||||
|
||||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="6t 3 4"
|
||||
WAN_PORTS="6t 0"
|
||||
BATMAN_PORTS="6t 1 2"
|
||||
|
||||
ETHMESHMAC=$(macFlipLocalBit "$(cat /sys/class/net/eth0/address)")
|
|
@ -1,9 +0,0 @@
|
|||
. /lib/functions/fff/network
|
||||
|
||||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="6t 3 4"
|
||||
WAN_PORTS="6t 0"
|
||||
BATMAN_PORTS="6t 1 2"
|
||||
|
||||
ETHMESHMAC=$(macFlipLocalBit "$(cat /sys/class/net/eth0/address)")
|
|
@ -1,9 +0,0 @@
|
|||
. /lib/functions/system.sh
|
||||
|
||||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="6t 3 4"
|
||||
WAN_PORTS="6t 0"
|
||||
BATMAN_PORTS="6t 1 2"
|
||||
|
||||
ETHMESHMAC=$(macaddr_setbit_la $(cat /sys/class/net/eth0/address))
|
|
@ -1,6 +0,0 @@
|
|||
WANDEV=switch0
|
||||
SWITCHDEV=switch0
|
||||
CLIENT_PORTS="eth3 eth4"
|
||||
WAN_PORTS="eth0"
|
||||
BATMAN_PORTS="eth1 eth2"
|
||||
DSA=1
|
|
@ -1,6 +0,0 @@
|
|||
WANDEV=switch0
|
||||
SWITCHDEV=switch0
|
||||
CLIENT_PORTS="eth3 eth4 eth5"
|
||||
WAN_PORTS="eth0"
|
||||
BATMAN_PORTS="eth1 eth2"
|
||||
DSA=1
|
|
@ -1,7 +0,0 @@
|
|||
. /lib/functions/fff/network
|
||||
|
||||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="6t 4"
|
||||
WAN_PORTS="6t 0"
|
||||
BATMAN_PORTS="6t 2"
|
|
@ -1,6 +0,0 @@
|
|||
WANDEV=switch0
|
||||
SWITCHDEV=switch0
|
||||
CLIENT_PORTS="lan2"
|
||||
WAN_PORTS="wan"
|
||||
BATMAN_PORTS="lan1"
|
||||
DSA=1
|
|
@ -1,12 +0,0 @@
|
|||
. /lib/functions/fff/network
|
||||
|
||||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="0t 4 5"
|
||||
WAN_PORTS="0t 1"
|
||||
BATMAN_PORTS="0t 2 3"
|
||||
|
||||
# use mac address from phy1 with 'locally administered' bit set to '1'
|
||||
# only possible, because wXmesh is created first and therefore gets the 'universally administered address'
|
||||
|
||||
ETHMESHMAC=$(macFlipLocalBit "$(cat /sys/class/ieee80211/phy1/macaddress)")
|
|
@ -0,0 +1,30 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=fff-node-config
|
||||
PKG_RELEASE:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=base
|
||||
CATEGORY:=Freifunk
|
||||
TITLE:=Freifunk-Franken node network configuration
|
||||
URL:=https://www.freifunk-franken.de
|
||||
DEPENDS:= \
|
||||
+fff-boardname \
|
||||
+fff-network
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
This package configures the network interfaces
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
# nothing
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(CP) ./files/* $(1)/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
. /lib/functions/fff/interfaces
|
||||
|
||||
## Add batman interfaces
|
||||
uci batch <<-__EOF__
|
||||
set network.bat0='interface'
|
||||
set network.bat0.proto='batadv'
|
||||
set network.bat0.gw_mode='client'
|
||||
set network.bat0.gw_sel_class='1'
|
||||
set network.bat0.network_coding='0'
|
||||
set network.bat0.aggregated_ogms='1'
|
||||
set network.bat0.ap_isolation='0'
|
||||
set network.bat0.bonding='0'
|
||||
set network.bat0.fragmentation='1'
|
||||
set network.bat0.orig_interval='1000'
|
||||
set network.bat0.distributed_arp_table='1'
|
||||
set network.bat0.hop_penalty='30'
|
||||
|
||||
set network.ethmesh='interface'
|
||||
set network.ethmesh.proto='batadv_hardif'
|
||||
set network.ethmesh.master='bat0'
|
||||
__EOF__
|
||||
|
||||
## Fix ethmesh mac-address, if necessary
|
||||
if [ -n "$ETHMESHMAC" ]; then
|
||||
uci set network.ethmesh.macaddr=$ETHMESHMAC
|
||||
uci commit network
|
||||
/etc/init.d/network restart
|
||||
fi
|
||||
|
||||
if [ ! -s /etc/network.config ] ; then
|
||||
# Write network.config
|
||||
if [ "$ONE_PORT" = "YES" ] || [ -n "$ETHPORT" ] ; then
|
||||
echo "ETHMODE='CLIENT' # use BATMAN, CLIENT or WAN" >> /etc/network.config
|
||||
fi
|
||||
if [ -n "$TWO_PORT" ] ; then
|
||||
echo "LAN0MODE='WAN' # use BATMAN, CLIENT or WAN" >> /etc/network.config
|
||||
echo "LAN1MODE='CLIENT' # use BATMAN, CLIENT or WAN" >> /etc/network.config
|
||||
fi
|
||||
fi
|
|
@ -0,0 +1,147 @@
|
|||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
. /lib/functions/system.sh
|
||||
. /lib/functions/fff/network
|
||||
. /lib/functions/fff/cpuport
|
||||
. /lib/functions/fff/interfaces
|
||||
. /lib/functions/fff/switchports
|
||||
|
||||
# Add cpuport to switch configuration
|
||||
CLIENT_PORTS="$(get_cpu_port) $CLIENT_PORTS"
|
||||
BATMAN_PORTS="$(get_cpu_port) $BATMAN_PORTS"
|
||||
[ -n "$WAN_PORTS" ] && WAN_PORTS="$(get_cpu_port) $WAN_PORTS"
|
||||
|
||||
if [ -s /etc/network.config ] ; then
|
||||
. /etc/network.config
|
||||
fi
|
||||
|
||||
if [ "$ONE_PORT" = "YES" ]; then
|
||||
uci set network.$SWITCHDEV=interface
|
||||
uci set network.$SWITCHDEV.ifname=$SWITCHDEV
|
||||
if [ "$ETHMODE" = "WAN" ]; then
|
||||
uci set network.client.ifname="bat0"
|
||||
uci set network.wan.ifname="$WANDEV"
|
||||
uci del network.ethmesh.ifname
|
||||
uci del network.${SWITCHDEV}.macaddr
|
||||
elif [ "$ETHMODE" = "CLIENT" ] ; then
|
||||
uci set network.client.ifname="bat0 $SWITCHDEV"
|
||||
uci set network.wan.ifname="eth2" #eth2 because it is default in config file
|
||||
uci del network.ethmesh.ifname
|
||||
uci del network.${SWITCHDEV}.macaddr
|
||||
elif [ "$ETHMODE" = "BATMAN" ] ; then
|
||||
uci set network.client.ifname="bat0"
|
||||
uci set network.wan.ifname="eth2" #eth2 because it is default in config file
|
||||
uci set network.ethmesh.ifname="$SWITCHDEV"
|
||||
ETH0DEV="$SWITCHDEV"
|
||||
fi
|
||||
uci commit network
|
||||
elif [ "$TWO_PORT" = "YES" ]; then
|
||||
uci set network.$WANDEV=interface
|
||||
uci set network.$WANDEV.ifname="$WANDEV"
|
||||
uci set network.$SWITCHDEV=interface
|
||||
uci set network.$SWITCHDEV.ifname="$SWITCHDEV"
|
||||
# Only one WAN possible, second port will be unset if both are WAN
|
||||
if [ "$LAN0MODE" = "WAN" ]; then
|
||||
if [ "$LAN1MODE" = "CLIENT" ]; then
|
||||
uci set network.client.ifname="bat0 $SWITCHDEV"; else
|
||||
uci set network.client.ifname=bat0; fi
|
||||
# WAN
|
||||
uci set network.wan.ifname="$WANDEV"
|
||||
if [ "$LAN1MODE" = "BATMAN" ]; then
|
||||
uci set network.ethmesh.ifname="$SWITCHDEV"; else
|
||||
uci del network.ethmesh.ifname; fi
|
||||
# Two client ports are possible
|
||||
elif [ "$LAN0MODE" = "CLIENT" ]; then
|
||||
if [ "$LAN1MODE" = "CLIENT" ]; then
|
||||
uci set network.client.ifname="bat0 $WANDEV $SWITCHDEV"; else
|
||||
uci set network.client.ifname="bat0 $WANDEV"; fi
|
||||
if [ "$LAN1MODE" = "WAN" ]; then
|
||||
uci set network.wan.ifname="$SWITCHDEV"; else
|
||||
uci set network.wan.ifname=eth2; fi #eth2 because it is default in config file
|
||||
if [ "$LAN1MODE" = "BATMAN" ]; then
|
||||
uci set network.ethmesh.ifname="$SWITCHDEV"; else
|
||||
uci del network.ethmesh.ifname; fi
|
||||
# Only one BATMAN port possible, second port will be unset if both are BATMAN
|
||||
elif [ "$LAN0MODE" = "BATMAN" ] ; then
|
||||
if [ "$LAN1MODE" = "CLIENT" ]; then
|
||||
uci set network.client.ifname="bat0 $SWITCHDEV"; else
|
||||
uci set network.client.ifname=bat0; fi
|
||||
if [ "$LAN1MODE" = "WAN" ]; then
|
||||
uci set network.wan.ifname="$SWITCHDEV"; else
|
||||
uci set network.wan.ifname=eth2; fi #eth2 because it is default in config file
|
||||
# BATMAN
|
||||
uci set network.ethmesh.ifname="$WANDEV"
|
||||
fi
|
||||
if [ "$LAN0MODE" = "BATMAN" ]; then
|
||||
ETH0DEV="$WANDEV" # only needed for setting macaddr
|
||||
uci del network.$SWITCHDEV.macaddr
|
||||
elif [ "$LAN1MODE" = "BATMAN" ]; then
|
||||
# $WANDEV will win if both are set to BATMAN, as above
|
||||
ETH0DEV="$SWITCHDEV" # only needed for setting macaddr
|
||||
uci del network.$WANDEV.macaddr
|
||||
else
|
||||
uci del network.$WANDEV.macaddr
|
||||
uci del network.$SWITCHDEV.macaddr
|
||||
fi
|
||||
|
||||
uci commit network
|
||||
else
|
||||
if [ "$DSA" = "1" ]; then
|
||||
uci set network.$SWITCHDEV=device
|
||||
uci set network.$SWITCHDEV.name=$SWITCHDEV
|
||||
uci set network.$SWITCHDEV.type=bridge
|
||||
# temporary workaround for netifd bug present in OpenWrt 21.02.0 (FS#4104)
|
||||
uci set network.$SWITCHDEV.bridge_empty='1'
|
||||
|
||||
uci set network.${SWITCHDEV}_1=bridge-vlan
|
||||
uci set network.${SWITCHDEV}_1.device=$SWITCHDEV
|
||||
uci set network.${SWITCHDEV}_1.vlan=1
|
||||
uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS"
|
||||
|
||||
if [ "$WANDEV" = "$SWITCHDEV" ] || ! [ -z "$WAN_PORTS" ]; then
|
||||
uci set network.${SWITCHDEV}_2=bridge-vlan
|
||||
uci set network.${SWITCHDEV}_2.device=$SWITCHDEV
|
||||
uci set network.${SWITCHDEV}_2.vlan=2
|
||||
uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS"
|
||||
fi
|
||||
|
||||
uci set network.${SWITCHDEV}_3=bridge-vlan
|
||||
uci set network.${SWITCHDEV}_3.device=$SWITCHDEV
|
||||
uci set network.${SWITCHDEV}_3.vlan=3
|
||||
uci set network.${SWITCHDEV}_3.ports="$BATMAN_PORTS"
|
||||
else
|
||||
SWITCHHW=$(swconfig list | awk '{ print $4 }')
|
||||
|
||||
uci set network.${SWITCHDEV}_1=switch_vlan
|
||||
uci set network.${SWITCHDEV}_1.device=$SWITCHHW
|
||||
uci set network.${SWITCHDEV}_1.vlan=1
|
||||
uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS"
|
||||
|
||||
if [ "$WANDEV" = "$SWITCHDEV" ] || [ -n "$WAN_PORTS" ]; then
|
||||
uci set network.${SWITCHDEV}_2=switch_vlan
|
||||
uci set network.${SWITCHDEV}_2.device=$SWITCHHW
|
||||
uci set network.${SWITCHDEV}_2.vlan=2
|
||||
uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS"
|
||||
fi
|
||||
|
||||
uci set network.${SWITCHDEV}_3=switch_vlan
|
||||
uci set network.${SWITCHDEV}_3.device=$SWITCHHW
|
||||
uci set network.${SWITCHDEV}_3.vlan=3
|
||||
uci set network.${SWITCHDEV}_3.ports="$BATMAN_PORTS"
|
||||
fi
|
||||
|
||||
uci set network.client.ifname="$SWITCHDEV.1 bat0"
|
||||
|
||||
uci set network.ethmesh.ifname="$SWITCHDEV.3"
|
||||
|
||||
if [ "$WANDEV" = "$SWITCHDEV" ]; then
|
||||
uci set network.wan.ifname=$WANDEV.2
|
||||
else
|
||||
uci set network.wan.ifname=$WANDEV
|
||||
fi
|
||||
|
||||
uci commit network
|
||||
fi
|
||||
|
||||
/etc/init.d/network restart
|
|
@ -14,6 +14,7 @@ define Package/fff-node
|
|||
+fff-fastd \
|
||||
+fff-firewall \
|
||||
+fff-hoods \
|
||||
+fff-node-config \
|
||||
+fff-uradvd
|
||||
endef
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ define Build/Compile
|
|||
endef
|
||||
|
||||
define Package/fff-ra/install
|
||||
$(CP) ./files/* $(1)/
|
||||
# nothing
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,fff-ra))
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
uci batch <<EOF
|
||||
set dhcp.client=dhcp
|
||||
set dhcp.client.interface='client'
|
||||
set dhcp.client.ra='server'
|
||||
set dhcp.client.ra_default='2'
|
||||
set dhcp.client.ra_management='0'
|
||||
EOF
|
||||
|
||||
exit 0
|
|
@ -4,10 +4,9 @@
|
|||
. /lib/functions/fff/evalhoodinfo
|
||||
. /lib/functions/fff/evalbytes
|
||||
. /lib/functions/fff/portorder
|
||||
. /lib/functions/fff/interfaces
|
||||
. /lib/functions.sh # required for config_load and config_foreach
|
||||
|
||||
board_name=$(uci -q get board.model.name)
|
||||
|
||||
HOSTNAME=$(uci -q get 'fff.system.hostname')
|
||||
hood="$(uci -q get "system.@system[0].hood")"
|
||||
hoodid="$(uci -q get "system.@system[0].hoodid")"
|
||||
|
@ -190,7 +189,7 @@ if swconfig list | grep -q switch0 ; then
|
|||
echo ""
|
||||
echo ""
|
||||
|
||||
if [ ! "$(awk -F= '/WANDEV=/ { print $2 }' /etc/network.$board_name)" = "$(awk -F= '/SWITCHDEV=/ { print $2 }' /etc/network.$board_name)" ] ; then
|
||||
if [ ! "$WANDEV" = "$SWITCHDEV" ] ; then
|
||||
wanif=$(uci -q get network.wan.ifname)
|
||||
link=$(cat /sys/class/net/${wanif}/operstate)
|
||||
if [ "$link" = "up" ] ; then
|
||||
|
@ -221,9 +220,8 @@ if swconfig list | grep -q switch0 ; then
|
|||
done
|
||||
else
|
||||
echo "-> PORT ASSIGNMENT"
|
||||
if grep -q "ONE_PORT" "/etc/network.$board_name" || grep -q "ETHPORT" "/etc/network.$board_name" ; then
|
||||
if [ -n "$ONE_PORT" ] || [ -n "$ETHPORT" ] ; then
|
||||
# Device has a port set by $ETHMODE
|
||||
. /etc/network.mode
|
||||
. /etc/network.config
|
||||
echo "Port Modus: $ETHMODE"
|
||||
fi
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#!/usr/bin/haserl
|
||||
|
||||
<%
|
||||
board_name=$(uci -q get board.model.name)
|
||||
|
||||
. /lib/functions/fff/interfaces
|
||||
|
||||
# write
|
||||
if [ "$REQUEST_METHOD" = "POST" ] ; then
|
||||
if [ "$POST_change_mode" != "" ] ; then
|
||||
sed -i '/^.*# set via WebUI/d' /etc/network.config
|
||||
echo "ETHMODE=\"${POST_mode}\" # set via WebUI" >> /etc/network.config
|
||||
sed -i '/^FORCEPARSE/d' /etc/network.config
|
||||
echo "FORCEPARSE='2'" >> /etc/network.config
|
||||
do_reboot=1
|
||||
MSG='<span class="green">Port Modus geändert! Router startet neu...</span>'
|
||||
fi
|
||||
|
@ -16,8 +16,6 @@ if [ "$REQUEST_METHOD" = "POST" ] ; then
|
|||
sed -i '/^.*# set via WebUI/d' /etc/network.config
|
||||
echo "LAN0MODE=\"${POST_mode0}\" # set via WebUI" >> /etc/network.config
|
||||
echo "LAN1MODE=\"${POST_mode1}\" # set via WebUI" >> /etc/network.config
|
||||
sed -i '/^FORCEPARSE/d' /etc/network.config
|
||||
echo "FORCEPARSE='2'" >> /etc/network.config
|
||||
do_reboot=1
|
||||
MSG='<span class="green">Port Modus geändert! Router startet neu...</span>'
|
||||
fi
|
||||
|
@ -92,7 +90,7 @@ format_port() {
|
|||
echo "</td>"
|
||||
echo "<td class=\"swport\" style=\"width:2em\"></td>"
|
||||
|
||||
if [ ! "$(awk -F= '/WANDEV=/ { print $2 }' /etc/network.$board_name)" = "$(awk -F= '/SWITCHDEV=/ { print $2 }' /etc/network.$board_name)" ] ; then
|
||||
if [ ! "$WANDEV" = "$SWITCHDEV" ] ; then
|
||||
wanif=$(uci -q get network.wan.ifname)
|
||||
link=$(cat /sys/class/net/${wanif}/operstate)
|
||||
if [ "$link" = "up" ] ; then
|
||||
|
@ -151,10 +149,9 @@ format_port() {
|
|||
</fieldset>
|
||||
</td></tr>
|
||||
<% fi %>
|
||||
<% if grep -q "ONE_PORT" "/etc/network.$board_name" || grep -q "ETHPORT" "/etc/network.$board_name" ; then %>
|
||||
<% if [ -n "$ONE_PORT" ] || [ -n "$ETHPORT" ] ; then %>
|
||||
<%
|
||||
# Device has a port set by $ETHMODE
|
||||
. /etc/network.mode
|
||||
. /etc/network.config
|
||||
%>
|
||||
<tr><td>
|
||||
|
@ -167,7 +164,7 @@ format_port() {
|
|||
<select name="mode">
|
||||
<option value="BATMAN" <% [ "$ETHMODE" = "BATMAN" ] && echo -n 'selected="selected" ' %>>BATMAN</option>
|
||||
<option value="CLIENT" <% [ "$ETHMODE" = "CLIENT" ] && echo -n 'selected="selected" ' %>>CLIENT</option>
|
||||
<% if grep -q "ONE_PORT" "/etc/network.$board_name" ; then %>
|
||||
<% if [ -n "$ONE_PORT" ] ; then %>
|
||||
<option value="WAN" <% [ "$ETHMODE" = "WAN" ] && echo -n 'selected="selected" ' %>>WAN</option>
|
||||
<% fi %>
|
||||
</select>
|
||||
|
@ -188,10 +185,9 @@ format_port() {
|
|||
</fieldset>
|
||||
</td></tr>
|
||||
<% fi %>
|
||||
<% if grep -q "LAN0PORT" "/etc/network.$board_name" || grep -q "LAN1PORT" "/etc/network.$board_name" ; then %>
|
||||
<% if [ -n "$TWO_PORT" ] ; then %>
|
||||
<%
|
||||
# Device has two ports
|
||||
. /etc/network.mode
|
||||
. /etc/network.config
|
||||
%>
|
||||
<tr><td>
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
. /lib/functions/fff/babel
|
||||
|
||||
#load board specific properties
|
||||
BOARD="$(uci get board.model.name)"
|
||||
. /etc/network.$BOARD
|
||||
. /lib/functions/fff/routermac
|
||||
[ -n "$ROUTERMAC" ] || ROUTERMAC=$(get_mac_label)
|
||||
|
||||
configure() {
|
||||
|
|
|
@ -1,51 +1,81 @@
|
|||
. /lib/functions.sh
|
||||
|
||||
. /lib/functions/fff/wireless
|
||||
|
||||
configure() {
|
||||
# get parameters
|
||||
essid=$(uci -q get gateway.@client[0].essid)
|
||||
chan2ghz=$(uci -q get gateway.@client[0].chan2ghz)
|
||||
chan5ghz=$(uci -q get gateway.@client[0].chan5ghz)
|
||||
add_wifi() {
|
||||
local name="$1"
|
||||
|
||||
if [ -z "$essid" ]; then
|
||||
echo "WARNING: No ESSID set! WiFi AP is disabled"
|
||||
fi
|
||||
# get parameters
|
||||
chan2ghz=$(uci -q get gateway.@client[0].chan2ghz)
|
||||
chan5ghz=$(uci -q get gateway.@client[0].chan5ghz)
|
||||
|
||||
for radio in $(wifiListRadio); do
|
||||
freq="$(wifiGetFreq $radio)"
|
||||
disabled=1
|
||||
|
||||
# Delete wXmesh, wXconfigap
|
||||
uci -q del wireless.w${freq}mesh
|
||||
uci -q del wireless.w${freq}configap
|
||||
|
||||
if [ -n "$essid" ]; then
|
||||
# set channel for 5ghz
|
||||
if [ "$freq" = "5" ]; then
|
||||
if [ -z "$chan5ghz" ]; then
|
||||
echo "WARNING: No 5 GHz channel set! Disabling AP on $radio"
|
||||
else
|
||||
uci set wireless.${radio}.channel="$chan5ghz"
|
||||
disabled=0
|
||||
fi
|
||||
fi
|
||||
|
||||
# set channel for 2.4ghz
|
||||
if [ "$freq" = "2" ]; then
|
||||
if [ -z "$chan2ghz" ]; then
|
||||
echo "WARNING: No 2.4 GHz channel set! Disabling AP on $radio"
|
||||
else
|
||||
uci set wireless.${radio}.channel="$chan2ghz"
|
||||
disabled=0
|
||||
fi
|
||||
fi
|
||||
|
||||
# set essid
|
||||
uci set wireless.w${freq}ap.ssid="$essid"
|
||||
if [ -z "$essid" ]; then
|
||||
echo "WARNING: No ESSID set! WiFi AP is disabled"
|
||||
fi
|
||||
|
||||
# enable or disable ap interface appropriately. The radios 'disabled'-option is not touched
|
||||
uci set wireless.w${freq}ap.disabled="$disabled"
|
||||
done
|
||||
for radio in $(wifiListRadio); do
|
||||
freq="$(wifiGetFreq $radio)"
|
||||
disabled=1
|
||||
|
||||
# Delete wXmesh, wXconfigap
|
||||
uci -q del wireless.w${freq}mesh
|
||||
uci -q del wireless.w${freq}configap
|
||||
|
||||
essid=$(uci -q get gateway.$name.essid)
|
||||
|
||||
if [ -n "$essid" ]; then
|
||||
# set channel for 5ghz
|
||||
if [ "$freq" = "5" ]; then
|
||||
if [ -z "$chan5ghz" ]; then
|
||||
echo "WARNING: No 5 GHz channel set! Disabling AP for interface \"$name\" on $radio"
|
||||
else
|
||||
uci set wireless.${radio}.channel="$chan5ghz"
|
||||
disabled=0
|
||||
fi
|
||||
fi
|
||||
|
||||
# set channel for 2.4ghz
|
||||
if [ "$freq" = "2" ]; then
|
||||
if [ -z "$chan2ghz" ]; then
|
||||
echo "WARNING: No 2.4 GHz channel set! Disabling AP for interface \"$name\" on $radio"
|
||||
else
|
||||
uci set wireless.${radio}.channel="$chan2ghz"
|
||||
disabled=0
|
||||
fi
|
||||
fi
|
||||
|
||||
uci set wireless.w${freq}${name}=wifi-iface
|
||||
uci set wireless.w${freq}${name}.device=$radio
|
||||
uci set wireless.w${freq}${name}.network=$name
|
||||
uci set wireless.w${freq}${name}.ifname=w${freq}${name}
|
||||
uci set wireless.w${freq}${name}.mode=ap
|
||||
uci set wireless.w${freq}${name}.encryption=none
|
||||
uci set wireless.w${freq}${name}.hidden=0
|
||||
|
||||
# set essid
|
||||
uci set wireless.w${freq}${name}.ssid="$essid"
|
||||
uci set wireless.w${freq}${name}.disabled="$disabled"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
remove_wifi() {
|
||||
local name="$1"
|
||||
local netname=$(uci -q get wireless.$name.network)
|
||||
|
||||
# only remove interfaces that disappeared from gwconfig
|
||||
[ "$(uci -q get gateway.$netname)" == "client" ] && return 0
|
||||
|
||||
uci -q del wireless.$name
|
||||
}
|
||||
|
||||
config_load wireless
|
||||
config_foreach remove_wifi wifi-iface
|
||||
|
||||
config_load gateway
|
||||
config_foreach add_wifi client
|
||||
}
|
||||
|
||||
apply() {
|
||||
|
|
Loading…
Reference in New Issue