* Fixed #2030
authorSteven Barth <steven@midlink.org>
Thu, 8 May 2008 16:04:18 +0000 (16:04 +0000)
committerSteven Barth <steven@midlink.org>
Thu, 8 May 2008 16:04:18 +0000 (16:04 +0000)
26 files changed:
modules/freifunk/Makefile [new file with mode: 0644]
modules/freifunk/root/etc/config/freifunk [new file with mode: 0644]
modules/freifunk/root/etc/init.d/luci_freifunk [new file with mode: 0644]
modules/freifunk/src/controller/admin/index/wizard.lua [new file with mode: 0644]
modules/freifunk/src/controller/public/index.lua [new file with mode: 0644]
modules/freifunk/src/controller/public/olsr.lua [new file with mode: 0644]
modules/freifunk/src/controller/public/status.lua [new file with mode: 0644]
modules/freifunk/src/controller/rpc/luciinfo.lua [new file with mode: 0644]
modules/freifunk/src/controller/sudo/status.lua [new file with mode: 0644]
modules/freifunk/src/i18n/admin_index_contact.en [new file with mode: 0644]
modules/freifunk/src/model/cbi/admin_index/contact.lua [new file with mode: 0644]
modules/freifunk/src/model/cbi/admin_index/freifunk.lua [new file with mode: 0644]
modules/freifunk/src/model/menu/10freifunk.lua [new file with mode: 0644]
modules/freifunk/src/view/public_index/contact.htm [new file with mode: 0644]
modules/freifunk/src/view/public_index/index.htm [new file with mode: 0644]
modules/freifunk/src/view/public_olsr/error_olsr.htm [new file with mode: 0644]
modules/freifunk/src/view/public_olsr/hna.htm [new file with mode: 0644]
modules/freifunk/src/view/public_olsr/index.htm [new file with mode: 0644]
modules/freifunk/src/view/public_olsr/mid.htm [new file with mode: 0644]
modules/freifunk/src/view/public_olsr/routes.htm [new file with mode: 0644]
modules/freifunk/src/view/public_olsr/topology.htm [new file with mode: 0644]
modules/freifunk/src/view/public_status/index.htm [new file with mode: 0644]
modules/freifunk/src/view/public_status/iwscan.htm [new file with mode: 0644]
modules/freifunk/src/view/public_status/routes.htm [new file with mode: 0644]
modules/freifunk/src/view/sudo_status/iwconfig.htm [new file with mode: 0644]
modules/freifunk/src/view/sudo_status/iwscan.htm [new file with mode: 0644]

diff --git a/modules/freifunk/Makefile b/modules/freifunk/Makefile
new file mode 100644 (file)
index 0000000..81a96f6
--- /dev/null
@@ -0,0 +1,2 @@
+include ../../build/config.mk
+include ../../build/module.mk
\ No newline at end of file
diff --git a/modules/freifunk/root/etc/config/freifunk b/modules/freifunk/root/etc/config/freifunk
new file mode 100644 (file)
index 0000000..01b83f2
--- /dev/null
@@ -0,0 +1,25 @@
+config public contact
+       option nickname
+       option name
+       option mail
+       option phone
+       option location
+       option geo
+       option note
+
+config public community
+    option name             "Freifunk Halle"
+    option homepage http://halle.freifunk.net
+    option essid    halle.freifunk.net
+    option bssid    02:CA:FF:EE:BA:BE
+    option realm    netz.freifunk-halle.net
+    option channel  1
+    option net              104.0.0.0
+    option mask             255.0.0.0
+    option dhcp             10.0.0.0
+    option dhcpmask 255.255.255.0
+    option dns              "88.198.178.18 141.54.1.1 212.204.49.83 208.67.220.220 208.67.222.222"
+
+config settings routing
+    option internal 0
+    option internet 0
diff --git a/modules/freifunk/root/etc/init.d/luci_freifunk b/modules/freifunk/root/etc/init.d/luci_freifunk
new file mode 100644 (file)
index 0000000..38779cb
--- /dev/null
@@ -0,0 +1,91 @@
+#!/bin/sh /etc/rc.common
+START=70
+
+start() {
+       include /lib/network
+       scan_interfaces
+       
+       
+       ### Read interface names
+       config_get wanif wan ifname
+       config_get lanif lan ifname
+       config_get ffif  ff  ifname
+       config_get ffdif ffdhcp  ifname
+       
+       config_get lanip   lan ipaddr
+       config_get lanmask lan netmask
+       
+       config_get ffip    ff ipaddr
+       config_get ffmask  ff netmask
+       
+       config_get ffdip   ffdhcp ipaddr
+       config_get ffdmask ffdhcp netmask
+       
+       [ -n "$ffif" ] || return 0
+       
+       
+       ### Creating chains
+       iptables -N luci_freifunk_forwarding
+       iptables -t nat -N luci_freifunk_postrouting
+               
+       
+       ### Read from config
+       config_load freifunk
+       
+       config_get_bool internal routing internal
+       [ -n "$wanif" ] && config_get_bool internet routing internet
+       
+       
+       ### Freifunk to Freifunk
+       [ "$internal" -gt 0 ] && {
+               iptables -A luci_freifunk_forwarding -i "$ffif" -o "$ffif" -j ACCEPT
+       }
+       
+       ### Freifunk DHCP to Freifunk
+       [ "$internal" -gt 0 -a -n "$ffdif" ] && {
+               eval "$(ipcalc.sh $ffdip $ffdmask)"
+               
+               iptables -t nat -A luci_freifunk_postrouting -s "$NETWORK/$PREFIX" -o "$ffif" -j MASQUERADE
+       }
+       
+       ### Lan to Freifunk     
+       [ -n "$lanif" ] && {
+               eval "$(ipcalc.sh $lanip $lanmask)"
+               
+               iptables -A luci_freifunk_forwarding -i "$lanif" -o "$ffif" -j ACCEPT
+               iptables -t nat -A luci_freifunk_postrouting -s "$NETWORK/$PREFIX" -o "$ffif" -j MASQUERADE
+       }
+       
+       ### Freifunk to Wan
+       [ "$internet" -gt 0 ] && {              
+               eval "$(ipcalc.sh $ffip $ffmask)"               
+               
+               iptables -A luci_freifunk_forwarding -i "$ffif" -o "$wanif" -j ACCEPT
+               iptables -t nat -A luci_freifunk_postrouting -s "$NETWORK/$PREFIX" -o "$wanif" -j MASQUERADE
+       }
+       
+       ### Freifunk DHCP to Wan
+       [ "$internet" -gt 0 -a -n "$ffdif" ] && {               
+               eval "$(ipcalc.sh $ffdip $ffdmask)"             
+               
+               iptables -t nat -A luci_freifunk_postrouting -s "$NETWORK/$PREFIX" -o "$wanif" -j MASQUERADE
+       }
+       
+       ### Hook in the chains
+       iptables -A forwarding_rule -j luci_freifunk_forwarding
+       iptables -t nat -A postrouting_rule -j luci_freifunk_postrouting
+}
+
+stop() {
+       ### Hook out the chains
+       iptables -D forwarding_rule -j luci_freifunk_forwarding
+       iptables -t nat -D postrouting_rule -j luci_freifunk_postrouting
+       
+       ### Clear the chains
+       iptables -F luci_freifunk_forwarding
+       iptables -t nat -F luci_freifunk_postrouting
+       
+       ### Delete chains
+       iptables -X luci_freifunk_forwarding
+       iptables -t nat -X luci_freifunk_postrouting
+}
diff --git a/modules/freifunk/src/controller/admin/index/wizard.lua b/modules/freifunk/src/controller/admin/index/wizard.lua
new file mode 100644 (file)
index 0000000..c7064bb
--- /dev/null
@@ -0,0 +1,171 @@
+module("ffluci.controller.admin.index.wizard", package.seeall)
+
+function action()
+       if ffluci.http.formvalue("ip") then
+               return configure_freifunk()
+       end
+       
+       local ifaces = {}
+       local wldevs = ffluci.model.uci.sections("wireless")
+       
+       if wldevs then
+               for k, v in pairs(wldevs) do
+                       if v[".type"] == "wifi-device" then
+                               table.insert(ifaces, k)
+                       end
+               end
+       end
+       
+       ffluci.template.render("admin_index/wizard", {ifaces=ifaces})
+end
+
+function configure_freifunk()
+       local ip  = ffluci.http.formvalue("ip")
+       local uci = ffluci.model.uci.Session()
+       
+       -- Load UCI
+       uci:t_load("network")
+       uci:t_load("dhcp")
+       uci:t_load("freifunk")
+       uci:t_load("luci_splash")
+       uci:t_load("olsr")
+       uci:t_load("wireless")
+       
+       
+       -- Configure FF-Interface
+       uci:t_del("network", "ff")
+       uci:t_del("network", "ffdhcp")
+       
+       uci:t_set("network", "ff", nil, "interface")
+       uci:t_set("network", "ff", "type", "bridge")
+       uci:t_set("network", "ff", "proto", "static")
+       uci:t_set("network", "ff", "ipaddr", ip)
+       uci:t_set("network", "ff", "netmask", uci:t_get("freifunk", "community", "mask")) 
+       uci:t_set("network", "ff", "dns", uci:t_get("freifunk", "community", "dns")) 
+       
+       -- Enable internal routing
+       uci:t_set("freifunk", "routing", "internal", "1")
+       
+       -- Enable internet routing
+       if ffluci.http.formvalue("shareinet") then
+               uci:t_set("freifunk", "routing", "internet", "1")
+       else
+               uci:t_set("freifunk", "routing", "internet", "0")
+       end
+       
+       -- Configure DHCP
+       if ffluci.http.formvalue("dhcp") then
+               local dhcpnet = uci:t_get("freifunk", "community", "dhcp"):match("^([0-9]+)")
+               local dhcpip  = ip:gsub("^[0-9]+", dhcpnet)
+       
+               uci:t_set("network", "ffdhcp", nil, "interface")
+               uci:t_set("network", "ffdhcp", "proto", "static")
+               uci:t_set("network", "ffdhcp", "ifname", "br-ff:dhcp")
+               uci:t_set("network", "ffdhcp", "ipaddr", dhcpip)
+               uci:t_set("network", "ffdhcp", "netmask", uci:t_get("freifunk", "community", "dhcpmask"))
+               
+               local dhcp = uci:t_sections("dhcp")
+               if dhcp then
+                       for k, v in pairs(dhcp) do
+                               if v[".type"] == "dhcp" and v.interface == "ffdhcp" then
+                                       uci:t_del("dhcp", k)
+                               end
+                       end             
+                       
+                       local dhcpbeg = 48 + tonumber(ip:match("[0-9]+$")) * 4
+                       
+                       local sk = uci:t_add("dhcp", "dhcp")
+                       uci:t_set("dhcp", sk, "interface", "ffdhcp")
+                       uci:t_set("dhcp", sk, "start", dhcpbeg)
+                       uci:t_set("dhcp", sk, "limit", (dhcpbeg < 252) and 3 or 2)
+                       uci:t_set("dhcp", sk, "leasetime", "30m")
+               end 
+               
+               local splash = uci:t_sections("luci_splash")
+               if splash then
+                       for k, v in pairs(splash) do
+                               if v[".type"] == "iface" then
+                                       uci:t_del("luci_splash", k)
+                               end
+                       end             
+                       
+                       local sk = uci:t_add("luci_splash", "iface")
+                       uci:t_set("luci_splash", sk, "network", "ffdhcp")
+               end             
+       end
+       
+       -- Configure OLSR
+       if ffluci.http.formvalue("olsr") and uci:t_sections("olsr") then
+               for k, v in pairs(uci:t_sections("olsr")) do
+                       if v[".type"] == "Interface" or v[".type"] == "LoadPlugin" then
+                               uci:t_del("olsr", k)
+                       end
+               end
+               
+               if ffluci.http.formvalue("shareinet") then
+                       uci:t_set("olsr", "dyn_gw", nil, "LoadPlugin")
+                       uci:t_set("olsr", "dyn_gw", "Library", "olsrd_dyn_gw.so.0.4")
+               end
+               
+               uci:t_set("olsr", "nameservice", nil, "LoadPlugin")
+               uci:t_set("olsr", "nameservice", "Library", "olsrd_nameservice.so.0.3")
+               uci:t_set("olsr", "nameservice", "name", ip:gsub("%.", "-"))
+               uci:t_set("olsr", "nameservice", "hosts_file", "/var/etc/hosts")
+               uci:t_set("olsr", "nameservice", "suffix", ".olsr")
+               uci:t_set("olsr", "nameservice", "latlon_infile", "/tmp/latlon.txt")
+               
+               uci:t_set("olsr", "txtinfo", nil, "LoadPlugin")
+               uci:t_set("olsr", "txtinfo", "Library", "olsrd_txtinfo.so.0.1")
+               uci:t_set("olsr", "txtinfo", "Accept", "127.0.0.1")
+               
+               local oif = uci:t_add("olsr", "Interface")
+               uci:t_set("olsr", oif, "Interface", "ff")
+               uci:t_set("olsr", oif, "HelloInterval", "6.0")
+               uci:t_set("olsr", oif, "HelloValidityTime", "108.0")
+               uci:t_set("olsr", oif, "TcInterval", "4.0")
+               uci:t_set("olsr", oif, "TcValidityTime", "324.0")
+               uci:t_set("olsr", oif, "MidInterval", "18.0")
+               uci:t_set("olsr", oif, "MidValidityTime", "324.0")
+               uci:t_set("olsr", oif, "HnaInterval", "18.0")
+               uci:t_set("olsr", oif, "HnaValidityTime", "108.0")
+       end
+       
+       -- Configure Wifi
+       local wcfg = uci:t_sections("wireless")
+       if wcfg then
+               for iface, v in pairs(wcfg) do
+                       if v[".type"] == "wifi-device" and ffluci.http.formvalue("wifi."..iface) then
+                               -- Cleanup
+                               for k, j in pairs(wcfg) do
+                                       if j[".type"] == "wifi-iface" and j.device == iface then
+                                               uci:t_del("wireless", k)
+                                       end
+                               end
+                               
+                               uci:t_set("wireless", iface, "disabled", "0")
+                               uci:t_set("wireless", iface, "mode", "11g")
+                               uci:t_set("wireless", iface, "txantenna", 1)
+                               uci:t_set("wireless", iface, "rxantenna", 1)
+                               uci:t_set("wireless", iface, "channel", uci:t_get("freifunk", "community", "channel")) 
+                               
+                               local wif = uci:t_add("wireless", "wifi-iface")
+                               uci:t_set("wireless", wif, "device", iface)
+                               uci:t_set("wireless", wif, "network", "ff")
+                               uci:t_set("wireless", wif, "mode", "adhoc")
+                               uci:t_set("wireless", wif, "ssid", uci:t_get("freifunk", "community", "essid"))
+                               uci:t_set("wireless", wif, "bssid", uci:t_get("freifunk", "community", "bssid"))
+                               uci:t_set("wireless", wif, "txpower", 13)
+                       end
+               end
+       end
+       
+       -- Save UCI
+       uci:t_save("network")
+       uci:t_save("dhcp")
+       uci:t_save("freifunk")
+       uci:t_save("luci_splash")
+       uci:t_save("olsr")
+       uci:t_save("wireless")
+
+       ffluci.http.redirect(ffluci.dispatcher.build_url("admin", "uci", "changes"))
+end
\ No newline at end of file
diff --git a/modules/freifunk/src/controller/public/index.lua b/modules/freifunk/src/controller/public/index.lua
new file mode 100644 (file)
index 0000000..f65478c
--- /dev/null
@@ -0,0 +1 @@
+module("ffluci.controller.public.index", package.seeall)
\ No newline at end of file
diff --git a/modules/freifunk/src/controller/public/olsr.lua b/modules/freifunk/src/controller/public/olsr.lua
new file mode 100644 (file)
index 0000000..d41f5ed
--- /dev/null
@@ -0,0 +1,137 @@
+module("ffluci.controller.public.olsr", package.seeall)
+require("ffluci.sys")
+
+function action_index()
+       local data = fetch_txtinfo("links")
+       
+       if not data or not data.Links then
+               ffluci.template.render("public_olsr/error_olsr")
+               return nil
+       end
+       
+       local function compare(a, b)
+               if tonumber(a.ETX) == 0 then
+                       return false
+               end
+               
+               if tonumber(b.ETX) == 0 then
+                       return true
+               end
+               
+               return tonumber(a.ETX) < tonumber(b.ETX)
+       end
+       
+       table.sort(data.Links, compare)
+       
+       ffluci.template.render("public_olsr/index", {links=data.Links})
+end
+
+function action_routes()
+       local data = fetch_txtinfo("routes")
+       
+       if not data or not data.Routes then
+               ffluci.template.render("public_olsr/error_olsr")
+               return nil
+       end
+       
+       local function compare(a, b)
+               if tonumber(a.ETX) == 0 then
+                       return false
+               end
+               
+               if tonumber(b.ETX) == 0 then
+                       return true
+               end
+               
+               return tonumber(a.ETX) < tonumber(b.ETX)
+       end
+       
+       table.sort(data.Routes, compare)
+       
+       ffluci.template.render("public_olsr/routes", {routes=data.Routes})
+end
+
+function action_topology()
+       local data = fetch_txtinfo("topology")
+       
+       if not data or not data.Topology then
+               ffluci.template.render("public_olsr/error_olsr")
+               return nil
+       end
+       
+       local function compare(a, b)
+               return a["Destination IP"] < b["Destination IP"]
+       end
+       
+       table.sort(data.Topology, compare)
+       
+       ffluci.template.render("public_olsr/topology", {routes=data.Topology})
+end
+
+function action_hna()
+       local data = fetch_txtinfo("hna")
+       
+       if not data or not data.HNA then
+               ffluci.template.render("public_olsr/error_olsr")
+               return nil
+       end
+       
+       local function compare(a, b)
+               return a.Network < b.Network
+       end
+       
+       table.sort(data.HNA, compare)
+       
+       ffluci.template.render("public_olsr/hna", {routes=data.HNA})
+end
+
+function action_mid()
+       local data = fetch_txtinfo("mid")
+       
+       if not data or not data.MID then
+               ffluci.template.render("public_olsr/error_olsr")
+               return nil
+       end
+       
+       local function compare(a, b)
+               return a.IP < b.IP
+       end
+       
+       table.sort(data.MID, compare)
+       
+       ffluci.template.render("public_olsr/mid", {mids=data.MID})
+end
+
+
+-- Internal
+function fetch_txtinfo(otable)
+       otable = otable or ""
+       local rawdata = ffluci.sys.httpget("http://127.0.0.1:2006/"..otable)
+       
+       if #rawdata == 0 then
+               return nil
+       end
+       
+       local data = {}
+       
+       local tables = ffluci.util.split(ffluci.util.trim(rawdata), "\n\n")
+       
+
+       for i, tbl in ipairs(tables) do
+               local lines = ffluci.util.split(tbl, "\n")
+               local name  = table.remove(lines, 1):sub(8)
+               local keys  = ffluci.util.split(table.remove(lines, 1), "\t")
+               
+               data[name] = {}
+               
+               for j, line in ipairs(lines) do
+                       local fields = ffluci.util.split(line, "\t")
+                       data[name][j] = {}
+                       for k, key in pairs(keys) do
+                               data[name][j][key] = fields[k] 
+                       end
+               end
+       end
+       
+       return data
+end
\ No newline at end of file
diff --git a/modules/freifunk/src/controller/public/status.lua b/modules/freifunk/src/controller/public/status.lua
new file mode 100644 (file)
index 0000000..8d2f7a3
--- /dev/null
@@ -0,0 +1,21 @@
+module("ffluci.controller.public.status", package.seeall)
+
+function action_index()
+       local data = {}
+       
+       data.s, data.m, data.r = ffluci.sys.sysinfo()
+       
+       data.wifi = ffluci.sys.wifi.getiwconfig()
+       
+       data.routes = {}
+       for i, r in pairs(ffluci.sys.net.routes()) do
+               if r.Destination == "00000000" then
+                       table.insert(data.routes, r)
+               end
+       end
+
+       
+       ffluci.template.render("public_status/index", data)
+end
+
+
diff --git a/modules/freifunk/src/controller/rpc/luciinfo.lua b/modules/freifunk/src/controller/rpc/luciinfo.lua
new file mode 100644 (file)
index 0000000..611423f
--- /dev/null
@@ -0,0 +1,41 @@
+module("ffluci.controller.rpc.luciinfo", package.seeall)
+
+function action_index()
+       local uci = ffluci.model.uci.StateSession()
+
+       ffluci.http.prepare_content("text/plain")
+       
+       -- General
+       print("luciinfo.api=1")
+       print("luciinfo.version=" .. tostring(ffluci.__version__))
+       
+       -- Sysinfo
+       local s, m, r = ffluci.sys.sysinfo()
+       local dr = ffluci.sys.net.defaultroute()
+       dr = dr and ffluci.sys.net.hexip4(dr.Gateway) or ""
+       local l1, l5, l15 = ffluci.sys.loadavg()
+       
+       print("sysinfo.system=" .. sanitize(s))
+       print("sysinfo.cpu=" .. sanitize(m))
+       print("sysinfo.ram=" .. sanitize(r))
+       print("sysinfo.hostname=" .. sanitize(ffluci.sys.hostname()))
+       print("sysinfo.load1=" .. tostring(l1))
+       print("sysinfo.load5=" .. tostring(l5))
+       print("sysinfo.load15=" .. tostring(l15))
+       print("sysinfo.defaultgw=" .. dr)
+
+       
+       -- Freifunk
+       local ff = uci:sections("freifunk") or {}
+       for k, v in pairs(ff) do
+               if k:sub(1, 1) ~= "." then
+                       for i, j in pairs(v) do
+                               print("freifunk." .. k .. "." .. i .. "=" .. j)
+                       end
+               end
+       end
+end
+
+function sanitize(val)
+       return val:gsub("\n", "\t")
+end
\ No newline at end of file
diff --git a/modules/freifunk/src/controller/sudo/status.lua b/modules/freifunk/src/controller/sudo/status.lua
new file mode 100644 (file)
index 0000000..fd5127d
--- /dev/null
@@ -0,0 +1 @@
+module("ffluci.controller.sudo.status", package.seeall)
\ No newline at end of file
diff --git a/modules/freifunk/src/i18n/admin_index_contact.en b/modules/freifunk/src/i18n/admin_index_contact.en
new file mode 100644 (file)
index 0000000..e2402e9
--- /dev/null
@@ -0,0 +1,11 @@
+contact1 = [[This information will be available on the public contact page.
+As stated in the Picopeering Agreement you should at least enter your e-mail address.
+To display your router on any topography map, please enter your geographical coordinates or at least
+your street and house number in the location field.]]
+nickname = "Nickname"
+mail1 = "This field is essential!"
+phone = "Phone"
+location = "Location"
+coord = "Coordinates"
+coord1 = "Latitude;Longitude (e.g. 51.5;12.9)"
+note = "Note"
\ No newline at end of file
diff --git a/modules/freifunk/src/model/cbi/admin_index/contact.lua b/modules/freifunk/src/model/cbi/admin_index/contact.lua
new file mode 100644 (file)
index 0000000..66a1ec4
--- /dev/null
@@ -0,0 +1,18 @@
+-- Todo: Translate
+m = Map("freifunk", translate("contact", "Kontakt"), translate("contact1", [[Diese Daten sind
+auf der öffentlichen Kontaktseite sichtbar. Bitte gib an, wie man dich am besten kontaktieren kann.
+Diese Informationen sollten nach der Picopeering Vereinbarung mindestens deine E-Mail-Adresse enthalten.
+Damit dein Knoten durch Topographieprogramme erfasst werden kann, gib bitte deine Geokoordinaten oder
+zumindest deine Straße und Hausnummer unter Standort an.]]))
+
+c = m:section(NamedSection, "contact", "public")
+
+c:option(Value, "nickname", translate("nickname", "Pseudonym"))
+c:option(Value, "name", translate("name", "Name"))
+c:option(Value, "mail", translate("mail", "E-Mail"), translate("mail1", "Bitte unbedingt angeben!"))
+c:option(Value, "phone", translate("phone", "Telefon"))
+c:option(Value, "location", translate("location", "Standort"))
+c:option(Value, "geo", translate("coord", "Koordinaten"), translate("coord1", "Bitte als Breite;Länge (z.B: 51.5;12.9) angeben"))
+c:option(Value, "note", translate("note", "Notiz"))
+
+return m
\ No newline at end of file
diff --git a/modules/freifunk/src/model/cbi/admin_index/freifunk.lua b/modules/freifunk/src/model/cbi/admin_index/freifunk.lua
new file mode 100644 (file)
index 0000000..ec4d100
--- /dev/null
@@ -0,0 +1,23 @@
+-- Todo: Translate
+m = Map("freifunk", "Freifunk")
+
+s = m:section(NamedSection, "routing", "settings", "Netzverkehr")
+s:option(Flag, "internal", "Freifunk zulassen", "immer aktivieren!")
+s:option(Flag, "internet", "Internet zulassen")
+
+c = m:section(NamedSection, "community", "public", "Gemeinschaft", [[Dies sind die Grundeinstellungen
+für die lokale Freifunkgemeinschaft. Diese Werte wirken sich NICHT auf die Konfiguration
+des Routers aus, sondern definieren nur die Vorgaben für den Freifunkassistenten.]])
+c:option(Value, "name", "Gemeinschaft")
+c:option(Value, "homepage", "Webseite")
+c:option(Value, "essid", "ESSID")
+c:option(Value, "bssid", "BSSID")
+c:option(Value, "channel", "Funkkanal")
+c:option(Value, "realm", "Realm")
+c:option(Value, "net", "Adressbereich")
+c:option(Value, "mask", "Netzmaske")
+c:option(Value, "dns", "DNS-Server")
+c:option(Value, "dhcp", "DHCP-Bereich")
+c:option(Value, "dhcpmask", "DHCP-Maske")
+
+return m
\ No newline at end of file
diff --git a/modules/freifunk/src/model/menu/10freifunk.lua b/modules/freifunk/src/model/menu/10freifunk.lua
new file mode 100644 (file)
index 0000000..3adbe89
--- /dev/null
@@ -0,0 +1,18 @@
+add("public", "index", "Übersicht", 10)
+act("contact", "Kontakt")
+
+add("public", "status", "Status", 20)
+act("routes", "Routingtabelle")
+act("iwscan", "WLAN-Scan")
+
+add("public", "olsr", "OLSR", 30)
+act("routes", "Routen")
+act("topology", "Topologie")
+act("hna", "HNA")
+act("mid", "MID")
+
+
+sel("admin", "index")
+act("wizard", "Freifunkassistent")
+act("contact", "Kontakt")
+act("freifunk", "Freifunk")
\ No newline at end of file
diff --git a/modules/freifunk/src/view/public_index/contact.htm b/modules/freifunk/src/view/public_index/contact.htm
new file mode 100644 (file)
index 0000000..221dc89
--- /dev/null
@@ -0,0 +1,13 @@
+<%+header%>
+<% local contact = ffluci.model.uci.sections("freifunk").contact %>
+<h1><%:contact Kontakt%></h1>
+<table cellspacing="0" cellpadding="6">
+       <tr><th><%:nickname Pseudonym%>:</th><td><%=contact.nickname%></td></tr>
+       <tr><th><%:name Name%>:</th><td><%=contact.name%></td></tr>
+       <tr><th><%:mail E-Mail%>:</th><td><%=contact.mail%></td></tr>
+       <tr><th><%:phone Telefon%>:</th><td><%=contact.phone%></td></tr>
+       <tr><th><%:location Standort%>:</th><td><%=contact.location%></td></tr>
+       <tr><th><%:geocoord Geokoordinaten%>:</th><td><%=contact.geo%></td></tr>
+       <tr><th><%:note Notiz%>:</th><td><%=contact.note%></td></tr>
+</table>
+<%+footer%>
\ No newline at end of file
diff --git a/modules/freifunk/src/view/public_index/index.htm b/modules/freifunk/src/view/public_index/index.htm
new file mode 100644 (file)
index 0000000..6c7fe85
--- /dev/null
@@ -0,0 +1,11 @@
+<%+header%>
+<% local ff = ffluci.model.uci.sections("freifunk") %>
+<h1><%:hellonet Hallo und willkommen im Netz von%> <%=ff.community.name%>!</h1>
+<p><%:public1 Wir sind eine Initiative zur Schaffung eines freien, offenen und unabhängigen Funknetzwerks auf WLAN-Basis.%><br />
+<%:public2 Dies ist der Zugangspunkt %><%=ffluci.sys.hostname()%>. <%:public3 Er wird betrieben von %>
+<a href="<%=controller%>/public/index/contact"><%=ff.contact.nickname%></a>.</p>
+<p><%:public4 Weitere Informationen zur globalen Freifunkinitiative findest du unter%> <a href="http://freifunk.net">Freifunk.net</a>.<br />
+<%:public5 Hast du Interesse an diesem Projekt, dann wende dich an deine lokale Gemeinschaft%> <a href="<%=ff.community.homepage%>"><%=ff.community.name%></a>.</p>
+<p><strong><%:note Hinweis%></strong>: <%:public6 Der Internetzugang über das experimentelle Freifunknetz ist an technische und organisatorische Bedingungen geknüpft und deshalb möglicherweise
+nicht (immer) gewährleistet.%></p>
+<%+footer%>
\ No newline at end of file
diff --git a/modules/freifunk/src/view/public_olsr/error_olsr.htm b/modules/freifunk/src/view/public_olsr/error_olsr.htm
new file mode 100644 (file)
index 0000000..25426f5
--- /dev/null
@@ -0,0 +1,6 @@
+<%+header%>
+<h1><%:olsr OLSR%></h1>
+<p class="error"><%:olsrerror1 Es konnte keine Verbindung zum OLSR-Daemon hergestellt werden!%></p>
+<p><%:olsrerror2 Um die Statusinformationen abfragen zu können muss der OLSR-Daemon gestartet
+und das Plugin "txtinfo" geladen sein.%></p>
+<%+footer%>
\ No newline at end of file
diff --git a/modules/freifunk/src/view/public_olsr/hna.htm b/modules/freifunk/src/view/public_olsr/hna.htm
new file mode 100644 (file)
index 0000000..c13369f
--- /dev/null
@@ -0,0 +1,17 @@
+<%+header%>
+<h1><%:olsrhna OLSR-HNA%></h1>
+<br />
+<table cellspacing="0" cellpadding="6">
+<tr>
+<th><%:destination Ziel%></th>
+<th><%:gateway Gateway%></th>
+</tr>
+<% for k, route in ipairs(routes) do %>
+<tr>
+<td><%=route.Network%>/<%=route.Netmask%></td>
+<td><a href="http://<%=route.Gateway%>"><%=route.Gateway%></a></td>
+</tr>
+<% end %>
+</table>
+<br />
+<%+footer%>
\ No newline at end of file
diff --git a/modules/freifunk/src/view/public_olsr/index.htm b/modules/freifunk/src/view/public_olsr/index.htm
new file mode 100644 (file)
index 0000000..0633d1f
--- /dev/null
@@ -0,0 +1,43 @@
+<%+header%>
+<h1><%:olsrlinks OLSR-Verbindungen%></h1>
+<p><%:olsrlinks1 Übersicht über aktuell bestehende OLSR-Verbindungen%></p>
+<br />
+<table cellspacing="0" cellpadding="6">
+<tr>
+<th><%:destination Ziel%></th>
+<th><%:local Lokal%></th>
+<th>LQ</th>
+<th>NLQ</th>
+<th>ETX</th>
+</tr>
+<% for k, link in ipairs(links) do 
+       local color = "#bb3333"
+       
+       link.ETX = tonumber(link.ETX)
+       if link.ETX == 0 then
+               color = "#bb3333"
+       elseif link.ETX < 4 then
+               color = "#00cc00"
+       elseif link.ETX < 10 then
+               color = "#ffcb05"
+       elseif link.ETX < 100 then
+               color = "#ff6600"
+       end
+%>
+<tr>
+<td><a href="http://<%=link["remote IP"]%>"><%=link["remote IP"]%></a></td>
+<td><%=link["Local IP"]%></td>
+<td><%=link.LinkQuality%></td>
+<td><%=link.NLQ%></td>
+<td style="background-color:<%=color%>"><%=link.ETX%></td>
+</tr>
+<% end %>
+</table>
+<br />
+<h3><%:legend Legende%>:</h3>
+<ul>
+<li><strong>LQ: </strong><%:lq1 Erfolgsquote gesendeter Pakete%></li>
+<li><strong>NLQ: </strong><%:nlq1 Erfolgsquote empfangener Pakete%></li>
+<li><strong>ETX: </strong><%:etx1 Zu erwartende Sendeversuche pro Paket%></li>
+</ul>
+<%+footer%>
\ No newline at end of file
diff --git a/modules/freifunk/src/view/public_olsr/mid.htm b/modules/freifunk/src/view/public_olsr/mid.htm
new file mode 100644 (file)
index 0000000..6553237
--- /dev/null
@@ -0,0 +1,17 @@
+<%+header%>
+<h1><%:olsrmid OLSR-MID%></h1>
+<br />
+<table cellspacing="0" cellpadding="6">
+<tr>
+<th><%:node Knoten%></th>
+<th><%:aliases Aliasse%></th>
+</tr>
+<% for k, mid in ipairs(mids) do %>
+<tr>
+<td><a href="http://<%=mid.IP%>"><%=mid.IP%></a></td>
+<td><%=mid.Aliases%></td>
+</tr>
+<% end %>
+</table>
+<br />
+<%+footer%>
\ No newline at end of file
diff --git a/modules/freifunk/src/view/public_olsr/routes.htm b/modules/freifunk/src/view/public_olsr/routes.htm
new file mode 100644 (file)
index 0000000..f3a0fd3
--- /dev/null
@@ -0,0 +1,36 @@
+<%+header%>
+<h1><%:olsrlinks OLSR-Routen%></h1>
+<br />
+<table cellspacing="0" cellpadding="6">
+<tr>
+<th><%:destination Ziel%></th>
+<th><%:gateway Gateway%></th>
+<th><%:interface Schnittstelle%></th>
+<th><%:metric Metrik%></th>
+<th>ETX</th>
+</tr>
+<% for k, route in ipairs(routes) do 
+       local color = "#bb3333"
+       
+       route.ETX = tonumber(route.ETX)
+       if route.ETX == 0 then
+               color = "#bb3333"
+       elseif route.ETX < 4 then
+               color = "#00cc00"
+       elseif route.ETX < 10 then
+               color = "#ffcb05"
+       elseif route.ETX < 100 then
+               color = "#ff6600"
+       end
+%>
+<tr>
+<td><%=route.Destination%></td>
+<td><%=route.Gateway%></td>
+<td><%=route.Interface%></td>
+<td><%=route.Metric%></td>
+<td style="background-color:<%=color%>"><%=route.ETX%></td>
+</tr>
+<% end %>
+</table>
+<br />
+<%+footer%>
\ No newline at end of file
diff --git a/modules/freifunk/src/view/public_olsr/topology.htm b/modules/freifunk/src/view/public_olsr/topology.htm
new file mode 100644 (file)
index 0000000..c622026
--- /dev/null
@@ -0,0 +1,23 @@
+<%+header%>
+<h1><%:olsrtopo OLSR-Topologie%></h1>
+<br />
+<table cellspacing="0" cellpadding="6">
+<tr>
+<th><%:destination Ziel%></th>
+<th><%:lasthop Letzter Router%></th>
+<th>LQ</th>
+<th>ILQ</th>
+<th>ETX</th>
+</tr>
+<% for k, route in ipairs(routes) do %>
+<tr>
+<td><a href="http://<%=route["Destination IP"]%>"><%=route["Destination IP"]%></a></td>
+<td><a href="http://<%=route["Last hop IP"]%>"><%=route["Last hop IP"]%></a></td>
+<td><%=route.LQ%></td>
+<td><%=route.ILQ%></td>
+<td><%=route.ETX%></td>
+</tr>
+<% end %>
+</table>
+<br />
+<%+footer%>
\ No newline at end of file
diff --git a/modules/freifunk/src/view/public_status/index.htm b/modules/freifunk/src/view/public_status/index.htm
new file mode 100644 (file)
index 0000000..be0b968
--- /dev/null
@@ -0,0 +1,59 @@
+<%+header%>
+<h1><%:status Status%></h1>
+<h2><%:system System%></h2>
+
+<br />
+<table cellspacing="0" cellpadding="6" class="smalltext">
+<tr>
+<th><%:system_type Systemtyp%>:</th>
+<td><%=s%></td>
+</tr>
+<tr>
+<th><%:cpu Prozessor%>:</th>
+<td><%=m%></td>
+</tr>
+<tr>
+<th><%:ram Hauptspeicher%>:</th>
+<td><%=r%></td>
+</tr>
+</table>
+<br /><br />
+
+<h2><%:wifi Drahtlos%></h2>
+<br />
+<table cellspacing="0" cellpadding="6" class="smalltext">
+<tr>
+<th><%:name Name%></th>
+<th><%:protocol Protokoll%></th>
+<th><%:frequency Frequenz%></th>
+<th><%:power Leistung%></th>
+<th><%:bitrate Bitrate%></th>
+<th><%:rts RTS%></th>
+<th><%:frag Frag.%></th>
+<th><%:link Verb.%></th>
+<th><%:signal Signal%></th>
+<th><%:noise Rausch%></th>
+</tr>
+<%=ffluci.sys.httpget("http://127.0.0.1" .. controller .. "/sudo/status/iwconfig")%>
+</table>
+<br />
+<br />
+<h2><%:defroutes Standardrouten%></h2>
+<br />
+<table cellspacing="0" cellpadding="6" class="smalltext">
+<tr>
+<th><%:gateway Gateway%></th>
+<th><%:metric Metrik%></th>
+<th><%:iface Schnittstelle%></th>
+</tr>
+<%
+for i, rt in pairs(routes) do
+%>
+<tr>
+<td><%=ffluci.sys.net.hexip4(rt.Gateway)%></th>
+<td><%=rt.Metric%></th>
+<td><%=rt.Iface%></th>
+</tr>
+<% end %>
+</table>
+<%+footer%>
\ No newline at end of file
diff --git a/modules/freifunk/src/view/public_status/iwscan.htm b/modules/freifunk/src/view/public_status/iwscan.htm
new file mode 100644 (file)
index 0000000..a8924c8
--- /dev/null
@@ -0,0 +1,21 @@
+<%+header%>
+<h1><%:iwscan WLAN-Scan%></h1>
+<p><%:iwscan1 Drahtlosnetzwerke in der lokalen Umgebung des Routers:%></p>
+
+<br />
+<table cellspacing="0" cellpadding="6" class="smalltext">
+<tr>
+<th><%:interface Schnittstelle%></th>
+<th><%:essid ESSID%></th>
+<th><%:bssid BSSID%></th>
+<th><%:mode Modus%></th>
+<th><%:channel Kanal%></th>
+<th><%:encr Vers.%></th>
+<th><%:link Verb.%></th>
+<th><%:signal Signal%></th>
+<th><%:noise Rausch%></th>
+</tr>
+<%=ffluci.sys.httpget("http://127.0.0.1" .. controller .. "/sudo/status/iwscan")%>
+</table>
+<br />
+<%+footer%>
\ No newline at end of file
diff --git a/modules/freifunk/src/view/public_status/routes.htm b/modules/freifunk/src/view/public_status/routes.htm
new file mode 100644 (file)
index 0000000..85b0221
--- /dev/null
@@ -0,0 +1,28 @@
+<%+header%>
+<h1><%:routes Routen%></h1>
+
+<br />
+<table cellspacing="0" cellpadding="6" class="smalltext">
+<tr>
+<th><%:target Ziel%></th>
+<th><%:netmask Netzmaske%></th>
+<th><%:gateway Gateway%></th>
+<th><%:metric Metrik%></th>
+<th><%:iface Schnittstelle%></th>
+</tr>
+<%
+local routes = ffluci.sys.net.routes()
+
+for i, r in pairs(routes) do
+%>
+<tr>
+<td><%=ffluci.sys.net.hexip4(r.Destination)%></td>
+<td><%=ffluci.sys.net.hexip4(r.Mask)%></td>
+<td><%=ffluci.sys.net.hexip4(r.Gateway)%></td>
+<td><%=r.Metric%></td>
+<td><%=r.Iface%></td>
+</tr>
+<% end %>
+</table>
+<br />
+<%+footer%>
\ No newline at end of file
diff --git a/modules/freifunk/src/view/sudo_status/iwconfig.htm b/modules/freifunk/src/view/sudo_status/iwconfig.htm
new file mode 100644 (file)
index 0000000..6f5dede
--- /dev/null
@@ -0,0 +1,21 @@
+<%
+ffluci.http.prepare_content("text/plain")
+for k, v in pairs(ffluci.sys.wifi.getiwconfig()) do
+%>
+<tr>
+<td rowspan="2"><%=k%></td>
+<td><%=v[1]%></td>
+<td><%=v.Frequency%></td>
+<td><%=v["Tx-Power"]%></td>
+<td><%=v["Bit Rate"]%></td>
+<td><%=v["RTS thr"]%></td>
+<td><%=v["Fragment thr"]%></td>
+<td><%=v["Link Quality"]%></td>
+<td><%=v["Signal level"]%></td>
+<td><%=v["Noise level"]%></td>
+</tr>
+<tr>
+<td colspan="4"><strong>ESSID: </strong><%=v.ESSID%></td>
+<td colspan="5"><strong>BSSID: </strong><%=(v.Cell or v["Access Point"])%></td>
+</tr>
+<%end%>
diff --git a/modules/freifunk/src/view/sudo_status/iwscan.htm b/modules/freifunk/src/view/sudo_status/iwscan.htm
new file mode 100644 (file)
index 0000000..6f321ae
--- /dev/null
@@ -0,0 +1,22 @@
+<%
+ffluci.http.prepare_content("text/plain")
+for iface, cells in pairs(ffluci.sys.wifi.iwscan()) do
+       for i, cell in ipairs(cells) do 
+%>
+<tr>
+<td><%=iface%></td>
+<td><%=cell.ESSID%></td>
+<td><%=cell.Address%></td>
+<td><%=cell.Mode%></td>
+<td><%=(cell.Channel or cell.Frequency or "")%></td>
+<td><%=cell["Encryption key"]%></td>
+<td><%=cell.Quality%></td>
+<td><%=cell["Signal level"]%></td>
+<td><%=cell["Noise level"]%></td>
+</tr>
+<%
+       end
+end
+%>
+
+