contrib/meshwizard: Do not enable DHCP on adhoc by default when VAPs are used.

This commit is contained in:
Manuel Munz 2013-10-19 14:23:28 +00:00
parent 115633350d
commit af11601787
9 changed files with 89 additions and 62 deletions

View file

@ -4,7 +4,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=meshwizard
PKG_RELEASE:=0.0.14
PKG_RELEASE:=0.1.0
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)

View file

@ -20,7 +20,7 @@ config_foreach handle_dnsmasq dhcp
[ "$net" == "lan" ] && uci -q delete dhcp.lan
if [ "$vap" == 1 ]; then
if [ "$supports_vap" = 1 -a "$vap" = 1 ]; then
uci batch <<- EOF
set dhcp.${netrenamed}dhcp="dhcp"
set dhcp.${netrenamed}dhcp.interface="${netrenamed}dhcp"
@ -28,11 +28,13 @@ if [ "$vap" == 1 ]; then
set_defaults "dhcp_" dhcp.${netrenamed}dhcp
fi
uci batch << EOF
set dhcp.${netrenamed}ahdhcp="dhcp"
set dhcp.${netrenamed}ahdhcp.interface="${netrenamed}ahdhcp"
EOF
ahdhcp_when_vap="$(uci get profile_$community.profile.adhoc_dhcp_when_vap)"
if [ "$supports_vap" = 0 ] || [ "$supports_vap" = 1 -a "$vap" = 1 -a "$ahdhcp_when_vap" = 1 ]; then
uci batch <<- EOF
set dhcp.${netrenamed}ahdhcp="dhcp"
set dhcp.${netrenamed}ahdhcp.interface="${netrenamed}ahdhcp"
EOF
fi
set_defaults "dhcp_" dhcp.${netrenamed}ahdhcp
uci_commitverbose "Setup DHCP for $netrenamed" dhcp

View file

@ -45,10 +45,6 @@ network=$(echo $network) # Removes leading and trailing whitespaces
[ -n "$netrenamed" ] && [ -z "$(echo $network | grep $netrenamed)" ] && network="$network $netrenamed"
# check if this hardware supports VAPs
supports_vap="0"
$dir/helpers/supports_vap.sh $net $type && supports_vap=1
if [ "$supports_vap" == "1" -a "$vap" == 1 ]; then
[ -n "$netrenamed" ] && [ "$network" == "${network/${netrenamed}dhcp/}" ] && network="$network ${netrenamed}dhcp"
fi

View file

@ -68,10 +68,13 @@ if [ "$net_dhcp" == 1 ]; then
uci set meshwizard.netconfig.${net}_dhcprange="$dhcprange"
fi
# If we use VAP then cut the dhcp range in two halves
# one for the adhoc, one for the managed VAP interface
# If we use VAP and also offer dhcp on the adhoc interface then cut the dhcp
# range in two halves. one for the adhoc, one for the managed VAP interface
ahdhcp_when_vap="$(uci get profile_$community.profile.adhoc_dhcp_when_vap)"
if [ "$vap" == 1 ]; then
if [ "$supports_vap" = 1 -a "$vap" = 1 -a "$ahdhcp_when_vap" = 1 ]; then
# VAPs are enabled for this interface, supported and we want to
# also use DHCP on the adhoc interface
local network
local mask
network=${dhcprange%%/*}
@ -94,21 +97,35 @@ if [ "$net_dhcp" == 1 ]; then
set network.${netrenamed}dhcp.netmask="$NETMASKVAP"
EOF
uci_commitverbose "Setup interface for ${netrenamed}dhcp" network
else
eval $(sh $dir/helpers/ipcalc-cidr.sh $dhcprange 1 0)
STARTADHOC=$START
NETMASKADHOC=$NETMASK
fi
if [ "$supports_vap" = 1 -a "$vap" = 1 -a "$ahdhcp_when_vap" != 1 ]; then
# vaps are enabled and supported and we do not use DHCP on adhoc
# Add dhcp interface
uci batch <<- EOF
set network.${netrenamed}dhcp=interface
set network.${netrenamed}dhcp.proto=static
set network.${netrenamed}dhcp.ipaddr="$STARTADHOC"
set network.${netrenamed}dhcp.netmask="$NETMASKADHOC"
EOF
uci_commitverbose "Setup interface for ${netrenamed}dhcp" network
fi
# Setup alias for $net adhoc interface
uci batch <<- EOF
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
# Setup alias for $net adhoc interface
if [ "$supports_vap" = 0 ] || [ "$vap" = 0 ] || [ "$supports_vap" = 1 -a "$vap" = 1 -a "$ahdhcp_when_vap" = 1 ]; then
# vaps are either not supported or enabled or they are supported and enabled
# but we also want to use DHCP on the adhoc interface
uci batch <<- EOF
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
fi
uci_commitverbose "Setup interface for ${netrenamed}ahdhcp" network
fi

View file

@ -17,6 +17,14 @@ uci_commitverbose "Setup general splash settings" luci_splash
dhcprange=$(uci -q get meshwizard.netconfig.$net\_dhcprange)
splash_net_add() {
uci batch <<- EOF
set luci_splash.$1="iface"
set luci_splash.$1.network="$1"
set luci_splash.$1.zone="freifunk"
EOF
}
if [ "$(uci -q get meshwizard.netconfig.$net\_dhcp)" == 1 ] && [ -n "$dhcprange" ]; then
handle_splash() {
config_get network "$1" network
@ -29,21 +37,16 @@ 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
if [ "$supports_vap" = 1 -a "$vap" = 1 ]; then
splash_net_add ${netrenamed}dhcp
uci_commitverbose "Setup dhcpsplash for ${netrenamed}dhcp" luci_splash
fi
uci batch <<- EOF
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
ahdhcp_when_vap="$(uci get profile_$community.profile.adhoc_dhcp_when_vap)"
if [ "$supports_vap" = 0 ] || [ "$supports_vap" = 1 -a "$vap" = 1 -a "$ahdhcp_when_vap" = 1 ]; then
splash_net_add ${netrenamed}ahdhcp
uci_commitverbose "Setup dhcpsplash for ${netrenamed}ahdhcp" luci_splash
fi
/etc/init.d/luci_splash enable
fi

View file

@ -28,7 +28,6 @@ uci set wireless.${net}=wifi-device
set_defaults "wifi_device_" wireless.${net}
channel="$(uci -q get meshwizard.netconfig.$net\_channel)"
vap="$(uci -q get meshwizard.netconfig.$net\_vap)"
if [ -z "$channel" -o "$channel" == "default" ]; then
channel=$wifi_device_channel
@ -77,26 +76,3 @@ EOF
uci_commitverbose "Setup wifi interface for $netrenamed" wireless
## VAP
ip4addr="$(uci get meshwizard.netconfig.$net\_ip4addr)"
# check if this hardware supports VAPs
# the interface needs to be up before the check can happen
/sbin/wifi
supports_vap="0"
$dir/helpers/supports_vap.sh $net $type && supports_vap=1
if [ "$supports_vap" == "1" -a "$vap" == 1 ]; then
uci batch <<- EOF
set wireless.$net\_iface_dhcp="wifi-iface"
set wireless.$net\_iface_dhcp.device="$net"
set wireless.$net\_iface_dhcp.mode="ap"
set wireless.$net\_iface_dhcp.encryption="none"
set wireless.$net\_iface_dhcp.network="${netrenamed}dhcp"
set wireless.$net\_iface_dhcp.ssid="Freifunk-$ip4addr"
EOF
uci_commitverbose "Setup VAP interface for $netrenamed" wireless
fi

View file

@ -0,0 +1,23 @@
#!/bin/sh
# sets up a wifi interface for meshing
# Arguments: $1 = network interface
net="$1"
. /lib/functions.sh
. $dir/functions.sh
## Setup a VAP interface in AP Mode
ip4addr="$(uci get meshwizard.netconfig.$net\_ip4addr)"
vap="$(uci -q get meshwizard.netconfig.$net\_vap)"
if [ "$supports_vap" == 1 -a "$vap" == 1 ]; then
uci batch <<- EOF
set wireless.$net\_iface_dhcp="wifi-iface"
set wireless.$net\_iface_dhcp.device="$net"
set wireless.$net\_iface_dhcp.mode="ap"
set wireless.$net\_iface_dhcp.encryption="none"
set wireless.$net\_iface_dhcp.network="${netrenamed}dhcp"
set wireless.$net\_iface_dhcp.ssid="Freifunk-$ip4addr"
EOF
uci_commitverbose "Setup VAP interface for $netrenamed" wireless
fi

View file

@ -12,7 +12,7 @@
. /lib/functions.sh
echo "
/* Meshwizard 0.0.9 */
/* Meshwizard 0.1.0 */
"
# config
@ -95,10 +95,21 @@ for net in $networks; do
# radioX devices need to be renamed
netrenamed="${net/radio/wireless}"
export netrenamed
$dir/helpers/setup_network.sh $net
if [ ! "$net" == "wan" ] && [ ! "$net" == "lan" ]; then
$dir/helpers/setup_wifi.sh $net
# check if this net supports vap
/sbin/wifi # wifi needs to be up for the check
export supports_vap="0"
type="$(uci -q get wireless.$net.type)"
[ -n "$type" ] && $dir/helpers/supports_vap.sh $net $type && export supports_vap=1
if [ "$supports_vap" = 1 ]; then
$dir/helpers/setup_wifi_vap.sh $net
fi
fi
$dir/helpers/setup_network.sh $net
$dir/helpers/setup_olsrd_interface.sh $net
net_dhcp=$(uci -q get meshwizard.netconfig.${net}_dhcp)