X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=contrib%2Fpackage%2Fmeshwizard%2Ffiles%2Fusr%2Fbin%2Fmeshwizard%2Fhelpers%2Fsetup_network.sh;fp=contrib%2Fpackage%2Fmeshwizard%2Ffiles%2Fusr%2Fbin%2Fmeshwizard%2Fhelpers%2Fsetup_network.sh;h=d8aa8a095fbea243bf052e7f5bfc25f5e0664fd1;hp=f0ed0e7f881c78783e2940fae553e0d9867d0136;hb=af116017873f81ab9948317c6a4be5befea6ab01;hpb=115633350d46dee2bf48a5680ac607a17db4a276 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 f0ed0e7f8..d8aa8a095 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 @@ -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