From 2346e8fd145e4c45760d9d5519a99db8ef1239df Mon Sep 17 00:00:00 2001 From: nbd Date: Mon, 29 Aug 2005 11:30:35 +0000 Subject: add Wi-viz git-svn-id: svn://svn.openwrt.org/openwrt/trunk@1785 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../package/wiviz/files/www/cgi-bin/wiviz/get.cgi | 15 ++ .../package/wiviz/files/www/cgi-bin/wiviz/set.cgi | 3 + .../package/wiviz/files/www/wiviz/adhoc-idle.gif | Bin 0 -> 332 bytes .../package/wiviz/files/www/wiviz/adhoc-idle.png | Bin 0 -> 729 bytes openwrt/package/wiviz/files/www/wiviz/adhoc.gif | Bin 0 -> 451 bytes openwrt/package/wiviz/files/www/wiviz/adhoc.png | Bin 0 -> 713 bytes openwrt/package/wiviz/files/www/wiviz/ap-idle.gif | Bin 0 -> 812 bytes openwrt/package/wiviz/files/www/wiviz/ap-idle.png | Bin 0 -> 813 bytes .../package/wiviz/files/www/wiviz/ap-wep-idle.gif | Bin 0 -> 812 bytes .../package/wiviz/files/www/wiviz/ap-wep-idle.png | Bin 0 -> 813 bytes openwrt/package/wiviz/files/www/wiviz/ap-wep.gif | Bin 0 -> 1455 bytes openwrt/package/wiviz/files/www/wiviz/ap-wep.png | Bin 0 -> 1996 bytes openwrt/package/wiviz/files/www/wiviz/ap.gif | Bin 0 -> 1468 bytes openwrt/package/wiviz/files/www/wiviz/ap.png | Bin 0 -> 1824 bytes openwrt/package/wiviz/files/www/wiviz/pip-idle.gif | Bin 0 -> 190 bytes openwrt/package/wiviz/files/www/wiviz/pip-idle.png | Bin 0 -> 330 bytes openwrt/package/wiviz/files/www/wiviz/pip.gif | Bin 0 -> 190 bytes openwrt/package/wiviz/files/www/wiviz/pip.png | Bin 0 -> 322 bytes .../package/wiviz/files/www/wiviz/station-idle.gif | Bin 0 -> 754 bytes .../package/wiviz/files/www/wiviz/station-idle.png | Bin 0 -> 1777 bytes openwrt/package/wiviz/files/www/wiviz/station.gif | Bin 0 -> 929 bytes openwrt/package/wiviz/files/www/wiviz/station.png | Bin 0 -> 2475 bytes openwrt/package/wiviz/files/www/wiviz/wiviz.css | 76 ++++++ openwrt/package/wiviz/files/www/wiviz/wiviz.html | 81 ++++++ openwrt/package/wiviz/files/www/wiviz/wiviz.js | 291 +++++++++++++++++++++ 25 files changed, 466 insertions(+) create mode 100755 openwrt/package/wiviz/files/www/cgi-bin/wiviz/get.cgi create mode 100755 openwrt/package/wiviz/files/www/cgi-bin/wiviz/set.cgi create mode 100755 openwrt/package/wiviz/files/www/wiviz/adhoc-idle.gif create mode 100755 openwrt/package/wiviz/files/www/wiviz/adhoc-idle.png create mode 100755 openwrt/package/wiviz/files/www/wiviz/adhoc.gif create mode 100755 openwrt/package/wiviz/files/www/wiviz/adhoc.png create mode 100755 openwrt/package/wiviz/files/www/wiviz/ap-idle.gif create mode 100755 openwrt/package/wiviz/files/www/wiviz/ap-idle.png create mode 100755 openwrt/package/wiviz/files/www/wiviz/ap-wep-idle.gif create mode 100755 openwrt/package/wiviz/files/www/wiviz/ap-wep-idle.png create mode 100755 openwrt/package/wiviz/files/www/wiviz/ap-wep.gif create mode 100755 openwrt/package/wiviz/files/www/wiviz/ap-wep.png create mode 100755 openwrt/package/wiviz/files/www/wiviz/ap.gif create mode 100755 openwrt/package/wiviz/files/www/wiviz/ap.png create mode 100755 openwrt/package/wiviz/files/www/wiviz/pip-idle.gif create mode 100755 openwrt/package/wiviz/files/www/wiviz/pip-idle.png create mode 100755 openwrt/package/wiviz/files/www/wiviz/pip.gif create mode 100755 openwrt/package/wiviz/files/www/wiviz/pip.png create mode 100755 openwrt/package/wiviz/files/www/wiviz/station-idle.gif create mode 100755 openwrt/package/wiviz/files/www/wiviz/station-idle.png create mode 100755 openwrt/package/wiviz/files/www/wiviz/station.gif create mode 100755 openwrt/package/wiviz/files/www/wiviz/station.png create mode 100755 openwrt/package/wiviz/files/www/wiviz/wiviz.css create mode 100755 openwrt/package/wiviz/files/www/wiviz/wiviz.html create mode 100755 openwrt/package/wiviz/files/www/wiviz/wiviz.js (limited to 'openwrt/package/wiviz/files') diff --git a/openwrt/package/wiviz/files/www/cgi-bin/wiviz/get.cgi b/openwrt/package/wiviz/files/www/cgi-bin/wiviz/get.cgi new file mode 100755 index 0000000000..161fc75ee1 --- /dev/null +++ b/openwrt/package/wiviz/files/www/cgi-bin/wiviz/get.cgi @@ -0,0 +1,15 @@ +#!/bin/sh + +WIVIZ_PATH=wiviz + +echo Content-type: text/html +echo +killall -USR1 wiviz >/dev/null 2>&1 +if [ 0 -ne $? ] + then #### Wi-Viz daemon not running, start it + $WIVIZ_PATH >/dev/null &1 & + killall -USR1 wiviz > /dev/null + fi +echo "" diff --git a/openwrt/package/wiviz/files/www/cgi-bin/wiviz/set.cgi b/openwrt/package/wiviz/files/www/cgi-bin/wiviz/set.cgi new file mode 100755 index 0000000000..17b47873ae --- /dev/null +++ b/openwrt/package/wiviz/files/www/cgi-bin/wiviz/set.cgi @@ -0,0 +1,3 @@ +#!/bin/sh +httpd -d $QUERY_STRING > /tmp/wiviz-cfg +killall -USR2 wiviz diff --git a/openwrt/package/wiviz/files/www/wiviz/adhoc-idle.gif b/openwrt/package/wiviz/files/www/wiviz/adhoc-idle.gif new file mode 100755 index 0000000000..79db61c4d3 Binary files /dev/null and b/openwrt/package/wiviz/files/www/wiviz/adhoc-idle.gif differ diff --git a/openwrt/package/wiviz/files/www/wiviz/adhoc-idle.png b/openwrt/package/wiviz/files/www/wiviz/adhoc-idle.png new file mode 100755 index 0000000000..24ae2769fa Binary files /dev/null and b/openwrt/package/wiviz/files/www/wiviz/adhoc-idle.png differ diff --git a/openwrt/package/wiviz/files/www/wiviz/adhoc.gif b/openwrt/package/wiviz/files/www/wiviz/adhoc.gif new file mode 100755 index 0000000000..d07c80cce3 Binary files /dev/null and b/openwrt/package/wiviz/files/www/wiviz/adhoc.gif differ diff --git a/openwrt/package/wiviz/files/www/wiviz/adhoc.png b/openwrt/package/wiviz/files/www/wiviz/adhoc.png new file mode 100755 index 0000000000..7cabb3e8f9 Binary files /dev/null and b/openwrt/package/wiviz/files/www/wiviz/adhoc.png differ diff --git a/openwrt/package/wiviz/files/www/wiviz/ap-idle.gif b/openwrt/package/wiviz/files/www/wiviz/ap-idle.gif new file mode 100755 index 0000000000..376e194da9 Binary files /dev/null and b/openwrt/package/wiviz/files/www/wiviz/ap-idle.gif differ diff --git a/openwrt/package/wiviz/files/www/wiviz/ap-idle.png b/openwrt/package/wiviz/files/www/wiviz/ap-idle.png new file mode 100755 index 0000000000..b5e593978d Binary files /dev/null and b/openwrt/package/wiviz/files/www/wiviz/ap-idle.png differ diff --git a/openwrt/package/wiviz/files/www/wiviz/ap-wep-idle.gif b/openwrt/package/wiviz/files/www/wiviz/ap-wep-idle.gif new file mode 100755 index 0000000000..376e194da9 Binary files /dev/null and b/openwrt/package/wiviz/files/www/wiviz/ap-wep-idle.gif differ diff --git a/openwrt/package/wiviz/files/www/wiviz/ap-wep-idle.png b/openwrt/package/wiviz/files/www/wiviz/ap-wep-idle.png new file mode 100755 index 0000000000..b5e593978d Binary files /dev/null and b/openwrt/package/wiviz/files/www/wiviz/ap-wep-idle.png differ diff --git a/openwrt/package/wiviz/files/www/wiviz/ap-wep.gif b/openwrt/package/wiviz/files/www/wiviz/ap-wep.gif new file mode 100755 index 0000000000..33debb1250 Binary files /dev/null and b/openwrt/package/wiviz/files/www/wiviz/ap-wep.gif differ diff --git a/openwrt/package/wiviz/files/www/wiviz/ap-wep.png b/openwrt/package/wiviz/files/www/wiviz/ap-wep.png new file mode 100755 index 0000000000..2a907f05b0 Binary files /dev/null and b/openwrt/package/wiviz/files/www/wiviz/ap-wep.png differ diff --git a/openwrt/package/wiviz/files/www/wiviz/ap.gif b/openwrt/package/wiviz/files/www/wiviz/ap.gif new file mode 100755 index 0000000000..739c18c918 Binary files /dev/null and b/openwrt/package/wiviz/files/www/wiviz/ap.gif differ diff --git a/openwrt/package/wiviz/files/www/wiviz/ap.png b/openwrt/package/wiviz/files/www/wiviz/ap.png new file mode 100755 index 0000000000..038aab83a3 Binary files /dev/null and b/openwrt/package/wiviz/files/www/wiviz/ap.png differ diff --git a/openwrt/package/wiviz/files/www/wiviz/pip-idle.gif b/openwrt/package/wiviz/files/www/wiviz/pip-idle.gif new file mode 100755 index 0000000000..fa923bdf16 Binary files /dev/null and b/openwrt/package/wiviz/files/www/wiviz/pip-idle.gif differ diff --git a/openwrt/package/wiviz/files/www/wiviz/pip-idle.png b/openwrt/package/wiviz/files/www/wiviz/pip-idle.png new file mode 100755 index 0000000000..33c280ea65 Binary files /dev/null and b/openwrt/package/wiviz/files/www/wiviz/pip-idle.png differ diff --git a/openwrt/package/wiviz/files/www/wiviz/pip.gif b/openwrt/package/wiviz/files/www/wiviz/pip.gif new file mode 100755 index 0000000000..4d48ff92ab Binary files /dev/null and b/openwrt/package/wiviz/files/www/wiviz/pip.gif differ diff --git a/openwrt/package/wiviz/files/www/wiviz/pip.png b/openwrt/package/wiviz/files/www/wiviz/pip.png new file mode 100755 index 0000000000..96be6a1e7e Binary files /dev/null and b/openwrt/package/wiviz/files/www/wiviz/pip.png differ diff --git a/openwrt/package/wiviz/files/www/wiviz/station-idle.gif b/openwrt/package/wiviz/files/www/wiviz/station-idle.gif new file mode 100755 index 0000000000..4abead0189 Binary files /dev/null and b/openwrt/package/wiviz/files/www/wiviz/station-idle.gif differ diff --git a/openwrt/package/wiviz/files/www/wiviz/station-idle.png b/openwrt/package/wiviz/files/www/wiviz/station-idle.png new file mode 100755 index 0000000000..e37469c2f6 Binary files /dev/null and b/openwrt/package/wiviz/files/www/wiviz/station-idle.png differ diff --git a/openwrt/package/wiviz/files/www/wiviz/station.gif b/openwrt/package/wiviz/files/www/wiviz/station.gif new file mode 100755 index 0000000000..0008a706a2 Binary files /dev/null and b/openwrt/package/wiviz/files/www/wiviz/station.gif differ diff --git a/openwrt/package/wiviz/files/www/wiviz/station.png b/openwrt/package/wiviz/files/www/wiviz/station.png new file mode 100755 index 0000000000..2df9420582 Binary files /dev/null and b/openwrt/package/wiviz/files/www/wiviz/station.png differ diff --git a/openwrt/package/wiviz/files/www/wiviz/wiviz.css b/openwrt/package/wiviz/files/www/wiviz/wiviz.css new file mode 100755 index 0000000000..7b5afa7061 --- /dev/null +++ b/openwrt/package/wiviz/files/www/wiviz/wiviz.css @@ -0,0 +1,76 @@ +/* +This file is part of Wi-viz (http://wiviz.natetrue.com). + +Wi-viz is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License v2 as published by +the Free Software Foundation. + +Wi-viz 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 Wi-viz; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +body { + background-color: #D0D0D0; + vertical-align: center; + text-align: center; +} +div.main { + background-color: #D0F0D0; + width: 500px; + height: 500px; + border: 1px solid #555599; + vertical-align: center; + text-align: center; +} +div.floater { + background-color: #D0F0D0; + width: 125px; + height: 300px; + border: 1px solid #555599; + float: right; + z-index: 3; +} +span.status { + color: #FF0000; +} +img.icon { + width: 50px; + height: 50px; +} +img.pip { + width: 12px; + height: 12px; + position: absolute; + z-index: 1; +} +td { + vertical-align: center; + text-align: center; +} +span.hostdesc { + font-size: 10pt; +} +span.extrafo { + font-size: 10pt; + visibility: hidden; +} +div.hostdiv { + position: absolute; + background-color: transparent; + text-align: center; + width: 150px; + z-index: 2; +} +div.hostdiv_hov { + position: absolute; + background-color: #C0E0C0; + text-align: center; + width: 150px; + z-index: 3; + border: 1px solid #000000; +} diff --git a/openwrt/package/wiviz/files/www/wiviz/wiviz.html b/openwrt/package/wiviz/files/www/wiviz/wiviz.html new file mode 100755 index 0000000000..f1356fd824 --- /dev/null +++ b/openwrt/package/wiviz/files/www/wiviz/wiviz.html @@ -0,0 +1,81 @@ + + + +Wi-viz wireless network environment visualization + + + + +

OpenWRT Wi-viz network visualization

+
+Status: Monitoring
+ +

+Channel setting: +
+
+
+
+
+
+ + +
+
+
+ + + + + diff --git a/openwrt/package/wiviz/files/www/wiviz/wiviz.js b/openwrt/package/wiviz/files/www/wiviz/wiviz.js new file mode 100755 index 0000000000..dc67d8f011 --- /dev/null +++ b/openwrt/package/wiviz/files/www/wiviz/wiviz.js @@ -0,0 +1,291 @@ +/* +This file is part of Wi-viz (http://wiviz.natetrue.com). + +Wi-viz is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License v2 as published by +the Free Software Foundation. + +Wi-viz 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 Wi-viz; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +var mv = 353; +var stupid = eval('window.attachEvent') ? 1 : 0; +var hosts; +var idle_timeout = 20; +var erase_timeout = 35; +var skew_x = 0; skew_y = 0; +var listening = 1; +var wiviz_cgi_url = "/cgi-bin/wiviz/get.cgi"; + +//What? You mean the POSIX thread API hasn't been ported to Javascript? Bugger. +function scan_thread() { + var loc = document.getElementById('wivizGetFrame').contentWindow.location; + if (!listening) return; + if (loc.href != wiviz_cgi_url) { + loc.replace(wiviz_cgi_url); + } + else { + loc.reload(true); + } + setTimeout("scan_thread()", 5000); +} + +function toggleListen() { + statusel = document.getElementById('status'); + statusbutton = document.getElementById('togglelisten'); + listening = 1 - listening; + if (listening) { + statusel.innerHTML = "Monitoring"; + statusbutton.value = "Stop monitoring"; + document.getElementById('content').innerHTML = ''; + scan_thread(); + } + else { + statusel.innerHTML = "Stopped"; + statusbutton.value = "Start monitoring"; + } +} + +function channelSet() { + channelset = document.getElementById('channelsel').value; + if (channelset == 'hop') { + document.getElementById('hopoptions').style.display = 'inline'; + } + else { + document.getElementById('hopoptions').style.display = 'none'; + if (channelset != 'nochange') document.forms[0].submit(); + } +} + +function mousenter(e) { + if (stupid) e = event; + el = stupid ? e.srcElement : e.currentTarget; + el.parentNode.parentNode.className = 'hostdiv_hov'; + el.nextSibling.nextSibling.nextSibling.style.visibility = 'visible'; +} + +function mouseout(e) { + if (stupid) e = event; + el = stupid ? e.srcElement : e.currentTarget; + el.parentNode.parentNode.className = 'hostdiv'; + el.nextSibling.nextSibling.nextSibling.style.visibility = 'hidden'; +} + +function generate_mnemonic(hash) { + c = new Array('b','c','d','f','g','h','j','k','l','m','n','p','qu','r','s', + 't','v','w','y','z','th','ch','sh','cc','rr'); + v = new Array('a','e','i','o','u','ae','ai','ao','au','eo','ei','eu','iu','oa','oe'); + var i, a; + var p = hash & 1; + var n = ''; + for (i = 0; i < 4; i++) { + a = p ? c : v; + n += a[hash % a.length]; + hash += a.length << 3 + a.length / 2; + hash *= hash; + p = 1 - p; + } + return n; +} + +function mkhash(mac) { + var macarr = mac.split(/:/); + var hash = 0; + for (j = 0; j < 6; j++) { + hash += parseInt(macarr[j]) * j << j; + hash += 11; + } + if (hash < 0) hash = -hash; + return hash; +} + +function wiviz_callback(mhosts, cfgstring) { + var nh = ''; + hosts = mhosts; + for (i = 0; i < hosts.length; i++) { + hs = hosts[i]; + if (hs.length == 0) break; + hs.mac = hs[0]; + hs.rssi = hs[1]; + hs.desc = hs[2]; + hs.descarr = hs.desc.split(/-/) + hs.age = hs[3]; + hs.hash = mkhash(hs.mac); + hs.mnem = generate_mnemonic(hs.hash) + hs.name = hs.mnem; + el = document.getElementById(hs.mnem); + if (el) { + if (hs.age > erase_timeout) { + el.parentNode.removeChild(el); + continue; + } + el.innerHTML = genHTML(hs); + } + else { + if (hs.age > erase_timeout) continue; + hs.x = Math.sin(hs.hash / mv) * hs.rssi * 2 - 67; + hs.y = Math.cos(hs.hash / mv) * hs.rssi * 2; + nh += "
"; + nh += genHTML(hs) + "
"; + } + } + document.getElementById('content').innerHTML += nh; + + cfgarr = cfgstring.split(/-/); + if (cfgarr[1]) { + if (cfgarr[1] == 'hopping') cfgarr[1] = 'hop'; + document.getElementById('channelsel').value = cfgarr[1]; + if (cfgarr[1] == 'hop') channelSet(); + } + + //repip(); + setTimeout("declump(); repip();", 250); +} + +function repip() { + var nh = ""; + if (!hosts) return; + for (i = 0; i < hosts.length; i++) { + hs = hosts[i]; + if (hs.length == 0) break; + mac = hs[0]; + rssi = hs[1]; + desc = hs[2].split(/-/); + if (desc[0] == 'sta' && desc[1] == 'assoc') { + bss = desc[2]; + hs.apmnem = generate_mnemonic(mkhash(bss)); + ap = document.getElementById(hs.apmnem); + sta = document.getElementById(hs.mnem); + if (ap && sta) { + x = parseInt(sta.style.left); + y = parseInt(sta.style.top); + dx = parseInt(ap.style.left) - x; + dy = parseInt(ap.style.top) - y; + x += 67; + y += 10; + d = Math.sqrt(dx*dx+dy*dy); + for (j = 0; j < d; j += 15) { + nh += ""; + } + } + } + } + document.getElementById('pips').innerHTML = nh; +} + +function declump() { + var c = 0; + var top = 30000,left = 30000,right = -30000,bottom = -30000; + for (i = 0; i < hosts.length; i++) { + for (j = 0; j < hosts.length; j++) { + if (i == j) continue; + e1 = document.getElementById(hosts[i].mnem); + e2 = document.getElementById(hosts[j].mnem); + if (!e1 || !e2) continue; + x1 = parseInt(e1.style.left); + x2 = parseInt(e2.style.left); + y1 = parseInt(e1.style.top); + y2 = parseInt(e2.style.top); + if (x1 < left) left = x1; + if (y1 < top) top = y1; + if (x1 > right) right = x1; + if (y1 > bottom) bottom = y1; + ox = x2; + oy = y2; + dist = Math.sqrt(Math.pow((x1-x2), 2) + Math.pow((y1-y2), 2)); + if (dist == 0) { + x2 += Math.random() * 5; + y2 += Math.random() * 5; + dist = 10; + } + if (dist < 100) { + cx = (x1-x2) * 5 / (dist / 3); + cy = (y1-y2) * 5 / (dist / 3); + x2 -= cx; + y2 -= cy; + } + if (hosts[j].apmnem == hosts[i].mnem + || hosts[i].apmnem == hosts[j].mnem) { + cx = (x1-x2) * 5 / (dist / 3); + cy = (y1-y2) * 5 / (dist / 3); + if (dist > 150) { + x2 += cx; + y2 += cy; + } + } + if (Math.abs(ox-x2) > 2 || Math.abs(oy-y2) > 2) { + e2.style.left = parseInt(x2); + e2.style.top = parseInt(y2); + c++; + } + } + } + if (top < bottom && left < right) { + document.getElementById('debug').innerHTML = left + "," + right + "," + top + "," +bottom; + document.getElementById('content').style.left = + document.getElementById('pips').style.left = + -(right - left) / 2 - left - 67; + document.getElementById('content').style.top = + document.getElementById('pips').style.top = + -(bottom - top) / 2 - top - 25; + } + repip(); + if (c) setTimeout("declump()", 100); +} + +function genHTML(hs) { + var nh = ''; + nh += "

" + hs.mac + "
'" + hs.name; + nh += "'"; + if (hs.channel) { + nh += " ch" + hs.channel; + } + nh += "

"; + if (a[0] == 'ap') nh += "Access point"; + if (a[0] == 'sta') nh += "Station"; + if (a[0] == 'adhoc') nh += "Logical ad-hoc entity"; + if (a[0] == 'ap' || a[0] == 'adhoc') { + nh += "
"; + if (a[5] == '?enc') nh += "Encryption unknown"; + if (a[5] == 'enc') nh += "Encrypted"; + if (a[5] == 'unenc') nh += "Unencrypted"; + if (a[6] == 'wep') nh += "-WEP"; + if (a[6] == 'wpa') nh += "-WPA"; + } + nh += "
RSSI: " + hs.rssi + " dBm
" + + "Seen " + hs.age + " seconds ago
"; + nh += "
"; + return nh; +} -- cgit v1.2.3