Add files for OpenWRT olsrd-stable-git generation
authorHenning Rogge <hrogge@googlemail.com>
Mon, 6 Dec 2010 19:05:21 +0000 (20:05 +0100)
committerHenning Rogge <hrogge@googlemail.com>
Mon, 6 Dec 2010 19:05:21 +0000 (20:05 +0100)
openwrt/README [new file with mode: 0644]
openwrt/olsrd-stable-git/Makefile [new file with mode: 0644]
openwrt/olsrd-stable-git/files/olsrd.config [new file with mode: 0644]
openwrt/olsrd-stable-git/files/olsrd.init [new file with mode: 0644]
openwrt/olsrd-stable-git/files/olsrd_secure_key [new file with mode: 0644]

diff --git a/openwrt/README b/openwrt/README
new file mode 100644 (file)
index 0000000..847f57d
--- /dev/null
@@ -0,0 +1,17 @@
+This is an OpenWrt package feed containing the olsrd-stable-git package.
+
+To use this package, add the following line to the feeds.conf
+in the OpenWrt buildroot:
+
+  src-git olsrd http://olsr.org/git/olsrd.git;stable
+  
+Update the feed:
+
+  ./scripts/feeds update olsrd
+  
+Activate the package:
+
+  ./scripts/feeds install olsrd-stable-git
+  
+The "olsrd-stable-git" package should now appear in menuconfig.
+
diff --git a/openwrt/olsrd-stable-git/Makefile b/openwrt/olsrd-stable-git/Makefile
new file mode 100644 (file)
index 0000000..6f6d86b
--- /dev/null
@@ -0,0 +1,227 @@
+# 
+# Copyright (C) 2009-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=olsrd-stable-git
+PKG_VERSION:=$(shell date +%Y%m%d)+$(shell git --git-dir=$(CURDIR)/../../.git log -1 --pretty=%h)
+PKG_RELEASE:=1
+
+PKG_BUILD_PARALLEL:=1
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+TARGET_CFLAGS += $(FPIC)
+
+define Build/Prepare
+       mkdir -p $(PKG_BUILD_DIR)
+       $(CP) $(CURDIR)/../../* $(PKG_BUILD_DIR)/
+endef
+
+define Package/olsrd-stable-git/template
+  SECTION:=net
+  CATEGORY:=Network
+  MAINTAINER:=OLSR Development Team <olsr-dev@lists.olsr.org>
+  TITLE:=OLSR (Optimized Link State Routing) daemon - Stable Branch
+  URL:=http://www.olsr.org/
+endef
+
+define Package/olsrd-stable-git
+  $(call Package/olsrd-stable-git/template)
+  MENU:=1
+  DEPENDS:=+libpthread
+endef
+
+define Package/olsrd-stable-git/conffiles
+/etc/config/olsrd
+endef
+
+define Package/olsrd-stable-git-mod-arprefresh
+  $(call Package/olsrd-stable-git/template)
+  DEPENDS:=olsrd-stable-git
+  TITLE:=Kernel ARP cache refresh plugin
+endef
+
+define Package/olsrd-stable-git-mod-dot-draw
+  $(call Package/olsrd-stable-git/template)
+  DEPENDS:=olsrd-stable-git
+  TITLE:=Dot topology information plugin
+endef
+
+define Package/olsrd-stable-git-mod-bmf
+  $(call Package/olsrd-stable-git/template)
+  DEPENDS:=olsrd-stable-git +kmod-tun
+  TITLE:=Basic multicast forwarding plugin
+endef
+
+define Package/olsrd-stable-git-mod-dyn-gw
+  $(call Package/olsrd-stable-git/template)
+  DEPENDS:=olsrd-stable-git
+  TITLE:=Dynamic internet gateway plugin
+endef
+
+define Package/olsrd-stable-git-mod-dyn-gw-plain
+  $(call Package/olsrd-stable-git/template)
+  DEPENDS:=olsrd-stable-git
+  TITLE:=Dynamic internet gateway plain plugin
+endef
+
+define Package/olsrd-stable-git-mod-httpinfo
+  $(call Package/olsrd-stable-git/template)
+  DEPENDS:=olsrd-stable-git
+  TITLE:=Small informative web server plugin
+endef
+
+define Package/olsrd-stable-git-mod-mdns
+  $(call Package/olsrd-stable-git/template)
+  DEPENDS:=olsrd-stable-git
+  TITLE:=Multicast DNS plugin
+endef
+
+define Package/olsrd-stable-git-mod-nameservice
+  $(call Package/olsrd-stable-git/template)
+  DEPENDS:=olsrd-stable-git
+  TITLE:=Lightweight hostname resolver plugin
+endef
+
+define Package/olsrd-stable-git-mod-p2pd
+  $(call Package/olsrd-stable-git/template)
+  DEPENDS:=olsrd-stable-git
+  TITLE:=Peer to Peer Discovery plugin
+endef
+
+define Package/olsrd-stable-git-mod-quagga
+  $(call Package/olsrd-stable-git/template)
+  DEPENDS:=olsrd-stable-git
+  TITLE:=Quagga plugin
+endef
+
+define Package/olsrd-stable-git-mod-secure
+  $(call Package/olsrd-stable-git/template)
+  DEPENDS:=olsrd-stable-git
+  TITLE:=Message signing plugin to secure routing domain
+endef
+
+define Package/olsrd-stable-git-mod-txtinfo
+  $(call Package/olsrd-stable-git/template)
+  DEPENDS:=olsrd-stable-git
+  TITLE:=Small informative web server plugin
+endef
+
+define Package/olsrd-stable-git-mod-watchdog
+  $(call Package/olsrd-stable-git/template)
+  DEPENDS:=olsrd-stable-git
+  TITLE:=Watchdog plugin
+endef
+
+define Package/olsrd-stable-git-mod-secure/conffiles
+/etc/olsrd.d/olsrd_secure_key
+endef
+
+MAKE_FLAGS+= \
+       NO_DEBUG_MESSAGES=1 \
+       OS="linux" \
+       DESTDIR="$(PKG_INSTALL_DIR)" \
+       STRIP="true" \
+       INSTALL_LIB="true" \
+       SUBDIRS="arprefresh bmf dot_draw dyn_gw dyn_gw_plain httpinfo mdns nameservice quagga secure txtinfo watchdog"
+
+define Build/Compile
+       $(call Build/Compile/Default,all)
+       $(call Build/Compile/Default,libs)
+endef
+
+define Build/Install
+       $(call Build/Install/Default,install)
+       $(call Build/Install/Default,install_libs)
+endef
+
+define Package/olsrd-stable-git/install
+       $(INSTALL_DIR) $(1)/etc/config
+       $(INSTALL_DATA) ./files/olsrd.config $(1)/etc/config/olsrd
+       $(INSTALL_DIR) $(1)/usr/sbin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/olsrd $(1)/usr/sbin/
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/olsrd.init $(1)/etc/init.d/olsrd
+endef
+
+define Package/olsrd-stable-git-mod-arprefresh/install
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/arprefresh/olsrd_arprefresh.so.* $(1)/usr/lib/
+endef
+
+define Package/olsrd-stable-git-mod-dot-draw/install
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/dot_draw/olsrd_dot_draw.so.* $(1)/usr/lib/
+endef
+
+define Package/olsrd-stable-git-mod-bmf/install
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmf/olsrd_bmf.so.* $(1)/usr/lib/
+endef
+
+define Package/olsrd-stable-git-mod-dyn-gw/install
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/dyn_gw/olsrd_dyn_gw.so.* $(1)/usr/lib/
+endef
+
+define Package/olsrd-stable-git-mod-dyn-gw-plain/install
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/dyn_gw_plain/olsrd_dyn_gw_plain.so.* $(1)/usr/lib/
+endef
+
+define Package/olsrd-stable-git-mod-httpinfo/install
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/httpinfo/olsrd_httpinfo.so.* $(1)/usr/lib/
+endef
+
+define Package/olsrd-stable-git-mod-mdns/install
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/mdns/olsrd_mdns.so.* $(1)/usr/lib/
+endef
+
+define Package/olsrd-stable-git-mod-nameservice/install
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/nameservice/olsrd_nameservice.so.* $(1)/usr/lib/
+endef
+
+define Package/olsrd-stable-git-mod-quagga/install
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/quagga/olsrd_quagga.so.* $(1)/usr/lib/
+endef
+
+define Package/olsrd-stable-git-mod-secure/install
+       $(INSTALL_DIR) $(1)/etc/olsrd.d
+       $(CP) ./files/olsrd_secure_key $(1)/etc/olsrd.d/
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/secure/olsrd_secure.so.* $(1)/usr/lib/
+endef
+
+define Package/olsrd-stable-git-mod-txtinfo/install
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/txtinfo/olsrd_txtinfo.so.* $(1)/usr/lib/
+endef
+
+define Package/olsrd-stable-git-mod-watchdog/install
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/watchdog/olsrd_watchdog.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,olsrd-stable-git))
+$(eval $(call BuildPackage,olsrd-stable-git-mod-arprefresh))
+$(eval $(call BuildPackage,olsrd-stable-git-mod-dot-draw))
+$(eval $(call BuildPackage,olsrd-stable-git-mod-bmf))
+$(eval $(call BuildPackage,olsrd-stable-git-mod-dyn-gw))
+$(eval $(call BuildPackage,olsrd-stable-git-mod-dyn-gw-plain))
+$(eval $(call BuildPackage,olsrd-stable-git-mod-httpinfo))
+$(eval $(call BuildPackage,olsrd-stable-git-mod-mdns))
+$(eval $(call BuildPackage,olsrd-stable-git-mod-nameservice))
+$(eval $(call BuildPackage,olsrd-stable-git-mod-quagga))
+$(eval $(call BuildPackage,olsrd-stable-git-mod-secure))
+$(eval $(call BuildPackage,olsrd-stable-git-mod-txtinfo))
+$(eval $(call BuildPackage,olsrd-stable-git-mod-watchdog))
diff --git a/openwrt/olsrd-stable-git/files/olsrd.config b/openwrt/olsrd-stable-git/files/olsrd.config
new file mode 100644 (file)
index 0000000..9a19eb9
--- /dev/null
@@ -0,0 +1,26 @@
+config olsrd
+       # uncomment the following line to use a custom config file instead:
+       #option config_file '/etc/olsrd.conf'
+
+       option IpVersion '4'
+
+config LoadPlugin
+       option library 'olsrd_arprefresh.so.0.1'
+
+config LoadPlugin
+       option library 'olsrd_dyn_gw.so.0.5'
+
+config LoadPlugin
+       option library 'olsrd_httpinfo.so.0.1'
+       option port '1978'
+       list Net '0.0.0.0 0.0.0.0'
+
+config LoadPlugin
+       option library 'olsrd_nameservice.so.0.3'
+
+config LoadPlugin
+       option library 'olsrd_txtinfo.so.0.1'
+       option accept '0.0.0.0'
+
+config Interface
+       list interface 'wlan'
diff --git a/openwrt/olsrd-stable-git/files/olsrd.init b/openwrt/olsrd-stable-git/files/olsrd.init
new file mode 100644 (file)
index 0000000..dd82bb5
--- /dev/null
@@ -0,0 +1,612 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008  Alina Friedrichsen <x-alina@gmx.net>
+# Special thanks to bittorf wireless ))
+START=65
+
+OLSRD_OLSRD_SCHEMA='ignore:internal config_file:internal DebugLevel=0 AllowNoInt=yes'
+OLSRD_IPCCONNECT_SCHEMA='ignore:internal Host:list Net:list2'
+OLSRD_LOADPLUGIN_SCHEMA='ignore:internal library:internal Host4:list Net4:list2 Host:list Net:list2 Host6:list Net6:list2 Ping:list redistribute:list NonOlsrIf:list name:list lat lon latlon_infile HNA:list2 hosts:list2'
+OLSRD_INTERFACE_SCHEMA='ignore:internal interface:internal AutoDetectChanges:bool'
+OLSRD_INTERFACE_DEFAULTS_SCHEMA='AutoDetectChanges:bool'
+
+T='    '
+N='
+'
+
+validate_varname() {
+       local varname="$1"
+       [ -z "$varname" -o "$varname" != "${varname%%[!A-Za-z0-9_]*}" ] && return 1
+       return 0
+}
+
+validate_ifname() {
+       local ifname="$1"
+       [ -z "$ifname" -o "$ifname" != "${ifname%%[!A-Za-z0-9.:_-]*}" ] && return 1
+       return 0
+}
+
+validate_olsrd_option() {
+       local str="$1"
+       [ -z "$str" -o "$str" != "${str%%[!     0-9A-Za-z./|:_-]*}" ] && return 1
+       return 0
+}
+
+get_ifname() {
+       IFNAME=
+       local interface="$1"
+       validate_varname "$interface" || return 1
+       local ifname
+
+       config_get ifname "$interface" ifname
+       validate_ifname "$ifname" || return 1
+       IFNAME="$ifname"
+
+       return 0
+}
+
+system_config() {
+       local cfg="$1"
+       local cfgt
+       local hostname
+       local latlon
+
+       config_get cfgt "$cfg" TYPE
+
+       if [ "$cfgt" = "system" ]; then
+               config_get hostname "$cfg" hostname
+               hostname="${hostname:-OpenWrt}"
+               SYSTEM_HOSTNAME="$hostname"
+       fi
+
+       if [ -z "$SYSTEM_LAT" -o -z "$SYSTEM_LON" ]; then
+               config_get latlon "$cfg" latlon
+               IFS=" ${T}${N},"
+               set -- $latlon
+               unset IFS
+               SYSTEM_LAT="$1"
+               SYSTEM_LON="$2"
+       fi
+
+       if [ -z "$SYSTEM_LAT" -o -z "$SYSTEM_LON" ]; then
+               config_get latlon "$cfg" latitude
+               SYSTEM_LAT="$latlon"
+               config_get latlon "$cfg" longitude
+               SYSTEM_LON="$latlon"
+       fi
+}
+
+olsrd_find_config_file() {
+       local cfg="$1"
+       validate_varname "$cfg" || return 0
+
+       config_get_bool ignore "$cfg" ignore 0
+       [ "$ignore" -ne 0 ] && return 0
+       config_get OLSRD_CONFIG_FILE "$cfg" config_file
+
+       return 0
+}
+
+warning_invalid_value() {
+       local package="$1"
+       validate_varname "$package" || package=
+       local config="$2"
+       validate_varname "$config" || config=
+       local option="$3"
+       validate_varname "$option" || option=
+
+       echo -n "Warning: Invalid value" 1>&2
+
+       if [ -n "$package" -a -n "$config" ]; then
+               echo -n " in option '$package.$config${option:+.}$option'" 1>&2
+       fi
+
+       echo ", skipped" 1>&2
+
+       return 0
+}
+
+olsrd_write_option() {
+       local param="$1"
+       local cfg="$2"
+       validate_varname "$cfg" || return 1
+       local option="$3"
+       validate_varname "$option" || return 1
+       local value="$4"
+       local option_type="$5"
+
+       if [ "$option_type" = bool ]; then
+               case "$value" in
+                       1|on|true|enabled|yes) value=yes;;
+                       0|off|false|disabled|no) value=no;;
+                       *) warning_invalid_value olsrd "$cfg" "$option"; return 1;;
+               esac
+       fi
+
+       if ! validate_olsrd_option "$value"; then
+               warning_invalid_value olsrd "$cfg" "$option"
+               return 1
+       fi
+
+       if [ "$value" != "${value%%[G-Zg-z_-]*}" ]; then
+               if [ "$option" != "Ip6AddrType" -a "$option" != "LinkQualityMult" -a "$value" != "yes" -a "$value" != "no" ]; then
+                       value="\"$value\""
+               fi
+       fi
+
+       echo -n "${N}$param$option $value"
+
+       return 0
+}
+
+olsrd_write_plparam() {
+       local param="$1"
+       local cfg="$2"
+       validate_varname "$cfg" || return 1
+       local option="$3"
+       validate_varname "$option" || return 1
+       local value="$4"
+       local option_type="$5"
+       local _option
+
+       if [ "$option_type" = bool ]; then
+               case "$value" in
+                       1|on|true|enabled|yes) value=yes;;
+                       0|off|false|disabled|no) value=no;;
+                       *) warning_invalid_value olsrd "$cfg" "$option"; return 1;;
+               esac
+       fi
+
+       if ! validate_olsrd_option "$value"; then
+               warning_invalid_value olsrd "$cfg" "$option"
+               return 1
+       fi
+
+       IFS='-_'
+       set -- $option
+       option="$*"
+       unset IFS
+       _option="$option"
+       if [ "$option" = 'hosts' ]; then
+               set -- $value
+               option="$1"
+               shift
+               value="$*"
+       fi
+       if [ "$option" = 'NonOlsrIf' ]; then
+               if validate_varname "$value"; then
+                       if get_ifname "$value"; then
+                               ifname="$IFNAME"
+                               echo "Info: mdns Interface '$value' ifname '$ifname' found" 1>&2
+                       else
+                               echo "Warning: mdns Interface '$value' not found, skipped" 1>&2
+                       fi
+               else
+                       warning_invalid_value olsrd "$cfg" "NonOlsrIf"
+               fi
+               [ -z "$ifname" ] || value=$ifname
+       fi
+
+       echo -n "${N}${param}PlParam \"$option\" \"$value\""
+
+       return 0
+}
+
+config_update_schema() {
+       unset IFS
+       local schema_varname="$1"
+       validate_varname "$schema_varname" || return 1
+       local command="$2"
+       validate_varname "$command" || return 1
+       local option="$3"
+       validate_varname "$option" || return 1
+       local value="$4"
+       local schema
+       local cur_option
+
+       case "$varname" in
+               *_LENGTH) return 0;;
+               *_ITEM*) return 0;;
+       esac
+
+       eval "export -n -- \"schema=\${$schema_varname}\""
+
+       for cur_option in $schema; do
+               [ "${cur_option%%[:=]*}" = "$option" ] && return 0
+       done
+
+       if [ "$command" = list ]; then
+               set -- $value
+               if [ "$#" -ge "3" ]; then
+                       schema_entry="$option:list3"
+               elif [ "$#" -ge "2" ]; then
+                       schema_entry="$option:list2"
+               else
+                       schema_entry="$option:list"
+               fi
+       else
+               schema_entry="$option"
+       fi
+
+       append "$schema_varname" "$schema_entry"
+
+       return 0
+}
+
+config_write_options() {
+       unset IFS
+       local schema="$1"
+       local cfg="$2"
+       validate_varname "$cfg" || return 1
+       local write_func="$3"
+       [ -z "$write_func" ] && output_func=echo
+       local write_param="$4"
+       local schema_entry
+       local option
+       local option_length
+       local option_type
+       local default
+       local value
+       local list_size
+       local list_item
+       local list_value
+       local i
+       local position
+
+       for schema_entry in $schema; do
+               default="${schema_entry#*[=]}"
+               [ "$default" = "$schema_entry" ] && default=
+               option="${schema_entry%%[=]*}"
+               IFS=':'
+               set -- $option
+               unset IFS
+               option="$1"
+               option_type="$2"
+               validate_varname "$option" || continue
+               [ -z "$option_type" ] || validate_varname "$option_type" || continue
+               [ "$option_type" = internal ] && continue
+               config_get value "$cfg" "$option"
+
+               if [ -z "$value" ]; then
+                       IFS='+'
+                       set -- $default
+                       unset IFS
+                       value=$*
+               elif [ "$value" = '-' -a -n "$default" ]; then
+                       continue
+               fi
+
+               [ -z "$value" ] && continue
+
+               case "$option_type" in
+                       list) list_size=1;;
+                       list2) list_size=2;;
+                       list3) list_size=3;;
+                       *) list_size=0;;
+               esac
+
+               if [ "$list_size" -gt 0 ]; then
+                       config_get option_length "$cfg" "${option}_LENGTH"
+                       if [ -n "$option_length" ]; then
+                               i=1
+                               while [ "$i" -le "$option_length" ]; do
+                                       config_get list_value "$cfg" "${option}_ITEM$i"
+                                       "$write_func" "$write_param" "$cfg" "$option" "$list_value" "$option_type" || break
+                                       i=$((i + 1))
+                               done
+                       else
+                               list_value=
+                               i=0
+                               for list_item in $value; do
+                                       append "list_value" "$list_item"
+                                       i=$((i + 1))
+                                       position=$((i % list_size))
+                                       if [ "$position" -eq 0 ]; then
+                                               "$write_func" "$write_param" "$cfg" "$option" "$list_value" "$option_type" || break
+                                               list_value=
+                                       fi
+                               done
+                               [ "$position" -ne 0 ] && "$write_func" "$write_param" "$cfg" "$option" "$list_value" "$option_type"
+                       fi
+               else
+                       "$write_func" "$write_param" "$cfg" "$option" "$value" "$option_type"
+               fi
+       done
+
+       return 0
+}
+
+olsrd_write_olsrd() {
+       local cfg="$1"
+       validate_varname "$cfg" || return 0
+       local ignore
+       local ipversion
+
+       config_get_bool ignore "$cfg" ignore 0
+       [ "$ignore" -ne 0 ] && return 0
+
+       [ "$OLSRD_COUNT" -gt 0 ] && return 0
+
+       config_get ipversion "$cfg" IpVersion
+       if [ "$ipversion" = "6and4" ]; then
+               OLSRD_IPVERSION_6AND4=1
+               config_set "$cfg" IpVersion '6'
+       fi
+
+       config_write_options "$OLSRD_OLSRD_SCHEMA" "$cfg" olsrd_write_option
+       echo
+       OLSRD_COUNT=$((OLSRD_COUNT + 1))
+
+       return 0
+}
+
+olsrd_write_ipcconnect() {
+       local cfg="$1"
+       validate_varname "$cfg" || return 0
+       local ignore
+
+       config_get_bool ignore "$cfg" ignore 0
+       [ "$ignore" -ne 0 ] && return 0
+
+       [ "$IPCCONNECT_COUNT" -gt 0 ] && return 0
+
+       echo -n "${N}IpcConnect${N}{"
+       config_write_options "$OLSRD_IPCCONNECT_SCHEMA" "$cfg" olsrd_write_option "${T}"
+       echo "${N}}"
+       IPCCONNECT_COUNT=$((IPCCONNECT_COUNT + 1))
+
+       return 0
+}
+
+olsrd_write_hna4() {
+       local cfg="$1"
+       validate_varname "$cfg" || return 0
+       local ignore
+
+       config_get_bool ignore "$cfg" ignore 0
+       [ "$ignore" -ne 0 ] && return 0
+
+       config_get netaddr "$cfg" netaddr
+       if ! validate_olsrd_option "$netaddr"; then
+               warning_invalid_value olsrd "$cfg" "netaddr"
+               return 0
+       fi
+
+       config_get netmask "$cfg" netmask
+       if ! validate_olsrd_option "$netmask"; then
+               warning_invalid_value olsrd "$cfg" "netmask"
+               return 0
+       fi
+
+       [ "$HNA4_COUNT" -le 0 ] && echo -n "${N}Hna4${N}{"
+       echo -n "${N}${T}${T}$netaddr $netmask"
+       HNA4_COUNT=$((HNA4_COUNT + 1))
+
+       return 0
+}
+
+olsrd_write_hna6() {
+       local cfg="$1"
+       validate_varname "$cfg" || return 0
+       local ignore
+
+       config_get_bool ignore "$cfg" ignore 0
+       [ "$ignore" -ne 0 ] && return 0
+
+       config_get netaddr "$cfg" netaddr
+       if ! validate_olsrd_option "$netaddr"; then
+               warning_invalid_value olsrd "$cfg" "netaddr"
+               return 0
+       fi
+
+       config_get prefix "$cfg" prefix
+       if ! validate_olsrd_option "$prefix"; then
+               warning_invalid_value olsrd "$cfg" "prefix"
+               return 0
+       fi
+
+       [ "$HNA6_COUNT" -le 0 ] && echo -n "${N}Hna6${N}{"
+       echo -n "${N}${T}${T}$netaddr $prefix"
+       HNA6_COUNT=$((HNA6_COUNT + 1))
+
+       return 0
+}
+
+olsrd_write_loadplugin() {
+       local cfg="$1"
+       validate_varname "$cfg" || return 0
+       local ignore
+       local name
+       local suffix
+       local lat
+       local lon
+       local latlon_infile
+
+       config_get_bool ignore "$cfg" ignore 0
+       [ "$ignore" -ne 0 ] && return 0
+
+       config_get library "$cfg" library
+       if ! validate_olsrd_option "$library"; then
+               warning_invalid_value olsrd "$cfg" "library"
+               return 0
+       fi
+       if ! [ -x "/lib/$library" -o -x "/usr/lib/$library" -o -x "/usr/local/lib/$library" ]; then
+               echo "Warning: Plugin library '$library' not found, skipped" 1>&2
+               return 0
+       fi
+
+       case "$library" in
+               olsrd_nameservice.*)
+                       config_get name "$cfg" name
+                       [ -z "$name" ] && config_set "$cfg" name $SYSTEM_HOSTNAME
+
+                       config_get suffix "$cfg" suffix
+                       [ -z "$suffix" ] && config_set "$cfg" suffix '.olsr'
+
+                       config_get lat "$cfg" lat
+                       config_get lon "$cfg" lon
+                       config_get latlon_infile "$cfg" latlon_infile
+                       if [ \( -z "$lat" -o -z "$lat" \) -a -z "$latlon_infile" ]; then
+                               if [ -f '/var/run/latlon.txt' ]; then
+                                       config_set "$cfg" lat ''
+                                       config_set "$cfg" lon ''
+                                       config_set "$cfg" latlon_infile '/var/run/latlon.txt'
+                               else
+                                       config_set "$cfg" lat "$SYSTEM_LAT"
+                                       config_set "$cfg" lon "$SYSTEM_LON"
+                               fi
+                       fi
+
+                       config_get latlon_file "$cfg" latlon_file
+                       [ -z "$latlon_file" ] && config_set "$cfg" latlon_file '/var/run/latlon.js'
+               ;;
+       esac
+
+       echo -n "${N}LoadPlugin \"$library\"${N}{"
+       config_write_options "$OLSRD_LOADPLUGIN_SCHEMA" "$cfg" olsrd_write_plparam "${T}"
+       echo "${N}}"
+
+       return 0
+}
+
+olsrd_write_interface() {
+       local cfg="$1"
+       validate_varname "$cfg" || return 0
+       local ignore
+       local interfaces
+       local interface
+       local ifnames
+
+       config_get_bool ignore "$cfg" ignore 0
+       [ "$ignore" -ne 0 ] && return 0
+
+       ifnames=
+       config_get interfaces "$cfg" interface
+       for interface in $interfaces; do
+               if validate_varname "$interface"; then
+                       if get_ifname "$interface"; then
+                               ifnames="$ifnames \"$IFNAME\""
+                       else
+                               echo "Warning: Interface '$interface' not found, skipped" 1>&2
+                       fi
+               else
+                       warning_invalid_value olsrd "$cfg" "interface"
+               fi
+       done
+
+       [ -z "$ifnames" ] && return 0
+
+       echo -n "${N}Interface$ifnames${N}{"
+       config_write_options "$OLSRD_INTERFACE_SCHEMA" "$cfg" olsrd_write_option "${T}"
+       echo "${N}}"
+       INTERFACES_COUNT=$((INTERFACES_COUNT + 1))
+
+       return 0
+}
+
+olsrd_write_interface_defaults() {
+       local cfg="$1"
+       validate_varname "$cfg" || return 0
+
+       echo -n "${N}InterfaceDefaults$ifnames${N}{"
+       config_write_options "$OLSRD_INTERFACE_DEFAULTS_SCHEMA" "$cfg" olsrd_write_option "${T}"
+       echo "${N}}"
+
+       return 1
+}
+
+olsrd_update_schema() {
+       local command="$1"
+       validate_varname "$command" || return 0
+       local varname="$2"
+       validate_varname "$varname" || return 0
+       local value="$3"
+       local cfg="$CONFIG_SECTION"
+       local cfgt
+       local cur_varname
+
+       config_get cfgt "$cfg" TYPE
+       case "$cfgt" in
+               olsrd) config_update_schema OLSRD_OLSRD_SCHEMA "$command" "$varname" "$value";;
+               IpcConnect) config_update_schema OLSRD_IPCCONNECT_SCHEMA "$command" "$varname" "$value";;
+               LoadPlugin) config_update_schema OLSRD_LOADPLUGIN_SCHEMA "$command" "$varname" "$value";;
+               Interface) config_update_schema OLSRD_INTERFACE_SCHEMA "$command" "$varname" "$value";;
+               InterfaceDefaults) config_update_schema OLSRD_INTERFACE_DEFAULTS_SCHEMA "$command" "$varname" "$value";;
+       esac
+
+       return 0
+}
+
+olsrd_write_config() {
+       OLSRD_IPVERSION_6AND4=0
+       OLSRD_COUNT=0
+       config_foreach olsrd_write_olsrd olsrd
+       IPCCONNECT_COUNT=0
+       config_foreach olsrd_write_ipcconnect IpcConnect
+       HNA4_COUNT=0
+       config_foreach olsrd_write_hna4 Hna4
+       [ "$HNA4_COUNT" -gt 0 ] && echo "${N}}"
+       HNA6_COUNT=0
+       config_foreach olsrd_write_hna6 Hna6
+       [ "$HNA6_COUNT" -gt 0 ] && echo "${N}}"
+       config_foreach olsrd_write_loadplugin LoadPlugin
+       INTERFACES_COUNT=0
+       config_foreach olsrd_write_interface_defaults InterfaceDefaults
+       config_foreach olsrd_write_interface Interface
+       echo
+
+       return 0
+}
+
+start() {
+       SYSTEM_HOSTNAME=
+       SYSTEM_LAT=
+       SYSTEM_LON=
+       config_load system
+       config_foreach system_config system
+
+       option_cb() {
+               olsrd_update_schema "option" "$@"
+       }
+
+       list_cb() {
+               olsrd_update_schema "list" "$@"
+       }
+
+       include /lib/network
+       scan_interfaces
+       config_load olsrd
+       reset_cb
+
+       OLSRD_CONFIG_FILE=
+       config_foreach olsrd_find_config_file olsrd
+
+       if [ -z "$OLSRD_CONFIG_FILE" ]; then
+               mkdir -p -- /var/etc/
+               olsrd_write_config > /var/etc/olsrd.conf
+               if [ "$INTERFACES_COUNT" -gt 0 -a "$OLSRD_COUNT" -gt 0 ]; then
+                       OLSRD_CONFIG_FILE=/var/etc/olsrd.conf
+               fi
+       fi
+
+       [ -z "$OLSRD_CONFIG_FILE" ] && return 1
+
+       local bindv6only='0'
+       if [ "$OLSRD_IPVERSION_6AND4" -ne 0 ]; then
+               bindv6only="$(sysctl -n net.ipv6.bindv6only)"
+               sysctl -w net.ipv6.bindv6only=1
+               sed -e 's/^\t\t[0-9.]*[ ][0-9.]*$//' < "$OLSRD_CONFIG_FILE" > /var/etc/olsrd.conf.ipv6
+               sed -i '/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/d' /var/etc/olsrd.conf.ipv6
+               olsrd -f /var/etc/olsrd.conf.ipv6 -nofork < /dev/null > /dev/null &
+
+               sed -e 's/^IpVersion[ ][ ]*6$/IpVersion 4/' -e 's/^\t\t[A-Fa-f0-9.:]*[:][A-Fa-f0-9.:]*[ ][0-9]*$//' < "$OLSRD_CONFIG_FILE" > /var/etc/olsrd.conf.ipv4
+               olsrd -f /var/etc/olsrd.conf.ipv4 -nofork < /dev/null > /dev/null &
+               sleep 3
+               sysctl -w net.ipv6.bindv6only="$bindv6only"
+       else
+               olsrd -f "$OLSRD_CONFIG_FILE" -nofork < /dev/null > /dev/null &
+       fi
+}
+
+stop() {
+       killall olsrd
+}
diff --git a/openwrt/olsrd-stable-git/files/olsrd_secure_key b/openwrt/olsrd-stable-git/files/olsrd_secure_key
new file mode 100644 (file)
index 0000000..4a7d725
--- /dev/null
@@ -0,0 +1 @@
+1234567890123456
\ No newline at end of file