luci is back

This commit is contained in:
Sukru Senli 2015-06-15 10:41:51 +02:00
parent cc2149cb33
commit c1227c9fcb
108 changed files with 5699 additions and 0 deletions

2
webgui/luci/Makefile Normal file
View file

@ -0,0 +1,2 @@
include ../../build/config.mk
include ../../build/module.mk

View file

@ -0,0 +1,39 @@
# Copyright (C) 2011 Manuel Munz <freifunk at somakoma de>
# This is free software, licensed under the Apache 2.0 license.
include $(TOPDIR)/rules.mk
PKG_NAME:=community-profiles
PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/community-profiles
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=9. Freifunk
TITLE:=Community profiles
DEPENDS:=freifunk-common
endef
define Package/community-profiles/description
These community profiles set defaults for various free network/freifunk communities and are used by wizards like ffwizard and meshwizard.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/community-profiles/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,community-profiles))

View file

@ -0,0 +1,10 @@
config 'community' 'profile'
option 'name' 'Freifunk'
option 'homepage' 'http://freifunk.net'
option 'ssid' 'www.freifunk.net'
option 'splash_network' '10.104.0.0/16'
option 'latitude' '52.000'
option 'longitude' '10.000'
option 'splash_prefix' '28'
option 'mesh_network' '10.0.0.0/8'

View file

@ -0,0 +1,10 @@
config 'community' 'profile'
option 'name' 'Aachen'
option 'homepage' 'http://aachen.freifunk.net'
option 'ssid' 'aachen.freifunk.net'
option 'suffix' 'ffac'
option 'latitude' '50.77900'
option 'longitude' '6.05399'
option 'mesh_network' '10.90.0.0/16'
option 'splash_network' '10.104.0.0/16'
option 'splash_prefix' '28'

View file

@ -0,0 +1,18 @@
config 'community' 'profile'
option 'name' 'Freifunk Augsburg'
option 'homepage' 'http://augsburg.freifunk.net'
option 'ssid' 'augsburg.freifunk.net'
option 'mesh_network' '10.11.0.0/18'
option 'splash_network' '10.104.0.0/16'
option 'latitude' '48.37071'
option 'longitude' '10.89475'
option 'suffix' 'ffa'
option 'splash_prefix' '27'
config 'defaults' 'interface'
option 'netmask' '255.255.192.0'
config 'defaults' 'bssidscheme'
option '1' '02:CA:FF:EE:BA:BE'
option '13' '13:CA:FF:EE:BA:BE'

View file

@ -0,0 +1,20 @@
config 'community' 'profile'
option 'name' 'Freifunk Bayreuth'
option 'homepage' 'http://bayreuth.freifunk.net'
option 'ssid' 'bayreuth.freifunk.net'
option 'mesh_network' '10.195.0.0/16'
option 'splash_network' '10.104.0.0/16'
option 'latitude' '49.945812'
option 'longitude' '11.575045'
option 'suffix' 'ffbt'
option 'splash_prefix' '28'
config 'defaults' 'interface'
option 'netmask' '255.255.192.0'
config 'defaults' 'wifi_device'
option 'channel' '4'
config 'defaults' 'wifi_iface'
option 'bssid' '42:CA:FF:EE:BA:BE'

View file

@ -0,0 +1,9 @@
config 'community' 'profile'
option 'name' 'Freifunk Bensheim'
option 'homepage' 'http://bensheim.freifunk.net'
option 'ssid' 'bensheim.freifunk.net'
option 'mesh_network' '10.49.0.0/16'
option 'splash_network' '10.104.0.0/16'
option 'splash_prefix' '27'
option 'latitude' '49.63939'
option 'longitude' '8.633718'

View file

@ -0,0 +1,15 @@
config 'community' 'profile'
option 'name' 'Piratenfreifunk Bergisches Land'
option 'homepage' 'http://www.piraten-bergisches-land.de'
option 'ssid' 'PiratenfunkBL'
option 'mesh_network' '10.3.0.0/16'
option 'splash_network' '192.168.0.0/16'
option 'splash_prefix' '27'
option 'latitude' '51.26849'
option 'longitude' '7.19476'
config 'defaults' 'wifi_device'
option 'channel' '11'
config 'defaults' 'wifi_iface'
option 'bssid' '02:40:00:42:42:42'

View file

@ -0,0 +1,16 @@
config 'community' 'profile'
option 'name' 'Freifunk Berlin'
option 'homepage' 'http://berlin.freifunk.net'
option 'ssid' 'olsr.freifunk.net'
option 'mesh_network' '104.0.0.0/8'
option 'splash_network' '10.104.0.0/16'
option 'splash_prefix' '27'
option 'latitude' '52.52075'
option 'longitude' '13.40948'
config 'defaults' 'wifi_device'
option 'channel' '10'
config 'defaults' 'interface'
option 'netmask' '255.0.0.0'

View file

@ -0,0 +1,23 @@
config 'community' 'profile'
option 'name' 'carbodebit'
option 'homepage' 'http://carbodebit.net'
option 'ssid' 'VHDCARBES'
option 'mesh_network' '10.72.1.0/24'
option 'latitude' '43.633683'
option 'longitude' '2.160894'
config 'defaults' 'wifi_iface'
option 'bssid' 'DE:78:70:E4:FA:B8'
config 'defaults' 'interface'
option 'netmask' '255.255.255.0'
option 'dns' '10.70.1.1 213.190.64.170 213.190.64.166'
config 'defaults' 'wifi_device'
option 'channel' '11'
option 'country' 'FR'
option 'distance' '2000'
config 'defaults' 'bssidscheme'
option 'all' 'DE:78:70:E4:FA:B8'

View file

@ -0,0 +1,15 @@
config 'community' 'profile'
option 'name' 'Freifunk Duesseldorf'
option 'homepage' 'http://freifunk-duesseldorf.de'
option 'ssid' 'duesseldorf.freifunk.net'
option 'mesh_network' '10.40.0.0/16'
option 'splash_network' '10.104.0.0/16'
option 'splash_prefix' '27'
option 'latitude' '51.217812'
option 'longitude' '6.761564'
config 'defaults' 'wifi_device'
option 'channel' '3'
config 'defaults' 'wifi_iface'
option 'bssid' '02:CA:FF:EE:BA:BE'

View file

@ -0,0 +1,25 @@
config 'community' 'profile'
option 'name' 'Freifunk Evernet eG'
option 'homepage' 'http://www.evernet-eg.de'
option 'ssid' 'evernet.freifunk.net'
option 'mesh_network' '10.0.0.0/8'
option 'latitude' '51.15692062509162'
option 'longitude' '10.716041922569275'
option 'suffix' 'evernet'
config 'defaults' 'interface'
option 'netmask' '255.0.0.0'
config 'defaults' 'bssidscheme'
option 'all' '02:CA:FF:EE:BA:BE'
config 'defaults' 'wifi_device'
option 'channel' '13'
option 'country' 'DE'
option 'txpower' '19'
option 'beacon_int' '5000'
option 'distance' '1500'
option 'noscan' '0'
config 'defaults' 'wifi_iface'
option 'mcast_rate' '6000'

View file

@ -0,0 +1,19 @@
config 'community' 'profile'
option 'name' 'Freifunk Franken'
option 'homepage' 'http://franken.freifunk.net'
option 'ssid' 'franken.freifunk.net'
option 'mesh_network' '10.50.0.0/16'
option 'splash_network' '10.104.0.0/16'
option 'latitude' '49.506485'
option 'longitude' '11.013565#
option 'splash_prefix' '27'
config 'defaults' 'interface'
option 'netmask' '255.255.0.0'
config 'defaults' 'bssidscheme'
option '1' '02:CA:FF:EE:BA:BE'
config 'defaults' 'luci_splash'
option 'limit_up' '40'
option 'limit_down' '40'

View file

@ -0,0 +1,15 @@
config 'community' 'profile'
option 'name' 'Freifunk Gadow'
option 'homepage' 'http://gadow.freifunk.net'
option 'ssid' 'gadow.freifunk.net'
option 'mesh_network' '104.0.0.0/8'
option 'splash_network' '10.61.0.0/16'
option 'splash_prefix' '27'
option 'latitude' '53.11'
option 'longitude' '12.61'
config 'defaults' 'interface'
option 'netmask' '255.0.0.0'
config 'defaults' 'bssidscheme'
option '1' '02:CA:FF:EE:BA:BE'

View file

@ -0,0 +1,19 @@
config 'community' 'profile'
option 'name' 'Guifi Bages'
option 'homepage' 'http://guifi.net/PlaBages'
option 'ssid' 'guifibages'
option 'mesh_network' '10.224.3.0/16'
option 'splash_network' '10.104.0.0/16'
option 'theme' 'luci-theme-freifunk-generic'
option 'latitude' '41.718437'
option 'longitude' '1.826477'
option 'suffix' 'guifibages.cat'
option 'splash_prefix' '27'
option 'extrapackages' 'luci-app-olsr-viz luci-i18n-catalan'
config 'defaults' 'interface'
option 'netmask' '255.255.0.0'
config 'defaults' 'bssidscheme'
option 'all' '12:34:56:78:9a:bc'

View file

@ -0,0 +1,17 @@
config 'community' 'profile'
option 'name' 'Freifunk Halle'
option 'homepage' 'http://freifunk-halle.net'
option 'ssid' 'halle.freifunk.net'
option 'mesh_network' '104.62.0.0/16'
option 'splash_network' '10.104.0.0/16'
option 'splash_prefix' '27'
option 'latitude' '51.47911'
option 'longitude' '11.96901'
config 'defaults' 'wifi_device'
option 'channel' '13'
config 'defaults' 'bssidscheme'
option 'all' '02:CA:FF:EE:BA:BE'

View file

@ -0,0 +1,15 @@
config 'community' 'profile'
option 'name' 'Freifunk Hamburg'
option 'homepage' 'http://hamburg.piratenpartei.de'
option 'ssid' 'hamburg.freifunk.net'
option 'mesh_network' '10.112.0.0/12'
option 'splash_network' '10.104.0.0/16'
option 'splash_prefix' '27'
option 'latitude' '53.56262'
option 'longitude' '10.01069'
config 'defaults' 'interface'
option 'netmask' '255.240.0.0'
config 'defaults' 'wifi_device'
option 'channel' '1'

View file

@ -0,0 +1,12 @@
config 'community' 'profile'
option 'name' 'Freifunk Hannover'
option 'homepage' 'http://hannover.freifunk.net'
option 'ssid' 'hannover.freifunk.net'
option 'mesh_network' '10.2.0.0/16'
option 'splash_network' '10.104.0.0/16'
option 'splash_prefix' '27'
option 'latitude' '52.38427'
option 'longitude' '9.74359'
config 'defaults' 'wifi_iface'
option 'bssid' 'CA:FF:EE:CA:FF:EE'

View file

@ -0,0 +1,9 @@
config 'community' 'profile'
option 'name' 'Freifunk Heppenheim'
option 'homepage' 'http://heppenheim.freifunk.net'
option 'ssid' 'heppenheim.freifunk.net'
option 'mesh_network' '10.48.0.0/16'
option 'splash_network' '10.104.0.0/16'
option 'splash_prefix' '27'
option 'latitude' '51.151786'
option 'longitude' '10.415039'

View file

@ -0,0 +1,12 @@
config 'community' 'profile'
option 'name' 'Freifunk Jena'
option 'homepage' 'http://www.freifunk-jena.de'
option 'ssid' 'www.freifunk-jena.de'
option 'mesh_network' '10.127.0.0/20'
option 'splash_network' '10.104.0.0/16'
option 'splash_prefix' '29'
option 'latitude' '50.92779'
option 'longitude' '11.58431'
config 'defaults' 'interface'
option 'dns' '217.11.48.200 217.11.49.200 8.8.8.8'

View file

@ -0,0 +1,15 @@
config 'community' 'profile'
option 'name' 'Kiberpipa.net'
option 'homepage' 'http://www.kiberpipa.net'
option 'ssid' 'open.kiberpipa.net'
option 'mesh_network' '10.14.0.0/16'
option 'splash_network' '10.14.128.0/17'
option 'splash_prefix' '27'
option 'latitude' '46.05063'
option 'longitude' '14.50402'
config 'defaults' 'wifi_device'
option 'channel' '8'
config 'defaults' 'interface'
option 'dns' '10.14.0.1 208.67.222.220 208.67.220.222'

View file

@ -0,0 +1,12 @@
config 'community' 'profile'
option 'name' 'Freifunk L59'
option 'homepage' 'http://freifunk.net'
option 'ssid' 'start.freifunk.net'
option 'mesh_network' '104.59.0.0/16'
option 'splash_network' '10.104.0.0/16'
option 'splash_prefix' '27'
option 'latitude' '52.26337'
option 'longitude' '10.52103'
config 'defaults' 'bssidscheme'
option '1' '02:CA:FF:EE:BA:BE'

View file

@ -0,0 +1,15 @@
config 'community' 'profile'
option 'name' 'Freifunk Leipzig'
option 'homepage' 'http://leipzig.freifunk.net'
option 'ssid' 'leipzig.freifunk.net'
option 'mesh_network' '104.61.0.0/16'
option 'splash_network' '10.104.0.0/16'
option 'splash_prefix' '27'
option 'latitude' '51.33348'
option 'longitude' '12.40297'
config 'defaults' 'interface'
option 'netmask' '255.0.0.0'
config 'defaults' 'bssidscheme'
option '1' '02:CA:FF:EE:BA:BE'

View file

@ -0,0 +1,15 @@
config 'community' 'profile'
option 'name' 'Freifunk Mainz'
option 'homepage' 'http://mainz.freifunk.net'
option 'ssid' 'mainz.freifunk.net'
option 'mesh_network' '10.37.0.0/16'
option 'splash_network' '10.104.0.0/16'
option 'splash_prefix' '27'
option 'latitude' '49.99635'
option 'longitude' '8.27417'
config 'defaults' 'wifi_iface'
option 'bssid' '02:ca:ff:ee:ba:be'
config 'defaults' 'wifi_device'
option 'channel' '1'

View file

@ -0,0 +1,12 @@
config 'community' 'profile'
option 'name' 'Freifunk Marburg'
option 'homepage' ' http://marburg.freifunk.de'
option 'ssid' 'marburg.freifunk.net'
option 'mesh_network' '10.128.0.0/16'
option 'splash_network' '10.104.0.0/16'
option 'splash_prefix' '29'
option 'latitude' '49.63939'
option 'longitude' '8.633718'
config 'defaults' 'interface'
option 'dns' '8.8.8.8 212.204.49.83'

View file

@ -0,0 +1,15 @@
config 'community' 'profile'
option 'name' 'Freifunk Neuss'
option 'homepage' 'http://neuss.freifunk.net'
option 'ssid' 'neuss.freifunk.net'
option 'mesh_network' '172.28.0.0/16'
option 'splash_network' '10.104.0.0/16'
option 'splash_prefix' '27'
option 'latitude' '51.19045'
option 'longitude' '6.69471'
config 'defaults' 'wifi_device'
option 'channel' '11'
config 'defaults' 'wifi_iface'
option 'bssid' 'DE:AD:BE:EF:CA:FE'

View file

@ -0,0 +1,15 @@
config 'community' 'profile'
option 'name' 'Freifunk Oldenburg'
option 'homepage' 'http://oldenburg.freifunk.net'
option 'ssid' 'oldenburg.freifunk.net'
option 'mesh_network' '10.18.0.0/16'
option 'splash_network' '10.104.0.0/16'
option 'splash_prefix' '27'
option 'latitude' '53.14083'
option 'longitude' '8.21314'
config 'defaults' 'wifi_device'
option 'channel' '6'
config 'defaults' 'wifi_iface'
option 'bssid' '02:CA:FF:EE:BA:BE'

View file

@ -0,0 +1,18 @@
config 'community' 'profile'
option 'name' 'Openwireless Bern'
option 'homepage' 'http://bern.openwireless.ch/'
option 'ssid' 'www.openwireless.ch'
option 'mesh_network' '10.247.0.0/16'
option 'splash_network' '10.104.0.0/16'
option 'splash_prefix' '27'
option 'latitude' '50.814788'
option 'longitude' '8.769239'
config 'defaults' 'interface'
option 'dns' '208.67.222.222 208.67.220.220'
config 'defaults' 'wifi_device'
option 'channel' '10'
option 'country' '756'

View file

@ -0,0 +1,12 @@
config 'community' 'profile'
option 'name' 'Freifunk Berlin Prenzlauer Berg'
option 'homepage' 'http://pberg.freifunk.net'
option 'ssid' 'olsr.freifunk.net'
option 'mesh_network' '104.0.0.0/8'
option 'splash_network' '10.104.0.0/16'
option 'splash_prefix' '27'
option 'latitude' '52.5427'
option 'longitude' '13.4172'
config 'defaults' 'wifi_device'
option 'channel' '10'

View file

@ -0,0 +1,12 @@
config 'community' 'profile'
option 'name' 'Piratenfreifunk Dresden'
option 'homepage' 'http://www.piraten-sachsen.de/'
option 'ssid' 'dresden.freifunk.net'
option 'mesh_network' '10.12.0.0/16'
option 'splash_network' '10.104.0.0/16'
option 'splash_prefix' '27'
option 'latitude' '51.05081'
option 'longitude' '13.73420'
config 'defaults' 'wifi_device'
option 'channel' '1'

View file

@ -0,0 +1,13 @@
config 'community' 'profile'
option 'name' 'Freifunk Potsdam'
option 'homepage' 'http://potsdam.freifunk.net'
option 'ssid' 'www.freifunk-potsdam.de'
option 'mesh_network' '10.22.0.0/16'
option 'splash_network' '192.168.22.0/24'
option 'splash_prefix' '24'
option 'latitude' '52.39349'
option 'longitude' '13.06489'
config 'defaults' 'wifi_device'
option 'channel' '13'
option 'bssid' '02:CA:FF:EE:BA:BE'

View file

@ -0,0 +1,15 @@
config 'community' 'profile'
option 'name' 'Freifunk Rosbach'
option 'homepage' 'freifunk-rosbach.de'
option 'ssid' 'rosbach.freifunk.net'
option 'mesh_network' '10.212.0.0/16'
option 'splash_network' '10.104.0.0/16'
option 'splash_prefix' '27'
option 'latitude' '50.18'
option 'longitude' '8.42'
config 'defaults' 'wifi_device'
option 'channel' '13'
config 'defaults' 'wifi_iface'
option 'bssid' 'D2:CA:FF:EE:BA:BE'

View file

@ -0,0 +1,13 @@
config 'community' 'profile'
option 'name' 'Freifunk Seefeld'
option 'homepage' 'http://wiki.freifunk.net/Seefeld.freifunk.net'
option 'ssid' 'seefeld.freifunk.net'
option 'mesh_network' '10.111.0.0/16'
option 'splash_network' '10.104.0.0/16'
option 'splash_prefix' '27'
option 'latitude' '48.03485'
option 'longitude' '11.21279'
config 'defaults' 'wifi_device'
option 'channel' '1'
option 'bssid' '02:CA:FF:EE:BA:BB'

View file

@ -0,0 +1,13 @@
config 'community' 'profile'
option 'name' 'Freifunk Stuttgart'
option 'homepage' 'http://freifunk-stuttgart.de'
option 'ssid' 'Freifunk Stuttgart'
option 'mesh_network' '172.21.0.0/16'
option 'splash_network' '10.104.0.0/16'
option 'latitude' '48'
option 'longitude' '9'
option 'splash_prefix' '27'
config 'defaults' 'wifi_device'
option 'channel' '5'
option 'bssid' '52:CA:FF:EE:BA:BE'

View file

@ -0,0 +1,10 @@
config 'community' 'profile'
option 'name' 'Weimarnetz e.V.'
option 'homepage' 'http://www.weimarnetz.de'
option 'ssid' 'weimarnetz'
option 'mesh_network' '10.63.0.0/16'
option 'latitude' '50.989530'
option 'longitude' '11.338675'
config 'defaults' 'interface'
option 'dns' '217.11.48.200 217.11.49.200 8.8.8.8'

View file

@ -0,0 +1,16 @@
config 'community' 'profile'
option 'name' 'Freifunk Weinstadt'
option 'homepage' 'http://freifunk-weinstadt.de'
option 'ssid' 'freifunk-weinstadt'
option 'mesh_network' '172.21.0.0/16'
option 'splash_network' '172.21.85.0/30'
option 'latitude' '48.81'
option 'longitude' '9.39'
option 'splash_prefix' '30'
config 'defaults' 'wifi_device'
option 'channel' '5'
option 'bssid' '02:07:01:03:08:04'
config 'defaults' 'bssidscheme'
option '5' '02:07:01:03:08:04'

View file

@ -0,0 +1,15 @@
config 'community' 'profile'
option 'name' 'wlan ljubljana'
option 'homepage' 'http://wlan-lj.net'
option 'ssid' 'open.wlan-lj.net'
option 'mesh_network' '10.254.0.0/16'
option 'splash_network' '10.254.120.0/21'
option 'splash_prefix' '27'
option 'latitude' '46.05063'
option 'longitude' '14.50402'
config 'defaults' 'wifi_device'
option 'channel' '8'
config 'defaults' 'interface'
option 'dns' '10.254.0.1 10.254.0.2'

View file

@ -0,0 +1,42 @@
# Copyright (C) 2011 Manuel Munz <freifunk at somakoma de>
# This is free software, licensed under the Apache 2.0 license.
include $(TOPDIR)/rules.mk
PKG_NAME:=freifunk-common
PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/freifunk-common
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=9. Freifunk
TITLE:=Freifunk common files
endef
define Package/freifunk-common/description
Common files and scripts that are needed to run free wireless mesh networks.
endef
define Package/luci-mod-freifunk/conffiles
/etc/config/freifunk
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/freifunk-common/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,freifunk-common))

View file

@ -0,0 +1,129 @@
package 'freifunk'
config 'public' 'contact'
option 'nickname' ''
option 'name' ''
option 'mail' ''
option 'phone' ''
option 'location' ''
option 'note' ''
config 'public' 'community'
option 'name' 'Freifunk'
option 'homepage' 'http://freifunk.net'
config 'fw_zone' 'zone_freifunk'
option 'name' 'freifunk'
option 'input' 'REJECT'
option 'forward' 'REJECT'
option 'output' 'ACCEPT'
config 'fw_rule' 'fficmp'
option 'src' 'freifunk'
option 'target' 'ACCEPT'
option 'proto' 'icmp'
config 'fw_rule' 'ffhttp'
option 'src' 'freifunk'
option 'target' 'ACCEPT'
option 'proto' 'tcp'
option 'dest_port' '80'
config 'fw_rule' 'ffhttps'
option 'src' 'freifunk'
option 'target' 'ACCEPT'
option 'proto' 'tcp'
option 'dest_port' '443'
config 'fw_rule' 'ffssh'
option 'src' 'freifunk'
option 'target' 'ACCEPT'
option 'proto' 'tcp'
option 'dest_port' '22'
config 'fw_rule' 'ffolsr'
option 'src' 'freifunk'
option 'target' 'ACCEPT'
option 'proto' 'udp'
option 'dest_port' '698'
config 'fw_rule' 'ffwprobe'
option 'src' 'freifunk'
option 'target' 'ACCEPT'
option 'proto' 'tcp'
option 'dest_port' '17990'
config 'fw_rule' 'ffdns'
option 'dest_port' '53'
option 'src' 'freifunk'
option 'target' 'ACCEPT'
option 'proto' 'udp'
config 'fw_rule' 'ffdhcp'
option 'src_port' '68'
option 'src' 'freifunk'
option 'target' 'ACCEPT'
option 'dest_port' '67'
option 'proto' 'udp'
option 'leasetime' '30m'
config 'fw_rule' 'ffsplash'
option 'dest_port' '8082'
option 'src' 'freifunk'
option 'target' 'ACCEPT'
option 'proto' 'tcp'
config 'fw_forwarding' 'lanfffwd'
option 'src' 'lan'
option 'dest' 'freifunk'
config 'fw_forwarding' 'ffwanfwd'
option 'src' 'freifunk'
option 'dest' 'wan'
config 'fw_forwarding' 'fffwd'
option 'src' 'freifunk'
option 'dest' 'freifunk'
config 'include' 'freifunk'
option 'path' '/etc/firewall.freifunk'
config 'defaults' 'system'
option 'zonename' 'Europe/Berlin'
option 'timezone' 'CET-1CEST,M3.5.0,M10.5.0/3'
config 'defaults' 'wifi_device'
option 'channel' '1'
option 'diversity' '1'
option 'disabled' '0'
option 'country' 'DE'
option 'hwmode' '11g'
option 'distance' '1000'
config 'defaults' 'wifi_iface'
option 'mode' 'adhoc'
option 'encryption' 'none'
option 'bgscan' '0'
option 'bssid' '12:CA:FF:EE:BA:BE'
option 'sw_merge' '1'
option 'mcast_rate' '5500'
option 'probereq' '1'
config 'defaults' 'interface'
option 'netmask' '255.255.0.0'
option 'dns' '8.8.8.8 212.204.49.83 141.1.1.1'
config 'defaults' 'alias'
option 'netmask' '255.255.255.0'
config 'defaults' 'dhcp'
option 'leasetime' '30m'
option 'force' '1'
config 'defaults' 'olsr_interfacedefaults'
option 'Ip4Broadcast' '255.255.255.255'
config 'defaults' 'upgrade'
option 'repository' 'http://dev.luci.freifunk-halle.net/freifunk-snapshots'
option 'rssfeed' 'http://firmware.leipzig.freifunk.net/kamikaze/.rss.xml'

View file

@ -0,0 +1,25 @@
#!/bin/sh /etc/rc.common
# Freifunk Init
# $Id: freifunk 8776 2012-06-23 09:10:06Z soma $
START=99
boot() {
test -f /etc/crontabs/root || touch /etc/crontabs/root
grep -q 'killall -HUP dnsmasq' /etc/crontabs/root || {
echo "*/5 * * * * killall -HUP dnsmasq" >> /etc/crontabs/root
}
grep -q '/usr/sbin/ff_olsr_watchdog' /etc/crontabs/root || {
echo "*/5 * * * * /usr/sbin/ff_olsr_watchdog" >> /etc/crontabs/root
}
[ -d /etc/rc.local.d ] && {
for file in /etc/rc.local.d/*; do
test -f "$file" && . "$file"
done
}
/etc/init.d/cron restart &
}

View file

@ -0,0 +1,51 @@
# Fixup various configurations to remove quirks
# from former versions.
_log() {
logger -t "Config Migration" "$1"
}
_uci() {
uci ${2:+-c $2} get "$1" 2>/dev/null
}
# Splash redirector had a wrong virtual url match
# which resulted in "No such handler"
[ "$(_uci lucid.splashredir.virtual)" == "/" ] && {
_log "Fix splash redirector configuration"
uci set lucid.splashredir.virtual=''
uci commit lucid
/etc/init.d/lucid restart
}
# Newer OLSR versions have the MinTCVtime hack active,
# ensure proper timings or olsrd won't start
FIX=0
for i in 0 1 2 3 4; do
[ -z "$(_uci olsrd.@Interface[$i].TcInterval)" ] && \
[ -z "$(_uci olsrd.@Interface[$i].TcValidityTime)" ] || {
uci delete olsrd.@Interface[$i].TcInterval
uci delete olsrd.@Interface[$i].TcValidityTime
FIX=1
}
done
[ "$FIX" == 1 ] && {
_log "Fix olsrd configuration for MinTCVTime hack"
uci commit olsrd
/etc/init.d/olsrd restart
}
# Ensure that the community definitions are in the
# new format
[ -z "$(_uci freifunk.leipzig.mesh_network)" ] && \
[ -n "$(_uci freifunk.leipzig.mesh_network /rom/etc/config)" ] && {
_log "Converting freifunk configuration to new format"
cp /rom/etc/config/freifunk /etc/config/freifunk
}

View file

@ -0,0 +1,2 @@
uci set uhttpd.main.rfc1918_filter=0
uci commit uhttpd

View file

@ -0,0 +1,10 @@
#!/bin/sh
test "$1" = "-h" && echo -e "Usage:\n\t$0 -h\n\t$0 [ { ip | hostname } ]" >&2 && exit 1
host="${1:-leipzig.freifunk.net}"
wget -O /dev/null http://$host/cgi-bin-dev-zero.bin
test "$?" = "1" && wget -O /dev/null http://$host/cgi-bin/dev-zero.bin
test "$?" = "1" && wget -O /dev/null http://$host/cgi-bin/luci/freifunk/status/zeroes
test "$?" = "1" && echo "$host: no zero download found..." && exit 1

View file

@ -0,0 +1,3 @@
#!/bin/sh
wget -q -O - http://localhost:2006/neighbours|sed -e's/LinkQuality/LQ/;s/Hysteresis/Hyst./;s/Willingness/Will./'

View file

@ -0,0 +1,29 @@
#!/usr/bin/lua
require "os"
require "io"
require "uci"
local fs = require "nixio.fs"
if fs.access("/var/run/olsrd.pid") then
local stamp, intv
local x = uci.cursor()
x:foreach("olsrd", "LoadPlugin",
function(s)
if s.library == "olsrd_watchdog.so.0.1" then
intv = tonumber(s.interval)
stamp = s.file
end
end)
if intv and fs.access(stamp) then
local systime = os.time()
local wdgtime = tonumber(io.lines(stamp)())
if not wdgtime or ( systime - wdgtime ) > ( intv * 2 ) then
os.execute("logger -t 'OLSR watchdog' 'Process died - restarting!'")
os.execute("/etc/init.d/olsrd restart")
end
end
end

View file

@ -0,0 +1,6 @@
#!/bin/sh
[ -n "${IPKG_INSTROOT}" ] || {
/etc/init.d/freifunk enabled || /etc/init.d/freifunk enable
exit 0
}

View file

@ -0,0 +1,53 @@
#
# Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
#
# This is free software, licensed under the Apache 2.0 license.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=freifunk-firewall
PKG_RELEASE:=2
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/freifunk-firewall
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=9. Freifunk
TITLE:=Freifunk Firewall Addon
DEPENDS:=+firewall
endef
define Package/freifunk-firewall/description
Various firewall extensions for Freifunk. Includes NAT fixes and advanced settings.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/freifunk-firewall/postinst
#!/bin/sh
[ -n "$${IPKG_INSTROOT}" ] || {
if ! grep -q /etc/firewall.freifunk /etc/config/firewall; then
uci add firewall include >/dev/null
uci set firewall.@include[-1].path=/etc/firewall.freifunk
uci commit firewall
fi
}
endef
define Package/freifunk-firewall/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,freifunk-firewall))

View file

@ -0,0 +1,42 @@
#!/bin/sh
# Freifunk Firewall addons
# $Id: firewall.freifunk 7810 2011-10-28 15:15:27Z jow $
#
# Apply advanced settings
#
apply_advanced() {
local tcp_ecn
local tcp_window_scaling
local accept_redirects
local accept_source_route
config_get_bool tcp_ecn $1 tcp_ecn 1
config_get_bool tcp_window_scaling $1 tcp_window_scaling 1
config_get_bool accept_redirects $1 accept_redirects 0
config_get_bool accept_source_route $1 accept_source_route 0
logger -t firewall.freifunk "tcp_ecn is $tcp_ecn"
logger -t firewall.freifunk "tcp_window_scaling is $tcp_window_scaling"
logger -t firewall.freifunk "accept_redirects is $accept_redirects"
logger -t firewall.freifunk "accept_source_route is $accept_source_route"
sysctl -w net.ipv4.tcp_ecn=$tcp_ecn >/dev/null
sysctl -w net.ipv4.tcp_window_scaling=$tcp_window_scaling >/dev/null
for f in /proc/sys/net/ipv4/conf/*/accept_redirects; do
echo $accept_redirects > $f
done
for f in /proc/sys/net/ipv4/conf/*/accept_source_route; do
echo $accept_source_route > $f
done
}
config_foreach apply_advanced advanced
[ -x /etc/init.d/luci_splash ] && ( sleep 3; /etc/init.d/luci_splash restart )&
[ -x /etc/init.d/freifunk-p2pblock ] && /etc/init.d/freifunk-p2pblock enabled && \
( sleep 3; /etc/init.d/freifunk-p2pblock restart )&

View file

@ -0,0 +1,72 @@
#!/bin/sh
clear_restricted_gw()
{
local state="$1"
local iface
local ifname
local ipaddr
local netmask
local gateway
config_get iface "$state" iface
if [ "$iface" = "$INTERFACE" ]; then
config_get ifname "$state" ifname
config_get ipaddr "$state" ipaddr
config_get netmask "$state" netmask
config_get gateway "$state" gateway
logger -t firewall.freifunk "removing local restriction to $iface($gateway)"
iptables -D forwarding_rule ! -i $ifname -o $ifname -d $ipaddr/$netmask -j REJECT --reject-with icmp-host-prohibited
uci_revert_state firewall "$state"
fi
}
get_enabled()
{
local name
config_get name "$1" name
if [ "$name" = "$ZONE" ]; then
config_get_bool local_restrict "$1" local_restrict
fi
}
if [ "$ACTION" = add ]; then
local enabled
local ipaddr
local netmask
local gateway
include /lib/network
scan_interfaces
config_get ipaddr "$INTERFACE" ipaddr
config_get netmask "$INTERFACE" netmask
config_get gateway "$INTERFACE" gateway
if [ -n "$gateway" ] && [ "$gateway" != 0.0.0.0 ]; then
config_load firewall
local_restrict=0
config_foreach get_enabled zone
if [ "$local_restrict" = 1 ]; then
logger -t firewall.freifunk "restricting local access to $DEVICE($gateway)"
iptables -I forwarding_rule ! -i $DEVICE -o $DEVICE -d $ipaddr/$netmask -j REJECT --reject-with icmp-host-prohibited
local state="restricted_gw_${INTERFACE}"
uci_set_state firewall "$state" "" restricted_gw_state
uci_set_state firewall "$state" iface "$INTERFACE"
uci_set_state firewall "$state" ifname "$DEVICE"
uci_set_state firewall "$state" ipaddr "$ipaddr"
uci_set_state firewall "$state" netmask "$netmask"
uci_set_state firewall "$state" gateway "$gateway"
fi
fi
elif [ "$ACTION" = remove ]; then
config_load firewall
config_foreach clear_restricted_gw restricted_gw_state
fi

View file

@ -0,0 +1,39 @@
# Copyright (C) 2011 Manuel Munz <freifunk at somakoma de>
# This is free software, licensed under the Apache 2.0 license.
include $(TOPDIR)/rules.mk
PKG_NAME:=freifunk-gwcheck
PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/freifunk-gwcheck
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=9. Freifunk
TITLE:=Freifunk gateway check script
DEPENDS:=firewall +ip +iptables-mod-ipopt +olsrd-mod-dyn-gw-plain
endef
define Package/freifunk-gwcheck/description
This script periodically checks if internet is available via your own gateway. If it detects that it is broken, then the defaultroute is removed from the main table and temporarilly placed in table gw-check until your internet works again. Config file is /etc/config/freifunk-gwcheck.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/freifunk-gwcheck/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,freifunk-gwcheck))

View file

@ -0,0 +1,5 @@
config 'gwcheck' 'hosts'
list 'host' 'augsburg.freifunk.net'
list 'host' 'vpn4.leipzig.freifunk.net'
list 'host' 'luci.subsignal.org'
list 'host' 'conntest.jpod.cc'

View file

@ -0,0 +1,82 @@
#!/bin/sh
#check if dyngw_plain is installed and enabled, else exit
dyngwplainlib=`uci show olsrd |grep dyn_gw_plain |awk {' FS="."; print $1"."$2 '}`
if [ -n "$dyngwplainlib" ]; then
if [ ! "$(uci -q get $dyngwplainlib.ignore)" == 0 ]; then
exit 1
fi
else
echo "dyngw_plain not found in olsrd config, exit"
exit 1
fi
# check if we have a defaultroute with metric=0 in one of these tables: main table and gw-check table.
# If not exit here.
defroutemain="$(ip r s |grep default |grep -v metric)"
defroutegw-check="$(ip r s t gw-check |grep default |grep -v metric)"
if [ -z "$defroutegw-check" -a -z "$defroutemain" ]; then
exit 1
fi
# get and shuffle list of testservers
testserver="$(uci -q get freifunk-gwcheck.hosts.host)"
[ -z "$testserver" ] && echo "No testservers found, exit" && exit
testserver="$(for t in $testserver; do echo $t; done | awk 'BEGIN {
srand();
}
{
l[NR] = $0;
}
END {
for (i = 1; i <= NR; i++) {
n = int(rand() * (NR - i + 1)) + i;
print l[n];
l[n] = l[i];
}
}')"
check_internet() {
for t in $testserver; do
local test
test=$(wget -q http://$t/conntest.html -O -| grep "Internet_works")
if [ "$test" == "Internet_works" ]; then
echo 0
break
else
logger -t gw-check "Could not get test file from http://$t/conntest.html"
fi
done
}
iw=$(check_internet)
if [ "$iw" == 0 ]; then
# check if we have a seperate routing table for our tests.
# If yes, move defaultroute to normal table and delete table gw-check
if [ -n "$defroutegw-check" ]; then
ip r a $defroutegw-check
ip r d $defroutegw-check t gw-check
ip ru del fwmark 0x2 lookup gw-check
for host in $testserver; do
iptables -t mangle -D OUTPUT -d $host -p tcp --dport 80 -j MARK --set-mark 0x2
done
logger -t gw-check "Internet is available again, restoring default route ( $defroutegw-check)"
fi
else
# Check failed. If we have a defaultroute with metric=0 and it is already in table gw-check then do nothing.
# If there is a defaultroute with metric=0 then remove it from the main routing table and add to table gw-check.
if [ -z "$(ip ru s | grep gw-check)" -a -n "$defroutemain" ]; then
ip rule add fwmark 0x2 lookup gw-check
for host in $testserver; do
iptables -t mangle -I OUTPUT -d $host -p tcp --dport 80 -j MARK --set-mark 0x2
done
ip r a $defroutemain table gw-check
ip r d $defroutemain
logger -t gw-check "Internet is not available, deactivating the default route ( $defroutemain)"
fi
fi

View file

@ -0,0 +1,4 @@
#!/bin/sh
[ -n "${IPKG_INSTROOT}" ] || {
( . /etc/uci-defaults/freifunk-gwcheck ) && rm -f /etc/uci-defaults/freifunk-gwcheck
}

View file

@ -0,0 +1,5 @@
#!/bin/sh
[ -n "${IPKG_INSTROOT}" ] || {
sed -i '/gw-check/d' /etc/iproute2/rt_tables
sed -i '/ff_olsr_test_gw.sh/d' /etc/crontabs/root
}

View file

@ -0,0 +1,6 @@
#!/bin/sh
tables="/etc/iproute2/rt_tables"
grep -q "gw-check" $tables || echo "200 gw-check" >> $tables
test -f /etc/crontabs/root || touch /etc/crontabs/root
grep -q "ff_olsr_test_gw.sh" /etc/crontabs/root || echo "* * * * * /usr/sbin/ff_olsr_test_gw.sh" >> /etc/crontabs/root
/etc/init.d/cron restart

View file

@ -0,0 +1,39 @@
# Copyright (C) 2011 Manuel Munz <freifunk at somakoma de>
# This is free software, licensed under the Apache 2.0 license.
include $(TOPDIR)/rules.mk
PKG_NAME:=freifunk-mapupdate
PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/freifunk-mapupdate
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=9. Freifunk
TITLE:=Update script for freifunkmap
DEPENDS:=+olsrd-mod-nameservice
endef
define Package/freifunk-mapupdate/description
This script updates the freifunkmap (also known as the global map, see http://map.berlin.freifunk.net) every hour. Config file is /etc/config/freifunk-mapupdate.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/freifunk-mapupdate/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,freifunk-mapupdate))

View file

@ -0,0 +1,3 @@
config 'mapupdate' 'mapupdate'
option 'enabled' '1'
option 'mapserver' 'http://map.berlin.freifunk.net/freifunkmap.php'

View file

@ -0,0 +1,59 @@
#!/bin/sh
if [ ! "$(uci -q get freifunk-mapupdate.mapupdate.enabled)" == 1 ]; then
exit 1
fi
MAPSERVER="$(uci -q get freifunk-mapupdate.mapupdate.mapserver)"
[ -z "$MAPSERVER" ] && logger -t "freifunk-mapupdate:" "No mapserver configured" && exit 1
#check if nameservice plugin is installed and enabled, else exit
nslib=`uci show olsrd |grep olsrd_nameservice.so |awk {' FS="."; print $1"."$2 '}`
if [ -n "$nslib" ]; then
LATLONFILE="$(uci -q get $nslib.latlon_file)"
if [ -z "$LATLONFILE" ]; then
LATLONFILE="/var/run/latlon.js"
fi
if [ ! -p "$LATLONFILE" ]; then
logger -t "freifunk-mapupdate:" "latlon_file not found."; exit 1
fi
else
logger -t "freifunk-mapupdate:" "nameservice plugin not found in olsrd config."
exit 1
fi
HOSTNAME="$(uci show system |grep hostname |cut -d "=" -f 2)"
HF_INFO=""
# Get info for myself
SELF=$(cat $LATLONFILE |grep ^Self | sed -e 's/Self(//' -e 's/);//' -e "s/'//g")
OLSR_IP="$(echo $SELF |awk '{ FS=",";print $1 }')"
LOCATION="$(uci show system |grep .location |cut -d "=" -f 2)"
[ -n "$LOCATION" ] && NOTE="$LOCATION<br>"
FFNOTE="$(uci -q get freifunk.contact.note)"
[ -n "$FFNOTE" ] && NOTE="$NOTE $FFNOTE"
NOTE="<h3><a href='http://$OLSR_IP' target='_blank'>$HOSTNAME</a></h3><p>$NOTE"
NOTE=`echo -e "$NOTE" | sed -e 's/\ /%20/g' -e 's/&/%26/g' -e 's/"/%22/g'`
UPDATESTRING="$(echo $SELF |awk '{ FS=",";print $2 }'), $(echo $SELF |awk '{ FS=",";print $3 }')"
# write our coordinates to mygooglemapscoords.txt to make Freifunk Firmware happy
echo "$UPDATESTRING" > /tmp/mygooglemapscoords.txt
[ ! -L /www/mygooglemapscoords.txt ] && ln -s /tmp/mygooglemapscoords.txt /www/mygooglemapscoords.txt
# get neighbor Info (lat, lon, lq)
while read line; do
NEIGHUPD="$(echo $line |awk '{ FS=","; print $6 }'), $(echo $line |awk '{ FS=","; print $7 }'), $(echo $line |awk '{ FS=",";print $4 }')"
UPDATESTRING="${UPDATESTRING}, ${NEIGHUPD}"
done << EOF
`grep "PLink('$OLSR_IP" $LATLONFILE | sed -e 's/PLink(//' -e 's/);//' -e "s/'//g"`
EOF
# Send UPDATESTRING
UPDATE=`echo -e "$UPDATESTRING" | sed s/\ /%20/g`
result="$(wget "$MAPSERVER?update=$UPDATE&updateiv=3600&olsrip=$OLSR_IP&note=${NOTE}${HF_INFO}" -qO -)"
if [ ! "$result" == "success update" ]; then
logger -t "freifunk-mapupdate:" "Update failed: $result"
fi

View file

@ -0,0 +1,4 @@
#!/bin/sh
[ -n "${IPKG_INSTROOT}" ] || {
( . /etc/uci-defaults/freifunk-mapupdate ) && rm -f /etc/uci-defaults/freifunk-mapupdate
}

View file

@ -0,0 +1,5 @@
#!/bin/sh
[ -n "${IPKG_INSTROOT}" ] || {
sed -i '/ff_mapupdate.sh/d' /etc/crontabs/root
/etc/init.d/cron restart
}

View file

@ -0,0 +1,6 @@
#!/bin/sh
test -f /etc/crontabs/root || touch /etc/crontabs/root
SEED="$( dd if=/dev/urandom bs=2 count=1 2>&- | hexdump | if read line; then echo 0x${line#* }; fi )"
MIN="$(( $SEED % 59 ))"
grep -q "ff_mapupdate.sh" /etc/crontabs/root || echo "$MIN * * * * /usr/sbin/ff_mapupdate.sh" >> /etc/crontabs/root
/etc/init.d/cron restart

View file

@ -0,0 +1,47 @@
#
# Copyright (C) 2009 Andreas Seidler <tetzlav@subsignal.org>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=freifunk-p2pblock
PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/freifunk-p2pblock
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=9. Freifunk
TITLE:=Freifunk p2pblock Addon
DEPENDS:=+iptables-mod-filter +iptables-mod-ipp2p +l7-protocols +iptables-mod-conntrack-extra
endef
define Package/freifunk-p2pblock/description
Simple Addon for Freifunk which use iptables layer7-, ipp2p- and recent-modules
to block p2p/filesharing traffic
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/freifunk-p2pblock/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/freifunk-p2pblock.init $(1)/etc/init.d/freifunk-p2pblock
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/freifunk-p2pblock.config $(1)/etc/config/freifunk_p2pblock
endef
$(eval $(call BuildPackage,freifunk-p2pblock))

View file

@ -0,0 +1,6 @@
config 'settings' 'p2pblock'
option 'portrange' '1024:65535'
option 'layer7' 'edonkey bittorrent fasttrack'
option 'ipp2p' 'edk dc kazaa gnu bit ares soul winmx apple'
option 'blocktime' '60'
option 'whitelist' ''

View file

@ -0,0 +1,94 @@
#!/bin/sh /etc/rc.common
START=82
ME="freifunk-p2pblock"
LOCK='/var/run/p2pblock.lock'
# helper-scripts
ipt_add() {
logger -t "$ME" "set 'iptables -I $1'"
iptables -I $1
echo "iptables -D $1" >> $LOCK
}
start() {
/etc/init.d/freifunk-p2pblock enabled || return
if [ ! -s "$LOCK" ]; then
logger -s -t "$ME" 'starting p2pblock...'
config_load network
config_get wan wan ifname
if [ -n "$wan" ]; then
config_load freifunk_p2pblock
config_get layer7 p2pblock layer7
config_get ipp2p p2pblock ipp2p
config_get portrange p2pblock portrange
config_get blocktime p2pblock blocktime
# load modules
insmod ipt_ipp2p 2>&-
insmod ipt_layer7 2>&-
insmod ipt_recent ip_list_tot=400 ip_pkt_list_tot=3 2>&-
# create new p2p-chain
iptables -N p2pblock
# pipe all incomming FORWARD with source-/destination-port 1024-65535 throu p2p-chain
ipt_add "FORWARD -i $wan -p tcp --sport $portrange --dport $portrange -j p2pblock"
ipt_add "FORWARD -i $wan -p udp --sport $portrange --dport $portrange -j p2pblock"
# if p2p-traffic blocked 3 packages to a destination ip then block all traffic within the next 180 sec (port 1024-65535)
ipt_add "p2pblock -m recent --rdest --rcheck --name P2PBLOCK --seconds $blocktime --hitcount 3 -j DROP"
ipt_add "p2pblock -m recent --rdest --rcheck --name P2PBLOCK --seconds $blocktime --hitcount 3 -m limit --limit 1/minute -j LOG --log-prefix P2PBLOCK-DROP:"
# create layer7-rules
for proto in $layer7; do
ipt_add "p2pblock -m layer7 --l7proto $proto -m recent --rdest --set --name P2PBLOCK"
ipt_add "p2pblock -m layer7 --l7proto $proto -m limit --limit 1/minute -j LOG --log-prefix P2PBLOCK-seen-$proto:"
done
# create ipp2p-rules
for proto in $ipp2p; do
ipt_add "p2pblock -m ipp2p --$proto -m recent --rdest --set --name P2PBLOCK"
ipt_add "p2pblock -m ipp2p --$proto -m limit --limit 1/minute -j LOG --log-prefix P2PBLOCK-seen-$proto:"
done
# insert whitelisted ips
for ip in $WHITELIST; do
ipt_add "p2pblock -d $ip -j RETURN"
done
logger -s -t "$ME" 'Done.'; return 0
else
logger -s -t "$ME" 'No wan interface present.'; return 0
fi
else
logger -s -t "$ME" 'WARNING! already running - Aborting!'; return 2
fi
}
stop() {
if [ -s "$LOCK" ]; then
logger -s -t "$ME" 'stopping p2pblock...'
# unset all rules in $LOCK-file
cat $LOCK | sed -ne '1!G;h;$p' | while read line; do
logger -t "$ME" "unset $line"
while eval $line 2>&-; do :; done
done; : > "$LOCK"
# flush and delete the p2p-chain
iptables -F p2pblock
iptables -X p2pblock
logger -s -t "$ME" 'Done.'; return 0
else
logger -s -t "$ME" 'WARNING! not running - Aborting!'; return 2
fi
}
restart() {
stop; sleep 1; start
}

View file

@ -0,0 +1,39 @@
# Copyright (C) 2011 Manuel Munz <freifunk at somakoma de>
# This is free software, licensed under the Apache 2.0 license.
include $(TOPDIR)/rules.mk
PKG_NAME:=freifunk-policyrouting
PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/freifunk-policyrouting
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=9. Freifunk
TITLE:=Freifunk policy routing addon
DEPENDS:=+firewall +ip
endef
define Package/freifunk-policyrouting/description
Allows you to send your own traffic via your own default gateway while sending traffic received from the mesh to a gateway in the mesh.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/freifunk-policyrouting/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,freifunk-policyrouting))

View file

@ -0,0 +1,6 @@
config 'settings' 'pr'
option 'enable' '0'
option 'strict' '1'
option 'zones' ''

View file

@ -0,0 +1,76 @@
if [ "$ACTION" = "add" ] && [ "$INTERFACE" = "wan" ]; then
pr=`uci get freifunk-policyrouting.pr.enable`
strict=`uci get freifunk-policyrouting.pr.strict`
zones=`uci get freifunk-policyrouting.pr.zones`
if [ $pr = "1" ]; then
# The wan device name
if [ -n "`uci -p /var/state get network.wan.ifname`" ]; then
wandev=`uci -p /var/state get network.wan.ifname`
else
wandev=`uci -p /var/state get network.wan.device`
fi
iptables -t mangle -D PREROUTING -j prerouting_policy > /dev/null 2>&1
iptables -t mangle -F prerouting_policy > /dev/null 2>&1
iptables -t mangle -N prerouting_policy > /dev/null 2>&1
iptables -t mangle -I PREROUTING -j prerouting_policy > /dev/null 2>&1
# If no route is in table olsr-default, then usually the hosts local default route is used.
# If set to strict then we add a filter which prevents this
if [ "$strict" == "1" ]; then
ln=$(( `iptables -L FORWARD -v --line-numbers | grep -m 1 reject | awk {' print $1 '}` - 1 ))
if [ ! $ln -gt 0 ]; then
ln=1
fi
if [ -z "`iptables -L |grep 'Chain forward_policy'`" ]; then
iptables -N forward_policy
fi
if [ -z "`iptables -L FORWARD -v |grep forward_policy`" ]; then
iptables -I FORWARD $ln -m mark --mark 1 -j forward_policy
fi
iptables -F forward_policy
iptables -I forward_policy -o $wandev -j REJECT --reject-with icmp-net-prohibited
fi
# set mark 1 for all packets coming in via enabled zones
for i in $zones; do
# find out which interfaces belong to this zone
zone=`uci show firewall |grep "name=$i" |awk {' FS="."; print $1"."$2 '}`
interfaces=`uci get $zone.network`
if [ "$interfaces" == "" ]; then
interfaces=$i
fi
for int in $interfaces; do
if [ "`uci -q get network.$int.type`" == "bridge" ]; then
dev="br-$int"
else
if [ -n "`uci -p /var/state get network.$int.ifname`" ]; then
dev=`uci -p /var/state get network.$int.ifname`
else
dev=`uci -p /var/state get network.$int.device`
fi
fi
logger -t policyrouting "Add mark 1 to packages coming in via interface $dev"
iptables -t mangle -I prerouting_policy -i $dev -j MARK --set-mark 1
done
done
else
# Cleanup policy routing stuff that might be lingering around
if [ -n "`iptables -t mangle -L PREROUTING |grep _policy`" ]; then
logger -t policyrouting "Delete prerouting_policy chain in table mangle"
iptables -t mangle -D PREROUTING -j prerouting_policy
iptables -t mangle -F prerouting_policy
iptables -t mangle -X prerouting_policy
fi
if [ -n "`iptables -L FORWARD |grep forward_policy`" ]; then
logger -t policyrouting "Delete strict forwarding rules"
iptables -D FORWARD -m mark --mark 1 -j forward_policy
iptables -F forward_policy
iptables -X forward_policy
fi
logger -t policyrouting "All firewall rules for policyrouting removed."
fi
fi

View file

@ -0,0 +1,78 @@
[ "$INTERFACE" != "wan" ] && exit 0
case $ACTION in
ifup)
pr=`uci get freifunk-policyrouting.pr.enable`
if [ $pr = "1" ]; then
logger -t policyrouting "Starting policy routing on $INTERFACE"
# Setup new tables
tables="/etc/iproute2/rt_tables"
if [ -z "`grep "111" $tables`" ]; then
echo "111 olsr" >> $tables
fi
if [ -z "`grep "112" $tables`" ]; then
echo "112 olsr-default" >> $tables
fi
# Make sure Rt_tables in olsrd are in place
if [ ! "`uci -q get olsrd.@olsrd[0].RtTable`" == "111" ] || [ ! "`uci -q get olsrd.@olsrd[0].RtTableDefault`" == "112" ]; then
uci set olsrd.@olsrd[0].RtTable='111'
uci set olsrd.@olsrd[0].RtTableDefault='112'
uci commit
/etc/init.d/olsrd restart
fi
# Disable dyn_gw and dyngw_plain
dyngwlib=`uci show olsrd |grep dyn_gw.so |awk {' FS="."; print $1"."$2 '}`
if [ -n "$dyngwlib" ]; then
uci set $dyngwlib.ignore=1
uci commit
fi
dyngwplainlib=`uci show olsrd |grep dyn_gw_plain |awk {' FS="."; print $1"."$2 '}`
if [ -n "$dyngwplainlib" ]; then
uci set $dyngwplainlib.ignore=1
uci commit
fi
gw=`uci -p /var/state get network.wan.gateway`
netmask=`uci -p /var/state get network.wan.netmask`
if [ -z "$netmask" ]; then
NETMASK="255.255.255.255"
fi
if [ -n "`uci -p /var/state get network.wan.ifname`" ]; then
device=`uci -p /var/state get network.wan.ifname`
else
device=`uci -p /var/state get network.wan.device`
fi
eval `ipcalc.sh $gw $netmask`
test -n "`ip r s t default`" && ip r d default t default
test -n "`ip r s |grep default`" && ip route del default
ip route add $NETWORK/$NETMASK dev $device table default
ip route add default via $gw dev $device table default
ip rule del lookup main
ip rule add fwmark 1 lookup olsr-default
ip rule add lookup main
ip rule add lookup olsr
else
# Remove custom routing tables from olsrd
if [ "`uci -q get olsrd.@olsrd[0].RtTable`" == "111" ] || [ "`uci -q get olsrd.@olsrd[0].RtTableDefault`" == "112" ]; then
uci delete olsrd.@olsrd[0].RtTable
uci delete olsrd.@olsrd[0].RtTableDefault
uci commit
/etc/init.d/olsrd restart
fi
fi
;;
ifdown)
logger -t policyrouting "Deleting policy rules for $INTERFACE"
ip rule del fwmark 1 lookup olsr-default > /dev/null 2>&1
ip rule del lookup olsr > /dev/null 2>&1
;;
esac

View file

@ -0,0 +1,13 @@
#!/bin/sh /etc/rc.common
START=60
boot()
{
prenabled=$(uci get freifunk-policyrouting.pr.enable)
if [ ! "$prenabled" = "1" ]; then
uci -q delete olsrd.@olsrd[0].RtTable
uci -q delete olsrd.@olsrd[0].RtTableDefault
uci commit olsrd
fi
}

View file

@ -0,0 +1 @@
../init.d/freifunk-policyrouting

View file

@ -0,0 +1,7 @@
#!/bin/sh
uci batch <<-EOF
add ucitrack freifunk-policyrouting
add_list ucitrack.@freifunk-policyrouting[-1].affects="network"
commit ucitrack
EOF

View file

@ -0,0 +1,53 @@
#
# Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=freifunk-watchdog
PKG_RELEASE:=7
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
PKG_BUILD_DEPENDS := uci
include $(INCLUDE_DIR)/package.mk
define Package/freifunk-watchdog
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=9. Freifunk
TITLE:=Freifunk Ad-Hoc watchdog daemon
DEPENDS:=libuci
endef
define Package/freifunk-watchdog/description
A watchdog daemon that monitors wireless interfaces to ensure the correct bssid and channel.
The process will initiate a wireless restart as soon as it detects a bssid or channel mismatch.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Build/Configure
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
CC="$(TARGET_CC)" \
CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include" \
LDFLAGS="$(TARGET_LDFLAGS)"
endef
define Package/freifunk-watchdog/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/freifunk-watchdog.init $(1)/etc/init.d/freifunk-watchdog
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ffwatchd $(1)/usr/sbin/
endef
$(eval $(call BuildPackage,freifunk-watchdog))

View file

@ -0,0 +1,39 @@
#!/bin/sh /etc/rc.common
START=99
PID=/var/run/ffwatchd.pid
BIN=/usr/sbin/ffwatchd
boot()
{
# If watchdog service is enabled, install cronjob, create device node and start daemon
if /etc/init.d/freifunk-watchdog enabled 2>/dev/null; then
if ! grep -q "$BIN" /etc/crontabs/root 2>/dev/null; then
echo "* * * * * $BIN running || /etc/init.d/freifunk-watchdog restart" >> /etc/crontabs/root
fi
mknod /dev/watchdog c 10 130
start
# If service is disabled, find and remove related cronjob
elif grep -q "$BIN" /etc/crontabs/root 2>/dev/null; then
sed -i -e "\\'$BIN'd" /etc/crontabs/root
fi
}
start()
{
start-stop-daemon -q -b -m -p $PID -x $BIN -S
}
stop()
{
start-stop-daemon -q -p $PID -x $BIN -K
if ! /etc/init.d/freifunk-watchdog enabled; then
if grep -q "$BIN" /etc/crontabs/root 2>/dev/null; then
sed -i -e "\\'$BIN'd" /etc/crontabs/root
fi
fi
}

View file

@ -0,0 +1,12 @@
WD_BINARY:=ffwatchd
WD_CFLAGS:=$(CFLAGS) -c -DBINARY=\"$(WD_BINARY)\"
WD_LDFLAGS:=$(LDFLAGS) -lm -luci
watchdog:
$(CC) $(WD_CFLAGS) -o ucix.o ucix.c
$(CC) $(WD_CFLAGS) -o watchdog.o watchdog.c
$(CC) $(WD_LDFLAGS) -o $(WD_BINARY) watchdog.o ucix.o
clean:
rm -f *~ $(WD_BINARY) *.o

View file

@ -0,0 +1,102 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* Copyright (C) 2008 John Crispin <blogic@openwrt.org>
*
* Changed by Jo-Philipp Wich <xm@subsignal.org>
*/
#include <string.h>
#include <stdlib.h>
#include <uci_config.h>
#include <uci.h>
#include "ucix.h"
static struct uci_ptr ptr;
static inline int ucix_get_ptr(struct uci_context *ctx, const char *p, const char *s, const char *o, const char *t)
{
memset(&ptr, 0, sizeof(ptr));
ptr.package = p;
ptr.section = s;
ptr.option = o;
ptr.value = t;
return uci_lookup_ptr(ctx, &ptr, NULL, true);
}
struct uci_context* ucix_init(const char *config_file)
{
struct uci_context *ctx = uci_alloc_context();
#ifdef uci_to_delta
uci_add_delta_path(ctx, "/var/state");
#else
uci_add_history_path(ctx, "/var/state");
#endif
if(uci_load(ctx, config_file, NULL) != UCI_OK)
{
return NULL;
}
return ctx;
}
void ucix_cleanup(struct uci_context *ctx)
{
uci_free_context(ctx);
}
const char* ucix_get_option(struct uci_context *ctx, const char *p, const char *s, const char *o)
{
struct uci_element *e = NULL;
const char *value = NULL;
if(ucix_get_ptr(ctx, p, s, o, NULL))
return NULL;
if (!(ptr.flags & UCI_LOOKUP_COMPLETE))
return NULL;
e = ptr.last;
switch (e->type)
{
case UCI_TYPE_SECTION:
value = uci_to_section(e)->type;
break;
case UCI_TYPE_OPTION:
switch(ptr.o->type) {
case UCI_TYPE_STRING:
value = ptr.o->v.string;
break;
default:
value = NULL;
break;
}
break;
default:
return 0;
}
return value;
}
void ucix_for_each_section_type(struct uci_context *ctx,
const char *p, const char *t,
void (*cb)(const char*, void*), void *priv)
{
struct uci_element *e;
if(ucix_get_ptr(ctx, p, NULL, NULL, NULL))
return;
uci_foreach_element(&ptr.p->sections, e)
if (!strcmp(t, uci_to_section(e)->type))
cb(e->name, priv);
}

View file

@ -0,0 +1,29 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* Copyright (C) 2008 John Crispin <blogic@openwrt.org>
*/
#ifndef _UCI_H__
#define _UCI_H__
struct uci_context* ucix_init(const char *config_file);
void ucix_for_each_section_type(struct uci_context *ctx,
const char *p, const char *t,
void (*cb)(const char*, void*), void *priv);
const char* ucix_get_option(struct uci_context *ctx,
const char *p, const char *s, const char *o);
#endif

View file

@ -0,0 +1,464 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
*/
#include "watchdog.h"
/* Global watchdog fd, required by signal handler */
int wdfd = -1;
/* Handle finished childs */
static void sigchld_handler(int sig)
{
pid_t pid;
while( (pid = waitpid(-1, NULL, WNOHANG)) > 0 )
syslog(LOG_INFO, "Child returned (pid %d)", pid);
}
/* Watchdog shutdown helper */
static void shutdown_watchdog(int sig)
{
static const char wshutdown = WATCH_SHUTDOWN;
if( wdfd > -1 )
{
syslog(LOG_INFO, "Stopping watchdog timer");
write(wdfd, &wshutdown, 1);
close(wdfd);
wdfd = -1;
}
exit(0);
}
/* Get BSSID of given interface */
static int iw_get_bssid(int iwfd, const char *ifname, char *bssid)
{
struct iwreq iwrq;
if( iw_ioctl(iwfd, ifname, SIOCGIWAP, &iwrq) >= 0 )
{
unsigned char *addr = (unsigned char *)iwrq.u.ap_addr.sa_data;
sprintf(bssid, "%02X:%02X:%02X:%02X:%02X:%02X",
addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
return 0;
}
return -1;
}
/* Get channel of given interface */
static int iw_get_channel(int iwfd, const char *ifname, int *channel)
{
int i;
char buffer[sizeof(struct iw_range)];
double cur_freq, cmp_freq;
struct iwreq iwrq;
struct iw_range *range;
memset(buffer, 0, sizeof(buffer));
iwrq.u.data.pointer = (char *)buffer;
iwrq.u.data.length = sizeof(buffer);
iwrq.u.data.flags = 0;
if( iw_ioctl(iwfd, ifname, SIOCGIWRANGE, &iwrq) < 0)
{
*channel = -1;
return -1;
}
range = (struct iw_range *)buffer;
if( iw_ioctl(iwfd, ifname, SIOCGIWFREQ, &iwrq) >= 0 )
{
cur_freq = ((double)iwrq.u.freq.m) * pow(10, iwrq.u.freq.e);
if( cur_freq < 1000.00 )
{
*channel = (int)cur_freq;
return 0;
}
for(i = 0; i < range->num_frequency; i++)
{
cmp_freq = ((double)range->freq[i].m) * pow(10, range->freq[i].e);
if( cmp_freq == cur_freq )
{
*channel = (int)range->freq[i].i;
return 0;
}
}
}
*channel = -1;
return -1;
}
/* Get the (first) pid of given process name */
static int find_process(const char *name)
{
int pid = -1;
int file;
char buffer[128];
char cmpname[128];
DIR *dir;
struct dirent *entry;
if( (dir = opendir("/proc")) != NULL )
{
snprintf(cmpname, sizeof(cmpname), "Name:\t%s\n", name);
while( (entry = readdir(dir)) != NULL )
{
if( !strcmp(entry->d_name, "..") || !isdigit(*entry->d_name) )
continue;
sprintf(buffer, "/proc/%s/status", entry->d_name);
if( (file = open(buffer, O_RDONLY)) > -1 )
{
read(file, buffer, sizeof(buffer));
close(file);
if( strstr(buffer, cmpname) == buffer )
{
pid = atoi(entry->d_name);
/* Skip myself ... */
if( pid == getpid() )
pid = -1;
else
break;
}
}
}
closedir(dir);
return pid;
}
syslog(LOG_CRIT, "Unable to open /proc: %s",
strerror(errno));
return -1;
}
/* Get the 5 minute load average */
static double find_loadavg(void)
{
int fd;
char buffer[10];
double load = 0.00;
if( (fd = open("/proc/loadavg", O_RDONLY)) > -1 )
{
if( read(fd, buffer, sizeof(buffer)) == sizeof(buffer) )
load = atof(&buffer[5]);
close(fd);
}
return load;
}
/* Check if given uci file was updated */
static int check_uci_update(const char *config, time_t *mtime)
{
struct stat s;
char path[128];
snprintf(path, sizeof(path), "/var/state/%s", config);
if( stat(path, &s) > -1 )
{
if( (*mtime == 0) || (s.st_mtime > *mtime) )
{
*mtime = s.st_mtime;
return 1;
}
}
return 0;
}
/* Add tuple */
static void load_wifi_uci_add_iface(const char *section, struct uci_itr_ctx *itr)
{
wifi_tuple_t *t;
const char *ucitmp;
int val = 0;
ucitmp = ucix_get_option(itr->ctx, "wireless", section, "mode");
if( ucitmp && !strncmp(ucitmp, "adhoc", 5) )
{
if( (t = (wifi_tuple_t *)malloc(sizeof(wifi_tuple_t))) != NULL )
{
ucitmp = ucix_get_option(itr->ctx, "wireless", section, "ifname");
if(ucitmp)
{
strncpy(t->ifname, ucitmp, sizeof(t->ifname));
val++;
}
ucitmp = ucix_get_option(itr->ctx, "wireless", section, "bssid");
if(ucitmp)
{
strncpy(t->bssid, ucitmp, sizeof(t->bssid));
val++;
}
ucitmp = ucix_get_option(itr->ctx, "wireless", section, "device");
if(ucitmp)
{
ucitmp = ucix_get_option(itr->ctx, "wireless", ucitmp, "channel");
if(ucitmp)
{
t->channel = atoi(ucitmp);
val++;
}
}
if( val == 3 )
{
syslog(LOG_INFO, "Monitoring %s: bssid=%s channel=%d",
t->ifname, t->bssid, t->channel);
t->next = itr->list;
itr->list = t;
}
else
{
free(t);
}
}
}
}
/* Load config */
static wifi_tuple_t * load_wifi_uci(wifi_tuple_t *ifs, time_t *modtime)
{
struct uci_context *ctx;
struct uci_itr_ctx itr;
wifi_tuple_t *cur, *next;
if( check_uci_update("wireless", modtime) )
{
syslog(LOG_INFO, "Config changed, reloading");
if( (ctx = ucix_init("wireless")) != NULL )
{
if( ifs != NULL )
{
for(cur = ifs; cur; cur = next)
{
next = cur->next;
free(cur);
}
}
itr.list = NULL;
itr.ctx = ctx;
ucix_for_each_section_type(ctx, "wireless", "wifi-iface",
(void *)load_wifi_uci_add_iface, &itr);
return itr.list;
}
}
return ifs;
}
/* Daemon implementation */
static int do_daemon(void)
{
static int wdtrigger = 1;
static int wdtimeout = BASE_INTERVAL * 2;
static const char wdkeepalive = WATCH_KEEPALIVE;
int iwfd;
int channel;
char bssid[18];
struct sigaction sa;
wifi_tuple_t *ifs = NULL, *curif;
time_t modtime = 0;
int action_intv = 0;
int restart_wifi = 0;
int restart_cron = 0;
int restart_sshd = 0;
int loadavg_panic = 0;
openlog(SYSLOG_IDENT, 0, LOG_DAEMON);
memset(&sa, 0, sizeof(sa));
if( (iwfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1 )
{
syslog(LOG_ERR, "Can not open wireless control socket: %s",
strerror(errno));
return 1;
}
if( (wdfd = open(WATCH_DEVICE, O_WRONLY)) > -1 )
{
syslog(LOG_INFO, "Opened %s - polling every %i seconds",
WATCH_DEVICE, BASE_INTERVAL);
/* Install signal handler to halt watchdog on shutdown */
sa.sa_handler = shutdown_watchdog;
sa.sa_flags = SA_NOCLDWAIT | SA_RESTART;
sigaction(SIGHUP, &sa, NULL);
sigaction(SIGINT, &sa, NULL);
sigaction(SIGPIPE, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGUSR1, &sa, NULL);
sigaction(SIGUSR2, &sa, NULL);
/* Set watchdog timeout to twice the interval */
ioctl(wdfd, WDIOC_SETTIMEOUT, &wdtimeout);
}
/* Install signal handler to reap childs */
sa.sa_handler = sigchld_handler;
sa.sa_flags = 0;
sigaction(SIGCHLD, &sa, NULL);
while( 1 )
{
/* Check/increment action interval */
if( ++action_intv >= ACTION_INTERVAL )
{
/* Reset action interval */
action_intv = 0;
/* Check average load */
if( find_loadavg() >= LOAD_TRESHOLD )
loadavg_panic++;
else
loadavg_panic = 0;
/* Check crond */
if( find_process("crond") < 0 )
restart_cron++;
else
restart_cron = 0;
/* Check SSHd */
if( find_process("dropbear") < 0 )
restart_sshd++;
else
restart_sshd = 0;
/* Check wireless interfaces */
ifs = load_wifi_uci(ifs, &modtime);
for( curif = ifs; curif; curif = curif->next )
{
/* Get current channel and bssid */
if( (iw_get_bssid(iwfd, curif->ifname, bssid) == 0) &&
(iw_get_channel(iwfd, curif->ifname, &channel) == 0) )
{
/* Check BSSID */
if( strcasecmp(bssid, curif->bssid) != 0 )
{
syslog(LOG_WARNING, "BSSID mismatch on %s: current=%s wanted=%s",
curif->ifname, bssid, curif->bssid);
restart_wifi++;
}
/* Check channel */
else if( channel != curif->channel )
{
syslog(LOG_WARNING, "Channel mismatch on %s: current=%d wanted=%d",
curif->ifname, channel, curif->channel);
restart_wifi++;
}
}
else
{
syslog(LOG_WARNING, "Requested interface %s not present", curif->ifname);
}
}
/* Wifi restart required? */
if( restart_wifi >= HYSTERESIS )
{
restart_wifi = 0;
syslog(LOG_WARNING, "Channel or BSSID mismatch on wireless interface, restarting");
EXEC(WIFI_ACTION);
}
/* Cron restart required? */
if( restart_cron >= HYSTERESIS )
{
restart_cron = 0;
syslog(LOG_WARNING, "The cron process died, restarting");
EXEC(CRON_ACTION);
}
/* SSHd restart required? */
if( restart_sshd >= HYSTERESIS )
{
restart_sshd = 0;
syslog(LOG_WARNING, "The ssh process died, restarting");
EXEC(SSHD_ACTION);
}
/* Is there a load problem? */
if( loadavg_panic >= HYSTERESIS )
{
syslog(LOG_EMERG, "Critical system load level, triggering reset!");
/* Try watchdog, fall back to reboot */
if( wdfd > -1 )
ioctl(wdfd, WDIOC_SETTIMEOUT, &wdtrigger);
else
EXEC(LOAD_ACTION);
}
}
/* Reset watchdog timer */
if( wdfd > -1 )
write(wdfd, &wdkeepalive, 1);
sleep(BASE_INTERVAL);
}
shutdown_watchdog(0);
closelog();
return 0;
}
int main(int argc, char *argv[])
{
/* Check if watchdog is running ... */
if( (argc > 1) && (strcmp(argv[1], "running") == 0) )
{
return (find_process(BINARY) == -1);
}
/* Start daemon */
return do_daemon();
}

View file

@ -0,0 +1,127 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
*/
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdint.h>
#include <stdlib.h>
#include <syslog.h>
#include <ctype.h>
#include <errno.h>
#include <dirent.h>
#include <fcntl.h>
#include <math.h>
#include <time.h>
#include <signal.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <linux/types.h>
#include <linux/watchdog.h>
#include "ucix.h"
#include "wireless.22.h"
/* Watchdog poll interval */
#define BASE_INTERVAL 5
/* Action interval (N * BASE_INTERVAL) */
#define ACTION_INTERVAL 6
/* Hysteresis */
#define HYSTERESIS 3
/* How to call myself in the logs */
#define SYSLOG_IDENT "Freifunk Watchdog"
/* Wifi error action */
#define WIFI_ACTION "/sbin/wifi", "/sbin/wifi"
/* Crond error action */
#define CRON_ACTION "/etc/init.d/cron", "/etc/init.d/cron", "restart"
/* SSHd error action */
#define SSHD_ACTION "/etc/init.d/dropbear", "/etc/init.d/dropbear", "restart"
/* Watchdog device */
#define WATCH_DEVICE "/dev/watchdog"
#define WATCH_SHUTDOWN 'V'
#define WATCH_KEEPALIVE '\0'
/* System load error action and treshold */
#define LOAD_TRESHOLD 15.00
#define LOAD_ACTION "/sbin/reboot", "/sbin/reboot"
/* Fallback binary name (passed by makefile) */
#ifndef BINARY
#define BINARY "ffwatchd"
#endif
/* ifname/bssid/channel tuples */
struct wifi_tuple {
char ifname[16];
char bssid[18];
int channel;
struct wifi_tuple *next;
};
/* structure to hold tuple-list and uci context during iteration */
struct uci_itr_ctx {
struct wifi_tuple *list;
struct uci_context *ctx;
};
typedef struct wifi_tuple wifi_tuple_t;
/* ioctl() helper (stolen from iwlib) */
static inline int
iw_ioctl(int skfd, /* Socket to the kernel */
const char * ifname, /* Device name */
int request, /* WE ID */
struct iwreq * pwrq) /* Fixed part of the request */
{
/* Set device name */
strncpy(pwrq->ifr_ifrn.ifrn_name, ifname, 16);
/* Do the request */
return(ioctl(skfd, request, pwrq));
}
/* fork() & execl() helper */
#define EXEC(x) \
do { \
switch(fork()) \
{ \
case -1: \
syslog(LOG_CRIT, "Unable to fork child: %s", \
strerror(errno)); \
break; \
\
case 0: \
execl(x, NULL); \
syslog(LOG_CRIT, "Unable to execute action: %s", \
strerror(errno)); \
return 1; \
} \
} while(0)

File diff suppressed because it is too large Load diff

655
webgui/luci/luci/Makefile Normal file
View file

@ -0,0 +1,655 @@
include $(TOPDIR)/rules.mk
PKG_BRANCH:=svn-0.11
PKG_NAME:=luci
PKG_VERSION:=inteno-1.1.3
PKG_SOURCE_VERSION:=f88c386161ef4ca2b22225cbb759e50b3e98ae32
PKG_SOURCE_PROTO:=git
ifeq ($(CONFIG_PACKAGE_bcmkernel),y)
PKG_SOURCE_URL:=git@iopsys.inteno.se:luci-inteno-private.git
else
PKG_SOURCE_URL:=http://ihgsp.inteno.se/git/luci-inteno.git
endif
PKG_RELEASE:=$(PKG_SOURCE_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE).tar.gz
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_BUILD_DEPENDS:=$(if $(STAGING_DIR_ROOT),lua/host)
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
LUA_TARGET:=source
LUCI_CFLAGS:=
LUCI_BUILD_PACKAGES:=
LUCI_SELECTED_MODULES:=
ifeq ($(BOARD),brcm-2.4)
MAKE_FLAGS += CRAP="1"
endif
### Templates ###
define Package/luci/install/template
$(CP) -a $(PKG_BUILD_DIR)/$(2)/dist/* $(1)/ -R
$(CP) -a $(PKG_BUILD_DIR)/$(2)/ipkg/* $(1)/CONTROL/ 2>/dev/null || true
endef
### Core package ###
define Package/luci-lib-core
SECTION:=luci
CATEGORY:=LuCI
TITLE:=LuCI - Lua Configuration Interface
URL:=http://luci.subsignal.org/
MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
SUBMENU:=8. Libraries
DEPENDS:=+lua +libuci-lua +libubus-lua
TITLE:=LuCI core libraries
endef
define Package/luci-lib-core/install
$(call Package/luci/install/template,$(1),libs/core)
$(PKG_BUILD_DIR)/build/mkversion.sh $(1)/usr/lib/lua/luci/version.lua \
"OpenWrt Firmware" \
"$(OPENWRTVERSION)" \
"$(PKG_BRANCH)" \
"$(PKG_VERSION)"
endef
define Package/luci-lib-core/config
choice
prompt "Build Target"
default PACKAGE_luci-lib-core_source
config PACKAGE_luci-lib-core_compile
bool "Precompiled"
config PACKAGE_luci-lib-core_stripped
bool "Stripped"
config PACKAGE_luci-lib-core_srcdiet
bool "Compressed Source"
config PACKAGE_luci-lib-core_source
bool "Full Source"
endchoice
endef
ifneq ($(CONFIG_PACKAGE_luci-lib-core_compile),)
LUA_TARGET:=compile
endif
ifneq ($(CONFIG_PACKAGE_luci-lib-core_stripped),)
LUA_TARGET:=strip
endif
ifneq ($(CONFIG_PACKAGE_luci-lib-core_srcdiet),)
LUA_TARGET:=diet
endif
ifneq ($(CONFIG_PACKAGE_luci-lib-core),)
LUCI_SELECTED_MODULES+=libs/core
endif
LUCI_BUILD_PACKAGES += luci-lib-core
### Libraries ###
define library
define Package/luci-lib-$(1)
SECTION:=luci
CATEGORY:=LuCI
TITLE:=LuCI - Lua Configuration Interface
URL:=http://luci.subsignal.org/
MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
SUBMENU:=8. Libraries
TITLE:=$(if $(2),$(2),LuCI $(1) library)
$(if $(3),DEPENDS:=+luci-lib-core $(3))
endef
define Package/luci-lib-$(1)/install
$(call Package/luci/install/template,$$(1),libs/$(1))
$(call Package/luci-lib-$(1)/extra-install)
endef
ifneq ($(CONFIG_PACKAGE_luci-lib-$(1)),)
LUCI_SELECTED_MODULES+=libs/$(1)
endif
LUCI_BUILD_PACKAGES += luci-lib-$(1)
endef
define Package/luci-lib-web/conffiles
/etc/config/luci
endef
define Package/luci-lib-nixio/config
choice
prompt "TLS Provider"
default PACKAGE_luci-lib-nixio_notls
config PACKAGE_luci-lib-nixio_notls
bool "Disabled"
config PACKAGE_luci-lib-nixio_axtls
bool "Builtin (axTLS)"
config PACKAGE_luci-lib-nixio_cyassl
bool "CyaSSL"
select PACKAGE_libcyassl
config PACKAGE_luci-lib-nixio_openssl
bool "OpenSSL"
select PACKAGE_libopenssl
endchoice
endef
NIXIO_TLS:=
ifneq ($(CONFIG_PACKAGE_luci-lib-nixio_axtls),)
NIXIO_TLS:=axtls
endif
ifneq ($(CONFIG_PACKAGE_luci-lib-nixio_openssl),)
NIXIO_TLS:=openssl
endif
ifneq ($(CONFIG_PACKAGE_luci-lib-nixio_cyassl),)
NIXIO_TLS:=cyassl
LUCI_CFLAGS+=-I$(STAGING_DIR)/usr/include/cyassl
endif
$(eval $(call library,fastindex,Fastindex indexing module,+PACKAGE_luci-lib-fastindex:liblua))
$(eval $(call library,httpclient,HTTP(S) client library,+luci-lib-web +luci-lib-nixio))
$(eval $(call library,ipkg,LuCI IPKG/OPKG call abstraction library))
$(eval $(call library,json,LuCI JSON library))
$(eval $(call library,lucid,LuCId Full-Stack Webserver,+luci-lib-nixio +luci-lib-web +luci-lib-px5g))
$(eval $(call library,lucid-http,LuCId HTTP Backend,+luci-lib-lucid))
$(eval $(call library,lucid-rpc,LuCId RPC Backend,+luci-lib-lucid))
$(eval $(call library,nixio,NIXIO POSIX library,+PACKAGE_luci-lib-nixio_openssl:libopenssl +PACKAGE_luci-lib-nixio_cyassl:libcyassl))
$(eval $(call library,px5g,RSA/X.509 Key Generator (required for LuCId SSL support),+luci-lib-nixio))
$(eval $(call library,sys,LuCI Linux/POSIX system library))
$(eval $(call library,web,MVC Webframework,+luci-lib-sys +luci-lib-nixio +luci-lib-core +luci-sgi-cgi))
### Protocols ###
define protocol
define Package/luci-proto-$(1)
SECTION:=luci
CATEGORY:=LuCI
TITLE:=LuCI - Lua Configuration Interface
URL:=http://luci.subsignal.org/
MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
SUBMENU:=6. Protocols
TITLE:=$(if $(2),$(2),LuCI $(1) protocol support)
DEPENDS:=$(3)
endef
define Package/luci-proto-$(1)/install
$(call Package/luci/install/template,$$(1),protocols/$(1))
endef
ifneq ($(CONFIG_PACKAGE_luci-proto-$(1)),)
LUCI_SELECTED_MODULES+=protocols/$(1)
endif
LUCI_BUILD_PACKAGES += luci-proto-$(1)
endef
$(eval $(call protocol,core,Support for static/dhcp/none))
$(eval $(call protocol,ppp,Support for PPP/PPPoE/PPPoA/PPtP))
$(eval $(call protocol,ipv6,Support for DHCPv6/6in4/6to4/6rd,+PACKAGE_luci-proto-ipv6:6in4 +PACKAGE_luci-proto-ipv6:6to4 +PACKAGE_luci-proto-ipv6:6rd +PACKAGE_luci-proto-ipv6:ipv6-support))
$(eval $(call protocol,3g,Support for 3G,+PACKAGE_luci-proto-3g:comgt))
$(eval $(call protocol,4g,Support for 4G,+PACKAGE_luci-proto-4g:libmbim +libqmi))
$(eval $(call protocol,relay,Support for relayd pseudo bridges,+PACKAGE_luci-proto-relay:relayd))
### Community Packages ###
define Package/luci-mod-freifunk-community
SECTION:=luci
CATEGORY:=LuCI
TITLE:=LuCI - Lua Configuration Interface
URL:=http://luci.subsignal.org/
MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
SUBMENU:=9. Freifunk
TITLE:=Freifunk Community Meta-Package
DEPENDS+= \
+luci-lib-web +luci-app-splash +luci-i18n-german \
+PACKAGE_luci-mod-freifunk-community:olsrd +PACKAGE_luci-mod-freifunk-community:olsrd-mod-dyn-gw-plain \
+PACKAGE_luci-mod-freifunk-community:olsrd-mod-txtinfo +PACKAGE_luci-mod-freifunk-community:olsrd-mod-nameservice \
+PACKAGE_luci-mod-freifunk-community:olsrd-mod-watchdog +PACKAGE_luci-mod-freifunk-community:kmod-tun \
+PACKAGE_luci-mod-freifunk-community:ip +PACKAGE_luci-mod-freifunk-community:freifunk-watchdog +luci-app-olsr \
+luci-app-olsr-services +freifunk-gwcheck +freifunk-mapupdate
endef
define Package/luci-mod-freifunk-community/install
$(call Package/luci/install/template,$(1),applications/freifunk-community)
endef
ifneq ($(CONFIG_PACKAGE_luci-mod-freifunk-community),)
LUCI_SELECTED_MODULES+=applications/freifunk-community
endif
LUCI_BUILD_PACKAGES += luci-mod-freifunk-community
### Modules ###
define module
define Package/luci-mod-$(1)
SECTION:=luci
CATEGORY:=LuCI
TITLE:=LuCI - Lua Configuration Interface
URL:=http://luci.subsignal.org/
MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
SUBMENU:=2. Modules
TITLE:=$(if $(2),$(2),LuCI $(1) module)
$(if $(3),DEPENDS+=$(3))
endef
define Package/luci-mod-$(1)/install
$(call Package/luci/install/template,$$(1),modules/$(1))
$(call Package/luci-mod-$(1)/extra-install)
endef
ifneq ($(CONFIG_PACKAGE_luci-mod-$(1)),)
LUCI_SELECTED_MODULES+=modules/$(1)
endif
LUCI_BUILD_PACKAGES += luci-mod-$(1)
endef
define Package/luci-mod-admin-core/extra-install
touch $(1)/etc/init.d/luci_fixtime || true
endef
$(eval $(call module,admin-core,Web UI Core module,+luci-lib-web +luci-proto-core +luci-i18n-english))
$(eval $(call module,admin-mini,LuCI Essentials - stripped down and user-friendly,+luci-mod-admin-core @BROKEN))
$(eval $(call module,admin-full,LuCI Administration - full-featured for full control,+luci-mod-admin-core +luci-lib-ipkg))
$(eval $(call module,failsafe,LuCI Fail-Safe - Fail-Safe sysupgrade module,+luci-mod-admin-core))
$(eval $(call module,rpc,LuCI RPC - JSON-RPC API,+luci-lib-json))
$(eval $(call module,freifunk,LuCI Freifunk module,+luci-mod-admin-full +luci-lib-json +PACKAGE_luci-mod-freifunk:freifunk-firewall +freifunk-common +community-profiles))
$(eval $(call module,niu,NIU - Next Generation Interface,+luci-mod-admin-core @BROKEN))
### Applications ###
define application
define Package/luci-app-$(1)
SECTION:=luci
CATEGORY:=LuCI
TITLE:=LuCI - Lua Configuration Interface
URL:=http://luci.subsignal.org/
MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
SUBMENU:=3. Applications
TITLE:=$(if $(2),$(2),LuCI $(1) application)
DEPENDS:=$(3)
endef
define Package/luci-app-$(1)/install
$(call Package/luci/install/template,$$(1),applications/luci-$(1))
endef
ifneq ($(CONFIG_PACKAGE_luci-app-$(1)),)
LUCI_SELECTED_MODULES+=applications/luci-$(1)
endif
LUCI_BUILD_PACKAGES += luci-app-$(1)
endef
define Package/luci-app-splash/conffiles
/etc/config/luci_splash
/usr/lib/luci-splash/splashtext.html
endef
define Package/luci-app-statistics/conffiles
/etc/config/luci_statistics
endef
define Package/luci-app-diag-devinfo/conffiles
/etc/config/luci_devinfo
endef
$(eval $(call application,siitwizard,SIIT IPv4-over-IPv6 configuration wizard,\
+PACKAGE_luci-app-siitwizard:kmod-siit))
$(eval $(call application,firewall,Firewall and Portforwarding application,\
+PACKAGE_luci-app-firewall:firewall))
$(eval $(call application,freifunk-policyrouting,Policy routing for mesh traffic,\
+PACKAGE_luci-app-freifunk-policyrouting:freifunk-policyrouting))
$(eval $(call application,freifunk-widgets,Widgets for the Freifunk index page,\
+PACKAGE_luci-app-freifunk-widgets:luci-mod-freifunk))
$(eval $(call application,meshwizard, Shellscript based wizard to setup mesh networks,\
+PACKAGE_luci-app-freifunk-meshwizard:meshwizard))
$(eval $(call application,olsr,OLSR configuration and status module,\
+olsrd-mod-txtinfo))
$(eval $(call application,olsr-viz,OLSR Visualisation,\
luci-app-olsr +olsrd-mod-txtinfo))
$(eval $(call application,freifunk-diagnostics,Tools for network diagnosis like traceroute and ping))
$(eval $(call application,olsr-services,Show services announced with the nameservice plugin,\
luci-app-olsr +olsrd-mod-nameservice))
$(eval $(call application,qos,Quality of Service configuration module,\
+PACKAGE_luci-app-qos:qos-scripts))
$(eval $(call application,splash,Freifunk DHCP-Splash application,\
+luci-lib-nixio +tc +kmod-sched +iptables-mod-nat-extra +iptables-mod-ipopt))
$(eval $(call application,statistics,LuCI Statistics Application,\
+PACKAGE_luci-app-statistics:collectd \
+PACKAGE_luci-app-statistics:rrdtool1 \
+PACKAGE_luci-app-statistics:collectd-mod-rrdtool \
+PACKAGE_luci-app-statistics:collectd-mod-iwinfo \
+PACKAGE_luci-app-statistics:collectd-mod-interface \
+PACKAGE_luci-app-statistics:collectd-mod-load)) \
+PACKAGE_luci-app-statistics:collectd-mod-network))
$(eval $(call application,diag-core,LuCI Diagnostics Tools (Core)))
$(eval $(call application,diag-devinfo,LuCI Diagnostics Tools (Device Info),\
+luci-app-diag-core \
+PACKAGE_luci-app-diag-devinfo:smap \
+PACKAGE_luci-app-diag-devinfo:netdiscover \
+PACKAGE_luci-app-diag-devinfo:mac-to-devinfo \
+PACKAGE_luci-app-diag-devinfo:httping \
+PACKAGE_luci-app-diag-devinfo:smap-to-devinfo \
+PACKAGE_luci-app-diag-devinfo:netdiscover-to-devinfo))
$(eval $(call application,commands,LuCI Shell Command Module))
$(eval $(call application,upnp,Universal Plug & Play configuration module,\
+PACKAGE_luci-app-upnp:miniupnpd))
$(eval $(call application,ntpc,NTP time synchronisation configuration module,\
+PACKAGE_luci-app-ntpc:ntpclient))
$(eval $(call application,ddns,Dynamic DNS configuration module,\
+PACKAGE_luci-app-ddns:ddns-scripts))
$(eval $(call application,samba,Network Shares - Samba SMB/CIFS module,\
+PACKAGE_luci-app-samba:samba3))
$(eval $(call application,mmc-over-gpio,MMC-over-GPIO configuration module,\
+PACKAGE_luci-app-mmc-over-gpio:kmod-mmc-over-gpio))
$(eval $(call application,p910nd,p910nd - Printer server module,\
+PACKAGE_luci-app-p910nd:p910nd))
$(eval $(call application,ushare,uShare - UPnP A/V & DLNA Media Server,\
+PACKAGE_luci-app-ushare:ushare))
$(eval $(call application,hd-idle,Hard Disk Idle Spin-Down module,\
+PACKAGE_luci-app-hd-idle:hd-idle))
$(eval $(call application,tinyproxy,Tinyproxy - HTTP(S)-Proxy configuration,\
+PACKAGE_luci-app-tinyproxy:tinyproxy))
$(eval $(call application,polipo,LuCI Support for the Polipo Proxy,\
+PACKAGE_luci-app-polipo:polipo))
$(eval $(call application,openvpn,LuCI Support for OpenVPN,\
+PACKAGE_luci-app-openvpn:openvpn))
$(eval $(call application,p2pblock,LuCI Support for the Freifunk P2P-Block addon,\
luci-app-firewall +PACKAGE_luci-app-p2pblock:freifunk-p2pblock))
$(eval $(call application,multiwan,LuCI Support for the OpenWrt MultiWAN agent,\
luci-app-firewall +PACKAGE_luci-app-multiwan:multiwan))
$(eval $(call application,wol,LuCI Support for Wake-on-LAN,\
+PACKAGE_luci-app-wol:etherwake))
$(eval $(call application,vnstat,LuCI Support for VnStat,\
+PACKAGE_luci-app-vnstat:vnstat \
+PACKAGE_luci-app-vnstat:vnstati))
$(eval $(call application,radvd,LuCI Support for Radvd,\
+PACKAGE_luci-app-radvd:radvd))
$(eval $(call application,ahcp,LuCI Support for AHCPd,\
+PACKAGE_luci-app-ahcp:ahcpd))
$(eval $(call application,wshaper,LuCI Support for wshaper,\
+PACKAGE_luci-app-wshaper:wshaper))
$(eval $(call application,voice,LuCI Voice application,\
+PACKAGE_luci-app-voice:voice-client))
$(eval $(call application,ltqtapi,Lantiq voip))
$(eval $(call application,minidlna,LuCI Support for miniDLNA,\
+PACKAGE_luci-app-minidlna:minidlna))
$(eval $(call application,transmission,LuCI Support for Transmission,\
+PACKAGE_luci-app-transmission:transmission-daemon))
$(eval $(call application,watchcat,LuCI Support for Watchcat,\
+PACKAGE_luci-app-watchcat:watchcat))
$(eval $(call application,dslstats,LuCI Support for DSL Statistics,\
+PACKAGE_luci-app-dslstats))
$(eval $(call application,mcpd,LuCI Support for IGMP Proxy,\
+PACKAGE_luci-app-mcpd:mcpd))
$(eval $(call application,sfp,LuCI Support for SFP status,\
+PACKAGE_luci-app-sfp:sfp))
$(eval $(call application,catv,LuCI Support for CATV Module,\
+PACKAGE_luci-app-catv:catv))
$(eval $(call application,mount,LuCI Support for Mount Management,\
+PACKAGE_luci-app-mount))
$(eval $(call application,software,LuCI Support for Package Management,\
+PACKAGE_luci-app-software))
$(eval $(call application,speedtest,LuCI Speed Test application,\
+PACKAGE_luci-app-speedtest:tptest))
$(eval $(call application,iup,LuCI Support for Provisioning,\
+PACKAGE_luci-app-iup:iup))
$(eval $(call application,dect,LuCI Support for DECT,\
+PACKAGE_luci-app-dect:dectmngr))
$(eval $(call application,snmp,LuCI Support for SNMP,\
+PACKAGE_luci-app-snmp:snmpd))
$(eval $(call application,port-management,LuCI Support for Port Management,\
+PACKAGE_luci-app-port-management))
$(eval $(call application,power-mgmt,LuCI Support for Power Management,\
+PACKAGE_luci-app-power-mgmt))
$(eval $(call application,parental-control,LuCI Support for Parental Control,\
+PACKAGE_luci-app-parental-control))
### Server Gateway Interfaces ###
define sgi
define Package/luci-sgi-$(1)
SECTION:=luci
CATEGORY:=LuCI
TITLE:=LuCI - Lua Configuration Interface
URL:=http://luci.subsignal.org/
MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
SUBMENU:=7. Server Interfaces
TITLE:=$(if $(2),$(2),LuCI $(1) server gateway interface)
DEPENDS:=$(3)
endef
define Package/luci-sgi-$(1)/install
$(call Package/luci/install/template,$$(1),libs/sgi-$(1))
endef
ifneq ($(CONFIG_PACKAGE_luci-sgi-$(1)),)
LUCI_SELECTED_MODULES+=libs/sgi-$(1)
endif
LUCI_BUILD_PACKAGES += luci-sgi-$(1)
endef
$(eval $(call sgi,cgi,CGI Gateway behind existing Webserver))
#$(eval $(call sgi,uhttpd,Binding for the uHTTPd server,+uhttpd +uhttpd-mod-lua))
### Themes ###
define theme
define Package/luci-theme-$(1)
SECTION:=luci
CATEGORY:=LuCI
TITLE:=LuCI - Lua Configuration Interface
URL:=http://luci.subsignal.org/
SUBMENU:=4. Themes
TITLE:=$(if $(2),$(2),LuCI $(1) theme)
MAINTAINER:=$(if $(3),$(3),LuCI Development Team <luci@lists.subsignal.org>)
DEPENDS:=$(if $(filter-out base,$(1)),+luci-theme-base) $(4)
$(if $(5),DEFAULT:=PACKAGE_luci-lib-core)
endef
define Package/luci-theme-$(1)/install
$(call Package/luci/install/template,$$(1),themes/$(1))
endef
ifneq ($(CONFIG_PACKAGE_luci-theme-$(1)),)
LUCI_SELECTED_MODULES+=themes/$(1)
endif
LUCI_BUILD_PACKAGES += luci-theme-$(1)
endef
$(eval $(call theme,base,Common base for all themes))
$(eval $(call theme,openwrt,OpenWrt.org))
$(eval $(call theme,bootstrap,Bootstrap Theme (default),,,1))
$(eval $(call theme,freifunk-bno,Freifunk Berlin Nordost Theme,\
Stefan Pirwitz <stefan-at-freifunk-bno-dot-de>))
$(eval $(call theme,freifunk-generic,Freifunk Generic Theme,\
Manuel Munz <freifunk-at-somakoma-dot-de>))
### Translations ###
define translation
define Package/luci-i18n-$(1)
SECTION:=luci
CATEGORY:=LuCI
TITLE:=LuCI - Lua Configuration Interface
URL:=http://luci.subsignal.org/
MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
SUBMENU:=5. Translations
TITLE:=$(if $(2),$(2),$(1))
endef
define Package/luci-i18n-$(1)/install
$(call Package/luci/install/template,$$(1),i18n/$(1))
endef
ifneq ($(CONFIG_PACKAGE_luci-i18n-$(1)),)
LUCI_SELECTED_MODULES+=i18n/$(1)
endif
LUCI_BUILD_PACKAGES += luci-i18n-$(1)
endef
$(eval $(call translation,german,German))
$(eval $(call translation,english,English))
$(eval $(call translation,french,French (by Florian Fainelli)))
$(eval $(call translation,italian,Italian (by Matteo Croce)))
$(eval $(call translation,russian,Russian (by Skryabin Dmitry)))
$(eval $(call translation,portuguese-brazilian,Portuguese (Brazilian) (by Carlos Cesario)))
$(eval $(call translation,chinese,Chinese (by Chinese Translators)))
$(eval $(call translation,japanese,Japanese (by Tsukasa Hamano)))
$(eval $(call translation,greek,Greek (by Vasilis Tsiligiannis)))
$(eval $(call translation,catalan,Catalan (by Eduard Duran)))
$(eval $(call translation,portuguese,Portuguese (by Jose Monteiro)))
$(eval $(call translation,spanish,Spanish (by Guillermo Javier Nardoni)))
$(eval $(call translation,vietnamese,Vietnamese (by Hong Phuc Dang)))
$(eval $(call translation,malay,Malay (by Teow Wai Chet)))
$(eval $(call translation,norwegian,Norwegian (by Lars Hardy)))
$(eval $(call translation,hebrew,Hebrew))
$(eval $(call translation,romanian,Romanian))
$(eval $(call translation,ukrainian,Ukrainian))
$(eval $(call translation,hungarian,Hungarian))
$(eval $(call translation,polish,Polish))
### Collections ###
define collection
define Package/luci$(if $(1),-$(1))
SECTION:=luci
CATEGORY:=LuCI
TITLE:=LuCI - Lua Configuration Interface
URL:=http://luci.subsignal.org/
MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
SUBMENU:=1. Collections
TITLE:=$(if $(2),$(2),LuCI $(if $(1),$(1),general) collection)
$(if $(3),DEPENDS:=$(3))
endef
define Package/luci$(if $(1),-$(1))/install
true
endef
LUCI_BUILD_PACKAGES += luci$(if $(1),-$(1))
endef
$(eval $(call collection,,\
Standard OpenWrt set including full admin with ppp support and the \
bootstrap theme,\
+lighttpd +luci-mod-admin-full +luci-theme-bootstrap \
+luci-app-firewall +luci-proto-core +luci-proto-ppp +libiwinfo-lua))
$(eval $(call collection,ssl,\
Standard OpenWrt set with HTTPS support,\
+luci +lighttpd +px5g))
$(eval $(call collection,light,\
Minimum package set using only admin mini and the bootstrap theme,\
+lighttpd +luci-mod-admin-mini +luci-theme-bootstrap @BROKEN))
$(eval $(call application,ipsec,LuCI Support for IPsec,\
+PACKAGE_luci-app-ipsec:openswan))
### Compile ###
PKG_CONFIG_DEPENDS=$(patsubst %,CONFIG_PACKAGE_%,$(LUCI_BUILD_PACKAGES))
include $(INCLUDE_DIR)/package.mk
ifeq ($(USELOCAL),1)
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(TAR) c -C ../../../ . \
--exclude=.pc --exclude=.svn --exclude=.git \
--exclude='boa-0*' --exclude='*.o' --exclude='*.so' \
--exclude=dist | \
tar x -C $(PKG_BUILD_DIR)/
endef
endif
define Build/Configure
endef
MAKE_FLAGS += \
MODULES="$(LUCI_SELECTED_MODULES)" \
LUA_TARGET="$(LUA_TARGET)" \
LUA_SHLIBS="-llua -lm -ldl -lcrypt" \
CFLAGS="$(TARGET_CFLAGS) $(LUCI_CFLAGS) -I$(STAGING_DIR)/usr/include" \
LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/usr/lib" \
NIXIO_TLS="$(NIXIO_TLS)" OS="Linux"
$(foreach b,$(LUCI_BUILD_PACKAGES),$(eval $(call BuildPackage,$(b))))

View file

@ -0,0 +1,39 @@
# Copyright (C) 2011 Manuel Munz <freifunk at somakoma de>
# This is free software, licensed under the Apache 2.0 license.
include $(TOPDIR)/rules.mk
PKG_NAME:=meshwizard
PKG_RELEASE:=0.0.5
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/meshwizard
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=9. Freifunk
TITLE:=Shell script based wizard for Mesh networks
DEPENDS:=+firewall
endef
define Package/meshwizard/description
A shellscript based wizard to simplify the setup of a typical mesh node (e.g. for Freifunk.net)
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/meshwizard/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,meshwizard))

View file

@ -0,0 +1,7 @@
config 'netconfig' 'netconfig'
config 'general' 'general'
option 'sharenet' '0'
option 'local_restrict' '1'
option 'cleanup' '1'

View file

@ -0,0 +1,59 @@
uci_remove_list_element() {
local option="$1"
local value="$2"
local list="$(uci get $option)"
local elem
uci delete $option
for elem in $list; do
if [ "$elem" != "$value" ]; then
uci add_list $option=$elem
fi
done
}
# Takes 2 arguments
# $1 = text to be displayed in the output for this section
# $2 = section (optional)
uci_commitverbose() {
echo "+ $1"
uci changes $2 | while read line; do
echo " $line"
done
uci commit $2
}
set_defaults() {
for def in $(env |grep "^$1" | sed 's/ /_/g'); do
option="${def/$1/}"
a="$(echo $option |cut -d '=' -f1)"
b="$(echo $option |cut -d '=' -f2)"
b="${b//_/ }"
uci set $2.$a="$b"
done
}
# 3 arguements: 1=config name 2=oldname 3=newname
section_rename() {
uci -q rename $1.$2=$3 && msg_rename $1.$2 $1.$3 || msg_rename_error $1.2 $1.$3
}
msg_missing_value() {
echo -e " \033[1mWarning:\033[0m Configuration option for $2 is missing in $1."
}
msg_success() {
echo " Finished."
}
msg_error() {
echo " \033[1mError: \033[0mThere was a problem."
}
msg_rename() {
echo " Renamed unnamed section $1 to $2."
}
msg_rename_error() {
echo " \033[1mWarning:\033[0m Could not rename $1 to $2."
}

View file

@ -0,0 +1,31 @@
#!/bin/sh
# Checks whether a netrange is inside another netrange, returns 1 if true
# Takes two arguments: $1: net from which we want to know if it is inside $2
# nets need to be given in CIDR notation
dir=$(dirname $0)
awk -f $dir/common.awk -f - $* <<EOF
BEGIN {
slpos=index(ARGV[1],"/")
ipaddr=ip2int(substr(ARGV[1],0,slpos-1))
netmask=compl(2**(32-int(substr(ARGV[1],slpos+1)))-1)
network=and(ipaddr,netmask)
broadcast=or(network,compl(netmask))
slpos2=index(ARGV[2],"/")
ipaddr2=ip2int(substr(ARGV[2],0,slpos2-1))
netmask2=compl(2**(32-int(substr(ARGV[2],slpos2+1)))-1)
network2=and(ipaddr2,netmask2)
broadcast2=or(network2,compl(netmask2))
if (network >= network2) {
if (network <= broadcast2) {
if (broadcast <= broadcast2) {
print "1"
}
}
}
}
EOF

View file

@ -0,0 +1,20 @@
function bitcount(c) {
c=and(rshift(c, 1),0x55555555)+and(c,0x55555555)
c=and(rshift(c, 2),0x33333333)+and(c,0x33333333)
c=and(rshift(c, 4),0x0f0f0f0f)+and(c,0x0f0f0f0f)
c=and(rshift(c, 8),0x00ff00ff)+and(c,0x00ff00ff)
c=and(rshift(c,16),0x0000ffff)+and(c,0x0000ffff)
return c
}
function ip2int(ip) {
for (ret=0,n=split(ip,a,"\."),x=1;x<=n;x++) ret=or(lshift(ret,8),a[x])
return ret
}
function int2ip(ip,ret,x) {
ret=and(ip,255)
ip=rshift(ip,8)
for(;x<3;ret=and(ip,255)"."ret,ip=rshift(ip,8),x++);
return ret
}

View file

@ -0,0 +1,36 @@
#!/bin/sh
# create essid from channel, takes two args:
# $1 = channel (integer)
# $2 = community (optional)
channel=$1
community=$2
. /lib/functions.sh
# Try to get BSSID from profile first
config_load profile_$community
config_get bssid bssidscheme $channel
if [ -z "$bssid" ]; then
config_get bssid bssidscheme "all"
fi
if [ -z "$bssid" ]; then
case $channel in
[1-9])
bssid="$(printf "%X\n" $channel)2:CA:FF:EE:BA:BE"
;;
1[0-4])
bssid="$(printf "%X\n" $channel)2:CA:FF:EE:BA:BE"
;;
[3-9][0-9])
bssid="00:$channel:CA:FF:EE:EE"
;;
1[0-9][0-9])
bssid="${channel/1/01:}:CA:FF:EE:EE"
;;
*) bssid="02:CA:FF:EE:BA:BE"
;;
esac
fi
echo $bssid

View file

@ -0,0 +1,6 @@
#!/bin/sh
# generates a dhcp-ip and netrange from a given ip/subnet
# takes 2 arguments:
# $1: Ip Address (of the Interface for which we want to generate an ip)
echo "$1" | awk 'BEGIN { FS = "." } ; { print "6."$3"."$4".1" }'

View file

@ -0,0 +1,33 @@
#!/bin/sh
# This is only run once (usually after flashing an image from the imagebuilder)
# It sets up the initial config for this node.
. /lib/functions.sh
. $dir/functions.sh
config_load system
# Rename system config
handle_system() {
if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
section_rename system $1 system
fi
}
config_foreach handle_system system
if [ -n "$(uci -q get meshwizard.community)" ]; then
set_defaults "community_" freifunk.community
uci -q delete meshwizard.community
fi
[ -n "$profile_homepage" ] && uci set freifunk.community.homepage="$profile_homepage"
uci_commitverbose "Setup community" freifunk
if [ -n "$(uci -q get meshwizard.contact)" ]; then
set_defaults "contact_" freifunk.contact
uci -q delete meshwizard.contact && uci_commitverbose "Setup contact" freifunk
fi
if [ "$has_luci" == TRUE ]; then
set_defaults "luci_main_" luci.main
uci -q delete meshwizard.luci_main && uci_commitverbose "Setup luci" luci
fi

View file

@ -0,0 +1,41 @@
#!/bin/sh
dir=$(dirname $0)
awk -f $dir/common.awk -f - $* <<EOF
BEGIN {
slpos=index(ARGV[1],"/")
if (slpos == 0) {
ipaddr=ip2int(ARGV[1])
netmask=ip2int(ARGV[2])
} else {
ipaddr=ip2int(substr(ARGV[1],0,slpos-1))
netmask=compl(2**(32-int(substr(ARGV[1],slpos+1)))-1)
ARGV[4]=ARGV[3]
ARGV[3]=ARGV[2]
}
network=and(ipaddr,netmask)
broadcast=or(network,compl(netmask))
start=or(network,and(ip2int(ARGV[3]),compl(netmask)))
limit=network+1
if (start<limit) start=limit
end=start+ARGV[4]
limit=or(network,compl(netmask))-1
if (end>limit) end=limit
print "IP="int2ip(ipaddr)
print "NETMASK="int2ip(netmask)
print "BROADCAST="int2ip(broadcast)
print "NETWORK="int2ip(network)
print "PREFIX="32-bitcount(compl(netmask))
# range calculations:
# ipcalc <ip> <netmask> <start> <num>
if (ARGC > 3) {
print "START="int2ip(start)
print "END="int2ip(end)
}
}
EOF

View file

@ -0,0 +1,25 @@
#!/bin/sh
# This reads the settings we need to have to configure everything
# Argument $1: community
community="$1"
# reads variables from uci files, parameter $1 is the section
get_var() {
uci -q show $1 | cut -d "." -f 2-100 |grep "\." | sed -e 's/^\([a-z_]*\)\./\1_/g' -e 's/=\(.*\)$/="\1"/g'
}
# read default values from /etc/config/freifunk
for v in system wifi_device wifi_iface interface alias dhcp olsr_interface olsr_interfacedefaults zone_freifunk include; do
get_var freifunk.$v
done
# now read all values from the selected community profile, will override some values from the defaults before
for v in system wifi_device wifi_iface interface alias dhcp olsr_interface olsr_interfacedefaults profile zone_freifunk include; do
get_var profile_$community.$v
done
# read values from meshwizard
for v in system luci_main contact community wan lan general; do
get_var meshwizard.$v
done

View file

@ -0,0 +1,46 @@
#!/bin/sh
# This script renames IB_wifi_ interface names into real interface names used on this system.
# E.g. wireless.IB_wifi0 would become wireless.wifi0 on madwifi and wireless.radio0 on mac80211
. $dir/functions.sh
posIB=-1
IBwifis="$(uci show meshwizard.netconfig | grep -v 'netconfig=netconfig' | sed 's/meshwizard.netconfig\.\(IB_wifi.*\)_.*/\1/' |uniq)"
[ -z "$(echo $IBwifis |grep IB_wifi)" ] && exit
for w in $IBwifis; do
posIB=$(( $posIB + 1 ))
export IB_wifi$posIB="$w"
done
pos=0
syswifis="$(uci show wireless |grep wifi-device | sed 's/wireless\.\(.*\)=.*/\1/' |uniq)"
for s in $syswifis; do
export syswifi$pos="$s"
pos=$(( $pos + 1 ))
done
for i in `seq 0 $posIB`; do
IBwifi=$(eval echo \$IB_wifi$i)
syswifi=$(eval echo \$syswifi$i)
if [ -n "$syswifi" ]; then
case $IBwifi in
IB_wifi* )
# replace IB_wifi_* with actual wifi interface names, delete old ones first
uci show meshwizard.netconfig | grep $IBwifi | while read line; do
oldline=$(echo $line | cut -d "=" -f 1)
uci set $oldline=""
newline=$(echo $line |sed "s/$IBwifi/$syswifi/g")
uci set $newline
done
;;
esac
unset IBwifi
unset syswifi
fi
done
uci_commitverbose "Renaming wifi-devices in /etc/config/meshwizard" meshwizard

View file

@ -0,0 +1,11 @@
#!/bin/sh
# This will restore default "factory" settings before running the meshwizard
# and is used when cleanup=1
# Warning: This will reset network settings for wan and lan to defaults too.
echo "+ Restore default config as requested with cleanup=1"
cp -f /rom/etc/config/* /etc/config/
rm /etc/config/wireless
wifi detect > /etc/config/wireless
rm /etc/config/network
/etc/init.d/defconfig start

View file

@ -0,0 +1,30 @@
#!/bin/sh
# Sets up the dhcp part of dnsmasq
. /lib/functions.sh
. $dir/functions.sh
net="$1"
handle_dnsmasq() {
config_get interface "$1" interface
if [ "$interface" == "${netrenamed}dhcp" ]; then
if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
section_rename dhcp $1 ${netrenamed}dhcp
fi
fi
}
config_load dhcp
config_foreach handle_dnsmasq dhcp
[ "$net" == "lan" ] && uci -q delete dhcp.lan
uci batch << EOF
set dhcp.${netrenamed}dhcp="dhcp"
set dhcp.${netrenamed}dhcp.interface="${netrenamed}dhcp"
EOF
set_defaults "dhcp_" dhcp.${netrenamed}dhcp
uci_commitverbose "Setup DHCP for $netrenamed" dhcp

View file

@ -0,0 +1,26 @@
#!/bin/sh
. /lib/functions.sh
. $dir/functions.sh
# Set dnsmasq config
handle_dhcp() {
if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
section_rename dhcp $1 dnsmasq
fi
}
config_load dhcp
config_foreach handle_dhcp dnsmasq
uci batch << EOF
set dhcp.dnsmasq.local="/$profile_suffix/"
set dhcp.dnsmasq.domain="$profile_suffix"
EOF
config_get addnhosts dnsmasq addnhosts
if [ -z "${addnhosts/\var\/etc\/hosts.olsr/}" ]; then
uci add_list dhcp.dnsmasq.addnhosts="/var/etc/hosts.olsr"
fi
uci_commitverbose "Setup dnsmasq" dhcp

View file

@ -0,0 +1,100 @@
#!/bin/sh
# Add "freifunk" firewall zone
# If wan/lan is used for olsr then remove these networks from wan/lan zones
# Also setup rules defined in /etc/config/freifunk and /etc/config/profile_<community>
. /lib/functions.sh
. $dir/functions.sh
wan_is_olsr=$(uci -q get meshwizard.netconfig.wan_config)
lan_is_olsr=$(uci -q get meshwizard.netconfig.lan_config)
config_load firewall
# Rename firewall zone for freifunk if unnamed
# If wan is used for olsr then set network for the firewall zone wan to ' ' to remove the wan interface from it, else add local restrict to it
# If lan is used for olsr then set network for the firewall zone lan to ' ' to remove the lan interface from it
handle_fwzone() {
config_get name "$1" name
config_get network "$1" network
if [ "$name" == "freifunk" ]; then
# rename section if unnamed
if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
section_rename firewall $1 zone_freifunk
fi
fi
if [ "$name" == "wan" ]; then
if [ "$wan_is_olsr" == 1 ]; then
uci set firewall.$1.network=' ' && uci_commitverbose "WAN is used for olsr, removed the wan interface from zone wan" firewall
else
uci set firewall.$1.local_restrict=1 && uci_commitverbose "Enable local_restrict for zone wan" firewall
fi
fi
if [ "$name" == "lan" ] && [ "$lan_is_olsr" == 1 ]; then
uci set firewall.$1.network=' ' && uci_commitverbose "LAN is used for olsr, removed the lan interface from zone lan" firewall
fi
}
config_foreach handle_fwzone zone
uci batch << EOF
set firewall.zone_freifunk="zone"
set firewall.zone_freifunk.name="freifunk"
set firewall.zone_freifunk.input="$zone_freifunk_input"
set firewall.zone_freifunk.forward="$zone_freifunk_forward"
set firewall.zone_freifunk.output="$zone_freifunk_output"
EOF
uci_commitverbose "Setup firewall zones" firewall
# Usually we need to setup masquerading for lan, except lan is an olsr interface or has an olsr hna-entry
handle_interface() {
config_get interface "$1" interface
if [ "$interface" == "lan" ]; then
no_masq_lan=1
fi
}
config_load olsrd
config_foreach handle_interface Interface
LANIP="$(uci -q get network.lan.ipaddr)"
if [ -n "$LANIP" ]; then
handle_hna() {
config_get netaddr "$1" netaddr
if [ "$LANIP" == "$netaddr" ]; then
no_masq_lan=1
fi
}
config_foreach handle_hna Hna4
fi
currms=$(uci -q get firewall.zone_freifunk.masq_src)
if [ ! "$no_masq_lan" == "1" ] && [ ! "$(uci -q get meshwizard.netconfig.lan_config)" == 1 ]; then
uci set firewall.zone_freifunk.masq="1"
[ -z "$(echo $currms |grep lan)" ] && uci add_list firewall.zone_freifunk.masq_src="lan"
fi
# Rules, Forwardings, advanced config and includes
for config in freifunk profile_$community; do
config_load $config
for section in advanced include fw_rule fw_forwarding; do
handle_firewall() {
local options=$(uci show $config."$1")
options=$(echo "$options" | sed -e "s/fw_//g" -e "s/^$config/firewall/g")
for o in $options; do
uci set $o
done
}
config_foreach handle_firewall $section
done
done
uci_commitverbose "Setup rules, forwardings, advanced config and includes." firewall

View file

@ -0,0 +1,81 @@
#!/bin/sh
# This will add $net to the zone firewall (and remove it from other zones where it is referenced)
# It will also setup rules defined in /etc/config/freifunk and /etc/config/profile_<community>
# Arg $1 = $net
net=$1
. /lib/functions.sh
. $dir/functions.sh
config_load firewall
# Get some variables
type="$(uci -q get wireless.$net.type)"
vap="$(uci -q get meshwizard.netconfig.$net\_vap)"
wan_is_olsr=$(uci -q get meshwizard.netconfig.wan_config)
# Delete old firewall zone for freifunk
handle_fwzone() {
config_get name "$1" name
config_get network "$1" network
if [ "$2" == "zoneconf" ]; then
if [ "$name" == "freifunk" ]; then
# rename section if unnamed
if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
section_rename firewall $1 zone_freifunk
fi
else
if [ ! "$name" == "freifunk" ] && [ -n "$netrenamed" -a -n "$(echo $network | grep $netrenamed)" ]; then
echo " Removed $netrenamed from firewall zone $name."
network_new=$(echo $network | sed -e 's/'$netrenamed'//' -e 's/^ //' -e 's/ / /' -e 's/ $//')
uci set firewall.$1.network="$network_new"
fi
fi
fi
}
config_foreach handle_fwzone zone zoneconf
# Add $netrenamed and if needed ${netrenamed}dhcp to the "freifunk" zone
config_get network zone_freifunk network
# remove ${netrenamed}dhcp from networks list
[ -n "$network" -a -n "$net" ] && network="${network/${netrenamed}dhcp/}"
network=$(echo $network) # Removes leading and trailing whitespaces
[ -n "$netrenamed" ] && [ -z "$(echo $network | grep $netrenamed)" ] && network="$network $netrenamed"
if [ "$type" == "atheros" -a "$vap" == 1 ]; then
[ -n "$netrenamed" ] && [ "$network" == "${network/${netrenamed}dhcp/}" ] && network="$network ${netrenamed}dhcp"
fi
uci set firewall.zone_freifunk.network="$network"
uci_commitverbose "Add '$netrenamed' to freifunk firewall zone" firewall
currms=$(uci -q get firewall.zone_freifunk.masq_src)
# If interfaces are outside of the mesh network they should be natted
# Get dhcprange and meshnet
if_ip="$(uci -q get network.${netrenamed}dhcp.ipaddr)"
if_mask="$(uci -q get network.${netrenamed}dhcp.netmask)"
[ -n "$if_ip" -a "$if_mask" ] && export $(ipcalc.sh $if_ip $if_mask)
[ -n "$NETWORK" -a "$PREFIX" ] && dhcprange="$NETWORK/$PREFIX"
if [ -n "$dhcprange" ]; then
meshnet="$(uci get profile_$community.profile.mesh_network)"
# check if the dhcprange is inside meshnet
dhcpinmesh="$($dir/helpers/check-range-in-range.sh $dhcprange $meshnet)"
if [ ! "$dhcpinmesh" == 1 ]; then
uci set firewall.zone_freifunk.masq=1
[ -z "$(echo $currms |grep ${netrenamed}dhcp)" ] && uci add_list firewall.zone_freifunk.masq_src="${netrenamed}dhcp"
fi
fi
for i in IP NETMASK BROADCAST NETWORK PREFIX; do
unset $i
done
uci_commitverbose "Setup masquerading rules for '$netrenamed'" firewall

View file

@ -0,0 +1,17 @@
#!/bin/sh
# Setup static interface settings for lan if lan is not an olsr interface
[ ! "$(uci -q get network.lan)" == "interface" ] && exit
. /lib/functions.sh
. $dir/functions.sh
uci batch << EOF
set network.lan.proto='$lan_proto'
set network.lan.ipaddr='$lan_ip4addr'
set network.lan.netmask='$lan_netmask'
EOF
uci_commitverbose "Setup static ip settings for lan" network
uci delete meshwizard.lan && uci commit meshwizard

View file

@ -0,0 +1,77 @@
# setup entry in /etc/config/network for a interface
# Argument $1: network interface
net="$1"
. /lib/functions.sh
. $dir/functions.sh
# Setup a (new) interface section for $net
ipaddr=$(uci get meshwizard.netconfig.$net\_ip4addr)
[ -z "$ipaddr" ] && msg_missing_value meshwizard $net\_ip4addr
netmask=$(uci -q get meshwizard.netconfig.$net\_netmask)
[ -z "$netmask" ] && netmask="$interface_netmask"
[ -z "$netmask" ] && netmask="255.255.0.0"
uci set network.$netrenamed="interface"
set_defaults "interface_" network.$netrenamed
uci batch << EOF
set network.$netrenamed.proto="static"
set network.$netrenamed.ipaddr="$ipaddr"
set network.$netrenamed.netmask="$netmask"
EOF
uci_commitverbose "Setup interface $netrenamed" network
# setup dhcp alias/interface
net_dhcp=$(uci -q get meshwizard.netconfig.${net}_dhcp)
if [ "$net_dhcp" == 1 ]; then
# Load meshwizard_settings
dhcprange="$(uci -q get meshwizard.netconfig.${net}_dhcprange)"
interface_ip="$(uci -q get meshwizard.netconfig.${net}_ip4addr)"
vap=$(uci -q get meshwizard.netconfig.${net}_vap)
# Rename config
handle_dhcpalias() {
config_get interface "$1" interface
if [ "$interface" == "$netrenamed" ]; then
if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
section_rename network $1 ${netrenamed}dhcp
fi
fi
}
config_load network
config_foreach handle_dhcpalias alias
# Get IP/netmask and start-ip for $net dhcp
# If no dhcprange is given in /etc/config/meshwizard we autogenerate one
if [ -z "$dhcprange" ]; then
dhcprange="$($dir/helpers/gen_dhcp_ip.sh $interface_ip)/24"
uci set meshwizard.netconfig.${net}_dhcprange="$dhcprange"
fi
eval $(sh $dir/helpers/ipcalc-cidr.sh $dhcprange 1 0)
# setup wifi-dhcp interface or alias
# Setup alias for $net
if [ "$vap" == 1 ]; then
uci set network.${netrenamed}dhcp=interface
else
uci set network.${netrenamed}dhcp=alias
uci set network.${netrenamed}dhcp.interface="$netrenamed"
fi
uci batch <<- EOF
set network.${netrenamed}dhcp.proto=static
set network.${netrenamed}dhcp.ipaddr="$START"
set network.${netrenamed}dhcp.netmask="$NETMASK"
EOF
uci_commitverbose "Setup interface for ${netrenamed}dhcp" network
fi

View file

@ -0,0 +1,60 @@
#!/bin/sh
# Sets up olsrd
. /lib/functions.sh
. $dir/functions.sh
# Rename interface defaults
handle_interfacedefaults() {
if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
section_rename olsrd $1 InterfaceDefaults
fi
}
config_load olsrd
config_foreach handle_interfacedefaults InterfaceDefaults
# Setup new InterfaceDefaults
uci set olsrd.InterfaceDefaults=InterfaceDefaults
set_defaults "olsr_interfacedefaults_" olsrd.InterfaceDefaults
uci_commitverbose "Setup olsr interface defaults" olsrd
# Rename nameservice, dyngw and httpinfo plugins
handle_plugin() {
config_get library "$1" library
if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
new="$(echo $library | cut -d '.' -f 1)"
section_rename olsrd $1 $new
fi
}
config_foreach handle_plugin LoadPlugin
# Setup nameservice plugin
if [ -n "$profile_suffix" ]; then
suffix=".$profile_suffix"
else
suffix=".olsr"
fi
uci batch << EOF
set olsrd.olsrd_nameservice=LoadPlugin
set olsrd.olsrd_nameservice.library="olsrd_nameservice.so.0.3"
set olsrd.olsrd_nameservice.latlon_file="/var/run/latlon.js"
set olsrd.olsrd_nameservice.hosts_file="/var/etc/hosts.olsr"
set olsrd.olsrd_nameservice.sighup_pid_file="/var/run/dnsmasq.pid"
set olsrd.olsrd_nameservice.suffix="$suffix"
EOF
uci_commitverbose "Setup olsr nameservice plugin" olsrd
# Setup dyngw_plain
# If Sharing of Internet is enabled then enable dyngw_plain plugin
if [ "$general_sharenet" == 1 ]; then
uci set olsrd.dyngw_plain=LoadPlugin
uci set olsrd.dyngw_plain.ignore=0
uci set olsrd.dyngw_plain.library="olsrd_dyn_gw_plain.so.0.4"
uci_commitverbose "Setup olsrd_dyngw_plain plugin" olsrd
fi

View file

@ -0,0 +1,46 @@
#!/bin/sh
# Sets up olsrd interfaces
# arg $1 = net
net=$1
. /lib/functions.sh
. $dir/functions.sh
# Rename interface for $netrenamed
handle_interface() {
config_get interface "$1" Interface
if [ "$interface" == "$netrenamed" ]; then
if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
section_rename olsrd $1 $netrenamed
fi
fi
}
config_foreach handle_interface Interface
# Setup new interface for $netrenamed
uci set olsrd.$netrenamed=Interface
set_defaults "olsr_interface_" olsrd.$net
uci set olsrd.$netrenamed.interface="$netrenamed"
uci_commitverbose "Setup olsr interface for $netrenamed." olsrd
# If dhcp-network is inside the mesh_network then add HNA for it
dhcprange=$(uci -q get meshwizard.netconfig.$net\_dhcprange)
uci -q delete olsrd.${netrenamed}clients
if [ -n "$dhcprange" ]; then
meshnet="$(uci get profile_$community.profile.mesh_network)"
dhcpinmesh="$($dir/helpers/check-range-in-range.sh $dhcprange $meshnet)"
if [ "$dhcpinmesh" == 1 ] && [ -n "$meshnet" ]; then
uci set olsrd.${netrenamed}clients="Hna4"
eval $(sh $dir/helpers/ipcalc-cidr.sh $dhcprange)
uci set olsrd.${netrenamed}clients.netaddr="$NETWORK"
uci set olsrd.${netrenamed}clients.netmask="$NETMASK"
uci_commitverbose "Setup HNA for network $dhcprange" olsrd
fi
fi

Some files were not shown because too many files have changed in this diff Show more