@@ -13,6 +13,7 @@ define Package/fff-gateway
CATEGORY:=Freifunk
TITLE:= Freifunk-Franken gateway configuration
URL:=https://www.freifunk-franken.de
+ DEPENDS:=+fff-boardname +fff-network
endef
define Package/fff-gateway/description
new file mode 100644
@@ -0,0 +1,44 @@
+# load uci functions
+. /lib/functions.sh
+
+# load CPUPORT
+. /lib/functions/fff/cpuport
+
+
+configure() {
+ add_vlan() {
+ local vlan="$1"
+ local ports="$(uci get gateway.$vlan.ports)"
+ local name="vlan$vlan"
+
+ uci set network.$name='switch_vlan'
+ uci set network.$name.device="$(uci get network.@switch[0].name)"
+ uci set network.$name.vlan="$vlan"
+ uci set network.$name.ports="$CPUPORT $ports"
+ }
+
+ remove_vlan() {
+ local name="$1"
+ local vlan=$(echo $name | sed 's/vlan//')
+
+ # only remove vlans not present in gateway config
+ if ! uci -q get gateway.$vlan > /dev/null; then
+ # remove switch_vlan
+ uci del network.$name
+ fi
+ }
+
+ config_load network
+ config_foreach remove_vlan switch_vlan
+
+ config_load gateway
+ config_foreach add_vlan vlan
+}
+
+apply() {
+ uci commit network
+}
+
+revert() {
+ uci revert network
+}
new file mode 100644
@@ -0,0 +1,71 @@
+configure() {
+ # IPv4 address
+ #remove old ipaddr
+ uci -q del network.mesh.ipaddr
+ #set new ipaddr
+ if ipaddr=$(uci -q get gateway.@client[0].ipaddr); then
+ for ip in $ipaddr; do
+ uci add_list network.mesh.ipaddr=$ip
+ done
+ else
+ echo "WARNING: No client IPv4 address set!"
+ fi
+ #put interface routes from set addresses into fff table
+ uci set network.mesh.ip4table='fff'
+
+ # IPv6 address
+ #remove old ip6addr
+ for ip in $(uci get network.mesh.ip6addr); do
+ if echo "$ip" | grep -q -v -e "^fdff:" -e "fe80::1/64"; then
+ uci del_list network.mesh.ip6addr="$ip"
+ fi
+ done
+ #set new ip6addr
+ if ip6addr=$(uci -q get gateway.@client[0].ip6addr); then
+ for ip in $ip6addr; do
+ uci add_list network.mesh.ip6addr=$ip
+ done
+ else
+ echo "WARNING: No client IPv6 address set!"
+ fi
+ #put interface routes from set addresses into fff table
+ uci set network.mesh.ip6table='fff'
+
+ # dhcp
+ uci -q del dhcp.mesh.start
+ uci -q del dhcp.mesh.limit
+ if dhcp_start=$(uci -q get gateway.@client[0].dhcp_start); then
+ uci set dhcp.mesh=dhcp
+ uci set dhcp.mesh.interface=mesh
+ uci set dhcp.mesh.start=$dhcp_start
+ else
+ echo "WARNING: No DHCP range start set!"
+ fi
+ if dhcp_limit=$(uci -q get gateway.@client[0].dhcp_limit); then
+ uci set dhcp.mesh.limit=$dhcp_limit
+ else
+ echo "WARNING: No DHCP range limit set!"
+ fi
+
+ # set interface
+ #Just replace existing eth0.x or ethX assigned to mesh.ifname
+ if vlan=$(uci -q get gateway.@client[0].vlan); then
+ newmesh="$(uci get network.mesh.ifname | sed "s/\(eth\d\.\)\d/\1$vlan/g")"
+ uci set network.mesh.ifname="$newmesh"
+ elif iface=$(uci -q get gateway.@client[0].iface); then
+ newmesh="$(uci get network.mesh.ifname | sed "s/eth[^ ]*/$iface/g")"
+ uci set network.mesh.ifname="$newmesh"
+ else
+ echo "WARNING: No interface for client specified!"
+ fi
+}
+
+apply() {
+ uci commit network
+ uci commit dhcp
+}
+
+revert() {
+ uci revert network
+ uci revert dhcp
+}
new file mode 100644
@@ -0,0 +1,5 @@
+# Enable forwarding
+net.ipv4.conf.all.forwarding=1
+net.ipv4.ip_forward=1
+net.ipv6.conf.all.forwarding=1
+net.ipv6.conf.default.forwarding=1