summaryrefslogtreecommitdiffhomepage
path: root/contrib/package/meshwizard/files
diff options
context:
space:
mode:
authorManuel Munz <freifunk@somakoma.de>2013-05-18 11:58:54 +0000
committerManuel Munz <freifunk@somakoma.de>2013-05-18 11:58:54 +0000
commitd55f7135de9b7cd4345305e70cc30d143f9e37e6 (patch)
treeaad090f253bd6e7ffc378bc3d32ed40073a7f52c /contrib/package/meshwizard/files
parentf8bf25a7bfbb77d2b10c5421898ff8095d90ec04 (diff)
contrib/meshwizard: Also setup a dhcp server on the adhoc interface if VAP is used. In this case split the DHCP Network in two halves, one for the adhoc, one for the managed network.
Diffstat (limited to 'contrib/package/meshwizard/files')
-rwxr-xr-xcontrib/package/meshwizard/files/usr/bin/meshwizard/helpers/ipcalc-cidr.sh1
-rwxr-xr-xcontrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dhcp.sh16
-rwxr-xr-xcontrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall_interface.sh39
-rwxr-xr-xcontrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_network.sh47
-rwxr-xr-xcontrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_splash.sh17
5 files changed, 95 insertions, 25 deletions
diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/ipcalc-cidr.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/ipcalc-cidr.sh
index 39d051ec1..6d7a1fb56 100755
--- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/ipcalc-cidr.sh
+++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/ipcalc-cidr.sh
@@ -28,6 +28,7 @@ BEGIN {
print "NETMASK="int2ip(netmask)
print "BROADCAST="int2ip(broadcast)
print "NETWORK="int2ip(network)
+ print "NEXTNET="int2ip(broadcast + 1)
print "PREFIX="32-bitcount(compl(netmask))
# range calculations:
diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dhcp.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dhcp.sh
index 5c8863e36..a6f16b32e 100755
--- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dhcp.sh
+++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dhcp.sh
@@ -5,6 +5,7 @@
. $dir/functions.sh
net="$1"
+vap="$(uci -q get meshwizard.netconfig.${net}_vap)"
handle_dnsmasq() {
config_get interface "$1" interface
@@ -19,12 +20,21 @@ config_foreach handle_dnsmasq dhcp
[ "$net" == "lan" ] && uci -q delete dhcp.lan
+if [ "$vap" == 1 ]; then
+ uci batch <<- EOF
+ set dhcp.${netrenamed}dhcp="dhcp"
+ set dhcp.${netrenamed}dhcp.interface="${netrenamed}dhcp"
+ EOF
+ set_defaults "dhcp_" dhcp.${netrenamed}dhcp
+fi
+
uci batch << EOF
- set dhcp.${netrenamed}dhcp="dhcp"
- set dhcp.${netrenamed}dhcp.interface="${netrenamed}dhcp"
+ set dhcp.${netrenamed}ahdhcp="dhcp"
+ set dhcp.${netrenamed}ahdhcp.interface="${netrenamed}ahdhcp"
EOF
-set_defaults "dhcp_" dhcp.${netrenamed}dhcp
+set_defaults "dhcp_" dhcp.${netrenamed}ahdhcp
uci_commitverbose "Setup DHCP for $netrenamed" dhcp
+
diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall_interface.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall_interface.sh
index 11c351b0d..893aed452 100755
--- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall_interface.sh
+++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall_interface.sh
@@ -61,17 +61,41 @@ currms=$(uci -q get firewall.zone_freifunk.masq_src)
# If interfaces are outside of the mesh network they should be natted
-# Get dhcprange and meshnet
-if_ip="$(uci -q get network.${netrenamed}dhcp.ipaddr)"
-if_mask="$(uci -q get network.${netrenamed}dhcp.netmask)"
+if [ "$vap" == 1 ]; then
+ # Get dhcprange and meshnet for the dhcp interface
+ if_ip="$(uci -q get network.${netrenamed}dhcp.ipaddr)"
+ if_mask="$(uci -q get network.${netrenamed}dhcp.netmask)"
+
+ [ -n "$if_ip" -a "$if_mask" ] && export $(ipcalc.sh $if_ip $if_mask)
+ [ -n "$NETWORK" -a "$PREFIX" ] && dhcprange="$NETWORK/$PREFIX"
+
+ if [ -n "$dhcprange" ]; then
+ meshnet="$(uci get profile_$community.profile.mesh_network)"
+ # check if the dhcprange is inside meshnet
+ dhcpinmesh="$($dir/helpers/check-range-in-range.sh $dhcprange $meshnet)"
+ if [ "$dhcpinmesh" == 1 ]; then
+ # needed or splash will not work
+ if [ "$has_luci_splash" == TRUE ]; then
+ uci set firewall.zone_freifunk.contrack="1"
+ fi
+ else
+ uci set firewall.zone_freifunk.masq=1
+ [ -z "$(echo $currms |grep ${netrenamed}dhcp)" ] && uci add_list firewall.zone_freifunk.masq_src="${netrenamed}dhcp"
+ fi
+ fi
+fi
+
+# Get dhcprange and meshnet for the adhoc dhcp interface
+if_ip="$(uci -q get network.${netrenamed}ahdhcp.ipaddr)"
+if_mask="$(uci -q get network.${netrenamed}ahdhcp.netmask)"
[ -n "$if_ip" -a "$if_mask" ] && export $(ipcalc.sh $if_ip $if_mask)
-[ -n "$NETWORK" -a "$PREFIX" ] && dhcprange="$NETWORK/$PREFIX"
+[ -n "$NETWORK" -a "$PREFIX" ] && dhcprangeah="$NETWORK/$PREFIX"
-if [ -n "$dhcprange" ]; then
+if [ -n "$dhcprangeah" ]; then
meshnet="$(uci get profile_$community.profile.mesh_network)"
# check if the dhcprange is inside meshnet
- dhcpinmesh="$($dir/helpers/check-range-in-range.sh $dhcprange $meshnet)"
+ dhcpinmesh="$($dir/helpers/check-range-in-range.sh $dhcprangeah $meshnet)"
if [ "$dhcpinmesh" == 1 ]; then
# needed or splash will not work
if [ "$has_luci_splash" == TRUE ]; then
@@ -79,10 +103,11 @@ if [ -n "$dhcprange" ]; then
fi
else
uci set firewall.zone_freifunk.masq=1
- [ -z "$(echo $currms |grep ${netrenamed}dhcp)" ] && uci add_list firewall.zone_freifunk.masq_src="${netrenamed}dhcp"
+ [ -z "$(echo $currms |grep ${netrenamed}ahdhcp)" ] && uci add_list firewall.zone_freifunk.masq_src="${netrenamed}ahdhcp"
fi
fi
+
for i in IP NETMASK BROADCAST NETWORK PREFIX; do
unset $i
done
diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_network.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_network.sh
index 70f82fe2a..f0ed0e7f8 100755
--- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_network.sh
+++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_network.sh
@@ -67,23 +67,48 @@ if [ "$net_dhcp" == 1 ]; then
dhcprange="$($dir/helpers/gen_dhcp_ip.sh $interface_ip)/24"
uci set meshwizard.netconfig.${net}_dhcprange="$dhcprange"
fi
- eval $(sh $dir/helpers/ipcalc-cidr.sh $dhcprange 1 0)
- # setup wifi-dhcp interface or alias (using interface notation)
-
- # Setup alias for $net
+ # If we use VAP then cut the dhcp range in two halves
+ # one for the adhoc, one for the managed VAP interface
if [ "$vap" == 1 ]; then
- uci set network.${netrenamed}dhcp=interface
+ local network
+ local mask
+ network=${dhcprange%%/*}
+ mask=${dhcprange##*/}
+ # Divide network size by adding 1 to the netmask
+ mask=$(($mask + 1))
+ # Get first ip and netmask for the adhoc dhcp network
+ eval $(sh $dir/helpers/ipcalc-cidr.sh ${network}/${mask} 1 0)
+ STARTADHOC=$START
+ NETMASKADHOC=$NETMASK
+ # Get first ip and netmask for the managed dhcp network
+ eval $(sh $dir/helpers/ipcalc-cidr.sh ${NEXTNET}/${mask} 1 0)
+ STARTVAP=$START
+ NETMASKVAP=$NETMASK
+ # Add dhcp interface
+ uci batch <<- EOF
+ set network.${netrenamed}dhcp=interface
+ set network.${netrenamed}dhcp.proto=static
+ set network.${netrenamed}dhcp.ipaddr="$STARTVAP"
+ set network.${netrenamed}dhcp.netmask="$NETMASKVAP"
+ EOF
+ uci_commitverbose "Setup interface for ${netrenamed}dhcp" network
+
else
- uci set network.${netrenamed}dhcp=interface
- uci set network.${netrenamed}dhcp.ifname="@${netrenamed}"
+ eval $(sh $dir/helpers/ipcalc-cidr.sh $dhcprange 1 0)
+ STARTADHOC=$START
+ NETMASKADHOC=$NETMASK
fi
+ # Setup alias for $net adhoc interface
+
uci batch <<- EOF
- set network.${netrenamed}dhcp.proto=static
- set network.${netrenamed}dhcp.ipaddr="$START"
- set network.${netrenamed}dhcp.netmask="$NETMASK"
+ set network.${netrenamed}ahdhcp=interface
+ set network.${netrenamed}ahdhcp.ifname="@${netrenamed}"
+ set network.${netrenamed}ahdhcp.proto=static
+ set network.${netrenamed}ahdhcp.ipaddr="$STARTADHOC"
+ set network.${netrenamed}ahdhcp.netmask="$NETMASKADHOC"
EOF
- uci_commitverbose "Setup interface for ${netrenamed}dhcp" network
+ uci_commitverbose "Setup interface for ${netrenamed}ahdhcp" network
fi
diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_splash.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_splash.sh
index 974111125..722567e81 100755
--- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_splash.sh
+++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_splash.sh
@@ -5,6 +5,7 @@
. $dir/functions.sh
net=$1
+vap=$(uci -q get meshwizard.netconfig.${net}_vap)
if [ ! "$has_luci_splash" == TRUE ]; then
echo " Luci Splash is not installed, skipping setup of it."
@@ -28,13 +29,21 @@ if [ "$(uci -q get meshwizard.netconfig.$net\_dhcp)" == 1 ] && [ -n "$dhcprange"
config_load luci_splash
config_foreach handle_splash iface
+ if [ "$vap" == 1 ]; then
+ uci batch <<- EOF
+ set luci_splash.${netrenamed}dhcp="iface"
+ set luci_splash.${netrenamed}dhcp.network="${netrenamed}dhcp"
+ set luci_splash.${netrenamed}dhcp.zone="freifunk"
+ EOF
+ uci_commitverbose "Setup dhcpsplash for ${netrenamed}dhcp" luci_splash
+ fi
uci batch <<- EOF
- set luci_splash.${netrenamed}dhcp="iface"
- set luci_splash.${netrenamed}dhcp.network="${netrenamed}dhcp"
- set luci_splash.${netrenamed}dhcp.zone="freifunk"
+ set luci_splash.${netrenamed}ahdhcp="iface"
+ set luci_splash.${netrenamed}ahdhcp.network="${netrenamed}ahdhcp"
+ set luci_splash.${netrenamed}ahdhcp.zone="freifunk"
EOF
+ uci_commitverbose "Setup dhcpsplash for ${netrenamed}ahdhcp" luci_splash
- uci_commitverbose "Setup dhcpsplash for ${netrenamed}dhcp" luci_splash
/etc/init.d/luci_splash enable
fi