From 3ffbdf95402e827188a03d9efe23dae68b1ed44d Mon Sep 17 00:00:00 2001 From: Matthias Strubel Date: Fri, 4 Oct 2013 16:05:50 +0200 Subject: [PATCH 1/4] Changed configuration to include batman interface to br-lan --- Makefile | 2 +- src/data/etc/mesh.config | 14 +++- src/data/usr/share/mesh/mesh.common | 119 ++++++++++++++++++---------- 3 files changed, 86 insertions(+), 49 deletions(-) diff --git a/Makefile b/Makefile index e48e156..997b274 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ NAME = piratebox-mesh -VERSION = 0.3.0 +VERSION = 1.0.2 ARCH = all IPK = $(NAME)_$(VERSION)_$(ARCH).ipk IPKDIR = src diff --git a/src/data/etc/mesh.config b/src/data/etc/mesh.config index d6faf77..a4caf6c 100644 --- a/src/data/etc/mesh.config +++ b/src/data/etc/mesh.config @@ -17,7 +17,7 @@ MESH_IF=mesh0 MESH_CHANNEL=0 # Mesh-SSID MESH_SSID="PB-Mesh" -# Needed MTU for B.A.T.M.A.N. +# Needed MTU on Wifi-Interface for B.A.T.M.A.N. MTU_NEEDED=1528 # Change this to 2nd card, if needed IW_DEVICE=phy0 @@ -50,7 +50,7 @@ IPV6_FIXED="" ####-------- # Extracts the fe80 address and adds an choosen prefix #### -SET_GENERATED_IPV6="yes" +SET_GENERATED_IPV6="no" #used for mesh if IPV6_GEN_PREFIX="fdc0:ffea" #Enter without / @@ -59,7 +59,7 @@ IPV6_GEN_NETMASK="48" #--------------------------------------------- # IPV4 Stuff -SET_IPV4="yes" +SET_IPV4="no" # Do you want to choose your IP? IPV4_FIXED="" IPV4_SUBNET_MASK="255.0.0.0" @@ -68,8 +68,14 @@ IPV4_SUBNET_MASK="255.0.0.0" IPV4_GENERATE="no" #Load from file or openWRT config (if openwrt) -IPV4_LOAD="yes" +IPV4_LOAD="no" IPV4_IP_SAVE=/etc/mesh_ipv4.cfg +#--------------------------------------------- +# Bridging options +### Should the BATMAN interface included to some available(!) bridge-devices +ADD_BRIDGE="yes" +BRIDGE_NAME="br-lan" + #----- Configuration END diff --git a/src/data/usr/share/mesh/mesh.common b/src/data/usr/share/mesh/mesh.common index f737a50..2b18b6e 100755 --- a/src/data/usr/share/mesh/mesh.common +++ b/src/data/usr/share/mesh/mesh.common @@ -108,6 +108,30 @@ modify_MAC() { fi } + +do_bridge_add(){ + echo "Adding $BAT_IF to bridge $BRIDGE_NAME " + brctl addif "$BRIDGE_NAME" "$BAT_IF" + check_rc $? + + ## If we are working in a bridge, disable ipv6 on that device, too + # Only disable, if IPV6 exists on device + if [ -e "/proc/sys/net/ipv6/conf/$BAT_IF/disable_ipv6" ] ; then + echo "Disabling IPV6 for $BAT_IF - IF without any configuration!" + echo "1" > /proc/sys/net/ipv6/conf/$BAT_IF/disable_ipv6 + check_rc $? + fi + +} + +do_bridge_remove() { + echo "Removing $BAT_IF from bridge $BRIDGE_NAME " + brctl delif "$BRIDGE_NAME" "$BAT_IF" + +} + + + do_wlan_if_up() { echo "Setting up AdHoc Interface for B.A.T.M.A.N. " iw $IW_DEVICE interface add $MESH_IF type adhoc @@ -203,7 +227,7 @@ do_batman_up() { fi #Load if not OpenWRt from dataset - [ "$OPENWRT" = "yes" ] && load_gen_ipv4 + [ "$IPV4_LOAD" = "yes" ] && load_gen_ipv4 if [ "$SET_IPV4" = "yes" ] ; then echo "Setting up ipv4 address ->$IPV4_FIXED<- on $BAT_IF" @@ -264,15 +288,18 @@ build_mesh() { echo "Starting Mesh Network with uci-collect..." [ "$OPENWRT" = "yes" ] && echo "Starting Mesh Network with uci-collect..." \ && uci_get_details - [ "$EXCHANGE_MAC" = "yes" ] && modify_MAC + # Run Modify_MAC always because severall Variables are shifted internally + modify_MAC do_wlan_if_up mesh_start do_batman_up + [ "$ADD_BRIDGE" = "yes" ] && do_bridge_add echo "finished" } destroy_mesh() { echo "Stopping Mesh Network..." + [ "$ADD_BRIDGE" = "yes" ] && do_bridge_remove mesh_stop do_batman_down do_wlan_if_down @@ -281,49 +308,53 @@ destroy_mesh() { openwrt_postinst() { - echo "Generating IPv4 ..." - generate_ipv4 - save_gen_ipv4 - echo "Generated $IPV4_FIXED for this box!" - - echo "Backuping /etc/config/network" - cp -v /etc/config/network /etc/config/network_pre_mesh.backup - echo "Backuping /etc/config/firewall" - cp -v /etc/config/firewall /etc/config/firewall_pre_mesh.backup - - echo "Do interface $OPENWRT_NETWORK setup on /etc/config/network" - uci set network.$OPENWRT_NETWORK=interface - uci set network.$OPENWRT_NETWORK.ipaddr=$IPV4_FIXED - uci set network.$OPENWRT_NETWORK.netmask=$IPV4_SUBNET_MASK - uci set network.$OPENWRT_NETWORK.proto=static - uci set network.$OPENWRT_NETWORK.ifname=$BAT_IF - uci commit - - echo "Do firewall configuration /etc/config/firewall" - - #Enable Forward on lan zone. Lan zone is always the first - # in MR3020 - echo " ... enabling forward on lan" - uci set firewall.@zone[0].forward=ACCEPT - - echo " ... inserting new zone $OPENWRT_NETWORK" - uci add firewall zone - uci set firewall.@zone[-1].name=$OPENWRT_NETWORK - uci set firewall.@zone[-1].masq=1 - uci set firewall.@zone[-1].mtu_fix=1 - uci set firewall.@zone[-1].input=ACCEPT - uci set firewall.@zone[-1].output=ACCEPT - uci set firewall.@zone[-1].forward=REJECT - - echo " ... adding new forward-rule" - uci add firewall forwarding - uci set firewall.@forwarding[-1].src=lan - uci set firewall.@forwarding[-1].dest=$OPENWRT_NETWORK - - uci commit + + if [ "$SET_IPV4" = "yes" ] ; then + echo "Generating IPv4 ..." + generate_ipv4 + save_gen_ipv4 + echo "Generated $IPV4_FIXED for this box!" + + echo "Backuping /etc/config/network" + cp -v /etc/config/network /etc/config/network_pre_mesh.backup + echo "Backuping /etc/config/firewall" + cp -v /etc/config/firewall /etc/config/firewall_pre_mesh.backup + + echo "Do interface $OPENWRT_NETWORK setup on /etc/config/network" + uci set network.$OPENWRT_NETWORK=interface + uci set network.$OPENWRT_NETWORK.ipaddr=$IPV4_FIXED + uci set network.$OPENWRT_NETWORK.netmask=$IPV4_SUBNET_MASK + uci set network.$OPENWRT_NETWORK.proto=static + uci set network.$OPENWRT_NETWORK.ifname=$BAT_IF + uci commit + + echo "Do firewall configuration /etc/config/firewall" + + #Enable Forward on lan zone. Lan zone is always the first + # in MR3020 + echo " ... enabling forward on lan" + uci set firewall.@zone[0].forward=ACCEPT + + echo " ... inserting new zone $OPENWRT_NETWORK" + uci add firewall zone + uci set firewall.@zone[-1].name=$OPENWRT_NETWORK + uci set firewall.@zone[-1].masq=1 + uci set firewall.@zone[-1].mtu_fix=1 + uci set firewall.@zone[-1].input=ACCEPT + uci set firewall.@zone[-1].output=ACCEPT + uci set firewall.@zone[-1].forward=REJECT + + echo " ... adding new forward-rule" + uci add firewall forwarding + uci set firewall.@forwarding[-1].src=lan + uci set firewall.@forwarding[-1].dest=$OPENWRT_NETWORK + + uci commit - echo "Reloading Firewall" - /etc/init.d/firewall reload + echo "Reloading Firewall" + /etc/init.d/firewall reload + + fi } From 637af64163480ef74cf70a2b9d3b8a9464f297d6 Mon Sep 17 00:00:00 2001 From: Matthias Strubel Date: Wed, 9 Oct 2013 12:34:35 +0200 Subject: [PATCH 2/4] impementing one_net stuff including supressed dhcp broadcast via gw mode --- Makefile | 4 ++-- src/control/control | 2 +- src/data/etc/mesh.config | 4 ++++ src/data/usr/share/mesh/mesh.common | 4 ++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 997b274..8bee79a 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ NAME = piratebox-mesh -VERSION = 1.0.2 +VERSION = 1.1.1 ARCH = all IPK = $(NAME)_$(VERSION)_$(ARCH).ipk IPKDIR = src @@ -20,7 +20,7 @@ data: $(IPKDIR)/data.tar.gz $(IPKPSDIR)/data.tar.gz $(IPK): $(IPKDIR)/control.tar.gz $(IPKDIR)/data.tar.gz $(IPKDIR)/control $(IPKDIR)/data - tar czf $@ -C $(IPKDIR) control.tar.gz data.tar.gz debian-binary + tar czf $@ -C $(IPKDIR) ./control.tar.gz ./data.tar.gz debian-binary all: $(IPK) $(NON_WRT) diff --git a/src/control/control b/src/control/control index 33853c0..753893d 100644 --- a/src/control/control +++ b/src/control/control @@ -1,5 +1,5 @@ Package: piratebox-mesh -Version: 0.2.8 +Version: 1.1.1 Depends: kmod-batman-adv wireless-tools Provides: Source: package/piratebox-mesh diff --git a/src/data/etc/mesh.config b/src/data/etc/mesh.config index a4caf6c..000c1a4 100644 --- a/src/data/etc/mesh.config +++ b/src/data/etc/mesh.config @@ -40,6 +40,10 @@ DISABLE_RTS="yes" BAT_IF=bat0 # Increase lookup Frequency to 5s BAT_INT=5000 +# Gateway mode ( off ; client ; server ) +# for NODE only (not be a PirateBox-AP at the same time), choose client +# that will stick the client to the next PBx (hopefully) +BAT_GW=server #------------------------------------------- # SET Ipv6 Stuff diff --git a/src/data/usr/share/mesh/mesh.common b/src/data/usr/share/mesh/mesh.common index 2b18b6e..a5fadd5 100755 --- a/src/data/usr/share/mesh/mesh.common +++ b/src/data/usr/share/mesh/mesh.common @@ -234,6 +234,10 @@ do_batman_up() { ifconfig "$BAT_IF" $IPV4_FIXED netmask $IPV4_SUBNET_MASK check_rc $? fi + + echo "Setting up GatewayMode to $BAT_GW" + batctl gw $BAT_GW + check_rc $? } mesh_start() { From 2c505c98a327fdecc2784cd89f4c5ed37e9b3b2d Mon Sep 17 00:00:00 2001 From: Matthias Strubel Date: Sat, 12 Jul 2014 18:11:14 +0200 Subject: [PATCH 3/4] cleanup old mesh packages --- piratebox-mesh_0.1_all.ipk | Bin 2581 -> 0 bytes piratebox-mesh_0.2.4_all.ipk | Bin 6800 -> 0 bytes piratebox-mesh_0.2.4_all_NON_WRT.sh | 446 --------------------------- piratebox-mesh_0.2.5_all.ipk | Bin 4656 -> 0 bytes piratebox-mesh_0.2.5_all_NON_WRT.sh | 448 ---------------------------- 5 files changed, 894 deletions(-) delete mode 100644 piratebox-mesh_0.1_all.ipk delete mode 100644 piratebox-mesh_0.2.4_all.ipk delete mode 100644 piratebox-mesh_0.2.4_all_NON_WRT.sh delete mode 100644 piratebox-mesh_0.2.5_all.ipk delete mode 100644 piratebox-mesh_0.2.5_all_NON_WRT.sh diff --git a/piratebox-mesh_0.1_all.ipk b/piratebox-mesh_0.1_all.ipk deleted file mode 100644 index c03efaac072e502a4d249930bea954e75c603707..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2581 zcmV+w3hMPAiwFSL2!l@m1MSy$P!q@=2k_8~G-($JT?9l3Nk~9yKu{1N2m(rz7Q_f4 z9H2;z5T%0(!Vwe#CryF~f`p<}31Cp<=taT<1(DFJNaT5M=FQx@Ki>Uu&%1du`TVi_ z$L`GT&dzt|x8AsbkRY5tIK(pu>>CdFE+F4%!{NX7P#py1xBb89K(qi*s16*W4S{RH zv;hz(Oa}@B$V0x*cK*}V;BQBlmj_@yL&AOj%e+4t|34*{%nKOeCD;Hs7W-}e#vvjA z59Gr63E^xB@(48BcC5;9L*e06Rp@9FRk0Rbc&>VL*d`zc%0HfW;!vZoC?TX?f8MLU z8(d-Wsmz&FR*~dR@+I0`b+R9~!#X&YPM1A@mEREQ=OoF25x(;}CvQdgNBsD{dAIel zdYFz|B~@<<>-6>7*Q>V8In85^YJ}-nL*@plcmLux&x=lO$r*&_T+;`wINQjRaw*k< z;&zF*>+)qzaKw)ahLvE3w1?XdCqyjEzP^DuQv=?Owhnn!7nWJsk(VdttkjoYoEXkDFWq6ZPP9aUDpVRLP}XO%}Be}TpjP~11EDzYKoIK-xh3N(nT;uMW$-F zh2Ic}Kk>~yvu=zRUUQ7T+ql7WY70kzbJgCB^<~`Dk8Sn5(8~*zf1BW;9@1yUQMkR_ z%J6O|w?F!vAQTZL#2-!#J}rm6{w7D;AZ1M0eDPd%u;@#d{ZycL3Y7Z0W(4$^?Kq>^ z6rlPi?;q_M;`v>}5BS6UYazac{df6?ew)t9|6kxY`M(emJa$TCo4zX!B6j;F8IQyc z$fPR(ReCrXP}DEP8XxpLB!^e#E=sv(K6H60R|y52>*Eg9^D!itg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XbUu$c#cbCR_hIlPEKda*ZsB@=~UlUh?wyH$b-MpNF zSpg*q_hpEGJx{}~1tQGS&aW6)Dxerv+@e1RjUJS5?48nRWQs_N$ORJZDL%;3D3uRJhl?EXy5JYP&}*LbX8 z9t2ud+l9p%Hg!fC5g$>vLOVmX2%Myn7$#15P7Zv}PiobjzKvaarHpz~J~xWCrjLnN z?@4vBA>NoY-lRA}ZBNYuxo5;r_6k^O;r%FvDPG)a#CUUPUW`r)FJ>?taa5#s)b;jn zWh1Fyb)@?uCaV2j`&&*(MLK8|%y)Ko_liO%!`s7D{D>hg-&K!tZMq}9#MUoRI__7u zRbK3i!u><7j+F1R!sw4;?uf%H;`$#}CpML{vq1yETC;$L>#Z`F# diff --git a/piratebox-mesh_0.2.4_all_NON_WRT.sh b/piratebox-mesh_0.2.4_all_NON_WRT.sh deleted file mode 100644 index 4db37f8..0000000 --- a/piratebox-mesh_0.2.4_all_NON_WRT.sh +++ /dev/null @@ -1,446 +0,0 @@ -#!/bin/sh - -#------------------------------------ -# Configuration for piratebox-mesh -#------------------------------------ - -RADIODEVICE=radio0 -OPENWRT=no -OPENWRT_NETWORK="meshwork" -# Interface for normal AP Mode -AP_IF=wlan0 -# Interface for MESH -MESH_IF=mesh0 -# Channel -# If 0 it will use the same channel as configured -# in /etc/config/wireless -> RADIODEVICE -MESH_CHANNEL=0 -# Mesh-SSID -MESH_SSID="PB-Mesh" -# Needed MTU for B.A.T.M.A.N. -MTU_NEEDED=1528 -# Change this to 2nd card, if needed -IW_DEVICE=phy0 -# Source MAC Adress.. If non WRT should be filled -SOURCEMAC="" -# Modified MAC -# if empty, it will exchange a few letters for itself -MODMAC="" -# Needed for 2nd device comming up -EXCHANGE_MAC="yes" - -#Fixed BSSID to avoid cell splitting -CUSTOM_BSSID="12:CA:FF:EE:BA:BA" - -#Disable RTS/CTS -DISABLE_RTS="yes" - -#### -# BATMAN stuff -BAT_IF=bat0 -# Increase lookup Frequency to 5s -BAT_INT=5000 - -#------------------------------------------- -# SET Ipv6 Stuff -SET_IPV6="no" -# Do you want a fixed address? -IPV6_FIXED="" - -####-------- -# Extracts the fe80 address and adds an choosen prefix -#### -SET_GENERATED_IPV6="yes" -#used for mesh if -IPV6_GEN_PREFIX="fdc0:ffea" -#Enter without / -IPV6_GEN_NETMASK="48" -#--------------------------------------------- - -#--------------------------------------------- -# IPV4 Stuff -SET_IPV4="yes" -# Do you want to choose your IP? -IPV4_FIXED="" -IPV4_SUBNET_MASK="255.0.0.0" - -# Generates a 10.x.y.z IP Adress -IPV4_GENERATE="no" - -#Load from file or openWRT config (if openwrt) -IPV4_LOAD="yes" - -IPV4_IP_SAVE=/etc/mesh_ipv4.cfg - -#----- Configuration END - -#-------- Common Functiond -BATCTL_FOUND="yes" -V6_GEN_RESULT="" - -check_rc() { - MSG="" - if [ -n "$2" ] ; then - MSG="Error in $2" - else - MSG="Failed with RC $1" - fi - [ "$1" != "0" ] && echo $MSG && exit 255 -} - - -uci_get_details() { - #get mac Adress from uci - SOURCEMAC=$(uci get wireless.$RADIODEVICE.macaddr) - check_rc $? "getting SourceMac" - [[ $MESH_CHANNEL = "0" ]] && MESH_CHANNEL=$( uci get wireless.$RADIODEVICE.channel) - check_rc $? "getting Channel" - - if [ "$IPV4_LOAD" = "yes" ] ; then - $IPV4_FIXED=$(uci get network.$OPENWRT_NETWORK.ipaddr) - check_rc $? "getting IPv4 from openwrt config" - fi -} - -generate_v6() { - IF=$1 - PREFIX="fd00" - - test -n "$2" && PREFIX=$2 - - CURRENT_GEN=`ifconfig $IF | - grep "inet6 addr: fe80" | - sed -n "s|^.*::\([^/]*\)/.*|\1|p" | - tr -d ":"` - - FIXED=`echo ${CURRENT_GEN} | tr -d "\012" | - sed "s|\(....\)\(....\)\(....\)\(....\)|\1:\2:\3:\4|"` - - echo "Extracted for $IF : $PREFIX::$FIXED " - V6_GEN_RESULT="$PREFIX::$FIXED" -} - - -RANDOM_NUM=0 -random_num() { - NUM=$((` "254" ]] && NUM=$(($NUM / 7)) - RANDOM_NUM=$NUM -} - -RANDOM_IP_NUM=0 -random_ip_num() { - #Repeat until IP is in range - RANDOM_IP_NUM=0 - RANDOM_NUM=0 - until [[ "$RANDOM_NUM" -gt "000" ]] && [[ $RANDOM_NUM -lt "255" ]] - do - random_num - [[ 1 == 2 ]] && echo "Result random_num $RANDOM_NUM" - done - RANDOM_IP_NUM=$RANDOM_NUM - - [[ 1 == 2 ]] && echo "result random_ip_num $RANDOM_IP_NUM" -} - - -generate_ipv4() { - # 10.x.y.z - x=0 - y=0 - z=0 - - random_ip_num - x=$RANDOM_IP_NUM - random_ip_num - y=$RANDOM_IP_NUM - random_ip_num - z=$RANDOM_IP_NUM - - IPV4_FIXED="10.$x.$y.$z" -} - -modify_MAC() { - # Modify MAC for 2nd interface if not set - #Change two letters - if [ "$MODMAC" = "" ] ; then - MODMAC=$( echo $SOURCEMAC | sed 's/c/a/' | sed 's/1/2/' ) - check_rc $? "sed :( " - echo "Found MAC for $RADIODEVICE : $SOURCEMAC" - echo " modified for 2nd Wifi-if : $MODMAC" - fi -} - -do_wlan_if_up() { - echo "Setting up AdHoc Interface for B.A.T.M.A.N. " - iw $IW_DEVICE interface add $MESH_IF type adhoc - check_rc $? - - echo "Setting fixed BSSID up" - iwconfig $MESH_IF ap $CUSTOM_BSSID - check_rc $? - - if [ "$DISABLE_RTS" = "yes" ] ; then - echo "Disabling RTS/CTS " - iwconfig $MESH_IF rts off - check_rc $? - fi - - echo "Increasing MTU for $MESH_IF to $MTU_NEEDED" - ifconfig $MESH_IF mtu $MTU_NEEDED - check_rc $? - - # Only disable, if IPV6 exists on device - if [ -e "/proc/sys/net/ipv6/conf/$MESH_IF/disable_ipv6" ] ; then - echo "Disabling IPV6 for $MESH_IF - IF without any configuration!" - echo "1" > /proc/sys/net/ipv6/conf/$MESH_IF/disable_ipv6 - check_rc $? - fi - - if [ "$EXCHANGE_MAC" = "yes" ] ; then - echo "Changing $MESH_IF MAC to $MODMAC" - ifconfig $MESH_IF hw ether $MODMAC - check_rc $? - fi - - echo "Setting up Channel $MESH_CHANNEL" - iwconfig $MESH_IF channel $MESH_CHANNEL - check_rc $? - - echo "Setting SSID for Mesh $MESH_SSID" - iwconfig $MESH_IF essid $MESH_SSID - check_rc $? -} - - -save_gen_ipv4() { - #Save IPv4 Address to tmp-space for later use - echo "$IPV4_FIXED" > $IPV4_IP_SAVE -} - -load_gen_ipv4() { - IPV4_FIXED=$(cat $IPV4_IP_SAVE) -} - -do_batman_up() { - if [ "$BATCTL_FOUND" = "yes" ] ; then - echo "Adding $MESH_IF to B.A.T.M.A.N." - batctl if add $MESH_IF - check_rc $? - else - echo "Adding $MESH_IF to B.A.T.M.A.N. via /sys/class/ " - echo "$BAT_IF" > /sys/class/net/$MESH_IF/batman_adv/mesh_iface - check_rc $? - fi - - echo "Starting $BAT_IF" - ifconfig $BAT_IF 0.0.0.0 up - check_rc $? - - if [ "$BATCTL_FOUND" = "yes" ] ; then - echo "Setting B.A.T.M.A.N. Intervall to $BAT_INT " - batctl it $BAT_INT - check_rc $? - else - echo "Setting B.A.T.M.A.N. Intervall via /sys/class/ to $BAT_INT " - echo "$BAT_INT" > /sys/class/net/$BAT_IF/mesh/orig_interval - check_rc $? - fi - - if [ "$SET_GENERATED_IPV6" = "yes" ] ; then - echo "Generating IPv6 address for $BAT_IF" - generate_v6 $BAT_IF $IPV6_GEN_PREFIX - check_rc $? - IPV6_FIXED="$V6_GEN_RESULT"/"$IPV6_GEN_NETMASK" - fi - - if [ "$SET_IPV6" = "yes" ] ; then - echo "Setting up ipv6 address ->$IPV6_FIXED<- on $BAT_IF" - ifconfig "$BAT_IF" add $IPV6_FIXED - check_rc $? - fi - - if [ "$IPV4_GENERATE" = "yes" ] ; then - echo "Generating IPv4 10.x.y.z address for $BAT_IF " - generate_ipv4 - fi - - if [ "$IPV4_LOAD" = "yes" ] ; then - load_gen_ipv4 - fi - - if [ "$SET_IPV4" = "yes" ] ; then - echo "Setting up ipv4 address ->$IPV4_FIXED<- on $BAT_IF" - ifconfig "$BAT_IF" add $IPV4_FIXED netmask $IPV4_SUBNET_MASK - check_rc $? - fi -} - -mesh_start() { - echo "Starting Mesh-IF!" - ifconfig $MESH_IF 0.0.0.0 up - check_rc $? - -# Extract auto IPV6 adress and remove it from mesh if -# AUTO_IPV6=$( ifconfig $MESH_IF | grep "inet6.* " | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//" ) -# echo "Removing .. $AUTO_IPV6 from $MESH_IF" -# ifconfig $MESH_IF inet6 del $AUTO_IPV6 -# check_rc $? "resetting IPv6 on $MESH_IF" - -} - -mesh_stop() { - echo "Stopping Mesh if!" - ifconfig $MESH_IF down -} - -do_wlan_if_down() { - echo "Cleaning up interfaces" - iw dev $MESH_IF del -} - -do_batman_down() { - if [ "$BATCTL_FOUND" = "yes" ] ; then - echo "Remove $MESH_IF from $BAT_IF " - batctl if del $MESH_IF - else - echo "Remove $MESH_IF from $BAT_IF via /sys/class/" - echo none > /sys/class/net/$MESH_IF/batman_adv/mesh_iface - fi -} - -check_requirements() { - lsmod | grep batman >> /dev/null - if [ "$?" != "0" ] ; then - modprobe batman-adv - check_rc $? "Loading kernel module batman-adv failed.. maybe not installed?" - fi - batctl if > /dev/null - if [ $? != "0" ] ; then - echo "Failed running batctl- maybe not installed? " - echo "Try to use /sys/class/" - BATCTL_FOUND='no' - fi -} - -build_mesh() { - check_requirements - echo "Starting Mesh Network with uci-collect..." - [ "$OPENWRT" = "yes" ] && echo "Starting Mesh Network with uci-collect..." \ - && uci_get_details - modify_MAC - do_wlan_if_up - mesh_start - do_batman_up - echo "finished" -} - -destroy_mesh() { - echo "Stopping Mesh Network..." - mesh_stop - do_batman_down - do_wlan_if_down - echo "finished" -} - - -openwrt_postinst() { - echo "Generating IPv4 ..." - generate_ipv4 - save_gen_ipv4 - echo "Generated $IPV4_FIXED for this box!" - - echo "Backuping /etc/config/network" - cp -v /etc/config/network /etc/config/network_pre_mesh.backup - echo "Backuping /etc/config/firewall" - cp -v /etc/config/firewall /etc/config/firewall_pre_mesh.backup - - echo "Do interface $OPENWRT_NETWORK setup on /etc/config/network" - uci set network.$OPENWRT_NETWORK=interface - uci set network.$OPENWRT_NETWORK.ipaddr=$IPV4_FIXED - uci set network.$OPENWRT_NETWORK.netmask=$IPV4_SUBNET_MASK - uci set network.$OPENWRT_NETWORK.proto=static - uci set network.$OPENWRT_NETWORK.ifname=$BAT_IF - uci commit - - echo "Do firewall configuration /etc/config/firewall" - - #Enable Forward on lan zone. Lan zone is always the first - # in MR3020 - echo " ... enabling forward on lan" - uci set firewall.@zone[0].forward=ACCEPT - - echo " ... inserting new zone $OPENWRT_NETWORK" - uci add firewall zone - uci set firewall.@zone[-1].name=$OPENWRT_NETWORK - uci set firewall.@zone[-1].masq=1 - uci set firewall.@zone[-1].mtu_fix=1 - uci set firewall.@zone[-1].input=ACCEPT - uci set firewall.@zone[-1].output=ACCEPT - uci set firewall.@zone[-1].forward=REJECT - - echo " ... adding new forward-rule" - uci add firewall forwarding - uci set firewall.@forwarding[-1].src=lan - uci set firewall.@forwarding[-1].dest=$OPENWRT_NETWORK - - uci commit - -} - -openwrt_preremove() { - if [ -f /etc/config/network_pre_mesh.backup ] ; then - echo "Saving current state of config/network" - mv /etc/config/network /etc/config/network_after_mesh.backup - echo "Restoring config/network" - mv /etc/config/network_pre_mesh.backup /etc/config/network - fi - - if [ -f /etc/config/firewall_pre_mesh.backup ] ; then - echo "Saving current state of config/firewall" - mv /etc/config/firewall /etc/config/firewall_after_mesh.backup - echo "Restoring config/firewall" - mv /etc/config/firewall_pre_mesh.backup /etc/config/firewall - fi -} - -## mesh.common END - - -# ----piece_start_stop Start -# -- Stuff will be added on Make - -check_config() { - if [ "$MESH_CHANNEL" = "0" ] ; then - echo "Please set option MESH_CHANNEL" - exit 255 - elif [ "$SOURCEMAC" = "$MODMAC" ] ; then - echo "Please set option SOURCEMAC to the MAC Address of you wifi device" - ifconfig wlan0 || ifconfig - echo "Please set option SOURCEMAC to the MAC Address of you wifi device" - echo " or enter a modified one in MODMAC and set EXCHANGE_MAC=no " - exit 255 - fi -} - - -# Start Stop stuff for running in script directly -if [ "$1" = "start" ] ; then - check_config - build_mesh -elif [ "$1" = "stop" ] ; then - destroy_mesh -elif [ "$1" = "restart" ] ; then - destroy_mesh - check_config - build_mesh -elif [ "$1" = "test_gen" ] ; then - generate_ipv4 - echo "Generated IPv4: $IPV4_FIXED" -else - echo "valid options are start|stop|restart" - exit 255 -fi -# ----piece_start_stop End - - diff --git a/piratebox-mesh_0.2.5_all.ipk b/piratebox-mesh_0.2.5_all.ipk deleted file mode 100644 index ee2456259426b4e5c1e1fcb348ead41f5fb340cc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4656 zcmV-063^`)iwFQ1e;-f)1MS#%Fr00_2k=#5MG(C{N_4C3YKyE+LsLIE$*)8>?euc$qalnnKQUUppow`RZr%Y+rUWU~~7A_r}F1 zbjRP6j(Ee2jdep6lI^vOXM(I42Aq*4b>8olUz|rI!{Z{%=YAiCjnIiYg$68_O0pjbOzX!*wx2_q&apLX`@d%qnvPKbQ+ zc~e-~yJ3T%UUo}XMs!_g?zEigE?;ZMjT*A6+4}pS8l0;0JriKwZ|+Pt_fIQ`KAu@k z?D+4yz!2a#GS+K4sjBahMSqMa^KxnjQeY7Hx>Kb4q=+f+TjPaj*9Yx@&pYc26Y@t%C_jfG2|0BJ0(`l;3)M zL@*>PSz}6>>Z$AIr8ScpMWrI_s?j|I9VQ0E^WQKlJ4%i#+Ef!ix<=2#dah=&14cuJ z^5*diI`U_DRLlA$p1(aLeQt2G{ymMi&I5(2a+uB+0Tw$>-oynfuW7UIxugs$!X_pI z$KJjj3SF&KcKh8jukG8KB4^bs{ZCO`e5-_(}@K5>A>h_F9EX{eqcNer`20x$ZVQJl6`XYlq1B_sRSW#x3GJ;$!(U?b4#;L@A_ri8pTE{N z^UGa1u&?~%`O}{97IM{)rlC4`qmgogOf);2t`X5xxxf#R4U zj^tN(m$J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=2HX`LgxJYkt+mm$AG<+UZL_@H+Bw_{w|KiKt8qagXNdKj zYi`=VLq}1)YjKBuO3vF*>TS?i9%!1N)pf4r>41;hnxdy0CNA|UK)9O8OwiI@T)Tv& z(zk37%3rj43(H`pY?H%UBjcMO>!#@>=Jd1aoASNV8aeUfq(C|?=7PPS{@a#wZPKuK zwWJb)CMI#o=VJIm!X`+YbjGiN#@*lTKAOh+SDsxKB16I{yntu+mX2?G-afMEkHm>_ z{VcmMeT}a4Ll)(&WrN~rL{e^ceL=hR7+Kw;4$!&@hhXEvBY|p;?4IH(kpl(g42R@ZYJb=rb zXkX&jwz{(?qYULQX!X6np;RV3zS{%I7j#Mh%WovKx&#wtaWVpWLU7<7B-K?zwxCo= z7kZG`63H6}Bhkwo!yJNXh)f|w{$!|-I49X;&#^(edjP|#gy3yuDGz`gsc2e3}G3g@KR_k`pHt`zaF9cIBPhw z{ab+k-~A*0H?eoHbFuXhv2*dT^?vaeo$+t_KYx-0Kp;>_uryd)3Jm#2|3?ZUb>08@ mzaTCOCi}Z RADIODEVICE -MESH_CHANNEL=0 -# Mesh-SSID -MESH_SSID="PB-Mesh" -# Needed MTU for B.A.T.M.A.N. -MTU_NEEDED=1528 -# Change this to 2nd card, if needed -IW_DEVICE=phy0 -# Source MAC Adress.. If non WRT should be filled -SOURCEMAC="" -# Modified MAC -# if empty, it will exchange a few letters for itself -MODMAC="" -# Needed for 2nd device comming up -EXCHANGE_MAC="yes" - -#Fixed BSSID to avoid cell splitting -CUSTOM_BSSID="12:CA:FF:EE:BA:BA" - -#Disable RTS/CTS -DISABLE_RTS="yes" - -#### -# BATMAN stuff -BAT_IF=bat0 -# Increase lookup Frequency to 5s -BAT_INT=5000 - -#------------------------------------------- -# SET Ipv6 Stuff -SET_IPV6="no" -# Do you want a fixed address? -IPV6_FIXED="" - -####-------- -# Extracts the fe80 address and adds an choosen prefix -#### -SET_GENERATED_IPV6="yes" -#used for mesh if -IPV6_GEN_PREFIX="fdc0:ffea" -#Enter without / -IPV6_GEN_NETMASK="48" -#--------------------------------------------- - -#--------------------------------------------- -# IPV4 Stuff -SET_IPV4="yes" -# Do you want to choose your IP? -IPV4_FIXED="" -IPV4_SUBNET_MASK="255.0.0.0" - -# Generates a 10.x.y.z IP Adress -IPV4_GENERATE="no" - -#Load from file or openWRT config (if openwrt) -IPV4_LOAD="yes" - -IPV4_IP_SAVE=/etc/mesh_ipv4.cfg - -#----- Configuration END - -#-------- Common Functiond -BATCTL_FOUND="yes" -V6_GEN_RESULT="" - -check_rc() { - MSG="" - if [ -n "$2" ] ; then - MSG="Error in $2" - else - MSG="Failed with RC $1" - fi - [ "$1" != "0" ] && echo $MSG && exit 255 -} - - -uci_get_details() { - #get mac Adress from uci - SOURCEMAC=$(uci get wireless.$RADIODEVICE.macaddr) - check_rc $? "getting SourceMac" - [[ $MESH_CHANNEL = "0" ]] && MESH_CHANNEL=$( uci get wireless.$RADIODEVICE.channel) - check_rc $? "getting Channel" - - if [ "$IPV4_LOAD" = "yes" ] ; then - IPV4_FIXED=$(uci get network.$OPENWRT_NETWORK.ipaddr) - check_rc $? "getting IPv4 from openwrt config" - fi -} - -generate_v6() { - IF=$1 - PREFIX="fd00" - - test -n "$2" && PREFIX=$2 - - CURRENT_GEN=`ifconfig $IF | - grep "inet6 addr: fe80" | - sed -n "s|^.*::\([^/]*\)/.*|\1|p" | - tr -d ":"` - - FIXED=`echo ${CURRENT_GEN} | tr -d "\012" | - sed "s|\(....\)\(....\)\(....\)\(....\)|\1:\2:\3:\4|"` - - echo "Extracted for $IF : $PREFIX::$FIXED " - V6_GEN_RESULT="$PREFIX::$FIXED" -} - - -RANDOM_NUM=0 -random_num() { - NUM=$((` "254" ]] && NUM=$(($NUM / 7)) - RANDOM_NUM=$NUM -} - -RANDOM_IP_NUM=0 -random_ip_num() { - #Repeat until IP is in range - RANDOM_IP_NUM=0 - RANDOM_NUM=0 - until [[ "$RANDOM_NUM" -gt "000" ]] && [[ $RANDOM_NUM -lt "255" ]] - do - random_num - [[ 1 == 2 ]] && echo "Result random_num $RANDOM_NUM" - done - RANDOM_IP_NUM=$RANDOM_NUM - - [[ 1 == 2 ]] && echo "result random_ip_num $RANDOM_IP_NUM" -} - - -generate_ipv4() { - # 10.x.y.z - x=0 - y=0 - z=0 - - random_ip_num - x=$RANDOM_IP_NUM - random_ip_num - y=$RANDOM_IP_NUM - random_ip_num - z=$RANDOM_IP_NUM - - IPV4_FIXED="10.$x.$y.$z" -} - -modify_MAC() { - # Modify MAC for 2nd interface if not set - #Change two letters - if [ "$MODMAC" = "" ] ; then - MODMAC=$( echo $SOURCEMAC | sed 's/c/a/' | sed 's/1/2/' ) - check_rc $? "sed :( " - echo "Found MAC for $RADIODEVICE : $SOURCEMAC" - echo " modified for 2nd Wifi-if : $MODMAC" - fi -} - -do_wlan_if_up() { - echo "Setting up AdHoc Interface for B.A.T.M.A.N. " - iw $IW_DEVICE interface add $MESH_IF type adhoc - check_rc $? - - echo "Setting fixed BSSID up" - iwconfig $MESH_IF ap $CUSTOM_BSSID - check_rc $? - - if [ "$DISABLE_RTS" = "yes" ] ; then - echo "Disabling RTS/CTS " - iwconfig $MESH_IF rts off - check_rc $? - fi - - echo "Increasing MTU for $MESH_IF to $MTU_NEEDED" - ifconfig $MESH_IF mtu $MTU_NEEDED - check_rc $? - - # Only disable, if IPV6 exists on device - if [ -e "/proc/sys/net/ipv6/conf/$MESH_IF/disable_ipv6" ] ; then - echo "Disabling IPV6 for $MESH_IF - IF without any configuration!" - echo "1" > /proc/sys/net/ipv6/conf/$MESH_IF/disable_ipv6 - check_rc $? - fi - - if [ "$EXCHANGE_MAC" = "yes" ] ; then - echo "Changing $MESH_IF MAC to $MODMAC" - ifconfig $MESH_IF hw ether $MODMAC - check_rc $? - fi - - echo "Setting up Channel $MESH_CHANNEL" - iwconfig $MESH_IF channel $MESH_CHANNEL - check_rc $? - - echo "Setting SSID for Mesh $MESH_SSID" - iwconfig $MESH_IF essid $MESH_SSID - check_rc $? -} - - -save_gen_ipv4() { - #Save IPv4 Address to tmp-space for later use - echo "$IPV4_FIXED" > $IPV4_IP_SAVE -} - -load_gen_ipv4() { - IPV4_FIXED=$(cat $IPV4_IP_SAVE) -} - -do_batman_up() { - if [ "$BATCTL_FOUND" = "yes" ] ; then - echo "Adding $MESH_IF to B.A.T.M.A.N." - batctl if add $MESH_IF - check_rc $? - else - echo "Adding $MESH_IF to B.A.T.M.A.N. via /sys/class/ " - echo "$BAT_IF" > /sys/class/net/$MESH_IF/batman_adv/mesh_iface - check_rc $? - fi - - echo "Starting $BAT_IF" - ifconfig $BAT_IF 0.0.0.0 up - check_rc $? - - if [ "$BATCTL_FOUND" = "yes" ] ; then - echo "Setting B.A.T.M.A.N. Intervall to $BAT_INT " - batctl it $BAT_INT - check_rc $? - else - echo "Setting B.A.T.M.A.N. Intervall via /sys/class/ to $BAT_INT " - echo "$BAT_INT" > /sys/class/net/$BAT_IF/mesh/orig_interval - check_rc $? - fi - - if [ "$SET_GENERATED_IPV6" = "yes" ] ; then - echo "Generating IPv6 address for $BAT_IF" - generate_v6 $BAT_IF $IPV6_GEN_PREFIX - check_rc $? - IPV6_FIXED="$V6_GEN_RESULT"/"$IPV6_GEN_NETMASK" - fi - - if [ "$SET_IPV6" = "yes" ] ; then - echo "Setting up ipv6 address ->$IPV6_FIXED<- on $BAT_IF" - ifconfig "$BAT_IF" add $IPV6_FIXED - check_rc $? - fi - - if [ "$IPV4_GENERATE" = "yes" ] ; then - echo "Generating IPv4 10.x.y.z address for $BAT_IF " - generate_ipv4 - fi - - #Load if not OpenWRt from dataset - [ "$OPENWRT" = "yes" ] || load_gen_ipv4 - - if [ "$SET_IPV4" = "yes" ] ; then - echo "Setting up ipv4 address ->$IPV4_FIXED<- on $BAT_IF" - ifconfig "$BAT_IF" add $IPV4_FIXED netmask $IPV4_SUBNET_MASK - check_rc $? - fi -} - -mesh_start() { - echo "Starting Mesh-IF!" - ifconfig $MESH_IF 0.0.0.0 up - check_rc $? - -# Extract auto IPV6 adress and remove it from mesh if -# AUTO_IPV6=$( ifconfig $MESH_IF | grep "inet6.* " | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//" ) -# echo "Removing .. $AUTO_IPV6 from $MESH_IF" -# ifconfig $MESH_IF inet6 del $AUTO_IPV6 -# check_rc $? "resetting IPv6 on $MESH_IF" - -} - -mesh_stop() { - echo "Stopping Mesh if!" - ifconfig $MESH_IF down -} - -do_wlan_if_down() { - echo "Cleaning up interfaces" - iw dev $MESH_IF del -} - -do_batman_down() { - if [ "$BATCTL_FOUND" = "yes" ] ; then - echo "Remove $MESH_IF from $BAT_IF " - batctl if del $MESH_IF - else - echo "Remove $MESH_IF from $BAT_IF via /sys/class/" - echo none > /sys/class/net/$MESH_IF/batman_adv/mesh_iface - fi -} - -check_requirements() { - lsmod | grep batman >> /dev/null - if [ "$?" != "0" ] ; then - modprobe batman-adv - check_rc $? "Loading kernel module batman-adv failed.. maybe not installed?" - fi - batctl if > /dev/null - if [ $? != "0" ] ; then - echo "Failed running batctl- maybe not installed? " - echo "Try to use /sys/class/" - BATCTL_FOUND='no' - fi -} - -build_mesh() { - check_requirements - echo "Starting Mesh Network with uci-collect..." - [ "$OPENWRT" = "yes" ] && echo "Starting Mesh Network with uci-collect..." \ - && uci_get_details - modify_MAC - do_wlan_if_up - mesh_start - do_batman_up - echo "finished" -} - -destroy_mesh() { - echo "Stopping Mesh Network..." - mesh_stop - do_batman_down - do_wlan_if_down - echo "finished" -} - - -openwrt_postinst() { - echo "Generating IPv4 ..." - generate_ipv4 - save_gen_ipv4 - echo "Generated $IPV4_FIXED for this box!" - - echo "Backuping /etc/config/network" - cp -v /etc/config/network /etc/config/network_pre_mesh.backup - echo "Backuping /etc/config/firewall" - cp -v /etc/config/firewall /etc/config/firewall_pre_mesh.backup - - echo "Do interface $OPENWRT_NETWORK setup on /etc/config/network" - uci set network.$OPENWRT_NETWORK=interface - uci set network.$OPENWRT_NETWORK.ipaddr=$IPV4_FIXED - uci set network.$OPENWRT_NETWORK.netmask=$IPV4_SUBNET_MASK - uci set network.$OPENWRT_NETWORK.proto=static - uci set network.$OPENWRT_NETWORK.ifname=$BAT_IF - uci commit - - echo "Do firewall configuration /etc/config/firewall" - - #Enable Forward on lan zone. Lan zone is always the first - # in MR3020 - echo " ... enabling forward on lan" - uci set firewall.@zone[0].forward=ACCEPT - - echo " ... inserting new zone $OPENWRT_NETWORK" - uci add firewall zone - uci set firewall.@zone[-1].name=$OPENWRT_NETWORK - uci set firewall.@zone[-1].masq=1 - uci set firewall.@zone[-1].mtu_fix=1 - uci set firewall.@zone[-1].input=ACCEPT - uci set firewall.@zone[-1].output=ACCEPT - uci set firewall.@zone[-1].forward=REJECT - - echo " ... adding new forward-rule" - uci add firewall forwarding - uci set firewall.@forwarding[-1].src=lan - uci set firewall.@forwarding[-1].dest=$OPENWRT_NETWORK - - uci commit - - echo "Reloading Firewall" - /etc/init.d/firewall reload - -} - -openwrt_preremove() { - if [ -f /etc/config/network_pre_mesh.backup ] ; then - echo "Saving current state of config/network" - mv /etc/config/network /etc/config/network_after_mesh.backup - echo "Restoring config/network" - mv /etc/config/network_pre_mesh.backup /etc/config/network - fi - - if [ -f /etc/config/firewall_pre_mesh.backup ] ; then - echo "Saving current state of config/firewall" - mv /etc/config/firewall /etc/config/firewall_after_mesh.backup - echo "Restoring config/firewall" - mv /etc/config/firewall_pre_mesh.backup /etc/config/firewall - fi -} - -## mesh.common END - - -# ----piece_start_stop Start -# -- Stuff will be added on Make - -check_config() { - if [ "$MESH_CHANNEL" = "0" ] ; then - echo "Please set option MESH_CHANNEL" - exit 255 - elif [ "$SOURCEMAC" = "$MODMAC" ] ; then - echo "Please set option SOURCEMAC to the MAC Address of you wifi device" - ifconfig wlan0 || ifconfig - echo "Please set option SOURCEMAC to the MAC Address of you wifi device" - echo " or enter a modified one in MODMAC and set EXCHANGE_MAC=no " - exit 255 - fi -} - - -# Start Stop stuff for running in script directly -if [ "$1" = "start" ] ; then - check_config - build_mesh -elif [ "$1" = "stop" ] ; then - destroy_mesh -elif [ "$1" = "restart" ] ; then - destroy_mesh - check_config - build_mesh -elif [ "$1" = "test_gen" ] ; then - generate_ipv4 - echo "Generated IPv4: $IPV4_FIXED" -else - echo "valid options are start|stop|restart" - exit 255 -fi -# ----piece_start_stop End - - From 00ce4b011f7e47b19e8ff15847d4f11e07265215 Mon Sep 17 00:00:00 2001 From: Matthias Strubel Date: Sat, 12 Jul 2014 18:11:46 +0200 Subject: [PATCH 4/4] Adding IPv4 filtering to the bridge interface --- Makefile | 2 +- src/control/control | 4 ++-- src/data/etc/mesh.config | 2 ++ src/data/usr/share/mesh/mesh.common | 22 ++++++++++++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 8bee79a..087bbe9 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ NAME = piratebox-mesh -VERSION = 1.1.1 +VERSION = 1.1.2 ARCH = all IPK = $(NAME)_$(VERSION)_$(ARCH).ipk IPKDIR = src diff --git a/src/control/control b/src/control/control index 753893d..7171ead 100644 --- a/src/control/control +++ b/src/control/control @@ -1,6 +1,6 @@ Package: piratebox-mesh -Version: 1.1.1 -Depends: kmod-batman-adv wireless-tools +Version: 1.1.2 +Depends: kmod-batman-adv wireless-tools iptables-mod-extra Provides: Source: package/piratebox-mesh Section: net diff --git a/src/data/etc/mesh.config b/src/data/etc/mesh.config index 000c1a4..4d631e2 100644 --- a/src/data/etc/mesh.config +++ b/src/data/etc/mesh.config @@ -82,4 +82,6 @@ IPV4_IP_SAVE=/etc/mesh_ipv4.cfg ADD_BRIDGE="yes" BRIDGE_NAME="br-lan" +FILTER_IPV4_BRIDGE="yes" + #----- Configuration END diff --git a/src/data/usr/share/mesh/mesh.common b/src/data/usr/share/mesh/mesh.common index a5fadd5..3c8b577 100755 --- a/src/data/usr/share/mesh/mesh.common +++ b/src/data/usr/share/mesh/mesh.common @@ -131,6 +131,23 @@ do_bridge_remove() { } +do_bridge_filter() { + echo "Add IPv4 filtering on the bridge interface." + echo "1" > /proc/sys/net/bridge/bridge-nf-call-iptables + check_rc $? + iptables -I INPUT -m physdev -i "$BRIDGE_NAME" --physdev-in "$BAT_IF" -j DROP + check_rc $? + iptables -I FORWARD -m physdev -i "$BRIDGE_NAME" --physdev-in "$BAT_IF" -j DROP + check_rc $? +} + +do_bridge_filter_remove() { + echo "Removing IPv4 filter on the bridge interface." + iptables -D INPUT -m physdev -i "$BRIDGE_NAME" --physdev-in "$BAT_IF" -j DROP + check_rc $? + iptables -D FORWARD -m physdev -i "$BRIDGE_NAME" --physdev-in "$BAT_IF" -j DROP + check_rc $? +} do_wlan_if_up() { echo "Setting up AdHoc Interface for B.A.T.M.A.N. " @@ -238,6 +255,8 @@ do_batman_up() { echo "Setting up GatewayMode to $BAT_GW" batctl gw $BAT_GW check_rc $? + + [ "$FILTER_IPV4_BRIDGE" = "yes" ] && do_bridge_filter } mesh_start() { @@ -271,6 +290,9 @@ do_batman_down() { echo "Remove $MESH_IF from $BAT_IF via /sys/class/" echo none > /sys/class/net/$MESH_IF/batman_adv/mesh_iface fi + + + [ "$FILTER_IPV4_BRIDGE" = "yes" ] && do_bridge_remove } check_requirements() {