#!/bin/sh export DATE="3.12.2008";SCRIPT=${0#/rom} export TITLE="Stato: OLSR" . ${SCRIPT%/*}/cgi-bin-pre.sh WLDEV=$(sed -n 's/^ *\([^:]\+\):.*/\1/p' /proc/net/wireless) ff_httpinfo=$(nvram get ff_httpinfo) if [ "$REQUEST_METHOD" = "POST" ]; then read QUERY_STRING fi if [ "$QUERY_STRING" != "${QUERY_STRING#*post_olsr=}" ]; then cat<Stato: OLSR
# s/./&/ tn c\ <\/TABLE> p } ' cat<
    EOF if [ "$(nvram get wl0_mode)" != "ap" ];then cat< EOF fi if [ "$ff_httpinfo" != "0" ];then cat< EOF fi cat<
 
EOF wget -q -O - http://127.0.0.1:2006/|sed -ne' /^Table:/,/^$/{ s#^Table: \(.*\)#

\1

<\TABLE BORDER="1" CELLSPACING="0" CELLPADDING="0" WIDTH="100%"># :n p n s#[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+#&#g s/ / - /g s/ $// s# #
#g s#.\+#
&
EOF elif [ "$QUERY_STRING" != "${QUERY_STRING#*post_route=}" ]; then cat<Stato: Rotte
\ \ \ # s#\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)\([ <]\)#\1\2#g ' echo '<''/TABLE>' cat<
    EOF if [ "$(nvram get wl0_mode)" != "ap" ];then cat< EOF fi if [ "$ff_httpinfo" != "0" ];then cat< EOF fi cat<
 
EOF echo '<''TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="400">' for i in olsr main dyngw;do ip ro ls table $i;done|sed -e' s#^\([^ ]\+\)\(.*\)#
\1\2
EOF elif [ "$QUERY_STRING" != "${QUERY_STRING#*post_scan=}" ]; then cat<Stato: Ricerca WLAN
' (/rom/usr/sbin/wl -i $WLDEV scan 2>&- && (sleep 2;/rom/usr/sbin/wl -i $WLDEV scanresults 2>&-|sed -ne' /^$/d /^WSEC/d /^SSID:/{ s/[\$\`"\\]//g s/: \(.*\)/="\1"/ h d } /^Supported Rates:/{ s/.* \([0-9]\+\).*/RATE="\1"/ H g s/\n/ /g p } s/ dBm//g s/: \+\([^ ]\+\)/="\1"/g s/ \+"/"/g s/Mode="Ad Hoc"/ADHOC="yes"/ s/Mode="[^"]\+"/ADHOC="no"/ s/Capability=".* WEP .*/OPEN="no"/ s/Capability.*/OPEN="yes"/g H ') || iwlist $WLDEV scanning 2>&-|sed -ne' 1{ s/.*/ignore/ h d } /Address:/{ s/^[^:]*: *\([0-9A-F:]*\)/BSSID="\1" IWTOOLS=1/ x s/\n/ /g tx :x s/^ignore$// t p } ${ x s/\n/ /g p } /ESSID:/{ s/^[^:]*:"// s/.$// s/[\$\`"\\]//g s/.*/SSID="&"/g H } /Mode:/{ s/^[^:]*:Ad-Hoc/ADHOC="yes"/ s/^[^:]*:.*/ADHOC="no"/ H } /Frequency:/{ s/^[^(]*(Channel *\([0-9]*\).*/Channel="\1"/ H } /Channel:/{ s/^[^:]*:\([0-9]*\).*/Channel="\1"/ H } /Quality[:=]/{ s/^.*Signal level[:=]\([-0-9]*\).*Noise level[:=]\([-0-9]*\).*/RSSI="\1" noise="\2"/ H } /Encryption key:/{ s/^[^:]*:off/OPEN="yes"/ s/^[^:]*:.*/OPEN="no"/ H } ')|while read line; do RSSI= eval $line test -z "$noise" && noise=-95 test -z "$RSSI" && test "1" = "$IWTOOLS" && eval $(iwlist $WLDEV ap 2>&-|sed -ne" /$BSSID/s/^.*Signal level[:=]\\([-0-9]*\\).*Noise level[:=]\\([-0-9]*\\).*/RSSI=\"\\1\" noise=\"\\2\"/p ") gif=$(( $RSSI - $noise )) gif=$(( $gif / 5 )) test $gif -gt 5 && gif=5 test $gif -lt 0 && gif=0 cat< EOF done echo '
    EOF if [ "$(nvram get wl0_mode)" != "ap" ];then cat< EOF fi if [ "$ff_httpinfo" != "0" ];then cat< EOF fi cat<
 
SSID Canale Ad-Hoc Open Signal Max. BSSID
EOF echo '
$SSID$Channel ad hoc $OPEN P=$gif $RATE$BSSID
 ' cat<
EOF else cat<Stato: Riassunto
# s/./&/ tn c\ <\/TABLE> p } ' fi cat<
    EOF if [ "$(nvram get wl0_mode)" != "ap" ];then cat< EOF fi if [ "$ff_httpinfo" != "0" ];then cat< EOF fi WLMASK=$(ip -f inet addr show dev $WLDEV label $WLDEV |sed -ne'2{s# \+inet \([0-9\.\/]\+\).*#\1#;p}') cat<
 
Indirizzo IP: IP: $(ip -f inet addr show dev $WLDEV label $WLDEV |sed -ne'2{s/ \+inet \([0-9\.]\+\).*/\1/;p}'), Maschera: $(test -n "$WLMASK" && ipcalc -m $WLMASK|cut -d'=' -f2), MAC: $(ip link show dev $WLDEV|sed -ne'2{s/.*ether \+\([^ ]\+\).*/\1/;p}')
Stato WLAN: EOF if /rom/usr/sbin/wl -i $WLDEV status 2>&-;then echo "
" /rom/usr/sbin/wl -i $WLDEV rate /rom/usr/sbin/wl -i $WLDEV mrate else iwconfig $WLDEV 2>&- fi cat<
Tempo di funzionamento: $(uptime)
Informazioni sull'apparato: Boardtype: $(nvram get boardtype), Boardnum: $(nvram get boardnum)
Versioni: Firmware: $(cat /etc/freifunk-release)
Olsrd: $(cat /etc/olsrd-release)
Rotta di Default: $(ip route list exact 0/0|sed '1q'|sed 's#\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)#\1#') EOF if [ "$ff_httpinfo" != "0" ];then cat<
Adiacenti: EOF wget -q -O - http://127.0.0.1:2006/neighbours|sed -ne' /^Table: Links/{ s/.*/<\TABLE FRAME="VOID" BORDER="1" CELLSPACING="0" CELLPADDING="1" WIDTH="400">/ :n p n s/^[^ ]* // s/^remote // s#\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)\([^/]\)#\1\2#g s/ $// s# ##g s#.\+#
&
Log del Kernel: Mostra / Nascondi
EOF echo -n '' if pidof syslogd>/dev/null;then cat<
Lod di Sistema: Mostra / Nascondi
EOF echo -n '' fi cat<
IP NAT: Mostra / Nascondi
EOF echo -n '' cat<
Configurazione delle Interfacce: Mostra / Nascondi
EOF echo -n '' cat<
Configurazione NVRAM: Mostra / Nascondi
EOF echo -n '' cat<
Connessioni Attive: Mostra / Nascondi
EOF echo -n '' cat<
EOF if [ "00:90:96:00:00:00" = "$(nvram get et0macaddr)" ] || [ "00:90:96:00:00:02" = "$(nvram get il0macaddr)" ]; then cat< Attenzione: Questo apparato SE505 non ha il corretto indirizzo MAC. Leggi l'indirizzo MAC dalla parte inferiore dell'apparato e correggilo manualmente dalla shell di linea di comando, per esempio con nvram set et0macaddr=xx:xx:xx:xx:xx:xx, nvram set il0macaddr=xx:xx:xx:xx:xx:[xx+1], nvram commit e infine reboot

EOF fi fi . ${SCRIPT%/*}/cgi-bin-post.sh