#!/usr/bin/webif-page
###
#
# FreeWLAN Addons - http://www.freewlan.info
#
# This Script is based on work from http://www.fonfan.de
#
# 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; either version 2
# of the License, or (at your option) any later version.
#
# 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, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA
#
# http://www.gnu.org/copyleft/gpl.html
#
###
. /usr/lib/webif/webif.sh
config_load router
config_get mode mode mode
config_get ssid mode ssid
config_get rssid mode rssid
config_get repeater_ssid mode ssid
config_load fon
. /tmp/network-config
get_default wanmode wan mode
case "$FORM_wanmode" in
static)
wanmode="Static"
;;
dhcp)
wanmode="DHCP"
;;
pppoe)
wanmode="PPPoE"
;;
pptp)
wanmode="PPTP"
;;
*) wanmode="Unknown";;
esac
config_get pubssid public essid
config_get privssid private essid
config_get encryption private encryption
pub_mac="$(ifconfig ath0 | grep HWaddr | awk -F'[ ]+' '{print $5}')"
priv_mac="$(ifconfig ath1 | grep HWaddr | awk -F'[ ]+' '{print $5}')"
bridge_ip="$(ifconfig ath0 | grep inet | awk -F'[: ]+' '{print $4}')"
priv_ip="$(ifconfig ath1 | grep inet | awk -F'[: ]+' '{print $4}')"
wan_mac="$(ifconfig eth0 | grep HWaddr | awk -F'[ ]+' '{print $5}')"
wan_ip="$(ifconfig "${wan_ifname:-eth0}" | grep inet | awk -F'[: ]+' '{print $4}')"
wan_gw="$(route -n | grep '^0.0.0.0' | awk '{print $2}')"
#wan_ns=
for ns in $(grep nameserver /etc/resolv.conf | awk '{print $2}'); do
wan_ns="${wan_ns:+$wan_ns, }$ns"
done
version="$(cat /etc/fon_version) r$(cat /etc/fon_revision)"
addonversion="$(cat /etc/addon_version)"
connected=""
if [ -f /var/dhcp.leases ]; then
for con in $(cat /var/dhcp.leases | awk '{printf "MAC: %s IP: %s PC: %s
", $2, $3, $4}'); do
connected="${connected:+$connected}$con"
done
fi
connected="$(echo $connected | tr a-z A-Z | sed -e "s/NBSP/nbsp/g")"
header "Router Status - Freewlan Addons $addonversion"
case "$mode" in
1) cat <
@TR<> |
|
@TR<> |
| $connected |
|
@TR<> |
| @TR<> | $version |
| @TR<> | $addonversion |
|
@TR<> |
| @TR<> | $wanmode |
| @TR<> | $wan_mac |
| @TR<> | ${wan_ip:-N/A} |
| @TR<> | ${wan_gw:-N/A} |
| @TR<> | ${wan_ns:-N/A} |
|
@TR<> |
| @TR<> | FON_$pubssid |
| @TR<> | $pub_mac |
| @TR<> | $privssid |
| @TR<> | $priv_mac |
| @TR<> | ${encryption:-none} |
| @TR<> | ${priv_ip:-N/A} |
EOF
;;
2) cat <
@TR<> |
|
@TR<> |
| $connected |
|
@TR<> |
| @TR<> | $version |
| @TR<> | $addonversion |
|
@TR<> |
| @TR<> | $ssid |
| @TR<> | ${bridge_ip:-N/A} |
| @TR<> | ${wan_gw:-N/A} |
| @TR<> | ${wan_ns:-N/A} |
|
@TR<> |
| @TR<> | $repeater_ssid |
| @TR<> | $pub_mac |
EOF
;;
esac
footer ?>