2015-01-18 12:36:49 -07:00
|
|
|
=for commnet
|
|
|
|
|
2015-03-09 17:39:04 -06:00
|
|
|
Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks
|
2015-01-18 12:36:49 -07:00
|
|
|
Copyright (C) 2015 Conrad Lara
|
|
|
|
See Contributors file for additional contributors
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation version 3 of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2015-03-09 17:39:04 -06:00
|
|
|
Additional Terms:
|
|
|
|
|
|
|
|
Additional use restrictions exist on the AREDN(TM) trademark and logo.
|
|
|
|
See AREDNLicense.txt for more info.
|
|
|
|
|
|
|
|
Attributions to the AREDN Project must be retained in the source code.
|
|
|
|
If importing this code into a new or existing project attribution
|
|
|
|
to the AREDN project must be added to the source code.
|
|
|
|
|
|
|
|
You must not misrepresent the origin of the material conained within.
|
|
|
|
|
|
|
|
Modified versions must be modified to attribute to the original source
|
|
|
|
and be marked in reasonable ways as differentiate it from the original
|
|
|
|
version.
|
|
|
|
|
2015-01-18 12:36:49 -07:00
|
|
|
=cut
|
2014-03-27 23:53:06 -06:00
|
|
|
|
|
|
|
use perlfunc;
|
|
|
|
|
|
|
|
#############################
|
|
|
|
|
|
|
|
#
|
|
|
|
# @returns all channels, or specific band lis
|
|
|
|
sub rf_channel_map
|
|
|
|
{
|
|
|
|
%channellist = (
|
2014-07-15 00:01:16 -06:00
|
|
|
'900' => {
|
|
|
|
4 => "(907)",
|
|
|
|
5 => "(912)",
|
|
|
|
6 => "(917)",
|
|
|
|
7 => "(922)",
|
|
|
|
},
|
2014-03-27 23:53:06 -06:00
|
|
|
'2400' => {
|
|
|
|
1 => "1 (2412)",
|
|
|
|
2 => "2 (2417)",
|
|
|
|
3 => "3 (2422)",
|
|
|
|
4 => "4 (2427)",
|
|
|
|
5 => "5 (2432)",
|
|
|
|
6 => "6 (2437)",
|
|
|
|
7 => "7 (2442)",
|
|
|
|
8 => "8 (2447)",
|
|
|
|
9 => "9 (2452)",
|
|
|
|
10 => "10 (2457)",
|
|
|
|
11 => "11 (2462)",
|
|
|
|
},
|
|
|
|
'5500' => {
|
|
|
|
37 => "36 (5190)",
|
|
|
|
40 => "40 (5200)",
|
|
|
|
44 => "44 (5220)",
|
|
|
|
48 => "48 (5240)",
|
|
|
|
52 => "52 (5260)",
|
|
|
|
56 => "56 (5280)",
|
|
|
|
60 => "60 (5300)",
|
|
|
|
64 => "64 (5320)",
|
|
|
|
100 => "100 (5500)",
|
|
|
|
104 => "104 (5520)",
|
|
|
|
108 => "108 (5540)",
|
|
|
|
112 => "112 (5560)",
|
|
|
|
116 => "116 (5580)",
|
|
|
|
120 => "120 (5600)",
|
|
|
|
124 => "124 (5620)",
|
|
|
|
128 => "128 (5640)",
|
|
|
|
132 => "132 (5660)",
|
|
|
|
136 => "136 (5680)",
|
|
|
|
140 => "140 (5700)",
|
|
|
|
149 => "149 (5745)",
|
|
|
|
153 => "153 (5765)",
|
|
|
|
157 => "157 (5785)",
|
|
|
|
161 => "161 (5805)",
|
|
|
|
165 => "165 (5825)",
|
|
|
|
},
|
|
|
|
# 5800 UBNT US Band
|
|
|
|
# Limiting to US speced channels until the hardware can be tested
|
|
|
|
# lower into the spectrum.
|
|
|
|
'5800ubntus' => {
|
|
|
|
149 => "149 (5745)",
|
|
|
|
153 => "153 (5765)",
|
|
|
|
157 => "157 (5785)",
|
|
|
|
161 => "161 (5805)",
|
|
|
|
165 => "165 (5825)",
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
my($reqband) = @_;
|
|
|
|
|
|
|
|
if ( defined($reqband) ){
|
|
|
|
if ( exists($channellist{$reqband}) ){
|
|
|
|
return $channellist{$reqband};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return $channellist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub is_channel_valid
|
|
|
|
{
|
|
|
|
my ($channel) = @_;
|
|
|
|
|
|
|
|
if ( !defined($channel) ) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$boardinfo=hardware_info();
|
|
|
|
#We know about the band so lets use it
|
|
|
|
if ( exists($boardinfo->{'rfband'}))
|
|
|
|
{
|
|
|
|
$validchannels=rf_channel_map($boardinfo->{'rfband'});
|
|
|
|
|
|
|
|
if ( exists($validchannels->{$channel}) )
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# We don't have the device band in the data file so lets fall back to checking manually
|
|
|
|
else {
|
|
|
|
my $channelok=0;
|
2014-05-09 23:40:11 -06:00
|
|
|
foreach (`iwinfo wlan0 freqlist`)
|
2014-03-27 23:53:06 -06:00
|
|
|
{
|
|
|
|
next unless /Channel $channel/;
|
2014-05-01 21:32:40 -06:00
|
|
|
next if /\[restricted\]/;
|
2014-03-27 23:53:06 -06:00
|
|
|
$channelok=1;
|
|
|
|
}
|
|
|
|
return $channelok;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub rf_channels_list
|
|
|
|
{
|
|
|
|
|
|
|
|
$boardinfo=hardware_info();
|
|
|
|
#We know about the band so lets use it
|
|
|
|
if ( exists($boardinfo->{'rfband'}))
|
|
|
|
{
|
|
|
|
if (rf_channel_map($boardinfo->{'rfband'}) != -1 )
|
|
|
|
{
|
|
|
|
return rf_channel_map($boardinfo->{'rfband'});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
my %channels = ();
|
2014-05-01 21:32:40 -06:00
|
|
|
foreach (`iwinfo wlan0 freqlist` )
|
2014-03-27 23:53:06 -06:00
|
|
|
{
|
2014-05-09 23:40:11 -06:00
|
|
|
next unless /([0-9]+.[0-9]+) GHz \(Channel ([0-9]+)\)/;
|
2014-05-01 21:32:40 -06:00
|
|
|
next if /\[restricted\]/;
|
|
|
|
my $channelnum = $2;
|
|
|
|
my $channelfreq = $1;
|
2014-04-20 00:51:55 -06:00
|
|
|
$channelnum =~s/^0+//g;
|
|
|
|
$channels->{$channelnum} = "$channelfreq GHZ" ;
|
2014-03-27 23:53:06 -06:00
|
|
|
}
|
|
|
|
return $channels;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-14 21:40:49 -06:00
|
|
|
sub is_wifi_chanbw_valid
|
|
|
|
{
|
2015-03-09 17:39:04 -06:00
|
|
|
# chan_bw valid
|
2014-07-14 21:40:49 -06:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-03-27 23:53:06 -06:00
|
|
|
#weird uhttpd/busybox error requires a 1 at the end of this file
|
|
|
|
1
|
|
|
|
|