diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/CHANGELOG olsrd-current/CHANGELOG
--- olsrd-0.5.0/CHANGELOG	2007-04-01 23:44:14.000000000 +0200
+++ olsrd-current/CHANGELOG	2007-04-03 10:25:19.000000000 +0200
@@ -1,5 +1,5 @@
 This file states changes as of version 0.2.4:
-$Id: CHANGELOG,v 1.58 2007/04/01 21:44:14 bernd67 Exp $
+$Id: CHANGELOG,v 1.59 2007/04/03 08:25:19 bernd67 Exp $
 
 0.5.0 ---------------------------------------------------------------------
 
@@ -11,14 +11,9 @@
 removed hardcoded limit on the number of interfaces (at least in the Unix part)
 made Makefile targets much more consistent
 
-BUGFIXES
-all over the place
-
 MISC
 put Bmf-1.3 plugin into it
 
-0.4.11 --------------------------------------------------------------------
-
 FreeBSD IPv6 SUPPORT
 
 Patch from John Hay applied.
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/files/olsrd.conf.default.lq-fisheye olsrd-current/files/olsrd.conf.default.lq-fisheye
--- olsrd-0.5.0/files/olsrd.conf.default.lq-fisheye	2007-02-10 20:27:32.000000000 +0100
+++ olsrd-current/files/olsrd.conf.default.lq-fisheye	2007-04-20 00:28:09.000000000 +0200
@@ -3,7 +3,7 @@
 #
 # Lines starting with a # are discarded
 #
-# This file was shipped with olsrd 0.X.X
+# This file was shipped with olsrd 0.5.0-unoffical
 #
 
 # This file is an example of a typical
@@ -14,7 +14,7 @@
 # Debug level(0-9)
 # If set to 0 the daemon runs in the background
 
-DebugLevel	2
+DebugLevel	0
 
 
 # Fisheye mechanism for TC messages 0=off, 1=on
@@ -22,6 +22,19 @@
 LinkQualityFishEye 1
 
 
+# Don't recalculate the Dijkstra-table for every incoming topology 
+# control packet. There is no need to recalculate the whole table 
+# if a minor change occured several hops away. Small CPUs will start
+# to glow if you do this in a mesh of considerable size. Rather the table 
+# should be recalculated if a change occured in the neighborhood 
+# of this node. The first number is the number of hops. Nodes within 
+# this number of hops trigger a recalculation of the table. If the 
+# number is 0 no incoming topology control packet will trigger 
+# a recalculation of the table. The second number (floating point!) 
+# is the length ot the interval until the table is recalculated anyway.    
+
+LinkQualityDijkstraLimit 1 6.0
+
 
 # IP version to use (4 or 6)
 
@@ -141,10 +154,6 @@
 
 Pollrate	0.05
 
-# Interval to poll network interfaces for configuration 
-# changes. Defaults to 2.5 seconds
-
-NicChgsPollInt  3.0
 
 # TC redundancy
 # Specifies how much neighbor info should
@@ -204,6 +213,14 @@
 #   PlParam     "Ping"       "194.25.2.129"
 #}
 
+LoadPlugin "olsrd_httpinfo.so.0.1"
+{
+    PlParam     "port"   "8080"
+    PlParam     "Host"   "127.0.0.1"
+#    PlParam     "Host"   "80.23.53.22"
+#    PlParam     "Net"    "10.0.0.0 255.0.0.0"
+#    PlParam     "Net"    "192.168.0.0 255.255.0.0"
+}
 
 
 # Interfaces and their rules
@@ -215,18 +232,10 @@
 # !!CHANGE THE INTERFACE LABEL(s) TO MATCH YOUR INTERFACE(s)!!
 # (eg. wlan0 or eth1):
 
-Interface "XXX" "YYY"
-{
+#Interface "eth0" "eth1" "eth2" "wlan0" "ath0" "rausb0"
 
-    # Olsrd can autodetect changes in NIC
-    # configurations(IP address changes etc.). 
-    # This is Enabled by default and the interval
-    # to poll for changes on is defined by 
-    # NicChgsPollInt.
-    # This polling can be disabled pr. NIC by setting
-    # AutoDetectChanges to no.
-
-    # AutoDetectChanges            yes
+Interface "rausb0"
+{
 
     # IPv4 broadcast address to use. The
     # one usefull example would be 255.255.255.255
@@ -263,8 +272,12 @@
     # HELLO validity time
     HelloValidityTime	200.0
 
-    # TC interval in seconds(float)
-    TcInterval        0.5
+
+    # TC interval in seconds(float) 0.5 is only viable when
+    # LinkQualityFishEye is enabled. Otherwise larger networks would
+    # suffocate from a massive protocol overhead of TC-messages
+
+    TcInterval        2.5
 
     # TC validity time
     TcValidityTime	250.0
@@ -273,7 +286,7 @@
     MidInterval	5.0
 
     # MID validity time
-    MidValidityTime	100.0
+    MidValidityTime	300.0
 
     # HNA interval in seconds(float)
     HnaInterval	5.0
@@ -282,31 +295,13 @@
     HnaValidityTime 	100.0
 
 
-    # When multiple links exist between hosts
-    # the weight of interface is used to determine
-    # the link to use. Normally the weight is
-    # automatically calculated by olsrd based
-    # on the characteristics of the interface,
-    # but here you can specify a fixed value.
-    # Olsrd will choose links with the lowest value.
-    # Note:
-    # Interface weight is used only when LinkQualityLevel is set to 0.
-    # For any other value of LinkQualityLevel, the interface ETX
-    # value is used instead.
-    # Weight 0
-
-
-    # If a certain route should be preferred 
-    # or ignored by the mesh, the Link Quality 
-    # value of a node can be multiplied with a factor 
-    # entered here. In the example the route 
-    # using 192.168.0.1 would rather be ignored.
-    # A multiplier of 0.5 will result in a small
-    # (bad) LinkQuality value and a high (bad)
-    # ETX value.
-    # Note:
-    # Link quality multiplier is used only when
-    # LinkQualityLevel is > 0.
+
+    # If a certain route should be preferred or ignored by the mesh, the
+    # Link Quality value of a node can be multiplied with a factor entered
+    # here. In the example the route using 192.168.0.1 would rather be
+    # ignored.  A multiplier of 0.5 will result in a small (bad) LinkQuality
+    # value and a high (bad) ETX value.  Note: Link quality multiplier is
+    # used only when LinkQualityLevel is > 0.
 
     # LinkQualityMult 192.168.0.1 0.5
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/gcc-warnings olsrd-current/gcc-warnings
--- olsrd-0.5.0/gcc-warnings	1970-01-01 01:00:00.000000000 +0100
+++ olsrd-current/gcc-warnings	2007-05-01 23:36:50.000000000 +0200
@@ -0,0 +1,32 @@
+#!/bin/bash --norc
+#
+# We expect warning options for gcc as argumenst and return the ones which are accepted
+# by the given gcc.
+#
+# $Id: gcc-warnings,v 1.1 2007/05/01 21:36:50 bernd67 Exp $
+
+set -ue
+#set -vx
+
+OPTS=""
+for param; do
+    case "$param" in
+    -W?*) OPTS="$OPTS $param";;
+    *)    echo "Ignoring $param" >&2
+    esac
+done
+
+while read error; do 
+    case "$error" in
+    *error:\ unrecognized\ option*) opt="${error#*\`}"
+                                    opt="${opt%\'*}"
+                                    OPTS="${OPTS//$opt/}"
+                                    ;;
+    esac
+done < <(cat <<EOF | $CC $OPTS -E - 2>&1 >/dev/null
+    int main(void) {
+        return 0;
+    }
+    EOF)
+echo $OPTS
+exit 0
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/gui/linux-gtk/src/olsr_protocol.h olsrd-current/gui/linux-gtk/src/olsr_protocol.h
--- olsrd-0.5.0/gui/linux-gtk/src/olsr_protocol.h	2004-09-14 18:45:41.000000000 +0200
+++ olsrd-current/gui/linux-gtk/src/olsr_protocol.h	2007-04-22 22:25:48.000000000 +0200
@@ -247,7 +247,7 @@
 };
 
 
-struct tcmsg 
+struct olsr_tcmsg 
 {
   olsr_u16_t        ansn;
   olsr_u16_t        reserved;
@@ -265,7 +265,7 @@
 };
 
 
-struct tcmsg6
+struct olsr_tcmsg6
 {
   olsr_u16_t           ansn;
   olsr_u16_t           reserved;
@@ -366,7 +366,7 @@
   union 
   {
     struct hellomsg hello;
-    struct tcmsg    tc;
+    struct olsr_tcmsg    tc;
     struct hnamsg   hna;
     struct midmsg   mid;
   } message;
@@ -390,7 +390,7 @@
   union 
   {
     struct hellomsg6 hello;
-    struct tcmsg6    tc;
+    struct olsr_tcmsg6    tc;
     struct hnamsg6   hna;
     struct midmsg6   mid;
   } message;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/gui/linux-gtk/src/packet.h olsrd-current/gui/linux-gtk/src/packet.h
--- olsrd-0.5.0/gui/linux-gtk/src/packet.h	2004-09-19 13:48:20.000000000 +0200
+++ olsrd-current/gui/linux-gtk/src/packet.h	2007-04-22 22:25:48.000000000 +0200
@@ -51,8 +51,8 @@
 
 union tc_message
 {
-  struct tcmsg v4;
-  struct tcmsg6 v6;
+  struct olsr_tcmsg v4;
+  struct olsr_tcmsg6 v6;
 };
 
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/bmf/Makefile olsrd-current/lib/bmf/Makefile
--- olsrd-0.5.0/lib/bmf/Makefile	2007-02-10 18:05:55.000000000 +0100
+++ olsrd-current/lib/bmf/Makefile	2007-04-22 19:40:38.000000000 +0200
@@ -31,11 +31,10 @@
 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 # POSSIBILITY OF SUCH DAMAGE.
 #
-# $Id: Makefile,v 1.2 2007/02/10 17:05:55 bernd67 Exp $
 
 OLSRD_PLUGIN =	true
 PLUGIN_NAME =	olsrd_bmf
-PLUGIN_VER =	1.3
+PLUGIN_VER =	1.4
 
 TOPDIR = ../..
 include $(TOPDIR)/Makefile.inc
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/bmf/README_BMF.txt olsrd-current/lib/bmf/README_BMF.txt
--- olsrd-0.5.0/lib/bmf/README_BMF.txt	2007-02-10 18:05:55.000000000 +0100
+++ olsrd-current/lib/bmf/README_BMF.txt	2007-04-22 19:40:38.000000000 +0200
@@ -1,6 +1,6 @@
 BASIC MULTICAST FORWARDING PLUGIN FOR OLSRD
 by Erik Tromp (erik.tromp@nl.thalesgroup.com, erik_tromp@hotmail.com)
-Version 1.3
+Version 1.4
 
 1. Introduction
 ---------------
@@ -17,14 +17,14 @@
 2. How to build and install
 ---------------------------
 
-Download the olsr-bmf-v1.3.tar.gz file and save it into your OLSRD
+Download the olsr-bmf-v1.4.tar.gz file and save it into your OLSRD
 base install directory.
 
 Change directory (cd) to your OLSRD base install directory.
 
 At the command prompt, type:
 
-  tar -zxvf ./olsr-bmf-v1.3.tar.gz
+  tar -zxvf ./olsr-bmf-v1.4.tar.gz
 
 then type:
 
@@ -47,7 +47,7 @@
 To configure BMF in OLSR, you must edit the file /etc/olsrd.conf
 to load the BMF plugin. For example, add the following lines:
 
-  LoadPlugin "olsrd_bmf.so.1.3"
+  LoadPlugin "olsrd_bmf.so.1.4"
   {
     # No PlParam entries required for basic operation
   }
@@ -64,8 +64,8 @@
 Look at the output; it should list the BMF plugin, e.g.:
 
   ---------- Plugin loader ----------
-  Library: olsrd_bmf.so.1.3
-  OLSRD Basic Multicast Forwarding plugin 1.3 (Dec 18 2006 11:23:51)
+  Library: olsrd_bmf.so.1.4
+  OLSRD Basic Multicast Forwarding plugin 1.4 (Mar 30 2007 14:30:57)
     (C) Thales Communications Huizen, Netherlands
     Erik Tromp (erik.tromp@nl.thalesgroup.com)
   Checking plugin interface version...  4 - OK
@@ -84,14 +84,14 @@
 Enter the following command on the command prompt:
   
   ping 224.0.0.1
-    
+
 All OLSR-BMF hosts in the OLSR network should respond. For example,
 assume we have three hosts, with IP addresses 192.168.151.50,
 192.168.151.53 and 192.168.151.55. On host 192.168.151.50 we enter
 the following ping command:
 
 root@IsdbServer:~# ping 224.0.0.1
-PING 224.0.0.1 (224.0.0.1) from 192.168.151.50 eth1: 56(84) bytes of data.
+PING 224.0.0.1 (224.0.0.1) 56(84) bytes of data.
 64 bytes from 192.168.151.50: icmp_seq=1 ttl=64 time=0.511 ms
 64 bytes from 192.168.151.53: icmp_seq=1 ttl=64 time=4.67 ms (DUP!)
 64 bytes from 192.168.151.55: icmp_seq=1 ttl=63 time=10.7 ms (DUP!)
@@ -110,6 +110,22 @@
 receive their own packets). We can also see the responses by the
 other hosts (correctly seen as DUPlicates by ping).
 
+Note: when using an older version of ping than the standard from
+iputils-20020927, as found in most current Linux distributions, you may want
+to test BMF by specifying the output interface to the ping command:
+
+  ping -I bmf0 224.0.0.1
+
+Older versions of 'ping' (e.g. as found in iputils-20020124) may bind to the
+autoselected source address, which may be incorrect. Since BMF re-uses
+one of the existing IP addresses for the "bmf0" network interface, the
+older-version ping command may 'autobind' to the wrong interface.
+
+See also the note in the iputils-20020927/RELNOTES file:
+"* Mads Martin Jørgensen <mmj@suse.de>: ping should not bind to autoselected
+  source address, it used to work when routing changes. Return classic
+  behaviour, option -B is added to enforce binding."
+
 
 5. How does it work
 -------------------
@@ -173,7 +189,7 @@
 The following gives an overview of all plugin parameters that can be
 configured:
 
-  LoadPlugin "olsrd_bmf.so.1.3"
+  LoadPlugin "olsrd_bmf.so.1.4"
   {
     # Specify the name of the BMF network interface.
     # Defaults to "bmf0".
@@ -205,6 +221,15 @@
     # the network. If not, hosts may receive multicast packets in duplicate.
     PlParam "CapturePacketsOnOlsrInterfaces" "yes"
 
+    # The forwarding mechanism to use. Either "Broadcast" or
+    # "UnicastPromiscuous". Defaults to "Broadcast".
+    # In the "UnicastPromiscuous" mode, packets are forwarded (unicast) to the
+    # best candidate neighbor; other neighbors listen promiscuously. IP-local
+    # broadcast is not used. This saves air time on 802.11 WLAN networks,
+    # on which unicast packets are usually sent at a much higher bit rate
+    # than broadcast packets (which are sent at a basic bit rate).
+    PlParam "BmfMechanism" "UnicastPromiscuous"
+
     # List of non-OLSR interfaces to include
     PlParam     "NonOlsrIf"  "eth2"
     PlParam     "NonOlsrIf"  "eth3"
@@ -309,7 +334,7 @@
 interfaces one by one as "NonOlsrIf" parameters in the BMF plugin section
 of /etc/olsrd.conf. For example:
 
-  LoadPlugin "olsrd_bmf.so.1.3"
+  LoadPlugin "olsrd_bmf.so.1.4"
   {
     # Non-OLSR interfaces to participate in the multicast flooding
     PlParam     "NonOlsrIf"  "eth2"
@@ -367,7 +392,7 @@
 the BMF network interface, by editing the /etc/olsrd.conf file.
 For example:
 
-  LoadPlugin "olsrd_bmf.so.1.3"
+  LoadPlugin "olsrd_bmf.so.1.4"
   {
       PlParam "BmfInterfaceIp" "10.10.10.4/24"
   }
@@ -436,8 +461,8 @@
 other. In an OLSR lab environment, we sometimes want to simulate the
 situation that some hosts in the network cannot directly see other hosts
 (as 1-hop neighbors) but only indirectly (as 2- or more-hop neighbors).
-To simulate that situation, the iptables tool is often used. For BMF,
-however, that is nog enough.
+To simulate that situation, the iptables tool is often used (see
+www.netfilter.org). For BMF, however, that is nog enough.
 
 For OLSR testing, setup iptables on each host to drop packets from
 all other hosts which are not direct (1-hop) neigbors. For example, to
@@ -453,7 +478,7 @@
 these hosts are dropped by iptables, they are still received on network
 interfaces if they are in promiscuous mode.) For example:
 
-  LoadPlugin "olsrd_bmf.so.1.3"
+  LoadPlugin "olsrd_bmf.so.1.4"
   {
     # Drop all packets received from the following MAC sources
     PlParam     "DropMac"    "00:0C:29:51:32:88" # RemoteClient1
@@ -461,6 +486,8 @@
     PlParam     "DropMac"    "00:0C:29:28:0E:CC" # SimpleClient2
   }
 
+See also the notes in the 'packet' manpage ("Packet sockets are not
+subject to the input or output firewall chains").
 
 
 10. Common problems, FAQ
@@ -488,6 +515,7 @@
 Turn on the possibility to create a tuntap interface; see section 2 of this
 file.
 
+
 ---------
 Question:
 When starting OLSRD with the BMF plugin, I can see the following
@@ -509,9 +537,17 @@
 
   modprobe tun
 
-If "modprobe tun" says something like "module tun not found", then either
+If "modprobe tun" says something like "modprobe: Can't locate module tun", then either
 it is not compiled at all or it is not compiled into the kernel. 
 
+Note: if you do not want to receive multicast packets, only forward the packets
+that other hosts send, then you do not need the tuntap interface. This could be the
+case if your host is purely an OLSR router; normally no traffic will be directed
+to the router itself. In that case you can ignore this error message. Beware, though,
+that you will then not be able to do the simple 'ping 224.0.0.1' test (as described in
+section 4. How to check if it works) to check for the presence of all OLSR-BMF routers
+in the network. 
+
 
 ---------
 Question:
@@ -528,6 +564,28 @@
 11. Version history
 -------------------
 
+31 Mar 2007: Version 1.4
+* Optimized the standard forwarding mechanism in such a way that
+  retransmissions of packets are only done on those network interfaces
+  that make a host a multi-point relay (MPR) for the sender. I.e.:
+  retransmitting a packet on a network interface is not done if that
+  does not lead to any new hosts being reached.
+* Optimized the standard forwarding mechanism such that, if the network
+  topology indicates there is only one neighbor on an interface, packets are
+  sent to the specific IP address (unicast) of that neighbor. If the network
+  topology indicates there are multiple neighbors, then BMF will still send
+  packets to the IP local-broadcast address.
+* Introduced a new forwarding mechanism, using only IP-unicast to
+  forward packets. Packets are forwarded to the best candidate neighbor;
+  other neighbors listen promiscuously. IP-local broadcast is not used.
+  This saves air time on 802.11 WLAN networks, on which unicast packets are
+  usually sent at a much higher bit rate than broadcast packets (which are
+  sent at a basic bit rate).
+  This mechanism can be activated by specifying the following plugin
+  parameter:
+    PlParam "BmfMechanism" "UnicastPromiscuous"
+  See also section 6 - Advanced configuration.
+
 18 Dec 2006: Version 1.3
 * Added the possibility to configure the BMF network interface:
   name (e.g. "bmf0"), type (tun or tap), IP address and subnet
@@ -572,7 +630,8 @@
   network interfaces.
 * Debug level 9 gives a better indication of what happens to each
   handled multicast/broadcast packet. To run the olsr daemon with
-  debug level 9, run "olsrd -d 9".
+  debug level 9, run "olsrd -d 9"; if you're only interested in
+  BMF debug messages, run "olsrd -d 9 | grep -i bmf".
 * Can now deal with network interface removal ("ifdown eth1") and
   addition ("ifup eth1").
 * CRC-calculation for duplicate detection is done over first 256
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/bmf/src/Address.c olsrd-current/lib/bmf/src/Address.c
--- olsrd-0.5.0/lib/bmf/src/Address.c	2007-02-10 18:05:55.000000000 +0100
+++ olsrd-current/lib/bmf/src/Address.c	2007-04-22 19:40:38.000000000 +0200
@@ -35,12 +35,12 @@
  * Description: IP packet characterization functions
  * Created    : 29 Jun 2006
  *
- * $Id: Address.c,v 1.2 2007/02/10 17:05:55 bernd67 Exp $ 
  * ------------------------------------------------------------------------- */
  
 #include "Address.h"
 
 /* System includes */
+#include <stddef.h> /* NULL */
 #include <assert.h> /* assert() */
 #include <netinet/ip.h> /* struct ip */
 #include <netinet/udp.h> /* struct udphdr */
@@ -99,130 +99,49 @@
 }
 
 /* -------------------------------------------------------------------------
- * Function   : IsLocalBroadcast
- * Description: Check if an IP address is a local broadcast address for a
- *              given network interface
- * Input      : destIp, broadAddr
- * Output     : none
- * Return     : true (1) or false (0)
- * Data Used  : none
- * ------------------------------------------------------------------------- */
-int IsLocalBroadcast(union olsr_ip_addr* destIp, struct sockaddr* broadAddr)
-{
-  struct sockaddr_in* sin;
-  
-  assert(destIp != NULL && broadAddr != NULL);
-
-  /* Cast down to correct sockaddr subtype */
-  sin = (struct sockaddr_in*)broadAddr;
-
-  return COMP_IP(&(sin->sin_addr.s_addr), destIp);
-}
-
-/* -------------------------------------------------------------------------
  * Function   : IsOlsrOrBmfPacket
- * Description: Check if an ethernet packet is an OLSR packet or a BMF packet
- * Input      : intf, ethPkt, len
+ * 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
- * Assumption : len >= IP_HDR_OFFSET + GetIpHeaderLength(ethPkt)
  * ------------------------------------------------------------------------- */
-int IsOlsrOrBmfPacket(struct TBmfInterface* intf, unsigned char* ethPkt, size_t len)
+int IsOlsrOrBmfPacket(unsigned char* ipPacket)
 {
-  struct ip* ipData;
+  struct ip* ipHeader;
   unsigned int ipHeaderLen;
-  struct udphdr* udpData;
+  struct udphdr* udpHeader;
   u_int16_t destPort;
 
-  assert(ethPkt != NULL);
+  assert(ipPacket != NULL);
 
-  /* Consider OLSR and BMF packets not to be local broadcast
-   * OLSR packets are UDP - port 698
+  /* OLSR packets are UDP - port 698
    * OLSR-BMF packets are UDP - port 50698
-   * OLSR-Autodetect probe packets are UDP - port 51698
-   * Fragments of the above packets are also not local broadcast */
+   * OLSR-Autodetect probe packets are UDP - port 51698 */
 
-  ipData = (struct ip*) (ethPkt + IP_HDR_OFFSET);
-  if (ipData->ip_p != SOL_UDP)
+  /* Check if UDP */
+  ipHeader = (struct ip*) ipPacket;
+  if (ipHeader->ip_p != SOL_UDP)
   {
+    /* Not UDP */
     return 0;
   }
 
-  /* Check if the packet is an IP-fragment */
-  if ((ntohs(ipData->ip_off) & IP_OFFMASK) != 0)
-  {
-#if 0
-    int i;
-    for (i = 0; i < FRAGMENT_HISTORY_SIZE; i++)
-    {
-      /* Quick-access pointer */
-      struct TFragmentHistory* entry = &intf->fragmentHistory[i];
-
-      /* Match */
-      if (entry->ipId == ntohs(ipData->ip_id) &&
-          entry->ipProto == ipData->ip_p &&
-          entry->ipSrc.s_addr == ntohl(ipData->ip_src.s_addr) &&
-          entry->ipDst.s_addr == ntohl(ipData->ip_dst.s_addr))
-      {
-        /* Found matching history entry, so packet is assumed to be a fragment
-         * of an earlier OLSR/OLSR-BMF/OLSR-Autodetect packet */
-
-        /* More fragments? If not, invalidate entry */
-        if (((ntohs(ipData->ip_off) & IP_MF) == 0))
-        {
-          memset(entry, 0, sizeof(struct TFragmentHistory));
-        }
-
-        return 1;
-      }
-    }
-
-    /* Matching history entry not found, so packet is not assumed to be a fragment
-     * of an earlier OLSR/OLSR-BMF/OLSR-Autodetect packet */
-#endif
-    /* OOPS! IP-fragments may come in earlier than their main packet. In that case,
-     * their relation with the main packet is not detected by the above code, resulting
-     * in stray fragments being forwarded all ove the network. Solution for now is to
-     * not forward any IP-fragments at all. */
-    /*return 0;*/
-    return 1;
-  }
-
-  /* The packet is the first (or only) IP-fragment */
-
-  /* Check length first */
-  ipHeaderLen = ipData->ip_hl << 2;
-  if (len < IP_HDR_OFFSET + ipHeaderLen + sizeof(struct udphdr))
+  /* The total length must be at least large enough to store the UDP header */
+  ipHeaderLen = GetHeaderLength(ipPacket);
+  if (GetTotalLength(ipPacket) < ipHeaderLen + sizeof(struct udphdr))
   {
+    /* Not long enough */
     return 0;
   }
 
   /* Go into the UDP header and check port number */
-  udpData = (struct udphdr*) (ethPkt + IP_HDR_OFFSET + ipHeaderLen);
-  destPort = ntohs(udpData->dest);
+  udpHeader = (struct udphdr*) (ipPacket + ipHeaderLen);
+  destPort = ntohs(udpHeader->dest);
 
   if (destPort == OLSRPORT || destPort == BMF_ENCAP_PORT || destPort == 51698)
       /* TODO: #define for 51698 */
   {
-#if 0
-    /* If more fragments are expected, keep a record in the fragment history */
-    if ((ntohs(ipData->ip_off) & IP_MF) != 0)
-    {
-      /* Quick-access pointer */
-      struct TFragmentHistory* entry = &intf->fragmentHistory[intf->nextFragmentHistoryEntry];
-
-      /* Store in fragment history */
-      entry->ipId = ntohs(ipData->ip_id);
-      entry->ipProto = ipData->ip_p;
-      entry->ipSrc.s_addr = ntohl(ipData->ip_src.s_addr);
-      entry->ipDst.s_addr = ntohl(ipData->ip_dst.s_addr);
-
-      /* Advance to next entry */
-      intf->nextFragmentHistoryEntry++;
-      intf->nextFragmentHistoryEntry %= FRAGMENT_HISTORY_SIZE;
-    }
-#endif
     return 1;
   }
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/bmf/src/Address.h olsrd-current/lib/bmf/src/Address.h
--- olsrd-0.5.0/lib/bmf/src/Address.h	2007-02-10 18:05:55.000000000 +0100
+++ olsrd-current/lib/bmf/src/Address.h	2007-04-22 19:40:38.000000000 +0200
@@ -38,7 +38,6 @@
  * Description: IP packet characterization functions
  * Created    : 29 Jun 2006
  *
- * $Id: Address.h,v 1.2 2007/02/10 17:05:55 bernd67 Exp $ 
  * ------------------------------------------------------------------------- */
 
 #include "olsr_types.h" /* olsr_ip_addr */
@@ -50,7 +49,6 @@
 
 int DoLocalBroadcast(const char* enable);
 int IsMulticast(union olsr_ip_addr* ipAddress);
-int IsLocalBroadcast(union olsr_ip_addr* destIp, struct sockaddr* broadAddr);
-int IsOlsrOrBmfPacket(struct TBmfInterface* intf, unsigned char* ethPkt, size_t len);
+int IsOlsrOrBmfPacket(unsigned char* ipPacket);
 
 #endif /* _BMF_ADDRESS_H */
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/bmf/src/Bmf.c olsrd-current/lib/bmf/src/Bmf.c
--- olsrd-0.5.0/lib/bmf/src/Bmf.c	2007-02-10 18:05:55.000000000 +0100
+++ olsrd-current/lib/bmf/src/Bmf.c	2007-04-22 19:40:38.000000000 +0200
@@ -35,7 +35,6 @@
  * Description: Multicast forwarding functions
  * Created    : 29 Jun 2006
  *
- * $Id: Bmf.c,v 1.2 2007/02/10 17:05:55 bernd67 Exp $ 
  * ------------------------------------------------------------------------- */
 
 #define _MULTI_THREADED
@@ -43,15 +42,17 @@
 #include "Bmf.h"
 
 /* System includes */
-#include <stdio.h> /* NULL */
+#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_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 */
 
 /* OLSRD includes */
 #include "defs.h" /* olsr_cnf, OLSR_PRINTF */
@@ -63,7 +64,7 @@
 
 /* Plugin includes */
 #include "NetworkInterfaces.h" /* TBmfInterface, CreateBmfNetworkInterfaces(), CloseBmfNetworkInterfaces() */
-#include "Address.h" /* IsMulticast(), IsLocalBroadcast() */
+#include "Address.h" /* IsMulticast() */
 #include "Packet.h" /* ETH_TYPE_OFFSET, IFHWADDRLEN etc. */
 #include "PacketHistory.h" /* InitPacketHistory() */
 #include "DropList.h" /* DropMac() */
@@ -72,109 +73,226 @@
 static int BmfThreadRunning = 0;
 
 /* -------------------------------------------------------------------------
+ * 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(char* format, ...)
+{
+#define MAX_STR_DESC 255
+  char* strErr = strerror(errno);
+  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);
+  }
+}
+
+/* -------------------------------------------------------------------------
+ * 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;
+}
+
+/* -------------------------------------------------------------------------
+ * Function   : ComposeEnapsulationDestination
+ * Description: Compose a next destination for an encapsulated packet
+ * Input      : intf - the network interface on which to forward the
+ *                encapsulation packet
+ *              src - the IP source of the encapsulated packet. Pass NULL if
+ *                not applicable.
+ *              forwardedBy - the IP address of the last host that forwarded
+ *                the packet. Pass NULL if not applicable.
+ *              forwardedTo - the IP address to which the last host has
+ *                forwarded the packet. Pass NULL if not applicable.
+ * Output     : nextDest - the composed next destination
+ * Return     : 1 if a valid next destination could be composed, or 0 if not
+ * Data Used  : BmfMechanism
+ * ------------------------------------------------------------------------- */
+static int ComposeEnapsulationDestination(
+  struct TBmfInterface* intf,
+  union olsr_ip_addr* src,
+  union olsr_ip_addr* forwardedBy,
+  union olsr_ip_addr* forwardedTo,
+  struct sockaddr_in* nextDest)
+{
+  struct link_entry* bestNeighborLink;
+  int nPossibleNeighbors;
+
+  memset(nextDest, 0, sizeof(nextDest));
+  nextDest->sin_family = AF_INET;
+  nextDest->sin_port = htons(BMF_ENCAP_PORT);
+
+  bestNeighborLink = GetBestNeighbor(intf, src, forwardedBy, forwardedTo, &nPossibleNeighbors);
+
+  if (bestNeighborLink != NULL)
+  {
+    /* Depending on the how many neighbors there are, and on the BMF mechanism... */
+    if (nPossibleNeighbors == 1 || BmfMechanism == BM_UNICAST_PROMISCUOUS)
+    {
+      /* ...destination IP address is address of best neighbor... */
+      COPY_IP(&nextDest->sin_addr.s_addr, &bestNeighborLink->neighbor_iface_addr);
+    }
+    else
+    {
+      /* ...or destination IP address is local broadcast. */
+      COPY_IP(&nextDest->sin_addr.s_addr, &intf->broadAddr);
+    }
+  }
+  else
+  {
+    /* No (good enough) neighbor on the specified interface: don't forward
+     * the packet */
+    return 0;
+  }
+
+  return 1;
+}
+
+/* -------------------------------------------------------------------------
  * Function   : EncapsulateAndForwardPacket
  * Description: Encapsulate a captured raw IP packet and forward it
  * Input      : intf - the network interface on which to forward the packet
- *              buffer - space for the encapsulation header, followed by
- *                the captured packet
- *              len - the number of octets in the encapsulation header plus
- *                captured packet
+ *              encapsulationUdpData - The encapsulation header, followed by
+ *                the encapsulated Ethernet frame
  * Output     : none
  * Return     : none
  * Data Used  : none
  * ------------------------------------------------------------------------- */
-static void EncapsulateAndForwardPacket(struct TBmfInterface* intf, unsigned char* buffer, ssize_t len)
+static void EncapsulateAndForwardPacket(
+  struct TBmfInterface* intf,
+  unsigned char* encapsulationUdpData)
 {
-  unsigned char* ethPkt = buffer + ENCAP_HDR_LEN;
+  unsigned char* ethernetFrame = GetEthernetFrame(encapsulationUdpData);
   int nBytesWritten;
-  struct sockaddr_in encapDest;
+  struct sockaddr_in forwardTo; /* Next destination of encapsulation packet */
+  u_int16_t udpDataLen = GetEncapsulationUdpDataLength(encapsulationUdpData);
 
   /* Change encapsulated source MAC address to that of sending interface */
-  memcpy(ethPkt + IFHWADDRLEN, intf->macAddr, IFHWADDRLEN);
+  SetFrameSourceMac(ethernetFrame, intf->macAddr);
 
-  /* Destination address is local broadcast */
-  memset(&encapDest, 0, sizeof(encapDest));
-  encapDest.sin_family = AF_INET;
-  encapDest.sin_port = htons(BMF_ENCAP_PORT);
-  encapDest.sin_addr.s_addr = ((struct sockaddr_in*)&intf->olsrIntf->int_broadaddr)->sin_addr.s_addr;
+  /* Compose destination of encapsulation packet */
+  if (ComposeEnapsulationDestination(intf, NULL, NULL, NULL, &forwardTo) == 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;
+  }
 
   nBytesWritten = sendto(
     intf->encapsulatingSkfd,
-    buffer,
-    len,
+    encapsulationUdpData,
+    udpDataLen,
     MSG_DONTROUTE,
-    (struct sockaddr*) &encapDest,
-    sizeof(encapDest));                   
-  if (nBytesWritten != len)
+    (struct sockaddr*) &forwardTo,
+    sizeof(forwardTo));                   
+  if (nBytesWritten != udpDataLen)
   {
-    olsr_printf(
-      1,
-      "%s: sendto() error forwarding pkt to \"%s\": %s\n",
-      PLUGIN_NAME,
-      intf->ifName,
-      strerror(errno));
+    BmfPError("sendto() error forwarding pkt on \"%s\"", intf->ifName);
   }
   else
   {
+    /* Increase counter */
+    intf->nBmfPacketsTx++;
+
     OLSR_PRINTF(
-      9,
-      "%s: --> encapsulated and forwarded to \"%s\"\n",
+      8,
+      "%s: --> encapsulated and forwarded on \"%s\" to %s\n",
       PLUGIN_NAME_SHORT,
-      intf->ifName);
-  } /* if (nBytesWritten != len) */
+      intf->ifName,
+      inet_ntoa(forwardTo.sin_addr));
+  } /* if (nBytesWritten != udpDataLen) */
 }
 
 /* -------------------------------------------------------------------------
  * Function   : BmfPacketCaptured
- * Description: Handle a captured raw IP packet
+ * Description: Handle a captured raw Ethernet frame
  * Input      : intf - the network interface on which the packet was captured
  *              sllPkttype - the type of packet. Either PACKET_OUTGOING,
  *                PACKET_BROADCAST or PACKET_MULTICAST.
- *              buffer - space for the encapsulation header, followed by
- *                the captured packet
- *              len - the number of octets in the encapsulation header plus
- *                captured packet
+ *              encapsulationUdpData - space for the encapsulation header, followed by
+ *                the captured Ethernet frame
  * Output     : none
  * Return     : none
  * Data Used  : BmfInterfaces
- * Notes      : The packet is assumed to be captured on a socket of family
+ * Notes      : The Ethernet frame is assumed to be captured on a socket of family
  *              PF_PACKET and type SOCK_RAW.
  * ------------------------------------------------------------------------- */
 static void BmfPacketCaptured(
   struct TBmfInterface* intf,
   unsigned char sllPkttype,
-  unsigned char* buffer,
-  ssize_t len)
+  unsigned char* encapsulationUdpData)
 {
   unsigned char* srcMac;
-  union olsr_ip_addr srcIp;
-  union olsr_ip_addr destIp;
-  union olsr_ip_addr* origIp;
-  struct TBmfInterface* nextFwIntf;
+  union olsr_ip_addr src; /* Source IP address in captured frame */
+  union olsr_ip_addr dst; /* Destination IP address in captured frame */
+  union olsr_ip_addr* origIp; /* Main OLSR address of source of captured frame */
+  struct TBmfInterface* walker;
   int isFromOlsrIntf;
   int isFromOlsrNeighbor;
   int iAmMpr;
-  unsigned char* ethPkt = buffer + ENCAP_HDR_LEN;
-  ssize_t ethPktLen = len - ENCAP_HDR_LEN;
-  struct ip* ipData;
+  unsigned char* ethernetFrame; /* The captured Ethernet frame... */
+  u_int16_t ethernetFrameLen; /* ...and its length */
+  struct ip* ipHeader; /* The IP header inside the captured Ethernet frame */
+  unsigned char* ipPacket; /* The IP packet inside the captured Ethernet frame */
   u_int32_t crc32;
   struct TEncapHeader* encapHdr;
 
+  ethernetFrame = GetEthernetFrame(encapsulationUdpData);
+
   /* Only forward IPv4 packets */
-  u_int16_t type;
-  memcpy(&type, ethPkt + ETH_TYPE_OFFSET, 2);
-  if (ntohs(type) != IPV4_TYPE)
+  if (GetEtherType(ethernetFrame) != IPV4_TYPE)
   {
     return;
   }
 
-  ipData = (struct ip*)(ethPkt + IP_HDR_OFFSET);
+  ipHeader = GetIpHeader(ethernetFrame);
 
-  /* Only forward multicast packets. Also forward local broadcast packets,
-   * if configured */
-  COPY_IP(&destIp, &ipData->ip_dst);
-  if (IsMulticast(&destIp) ||
-      (EnableLocalBroadcast != 0 && IsLocalBroadcast(&destIp, &intf->broadAddr)))
+  COPY_IP(&dst, &ipHeader->ip_dst);
+
+  /* Only forward multicast packets. If configured, also forward local broadcast packets */
+  if (IsMulticast(&dst) ||
+      (EnableLocalBroadcast != 0 && COMP_IP(&dst, &intf->broadAddr)))
   {
     /* continue */
   }
@@ -183,33 +301,42 @@
     return;
   }
 
-  /* Discard OLSR packets (UDP port 698) and BMF encapsulated packets */
-  if (IsOlsrOrBmfPacket(intf, ethPkt, ethPktLen))
+  ipPacket = GetIpPacket(ethernetFrame);
+
+  /* Don't forward fragments of IP packets. Also, don't forward OLSR packets (UDP
+   * port 698) and BMF encapsulated packets */
+  if (IsIpFragment(ipPacket) || IsOlsrOrBmfPacket(ipPacket))
   {
     return;
   }
 
-  /* Check if this packet is captured on an OLSR-enabled interface */
+  /* Increase counter */
+  intf->nBmfPacketsRx++;
+
+  /* Check if the frame is captured on an OLSR-enabled interface */
   isFromOlsrIntf = (intf->olsrIntf != NULL);
 
-  COPY_IP(&srcIp, &ipData->ip_src);
+  /* Retrieve the length of the captured frame */
+  ethernetFrameLen = GetFrameLength(ethernetFrame);
+
+  COPY_IP(&src, &ipHeader->ip_src);
   OLSR_PRINTF(
-    9,
-    "%s: %s pkt of %d bytes captured on %s interface \"%s\": %s->%s\n",
+    8,
+    "%s: %s pkt of %ld bytes captured on %s interface \"%s\": %s->%s\n",
     PLUGIN_NAME_SHORT,
     sllPkttype == PACKET_OUTGOING ? "outgoing" : "incoming",
-    ethPktLen,
+    (long)ethernetFrameLen,
     isFromOlsrIntf ? "OLSR" : "non-OLSR",
     intf->ifName,
-    olsr_ip_to_string(&srcIp),
-    olsr_ip_to_string(&destIp));
+    olsr_ip_to_string(&src),
+    olsr_ip_to_string(&dst));
 
   /* Apply drop list for testing purposes. */
-  srcMac = ethPkt + IFHWADDRLEN;
+  srcMac = ethernetFrame + IFHWADDRLEN;
   if (IsInDropList(srcMac))
   {
     OLSR_PRINTF(
-      9,
+      8,
       "%s: --> discarding: source MAC (%.2x:%.2x:%.2x:%.2x:%.2x:%.2x) found in drop list\n",
       PLUGIN_NAME_SHORT,
       *srcMac, *(srcMac + 1), *(srcMac + 2), *(srcMac + 3), *(srcMac + 4), *(srcMac + 5));
@@ -217,66 +344,44 @@
   }
 
   /* Lookup main address of source in the MID table of OLSR */
-  origIp = mid_lookup_main_addr(&srcIp);
-  if (origIp == NULL)
-  {
-    origIp = &srcIp;
-  }
-
-#ifdef DO_TTL_STUFF
-  /* If this packet is captured on a non-OLSR interface, decrease
-   * the TTL and re-calculate the IP header checksum. */
-  if (! isFromOlsrIntf)
-  {
-    DecreaseTtlAndUpdateHeaderChecksum(ethPkt);
-  } */
-
-  /* If the resulting TTL is <= 0, this packet life has ended, so do not forward it */
-  if (GetIpTtl(ethPkt) <= 0)
-  {
-    OLSR_PRINTF(
-      9,
-      "%s: --> discarding: TTL=0\n",
-      PLUGIN_NAME_SHORT);
-    return;
-  } */
-#endif
+  origIp = MainAddressOf(&src);
 
   /* Check if this packet was seen recently */
-  crc32 = PacketCrc32(ethPkt, ethPktLen);
+  crc32 = PacketCrc32(ethernetFrame, ethernetFrameLen);
   if (CheckAndMarkRecentPacket(Hash16(crc32)))
   {
+    /* Increase counter */
+    intf->nBmfPacketsRxDup++;
+
     OLSR_PRINTF(
-      9,
+      8,
       "%s: --> discarding: packet is duplicate\n",
       PLUGIN_NAME_SHORT);
     return;
   }
 
   /* Compose encapsulation header */
-  encapHdr = (struct TEncapHeader*) buffer;
+  encapHdr = (struct TEncapHeader*) encapsulationUdpData;
   memset (encapHdr, 0, ENCAP_HDR_LEN);
   encapHdr->crc32 = htonl(crc32);
 
-  /* Check if this packet is captured on an OLSR interface from an OLSR neighbor */
+  /* Check if the frame is captured on an OLSR interface from an OLSR neighbor.
+   * TODO1: get_best_link_to_neighbor() is not thread-safe.
+   * TODO2: get_best_link_to_neighbor() may be very CPU-expensive, a simpler call
+   * would do here (something like 'get_any_link_to_neighbor()'). */
   isFromOlsrNeighbor =
-    (isFromOlsrIntf /* The packet is captured on an OLSR interface... */
+    (isFromOlsrIntf /* The frame is captured on an OLSR interface... */
     && get_best_link_to_neighbor(origIp) != NULL); /* ...from an OLSR neighbor */ 
 
   /* Check with OLSR if I am MPR for that neighbor */
+  /* TODO: olsr_lookup_mprs_set() is not thread-safe! */
   iAmMpr = olsr_lookup_mprs_set(origIp) != NULL;
 
-  /* Check with each interface what needs to be done on it */
-  nextFwIntf = BmfInterfaces;
-  while (nextFwIntf != NULL)
+  /* Check with each network interface what needs to be done on it */
+  for (walker = BmfInterfaces; walker != NULL; walker = walker->next)
   {
-    int isToOlsrIntf;
-
-    struct TBmfInterface* fwIntf = nextFwIntf;
-    nextFwIntf = fwIntf->next;
-
     /* Is the forwarding interface OLSR-enabled? */
-    isToOlsrIntf = (fwIntf->olsrIntf != NULL);
+    int isToOlsrIntf = (walker->olsrIntf != NULL);
 
     /* Depending on certain conditions, we decide whether or not to forward
      * the packet, and if it is forwarded, in which form (encapsulated
@@ -307,17 +412,17 @@
      *
      * - Case 2: Packet coming in on an OLSR interface. What to do with it on a
      *   non-OLSR interface?
-     *   Answer: [Decrease the packet's TTL and] forward it.
+     *   Answer: Forward it.
      *
      * - Case 3: Packet coming in on a non-OLSR interface. What to
      *   do with it on an OLSR interface?
-     *   Answer: [Decrease the packet's TTL, then] encapsulate and forward it.
+     *   Answer: Encapsulate and forward it.
      *
      * - Case 4: Packet coming in on non-OLSR interface. What to do with it on a
      *   non-OLSR interface?
      *   Answer 1: nothing. Multicast routing between non-OLSR interfaces
      *   is to be done by other protocols (e.g. PIM, DVMRP).
-     *   Answer 2 (better): [Decrease the packet's TTL, then] forward it.
+     *   Answer 2 (better): Forward it.
      */
 
     if (isFromOlsrIntf && isToOlsrIntf)
@@ -329,238 +434,195 @@
         /* Case 1.1 */
         {
           OLSR_PRINTF(
-            9,
-            "%s: --> not encap-forwarding to \"%s\": I am not selected as MPR by neighbor %s\n",
+            8,
+            "%s: --> not encap-forwarding on \"%s\": I am not selected as MPR by neighbor %s\n",
             PLUGIN_NAME_SHORT,
-            fwIntf->ifName,
-            olsr_ip_to_string(&srcIp));
+            walker->ifName,
+            olsr_ip_to_string(&src));
         }    
       }
-      else if (sllPkttype == PACKET_OUTGOING && intf == fwIntf)
+      else if (sllPkttype == PACKET_OUTGOING && intf == walker)
       {
         OLSR_PRINTF(
-          9,
-          "%s: --> not encap-forwarding to \"%s\": pkt was captured on that interface\n",
+          8,
+          "%s: --> not encap-forwarding on \"%s\": pkt was captured on that interface\n",
           PLUGIN_NAME_SHORT,
-          fwIntf->ifName);
+          walker->ifName);
       }
       else
       {
         /* Case 1.2 and 1.3 */
-        EncapsulateAndForwardPacket(fwIntf, buffer, len);
+        EncapsulateAndForwardPacket(walker, encapsulationUdpData);
       }
     } /* if (isFromOlsrIntf && isToOlsrIntf) */
 
     else if (isFromOlsrIntf && !isToOlsrIntf)
     {
-      /* Case 2: Forward from OLSR interface to non-OLSR interface.
-       * [Decrease TTL and] forward */
+      /* Case 2: Forward from OLSR interface to non-OLSR interface */
+
+      int nBytesWritten;
+
+      /* Change source MAC address to that of sending interface */
+      SetFrameSourceMac(ethernetFrame, walker->macAddr);
 
-#ifdef DO_TTL_STUFF
-      /* If the TTL is to become 0, do not forward this packet */
-      if (GetIpTtl(ethPkt) <= 1)
+      /* If the encapsulated Ethernet frame is an IP local broadcast packet,
+       * update its destination address to match the subnet of the network
+       * interface on which the packet is being sent. */
+      CheckAndUpdateLocalBroadcast(GetIpPacket(ethernetFrame), &walker->broadAddr);
+
+      nBytesWritten = write(walker->capturingSkfd, ethernetFrame, ethernetFrameLen);
+      if (nBytesWritten != ethernetFrameLen)
       {
-        OLSR_PRINTF(
-          9,
-          "%s: --> not forwarding to \"%s\": TTL=0\n",
-          PLUGIN_NAME_SHORT,
-          fwIntf->ifName);
+        BmfPError("write() error forwarding pkt on \"%s\"", walker->ifName);
       }
       else
       {
-        struct TSaveTtl sttl;
-#endif
-        int nBytesWritten;
-
-        /* Change source MAC address to that of sending interface */
-        memcpy(ethPkt + IFHWADDRLEN, fwIntf->macAddr, IFHWADDRLEN);
-
-        /* If the destination address is not a multicast address, it is assumed to be
-         * a local broadcast packet. Update the destination address to match the subnet
-         * of the network interface on which the packet is being sent. */
-        CheckAndUpdateLocalBroadcast(ethPkt, &fwIntf->broadAddr);
-
-#ifdef DO_TTL_STUFF
-        /* Save IP header checksum and the TTL-value of the packet */ 
-        SaveTtlAndChecksum(ethPkt, &sttl);
-
-        /* Decrease the TTL by 1 before writing */
-        DecreaseTtlAndUpdateHeaderChecksum(ethPkt);
-#endif
-
-        nBytesWritten = write(fwIntf->capturingSkfd, ethPkt, ethPktLen);
-        if (nBytesWritten != ethPktLen)
-        {
-          olsr_printf(
-            1,
-            "%s: write() error forwarding pkt for %s to \"%s\": %s\n",
-            PLUGIN_NAME,
-            olsr_ip_to_string(&destIp),
-            fwIntf->ifName,
-            strerror(errno));
-        }
-        else
-        {
-          OLSR_PRINTF(
-            9,
-            "%s: --> forwarded to \"%s\"\n",
-            PLUGIN_NAME_SHORT,
-            fwIntf->ifName);
-        }
+        /* Increase counter */
+        walker->nBmfPacketsTx++;
 
-#ifdef DO_TTL_STUFF
-        /* Restore the IP header checksum and the TTL-value of the packet */
-        RestoreTtlAndChecksum(ethPkt, &sttl);
-
-      } /* if (GetIpTtl(ethPkt) <= 1) */
-#endif
+        OLSR_PRINTF(8, "%s: --> forwarded on \"%s\"\n", PLUGIN_NAME_SHORT, walker->ifName);
+      }
     } /* else if (isFromOlsrIntf && !isToOlsrIntf) */
 
     else if (!isFromOlsrIntf && isToOlsrIntf)
     {
       /* Case 3: Forward from a non-OLSR interface to an OLSR interface.
-       * Encapsulate and forward packet.
-       * Note that packets from non-OLSR interfaces already had their TTL decreased. */
+       * Encapsulate and forward packet. */
 
-      EncapsulateAndForwardPacket(fwIntf, buffer, len);
+      EncapsulateAndForwardPacket(walker, encapsulationUdpData);
     } /* else if (!isFromOlsrIntf && isToOlsrIntf) */
 
     else
     {
-      /* Case 4: Forward from non-OLSR interface to non-OLSR interface.
-       * Note that packets from non-OLSR interfaces already had their TTL decreased. */
+      /* Case 4: Forward from non-OLSR interface to non-OLSR interface. */
 
       /* Don't forward on interface on which packet was received */
-      if (intf == fwIntf)
+      if (intf == walker)
       {
         OLSR_PRINTF(
-          9,
-          "%s: --> not forwarding to \"%s\": pkt was captured on that interface\n",
+          8,
+          "%s: --> not forwarding on \"%s\": pkt was captured on that interface\n",
           PLUGIN_NAME_SHORT,
-          fwIntf->ifName);
+          walker->ifName);
       }
 
-#ifdef DO_TTL_STUFF
-      /* If the TTL is <= 0, do not forward this packet */
-      else if (GetIpTtl(ethPkt) <= 0)
-      {
-        OLSR_PRINTF(
-          9,
-          "%s: --> not forwarding to \"%s\": TTL=0\n",
-          PLUGIN_NAME_SHORT,
-          fwIntf->ifName);
-      }
-#endif
       else
       {
         int nBytesWritten;
 
         /* Change source MAC address to that of sending interface */
-        memcpy(ethPkt + IFHWADDRLEN, fwIntf->macAddr, IFHWADDRLEN);
+        SetFrameSourceMac(ethernetFrame, walker->macAddr);
 
-        /* If the destination address is not a multicast address, it is assumed to be
-         * a local broadcast packet. Update the destination address to match the subnet
-         * of the network interface on which the packet is being sent. */
-        CheckAndUpdateLocalBroadcast(ethPkt, &fwIntf->broadAddr);
+        /* If the encapsulated Ethernet frame is an IP local broadcast packet,
+         * update its destination address to match the subnet of the network
+         * interface on which the packet is being sent. */
+        CheckAndUpdateLocalBroadcast(GetIpPacket(ethernetFrame), &walker->broadAddr);
 
-        nBytesWritten = write(fwIntf->capturingSkfd, ethPkt, ethPktLen);
-        if (nBytesWritten != ethPktLen)
+        nBytesWritten = write(walker->capturingSkfd, ethernetFrame, ethernetFrameLen);
+        if (nBytesWritten != ethernetFrameLen)
         {
-          olsr_printf(
-            1,
-            "%s: write() error forwarding pkt for %s to \"%s\": %s\n",
-            PLUGIN_NAME,
-            olsr_ip_to_string(&destIp),
-            fwIntf->ifName,
-            strerror(errno));
+          BmfPError("write() error forwarding pkt on \"%s\"", walker->ifName);
         }
         else
         {
+          /* Increase counter */
+          walker->nBmfPacketsTx++;
+
           OLSR_PRINTF(
-            9,
-            "%s: --> forwarded from non-OLSR to non-OLSR \"%s\"\n",
+            8,
+            "%s: --> forwarded from non-OLSR on non-OLSR \"%s\"\n",
             PLUGIN_NAME_SHORT,
-            fwIntf->ifName);
+            walker->ifName);
         }
-      } /* if (intf == fwIntf) */
-    }
-  } /* while (nextFwIntf != NULL) */
+      } /* if (intf == walker) */
+    } /* if */
+  } /* for */
 }
 
 /* -------------------------------------------------------------------------
- * Function   : BmfEncapsulatedPacketReceived
- * Description: Handle a received BMF-encapsulated IP packet
+ * Function   : BmfEncapsulationPacketReceived
+ * Description: Handle a received BMF-encapsulation packet
  * Input      : intf - the network interface on which the packet was received
- *              fromIp - the IP node that forwarded the packet to us
- *              buffer - the received encapsulated packet
- *              len - the number of octets in the received encapsulated packet
+ *              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
+ *                Ethernet frame
  * Output     : none
  * Return     : none
  * Data Used  : BmfInterfaces
- * Notes      : The packet is assumed to be received on a socket of family
- *              PF_INET and type SOCK_DGRAM (UDP).
  * ------------------------------------------------------------------------- */
-static void BmfEncapsulatedPacketReceived(
-  struct TBmfInterface* intf, 
-  union olsr_ip_addr* fromIp,
-  unsigned char* buffer,
-  ssize_t len)
+static void BmfEncapsulationPacketReceived(
+  struct TBmfInterface* intf,
+  union olsr_ip_addr* forwardedBy,
+  union olsr_ip_addr* forwardedTo,
+  unsigned char* encapsulationUdpData)
 {
-  union olsr_ip_addr* forwarder;
-  int nBytesToWrite;
-  unsigned char* bufferToWrite;
-  int nBytesWritten;
-  int iAmMpr;
-  struct sockaddr_in encapDest;
-  struct TBmfInterface* nextFwIntf;
-  struct ip* ipData;
-  unsigned char* ethPkt;
-  ssize_t ethPktLen;
-  struct TEncapHeader* encapHdr;
+  int iAmMpr; /* True (1) if I am selected as MPR by 'forwardedBy' */
+  struct sockaddr_in forwardTo; /* Next destination of encapsulation packet */
+  struct TBmfInterface* walker;
+  unsigned char* ethernetFrame; /* The encapsulated Ethernet packet */
+  u_int16_t ethernetFrameLen; /* Length of the encapsulated Ethernet packet */
+  struct ip* ipHeader; /* IP header inside the encapsulated Ethernet 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;
 
   /* Are we talking to ourselves? */
-  if (if_ifwithaddr(fromIp) != NULL)
+  if (if_ifwithaddr(forwardedBy) != NULL)
   {
     return;
   }
 
-  /* Encapsulated packet received on non-OLSR interface? Then discard */
+  /* Discard encapsulated packets received on a non-OLSR interface */
   if (intf->olsrIntf == NULL)
   {
     return;
   }
 
-  /* Apply drop list? No, not needed: encapsulated packets are routed,
+  ethernetFrame = GetEthernetFrame(encapsulationUdpData);
+  ethernetFrameLen = GetFrameLength(ethernetFrame);
+
+  ipHeader = GetIpHeader(ethernetFrame);
+
+  COPY_IP(&mcSrc, &ipHeader->ip_src);
+  COPY_IP(&mcDst, &ipHeader->ip_dst);
+
+  /* Apply drop list? No, not needed: encapsulation packets are IP-routed,
    * so filtering should be done by adding a rule to the iptables FORWARD
    * chain, e.g.:
    * iptables -A FORWARD -m mac --mac-source 00:0C:29:28:0E:CC -j DROP */
 
-  ethPkt = buffer + ENCAP_HDR_LEN;
-  ethPktLen = len - ENCAP_HDR_LEN;
-
-  ipData = (struct ip*) (ethPkt + IP_HDR_OFFSET);
+  /* Increase counter */
+  intf->nBmfPacketsRx++;
 
+  /* Beware: not possible to call olsr_ip_to_string more than 4 times in same printf */
   OLSR_PRINTF(
-    9,
-    "%s: encapsulated pkt of %d bytes incoming on \"%s\": %s->",
+    8,
+    "%s: encapsulated pkt of %ld bytes incoming on \"%s\": %s->%s, forwarded by %s to %s\n",
     PLUGIN_NAME_SHORT,
-    ethPktLen,
+    (long)ethernetFrameLen,
     intf->ifName,
-    inet_ntoa(ipData->ip_src));
-  OLSR_PRINTF(
-    9,
-    "%s, forwarded by %s\n",
-    inet_ntoa(ipData->ip_dst), /* not possible to call inet_ntoa twice in same printf */
-    olsr_ip_to_string(fromIp));
+    olsr_ip_to_string(&mcSrc),
+    olsr_ip_to_string(&mcDst),
+    olsr_ip_to_string(forwardedBy),
+    forwardedTo != NULL ? olsr_ip_to_string(forwardedTo) : "me");
 
   /* Get encapsulation header */
-  encapHdr = (struct TEncapHeader*) buffer;
+  encapsulationHdr = (struct TEncapHeader*) encapsulationUdpData;
 
   /* Check if this packet was seen recently */
-  if (CheckAndMarkRecentPacket(Hash16(ntohl(encapHdr->crc32))))
+  if (CheckAndMarkRecentPacket(Hash16(ntohl(encapsulationHdr->crc32))))
   {
+    /* Increase counter */
+    intf->nBmfPacketsRxDup++;
+
     OLSR_PRINTF(
-      9,
+      8,
       "%s: --> discarding: packet is duplicate\n",
       PLUGIN_NAME_SHORT);
     return;
@@ -568,60 +630,59 @@
 
   if (EtherTunTapFd >= 0)
   {
-    struct sockaddr broadAddr;
+    /* Unpack the encapsulated Ethernet packet and send a copy to myself via
+     * the EtherTunTap interface */
+
+    union olsr_ip_addr broadAddr;
+    int nBytesToWrite, nBytesWritten;
+    unsigned char* bufferToWrite;
+
+    /* If the encapsulated Ethernet frame is an IP local broadcast packet,
+     * update its destination address to match the subnet of the EtherTunTap
+     * interface */
+    broadAddr.v4 = htonl(EtherTunTapIpBroadcast);
+    CheckAndUpdateLocalBroadcast(GetIpPacket(ethernetFrame), &broadAddr);
+
+    /* Start off by assuming a TAP device */
+    bufferToWrite = ethernetFrame;
+    nBytesToWrite = ethernetFrameLen;
 
-    /* Unpack encapsulated packet and send a copy to myself via the EtherTunTap interface */
-    bufferToWrite = ethPkt;
-    nBytesToWrite = ethPktLen;
+    /* If we're using the TUN device instead, we need to write an IP packet instead
+     * of an Ethernet packet */
     if (TunOrTap == TT_TUN)
     {
       bufferToWrite += IP_HDR_OFFSET;
       nBytesToWrite -= IP_HDR_OFFSET;
     }
 
-    ((struct sockaddr_in*)&broadAddr)->sin_addr.s_addr = htonl(EtherTunTapIpBroadcast);
-    CheckAndUpdateLocalBroadcast(ethPkt, &broadAddr);
-
     nBytesWritten = write(EtherTunTapFd, bufferToWrite, nBytesToWrite);
     if (nBytesWritten != nBytesToWrite)
     {
-      olsr_printf(
-        1,
-        "%s: write() error forwarding encapsulated pkt to \"%s\": %s\n",
-        PLUGIN_NAME,
-        EtherTunTapIfName,
-        strerror(errno));
+      BmfPError("write() error forwarding encapsulated pkt on \"%s\"", EtherTunTapIfName);
     }
     else
     {
       OLSR_PRINTF(
-        9,
-        "%s: --> unpacked and forwarded to \"%s\"\n",
+        8,
+        "%s: --> unpacked and delivered locally on \"%s\"\n",
         PLUGIN_NAME_SHORT,
         EtherTunTapIfName);
     }
   }
 
-  /* Lookup main address of forwarding node */
-  forwarder = mid_lookup_main_addr(fromIp);
-  if (forwarder == NULL)
-  {
-    forwarder = fromIp;
-  }
-
   /* Check if I am MPR for the forwarder */
-  iAmMpr = (olsr_lookup_mprs_set(forwarder) != NULL);
+  /* TODO: olsr_lookup_mprs_set() is not thread-safe! */
+  iAmMpr = (olsr_lookup_mprs_set(MainAddressOf(forwardedBy)) != NULL);
 
-  memset(&encapDest, 0, sizeof(encapDest));
-  encapDest.sin_family = AF_INET;
-  encapDest.sin_port = htons(BMF_ENCAP_PORT);
+  memset(&forwardTo, 0, sizeof(forwardTo));
+  forwardTo.sin_family = AF_INET;
+  forwardTo.sin_port = htons(BMF_ENCAP_PORT);
 
-  nextFwIntf = BmfInterfaces;
-  while (nextFwIntf != NULL)
-  {
-    struct TBmfInterface* fwIntf = nextFwIntf;
-    nextFwIntf = fwIntf->next;
+  encapsulationUdpDataLen = GetEncapsulationUdpDataLength(encapsulationUdpData);
 
+  /* Check with each network interface what needs to be done on it */
+  for (walker = BmfInterfaces; walker != NULL; walker = walker->next)
+  {
     /* Depending on certain conditions, decide whether or not to forward
      * the packet, and if it is forwarded, in which form (encapsulated
      * or not). These conditions are:
@@ -643,157 +704,133 @@
      *   the flooding.
      */
 
-    /* Forward from OLSR interface to non-OLSR interface: unpack encapsulated
-     * packet, [decrease TTL] and forward */
-    if (fwIntf->olsrIntf == NULL)
+    /* To a non-OLSR interface: unpack encapsulated packet and forward */
+    if (walker->olsrIntf == NULL)
     {
-#ifdef DO_TTL_STUFF
-      /* If the TTL is to become 0, do not forward this packet */
-      if (GetIpTtl(ethPkt) <= 1)
+      int nBytesWritten;
+
+      /* If the encapsulated Ethernet frame is an IP local broadcast packet,
+       * update its destination address to match the subnet of the network
+       * interface on which the packet is being sent. */
+      CheckAndUpdateLocalBroadcast(GetIpPacket(ethernetFrame), &walker->broadAddr);
+
+      nBytesWritten = write(walker->capturingSkfd, ethernetFrame, ethernetFrameLen);
+      if (nBytesWritten != ethernetFrameLen)
       {
-        OLSR_PRINTF(
-          9,
-          "%s: --> not forwarding on \"%s\": TTL=0\n",
-          PLUGIN_NAME_SHORT,
-          fwIntf->ifName);
+        BmfPError("write() error forwarding unpacked encapsulated pkt on \"%s\"", walker->ifName);
       }
       else
       {
-        struct TSaveTtl sttl;
-#endif
+        /* Increase counter */
+        walker->nBmfPacketsTx++;
 
-        /* If the destination address is not a multicast address, it is assumed to be
-         * a local broadcast packet. Update the destination address to match the subnet
-         * of the network interface on which the packet is being sent. */
-        CheckAndUpdateLocalBroadcast(ethPkt, &fwIntf->broadAddr);
-
-#ifdef DO_TTL_STUFF
-        /* Save IP header checksum and the TTL-value of the packet, then 
-         * decrease the TTL by 1 before writing */
-        SaveTtlAndChecksum(ethPkt, &sttl);
-
-        /* Decrease the TTL by 1 before writing */
-        DecreaseTtlAndUpdateHeaderChecksum(ethPkt);
-#endif
-
-        nBytesWritten = write(fwIntf->capturingSkfd, ethPkt, ethPktLen);
-        if (nBytesWritten != ethPktLen)
-        {
-          olsr_printf(
-            1,
-            "%s: write() error forwarding unpacked encapsulated pkt to \"%s\": %s\n",
-            PLUGIN_NAME,
-            fwIntf->ifName,
-            strerror(errno));
-        }
-        else
-        {
-          OLSR_PRINTF(
-            9,
-            "%s: --> unpacked and forwarded to \"%s\"\n",
-            PLUGIN_NAME_SHORT,
-            fwIntf->ifName);
-        }
-
-#ifdef DO_TTL_STUFF
-        /* Restore the IP header checksum and the TTL-value of the packet */
-        RestoreTtlAndChecksum(ethPkt, &sttl);
-
-      } /* if (GetIpTtl(ethPkt) <= 1) */
-#endif
-    } /* if (fwIntf->olsrIntf == NULL) */
+        OLSR_PRINTF(
+          8,
+          "%s: --> unpacked and forwarded on \"%s\"\n",
+          PLUGIN_NAME_SHORT,
+          walker->ifName);
+      }
+    } /* if (walker->olsrIntf == NULL) */
 
-    /* Forward from OLSR interface to OLSR interface: forward the packet if this
-     * node is selected as MPR by the forwarding node */
+    /* To a OLSR interface: forward the packet if this node is selected as MPR by the forwarding node */
     else if (iAmMpr)
     {
-      /* Change source MAC address to that of sending interface */
-      memcpy(buffer + IFHWADDRLEN, fwIntf->macAddr, IFHWADDRLEN);
+      int nBytesWritten;
+
+      /* Compose destination of encapsulation packet */
+      if (ComposeEnapsulationDestination(
+        walker,
+        &mcSrc,
+        forwardedBy,
+        forwardedTo,
+        &forwardTo) == 0)
+      {
+        OLSR_PRINTF(
+          8,
+          "%s: --> not forwarding on \"%s\": there is no neighbor that needs my retransmission\n",
+          PLUGIN_NAME_SHORT,
+          walker->ifName);
 
-      /* Destination address is local broadcast */
-      encapDest.sin_addr.s_addr = ((struct sockaddr_in*)&fwIntf->olsrIntf->int_broadaddr)->sin_addr.s_addr;
+        continue; /* for */
+      }
 
       nBytesWritten = sendto(
-        fwIntf->encapsulatingSkfd,
-        buffer,
-        len,
+        walker->encapsulatingSkfd,
+        encapsulationUdpData,
+        encapsulationUdpDataLen,
         MSG_DONTROUTE,
-        (struct sockaddr*) &encapDest,
-        sizeof(encapDest));                   
+        (struct sockaddr*) &forwardTo,
+        sizeof(forwardTo));                   
 
-      if (nBytesWritten != len)
+      if (nBytesWritten != encapsulationUdpDataLen)
       {
-        olsr_printf(
-          1,
-          "%s: sendto() error forwarding encapsulated pkt via \"%s\": %s\n",
-          PLUGIN_NAME,
-          fwIntf->ifName,
-          strerror(errno));
+        BmfPError("sendto() error forwarding encapsulated pkt on \"%s\"", walker->ifName);
       }
       else
       {
+        /* Increase counter */
+        walker->nBmfPacketsTx++;
+
         OLSR_PRINTF(
-          9,
-          "%s: --> forwarded to \"%s\"\n",
+          8,
+          "%s: --> forwarded on \"%s\" to %s\n",
           PLUGIN_NAME_SHORT,
-          fwIntf->ifName);
+          walker->ifName,
+          inet_ntoa(forwardTo.sin_addr));
       }
     }  /* else if (iAmMpr) */
-    else /* fwIntf->olsrIntf != NULL && !iAmMpr */
+    else /* walker->olsrIntf != NULL && !iAmMpr */
     {
-      /* fwIntf is an OLSR interface and I am not selected as MPR */
+      /* 'walker' is an OLSR interface and I am not selected as MPR */
       OLSR_PRINTF(
-        9,
-        "%s: --> not forwarding to \"%s\": I am not selected as MPR by %s\n",
+        8,
+        "%s: --> not forwarding on \"%s\": I am not selected as MPR by %s\n",
         PLUGIN_NAME_SHORT,
-        fwIntf->ifName,
-        olsr_ip_to_string(fromIp));
+        walker->ifName,
+        olsr_ip_to_string(forwardedBy));
     }
-  } /* while (nextFwIntf != NULL) */
+  } /* for */
 }
 
 /* -------------------------------------------------------------------------
  * Function   : BmfTunPacketCaptured
- * Description: Handle a raw IP packet captured outgoing on the tuntap interface
- * Input      : buffer - space for the encapsulation header, followed by
- *                the captured packet
- *              len - the number of octets in the encapsulation header plus
- *                captured packet
+ * Description: Handle a Ethernet frame, captured outgoing on the tuntap interface
+ * Input      : encapsulationUdpData - space for the encapsulation header, followed by
+ *                the captured Ethernet frame
  * 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_RAW.
  * ------------------------------------------------------------------------- */
-static void BmfTunPacketCaptured(
-  unsigned char* buffer,
-  ssize_t len)
+static void BmfTunPacketCaptured(unsigned char* encapsulationUdpData)
 {
   union olsr_ip_addr srcIp;
-  union olsr_ip_addr destIp;
-  struct TBmfInterface* nextFwIntf;
-  unsigned char* ethPkt = buffer + ENCAP_HDR_LEN;
-  ssize_t ethPktLen = len - ENCAP_HDR_LEN;
-  struct ip* ipData;
+  union olsr_ip_addr dstIp;
+  union olsr_ip_addr broadAddr;
+  struct TBmfInterface* walker;
+  unsigned char* ethernetFrame;
+  u_int16_t ethernetFrameLen;
+  struct ip* ipHeader;
   u_int32_t crc32;
   struct TEncapHeader* encapHdr;
-  struct sockaddr broadAddr;
-  u_int16_t type;
+
+  ethernetFrame = GetEthernetFrame(encapsulationUdpData);
+  ethernetFrameLen = GetFrameLength(ethernetFrame);
 
   /* Only forward IPv4 packets */
-  memcpy(&type, ethPkt + ETH_TYPE_OFFSET, 2);
-  if (ntohs(type) != IPV4_TYPE)
+  if (GetEtherType(ethernetFrame) != IPV4_TYPE)
   {
     return;
   }
 
-  ipData = (struct ip*)(ethPkt + IP_HDR_OFFSET);
+  ipHeader = GetIpHeader(ethernetFrame);
 
-  /* Only forward multicast packets, or local broadcast packets if specified */
-  COPY_IP(&destIp, &ipData->ip_dst);
-  ((struct sockaddr_in*)&broadAddr)->sin_addr.s_addr = htonl(EtherTunTapIpBroadcast);
-  if (IsMulticast(&destIp) ||
-      (EnableLocalBroadcast != 0 && IsLocalBroadcast(&destIp, &broadAddr)))
+  /* Only forward multicast packets. If configured, also forward local broadcast packets */
+  COPY_IP(&dstIp, &ipHeader->ip_dst);
+  broadAddr.v4 = htonl(EtherTunTapIpBroadcast);
+  if (IsMulticast(&dstIp) ||
+      (EnableLocalBroadcast != 0 && COMP_IP(&dstIp, &broadAddr)))
   {
     /* continue */
   }
@@ -802,102 +839,77 @@
     return;
   }
 
-  COPY_IP(&srcIp, &ipData->ip_src);
+  COPY_IP(&srcIp, &ipHeader->ip_src);
   OLSR_PRINTF(
-    9,
-    "%s: outgoing pkt of %d bytes captured on tuntap interface \"%s\": %s->%s\n",
+    8,
+    "%s: outgoing pkt of %ld bytes captured on tuntap interface \"%s\": %s->%s\n",
     PLUGIN_NAME_SHORT,
-    ethPktLen,
+    (long)ethernetFrameLen,
     EtherTunTapIfName,
     olsr_ip_to_string(&srcIp),
-    olsr_ip_to_string(&destIp));
+    olsr_ip_to_string(&dstIp));
 
   /* Check if this packet was seen recently */
-  crc32 = PacketCrc32(ethPkt, ethPktLen);
+  crc32 = PacketCrc32(ethernetFrame, ethernetFrameLen);
   if (CheckAndMarkRecentPacket(Hash16(crc32)))
   {
     OLSR_PRINTF(
-      9,
+      8,
       "%s: --> discarding: packet is duplicate\n",
       PLUGIN_NAME_SHORT);
     return;
   }
 
   /* Compose encapsulation header */
-  encapHdr = (struct TEncapHeader*) buffer;
+  encapHdr = (struct TEncapHeader*) encapsulationUdpData;
   memset (encapHdr, 0, ENCAP_HDR_LEN);
   encapHdr->crc32 = htonl(crc32);
 
-  /* Check with each interface what needs to be done on it */
-  nextFwIntf = BmfInterfaces;
-  while (nextFwIntf != NULL)
+  /* Check with each network interface what needs to be done on it */
+  for (walker = BmfInterfaces; walker != NULL; walker = walker->next)
   {
-    int isToOlsrIntf;
-
-    struct TBmfInterface* fwIntf = nextFwIntf;
-    nextFwIntf = fwIntf->next;
-
     /* Is the forwarding interface OLSR-enabled? */
-    isToOlsrIntf = (fwIntf->olsrIntf != NULL);
-
-    /* Depending on certain conditions, we decide whether or not to forward
-     * the packet, and if it is forwarded, in which form (encapsulated
-     * or not). These conditions are:
-     * - is the packet going out on an OLSR interface or not? (isToOlsrIntf)
-     *
-     * Based on these conditions, the following cases can be distinguished:
-     *
-     * - Case 1: What to do with a packet for an OLSR interface?
-     *   Answer: Encapsulate and forward it.
-     *
-     * - Case 2: What to do with a packet for a non-OLSR interface?
-     *   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.
-     */
-
-    if (isToOlsrIntf)
+    if (walker->olsrIntf != NULL)
     {
-      /* Case 1: Forward to an OLSR interface.
-       * Encapsulate and forward packet. */
+      /* On an OLSR interface: encapsulate and forward packet. */
 
-      EncapsulateAndForwardPacket(fwIntf, buffer, len);
+      EncapsulateAndForwardPacket(walker, encapsulationUdpData);
     }
     else
     {
-      /* Case 2: Forward to a non-OLSR interface. */
+      /* 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;
 
       /* Change source MAC address to that of sending interface */
-      memcpy(ethPkt + IFHWADDRLEN, fwIntf->macAddr, IFHWADDRLEN);
+      SetFrameSourceMac(ethernetFrame, walker->macAddr);
 
-      /* If the destination address is not a multicast address, it is assumed to be
-       * a local broadcast packet. Update the destination address to match the subnet
-       * of the network interface on which the packet is being sent. */
-      CheckAndUpdateLocalBroadcast(ethPkt, &fwIntf->broadAddr);
+      /* If the encapsulated Ethernet frame is an IP local broadcast packet,
+       * update its destination address to match the subnet of the network
+       * interface on which the packet is being sent. */
+      CheckAndUpdateLocalBroadcast(GetIpPacket(ethernetFrame), &walker->broadAddr);
 
-      nBytesWritten = write(fwIntf->capturingSkfd, ethPkt, ethPktLen);
-      if (nBytesWritten != ethPktLen)
+      nBytesWritten = write(walker->capturingSkfd, ethernetFrame, ethernetFrameLen);
+      if (nBytesWritten != ethernetFrameLen)
       {
-        olsr_printf(
-          1,
-          "%s: write() error forwarding pkt for %s to \"%s\": %s\n",
-          PLUGIN_NAME,
-          olsr_ip_to_string(&destIp),
-          fwIntf->ifName,
-          strerror(errno));
+        BmfPError("write() error forwarding pkt on \"%s\"", walker->ifName);
       }
       else
       {
+        /* Increase counter */
+        walker->nBmfPacketsTx++;
+
         OLSR_PRINTF(
-          9,
+          8,
           "%s: --> forwarded from non-OLSR to non-OLSR \"%s\"\n",
           PLUGIN_NAME_SHORT,
-          fwIntf->ifName);
-      }
-    } /* if (isToOlsrIntf) */
-  } /* while (nextFwIntf != NULL) */
+          walker->ifName);
+      } /* if */
+    } /* if */
+  } /* for */
 }
 
 /* -------------------------------------------------------------------------
@@ -911,13 +923,11 @@
  * ------------------------------------------------------------------------- */
 static void DoBmf(void)
 {
-  struct TBmfInterface* currIf;
   int nFdBitsSet;
-  /*unsigned char* rxBuffer = malloc(BMF_BUFFER_SIZE);*/
   unsigned char rxBuffer[BMF_BUFFER_SIZE];
   fd_set rxFdSet;
 
-  assert(HighestSkfd >= 0/* && rxBuffer != NULL*/);
+  assert(HighestSkfd >= 0);
 
   /* Make a local copy of the set of file descriptors that select() can
    * modify to indicate which descriptors actually changed status */
@@ -930,109 +940,184 @@
   {
     if (errno != EINTR)
     {
-      olsr_printf(1, "%s: select() error: %s\n", PLUGIN_NAME, strerror(errno));
+      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 */
-    struct TBmfInterface* nextIf = BmfInterfaces;
-    while (nextIf != NULL)
+    for (walker = BmfInterfaces; walker != NULL; walker = walker->next)
     {
-      int skfd;
-
-      currIf = nextIf;
-      nextIf = currIf->next;
-
-      skfd = currIf->capturingSkfd;
+      int skfd = walker->capturingSkfd;
       if (skfd >= 0 && (FD_ISSET(skfd, &rxFdSet)))
       {
         struct sockaddr_ll pktAddr;
         socklen_t addrLen = sizeof(pktAddr);
         int nBytes;
-        unsigned char* ethPkt;
+        unsigned char* ethernetFrame;
 
         /* A packet was captured. */
 
         nFdBitsSet--;
 
-        /* Receive the packet, leaving space for the BMF encapsulation header */
-        ethPkt = rxBuffer + ENCAP_HDR_LEN;
+        /* Receive the captured Ethernet frame, leaving space for the BMF
+         * encapsulation header */
+        ethernetFrame = GetEthernetFrame(rxBuffer);
         nBytes = recvfrom(
           skfd,
-          ethPkt,
+          ethernetFrame,
           BMF_BUFFER_SIZE - ENCAP_HDR_LEN,
           0,
           (struct sockaddr*)&pktAddr,
           &addrLen);
         if (nBytes < 0)
         {
+          BmfPError("recvfrom() error on \"%s\"", walker->ifName);
+
+          continue; /* for */
+        } /* if (nBytes < 0) */
+
+        /* Check if the number of received bytes is large enough for an Ethernet
+         * frame 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 < IP_HDR_OFFSET + (int)sizeof(struct ip))
+        {
           olsr_printf(
             1,
-            "%s: recvfrom() error on \"%s\": %s\n",
+            "%s: captured frame too short (%d bytes) on \"%s\"\n",
             PLUGIN_NAME,
-            currIf->ifName,
-            strerror(errno));
+            nBytes,
+            walker->ifName);
+
+          continue; /* for */
+        }
+
+        if (pktAddr.sll_pkttype == PACKET_OUTGOING ||
+            pktAddr.sll_pkttype == PACKET_MULTICAST ||
+            pktAddr.sll_pkttype == PACKET_BROADCAST)
+        {
+          /* A multicast or broadcast packet was captured */
+
+          BmfPacketCaptured(walker, pktAddr.sll_pkttype, rxBuffer);
+
+        } /* if (pktAddr.sll_pkttype == ...) */
+      } /* if (skfd >= 0 && (FD_ISSET...)) */
+    } /* for */
+    
+    /* Check if a BMF encapsulation packet was received on the listening
+     * socket (if any) of each network interface */
+    for (walker = BmfInterfaces; walker != NULL; walker = walker->next)
+    {
+      int skfd = walker->listeningSkfd;
+      if (skfd >= 0 && (FD_ISSET(skfd, &rxFdSet)))
+      {
+        struct sockaddr_ll pktAddr;
+        socklen_t addrLen = sizeof(pktAddr);
+        int nBytes;
+        int minimumLength;
+        struct ip* ipHeader;
+        struct udphdr* udpHeader;
+        u_int16_t destPort;
+        union olsr_ip_addr forwardedBy;
+        union olsr_ip_addr forwardedTo;
+
+        /* Heard a BMF packet */
+
+        nFdBitsSet--;
+
+        nBytes = recvfrom(
+          skfd,
+          rxBuffer,
+          BMF_BUFFER_SIZE,
+          0,
+          (struct sockaddr*)&pktAddr,
+          &addrLen);
+        if (nBytes < 0)
+        {
+          BmfPError("recvfrom() error on \"%s\"", walker->ifName);
+
+          continue; /* for */
+        } /* if (nBytes < 0) */
+
+        if (pktAddr.sll_pkttype != PACKET_OTHERHOST)
+        {
+          continue; /* for */
+        } /* if (pktAddr.sll_pkttype ...) */
+
+        /* Check if the received packet is UDP - BMF port */
+        ipHeader = (struct ip*)rxBuffer;
+        if (ipHeader->ip_p != SOL_UDP)
+        {
+          /* Not UDP */
+          continue; /* for */
         }
-        else if (nBytes < IP_HDR_OFFSET + (int)sizeof(struct iphdr))
+
+        udpHeader = (struct udphdr*)(rxBuffer + GetHeaderLength(rxBuffer));
+        destPort = ntohs(udpHeader->dest);
+        if (destPort != BMF_ENCAP_PORT)
+        {
+          /* Not BMF */
+          continue; /* for */
+        }
+
+        /* Check if the number of received bytes is large enough for a minimal BMF
+         * encapsulation packet, at least:
+         * - the IP header of the encapsulation IP packet
+         * - the UDP header of the encapsulation IP packet
+         * - the encapsulation header
+         * - the Ethernet header in the encapsulated Ethernet packet
+         * - a minimum IP header inside the encapsulated packet
+         * Note: 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. */
+        minimumLength =
+          GetHeaderLength(rxBuffer) +
+          sizeof(struct udphdr) +
+          ENCAP_HDR_LEN +
+          IP_HDR_OFFSET +
+          sizeof(struct ip);
+        if (nBytes < minimumLength)
         {
           olsr_printf(
             1,
-            "%s: captured packet too short (%d bytes) on \"%s\"\n",
+            "%s: captured a too short encapsulation packet (%d bytes) on \"%s\"\n",
             PLUGIN_NAME,
             nBytes,
-            currIf->ifName);
+            walker->ifName);
+
+          continue; /* for */
         }
-        else
-        {
-          /* Don't trust the number of bytes as returned from 'recvfrom':
-           * that number may be 4 bytes too large, in case the receiving
-           * network interface is a VLAN interface. */
-          nBytes = IP_HDR_OFFSET + GetIpPacketLength(ethPkt);
-
-          /* Don't let BMF crash by sending too short packets */
-          if (nBytes >= IP_HDR_OFFSET + GetIpHeaderLength(ethPkt))
-          {
-            if (pktAddr.sll_pkttype == PACKET_OUTGOING ||
-                pktAddr.sll_pkttype == PACKET_MULTICAST ||
-                pktAddr.sll_pkttype == PACKET_BROADCAST)
-            {
-              /* A multicast or broadcast packet was captured */
-              BmfPacketCaptured(currIf, pktAddr.sll_pkttype, rxBuffer, nBytes + ENCAP_HDR_LEN);
-            }
-          }
-          else
-          {
-            olsr_printf(
-              1,
-              "%s: captured packet too short (%d bytes) on \"%s\"\n",
-              PLUGIN_NAME,
-              nBytes,
-              currIf->ifName);
-          }
-        } /* if (nBytes < 0) */
+
+        COPY_IP(&forwardedBy, &ipHeader->ip_src);
+        COPY_IP(&forwardedTo, &ipHeader->ip_dst);
+        BmfEncapsulationPacketReceived(
+          walker,
+          &forwardedBy,
+          &forwardedTo,
+          rxBuffer + GetHeaderLength(rxBuffer) + sizeof(struct udphdr));
+
       } /* if (skfd >= 0 && (FD_ISSET...)) */
-    } /* while (nextIf != NULL) */
-    
+    } /* for */
+
     /* Check if a packet was received on the encapsulating socket (if any)
      * of each network interface */
-    nextIf = BmfInterfaces;
-    while (nextIf != NULL)
+    for (walker = BmfInterfaces; walker != NULL; walker = walker->next)
     {
-      int skfd;
-
-      currIf = nextIf;
-      nextIf = currIf->next;
-
-      skfd = currIf->encapsulatingSkfd;
+      int skfd = walker->encapsulatingSkfd;
       if (skfd >= 0 && (FD_ISSET(skfd, &rxFdSet)))
       {
         struct sockaddr_in from;
         socklen_t fromLen = sizeof(from);
         int nBytes;
+        union olsr_ip_addr forwardedBy;
 
         /* An encapsulated packet was received */
 
@@ -1047,52 +1132,52 @@
           &fromLen);
         if (nBytes < 0)
         {
+          BmfPError("recvfrom() error on \"%s\"", walker->ifName);
+
+          continue; /* for */
+        } /* if (nBytes < 0) */
+
+        COPY_IP(&forwardedBy, &from.sin_addr.s_addr);
+
+        /* Check if the number of received bytes is large enough for a minimal BMF
+         * encapsulation packet, at least:
+         * - the encapsulation header
+         * - the Ethernet header in the encapsulated Ethernet packet
+         * - a minimum IP header inside the encapsulated packet */
+        if (nBytes < ENCAP_HDR_LEN + IP_HDR_OFFSET + (int)sizeof(struct ip))
+        {
           olsr_printf(
             1,
-            "%s: recvfrom() error on \"%s\": %s\n",
+            "%s: received a too short encapsulation packet (%d bytes) from %s on \"%s\"\n",
             PLUGIN_NAME,
-            currIf->ifName,
-            strerror(errno));
+            nBytes,
+            olsr_ip_to_string(&forwardedBy),
+            walker->ifName);
+
+          continue; /* for */
         }
-        else
-        {
-          /* Don't let BMF crash by sending too short packets. */
-          if (nBytes >= IP_HDR_OFFSET + GetIpHeaderLength(rxBuffer))
-          {
-            union olsr_ip_addr srcIp;
-            COPY_IP(&srcIp, &from.sin_addr.s_addr);
-            BmfEncapsulatedPacketReceived(currIf, &srcIp, rxBuffer, nBytes);
-          }
-          else
-          {
-            olsr_printf(
-              1,
-              "%s: encapsulated packet too short (%d bytes) from %s on \"%s\"\n",
-              PLUGIN_NAME,
-              nBytes,
-              inet_ntoa(from.sin_addr),
-              currIf->ifName);
-          }
-        } /* if (nBytes < 0) */
+
+        BmfEncapsulationPacketReceived(walker, &forwardedBy, NULL, rxBuffer);
+
       } /* if (skfd >= 0 && (FD_ISSET...)) */
-    } /* while (nextIf != NULL) */
+    } /* for */
 
     if (nFdBitsSet > 0 && FD_ISSET(EtherTunTapFd, &rxFdSet))
     {
-      /* Check if an application has sent a packet to the tuntap
+      /* Check if an application has sent a packet out via the tuntap
        * network interface */
 
       int nBytes;
-      unsigned char* ethPkt;
+      unsigned char* ethernetFrame;
       unsigned char* bufferToRead;
       size_t nBytesToRead;
 
       nFdBitsSet--;
 
       /* Receive the packet, leaving space for the BMF encapsulation header */
-      ethPkt = rxBuffer + ENCAP_HDR_LEN;
+      ethernetFrame = GetEthernetFrame(rxBuffer);
     
-      bufferToRead = ethPkt;
+      bufferToRead = ethernetFrame;
       nBytesToRead = BMF_BUFFER_SIZE - ENCAP_HDR_LEN;
       if (TunOrTap == TT_TUN)
       {
@@ -1102,8 +1187,8 @@
         bufferToRead += IP_HDR_OFFSET;
         nBytesToRead -= IP_HDR_OFFSET;
 
-        /* Compose an Ethernet header, in case other BMF-nodes are receiving
-         * their BMF packets on a tap-interface. */
+        /* Compose a valid Ethernet header, for other BMF-nodes which may be
+         * receiving their BMF packets on a tap-interface. */
 
         /* Use all-ones as destination MAC address. When the IP destination is
          * a multicast address, the destination MAC address should normally also
@@ -1111,56 +1196,31 @@
          * 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(ethPkt, 0xFF, IFHWADDRLEN);
+        memset(ethernetFrame, 0xFF, IFHWADDRLEN);
 
         /* Source MAC address is not important. Set to all-zeros */
-        memset(ethPkt + IFHWADDRLEN, 0x00, IFHWADDRLEN);
+        memset(ethernetFrame + IFHWADDRLEN, 0x00, IFHWADDRLEN);
 
         /* Ethertype = 0800 = IP */
         type = htons(0x0800);
-        memcpy(ethPkt + ETH_TYPE_OFFSET, &type, 2);
+        memcpy(ethernetFrame + ETH_TYPE_OFFSET, &type, 2);
       }
 
-      nBytes = read(
-        EtherTunTapFd,
-        bufferToRead,
-        nBytesToRead);
+      nBytes = read(EtherTunTapFd, bufferToRead, nBytesToRead);
 
       if (nBytes < 0)
       {
-        if (errno != EAGAIN)
-        {
-          olsr_printf(
-            1,
-            "%s: recvfrom() error on \"%s\": %s\n",
-            PLUGIN_NAME,
-            EtherTunTapIfName,
-            strerror(errno));
-        }
-      }
-      else if (nBytes < (int)sizeof(struct iphdr))
-      {
-        olsr_printf(
-          1,
-          "%s: captured packet too short (%d bytes) on \"%s\"\n",
-          PLUGIN_NAME,
-          nBytes,
-          EtherTunTapIfName);
+        BmfPError("recvfrom() error on \"%s\"", EtherTunTapIfName);
       }
       else
       {
-        /* Don't trust the number of bytes as returned from 'recvfrom':
-         * that number may be 4 bytes too large, in case the receiving
-         * network interface is a VLAN interface. */
-        nBytes = IP_HDR_OFFSET + GetIpPacketLength(ethPkt);
-
-        /* Don't let BMF crash by sending too short packets */
-        if (nBytes >= IP_HDR_OFFSET + GetIpHeaderLength(ethPkt))
+        /* Check if the number of received bytes is large enough for an Ethernet
+         * frame which contains at least a minimum-size IP header */
+        if (TunOrTap == TT_TUN)
         {
-          /* An outbound packet was captured */
-          BmfTunPacketCaptured(rxBuffer, nBytes + ENCAP_HDR_LEN);
+          nBytes += IP_HDR_OFFSET;
         }
-        else
+        if (nBytes < IP_HDR_OFFSET + (int)sizeof(struct ip))
         {
           olsr_printf(
             1,
@@ -1168,11 +1228,17 @@
             PLUGIN_NAME,
             nBytes,
             EtherTunTapIfName);
-        } /* if (nBytes >= IP_HDR_OFFSET... */
+        }
+        else
+        {
+          /* An outbound packet was captured */
+
+          BmfTunPacketCaptured(rxBuffer);
+
+        } /* if (nBytes < IP_HDR_OFFSET... */
       } /* if (nBytes < 0) */
     } /* if (nFdBitsSet > 0 && ... */
   } /* while (nFdBitsSet > 0) */
-  /*free(rxBuffer);*/
 }
 
 /* -------------------------------------------------------------------------
@@ -1183,7 +1249,7 @@
  * Return     : none
  * Data Used  : BmfThreadRunning
  * ------------------------------------------------------------------------- */
-static void BmfSignalHandler(int signo)
+static void BmfSignalHandler(int signo __attribute__((unused)))
 {
   BmfThreadRunning = 0;
 }
@@ -1198,7 +1264,7 @@
  * Notes      : Another thread can gracefully stop this thread by sending
  *              a SIGALRM signal.
  * ------------------------------------------------------------------------- */
-static void* BmfRun(void* useless)
+static void* BmfRun(void* useless __attribute__((unused)))
 {
   /* Mask all signals except SIGALRM */
   sigset_t blockedSigs;
@@ -1206,7 +1272,7 @@
   sigdelset(&blockedSigs, SIGALRM);
   if (pthread_sigmask(SIG_BLOCK, &blockedSigs, NULL) != 0)
   {
-    olsr_printf(1, "%s: pthread_sigmask() error: %s\n", PLUGIN_NAME, strerror(errno));
+    BmfPError("pthread_sigmask() error");
   }
 
   /* Set up the signal handler for the process: use SIGALRM to terminate
@@ -1217,7 +1283,7 @@
    * function (see DoBmf()). */
   if (signal(SIGALRM, BmfSignalHandler) == SIG_ERR)
   {
-    olsr_printf(1, "%s: signal() error: %s\n", PLUGIN_NAME, strerror(errno));
+    BmfPError("signal() error");
   }
 
   /* Call the thread function until flagged to exit */
@@ -1292,9 +1358,23 @@
   BmfThreadRunning = 1;
   if (pthread_create(&BmfThread, NULL, BmfRun, NULL) != 0)
   {
-    olsr_printf(1, "%s: pthread_create error: %s\n", PLUGIN_NAME, strerror(errno));
+    BmfPError("pthread_create() error");
     return 0;
   }
+
+  if (EtherTunTapFd >= 0)
+  {
+    /* Deactivate IP spoof filter for EtherTunTap interface */
+    DeactivateSpoofFilter();
+
+    /* If the BMF network interface has a sensible IP address, it is a good idea
+     * to route all multicast traffic through that interface */
+    if (EtherTunTapIp != ETHERTUNTAPDEFAULTIP)
+    {
+      AddMulticastRoute();
+    }
+  }
+
   return 1;
 }
 
@@ -1306,24 +1386,33 @@
  * Return     : none
  * Data Used  : BmfThreadRunning, BmfThread
  * ------------------------------------------------------------------------- */
-void CloseBmf()
+void CloseBmf(void)
 {
+  if (EtherTunTapFd >= 0)
+  {
+    /* If there is a multicast route, try to delete it first */
+    DeleteMulticastRoute();
+
+    /* Restore IP spoof filter for EtherTunTap interface */
+    RestoreSpoofFilter();
+  }
+
   /* Signal BmfThread to exit */
-  if (pthread_kill(BmfThread, SIGALRM) != 0)
   /* 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(BmfThread, SIGALRM) != 0)
   {
-    olsr_printf(1, "%s: pthread_kill() error: %s\n", PLUGIN_NAME, strerror(errno));
+    BmfPError("pthread_kill() error");
   }
 
   /* Wait for BmfThread to acknowledge */
   if (pthread_join(BmfThread, NULL) != 0)
   {
-    olsr_printf(1, "%s: pthread_join() error: %s\n", PLUGIN_NAME, strerror(errno));
+    BmfPError("pthread_join() error");
   }
 
-  /* Time to clean up */
+  /* Clean up after the BmfThread has been killed */
   CloseBmfNetworkInterfaces();
 }
 
@@ -1366,7 +1455,12 @@
   {
     return SetCapturePacketsOnOlsrInterfaces(value);
   }
+  else if (strcmp(key, "BmfMechanism") == 0)
+  {
+    return SetBmfMechanism(value);
+  }
 
   /* Key not recognized */
   return 0;
 }
+
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/bmf/src/Bmf.h olsrd-current/lib/bmf/src/Bmf.h
--- olsrd-0.5.0/lib/bmf/src/Bmf.h	2007-02-10 18:05:55.000000000 +0100
+++ olsrd-current/lib/bmf/src/Bmf.h	2007-04-22 19:40:38.000000000 +0200
@@ -38,13 +38,12 @@
  * Description: Multicast forwarding functions
  * Created    : 29 Jun 2006
  *
- * $Id: Bmf.h,v 1.2 2007/02/10 17:05:55 bernd67 Exp $ 
  * ------------------------------------------------------------------------- */
 
 /* BMF plugin data */
 #define PLUGIN_NAME "OLSRD Basic Multicast Forwarding (BMF) plugin"
 #define PLUGIN_NAME_SHORT "OLSRD BMF"
-#define PLUGIN_VERSION "1.3 (" __DATE__ " " __TIME__ ")"
+#define PLUGIN_VERSION "1.4 (" __DATE__ " " __TIME__ ")"
 #define PLUGIN_COPYRIGHT "  (C) Thales Communications Huizen, Netherlands"
 #define PLUGIN_AUTHOR "  Erik Tromp (erik.tromp@nl.thalesgroup.com)"
 #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION "\n" PLUGIN_COPYRIGHT "\n" PLUGIN_AUTHOR
@@ -52,8 +51,11 @@
 /* UDP-Port on which multicast packets are encapsulated */
 #define BMF_ENCAP_PORT 50698
 
+/* Forward declaration of OLSR interface type */
 struct interface;
 
+void BmfPError(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 InitBmf(struct interface* skipThisIntf);
 void CloseBmf(void);
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/bmf/src/DropList.c olsrd-current/lib/bmf/src/DropList.c
--- olsrd-0.5.0/lib/bmf/src/DropList.c	2007-02-10 18:05:55.000000000 +0100
+++ olsrd-current/lib/bmf/src/DropList.c	2007-04-22 19:40:38.000000000 +0200
@@ -36,7 +36,6 @@
  *              and local broadcast packets are dropped.
  * Created    : 29 Jun 2006
  *
- * $Id: DropList.c,v 1.2 2007/02/10 17:05:55 bernd67 Exp $ 
  * ------------------------------------------------------------------------- */
 
 
@@ -44,7 +43,8 @@
 
 /* System includes */
 #include <assert.h> /* assert() */
-#include <stdio.h> /* NULL */
+#include <stddef.h> /* NULL */
+#include <stdio.h> /* sscanf */
 #include <stdlib.h> /* malloc */
 #include <string.h> /* memcmp */
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/bmf/src/DropList.h olsrd-current/lib/bmf/src/DropList.h
--- olsrd-0.5.0/lib/bmf/src/DropList.h	2007-02-10 18:05:56.000000000 +0100
+++ olsrd-current/lib/bmf/src/DropList.h	2007-04-22 19:40:38.000000000 +0200
@@ -38,7 +38,6 @@
  * Description: List of MAC addresses of hosts from which all packets are dropped.
  * Created    : 29 Jun 2006
  *
- * $Id: DropList.h,v 1.2 2007/02/10 17:05:56 bernd67 Exp $ 
  * ------------------------------------------------------------------------- */
 
 struct TMacAddress
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/bmf/src/NetworkInterfaces.c olsrd-current/lib/bmf/src/NetworkInterfaces.c
--- olsrd-0.5.0/lib/bmf/src/NetworkInterfaces.c	2007-02-11 12:51:56.000000000 +0100
+++ olsrd-current/lib/bmf/src/NetworkInterfaces.c	2007-04-22 19:40:38.000000000 +0200
@@ -35,12 +35,12 @@
  * Description: Functions to open and close sockets
  * Created    : 29 Jun 2006
  *
- * $Id: NetworkInterfaces.c,v 1.3 2007/02/11 11:51:56 bernd67 Exp $ 
  * ------------------------------------------------------------------------- */
 
 #include "NetworkInterfaces.h"
 
 /* System includes */
+#include <stddef.h> /* NULL */
 #include <syslog.h> /* syslog() */
 #include <string.h> /* strerror(), strchr(), strcmp() */
 #include <errno.h> /* errno */
@@ -60,14 +60,18 @@
 #include "olsr.h" /* olsr_printf() */
 #include "defs.h" /* olsr_cnf */
 #include "local_hna_set.h" /* add_local_hna4_entry() */
+#include "link_set.h" /* get_link_set() */
+#include "lq_route.h" /* MIN_LINK_QUALITY */
+#include "tc_set.h" /* olsr_lookup_tc_entry(), olsr_tc_lookup_dst() */
 
 /* Plugin includes */
 #include "Packet.h" /* IFHWADDRLEN */
-#include "Bmf.h" /* PLUGIN_NAME */
+#include "Bmf.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(...). */
@@ -89,10 +93,13 @@
  * used, and this variable will be set to TT_TUN. */
 enum TTunOrTap TunOrTap = TT_TUN;
 
-#define ETHERTUNTAPIPNOTSET 0
+/* 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;
 
-/* 10.255.255.253 in host byte order */
-#define ETHERTUNTAPDEFAULTIP 0x0AFFFFFD
+#define ETHERTUNTAPIPNOTSET 0
 
 /* The IP address of the BMF network interface in host byte order.
  * May be overruled by setting the plugin parameter "BmfInterfaceIp". */
@@ -104,7 +111,7 @@
 
 /* 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 = ETHERTUNTAPDEFAULTIP;
+u_int32_t EtherTunTapIpBroadcast = ETHERTUNTAPIPNOTSET;
 
 /* Whether or not the configuration has overruled the default IP
  * configuration of the EtherTunTap interface */
@@ -122,7 +129,7 @@
  * Input      : ifname - network interface name (e.g. "mybmf0")
  * Output     : none
  * Return     : fail (0) or success (1)
- * Data Used  : none
+ * Data Used  : EtherTunTapIfName
  * ------------------------------------------------------------------------- */
 int SetBmfInterfaceName(const char* ifname)
 {
@@ -161,10 +168,11 @@
  * Function   : SetBmfInterfaceIp
  * Description: Overrule the default IP address and prefix length
  *              ("10.255.255.253/30") of the EtherTunTap interface
- * Input      : ip - IP address, followed by '/' and prefix length
+ * Input      : ip - IP address string, followed by '/' and prefix length
  * Output     : none
  * Return     : fail (0) or success (1)
- * Data Used  : none
+ * Data Used  : EtherTunTapIp, EtherTunTapIpMask, EtherTunTapIpBroadcast,
+ *              TunTapIpOverruled
  * ------------------------------------------------------------------------- */
 int SetBmfInterfaceIp(const char* ip)
 {
@@ -251,6 +259,53 @@
   return 0;
 }
 
+/* -------------------------------------------------------------------------
+ * Function   : SetBmfMechanism
+ * Description: Overrule the default BMF mechanism to either BM_BROADCAST or
+ *              BM_UNICAST_PROMISCUOUS.
+ * Input      : mechanism - either "Broadcast" or "UnicastPromiscuous"
+ * Output     : none
+ * Return     : fail (0) or success (1)
+ * Data Used  : none
+ * ------------------------------------------------------------------------- */
+int SetBmfMechanism(const char* mechanism)
+{
+  if (strcmp(mechanism, "Broadcast") == 0)
+  {
+    BmfMechanism = BM_BROADCAST;
+    return 1;
+  }
+  else if (strcmp(mechanism, "UnicastPromiscuous") == 0)
+  {
+    BmfMechanism = BM_UNICAST_PROMISCUOUS;
+    return 1;
+  }
+
+  /* Value not recognized */
+  return 0;
+}
+
+/* -------------------------------------------------------------------------
+ * 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);
+}
+
 /* To save the state of the IP spoof filter for the EtherTunTap interface */
 static char EthTapSpoofState = '1';
 
@@ -258,21 +313,19 @@
  * Function   : DeactivateSpoofFilter
  * Description: Deactivates the Linux anti-spoofing filter for the tuntap
  *              interface
- * Input      : tunTapName - name used for the tuntap interface (e.g. "tun0" or "tap1")
+ * Input      : none
  * Output     : none
  * Return     : fail (0) or success (1)
- * Data Used  : EthTapSpoofState
+ * Data Used  : EtherTunTapIfName, EthTapSpoofState
  * Notes      : Saves the current filter state for later restoring
  * ------------------------------------------------------------------------- */
-static int DeactivateSpoofFilter(const char* tunTapName)
+int DeactivateSpoofFilter(void)
 {
   FILE* procSpoof;
   char procFile[FILENAME_MAX];
 
-  assert(tunTapName != NULL);
-
   /* Generate the procfile name */
-  sprintf(procFile, "/proc/sys/net/ipv4/conf/%s/rp_filter", tunTapName);
+  sprintf(procFile, "/proc/sys/net/ipv4/conf/%s/rp_filter", EtherTunTapIfName);
 
   /* Open procfile for reading */
   procSpoof = fopen(procFile, "r");
@@ -319,20 +372,18 @@
  * Function   : RestoreSpoofFilter
  * Description: Restores the Linux anti-spoofing filter setting for the tuntap
  *              interface
- * Input      : tunTapName - name used for the tuntap interface (e.g. "tun0" or "tap1")
+ * Input      : none
  * Output     : none
  * Return     : none
- * Data Used  : EthTapSpoofState
+ * Data Used  : EtherTunTapIfName, EthTapSpoofState
  * ------------------------------------------------------------------------- */
-static void RestoreSpoofFilter(const char* tunTapName)
+void RestoreSpoofFilter(void)
 {
   FILE* procSpoof;
   char procFile[FILENAME_MAX];
 
-  assert(tunTapName != NULL);
-
   /* Generate the procfile name */
-  sprintf(procFile, "/proc/sys/net/ipv4/conf/%s/rp_filter", tunTapName);
+  sprintf(procFile, "/proc/sys/net/ipv4/conf/%s/rp_filter", EtherTunTapIfName);
 
   /* Open procfile for writing */
   procSpoof = fopen(procFile, "w");
@@ -349,6 +400,560 @@
   }
 }
 
+#ifndef USING_THALES_LINK_COST_ROUTING
+/* -------------------------------------------------------------------------
+ * Function   : CalcEtx
+ * Description: Calculate the Expected Transmission Count (ETX) value, based on
+ *              link loss fraction and inverse link loss fraction
+ * Input      : loss - link loss fraction
+ *              neigh_loss - inverse link loss fraction 
+ * Output     : none
+ * Return     : the ETX value
+ * Data Used  : none
+ * ------------------------------------------------------------------------- */
+static float CalcEtx(float loss, float neigh_loss) 
+{
+  if (loss < MIN_LINK_QUALITY || neigh_loss < MIN_LINK_QUALITY)
+  {
+    return INFINITE_ETX;
+  }
+  else
+  {
+    return 1.0 / (loss * neigh_loss);
+  }
+}
+#endif /* USING_THALES_LINK_COST_ROUTING */
+
+/* -------------------------------------------------------------------------
+ * Function   : GetBestNeighbor
+ * Description: Get the best neighbor on an interface to send 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     : nPossibleNeighbors - number of found possible neighbors
+ * Return     : the best neighbor, or NULL if none found
+ * Data Used  : none
+ * ------------------------------------------------------------------------- */
+struct link_entry* GetBestNeighbor(
+  struct TBmfInterface* intf,
+  union olsr_ip_addr* source,
+  union olsr_ip_addr* forwardedBy,
+  union olsr_ip_addr* forwardedTo,
+  int* nPossibleNeighbors)
+{
+  /* handle the non-LQ case */
+
+  if (olsr_cnf->lq_level == 0)
+  {
+    struct link_entry* walker;
+    struct link_entry* bestLink = NULL;
+    *nPossibleNeighbors = 0;
+
+    /* TODO: get_link_set() is not thread-safe! */
+    for (walker = get_link_set(); walker != NULL; walker = walker->next) 
+    {
+      union olsr_ip_addr* neighborMainIp;
+
+      /* Consider only links from the specified interface */
+      if (! COMP_IP(&intf->intAddr, &walker->local_iface_addr))
+      {
+        continue; /* for */
+      }
+
+      OLSR_PRINTF(
+        8,
+        "%s: ----> Considering forwarding pkt on \"%s\" to %s\n",
+        PLUGIN_NAME_SHORT,
+        intf->ifName,
+        olsr_ip_to_string(&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 && COMP_IP(neighborMainIp, MainAddressOf(source)))
+      {
+        OLSR_PRINTF(
+          9,
+          "%s: ----> Not forwarding to %s: is source of pkt\n",
+          PLUGIN_NAME_SHORT,
+          olsr_ip_to_string(&walker->neighbor_iface_addr));
+
+        continue; /* for */
+      }
+
+      /* Rely on short-circuit boolean evaluation */
+      if (forwardedBy != NULL && COMP_IP(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(&walker->neighbor_iface_addr));
+
+        continue; /* for */
+      }
+
+      /* Rely on short-circuit boolean evaluation */
+      if (forwardedTo != NULL && COMP_IP(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(&walker->neighbor_iface_addr));
+
+        continue; /* for */
+      }
+
+      /* Found a candidate neighbor to direct our packet to */
+
+      *nPossibleNeighbors += 1;
+
+      /* Remember the first found link */
+      if (bestLink == NULL)
+      {
+        bestLink = walker;
+      }
+
+    } /* for */
+
+    if (bestLink == NULL)
+    {
+      OLSR_PRINTF(
+        9,
+        "%s: ----> No suitable neighbor found to forward to on \"%s\"\n",
+        PLUGIN_NAME_SHORT,
+        intf->ifName);
+    }
+    else
+    {
+      OLSR_PRINTF(
+        9,
+        "%s: ----> Best %sneighbor to forward to on \"%s\" is %s\n",
+        PLUGIN_NAME_SHORT,
+        *nPossibleNeighbors == 1 ? "(and only) " : "",
+        intf->ifName,
+        olsr_ip_to_string(&bestLink->neighbor_iface_addr));
+    }
+
+    return bestLink;
+  }
+  /* handle the LQ case */
+  else
+  {
+#ifdef USING_THALES_LINK_COST_ROUTING
+
+    struct link_entry* walker;
+    struct link_entry* bestLink = NULL;
+    float previousLinkCost = INFINITE_COST;
+    float bestLinkCost = INFINITE_COST;
+    *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)
+      {
+        previousLinkCost = bestLinkFromForwarder->link_cost;
+      }
+    }
+
+    /* TODO: get_link_set() is not thread-safe! */
+    for (walker = get_link_set(); walker != NULL; walker = walker->next) 
+    {
+      union olsr_ip_addr* neighborMainIp;
+      struct link_entry* bestLinkToNeighbor;
+      struct tc_entry* tcLastHop;
+
+      /* Consider only links from the specified interface */
+      if (! COMP_IP(&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(&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 && COMP_IP(neighborMainIp, MainAddressOf(source)))
+      {
+        OLSR_PRINTF(
+          9,
+          "%s: ----> Not forwarding to %s: is source of pkt\n",
+          PLUGIN_NAME_SHORT,
+          olsr_ip_to_string(&walker->neighbor_iface_addr));
+
+        continue; /* for */
+      }
+
+      /* Rely on short-circuit boolean evaluation */
+      if (forwardedBy != NULL && COMP_IP(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(&walker->neighbor_iface_addr));
+
+        continue; /* for */
+      }
+
+      /* Rely on short-circuit boolean evaluation */
+      if (forwardedTo != NULL && COMP_IP(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(&walker->neighbor_iface_addr));
+
+        continue; /* for */
+      }
+
+      /* Found a candidate neighbor to direct our packet to */
+
+      /* Compare costs to check if the candidate neighbor is best reached via 'intf' */
+      OLSR_PRINTF(
+        9,
+        "%s: ----> Forwarding pkt to %s will cost %5.2f\n",
+        PLUGIN_NAME_SHORT,
+        olsr_ip_to_string(&walker->neighbor_iface_addr),
+        walker->link_cost);
+
+      /* 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.
+       * TODO: get_best_link_to_neighbor() is not thread-safe. */
+      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(&walker->neighbor_iface_addr));
+        }
+        else
+        {
+          struct interface* bestIntf = if_ifwithaddr(&bestLinkToNeighbor->local_iface_addr);
+
+          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(&walker->neighbor_iface_addr),
+            bestIntf->int_name,
+            bestLinkToNeighbor->link_cost);
+        }
+
+        continue; /* for */
+      }
+
+      if (forwardedBy != NULL)
+      {
+        OLSR_PRINTF(
+          9,
+          "%s: ----> 2-hop path from %s via me to %s will cost %5.2f\n",
+          PLUGIN_NAME_SHORT,
+          olsr_ip_to_string(forwardedBy),
+          olsr_ip_to_string(&walker->neighbor_iface_addr),
+          previousLinkCost + walker->link_cost);
+      }
+
+      /* 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)
+      {
+        /* TODO: olsr_lookup_tc_entry() is not thread-safe. */
+        tcLastHop = olsr_lookup_tc_entry(MainAddressOf(forwardedBy));
+        if (tcLastHop != NULL)
+        {
+          struct topo_dst* tcDest;
+
+          /* TODO: olsr_tc_lookup_dst() is not thread-safe. */
+          tcDest = olsr_tc_lookup_dst(tcLastHop, MainAddressOf(&walker->neighbor_iface_addr));
+
+          /* Rely on short-circuit boolean evaluation */
+          if (tcDest != NULL && previousLinkCost + walker->link_cost > tcDest->link_cost)
+          {
+            OLSR_PRINTF(
+              9,
+              "%s: ----> Not forwarding to %s: I am not an MPR between %s and %s, direct link costs %5.2f\n",
+              PLUGIN_NAME_SHORT,
+              olsr_ip_to_string(&walker->neighbor_iface_addr),
+              olsr_ip_to_string(forwardedBy),
+              olsr_ip_to_string(&walker->neighbor_iface_addr),
+              tcDest->link_cost);
+
+            continue; /* for */
+          } /* if */
+        } /* if */
+      } /* if */
+
+      *nPossibleNeighbors += 1;
+
+      /* Remember the best link. If all are very bad, remember none. */
+      if (walker->link_cost < bestLinkCost)
+      {
+        bestLink = walker;
+        bestLinkCost = walker->link_cost;
+	    }
+    } /* for */
+
+    if (bestLink == NULL)
+    {
+      OLSR_PRINTF(
+        9,
+        "%s: ----> No suitable neighbor found to forward to on \"%s\"\n",
+        PLUGIN_NAME_SHORT,
+        intf->ifName);
+    }
+    else
+    {
+      OLSR_PRINTF(
+        9,
+        "%s: ----> Best %sneighbor to forward to on \"%s\" is %s\n",
+        PLUGIN_NAME_SHORT,
+        *nPossibleNeighbors == 1 ? "(and only) " : "",
+        intf->ifName,
+        olsr_ip_to_string(&bestLink->neighbor_iface_addr));
+    }
+
+    return bestLink;
+
+#else /* USING_THALES_LINK_COST_ROUTING */
+        
+    struct link_entry* walker;
+    struct link_entry* bestLink = NULL;
+    float previousLinkEtx = INFINITE_ETX;
+    float bestEtx = INFINITE_ETX; 
+    *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 =
+          CalcEtx(
+            bestLinkFromForwarder->loss_link_quality,
+            bestLinkFromForwarder->neigh_link_quality);
+      }
+    }
+
+    /* TODO: get_link_set() is not thread-safe! */
+    for (walker = get_link_set(); walker != NULL; walker = walker->next) 
+    {
+      union olsr_ip_addr* neighborMainIp;
+      struct link_entry* bestLinkToNeighbor;
+      struct tc_entry* tcLastHop;
+      float currEtx;
+ 
+      /* Consider only links from the specified interface */
+      if (! COMP_IP(&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(&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 && COMP_IP(neighborMainIp, MainAddressOf(source)))
+      {
+        OLSR_PRINTF(
+          9,
+          "%s: ----> Not forwarding to %s: is source of pkt\n",
+          PLUGIN_NAME_SHORT,
+          olsr_ip_to_string(&walker->neighbor_iface_addr));
+
+        continue; /* for */
+      }
+
+      /* Rely on short-circuit boolean evaluation */
+      if (forwardedBy != NULL && COMP_IP(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(&walker->neighbor_iface_addr));
+
+        continue; /* for */
+      }
+
+      /* Rely on short-circuit boolean evaluation */
+      if (forwardedTo != NULL && COMP_IP(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(&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 = CalcEtx(
+        walker->loss_link_quality,
+        walker->neigh_link_quality);
+ 
+      /* 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(&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.
+       * TODO: get_best_link_to_neighbor() is not thread-safe. */
+      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(&walker->neighbor_iface_addr));
+        }
+        else
+        {
+          struct interface* bestIntf = if_ifwithaddr(&bestLinkToNeighbor->local_iface_addr);
+
+          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(&walker->neighbor_iface_addr),
+            bestIntf->int_name,
+            CalcEtx(
+              bestLinkToNeighbor->loss_link_quality,
+              bestLinkToNeighbor->neigh_link_quality));
+        }
+
+        continue; /* for */
+      }
+
+      if (forwardedBy != NULL)
+      {
+        OLSR_PRINTF(
+          9,
+          "%s: ----> 2-hop path from %s via me to %s will cost ETX %5.2f\n",
+          PLUGIN_NAME_SHORT,
+          olsr_ip_to_string(forwardedBy),
+          olsr_ip_to_string(&walker->neighbor_iface_addr),
+          previousLinkEtx + currEtx);
+      }
+
+      /* 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)
+      {
+        /* TODO: olsr_lookup_tc_entry() is not thread-safe. */
+        tcLastHop = olsr_lookup_tc_entry(MainAddressOf(forwardedBy));
+        if (tcLastHop != NULL)
+        {
+          struct topo_dst* tcDest;
+
+          /* TODO: olsr_tc_lookup_dst() is not thread-safe. */
+          tcDest = olsr_tc_lookup_dst(tcLastHop, MainAddressOf(&walker->neighbor_iface_addr));
+
+          if (tcDest != NULL)
+          {
+            float tcEtx = CalcEtx(
+              tcDest->link_quality,
+              tcDest->inverse_link_quality);
+
+            if (previousLinkEtx + currEtx > tcEtx)
+            {
+              OLSR_PRINTF(
+                9,
+                "%s: ----> Not forwarding to %s: I am not an MPR between %s and %s, direct link costs %5.2f\n",
+                PLUGIN_NAME_SHORT,
+                olsr_ip_to_string(&walker->neighbor_iface_addr),
+                olsr_ip_to_string(forwardedBy),
+                olsr_ip_to_string(&walker->neighbor_iface_addr),
+                tcEtx);
+
+              continue; /* for */
+            } /* if */
+          } /* if */
+        } /* if */
+      } /* if */
+
+      *nPossibleNeighbors += 1;
+
+      /* Remember the best link. If all are very bad, remember none. */
+      if (currEtx < bestEtx)
+      {
+        bestLink = walker;
+        bestEtx = currEtx;
+      }
+
+    } /* for */
+
+    if (bestLink == NULL)
+    {
+      OLSR_PRINTF(
+        9,
+        "%s: ----> No suitable neighbor found to forward to on \"%s\"\n",
+        PLUGIN_NAME_SHORT,
+        intf->ifName);
+    }
+    else
+    {
+      OLSR_PRINTF(
+        9,
+        "%s: ----> Best %sneighbor to forward to on \"%s\" is %s\n",
+        PLUGIN_NAME_SHORT,
+        *nPossibleNeighbors == 1 ? "(and only) " : "",
+        intf->ifName,
+        olsr_ip_to_string(&bestLink->neighbor_iface_addr));
+    }
+
+    return bestLink;
+
+#endif /* USING_THALES_LINK_COST_ROUTING */
+
+  } /* if */
+} /* GetBestNeighbor */
+
 /* -------------------------------------------------------------------------
  * Function   : CreateCaptureSocket
  * Description: Create socket for promiscuously capturing multicast IP traffic
@@ -370,7 +975,7 @@
   int skfd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
   if (skfd < 0)
   {
-    olsr_printf(1, "%s: socket(PF_PACKET) error: %s\n", PLUGIN_NAME, strerror(errno));
+    BmfPError("socket(PF_PACKET) error");
     return -1;
   }
 
@@ -380,7 +985,7 @@
   mreq.mr_type = PACKET_MR_PROMISC;
   if (setsockopt(skfd, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0)
   {
-    olsr_printf(1, "%s: setsockopt(PACKET_MR_PROMISC) error: %s\n", PLUGIN_NAME, strerror(errno));
+    BmfPError("setsockopt(PACKET_MR_PROMISC) error");
     close(skfd);
     return -1;
   }
@@ -391,22 +996,22 @@
   req.ifr_name[IFNAMSIZ-1] = '\0'; /* Ensures null termination */
   if (ioctl(skfd, SIOCGIFHWADDR, &req) < 0)
   {
-    olsr_printf(1, "%s: error retrieving MAC address: %s\n", PLUGIN_NAME, strerror(errno));
+    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_ALL);
   bindTo.sll_ifindex = ifIndex;
-  bindTo.sll_family = AF_PACKET;
   memcpy(bindTo.sll_addr, req.ifr_hwaddr.sa_data, IFHWADDRLEN);
   bindTo.sll_halen = IFHWADDRLEN;
     
   if (bind(skfd, (struct sockaddr*)&bindTo, sizeof(bindTo)) < 0)
   {
-    olsr_printf(1, "%s: bind() error: %s\n", PLUGIN_NAME, strerror(errno));
+    BmfPError("bind() error");
     close(skfd);
     return -1;
   }
@@ -414,19 +1019,88 @@
   /* Set socket to blocking operation */
   if (fcntl(skfd, F_SETFL, fcntl(skfd, F_GETFL, 0) & ~O_NONBLOCK) < 0)
   {
-    olsr_printf(1, "%s: fcntl() error: %s\n", PLUGIN_NAME, strerror(errno));
+    BmfPError("fcntl() error");
     close(skfd);
     return -1;
   }
 
-  /* Keep the highest-numbered descriptor */
-  if (skfd > HighestSkfd)
+  AddDescriptorToInputSet(skfd);
+
+  return skfd;
+}
+
+/* -------------------------------------------------------------------------
+ * Function   : CreateListeningSocket
+ * Description: Create socket for promiscuously listening to BMF packets.
+ *              Used 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 an UDP (datagram) 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 UDP packet socket */
+  int skfd = socket(PF_PACKET, SOCK_DGRAM, 0);
+  if (skfd < 0)
   {
-    HighestSkfd = skfd;
+    BmfPError("socket(PF_PACKET) error");
+    return -1;
   }
 
-  /* Add descriptor to input set */
-  FD_SET(skfd, &InputSet);
+  /* 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_ALL);
+  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;
 }
@@ -451,14 +1125,14 @@
   int skfd = socket(PF_INET, SOCK_DGRAM, 0);
   if (skfd < 0)
   {
-    olsr_printf(1, "%s: socket(PF_INET) error: %s\n", PLUGIN_NAME, strerror(errno));
+    BmfPError("socket(PF_INET) error");
     return -1;
   }
 
   /* Enable sending to broadcast addresses */
   if (setsockopt(skfd, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on)) < 0)
   {
-    olsr_printf(1, "%s: setsockopt() error: %s\n", PLUGIN_NAME, strerror(errno));
+    BmfPError("setsockopt(SO_BROADCAST) error");
     close(skfd);
     return -1;
   }
@@ -467,12 +1141,12 @@
   /* 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)
   {
-    olsr_printf(1, "%s: setsockopt() error: %s\n", PLUGIN_NAME, strerror(errno));
+    BmfPError("setsockopt(SO_BINDTODEVICE) error");
     close(skfd);
     return -1;
   }
 
-  /* Bind to port */
+  /* Bind to BMF port */
   memset(&bindTo, 0, sizeof(bindTo));
   bindTo.sin_family = AF_INET;
   bindTo.sin_port = htons(BMF_ENCAP_PORT);
@@ -480,7 +1154,7 @@
       
   if (bind(skfd, (struct sockaddr*)&bindTo, sizeof(bindTo)) < 0) 
   {
-    olsr_printf(1, "%s: bind() error: %s\n", PLUGIN_NAME, strerror(errno));
+    BmfPError("bind() error");
     close(skfd);
     return -1;
   }
@@ -488,19 +1162,12 @@
   /* Set socket to blocking operation */
   if (fcntl(skfd, F_SETFL, fcntl(skfd, F_GETFL, 0) & ~O_NONBLOCK) < 0)
   {
-    olsr_printf(1, "%s: fcntl() error: %s\n", PLUGIN_NAME, strerror(errno));
+    BmfPError("fcntl() error");
     close(skfd);
     return -1;
   }
 
-  /* Keep the highest-numbered descriptor */
-  if (skfd > HighestSkfd)
-  {
-    HighestSkfd = skfd;
-  }
-
-  /* Add descriptor to input set */
-  FD_SET(skfd, &InputSet);
+  AddDescriptorToInputSet(skfd);
 
   return skfd;
 }
@@ -525,13 +1192,13 @@
   static char* deviceName = "/dev/net/tun";
   struct ifreq ifreq;
   int etfd;
-  int ioctl_s;
+  int ioctlSkfd;
   int ioctlres;
 
   etfd = open(deviceName, O_RDWR | O_NONBLOCK);
   if (etfd < 0)
   {
-    olsr_printf(1, "%s: error opening %s: %s\n", PLUGIN_NAME, deviceName, strerror(errno));
+    BmfPError("error opening %s", deviceName);
     return -1;
   }
 
@@ -553,7 +1220,7 @@
 
   if (ioctl(etfd, TUNSETIFF, (void *)&ifreq) < 0)
   {
-    olsr_printf(1, "%s: ioctl(TUNSETIFF) error on %s: %s\n", PLUGIN_NAME, deviceName, strerror(errno));
+    BmfPError("ioctl(TUNSETIFF) error on %s", deviceName);
     close(etfd);
     return -1;
   }
@@ -563,10 +1230,10 @@
   ifreq.ifr_name[IFNAMSIZ - 1] = '\0'; /* Ensures null termination */
   ifreq.ifr_addr.sa_family = AF_INET;
 
-  ioctl_s = socket(PF_INET, SOCK_DGRAM, 0);
-  if (ioctl_s < 0)
+  ioctlSkfd = socket(PF_INET, SOCK_DGRAM, 0);
+  if (ioctlSkfd < 0)
   {
-    olsr_printf(1, "%s: socket(PF_INET) error on %s: %s\n", PLUGIN_NAME, deviceName, strerror(errno));
+    BmfPError("socket(PF_INET) error on %s", deviceName);
     close(etfd);
     return -1;
   }
@@ -585,7 +1252,7 @@
 
       if (bmfIf->olsrIntf != NULL)
       {
-        EtherTunTapIp = ntohl(((struct sockaddr_in*)&bmfIf->intAddr)->sin_addr.s_addr);
+        EtherTunTapIp = ntohl(bmfIf->intAddr.v4);
         EtherTunTapIpBroadcast = EtherTunTapIp;
       }
     }
@@ -599,25 +1266,25 @@
   }
 
   ((struct sockaddr_in*)&ifreq.ifr_addr)->sin_addr.s_addr = htonl(EtherTunTapIp);
-  ioctlres = ioctl(ioctl_s, SIOCSIFADDR, &ifreq);
+  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(ioctl_s, SIOCSIFNETMASK, &ifreq);
+    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(ioctl_s, SIOCSIFBRDADDR, &ifreq);
+      ioctlres = ioctl(ioctlSkfd, SIOCSIFBRDADDR, &ifreq);
       if (ioctlres >= 0)
       {
         /* Bring EtherTunTap interface up (if not already) */
-        ioctlres = ioctl(ioctl_s, SIOCGIFFLAGS, &ifreq);
+        ioctlres = ioctl(ioctlSkfd, SIOCGIFFLAGS, &ifreq);
         if (ioctlres >= 0)
         {
           ifreq.ifr_flags |= (IFF_UP | IFF_RUNNING | IFF_BROADCAST);
-          ioctlres = ioctl(ioctl_s, SIOCSIFFLAGS, &ifreq);
+          ioctlres = ioctl(ioctlSkfd, SIOCSIFFLAGS, &ifreq);
         }
       }
     }
@@ -626,15 +1293,10 @@
   if (ioctlres < 0)
   {
     /* Any of the above ioctl() calls failed */
-    olsr_printf(
-      1,
-      "%s: error bringing up EtherTunTap interface \"%s\": %s\n",
-      PLUGIN_NAME,
-      EtherTunTapIfName,
-      strerror(errno));
+    BmfPError("error bringing up EtherTunTap interface \"%s\"", EtherTunTapIfName);
 
     close(etfd);
-    close(ioctl_s);
+    close(ioctlSkfd);
     return -1;
   } /* if (ioctlres < 0) */
 
@@ -643,21 +1305,17 @@
   strncpy(ifreq.ifr_name, EtherTunTapIfName, IFNAMSIZ - 1);
   ifreq.ifr_name[IFNAMSIZ - 1] = '\0'; /* Ensures null termination */
 
-  ioctlres = ioctl(ioctl_s, SIOCGIFFLAGS, &ifreq);
+  ioctlres = ioctl(ioctlSkfd, SIOCGIFFLAGS, &ifreq);
   if (ioctlres >= 0)
   {
     ifreq.ifr_flags |= IFF_MULTICAST;
-    ioctlres = ioctl(ioctl_s, SIOCSIFFLAGS, &ifreq);
+    ioctlres = ioctl(ioctlSkfd, SIOCSIFFLAGS, &ifreq);
   }
   if (ioctlres < 0)
   {
     /* Any of the two above ioctl() calls failed */
-    olsr_printf(
-      1,
-      "%s: error setting multicast flag on EtherTunTap interface \"%s\": %s\n",
-      PLUGIN_NAME,
-      EtherTunTapIfName,
-      strerror(errno));
+    BmfPError("error setting multicast flag on EtherTunTap interface \"%s\"", EtherTunTapIfName);
+
     /* Continue anyway */
   }
 
@@ -666,32 +1324,18 @@
    * daemon (e.g. mrouted) may be using the tuntap interface. */
   if (ioctl(etfd, TUNSETPERSIST, (void *)&ifreq) < 0)
   {
-    olsr_printf(
-      1,
-      "%s: error making EtherTunTap interface \"%s\" persistent: %s\n",
-      PLUGIN_NAME,
-      EtherTunTapIfName,
-      strerror(errno));
+    BmfPError("error making EtherTunTap interface \"%s\" persistent", EtherTunTapIfName);
+
     /* Continue anyway */
   }
 
-  /* Deactivate IP spoof filter for EtherTunTap interface */
-  DeactivateSpoofFilter(EtherTunTapIfName);
+  OLSR_PRINTF(8, "%s: opened 1 socket on \"%s\"\n", PLUGIN_NAME_SHORT, EtherTunTapIfName);
 
-  OLSR_PRINTF(9, "%s: opened 1 socket on \"%s\"\n", PLUGIN_NAME_SHORT, EtherTunTapIfName);
-
-  /* Keep the highest-numbered descriptor */
-  if (etfd > HighestSkfd)
-  {
-    HighestSkfd = etfd;
-  }
-
-  /* Add descriptor to input set */
-  FD_SET(etfd, &InputSet);
+  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 */
+   * on the OLSR network via HNA */
   if (TunTapIpOverruled != 0)
   {
     union olsr_ip_addr temp_net;
@@ -702,67 +1346,11 @@
     add_local_hna4_entry(&temp_net, &temp_netmask);
   }
 
-  /* If the BMF network interface has a sensible IP address, it is a good idea
-   * to route all multicast traffic through that interface */
-  if (EtherTunTapIp != ETHERTUNTAPDEFAULTIP)
-  {
-    struct rtentry kernel_route;
-
-    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(ioctl_s, SIOCADDRT, &kernel_route) < 0)
-    {
-      olsr_printf(
-        1,
-        "%s: error setting multicast route via EtherTunTap interface \"%s\": %s\n",
-        PLUGIN_NAME,
-        EtherTunTapIfName,
-        strerror(errno));
-      /* Continue anyway */
-    }
-  }
-
-  close(ioctl_s);
+  close(ioctlSkfd);
 
   return etfd;
 }
 
-#if 0
-/* -------------------------------------------------------------------------
- * Function   : IsNullMacAddress
- * Description: Checks if a MAC address is all-zeroes
- * Input      : mac - address to check
- * Output     : none
- * Return     : true (1) or false (0)
- * Data Used  : none
- * ------------------------------------------------------------------------- */
-static int IsNullMacAddress(char* mac)
-{
-  int i;
-
-  assert(mac != NULL);
-
-  for (i = 0; i < IFHWADDRLEN; i++)
-  {
-    if (mac[i] != 0) return 0;
-  }
-  return 1;
-}
-#endif
-
 /* -------------------------------------------------------------------------
  * Function   : CreateInterface
  * Description: Create a new TBmfInterface object and adds it to the global
@@ -772,7 +1360,7 @@
  *                NULL if the network interface is not OLSR-enabled
  * Output     : none
  * Return     : the number of opened sockets
- * Data Used  : none
+ * Data Used  : BmfInterfaces, LastBmfInterface
  * ------------------------------------------------------------------------- */
 static int CreateInterface(
   const char* ifName,
@@ -780,6 +1368,7 @@
 {
   int capturingSkfd = -1;
   int encapsulatingSkfd = -1;
+  int listeningSkfd = -1;
   int ioctlSkfd;
   struct ifreq ifr;
   int nOpened = 0;
@@ -794,7 +1383,7 @@
 
   if (olsrIntf != NULL)
   {
-    /* On OLSR interfaces, create socket for encapsulating and forwarding 
+    /* On OLSR-enabled interfaces, create socket for encapsulating and forwarding 
      * multicast packets */
     encapsulatingSkfd = CreateEncapsulateSocket(ifName);
     if (encapsulatingSkfd < 0)
@@ -820,6 +1409,22 @@
     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;
@@ -830,43 +1435,27 @@
   ifr.ifr_name[IFNAMSIZ - 1] = '\0'; /* Ensures null termination */
   if (ioctl(ioctlSkfd, SIOCGIFHWADDR, &ifr) < 0)
   {
-    olsr_printf(
-      1,
-      "%s: ioctl(SIOCGIFHWADDR) error for interface \"%s\": %s\n",
-      PLUGIN_NAME,
-      ifName,
-      strerror(errno));
-    close(capturingSkfd);
-    close(encapsulatingSkfd);
-    free(newIf);
-    return 0;
-  }
-
-  /* If null-interface, cancel the whole creation and return NULL */
-  /* -- Not needed, all goes well with interfaces that have a
-   * null-address, such as ppp interfaces. */
-  /*
-  if (IsNullMacAddress(ifr.ifr_hwaddr.sa_data))
-  {
+    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 */
-    newIf->intAddr = olsrIntf->int_addr;
-    newIf->broadAddr = olsrIntf->int_broadaddr;
+     * address from the OLSR interface object. Downcast to correct sockaddr
+     * subtype. */
+    COPY_IP(&newIf->intAddr, &((struct sockaddr_in *)&olsrIntf->int_addr)->sin_addr.s_addr);
+    COPY_IP(&newIf->broadAddr, &((struct sockaddr_in *)&olsrIntf->int_broadaddr)->sin_addr.s_addr);
   }
   else
   {
@@ -876,18 +1465,14 @@
     ifr.ifr_name[IFNAMSIZ - 1] = '\0'; /* Ensures null termination */
     if (ioctl(ioctlSkfd, SIOCGIFADDR, &ifr) < 0) 
     {
-      olsr_printf(
-        1,
-        "%s: ioctl(SIOCGIFADDR) error for interface \"%s\": %s\n",
-        PLUGIN_NAME,
-        ifName,
-        strerror(errno));
+      BmfPError("ioctl(SIOCGIFADDR) error for interface \"%s\"", ifName);
 
-      ((struct sockaddr_in*)&newIf->intAddr)->sin_addr.s_addr = inet_addr("0.0.0.0");
+      newIf->intAddr.v4 = inet_addr("0.0.0.0");
 	  }
 	  else
 	  {
-      newIf->intAddr = ifr.ifr_addr;
+      /* Downcast to correct sockaddr subtype */
+      COPY_IP(&newIf->intAddr, &((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr);
     }
 
     /* For a non-OLSR interface, retrieve the IP broadcast address ourselves */
@@ -896,18 +1481,14 @@
     ifr.ifr_name[IFNAMSIZ - 1] = '\0'; /* Ensures null termination */
     if (ioctl(ioctlSkfd, SIOCGIFBRDADDR, &ifr) < 0) 
     {
-      olsr_printf(
-        1,
-        "%s: ioctl(SIOCGIFBRDADDR) error for interface \"%s\": %s\n",
-        PLUGIN_NAME,
-        ifName,
-        strerror(errno));
+      BmfPError("ioctl(SIOCGIFBRDADDR) error for interface \"%s\"", ifName);
 
-      ((struct sockaddr_in*)&newIf->broadAddr)->sin_addr.s_addr = inet_addr("0.0.0.0");
+      newIf->broadAddr.v4 = inet_addr("0.0.0.0");
 	  }
 	  else
 	  {
-      newIf->broadAddr = ifr.ifr_broadaddr;
+      /* Downcast to correct sockaddr subtype */
+      COPY_IP(&newIf->broadAddr, &((struct sockaddr_in *)&ifr.ifr_broadaddr)->sin_addr.s_addr);
     }
   }
 
@@ -915,12 +1496,35 @@
   memset(&newIf->fragmentHistory, 0, sizeof(newIf->fragmentHistory));
   newIf->nextFragmentHistoryEntry = 0;
 
-  /* Add new TBmfInterface object to global list */
-  newIf->next = BmfInterfaces;
-  BmfInterfaces = newIf;
+  /* 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(
-    9,
+    8,
     "%s: opened %d socket%s on %s interface \"%s\"\n",
     PLUGIN_NAME_SHORT,
     nOpened,
@@ -955,11 +1559,7 @@
   skfd = socket(PF_INET, SOCK_DGRAM, 0);
   if (skfd < 0)
   {
-    olsr_printf(
-      1,
-      "%s: no inet socket available to retrieve interface list: %s\n",
-      PLUGIN_NAME,
-      strerror(errno));
+    BmfPError("no inet socket available to retrieve interface list");
     return -1;
   }
 
@@ -972,7 +1572,7 @@
 
     if (ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
     {
-      olsr_printf(1, "%s: ioctl(SIOCGIFCONF) error: %s\n", PLUGIN_NAME, strerror(errno));
+      BmfPError("ioctl(SIOCGIFCONF) error");
 
       close(skfd);
       free(ifc.ifc_buf);
@@ -995,9 +1595,15 @@
   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 */
-    union olsr_ip_addr ipAddr;
     COPY_IP(&ipAddr, &((struct sockaddr_in*)&ifr->ifr_addr)->sin_addr.s_addr);
     olsrIntf = if_ifwithaddr(&ipAddr);
 
@@ -1073,14 +1679,19 @@
  *              Also restores the network state to the situation before BMF
  *              was started.
  * ------------------------------------------------------------------------- */
-
-void CloseBmfNetworkInterfaces()
+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)
+  while (nextBmfIf != NULL) 
   {
     struct TBmfInterface* bmfIf = nextBmfIf;
     nextBmfIf = bmfIf->next;
@@ -1097,61 +1708,65 @@
     }
 
     OLSR_PRINTF(
-      9,
+      7,
+      "%s: %s interface \"%s\": RX pkts %d (%d dups); TX pkts %d\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)
   {
-    /* Restore IP spoof filter for EtherTunTap interface */
-    RestoreSpoofFilter(EtherTunTapIfName);
-
     close(EtherTunTapFd);
     nClosed++;
 
-    OLSR_PRINTF(9, "%s: closed \"%s\"\n", PLUGIN_NAME_SHORT, EtherTunTapIfName);
+    OLSR_PRINTF(7, "%s: closed \"%s\"\n", PLUGIN_NAME_SHORT, EtherTunTapIfName);
   }
 
   BmfInterfaces = NULL;
 
-  olsr_printf(1, "%s: closed %d sockets\n", PLUGIN_NAME, nClosed);
-
-  /* If there is a multicast route, delete it */
-  if (EtherTunTapIp != ETHERTUNTAPDEFAULTIP)
-  {
-    struct rtentry kernel_route;
-
-    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);
+  olsr_printf(1, "%s: closed %d sockets\n", PLUGIN_NAME_SHORT, nClosed);
 
-    kernel_route.rt_metric = 0;
-    kernel_route.rt_flags = RTF_UP;
-
-    kernel_route.rt_dev = EtherTunTapIfName;
-
-    if (ioctl(olsr_cnf->ioctl_s, SIOCDELRT, &kernel_route) < 0)
-    {
-      olsr_printf(
-        1,
-        "%s: error deleting multicast route via EtherTunTap interface \"%s\": %s\n",
-        PLUGIN_NAME,
-        EtherTunTapIfName,
-        strerror(errno));
-      /* Continue anyway */
-    }
-  }
+  OLSR_PRINTF(
+    7,
+    "%s: Total all OLSR interfaces    : RX pkts %d (%d dups); TX pkts %d\n",
+    PLUGIN_NAME_SHORT,
+    totalOlsrBmfPacketsRx,
+    totalOlsrBmfPacketsRxDup,
+    totalOlsrBmfPacketsTx);
+  OLSR_PRINTF(
+    7,
+    "%s: Total all non-OLSR interfaces: RX pkts %d (%d dups); TX pkts %d\n",
+    PLUGIN_NAME_SHORT,
+    totalNonOlsrBmfPacketsRx,
+    totalNonOlsrBmfPacketsRxDup,
+    totalNonOlsrBmfPacketsTx);
 }
 
 #define MAX_NON_OLSR_IFS 32
@@ -1165,7 +1780,7 @@
  * Input      : ifName - network interface (e.g. "eth0")
  * Output     : none
  * Return     : fail (0) or success (1)
- * Data Used  : none
+ * Data Used  : NonOlsrIfNames
  * ------------------------------------------------------------------------- */
 int AddNonOlsrBmfIf(const char* ifName)
 {
@@ -1193,7 +1808,7 @@
  * Input      : ifName - network interface (e.g. "eth0")
  * Output     : none
  * Return     : true (1) or false (0)
- * Data Used  : none
+ * Data Used  : NonOlsrIfNames
  * ------------------------------------------------------------------------- */
 int IsNonOlsrBmfIf(const char* ifName)
 {
@@ -1212,36 +1827,32 @@
  * 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. Update the destination address to
- *              match the passed network interface.
- * Input      : buffer - the ethernet-IP packet
+ *              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* buffer, struct sockaddr* broadAddr)
+void CheckAndUpdateLocalBroadcast(unsigned char* ipPacket, union olsr_ip_addr* broadAddr)
 {
   struct iphdr* iph;
   union olsr_ip_addr destIp;
 
-  assert(buffer != NULL && broadAddr != NULL);
+  assert(ipPacket != NULL && broadAddr != NULL);
 
-  iph = (struct iphdr*) (buffer + IP_HDR_OFFSET);
+  iph = (struct iphdr*) ipPacket;
   COPY_IP(&destIp, &iph->daddr);
   if (! IsMulticast(&destIp))
   {
     u_int32_t origDaddr, newDaddr;
-    struct sockaddr_in* sin;
     u_int32_t check;
 
-    /* Cast down to correct sockaddr subtype */
-    sin = (struct sockaddr_in*)broadAddr;
-    
     origDaddr = ntohl(iph->daddr);
 
-    iph->daddr = sin->sin_addr.s_addr;
+    COPY_IP(&iph->daddr, broadAddr);
     newDaddr = ntohl(iph->daddr);
 
     /* Re-calculate IP header checksum for new destination */
@@ -1259,8 +1870,8 @@
     {
       /* Re-calculate UDP/IP checksum for new destination */
 
-      int ipHeaderLen = GetIpHeaderLength(buffer);
-      struct udphdr* udph = (struct udphdr*) (buffer + IP_HDR_OFFSET + ipHeaderLen);
+      int ipHeaderLen = GetHeaderLength(ipPacket);
+      struct udphdr* udph = (struct udphdr*) (ipPacket + ipHeaderLen);
 
       /* RFC 1624, Eq. 3: HC' = ~(~HC - m + m') */
 
@@ -1277,3 +1888,91 @@
   }
 }
 
+/* -------------------------------------------------------------------------
+ * 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);
+}
+
+/* -------------------------------------------------------------------------
+ * 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);
+  }
+}
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/bmf/src/NetworkInterfaces.h olsrd-current/lib/bmf/src/NetworkInterfaces.h
--- olsrd-0.5.0/lib/bmf/src/NetworkInterfaces.h	2007-02-10 18:05:56.000000000 +0100
+++ olsrd-current/lib/bmf/src/NetworkInterfaces.h	2007-04-22 19:40:38.000000000 +0200
@@ -38,12 +38,14 @@
  * Description: Functions to open and close sockets
  * Created    : 29 Jun 2006
  *
- * $Id: NetworkInterfaces.h,v 1.2 2007/02/10 17:05:56 bernd67 Exp $ 
  * ------------------------------------------------------------------------- */
 
 /* System includes */
 #include <netinet/in.h> /* struct in_addr */
 
+/* OLSR includes */
+#include "olsr_types.h" /* olsr_ip_addr */
+
 /* Plugin includes */
 #include "Packet.h" /* IFHWADDRLEN */
 
@@ -59,6 +61,10 @@
    * 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];
@@ -68,10 +74,10 @@
   struct interface* olsrIntf;
 
   /* IP address of this network interface */
-  struct sockaddr intAddr;
+  union olsr_ip_addr intAddr;
 
   /* Broadcast address of this network interface */
-  struct sockaddr broadAddr;
+  union olsr_ip_addr broadAddr;
 
   #define FRAGMENT_HISTORY_SIZE 10
   struct TFragmentHistory
@@ -84,6 +90,11 @@
 
   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; 
 };
@@ -97,6 +108,9 @@
 
 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;
@@ -106,15 +120,29 @@
 enum TTunOrTap { TT_TUN = 0, TT_TAP };
 extern enum TTunOrTap TunOrTap;
 
+enum TBmfMechanism { BM_BROADCAST = 0, BM_UNICAST_PROMISCUOUS };
+extern enum TBmfMechanism BmfMechanism;
+
 int SetBmfInterfaceName(const char* ifname);
 int SetBmfInterfaceType(const char* iftype);
 int SetBmfInterfaceIp(const char* ip);
 int SetCapturePacketsOnOlsrInterfaces(const char* enable);
+int SetBmfMechanism(const char* mechanism);
+int DeactivateSpoofFilter(void);
+void RestoreSpoofFilter(void);
+struct link_entry* GetBestNeighbor(
+  struct TBmfInterface* intf,
+  union olsr_ip_addr* source,
+  union olsr_ip_addr* forwardedBy,
+  union olsr_ip_addr* forwardedTo,
+  int* multipleNeighbors);
 int CreateBmfNetworkInterfaces(struct interface* skipThisIntf);
 void AddInterface(struct interface* newIntf);
 void CloseBmfNetworkInterfaces(void);
 int AddNonOlsrBmfIf(const char* ifName);
 int IsNonOlsrBmfIf(const char* ifName);
-void CheckAndUpdateLocalBroadcast(unsigned char* buffer, struct sockaddr* broadAddr);
+void CheckAndUpdateLocalBroadcast(unsigned char* ipPacket, union olsr_ip_addr* broadAddr);
+void AddMulticastRoute(void);
+void DeleteMulticastRoute(void);
 
 #endif /* _BMF_NETWORKINTERFACES_H */
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/bmf/src/olsrd_plugin.c olsrd-current/lib/bmf/src/olsrd_plugin.c
--- olsrd-0.5.0/lib/bmf/src/olsrd_plugin.c	2007-02-10 18:05:56.000000000 +0100
+++ olsrd-current/lib/bmf/src/olsrd_plugin.c	2007-04-22 19:40:39.000000000 +0200
@@ -35,12 +35,11 @@
  * Description: Interface to the OLSRD plugin system
  * Created    : 29 Jun 2006
  *
- * $Id: olsrd_plugin.c,v 1.2 2007/02/10 17:05:56 bernd67 Exp $ 
  * ------------------------------------------------------------------------- */
 
 /* System includes */
 #include <assert.h> /* assert() */
-#include <stdio.h>
+#include <stddef.h> /* NULL */
 
 /* OLSRD includes */
 #include "olsrd_plugin.h"
@@ -66,7 +65,7 @@
  * Notes      : Called by main OLSRD (olsr_load_dl) to check plugin interface
  *              version
  * ------------------------------------------------------------------------- */
-int olsrd_plugin_interface_version()
+int olsrd_plugin_interface_version(void)
 {
   return OLSRD_PLUGIN_INTERFACE_VERSION;
 }
@@ -80,7 +79,7 @@
  * Data Used  : olsr_cnf
  * Notes      : Called by main OLSRD (init_olsr_plugin) to initialize plugin
  * ------------------------------------------------------------------------- */
-int olsrd_plugin_init()
+int olsrd_plugin_init(void)
 {
   /* Check validity */
   if (olsr_cnf->ip_version != AF_INET)
@@ -110,7 +109,7 @@
  * Data Used  : none
  * Notes      : Called by my_fini() at unload of shared object
  * ------------------------------------------------------------------------- */
-void olsr_plugin_exit()
+void olsr_plugin_exit(void)
 {
   CloseBmf();
 }
@@ -141,7 +140,7 @@
  * Data Used  : none
  * Notes      : Called at load of shared object
  * ------------------------------------------------------------------------- */
-static void my_init()
+static void my_init(void)
 {
   /* Print plugin info to stdout */
   printf("%s\n", MOD_DESC);
@@ -158,7 +157,7 @@
  * Data Used  : none
  * Notes      : Called at unload of shared object
  * ------------------------------------------------------------------------- */
-static void my_fini()
+static void my_fini(void)
 {
   olsr_plugin_exit();
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/bmf/src/Packet.c olsrd-current/lib/bmf/src/Packet.c
--- olsrd-0.5.0/lib/bmf/src/Packet.c	2007-02-10 18:05:56.000000000 +0100
+++ olsrd-current/lib/bmf/src/Packet.c	2007-04-22 19:40:38.000000000 +0200
@@ -32,94 +32,115 @@
 
 /* -------------------------------------------------------------------------
  * File       : Packet.c
- * Description: BMF and IP packet processing functions
+ * Description: IP packet and Ethernet frame processing functions
  * Created    : 29 Jun 2006
  *
- * $Id: Packet.c,v 1.3 2007/02/10 17:05:56 bernd67 Exp $ 
  * ------------------------------------------------------------------------- */
 
 #include "Packet.h"
 
 /* System includes */
+#include <stddef.h> /* NULL */
 #include <assert.h> /* assert() */
-#include <sys/types.h> /* u_int32_t */
+#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 */
 
-#include <stdio.h>
 /* -------------------------------------------------------------------------
- * Function   : GetIpPacketLength
- * Description: Retrieve the IP packet length (in bytes) of the passed
- *              ethernet-IP packet
- * Input      : buffer - the ethernet-IP packet
+ * 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;
+}
+
+/* -------------------------------------------------------------------------
+ * Function   : GetTotalLength
+ * 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
  * ------------------------------------------------------------------------- */
-int GetIpPacketLength(unsigned char* buffer)
+u_int16_t GetTotalLength(unsigned char* ipPacket)
 {
   struct iphdr* iph;
 
-  assert(buffer != NULL);
+  assert(ipPacket != NULL);
 
-  iph = (struct iphdr*) (buffer + IP_HDR_OFFSET);
+  iph = (struct iphdr*) ipPacket;
   return ntohs(iph->tot_len);
 }
 
 /* -------------------------------------------------------------------------
- * Function   : GetIpHeaderLength
- * Description: Retrieve the IP header length (in bytes) of the passed
- *              ethernet-IP packet
- * Input      : buffer - the ethernet-IP packet
+ * Function   : GetHeaderLength
+ * 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
  * ------------------------------------------------------------------------- */
-int GetIpHeaderLength(unsigned char* buffer)
+unsigned int GetHeaderLength(unsigned char* ipPacket)
 {
   struct iphdr* iph;
 
-  assert(buffer != NULL);
+  assert(ipPacket != NULL);
 
-  iph = (struct iphdr*) (buffer + IP_HDR_OFFSET);
+  iph = (struct iphdr*) ipPacket;
   return iph->ihl << 2;
 }
 
 /* -------------------------------------------------------------------------
- * Function   : GetIpTtl
+ * Function   : GetTtl
  * Description: Retrieve the TTL (Time To Live) value from the IP header of
- *              the passed ethernet-IP packet
- * Input      : buffer - the ethernet-IP packet
+ *              an IP packet
+ * Input      : ipPacket - the IP packet
  * Output     : none
  * Return     : TTL value
  * Data Used  : none
  * ------------------------------------------------------------------------- */
-int GetIpTtl(unsigned char* buffer)
+u_int8_t GetTtl(unsigned char* ipPacket)
 {
   struct iphdr* iph;
 
-  assert(buffer != NULL);
+  assert(ipPacket != NULL);
 
-  iph = (struct iphdr*) (buffer + IP_HDR_OFFSET);
+  iph = (struct iphdr*) ipPacket;
   return iph->ttl;
 }
 
 /* -------------------------------------------------------------------------
  * Function   : SaveTtlAndChecksum
  * Description: Save the TTL (Time To Live) value and IP checksum as found in
- *              the IP header of the passed ethernet-IP packet
- * Input      : buffer - the ethernet-IP packet
+ *              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* buffer, struct TSaveTtl* sttl)
+void SaveTtlAndChecksum(unsigned char* ipPacket, struct TSaveTtl* sttl)
 {
   struct iphdr* iph;
 
-  assert(buffer != NULL && sttl != NULL);
+  assert(ipPacket != NULL && sttl != NULL);
 
-  iph = (struct iphdr*) (buffer + IP_HDR_OFFSET);
+  iph = (struct iphdr*) ipPacket;
   sttl->ttl = iph->ttl;
   sttl->check = ntohs(iph->check);
 }
@@ -127,20 +148,20 @@
 /* -------------------------------------------------------------------------
  * Function   : RestoreTtlAndChecksum
  * Description: Restore the TTL (Time To Live) value and IP checksum in
- *              the IP header of the passed ethernet-IP packet
- * Input      : buffer - the ethernet-IP packet
+ *              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* buffer, struct TSaveTtl* sttl)
+void RestoreTtlAndChecksum(unsigned char* ipPacket, struct TSaveTtl* sttl)
 {
   struct iphdr* iph;
 
-  assert(buffer != NULL && sttl != NULL);
+  assert(ipPacket != NULL && sttl != NULL);
 
-  iph = (struct iphdr*) (buffer + IP_HDR_OFFSET);
+  iph = (struct iphdr*) ipPacket;
   iph->ttl = sttl->ttl;
   iph->check = htons(sttl->check);
 }
@@ -149,22 +170,118 @@
  * Function   : DecreaseTtlAndUpdateHeaderChecksum
  * Description: For an IP packet, decrement the TTL value and update the IP header
  *              checksum accordingly.
- * Input      : buffer - the ethernet-IP packet
+ * Input      : ipPacket - the IP packet
  * Output     : none
  * Return     : none
  * Data Used  : none
  * Notes      : See also RFC1141
  * ------------------------------------------------------------------------- */
-void DecreaseTtlAndUpdateHeaderChecksum(unsigned char* buffer)
+void DecreaseTtlAndUpdateHeaderChecksum(unsigned char* ipPacket)
 {
   struct iphdr* iph;
   u_int32_t sum;
 
-  assert(buffer != NULL);
+  assert(ipPacket != NULL);
 
-  iph = (struct iphdr*) (buffer + IP_HDR_OFFSET);
+  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 */
 }
+
+/* -------------------------------------------------------------------------
+ * Function   : GetEtherType
+ * Description: Retrieve the EtherType of an Ethernet frame
+ * Input      : ethernetFrame - the Ethernet frame
+ * Output     : none
+ * Return     : EtherType
+ * Data Used  : none
+ * ------------------------------------------------------------------------- */
+u_int16_t GetEtherType(unsigned char* ethernetFrame)
+{
+  u_int16_t type;
+  memcpy(&type, ethernetFrame + ETH_TYPE_OFFSET, 2);
+  return ntohs(type);
+}
+
+/* -------------------------------------------------------------------------
+ * Function   : GetIpHeader
+ * Description: Retrieve the IP header from an Ethernet frame
+ * Input      : ethernetFrame - the Ethernet frame
+ * Output     : none
+ * Return     : IP header
+ * Data Used  : none
+ * ------------------------------------------------------------------------- */
+struct ip* GetIpHeader(unsigned char* ethernetFrame)
+{
+  return (struct ip*)(ethernetFrame + IP_HDR_OFFSET);
+}
+
+/* -------------------------------------------------------------------------
+ * Function   : GetIpPacket
+ * Description: Retrieve the IP packet from an Ethernet frame
+ * Input      : ethernetFrame - the Ethernet frame
+ * Output     : none
+ * Return     : IP packet
+ * Data Used  : none
+ * ------------------------------------------------------------------------- */
+unsigned char* GetIpPacket(unsigned char* ethernetFrame)
+{
+  return ethernetFrame + IP_HDR_OFFSET;
+}
+
+/* -------------------------------------------------------------------------
+ * Function   : GetFrameLength
+ * Description: Return the Ethernet frame length of an Ethernet frame containing
+ *              an IP packet
+ * Input      : ethernetFrame - the Ethernet frame
+ * Output     : none
+ * Return     : The frame length
+ * Data Used  : none
+ * ------------------------------------------------------------------------- */
+u_int16_t GetFrameLength(unsigned char* ethernetFrame)
+{
+  return GetTotalLength(GetIpPacket(ethernetFrame)) + IP_HDR_OFFSET;
+}
+
+/* -------------------------------------------------------------------------
+ * Function   : SetFrameSourceMac
+ * Description: Set the source MAC address of an Ethernet frame
+ * Input      : ethernetFrame - the Ethernet frame
+              : srcMac - the source MAC address
+ * Output     : none
+ * Return     : none
+ * Data Used  : none
+ * ------------------------------------------------------------------------- */
+void SetFrameSourceMac(unsigned char* ethernetFrame, unsigned char* srcMac)
+{
+  memcpy(ethernetFrame + IFHWADDRLEN, srcMac, IFHWADDRLEN);
+}
+
+/* -------------------------------------------------------------------------
+ * Function   : GetEthernetFrame
+ * Description: Retrieve the Ethernet frame from BMF encapsulation UDP data
+ * Input      : encapsulationUdpData - the encapsulation UDP data
+ * Output     : none
+ * Return     : The Ethernet frame
+ * Data Used  : none
+ * ------------------------------------------------------------------------- */
+unsigned char* GetEthernetFrame(unsigned char* encapsulationUdpData)
+{
+  return encapsulationUdpData + ENCAP_HDR_LEN;
+}
+
+/* -------------------------------------------------------------------------
+ * Function   : GetEncapsulationUdpDataLength
+ * Description: Return the length of BMF encapsulation UDP data
+ * Input      : encapsulationUdpData - the encapsulation UDP data
+ * Output     : none
+ * Return     : The packet length
+ * Data Used  : none
+ * ------------------------------------------------------------------------- */
+u_int16_t GetEncapsulationUdpDataLength(unsigned char* encapsulationUdpData)
+{
+  return GetFrameLength(GetEthernetFrame(encapsulationUdpData)) + ENCAP_HDR_LEN;
+}
+
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/bmf/src/Packet.h olsrd-current/lib/bmf/src/Packet.h
--- olsrd-0.5.0/lib/bmf/src/Packet.h	2007-02-10 18:05:56.000000000 +0100
+++ olsrd-current/lib/bmf/src/Packet.h	2007-04-22 19:40:38.000000000 +0200
@@ -38,7 +38,6 @@
  * Description: BMF and IP packet processing functions
  * Created    : 29 Jun 2006
  *
- * $Id: Packet.h,v 1.2 2007/02/10 17:05:56 bernd67 Exp $ 
  * ------------------------------------------------------------------------- */
 
 /* System includes */
@@ -67,7 +66,7 @@
   u_int32_t futureExpansion3;
 } __attribute__((__packed__));
 
-#define	ENCAP_HDR_LEN (sizeof(struct TEncapHeader))
+#define	ENCAP_HDR_LEN ((int)sizeof(struct TEncapHeader))
 
 struct TSaveTtl
 {
@@ -75,11 +74,19 @@
   u_int16_t check;
 } __attribute__((__packed__));
 
-int GetIpPacketLength(unsigned char* buffer);
-int GetIpHeaderLength(unsigned char* buffer);
-int GetIpTtl(unsigned char* buffer);
-void SaveTtlAndChecksum(unsigned char* buffer, struct TSaveTtl* sttl);
-void RestoreTtlAndChecksum(unsigned char* buffer, struct TSaveTtl* sttl);
-void DecreaseTtlAndUpdateHeaderChecksum(unsigned char* buffer);
+int IsIpFragment(unsigned char* ipPacket);
+u_int16_t GetTotalLength(unsigned char* ipPacket);
+unsigned int GetHeaderLength(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);
+u_int16_t GetEtherType(unsigned char* ethernetFrame);
+struct ip* GetIpHeader(unsigned char* ethernetFrame);
+unsigned char* GetIpPacket(unsigned char* ethernetFrame);
+u_int16_t GetFrameLength(unsigned char* ethernetFrame);
+void SetFrameSourceMac(unsigned char* ethernetFrame, unsigned char* srcMac);
+unsigned char* GetEthernetFrame(unsigned char* encapsulationUdpData);
+u_int16_t GetEncapsulationUdpDataLength(unsigned char* encapsulationUdpData);
 
 #endif /* _BMF_PACKET_H */
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/bmf/src/PacketHistory.c olsrd-current/lib/bmf/src/PacketHistory.c
--- olsrd-0.5.0/lib/bmf/src/PacketHistory.c	2007-02-10 18:05:56.000000000 +0100
+++ olsrd-current/lib/bmf/src/PacketHistory.c	2007-04-22 19:40:38.000000000 +0200
@@ -36,12 +36,12 @@
  *              multicast IP packets.
  * Created    : 29 Jun 2006
  *
- * $Id: PacketHistory.c,v 1.2 2007/02/10 17:05:56 bernd67 Exp $ 
  * ------------------------------------------------------------------------- */
 
 #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 */
@@ -50,7 +50,7 @@
 /* OLSRD includes */
 #include "olsr.h" /* olsr_printf */
 
-/* Plugin includes */
+/* NULLPlugin includes */
 #include "Packet.h"
 
 static u_int32_t PacketHistory[HISTORY_TABLE_SIZE];
@@ -146,23 +146,23 @@
 
 /* -------------------------------------------------------------------------
  * Function   : PacketCrc32
- * Description: Calculates the CRC-32 value for an Ethernet packet
- * Input      : ethPkt - the Ethernet packet
- *              len - the number of octets in the Ethernet packet
+ * Description: Calculates the CRC-32 value for an Ethernet frame
+ * Input      : ethernetFrame - the Ethernet frame
+ *              len - the number of octets in the Ethernet frame
  * Output     : none
  * Return     : 32-bits hash value
  * Data Used  : none
  * Notes      : The source and destination MAC address are not taken into account
  *              in the CRC calculation.
  * ------------------------------------------------------------------------- */
-u_int32_t PacketCrc32(unsigned char* ethPkt, ssize_t len)
+u_int32_t PacketCrc32(unsigned char* ethernetFrame, ssize_t len)
 {
   ssize_t nCrcBytes;
   struct TSaveTtl sttl;
-  struct iphdr* iph;
+  struct ip* ipHeader;
   u_int32_t result;
 
-  assert(ethPkt != NULL);
+  assert(ethernetFrame != NULL);
 
   /* Start CRC calculation at ethertype; skip source and destination MAC 
    * addresses, and ethertype.
@@ -183,15 +183,15 @@
     nCrcBytes = CRC_UPTO_NBYTES;
   }
 
-  SaveTtlAndChecksum(ethPkt, &sttl);
+  SaveTtlAndChecksum(GetIpPacket(ethernetFrame), &sttl);
 
-  iph = (struct iphdr*) (ethPkt + IP_HDR_OFFSET);
-  iph->ttl = 0xFF; /* fixed value of TTL for CRC-32 calculation */
-  iph->check = 0x5A5A; /* fixed value of IP header checksum for CRC-32 calculation */
+  ipHeader = GetIpHeader(ethernetFrame);
+  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(ethPkt + IP_HDR_OFFSET, nCrcBytes);
+  result = CalcCrc32(ethernetFrame + IP_HDR_OFFSET, nCrcBytes);
 
-  RestoreTtlAndChecksum(ethPkt, &sttl);
+  RestoreTtlAndChecksum(GetIpPacket(ethernetFrame), &sttl);
   return result;
 }
 
@@ -209,7 +209,7 @@
  * Return     : none
  * Data Used  : PacketHistory
  * ------------------------------------------------------------------------- */
-void InitPacketHistory()
+void InitPacketHistory(void)
 {
   memset(PacketHistory, 0, sizeof(PacketHistory));
   GenerateCrc32Table();
@@ -277,7 +277,7 @@
  * Return     : none
  * Data Used  : PacketHistory
  * ------------------------------------------------------------------------- */
-void PrunePacketHistory(void* useless)
+void PrunePacketHistory(void* useless __attribute__((unused)))
 {
   uint i;
   for (i = 0; i < HISTORY_TABLE_SIZE; i++)
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/bmf/src/PacketHistory.h olsrd-current/lib/bmf/src/PacketHistory.h
--- olsrd-0.5.0/lib/bmf/src/PacketHistory.h	2007-02-10 18:05:56.000000000 +0100
+++ olsrd-current/lib/bmf/src/PacketHistory.h	2007-04-22 19:40:39.000000000 +0200
@@ -39,7 +39,6 @@
  *              multicast IP packets.
  * Created    : 29 Jun 2006
  *
- * $Id: PacketHistory.h,v 1.2 2007/02/10 17:05:56 bernd67 Exp $ 
  * ------------------------------------------------------------------------- */
 
 #include <sys/types.h> /* ssize_t */
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/dot_draw/src/olsrd_dot_draw.c olsrd-current/lib/dot_draw/src/olsrd_dot_draw.c
--- olsrd-0.5.0/lib/dot_draw/src/olsrd_dot_draw.c	2006-04-11 20:43:12.000000000 +0200
+++ olsrd-current/lib/dot_draw/src/olsrd_dot_draw.c	2007-04-20 16:06:18.000000000 +0200
@@ -37,7 +37,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_dot_draw.c,v 1.22 2006/04/11 18:43:12 kattemat Exp $
+ * $Id: olsrd_dot_draw.c,v 1.23 2007/04/20 14:06:18 bernd67 Exp $
  */
 
 /*
@@ -98,27 +98,24 @@
 static void
 ipc_action(int);
 
-static void inline
+static void
 ipc_print_neigh_link(struct neighbor_entry *neighbor);
 
-static void inline
+static void
 ipc_print_tc_link(struct tc_entry *entry, struct topo_dst *dst_entry);
 
-static void inline
+static void
 ipc_print_net(union olsr_ip_addr *, union olsr_ip_addr *, union hna_netmask *);
 
 static int
-ipc_send(char *, int);
+ipc_send(const char *, int);
 
 static int
-ipc_send_str(char *);
+ipc_send_str(const char *);
 
 static double 
 calc_etx(double, double);
 
-static void inline
-ipc_print_neigh_link(struct neighbor_entry *);
-
 
 /**
  *Do initialization here
@@ -127,11 +124,13 @@
  *function in uolsrd_plugin.c
  */
 int
-olsrd_plugin_init()
+olsrd_plugin_init(void)
 {
   /* Initial IPC value */
   ipc_open = 0;
   ipc_socket_up = 0;
+  ipc_socket = -1;
+  ipc_connection = -1;
 
   /* Register the "ProcessChanges" function */
   register_pcf(&pcf_event);
@@ -146,19 +145,19 @@
  * destructor - called at unload
  */
 void
-olsr_plugin_exit()
+olsr_plugin_exit(void)
 {
   if(ipc_open)
     close(ipc_socket);
 }
 
 
-static void inline
+static void
 ipc_print_neigh_link(struct neighbor_entry *neighbor)
 {
   char buf[256];
-  char* adr;
-  double etx=0.0;
+  const char* adr;
+  double etx = 0.0;
   char* style = "solid";
   struct link_entry* link;
   adr = olsr_ip_to_string(&olsr_cnf->main_addr);
@@ -188,7 +187,7 @@
 
 
 static int
-plugin_ipc_init()
+plugin_ipc_init(void)
 {
   struct sockaddr_in sin;
   olsr_u32_t yes = 1;
@@ -249,40 +248,35 @@
 
 
 static void
-ipc_action(int fd)
+ipc_action(int fd __attribute__((unused)))
 {
   struct sockaddr_in pin;
-  socklen_t addrlen;
-  char *addr;  
-
-  addrlen = sizeof(struct sockaddr_in);
+  socklen_t addrlen = sizeof(struct sockaddr_in);
 
   if (ipc_open)
     {
-      while(close(ipc_connection) == -1) 
-        {
-          olsr_printf(1, "(DOT DRAW) Error on closing previously active TCP connection on fd %d: %s\n", ipc_connection, strerror(errno));
-          if (errno != EINTR)
-            {
-	      break;
-            }
-        }
+      int rc;
+      do {
+        rc = close(ipc_connection);
+      } while (rc == -1 && (errno == EINTR || errno == EAGAIN));
+      if (rc == -1) {
+        olsr_printf(1, "(DOT DRAW) Error on closing previously active TCP connection on fd %d: %s\n", ipc_connection, strerror(errno));
+      }
       ipc_open = 0;
     }
   
   if ((ipc_connection = accept(ipc_socket, (struct sockaddr *)  &pin, &addrlen)) == -1)
     {
       olsr_printf(1, "(DOT DRAW)IPC accept: %s\n", strerror(errno));
-      exit(1);
     }
   else
     {
-      addr = inet_ntoa(pin.sin_addr);
+      char *addr = inet_ntoa(pin.sin_addr);
       if(ntohl(pin.sin_addr.s_addr) != ntohl(ipc_accept_ip.s_addr))
 	{
 	  olsr_printf(1, "Front end-connection from foregin host(%s) not allowed!\n", addr);
 	  close(ipc_connection);
-	  return;
+          ipc_connection = -1;
 	}
       else
 	{
@@ -395,11 +389,11 @@
 }
 
 
-static void inline
+static void
 ipc_print_tc_link(struct tc_entry *entry, struct topo_dst *dst_entry)
 {
   char buf[256];
-  char* adr;
+  const char* adr;
   double etx = calc_etx( dst_entry->link_quality, dst_entry->inverse_link_quality );
 
   adr = olsr_ip_to_string(&entry->T_last_addr);
@@ -412,10 +406,10 @@
 }
 
 
-static void inline
+static void
 ipc_print_net(union olsr_ip_addr *gw, union olsr_ip_addr *net, union hna_netmask *mask)
 {
-  char *adr;
+  const char *adr;
 
   adr = olsr_ip_to_string(gw);
   ipc_send_str("\"");
@@ -438,7 +432,7 @@
 }
 
 static int
-ipc_send_str(char *data)
+ipc_send_str(const char *data)
 {
   if(!ipc_open)
     return 0;
@@ -447,16 +441,17 @@
 
 
 static int
-ipc_send(char *data, int size)
+ipc_send(const char *data, int size)
 {
   if(!ipc_open)
     return 0;
 
 #if defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ || defined __MacOSX__
-  if (send(ipc_connection, data, size, 0) < 0) 
+#define FLAGS 0
 #else
-  if (send(ipc_connection, data, size, MSG_NOSIGNAL) < 0) 
+#define FLAGS MSG_NOSIGNAL
 #endif
+  if (send(ipc_connection, data, size, FLAGS) == -1)
     {
       olsr_printf(1, "(DOT DRAW)IPC connection lost!\n");
       close(ipc_connection);
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/dot_draw/src/olsrd_dot_draw.h olsrd-current/lib/dot_draw/src/olsrd_dot_draw.h
--- olsrd-0.5.0/lib/dot_draw/src/olsrd_dot_draw.h	2005-05-29 14:47:40.000000000 +0200
+++ olsrd-current/lib/dot_draw/src/olsrd_dot_draw.h	2007-04-20 16:20:11.000000000 +0200
@@ -37,7 +37,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_dot_draw.h,v 1.7 2005/05/29 12:47:40 br1 Exp $
+ * $Id: olsrd_dot_draw.h,v 1.8 2007/04/20 14:20:11 bernd67 Exp $
  */
 
 /*
@@ -51,10 +51,15 @@
 extern struct in_addr ipc_accept_ip;
 extern int ipc_port;
 
+int 
+olsrd_plugin_interface_version(void);
 
 int
 olsrd_plugin_init(void);
 
+int
+olsrd_plugin_register_param(char *key, char *value);
+
 void
 olsr_plugin_exit(void);
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/dot_draw/src/olsrd_plugin.c olsrd-current/lib/dot_draw/src/olsrd_plugin.c
--- olsrd-0.5.0/lib/dot_draw/src/olsrd_plugin.c	2005-06-02 17:09:37.000000000 +0200
+++ olsrd-current/lib/dot_draw/src/olsrd_plugin.c	2007-04-20 16:06:18.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_plugin.c,v 1.12 2005/06/02 15:09:37 br1 Exp $
+ * $Id: olsrd_plugin.c,v 1.14 2007/04/20 14:06:18 bernd67 Exp $
  */
 
 /*
@@ -51,6 +51,7 @@
 #include <sys/types.h>
 #include <netinet/in.h>
 
+#include "olsr.h"
 #include "olsrd_plugin.h"
 #include "olsrd_dot_draw.h"
 
@@ -77,7 +78,7 @@
  *Constructor
  */
 static void
-my_init()
+my_init(void)
 {
   /* Print plugin info to stdout */
   printf("%s\n", MOD_DESC);
@@ -92,7 +93,7 @@
  *Destructor
  */
 static void
-my_fini()
+my_fini(void)
 {
   /* Calls the destruction function
    * olsr_plugin_exit()
@@ -105,7 +106,7 @@
 
 
 int 
-olsrd_plugin_interface_version()
+olsrd_plugin_interface_version(void)
 {
   return PLUGIN_INTERFACE_VERSION;
 }
@@ -116,14 +117,17 @@
 {
   if(!strcmp(key, "port"))
     {
-     ipc_port = atoi(value);
-     printf("(DOT DRAW) listening on port: %d\n", ipc_port);
+      ipc_port = atoi(value);
+      olsr_printf(0, "(DOT DRAW) listening on port: %d\n", ipc_port);
+      return 1;
     }
 
   if(!strcmp(key, "accept"))
     {
-	inet_aton(value, &ipc_accept_ip);
-	printf("(DOT DRAW) accept only: %s\n", inet_ntoa(ipc_accept_ip));
+      inet_aton(value, &ipc_accept_ip);
+      olsr_printf(0, "(DOT DRAW) accept only: %s\n", inet_ntoa(ipc_accept_ip));
+      return 1;
     }
+  olsr_printf(0, "(DOT DRAW) ignored: %s=\"%s\"\n", key, value);
   return 1;
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/dyn_gw/src/olsrd_dyn_gw.c olsrd-current/lib/dyn_gw/src/olsrd_dyn_gw.c
--- olsrd-0.5.0/lib/dyn_gw/src/olsrd_dyn_gw.c	2007-01-30 17:48:34.000000000 +0100
+++ olsrd-current/lib/dyn_gw/src/olsrd_dyn_gw.c	2007-05-09 01:49:00.000000000 +0200
@@ -37,7 +37,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_dyn_gw.c,v 1.19 2007/01/30 16:48:34 bernd67 Exp $
+ * $Id: olsrd_dyn_gw.c,v 1.21 2007/05/08 23:49:00 bernd67 Exp $
  */
 
 /*
@@ -87,7 +87,6 @@
   void *(*Func)(void *);
   void *Arg;
 };
-
 #endif
 
 
@@ -103,8 +102,6 @@
 static struct ping_list *
 add_to_ping_list(char *, struct ping_list *);
 
-//struct ping_list *the_ping_list = NULL;
-
 struct hna_list {
   union olsr_ip_addr hna_net;
   union olsr_ip_addr hna_netmask;
@@ -121,8 +118,8 @@
 
 struct hna_list *the_hna_list = NULL;
 
-static void *
-looped_checks(void *foo);
+static void
+looped_checks(void *) __attribute__((noreturn));
 
 static int
 check_gw(union olsr_ip_addr *, union olsr_ip_addr *,struct ping_list *);
@@ -130,8 +127,9 @@
 static int
 ping_is_possible(struct ping_list *);
 
-   
-     
+/* Event function to register with the scheduler */
+static void
+olsr_event_doing_hna(void *);
 
 /**
  * read config file parameters
@@ -197,7 +195,7 @@
  *It is ran _after_ register_olsr_param
  */
 int
-olsrd_plugin_init()
+olsrd_plugin_init(void)
 {
   pthread_t ping_thread;
   
@@ -214,7 +212,7 @@
     olsr_printf(1, "HNA Internet gateway deleted\n");
   }*/
 
-  pthread_create(&ping_thread, NULL, looped_checks, NULL);
+  pthread_create(&ping_thread, NULL, (void *(*)(void *))looped_checks, NULL);
   
   /* Register the GW check */
   olsr_register_scheduler_event(&olsr_event_doing_hna, NULL, 3, 4, NULL);
@@ -227,8 +225,8 @@
  * Scheduled event to update the hna table,
  * called from olsrd main thread to keep the hna table thread-safe
  */
-void
-olsr_event_doing_hna(void *foo)
+static void
+olsr_event_doing_hna(void *foo __attribute__((unused)))
 {
 	struct hna_list *li;
 	/*
@@ -265,76 +263,57 @@
  * reiterated every "Interval" sec (as given in the config or 
  * the default value)
  */
-static void *
-looped_checks(void *foo)
+static void
+looped_checks(void *foo __attribute__((unused)))
 {
-	/*
-	struct hna_list {
-  union olsr_ip_addr hna_net;
-  union hna_netmask hna_netmask;
-  struct ping_list *ping_hosts;
-  int hna_added;
-  int probe_ok;
-  struct hna_list *next;
-};
-	*/
-	struct hna_list *li;
-	
   for(;;) {
+    struct hna_list *li;
     struct timespec remainder_spec;
     /* the time to wait in "Interval" sec (see connfig), default=5sec */
-    struct timespec sleeptime_spec  = {(time_t) check_interval, 0L };
+    struct timespec sleeptime_spec  = { check_interval, 0L };
 
-    li=the_hna_list;
-    while(li){
-	    /* check for gw in table entry and if Ping IPs are given also do pings */
-	    li->probe_ok = check_gw(&li->hna_net,&li->hna_netmask,li->ping_hosts);
-	    //has_available_gw = check_gw(&gw_net, &gw_netmask);
-	    
-	    li=li->next;
+    for(li = the_hna_list; li; li = li->next){
+      /* check for gw in table entry and if Ping IPs are given also do pings */
+      li->probe_ok = check_gw(&li->hna_net,&li->hna_netmask,li->ping_hosts);
+      //has_available_gw = check_gw(&gw_net, &gw_netmask);
     }
 
     while(nanosleep(&sleeptime_spec, &remainder_spec) < 0)
       sleeptime_spec = remainder_spec;
   }
-  return NULL;
+  // return NULL;
 }
 
 
+
 static int
 check_gw(union olsr_ip_addr *net, union olsr_ip_addr *mask, struct ping_list *the_ping_list)
 {
-    char buff[1024], iface[16];
+    char buf[1024], iface[16];
     olsr_u32_t gate_addr, dest_addr, netmask;
     unsigned int iflags;
-    int num, metric, refcnt, use;
+    int metric, refcnt, use;
     int retval = 0;
 
     FILE *fp = fopen(PROCENTRY_ROUTE, "r");
-
     if (!fp) 
       {
         perror(PROCENTRY_ROUTE);
         olsr_printf(1, "INET (IPv4) not configured in this system.\n");
 	return -1;
-      }
-    
-    rewind(fp);
+      }    
 
     /*
     olsr_printf(1, "Genmask         Destination     Gateway         "
                 "Flags Metric Ref    Use Iface\n");
     */
-    while (fgets(buff, 1023, fp))
-	{	
-	num = sscanf(buff, "%15s %128X %128X %X %d %d %d %128X \n",
-		     iface, &dest_addr, &gate_addr,
-		     &iflags, &refcnt, &use, &metric, &netmask);
-
+    while (fgets(buf, sizeof(buf), fp))
+      {	
+	int num = sscanf(buf, "%15s %128X %128X %X %d %d %d %128X \n",
+                         iface, &dest_addr, &gate_addr,
+                         &iflags, &refcnt, &use, &metric, &netmask);
 	if (num < 8)
-	  {
 	    continue;
-	  }
 
 	/*
 	olsr_printf(1, "%-15s ", olsr_ip_to_string((union olsr_ip_addr *)&netmask));
@@ -346,33 +325,34 @@
 		    metric, refcnt, use, iface);
 	*/
 
-		if( (iflags & RTF_UP) &&
-		   (metric == 0) &&
-		   (netmask == mask->v4) && 
-		   (dest_addr == net->v4))
-		{
-			if ( ((mask->v4==INET_PREFIX)&&(net->v4==INET_NET))&&(!(iflags & RTF_GATEWAY)))
-				return retval;
-			/* don't ping, if there was no "Ping" IP addr in the config file */
-			if (the_ping_list != NULL) {  
-				/*validate the found inet gw by pinging*/ 
-				if (ping_is_possible(the_ping_list)) {
-					olsr_printf(1, "HNA[%08x/%08x](ping is possible) VIA %s detected in routing table.\n", dest_addr,netmask,iface);
-					retval=1;      
-				}
-			} else {
-				olsr_printf(1, "HNA[%08x/%08x] VIA %s detected in routing table.\n", dest_addr,netmask,iface);
-				retval=1;      
-			}
-		}
-
-	}//while
+        if( (iflags & RTF_UP) &&
+            (metric == 0) &&
+            (netmask == mask->v4) && 
+            (dest_addr == net->v4))
+          {
+            if ( ((mask->v4==INET_PREFIX)&&(net->v4==INET_NET))&&(!(iflags & RTF_GATEWAY)))
+              {
+                fclose(fp);  
+                return retval;
+              }
+            /* don't ping, if there was no "Ping" IP addr in the config file */
+            if (the_ping_list != NULL) {  
+              /*validate the found inet gw by pinging*/ 
+              if (ping_is_possible(the_ping_list)) {
+                olsr_printf(1, "HNA[%08x/%08x](ping is possible) VIA %s detected in routing table.\n", dest_addr,netmask,iface);
+                retval=1;      
+              }
+            } else {
+              olsr_printf(1, "HNA[%08x/%08x] VIA %s detected in routing table.\n", dest_addr,netmask,iface);
+              retval=1;      
+            }
+          }
+      }
 
-	fclose(fp);  
-  
-	if(retval == 0){
-		olsr_printf(1, "HNA[%08x/%08x] is invalid\n", net->v4,mask->v4);
-	}  
+    fclose(fp);      
+    if(retval == 0){
+      olsr_printf(1, "HNA[%08x/%08x] is invalid\n", net->v4,mask->v4);
+    }  
     return retval;
 }
 
@@ -380,16 +360,15 @@
 ping_is_possible(struct ping_list *the_ping_list) 
 {
   struct ping_list *list;
-  for (list = the_ping_list; list != NULL; list = list->next) {
-    char ping_command[50] = "ping -c 1 -q ";
-    strcat(ping_command, list->ping_address);
+  for(list = the_ping_list; list; list = list->next) {
+    char ping_command[50];
+    snprintf(ping_command, sizeof(ping_command), "ping -c 1 -q %s", list->ping_address);
     olsr_printf(1, "\nDo ping on %s ...\n", list->ping_address);
     if (system(ping_command) == 0) {
       olsr_printf(1, "...OK\n\n");
       return 1;      
-    } else {
-      olsr_printf(1, "...FAILED\n\n");
     }
+    olsr_printf(1, "...FAILED\n\n");
   }
   return 0;
 }
@@ -398,8 +377,8 @@
 static struct ping_list *
 add_to_ping_list(char *ping_address, struct ping_list *the_ping_list)
 {
-  struct ping_list *new = (struct ping_list *) malloc(sizeof(struct ping_list));
-  if(new == NULL)
+  struct ping_list *new = malloc(sizeof(struct ping_list));
+  if(!new)
   {
     fprintf(stderr, "DYN GW: Out of memory!\n");
     exit(0);
@@ -414,7 +393,7 @@
 static struct hna_list *
 add_to_hna_list(struct hna_list * list_root, union olsr_ip_addr *hna_net, union olsr_ip_addr *hna_netmask )
 {
-  struct hna_list *new = (struct hna_list *) malloc(sizeof(struct hna_list));
+  struct hna_list *new = malloc(sizeof(struct hna_list));
   if(new == NULL)
   {
     fprintf(stderr, "DYN GW: Out of memory!\n");
@@ -428,14 +407,10 @@
   new->probe_ok=0;
   new->ping_hosts=NULL;
   new->next=list_root;  
-
   return new;
 }
 
-
-
 #ifdef WIN32
-
 /*
  * Windows ptread compat stuff
  */
@@ -457,7 +432,7 @@
   return 0;
 }
 
-int pthread_create(HANDLE *Hand, void *Attr, void *(*Func)(void *), void *Arg)
+int pthread_create(HANDLE *Hand, void *Attr __attribute__((unused)), void *(*Func)(void *), void *Arg)
 {
   struct ThreadPara *Para;
   unsigned long ThreadId;
@@ -478,7 +453,7 @@
   return 0;
 }
 
-int pthread_kill(HANDLE Hand, int Sig)
+int pthread_kill(HANDLE Hand, int Sig __attribute__((unused)))
 {
   if (!TerminateThread(Hand, 0))
     return -1;
@@ -486,7 +461,7 @@
   return 0;
 }
 
-int pthread_mutex_init(HANDLE *Hand, void *Attr)
+int pthread_mutex_init(HANDLE *Hand, void *Attr __attribute__((unused)))
 {
   *Hand = CreateMutex(NULL, FALSE, NULL);
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/dyn_gw/src/olsrd_dyn_gw.h olsrd-current/lib/dyn_gw/src/olsrd_dyn_gw.h
--- olsrd-0.5.0/lib/dyn_gw/src/olsrd_dyn_gw.h	2005-05-29 14:47:40.000000000 +0200
+++ olsrd-current/lib/dyn_gw/src/olsrd_dyn_gw.h	2007-04-20 16:06:18.000000000 +0200
@@ -37,7 +37,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_dyn_gw.h,v 1.11 2005/05/29 12:47:40 br1 Exp $
+ * $Id: olsrd_dyn_gw.h,v 1.12 2007/04/20 14:06:18 bernd67 Exp $
  */
 
 #ifndef _OLSRD_PLUGIN_TEST
@@ -50,13 +50,13 @@
 
 #define PROCENTRY_ROUTE "/proc/net/route"
 
-/* Timeout function to register with the scheduler */
-void
-olsr_timeout(void);
+int
+olsrd_plugin_init(void);
 
+int 
+olsrd_plugin_interface_version(void);
 
-/* Event function to register with the scheduler */
-void
-olsr_event_doing_hna(void *);
+int
+olsrd_plugin_register_param(char *key, char *value);
 
 #endif
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/dyn_gw/src/olsrd_plugin.c olsrd-current/lib/dyn_gw/src/olsrd_plugin.c
--- olsrd-0.5.0/lib/dyn_gw/src/olsrd_plugin.c	2005-05-29 14:47:40.000000000 +0200
+++ olsrd-current/lib/dyn_gw/src/olsrd_plugin.c	2007-04-20 16:19:44.000000000 +0200
@@ -37,10 +37,11 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_plugin.c,v 1.12 2005/05/29 12:47:40 br1 Exp $
+ * $Id: olsrd_plugin.c,v 1.14 2007/04/20 14:19:44 bernd67 Exp $
  */
 
 #include "olsrd_plugin.h"
+#include "olsrd_dyn_gw.h"
 #include <stdio.h>
 
 #define PLUGIN_NAME    "OLSRD dynamic gateway plugin"
@@ -64,7 +65,7 @@
  * Do not alter unless you know what you are doing!
  */
 int 
-olsrd_plugin_interface_version()
+olsrd_plugin_interface_version(void)
 {
   return PLUGIN_INTERFACE_VERSION;
 }
@@ -74,7 +75,7 @@
  *Constructor
  */
 void
-my_init()
+my_init(void)
 {
   /* Print plugin info to stdout */
   printf("%s\n", MOD_DESC);
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/dyn_gw_plain/src/olsrd_dyn_gw_plain.c olsrd-current/lib/dyn_gw_plain/src/olsrd_dyn_gw_plain.c
--- olsrd-0.5.0/lib/dyn_gw_plain/src/olsrd_dyn_gw_plain.c	2007-02-04 21:47:50.000000000 +0100
+++ olsrd-current/lib/dyn_gw_plain/src/olsrd_dyn_gw_plain.c	2007-04-20 16:06:18.000000000 +0200
@@ -58,7 +58,7 @@
  * Used by main olsrd to check plugin interface version
  */
 int 
-olsrd_plugin_interface_version()
+olsrd_plugin_interface_version(void)
 {
   return OLSRD_PLUGIN_INTERFACE_VERSION;
 }
@@ -68,7 +68,7 @@
  * Called for all plugin parameters
  */
 int
-olsrd_plugin_register_param(char *key, char *value)
+olsrd_plugin_register_param(char *key __attribute__((unused)), char *value __attribute__((unused)))
 {
   return 1;
 }
@@ -78,7 +78,7 @@
  * Called after all parameters are passed
  */
 int
-olsrd_plugin_init()
+olsrd_plugin_init(void)
 {
   gw_net.v4 = INET_NET;
   gw_netmask.v4 = INET_PREFIX;
@@ -167,7 +167,7 @@
  * Scheduled event to update the hna table,
  * called from olsrd main thread to keep the hna table thread-safe
  */
-void olsr_event(void* foo)
+void olsr_event(void* foo __attribute__((unused)))
 {
   int res = check_gw(&gw_net, &gw_netmask);
   if (1 == res && 0 == has_inet_gateway) {
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/httpinfo/src/admin_interface.c olsrd-current/lib/httpinfo/src/admin_interface.c
--- olsrd-0.5.0/lib/httpinfo/src/admin_interface.c	2006-09-18 20:55:30.000000000 +0200
+++ olsrd-current/lib/httpinfo/src/admin_interface.c	2007-04-20 16:06:18.000000000 +0200
@@ -37,7 +37,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: admin_interface.c,v 1.7 2006/09/18 18:55:30 kattemat Exp $
+ * $Id: admin_interface.c,v 1.8 2007/04/20 14:06:18 bernd67 Exp $
  */
 
 /*
@@ -45,26 +45,32 @@
  */
 
 
+#include "olsr.h"
 #include "olsrd_httpinfo.h"
 #include "olsr_cfg.h"
 #include "admin_html.h"
 #include "admin_interface.h"
+#include "local_hna_set.h" /* add_local_hna4_entry() */
+
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 
+#if 0
 extern int netsprintf(char *str, const char* format, ...);
 #define sprintf netsprintf
 #define NETDIRECT
+#endif
+
 
 int
-build_admin_body(char *buf, olsr_u32_t bufsize)
+build_admin_body(char *buf, olsr_u32_t bufsize __attribute__((unused)))
 {
   int size = 0, i = 0;
 
   while(admin_frame[i] && strcmp(admin_frame[i], "<!-- BASICSETTINGS -->\n"))
     {
-      size += sprintf(&buf[size], admin_frame[i]);
+      size += snprintf(&buf[size], bufsize-size, admin_frame[i]);
       i++;
     }
   
@@ -72,69 +78,69 @@
     return size;
 
 
-  size += sprintf(&buf[size], "<tr>\n");
+  size += snprintf(&buf[size], bufsize-size, "<tr>\n");
 
-  size += sprintf(&buf[size], admin_basic_setting_int,
+  size += snprintf(&buf[size], bufsize-size, admin_basic_setting_int,
 		  "Debug level:", "debug_level", 2, olsr_cnf->debug_level);
-  size += sprintf(&buf[size], admin_basic_setting_float,
+  size += snprintf(&buf[size], bufsize-size, admin_basic_setting_float,
 		  "Pollrate:", "pollrate", 4, olsr_cnf->pollrate);
-  size += sprintf(&buf[size], admin_basic_setting_string,
+  size += snprintf(&buf[size], bufsize-size, admin_basic_setting_string,
 		  "TOS:", "tos", 6, "TBD");
 
-  size += sprintf(&buf[size], "</tr>\n");
-  size += sprintf(&buf[size], "<tr>\n");
+  size += snprintf(&buf[size], bufsize-size, "</tr>\n");
+  size += snprintf(&buf[size], bufsize-size, "<tr>\n");
 
-  size += sprintf(&buf[size], admin_basic_setting_int,
+  size += snprintf(&buf[size], bufsize-size, admin_basic_setting_int,
 		  "TC redundancy:", "tc_redundancy", 1, olsr_cnf->tc_redundancy);
-  size += sprintf(&buf[size], admin_basic_setting_int,
+  size += snprintf(&buf[size], bufsize-size, admin_basic_setting_int,
 		  "MPR coverage:", "mpr_coverage", 1, olsr_cnf->mpr_coverage);
-  size += sprintf(&buf[size], admin_basic_setting_int,
+  size += snprintf(&buf[size], bufsize-size, admin_basic_setting_int,
 		  "Willingness:", "willingness", 1, olsr_cnf->willingness);
 
-  size += sprintf(&buf[size], "</tr>\n");
-  size += sprintf(&buf[size], "<tr>\n");
+  size += snprintf(&buf[size], bufsize-size, "</tr>\n");
+  size += snprintf(&buf[size], bufsize-size, "<tr>\n");
 
   if(olsr_cnf->use_hysteresis)
     {
-      size += sprintf(&buf[size], admin_basic_setting_float,
+      size += snprintf(&buf[size], bufsize-size, admin_basic_setting_float,
 		      "Hyst scaling:", "hyst_scaling", 4, olsr_cnf->hysteresis_param.scaling);
 
-      size += sprintf(&buf[size], admin_basic_setting_float,
+      size += snprintf(&buf[size], bufsize-size, admin_basic_setting_float,
 		      "Lower thr:", "hyst_lower", 4, olsr_cnf->hysteresis_param.thr_low);
-      size += sprintf(&buf[size], admin_basic_setting_float,
+      size += snprintf(&buf[size], bufsize-size, admin_basic_setting_float,
 		      "Upper thr:", "hyst_upper", 4, olsr_cnf->hysteresis_param.thr_high);
     }
   else
     {
-      size += sprintf(&buf[size], "<td>Hysteresis disabled</td>\n");
+      size += snprintf(&buf[size], bufsize-size, "<td>Hysteresis disabled</td>\n");
     }
 
-  size += sprintf(&buf[size], "</tr>\n");
-  size += sprintf(&buf[size], "<tr>\n");
+  size += snprintf(&buf[size], bufsize-size, "</tr>\n");
+  size += snprintf(&buf[size], bufsize-size, "<tr>\n");
   
   if(olsr_cnf->lq_level)
     {
-      size += sprintf(&buf[size], admin_basic_setting_int,
+      size += snprintf(&buf[size], bufsize-size, admin_basic_setting_int,
 		      "LQ level:", "lq_level", 1, olsr_cnf->lq_level);
-      size += sprintf(&buf[size], admin_basic_setting_int,
+      size += snprintf(&buf[size], bufsize-size, admin_basic_setting_int,
 		      "LQ winsize:", "lq_wsize", 2, olsr_cnf->lq_wsize);
     }
   else
     {
-      size += sprintf(&buf[size], "<td>LQ disabled</td>\n");
+      size += snprintf(&buf[size], bufsize-size, "<td>LQ disabled</td>\n");
     }
 
 
-  size += sprintf(&buf[size], "</tr>\n");
-  size += sprintf(&buf[size], "<tr>\n");
+  size += snprintf(&buf[size], bufsize-size, "</tr>\n");
+  size += snprintf(&buf[size], bufsize-size, "<tr>\n");
 
-  size += sprintf(&buf[size], "</tr>\n");
+  size += snprintf(&buf[size], bufsize-size, "</tr>\n");
   
   i++;
 
   while(admin_frame[i] && strcmp(admin_frame[i], "<!-- HNAENTRIES -->\n"))
     {
-      size += sprintf(&buf[size], admin_frame[i]);
+      size += snprintf(&buf[size], bufsize-size, admin_frame[i]);
       i++;
     }
 
@@ -149,7 +155,7 @@
       
       for(hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next)
 	{
-	  size += sprintf(&buf[size], admin_frame[i], 
+	  size += snprintf(&buf[size], bufsize-size, admin_frame[i], 
 			  olsr_ip_to_string((union olsr_ip_addr *)&hna4->net),
 			  olsr_ip_to_string((union olsr_ip_addr *)&hna4->netmask),
 			  olsr_ip_to_string((union olsr_ip_addr *)&hna4->net),
@@ -162,7 +168,7 @@
 	
       for(hna6 = olsr_cnf->hna6_entries; hna6; hna6 = hna6->next)
 	{
-	  size += sprintf(&buf[size], admin_frame[i], 
+	  size += snprintf(&buf[size], bufsize-size, admin_frame[i], 
 			  olsr_ip_to_string((union olsr_ip_addr *)&hna6->net),
 			  "TBD"/*hna6->prefix_len*/);
 	}
@@ -172,7 +178,7 @@
 
   while(admin_frame[i])
     {
-      size += sprintf(&buf[size], admin_frame[i]);
+      size += snprintf(&buf[size], bufsize-size, admin_frame[i]);
       i++;
     }
   
@@ -334,7 +340,7 @@
 	  return -1;
 	}
       add_local_hna4_entry((union olsr_ip_addr *)&curr_hna_net,
-			   (union hna_netmask *)&in.s_addr);
+			   (union olsr_ip_addr *)&in.s_addr);
       
       return 1;
     }
@@ -366,7 +372,7 @@
 	}
 
       remove_local_hna4_entry((union olsr_ip_addr *)&net.s_addr,
-			      (union hna_netmask *)&mask.s_addr);
+			      (union olsr_ip_addr *)&mask.s_addr);
 
       return 1;
     }
@@ -378,10 +384,11 @@
 }
 
 int
-process_set_values(char *data, olsr_u32_t data_size, char *buf, olsr_u32_t bufsize)
+process_set_values(char *data, olsr_u32_t data_size, char *buf, olsr_u32_t bufsize __attribute__((unused)))
 {
   int size = 0;
-  int i, val_start, key_start;
+  int val_start, key_start;
+  olsr_u32_t i;
 
   printf("Dynamic Data: %s\n", data);
 
@@ -403,7 +410,7 @@
 	  data[i] = '\0';
 	  if(!process_param(&data[key_start], &data[val_start]))
 	    {
-	      size += sprintf(&buf[size], "<h2>FAILED PROCESSING!</h2><br>Key: %s Value: %s<br>\n", 
+	      size += snprintf(&buf[size], bufsize-size, "<h2>FAILED PROCESSING!</h2><br>Key: %s Value: %s<br>\n", 
 			      &data[key_start], &data[val_start]);
 	      return -1;
 	    }
@@ -416,7 +423,7 @@
 
   if(!process_param(&data[key_start], &data[val_start]))
     {
-      size += sprintf(&buf[size], "<b>FAILED PROCESSING!</b><br>Key: %s Value: %s<br>\n", 
+      size += snprintf(&buf[size], bufsize-size, "<b>FAILED PROCESSING!</b><br>Key: %s Value: %s<br>\n", 
 		      &data[key_start], &data[val_start]);
       return -1;
     }
@@ -424,8 +431,8 @@
   printf("Key: %s\nValue: %s\n", 
 	 &data[key_start], &data[val_start]);
 
-  size += sprintf(&buf[size], "<h2>UPDATE SUCESSFULL!</h2><br>Press BACK and RELOAD in your browser to return to the plugin<br>\n</body>\n</html>\n");
-  size += sprintf(&buf[size], "\n</body>\n</html>\n");
+  size += snprintf(&buf[size], bufsize-size, "<h2>UPDATE SUCESSFULL!</h2><br>Press BACK and RELOAD in your browser to return to the plugin<br>\n</body>\n</html>\n");
+  size += snprintf(&buf[size], bufsize-size, "\n</body>\n</html>\n");
 
   return size;
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/httpinfo/src/olsrd_httpinfo.c olsrd-current/lib/httpinfo/src/olsrd_httpinfo.c
--- olsrd-0.5.0/lib/httpinfo/src/olsrd_httpinfo.c	2007-02-04 23:37:36.000000000 +0100
+++ olsrd-current/lib/httpinfo/src/olsrd_httpinfo.c	2007-05-17 13:25:27.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_httpinfo.c,v 1.61 2007/02/04 22:37:36 bernd67 Exp $
+ * $Id: olsrd_httpinfo.c,v 1.67 2007/05/17 11:25:27 bernd67 Exp $
  */
 
 /*
@@ -49,6 +49,9 @@
 #include <stdarg.h>
 #include <unistd.h>
 #include <errno.h>
+#ifndef WIN32
+#include <netdb.h>
+#endif
 
 #include "olsr.h"
 #include "olsr_cfg.h"
@@ -86,11 +89,11 @@
 
 #define MAX_CLIENTS 3
 
-#define MAX_HTTPREQ_SIZE 1024 * 10
+#define MAX_HTTPREQ_SIZE (1024 * 10)
 
 #define DEFAULT_TCP_PORT 1978
 
-#define HTML_BUFSIZE 1024*75
+#define HTML_BUFSIZE (1024 * 200)
 
 #define FRAMEWIDTH 800
 
@@ -131,10 +134,10 @@
 static int
 get_http_socket(int);
 
-int
-build_tabs(char *, int);
+static int
+build_tabs(char *, olsr_u32_t, int);
 
-void
+static void
 parse_http_request(int);
 
 int
@@ -180,8 +183,13 @@
 olsr_bool
 check_allowed_ip(union olsr_ip_addr *);
 
-static char *
-get_copyright_string(void);
+
+static int
+build_ip_txt(char *buf, const olsr_u32_t bufsize, const olsr_bool want_link, const char * const ipstr, const char  * const maskstr);
+static int
+build_ipaddr_link(char *buf, const olsr_u32_t bufsize, const olsr_bool want_link, union olsr_ip_addr * const ipaddr, const union hna_netmask * const mask);
+
+static ssize_t writen(int fd, const void *buf, size_t count);
 
 static struct timeval start_time;
 static struct http_stats stats;
@@ -189,14 +197,15 @@
 static int curr_clients;
 static int http_socket;
 
-int netsprintf(char *str, const char* format, ...);
+#if 0
+int netsprintf(char *str, const char* format, ...) __attribute__((format(printf, 2, 3)));
 static int netsprintf_direct = 0;
 static int netsprintf_error = 0;
 #define sprintf netsprintf
 #define NETDIRECT
+#endif
 
-
-struct tab_entry tab_entries[] =
+static const struct tab_entry tab_entries[] =
   {
     {"Configuration", "config", build_config_body, OLSR_TRUE},
     {"Routes", "routes", build_routes_body, OLSR_TRUE},
@@ -207,10 +216,10 @@
 #endif
     {"About", "about", build_about_body, OLSR_TRUE},
     {"FOO", "cfgfile", build_cfgfile_body, OLSR_FALSE},
-    {NULL, NULL, NULL}
+    {NULL, NULL, NULL, OLSR_FALSE}
   };
 
-struct static_bin_file_entry static_bin_files[] =
+static const struct static_bin_file_entry static_bin_files[] =
   {
     {"favicon.ico", favicon_ico, 1406/*favicon_ico_len*/},
     {"logo.gif", logo_gif, 2801/*logo_gif_len*/},
@@ -218,14 +227,14 @@
     {NULL, NULL, 0}
   };
 
-struct static_txt_file_entry static_txt_files[] =
+static const struct static_txt_file_entry static_txt_files[] =
   {
     {"httpinfo.css", httpinfo_css},
     {NULL, NULL}
   };
 
 
-struct dynamic_file_entry dynamic_files[] =
+static const struct dynamic_file_entry dynamic_files[] =
   {
 #ifdef ADMIN_INTERFACE
     {"set_values", process_set_values},
@@ -240,9 +249,9 @@
  *function in uolsrd_plugin.c
  */
 int
-olsrd_plugin_init()
+olsrd_plugin_init(void)
 {
-  get_copyright_string();
+  (void)copyright_string;
   /* Get start time */
   gettimeofday(&start_time, NULL);
 
@@ -403,7 +412,7 @@
 	      printf("Dynamic read %d bytes\n", param_size);
 	      
 	      //memcpy(body, dynamic_files[i].data, static_bin_files[i].data_size);
-	      size += dynamic_files[i].process_data_cb(req, param_size, &body[size], HTML_BUFSIZE - size);
+	      size += dynamic_files[i].process_data_cb(req, param_size, &body[size], sizeof(body)-size);
 	      c = build_http_header(HTTP_OK, OLSR_TRUE, size, req, MAX_HTTPREQ_SIZE);  
 	      goto send_http_data;
 	    }
@@ -491,12 +500,12 @@
 	      y++;
 	    }
 	  
-	  size += build_tabs(&body[size], i);
+	  size += build_tabs(&body[size], sizeof(body)-size, i);
 	  size += build_frame("Current Routes", 
 			      "routes", 
 			      FRAMEWIDTH, 
 			      &body[size], 
-			      HTML_BUFSIZE - size, 
+			      sizeof(body)-size, 
 			      tab_entries[i].build_body_cb);
 	  
 	  stats.ok_hits++;
@@ -533,14 +542,14 @@
 
  send_http_data:
   
-  r = send(client_sockets[curr_clients], req, c, 0);   
+  r = writen(client_sockets[curr_clients], req, c);   
   if(r < 0)
     {
       olsr_printf(1, "(HTTPINFO) Failed sending data to client!\n");
       goto close_connection;
     }
 
-  r = send(client_sockets[curr_clients], body, size, 0);
+  r = writen(client_sockets[curr_clients], body, size);
   if(r < 0)
     {
       olsr_printf(1, "(HTTPINFO) Failed sending data to client!\n");
@@ -557,85 +566,72 @@
 int
 build_http_header(http_header_type type, 
 		  olsr_bool is_html, 
-		  olsr_u32_t size, 
+		  olsr_u32_t msgsize, 
 		  char *buf, 
 		  olsr_u32_t bufsize)
 {
   time_t currtime;
-  char timestr[45];
-  char tmp[30];
-
-  memset(buf, 0, bufsize);
+  const char *h;
+  int size;
 
-  switch(type)
-    {
-    case(HTTP_BAD_REQ):
-      memcpy(buf, HTTP_400, strlen(HTTP_400));
+  switch(type) {
+  case(HTTP_BAD_REQ):
+      h = HTTP_400;
       break;
-    case(HTTP_BAD_FILE):
-      memcpy(buf, HTTP_404, strlen(HTTP_404));
+  case(HTTP_BAD_FILE):
+      h = HTTP_404;
       break;
-    default:
+  default:
       /* Defaults to OK */
-      memcpy(buf, HTTP_200, strlen(HTTP_200));
+      h = HTTP_200;
       break;
-    }
-
+  }
+  size = snprintf(buf, bufsize, "%s", h);
 
   /* Date */
-  if(time(&currtime))
-    {
-      strftime(timestr, 45, "Date: %a, %d %b %Y %H:%M:%S GMT\r\n", localtime(&currtime));
-      strcat(buf, timestr);
-    }
+  time(&currtime);
+  size += strftime(&buf[size], bufsize-size, "Date: %a, %d %b %Y %H:%M:%S GMT\r\n", localtime(&currtime));
   
   /* Server version */
-  strcat(buf, "Server: " PLUGIN_NAME " " PLUGIN_VERSION " " HTTP_VERSION "\r\n");
+  size += snprintf(&buf[size], bufsize-size, "Server: %s %s %s\r\n", PLUGIN_NAME, PLUGIN_VERSION, HTTP_VERSION);
 
   /* connection-type */
-  strcat(buf,"Connection: closed\r\n");
+  size += snprintf(&buf[size], bufsize-size, "Connection: closed\r\n");
 
   /* MIME type */
-  if(is_html)
-    strcat(buf, "Content-type: text/html\r\n");
-  else
-    strcat(buf, "Content-type: text/plain\r\n");
+  size += snprintf(&buf[size], bufsize-size, "Content-type: text/%s\r\n", is_html ? "html" : "plain");
 
   /* Content length */
-  if(size > 0)
-    {
-      snprintf(tmp, sizeof(tmp), "Content-length: %i\r\n", size);
-      strcat(buf, tmp);
-    }
-
+  if(msgsize > 0) {
+      size += snprintf(&buf[size], bufsize-size, "Content-length: %i\r\n", msgsize);
+  }
 
   /* Cache-control 
    * No caching dynamic pages
    */
-  strcat(buf, "Cache-Control: no-cache\r\n");
-
-  if(!is_html)
-    strcat(buf, "Accept-Ranges: bytes\r\n");
+  size += snprintf(&buf[size], bufsize-size, "Cache-Control: no-cache\r\n");
 
+  if(!is_html) {
+    size += snprintf(&buf[size], bufsize-size, "Accept-Ranges: bytes\r\n");
+  }
   /* End header */
-  strcat(buf, "\r\n");
+  size += snprintf(&buf[size], bufsize-size, "\r\n");
   
   olsr_printf(1, "HEADER:\n%s", buf);
 
-  return strlen(buf);
-
+  return size;
 }
 
 
 
 int 
-build_tabs(char *buf, int active)
+build_tabs(char *buf, const olsr_u32_t bufsize, int active)
 {
   int size = 0, i = 0, tabs = 0;
 
   while(strcmp(html_tabs[i], "<!-- TAB ELEMENTS -->"))
     {
-      size += sprintf(&buf[size], html_tabs[i]);
+      size += snprintf(&buf[size], bufsize-size, html_tabs[i]);
       i++;
     }
 
@@ -647,13 +643,13 @@
 	continue;
 
       if(tabs == active)
-	size += sprintf(&buf[size], 
+	size += snprintf(&buf[size], bufsize-size, 
 			html_tabs[i], 
 			tab_entries[tabs].filename, 
 			ACTIVE_TAB, 
 			tab_entries[tabs].tab_label);
       else
-	size += sprintf(&buf[size], 
+	size += snprintf(&buf[size], bufsize-size, 
 			html_tabs[i], 
 			tab_entries[tabs].filename, 
 			" ", 
@@ -663,7 +659,7 @@
   i++;      
   while(html_tabs[i])
     {
-      size += sprintf(&buf[size], html_tabs[i]);
+      size += snprintf(&buf[size], bufsize-size, html_tabs[i]);
       i++;
     }
   
@@ -675,7 +671,7 @@
  * destructor - called at unload
  */
 void
-olsr_plugin_exit()
+olsr_plugin_exit(void)
 {
   if(http_socket)
     close(http_socket);
@@ -683,9 +679,9 @@
 
 
 static int
-build_frame(char *title, 
-	    char *link, 
-	    int width,
+build_frame(char *title __attribute__((unused)), 
+	    char *link __attribute__((unused)), 
+	    int width __attribute__((unused)),
 	    char *buf,
 	    olsr_u32_t bufsize, 
 	    int(*frame_body_cb)(char *, olsr_u32_t))
@@ -695,9 +691,9 @@
   while(http_frame[i])
     {
       if(!strcmp(http_frame[i], "<!-- BODY -->"))
-	size += frame_body_cb(&buf[size], bufsize - size);
+	size += frame_body_cb(&buf[size], bufsize-size);
       else
-	size += sprintf(&buf[size], http_frame[i]);      
+	size += snprintf(&buf[size], bufsize-size, "%s", http_frame[i]);      
 
       i++;
     }
@@ -705,7 +701,67 @@
   return size;
 }
 
+static int
+build_ip_txt(char *buf, const olsr_u32_t bufsize, const olsr_bool want_link, const char * const ipstr, const char  * const maskstr)
+{
+  int size = 0;
+  if (want_link && maskstr == NULL) { /* Print the link only if there is not netmask */
+    size += snprintf(&buf[size],
+                     bufsize-size,
+                     "<a href=\"http://%s:%d/all\">",
+                     ipstr,
+                     http_port);
+  }
+  size += snprintf(&buf[size], bufsize-size, "%s", ipstr);
+  if (maskstr) {
+    size += snprintf(&buf[size], bufsize-size, "/%s", maskstr);
+  }
+  if (want_link && maskstr == NULL) { /* Print the link only if there is not netmask */
+    size += snprintf(&buf[size], bufsize-size, "</a>");
+  }
+  return size;
+}
 
+static int
+build_ipaddr_link(char *buf, const olsr_u32_t bufsize, const olsr_bool want_link, union olsr_ip_addr * const ipaddr, const union hna_netmask * const mask)
+{
+  int size = 0;
+  char maskbuf[32];
+  char *maskstr;
+  const struct hostent * const hp =
+#ifndef WIN32
+                                    resolve_ip_addresses ? gethostbyaddr(ipaddr, olsr_cnf->ipsize, olsr_cnf->ip_version) :
+#endif
+                                        NULL;
+  if (mask != NULL) {
+    if (olsr_cnf->ip_version == AF_INET) {
+      if (mask->v4 == ~0U) {
+        maskstr = NULL;
+      } else {
+        struct in_addr in;
+        in.s_addr = mask->v4;
+        snprintf(maskbuf, sizeof(maskbuf), "%s", inet_ntoa(in));
+        maskstr = maskbuf;
+      }
+    } else {
+      snprintf(maskbuf, sizeof(maskbuf), "%d", mask->v6);
+      maskstr = maskbuf;
+    }
+  } else {
+    maskstr =  NULL;
+  }
+  size += snprintf(&buf[size], bufsize-size, "<td%s>", resolve_ip_addresses && hp ? "" : " colspan=\"2\"");
+  size += build_ip_txt(&buf[size], bufsize-size, want_link, olsr_ip_to_string(ipaddr), maskstr);
+  if (hp) {
+    size += snprintf(&buf[size], bufsize-size, "</td><td>(");
+    size += build_ip_txt(&buf[size], bufsize-size, want_link, hp->h_name, NULL);
+    size += snprintf(&buf[size], bufsize-size, ")");
+  }
+  size += snprintf(&buf[size], bufsize-size, "</td>");
+  return size;
+}
+#define build_ipaddr_with_link(buf, bufsize, ipaddr, mask) build_ipaddr_link((buf), (bufsize), OLSR_TRUE, (ipaddr), (mask))
+#define build_ipaddr_no_link(buf, bufsize, ipaddr, mask)   build_ipaddr_link((buf), (bufsize), OLSR_FALSE, (ipaddr), (mask))
 
 int
 build_routes_body(char *buf, olsr_u32_t bufsize)
@@ -713,12 +769,13 @@
   int size = 0, index;
   struct rt_entry *routes;
 
-  size += sprintf(&buf[size], "<h2>OLSR routes in kernel</h2>\n");
+  size += snprintf(&buf[size], bufsize-size, "<h2>OLSR routes in kernel</h2>\n");
 
-  size += sprintf(&buf[size], "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Destination</th><th>Gateway</th><th>Metric</th>");
+  size += snprintf(&buf[size], bufsize-size, "<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\"><tr><th%s>Destination</th><th>Gateway</th><th>Metric</th>",
+                  resolve_ip_addresses ? " colspan=\"2\"" : "");
   if (olsr_cnf->lq_level > 0)
-    size += sprintf(&buf[size], "<th>ETX</th>");
-  size += sprintf(&buf[size], "<th>Interface</th><th>Type</th></tr>\n");
+    size += snprintf(&buf[size], bufsize-size, "<th>ETX</th>");
+  size += snprintf(&buf[size], bufsize-size, "<th>Interface</th><th>Type</th></tr>\n");
 
   /* Neighbors */
   for(index = 0;index < HASHSIZE;index++)
@@ -727,20 +784,14 @@
 	  routes != &routingtable[index];
 	  routes = routes->next)
 	{
-	  size += sprintf(&buf[size],
-                         "<tr><td><a href=\"http://%s:%d/all\">%s</a></td>"
-                         "<td><a href=\"http://%s:%d/all\">%s</a></td>"
-                         "<td>%d</td>",
-                         olsr_ip_to_string(&routes->rt_dst),
-                         http_port,
-                         olsr_ip_to_string(&routes->rt_dst),
-                         olsr_ip_to_string(&routes->rt_router),
-                         http_port,
-                         olsr_ip_to_string(&routes->rt_router),
-                         routes->rt_metric);
+          size += snprintf(&buf[size], bufsize-size, "<tr>");
+	  size += build_ipaddr_with_link(&buf[size], bufsize-size, &routes->rt_dst, NULL);
+	  size += build_ipaddr_with_link(&buf[size], bufsize-size, &routes->rt_router, NULL);
+
+	  size += snprintf(&buf[size], bufsize-size, "<td align=\"right\">%d</td>", routes->rt_metric);
           if (olsr_cnf->lq_level > 0)
-	    size += sprintf(&buf[size], "<td>%.2f</td>", routes->rt_etx);
-	  size += sprintf(&buf[size],
+            size += snprintf(&buf[size], bufsize-size, "<td align=\"right\">%.2f</td>", routes->rt_etx);
+	  size += snprintf(&buf[size], bufsize-size,
                          "<td>%s</td>"
                          "<td>HOST</td></tr>\n",
                          routes->rt_if->int_name);
@@ -754,25 +805,22 @@
 	  routes != &hna_routes[index];
 	  routes = routes->next)
 	{
-	  size += sprintf(&buf[size],
-                         "<tr><td>%s</td>"
-                         "<td><a href=\"http://%s:%d/all\">%s</a></td>"
-                         "<td>%d</td>",
-                         olsr_ip_to_string(&routes->rt_dst),
-                         olsr_ip_to_string(&routes->rt_router),
-                         http_port,
-                         olsr_ip_to_string(&routes->rt_router),
+          size += snprintf(&buf[size], bufsize-size, "<tr>");
+	  size += build_ipaddr_with_link(&buf[size], bufsize-size, &routes->rt_dst, &routes->rt_mask);
+	  size += build_ipaddr_with_link(&buf[size], bufsize-size, &routes->rt_router, NULL);
+	  size += snprintf(&buf[size], bufsize-size,
+                         "<td align=\"right\">%d</td>",
                          routes->rt_metric);
           if (olsr_cnf->lq_level > 0)
-	    size += sprintf(&buf[size], "<td>%.2f</td>", routes->rt_etx);
-	  size += sprintf(&buf[size],
+	    size += snprintf(&buf[size], bufsize-size, "<td align=\"right\">%.2f</td>", routes->rt_etx);
+	  size += snprintf(&buf[size], bufsize-size,
                          "<td>%s</td>"
                          "<td>HNA</td></tr>\n",
                          routes->rt_if->int_name);
 	}
     }
 
-  size += sprintf(&buf[size], "</table>\n");
+  size += snprintf(&buf[size], bufsize-size, "</table>\n");
 
   return size;
 }
@@ -802,169 +850,169 @@
     strftime(systime, 100, "System time: <i>%a, %d %b %Y %H:%M:%S</i><br>", localtime(&currtime));
 
 
-    size += sprintf(&buf[size], "OS: %s\n<br>", OS);
+    size += snprintf(&buf[size], bufsize-size, "OS: %s\n<br>", OS);
 
-    size += sprintf(&buf[size], "%s\n", systime);
+    size += snprintf(&buf[size], bufsize-size, "%s\n", systime);
 
     if(days)
-      size += sprintf(&buf[size], "Olsrd uptime: <i>%d day(s) %02d hours %02d minutes %02d seconds</i><br>\n", days, hours, mins, (int)uptime.tv_sec);
+      size += snprintf(&buf[size], bufsize-size, "Olsrd uptime: <i>%d day(s) %02d hours %02d minutes %02d seconds</i><br>\n", days, hours, mins, (int)uptime.tv_sec);
     else
-      size += sprintf(&buf[size], "Olsrd uptime: <i>%02d hours %02d minutes %02d seconds</i><br>\n", hours, mins, (int)uptime.tv_sec);
+      size += snprintf(&buf[size], bufsize-size, "Olsrd uptime: <i>%02d hours %02d minutes %02d seconds</i><br>\n", hours, mins, (int)uptime.tv_sec);
 
-    size += sprintf(&buf[size], "HTTP stats(ok/dyn/error/illegal): <i>%d/%d/%d/%d</i><br>\n", stats.ok_hits, stats.dyn_hits, stats.err_hits, stats.ill_hits);
+    size += snprintf(&buf[size], bufsize-size, "HTTP stats(ok/dyn/error/illegal): <i>%d/%d/%d/%d</i><br>\n", stats.ok_hits, stats.dyn_hits, stats.err_hits, stats.ill_hits);
 
-    size += sprintf(&buf[size], "Click <a href=\"/cfgfile\">here</a> to <i>generate a configuration file for this node</i>.\n");
+    size += snprintf(&buf[size], bufsize-size, "Click <a href=\"/cfgfile\">here</a> to <i>generate a configuration file for this node</i>.\n");
 
-    size += sprintf(&buf[size], "<h2>Variables</h2>\n");
+    size += snprintf(&buf[size], bufsize-size, "<h2>Variables</h2>\n");
 
-    size += sprintf(&buf[size], "<table width=\"100%%\" border=0>\n<tr>");
+    size += snprintf(&buf[size], bufsize-size, "<table width=\"100%%\" border=0>\n<tr>");
 
-    size += sprintf(&buf[size], "<td>Main address: <b>%s</b></td>\n", olsr_ip_to_string(&olsr_cnf->main_addr));
+    size += snprintf(&buf[size], bufsize-size, "<td>Main address: <b>%s</b></td>\n", olsr_ip_to_string(&olsr_cnf->main_addr));
     
-    size += sprintf(&buf[size], "<td>IP version: %d</td>\n", olsr_cnf->ip_version == AF_INET ? 4 : 6);
+    size += snprintf(&buf[size], bufsize-size, "<td>IP version: %d</td>\n", olsr_cnf->ip_version == AF_INET ? 4 : 6);
 
-    size += sprintf(&buf[size], "<td>Debug level: %d</td>\n", olsr_cnf->debug_level);
+    size += snprintf(&buf[size], bufsize-size, "<td>Debug level: %d</td>\n", olsr_cnf->debug_level);
 
-    size += sprintf(&buf[size], "</tr>\n<tr>\n");
+    size += snprintf(&buf[size], bufsize-size, "</tr>\n<tr>\n");
 
-    size += sprintf(&buf[size], "<td>Pollrate: %0.2f</td>\n", olsr_cnf->pollrate);
-    size += sprintf(&buf[size], "<td>TC redundancy: %d</td>\n", olsr_cnf->tc_redundancy);
-    size += sprintf(&buf[size], "<td>MPR coverage: %d</td>\n", olsr_cnf->mpr_coverage);
+    size += snprintf(&buf[size], bufsize-size, "<td>Pollrate: %0.2f</td>\n", olsr_cnf->pollrate);
+    size += snprintf(&buf[size], bufsize-size, "<td>TC redundancy: %d</td>\n", olsr_cnf->tc_redundancy);
+    size += snprintf(&buf[size], bufsize-size, "<td>MPR coverage: %d</td>\n", olsr_cnf->mpr_coverage);
 
 
-    size += sprintf(&buf[size], "</tr>\n<tr>\n");
+    size += snprintf(&buf[size], bufsize-size, "</tr>\n<tr>\n");
 
-    size += sprintf(&buf[size], "<td>Fisheye: %s</td>\n", olsr_cnf->lq_fish ? "Enabled" : "Disabled");
+    size += snprintf(&buf[size], bufsize-size, "<td>Fisheye: %s</td>\n", olsr_cnf->lq_fish ? "Enabled" : "Disabled");
 
-    size += sprintf(&buf[size], "<td>TOS: 0x%04x</td>\n", olsr_cnf->tos);
+    size += snprintf(&buf[size], bufsize-size, "<td>TOS: 0x%04x</td>\n", olsr_cnf->tos);
 
-    size += sprintf(&buf[size], "<td>Willingness: %d %s</td>\n", olsr_cnf->willingness, olsr_cnf->willingness_auto ? "(auto)" : "");
+    size += snprintf(&buf[size], bufsize-size, "<td>Willingness: %d %s</td>\n", olsr_cnf->willingness, olsr_cnf->willingness_auto ? "(auto)" : "");
     
-    size += sprintf(&buf[size], "</tr>\n<tr>\n");
+    size += snprintf(&buf[size], bufsize-size, "</tr>\n<tr>\n");
 
     if (olsr_cnf->lq_level == 0)
       {
-        size += sprintf(&buf[size], "<td>Hysteresis: %s</td>\n", olsr_cnf->use_hysteresis ? "Enabled" : "Disabled");
+        size += snprintf(&buf[size], bufsize-size, "<td>Hysteresis: %s</td>\n", olsr_cnf->use_hysteresis ? "Enabled" : "Disabled");
 	if (olsr_cnf->use_hysteresis)
           {
-            size += sprintf(&buf[size], "<td>Hyst scaling: %0.2f</td>\n", olsr_cnf->hysteresis_param.scaling);
-            size += sprintf(&buf[size], "<td>Hyst lower/upper: %0.2f/%0.2f</td>\n", olsr_cnf->hysteresis_param.thr_low, olsr_cnf->hysteresis_param.thr_high);
+            size += snprintf(&buf[size], bufsize-size, "<td>Hyst scaling: %0.2f</td>\n", olsr_cnf->hysteresis_param.scaling);
+            size += snprintf(&buf[size], bufsize-size, "<td>Hyst lower/upper: %0.2f/%0.2f</td>\n", olsr_cnf->hysteresis_param.thr_low, olsr_cnf->hysteresis_param.thr_high);
           }
       }
 
-    size += sprintf(&buf[size], "</tr>\n<tr>\n");
+    size += snprintf(&buf[size], bufsize-size, "</tr>\n<tr>\n");
 
-    size += sprintf(&buf[size], "<td>LQ extension: %s</td>\n", olsr_cnf->lq_level ? "Enabled" : "Disabled");
+    size += snprintf(&buf[size], bufsize-size, "<td>LQ extension: %s</td>\n", olsr_cnf->lq_level ? "Enabled" : "Disabled");
     if (olsr_cnf->lq_level)
       {
-        size += sprintf(&buf[size], "<td>LQ level: %d</td>\n", olsr_cnf->lq_level);
-        size += sprintf(&buf[size], "<td>LQ winsize: %d</td>\n", olsr_cnf->lq_wsize);
+        size += snprintf(&buf[size], bufsize-size, "<td>LQ level: %d</td>\n", olsr_cnf->lq_level);
+        size += snprintf(&buf[size], bufsize-size, "<td>LQ winsize: %d</td>\n", olsr_cnf->lq_wsize);
       }
 
-    size += sprintf(&buf[size], "</tr></table>\n");
+    size += snprintf(&buf[size], bufsize-size, "</tr></table>\n");
 
-    size += sprintf(&buf[size], "<h2>Interfaces</h2>\n");
+    size += snprintf(&buf[size], bufsize-size, "<h2>Interfaces</h2>\n");
 
 
-    size += sprintf(&buf[size], "<table width=\"100%%\" border=0>\n");
+    size += snprintf(&buf[size], bufsize-size, "<table width=\"100%%\" border=0>\n");
 
 
     for(ifs = olsr_cnf->interfaces; ifs; ifs = ifs->next)
       {
 	struct interface *rifs = ifs->interf;
 
-	size += sprintf(&buf[size], "<tr><th colspan=3>%s</th>\n", ifs->name);
+	size += snprintf(&buf[size], bufsize-size, "<tr><th colspan=3>%s</th>\n", ifs->name);
 	if(!rifs)
 	  {
-	    size += sprintf(&buf[size], "<tr><td colspan=3>Status: DOWN</td></tr>\n");
+	    size += snprintf(&buf[size], bufsize-size, "<tr><td colspan=3>Status: DOWN</td></tr>\n");
 	    continue;
 	  }
 	
 	if(olsr_cnf->ip_version == AF_INET)
 	  {
-	    size += sprintf(&buf[size], "<tr><td>IP: %s</td>\n", 
+	    size += snprintf(&buf[size], bufsize-size, "<tr><td>IP: %s</td>\n", 
 			    sockaddr_to_string(&rifs->int_addr));
-	    size += sprintf(&buf[size], "<td>MASK: %s</td>\n", 
+	    size += snprintf(&buf[size], bufsize-size, "<td>MASK: %s</td>\n", 
 			    sockaddr_to_string(&rifs->int_netmask));
-	    size += sprintf(&buf[size], "<td>BCAST: %s</td></tr>\n",
+	    size += snprintf(&buf[size], bufsize-size, "<td>BCAST: %s</td></tr>\n",
 			    sockaddr_to_string(&rifs->int_broadaddr));
-	    size += sprintf(&buf[size], "<tr><td>MTU: %d</td>\n", rifs->int_mtu);
-	    size += sprintf(&buf[size], "<td>WLAN: %s</td>\n", rifs->is_wireless ? "Yes" : "No");
-	    size += sprintf(&buf[size], "<td>STATUS: UP</td></tr>\n");
+	    size += snprintf(&buf[size], bufsize-size, "<tr><td>MTU: %d</td>\n", rifs->int_mtu);
+	    size += snprintf(&buf[size], bufsize-size, "<td>WLAN: %s</td>\n", rifs->is_wireless ? "Yes" : "No");
+	    size += snprintf(&buf[size], bufsize-size, "<td>STATUS: UP</td></tr>\n");
 	  }
 	else
 	  {
-	    size += sprintf(&buf[size], "<tr><td>IP: %s</td>\n", olsr_ip_to_string((union olsr_ip_addr *)&rifs->int6_addr.sin6_addr));
-	    size += sprintf(&buf[size], "<td>MCAST: %s</td>\n", olsr_ip_to_string((union olsr_ip_addr *)&rifs->int6_multaddr.sin6_addr));
-	    size += sprintf(&buf[size], "<td></td></tr>\n");
-	    size += sprintf(&buf[size], "<tr><td>MTU: %d</td>\n", rifs->int_mtu);
-	    size += sprintf(&buf[size], "<td>WLAN: %s</td>\n", rifs->is_wireless ? "Yes" : "No");
-	    size += sprintf(&buf[size], "<td>STATUS: UP</td></tr>\n");
+	    size += snprintf(&buf[size], bufsize-size, "<tr><td>IP: %s</td>\n", olsr_ip_to_string((union olsr_ip_addr *)&rifs->int6_addr.sin6_addr));
+	    size += snprintf(&buf[size], bufsize-size, "<td>MCAST: %s</td>\n", olsr_ip_to_string((union olsr_ip_addr *)&rifs->int6_multaddr.sin6_addr));
+	    size += snprintf(&buf[size], bufsize-size, "<td></td></tr>\n");
+	    size += snprintf(&buf[size], bufsize-size, "<tr><td>MTU: %d</td>\n", rifs->int_mtu);
+	    size += snprintf(&buf[size], bufsize-size, "<td>WLAN: %s</td>\n", rifs->is_wireless ? "Yes" : "No");
+	    size += snprintf(&buf[size], bufsize-size, "<td>STATUS: UP</td></tr>\n");
 	  }	    
       }
 
-    size += sprintf(&buf[size], "</table>\n");
+    size += snprintf(&buf[size], bufsize-size, "</table>\n");
 
     if(olsr_cnf->allow_no_interfaces)
-      size += sprintf(&buf[size], "<i>Olsrd is configured to run even if no interfaces are available</i><br>\n");
+      size += snprintf(&buf[size], bufsize-size, "<i>Olsrd is configured to run even if no interfaces are available</i><br>\n");
     else
-      size += sprintf(&buf[size], "<i>Olsrd is configured to halt if no interfaces are available</i><br>\n");
+      size += snprintf(&buf[size], bufsize-size, "<i>Olsrd is configured to halt if no interfaces are available</i><br>\n");
 
-    size += sprintf(&buf[size], "<h2>Plugins</h2>\n");
+    size += snprintf(&buf[size], bufsize-size, "<h2>Plugins</h2>\n");
 
-    size += sprintf(&buf[size], "<table width=\"100%%\" border=0><tr><th>Name</th><th>Parameters</th></tr>\n");
+    size += snprintf(&buf[size], bufsize-size, "<table width=\"100%%\" border=0><tr><th>Name</th><th>Parameters</th></tr>\n");
 
     for(pentry = olsr_cnf->plugins; pentry; pentry = pentry->next)
       {
-	size += sprintf(&buf[size], "<tr><td>%s</td>\n", pentry->name);
+	size += snprintf(&buf[size], bufsize-size, "<tr><td>%s</td>\n", pentry->name);
 
-	size += sprintf(&buf[size], "<td><select>\n");
-	size += sprintf(&buf[size], "<option>KEY, VALUE</option>\n");
+	size += snprintf(&buf[size], bufsize-size, "<td><select>\n");
+	size += snprintf(&buf[size], bufsize-size, "<option>KEY, VALUE</option>\n");
 
 	for(pparam = pentry->params; pparam; pparam = pparam->next)
 	  {
-	    size += sprintf(&buf[size], "<option>\"%s\", \"%s\"</option>\n",
+	    size += snprintf(&buf[size], bufsize-size, "<option>\"%s\", \"%s\"</option>\n",
 			    pparam->key,
 			    pparam->value);
 	  }
-	size += sprintf(&buf[size], "</select></td></tr>\n");
+	size += snprintf(&buf[size], bufsize-size, "</select></td></tr>\n");
 
       }
 
-    size += sprintf(&buf[size], "</table>\n");
+    size += snprintf(&buf[size], bufsize-size, "</table>\n");
 
 
     if((olsr_cnf->ip_version == AF_INET) && (olsr_cnf->hna4_entries))
       {
 	struct hna4_entry *hna4;
 	
-	size += sprintf(&buf[size], "<h2>Announced HNA entries</h2>\n");
-	size += sprintf(&buf[size], "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Network</th><th>Netmask</th></tr>\n");
+	size += snprintf(&buf[size], bufsize-size, "<h2>Announced HNA entries</h2>\n");
+	size += snprintf(&buf[size], bufsize-size, "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Network</th><th>Netmask</th></tr>\n");
 	
 	for(hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next)
 	  {
-	    size += sprintf(&buf[size], "<tr><td>%s</td><td>%s</td></tr>\n", 
+	    size += snprintf(&buf[size], bufsize-size, "<tr><td>%s</td><td>%s</td></tr>\n", 
 			    olsr_ip_to_string((union olsr_ip_addr *)&hna4->net),
 			    olsr_ip_to_string((union olsr_ip_addr *)&hna4->netmask));
 	  }
 	
-	size += sprintf(&buf[size], "</table>\n");
-      }
-    else if((olsr_cnf->ip_version == AF_INET6) && (olsr_cnf->hna6_entries))
+	size += snprintf(&buf[size], bufsize-size, "</table>\n");
+      } 
+   else if((olsr_cnf->ip_version == AF_INET6) && (olsr_cnf->hna6_entries))
       {
 	struct hna6_entry *hna6;
 	
-	size += sprintf(&buf[size], "<h2>Announced HNA entries</h2>\n");
-	size += sprintf(&buf[size], "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Network</th><th>Prefix length</th></tr>\n");
+	size += snprintf(&buf[size], bufsize-size, "<h2>Announced HNA entries</h2>\n");
+	size += snprintf(&buf[size], bufsize-size, "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Network</th><th>Prefix length</th></tr>\n");
 	
 	for(hna6 = olsr_cnf->hna6_entries; hna6; hna6 = hna6->next)
 	  {
-	    size += sprintf(&buf[size], "<tr><td>%s</td><td>%d</td></tr>\n", 
+	    size += snprintf(&buf[size], bufsize-size, "<tr><td>%s</td><td>%d</td></tr>\n", 
 			    olsr_ip_to_string((union olsr_ip_addr *)&hna6->net),
 			    hna6->prefix_len);
 	  }
 	
-	size += sprintf(&buf[size], "</table>\n");
+	size += snprintf(&buf[size], bufsize-size, "</table>\n");
       }
     
 
@@ -981,48 +1029,45 @@
   struct link_entry *link = NULL;
   int size = 0, index, thop_cnt;
 
-  size += sprintf(&buf[size], "<h2>Links</h2>\n");
-  size += sprintf(&buf[size], "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Local IP</th><th>remote IP</th><th>Hysteresis</th>\n");
+  size += snprintf(&buf[size], bufsize-size, "<h2>Links</h2>\n");
+  size += snprintf(&buf[size], bufsize-size, "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Local IP</th><th>Remote IP</th><th>Hysteresis</th>\n");
   if (olsr_cnf->lq_level > 0)
-    size += sprintf(&buf[size], "<th>LinkQuality</th><th>lost</th><th>total</th><th>NLQ</th><th>ETX</th>\n");
-  size += sprintf(&buf[size], "</tr>\n");
+    size += snprintf(&buf[size], bufsize-size, "<th>LinkQuality</th><th>lost</th><th>total</th><th>NLQ</th><th>ETX</th>\n");
+  size += snprintf(&buf[size], bufsize-size, "</tr>\n");
 
   /* Link set */
   link = link_set;
     while(link)
       {
-	size += sprintf(&buf[size],
-                       "<tr><td>%s</td>"
-                       "<td><a href=\"http://%s:%d/all\">%s</a></td>"
-                       "<td>%0.2f</td>",
-                       olsr_ip_to_string(&link->local_iface_addr),
-                       olsr_ip_to_string(&link->neighbor_iface_addr),
-                       http_port,
-                       olsr_ip_to_string(&link->neighbor_iface_addr),
+        size += snprintf(&buf[size], bufsize-size, "<tr>");
+        size += build_ipaddr_no_link(&buf[size], bufsize, &link->local_iface_addr, NULL);
+        size += build_ipaddr_with_link(&buf[size], bufsize, &link->neighbor_iface_addr, NULL);
+	size += snprintf(&buf[size], bufsize-size,
+                       "<td align=\"right\">%0.2f</td>",
                        link->L_link_quality);
         if (olsr_cnf->lq_level > 0)
           {
-	    size += sprintf(&buf[size],
-                           "<td>%0.2f</td>"
+	    size += snprintf(&buf[size], bufsize-size,
+                           "<td align=\"right\">%0.2f</td>"
                            "<td>%d</td>"
                            "<td>%d</td>"
-                           "<td>%0.2f</td>"
-                           "<td>%0.2f</td></tr>\n",
+                           "<td align=\"right\">%0.2f</td>"
+                           "<td align=\"right\">%0.2f</td></tr>\n",
                            link->loss_link_quality,
                            link->lost_packets, 
                            link->total_packets,
                            link->neigh_link_quality, 
                            (link->loss_link_quality * link->neigh_link_quality) ? 1.0 / (link->loss_link_quality * link->neigh_link_quality) : 0.0);
           }
-	size += sprintf(&buf[size], "</tr>\n");
+	size += snprintf(&buf[size], bufsize-size, "</tr>\n");
 
 	link = link->next;
       }
 
-  size += sprintf(&buf[size], "</table>\n");
+  size += snprintf(&buf[size], bufsize-size, "</table>\n");
 
-  size += sprintf(&buf[size], "<h2>Neighbors</h2>\n");
-  size += sprintf(&buf[size], "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>IP address</th><th>SYM</th><th>MPR</th><th>MPRS</th><th>Willingness</th><th>2 Hop Neighbors</th></tr>\n");
+  size += snprintf(&buf[size], bufsize-size, "<h2>Neighbors</h2>\n");
+  size += snprintf(&buf[size], bufsize-size, "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>IP address</th><th>SYM</th><th>MPR</th><th>MPRS</th><th>Willingness</th><th>2 Hop Neighbors</th></tr>\n");
   /* Neighbors */
   for(index=0;index<HASHSIZE;index++)
     {
@@ -1030,22 +1075,20 @@
 	  neigh != &neighbortable[index];
 	  neigh = neigh->next)
 	{
-	  size += sprintf(&buf[size], 
-			  "<tr><td><a href=\"http://%s:%d/all\">%s</a></td>"
+          size += snprintf(&buf[size], bufsize-size, "<tr>");
+          size += build_ipaddr_with_link(&buf[size], bufsize, &neigh->neighbor_main_addr, NULL);
+	  size += snprintf(&buf[size], bufsize-size, 
 			  "<td>%s</td>"
 			  "<td>%s</td>"
 			  "<td>%s</td>"
 			  "<td>%d</td>", 
-			  olsr_ip_to_string(&neigh->neighbor_main_addr),
-                          http_port,
-			  olsr_ip_to_string(&neigh->neighbor_main_addr),
 			  (neigh->status == SYM) ? "YES" : "NO",
 			  neigh->is_mpr ? "YES" : "NO",
 			  olsr_lookup_mprs_set(&neigh->neighbor_main_addr) ? "YES" : "NO",
 			  neigh->willingness);
 
-	  size += sprintf(&buf[size], "<td><select>\n");
-	  size += sprintf(&buf[size], "<option>IP ADDRESS</option>\n");
+	  size += snprintf(&buf[size], bufsize-size, "<td><select>\n");
+	  size += snprintf(&buf[size], bufsize-size, "<option>IP ADDRESS</option>\n");
 
 	  thop_cnt = 0;
 
@@ -1053,15 +1096,15 @@
 	      list_2 != &neigh->neighbor_2_list;
 	      list_2 = list_2->next)
 	    {
-	      size += sprintf(&buf[size], "<option>%s</option>\n", olsr_ip_to_string(&list_2->neighbor_2->neighbor_2_addr));
+              size += snprintf(&buf[size], bufsize-size, "<option>%s</option>", olsr_ip_to_string(&list_2->neighbor_2->neighbor_2_addr));
 	      thop_cnt ++;
 	    }
-	  size += sprintf(&buf[size], "</select> (%d)</td></tr>\n", thop_cnt);
+	  size += snprintf(&buf[size], bufsize-size, "</select> (%d)</td></tr>\n", thop_cnt);
 
 	}
     }
 
-  size += sprintf(&buf[size], "</table>\n");
+  size += snprintf(&buf[size], bufsize-size, "</table>\n");
 
   return size;
 }
@@ -1077,10 +1120,10 @@
   struct topo_dst *dst_entry;
 
 
-  size += sprintf(&buf[size], "<h2>Topology entries</h2>\n<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Destination IP</th><th>Last hop IP</th>");
+  size += snprintf(&buf[size], bufsize-size, "<h2>Topology entries</h2>\n<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Destination IP</th><th>Last Hop IP</th>");
   if (olsr_cnf->lq_level > 0)
-    size += sprintf(&buf[size], "<th>LQ</th><th>ILQ</th><th>ETX</th>");
-  size += sprintf(&buf[size], "</tr>\n");
+    size += snprintf(&buf[size], bufsize-size, "<th>LQ</th><th>ILQ</th><th>ETX</th>");
+  size += snprintf(&buf[size], bufsize-size, "</tr>\n");
 
 
   /* Topology */  
@@ -1094,26 +1137,21 @@
 	  dst_entry = entry->destinations.next;
 	  while(dst_entry != &entry->destinations)
 	    {
-	      size += sprintf(&buf[size],
-                             "<tr><td><a href=\"http://%s:%d/all\">%s</a></td>"
-                             "<td><a href=\"http://%s:%d/all\">%s</a></td>",
-                             olsr_ip_to_string(&dst_entry->T_dest_addr),
-                             http_port,
-                             olsr_ip_to_string(&dst_entry->T_dest_addr),
-                             olsr_ip_to_string(&entry->T_last_addr), 
-                             http_port,
-                             olsr_ip_to_string(&entry->T_last_addr));
+              size += snprintf(&buf[size], bufsize-size, "<tr>");
+              size += build_ipaddr_with_link(&buf[size], bufsize, &dst_entry->T_dest_addr, NULL);
+              size += build_ipaddr_with_link(&buf[size], bufsize, &entry->T_last_addr, NULL);
               if (olsr_cnf->lq_level > 0)
                 {
-	          size += sprintf(&buf[size],
-                                 "<td>%0.2f</td>"
-                                 "<td>%0.2f</td>"
-                                 "<td>%0.2f</td>\n",
+                  const double d = dst_entry->link_quality * dst_entry->inverse_link_quality;
+	          size += snprintf(&buf[size], bufsize-size,
+                                 "<td align=\"right\">%0.2f</td>"
+                                 "<td align=\"right\">%0.2f</td>"
+                                 "<td align=\"right\">%0.2f</td>\n",
                                  dst_entry->link_quality,
                                  dst_entry->inverse_link_quality,
-                                 (dst_entry->link_quality * dst_entry->inverse_link_quality) ? 1.0 / (dst_entry->link_quality * dst_entry->inverse_link_quality) : 0.0);
+                                 d ? 1.0 / d : 0.0);
                 }
-	      size += sprintf(&buf[size], "</tr>\n");
+	      size += snprintf(&buf[size], bufsize-size, "</tr>\n");
 
 	      dst_entry = dst_entry->next;
 	    }
@@ -1121,7 +1159,7 @@
 	}
     }
 
-  size += sprintf(&buf[size], "</table>\n");
+  size += snprintf(&buf[size], bufsize-size, "</table>\n");
 
   return size;
 }
@@ -1138,7 +1176,7 @@
 
   size = 0;
 
-  size += sprintf(&buf[size], "<h2>HNA entries</h2>\n<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Network</th><th>Netmask</th><th>Gateway</th></tr>\n");
+  size += snprintf(&buf[size], bufsize-size, "<h2>HNA entries</h2>\n<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Network</th><th>Netmask</th><th>Gateway</th></tr>\n");
 
   /* HNA entries */
   for(index=0;index<HASHSIZE;index++)
@@ -1152,14 +1190,11 @@
 	      
 	  while(tmp_net != &tmp_hna->networks)
 	    {
-	      size += sprintf(&buf[size], "<tr><td>%s</td>", 
-			      olsr_ip_to_string(&tmp_net->A_network_addr));
-	      size += sprintf(&buf[size], "<td>%s</td>",
+              size += snprintf(&buf[size], bufsize-size, "<tr>");
+              size += build_ipaddr_no_link(&buf[size], bufsize, &tmp_net->A_network_addr, NULL);
+	      size += snprintf(&buf[size], bufsize-size, "<td>%s</td>",
 			      olsr_netmask_to_string(&tmp_net->A_netmask));
-	      size += sprintf(&buf[size], "<td><a href=\"http://%s:%d/all\">%s</a></td></tr>\n",
-                              olsr_ip_to_string(&tmp_hna->A_gateway_addr),
-                              http_port,
-                              olsr_ip_to_string(&tmp_hna->A_gateway_addr));
+              size += build_ipaddr_with_link(&buf[size], bufsize, &tmp_hna->A_gateway_addr, NULL);
 	      tmp_net = tmp_net->next;
 	    }
 	      
@@ -1167,7 +1202,7 @@
 	}
     }
 
-  size += sprintf(&buf[size], "</table>\n");
+  size += snprintf(&buf[size], bufsize-size, "</table>\n");
 
   return size;
 }
@@ -1176,42 +1211,37 @@
 int
 build_mid_body(char *buf, olsr_u32_t bufsize)
 {
-  int size = 0, mid_cnt;
+  int size = 0;
   olsr_u8_t index;
-  struct mid_entry *entry;
-  struct mid_address *alias;
 
-  size += sprintf(&buf[size], "<h2>MID entries</h2>\n<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Main Address</th><th>Aliases</th></tr>\n");
+  size += snprintf(&buf[size], bufsize-size, "<h2>MID entries</h2>\n<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Main Address</th><th>Aliases</th></tr>\n");
   
   /* MID */  
-  for(index=0;index<HASHSIZE;index++)
+  for(index = 0;index < HASHSIZE; index++)
     {
-      entry = mid_set[index].next;
+      struct mid_entry *entry = mid_set[index].next;
       while(entry != &mid_set[index])
 	{
-	  size += sprintf(&buf[size], "<tr><td><a href=\"http://%s:%d/all\">%s</a></td>\n",
-	                  olsr_ip_to_string(&entry->main_addr),
-                          http_port,
-	                  olsr_ip_to_string(&entry->main_addr));
-	  size += sprintf(&buf[size], "<td><select>\n<option>IP ADDRESS</option>\n");
+          int mid_cnt;
+          struct mid_address *alias;
+          size += snprintf(&buf[size], bufsize-size, "<tr>");
+          size += build_ipaddr_with_link(&buf[size], bufsize, &entry->main_addr, NULL);
+	  size += snprintf(&buf[size], bufsize-size, "<td><select>\n<option>IP ADDRESS</option>\n");
 
 	  alias = entry->aliases;
 	  mid_cnt = 0;
 	  while(alias)
 	    {
-	      size += sprintf(&buf[size], "<option>%s</option>\n", olsr_ip_to_string(&alias->alias));
-	      mid_cnt ++;
+	      size += snprintf(&buf[size], bufsize-size, "<option>%s</option>\n", olsr_ip_to_string(&alias->alias));
+	      mid_cnt++;
 	      alias = alias->next_alias;
 	    }
-	  size += sprintf(&buf[size], "</select> (%d)</td></tr>\n", mid_cnt);
+	  size += snprintf(&buf[size], bufsize-size, "</select> (%d)</td></tr>\n", mid_cnt);
 	  entry = entry->next;
 	}
     }
 
-  size += sprintf(&buf[size], "</table>\n");
-
-
-
+  size += snprintf(&buf[size], bufsize-size, "</table>\n");
   return size;
 }
 
@@ -1221,10 +1251,10 @@
 {
   int size = 0;
 
-  size += build_neigh_body(buf, bufsize);
-  size += build_topo_body(&buf[size], bufsize - size);
-  size += build_hna_body(&buf[size], bufsize - size);
-  size += build_mid_body(&buf[size], bufsize - size);
+  size += build_neigh_body(&buf[size], bufsize-size);
+  size += build_topo_body(&buf[size], bufsize-size);
+  size += build_hna_body(&buf[size], bufsize-size);
+  size += build_mid_body(&buf[size], bufsize-size);
 
   return size;
 }
@@ -1234,12 +1264,12 @@
 {
   int size = 0;
 
-  size += build_config_body(&buf[size], bufsize);
-  size += build_routes_body(&buf[size], bufsize - size);
-  size += build_neigh_body(&buf[size], bufsize);
-  size += build_topo_body(&buf[size], bufsize - size);
-  size += build_hna_body(&buf[size], bufsize - size);
-  size += build_mid_body(&buf[size], bufsize - size);
+  size += build_config_body(&buf[size], bufsize-size);
+  size += build_routes_body(&buf[size], bufsize-size);
+  size += build_neigh_body(&buf[size], bufsize-size);
+  size += build_topo_body(&buf[size], bufsize-size);
+  size += build_hna_body(&buf[size], bufsize-size);
+  size += build_mid_body(&buf[size], bufsize-size);
 
   return size;
 }
@@ -1250,11 +1280,10 @@
 {
   int size = 0, i = 0;
 
-  while(about_frame[i])
-    {
-      size += sprintf(&buf[size], about_frame[i]);
+  while(about_frame[i]) {
+      size += snprintf(&buf[size], bufsize-size, about_frame[i]);
       i++;
-    }
+  }
   return size;
 }
 
@@ -1263,36 +1292,33 @@
 {
   int size = 0, i = 0;
 
-  while(cfgfile_body[i] && strcmp(cfgfile_body[i], "<!-- CFGFILE -->"))
-    {
-      size += sprintf(&buf[size], cfgfile_body[i]);
+  while(cfgfile_body[i] && strcmp(cfgfile_body[i], "<!-- CFGFILE -->")) {
+      size += snprintf(&buf[size], bufsize-size, cfgfile_body[i]);
       i++;
-    }
+  }
 
 #ifdef NETDIRECT
-    {
+  {
         /* Hack to make netdirect stuff work with
            olsrd_write_cnf_buf
         */
         char tmpBuf[10000];
         size = olsrd_write_cnf_buf(olsr_cnf, tmpBuf, 10000);
-        sprintf(&buf[size], tmpBuf);
-    }
+        snprintf(&buf[size], bufsize-size, tmpBuf);
+  }
 #else
-  size += olsrd_write_cnf_buf(olsr_cnf, &buf[size], bufsize - size);
+  size += olsrd_write_cnf_buf(olsr_cnf, &buf[size], bufsize-size);
 #endif
   
-  if(size < 0)
-    {
+  if(size < 0) {
       size = sprintf(&buf[0], "ERROR GENERATING CONFIGFILE!\n");
-    }
+  }
 
   i++;
-  while(cfgfile_body[i])
-    {
-      size += sprintf(&buf[size], cfgfile_body[i]);
+  while(cfgfile_body[i]) {
+      size += snprintf(&buf[size], bufsize-size, cfgfile_body[i]);
       i++;
-    }
+  }
   printf("RETURNING %d\n", size);
   return size;
 }
@@ -1334,35 +1360,21 @@
 olsr_netmask_to_string(union hna_netmask *mask)
 {
   char *ret;
-  struct in_addr in;
-  static char netmask[5];
-
-  if(olsr_cnf->ip_version == AF_INET)
-    {
+  if(olsr_cnf->ip_version == AF_INET) {
+      struct in_addr in;
       in.s_addr = mask->v4;
       ret = inet_ntoa(in);
-      return ret;
-
-    }
-  else
-    {
+  } else {
+      static char netmask[5];
       /* IPv6 */
       snprintf(netmask, sizeof(netmask), "%d", mask->v6);
-      return netmask;
-    }
-
+      ret = netmask;
+  }
   return ret;
 }
 
 
-
-
-static char *
-get_copyright_string()
-{
-  return copyright_string;
-}
-
+#if 0
 /*
  * In a bigger mesh, there are probs with the fixed
  * bufsize. Because the Content-Length header is
@@ -1388,3 +1400,23 @@
 	}
 	return rv;
 }
+#endif
+
+static ssize_t writen(int fd, const void *buf, size_t count)
+{
+    size_t bytes_left = count;
+    const char *p = buf;
+    while (bytes_left > 0) {
+        const ssize_t written = write(fd, p, bytes_left);
+        if (written == -1)  { /* error */
+            if (errno == EINTR ) {
+                continue;
+            }
+            return -1;
+        }
+        /* We wrote something */
+        bytes_left -= written;
+        p += written;
+    }
+    return count;
+}
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/httpinfo/src/olsrd_httpinfo.h olsrd-current/lib/httpinfo/src/olsrd_httpinfo.h
--- olsrd-0.5.0/lib/httpinfo/src/olsrd_httpinfo.h	2005-05-29 14:47:41.000000000 +0200
+++ olsrd-current/lib/httpinfo/src/olsrd_httpinfo.h	2007-04-20 16:06:18.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_httpinfo.h,v 1.28 2005/05/29 12:47:41 br1 Exp $
+ * $Id: olsrd_httpinfo.h,v 1.29 2007/04/20 14:06:18 bernd67 Exp $
  */
 
 /*
@@ -82,9 +82,6 @@
 
 
 char *
-olsr_ip_to_string(union olsr_ip_addr *);
-
-char *
 olsr_netmask_to_string(union hna_netmask *);
 
 /* Destructor function */
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/httpinfo/src/olsrd_plugin.c olsrd-current/lib/httpinfo/src/olsrd_plugin.c
--- olsrd-0.5.0/lib/httpinfo/src/olsrd_plugin.c	2007-02-04 23:37:36.000000000 +0100
+++ olsrd-current/lib/httpinfo/src/olsrd_plugin.c	2007-05-09 02:22:47.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_plugin.c,v 1.13 2007/02/04 22:37:36 bernd67 Exp $
+ * $Id: olsrd_plugin.c,v 1.16 2007/05/09 00:22:47 bernd67 Exp $
  */
 
 /*
@@ -49,9 +49,16 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <netinet/in.h>
+#ifndef WIN32
+#include <arpa/nameser.h>
+#endif
+
 #include "olsrd_httpinfo.h"
 
+
 int http_port = 0;
+int resolve_ip_addresses = 0;
 
 static void __attribute__ ((constructor)) 
 my_init(void);
@@ -59,14 +66,13 @@
 static void __attribute__ ((destructor)) 
 my_fini(void);
 
-
 /*
  * Defines the version of the plugin interface that is used
  * THIS IS NOT THE VERSION OF YOUR PLUGIN!
  * Do not alter unless you know what you are doing!
  */
 int 
-olsrd_plugin_interface_version()
+olsrd_plugin_interface_version(void)
 {
   return PLUGIN_INTERFACE_VERSION;
 }
@@ -77,11 +83,11 @@
  *Constructor
  */
 static void
-my_init()
+my_init(void)
 {
   /* Print plugin info to stdout */
   printf("%s\n", MOD_DESC);
-  
+
   return;
 }
 
@@ -89,7 +95,7 @@
  *Destructor
  */
 static void
-my_fini()
+my_fini(void)
 {
 
   /* Calls the destruction function
@@ -166,6 +172,15 @@
       return 1;
       
     }
-
+  if(!strcasecmp(key, "resolve"))
+    {
+        if (!strcasecmp (value, "yes")) {
+            resolve_ip_addresses = 1;
+        } else if (!strcasecmp (value, "no")) {
+            resolve_ip_addresses = 0;
+        } else {
+            return 0;
+        }
+    }
   return 1;
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/httpinfo/src/olsrd_plugin.h olsrd-current/lib/httpinfo/src/olsrd_plugin.h
--- olsrd-0.5.0/lib/httpinfo/src/olsrd_plugin.h	2007-02-04 23:37:36.000000000 +0100
+++ olsrd-current/lib/httpinfo/src/olsrd_plugin.h	2007-04-03 00:22:26.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_plugin.h,v 1.21 2007/02/04 22:37:36 bernd67 Exp $
+ * $Id: olsrd_plugin.h,v 1.22 2007/04/02 22:22:26 bernd67 Exp $
  */
 
 /*
@@ -72,6 +72,7 @@
 #define PLUGIN_INTERFACE_VERSION 4
 
 extern int http_port;
+extern int resolve_ip_addresses;
 
 /* Allowed hosts stuff */
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/Makefile olsrd-current/lib/Makefile
--- olsrd-0.5.0/lib/Makefile	2007-02-14 22:47:06.000000000 +0100
+++ olsrd-current/lib/Makefile	2007-04-03 12:08:53.000000000 +0200
@@ -1,8 +1,8 @@
-# This is quite ougly but at least it works
+# This is quite ugly but at least it works
 ifeq ($(OS),linux)
 SUBDIRS := $(shell find -maxdepth 2 -name Makefile -not -path ./Makefile -printf "%h\n")
 else
-SUBDIRS := dot_draw dyn_gw dyn_gw_plain httpinfo mini nameservice pgraph secure txtinfo
+SUBDIRS := bmf dot_draw dyn_gw dyn_gw_plain httpinfo mini nameservice pgraph secure txtinfo
 endif
 
 .PHONY: $(SUBDIRS)
@@ -12,4 +12,4 @@
 install: $(SUBDIRS)
 
 $(SUBDIRS):
-	$(MAKE) -C $@ $(MAKECMDGOALS)
+	$(MAKE) OS=$(OS) -C $@ $(MAKECMDGOALS)
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/mini/README olsrd-current/lib/mini/README
--- olsrd-0.5.0/lib/mini/README	2005-05-26 18:09:25.000000000 +0200
+++ olsrd-current/lib/mini/README	1970-01-01 01:00:00.000000000 +0100
@@ -1,36 +0,0 @@
----------------------------------------------------------------------
-MINI PLUGIN FOR OLSRD
-by Bruno Randolf <bruno.randolf@4g-systems.biz>
----------------------------------------------------------------------
-
-This is a minimal example plugin to demonstrate the functions a plugin
-must implement. It documents the minimal requirements for the new
-plugin interface and is a good start for creating new plugins and 
-testing the plugin loader.
-
-This plugin does nothing, except printing messages when it is loaded
-and unloaded.
-
-
----------------------------------------------------------------------
-PLUGIN PARAMETERS (PlParam)
----------------------------------------------------------------------
-
-PlParam "test" "anything"
-	just for a test: print the parameter.
-
-
----------------------------------------------------------------------
-SAMPLE CONFIG
----------------------------------------------------------------------
-
-add in /etc/olsrd.conf:
-
-LoadPlugin "olsrd_mini.so.0.1"
-{
-	PlParam "test" "hello"
-}
-
-
----------------------------------------------------------------------
-EOF / 26.05.2005
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/mini/README_MINI olsrd-current/lib/mini/README_MINI
--- olsrd-0.5.0/lib/mini/README_MINI	1970-01-01 01:00:00.000000000 +0100
+++ olsrd-current/lib/mini/README_MINI	2007-04-03 11:48:45.000000000 +0200
@@ -0,0 +1,36 @@
+---------------------------------------------------------------------
+MINI PLUGIN FOR OLSRD
+by Bruno Randolf <bruno.randolf@4g-systems.biz>
+---------------------------------------------------------------------
+
+This is a minimal example plugin to demonstrate the functions a plugin
+must implement. It documents the minimal requirements for the new
+plugin interface and is a good start for creating new plugins and 
+testing the plugin loader.
+
+This plugin does nothing, except printing messages when it is loaded
+and unloaded.
+
+
+---------------------------------------------------------------------
+PLUGIN PARAMETERS (PlParam)
+---------------------------------------------------------------------
+
+PlParam "test" "anything"
+	just for a test: print the parameter.
+
+
+---------------------------------------------------------------------
+SAMPLE CONFIG
+---------------------------------------------------------------------
+
+add in /etc/olsrd.conf:
+
+LoadPlugin "olsrd_mini.so.0.1"
+{
+	PlParam "test" "hello"
+}
+
+
+---------------------------------------------------------------------
+EOF / 26.05.2005
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/mini/src/olsrd_plugin.c olsrd-current/lib/mini/src/olsrd_plugin.c
--- olsrd-0.5.0/lib/mini/src/olsrd_plugin.c	2005-05-29 14:47:41.000000000 +0200
+++ olsrd-current/lib/mini/src/olsrd_plugin.c	2007-04-20 15:46:02.000000000 +0200
@@ -29,7 +29,7 @@
  *
  */
 
-/* $Id: olsrd_plugin.c,v 1.2 2005/05/29 12:47:41 br1 Exp $ */
+/* $Id: olsrd_plugin.c,v 1.3 2007/04/20 13:46:02 bernd67 Exp $ */
 
  /*
  * Example plugin for olsrd.org OLSR daemon
@@ -43,6 +43,8 @@
 #include "olsrd_plugin.h"
 #include "olsr.h"
 
+#define PLUGIN_INTERFACE_VERSION 1
+
 
 /****************************************************************************
  *                Functions that the plugin MUST provide                    *
@@ -53,9 +55,9 @@
  * Used by main olsrd to check plugin interface version
  */
 int 
-olsrd_plugin_interface_version()
+olsrd_plugin_interface_version(void)
 {
-	return OLSRD_PLUGIN_INTERFACE_VERSION;
+	return PLUGIN_INTERFACE_VERSION;
 }
 
 
@@ -79,7 +81,7 @@
  * Called after all parameters are passed
  */
 int
-olsrd_plugin_init()
+olsrd_plugin_init(void)
 {
 	printf("*** MINI: plugin_init\n");
 	
@@ -107,7 +109,7 @@
  * Optional Private Constructor
  */
 static void
-my_init()
+my_init(void)
 {
 	printf("*** MINI: constructor\n");
 }
@@ -117,7 +119,7 @@
  * Optional Private Destructor
  */
 static void
-my_fini()
+my_fini(void)
 {
 	printf("*** MINI: destructor\n");
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/mini/src/olsrd_plugin.h olsrd-current/lib/mini/src/olsrd_plugin.h
--- olsrd-0.5.0/lib/mini/src/olsrd_plugin.h	1970-01-01 01:00:00.000000000 +0100
+++ olsrd-current/lib/mini/src/olsrd_plugin.h	2007-04-20 16:18:56.000000000 +0200
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2005, Bruno Randolf <bruno.randolf@4g-systems.biz>
+ * Copyright (c) 2004, Andreas Tønnesen(andreto-at-olsr.org)
+ * 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 the UniK olsr daemon 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.
+ *
+ */
+
+/*
+ * Dynamic linked library for the olsr.org olsr daemon
+ */
+
+#ifndef _OLSRD_PLUGIN_MINI
+#define _OLSRD_PLUGIN_MINI
+
+
+/****************************************************************************
+ *                Functions that the plugin MUST provide                    *
+ ****************************************************************************/
+
+
+/* Initialization function */
+int
+olsrd_plugin_init(void);
+
+int
+olsrd_plugin_register_param(char *, char *);
+
+int 
+olsrd_plugin_interface_version(void);
+
+#endif
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/nameservice/Makefile olsrd-current/lib/nameservice/Makefile
--- olsrd-0.5.0/lib/nameservice/Makefile	2005-05-25 15:50:22.000000000 +0200
+++ olsrd-current/lib/nameservice/Makefile	2007-05-09 19:30:42.000000000 +0200
@@ -35,7 +35,7 @@
 # to the project. For more information see the website or contact
 # the copyright holders.
 #
-# $Id: Makefile,v 1.10 2005/05/25 13:50:22 br1 Exp $
+# $Id: Makefile,v 1.11 2007/05/09 17:30:42 bernd67 Exp $
 
 OLSRD_PLUGIN =	true
 PLUGIN_NAME =	olsrd_nameservice
@@ -44,6 +44,10 @@
 TOPDIR = ../..
 include $(TOPDIR)/Makefile.inc
 
+ifeq ($(OS),win32)
+default_target install clean:
+	@echo "**** We use the regex library here. Does Win32 has something like this?"
+else
 default_target: $(PLUGIN_FULLNAME)
 
 $(PLUGIN_FULLNAME): $(OBJS)
@@ -55,3 +59,4 @@
 
 clean:
 		rm -f $(OBJS) $(SRCS:%.c=%.d) $(PLUGIN_FULLNAME)
+endif
\ Kein Zeilenumbruch am Dateiende.
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/nameservice/README olsrd-current/lib/nameservice/README
--- olsrd-0.5.0/lib/nameservice/README	2005-04-20 19:57:00.000000000 +0200
+++ olsrd-current/lib/nameservice/README	1970-01-01 01:00:00.000000000 +0100
@@ -1,125 +0,0 @@
----------------------------------------------------------------------
-NAMESERVICE PLUGIN FOR OLSRD
-by Bruno Randolf <bruno.randolf@4g-systems.biz>
----------------------------------------------------------------------
-
-a simple DNS replacement for OLSR networks
-
-this plugin distributes host name (DNS) information over OLSR. every 
-node which runs the olsr daemon can announce it's own name, names for
-other IP adresses it is associated with (HNAs) and if it is running
-a "real" nameserver which can resolve other (internet) names (upstream 
-dns server).
-
-the nodes in the network collect this information and write the host 
-names to a file (possibly /etc/hosts), and the 3 nearest upstream 
-nameservers to another file (possibly /etc/resolv.conf).
-
-these files can be used to resolve hostnames on the local system and/or
-be read by a DNS server like "dnsmasq", to make the names available 
-via the ordinary DNS protocol to other clients as well.
-
-the default location of the hosts file is
-"/var/run/hosts_olsr" on unixes
-"C:\WINDOWS\hosts_olsr" on windows
-
-
----------------------------------------------------------------------
-PLUGIN PARAMETERS (PlParam)
----------------------------------------------------------------------
-
-PlParam "name" "my-name.mesh"
-	the name of this OLSR node (main address).
-	can be specified multiple times for different names.
-
-PlParam "IP.ADDR" "another-name.mesh"
-	a name for a specified IP address.
-	the IP address has to be either from one of the olsr 
-	interfaces or within a HNA network we announce.
-	can be specified multiple times.
-
-PlParam "hosts-file" "/path/to/hosts_file"
-	which file to write to (usually /etc/hosts).
-	(default: /var/run/hosts_olsr)
-
-PlParam "suffix" ".olsr"
-	local suffix which is appended to all received names.
-	(default: "")
-
-PlParam "add-hosts" "/path/to/file"
-	copy contents of this additional hosts file to output file.
-	this is practical if you alreay use your /etc/hosts file.
-
-PlParam "dns-server" "IP.ADDR"
-	anounce that this IP has a full (upstream) DNS server. if 
-	IP.ADDR is not specified (""), the main address is used.
-	nodes which don't know a nameserver will automatically use
-	this nameserver.
-
-PlParam "resolv-file" "/path/to/resolv.conf"
-	path to resolv.conf file (usually /etc/resolv.conf)
-	if set, the 3 nearest (best ETX) upstream nameservers annonced 
-	by other nodes in the network are written to this file
-
-PlParam "interval" "SEC"
-	interval for sending NAME messages in seconds.
-	(default: 120 - 2 minutes)
-
-PlParam "timeout" "SEC"
-	validity time for received NAME messages in seconds.
-	(default: 3600 - 1 hour)
-
-
----------------------------------------------------------------------
-SAMPLE CONFIG
----------------------------------------------------------------------
-
-add in /etc/olsrd.conf:
-
-LoadPlugin "olsrd_nameservice.so.0.2"
-{
-	PlParam "name" "thisismyname"
-	PlParam "hosts-file" "/etc/hosts"
-	PlParam "resolv-file" "/etc/resolv.conf"
-}
-
-
----------------------------------------------------------------------
-USING THE NAME INFORMATION
----------------------------------------------------------------------
-
-to use the name information distributed by the plugin actually for
-name resolution you can do one of the following.
-
-UNIX VARIANTS:
-
-* overwrite /etc/hosts
-	be sure you have nothing in /etc/hosts which you still need and
-	configure the plugin with PlParam "host-file" "/etc/hosts"
-
-* link /etc/hosts
-	ln -s /var/run/hosts_olsr /etc/hosts
-
-* use dnsmasq
-	if you want to make the names available via ordinary DNS
-	you can use dnsmasq to read the hosts file and serve it to
-	users. add "addn-hosts=/var/run/hosts_olsr" to dnsmasq.conf 
-	and restart dnsmasq
-
-WINDOWS:
-
-* overwrite C:\WINDOWS\system32\drivers\etc\hosts
-	be sure you have nothing in the file which you still need 
-	and configure the plugin with
-	PlParam "filename" "C:\WINDOWS\system32\drivers\etc\hosts"
-
-
----------------------------------------------------------------------
-TODO
----------------------------------------------------------------------
-  
-  * implement a small DNS server into the plugin?
-  * or make dynamic DNS updates for bind?
-
----------------------------------------------------------------------
-EOF / 20.04.2005
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/nameservice/README_NAMESERVICE olsrd-current/lib/nameservice/README_NAMESERVICE
--- olsrd-0.5.0/lib/nameservice/README_NAMESERVICE	1970-01-01 01:00:00.000000000 +0100
+++ olsrd-current/lib/nameservice/README_NAMESERVICE	2007-04-03 11:48:45.000000000 +0200
@@ -0,0 +1,125 @@
+---------------------------------------------------------------------
+NAMESERVICE PLUGIN FOR OLSRD
+by Bruno Randolf <bruno.randolf@4g-systems.biz>
+---------------------------------------------------------------------
+
+a simple DNS replacement for OLSR networks
+
+this plugin distributes host name (DNS) information over OLSR. every 
+node which runs the olsr daemon can announce it's own name, names for
+other IP adresses it is associated with (HNAs) and if it is running
+a "real" nameserver which can resolve other (internet) names (upstream 
+dns server).
+
+the nodes in the network collect this information and write the host 
+names to a file (possibly /etc/hosts), and the 3 nearest upstream 
+nameservers to another file (possibly /etc/resolv.conf).
+
+these files can be used to resolve hostnames on the local system and/or
+be read by a DNS server like "dnsmasq", to make the names available 
+via the ordinary DNS protocol to other clients as well.
+
+the default location of the hosts file is
+"/var/run/hosts_olsr" on unixes
+"C:\WINDOWS\hosts_olsr" on windows
+
+
+---------------------------------------------------------------------
+PLUGIN PARAMETERS (PlParam)
+---------------------------------------------------------------------
+
+PlParam "name" "my-name.mesh"
+	the name of this OLSR node (main address).
+	can be specified multiple times for different names.
+
+PlParam "IP.ADDR" "another-name.mesh"
+	a name for a specified IP address.
+	the IP address has to be either from one of the olsr 
+	interfaces or within a HNA network we announce.
+	can be specified multiple times.
+
+PlParam "hosts-file" "/path/to/hosts_file"
+	which file to write to (usually /etc/hosts).
+	(default: /var/run/hosts_olsr)
+
+PlParam "suffix" ".olsr"
+	local suffix which is appended to all received names.
+	(default: "")
+
+PlParam "add-hosts" "/path/to/file"
+	copy contents of this additional hosts file to output file.
+	this is practical if you alreay use your /etc/hosts file.
+
+PlParam "dns-server" "IP.ADDR"
+	anounce that this IP has a full (upstream) DNS server. if 
+	IP.ADDR is not specified (""), the main address is used.
+	nodes which don't know a nameserver will automatically use
+	this nameserver.
+
+PlParam "resolv-file" "/path/to/resolv.conf"
+	path to resolv.conf file (usually /etc/resolv.conf)
+	if set, the 3 nearest (best ETX) upstream nameservers annonced 
+	by other nodes in the network are written to this file
+
+PlParam "interval" "SEC"
+	interval for sending NAME messages in seconds.
+	(default: 120 - 2 minutes)
+
+PlParam "timeout" "SEC"
+	validity time for received NAME messages in seconds.
+	(default: 3600 - 1 hour)
+
+
+---------------------------------------------------------------------
+SAMPLE CONFIG
+---------------------------------------------------------------------
+
+add in /etc/olsrd.conf:
+
+LoadPlugin "olsrd_nameservice.so.0.2"
+{
+	PlParam "name" "thisismyname"
+	PlParam "hosts-file" "/etc/hosts"
+	PlParam "resolv-file" "/etc/resolv.conf"
+}
+
+
+---------------------------------------------------------------------
+USING THE NAME INFORMATION
+---------------------------------------------------------------------
+
+to use the name information distributed by the plugin actually for
+name resolution you can do one of the following.
+
+UNIX VARIANTS:
+
+* overwrite /etc/hosts
+	be sure you have nothing in /etc/hosts which you still need and
+	configure the plugin with PlParam "host-file" "/etc/hosts"
+
+* link /etc/hosts
+	ln -s /var/run/hosts_olsr /etc/hosts
+
+* use dnsmasq
+	if you want to make the names available via ordinary DNS
+	you can use dnsmasq to read the hosts file and serve it to
+	users. add "addn-hosts=/var/run/hosts_olsr" to dnsmasq.conf 
+	and restart dnsmasq
+
+WINDOWS:
+
+* overwrite C:\WINDOWS\system32\drivers\etc\hosts
+	be sure you have nothing in the file which you still need 
+	and configure the plugin with
+	PlParam "filename" "C:\WINDOWS\system32\drivers\etc\hosts"
+
+
+---------------------------------------------------------------------
+TODO
+---------------------------------------------------------------------
+  
+  * implement a small DNS server into the plugin?
+  * or make dynamic DNS updates for bind?
+
+---------------------------------------------------------------------
+EOF / 20.04.2005
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/nameservice/src/compat.c olsrd-current/lib/nameservice/src/compat.c
--- olsrd-0.5.0/lib/nameservice/src/compat.c	2005-06-02 17:34:00.000000000 +0200
+++ olsrd-current/lib/nameservice/src/compat.c	2007-04-20 00:21:34.000000000 +0200
@@ -11,9 +11,6 @@
   size_t len = strlen(ptr);
   char *ret = NULL;
 
-  if(!len)
-    return NULL;
-
   if(len > size)
     len = size;
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/nameservice/src/nameservice.c olsrd-current/lib/nameservice/src/nameservice.c
--- olsrd-0.5.0/lib/nameservice/src/nameservice.c	2007-02-06 22:07:11.000000000 +0100
+++ olsrd-current/lib/nameservice/src/nameservice.c	2007-04-28 21:58:49.000000000 +0200
@@ -30,7 +30,7 @@
  *
  */
 
-/* $Id: nameservice.c,v 1.18 2007/02/06 21:07:11 bernd67 Exp $ */
+/* $Id: nameservice.c,v 1.23 2007/04/28 19:58:49 bernd67 Exp $ */
 
 /*
  * Dynamic linked library for UniK OLSRd
@@ -104,7 +104,7 @@
  * do initialization
  */
 void
-name_constructor() 
+name_constructor(void) 
 {
 	int i;
 	
@@ -187,7 +187,7 @@
 		if (strlen(value) == 0) {
             my_forwarders = add_name_to_list(my_forwarders, "", NAME_FORWARDER, NULL);
             olsr_printf(1,"\nNAME PLUGIN: parameter dns-server: (main address)");
-        } else if (inet_pton(olsr_cnf->ip_version, value, &ip)) {
+        } else if (inet_pton(olsr_cnf->ip_version, value, &ip) > 0) {
             my_forwarders = add_name_to_list(my_forwarders, "", NAME_FORWARDER, &ip);
             olsr_printf(1,"\nNAME PLUGIN: parameter dns-server: (%s)", value);
         } else {
@@ -208,7 +208,7 @@
 		// assume this is an IP address and hostname
 		union olsr_ip_addr ip;
 		
-		if (inet_pton(olsr_cnf->ip_version, key, &ip) == 1) {
+		if (inet_pton(olsr_cnf->ip_version, key, &ip) > 0) {
 			// the IP is validated later
             my_names = add_name_to_list(my_names, value, NAME_HOST, &ip);
 			olsr_printf(1,"\nNAME PLUGIN: parameter name %s (%s)", value, key);
@@ -257,18 +257,17 @@
  *   - register_olsr_data() then then finally calls this function
  */
 int
-name_init()
+name_init(void)
 {
 	struct name_entry *name;
 	union olsr_ip_addr ipz;
-
-	memset(&ipz, 0, sizeof(ipz));
-
     int ret;
+
     //regex string for validating the hostnames
     char *regex_name = "^[[:alnum:]_.-]+$";
     //regex string for the service line
     char *regex_service = olsr_malloc(256*sizeof(char) + strlen(my_suffix), "new *char from name_init for regex_service");
+	memset(&ipz, 0, sizeof(ipz));
 
     //compile the regex from the string
 	if ((ret = regcomp(&regex_t_name, regex_name , REG_EXTENDED)) != 0)
@@ -390,7 +389,7 @@
  * XXX: should I delete the hosts/services/resolv.conf files on exit?
  */
 void
-name_destructor()
+name_destructor(void)
 {
 	olsr_printf(2, "NAME PLUGIN: exit. cleaning up...\n");
 	
@@ -412,15 +411,13 @@
 free_all_list_entries(struct db_entry **this_db_list) 
 {
 	int i;
-	struct db_entry **tmp;
-	struct db_entry *to_delete;
 	
 	for(i = 0; i < HASHSIZE; i++)
 	{
-		tmp = &list[i];
+        struct db_entry **tmp = &this_db_list[i];
 		while(*tmp != NULL)
 		{
-			to_delete = *tmp;
+            struct db_entry *to_delete = *tmp;
 			*tmp = (*tmp)->next;
 			free_name_entry_list(&to_delete->names);
 			free(to_delete);
@@ -440,7 +437,7 @@
  * and write changes to file
  */
 void
-olsr_timeout()
+olsr_timeout(void)
 {
     timeout_old_names(list, &name_table_changed);
     timeout_old_names(forwarder_list, &forwarder_table_changed);
@@ -488,7 +485,7 @@
  * Scheduled event: generate and send NAME packet
  */
 void
-olsr_event(void *foo)
+olsr_event(void *foo __attribute__((unused)))
 {
 	union olsr_message *message = (union olsr_message*)buffer;
 	struct interface *ifn;
@@ -531,10 +528,10 @@
 			message->v6.olsr_msgsize = htons(namesize);
 		}
 		
-		if(net_outbuffer_push(ifn, (olsr_u8_t *)message, namesize) != namesize ) {
+		if(net_outbuffer_push(ifn, message, namesize) != namesize ) {
 			/* send data and try again */
 			net_output(ifn);
-			if(net_outbuffer_push(ifn, (olsr_u8_t *)message, namesize) != namesize ) {
+			if(net_outbuffer_push(ifn, message, namesize) != namesize ) {
 				olsr_printf(1, "NAME PLUGIN: could not send on interface: %s\n", ifn->int_name);
 			}
 		}
@@ -679,9 +676,9 @@
 	struct name_entry *tmp;
 	struct name_entry *already_saved_name_entries;
     char *name = (char*)from_packet + sizeof(struct name);
-	olsr_printf(4, "\nNAME PLUGIN: decapsulating received name, service or forwarder \n");
     int type_of_from_packet = ntohs(from_packet->type);
     unsigned int len_of_name = ntohs(from_packet->len);
+	olsr_printf(4, "\nNAME PLUGIN: decapsulating received name, service or forwarder \n");
     
     // don't insert the received entry again, if it has already been inserted in the hash table. 
     // Instead only the validity time is set in insert_new_name_in_list function, which calls this one
@@ -833,7 +830,7 @@
  * write names to a file in /etc/hosts compatible format
  */
 void
-write_hosts_file()
+write_hosts_file(void)
 {
 	int hash;
 	struct name_entry *name;
@@ -914,7 +911,7 @@
  * http://me.olsr:80|tcp|my little homepage
  */
 void
-write_services_file()
+write_services_file(void)
 {
 	int hash;
 	struct name_entry *name;
@@ -972,7 +969,7 @@
  * best means the 3 with the best etx value in routing table
  */
 void
-write_resolv_file()
+write_resolv_file(void)
 {
 	int hash;
 	struct name_entry *name, *tmp_dns, *last_dns, *dnslist = NULL;
@@ -1280,7 +1277,7 @@
     }
     
     //ip in service-line is allowed 
-    if (inet_pton(olsr_cnf->ip_version, hostname_or_ip, &olsr_ip)) {
+    if (inet_pton(olsr_cnf->ip_version, hostname_or_ip, &olsr_ip) > 0) {
         if (allowed_ip(&olsr_ip)) {
             olsr_printf(2, "NAME PLUGIN: ip %s in service %s is OK\n", olsr_ip_to_string(&olsr_ip), service_line);
             free(hostname_or_ip);
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/nameservice/src/olsrd_plugin.c olsrd-current/lib/nameservice/src/olsrd_plugin.c
--- olsrd-0.5.0/lib/nameservice/src/olsrd_plugin.c	2005-05-29 14:47:42.000000000 +0200
+++ olsrd-current/lib/nameservice/src/olsrd_plugin.c	2007-04-20 15:46:02.000000000 +0200
@@ -29,7 +29,7 @@
  *
  */
 
-/* $Id: olsrd_plugin.c,v 1.11 2005/05/29 12:47:42 br1 Exp $ */
+/* $Id: olsrd_plugin.c,v 1.12 2007/04/20 13:46:02 bernd67 Exp $ */
 
 /*
  * Dynamic linked library for olsr.org olsrd
@@ -41,7 +41,6 @@
 #include "olsrd_plugin.h"
 #include "nameservice.h"
 
-
 #define PLUGIN_NAME    "OLSRD nameservice plugin"
 #define PLUGIN_VERSION "0.2"
 #define PLUGIN_AUTHOR   "Bruno Randolf"
@@ -54,22 +53,21 @@
 static void __attribute__ ((destructor)) 
 my_fini(void);
 
-
 int 
-olsrd_plugin_interface_version()
+olsrd_plugin_interface_version(void)
 {
 	return OLSRD_PLUGIN_INTERFACE_VERSION;
 }
 
-
-int olsrd_plugin_init()
+int
+olsrd_plugin_init(void)
 {
 	return name_init();
 }
 
 
 static void
-my_init()
+my_init(void)
 {
 	/* Print plugin info to stdout */
 	printf("%s\n", MOD_DESC);
@@ -81,7 +79,7 @@
 
 
 static void
-my_fini()
+my_fini(void)
 {
 	name_destructor();
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/pgraph/README-OLSR olsrd-current/lib/pgraph/README-OLSR
--- olsrd-0.5.0/lib/pgraph/README-OLSR	2005-07-13 23:45:07.000000000 +0200
+++ olsrd-current/lib/pgraph/README-OLSR	1970-01-01 01:00:00.000000000 +0100
@@ -1,69 +0,0 @@
-README-OLSR
-Modified: 05/17/2005
-
-#========================================================================
-#  These programs NEVER meet your needs.  In fact, they can cause
-#  serious damages to your precious things, including, but not being
-#  limited to, time, money, effort, computer files, information,
-#  hardware, software, and other things that you value.
-#
-#  The author DOES NOT request or even suggest that you use any of these
-#  programs. You understand clearly that you are taking a big risk
-#  in using these programs and that you are completely (100%) liable
-#  for using them.
-#
-#  You further understand that although you can use these programs
-#  without paying the author or the employer of the author, you
-#  do not own them.  You will give proper credits to the
-#  author and his employer whenever you use them; i.e.,
-#  you will never pretend that you are the author of these programs.
-#  If you make any changes to them, you will send a copy
-#  of each modified programs to the author.  You will also NEVER
-#  sell or give any of them to anyone else without the approval of the
-#  author or his employer.
-
-
-Parser: OLSRConnect.py
-Description: This parser has been written to interface with a plugin for
-	     the version 4.9 OLSR from olsr.org.  The plugin can also be 
-	     found in this directory.  
-
-Parser for OLSR: 	OLSRConnect.py
-Plugin for OLSRv4.9:	olsr_v4.9-pgraph-plugin
-
-Usage:
-	1) Copy the "olsr_v4.9-pgraph-plugin" directory from this distribution
-	   to the "/<your OLSRv4.9 path>/lib/."
-
-	2) cd to the "/<your OLSRv4.9 path>/lib/." directory, 
-           run "make" and "make install"
-	   This will create the "olsrd_pgraph.so.1.1" file and install it. 
-
-	3) Modify the "/etc/olsrd.conf" file of the system you wish to
-	   monitor from to load the plugin. 
-	   Add the line: "LoadPlugin "olsrd_pgraph.so.1.1" {}"
-
-	4) The plugin actually allows any host to connect regardless of
-           what is specified in the olsrd.conf file.  This is currently 
-           done for testing purposes and due to the fact that the "Host" 
-           parameter in the olsrd.conf file never worked.  
-
-           # By default only localhost will be able to connect to the IPC
-	   # system of the olsrd process so if you are not going to be 
-	   # running pgraph locally, modify the "Host" variable of the 
-	   # "IpcConnect" structure in the "/etc/olsrd.conf" file to 
-	   # reflect the IP address of the host you will be connecting from. 
-
-	5) Start olsrd and make sure that the plugin has loaded correctly.
-
-	6) On the machine you will be running pgraph from, use the 
-	   "OLSRConnect.py" parser to connect to the olsrd plugin and pipe
-	   the output to pgraph. 
-
-Usage: (note the use of the backquote "`") 
-"python  OLSRConnect.py <ip of machine running plugin> 2004 | `python pgraph.py`"
-
-- Where the "2004" above is the default port that the plugin will be listening on.
-
-To kill pgraph when using the parser:
-- Hit "Ctl-C" in the terminal. 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/pgraph/README_PGRAPH olsrd-current/lib/pgraph/README_PGRAPH
--- olsrd-0.5.0/lib/pgraph/README_PGRAPH	1970-01-01 01:00:00.000000000 +0100
+++ olsrd-current/lib/pgraph/README_PGRAPH	2007-04-03 11:48:45.000000000 +0200
@@ -0,0 +1,69 @@
+README-OLSR
+Modified: 05/17/2005
+
+#========================================================================
+#  These programs NEVER meet your needs.  In fact, they can cause
+#  serious damages to your precious things, including, but not being
+#  limited to, time, money, effort, computer files, information,
+#  hardware, software, and other things that you value.
+#
+#  The author DOES NOT request or even suggest that you use any of these
+#  programs. You understand clearly that you are taking a big risk
+#  in using these programs and that you are completely (100%) liable
+#  for using them.
+#
+#  You further understand that although you can use these programs
+#  without paying the author or the employer of the author, you
+#  do not own them.  You will give proper credits to the
+#  author and his employer whenever you use them; i.e.,
+#  you will never pretend that you are the author of these programs.
+#  If you make any changes to them, you will send a copy
+#  of each modified programs to the author.  You will also NEVER
+#  sell or give any of them to anyone else without the approval of the
+#  author or his employer.
+
+
+Parser: OLSRConnect.py
+Description: This parser has been written to interface with a plugin for
+	     the version 4.9 OLSR from olsr.org.  The plugin can also be 
+	     found in this directory.  
+
+Parser for OLSR: 	OLSRConnect.py
+Plugin for OLSRv4.9:	olsr_v4.9-pgraph-plugin
+
+Usage:
+	1) Copy the "olsr_v4.9-pgraph-plugin" directory from this distribution
+	   to the "/<your OLSRv4.9 path>/lib/."
+
+	2) cd to the "/<your OLSRv4.9 path>/lib/." directory, 
+           run "make" and "make install"
+	   This will create the "olsrd_pgraph.so.1.1" file and install it. 
+
+	3) Modify the "/etc/olsrd.conf" file of the system you wish to
+	   monitor from to load the plugin. 
+	   Add the line: "LoadPlugin "olsrd_pgraph.so.1.1" {}"
+
+	4) The plugin actually allows any host to connect regardless of
+           what is specified in the olsrd.conf file.  This is currently 
+           done for testing purposes and due to the fact that the "Host" 
+           parameter in the olsrd.conf file never worked.  
+
+           # By default only localhost will be able to connect to the IPC
+	   # system of the olsrd process so if you are not going to be 
+	   # running pgraph locally, modify the "Host" variable of the 
+	   # "IpcConnect" structure in the "/etc/olsrd.conf" file to 
+	   # reflect the IP address of the host you will be connecting from. 
+
+	5) Start olsrd and make sure that the plugin has loaded correctly.
+
+	6) On the machine you will be running pgraph from, use the 
+	   "OLSRConnect.py" parser to connect to the olsrd plugin and pipe
+	   the output to pgraph. 
+
+Usage: (note the use of the backquote "`") 
+"python  OLSRConnect.py <ip of machine running plugin> 2004 | `python pgraph.py`"
+
+- Where the "2004" above is the default port that the plugin will be listening on.
+
+To kill pgraph when using the parser:
+- Hit "Ctl-C" in the terminal. 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/pgraph/src/olsrd_pgraph.c olsrd-current/lib/pgraph/src/olsrd_pgraph.c
--- olsrd-0.5.0/lib/pgraph/src/olsrd_pgraph.c	2006-01-07 09:17:43.000000000 +0100
+++ olsrd-current/lib/pgraph/src/olsrd_pgraph.c	2007-04-28 22:48:57.000000000 +0200
@@ -37,7 +37,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_pgraph.c,v 1.3 2006/01/07 08:17:43 kattemat Exp $
+ * $Id: olsrd_pgraph.c,v 1.5 2007/04/28 20:48:57 bernd67 Exp $
  */
 
 /*
@@ -56,28 +56,42 @@
 #define close(x) closesocket(x)
 #endif
 
-int ipc_socket;
-int ipc_open;
-int ipc_connection;
-int ipc_socket_up;
+static int ipc_socket;
+static int ipc_open;
+static int ipc_connection;
+static int ipc_socket_up;
 
-static void inline
+static void
+ipc_print_neigh_link(struct neighbor_entry *neighbor);
+
+static void
+ipc_print_tc_link(struct tc_entry *entry, struct topo_dst *dst_entry);
+
+#if 0
+static void
+ipc_print_net(union olsr_ip_addr *, union olsr_ip_addr *, union hna_netmask *);
+#endif
+
+static int
+ipc_send(const char *, int);
+
+static void
 ipc_print_neigh_link(struct neighbor_entry *);
 
-int
+static int
 plugin_ipc_init(void);
 
 void
 olsr_plugin_exit(void);
 
 
-static void inline
+static void
 ipc_print_neigh_link(struct neighbor_entry *neighbor)
 {
   char buf[256];
   int len;
-  char* main_adr;
-  char* adr;
+  const char* main_adr;
+  const char* adr;
 //  double etx=0.0;
 //  char* style = "solid";
 //  struct link_entry* link;
@@ -120,7 +134,7 @@
  *function in uolsrd_plugin.c
  */
 int
-olsrd_plugin_init()
+olsrd_plugin_init(void)
 {
 
   /* Initial IPC value */
@@ -134,7 +148,7 @@
 }
 
 int
-plugin_ipc_init()
+plugin_ipc_init(void)
 {
   struct sockaddr_in sin;
   olsr_u32_t yes = 1;
@@ -193,7 +207,7 @@
 }
 
 void
-ipc_action(int fd)
+ipc_action(int fd __attribute__((unused)))
 {
   struct sockaddr_in pin;
   socklen_t addrlen;
@@ -235,7 +249,7 @@
  * destructor - called at unload
  */
 void
-olsr_plugin_exit()
+olsr_plugin_exit(void)
 {
   if(ipc_open)
     close(ipc_socket);
@@ -249,7 +263,7 @@
 int
 pcf_event(int changes_neighborhood,
 	  int changes_topology,
-	  int changes_hna)
+	  int changes_hna __attribute__((unused)))
 {
   int res;
   olsr_u8_t index;
@@ -344,13 +358,13 @@
 }
 #endif
 
-static void inline
+static void
 ipc_print_tc_link(struct tc_entry *entry, struct topo_dst *dst_entry)
 {
   char buf[256];
   int len;
-  char* main_adr;
-  char* adr;
+  const char* main_adr;
+  const char* adr;
 //  double etx = calc_etx( dst_entry->link_quality, dst_entry->inverse_link_quality );
 
   main_adr = olsr_ip_to_string(&entry->T_last_addr);
@@ -359,10 +373,11 @@
   ipc_send(buf, len);
 }
 
-static void inline
+#if 0
+static void
 ipc_print_net(union olsr_ip_addr *gw, union olsr_ip_addr *net, union hna_netmask *mask)
 {
-  char *adr;
+  const char *adr;
 
   adr = olsr_ip_to_string(gw);
   ipc_send("\"", 1);
@@ -383,11 +398,11 @@
   ipc_send("\"", 1);
   ipc_send("[shape=diamond];\n", strlen("[shape=diamond];\n"));
 }
-
+#endif
 
 
 int
-ipc_send(char *data, int size)
+ipc_send(const char *data, int size)
 {
   if(!ipc_open)
     return 0;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/pgraph/src/olsrd_pgraph.h olsrd-current/lib/pgraph/src/olsrd_pgraph.h
--- olsrd-0.5.0/lib/pgraph/src/olsrd_pgraph.h	2005-07-13 23:45:08.000000000 +0200
+++ olsrd-current/lib/pgraph/src/olsrd_pgraph.h	2007-04-20 15:46:03.000000000 +0200
@@ -37,7 +37,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_pgraph.h,v 1.1 2005/07/13 21:45:08 kattemat Exp $
+ * $Id: olsrd_pgraph.h,v 1.2 2007/04/20 13:46:03 bernd67 Exp $
  */
 
 /*
@@ -73,7 +73,7 @@
 extern struct in_addr ipc_accept_ip;
 extern int ipc_port;
 
-char netmask[5];
+extern char netmask[5];
 
 /* Event function to register with the sceduler */
 int
@@ -82,18 +82,6 @@
 void
 ipc_action(int);
 
-static void inline
-ipc_print_neigh_link(struct neighbor_entry *neighbor);
-
-static void inline
-ipc_print_tc_link(struct tc_entry *entry, struct topo_dst *dst_entry);
-
-static void inline
-ipc_print_net(union olsr_ip_addr *, union olsr_ip_addr *, union hna_netmask *);
-
-int
-ipc_send(char *, int);
-
 char *
 olsr_netmask_to_string(union hna_netmask *);
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/pgraph/src/olsrd_plugin.c olsrd-current/lib/pgraph/src/olsrd_plugin.c
--- olsrd-0.5.0/lib/pgraph/src/olsrd_plugin.c	2005-07-13 23:45:08.000000000 +0200
+++ olsrd-current/lib/pgraph/src/olsrd_plugin.c	2007-04-20 15:46:03.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_plugin.c,v 1.1 2005/07/13 21:45:08 kattemat Exp $
+ * $Id: olsrd_plugin.c,v 1.2 2007/04/20 13:46:03 bernd67 Exp $
  */
 
 /*
@@ -78,7 +78,7 @@
  * Do not alter unless you know what you are doing!
  */
 int 
-olsrd_plugin_interface_version()
+olsrd_plugin_interface_version(void)
 {
   return PLUGIN_INTERFACE_VERSION;
 }
@@ -88,7 +88,7 @@
  *Constructor
  */
 void
-my_init()
+my_init(void)
 {
   /* Print plugin info to stdout */
   printf("%s\n", MOD_DESC);
@@ -104,7 +104,7 @@
  *Destructor
  */
 void
-my_fini()
+my_fini(void)
 {
 
   /* Calls the destruction function
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/quagga/README olsrd-current/lib/quagga/README
--- olsrd-0.5.0/lib/quagga/README	2007-03-12 00:26:06.000000000 +0100
+++ olsrd-current/lib/quagga/README	1970-01-01 01:00:00.000000000 +0100
@@ -1,58 +0,0 @@
----------------------------------------------------------------------
-QUAGGA PLUGIN FOR OLSRD
-by Immo 'FaUl' Wehrenberg <immo@chaostreff-dortmund.de>
----------------------------------------------------------------------
-
-This is the Quagga Plugin for the OLSRD. 
-It allowes olsrd to redistribute from various quagga-protocols 
-as well as to export olsr-routes to quagga so that they can be
-redistributed by the quagga-routing-daemons.
-
-Note Sven-Ola: You also need a source distribution of quagga-0.98.5
-or quagga-0.98.6 (that is the current stable). The quagga source tree 
-needs to be patched with quagga-0.98.6-olsr.diff, compiled and installed
-via 'make install'. Because many people will otherwise have compile
-probs, I've added 2 include files in lib/quagga/src/quagga. If you
-want to use another version of quagga, make sure to remove these
-before you compile the olsrd_quagga plugin.
-
----------------------------------------------------------------------
-PLUGIN PARAMETERS (PlParam)
----------------------------------------------------------------------
-
-PlParam "redistribute" "<protocol>"
-	where protocol is one of the following:
-	system, kernel, connect, static, rip, ripng, ospf, ospf6,
-	isis, bgp, hsls
-	May be used more then once
-
-PlParam "ExportRoutes" "<only/both>"
-	exportes olsr-routes to quagga or to both, quagga and kernel
-	no routes are exportet if not set.
-
-PlParam "LocalPref" "true"
-        sets the zebra SELECTED-flag on the routes exported to zebra
-	which means these routes are prefered in any case.
-
-PlParam "Distance" "0-255"
-        allowes to set Administrative distance to routes exported 
-	to zebra.
-	
----------------------------------------------------------------------
-SAMPLE CONFIG
----------------------------------------------------------------------
-
-add in /etc/olsrd.conf:
-
-LoadPlugin "olsrd_quagga.so.0.2.2"
-{
-	PlParam "redistribute" "ospf"
-	PlParam "redistribute" "bgp"
-	PlParam "ExportRoutes" "only"
-	PlParam "Distance" "125" 
-	PlParam "LocalPref" "false"
-}
-
-
----------------------------------------------------------------------
-EOF / 8.5.2006
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/quagga/README_QUAGGA olsrd-current/lib/quagga/README_QUAGGA
--- olsrd-0.5.0/lib/quagga/README_QUAGGA	1970-01-01 01:00:00.000000000 +0100
+++ olsrd-current/lib/quagga/README_QUAGGA	2007-04-03 11:48:45.000000000 +0200
@@ -0,0 +1,58 @@
+---------------------------------------------------------------------
+QUAGGA PLUGIN FOR OLSRD
+by Immo 'FaUl' Wehrenberg <immo@chaostreff-dortmund.de>
+---------------------------------------------------------------------
+
+This is the Quagga Plugin for the OLSRD. 
+It allowes olsrd to redistribute from various quagga-protocols 
+as well as to export olsr-routes to quagga so that they can be
+redistributed by the quagga-routing-daemons.
+
+Note Sven-Ola: You also need a source distribution of quagga-0.98.5
+or quagga-0.98.6 (that is the current stable). The quagga source tree 
+needs to be patched with quagga-0.98.6-olsr.diff, compiled and installed
+via 'make install'. Because many people will otherwise have compile
+probs, I've added 2 include files in lib/quagga/src/quagga. If you
+want to use another version of quagga, make sure to remove these
+before you compile the olsrd_quagga plugin.
+
+---------------------------------------------------------------------
+PLUGIN PARAMETERS (PlParam)
+---------------------------------------------------------------------
+
+PlParam "redistribute" "<protocol>"
+	where protocol is one of the following:
+	system, kernel, connect, static, rip, ripng, ospf, ospf6,
+	isis, bgp, hsls
+	May be used more then once
+
+PlParam "ExportRoutes" "<only/both>"
+	exportes olsr-routes to quagga or to both, quagga and kernel
+	no routes are exportet if not set.
+
+PlParam "LocalPref" "true"
+        sets the zebra SELECTED-flag on the routes exported to zebra
+	which means these routes are prefered in any case.
+
+PlParam "Distance" "0-255"
+        allowes to set Administrative distance to routes exported 
+	to zebra.
+	
+---------------------------------------------------------------------
+SAMPLE CONFIG
+---------------------------------------------------------------------
+
+add in /etc/olsrd.conf:
+
+LoadPlugin "olsrd_quagga.so.0.2.2"
+{
+	PlParam "redistribute" "ospf"
+	PlParam "redistribute" "bgp"
+	PlParam "ExportRoutes" "only"
+	PlParam "Distance" "125" 
+	PlParam "LocalPref" "false"
+}
+
+
+---------------------------------------------------------------------
+EOF / 8.5.2006
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/secure/README_SECURE olsrd-current/lib/secure/README_SECURE
--- olsrd-0.5.0/lib/secure/README_SECURE	1970-01-01 01:00:00.000000000 +0100
+++ olsrd-current/lib/secure/README_SECURE	2007-04-03 11:48:45.000000000 +0200
@@ -0,0 +1,64 @@
+
+
+Secure OLSR 0.4 implementation notes
+(c)Andreas Tønnesen 2004
+
+This document contains information on how to
+use the secure OLSR plugin with the UniK olsr daemon.
+It does _not_ cover secure OLSR protocol issues.
+
+Lines starting with '# ' indicates shell commands.
+
+NOTES
+
+  The plugin interface and olsrd output buffering was
+  heavily rewritten for the 0.4.8 release. The plugin
+  should work with this release - but has not been
+  tested much.
+
+COMPILING
+
+  To compile simply do:
+  # make
+  This compiles the local MD5 function and the plugin has
+  no external dependencies.
+  If you want the plugin to use SHA-1 using the openssl libs
+  do:
+  # make USE_OPENSSL=1
+
+INSTALLING
+
+  To install:
+  # make install
+
+  This will run ldconfig to update the dynamic linker.
+  It might take a while.
+
+USAGE
+
+  To make olsrd load the secure OLSR plugin add the
+  following in the olsrd configuration file:
+
+LoadPlugin "olsrd_secure.so.0.4"
+{
+    PlParam     "Keyfile"   "FILENAME"
+}
+
+  replacing FILENAME with the full path of the file
+  containing the shared key.
+
+  The plugin uses this shared secret key for signature
+  generation and verification. For nodes to participate 
+  in the OLSR routing domain they need to use the key 
+  used by the other nodes.
+  The key is 128-bits of size and is read from the
+  specified file from the config file or by default from:
+  /etc/olsrd.d/olsrd_secure_key
+
+  Copy the key to this file an all nodes. The plugin
+  will terminate olsrd if this file cannot be found.
+
+  Now start olsrd and the let the plugin do its
+  thing :)
+
+- Andreas
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/secure/SOLSR-README olsrd-current/lib/secure/SOLSR-README
--- olsrd-0.5.0/lib/secure/SOLSR-README	2007-02-10 18:10:19.000000000 +0100
+++ olsrd-current/lib/secure/SOLSR-README	1970-01-01 01:00:00.000000000 +0100
@@ -1,64 +0,0 @@
-
-
-Secure OLSR 0.4 implementation notes
-(c)Andreas Tønnesen 2004
-
-This document contains information on how to
-use the secure OLSR plugin with the UniK olsr daemon.
-It does _not_ cover secure OLSR protocol issues.
-
-Lines starting with '# ' indicates shell commands.
-
-NOTES
-
-  The plugin interface and olsrd output buffering was
-  heavily rewritten for the 0.4.8 release. The plugin
-  should work with this release - but has not been
-  tested much.
-
-COMPILING
-
-  To compile simply do:
-  # make
-  This compiles the local MD5 function and the plugin has
-  no external dependencies.
-  If you want the plugin to use SHA-1 using the openssl libs
-  do:
-  # make USE_OPENSSL=1
-
-INSTALLING
-
-  To install:
-  # make install
-
-  This will run ldconfig to update the dynamic linker.
-  It might take a while.
-
-USAGE
-
-  To make olsrd load the secure OLSR plugin add the
-  following in the olsrd configuration file:
-
-LoadPlugin "olsrd_secure.so.0.4"
-{
-    PlParam     "Keyfile"   "FILENAME"
-}
-
-  replacing FILENAME with the full path of the file
-  containing the shared key.
-
-  The plugin uses this shared secret key for signature
-  generation and verification. For nodes to participate 
-  in the OLSR routing domain they need to use the key 
-  used by the other nodes.
-  The key is 128-bits of size and is read from the
-  specified file from the config file or by default from:
-  /etc/olsrd.d/olsrd_secure_key
-
-  Copy the key to this file an all nodes. The plugin
-  will terminate olsrd if this file cannot be found.
-
-  Now start olsrd and the let the plugin do its
-  thing :)
-
-- Andreas
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/secure/src/olsrd_plugin.c olsrd-current/lib/secure/src/olsrd_plugin.c
--- olsrd-0.5.0/lib/secure/src/olsrd_plugin.c	2005-05-29 14:47:43.000000000 +0200
+++ olsrd-current/lib/secure/src/olsrd_plugin.c	2007-04-20 15:46:03.000000000 +0200
@@ -33,7 +33,7 @@
  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * $Id: olsrd_plugin.c,v 1.10 2005/05/29 12:47:43 br1 Exp $
+ * $Id: olsrd_plugin.c,v 1.11 2007/04/20 13:46:03 bernd67 Exp $
  */
 
 
@@ -63,18 +63,17 @@
  * Do not alter unless you know what you are doing!
  */
 int 
-olsrd_plugin_interface_version()
+olsrd_plugin_interface_version(void)
 {
   return OLSRD_PLUGIN_INTERFACE_VERSION;
 }
 
 
-
 /**
  *Constructor
  */
 static void
-my_init()
+my_init(void)
 {
   /* Print plugin info to stdout */
   /* We cannot use olsr_printf yet! */
@@ -86,7 +85,7 @@
  *Destructor
  */
 static void
-my_fini()
+my_fini(void)
 {
 
   /* Calls the destruction function
@@ -112,7 +111,7 @@
 
 
 int
-olsrd_plugin_init() {
+olsrd_plugin_init(void) {
   /* Calls the initialization function
    * olsr_plugin_init()
    * This function should be present in your
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/secure/src/olsrd_secure.c olsrd-current/lib/secure/src/olsrd_secure.c
--- olsrd-0.5.0/lib/secure/src/olsrd_secure.c	2007-01-31 13:36:49.000000000 +0100
+++ olsrd-current/lib/secure/src/olsrd_secure.c	2007-05-09 19:41:17.000000000 +0200
@@ -33,7 +33,7 @@
  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * $Id: olsrd_secure.c,v 1.21 2007/01/31 12:36:49 bernd67 Exp $
+ * $Id: olsrd_secure.c,v 1.25 2007/05/09 17:41:17 bernd67 Exp $
  */
 
 
@@ -115,7 +115,7 @@
  */
 
 int
-secure_plugin_init()
+secure_plugin_init(void)
 {
   struct interface *ints;
   int i;
@@ -174,7 +174,7 @@
 
 
 int
-plugin_ipc_init()
+plugin_ipc_init(void)
 {
   return 1;
 }
@@ -184,7 +184,7 @@
  * destructor - called at unload
  */
 void
-secure_plugin_exit()
+secure_plugin_exit(void)
 {
 }
 
@@ -193,14 +193,14 @@
  *Scheduled event
  */
 void
-olsr_event()
+olsr_event(void)
 {
 
 }
 
 
 int
-ipc_send(char *data, int size)
+ipc_send(char *data __attribute__((unused)), int size __attribute__((unused)))
 {
   return 1;
 }
@@ -358,7 +358,7 @@
  *
  */
 int
-check_auth(char *pck, int *size)
+check_auth(char *pck, int *size __attribute__((unused)))
 {
 
   olsr_printf(3, "[ENC]Checking packet for challenge response message...\n");
@@ -426,7 +426,7 @@
   
   /* Add timestamp */
   msg->sig.timestamp = htonl(now.tv_sec);
-  olsr_printf(3, "[ENC]timestamp: %d\n", now.tv_sec);
+  olsr_printf(3, "[ENC]timestamp: %ld\n", now.tv_sec);
   
   /* Set the new size */
   *size = *size + sizeof(struct s_olsrmsg);
@@ -593,7 +593,7 @@
       return 0;
     }
 
-  olsr_printf(1, "[ENC]Received timestamp %d diff: %d\n", rec_time, now.tv_sec - rec_time);
+  olsr_printf(1, "[ENC]Received timestamp %ld diff: %ld\n", rec_time, now.tv_sec - rec_time);
 
   /* Remove signature message */
   *size = packetsize;
@@ -684,7 +684,7 @@
   memcpy(&cmsg.destination, new_host, olsr_cnf->ipsize);
   cmsg.challenge = htonl(challenge);
 
-  olsr_printf(3, "[ENC]Size: %d\n", sizeof(struct challengemsg));
+  olsr_printf(3, "[ENC]Size: %lu\n", (unsigned long)sizeof(struct challengemsg));
 
   {
   olsr_u8_t checksum_cache[512 + KEYLENGTH];
@@ -704,7 +704,7 @@
 	      challenge);
 
   /* Add to buffer */
-  net_outbuffer_push(olsr_in_if, (olsr_u8_t *)&cmsg, sizeof(struct challengemsg));
+  net_outbuffer_push(olsr_in_if, &cmsg, sizeof(struct challengemsg));
 
   /* Send the request */
   net_output(olsr_in_if);
@@ -752,7 +752,7 @@
       return 0;
     }
 
-  olsr_printf(3, "[ENC]Challenge: 0x%x\n", ntohl(msg->challenge));
+  olsr_printf(3, "[ENC]Challenge: 0x%lx\n", (unsigned long)ntohl(msg->challenge)); /* ntohl() returns a unsignedlong onwin32 */
 
   /* Check signature */
 
@@ -979,7 +979,7 @@
 	}
     }
 
-  olsr_printf(3, "[ENC]Challenge: 0x%x\n", ntohl(msg->challenge));
+  olsr_printf(3, "[ENC]Challenge: 0x%lx\n", (unsigned long)ntohl(msg->challenge)); /* ntohl() returns a unsignedlong onwin32 */
 
   /* Check signature */
 
@@ -1056,7 +1056,7 @@
 
   /* set timestamp */
   crmsg.timestamp = now.tv_sec;
-  olsr_printf(3, "[ENC]Timestamp %d\n", crmsg.timestamp);
+  olsr_printf(3, "[ENC]Timestamp %ld\n", crmsg.timestamp);
 
   /* Fill subheader */
   memcpy(&crmsg.destination, to, olsr_cnf->ipsize);
@@ -1099,7 +1099,7 @@
 	      challenge);
 
   /* Add to buffer */
-  net_outbuffer_push(olsr_in_if, (olsr_u8_t *)&crmsg, sizeof(struct c_respmsg));
+  net_outbuffer_push(olsr_in_if, &crmsg, sizeof(struct c_respmsg));
   /* Send the request */
   net_output(olsr_in_if);
 
@@ -1135,7 +1135,7 @@
 
   /* set timestamp */
   rrmsg.timestamp = now.tv_sec;
-  olsr_printf(3, "[ENC]Timestamp %d\n", rrmsg.timestamp);
+  olsr_printf(3, "[ENC]Timestamp %ld\n", rrmsg.timestamp);
 
   /* Fill subheader */
   memcpy(&rrmsg.destination, to, olsr_cnf->ipsize);
@@ -1176,7 +1176,7 @@
 	      olsr_ip_to_string(to));
 
   /* add to buffer */
-  net_outbuffer_push(olsr_in_if, (olsr_u8_t *)&rrmsg, sizeof(struct r_respmsg));
+  net_outbuffer_push(olsr_in_if, &rrmsg, sizeof(struct r_respmsg));
 
   /* Send the request */
   net_output(olsr_in_if);
@@ -1218,7 +1218,7 @@
  *@return nada
  */
 void
-timeout_timestamps(void* foo)
+timeout_timestamps(void* foo __attribute__((unused)))
 {
   struct stamp *tmp_list;
   struct stamp *entry_to_delete;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/tas/src/glua.c olsrd-current/lib/tas/src/glua.c
--- olsrd-0.5.0/lib/tas/src/glua.c	2005-11-16 00:46:19.000000000 +0100
+++ olsrd-current/lib/tas/src/glua.c	2007-04-20 15:46:03.000000000 +0200
@@ -37,7 +37,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: glua.c,v 1.3 2005/11/15 23:46:19 tlopatic Exp $
+ * $Id: glua.c,v 1.4 2007/04/20 13:46:03 bernd67 Exp $
  */
 
 #include "lua/lua.h"
@@ -229,7 +229,7 @@
   return 0;
 }
 
-static int luaWriter(lua_State *lua, const void *buff, int len, FILE *file)
+static int luaWriter(lua_State *lua __attribute__((unused)), const void *buff, int len, FILE *file)
 {
   return fwrite(buff, len, 1, file) == 1;
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/tas/src/lib.h olsrd-current/lib/tas/src/lib.h
--- olsrd-0.5.0/lib/tas/src/lib.h	2005-04-12 21:57:26.000000000 +0200
+++ olsrd-current/lib/tas/src/lib.h	2007-04-20 15:46:03.000000000 +0200
@@ -37,9 +37,12 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: lib.h,v 1.2 2005/04/12 19:57:26 tlopatic Exp $
+ * $Id: lib.h,v 1.3 2007/04/20 13:46:03 bernd67 Exp $
  */
 
+#ifndef _OLSRD_TAS_LIB_H
+#define _OLSRD_TAS_LIB_H
+
 #define DEBUG_MESSAGE 1
 #define DEBUG_SESSION 2
 #define DEBUG_CONNECTION 4
@@ -47,10 +50,12 @@
 #define DEBUG_LUA 16
 #define DEBUG_QUANTUM 32
 
-extern void error(char *form, ...);
-extern void debug(int facility, char *form, ...);
+extern void error(char *form, ...) __attribute__((format(printf,1,2)));
+extern void debug(int facility, char *form, ...) __attribute__((format(printf,2,3)));
 extern char *strdupAdd(const char *string, int add);
 extern char *myStrdup(const char *string);
 extern void chomp(char *line, int len);
 extern char *intToString(char *buff, unsigned int val);
 extern int stringToInt(unsigned int *val, const char *buff);
+
+#endif
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/tas/src/lua/lapi.c olsrd-current/lib/tas/src/lua/lapi.c
--- olsrd-0.5.0/lib/tas/src/lua/lapi.c	2005-04-12 19:17:26.000000000 +0200
+++ olsrd-current/lib/tas/src/lua/lapi.c	2007-04-20 15:46:03.000000000 +0200
@@ -1,5 +1,5 @@
 /*
-** $Id: lapi.c,v 1.1 2005/04/12 17:17:26 tlopatic Exp $
+** $Id: lapi.c,v 1.2 2007/04/20 13:46:03 bernd67 Exp $
 ** Lua API
 ** See Copyright Notice in lua.h
 */
@@ -805,7 +805,6 @@
   api_checknelems(L, 1);
   luaG_errormsg(L);
   lua_unlock(L);
-  return 0;  /* to avoid warnings */
 }
 
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/tas/src/lua/lauxlib.c olsrd-current/lib/tas/src/lua/lauxlib.c
--- olsrd-0.5.0/lib/tas/src/lua/lauxlib.c	2005-04-12 19:17:26.000000000 +0200
+++ olsrd-current/lib/tas/src/lua/lauxlib.c	2007-04-20 15:46:03.000000000 +0200
@@ -1,5 +1,5 @@
 /*
-** $Id: lauxlib.c,v 1.1 2005/04/12 17:17:26 tlopatic Exp $
+** $Id: lauxlib.c,v 1.2 2007/04/20 13:46:03 bernd67 Exp $
 ** Auxiliary functions for building Lua libraries
 ** See Copyright Notice in lua.h
 */
@@ -50,11 +50,11 @@
   if (strcmp(ar.namewhat, "method") == 0) {
     narg--;  /* do not count `self' */
     if (narg == 0)  /* error is in the self argument itself? */
-      return luaL_error(L, "calling `%s' on bad self (%s)", ar.name, extramsg);
+      luaL_error(L, "calling `%s' on bad self (%s)", ar.name, extramsg);
   }
   if (ar.name == NULL)
     ar.name = "?";
-  return luaL_error(L, "bad argument #%d to `%s' (%s)",
+  luaL_error(L, "bad argument #%d to `%s' (%s)",
                         narg, ar.name, extramsg);
 }
 
@@ -62,10 +62,11 @@
 LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) {
   const char *msg = lua_pushfstring(L, "%s expected, got %s",
                                     tname, lua_typename(L, lua_type(L,narg)));
-  return luaL_argerror(L, narg, msg);
+  luaL_argerror(L, narg, msg);
 }
 
 
+static void tag_error (lua_State *L, int narg, int tag) __attribute__((noreturn));
 static void tag_error (lua_State *L, int narg, int tag) {
   luaL_typerror(L, narg, lua_typename(L, tag)); 
 }
@@ -91,7 +92,7 @@
   lua_pushvfstring(L, fmt, argp);
   va_end(argp);
   lua_concat(L, 2);
-  return lua_error(L);
+  lua_error(L);
 }
 
 /* }====================================================== */
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/tas/src/lua/lauxlib.h olsrd-current/lib/tas/src/lua/lauxlib.h
--- olsrd-0.5.0/lib/tas/src/lua/lauxlib.h	2005-04-12 19:17:26.000000000 +0200
+++ olsrd-current/lib/tas/src/lua/lauxlib.h	2007-04-20 15:46:03.000000000 +0200
@@ -1,5 +1,5 @@
 /*
-** $Id: lauxlib.h,v 1.1 2005/04/12 17:17:26 tlopatic Exp $
+** $Id: lauxlib.h,v 1.2 2007/04/20 13:46:03 bernd67 Exp $
 ** Auxiliary functions for building Lua libraries
 ** See Copyright Notice in lua.h
 */
@@ -31,8 +31,8 @@
                                const luaL_reg *l, int nup);
 LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *e);
 LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *e);
-LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname);
-LUALIB_API int luaL_argerror (lua_State *L, int numarg, const char *extramsg);
+LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) __attribute__((noreturn));
+LUALIB_API int luaL_argerror (lua_State *L, int numarg, const char *extramsg) __attribute__((noreturn));
 LUALIB_API const char *luaL_checklstring (lua_State *L, int numArg, size_t *l);
 LUALIB_API const char *luaL_optlstring (lua_State *L, int numArg,
                                            const char *def, size_t *l);
@@ -48,7 +48,7 @@
 LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname);
 
 LUALIB_API void luaL_where (lua_State *L, int lvl);
-LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...);
+LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) __attribute__((noreturn));
 
 LUALIB_API int luaL_findstring (const char *st, const char *const lst[]);
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/tas/src/lua/lbaselib.c olsrd-current/lib/tas/src/lua/lbaselib.c
--- olsrd-0.5.0/lib/tas/src/lua/lbaselib.c	2005-04-12 19:17:26.000000000 +0200
+++ olsrd-current/lib/tas/src/lua/lbaselib.c	2007-04-20 15:46:03.000000000 +0200
@@ -1,5 +1,5 @@
 /*
-** $Id: lbaselib.c,v 1.1 2005/04/12 17:17:26 tlopatic Exp $
+** $Id: lbaselib.c,v 1.2 2007/04/20 13:46:03 bernd67 Exp $
 ** Basic library
 ** See Copyright Notice in lua.h
 */
@@ -75,7 +75,7 @@
   return 1;
 }
 
-
+static int luaB_error (lua_State *L)  __attribute__((noreturn));
 static int luaB_error (lua_State *L) {
   int level = luaL_optint(L, 2, 1);
   luaL_checkany(L, 1);
@@ -86,7 +86,7 @@
     lua_pushvalue(L, 1);
     lua_concat(L, 2);
   }
-  return lua_error(L);
+  lua_error(L);
 }
 
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/tas/src/lua/ldebug.c olsrd-current/lib/tas/src/lua/ldebug.c
--- olsrd-0.5.0/lib/tas/src/lua/ldebug.c	2005-04-12 19:17:26.000000000 +0200
+++ olsrd-current/lib/tas/src/lua/ldebug.c	2007-04-20 15:46:03.000000000 +0200
@@ -1,5 +1,5 @@
 /*
-** $Id: ldebug.c,v 1.1 2005/04/12 17:17:26 tlopatic Exp $
+** $Id: ldebug.c,v 1.2 2007/04/20 13:46:03 bernd67 Exp $
 ** Debug Interface
 ** See Copyright Notice in lua.h
 */
@@ -547,7 +547,6 @@
     luaG_runerror(L, "attempt to compare two %s values", t1);
   else
     luaG_runerror(L, "attempt to compare %s with %s", t1, t2);
-  return 0;
 }
 
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/tas/src/lua/ldebug.h olsrd-current/lib/tas/src/lua/ldebug.h
--- olsrd-0.5.0/lib/tas/src/lua/ldebug.h	2005-04-12 19:17:26.000000000 +0200
+++ olsrd-current/lib/tas/src/lua/ldebug.h	2007-04-20 15:46:03.000000000 +0200
@@ -1,5 +1,5 @@
 /*
-** $Id: ldebug.h,v 1.1 2005/04/12 17:17:26 tlopatic Exp $
+** $Id: ldebug.h,v 1.2 2007/04/20 13:46:03 bernd67 Exp $
 ** Auxiliary functions from Debug Interface module
 ** See Copyright Notice in lua.h
 */
@@ -19,12 +19,12 @@
 
 
 void luaG_inithooks (lua_State *L);
-void luaG_typeerror (lua_State *L, const TObject *o, const char *opname);
-void luaG_concaterror (lua_State *L, StkId p1, StkId p2);
-void luaG_aritherror (lua_State *L, const TObject *p1, const TObject *p2);
-int luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2);
-void luaG_runerror (lua_State *L, const char *fmt, ...);
-void luaG_errormsg (lua_State *L);
+void luaG_typeerror (lua_State *L, const TObject *o, const char *opname) __attribute__((noreturn));
+void luaG_concaterror (lua_State *L, StkId p1, StkId p2) __attribute__((noreturn));
+void luaG_aritherror (lua_State *L, const TObject *p1, const TObject *p2) __attribute__((noreturn));
+int luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) __attribute__((noreturn));
+void luaG_runerror (lua_State *L, const char *fmt, ...) __attribute__((noreturn));
+void luaG_errormsg (lua_State *L) __attribute__((noreturn));
 int luaG_checkcode (const Proto *pt);
 
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/tas/src/lua/ldo.h olsrd-current/lib/tas/src/lua/ldo.h
--- olsrd-0.5.0/lib/tas/src/lua/ldo.h	2005-04-12 19:17:26.000000000 +0200
+++ olsrd-current/lib/tas/src/lua/ldo.h	2007-04-20 15:46:03.000000000 +0200
@@ -1,5 +1,5 @@
 /*
-** $Id: ldo.h,v 1.1 2005/04/12 17:17:26 tlopatic Exp $
+** $Id: ldo.h,v 1.2 2007/04/20 13:46:03 bernd67 Exp $
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 */
@@ -53,7 +53,7 @@
 void luaD_reallocstack (lua_State *L, int newsize);
 void luaD_growstack (lua_State *L, int n);
 
-void luaD_throw (lua_State *L, int errcode);
+void luaD_throw (lua_State *L, int errcode) __attribute__((noreturn));
 int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
 
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/tas/src/lua/liolib.c olsrd-current/lib/tas/src/lua/liolib.c
--- olsrd-0.5.0/lib/tas/src/lua/liolib.c	2005-04-12 19:17:26.000000000 +0200
+++ olsrd-current/lib/tas/src/lua/liolib.c	2007-04-20 15:46:03.000000000 +0200
@@ -1,5 +1,5 @@
 /*
-** $Id: liolib.c,v 1.1 2005/04/12 17:17:26 tlopatic Exp $
+** $Id: liolib.c,v 1.2 2007/04/20 13:46:03 bernd67 Exp $
 ** Standard I/O (and system) library
 ** See Copyright Notice in lua.h
 */
@@ -50,6 +50,8 @@
 
 
 
+static int io_exit (lua_State *L) __attribute__((noreturn));
+
 
 /*
 ** {======================================================
@@ -555,10 +557,15 @@
 }
 
 
+#if !USE_TMPNAME
+static int io_tmpname (lua_State *L) __attribute__((noreturn));
+#else
+static int io_tmpname (lua_State *L);
+#endif
+
 static int io_tmpname (lua_State *L) {
 #if !USE_TMPNAME
   luaL_error(L, "`tmpname' not supported");
-  return 0;
 #else
   char buff[L_tmpnam];
   if (tmpnam(buff) != buff)
@@ -714,7 +721,6 @@
 
 static int io_exit (lua_State *L) {
   exit(luaL_optint(L, 1, EXIT_SUCCESS));
-  return 0;  /* to avoid warnings */
 }
 
 static const luaL_reg syslib[] = {
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/tas/src/lua/llex.c olsrd-current/lib/tas/src/lua/llex.c
--- olsrd-0.5.0/lib/tas/src/lua/llex.c	2005-04-12 19:17:26.000000000 +0200
+++ olsrd-current/lib/tas/src/lua/llex.c	2007-04-20 15:46:03.000000000 +0200
@@ -1,5 +1,5 @@
 /*
-** $Id: llex.c,v 1.1 2005/04/12 17:17:26 tlopatic Exp $
+** $Id: llex.c,v 1.2 2007/04/20 13:46:03 bernd67 Exp $
 ** Lexical Analyzer
 ** See Copyright Notice in lua.h
 */
@@ -21,9 +21,10 @@
 #include "lzio.h"
 
 
-
 #define next(LS) (LS->current = zgetc(LS->z))
 
+static void luaX_error (LexState *ls, const char *s, const char *token) __attribute__((noreturn));
+static void luaX_lexerror (LexState *ls, const char *s, int token) __attribute__((noreturn));
 
 
 /* ORDER RESERVED */
@@ -58,7 +59,6 @@
   }
 }
 
-
 void luaX_errorline (LexState *ls, const char *s, const char *token, int line) {
   lua_State *L = ls->L;
   char buff[MAXSRC];
@@ -67,7 +67,6 @@
   luaD_throw(L, LUA_ERRSYNTAX);
 }
 
-
 static void luaX_error (LexState *ls, const char *s, const char *token) {
   luaX_errorline(ls, s, token, ls->linenumber);
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/tas/src/lua/llex.h olsrd-current/lib/tas/src/lua/llex.h
--- olsrd-0.5.0/lib/tas/src/lua/llex.h	2005-04-12 19:17:26.000000000 +0200
+++ olsrd-current/lib/tas/src/lua/llex.h	2007-04-20 15:46:03.000000000 +0200
@@ -1,5 +1,5 @@
 /*
-** $Id: llex.h,v 1.1 2005/04/12 17:17:26 tlopatic Exp $
+** $Id: llex.h,v 1.2 2007/04/20 13:46:03 bernd67 Exp $
 ** Lexical Analyzer
 ** See Copyright Notice in lua.h
 */
@@ -67,8 +67,8 @@
 void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source);
 int luaX_lex (LexState *LS, SemInfo *seminfo);
 void luaX_checklimit (LexState *ls, int val, int limit, const char *msg);
-void luaX_syntaxerror (LexState *ls, const char *s);
-void luaX_errorline (LexState *ls, const char *s, const char *token, int line);
+void luaX_syntaxerror (LexState *ls, const char *s) __attribute__((noreturn));
+void luaX_errorline (LexState *ls, const char *s, const char *token, int line) __attribute__((noreturn));
 const char *luaX_token2str (LexState *ls, int token);
 
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/tas/src/lua/lparser.c olsrd-current/lib/tas/src/lua/lparser.c
--- olsrd-0.5.0/lib/tas/src/lua/lparser.c	2005-04-12 19:17:27.000000000 +0200
+++ olsrd-current/lib/tas/src/lua/lparser.c	2007-04-20 15:46:03.000000000 +0200
@@ -1,5 +1,5 @@
 /*
-** $Id: lparser.c,v 1.1 2005/04/12 17:17:27 tlopatic Exp $
+** $Id: lparser.c,v 1.2 2007/04/20 13:46:03 bernd67 Exp $
 ** Lua Parser
 ** See Copyright Notice in lua.h
 */
@@ -51,6 +51,7 @@
 */
 static void chunk (LexState *ls);
 static void expr (LexState *ls, expdesc *v);
+static void error_expected (LexState *ls, int token) __attribute__((noreturn));
 
 
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/tas/src/lua/lua.h olsrd-current/lib/tas/src/lua/lua.h
--- olsrd-0.5.0/lib/tas/src/lua/lua.h	2005-04-12 19:17:27.000000000 +0200
+++ olsrd-current/lib/tas/src/lua/lua.h	2007-04-20 15:46:03.000000000 +0200
@@ -1,5 +1,5 @@
 /*
-** $Id: lua.h,v 1.1 2005/04/12 17:17:27 tlopatic Exp $
+** $Id: lua.h,v 1.2 2007/04/20 13:46:03 bernd67 Exp $
 ** Lua - An Extensible Extension Language
 ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil
 ** http://www.lua.org	mailto:info@lua.org
@@ -213,7 +213,7 @@
 
 LUA_API const char *lua_version (void);
 
-LUA_API int   lua_error (lua_State *L);
+LUA_API int   lua_error (lua_State *L) __attribute__((noreturn));
 
 LUA_API int   lua_next (lua_State *L, int idx);
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/tas/src/lua/lundump.c olsrd-current/lib/tas/src/lua/lundump.c
--- olsrd-0.5.0/lib/tas/src/lua/lundump.c	2005-04-12 19:17:35.000000000 +0200
+++ olsrd-current/lib/tas/src/lua/lundump.c	2007-04-20 15:46:03.000000000 +0200
@@ -1,5 +1,5 @@
 /*
-** $Id: lundump.c,v 1.1 2005/04/12 17:17:35 tlopatic Exp $
+** $Id: lundump.c,v 1.2 2007/04/20 13:46:03 bernd67 Exp $
 ** load pre-compiled Lua chunks
 ** See Copyright Notice in lua.h
 */
@@ -26,6 +26,8 @@
  const char* name;
 } LoadState;
 
+static void unexpectedEOZ (LoadState* S) __attribute__((noreturn));
+
 static void unexpectedEOZ (LoadState* S)
 {
  luaG_runerror(S->L,"unexpected end of file in %s",S->name);
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/tas/src/os_unix.c olsrd-current/lib/tas/src/os_unix.c
--- olsrd-0.5.0/lib/tas/src/os_unix.c	2005-11-16 00:46:20.000000000 +0100
+++ olsrd-current/lib/tas/src/os_unix.c	2007-04-20 01:01:32.000000000 +0200
@@ -37,7 +37,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: os_unix.c,v 1.5 2005/11/15 23:46:20 tlopatic Exp $
+ * $Id: os_unix.c,v 1.6 2007/04/19 23:01:32 bernd67 Exp $
  */
 
 #if defined linux
@@ -107,7 +107,7 @@
 
 void os_now(struct timeStamp *timeStamp)
 {
-  time((time_t *)&timeStamp->time);
+  timeStamp->time = time(NULL);
 }
 
 int timedOut(struct timeStamp *timeStamp, int sec)
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/tas/src/plugin.c olsrd-current/lib/tas/src/plugin.c
--- olsrd-0.5.0/lib/tas/src/plugin.c	2006-01-07 09:17:45.000000000 +0100
+++ olsrd-current/lib/tas/src/plugin.c	2007-04-20 15:46:03.000000000 +0200
@@ -37,7 +37,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: plugin.c,v 1.7 2006/01/07 08:17:45 kattemat Exp $
+ * $Id: plugin.c,v 1.8 2007/04/20 13:46:03 bernd67 Exp $
  */
 
 #include <string.h>
@@ -465,7 +465,7 @@
   return 4;
 }
 
-int olsrd_plugin_init()
+int olsrd_plugin_init(void)
 {
   ipAddrLen = olsr_cnf->ipsize;
   mainAddr = &olsr_cnf->main_addr;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/txtinfo/src/olsrd_plugin.c olsrd-current/lib/txtinfo/src/olsrd_plugin.c
--- olsrd-0.5.0/lib/txtinfo/src/olsrd_plugin.c	2007-01-31 13:38:26.000000000 +0100
+++ olsrd-current/lib/txtinfo/src/olsrd_plugin.c	2007-04-20 15:46:04.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_plugin.c,v 1.1 2007/01/31 12:38:26 bernd67 Exp $
+ * $Id: olsrd_plugin.c,v 1.2 2007/04/20 13:46:04 bernd67 Exp $
  */
 
 /*
@@ -78,7 +78,7 @@
  *Constructor
  */
 static void
-my_init()
+my_init(void)
 {
   /* Print plugin info to stdout */
   printf("%s\n", MOD_DESC);
@@ -96,7 +96,7 @@
  *Destructor
  */
 static void
-my_fini()
+my_fini(void)
 {
   /* Calls the destruction function
    * olsr_plugin_exit()
@@ -109,7 +109,7 @@
 
 
 int 
-olsrd_plugin_interface_version()
+olsrd_plugin_interface_version(void)
 {
   return PLUGIN_INTERFACE_VERSION;
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/lib/txtinfo/src/olsrd_txtinfo.c olsrd-current/lib/txtinfo/src/olsrd_txtinfo.c
--- olsrd-0.5.0/lib/txtinfo/src/olsrd_txtinfo.c	2007-03-27 05:59:27.000000000 +0200
+++ olsrd-current/lib/txtinfo/src/olsrd_txtinfo.c	2007-05-09 19:29:53.000000000 +0200
@@ -40,7 +40,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_txtinfo.c,v 1.2 2007/03/27 03:59:27 tlopatic Exp $
+ * $Id: olsrd_txtinfo.c,v 1.6 2007/05/09 17:29:53 bernd67 Exp $
  */
 
 /*
@@ -101,21 +101,24 @@
 static void
 ipc_action(int);
 
-static void inline
+static void
 ipc_print_neigh_link(void);
 
-static void inline
+static void
 ipc_print_routes(void);
 
-static void inline
+static void
 ipc_print_topology(void);
 
-static void inline
+static void
 ipc_print_hna(void);
 
+static void
+ipc_print_mid(void);
+
 #define TXT_IPC_BUFSIZE 256
 static int 
-ipc_sendf(const char* format, ...);
+ipc_sendf(const char* format, ...) __attribute__((format(printf, 1, 2)));
 
 /**
  *Do initialization here
@@ -124,7 +127,7 @@
  *function in uolsrd_plugin.c
  */
 int
-olsrd_plugin_init()
+olsrd_plugin_init(void)
 {
   /* Initial IPC value */
   ipc_open = 0;
@@ -139,7 +142,7 @@
  * destructor - called at unload
  */
 void
-olsr_plugin_exit()
+olsr_plugin_exit(void)
 {
   if(ipc_open)
     close(ipc_socket);
@@ -148,7 +151,7 @@
 
 
 static int
-plugin_ipc_init()
+plugin_ipc_init(void)
 {
   struct sockaddr_in sin;
   olsr_u32_t yes = 1;
@@ -239,6 +242,10 @@
     }
   else
     {
+      fd_set rfds;
+      struct timeval tv = {0,0};
+      int neighonly = 0;
+
       addr = inet_ntoa(pin.sin_addr);
       if(ntohl(pin.sin_addr.s_addr) != ntohl(ipc_accept_ip.s_addr))
 	{
@@ -254,14 +261,11 @@
 #endif
       
       /* purge read buffer to prevent blocking on linux*/
-      fd_set rfds;
       FD_ZERO(&rfds);
-      FD_SET(ipc_connection, &rfds);
-      struct timeval tv = {0,0};
-      int neighonly = 0;
+      FD_SET((unsigned int)ipc_connection, &rfds); /* Win32 needs the cast here */
       if(select(ipc_connection+1, &rfds, NULL, NULL, &tv)) {
         char requ[128];
-        ssize_t s = recv(ipc_connection, &requ, sizeof(requ), 0);
+        ssize_t s = recv(ipc_connection, (void*)&requ, sizeof(requ), 0); /* Win32 needs the cast here */
         if (0 < s) {
           requ[s] = 0;
           /* To print out neighbours only on the Freifunk Status
@@ -280,7 +284,7 @@
   }
 }
 
-static void inline
+static void
 ipc_print_neigh_link(void)
 {
   struct neighbor_entry *neigh;
@@ -339,7 +343,7 @@
 }
 
 
-static void inline
+static void
 ipc_print_routes(void)
 {
   int size = 0, index;
@@ -383,7 +387,7 @@
 
 }
 
-static void inline
+static void
 ipc_print_topology(void)
 {
   olsr_u8_t index;
@@ -420,20 +424,21 @@
   ipc_sendf("\n");
 }
 
-static void inline
+static void
 ipc_print_hna(void)
 {
   int size;
   olsr_u8_t index;
   struct hna_entry *tmp_hna;
   struct hna_net *tmp_net;
+  struct hna4_entry *hna4;
+  struct hna6_entry *hna6;
 
   size = 0;
 
   ipc_sendf("Table: HNA\nNetwork\tNetmask\tGateway\n");
 
   /* Announced HNA entries */
-	struct hna4_entry *hna4;
 	for(hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next)
 	  {
 			ipc_sendf("%s\t%s\t%s\n",
@@ -441,7 +446,6 @@
 			  olsr_ip_to_string(&hna4->netmask),
 				olsr_ip_to_string(&olsr_cnf->main_addr));
 	  }
-	struct hna6_entry *hna6;
 	for(hna6 = olsr_cnf->hna6_entries; hna6; hna6 = hna6->next)
 	  {
 			ipc_sendf("%s\t%d\t%s\n",
@@ -485,6 +489,46 @@
 
 }
 
+static void
+ipc_print_mid(void)
+{
+    olsr_u8_t index;
+    unsigned short is_first;
+    struct mid_entry *entry;
+    struct mid_address *alias;
+
+    ipc_sendf("Table: MID\nIP\tAliases\n");
+
+    /* MID */
+    for( index = 0; index < HASHSIZE; index++ )
+    {
+        entry = mid_set[index].next;
+
+        while( entry != &mid_set[index] )
+        {
+            ipc_sendf( olsr_ip_to_string( &entry->main_addr ) );
+            alias = entry->aliases;
+            is_first = 1;
+
+            while( alias )
+            {
+                ipc_sendf( "%s%s",
+                    ( is_first ? "\t" : ";" ),
+                    olsr_ip_to_string( &alias->alias )
+                );
+
+                alias = alias->next_alias;
+                is_first = 0;
+            }
+
+            entry = entry->next;
+            ipc_sendf("\n");
+        }
+    }
+
+	ipc_sendf("\n");
+}
+
 
 static void 
 send_info(int neighonly)
@@ -505,6 +549,9 @@
  	/* hna */
 	if (!neighonly) ipc_print_hna();
 
+ 	/* mid */
+	if (!neighonly) ipc_print_mid();
+
 	/* routes */
 	if (!neighonly) ipc_print_routes();
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/make/guess_os.sh olsrd-current/make/guess_os.sh
--- olsrd-0.5.0/make/guess_os.sh	2005-12-29 20:48:43.000000000 +0100
+++ olsrd-current/make/guess_os.sh	2007-05-14 01:44:24.000000000 +0200
@@ -1,11 +1,6 @@
 #!/bin/sh
 
 if test -n "$OS"; then
-	# cygwin exports the OS environment vaiable - fix it. 
-	# otherwiese accept the user supplied OS
-	case "$OS" in
-		Windows*)	OS=win32 ;;
-	esac
 	echo $OS;
 	exit;
 else
@@ -17,7 +12,7 @@
 		freebsd*)	arch=fbsd ;;
 		netbsd*)	arch=nbsd ;;
 		openbsd*)	arch=obsd ;;
-		darwin*)		arch=osx ;;
+		darwin*)	arch=osx ;;
 		cygwin_*)	arch=win32 ;;
 		Windows_*)	arch=win32 ;;
 		*)		arch="UNKNOWN" ;;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/make/Makefile.linux olsrd-current/make/Makefile.linux
--- olsrd-0.5.0/make/Makefile.linux	2007-02-10 20:59:51.000000000 +0100
+++ olsrd-current/make/Makefile.linux	2007-04-27 13:41:25.000000000 +0200
@@ -22,6 +22,9 @@
 ifeq ($(ARCH),x86_64)
 GENERATE_PIC = true
 endif
+ifeq ($(ARCH),alpha)
+GENERATE_PIC = true
+endif
 
 ifdef GENERATE_PIC
 CFLAGS +=	-fPIC
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/Makefile olsrd-current/Makefile
--- olsrd-0.5.0/Makefile	2007-04-02 12:02:35.000000000 +0200
+++ olsrd-current/Makefile	2007-05-01 23:36:50.000000000 +0200
@@ -35,15 +35,17 @@
 # to the project. For more information see the website or contact
 # the copyright holders.
 #
-# $Id: Makefile,v 1.78 2007/04/02 09:40:48 tlopatic Exp $
+# $Id: Makefile,v 1.84 2007/05/01 21:36:50 bernd67 Exp $
 
-VERS =		0.5.0
-
-CFLAGS +=	-DVERSION=\"$(VERS)\"
+VERS =		0.5.1pre
 
 TOPDIR = .
 include Makefile.inc
 
+CFLAGS +=	-DVERSION=\"$(VERS)\"
+
+MAKECMD = $(MAKE) OS="$(OS)" WARNINGS="$(WARNINGS)"
+
 LIBS +=		$(OS_LIB_DYNLOAD)
 
 ifeq ($(OS), win32)
@@ -62,27 +64,26 @@
 		$(CC) $(LDFLAGS) -o $@ $(OBJS) $(CFGOBJS) $(LIBS)
 
 cfgparser:	$(CFGDEPS)
-		$(MAKE) -C $(CFGDIR)
+		$(MAKECMD) -C $(CFGDIR)
 
 switch:		
-		$(MAKE) -C $(SWITCHDIR)
+		$(MAKECMD) -C $(SWITCHDIR)
 
 $(CFGOBJS):
-		$(MAKE) -C $(CFGDIR)
+		$(MAKECMD) -C $(CFGDIR)
 
 .PHONY: help libs clean_libs libs_clean clean uberclean install_libs libs_install install_bin install_olsrd install build_all install_all clean_all
 
 clean:
 		-rm -f $(OBJS) $(SRCS:%.c=%.d) olsrd olsrd.exe
-		$(MAKE) -C $(CFGDIR) clean
-		$(MAKE) -C $(SWITCHDIR) clean
+		$(MAKECMD) -C $(CFGDIR) clean
+		$(MAKECMD) -C $(SWITCHDIR) clean
 
 uberclean:	clean clean_libs
 		-rm -f $(TAGFILE)
-		-rm -f src/*.[od~] 
-		-rm -f src/linux/*.[od~] src/unix/*.[od~] src/win32/*.[od~] src/bsd/*.[od~]
-		$(MAKE) -C $(CFGDIR) uberclean
-		$(MAKE) -C $(SWITCHDIR) clean
+		find . \( -name '*.[od]' -o -name '*~' \) -print | xargs -r rm -f
+		$(MAKECMD) -C $(CFGDIR) uberclean
+		$(MAKECMD) -C $(SWITCHDIR) clean
 
 install: install_olsrd
 
@@ -123,60 +124,60 @@
 #
 
 libs: 
-		$(MAKE) -C lib LIBDIR=$(LIBDIR)
+		$(MAKECMD) -C lib LIBDIR=$(LIBDIR)
 
 libs_clean clean_libs:
-		$(MAKE) -C lib LIBDIR=$(LIBDIR) clean
+		$(MAKECMD) -C lib LIBDIR=$(LIBDIR) clean
 
 libs_install install_libs:
-		$(MAKE) -C lib LIBDIR=$(LIBDIR) install
+		$(MAKECMD) -C lib LIBDIR=$(LIBDIR) install
 
 httpinfo:
-		$(MAKE) -C lib/httpinfo clean
-		$(MAKE) -C lib/httpinfo 
-		$(MAKE) -C lib/httpinfo DESTDIR=$(DESTDIR) install 
+		$(MAKECMD) -C lib/httpinfo clean
+		$(MAKECMD) -C lib/httpinfo 
+		$(MAKECMD) -C lib/httpinfo DESTDIR=$(DESTDIR) install 
 
 tas:
-		$(MAKE) -C lib/tas clean
-		$(MAKE) -C lib/tas DESTDIR=$(DESTDIR) install
+		$(MAKECMD) -C lib/tas clean
+		$(MAKECMD) -C lib/tas DESTDIR=$(DESTDIR) install
 
 dot_draw:
-		$(MAKE) -C lib/dot_draw clean
-		$(MAKE) -C lib/dot_draw DESTDIR=$(DESTDIR) install
+		$(MAKECMD) -C lib/dot_draw clean
+		$(MAKECMD) -C lib/dot_draw DESTDIR=$(DESTDIR) install
 
 nameservice:
-		$(MAKE) -C lib/nameservice clean
-		$(MAKE) -C lib/nameservice DESTDIR=$(DESTDIR) install
+		$(MAKECMD) -C lib/nameservice clean
+		$(MAKECMD) -C lib/nameservice DESTDIR=$(DESTDIR) install
 
 dyn_gw:
-		$(MAKE) -C lib/dyn_gw clean
-		$(MAKE) -C lib/dyn_gw
-		$(MAKE) -C lib/dyn_gw DESTDIR=$(DESTDIR) install
+		$(MAKECMD) -C lib/dyn_gw clean
+		$(MAKECMD) -C lib/dyn_gw
+		$(MAKECMD) -C lib/dyn_gw DESTDIR=$(DESTDIR) install
 
 dyn_gw_plain:
-		$(MAKE) -C lib/dyn_gw_plain clean
-		$(MAKE) -C lib/dyn_gw_plain
-		$(MAKE) -C lib/dyn_gw_plain DESTDIR=$(DESTDIR) install
+		$(MAKECMD) -C lib/dyn_gw_plain clean
+		$(MAKECMD) -C lib/dyn_gw_plain
+		$(MAKECMD) -C lib/dyn_gw_plain DESTDIR=$(DESTDIR) install
 
 secure:
-		$(MAKE) -C lib/secure clean
-		$(MAKE) -C lib/secure
-		$(MAKE) -C lib/secure DESTDIR=$(DESTDIR) install
+		$(MAKECMD) -C lib/secure clean
+		$(MAKECMD) -C lib/secure
+		$(MAKECMD) -C lib/secure DESTDIR=$(DESTDIR) install
 
 pgraph:
-		$(MAKE) -C lib/pgraph clean
-		$(MAKE) -C lib/pgraph 
-		$(MAKE) -C lib/pgraph DESTDIR=$(DESTDIR) install 
+		$(MAKECMD) -C lib/pgraph clean
+		$(MAKECMD) -C lib/pgraph 
+		$(MAKECMD) -C lib/pgraph DESTDIR=$(DESTDIR) install 
 
 bmf:
-		$(MAKE) -C lib/bmf clean
-		$(MAKE) -C lib/bmf 
-		$(MAKE) -C lib/bmf DESTDIR=$(DESTDIR) install 
+		$(MAKECMD) -C lib/bmf clean
+		$(MAKECMD) -C lib/bmf 
+		$(MAKECMD) -C lib/bmf DESTDIR=$(DESTDIR) install 
 
 quagga:
-		$(MAKE) -C lib/quagga clean
-		$(MAKE) -C lib/quagga 
-		$(MAKE) -C lib/quagga DESTDIR=$(DESTDIR) install 
+		$(MAKECMD) -C lib/quagga clean
+		$(MAKECMD) -C lib/quagga 
+		$(MAKECMD) -C lib/quagga DESTDIR=$(DESTDIR) install 
 
 
 build_all:	cfgparser olsrd libs
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/Makefile.inc olsrd-current/Makefile.inc
--- olsrd-0.5.0/Makefile.inc	2007-02-05 22:25:49.000000000 +0100
+++ olsrd-current/Makefile.inc	2007-05-14 01:44:23.000000000 +0200
@@ -1,6 +1,10 @@
 # programs
-CCACHE =        $(shell sh -c "type -path ccache")
+CCACHE ?=       $(shell sh -c "type -path ccache")
+ifeq ($(origin CC),default)
+CC = 		$(CCACHE) gcc
+else
 CC ?= 		$(CCACHE) gcc
+endif
 STRIP ?=	strip
 BISON ?=	bison
 FLEX ?=		flex
@@ -20,9 +24,31 @@
 
 # add gcc warnings and optimizations if CFLAGS not set
 ifndef CFLAGS
-CFLAGS +=	-Wall -Wmissing-prototypes -Wstrict-prototypes \
-		-Wmissing-declarations -Wsign-compare
-CFLAGS +=	-O2 -g
+ifndef WARNINGS
+WARNINGS +=	-Wall
+WARNINGS +=	-Wextra
+WARNINGS +=	-Wold-style-definition
+WARNINGS +=	-Wdeclaration-after-statement
+WARNINGS +=	-Wmissing-prototypes
+WARNINGS +=	-Wstrict-prototypes
+WARNINGS +=	-Wmissing-declarations
+WARNINGS +=	-Wsign-compare
+WARNINGS +=	-Waggregate-return
+WARNINGS +=	-Wmissing-noreturn
+WARNINGS +=	-Wmissing-format-attribute
+WARNINGS +=	-Wno-multichar
+WARNINGS +=	-Wno-deprecated-declarations
+#WARNINGS +=	-Wredundant-decls
+WARNINGS +=	-Wnested-externs
+#WARNINGS +=	-Wunreachable-code
+WARNINGS +=	-Winline
+WARNINGS +=	-Wdisabled-optimization
+#WARNINGS +=	-Werror
+WARNINGS :=	$(shell CC="$(CC)" $(TOPDIR)/gcc-warnings $(WARNINGS))
+endif
+CFLAGS +=	$(WARNINGS)
+CFLAGS +=	-O2
+CFLAGS +=	-g
 endif
 
 ifdef OLSRD_PLUGIN
@@ -44,7 +70,12 @@
 all: default_target
 
 # OS detection
-OS =		$(shell sh $(TOPDIR)/make/guess_os.sh)
+ifeq ($(OS),Windows_NT)
+OS = win32
+endif
+ifeq ($(OS),)
+OS :=		$(shell sh $(TOPDIR)/make/guess_os.sh)
+endif
 ifeq ($(OS),UNKNOWN)
 all: help
 else
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/README olsrd-current/README
--- olsrd-0.5.0/README	2007-02-05 22:49:43.000000000 +0100
+++ olsrd-current/README	2007-04-03 10:46:44.000000000 +0200
@@ -1,6 +1,6 @@
 
 +====================================================================+
-| README - olsr.org OLSR daemon 0.4.10, 23.11.05                     |
+| README - olsr.org OLSR daemon 0.5.0, 02.04.2007                    |
 +====================================================================+
 
 Andreas Tonnesen(andreto@olsr.org)
@@ -135,11 +135,6 @@
     shared key can participate in the routing.
     You need to have the OpenSSL libs installed to use this plugin.
 
-  - Power plugin. A plugin that uses OLSRs MPR flooding to spread information
-    about the power status of nodes. Meant as an example plugin for code
-    reference only.
-
-
 ========================
  * LINK QUALITY ROUTING
 ========================
@@ -153,11 +148,17 @@
  * KNOWN PROBLEMS
 ==================
 
+There is no synchronization concept (and thus - and for Gods sake -  no
+code). Some plugins use threads for concurrency so this should be solved.
 
 ===============
  * FUTURE WORK
 ===============
 
+Future work concentrates on reduction of ressource (ab)use nad to make
+it more scalable. Of course additional useful plugins are always
+appreciated.
+
 Future releases of the 0.4 series will be maintainance releases focused
 on bugfixing. Work will soon begin on a 0.5 series where we will focus
 much more on new ideas. 0.4 and 0.5 might coexist for some time. 
@@ -202,14 +203,18 @@
 olsr_switch	+/+	+/+	+/+	+/+	+/+	?
 ------------------------------------------------------------
 PLUGINS
+bmf		+/+	+/?	+/+	+/+	+/+	?
 dot_draw	+/+	+/?	+/+	+/+	+/+	?
 dyn_gw		+/+	+/?	+/-	+/-	+/-	?
+dyn_gw_plain	+/+	+/?	+/-	+/-	+/-	?
 httpinfo	+/+	+/+	+/+	+/+	+/+	?
 mini		+/+	+/?	+/+	+/+	+/+	?
 nameservice	+/+	+/?	+/+	+/+	+/+	?
-powerinfo	+/+	+/+	+/-	+/-	+/-	?
+pgraph		+/+	+/+	+/+	+/+	+/+	?
+quagga		+/+	-/-	+/+	+/+	+/+	?
 secure		+/+	+/+	+/+	+/+	+/+	?
 tas		+/+	-	-	-	-	?
+txtinfo		+/+	+/+	+/+	+/+	+/+	?
 ------------------------------------------------------------
 
 LEGEND:   +/+ = compiles/runs
@@ -439,4 +444,4 @@
 installing works in the same was as on FreeBSD.
 
 
-$Id: README,v 1.17 2007/02/05 21:49:43 bernd67 Exp $
+$Id: README,v 1.18 2007/04/03 08:46:44 bernd67 Exp $
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/bsd/kernel_routes.c olsrd-current/src/bsd/kernel_routes.c
--- olsrd-0.5.0/src/bsd/kernel_routes.c	2007-02-14 10:09:16.000000000 +0100
+++ olsrd-current/src/bsd/kernel_routes.c	2007-05-02 09:41:20.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: kernel_routes.c,v 1.9 2007/02/14 09:09:16 kattemat Exp $
+ * $Id: kernel_routes.c,v 1.11 2007/05/02 07:41:20 bernd67 Exp $
  */
 
 
@@ -68,7 +68,7 @@
   inet_ntop(AF_INET, &dest->rt_router.v4, Str3, 16);
 
   OLSR_PRINTF(1, "%s IPv4 route to %s/%s via %s.\n",
-    (add != 0) ? "Adding" : "Removing", Str1, Str2, Str3)
+    (add != 0) ? "Adding" : "Removing", Str1, Str2, Str3);
 
   memset(buff, 0, sizeof (buff));
   memset(&sin, 0, sizeof (sin));
@@ -184,8 +184,8 @@
   inet_ntop(AF_INET6, &dest->rt_dst.v6, Str1, 40);
   inet_ntop(AF_INET6, &dest->rt_router.v6, Str2, 40);
 
-  OLSR_PRINTF(1, "%s IPv6 route to %s/%d via %s.\n",
-    (add != 0) ? "Adding" : "Removing", Str1, dest->rt_mask.v6, Str2)
+  OLSR_PRINTF(1, "%s IPv6 route to %s/%d via %s.\n", 
+    (add != 0) ? "Adding" : "Removing", Str1, dest->rt_mask.v6, Str2);
 
   memset(buff, 0, sizeof (buff));
   memset(&sin6, 0, sizeof (sin6));
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/bsd/net.c olsrd-current/src/bsd/net.c
--- olsrd-0.5.0/src/bsd/net.c	2007-03-14 15:01:13.000000000 +0100
+++ olsrd-current/src/bsd/net.c	2007-05-02 09:41:20.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: net.c,v 1.32 2007/03/14 14:01:13 bernd67 Exp $
+ * $Id: net.c,v 1.36 2007/05/02 07:41:20 bernd67 Exp $
  */
 
 #include "defs.h"
@@ -58,6 +58,9 @@
 #include <netinet/ip_icmp.h>
 #include <netinet/icmp_var.h>
 #include <netinet/icmp6.h>
+#include <netinet6/in6_var.h> /* For struct in6_ifreq */
+#include <ifaddrs.h>
+#include <sys/uio.h>
 #endif
 
 #ifdef __FreeBSD__
@@ -97,7 +100,7 @@
 static int set_sysctl_int(char *name, int new)
 {
   int old;
-#if __MacOSX__
+#if __MacOSX__ || __OpenBSD__
   size_t len = sizeof (old);
 #else
   unsigned int len = sizeof (old);
@@ -486,7 +489,7 @@
   COPY_IP(&mcastreq.ipv6mr_multiaddr, &ifs->int6_multaddr.sin6_addr);
   mcastreq.ipv6mr_interface = ifs->if_index;
 
-  OLSR_PRINTF(3, "Interface %s joining multicast %s...",	ifs->int_name, olsr_ip_to_string((union olsr_ip_addr *)&ifs->int6_multaddr.sin6_addr))
+  OLSR_PRINTF(3, "Interface %s joining multicast %s...",	ifs->int_name, olsr_ip_to_string((union olsr_ip_addr *)&ifs->int6_multaddr.sin6_addr));
 
   /* rfc 3493 */
 #ifdef IPV6_JOIN_GROUP
@@ -524,7 +527,7 @@
     }
 
 
-  OLSR_PRINTF(3, "OK\n")
+  OLSR_PRINTF(3, "OK\n");
   return 0;
 }
 
@@ -542,7 +545,7 @@
 
   if (getifaddrs(&ifap) != 0)
     {
-      OLSR_PRINTF(3, "get_ipv6_address: getifaddrs() failed.\n")
+      OLSR_PRINTF(3, "get_ipv6_address: getifaddrs() failed.\n");
       return 0;
     }
 
@@ -639,7 +642,7 @@
   context = libnet_init(LIBNET_LINK, iface->int_name, errbuf);
   if (context == NULL)
     {
-      OLSR_PRINTF (1, "libnet init: %s\n", libnet_geterror (context))
+      OLSR_PRINTF (1, "libnet init: %s\n", libnet_geterror (context));
       return (0);
     }
 
@@ -659,7 +662,7 @@
 			      udp_tag);				/* pblock */
   if (udp_tag == -1)
     {
-      OLSR_PRINTF (1, "libnet UDP header: %s\n", libnet_geterror (context))
+      OLSR_PRINTF (1, "libnet UDP header: %s\n", libnet_geterror (context));
 	return (0);
     }
 
@@ -678,7 +681,7 @@
 			      ip_tag);				/* pblock */
   if (ip_tag == -1)
     {
-      OLSR_PRINTF (1, "libnet IP header: %s\n", libnet_geterror (context))
+      OLSR_PRINTF (1, "libnet IP header: %s\n", libnet_geterror (context));
       return (0);
     }
 
@@ -691,14 +694,14 @@
 				     ether_tag);  		/* pblock tag */
   if (ether_tag == -1)
     {
-      OLSR_PRINTF (1, "libnet ethernet header: %s\n", libnet_geterror (context))
+      OLSR_PRINTF (1, "libnet ethernet header: %s\n", libnet_geterror (context));
       return (0);
     }
  
   status = libnet_write (context);
   if (status == -1)
     {
-      OLSR_PRINTF (1, "libnet packet write: %s\n", libnet_geterror (context))
+      OLSR_PRINTF (1, "libnet packet write: %s\n", libnet_geterror (context));
       return (0);
     }
 
@@ -863,11 +866,11 @@
 
       if(ioctl(olsr_cnf->ioctl_s, SIOCGIFMEDIA, &ifm) < 0)
 	{
-	  OLSR_PRINTF(1, "Error SIOCGIFMEDIA(%s)\n", ifm.ifm_name)
+	  OLSR_PRINTF(1, "Error SIOCGIFMEDIA(%s)\n", ifm.ifm_name);
 	  return WEIGHT_ETHERNET_DEFAULT;
 	}
 
-      OLSR_PRINTF(1, "%s: STATUS 0x%08x\n", ifm.ifm_name, ifm.ifm_status)
+      OLSR_PRINTF(1, "%s: STATUS 0x%08x\n", ifm.ifm_name, ifm.ifm_status);
 #endif
       return WEIGHT_ETHERNET_DEFAULT;
     }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/bsd/net.h olsrd-current/src/bsd/net.h
--- olsrd-0.5.0/src/bsd/net.h	2004-11-21 11:50:52.000000000 +0100
+++ olsrd-current/src/bsd/net.h	2007-04-20 15:46:05.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: net.h,v 1.3 2004/11/21 10:50:52 kattemat Exp $
+ * $Id: net.h,v 1.4 2007/04/20 13:46:05 bernd67 Exp $
  */
 
 
@@ -55,7 +55,4 @@
 #include <netinet/in.h>
 #include "../olsr_protocol.h"
 
-extern int
-olsr_printf(int, char *, ...);
-
 #endif
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/build_msg.c olsrd-current/src/build_msg.c
--- olsrd-0.5.0/src/build_msg.c	2006-12-14 12:29:19.000000000 +0100
+++ olsrd-current/src/build_msg.c	2007-04-26 00:08:07.000000000 +0200
@@ -36,10 +36,9 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: build_msg.c,v 1.33 2006/12/14 11:29:19 bernd67 Exp $
+ * $Id: build_msg.c,v 1.36 2007/04/25 22:08:07 bernd67 Exp $
  */
 
-
 #include "defs.h"
 #include "olsr.h"
 #include "log.h"
@@ -113,7 +112,7 @@
  * empty TC messages
  */
 clock_t
-get_empty_tc_timer()
+get_empty_tc_timer(void)
 {
   return send_empty_tc;
 }
@@ -137,7 +136,7 @@
 queue_hello(struct hello_message *message, struct interface *ifp)
 {
 #ifdef DEBUG
-  OLSR_PRINTF(BMSG_DBGLVL, "Building HELLO on %s\n-------------------\n", ifp->int_name)
+  OLSR_PRINTF(BMSG_DBGLVL, "Building HELLO on %s\n-------------------\n", ifp->int_name);
 #endif
 
   switch(olsr_cnf->ip_version)
@@ -168,7 +167,7 @@
 queue_tc(struct tc_message *message, struct interface *ifp)           
 {
 #ifdef DEBUG
-  OLSR_PRINTF(BMSG_DBGLVL, "Building TC on %s\n-------------------\n", ifp->int_name)
+  OLSR_PRINTF(BMSG_DBGLVL, "Building TC on %s\n-------------------\n", ifp->int_name);
 #endif
 
   switch(olsr_cnf->ip_version)
@@ -194,7 +193,7 @@
 queue_mid(struct interface *ifp)
 {
 #ifdef DEBUG
-  OLSR_PRINTF(BMSG_DBGLVL, "Building MID on %s\n-------------------\n", ifp->int_name)
+  OLSR_PRINTF(BMSG_DBGLVL, "Building MID on %s\n-------------------\n", ifp->int_name);
 #endif
 
   switch(olsr_cnf->ip_version)
@@ -219,7 +218,7 @@
 queue_hna(struct interface *ifp)
 {
 #ifdef DEBUG
-  OLSR_PRINTF(BMSG_DBGLVL, "Building HNA on %s\n-------------------\n", ifp->int_name)
+  OLSR_PRINTF(BMSG_DBGLVL, "Building HNA on %s\n-------------------\n", ifp->int_name);
 #endif
 
   switch(olsr_cnf->ip_version)
@@ -242,7 +241,7 @@
 {
   if(msgsize > buffsize)
     {
-      OLSR_PRINTF(1, "%s build, outputbuffer to small(%d/%d)!\n", type, msgsize, buffsize)
+      OLSR_PRINTF(1, "%s build, outputbuffer to small(%d/%d)!\n", type, msgsize, buffsize);
       olsr_syslog(OLSR_LOG_ERR, "%s build, outputbuffer to small(%d/%d)!\n", type, msgsize, buffsize);
       olsr_exit(__func__, EXIT_FAILURE);
     }
@@ -335,8 +334,8 @@
 		continue;
 
 #ifdef DEBUG
-	      OLSR_PRINTF(BMSG_DBGLVL, "\t%s - ", olsr_ip_to_string(&nb->address))
-	      OLSR_PRINTF(BMSG_DBGLVL, "L:%d N:%d\n", j, i)
+	      OLSR_PRINTF(BMSG_DBGLVL, "\t%s - ", olsr_ip_to_string(&nb->address));
+	      OLSR_PRINTF(BMSG_DBGLVL, "L:%d N:%d\n", j, i);
 #endif		  
 	      /*
 	       * If there is not enough room left 
@@ -355,7 +354,7 @@
 		  if(curr_size > OLSR_HELLO_IPV4_HDRSIZE)
 		    {
 #ifdef DEBUG
-		      OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize)
+		      OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize);
 #endif
 		      /* Complete the headers */
 		      m->v4.seqno = htons(get_msg_seqno());
@@ -499,8 +498,8 @@
 		continue;
 
 #ifdef DEBUG
-	      OLSR_PRINTF(BMSG_DBGLVL, "\t%s - ", olsr_ip_to_string(&nb->address))
-	      OLSR_PRINTF(BMSG_DBGLVL, "L:%d N:%d\n", j, i)
+	      OLSR_PRINTF(BMSG_DBGLVL, "\t%s - ", olsr_ip_to_string(&nb->address));
+	      OLSR_PRINTF(BMSG_DBGLVL, "L:%d N:%d\n", j, i);
 #endif		  
 
 
@@ -521,7 +520,7 @@
 		  if(curr_size > OLSR_HELLO_IPV6_HDRSIZE)
 		    {
 #ifdef DEBUG
-		      OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize)
+		      OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize);
 #endif
 		      /* Complete the headers */
 		      m->v6.seqno = htons(get_msg_seqno());
@@ -604,7 +603,7 @@
   olsr_u16_t remainsize, curr_size;
   struct tc_mpr_addr *mprs;
   union olsr_message *m;
-  struct tcmsg *tc;
+  struct olsr_tcmsg *tc;
   struct neigh_info *mprsaddr; 
   olsr_bool found = OLSR_FALSE, partial_sent = OLSR_FALSE;
 
@@ -652,7 +651,7 @@
 	  if(curr_size > OLSR_TC_IPV4_HDRSIZE)
 	    {
 #ifdef DEBUG
-	      OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize)
+	      OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize);
 #endif
 
 	      m->v4.olsr_msgsize = htons(curr_size);
@@ -675,7 +674,7 @@
       found = OLSR_TRUE;
 #ifdef DEBUG
 	  OLSR_PRINTF(BMSG_DBGLVL, "\t%s\n", 
-		      olsr_ip_to_string(&mprs->address))
+		      olsr_ip_to_string(&mprs->address));
 #endif 
       COPY_IP(&mprsaddr->addr, &mprs->address);
 
@@ -697,7 +696,7 @@
       if((!partial_sent) && (!TIMED_OUT(send_empty_tc)))
 	{
 	  if(!TIMED_OUT(send_empty_tc))
-	    OLSR_PRINTF(1, "TC: Sending empty package - (%d/%d/%d/%d)\n", partial_sent, (int)send_empty_tc, (int)now_times, (int)((send_empty_tc) - now_times))
+	    OLSR_PRINTF(1, "TC: Sending empty package - (%d/%d/%d/%d)\n", partial_sent, (int)send_empty_tc, (int)now_times, (int)((send_empty_tc) - now_times));
 
 	  m->v4.olsr_msgsize = htons(curr_size);
 	  m->v4.seqno = htons(get_msg_seqno());
@@ -730,7 +729,7 @@
   olsr_u16_t remainsize, curr_size;
   struct tc_mpr_addr *mprs;
   union olsr_message *m;
-  struct tcmsg6 *tc6;
+  struct olsr_tcmsg6 *tc6;
   struct neigh_info6 *mprsaddr6; 
   olsr_bool found = OLSR_FALSE, partial_sent = OLSR_FALSE;
 
@@ -777,7 +776,7 @@
 	  if(curr_size > OLSR_TC_IPV6_HDRSIZE)
 	    {
 #ifdef DEBUG
-	      OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize)
+	      OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize);
 #endif
 	      m->v6.olsr_msgsize = htons(curr_size);
 	      m->v6.seqno = htons(get_msg_seqno());
@@ -796,7 +795,7 @@
       found = OLSR_TRUE;
 #ifdef DEBUG
 	  OLSR_PRINTF(BMSG_DBGLVL, "\t%s\n", 
-		      olsr_ip_to_string(&mprs->address))
+		      olsr_ip_to_string(&mprs->address));
 #endif
       COPY_IP(&mprsaddr6->addr, &mprs->address);
       curr_size += olsr_cnf->ipsize;
@@ -816,7 +815,7 @@
     {
       if((!partial_sent) && (!TIMED_OUT(send_empty_tc)))
 	{
-	  OLSR_PRINTF(1, "TC: Sending empty package\n")
+	  OLSR_PRINTF(1, "TC: Sending empty package\n");
 	    
 	  m->v6.olsr_msgsize = htons(curr_size);
 	  m->v6.seqno = htons(get_msg_seqno());
@@ -890,7 +889,7 @@
 	      if(curr_size > OLSR_MID_IPV4_HDRSIZE)
 		{
 #ifdef DEBUG
-		  OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize)
+		  OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize);
 #endif
 		  /* set size */
 		  m->v4.olsr_msgsize = htons(curr_size);
@@ -907,7 +906,7 @@
 #ifdef DEBUG
 	  OLSR_PRINTF(BMSG_DBGLVL, "\t%s(%s)\n", 
 		      olsr_ip_to_string(&ifs->ip_addr), 
-		      ifs->int_name)
+		      ifs->int_name);
 #endif
 	  
 	  COPY_IP(&addrs->addr, &ifs->ip_addr);
@@ -989,7 +988,7 @@
 	      if(curr_size > OLSR_MID_IPV6_HDRSIZE)
 		{
 #ifdef DEBUG
-		  OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize)
+		  OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize);
 #endif
 		  /* set size */
 		  m->v6.olsr_msgsize = htons(curr_size);
@@ -1006,7 +1005,7 @@
 #ifdef DEBUG
 		  OLSR_PRINTF(BMSG_DBGLVL, "\t%s(%s)\n", 
 			      olsr_ip_to_string(&ifs->ip_addr), 
-			      ifs->int_name)
+			      ifs->int_name);
 #endif
 
 	  COPY_IP(&addrs6->addr, &ifs->ip_addr);
@@ -1080,7 +1079,7 @@
 	  if(curr_size > OLSR_HNA_IPV4_HDRSIZE)
 	    {
 #ifdef DEBUG
-	      OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize)
+	      OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize);
 #endif
 	      m->v4.seqno = htons(get_msg_seqno());
 	      m->v4.olsr_msgsize = htons(curr_size);
@@ -1095,7 +1094,7 @@
 #ifdef DEBUG
       OLSR_PRINTF(BMSG_DBGLVL, "\tNet: %s/%s\n", 
 		  olsr_ip_to_string(&h->net),
-		  olsr_ip_to_string(&h->netmask))
+		  olsr_ip_to_string(&h->netmask));
 #endif
       COPY_IP(&pair->addr, &h->net);
       COPY_IP(&pair->netmask, &h->netmask);
@@ -1170,7 +1169,7 @@
 	  if(curr_size > OLSR_HNA_IPV6_HDRSIZE)
 	    {
 #ifdef DEBUG
-	      OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize)
+	      OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize);
 #endif
 	      m->v6.seqno = htons(get_msg_seqno());
 	      m->v6.olsr_msgsize = htons(curr_size);
@@ -1185,7 +1184,7 @@
 #ifdef DEBUG
       OLSR_PRINTF(BMSG_DBGLVL, "\tNet: %s/%d\n", 
 		  olsr_ip_to_string(&h->net),
-		  h->prefix_len)
+		  h->prefix_len);
 #endif
       COPY_IP(&pair6->addr, &h->net);
       olsr_prefix_to_netmask(&tmp_netmask, h->prefix_len);
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/cfgparser/Makefile olsrd-current/src/cfgparser/Makefile
--- olsrd-0.5.0/src/cfgparser/Makefile	2007-03-27 05:05:21.000000000 +0200
+++ olsrd-current/src/cfgparser/Makefile	2007-05-14 00:02:57.000000000 +0200
@@ -36,7 +36,7 @@
 # to the project. For more information see the website or contact
 # the copyright holders.
 #
-# $Id: Makefile,v 1.22 2007/03/27 03:05:21 tlopatic Exp $
+# $Id: Makefile,v 1.26 2007/05/13 22:02:57 bernd67 Exp $
 
 TOPDIR=../..
 include $(TOPDIR)/Makefile.inc
@@ -89,11 +89,20 @@
 $(NAME):	$(OBJS)
 		$(CC) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS)
 
-oscan.c:	oscan.lex
-		$(FLEX) -ooscan.c oscan.lex
+oscan.c:	oscan.lex Makefile
+		$(FLEX) -Cem -ooscan.c-tmp oscan.lex
+		sed	-e '/^static/s/yy_get_next_buffer[\(][\)]/yy_get_next_buffer(void)/' \
+			-e '/^static/s/yy_get_previous_state[\(][\)]/yy_get_previous_state(void)/' \
+			-e '/^static/s/yygrowstack[\(][\)]/yygrowstack(void)/' \
+			-e '/^static/s/input[\(][\)]/input(void)/' \
+			-e '/^static  *void  *yy_fatal_error/s/^\(.*)\);$$/\1 __attribute__((noreturn));/' \
+			< oscan.c-tmp >oscan.c
+		$(RM) oscan.c-tmp
 
-oparse.c:	oparse.y olsrd_conf.h
-		$(BISON) -d -ooparse.c oparse.y
+oparse.c:	oparse.y olsrd_conf.h Makefile
+		$(BISON) -d -o oparse.c oparse.y
+
+#oscan.o oparse.o:: CFLAGS := $(filter-out -Wunreachable-code, $(CFLAGS))
 
 .PHONY: install clean uberclean
 
@@ -102,9 +111,10 @@
 		/sbin/ldconfig -n $(LIBDIR)
 
 clean:
-		rm -f *.[od~]
+		rm -f *.[od~] oscan.c oparse.[ch]
 		rm -f $(LIBNAME)
 		rm -f $(BINNAME)
+		$(RM) oparse.c-tmp
 
 uberclean:	clean
 		rm -f oparse.c oparse.h oscan.c
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/cfgparser/olsrd_conf.c olsrd-current/src/cfgparser/olsrd_conf.c
--- olsrd-0.5.0/src/cfgparser/olsrd_conf.c	2007-03-14 14:59:30.000000000 +0100
+++ olsrd-current/src/cfgparser/olsrd_conf.c	2007-05-14 00:23:55.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_conf.c,v 1.51 2007/03/14 13:59:30 bernd67 Exp $
+ * $Id: olsrd_conf.c,v 1.54 2007/05/13 22:23:55 bernd67 Exp $
  */
 
 
@@ -157,7 +157,6 @@
   while(in)
     {
       /* set various stuff */
-      in->index = cnf->ifcnt++;
       in->configured = OLSR_FALSE;
       in->interf = NULL;
       in->host_emul = OLSR_FALSE;
@@ -419,7 +418,7 @@
 
 
 struct olsrd_config *
-olsrd_get_default_cnf()
+olsrd_get_default_cnf(void)
 {
   cnf = malloc(sizeof(struct olsrd_config));
   if (cnf == NULL)
@@ -481,7 +480,7 @@
 
 
 struct if_config_options *
-get_default_if_config()
+get_default_if_config(void)
 {
   struct if_config_options *io = malloc(sizeof(struct if_config_options));
   struct in6_addr in6;
@@ -731,6 +730,4 @@
   // setbuf(stdout, NULL);
   setbuf(stderr, NULL);
 }
-#else
-void win32_stdio_hack(unsigned int handle) {}
 #endif
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/cfgparser/olsrd_conf.h olsrd-current/src/cfgparser/olsrd_conf.h
--- olsrd-0.5.0/src/cfgparser/olsrd_conf.h	2004-11-30 17:52:16.000000000 +0100
+++ olsrd-current/src/cfgparser/olsrd_conf.h	2007-04-28 22:46:32.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_conf.h,v 1.12 2004/11/30 16:52:16 kattemat Exp $
+ * $Id: olsrd_conf.h,v 1.13 2007/04/28 20:46:32 bernd67 Exp $
  */
 
 
@@ -64,7 +64,11 @@
 void
 set_default_cnf(struct olsrd_config *);
 
+#if defined WIN32_STDIO_HACK
 void 
 win32_stdio_hack(unsigned int);
+#else
+#define win32_stdio_hack(handle) do { } while(0)
+#endif
 
 #endif
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/cfgparser/oparse.y olsrd-current/src/cfgparser/oparse.y
--- olsrd-0.5.0/src/cfgparser/oparse.y	2007-01-31 13:36:50.000000000 +0100
+++ olsrd-current/src/cfgparser/oparse.y	2007-05-13 23:49:59.000000000 +0200
@@ -38,7 +38,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: oparse.y,v 1.31 2007/01/31 12:36:50 bernd67 Exp $
+ * $Id: oparse.y,v 1.33 2007/05/13 21:49:59 bernd67 Exp $
  */
 
 
@@ -55,6 +55,12 @@
 
 #define PARSER_DEBUG 0
 
+#if PARSER_DEBUG
+#define PARSER_DEBUG_PRINTF(x, ...)   printf(x, ##args)
+#else
+#define PARSER_DEBUG_PRINTF(x, ...)   do { } while (0)
+#endif
+
 #define YYSTYPE struct conf_token *
 
 void yyerror(char *);
@@ -121,7 +127,6 @@
 
 %token TOK_OPEN
 %token TOK_CLOSE
-%token TOK_SEMI
 
 %token TOK_STRING
 %token TOK_INTEGER
@@ -154,7 +159,6 @@
 %token TOK_LQ_WSIZE
 %token TOK_LQ_MULT
 %token TOK_CLEAR_SCREEN
-%token TOK_PLNAME
 %token TOK_PLPARAM
 
 %token TOK_HOSTLABEL
@@ -305,7 +309,7 @@
   struct in_addr in;
   struct ipc_host *ipch;
 
-  if(PARSER_DEBUG) printf("\tIPC host: %s\n", $2->string);
+  PARSER_DEBUG_PRINTF("\tIPC host: %s\n", $2->string);
   
   if(inet_aton($2->string, &in) == 0)
     {
@@ -330,7 +334,7 @@
   struct in_addr in1, in2;
   struct ipc_net *ipcn;
 
-  if(PARSER_DEBUG) printf("\tIPC net: %s/%s\n", $2->string, $3->string);
+  PARSER_DEBUG_PRINTF("\tIPC net: %s/%s\n", $2->string, $3->string);
   
   if(inet_aton($2->string, &in1) == 0)
     {
@@ -364,7 +368,7 @@
   int ifcnt = ifs_in_curr_cfg;
   struct olsr_if *ifs = cnf->interfaces;
 
-  if(PARSER_DEBUG) printf("Fixed willingness: %d\n", $2->integer);
+  PARSER_DEBUG_PRINTF("Fixed willingness: %d\n", $2->integer);
 
   while(ifcnt)
     {
@@ -385,7 +389,7 @@
   int ifcnt = ifs_in_curr_cfg;
   struct olsr_if *ifs = cnf->interfaces;
 
-  if(PARSER_DEBUG) printf("\tIPv4 broadcast: %s\n", $2->string);
+  PARSER_DEBUG_PRINTF("\tIPv4 broadcast: %s\n", $2->string);
 
   if(inet_aton($2->string, &in) == 0)
     {
@@ -442,7 +446,7 @@
   int ifcnt = ifs_in_curr_cfg;
   struct olsr_if *ifs = cnf->interfaces;
 
-  if(PARSER_DEBUG) printf("\tIPv6 site-local multicast: %s\n", $2->string);
+  PARSER_DEBUG_PRINTF("\tIPv6 site-local multicast: %s\n", $2->string);
 
   if(inet_pton(AF_INET6, $2->string, &in6) < 0)
     {
@@ -471,7 +475,7 @@
   int ifcnt = ifs_in_curr_cfg;
   struct olsr_if *ifs = cnf->interfaces;
 
-  if(PARSER_DEBUG) printf("\tIPv6 global multicast: %s\n", $2->string);
+  PARSER_DEBUG_PRINTF("\tIPv6 global multicast: %s\n", $2->string);
 
   if(inet_pton(AF_INET6, $2->string, &in6) < 0)
     {
@@ -497,7 +501,7 @@
   int ifcnt = ifs_in_curr_cfg;
   struct olsr_if *ifs = cnf->interfaces;
 
-  if(PARSER_DEBUG) printf("\tHELLO interval: %0.2f\n", $2->floating);
+  PARSER_DEBUG_PRINTF("\tHELLO interval: %0.2f\n", $2->floating);
 
   while(ifcnt)
     {
@@ -515,7 +519,7 @@
   int ifcnt = ifs_in_curr_cfg;
   struct olsr_if *ifs = cnf->interfaces;
 
-  if(PARSER_DEBUG) printf("\tHELLO validity: %0.2f\n", $2->floating);
+  PARSER_DEBUG_PRINTF("\tHELLO validity: %0.2f\n", $2->floating);
 
   while(ifcnt)
     {
@@ -533,7 +537,7 @@
   int ifcnt = ifs_in_curr_cfg;
   struct olsr_if *ifs = cnf->interfaces;
 
-  if(PARSER_DEBUG) printf("\tTC interval: %0.2f\n", $2->floating);
+  PARSER_DEBUG_PRINTF("\tTC interval: %0.2f\n", $2->floating);
 
   while(ifcnt)
     {
@@ -550,7 +554,7 @@
   int ifcnt = ifs_in_curr_cfg;
   struct olsr_if *ifs = cnf->interfaces;
   
-  if(PARSER_DEBUG) printf("\tTC validity: %0.2f\n", $2->floating);
+  PARSER_DEBUG_PRINTF("\tTC validity: %0.2f\n", $2->floating);
   while(ifcnt)
     {
       ifs->cnf->tc_params.validity_time = $2->floating;
@@ -568,7 +572,7 @@
   struct olsr_if *ifs = cnf->interfaces;
 
 
-  if(PARSER_DEBUG) printf("\tMID interval: %0.2f\n", $2->floating);
+  PARSER_DEBUG_PRINTF("\tMID interval: %0.2f\n", $2->floating);
   while(ifcnt)
     {
       ifs->cnf->mid_params.emission_interval = $2->floating;
@@ -585,7 +589,7 @@
   int ifcnt = ifs_in_curr_cfg;
   struct olsr_if *ifs = cnf->interfaces;
 
-  if(PARSER_DEBUG) printf("\tMID validity: %0.2f\n", $2->floating);
+  PARSER_DEBUG_PRINTF("\tMID validity: %0.2f\n", $2->floating);
   while(ifcnt)
     {
       ifs->cnf->mid_params.validity_time = $2->floating;
@@ -602,7 +606,7 @@
   int ifcnt = ifs_in_curr_cfg;
   struct olsr_if *ifs = cnf->interfaces;
   
-  if(PARSER_DEBUG) printf("\tHNA interval: %0.2f\n", $2->floating);
+  PARSER_DEBUG_PRINTF("\tHNA interval: %0.2f\n", $2->floating);
   while(ifcnt)
     {
       ifs->cnf->hna_params.emission_interval = $2->floating;
@@ -619,7 +623,7 @@
   int ifcnt = ifs_in_curr_cfg;
   struct olsr_if *ifs = cnf->interfaces;
 
-  if(PARSER_DEBUG) printf("\tHNA validity: %0.2f\n", $2->floating);
+  PARSER_DEBUG_PRINTF("\tHNA validity: %0.2f\n", $2->floating);
   while(ifcnt)
     {
       ifs->cnf->hna_params.validity_time = $2->floating;
@@ -636,7 +640,7 @@
   int ifcnt = ifs_in_curr_cfg;
   struct olsr_if *ifs = cnf->interfaces;
 
-  if(PARSER_DEBUG) printf("\tAutodetect changes: %s\n", $2->boolean ? "YES" : "NO");
+  PARSER_DEBUG_PRINTF("\tAutodetect changes: %s\n", $2->boolean ? "YES" : "NO");
   while(ifcnt)
     {
       ifs->cnf->autodetect_chg = $2->boolean;
@@ -673,7 +677,7 @@
 {
 
   cnf->debug_level = $2->integer;
-  if(PARSER_DEBUG) printf("Debug level: %d\n", cnf->debug_level);
+  PARSER_DEBUG_PRINTF("Debug level: %d\n", cnf->debug_level);
   free($2);
 }
 ;
@@ -691,7 +695,7 @@
       YYABORT;
     }
 
-  if(PARSER_DEBUG) printf("IpVersion: %d\n", $2->integer);
+  PARSER_DEBUG_PRINTF("IpVersion: %d\n", $2->integer);
   free($2);
 }
 ;
@@ -702,7 +706,7 @@
   struct hna4_entry *h = malloc(sizeof(struct hna4_entry));
   struct in_addr in;
 
-  if(PARSER_DEBUG) printf("HNA IPv4 entry: %s/%s\n", $1->string, $2->string);
+  PARSER_DEBUG_PRINTF("HNA IPv4 entry: %s/%s\n", $1->string, $2->string);
 
   if(h == NULL)
     {
@@ -740,7 +744,7 @@
   struct hna6_entry *h = malloc(sizeof(struct hna6_entry));
   struct in6_addr in6;
 
-  if(PARSER_DEBUG) printf("HNA IPv6 entry: %s/%d\n", $1->string, $2->integer);
+  PARSER_DEBUG_PRINTF("HNA IPv6 entry: %s/%d\n", $1->string, $2->integer);
 
   if(h == NULL)
     {
@@ -755,7 +759,7 @@
     }
   memcpy(&h->net, &in6, sizeof(struct in6_addr));
 
-  if(($2->integer < 0) || ($2->integer > 128))
+  if($2->integer > 128)
     {
       fprintf(stderr, "ihna6entry: Illegal IPv6 prefix length %d\n", $2->integer);
       return -1;
@@ -775,7 +779,7 @@
 
 ifstart: TOK_INTERFACE
 {
-  if(PARSER_DEBUG) printf("setting ifs_in_curr_cfg = 0\n");
+  PARSER_DEBUG_PRINTF("setting ifs_in_curr_cfg = 0\n");
   ifs_in_curr_cfg = 0;
 }
 ;
@@ -812,7 +816,7 @@
 
 bnoint: TOK_NOINT TOK_BOOLEAN
 {
-  if(PARSER_DEBUG) printf("Noint set to %d\n", $2->boolean);
+  PARSER_DEBUG_PRINTF("Noint set to %d\n", $2->boolean);
 
   cnf->allow_no_interfaces = $2->boolean;
 
@@ -822,7 +826,7 @@
 
 atos: TOK_TOS TOK_INTEGER
 {
-  if(PARSER_DEBUG) printf("TOS: %d\n", $2->integer);
+  PARSER_DEBUG_PRINTF("TOS: %d\n", $2->integer);
   cnf->tos = $2->integer;
 
   free($2);
@@ -834,7 +838,7 @@
 {
   cnf->willingness_auto = OLSR_FALSE;
 
-  if(PARSER_DEBUG) printf("Willingness: %d\n", $2->integer);
+  PARSER_DEBUG_PRINTF("Willingness: %d\n", $2->integer);
   cnf->willingness = $2->integer;
 
   free($2);
@@ -849,11 +853,11 @@
   cnf->use_hysteresis = $2->boolean;
   if(cnf->use_hysteresis)
     {
-      if(PARSER_DEBUG) printf("Hysteresis enabled\n");
+      PARSER_DEBUG_PRINTF("Hysteresis enabled\n");
     }
   else
     {
-      if(PARSER_DEBUG) printf("Hysteresis disabled\n");
+      PARSER_DEBUG_PRINTF("Hysteresis disabled\n");
     }
   free($2);
 
@@ -864,7 +868,7 @@
 fhystscale: TOK_HYSTSCALE TOK_FLOAT
 {
   cnf->hysteresis_param.scaling = $2->floating;
-  if(PARSER_DEBUG) printf("Hysteresis Scaling: %0.2f\n", $2->floating);
+  PARSER_DEBUG_PRINTF("Hysteresis Scaling: %0.2f\n", $2->floating);
   free($2);
 }
 ;
@@ -873,7 +877,7 @@
 fhystupper: TOK_HYSTUPPER TOK_FLOAT
 {
   cnf->hysteresis_param.thr_high = $2->floating;
-  if(PARSER_DEBUG) printf("Hysteresis UpperThr: %0.2f\n", $2->floating);
+  PARSER_DEBUG_PRINTF("Hysteresis UpperThr: %0.2f\n", $2->floating);
   free($2);
 }
 ;
@@ -882,14 +886,14 @@
 fhystlower: TOK_HYSTLOWER TOK_FLOAT
 {
   cnf->hysteresis_param.thr_low = $2->floating;
-  if(PARSER_DEBUG) printf("Hysteresis LowerThr: %0.2f\n", $2->floating);
+  PARSER_DEBUG_PRINTF("Hysteresis LowerThr: %0.2f\n", $2->floating);
   free($2);
 }
 ;
 
 fpollrate: TOK_POLLRATE TOK_FLOAT
 {
-  if(PARSER_DEBUG) printf("Pollrate %0.2f\n", $2->floating);
+  PARSER_DEBUG_PRINTF("Pollrate %0.2f\n", $2->floating);
   cnf->pollrate = $2->floating;
 
   free($2);
@@ -898,7 +902,7 @@
 
 fnicchgspollrt: TOK_NICCHGSPOLLRT TOK_FLOAT
 {
-  if(PARSER_DEBUG) printf("NIC Changes Pollrate %0.2f\n", $2->floating);
+  PARSER_DEBUG_PRINTF("NIC Changes Pollrate %0.2f\n", $2->floating);
   cnf->nic_chgs_pollrate = $2->floating;
 
   free($2);
@@ -907,7 +911,7 @@
 
 atcredundancy: TOK_TCREDUNDANCY TOK_INTEGER
 {
-  if(PARSER_DEBUG) printf("TC redundancy %d\n", $2->integer);
+  PARSER_DEBUG_PRINTF("TC redundancy %d\n", $2->integer);
   cnf->tc_redundancy = $2->integer;
   free($2);
 }
@@ -915,7 +919,7 @@
 
 amprcoverage: TOK_MPRCOVERAGE TOK_INTEGER
 {
-  if(PARSER_DEBUG) printf("MPR coverage %d\n", $2->integer);
+  PARSER_DEBUG_PRINTF("MPR coverage %d\n", $2->integer);
   cnf->mpr_coverage = $2->integer;
   free($2);
 }
@@ -923,7 +927,7 @@
 
 alq_level: TOK_LQ_LEVEL TOK_INTEGER
 {
-  if(PARSER_DEBUG) printf("Link quality level %d\n", $2->integer);
+  PARSER_DEBUG_PRINTF("Link quality level %d\n", $2->integer);
   cnf->lq_level = $2->integer;
   free($2);
 }
@@ -931,7 +935,7 @@
 
 alq_fish: TOK_LQ_FISH TOK_INTEGER
 {
-  if(PARSER_DEBUG) printf("Link quality fish eye %d\n", $2->integer);
+  PARSER_DEBUG_PRINTF("Link quality fish eye %d\n", $2->integer);
   cnf->lq_fish = $2->integer;
   free($2);
 }
@@ -939,7 +943,7 @@
 
 alq_dlimit: TOK_LQ_DLIMIT TOK_INTEGER TOK_FLOAT
 {
-  if(PARSER_DEBUG) printf("Link quality dijkstra limit %d, %0.2f\n", $2->integer, $3->floating);
+  PARSER_DEBUG_PRINTF("Link quality dijkstra limit %d, %0.2f\n", $2->integer, $3->floating);
   cnf->lq_dlimit = $2->integer;
   cnf->lq_dinter = $3->floating;
   free($2);
@@ -948,7 +952,7 @@
 
 alq_wsize: TOK_LQ_WSIZE TOK_INTEGER
 {
-  if(PARSER_DEBUG) printf("Link quality window size %d\n", $2->integer);
+  PARSER_DEBUG_PRINTF("Link quality window size %d\n", $2->integer);
   cnf->lq_wsize = $2->integer;
   free($2);
 }
@@ -958,8 +962,7 @@
 {
   cnf->clear_screen = $2->boolean;
 
-  if (PARSER_DEBUG)
-    printf("Clear screen %s\n", cnf->clear_screen ? "enabled" : "disabled");
+  PARSER_DEBUG_PRINTF("Clear screen %s\n", cnf->clear_screen ? "enabled" : "disabled");
 
   free($2);
 }
@@ -979,7 +982,7 @@
 
   pe->params = NULL;
   
-  if(PARSER_DEBUG) printf("Plugin: %s\n", $2->string);
+  PARSER_DEBUG_PRINTF("Plugin: %s\n", $2->string);
 
   /* Queue */
   pe->next = cnf->plugins;
@@ -999,7 +1002,7 @@
       YYABORT;
     }
   
-  if(PARSER_DEBUG) printf("Plugin param key:\"%s\" val: \"%s\"\n", $2->string, $3->string);
+  PARSER_DEBUG_PRINTF("Plugin param key:\"%s\" val: \"%s\"\n", $2->string, $3->string);
   
   pp->key = $2->string;
   pp->value = $3->string;
@@ -1015,7 +1018,7 @@
 
 vcomment:       TOK_COMMENT
 {
-    //if(PARSER_DEBUG) printf("Comment\n");
+    //PARSER_DEBUG_PRINTF("Comment\n");
 }
 ;
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/cfgparser/oscan.lex olsrd-current/src/cfgparser/oscan.lex
--- olsrd-0.5.0/src/cfgparser/oscan.lex	2006-04-17 20:31:09.000000000 +0200
+++ olsrd-current/src/cfgparser/oscan.lex	2007-05-17 22:35:16.000000000 +0200
@@ -38,7 +38,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: oscan.lex,v 1.21 2006/04/17 18:31:09 kattemat Exp $
+ * $Id: oscan.lex,v 1.24 2007/05/17 20:35:16 bernd67 Exp $
  */
 
 
@@ -55,7 +55,7 @@
 #include "olsrd_conf.h"
 
 #include "oparse.h"
-
+ 
 /* Prototypes */
 int yyget_lineno(void);
 FILE * yyget_in(void);
@@ -70,27 +70,63 @@
 int yylex_destroy(void);
 int yylex(void);
 
-struct conf_token *
-get_conf_token(void);
+static struct conf_token *get_conf_token(void);
+static struct conf_token *get_string_token(const char * const s, int const n);
+static struct conf_token *get_integer_token(const char * const s);
+static struct conf_token *get_floating_token(const char * const s);
+static struct conf_token *get_boolean_token(const olsr_bool b);
 
-struct conf_token *
-get_conf_token()
+static struct conf_token *get_conf_token(void)
 {
-  struct conf_token *t = malloc(sizeof(struct conf_token));
-
-  if (t == NULL)
-    {
-      fprintf(stderr, "Cannot allocate %d bytes for an configuration token.\n",
-	      (int) sizeof (struct conf_token));
-      exit(EXIT_FAILURE);
+    struct conf_token *t = calloc(1, sizeof(struct conf_token));
+    if (t == NULL) {
+        fprintf(stderr, "Cannot allocate %d bytes for an configuration token.\n", (int)sizeof(struct conf_token));
     }
+    return t;
+}
 
-  memset(t, 0, sizeof(struct conf_token));
+static struct conf_token *get_string_token(const char * const s, int const n)
+{
+    struct conf_token *rv = get_conf_token();
+    if (rv != NULL) {
+        rv->string = malloc(n+1);
+        if (rv->string == NULL) {
+            fprintf(stderr, "Cannot allocate %d bytes for string token data.\n", n+1);
+            free(rv);
+            return NULL;
+        }
+        strncpy(rv->string, s, n);
+        rv->string[n] = '\0';
+    }
+    return rv;
+}
 
-  return t;
+static struct conf_token *get_integer_token(const char * const s)
+{
+    struct conf_token *rv = get_conf_token();
+    if (rv != NULL) {
+        rv->integer = strtol(s, NULL, 0);
+    }
+    return rv;
 }
 
+static struct conf_token *get_floating_token(const char * const s)
+{
+    struct conf_token *rv = get_conf_token();
+    if (rv != NULL) {
+        rv->floating = strtod(s, NULL);
+    }
+    return rv;
+}
 
+static struct conf_token *get_boolean_token(const olsr_bool b)
+{
+    struct conf_token *rv = get_conf_token();
+    if (rv != NULL) {
+        rv->boolean = b;
+    }
+    return rv;
+}
 
 %}
 
@@ -119,345 +155,287 @@
 %%
 
 \s*"#".*\n {
-
-  current_line++;
-  return TOK_COMMENT;
+    current_line++;
+    return TOK_COMMENT;
 }
 
 \{ {
-  yylval = NULL;
-  return TOK_OPEN;
+    yylval = NULL;
+    return TOK_OPEN;
 }
 
 \} {
-  yylval = NULL;
-  return TOK_CLOSE;
-}
-
-\; {
-  yylval = NULL;
-  return TOK_SEMI;
+    yylval = NULL;
+    return TOK_CLOSE;
 }
 
 \"[^\"]*\" {
-  yylval = get_conf_token();
-
-  yylval->string = malloc(yyleng - 1);
-
-  if (yylval->string == NULL)
-  {
-    fprintf(stderr,
-            "Cannot allocate %d bytes for string token data.\n", yyleng - 1);
-    yyterminate();
-  }
-
-  strncpy(yylval->string, yytext + 1, yyleng - 2);
-  yylval->string[yyleng - 2] = 0;
-
-  return TOK_STRING;
+    yylval = get_string_token(yytext + 1, yyleng - 2);
+    if (yylval == NULL) {
+        yyterminate();
+    }
+    return TOK_STRING;
 }
 
 0x{HEXDIGIT}+ {
-  yylval = get_conf_token();
-
-  yylval->integer = strtol(yytext, NULL, 0);
-
-  return TOK_INTEGER;
+    yylval = get_integer_token(yytext);
+    return TOK_INTEGER;
 }
 
 {FLOAT} {
-  yylval = get_conf_token();
-
-  sscanf(yytext, "%f", &yylval->floating);
-  return TOK_FLOAT;
+    yylval = get_floating_token(yytext);
+    return TOK_FLOAT;
 }
 
 {IPV4ADDR} {
-  yylval = get_conf_token();
-  
-  yylval->string = malloc(yyleng + 1);
-  
-  if (yylval->string == NULL)
-    {
-      fprintf(stderr,
-	      "Cannot allocate %d bytes for string token data.\n", yyleng + 1);
-      yyterminate();
+    yylval = get_string_token(yytext, yyleng + 1);
+    if (yylval == NULL) {
+        yyterminate();
     }
-  
-  strncpy(yylval->string, yytext, yyleng+1);
-
-  return TOK_IP4_ADDR;
+    return TOK_IP4_ADDR;
 }
 
-
-
 {IPV6ADDR} {
-
-  yylval = get_conf_token();
-  
-  yylval->string = malloc(yyleng+1);
-  
-  if (yylval->string == NULL)
-    {
-      fprintf(stderr,
-	      "Cannot allocate %d bytes for string token data.\n", yyleng + 1);
-      yyterminate();
+    yylval = get_string_token(yytext, yyleng + 1);
+    if (yylval == NULL) {
+        yyterminate();
     }
-  
-  strncpy(yylval->string, yytext, yyleng+1);
-  
-  return TOK_IP6_ADDR;
+    return TOK_IP6_ADDR;
 }
 
 "default" {
-  yylval = NULL;
-  return TOK_DEFAULT;
+    yylval = NULL;
+    return TOK_DEFAULT;
 }
 
 {DECDIGIT}+ {
-
-  yylval = get_conf_token();
-
-  yylval->integer = atoi(yytext);
-
-  return TOK_INTEGER;
-
+    yylval = get_integer_token(yytext);
+    return TOK_INTEGER;
 }
 
 
-"yes"|"no" {
-  yylval = get_conf_token();
-
-  if (strncmp(yytext, "yes", 3) == 0)
-    yylval->boolean = OLSR_TRUE;
-
-  else
-    yylval->boolean = OLSR_FALSE;
-
-  return TOK_BOOLEAN;
+"yes" {
+    yylval = get_boolean_token(OLSR_TRUE);
+    return TOK_BOOLEAN;
 }
 
+"no" {
+    yylval = get_boolean_token(OLSR_FALSE);
+    return TOK_BOOLEAN;
+}
 
+"site-local" {
+    yylval = get_boolean_token(OLSR_TRUE);
+    return TOK_IP6TYPE;
+}
 
-"site-local"|"global" {
-  yylval = get_conf_token();
-
-  if (strncmp(yytext, "site-local", 10) == 0)
-    yylval->boolean = OLSR_TRUE;
-
-  else
-    yylval->boolean = OLSR_FALSE;
-
-  return TOK_IP6TYPE;
+"global" {
+    yylval = get_boolean_token(OLSR_FALSE);
+    return TOK_IP6TYPE;
 }
 
 "Host" {
-  yylval = NULL;
-  return TOK_HOSTLABEL;
+    yylval = NULL;
+    return TOK_HOSTLABEL;
 }
 
 "Net" {
-  yylval = NULL;
-  return TOK_NETLABEL;
+    yylval = NULL;
+    return TOK_NETLABEL;
 }
 
 "MaxConnections" {
-  yylval = NULL;
-  return TOK_MAXIPC;
+    yylval = NULL;
+    return TOK_MAXIPC;
 }
 
 "DebugLevel" {
-  yylval = NULL;
-  return TOK_DEBUGLEVEL;
+    yylval = NULL;
+    return TOK_DEBUGLEVEL;
 }
 
 "IpVersion" {
-  yylval = NULL;
-  return TOK_IPVERSION;
+    yylval = NULL;
+    return TOK_IPVERSION;
 }
 
 "NicChgsPollInt" {
-  yylval = NULL;
-  return TOK_NICCHGSPOLLRT;
+    yylval = NULL;
+    return TOK_NICCHGSPOLLRT;
 }
 
 "Hna4" {
-  yylval = NULL;
-  return TOK_HNA4;
+    yylval = NULL;
+    return TOK_HNA4;
 }
 
 "Hna6" {
-  yylval = NULL;
-  return TOK_HNA6;
+    yylval = NULL;
+    return TOK_HNA6;
 }
 
 "LoadPlugin" {
-  yylval = NULL;
-  return TOK_PLUGIN;
-}
-
-"PlName" {
-  yylval = NULL;
-  return TOK_PLNAME;
+    yylval = NULL;
+    return TOK_PLUGIN;
 }
 
 "PlParam" {
-  yylval = NULL;
-  return TOK_PLPARAM;
+    yylval = NULL;
+    return TOK_PLPARAM;
 }
 
 "Interface" {
-  yylval = NULL;
-  return TOK_INTERFACE;
+    yylval = NULL;
+    return TOK_INTERFACE;
 }
 
 "AllowNoInt" {
-  yylval = NULL;
-  return TOK_NOINT;
+    yylval = NULL;
+    return TOK_NOINT;
 }
 
 "TosValue" {
-  yylval = NULL;
-  return TOK_TOS;
+    yylval = NULL;
+    return TOK_TOS;
 }
 
 "Willingness" {
-  yylval = NULL;
-  return TOK_WILLINGNESS;
+    yylval = NULL;
+    return TOK_WILLINGNESS;
 }
 
 "IpcConnect" {
-  yylval = NULL;
-  return TOK_IPCCON;
+    yylval = NULL;
+    return TOK_IPCCON;
 }
 
 "UseHysteresis" {
-  yylval = NULL;
-  return TOK_USEHYST;
+    yylval = NULL;
+    return TOK_USEHYST;
 }
 
 "HystScaling" {
-  yylval = NULL;
-  return TOK_HYSTSCALE;
+    yylval = NULL;
+    return TOK_HYSTSCALE;
 }
 
 "HystThrHigh" {
-  yylval = NULL;
-  return TOK_HYSTUPPER;
+    yylval = NULL;
+    return TOK_HYSTUPPER;
 }
 
 "HystThrLow" {
-  yylval = NULL;
-  return TOK_HYSTLOWER;
+    yylval = NULL;
+    return TOK_HYSTLOWER;
 }
 
 "Pollrate" {
-  yylval = NULL;
-  return TOK_POLLRATE;
+    yylval = NULL;
+    return TOK_POLLRATE;
 }
 
 
 "TcRedundancy" {
-  yylval = NULL;
-  return TOK_TCREDUNDANCY;
+    yylval = NULL;
+    return TOK_TCREDUNDANCY;
 }
 
 "MprCoverage" {
-  yylval = NULL;
-  return TOK_MPRCOVERAGE;
+    yylval = NULL;
+    return TOK_MPRCOVERAGE;
 }
 
 "LinkQualityLevel" {
-  yylval = NULL;
-  return TOK_LQ_LEVEL;
+    yylval = NULL;
+    return TOK_LQ_LEVEL;
 }
 
 "LinkQualityFishEye" {
-  yylval = NULL;
-  return TOK_LQ_FISH;
+    yylval = NULL;
+    return TOK_LQ_FISH;
 }
 
 "LinkQualityDijkstraLimit" {
-  yylval = NULL;
-  return TOK_LQ_DLIMIT;
+    yylval = NULL;
+    return TOK_LQ_DLIMIT;
 }
 
 "LinkQualityWinSize" {
-  yylval = NULL;
-  return TOK_LQ_WSIZE;
+    yylval = NULL;
+    return TOK_LQ_WSIZE;
 }
 
 "LinkQualityMult" {
-  yylval = NULL;
-  return TOK_LQ_MULT;
+    yylval = NULL;
+    return TOK_LQ_MULT;
 }
 
 "ClearScreen" {
-  yylval = NULL;
-  return TOK_CLEAR_SCREEN;
+    yylval = NULL;
+    return TOK_CLEAR_SCREEN;
 }
 
 "Weight" {
-  yylval = NULL;
-  return TOK_IFWEIGHT;
+    yylval = NULL;
+    return TOK_IFWEIGHT;
 }
 
 "Ip4Broadcast" {
-  yylval = NULL;
-  return TOK_IP4BROADCAST;
+    yylval = NULL;
+    return TOK_IP4BROADCAST;
 }
 "Ip6AddrType" {
-  yylval = NULL;
-  return TOK_IP6ADDRTYPE;
+    yylval = NULL;
+    return TOK_IP6ADDRTYPE;
 }
 "Ip6MulticastSite" {
-  yylval = NULL;
-  return TOK_IP6MULTISITE;
+    yylval = NULL;
+    return TOK_IP6MULTISITE;
 }
 "Ip6MulticastGlobal" {
-  yylval = NULL;
-  return TOK_IP6MULTIGLOBAL;
+    yylval = NULL;
+    return TOK_IP6MULTIGLOBAL;
 }
 "HelloInterval" {
-  yylval = NULL;
-  return TOK_HELLOINT;
+    yylval = NULL;
+    return TOK_HELLOINT;
 }
 "HelloValidityTime" {
-  yylval = NULL;
-  return TOK_HELLOVAL;
+    yylval = NULL;
+    return TOK_HELLOVAL;
 }
 "TcInterval" {
-  yylval = NULL;
-  return TOK_TCINT;
+    yylval = NULL;
+    return TOK_TCINT;
 }
 "TcValidityTime" {
-  yylval = NULL;
-  return TOK_TCVAL;
+    yylval = NULL;
+    return TOK_TCVAL;
 }
 "MidInterval" {
-  yylval = NULL;
-  return TOK_MIDINT;
+    yylval = NULL;
+    return TOK_MIDINT;
 }
 "MidValidityTime" {
-  yylval = NULL;
-  return TOK_MIDVAL;
+    yylval = NULL;
+    return TOK_MIDVAL;
 }
 "HnaInterval" {
-  yylval = NULL;
-  return TOK_HNAINT;
+    yylval = NULL;
+    return TOK_HNAINT;
 }
 "HnaValidityTime" {
-  yylval = NULL;
-  return TOK_HNAVAL;
+    yylval = NULL;
+    return TOK_HNAVAL;
 }
 "AutoDetectChanges" {
-  yylval = NULL;
-  return TOK_AUTODETCHG;
+    yylval = NULL;
+    return TOK_AUTODETCHG;
 }
 
 
 \n|\r\n {
-  current_line++;
+    current_line++;
 }
 
 \ |\t
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/defs.h olsrd-current/src/defs.h
--- olsrd-0.5.0/src/defs.h	2007-04-02 11:40:48.000000000 +0200
+++ olsrd-current/src/defs.h	2007-05-02 10:06:28.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: defs.h,v 1.56 2007/04/02 09:40:48 tlopatic Exp $
+ * $Id: defs.h,v 1.60 2007/05/02 08:06:28 bernd67 Exp $
  */
 
 
@@ -59,64 +59,67 @@
 #include "net_olsr.h" /* IPaddr -> string conversions is used by everyone */
 #include "olsr_cfg.h"
 
-#define SOFTWARE_VERSION "olsr.org - " VERSION
-#define OLSRD_VERSION_DATE "       *** " SOFTWARE_VERSION " (" __DATE__ ") ***\n"
+#define SOFTWARE_VERSION	"olsr.org - " VERSION
+#define OLSRD_VERSION_DATE	"       *** " SOFTWARE_VERSION " (" __DATE__ ") ***\n"
 
 #ifndef OLSRD_GLOBAL_CONF_FILE
-#define OLSRD_CONF_FILE_NAME "olsrd.conf"
-#define OLSRD_GLOBAL_CONF_FILE "/etc/" OLSRD_CONF_FILE_NAME
+#define OLSRD_CONF_FILE_NAME	"olsrd.conf"
+#define OLSRD_GLOBAL_CONF_FILE	"/etc/" OLSRD_CONF_FILE_NAME
 #endif
 
 #define	MAXMESSAGESIZE		1500	/* max broadcast size */
 #define UDP_IPV4_HDRSIZE        28
 #define UDP_IPV6_HDRSIZE        62
 
-#define MIN_PACKET_SIZE(ver)  (int)(sizeof(olsr_u8_t) * ((ver == AF_INET) ? 4 : 7))
+#define MIN_PACKET_SIZE(ver)	((int)(sizeof(olsr_u8_t) * (((ver) == AF_INET) ? 4 : 7)))
 /* Debug helper macro */
 #ifdef DEBUG
-#define olsr_debug(lvl,format,args...) \
-   OLSR_PRINTF(lvl, "%s (%s:%d): ", __func__, __FILE__, __LINE__); \
-   OLSR_PRINTF(lvl, format, ##args);
+#define olsr_debug(lvl, format, args...) do {                           \
+    OLSR_PRINTF(lvl, "%s (%s:%d): ", __func__, __FILE__, __LINE__);     \
+    OLSR_PRINTF(lvl, (format), ##args);                                 \
+  } while (0)
 #endif
 
 extern FILE *debug_handle;
 
 #ifdef NODEBUG
-#define OLSR_PRINTF(lvl, format, args...) \
-   { }
+#define OLSR_PRINTF(lvl, format, args...) do { } while(0)
 #else
-#define OLSR_PRINTF(lvl, format, args...) \
-   { \
-     if((olsr_cnf->debug_level >= lvl) && debug_handle) \
-        fprintf(debug_handle, format, ##args); \
-   }
+#define OLSR_PRINTF(lvl, format, args...) do {                  \
+    if((olsr_cnf->debug_level >= (lvl)) && debug_handle)          \
+      fprintf(debug_handle, (format), ##args);                    \
+  } while (0)
 #endif
 
 /* Provides a timestamp s1 milliseconds in the future
    according to system ticks returned by times(2) */
-#define GET_TIMESTAMP(s1) \
-        (now_times + ((s1) / olsr_cnf->system_tick_divider))
+#define GET_TIMESTAMP(s1)	(now_times + ((s1) / olsr_cnf->system_tick_divider))
 
-#define TIMED_OUT(s1) \
-        ((int)((s1) - now_times) < 0)
+#define TIMED_OUT(s1)	((int)((s1) - now_times) < 0)
 
 
+#define ARRAYSIZE(x)	(sizeof(x)/sizeof(*(x)))
+
 /*
  * Queueing macros
  */
 
 /* First "argument" is NOT a pointer! */
 
-#define QUEUE_ELEM(pre, new) \
-        pre.next->prev = new; \
-        new->next = pre.next; \
-        new->prev = &pre; \
-        pre.next = new
-
-#define DEQUEUE_ELEM(elem) \
-	elem->prev->next = elem->next; \
-	elem->next->prev = elem->prev
+#define QUEUE_ELEM(pre, new) do { \
+    pre.next->prev = new;         \
+    new->next = pre.next;         \
+    new->prev = &pre;             \
+    pre.next = new;               \
+  } while (0)
+
+#define DEQUEUE_ELEM(elem) do { \
+    elem->prev->next = elem->next;     \
+    elem->next->prev = elem->prev;     \
+  } while (0)
+
 
+#define CLOSE(fd)  do { close(fd); (fd) = -1; } while (0)
 
 /*
  * Global olsrd configuragtion
@@ -126,8 +129,8 @@
 
 /* Timer data */
 extern clock_t now_times;              /* current idea of times(2) reported uptime */
-extern struct timeval now;		/* current idea of time */
-extern struct tm *nowtm;		/* current idea of time (in tm) */
+extern struct timeval now;	       /* current idea of time */
+extern struct tm *nowtm;	       /* current idea of time (in tm) */
 
 /*
  *IPC functions
@@ -138,8 +141,10 @@
 int
 ipc_init(void);
 
+#if 0
 int
 ipc_input(int);
+#endif
 
 int
 shutdown_ipc(void);
@@ -148,9 +153,6 @@
 ipc_output(struct olsr *);
 
 int
-ipc_send_net_info(void);
-
-int
 ipc_route_send_rtentry(union olsr_ip_addr*, union olsr_ip_addr *, int, int, char *);
 
 #endif
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/duplicate_set.c olsrd-current/src/duplicate_set.c
--- olsrd-0.5.0/src/duplicate_set.c	2007-01-31 13:36:50.000000000 +0100
+++ olsrd-current/src/duplicate_set.c	2007-04-26 00:08:07.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: duplicate_set.c,v 1.13 2007/01/31 12:36:50 bernd67 Exp $
+ * $Id: duplicate_set.c,v 1.15 2007/04/25 22:08:07 bernd67 Exp $
  */
 
 
@@ -57,11 +57,11 @@
  *@return nada
  */
 void
-olsr_init_duplicate_table()
+olsr_init_duplicate_table(void)
 {
   int i;
 
-  OLSR_PRINTF(3, "Initializing duplicatetable - hashsize %d\n", HASHSIZE)
+  OLSR_PRINTF(3, "Initializing duplicatetable - hashsize %d\n", HASHSIZE);
 
   /* Since the holdingtime is rather large for duplicate
    * entries the timeoutfunction is only ran every 2 seconds
@@ -225,7 +225,7 @@
 
 
 void
-olsr_time_out_duplicate_table(void *foo)
+olsr_time_out_duplicate_table(void *foo __attribute__((unused)))
 {
   int i;
 
@@ -242,7 +242,7 @@
 #ifdef DEBUG
 	      OLSR_PRINTF(5, "DUP TIMEOUT[%s] s: %d\n", 
 		          olsr_ip_to_string(&tmp_dup_table->addr),
-		          tmp_dup_table->seqno)
+		          tmp_dup_table->seqno);
 #endif
 	      tmp_dup_table = tmp_dup_table->next;
 	      olsr_del_dup_entry(entry_to_delete);
@@ -332,7 +332,7 @@
     return 0;
   
 #ifdef DEBUG
-  OLSR_PRINTF(3, "Setting DUP %s/%d forwarded\n", olsr_ip_to_string(&tmp_dup_table->addr), seqno)
+  OLSR_PRINTF(3, "Setting DUP %s/%d forwarded\n", olsr_ip_to_string(&tmp_dup_table->addr), seqno);
 #endif
 
   /* Set forwarded */
@@ -344,14 +344,8 @@
   return 1;
 }
 
-
-
-
-
-
-
 void
-olsr_print_duplicate_table()
+olsr_print_duplicate_table(void)
 {
   int i;
 
@@ -370,6 +364,6 @@
 	  tmp_dup_table = tmp_dup_table->next;
 	}
     }
-printf("\n");
+  printf("\n");
 
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/generate_msg.c olsrd-current/src/generate_msg.c
--- olsrd-0.5.0/src/generate_msg.c	2006-01-07 09:16:20.000000000 +0100
+++ olsrd-current/src/generate_msg.c	2007-04-20 15:46:04.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: generate_msg.c,v 1.24 2006/01/07 08:16:20 kattemat Exp $
+ * $Id: generate_msg.c,v 1.25 2007/04/20 13:46:04 bernd67 Exp $
  */
 
 #include "generate_msg.h"
@@ -121,7 +121,7 @@
 
 
 void
-generate_stdout_pulse(void *foo)
+generate_stdout_pulse(void *foo __attribute__((unused)))
 {
   if(olsr_cnf->debug_level == 0)
     return;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/hashing.c olsrd-current/src/hashing.c
--- olsrd-0.5.0/src/hashing.c	2007-01-31 13:36:50.000000000 +0100
+++ olsrd-current/src/hashing.c	2007-04-20 15:46:04.000000000 +0200
@@ -36,10 +36,9 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: hashing.c,v 1.10 2007/01/31 12:36:50 bernd67 Exp $
+ * $Id: hashing.c,v 1.11 2007/04/20 13:46:04 bernd67 Exp $
  */
 
-
 #include "olsr_protocol.h"
 #include "hashing.h"
 #include "defs.h"
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/hna_set.c olsrd-current/src/hna_set.c
--- olsrd-0.5.0/src/hna_set.c	2005-05-29 14:47:45.000000000 +0200
+++ olsrd-current/src/hna_set.c	2007-04-26 00:08:08.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: hna_set.c,v 1.17 2005/05/29 12:47:45 br1 Exp $
+ * $Id: hna_set.c,v 1.19 2007/04/25 22:08:08 bernd67 Exp $
  */
 
 #include "defs.h"
@@ -52,7 +52,7 @@
  *Initialize the HNA set
  */
 int
-olsr_init_hna_set()
+olsr_init_hna_set(void)
 {
 
   int index;
@@ -128,7 +128,7 @@
   struct hna_entry *tmp_hna;
   olsr_u32_t hash;
 
-  //OLSR_PRINTF(5, "TC: lookup entry\n")
+  //OLSR_PRINTF(5, "TC: lookup entry\n");
 
   hash = olsr_hashing(gw);
   
@@ -265,7 +265,7 @@
  *@return nada
  */
 void
-olsr_time_out_hna_set(void *foo)
+olsr_time_out_hna_set(void *foo __attribute__((unused)))
 {
   int index;
 
@@ -319,7 +319,7 @@
  *@return nada
  */
 void
-olsr_print_hna_set()
+olsr_print_hna_set(void)
 {
   int index;
 
@@ -327,12 +327,12 @@
               nowtm->tm_hour,
               nowtm->tm_min,
               nowtm->tm_sec,
-	      (int)now.tv_usec/10000)
+	      (int)now.tv_usec/10000);
   
   if(olsr_cnf->ip_version == AF_INET)
-    OLSR_PRINTF(1, "IP net          netmask         GW IP\n")
+    OLSR_PRINTF(1, "IP net          netmask         GW IP\n");
   else
-    OLSR_PRINTF(1, "IP net/prefixlen               GW IP\n")
+    OLSR_PRINTF(1, "IP net/prefixlen               GW IP\n");
 
   for(index=0;index<HASHSIZE;index++)
     {
@@ -347,14 +347,14 @@
 	    {
 	      if(olsr_cnf->ip_version == AF_INET)
 		{
-		  OLSR_PRINTF(1, "%-15s ", olsr_ip_to_string(&tmp_net->A_network_addr))
-		  OLSR_PRINTF(1, "%-15s ", olsr_ip_to_string((union olsr_ip_addr *)&tmp_net->A_netmask.v4))
-		  OLSR_PRINTF(1, "%-15s\n", olsr_ip_to_string(&tmp_hna->A_gateway_addr))
+		  OLSR_PRINTF(1, "%-15s ", olsr_ip_to_string(&tmp_net->A_network_addr));
+		  OLSR_PRINTF(1, "%-15s ", olsr_ip_to_string((union olsr_ip_addr *)&tmp_net->A_netmask.v4));
+		  OLSR_PRINTF(1, "%-15s\n", olsr_ip_to_string(&tmp_hna->A_gateway_addr));
 		}
 	      else
 		{
-		  OLSR_PRINTF(1, "%-27s/%d", olsr_ip_to_string(&tmp_net->A_network_addr), tmp_net->A_netmask.v6)
-		  OLSR_PRINTF(1, "%s\n", olsr_ip_to_string(&tmp_hna->A_gateway_addr))
+		  OLSR_PRINTF(1, "%-27s/%d", olsr_ip_to_string(&tmp_net->A_network_addr), tmp_net->A_netmask.v6);
+		  OLSR_PRINTF(1, "%s\n", olsr_ip_to_string(&tmp_hna->A_gateway_addr));
 		}
 
 	      tmp_net = tmp_net->next;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/hysteresis.c olsrd-current/src/hysteresis.c
--- olsrd-0.5.0/src/hysteresis.c	2007-02-10 20:27:32.000000000 +0100
+++ olsrd-current/src/hysteresis.c	2007-04-26 00:08:08.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: hysteresis.c,v 1.18 2007/02/10 19:27:32 bernd67 Exp $
+ * $Id: hysteresis.c,v 1.20 2007/04/25 22:08:08 bernd67 Exp $
  */
 
 
@@ -51,7 +51,7 @@
 #define hhigh    olsr_cnf->hysteresis_param.thr_high
 #define hlow     olsr_cnf->hysteresis_param.thr_low
 
-inline float
+float
 olsr_hyst_calc_stability(float old_quality)
 {
   return (((1 - hscaling) * old_quality) + hscaling);
@@ -59,7 +59,7 @@
 
 
 
-inline float
+float
 olsr_hyst_calc_instability(float old_quality)
 {
   return ((1 - hscaling) * old_quality);
@@ -78,7 +78,7 @@
       if(entry->L_link_pending == 1)
 	{
 	  OLSR_PRINTF(1, "HYST[%s] link set to NOT pending!\n", 
-		      olsr_ip_to_string(&entry->neighbor_iface_addr))
+		      olsr_ip_to_string(&entry->neighbor_iface_addr));
 	  changes_neighborhood = OLSR_TRUE;
 	}
 
@@ -99,7 +99,7 @@
       if(entry->L_link_pending == 0)
 	{
 	  OLSR_PRINTF(1, "HYST[%s] link set to pending!\n", 
-		      olsr_ip_to_string(&entry->neighbor_iface_addr))
+		      olsr_ip_to_string(&entry->neighbor_iface_addr));
 	  changes_neighborhood = OLSR_TRUE;
 	}
       
@@ -148,7 +148,7 @@
 olsr_update_hysteresis_hello(struct link_entry *entry, double htime)
 {
 #ifdef DEBUG
-  OLSR_PRINTF(3, "HYST[%s]: HELLO update vtime %f\n", olsr_ip_to_string(&entry->neighbor_iface_addr), htime*1.5)
+  OLSR_PRINTF(3, "HYST[%s]: HELLO update vtime %f\n", olsr_ip_to_string(&entry->neighbor_iface_addr), htime*1.5);
 #endif
   /* hello timeout = current time + hint time */
   /* SET TIMER TO 1.5 TIMES THE INTERVAL */
@@ -173,7 +173,7 @@
     {
       link->L_link_quality = olsr_hyst_calc_stability(link->L_link_quality);
 #ifdef DEBUG
-      OLSR_PRINTF(3, "HYST[%s]: %0.3f\n", olsr_ip_to_string(remote), link->L_link_quality)
+      OLSR_PRINTF(3, "HYST[%s]: %0.3f\n", olsr_ip_to_string(remote), link->L_link_quality);
 #endif
 
       /* 
@@ -190,7 +190,7 @@
 	      link->L_link_quality = olsr_hyst_calc_instability(link->L_link_quality);
 #ifdef DEBUG
 	      OLSR_PRINTF(5, "HYST[%s] PACKET LOSS! %0.3f\n",
-			  olsr_ip_to_string(remote), link->L_link_quality)
+			  olsr_ip_to_string(remote), link->L_link_quality);
 #endif
 	      if(link->L_link_quality < olsr_cnf->hysteresis_param.thr_low)
 		break;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/hysteresis.h olsrd-current/src/hysteresis.h
--- olsrd-0.5.0/src/hysteresis.h	2006-12-14 12:29:19.000000000 +0100
+++ olsrd-current/src/hysteresis.h	2007-04-20 15:46:04.000000000 +0200
@@ -36,21 +36,17 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: hysteresis.h,v 1.8 2006/12/14 11:29:19 bernd67 Exp $
+ * $Id: hysteresis.h,v 1.9 2007/04/20 13:46:04 bernd67 Exp $
  */
-
-
 #ifndef _OLSR_HYSTERESIS
 #define _OLSR_HYSTERESIS
 
 #include "link_set.h"
 
-
-
-inline float
+float
 olsr_hyst_calc_stability(float);
 
-inline int
+int
 olsr_process_hysteresis(struct link_entry *);
 
 float
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/interfaces.c olsrd-current/src/interfaces.c
--- olsrd-0.5.0/src/interfaces.c	2006-04-17 20:31:09.000000000 +0200
+++ olsrd-current/src/interfaces.c	2007-05-14 00:23:55.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: interfaces.c,v 1.29 2006/04/17 18:31:09 kattemat Exp $
+ * $Id: interfaces.c,v 1.32 2007/05/13 22:23:55 bernd67 Exp $
  */
 
 #include "defs.h"
@@ -72,7 +72,7 @@
  *@return the number of interfaces configured
  */
 int
-ifinit()
+ifinit(void)
 {
   struct olsr_if *tmp_if;
 
@@ -101,7 +101,7 @@
       //(addrsock6.sin6_addr).s_addr = IN6ADDR_ANY_INIT;
     }
 
-  OLSR_PRINTF(1, "\n ---- Interface configuration ---- \n\n")
+  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)
       {
@@ -123,7 +123,7 @@
 
 
 olsr_u32_t
-get_if_property_id()
+get_if_property_id(void)
 {
   return if_property_id++;
 }
@@ -342,7 +342,6 @@
   interf_n->cnf = NULL;
   interf_n->interf = NULL;
   interf_n->configured = 0;
-  interf_n->index = olsr_cnf->ifcnt++;
 
   interf_n->host_emul = hemu ? OLSR_TRUE : OLSR_FALSE;
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/interfaces.h olsrd-current/src/interfaces.h
--- olsrd-0.5.0/src/interfaces.h	2007-02-10 20:59:51.000000000 +0100
+++ olsrd-current/src/interfaces.h	2007-05-14 00:23:55.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: interfaces.h,v 1.38 2007/02/10 19:59:51 bernd67 Exp $
+ * $Id: interfaces.h,v 1.40 2007/05/13 22:23:55 bernd67 Exp $
  */
 
 
@@ -111,7 +111,7 @@
  */
 struct olsr_netbuf
 {
-  olsr_u8_t *buff;/* Pointer to the allocated buffer */
+  olsr_u8_t *buff;     /* Pointer to the allocated buffer */
   int bufsize;    /* Size of the buffer */
   int maxsize;    /* Max bytes of payload that can be added to the buffer */
   int pending;    /* How much data is currently pending in the buffer */
@@ -141,7 +141,6 @@
   int	        int_flags;			/* see below */
   char	        *int_name;			/* from kernel if structure */
   int           if_index;                       /* Kernels index of this interface */
-  int           if_nr;                          /* This interfaces index internally*/
   int           is_wireless;                    /* wireless interface or not*/
   olsr_u16_t    olsr_seqnum;                    /* Olsr message seqno */
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/ipc_frontend.c olsrd-current/src/ipc_frontend.c
--- olsrd-0.5.0/src/ipc_frontend.c	2006-01-07 09:16:20.000000000 +0100
+++ olsrd-current/src/ipc_frontend.c	2007-04-28 22:45:06.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: ipc_frontend.c,v 1.28 2006/01/07 08:16:20 kattemat Exp $
+ * $Id: ipc_frontend.c,v 1.31 2007/04/28 20:45:06 bernd67 Exp $
  */
 
 /*
@@ -65,6 +65,16 @@
 #define MSG_NOSIGNAL 0
 #endif
 
+static int ipc_sock = -1;
+static int ipc_conn = -1;
+
+static int
+ipc_send_all_routes(int fd);
+
+static int
+ipc_send_net_info(int fd);
+
+
 /**
  *Create the socket to use for IPC to the
  *GUI front-end
@@ -72,7 +82,7 @@
  *@return the socket FD
  */
 int
-ipc_init()
+ipc_init(void)
 {
   //int flags;
   struct   sockaddr_in sin;
@@ -104,14 +114,14 @@
   if(bind(ipc_sock, (struct sockaddr *) &sin, sizeof(sin)) == -1) 
     {
       perror("IPC bind");
-      OLSR_PRINTF(1, "Will retry in 10 seconds...\n")
+      OLSR_PRINTF(1, "Will retry in 10 seconds...\n");
       sleep(10);
       if(bind(ipc_sock, (struct sockaddr *) &sin, sizeof(sin)) == -1) 
 	{
 	  perror("IPC bind");
 	  olsr_exit("IPC bind", EXIT_FAILURE);
 	}
-      OLSR_PRINTF(1, "OK\n")
+      OLSR_PRINTF(1, "OK\n");
     }
 
   /* show that we are willing to listen */
@@ -138,27 +148,27 @@
 
   addrlen = sizeof (struct sockaddr_in);
   
-  if ((ipc_connection = accept(ipc_sock, (struct sockaddr *)  &pin, &addrlen)) == -1)
+  if ((ipc_conn = accept(fd, (struct sockaddr *)  &pin, &addrlen)) == -1)
     {
       perror("IPC accept");
       olsr_exit("IPC accept", EXIT_FAILURE);
     }
   else
     {
-      OLSR_PRINTF(1, "Front end connected\n")
+      OLSR_PRINTF(1, "Front end connected\n");
       addr = inet_ntoa(pin.sin_addr);
       if(ipc_check_allowed_ip((union olsr_ip_addr *)&pin.sin_addr.s_addr))
 	{
 	  ipc_active = OLSR_TRUE;
-	  ipc_send_net_info();
-	  ipc_send_all_routes();
-	  OLSR_PRINTF(1, "Connection from %s\n",addr)
+	  ipc_send_net_info(ipc_conn);
+	  ipc_send_all_routes(ipc_conn);
+	  OLSR_PRINTF(1, "Connection from %s\n",addr);
 	}
       else
 	{
-	  OLSR_PRINTF(1, "Front end-connection from foregin host(%s) not allowed!\n", addr)
+	  OLSR_PRINTF(1, "Front end-connection from foregin host(%s) not allowed!\n", addr);
 	  olsr_syslog(OLSR_LOG_ERR, "OLSR: Front end-connection from foregin host(%s) not allowed!\n", addr);
-	  close(ipc_connection);
+	  CLOSE(ipc_conn);
 	}
     }
 
@@ -192,6 +202,7 @@
   return OLSR_FALSE;
 }
 
+#if 0
 /**
  *Read input from the IPC socket. Not in use.
  *
@@ -200,9 +211,8 @@
  *@return 1
  */
 int
-ipc_input(int sock)
+ipc_input(int sock __attribute__((unused)))
 {
-  /*
   union 
   {
     char	buf[MAXPACKETSIZE+1];
@@ -215,10 +225,9 @@
       perror("recv");
       exit(1);
     }
-*/
   return 1;
 }
-
+#endif
 
 /**
  *Sends a olsr packet on the IPC socket.
@@ -228,7 +237,7 @@
  *@return negative on error
  */
 void
-frontend_msgparser(union olsr_message *msg, struct interface *in_if, union olsr_ip_addr *from_addr)
+frontend_msgparser(union olsr_message *msg, struct interface *in_if __attribute__((unused)), union olsr_ip_addr *from_addr __attribute__((unused)))
 {
   int size;
 
@@ -240,16 +249,13 @@
   else
     size = ntohs(msg->v6.olsr_msgsize);
   
-  if (send(ipc_connection, (void *)msg, size, MSG_NOSIGNAL) < 0) 
+  if (send(ipc_conn, (void *)msg, size, MSG_NOSIGNAL) < 0) 
     {
-      OLSR_PRINTF(1, "(OUTPUT)IPC connection lost!\n")
-      close(ipc_connection);
+      OLSR_PRINTF(1, "(OUTPUT)IPC connection lost!\n");
+      CLOSE(ipc_conn);
       //olsr_cnf->open_ipc = 0;
       ipc_active = OLSR_FALSE;
-      return;
     }
-  
-  return;
 }
 
 
@@ -308,10 +314,11 @@
   printf("\n");
   */
   
-  if (send(ipc_connection, tmp, IPC_PACK_SIZE, MSG_NOSIGNAL) < 0) // MSG_NOSIGNAL to avoid sigpipe
+  if (send(ipc_conn, tmp, IPC_PACK_SIZE, MSG_NOSIGNAL) < 0) // MSG_NOSIGNAL to avoid sigpipe
     {
-      OLSR_PRINTF(1, "(RT_ENTRY)IPC connection lost!\n")
-      close(ipc_connection);
+      OLSR_PRINTF(1, "(RT_ENTRY)IPC connection lost!\n");
+      CLOSE(ipc_conn);
+
       //olsr_cnf->open_ipc = 0;
       ipc_active = OLSR_FALSE;
       return -1;
@@ -322,8 +329,8 @@
 
 
 
-int
-ipc_send_all_routes()
+static int
+ipc_send_all_routes(int fd)
 {
   struct rt_entry  *destination;
   struct interface *ifn;
@@ -370,10 +377,10 @@
 
 	  tmp = (char *) &packet;
   
-	  if (send(ipc_connection, tmp, IPC_PACK_SIZE, MSG_NOSIGNAL) < 0) // MSG_NOSIGNAL to avoid sigpipe
+	  if (send(fd, tmp, IPC_PACK_SIZE, MSG_NOSIGNAL) < 0) // MSG_NOSIGNAL to avoid sigpipe
 	    {
-	      OLSR_PRINTF(1, "(RT_ENTRY)IPC connection lost!\n")
-	      close(ipc_connection);
+	      OLSR_PRINTF(1, "(RT_ENTRY)IPC connection lost!\n");
+	      CLOSE(ipc_conn);
 	      //olsr_cnf->open_ipc = 0;
 	      ipc_active = OLSR_FALSE;
 	      return -1;
@@ -415,10 +422,10 @@
 
 	  tmp = (char *) &packet;
   
-	  if (send(ipc_connection, tmp, IPC_PACK_SIZE, MSG_NOSIGNAL) < 0) // MSG_NOSIGNAL to avoid sigpipe
+	  if (send(ipc_conn, tmp, IPC_PACK_SIZE, MSG_NOSIGNAL) < 0) // MSG_NOSIGNAL to avoid sigpipe
 	    {
-	      OLSR_PRINTF(1, "(RT_ENTRY)IPC connection lost!\n")
-	      close(ipc_connection);
+	      OLSR_PRINTF(1, "(RT_ENTRY)IPC connection lost!\n");
+	      CLOSE(ipc_conn);
 	      //olsr_cnf->open_ipc = 0;
 	      ipc_active = OLSR_FALSE;
 	      return -1;
@@ -440,8 +447,8 @@
  *
  *@return negative on error
  */
-int
-ipc_send_net_info()
+static int
+ipc_send_net_info(int fd)
 {
   struct ipc_net_msg *net_msg;
   //int x, i;
@@ -452,7 +459,7 @@
 
   msg = (char *)net_msg;
 
-  OLSR_PRINTF(1, "Sending net-info to front end...\n")
+  OLSR_PRINTF(1, "Sending net-info to front end...\n");
   
   memset(net_msg, 0, sizeof(struct ipc_net_msg));
   
@@ -518,10 +525,10 @@
   */
 
 
-  if (send(ipc_connection, (char *)net_msg, sizeof(struct ipc_net_msg), MSG_NOSIGNAL) < 0) 
+  if (send(fd, (char *)net_msg, sizeof(struct ipc_net_msg), MSG_NOSIGNAL) < 0) 
     {
-      OLSR_PRINTF(1, "(NETINFO)IPC connection lost!\n")
-      close(ipc_connection);
+      OLSR_PRINTF(1, "(NETINFO)IPC connection lost!\n");
+      CLOSE(ipc_conn);
       //olsr_cnf->open_ipc = 0;
       return -1;
     }
@@ -533,11 +540,11 @@
 
 
 int
-shutdown_ipc()
+shutdown_ipc(void)
 {
-  OLSR_PRINTF(1, "Shutting down IPC...\n")
-  close(ipc_sock);
-  close(ipc_connection);
+  OLSR_PRINTF(1, "Shutting down IPC...\n");
+  CLOSE(ipc_sock);
+  CLOSE(ipc_conn);
   
   return 1;
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/ipc_frontend.h olsrd-current/src/ipc_frontend.h
--- olsrd-0.5.0/src/ipc_frontend.h	2004-11-21 12:28:56.000000000 +0100
+++ olsrd-current/src/ipc_frontend.h	2007-04-20 15:46:04.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: ipc_frontend.h,v 1.12 2004/11/21 11:28:56 kattemat Exp $
+ * $Id: ipc_frontend.h,v 1.13 2007/04/20 13:46:04 bernd67 Exp $
  */
 
 /*
@@ -98,8 +98,6 @@
 };
 
 
-int ipc_connection;
-int ipc_sock;
 olsr_bool ipc_active;
 
 olsr_bool
@@ -108,9 +106,6 @@
 void
 ipc_accept(int);
 
-int
-ipc_send_all_routes(void);
-
 void
 frontend_msgparser(union olsr_message *, struct interface *, union olsr_ip_addr *);
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/link_set.c olsrd-current/src/link_set.c
--- olsrd-0.5.0/src/link_set.c	2007-02-10 20:27:32.000000000 +0100
+++ olsrd-current/src/link_set.c	2007-04-26 00:08:09.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: link_set.c,v 1.66 2007/02/10 19:27:32 bernd67 Exp $
+ * $Id: link_set.c,v 1.68 2007/04/25 22:08:09 bernd67 Exp $
  */
 
 
@@ -79,19 +79,19 @@
 
 
 clock_t 
-get_hold_time_neighbor()
+get_hold_time_neighbor(void)
 {
   return hold_time_neighbor;
 }
 
 struct link_entry *
-get_link_set()
+get_link_set(void)
 {
   return link_set;
 }
 
 void
-olsr_init_link_set()
+olsr_init_link_set(void)
 {
 
   /* Timers */
@@ -145,7 +145,7 @@
       if(entry->L_link_pending == 1)
 	{
 #ifdef DEBUG
-	  OLSR_PRINTF(3, "HYST[%s]: Setting to HIDE\n", olsr_ip_to_string(&entry->neighbor_iface_addr))
+	  OLSR_PRINTF(3, "HYST[%s]: Setting to HIDE\n", olsr_ip_to_string(&entry->neighbor_iface_addr));
 #endif
 	  return HIDE_LINK;
 	}
@@ -470,7 +470,7 @@
    */
 
 #ifdef DEBUG
-  OLSR_PRINTF(1, "Adding %s=>%s to link set\n", olsr_ip_to_string(local), olsr_ip_to_string(remote))
+  OLSR_PRINTF(1, "Adding %s=>%s to link set\n", olsr_ip_to_string(local), olsr_ip_to_string(remote));
 #endif
 
   /* a new tuple is created with... */
@@ -561,7 +561,7 @@
     {
       neighbor = olsr_insert_neighbor_table(remote_main);
 #ifdef DEBUG
-      OLSR_PRINTF(3, "ADDING NEW NEIGHBOR ENTRY %s FROM LINK SET\n", olsr_ip_to_string(remote_main))
+      OLSR_PRINTF(3, "ADDING NEW NEIGHBOR ENTRY %s FROM LINK SET\n", olsr_ip_to_string(remote_main));
 #endif
     }
 
@@ -587,12 +587,13 @@
        * We'll go for one that is hopefully long
        * enough in most cases. 10 seconds
        */
+
     /* Erik Tromp - commented out. It is not RFC-compliant. Also, MID aliases
      * that are not explicitly declared by a node will be removed as soon as
      * the olsr_prune_aliases(...) function is called.
      *
-     * OLSR_PRINTF(1, "Adding MID alias main %s ", olsr_ip_to_string(remote_main))
-     * OLSR_PRINTF(1, "-> %s based on HELLO\n\n", olsr_ip_to_string(remote))
+     * OLSR_PRINTF(1, "Adding MID alias main %s ", olsr_ip_to_string(remote_main));
+     * OLSR_PRINTF(1, "-> %s based on HELLO\n\n", olsr_ip_to_string(remote));
      * insert_mid_alias(remote_main, remote, MID_ALIAS_HACK_VTIME);
      */
     }
@@ -819,7 +820,7 @@
  *
  */
 static void
-olsr_time_out_link_set()
+olsr_time_out_link_set(void)
 {
 
   struct link_entry *tmp_link_set, *last_link_entry;
@@ -896,7 +897,7 @@
  *@return nada
  */
 static void
-olsr_time_out_hysteresis()
+olsr_time_out_hysteresis(void)
 {
   struct link_entry *tmp_link_set;
 
@@ -910,7 +911,7 @@
       if(TIMED_OUT(tmp_link_set->hello_timeout))
 	{
 	  tmp_link_set->L_link_quality = olsr_hyst_calc_instability(tmp_link_set->L_link_quality);
-	  OLSR_PRINTF(1, "HYST[%s] HELLO timeout %0.3f\n", olsr_ip_to_string(&tmp_link_set->neighbor_iface_addr), tmp_link_set->L_link_quality)
+	  OLSR_PRINTF(1, "HYST[%s] HELLO timeout %0.3f\n", olsr_ip_to_string(&tmp_link_set->neighbor_iface_addr), tmp_link_set->L_link_quality);
 	  /* Update hello_timeout - NO SLACK THIS TIME */
 	  tmp_link_set->hello_timeout = GET_TIMESTAMP(tmp_link_set->last_htime*1000);
 	  /* Recalculate status */
@@ -942,17 +943,17 @@
               nowtm->tm_hour,
               nowtm->tm_min,
               nowtm->tm_sec,
-              (int)now.tv_usec/10000)
+              (int)now.tv_usec/10000);
 
   if (olsr_cnf->ip_version == AF_INET)
   {
-    OLSR_PRINTF(1, "IP address       hyst   LQ     lost   total  NLQ    ETX\n")
+    OLSR_PRINTF(1, "IP address       hyst   LQ     lost   total  NLQ    ETX\n");
     fstr = "%-15s  %5.3f  %5.3f  %-3d    %-3d    %5.3f  %.2f\n";
   }
 
   else
   {
-    OLSR_PRINTF(1, "IP address                               hyst   LQ     lost   total  NLQ    ETX\n")
+    OLSR_PRINTF(1, "IP address                               hyst   LQ     lost   total  NLQ    ETX\n");
     fstr = "%-39s  %5.3f  %5.3f  %-3d    %-3d    %5.3f  %.2f\n";
   }
 
@@ -970,7 +971,7 @@
     OLSR_PRINTF(1, fstr, olsr_ip_to_string(&walker->neighbor_iface_addr),
                 walker->L_link_quality, walker->loss_link_quality,
 		walker->lost_packets, walker->total_packets,
-		walker->neigh_link_quality, etx)
+		walker->neigh_link_quality, etx);
   }
 }
 
@@ -1059,7 +1060,7 @@
       }
 
       else
-        OLSR_PRINTF(3, "Skipping Dijkstra (1)\n")
+        OLSR_PRINTF(3, "Skipping Dijkstra (1)\n");
 
       // create a new ANSN
 
@@ -1138,7 +1139,7 @@
   entry->loss_timeout = GET_TIMESTAMP(entry->loss_hello_int * 1500.0);
 }
 
-static void olsr_time_out_packet_loss()
+static void olsr_time_out_packet_loss(void)
 {
   struct link_entry *walker;
 
@@ -1167,7 +1168,7 @@
     }
 }
 
-void olsr_update_dijkstra_link_qualities()
+void olsr_update_dijkstra_link_qualities(void)
 {
   struct link_entry *walker;
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/linux/apm.c olsrd-current/src/linux/apm.c
--- olsrd-0.5.0/src/linux/apm.c	2006-11-26 01:32:14.000000000 +0100
+++ olsrd-current/src/linux/apm.c	2007-04-26 00:08:17.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: apm.c,v 1.16 2006/11/26 00:32:14 bernd67 Exp $
+ * $Id: apm.c,v 1.18 2007/04/25 22:08:17 bernd67 Exp $
  */
 
 /*
@@ -128,56 +128,46 @@
   struct olsr_apm_info ainfo;
 
   method = -1;
-  OLSR_PRINTF(3, "Initializing APM\n")
+  OLSR_PRINTF(3, "Initializing APM\n");
 
   if(((fd_index = acpi_probe()) >= 0) && apm_read_acpi(&ainfo))
     method = USE_ACPI;
   else if(apm_read_apm(&ainfo))
     method = USE_APM;
   
-  if(method)
+  if(method != -1)
     apm_printinfo(&ainfo);
 
   return method;
 }
 
+
 void
 apm_printinfo(struct olsr_apm_info *ainfo)
 {
   OLSR_PRINTF(5, "APM info:\n\tAC status %d\n\tBattery percentage %d%%\n\tBattery time left %d mins\n\n",
 	      ainfo->ac_line_status,
 	      ainfo->battery_percentage,
-	      ainfo->battery_time_left)
-
-  return;
+	      ainfo->battery_time_left);
 }
 
 
-
 int
 apm_read(struct olsr_apm_info *ainfo)
 {
-
   switch(method)
     {
     case(USE_APM):
       return apm_read_apm(ainfo);
-      break;
     case(USE_ACPI):
       return apm_read_acpi(ainfo);
-      break;
     default:
-      return 0;
       break;
     }
-
-  return 1;
+  return 0;
 }
 
 
-
-
-
 static int
 apm_read_apm(struct olsr_apm_info *ainfo)
 {
@@ -190,14 +180,14 @@
   if((apm_procfile = fopen(APM_PROC, "r")) == NULL)
     return 0;
 
-  if(fgets(buffer, sizeof(buffer) - 1, apm_procfile) == NULL)
+  if(fgets(buffer, sizeof(buffer), apm_procfile) == NULL)
     {
       fclose(apm_procfile);
       /* Try re-opening the file */
       if((apm_procfile = fopen(APM_PROC, "r")) != NULL)
 	return 0;
 
-      if(fgets(buffer, sizeof(buffer) - 1, apm_procfile) == NULL)
+      if(fgets(buffer, sizeof(buffer), apm_procfile) == NULL)
 	{
 	  /* Giving up */
 	  fprintf(stderr, "OLSRD: Could not read APM info - setting willingness to default");
@@ -205,8 +195,8 @@
 	  return 0;
 	}
     }
+  fclose(apm_procfile);
 
-  buffer[sizeof(buffer) - 1] = '\0';
 
   //printf("READ: %s\n", buffer);
 
@@ -245,18 +235,14 @@
   ainfo->battery_percentage = lainfo.battery_percentage;
   ainfo->battery_time_left = lainfo.battery_time;
   
-  fclose(apm_procfile);
-
   return 1;
 }
 
 
-
 static int
 apm_read_acpi(struct olsr_apm_info *ainfo)
 {
   FILE *fd;
-  char s1[32], s2[32], s3[32], s4[32], inbuff[127];
   int bat_max = 5000; /* Find some sane value */
   int bat_val = 0;
   
@@ -271,22 +257,19 @@
       return 1;
     }
 
-
   /* Get maxvalue */
   if((fd = fopen(acpi_info[fd_index], "r")) == NULL) 
     return 0;
-
-  fgets(inbuff, 127, fd);
-  while(!feof(fd)) 
+  
+  for(;;) 
     {
-      sscanf(inbuff, "%s %s %s %s", s1, s2, s3, s4);
-	
+      char s1[32], s2[32], s3[32], s4[32], inbuff[127];
+      if (fgets(inbuff, sizeof(inbuff), fd) == NULL)
+        break;
+
+      sscanf(inbuff, "%s %s %s %s", s1, s2, s3, s4);	
       if (!strcasecmp(s2, "full")) 
-	{
 	  bat_max = atoi(s4);
-	}
-
-      fgets(inbuff, 127, fd);
     }
   fclose(fd);
 
@@ -295,23 +278,19 @@
     return 0;
 
   /* Extract battery status */
-  fgets(inbuff, 127, fd);
-  while(!feof(fd)) 
+  for(;;)
     {
+      char s1[32], s2[32], s3[32], s4[32], inbuff[127];
+      if (fgets(inbuff, sizeof(inbuff), fd) == NULL)
+        break;
       sscanf(inbuff, "%s %s %s %s", s1, s2, s3, s4);
 
       /* find remaining juice */
       if(!strcasecmp(s1, "Remaining")) 
-	{
 	  bat_val = atoi(s3);
-	}
-
-      fgets(inbuff, 127, fd);
     }
-
   fclose(fd);
 
-
   ainfo->ac_line_status = OLSR_BATTERY_POWERED;
   ainfo->battery_percentage = bat_val * 100 / bat_max;
 
@@ -319,57 +298,56 @@
 }
 
 
-
 static int
 acpi_probe(void)
 {
-  char s1[32], s2[32];
-  FILE *fd;
-  olsr_u16_t i;
+  unsigned int i;
   
-
   /* First check for AC power */
 
   for(i = 0; i < ACPI_AC_CNT; i++)
     {
+      char s1[32], s2[32];
+      int rc;
+      FILE *fd = fopen(acpi_ac[i], "r");
+  
       /* Try opening the info file */
-      if((fd = fopen(acpi_ac[i], "r")) == NULL)
+      if(fd == NULL)
 	continue;
       
       /* Extract info */
-      if(fscanf(fd, "%s %s", s1, s2) < 2)
-	{
-	  fclose(fd);
-	  continue;
-	}
-      
+      rc = fscanf(fd, "%s %s", s1, s2);
+
       /* Close info entry */
       fclose(fd);
 
+      if(rc < 2)
+	  continue;
+      
       /* Running on AC power */
       if(!strcasecmp(s2, "on-line"))
 	return -1;
-
     }
 
-  /* Only checking the first found batery entry... */
+  /* Only checking the first found battery entry... */
   for(i = 0; i < ACPI_BT_CNT; i ++)
     {
-
+      char s1[32], s2[32];
+      int rc;
+      FILE *fd = fopen(acpi_info[i], "r");
+  
       /* Try opening the info file */
-      if((fd = fopen(acpi_info[i], "r")) == NULL)
+      if(fd == NULL)
 	continue;
 
       /* Extract info */
-      if(fscanf(fd, "%s %s", s1, s2) < 2)
-	{
-	  fclose(fd);
-	  continue;
-	}
-
+      rc = fscanf(fd, "%s %s", s1, s2);
       /* Close info entry */
       fclose(fd);
 
+      if(rc < 2)
+	  continue;
+
       /* Check if battery is present */
       if((!strcasecmp(s1, "present:")) && (!strcasecmp(s2, "no"))) 
 	continue;
@@ -379,11 +357,9 @@
 	continue;
 
       fclose(fd);
-
       return i;
     }
 
   /* No battery found */
   return -1;
 }
-
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/linux/kernel_routes.c olsrd-current/src/linux/kernel_routes.c
--- olsrd-0.5.0/src/linux/kernel_routes.c	2007-01-31 13:36:50.000000000 +0100
+++ olsrd-current/src/linux/kernel_routes.c	2007-05-17 22:30:09.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: kernel_routes.c,v 1.20 2007/01/31 12:36:50 bernd67 Exp $
+ * $Id: kernel_routes.c,v 1.23 2007/05/17 20:30:09 bernd67 Exp $
  */
 
 
@@ -65,15 +65,14 @@
 {
   struct rtentry kernel_route;
   int tmp;
-  char dst_str[16], mask_str[16], router_str[16];
-
-  inet_ntop(AF_INET, &destination->rt_dst.v4, dst_str, 16);
-  inet_ntop(AF_INET, &destination->rt_mask.v4, mask_str, 16);
-  inet_ntop(AF_INET, &destination->rt_router.v4, router_str, 16);
+  char dst_str[INET_ADDRSTRLEN], mask_str[INET_ADDRSTRLEN], router_str[INET_ADDRSTRLEN];
 
   OLSR_PRINTF(1, "(ioctl)Adding route with metric %d to %s/%s via %s/%s.\n",
-              destination->rt_metric, dst_str, mask_str, router_str,
-              destination->rt_if->int_name)
+              destination->rt_metric,
+              inet_ntop(AF_INET, &destination->rt_dst.v4, dst_str, sizeof(dst_str)),
+              inet_ntop(AF_INET, &destination->rt_mask.v4, mask_str, sizeof(mask_str)),
+              inet_ntop(AF_INET, &destination->rt_router.v4, router_str, sizeof(router_str)),
+              destination->rt_if->int_name);
   
   memset(&kernel_route, 0, sizeof(struct rtentry));
 
@@ -104,14 +103,7 @@
   /*
    * Set interface
    */
-  if((kernel_route.rt_dev = malloc(strlen(destination->rt_if->int_name) + 1)) == 0)
-    {
-      fprintf(stderr, "Out of memory!\n%s\n", strerror(errno));
-      olsr_exit(__func__, EXIT_FAILURE);
-    }
-
-  strcpy(kernel_route.rt_dev, destination->rt_if->int_name);
-
+  kernel_route.rt_dev = destination->rt_if->int_name;
   
   //printf("Inserting route entry on device %s\n\n", kernel_route.rt_dev);
   
@@ -140,13 +132,6 @@
 			       destination->rt_if->int_name); /* Send interface name */
       }
   
-  
-  if (ifnet && kernel_route.rt_dev)
-    {
-      free(kernel_route.rt_dev);
-    }
-  
-  
   return tmp;
 }
 
@@ -170,7 +155,7 @@
 
   OLSR_PRINTF(2, "(ioctl)Adding route: %s(hopc %d)\n", 
 	      olsr_ip_to_string(&destination->rt_dst), 
-	      destination->rt_metric + 1)
+	      destination->rt_metric + 1);
   
 
   memset(&zeroaddr, 0, olsr_cnf->ipsize); /* Use for comparision */
@@ -201,8 +186,8 @@
 
 
   
-  //OLSR_PRINTF(3, "Adding route to %s using gw ", olsr_ip_to_string((union olsr_ip_addr *)&kernel_route.rtmsg_dst))
-  //OLSR_PRINTF(3, "%s\n", olsr_ip_to_string((union olsr_ip_addr *)&kernel_route.rtmsg_gateway))
+  //OLSR_PRINTF(3, "Adding route to %s using gw ", olsr_ip_to_string((union olsr_ip_addr *)&kernel_route.rtmsg_dst));
+  //OLSR_PRINTF(3, "%s\n", olsr_ip_to_string((union olsr_ip_addr *)&kernel_route.rtmsg_gateway));
 
   if((tmp = ioctl(olsr_cnf->ioctl_s, SIOCADDRT, &kernel_route)) >= 0)
     {
@@ -234,14 +219,13 @@
 {
   struct rtentry kernel_route;
   int tmp;
-  char dst_str[16], mask_str[16], router_str[16];
-
-  inet_ntop(AF_INET, &destination->rt_dst.v4, dst_str, 16);
-  inet_ntop(AF_INET, &destination->rt_mask.v4, mask_str, 16);
-  inet_ntop(AF_INET, &destination->rt_router.v4, router_str, 16);
+  char dst_str[INET_ADDRSTRLEN], mask_str[INET_ADDRSTRLEN], router_str[INET_ADDRSTRLEN];
 
   OLSR_PRINTF(1, "(ioctl)Deleting route with metric %d to %s/%s via %s.\n",
-              destination->rt_metric, dst_str, mask_str, router_str)
+              destination->rt_metric,
+              inet_ntop(AF_INET, &destination->rt_dst.v4, dst_str, sizeof(dst_str)),
+              inet_ntop(AF_INET, &destination->rt_mask.v4, mask_str, sizeof(mask_str)),
+              inet_ntop(AF_INET, &destination->rt_router.v4, router_str, sizeof(router_str)));
   
   memset(&kernel_route,0,sizeof(struct rtentry));
 
@@ -309,10 +293,10 @@
 
   OLSR_PRINTF(2, "(ioctl)Deleting route: %s(hopc %d)\n", 
 	      olsr_ip_to_string(&destination->rt_dst), 
-	      destination->rt_metric)
+	      destination->rt_metric);
 
 
-  OLSR_PRINTF(1, "Deleting route: %s\n", olsr_ip_to_string(&tmp_addr))
+  OLSR_PRINTF(1, "Deleting route: %s\n", olsr_ip_to_string(&tmp_addr));
 
   memset(&kernel_route,0,sizeof(struct in6_rtmsg));
 
@@ -346,16 +330,14 @@
 
 
 int
-delete_all_inet_gws()
-{
-  struct rtentry kernel_route;
-  
+delete_all_inet_gws(void)
+{  
   int s;
   char buf[BUFSIZ], *cp, *cplim;
   struct ifconf ifc;
   struct ifreq *ifr;
   
-  OLSR_PRINTF(1, "Internet gateway detected...\nTrying to delete default gateways\n")
+  OLSR_PRINTF(1, "Internet gateway detected...\nTrying to delete default gateways\n");
   
   /* Get a socket */
   if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) 
@@ -375,20 +357,20 @@
     }
 
   ifr = ifc.ifc_req;
-#define size(p) (sizeof (p))
   cplim = buf + ifc.ifc_len; /*skip over if's with big ifr_addr's */
-  for (cp = buf; cp < cplim;cp += sizeof (ifr->ifr_name) + size(ifr->ifr_addr)) 
+  for (cp = buf; cp < cplim; cp += sizeof (ifr->ifr_name) + sizeof(ifr->ifr_addr)) 
     {
+      struct rtentry kernel_route;
       ifr = (struct ifreq *)cp;
       
       
       if(strcmp(ifr->ifr_ifrn.ifrn_name, "lo") == 0)
 	{
-	  OLSR_PRINTF(1, "Skipping loopback...\n")
+          OLSR_PRINTF(1, "Skipping loopback...\n");
 	  continue;
 	}
 
-      OLSR_PRINTF(1, "Trying 0.0.0.0/0 %s...", ifr->ifr_ifrn.ifrn_name)
+      OLSR_PRINTF(1, "Trying 0.0.0.0/0 %s...", ifr->ifr_ifrn.ifrn_name);
       
       
       memset(&kernel_route,0,sizeof(struct rtentry));
@@ -408,29 +390,17 @@
       kernel_route.rt_flags = RTF_UP | RTF_GATEWAY;
 	   
 	   
-      if((kernel_route.rt_dev = malloc(6)) == 0)
-	{
-	  fprintf(stderr, "Out of memory!\n%s\n", strerror(errno));
-	  olsr_exit(__func__, EXIT_FAILURE);
-	}
-	   
-      strncpy(kernel_route.rt_dev, ifr->ifr_ifrn.ifrn_name, 6);
+      kernel_route.rt_dev = ifr->ifr_ifrn.ifrn_name;
 
   
       //printf("Inserting route entry on device %s\n\n", kernel_route.rt_dev);
       
       if((ioctl(s, SIOCDELRT, &kernel_route)) < 0)
-	OLSR_PRINTF(1, "NO\n")
+         OLSR_PRINTF(1, "NO\n");
       else
-	OLSR_PRINTF(1, "YES\n")
-
-
-      free(kernel_route.rt_dev);
-      
-    }
-  
+         OLSR_PRINTF(1, "YES\n");
+    }  
   close(s);
-  
   return 0;
        
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/linux/link_layer.c olsrd-current/src/linux/link_layer.c
--- olsrd-0.5.0/src/linux/link_layer.c	2007-02-10 18:11:49.000000000 +0100
+++ olsrd-current/src/linux/link_layer.c	2007-04-26 00:08:17.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: link_layer.c,v 1.12 2007/02/10 17:11:49 bernd67 Exp $
+ * $Id: link_layer.c,v 1.13 2007/04/25 22:08:17 bernd67 Exp $
  */
 
 
@@ -100,7 +100,7 @@
 {
   struct interface *ifd;
 
-  OLSR_PRINTF(1, "Initializing link-layer notification...\n")
+  OLSR_PRINTF(1, "Initializing link-layer notification...\n");
 
 
   for (ifd = ifnet; ifd ; ifd = ifd->int_next) 
@@ -129,7 +129,7 @@
 
   if(ioctl(olsr_cnf->ioctl_s, SIOCSIWSPY, &wrq) < 0)
     {
-      OLSR_PRINTF(1, "Could not clear spylist %s\n", strerror(errno))
+      OLSR_PRINTF(1, "Could not clear spylist %s\n", strerror(errno));
       return -1;
     }
 
@@ -148,7 +148,7 @@
   char	buffer[(sizeof(struct iw_quality) +
 		sizeof(struct sockaddr)) * IW_MAX_SPY];
   
-  OLSR_PRINTF(1, "Adding spynode!\n\n")
+  OLSR_PRINTF(1, "Adding spynode!\n\n");
   
   /* get all addresses already in the driver */
 
@@ -160,7 +160,7 @@
 
   if(ioctl(olsr_cnf->ioctl_s, SIOCGIWSPY, &wrq) < 0)
     {
-      OLSR_PRINTF(1, "Could not get old spylist %s\n", strerror(errno))
+      OLSR_PRINTF(1, "Could not get old spylist %s\n", strerror(errno));
       return 0;
     }
 
@@ -168,7 +168,7 @@
   nbr = wrq.u.data.length;
   memcpy(hw_address, buffer, nbr * sizeof(struct sockaddr));
 
-  OLSR_PRINTF(1, "Old addresses: %d\n\n", nbr)
+  OLSR_PRINTF(1, "Old addresses: %d\n\n", nbr);
 
   /* Check upper limit */
   if(nbr >= IW_MAX_SPY)
@@ -193,7 +193,7 @@
   
   if(ioctl(olsr_cnf->ioctl_s, SIOCSIWSPY, &wrq) < 0)
     {
-      OLSR_PRINTF(1, "Could not clear spylist %s\n", strerror(errno))
+      OLSR_PRINTF(1, "Could not clear spylist %s\n", strerror(errno));
       return 0;
     }
 
@@ -213,7 +213,7 @@
 
   OLSR_PRINTF(1, "\nARP conversion for %s interface %s\n", 
 	      olsr_ip_to_string(ip),
-	      interface)
+	      interface);
 
   tmp_sockaddr.sin_family = AF_INET;
   tmp_sockaddr.sin_port = 0;
@@ -230,7 +230,7 @@
   if((ioctl(olsr_cnf->ioctl_s, SIOCGARP, &arp_query) < 0) ||
      !(arp_query.arp_flags & ATF_COM)) /* ATF_COM - hw addr valid */
     {
-      OLSR_PRINTF(1, "Arp failed: (%s) - trying lookup\n", strerror(errno))
+      OLSR_PRINTF(1, "Arp failed: (%s) - trying lookup\n", strerror(errno));
 
       /* No address - create a thread that sends a PING */
       send_ping(ip);
@@ -238,7 +238,7 @@
       return -1;
     }
 
-  OLSR_PRINTF(1, "Arp success!\n")
+  OLSR_PRINTF(1, "Arp success!\n");
 
   memcpy(mac, &arp_query.arp_ha, sizeof(struct sockaddr));
 
@@ -270,11 +270,11 @@
   dst_in->sin_family = AF_INET;
   memcpy(&dst_in->sin_addr, ip, olsr_cnf->ipsize);
 
-  OLSR_PRINTF(1, "pinging %s\n\n", olsr_ip_to_string(ip))
+  OLSR_PRINTF(1, "pinging %s\n\n", olsr_ip_to_string(ip));
 
   if ((ping_s = socket(AF_INET, SOCK_RAW, PF_INET)) < 0) 
     {
-      OLSR_PRINTF(1, "Could not create RAW socket for ping!\n%s\n", strerror(errno))
+      OLSR_PRINTF(1, "Could not create RAW socket for ping!\n%s\n", strerror(errno));
       return;
     }
 
@@ -292,12 +292,12 @@
   if((sendto(ping_s, packet, MAXIPLEN + MAXICMPLEN + 8, 0, &dst, sizeof(struct sockaddr))) !=
      MAXIPLEN + MAXICMPLEN + 8)
     {
-      OLSR_PRINTF(1, "Error PING: %s\n", strerror(errno))
+      OLSR_PRINTF(1, "Error PING: %s\n", strerror(errno));
     }
 
   /* Nevermind the pong ;-) */
 
-  OLSR_PRINTF(1, "Ping complete...\n")
+  OLSR_PRINTF(1, "Ping complete...\n");
   close(ping_s);
 
   free(packet);
@@ -319,7 +319,7 @@
   int                   has_range = 0;
   struct interface      *iflist;
 
-  //OLSR_PRINTF(1, "Polling link-layer notification...\n")
+  //OLSR_PRINTF(1, "Polling link-layer notification...\n");
 
   for(iflist = ifnet; iflist != NULL; iflist = iflist->int_next)
     {
@@ -337,7 +337,7 @@
       /* Do the request */
       if(ioctl(olsr_cnf->ioctl_s, SIOCGIWSPY, &wrq) < 0)
 	{
-	  OLSR_PRINTF(1, "%-8.16s  Interface doesn't support wireless statistic collection\n\n", iflist->int_name)
+          OLSR_PRINTF(1, "%-8.16s  Interface doesn't support wireless statistic collection\n\n", iflist->int_name);
 	  return;
 	}
       
@@ -358,29 +358,29 @@
 	    continue;
 	  
 	  /* Print stats for each address */
-	  OLSR_PRINTF(1, "MAC")
+	  OLSR_PRINTF(1, "MAC");
 	  for(j = 0; j < 6; j++)
 	    {
-	      OLSR_PRINTF(1, ":%02x", (hwa[i].sa_data[j] % 0xffffff00))
+                    OLSR_PRINTF(1, ":%02x", (hwa[i].sa_data[j] % 0xffffff00));
 	    }
 	  if(!has_range)
 	    OLSR_PRINTF(1, " : Quality:%d  Signal level:%d dBm  Noise level:%d dBm",
 			qual[i].qual,
 			qual[i].level - 0x100, 
-			qual[i].noise - 0x100)
+			qual[i].noise - 0x100);
 	  else
 	    OLSR_PRINTF(1, " : Quality:%d/%d  Signal level:%d dBm  Noise level:%d dBm",
 			qual[i].qual,
 			range.max_qual.qual,
 			qual[i].level - 0x100, 
-			qual[i].noise - 0x100)
+			qual[i].noise - 0x100);
 	  
-	  OLSR_PRINTF(1, "\n")
+	  OLSR_PRINTF(1, "\n");
 	  
 	}
     }
 
-  //OLSR_PRINTF(1, "\n")
+  //OLSR_PRINTF(1, "\n");
   return;
 }
 
@@ -411,7 +411,7 @@
 
   if(ioctl(olsr_cnf->ioctl_s, SIOCGIWRANGE, &wrq) < 0)
     {
-      OLSR_PRINTF(1, "NO RANGE\n")
+      OLSR_PRINTF(1, "NO RANGE\n");
       return -1;
     }
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/linux/net.c olsrd-current/src/linux/net.c
--- olsrd-0.5.0/src/linux/net.c	2007-02-05 00:36:35.000000000 +0100
+++ olsrd-current/src/linux/net.c	2007-04-26 00:08:18.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: net.c,v 1.32 2007/02/04 23:36:35 bernd67 Exp $
+ * $Id: net.c,v 1.34 2007/04/25 22:08:18 bernd67 Exp $
  */
 
 
@@ -76,9 +76,8 @@
   /*
    *Bind to device using the SO_BINDTODEVICE flag
    */
-  OLSR_PRINTF(3, "Binding socket %d to device %s\n", sock, dev_name)
+  OLSR_PRINTF(3, "Binding socket %d to device %s\n", sock, dev_name);
   return setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, dev_name, strlen(dev_name)+1);
-
 }
 
 
@@ -98,20 +97,9 @@
 enable_ip_forwarding(int version)
 {
   FILE *proc_fwd;
-  char procfile[FILENAME_MAX];
-
-  if(version == AF_INET)
-    {
-      strncpy(procfile, "/proc/sys/net/ipv4/ip_forward", FILENAME_MAX);
-    }
-  else
-    if(version == AF_INET6)
-      {
-	strncpy(procfile, "/proc/sys/net/ipv6/conf/all/forwarding", FILENAME_MAX);
-      }
-    else
-      return -1;
-
+  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)
     {
@@ -126,48 +114,40 @@
       return 0;
     }
   
+  orig_fwd_state = fgetc(proc_fwd);
+  fclose(proc_fwd);
+  if(orig_fwd_state == '1')
+    {
+      OLSR_PRINTF(3, "\nIP forwarding is enabled on this system\n");
+    }
   else
     {
-      orig_fwd_state = fgetc(proc_fwd);
-      fclose(proc_fwd);
-      if(orig_fwd_state == '1')
-	{
-	  OLSR_PRINTF(3, "\nIP forwarding is enabled on this system\n")
-	}
+      if ((proc_fwd=fopen(procfile, "w"))==NULL)
+        {
+          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);
+          return 0;
+        }
       else
-	{
-	  if ((proc_fwd=fopen(procfile, "w"))==NULL)
-	    {
-	      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);
-	      return 0;
-	    }
-	  else
-	    {
-	      syslog(LOG_INFO, "Writing \"1\" to %s\n", procfile);
-	      fputs("1", proc_fwd);
-	    }
-	  fclose(proc_fwd);
-
-	}
+        {
+          syslog(LOG_INFO, "Writing \"1\" to %s\n", procfile);
+          fputs("1", proc_fwd);
+        }
+      fclose(proc_fwd);
     }
-  return 1;
-      
+  return 1;      
 }
 
-
 int
 disable_redirects_global(int version)
 {
   FILE *proc_redirect;
-  char procfile[FILENAME_MAX];
+  const char * const procfile = "/proc/sys/net/ipv4/conf/all/send_redirects";
 
   if(version == AF_INET6)
     return -1;
 
-  strcpy(procfile, "/proc/sys/net/ipv4/conf/all/send_redirects");
-
   if((proc_redirect = fopen(procfile, "r")) == NULL)
     {
       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);
@@ -175,16 +155,11 @@
       sleep(3);
       return -1;
     }
-  else
-    {
-      orig_global_redirect_state = fgetc(proc_redirect);
-      fclose(proc_redirect);
-    }
+  orig_global_redirect_state = fgetc(proc_redirect);
+  fclose(proc_redirect);
 
   if(orig_global_redirect_state == '0')
-    {
       return 0;
-    }
 
   if ((proc_redirect = fopen(procfile, "w"))==NULL)
     {
@@ -193,17 +168,12 @@
       sleep(3);
       return 0;
     }
-  else
-    {
-      syslog(LOG_INFO, "Writing \"0\" to %s", procfile);
-      fputs("0", proc_redirect);
-    }
-  fclose(proc_redirect);
-  
+  syslog(LOG_INFO, "Writing \"0\" to %s", procfile);
+  fputs("0", proc_redirect);
+  fclose(proc_redirect);  
   return 1;
 }
 
-
 /**
  *
  *@return 1 on sucess 0 on failiure
@@ -218,22 +188,17 @@
     return -1;
 
   /* Generate the procfile name */
-  sprintf(procfile, REDIRECT_PROC, if_name);
+  snprintf(procfile, sizeof(procfile), REDIRECT_PROC, if_name);
 
 
   if((proc_redirect = fopen(procfile, "r")) == NULL)
     {
-      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);
-      
+      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);
       return 0;
     }
-  else
-    {
-      iface->nic_state.redirect = fgetc(proc_redirect);
-      fclose(proc_redirect);
-      
-    }
+  iface->nic_state.redirect = fgetc(proc_redirect);
+  fclose(proc_redirect);      
 
   if ((proc_redirect = fopen(procfile, "w"))==NULL)
     {
@@ -242,18 +207,12 @@
       sleep(3);
       return 0;
     }
-  else
-    {
-      syslog(LOG_INFO, "Writing \"0\" to %s", procfile);
-      fputs("0", proc_redirect);
-    }
+  syslog(LOG_INFO, "Writing \"0\" to %s", procfile);
+  fputs("0", proc_redirect);
   fclose(proc_redirect);
-
   return 1;
 }
 
-
-
 /**
  *
  *@return 1 on sucess 0 on failiure
@@ -267,11 +226,9 @@
   if(version == AF_INET6)
     return -1;
 
-
   /* Generate the procfile name */
   sprintf(procfile, SPOOF_PROC, if_name);
 
-
   if((proc_spoof = fopen(procfile, "r")) == NULL)
     {
       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);
@@ -279,12 +236,8 @@
       sleep(3);
       return 0;
     }
-  else
-    {
-      iface->nic_state.spoof = fgetc(proc_spoof);
-      fclose(proc_spoof);
-      
-    }
+  iface->nic_state.spoof = fgetc(proc_spoof);
+  fclose(proc_spoof);
 
   if ((proc_spoof = fopen(procfile, "w")) == NULL)
     {
@@ -293,42 +246,29 @@
       sleep(3);
       return 0;
     }
-  else
-    {
-      syslog(LOG_INFO, "Writing \"0\" to %s", procfile);
-      fputs("0", proc_spoof);
-    }
+  syslog(LOG_INFO, "Writing \"0\" to %s", procfile);
+  fputs("0", proc_spoof);
   fclose(proc_spoof);
-
   return 1;
 }
 
-
-
 /**
  *Resets the spoof filter and ICMP redirect settings
  */
-
 int
 restore_settings(int version)
 {
-  FILE *proc_fd;
-  char procfile[FILENAME_MAX];
   struct interface *ifs;
 
-  OLSR_PRINTF(1, "Restoring network state\n")
+  OLSR_PRINTF(1, "Restoring network state\n");
 
   /* Restore IP forwarding to "off" */
   if(orig_fwd_state == '0')
     {
-      if(version == AF_INET)
-	{
-	  strcpy(procfile, "/proc/sys/net/ipv4/ip_forward");
-	}
-      else if(version == AF_INET6)
-	{
-	  strcpy(procfile, "/proc/sys/net/ipv6/conf/all/forwarding");
-	}
+      const char * const procfile = version == AF_INET
+        ? "/proc/sys/net/ipv4/ip_forward"
+        : "/proc/sys/net/ipv6/conf/all/forwarding";
+      FILE *proc_fd;
 
       if ((proc_fd = fopen(procfile, "w")) == NULL)
 	{
@@ -340,7 +280,6 @@
 	  fputc(orig_fwd_state, proc_fd);
 	  fclose(proc_fd);
 	}
-
     }
 
   /* Restore global ICMP redirect setting */
@@ -348,7 +287,8 @@
     {
       if(version == AF_INET)
 	{
-	  strcpy(procfile, "/proc/sys/net/ipv4/conf/all/send_redirects");
+	  const char * const procfile = "/proc/sys/net/ipv4/conf/all/send_redirects";
+          FILE *proc_fd;
 
 	  if ((proc_fd = fopen(procfile, "w")) == NULL)
 	    {
@@ -363,24 +303,23 @@
 	}
     }
 
-
   if(version == AF_INET6)
     return 0;
 
   for(ifs = ifnet; ifs != NULL; ifs = ifs->int_next)
     {
+      char procfile[FILENAME_MAX];
+      FILE *proc_fd;
       /* Discard host-emulation interfaces */
       if(ifs->is_hcif)
 	continue;
       /* ICMP redirects */
       
       /* Generate the procfile name */
-      sprintf(procfile, REDIRECT_PROC, ifs->int_name);
+      snprintf(procfile, sizeof(procfile), REDIRECT_PROC, ifs->int_name);
       
       if ((proc_fd = fopen(procfile, "w")) == NULL)
-	{
 	  fprintf(stderr, "Could not open %s for writing!\nSettings not restored!\n", procfile);
-	}
       else
 	{
 	  syslog(LOG_INFO, "Resetting %s to %c\n", procfile, ifs->nic_state.redirect);
@@ -388,17 +327,13 @@
 	  fputc(ifs->nic_state.redirect, proc_fd);
 	  fclose(proc_fd);
 	}
-
       
       /* Spoof filter */
       
       /* Generate the procfile name */
       sprintf(procfile, SPOOF_PROC, ifs->int_name);
-
       if ((proc_fd = fopen(procfile, "w")) == NULL)
-	{
 	  fprintf(stderr, "Could not open %s for writing!\nSettings not restored!\n", procfile);
-	}
       else
 	{
 	  syslog(LOG_INFO, "Resetting %s to %c\n", procfile, ifs->nic_state.spoof);
@@ -406,13 +341,10 @@
 	  fputc(ifs->nic_state.spoof, proc_fd);
 	  fclose(proc_fd);
 	}
-
     }
   return 1;
-
 }
 
-
 /**
  *Creates a nonblocking broadcast socket.
  *@param sa sockaddr struct. Used for bind(2).
@@ -424,20 +356,18 @@
   int sock, on = 1;
 
   OLSR_PRINTF(1, "       Connecting to switch daemon port 10150...");
-
-
   if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) 
     {
       perror("hcsocket");
       syslog(LOG_ERR, "hcsocket: %m");
-      return (-1);
+      return -1;
     }
 
   if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) 
     {
       perror("SO_REUSEADDR failed");
       close(sock);
-      return (-1);
+      return -1;
     }
   /* connect to PORT on HOST */
   if (connect(sock,(struct sockaddr *) pin, sizeof(*pin)) < 0) 
@@ -446,13 +376,13 @@
       fprintf(stderr, "Error connecting %d - %s\n", errno, strerror(errno));
       printf("connection refused\n");
       close(sock);
-      return (-1);
+      return -1;
     }
 
   printf("OK\n");
 
   /* Keep TCP socket blocking */  
-  return (sock);
+  return sock;
 }
 
 
@@ -467,24 +397,20 @@
   struct sockaddr_in *sin=(struct sockaddr_in *)sa;
   int sock, on = 1;
 
-
-
   if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) 
     {
       perror("socket");
       syslog(LOG_ERR, "socket: %m");
-      return (-1);
+      return -1;
     }
 
-
-
 #ifdef SO_BROADCAST
   if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0)
     {
       perror("setsockopt");
       syslog(LOG_ERR, "setsockopt SO_BROADCAST: %m");
       close(sock);
-      return (-1);
+      return -1;
     }
 #endif
 
@@ -492,17 +418,13 @@
     {
       perror("SO_REUSEADDR failed");
       close(sock);
-      return (-1);
+      return -1;
     }
 
-
-
 #ifdef SO_RCVBUF
-
   for (on = bufspace; ; on -= 1024) 
     {
-      if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
-		     &on, sizeof (on)) == 0)
+      if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &on, sizeof (on)) == 0)
 	break;
       if (on <= 8*1024) 
 	{
@@ -511,11 +433,8 @@
 	  break;
 	}
     }
-
-
 #endif
 
-
   /*
    * WHEN USING KERNEL 2.6 THIS MUST HAPPEN PRIOR TO THE PORT BINDING!!!!
    */
@@ -529,23 +448,21 @@
       return -1;
     }
 
-
   if (bind(sock, (struct sockaddr *)sin, sizeof (*sin)) < 0) 
     {
       perror("bind");
       syslog(LOG_ERR, "bind: %m");
       close(sock);
-      return (-1);
+      return -1;
     }
-
   /*
-   *One should probably fetch the flags first
+   *FIXME: One should probably fetch the flags first
    *using F_GETFL....
    */
   if (fcntl(sock, F_SETFL, O_NONBLOCK) == -1)
     syslog(LOG_ERR, "fcntl O_NONBLOCK: %m\n");
 
-  return (sock);
+  return sock;
 }
 
 
@@ -558,9 +475,6 @@
 getsocket6(struct sockaddr_in6 *sin, int bufspace, char *int_name)
 {
   int sock, on = 1;
-
-
-
   if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) 
     {
       perror("socket");
@@ -589,14 +503,10 @@
   */
   //#endif
 
-
-
-
 #ifdef SO_RCVBUF
   for (on = bufspace; ; on -= 1024) 
     {
-      if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
-		     &on, sizeof (on)) == 0)
+      if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &on, sizeof (on)) == 0)
 	break;
       if (on <= 8*1024) 
 	{
@@ -605,8 +515,6 @@
 	  break;
 	}
     }
-
-
 #endif
 
   if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) 
@@ -616,7 +524,6 @@
       return (-1);
     }
 
-
   /*
    * WHEN USING KERNEL 2.6 THIS MUST HAPPEN PRIOR TO THE PORT BINDING!!!!
    */
@@ -630,7 +537,6 @@
       return -1;
     }
 
-
   if (bind(sock, (struct sockaddr *)sin, sizeof (*sin)) < 0) 
     {
       perror("bind");
@@ -638,7 +544,6 @@
       close(sock);
       return (-1);
     }
-
   /*
    *One should probably fetch the flags first
    *using F_GETFL....
@@ -646,12 +551,9 @@
   if (fcntl(sock, F_SETFL, O_NONBLOCK) == -1)
     syslog(LOG_ERR, "fcntl O_NONBLOCK: %m\n");
 
-
-
-  return (sock);
+  return sock;
 }
 
-
 int
 join_mcast(struct interface *ifs, int sock)
 {
@@ -663,7 +565,7 @@
   mcastreq.ipv6mr_interface = ifs->if_index;
 
 #if !defined __FreeBSD__ && !defined __MacOSX__ && !defined __NetBSD__
-  OLSR_PRINTF(3, "Interface %s joining multicast %s...",	ifs->int_name, olsr_ip_to_string((union olsr_ip_addr *)&ifs->int6_multaddr.sin6_addr))
+  OLSR_PRINTF(3, "Interface %s joining multicast %s...",	ifs->int_name, olsr_ip_to_string((union olsr_ip_addr *)&ifs->int6_multaddr.sin6_addr));
   /* Send multicast */
   if(setsockopt(sock, 
 		IPPROTO_IPV6, 
@@ -700,9 +602,8 @@
     {
       perror("Join multicast send");
       return -1;
-    }
+    }  
 
-  
   if(setsockopt(sock, 
 		IPPROTO_IPV6, 
 		IPV6_MULTICAST_IF, 
@@ -715,17 +616,14 @@
     }
 
 
-  OLSR_PRINTF(3, "OK\n")
+  OLSR_PRINTF(3, "OK\n");
   return 0;
 }
 
-
-
 /*
  *From net-tools lib/interface.c
  *
  */
-
 int
 get_ipv6_address(char *ifname, struct sockaddr_in6 *saddr6, int scope_in)
 {
@@ -747,13 +645,13 @@
 	      sprintf(addr6, "%s:%s:%s:%s:%s:%s:%s:%s",
 		      addr6p[0], addr6p[1], addr6p[2], addr6p[3],
 		      addr6p[4], addr6p[5], addr6p[6], addr6p[7]);
-	      OLSR_PRINTF(5, "\tinet6 addr: %s\n", addr6)
-	      OLSR_PRINTF(5, "\tScope: %d\n", scope)
+	      OLSR_PRINTF(5, "\tinet6 addr: %s\n", addr6);
+	      OLSR_PRINTF(5, "\tScope: %d\n", scope);
 	      if(scope == scope_in)
 		{
 		  OLSR_PRINTF(4, "Found addr: %s:%s:%s:%s:%s:%s:%s:%s\n",
 			      addr6p[0], addr6p[1], addr6p[2], addr6p[3],
-			      addr6p[4], addr6p[5], addr6p[6], addr6p[7])
+			      addr6p[4], addr6p[5], addr6p[6], addr6p[7]);
 		  inet_pton(AF_INET6,addr6,&tmp_sockaddr6);
 		  memcpy(&saddr6->sin6_addr, &tmp_sockaddr6, sizeof(struct in6_addr));	  
 		  fclose(f);
@@ -762,8 +660,7 @@
 	    }
 	}
       fclose(f);
-    }
-  
+    }  
   return 0;
 }
 
@@ -771,7 +668,6 @@
 /**
  * Wrapper for sendto(2)
  */
-
 ssize_t
 olsr_sendto(int s, 
 	    const void *buf, 
@@ -822,7 +718,7 @@
 }
 
 int
-check_wireless_interface(char *ifname)
+check_wireless_interface(char * ifname)
 {
   struct ifreq ifr;
 
@@ -884,11 +780,11 @@
       /* Get bit rate */
       if(ioctl(olsr_cnf->ioctl_s, SIOCGIWRATE, &ifr) < 0)
 	{
-	  OLSR_PRINTF(1, "Not able to find rate for WLAN interface %s\n", ifname)
+          OLSR_PRINTF(1, "Not able to find rate for WLAN interface %s\n", ifname);
 	  return WEIGHT_WLAN_11MB;
 	}
       
-      OLSR_PRINTF(1, "Bitrate %d\n", ifr.ifr_ifru.ifru_ivalue)
+      OLSR_PRINTF(1, "Bitrate %d\n", ifr.ifr_ifru.ifru_ivalue);
 
       //WEIGHT_WLAN_LOW,          /* <11Mb WLAN     */
       //WEIGHT_WLAN_11MB,         /* 11Mb 802.11b   */
@@ -908,23 +804,23 @@
       if (ioctl(olsr_cnf->ioctl_s, SIOCGMIIPHY, &ifr) < 0) {
 	if (errno != ENODEV)
 	  OLSR_PRINTF(1, "SIOCGMIIPHY on '%s' failed: %s\n",
-		      ifr.ifr_name, strerror(errno))
+		      ifr.ifr_name, strerror(errno));
 	return WEIGHT_ETHERNET_DEFAULT;
       }
 
       mii->reg_num = MII_BMCR;
       if (ioctl(olsr_cnf->ioctl_s, SIOCGMIIREG, &ifr) < 0) {
 	OLSR_PRINTF(1, "SIOCGMIIREG on %s failed: %s\n", ifr.ifr_name,
-		    strerror(errno))
+		    strerror(errno));
 	return WEIGHT_ETHERNET_DEFAULT;
       }
       bmcr = mii->val_out;
 
 
-      OLSR_PRINTF(1, "%s: ", ifr.ifr_name)
+      OLSR_PRINTF(1, "%s: ", ifr.ifr_name);
       OLSR_PRINTF(1, "%s Mbit, %s duplex\n",
 		  (bmcr & MII_BMCR_100MBIT) ? "100" : "10",
-		  (bmcr & MII_BMCR_DUPLEX) ? "full" : "half")
+		  (bmcr & MII_BMCR_DUPLEX) ? "full" : "half");
     
       is_if_link_up(ifname);
 
@@ -958,19 +854,19 @@
       if (ioctl(olsr_cnf->ioctl_s, SIOCGMIIPHY, &ifr) < 0) {
 	if (errno != ENODEV)
 	  OLSR_PRINTF(1, "SIOCGMIIPHY on '%s' failed: %s\n",
-		      ifr.ifr_name, strerror(errno))
+		      ifr.ifr_name, strerror(errno));
 	return WEIGHT_ETHERNET_DEFAULT;
       }
       mii->reg_num = MII_BMSR;
       if (ioctl(olsr_cnf->ioctl_s, SIOCGMIIREG, &ifr) < 0) {
 	OLSR_PRINTF(1, "SIOCGMIIREG on %s failed: %s\n", ifr.ifr_name,
-		    strerror(errno))
+		    strerror(errno));
 	return WEIGHT_ETHERNET_DEFAULT;
       }
       bmsr = mii->val_out;
 
-      OLSR_PRINTF(1, "%s: ", ifr.ifr_name)
-      OLSR_PRINTF(1, "%s\n", (bmsr & MII_BMSR_LINK_VALID) ? "link ok " : "no link ")
+      OLSR_PRINTF(1, "%s: ", ifr.ifr_name);
+      OLSR_PRINTF(1, "%s\n", (bmsr & MII_BMSR_LINK_VALID) ? "link ok " : "no link ");
     
       return (bmsr & MII_BMSR_LINK_VALID);
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/local_hna_set.c olsrd-current/src/local_hna_set.c
--- olsrd-0.5.0/src/local_hna_set.c	2007-02-10 20:27:32.000000000 +0100
+++ olsrd-current/src/local_hna_set.c	2007-04-20 15:46:04.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: local_hna_set.c,v 1.12 2007/02/10 19:27:32 bernd67 Exp $
+ * $Id: local_hna_set.c,v 1.13 2007/04/20 13:46:04 bernd67 Exp $
  */
 
 #include "defs.h"
@@ -106,9 +106,9 @@
 int
 remove_local_hna6_entry(union olsr_ip_addr *net, olsr_u16_t prefix_len)
 {
-  struct hna6_entry *h6 = olsr_cnf->hna6_entries, *h6prev = NULL;
+  struct hna6_entry *h6, *h6prev = NULL;
 
-  while(h6)
+  for(h6 = olsr_cnf->hna6_entries; h6; h6 = h6->next)
     {
       if((memcmp(net, &h6->net, olsr_cnf->ipsize) == 0) && 
 	 (prefix_len == h6->prefix_len))
@@ -123,9 +123,7 @@
 	  return 1;
 	}
       h6prev = h6;
-      h6 = h6->next;
     }
-
   return 0;
 }
 
@@ -171,19 +169,16 @@
 
 
 int
-check_inet_gw()
+check_inet_gw(void)
 {
-  struct hna4_entry *h4 = olsr_cnf->hna4_entries;
-
   if(olsr_cnf->ip_version == AF_INET)
     {
-      while(h4)
+      struct hna4_entry *h4;
+      for(h4 = olsr_cnf->hna4_entries; h4; h4 = h4->next)
 	{
 	  if(h4->netmask.v4 == 0 && h4->net.v4 == 0)
 	    return 1;
-	  h4 = h4->next;
 	}
-      return 0;
     }
   return 0;
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/log.h olsrd-current/src/log.h
--- olsrd-0.5.0/src/log.h	2004-11-21 12:28:56.000000000 +0100
+++ olsrd-current/src/log.h	2007-04-20 15:46:04.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: log.h,v 1.5 2004/11/21 11:28:56 kattemat Exp $
+ * $Id: log.h,v 1.6 2007/04/20 13:46:04 bernd67 Exp $
  */
 
 /* 
@@ -55,7 +55,7 @@
 olsr_openlog(const char *ident);
 
 void
-olsr_syslog(int level, char *format, ...);
+olsr_syslog(int level, char *format, ...) __attribute__((format(printf,2,3)));
 
 
 #endif
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/lq_avl.c olsrd-current/src/lq_avl.c
--- olsrd-0.5.0/src/lq_avl.c	2007-03-29 02:05:50.000000000 +0200
+++ olsrd-current/src/lq_avl.c	2007-04-20 16:23:41.000000000 +0200
@@ -37,7 +37,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: lq_avl.c,v 1.8 2007/03/29 00:05:50 tlopatic Exp $
+ * $Id: lq_avl.c,v 1.9 2007/04/20 14:23:41 bernd67 Exp $
  */
 
 #include <stddef.h>
@@ -427,7 +427,7 @@
   post_delete(tree, parent->parent);
 }
 
-static inline struct avl_node *local_min(struct avl_node *node)
+static struct avl_node *local_min(struct avl_node *node)
 {
   while (node->left != NULL)
     node = node->left;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/lq_route.c olsrd-current/src/lq_route.c
--- olsrd-0.5.0/src/lq_route.c	2007-03-29 02:05:50.000000000 +0200
+++ olsrd-current/src/lq_route.c	2007-04-26 00:08:09.000000000 +0200
@@ -37,7 +37,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: lq_route.c,v 1.45 2007/03/29 00:05:50 tlopatic Exp $
+ * $Id: lq_route.c,v 1.46 2007/04/25 22:08:09 bernd67 Exp $
  */
 
 #include "defs.h"
@@ -594,7 +594,7 @@
               nowtm->tm_hour,
               nowtm->tm_min,
               nowtm->tm_sec,
-              (int)now.tv_usec/10000)
+              (int)now.tv_usec/10000);
 
   for (node = list_get_next(node); node != NULL; node = list_get_next(node))
   {
@@ -609,7 +609,7 @@
          walker = walker->prev)
     {
       OLSR_PRINTF(2, "%s:%s <- ", olsr_ip_to_string(&walker->addr),
-                  etx_to_string(walker->path_etx))
+                  etx_to_string(walker->path_etx));
       hops++;
     }
 
@@ -618,7 +618,7 @@
     if (walker != NULL)
     {
       OLSR_PRINTF(2, "%s:%s (one-hop)\n", olsr_ip_to_string(&walker->addr),
-                  etx_to_string(walker->path_etx))
+                  etx_to_string(walker->path_etx));
 
       // node reachable => add to the set of unprocessed nodes
       // for HNA processing
@@ -628,7 +628,7 @@
 
     else
     {
-      OLSR_PRINTF(2, "%s FAILED\n", olsr_ip_to_string(&vert->addr))
+      OLSR_PRINTF(2, "%s FAILED\n", olsr_ip_to_string(&vert->addr));
       continue;
     }
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/main.c olsrd-current/src/main.c
--- olsrd-0.5.0/src/main.c	2007-02-24 12:54:24.000000000 +0100
+++ olsrd-current/src/main.c	2007-05-09 01:10:37.000000000 +0200
@@ -37,7 +37,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: main.c,v 1.92 2007/02/24 11:54:24 kattemat Exp $
+ * $Id: main.c,v 1.96 2007/05/08 23:10:37 bernd67 Exp $
  */
 
 #include <unistd.h>
@@ -62,21 +62,21 @@
 
 #ifdef WIN32
 #define close(x) closesocket(x)
-int __stdcall SignalHandler(unsigned long signal);
+int __stdcall SignalHandler(unsigned long signal) __attribute__((noreturn));
 void ListInterfaces(void);
 void DisableIcmpRedirects(void);
 olsr_bool olsr_win32_end_request = OLSR_FALSE;
 olsr_bool olsr_win32_end_flag = OLSR_FALSE;
 #else
 static void
-olsr_shutdown(int);
+olsr_shutdown(int) __attribute__((noreturn));
 #endif
 
 /*
  * Local function prototypes
  */
 void
-olsr_reconfigure(int);
+olsr_reconfigure(int) __attribute__((noreturn));
 
 static void
 print_usage(void);
@@ -105,17 +105,17 @@
   char conf_file_name[FILENAME_MAX];
   struct tms tms_buf;
 
+#ifdef WIN32
+  WSADATA WsaData;
+  int len;
+#endif
+
   /* Stop the compiler from complaining */
   (void)copyright_string;
 
   debug_handle = stdout;
   olsr_argv = argv;
 
-#ifdef WIN32
-  WSADATA WsaData;
-  int len;
-#endif
-
   setbuf(stdout, NULL);
   setbuf(stderr, NULL);
 
@@ -301,7 +301,7 @@
     {
       if(apm_init() < 0)
 	{
-	  OLSR_PRINTF(1, "Could not read APM info - setting default willingness(%d)\n", WILL_DEFAULT)
+	  OLSR_PRINTF(1, "Could not read APM info - setting default willingness(%d)\n", WILL_DEFAULT);
 
 	  olsr_syslog(OLSR_LOG_ERR, "Could not read APM info - setting default willingness(%d)\n", WILL_DEFAULT);
 
@@ -312,19 +312,19 @@
 	{
 	  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)
+	  OLSR_PRINTF(1, "Willingness set to %d - next update in %.1f secs\n", olsr_cnf->willingness, olsr_cnf->will_int);
 	}
     }
 
   /* Set ipsize */
   if(olsr_cnf->ip_version == AF_INET6)
     {
-      OLSR_PRINTF(1, "Using IP version 6\n")
+      OLSR_PRINTF(1, "Using IP version 6\n");
       olsr_cnf->ipsize = sizeof(struct in6_addr);
     }
   else
     {
-      OLSR_PRINTF(1, "Using IP version 4\n")
+      OLSR_PRINTF(1, "Using IP version 4\n");
       olsr_cnf->ipsize = sizeof(olsr_u32_t);
     }
 
@@ -380,7 +380,7 @@
   /* Load plugins */
   olsr_load_plugins();
 
-  OLSR_PRINTF(1, "Main address: %s\n\n", olsr_ip_to_string(&olsr_cnf->main_addr))
+  OLSR_PRINTF(1, "Main address: %s\n\n", olsr_ip_to_string(&olsr_cnf->main_addr));
 
   /* Start syslog entry */
   olsr_syslog(OLSR_LOG_INFO, "%s successfully started", SOFTWARE_VERSION);
@@ -407,9 +407,11 @@
   /* Starting scheduler */
   scheduler();
 
+  /* Stop the compiler from complaining */
+  (void)copyright_string;
+
   /* Like we're ever going to reach this ;-) */
   return 1;
-
 } /* main */
 
 
@@ -421,7 +423,7 @@
  */
 #ifndef WIN32
 void
-olsr_reconfigure(int signal)
+olsr_reconfigure(int signal __attribute__((unused)))
 {
   if(!fork())
     {
@@ -467,7 +469,7 @@
 
   olsr_delete_all_kernel_routes();
 
-  OLSR_PRINTF(1, "Closing sockets...\n")
+  OLSR_PRINTF(1, "Closing sockets...\n");
 
   /* front-end IPC socket */
   if(olsr_cnf->open_ipc)
@@ -493,7 +495,7 @@
 
   olsr_syslog(OLSR_LOG_INFO, "%s stopped", SOFTWARE_VERSION);
 
-  OLSR_PRINTF(1, "\n <<<< %s - terminating >>>>\n           http://www.olsr.org\n", SOFTWARE_VERSION)
+  OLSR_PRINTF(1, "\n <<<< %s - terminating >>>>\n           http://www.olsr.org\n", SOFTWARE_VERSION);
 
   exit(olsr_cnf->exit_value);
 }
@@ -502,18 +504,19 @@
  * Print the command line usage
  */
 static void
-print_usage()
+print_usage(void)
 {
 
-  fprintf(stderr, "An error occured somewhere between your keyboard and your chair!\n"); 
-  fprintf(stderr, "usage: olsrd [-f <configfile>] [ -i interface1 interface2 ... ]\n");
-  fprintf(stderr, "  [-d <debug_level>] [-ipv6] [-multi <IPv6 multicast address>]\n"); 
-  fprintf(stderr, "  [-lql <LQ level>] [-lqw <LQ winsize>]\n"); 
-  fprintf(stderr, "  [-bcast <broadcastaddr>] [-ipc] [-dispin] [-dispout] [-delgw]\n");
-  fprintf(stderr, "  [-hint <hello interval (secs)>] [-tcint <tc interval (secs)>]\n");
-  fprintf(stderr, "  [-midint <mid interval (secs)>] [-hnaint <hna interval (secs)>]\n");
-  fprintf(stderr, "  [-T <Polling Rate (secs)>] [-nofork] [-hemu <ip_address>] \n"); 
-  fprintf(stderr, "  [-lql <LQ level>] [-lqw <LQ winsize>]\n");
+  fprintf(stderr,
+          "An error occured somwhere between your keyboard and your chair!\n"
+          "usage: olsrd [-f <configfile>] [ -i interface1 interface2 ... ]\n"
+          "  [-d <debug_level>] [-ipv6] [-multi <IPv6 multicast address>]\n"
+          "  [-lql <LQ level>] [-lqw <LQ winsize>]\n"
+          "  [-bcast <broadcastaddr>] [-ipc] [-dispin] [-dispout] [-delgw]\n"
+          "  [-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>] [-lqw <LQ winsize>]\n");
 }
 
 
@@ -789,7 +792,7 @@
 	  struct in6_addr in6;
 	  NEXT_ARG;
           CHECK_ARGC;
-	  if(inet_pton(AF_INET6, *argv, &in6) < 0)
+	  if(inet_pton(AF_INET6, *argv, &in6) <= 0)
 	    {
 	      fprintf(stderr, "Failed converting IP address %s\n", *argv);
 	      exit(EXIT_FAILURE);
@@ -810,7 +813,7 @@
       
 	  NEXT_ARG;
           CHECK_ARGC;
-	  if(inet_pton(AF_INET, *argv, &in) < 0)
+	  if(inet_pton(AF_INET, *argv, &in) <= 0)
 	    {
 	      fprintf(stderr, "Failed converting IP address %s\n", *argv);
 	      exit(EXIT_FAILURE);
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/mid_set.c olsrd-current/src/mid_set.c
--- olsrd-0.5.0/src/mid_set.c	2007-02-10 20:27:32.000000000 +0100
+++ olsrd-current/src/mid_set.c	2007-04-26 00:08:09.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: mid_set.c,v 1.17 2007/02/10 19:27:32 bernd67 Exp $
+ * $Id: mid_set.c,v 1.20 2007/04/25 22:08:09 bernd67 Exp $
  */
 
 #include "defs.h"
@@ -60,11 +60,11 @@
  */
 
 int
-olsr_init_mid_set()
+olsr_init_mid_set(void)
 {
   int index;
 
-  OLSR_PRINTF(5, "MID: init\n")
+  OLSR_PRINTF(5, "MID: init\n");
 
   /* Since the holdingtime is assumed to be rather large for 
    * MID entries, the timeoutfunction is only ran once every second
@@ -167,8 +167,8 @@
       /* Delete possible 2 hop neighbor */
       if((tmp_2_neighbor = olsr_lookup_two_hop_neighbor_table_mid(&tmp_adr->alias)) != NULL)
 	{
-	  OLSR_PRINTF(1, "Deleting 2 hop node from MID: %s to ", olsr_ip_to_string(&tmp_adr->alias))
-	  OLSR_PRINTF(1, "%s\n", olsr_ip_to_string(m_addr))
+	  OLSR_PRINTF(1, "Deleting 2 hop node from MID: %s to ", olsr_ip_to_string(&tmp_adr->alias));
+	  OLSR_PRINTF(1, "%s\n", olsr_ip_to_string(m_addr));
 
 	  olsr_delete_two_hop_neighbor_table(tmp_2_neighbor);
 
@@ -180,8 +180,8 @@
 	 && ((real_neigh = olsr_lookup_neighbor_table_alias(m_addr)) != NULL))
 
 	{
-	  OLSR_PRINTF(1, "[MID]Deleting bogus neighbor entry %s real ", olsr_ip_to_string(&tmp_adr->alias))
-	  OLSR_PRINTF(1, "%s\n", olsr_ip_to_string(m_addr))
+	  OLSR_PRINTF(1, "[MID]Deleting bogus neighbor entry %s real ", olsr_ip_to_string(&tmp_adr->alias));
+	  OLSR_PRINTF(1, "%s\n", olsr_ip_to_string(m_addr));
 
 	  replace_neighbor_link_set(tmp_neigh, real_neigh);
 
@@ -221,8 +221,8 @@
 
   adr = olsr_malloc(sizeof(struct mid_address), "Insert MID alias");
   
-  OLSR_PRINTF(1, "Inserting alias %s for ", olsr_ip_to_string(alias))
-  OLSR_PRINTF(1, "%s\n", olsr_ip_to_string(main_add))
+  OLSR_PRINTF(1, "Inserting alias %s for ", olsr_ip_to_string(alias));
+  OLSR_PRINTF(1, "%s\n", olsr_ip_to_string(main_add));
 
   COPY_IP(&adr->alias, alias);
   adr->next_alias = NULL;
@@ -302,7 +302,7 @@
   struct mid_entry *tmp_list;
   olsr_u32_t hash;
 
-  //OLSR_PRINTF(1, "MID: lookup entry...")
+  //OLSR_PRINTF(1, "MID: lookup entry...");
 
   hash = olsr_hashing(adr);
 
@@ -327,7 +327,7 @@
  *
  *@return a linked list of addresses structs
  */
-inline struct mid_address *
+struct mid_address *
 mid_lookup_aliases(union olsr_ip_addr *adr)
 {
   struct mid_entry *tmp = mid_lookup_entry_bymain(adr);
@@ -348,7 +348,7 @@
   struct mid_entry *tmp_list = mid_set;
   olsr_u32_t hash;
 
-  OLSR_PRINTF(3, "MID: update %s\n", olsr_ip_to_string(adr))
+  OLSR_PRINTF(3, "MID: update %s\n", olsr_ip_to_string(adr));
   hash = olsr_hashing(adr);
 
   /* Check all registered nodes...*/
@@ -422,8 +422,8 @@
       if (declared_aliases == 0)
         {
           /* Current alias not found in list of declared aliases: free current alias */
-          OLSR_PRINTF(1, "MID remove: (%s, ", olsr_ip_to_string(&entry->main_addr))
-          OLSR_PRINTF(1, "%s)\n", olsr_ip_to_string(&current_alias->alias))
+          OLSR_PRINTF(1, "MID remove: (%s, ", olsr_ip_to_string(&entry->main_addr));
+            OLSR_PRINTF(1, "%s)\n", olsr_ip_to_string(&current_alias->alias));
 
           /* Update linked list as seen by 'entry' */
           if (previous_alias != NULL)
@@ -461,7 +461,7 @@
  *@return nada
  */
 void
-olsr_time_out_mid_set(void *foo)
+olsr_time_out_mid_set(void *foo __attribute__((unused)))
 {
   int index;
 
@@ -478,8 +478,8 @@
 	      struct mid_entry *entry_to_delete = tmp_list;
 	      tmp_list = tmp_list->next;
 #ifdef DEBUG
-	      OLSR_PRINTF(1, "MID info for %s timed out.. deleting it\n", 
-			  olsr_ip_to_string(&entry_to_delete->main_addr))
+	      OLSR_PRINTF(1, "MID info for %s timed out.. deleting it\n",
+			  olsr_ip_to_string(&entry_to_delete->main_addr));
 #endif
 	      /*Delete it*/
 	      mid_delete_node(entry_to_delete);
@@ -527,30 +527,26 @@
  *For debuging purposes
  */
 void
-olsr_print_mid_set()
+olsr_print_mid_set(void)
 {
-
   int index;
 
-  OLSR_PRINTF(1, "mid set: %02d:%02d:%02d.%06lu\n",nowtm->tm_hour, nowtm->tm_min, nowtm->tm_sec, now.tv_usec)
+  OLSR_PRINTF(1, "mid set: %02d:%02d:%02d.%06lu\n",nowtm->tm_hour, nowtm->tm_min, nowtm->tm_sec, now.tv_usec);
 
   for(index=0;index<HASHSIZE;index++)
     {
       struct mid_entry *tmp_list = mid_set[index].next;
       /*Traverse MID list*/
-      for(tmp_list = mid_set[index].next;
-	  tmp_list != &mid_set[index];
-	  tmp_list = tmp_list->next)
+      for(tmp_list = mid_set[index].next; tmp_list != &mid_set[index]; tmp_list = tmp_list->next)
 	{
-	  struct mid_address *tmp_addr = tmp_list->aliases;
-
-	  OLSR_PRINTF(1, "%s: ", olsr_ip_to_string(&tmp_list->main_addr))
-	  while(tmp_addr)
+	  struct mid_address *tmp_addr;
+          
+	  OLSR_PRINTF(1, "%s: ", olsr_ip_to_string(&tmp_list->main_addr));
+          for(tmp_addr = tmp_list->aliases;tmp_addr;tmp_addr = tmp_addr->next_alias)
 	    {
-	      OLSR_PRINTF(1, " %s ", olsr_ip_to_string(&tmp_addr->alias))
-	      tmp_addr = tmp_addr->next_alias;
+	      OLSR_PRINTF(1, " %s ", olsr_ip_to_string(&tmp_addr->alias));
 	    }
-	  OLSR_PRINTF(1, "\n")	  
+	  OLSR_PRINTF(1, "\n");
 	}
     }
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/mpr.c olsrd-current/src/mpr.c
--- olsrd-0.5.0/src/mpr.c	2006-01-07 09:16:20.000000000 +0100
+++ olsrd-current/src/mpr.c	2007-04-26 00:08:09.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: mpr.c,v 1.15 2006/01/07 08:16:20 kattemat Exp $
+ * $Id: mpr.c,v 1.17 2007/04/25 22:08:09 bernd67 Exp $
  */
 
 #include "defs.h"
@@ -121,7 +121,7 @@
 	  if((dup_neighbor != NULL) && (dup_neighbor->status != NOT_SYM))
 	    {
 	      
-	      //OLSR_PRINTF(1, "(1)Skipping 2h neighbor %s - already 1hop\n", olsr_ip_to_string(&two_hop_neighbor->neighbor_2_addr))
+	      //OLSR_PRINTF(1, "(1)Skipping 2h neighbor %s - already 1hop\n", olsr_ip_to_string(&two_hop_neighbor->neighbor_2_addr));
 
 	      continue;
 	    }
@@ -133,7 +133,7 @@
 		{
 		  two_hop_list_tmp = olsr_malloc(sizeof(struct neighbor_2_list_entry), "MPR two hop list");
 
-		  //OLSR_PRINTF(1, "ONE LINK ADDING %s\n", olsr_ip_to_string(&two_hop_neighbor->neighbor_2_addr))
+		  //OLSR_PRINTF(1, "ONE LINK ADDING %s\n", olsr_ip_to_string(&two_hop_neighbor->neighbor_2_addr));
 
 		  /* Only queue one way here */		  
 		  two_hop_list_tmp->neighbor_2 = two_hop_neighbor;
@@ -170,7 +170,7 @@
   
   count = *two_hop_covered_count;
 
-  OLSR_PRINTF(1, "Setting %s as MPR\n", olsr_ip_to_string(&one_hop_neighbor->neighbor_main_addr))
+  OLSR_PRINTF(1, "Setting %s as MPR\n", olsr_ip_to_string(&one_hop_neighbor->neighbor_main_addr));
 
   //printf("PRE COUNT: %d\n\n", count);
 
@@ -184,7 +184,7 @@
 
       if((dup_neighbor != NULL) && (dup_neighbor->status == SYM))
 	{
-	  //OLSR_PRINTF(7, "(2)Skipping 2h neighbor %s - already 1hop\n", olsr_ip_to_string(&second_hop_entries->neighbor_2->neighbor_2_addr))
+	  //OLSR_PRINTF(7, "(2)Skipping 2h neighbor %s - already 1hop\n", olsr_ip_to_string(&second_hop_entries->neighbor_2->neighbor_2_addr));
 	  continue;
 	}
 
@@ -197,7 +197,7 @@
 	  second_hop_entries->neighbor_2->mpr_covered_count++;
 	  the_one_hop_list = second_hop_entries->neighbor_2->neighbor_2_nblist.next;
 
-	  //OLSR_PRINTF(1, "[%s](%x) has coverage %d\n", olsr_ip_to_string(&second_hop_entries->neighbor_2->neighbor_2_addr), second_hop_entries->neighbor_2, second_hop_entries->neighbor_2->mpr_covered_count)
+	  //OLSR_PRINTF(1, "[%s](%x) has coverage %d\n", olsr_ip_to_string(&second_hop_entries->neighbor_2->neighbor_2_addr), second_hop_entries->neighbor_2, second_hop_entries->neighbor_2->mpr_covered_count);
 
 	  if(second_hop_entries->neighbor_2->mpr_covered_count >= olsr_cnf->mpr_coverage)
 	     count++;
@@ -276,18 +276,18 @@
  *Remove all MPR registrations
  */
 static void
-olsr_clear_mprs()
+olsr_clear_mprs(void)
 {
   olsr_u32_t index;
-  struct neighbor_entry   *a_neighbor;
-  struct neighbor_2_list_entry *two_hop_list;
   
   for (index=0;index<HASHSIZE;index++)
     {
+      struct neighbor_entry   *a_neighbor;
       for(a_neighbor = neighbortable[index].next;
 	  a_neighbor != &neighbortable[index];
 	  a_neighbor = a_neighbor->next)
 	{
+          struct neighbor_2_list_entry *two_hop_list;
 	  /* Clear MPR selection */
 	  if(a_neighbor->is_mpr)
 	    {
@@ -304,7 +304,6 @@
 	    }
 	}
     }
-
 }
 
 
@@ -314,16 +313,16 @@
  *@return 1 if changes occured 0 if not
  */
 static int
-olsr_check_mpr_changes()
+olsr_check_mpr_changes(void)
 {
   olsr_u32_t index;
-  struct neighbor_entry       *a_neighbor;
   int retval;
 
   retval = 0;
   
   for (index=0;index<HASHSIZE;index++)
     {
+      struct neighbor_entry *a_neighbor;
       for(a_neighbor = neighbortable[index].next;
 	  a_neighbor != &neighbortable[index];
 	  a_neighbor = a_neighbor->next)
@@ -346,13 +345,13 @@
  *on two hop neighbors
  */
 static void
-olsr_clear_two_hop_processed()
+olsr_clear_two_hop_processed(void)
 {
-  struct neighbor_2_entry  *neighbor_2;
   int index;
   
   for(index=0;index<HASHSIZE;index++)
     {
+      struct neighbor_2_entry  *neighbor_2;
       for(neighbor_2 = two_hop_neighbortable[index].next;
 	  neighbor_2 != &two_hop_neighbortable[index];
 	  neighbor_2 = neighbor_2->next)
@@ -369,32 +368,23 @@
  *This function calculates the number of two hop neighbors
  */
 static olsr_u16_t
-olsr_calculate_two_hop_neighbors()
+olsr_calculate_two_hop_neighbors(void)
 {
   olsr_u8_t                    index;
-  struct neighbor_entry        *a_neighbor, *dup_neighbor;
-  olsr_u16_t                   count, n_count, sum;
-  struct neighbor_2_list_entry *twohop_neighbors;
-  
-  //dup_neighbor = NULL;
-  
-  n_count = 0;
-  count = 0;
-  sum = 0;
-
+  olsr_u16_t                   sum = 0;
+  
   /* Clear 2 hop neighs */
   olsr_clear_two_hop_processed();
 
   for(index=0;index<HASHSIZE;index++)
     {
-      for(a_neighbor = neighbortable[index].next;
-	  a_neighbor != &neighbortable[index];
-	  a_neighbor = a_neighbor->next)
+      struct neighbor_entry *a_neighbor;
+      for(a_neighbor = neighbortable[index].next; a_neighbor != &neighbortable[index]; a_neighbor = a_neighbor->next)
 	{ 
-	  count = 0;
-	  n_count = 0;
-	  
-	  if(a_neighbor->status == NOT_SYM)
+          struct neighbor_2_list_entry *twohop_neighbors;
+          olsr_u16_t                   count = 0;
+          olsr_u16_t                   n_count = 0;
+          if(a_neighbor->status == NOT_SYM)
 	    {	    
 	      a_neighbor->neighbor_2_nocov = count;
 	      continue;
@@ -405,8 +395,7 @@
 	      twohop_neighbors = twohop_neighbors->next)
 	    {
 	      //printf("\tChecking %s....", olsr_ip_to_string(&twohop_neighbors->neighbor_2->neighbor_2_addr));
-	      
-	      dup_neighbor = olsr_lookup_neighbor_table(&twohop_neighbors->neighbor_2->neighbor_2_addr);
+              struct neighbor_entry *dup_neighbor = olsr_lookup_neighbor_table(&twohop_neighbors->neighbor_2->neighbor_2_addr);
 	      
 	      if((dup_neighbor == NULL) || (dup_neighbor->status != SYM))
 		{
@@ -425,7 +414,7 @@
 	}
     }
   
-  OLSR_PRINTF(3, "Two hop neighbors: %d\n", sum)
+  OLSR_PRINTF(3, "Two hop neighbors: %d\n", sum);
   return sum;
 }
 
@@ -436,19 +425,16 @@
  * Adds all nodes with willingness set to WILL_ALWAYS
  */
 static olsr_u16_t
-add_will_always_nodes()
+add_will_always_nodes(void)
 {
-
+  olsr_u16_t                   count = 0;
   olsr_u8_t                    index;
-  struct neighbor_entry        *a_neighbor;
-  olsr_u16_t                   count;
-
-  count = 0;
 
   //printf("\nAdding WILL ALWAYS nodes....\n");
 
   for(index=0;index<HASHSIZE;index++)
     {
+      struct neighbor_entry        *a_neighbor;
       for(a_neighbor = neighbortable[index].next;
 	  a_neighbor != &neighbortable[index];
 	  a_neighbor = a_neighbor->next)
@@ -458,12 +444,12 @@
 
 	  olsr_chosen_mpr(a_neighbor, &count); 
 
-	  OLSR_PRINTF(3, "Adding WILL_ALWAYS: %s\n", olsr_ip_to_string(&a_neighbor->neighbor_main_addr))
+	  OLSR_PRINTF(3, "Adding WILL_ALWAYS: %s\n", olsr_ip_to_string(&a_neighbor->neighbor_main_addr));
 
 	}
     }
   
-  //OLSR_PRINTF(1, "Count: %d\n", count)
+  //OLSR_PRINTF(1, "Count: %d\n", count);
   return count;
 }
 
@@ -472,22 +458,16 @@
  *@return nada
  */
 void
-olsr_calculate_mpr()     
-{
-  
-  olsr_u16_t                   two_hop_covered_count=0;
-  olsr_u16_t                   two_hop_count=0;  
-  struct neighbor_2_list_entry *two_hop_list=NULL;
-  struct neighbor_2_list_entry *tmp;
-  struct neighbor_entry        *mprs; 
+olsr_calculate_mpr(void)     
+{  
+  olsr_u16_t                   two_hop_covered_count;
+  olsr_u16_t                   two_hop_count;
   int i;
 
-  OLSR_PRINTF(3, "\n**RECALCULATING MPR**\n\n")
+  OLSR_PRINTF(3, "\n**RECALCULATING MPR**\n\n");
 
   olsr_clear_mprs();
-
   two_hop_count = olsr_calculate_two_hop_neighbors();
-
   two_hop_covered_count += add_will_always_nodes();
 
   /*
@@ -496,10 +476,12 @@
 
   for(i = WILL_ALWAYS - 1; i > WILL_NEVER; i--)
     {
-      two_hop_list = olsr_find_2_hop_neighbors_with_1_link(i);
+      struct neighbor_entry        *mprs; 
+      struct neighbor_2_list_entry *two_hop_list = olsr_find_2_hop_neighbors_with_1_link(i);
 
       while(two_hop_list != NULL)
 	{
+          struct neighbor_2_list_entry *tmp;
 	  //printf("CHOSEN FROM 1 LINK\n");
 	  if(!two_hop_list->neighbor_2->neighbor_2_nblist.next->neighbor->is_mpr)
 	    olsr_chosen_mpr(two_hop_list->neighbor_2->neighbor_2_nblist.next->neighbor, &two_hop_covered_count); 
@@ -540,7 +522,7 @@
 
   if(olsr_check_mpr_changes())
     {
-      OLSR_PRINTF(3, "CHANGES IN MPR SET\n")
+      OLSR_PRINTF(3, "CHANGES IN MPR SET\n");
       if(olsr_cnf->tc_redundancy > 0)
 	signal_link_changes(OLSR_TRUE);
     }
@@ -557,20 +539,18 @@
  *@return nada
  */
 static void
-olsr_optimize_mpr_set()
+olsr_optimize_mpr_set(void)
 {
-  int i, remove, index;
-  struct neighbor_2_list_entry *two_hop_list;
-  struct neighbor_entry *a_neighbor, *dup_neighbor;
+  int i, remove;
 
   //printf("\n**MPR OPTIMIZING**\n\n");
 
   for(i = WILL_NEVER + 1; i < WILL_ALWAYS; i++)
     {
-
+      int index;
       for(index=0;index<HASHSIZE;index++)
 	{
-
+          struct neighbor_entry *a_neighbor;
 	  for(a_neighbor = neighbortable[index].next;
 	      a_neighbor != &neighbortable[index];
 	      a_neighbor = a_neighbor->next)
@@ -581,6 +561,7 @@
 	      
 	      if(a_neighbor->is_mpr)
 		{
+                  struct neighbor_2_list_entry *two_hop_list;
 		  //printf("\tChecking %s\n", olsr_ip_to_string(&a_neighbor->neighbor_main_addr));
 		  remove = 1;
 
@@ -589,7 +570,7 @@
 		      two_hop_list = two_hop_list->next)
 		    {
 		      
-		      dup_neighbor = olsr_lookup_neighbor_table(&two_hop_list->neighbor_2->neighbor_2_addr);
+                      const struct neighbor_entry * const dup_neighbor = olsr_lookup_neighbor_table(&two_hop_list->neighbor_2->neighbor_2_addr);
 		      
 		      if((dup_neighbor != NULL) && (dup_neighbor->status != NOT_SYM))
 			continue;
@@ -602,46 +583,37 @@
 		    }
 		  if(remove)
 		    {
-		      OLSR_PRINTF(3, "MPR OPTIMIZE: removiong mpr %s\n\n", olsr_ip_to_string(&a_neighbor->neighbor_main_addr))
+		      OLSR_PRINTF(3, "MPR OPTIMIZE: removiong mpr %s\n\n", olsr_ip_to_string(&a_neighbor->neighbor_main_addr));
 		      a_neighbor->is_mpr = OLSR_FALSE;
 		    }
-
-
 		}
 	    }
-	  
 	}
-
-
     }
-
 }
 
 
 
 void
-olsr_print_mpr_set()
+olsr_print_mpr_set(void)
 {
-  int                   index;
-  struct neighbor_entry *a_neighbor;
+  int index;
 
-  OLSR_PRINTF(1, "MPR SET: ")
+  OLSR_PRINTF(1, "MPR SET: ");
 
   for(index=0;index<HASHSIZE;index++)
     {
+      struct neighbor_entry *a_neighbor;
       for(a_neighbor = neighbortable[index].next;
 	  a_neighbor != &neighbortable[index];
 	  a_neighbor = a_neighbor->next)
 	{ 
-	  
 	  /* 
 	   * Remove MPR settings
 	   */
 	  if(a_neighbor->is_mpr)
-	    OLSR_PRINTF(1, "[%s] ", olsr_ip_to_string(&a_neighbor->neighbor_main_addr))
+	    OLSR_PRINTF(1, "[%s] ", olsr_ip_to_string(&a_neighbor->neighbor_main_addr));
 	}
     }
-
-  OLSR_PRINTF(1, "\n")
-
+  OLSR_PRINTF(1, "\n");
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/mpr_selector_set.c olsrd-current/src/mpr_selector_set.c
--- olsrd-0.5.0/src/mpr_selector_set.c	2006-01-07 09:16:20.000000000 +0100
+++ olsrd-current/src/mpr_selector_set.c	2007-04-26 00:08:09.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: mpr_selector_set.c,v 1.15 2006/01/07 08:16:20 kattemat Exp $
+ * $Id: mpr_selector_set.c,v 1.17 2007/04/25 22:08:09 bernd67 Exp $
  */
 
 
@@ -55,9 +55,9 @@
  */
 
 int
-olsr_init_mprs_set()
+olsr_init_mprs_set(void)
 {
-  OLSR_PRINTF(5, "MPRS: Init\n")
+  OLSR_PRINTF(5, "MPRS: Init\n");
   /* Initial values */
   ansn = 0;
 
@@ -65,20 +65,19 @@
   
   mprs_list.next = &mprs_list;
   mprs_list.prev = &mprs_list;
-  
 
   return 1;
 }
 
 
 olsr_u16_t 
-get_local_ansn()
+get_local_ansn(void)
 {
   return ansn;
 }
 
 void
-increase_local_ansn()
+increase_local_ansn(void)
 {
   ansn++;
 }
@@ -88,7 +87,7 @@
  * neighbors. If the list is empty we are not MPR.
  */
 olsr_bool
-olsr_is_mpr()
+olsr_is_mpr(void)
 {
     return ((mprs_list.next == &mprs_list) ? OLSR_FALSE : OLSR_TRUE);
 }
@@ -106,7 +105,7 @@
 {
   struct mpr_selector *new_entry;
 
-  OLSR_PRINTF(1, "MPRS: adding %s\n", olsr_ip_to_string(addr))
+  OLSR_PRINTF(1, "MPRS: adding %s\n", olsr_ip_to_string(addr));
 
   new_entry = olsr_malloc(sizeof(struct mpr_selector), "Add MPR selector");
 
@@ -143,7 +142,7 @@
 
   if(addr == NULL)
     return NULL;
-  //OLSR_PRINTF(1, "MPRS: Lookup....")
+  //OLSR_PRINTF(1, "MPRS: Lookup....");
 
   mprs = mprs_list.next;
 
@@ -152,13 +151,13 @@
 
       if(COMP_IP(&mprs->MS_main_addr, addr))
 	{
-	  //OLSR_PRINTF(1, "MATCH\n")
+	  //OLSR_PRINTF(1, "MATCH\n");
 	  return mprs;
 	}
       mprs = mprs->next;
     }
   
-  //OLSR_PRINTF(1, "NO MACH\n")
+  //OLSR_PRINTF(1, "NO MACH\n");
   return NULL;
 }
 
@@ -178,7 +177,7 @@
   struct mpr_selector *mprs;
   int retval;
 
-  OLSR_PRINTF(5, "MPRS: Update %s\n", olsr_ip_to_string(addr))
+  OLSR_PRINTF(5, "MPRS: Update %s\n", olsr_ip_to_string(addr));
 
   retval = 0;
 
@@ -195,32 +194,25 @@
   return retval;
 }
 
-
-
-
-
 /**
  *Time out MPR selector entries
  *
  *@return nada
  */
 void
-olsr_time_out_mprs_set()
+olsr_time_out_mprs_set(void)
 {
-  struct mpr_selector *mprs;
-
-  mprs = mprs_list.next;
+  struct mpr_selector *mprs = mprs_list.next;
 
   while(mprs != &mprs_list)
     {
-
       if(TIMED_OUT(mprs->MS_time))
 	{
 	  /* Dequeue */
 	  struct mpr_selector *mprs_to_delete = mprs;
 	  mprs = mprs->next;
 
-	  OLSR_PRINTF(1, "MPRS: Timing out %s\n", olsr_ip_to_string(&mprs_to_delete->MS_main_addr))
+	  OLSR_PRINTF(1, "MPRS: Timing out %s\n", olsr_ip_to_string(&mprs_to_delete->MS_main_addr));
 
 	  DEQUEUE_ELEM(mprs_to_delete);
 
@@ -231,27 +223,20 @@
       else
 	mprs = mprs->next;
     }
-
 }
 
-
-
 /**
  *Print the current MPR selector set to STDOUT
  */
 void
-olsr_print_mprs_set()
+olsr_print_mprs_set(void)
 {
   struct mpr_selector *mprs;
+  OLSR_PRINTF(1, "MPR SELECTORS: ");
 
-
-  mprs = mprs_list.next;
-  OLSR_PRINTF(1, "MPR SELECTORS: ")
-
-  while(mprs != &mprs_list)
+    for(mprs = mprs_list.next; mprs != &mprs_list; mprs = mprs->next)
     {
-      OLSR_PRINTF(1, "%s ", olsr_ip_to_string(&mprs->MS_main_addr))
-      mprs = mprs->next;
+      OLSR_PRINTF(1, "%s ", olsr_ip_to_string(&mprs->MS_main_addr));
     }
-  OLSR_PRINTF(1, "\n")
+  OLSR_PRINTF(1, "\n");
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/neighbor_table.c olsrd-current/src/neighbor_table.c
--- olsrd-0.5.0/src/neighbor_table.c	2006-01-07 09:16:20.000000000 +0100
+++ olsrd-current/src/neighbor_table.c	2007-04-26 00:08:09.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: neighbor_table.c,v 1.30 2006/01/07 08:16:20 kattemat Exp $
+ * $Id: neighbor_table.c,v 1.32 2007/04/25 22:08:09 bernd67 Exp $
  */
 
 
@@ -56,12 +56,11 @@
 
 
 void
-olsr_init_neighbor_table()
+olsr_init_neighbor_table(void)
 {
   int i;
 
   olsr_register_timeout_function(&olsr_time_out_neighborhood_tables);
-
   for(i = 0; i < HASHSIZE; i++)
     {
       neighbortable[i].next = &neighbortable[i];
@@ -437,31 +436,21 @@
     }
 }
 
-
-
-
-
 void
-olsr_time_out_neighborhood_tables()
+olsr_time_out_neighborhood_tables(void)
 {
-  olsr_u8_t              index;
+  olsr_u8_t index;
   
   for(index=0;index<HASHSIZE;index++)
     {
-      struct neighbor_entry *entry = neighbortable[index].next;
-
-      while(entry != &neighbortable[index])
+      struct neighbor_entry *entry;
+      for(entry = neighbortable[index].next; entry != &neighbortable[index]; entry = entry->next)
 	{	  
 	  olsr_time_out_two_hop_neighbors(entry);
-	  entry = entry->next;
 	}
     }
 }
 
-
-
-
-
 /**
  *Prints the registered neighbors and two hop neighbors
  *to STDOUT.
@@ -469,7 +458,7 @@
  *@return nada
  */
 void
-olsr_print_neighbor_table()
+olsr_print_neighbor_table(void)
 {
   int i;
   char *fstr;
@@ -478,42 +467,37 @@
               nowtm->tm_hour,
               nowtm->tm_min,
               nowtm->tm_sec,
-              (int)now.tv_usec/10000)
+              (int)now.tv_usec/10000);
 
   if (olsr_cnf->ip_version == AF_INET)
-  {
-    OLSR_PRINTF(1, "IP address       LQ     NLQ    SYM   MPR   MPRS  will\n")
-    fstr = "%-15s  %5.3f  %5.3f  %s  %s  %s  %d\n";
-  }
-
+    {
+      OLSR_PRINTF(1, "IP address       LQ     NLQ    SYM   MPR   MPRS  will\n");
+      fstr = "%-15s  %5.3f  %5.3f  %s  %s  %s  %d\n";
+    }
   else
-  {
-    OLSR_PRINTF(1, "IP address                               LQ     NLQ    SYM   MPR   MPRS  will\n")
-    fstr = "%-39s  %5.3f  %5.3f  %s  %s  %s  %d\n";
-  }
+    {
+      OLSR_PRINTF(1, "IP address                               LQ     NLQ    SYM   MPR   MPRS  will\n");
+      fstr = "%-39s  %5.3f  %5.3f  %s  %s  %s  %d\n";
+    }
 
   for (i = 0; i < HASHSIZE; i++)
     {
       struct neighbor_entry *neigh;
-      for(neigh = neighbortable[i].next; neigh != &neighbortable[i];
-	  neigh = neigh->next)
+      for(neigh = neighbortable[i].next; neigh != &neighbortable[i]; neigh = neigh->next)
 	{
-	  struct link_entry *link =
-            get_best_link_to_neighbor(&neigh->neighbor_main_addr);
-	  double best_lq, inv_best_lq;
-
-	  if(!link) 
-	    continue;
-
-	  best_lq = link->neigh_link_quality;
-	  inv_best_lq = link->loss_link_quality;
-
-          OLSR_PRINTF(1, fstr, olsr_ip_to_string(&neigh->neighbor_main_addr),
-                      inv_best_lq, best_lq,
-                      (neigh->status == SYM) ? "YES " : "NO  ",
-                      neigh->is_mpr ? "YES " : "NO  ", 
-		      olsr_lookup_mprs_set(&neigh->neighbor_main_addr) == NULL ? "NO  " : "YES ",
-                      neigh->willingness)
+	  struct link_entry *link = get_best_link_to_neighbor(&neigh->neighbor_main_addr);
+	  if(link)
+            {
+              double best_lq = link->neigh_link_quality;
+              double inv_best_lq = link->loss_link_quality;
+
+              OLSR_PRINTF(1, fstr, olsr_ip_to_string(&neigh->neighbor_main_addr),
+                          inv_best_lq, best_lq,
+                          (neigh->status == SYM) ? "YES " : "NO  ",
+                          neigh->is_mpr ? "YES " : "NO  ", 
+                          olsr_lookup_mprs_set(&neigh->neighbor_main_addr) == NULL ? "NO  " : "YES ",
+                          neigh->willingness);
+            }
         }
     }
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/net_olsr.c olsrd-current/src/net_olsr.c
--- olsrd-0.5.0/src/net_olsr.c	2007-02-10 20:59:51.000000000 +0100
+++ olsrd-current/src/net_olsr.c	2007-05-14 00:23:55.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: net_olsr.c,v 1.19 2007/02/10 19:59:51 bernd67 Exp $
+ * $Id: net_olsr.c,v 1.23 2007/05/13 22:23:55 bernd67 Exp $
  */
 
 #include "net_olsr.h"
@@ -77,8 +77,6 @@
 
 static struct ptf *ptf_list;
 
-static char ipv6_buf[100]; /* for address coversion */
-
 static struct deny_address_entry *deny_entries;
 
 static const char * const deny_ipv4_defaults[] =
@@ -104,16 +102,15 @@
 void
 init_net(void)
 {
-  union olsr_ip_addr addr;
-  int i;
-
   /* Block invalid addresses */
   if(olsr_cnf->ip_version == AF_INET)
     {
+      union olsr_ip_addr addr;
+      int i;
       /* IPv4 */
       for(i = 0; deny_ipv4_defaults[i] != NULL; i++)
 	{
-	  if(inet_pton(olsr_cnf->ip_version, deny_ipv4_defaults[i], &addr) < 0)
+	  if(inet_pton(olsr_cnf->ip_version, deny_ipv4_defaults[i], &addr) <= 0)
 	    {
 	      fprintf(stderr, "Error converting fixed IP %s for deny rule!!\n",
 		      deny_ipv4_defaults[i]);
@@ -124,10 +121,12 @@
     }
   else 
     {
+      union olsr_ip_addr addr;
+      int i;
       /* IPv6 */
       for(i = 0; deny_ipv6_defaults[i] != NULL; i++)
 	{
-	  if(inet_pton(olsr_cnf->ip_version, deny_ipv6_defaults[i], &addr) < 0)
+	  if(inet_pton(olsr_cnf->ip_version, deny_ipv6_defaults[i], &addr) <= 0)
 	    {
 	      fprintf(stderr, "Error converting fixed IP %s for deny rule!!\n",
 		      deny_ipv6_defaults[i]);
@@ -250,7 +249,7 @@
  *  success
  */
 int
-net_outbuffer_push(struct interface *ifp, olsr_u8_t *data, olsr_u16_t size)
+net_outbuffer_push(struct interface *ifp, const void *data, const olsr_u16_t size)
 {
   if((ifp->netbuf.pending + size) > ifp->netbuf.maxsize)
     return 0;
@@ -274,7 +273,7 @@
  *  success
  */
 int
-net_outbuffer_push_reserved(struct interface *ifp, olsr_u8_t *data, olsr_u16_t size)
+net_outbuffer_push_reserved(struct interface *ifp, const void *data, const olsr_u16_t size)
 {
   if((ifp->netbuf.pending + size) > (ifp->netbuf.maxsize + ifp->netbuf.reserved))
     return 0;
@@ -294,7 +293,7 @@
  * @return the number of bytes available in the buffer or
  */
 int
-net_outbuffer_bytes_left(struct interface *ifp)
+net_outbuffer_bytes_left(const struct interface *ifp)
 {
   return ifp->netbuf.maxsize - ifp->netbuf.pending;
 }
@@ -417,11 +416,9 @@
   /*
    *Call possible packet transform functions registered by plugins  
    */
-  tmp_ptf_list = ptf_list;
-  while(tmp_ptf_list != NULL)
+  for (tmp_ptf_list = ptf_list; tmp_ptf_list != NULL; tmp_ptf_list = tmp_ptf_list->next)
     {
       tmp_ptf_list->function(ifp->netbuf.buff, &ifp->netbuf.pending);
-      tmp_ptf_list = tmp_ptf_list->next;
     }
 
   /*
@@ -461,7 +458,7 @@
 	{
 	  perror("sendto(v6)");
 	  olsr_syslog(OLSR_LOG_ERR, "OLSR: sendto IPv6 %m");
-	  fprintf(stderr, "Socket: %d interface: %d\n", ifp->olsr_socket, ifp->if_nr);
+	  fprintf(stderr, "Socket: %d interface: %d\n", ifp->olsr_socket, ifp->if_index);
 	  fprintf(stderr, "To: %s (size: %d)\n", ip6_to_string(&sin6->sin6_addr), (int)sizeof(*sin6));
 	  fprintf(stderr, "Outputsize: %d\n", ifp->netbuf.pending);
 	  retval = -1;
@@ -508,7 +505,7 @@
     }
 
 #ifdef DEBUG
-  OLSR_PRINTF(3, "Prefix %d = Netmask: %s\n", prefix, olsr_ip_to_string(adr))
+  OLSR_PRINTF(3, "Prefix %d = Netmask: %s\n", prefix, olsr_ip_to_string(adr));
 #endif
 
   return 1;
@@ -547,7 +544,7 @@
     }
 
 #ifdef DEBUG
-  OLSR_PRINTF(3, "Netmask: %s = Prefix %d\n", olsr_ip_to_string(adr), prefix)
+  OLSR_PRINTF(3, "Netmask: %s = Prefix %d\n", olsr_ip_to_string(adr), prefix);
 #endif
 
   return prefix;
@@ -585,19 +582,15 @@
  *@return a char pointer to the string containing the IP
  */
 
-char *
-ip_to_string(olsr_u32_t *address)
+const char *
+ip_to_string(const olsr_u32_t *address)
 {
-
   struct in_addr in;
   in.s_addr=*address;
   return(inet_ntoa(in));
   
 }
 
-
-
-
 /**
  *Converts the 32bit olsr_u32_t datatype to
  *a char array.
@@ -608,36 +601,36 @@
  *@return a char pointer to the string containing the IP
  */
 
-char *
-ip6_to_string(struct in6_addr *addr6)
+const char *
+ip6_to_string(const struct in6_addr *addr6)
 {
-  return (char *)inet_ntop(AF_INET6, addr6, ipv6_buf, sizeof(ipv6_buf));
+  static char ipv6_buf[INET6_ADDRSTRLEN]; /* for address coversion */
+  return inet_ntop(AF_INET6, addr6, ipv6_buf, sizeof(ipv6_buf));
 }
 
 
-char *
-olsr_ip_to_string(union olsr_ip_addr *addr)
+const char *
+olsr_ip_to_string(const union olsr_ip_addr *addr)
 {
   static int index = 0;
-  static char buff[4][100];
-  char *ret;
-  struct in_addr in;
+  static char buff[4][INET6_ADDRSTRLEN > INET_ADDRSTRLEN ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN];
+  const char *ret;
   
   if(olsr_cnf->ip_version == AF_INET)
     {
-      in.s_addr=addr->v4;
-      ret = inet_ntoa(in);
+#if 0
+      struct in_addr in;
+      in.s_addr = addr->v4;
+      ret = inet_ntop(AF_INET, &in, buff[index], sizeof(buff[index]));
+#else
+      ret = inet_ntop(AF_INET, &addr->v6, buff[index], sizeof(buff[index]));
+#endif
     }
   else
     {
       /* IPv6 */
-      ret = (char *)inet_ntop(AF_INET6, &addr->v6, ipv6_buf, sizeof(ipv6_buf));
+      ret = inet_ntop(AF_INET6, &addr->v6, buff[index], sizeof(buff[index]));
     }
-
-  strncpy(buff[index], ret, 100);
-
-  ret = buff[index];
-
   index = (index + 1) & 3;
 
   return ret;
@@ -656,7 +649,7 @@
 
   deny_entries = new_entry;
 
-  OLSR_PRINTF(1, "Added %s to IP deny set\n", olsr_ip_to_string(&new_entry->addr))
+  OLSR_PRINTF(1, "Added %s to IP deny set\n", olsr_ip_to_string(&new_entry->addr));
   return;
 }
 
@@ -679,7 +672,7 @@
       if(COMP_IP(adr, &deny_entry->addr))
 	{
 	  OLSR_PRINTF(1, "Validation of address %s failed!\n",
-		      olsr_ip_to_string(adr))
+		      olsr_ip_to_string(adr));
 	  return OLSR_FALSE;
 	}
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/net_olsr.h olsrd-current/src/net_olsr.h
--- olsrd-0.5.0/src/net_olsr.h	2007-02-10 20:59:51.000000000 +0100
+++ olsrd-current/src/net_olsr.h	2007-04-26 00:08:09.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: net_olsr.h,v 1.7 2007/02/10 19:59:51 bernd67 Exp $
+ * $Id: net_olsr.h,v 1.9 2007/04/25 22:08:09 bernd67 Exp $
  */
 
 
@@ -64,7 +64,7 @@
 net_remove_buffer(struct interface *);
 
 int
-net_outbuffer_bytes_left(struct interface *);
+net_outbuffer_bytes_left(const struct interface *);
 
 olsr_u16_t
 net_output_pending(struct interface *);
@@ -73,13 +73,13 @@
 net_reserve_bufspace(struct interface *, int);
 
 int
-net_outbuffer_push(struct interface *, olsr_u8_t *, olsr_u16_t);
+net_outbuffer_push(struct interface *, const void *, const olsr_u16_t);
 
 int
-net_outbuffer_push_reserved(struct interface *, olsr_u8_t *, olsr_u16_t);
+net_outbuffer_push_reserved(struct interface *, const void *, const olsr_u16_t);
 
 int
-net_output(struct interface*);
+net_output(struct interface *);
 
 int
 net_sendroute(struct rt_entry *, struct sockaddr *);
@@ -93,14 +93,14 @@
 char *
 sockaddr_to_string(struct sockaddr *);
 
-char *
-ip_to_string(olsr_u32_t *);
+const char *
+ip_to_string(const olsr_u32_t *);
 
-char *
-ip6_to_string(struct in6_addr *);
+const char *
+ip6_to_string(const struct in6_addr *);
 
-char *
-olsr_ip_to_string(union olsr_ip_addr *);
+const char *
+olsr_ip_to_string(const union olsr_ip_addr *);
 
 int
 add_ptf(packet_transform_function);
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/olsr.c olsrd-current/src/olsr.c
--- olsrd-0.5.0/src/olsr.c	2007-02-04 23:47:45.000000000 +0100
+++ olsrd-current/src/olsr.c	2007-04-26 00:08:09.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsr.c,v 1.50 2007/02/04 22:47:45 bernd67 Exp $
+ * $Id: olsr.c,v 1.54 2007/04/25 22:08:09 bernd67 Exp $
  */
 
 /**
@@ -88,7 +88,7 @@
  *Initialize the message sequence number as a random value
  */
 void
-init_msg_seqno()
+init_msg_seqno(void)
 {
   message_seqno = random() & 0xFFFF;
 }
@@ -98,8 +98,8 @@
  *
  *@return the seqno
  */
-inline olsr_u16_t
-get_msg_seqno()
+olsr_u16_t
+get_msg_seqno(void)
 {
   return message_seqno++;
 }
@@ -110,7 +110,7 @@
 {
   struct pcf *new_pcf;
 
-  OLSR_PRINTF(1, "Registering pcf function\n")
+  OLSR_PRINTF(1, "Registering pcf function\n");
 
   new_pcf = olsr_malloc(sizeof(struct pcf), "New PCF");
 
@@ -129,18 +129,17 @@
  *@return 0
  */
 void
-olsr_process_changes()
+olsr_process_changes(void)
 {
-
   struct pcf *tmp_pc_list;
 
 #ifdef DEBUG
   if(changes_neighborhood)
-    OLSR_PRINTF(3, "CHANGES IN NEIGHBORHOOD\n")
+    OLSR_PRINTF(3, "CHANGES IN NEIGHBORHOOD\n");
   if(changes_topology)
-    OLSR_PRINTF(3, "CHANGES IN TOPOLOGY\n")
+    OLSR_PRINTF(3, "CHANGES IN TOPOLOGY\n");
   if(changes_hna)
-    OLSR_PRINTF(3, "CHANGES IN HNA\n")
+    OLSR_PRINTF(3, "CHANGES IN HNA\n");
 #endif
   
   if(!changes_force &&
@@ -255,9 +254,8 @@
  *Also initalizes other variables
  */
 void
-olsr_init_tables()
-{
-  
+olsr_init_tables(void)
+{  
   changes_topology = OLSR_FALSE;
   changes_neighborhood = OLSR_FALSE;
   changes_hna = OLSR_FALSE;
@@ -290,15 +288,9 @@
   olsr_init_mid_set();
 
   /* Initialize HNA set */
-  olsr_init_hna_set();
-  
+  olsr_init_hna_set();  
 }
 
-
-
-
-
-
 /**
  *Check if a message is to be forwarded and forward
  *it if necessary.
@@ -325,17 +317,18 @@
   if(!olsr_check_dup_table_fwd(originator, seqno, &in_if->ip_addr))
     {
 #ifdef DEBUG
-      OLSR_PRINTF(3, "Message already forwarded!\n")
+      OLSR_PRINTF(3, "Message already forwarded!\n");
 #endif
       return 0;
     }
 
   /* Lookup sender address */
-  if(!(src = mid_lookup_main_addr(from_addr)))
+  src = mid_lookup_main_addr(from_addr);
+  if(!src)
     src = from_addr;
 
-
-  if(NULL == (neighbor=olsr_lookup_neighbor_table(src)))
+  neighbor=olsr_lookup_neighbor_table(src);
+  if(!neighbor)
     return 0;
 
   if(neighbor->status != SYM)
@@ -349,12 +342,11 @@
   if(olsr_lookup_mprs_set(src) == NULL)
     {
 #ifdef DEBUG
-      OLSR_PRINTF(5, "Forward - sender %s not MPR selector\n", olsr_ip_to_string(src))
+      OLSR_PRINTF(5, "Forward - sender %s not MPR selector\n", olsr_ip_to_string(src));
 #endif
       return 0;
     }
 
-
   /* Treat TTL hopcnt */
   if(olsr_cnf->ip_version == AF_INET)
     {
@@ -369,14 +361,10 @@
       m->v6.ttl--; 
     }
 
-
-
   /* Update dup forwarded */
   olsr_set_dup_forward(originator, seqno);
 
   /* Update packet data */
-
-
   msgsize = ntohs(m->v4.olsr_msgsize);
 
   /* looping trough interfaces */
@@ -387,37 +375,33 @@
 	  /*
 	   * Check if message is to big to be piggybacked
 	   */
-	  if(net_outbuffer_push(ifn, (olsr_u8_t *)m, msgsize) != msgsize)
+	  if(net_outbuffer_push(ifn, m, msgsize) != msgsize)
 	    {
 	      /* Send */
 	      net_output(ifn);
 	      /* Buffer message */
 	      set_buffer_timer(ifn);
 	      
-	      if(net_outbuffer_push(ifn, (olsr_u8_t *)m, msgsize) != msgsize)
+	      if(net_outbuffer_push(ifn, m, msgsize) != msgsize)
 		{
-		  OLSR_PRINTF(1, "Received message to big to be forwarded in %s(%d bytes)!", ifn->int_name, msgsize)
+		  OLSR_PRINTF(1, "Received message to big to be forwarded in %s(%d bytes)!", ifn->int_name, msgsize);
 		  olsr_syslog(OLSR_LOG_ERR, "Received message to big to be forwarded on %s(%d bytes)!", ifn->int_name, msgsize);
 		}
-
 	    }
 	}
-      
       else
 	{
 	  /* No forwarding pending */
 	  set_buffer_timer(ifn);
 	  
-	  if(net_outbuffer_push(ifn, (olsr_u8_t *)m, msgsize) != msgsize)
+	  if(net_outbuffer_push(ifn, m, msgsize) != msgsize)
 	    {
-	      OLSR_PRINTF(1, "Received message to big to be forwarded in %s(%d bytes)!", ifn->int_name, msgsize)
+	      OLSR_PRINTF(1, "Received message to big to be forwarded in %s(%d bytes)!", ifn->int_name, msgsize);
 	      olsr_syslog(OLSR_LOG_ERR, "Received message to big to be forwarded on %s(%d bytes)!", ifn->int_name, msgsize);
 	    }
 	}
     }
-
   return 1;
-
 }
 
 
@@ -431,13 +415,10 @@
   jitter *= olsr_cnf->max_jitter;
 
   ifn->fwdtimer = GET_TIMESTAMP(jitter*1000);
-
 }
 
-
-
 void
-olsr_init_willingness()
+olsr_init_willingness(void)
 {
   if(olsr_cnf->willingness_auto)
     olsr_register_scheduler_event(&olsr_update_willingness, 
@@ -445,18 +426,16 @@
 }
 
 void
-olsr_update_willingness(void *foo)
+olsr_update_willingness(void *foo __attribute__((unused)))
 {
-  int tmp_will;
-
-  tmp_will = olsr_cnf->willingness;
+  int tmp_will = olsr_cnf->willingness;
 
   /* Re-calculate willingness */
   olsr_cnf->willingness = olsr_calculate_willingness();
 
   if(tmp_will != olsr_cnf->willingness)
     {
-      OLSR_PRINTF(1, "Local willingness updated: old %d new %d\n", tmp_will, olsr_cnf->willingness)
+      OLSR_PRINTF(1, "Local willingness updated: old %d new %d\n", tmp_will, olsr_cnf->willingness);
     }
 }
 
@@ -470,7 +449,7 @@
  */
 
 olsr_u8_t
-olsr_calculate_willingness()
+olsr_calculate_willingness(void)
 {
   struct olsr_apm_info ainfo;
 
@@ -582,7 +561,7 @@
 void
 olsr_exit(const char *msg, int val)
 {
-  OLSR_PRINTF(1, "OLSR EXIT: %s\n", msg)
+  OLSR_PRINTF(1, "OLSR EXIT: %s\n", msg);
   olsr_syslog(OLSR_LOG_ERR, "olsrd exit: %s\n", msg);
   fflush(stdout);
   olsr_cnf->exit_value = val;
@@ -607,9 +586,10 @@
 
   if((ptr = malloc(size)) == 0) 
     {
-      OLSR_PRINTF(1, "OUT OF MEMORY: %s\n", strerror(errno))
-      olsr_syslog(OLSR_LOG_ERR, "olsrd: out of memory!: %m\n");
-      olsr_exit((char *)id, EXIT_FAILURE);
+      const char * const err_msg = strerror(errno);
+      OLSR_PRINTF(1, "OUT OF MEMORY: %s\n", err_msg);
+      olsr_syslog(OLSR_LOG_ERR, "olsrd: out of memory!: %s\n", err_msg);
+      olsr_exit(id, EXIT_FAILURE);
     }
   return ptr;
 }
@@ -624,17 +604,12 @@
 int
 olsr_printf(int loglevel, char *format, ...)
 {
-  va_list arglist;
-
   if((loglevel <= olsr_cnf->debug_level) && debug_handle)
     {
+      va_list arglist;
       va_start(arglist, format);
-      
       vfprintf(debug_handle, format, arglist);
-      
       va_end(arglist);
     }
-
-
   return 0;
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/olsr_cfg.h olsrd-current/src/olsr_cfg.h
--- olsrd-0.5.0/src/olsr_cfg.h	2006-04-17 20:31:09.000000000 +0200
+++ olsrd-current/src/olsr_cfg.h	2007-05-14 00:23:55.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsr_cfg.h,v 1.30 2006/04/17 18:31:09 kattemat Exp $
+ * $Id: olsr_cfg.h,v 1.31 2007/05/13 22:23:55 bernd67 Exp $
  */
 
 
@@ -132,7 +132,6 @@
 {
   char                     *name;
   char                     *config;
-  int                      index;
   olsr_bool                configured;
   olsr_bool                host_emul;
   union olsr_ip_addr       hemu_ip;
@@ -223,7 +222,6 @@
   struct ipc_host          *ipc_hosts;
   struct ipc_net           *ipc_nets;
   struct olsr_if           *interfaces;
-  olsr_u16_t               ifcnt;
 
   /* Stuff set by olsrd */
   size_t                   ipsize;               /* Size of address */
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/olsrd_plugin.h olsrd-current/src/olsrd_plugin.h
--- olsrd-0.5.0/src/olsrd_plugin.h	2005-05-29 14:47:45.000000000 +0200
+++ olsrd-current/src/olsrd_plugin.h	2007-04-20 15:46:04.000000000 +0200
@@ -29,7 +29,7 @@
  *
  */
 
-/* $Id: olsrd_plugin.h,v 1.1 2005/05/29 12:47:45 br1 Exp $ */
+/* $Id: olsrd_plugin.h,v 1.2 2007/04/20 13:46:04 bernd67 Exp $ */
 
 /*
  * Example plugin for olsrd.org OLSR daemon
@@ -48,6 +48,13 @@
  *                Functions that the plugin MUST provide                    *
  ****************************************************************************/
 
+#if 1
+/* We hide them from the compiler here to allow the plugins itself to declare them
+ * as they also implement them if we activate -Wredundant-decls.
+ * Normally we leave it seen so that we enforce a check by the compiler if they are
+ * identical.
+ */
+
 /**
  * Plugin interface version
  * Used by main olsrd to check plugin interface version
@@ -70,6 +77,6 @@
  */
 int
 olsrd_plugin_init(void);
-
+#endif
 
 #endif
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/olsr.h olsrd-current/src/olsr.h
--- olsrd-0.5.0/src/olsr.h	2007-01-31 13:36:50.000000000 +0100
+++ olsrd-current/src/olsr.h	2007-04-20 15:46:04.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsr.h,v 1.25 2007/01/31 12:36:50 bernd67 Exp $
+ * $Id: olsr.h,v 1.26 2007/04/20 13:46:04 bernd67 Exp $
  */
 
 
@@ -60,7 +60,7 @@
 void
 init_msg_seqno(void);
 
-inline olsr_u16_t
+olsr_u16_t
 get_msg_seqno(void);
 
 int
@@ -101,6 +101,6 @@
 olsr_malloc(size_t, const char *);
 
 int
-olsr_printf(int, char *, ...);
+olsr_printf(int, char *, ...) __attribute__((format(printf,2,3)));
 
 #endif
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/olsr_protocol.h olsrd-current/src/olsr_protocol.h
--- olsrd-0.5.0/src/olsr_protocol.h	2006-01-12 12:00:49.000000000 +0100
+++ olsrd-current/src/olsr_protocol.h	2007-04-22 22:25:48.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsr_protocol.h,v 1.21 2006/01/12 11:00:49 kattemat Exp $
+ * $Id: olsr_protocol.h,v 1.22 2007/04/22 20:25:48 bernd67 Exp $
  */
 
 /*
@@ -253,7 +253,7 @@
 } __attribute__ ((packed));
 
 
-struct tcmsg 
+struct olsr_tcmsg 
 {
   olsr_u16_t        ansn;
   olsr_u16_t        reserved;
@@ -272,7 +272,7 @@
 } __attribute__ ((packed));
 
 
-struct tcmsg6
+struct olsr_tcmsg6
 {
   olsr_u16_t           ansn;
   olsr_u16_t           reserved;
@@ -373,7 +373,7 @@
   union 
   {
     struct hellomsg hello;
-    struct tcmsg    tc;
+    struct olsr_tcmsg    tc;
     struct hnamsg   hna;
     struct midmsg   mid;
   } message;
@@ -397,7 +397,7 @@
   union 
   {
     struct hellomsg6 hello;
-    struct tcmsg6    tc;
+    struct olsr_tcmsg6    tc;
     struct hnamsg6   hna;
     struct midmsg6   mid;
   } message;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/olsr_switch/commands.h olsrd-current/src/olsr_switch/commands.h
--- olsrd-0.5.0/src/olsr_switch/commands.h	2005-06-04 23:07:33.000000000 +0200
+++ olsrd-current/src/olsr_switch/commands.h	2007-05-31 02:16:52.000000000 +0200
@@ -37,7 +37,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: commands.h,v 1.7 2005/06/04 21:07:33 kattemat Exp $
+ * $Id: commands.h,v 1.8 2007/05/31 00:16:52 ipo23 Exp $
  */
 
 
@@ -76,7 +76,7 @@
     },
     { "olsrd", "olsrd [start|stop|show|setb|seta] [IP|path|args]",
       "Start or stop local olsrd processes. Also used to set the olsrd binary path and arguments",
-      "This command is used for managing local olsrd instances from within olsr_switch.\nThe command can be configured in runtime using the setb and seta sub-commands.\nTo show the current olsrd command-configuration do:\nolsrd show\nTo set the olsrd binary path do:\nolsrd setb /full/path/to/olsrd\nTo start a olsrd instance with a IP address of 10.0.0.1, do:\nolsrd start 10.0.0.1\nTo stop that same instance do:\nolsrd stop 10.0.0.1\n",
+      "This command is used for managing local olsrd instances from within olsr_switch.\nThe command can be configured in runtime using the setb and seta sub-commands.\nTo show the current olsrd command-configuration do:\nolsrd show\nTo set the olsrd binary path do:\nolsrd setb /full/path/to/olsrd\nTo start a olsrd instance with a IP address of 10.0.0.1, do:\nolsrd start 10.0.0.1\nTo stop that same instance do:\nolsrd stop 10.0.0.1\nseta would set arguments but is currently not implemented\n",
       ohs_cmd_olsrd
     },
     { NULL, NULL,
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/olsr_switch/main.c olsrd-current/src/olsr_switch/main.c
--- olsrd-0.5.0/src/olsr_switch/main.c	2006-11-06 00:03:56.000000000 +0100
+++ olsrd-current/src/olsr_switch/main.c	2007-04-20 16:23:41.000000000 +0200
@@ -37,7 +37,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: main.c,v 1.23 2006/11/05 23:03:56 bernd67 Exp $
+ * $Id: main.c,v 1.24 2007/04/20 14:23:41 bernd67 Exp $
  */
 
 /* olsrd host-switch daemon */
@@ -84,7 +84,7 @@
 static int
 ohs_init_new_connection(int);
 
-inline static int
+static int
 ohs_route_data(struct ohs_connection *);
 
 static int
@@ -263,7 +263,7 @@
   return 0;
 }
 
-inline static int
+static int
 ohs_route_data(struct ohs_connection *oc)
 {
   struct ohs_connection *ohs_cs;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/olsr_switch/ohs_cmd.c olsrd-current/src/olsr_switch/ohs_cmd.c
--- olsrd-0.5.0/src/olsr_switch/ohs_cmd.c	2005-11-22 11:12:30.000000000 +0100
+++ olsrd-current/src/olsr_switch/ohs_cmd.c	2007-05-31 02:14:53.000000000 +0200
@@ -37,7 +37,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: ohs_cmd.c,v 1.21 2005/11/22 10:12:30 tlopatic Exp $
+ * $Id: ohs_cmd.c,v 1.22 2007/05/31 00:14:53 ipo23 Exp $
  */
 
 #include "olsr_host_switch.h"
@@ -214,7 +214,8 @@
   /* Set arguments */
   else if(!strncmp(tok_buf, "seta", strlen("seta")))
     {
-
+	printf("Error - NOT IMPLEMENTED YET\n");
+	return 1;
     }
   /* Show settings */
   else if(!strncmp(tok_buf, "show", strlen("show")))
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/olsr_types.h olsrd-current/src/olsr_types.h
--- olsrd-0.5.0/src/olsr_types.h	2007-01-31 13:36:50.000000000 +0100
+++ olsrd-current/src/olsr_types.h	2007-04-26 00:08:09.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsr_types.h,v 1.5 2007/01/31 12:36:50 bernd67 Exp $
+ * $Id: olsr_types.h,v 1.7 2007/04/25 22:08:09 bernd67 Exp $
  */
 
 /*
@@ -50,11 +50,10 @@
 /* types */
 #include <sys/types.h>
 
-typedef enum
-{
+typedef enum {
     OLSR_FALSE = 0,
     OLSR_TRUE
-}olsr_bool;
+} olsr_bool;
 
 #if defined linux || defined __MacOSX__
 
@@ -92,6 +91,9 @@
 
 union olsr_ip_addr
 {
+  /*
+  struct in_addr v4;
+  */
   olsr_u32_t v4;
   olsr_u8_t v4x[4];
   struct in6_addr v6;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/packet.c olsrd-current/src/packet.c
--- olsrd-0.5.0/src/packet.c	2006-01-07 09:16:20.000000000 +0100
+++ olsrd-current/src/packet.c	2007-04-26 00:08:09.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: packet.c,v 1.21 2006/01/07 08:16:20 kattemat Exp $
+ * $Id: packet.c,v 1.22 2007/04/25 22:08:09 bernd67 Exp $
  */
 
 
@@ -94,7 +94,7 @@
   int                     link;
 
 #ifdef DEBUG
-  OLSR_PRINTF(3, "\tBuilding HELLO on interface %d\n", outif->if_nr)
+  OLSR_PRINTF(3, "\tBuilding HELLO on interface %d\n", outif->if_nr);
 #endif
 
   message->neighbors=NULL;
@@ -106,7 +106,7 @@
 
   message->willingness = olsr_cnf->willingness;
 #ifdef DEBUG
-  OLSR_PRINTF(3, "Willingness: %d\n", olsr_cnf->willingness)
+  OLSR_PRINTF(3, "Willingness: %d\n", olsr_cnf->willingness);
 #endif
 
   /* Set TTL */
@@ -115,7 +115,7 @@
   COPY_IP(&message->source_addr, &olsr_cnf->main_addr);
 
 #ifdef DEBUG
-      OLSR_PRINTF(5, "On link:\n")
+  OLSR_PRINTF(5, "On link:\n");
 #endif
 
   /* Get the links of this interface */
@@ -193,8 +193,8 @@
       /* Set the main address */
       COPY_IP(&message_neighbor->main_address, &links->neighbor->neighbor_main_addr);
 #ifdef DEBUG
-      OLSR_PRINTF(5, "Added: %s - ", olsr_ip_to_string(&message_neighbor->address))
-      OLSR_PRINTF(5, " status %d\n", message_neighbor->status)
+      OLSR_PRINTF(5, "Added: %s - ", olsr_ip_to_string(&message_neighbor->address));
+      OLSR_PRINTF(5, " status %d\n", message_neighbor->status);
 #endif
       message_neighbor->next=message->neighbors;
       message->neighbors=message_neighbor;	    
@@ -207,7 +207,7 @@
 
 
 #ifdef DEBUG
-      OLSR_PRINTF(5, "Not on link:\n")
+    OLSR_PRINTF(5, "Not on link:\n");
 #endif
 
   /* Add the rest of the neighbors if running on multiple interfaces */
@@ -291,8 +291,8 @@
 
 	    COPY_IP(&message_neighbor->main_address, &neighbor->neighbor_main_addr);
 #ifdef DEBUG
-	    OLSR_PRINTF(5, "Added: %s - ", olsr_ip_to_string(&message_neighbor->address))
-	    OLSR_PRINTF(5, " status  %d\n", message_neighbor->status)
+	    OLSR_PRINTF(5, "Added: %s - ", olsr_ip_to_string(&message_neighbor->address));
+	    OLSR_PRINTF(5, " status  %d\n", message_neighbor->status);
 #endif
 	    message_neighbor->next=message->neighbors;
 	    message->neighbors=message_neighbor;	    
@@ -428,7 +428,7 @@
       if(sending_tc)
 	{
 	  /* Send empty TC */
-	  OLSR_PRINTF(3, "No more MPR selectors - will send empty TCs\n")
+	  OLSR_PRINTF(3, "No more MPR selectors - will send empty TCs\n");
 	  set_empty_tc_timer(GET_TIMESTAMP((olsr_cnf->max_tc_vtime*3)*1000));
 
 	  sending_tc = OLSR_FALSE;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/parser.c olsrd-current/src/parser.c
--- olsrd-0.5.0/src/parser.c	2007-01-31 13:36:50.000000000 +0100
+++ olsrd-current/src/parser.c	2007-05-09 01:34:52.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: parser.c,v 1.32 2007/01/31 12:36:50 bernd67 Exp $
+ * $Id: parser.c,v 1.35 2007/05/08 23:34:52 bernd67 Exp $
  */
 
 #include "parser.h"
@@ -87,9 +87,9 @@
  *@return nada
  */
 void
-olsr_init_parser()
+olsr_init_parser(void)
 {
-  OLSR_PRINTF(3, "Initializing parser...\n")
+  OLSR_PRINTF(3, "Initializing parser...\n");
 
   /* Initialize the packet functions */
   olsr_init_package_process();
@@ -101,7 +101,7 @@
 {
   struct parse_function_entry *new_entry;
 
-  OLSR_PRINTF(3, "Parser: registering event for type %d\n", type)
+  OLSR_PRINTF(3, "Parser: registering event for type %d\n", type);
  
 
   new_entry = olsr_malloc(sizeof(struct parse_function_entry), "Register parse function");
@@ -114,7 +114,7 @@
   new_entry->next = parse_functions;
   parse_functions = new_entry;
 
-  OLSR_PRINTF(3, "Register parse function: Added function for type %d\n", type)
+  OLSR_PRINTF(3, "Register parse function: Added function for type %d\n", type);
 
 }
 
@@ -181,7 +181,7 @@
 
   if (ntohs(olsr->olsr_packlen) != size)
     {
-      OLSR_PRINTF(1, "Size error detected in received packet.\nRecieved %d, in packet %d\n", size, ntohs(olsr->olsr_packlen))
+      OLSR_PRINTF(1, "Size error detected in received packet.\nRecieved %d, in packet %d\n", size, ntohs(olsr->olsr_packlen));
 	    
       olsr_syslog(OLSR_LOG_ERR, " packet length error in  packet received from %s!",
 	     olsr_ip_to_string(from_addr));
@@ -245,7 +245,7 @@
       if(count < 0)
 	{
 	  OLSR_PRINTF(1, "packet length error in  packet received from %s!",
-		      olsr_ip_to_string(from_addr))
+		      olsr_ip_to_string(from_addr));
 
 	  olsr_syslog(OLSR_LOG_ERR, " packet length error in  packet received from %s!",
 		 olsr_ip_to_string(from_addr));
@@ -261,7 +261,7 @@
 	    {
 	      OLSR_PRINTF(2, "Dropping packet type %d from neigh %s with TTL 0\n", 
 			  m->v4.olsr_msgtype,
-			  olsr_ip_to_string(from_addr))
+			  olsr_ip_to_string(from_addr));
 	      continue;
 	    }
 	}
@@ -272,7 +272,7 @@
 	    {
 	      OLSR_PRINTF(2, "Dropping packet type %d from %s with TTL 0\n", 
 			  m->v4.olsr_msgtype,
-			  olsr_ip_to_string(from_addr))
+			  olsr_ip_to_string(from_addr));
 	      continue;
 	    }
 	}
@@ -289,7 +289,7 @@
       if(COMP_IP(&m->v4.originator, &olsr_cnf->main_addr))
 	{
 #ifdef DEBUG
-	  OLSR_PRINTF(3, "Not processing message originating from us!\n")
+	  OLSR_PRINTF(3, "Not processing message originating from us!\n");
 #endif
 	  continue;
 	}
@@ -323,7 +323,7 @@
 	  OLSR_PRINTF(3, "Unknown type: %d, size %d, from %s\n",
 		      m->v4.olsr_msgtype,
 		      size,
-		      olsr_ip_to_string(&unkpacket.originator))
+		      olsr_ip_to_string(&unkpacket.originator));
 
 	  /* Forward message */
 	  if(!COMP_IP(&unkpacket.originator, &olsr_cnf->main_addr))
@@ -369,7 +369,7 @@
     {
       if (32 < ++cpu_overload_exit)
       {
-        OLSR_PRINTF(1, "CPU overload detected, ending olsr_input() loop\n")
+        OLSR_PRINTF(1, "CPU overload detected, ending olsr_input() loop\n");
       	break;
       }
       
@@ -386,7 +386,7 @@
 	{
 	  if (cc < 0 && errno != EWOULDBLOCK)
 	    {
-	      OLSR_PRINTF(1, "error recvfrom: %s", strerror(errno))
+	      OLSR_PRINTF(1, "error recvfrom: %s", strerror(errno));
 	      olsr_syslog(OLSR_LOG_ERR, "error recvfrom: %m");
 	    }
 	  break;
@@ -405,7 +405,7 @@
       
       
 #ifdef DEBUG
-      OLSR_PRINTF(5, "Recieved a packet from %s\n", olsr_ip_to_string((union olsr_ip_addr *)&((struct sockaddr_in *)&from)->sin_addr.s_addr))
+      OLSR_PRINTF(5, "Recieved a packet from %s\n", olsr_ip_to_string((union olsr_ip_addr *)&((struct sockaddr_in *)&from)->sin_addr.s_addr));
 #endif
 	
 	if ((olsr_cnf->ip_version == AF_INET) && (fromlen != sizeof (struct sockaddr_in)))
@@ -421,7 +421,7 @@
 	{
 	  OLSR_PRINTF(1, "Could not find input interface for message from %s size %d\n",
 		      olsr_ip_to_string(&from_addr),
-		      cc)
+		      cc);
 	  olsr_syslog(OLSR_LOG_ERR, "Could not find input interface for message from %s size %d\n",
 		 olsr_ip_to_string(&from_addr),
 		 cc);
@@ -474,7 +474,7 @@
     return;
       
   /* Extract size */
-  if((cc = recv(fd, &pcklen, 2, MSG_PEEK)) != 2)
+  if((cc = recv(fd, (void *)&pcklen, 2, MSG_PEEK)) != 2) /* Win needs a cast */
     {
       if(cc <= 0)
 	{
@@ -502,8 +502,9 @@
     {
       if (cc < 0 && errno != EWOULDBLOCK)
 	{
-	  OLSR_PRINTF(1, "error recvfrom: %s", strerror(errno))
-	    olsr_syslog(OLSR_LOG_ERR, "error recvfrom: %m");
+          const char * const err_msg = strerror(errno);
+	  OLSR_PRINTF(1, "error recvfrom: %s", err_msg);
+          olsr_syslog(OLSR_LOG_ERR, "error recvfrom: %s", err_msg);
 	}
       return;
     }
@@ -518,10 +519,10 @@
     {
       OLSR_PRINTF(1, "Could not find input interface for message from %s size %d\n",
 		  olsr_ip_to_string(&from_addr),
-		  cc)
-	olsr_syslog(OLSR_LOG_ERR, "Could not find input interface for message from %s size %d\n",
-		    olsr_ip_to_string(&from_addr),
-		    cc);
+		  cc);
+      olsr_syslog(OLSR_LOG_ERR, "Could not find input interface for message from %s size %d\n",
+                  olsr_ip_to_string(&from_addr),
+                  cc);
       return;
     }
   
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/plugin_loader.c olsrd-current/src/plugin_loader.c
--- olsrd-0.5.0/src/plugin_loader.c	2005-05-29 14:47:45.000000000 +0200
+++ olsrd-current/src/plugin_loader.c	2007-04-26 00:08:13.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: plugin_loader.c,v 1.23 2005/05/29 12:47:45 br1 Exp $
+ * $Id: plugin_loader.c,v 1.25 2007/04/25 22:08:13 bernd67 Exp $
  */
 
 #include "plugin_loader.h"
@@ -60,22 +60,17 @@
  *@return the number of plugins loaded
  */
 int
-olsr_load_plugins()
+olsr_load_plugins(void)
 {
-  struct plugin_entry *entry;
-  int loaded;
-
-  entry = olsr_cnf->plugins;
-  loaded = 0;
-
-  OLSR_PRINTF(1, "Loading plugins...\n\n")
-
+  struct plugin_entry *entry = olsr_cnf->plugins;
+  int loaded = 0;
+  OLSR_PRINTF(1, "Loading plugins...\n\n");
   while(entry)
     {  
       if(olsr_load_dl(entry->name, entry->params) < 0)
-	OLSR_PRINTF(1, "-- PLUGIN LOADING FAILED! --\n\n")
+	OLSR_PRINTF(1, "-- PLUGIN LOADING FAILED! --\n\n");
       else
-	loaded ++;
+	loaded++;
 
       entry = entry->next;
     }
@@ -98,25 +93,25 @@
   int (*get_interface_version)(void);
   int *interface_version;
 
-  OLSR_PRINTF(1, "---------- Plugin loader ----------\nLibrary: %s\n", libname)
+  OLSR_PRINTF(1, "---------- Plugin loader ----------\nLibrary: %s\n", libname);
 
   if((new_entry.dlhandle = dlopen(libname, RTLD_NOW)) == NULL)
     {
-      OLSR_PRINTF(1, "DL loading failed: \"%s\"!\n", dlerror())
+      OLSR_PRINTF(1, "DL loading failed: \"%s\"!\n", dlerror());
       return -1;
     }
 
   /* Fetch the interface version function, 3 different ways */
-  OLSR_PRINTF(1, "Checking plugin interface version... ")
+  OLSR_PRINTF(1, "Checking plugin interface version... ");
   if((get_interface_version = dlsym(new_entry.dlhandle, "olsrd_plugin_interface_version")) == NULL)
     {
-      OLSR_PRINTF(1, "trying v2 detection... ")
+      OLSR_PRINTF(1, "trying v2 detection... ");
       if((get_interface_version = dlsym(new_entry.dlhandle, "get_plugin_interface_version")) == NULL)
         {
-          OLSR_PRINTF(1, "trying v1 detection... ")
+          OLSR_PRINTF(1, "trying v1 detection... ");
           if((interface_version = dlsym(new_entry.dlhandle, "plugin_interface_version")) == NULL)
             {
-              OLSR_PRINTF(1, "FAILED: \"%s\"\n", dlerror())
+              OLSR_PRINTF(1, "FAILED: \"%s\"\n", dlerror());
               dlclose(new_entry.dlhandle);
               return -1;
             }
@@ -134,13 +129,13 @@
     {
       new_entry.plugin_interface_version = get_interface_version();
     }
-  OLSR_PRINTF(1, " %d - OK\n", new_entry.plugin_interface_version)
+  OLSR_PRINTF(1, " %d - OK\n", new_entry.plugin_interface_version);
   
   if ( new_entry.plugin_interface_version < 4 ) 
     {
       /* old plugin interface */
    
-      OLSR_PRINTF(1, "\nWARNING: YOU ARE USING AN OLD DEPRECATED PLUGIN INTERFACE! DETECTED VERSION %d CURRENT VERSION %d\nPLEASE UPGRADE YOUR PLUGIN!\nWILL CONTINUE IN 5 SECONDS...\n\n", new_entry.plugin_interface_version, OLSRD_PLUGIN_INTERFACE_VERSION)
+      OLSR_PRINTF(1, "\nWARNING: YOU ARE USING AN OLD DEPRECATED PLUGIN INTERFACE! DETECTED VERSION %d CURRENT VERSION %d\nPLEASE UPGRADE YOUR PLUGIN!\nWILL CONTINUE IN 5 SECONDS...\n\n", new_entry.plugin_interface_version, OLSRD_PLUGIN_INTERFACE_VERSION);
       
       sleep(5);
       dlclose(new_entry.dlhandle);
@@ -152,30 +147,30 @@
       
       if ( new_entry.plugin_interface_version != OLSRD_PLUGIN_INTERFACE_VERSION ) 
         {
-          OLSR_PRINTF(1, "\n\nWARNING: VERSION MISSMATCH! DETECTED %d CURRENT VERSION %d\nTHIS CAN CAUSE UNEXPECTED BEHAVIOUR AND CRASHES!\nWILL CONTINUE IN 5 SECONDS...\n\n", get_interface_version(), OLSRD_PLUGIN_INTERFACE_VERSION)
+          OLSR_PRINTF(1, "\n\nWARNING: VERSION MISSMATCH! DETECTED %d CURRENT VERSION %d\nTHIS CAN CAUSE UNEXPECTED BEHAVIOUR AND CRASHES!\nWILL CONTINUE IN 5 SECONDS...\n\n", get_interface_version(), OLSRD_PLUGIN_INTERFACE_VERSION);
           sleep(5);
         }
    
       /* Fetch the init function */
-      OLSR_PRINTF(1, "Trying to fetch plugin init function... ")
+      OLSR_PRINTF(1, "Trying to fetch plugin init function... ");
       if((new_entry.plugin_init = dlsym(new_entry.dlhandle, "olsrd_plugin_init")) == NULL)
         {
-          OLSR_PRINTF(1, "FAILED: \"%s\"\n", dlerror())
+          OLSR_PRINTF(1, "FAILED: \"%s\"\n", dlerror());
           dlclose(new_entry.dlhandle);
           return -1;
         }
       else
 	{
-	  OLSR_PRINTF(1, "OK\n")	
+	  OLSR_PRINTF(1, "OK\n");
 	}
     }
 
   /* Fetch the parameter function */
-  OLSR_PRINTF(1, "Trying to fetch param function... ")
+  OLSR_PRINTF(1, "Trying to fetch param function... ");
   if((new_entry.register_param = dlsym(new_entry.dlhandle, "olsrd_plugin_register_param")) == NULL)
-    OLSR_PRINTF(1, "FAILED: \"%s\"\n", dlerror())
+    OLSR_PRINTF(1, "FAILED: \"%s\"\n", dlerror());
   else
-    OLSR_PRINTF(1, "OK\n")
+    OLSR_PRINTF(1, "OK\n");
 
   entry = olsr_malloc(sizeof(struct olsr_plugin), "Plugin entry");
   memcpy(entry, &new_entry, sizeof(struct olsr_plugin));
@@ -188,7 +183,7 @@
   entry->next = olsr_plugins;
   olsr_plugins = entry;
 
-  OLSR_PRINTF(1, "---------- LIBRARY LOADED ----------\n\n")
+  OLSR_PRINTF(1, "---------- LIBRARY LOADED ----------\n\n");
 
   return 0;
 }
@@ -207,27 +202,24 @@
 void
 init_olsr_plugin(struct olsr_plugin *entry)
 {
-  struct plugin_param *params = entry->params;
-  int retval;
-
   if(entry->register_param)
     {
-      OLSR_PRINTF(1, "Sending parameters...\n")
-      while(params)
+      struct plugin_param *params;
+      OLSR_PRINTF(1, "Sending parameters...\n");
+        for(params = entry->params;params;params = params->next)
         {
-          OLSR_PRINTF(1, "\"%s\"/\"%s\"... ", params->key, params->value)
-          if((retval = entry->register_param(params->key, params->value)) < 0)
+          int retval = entry->register_param(params->key, params->value);
+          OLSR_PRINTF(1, "\"%s\"/\"%s\"... ", params->key, params->value);
+          if(retval < 0)
             {
               fprintf(stderr, "\nFatal error in plugin parameter \"%s\"/\"%s\"\n", params->key, params->value);
               exit(EXIT_FAILURE);
             }
-          OLSR_PRINTF(1, "%s\n", retval == 0 ? "FAILED" : "OK")
-
-          params = params->next;
+          OLSR_PRINTF(1, "%s\n", retval == 0 ? "FAILED" : "OK");
         }
     }
     
-    OLSR_PRINTF(1, "Running plugin_init function...\n")
+  OLSR_PRINTF(1, "Running plugin_init function...\n");
     entry->plugin_init();
 }
 
@@ -236,15 +228,11 @@
  *Close all loaded plugins
  */
 void
-olsr_close_plugins()
+olsr_close_plugins(void)
 {
   struct olsr_plugin *entry;
 
-  OLSR_PRINTF(1, "Closing plugins...\n")
-  for(entry = olsr_plugins; 
-      entry != NULL ; 
-      entry = entry->next)
-    {
+  OLSR_PRINTF(1, "Closing plugins...\n");
+  for(entry = olsr_plugins; entry != NULL; entry = entry->next)
       dlclose(entry->dlhandle);
-    }
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/print_packet.c olsrd-current/src/print_packet.c
--- olsrd-0.5.0/src/print_packet.c	2006-01-07 09:16:20.000000000 +0100
+++ olsrd-current/src/print_packet.c	2007-04-22 22:25:48.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: print_packet.c,v 1.9 2006/01/07 08:16:20 kattemat Exp $
+ * $Id: print_packet.c,v 1.10 2007/04/22 20:25:48 bernd67 Exp $
  */
 
 #include "print_packet.h"
@@ -55,10 +55,10 @@
 print_hnamsg(FILE *, olsr_u8_t *, olsr_16_t);
 
 static void
-print_tcmsg(FILE *, olsr_u8_t *, olsr_16_t);
+print_olsr_tcmsg(FILE *, olsr_u8_t *, olsr_16_t);
 
 static void
-print_tcmsg_lq(FILE *, olsr_u8_t *, olsr_16_t);
+print_olsr_tcmsg_lq(FILE *, olsr_u8_t *, olsr_16_t);
 
 static void
 print_hellomsg(FILE *, olsr_u8_t *, olsr_16_t);
@@ -131,13 +131,13 @@
 		   ntohs(msg->v4.olsr_msgsize));
       break;
     case(TC_MESSAGE):
-      print_tcmsg(handle,
+      print_olsr_tcmsg(handle,
 		  (olsr_cnf->ip_version == AF_INET) ? 
 		  (olsr_u8_t *)&msg->v4.message : (olsr_u8_t *)&msg->v6.message,
 		  ntohs(msg->v4.olsr_msgsize));
       break;
     case(LQ_TC_MESSAGE):
-      print_tcmsg_lq(handle,
+      print_olsr_tcmsg_lq(handle,
 		     (olsr_cnf->ip_version == AF_INET) ? 
 		     (olsr_u8_t *)&msg->v4.message : (olsr_u8_t *)&msg->v6.message,
 		     ntohs(msg->v4.olsr_msgsize));
@@ -323,11 +323,11 @@
 }
 
 static void
-print_tcmsg_lq(FILE *handle, olsr_u8_t *data, olsr_16_t totsize)
+print_olsr_tcmsg_lq(FILE *handle, olsr_u8_t *data, olsr_16_t totsize)
 {
   int remsize = totsize - ((olsr_cnf->ip_version == AF_INET) ? OLSR_MSGHDRSZ_IPV4 : OLSR_MSGHDRSZ_IPV6);
   
-  fprintf(handle, "    +ANSN: %d\n", htons(((struct tcmsg *)data)->ansn));
+  fprintf(handle, "    +ANSN: %d\n", htons(((struct olsr_tcmsg *)data)->ansn));
 
   data += 4;
   remsize -= 4;
@@ -347,11 +347,11 @@
 
 
 static void
-print_tcmsg(FILE *handle, olsr_u8_t *data, olsr_16_t totsize)
+print_olsr_tcmsg(FILE *handle, olsr_u8_t *data, olsr_16_t totsize)
 {
   int remsize = totsize - ((olsr_cnf->ip_version == AF_INET) ? OLSR_MSGHDRSZ_IPV4 : OLSR_MSGHDRSZ_IPV6);
   
-  fprintf(handle, "    +ANSN: %d\n", htons(((struct tcmsg *)data)->ansn));
+  fprintf(handle, "    +ANSN: %d\n", htons(((struct olsr_tcmsg *)data)->ansn));
 
   data += 4;
   remsize -= 4;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/process_package.c olsrd-current/src/process_package.c
--- olsrd-0.5.0/src/process_package.c	2007-02-10 20:27:32.000000000 +0100
+++ olsrd-current/src/process_package.c	2007-04-26 00:08:13.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: process_package.c,v 1.38 2007/02/10 19:27:32 bernd67 Exp $
+ * $Id: process_package.c,v 1.40 2007/04/25 22:08:13 bernd67 Exp $
  */
 
 
@@ -60,7 +60,7 @@
  *Initializing the parser functions we are using
  */
 void
-olsr_init_package_process()
+olsr_init_package_process(void)
 {
   if (olsr_cnf->lq_level == 0)
     {
@@ -81,21 +81,19 @@
 olsr_hello_tap(struct hello_message *message, struct interface *in_if,
                union olsr_ip_addr *from_addr)
 {
-  struct link_entry         *link;
   struct neighbor_entry     *neighbor;
-  struct hello_neighbor *walker;
-  double saved_lq;
-  double rel_lq;
 
   /*
    * Update link status
    */
-  link = update_link_entry(&in_if->ip_addr, from_addr, message, in_if);
+  struct link_entry         *link = update_link_entry(&in_if->ip_addr, from_addr, message, in_if);
 
   if (olsr_cnf->lq_level > 0)
     {
+      double saved_lq;
+      double rel_lq;
+      struct hello_neighbor *walker;
       // just in case our neighbor has changed its HELLO interval
-
       olsr_update_packet_loss_hello_int(link, message->htime);
 
       // find the input interface in the list of neighbor interfaces
@@ -136,7 +134,7 @@
           }
 
           else
-            OLSR_PRINTF(3, "Skipping Dijkstra (2)\n")
+            OLSR_PRINTF(3, "Skipping Dijkstra (2)\n");
 
           // create a new ANSN
 
@@ -172,7 +170,7 @@
       OLSR_PRINTF(1, "Willingness for %s changed from %d to %d - UPDATING\n", 
 		  olsr_ip_to_string(&neighbor->neighbor_main_addr),
 		  neighbor->willingness,
-		  message->willingness)
+		  message->willingness);
       /*
        *If willingness changed - recalculate
        */
@@ -231,7 +229,7 @@
     }
 
   OLSR_PRINTF(3, "Processing TC from %s\n",
-              olsr_ip_to_string(&message->originator))
+              olsr_ip_to_string(&message->originator));
 
   /*
    *      If the sender interface (NB: not originator) of this message
@@ -242,7 +240,7 @@
   if(check_neighbor_link(from_addr) != SYM_LINK)
     {
       OLSR_PRINTF(2, "Received TC from NON SYM neighbor %s\n",
-                  olsr_ip_to_string(from_addr))
+                  olsr_ip_to_string(from_addr));
       olsr_free_tc_packet(message);
       return;
     }
@@ -250,15 +248,15 @@
   if(olsr_cnf->debug_level > 2)
     {
       mpr = message->multipoint_relay_selector_address;
-      OLSR_PRINTF(3, "mpr_selector_list:[")
+      OLSR_PRINTF(3, "mpr_selector_list:[");
 
       while(mpr!=NULL)
         {
-          OLSR_PRINTF(3, "%s:", olsr_ip_to_string(&mpr->address))
+          OLSR_PRINTF(3, "%s:", olsr_ip_to_string(&mpr->address));
           mpr=mpr->next;
         }
 
-      OLSR_PRINTF(3, "]\n")
+      OLSR_PRINTF(3, "]\n");
     }
 
   tc_last = olsr_lookup_tc_entry(&message->originator);
@@ -296,7 +294,7 @@
       else
         {
           OLSR_PRINTF(3, "Dropping empty TC from %s\n",
-                      olsr_ip_to_string(&message->originator))
+                      olsr_ip_to_string(&message->originator));
         }
     }
 
@@ -374,7 +372,7 @@
     }
 
 #ifdef DEBUG
-  OLSR_PRINTF(5, "Processing MID from %s...\n", olsr_ip_to_string(&message.mid_origaddr))
+  OLSR_PRINTF(5, "Processing MID from %s...\n", olsr_ip_to_string(&message.mid_origaddr));
 #endif
   tmp_adr = message.mid_addr;
 
@@ -386,7 +384,7 @@
 
   if(check_neighbor_link(from_addr) != SYM_LINK)
     {
-      OLSR_PRINTF(2, "Received MID from NON SYM neighbor %s\n", olsr_ip_to_string(from_addr))
+      OLSR_PRINTF(2, "Received MID from NON SYM neighbor %s\n", olsr_ip_to_string(from_addr));
       olsr_free_mid_packet(&message);
       return;
     }
@@ -398,8 +396,8 @@
     {
       if(!mid_lookup_main_addr(&tmp_adr->alias_addr))
 	{
-	  OLSR_PRINTF(1, "MID new: (%s, ", olsr_ip_to_string(&message.mid_origaddr))
-	  OLSR_PRINTF(1, "%s)\n", olsr_ip_to_string(&tmp_adr->alias_addr))
+	  OLSR_PRINTF(1, "MID new: (%s, ", olsr_ip_to_string(&message.mid_origaddr));
+	  OLSR_PRINTF(1, "%s)\n", olsr_ip_to_string(&tmp_adr->alias_addr));
 	  insert_mid_alias(&message.mid_origaddr, &tmp_adr->alias_addr, (float)message.vtime);
 	}
 
@@ -440,7 +438,7 @@
   struct  hna_message message;
 
 #ifdef DEBUG
-  OLSR_PRINTF(5, "Processing HNA\n")
+  OLSR_PRINTF(5, "Processing HNA\n");
 #endif
 
   hna_chgestruct(&message, m);
@@ -466,7 +464,7 @@
    */
   if(check_neighbor_link(from_addr) != SYM_LINK)
     {
-      OLSR_PRINTF(2, "Received HNA from NON SYM neighbor %s\n", olsr_ip_to_string(from_addr))
+      OLSR_PRINTF(2, "Received HNA from NON SYM neighbor %s\n", olsr_ip_to_string(from_addr));
       olsr_free_hna_packet(&message);
       return;
     }
@@ -540,7 +538,7 @@
 	  struct neighbor_2_list_entry *two_hop_neighbor_yet =
             olsr_lookup_my_neighbors(neighbor, &message_neighbors->address);
 #ifdef DEBUG
-          OLSR_PRINTF(7, "\tProcessing %s\n", olsr_ip_to_string(&message_neighbors->address))
+          OLSR_PRINTF(7, "\tProcessing %s\n", olsr_ip_to_string(&message_neighbors->address));
 #endif
           if (two_hop_neighbor_yet != NULL)
             {
@@ -582,7 +580,7 @@
 #ifdef DEBUG
                   OLSR_PRINTF(5, 
 			      "Adding 2 hop neighbor %s\n\n", 
-			      olsr_ip_to_string(&message_neighbors->address))
+			      olsr_ip_to_string(&message_neighbors->address));
 #endif
                   changes_neighborhood = OLSR_TRUE;
                   changes_topology = OLSR_TRUE;
@@ -773,7 +771,7 @@
                           }
 
                           else
-                            OLSR_PRINTF(3, "Skipping Dijkstra (3)\n")
+                            OLSR_PRINTF(3, "Skipping Dijkstra (3)\n");
                         }
                     }
                 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/process_routes.c olsrd-current/src/process_routes.c
--- olsrd-0.5.0/src/process_routes.c	2007-01-31 13:36:50.000000000 +0100
+++ olsrd-current/src/process_routes.c	2007-05-14 00:23:55.000000000 +0200
@@ -39,7 +39,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: process_routes.c,v 1.30 2007/01/31 12:36:50 bernd67 Exp $
+ * $Id: process_routes.c,v 1.33 2007/05/13 22:23:55 bernd67 Exp $
  */
 
 #include "defs.h"
@@ -148,7 +148,7 @@
 }
 
 void 
-olsr_init_export_route() 
+olsr_init_export_route(void)
 {
   olsr_addroute_add_function(&olsr_ioctl_add_route, AF_INET);
   olsr_addroute_add_function(&olsr_ioctl_add_route6, AF_INET6);
@@ -211,7 +211,7 @@
 
 
 int
-olsr_init_old_table()
+olsr_init_old_table(void)
 {
   int index;
 
@@ -238,20 +238,16 @@
 int
 olsr_find_up_route(struct rt_entry *dst, struct rt_entry *table)
 { 
-  struct rt_entry *destination;
-  olsr_u32_t      hash;
- 
-  hash = olsr_hashing(&dst->rt_dst);
+  struct rt_entry  *destination;
+  const olsr_u32_t  hash = olsr_hashing(&dst->rt_dst);
 
-  for(destination = table[hash].next;
-      destination != &table[hash];
-      destination = destination->next)
+  for(destination = table[hash].next; destination != &table[hash]; destination = destination->next)
     {
       //printf("Checking %s hc: %d ", olsr_ip_to_string(&dst->rt_dst), dst->rt_metric);
       //printf("vs %s hc: %d ... ", olsr_ip_to_string(&destination->rt_dst), destination->rt_metric);      
       if (COMP_IP(&destination->rt_dst, &dst->rt_dst) &&
 	  COMP_IP(&destination->rt_router, &dst->rt_router) &&
-	  (destination->rt_if->if_nr == dst->rt_if->if_nr))
+	  (destination->rt_if->if_index == dst->rt_if->if_index))
 	{
 	  if(destination->rt_metric == dst->rt_metric)
 	    {
@@ -263,9 +259,7 @@
 	    }
 	}
     }
-
   return 0;
-
 }
 
 
@@ -318,42 +312,33 @@
  *@return 1
  */
 int
-olsr_delete_all_kernel_routes()
+olsr_delete_all_kernel_routes(void)
 { 
-  struct destination_n *delete_kernel_list = NULL;
-  struct destination_n *tmp = NULL;
-  union olsr_ip_addr *tmp_addr;
+  struct destination_n *delete_kernel_list;
+  struct destination_n *tmp;
 
-  OLSR_PRINTF(1, "Deleting all routes...\n")
+  OLSR_PRINTF(1, "Deleting all routes...\n");
 
   delete_kernel_list = olsr_build_update_list(hna_routes, old_hna);
 
-  tmp = delete_kernel_list;
-
-  OLSR_PRINTF(1, "HNA list:\n")
-  while(tmp)
+  OLSR_PRINTF(1, "HNA list:\n");
+  for(tmp = delete_kernel_list;tmp;tmp = tmp->next)
     {
-      tmp_addr = &tmp->destination->rt_dst;
-      OLSR_PRINTF(1, "Dest: %s\n", olsr_ip_to_string(tmp_addr))
-      tmp = tmp->next;
+      union olsr_ip_addr *tmp_addr = &tmp->destination->rt_dst;
+      OLSR_PRINTF(1, "Dest: %s\n", olsr_ip_to_string(tmp_addr));
     }
 
   olsr_delete_routes_from_kernel(delete_kernel_list);
 
   delete_kernel_list = olsr_build_update_list(routingtable,old_routes);
 
-  tmp = delete_kernel_list;
-
-  OLSR_PRINTF(1, "Route list:\n")
-  while(tmp)
+  OLSR_PRINTF(1, "Route list:\n");
+  for(tmp = delete_kernel_list;tmp;tmp = tmp->next)
     {
-      tmp_addr = &tmp->destination->rt_dst;
-      OLSR_PRINTF(1, "Dest: %s\n", olsr_ip_to_string(tmp_addr))
-      tmp = tmp->next;
+      union olsr_ip_addr *tmp_addr = &tmp->destination->rt_dst;
+      OLSR_PRINTF(1, "Dest: %s\n", olsr_ip_to_string(tmp_addr));
     }
-
   olsr_delete_routes_from_kernel(delete_kernel_list);
-
   return 1;
 }
 
@@ -365,12 +350,12 @@
  *@return nada
  */
 void
-olsr_update_kernel_routes()
+olsr_update_kernel_routes(void)
 {
-  struct destination_n *delete_kernel_list = NULL;
-  struct destination_n *add_kernel_list = NULL;
+  struct destination_n *delete_kernel_list;
+  struct destination_n *add_kernel_list;
 
-  OLSR_PRINTF(3, "Updating kernel routes...\n")
+  OLSR_PRINTF(3, "Updating kernel routes...\n");
   delete_kernel_list = olsr_build_update_list(old_routes, routingtable);
   add_kernel_list = olsr_build_update_list(routingtable, old_routes);
 
@@ -387,14 +372,12 @@
  *@return nada
  */
 void
-olsr_update_kernel_hna_routes()
+olsr_update_kernel_hna_routes(void)
 {
-  struct destination_n *delete_kernel_list = NULL;
-  //struct destination_n *delete_kernel_list2;
-  struct destination_n *add_kernel_list = NULL;
-
-  OLSR_PRINTF(3, "Updating kernel HNA routes...\n")
+  struct destination_n *delete_kernel_list;
+  struct destination_n *add_kernel_list;
 
+  OLSR_PRINTF(3, "Updating kernel HNA routes...\n");
 
   delete_kernel_list = olsr_build_update_list(old_hna, hna_routes);
   add_kernel_list = olsr_build_update_list(hna_routes, old_hna);
@@ -467,7 +450,7 @@
 
 #ifdef DEBUG
   OLSR_PRINTF(3, "%s highest metric %d\n",
-	      __func__, metric_counter)
+	      __func__, metric_counter);
 #endif
  
   while(delete_kernel_list!=NULL)
@@ -497,7 +480,7 @@
 #ifdef DEBUG
 		  OLSR_PRINTF(3, "Deleting route to %s hopcount %d\n",
 			      olsr_ip_to_string(&destination_ptr->destination->rt_dst),
-			      destination_ptr->destination->rt_metric)
+			      destination_ptr->destination->rt_metric);
 #endif
 		    if(!olsr_cnf->host_emul)
 		      {
@@ -508,8 +491,9 @@
 			
 			if(error < 0)
 			  {
-			    OLSR_PRINTF(1, "Delete route(%s):%s\n", olsr_ip_to_string(&destination_ptr->destination->rt_dst), strerror(errno))
-			      olsr_syslog(OLSR_LOG_ERR, "Delete route:%m");
+                            const char * const err_msg = strerror(errno);
+			    OLSR_PRINTF(1, "Delete route(%s):%s\n", olsr_ip_to_string(&destination_ptr->destination->rt_dst), err_msg);
+                            olsr_syslog(OLSR_LOG_ERR, "Delete route:%s", err_msg);
 			  }
 		    }
 		  
@@ -582,7 +566,7 @@
 #ifdef DEBUG
 	      OLSR_PRINTF(3, "Adding route to %s hopcount %d\n",
 			  olsr_ip_to_string(&destination_kernel->destination->rt_dst),
-			  destination_kernel->destination->rt_metric)
+			  destination_kernel->destination->rt_metric);
 #endif
 			  
 		if(!olsr_cnf->host_emul)
@@ -594,8 +578,9 @@
 		    
 		    if(error < 0)
 		      {
-			OLSR_PRINTF(1, "Add route(%s): %s\n", olsr_ip_to_string(&destination_kernel->destination->rt_dst), strerror(errno))
-			  olsr_syslog(OLSR_LOG_ERR, "Add route:%m");
+                        const char * const err_msg = strerror(errno);
+			OLSR_PRINTF(1, "Add route(%s): %s\n", olsr_ip_to_string(&destination_kernel->destination->rt_dst), err_msg);
+                        olsr_syslog(OLSR_LOG_ERR, "Add route:%s", err_msg);
 		      }
 		  }
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/rebuild_packet.c olsrd-current/src/rebuild_packet.c
--- olsrd-0.5.0/src/rebuild_packet.c	2005-05-28 18:01:14.000000000 +0200
+++ olsrd-current/src/rebuild_packet.c	2007-04-26 00:08:13.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: rebuild_packet.c,v 1.19 2005/05/28 16:01:14 kattemat Exp $
+ * $Id: rebuild_packet.c,v 1.21 2007/04/25 22:08:13 bernd67 Exp $
  */
 
 
@@ -230,15 +230,15 @@
       
       if(olsr_cnf->debug_level > 1)
 	{
-	  OLSR_PRINTF(3, "Alias list for %s: ", ip_to_string(&mmsg->mid_origaddr.v4))
-	  OLSR_PRINTF(3, "%s", ip_to_string(&mmsg->addr.v4))
+	  OLSR_PRINTF(3, "Alias list for %s: ", ip_to_string(&mmsg->mid_origaddr.v4));
+	  OLSR_PRINTF(3, "%s", ip_to_string(&mmsg->addr.v4));
 	  alias_tmp = mmsg->mid_addr;
 	  while(alias_tmp)
 	    {
-	      OLSR_PRINTF(3, " - %s", ip_to_string(&alias_tmp->alias_addr.v4))
+	      OLSR_PRINTF(3, " - %s", ip_to_string(&alias_tmp->alias_addr.v4));
 	      alias_tmp = alias_tmp->next;
 	    }
-	  OLSR_PRINTF(3, "\n")
+	  OLSR_PRINTF(3, "\n");
 	}
     }
   else
@@ -282,16 +282,16 @@
 
       if(olsr_cnf->debug_level > 1)
 	{
-	  OLSR_PRINTF(3, "Alias list for %s", ip6_to_string(&mmsg->mid_origaddr.v6))
-	  OLSR_PRINTF(3, "%s", ip6_to_string(&mmsg->addr.v6))
+	  OLSR_PRINTF(3, "Alias list for %s", ip6_to_string(&mmsg->mid_origaddr.v6));
+	  OLSR_PRINTF(3, "%s", ip6_to_string(&mmsg->addr.v6));
 
 	  alias_tmp = mmsg->mid_addr;
 	  while(alias_tmp)
 	    {
-	      OLSR_PRINTF(3, " - %s", ip6_to_string(&alias_tmp->alias_addr.v6))
+	      OLSR_PRINTF(3, " - %s", ip6_to_string(&alias_tmp->alias_addr.v6));
 	      alias_tmp = alias_tmp->next;
 	    }
-	  OLSR_PRINTF(3, "\n")
+	  OLSR_PRINTF(3, "\n");
 	}
     }
 
@@ -381,7 +381,7 @@
       /* Willingness */
       hmsg->willingness = m->v4.message.hello.willingness;
 
-      OLSR_PRINTF(3, "Got HELLO vtime: %f htime: %f\n", hmsg->vtime, hmsg->htime)
+      OLSR_PRINTF(3, "Got HELLO vtime: %f htime: %f\n", hmsg->vtime, hmsg->htime);
 
       for (hinf = m->v4.message.hello.hell_info; 
 	   (char *)hinf < ((char *)m + (ntohs(m->v4.olsr_msgsize))); 
@@ -425,7 +425,7 @@
       /* Willingness */
       hmsg->willingness = m->v6.message.hello.willingness;
 
-      OLSR_PRINTF(3, "Got HELLO vtime: %f htime: %f\n", hmsg->vtime, hmsg->htime)
+      OLSR_PRINTF(3, "Got HELLO vtime: %f htime: %f\n", hmsg->vtime, hmsg->htime);
 
 
       for (hinf6 = m->v6.message.hello.hell_info; 
@@ -479,7 +479,7 @@
   if(olsr_cnf->ip_version == AF_INET)
     {
       /* IPv4 */
-      struct tcmsg *tc;
+      struct olsr_tcmsg *tc;
       struct neigh_info *mprsaddr, *maddr;
 
       tc = &m->v4.message.tc;
@@ -498,7 +498,7 @@
       /* Get vtime */
       tmsg->vtime = ME_TO_DOUBLE(m->v4.olsr_vtime);
 
-      OLSR_PRINTF(3, "Got TC vtime: %f\n", tmsg->vtime)
+      OLSR_PRINTF(3, "Got TC vtime: %f\n", tmsg->vtime);
 
       COPY_IP(&tmsg->originator, &m->v4.originator);
       tmsg->packet_seq_number = ntohs(m->v4.seqno);
@@ -520,7 +520,7 @@
   else
     {
       /* IPv6 */
-      struct tcmsg6 *tc6;
+      struct olsr_tcmsg6 *tc6;
       struct neigh_info6 *mprsaddr6, *maddr6;
 
       tc6 = &m->v6.message.tc;
@@ -540,7 +540,7 @@
       /* Get vtime */
       tmsg->vtime = ME_TO_DOUBLE(m->v6.olsr_vtime);
 
-      OLSR_PRINTF(3, "Got TC vtime: %f\n", tmsg->vtime)
+      OLSR_PRINTF(3, "Got TC vtime: %f\n", tmsg->vtime);
 
       COPY_IP(&tmsg->originator, &m->v6.originator);
       tmsg->packet_seq_number = ntohs(m->v6.seqno);
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/routing_table.c olsrd-current/src/routing_table.c
--- olsrd-0.5.0/src/routing_table.c	2007-02-10 20:27:32.000000000 +0100
+++ olsrd-current/src/routing_table.c	2007-04-26 00:08:14.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: routing_table.c,v 1.25 2007/02/10 19:27:32 bernd67 Exp $
+ * $Id: routing_table.c,v 1.27 2007/04/25 22:08:14 bernd67 Exp $
  */
 
 
@@ -48,6 +48,7 @@
 #include "neighbor_table.h"
 #include "olsr.h"
 #include "link_set.h"
+#include "routing_table.h"
 
 
 struct rt_entry routingtable[HASHSIZE];
@@ -82,10 +83,9 @@
  *Initialize the routing table
  */
 int
-olsr_init_routing_table()
+olsr_init_routing_table(void)
 {
   int index;
-
   /*
    *The hna routes hash will almost always
    *be indexed to 0
@@ -116,9 +116,7 @@
 {
 
   struct rt_entry *rt_table;
-  olsr_u32_t      hash;
-
-  hash = olsr_hashing(dst);
+  olsr_u32_t      hash = olsr_hashing(dst);
 
   for(rt_table = routingtable[hash].next;
       rt_table != &routingtable[hash];
@@ -126,10 +124,10 @@
     {
       if (COMP_IP(&rt_table->rt_dst, dst))
 	{
-	  return(rt_table);
+	  return rt_table;
 	}
     }
-  return(NULL);
+  return NULL;
   
 }
 
@@ -249,23 +247,21 @@
  *@return
  */
 static int
-olsr_fill_routing_table_with_neighbors()
+olsr_fill_routing_table_with_neighbors(void)
 {
-  olsr_u8_t              index;
+  int index;
 
 #ifdef DEBUG
-  OLSR_PRINTF(7, "FILL ROUTING TABLE WITH NEIGHBORS\n")
+  OLSR_PRINTF(7, "FILL ROUTING TABLE WITH NEIGHBORS\n");
 #endif
 
   for(index=0;index<HASHSIZE;index++)
     {
       struct neighbor_entry *neighbor;
-
       for(neighbor = neighbortable[index].next;
 	  neighbor != &neighbortable[index];
 	  neighbor=neighbor->next)     
 	{
-
 	  if(neighbor->status == SYM)
 	    {
 	      static struct mid_address addrs;
@@ -277,13 +273,12 @@
 
 	      COPY_IP(&addrs.alias, &neighbor->neighbor_main_addr);
 	      addrs.next_alias = mid_lookup_aliases(&neighbor->neighbor_main_addr);
-	      addrs2 = &addrs;
 
-	      while(addrs2!=NULL)
+	      for(addrs2 = &addrs;addrs2!=NULL;addrs2 = addrs2->next_alias)
 		{
 		  struct link_entry *link = get_best_link_to_neighbor(&addrs2->alias);
 #ifdef DEBUG
-		  OLSR_PRINTF(7, "(ROUTE)Adding neighbor %s\n", olsr_ip_to_string(&addrs.alias))
+		  OLSR_PRINTF(7, "(ROUTE)Adding neighbor %s\n", olsr_ip_to_string(&addrs.alias));
 #endif
 		  if(link)
 		    {
@@ -298,14 +293,10 @@
 						    -1.0);
 			}
 		    }
-	      
-		  addrs2 = addrs2->next_alias;
 		}
 	    }
 	}
     }
-
-
   return 1;
 }
 
@@ -342,10 +333,10 @@
  */
 
 static struct destination_n *
-olsr_fill_routing_table_with_two_hop_neighbors()
+olsr_fill_routing_table_with_two_hop_neighbors(void)
 {
   struct destination_n *list_destination_n=NULL;
-  olsr_u8_t            index;
+  int            index;
 
   //printf("FILL ROUTING TABLE WITH TWO HOP NEIGHBORS\n");
 
@@ -378,7 +369,7 @@
 	      if(olsr_lookup_routing_table(n2_addr))
 		{
 #ifdef DEBUG
-		  OLSR_PRINTF(7, "2hop: %s already added\n", olsr_ip_to_string(n2_addr))
+		  OLSR_PRINTF(7, "2hop: %s already added\n", olsr_ip_to_string(n2_addr));
 #endif
 		  continue;
 		}	    
@@ -386,23 +377,22 @@
 	      if(!two_hop_neighbor_reachable(neigh_2_list))
 		{
 		  OLSR_PRINTF(1, "Two hop neighbor %s not added - no one hop neighbors.\n",
-			      olsr_ip_to_string(n2_addr))
+			      olsr_ip_to_string(n2_addr));
 		  continue;
 		}
 
 	      COPY_IP(&addrs.alias, n2_addr);
 	      addrs.next_alias = mid_lookup_aliases(n2_addr);
-	      addrsp = &addrs;
 
-	      while(addrsp!=NULL)
+	      for(addrsp = &addrs; addrsp; addrsp = addrsp->next_alias)
 		{
 		  struct link_entry *link = get_best_link_to_neighbor(&neighbor->neighbor_main_addr);
 #ifdef DEBUG
-		  OLSR_PRINTF(7, "(ROUTE)Adding neighbor %s\n", olsr_ip_to_string(&addrsp->alias))
+		  OLSR_PRINTF(7, "(ROUTE)Adding neighbor %s\n", olsr_ip_to_string(&addrsp->alias));
 #endif
 		  if(link)
 		    {
-		    struct interface *iface = link->if_name ? if_ifwithname(link->if_name) :
+                      struct interface *iface = link->if_name ? if_ifwithname(link->if_name) :
 		                                if_ifwithaddr(&link->local_iface_addr);
 		      if(iface)
 			{
@@ -415,47 +405,39 @@
 			  
 			  if(new_route_entry != NULL)
 			    {
-			      struct destination_n *list_destination_tmp;
-			      list_destination_tmp = olsr_malloc(sizeof(struct destination_n), 
-								 "Fill rt table 2 hop tmp");
-			      
-			      list_destination_tmp->destination = new_route_entry;
-			      list_destination_tmp->next = list_destination_n;
-			      list_destination_n = list_destination_tmp;
+			      struct destination_n *tmp = olsr_malloc(sizeof(struct destination_n), 
+                                                                      "Fill rt table 2 hop tmp");
+			      tmp->destination = new_route_entry;
+			      tmp->next = list_destination_n;
+			      list_destination_n = tmp;
 			    }
 			}
 		    }
-		  addrsp = addrsp->next_alias; 
 		}
 	    }
-	}
-      
+	}      
     }
-  
   return list_destination_n;
 }
 
-
-
-
 /**
  *Recalculate the routing table
  *
  *@return nada
  */
 void 
-olsr_calculate_routing_table()
+olsr_calculate_routing_table(void)
 {
-  struct destination_n *list_destination_n_1 = NULL;
+  struct destination_n *list_destination_n_1;
 
   olsr_move_route_table(routingtable, old_routes);
 
   /* Add neighbors */
   olsr_fill_routing_table_with_neighbors();
   /* Add two hop enighbors - now they are the "outer rim" */
+  
   list_destination_n_1 = olsr_fill_routing_table_with_two_hop_neighbors();
-
-  while(list_destination_n_1!=NULL)
+  while(list_destination_n_1)
     {
       /* List_destination_n_1 holds the "outer rim" */
       struct destination_n *list_destination_n = list_destination_n_1;
@@ -496,8 +478,8 @@
 			{
 			  /* PRINT OUT: Last Hop to Final Destination */
 			  /* The function ip_to_string has to be seperately */
-			  OLSR_PRINTF(3, "%s -> ", olsr_ip_to_string(&list_destination_n->destination->rt_dst))
-			  OLSR_PRINTF(3, "%s\n", olsr_ip_to_string(&tmp_addrsp->alias))
+			  OLSR_PRINTF(3, "%s -> ", olsr_ip_to_string(&list_destination_n->destination->rt_dst));
+			  OLSR_PRINTF(3, "%s\n", olsr_ip_to_string(&tmp_addrsp->alias));
 			  
 			  destination_n_1 = olsr_malloc(sizeof(struct destination_n), 
 							"Calculate routing table 2");
@@ -643,17 +625,16 @@
  *
  */
 void
-olsr_calculate_hna_routes()
+olsr_calculate_hna_routes(void)
 {
-  olsr_u32_t index;
+  int index;
 
 #ifdef DEBUG
-  OLSR_PRINTF(3, "Calculating HNA routes\n")
+  OLSR_PRINTF(3, "Calculating HNA routes\n");
 #endif
 
   olsr_move_route_table(hna_routes, old_hna);
 
-  
   for(index=0;index<HASHSIZE;index++)
     {
       struct hna_entry *tmp_hna;
@@ -674,15 +655,11 @@
 
 	      /* If no route to gateway - skip */
 	      if((tmp_rt = olsr_lookup_routing_table(&tmp_hna->A_gateway_addr)) == NULL)
-		{
 		  continue;
-		}
 
 	      /* If there exists a better or equal entry - skip */
 	      if(olsr_check_for_higher_quality(hna_routes, tmp_net, tmp_rt->rt_etx) != NULL)
-		{
 		  continue;
-		}
 
 	      /* If we find an entry with lower quality we just edit it */
 	      if((new_rt = olsr_check_for_lower_quality(hna_routes, tmp_net, tmp_rt->rt_etx)) != NULL)
@@ -739,12 +716,11 @@
 
   if(olsr_cnf->debug_level > 2)
     {
-      OLSR_PRINTF(3, "HNA table:\n")
+      OLSR_PRINTF(3, "HNA table:\n");
       olsr_print_routing_table(hna_routes);
     }
 
   olsr_free_routing_table(old_hna);
-
 }
 
 
@@ -759,12 +735,11 @@
 void
 olsr_print_routing_table(struct rt_entry *table)
 {
-
-  olsr_u8_t index;
+  int index;
 
   printf("ROUTING TABLE\n");
   printf("DESTINATION\tNEXT HOP\tHOPCNT\tINTERFACE\n");
-  for(index=0;index<HASHSIZE;index++)
+  for(index = 0; index < HASHSIZE; index++)
     {
       struct rt_entry *destination;
       for(destination = table[index].next;
@@ -779,8 +754,3 @@
 	}
     }
 }
-
-
-
-
-
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/scheduler.c olsrd-current/src/scheduler.c
--- olsrd-0.5.0/src/scheduler.c	2007-01-31 13:36:50.000000000 +0100
+++ olsrd-current/src/scheduler.c	2007-04-26 00:08:16.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: scheduler.c,v 1.37 2007/01/31 12:36:50 bernd67 Exp $
+ * $Id: scheduler.c,v 1.39 2007/04/25 22:08:16 bernd67 Exp $
  */
 
 
@@ -77,7 +77,7 @@
 }
 
 static void 
-trigger_dijkstra(void *dummy)
+trigger_dijkstra(void *foo __attribute__((unused)))
 {
   OLSR_PRINTF(3, "Triggering Dijkstra\n");
 
@@ -98,7 +98,7 @@
  */
 
 void
-scheduler()
+scheduler(void)
 {
   struct timespec remainder_spec;
   struct timespec sleeptime_spec;
@@ -132,13 +132,12 @@
   interval.tv_sec = interval_usec / 1000000;
   interval.tv_usec = interval_usec % 1000000;
 
-  OLSR_PRINTF(1, "Scheduler started - polling every %0.2f seconds\n", pollrate)
-  OLSR_PRINTF(3, "Max jitter is %f\n\n", olsr_cnf->max_jitter)
+  OLSR_PRINTF(1, "Scheduler started - polling every %0.2f seconds\n", pollrate);
+  OLSR_PRINTF(3, "Max jitter is %f\n\n", olsr_cnf->max_jitter);
 
   /* Main scheduler event loop */
   for(;;)
     {
-
       /* Update now_times */
       now_times = times(&tms_buf);
 
@@ -170,7 +169,7 @@
       /* Check for changes in topology */
       if(link_changes)
         {
-	  OLSR_PRINTF(3, "ANSN UPDATED %d\n\n", get_local_ansn())
+	  OLSR_PRINTF(3, "ANSN UPDATED %d\n\n", get_local_ansn());
 	  increase_local_ansn();
           link_changes = OLSR_FALSE;
 	}
@@ -201,7 +200,7 @@
 	      if(entry->trigger != NULL)
 		*(entry->trigger) = 0;
 	      
-	      //OLSR_PRINTF(3, "Since_last jitter: %0.2f\n", entry->since_last)
+	      //OLSR_PRINTF(3, "Since_last jitter: %0.2f\n", entry->since_last);
 
 	    }
 
@@ -278,7 +277,7 @@
 {
   struct event_entry *new_entry;
 
-  OLSR_PRINTF(3, "Scheduler event registered int: %0.2f\n", interval)
+  OLSR_PRINTF(3, "Scheduler event registered int: %0.2f\n", interval);
 
   /* check that this entry is not added already */
   new_entry = event_functions;
@@ -314,7 +313,7 @@
 
 /*
  *
- *@param initial how long utnil the first generation
+ *@param initial how long until the first generation
  *@param trigger pointer to a boolean indicating that
  *this function should be triggered immediatley
  */
@@ -322,7 +321,7 @@
 olsr_remove_scheduler_event(void (*event_function)(void *), 
 			    void *par,
 			    float interval, 
-			    float initial, 
+			    float initial __attribute__((unused)), 
 			    olsr_u8_t *trigger)
 {
   struct event_entry *entry, *prev;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/scheduler.h olsrd-current/src/scheduler.h
--- olsrd-0.5.0/src/scheduler.h	2006-01-07 09:16:20.000000000 +0100
+++ olsrd-current/src/scheduler.h	2007-04-20 15:46:04.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: scheduler.h,v 1.12 2006/01/07 08:16:20 kattemat Exp $
+ * $Id: scheduler.h,v 1.13 2007/04/20 13:46:04 bernd67 Exp $
  */
 
 
@@ -84,6 +84,6 @@
 olsr_remove_scheduler_event(void (*)(void *), void *, float, float, olsr_u8_t *);
 
 void
-scheduler(void);
+scheduler(void) __attribute__((noreturn));
 
 #endif
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/socket_parser.c olsrd-current/src/socket_parser.c
--- olsrd-0.5.0/src/socket_parser.c	2005-05-29 14:47:45.000000000 +0200
+++ olsrd-current/src/socket_parser.c	2007-05-09 01:43:17.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: socket_parser.c,v 1.23 2005/05/29 12:47:45 br1 Exp $
+ * $Id: socket_parser.c,v 1.27 2007/05/08 23:43:17 bernd67 Exp $
  */
 
 #include <unistd.h>
@@ -60,9 +60,6 @@
 
 static int hfd = 0;
 
-static struct timeval tvp = {0, 0};
-static fd_set ibits;
-
 /**
  * Add a socket and handler to the socketset
  * beeing used in the main select(2) loop
@@ -81,7 +78,7 @@
       fprintf(stderr, "Bogus socket entry - not registering...\n");
       return;
     }
-  OLSR_PRINTF(2, "Adding OLSR socket entry %d\n", fd)
+  OLSR_PRINTF(2, "Adding OLSR socket entry %d\n", fd);
 
   new_entry = olsr_malloc(sizeof(struct olsr_socket_entry), "Socket entry");
 
@@ -114,7 +111,7 @@
       olsr_syslog(OLSR_LOG_ERR, "Bogus socket entry - not processing...\n");
       return 0;
     }
-  OLSR_PRINTF(1, "Removing OLSR socket entry %d\n", fd)
+  OLSR_PRINTF(1, "Removing OLSR socket entry %d\n", fd);
 
   entry = olsr_socket_entries;
   prev_entry = NULL;
@@ -157,11 +154,15 @@
 
 
 void
-poll_sockets()
+poll_sockets(void)
 {
   int n;
   struct olsr_socket_entry *olsr_sockets;
-  static struct tms tms_buf;
+  /* Global buffer for times(2) calls. Do not remopve since at least OpenBSD needs it. */
+  struct tms tms_buf;
+  fd_set ibits;
+  struct timeval tvp = {0, 0};
+
 
   /* If there are no registered sockets we
    * do not call select(2)
@@ -172,11 +173,10 @@
   FD_ZERO(&ibits);
   
   /* Adding file-descriptors to FD set */
-  olsr_sockets = olsr_socket_entries;
-  while(olsr_sockets)
+  
+  for(olsr_sockets = olsr_socket_entries; olsr_sockets; olsr_sockets = olsr_sockets->next)
     {
-      FD_SET(olsr_sockets->fd, &ibits);
-      olsr_sockets = olsr_sockets->next;
+      FD_SET((unsigned int)olsr_sockets->fd, &ibits); /* And we cast here since we get a warning on Win32 */    
     }
       
   /* Runnig select on the FD set */
@@ -187,27 +187,22 @@
   /* Did somethig go wrong? */
   if (n < 0) 
     {
-      if(errno == EINTR)
-	return;
-
-      olsr_syslog(OLSR_LOG_ERR, "select: %m");
-      OLSR_PRINTF(1, "Error select: %s", strerror(errno))
+      if(errno != EINTR) {
+        const char * const err_msg = strerror(errno);
+        olsr_syslog(OLSR_LOG_ERR, "select: %s", err_msg);
+        OLSR_PRINTF(1, "Error select: %s", err_msg);
+      }
       return;
     }
 
   /* Update time since this is much used by the parsing functions */
-  gettimeofday(&now, NULL);      
+  gettimeofday(&now, NULL);
   now_times = times(&tms_buf);
 
-  olsr_sockets = olsr_socket_entries;
-  while(olsr_sockets)
+  for(olsr_sockets = olsr_socket_entries;olsr_sockets;olsr_sockets = olsr_sockets->next)
     {
       if(FD_ISSET(olsr_sockets->fd, &ibits))
-	{
 	  olsr_sockets->process_function(olsr_sockets->fd);
-	}
-      olsr_sockets = olsr_sockets->next;
-    }
-  	
+    }  	
 }
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/tc_set.c olsrd-current/src/tc_set.c
--- olsrd-0.5.0/src/tc_set.c	2006-01-07 09:16:20.000000000 +0100
+++ olsrd-current/src/tc_set.c	2007-04-26 00:08:17.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: tc_set.c,v 1.24 2006/01/07 08:16:20 kattemat Exp $
+ * $Id: tc_set.c,v 1.26 2007/04/25 22:08:17 bernd67 Exp $
  */
 
 
@@ -55,11 +55,10 @@
  */
 
 int
-olsr_init_tc()
+olsr_init_tc(void)
 {
   int index;
- 
-  OLSR_PRINTF(5, "TC: init topo\n")
+  OLSR_PRINTF(5, "TC: init topo\n");
 
   olsr_register_timeout_function(&olsr_time_out_tc_set);
 
@@ -86,7 +85,7 @@
 olsr_tc_delete_entry_if_empty(struct tc_entry *entry)
 {
 
-  //OLSR_PRINTF(1, "TC: del entry if empty\n")
+  //OLSR_PRINTF(1, "TC: del entry if empty\n");
 
   if(entry->destinations.next == &entry->destinations)
     {
@@ -94,7 +93,7 @@
       DEQUEUE_ELEM(entry);
       //entry->prev->next = entry->next;
       //entry->next->prev = entry->prev;
-      OLSR_PRINTF(1, "TC-SET: Deleting empty entry %s ->\n", olsr_ip_to_string(&entry->T_last_addr))
+      OLSR_PRINTF(1, "TC-SET: Deleting empty entry %s ->\n", olsr_ip_to_string(&entry->T_last_addr));
       free(entry);
       return 1;
     }
@@ -118,7 +117,7 @@
   struct tc_entry *entries;
   olsr_u32_t hash;
 
-  //OLSR_PRINTF(1, "TC: lookup entry\n")
+  //OLSR_PRINTF(1, "TC: lookup entry\n");
 
   hash = olsr_hashing(adr);
 
@@ -149,7 +148,7 @@
   struct tc_entry *new_entry;
   olsr_u32_t hash;
 
-  OLSR_PRINTF(1, "TC: adding entry %s\n", olsr_ip_to_string(adr))
+  OLSR_PRINTF(1, "TC: adding entry %s\n", olsr_ip_to_string(adr));
 
   hash = olsr_hashing(adr);
 
@@ -189,7 +188,7 @@
   struct topo_dst *tmp_dsts, *dst_to_del;
   int retval;
 
-  //OLSR_PRINTF(5, "TC: deleting MPRS\n")
+  //OLSR_PRINTF(5, "TC: deleting MPRS\n");
 
   tmp_dsts = entry->destinations.next;
   retval = 0;
@@ -235,7 +234,7 @@
   struct topo_dst *new_topo_dst, *existing_dst;
   int retval;
 
-  //OLSR_PRINTF(1, "TC: update MPRS\n")
+  //OLSR_PRINTF(1, "TC: update MPRS\n");
 
   retval = 0;
 
@@ -305,7 +304,7 @@
                     retval = 1;
 
                   else
-                    OLSR_PRINTF(3, "Skipping Dijkstra (4)\n")
+                    OLSR_PRINTF(3, "Skipping Dijkstra (4)\n");
                 }
 
               saved_lq = existing_dst->saved_inverse_link_quality;
@@ -326,7 +325,7 @@
                     retval = 1;
 
                   else
-                    OLSR_PRINTF(3, "Skipping Dijkstra (5)\n")
+                    OLSR_PRINTF(3, "Skipping Dijkstra (5)\n");
                 }
             }
 	}
@@ -352,7 +351,7 @@
 {
   struct topo_dst *dsts;
   
-  //OLSR_PRINTF(1, "TC: lookup dst\n")
+  //OLSR_PRINTF(1, "TC: lookup dst\n");
 
   for(dsts = entry->destinations.next; 
       dsts != &entry->destinations; 
@@ -364,11 +363,6 @@
   return NULL;
 }
 
-
-
-
-
-
 /**
  * Time out entries
  *
@@ -376,28 +370,27 @@
  */
 
 void
-olsr_time_out_tc_set()
+olsr_time_out_tc_set(void)
 {
-  int index, deleted;
-  struct tc_entry *entry, *entry2;
-  struct topo_dst *dst_entry, *dst_to_delete;
-
+  int index;
 
   for(index=0;index<HASHSIZE;index++)
     {
       /* For all TC entries */
-      entry = tc_table[index].next;
+      struct tc_entry *entry = tc_table[index].next;
       while(entry != &tc_table[index])
 	{
+          struct tc_entry *entry2;
 	  //printf("INDEX: %d\n", index);
 	  /* For all destination entries of that TC entry */
-	  deleted = 0;
-	  dst_entry = entry->destinations.next;
+	  int deleted = 0;
+	  struct topo_dst *dst_entry = entry->destinations.next;
 	  while(dst_entry != &entry->destinations)
 	    {
 	      /* If timed out - delete */
 	      if(TIMED_OUT(dst_entry->T_time))
 		{
+                  struct topo_dst *dst_to_delete;
 		  deleted = 1;
 		  /* Dequeue */
 		  DEQUEUE_ELEM(dst_entry);
@@ -420,8 +413,6 @@
 	    olsr_tc_delete_entry_if_empty(entry2);
 	}
     }
-
-  return;
 }
 
 
@@ -429,11 +420,9 @@
  *Print the topology table to stdout
  */
 int
-olsr_print_tc_table()
+olsr_print_tc_table(void)
 {
   int i;
-  struct tc_entry *entry;
-  struct topo_dst *dst_entry;
   char *fstr;
   float etx;
   
@@ -441,49 +430,39 @@
               nowtm->tm_hour,
               nowtm->tm_min,
               nowtm->tm_sec,
-              (int)now.tv_usec / 10000)
+              (int)now.tv_usec / 10000);
 
   if (olsr_cnf->ip_version == AF_INET)
-  {
-    OLSR_PRINTF(1, "Source IP addr   Dest IP addr     LQ     ILQ    ETX\n")
-    fstr = "%-15s  %-15s  %5.3f  %5.3f  %.2f\n";
-  }
-
+    {
+      OLSR_PRINTF(1, "Source IP addr   Dest IP addr     LQ     ILQ    ETX\n");
+      fstr = "%-15s  %-15s  %5.3f  %5.3f  %.2f\n";
+    }
   else
-  {
-    OLSR_PRINTF(1, "Source IP addr                Dest IP addr                    LQ     ILQ    ETX\n")
-    fstr = "%-30s%-30s  %5.3f  %5.3f  %.2f\n";
-  }
+    {
+      OLSR_PRINTF(1, "Source IP addr                Dest IP addr                    LQ     ILQ    ETX\n");
+      fstr = "%-30s%-30s  %5.3f  %5.3f  %.2f\n";
+    }
 
   for (i = 0; i < HASHSIZE; i++)
-  {
-    entry = tc_table[i].next;
-
-    while (entry != &tc_table[i])
     {
-      dst_entry = entry->destinations.next;
-
-      while(dst_entry != &entry->destinations)
-      {
-        if (dst_entry->link_quality < MIN_LINK_QUALITY ||
-            dst_entry->inverse_link_quality < MIN_LINK_QUALITY)
-          etx = 0.0;
-
-        else
-          etx = 1.0 / (dst_entry->link_quality *
-                       dst_entry->inverse_link_quality);
-
-        OLSR_PRINTF(1, fstr, olsr_ip_to_string(&entry->T_last_addr),
-                    olsr_ip_to_string(&dst_entry->T_dest_addr),
-                    dst_entry->link_quality, dst_entry->inverse_link_quality,
-                    etx)
-
-        dst_entry = dst_entry->next;
-      }
-
-      entry = entry->next;
+      struct tc_entry *entry;
+      for(entry = tc_table[i].next;entry != &tc_table[i];entry = entry->next)
+        {
+          struct topo_dst *dst_entry;
+          for(dst_entry = entry->destinations.next;dst_entry != &entry->destinations;dst_entry = dst_entry->next)
+            {
+              if (dst_entry->link_quality < MIN_LINK_QUALITY ||
+                  dst_entry->inverse_link_quality < MIN_LINK_QUALITY)
+                etx = 0.0;
+              else
+                etx = 1.0 / (dst_entry->link_quality * dst_entry->inverse_link_quality);
+
+              OLSR_PRINTF(1, fstr, olsr_ip_to_string(&entry->T_last_addr),
+                          olsr_ip_to_string(&dst_entry->T_dest_addr),
+                          dst_entry->link_quality, dst_entry->inverse_link_quality,
+                          etx);
+            }
+        }
     }
-  }
-
   return 1;
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/two_hop_neighbor_table.c olsrd-current/src/two_hop_neighbor_table.c
--- olsrd-0.5.0/src/two_hop_neighbor_table.c	2005-05-29 14:47:46.000000000 +0200
+++ olsrd-current/src/two_hop_neighbor_table.c	2007-04-26 00:08:17.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: two_hop_neighbor_table.c,v 1.16 2005/05/29 12:47:46 br1 Exp $
+ * $Id: two_hop_neighbor_table.c,v 1.18 2007/04/25 22:08:17 bernd67 Exp $
  */
 
 
@@ -54,7 +54,7 @@
  *Initialize 2 hop neighbor table
  */
 int
-olsr_init_two_hop_table()
+olsr_init_two_hop_table(void)
 {
   int index;
 
@@ -242,7 +242,7 @@
  *@return nada
  */
 void
-olsr_print_two_hop_neighbor_table()
+olsr_print_two_hop_neighbor_table(void)
 {
   int i;
 
@@ -250,9 +250,9 @@
               nowtm->tm_hour,
               nowtm->tm_min,
               nowtm->tm_sec,
-              (int)now.tv_usec)
+              (int)now.tv_usec);
 
-  OLSR_PRINTF(1, "IP addr (2-hop)  IP addr (1-hop)  TLQ\n")
+  OLSR_PRINTF(1, "IP addr (2-hop)  IP addr (1-hop)  TLQ\n");
 
   for (i = 0; i < HASHSIZE; i++)
     {
@@ -272,18 +272,18 @@
               if (first)
                 {
                   OLSR_PRINTF(1, "%-15s  ",
-                              olsr_ip_to_string(&neigh2->neighbor_2_addr))
+                              olsr_ip_to_string(&neigh2->neighbor_2_addr));
                   first = OLSR_FALSE;
                 }
 
               else
-                OLSR_PRINTF(1, "                 ")
+                OLSR_PRINTF(1, "                 ");
 
               total_lq = entry->path_link_quality;
 
               OLSR_PRINTF(1, "%-15s  %5.3f\n",
                           olsr_ip_to_string(&neigh->neighbor_main_addr),
-                          total_lq)
+                          total_lq);
             }
 	}
     }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/unix/ifnet.c olsrd-current/src/unix/ifnet.c
--- olsrd-0.5.0/src/unix/ifnet.c	2007-03-14 15:01:14.000000000 +0100
+++ olsrd-current/src/unix/ifnet.c	2007-05-14 00:23:55.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: ifnet.c,v 1.46 2007/03/14 14:01:14 bernd67 Exp $
+ * $Id: ifnet.c,v 1.49 2007/05/13 22:23:55 bernd67 Exp $
  */
 
 
@@ -72,7 +72,7 @@
 
 
 int
-set_flag(char *ifname, short flag)
+set_flag(char *ifname, short flag __attribute__((unused)))
 {
   struct ifreq ifr;
 
@@ -108,12 +108,12 @@
 
 
 void
-check_interface_updates(void *foo)
+check_interface_updates(void *foo __attribute__((unused)))
 {
   struct olsr_if *tmp_if;
 
 #ifdef DEBUG
-  OLSR_PRINTF(3, "Checking for updates in the interface set\n")
+  OLSR_PRINTF(3, "Checking for updates in the interface set\n");
 #endif
 
   for(tmp_if = olsr_cnf->interfaces; tmp_if != NULL; tmp_if = tmp_if->next)
@@ -163,7 +163,7 @@
   if_changes = 0;
 
 #ifdef DEBUG
-  OLSR_PRINTF(3, "Checking if %s is set down or changed\n", iface->name)
+  OLSR_PRINTF(3, "Checking if %s is set down or changed\n", iface->name);
 #endif
 
   if(iface->host_emul)
@@ -185,7 +185,7 @@
   /* Get flags (and check if interface exists) */
   if (ioctl(olsr_cnf->ioctl_s, SIOCGIFFLAGS, &ifr) < 0) 
     {
-      OLSR_PRINTF(3, "No such interface: %s\n", iface->name)
+      OLSR_PRINTF(3, "No such interface: %s\n", iface->name);
       goto remove_interface;
     }
 
@@ -197,7 +197,7 @@
 
   if ((ifp->int_flags & IFF_UP) == 0)
     {
-      OLSR_PRINTF(1, "\tInterface %s not up - removing it...\n", iface->name)
+      OLSR_PRINTF(1, "\tInterface %s not up - removing it...\n", iface->name);
       goto remove_interface;
     }
 
@@ -212,13 +212,13 @@
       !iface->cnf->ipv4_broadcast.v4 && /* Skip if fixed bcast */ 
       (!(ifp->int_flags & IFF_BROADCAST))) 
     {
-      OLSR_PRINTF(3, "\tNo broadcast - removing\n")
+      OLSR_PRINTF(3, "\tNo broadcast - removing\n");
       goto remove_interface;
     }
 
   if (ifp->int_flags & IFF_LOOPBACK)
     {
-      OLSR_PRINTF(3, "\tThis is a loopback interface - removing it...\n")
+      OLSR_PRINTF(3, "\tThis is a loopback interface - removing it...\n");
       goto remove_interface;
     }
 
@@ -265,23 +265,23 @@
       if(get_ipv6_address(ifr.ifr_name, &tmp_saddr6, iface->cnf->ipv6_addrtype) <= 0)
 	{
 	  if(iface->cnf->ipv6_addrtype == IPV6_ADDR_SITELOCAL)
-	    OLSR_PRINTF(3, "\tCould not find site-local IPv6 address for %s\n", ifr.ifr_name)
+	    OLSR_PRINTF(3, "\tCould not find site-local IPv6 address for %s\n", ifr.ifr_name);
 	  else
-	    OLSR_PRINTF(3, "\tCould not find global IPv6 address for %s\n", ifr.ifr_name)
+	    OLSR_PRINTF(3, "\tCould not find global IPv6 address for %s\n", ifr.ifr_name);
 	  
 	  
 	  goto remove_interface;
 	}
       
 #ifdef DEBUG
-      OLSR_PRINTF(3, "\tAddress: %s\n", ip6_to_string(&tmp_saddr6.sin6_addr))
+      OLSR_PRINTF(3, "\tAddress: %s\n", ip6_to_string(&tmp_saddr6.sin6_addr));
 #endif
 
       if(memcmp(&tmp_saddr6.sin6_addr, &ifp->int6_addr.sin6_addr, olsr_cnf->ipsize) != 0)
 	{
-	  OLSR_PRINTF(1, "New IP address for %s:\n", ifr.ifr_name)
-	  OLSR_PRINTF(1, "\tOld: %s\n", ip6_to_string(&ifp->int6_addr.sin6_addr))
-	  OLSR_PRINTF(1, "\tNew: %s\n", ip6_to_string(&tmp_saddr6.sin6_addr))
+	  OLSR_PRINTF(1, "New IP address for %s:\n", ifr.ifr_name);
+	  OLSR_PRINTF(1, "\tOld: %s\n", ip6_to_string(&ifp->int6_addr.sin6_addr));
+	  OLSR_PRINTF(1, "\tNew: %s\n", ip6_to_string(&tmp_saddr6.sin6_addr));
 
 	  /* Check main addr */
 	  if(memcmp(&olsr_cnf->main_addr, &tmp_saddr6.sin6_addr, olsr_cnf->ipsize) == 0)
@@ -307,12 +307,12 @@
       /* 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")
+	  OLSR_PRINTF(1, "\tCould not get address of interface - removing it\n");
 	  goto remove_interface;
 	}
 
 #ifdef DEBUG
-      OLSR_PRINTF(3, "\tAddress:%s\n", sockaddr_to_string(&ifr.ifr_addr))
+      OLSR_PRINTF(3, "\tAddress:%s\n", sockaddr_to_string(&ifr.ifr_addr));
 #endif
 
       if(memcmp(&((struct sockaddr_in *)&ifp->int_addr)->sin_addr.s_addr,
@@ -320,9 +320,9 @@
 		olsr_cnf->ipsize) != 0)
 	{
 	  /* New address */
-	  OLSR_PRINTF(1, "IPv4 address changed for %s\n", ifr.ifr_name)
-	  OLSR_PRINTF(1, "\tOld:%s\n", sockaddr_to_string(&ifp->int_addr))
-	  OLSR_PRINTF(1, "\tNew:%s\n", sockaddr_to_string(&ifr.ifr_addr))
+	  OLSR_PRINTF(1, "IPv4 address changed for %s\n", ifr.ifr_name);
+	  OLSR_PRINTF(1, "\tOld:%s\n", sockaddr_to_string(&ifp->int_addr));
+	  OLSR_PRINTF(1, "\tNew:%s\n", sockaddr_to_string(&ifr.ifr_addr));
 
 	  ifp->int_addr = ifr.ifr_addr;
 
@@ -330,7 +330,7 @@
 		    &ifp->ip_addr,
 		    olsr_cnf->ipsize) == 0)
 	    {
-	      OLSR_PRINTF(1, "New main address: %s\n", sockaddr_to_string(&ifr.ifr_addr))
+	      OLSR_PRINTF(1, "New main address: %s\n", sockaddr_to_string(&ifr.ifr_addr));
 	      olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", sockaddr_to_string(&ifr.ifr_addr));
 	      memcpy(&olsr_cnf->main_addr, 
 		     &((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr, 
@@ -352,7 +352,7 @@
 	}
 
 #ifdef DEBUG
-      OLSR_PRINTF(3, "\tNetmask:%s\n", sockaddr_to_string(&ifr.ifr_netmask))
+      OLSR_PRINTF(3, "\tNetmask:%s\n", sockaddr_to_string(&ifr.ifr_netmask));
 #endif
 
       if(memcmp(&((struct sockaddr_in *)&ifp->int_netmask)->sin_addr.s_addr,
@@ -360,9 +360,9 @@
 		olsr_cnf->ipsize) != 0)
 	{
 	  /* New address */
-	  OLSR_PRINTF(1, "IPv4 netmask changed for %s\n", ifr.ifr_name)
-	  OLSR_PRINTF(1, "\tOld:%s\n", sockaddr_to_string(&ifp->int_netmask))
-	  OLSR_PRINTF(1, "\tNew:%s\n", sockaddr_to_string(&ifr.ifr_netmask))
+	  OLSR_PRINTF(1, "IPv4 netmask changed for %s\n", ifr.ifr_name);
+	  OLSR_PRINTF(1, "\tOld:%s\n", sockaddr_to_string(&ifp->int_netmask));
+	  OLSR_PRINTF(1, "\tNew:%s\n", sockaddr_to_string(&ifr.ifr_netmask));
 
 	  ifp->int_netmask = ifr.ifr_netmask;
 
@@ -379,7 +379,7 @@
 	    }
 	  
 #ifdef DEBUG
-	  OLSR_PRINTF(3, "\tBroadcast address:%s\n", sockaddr_to_string(&ifr.ifr_broadaddr))
+	  OLSR_PRINTF(3, "\tBroadcast address:%s\n", sockaddr_to_string(&ifr.ifr_broadaddr));
 #endif
 	  
 	  if(memcmp(&((struct sockaddr_in *)&ifp->int_broadaddr)->sin_addr.s_addr,
@@ -388,9 +388,9 @@
 	    {
 	      
 	      /* New address */
-	      OLSR_PRINTF(1, "IPv4 broadcast changed for %s\n", ifr.ifr_name)
-	      OLSR_PRINTF(1, "\tOld:%s\n", sockaddr_to_string(&ifp->int_broadaddr))
-	      OLSR_PRINTF(1, "\tNew:%s\n", sockaddr_to_string(&ifr.ifr_broadaddr))
+	      OLSR_PRINTF(1, "IPv4 broadcast changed for %s\n", ifr.ifr_name);
+	      OLSR_PRINTF(1, "\tOld:%s\n", sockaddr_to_string(&ifp->int_broadaddr));
+	      OLSR_PRINTF(1, "\tNew:%s\n", sockaddr_to_string(&ifr.ifr_broadaddr));
 	      
 	      ifp->int_broadaddr = ifr.ifr_broadaddr;
 	      if_changes = 1;
@@ -405,7 +405,7 @@
 
 
  remove_interface:
-  OLSR_PRINTF(1, "Removing interface %s\n", iface->name)
+  OLSR_PRINTF(1, "Removing interface %s\n", iface->name);
   olsr_syslog(OLSR_LOG_INFO, "Removing interface %s\n", iface->name);
 
   del_if_link_entries(&ifp->ip_addr);
@@ -441,12 +441,12 @@
 	{
 	  /* No more interfaces */
 	  memset(&olsr_cnf->main_addr, 0, olsr_cnf->ipsize);
-	  OLSR_PRINTF(1, "No more interfaces...\n")
+	  OLSR_PRINTF(1, "No more interfaces...\n");
 	}
       else
 	{
 	  COPY_IP(&olsr_cnf->main_addr, &ifnet->ip_addr);
-	  OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr))
+	  OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
 	  olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
 	}
     }
@@ -509,7 +509,7 @@
 
   if((ifnet == NULL) && (!olsr_cnf->allow_no_interfaces))
     {
-      OLSR_PRINTF(1, "No more active interfaces - exiting.\n")
+      OLSR_PRINTF(1, "No more active interfaces - exiting.\n");
       olsr_syslog(OLSR_LOG_INFO, "No more active interfaces - exiting.\n");
       olsr_cnf->exit_value = EXIT_FAILURE;
       kill(getpid(), SIGINT);
@@ -546,12 +546,10 @@
 
   strcpy(ifp->int_name, "hcif01");
 
-  OLSR_PRINTF(1, "Adding %s(host emulation):\n", ifp->int_name)
+  OLSR_PRINTF(1, "Adding %s(host emulation):\n", ifp->int_name);
 
   OLSR_PRINTF(1, "       Address:%s\n", olsr_ip_to_string(&iface->hemu_ip));
 
-  OLSR_PRINTF(1, "       Index:%d\n", iface->index);
-
   OLSR_PRINTF(1, "       NB! This is a emulated interface\n       that does not exist in the kernel!\n");
 
   ifp->int_next = ifnet;
@@ -561,13 +559,10 @@
   if(COMP_IP(&null_addr, &olsr_cnf->main_addr))
     {
       COPY_IP(&olsr_cnf->main_addr, &iface->hemu_ip);
-      OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr))
+      OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
 	olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
     }
 
-  /* setting the interfaces number*/
-  ifp->if_nr = iface->index;
-
   ifp->int_mtu = OLSR_DEFAULT_MTU;
 
   ifp->int_mtu -= (olsr_cnf->ip_version == AF_INET6) ? UDP_IPV6_HDRSIZE : UDP_IPV4_HDRSIZE;
@@ -745,12 +740,12 @@
   memset(&ifr, 0, sizeof(struct ifreq));
   strncpy(ifr.ifr_name, iface->name, IFNAMSIZ);
 
-  OLSR_PRINTF(debuglvl, "Checking %s:\n", ifr.ifr_name)
+  OLSR_PRINTF(debuglvl, "Checking %s:\n", ifr.ifr_name);
 
   /* Get flags (and check if interface exists) */
   if (ioctl(olsr_cnf->ioctl_s, SIOCGIFFLAGS, &ifr) < 0) 
     {
-      OLSR_PRINTF(debuglvl, "\tNo such interface!\n")
+      OLSR_PRINTF(debuglvl, "\tNo such interface!\n");
       return 0;
     }
 
@@ -760,7 +755,7 @@
 
   if ((ifs.int_flags & IFF_UP) == 0)
     {
-      OLSR_PRINTF(debuglvl, "\tInterface not up - skipping it...\n")
+      OLSR_PRINTF(debuglvl, "\tInterface not up - skipping it...\n");
       return 0;
     }
 
@@ -769,14 +764,14 @@
       !iface->cnf->ipv4_broadcast.v4 && /* Skip if fixed bcast */ 
       (!(ifs.int_flags & IFF_BROADCAST))) 
     {
-      OLSR_PRINTF(debuglvl, "\tNo broadcast - skipping\n")
+      OLSR_PRINTF(debuglvl, "\tNo broadcast - skipping\n");
       return 0;
     }
 
 
   if (ifs.int_flags & IFF_LOOPBACK)
     {
-      OLSR_PRINTF(debuglvl, "\tThis is a loopback interface - skipping it...\n")
+      OLSR_PRINTF(debuglvl, "\tThis is a loopback interface - skipping it...\n");
       return 0;
     }
 
@@ -786,9 +781,9 @@
   ifs.is_wireless = check_wireless_interface(ifr.ifr_name);
 
   if(ifs.is_wireless)
-    OLSR_PRINTF(debuglvl, "\tWireless interface detected\n")
+    OLSR_PRINTF(debuglvl, "\tWireless interface detected\n");
   else
-    OLSR_PRINTF(debuglvl, "\tNot a wireless interface\n")
+    OLSR_PRINTF(debuglvl, "\tNot a wireless interface\n");
 
   
   /* IP version 6 */
@@ -799,14 +794,14 @@
       if(get_ipv6_address(ifr.ifr_name, &ifs.int6_addr, iface->cnf->ipv6_addrtype) <= 0)
 	{
 	  if(iface->cnf->ipv6_addrtype == IPV6_ADDR_SITELOCAL)
-	    OLSR_PRINTF(debuglvl, "\tCould not find site-local IPv6 address for %s\n", ifr.ifr_name)
+	    OLSR_PRINTF(debuglvl, "\tCould not find site-local IPv6 address for %s\n", ifr.ifr_name);
 	  else
-	    OLSR_PRINTF(debuglvl, "\tCould not find global IPv6 address for %s\n", ifr.ifr_name)
+	    OLSR_PRINTF(debuglvl, "\tCould not find global IPv6 address for %s\n", ifr.ifr_name);
 	  
 	  return 0;
 	}
       
-      OLSR_PRINTF(debuglvl, "\tAddress: %s\n", ip6_to_string(&ifs.int6_addr.sin6_addr))
+      OLSR_PRINTF(debuglvl, "\tAddress: %s\n", ip6_to_string(&ifs.int6_addr.sin6_addr));
       
       /* Multicast */
       ifs.int6_multaddr.sin6_addr = (iface->cnf->ipv6_addrtype == IPV6_ADDR_SITELOCAL) ? 
@@ -821,7 +816,7 @@
       ifs.int6_multaddr.sin6_scope_id = 0;
 #endif
 
-      OLSR_PRINTF(debuglvl, "\tMulticast: %s\n", ip6_to_string(&ifs.int6_multaddr.sin6_addr))
+      OLSR_PRINTF(debuglvl, "\tMulticast: %s\n", ip6_to_string(&ifs.int6_multaddr.sin6_addr));
       
     }
   /* IP version 4 */
@@ -830,7 +825,7 @@
       /* Get interface address (IPv4)*/
       if(ioctl(olsr_cnf->ioctl_s, SIOCGIFADDR, &ifr) < 0) 
 	{
-	  OLSR_PRINTF(debuglvl, "\tCould not get address of interface - skipping it\n")
+	  OLSR_PRINTF(debuglvl, "\tCould not get address of interface - skipping it\n");
 	  return 0;
 	}
       
@@ -885,11 +880,7 @@
     ifs.int_metric = iface->cnf->weight.value;
   else
     ifs.int_metric = calculate_if_metric(ifr.ifr_name);
-  OLSR_PRINTF(1, "\tMetric: %d\n", ifs.int_metric)
-
-  /* setting the interfaces number*/
-  ifs.if_nr = iface->index;
-
+  OLSR_PRINTF(1, "\tMetric: %d\n", ifs.int_metric);
 
   /* Get MTU */
   if (ioctl(olsr_cnf->ioctl_s, SIOCGIFMTU, &ifr) < 0)
@@ -904,21 +895,21 @@
   /* Set up buffer */
   net_add_buffer(&ifs);
 	       
-  OLSR_PRINTF(1, "\tMTU - IPhdr: %d\n", ifs.int_mtu)
+  OLSR_PRINTF(1, "\tMTU - IPhdr: %d\n", ifs.int_mtu);
 
   olsr_syslog(OLSR_LOG_INFO, "Adding interface %s\n", iface->name);
-  OLSR_PRINTF(1, "\tIndex %d\n", ifs.if_nr)
+  OLSR_PRINTF(1, "\tIndex %d\n", ifs.if_index);
 
   if(olsr_cnf->ip_version == AF_INET)
     {
-      OLSR_PRINTF(1, "\tAddress:%s\n", sockaddr_to_string(&ifs.int_addr))
-      OLSR_PRINTF(1, "\tNetmask:%s\n", sockaddr_to_string(&ifs.int_netmask))
-      OLSR_PRINTF(1, "\tBroadcast address:%s\n", sockaddr_to_string(&ifs.int_broadaddr))
+      OLSR_PRINTF(1, "\tAddress:%s\n", sockaddr_to_string(&ifs.int_addr));
+      OLSR_PRINTF(1, "\tNetmask:%s\n", sockaddr_to_string(&ifs.int_netmask));
+      OLSR_PRINTF(1, "\tBroadcast address:%s\n", sockaddr_to_string(&ifs.int_broadaddr));
     }
   else
     {
-      OLSR_PRINTF(1, "\tAddress: %s\n", ip6_to_string(&ifs.int6_addr.sin6_addr))
-      OLSR_PRINTF(1, "\tMulticast: %s\n", ip6_to_string(&ifs.int6_multaddr.sin6_addr))
+      OLSR_PRINTF(1, "\tAddress: %s\n", ip6_to_string(&ifs.int6_addr.sin6_addr));
+      OLSR_PRINTF(1, "\tMulticast: %s\n", ip6_to_string(&ifs.int6_multaddr.sin6_addr));
     }
   
   ifp = olsr_malloc(sizeof (struct interface), "Interface update 2");
@@ -1015,7 +1006,7 @@
   if(COMP_IP(&null_addr, &olsr_cnf->main_addr))
     {
       COPY_IP(&olsr_cnf->main_addr, &ifp->ip_addr);
-      OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr))
+      OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
       olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
     }
   
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/win32/apm.c olsrd-current/src/win32/apm.c
--- olsrd-0.5.0/src/win32/apm.c	2005-03-21 03:17:36.000000000 +0100
+++ olsrd-current/src/win32/apm.c	2007-04-26 00:19:00.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: apm.c,v 1.10 2005/03/21 02:17:36 tlopatic Exp $
+ * $Id: apm.c,v 1.12 2007/04/25 22:19:00 bernd67 Exp $
  */
 
 #include "apm.h"
@@ -48,11 +48,11 @@
 #include <windows.h>
 #undef interface
 
-int apm_init()
+int apm_init(void)
 {
   struct olsr_apm_info ApmInfo;
 
-  OLSR_PRINTF(3, "Initializing APM\n")
+  OLSR_PRINTF(3, "Initializing APM\n");
 
   if(apm_read(&ApmInfo) < 0)
     return -1;
@@ -66,7 +66,7 @@
 {
   OLSR_PRINTF(5, "APM info:\n\tAC status %d\n\tBattery percentage %d%%\n\n",
 	      ApmInfo->ac_line_status,
-	      ApmInfo->battery_percentage)
+	      ApmInfo->battery_percentage);
 }
 
 int apm_read(struct olsr_apm_info *ApmInfo)
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/win32/arpa/inet.h olsrd-current/src/win32/arpa/inet.h
--- olsrd-0.5.0/src/win32/arpa/inet.h	2004-11-21 02:21:10.000000000 +0100
+++ olsrd-current/src/win32/arpa/inet.h	2007-05-09 01:18:56.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: inet.h,v 1.6 2004/11/21 01:21:10 tlopatic Exp $
+ * $Id: inet.h,v 1.7 2007/05/08 23:18:56 bernd67 Exp $
  */
 
 #if !defined TL_ARPA_INET_H_INCLUDED
@@ -49,7 +49,7 @@
 #undef interface
 
 int inet_aton(char *cp, struct in_addr *addr);
-int inet_pton(int af, char *src, void *dst);
-char *inet_ntop(int af, void *src, char *dst, int size);
+int inet_pton(int af, const char *src, void *dst);
+char *inet_ntop(int af, const void *src, char *dst, int size);
 
 #endif
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/win32/compat.c olsrd-current/src/win32/compat.c
--- olsrd-0.5.0/src/win32/compat.c	2005-03-21 03:17:36.000000000 +0100
+++ olsrd-current/src/win32/compat.c	2007-05-09 02:30:04.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: compat.c,v 1.12 2005/03/21 02:17:36 tlopatic Exp $
+ * $Id: compat.c,v 1.15 2007/05/09 00:30:04 bernd67 Exp $
  */
 
 /*
@@ -100,7 +100,7 @@
   return 0;
 }
 
-void gettimeofday(struct timeval *TVal, void *TZone)
+void gettimeofday(struct timeval *TVal, void *TZone __attribute__((unused)))
 {
   SYSTEMTIME SysTime;
   FILETIME FileTime;
@@ -118,7 +118,7 @@
   TVal->tv_usec = (unsigned int)(Ticks % 10000000) / 10;
 }
 
-long times(struct tms *Dummy)
+long times(struct tms *Dummy __attribute__((unused)))
 {
   return (long)GetTickCount();
 }
@@ -165,7 +165,7 @@
 
 // XXX - not thread-safe, which is okay for our purposes
  
-void *dlopen(char *Name, int Flags)
+void *dlopen(char *Name, int Flags __attribute__((unused)))
 {
 #if !defined WINCE
   return (void *)LoadLibrary(Name);
@@ -363,7 +363,7 @@
   return (1);
 }
 
-int inet_pton(int af, char *src, void *dst)
+int inet_pton(int af, const char *src, void *dst)
 {
   switch (af)
   {
@@ -477,7 +477,7 @@
   return strcpy(dst, tmp);
 }
 
-char *inet_ntop(int af, void *src, char *dst, int size)
+char *inet_ntop(int af, const void *src, char *dst, int size)
 {
   switch (af)
   {
@@ -522,3 +522,19 @@
   return 0;
 #endif
 }
+
+#define CHUNK_SIZE 512
+
+/* and we emulate a real write(2) syscall using send() */
+ssize_t write(int fd, const void *buf, size_t count)
+{
+  size_t written = 0;
+  while (written < count) {
+    ssize_t rc = send(fd, buf+written, min(count-written, CHUNK_SIZE), 0);
+    if (rc <= 0) {
+      break;
+    }
+    written += rc;
+  }
+  return written;
+}
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/win32/ifnet.c olsrd-current/src/win32/ifnet.c
--- olsrd-0.5.0/src/win32/ifnet.c	2007-03-29 18:34:39.000000000 +0200
+++ olsrd-current/src/win32/ifnet.c	2007-05-14 00:23:55.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: ifnet.c,v 1.34 2007/03/29 16:34:39 tlopatic Exp $
+ * $Id: ifnet.c,v 1.38 2007/05/13 22:23:55 bernd67 Exp $
  */
 
 #include "interfaces.h"
@@ -113,7 +113,6 @@
 
 void WinSockPError(char *);
 char *StrError(unsigned int ErrNo);
-int inet_pton(int af, char *src, void *dst);
 
 void ListInterfaces(void);
 int GetIntInfo(struct InterfaceInfo *Info, char *Name);
@@ -123,7 +122,7 @@
 
 int __stdcall SignalHandler(unsigned long Signal);
 
-static unsigned long __stdcall SignalHandlerWrapper(void *Dummy)
+static unsigned long __stdcall SignalHandlerWrapper(void *Dummy __attribute__((unused)))
 {
   SignalHandler(0);
   return 0;
@@ -246,6 +245,7 @@
   IP_ADAPTER_INFO AdInfo[MAX_INTERFACES], *Walker;
   HMODULE Lib;
   struct MibIpInterfaceRow Row;
+  GETIPINTERFACEENTRY InterfaceEntry;
 
   if (olsr_cnf->ip_version == AF_INET6)
   {
@@ -312,8 +312,7 @@
     return -1;
   }
 
-  GETIPINTERFACEENTRY InterfaceEntry =
-    (GETIPINTERFACEENTRY)GetProcAddress(Lib, "GetIpInterfaceEntry");
+  InterfaceEntry = (GETIPINTERFACEENTRY)GetProcAddress(Lib, "GetIpInterfaceEntry");
 
   if (InterfaceEntry == NULL)
   {
@@ -444,11 +443,11 @@
 
     if (ErrNo == ERROR_GEN_FAILURE || ErrNo == ERROR_INVALID_PARAMETER)
     {
-      OLSR_PRINTF(5, "OID not supported. Device probably not wireless.\n")
+      OLSR_PRINTF(5, "OID not supported. Device probably not wireless.\n");
       return 0;
     }
 
-    OLSR_PRINTF(5, "DeviceIoControl() = %08x, %s\n", ErrNo, StrError(ErrNo))
+    OLSR_PRINTF(5, "DeviceIoControl() = %08x, %s\n", ErrNo, StrError(ErrNo));
     return -1;
   }
 
@@ -490,7 +489,7 @@
 
   for (Walker = AdInfo; Walker != NULL; Walker = Walker->Next)
   {
-    OLSR_PRINTF(5, "Index = %08x\n", (int)Walker->Index)
+    OLSR_PRINTF(5, "Index = %08x\n", (int)Walker->Index);
 
     MiniIndexToIntName(IntName, Walker->Index);
 
@@ -519,7 +518,7 @@
 {
   struct interface *Int, *Prev;
 
-  OLSR_PRINTF(1, "Removing interface %s.\n", IntConf->name)
+  OLSR_PRINTF(1, "Removing interface %s.\n", IntConf->name);
   
   Int = IntConf->interf;
 
@@ -540,13 +539,13 @@
     if(ifnet == NULL)
     {
       memset(&olsr_cnf->main_addr, 0, olsr_cnf->ipsize);
-      OLSR_PRINTF(1, "Removed last interface. Cleared main address.\n")
+      OLSR_PRINTF(1, "Removed last interface. Cleared main address.\n");
     }
 
     else
     {
       COPY_IP(&olsr_cnf->main_addr, &ifnet->ip_addr);
-      OLSR_PRINTF(1, "New main address: %s.\n", olsr_ip_to_string(&olsr_cnf->main_addr))
+      OLSR_PRINTF(1, "New main address: %s.\n", olsr_ip_to_string(&olsr_cnf->main_addr));
     }
   }
 
@@ -593,7 +592,7 @@
 
   if (ifnet == NULL && !olsr_cnf->allow_no_interfaces)
   {
-    OLSR_PRINTF(1, "No more active interfaces - exiting.\n")
+    OLSR_PRINTF(1, "No more active interfaces - exiting.\n");
     olsr_cnf->exit_value = EXIT_FAILURE;
     CallSignalHandler();
   }
@@ -621,12 +620,10 @@
 
   strcpy(ifp->int_name, "hcif01");
 
-  OLSR_PRINTF(1, "Adding %s(host emulation):\n", ifp->int_name)
+  OLSR_PRINTF(1, "Adding %s(host emulation):\n", ifp->int_name);
 
   OLSR_PRINTF(1, "       Address:%s\n", olsr_ip_to_string(&iface->hemu_ip));
 
-  OLSR_PRINTF(1, "       Index:%d\n", iface->index);
-
   OLSR_PRINTF(1, "       NB! This is a emulated interface\n       that does not exist in the kernel!\n");
 
   ifp->int_next = ifnet;
@@ -636,12 +633,9 @@
   if(COMP_IP(&null_addr, &olsr_cnf->main_addr))
     {
       COPY_IP(&olsr_cnf->main_addr, &iface->hemu_ip);
-      OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr))
+      OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
     }
 
-  /* setting the interfaces number*/
-  ifp->if_nr = iface->index;
-
   ifp->int_mtu = OLSR_DEFAULT_MTU;
 
   ifp->int_mtu -= (olsr_cnf->ip_version == AF_INET6) ?
@@ -796,7 +790,7 @@
   }
 
 #ifdef DEBUG
-  OLSR_PRINTF(3, "Checking if %s is set down or changed\n", IntConf->name)
+  OLSR_PRINTF(3, "Checking if %s is set down or changed\n", IntConf->name);
 #endif
 
   Int = IntConf->interf;
@@ -816,7 +810,7 @@
 
   if (Int->is_wireless != IsWlan)
   {
-    OLSR_PRINTF(1, "\tLAN/WLAN change: %d -> %d.\n", Int->is_wireless, IsWlan)
+    OLSR_PRINTF(1, "\tLAN/WLAN change: %d -> %d.\n", Int->is_wireless, IsWlan);
 
     Int->is_wireless = IsWlan;
 
@@ -846,14 +840,14 @@
   NewVal.v4 = Info.Addr;
 
 #ifdef DEBUG
-  OLSR_PRINTF(3, "\tAddress: %s\n", olsr_ip_to_string(&NewVal))
+  OLSR_PRINTF(3, "\tAddress: %s\n", olsr_ip_to_string(&NewVal));
 #endif
 
   if (NewVal.v4 != OldVal.v4)
   {
-    OLSR_PRINTF(1, "\tAddress change.\n")
-    OLSR_PRINTF(1, "\tOld: %s\n", olsr_ip_to_string(&OldVal))
-    OLSR_PRINTF(1, "\tNew: %s\n", olsr_ip_to_string(&NewVal))
+    OLSR_PRINTF(1, "\tAddress change.\n");
+    OLSR_PRINTF(1, "\tOld: %s\n", olsr_ip_to_string(&OldVal));
+    OLSR_PRINTF(1, "\tNew: %s\n", olsr_ip_to_string(&NewVal));
 
     Int->ip_addr.v4 = NewVal.v4;
 
@@ -865,7 +859,7 @@
 
     if (olsr_cnf->main_addr.v4 == OldVal.v4)
     {
-      OLSR_PRINTF(1, "\tMain address change.\n")
+      OLSR_PRINTF(1, "\tMain address change.\n");
 
       olsr_cnf->main_addr.v4 = NewVal.v4;
     }
@@ -874,20 +868,20 @@
   }
 
   else
-    OLSR_PRINTF(3, "\tNo address change.\n")
+    OLSR_PRINTF(3, "\tNo address change.\n");
 
   OldVal.v4 = ((struct sockaddr_in *)&Int->int_netmask)->sin_addr.s_addr;
   NewVal.v4 = Info.Mask;
 
 #ifdef DEBUG
-  OLSR_PRINTF(3, "\tNetmask: %s\n", olsr_ip_to_string(&NewVal))
+  OLSR_PRINTF(3, "\tNetmask: %s\n", olsr_ip_to_string(&NewVal));
 #endif
 
   if (NewVal.v4 != OldVal.v4)
   {
-    OLSR_PRINTF(1, "\tNetmask change.\n")
-    OLSR_PRINTF(1, "\tOld: %s\n", olsr_ip_to_string(&OldVal))
-    OLSR_PRINTF(1, "\tNew: %s\n", olsr_ip_to_string(&NewVal))
+    OLSR_PRINTF(1, "\tNetmask change.\n");
+    OLSR_PRINTF(1, "\tOld: %s\n", olsr_ip_to_string(&OldVal));
+    OLSR_PRINTF(1, "\tNew: %s\n", olsr_ip_to_string(&NewVal));
 
     AddrIn = (struct sockaddr_in *)&Int->int_netmask;
 
@@ -899,20 +893,20 @@
   }
 
   else
-    OLSR_PRINTF(3, "\tNo netmask change.\n")
+    OLSR_PRINTF(3, "\tNo netmask change.\n");
 
   OldVal.v4 = ((struct sockaddr_in *)&Int->int_broadaddr)->sin_addr.s_addr;
   NewVal.v4 = Info.Broad;
 
 #ifdef DEBUG
-  OLSR_PRINTF(3, "\tBroadcast address: %s\n", olsr_ip_to_string(&NewVal))
+  OLSR_PRINTF(3, "\tBroadcast address: %s\n", olsr_ip_to_string(&NewVal));
 #endif
 
   if (NewVal.v4 != OldVal.v4)
   {
-    OLSR_PRINTF(1, "\tBroadcast address change.\n")
-    OLSR_PRINTF(1, "\tOld: %s\n", olsr_ip_to_string(&OldVal))
-    OLSR_PRINTF(1, "\tNew: %s\n", olsr_ip_to_string(&NewVal))
+    OLSR_PRINTF(1, "\tBroadcast address change.\n");
+    OLSR_PRINTF(1, "\tOld: %s\n", olsr_ip_to_string(&OldVal));
+    OLSR_PRINTF(1, "\tNew: %s\n", olsr_ip_to_string(&NewVal));
 
     AddrIn = (struct sockaddr_in *)&Int->int_broadaddr;
 
@@ -924,7 +918,7 @@
   }
 
   else
-    OLSR_PRINTF(3, "\tNo broadcast address change.\n")
+    OLSR_PRINTF(3, "\tNo broadcast address change.\n");
 
   if (Res != 0)
     run_ifchg_cbs(Int, IFCHG_IF_UPDATE);
@@ -932,7 +926,7 @@
   return Res;
 }
 
-int chk_if_up(struct olsr_if *IntConf, int DebugLevel)
+int chk_if_up(struct olsr_if *IntConf, int DebugLevel __attribute__((unused)))
 {
   struct InterfaceInfo Info;
   struct interface *New;
@@ -983,8 +977,6 @@
   New->int_name = olsr_malloc(strlen (IntConf->name) + 1, "Interface 2");
   strcpy(New->int_name, IntConf->name);
 
-  New->if_nr = IntConf->index;
-
   IsWlan = IsWireless(IntConf->name);
 
   if (IsWlan < 0)
@@ -1003,20 +995,20 @@
   New->ttl_index = 0;
     
   OLSR_PRINTF(1, "\tInterface %s set up for use with index %d\n\n",
-              IntConf->name, New->if_nr)
+              IntConf->name, New->if_index);
       
-  OLSR_PRINTF(1, "\tMTU: %d\n", New->int_mtu)
-  OLSR_PRINTF(1, "\tAddress: %s\n", sockaddr_to_string(&New->int_addr))
-  OLSR_PRINTF(1, "\tNetmask: %s\n", sockaddr_to_string(&New->int_netmask))
+  OLSR_PRINTF(1, "\tMTU: %d\n", New->int_mtu);
+  OLSR_PRINTF(1, "\tAddress: %s\n", sockaddr_to_string(&New->int_addr));
+  OLSR_PRINTF(1, "\tNetmask: %s\n", sockaddr_to_string(&New->int_netmask));
   OLSR_PRINTF(1, "\tBroadcast address: %s\n",
-              sockaddr_to_string(&New->int_broadaddr))
+              sockaddr_to_string(&New->int_broadaddr));
 
   New->ip_addr.v4 =
     ((struct sockaddr_in *)&New->int_addr)->sin_addr.s_addr;
       
   New->if_index = Info.Index;
 
-  OLSR_PRINTF(3, "\tKernel index: %08x\n", New->if_index)
+  OLSR_PRINTF(3, "\tKernel index: %08x\n", New->if_index);
 
   AddrSockAddr = addrsock.sin_addr.s_addr;
   addrsock.sin_addr.s_addr = New->ip_addr.v4;
@@ -1045,7 +1037,7 @@
   if(COMP_IP(&NullAddr, &olsr_cnf->main_addr))
   {
     COPY_IP(&olsr_cnf->main_addr, &New->ip_addr);
-    OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr))
+    OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
   }
 
   net_add_buffer(New);
@@ -1099,12 +1091,12 @@
   return 1;
 }
 
-void check_interface_updates(void *dummy)
+void check_interface_updates(void *dummy __attribute__((unused)))
 {
   struct olsr_if *IntConf;
 
 #ifdef DEBUG
-  OLSR_PRINTF(3, "Checking for updates in the interface set\n")
+  OLSR_PRINTF(3, "Checking for updates in the interface set\n");
 #endif
 
   for(IntConf = olsr_cnf->interfaces; IntConf != NULL; IntConf = IntConf->next)
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/win32/kernel_routes.c olsrd-current/src/win32/kernel_routes.c
--- olsrd-0.5.0/src/win32/kernel_routes.c	2007-03-28 14:07:05.000000000 +0200
+++ olsrd-current/src/win32/kernel_routes.c	2007-04-26 00:22:15.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: kernel_routes.c,v 1.18 2007/03/28 12:07:05 tlopatic Exp $
+ * $Id: kernel_routes.c,v 1.20 2007/04/25 22:22:15 bernd67 Exp $
  */
 
 #include <stdio.h>
@@ -63,7 +63,7 @@
   inet_ntop(AF_INET, &Dest->rt_router.v4, Str3, 16);
 
   OLSR_PRINTF(1, "Adding IPv4 route with metric %d to %s/%s via %s and I/F 0x%x.\n",
-              Dest->rt_metric + Dest->rt_if->int_metric, Str1, Str2, Str3, Dest->rt_if->if_index)
+              Dest->rt_metric + Dest->rt_if->int_metric, Str1, Str2, Str3, Dest->rt_if->if_index);
 
   memset(&Row, 0, sizeof (MIB_IPFORWARDROW));
 
@@ -113,7 +113,7 @@
 
 // XXX - to be implemented
 
-int olsr_ioctl_add_route6(struct rt_entry *Dest)
+int olsr_ioctl_add_route6(struct rt_entry *Dest __attribute__((unused)))
 {
   return 0;
 }
@@ -129,7 +129,7 @@
   inet_ntop(AF_INET, &Dest->rt_router.v4, Str3, 16);
 
   OLSR_PRINTF(1, "Deleting IPv4 route with metric %d to %s/%s via %s and I/F 0x%x.\n",
-              Dest->rt_metric + Dest->rt_if->int_metric, Str1, Str2, Str3, Dest->rt_if->if_index)
+              Dest->rt_metric + Dest->rt_if->int_metric, Str1, Str2, Str3, Dest->rt_if->if_index);
 
   memset(&Row, 0, sizeof (MIB_IPFORWARDROW));
 
@@ -170,7 +170,7 @@
 
 // XXX - to be implemented
 
-int olsr_ioctl_del_route6(struct rt_entry *Dest)
+int olsr_ioctl_del_route6(struct rt_entry *Dest __attribute__((unused)))
 {
   return 0;
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/win32/log.c olsrd-current/src/win32/log.c
--- olsrd-0.5.0/src/win32/log.c	2004-11-21 02:21:10.000000000 +0100
+++ olsrd-current/src/win32/log.c	2007-04-26 00:23:09.000000000 +0200
@@ -36,15 +36,15 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: log.c,v 1.4 2004/11/21 01:21:10 tlopatic Exp $
+ * $Id: log.c,v 1.5 2007/04/25 22:23:09 bernd67 Exp $
  */
 
 #include "../log.h"
 
-void olsr_openlog(const char *Id)
+void olsr_openlog(const char *Id __attribute__((unused)))
 {
 }
 
-void olsr_syslog(int Level, char *Format, ...)
+void olsr_syslog(int Level __attribute__((unused)), char *Format __attribute__((unused)), ...)
 {
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/win32/net.c olsrd-current/src/win32/net.c
--- olsrd-0.5.0/src/win32/net.c	2006-11-06 00:03:56.000000000 +0100
+++ olsrd-current/src/win32/net.c	2007-04-26 00:24:09.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: net.c,v 1.20 2006/11/05 23:03:56 bernd67 Exp $
+ * $Id: net.c,v 1.22 2007/04/25 22:24:09 bernd67 Exp $
  */
 
 #if defined WINCE
@@ -97,7 +97,7 @@
   return (sock);
 }
 
-int getsocket(struct sockaddr *Addr, int BuffSize, char *Int)
+int getsocket(struct sockaddr *Addr, int BuffSize, char *Int __attribute__((unused)))
 {
   int Sock;
   int On = 1;
@@ -148,7 +148,7 @@
   return Sock;
 }
 
-int getsocket6(struct sockaddr_in6 *Addr, int BuffSize, char *Int)
+int getsocket6(struct sockaddr_in6 *Addr, int BuffSize, char *Int __attribute__((unused)))
 {
   int Sock;
   int On = 1;
@@ -228,7 +228,7 @@
     return -1;
   }
 
-  OLSR_PRINTF(3, "Routing enabled.\n")
+  OLSR_PRINTF(3, "Routing enabled.\n");
 
   return 0;
 }
@@ -259,7 +259,7 @@
     return -1;
   }
 
-  OLSR_PRINTF(3, "Routing disabled, count = %u.\n", Count)
+  OLSR_PRINTF(3, "Routing disabled, count = %u.\n", Count);
 
   return 0;
 }
@@ -343,7 +343,7 @@
   COPY_IP(&McastReq.ipv6mr_multiaddr, &Nic->int6_multaddr.sin6_addr);
   McastReq.ipv6mr_interface = Nic->if_index;
 
-  OLSR_PRINTF(3, "Interface %s joining multicast %s...", Nic->int_name, olsr_ip_to_string((union olsr_ip_addr *)&Nic->int6_multaddr.sin6_addr))
+  OLSR_PRINTF(3, "Interface %s joining multicast %s...", Nic->int_name, olsr_ip_to_string((union olsr_ip_addr *)&Nic->int6_multaddr.sin6_addr));
   /* Send multicast */
   if(setsockopt(Sock, 
 		IPPROTO_IPV6, 
@@ -392,7 +392,7 @@
     }
 
 
-  OLSR_PRINTF(3, "OK\n")
+  OLSR_PRINTF(3, "OK\n");
   return 0;
 }
 
@@ -421,7 +421,7 @@
 olsr_recvfrom(int  s, 
 	      void *buf, 
 	      size_t len, 
-	      int flags, 
+	      int flags __attribute__((unused)), 
 	      struct sockaddr *from,
 	      socklen_t *fromlen)
 {
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.0/src/win32/unistd.h olsrd-current/src/win32/unistd.h
--- olsrd-0.5.0/src/win32/unistd.h	2004-11-21 02:21:10.000000000 +0100
+++ olsrd-current/src/win32/unistd.h	2007-05-14 01:44:24.000000000 +0200
@@ -36,11 +36,13 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: unistd.h,v 1.5 2004/11/21 01:21:10 tlopatic Exp $
+ * $Id: unistd.h,v 1.7 2007/05/13 23:44:24 tlopatic Exp $
  */
 
 #if !defined TL_UNISTD_H_INCLUDED
 
+#include <stddef.h>
+
 #define TL_UNISTD_H_INCLUDED
 
 void sleep(unsigned int Sec);
@@ -52,8 +54,8 @@
 
 int getpid(void);
 
-#define IPTOS_TOS(x) (x & 0x1e)
-#define IPTOS_PREC(x) (x & 0xe0)
+#define IPTOS_TOS(x) ((x) & 0x1e)
+#define IPTOS_PREC(x) ((x) & 0xe0)
 
 int isatty(int fd);
 
