Freifunk Dresden: Unterschied zwischen den Versionen

Aus C3D2
Zur Navigation springen Zur Suche springen
Zeile 120: Zeile 120:
     middle = a[3]
     middle = a[3]
     if a[2]=="201" then middle = middle + 256 end
     if a[2]=="201" then middle = middle + 256 end
     minor = math.floor(a[4]/64) --x>>6  
     minor = math.floor(a[4]/64) --x>>6
     node = middle*4+minor --x<<2
     node = middle*4+minor --x<<2
     if node < 0 or node > ipcalc.data.max then return -1 end
     if node < 0 or node > ipcalc.data.max then return -1 end
Zeile 127: Zeile 127:


function ipcalc.calc(node)
function ipcalc.calc(node)
    --node has to be a number n \in N_0, 0 <= n <= 2048
     if node==nil or node=="" then return -1 end
     if node==nil or node=="" then return -1 end
     node=tonumber(node)
     node=tonumber(node)
Zeile 134: Zeile 135:
     local domain = "freifunk-dresden.de"
     local domain = "freifunk-dresden.de"


    --Ternary Operator in use
    -- major network for nodes n < 1024: 200, for nodes > 1023: 201
     local major  = node >= 1024 and 201 or 200                    --a[2]
     local major  = node >= 1024 and 201 or 200                    --a[2]
    -- etc.
     local middle  = node >= 1024 and math.floor((node-1024) / 4) or math.floor(node / 4)  --a[3]
     local middle  = node >= 1024 and math.floor((node-1024) / 4) or math.floor(node / 4)  --a[3]
     local minor  = (node % 4) * 64  
     local minor  = (node % 4) * 64


     local meshnet = "10"
     local meshnet = "10"
     local nodeip  = meshnet .. "." .. major .. "." .. middle .. "." .. minor + 1  
     local nodeip  = meshnet .. "." .. major .. "." .. middle .. "." .. minor + 1
     local meshnetmask = "255.0.0.0"
     local meshnetmask = "255.0.0.0"
     local meshpre = 15
     local meshpre = 15
Zeile 146: Zeile 150:


     local dhcpstart    = meshnet .. "." .. major .. "." .. middle .. "." .. minor + 2
     local dhcpstart    = meshnet .. "." .. major .. "." .. middle .. "." .. minor + 2
     local dhcpend      = meshnet .. "." .. major .. "." .. middle .. "." .. minor + 63  
     local dhcpend      = meshnet .. "." .. major .. "." .. middle .. "." .. minor + 63
     local dhcpoffset    = 1 --used by config/dhcp  
     local dhcpoffset    = 1 --used by config/dhcp
     local dhcplimit    = 62 --used by config/dhcp
     local dhcplimit    = 62 --used by config/dhcp
     local dhcprangepre  = 26
     local dhcprangepre  = 26
Zeile 160: Zeile 164:
     -- client range
     -- client range
     local mesh6nodenet= "fd11:11ae:7466:" .. string.format("%x", node) .. "::"
     local mesh6nodenet= "fd11:11ae:7466:" .. string.format("%x", node) .. "::"
     local mesh6ip = mesh6nodenet .. "1"  
     local mesh6ip = mesh6nodenet .. "1"
     local mesh6nodepre= "64"
     local mesh6nodepre= "64"


    -- preparing variabled to be expoted
     ipcalc.data.node              = node
     ipcalc.data.node              = node
     ipcalc.data.domain            = domain  
     ipcalc.data.domain            = domain
     ipcalc.data.hostname          = "r" .. node
     ipcalc.data.hostname          = "r" .. node
     ipcalc.data.ip                = nodeip  
     ipcalc.data.ip                = nodeip
     ipcalc.data.network            = meshnetwork  
     ipcalc.data.network            = meshnetwork
     ipcalc.data.netpre            = meshpre
     ipcalc.data.netpre            = meshpre
     ipcalc.data.netmask            = meshnetmask  
     ipcalc.data.netmask            = meshnetmask
     ipcalc.data.broadcast          = meshbroadcast  
     ipcalc.data.broadcast          = meshbroadcast
     ipcalc.data.dhcpstart          = dhcpstart
     ipcalc.data.dhcpstart          = dhcpstart
     ipcalc.data.dhcpend            = dhcpend
     ipcalc.data.dhcpend            = dhcpend
     ipcalc.data.dhcpoffset   = dhcpoffset
     ipcalc.data.dhcpoffset   = dhcpoffset
     ipcalc.data.dhcplimit        = dhcplimit
     ipcalc.data.dhcplimit        = dhcplimit
     ipcalc.data.dhcprangepre      = dhcprangepre  
     ipcalc.data.dhcprangepre      = dhcprangepre
     ipcalc.data.dhcprangemask      = dhcprangemask  
     ipcalc.data.dhcprangemask      = dhcprangemask
     ipcalc.data.dhcpnetwork        = dhcpnetwork  
     ipcalc.data.dhcpnetwork        = dhcpnetwork
     ipcalc.data.dhcpbroadcast      = dhcpbroadcast  
     ipcalc.data.dhcpbroadcast      = dhcpbroadcast
     ipcalc.data.dhcpnetmask        = dhcpnetmask  
     ipcalc.data.dhcpnetmask        = dhcpnetmask
     ipcalc.data.clienthna          = hna  
     ipcalc.data.clienthna          = hna
     ipcalc.data.mesh6ip   = mesh6ip
     ipcalc.data.mesh6ip   = mesh6ip
     ipcalc.data.mesh6net   = mesh6net
     ipcalc.data.mesh6net   = mesh6net
Zeile 196: Zeile 201:
     ipcalc.calc(node)
     ipcalc.calc(node)


     for k,v in pairs(ipcalc.data)
     for k,v in pairs(ipcalc.data) do
    do
         print("export _ddmesh_"..k.."="..v)
         print("export _ddmesh_"..k.."="..v)
     end
     end
end
end


--not needed for ip address calculation
function iplookup(ip)
function iplookup(ip)
if ip==nil then return -1 end
if ip==nil then return -1 end
Zeile 210: Zeile 215:
end
end


--not needed for ip address calculation
function lookup(node)
function lookup(node)
if node==nil then return -1 end
if node==nil then return -1 end
if string.sub(node,1,1) == "r" then  
if string.sub(node,1,1) == "r" then
n=tonumber(string.sub(node,2))  
n=tonumber(string.sub(node,2))
else  
else
n=tonumber(node)
n=tonumber(node)
end
end

Version vom 8. September 2014, 09:07 Uhr

b0rk3d

Teile des folgenden Inhalts sind nicht korrekt. Begründung: Technische Details depubliziert unter Intern:Freifunk_Dresden.

Freifunk Dresden ist das Projekt in Dresden zu wikipedia:de:Freifunk.


Entstehung

Freifunk Dresden wurde ursprünglich unter dem Namen ddmesh von Stephan Enderlein gestartet und existiert bereits seit einigen Jahren. Seit 2014 sind stabil mehr als 50 Knoten in Dresden erreichbar und auch Geschäfte in Dresden nehmen die Vorteile von Freifunk für sich und ihre Kunden wahr.

Original-Firmware

Die Firmware basiert auf OpenWrt mit BMX (Vorläufer von batman-adv) und einer custom Weboberfläche.

Nutzung der wenig dokumentierten Original-Firmware hat folgende Vorteile:

  • Konsistente Konfiguration mit fast allen anderen Teilnehmern
  • Anschluß ans Backbone-VPN (vtun)
  • Offenes WLAN, welches über das Backbone ins Internet kommt (alternativ durch zusätzliche Pakete ein eigener VPN-Dienst konfigurierbar)
  • Webserver der die Knotenmetadaten ausliefert

Freie Software und Peering

Die Software ist frei und kann durch die Quellen von OpenWRT und die Sourcen zu Änderungen von der Freifunk-Seite eingesehen werden. Konfiguration und Scripte sind in den Images zu finden. Eine komplette Öffnung des Projektes ist bisher nicht vorgesehen gewesen, sodass u.a. eine Anleitung zum Selbstbau der Firmware fehlt und die Dokumentation so gut wie nicht vorhanden ist.

Da zu [Freier Software|Freie Software] für viele von uns auch der freie und möglichst barrierefreiem Zugang zu weiteren Informationen zählt, wollen wir diesen Umstand ändern - auch um Freifunk noch besser machen zu können. Im Widerspruch dazu steht das berechtigte Interesse der bisherigen Freifunk-Teilnehmer auf einen Störungsfreien Betrieb und infolgedessen Imageschaden bei den normalen Benutzern, der durch Experimente mit alternativer Firmware gefährdet sein könnte - das Marketing für Freie Software sowie für Freifunk selbst sind leider schwierig.

Ideen dazu werden derzeit diskutiert um die jetzigen Betreiber in Blick auf offenem Zugang zu Informationen zu überzeugen.

Links

WLAN-Einstellungen

Wird derzeit Intern beschrieben.

Adressvergabe

IP-Adressberechnungs mit Shell- und Lua Script

Die Scripte deren Algorithmus formalisiert werden soll:

usr/bin/ddmesh-ipcalc.sh
#!/bin/sh

if [ "$1" = "" ]
then
	echo ""
        echo "ddmesh-ipcalc.sh (lua) Stephan Enderlein (c) 2013 V1.7"
	echo ""
        echo "Calculates all the addresses for the ddmesh freifunk node"
	echo "usage: ddmesh-ipcalc.sh [-n node] | [ip]"
	echo ""
        exit 1
fi

if [ "$1" = "-n" ]; then
	node=`echo "$2" | sed 's/[\$\`\(\)]/0/g'`
	lua -lddmesh -e "ipcalc.print($node)"
else
	ip=`echo "$1" | sed 's/[\$\`\(\)]/0/g'`
	lua -lddmesh -e "print(iplookup(\"$ip\"))"
fi

usr/lib/lua/ddmesh.lua
--[[----------------------------------------------------------------------------------------
ddmesh.lua
library for different freifunk functions
version: 6
-------------------------------------------------------------------------------------------]]

----------------- ipcalc ---------------
ipcalc={}
ipcalc.data={}
ipcalc.data.max=2048

function split(str, delim, maxNb)
    -- Eliminate bad cases...
    if string.find(str, delim) == nil then
        return { str }
    end
    if maxNb == nil or maxNb < 1 then
        maxNb = 0    -- No limit
    end
    local result = {}
    local pat = "(.-)" .. delim .. "()"
    local nb = 0
    local lastPos
    for part, pos in string.gfind(str, pat) do
        nb = nb + 1
        result[nb] = part
        lastPos = pos
        if nb == maxNb then break end
    end
    -- Handle the last field
    if nb ~= maxNb then
        result[nb + 1] = string.sub(str, lastPos)
    end
    return result
end

function ipcalc.rCalcIp(ip)
    if ip==nil or ip=="" then return -1 end
    a = split(ip, "[.]")
    if #a ~= 4 then return -1 end
    if a[1]==nil or a[1]=="" or tonumber(a[1]) ~= 10 then return -1 end
    if a[2]==nil or a[2]=="" or tonumber(a[2]) ~= 200 and tonumber(a[2]) ~= 201 then return -1 end
    if a[3]==nil or a[3]=="" or tonumber(a[3]) < 0 or tonumber(a[3]) > 255 then return -1 end
    if a[4]==nil or a[4]=="" or tonumber(a[4]) < 0 or tonumber(a[4]) > 255 then return -1 end

    middle = a[3]
    if a[2]=="201" then middle = middle + 256 end
    minor = math.floor(a[4]/64) --x>>6
    node = middle*4+minor	--x<<2
    if node < 0 or node > ipcalc.data.max then return -1 end
    return node
end

function ipcalc.calc(node)
    --node has to be a number n \in N_0, 0 <= n <= 2048
    if node==nil or node=="" then return -1 end
    node=tonumber(node)
    if node==nil or node=="" then return -1 end
    if node < 0 or node > ipcalc.data.max then return -1 end

    local domain	= "freifunk-dresden.de"

    --Ternary Operator in use
    -- major network for nodes n < 1024: 200, for nodes > 1023: 201
    local major   = node >= 1024 and 201 or 200                     --a[2]
    -- etc.
    local middle  = node >= 1024 and math.floor((node-1024) / 4) or math.floor(node / 4)  --a[3]
    local minor   = (node % 4) * 64

    local meshnet	= "10"
    local nodeip  	= meshnet .. "." .. major .. "." .. middle .. "." .. minor + 1
    local meshnetmask	= "255.0.0.0"
    local meshpre 	= 15
    local meshbroadcast = "10.255.255.255"
    local meshnetwork   = "10.200.0.0"

    local dhcpstart     = meshnet .. "." .. major .. "." .. middle .. "." .. minor + 2
    local dhcpend       = meshnet .. "." .. major .. "." .. middle .. "." .. minor + 63
    local dhcpoffset    = 1	--used by config/dhcp
    local dhcplimit     = 62	--used by config/dhcp
    local dhcprangepre  = 26
    local dhcprangemask = "255.255.255.192"
    local dhcpnetmask   = "255.255.255.255"
    local dhcpbroadcast = "10.255.255.255" -- needed, else dnsmasq will not start
    local dhcpnetwork   = meshnet .. "." .. major .. "." .. middle .. "." .. minor

    local hna = meshnet .. "." .. major .. "." .. middle .. "." .. minor .. "/" .. dhcprangepre
    local mesh6pre	= "48"
    local mesh6net	= "fd11:11ae:7466::"
    -- client range
    local mesh6nodenet= "fd11:11ae:7466:" .. string.format("%x", node) .. "::"
    local mesh6ip	= mesh6nodenet .. "1"
    local mesh6nodepre= "64"

    -- preparing variabled to be expoted
    ipcalc.data.node               = node
    ipcalc.data.domain             = domain
    ipcalc.data.hostname           = "r" .. node
    ipcalc.data.ip                 = nodeip
    ipcalc.data.network            = meshnetwork
    ipcalc.data.netpre             = meshpre
    ipcalc.data.netmask            = meshnetmask
    ipcalc.data.broadcast          = meshbroadcast
    ipcalc.data.dhcpstart          = dhcpstart
    ipcalc.data.dhcpend            = dhcpend
    ipcalc.data.dhcpoffset	   = dhcpoffset
    ipcalc.data.dhcplimit      	   = dhcplimit
    ipcalc.data.dhcprangepre       = dhcprangepre
    ipcalc.data.dhcprangemask      = dhcprangemask
    ipcalc.data.dhcpnetwork        = dhcpnetwork
    ipcalc.data.dhcpbroadcast      = dhcpbroadcast
    ipcalc.data.dhcpnetmask        = dhcpnetmask
    ipcalc.data.clienthna          = hna
    ipcalc.data.mesh6ip		   = mesh6ip
    ipcalc.data.mesh6net	   = mesh6net
    ipcalc.data.mesh6pre	   = mesh6pre
    ipcalc.data.mesh6nodenet	   = mesh6nodenet
    ipcalc.data.mesh6nodepre	   = mesh6nodepre
end

function ipcalc.print(node)

    if node==nil or node=="" then print("ERROR"); return -1 end
    node=tonumber(node)
    if node==nil then print("ERROR"); return -1 end
    if node < 0 or node > ipcalc.data.max then return -1 end
    ipcalc.calc(node)

    for k,v in pairs(ipcalc.data) do
        print("export _ddmesh_"..k.."="..v)
    end
end

--not needed for ip address calculation
function iplookup(ip)
	if ip==nil then return -1 end
	n=ipcalc.rCalcIp(ip)
	if n == -1 then return -1 end
	ipcalc.calc(n)
	return ipcalc.data.hostname
end

--not needed for ip address calculation
function lookup(node)
	if node==nil then return -1 end
	if string.sub(node,1,1) == "r" then
		n=tonumber(string.sub(node,2))
	else
		n=tonumber(node)
	end
	if n==nil then return -1 end
	if n < 0 or n > ipcalc.data.max then return -1 end
	ipcalc.calc(n)
	return ipcalc.data.ip
end

Metadaten

Freifunk-API

Es existiert eine Inter-Community-API analog zur SpaceAPI. Beispiel: Freifunk API Viewer

Directory.json, Dresden

Knotenmetadaten

Jeder Knoten bietet ein JSON-Dokument unter http://10.200.../sysinfo-json.cgi an. Es enthält Versionsstände, Geokoordinaten, Kontaktinfo, Auslastung und alle Routen.

Siehe auch

Weblinks