summaryrefslogtreecommitdiffhomepage
path: root/contrib/package/olsrd-luci
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/package/olsrd-luci')
-rw-r--r--contrib/package/olsrd-luci/Makefile226
-rw-r--r--contrib/package/olsrd-luci/files/etc/config/olsrd21
-rw-r--r--contrib/package/olsrd-luci/files/etc/default/olsrd8
-rwxr-xr-xcontrib/package/olsrd-luci/files/etc/init.d/olsrd581
-rwxr-xr-xcontrib/package/olsrd-luci/ipkg/postinst6
-rw-r--r--contrib/package/olsrd-luci/patches/131-olsrd-tweak-ffetx.patch13
-rw-r--r--contrib/package/olsrd-luci/patches/137-olsrd-192.168.1.1.patch11
-rw-r--r--contrib/package/olsrd-luci/patches/139-olsrd-magicarprefresh.patch44
-rw-r--r--contrib/package/olsrd-luci/patches/140-olsrd-optimize-size.patch1909
-rw-r--r--contrib/package/olsrd-luci/patches/160-add-mdns.patch4408
-rw-r--r--contrib/package/olsrd-luci/patches/170-fcntl-fix.patch10
-rw-r--r--contrib/package/olsrd-luci/patches/200-mid_memory_cleanup.patch256
12 files changed, 0 insertions, 7493 deletions
diff --git a/contrib/package/olsrd-luci/Makefile b/contrib/package/olsrd-luci/Makefile
deleted file mode 100644
index 766bb606b3..0000000000
--- a/contrib/package/olsrd-luci/Makefile
+++ /dev/null
@@ -1,226 +0,0 @@
-#
-# Copyright (C) 2008-2009 Freifunk Leipzig
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-# $Id$
-#
-
-include $(TOPDIR)/rules.mk
-
-PKG_BASENAME:=olsrd
-PKG_NAME:=$(PKG_BASENAME)-luci
-PKG_BASEVER:=0.5.6-r7
-PKG_RELEASE:=2
-
-#PKG_HGREV:=438bd63a1ab8
-#PKG_SOURCE:=$(PKG_HGREV).tar.gz
-#PKG_SOURCE_URL:=http://gredler.at/hg/olsrd-0.5.6/archive
-#PKG_MD5SUM:=18cfb6afd823daa29dee8375223201d2
-#PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_HGREV)
-#PKG_UNPACK=$(HOST_TAR) -C $(PKG_BUILD_DIR) --strip-components=1 -xzf $(DL_DIR)/$(PKG_SOURCE)
-#PKG_VERSION:=$(PKG_BASEVER)+$(PKG_HGREV)+luci1
-
-PKG_SOURCE:=$(PKG_BASENAME)-$(PKG_BASEVER).tar.bz2
-PKG_SOURCE_URL:=http://www.olsr.org/releases/0.5
-PKG_MD5SUM:=dde8cb45a10f0cad2010ab2e8ad55146
-PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_BASEVER)
-PKG_UNPACK=$(HOST_TAR) -C $(PKG_BUILD_DIR) --strip-components=1 -xjf $(DL_DIR)/$(PKG_SOURCE)
-PKG_VERSION:=$(PKG_BASEVER)+luci1
-
-include $(INCLUDE_DIR)/package.mk
-
-
-define Package/olsrd-luci/common_info
- SECTION:=luci
- CATEGORY:=LuCI
- SUBMENU:=Freifunk
- TITLE:=OLSR - Optimized Link State Routing Daemon
- URL:=http://www.olsr.org/
- MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
-endef
-
-define Package/olsrd-luci
- $(call Package/olsrd-luci/common_info)
- MENU:=1
- DEPENDS:=+libpthread
-endef
-
-define Package/olsrd-luci/conffiles
-/etc/config/olsrd
-endef
-
-define Package/olsrd-luci-mod-arprefresh
- $(call Package/olsrd-luci/common_info)
- TITLE:=OLSR - ARP Refresh Plugin
- DEPENDS:=olsrd-luci
-endef
-
-define Package/olsrd-luci-mod-dot-draw
- $(call Package/olsrd-luci/common_info)
- TITLE:=OLSR - Dot Draw Plugin
- DEPENDS:=olsrd-luci
-endef
-
-define Package/olsrd-luci-mod-bmf
- $(call Package/olsrd-luci/common_info)
- TITLE:=OLSR - Basic Multicast Forwarding Plugin
- DEPENDS:=olsrd-luci +kmod-tun
-endef
-
-define Package/olsrd-luci-mod-dyn-gw
- $(call Package/olsrd-luci/common_info)
- TITLE:=OLSR - Dynamic Gateway Plugin
- DEPENDS:=olsrd-luci
-endef
-
-define Package/olsrd-luci-mod-dyn-gw-plain
- $(call Package/olsrd-luci/common_info)
- TITLE:=OLSR - Dynamic Gateway Plugin (Plain Version)
- DEPENDS:=olsrd-luci
-endef
-
-define Package/olsrd-luci-mod-httpinfo
- $(call Package/olsrd-luci/common_info)
- TITLE:=OLSR - HTTP/HTML Info Plugin
- DEPENDS:=olsrd-luci
-endef
-
-define Package/olsrd-luci-mod-nameservice
- $(call Package/olsrd-luci/common_info)
- TITLE:=OLSR - Hostname Propagation Plugin
- DEPENDS:=olsrd-luci
-endef
-
-define Package/olsrd-luci-mod-secure
- $(call Package/olsrd-luci/common_info)
- TITLE:=OLSR - Security Extensions Plugin
- DEPENDS:=olsrd-luci
-endef
-
-define Package/olsrd-luci-mod-txtinfo
- $(call Package/olsrd-luci/common_info)
- TITLE:=OLSR - HTTP/Plaintext Info Plugin
- DEPENDS:=olsrd-luci
-endef
-
-define Package/olsrd-luci-mod-quagga
- $(call Package/olsrd-luci/common_info)
- TITLE:=OLSR - Quagga Plugin
- DEPENDS:=olsrd-luci
-endef
-
-define Package/olsrd-luci-mod-watchdog
- $(call Package/olsrd-luci/common_info)
- TITLE:=OLSR - Watchdog Plugin
- DEPENDS:=olsrd-luci
-endef
-
-define Package/olsrd-luci-mod-mdns
- $(call Package/olsrd-luci/common_info)
- TITLE:=OLSR - mDNS Plugin
- DEPENDS:=olsrd-luci
-endef
-
-TARGET_CFLAGS += $(FPIC)
-
-define Build/Compile
- $(MAKE) -C "$(PKG_BUILD_DIR)" olsrd libs \
- $(TARGET_CONFIGURE_OPTS) \
- NODEBUG=1 \
- CFLAGS="$(TARGET_CFLAGS) -DSVEN_OLA_UNBLOAT -DNODEBUG" \
- OS="linux" \
- INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
- LIBDIR="$(PKG_INSTALL_DIR)/usr/lib" \
- SBINDIR="$(PKG_INSTALL_DIR)/usr/sbin/" \
- ETCDIR="$(PKG_INSTALL_DIR)/etc" \
- MANDIR="$(PKG_INSTALL_DIR)/usr/share/man" \
- STRIP="true" \
- INSTALL_LIB="true" \
- SUBDIRS="arprefresh bmf dot_draw dyn_gw dyn_gw_plain httpinfo nameservice secure txtinfo quagga watchdog mdns"
-endef
-
-define Package/olsrd-luci/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_DIR) $(1)/etc/config
- $(INSTALL_DIR) $(1)/etc/init.d
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/olsrd $(1)/usr/sbin/
- $(INSTALL_BIN) ./files/etc/init.d/olsrd $(1)/etc/init.d/
- $(INSTALL_CONF) ./files/etc/config/olsrd $(1)/etc/config/
-endef
-
-define Package/olsrd-luci-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-luci-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-luci-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-luci-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-luci-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-luci-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-luci-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-luci-mod-secure/install
- $(INSTALL_DIR) $(1)/usr/lib
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/secure/olsrd_secure.so.* $(1)/usr/lib/
-endef
-
-define Package/olsrd-luci-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-luci-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-luci-mod-watchdog/install
- $(INSTALL_DIR) $(1)/usr/lib
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/watchdog/olsrd_watchdog.so.* $(1)/usr/lib/
-endef
-
-define Package/olsrd-luci-mod-mdns/install
- $(INSTALL_DIR) $(1)/usr/lib
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/mdns/olsrd_mdns.so.* $(1)/usr/lib/
-endef
-
-
-$(eval $(call BuildPackage,olsrd-luci))
-$(eval $(call BuildPackage,olsrd-luci-mod-arprefresh))
-$(eval $(call BuildPackage,olsrd-luci-mod-dot-draw))
-$(eval $(call BuildPackage,olsrd-luci-mod-bmf))
-$(eval $(call BuildPackage,olsrd-luci-mod-dyn-gw))
-$(eval $(call BuildPackage,olsrd-luci-mod-dyn-gw-plain))
-$(eval $(call BuildPackage,olsrd-luci-mod-httpinfo))
-$(eval $(call BuildPackage,olsrd-luci-mod-nameservice))
-$(eval $(call BuildPackage,olsrd-luci-mod-secure))
-$(eval $(call BuildPackage,olsrd-luci-mod-txtinfo))
-$(eval $(call BuildPackage,olsrd-luci-mod-quagga))
-$(eval $(call BuildPackage,olsrd-luci-mod-watchdog))
-$(eval $(call BuildPackage,olsrd-luci-mod-mdns))
diff --git a/contrib/package/olsrd-luci/files/etc/config/olsrd b/contrib/package/olsrd-luci/files/etc/config/olsrd
deleted file mode 100644
index 5e490c3403..0000000000
--- a/contrib/package/olsrd-luci/files/etc/config/olsrd
+++ /dev/null
@@ -1,21 +0,0 @@
-config 'olsrd'
- option 'IpVersion' '4'
- option 'FIBMetric' 'flat'
- option 'LinkQualityAlgorithm' 'etx_ff'
- option 'NatThreshold' '0.75'
-
-config 'Interface'
- option 'ignore' '1'
- option 'interface' 'ff'
-
-config 'LoadPlugin'
- option 'library' 'olsrd_dyn_gw_plain.so.0.4'
-
-config 'LoadPlugin'
- option 'library' 'olsrd_nameservice.so.0.3'
- option 'suffix' '.olsr'
- option 'hosts_file' '/var/etc/hosts.olsr'
-
-config 'LoadPlugin'
- option 'library' 'olsrd_txtinfo.so.0.1'
- option 'accept' '127.0.0.1'
diff --git a/contrib/package/olsrd-luci/files/etc/default/olsrd b/contrib/package/olsrd-luci/files/etc/default/olsrd
deleted file mode 100644
index d89e007bd4..0000000000
--- a/contrib/package/olsrd-luci/files/etc/default/olsrd
+++ /dev/null
@@ -1,8 +0,0 @@
-# you can override olsrd's startup variables here
-#BIN=/usr/sbin/olsrd
-#CONF=/var/etc/olsrd.conf
-#PID=/var/run/olsrd.pid
-
-# place your custom olsrd parameters here
-OPTIONS=
-
diff --git a/contrib/package/olsrd-luci/files/etc/init.d/olsrd b/contrib/package/olsrd-luci/files/etc/init.d/olsrd
deleted file mode 100755
index 875800e75c..0000000000
--- a/contrib/package/olsrd-luci/files/etc/init.d/olsrd
+++ /dev/null
@@ -1,581 +0,0 @@
-#!/bin/sh /etc/rc.common
-# Copyright (C) 2008 Alina Friedrichsen <x-alina@gmx.net>
-# Special thanks to bittorf wireless ))
-START=50
-
-BIN=/usr/sbin/olsrd
-CONF=/var/etc/olsrd.conf
-PID=/var/run/olsrd.pid
-
-OLSRD_OLSRD_SCHEMA='ignore:internal config_file:internal DebugLevel=0 IpVersion=4 AllowNoInt:bool=1 Pollrate=0.025 TcRedundancy=2 MprCoverage=3 LinkQualityFishEye=1 LinkQualityDijkstraLimit=0+9.0 FIBMetric=flat ClearScreen:bool=1 Willingness=3 LinkQualityAging=0.1 LinkQualityAlgorithm=etx_fpm MinTCVTime=500.0'
-OLSRD_IPCCONNECT_SCHEMA='ignore:internal Host:list Net:list2'
-OLSRD_LOADPLUGIN_SCHEMA='ignore:internal library:internal Host:list Net: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 Ip4Broadcast HelloInterval=5.0 HelloValidityTime=40.0 TcInterval=2.0 TcValidityTime=256.0 MidInterval=18.0 MidValidityTime=324.0 HnaInterval=18.0 HnaValidityTime=108.0'
-
-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
-}
-
-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 "$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
-
- 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
-
- config_get_bool ignore "$cfg" ignore 0
- [ "$ignore" -ne 0 ] && return 0
-
- [ "$OLSRD_COUNT" -gt 0 ] && return 0
-
- 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}$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}$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
- ;;
- 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_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";;
- esac
-
- return 0
-}
-
-olsrd_write_config() {
- 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 Interface
- echo
-
- return 0
-}
-
-start() {
- ### check for running instance
- if [ -s $PID ]; then
- if kill -0 $(cat $PID) 2>&-; then
- echo "there is already a running instance ($(cat $PID))"
- return 1
- fi
- fi
-
- ### disable icmp redirects
- echo 0 > /proc/sys/net/ipv4/conf/all/send_redirects
-
- 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
- ### generate config
- mkdir -p ${CONF%/*}
- olsrd_write_config > $CONF
- if [ "$INTERFACES_COUNT" -gt 0 -a "$OLSRD_COUNT" -gt 0 ]; then
- OLSRD_CONFIG_FILE=$CONF
- fi
- fi
-
- [ -z "$OLSRD_CONFIG_FILE" ] && return 1
-
- ### start olsrd
- start-stop-daemon -q -b -m -p $PID -x $BIN -S -- -f $CONF -nofork
-}
-
-stop() {
- ### stop olsrd
- start-stop-daemon -q -p $PID -x $BIN -K
-
- ### re-enable icmp redirects
- echo 1 > /proc/sys/net/ipv4/conf/all/send_redirects
-}
-
-restart() {
- ### override generic restart because we need some time between stop and start
- stop; sleep 3; start
-}
diff --git a/contrib/package/olsrd-luci/ipkg/postinst b/contrib/package/olsrd-luci/ipkg/postinst
deleted file mode 100755
index 26156a6933..0000000000
--- a/contrib/package/olsrd-luci/ipkg/postinst
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-[ -n "${IPKG_INSTROOT}" ] || {
- /etc/init.d/olsrd enabled || /etc/init.d/olsrd enable
- exit 0
-}
diff --git a/contrib/package/olsrd-luci/patches/131-olsrd-tweak-ffetx.patch b/contrib/package/olsrd-luci/patches/131-olsrd-tweak-ffetx.patch
deleted file mode 100644
index 853a14fe7d..0000000000
--- a/contrib/package/olsrd-luci/patches/131-olsrd-tweak-ffetx.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff -Nur olsrd-0.5.6-r2.orig/src/lq_plugin_default_ff.h olsrd-0.5.6-r2/src/lq_plugin_default_ff.h
---- olsrd-0.5.6-r2.orig/src/lq_plugin_default_ff.h 2008-11-26 10:53:16.000000000 +0100
-+++ olsrd-0.5.6-r2/src/lq_plugin_default_ff.h 2008-11-26 10:53:16.000000000 +0100
-@@ -50,7 +50,8 @@
-
- #define LQ_ALGORITHM_ETX_FF_NAME "etx_ff"
-
--#define LQ_FF_WINDOW 32
-+/* 16,32,64 and max. 128 */
-+#define LQ_FF_WINDOW 64
- #define LQ_FF_QUICKSTART_INIT 4
-
- struct default_lq_ff {
diff --git a/contrib/package/olsrd-luci/patches/137-olsrd-192.168.1.1.patch b/contrib/package/olsrd-luci/patches/137-olsrd-192.168.1.1.patch
deleted file mode 100644
index 33a916b2f6..0000000000
--- a/contrib/package/olsrd-luci/patches/137-olsrd-192.168.1.1.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-diff -Nur olsrd-0.5.6-r2.orig/src/net_olsr.c olsrd-0.5.6-r2/src/net_olsr.c
---- olsrd-0.5.6-r2.orig/src/net_olsr.c 2008-11-26 10:53:53.000000000 +0100
-+++ olsrd-0.5.6-r2/src/net_olsr.c 2008-11-26 10:53:53.000000000 +0100
-@@ -78,6 +78,7 @@
- static const char *const deny_ipv4_defaults[] = {
- "0.0.0.0",
- "127.0.0.1",
-+ "192.168.1.1",
- NULL
- };
-
diff --git a/contrib/package/olsrd-luci/patches/139-olsrd-magicarprefresh.patch b/contrib/package/olsrd-luci/patches/139-olsrd-magicarprefresh.patch
deleted file mode 100644
index 8d231dfec3..0000000000
--- a/contrib/package/olsrd-luci/patches/139-olsrd-magicarprefresh.patch
+++ /dev/null
@@ -1,44 +0,0 @@
---- a/lib/arprefresh/src/olsrd_arprefresh.c
-+++ b/lib/arprefresh/src/olsrd_arprefresh.c
-@@ -34,6 +34,8 @@
- * Plugin to refresh the local ARP cache from received OLSR broadcasts
- */
-
-+#undef ARPREFRESH_DEBUG
-+
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
-@@ -46,6 +48,9 @@
- #include <netinet/ip.h>
- #include <netinet/udp.h>
- #include <netpacket/packet.h>
-+#ifdef ARPREFRESH_DEBUG
-+#include <arpa/inet.h>
-+#endif
- #include <linux/types.h>
- #include <linux/filter.h>
- #include <unistd.h>
-@@ -54,7 +59,6 @@
- #include "kernel_routes.h"
- #include "scheduler.h"
-
--#undef ARPREFRESH_DEBUG
- #define PLUGIN_INTERFACE_VERSION 5
-
- /****************************************************************************
-@@ -129,7 +133,13 @@
- memcpy(&req.in_pa.sin_addr, &buf.ip.saddr, sizeof(buf.ip.saddr));
- req.arp.arp_ha.sa_family = AF_LOCAL;
- memcpy(&req.arp.arp_ha.sa_data, &buf.eth.h_source, sizeof(buf.eth.h_source));
-- req.arp.arp_flags = ATF_COM;
-+ /*
-+ * Currently, temp arp entries work partially under linux-2.6 (the entries
-+ * are timed out after a short period, not after the default 5 minutes. Under
-+ * linux 2.4 this does not work. The ATF_MAGIC triggers a hack in the Freifunk
-+ * firmware's kernel. ATF_MACIG seem not to be used anywhere...
-+ */
-+ req.arp.arp_flags = ATF_COM | ATF_MAGIC;
- if_indextoname(from.sll_ifindex, req.arp.arp_dev);
- #ifdef ARPREFRESH_DEBUG
- {
diff --git a/contrib/package/olsrd-luci/patches/140-olsrd-optimize-size.patch b/contrib/package/olsrd-luci/patches/140-olsrd-optimize-size.patch
deleted file mode 100644
index 3c3dabd9ba..0000000000
--- a/contrib/package/olsrd-luci/patches/140-olsrd-optimize-size.patch
+++ /dev/null
@@ -1,1909 +0,0 @@
---- a/Makefile.inc
-+++ b/Makefile.inc
-@@ -207,6 +207,10 @@
- $(warning Use CPPFLAGS instead of DEFINES for -D)
- endif
-
-+ifeq ($(SVEN_OLA_UNBLOAT),1)
-+CPPFLAGS += -DSVEN_OLA_UNBLOAT -DNODEBUG
-+endif
-+
- TAGFILE ?= src/TAGS
-
- help:
---- a/lib/bmf/src/NetworkInterfaces.c
-+++ b/lib/bmf/src/NetworkInterfaces.c
-@@ -541,7 +541,9 @@
- OLSR_PRINTF(9, "%s: ----> Not forwarding to %s: no link found\n", PLUGIN_NAME_SHORT,
- olsr_ip_to_string(&buf, &walker->neighbor_iface_addr));
- } else {
-+#ifndef DEBUG
- struct interface *bestIntf = if_ifwithaddr(&bestLinkToNeighbor->local_iface_addr);
-+#endif
-
- OLSR_PRINTF(9, "%s: ----> Not forwarding to %s: \"%s\" gives a better link to this neighbor, costing %5.2f\n",
- PLUGIN_NAME_SHORT, olsr_ip_to_string(&buf, &walker->neighbor_iface_addr), bestIntf->int_name,
---- a/lib/httpinfo/Makefile
-+++ b/lib/httpinfo/Makefile
-@@ -47,7 +47,11 @@
- CPPFLAGS += -DADMIN_INTERFACE
- endif
-
-+ifdef SVEN_OLA_UNBLOAT
-+ CFLAGS += -DSVEN_OLA
-+else
- OBJS += $(TOPDIR)/src/cfgparser/cfgfile_gen.o
-+endif
-
- default_target: $(PLUGIN_FULLNAME)
- ifdef ADMIN_INTERFACE
---- a/lib/httpinfo/src/olsrd_httpinfo.c
-+++ b/lib/httpinfo/src/olsrd_httpinfo.c
-@@ -67,7 +67,9 @@
-
- #include "olsrd_httpinfo.h"
- #include "admin_interface.h"
-+#ifndef SVEN_OLA_UNBLOAT
- #include "gfx.h"
-+#endif /* SVEN_OLA_UNBLOAT */
-
- #ifdef OS
- #undef OS
-@@ -222,10 +224,13 @@
- {"Admin", "admin", build_admin_body, true},
- #endif
- {"About", "about", build_about_body, true},
-+#ifndef SVEN_OLA_UNBLOAT
- {"FOO", "cfgfile", build_cfgfile_body, false},
-+#endif /* SVEN_OLA_UNBLOAT */
- {NULL, NULL, NULL, false}
- };
-
-+#ifndef SVEN_OLA_UNBLOAT
- static const struct static_bin_file_entry static_bin_files[] = {
- {"favicon.ico", favicon_ico, sizeof(favicon_ico)}
- ,
-@@ -235,6 +240,7 @@
- ,
- {NULL, NULL, 0}
- };
-+#endif /* SVEN_OLA_UNBLOAT */
-
- static const struct static_txt_file_entry static_txt_files[] = {
- {"httpinfo.css", httpinfo_css},
-@@ -428,6 +434,7 @@
- } else if (!strcmp(req_type, "GET")) {
- int i = 0;
-
-+#ifndef SVEN_OLA_UNBLOAT
- for (i = 0; static_bin_files[i].filename; i++) {
- if (FILENREQ_MATCH(filename, static_bin_files[i].filename)) {
- break;
-@@ -442,6 +449,7 @@
- }
-
- i = 0;
-+#endif /* SVEN_OLA_UNBLOAT */
- while (static_txt_files[i].filename) {
- if (FILENREQ_MATCH(filename, static_txt_files[i].filename)) {
- break;
-@@ -480,16 +488,22 @@
- abuf_appendf(&body_abuf,
- "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n" "<head>\n"
- "<meta http-equiv=\"Content-type\" content=\"text/html; charset=ISO-8859-1\">\n"
-- "<title>olsr.org httpinfo plugin</title>\n" "<link rel=\"icon\" href=\"favicon.ico\" type=\"image/x-icon\">\n"
-+ "<title>olsr.org httpinfo plugin</title>\n"
-+#ifndef SVEN_OLA_UNBLOAT
-+ "<link rel=\"icon\" href=\"favicon.ico\" type=\"image/x-icon\">\n"
- "<link rel=\"shortcut icon\" href=\"favicon.ico\" type=\"image/x-icon\">\n"
-+#endif /* SVEN_OLA_UNBLOAT */
- "<link rel=\"stylesheet\" type=\"text/css\" href=\"httpinfo.css\">\n" "</head>\n"
- "<body bgcolor=\"#ffffff\" text=\"#000000\">\n"
-+#ifndef SVEN_OLA_UNBLOAT
- "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"%d\">\n"
- "<tbody><tr bgcolor=\"#ffffff\">\n" "<td align=\"left\" height=\"69\" valign=\"middle\" width=\"80%%\">\n"
- "<font color=\"black\" face=\"timesroman\" size=\"6\">&nbsp;&nbsp;&nbsp;<a href=\"http://www.olsr.org/\">olsr.org OLSR daemon</a></font></td>\n"
- "<td height=\"69\" valign=\"middle\" width=\"20%%\">\n"
- "<a href=\"http://www.olsr.org/\"><img border=\"0\" src=\"/logo.gif\" alt=\"olsrd logo\"></a></td>\n" "</tr>\n"
-- "</tbody>\n" "</table>\n", FRAMEWIDTH);
-+ "</tbody>\n" "</table>\n", FRAMEWIDTH
-+#endif /* SVEN_OLA_UNBLOAT */
-+ );
-
- build_tabs(&body_abuf, i);
- build_frame(&body_abuf, "Current Routes", "routes", FRAMEWIDTH, tab_entries[i].build_body_cb);
-@@ -894,7 +908,7 @@
- abuf_puts(abuf, "<tr><td colspan=\"3\">Status: DOWN</td></tr>\n");
- continue;
- }
--
-+#ifndef SVEN_OLA_UNBLOAT
- if (olsr_cnf->ip_version == AF_INET) {
- struct ipaddr_str addrbuf, maskbuf, bcastbuf;
- abuf_appendf(abuf, "<tr>\n" "<td>IP: %s</td>\n" "<td>MASK: %s</td>\n" "<td>BCAST: %s</td>\n" "</tr>\n",
-@@ -905,6 +919,7 @@
- abuf_appendf(abuf, "<tr>\n" "<td>IP: %s</td>\n" "<td>MCAST: %s</td>\n" "<td></td>\n" "</tr>\n",
- ip6_to_string(&addrbuf, &rifs->int6_addr.sin6_addr), ip6_to_string(&maskbuf, &rifs->int6_multaddr.sin6_addr));
- }
-+#endif /* SVEN_OLA_UNBLOAT */
- abuf_appendf(abuf, "<tr>\n" "<td>MTU: %d</td>\n" "<td>WLAN: %s</td>\n" "<td>STATUS: UP</td>\n" "</tr>\n",
- rifs->int_mtu, rifs->is_wireless ? "Yes" : "No");
- }
-@@ -1155,6 +1170,7 @@
- #endif
- }
-
-+#ifndef SVEN_OLA_UNBLOAT
- static int
- check_allowed_ip(const struct allowed_net *const my_allowed_nets, const union olsr_ip_addr *const addr)
- {
-@@ -1166,6 +1182,7 @@
- }
- return 0;
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- #if 0
-
---- a/lib/nameservice/src/nameservice.c
-+++ b/lib/nameservice/src/nameservice.c
-@@ -67,6 +67,11 @@
- #include "mapwrite.h"
- #include "compat.h"
-
-+#ifdef SVEN_OLA_UNBLOAT
-+#undef OLSR_PRINTF
-+#define OLSR_PRINTF(...)
-+#endif /* SVEN_OLA_UNBLOAT */
-+
- /* config parameters */
- static char my_hosts_file[MAX_FILE + 1];
- static char my_sighup_pid_file[MAX_FILE + 1];
-@@ -383,6 +388,7 @@
- name->ip = olsr_cnf->main_addr;
- }
- }
-+
- for (name = my_forwarders; name != NULL; name = name->next) {
- if (name->ip.v4.s_addr == 0) {
- OLSR_PRINTF(2, "NAME PLUGIN: insert main addr for name %s \n", name->name);
-@@ -903,9 +909,11 @@
- pos += sizeof(struct name);
- pos += 1 + ((ntohs(from_packet->len) - 1) | 3);
- }
-+#ifdef DEBUG
- if (i != 0)
- OLSR_PRINTF(4, "NAME PLUGIN: Lost %d entries in received packet due to length inconsistency (%s)\n", i,
- olsr_ip_to_string(&strbuf, originator));
-+#endif
- }
-
- /**
---- a/src/apm.h
-+++ b/src/apm.h
-@@ -41,6 +41,7 @@
-
- #ifndef _OLSR_APM
- #define _OLSR_APM
-+#ifndef SVEN_OLA_UNBLOAT
-
- /*
- * Interface to OS dependent power management information
-@@ -69,6 +70,7 @@
- int apm_read(struct olsr_apm_info *);
-
- #endif
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /*
- * Local Variables:
---- a/src/cfgparser/cfgfile_gen.c
-+++ b/src/cfgparser/cfgfile_gen.c
-@@ -57,7 +57,9 @@
- struct olsr_if *in = cnf->interfaces;
- struct plugin_entry *pe = cnf->plugins;
- struct plugin_param *pp;
-+#ifndef SVEN_OLA_UNBLOAT
- struct ip_prefix_list *ie = cnf->ipc_nets;
-+#endif /* SVEN_OLA_UNBLOAT */
- struct olsr_lq_mult *mult;
-
- char ipv6_buf[100]; /* buffer for IPv6 inet_htop */
-@@ -133,6 +135,7 @@
- else
- fprintf(fd, "Willingness\t%d\n\n", cnf->willingness);
-
-+#ifndef SVEN_OLA_UNBLOAT
- /* IPC */
- fprintf(fd, "# Allow processes like the GUI front-end\n# to connect to the daemon.\n\n");
- fprintf(fd, "IpcConnect {\n");
-@@ -149,6 +152,7 @@
- }
-
- fprintf(fd, "}\n\n");
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /* Hysteresis */
- fprintf(fd, "# Hysteresis adds more robustness to the\n# link sensing.\n# Used by default. 'yes' or 'no'\n\n");
-@@ -367,7 +371,9 @@
- struct olsr_if *in = cnf->interfaces;
- struct plugin_entry *pe = cnf->plugins;
- struct plugin_param *pp;
-+#ifndef SVEN_OLA_UNBLOAT
- struct ip_prefix_list *ie = cnf->ipc_nets;
-+#endif /* SVEN_OLA_UNBLOAT */
- struct olsr_lq_mult *mult;
-
- int size = 0;
-@@ -434,6 +440,7 @@
- else
- WRITE_TO_BUF("Willingness\t%d\n\n", cnf->willingness);
-
-+#ifndef SVEN_OLA_UNBLOAT
- /* IPC */
- WRITE_TO_BUF("# Allow processes like the GUI front-end\n# to connect to the daemon.\n\n");
- WRITE_TO_BUF("IpcConnect {\n");
-@@ -449,6 +456,7 @@
- }
-
- WRITE_TO_BUF("}\n\n");
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /* Hysteresis */
- WRITE_TO_BUF("# Hysteresis adds more robustness to the\n# link sensing.\n# Used by default. 'yes' or 'no'\n\n");
---- a/src/cfgparser/local.mk
-+++ b/src/cfgparser/local.mk
-@@ -41,8 +41,13 @@
- C=$(if $(CFGDIR),$(CFGDIR)/)
-
- # add the variables as we may have others already there
-+ifeq ($(SVEN_OLA_UNBLOAT),1)
-+SRCS += $(foreach file,olsrd_conf oparse oscan,$(C)$(file).c)
-+OBJS += $(foreach file,olsrd_conf oparse oscan,$(C)$(file).o)
-+else
- SRCS += $(foreach file,olsrd_conf oparse oscan cfgfile_gen,$(C)$(file).c)
- OBJS += $(foreach file,olsrd_conf oparse oscan cfgfile_gen,$(C)$(file).o)
-+endif
- HDRS += $(foreach file,olsrd_conf oparse,$(C)$(file).h)
-
- $(C)oscan.c: $(C)oscan.lex $(C)Makefile
---- a/src/cfgparser/olsrd_conf.c
-+++ b/src/cfgparser/olsrd_conf.c
-@@ -81,11 +81,13 @@
- }
-
- if ((cnf = olsrd_parse_cnf(argv[1])) != NULL) {
-+#ifndef SVEN_OLA_UNBLOAT
- if ((argc > 2) && (!strcmp(argv[2], "-print"))) {
- olsrd_print_cnf(cnf);
- olsrd_write_cnf(cnf, "./out.conf");
- } else
- printf("Use -print to view parsed values\n");
-+#endif /* SVEN_OLA_UNBLOAT */
- printf("Configfile parsed OK\n");
- } else {
- printf("Failed parsing \"%s\"\n", argv[1]);
-@@ -152,7 +154,9 @@
- /* set various stuff */
- in->configured = false;
- in->interf = NULL;
-+#ifndef SVEN_OLA_UNBLOAT
- in->host_emul = false;
-+#endif /* SVEN_OLA_UNBLOAT */
- }
- return olsr_cnf;
- }
-@@ -416,7 +420,9 @@
-
- cnf->debug_level = DEF_DEBUGLVL;
- cnf->no_fork = false;
-+#ifndef SVEN_OLA_UNBLOAT
- cnf->host_emul = false;
-+#endif /* SVEN_OLA_UNBLOAT */
- cnf->ip_version = AF_INET;
- cnf->ipsize = sizeof(struct in_addr);
- cnf->maxplen = 32;
-@@ -427,7 +433,9 @@
- cnf->rtproto = DEF_RTPROTO;
- cnf->rttable_default = 0;
- cnf->willingness_auto = DEF_WILL_AUTO;
-+#ifndef SVEN_OLA_UNBLOAT
- cnf->ipc_connections = DEF_IPC_CONNECTIONS;
-+#endif /* SVEN_OLA_UNBLOAT */
- cnf->fib_metric = DEF_FIB_METRIC;
-
- cnf->use_hysteresis = DEF_USE_HYST;
-@@ -506,6 +514,7 @@
-
- }
-
-+#ifndef SVEN_OLA_UNBLOAT
- void
- olsrd_print_cnf(struct olsrd_config *cnf)
- {
-@@ -649,6 +658,7 @@
- }
- }
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- #if defined WIN32
- struct ioinfo {
---- a/src/cfgparser/oparse.y
-+++ b/src/cfgparser/oparse.y
-@@ -178,7 +178,6 @@
- %token TOK_RTPROTO
- %token TOK_RTTABLE_DEFAULT
- %token TOK_WILLINGNESS
--%token TOK_IPCCON
- %token TOK_FIBMETRIC
- %token TOK_USEHYST
- %token TOK_HYSTSCALE
-@@ -203,7 +202,6 @@
-
- %token TOK_HOSTLABEL
- %token TOK_NETLABEL
--%token TOK_MAXIPC
-
- %token TOK_IP4BROADCAST
- %token TOK_IFMODE
-@@ -267,7 +265,6 @@
-
- block: TOK_HNA4 hna4body
- | TOK_HNA6 hna6body
-- | TOK_IPCCON ipcbody
- | ifblock ifbody
- | plblock plbody
- ;
-@@ -292,18 +289,6 @@
- | ihna6entry
- ;
-
--ipcbody: TOK_OPEN ipcstmts TOK_CLOSE
--;
--
--ipcstmts: | ipcstmts ipcstmt
--;
--
--ipcstmt: vcomment
-- | imaxipc
-- | ipchost
-- | ipcnet
--;
--
- ifblock: ifstart ifnicks
- ;
-
-@@ -345,77 +330,6 @@
- | vcomment
- ;
-
--imaxipc: TOK_MAXIPC TOK_INTEGER
--{
-- olsr_cnf->ipc_connections = $2->integer;
-- free($2);
--}
--;
--
--ipchost: TOK_HOSTLABEL TOK_IP4_ADDR
--{
-- union olsr_ip_addr ipaddr;
-- PARSER_DEBUG_PRINTF("\tIPC host: %s\n", $2->string);
--
-- if (inet_aton($2->string, &ipaddr.v4) == 0) {
-- fprintf(stderr, "Failed converting IP address IPC %s\n", $2->string);
-- YYABORT;
-- }
--
-- ip_prefix_list_add(&olsr_cnf->ipc_nets, &ipaddr, olsr_cnf->maxplen);
--
-- free($2->string);
-- free($2);
--}
--;
--
--ipcnet: TOK_NETLABEL TOK_IP4_ADDR TOK_IP4_ADDR
--{
-- union olsr_ip_addr ipaddr, netmask;
--
-- PARSER_DEBUG_PRINTF("\tIPC net: %s/%s\n", $2->string, $3->string);
--
-- if (inet_pton(AF_INET, $2->string, &ipaddr.v4) == 0) {
-- fprintf(stderr, "Failed converting IP net IPC %s\n", $2->string);
-- YYABORT;
-- }
--
-- if (inet_pton(AF_INET, $3->string, &netmask.v4) == 0) {
-- fprintf(stderr, "Failed converting IP mask IPC %s\n", $3->string);
-- YYABORT;
-- }
--
-- ip_prefix_list_add(&olsr_cnf->ipc_nets, &ipaddr, olsr_netmask_to_prefix(&netmask));
--
-- free($2->string);
-- free($2);
-- free($3->string);
-- free($3);
--}
-- | TOK_NETLABEL TOK_IP4_ADDR TOK_SLASH TOK_INTEGER
--{
-- union olsr_ip_addr ipaddr;
--
-- PARSER_DEBUG_PRINTF("\tIPC net: %s/%s\n", $2->string, $3->string);
--
-- if (inet_pton(AF_INET, $2->string, &ipaddr.v4) == 0) {
-- fprintf(stderr, "Failed converting IP net IPC %s\n", $2->string);
-- YYABORT;
-- }
--
-- if ($4->integer > olsr_cnf->maxplen) {
-- fprintf(stderr, "ipcnet: Prefix len %u > %d is not allowed!\n", $4->integer, olsr_cnf->maxplen);
-- YYABORT;
-- }
--
-- ip_prefix_list_add(&olsr_cnf->ipc_nets, &ipaddr, $4->integer);
--
-- free($2->string);
-- free($2);
-- free($4);
--}
--;
--
- iifweight: TOK_IFWEIGHT TOK_INTEGER
- {
- int ifcnt = ifs_in_curr_cfg;
---- a/src/cfgparser/oscan.lex
-+++ b/src/cfgparser/oscan.lex
-@@ -252,11 +252,6 @@
- return TOK_NETLABEL;
- }
-
--"MaxConnections" {
-- yylval = NULL;
-- return TOK_MAXIPC;
--}
--
- "DebugLevel" {
- yylval = NULL;
- return TOK_DEBUGLEVEL;
-@@ -333,11 +328,6 @@
- return TOK_WILLINGNESS;
- }
-
--"IpcConnect" {
-- yylval = NULL;
-- return TOK_IPCCON;
--}
--
- "FIBMetric" {
- yylval = NULL;
- return TOK_FIBMETRIC;
---- a/src/defs.h
-+++ b/src/defs.h
-@@ -189,6 +189,8 @@
-
- uint32_t olsr_times(void);
-
-+#ifndef SVEN_OLA_UNBLOAT
-+
- /*
- *IPC functions
- *These are moved to a plugin soon
-@@ -206,6 +208,7 @@
- int ipc_output(struct olsr *);
-
- #endif
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /*
- * Local Variables:
---- a/src/duplicate_set.c
-+++ b/src/duplicate_set.c
-@@ -177,6 +177,7 @@
- return false; /* no duplicate */
- }
-
-+#ifndef SVEN_OLA_UNBLOAT
- void
- olsr_print_duplicate_table(void)
- {
-@@ -195,6 +196,7 @@
- } OLSR_FOR_ALL_DUP_ENTRIES_END(entry);
- #endif
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /*
- * Local Variables:
---- a/src/hna_set.c
-+++ b/src/hna_set.c
-@@ -280,6 +280,7 @@
- *
- *@return nada
- */
-+#ifndef SVEN_OLA_UNBLOAT
- void
- olsr_print_hna_set(void)
- {
-@@ -321,6 +322,7 @@
- }
- #endif
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /**
- *Process incoming HNA message.
---- a/src/interfaces.c
-+++ b/src/interfaces.c
-@@ -93,12 +93,16 @@
- OLSR_PRINTF(1, "\n ---- Interface configuration ---- \n\n");
- /* Run trough all interfaces immedeatly */
- for (tmp_if = olsr_cnf->interfaces; tmp_if != NULL; tmp_if = tmp_if->next) {
-+#ifndef SVEN_OLA_UNBLOAT
- if (!tmp_if->host_emul) {
- if (!olsr_cnf->host_emul) /* XXX: TEMPORARY! */
-+#endif /* SVEN_OLA_UNBLOAT */
- chk_if_up(tmp_if, 1);
-+#ifndef SVEN_OLA_UNBLOAT
- } else {
- add_hemu_if(tmp_if);
- }
-+#endif /* SVEN_OLA_UNBLOAT */
- }
-
- /* Kick a periodic timer for the network interface update function */
-@@ -244,7 +248,11 @@
- *@return nada
- */
- struct olsr_if *
-+#ifdef SVEN_OLA_UNBLOAT
-+queue_if(const char *name)
-+#else /* SVEN_OLA_UNBLOAT */
- queue_if(const char *name, int hemu)
-+#endif /* SVEN_OLA_UNBLOAT */
- {
- struct olsr_if *interf_n = olsr_cnf->interfaces;
- size_t name_size;
-@@ -268,7 +276,9 @@
- interf_n->interf = NULL;
- interf_n->configured = 0;
-
-+#ifndef SVEN_OLA_UNBLOAT
- interf_n->host_emul = hemu ? true : false;
-+#endif /* SVEN_OLA_UNBLOAT */
-
- strscpy(interf_n->name, name, name_size);
- interf_n->next = olsr_cnf->interfaces;
---- a/src/interfaces.h
-+++ b/src/interfaces.h
-@@ -200,7 +200,12 @@
-
- struct interface *if_ifwithindex(const int if_index);
-
--struct olsr_if *queue_if(const char *, int);
-+struct olsr_if *
-+#ifdef SVEN_OLA_UNBLOAT
-+ queue_if(const char *);
-+#else /* SVEN_OLA_UNBLOAT */
-+ queue_if(const char *, int);
-+#endif /* SVEN_OLA_UNBLOAT */
-
- int add_ifchgf(int (*f) (struct interface *, int));
-
---- a/src/ipc_frontend.c
-+++ b/src/ipc_frontend.c
-@@ -46,6 +46,7 @@
- *
- */
-
-+#ifndef SVEN_OLA_UNBLOAT
- #include "ipc_frontend.h"
- #include "link_set.h"
- #include "olsr.h"
-@@ -423,6 +424,7 @@
-
- return 1;
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /*
- * Local Variables:
---- a/src/ipc_frontend.h
-+++ b/src/ipc_frontend.h
-@@ -48,6 +48,7 @@
-
- #ifndef _OLSR_IPC
- #define _OLSR_IPC
-+#ifndef SVEN_OLA_UNBLOAT
-
- #include <sys/types.h>
- #include <netinet/in.h>
-@@ -103,6 +104,7 @@
- int ipc_route_send_rtentry(const union olsr_ip_addr *, const union olsr_ip_addr *, int, int, const char *);
-
- #endif
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /*
- * Local Variables:
---- a/src/ipcalc.c
-+++ b/src/ipcalc.c
-@@ -121,6 +121,7 @@
- return prefix;
- }
-
-+#ifndef SVEN_OLA_UNBLOAT
- const char *
- olsr_ip_prefix_to_string(const struct olsr_ip_prefix *prefix)
- {
-@@ -147,6 +148,7 @@
- }
- return rv;
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /* see if the ipaddr is in the net. That is equivalent to the fact that the net part
- * of both are equal. So we must compare the first <prefixlen> bits.
---- a/src/ipcalc.h
-+++ b/src/ipcalc.h
-@@ -146,7 +146,9 @@
- return inet_ntop(olsr_cnf->ip_version, addr, buf->buf, sizeof(buf->buf));
- }
-
-+#ifndef SVEN_OLA_UNBLOAT
- const char *olsr_ip_prefix_to_string(const struct olsr_ip_prefix *prefix);
-+#endif /* SVEN_OLA_UNBLOAT */
-
- static INLINE const char *
- sockaddr4_to_string(struct ipaddr_str *const buf, const struct sockaddr *const addr)
---- a/src/link_set.c
-+++ b/src/link_set.c
-@@ -770,6 +770,7 @@
- return ret;
- }
-
-+#ifndef SVEN_OLA_UNBLOAT
- void
- olsr_print_link_set(void)
- {
-@@ -791,6 +792,7 @@
- } OLSR_FOR_ALL_LINK_ENTRIES_END(walker);
- #endif
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /*
- * called for every LQ HELLO message.
---- a/src/linux/apm.c
-+++ b/src/linux/apm.c
-@@ -44,6 +44,7 @@
- * Acpi-Power Enlightenment epplet
- */
-
-+#ifndef SVEN_OLA_UNBLOAT
- #include "apm.h"
- #include "defs.h"
- #include <stdio.h>
-@@ -348,6 +349,7 @@
- /* No battery found */
- return -1;
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /*
- * Local Variables:
---- a/src/linux/kernel_routes.c
-+++ b/src/linux/kernel_routes.c
-@@ -486,7 +486,11 @@
- }
- /* send ipc update on success */
- if ( ( cmd != RTM_NEWRULE ) && ( cmd != RTM_DELRULE )
-- && (flag = RT_ORIG_REQUEST) && (0 <= rt_ret && olsr_cnf->ipc_connections > 0) ) {
-+ && (flag = RT_ORIG_REQUEST) && (0 <= rt_ret
-+#ifndef SVEN_OLA_UNBLOAT
-+ && olsr_cnf->ipc_connections > 0
-+#endif /* SVEN_OLA_UNBLOAT */
-+ ) ) {
- ipc_route_send_rtentry(&rt->rt_dst.prefix, &nexthop->gateway, metric,
- RTM_NEWROUTE == cmd, if_ifwithindex_name(nexthop->iif_index));
- }
-@@ -528,7 +532,9 @@
- int rslt;
- #endif /* LINUX_POLICY_ROUTING */
-
-+#ifndef SVEN_OLA_UNBLOAT
- OLSR_PRINTF(2, "KERN: Adding %s\n", olsr_rtp_to_string(rt->rt_best));
-+#endif /* SVEN_OLA_UNBLOAT */
-
- #if !LINUX_POLICY_ROUTING
- memset(&kernel_route, 0, sizeof(struct rtentry));
-@@ -604,7 +610,9 @@
- struct in6_rtmsg kernel_route;
- int rslt;
-
-+#ifndef SVEN_OLA_UNBLOAT
- OLSR_PRINTF(2, "KERN: Adding %s\n", olsr_rtp_to_string(rt->rt_best));
-+#endif /* SVEN_OLA_UNBLOAT */
-
- memset(&kernel_route, 0, sizeof(struct in6_rtmsg));
-
-@@ -658,7 +666,9 @@
- int rslt;
- #endif /* LINUX_POLICY_ROUTING */
-
-+#ifndef SVEN_OLA_UNBLOAT
- OLSR_PRINTF(2, "KERN: Deleting %s\n", olsr_rt_to_string(rt));
-+#endif /* SVEN_OLA_UNBLOAT */
-
- #if !LINUX_POLICY_ROUTING
- memset(&kernel_route, 0, sizeof(struct rtentry));
-@@ -727,7 +737,9 @@
- int rslt;
- #endif /* LINUX_POLICY_ROUTING */
-
-+#ifndef SVEN_OLA_UNBLOAT
- OLSR_PRINTF(2, "KERN: Deleting %s\n", olsr_rt_to_string(rt));
-+#endif /* SVEN_OLA_UNBLOAT */
-
- #if !LINUX_POLICY_ROUTING
- memset(&kernel_route, 0, sizeof(struct in6_rtmsg));
---- a/src/linux/net.c
-+++ b/src/linux/net.c
-@@ -70,8 +70,10 @@
- #define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
-
- /* The original state of the IP forwarding proc entry */
-+#ifndef SVEN_OLA_UNBLOAT
- static char orig_fwd_state;
- static char orig_global_redirect_state;
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /**
- *Bind a socket to a device
-@@ -92,6 +94,8 @@
- return setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, dev_name, strlen(dev_name) + 1);
- }
-
-+#ifndef SVEN_OLA_UNBLOAT
-+
- /**
- *Enable IP forwarding.
- *Just writing "1" to the /proc/sys/net/ipv4/ip_forward
-@@ -111,6 +115,9 @@
- const char *const procfile = version == AF_INET ? "/proc/sys/net/ipv4/ip_forward" : "/proc/sys/net/ipv6/conf/all/forwarding";
-
- if ((proc_fwd = fopen(procfile, "r")) == NULL) {
-+#ifdef SVEN_OLA_UNBLOAT_OLD
-+ perror(procfile);
-+#else
- /* IPv4 */
- if (version == AF_INET)
- fprintf(stderr,
-@@ -123,6 +130,7 @@
- procfile);
-
- sleep(3);
-+#endif
- return 0;
- }
-
-@@ -132,9 +140,13 @@
- OLSR_PRINTF(3, "\nIP forwarding is enabled on this system\n");
- } else {
- if ((proc_fwd = fopen(procfile, "w")) == NULL) {
-+#ifdef SVEN_OLA_UNBLOAT_OLD
-+ perror(procfile);
-+#else
- fprintf(stderr, "Could not open %s for writing!\n", procfile);
- fprintf(stderr, "I will continue(in 3 sec) - but you should mannually ensure that IP forwarding is enabeled!\n\n");
- sleep(3);
-+#endif
- return 0;
- } else {
- syslog(LOG_INFO, "Writing \"1\" to %s\n", procfile);
-@@ -155,11 +167,15 @@
- return -1;
-
- if ((proc_redirect = fopen(procfile, "r")) == NULL) {
-+#ifdef SVEN_OLA_UNBLOAT_OLD
-+ perror(procfile);
-+#else
- fprintf(stderr,
- "WARNING! Could not open the %s file to check/disable ICMP redirects!\nAre you using the procfile filesystem?\nDoes your system support IPv4?\nI will continue(in 3 sec) - but you should mannually ensure that ICMP redirects are disabled!\n\n",
- procfile);
-
- sleep(3);
-+#endif
- return -1;
- }
- orig_global_redirect_state = fgetc(proc_redirect);
-@@ -169,9 +185,13 @@
- return 0;
-
- if ((proc_redirect = fopen(procfile, "w")) == NULL) {
-+#ifdef SVEN_OLA_UNBLOAT_OLD
-+ perror(procfile);
-+#else
- fprintf(stderr, "Could not open %s for writing!\n", procfile);
- fprintf(stderr, "I will continue(in 3 sec) - but you should mannually ensure that ICMP redirect is disabeled!\n\n");
- sleep(3);
-+#endif
- return 0;
- }
- syslog(LOG_INFO, "Writing \"0\" to %s", procfile);
-@@ -197,19 +217,27 @@
- snprintf(procfile, sizeof(procfile), REDIRECT_PROC, if_name);
-
- if ((proc_redirect = fopen(procfile, "r")) == NULL) {
-+#ifdef SVEN_OLA_UNBLOAT_OLD
-+ perror(procfile);
-+#else
- fprintf(stderr,
- "WARNING! Could not open the %s file to check/disable ICMP redirects!\nAre you using the procfile filesystem?\nDoes your system support IPv4?\nI will continue(in 3 sec) - but you should mannually ensure that ICMP redirects are disabled!\n\n",
- procfile);
- sleep(3);
-+#endif
- return 0;
- }
- iface->nic_state.redirect = fgetc(proc_redirect);
- fclose(proc_redirect);
-
- if ((proc_redirect = fopen(procfile, "w")) == NULL) {
-+#ifdef SVEN_OLA_UNBLOAT_OLD
-+ perror(procfile);
-+#else
- fprintf(stderr, "Could not open %s for writing!\n", procfile);
- fprintf(stderr, "I will continue(in 3 sec) - but you should mannually ensure that ICMP redirect is disabeled!\n\n");
- sleep(3);
-+#endif
- return 0;
- }
- syslog(LOG_INFO, "Writing \"0\" to %s", procfile);
-@@ -235,20 +263,28 @@
- sprintf(procfile, SPOOF_PROC, if_name);
-
- if ((proc_spoof = fopen(procfile, "r")) == NULL) {
-+#ifdef SVEN_OLA_UNBLOAT_OLD
-+ perror(procfile);
-+#else
- fprintf(stderr,
- "WARNING! Could not open the %s file to check/disable the IP spoof filter!\nAre you using the procfile filesystem?\nDoes your system support IPv4?\nI will continue(in 3 sec) - but you should mannually ensure that IP spoof filtering is disabled!\n\n",
- procfile);
-
- sleep(3);
-+#endif
- return 0;
- }
- iface->nic_state.spoof = fgetc(proc_spoof);
- fclose(proc_spoof);
-
- if ((proc_spoof = fopen(procfile, "w")) == NULL) {
-+#ifdef SVEN_OLA_UNBLOAT_OLD
-+ perror(procfile);
-+#else
- fprintf(stderr, "Could not open %s for writing!\n", procfile);
- fprintf(stderr, "I will continue(in 3 sec) - but you should mannually ensure that IP spoof filtering is disabeled!\n\n");
- sleep(3);
-+#endif
- return 0;
- }
- syslog(LOG_INFO, "Writing \"0\" to %s", procfile);
-@@ -273,7 +309,11 @@
- FILE *proc_fd;
-
- if ((proc_fd = fopen(procfile, "w")) == NULL) {
-+#ifdef SVEN_OLA_UNBLOAT_OLD
-+ perror(procfile);
-+#else
- fprintf(stderr, "Could not open %s for writing!\nSettings not restored!\n", procfile);
-+#endif
- } else {
- syslog(LOG_INFO, "Resetting %s to %c\n", procfile, orig_fwd_state);
- fputc(orig_fwd_state, proc_fd);
-@@ -288,7 +328,11 @@
- FILE *proc_fd;
-
- if ((proc_fd = fopen(procfile, "w")) == NULL) {
-+#ifdef SVEN_OLA_UNBLOAT_OLD
-+ perror(procfile);
-+#else
- fprintf(stderr, "Could not open %s for writing!\nSettings not restored!\n", procfile);
-+#endif
- } else {
- syslog(LOG_INFO, "Resetting %s to %c\n", procfile, orig_global_redirect_state);
- fputc(orig_global_redirect_state, proc_fd);
-@@ -312,7 +356,11 @@
- snprintf(procfile, sizeof(procfile), REDIRECT_PROC, ifs->int_name);
-
- if ((proc_fd = fopen(procfile, "w")) == NULL)
-+#ifdef SVEN_OLA_UNBLOAT_OLD
-+ perror(procfile);
-+#else
- fprintf(stderr, "Could not open %s for writing!\nSettings not restored!\n", procfile);
-+#endif
- else {
- syslog(LOG_INFO, "Resetting %s to %c\n", procfile, ifs->nic_state.redirect);
-
-@@ -325,7 +373,11 @@
- /* Generate the procfile name */
- sprintf(procfile, SPOOF_PROC, ifs->int_name);
- if ((proc_fd = fopen(procfile, "w")) == NULL)
-+#ifdef SVEN_OLA_UNBLOAT_OLD
-+ perror(procfile);
-+#else
- fprintf(stderr, "Could not open %s for writing!\nSettings not restored!\n", procfile);
-+#endif
- else {
- syslog(LOG_INFO, "Resetting %s to %c\n", procfile, ifs->nic_state.spoof);
-
-@@ -373,6 +425,8 @@
- return sock;
- }
-
-+#endif /* SVEN_OLA_UNBLOAT */
-+
- /**
- *Creates a nonblocking broadcast socket.
- *@param sa sockaddr struct. Used for bind(2).
---- a/src/lq_plugin.c
-+++ b/src/lq_plugin.c
-@@ -67,12 +67,18 @@
- init_lq_handler_tree(void)
- {
- avl_init(&lq_handler_tree, &avl_strcasecmp);
-+#ifndef SVEN_OLA_UNBLOAT
- register_lq_handler(&lq_etx_float_handler, LQ_ALGORITHM_ETX_FLOAT_NAME);
- register_lq_handler(&lq_etx_fpm_handler, LQ_ALGORITHM_ETX_FPM_NAME);
-+#endif /* SVEN_OLA_UNBLOAT */
- register_lq_handler(&lq_etx_ff_handler, LQ_ALGORITHM_ETX_FF_NAME);
-+#ifndef SVEN_OLA_UNBLOAT
- if (activate_lq_handler(olsr_cnf->lq_algorithm)) {
- activate_lq_handler(LQ_ALGORITHM_ETX_FPM_NAME);
- }
-+#else /* SVEN_OLA_UNBLOAT */
-+ activate_lq_handler(LQ_ALGORITHM_ETX_FF_NAME);
-+#endif /* SVEN_OLA_UNBLOAT */
- }
-
- /*
-@@ -385,7 +391,11 @@
- * @return pointer to hello_neighbor
- */
- struct hello_neighbor *
-+#ifndef SVEN_OLA_UNBLOAT
- olsr_malloc_hello_neighbor(const char *id)
-+#else /* SVEN_OLA_UNBLOAT */
-+olsr_malloc_hello_neighbor(const char *id __attribute__ ((unused)))
-+#endif /* SVEN_OLA_UNBLOAT */
- {
- struct hello_neighbor *h;
-
-@@ -407,7 +417,11 @@
- * @return pointer to tc_mpr_addr
- */
- struct tc_mpr_addr *
-+#ifndef SVEN_OLA_UNBLOAT
- olsr_malloc_tc_mpr_addr(const char *id)
-+#else /* SVEN_OLA_UNBLOAT */
-+olsr_malloc_tc_mpr_addr(const char *id __attribute__ ((unused)))
-+#endif /* SVEN_OLA_UNBLOAT */
- {
- struct tc_mpr_addr *t;
-
-@@ -429,7 +443,11 @@
- * @return pointer to lq_hello_neighbor
- */
- struct lq_hello_neighbor *
-+#ifndef SVEN_OLA_UNBLOAT
- olsr_malloc_lq_hello_neighbor(const char *id)
-+#else /* SVEN_OLA_UNBLOAT */
-+olsr_malloc_lq_hello_neighbor(const char *id __attribute__ ((unused)))
-+#endif /* SVEN_OLA_UNBLOAT */
- {
- struct lq_hello_neighbor *h;
-
-@@ -451,7 +469,11 @@
- * @return pointer to link_entry
- */
- struct link_entry *
-+#ifndef SVEN_OLA_UNBLOAT
- olsr_malloc_link_entry(const char *id)
-+#else /* SVEN_OLA_UNBLOAT */
-+olsr_malloc_link_entry(const char *id __attribute__ ((unused)))
-+#endif /* SVEN_OLA_UNBLOAT */
- {
- struct link_entry *h;
-
---- a/src/lq_plugin_default_float.c
-+++ b/src/lq_plugin_default_float.c
-@@ -39,6 +39,7 @@
- *
- */
-
-+#ifndef SVEN_OLA_UNBLOAT
- #include "tc_set.h"
- #include "link_set.h"
- #include "olsr_spf.h"
-@@ -228,6 +229,7 @@
-
- return buffer->buf;
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /*
- * Local Variables:
---- a/src/lq_plugin_default_float.h
-+++ b/src/lq_plugin_default_float.h
-@@ -39,6 +39,7 @@
- *
- */
-
-+#ifndef SVEN_OLA_UNBLOAT
- #ifndef LQ_PLUGIN_DEFAULT_H_
- #define LQ_PLUGIN_DEFAULT_H_
-
-@@ -57,6 +58,7 @@
- extern struct lq_handler lq_etx_float_handler;
-
- #endif /*LQ_PLUGIN_DEFAULT_H_ */
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /*
- * Local Variables:
---- a/src/lq_plugin_default_fpm.c
-+++ b/src/lq_plugin_default_fpm.c
-@@ -39,6 +39,7 @@
- *
- */
-
-+#ifndef SVEN_OLA_UNBLOAT
- #include "tc_set.h"
- #include "link_set.h"
- #include "lq_plugin.h"
-@@ -239,6 +240,7 @@
- snprintf(buffer->buf, sizeof(buffer->buf), "%.3f", (float)(cost) / LQ_FPM_LINKCOST_MULTIPLIER);
- return buffer->buf;
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /*
- * Local Variables:
---- a/src/lq_plugin_default_fpm.h
-+++ b/src/lq_plugin_default_fpm.h
-@@ -39,6 +39,7 @@
- *
- */
-
-+#ifndef SVEN_OLA_UNBLOAT
- #ifndef LQ_ETX_FPM_
- #define LQ_ETX_FPM_
-
-@@ -61,6 +62,7 @@
- extern struct lq_handler lq_etx_fpm_handler;
-
- #endif /*LQ_ETX_FPM_ */
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /*
- * Local Variables:
---- a/src/main.c
-+++ b/src/main.c
-@@ -289,13 +289,17 @@
- /*
- * Print configuration
- */
-+#ifndef SVEN_OLA_UNBLOAT
- if (olsr_cnf->debug_level > 1) {
- olsrd_print_cnf(olsr_cnf);
- }
-+#endif /* SVEN_OLA_UNBLOAT */
- #ifndef WIN32
-+#ifndef SVEN_OLA_UNBLOAT
- /* Disable redirects globally */
- disable_redirects_global(olsr_cnf->ip_version);
- #endif
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /*
- * socket for ioctl calls
-@@ -331,7 +335,9 @@
- /*
- *enable ip forwarding on host
- */
-+#ifndef SVEN_OLA_UNBLOAT
- enable_ip_forwarding(olsr_cnf->ip_version);
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /* Initialize parser */
- olsr_init_parser();
-@@ -349,6 +355,7 @@
- *Set up willingness/APM
- */
- if (olsr_cnf->willingness_auto) {
-+#ifndef SVEN_OLA_UNBLOAT
- if (apm_init() < 0) {
- OLSR_PRINTF(1, "Could not read APM info - setting default willingness(%d)\n", WILL_DEFAULT);
-
-@@ -359,10 +366,13 @@
- olsr_cnf->willingness_auto = 0;
- olsr_cnf->willingness = WILL_DEFAULT;
- } else {
-+#endif /* SVEN_OLA_UNBLOAT */
- olsr_cnf->willingness = olsr_calculate_willingness();
-
- OLSR_PRINTF(1, "Willingness set to %d - next update in %.1f secs\n", olsr_cnf->willingness, olsr_cnf->will_int);
-+#ifndef SVEN_OLA_UNBLOAT
- }
-+#endif /* SVEN_OLA_UNBLOAT */
- }
-
- /* Initialize net */
-@@ -392,9 +402,11 @@
-
- /* Initialize the IPC socket */
-
-+#ifndef SVEN_OLA_UNBLOAT
- if (olsr_cnf->ipc_connections > 0) {
- ipc_init();
- }
-+#endif /* SVEN_OLA_UNBLOAT */
- /* Initialisation of different tables to be used. */
- olsr_init_tables();
-
-@@ -533,9 +545,11 @@
- OLSR_PRINTF(1, "Closing sockets...\n");
-
- /* front-end IPC socket */
-+#ifndef SVEN_OLA_UNBLOAT
- if (olsr_cnf->ipc_connections > 0) {
- shutdown_ipc();
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /* OLSR sockets */
- for (ifn = ifnet; ifn; ifn = ifn->int_next)
-@@ -545,7 +559,9 @@
- olsr_close_plugins();
-
- /* Reset network settings */
-+#ifndef SVEN_OLA_UNBLOAT
- restore_settings(olsr_cnf->ip_version);
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /* ioctl socket */
- close(olsr_cnf->ioctl_s);
-@@ -585,7 +601,11 @@
- "usage: olsrd [-f <configfile>] [ -i interface1 interface2 ... ]\n"
- " [-d <debug_level>] [-ipv6] [-multi <IPv6 multicast address>]\n"
- " [-lql <LQ level>] [-lqw <LQ winsize>] [-lqnt <nat threshold>]\n"
-+#ifdef SVEN_OLA_UNBLOAT
-+ " [-bcast <broadcastaddr>] [-delgw] (Note: no -ipc,-dispin,-dispout)\n"
-+#else
- " [-bcast <broadcastaddr>] [-ipc] [-dispin] [-dispout] [-delgw]\n"
-+#endif /* SVEN_OLA_UNBLOAT */
- " [-hint <hello interval (secs)>] [-tcint <tc interval (secs)>]\n"
- " [-midint <mid interval (secs)>] [-hnaint <hna interval (secs)>]\n"
- " [-T <Polling Rate (secs)>] [-nofork] [-hemu <ip_address>]\n" " [-lql <LQ level>] [-lqa <LQ aging factor>]\n");
-@@ -749,12 +769,20 @@
- olsr_exit(__func__, EXIT_FAILURE);
- }
- printf("Queuing if %s\n", *argv);
-+#ifdef SVEN_OLA_UNBLOAT
-+ queue_if(*argv);
-+#else /* SVEN_OLA_UNBLOAT */
- queue_if(*argv, false);
-+#endif /* SVEN_OLA_UNBLOAT */
-
- while ((argc - 1) && (argv[1][0] != '-')) {
- NEXT_ARG;
- printf("Queuing if %s\n", *argv);
-+#ifdef SVEN_OLA_UNBLOAT
-+ queue_if(*argv);
-+#else /* SVEN_OLA_UNBLOAT */
- queue_if(*argv, false);
-+#endif /* SVEN_OLA_UNBLOAT */
- }
-
- continue;
-@@ -817,7 +845,7 @@
- sscanf(*argv, "%f", &cnf->pollrate);
- continue;
- }
--
-+#ifndef SVEN_OLA_UNBLOAT
- /*
- * Should we display the contents of packages beeing sent?
- */
-@@ -841,6 +869,7 @@
- cnf->ipc_connections = 1;
- continue;
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /*
- * IPv6 multicast addr
-@@ -858,7 +887,7 @@
-
- continue;
- }
--
-+#ifndef SVEN_OLA_UNBLOAT
- /*
- * Host emulation
- */
-@@ -886,6 +915,7 @@
-
- continue;
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /*
- * Delete possible default GWs
---- a/src/neighbor_table.c
-+++ b/src/neighbor_table.c
-@@ -362,6 +362,7 @@
- *
- *@return nada
- */
-+#ifndef SVEN_OLA_UNBLOAT
- void
- olsr_print_neighbor_table(void)
- {
-@@ -391,6 +392,7 @@
- }
- #endif
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /*
- * Local Variables:
---- a/src/net_olsr.c
-+++ b/src/net_olsr.c
-@@ -44,7 +44,9 @@
- #include "log.h"
- #include "olsr.h"
- #include "net_os.h"
-+#ifndef SVEN_OLA_UNBLOAT
- #include "print_packet.h"
-+#endif /* SVEN_OLA_UNBLOAT */
- #include "link_set.h"
- #include "lq_packet.h"
-
-@@ -385,8 +387,10 @@
- *if the -dispout option was given
- *we print the content of the packets
- */
-+#ifndef SVEN_OLA_UNBLOAT
- if (disp_pack_out)
- print_olsr_serialized_packet(stdout, (union olsr_packet *)ifp->netbuf.buff, ifp->netbuf.pending, &ifp->ip_addr);
-+#endif /* SVEN_OLA_UNBLOAT */
-
- if (olsr_cnf->ip_version == AF_INET) {
- /* IP version 4 */
-@@ -400,12 +404,16 @@
- /* IP version 6 */
- if (olsr_sendto(ifp->olsr_socket, ifp->netbuf.buff, ifp->netbuf.pending, MSG_DONTROUTE, (struct sockaddr *)sin6, sizeof(*sin6))
- < 0) {
-+#ifndef SVEN_OLA_UNBLOAT
- struct ipaddr_str buf;
-+#endif /* SVEN_OLA_UNBLOAT */
- perror("sendto(v6)");
- olsr_syslog(OLSR_LOG_ERR, "OLSR: sendto IPv6 %m");
-+#ifndef SVEN_OLA_UNBLOAT
- fprintf(stderr, "Socket: %d interface: %d\n", ifp->olsr_socket, ifp->if_index);
- fprintf(stderr, "To: %s (size: %u)\n", ip6_to_string(&buf, &sin6->sin6_addr), (unsigned int)sizeof(*sin6));
- fprintf(stderr, "Outputsize: %d\n", ifp->netbuf.pending);
-+#endif /* SVEN_OLA_UNBLOAT */
- retval = -1;
- }
- }
---- a/src/olsr.c
-+++ b/src/olsr.c
-@@ -150,7 +150,9 @@
- return;
-
- if (olsr_cnf->debug_level > 0 && olsr_cnf->clear_screen && isatty(1)) {
-+#ifndef SVEN_OLA_UNBLOAT
- clear_console();
-+#endif /* SVEN_OLA_UNBLOAT */
- printf(" *** %s (%s on %s) ***\n", olsrd_version, build_date, build_host);
- }
-
-@@ -166,7 +168,7 @@
- if (changes_neighborhood || changes_topology || changes_hna) {
- olsr_calculate_routing_table();
- }
--
-+#ifndef SVEN_OLA_UNBLOAT
- if (olsr_cnf->debug_level > 0) {
- if (olsr_cnf->debug_level > 2) {
- olsr_print_mid_set();
-@@ -185,6 +187,7 @@
- olsr_print_tc_table();
- #endif
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- for (tmp_pc_list = pcf_list; tmp_pc_list != NULL; tmp_pc_list = tmp_pc_list->next) {
- tmp_pc_list->function(changes_neighborhood, changes_topology, changes_hna);
-@@ -421,12 +424,15 @@
- uint8_t
- olsr_calculate_willingness(void)
- {
-+#ifndef SVEN_OLA_UNBLOAT
- struct olsr_apm_info ainfo;
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /* If fixed willingness */
- if (!olsr_cnf->willingness_auto)
- return olsr_cnf->willingness;
-
-+#ifndef SVEN_OLA_UNBLOAT
- if (apm_read(&ainfo) < 1)
- return WILL_DEFAULT;
-
-@@ -443,8 +449,12 @@
- * 26% > juice will: 1
- */
- return (ainfo.battery_percentage / 26);
-+#else /* SVEN_OLA_UNBLOAT */
-+ return WILL_DEFAULT;
-+#endif /* SVEN_OLA_UNBLOAT */
- }
-
-+#ifndef SVEN_OLA_UNBLOAT
- const char *
- olsr_msgtype_to_string(uint8_t msgtype)
- {
-@@ -514,6 +524,7 @@
- snprintf(type, sizeof(type), "UNKNOWN(%d)", status);
- return type;
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /**
- *Termination function to be called whenever a error occures
-@@ -542,6 +553,7 @@
- *
- * @return a void pointer to the memory allocated
- */
-+#ifndef SVEN_OLA_UNBLOAT
- void *
- olsr_malloc(size_t size, const char *id)
- {
-@@ -566,6 +578,7 @@
-
- return ptr;
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /**
- *Wrapper for printf that prints to a specific
---- a/src/olsr.h
-+++ b/src/olsr.h
-@@ -72,15 +72,21 @@
-
- uint8_t olsr_calculate_willingness(void);
-
-+#ifndef SVEN_OLA_UNBLOAT
- const char *olsr_msgtype_to_string(uint8_t);
-
- const char *olsr_link_to_string(uint8_t);
-
- const char *olsr_status_to_string(uint8_t);
-+#endif /* SVEN_OLA_UNBLOAT */
-
- void olsr_exit(const char *, int);
-
-+#ifdef SVEN_OLA_UNBLOAT
-+#define olsr_malloc(size, msg) calloc(1, size)
-+#else /* SVEN_OLA_UNBLOAT */
- void *olsr_malloc(size_t, const char *);
-+#endif /* SVEN_OLA_UNBLOAT */
-
- int olsr_printf(int, const char *, ...) __attribute__ ((format(printf, 2, 3)));
-
---- a/src/olsr_cfg.h
-+++ b/src/olsr_cfg.h
-@@ -154,8 +154,10 @@
- char *name;
- char *config;
- bool configured;
-+#ifndef SVEN_OLA_UNBLOAT
- bool host_emul;
- union olsr_ip_addr hemu_ip;
-+#endif /* SVEN_OLA_UNBLOAT */
- struct interface *interf;
- struct if_config_options *cnf;
- struct olsr_if *next;
-@@ -198,7 +200,9 @@
- uint16_t olsrport;
- int debug_level;
- bool no_fork;
-+#ifndef SVEN_OLA_UNBLOAT
- bool host_emul;
-+#endif /* SVEN_OLA_UNBLOAT */
- int ip_version;
- bool allow_no_interfaces;
- uint16_t tos;
-@@ -207,13 +211,17 @@
- uint8_t rttable_default;
- uint8_t willingness;
- bool willingness_auto;
-+#ifndef SVEN_OLA_UNBLOAT
- int ipc_connections;
-+#endif /* SVEN_OLA_UNBLOAT */
- bool use_hysteresis;
- olsr_fib_metric_options fib_metric;
- struct hyst_param hysteresis_param;
- struct plugin_entry *plugins;
- struct ip_prefix_list *hna_entries;
-+#ifndef SVEN_OLA_UNBLOAT
- struct ip_prefix_list *ipc_nets;
-+#endif /* SVEN_OLA_UNBLOAT */
- struct olsr_if *interfaces;
- float pollrate;
- float nic_chgs_pollrate;
-@@ -275,7 +283,9 @@
-
- void olsrd_free_cnf(struct olsrd_config *);
-
-+#ifndef SVEN_OLA_UNBLOAT
- void olsrd_print_cnf(struct olsrd_config *);
-+#endif /* SVEN_OLA_UNBLOAT */
-
- int olsrd_write_cnf(struct olsrd_config *, const char *);
-
---- a/src/parser.c
-+++ b/src/parser.c
-@@ -51,7 +51,9 @@
- #include "rebuild_packet.h"
- #include "net_os.h"
- #include "log.h"
-+#ifndef SVEN_OLA_UNBLOAT
- #include "print_packet.h"
-+#endif /* SVEN_OLA_UNBLOAT */
- #include "net_olsr.h"
-
- #ifdef WIN32
-@@ -281,8 +283,10 @@
- //printf("Message from %s\n\n", olsr_ip_to_string(&buf, from_addr));
-
- /* Display packet */
-+#ifndef SVEN_OLA_UNBLOAT
- if (disp_pack_in)
- print_olsr_serialized_packet(stdout, (union olsr_packet *)olsr, size, from_addr);
-+#endif /* SVEN_OLA_UNBLOAT */
-
- if (olsr_cnf->ip_version == AF_INET)
- msgsize = ntohs(m->v4.olsr_msgsize);
---- a/src/print_packet.c
-+++ b/src/print_packet.c
-@@ -39,6 +39,7 @@
- *
- */
-
-+#ifndef SVEN_OLA_UNBLOAT
- #include "print_packet.h"
- #include "ipcalc.h"
- #include "mantissa.h"
-@@ -339,6 +340,7 @@
- remsize -= olsr_cnf->ipsize;
- }
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /*
- * Local Variables:
---- a/src/process_routes.c
-+++ b/src/process_routes.c
-@@ -158,6 +158,7 @@
- static void
- olsr_delete_kernel_route(struct rt_entry *rt)
- {
-+#ifndef SVEN_OLA_UNBLOAT
- if (!olsr_cnf->host_emul) {
- int16_t error = olsr_cnf->ip_version == AF_INET ? olsr_delroute_function(rt) : olsr_delroute6_function(rt);
-
-@@ -169,6 +170,12 @@
- olsr_syslog(OLSR_LOG_ERR, "Delete route %s: %s", routestr, err_msg);
- }
- }
-+#else /* SVEN_OLA_UNBLOAT */
-+ int16_t error = olsr_cnf->ip_version == AF_INET ? olsr_delroute_function(rt) : olsr_delroute6_function(rt);
-+ if (0 > error) {
-+ olsr_syslog(OLSR_LOG_ERR, "Delete route: %s", strerror(errno));
-+ }
-+#endif /* SVEN_OLA_UNBLOAT */
- }
-
- /**
-@@ -180,6 +187,7 @@
- olsr_add_kernel_route(struct rt_entry *rt)
- {
-
-+#ifndef SVEN_OLA_UNBLOAT
- if (!olsr_cnf->host_emul) {
- int16_t error = (olsr_cnf->ip_version == AF_INET) ? olsr_addroute_function(rt) : olsr_addroute6_function(rt);
-
-@@ -198,6 +206,14 @@
- rt->rt_metric = rt->rt_best->rtp_metric;
- }
- }
-+#else /* SVEN_OLA_UNBLOAT */
-+ int16_t error = olsr_cnf->ip_version == AF_INET ? olsr_addroute_function(rt) : olsr_addroute6_function(rt);
-+ if (0 > error) {
-+ olsr_syslog(OLSR_LOG_ERR, "Add route: %s", strerror(errno));
-+ } else {
-+ rt->rt_nexthop = rt->rt_best->rtp_nexthop;
-+ }
-+#endif /* SVEN_OLA_UNBLOAT */
- }
-
- /**
-@@ -348,9 +364,11 @@
- /* route changes */
- olsr_chg_kernel_routes(&chg_kernel_list);
-
--#if DEBUG
-+#ifndef SVEN_OLA_UNBLOAT
-+#ifdef DEBUG
- olsr_print_routing_table(&routingtree);
- #endif
-+#endif /* SVEN_OLA_UNBLOAT */
- }
-
- /*
---- a/src/rebuild_packet.c
-+++ b/src/rebuild_packet.c
-@@ -60,7 +60,11 @@
- mid_chgestruct(struct mid_message *mmsg, const union olsr_message *m)
- {
- int i;
-+#ifndef SVEN_OLA_UNBLOAT
- struct mid_alias *alias, *alias_tmp;
-+#else /* SVEN_OLA_UNBLOAT */
-+ struct mid_alias *alias;
-+#endif /* SVEN_OLA_UNBLOAT */
- int no_aliases;
-
- /* Checking if everything is ok */
-@@ -100,6 +104,7 @@
- maddr++;
- }
-
-+#ifndef SVEN_OLA_UNBLOAT
- if (olsr_cnf->debug_level > 1) {
- struct ipaddr_str buf;
- OLSR_PRINTF(3, "Alias list for %s: ", olsr_ip_to_string(&buf, &mmsg->mid_origaddr));
-@@ -111,6 +116,7 @@
- }
- OLSR_PRINTF(3, "\n");
- }
-+#endif /* SVEN_OLA_UNBLOAT */
- } else {
- /* IPv6 */
- const struct midaddr6 *maddr6 = m->v6.message.mid.mid_addr;
-@@ -144,6 +150,7 @@
- maddr6++;
- }
-
-+#ifndef SVEN_OLA_UNBLOAT
- if (olsr_cnf->debug_level > 1) {
- struct ipaddr_str buf;
- OLSR_PRINTF(3, "Alias list for %s", ip6_to_string(&buf, &mmsg->mid_origaddr.v6));
-@@ -156,6 +163,7 @@
- }
- OLSR_PRINTF(3, "\n");
- }
-+#endif /* SVEN_OLA_UNBLOAT */
- }
-
- }
---- a/src/routing_table.c
-+++ b/src/routing_table.c
-@@ -628,6 +628,7 @@
- /**
- * format a route entry into a buffer
- */
-+#ifndef SVEN_OLA_UNBLOAT
- char *
- olsr_rt_to_string(const struct rt_entry *rt)
- {
-@@ -659,11 +660,13 @@
-
- return buff;
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /**
- * Print the routingtree to STDOUT
- *
- */
-+#ifndef SVEN_OLA_UNBLOAT
- void
- olsr_print_routing_table(struct avl_tree *tree)
- {
-@@ -697,6 +700,7 @@
- #endif
- tree = NULL; /* squelch compiler warnings */
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /*
- * Local Variables:
---- a/src/routing_table.h
-+++ b/src/routing_table.h
-@@ -210,9 +210,11 @@
- bool olsr_cmp_rt(const struct rt_entry *, const struct rt_entry *);
- uint8_t olsr_fib_metric(const struct rt_metric *);
-
-+#ifndef SVEN_OLA_UNBLOAT
- char *olsr_rt_to_string(const struct rt_entry *);
- char *olsr_rtp_to_string(const struct rt_path *);
- void olsr_print_routing_table(struct avl_tree *);
-+#endif /* SVEN_OLA_UNBLOAT */
-
- const struct rt_nexthop *olsr_get_nh(const struct rt_entry *);
-
---- a/src/tc_set.c
-+++ b/src/tc_set.c
-@@ -336,6 +336,7 @@
- /**
- * Format tc_edge contents into a buffer.
- */
-+#ifndef SVEN_OLA_UNBLOAT
- char *
- olsr_tc_edge_to_string(struct tc_edge_entry *tc_edge)
- {
-@@ -350,6 +351,7 @@
-
- return buf;
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /**
- * Wrapper for the timer callback.
-@@ -693,6 +695,7 @@
- /**
- * Print the topology table to stdout
- */
-+#ifndef SVEN_OLA_UNBLOAT
- void
- olsr_print_tc_table(void)
- {
-@@ -718,6 +721,7 @@
- } OLSR_FOR_ALL_TC_ENTRIES_END(tc);
- #endif
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /*
- * calculate the border IPs of a tc edge set according to the border flags
---- a/src/tc_set.h
-+++ b/src/tc_set.h
-@@ -157,7 +157,9 @@
-
- /* tc_edge_entry manipulation */
- bool olsr_delete_outdated_tc_edges(struct tc_entry *);
-+#ifndef SVEN_OLA_UNBLOAT
- char *olsr_tc_edge_to_string(struct tc_edge_entry *);
-+#endif /* SVEN_OLA_UNBLOAT */
- struct tc_edge_entry *olsr_lookup_tc_edge(struct tc_entry *, union olsr_ip_addr *);
- struct tc_edge_entry *olsr_add_tc_edge_entry(struct tc_entry *, union olsr_ip_addr *, uint16_t);
- void olsr_delete_tc_entry(struct tc_entry *);
---- a/src/two_hop_neighbor_table.c
-+++ b/src/two_hop_neighbor_table.c
-@@ -203,6 +203,8 @@
- return NULL;
- }
-
-+#ifndef SVEN_OLA_UNBLOAT
-+
- /**
- *Print the two hop neighbor table to STDOUT.
- *
-@@ -240,6 +242,7 @@
- }
- #endif
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /*
- * Local Variables:
---- a/src/unix/ifnet.c
-+++ b/src/unix/ifnet.c
-@@ -70,6 +70,8 @@
-
- #define BUFSPACE (127*1024) /* max. input buffer size to request */
-
-+#ifndef SVEN_OLA_UNBLOAT
-+
- int
- set_flag(char *ifname, short flag __attribute__ ((unused)))
- {
-@@ -100,6 +102,8 @@
-
- }
-
-+#endif /* SVEN_OLA_UNBLOAT */
-+
- void
- check_interface_updates(void *foo __attribute__ ((unused)))
- {
-@@ -110,11 +114,13 @@
- #endif
-
- for (tmp_if = olsr_cnf->interfaces; tmp_if != NULL; tmp_if = tmp_if->next) {
-+#ifndef SVEN_OLA_UNBLOAT
- if (tmp_if->host_emul)
- continue;
-
- if (olsr_cnf->host_emul) /* XXX: TEMPORARY! */
- continue;
-+#endif /* SVEN_OLA_UNBLOAT */
-
- if (!tmp_if->cnf->autodetect_chg) {
- #ifdef DEBUG
-@@ -154,8 +160,10 @@
- OLSR_PRINTF(3, "Checking if %s is set down or changed\n", iface->name);
- #endif
-
-+#ifndef SVEN_OLA_UNBLOAT
- if (iface->host_emul)
- return -1;
-+#endif /* SVEN_OLA_UNBLOAT */
-
- ifp = iface->interf;
-
-@@ -278,7 +286,9 @@
- } else
- /* IP version 4 */
- {
-+#ifndef SVEN_OLA_UNBLOAT
- struct ipaddr_str buf;
-+#endif /* SVEN_OLA_UNBLOAT */
- /* Check interface address (IPv4) */
- if (ioctl(olsr_cnf->ioctl_s, SIOCGIFADDR, &ifr) < 0) {
- OLSR_PRINTF(1, "\tCould not get address of interface - removing it\n");
-@@ -291,17 +301,21 @@
- if (memcmp
- (&((struct sockaddr_in *)(ARM_NOWARN_ALIGN)&ifp->int_addr)->sin_addr.s_addr, &((struct sockaddr_in *)(ARM_NOWARN_ALIGN)&ifr.ifr_addr)->sin_addr.s_addr,
- olsr_cnf->ipsize) != 0) {
-+#ifndef SVEN_OLA_UNBLOAT
- /* New address */
- OLSR_PRINTF(1, "IPv4 address changed for %s\n", ifr.ifr_name);
- OLSR_PRINTF(1, "\tOld:%s\n", ip4_to_string(&buf, ifp->int_addr.sin_addr));
- OLSR_PRINTF(1, "\tNew:%s\n", sockaddr4_to_string(&buf, &ifr.ifr_addr));
-+#endif /* SVEN_OLA_UNBLOAT */
-
- ifp->int_addr = *(struct sockaddr_in *)(ARM_NOWARN_ALIGN)&ifr.ifr_addr;
- /* deactivated to prevent change of originator IP */
- #if 0
- if (memcmp(&olsr_cnf->main_addr, &ifp->ip_addr, olsr_cnf->ipsize) == 0) {
- OLSR_PRINTF(1, "New main address: %s\n", sockaddr4_to_string(&buf, &ifr.ifr_addr));
-+#ifndef SVEN_OLA_UNBLOAT
- olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", sockaddr4_to_string(&buf, &ifr.ifr_addr));
-+#endif /* SVEN_OLA_UNBLOAT */
- memcpy(&olsr_cnf->main_addr, &((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr, olsr_cnf->ipsize);
- }
- #endif
-@@ -375,7 +389,9 @@
- ifp = iface->interf;
-
- OLSR_PRINTF(1, "Removing interface %s\n", iface->name);
-+#ifndef SVEN_OLA_UNBLOAT
- olsr_syslog(OLSR_LOG_INFO, "Removing interface %s\n", iface->name);
-+#endif /* SVEN_OLA_UNBLOAT */
-
- olsr_delete_link_entry_by_ip(&ifp->ip_addr);
-
-@@ -417,10 +433,14 @@
- memset(&olsr_cnf->main_addr, 0, olsr_cnf->ipsize);
- OLSR_PRINTF(1, "No more interfaces...\n");
- } else {
-+#if !defined(SVEN_OLA_UNBLOAT)
- struct ipaddr_str buf;
-+#endif /* SVEN_OLA_UNBLOAT */
- olsr_cnf->main_addr = ifnet->ip_addr;
- OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&buf, &olsr_cnf->main_addr));
-+#ifndef SVEN_OLA_UNBLOAT
- olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", olsr_ip_to_string(&buf, &olsr_cnf->main_addr));
-+#endif /* SVEN_OLA_UNBLOAT */
- }
- }
- #endif
-@@ -444,13 +464,17 @@
-
- if ((ifnet == NULL) && (!olsr_cnf->allow_no_interfaces)) {
- OLSR_PRINTF(1, "No more active interfaces - exiting.\n");
-+#ifndef SVEN_OLA_UNBLOAT
- olsr_syslog(OLSR_LOG_INFO, "No more active interfaces - exiting.\n");
-+#endif /* SVEN_OLA_UNBLOAT */
- olsr_cnf->exit_value = EXIT_FAILURE;
- kill(getpid(), SIGINT);
- }
-
- }
-
-+#ifndef SVEN_OLA_UNBLOAT
-+
- /**
- * Initializes the special interface used in
- * host-client emulation
-@@ -602,6 +626,7 @@
-
- return 1;
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- static char basenamestr[32];
- static const char *if_basename(const char *name);
-@@ -637,8 +662,10 @@
- int tos_bits = IPTOS_TOS(olsr_cnf->tos);
- #endif
-
-+#ifndef SVEN_OLA_UNBLOAT
- if (iface->host_emul)
- return -1;
-+#endif /* SVEN_OLA_UNBLOAT */
-
- memset(&ifr, 0, sizeof(struct ifreq));
- memset(&ifs, 0, sizeof(struct interface));
-@@ -745,11 +772,13 @@
- ifs.int_broadaddr = *(struct sockaddr_in *)(ARM_NOWARN_ALIGN)&ifr.ifr_broadaddr;
- }
-
-+#ifndef SVEN_OLA_UNBLOAT
- /* Deactivate IP spoof filter */
- deactivate_spoof(if_basename(ifr.ifr_name), &ifs, olsr_cnf->ip_version);
-
- /* Disable ICMP redirects */
- disable_redirects(if_basename(ifr.ifr_name), &ifs, olsr_cnf->ip_version);
-+#endif /* SVEN_OLA_UNBLOAT */
-
- }
-
-@@ -779,7 +808,9 @@
-
- OLSR_PRINTF(1, "\tMTU - IPhdr: %d\n", ifs.int_mtu);
-
-+#ifndef SVEN_OLA_UNBLOAT
- olsr_syslog(OLSR_LOG_INFO, "Adding interface %s\n", iface->name);
-+#endif /* SVEN_OLA_UNBLOAT */
- OLSR_PRINTF(1, "\tIndex %d\n", ifs.if_index);
-
- if (olsr_cnf->ip_version == AF_INET) {
-@@ -884,10 +915,14 @@
- */
- memset(&null_addr, 0, olsr_cnf->ipsize);
- if (ipequal(&null_addr, &olsr_cnf->main_addr)) {
-+#ifndef SVEN_OLA_UNBLOAT
- struct ipaddr_str buf;
-+#endif
- olsr_cnf->main_addr = ifp->ip_addr;
-+#ifndef SVEN_OLA_UNBLOAT
- OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&buf, &olsr_cnf->main_addr));
- olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", olsr_ip_to_string(&buf, &olsr_cnf->main_addr));
-+#endif /* SVEN_OLA_UNBLOAT */
- }
-
- /*
---- a/src/unix/misc.c
-+++ b/src/unix/misc.c
-@@ -44,6 +44,7 @@
- #include "misc.h"
- #include "olsr_types.h"
-
-+#ifndef SVEN_OLA_UNBLOAT
- void
- clear_console(void)
- {
-@@ -69,6 +70,7 @@
-
- fflush(stdout);
- }
-+#endif /* SVEN_OLA_UNBLOAT */
-
- /*
- * Local Variables:
diff --git a/contrib/package/olsrd-luci/patches/160-add-mdns.patch b/contrib/package/olsrd-luci/patches/160-add-mdns.patch
deleted file mode 100644
index 0030611194..0000000000
--- a/contrib/package/olsrd-luci/patches/160-add-mdns.patch
+++ /dev/null
@@ -1,4408 +0,0 @@
---- a/Makefile
-+++ b/Makefile
-@@ -154,7 +154,7 @@
- # nameservice: no regex
- SUBDIRS := bmf dot_draw dyn_gw_plain httpinfo mini quagga secure tas txtinfo watchdog
- else
--SUBDIRS := bmf dot_draw dyn_gw dyn_gw_plain httpinfo mini nameservice pgraph secure txtinfo watchdog
-+SUBDIRS := bmf dot_draw dyn_gw dyn_gw_plain httpinfo mini nameservice pgraph secure txtinfo watchdog mdns
- endif
- endif
- endif
-@@ -241,6 +241,11 @@
- $(MAKECMD) -C lib/watchdog
- $(MAKECMD) -C lib/watchdog DESTDIR=$(DESTDIR) install
-
-+mdns:
-+ $(MAKECMD) -C lib/mdns clean
-+ $(MAKECMD) -C lib/mdns
-+ $(MAKECMD) -C lib/mdns DESTDIR=$(DESTDIR) install
-+
- build_all: all switch libs
- install_all: install install_libs
- clean_all: uberclean clean_libs
---- /dev/null
-+++ b/lib/mdns/Makefile
-@@ -0,0 +1,66 @@
-+#
-+# OLSR Basic Multicast Forwarding (BMF) plugin.
-+# Copyright (c) 2005, 2006, Thales Communications, Huizen, The Netherlands.
-+# Written by Erik Tromp.
-+# All rights reserved.
-+#
-+# Redistribution and use in source and binary forms, with or without
-+# modification, are permitted provided that the following conditions
-+# are met:
-+#
-+# * Redistributions of source code must retain the above copyright
-+# notice, this list of conditions and the following disclaimer.
-+# * Redistributions in binary form must reproduce the above copyright
-+# notice, this list of conditions and the following disclaimer in
-+# the documentation and/or other materials provided with the
-+# distribution.
-+# * Neither the name of Thales, BMF nor the names of its
-+# contributors may be used to endorse or promote products derived
-+# from this software without specific prior written permission.
-+#
-+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-+# POSSIBILITY OF SUCH DAMAGE.
-+#
-+
-+OLSRD_PLUGIN = true
-+PLUGIN_NAME = olsrd_mdns
-+PLUGIN_VER = 1.0.0
-+
-+TOPDIR = ../..
-+include $(TOPDIR)/Makefile.inc
-+
-+LIBS += $(OS_LIB_PTHREAD)
-+
-+# Must be specified along with -lpthread on linux
-+CPPFLAGS += $(OS_CFLAG_PTHREAD)
-+
-+ifneq ($(OS),linux)
-+
-+default_target install clean:
-+ @echo "*** BMF Plugin only supported on Linux, sorry!"
-+
-+else
-+
-+default_target: $(PLUGIN_FULLNAME)
-+
-+$(PLUGIN_FULLNAME): $(OBJS) version-script.txt
-+ $(CC) $(LDFLAGS) -o $(PLUGIN_FULLNAME) $(OBJS) $(LIBS)
-+
-+install: $(PLUGIN_FULLNAME)
-+ $(STRIP) $(PLUGIN_FULLNAME)
-+ $(INSTALL_LIB)
-+
-+clean:
-+ rm -f $(OBJS) $(SRCS:%.c=%.d) $(PLUGIN_FULLNAME)
-+
-+endif
---- /dev/null
-+++ b/lib/mdns/src/Address.c
-@@ -0,0 +1,164 @@
-+/*
-+ * OLSR Basic Multicast Forwarding (BMF) plugin.
-+ * Copyright (c) 2005 - 2007, Thales Communications, Huizen, The Netherlands.
-+ * Written by Erik Tromp.
-+ * All rights reserved.
-+ *
-+ * Redistribution and use in source and binary forms, with or without
-+ * modification, are permitted provided that the following conditions
-+ * are met:
-+ *
-+ * * Redistributions of source code must retain the above copyright
-+ * notice, this list of conditions and the following disclaimer.
-+ * * Redistributions in binary form must reproduce the above copyright
-+ * notice, this list of conditions and the following disclaimer in
-+ * the documentation and/or other materials provided with the
-+ * distribution.
-+ * * Neither the name of Thales, BMF nor the names of its
-+ * contributors may be used to endorse or promote products derived
-+ * from this software without specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
-+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-+ * OF THE POSSIBILITY OF SUCH DAMAGE.
-+ */
-+
-+/* -------------------------------------------------------------------------
-+ * File : Address.c
-+ * Description: IP packet characterization functions
-+ * Created : 29 Jun 2006
-+ *
-+ * ------------------------------------------------------------------------- */
-+
-+#include "Address.h"
-+
-+/* System includes */
-+#include <stddef.h> /* NULL */
-+#include <string.h> /* strcmp */
-+#include <assert.h> /* assert() */
-+#include <netinet/ip.h> /* struct ip */
-+#include <netinet/udp.h> /* struct udphdr */
-+
-+/* OLSRD includes */
-+#include "defs.h" /* ipequal */
-+#include "olsr_protocol.h" /* OLSRPORT */
-+
-+/* Plugin includes */
-+#include "mdns.h" /* BMF_ENCAP_PORT */
-+#include "NetworkInterfaces.h" /* TBmfInterface */
-+
-+/* Whether or not to flood local broadcast packets (e.g. packets with IP
-+ * destination 192.168.1.255). May be overruled by setting the plugin
-+ * parameter "DoLocalBroadcast" to "no" */
-+int EnableLocalBroadcast = 1;
-+
-+/* -------------------------------------------------------------------------
-+ * Function : DoLocalBroadcast
-+ * Description: Overrule the default setting, enabling or disabling the
-+ * flooding of local broadcast packets
-+ * Input : enable - either "yes" or "no"
-+ * data - not used
-+ * addon - not used
-+ * Output : none
-+ * Return : success (0) or fail (1)
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+int DoLocalBroadcast(
-+ const char* enable,
-+ void* data __attribute__((unused)),
-+ set_plugin_parameter_addon addon __attribute__((unused)))
-+{
-+ if (strcmp(enable, "yes") == 0)
-+ {
-+ EnableLocalBroadcast = 1;
-+ return 0;
-+ }
-+ else if (strcmp(enable, "no") == 0)
-+ {
-+ EnableLocalBroadcast = 0;
-+ return 0;
-+ }
-+
-+ /* Value not recognized */
-+ return 1;
-+}
-+
-+/* -------------------------------------------------------------------------
-+ * Function : IsMulticast
-+ * Description: Check if an IP address is a multicast address
-+ * Input : ipAddress
-+ * Output : none
-+ * Return : true (1) or false (0)
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+int IsMulticast(union olsr_ip_addr* ipAddress)
-+{
-+ assert(ipAddress != NULL);
-+
-+ return (ntohl(ipAddress->v4.s_addr) & 0xF0000000) == 0xE0000000;
-+}
-+
-+/* -------------------------------------------------------------------------
-+ * Function : IsOlsrOrBmfPacket
-+ * Description: Check if an IP packet is either an OLSR packet or a BMF packet
-+ * Input : ipPacket
-+ * Output : none
-+ * Return : true (1) or false (0)
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+//int IsOlsrOrBmfPacket(unsigned char* ipPacket)
-+//{//MODIFICATA
-+// struct ip* ipHeader;
-+// unsigned int ipHeaderLen;
-+// struct udphdr* udpHeader;
-+// u_int16_t destPort;
-+//
-+// assert(ipPacket != NULL);
-+//
-+// /* OLSR packets are UDP - port 698
-+// * OLSR-BMF packets are UDP - port 50698
-+// * OLSR-Autodetect probe packets are UDP - port 51698 */
-+//
-+// /* Check if UDP */
-+// ipHeader = (struct ip*) ipPacket;
-+// if (ipHeader->ip_p != SOL_UDP)
-+// {
-+// /* Not UDP */
-+// return 0;
-+// }
-+//
-+// /* The total length must be at least large enough to store the UDP header */
-+// ipHeaderLen = GetIpHeaderLength(ipPacket);
-+// if (GetIpTotalLength(ipPacket) < ipHeaderLen + sizeof(struct udphdr))
-+// {
-+// /* Not long enough */
-+// return 0;
-+// }
-+//
-+// /* Go into the UDP header and check port number */
-+// udpHeader = (struct udphdr*) (ipPacket + ipHeaderLen);
-+// destPort = ntohs(udpHeader->dest);
-+//
-+// //if (destPort == OLSRPORT || destPort == BMF_ENCAP_PORT || destPort == 51698)
-+// if (destPort == 5353)
-+// /* TODO: #define for 51698 */
-+// {
-+// return 1;
-+// }
-+//
-+// return 0;
-+//}
-+//
-+/*
-+ * Local Variables:
-+ * c-basic-offset: 2
-+ * indent-tabs-mode: nil
-+ * End:
-+ */
---- /dev/null
-+++ b/lib/mdns/src/Address.h
-@@ -0,0 +1,62 @@
-+#ifndef _BMF_ADDRESS_H
-+#define _BMF_ADDRESS_H
-+
-+/*
-+ * OLSR Basic Multicast Forwarding (BMF) plugin.
-+ * Copyright (c) 2005 - 2007, Thales Communications, Huizen, The Netherlands.
-+ * Written by Erik Tromp.
-+ * All rights reserved.
-+ *
-+ * Redistribution and use in source and binary forms, with or without
-+ * modification, are permitted provided that the following conditions
-+ * are met:
-+ *
-+ * * Redistributions of source code must retain the above copyright
-+ * notice, this list of conditions and the following disclaimer.
-+ * * Redistributions in binary form must reproduce the above copyright
-+ * notice, this list of conditions and the following disclaimer in
-+ * the documentation and/or other materials provided with the
-+ * distribution.
-+ * * Neither the name of Thales, BMF nor the names of its
-+ * contributors may be used to endorse or promote products derived
-+ * from this software without specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
-+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-+ * OF THE POSSIBILITY OF SUCH DAMAGE.
-+ */
-+
-+/* -------------------------------------------------------------------------
-+ * File : Address.h
-+ * Description: IP packet characterization functions
-+ * Created : 29 Jun 2006
-+ *
-+ * ------------------------------------------------------------------------- */
-+
-+#include "olsr_types.h" /* olsr_ip_addr */
-+#include "olsrd_plugin.h" /* union set_plugin_parameter_addon */
-+#include "interfaces.h" /* struct interface */
-+
-+struct TBmfInterface;
-+
-+extern int EnableLocalBroadcast;
-+
-+int DoLocalBroadcast(const char* enable, void* data, set_plugin_parameter_addon addon);
-+int IsMulticast(union olsr_ip_addr* ipAddress);
-+int IsOlsrOrBmfPacket(unsigned char* ipPacket);
-+
-+#endif /* _BMF_ADDRESS_H */
-+
-+/*
-+ * Local Variables:
-+ * c-basic-offset: 2
-+ * indent-tabs-mode: nil
-+ * End:
-+ */
---- /dev/null
-+++ b/lib/mdns/src/NetworkInterfaces.c
-@@ -0,0 +1,1703 @@
-+/*
-+ * OLSR Basic Multicast Forwarding (BMF) plugin.
-+ * Copyright (c) 2005 - 2007, Thales Communications, Huizen, The Netherlands.
-+ * Written by Erik Tromp.
-+ * All rights reserved.
-+ *
-+ * Redistribution and use in source and binary forms, with or without
-+ * modification, are permitted provided that the following conditions
-+ * are met:
-+ *
-+ * * Redistributions of source code must retain the above copyright
-+ * notice, this list of conditions and the following disclaimer.
-+ * * Redistributions in binary form must reproduce the above copyright
-+ * notice, this list of conditions and the following disclaimer in
-+ * the documentation and/or other materials provided with the
-+ * distribution.
-+ * * Neither the name of Thales, BMF nor the names of its
-+ * contributors may be used to endorse or promote products derived
-+ * from this software without specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
-+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-+ * OF THE POSSIBILITY OF SUCH DAMAGE.
-+ */
-+
-+/* -------------------------------------------------------------------------
-+ * File : NetworkInterfaces.c
-+ * Description: Functions to open and close sockets
-+ * Created : 29 Jun 2006
-+ *
-+ * ------------------------------------------------------------------------- */
-+
-+#include "NetworkInterfaces.h"
-+
-+/* System includes */
-+#include <stddef.h> /* NULL */
-+#include <syslog.h> /* syslog() */
-+#include <string.h> /* strerror(), strchr(), strcmp() */
-+#include <errno.h> /* errno */
-+#include <unistd.h> /* close() */
-+#include <sys/ioctl.h> /* ioctl() */
-+#include <fcntl.h> /* fcntl() */
-+#include <assert.h> /* assert() */
-+#include <net/if.h> /* socket(), ifreq, if_indextoname(), if_nametoindex() */
-+#include <netinet/in.h> /* htons() */
-+#include <linux/if_ether.h> /* ETH_P_IP */
-+#include <linux/if_packet.h> /* packet_mreq, PACKET_MR_PROMISC, PACKET_ADD_MEMBERSHIP */
-+#include <linux/if_tun.h> /* IFF_TAP */
-+#include <netinet/ip.h> /* struct ip */
-+#include <netinet/udp.h> /* SOL_UDP */
-+#include <stdlib.h> /* atoi, malloc */
-+
-+/* OLSRD includes */
-+#include "olsr.h" /* OLSR_PRINTF() */
-+#include "ipcalc.h"
-+#include "defs.h" /* olsr_cnf */
-+#include "link_set.h" /* get_link_set() */
-+#include "tc_set.h" /* olsr_lookup_tc_entry(), olsr_lookup_tc_edge() */
-+#include "net_olsr.h" /* ipequal */
-+#include "lq_plugin.h"
-+
-+
-+/* Plugin includes */
-+#include "Packet.h" /* IFHWADDRLEN */
-+#include "mdns.h" /* PLUGIN_NAME, MainAddressOf() */
-+#include "Address.h" /* IsMulticast() */
-+
-+/* List of network interface objects used by BMF plugin */
-+struct TBmfInterface* BmfInterfaces = NULL;
-+struct TBmfInterface* LastBmfInterface = NULL;
-+
-+/* Highest-numbered open socket file descriptor. To be used as first
-+ * parameter in calls to select(...). */
-+int HighestSkfd = -1;
-+
-+/* Set of socket file descriptors */
-+fd_set InputSet;
-+
-+/* File descriptor of EtherTunTap interface */
-+int EtherTunTapFd = -1;
-+
-+/* Network interface name of EtherTunTap interface. May be overruled by
-+ * setting the plugin parameter "BmfInterface". */
-+char EtherTunTapIfName[IFNAMSIZ] = "bmf0";
-+
-+/* The underlying mechanism to forward multicast packets. Either:
-+ * - BM_BROADCAST: BMF uses the IP local broadcast as destination address
-+ * - BM_UNICAST_PROMISCUOUS: BMF uses the IP address of the best neighbor as
-+ * destination address. The other neighbors listen promiscuously. */
-+enum TBmfMechanism BmfMechanism = BM_BROADCAST;
-+
-+#define ETHERTUNTAPIPNOTSET 0
-+
-+/* The IP address of the BMF network interface in host byte order.
-+ * May be overruled by setting the plugin parameter "BmfInterfaceIp". */
-+u_int32_t EtherTunTapIp = ETHERTUNTAPIPNOTSET;
-+
-+/* 255.255.255.255 in host byte order. May be overruled by
-+ * setting the plugin parameter "BmfInterfaceIp". */
-+u_int32_t EtherTunTapIpMask = 0xFFFFFFFF;
-+
-+/* The IP broadcast address of the BMF network interface in host byte order.
-+ * May be overruled by setting the plugin parameter "BmfinterfaceIp". */
-+u_int32_t EtherTunTapIpBroadcast = ETHERTUNTAPIPNOTSET;
-+
-+/* Whether or not the configuration has overruled the default IP
-+ * configuration of the EtherTunTap interface */
-+int TunTapIpOverruled = 0;
-+
-+/* Whether or not to capture packets on the OLSR-enabled
-+ * interfaces (in promiscuous mode). May be overruled by setting the plugin
-+ * parameter "CapturePacketsOnOlsrInterfaces" to "yes". */
-+int CapturePacketsOnOlsrInterfaces = 0;
-+
-+/* -------------------------------------------------------------------------
-+ * Function : SetBmfInterfaceName
-+ * Description: Overrule the default network interface name ("bmf0") of the
-+ * EtherTunTap interface
-+ * Input : ifname - network interface name (e.g. "mybmf0")
-+ * data - not used
-+ * addon - not used
-+ * Output : none
-+ * Return : success (0) or fail (1)
-+ * Data Used : EtherTunTapIfName
-+ * ------------------------------------------------------------------------- */
-+int SetBmfInterfaceName(
-+ const char* ifname,
-+ void* data __attribute__((unused)),
-+ set_plugin_parameter_addon addon __attribute__((unused)))
-+{
-+ strncpy(EtherTunTapIfName, ifname, IFNAMSIZ - 1);
-+ EtherTunTapIfName[IFNAMSIZ - 1] = '\0'; /* Ensures null termination */
-+ return 0;
-+} /* SetBmfInterfaceName */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : SetBmfInterfaceIp
-+ * Description: Overrule the default IP address and prefix length
-+ * ("10.255.255.253/30") of the EtherTunTap interface
-+ * Input : ip - IP address string, followed by '/' and prefix length
-+ * data - not used
-+ * addon - not used
-+ * Output : none
-+ * Return : success (0) or fail (1)
-+ * Data Used : EtherTunTapIp, EtherTunTapIpMask, EtherTunTapIpBroadcast,
-+ * TunTapIpOverruled
-+ * ------------------------------------------------------------------------- */
-+int SetBmfInterfaceIp(
-+ const char* ip,
-+ void* data __attribute__((unused)),
-+ set_plugin_parameter_addon addon __attribute__((unused)))
-+{
-+#define IPV4_MAX_ADDRLEN 16
-+#define IPV4_MAX_PREFIXLEN 32
-+ char* slashAt;
-+ char ipAddr[IPV4_MAX_ADDRLEN];
-+ struct in_addr sinaddr;
-+ int prefixLen;
-+ int i;
-+
-+ /* Inspired by function str2prefix_ipv4 as found in Quagga source
-+ * file lib/prefix.c */
-+
-+ /* Find slash inside string. */
-+ slashAt = strchr(ip, '/');
-+
-+ /* String doesn't contain slash. */
-+ if (slashAt == NULL || slashAt - ip >= IPV4_MAX_ADDRLEN)
-+ {
-+ /* No prefix length specified, or IP address too long */
-+ return 1;
-+ }
-+
-+ strncpy(ipAddr, ip, slashAt - ip);
-+ *(ipAddr + (slashAt - ip)) = '\0';
-+ if (inet_aton(ipAddr, &sinaddr) == 0)
-+ {
-+ /* Invalid address passed */
-+ return 1;
-+ }
-+
-+ EtherTunTapIp = ntohl(sinaddr.s_addr);
-+
-+ /* Get prefix length. */
-+ prefixLen = atoi(++slashAt);
-+ if (prefixLen <= 0 || prefixLen > IPV4_MAX_PREFIXLEN)
-+ {
-+ return 1;
-+ }
-+
-+ /* Compose IP subnet mask in host byte order */
-+ EtherTunTapIpMask = 0;
-+ for (i = 0; i < prefixLen; i++)
-+ {
-+ EtherTunTapIpMask |= (1 << (IPV4_MAX_PREFIXLEN - 1 - i));
-+ }
-+
-+ /* Compose IP broadcast address in host byte order */
-+ EtherTunTapIpBroadcast = EtherTunTapIp;
-+ for (i = prefixLen; i < IPV4_MAX_PREFIXLEN; i++)
-+ {
-+ EtherTunTapIpBroadcast |= (1 << (IPV4_MAX_PREFIXLEN - 1 - i));
-+ }
-+
-+ TunTapIpOverruled = 1;
-+
-+ return 0;
-+} /* SetBmfInterfaceIp */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : SetCapturePacketsOnOlsrInterfaces
-+ * Description: Overrule the default setting, enabling or disabling the
-+ * capturing of packets on OLSR-enabled interfaces.
-+ * Input : enable - either "yes" or "no"
-+ * data - not used
-+ * addon - not used
-+ * Output : none
-+ * Return : success (0) or fail (1)
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+int SetCapturePacketsOnOlsrInterfaces(
-+ const char* enable,
-+ void* data __attribute__((unused)),
-+ set_plugin_parameter_addon addon __attribute__((unused)))
-+{
-+ if (strcmp(enable, "yes") == 0)
-+ {
-+ CapturePacketsOnOlsrInterfaces = 1;
-+ return 0;
-+ }
-+ else if (strcmp(enable, "no") == 0)
-+ {
-+ CapturePacketsOnOlsrInterfaces = 0;
-+ return 0;
-+ }
-+
-+ /* Value not recognized */
-+ return 1;
-+} /* SetCapturePacketsOnOlsrInterfaces */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : SetBmfMechanism
-+ * Description: Overrule the default BMF mechanism to either BM_BROADCAST or
-+ * BM_UNICAST_PROMISCUOUS.
-+ * Input : mechanism - either "Broadcast" or "UnicastPromiscuous"
-+ * data - not used
-+ * addon - not used
-+ * Output : none
-+ * Return : success (0) or fail (1)
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+int SetBmfMechanism(
-+ const char* mechanism,
-+ void* data __attribute__((unused)),
-+ set_plugin_parameter_addon addon __attribute__((unused)))
-+{
-+ if (strcmp(mechanism, "Broadcast") == 0)
-+ {
-+ BmfMechanism = BM_BROADCAST;
-+ return 0;
-+ }
-+ else if (strcmp(mechanism, "UnicastPromiscuous") == 0)
-+ {
-+ BmfMechanism = BM_UNICAST_PROMISCUOUS;
-+ return 0;
-+ }
-+
-+ /* Value not recognized */
-+ return 1;
-+} /* SetBmfMechanism */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : AddDescriptorToInputSet
-+ * Description: Add a socket descriptor to the global set of socket file descriptors
-+ * Input : skfd - socket file descriptor
-+ * Output : none
-+ * Return : none
-+ * Data Used : HighestSkfd, InputSet
-+ * Notes : Keeps track of the highest-numbered descriptor
-+ * ------------------------------------------------------------------------- */
-+static void AddDescriptorToInputSet(int skfd)
-+{
-+ /* Keep the highest-numbered descriptor */
-+ if (skfd > HighestSkfd)
-+ {
-+ HighestSkfd = skfd;
-+ }
-+
-+ /* Add descriptor to input set */
-+ FD_SET(skfd, &InputSet);
-+} /* AddDescriptorToInputSet */
-+
-+/* To save the state of the IP spoof filter for the EtherTunTap interface */
-+static char EthTapSpoofState = '1';
-+
-+/* -------------------------------------------------------------------------
-+ * Function : DeactivateSpoofFilter
-+ * Description: Deactivates the Linux anti-spoofing filter for the tuntap
-+ * interface
-+ * Input : none
-+ * Output : none
-+ * Return : fail (0) or success (1)
-+ * Data Used : EtherTunTapIfName, EthTapSpoofState
-+ * Notes : Saves the current filter state for later restoring
-+ * ------------------------------------------------------------------------- */
-+int DeactivateSpoofFilter(void)
-+{
-+ FILE* procSpoof;
-+ char procFile[FILENAME_MAX];
-+
-+ /* Generate the procfile name */
-+ sprintf(procFile, "/proc/sys/net/ipv4/conf/%s/rp_filter", EtherTunTapIfName);
-+
-+ /* Open procfile for reading */
-+ procSpoof = fopen(procFile, "r");
-+ if (procSpoof == NULL)
-+ {
-+ fprintf(
-+ stderr,
-+ "WARNING! Could not open the %s file to check/disable the IP spoof filter!\n"
-+ "Are you using the procfile filesystem?\n"
-+ "Does your system support IPv4?\n"
-+ "I will continue (in 3 sec) - but you should manually ensure that IP spoof\n"
-+ "filtering is disabled!\n\n",
-+ procFile);
-+
-+ sleep(3);
-+ return 0;
-+ }
-+
-+ EthTapSpoofState = fgetc(procSpoof);
-+ fclose(procSpoof);
-+
-+ /* Open procfile for writing */
-+ procSpoof = fopen(procFile, "w");
-+ if (procSpoof == NULL)
-+ {
-+ fprintf(stderr, "Could not open %s for writing!\n", procFile);
-+ fprintf(
-+ stderr,
-+ "I will continue (in 3 sec) - but you should manually ensure that IP"
-+ " spoof filtering is disabled!\n\n");
-+ sleep(3);
-+ return 0;
-+ }
-+
-+ syslog(LOG_INFO, "Writing \"0\" to %s", procFile);
-+ fputs("0", procSpoof);
-+
-+ fclose(procSpoof);
-+
-+ return 1;
-+} /* DeactivateSpoofFilter */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : RestoreSpoofFilter
-+ * Description: Restores the Linux anti-spoofing filter setting for the tuntap
-+ * interface
-+ * Input : none
-+ * Output : none
-+ * Return : none
-+ * Data Used : EtherTunTapIfName, EthTapSpoofState
-+ * ------------------------------------------------------------------------- */
-+void RestoreSpoofFilter(void)
-+{
-+ FILE* procSpoof;
-+ char procFile[FILENAME_MAX];
-+
-+ /* Generate the procfile name */
-+ sprintf(procFile, "/proc/sys/net/ipv4/conf/%s/rp_filter", EtherTunTapIfName);
-+
-+ /* Open procfile for writing */
-+ procSpoof = fopen(procFile, "w");
-+ if (procSpoof == NULL)
-+ {
-+ fprintf(stderr, "Could not open %s for writing!\nSettings not restored!\n", procFile);
-+ }
-+ else
-+ {
-+ syslog(LOG_INFO, "Resetting %s to %c\n", procFile, EthTapSpoofState);
-+
-+ fputc(EthTapSpoofState, procSpoof);
-+ fclose(procSpoof);
-+ }
-+} /* RestoreSpoofFilter */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : FindNeighbors
-+ * Description: Find the neighbors on a network interface to forward a BMF
-+ * packet to
-+ * Input : intf - the network interface
-+ * source - the source IP address of the BMF packet
-+ * forwardedBy - the IP address of the node that forwarded the BMF
-+ * packet
-+ * forwardedTo - the IP address of the node to which the BMF packet
-+ * was directed
-+ * Output : neighbors - list of (up to a number of 'FanOutLimit') neighbors.
-+ * bestNeighbor - the best neighbor (in terms of lowest cost or ETX
-+ * value)
-+ * nPossibleNeighbors - number of found possible neighbors
-+ * Data Used : FanOutLimit
-+ * ------------------------------------------------------------------------- */
-+//void FindNeighbors(
-+// struct TBestNeighbors* neighbors,
-+// struct link_entry** bestNeighbor,
-+// struct TBmfInterface* intf,
-+// union olsr_ip_addr* source,
-+// union olsr_ip_addr* forwardedBy,
-+// union olsr_ip_addr* forwardedTo,
-+// int* nPossibleNeighbors)
-+//{
-+// struct link_entry* walker;
-+// olsr_linkcost previousLinkEtx = LINK_COST_BROKEN;
-+// olsr_linkcost bestEtx = LINK_COST_BROKEN;
-+//
-+// int i;
-+//
-+// /* Initialize */
-+// *bestNeighbor = NULL;
-+// for (i = 0; i < MAX_UNICAST_NEIGHBORS; i++)
-+// {
-+// neighbors->links[i] = NULL;
-+// }
-+// *nPossibleNeighbors = 0;
-+//
-+// if (forwardedBy != NULL)
-+// {
-+// /* Retrieve the cost of the link from 'forwardedBy' to myself */
-+// struct link_entry* bestLinkFromForwarder = get_best_link_to_neighbor(forwardedBy);
-+// if (bestLinkFromForwarder != NULL)
-+// {
-+// previousLinkEtx = bestLinkFromForwarder->linkcost;
-+// }
-+// }
-+//
-+// OLSR_FOR_ALL_LINK_ENTRIES(walker) {
-+// struct ipaddr_str buf;
-+// union olsr_ip_addr* neighborMainIp;
-+// struct link_entry* bestLinkToNeighbor;
-+// struct tc_entry* tcLastHop;
-+// float currEtx;
-+//
-+// /* Consider only links from the specified interface */
-+// if (! olsr_ipequal(&intf->intAddr, &walker->local_iface_addr))
-+// {
-+// continue; /* for */
-+// }
-+//
-+// OLSR_PRINTF(
-+// 9,
-+// "%s: ----> Considering forwarding pkt on \"%s\" to %s\n",
-+// PLUGIN_NAME_SHORT,
-+// intf->ifName,
-+// olsr_ip_to_string(&buf, &walker->neighbor_iface_addr));
-+//
-+// neighborMainIp = MainAddressOf(&walker->neighbor_iface_addr);
-+//
-+// /* Consider only neighbors with an IP address that differs from the
-+// * passed IP addresses (if passed). Rely on short-circuit boolean evaluation. */
-+// if (source != NULL && olsr_ipequal(neighborMainIp, MainAddressOf(source)))
-+// {
-+// OLSR_PRINTF(
-+// 9,
-+// "%s: ----> Not forwarding to %s: is source of pkt\n",
-+// PLUGIN_NAME_SHORT,
-+// olsr_ip_to_string(&buf, &walker->neighbor_iface_addr));
-+//
-+// continue; /* for */
-+// }
-+//
-+// /* Rely on short-circuit boolean evaluation */
-+// if (forwardedBy != NULL && olsr_ipequal(neighborMainIp, MainAddressOf(forwardedBy)))
-+// {
-+// OLSR_PRINTF(
-+// 9,
-+// "%s: ----> Not forwarding to %s: is the node that forwarded the pkt\n",
-+// PLUGIN_NAME_SHORT,
-+// olsr_ip_to_string(&buf, &walker->neighbor_iface_addr));
-+//
-+// continue; /* for */
-+// }
-+//
-+// /* Rely on short-circuit boolean evaluation */
-+// if (forwardedTo != NULL && olsr_ipequal(neighborMainIp, MainAddressOf(forwardedTo)))
-+// {
-+// OLSR_PRINTF(
-+// 9,
-+// "%s: ----> Not forwarding to %s: is the node to which the pkt was forwarded\n",
-+// PLUGIN_NAME_SHORT,
-+// olsr_ip_to_string(&buf, &walker->neighbor_iface_addr));
-+//
-+// continue; /* for */
-+// }
-+//
-+// /* Found a candidate neighbor to direct our packet to */
-+//
-+// /* Calculate the link quality (ETX) of the link to the found neighbor */
-+// currEtx = walker->linkcost;
-+//
-+// if (currEtx >= LINK_COST_BROKEN)
-+// {
-+// OLSR_PRINTF(
-+// 9,
-+// "%s: ----> Not forwarding to %s: link is timing out\n",
-+// PLUGIN_NAME_SHORT,
-+// olsr_ip_to_string(&buf, &walker->neighbor_iface_addr));
-+//
-+// continue; /* for */
-+// }
-+//
-+// /* Compare costs to check if the candidate neighbor is best reached via 'intf' */
-+// OLSR_PRINTF(
-+// 9,
-+// "%s: ----> Forwarding pkt to %s will cost ETX %5.2f\n",
-+// PLUGIN_NAME_SHORT,
-+// olsr_ip_to_string(&buf, &walker->neighbor_iface_addr),
-+// currEtx);
-+//
-+// /*
-+// * If the candidate neighbor is best reached via another interface, then skip
-+// * the candidate neighbor; the candidate neighbor has been / will be selected via that
-+// * other interface.
-+// */
-+// bestLinkToNeighbor = get_best_link_to_neighbor(&walker->neighbor_iface_addr);
-+//
-+// if (walker != bestLinkToNeighbor)
-+// {
-+// if (bestLinkToNeighbor == NULL)
-+// {
-+// OLSR_PRINTF(
-+// 9,
-+// "%s: ----> Not forwarding to %s: no link found\n",
-+// PLUGIN_NAME_SHORT,
-+// olsr_ip_to_string(&buf, &walker->neighbor_iface_addr));
-+// }
-+// else
-+// {
-+//#ifndef NODEBUG
-+// struct interface* bestIntf = if_ifwithaddr(&bestLinkToNeighbor->local_iface_addr);
-+// struct lqtextbuffer lqbuffer;
-+//#endif
-+// OLSR_PRINTF(
-+// 9,
-+// "%s: ----> Not forwarding to %s: \"%s\" gives a better link to this neighbor, costing %s\n",
-+// PLUGIN_NAME_SHORT,
-+// olsr_ip_to_string(&buf, &walker->neighbor_iface_addr),
-+// bestIntf->int_name,
-+// get_linkcost_text(bestLinkToNeighbor->linkcost, 0, &lqbuffer));
-+// }
-+//
-+// continue; /* for */
-+// }
-+//
-+// if (forwardedBy != NULL)
-+// {
-+//#ifndef NODEBUG
-+// struct ipaddr_str forwardedByBuf, niaBuf;
-+// struct lqtextbuffer lqbuffer;
-+//#endif
-+// OLSR_PRINTF(
-+// 9,
-+// "%s: ----> 2-hop path from %s via me to %s will cost ETX %s\n",
-+// PLUGIN_NAME_SHORT,
-+// olsr_ip_to_string(&forwardedByBuf, forwardedBy),
-+// olsr_ip_to_string(&niaBuf, &walker->neighbor_iface_addr),
-+// get_linkcost_text(previousLinkEtx + currEtx, 1, &lqbuffer));
-+// }
-+//
-+// /* Check the topology table whether the 'forwardedBy' node is itself a direct
-+// * neighbor of the candidate neighbor, at a lower cost than the 2-hop route
-+// * via myself. If so, we do not need to forward the BMF packet to the candidate
-+// * neighbor, because the 'forwardedBy' node will forward the packet. */
-+// if (forwardedBy != NULL)
-+// {
-+// tcLastHop = olsr_lookup_tc_entry(MainAddressOf(forwardedBy));
-+// if (tcLastHop != NULL)
-+// {
-+// struct tc_edge_entry* tc_edge;
-+//
-+// tc_edge = olsr_lookup_tc_edge(tcLastHop, MainAddressOf(&walker->neighbor_iface_addr));
-+//
-+// /* We are not interested in dead-end edges. */
-+// if (tc_edge) {
-+// olsr_linkcost tcEtx = tc_edge->cost;
-+//
-+// if (previousLinkEtx + currEtx > tcEtx)
-+// {
-+//#ifndef NODEBUG
-+// struct ipaddr_str neighbor_iface_buf, forw_buf;
-+// struct lqtextbuffer lqbuffer;
-+// olsr_ip_to_string(&neighbor_iface_buf, &walker->neighbor_iface_addr);
-+//#endif
-+// OLSR_PRINTF(
-+// 9,
-+// "%s: ----> Not forwarding to %s: I am not an MPR between %s and %s, direct link costs %s\n",
-+// PLUGIN_NAME_SHORT,
-+// neighbor_iface_buf.buf,
-+// olsr_ip_to_string(&forw_buf, forwardedBy),
-+// neighbor_iface_buf.buf,
-+// get_linkcost_text(tcEtx, 0, &lqbuffer));
-+//
-+// continue; /* for */
-+// } /* if */
-+// } /* if */
-+// } /* if */
-+// } /* if */
-+//
-+// /* Remember the best neighbor. If all are very bad, remember none. */
-+// if (currEtx < bestEtx)
-+// {
-+// *bestNeighbor = walker;
-+// bestEtx = currEtx;
-+// }
-+//
-+// /* Fill the list with up to 'FanOutLimit' neighbors. If there
-+// * are more neighbors, broadcast is used instead of unicast. In that
-+// * case we do not need the list of neighbors. */
-+// if (*nPossibleNeighbors < FanOutLimit)
-+// {
-+// neighbors->links[*nPossibleNeighbors] = walker;
-+// }
-+//
-+// *nPossibleNeighbors += 1;
-+// } OLSR_FOR_ALL_LINK_ENTRIES_END(walker);
-+//
-+// /* Display the result of the neighbor search */
-+// if (*nPossibleNeighbors == 0)
-+// {
-+// OLSR_PRINTF(
-+// 9,
-+// "%s: ----> No suitable neighbor found to forward to on \"%s\"\n",
-+// PLUGIN_NAME_SHORT,
-+// intf->ifName);
-+// }
-+// else
-+// {
-+// struct ipaddr_str buf;
-+// OLSR_PRINTF(
-+// 9,
-+// "%s: ----> %d neighbors found on \"%s\"; best neighbor to forward to: %s\n",
-+// PLUGIN_NAME_SHORT,
-+// *nPossibleNeighbors,
-+// intf->ifName,
-+// olsr_ip_to_string(&buf, &(*bestNeighbor)->neighbor_iface_addr));
-+// } /* if */
-+//
-+//} /* FindNeighbors */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : CreateCaptureSocket
-+ * Description: Create socket for promiscuously capturing multicast IP traffic
-+ * Input : ifname - network interface (e.g. "eth0")
-+ * Output : none
-+ * Return : the socket descriptor ( >= 0), or -1 if an error occurred
-+ * Data Used : none
-+ * Notes : The socket is a cooked IP packet socket, bound to the specified
-+ * network interface
-+ * ------------------------------------------------------------------------- */
-+static int CreateCaptureSocket(const char* ifName)
-+{
-+ int ifIndex = if_nametoindex(ifName);
-+ struct packet_mreq mreq;
-+ struct ifreq req;
-+ struct sockaddr_ll bindTo;
-+ int skfd = 0;
-+ /* Open cooked IP packet socket */
-+ if (olsr_cnf->ip_version == AF_INET){
-+ skfd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP));
-+ }
-+ else {
-+ skfd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IPV6));
-+ }
-+ if (skfd < 0)
-+ {
-+ BmfPError("socket(PF_PACKET) error");
-+ return -1;
-+ }
-+
-+ /* Set interface to promiscuous mode */
-+ memset(&mreq, 0, sizeof(struct packet_mreq));
-+ mreq.mr_ifindex = ifIndex;
-+ mreq.mr_type = PACKET_MR_PROMISC;
-+ if (setsockopt(skfd, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0)
-+ {
-+ BmfPError("setsockopt(PACKET_MR_PROMISC) error");
-+ close(skfd);
-+ return -1;
-+ }
-+
-+ /* Get hardware (MAC) address */
-+ memset(&req, 0, sizeof(struct ifreq));
-+ strncpy(req.ifr_name, ifName, IFNAMSIZ - 1);
-+ req.ifr_name[IFNAMSIZ-1] = '\0'; /* Ensures null termination */
-+ if (ioctl(skfd, SIOCGIFHWADDR, &req) < 0)
-+ {
-+ BmfPError("error retrieving MAC address");
-+ close(skfd);
-+ return -1;
-+ }
-+
-+ /* Bind the socket to the specified interface */
-+ memset(&bindTo, 0, sizeof(bindTo));
-+ bindTo.sll_family = AF_PACKET;
-+ if (olsr_cnf->ip_version == AF_INET){
-+ bindTo.sll_protocol = htons(ETH_P_IP);
-+ }
-+ else{
-+ bindTo.sll_protocol = htons(ETH_P_IPV6);
-+ }
-+ bindTo.sll_ifindex = ifIndex;
-+ memcpy(bindTo.sll_addr, req.ifr_hwaddr.sa_data, IFHWADDRLEN);
-+ bindTo.sll_halen = IFHWADDRLEN;
-+
-+ if (bind(skfd, (struct sockaddr*)&bindTo, sizeof(bindTo)) < 0)
-+ {
-+ BmfPError("bind() error");
-+ close(skfd);
-+ return -1;
-+ }
-+
-+ /* Set socket to blocking operation */
-+ if (fcntl(skfd, F_SETFL, fcntl(skfd, F_GETFL, 0) & ~O_NONBLOCK) < 0)
-+ {
-+ BmfPError("fcntl() error");
-+ close(skfd);
-+ return -1;
-+ }
-+
-+ AddDescriptorToInputSet(skfd);
-+ add_olsr_socket(skfd,&DoMDNS);
-+
-+ return skfd;
-+} /* CreateCaptureSocket */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : CreateListeningSocket
-+ * Description: Create socket for promiscuously listening to BMF packets.
-+ * Used only when 'BmfMechanism' is BM_UNICAST_PROMISCUOUS
-+ * Input : ifname - network interface (e.g. "eth0")
-+ * Output : none
-+ * Return : the socket descriptor ( >= 0), or -1 if an error occurred
-+ * Data Used : none
-+ * Notes : The socket is a cooked IP packet socket, bound to the specified
-+ * network interface
-+ * ------------------------------------------------------------------------- */
-+//static int CreateListeningSocket(const char* ifName)
-+//{
-+// int ifIndex = if_nametoindex(ifName);
-+// struct packet_mreq mreq;
-+// struct ifreq req;
-+// struct sockaddr_ll bindTo;
-+//
-+// /* Open cooked IP packet socket */
-+// int skfd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP));
-+// if (skfd < 0)
-+// {
-+// BmfPError("socket(PF_PACKET) error");
-+// return -1;
-+// }
-+//
-+// /* Set interface to promiscuous mode */
-+// memset(&mreq, 0, sizeof(struct packet_mreq));
-+// mreq.mr_ifindex = ifIndex;
-+// mreq.mr_type = PACKET_MR_PROMISC;
-+// if (setsockopt(skfd, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0)
-+// {
-+// BmfPError("setsockopt(PACKET_MR_PROMISC) error");
-+// close(skfd);
-+// return -1;
-+// }
-+//
-+// /* Get hardware (MAC) address */
-+// memset(&req, 0, sizeof(struct ifreq));
-+// strncpy(req.ifr_name, ifName, IFNAMSIZ - 1);
-+// req.ifr_name[IFNAMSIZ-1] = '\0'; /* Ensures null termination */
-+// if (ioctl(skfd, SIOCGIFHWADDR, &req) < 0)
-+// {
-+// BmfPError("error retrieving MAC address");
-+// close(skfd);
-+// return -1;
-+// }
-+//
-+// /* Bind the socket to the specified interface */
-+// memset(&bindTo, 0, sizeof(bindTo));
-+// bindTo.sll_family = AF_PACKET;
-+// bindTo.sll_protocol = htons(ETH_P_IP);
-+// bindTo.sll_ifindex = ifIndex;
-+// memcpy(bindTo.sll_addr, req.ifr_hwaddr.sa_data, IFHWADDRLEN);
-+// bindTo.sll_halen = IFHWADDRLEN;
-+//
-+// if (bind(skfd, (struct sockaddr*)&bindTo, sizeof(bindTo)) < 0)
-+// {
-+// BmfPError("bind() error");
-+// close(skfd);
-+// return -1;
-+// }
-+//
-+// /* Set socket to blocking operation */
-+// if (fcntl(skfd, F_SETFL, fcntl(skfd, F_GETFL, 0) & ~O_NONBLOCK) < 0)
-+// {
-+// BmfPError("fcntl() error");
-+// close(skfd);
-+// return -1;
-+// }
-+//
-+// AddDescriptorToInputSet(skfd);
-+//
-+// return skfd;
-+//} /* CreateListeningSocket */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : CreateEncapsulateSocket
-+ * Description: Create a socket for sending and receiving encapsulated
-+ * multicast packets
-+ * Input : ifname - network interface (e.g. "eth0")
-+ * Output : none
-+ * Return : the socket descriptor ( >= 0), or -1 if an error occurred
-+ * Data Used : none
-+ * Notes : The socket is an UDP (datagram) over IP socket, bound to the
-+ * specified network interface
-+ * ------------------------------------------------------------------------- */
-+//static int CreateEncapsulateSocket(const char* ifName)
-+//{
-+// int on = 1;
-+// struct sockaddr_in bindTo;
-+//
-+// /* Open UDP-IP socket */
-+// int skfd = socket(PF_INET, SOCK_DGRAM, 0);
-+// if (skfd < 0)
-+// {
-+// BmfPError("socket(PF_INET) error");
-+// return -1;
-+// }
-+//
-+// /* Enable sending to broadcast addresses */
-+// if (setsockopt(skfd, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on)) < 0)
-+// {
-+// BmfPError("setsockopt(SO_BROADCAST) error");
-+// close(skfd);
-+// return -1;
-+// }
-+//
-+// /* Bind to the specific network interfaces indicated by ifName. */
-+// /* When using Kernel 2.6 this must happer prior to the port binding! */
-+// if (setsockopt(skfd, SOL_SOCKET, SO_BINDTODEVICE, ifName, strlen(ifName) + 1) < 0)
-+// {
-+// BmfPError("setsockopt(SO_BINDTODEVICE) error");
-+// close(skfd);
-+// return -1;
-+// }
-+//
-+// /* Bind to BMF port */
-+// memset(&bindTo, 0, sizeof(bindTo));
-+// bindTo.sin_family = AF_INET;
-+// bindTo.sin_port = htons(BMF_ENCAP_PORT);
-+// bindTo.sin_addr.s_addr = htonl(INADDR_ANY);
-+//
-+// if (bind(skfd, (struct sockaddr*)&bindTo, sizeof(bindTo)) < 0)
-+// {
-+// BmfPError("bind() error");
-+// close(skfd);
-+// return -1;
-+// }
-+//
-+// /* Set socket to blocking operation */
-+// if (fcntl(skfd, F_SETFL, fcntl(skfd, F_GETFL, 0) & ~O_NONBLOCK) < 0)
-+// {
-+// BmfPError("fcntl() error");
-+// close(skfd);
-+// return -1;
-+// }
-+//
-+// AddDescriptorToInputSet(skfd);
-+//
-+// return skfd;
-+//} /* CreateEncapsulateSocket */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : CreateLocalEtherTunTap
-+ * Description: Creates and brings up an EtherTunTap interface
-+ * Input : none
-+ * Output : none
-+ * Return : the socket file descriptor (>= 0), or -1 in case of failure
-+ * Data Used : EtherTunTapIfName - name used for the tuntap interface (e.g.
-+ * "bmf0")
-+ * EtherTunTapIp
-+ * EtherTunTapIpMask
-+ * EtherTunTapIpBroadcast
-+ * BmfInterfaces
-+ * Note : Order dependency: call this function only if BmfInterfaces
-+ * is filled with a list of network interfaces.
-+ * ------------------------------------------------------------------------- */
-+//static int CreateLocalEtherTunTap(void)
-+//{
-+// static const char deviceName[] = "/dev/net/tun";
-+// struct ifreq ifreq;
-+// int etfd;
-+// int ioctlSkfd;
-+// int ioctlres;
-+//
-+// etfd = open(deviceName, O_RDWR | O_NONBLOCK);
-+// if (etfd < 0)
-+// {
-+// BmfPError("error opening %s", deviceName);
-+// return -1;
-+// }
-+//
-+// memset(&ifreq, 0, sizeof(ifreq));
-+// strncpy(ifreq.ifr_name, EtherTunTapIfName, IFNAMSIZ - 1);
-+// ifreq.ifr_name[IFNAMSIZ - 1] = '\0'; /* Ensures null termination */
-+//
-+// /* Specify the IFF_TUN flag for IP packets.
-+// * Specify IFF_NO_PI for not receiving extra meta packet information. */
-+// ifreq.ifr_flags = IFF_TUN;
-+// ifreq.ifr_flags |= IFF_NO_PI;
-+//
-+// if (ioctl(etfd, TUNSETIFF, (void *)&ifreq) < 0)
-+// {
-+// BmfPError("ioctl(TUNSETIFF) error on %s", deviceName);
-+// close(etfd);
-+// return -1;
-+// }
-+//
-+// memset(&ifreq, 0, sizeof(ifreq));
-+// strncpy(ifreq.ifr_name, EtherTunTapIfName, IFNAMSIZ - 1);
-+// ifreq.ifr_name[IFNAMSIZ - 1] = '\0'; /* Ensures null termination */
-+// ifreq.ifr_addr.sa_family = AF_INET;
-+//
-+// ioctlSkfd = socket(PF_INET, SOCK_DGRAM, 0);
-+// if (ioctlSkfd < 0)
-+// {
-+// BmfPError("socket(PF_INET) error on %s", deviceName);
-+// close(etfd);
-+// return -1;
-+// }
-+//
-+// /* Give the EtherTunTap interface an IP address.
-+// * The default IP address is the address of the first OLSR interface;
-+// * the default netmask is 255.255.255.255 . Having an all-ones netmask prevents
-+// * automatic entry of the BMF network interface in the routing table. */
-+// if (EtherTunTapIp == ETHERTUNTAPIPNOTSET)
-+// {
-+// struct TBmfInterface* nextBmfIf = BmfInterfaces;
-+// while (nextBmfIf != NULL)
-+// {
-+// struct TBmfInterface* bmfIf = nextBmfIf;
-+// nextBmfIf = bmfIf->next;
-+//
-+// if (bmfIf->olsrIntf != NULL)
-+// {
-+// EtherTunTapIp = ntohl(bmfIf->intAddr.v4.s_addr);
-+// EtherTunTapIpBroadcast = EtherTunTapIp;
-+// }
-+// }
-+// }
-+//
-+// if (EtherTunTapIp == ETHERTUNTAPIPNOTSET)
-+// {
-+// /* No IP address configured for BMF network interface, and no OLSR interface found to
-+// * copy IP address from. Fall back to default: 10.255.255.253 . */
-+// EtherTunTapIp = ETHERTUNTAPDEFAULTIP;
-+// }
-+//
-+// ((struct sockaddr_in*)&ifreq.ifr_addr)->sin_addr.s_addr = htonl(EtherTunTapIp);
-+// ioctlres = ioctl(ioctlSkfd, SIOCSIFADDR, &ifreq);
-+// if (ioctlres >= 0)
-+// {
-+// /* Set net mask */
-+// ((struct sockaddr_in*)&ifreq.ifr_netmask)->sin_addr.s_addr = htonl(EtherTunTapIpMask);
-+// ioctlres = ioctl(ioctlSkfd, SIOCSIFNETMASK, &ifreq);
-+// if (ioctlres >= 0)
-+// {
-+// /* Set broadcast IP */
-+// ((struct sockaddr_in*)&ifreq.ifr_broadaddr)->sin_addr.s_addr = htonl(EtherTunTapIpBroadcast);
-+// ioctlres = ioctl(ioctlSkfd, SIOCSIFBRDADDR, &ifreq);
-+// if (ioctlres >= 0)
-+// {
-+// /* Bring EtherTunTap interface up (if not already) */
-+// ioctlres = ioctl(ioctlSkfd, SIOCGIFFLAGS, &ifreq);
-+// if (ioctlres >= 0)
-+// {
-+// ifreq.ifr_flags |= (IFF_UP | IFF_RUNNING | IFF_BROADCAST);
-+// ioctlres = ioctl(ioctlSkfd, SIOCSIFFLAGS, &ifreq);
-+// }
-+// }
-+// }
-+// }
-+//
-+// if (ioctlres < 0)
-+// {
-+// /* Any of the above ioctl() calls failed */
-+// BmfPError("error bringing up EtherTunTap interface \"%s\"", EtherTunTapIfName);
-+//
-+// close(etfd);
-+// close(ioctlSkfd);
-+// return -1;
-+// } /* if (ioctlres < 0) */
-+//
-+// /* Set the multicast flag on the interface */
-+// memset(&ifreq, 0, sizeof(ifreq));
-+// strncpy(ifreq.ifr_name, EtherTunTapIfName, IFNAMSIZ - 1);
-+// ifreq.ifr_name[IFNAMSIZ - 1] = '\0'; /* Ensures null termination */
-+//
-+// ioctlres = ioctl(ioctlSkfd, SIOCGIFFLAGS, &ifreq);
-+// if (ioctlres >= 0)
-+// {
-+// ifreq.ifr_flags |= IFF_MULTICAST;
-+// ioctlres = ioctl(ioctlSkfd, SIOCSIFFLAGS, &ifreq);
-+// }
-+// if (ioctlres < 0)
-+// {
-+// /* Any of the two above ioctl() calls failed */
-+// BmfPError("error setting multicast flag on EtherTunTap interface \"%s\"", EtherTunTapIfName);
-+//
-+// /* Continue anyway */
-+// }
-+//
-+// /* Use ioctl to make the tuntap persistent. Otherwise it will disappear
-+// * when this program exits. That is not desirable, since a multicast
-+// * daemon (e.g. mrouted) may be using the tuntap interface. */
-+// if (ioctl(etfd, TUNSETPERSIST, (void *)&ifreq) < 0)
-+// {
-+// BmfPError("error making EtherTunTap interface \"%s\" persistent", EtherTunTapIfName);
-+//
-+// /* Continue anyway */
-+// }
-+//
-+// OLSR_PRINTF(8, "%s: opened 1 socket on \"%s\"\n", PLUGIN_NAME_SHORT, EtherTunTapIfName);
-+//
-+// AddDescriptorToInputSet(etfd);
-+//
-+// /* If the user configured a specific IP address for the BMF network interface,
-+// * help the user and advertise the IP address of the BMF network interface
-+// * on the OLSR network via HNA */
-+// if (TunTapIpOverruled != 0)
-+// {
-+// union olsr_ip_addr temp_net;
-+//
-+// temp_net.v4.s_addr = htonl(EtherTunTapIp);
-+// ip_prefix_list_add(&olsr_cnf->hna_entries, &temp_net, 32);
-+// }
-+//
-+// close(ioctlSkfd);
-+//
-+// return etfd;
-+//} /* CreateLocalEtherTunTap */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : CreateInterface
-+ * Description: Create a new TBmfInterface object and adds it to the global
-+ * BmfInterfaces list
-+ * Input : ifName - name of the network interface (e.g. "eth0")
-+ * : olsrIntf - OLSR interface object of the network interface, or
-+ * NULL if the network interface is not OLSR-enabled
-+ * Output : none
-+ * Return : the number of opened sockets
-+ * Data Used : BmfInterfaces, LastBmfInterface
-+ * ------------------------------------------------------------------------- */
-+
-+//FOR MDNS IS ALWAYS CALLED WITH NULL AS SECOND ARG
-+
-+static int CreateInterface(
-+ const char* ifName,
-+ struct interface* olsrIntf)
-+{
-+ int capturingSkfd = -1;
-+ int encapsulatingSkfd = -1;
-+ int listeningSkfd = -1;
-+ int ioctlSkfd;
-+ struct ifreq ifr;
-+ int nOpened = 0;
-+ struct TBmfInterface* newIf = malloc(sizeof(struct TBmfInterface));
-+
-+ assert(ifName != NULL);
-+
-+ if (newIf == NULL)
-+ {
-+ return 0;
-+ }
-+
-+//TODO: assert interface is not talking OLSR
-+
-+// if (olsrIntf != NULL)
-+// {
-+// /* On OLSR-enabled interfaces, create socket for encapsulating and forwarding
-+// * multicast packets */
-+// encapsulatingSkfd = CreateEncapsulateSocket(ifName);
-+// if (encapsulatingSkfd < 0)
-+// {
-+// free(newIf);
-+// return 0;
-+// }
-+// nOpened++;
-+// }
-+
-+ /* Create socket for capturing and sending of multicast packets on
-+ * non-OLSR interfaces, and on OLSR-interfaces if configured. */
-+ if ((olsrIntf == NULL) || (CapturePacketsOnOlsrInterfaces != 0))
-+ {
-+ capturingSkfd = CreateCaptureSocket(ifName);
-+ if (capturingSkfd < 0)
-+ {
-+ close(encapsulatingSkfd);
-+ free(newIf);
-+ return 0;
-+ }
-+
-+ nOpened++;
-+ }
-+
-+// /* Create promiscuous mode listening interface if BMF uses IP unicast
-+// * as underlying forwarding mechanism */
-+// if (BmfMechanism == BM_UNICAST_PROMISCUOUS)
-+// {
-+// listeningSkfd = CreateListeningSocket(ifName);
-+// if (listeningSkfd < 0)
-+// {
-+// close(listeningSkfd);
-+// close(encapsulatingSkfd); /* no problem if 'encapsulatingSkfd' is -1 */
-+// free(newIf);
-+// return 0;
-+// }
-+//
-+// nOpened++;
-+// }
-+
-+ /* For ioctl operations on the network interface, use either capturingSkfd
-+ * or encapsulatingSkfd, whichever is available */
-+ ioctlSkfd = (capturingSkfd >= 0) ? capturingSkfd : encapsulatingSkfd;
-+
-+ /* Retrieve the MAC address of the interface. */
-+ memset(&ifr, 0, sizeof(struct ifreq));
-+ strncpy(ifr.ifr_name, ifName, IFNAMSIZ - 1);
-+ ifr.ifr_name[IFNAMSIZ - 1] = '\0'; /* Ensures null termination */
-+ if (ioctl(ioctlSkfd, SIOCGIFHWADDR, &ifr) < 0)
-+ {
-+ BmfPError("ioctl(SIOCGIFHWADDR) error for interface \"%s\"", ifName);
-+ close(capturingSkfd);
-+ close(encapsulatingSkfd);
-+ free(newIf);
-+ return 0;
-+ }
-+
-+ /* Copy data into TBmfInterface object */
-+ newIf->capturingSkfd = capturingSkfd;
-+ newIf->encapsulatingSkfd = encapsulatingSkfd;
-+ newIf->listeningSkfd = listeningSkfd;
-+ memcpy(newIf->macAddr, ifr.ifr_hwaddr.sa_data, IFHWADDRLEN);
-+ memcpy(newIf->ifName, ifName, IFNAMSIZ);
-+ newIf->olsrIntf = olsrIntf;
-+ if (olsrIntf != NULL)
-+ {
-+ /* For an OLSR-interface, copy the interface address and broadcast
-+ * address from the OLSR interface object. Downcast to correct sockaddr
-+ * subtype. */
-+ newIf->intAddr.v4 = olsrIntf->int_addr.sin_addr;
-+ newIf->broadAddr.v4 = olsrIntf->int_broadaddr.sin_addr;
-+ }
-+ else
-+ {
-+ /* For a non-OLSR interface, retrieve the IP address ourselves */
-+ memset(&ifr, 0, sizeof(struct ifreq));
-+ strncpy(ifr.ifr_name, ifName, IFNAMSIZ - 1);
-+ ifr.ifr_name[IFNAMSIZ - 1] = '\0'; /* Ensures null termination */
-+ if (ioctl(ioctlSkfd, SIOCGIFADDR, &ifr) < 0)
-+ {
-+ BmfPError("ioctl(SIOCGIFADDR) error for interface \"%s\"", ifName);
-+
-+ newIf->intAddr.v4.s_addr = inet_addr("0.0.0.0");
-+ }
-+ else
-+ {
-+ /* Downcast to correct sockaddr subtype */
-+ newIf->intAddr.v4 = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr;
-+ }
-+
-+ /* For a non-OLSR interface, retrieve the IP broadcast address ourselves */
-+ memset(&ifr, 0, sizeof(struct ifreq));
-+ strncpy(ifr.ifr_name, ifName, IFNAMSIZ - 1);
-+ ifr.ifr_name[IFNAMSIZ - 1] = '\0'; /* Ensures null termination */
-+ if (ioctl(ioctlSkfd, SIOCGIFBRDADDR, &ifr) < 0)
-+ {
-+ BmfPError("ioctl(SIOCGIFBRDADDR) error for interface \"%s\"", ifName);
-+
-+ newIf->broadAddr.v4.s_addr = inet_addr("0.0.0.0");
-+ }
-+ else
-+ {
-+ /* Downcast to correct sockaddr subtype */
-+ newIf->broadAddr.v4 = ((struct sockaddr_in *)&ifr.ifr_broadaddr)->sin_addr;
-+ }
-+ }
-+
-+ /* Initialize fragment history table */
-+ //memset(&newIf->fragmentHistory, 0, sizeof(newIf->fragmentHistory));
-+ //newIf->nextFragmentHistoryEntry = 0;
-+
-+ /* Reset counters */
-+ //newIf->nBmfPacketsRx = 0;
-+ //newIf->nBmfPacketsRxDup = 0;
-+ //newIf->nBmfPacketsTx = 0;
-+
-+ /* Add new TBmfInterface object to global list. OLSR interfaces are
-+ * added at the front of the list, non-OLSR interfaces at the back. */
-+ if (BmfInterfaces == NULL)
-+ {
-+ /* First TBmfInterface object in list */
-+ BmfInterfaces = newIf;
-+ LastBmfInterface = newIf;
-+ }
-+ else if (olsrIntf != NULL)
-+ {
-+ /* Add new TBmfInterface object at front of list */
-+ newIf->next = BmfInterfaces;
-+ BmfInterfaces = newIf;
-+ }
-+ else
-+ {
-+ /* Add new TBmfInterface object at back of list */
-+ newIf->next = NULL;
-+ LastBmfInterface->next= newIf;
-+ LastBmfInterface = newIf;
-+ }
-+
-+ OLSR_PRINTF(
-+ 8,
-+ "%s: opened %d socket%s on %s interface \"%s\"\n",
-+ PLUGIN_NAME_SHORT,
-+ nOpened,
-+ nOpened == 1 ? "" : "s",
-+ olsrIntf != NULL ? "OLSR" : "non-OLSR",
-+ ifName);
-+
-+ return nOpened;
-+} /* CreateInterface */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : CreateBmfNetworkInterfaces
-+ * Description: Create a list of TBmfInterface objects, one for each network
-+ * interface on which BMF runs
-+ * Input : skipThisIntf - network interface to skip, if seen
-+ * Output : none
-+ * Return : fail (-1) or success (0)
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+int CreateBmfNetworkInterfaces(struct interface* skipThisIntf)
-+{
-+ int skfd;
-+ struct ifconf ifc;
-+ int numreqs = 30;
-+ struct ifreq* ifr;
-+ int n;
-+ int nOpenedSockets = 0;
-+
-+ /* Clear input descriptor set */
-+ FD_ZERO(&InputSet);
-+
-+ skfd = socket(PF_INET, SOCK_DGRAM, 0);
-+ if (skfd < 0)
-+ {
-+ BmfPError("no inet socket available to retrieve interface list");
-+ return -1;
-+ }
-+
-+ /* Retrieve the network interface configuration list */
-+ ifc.ifc_buf = NULL;
-+ for (;;)
-+ {
-+ ifc.ifc_len = sizeof(struct ifreq) * numreqs;
-+ ifc.ifc_buf = realloc(ifc.ifc_buf, ifc.ifc_len);
-+
-+ if (ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
-+ {
-+ BmfPError("ioctl(SIOCGIFCONF) error");
-+
-+ close(skfd);
-+ free(ifc.ifc_buf);
-+ return -1;
-+ }
-+ if ((unsigned)ifc.ifc_len == sizeof(struct ifreq) * numreqs)
-+ {
-+ /* Assume it overflowed; double the space and try again */
-+ numreqs *= 2;
-+ assert(numreqs < 1024);
-+ continue; /* for (;;) */
-+ }
-+ break; /* for (;;) */
-+ } /* for (;;) */
-+
-+ close(skfd);
-+
-+ /* For each item in the interface configuration list... */
-+ ifr = ifc.ifc_req;
-+ for (n = ifc.ifc_len / sizeof(struct ifreq); --n >= 0; ifr++)
-+ {
-+ struct interface* olsrIntf;
-+ union olsr_ip_addr ipAddr;
-+
-+ /* Skip the BMF network interface itself */
-+ //if (strncmp(ifr->ifr_name, EtherTunTapIfName, IFNAMSIZ) == 0)
-+ //{
-+ // continue; /* for (n = ...) */
-+ //}
-+
-+ /* ...find the OLSR interface structure, if any */
-+ ipAddr.v4 = ((struct sockaddr_in*)&ifr->ifr_addr)->sin_addr;
-+ olsrIntf = if_ifwithaddr(&ipAddr);
-+
-+ if (skipThisIntf != NULL && olsrIntf == skipThisIntf)
-+ {
-+ continue; /* for (n = ...) */
-+ }
-+
-+ if (olsrIntf == NULL && ! IsNonOlsrBmfIf(ifr->ifr_name))
-+ {
-+ /* Interface is neither OLSR interface, nor specified as non-OLSR BMF
-+ * interface in the BMF plugin parameter list */
-+ continue; /* for (n = ...) */
-+ }
-+
-+ if (! IsNonOlsrBmfIf(ifr->ifr_name))
-+ {
-+ //If the interface is not specified in the configuration file then go ahead
-+ continue; /* for (n = ...) */
-+ }
-+ //TODO: asser if->ifr_name is not talking OLSR
-+ //nOpenedSockets += CreateInterface(ifr->ifr_name, olsrIntf);
-+ nOpenedSockets += CreateInterface(ifr->ifr_name, NULL);
-+
-+ } /* for (n = ...) */
-+
-+ free(ifc.ifc_buf);
-+
-+ /* Create the BMF network interface */
-+ //EtherTunTapFd = CreateLocalEtherTunTap();
-+ //if (EtherTunTapFd >= 0)
-+ //{
-+ // nOpenedSockets++;
-+ //}
-+
-+ if (BmfInterfaces == NULL)
-+ {
-+ OLSR_PRINTF(1, "%s: could not initialize any network interface\n", PLUGIN_NAME);
-+ }
-+ else
-+ {
-+ OLSR_PRINTF(1, "%s: opened %d sockets\n", PLUGIN_NAME, nOpenedSockets);
-+ }
-+ return 0;
-+} /* CreateBmfNetworkInterfaces */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : AddInterface
-+ * Description: Add an OLSR-enabled network interface to the list of BMF-enabled
-+ * network interfaces
-+ * Input : newIntf - network interface to add
-+ * Output : none
-+ * Return : none
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+void AddInterface(struct interface* newIntf)
-+{
-+ int nOpened;
-+
-+ assert(newIntf != NULL);
-+
-+ nOpened = CreateInterface(newIntf->int_name, newIntf);
-+
-+ OLSR_PRINTF(1, "%s: opened %d sockets\n", PLUGIN_NAME, nOpened);
-+} /* AddInterface */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : CloseBmfNetworkInterfaces
-+ * Description: Closes every socket on each network interface used by BMF
-+ * Input : none
-+ * Output : none
-+ * Return : none
-+ * Data Used : none
-+ * Notes : Closes
-+ * - the local EtherTunTap interface (e.g. "tun0" or "tap0")
-+ * - for each BMF-enabled interface, the socket used for
-+ * capturing multicast packets
-+ * - for each OLSR-enabled interface, the socket used for
-+ * encapsulating packets
-+ * Also restores the network state to the situation before BMF
-+ * was started.
-+ * ------------------------------------------------------------------------- */
-+void CloseBmfNetworkInterfaces(void)
-+{
-+ int nClosed = 0;
-+ u_int32_t totalOlsrBmfPacketsRx = 0;
-+ u_int32_t totalOlsrBmfPacketsRxDup = 0;
-+ u_int32_t totalOlsrBmfPacketsTx = 0;
-+ u_int32_t totalNonOlsrBmfPacketsRx = 0;
-+ u_int32_t totalNonOlsrBmfPacketsRxDup = 0;
-+ u_int32_t totalNonOlsrBmfPacketsTx = 0;
-+
-+ /* Close all opened sockets */
-+ struct TBmfInterface* nextBmfIf = BmfInterfaces;
-+ while (nextBmfIf != NULL)
-+ {
-+ struct TBmfInterface* bmfIf = nextBmfIf;
-+ nextBmfIf = bmfIf->next;
-+
-+ if (bmfIf->capturingSkfd >= 0)
-+ {
-+ close(bmfIf->capturingSkfd);
-+ nClosed++;
-+ }
-+ if (bmfIf->encapsulatingSkfd >= 0)
-+ {
-+ close(bmfIf->encapsulatingSkfd);
-+ nClosed++;
-+ }
-+
-+ OLSR_PRINTF(
-+ 7,
-+ "%s: %s interface \"%s\": RX pkts %u (%u dups); TX pkts %u\n",
-+ PLUGIN_NAME_SHORT,
-+ bmfIf->olsrIntf != NULL ? "OLSR" : "non-OLSR",
-+ bmfIf->ifName,
-+ bmfIf->nBmfPacketsRx,
-+ bmfIf->nBmfPacketsRxDup,
-+ bmfIf->nBmfPacketsTx);
-+
-+ OLSR_PRINTF(
-+ 1,
-+ "%s: closed %s interface \"%s\"\n",
-+ PLUGIN_NAME_SHORT,
-+ bmfIf->olsrIntf != NULL ? "OLSR" : "non-OLSR",
-+ bmfIf->ifName);
-+
-+ /* Add totals */
-+ if (bmfIf->olsrIntf != NULL)
-+ {
-+ totalOlsrBmfPacketsRx += bmfIf->nBmfPacketsRx;
-+ totalOlsrBmfPacketsRxDup += bmfIf->nBmfPacketsRxDup;
-+ totalOlsrBmfPacketsTx += bmfIf->nBmfPacketsTx;
-+ }
-+ else
-+ {
-+ totalNonOlsrBmfPacketsRx += bmfIf->nBmfPacketsRx;
-+ totalNonOlsrBmfPacketsRxDup += bmfIf->nBmfPacketsRxDup;
-+ totalNonOlsrBmfPacketsTx += bmfIf->nBmfPacketsTx;
-+ }
-+
-+ free(bmfIf);
-+ } /* while */
-+
-+ if (EtherTunTapFd >= 0)
-+ {
-+ close(EtherTunTapFd);
-+ nClosed++;
-+
-+ OLSR_PRINTF(7, "%s: closed \"%s\"\n", PLUGIN_NAME_SHORT, EtherTunTapIfName);
-+ }
-+
-+ BmfInterfaces = NULL;
-+
-+ OLSR_PRINTF(1, "%s: closed %d sockets\n", PLUGIN_NAME_SHORT, nClosed);
-+
-+ OLSR_PRINTF(
-+ 7,
-+ "%s: Total all OLSR interfaces : RX pkts %u (%u dups); TX pkts %u\n",
-+ PLUGIN_NAME_SHORT,
-+ totalOlsrBmfPacketsRx,
-+ totalOlsrBmfPacketsRxDup,
-+ totalOlsrBmfPacketsTx);
-+ OLSR_PRINTF(
-+ 7,
-+ "%s: Total all non-OLSR interfaces: RX pkts %u (%u dups); TX pkts %u\n",
-+ PLUGIN_NAME_SHORT,
-+ totalNonOlsrBmfPacketsRx,
-+ totalNonOlsrBmfPacketsRxDup,
-+ totalNonOlsrBmfPacketsTx);
-+} /* CloseBmfNetworkInterfaces */
-+
-+#define MAX_NON_OLSR_IFS 32
-+static char NonOlsrIfNames[MAX_NON_OLSR_IFS][IFNAMSIZ];
-+static int nNonOlsrIfs = 0;
-+
-+/* -------------------------------------------------------------------------
-+ * Function : AddNonOlsrBmfIf
-+ * Description: Add an non-OLSR enabled network interface to the list of BMF-enabled
-+ * network interfaces
-+ * Input : ifName - network interface (e.g. "eth0")
-+ * data - not used
-+ * addon - not used
-+ * Output : none
-+ * Return : success (0) or fail (1)
-+ * Data Used : NonOlsrIfNames
-+ * ------------------------------------------------------------------------- */
-+int AddNonOlsrBmfIf(
-+ const char* ifName,
-+ void* data __attribute__((unused)),
-+ set_plugin_parameter_addon addon __attribute__((unused)))
-+{
-+ assert(ifName != NULL);
-+
-+ if (nNonOlsrIfs >= MAX_NON_OLSR_IFS)
-+ {
-+ OLSR_PRINTF(
-+ 1,
-+ "%s: too many non-OLSR interfaces specified, maximum is %d\n",
-+ PLUGIN_NAME,
-+ MAX_NON_OLSR_IFS);
-+ return 1;
-+ }
-+
-+ strncpy(NonOlsrIfNames[nNonOlsrIfs], ifName, IFNAMSIZ - 1);
-+ NonOlsrIfNames[nNonOlsrIfs][IFNAMSIZ - 1] = '\0'; /* Ensures null termination */
-+ nNonOlsrIfs++;
-+ return 0;
-+} /* AddNonOlsrBmfIf */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : IsNonOlsrBmfIf
-+ * Description: Checks if a network interface is OLSR-enabled
-+ * Input : ifName - network interface (e.g. "eth0")
-+ * Output : none
-+ * Return : true (1) or false (0)
-+ * Data Used : NonOlsrIfNames
-+ * ------------------------------------------------------------------------- */
-+int IsNonOlsrBmfIf(const char* ifName)
-+{
-+ int i;
-+
-+ assert(ifName != NULL);
-+
-+ for (i = 0; i < nNonOlsrIfs; i++)
-+ {
-+ if (strncmp(NonOlsrIfNames[i], ifName, IFNAMSIZ) == 0) return 1;
-+ }
-+ return 0;
-+} /* IsNonOlsrBmfIf */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : CheckAndUpdateLocalBroadcast
-+ * Description: For an IP packet, check if the destination address is not a
-+ * multicast address. If it is not, the packet is assumed to be
-+ * a local broadcast packet. In that case, set the destination
-+ * address of the IP packet to the passed broadcast address.
-+ * Input : ipPacket - the IP packet
-+ * broadAddr - the broadcast address to fill in
-+ * Output : none
-+ * Return : none
-+ * Data Used : none
-+ * Notes : See also RFC1141
-+ * ------------------------------------------------------------------------- */
-+void CheckAndUpdateLocalBroadcast(unsigned char* ipPacket, union olsr_ip_addr* broadAddr)
-+{
-+ struct iphdr* iph;
-+ union olsr_ip_addr destIp;
-+
-+ assert(ipPacket != NULL && broadAddr != NULL);
-+
-+ iph = (struct iphdr*) ipPacket;
-+ destIp.v4.s_addr = iph->daddr;
-+ if (! IsMulticast(&destIp))
-+ {
-+ u_int32_t origDaddr, newDaddr;
-+ u_int32_t check;
-+
-+ origDaddr = ntohl(iph->daddr);
-+
-+ iph->daddr = broadAddr->v4.s_addr;
-+ newDaddr = ntohl(iph->daddr);
-+
-+ /* Re-calculate IP header checksum for new destination */
-+ check = ntohs(iph->check);
-+
-+ check = ~ (~ check - ((origDaddr >> 16) & 0xFFFF) + ((newDaddr >> 16) & 0xFFFF));
-+ check = ~ (~ check - (origDaddr & 0xFFFF) + (newDaddr & 0xFFFF));
-+
-+ /* Add carry */
-+ check = check + (check >> 16);
-+
-+ iph->check = htons(check);
-+
-+ if (iph->protocol == SOL_UDP)
-+ {
-+ /* Re-calculate UDP/IP checksum for new destination */
-+
-+ int ipHeaderLen = GetIpHeaderLength(ipPacket);
-+ struct udphdr* udph = (struct udphdr*) (ipPacket + ipHeaderLen);
-+
-+ /* RFC 1624, Eq. 3: HC' = ~(~HC - m + m') */
-+
-+ check = ntohs(udph->check);
-+
-+ check = ~ (~ check - ((origDaddr >> 16) & 0xFFFF) + ((newDaddr >> 16) & 0xFFFF));
-+ check = ~ (~ check - (origDaddr & 0xFFFF) + (newDaddr & 0xFFFF));
-+
-+ /* Add carry */
-+ check = check + (check >> 16);
-+
-+ udph->check = htons(check);
-+ } /* if */
-+ } /* if */
-+} /* CheckAndUpdateLocalBroadcast */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : AddMulticastRoute
-+ * Description: Insert a route to all multicast addresses in the kernel
-+ * routing table. The route will be via the BMF network interface.
-+ * Input : none
-+ * Output : none
-+ * Return : none
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+void AddMulticastRoute(void)
-+{
-+ struct rtentry kernel_route;
-+ int ioctlSkfd = socket(PF_INET, SOCK_DGRAM, 0);
-+ if (ioctlSkfd < 0)
-+ {
-+ BmfPError("socket(PF_INET) error");
-+ return;
-+ }
-+
-+ memset(&kernel_route, 0, sizeof(struct rtentry));
-+
-+ ((struct sockaddr_in*)&kernel_route.rt_dst)->sin_family = AF_INET;
-+ ((struct sockaddr_in*)&kernel_route.rt_gateway)->sin_family = AF_INET;
-+ ((struct sockaddr_in*)&kernel_route.rt_genmask)->sin_family = AF_INET;
-+
-+ /* 224.0.0.0/4 */
-+ ((struct sockaddr_in *)&kernel_route.rt_dst)->sin_addr.s_addr = htonl(0xE0000000);
-+ ((struct sockaddr_in *)&kernel_route.rt_genmask)->sin_addr.s_addr = htonl(0xF0000000);
-+
-+ kernel_route.rt_metric = 0;
-+ kernel_route.rt_flags = RTF_UP;
-+
-+ kernel_route.rt_dev = EtherTunTapIfName;
-+
-+ if (ioctl(ioctlSkfd, SIOCADDRT, &kernel_route) < 0)
-+ {
-+ BmfPError("error setting multicast route via EtherTunTap interface \"%s\"", EtherTunTapIfName);
-+
-+ /* Continue anyway */
-+ }
-+ close(ioctlSkfd);
-+} /* AddMulticastRoute */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : DeleteMulticastRoute
-+ * Description: Delete the route to all multicast addresses from the kernel
-+ * routing table
-+ * Input : none
-+ * Output : none
-+ * Return : none
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+void DeleteMulticastRoute(void)
-+{
-+ if (EtherTunTapIp != ETHERTUNTAPDEFAULTIP)
-+ {
-+ struct rtentry kernel_route;
-+ int ioctlSkfd = socket(PF_INET, SOCK_DGRAM, 0);
-+ if (ioctlSkfd < 0)
-+ {
-+ BmfPError("socket(PF_INET) error");
-+ return;
-+ }
-+
-+ memset(&kernel_route, 0, sizeof(struct rtentry));
-+
-+ ((struct sockaddr_in*)&kernel_route.rt_dst)->sin_family = AF_INET;
-+ ((struct sockaddr_in*)&kernel_route.rt_gateway)->sin_family = AF_INET;
-+ ((struct sockaddr_in*)&kernel_route.rt_genmask)->sin_family = AF_INET;
-+
-+ /* 224.0.0.0/4 */
-+ ((struct sockaddr_in *)&kernel_route.rt_dst)->sin_addr.s_addr = htonl(0xE0000000);
-+ ((struct sockaddr_in *)&kernel_route.rt_genmask)->sin_addr.s_addr = htonl(0xF0000000);
-+
-+ kernel_route.rt_metric = 0;
-+ kernel_route.rt_flags = RTF_UP;
-+
-+ kernel_route.rt_dev = EtherTunTapIfName;
-+
-+ if (ioctl(ioctlSkfd, SIOCDELRT, &kernel_route) < 0)
-+ {
-+ BmfPError("error deleting multicast route via EtherTunTap interface \"%s\"", EtherTunTapIfName);
-+
-+ /* Continue anyway */
-+ }
-+ close(ioctlSkfd);
-+ } /* if */
-+} /* DeleteMulticastRoute */
-+
-+/*
-+ * Local Variables:
-+ * c-basic-offset: 2
-+ * indent-tabs-mode: nil
-+ * End:
-+ */
---- /dev/null
-+++ b/lib/mdns/src/NetworkInterfaces.h
-@@ -0,0 +1,162 @@
-+#ifndef _BMF_NETWORKINTERFACES_H
-+#define _BMF_NETWORKINTERFACES_H
-+
-+/*
-+ * OLSR Basic Multicast Forwarding (BMF) plugin.
-+ * Copyright (c) 2005 - 2007, Thales Communications, Huizen, The Netherlands.
-+ * Written by Erik Tromp.
-+ * All rights reserved.
-+ *
-+ * Redistribution and use in source and binary forms, with or without
-+ * modification, are permitted provided that the following conditions
-+ * are met:
-+ *
-+ * * Redistributions of source code must retain the above copyright
-+ * notice, this list of conditions and the following disclaimer.
-+ * * Redistributions in binary form must reproduce the above copyright
-+ * notice, this list of conditions and the following disclaimer in
-+ * the documentation and/or other materials provided with the
-+ * distribution.
-+ * * Neither the name of Thales, BMF nor the names of its
-+ * contributors may be used to endorse or promote products derived
-+ * from this software without specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
-+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-+ * OF THE POSSIBILITY OF SUCH DAMAGE.
-+ */
-+
-+/* -------------------------------------------------------------------------
-+ * File : NetworkInterfaces.h
-+ * Description: Functions to open and close sockets
-+ * Created : 29 Jun 2006
-+ *
-+ * ------------------------------------------------------------------------- */
-+
-+/* System includes */
-+#include <netinet/in.h> /* struct in_addr */
-+
-+/* OLSR includes */
-+#include "olsr_types.h" /* olsr_ip_addr */
-+#include "olsrd_plugin.h" /* union set_plugin_parameter_addon */
-+#include "socket_parser.h"
-+/* Plugin includes */
-+#include "Packet.h" /* IFHWADDRLEN */
-+#include "mdns.h"
-+/* Size of buffer in which packets are received */
-+#define BMF_BUFFER_SIZE 2048
-+
-+struct TBmfInterface
-+{
-+ /* File descriptor of raw packet socket, used for capturing multicast packets */
-+ int capturingSkfd;
-+
-+ /* File descriptor of UDP (datagram) socket for encapsulated multicast packets.
-+ * Only used for OLSR-enabled interfaces; set to -1 if interface is not OLSR-enabled. */
-+ int encapsulatingSkfd;
-+
-+ /* File descriptor of UDP packet socket, used for listening to encapsulation packets.
-+ * Used only when PlParam "BmfMechanism" is set to "UnicastPromiscuous". */
-+ int listeningSkfd;
-+
-+ unsigned char macAddr[IFHWADDRLEN];
-+
-+ char ifName[IFNAMSIZ];
-+
-+ /* OLSRs idea of this network interface. NULL if this interface is not
-+ * OLSR-enabled. */
-+ struct interface* olsrIntf;
-+
-+ /* IP address of this network interface */
-+ union olsr_ip_addr intAddr;
-+
-+ /* Broadcast address of this network interface */
-+ union olsr_ip_addr broadAddr;
-+
-+ #define FRAGMENT_HISTORY_SIZE 10
-+ struct TFragmentHistory
-+ {
-+ u_int16_t ipId;
-+ u_int8_t ipProto;
-+ struct in_addr ipSrc;
-+ struct in_addr ipDst;
-+ } fragmentHistory [FRAGMENT_HISTORY_SIZE];
-+
-+ int nextFragmentHistoryEntry;
-+
-+ /* Number of received and transmitted BMF packets on this interface */
-+ u_int32_t nBmfPacketsRx;
-+ u_int32_t nBmfPacketsRxDup;
-+ u_int32_t nBmfPacketsTx;
-+
-+ /* Next element in list */
-+ struct TBmfInterface* next;
-+};
-+
-+extern struct TBmfInterface* BmfInterfaces;
-+
-+extern int HighestSkfd;
-+extern fd_set InputSet;
-+
-+extern int EtherTunTapFd;
-+
-+extern char EtherTunTapIfName[];
-+
-+/* 10.255.255.253 in host byte order */
-+#define ETHERTUNTAPDEFAULTIP 0x0AFFFFFD
-+
-+extern u_int32_t EtherTunTapIp;
-+extern u_int32_t EtherTunTapIpMask;
-+extern u_int32_t EtherTunTapIpBroadcast;
-+
-+extern int CapturePacketsOnOlsrInterfaces;
-+
-+enum TBmfMechanism { BM_BROADCAST = 0, BM_UNICAST_PROMISCUOUS };
-+extern enum TBmfMechanism BmfMechanism;
-+
-+int SetBmfInterfaceName(const char* ifname, void* data, set_plugin_parameter_addon addon);
-+int SetBmfInterfaceIp(const char* ip, void* data, set_plugin_parameter_addon addon);
-+int SetCapturePacketsOnOlsrInterfaces(const char* enable, void* data, set_plugin_parameter_addon addon);
-+int SetBmfMechanism(const char* mechanism, void* data, set_plugin_parameter_addon addon);
-+int DeactivateSpoofFilter(void);
-+void RestoreSpoofFilter(void);
-+
-+#define MAX_UNICAST_NEIGHBORS 10
-+struct TBestNeighbors
-+{
-+ struct link_entry* links[MAX_UNICAST_NEIGHBORS];
-+};
-+
-+void FindNeighbors(
-+ struct TBestNeighbors* neighbors,
-+ struct link_entry** bestNeighbor,
-+ struct TBmfInterface* intf,
-+ union olsr_ip_addr* source,
-+ union olsr_ip_addr* forwardedBy,
-+ union olsr_ip_addr* forwardedTo,
-+ int* nPossibleNeighbors);
-+
-+int CreateBmfNetworkInterfaces(struct interface* skipThisIntf);
-+void AddInterface(struct interface* newIntf);
-+void CloseBmfNetworkInterfaces(void);
-+int AddNonOlsrBmfIf(const char* ifName, void* data, set_plugin_parameter_addon addon);
-+int IsNonOlsrBmfIf(const char* ifName);
-+void CheckAndUpdateLocalBroadcast(unsigned char* ipPacket, union olsr_ip_addr* broadAddr);
-+void AddMulticastRoute(void);
-+void DeleteMulticastRoute(void);
-+
-+#endif /* _BMF_NETWORKINTERFACES_H */
-+
-+/*
-+ * Local Variables:
-+ * c-basic-offset: 2
-+ * indent-tabs-mode: nil
-+ * End:
-+ */
---- /dev/null
-+++ b/lib/mdns/src/Packet.c
-@@ -0,0 +1,238 @@
-+/*
-+ * OLSR Basic Multicast Forwarding (BMF) plugin.
-+ * Copyright (c) 2005 - 2007, Thales Communications, Huizen, The Netherlands.
-+ * Written by Erik Tromp.
-+ * All rights reserved.
-+ *
-+ * Redistribution and use in source and binary forms, with or without
-+ * modification, are permitted provided that the following conditions
-+ * are met:
-+ *
-+ * * Redistributions of source code must retain the above copyright
-+ * notice, this list of conditions and the following disclaimer.
-+ * * Redistributions in binary form must reproduce the above copyright
-+ * notice, this list of conditions and the following disclaimer in
-+ * the documentation and/or other materials provided with the
-+ * distribution.
-+ * * Neither the name of Thales, BMF nor the names of its
-+ * contributors may be used to endorse or promote products derived
-+ * from this software without specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
-+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-+ * OF THE POSSIBILITY OF SUCH DAMAGE.
-+ */
-+
-+/* -------------------------------------------------------------------------
-+ * File : Packet.c
-+ * Description: IP packet and Ethernet frame processing functions
-+ * Created : 29 Jun 2006
-+ *
-+ * ------------------------------------------------------------------------- */
-+
-+#include "Packet.h"
-+
-+/* System includes */
-+#include <stddef.h> /* NULL */
-+#include <assert.h> /* assert() */
-+#include <string.h> /* memcpy() */
-+#include <sys/types.h> /* u_int8_t, u_int16_t, u_int32_t */
-+#include <netinet/in.h> /* ntohs(), htons() */
-+#include <netinet/ip.h> /* struct iphdr */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : IsIpFragment
-+ * Description: Check if an IP packet is an IP fragment
-+ * Input : ipPacket - the IP packet
-+ * Output : none
-+ * Return : true (1) or false (0)
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+int IsIpFragment(unsigned char* ipPacket)
-+{
-+ struct ip* iph;
-+
-+ assert(ipPacket != NULL);
-+
-+ iph = (struct ip*) ipPacket;
-+ if ((ntohs(iph->ip_off) & IP_OFFMASK) != 0)
-+ {
-+ return 1;
-+ }
-+ return 0;
-+} /* IsIpFragment */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : GetIpTotalLength
-+ * Description: Retrieve the total length of the IP packet (in bytes) of
-+ * an IP packet
-+ * Input : ipPacket - the IP packet
-+ * Output : none
-+ * Return : IP packet length
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+u_int16_t GetIpTotalLength(unsigned char* ipPacket)
-+{
-+ struct iphdr* iph;
-+
-+ assert(ipPacket != NULL);
-+
-+ iph = (struct iphdr*) ipPacket;
-+ return ntohs(iph->tot_len);
-+} /* GetIpTotalLength */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : GetIpHeaderLength
-+ * Description: Retrieve the IP header length (in bytes) of an IP packet
-+ * Input : ipPacket - the IP packet
-+ * Output : none
-+ * Return : IP header length
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+unsigned int GetIpHeaderLength(unsigned char* ipPacket)
-+{
-+ struct iphdr* iph;
-+
-+ assert(ipPacket != NULL);
-+
-+ iph = (struct iphdr*) ipPacket;
-+ return iph->ihl << 2;
-+} /* GetIpHeaderLength */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : GetTtl
-+ * Description: Retrieve the TTL (Time To Live) value from the IP header of
-+ * an IP packet
-+ * Input : ipPacket - the IP packet
-+ * Output : none
-+ * Return : TTL value
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+u_int8_t GetTtl(unsigned char* ipPacket)
-+{
-+ struct iphdr* iph;
-+
-+ assert(ipPacket != NULL);
-+
-+ iph = (struct iphdr*) ipPacket;
-+ return iph->ttl;
-+} /* GetTtl */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : SaveTtlAndChecksum
-+ * Description: Save the TTL (Time To Live) value and IP checksum as found in
-+ * the IP header of an IP packet
-+ * Input : ipPacket - the IP packet
-+ * Output : sttl - the TTL and checksum values
-+ * Return : none
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+void SaveTtlAndChecksum(unsigned char* ipPacket, struct TSaveTtl* sttl)
-+{
-+ struct iphdr* iph;
-+
-+ assert(ipPacket != NULL && sttl != NULL);
-+
-+ iph = (struct iphdr*) ipPacket;
-+ sttl->ttl = iph->ttl;
-+ sttl->check = ntohs(iph->check);
-+} /* SaveTtlAndChecksum */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : RestoreTtlAndChecksum
-+ * Description: Restore the TTL (Time To Live) value and IP checksum in
-+ * the IP header of an IP packet
-+ * Input : ipPacket - the IP packet
-+ * sttl - the TTL and checksum values
-+ * Output : none
-+ * Return : none
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+void RestoreTtlAndChecksum(unsigned char* ipPacket, struct TSaveTtl* sttl)
-+{
-+ struct iphdr* iph;
-+
-+ assert(ipPacket != NULL && sttl != NULL);
-+
-+ iph = (struct iphdr*) ipPacket;
-+ iph->ttl = sttl->ttl;
-+ iph->check = htons(sttl->check);
-+} /* RestoreTtlAndChecksum */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : DecreaseTtlAndUpdateHeaderChecksum
-+ * Description: For an IP packet, decrement the TTL value and update the IP header
-+ * checksum accordingly.
-+ * Input : ipPacket - the IP packet
-+ * Output : none
-+ * Return : none
-+ * Data Used : none
-+ * Notes : See also RFC1141
-+ * ------------------------------------------------------------------------- */
-+void DecreaseTtlAndUpdateHeaderChecksum(unsigned char* ipPacket)
-+{
-+ struct iphdr* iph;
-+ u_int32_t sum;
-+
-+ assert(ipPacket != NULL);
-+
-+ iph = (struct iphdr*) ipPacket;
-+
-+ iph->ttl--; /* decrement ttl */
-+ sum = ntohs(iph->check) + 0x100; /* increment checksum high byte */
-+ iph->check = htons(sum + (sum>>16)); /* add carry */
-+} /* DecreaseTtlAndUpdateHeaderChecksum */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : GetIpHeader
-+ * Description: Retrieve the IP header from BMF encapsulation UDP data
-+ * Input : encapsulationUdpData - the encapsulation UDP data
-+ * Output : none
-+ * Return : IP header
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+struct ip* GetIpHeader(unsigned char* encapsulationUdpData)
-+{
-+ return (struct ip*)(encapsulationUdpData + ENCAP_HDR_LEN);
-+} /* GetIpHeader */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : GetIpPacket
-+ * Description: Retrieve the IP packet from BMF encapsulation UDP data
-+ * Input : encapsulationUdpData - the encapsulation UDP data
-+ * Output : none
-+ * Return : The IP packet
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+unsigned char* GetIpPacket(unsigned char* encapsulationUdpData)
-+{
-+ return encapsulationUdpData + ENCAP_HDR_LEN;
-+} /* GetIpPacket */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : GetEncapsulationUdpDataLength
-+ * Description: Return the length of BMF encapsulation UDP data
-+ * Input : encapsulationUdpData - the encapsulation UDP data
-+ * Output : none
-+ * Return : The encapsulation data length
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+u_int16_t GetEncapsulationUdpDataLength(unsigned char* encapsulationUdpData)
-+{
-+ return GetIpTotalLength(GetIpPacket(encapsulationUdpData)) + ENCAP_HDR_LEN;
-+} /* GetEncapsulationUdpDataLength */
-+
-+
-+/*
-+ * Local Variables:
-+ * c-basic-offset: 2
-+ * indent-tabs-mode: nil
-+ * End:
-+ */
---- /dev/null
-+++ b/lib/mdns/src/Packet.h
-@@ -0,0 +1,88 @@
-+#ifndef _BMF_PACKET_H
-+#define _BMF_PACKET_H
-+
-+/*
-+ * OLSR Basic Multicast Forwarding (BMF) plugin.
-+ * Copyright (c) 2005 - 2007, Thales Communications, Huizen, The Netherlands.
-+ * Written by Erik Tromp.
-+ * All rights reserved.
-+ *
-+ * Redistribution and use in source and binary forms, with or without
-+ * modification, are permitted provided that the following conditions
-+ * are met:
-+ *
-+ * * Redistributions of source code must retain the above copyright
-+ * notice, this list of conditions and the following disclaimer.
-+ * * Redistributions in binary form must reproduce the above copyright
-+ * notice, this list of conditions and the following disclaimer in
-+ * the documentation and/or other materials provided with the
-+ * distribution.
-+ * * Neither the name of Thales, BMF nor the names of its
-+ * contributors may be used to endorse or promote products derived
-+ * from this software without specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
-+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-+ * OF THE POSSIBILITY OF SUCH DAMAGE.
-+ */
-+
-+/* -------------------------------------------------------------------------
-+ * File : Packet.h
-+ * Description: BMF and IP packet processing functions
-+ * Created : 29 Jun 2006
-+ *
-+ * ------------------------------------------------------------------------- */
-+
-+/* System includes */
-+#include <net/if.h> /* IFNAMSIZ, IFHWADDRLEN */
-+#include <sys/types.h> /* u_int8_t, u_int16_t */
-+
-+/* BMF-encapsulated packets are Ethernet-IP-UDP packets, which start
-+ * with a 8-bytes BMF header (struct TEncapHeader), followed by the
-+ * encapsulated Ethernet-IP packet itself */
-+
-+struct TEncapHeader
-+{
-+ /* Use a standard Type-Length-Value (TLV) element */
-+ u_int8_t type;
-+ u_int8_t len;
-+ u_int16_t reserved; /* Always 0 */
-+ u_int32_t crc32;
-+} __attribute__((__packed__));
-+
-+#define ENCAP_HDR_LEN ((int)sizeof(struct TEncapHeader))
-+#define BMF_ENCAP_TYPE 1
-+#define BMF_ENCAP_LEN 6
-+
-+struct TSaveTtl
-+{
-+ u_int8_t ttl;
-+ u_int16_t check;
-+} __attribute__((__packed__));
-+
-+int IsIpFragment(unsigned char* ipPacket);
-+u_int16_t GetIpTotalLength(unsigned char* ipPacket);
-+unsigned int GetIpHeaderLength(unsigned char* ipPacket);
-+u_int8_t GetTtl(unsigned char* ipPacket);
-+void SaveTtlAndChecksum(unsigned char* ipPacket, struct TSaveTtl* sttl);
-+void RestoreTtlAndChecksum(unsigned char* ipPacket, struct TSaveTtl* sttl);
-+void DecreaseTtlAndUpdateHeaderChecksum(unsigned char* ipPacket);
-+struct ip* GetIpHeader(unsigned char* encapsulationUdpData);
-+unsigned char* GetIpPacket(unsigned char* encapsulationUdpData);
-+u_int16_t GetEncapsulationUdpDataLength(unsigned char* encapsulationUdpData);
-+
-+#endif /* _BMF_PACKET_H */
-+
-+/*
-+ * Local Variables:
-+ * c-basic-offset: 2
-+ * indent-tabs-mode: nil
-+ * End:
-+ */
---- /dev/null
-+++ b/lib/mdns/src/PacketHistory.c
-@@ -0,0 +1,324 @@
-+/*
-+ * OLSR Basic Multicast Forwarding (BMF) plugin.
-+ * Copyright (c) 2005 - 2007, Thales Communications, Huizen, The Netherlands.
-+ * Written by Erik Tromp.
-+ * All rights reserved.
-+ *
-+ * Redistribution and use in source and binary forms, with or without
-+ * modification, are permitted provided that the following conditions
-+ * are met:
-+ *
-+ * * Redistributions of source code must retain the above copyright
-+ * notice, this list of conditions and the following disclaimer.
-+ * * Redistributions in binary form must reproduce the above copyright
-+ * notice, this list of conditions and the following disclaimer in
-+ * the documentation and/or other materials provided with the
-+ * distribution.
-+ * * Neither the name of Thales, BMF nor the names of its
-+ * contributors may be used to endorse or promote products derived
-+ * from this software without specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
-+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-+ * OF THE POSSIBILITY OF SUCH DAMAGE.
-+ */
-+
-+/* -------------------------------------------------------------------------
-+ * File : PacketHistory.c
-+ * Description: Functions for keeping and accessing the history of processed
-+ * multicast IP packets.
-+ * Created : 29 Jun 2006
-+ *
-+ * ------------------------------------------------------------------------- */
-+
-+#include "PacketHistory.h"
-+
-+/* System includes */
-+#include <stddef.h> /* NULL */
-+#include <assert.h> /* assert() */
-+#include <string.h> /* memset */
-+#include <sys/types.h> /* u_int16_t, u_int32_t */
-+#include <netinet/ip.h> /* struct iphdr */
-+#include <stdlib.h> /* atoi, malloc */
-+
-+/* OLSRD includes */
-+#include "defs.h" /* GET_TIMESTAMP, TIMED_OUT */
-+#include "olsr.h" /* OLSR_PRINTF */
-+#include "scheduler.h" /* now_times */
-+
-+/* Plugin includes */
-+#include "Packet.h"
-+
-+static struct TDupEntry* PacketHistory[HISTORY_HASH_SIZE];
-+
-+#define CRC_UPTO_NBYTES 256
-+
-+#if 0
-+/* -------------------------------------------------------------------------
-+ * Function : CalcCrcCcitt
-+ * Description: Calculate 16-bits CRC according to CRC-CCITT specification
-+ * Input : buffer - the bytes to calculate the CRC value over
-+ * len - the number of bytes to calculate the CRC value over
-+ * Output : none
-+ * Return : CRC-16 value
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+static u_int16_t CalcCrcCcitt(unsigned char* buffer, ssize_t len)
-+{
-+ /* Initial value of 0xFFFF should be 0x1D0F according to
-+ * www.joegeluso.com/software/articles/ccitt.htm */
-+ u_int16_t crc = 0xFFFF;
-+ int i;
-+
-+ assert(buffer != NULL);
-+
-+ for (i = 0; i < len; i++)
-+ {
-+ crc = (unsigned char)(crc >> 8) | (crc << 8);
-+ crc ^= buffer[i];
-+ crc ^= (unsigned char)(crc & 0xff) >> 4;
-+ crc ^= (crc << 8) << 4;
-+ crc ^= ((crc & 0xff) << 4) << 1;
-+ }
-+ return crc;
-+} /* CalcCrcCcitt */
-+#endif
-+
-+/* -------------------------------------------------------------------------
-+ * Function : GenerateCrc32Table
-+ * Description: Generate the table of CRC remainders for all possible bytes,
-+ * according to CRC-32-IEEE 802.3
-+ * Input : none
-+ * Output : none
-+ * Return : none
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+#define CRC32_POLYNOMIAL 0xedb88320UL /* bit-inverse of 0x04c11db7UL */
-+
-+static unsigned long CrcTable[256];
-+
-+static void GenerateCrc32Table(void)
-+{
-+ int i, j;
-+ u_int32_t crc;
-+ for (i = 0; i < 256; i++)
-+ {
-+ crc = (u_int32_t) i;
-+ for (j = 0; j < 8; j++)
-+ {
-+ if (crc & 1)
-+ {
-+ crc = (crc >> 1) ^ CRC32_POLYNOMIAL;
-+ }
-+ else
-+ {
-+ crc = (crc >> 1);
-+ }
-+ }
-+ CrcTable[i] = crc;
-+ } /* for */
-+} /* GenerateCrc32Table */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : CalcCrc32
-+ * Description: Calculate CRC-32 according to CRC-32-IEEE 802.3
-+ * Input : buffer - the bytes to calculate the CRC value over
-+ * len - the number of bytes to calculate the CRC value over
-+ * Output : none
-+ * Return : CRC-32 value
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+static u_int32_t CalcCrc32(unsigned char* buffer, ssize_t len)
-+{
-+ int i, j;
-+ u_int32_t crc = 0xffffffffUL;
-+ for (i = 0; i < len; i++)
-+ {
-+ j = ((int) (crc & 0xFF) ^ *buffer++);
-+ crc = (crc >> 8) ^ CrcTable[j];
-+ }
-+ return crc ^ 0xffffffffUL;
-+} /* CalcCrc32 */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : PacketCrc32
-+ * Description: Calculates the CRC-32 value for an IP packet
-+ * Input : ipPacket - the IP packet
-+ * len - the number of octets in the IP packet
-+ * Output : none
-+ * Return : 32-bits CRC value
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+u_int32_t PacketCrc32(unsigned char* ipPacket, ssize_t len)
-+{
-+ struct TSaveTtl sttl;
-+ struct ip* ipHeader;
-+ u_int32_t result;
-+
-+ assert(ipPacket != NULL);
-+
-+ /* Skip TTL: in a multi-homed OLSR-network, the same multicast packet
-+ * may enter the network multiple times, each copy differing only in its
-+ * TTL value. BMF must not calculate a different CRC for packets that
-+ * differ only in TTL. Skip also the IP-header checksum, because it changes
-+ * along with TTL. Besides, it is not a good idea to calculate a CRC over
-+ * data that already contains a checksum.
-+ *
-+ * Clip number of bytes over which CRC is calculated to prevent
-+ * long packets from possibly claiming too much CPU resources. */
-+ assert(len > 0);
-+ if (len > CRC_UPTO_NBYTES)
-+ {
-+ len = CRC_UPTO_NBYTES;
-+ }
-+
-+ SaveTtlAndChecksum(ipPacket, &sttl);
-+
-+ ipHeader = (struct ip*)ipPacket;
-+ ipHeader->ip_ttl = 0xFF; /* fixed value of TTL for CRC-32 calculation */
-+ ipHeader->ip_sum = 0x5A5A; /* fixed value of IP header checksum for CRC-32 calculation */
-+
-+ result = CalcCrc32(ipPacket, len);
-+
-+ RestoreTtlAndChecksum(ipPacket, &sttl);
-+ return result;
-+} /* PacketCrc32 */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : Hash
-+ * Description: Calculates a hash value from a 32-bit value
-+ * Input : from32 - 32-bit value
-+ * Output : none
-+ * Return : hash value
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+u_int32_t Hash(u_int32_t from32)
-+{
-+ return ((from32 >> N_HASH_BITS) + from32) & ((1 << N_HASH_BITS) - 1);
-+} /* Hash */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : InitPacketHistory
-+ * Description: Initialize the packet history table and CRC-32 table
-+ * Input : none
-+ * Output : none
-+ * Return : none
-+ * Data Used : PacketHistory
-+ * ------------------------------------------------------------------------- */
-+void InitPacketHistory(void)
-+{
-+ int i;
-+
-+ GenerateCrc32Table();
-+
-+ for(i = 0; i < HISTORY_HASH_SIZE; i++)
-+ {
-+ PacketHistory[i] = NULL;
-+ }
-+} /* InitPacketHistory */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : CheckAndMarkRecentPacket
-+ * Description: Check if this packet was seen recently, then record the fact
-+ * that this packet was seen recently.
-+ * Input : crc32 - 32-bits crc value of the packet
-+ * Output : none
-+ * Return : not recently seen (0), recently seen (1)
-+ * Data Used : PacketHistory
-+ * ------------------------------------------------------------------------- */
-+int CheckAndMarkRecentPacket(u_int32_t crc32)
-+{
-+ u_int32_t idx;
-+ struct TDupEntry* walker;
-+ struct TDupEntry* newEntry;
-+
-+ idx = Hash(crc32);
-+ assert(idx < HISTORY_HASH_SIZE);
-+
-+ for (walker = PacketHistory[idx]; walker != NULL; walker = walker->next)
-+ {
-+ if (walker->crc32 == crc32)
-+ {
-+ /* Found duplicate entry */
-+
-+ /* Always mark as "seen recently": refresh time-out */
-+ walker->timeOut = GET_TIMESTAMP(HISTORY_HOLD_TIME);
-+
-+ return 1;
-+ } /* if */
-+ } /* for */
-+
-+ /* No duplicate entry found: create one */
-+ newEntry = malloc(sizeof(struct TDupEntry));
-+ if (newEntry != NULL)
-+ {
-+ newEntry->crc32 = crc32;
-+ newEntry->timeOut = GET_TIMESTAMP(HISTORY_HOLD_TIME);
-+
-+ /* Add new entry at the front of the list */
-+ newEntry->next = PacketHistory[idx];
-+ PacketHistory[idx] = newEntry;
-+ }
-+
-+ return 0;
-+} /* CheckAndMarkRecentPacket */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : PrunePacketHistory
-+ * Description: Prune the packet history table.
-+ * Input : useless - not used
-+ * Output : none
-+ * Return : none
-+ * Data Used : PacketHistory
-+ * ------------------------------------------------------------------------- */
-+void PrunePacketHistory(void* useless __attribute__((unused)))
-+{
-+ uint i;
-+ for (i = 0; i < HISTORY_HASH_SIZE; i++)
-+ {
-+ if (PacketHistory[i] != NULL)
-+ {
-+ struct TDupEntry* nextEntry = PacketHistory[i];
-+ struct TDupEntry* prevEntry = NULL;
-+ while (nextEntry != NULL)
-+ {
-+ struct TDupEntry* entry = nextEntry;
-+ nextEntry = entry->next;
-+
-+ if (TIMED_OUT(entry->timeOut))
-+ {
-+ /* De-queue */
-+ if (prevEntry != NULL)
-+ {
-+ prevEntry->next = entry->next;
-+ }
-+ else
-+ {
-+ PacketHistory[i] = entry->next;
-+ } /* if */
-+
-+ /* De-allocate memory */
-+ free(entry);
-+ }
-+ else
-+ {
-+ prevEntry = entry;
-+ } /* if */
-+ } /* while */
-+ } /* if (PacketHistory[i] != NULL) */
-+ } /* for (i = ...) */
-+} /* PrunePacketHistory */
-+
-+/*
-+ * Local Variables:
-+ * c-basic-offset: 2
-+ * indent-tabs-mode: nil
-+ * End:
-+ */
---- /dev/null
-+++ b/lib/mdns/src/PacketHistory.h
-@@ -0,0 +1,75 @@
-+#ifndef _BMF_PACKETHISTORY_H
-+#define _BMF_PACKETHISTORY_H
-+
-+/*
-+ * OLSR Basic Multicast Forwarding (BMF) plugin.
-+ * Copyright (c) 2005 - 2007, Thales Communications, Huizen, The Netherlands.
-+ * Written by Erik Tromp.
-+ * All rights reserved.
-+ *
-+ * Redistribution and use in source and binary forms, with or without
-+ * modification, are permitted provided that the following conditions
-+ * are met:
-+ *
-+ * * Redistributions of source code must retain the above copyright
-+ * notice, this list of conditions and the following disclaimer.
-+ * * Redistributions in binary form must reproduce the above copyright
-+ * notice, this list of conditions and the following disclaimer in
-+ * the documentation and/or other materials provided with the
-+ * distribution.
-+ * * Neither the name of Thales, BMF nor the names of its
-+ * contributors may be used to endorse or promote products derived
-+ * from this software without specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
-+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-+ * OF THE POSSIBILITY OF SUCH DAMAGE.
-+ */
-+
-+/* -------------------------------------------------------------------------
-+ * File : PacketHistory.h
-+ * Description: Functions for keeping and accessing the history of processed
-+ * multicast IP packets.
-+ * Created : 29 Jun 2006
-+ *
-+ * ------------------------------------------------------------------------- */
-+
-+/* System includes */
-+#include <sys/types.h> /* ssize_t */
-+#include <sys/times.h> /* clock_t */
-+
-+#define N_HASH_BITS 12
-+#define HISTORY_HASH_SIZE (1 << N_HASH_BITS)
-+
-+/* Time-out of duplicate entries, in milliseconds */
-+#define HISTORY_HOLD_TIME 3000
-+
-+struct TDupEntry
-+{
-+ u_int32_t crc32;
-+ clock_t timeOut;
-+ struct TDupEntry* next;
-+};
-+
-+void InitPacketHistory(void);
-+u_int32_t PacketCrc32(unsigned char* ipPkt, ssize_t len);
-+u_int32_t Hash(u_int32_t from32);
-+void MarkRecentPacket(u_int32_t crc32);
-+int CheckAndMarkRecentPacket(u_int32_t crc32);
-+void PrunePacketHistory(void*);
-+
-+#endif /* _BMF_PACKETHISTORY_H */
-+
-+/*
-+ * Local Variables:
-+ * c-basic-offset: 2
-+ * indent-tabs-mode: nil
-+ * End:
-+ */
---- /dev/null
-+++ b/lib/mdns/src/mdns.c
-@@ -0,0 +1,1174 @@
-+/*
-+ * OLSR MDNS plugin.
-+ * Written by Saverio Proto.
-+ *
-+ * Redistribution and use in source and binary forms, with or without
-+ * modification, are permitted provided that the following conditions
-+ * are met:
-+ *
-+ * * Redistributions of source code must retain the above copyright
-+ * notice, this list of conditions and the following disclaimer.
-+ * * Redistributions in binary form must reproduce the above copyright
-+ * notice, this list of conditions and the following disclaimer in
-+ * the documentation and/or other materials provided with the
-+ * distribution.
-+ * * Neither the name of Thales, BMF nor the names of its
-+ * contributors may be used to endorse or promote products derived
-+ * from this software without specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
-+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-+ * OF THE POSSIBILITY OF SUCH DAMAGE.
-+ */
-+
-+
-+//#define _MULTI_THREADED
-+
-+#include "mdns.h"
-+
-+/* System includes */
-+#include <stddef.h> /* NULL */
-+#include <sys/types.h> /* ssize_t */
-+#include <string.h> /* strerror() */
-+#include <stdarg.h> /* va_list, va_start, va_end */
-+#include <errno.h> /* errno */
-+#include <assert.h> /* assert() */
-+#include <linux/if_ether.h> /* ETH_P_IP */
-+#include <linux/if_packet.h> /* struct sockaddr_ll, PACKET_MULTICAST */
-+//#include <pthread.h> /* pthread_t, pthread_create() */
-+#include <signal.h> /* sigset_t, sigfillset(), sigdelset(), SIGINT */
-+#include <netinet/ip.h> /* struct ip */
-+#include <netinet/udp.h> /* struct udphdr */
-+#include <unistd.h> /* close() */
-+
-+#include <netinet/in.h>
-+#include <netinet/ip6.h>
-+
-+/* OLSRD includes */
-+#include "plugin_util.h" /* set_plugin_int */
-+#include "defs.h" /* olsr_cnf, OLSR_PRINTF */
-+#include "ipcalc.h"
-+#include "olsr.h" /* OLSR_PRINTF */
-+#include "mid_set.h" /* mid_lookup_main_addr() */
-+#include "mpr_selector_set.h" /* olsr_lookup_mprs_set() */
-+#include "link_set.h" /* get_best_link_to_neighbor() */
-+#include "net_olsr.h" /* ipequal */
-+
-+/* plugin includes */
-+#include "NetworkInterfaces.h" /* TBmfInterface, CreateBmfNetworkInterfaces(), CloseBmfNetworkInterfaces() */
-+#include "Address.h" /* IsMulticast() */
-+#include "Packet.h" /* ENCAP_HDR_LEN, BMF_ENCAP_TYPE, BMF_ENCAP_LEN etc. */
-+#include "PacketHistory.h" /* InitPacketHistory() */
-+
-+//static pthread_t mdnsThread;
-+//static int mdnsThreadRunning = 0;
-+
-+/* -------------------------------------------------------------------------
-+ * Function : PacketReceivedFromOLSR
-+ * Description: Handle a received packet from a OLSR message
-+ * Input : ipPacket into an unsigned char and the lenght of the packet
-+ * Output : none
-+ * Return : none
-+ * Data Used : BmfInterfaces
-+ * ------------------------------------------------------------------------- */
-+static void PacketReceivedFromOLSR(
-+ unsigned char* encapsulationUdpData, int len)
-+{
-+ struct ip* ipHeader; /* IP header inside the encapsulated IP packet */
-+ union olsr_ip_addr mcSrc; /* Original source of the encapsulated multicast packet */
-+ union olsr_ip_addr mcDst; /* Multicast destination of the encapsulated packet */
-+ struct TBmfInterface* walker;
-+ ipHeader = (struct ip*) encapsulationUdpData;
-+ mcSrc.v4 = ipHeader->ip_src;
-+ mcDst.v4 = ipHeader->ip_dst;
-+
-+ OLSR_PRINTF(3, "MDNS PLUGIN got packet from OLSR message\n");
-+
-+
-+ /* Check with each network interface what needs to be done on it */
-+ for (walker = BmfInterfaces; walker != NULL; walker = walker->next)
-+ {
-+ /* To a non-OLSR interface: unpack the encapsulated IP packet and forward it */
-+ if (walker->olsrIntf == NULL)
-+ {
-+ int nBytesWritten;
-+ struct sockaddr_ll dest;
-+
-+ memset(&dest, 0, sizeof(dest));
-+ dest.sll_family = AF_PACKET;
-+ if ((encapsulationUdpData[0] & 0xf0) == 0x40) dest.sll_protocol = htons(ETH_P_IP);
-+ if ((encapsulationUdpData[0] & 0xf0) == 0x60) dest.sll_protocol = htons(ETH_P_IPV6);
-+ //TODO: if packet is not IP die here
-+ dest.sll_ifindex = if_nametoindex(walker->ifName);
-+ dest.sll_halen = IFHWADDRLEN;
-+
-+ /* Use all-ones as destination MAC address. When the IP destination is
-+ * a multicast address, the destination MAC address should normally also
-+ * be a multicast address. E.g., when the destination IP is 224.0.0.1,
-+ * the destination MAC should be 01:00:5e:00:00:01. However, it does not
-+ * seem to matter when the destination MAC address is set to all-ones
-+ * in that case. */
-+ memset(dest.sll_addr, 0xFF, IFHWADDRLEN);
-+
-+ nBytesWritten = sendto(
-+ walker->capturingSkfd,
-+ encapsulationUdpData,
-+ len,
-+ 0,
-+ (struct sockaddr*) &dest,
-+ sizeof(dest));
-+ if (nBytesWritten != len)
-+ {
-+ BmfPError("sendto() error forwarding unpacked encapsulated pkt on \"%s\"", walker->ifName);
-+ }
-+ else
-+ {
-+
-+ OLSR_PRINTF(
-+ 2,
-+ "%s: --> unpacked and forwarded on \"%s\"\n",
-+ PLUGIN_NAME_SHORT,
-+ walker->ifName);
-+ }
-+ } /* if (walker->olsrIntf == NULL) */
-+}
-+} /* PacketReceivedFromOLSR */
-+
-+
-+
-+bool
-+olsr_parser(union olsr_message *m,
-+ struct interface *in_if __attribute__((unused)),
-+ union olsr_ip_addr *ipaddr)
-+{
-+ union olsr_ip_addr originator;
-+ int size;
-+ olsr_reltime vtime;
-+ OLSR_PRINTF(2, "MDNS PLUGIN: Received msg in parser\n");
-+ /* Fetch the originator of the messsage */
-+ if(olsr_cnf->ip_version == AF_INET) {
-+ memcpy(&originator, &m->v4.originator, olsr_cnf->ipsize);
-+ vtime = me_to_reltime(m->v4.olsr_vtime);
-+ size = ntohs(m->v4.olsr_msgsize);
-+ } else {
-+ memcpy(&originator, &m->v6.originator, olsr_cnf->ipsize);
-+ vtime = me_to_reltime(m->v6.olsr_vtime);
-+ size = ntohs(m->v6.olsr_msgsize);
-+ }
-+
-+ /* Check if message originated from this node.
-+ * If so - back off */
-+ if(ipequal(&originator, &olsr_cnf->main_addr))
-+ return false;
-+
-+ /* Check that the neighbor this message was received from is symmetric.
-+ * If not - back off*/
-+ if(check_neighbor_link(ipaddr) != SYM_LINK) {
-+ struct ipaddr_str strbuf;
-+ OLSR_PRINTF(3, "NAME PLUGIN: Received msg from NON SYM neighbor %s\n", olsr_ip_to_string(&strbuf, ipaddr));
-+ return false;
-+ }
-+
-+ if(olsr_cnf->ip_version == AF_INET){
-+ PacketReceivedFromOLSR((unsigned char*) &m->v4.message,size-12);
-+ }
-+ else {
-+ PacketReceivedFromOLSR((unsigned char*) &m->v6.message,size-12-96);
-+ }
-+ /* Forward the message */
-+ return 1;
-+}
-+
-+//Sends a packet in the OLSR network
-+void
-+olsr_mdns_gen(unsigned char* packet, int len)
-+{
-+ /* send buffer: huge */
-+ char buffer[10240];
-+ union olsr_message *message = (union olsr_message *)buffer;
-+ struct interface *ifn;
-+ //int namesize;
-+
-+ /* fill message */
-+ if(olsr_cnf->ip_version == AF_INET)
-+ {
-+ /* IPv4 */
-+ message->v4.olsr_msgtype = MESSAGE_TYPE;
-+ message->v4.olsr_vtime = reltime_to_me(MDNS_VALID_TIME * MSEC_PER_SEC);
-+ memcpy(&message->v4.originator, &olsr_cnf->main_addr, olsr_cnf->ipsize);
-+ message->v4.ttl = MAX_TTL;
-+ message->v4.hopcnt = 0;
-+ message->v4.seqno = htons(get_msg_seqno());
-+
-+ message->v4.olsr_msgsize = htons(len+12);
-+
-+ memcpy(&message->v4.message,packet,len);
-+ len=len+12;
-+ }
-+ else
-+ {
-+ /* IPv6 */
-+ message->v6.olsr_msgtype = MESSAGE_TYPE;
-+ message->v6.olsr_vtime = reltime_to_me(MDNS_VALID_TIME * MSEC_PER_SEC);
-+ memcpy(&message->v6.originator, &olsr_cnf->main_addr, olsr_cnf->ipsize);
-+ message->v6.ttl = MAX_TTL;
-+ message->v6.hopcnt = 0;
-+ message->v6.seqno = htons(get_msg_seqno());
-+
-+ message->v6.olsr_msgsize = htons(len+12+96);
-+ memcpy(&message->v6.message,packet,len);
-+ len=len+12+96;
-+ }
-+
-+ /* looping trough interfaces */
-+ for (ifn = ifnet; ifn; ifn = ifn->int_next) {
-+ OLSR_PRINTF(1, "MDNS PLUGIN: Generating packet - [%s]\n", ifn->int_name);
-+
-+ if(net_outbuffer_push(ifn, message, len) != len) {
-+ /* send data and try again */
-+ net_output(ifn);
-+ if(net_outbuffer_push(ifn, message, len) != len) {
-+ OLSR_PRINTF(1, "MDNS PLUGIN: could not send on interface: %s\n", ifn->int_name);
-+ }
-+ }
-+ }
-+}
-+
-+/* -------------------------------------------------------------------------
-+ * Function : BmfPError
-+ * Description: Prints an error message at OLSR debug level 1.
-+ * First the plug-in name is printed. Then (if format is not NULL
-+ * and *format is not empty) the arguments are printed, followed
-+ * by a colon and a blank. Then the message and a new-line.
-+ * Input : format, arguments
-+ * Output : none
-+ * Return : none
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+
-+void BmfPError(const char* format, ...)
-+{
-+#define MAX_STR_DESC 255
-+#ifndef NODEBUG
-+ char* strErr = strerror(errno);
-+#endif
-+ char strDesc[MAX_STR_DESC];
-+
-+ /* Rely on short-circuit boolean evaluation */
-+ if (format == NULL || *format == '\0')
-+ {
-+ OLSR_PRINTF(1, "%s: %s\n", PLUGIN_NAME, strErr);
-+ }
-+ else
-+ {
-+ va_list arglist;
-+
-+ OLSR_PRINTF(1, "%s: ", PLUGIN_NAME);
-+
-+ va_start(arglist, format);
-+ vsnprintf(strDesc, MAX_STR_DESC, format, arglist);
-+ va_end(arglist);
-+
-+ strDesc[MAX_STR_DESC - 1] = '\0'; /* Ensures null termination */
-+
-+ OLSR_PRINTF(1, "%s: %s\n", strDesc, strErr);
-+ }
-+} /* BmfPError */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : MainAddressOf
-+ * Description: Lookup the main address of a node
-+ * Input : ip - IP address of the node
-+ * Output : none
-+ * Return : The main IP address of the node
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+union olsr_ip_addr* MainAddressOf(union olsr_ip_addr* ip)
-+{
-+ union olsr_ip_addr* result;
-+
-+ /* TODO: mid_lookup_main_addr() is not thread-safe! */
-+ result = mid_lookup_main_addr(ip);
-+ if (result == NULL)
-+ {
-+ result = ip;
-+ }
-+ return result;
-+} /* MainAddressOf */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : EncapsulateAndForwardPacket
-+ * Description: Encapsulate a captured raw IP packet and forward it
-+ * Input : intf - the network interface on which to forward the packet
-+ * encapsulationUdpData - The encapsulation header, followed by
-+ * the encapsulated IP packet
-+ * Output : none
-+ * Return : none
-+ * Data Used : none
-+ * ------------------------------------------------------------------------- */
-+//static void EncapsulateAndForwardPacket(
-+// struct TBmfInterface* intf,
-+// unsigned char* encapsulationUdpData)
-+//{
-+//// /* The packet */
-+// u_int16_t udpDataLen = GetEncapsulationUdpDataLength(encapsulationUdpData);
-+//
-+// /* The next destination(s) */
-+// struct TBestNeighbors bestNeighborLinks;
-+// struct link_entry* bestNeighbor;
-+//
-+// int nPossibleNeighbors = 0;
-+// struct sockaddr_in forwardTo; /* Next destination of encapsulation packet */
-+// int nPacketsToSend;
-+// int sendUnicast; /* 0 = send broadcast; 1 = send unicast */
-+//
-+// int i;
-+//
-+// /* Find at most 'FanOutLimit' best neigbors to forward the packet to */
-+// FindNeighbors(&bestNeighborLinks, &bestNeighbor, intf, NULL, NULL, NULL, &nPossibleNeighbors);
-+//
-+// if (nPossibleNeighbors <= 0)
-+// {
-+// OLSR_PRINTF(
-+// 8,
-+// "%s: --> not encap-forwarding on \"%s\": there is no neighbor that needs my retransmission\n",
-+// PLUGIN_NAME_SHORT,
-+// intf->ifName);
-+// return;
-+// }
-+//
-+// /* Compose destination of encapsulation packet */
-+//
-+// memset(&forwardTo, 0, sizeof(forwardTo));
-+// forwardTo.sin_family = AF_INET;
-+// forwardTo.sin_port = htons(BMF_ENCAP_PORT);
-+//
-+// /* Start by filling in the local broadcast address. This may be overwritten later. */
-+// forwardTo.sin_addr = intf->broadAddr.v4;
-+//
-+// /* - If the BMF mechanism is BM_UNICAST_PROMISCUOUS, always send just one
-+// * unicast packet (to the best neighbor).
-+// * - But if the BMF mechanism is BM_BROADCAST,
-+// * - send 'nPossibleNeighbors' unicast packets if there are up to
-+// * 'FanOutLimit' possible neighbors,
-+// * - if there are more than 'FanOutLimit' possible neighbors, then
-+// * send a (WLAN-air-expensive, less reliable) broadcast packet. */
-+// if (BmfMechanism == BM_UNICAST_PROMISCUOUS)
-+// {
-+// /* One unicast packet to the best neighbor */
-+// nPacketsToSend = 1;
-+// sendUnicast = 1;
-+// bestNeighborLinks.links[0] = bestNeighbor;
-+// }
-+// else /* BmfMechanism == BM_BROADCAST */
-+// {
-+// if (nPossibleNeighbors <= FanOutLimit)
-+// {
-+// /* 'nPossibleNeighbors' unicast packets */
-+// nPacketsToSend = nPossibleNeighbors;
-+// sendUnicast = 1;
-+// }
-+// else /* nPossibleNeighbors > FanOutLimit */
-+// {
-+// /* One broadcast packet, possibly retransmitted as specified in the
-+// * 'BroadcastRetransmitCount' plugin parameter */
-+// nPacketsToSend = BroadcastRetransmitCount;
-+// sendUnicast = 0;
-+// } /* if */
-+// } /* if */
-+//
-+// for (i = 0; i < nPacketsToSend; i++)
-+// {
-+// int nBytesWritten;
-+//
-+// if (sendUnicast == 1)
-+// {
-+// /* For unicast, overwrite the local broadcast address which was filled in above */
-+// forwardTo.sin_addr = bestNeighborLinks.links[i]->neighbor_iface_addr.v4;
-+// }
-+//
-+// /* Forward the BMF packet via the encapsulation socket */
-+// nBytesWritten = sendto(
-+// intf->encapsulatingSkfd,
-+// encapsulationUdpData,
-+// udpDataLen,
-+// MSG_DONTROUTE,
-+// (struct sockaddr*) &forwardTo,
-+// sizeof(forwardTo));
-+//
-+// /* Evaluate and display result */
-+// if (nBytesWritten != udpDataLen)
-+// {
-+// BmfPError("sendto() error forwarding pkt on \"%s\"", intf->ifName);
-+// }
-+// else
-+// {
-+// /* Increase counter */
-+// intf->nBmfPacketsTx++;
-+//
-+// OLSR_PRINTF(
-+// 8,
-+// "%s: --> encapsulated and forwarded on \"%s\" to %s\n",
-+// PLUGIN_NAME_SHORT,
-+// intf->ifName,
-+// inet_ntoa(forwardTo.sin_addr));
-+// } /* if (nBytesWritten != udpDataLen) */
-+// } /* for */
-+//} /* EncapsulateAndForwardPacket */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : BmfPacketCaptured
-+ * Description: Handle a captured IP packet
-+ * Input : intf - the network interface on which the packet was captured
-+ * sllPkttype - the type of packet. Either PACKET_OUTGOING,
-+ * PACKET_BROADCAST or PACKET_MULTICAST.
-+ * encapsulationUdpData - space for the encapsulation header, followed by
-+ * the captured IP packet
-+ * Output : none
-+ * Return : none
-+ * Data Used : BmfInterfaces
-+ * Notes : The IP packet is assumed to be captured on a socket of family
-+ * PF_PACKET and type SOCK_DGRAM (cooked).
-+ * ------------------------------------------------------------------------- */
-+static void BmfPacketCaptured(
-+ //struct TBmfInterface* intf,
-+ //unsigned char sllPkttype,
-+ unsigned char* encapsulationUdpData,
-+ int nBytes)
-+{
-+ union olsr_ip_addr src; /* Source IP address in captured packet */
-+ union olsr_ip_addr dst; /* Destination IP address in captured packet */
-+ union olsr_ip_addr* origIp; /* Main OLSR address of source of captured packet */
-+ //struct TBmfInterface* walker;
-+ //int isFromOlsrIntf;
-+ //int isFromOlsrNeighbor;
-+ //int iAmMpr;
-+ //unsigned char* ipPacket; /* The captured IP packet... */
-+ //u_int16_t ipPacketLen; /* ...and its length */
-+ struct ip* ipHeader; /* The IP header inside the captured IP packet */
-+ struct ip6_hdr* ipHeader6; /* The IP header inside the captured IP packet */
-+ //u_int32_t crc32;
-+ //struct TEncapHeader* encapHdr;
-+ //struct ipaddr_str srcBuf, dstBuf;
-+ struct udphdr* udpHeader;
-+ u_int16_t destPort;
-+
-+ if ((encapsulationUdpData[0] & 0xf0) == 0x40) { //IPV4
-+
-+ ipHeader = (struct ip*) encapsulationUdpData;
-+
-+ dst.v4 = ipHeader->ip_dst;
-+
-+ /* Only forward multicast packets. If configured, also forward local broadcast packets */
-+ if (IsMulticast(&dst))
-+ {
-+ /* continue */
-+ }
-+ else
-+ {
-+ return;
-+ }
-+ if (ipHeader->ip_p != SOL_UDP)
-+ {
-+ /* Not UDP */
-+ OLSR_PRINTF(1,"NON UDP PACKET\n");
-+ return; /* for */
-+ }
-+ udpHeader = (struct udphdr*)(encapsulationUdpData + GetIpHeaderLength(encapsulationUdpData));
-+ destPort = ntohs(udpHeader->dest);
-+ if (destPort != 5353)
-+ {
-+ return;
-+ }
-+ }//END IPV4
-+
-+ else if ((encapsulationUdpData[0] & 0xf0) == 0x60) { //IPv6
-+
-+ ipHeader6 = (struct ip6_hdr*) encapsulationUdpData;
-+ if (ipHeader6->ip6_dst.s6_addr[0] == 0xff) //Multicast
-+ {
-+ //Continua
-+ }
-+ else
-+ {
-+ return; //not multicast
-+ }
-+ if (ipHeader6->ip6_nxt != SOL_UDP)
-+ {
-+ /* Not UDP */
-+ OLSR_PRINTF(1,"NON UDP PACKET\n");
-+ return; /* for */
-+ }
-+ udpHeader = (struct udphdr*)(encapsulationUdpData + 40);
-+ destPort = ntohs(udpHeader->dest);
-+ if (destPort != 5353)
-+ {
-+ return;
-+ }
-+ } //END IPV6
-+ else return; //Is not IP packet
-+
-+ /* Check if the frame is captured on an OLSR-enabled interface */
-+ //isFromOlsrIntf = (intf->olsrIntf != NULL); TODO: put again this check
-+
-+ /* Retrieve the length of the captured packet */
-+ //ipPacketLen = GetIpTotalLength(ipPacket);
-+
-+ //src.v4 = ipHeader->ip_src;
-+
-+ //OLSR_PRINTF(
-+ // 1,
-+ // "%s: %s pkt of %ld bytes captured on %s interface \"%s\": %s->%s\n",
-+ // PLUGIN_NAME_SHORT,
-+ // sllPkttype == PACKET_OUTGOING ? "outgoing" : "incoming",
-+ // (long)ipPacketLen,
-+ // isFromOlsrIntf ? "OLSR" : "non-OLSR",
-+ // intf->ifName,
-+ // olsr_ip_to_string(&srcBuf, &src),
-+ // olsr_ip_to_string(&dstBuf, &dst));
-+
-+ /* Lookup main address of source in the MID table of OLSR */
-+ origIp = MainAddressOf(&src);
-+
-+ // send the packet to OLSR forward mechanism
-+ olsr_mdns_gen(encapsulationUdpData,nBytes);
-+} /* BmfPacketCaptured */
-+
-+
-+/* -------------------------------------------------------------------------
-+ * Function : BmfEncapsulationPacketReceived
-+ * Description: Handle a received BMF-encapsulation packet
-+ * Input : intf - the network interface on which the packet was received
-+ * forwardedBy - the IP node that forwarded the packet to me
-+ * forwardedTo - the destination IP address of the encapsulation
-+ * packet, in case the packet was received promiscuously.
-+ * Pass NULL if the packet is received normally (unicast or
-+ * broadcast).
-+ * encapsulationUdpData - the encapsulating IP UDP data, containting
-+ * the BMF encapsulation header, followed by the encapsulated
-+ * IP packet
-+ * Output : none
-+ * Return : none
-+ * Data Used : BmfInterfaces
-+ * ------------------------------------------------------------------------- */
-+//static void BmfEncapsulationPacketReceived(
-+// struct TBmfInterface* intf,
-+// union olsr_ip_addr* forwardedBy,
-+// union olsr_ip_addr* forwardedTo,
-+// unsigned char* encapsulationUdpData)
-+//{
-+// int iAmMpr; /* True (1) if I am selected as MPR by 'forwardedBy' */
-+// struct sockaddr_in forwardTo; /* Next destination of encapsulation packet */
-+// unsigned char* ipPacket; /* The encapsulated IP packet */
-+// u_int16_t ipPacketLen; /* Length of the encapsulated IP packet */
-+// struct ip* ipHeader; /* IP header inside the encapsulated IP packet */
-+// union olsr_ip_addr mcSrc; /* Original source of the encapsulated multicast packet */
-+// union olsr_ip_addr mcDst; /* Multicast destination of the encapsulated packet */
-+// struct TEncapHeader* encapsulationHdr;
-+// u_int16_t encapsulationUdpDataLen;
-+// struct TBmfInterface* walker;
-+// struct ipaddr_str mcSrcBuf, mcDstBuf, forwardedByBuf, forwardedToBuf;
-+// /* Are we talking to ourselves? */
-+// if (if_ifwithaddr(forwardedBy) != NULL)
-+// {
-+// return;
-+// }
-+//
-+// /* Discard encapsulated packets received on a non-OLSR interface */
-+// if (intf->olsrIntf == NULL)
-+// {
-+// return;
-+// }
-+//
-+// /* Retrieve details about the encapsulated IP packet */
-+// ipPacket = GetIpPacket(encapsulationUdpData);
-+// ipPacketLen = GetIpTotalLength(ipPacket);
-+// ipHeader = GetIpHeader(encapsulationUdpData);
-+//
-+// mcSrc.v4 = ipHeader->ip_src;
-+// mcDst.v4 = ipHeader->ip_dst;
-+//
-+// /* Increase counter */
-+// intf->nBmfPacketsRx++;
-+//
-+// /* Beware: not possible to call olsr_ip_to_string more than 4 times in same printf */
-+// OLSR_PRINTF(
-+// 8,
-+// "%s: encapsulated pkt of %ld bytes incoming on \"%s\": %s->%s, forwarded by %s to %s\n",
-+// PLUGIN_NAME_SHORT,
-+// (long)ipPacketLen,
-+// intf->ifName,
-+// olsr_ip_to_string(&mcSrcBuf, &mcSrc),
-+// olsr_ip_to_string(&mcDstBuf, &mcDst),
-+// olsr_ip_to_string(&forwardedByBuf, forwardedBy),
-+// forwardedTo != NULL ? olsr_ip_to_string(&forwardedToBuf, forwardedTo) : "me");
-+//
-+// /* Get encapsulation header */
-+// encapsulationHdr = (struct TEncapHeader*) encapsulationUdpData;
-+//
-+// /* Verify correct format of BMF encapsulation header */
-+// if (encapsulationHdr->type != BMF_ENCAP_TYPE ||
-+// encapsulationHdr->len != BMF_ENCAP_LEN ||
-+// ntohs(encapsulationHdr->reserved != 0))
-+// {
-+// OLSR_PRINTF(
-+// 8,
-+// "%s: --> discarding: format of BMF encapsulation header not recognized\n",
-+// PLUGIN_NAME_SHORT);
-+// return;
-+// }
-+//
-+// /* Check if this packet was seen recently */
-+// if (CheckAndMarkRecentPacket(ntohl(encapsulationHdr->crc32)))
-+// {
-+// /* Increase counter */
-+// intf->nBmfPacketsRxDup++;
-+//
-+// OLSR_PRINTF(
-+// 8,
-+// "%s: --> discarding: packet is duplicate\n",
-+// PLUGIN_NAME_SHORT);
-+// return;
-+// }
-+//
-+// if (EtherTunTapFd >= 0)
-+// {
-+// /* Unpack the encapsulated IP packet and deliver it locally, by sending
-+// * a copy into the local IP stack via the EtherTunTap interface */
-+//
-+// union olsr_ip_addr broadAddr;
-+// int nBytesToWrite, nBytesWritten;
-+// unsigned char* bufferToWrite;
-+//
-+// /* If the encapsulated IP packet is a local broadcast packet,
-+// * update its destination address to match the subnet of the EtherTunTap
-+// * interface */
-+// broadAddr.v4.s_addr = htonl(EtherTunTapIpBroadcast);
-+// CheckAndUpdateLocalBroadcast(ipPacket, &broadAddr);
-+//
-+// bufferToWrite = ipPacket;
-+// nBytesToWrite = ipPacketLen;
-+//
-+// /* Write the packet into the EtherTunTap interface for local delivery */
-+// nBytesWritten = write(EtherTunTapFd, bufferToWrite, nBytesToWrite);
-+// if (nBytesWritten != nBytesToWrite)
-+// {
-+// BmfPError("write() error forwarding encapsulated pkt on \"%s\"", EtherTunTapIfName);
-+// }
-+// else
-+// {
-+// OLSR_PRINTF(
-+// 8,
-+// "%s: --> unpacked and delivered locally on \"%s\"\n",
-+// PLUGIN_NAME_SHORT,
-+// EtherTunTapIfName);
-+// }
-+// } /* if (EtherTunTapFd >= 0) */
-+//
-+// /* Check if I am MPR for the forwarder */
-+// /* TODO: olsr_lookup_mprs_set() is not thread-safe! */
-+// iAmMpr = (olsr_lookup_mprs_set(MainAddressOf(forwardedBy)) != NULL);
-+//
-+// /* Compose destination address for next hop */
-+// memset(&forwardTo, 0, sizeof(forwardTo));
-+// forwardTo.sin_family = AF_INET;
-+// forwardTo.sin_port = htons(BMF_ENCAP_PORT);
-+//
-+// /* Retrieve the number of bytes to be forwarded via the encapsulation socket */
-+// encapsulationUdpDataLen = GetEncapsulationUdpDataLength(encapsulationUdpData);
-+//
-+// /* Check with each network interface what needs to be done on it */
-+// for (walker = BmfInterfaces; walker != NULL; walker = walker->next)
-+// {
-+// /* What to do with the packet on a non-OLSR interface? Unpack
-+// * encapsulated packet, and forward it.
-+// *
-+// * What to do with the packet on an OLSR interface? Forward it only
-+// * if the forwarding node has selected us as MPR (iAmMpr).
-+// *
-+// * Note that the packet is always coming in on an OLSR interface, because
-+// * it is an encapsulated BMF packet. */
-+//
-+// /* To a non-OLSR interface: unpack the encapsulated IP packet and forward it */
-+// if (walker->olsrIntf == NULL)
-+// {
-+// int nBytesWritten;
-+// struct sockaddr_ll dest;
-+//
-+// /* If the encapsulated IP packet is a local broadcast packet,
-+// * update its destination address to match the subnet of the network
-+// * interface on which the packet is being sent. */
-+// CheckAndUpdateLocalBroadcast(ipPacket, &walker->broadAddr);
-+//
-+// memset(&dest, 0, sizeof(dest));
-+// dest.sll_family = AF_PACKET;
-+// dest.sll_protocol = htons(ETH_P_IP);
-+// dest.sll_ifindex = if_nametoindex(walker->ifName);
-+// dest.sll_halen = IFHWADDRLEN;
-+//
-+// /* Use all-ones as destination MAC address. When the IP destination is
-+// * a multicast address, the destination MAC address should normally also
-+// * be a multicast address. E.g., when the destination IP is 224.0.0.1,
-+// * the destination MAC should be 01:00:5e:00:00:01. However, it does not
-+// * seem to matter when the destination MAC address is set to all-ones
-+// * in that case. */
-+// memset(dest.sll_addr, 0xFF, IFHWADDRLEN);
-+//
-+// nBytesWritten = sendto(
-+// walker->capturingSkfd,
-+// ipPacket,
-+// ipPacketLen,
-+// 0,
-+// (struct sockaddr*) &dest,
-+// sizeof(dest));
-+// if (nBytesWritten != ipPacketLen)
-+// {
-+// BmfPError("sendto() error forwarding unpacked encapsulated pkt on \"%s\"", walker->ifName);
-+// }
-+// else
-+// {
-+// /* Increase counter */
-+// walker->nBmfPacketsTx++;
-+//
-+// OLSR_PRINTF(
-+// 8,
-+// "%s: --> unpacked and forwarded on \"%s\"\n",
-+// PLUGIN_NAME_SHORT,
-+// walker->ifName);
-+// }
-+// } /* if (walker->olsrIntf == NULL) */
-+//
-+// /* To an OLSR interface: forward the packet, but only if this node is
-+// * selected as MPR by the forwarding node */
-+// else if (iAmMpr)
-+// {
-+// struct TBestNeighbors bestNeighborLinks;
-+// struct link_entry* bestNeighbor;
-+// int nPossibleNeighbors;
-+// int nPacketsToSend;
-+// int sendUnicast; /* 0 = send broadcast; 1 = send unicast */
-+// int i;
-+//
-+// /* Retrieve at most two best neigbors to forward the packet to */
-+// FindNeighbors(
-+// &bestNeighborLinks,
-+// &bestNeighbor,
-+// walker,
-+// &mcSrc,
-+// forwardedBy,
-+// forwardedTo,
-+// &nPossibleNeighbors);
-+//
-+// if (nPossibleNeighbors <= 0)
-+// {
-+// OLSR_PRINTF(
-+// 8,
-+// "%s: --> not forwarding on \"%s\": there is no neighbor that needs my retransmission\n",
-+// PLUGIN_NAME_SHORT,
-+// walker->ifName);
-+//
-+// continue; /* for */
-+// }
-+//
-+// /* Compose destination of encapsulation packet.
-+// * Start by filling in the local broadcast address. This may be overwritten later. */
-+// forwardTo.sin_addr = walker->broadAddr.v4;
-+//
-+// /* - If the BMF mechanism is BM_UNICAST_PROMISCUOUS, always send just one
-+// * unicast packet (to the best neighbor).
-+// * - But if the BMF mechanism is BM_BROADCAST,
-+// * - send 'nPossibleNeighbors' unicast packets if there are up to
-+// * 'FanOutLimit' possible neighbors,
-+// * - if there are more than 'FanOutLimit' possible neighbors, then
-+// * send a (WLAN-air-expensive, less reliable) broadcast packet. */
-+// if (BmfMechanism == BM_UNICAST_PROMISCUOUS)
-+// {
-+// /* One unicast packet to the best neighbor */
-+// nPacketsToSend = 1;
-+// sendUnicast = 1;
-+// bestNeighborLinks.links[0] = bestNeighbor;
-+// }
-+// else /* BmfMechanism == BM_BROADCAST */
-+// {
-+// if (nPossibleNeighbors <= FanOutLimit)
-+// {
-+// /* 'nPossibleNeighbors' unicast packets */
-+// nPacketsToSend = nPossibleNeighbors;
-+// sendUnicast = 1;
-+// }
-+// else /* nPossibleNeighbors > FanOutLimit */
-+// {
-+// /* One broadcast packet, possibly retransmitted as specified in the
-+// * 'BroadcastRetransmitCount' plugin parameter */
-+// nPacketsToSend = BroadcastRetransmitCount;
-+// sendUnicast = 0;
-+// } /* if */
-+// } /* if */
-+//
-+// for (i = 0; i < nPacketsToSend; i++)
-+// {
-+// int nBytesWritten;
-+//
-+// if (sendUnicast)
-+// {
-+// /* For unicast, overwrite the local broadcast address which was filled in above */
-+// forwardTo.sin_addr = bestNeighborLinks.links[i]->neighbor_iface_addr.v4;
-+// }
-+//
-+// /* Forward the BMF packet via the encapsulation socket */
-+// nBytesWritten = sendto(
-+// walker->encapsulatingSkfd,
-+// encapsulationUdpData,
-+// encapsulationUdpDataLen,
-+// MSG_DONTROUTE,
-+// (struct sockaddr*) &forwardTo,
-+// sizeof(forwardTo));
-+//
-+// /* Evaluate and display result */
-+// if (nBytesWritten != encapsulationUdpDataLen)
-+// {
-+// BmfPError("sendto() error forwarding encapsulated pkt on \"%s\"", walker->ifName);
-+// }
-+// else
-+// {
-+// /* Increase counter */
-+// walker->nBmfPacketsTx++;
-+//
-+// OLSR_PRINTF(
-+// 8,
-+// "%s: --> forwarded on \"%s\" to %s\n",
-+// PLUGIN_NAME_SHORT,
-+// walker->ifName,
-+// inet_ntoa(forwardTo.sin_addr));
-+// } /* if */
-+// } /* for */
-+// } /* else if (iAmMpr) */
-+//
-+// else /* walker->olsrIntf != NULL && !iAmMpr */
-+// {
-+// struct ipaddr_str buf;
-+// /* 'walker' is an OLSR interface, but I am not selected as MPR. In that
-+// * case, don't forward. */
-+// OLSR_PRINTF(
-+// 8,
-+// "%s: --> not forwarding on \"%s\": I am not selected as MPR by %s\n",
-+// PLUGIN_NAME_SHORT,
-+// walker->ifName,
-+// olsr_ip_to_string(&buf, forwardedBy));
-+// } /* else */
-+// } /* for */
-+//} /* BmfEncapsulationPacketReceived */
-+//
-+/* -------------------------------------------------------------------------
-+ * Function : BmfTunPacketCaptured
-+ * Description: Handle an IP packet, captured outgoing on the tuntap interface
-+ * Input : encapsulationUdpData - space for the encapsulation header, followed by
-+ * the captured outgoing IP packet
-+ * Output : none
-+ * Return : none
-+ * Data Used : none
-+ * Notes : The packet is assumed to be captured on a socket of family
-+ * PF_PACKET and type SOCK_DGRAM (cooked).
-+ * ------------------------------------------------------------------------- */
-+//static void BmfTunPacketCaptured(unsigned char* encapsulationUdpData)
-+//{
-+// union olsr_ip_addr srcIp;
-+// union olsr_ip_addr dstIp;
-+// union olsr_ip_addr broadAddr;
-+// struct TBmfInterface* walker;
-+// unsigned char* ipPacket;
-+// u_int16_t ipPacketLen;
-+// struct ip* ipHeader;
-+// u_int32_t crc32;
-+// struct TEncapHeader* encapHdr;
-+// struct ipaddr_str srcIpBuf, dstIpBuf;
-+// ipPacket = GetIpPacket(encapsulationUdpData);
-+// ipPacketLen = GetIpTotalLength(ipPacket);
-+// ipHeader = GetIpHeader(encapsulationUdpData);
-+//
-+// dstIp.v4 = ipHeader->ip_dst;
-+// broadAddr.v4.s_addr = htonl(EtherTunTapIpBroadcast);
-+//
-+// /* Only forward multicast packets. If configured, also forward local broadcast packets */
-+// if (IsMulticast(&dstIp) ||
-+// (EnableLocalBroadcast != 0 && olsr_ipequal(&dstIp, &broadAddr)))
-+// {
-+// /* continue */
-+// }
-+// else
-+// {
-+// return;
-+// }
-+//
-+// srcIp.v4 = ipHeader->ip_src;
-+//
-+// OLSR_PRINTF(
-+// 8,
-+// "%s: outgoing pkt of %ld bytes captured on tuntap interface \"%s\": %s->%s\n",
-+// PLUGIN_NAME_SHORT,
-+// (long)ipPacketLen,
-+// EtherTunTapIfName,
-+// olsr_ip_to_string(&srcIpBuf, &srcIp),
-+// olsr_ip_to_string(&dstIpBuf, &dstIp));
-+//
-+// /* Calculate packet fingerprint */
-+// crc32 = PacketCrc32(ipPacket, ipPacketLen);
-+//
-+// /* Check if this packet was seen recently */
-+// if (CheckAndMarkRecentPacket(crc32))
-+// {
-+// OLSR_PRINTF(
-+// 8,
-+// "%s: --> discarding: packet is duplicate\n",
-+// PLUGIN_NAME_SHORT);
-+// return;
-+// }
-+//
-+// /* Compose encapsulation header */
-+// encapHdr = (struct TEncapHeader*) encapsulationUdpData;
-+// memset (encapHdr, 0, ENCAP_HDR_LEN);
-+// encapHdr->type = BMF_ENCAP_TYPE;
-+// encapHdr->len = BMF_ENCAP_LEN;
-+// encapHdr->reserved = 0;
-+// encapHdr->crc32 = htonl(crc32);
-+//
-+// /* Check with each network interface what needs to be done on it */
-+// for (walker = BmfInterfaces; walker != NULL; walker = walker->next)
-+// {
-+// /* Is the forwarding interface OLSR-enabled? */
-+// if (walker->olsrIntf != NULL)
-+// {
-+// /* On an OLSR interface: encapsulate and forward packet. */
-+//
-+// EncapsulateAndForwardPacket(walker, encapsulationUdpData);
-+// }
-+// else
-+// {
-+// /* On a non-OLSR interface: what to do?
-+// * Answer 1: nothing. Multicast routing between non-OLSR interfaces
-+// * is to be done by other protocols (e.g. PIM, DVMRP).
-+// * Answer 2 (better): Forward it. */
-+//
-+// int nBytesWritten;
-+// struct sockaddr_ll dest;
-+//
-+// /* If the encapsulated IP packet is a local broadcast packet,
-+// * update its destination address to match the subnet of the network
-+// * interface on which the packet is being sent. */
-+// CheckAndUpdateLocalBroadcast(ipPacket, &walker->broadAddr);
-+//
-+// memset(&dest, 0, sizeof(dest));
-+// dest.sll_family = AF_PACKET;
-+// dest.sll_protocol = htons(ETH_P_IP);
-+// dest.sll_ifindex = if_nametoindex(walker->ifName);
-+// dest.sll_halen = IFHWADDRLEN;
-+//
-+// /* Use all-ones as destination MAC address. When the IP destination is
-+// * a multicast address, the destination MAC address should normally also
-+// * be a multicast address. E.g., when the destination IP is 224.0.0.1,
-+// * the destination MAC should be 01:00:5e:00:00:01. However, it does not
-+// * seem to matter when the destination MAC address is set to all-ones
-+// * in that case. */
-+// memset(dest.sll_addr, 0xFF, IFHWADDRLEN);
-+//
-+// nBytesWritten = sendto(
-+// walker->capturingSkfd,
-+// ipPacket,
-+// ipPacketLen,
-+// 0,
-+// (struct sockaddr*) &dest,
-+// sizeof(dest));
-+// if (nBytesWritten != ipPacketLen)
-+// {
-+// BmfPError("sendto() error forwarding pkt on \"%s\"", walker->ifName);
-+// }
-+// else
-+// {
-+// /* Increase counter */
-+// walker->nBmfPacketsTx++;
-+//
-+// OLSR_PRINTF(
-+// 8,
-+// "%s: --> forwarded from non-OLSR to non-OLSR \"%s\"\n",
-+// PLUGIN_NAME_SHORT,
-+// walker->ifName);
-+// } /* if */
-+// } /* if */
-+// } /* for */
-+//} /* BmfTunPacketCaptured */
-+//
-+/* -------------------------------------------------------------------------
-+ * Function : DoBmf
-+ * Description: Wait (blocking) for IP packets, then call the handler for each
-+ * received packet
-+ * Input : none
-+ * Output : none
-+ * Return : none
-+ * Data Used : BmfInterfaces
-+ * ------------------------------------------------------------------------- */
-+void DoMDNS(int skfd, void *data __attribute__ ((unused)), unsigned int flags __attribute__ ((unused)))
-+
-+{
-+// int nFdBitsSet;
-+ unsigned char rxBuffer[BMF_BUFFER_SIZE];
-+// fd_set rxFdSet;
-+// OLSR_PRINTF(1,"ENTERING DoMDNS\n");
-+// assert(HighestSkfd >= 0);
-+//
-+// /* Make a local copy of the set of file descriptors that select() can
-+// * modify to indicate which descriptors actually changed status */
-+// rxFdSet = InputSet;
-+//
-+// /* Wait (blocking) for packets received on any of the sockets.
-+// * NOTE: don't use a timeout (last parameter). It causes a high system CPU load! */
-+// nFdBitsSet = select(HighestSkfd + 1, &rxFdSet, NULL, NULL, NULL);
-+// if (nFdBitsSet < 0)
-+// {
-+// if (errno != EINTR)
-+// {
-+// BmfPError("select() error");
-+// }
-+// return;
-+// }
-+//
-+ //while (nFdBitsSet > 0)
-+ //{
-+ //struct TBmfInterface* walker;
-+
-+ /* Check if a packet was received on the capturing socket (if any)
-+ * of each network interface */
-+ //for (walker = BmfInterfaces; walker != NULL; walker = walker->next)
-+ //{
-+ //int skfd = walker->capturingSkfd;
-+ //if (skfd >= 0 && (FD_ISSET(skfd, &rxFdSet)))
-+ if (skfd >= 0)
-+ {
-+ struct sockaddr_ll pktAddr;
-+ socklen_t addrLen = sizeof(pktAddr);
-+ int nBytes;
-+ unsigned char* ipPacket;
-+
-+ /* Receive the captured Ethernet frame, leaving space for the BMF
-+ * encapsulation header */
-+ ipPacket = GetIpPacket(rxBuffer);
-+ nBytes = recvfrom(
-+ skfd,
-+ ipPacket,
-+ //BMF_BUFFER_SIZE - ENCAP_HDR_LEN, //TODO: understand how to change this
-+ BMF_BUFFER_SIZE, //TODO: understand how to change this
-+ 0,
-+ (struct sockaddr*)&pktAddr,
-+ &addrLen);
-+ if (nBytes < 0)
-+ {
-+ //BmfPError("recvfrom() error on \"%s\"", walker->ifName);
-+
-+ return; /* for */
-+ } /* if (nBytes < 0) */
-+
-+ /* Check if the number of received bytes is large enough for an IP
-+ * packet which contains at least a minimum-size IP header.
-+ * Note: There is an apparent bug in the packet socket implementation in
-+ * combination with VLAN interfaces. On a VLAN interface, the value returned
-+ * by 'recvfrom' may (but need not) be 4 (bytes) larger than the value
-+ * returned on a non-VLAN interface, for the same ethernet frame. */
-+ if (nBytes < (int)sizeof(struct ip))
-+ {
-+ //OLSR_PRINTF(
-+ // 1,
-+ // "%s: captured frame too short (%d bytes) on \"%s\"\n",
-+ // PLUGIN_NAME,
-+ // nBytes,
-+ // walker->ifName);
-+
-+ return; /* for */
-+ }
-+
-+ if (pktAddr.sll_pkttype == PACKET_OUTGOING ||
-+ pktAddr.sll_pkttype == PACKET_MULTICAST ||
-+ pktAddr.sll_pkttype == PACKET_BROADCAST)
-+ {
-+ /* A multicast or broadcast packet was captured */
-+
-+ //OLSR_PRINTF(
-+ // 1,
-+ // "%s: captured frame (%d bytes) on \"%s\"\n",
-+ // PLUGIN_NAME,
-+ // nBytes,
-+ // walker->ifName);
-+ //BmfPacketCaptured(walker, pktAddr.sll_pkttype, rxBuffer);
-+ BmfPacketCaptured(ipPacket,nBytes);
-+
-+ } /* if (pktAddr.sll_pkttype == ...) */
-+ } /* if (skfd >= 0 && (FD_ISSET...)) */
-+// } /* for */
-+
-+// } /* while (nFdBitsSet > 0) */
-+} /* DoMDNS */
-+
-+int InitMDNS(struct interface* skipThisIntf)
-+{
-+
-+
-+ //Tells OLSR to launch olsr_parser when the packets for this plugin arrive
-+ olsr_parser_add_function(&olsr_parser, PARSER_TYPE);
-+ CreateBmfNetworkInterfaces(skipThisIntf);
-+
-+ return 0;
-+} /* InitBmf */
-+
-+/* -------------------------------------------------------------------------
-+ * Function : CloseBmf
-+ * Description: Close the BMF plugin and clean up
-+ * Input : none
-+ * Output : none
-+ * Return : none
-+ * Data Used : BmfThread
-+ * ------------------------------------------------------------------------- */
-+void CloseMDNS(void)
-+{
-+// if (EtherTunTapFd >= 0)
-+// {
-+// /* If there is a multicast route, try to delete it first */
-+// DeleteMulticastRoute();
-+//
-+// /* Restore IP spoof filter for EtherTunTap interface */
-+// RestoreSpoofFilter();
-+// }
-+//
-+// if (mdnsThreadRunning)
-+// {
-+// /* Signal BmfThread to exit */
-+// /* Strangely enough, all running threads receive the SIGALRM signal. But only the
-+// * BMF thread is affected by this signal, having specified a handler for this
-+// * signal in its thread entry function BmfRun(...). */
-+// if (pthread_kill(mdnsThread, SIGALRM) != 0)
-+// {
-+// BmfPError("pthread_kill() error");
-+// }
-+//
-+// /* Wait for BmfThread to acknowledge */
-+// if (pthread_join(mdnsThread, NULL) != 0)
-+// {
-+// BmfPError("pthread_join() error");
-+// }
-+// }
-+//
-+// /* Clean up after the BmfThread has been killed */
-+ CloseBmfNetworkInterfaces();
-+} /* CloseBmf */
-+
-+
-+/*
-+ * Local Variables:
-+ * c-basic-offset: 2
-+ * indent-tabs-mode: nil
-+ * End:
-+ */
---- /dev/null
-+++ b/lib/mdns/src/mdns.h
-@@ -0,0 +1,95 @@
-+#ifndef _BMF_BMF_H
-+#define _BMF_BMF_H
-+
-+/*
-+ * OLSR Basic Multicast Forwarding (BMF) plugin.
-+ * Copyright (c) 2005 - 2007, Thales Communications, Huizen, The Netherlands.
-+ * Written by Erik Tromp.
-+ * All rights reserved.
-+ *
-+ * Redistribution and use in source and binary forms, with or without
-+ * modification, are permitted provided that the following conditions
-+ * are met:
-+ *
-+ * * Redistributions of source code must retain the above copyright
-+ * notice, this list of conditions and the following disclaimer.
-+ * * Redistributions in binary form must reproduce the above copyright
-+ * notice, this list of conditions and the following disclaimer in
-+ * the documentation and/or other materials provided with the
-+ * distribution.
-+ * * Neither the name of Thales, BMF nor the names of its
-+ * contributors may be used to endorse or promote products derived
-+ * from this software without specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
-+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-+ * OF THE POSSIBILITY OF SUCH DAMAGE.
-+ */
-+
-+/* -------------------------------------------------------------------------
-+ * File : Bmf.h
-+ * Description: Multicast forwarding functions
-+ * Created : 29 Jun 2006
-+ *
-+ * ------------------------------------------------------------------------- */
-+
-+#include "olsrd_plugin.h" /* union set_plugin_parameter_addon */
-+
-+#include "parser.h"
-+#include <socket_parser.h>
-+
-+#define MESSAGE_TYPE 132
-+#define PARSER_TYPE MESSAGE_TYPE
-+#define EMISSION_INTERVAL 10 /* seconds */
-+#define EMISSION_JITTER 25 /* percent */
-+#define MDNS_VALID_TIME 1800 /* seconds */
-+
-+/* BMF plugin data */
-+#define PLUGIN_NAME "OLSRD MDNS plugin"
-+#define PLUGIN_NAME_SHORT "OLSRD MDNS"
-+#define PLUGIN_VERSION "1.0.0 (" __DATE__ " " __TIME__ ")"
-+#define PLUGIN_COPYRIGHT " (C) Ninux.org"
-+#define PLUGIN_AUTHOR " Saverio Proto (zioproto@gmail.com)"
-+#define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION "\n" PLUGIN_COPYRIGHT "\n" PLUGIN_AUTHOR
-+#define PLUGIN_INTERFACE_VERSION 5
-+
-+/* UDP-Port on which multicast packets are encapsulated */
-+//#define BMF_ENCAP_PORT 50698
-+
-+/* Forward declaration of OLSR interface type */
-+struct interface;
-+
-+//extern int FanOutLimit;
-+//extern int BroadcastRetransmitCount;
-+
-+void DoMDNS(int sd, void * x, unsigned int y);
-+void BmfPError(const char* format, ...) __attribute__((format(printf, 1, 2)));
-+union olsr_ip_addr* MainAddressOf(union olsr_ip_addr* ip);
-+//int InterfaceChange(struct interface* interf, int action);
-+//int SetFanOutLimit(const char* value, void* data, set_plugin_parameter_addon addon);
-+//int InitBmf(struct interface* skipThisIntf);
-+//void CloseBmf(void);
-+int InitMDNS(struct interface* skipThisIntf);
-+void CloseMDNS(void);
-+
-+void olsr_mdns_gen(unsigned char* packet, int len);
-+
-+/* Parser function to register with the scheduler */
-+bool
-+olsr_parser(union olsr_message *, struct interface *, union olsr_ip_addr *);
-+
-+#endif /* _BMF_BMF_H */
-+
-+/*
-+ * Local Variables:
-+ * c-basic-offset: 2
-+ * indent-tabs-mode: nil
-+ * End:
-+ */
---- /dev/null
-+++ b/lib/mdns/src/olsrd_plugin.c
-@@ -0,0 +1,185 @@
-+/*
-+ * OLSR Basic Multicast Forwarding (BMF) plugin.
-+ * Copyright (c) 2005 - 2007, Thales Communications, Huizen, The Netherlands.
-+ * Written by Erik Tromp.
-+ * All rights reserved.
-+ *
-+ * Redistribution and use in source and binary forms, with or without
-+ * modification, are permitted provided that the following conditions
-+ * are met:
-+ *
-+ * * Redistributions of source code must retain the above copyright
-+ * notice, this list of conditions and the following disclaimer.
-+ * * Redistributions in binary form must reproduce the above copyright
-+ * notice, this list of conditions and the following disclaimer in
-+ * the documentation and/or other materials provided with the
-+ * distribution.
-+ * * Neither the name of Thales, BMF nor the names of its
-+ * contributors may be used to endorse or promote products derived
-+ * from this software without specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
-+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-+ * OF THE POSSIBILITY OF SUCH DAMAGE.
-+ */
-+
-+/* -------------------------------------------------------------------------
-+ * File : olsrd_plugin.c
-+ * Description: Interface to the OLSRD plugin system
-+ * Created : 29 Jun 2006
-+ *
-+ * ------------------------------------------------------------------------- */
-+
-+/* System includes */
-+#include <assert.h> /* assert() */
-+#include <stddef.h> /* NULL */
-+
-+/* OLSRD includes */
-+#include "olsrd_plugin.h"
-+#include "plugin_util.h"
-+#include "defs.h" /* uint8_t, olsr_cnf */
-+#include "scheduler.h" /* olsr_start_timer() */
-+#include "olsr_cfg.h" /* olsr_cnf() */
-+#include "olsr_cookie.h" /* olsr_alloc_cookie() */
-+
-+/* BMF includes */
-+#include "mdns.h" /* InitBmf(), CloseBmf() */
-+#include "PacketHistory.h" /* InitPacketHistory() */
-+#include "NetworkInterfaces.h" /* AddNonOlsrBmfIf(), SetBmfInterfaceIp(), ... */
-+#include "Address.h" /* DoLocalBroadcast() */
-+
-+static void __attribute__ ((constructor)) my_init(void);
-+static void __attribute__ ((destructor)) my_fini(void);
-+
-+//static struct olsr_cookie_info *prune_packet_history_timer_cookie;
-+
-+void olsr_plugin_exit(void);
-+
-+/* -------------------------------------------------------------------------
-+ * Function : olsrd_plugin_interface_version
-+ * Description: Plugin interface version
-+ * Input : none
-+ * Output : none
-+ * Return : BMF plugin interface version number
-+ * Data Used : none
-+ * Notes : Called by main OLSRD (olsr_load_dl) to check plugin interface
-+ * version
-+ * ------------------------------------------------------------------------- */
-+int olsrd_plugin_interface_version(void)
-+{
-+ return PLUGIN_INTERFACE_VERSION;
-+}
-+
-+/* -------------------------------------------------------------------------
-+ * Function : olsrd_plugin_init
-+ * Description: Plugin initialisation
-+ * Input : none
-+ * Output : none
-+ * Return : fail (0) or success (1)
-+ * Data Used : olsr_cnf
-+ * Notes : Called by main OLSRD (init_olsr_plugin) to initialize plugin
-+ * ------------------------------------------------------------------------- */
-+int olsrd_plugin_init(void)
-+{
-+ /* Clear the packet history */
-+ //InitPacketHistory();
-+
-+ /* Register ifchange function */
-+ //add_ifchgf(&InterfaceChange);
-+
-+ /* create the cookie */
-+ //prune_packet_history_timer_cookie = olsr_alloc_cookie("BMF: Prune Packet History", OLSR_COOKIE_TYPE_TIMER);
-+
-+ /* Register the duplicate registration pruning process */
-+ //olsr_start_timer(3 * MSEC_PER_SEC, 0, OLSR_TIMER_PERIODIC,
-+ // &PrunePacketHistory, NULL, prune_packet_history_timer_cookie->ci_id);
-+
-+
-+ return InitMDNS(NULL);
-+}
-+
-+/* -------------------------------------------------------------------------
-+ * Function : olsr_plugin_exit
-+ * Description: Plugin cleanup
-+ * Input : none
-+ * Output : none
-+ * Return : none
-+ * Data Used : none
-+ * Notes : Called by my_fini() at unload of shared object
-+ * ------------------------------------------------------------------------- */
-+void olsr_plugin_exit(void)
-+{
-+ CloseMDNS();
-+}
-+
-+static const struct olsrd_plugin_parameters plugin_parameters[] = {
-+ { .name = "NonOlsrIf", .set_plugin_parameter = &AddNonOlsrBmfIf, .data = NULL },
-+ //{ .name = "DoLocalBroadcast", .set_plugin_parameter = &DoLocalBroadcast, .data = NULL },
-+ //{ .name = "BmfInterface", .set_plugin_parameter = &SetBmfInterfaceName, .data = NULL },
-+ //{ .name = "BmfInterfaceIp", .set_plugin_parameter = &SetBmfInterfaceIp, .data = NULL },
-+ //{ .name = "CapturePacketsOnOlsrInterfaces", .set_plugin_parameter = &SetCapturePacketsOnOlsrInterfaces, .data = NULL },
-+ //{ .name = "BmfMechanism", .set_plugin_parameter = &SetBmfMechanism, .data = NULL },
-+ //{ .name = "FanOutLimit", .set_plugin_parameter = &SetFanOutLimit, .data = NULL },
-+ //{ .name = "BroadcastRetransmitCount", .set_plugin_parameter = &set_plugin_int, .data = &BroadcastRetransmitCount},
-+};
-+
-+/* -------------------------------------------------------------------------
-+ * Function : olsrd_get_plugin_parameters
-+ * Description: Return the parameter table and its size
-+ * Input : none
-+ * Output : params - the parameter table
-+ * size - its size in no. of entries
-+ * Return : none
-+ * Data Used : plugin_parameters
-+ * Notes : Called by main OLSR (init_olsr_plugin) for all plugins
-+ * ------------------------------------------------------------------------- */
-+void olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size)
-+{
-+ *params = plugin_parameters;
-+ *size = ARRAYSIZE(plugin_parameters);
-+}
-+
-+/* -------------------------------------------------------------------------
-+ * Function : my_init
-+ * Description: Plugin constructor
-+ * Input : none
-+ * Output : none
-+ * Return : none
-+ * Data Used : none
-+ * Notes : Called at load of shared object
-+ * ------------------------------------------------------------------------- */
-+static void my_init(void)
-+{
-+ /* Print plugin info to stdout */
-+ printf("%s\n", MOD_DESC);
-+
-+ return;
-+}
-+
-+/* -------------------------------------------------------------------------
-+ * Function : my_fini
-+ * Description: Plugin destructor
-+ * Input : none
-+ * Output : none
-+ * Return : none
-+ * Data Used : none
-+ * Notes : Called at unload of shared object
-+ * ------------------------------------------------------------------------- */
-+static void my_fini(void)
-+{
-+ olsr_plugin_exit();
-+}
-+
-+/*
-+ * Local Variables:
-+ * c-basic-offset: 2
-+ * indent-tabs-mode: nil
-+ * End:
-+ */
---- /dev/null
-+++ b/lib/mdns/version-script.txt
-@@ -0,0 +1,10 @@
-+VERS_1.0
-+{
-+ global:
-+ olsrd_plugin_interface_version;
-+ olsrd_plugin_init;
-+ olsrd_get_plugin_parameters;
-+
-+ local:
-+ *;
-+};
diff --git a/contrib/package/olsrd-luci/patches/170-fcntl-fix.patch b/contrib/package/olsrd-luci/patches/170-fcntl-fix.patch
deleted file mode 100644
index ca56767272..0000000000
--- a/contrib/package/olsrd-luci/patches/170-fcntl-fix.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/src/linux/kernel_routes.c
-+++ b/src/linux/kernel_routes.c
-@@ -42,6 +42,7 @@
- #include "kernel_routes.h"
- #include "ipc_frontend.h"
- #include "log.h"
-+#include <fcntl.h>
-
- /* values for control flag to handle recursive route corrections
- * currently only requires in linux specific kernel_routes.c */
diff --git a/contrib/package/olsrd-luci/patches/200-mid_memory_cleanup.patch b/contrib/package/olsrd-luci/patches/200-mid_memory_cleanup.patch
deleted file mode 100644
index 00b2f4c2cf..0000000000
--- a/contrib/package/olsrd-luci/patches/200-mid_memory_cleanup.patch
+++ /dev/null
@@ -1,256 +0,0 @@
---- a/lib/httpinfo/src/olsrd_httpinfo.c
-+++ b/lib/httpinfo/src/olsrd_httpinfo.c
-@@ -687,9 +687,16 @@
- void
- olsr_plugin_exit(void)
- {
-+ struct allowed_net *a, *next;
- if (http_socket >= 0) {
- CLOSE(http_socket);
- }
-+
-+ for (a = allowed_nets; a != NULL; a = next) {
-+ next = a->next;
-+
-+ free(a);
-+ }
- }
-
- static void
---- a/src/interfaces.h
-+++ b/src/interfaces.h
-@@ -187,6 +187,7 @@
- extern struct interface *ifnet;
-
- int ifinit(void);
-+void olsr_delete_interfaces(void);
-
- void run_ifchg_cbs(struct interface *, int);
-
---- a/src/linux/kernel_routes.c
-+++ b/src/linux/kernel_routes.c
-@@ -85,6 +85,8 @@
- OLSR_PRINTF(1,"could not create rtnetlink socket! %d",sock);
- }
- else {
-+ memset(&addr, 0, sizeof(addr));
-+
- addr.nl_family = AF_NETLINK;
- addr.nl_pid = 0; //kernel will assign appropiate number instead of pid (which is already used by primaray rtnetlink socket to add/delete routes)
- addr.nl_groups = rtnl_mgrp;
---- a/src/main.c
-+++ b/src/main.c
-@@ -57,6 +57,7 @@
- #include "net_os.h"
- #include "build_msg.h"
- #include "net_olsr.h"
-+#include "mid_set.h"
-
- #if LINUX_POLICY_ROUTING
- #include <linux/types.h>
-@@ -526,6 +527,7 @@
- #endif
- {
- struct interface *ifn;
-+ int exit_value;
-
- OLSR_PRINTF(1, "Received signal %d - shutting down\n", (int)signo);
-
-@@ -542,6 +544,12 @@
-
- olsr_delete_all_kernel_routes();
-
-+ olsr_delete_all_tc_entries();
-+
-+ olsr_delete_all_mid_entries();
-+
-+ olsr_destroy_parser();
-+
- OLSR_PRINTF(1, "Closing sockets...\n");
-
- /* front-end IPC socket */
-@@ -551,7 +559,6 @@
- }
- #endif /* SVEN_OLA_UNBLOAT */
-
-- /* OLSR sockets */
- for (ifn = ifnet; ifn; ifn = ifn->int_next)
- close(ifn->olsr_socket);
-
-@@ -581,13 +588,17 @@
- #endif
-
- /* Free cookies and memory pools attached. */
-+ OLSR_PRINTF(0, "Free all memory...\n");
- olsr_delete_all_cookies();
-
- olsr_syslog(OLSR_LOG_INFO, "%s stopped", olsrd_version);
-
- OLSR_PRINTF(1, "\n <<<< %s - terminating >>>>\n http://www.olsr.org\n", olsrd_version);
-
-- exit(olsr_cnf->exit_value);
-+ exit_value = olsr_cnf->exit_value;
-+ free (olsr_cnf);
-+
-+ exit(exit_value);
- }
-
- /**
---- a/src/mid_set.c
-+++ b/src/mid_set.c
-@@ -38,6 +38,7 @@
- * the copyright holders.
- *
- */
-+#include <assert.h>
-
- #include "ipcalc.h"
- #include "defs.h"
-@@ -79,6 +80,15 @@
- return 1;
- }
-
-+void olsr_delete_all_mid_entries(void) {
-+ int hash;
-+
-+ for (hash = 0; hash < HASHSIZE; hash++) {
-+ while (mid_set[hash].next != &mid_set[hash]) {
-+ olsr_delete_mid_entry(mid_set[hash].next);
-+ }
-+ }
-+}
- /**
- * Wrapper for the timer callback.
- */
-@@ -124,10 +134,10 @@
- *
- * @param m_addr the main address of the node
- * @param alias the alias address to insert
-- * @return nada
-+ * @return false if mid_address is unnecessary, true otherwise
- */
-
--void
-+static bool
- insert_mid_tuple(union olsr_ip_addr *m_addr, struct mid_address *alias, olsr_reltime vtime)
- {
- struct mid_entry *tmp;
-@@ -147,9 +157,8 @@
- /* Check if alias is already registered with m_addr */
- registered_m_addr = mid_lookup_main_addr(&alias->alias);
- if (registered_m_addr != NULL && ipequal(registered_m_addr, m_addr)) {
--
- /* Alias is already registered with main address. Nothing to do here. */
-- return;
-+ return false;
- }
-
- /*
-@@ -223,6 +232,7 @@
- }
- tmp_adr = tmp_adr->next_alias;
- }
-+ return true;
- }
-
- /**
-@@ -284,7 +294,9 @@
- }
- }
-
-- insert_mid_tuple(main_add, adr, vtime);
-+ if (!insert_mid_tuple(main_add, adr, vtime)) {
-+ free(adr);
-+ }
-
- /*
- *Recalculate topology
---- a/src/mid_set.h
-+++ b/src/mid_set.h
-@@ -75,7 +75,7 @@
- struct mid_alias;
-
- int olsr_init_mid_set(void);
--void insert_mid_tuple(union olsr_ip_addr *, struct mid_address *, olsr_reltime);
-+void olsr_delete_all_mid_entries(void);
- void insert_mid_alias(union olsr_ip_addr *, const union olsr_ip_addr *, olsr_reltime);
- union olsr_ip_addr *mid_lookup_main_addr(const union olsr_ip_addr *);
- struct mid_address *mid_lookup_aliases(const union olsr_ip_addr *);
---- a/src/parser.c
-+++ b/src/parser.c
-@@ -104,6 +104,26 @@
- }
-
- void
-+olsr_destroy_parser(void) {
-+ struct parse_function_entry *pe, *pe_next;
-+ struct preprocessor_function_entry *ppe, *ppe_next;
-+ struct packetparser_function_entry *pae, *pae_next;
-+
-+ for (pe = parse_functions; pe; pe = pe_next) {
-+ pe_next = pe->next;
-+ free (pe);
-+ }
-+ for (ppe = preprocessor_functions; ppe; ppe = ppe_next) {
-+ ppe_next = ppe->next;
-+ free (ppe);
-+ }
-+ for (pae = packetparser_functions; pae; pae = pae_next) {
-+ pae_next = pae->next;
-+ free(pae);
-+ }
-+}
-+
-+void
- olsr_parser_add_function(parse_function * function, uint32_t type)
- {
- struct parse_function_entry *new_entry;
---- a/src/parser.h
-+++ b/src/parser.h
-@@ -74,6 +74,8 @@
-
- void olsr_init_parser(void);
-
-+void olsr_destroy_parser(void);
-+
- void olsr_input(int);
-
- void olsr_input_hostemu(int);
---- a/src/scheduler.c
-+++ b/src/scheduler.c
-@@ -40,6 +40,8 @@
- *
- */
-
-+#include <assert.h>
-+
- #include "defs.h"
- #include "scheduler.h"
- #include "log.h"
---- a/src/tc_set.c
-+++ b/src/tc_set.c
-@@ -205,6 +205,14 @@
- tc_myself = olsr_add_tc_entry(&olsr_cnf->main_addr);
- }
-
-+void olsr_delete_all_tc_entries(void) {
-+ struct tc_entry *tc;
-+
-+ OLSR_FOR_ALL_TC_ENTRIES(tc) {
-+ olsr_delete_tc_entry(tc);
-+ } OLSR_FOR_ALL_TC_ENTRIES_END(tc)
-+}
-+
- /**
- * The main ip address has changed.
- * Do the needful.
---- a/src/tc_set.h
-+++ b/src/tc_set.h
-@@ -142,6 +142,7 @@
- extern struct tc_entry *tc_myself;
-
- void olsr_init_tc(void);
-+void olsr_delete_all_tc_entries(void);
- void olsr_change_myself_tc(void);
- void olsr_print_tc_table(void);
- void olsr_time_out_tc_set(void);