mirror of https://github.com/aredn/aredn.git
feature: Add function and code to UI code to prepare for changing interface names in the core OS.
Create get_interface which will lookup in the current uci network config the realname for the logical interface name. When the interface is not found it will fall back to a hard coded list. Configure the UI to use the new get_interface function.
This commit is contained in:
parent
097d62ae01
commit
9444716fbd
|
@ -139,7 +139,8 @@ sub is_channel_valid
|
|||
# We don't have the device band in the data file so lets fall back to checking manually
|
||||
else {
|
||||
my $channelok=0;
|
||||
foreach (`iwinfo wlan0 freqlist`)
|
||||
my $wifiintf = get_interface("wifi");
|
||||
foreach (`iwinfo $wifiintf freqlist`)
|
||||
{
|
||||
next unless /Channel $channel/;
|
||||
next if /\[restricted\]/;
|
||||
|
@ -166,7 +167,8 @@ sub rf_channels_list
|
|||
else
|
||||
{
|
||||
my %channels = ();
|
||||
foreach (`iwinfo wlan0 freqlist` )
|
||||
my $wifiintf = get_interface("wifi");
|
||||
foreach (`iwinfo $wifiintf freqlist` )
|
||||
{
|
||||
next unless /([0-9]+.[0-9]+) GHz \(Channel ([0-9]+)\)/;
|
||||
next if /\[restricted\]/;
|
||||
|
|
|
@ -47,7 +47,7 @@ $node = "NOCALL" if $node eq "";
|
|||
$tactical = nvram_get("tactical");
|
||||
$config = nvram_get("config");
|
||||
$config = "not set" if $config eq "" or not -d "/etc/config.$config";
|
||||
($my_ip) = get_ip4_network("wlan0");
|
||||
($my_ip) = get_ip4_network(get_interface("wifi"));
|
||||
|
||||
read_postdata();
|
||||
|
||||
|
|
|
@ -286,14 +286,7 @@ sub reboot_page
|
|||
$link = "/cgi-bin/status" unless $link;
|
||||
|
||||
# is the browser coming from the lan?
|
||||
if(system "ifconfig br-lan >/dev/null 2>&1")
|
||||
{
|
||||
($lanip, $lanmask, $junk, $lannet) = &get_ip4_network("eth0");
|
||||
}
|
||||
else
|
||||
{
|
||||
($lanip, $lanmask, $junk, $lannet) = &get_ip4_network("br-lan");
|
||||
}
|
||||
($lanip, $lanmask, $junk, $lannet) = &get_ip4_network(get_interface("lan"));
|
||||
my($browser) = $ENV{REMOTE_ADDR} =~ /::ffff:([\d\.]+)/;
|
||||
my $fromlan = validate_same_subnet($browser, $lanip, $lanmask);
|
||||
$junk = ""; # dummy to avoid warning
|
||||
|
@ -538,8 +531,8 @@ sub load_cfg
|
|||
{
|
||||
#my $mac2 = nvram_get("mac2");
|
||||
my $node = nvram_get("node");
|
||||
my $mac2 = mac2ip(get_mac("wlan0"), 0);
|
||||
my $dtdmac = mac2ip(get_mac("eth0"), 0);
|
||||
my $mac2 = mac2ip(get_mac(get_interface("wifi")), 0);
|
||||
my $dtdmac = mac2ip(get_mac(get_interface("lan")), 0);
|
||||
open(FILE, $_[0]) or return 0;
|
||||
while(defined ($line = <FILE>))
|
||||
{
|
||||
|
@ -1280,7 +1273,8 @@ sub wifi_useschains
|
|||
#has increased it to a higher level.
|
||||
sub wifi_txpoweroffset
|
||||
{
|
||||
my $doesiwoffset=`iwinfo wlan0 info 2>/dev/null` =~ /TX power offset: (\d+)/;
|
||||
my $wlanintf = get_interface("wifi");
|
||||
my $doesiwoffset=`iwinfo $wlanintf info 2>/dev/null` =~ /TX power offset: (\d+)/;
|
||||
if ( $doesiwoffset ) {
|
||||
return $1;
|
||||
} else
|
||||
|
@ -1339,5 +1333,33 @@ sub page_footer
|
|||
print "</div>"
|
||||
}
|
||||
|
||||
|
||||
sub get_interface
|
||||
{
|
||||
my ($intfname) = @_;
|
||||
my $intfname = `uci -q get network.$intfname.ifname`;
|
||||
chomp $intfname;
|
||||
|
||||
if ($intfname) {
|
||||
return $intfname;
|
||||
} else {
|
||||
# Capture rules incase uci file is not in sync.
|
||||
if ( $intfname eq "lan" )
|
||||
{
|
||||
return "eth0";
|
||||
} elsif ( $intfname eq "wan" ){
|
||||
return "eth0.1";
|
||||
} elsif ( $intfname eq "wifi" ){
|
||||
return "wlan0";
|
||||
} elsif ( $intfname eq "dtdlink" ){
|
||||
return "eth0.1";
|
||||
} else {
|
||||
# we have a problem
|
||||
die("Unknown interface in call to get_interface");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#weird uhttpd/busybox error requires a 1 at the end of this file
|
||||
1
|
||||
|
|
|
@ -75,14 +75,7 @@ else { $dmz_mode = 0 }
|
|||
|
||||
# get the network details of the lan interface for dhcp calculations
|
||||
|
||||
if(system "ifconfig br-lan >/dev/null 2>&1")
|
||||
{
|
||||
($lanip, $lanmask, $junk, $lannet, $lancidr) = get_ip4_network("eth0");
|
||||
}
|
||||
else
|
||||
{
|
||||
($lanip, $lanmask, $junk, $lannet, $lancidr) = get_ip4_network("br-lan");
|
||||
}
|
||||
($lanip, $lanmask, $junk, $lannet, $lancidr) = get_ip4_network(get_interface("lan"));
|
||||
|
||||
$lannet_d = ip2decimal($lannet);
|
||||
|
||||
|
|
|
@ -130,8 +130,9 @@ $parms{dmz_dhcp_limit} = $dmz_dhcp_limit = $dmz_dhcp_end - $dmz_dhcp_start + 1;
|
|||
|
||||
unless($parms{reload})
|
||||
{
|
||||
($wifi_txpower) = `iwinfo wlan0 info 2>/dev/null` =~ /Tx-Power: (\d+)/;
|
||||
(my $doesiwoffset) = `iwinfo wlan0 info 2>/dev/null` =~ /TX power offset: (\d+)/;
|
||||
my $wifiintf = get_interface("wifi");
|
||||
($wifi_txpower) = `iwinfo $wifiintf info 2>/dev/null` =~ /Tx-Power: (\d+)/;
|
||||
(my $doesiwoffset) = `iwinfo $wifiintf info 2>/dev/null` =~ /TX power offset: (\d+)/;
|
||||
if ( $doesiwoffset ) {
|
||||
$wifi_txpower -= $1;
|
||||
}
|
||||
|
@ -173,6 +174,7 @@ $parms{wifi_rxant} = $wifi_rxant;
|
|||
|
||||
if($parms{button_apply} or $parms{button_save})
|
||||
{
|
||||
my $wifiintf = get_interface("wifi");
|
||||
$cmd = "";
|
||||
if(wifi_useschains()){
|
||||
$cmd .= "echo $wifi_rxant > /sys/kernel/debug/ieee80211/phy0/ath9k/rx_chainmask;";
|
||||
|
@ -185,7 +187,7 @@ if($parms{button_apply} or $parms{button_save})
|
|||
$cmd .= "ifup wifi_mon >/dev/null 2>&1;";
|
||||
}
|
||||
$cmd .= "iw phy phy0 set distance $wifi_distance >/dev/null 2>&1;";
|
||||
$cmd .= "iw dev wlan0 set txpower fixed ${wifi_txpower}00 >/dev/null 2>&1;";
|
||||
$cmd .= "iw dev $wifiintf set txpower fixed ${wifi_txpower}00 >/dev/null 2>&1;";
|
||||
system $cmd;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ system "rm -f /tmp/web/siglevel" if $parms{start};
|
|||
|
||||
# get the current levels
|
||||
|
||||
($s, $n) = get_wifi_signal("wlan0");
|
||||
($s, $n) = get_wifi_signal(get_interface("wifi"));
|
||||
if($s eq "N/A") { $s = $n = "---" }
|
||||
|
||||
# load the previous levels
|
||||
|
|
|
@ -136,61 +136,43 @@ $browser_ip = "";
|
|||
|
||||
# left column - network interface info
|
||||
|
||||
if(system "ifconfig br-lan >/dev/null 2>&1") # lan not bridged
|
||||
# show the wifi address
|
||||
($ip, $mask, $bcast, $net, $cidr) = get_ip4_network(get_interface("wifi"));
|
||||
$cidr = "/ $cidr" if $cidr;
|
||||
$str = "<th align=right><nobr>WiFi address</nobr></th><td>$ip <small>$cidr</small><br>";
|
||||
$str .= "<small><nobr>" . get_ip6_addr(get_interface("wifi")) . "</nobr></small></td>";
|
||||
push @col1, $str;
|
||||
|
||||
# find out if the browser is on this node's lan
|
||||
# if not, hide the local network details
|
||||
($ip, $mask, $bcast, $net, $cidr) = get_ip4_network(get_interface("lan"));
|
||||
if($ENV{REMOTE_ADDR} =~ /::ffff:([\d\.]+)/)
|
||||
{
|
||||
# show the wifi address
|
||||
($ip, $mask, $bcast, $net, $cidr) = get_ip4_network("wlan0");
|
||||
$cidr = "/ $cidr" if $cidr;
|
||||
$str = "<th align=right><nobr>WiFi address</nobr></th><td>$ip <small>$cidr</small><br>";
|
||||
$str .= "<small><nobr>" . get_ip6_addr("wlan0") . "</nobr></small></td>";
|
||||
push @col1, $str;
|
||||
|
||||
# find out if the browser is on this node's lan
|
||||
# if not, hide the local network details
|
||||
($ip, $mask, $bcast, $net, $cidr) = get_ip4_network("eth0");
|
||||
if($ENV{REMOTE_ADDR} =~ /::ffff:([\d\.]+)/)
|
||||
{
|
||||
$browser_ip = $1;
|
||||
$hide_local = 1 unless validate_same_subnet($browser_ip, $ip, $mask);
|
||||
}
|
||||
|
||||
if($ip =~ /^10\./ or not $hide_local)
|
||||
{
|
||||
$cidr = "/ $cidr" if $cidr;
|
||||
$str = "<th align=right><nobr>LAN address</nobr></th><td>$ip <small>$cidr</small><br>";
|
||||
$str .= "<small><nobr>" . get_ip6_addr("eth0") . "</nobr></small></td>";
|
||||
push @col1, $str;
|
||||
}
|
||||
}
|
||||
else # lan is bridged
|
||||
{
|
||||
# show the wifi/lan bridge address unless the browser is on a different network
|
||||
($ip, $mask, $bcast, $net, $cidr) = get_ip4_network("br-lan");
|
||||
if($ENV{REMOTE_ADDR} =~ /::ffff:([\d\.]+)/)
|
||||
{
|
||||
$browser_ip = $1;
|
||||
$hide_local = 1 unless validate_same_subnet($browser_ip, $ip, $mask);
|
||||
}
|
||||
|
||||
unless($hide_local)
|
||||
{
|
||||
$cidr = "/ $cidr" if $cidr;
|
||||
$str = "<th align=right><nobr>WiFi/LAN address</nobr></th><td>$ip <small>$cidr</small><br>";
|
||||
$str .= "<small><nobr>" . get_ip6_addr("br-lan") . "</nobr></small></td>";
|
||||
push @col1, $str;
|
||||
}
|
||||
$browser_ip = $1;
|
||||
$hide_local = 1 unless validate_same_subnet($browser_ip, $ip, $mask);
|
||||
}
|
||||
|
||||
if(not $hide_local and not system "ifconfig eth0.1 >/dev/null 2>&1")
|
||||
if($ip =~ /^10\./ or not $hide_local)
|
||||
{
|
||||
($ip, $mask, $bcast, $net, $cidr) = get_ip4_network("eth0.1");
|
||||
$cidr = "/ $cidr" if $cidr;
|
||||
$cidr = "" unless $cidr;
|
||||
$str = "<th align=right><nobr>WAN address</nobr></th><td>$ip <small>$cidr</small><br>";
|
||||
$str .= "<small><nobr>" . get_ip6_addr("eth0.1") . "</nobr></small></td>";
|
||||
$str = "<th align=right><nobr>LAN address</nobr></th><td>$ip <small>$cidr</small><br>";
|
||||
$str .= "<small><nobr>" . get_ip6_addr(get_interface("lan")) . "</nobr></small></td>";
|
||||
push @col1, $str;
|
||||
}
|
||||
|
||||
{
|
||||
my $wanintf = get_interface("wan");
|
||||
if(not $hide_local and not system "ifconfig $wanintf >/dev/null 2>&1")
|
||||
{
|
||||
($ip, $mask, $bcast, $net, $cidr) = get_ip4_network("$wanintf");
|
||||
$cidr = "/ $cidr" if $cidr;
|
||||
$cidr = "" unless $cidr;
|
||||
$str = "<th align=right><nobr>WAN address</nobr></th><td>$ip <small>$cidr</small><br>";
|
||||
$str .= "<small><nobr>" . get_ip6_addr("$wanintf") . "</nobr></small></td>";
|
||||
push @col1, $str;
|
||||
}
|
||||
}
|
||||
|
||||
$ip = get_default_gw();
|
||||
|
||||
if($ip =~ /^10\./ or not $hide_local)
|
||||
|
@ -232,7 +214,7 @@ if(-f "/tmp/olsrd.log")
|
|||
if($config eq "mesh" or $config eq "client")
|
||||
{
|
||||
$str = "<th align=right valign=middle><nobr>Signal/Noise/Ratio</nobr></th><td valign=middle><nobr>";
|
||||
($s, $n) = get_wifi_signal("wlan0");
|
||||
($s, $n) = get_wifi_signal(get_interface("wifi"));
|
||||
if($s eq "N/A") { $str .= "N/A" }
|
||||
else { $str .= sprintf "<big><b>%d / %d / %d dB</b></big>", $s, $n, $s - $n }
|
||||
$str .= " ";
|
||||
|
|
Loading…
Reference in New Issue