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 "
The LAN box allows you to set the LAN IP Address of the node and the address range of the DHCP server, and these should be -self explanatory. The LAN Mode is described in the next section. -
- -
-The LAN Access Point section will appear on the hAP ac
-lite device. Configure similar to a typical home access point. DFS channels
-are currently not selectable. Access Points must detect Doppler Radar signals
-and dynamically move to a clear channel for part 15 compliance. This capability
-and channels may be added in a future image. Clients connecting to the LAN Access
-Point share the IP Address range with clients attached though the physical Ethernet
-ports.
The Encryption option 'none' is not given to enable operator control
-of who is connecting to the mesh network and manage compliance of part 97
-obligations.
The password key length must be between 8 and 63 characters.
-If the key is 64 characters, it is treated as hex encoded. A single quote character
-may not be used.
-The WAN box contains the settings used to -connect with an upstream network, usually an internet connection. The DNS -servers are set by default to the Google DNS servers and should not be changed -under normal circumstances. More and more ISP's are adopting the "helpful" -but broken behavior of taking you to an ISP generated web page if you -incorrectly type in a URL or if the host you are trying to reach no longer -exists. The proper behavior is for your browser to be able to detect these -error conditions and report them accordingly. Google follows the rules and -allows for the proper operation of the network. -
--When the WAN protocol is set to disabled you have the option of using a -default gateway on the LAN. Integrating an existing LAN with a mesh node LAN -is an expert level undertaking and there are far too many considerations to be -covered here. -
-
-The Allow others to use my WAN is an Advanced WAN option.
-
When a node has internet access from either the WAN or LAN, that access is
-available to the node itself and to any computer connected to the LAN network.
-When this option is enabled this node will gate(route) traffic from the
-mesh onto this network and the internet.
-
-By default it is disabled, so consider carefully your
-intentions for enabling it. AREDN™ is an FCC Part 97 amateur radio
-computer network, so be sure that any internet traffic that will be sent over
-radio needs to comply with Part 97 rules. If you just want local wireless
-internet access, consider using a standard Part 15 compliant access point
-instead of the Mesh Gateway function.
-
-
-The Prevent LAN devices from accessing WAN checkbox will
-cause the node to not advertise to LAN devices that it should be chosen
-as the default route. This means that computers on the LAN of this node
-will not try and route to the internet or other networks via the mesh node
-and will only try and use the mesh node for the 10.0.0.0/8 and 172.16.0.0/12
-"mesh" network ranges. You will not be able to access the internet, even
-if your node has internet available on its WAN port with this setting checked.
-This also applies to internet available over the mesh. Use this only if you
-know what a default route is and you need to be connected to two networks at
-once such as wired to the mesh, and WiFi to a local served agency network.
+self explanatory.
@@ -511,6 +457,83 @@ provided by computers on the LAN can only be accessed through port forwarding
rules. A single DMZ server can be set up to accept all incoming traffic that
is not already handled by other rules or by the node itself.
+
+LAN Access Point
+
+The LAN Access Point section will appear on the hAP ac
+lite device. Configure similar to a typical home access point. DFS channels
+are currently not selectable. Access Points must detect Doppler Radar signals
+and dynamically move to a clear channel for part 15 compliance. This capability
+and channels may be added in a future image. Clients connecting to the LAN Access
+Point share the IP Address range with clients attached though the physical Ethernet
+ports.
The Encryption option 'none' is not given to enable operator control
+of who is connecting to the mesh network and manage compliance of part 97
+obligations.
The password key length must be between 8 and 63 characters.
+If the key is 64 characters, it is treated as hex encoded. A single quote character
+may not be used.
+
+WAN Settings
+
+The WAN box contains the settings used to +connect with an upstream network, usually an internet connection. The DNS +servers are set by default to the Google DNS servers and should not be changed +under normal circumstances. More and more ISP's are adopting the "helpful" +but broken behavior of taking you to an ISP generated web page if you +incorrectly type in a URL or if the host you are trying to reach no longer +exists. The proper behavior is for your browser to be able to detect these +error conditions and report them accordingly. Google follows the rules and +allows for the proper operation of the network. +
++When the WAN protocol is set to disabled you have the option of using a +default gateway on the LAN. Integrating an existing LAN with a mesh node LAN +is an expert level undertaking and there are far too many considerations to be +covered here. +
+
+The Allow others to use my WAN is an Advanced WAN option.
+
When a node has internet access from either the WAN or LAN, that access is
+available to the node itself and to any computer connected to the LAN network.
+When this option is enabled this node will gate(route) traffic from the
+mesh onto this network and the internet.
+
+By default it is disabled, so consider carefully your
+intentions for enabling it. AREDN™ is an FCC Part 97 amateur radio
+computer network, so be sure that any internet traffic that will be sent over
+radio needs to comply with Part 97 rules. If you just want local wireless
+internet access, consider using a standard Part 15 compliant access point
+instead of the Mesh Gateway function.
+
+
+The Prevent LAN devices from accessing WAN checkbox will
+cause the node to not advertise to LAN devices that it should be chosen
+as the default route. This means that computers on the LAN of this node
+will not try and route to the internet or other networks via the mesh node
+and will only try and use the mesh node for the 10.0.0.0/8 and 172.16.0.0/12
+"mesh" network ranges. You will not be able to access the internet, even
+if your node has internet available on its WAN port with this setting checked.
+This also applies to internet available over the mesh. Use this only if you
+know what a default route is and you need to be connected to two networks at
+once such as wired to the mesh, and WiFi to a local served agency network.
+
+
+WAN Wifi Client
+
+The WAN Wifi Client feature enables connecting the mesh node to the Internet or foreign network
+available on a wifi Access Point. Enabling the WAN Wifi Client will disable vlan1
+and access to the Internet over the physical Ethernet port. Type in the SSID and password
+to connect to. If the device is dual-band, e.g. an hAP a lite, the band option will be
+shown.
The password key length must not be greater than 64 characters. If the key
+lenght is 64, it is treated as hex encoded. A single quote character
+may not be used.