#!/bin/sh echo Content-type: text/html echo cat<<EOF

HomeKontaktOpenWRT-Admin |  |

# Inhalt

Status
Verwalten

EOF WLDEV=$(nvram get wl0_ifname) if [ "$REQUEST_METHOD" = "POST" ]; then read QUERY_STRING fi if [ -n "$QUERY_STRING" ]; then eval $(echo "${QUERY_STRING%%[^%&=+-:@-_a-z~]*}"|awk -F'&' '{for(i=1;i<=NF;i++)if($i~/^[a-z0-9_]+=/){print $i}}') fi if [ -n "$post_olsr" ]; then cat<<EOF

# Status: OLSR

EOF if [ "$(nvram get wl0_mode)" != "ap" ];then cat<<EOF EOF fi if [ "$(nvram get ff_httpinfo)" != "0" ];then cat<<EOF EOF fi cat<<EOF

EOF wget -O - http://127.0.0.1:8080/all|awk ' /

## /, /<\/div>/ { gsub("border=0", "border=1 cellspacing=0 cellpadding=0") gsub("BORDER=0", "BORDER=1") gsub("<select", "<select name=none") print }' cat<<EOF </TD>

EOF elif [ -n "$post_route" ]; then cat<<EOF

# Status: Routen

EOF if [ "$(nvram get wl0_mode)" != "ap" ];then cat<<EOF EOF fi if [ "$(nvram get ff_httpinfo)" != "0" ];then cat<<EOF EOF fi cat<<EOF
", s); } function ip(s) { if(s!~/\.0$/) { td(sprintf("%s", s, s)); } else { td(s); } } BEGIN { print "<""TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\">"; } /^[0-9]/ { printf "
EOF route -n|awk ' function td(s) { printf(" | %s
"; ip($1); ip($2); for(i=3;i<=NF;i++) td($i); printf "
\n"; } /^Destination/ { printf "
"; for(i=1;i<=NF;i++) printf("
", $i); printf "
%s
\n"; } END { print "<""/TABLE>"; }' cat<<EOF

EOF elif [ -n "$post_scan" ]; then cat<<EOF

# Status: WLAN Suche

EOF if [ "$(nvram get wl0_mode)" != "ap" ];then cat<<EOF EOF fi if [ "$(nvram get ff_httpinfo)" != "0" ];then cat<<EOF EOF fi cat<<EOF
SSID | Kanal | Ad Hoc | Signal | Open | Max. | BSSID
--- | --- | --- | --- | --- | --- | ---
EOF wl -i $WLDEV scan sleep 2 wl -i $WLDEV scanresults|awk ' BEGIN { print "
"; } /^SSID:/ { ssid=substr($2, 2, length($2) - 2); chan=" "; adhoc="no"; rssi="0"; titl=" "; wep="no"; rate=" "; bssid=" "; do { if(!(getline))break; if (/Channel:/) { chan=$NF; } if (/Mode:/) { adhoc=($2~/Managed/?"no":"yes"); } if (/RSSI:/) { rssi=int(($(4+($3~/Hoc/))-$(7+($3~/Hoc/)))/4); for(i=3; i<=8; i++) { titl=titl$(i+($3~/Hoc/))" "; } if (0 > rssi) rssi = 0; if (5 < rssi) rssi = 5; } if (/Capability:/) { for(i = 4; i <= NF; i++) { if ($i~/^WEP/) wep="yes"; } } if (/Supported Rates:/) { rate=$(NF - 1); } if (/BSSID:/) { bssid=$2; } } while(/\S/); print "
" print "
" print "
" print "
" print "
" print "
" print "
" print "
" print "
"ssid" | "chan" |  |  |  | "rate" | "bssid"
"; } END { print "
" }' cat<<EOF

EOF else cat<<EOF

# Status: Übersicht

EOF if [ "$(nvram get wl0_mode)" != "ap" ];then cat<<EOF EOF fi if [ "$(nvram get ff_httpinfo)" != "0" ];then cat<<EOF EOF fi cat<<EOF
IP Adresse: | IP: $(ifconfig $WLDEV|awk 'sub("inet addr:","") {print $1}'), Maske: $(ifconfig $WLDEV|awk 'sub("Mask:","") {print $4}'), MAC: $(ifconfig $WLDEV|awk 'sub("HWaddr","") {print $4}')

WLAN-Status:

SSID: $(wl -i $WLDEV ssid|awk 'sub("Current SSID:","") {print $1}'), Modus: $(wl -i $WLDEV status|awk 'sub("Mode:","") {print $1 $2}'), Kanal: $(wl -i $WLDEV channel|awk 'sub("current mac channel","") {print $1}'), BSSID: $(wl -i $WLDEV bssid|awk 'sub("bssid is","") {print $1}'), Rate: $(wl -i $WLDEV rate|awk 'sub("rate is","") {print $1}') Mbit/s, Sendeleistung: $(wl -i $WLDEV txpwr|awk 'sub("txpwr is","") {print $1}') mW, Signal: $(wl -i $WLDEV rssi|awk 'sub("rssi is","") {print $1}') dBm, Rauschen: $(wl -i $WLDEV noise|awk 'sub("noise is","") {print $1}') dBm

EOF if [ "$(nvram get ff_httpinfo)" != "0" ];then cat<<EOF

Nachbarn:

EOF wget -O - http://127.0.0.1:8080/nodes|awk ' /

## /,/<\/div>/ { if ($1~/

## /) { prnt=($1~/Links/) } else if (prnt) { sub("<""table[^>]+>", "<""table frame=void border=1 cellspacing=0 cellpadding=1 width=100%>") sub("

<t.>[^>]+</t.>", "
") sub("
remote IP", " | IP") sub("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+", "&") print } }' cat<<EOF
--- | ---

EOF fi cat<<EOF
OpenVPN: | EOF if [ -f /tmp/openvpn_msg.txt ];then cat<<EOF VPN-Tunnel aktiv ($(nvram get on_gw)) EOF #echo -n " ($(nvram get on_gw))" else cat<<EOF VPN-Tunnel inaktiv, Details im System-Log EOF fi cat<<EOF
EOF if [ -n "$(ip route show table 5)" ];then cat<<EOF
Internet: | EOF if [ -f /tmp/openvpn_ugw_msg.txt ];then echo "Freigabe / User-Gateway aktiv ($(nvram get on_ugw)) " else echo "Freigabe / User-Gateway inaktiv" minutes=$(nvram get on_share_internet_blocked) if [ -n "$minutes" ]; then echo " (Reaktivierung in $minutes Minuten)" fi echo "" fi cat<<EOF
EOF fi cat<<EOF
Gerätelaufzeit: | $(uptime)
Geräteinfo: | Bordtype: $(nvram get boardtype), Bordnummer: $(nvram get boardnum)
Kernel-Log: | Ein- / Ausblenden

EOF echo -n '

    '
    dmesg 2>&1
    echo '

' cat<<EOF

System-Log: | Ein- / Ausblenden

EOF echo -n '

    '
    logread 2>&1
    echo '

' cat<<EOF

IP-NAT: | Ein- / Ausblenden

EOF echo -n '

    '
    iptables -t nat -L -n 2>&1
    echo '

' cat<<EOF

Schnittstellen-Konfiguration: | Ein- / Ausblenden

EOF echo -n '

    '
    echo "lan_ifnames=$(nvram get lan_ifnames)"
    echo "lan_ifname=$(nvram get lan_ifname)"
    echo "wl0_ifname=$(nvram get wl0_ifname)"
    echo "wifi_ifname=$(nvram get wifi_ifname)"
    echo "wan_ifname=$(nvram get wan_ifname)"
    echo
    brctl show 2>&1
    echo
    ifconfig 2>&1
    echo '

' cat<<EOF

Aktive Verbindungen: | Ein- / Ausblenden

EOF echo -n '

    '
    eval $(sed -e'
    s/src=\([0-9\.]\+\).*/conn_\1=$(( \$conn_\1 + 1 ));/
    s/^.* conn_/conn_/
    s/\./_/g
    ' /proc/net/ip_conntrack)
    set|sed -ne"
    s/^conn_//
    tp
    b
    :p
    s/_/./g
    s/^\(.*\)='\([0-9]\+\)'/\2      \1/
    p
    "|sort
    echo '

' cat<<EOF

EOF fi cat<<EOF
EOF