contrib/meshwizard: Do not enable DHCP on adhoc by default when VAPs are used.
This commit is contained in:
parent
115633350d
commit
af11601787
9 changed files with 89 additions and 62 deletions
|
@ -4,7 +4,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=meshwizard
|
PKG_NAME:=meshwizard
|
||||||
PKG_RELEASE:=0.0.14
|
PKG_RELEASE:=0.1.0
|
||||||
|
|
||||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ config_foreach handle_dnsmasq dhcp
|
||||||
|
|
||||||
[ "$net" == "lan" ] && uci -q delete dhcp.lan
|
[ "$net" == "lan" ] && uci -q delete dhcp.lan
|
||||||
|
|
||||||
if [ "$vap" == 1 ]; then
|
if [ "$supports_vap" = 1 -a "$vap" = 1 ]; then
|
||||||
uci batch <<- EOF
|
uci batch <<- EOF
|
||||||
set dhcp.${netrenamed}dhcp="dhcp"
|
set dhcp.${netrenamed}dhcp="dhcp"
|
||||||
set dhcp.${netrenamed}dhcp.interface="${netrenamed}dhcp"
|
set dhcp.${netrenamed}dhcp.interface="${netrenamed}dhcp"
|
||||||
|
@ -28,11 +28,13 @@ if [ "$vap" == 1 ]; then
|
||||||
set_defaults "dhcp_" dhcp.${netrenamed}dhcp
|
set_defaults "dhcp_" dhcp.${netrenamed}dhcp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
uci batch << EOF
|
ahdhcp_when_vap="$(uci get profile_$community.profile.adhoc_dhcp_when_vap)"
|
||||||
set dhcp.${netrenamed}ahdhcp="dhcp"
|
if [ "$supports_vap" = 0 ] || [ "$supports_vap" = 1 -a "$vap" = 1 -a "$ahdhcp_when_vap" = 1 ]; then
|
||||||
set dhcp.${netrenamed}ahdhcp.interface="${netrenamed}ahdhcp"
|
uci batch <<- EOF
|
||||||
EOF
|
set dhcp.${netrenamed}ahdhcp="dhcp"
|
||||||
|
set dhcp.${netrenamed}ahdhcp.interface="${netrenamed}ahdhcp"
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
set_defaults "dhcp_" dhcp.${netrenamed}ahdhcp
|
set_defaults "dhcp_" dhcp.${netrenamed}ahdhcp
|
||||||
|
|
||||||
uci_commitverbose "Setup DHCP for $netrenamed" dhcp
|
uci_commitverbose "Setup DHCP for $netrenamed" dhcp
|
||||||
|
|
|
@ -45,10 +45,6 @@ network=$(echo $network) # Removes leading and trailing whitespaces
|
||||||
|
|
||||||
[ -n "$netrenamed" ] && [ -z "$(echo $network | grep $netrenamed)" ] && network="$network $netrenamed"
|
[ -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
|
if [ "$supports_vap" == "1" -a "$vap" == 1 ]; then
|
||||||
[ -n "$netrenamed" ] && [ "$network" == "${network/${netrenamed}dhcp/}" ] && network="$network ${netrenamed}dhcp"
|
[ -n "$netrenamed" ] && [ "$network" == "${network/${netrenamed}dhcp/}" ] && network="$network ${netrenamed}dhcp"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -68,10 +68,13 @@ if [ "$net_dhcp" == 1 ]; then
|
||||||
uci set meshwizard.netconfig.${net}_dhcprange="$dhcprange"
|
uci set meshwizard.netconfig.${net}_dhcprange="$dhcprange"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If we use VAP then cut the dhcp range in two halves
|
# If we use VAP and also offer dhcp on the adhoc interface then cut the dhcp
|
||||||
# one for the adhoc, one for the managed VAP interface
|
# 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 network
|
||||||
local mask
|
local mask
|
||||||
network=${dhcprange%%/*}
|
network=${dhcprange%%/*}
|
||||||
|
@ -94,21 +97,35 @@ if [ "$net_dhcp" == 1 ]; then
|
||||||
set network.${netrenamed}dhcp.netmask="$NETMASKVAP"
|
set network.${netrenamed}dhcp.netmask="$NETMASKVAP"
|
||||||
EOF
|
EOF
|
||||||
uci_commitverbose "Setup interface for ${netrenamed}dhcp" network
|
uci_commitverbose "Setup interface for ${netrenamed}dhcp" network
|
||||||
|
|
||||||
else
|
else
|
||||||
eval $(sh $dir/helpers/ipcalc-cidr.sh $dhcprange 1 0)
|
eval $(sh $dir/helpers/ipcalc-cidr.sh $dhcprange 1 0)
|
||||||
STARTADHOC=$START
|
STARTADHOC=$START
|
||||||
NETMASKADHOC=$NETMASK
|
NETMASKADHOC=$NETMASK
|
||||||
fi
|
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
|
# Setup alias for $net adhoc interface
|
||||||
set network.${netrenamed}ahdhcp=interface
|
if [ "$supports_vap" = 0 ] || [ "$vap" = 0 ] || [ "$supports_vap" = 1 -a "$vap" = 1 -a "$ahdhcp_when_vap" = 1 ]; then
|
||||||
set network.${netrenamed}ahdhcp.ifname="@${netrenamed}"
|
# vaps are either not supported or enabled or they are supported and enabled
|
||||||
set network.${netrenamed}ahdhcp.proto=static
|
# but we also want to use DHCP on the adhoc interface
|
||||||
set network.${netrenamed}ahdhcp.ipaddr="$STARTADHOC"
|
uci batch <<- EOF
|
||||||
set network.${netrenamed}ahdhcp.netmask="$NETMASKADHOC"
|
set network.${netrenamed}ahdhcp=interface
|
||||||
EOF
|
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
|
uci_commitverbose "Setup interface for ${netrenamed}ahdhcp" network
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -17,6 +17,14 @@ uci_commitverbose "Setup general splash settings" luci_splash
|
||||||
|
|
||||||
dhcprange=$(uci -q get meshwizard.netconfig.$net\_dhcprange)
|
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
|
if [ "$(uci -q get meshwizard.netconfig.$net\_dhcp)" == 1 ] && [ -n "$dhcprange" ]; then
|
||||||
handle_splash() {
|
handle_splash() {
|
||||||
config_get network "$1" network
|
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_load luci_splash
|
||||||
config_foreach handle_splash iface
|
config_foreach handle_splash iface
|
||||||
|
|
||||||
if [ "$vap" == 1 ]; then
|
if [ "$supports_vap" = 1 -a "$vap" = 1 ]; then
|
||||||
uci batch <<- EOF
|
splash_net_add ${netrenamed}dhcp
|
||||||
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
|
uci_commitverbose "Setup dhcpsplash for ${netrenamed}dhcp" luci_splash
|
||||||
fi
|
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
|
/etc/init.d/luci_splash enable
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ uci set wireless.${net}=wifi-device
|
||||||
set_defaults "wifi_device_" wireless.${net}
|
set_defaults "wifi_device_" wireless.${net}
|
||||||
|
|
||||||
channel="$(uci -q get meshwizard.netconfig.$net\_channel)"
|
channel="$(uci -q get meshwizard.netconfig.$net\_channel)"
|
||||||
vap="$(uci -q get meshwizard.netconfig.$net\_vap)"
|
|
||||||
|
|
||||||
if [ -z "$channel" -o "$channel" == "default" ]; then
|
if [ -z "$channel" -o "$channel" == "default" ]; then
|
||||||
channel=$wifi_device_channel
|
channel=$wifi_device_channel
|
||||||
|
@ -77,26 +76,3 @@ EOF
|
||||||
|
|
||||||
uci_commitverbose "Setup wifi interface for $netrenamed" wireless
|
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
|
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
@ -32,4 +32,3 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
. /lib/functions.sh
|
. /lib/functions.sh
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
/* Meshwizard 0.0.9 */
|
/* Meshwizard 0.1.0 */
|
||||||
"
|
"
|
||||||
|
|
||||||
# config
|
# config
|
||||||
|
@ -95,10 +95,21 @@ for net in $networks; do
|
||||||
# radioX devices need to be renamed
|
# radioX devices need to be renamed
|
||||||
netrenamed="${net/radio/wireless}"
|
netrenamed="${net/radio/wireless}"
|
||||||
export netrenamed
|
export netrenamed
|
||||||
$dir/helpers/setup_network.sh $net
|
|
||||||
if [ ! "$net" == "wan" ] && [ ! "$net" == "lan" ]; then
|
if [ ! "$net" == "wan" ] && [ ! "$net" == "lan" ]; then
|
||||||
$dir/helpers/setup_wifi.sh $net
|
$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
|
fi
|
||||||
|
|
||||||
|
$dir/helpers/setup_network.sh $net
|
||||||
|
|
||||||
$dir/helpers/setup_olsrd_interface.sh $net
|
$dir/helpers/setup_olsrd_interface.sh $net
|
||||||
|
|
||||||
net_dhcp=$(uci -q get meshwizard.netconfig.${net}_dhcp)
|
net_dhcp=$(uci -q get meshwizard.netconfig.${net}_dhcp)
|
||||||
|
|
Loading…
Reference in a new issue