. /etc/sysconfig/rc
. ${rc_functions}
+. /etc/rc.d/init.d/lib-freifunk
+
eval $(/usr/local/bin/readhash /var/ipfire/ppp/settings)
eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
eval $(/usr/local/bin/readhash /var/ipfire/optionsfw/settings)
iptables -t nat -N CUSTOMPOSTROUTING
iptables -t nat -A POSTROUTING -j CUSTOMPOSTROUTING
+ # Freifunk
+ iptables -N FREIFUNK
+ iptables -A FORWARD -j FREIFUNK
+
# P2PBLOCK
iptables -N P2PBLOCK
iptables -A INPUT -j P2PBLOCK
# Install firewall rules for the red interface.
iptables_red_up
+ # Install firewall rules for Freifunk
+ freifunk_init_firewall
+
# If red has not been brought up yet, we will
# add the blocking rules for MASQUERADE
if [ ! -e "/var/ipfire/red/active" ]; then
}
function freifunk_start() {
+ freifunk_flush_firewall
+
# Do nothing if Freifunk is not enabled
freifunk_is_enabled || exit 0
+ # Initialize firewall rules
+ freifunk_init_firewall
+
# Bring up the batman interface
freifunk_batman_create
freifunk_batman_attach_all
}
function freifunk_stop() {
+ freifunk_flush_firewall
+
/etc/init.d/alfred stop &>/dev/null
ip link set "${BATMAN_INTERFACE}" down &>/dev/null
done
}
+function freifunk_init_firewall() {
+ # Flush the existing configuration
+ freifunk_flush_firewall
+
+ # Forward everything incoming and outgoing on the
+ # BATMAN interface without further noticing.
+ iptables -A FREIFUNK -i bat+ -j ACCEPT
+ iptables -A FREIFUNK -o bat+ -j ACCEPT
+
+ # Also make the mesh bridge transparent for IPv4
+ iptables -A FREIFUNK -i meshbr+ -j ACCEPT
+ iptables -A FREIFUNK -o meshbr+ -j ACCEPT
+
+ # Forward all packets from and to the local interfaces
+ local mesh
+ for mesh in FREIFUNK1 FREIFUNK2 FREIFUNK3 FREIFUNK4; do
+ local interface_var="${mesh}_DEV"
+ local interface="${!interface_var}"
+
+ [ -n "${interface}" ] || continue
+
+ iptables -A FREIFUNK -i "${interface}" -j ACCEPT
+ iptables -A FREIFUNK -o "${interface}" -j ACCEPT
+ done
+}
+
+function freifunk_flush_firewall() {
+ # Flush all existing rules
+ iptables -F FREIFUNK
+}
+
function freifunk_ipv6_enable() {
local device="${1}"