diff --git a/files/etc/config.mesh/_setup b/files/etc/config.mesh/_setup index d6e5a612..a3ee31a8 100644 --- a/files/etc/config.mesh/_setup +++ b/files/etc/config.mesh/_setup @@ -17,6 +17,11 @@ wifi2_encryption = wifi2_key = wifi2_hwmode = 11a +wifi3_enable = 0 +wifi3_ssid = +wifi3_key = +wifi3_hwmode = 11a + dmz_mode = 3 lan_proto = static lan_ip = 172.27.0.1 diff --git a/files/etc/config.mesh/_setup.default b/files/etc/config.mesh/_setup.default index ffd8dbdd..9a1abc97 100644 --- a/files/etc/config.mesh/_setup.default +++ b/files/etc/config.mesh/_setup.default @@ -17,6 +17,11 @@ wifi2_encryption = none wifi2_key = wifi2_hwmode = 11a +wifi3_enable = 0 +wifi3_ssid = +wifi3_key = +wifi3_hwmode = 11a + dmz_mode = 3 lan_proto = static lan_ip = 172.27.0.1 diff --git a/files/usr/local/bin/node-setup b/files/usr/local/bin/node-setup index affb380c..3b47a6b5 100755 --- a/files/usr/local/bin/node-setup +++ b/files/usr/local/bin/node-setup @@ -126,7 +126,9 @@ foreach $line (`cat /etc/config.mesh/_setup`) chomp ($lanintf=`jsonfilter -e '@.network.lan.ifname' < /etc/board.json`); $cfg{lan_intf} = "$lanintf"; -$cfg{wan_intf} = get_bridge_interfaces("wan"); +$cfg{wan_intf} = "dummy"; +# wan_intf is set by wifi-setup directly to network config file + $cfg{dtdlink_intf} = get_bridge_interfaces("dtdlink"); if ( $cfg{wifi_enable} == 1 ) @@ -511,7 +513,6 @@ system $cmd; # system('/usr/local/bin/wifi-setup'); - unless($auto) { print "configuration complete.\n"; diff --git a/files/usr/local/bin/wifi-setup b/files/usr/local/bin/wifi-setup index 7b072d29..d5702a49 100755 --- a/files/usr/local/bin/wifi-setup +++ b/files/usr/local/bin/wifi-setup @@ -53,18 +53,27 @@ done < $configfile meshif="$(uci -q get network.wifi.ifname)" meshphy="phy${meshif#wlan}" +# set physical wan interface in network + +wan_intf=`cat /etc/board.json|jsonfilter -e '@.network.wan.ifname'` +uci -c ${dropdir} -q batch > /dev/null <<-EOF +set network.wan.ifname=$wan_intf +EOF +uci -c ${dropdir} -q commit network + rm -f "${dropdir}/wireless" touch "${dropdir}/wireless" ifacecount=$(ls -d /sys/class/ieee80211/* | wc -l) ifacenum=0 -# find each phy and configure in wirelss config +# find each phy and configure in wireless config for _dev in /sys/class/ieee80211/*; do [ -e "$_dev" ] || continue dev="${_dev##*/}" radio="radio${dev#phy}" + wlan="wlan${dev#phy}" if [ -x /usr/bin/readlink -a -h "/sys/class/ieee80211/${dev}" ]; then devpath="$(readlink -n -f /sys/class/ieee80211/${dev})" @@ -85,21 +94,19 @@ for _dev in /sys/class/ieee80211/*; do is_mesh_rf=0 hwmode="11g" htmode="HT20" + disabled="0" + chanbw="" + country="" + channel="" + distance="" iw phy "${dev}" info | grep -q '5180 MHz' && { hwmode="11a" } - if [[ $wifi2_enable -eq 1 -a \( $ifacecount -eq 1 -o \( \( $ifacecount -gt 1 \) -a \( "$hwmode" = "$wifi2_hwmode" \) \) \) ]] ; then - wifi2_disabled="0" - else - wifi2_disabled="1" - fi - if [ "${dev}" = "${meshphy}" ]; then # mesh RF adhoc configuration is_mesh_rf=1 - disabled="0" channel="${wifi_channel}" chanbw="${wifi_chanbw}" country="HX" @@ -109,12 +116,9 @@ for _dev in /sys/class/ieee80211/*; do encryption="none" key="" network="wifi" - else - disabled="${wifi2_disabled}" + elif [[ $wifi2_enable -eq 1 -a \( $ifacecount -eq 1 -o \( \( $ifacecount -gt 1 \) -a \( "$hwmode" = "$wifi2_hwmode" \) \) \) ]]; then + # LAN AP interface channel="${wifi2_channel}" - chanbw="" - country="" - distance="" ssid=$(echo "${wifi2_ssid}" | sed -e 's/\(..\)/\\x\1/g') ssid=$(echo -e "${ssid}") ssid=${ssid//\"/\\\"} @@ -124,6 +128,27 @@ for _dev in /sys/class/ieee80211/*; do key=$(echo -e "${key}") key=${key//\"/\\\"} network="lan" + elif [[ $wifi3_enable -eq 1 -a \( $ifacecount -eq 1 -o \( \( $ifacecount -gt 1 \) -a \( "$hwmode" = "$wifi3_hwmode" \) \) \) ]]; then + # WAN Client + disabled="0" + channel="" + ssid=$(echo "${wifi3_ssid}" | sed -e 's/\(..\)/\\x\1/g') + ssid=$(echo -e "${ssid}") + ssid=${ssid//\"/\\\"} + mode="sta" + encryption="psk2" + key=$(echo "${wifi3_key}" | sed -e 's/\(..\)/\\x\1/g') + key=$(echo -e "${key}") + key=${key//\"/\\\"} + network="wan" + htmode="" + uci -c ${dropdir} -q batch > /dev/null <<-EOF +set network.wan.ifname=$wlan +EOF + uci -c ${dropdir} -q commit network + else + # interface is disabled + disabled="1" fi uci -c ${dropdir} -q batch > /dev/null <<-EOF diff --git a/files/www/cgi-bin/perlfunc.pm b/files/www/cgi-bin/perlfunc.pm index a1128d14..aea9bda2 100644 --- a/files/www/cgi-bin/perlfunc.pm +++ b/files/www/cgi-bin/perlfunc.pm @@ -594,7 +594,7 @@ sub save_setup open(FILE, ">$_[0]") or return 0; foreach(sort keys %parms) { - next unless /^(aprs|dhcp|dmz|lan|olsrd|wan|wifi|wifi2|dtdlink|ntp|time|description)_/; + next unless /^(aprs|dhcp|dmz|lan|olsrd|wan|wifi|wifi2|wifi3|dtdlink|ntp|time|description)_/; print FILE "$_ = $parms{$_}\n"; } close(FILE); diff --git a/files/www/cgi-bin/setup b/files/www/cgi-bin/setup index 0a870151..d9458c8c 100755 --- a/files/www/cgi-bin/setup +++ b/files/www/cgi-bin/setup @@ -2,7 +2,7 @@ =for comment Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks - Copyright (C) 2015 Conrad Lara + Copyright (C) 2019 Joe Ayers AE6XE See Contributors file for additional contributors Copyright (c) 2013 David Rivenburg et al. BroadBand-HamNet @@ -113,6 +113,8 @@ else } $wifi2_key =~ s/([a-f0-9][a-f0-9])/chr(hex($1))/eg; $wifi2_ssid =~ s/([a-f0-9][a-f0-9])/chr(hex($1))/eg; + $wifi3_key =~ s/([a-f0-9][a-f0-9])/chr(hex($1))/eg; + $wifi3_ssid =~ s/([a-f0-9][a-f0-9])/chr(hex($1))/eg; } } @@ -128,7 +130,7 @@ else } # make sure unchecked checkboxes are accounted for -foreach(qw(lan_dhcp olsrd_bridge olsrd_gw wifi2_enable lan_dhcp_noroute wifi_enable)) +foreach(qw(lan_dhcp olsrd_bridge olsrd_gw wifi2_enable lan_dhcp_noroute wifi_enable wifi3_enable)) { $parms{$_} = 0 unless $parms{$_}; } @@ -450,9 +452,17 @@ if($parms{button_save}) { push (@errors, "LAN Access Point Password must be at least 8 characters, up to 64"); } + if( "$wifi3_enable" eq "1" and length($wifi3_key) > 64) + { + push (@errors, "WAN Wifi Client Password must not be greater than 64 characters"); + } if( "$wifi2_enable" eq "1" and ( $wifi2_key =~ /\'/ or $wifi2_ssid =~ /\'/ )) { - push (@errors, "The password and ssid may not contain a single quote character."); + push (@errors, "The LAN Access Point password and ssid may not contain a single quote character"); + } + if( "$wifi3_enable" eq "1" and ( $wifi3_key =~ /\'/ or $wifi3_ssid =~ /\'/ )) + { + push (@errors, "The WAN Wifi Client password and ssid may not contain a single quote character"); } if ( $wifi2_channel < 30 and "$wifi2_hwmode" eq "11a" ) @@ -467,7 +477,21 @@ if($parms{button_save}) { push (@errors, "Mesh RF and LAN Access Point can not both use the same wireless card, review LAN AP settings"); } - + if ( $phycount > 1 and ! $wifi_enable and $wifi2_hwmode eq $wifi3_hwmode ) + { + push (@errors, "Some settings auto updated to avoid conflicts, please review and save one more time"); + } + if ( $wifi_enable and $wifi2_enable and $wifi3_enable ) + { + push (@errors, "Can not enable Mesh RF, LAN AP, and WAN Wifi Client with only 2 wireless cards, WAN Wifi Client turned off"); + $wifi3_enable = 0; + } + if ( $phycount == 1 and $wifi_enable and ($wifi2_enable or $wifi3_enable )) + { + push (@errors, "Can not enable Mesh RF along with LAN AP or WAN Wifi Client. Only Mesh RF enabled now, please review settings."); + $wifi2_enable = 0; + $wifi3_enable = 0; + } if($debug == 3) # don't save the config, just validate it { @@ -481,6 +505,8 @@ if($parms{button_save}) system "touch /tmp/unconfigured" if -f "/etc/config/unconfigured"; $parms{wifi2_key} =~ s/(.)/sprintf("%x",ord($1))/eg; $parms{wifi2_ssid} =~ s/(.)/sprintf("%x",ord($1))/eg; + $parms{wifi3_key} =~ s/(.)/sprintf("%x",ord($1))/eg; + $parms{wifi3_ssid} =~ s/(.)/sprintf("%x",ord($1))/eg; $rc = save_setup("/etc/config.mesh/_setup"); $rc2 = &uci_commit("system"); if(-s "/tmp/web/save/node-setup.out") @@ -880,26 +906,55 @@ else print "
"; $M39model = `/usr/local/bin/get_model | grep -e "M[39]"`; -if ( $phycount > 1 or ! $wifi_enable and ! $M39model ) +if ( ($phycount > 1 and (! $wifi_enable or ! $wifi3_enable)) + or ($phycount == 1 and ! $wifi_enable and ! $wifi3_enable ) + and ! $M39model ) { + # LAN AP shows as an option - if ( $wifi_enable and "$wifi2_hwmode" eq "11g" ) + # Determine hardware options and set band and channels accordingly + + if ($phycount == 1) { - $wifi2_hwmode = "11a"; - if ( $wifi2_channel < 36 ) + $rc3 = system("iw phy phy0 info | grep -q '5180 MHz' > /dev/null"); + if ( $rc3 ) { - $wifi2_channel = 36; + $wifi2_hwmode="11g"; + if ( $wifi2_channel > 14 ) { $wifi2_channel = 1; } + @chan=@ctwo; + } + else + { + $wifi2_hwmode="11a"; + if ( $wifi2_channel < 36 ) { $wifi2_channel = 36; } + @chan=@cfive; + } + } + else + { + # 2 band device + if ( $wifi_enable == 1 ) + { + $wifi2_hwmode="11a"; + if ( $wifi2_channel < 36 ) { $wifi2_channel = 36; } + @chan=@cfive; + } + else + { + if ( ! $wifi2_enable and $wifi3_enable and $wifi3_hwmode eq "11a" ) { $wifi2_hwmode = "11g"; } + if ( ! $wifi2_enable and $wifi3_enable and $wifi3_hwmode eq "11g" ) { $wifi2_hwmode = "11a"; } + if ( $wifi2_hwmode eq "11a" ) + { + if ( $wifi2_channel < 36 ) { $wifi2_channel = 36; } + @chan=@cfive; + } + else + { + if ( $wifi2_channel > 14 ) { $wifi2_channel = 1; } + @chan=@ctwo; + } } } - - # determine AP's wireless phy - if ( "$wifi2_hwmode" eq "11g" and ! $wifi_enable ) - { $APphy="phy1"; } - else { $APphy="phy0"; } - - $rc3 = system("iw phy ${APphy} info | grep -q '5180 MHz' > /dev/null"); - undef @chan; - if ( $rc3 ) { @chan=@ctwo; } else { @chan=@cfive; } print "LAN Access Point"; print "Enable"; @@ -916,6 +971,10 @@ if ( $phycount > 1 or ! $wifi_enable and ! $M39model ) selopt("5GHz", "11a", $wifi2_hwmode); print "\n"; } + else + { + push @hidden, ""; + } print "SSID\n"; print "\n"; @@ -1011,11 +1070,90 @@ print " /dev/null"); + if ( $rc3 ) { $wifi3_hwmode="11g"; } + else { $wifi3_hwmode="11a"; } + } + else + { + # 2 band device + if ( $wifi_enable ) { $wifi3_hwmode="11a"; } + else + { + if ( $wifi2_hwmode eq "11g" and $wifi2_enable ) + { + $wifi3_hwmode = "11a"; + } + if ( $wifi2_hwmode eq "11a" and $wifi2_enable ) + { + $wifi3_hwmode="11g"; + } + } + } + + print "
\n"; + print "WAN Wifi Client"; + print "Enable"; + print "\n"; + + if ( ! $wifi_enable and ! $wifi2_enable and $phycount > 1) + { + print "WAN Wifi Client band\n"; + print "\n"; + } + else + { + push @hidden, ""; + } + +# for (my $i=0; $i<5; $i++) +# { +# @wan_ssids=`iw dev wlan0 scan passive | egrep "SSID:\\s\\S+" | cut -f 2 -d\\ | sort -u`; +# last if @wan_ssids; +# sleep 1; +# } + + print "SSID\n"; + print "\n"; + print "\n"; + + print "Password\n"; + print ""; + print "\n"; + +} +else +{ + push @hidden, ""; + push @hidden, ""; + push @hidden, ""; + push @hidden, ""; +} +# end WAN wifi Client + +print "\n\n"; + +print "
- \n"; # diff --git a/files/www/help.html b/files/www/help.html index 6450c95c..662965ef 100644 --- a/files/www/help.html +++ b/files/www/help.html @@ -17,6 +17,9 @@ Table of Contents: