diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/CHANGELOG olsrd-current/CHANGELOG
--- olsrd-0.5.3/CHANGELOG	2007-08-02 22:57:21.000000000 +0200
+++ olsrd-current/CHANGELOG	2007-08-30 01:17:13.000000000 +0200
@@ -1,5 +1,69 @@
 This file states changes as of version 0.2.4:
-$Id: CHANGELOG,v 1.73 2007/08/02 20:57:21 bernd67 Exp $
+$Id: CHANGELOG,v 1.79 2007/08/29 23:17:13 bernd67 Exp $
+
+0.5.4 ---------------------------------------------------------------------
+
+QUAGGA
+updated to svn version 33
+
+PATCHES by Sven-Ola Tücke to be found on from
+http://download-master.berlin.freifunk.net/sven-ola/nylon/packages/olsrd/files/
+- 110-olsrd-double-wlancard-neigh-hack.patch:
+  This is a hack for Nodes having to wifi cards with the same channel,
+  bssid, IP-Range etc. If two nodes can see each other by means of two
+  possible links (here: two wifi cards with equal config), a bug is  triggered
+  with the Neigh-is-SYM detections. This small little hack prevents this.
+
+- 112-olsrd-nameservice-fixemptyname.patch:
+  This is an addon to my lat/lon stuff which will prevent olsrd from
+  running (oops?) if no hostname is given and the nameservice plugin
+  is loaded.
+
+- 113-olsrd-dyngwplain-pluginvers5.patch:
+  This updates the dyngwplain plugin to the new Plugin Iface
+
+- 140-olsrd-arprefreshed.patch:
+  This is a new one. Opens a packet socket and listen to UDP(698), extract
+  the sender MAC and refreshes the ARP cache whith that. Should speedup
+  especially in cases, if you initially try to use a longer routing path which normally
+  triggers a "ARP-Lookup-Chain".
+- 106-olsrd-nameserviceparams.patch:
+  This patch converts more plugins to the new interface version.
+
+PATCH by Arnd Hannemann <hannemann@i4.informatik.rwth-aachen.de>
+olsr_makefile_make_use_of_exename.patch
+- This patch makes sure that the EXENAME variable of Makefile.inc is used
+  in Makefile.
+
+PATCHES and CLEANUPS by Bernd Petrovitsch <bernd@firmix.at>
+- Made a function from the ME_TO_DOUBLE() macro (in src/mantissa.h).
+  This saves code throughout the code even on i386 and will even more
+  on architectures without floating point units and "-msoft-float".
+- And the mathemathics in src/mantissa.h is reformulated to minimize
+  floating point operations to save CPU power - especially on embedded
+  devices.
+- I rewrote the half of src/lq_packet.[ch] which deals with incoming
+  packets. This was triggered with performance output of gcc produced
+  by Sven-Ola Tuecke at CCCamp07.
+  This kills *lots* of (more than) superflous malloc()s and the same
+  number of (free()s). And it also kills some code and copying around of
+  data.
+
+- paving the way to activate -Wshadow, much more to do
+- const-ify parameters here and there
+- use NULL for pointers (and not "0")
+- Killed "extern" declarations in (not generated) .c files
+
+- Based on a patch by Gianni Costanzi <gianni.costanzi@gmail.com> (so credits
+  and thanks have to go there):
+  added OS_CFLAG_PTHREAD Makefile variable since gcc (on Linux) requests this
+  in the manual page.
+  Changes/additions:
+  - I added definitions to all OS-specific Makefile.$OS with the value similar
+    to the value in OS_LIB_PTHREAD (either empty or "-pthread").
+  - The variable is added to CPPFLAGS (and not CFLAGS) since CPPFLAGS is used
+    for all cpp and gcc calls (and gcc's man page indicates that it sets
+    variables for both of them).
 
 0.5.3 ---------------------------------------------------------------------
 
@@ -14,7 +78,7 @@
 ATM. Thanks to Cédric Krier <ced@ced.homedns.org> for reporting this.
 
 DEPENDENCIES FIXED
-The dependencies (*.d files) are now properly generated and used. Nd they also
+The dependencies (*.d files) are now properly generated and used. And they also
 dependen on the Makefile in the current directory and the Makefile.inc so that
 changes there also lead to new compilation.
 Remember: We support "ccache" so install it to save lot of meaningless recompiles
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/arprefresh/Makefile olsrd-current/lib/arprefresh/Makefile
--- olsrd-0.5.3/lib/arprefresh/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ olsrd-current/lib/arprefresh/Makefile	2007-08-19 22:37:41.000000000 +0200
@@ -0,0 +1,58 @@
+# The olsr.org Optimized Link-State Routing daemon(olsrd)
+# Copyright (c) 2004, Andreas T�nnesen(andreto@olsr.org)
+# Arprefresh plugin Copyright (c) 2007, Sven-Ola-aet-gmx.de
+# 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 olsr.org, olsrd 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.
+#
+# Visit http://www.olsr.org for more information.
+#
+# If you find this software useful feel free to make a donation
+# to the project. For more information see the website or contact
+# the copyright holders.
+#
+# $Id: Makefile,v 1.1 2007/08/19 20:37:41 bernd67 Exp $
+
+OLSRD_PLUGIN =	true
+PLUGIN_NAME =	olsrd_arprefresh
+PLUGIN_VER =	0.1
+
+TOPDIR = ../..
+include $(TOPDIR)/Makefile.inc
+
+default_target: $(PLUGIN_FULLNAME)
+
+$(PLUGIN_FULLNAME): $(OBJS) version-script.txt
+		$(CC) $(LDFLAGS) -o $(PLUGIN_FULLNAME) $(OBJS) $(LIBS)
+
+install:	$(PLUGIN_FULLNAME)
+		$(STRIP) $(PLUGIN_FULLNAME)
+		$(INSTALL_LIB)
+
+clean:
+		rm -f $(OBJS) $(SRCS:%.c=%.d) $(PLUGIN_FULLNAME)
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/arprefresh/README_ARPREFRESH olsrd-current/lib/arprefresh/README_ARPREFRESH
--- olsrd-0.5.3/lib/arprefresh/README_ARPREFRESH	1970-01-01 01:00:00.000000000 +0100
+++ olsrd-current/lib/arprefresh/README_ARPREFRESH	2007-08-19 22:37:41.000000000 +0200
@@ -0,0 +1,31 @@
+---------------------------------------------------------------------
+ARP REFRESH PLUGIN FOR OLSRD
+by Sven-Ola Tuecke <sven-ola-aet-gmx.de>
+---------------------------------------------------------------------
+
+This plugin listens to all recevice UDP packets and maintains an
+internal list of MAC addresses extracted from these. By hitchhiking
+the set-route-function, the kernel ARP cache will be refreshed from
+this list if a direct-neighbour host route is configured. Result:
+no more ARP lookups if you use a larger routing chain - e.g. fetch
+a web site 8 olsr-hops away does not show the typcial 8-nodes-need
+to ARP first delay.
+
+---------------------------------------------------------------------
+PLUGIN PARAMETERS (PlParam)
+---------------------------------------------------------------------
+
+None.
+
+---------------------------------------------------------------------
+SAMPLE CONFIG
+---------------------------------------------------------------------
+
+add in /etc/olsrd.conf:
+
+LoadPlugin "arprefresh.so.0.1"
+{
+}
+
+---------------------------------------------------------------------
+EOF / 2007-AUG-02
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/arprefresh/src/olsrd_arprefresh.c olsrd-current/lib/arprefresh/src/olsrd_arprefresh.c
--- olsrd-0.5.3/lib/arprefresh/src/olsrd_arprefresh.c	1970-01-01 01:00:00.000000000 +0100
+++ olsrd-current/lib/arprefresh/src/olsrd_arprefresh.c	2007-08-19 22:37:41.000000000 +0200
@@ -0,0 +1,229 @@
+/*
+ * Copyright (c) 2007, Sven-Ola Tuecke <sven-ola-aet-gmx.de>
+ * 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.
+ *
+ */
+
+/* $Id: olsrd_arprefresh.c,v 1.1 2007/08/19 20:37:41 bernd67 Exp $ */
+
+/*
+ * Plugin to refresh the local ARP cache from received OLSR broadcasts
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <net/ethernet.h>
+#include <netinet/ip.h>
+#include <netinet/udp.h>
+#include <netpacket/packet.h>
+#include <linux/types.h>
+#include <linux/filter.h>
+
+#include "olsrd_arprefresh.h"
+#include "kernel_routes.h"
+#include "scheduler.h"
+
+#undef ARPREFRESH_DEBUG
+#define PLUGIN_INTERFACE_VERSION 5
+
+/****************************************************************************
+ *                Functions that the plugin MUST provide                    *
+ ****************************************************************************/
+ 
+/**
+ * Plugin interface version
+ * Used by main olsrd to check plugin interface version
+ */
+int olsrd_plugin_interface_version(void)
+{
+	return PLUGIN_INTERFACE_VERSION;
+}
+
+static const struct olsrd_plugin_parameters plugin_parameters[] = {
+};
+
+void olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size)
+{
+    *params = plugin_parameters;
+    *size = sizeof(plugin_parameters)/sizeof(*plugin_parameters);
+}
+
+typedef struct
+{
+	struct ethhdr eth;
+	struct iphdr ip;
+	struct udphdr udp;
+} __attribute__((packed)) arprefresh_buf;
+
+static int arprefresh_sockfd = -1;
+static const int arprefresh_portnum = 698;
+
+/**
+ * Scheduled event to fetch gathered packets and update the ARP cache
+ * called from olsrd main thread
+ */
+static void olsr_arp_event(void* foo __attribute__((unused)))
+{
+	if (0 <= arprefresh_sockfd)
+	{
+		arprefresh_buf buf;
+		struct sockaddr_ll from;
+		socklen_t fromlen = sizeof(from);
+		
+		/*
+		 * Grab a single snapshot on the packet socket. This only works
+		 * if not too much IP traffic is currently flowing through.
+		 */
+		ssize_t size = recvfrom(arprefresh_sockfd, &buf, sizeof(buf),
+			MSG_TRUNC, (struct sockaddr *)&from, &fromlen);
+
+		if (0 <= size &&
+		    size >= (ssize_t)sizeof(buf) /*** &&
+		    ETH_P_IP == ntohs(buf.eth.h_proto) &&
+		    IPPROTO_UDP == buf.ip.protocol &&
+		    arprefresh_portnum == ntohs(buf.udp.source) &&
+		    arprefresh_portnum == ntohs(buf.udp.dest) ***/)
+		{
+			union
+			{
+				struct arpreq arp;
+				struct sockaddr_in in_pa;
+				struct sockaddr_in6 in_pa6;
+			} req;
+
+			memset(&req, 0, sizeof(req));
+			req.in_pa.sin_family = AF_INET;
+			memcpy(&req.in_pa.sin_addr, &buf.ip.saddr, sizeof(buf.ip.saddr));
+			req.arp.arp_ha.sa_family = AF_LOCAL;
+			memcpy(&req.arp.arp_ha.sa_data, &buf.eth.h_source, sizeof(buf.eth.h_source));
+			req.arp.arp_flags = ATF_COM;
+			if_indextoname(from.sll_ifindex, req.arp.arp_dev);
+#ifdef ARPREFRESH_DEBUG
+			{
+				int i;
+				OLSR_PRINTF(0, "Refresh on %s, %s=", req.arp.arp_dev,
+					inet_ntoa(*((struct in_addr*)&buf.ip.saddr)));
+				for(i = 0; i < (ssize_t)sizeof(buf.eth.h_source); i++)
+				{
+					OLSR_PRINTF(0, "%02x%s", ((unsigned char *)&buf.eth.h_source)[i], i < (ssize_t)sizeof(buf.eth.h_source) -1 ? ":" : "\n");
+				}
+			}
+#endif
+			if (ioctl(arprefresh_sockfd, SIOCSARP, &req) < 0) {
+				OLSR_PRINTF(1, "*** ARPREFRESH: SIOCSARP: %s\n", strerror(errno));
+				close(arprefresh_sockfd);
+				arprefresh_sockfd = -1;
+				return;
+			}
+		}
+	}
+}
+
+/**
+ * Initialize plugin
+ * Called after all parameters are passed
+ */
+int olsrd_plugin_init(void)
+{
+	int ret = 0;
+	if (AF_INET == olsr_cnf->ip_version)
+	{
+		int flags;
+		struct sock_fprog filter;
+		struct sock_filter BPF_code[]=
+		{
+			/* tcpdump -s [sizeof(arprefresh_buf)] -ni lo udp and dst port [arprefresh_portnum] -dd */
+			{ 0x28, 0, 0, 0x0000000c },
+			{ 0x15, 0, 4, 0x000086dd },
+			{ 0x30, 0, 0, 0x00000014 },
+			{ 0x15, 0, 11, 0x00000011 },
+			{ 0x28, 0, 0, 0x00000038 },
+			{ 0x15, 8, 9, arprefresh_portnum },
+			{ 0x15, 0, 8, 0x00000800 },
+			{ 0x30, 0, 0, 0x00000017 },
+			{ 0x15, 0, 6, 0x00000011 },
+			{ 0x28, 0, 0, 0x00000014 },
+			{ 0x45, 4, 0, 0x00001fff },
+			{ 0xb1, 0, 0, 0x0000000e },
+			{ 0x48, 0, 0, 0x00000010 },
+			{ 0x15, 0, 1, arprefresh_portnum },
+			{ 0x6, 0, 0, sizeof(arprefresh_buf) },
+			{ 0x6, 0, 0, 0x00000000 }
+		};
+		filter.len = sizeof(BPF_code) / sizeof(BPF_code[0]);
+		filter.filter = BPF_code;
+		if (0 <= (arprefresh_sockfd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_IP))) &&
+		    0 <= (flags = fcntl(arprefresh_sockfd, F_GETFL)) &&
+		    0 <= fcntl(arprefresh_sockfd, F_SETFL, flags | O_NONBLOCK) &&
+		    0 <= setsockopt(arprefresh_sockfd, SOL_SOCKET, SO_ATTACH_FILTER, &filter, sizeof(filter)))
+		{
+			/* Register the ARP refresh event */
+			olsr_register_scheduler_event(&olsr_arp_event, NULL, 2, 0, NULL);
+			ret = 1;
+		}
+		else
+		{
+			OLSR_PRINTF(1, "*** ARPREFRESH: Cannot create non-blocking filtering packet socket: %s\n", strerror(errno));
+		}
+	}
+	else
+	{
+		OLSR_PRINTF(1, "*** ARPREFRESH: IPv6 not supported\n");
+	}
+	return ret;
+}
+
+/****************************************************************************
+ *       Optional private constructor and destructor functions              *
+ ****************************************************************************/
+
+static void __attribute__ ((constructor)) my_init(void);
+static void __attribute__ ((destructor)) my_fini(void);
+
+static void my_init(void)
+{
+	printf("OLSRD arprefresh plugin by Sven-Ola\n");
+}
+
+/**
+ * Optional Private Destructor
+ */
+static void my_fini(void)
+{
+	if (0 <= arprefresh_sockfd)
+	{
+		close(arprefresh_sockfd);
+		arprefresh_sockfd = -1;
+	}
+}
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/arprefresh/src/olsrd_arprefresh.h olsrd-current/lib/arprefresh/src/olsrd_arprefresh.h
--- olsrd-0.5.3/lib/arprefresh/src/olsrd_arprefresh.h	1970-01-01 01:00:00.000000000 +0100
+++ olsrd-current/lib/arprefresh/src/olsrd_arprefresh.h	2007-08-19 22:37:41.000000000 +0200
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2007, Sven-Ola Tuecke <sven-ola-aet-gmx.de>
+ * 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.
+ *
+ */
+
+/* $Id: olsrd_arprefresh.h,v 1.1 2007/08/19 20:37:41 bernd67 Exp $ */
+
+#ifndef _OLSRD_ARPREFRESH
+#define _OLSRD_ARPREFRESH
+
+#include "olsr_types.h"
+#include "olsrd_plugin.h"
+#include "plugin_util.h"
+
+int olsrd_plugin_init(void);
+void olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size);
+int olsrd_plugin_interface_version(void);
+
+#endif
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/arprefresh/version-script.txt olsrd-current/lib/arprefresh/version-script.txt
--- olsrd-0.5.3/lib/arprefresh/version-script.txt	1970-01-01 01:00:00.000000000 +0100
+++ olsrd-current/lib/arprefresh/version-script.txt	2007-08-25 21:48:42.000000000 +0200
@@ -0,0 +1,10 @@
+VERS_1.0
+{
+  global:
+    olsrd_plugin_interface_version;
+    olsrd_plugin_init;
+    olsrd_get_plugin_parameters;
+
+  local:
+    *;
+};
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/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.3/lib/dyn_gw_plain/src/olsrd_dyn_gw_plain.c	2007-07-15 19:52:43.000000000 +0200
+++ olsrd-current/lib/dyn_gw_plain/src/olsrd_dyn_gw_plain.c	2007-08-19 22:37:41.000000000 +0200
@@ -1,5 +1,5 @@
 /*
- * The olsr.org Optimized Link-State Routing daemon(olsrd)
+ * Copyright (c) 2006, Sven-Ola Tuecke <sven-ola-aet-gmx.de>
  * Copyright (c) 2004, Andreas T�nnesen(andreto@olsr.org)
  * All rights reserved.
  *
@@ -51,7 +51,7 @@
 
 #define DEBUGLEV 1
 
-#define PLUGIN_INTERFACE_VERSION 4
+#define PLUGIN_INTERFACE_VERSION 5
 
 static int has_inet_gateway;
 
@@ -65,14 +65,13 @@
   return PLUGIN_INTERFACE_VERSION;
 }
 
-/**
- * Register parameters from config file
- * Called for all plugin parameters
- */
-int
-olsrd_plugin_register_param(char *key __attribute__((unused)), char *value __attribute__((unused)))
+static const struct olsrd_plugin_parameters plugin_parameters[] = {
+};
+
+void olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size)
 {
-  return 1;
+    *params = plugin_parameters;
+    *size = sizeof(plugin_parameters)/sizeof(*plugin_parameters);
 }
 
 /**
@@ -82,6 +81,8 @@
 int
 olsrd_plugin_init(void)
 {
+  printf("OLSRD dyn_gw_plain plugin by Sven-Ola\n");
+  
   gw_net.v4 = INET_NET;
   gw_netmask.v4 = INET_PREFIX;
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/dyn_gw_plain/version-script.txt olsrd-current/lib/dyn_gw_plain/version-script.txt
--- olsrd-0.5.3/lib/dyn_gw_plain/version-script.txt	2007-01-31 13:38:25.000000000 +0100
+++ olsrd-current/lib/dyn_gw_plain/version-script.txt	2007-08-25 21:48:42.000000000 +0200
@@ -2,8 +2,8 @@
 {
   global:
     olsrd_plugin_interface_version;
-    olsrd_plugin_register_param;
     olsrd_plugin_init;
+    olsrd_get_plugin_parameters;
 
   local:
     *;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/httpinfo/src/admin_interface.c olsrd-current/lib/httpinfo/src/admin_interface.c
--- olsrd-0.5.3/lib/httpinfo/src/admin_interface.c	2007-04-20 16:06:18.000000000 +0200
+++ olsrd-current/lib/httpinfo/src/admin_interface.c	2007-08-20 01:00:22.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.8 2007/04/20 14:06:18 bernd67 Exp $
+ * $Id: admin_interface.c,v 1.9 2007/08/19 23:00:22 bernd67 Exp $
  */
 
 /*
@@ -57,7 +57,6 @@
 #include <stdlib.h>
 
 #if 0
-extern int netsprintf(char *str, const char* format, ...);
 #define sprintf netsprintf
 #define NETDIRECT
 #endif
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/httpinfo/src/olsrd_httpinfo.h olsrd-current/lib/httpinfo/src/olsrd_httpinfo.h
--- olsrd-0.5.3/lib/httpinfo/src/olsrd_httpinfo.h	2007-07-15 21:29:38.000000000 +0200
+++ olsrd-current/lib/httpinfo/src/olsrd_httpinfo.h	2007-08-25 21:48:42.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.30 2007/07/15 19:29:38 bernd67 Exp $
+ * $Id: olsrd_httpinfo.h,v 1.32 2007/08/25 19:48:42 bernd67 Exp $
  */
 
 /*
@@ -81,8 +81,10 @@
 /* Destructor function */
 void olsr_plugin_exit(void);
 void olsr_plugin_exit(void);
-void olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size);
 
+#if 0
+extern int netsprintf(char *str, const char* format, ...);
+#endif
 
 #endif
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/httpinfo/src/olsrd_plugin.c olsrd-current/lib/httpinfo/src/olsrd_plugin.c
--- olsrd-0.5.3/lib/httpinfo/src/olsrd_plugin.c	2007-07-15 21:29:38.000000000 +0200
+++ olsrd-current/lib/httpinfo/src/olsrd_plugin.c	2007-08-25 21:48:42.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.17 2007/07/15 19:29:38 bernd67 Exp $
+ * $Id: olsrd_plugin.c,v 1.18 2007/08/25 19:48:42 bernd67 Exp $
  */
 
 /*
@@ -64,8 +64,8 @@
 static void my_init(void) __attribute__ ((constructor));
 static void my_fini(void) __attribute__ ((destructor));
 
-static int add_plugin_ipnet(const char *value, void *data);
-static int add_plugin_ipaddr(const char *value, void *data);
+static int add_plugin_ipnet(const char *value, void *data, unsigned int);
+static int add_plugin_ipaddr(const char *value, void *data, unsigned int);
 
 static int insert_plugin_ipnet(const char *sz_net, const char *sz_mask, struct allowed_net **allowed_nets);
 
@@ -140,9 +140,10 @@
     return 0;
 }
 
-static int add_plugin_ipnet(const char *value, void *data)
+static int add_plugin_ipnet(const char *value, void *data, unsigned int addon)
 {
     char sz_net[100], sz_mask[100]; /* IPv6 in the future */
+    if (addon) {}
 
     if(sscanf(value, "%99s %99s", sz_net, sz_mask) != 2) {
         olsr_printf(1, "(HTTPINFO) Error parsing net param \"%s\"!\n", value);
@@ -151,8 +152,9 @@
     return insert_plugin_ipnet(sz_net, sz_mask, data);
 }
 
-static int add_plugin_ipaddr(const char *value, void *data)
+static int add_plugin_ipaddr(const char *value, void *data, unsigned int addon)
 {
+    if (addon) {}
     return insert_plugin_ipnet(value, "255.255.255.255", data);
 }
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/mini/src/olsrd_plugin.c olsrd-current/lib/mini/src/olsrd_plugin.c
--- olsrd-0.5.3/lib/mini/src/olsrd_plugin.c	2007-04-20 15:46:02.000000000 +0200
+++ olsrd-current/lib/mini/src/olsrd_plugin.c	2007-09-02 23:37:49.000000000 +0200
@@ -29,7 +29,7 @@
  *
  */
 
-/* $Id: olsrd_plugin.c,v 1.3 2007/04/20 13:46:02 bernd67 Exp $ */
+/* $Id: olsrd_plugin.c,v 1.4 2007/09/02 21:37:49 bernd67 Exp $ */
 
  /*
  * Example plugin for olsrd.org OLSR daemon
@@ -40,10 +40,12 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "../../../src/olsrd_plugin.h"
+
 #include "olsrd_plugin.h"
 #include "olsr.h"
 
-#define PLUGIN_INTERFACE_VERSION 1
+#define PLUGIN_INTERFACE_VERSION 5
 
 
 /****************************************************************************
@@ -54,25 +56,30 @@
  * Plugin interface version
  * Used by main olsrd to check plugin interface version
  */
-int 
-olsrd_plugin_interface_version(void)
+int olsrd_plugin_interface_version(void)
 {
-	return PLUGIN_INTERFACE_VERSION;
+    return PLUGIN_INTERFACE_VERSION;
 }
 
 
+static int set_plugin_test(const char *value, void *data __attribute__((unused)), unsigned int addon __attribute__((unused)))
+{
+    printf("\n*** MINI: parameter test: %s\n", value);
+    return 0;
+}
+
 /**
  * Register parameters from config file
  * Called for all plugin parameters
  */
-int
-olsrd_plugin_register_param(char *key, char *value)
+static const struct olsrd_plugin_parameters plugin_parameters[] = {
+    { .name = "test",   .set_plugin_parameter = &set_plugin_test,      .data = NULL },
+};
+
+void olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size)
 {
-	if(!strcmp(key, "test")) {
-		printf("\n*** MINI: parameter test: %s\n", value);
-		return 1;
-	}
-	return 0;
+    *params = plugin_parameters;
+    *size = sizeof(plugin_parameters)/sizeof(*plugin_parameters);
 }
 
 
@@ -98,28 +105,23 @@
 
 /* attention: make static to avoid name clashes */
 
-static void __attribute__ ((constructor)) 
-my_init(void);
-
-static void __attribute__ ((destructor)) 
-my_fini(void);
+static void my_init(void) __attribute__ ((constructor));
+static void my_fini(void) __attribute__ ((destructor));
 
 
 /**
  * Optional Private Constructor
  */
-static void
-my_init(void)
+static void my_init(void)
 {
-	printf("*** MINI: constructor\n");
+    printf("*** MINI: constructor\n");
 }
 
 
 /**
  * Optional Private Destructor
  */
-static void
-my_fini(void)
+static void my_fini(void)
 {
-	printf("*** MINI: destructor\n");
+    printf("*** MINI: destructor\n");
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/mini/src/olsrd_plugin.h olsrd-current/lib/mini/src/olsrd_plugin.h
--- olsrd-0.5.3/lib/mini/src/olsrd_plugin.h	2007-04-20 16:18:56.000000000 +0200
+++ olsrd-current/lib/mini/src/olsrd_plugin.h	2007-09-02 23:37:49.000000000 +0200
@@ -46,9 +46,6 @@
 int
 olsrd_plugin_init(void);
 
-int
-olsrd_plugin_register_param(char *, char *);
-
 int 
 olsrd_plugin_interface_version(void);
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/mini/version-script.txt olsrd-current/lib/mini/version-script.txt
--- olsrd-0.5.3/lib/mini/version-script.txt	2005-05-29 14:47:41.000000000 +0200
+++ olsrd-current/lib/mini/version-script.txt	2007-09-02 23:37:49.000000000 +0200
@@ -2,8 +2,8 @@
 {
   global:
     olsrd_plugin_interface_version;
-    olsrd_plugin_register_param;
     olsrd_plugin_init;
+    olsrd_get_plugin_parameters;
 
   local:
     *;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/nameservice/src/nameservice.c olsrd-current/lib/nameservice/src/nameservice.c
--- olsrd-0.5.3/lib/nameservice/src/nameservice.c	2007-07-02 12:59:12.000000000 +0200
+++ olsrd-current/lib/nameservice/src/nameservice.c	2007-08-28 22:45:17.000000000 +0200
@@ -2,6 +2,7 @@
  * Copyright (c) 2006, Jens Nachtigall <nachtigall@web.de>
  * Copyright (c) 2005, Bruno Randolf <bruno.randolf@4g-systems.biz>
  * Copyright (c) 2004, Andreas T�nnesen(andreto-at-olsr.org)
+ * Copyright (c) 2007, Sven-Ola <sven-ola@gmx.de>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without 
@@ -30,7 +31,7 @@
  *
  */
 
-/* $Id: nameservice.c,v 1.24 2007/07/02 10:59:12 bernd67 Exp $ */
+/* $Id: nameservice.c,v 1.27 2007/08/28 20:45:17 bernd67 Exp $ */
 
 /*
  * Dynamic linked library for UniK OLSRd
@@ -56,6 +57,7 @@
 #include "mid_set.h"
 #include "link_set.h"
 
+#include "plugin_util.h"
 #include "nameservice.h"
 #include "olsrd_copy.h"
 #include "compat.h"
@@ -166,95 +168,104 @@
 }
 
 
-/**
- * called for all plugin parameters
- */
-int
-olsrd_plugin_register_param(char *key, char *value)
+static int set_nameservice_server(const char *value, void *data, unsigned int addon)
 {
-	if(!strcmp(key, "interval")) {
-		my_interval = atoi(value);
-		OLSR_PRINTF(1, "\nNAME PLUGIN: parameter interval: %d\n", my_interval);
-	}
-	else if(!strcmp(key, "timeout")) {
-		my_timeout = atof(value);
-		OLSR_PRINTF(1, "\nNAME PLUGIN: parameter timeout: %f\n", my_timeout);
-	} 
-	else if(!strcmp(key, "hosts-file")) {
-		strncpy( my_hosts_file, value, MAX_FILE );
-		OLSR_PRINTF(1, "\nNAME PLUGIN: parameter filename: %s\n", my_hosts_file);
-	}
-	else if(!strcmp(key, "resolv-file")) {
-		strncpy(my_resolv_file, value, MAX_FILE);
-		OLSR_PRINTF(1, "\nNAME PLUGIN: parameter resolv file: %s\n", my_resolv_file);
-	}
-	else if(!strcmp(key, "suffix")) {
-		strncpy(my_suffix, value, MAX_SUFFIX);
-		OLSR_PRINTF(1, "\nNAME PLUGIN: parameter suffix: %s\n", my_suffix);
-	}
-	else if(!strcmp(key, "add-hosts")) {
-		strncpy(my_add_hosts, value, MAX_FILE);
-		OLSR_PRINTF(1, "\nNAME PLUGIN: parameter additional host: %s\n", my_add_hosts);
-	}
-	else if(!strcmp(key, "services-file")) {
-		strncpy(my_services_file, value, MAX_FILE);
-		OLSR_PRINTF(1,"\nNAME PLUGIN: parameter services-file: %s", my_services_file);
-	}
-	else if(!strcmp(key, "lat")) {
-		my_lat = atof(value);
-		OLSR_PRINTF(1,"\nNAME PLUGIN: parameter lat: %f\n", my_lat);
-	}
-	else if(!strcmp(key, "lon")) {
-		my_lon = atof(value);
-		OLSR_PRINTF(1,"\nNAME PLUGIN: parameter lon: %f\n", my_lon);
-	}
-	else if(!strcmp(key, "latlon-file")) {
-		strncpy( my_latlon_file, value, MAX_FILE );
-		OLSR_PRINTF(1, "\nNAME PLUGIN: parameter latlon-file: %s\n", my_latlon_file);
-	}
-	else if(!strcmp(key, "latlon-infile")) {
-		strncpy( latlon_in_file, value, MAX_FILE );
-		OLSR_PRINTF(1, "\nNAME PLUGIN: parameter latlon-infile: %s\n", latlon_in_file);
-	}
-	else if(!strcmp(key, "dns-server")) {
-		union olsr_ip_addr ip;
-		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) > 0) {
-			my_forwarders = add_name_to_list(my_forwarders, "", NAME_FORWARDER, &ip);
-			OLSR_PRINTF(1,"\nNAME PLUGIN: parameter dns-server: (%s)", value);
-		} else {
-			OLSR_PRINTF(1,"\nNAME PLUGIN: invalid parameter dns-server: %s ", value);
-		}
-	}
-	else if(!strcmp(key, "name")) {
-		// name for main address
-		my_names = add_name_to_list(my_names, value, NAME_HOST, NULL);
-		OLSR_PRINTF(1,"\nNAME PLUGIN: parameter name: %s (main address)", value);
-	}
-	else if(!strcmp(key, "service")) {
-		// name for main address
-		my_services = add_name_to_list(my_services, value, NAME_SERVICE, NULL);
-		OLSR_PRINTF(1,"\nNAME PLUGIN: parameter service: %s (main address)", value);
+	union olsr_ip_addr ip;
+	struct name_entry **v = data;
+	if (0 == strlen(value))
+	{
+		*v = add_name_to_list(*v, "", addon, NULL);
+                OLSR_PRINTF(1, "%s got %s (main address)\n", "Got", value);
+		return 0;
+	}
+	else if (0 < inet_pton(olsr_cnf->ip_version, value, &ip))
+	{
+		*v = add_name_to_list(*v, "", addon, &ip);
+                OLSR_PRINTF(1, "%s got %s\n", "Got", value);
+		return 0;
 	}
-	else {
-		// assume this is an IP address and hostname
-		union olsr_ip_addr ip;
-		
-		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);
-		} 
-		else {
-			OLSR_PRINTF(1, "\nNAME PLUGIN: invalid IP %s for name %s!\n", key, value);
-		}
+	else
+	{
+                OLSR_PRINTF(0, "Illegal IP address \"%s\"", value);
 	}
+	return 1;
+}
 
+static int set_nameservice_name(const char *value, void *data, unsigned int addon)
+{
+	struct name_entry **v = data;
+	if (0 < strlen(value))
+	{
+		*v = add_name_to_list(*v, (char*)value, addon, NULL);
+                OLSR_PRINTF(1, "%s got %s (main address)\n", "Got", value);
+		return 0;
+	}
+	else
+	{
+                OLSR_PRINTF(0, "Illegal name \"%s\"", value);
+	}
 	return 1;
 }
 
+static int set_nameservice_host(const char *value, void *data, unsigned int addon)
+{
+	union olsr_ip_addr ip;
+	struct name_entry **v = data;
+	if (0 < inet_pton(olsr_cnf->ip_version, (char*)addon, &ip))
+	{
+		// the IP is validated later
+		*v = add_name_to_list(*v, (char*)value, addon, &ip);
+                OLSR_PRINTF(1, "%s: %s got %s\n", "Got", (char*) addon, value);
+		return 0;
+	}
+	else
+	{
+                OLSR_PRINTF(0, "%s: Illegal IP address \"%s\"", (char*) addon, value);
+	}
+	return 1;
+}
+
+static int set_nameservice_float(const char *value, void *data, unsigned int addon)
+{
+    const float thefloat = atof(value);
+    if (addon) {}
+    if (data != NULL)
+    {
+        float *v = data;
+        *v = thefloat;
+        OLSR_PRINTF(1, "%s float %f\n", "Got", thefloat);
+    }
+    else
+    {
+        OLSR_PRINTF(0, "%s float %f\n", "Ignored", thefloat);
+    }
+    return 0;
+}
+
+static const struct olsrd_plugin_parameters plugin_parameters[] = {
+    { .name = "interval",      .set_plugin_parameter = &set_plugin_int,         .data = &my_interval },
+    { .name = "timeout",       .set_plugin_parameter = &set_nameservice_float,  .data = &my_timeout },
+    { .name = "hosts-file",    .set_plugin_parameter = &set_plugin_string,      .data = &my_hosts_file,    .addon = sizeof(my_hosts_file) },
+    { .name = "resolv-file",   .set_plugin_parameter = &set_plugin_string,      .data = &my_resolv_file,   .addon = sizeof(my_resolv_file) },
+    { .name = "suffix",        .set_plugin_parameter = &set_plugin_string,      .data = &my_suffix,        .addon = sizeof(my_suffix) },
+    { .name = "add-hosts",     .set_plugin_parameter = &set_plugin_string,      .data = &my_add_hosts,     .addon = sizeof(my_add_hosts) },
+    { .name = "services-file", .set_plugin_parameter = &set_plugin_string,      .data = &my_services_file, .addon = sizeof(my_services_file) },
+    { .name = "lat",           .set_plugin_parameter = &set_nameservice_float,  .data = &my_lat },
+    { .name = "lon",           .set_plugin_parameter = &set_nameservice_float,  .data = &my_lon },
+    { .name = "latlon-file",   .set_plugin_parameter = &set_plugin_string,      .data = &my_latlon_file,   .addon = sizeof(my_latlon_file) },
+    { .name = "latlon-infile", .set_plugin_parameter = &set_plugin_string,      .data = &latlon_in_file,   .addon = sizeof(latlon_in_file) },
+    { .name = "dns-server",    .set_plugin_parameter = &set_nameservice_server, .data = &my_forwarders,    .addon = NAME_FORWARDER },
+    { .name = "name",          .set_plugin_parameter = &set_nameservice_name,   .data = &my_names,         .addon = NAME_HOST },
+    { .name = "service",       .set_plugin_parameter = &set_nameservice_name,   .data = &my_services,      .addon = NAME_SERVICE },
+    { .name = "",              .set_plugin_parameter = &set_nameservice_host,   .data = &my_names,         .addon = NAME_HOST },
+};
+
+void olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size)
+{
+    *params = plugin_parameters;
+    *size = sizeof(plugin_parameters)/sizeof(*plugin_parameters);
+}
+
 
 /**
  * queue the name/forwarder/service given in value
@@ -325,9 +336,9 @@
 	//regex_service = "^[[:alnum:]]+://(([[:alnum:]_.-]+.olsr)|([[:digit:]]{1,3}\\.[[:digit:]]{1,3}\\.[[:digit:]]{1,3}\\.[[:digit:]]{1,3}))
 	//                 :    port              /path      |(tcp OR udp) |short description
 	//                 :[[:digit:]]+[[:alnum:]/?._=#-]*\\|(tcp|udp)\\|[^|[:cntrl:]]+$";
-	strcat (strcat (strcat(regex_service, "^[[:alnum:]]+://(([[:alnum:]_.-]+"),
-		my_suffix),
-		")|([[:digit:]]{1,3}\\.[[:digit:]]{1,3}\\.[[:digit:]]{1,3}\\.[[:digit:]]{1,3})):[[:digit:]]+[[:alnum:]/?._=#-]*\\|(tcp|udp)\\|[^|[:cntrl:]]+$");
+    strcpy(regex_service, "^[[:alnum:]]+://(([[:alnum:]_.-]+");
+    strcat(regex_service, my_suffix);
+	strcat(regex_service, ")|([[:digit:]]{1,3}\\.[[:digit:]]{1,3}\\.[[:digit:]]{1,3}\\.[[:digit:]]{1,3})):[[:digit:]]+[[:alnum:]/?._=#-]*\\|(tcp|udp)\\|[^|[:cntrl:]]+$");
 
 	/* #1: call regcomp() to compile the regex */
 	if ((ret = regcomp(&regex_t_service, regex_service , REG_EXTENDED )) != 0)
@@ -602,12 +613,12 @@
 		
 	/* Fetch the message based on IP version */
 	if(olsr_cnf->ip_version == AF_INET) {
-		vtime = ME_TO_DOUBLE(m->v4.olsr_vtime);
+		vtime = me_to_double(m->v4.olsr_vtime);
 		size = ntohs(m->v4.olsr_msgsize);
 		namemessage = (struct namemsg*)&m->v4.message;
 	}
 	else {
-		vtime = ME_TO_DOUBLE(m->v6.olsr_vtime);
+		vtime = me_to_double(m->v6.olsr_vtime);
 		size = ntohs(m->v6.olsr_msgsize);
 		namemessage = (struct namemsg*)&m->v6.message;
 	}
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/nameservice/src/olsrd_plugin.c olsrd-current/lib/nameservice/src/olsrd_plugin.c
--- olsrd-0.5.3/lib/nameservice/src/olsrd_plugin.c	2007-07-15 19:41:33.000000000 +0200
+++ olsrd-current/lib/nameservice/src/olsrd_plugin.c	2007-08-25 21:48:42.000000000 +0200
@@ -29,7 +29,7 @@
  *
  */
 
-/* $Id: olsrd_plugin.c,v 1.14 2007/07/15 17:41:33 bernd67 Exp $ */
+/* $Id: olsrd_plugin.c,v 1.15 2007/08/25 19:48:42 bernd67 Exp $ */
 
 /*
  * Dynamic linked library for olsr.org olsrd
@@ -45,7 +45,7 @@
 #define PLUGIN_VERSION "0.3"
 #define PLUGIN_AUTHOR   "Bruno Randolf, Jens Nachtigall, Sven-Ola"
 #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION
-#define PLUGIN_INTERFACE_VERSION 4
+#define PLUGIN_INTERFACE_VERSION 5
 
 
 static void __attribute__ ((constructor)) 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/nameservice/version-script.txt olsrd-current/lib/nameservice/version-script.txt
--- olsrd-0.5.3/lib/nameservice/version-script.txt	2005-05-29 14:47:42.000000000 +0200
+++ olsrd-current/lib/nameservice/version-script.txt	2007-08-25 21:48:42.000000000 +0200
@@ -2,8 +2,8 @@
 {
   global:
     olsrd_plugin_interface_version;
-    olsrd_plugin_register_param;
     olsrd_plugin_init;
+    olsrd_get_plugin_parameters;
 
   local:
     *;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/pgraph/src/olsrd_pgraph.c olsrd-current/lib/pgraph/src/olsrd_pgraph.c
--- olsrd-0.5.3/lib/pgraph/src/olsrd_pgraph.c	2007-08-02 16:38:34.000000000 +0200
+++ olsrd-current/lib/pgraph/src/olsrd_pgraph.c	2007-08-31 00:49:12.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.6 2007/08/02 14:38:34 bernd67 Exp $
+ * $Id: olsrd_pgraph.c,v 1.7 2007/08/30 22:49:12 bernd67 Exp $
  */
 
 /*
@@ -46,6 +46,8 @@
 
 #include "olsrd_pgraph.h"
 #include "socket_parser.h"
+#include "olsrd_plugin.h"
+#include "plugin_util.h"
 
 #include <stdio.h>
 #include <string.h>
@@ -56,37 +58,107 @@
 #define close(x) closesocket(x)
 #endif
 
+#define PLUGIN_NAME    "OLSRD pgraph plugin"
+#define PLUGIN_VERSION "0.1"
+#define PLUGIN_AUTHOR   "Richard Gopaul"
+#define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR
+#define PLUGIN_INTERFACE_VERSION 5
+
+static union olsr_ip_addr ipc_accept_ip;
+static int ipc_port;
+
 static int ipc_socket;
-static int ipc_open;
 static int ipc_connection;
-static int ipc_socket_up;
 
-static void
-ipc_print_neigh_link(struct neighbor_entry *neighbor);
+void my_init(void) __attribute__((constructor));
 
-static void
-ipc_print_tc_link(struct tc_entry *entry, struct topo_dst *dst_entry);
+void my_fini(void) __attribute__((destructor));
+
+/*
+ * 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(void)
+{
+   return PLUGIN_INTERFACE_VERSION;
+}
+
+
+/**
+ *Constructor
+ */
+void
+my_init(void)
+{
+  /* Print plugin info to stdout */
+  printf("%s\n", MOD_DESC);
+
+  /* defaults for parameters */
+  ipc_port = 2004;
+  if (olsr_cnf->ip_version == AF_INET) {
+    ipc_accept_ip.v4 = htonl(INADDR_LOOPBACK);
+  } else {
+    ipc_accept_ip.v6 = in6addr_loopback;
+  }
+  ipc_socket = -1;
+  ipc_connection = -1;
+}
+
+/**
+ *Destructor
+ */
+void
+my_fini(void)
+{
+  if(ipc_socket >= 0) {
+    close(ipc_socket);
+    ipc_socket = -1;
+  }
+  if(ipc_connection >= 0) {
+    close(ipc_connection);
+    ipc_connection = -1;
+  }
+
+}
+
+static const struct olsrd_plugin_parameters plugin_parameters[] = {
+    { .name = "port",   .set_plugin_parameter = &set_plugin_port,      .data = &ipc_port },
+    { .name = "accept", .set_plugin_parameter = &set_plugin_ipaddress, .data = &ipc_accept_ip },
+};
+
+void olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size)
+{
+    *params = plugin_parameters;
+    *size = sizeof(plugin_parameters)/sizeof(*plugin_parameters);
+}
+
+/* Event function to register with the sceduler */
+static int pcf_event(int, int, int);
+
+static void ipc_action(int);
 
 #if 0
-static void
-ipc_print_net(union olsr_ip_addr *, union olsr_ip_addr *, union hna_netmask *);
+static struct link_entry *olsr_neighbor_best_link(union olsr_ip_addr *main);
 #endif
 
-static int
-ipc_send(const char *, int);
+static void ipc_print_neigh_link(struct neighbor_entry *neighbor);
 
-static void
-ipc_print_neigh_link(struct neighbor_entry *);
+static void ipc_print_tc_link(struct tc_entry *entry, struct topo_dst *dst_entry);
 
-static int
-plugin_ipc_init(void);
+#if 0
+static void ipc_print_net(union olsr_ip_addr *, union olsr_ip_addr *, union hna_netmask *);
+#endif
 
-void
-olsr_plugin_exit(void);
+static int ipc_send(const char *, int);
 
+static void ipc_print_neigh_link(struct neighbor_entry *);
 
-static void
-ipc_print_neigh_link(struct neighbor_entry *neighbor)
+static int plugin_ipc_init(void);
+
+
+static void ipc_print_neigh_link(struct neighbor_entry *neighbor)
 {
   char buf[256];
   int len;
@@ -133,13 +205,11 @@
  *This function is called by the my_init
  *function in uolsrd_plugin.c
  */
-int
-olsrd_plugin_init(void)
+int olsrd_plugin_init(void)
 {
 
   /* Initial IPC value */
-  ipc_open = 0;
-  ipc_socket_up = 0;
+  ipc_socket = -1;
 
   /* Register the "ProcessChanges" function */
   register_pcf(&pcf_event);
@@ -147,8 +217,7 @@
   return 1;
 }
 
-static int
-plugin_ipc_init(void)
+static int plugin_ipc_init(void)
 {
   struct sockaddr_in sin;
   olsr_u32_t yes = 1;
@@ -170,7 +239,7 @@
 #ifdef __FreeBSD__
       if (setsockopt(ipc_socket, SOL_SOCKET, SO_NOSIGPIPE, (char *)&yes, sizeof(yes)) < 0) 
       {
-	perror("SO_REUSEADDR failed");
+	perror("SO_NOSIGPIPE failed");
 	return 0;
       }
 #endif
@@ -200,14 +269,12 @@
 
       /* Register with olsrd */
       add_olsr_socket(ipc_socket, &ipc_action);
-      ipc_socket_up = 1;
     }
 
   return 1;
 }
 
-void
-ipc_action(int fd __attribute__((unused)))
+static void ipc_action(int fd __attribute__((unused)))
 {
   struct sockaddr_in pin;
   socklen_t addrlen;
@@ -235,7 +302,6 @@
       else
 	{
 */
-	  ipc_open = 1;
 	  olsr_printf(1, "(DOT DRAW)IPC: Connection from %s\n",addr);
           len = sprintf(buf, "add node %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
   	  ipc_send(buf, len);
@@ -245,25 +311,12 @@
 
 }
 
-/*
- * destructor - called at unload
- */
-void
-olsr_plugin_exit(void)
-{
-  if(ipc_open)
-    close(ipc_socket);
-}
-
-
-
 /**
  *Scheduled event
  */
-int
-pcf_event(int changes_neighborhood,
-	  int changes_topology,
-	  int changes_hna __attribute__((unused)))
+static int pcf_event(int changes_neighborhood,
+                     int changes_topology,
+                     int changes_hna __attribute__((unused)))
 {
   int res;
   olsr_u8_t index;
@@ -340,7 +393,7 @@
     }
 
 
-  if(!ipc_socket_up)
+  if(ipc_socket == -1)
     plugin_ipc_init();
 
   return res;
@@ -348,8 +401,7 @@
 
 #if 0
 #define MIN_LINK_QUALITY 0.01
-static double 
-calc_etx(double loss, double neigh_loss) 
+static double calc_etx(double loss, double neigh_loss) 
 {
   if (loss < MIN_LINK_QUALITY || neigh_loss < MIN_LINK_QUALITY)
     return 0.0;
@@ -358,8 +410,7 @@
 }
 #endif
 
-static void
-ipc_print_tc_link(struct tc_entry *entry, struct topo_dst *dst_entry)
+static void ipc_print_tc_link(struct tc_entry *entry, struct topo_dst *dst_entry)
 {
   char buf[256];
   int len;
@@ -401,29 +452,29 @@
 #endif
 
 
-static int
-ipc_send(const char *data, int size)
+static int ipc_send(const char *data, int size)
 {
-  if(!ipc_open)
+  if(ipc_connection == -1)
     return 0;
 
 #if defined __FreeBSD__ || defined __MacOSX__
-  if (send(ipc_connection, data, size, 0) < 0) 
+#define FLAG 0
 #else
-  if (send(ipc_connection, data, size, MSG_NOSIGNAL) < 0) 
+#define FLAG MSG_NOSIGNAL
 #endif
+  if (send(ipc_connection, data, size, FLAG) < 0) 
     {
       olsr_printf(1, "(DOT DRAW)IPC connection lost!\n");
       close(ipc_connection);
-      ipc_open = 0;
+      ipc_connection = -1;
       return -1;
     }
 
   return 1;
 }
 
-
-struct link_entry *olsr_neighbor_best_link(union olsr_ip_addr *main)
+#if 0
+static struct link_entry *olsr_neighbor_best_link(union olsr_ip_addr *main)
 {
   struct link_entry *walker;
   double best = 0.0;
@@ -450,4 +501,4 @@
 
   return res;
 }
-
+#endif
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/pgraph/src/olsrd_pgraph.h olsrd-current/lib/pgraph/src/olsrd_pgraph.h
--- olsrd-0.5.3/lib/pgraph/src/olsrd_pgraph.h	2007-04-20 15:46:03.000000000 +0200
+++ olsrd-current/lib/pgraph/src/olsrd_pgraph.h	2007-08-31 00:49:12.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.2 2007/04/20 13:46:03 bernd67 Exp $
+ * $Id: olsrd_pgraph.h,v 1.3 2007/08/30 22:49:12 bernd67 Exp $
  */
 
 /*
@@ -70,21 +70,8 @@
 #include "mid_set.h"
 #include "link_set.h"
 
-extern struct in_addr ipc_accept_ip;
-extern int ipc_port;
+void olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size);
 
-extern char netmask[5];
-
-/* Event function to register with the sceduler */
-int
-pcf_event(int, int, int);
-
-void
-ipc_action(int);
-
-char *
-olsr_netmask_to_string(union hna_netmask *);
-
-struct link_entry *olsr_neighbor_best_link(union olsr_ip_addr *main);
+int olsrd_plugin_interface_version(void);
 
 #endif
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/pgraph/src/olsrd_plugin.c olsrd-current/lib/pgraph/src/olsrd_plugin.c
--- olsrd-0.5.3/lib/pgraph/src/olsrd_plugin.c	2007-04-20 15:46:03.000000000 +0200
+++ olsrd-current/lib/pgraph/src/olsrd_plugin.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,138 +0,0 @@
-/*
- * The olsr.org Optimized Link-State Routing daemon(olsrd)
- * Copyright (c) 2004, Andreas T�nnesen(andreto@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 olsr.org, olsrd 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.
- *
- * Visit http://www.olsr.org for more information.
- *
- * If you find this software useful feel free to make a donation
- * to the project. For more information see the website or contact
- * the copyright holders.
- *
- * $Id: olsrd_plugin.c,v 1.2 2007/04/20 13:46:03 bernd67 Exp $
- */
-
-/*
- * Dynamic linked library for the olsr.org olsr daemon
- */
-
-
-#include "olsrd_plugin.h"
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include "plugin_loader.h"
-
-#define PLUGIN_NAME    "OLSRD pgraph plugin"
-#define PLUGIN_VERSION "0.1"
-#define PLUGIN_AUTHOR   "Richard Gopaul"
-#define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR
-#define PLUGIN_INTERFACE_VERSION 4
-
-struct in_addr ipc_accept_ip;
-int ipc_port;
-
-void
-olsr_plugin_exit(void);
-
-void __attribute__ ((constructor)) 
-my_init(void);
-
-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(void)
-{
-  return PLUGIN_INTERFACE_VERSION;
-}
-
-
-/**
- *Constructor
- */
-void
-my_init(void)
-{
-  /* Print plugin info to stdout */
-  printf("%s\n", MOD_DESC);
-
-  /* defaults for parameters */
-  ipc_port = 2004;
-  ipc_accept_ip.s_addr = htonl(INADDR_LOOPBACK);
-  
-  return;
-}
-
-/**
- *Destructor
- */
-void
-my_fini(void)
-{
-
-  /* Calls the destruction function
-   * olsr_plugin_exit()
-   * This function should be present in your
-   * sourcefile and all data destruction
-   * should happen there - NOT HERE!
-   */
-  olsr_plugin_exit();
-
-  return;
-}
-
-int
-olsrd_plugin_register_param(char *key, char *value)
-{
-  if(!strcmp(key, "port"))
-    {
-     ipc_port = atoi(value);
-     printf("(PGRAPH) listening on port: %d\n", ipc_port);
-    }
-
-  if(!strcmp(key, "accept"))
-    {
-	inet_aton(value, &ipc_accept_ip);
-	printf("(PGRAPH) accept only: %s\n", inet_ntoa(ipc_accept_ip));
-    }
-  return 1;
-}
-
-
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/pgraph/version-script.txt olsrd-current/lib/pgraph/version-script.txt
--- olsrd-0.5.3/lib/pgraph/version-script.txt	2005-07-13 23:45:07.000000000 +0200
+++ olsrd-current/lib/pgraph/version-script.txt	2007-08-31 00:49:12.000000000 +0200
@@ -2,8 +2,8 @@
 {
   global:
     olsrd_plugin_interface_version;
-    olsrd_plugin_register_param;
     olsrd_plugin_init;
+    olsrd_get_plugin_parameters;
 
   local:
     *;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/quagga/ChangeLog olsrd-current/lib/quagga/ChangeLog
--- olsrd-0.5.3/lib/quagga/ChangeLog	2007-01-31 13:38:26.000000000 +0100
+++ olsrd-current/lib/quagga/ChangeLog	2007-08-16 21:07:28.000000000 +0200
@@ -1,3 +1,11 @@
+0.2.2: Immo 'FaUl' Wehrenberg <immo@chaostreff-dortmund.de>:
+	* make selected flag configurable (do not set it by default)
+	* configurable administrative distance now
+	* make it compile (and work) on *bsd (only tested on freebsd, please
+	  drop me a note if you test it on any other platform!)
+	* lot of bugfixes (now support for redistribute with
+	  ZEBRA_HEADER_MARKER), etc
+
 0.2.1: Immo 'FaUl' Wehrenberg <immo@chaostreff-dortmund.de>:
 	* now check (most of the) return-values of syscalls, improvement still
 	  possible...
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/quagga/Contributors olsrd-current/lib/quagga/Contributors
--- olsrd-0.5.3/lib/quagga/Contributors	1970-01-01 01:00:00.000000000 +0100
+++ olsrd-current/lib/quagga/Contributors	2007-08-16 21:07:28.000000000 +0200
@@ -0,0 +1,4 @@
+This file is to thank people contributing code or do a lot of testing 
+
+* Vassilis T. <acinonyxs@yahoo.gr> for a lot of cleanups and fixes
+* Johannes Joemann <5@free.de> for a lot of testing
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/quagga/quagga-0.98.6-olsr.diff olsrd-current/lib/quagga/quagga-0.98.6-olsr.diff
--- olsrd-0.5.3/lib/quagga/quagga-0.98.6-olsr.diff	2007-01-31 13:43:09.000000000 +0100
+++ olsrd-current/lib/quagga/quagga-0.98.6-olsr.diff	1970-01-01 01:00:00.000000000 +0100
@@ -1,717 +0,0 @@
-diff -Nur quagga-0.98.6.orig/bgpd/bgp_vty.c quagga-0.98.6/bgpd/bgp_vty.c
---- quagga-0.98.6.orig/bgpd/bgp_vty.c	2006-03-30 18:12:25.000000000 +0200
-+++ quagga-0.98.6/bgpd/bgp_vty.c	2006-12-02 10:52:14.000000000 +0100
-@@ -7793,7 +7793,9 @@
- 	return ZEBRA_ROUTE_STATIC;
-       else if (strncmp (str, "r", 1) == 0)
- 	return ZEBRA_ROUTE_RIP;
--      else if (strncmp (str, "o", 1) == 0)
-+      else if (strncmp (str, "ol", 2) == 0)
-+	return ZEBRA_ROUTE_OLSR;
-+      else if (strncmp (str, "os", 2) == 0)
- 	return ZEBRA_ROUTE_OSPF;
-     }
-   if (afi == AFI_IP6)
-@@ -7806,20 +7808,23 @@
- 	return ZEBRA_ROUTE_STATIC;
-       else if (strncmp (str, "r", 1) == 0)
- 	return ZEBRA_ROUTE_RIPNG;
--      else if (strncmp (str, "o", 1) == 0)
-+      else if (strncmp (str, "os", 2) == 0)
- 	return ZEBRA_ROUTE_OSPF6;
-+      else if (strncmp (str, "ol", 2) == 0)
-+	return ZEBRA_ROUTE_OLSR;
-     }
-   return 0;
- }
- 
- DEFUN (bgp_redistribute_ipv4,
-        bgp_redistribute_ipv4_cmd,
--       "redistribute (connected|kernel|ospf|rip|static)",
-+       "redistribute (connected|kernel|ospf|rip|static|olsr)",
-        "Redistribute information from another routing protocol\n"
-        "Connected\n"
-        "Kernel routes\n"
-        "Open Shurtest Path First (OSPF)\n"
-        "Routing Information Protocol (RIP)\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Static routes\n")
- {
-   int type;
-@@ -7835,13 +7840,14 @@
- 
- DEFUN (bgp_redistribute_ipv4_rmap,
-        bgp_redistribute_ipv4_rmap_cmd,
--       "redistribute (connected|kernel|ospf|rip|static) route-map WORD",
-+       "redistribute (connected|kernel|ospf|rip|static|olsr) route-map WORD",
-        "Redistribute information from another routing protocol\n"
-        "Connected\n"
-        "Kernel routes\n"
-        "Open Shurtest Path First (OSPF)\n"
-        "Routing Information Protocol (RIP)\n"
-        "Static routes\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Route map reference\n"
-        "Pointer to route-map entries\n")
- {
-@@ -7860,13 +7866,14 @@
- 
- DEFUN (bgp_redistribute_ipv4_metric,
-        bgp_redistribute_ipv4_metric_cmd,
--       "redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295>",
-+       "redistribute (connected|kernel|ospf|rip|static|olsr) metric <0-4294967295>",
-        "Redistribute information from another routing protocol\n"
-        "Connected\n"
-        "Kernel routes\n"
-        "Open Shurtest Path First (OSPF)\n"
-        "Routing Information Protocol (RIP)\n"
-        "Static routes\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Metric for redistributed routes\n"
-        "Default metric\n")
- {
-@@ -7887,13 +7894,14 @@
- 
- DEFUN (bgp_redistribute_ipv4_rmap_metric,
-        bgp_redistribute_ipv4_rmap_metric_cmd,
--       "redistribute (connected|kernel|ospf|rip|static) route-map WORD metric <0-4294967295>",
-+       "redistribute (connected|kernel|ospf|rip|static|olsr) route-map WORD metric <0-4294967295>",
-        "Redistribute information from another routing protocol\n"
-        "Connected\n"
-        "Kernel routes\n"
-        "Open Shurtest Path First (OSPF)\n"
-        "Routing Information Protocol (RIP)\n"
-        "Static routes\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Route map reference\n"
-        "Pointer to route-map entries\n"
-        "Metric for redistributed routes\n"
-@@ -7917,13 +7925,14 @@
- 
- DEFUN (bgp_redistribute_ipv4_metric_rmap,
-        bgp_redistribute_ipv4_metric_rmap_cmd,
--       "redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295> route-map WORD",
-+       "redistribute (connected|kernel|ospf|rip|static|olsr) metric <0-4294967295> route-map WORD",
-        "Redistribute information from another routing protocol\n"
-        "Connected\n"
-        "Kernel routes\n"
-        "Open Shurtest Path First (OSPF)\n"
-        "Routing Information Protocol (RIP)\n"
-        "Static routes\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Metric for redistributed routes\n"
-        "Default metric\n"
-        "Route map reference\n"
-@@ -7947,14 +7956,16 @@
- 
- DEFUN (no_bgp_redistribute_ipv4,
-        no_bgp_redistribute_ipv4_cmd,
--       "no redistribute (connected|kernel|ospf|rip|static)",
-+       "no redistribute (connected|kernel|ospf|rip|static|olsr)",
-        NO_STR
-        "Redistribute information from another routing protocol\n"
-        "Connected\n"
-        "Kernel routes\n"
-        "Open Shurtest Path First (OSPF)\n"
-        "Routing Information Protocol (RIP)\n"
--       "Static routes\n")
-+       "Static routes\n"
-+       "Optimized Link State Routing (OLSR)\n"
-+       )
- {
-   int type;
- 
-@@ -7970,7 +7981,7 @@
- 
- DEFUN (no_bgp_redistribute_ipv4_rmap,
-        no_bgp_redistribute_ipv4_rmap_cmd,
--       "no redistribute (connected|kernel|ospf|rip|static) route-map WORD",
-+       "no redistribute (connected|kernel|ospf|rip|static|olsr) route-map WORD",
-        NO_STR
-        "Redistribute information from another routing protocol\n"
-        "Connected\n"
-@@ -7978,6 +7989,7 @@
-        "Open Shurtest Path First (OSPF)\n"
-        "Routing Information Protocol (RIP)\n"
-        "Static routes\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Route map reference\n"
-        "Pointer to route-map entries\n")
- {
-@@ -7996,7 +8008,7 @@
- 
- DEFUN (no_bgp_redistribute_ipv4_metric,
-        no_bgp_redistribute_ipv4_metric_cmd,
--       "no redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295>",
-+       "no redistribute (connected|kernel|ospf|rip|static|olsr) metric <0-4294967295>",
-        NO_STR
-        "Redistribute information from another routing protocol\n"
-        "Connected\n"
-@@ -8004,6 +8016,7 @@
-        "Open Shurtest Path First (OSPF)\n"
-        "Routing Information Protocol (RIP)\n"
-        "Static routes\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Metric for redistributed routes\n"
-        "Default metric\n")
- {
-@@ -8022,7 +8035,7 @@
- 
- DEFUN (no_bgp_redistribute_ipv4_rmap_metric,
-        no_bgp_redistribute_ipv4_rmap_metric_cmd,
--       "no redistribute (connected|kernel|ospf|rip|static) route-map WORD metric <0-4294967295>",
-+       "no redistribute (connected|kernel|ospf|rip|static|olsr) route-map WORD metric <0-4294967295>",
-        NO_STR
-        "Redistribute information from another routing protocol\n"
-        "Connected\n"
-@@ -8030,6 +8043,7 @@
-        "Open Shurtest Path First (OSPF)\n"
-        "Routing Information Protocol (RIP)\n"
-        "Static routes\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Route map reference\n"
-        "Pointer to route-map entries\n"
-        "Metric for redistributed routes\n"
-@@ -8051,7 +8065,7 @@
- 
- ALIAS (no_bgp_redistribute_ipv4_rmap_metric,
-        no_bgp_redistribute_ipv4_metric_rmap_cmd,
--       "no redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295> route-map WORD",
-+       "no redistribute (connected|kernel|ospf|rip|static|olsr) metric <0-4294967295> route-map WORD",
-        NO_STR
-        "Redistribute information from another routing protocol\n"
-        "Connected\n"
-@@ -8059,6 +8073,7 @@
-        "Open Shurtest Path First (OSPF)\n"
-        "Routing Information Protocol (RIP)\n"
-        "Static routes\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Metric for redistributed routes\n"
-        "Default metric\n"
-        "Route map reference\n"
-@@ -8067,13 +8082,15 @@
- #ifdef HAVE_IPV6
- DEFUN (bgp_redistribute_ipv6,
-        bgp_redistribute_ipv6_cmd,
--       "redistribute (connected|kernel|ospf6|ripng|static)",
-+       "redistribute (connected|kernel|ospf6|ripng|static|olsr)",
-        "Redistribute information from another routing protocol\n"
-        "Connected\n"
-        "Kernel routes\n"
-        "Open Shurtest Path First (OSPFv3)\n"
-        "Routing Information Protocol (RIPng)\n"
--       "Static routes\n")
-+       "Static routes\n"
-+       "Optimized Link State Routing (OLSR)\n"
-+       )
- {
-   int type;
- 
-@@ -8089,13 +8106,14 @@
- 
- DEFUN (bgp_redistribute_ipv6_rmap,
-        bgp_redistribute_ipv6_rmap_cmd,
--       "redistribute (connected|kernel|ospf6|ripng|static) route-map WORD",
-+       "redistribute (connected|kernel|ospf6|ripng|static|olsr) route-map WORD",
-        "Redistribute information from another routing protocol\n"
-        "Connected\n"
-        "Kernel routes\n"
-        "Open Shurtest Path First (OSPFv3)\n"
-        "Routing Information Protocol (RIPng)\n"
-        "Static routes\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Route map reference\n"
-        "Pointer to route-map entries\n")
- {
-@@ -8114,13 +8132,14 @@
- 
- DEFUN (bgp_redistribute_ipv6_metric,
-        bgp_redistribute_ipv6_metric_cmd,
--       "redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295>",
-+       "redistribute (connected|kernel|ospf6|ripng|static|olsr) metric <0-4294967295>",
-        "Redistribute information from another routing protocol\n"
-        "Connected\n"
-        "Kernel routes\n"
-        "Open Shurtest Path First (OSPFv3)\n"
-        "Routing Information Protocol (RIPng)\n"
-        "Static routes\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Metric for redistributed routes\n"
-        "Default metric\n")
- {
-@@ -8141,13 +8160,14 @@
- 
- DEFUN (bgp_redistribute_ipv6_rmap_metric,
-        bgp_redistribute_ipv6_rmap_metric_cmd,
--       "redistribute (connected|kernel|ospf6|ripng|static) route-map WORD metric <0-4294967295>",
-+       "redistribute (connected|kernel|ospf6|ripng|static|ols) route-map WORD metric <0-4294967295>",
-        "Redistribute information from another routing protocol\n"
-        "Connected\n"
-        "Kernel routes\n"
-        "Open Shurtest Path First (OSPFv3)\n"
-        "Routing Information Protocol (RIPng)\n"
-        "Static routes\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Route map reference\n"
-        "Pointer to route-map entries\n"
-        "Metric for redistributed routes\n"
-@@ -8171,13 +8191,14 @@
- 
- DEFUN (bgp_redistribute_ipv6_metric_rmap,
-        bgp_redistribute_ipv6_metric_rmap_cmd,
--       "redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295> route-map WORD",
-+       "redistribute (connected|kernel|ospf6|ripng|static|olsr) metric <0-4294967295> route-map WORD",
-        "Redistribute information from another routing protocol\n"
-        "Connected\n"
-        "Kernel routes\n"
-        "Open Shurtest Path First (OSPFv3)\n"
-        "Routing Information Protocol (RIPng)\n"
-        "Static routes\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Metric for redistributed routes\n"
-        "Default metric\n"
-        "Route map reference\n"
-@@ -8201,14 +8222,16 @@
- 
- DEFUN (no_bgp_redistribute_ipv6,
-        no_bgp_redistribute_ipv6_cmd,
--       "no redistribute (connected|kernel|ospf6|ripng|static)",
-+       "no redistribute (connected|kernel|ospf6|ripng|static|olsr)",
-        NO_STR
-        "Redistribute information from another routing protocol\n"
-        "Connected\n"
-        "Kernel routes\n"
-        "Open Shurtest Path First (OSPFv3)\n"
-        "Routing Information Protocol (RIPng)\n"
--       "Static routes\n")
-+       "Static routes\n"
-+       "Optimized Link State Routing (OLSR)\n"
-+      )
- {
-   int type;
- 
-@@ -8224,7 +8247,7 @@
- 
- DEFUN (no_bgp_redistribute_ipv6_rmap,
-        no_bgp_redistribute_ipv6_rmap_cmd,
--       "no redistribute (connected|kernel|ospf6|ripng|static) route-map WORD",
-+       "no redistribute (connected|kernel|ospf6|ripng|static|olsr) route-map WORD",
-        NO_STR
-        "Redistribute information from another routing protocol\n"
-        "Connected\n"
-@@ -8232,6 +8255,7 @@
-        "Open Shurtest Path First (OSPFv3)\n"
-        "Routing Information Protocol (RIPng)\n"
-        "Static routes\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Route map reference\n"
-        "Pointer to route-map entries\n")
- {
-@@ -8250,7 +8274,7 @@
- 
- DEFUN (no_bgp_redistribute_ipv6_metric,
-        no_bgp_redistribute_ipv6_metric_cmd,
--       "no redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295>",
-+       "no redistribute (connected|kernel|ospf6|ripng|static|olsr) metric <0-4294967295>",
-        NO_STR
-        "Redistribute information from another routing protocol\n"
-        "Connected\n"
-@@ -8258,6 +8282,7 @@
-        "Open Shurtest Path First (OSPFv3)\n"
-        "Routing Information Protocol (RIPng)\n"
-        "Static routes\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Metric for redistributed routes\n"
-        "Default metric\n")
- {
-@@ -8276,7 +8301,7 @@
- 
- DEFUN (no_bgp_redistribute_ipv6_rmap_metric,
-        no_bgp_redistribute_ipv6_rmap_metric_cmd,
--       "no redistribute (connected|kernel|ospf6|ripng|static) route-map WORD metric <0-4294967295>",
-+       "no redistribute (connected|kernel|ospf6|ripng|static|olsr) route-map WORD metric <0-4294967295>",
-        NO_STR
-        "Redistribute information from another routing protocol\n"
-        "Connected\n"
-@@ -8284,6 +8309,7 @@
-        "Open Shurtest Path First (OSPFv3)\n"
-        "Routing Information Protocol (RIPng)\n"
-        "Static routes\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Route map reference\n"
-        "Pointer to route-map entries\n"
-        "Metric for redistributed routes\n"
-@@ -8305,7 +8331,7 @@
- 
- ALIAS (no_bgp_redistribute_ipv6_rmap_metric,
-        no_bgp_redistribute_ipv6_metric_rmap_cmd,
--       "no redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295> route-map WORD",
-+       "no redistribute (connected|kernel|ospf6|ripng|static|olsr) metric <0-4294967295> route-map WORD",
-        NO_STR
-        "Redistribute information from another routing protocol\n"
-        "Connected\n"
-@@ -8313,6 +8339,7 @@
-        "Open Shurtest Path First (OSPFv3)\n"
-        "Routing Information Protocol (RIPng)\n"
-        "Static routes\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Metric for redistributed routes\n"
-        "Default metric\n"
-        "Route map reference\n"
-@@ -8325,7 +8352,7 @@
- {
-   int i;
-   const char *str[] = { "system", "kernel", "connected", "static", "rip",
--		  "ripng", "ospf", "ospf6", "isis", "bgp"};
-+		  "ripng", "ospf", "ospf6", "isis", "bgp", "hsls", "olsr"};
- 
-   /* Unicast redistribution only.  */
-   if (safi != SAFI_UNICAST)
-diff -Nur quagga-0.98.6.orig/lib/zebra.h quagga-0.98.6/lib/zebra.h
---- quagga-0.98.6.orig/lib/zebra.h	2005-06-15 13:54:18.000000000 +0200
-+++ quagga-0.98.6/lib/zebra.h	2006-12-02 10:48:51.000000000 +0100
-@@ -378,7 +378,8 @@
- #define ZEBRA_ROUTE_ISIS                 8
- #define ZEBRA_ROUTE_BGP                  9
- #define ZEBRA_ROUTE_HSLS		 10
--#define ZEBRA_ROUTE_MAX                  11
-+#define ZEBRA_ROUTE_OLSR		 11
-+#define ZEBRA_ROUTE_MAX                  12
- 
- /* Zebra's family types. */
- #define ZEBRA_FAMILY_IPV4                1
-diff -Nur quagga-0.98.6.orig/ospfd/ospf_vty.c quagga-0.98.6/ospfd/ospf_vty.c
---- quagga-0.98.6.orig/ospfd/ospf_vty.c	2006-03-30 17:41:20.000000000 +0200
-+++ quagga-0.98.6/ospfd/ospf_vty.c	2006-12-02 10:48:51.000000000 +0100
-@@ -108,9 +108,11 @@
-     *source = ZEBRA_ROUTE_RIP;
-   else if (strncmp (str, "b", 1) == 0)
-     *source = ZEBRA_ROUTE_BGP;
-+  else if (strncmp (str, "ol", 2) == 0)
-+    *source = ZEBRA_ROUTE_OLSR;
-   else
-     return 0;
--
-+  
-   return 1;
- }
- 
-@@ -5302,13 +5304,14 @@
- 
- DEFUN (ospf_redistribute_source_metric_type,
-        ospf_redistribute_source_metric_type_routemap_cmd,
--       "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
-+       "redistribute (kernel|connected|static|rip|bgp|olsr) metric <0-16777214> metric-type (1|2) route-map WORD",
-        "Redistribute information from another routing protocol\n"
-        "Kernel routes\n"
-        "Connected\n"
-        "Static routes\n"
-        "Routing Information Protocol (RIP)\n"
-        "Border Gateway Protocol (BGP)\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Metric for redistributed routes\n"
-        "OSPF default metric\n"
-        "OSPF exterior metric type for redistributed routes\n"
-@@ -5346,13 +5349,14 @@
- 
- ALIAS (ospf_redistribute_source_metric_type,
-        ospf_redistribute_source_metric_type_cmd,
--       "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
-+       "redistribute (kernel|connected|static|rip|bgp|olsr) metric <0-16777214> metric-type (1|2)",
-        "Redistribute information from another routing protocol\n"
-        "Kernel routes\n"
-        "Connected\n"
-        "Static routes\n"
-        "Routing Information Protocol (RIP)\n"
-        "Border Gateway Protocol (BGP)\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Metric for redistributed routes\n"
-        "OSPF default metric\n"
-        "OSPF exterior metric type for redistributed routes\n"
-@@ -5368,18 +5372,20 @@
-        "Static routes\n"
-        "Routing Information Protocol (RIP)\n"
-        "Border Gateway Protocol (BGP)\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Metric for redistributed routes\n"
-        "OSPF default metric\n")
- 
- DEFUN (ospf_redistribute_source_type_metric,
-        ospf_redistribute_source_type_metric_routemap_cmd,
--       "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
-+       "redistribute (kernel|connected|static|rip|bgp|olsr) metric-type (1|2) metric <0-16777214> route-map WORD",
-        "Redistribute information from another routing protocol\n"
-        "Kernel routes\n"
-        "Connected\n"
-        "Static routes\n"
-        "Routing Information Protocol (RIP)\n"
-        "Border Gateway Protocol (BGP)\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "OSPF exterior metric type for redistributed routes\n"
-        "Set OSPF External Type 1 metrics\n"
-        "Set OSPF External Type 2 metrics\n"
-@@ -5417,13 +5423,14 @@
- 
- ALIAS (ospf_redistribute_source_type_metric,
-        ospf_redistribute_source_type_metric_cmd,
--       "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
-+       "redistribute (kernel|connected|static|rip|bgp|olsr) metric-type (1|2) metric <0-16777214>",
-        "Redistribute information from another routing protocol\n"
-        "Kernel routes\n"
-        "Connected\n"
-        "Static routes\n"
-        "Routing Information Protocol (RIP)\n"
-        "Border Gateway Protocol (BGP)\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "OSPF exterior metric type for redistributed routes\n"
-        "Set OSPF External Type 1 metrics\n"
-        "Set OSPF External Type 2 metrics\n"
-@@ -5432,7 +5439,7 @@
- 
- ALIAS (ospf_redistribute_source_type_metric,
-        ospf_redistribute_source_type_cmd,
--       "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
-+       "redistribute (kernel|connected|static|rip|bgp|olsr) metric-type (1|2)",
-        "Redistribute information from another routing protocol\n"
-        "Kernel routes\n"
-        "Connected\n"
-@@ -5440,28 +5447,31 @@
-        "Routing Information Protocol (RIP)\n"
-        "Border Gateway Protocol (BGP)\n"
-        "OSPF exterior metric type for redistributed routes\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Set OSPF External Type 1 metrics\n"
-        "Set OSPF External Type 2 metrics\n")
- 
- ALIAS (ospf_redistribute_source_type_metric,
-        ospf_redistribute_source_cmd,
--       "redistribute (kernel|connected|static|rip|bgp)",
-+       "redistribute (kernel|connected|static|rip|bgp|olsr)",
-        "Redistribute information from another routing protocol\n"
-        "Kernel routes\n"
-        "Connected\n"
-        "Static routes\n"
-        "Routing Information Protocol (RIP)\n"
--       "Border Gateway Protocol (BGP)\n")
-+       "Border Gateway Protocol (BGP)\n"
-+       "Optimized Link State Routing (OLSR)\n")
- 
- DEFUN (ospf_redistribute_source_metric_routemap,
-        ospf_redistribute_source_metric_routemap_cmd,
--       "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
-+       "redistribute (kernel|connected|static|rip|bgp|olsr) metric <0-16777214> route-map WORD",
-        "Redistribute information from another routing protocol\n"
-        "Kernel routes\n"
-        "Connected\n"
-        "Static routes\n"
-        "Routing Information Protocol (RIP)\n"
-        "Border Gateway Protocol (BGP)\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Metric for redistributed routes\n"
-        "OSPF default metric\n"
-        "Route map reference\n"
-@@ -5490,13 +5500,14 @@
- 
- DEFUN (ospf_redistribute_source_type_routemap,
-        ospf_redistribute_source_type_routemap_cmd,
--       "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
-+       "redistribute (kernel|connected|static|rip|bgp|olsr) metric-type (1|2) route-map WORD",
-        "Redistribute information from another routing protocol\n"
-        "Kernel routes\n"
-        "Connected\n"
-        "Static routes\n"
-        "Routing Information Protocol (RIP)\n"
-        "Border Gateway Protocol (BGP)\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "OSPF exterior metric type for redistributed routes\n"
-        "Set OSPF External Type 1 metrics\n"
-        "Set OSPF External Type 2 metrics\n"
-@@ -5526,13 +5537,14 @@
- 
- DEFUN (ospf_redistribute_source_routemap,
-        ospf_redistribute_source_routemap_cmd,
--       "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
-+       "redistribute (kernel|connected|static|rip|bgp|olsr) route-map WORD",
-        "Redistribute information from another routing protocol\n"
-        "Kernel routes\n"
-        "Connected\n"
-        "Static routes\n"
-        "Routing Information Protocol (RIP)\n"
-        "Border Gateway Protocol (BGP)\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Route map reference\n"
-        "Pointer to route-map entries\n")
- {
-@@ -5553,14 +5565,16 @@
- 
- DEFUN (no_ospf_redistribute_source,
-        no_ospf_redistribute_source_cmd,
--       "no redistribute (kernel|connected|static|rip|bgp)",
-+       "no redistribute (kernel|connected|static|rip|bgp|olsr)",
-        NO_STR
-        "Redistribute information from another routing protocol\n"
-        "Kernel routes\n"
-        "Connected\n"
-        "Static routes\n"
-        "Routing Information Protocol (RIP)\n"
--       "Border Gateway Protocol (BGP)\n")
-+       "Border Gateway Protocol (BGP)\n"
-+       "Optimized Link State Routing (olsr)\n"
-+       )
- {
-   struct ospf *ospf = vty->index;
-   int source;
-@@ -5574,7 +5588,7 @@
- 
- DEFUN (ospf_distribute_list_out,
-        ospf_distribute_list_out_cmd,
--       "distribute-list WORD out (kernel|connected|static|rip|bgp)",
-+       "distribute-list WORD out (kernel|connected|static|rip|bgp|olsr)",
-        "Filter networks in routing updates\n"
-        "Access-list name\n"
-        OUT_STR
-@@ -5582,7 +5596,8 @@
-        "Connected\n"
-        "Static routes\n"
-        "Routing Information Protocol (RIP)\n"
--       "Border Gateway Protocol (BGP)\n")
-+       "Border Gateway Protocol (BGP)\n"
-+       "Optimized Link State Routing (OLSR)\n")
- {
-   struct ospf *ospf = vty->index;
-   int source;
-@@ -5596,7 +5611,7 @@
- 
- DEFUN (no_ospf_distribute_list_out,
-        no_ospf_distribute_list_out_cmd,
--       "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
-+       "no distribute-list WORD out (kernel|connected|static|rip|bgp|olsr)",
-        NO_STR
-        "Filter networks in routing updates\n"
-        "Access-list name\n"
-@@ -5605,7 +5620,8 @@
-        "Connected\n"
-        "Static routes\n"
-        "Routing Information Protocol (RIP)\n"
--       "Border Gateway Protocol (BGP)\n")
-+       "Border Gateway Protocol (BGP)\n"
-+       "Optimized Link State Routing (OLSR)\n")
- {
-   struct ospf *ospf = vty->index;
-   int source;
-@@ -7121,7 +7137,8 @@
- 
- 
- const char *distribute_str[] = { "system", "kernel", "connected", "static",
--				"rip", "ripng", "ospf", "ospf6", "isis", "bgp"};
-+				"rip", "ripng", "ospf", "ospf6", "isis", "bgp",
-+				"hsls","olsr"};
- int
- config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
- {
-diff -Nur quagga-0.98.6.orig/zebra/zebra_vty.c quagga-0.98.6/zebra/zebra_vty.c
---- quagga-0.98.6.orig/zebra/zebra_vty.c	2004-12-18 17:03:29.000000000 +0100
-+++ quagga-0.98.6/zebra/zebra_vty.c	2006-12-02 10:49:45.000000000 +0100
-@@ -53,6 +53,8 @@
-       return "isis";
-     case ZEBRA_ROUTE_BGP:
-       return "bgp";
-+    case ZEBRA_ROUTE_OLSR:
-+      return "olsr";
-     default:
-       return "unknown";
-     }
-@@ -84,6 +86,10 @@
-       return 'I';
-     case ZEBRA_ROUTE_BGP:
-       return 'B';
-+    case ZEBRA_ROUTE_HSLS:
-+      return 'H';
-+    case ZEBRA_ROUTE_OLSR:
-+      return 'L';
-     default:
-       return '?';
-     }
-@@ -755,8 +761,8 @@
- }
- 
- #define SHOW_ROUTE_V4_HEADER "Codes: K - kernel route, C - connected, " \
--  "S - static, R - RIP, O - OSPF,%s       I - ISIS, B - BGP, " \
--  "> - selected route, * - FIB route%s%s"
-+  "S - static, R - RIP, O - OSPF,%s       I - ISIS, B - BGP, H - HSLS, " \
-+  "L - OLSR, > - selected route, * - FIB route%s%s"
- 
- DEFUN (show_ip_route,
-        show_ip_route_cmd,
-@@ -874,7 +880,7 @@
- 
- DEFUN (show_ip_route_protocol,
-        show_ip_route_protocol_cmd,
--       "show ip route (bgp|connected|isis|kernel|ospf|rip|static)",
-+       "show ip route (bgp|connected|isis|kernel|ospf|rip|olsr|static)",
-        SHOW_STR
-        IP_STR
-        "IP routing table\n"
-@@ -884,6 +890,7 @@
-        "Kernel\n"
-        "Open Shortest Path First (OSPF)\n"
-        "Routing Information Protocol (RIP)\n"
-+       "Optimized Link State Routing (OLSR)\n"
-        "Static routes\n")
- {
-   int type;
-@@ -898,7 +905,7 @@
-     type = ZEBRA_ROUTE_CONNECT;
-   else if (strncmp (argv[0], "k", 1) ==0)
-     type = ZEBRA_ROUTE_KERNEL;
--  else if (strncmp (argv[0], "o", 1) == 0)
-+  else if (strncmp (argv[0], "os", 2) == 0)
-     type = ZEBRA_ROUTE_OSPF;
-   else if (strncmp (argv[0], "i", 1) == 0)
-     type = ZEBRA_ROUTE_ISIS;
-@@ -906,6 +913,8 @@
-     type = ZEBRA_ROUTE_RIP;
-   else if (strncmp (argv[0], "s", 1) == 0)
-     type = ZEBRA_ROUTE_STATIC;
-+  else if (strncmp (argv[0], "ol", 2) == 0)
-+    type = ZEBRA_ROUTE_OLSR;
-   else 
-     {
-       vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
-@@ -1732,7 +1741,7 @@
- 
- DEFUN (show_ipv6_route_protocol,
-        show_ipv6_route_protocol_cmd,
--       "show ipv6 route (bgp|connected|isis|kernel|ospf6|ripng|static)",
-+       "show ipv6 route (bgp|connected|isis|kernel|ospf6|ripng|olsr|static)",
-        SHOW_STR
-        IP_STR
-        "IP routing table\n"
-@@ -1742,6 +1751,7 @@
-        "Kernel\n"
-        "Open Shortest Path First (OSPFv3)\n"
-        "Routing Information Protocol (RIPng)\n"
-+       "Optimized Link State Routing (olsr)\n"
-        "Static routes\n")
- {
-   int type;
-@@ -1756,7 +1766,7 @@
-     type = ZEBRA_ROUTE_CONNECT;
-   else if (strncmp (argv[0], "k", 1) ==0)
-     type = ZEBRA_ROUTE_KERNEL;
--  else if (strncmp (argv[0], "o", 1) == 0)
-+  else if (strncmp (argv[0], "os", 2) == 0)
-     type = ZEBRA_ROUTE_OSPF6;
-   else if (strncmp (argv[0], "i", 1) == 0)
-     type = ZEBRA_ROUTE_ISIS;
-@@ -1764,7 +1774,9 @@
-     type = ZEBRA_ROUTE_RIPNG;
-   else if (strncmp (argv[0], "s", 1) == 0)
-     type = ZEBRA_ROUTE_STATIC;
--  else 
-+  else if (strncmp (argv[0], "ol", 2) == 0)
-+     type = ZEBRA_ROUTE_OLSR;
-+  else
-     {
-       vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
-       return CMD_WARNING;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/quagga/README_QUAGGA olsrd-current/lib/quagga/README_QUAGGA
--- olsrd-0.5.3/lib/quagga/README_QUAGGA	2007-04-03 11:48:45.000000000 +0200
+++ olsrd-current/lib/quagga/README_QUAGGA	2007-08-16 21:07:28.000000000 +0200
@@ -28,15 +28,15 @@
 
 PlParam "ExportRoutes" "<only/both>"
 	exportes olsr-routes to quagga or to both, quagga and kernel
-	no routes are exportet if not set.
+	no routes are exported to quagga (normal behaviour) if not set.
 
 PlParam "LocalPref" "true"
-        sets the zebra SELECTED-flag on the routes exported to zebra
+        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.
+        allowes to set the administrative distance to routes exported 
+	to Zebra.
 	
 ---------------------------------------------------------------------
 SAMPLE CONFIG
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/quagga/src/olsrd_plugin.c olsrd-current/lib/quagga/src/olsrd_plugin.c
--- olsrd-0.5.3/lib/quagga/src/olsrd_plugin.c	2007-07-15 19:41:33.000000000 +0200
+++ olsrd-current/lib/quagga/src/olsrd_plugin.c	2007-08-16 21:07:28.000000000 +0200
@@ -31,7 +31,6 @@
 #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR
 #define PLUGIN_INTERFACE_VERSION 4
 
-
 static void __attribute__ ((constructor)) my_init(void);
 static void __attribute__ ((destructor)) my_fini(void);
 static void redist_hna (void);
@@ -63,13 +62,16 @@
 	puts ("AIII, could not remove the kernel route deleter");
       olsr_addroute_add_function(&zebra_add_olsr_v4_route, AF_INET);
       olsr_delroute_add_function(&zebra_del_olsr_v4_route, AF_INET);
+      zebra_export_routes(1);
       return 1;
     }
     else if (!strcmp(value, "additional")) {
       olsr_addroute_add_function(&zebra_add_olsr_v4_route, AF_INET);
       olsr_delroute_add_function(&zebra_del_olsr_v4_route, AF_INET);
+      zebra_export_routes(1);
       return 1;
     }
+    else zebra_export_routes(0);
   }
   else if (!strcmp(key, "Distance")) {
     unsigned int distance = atoi (value);
@@ -91,7 +93,7 @@
 
 int olsrd_plugin_init() {
   if(olsr_cnf->ip_version != AF_INET) {
-    fputs("see the source - ipv6 so far not supportet\n" ,stderr);
+    fputs("see the source - ipv6 so far not supported\n" ,stderr);
     return 1;
   }
 
@@ -105,5 +107,6 @@
 }
 
 static void my_fini(void) {
+  zebra_cleanup();
 }
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/quagga/src/quagga.c olsrd-current/lib/quagga/src/quagga.c
--- olsrd-0.5.3/lib/quagga/src/quagga.c	2007-03-12 00:26:06.000000000 +0100
+++ olsrd-current/lib/quagga/src/quagga.c	2007-08-25 21:48:42.000000000 +0200
@@ -46,9 +46,11 @@
 #define BUFSIZE 1024
 
 #define STATUS_CONNECTED 1
+#define OPTION_EXPORT 1
 
 static struct {
-  char status; // TODO: internal status
+  char status; // internal status
+  char options; // internal options
   int sock; // Socket to zebra...
   char redistribute[ZEBRA_ROUTE_MAX];
   char distance;
@@ -58,22 +60,21 @@
 
 
 /* prototypes intern */
-static char *try_read (ssize_t *);
-static char* zebra_route_packet (struct ipv4_route r, ssize_t *);
-static int parse_interface_add (char *, size_t);
-static int parse_interface_delete (char *, size_t);
-static int parse_interface_up (char *, size_t);
-static int parse_interface_down (char *, size_t);
-static int parse_interface_address_add (char *, size_t);
-static int parse_interface_address_delete (char *, size_t);
-static int parse_ipv4_route (char *, size_t, struct ipv4_route *);
-static int ipv4_route_add (char *, size_t);
-static int ipv4_route_delete (char *, size_t);
-static int parse_ipv6_route_add (char*, size_t);
-static int zebra_reconnect (void);
-static int zebra_connect (void);
-static int add_v4_route_status (struct ipv4_route r);
-static int del_v4_route_status (struct ipv4_route r);
+static unsigned char *try_read (ssize_t *);
+static unsigned char* zebra_route_packet (struct ipv4_route r, ssize_t *);
+static int parse_interface_add (unsigned char *, size_t);
+static int parse_interface_delete (unsigned char *, size_t);
+static int parse_interface_up (unsigned char *, size_t);
+static int parse_interface_down (unsigned char *, size_t);
+static int parse_interface_address_add (unsigned char *, size_t);
+static int parse_interface_address_delete (unsigned char *, size_t);
+static int parse_ipv4_route (unsigned char *, size_t, struct ipv4_route *);
+static int ipv4_route_add (unsigned char *, size_t);
+static int ipv4_route_delete (unsigned char *, size_t);
+static int parse_ipv6_route_add (unsigned char*, size_t);
+static void zebra_reconnect (void);
+static void zebra_connect (void);
+
 static uint32_t prefixlentomask (uint8_t);
 static void free_ipv4_route (struct ipv4_route);
 static void update_olsr_zebra_routes (struct ipv4_route*, struct ipv4_route*);
@@ -85,7 +86,6 @@
 static uint8_t masktoprefixlen (uint32_t);
 
 
-
 #ifdef MY_DEBUG
 static void dump_ipv4_route (struct ipv4_route r, char *c) {
   int i = 0, x = 0;
@@ -147,114 +147,72 @@
 void *my_realloc (void *buf, size_t s, const char *c) {
   buf = realloc (buf, s);
   if (!buf) {
-    OLSR_PRINTF (1, "OUT OF MEMORY: %s\n", strerror(errno));
+    OLSR_PRINTF (1, "(QUAGGA) OUT OF MEMORY: %s\n", strerror(errno));
     olsr_syslog(OLSR_LOG_ERR, "olsrd: out of memory!: %m\n");
     olsr_exit(c, EXIT_FAILURE);
   }
   return buf;
 }
 
-int init_zebra () {
-  if (zebra_connect() < 0 || !(zebra.status&STATUS_CONNECTED)) {
-    olsr_exit ("AIIIII, could not connect to zebra! is zebra running?", 
+void init_zebra (void) {
+  zebra_connect();
+  if (!zebra.status&STATUS_CONNECTED)
+    olsr_exit ("(QUAGGA) AIIIII, could not connect to zebra! is zebra running?", 
 	       EXIT_FAILURE);
-  }
 }
 
-
-static int zebra_reconnect (void) {
-  struct ipv4_route *tmp;
+void zebra_cleanup (void) {
   int i;
+  struct rt_entry *tmp;
+  if (zebra.options & OPTION_EXPORT) {
+    for (i = 0; i < HASHSIZE; i++) {
+      for (tmp = routingtable[i].next; tmp != &routingtable[i]; tmp = tmp->next)
+	zebra_del_olsr_v4_route (tmp);     
+      for (tmp = hna_routes[i].next; tmp != &hna_routes[i]; tmp = tmp->next)
+	zebra_del_olsr_v4_route (tmp) ;   }
+  }  
 
-  if (zebra_connect() < 0 || !(zebra.status&STATUS_CONNECTED)) 
-    // log: zebra-reconnect failed
-    ;
   for (i = 0; ZEBRA_ROUTE_MAX - 1; i++)
-    if (zebra.redistribute[i]) zebra_redistribute(i + 1);
-
-  for (tmp = zebra.v4_rt; tmp; tmp = tmp->next)
-    zebra_add_v4_route(*tmp);
-}
-
-
-static int add_v4_route_status (struct ipv4_route r) {
-
-  struct ipv4_route *tmp = olsr_malloc (sizeof r, "quagga_v4_route_status");
-  memcpy (tmp, &r, sizeof r);
-
-  if (r.message & ZAPI_MESSAGE_NEXTHOP) {
-    tmp->nexthops = olsr_malloc (r.nh_count * sizeof tmp->nexthops, 
-				 "quagga_v4_route_status");
-    memcpy (tmp->nexthops, &r.nexthops, sizeof *r.nexthops);
-  }
-
-  if (r.message & ZAPI_MESSAGE_IFINDEX) {
-    tmp->index = olsr_malloc (r.ind_num * sizeof *tmp->index, 
-			      "quagga_v4_route_status");
-    memcpy (tmp->index, &r.index, r.ind_num * sizeof *tmp->index);
-  }
-
-  tmp->next = zebra.v4_rt;
-  zebra.v4_rt = tmp;
-
-  return 0;
-
-}
-
-
-static int cmp_v4_route (struct ipv4_route a, struct ipv4_route b) {
-  if (a.type != b.type) return 1;
-  if (a.flags != b.flags) return 1;
-  if (a.message != b.message) return 1;
-  if (a.prefixlen != b.prefixlen) return 1;
-  if (a.message & ZAPI_MESSAGE_NEXTHOP) {
-    if (a.nh_count != b.nh_count) return 1;
-    if (memcmp (a.nexthops, b.nexthops, a.nh_count * sizeof *b.nexthops)) 
-      return 1;
-  }
-  if (a.message & ZAPI_MESSAGE_IFINDEX) {
-    if (a.ind_num != b.ind_num) return 1;
-    if (memcpy (a.index, b.index, a.ind_num * sizeof *a.index)) return 1;
-  }
-  if (a.message & ZAPI_MESSAGE_DISTANCE) 
-    if (a.distance != b.distance) return 1;
-  if (a.message & ZAPI_MESSAGE_METRIC)
-    if (a.metric != b.metric) return 1;
-  return 0;
+    if (zebra.redistribute[i]) zebra_disable_redistribute(i + 1);
 }
 
-static int del_v4_route_status (struct ipv4_route r) {
 
-  struct ipv4_route *tmp, *prv = 0;
-
-  for (tmp = zebra.v4_rt; tmp; tmp = tmp->next) {
-    if (!cmp_v4_route(*tmp, r)) {
-      if (prv) prv->next = tmp->next;
-
-      free_ipv4_route(*tmp);
-      free (tmp);
+static void zebra_reconnect (void) {
+  struct rt_entry *tmp;
+  int i;
 
-      return 0;
+  zebra_connect();
+  if (!zebra.status & STATUS_CONNECTED) return; // try again next time
 
+  if (zebra.options & OPTION_EXPORT) {
+    for (i = 0; i < HASHSIZE; i++) {
+      for (tmp = routingtable[i].next; tmp != &routingtable[i]; tmp = tmp->next)
+	zebra_add_olsr_v4_route (tmp);     
+      for (tmp = hna_routes[i].next; tmp != &hna_routes[i]; tmp = tmp->next)
+	zebra_add_olsr_v4_route (tmp);
     }
-    prv = tmp;
-  }
+  }  
 
-  return 1;
+  for (i = 0; ZEBRA_ROUTE_MAX - 1; i++)
+    if (zebra.redistribute[i]) zebra_redistribute(i + 1);
+  /* Zebra sends us all routes of type it knows after 
+     zebra_redistribute(type) */
 }
 
 
+
 /* Connect to the zebra-daemon, returns a socket */
-static int zebra_connect (void) {
+static void zebra_connect (void) {
 
 #ifndef USE_UNIX_DOMAIN_SOCKET
   struct sockaddr_in i;
-  close (zebra.sock);
+  if (close (zebra.sock) < 0) olsr_exit ("(QUAGGA) Could not close socket!", EXIT_FAILURE);
+  
 
   zebra.sock = socket (AF_INET,SOCK_STREAM, 0);
 #else
   struct sockaddr_un i;
-  close (zebra.sock);
+  if (close (zebra.sock) < 0) olsr_exit ("(QUAGGA) Could not close socket!", EXIT_FAILURE);
 
   zebra.sock = socket (AF_UNIX,SOCK_STREAM, 0);
 #endif
@@ -262,7 +220,7 @@
   int ret;
 
   if (zebra.sock <0 )
-    olsr_exit("could not create socket!", EXIT_FAILURE);
+    olsr_exit("(QUAGGA) Could not create socket!", EXIT_FAILURE);
   
   memset (&i, 0, sizeof i);
 #ifndef USE_UNIX_DOMAIN_SOCKET
@@ -275,18 +233,15 @@
 #endif
 
   ret = connect (zebra.sock, (struct sockaddr *)&i, sizeof i);
-  if  (ret < 0) {
-    close (zebra.sock);
-  }
+  if  (ret < 0) zebra.status &= ~STATUS_CONNECTED;
   else zebra.status |= STATUS_CONNECTED;
-  return zebra.sock;
 }
 
     
 /* Sends a command to zebra, command is 
    the command defined in zebra.h, options is the packet-payload, 
    optlen the length, of the payload */
-char zebra_send_command (unsigned char command, char * options, int optlen) {
+unsigned char zebra_send_command (unsigned char command, unsigned char * options, int optlen) {
 
 #ifdef ZEBRA_HEADER_MARKER
   char *p = olsr_malloc (optlen + 6, "zebra_send_command");
@@ -297,10 +252,11 @@
   char *p = olsr_malloc (optlen + 3, "zebra_send_command");
   uint16_t length = optlen + 3;  // length of option + command + packet_length
 #endif
-  
+  char *pnt = p;
   int ret;
   
   uint16_t len = htons(length);
+
   memcpy (p, &len, 2);
 
 #ifdef ZEBRA_HEADER_MARKER
@@ -324,24 +280,26 @@
 	continue;
       }
       else {
+	olsr_printf (1, "(QUAGGA) Disconnected from zebra\n");
 	zebra.status &= ~STATUS_CONNECTED;
+	free (pnt);
 	return -1;
       }
     }
     p = p+ret;
   } while ((length -= ret));
-
+  free (pnt);
   return 0;
 }
 
 
 /* Creates a Route-Packet-Payload, needs address, netmask, nexthop, 
    distance, and a pointer of an size_t */
-static char* zebra_route_packet (struct ipv4_route r, ssize_t *optlen) {
+static unsigned char* zebra_route_packet (struct ipv4_route r, ssize_t *optlen) {
 
   int count;
 
-  char *cmdopt, *t;
+  unsigned char *cmdopt, *t;
   *optlen = 4; // first: type, flags, message, prefixlen
   *optlen += r.prefixlen / 8 + (r.prefixlen % 8 ? 1 : 0); // + prefix
   if (r.message & ZAPI_MESSAGE_NEXTHOP)
@@ -405,7 +363,7 @@
 /* adds a route to zebra-daemon */
 int zebra_add_v4_route (struct ipv4_route r) {
   
-  char *cmdopt;
+  unsigned char *cmdopt;
   ssize_t optlen;
   int retval;
 
@@ -420,7 +378,7 @@
 /* deletes a route from the zebra-daemon */
 int zebra_delete_v4_route (struct ipv4_route r) {
   
-  char *cmdopt;
+  unsigned char *cmdopt;
   ssize_t optlen;
   int retval;
 
@@ -436,20 +394,20 @@
 
 /* Check wether there is data from zebra aviable */
 void zebra_check (void* foo) {
-  char *data, *f;
+  unsigned char *data, *f;
   ssize_t len, ret;
 
   if (!(zebra.status & STATUS_CONNECTED)) {
-    if (!zebra_reconnect()) return;
+    zebra_reconnect();
+    return;
   }
   data = try_read (&len);
   if (data) {
     f = data;
     do {
       ret = zebra_parse_packet (f, len);
-      if (!ret) {//something wired happened
-	puts ("DEBUG: IIIIIIIIIIRGS");
-	exit (EXIT_FAILURE);
+      if (!ret) { // something wired happened
+	olsr_exit ("(QUAGGA) Zero message length??? ", EXIT_FAILURE);
       }
       f += ret;
     } while ((f - data) < len);
@@ -460,8 +418,8 @@
 
 // tries to read a packet from zebra_socket
 // if there is something to read - make sure to read whole packages
-static char *try_read (ssize_t *len) {
-  char *buf = NULL;
+static unsigned char *try_read (ssize_t *len) {
+  unsigned char *buf = NULL;
   ssize_t ret = 0, bsize = 0;
   uint16_t length = 0, l = 0;
   int sockstate;
@@ -477,22 +435,16 @@
       buf = my_realloc (buf, bsize, "Zebra try_read");
     }
     ret = read (zebra.sock, buf + l, bsize - l);
-    if (ret <= 0) {
-      if (errno == EAGAIN) {
-	errno = 0;
-      }
-      else {
-	olsr_printf(1, "OOPS, something realy wired happened:"
-		    "read returned %s\n", strerror(errno));
-	errno = 0;
-	zebra.status &= ~STATUS_CONNECTED;
-	return 0;
-      }
+    if (!ret) { // nothing more to read, packet is broken, discard!
       free (buf);
       return NULL;
     }
-    *len += ret;
+    if (ret < 0 && errno != EAGAIN) { // oops - we got disconnected
+      olsr_printf (1, "(QUAGGA) Disconnected from zebra\n");
+      zebra.status &= ~STATUS_CONNECTED;
+    }
 
+    *len += ret;
     while ((*len - l) > length) {
       l += length;
       memcpy (&length, buf + l, 2);
@@ -511,10 +463,13 @@
 
 
 /* Parse a packet recived from zebra */
-int zebra_parse_packet (char *packet, ssize_t maxlen) {
+int zebra_parse_packet (unsigned char *packet, ssize_t maxlen) {
+
+  uint16_t command;
+  int skip;
 
   /* Array of functions */
-  int (*foo[ZEBRA_MESSAGE_MAX]) (char *, size_t) = {
+  int (*foo[ZEBRA_MESSAGE_MAX]) (unsigned char *, size_t) = {
     parse_interface_add,
     parse_interface_delete,
     parse_interface_address_add,
@@ -526,67 +481,79 @@
     parse_ipv6_route_add
   };
 
+  uint16_t length;
+  int ret;
+
 #ifdef MY_DEBUG
   puts ("DEBUG: zebra_parse_packet");
 #endif
-  uint16_t length;
-  
-  int ret;
+
   memcpy (&length, packet, 2);
   length = ntohs (length);
   
   if (maxlen < length) {
-    puts("Error: programmer is an idiot");
-    printf ("DEBUG: maxlen = %d, packet_length = %d\n", maxlen, length);
-    return maxlen;
+    olsr_printf (1, "(QUAGGA) maxlen = %d, packet_length = %d\n", maxlen, length);
+    olsr_exit ("(QUAGGA) programmer is an idiot", EXIT_FAILURE);
   }
 
-  if (packet[2] - 1 < ZEBRA_MESSAGE_MAX && foo[packet[2] - 1]) { 
-    if (!(ret = foo[packet[2] - 1] (packet + 3, length - 3))) 
+#ifdef ZEBRA_HEADER_MARKER
+  if (packet[2] == 255) { // found header marker!!
+    //packet[3] == ZSERV_VERSION: FIXME: HANDLE THIS!
+    memcpy (command, packet + 4, sizeof command); // two bytes command now!
+    command-- = ntohs (command); 
+    skip = 6;
+  }
+#else
+  command = packet[2] - 1;
+  skip = 3;
+#endif
+
+  if (command < ZEBRA_MESSAGE_MAX && foo[command]) { 
+    if (!(ret = foo[command] (packet + skip, length - skip))) 
       return length;
-    else printf ("DEBUG: Parse error: %d\n", ret);
+    else olsr_printf (1, "(QUAGGA) Parse error: %d\n", ret);
   }
   else
-    printf ("Unknown packet type: %d\n", packet[2]);
+    olsr_printf (1, "(QUAGGA) Unknown packet type: %d\n", packet[2]);
 
-  puts ("Quagga: RECIVED PACKET FROM ZEBRA THAT I CAN'T PARSE");
+  olsr_printf (1, "(Quagga) RECIVED PACKET FROM ZEBRA THAT I CAN'T PARSE");
 
   return length;
 }
 
 
-static int parse_interface_add (char *opt, size_t len) {
+static int parse_interface_add (unsigned char *opt, size_t len) {
   //todo
   return 0;
 }
 
 
-static int parse_interface_delete (char *opt, size_t len) {
+static int parse_interface_delete (unsigned char *opt, size_t len) {
   //todo
   return 0;
 }
 
 
-static int parse_interface_address_add (char *opt, size_t len) {
+static int parse_interface_address_add (unsigned char *opt, size_t len) {
   
   //todo
   return 0;
 }
 
-static int parse_interface_up (char *opt, size_t len) {
+static int parse_interface_up (unsigned char *opt, size_t len) {
   
   //todo
   return 0;
 }
 
-static int parse_interface_down (char *opt, size_t len) {
+static int parse_interface_down (unsigned char *opt, size_t len) {
   
   //todo
   return 0;
 }
 
 
-static int parse_interface_address_delete (char *opt, size_t  len) {
+static int parse_interface_address_delete (unsigned char *opt, size_t  len) {
   //todo
   return 0;
 }
@@ -594,7 +561,7 @@
 
 /* Parse an ipv4-route-packet recived from zebra
  */
-static int parse_ipv4_route (char *opt, size_t len, struct ipv4_route *r) {
+static int parse_ipv4_route (unsigned char *opt, size_t len, struct ipv4_route *r) {
   int c;
 
   if (len < 4) return -1;
@@ -653,22 +620,18 @@
 }
 
 
-static int ipv4_route_add (char *opt, size_t len) {
+static int ipv4_route_add (unsigned char *opt, size_t len) {
 
   struct ipv4_route r;
   int f;
     
   f = parse_ipv4_route (opt, len, &r);
-  if (f < 0) {
-    printf ("parse-error: %d\n",f);
-    return f;
-  }
-  
-  add_hna4_route (r);
-  return 0;
+  if (f < 0) return f;
+
+  return add_hna4_route (r);
 }
 
-static int ipv4_route_delete (char *opt, size_t len) {
+static int ipv4_route_delete (unsigned char *opt, size_t len) {
   struct ipv4_route r;
   int f;
   
@@ -679,7 +642,7 @@
   
 }
 
-static int parse_ipv6_route_add (char *opt, size_t len) {
+static int parse_ipv6_route_add (unsigned char *opt, size_t len) {
   //todo
   return 0;
 }
@@ -810,7 +773,6 @@
     route.distance = zebra.distance;
   }
 
-  add_v4_route_status (route);
   retval = zebra_add_v4_route(route);
   free_ipv4_route (route);
   return retval;
@@ -855,7 +817,6 @@
     route.distance = zebra.distance;
   }
 
-  retval = zebra_delete_v4_route(route);
   del_v4_route_status(route);
   free_ipv4_route (route);
   return retval;
@@ -868,3 +829,10 @@
 void zebra_olsr_localpref (void) {
   zebra.flags &= ZEBRA_FLAG_SELECTED;
 }
+
+void zebra_export (char t) {
+  if (t)
+    zebra.options |= OPTION_EXPORT;
+  else
+    zebra.options &= ~OPTION_EXPORT;
+}
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/quagga/src/quagga.h olsrd-current/lib/quagga/src/quagga.h
--- olsrd-0.5.3/lib/quagga/src/quagga.h	2007-03-12 00:26:06.000000000 +0100
+++ olsrd-current/lib/quagga/src/quagga.h	2007-08-25 21:48:42.000000000 +0200
@@ -51,12 +51,13 @@
   struct ipv4_route *next;
 };
 
-int init_zebra (void);
-char zebra_send_command (unsigned char, char *, int );
+void init_zebra (void);
+void zebra_cleanup (void);
+unsigned char zebra_send_command (unsigned char, unsigned char *, int );
 int zebra_add_v4_route (struct ipv4_route r);
 int zebra_delete_v4_route (struct ipv4_route r);
 void zebra_check (void*);
-int zebra_parse_packet (char*, ssize_t);
+int zebra_parse_packet (unsigned char*, ssize_t);
 int zebra_redistribute (unsigned char);
 int zebra_disable_redistribute (unsigned char);
 int add_hna4_route (struct ipv4_route);
@@ -64,5 +65,6 @@
 void *my_realloc (void *, size_t, const char*);
 int zebra_add_olsr_v4_route (struct rt_entry*);
 int zebra_del_olsr_v4_route (struct rt_entry*);
-void zebra_olsr_localpref(void);
-void zebra_olsr_distance(char);
+void zebra_olsr_localpref (void);
+void zebra_olsr_distance (char);
+void zebra_export_routes (unsigned char);
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/secure/src/olsrd_plugin.c olsrd-current/lib/secure/src/olsrd_plugin.c
--- olsrd-0.5.3/lib/secure/src/olsrd_plugin.c	2007-07-15 23:47:17.000000000 +0200
+++ olsrd-current/lib/secure/src/olsrd_plugin.c	2007-08-25 21:48:42.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.13 2007/07/15 21:47:17 bernd67 Exp $
+ * $Id: olsrd_plugin.c,v 1.14 2007/08/25 19:48:42 bernd67 Exp $
  */
 
 
@@ -90,9 +90,10 @@
   secure_plugin_exit();
 }
 
-static int store_string(const char *value, void *data)
+static int store_string(const char *value, void *data, unsigned int addon)
 {
   char *str = data;
+  if (addon) {}
   snprintf(str, FILENAME_MAX+1, "%s", value);
   return 0;
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/tas/src/http.c olsrd-current/lib/tas/src/http.c
--- olsrd-0.5.3/lib/tas/src/http.c	2005-11-10 20:50:42.000000000 +0100
+++ olsrd-current/lib/tas/src/http.c	2007-09-03 00:17:00.000000000 +0200
@@ -37,7 +37,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: http.c,v 1.5 2005/11/10 19:50:42 kattemat Exp $
+ * $Id: http.c,v 1.6 2007/09/02 22:17:00 bernd67 Exp $
  */
 
 #include "link.h"
@@ -447,7 +447,7 @@
   getRandomBytes(cookieStruct.key, 16);
 }
 
-int httpSetAddress(const char *addrStr)
+int httpSetAddress(const char *addrStr, void *data __attribute__((unused)), unsigned int addon __attribute__((unused)))
 {
   if (parseIpAddr(&confAddr, addrStr) < 0)
   {
@@ -458,7 +458,7 @@
   return 0;
 }
 
-int httpSetPort(const char *portStr)
+int httpSetPort(const char *portStr, void *data __attribute__((unused)), unsigned int addon __attribute__((unused)))
 {
   unsigned int port;
 
@@ -479,7 +479,7 @@
   return 0;
 }
 
-int httpSetRootDir(const char *rootDir)
+int httpSetRootDir(const char *rootDir, void *data __attribute__((unused)), unsigned int addon __attribute__((unused)))
 {
   if (checkAbsPath(rootDir) < 0)
   {
@@ -491,7 +491,7 @@
   return 0;
 }
 
-int httpSetWorkDir(const char *workDir)
+int httpSetWorkDir(const char *workDir, void *data __attribute__((unused)), unsigned int addon __attribute__((unused)))
 {
   if (checkAbsPath(workDir) < 0)
   {
@@ -503,22 +503,25 @@
   return 0;
 }
 
-void httpSetIndexFile(const char *indexFile)
+int httpSetIndexFile(const char *indexFile, void *data __attribute__((unused)), unsigned int addon __attribute__((unused)))
 {
   confIndexFile = myStrdup(indexFile);
+  return 0;
 }
 
-void httpSetUser(const char *user)
+int httpSetUser(const char *user, void *data __attribute__((unused)), unsigned int addon __attribute__((unused)))
 {
   confUser = myStrdup(user);
+  return 0;
 }
 
-void httpSetPassword(const char *password)
+int httpSetPassword(const char *password, void *data __attribute__((unused)), unsigned int addon __attribute__((unused)))
 {
   confPassword = myStrdup(password);
+  return 0;
 }
 
-int httpSetSessTime(const char *timeStr)
+int httpSetSessTime(const char *timeStr, void *data __attribute__((unused)), unsigned int addon __attribute__((unused)))
 {
   unsigned int time;
 
@@ -539,12 +542,13 @@
   return 0;
 }
 
-void httpSetPubDir(const char *pubDir)
+int httpSetPubDir(const char *pubDir, void *data __attribute__((unused)), unsigned int addon __attribute__((unused)))
 {
   confPubDir = myStrdup(pubDir);
+  return 0;
 }
 
-int httpSetQuantum(const char *quantumStr)
+int httpSetQuantum(const char *quantumStr, void *data __attribute__((unused)), unsigned int addon __attribute__((unused)))
 {
   unsigned int quantum;
 
@@ -565,7 +569,7 @@
   return 0;
 }
 
-int httpSetMessTime(const char *timeStr)
+int httpSetMessTime(const char *timeStr, void *data __attribute__((unused)), unsigned int addon __attribute__((unused)))
 {
   unsigned int time;
 
@@ -586,7 +590,7 @@
   return 0;
 }
 
-int httpSetMessLimit(const char *limitStr)
+int httpSetMessLimit(const char *limitStr, void *data __attribute__((unused)), unsigned int addon __attribute__((unused)))
 {
   unsigned int limit;
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/tas/src/http.h olsrd-current/lib/tas/src/http.h
--- olsrd-0.5.3/lib/tas/src/http.h	2005-04-12 19:17:26.000000000 +0200
+++ olsrd-current/lib/tas/src/http.h	2007-09-03 00:17:00.000000000 +0200
@@ -37,7 +37,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: http.h,v 1.1 2005/04/12 17:17:26 tlopatic Exp $
+ * $Id: http.h,v 1.2 2007/09/02 22:17:00 bernd67 Exp $
  */
 
 #define CHUNK_SIZE 1024
@@ -117,18 +117,18 @@
 
 extern void httpInit(void);
 
-extern int httpSetAddress(const char *addrStr);
-extern int httpSetPort(const char *portStr);
-extern int httpSetRootDir(const char *rootDir);
-extern int httpSetWorkDir(const char *workDir);
-extern void httpSetIndexFile(const char *indexFile);
-extern void httpSetUser(const char *user);
-extern void httpSetPassword(const char *password);
-extern int httpSetSessTime(const char *timeStr);
-extern void httpSetPubDir(const char *pref);
-extern int httpSetQuantum(const char *quantumStr);
-extern int httpSetMessTime(const char *timeStr);
-extern int httpSetMessLimit(const char *limitStr);
+extern int httpSetAddress(const char *addrStr, void *data, unsigned int addon);
+extern int httpSetPort(const char *portStr, void *data, unsigned int addon);
+extern int httpSetRootDir(const char *rootDir, void *data, unsigned int addon);
+extern int httpSetWorkDir(const char *workDir, void *data, unsigned int addon);
+extern int httpSetIndexFile(const char *indexFile, void *data, unsigned int addon);
+extern int httpSetUser(const char *user, void *data, unsigned int addon);
+extern int httpSetPassword(const char *password, void *data, unsigned int addon);
+extern int httpSetSessTime(const char *timeStr, void *data, unsigned int addon);
+extern int httpSetPubDir(const char *pref, void *data, unsigned int addon);
+extern int httpSetQuantum(const char *quantumStr, void *data, unsigned int addon);
+extern int httpSetMessTime(const char *timeStr, void *data, unsigned int addon);
+extern int httpSetMessLimit(const char *limitStr, void *data, unsigned int addon);
 
 extern int httpSetup(void);
 extern int httpService(int freq);
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/tas/src/plugin.c olsrd-current/lib/tas/src/plugin.c
--- olsrd-0.5.3/lib/tas/src/plugin.c	2007-04-20 15:46:03.000000000 +0200
+++ olsrd-current/lib/tas/src/plugin.c	2007-09-03 00:17:00.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.8 2007/04/20 13:46:03 bernd67 Exp $
+ * $Id: plugin.c,v 1.9 2007/09/02 22:17:00 bernd67 Exp $
  */
 
 #include <string.h>
@@ -50,6 +50,7 @@
 #include "http.h"
 #include "glua.h"
 #include "glua_ext.h"
+#include "olsrd_plugin.h"
 
 #include <defs.h>
 #include <olsr.h>
@@ -67,6 +68,8 @@
 #include <mpr_selector_set.h>
 #include <duplicate_set.h>
 
+#define PLUGIN_INTERFACE_VERSION 5
+
 #define MESSAGE_TYPE 129
 
 int olsrd_plugin_interface_version(void);
@@ -462,7 +465,7 @@
 
 int olsrd_plugin_interface_version(void)
 {
-  return 4;
+  return PLUGIN_INTERFACE_VERSION;
 }
 
 int olsrd_plugin_init(void)
@@ -486,95 +489,23 @@
   return 0;
 }
 
-int olsrd_plugin_register_param(char *name, char *value)
-{
-  if (strcmp(name, "address") == 0)
-  {
-    if (httpSetAddress(value) < 0)
-      return 0;
-
-    return 1;
-  }
-
-  if (strcmp(name, "port") == 0)
-  {
-    if (httpSetPort(value) < 0)
-      return 0;
-
-    return 1;
-  }
-
-  if (strcmp(name, "rootdir") == 0)
-  {
-    if (httpSetRootDir(value) < 0)
-      return 0;
-
-    return 1;
-  }
-
-  if (strcmp(name, "workdir") == 0)
-  {
-    if (httpSetWorkDir(value) < 0)
-      return 0;
-
-    return 1;
-  }
-
-  if (strcmp(name, "indexfile") == 0)
-  {
-    httpSetIndexFile(value);
-    return 1;
-  }
-
-  if (strcmp(name, "user") == 0)
-  {
-    httpSetUser(value);
-    return 1;
-  }
+static const struct olsrd_plugin_parameters plugin_parameters[] = {
+    { .name = "address",   .set_plugin_parameter = &httpSetAddress,   .data = NULL },
+    { .name = "port",      .set_plugin_parameter = &httpSetPort,      .data = NULL },
+    { .name = "rootdir",   .set_plugin_parameter = &httpSetRootDir,   .data = NULL },
+    { .name = "workdir",   .set_plugin_parameter = &httpSetWorkDir,   .data = NULL },
+    { .name = "indexfile", .set_plugin_parameter = &httpSetIndexFile, .data = NULL },
+    { .name = "user",      .set_plugin_parameter = &httpSetUser,      .data = NULL },
+    { .name = "password",  .set_plugin_parameter = &httpSetPassword,  .data = NULL },
+    { .name = "sesstime",  .set_plugin_parameter = &httpSetSessTime,  .data = NULL },
+    { .name = "pubdir",    .set_plugin_parameter = &httpSetPubDir,    .data = NULL },
+    { .name = "quantum",   .set_plugin_parameter = &httpSetQuantum,   .data = NULL },
+    { .name = "messtime",  .set_plugin_parameter = &httpSetMessTime,  .data = NULL },
+    { .name = "messlimit", .set_plugin_parameter = &httpSetMessLimit, .data = NULL },
+};
 
-  if (strcmp(name, "password") == 0)
-  {
-    httpSetPassword(value);
-    return 1;
-  }
-
-  if (strcmp(name, "sesstime") == 0)
-  {
-    if (httpSetSessTime(value) < 0)
-      return 0;
-
-    return 1;
-  }
-
-  if (strcmp(name, "pubdir") == 0)
-  {
-    httpSetPubDir(value);
-    return 1;
-  }
-
-  if (strcmp(name, "quantum") == 0)
-  {
-    if (httpSetQuantum(value) < 0)
-      return 0;
-
-    return 1;
-  }
-
-  if (strcmp(name, "messtime") == 0)
-  {
-    if (httpSetMessTime(value) < 0)
-      return 0;
-
-    return 1;
-  }
-
-  if (strcmp(name, "messlimit") == 0)
-  {
-    if (httpSetMessLimit(value) < 0)
-      return 0;
-
-    return 1;
-  }
-
-  return 0;
+void olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size)
+{
+    *params = plugin_parameters;
+    *size = sizeof(plugin_parameters)/sizeof(*plugin_parameters);
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/tas/test.c olsrd-current/lib/tas/test.c
--- olsrd-0.5.3/lib/tas/test.c	2007-07-15 19:48:55.000000000 +0200
+++ olsrd-current/lib/tas/test.c	2007-09-03 00:17:00.000000000 +0200
@@ -37,7 +37,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: test.c,v 1.2 2007/07/15 17:48:55 bernd67 Exp $
+ * $Id: test.c,v 1.3 2007/09/02 22:17:00 bernd67 Exp $
  */
 
 #include "src/link.h"
@@ -88,7 +88,7 @@
         return 1;
       }
 
-      if (httpSetAddress(av[i]) < 0)
+      if (httpSetAddress(av[i], NULL, 0) < 0)
       {
         fprintf(stderr, "cannot set address\n");
         return 1;
@@ -104,7 +104,7 @@
         return 1;
       }
 
-      if (httpSetPort(av[i]) < 0)
+      if (httpSetPort(av[i], NULL, 0) < 0)
       {
         fprintf(stderr, "cannot set port\n");
         return 1;
@@ -120,7 +120,7 @@
         return 1;
       }
 
-      if (httpSetWorkDir(av[i]) < 0)
+      if (httpSetWorkDir(av[i], NULL, 0) < 0)
       {
         fprintf(stderr, "cannot set work directory\n");
         return 1;
@@ -136,7 +136,7 @@
         return 1;
       }
 
-      if (httpSetRootDir(av[i]) < 0)
+      if (httpSetRootDir(av[i], NULL, 0) < 0)
       {
         fprintf(stderr, "cannot set root directory\n");
         return 1;
@@ -152,7 +152,7 @@
         return 1;
       }
 
-      httpSetIndexFile(av[i]);
+      httpSetIndexFile(av[i], NULL, 0);
     }
 
     else if (strcmp(av[i], "--user") == 0)
@@ -164,7 +164,7 @@
         return 1;
       }
 
-      httpSetUser(av[i]);
+      httpSetUser(av[i], NULL, 0);
     }
 
     else if (strcmp(av[i], "--password") == 0)
@@ -176,7 +176,7 @@
         return 1;
       }
 
-      httpSetPassword(av[i]);
+      httpSetPassword(av[i], NULL, 0);
     }
 
     else if (strcmp(av[i], "--sess-time") == 0)
@@ -188,7 +188,7 @@
         return 1;
       }
 
-      if (httpSetSessTime(av[i]) < 0)
+      if (httpSetSessTime(av[i], NULL, 0) < 0)
       {
         fprintf(stderr, "cannot set session timeout\n");
         return 1;
@@ -204,7 +204,7 @@
         return 1;
       }
 
-      httpSetPubDir(av[i]);
+      httpSetPubDir(av[i], NULL, 0);
     }
 
     else if (strcmp(av[i], "--quantum") == 0)
@@ -216,7 +216,7 @@
         return 1;
       }
 
-      if (httpSetQuantum(av[i]) < 0)
+      if (httpSetQuantum(av[i], NULL, 0) < 0)
       {
         fprintf(stderr, "cannot set quantum\n");
         return 1;
@@ -232,7 +232,7 @@
         return 1;
       }
 
-      if (httpSetMessTime(av[i]) < 0)
+      if (httpSetMessTime(av[i], NULL, 0) < 0)
       {
         fprintf(stderr, "cannot set message timeout\n");
         return 1;
@@ -248,7 +248,7 @@
         return 1;
       }
 
-      if (httpSetMessLimit(av[i]) < 0)
+      if (httpSetMessLimit(av[i], NULL, 0) < 0)
       {
         fprintf(stderr, "cannot set message queue limit\n");
         return 1;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/lib/tas/version-script.txt olsrd-current/lib/tas/version-script.txt
--- olsrd-0.5.3/lib/tas/version-script.txt	2005-05-29 14:47:44.000000000 +0200
+++ olsrd-current/lib/tas/version-script.txt	2007-09-03 00:51:33.000000000 +0200
@@ -2,8 +2,8 @@
 {
   global:
     olsrd_plugin_interface_version;
-    olsrd_plugin_register_param;
     olsrd_plugin_init;
+    olsrd_get_plugin_parameters;
 
   local:
     *;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/make/Makefile.fbsd olsrd-current/make/Makefile.fbsd
--- olsrd-0.5.3/make/Makefile.fbsd	2007-07-26 19:34:54.000000000 +0200
+++ olsrd-current/make/Makefile.fbsd	2007-08-29 23:46:25.000000000 +0200
@@ -37,6 +37,7 @@
 		/sbin/ldconfig
 
 OS_LIB_PTHREAD = -pthread
+OS_CFLAG_PTHREAD = -pthread
 OS_LIB_DYNLOAD =
 
 # Local Variables:
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/make/Makefile.linux olsrd-current/make/Makefile.linux
--- olsrd-0.5.3/make/Makefile.linux	2007-08-02 18:26:55.000000000 +0200
+++ olsrd-current/make/Makefile.linux	2007-08-29 23:46:25.000000000 +0200
@@ -29,6 +29,7 @@
 endif
 
 OS_LIB_PTHREAD = -lpthread
+OS_CFLAG_PTHREAD = -pthread
 OS_LIB_DYNLOAD = -ldl
 
 # Local Variables:
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/make/Makefile.nbsd olsrd-current/make/Makefile.nbsd
--- olsrd-0.5.3/make/Makefile.nbsd	2007-07-26 19:34:54.000000000 +0200
+++ olsrd-current/make/Makefile.nbsd	2007-08-29 23:46:25.000000000 +0200
@@ -21,6 +21,7 @@
 endif
 
 OS_LIB_PTHREAD = 
+OS_CFLAG_PTHREAD =
 OS_LIB_DYNLOAD =
 
 # Local Variables:
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/make/Makefile.obsd olsrd-current/make/Makefile.obsd
--- olsrd-0.5.3/make/Makefile.obsd	2007-07-26 19:34:54.000000000 +0200
+++ olsrd-current/make/Makefile.obsd	2007-08-29 23:46:25.000000000 +0200
@@ -21,6 +21,7 @@
 endif
 
 OS_LIB_PTHREAD =
+OS_CFLAG_PTHREAD =
 OS_LIB_DYNLOAD =
 
 # Local Variables:
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/make/Makefile.osx olsrd-current/make/Makefile.osx
--- olsrd-0.5.3/make/Makefile.osx	2007-07-26 19:34:54.000000000 +0200
+++ olsrd-current/make/Makefile.osx	2007-08-29 23:46:26.000000000 +0200
@@ -25,6 +25,7 @@
 endif
 
 OS_LIB_PTHREAD =
+OS_CFLAG_PTHREAD =
 OS_LIB_DYNLOAD =
 
 # Local Variables:
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/make/Makefile.win32 olsrd-current/make/Makefile.win32
--- olsrd-0.5.3/make/Makefile.win32	2007-07-26 19:34:54.000000000 +0200
+++ olsrd-current/make/Makefile.win32	2007-08-29 23:46:26.000000000 +0200
@@ -23,6 +23,7 @@
 endif
 
 OS_LIB_PTHREAD =
+OS_CFLAG_PTHREAD =
 OS_LIB_DYNLOAD =
 
 olsr-$(VERS).zip:	gui/win32/release/Main.exe \
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/make/Makefile.wince olsrd-current/make/Makefile.wince
--- olsrd-0.5.3/make/Makefile.wince	2007-07-26 19:34:54.000000000 +0200
+++ olsrd-current/make/Makefile.wince	2007-08-29 23:46:26.000000000 +0200
@@ -19,6 +19,7 @@
 endif
 
 OS_LIB_PTHREAD =
+OS_CFLAG_PTHREAD =
 OS_LIB_DYNLOAD =
 
 # Local Variables:
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/Makefile olsrd-current/Makefile
--- olsrd-0.5.3/Makefile	2007-08-02 23:00:49.000000000 +0200
+++ olsrd-current/Makefile	2007-08-30 00:26:11.000000000 +0200
@@ -35,34 +35,33 @@
 # to the project. For more information see the website or contact
 # the copyright holders.
 #
-# $Id: Makefile,v 1.90 2007/08/02 20:53:20 bernd67 Exp $
+# $Id: Makefile,v 1.95 2007/08/29 22:26:11 bernd67 Exp $
 
-VERS =		0.5.3
-
-all:
+VERS =		0.5.4pre
 
 TOPDIR = .
 include Makefile.inc
 
 CPPFLAGS +=	-DVERSION=\"$(VERS)\"
 
+# pass generated variables to save time
 MAKECMD = $(MAKE) OS="$(OS)" WARNINGS="$(WARNINGS)"
 
-LIBS +=		$(OS_LIB_DYNLOAD)
+LIBS +=		$(OS_LIB_DYNLOAD) $(OS_LIB_PTHREAD)
 
 ifeq ($(OS), win32)
 LDFLAGS +=	-Wl,--out-implib=libolsrd.a -Wl,--export-all-symbols
 endif
 
-SWITCHDIR =     src/olsr_switch
+SWITCHDIR =	src/olsr_switch
 CFGDIR =	src/cfgparser
 CFGOBJS = 	$(CFGDIR)/oscan.o $(CFGDIR)/oparse.o $(CFGDIR)/olsrd_conf.o
-CFGDEPS = 	$(wildcard $(CFGDIR)/*.c) $(wildcard $(CFGDIR)/*.h) $(CFGDIR)/oparse.y $(CFGDIR)/oscan.lex
-TAG_SRCS = $(SRCS) $(HDRS) $(wildcard src/cfgparser/*.c) $(wildcard src/cfgparser/*.h) $(wildcard src/olsr_switch/*.c) $(wildcard src/olsr_switch/*.h)
+CFGDEPS = 	$(wildcard $(CFGDIR)/*.[ch]) $(CFGDIR)/oparse.y $(CFGDIR)/oscan.lex
+TAG_SRCS =	$(SRCS) $(HDRS) $(wildcard $(CFGDIR)/*.[ch] $(SWITCHDIR)/*.[ch])
 
-default_target: cfgparser olsrd
+default_target: cfgparser $(EXENAME)
 
-olsrd:		$(OBJS) $(CFGOBJS)
+$(EXENAME):	$(OBJS) $(CFGOBJS)
 		$(CC) $(LDFLAGS) -o $@ $(OBJS) $(CFGOBJS) $(LIBS)
 
 cfgparser:	$(CFGDEPS)
@@ -77,7 +76,10 @@
 .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
+		-rm -f $(OBJS) $(SRCS:%.c=%.d) $(EXENAME) $(EXENAME).exe
+ifeq ($(OS), win32)
+		-rm -f libolsrd.a
+endif
 		$(MAKECMD) -C $(CFGDIR) clean
 
 uberclean:	clean clean_libs
@@ -95,7 +97,7 @@
 
 install_olsrd:	install_bin
 		@echo ========= C O N F I G U R A T I O N - F I L E ============
-		@echo olsrd uses the configfile $(CFGFILE)
+		@echo $(EXENAME) uses the configfile $(CFGFILE)
 		@echo a default configfile. A sample RFC-compliance aimed
 		@echo configfile can be installed. Note that a LQ-based configfile
 		@echo can be found at files/olsrd.conf.default.lq
@@ -105,11 +107,11 @@
 		@echo -------------------------------------------
 		@echo Edit $(CFGFILE) before running olsrd!!
 		@echo -------------------------------------------
-		@echo Installing manpages olsrd\(8\) and olsrd.conf\(5\)
+		@echo Installing manpages $(EXENAME)\(8\) and $(CFGNAME)\(5\)
 		mkdir -p $(MANDIR)/man8/
-		cp files/olsrd.8.gz $(MANDIR)/man8/olsrd.8.gz
+		cp files/olsrd.8.gz $(MANDIR)/man8/$(EXENAME).8.gz
 		mkdir -p $(MANDIR)/man5/
-		cp files/olsrd.conf.5.gz $(MANDIR)/man5/olsrd.conf.5.gz
+		cp files/olsrd.conf.5.gz $(MANDIR)/man5/$(CFGNAME).5.gz
 
 tags:
 		$(TAGCMD) -o $(TAGFILE) $(TAG_SRCS)
@@ -181,6 +183,6 @@
 		$(MAKECMD) -C lib/quagga DESTDIR=$(DESTDIR) install 
 
 
-build_all:	cfgparser olsrd libs switch
+build_all:	all cfgparser $(EXENAME) switch libs
 install_all:	install install_libs
 clean_all:	uberclean clean_libs
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/Makefile.inc olsrd-current/Makefile.inc
--- olsrd-0.5.3/Makefile.inc	2007-08-02 14:31:38.000000000 +0200
+++ olsrd-current/Makefile.inc	2007-08-29 23:46:25.000000000 +0200
@@ -1,5 +1,5 @@
 # programs
-CCACHE ?=       $(shell sh -c "type -path ccache")
+CCACHE ?=       $(shell bash -c "type -path ccache")
 ifeq ($(origin CC),default)
 CC = 		$(CCACHE) gcc
 else
@@ -17,10 +17,11 @@
 LIBDIR  ?= $(DESTDIR)/usr/lib
 DOCDIR  ?= $(DESTDIR)/usr/share/doc
 MANDIR  ?= $(DESTDIR)/usr/share/man
-CFGFILE ?= $(ETCDIR)/olsrd.conf
 EXENAME ?= olsrd
+CFGNAME ?= $(EXENAME).conf
+CFGFILE ?= $(ETCDIR)/$(CFGNAME)
 
-CPPFLAGS =	-Isrc -I$(TOPDIR)/src 
+CPPFLAGS =	-Isrc -I$(TOPDIR)/src
 
 # add gcc warnings and optimizations if CFLAGS not set
 ifndef CFLAGS
@@ -48,7 +49,11 @@
 endif
 CFLAGS +=	$(WARNINGS)
 CFLAGS +=	-O2
-CFLAGS +=	-g
+#CFLAGS +=	-g
+CFLAGS +=	$(EXTRA_CFLAGS)
+
+# Must be specified along with -lpthread on linux
+CPPFLAGS +=	$(OS_CFLAG_PTHREAD)
 endif
 
 ifdef OLSRD_PLUGIN
@@ -72,8 +77,6 @@
 SRCS +=		$(wildcard src/*.c *.c)
 HDRS +=		$(wildcard src/*.h *.h)
 
-all: default_target
-
 # OS detection
 ifeq ($(OS),Windows_NT)
 OS := win32
@@ -85,8 +88,8 @@
 all: help
 else
 # include OS specifics
-include $(TOPDIR)/make/Makefile.$(OS)
 all: default_target
+include $(TOPDIR)/make/Makefile.$(OS)
 endif
 
 # one object for each source file
@@ -102,7 +105,7 @@
 
 # fully automatic and working dependency generation
 %.d: %.c
-	@$(CC) -M $(CPPFLAGS) "$<" | sed -e '1s|\($(*F)\)\.o[ :]*|$(*D)/\1.o $@: Makefile $(TOPDIR)$(if $(TOPDIR),/)Makefile.inc \\\n  |g' >"$@"
+	@$(CC) -M $(CPPFLAGS) "$<" | sed -e '1s|\($(*F)\)\.o[ :]*|$(*D)/\1.o $@: Makefile $(TOPDIR)$(if $(TOPDIR),/)Makefile.inc |g' >"$@"
 
 # we always need the includes and defines
 # for legacy since now
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/defs.h olsrd-current/src/defs.h
--- olsrd-0.5.3/src/defs.h	2007-05-02 10:06:28.000000000 +0200
+++ olsrd-current/src/defs.h	2007-08-20 01:00:22.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.60 2007/05/02 08:06:28 bernd67 Exp $
+ * $Id: defs.h,v 1.62 2007/08/19 23:00:22 bernd67 Exp $
  */
 
 
@@ -107,15 +107,15 @@
 /* First "argument" is NOT a pointer! */
 
 #define QUEUE_ELEM(pre, new) do { \
-    pre.next->prev = new;         \
-    new->next = pre.next;         \
-    new->prev = &pre;             \
-    pre.next = new;               \
+    (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;     \
+    (elem)->prev->next = (elem)->next;     \
+    (elem)->next->prev = (elem)->prev;     \
   } while (0)
 
 
@@ -132,6 +132,11 @@
 extern struct timeval now;	       /* current idea of time */
 extern struct tm *nowtm;	       /* current idea of time (in tm) */
 
+#if defined WIN32
+extern olsr_bool olsr_win32_end_request;
+extern olsr_bool olsr_win32_end_flag;
+#endif
+
 /*
  *IPC functions
  *These are moved to a plugin soon
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/hashing.c olsrd-current/src/hashing.c
--- olsrd-0.5.3/src/hashing.c	2007-08-02 16:47:26.000000000 +0200
+++ olsrd-current/src/hashing.c	2007-08-02 23:59:59.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: hashing.c,v 1.15 2007/08/02 14:47:26 bernd67 Exp $
+ * $Id: hashing.c,v 1.16 2007/08/02 21:59:59 bernd67 Exp $
  */
 
 #include "olsr_protocol.h"
@@ -58,7 +58,7 @@
         hash = v4x[0] ^ v4x[1] ^ v4x[2] ^ v4x[3];
     } else {
         /* IPv6 */
-        const char * const tmp = (char *)&address->v6;
+        const char * const tmp = (const char *)&address->v6;
         hash = ntohl(*tmp);
     }
     return hash & HASHMASK;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/hna_set.c olsrd-current/src/hna_set.c
--- olsrd-0.5.3/src/hna_set.c	2007-04-26 00:08:08.000000000 +0200
+++ olsrd-current/src/hna_set.c	2007-08-03 00:07:19.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.19 2007/04/25 22:08:08 bernd67 Exp $
+ * $Id: hna_set.c,v 1.20 2007/08/02 22:07:19 bernd67 Exp $
  */
 
 #include "defs.h"
@@ -55,7 +55,7 @@
 olsr_init_hna_set(void)
 {
 
-  int index;
+  int idx;
 
   if(olsr_cnf->ip_version == AF_INET)
     {
@@ -71,10 +71,10 @@
    */
   olsr_register_scheduler_event(&olsr_time_out_hna_set, NULL, 1, 0, NULL);
 
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
-      hna_set[index].next = &hna_set[index];
-      hna_set[index].prev = &hna_set[index];
+      hna_set[idx].next = &hna_set[idx];
+      hna_set[idx].prev = &hna_set[idx];
     }
 
   return 1;
@@ -267,13 +267,13 @@
 void
 olsr_time_out_hna_set(void *foo __attribute__((unused)))
 {
-  int index;
+  int idx;
 
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
-      struct hna_entry *tmp_hna = hna_set[index].next;
+      struct hna_entry *tmp_hna = hna_set[idx].next;
       /* Check all entrys */
-      while(tmp_hna != &hna_set[index])
+      while(tmp_hna != &hna_set[idx])
 	{
 	  /* Check all networks */
 	  struct hna_net *tmp_net = tmp_hna->networks.next;
@@ -321,7 +321,7 @@
 void
 olsr_print_hna_set(void)
 {
-  int index;
+  int idx;
 
   OLSR_PRINTF(1, "\n--- %02d:%02d:%02d.%02d ------------------------------------------------- HNA SET\n\n",
               nowtm->tm_hour,
@@ -334,11 +334,11 @@
   else
     OLSR_PRINTF(1, "IP net/prefixlen               GW IP\n");
 
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
-      struct hna_entry *tmp_hna = hna_set[index].next;
+      struct hna_entry *tmp_hna = hna_set[idx].next;
       /* Check all entrys */
-      while(tmp_hna != &hna_set[index])
+      while(tmp_hna != &hna_set[idx])
 	{
 	  /* Check all networks */
 	  struct hna_net *tmp_net = tmp_hna->networks.next;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/hysteresis.c olsrd-current/src/hysteresis.c
--- olsrd-0.5.3/src/hysteresis.c	2007-04-26 00:08:08.000000000 +0200
+++ olsrd-current/src/hysteresis.c	2007-08-03 00:07:19.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.20 2007/04/25 22:08:08 bernd67 Exp $
+ * $Id: hysteresis.c,v 1.21 2007/08/02 22:07:19 bernd67 Exp $
  */
 
 
@@ -164,16 +164,14 @@
 void
 update_hysteresis_incoming(union olsr_ip_addr *remote, struct interface *local, olsr_u16_t seqno)
 {
-  struct link_entry *link;
-
-  link = lookup_link_entry(remote, NULL, local);
+  struct link_entry *lnk = lookup_link_entry(remote, NULL, local);
 
   /* Calculate new quality */      
-  if(link != NULL)
+  if(lnk != NULL)
     {
-      link->L_link_quality = olsr_hyst_calc_stability(link->L_link_quality);
+      lnk->L_link_quality = olsr_hyst_calc_stability(lnk->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), lnk->L_link_quality);
 #endif
 
       /* 
@@ -183,26 +181,26 @@
        * been added to olsr_seqno there
        */
 
-      if (link->olsr_seqno_valid && 
-          (unsigned short)(seqno - link->olsr_seqno) < 100)
-	  while (link->olsr_seqno != seqno)
+      if (lnk->olsr_seqno_valid && 
+          (unsigned short)(seqno - lnk->olsr_seqno) < 100)
+	  while (lnk->olsr_seqno != seqno)
 	    {
-	      link->L_link_quality = olsr_hyst_calc_instability(link->L_link_quality);
+	      lnk->L_link_quality = olsr_hyst_calc_instability(lnk->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), lnk->L_link_quality);
 #endif
-	      if(link->L_link_quality < olsr_cnf->hysteresis_param.thr_low)
+	      if(lnk->L_link_quality < olsr_cnf->hysteresis_param.thr_low)
 		break;
 
-	      link->olsr_seqno++;
+	      lnk->olsr_seqno++;
 	    }
 
 
-      link->olsr_seqno = seqno + 1;
-      link->olsr_seqno_valid = OLSR_TRUE;
+      lnk->olsr_seqno = seqno + 1;
+      lnk->olsr_seqno_valid = OLSR_TRUE;
 
-      //printf("Updating seqno to: %d\n", link->olsr_seqno);
+      //printf("Updating seqno to: %d\n", lnk->olsr_seqno);
     }
   return;
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/interfaces.c olsrd-current/src/interfaces.c
--- olsrd-0.5.3/src/interfaces.c	2007-05-14 00:23:55.000000000 +0200
+++ olsrd-current/src/interfaces.c	2007-08-02 23:51:40.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.32 2007/05/13 22:23:55 bernd67 Exp $
+ * $Id: interfaces.c,v 1.33 2007/08/02 21:51:40 bernd67 Exp $
  */
 
 #include "defs.h"
@@ -226,7 +226,7 @@
  */
 
 struct interface *
-if_ifwithaddr(union olsr_ip_addr *addr)
+if_ifwithaddr(const union olsr_ip_addr * const addr)
 {
   struct interface *ifp;
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/interfaces.h olsrd-current/src/interfaces.h
--- olsrd-0.5.3/src/interfaces.h	2007-05-14 00:23:55.000000000 +0200
+++ olsrd-current/src/interfaces.h	2007-08-02 23:51:40.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.40 2007/05/13 22:23:55 bernd67 Exp $
+ * $Id: interfaces.h,v 1.41 2007/08/02 21:51:40 bernd67 Exp $
  */
 
 
@@ -206,7 +206,7 @@
 if_ifwithsock(int);
 
 struct interface *
-if_ifwithaddr(union olsr_ip_addr *);
+if_ifwithaddr(const union olsr_ip_addr *);
 
 struct interface *
 if_ifwithname(const char *);
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/ipc_frontend.c olsrd-current/src/ipc_frontend.c
--- olsrd-0.5.3/src/ipc_frontend.c	2007-08-01 18:19:48.000000000 +0200
+++ olsrd-current/src/ipc_frontend.c	2007-08-03 00:07:19.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.32 2007/08/01 16:19:48 bernd67 Exp $
+ * $Id: ipc_frontend.c,v 1.33 2007/08/02 22:07:19 bernd67 Exp $
  */
 
 /*
@@ -335,7 +335,7 @@
 {
   struct rt_entry  *destination;
   struct interface *ifn;
-  olsr_u8_t        index;
+  int               idx;
   struct ipcmsg packet;
   char *tmp;
   
@@ -343,10 +343,10 @@
   if(!ipc_active)
     return 0;
   
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
-      for(destination = routingtable[index].next;
-	  destination != &routingtable[index];
+      for(destination = routingtable[idx].next;
+	  destination != &routingtable[idx];
 	  destination = destination->next)
 	{
 	  ifn = destination->rt_if;
@@ -390,10 +390,10 @@
 	}
     }
 
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
-      for(destination = hna_routes[index].next;
-	  destination != &hna_routes[index];
+      for(destination = hna_routes[idx].next;
+	  destination != &hna_routes[idx];
 	  destination = destination->next)
 	{
 	  ifn = destination->rt_if;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/link_set.c olsrd-current/src/link_set.c
--- olsrd-0.5.3/src/link_set.c	2007-04-26 00:08:09.000000000 +0200
+++ olsrd-current/src/link_set.c	2007-08-19 22:37:41.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.68 2007/04/25 22:08:09 bernd67 Exp $
+ * $Id: link_set.c,v 1.70 2007/08/19 20:37:41 bernd67 Exp $
  */
 
 
@@ -198,14 +198,14 @@
   for(ifs = ifnet; ifs != NULL; ifs = ifs->int_next)
     {
       struct mid_address   *aliases;
-      struct link_entry  *link;
+      struct link_entry  *lnk = lookup_link_entry(main_addr, NULL, ifs);
 
       //printf("\tChecking %s->", olsr_ip_to_string(&ifs->ip_addr));
       //printf("%s : ", olsr_ip_to_string(main_addr)); 
-      if((link = lookup_link_entry(main_addr, NULL, ifs)) != NULL)
+      if(lnk != NULL)
 	{
 	  //printf("%d\n", lookup_link_status(link));
-	  if(lookup_link_status(link) == SYM_LINK)
+	  if(lookup_link_status(lnk) == SYM_LINK)
 	    return SYM_LINK;
 	}
       /* Get aliases */
@@ -215,11 +215,12 @@
 	{
 	  //printf("\tChecking %s->", olsr_ip_to_string(&ifs->ip_addr));
 	  //printf("%s : ", olsr_ip_to_string(&aliases->address)); 
-            if((link = lookup_link_entry(&aliases->alias, NULL, ifs)) != NULL)
+            lnk = lookup_link_entry(&aliases->alias, NULL, ifs);
+            if(lnk != NULL)
 	    {
 	      //printf("%d\n", lookup_link_status(link));
 
-	      if(lookup_link_status(link) == SYM_LINK)
+	      if(lookup_link_status(lnk) == SYM_LINK)
 		return SYM_LINK;
 	    }
 	}
@@ -793,23 +794,29 @@
 static int
 check_link_status(struct hello_message *message, struct interface *in_if)
 {
+  int ret = UNSPEC_LINK;
   struct hello_neighbor  *neighbors;
 
   neighbors = message->neighbors;
   
   while(neighbors!=NULL)
     {
+      /*
+       * Note: If a neigh has 2 cards we can reach, the neigh
+       * will send a Hello with the same IP mentined twice
+       */
       if(COMP_IP(&neighbors->address, &in_if->ip_addr))
         {
 	  //printf("ok");
-	  return neighbors->link;
+	  ret = neighbors->link;
+	  if (SYM_LINK == ret) break;
 	}
 
       neighbors = neighbors->next; 
     }
 
 
-  return UNSPEC_LINK;
+  return ret;
 }
 
 
@@ -978,19 +985,19 @@
 static void update_packet_loss_worker(struct link_entry *entry, int lost)
 {
   unsigned char mask = 1 << (entry->loss_index & 7);
-  int index = entry->loss_index >> 3;
+  const int idx = entry->loss_index >> 3;
   double rel_lq, saved_lq;
 
   if (lost == 0)
     {
       // packet not lost
 
-      if ((entry->loss_bitmap[index] & mask) != 0)
+      if ((entry->loss_bitmap[idx] & mask) != 0)
         {
           // but the packet that we replace was lost
           // => decrement packet loss
 
-          entry->loss_bitmap[index] &= ~mask;
+          entry->loss_bitmap[idx] &= ~mask;
           entry->lost_packets--;
         }
     }
@@ -999,12 +1006,12 @@
     {
       // packet lost
 
-      if ((entry->loss_bitmap[index] & mask) == 0)
+      if ((entry->loss_bitmap[idx] & mask) == 0)
         {
           // but the packet that we replace was not lost
           // => increment packet loss
 
-          entry->loss_bitmap[index] |= mask;
+          entry->loss_bitmap[idx] |= mask;
           entry->lost_packets++;
         }
     }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/linux/link_layer.c olsrd-current/src/linux/link_layer.c
--- olsrd-0.5.3/src/linux/link_layer.c	2007-04-26 00:08:17.000000000 +0200
+++ olsrd-current/src/linux/link_layer.c	2007-08-20 01:00:15.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.13 2007/04/25 22:08:17 bernd67 Exp $
+ * $Id: link_layer.c,v 1.14 2007/08/19 23:00:15 bernd67 Exp $
  */
 
 
@@ -69,14 +69,6 @@
 int
 add_spy_node(union olsr_ip_addr *, char *);
 
-
-extern char *
-sockaddr_to_string(struct sockaddr *);
-
-extern char *
-olsr_ip_to_string(union olsr_ip_addr *);
-
-
 #define	MAXIPLEN	60
 #define	MAXICMPLEN	76
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/lq_avl.c olsrd-current/src/lq_avl.c
--- olsrd-0.5.3/src/lq_avl.c	2007-07-06 00:43:46.000000000 +0200
+++ olsrd-current/src/lq_avl.c	2007-08-03 00:00:46.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.10 2007/07/05 22:43:46 bernd67 Exp $
+ * $Id: lq_avl.c,v 1.11 2007/08/02 22:00:46 bernd67 Exp $
  */
 
 #include <stddef.h>
@@ -53,7 +53,7 @@
  * dummy comparison pointer
  * set to zero for a fast inline ipv4 comparison
  */
-int (*avl_comp_default)(void *, void *) = 0;
+int (*avl_comp_default)(void *, void *) = NULL;
 
 int avl_comp_ipv4(void *ip1, void *ip2)
 {
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/lq_mpr.c olsrd-current/src/lq_mpr.c
--- olsrd-0.5.3/src/lq_mpr.c	2007-02-10 20:27:32.000000000 +0100
+++ olsrd-current/src/lq_mpr.c	2007-08-03 00:07:19.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: lq_mpr.c,v 1.12 2007/02/10 19:27:32 bernd67 Exp $
+ * $Id: lq_mpr.c,v 1.13 2007/08/02 22:07:19 bernd67 Exp $
  */
 
 #include "defs.h"
@@ -54,7 +54,6 @@
   struct neighbor_entry *neigh;
   double best, best_1hop;
   olsr_bool mpr_changes = OLSR_FALSE;
-  struct link_entry *link;
 
   for(i = 0; i < HASHSIZE; i++)
     {
@@ -108,12 +107,12 @@
 
               // determine the link quality of the direct link
 
-              link = get_best_link_to_neighbor(&neigh->neighbor_main_addr);
+              struct link_entry *lnk = get_best_link_to_neighbor(&neigh->neighbor_main_addr);
 
-	      if(!link)
+	      if (!lnk)
 		continue;
 
-              best_1hop = link->loss_link_quality * link->neigh_link_quality;
+              best_1hop = lnk->loss_link_quality * lnk->neigh_link_quality;
 
               // see wether we find a better route via an MPR
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/lq_packet.c olsrd-current/src/lq_packet.c
--- olsrd-0.5.3/src/lq_packet.c	2007-02-10 18:36:51.000000000 +0100
+++ olsrd-current/src/lq_packet.c	2007-08-30 01:08:54.000000000 +0200
@@ -38,7 +38,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: lq_packet.c,v 1.23 2007/02/10 17:36:51 bernd67 Exp $
+ * $Id: lq_packet.c,v 1.28 2007/08/29 23:08:54 bernd67 Exp $
  */
 
 #include "olsr_protocol.h"
@@ -56,20 +56,50 @@
 #include "olsr.h"
 #include "build_msg.h"
 
+
 olsr_bool lq_tc_pending = OLSR_FALSE;
 
 static unsigned char msg_buffer[MAXMESSAGESIZE - OLSR_HEADERSIZE];
 
+static inline void        pkt_get_u8(const olsr_u8_t **p, olsr_u8_t  *var)         { *var =       *(olsr_u8_t *)(*p);   *p += sizeof(olsr_u8_t); }
+static inline void       pkt_get_u16(const olsr_u8_t **p, olsr_u16_t *var)         { *var = ntohs(*(olsr_u16_t *)(*p)); *p += sizeof(olsr_u16_t); }
+static inline void       pkt_get_u32(const olsr_u8_t **p, olsr_u32_t *var)         { *var = ntohl(*(olsr_u32_t *)(p));  *p += sizeof(olsr_u32_t); }
+static inline void        pkt_get_s8(const olsr_u8_t **p, olsr_8_t  *var)          { *var =       *(olsr_8_t *)(*p);    *p += sizeof(olsr_8_t); }
+static inline void       pkt_get_s16(const olsr_u8_t **p, olsr_16_t *var)          { *var = ntohs(*(olsr_16_t *)(*p));  *p += sizeof(olsr_16_t); }
+static inline void       pkt_get_s32(const olsr_u8_t **p, olsr_32_t *var)          { *var = ntohl(*(olsr_32_t *)(*p));  *p += sizeof(olsr_32_t); }
+static inline void    pkt_get_double(const olsr_u8_t **p, double *var)             { *var = me_to_double(**p);          *p += sizeof(olsr_u8_t); }
+static inline void pkt_get_ipaddress(const olsr_u8_t **p, union olsr_ip_addr *var) { COPY_IP(var, *p);                  *p += olsr_cnf->ipsize; }
+static inline void        pkt_get_lq(const olsr_u8_t **p, double *var)             { *var = (double)**p / 255.0;        *p += sizeof(olsr_u8_t); }
+
+static inline void        pkt_ignore_u8(const olsr_u8_t **p) { *p += sizeof(olsr_u8_t); }
+static inline void       pkt_ignore_u16(const olsr_u8_t **p) { *p += sizeof(olsr_u16_t); }
+static inline void       pkt_ignore_u32(const olsr_u8_t **p) { *p += sizeof(olsr_u32_t); }
+static inline void        pkt_ignore_s8(const olsr_u8_t **p) { *p += sizeof(olsr_8_t); }
+static inline void       pkt_ignore_s16(const olsr_u8_t **p) { *p += sizeof(olsr_16_t); }
+static inline void       pkt_ignore_s32(const olsr_u8_t **p) { *p += sizeof(olsr_32_t); }
+static inline void pkt_ignore_ipaddress(const olsr_u8_t **p) { *p += olsr_cnf->ipsize; }
+
+static inline void        pkt_put_u8(olsr_u8_t **p, const olsr_u8_t  var)         { *(olsr_u8_t *)(*p)  = var;        *p += sizeof(olsr_u8_t); }
+static inline void       pkt_put_u16(olsr_u8_t **p, const olsr_u16_t var)         { *(olsr_u16_t *)(*p) = htons(var); *p += sizeof(olsr_u16_t); }
+static inline void       pkt_put_u32(olsr_u8_t **p, const olsr_u32_t var)         { *(olsr_u32_t *)(*p) = htonl(var); *p += sizeof(olsr_u32_t); }
+static inline void        pkt_put_s8(olsr_u8_t **p, const olsr_8_t  var)          { *(olsr_8_t *)(*p)   = var;        *p += sizeof(olsr_8_t); }
+static inline void       pkt_put_s16(olsr_u8_t **p, const olsr_16_t var)          { *(olsr_16_t *)(*p)  = htons(var); *p += sizeof(olsr_16_t); }
+static inline void       pkt_put_s32(olsr_u8_t **p, const olsr_32_t var)          { *(olsr_32_t *)(*p)  = htonl(var); *p += sizeof(olsr_32_t); }
+static inline void    pkt_put_double(olsr_u8_t **p, const double var)             { **p = double_to_me(var);          *p += sizeof(olsr_u8_t); }
+static inline void pkt_put_ipaddress(olsr_u8_t **p, const union olsr_ip_addr var) { COPY_IP(*p, &var);                *p += olsr_cnf->ipsize; }
+static inline void        pkt_put_lq(olsr_u8_t **p, const double var)             { **p  = var * 255.0;               *p += sizeof(olsr_u8_t); }
+
+
+
 static void
 create_lq_hello(struct lq_hello_message *lq_hello, struct interface *outif)
 {
-  struct lq_hello_neighbor *neigh;
   struct link_entry *walker;
 
   // initialize the static fields
 
   lq_hello->comm.type = LQ_HELLO_MESSAGE;
-  lq_hello->comm.vtime = ME_TO_DOUBLE(outif->valtimes.hello);
+  lq_hello->comm.vtime = me_to_double(outif->valtimes.hello);
   lq_hello->comm.size = 0;
 
   COPY_IP(&lq_hello->comm.orig, &olsr_cnf->main_addr);
@@ -88,11 +118,9 @@
   for (walker = get_link_set(); walker != NULL; walker = walker->next)
     {
       // allocate a neighbour entry
+      struct lq_hello_neighbor *neigh = olsr_malloc(sizeof (struct lq_hello_neighbor), "Build LQ_HELLO");
 
-      neigh = olsr_malloc(sizeof (struct lq_hello_neighbor), "Build LQ_HELLO");
-      
       // a) this neighbor interface IS NOT visible via the output interface
-
       if(!COMP_IP(&walker->local_iface_addr, &outif->ip_addr))
         neigh->link_type = UNSPEC_LINK;
       
@@ -147,10 +175,7 @@
 static void
 create_lq_tc(struct lq_tc_message *lq_tc, struct interface *outif)
 {
-  struct lq_tc_neighbor *neigh;
   int i;
-  struct neighbor_entry *walker;
-  struct link_entry *link;
   static int ttl_list[] = { 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1, MAX_TTL-1, 0};
 
   // remember that we have generated an LQ TC message; this is
@@ -161,7 +186,7 @@
   // initialize the static fields
 
   lq_tc->comm.type = LQ_TC_MESSAGE;
-  lq_tc->comm.vtime = ME_TO_DOUBLE(outif->valtimes.tc);
+  lq_tc->comm.vtime = me_to_double(outif->valtimes.tc);
   lq_tc->comm.size = 0;
 
   COPY_IP(&lq_tc->comm.orig, &olsr_cnf->main_addr);
@@ -196,9 +221,12 @@
   
   for(i = 0; i < HASHSIZE; i++)
     {
+      struct neighbor_entry *walker;
+      struct tc_mpr_addr    *neigh;
       for(walker = neighbortable[i].next; walker != &neighbortable[i];
           walker = walker->next)
         {
+          struct link_entry *lnk;
           // only consider symmetric neighbours
 
           if(walker->status != SYM)
@@ -211,26 +239,23 @@
             continue;
 
           // TC redundancy == 0: only consider MPR selectors
-
-          else if (olsr_cnf->tc_redundancy == 0 &&
-                   olsr_lookup_mprs_set(&walker->neighbor_main_addr) == NULL)
+          if (olsr_cnf->tc_redundancy == 0 &&
+              olsr_lookup_mprs_set(&walker->neighbor_main_addr) == NULL)
             continue;
 
-          // allocate a neighbour entry
-          
-          neigh = olsr_malloc(sizeof (struct lq_tc_neighbor), "Build LQ_TC");
-		
+          // allocate a neighbour entry          
+          neigh = olsr_malloc(sizeof (struct tc_mpr_addr), "Build LQ_TC");
+
           // set the entry's main address
 
-          COPY_IP(&neigh->main, &walker->neighbor_main_addr);
+          COPY_IP(&neigh->address, &walker->neighbor_main_addr);
 
           // set the entry's link quality
+          lnk = get_best_link_to_neighbor(&neigh->address);
 
-          link = get_best_link_to_neighbor(&neigh->main);
-
-          if (link) {
-            neigh->link_quality = link->loss_link_quality;
-            neigh->neigh_link_quality = link->neigh_link_quality;
+          if (lnk) {
+            neigh->link_quality = lnk->loss_link_quality;
+            neigh->neigh_link_quality = lnk->neigh_link_quality;
           }
 
           // queue the neighbour entry
@@ -244,7 +269,7 @@
 static void
 destroy_lq_tc(struct lq_tc_message *lq_tc)
 {
-  struct lq_tc_neighbor *walker, *aux;
+  struct tc_mpr_addr *walker, *aux;
 
   // loop through the queued neighbour entries and free them
 
@@ -265,14 +290,10 @@
 
 static void serialize_common(struct olsr_common *comm)
 {
-  struct olsr_header_v4 *olsr_head_v4;
-  struct olsr_header_v6 *olsr_head_v6;
-
-  // serialize an IPv4 OLSR message header
-
   if (olsr_cnf->ip_version == AF_INET)
     {
-      olsr_head_v4 = (struct olsr_header_v4 *)msg_buffer;
+      // serialize an IPv4 OLSR message header
+      struct olsr_header_v4 *olsr_head_v4 = (struct olsr_header_v4 *)msg_buffer;
 
       olsr_head_v4->type = comm->type;
       olsr_head_v4->vtime = double_to_me(comm->vtime);
@@ -283,46 +304,40 @@
       olsr_head_v4->ttl = comm->ttl;
       olsr_head_v4->hops = comm->hops;
       olsr_head_v4->seqno = htons(comm->seqno);
-
-      return;
     }
+  else
+    {
+      // serialize an IPv6 OLSR message header
+      struct olsr_header_v6 *olsr_head_v6 = (struct olsr_header_v6 *)msg_buffer;
 
-  // serialize an IPv6 OLSR message header
-
-  olsr_head_v6 = (struct olsr_header_v6 *)msg_buffer;
-
-  olsr_head_v6->type = comm->type;
-  olsr_head_v6->vtime = double_to_me(comm->vtime);
-  olsr_head_v6->size = htons(comm->size);
-
-  COPY_IP(&olsr_head_v6->orig, &comm->orig);
-
-  olsr_head_v6->ttl = comm->ttl;
-  olsr_head_v6->hops = comm->hops;
-  olsr_head_v6->seqno = htons(comm->seqno);
+      olsr_head_v6->type = comm->type;
+      olsr_head_v6->vtime = double_to_me(comm->vtime);
+      olsr_head_v6->size = htons(comm->size);
+
+      COPY_IP(&olsr_head_v6->orig, &comm->orig);
+
+      olsr_head_v6->ttl = comm->ttl;
+      olsr_head_v6->hops = comm->hops;
+      olsr_head_v6->seqno = htons(comm->seqno);
+    }
 }
 
 static void
 serialize_lq_hello(struct lq_hello_message *lq_hello, struct interface *outif)
 {
-  int off, rem, size, req;
-  struct lq_hello_header *head;
+  int rem, size, req;
   struct lq_hello_info_header *info_head;
   struct lq_hello_neighbor *neigh;
   unsigned char *buff;
   int is_first;
-  int i, j;
-
-  if (lq_hello == NULL || outif == NULL)
-    return;
+  int i;
 
   // leave space for the OLSR header
-
-  off = common_size();
+  int off = common_size();
 
   // initialize the LQ_HELLO header
 
-  head = (struct lq_hello_header *)(msg_buffer + off);
+  struct lq_hello_header *head = (struct lq_hello_header *)(msg_buffer + off);
 
   head->reserved = 0;
   head->htime = double_to_me(lq_hello->htime);
@@ -360,18 +375,17 @@
 
   for (i = 0; i <= MAX_NEIGH; i++) 
     {
-      for(j = 0; j <= MAX_LINK; j++)
+      static const int LINK_ORDER[] = {SYM_LINK, UNSPEC_LINK, ASYM_LINK, LOST_LINK};
+      unsigned int j;
+      for(j = 0; j < sizeof(LINK_ORDER) / sizeof(LINK_ORDER[0]); j++)
         {
-          if(j == HIDE_LINK)
-            continue;
-
           is_first = 1;
 
           // loop through neighbors
 
           for (neigh = lq_hello->neigh; neigh != NULL; neigh = neigh->next)
             {  
-              if (neigh->neigh_type != i || neigh->link_type != j)
+              if (neigh->neigh_type != i || neigh->link_type != LINK_ORDER[j])
                 continue;
 
               // we need space for an IP address plus link quality
@@ -395,7 +409,7 @@
 
                   lq_hello->comm.size = size + off;
 
-                  serialize_common((struct olsr_common *)lq_hello);
+                  serialize_common(&lq_hello->comm);
 
                   // finalize the info header
 
@@ -426,7 +440,7 @@
                   size += sizeof (struct lq_hello_info_header);
 
                   info_head->reserved = 0;
-                  info_head->link_code = CREATE_LINK_CODE(i, j);
+                  info_head->link_code = CREATE_LINK_CODE(i, LINK_ORDER[j]);
                 }
 
               // add the current neighbor's IP address
@@ -471,12 +485,9 @@
 {
   int off, rem, size;
   struct lq_tc_header *head;
-  struct lq_tc_neighbor *neigh;
+  struct tc_mpr_addr *neigh;
   unsigned char *buff;
 
-  if (lq_tc == NULL || outif == NULL)
-    return;
-
   // leave space for the OLSR header
 
   off = common_size();
@@ -544,17 +555,14 @@
         }
 
       // add the current neighbor's IP address
-
-      COPY_IP(buff + size, &neigh->main);
+      COPY_IP(buff + size, &neigh->address);
       size += olsr_cnf->ipsize;
 
       // add the corresponding link quality
-
       buff[size++] = (unsigned char)(neigh->link_quality * 255);
       buff[size++] = (unsigned char)(neigh->neigh_link_quality * 255);
 
       // pad
-
       buff[size++] = 0;
       buff[size++] = 0;
     }
@@ -568,179 +576,157 @@
   net_outbuffer_push(outif, msg_buffer, size + off);
 }
 
-static void *deserialize_common(struct olsr_common *comm, void *ser)
-{
-  struct olsr_header_v4 *olsr_head_v4;
-  struct olsr_header_v6 *olsr_head_v6;
-
-  // deserialize an IPv4 OLSR message header
-
-  if (olsr_cnf->ip_version == AF_INET)
-    {
-      olsr_head_v4 = (struct olsr_header_v4 *)ser;
-
-      comm->type = olsr_head_v4->type;
-      comm->vtime = ME_TO_DOUBLE(olsr_head_v4->vtime);
-      comm->size = ntohs(olsr_head_v4->size);
 
-      COPY_IP(&comm->orig, &olsr_head_v4->orig);
-
-      comm->ttl = olsr_head_v4->ttl;
-      comm->hops = olsr_head_v4->hops;
-      comm->seqno = ntohs(olsr_head_v4->seqno);
-
-      return (void *)(olsr_head_v4 + 1);
-    }
-
-  // deserialize an IPv6 OLSR message header
-
-  olsr_head_v6 = (struct olsr_header_v6 *)ser;
-
-  comm->type = olsr_head_v6->type;
-  comm->vtime = ME_TO_DOUBLE(olsr_head_v6->vtime);
-  comm->size = ntohs(olsr_head_v6->size);
-
-  COPY_IP(&comm->orig, &olsr_head_v6->orig);
-
-  comm->ttl = olsr_head_v6->ttl;
-  comm->hops = olsr_head_v6->hops;
-  comm->seqno = ntohs(olsr_head_v6->seqno);
-
-  return (void *)(olsr_head_v6 + 1);
-}
-
-static void
-deserialize_lq_hello(struct lq_hello_message *lq_hello, void *ser)
-{
-  struct lq_hello_header *head;
-  struct lq_hello_info_header *info_head;
-  unsigned char *curr, *limit, *limit2;
-  struct lq_hello_neighbor *neigh;
+static int
+deserialize_lq_hello(struct hello_message *hello,
+                     const void *ser)
+{
+    const unsigned char *limit;
+    olsr_u8_t type;
+    olsr_u16_t size;
   
-  lq_hello->neigh = NULL;
-
-  if (ser == NULL)
-    return;
-
-  head = (struct lq_hello_header *)
-    deserialize_common((struct olsr_common *)lq_hello, ser);
-
-  if (lq_hello->comm.type != LQ_HELLO_MESSAGE)
-    return;
-
-  limit = ((unsigned char *)ser) + lq_hello->comm.size;
-
-  lq_hello->htime = ME_TO_DOUBLE(head->htime);
-  lq_hello->will = head->will;
-
-  lq_hello->neigh = NULL;
+    const unsigned char *curr = ser;
+    pkt_get_u8(&curr, &type);
+    if (type != LQ_HELLO_MESSAGE) {
+        /* No need to do anything more */
+        return 1;
+    }
+    pkt_get_double(&curr, &hello->vtime);
+    pkt_get_u16(&curr, &size);
+
+    // Sven-Ola: Check the message source addr
+    if (!olsr_validate_address((const union olsr_ip_addr *)curr)) {
+        /* No need to do anything more */
+        return 1;
+    }
+    pkt_get_ipaddress(&curr, &hello->source_addr);
+
+    pkt_get_u8(&curr, &hello->ttl);
+    pkt_get_u8(&curr, &hello->hop_count);
+    pkt_get_u16(&curr, &hello->packet_seq_number);
+    pkt_ignore_u16(&curr);
+
+    pkt_get_double(&curr, &hello->htime);
+    pkt_get_u8(&curr, &hello->willingness);
+
+    hello->neighbors = NULL;
+    limit = ser + size;
+    while (curr < limit) {
+        struct lq_hello_info_header *info_head = (struct lq_hello_info_header *)curr;
+        const unsigned char *limit2 = curr + ntohs(info_head->size);
+
+        curr = (unsigned char *)(info_head + 1);      
+        while (curr < limit2) {
+            struct hello_neighbor *neigh = olsr_malloc(sizeof (struct hello_neighbor),
+                                                       "LQ_HELLO deserialization");
+            pkt_get_ipaddress(&curr, &neigh->address);
+
+            pkt_get_lq(&curr, &neigh->link_quality);
+            pkt_get_lq(&curr, &neigh->neigh_link_quality);
+            pkt_ignore_u16(&curr);
 
-  curr = (unsigned char *)(head + 1);
+            neigh->link   = EXTRACT_LINK(info_head->link_code);
+            neigh->status = EXTRACT_STATUS(info_head->link_code);
 
-  while (curr < limit)
-    {
-      info_head = (struct lq_hello_info_header *)curr;
-
-      limit2 = curr + ntohs(info_head->size);
-
-      curr = (unsigned char *)(info_head + 1);
-      
-      while (curr < limit2)
-        {
-          neigh = olsr_malloc(sizeof (struct lq_hello_neighbor),
-                              "LQ_HELLO deserialization");
-
-          COPY_IP(&neigh->addr, curr);
-          curr += olsr_cnf->ipsize;
-
-          neigh->link_quality = (double)*curr++ / 255.0;
-          neigh->neigh_link_quality = (double)*curr++ / 255.0;
-
-          curr += 2;
-
-          neigh->link_type = EXTRACT_LINK(info_head->link_code);
-          neigh->neigh_type = EXTRACT_STATUS(info_head->link_code);
-
-          neigh->next = lq_hello->neigh;
-          lq_hello->neigh = neigh;
+            neigh->next = hello->neighbors;
+            hello->neighbors = neigh;
         }
     }
+    return 0;
 }
 
-static void
-deserialize_lq_tc(struct lq_tc_message *lq_tc, void *ser,
+static int
+deserialize_lq_tc(struct tc_message *tc,
+                  const void *ser,
                   union olsr_ip_addr *from)
 {
-  struct lq_tc_header *head;
-  union olsr_ip_addr *addr;
-  unsigned char *curr, *limit;
-  struct lq_tc_neighbor *neigh;
-
-  lq_tc->neigh = NULL;
-
-  if (ser == NULL)
-    return;
-
-  head = (struct lq_tc_header *)
-    deserialize_common((struct olsr_common *)lq_tc, ser);
-
-  if (lq_tc->comm.type != LQ_TC_MESSAGE)
-    return;
-
-  limit = ((unsigned char *)ser) + lq_tc->comm.size;
-
-  addr = mid_lookup_main_addr(from);
-
-  if (addr == 0)
-    COPY_IP(&lq_tc->from, from);
-
-  else
-    COPY_IP(&lq_tc->from, addr);
-
-  lq_tc->ansn =  ntohs(head->ansn);
-
-  lq_tc->neigh = NULL;
-
-  curr = (unsigned char *)(head + 1);
-
-  while (curr < limit)
-    {
-      neigh = olsr_malloc(sizeof (struct lq_tc_neighbor),
-                          "LQ_TC deserialization");
+    const union olsr_ip_addr *addr;
+    olsr_u8_t type;
+    olsr_u16_t size;
+    const unsigned char *limit;
+
+    // convert received packet from transmission format into internal format
+    const unsigned char *curr = ser;
+    pkt_get_u8(&curr, &type);
+    if (type != LQ_TC_MESSAGE) {
+        /* No need to do anything more */
+        return 1;
+    }
+    pkt_get_double(&curr, &tc->vtime);
+    pkt_get_u16(&curr, &size);
+    // Sven-Ola: Check the message source addr
+    if (!olsr_validate_address((const union olsr_ip_addr *)curr)) {
+        /* No need to do anything more */
+        return 1;
+    }
+    pkt_get_ipaddress(&curr, &tc->originator);
+
+    addr = mid_lookup_main_addr(from);
+    if (addr == NULL) {
+        addr = from;
+    }
+    // Sven-Ola: Check the message source addr
+    if (!olsr_validate_address(addr)) {
+        return 1;
+    }
+    COPY_IP(&tc->source_addr, addr);
+
+    pkt_get_u8(&curr, &tc->ttl);
+    pkt_get_u8(&curr, &tc->hop_count);
+    pkt_get_u16(&curr, &tc->packet_seq_number);
+    pkt_get_u16(&curr, &tc->ansn);
+    pkt_ignore_u16(&curr);
+
+    tc->multipoint_relay_selector_address = NULL;
+    limit = ser + size;
+    while (curr < limit) {
+        struct tc_mpr_addr *neigh;
+
+        if (!olsr_validate_address((const union olsr_ip_addr *)curr)) {
+            /* Ignore the same amount as below  */
+            pkt_ignore_ipaddress(&curr);
+            pkt_ignore_u8(&curr);
+            pkt_ignore_u8(&curr);
+            pkt_ignore_u16(&curr);
+            continue;
+        }
 
-      COPY_IP(&neigh->main, curr);
-      curr += olsr_cnf->ipsize;
+        neigh = olsr_malloc(sizeof (struct tc_mpr_addr), "LQ_TC deserialization");
 
-      neigh->link_quality = (double)*curr++ / 255.0;
-      neigh->neigh_link_quality = (double)*curr++ / 255.0;
+        pkt_get_ipaddress(&curr, &neigh->address);
 
-      curr += 2;
+        pkt_get_lq(&curr, &neigh->link_quality);
+        pkt_get_lq(&curr, &neigh->neigh_link_quality);
+        pkt_ignore_u16(&curr);
 
-      neigh->next = lq_tc->neigh;
-      lq_tc->neigh = neigh;
+        neigh->next = tc->multipoint_relay_selector_address;
+        tc->multipoint_relay_selector_address = neigh;
     }
+    return 0;
 }
 
 void
 olsr_output_lq_hello(void *para)
 {
   struct lq_hello_message lq_hello;
-  struct interface *outif = (struct interface *)para;
+  struct interface *outif = para;
 
-  // create LQ_HELLO in internal format
+  if (outif == NULL) {
+    return;
+  }
 
+  // create LQ_HELLO in internal format
   create_lq_hello(&lq_hello, outif);
 
   // convert internal format into transmission format, send it
-
   serialize_lq_hello(&lq_hello, outif);
 
   // destroy internal format
-
   destroy_lq_hello(&lq_hello);
 
-  if(net_output_pending(outif))
+  if(net_output_pending(outif)) {
     net_output(outif);
+  }
 }
 
 void
@@ -748,167 +734,46 @@
 {
   static int prev_empty = 1;
   struct lq_tc_message lq_tc;
-  struct interface *outif = (struct interface *)para;
+  struct interface *outif = para;
 
+  if (outif == NULL) {
+    return;
+  }
   // create LQ_TC in internal format
 
   create_lq_tc(&lq_tc, outif);
 
   // a) the message is not empty
 
-  if (lq_tc.neigh != NULL)
-    {
+  if (lq_tc.neigh != NULL) {
       prev_empty = 0;
-
+      
       // convert internal format into transmission format, send it
-
       serialize_lq_tc(&lq_tc, outif);
-    }
 
   // b) this is the first empty message
-
-  else if (prev_empty == 0)
-    {
+  } else if (prev_empty == 0) {
       // initialize timer
 
-      set_empty_tc_timer(GET_TIMESTAMP((olsr_cnf->max_tc_vtime * 3) * 1000));
+      set_empty_tc_timer(GET_TIMESTAMP(olsr_cnf->max_tc_vtime * 3 * 1000));
 
       prev_empty = 1;
 
       // convert internal format into transmission format, send it
 
       serialize_lq_tc(&lq_tc, outif);
-    }
 
   // c) this is not the first empty message, send if timer hasn't fired
-
-  else if (!TIMED_OUT(get_empty_tc_timer()))
-    serialize_lq_tc(&lq_tc, outif);
-
+  } else if (!TIMED_OUT(get_empty_tc_timer())) {
+      serialize_lq_tc(&lq_tc, outif);
+  }
   // destroy internal format
 
   destroy_lq_tc(&lq_tc);
 
-  if(net_output_pending(outif) && TIMED_OUT(outif->fwdtimer))
+  if(net_output_pending(outif) && TIMED_OUT(outif->fwdtimer)) {
     set_buffer_timer(outif);
-}
-
-static void
-process_lq_hello(struct lq_hello_message *lq_hello, struct interface *inif,
-                 union olsr_ip_addr *from)
-{
-  struct hello_message hello;
-  struct lq_hello_neighbor *neigh;
-  struct hello_neighbor *new_neigh;
-
-  // Sven-Ola: Check the message source addr
-  if(!olsr_validate_address(&lq_hello->comm.orig))
-    {
-      return;
-    }
-
-  // XXX - translation is ugly; everybody should use lq_hello_message :-)
-
-  // move the static fields from LQ_HELLO to HELLO
-
-  hello.vtime = lq_hello->comm.vtime;
-  hello.htime = lq_hello->htime;
-
-  COPY_IP(&hello.source_addr, &lq_hello->comm.orig);
-
-  hello.packet_seq_number = lq_hello->comm.seqno;
-  hello.hop_count = lq_hello->comm.hops;
-  hello.ttl = lq_hello->comm.ttl;
-  hello.willingness = lq_hello->will;
-
-  hello.neighbors = NULL;
-
-  // move all LQ_HELLO neighbours to HELLO
-
-  for (neigh = lq_hello->neigh; neigh != NULL; neigh = neigh->next)
-    {
-      // Sven-Ola: Also check the neighbours
-      if(!olsr_validate_address(&neigh->addr)) continue;
-      
-      // allocate HELLO neighbour
-
-      new_neigh = olsr_malloc(sizeof (struct hello_neighbor),
-                              "LQ_HELLO translation");
-
-      // copy fields
-
-      new_neigh->status = neigh->neigh_type;
-      new_neigh->link = neigh->link_type;
-      new_neigh->link_quality = neigh->link_quality;
-      new_neigh->neigh_link_quality = neigh->neigh_link_quality;
-
-      COPY_IP(&new_neigh->address, &neigh->addr);
-
-      // queue HELLO neighbour
-
-      new_neigh->next = hello.neighbors;
-      hello.neighbors = new_neigh;
-    }
-
-  olsr_hello_tap(&hello, inif, from);
-}
-
-static void
-process_lq_tc(struct lq_tc_message *lq_tc, struct interface *inif,
-              union olsr_ip_addr *from, union olsr_message *ser)
-{
-  struct tc_message tc;
-  struct lq_tc_neighbor *neigh;
-  struct tc_mpr_addr *new_neigh;
-
-  // Sven-Ola: Check the message source addr
-  if(!olsr_validate_address(&lq_tc->from)||!olsr_validate_address(&lq_tc->comm.orig))
-    {
-      return;
-    }
-
-  // XXX - translation is ugly; everybody should use lq_tc_message :-)
-
-  // move the static fields from LQ_TC to TC
-
-  tc.vtime = lq_tc->comm.vtime;
-
-  COPY_IP(&tc.source_addr, &lq_tc->from);
-  COPY_IP(&tc.originator, &lq_tc->comm.orig);
-
-  tc.packet_seq_number = lq_tc->comm.seqno;
-  tc.hop_count = lq_tc->comm.hops;
-  tc.ttl = lq_tc->comm.ttl;
-  tc.ansn = lq_tc->ansn;
-
-  tc.multipoint_relay_selector_address = NULL;
-
-  // move all LQ_TC neighbours to TC
-
-  for (neigh = lq_tc->neigh; neigh != NULL; neigh = neigh->next)
-    {
-      // Sven-Ola: Also check the neighbours
-      if(!olsr_validate_address(&neigh->main)) continue;
-      
-      // allocate TC neighbour
-
-      new_neigh = olsr_malloc(sizeof (struct tc_mpr_addr),
-                              "LQ_TC translation");
-
-      // copy fields
-
-      new_neigh->link_quality = neigh->link_quality;
-      new_neigh->neigh_link_quality = neigh->neigh_link_quality;
-
-      COPY_IP(&new_neigh->address, &neigh->main);
-
-      // queue TC neighbour
-
-      new_neigh->next = tc.multipoint_relay_selector_address;
-      tc.multipoint_relay_selector_address = new_neigh;
-    }
-
-  olsr_tc_tap(&tc, inif, from, ser);
+  }
 }
 
 void
@@ -916,36 +781,29 @@
                     struct interface *inif,
                     union olsr_ip_addr *from)
 {
-  struct lq_hello_message lq_hello;
-
-  // convert received packet from transmission format into internal format
-
-  deserialize_lq_hello(&lq_hello, ser);
-
-  // process internal format
-
-  process_lq_hello(&lq_hello, inif, from);
-
-  // destroy internal format
+  struct hello_message hello;
 
-  destroy_lq_hello(&lq_hello);
+  if (ser == NULL) {
+    return;
+  }
+  if (deserialize_lq_hello(&hello, ser) != 0) {
+    return;
+  }
+  olsr_hello_tap(&hello, inif, from);
 }
 
 void
-olsr_input_lq_tc(union olsr_message *ser, struct interface *inif,
+olsr_input_lq_tc(union olsr_message *ser,
+                 struct interface *inif,
                  union olsr_ip_addr *from)
 {
-  struct lq_tc_message lq_tc;
-  
-  // convert received packet from transmission format into internal format
-
-  deserialize_lq_tc(&lq_tc, ser, from);
-
-  // process internal format
-
-  process_lq_tc(&lq_tc, inif, from, ser);
-
-  // destroy internal format
+  struct tc_message tc;
 
-  destroy_lq_tc(&lq_tc);
+  if (ser == NULL) {
+    return;
+  }
+  if (deserialize_lq_tc(&tc, ser, from) != 0) {
+    return;
+  }
+  olsr_tc_tap(&tc, inif, from, ser);
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/lq_packet.h olsrd-current/src/lq_packet.h
--- olsrd-0.5.3/src/lq_packet.h	2005-02-20 19:52:18.000000000 +0100
+++ olsrd-current/src/lq_packet.h	2007-08-30 00:57:17.000000000 +0200
@@ -36,13 +36,14 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: lq_packet.h,v 1.6 2005/02/20 18:52:18 kattemat Exp $
+ * $Id: lq_packet.h,v 1.8 2007/08/29 22:57:17 bernd67 Exp $
  */
 
 #ifndef _OLSR_LQ_PACKET_H
 #define _OLSR_LQ_PACKET_H
 
 #include "olsr_types.h"
+#include "packet.h"
 
 #define LQ_HELLO_MESSAGE      201
 #define LQ_TC_MESSAGE         202
@@ -123,21 +124,12 @@
 };
 
 // deserialized LQ_TC
-
-struct lq_tc_neighbor
-{
-  double                link_quality;
-  double                neigh_link_quality;
-  union olsr_ip_addr    main;
-  struct lq_tc_neighbor *next;
-};
-
 struct lq_tc_message
 {
   struct olsr_common    comm;
   union olsr_ip_addr    from;
   olsr_u16_t            ansn;
-  struct lq_tc_neighbor *neigh;
+  struct tc_mpr_addr    *neigh;
 };
 
 // serialized LQ_TC
@@ -158,4 +150,6 @@
 void olsr_input_lq_tc(union olsr_message *ser, struct interface *inif,
                       union olsr_ip_addr *from);
 
+extern olsr_bool lq_tc_pending;
+
 #endif
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/lq_route.c olsrd-current/src/lq_route.c
--- olsrd-0.5.3/src/lq_route.c	2007-07-06 00:43:46.000000000 +0200
+++ olsrd-current/src/lq_route.c	2007-08-03 00:07:19.000000000 +0200
@@ -38,7 +38,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: lq_route.c,v 1.47 2007/07/05 22:43:46 bernd67 Exp $
+ * $Id: lq_route.c,v 1.48 2007/08/02 22:07:19 bernd67 Exp $
  */
 
 #include "defs.h"
@@ -433,7 +433,6 @@
   struct tc_entry *tcsrc;
   struct topo_dst *tcdst;
   struct olsr_spf_vertex *vert, *myself;
-  struct link_entry *link;
   struct neighbor_entry *neigh;
   struct mid_address *mid_walker;
   float etx;
@@ -525,15 +524,15 @@
          neigh = neigh->next)
       if (neigh->status == SYM)
       {
-        link = get_best_link_to_neighbor(&neigh->neighbor_main_addr);
+        struct link_entry *lnk = get_best_link_to_neighbor(&neigh->neighbor_main_addr);
 
-	if(!link)
+	if(!lnk)
 	  continue;
 
-        if (link->loss_link_quality2 >= MIN_LINK_QUALITY &&
-            link->neigh_link_quality2 >= MIN_LINK_QUALITY)
+        if (lnk->loss_link_quality2 >= MIN_LINK_QUALITY &&
+            lnk->neigh_link_quality2 >= MIN_LINK_QUALITY)
           {
-            etx = 1.0 / (link->loss_link_quality2 * link->neigh_link_quality2);
+            etx = 1.0 / (lnk->loss_link_quality2 * lnk->neigh_link_quality2);
 
             olsr_spf_add_edge(&vertex_tree, &neigh->neighbor_main_addr, &olsr_cnf->main_addr, etx);
           }
@@ -606,7 +605,7 @@
   for (tree_node = avl_walk_first(&path_tree);
        tree_node != NULL;
        tree_node = avl_walk_next(tree_node)) {
-
+    struct link_entry *lnk;
     vert = tree_node->data;
 
     if (!vert->next_hop) {
@@ -616,17 +615,17 @@
 
     // find the best link to the one-hop neighbour
 
-    link = get_best_link_to_neighbor(vert->next_hop);
+    lnk = get_best_link_to_neighbor(vert->next_hop);
 
     // we may see NULL here, if the one-hop neighbour is not in the
     // link and neighbour sets any longer, but we have derived an edge
     // between us and the one-hop neighbour from the TC set
 
-    if (link != NULL)
+    if (lnk != NULL)
     {
       // find the interface for the found link
-      inter = link->if_name ? if_ifwithname(link->if_name) : 
-              if_ifwithaddr(&link->local_iface_addr);
+      inter = lnk->if_name ? if_ifwithname(lnk->if_name) : 
+              if_ifwithaddr(&lnk->local_iface_addr);
 
       // we may see NULL here if the interface is down, but we have
       // links that haven't timed out, yet
@@ -640,7 +639,7 @@
         // destination node
 
         if (olsr_lookup_routing_table(&vert->addr) == NULL)
-          olsr_insert_routing_table(&vert->addr, &link->neighbor_iface_addr,
+          olsr_insert_routing_table(&vert->addr, &lnk->neighbor_iface_addr,
                                     inter, vert->hops, vert->path_etx);
 
         // route addition, case B - add routes to the remaining interfaces
@@ -650,7 +649,7 @@
              mid_walker = mid_walker->next_alias)
           if (olsr_lookup_routing_table(&mid_walker->alias) == NULL)
             olsr_insert_routing_table(&mid_walker->alias,
-                                      &link->neighbor_iface_addr, inter, vert->hops, 
+                                      &lnk->neighbor_iface_addr, inter, vert->hops, 
                                       vert->path_etx);
 
         // XXX - we used to use olsr_lookup_routing_table() only here, but
@@ -663,9 +662,9 @@
         // router - e.g. in case the router's not the main address and it's
         // MID entry has timed out
 
-        if (olsr_lookup_routing_table(&link->neighbor_iface_addr) == NULL)
-          olsr_insert_routing_table(&link->neighbor_iface_addr,
-                                    &link->neighbor_iface_addr, inter, 1,
+        if (olsr_lookup_routing_table(&lnk->neighbor_iface_addr) == NULL)
+          olsr_insert_routing_table(&lnk->neighbor_iface_addr,
+                                    &lnk->neighbor_iface_addr, inter, 1,
                                     vert->path_etx);
       }
     }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/mantissa.c olsrd-current/src/mantissa.c
--- olsrd-0.5.3/src/mantissa.c	2005-05-25 15:36:26.000000000 +0200
+++ olsrd-current/src/mantissa.c	2007-08-28 22:45:17.000000000 +0200
@@ -36,10 +36,9 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: mantissa.c,v 1.8 2005/05/25 13:36:26 kattemat Exp $
+ * $Id: mantissa.c,v 1.9 2007/08/28 20:45:17 bernd67 Exp $
  */
 
-
 #include "mantissa.h"
 
 /**
@@ -58,38 +57,77 @@
  */
 
 olsr_u8_t
-double_to_me(double interval)
+double_to_me(const double interval)
 {
-  olsr_u8_t a, b;
-
-  b = 0;
+    olsr_u8_t a, b;
 
-  while(interval / VTIME_SCALE_FACTOR >= (1<<b))
-    b++;
+    /* It is sufficent to compare the integer part since we test on >=.
+     * So we have now only a floating point division and the rest of the loop
+     * are only integer operations.
+     */
+    const unsigned int unscaled_interval = interval / VTIME_SCALE_FACTOR;
+    b = 0;
+    while (unscaled_interval >= (1U << b)) {
+        b++;
+    }
 
-  if(b == 0)
-    {
-      a = 1;
-      b = 0;
-    } 
-  else 
-    {
-      b--;
-      if (b > 15)
-	{
-	  a = 15;
-	  b = 15;
-	} 
-      else 
-	{ 
-	  a = (int)(16*((double)interval/(VTIME_SCALE_FACTOR*(double)(1<<b))-1));
-	  while(a >= 16)
-	    {
-	      a -= 16;
-	      b++;
-	    }
-	}
+    if(b == 0) {
+        a = 1;
+        b = 0;
+    } else {
+        b--;
+        if (b > 15) {
+            a = 15;
+            b = 15;
+        } else {
+            /* And again some maths simplification from the former version:
+             *    a = 16 * ((double)interval / (VTIME_SCALE_FACTOR * (double)(1 << b)) - 1)
+             * Since interval is already double:
+             *    a = 16 * (interval / (VTIME_SCALE_FACTOR * (double)(1 << b)) - 1)
+             * first, we can get rid of parentheses and change the * to a /
+             *    a = 16 * (interval / VTIME_SCALE_FACTOR / (double)(1 << b) - 1)
+             * then we make an integer addition from the floating point addition
+             *    a = (int)(16.0 * interval / VTIME_SCALE_FACTOR / (double)(1 << b)) - 16
+             * and we loose an unnecessary cast
+             *    a = (int)(16.0 * interval / VTIME_SCALE_FACTOR / (1 << b)) - 16
+             */
+            a = (int)(16.0 * interval / VTIME_SCALE_FACTOR / (1 << b)) - 16;
+            b += a >> 4;
+            a &= 0x0f;
+        }
     }
-  //printf("Generated mantissa/exponent(%d/%d): %d from %f\n", a, b, (olsr_u8_t) (a*16+b), interval);  //printf("Resolves back to: %f\n", ME_TO_DOUBLE(((a<<4)|(b&0x0F))));
-  return (olsr_u8_t) ((a<<4)|(b&0x0F));
+    //printf("Generated mantissa/exponent(%d/%d): %d from %f\n", a, b, (olsr_u8_t) (a*16+b), interval);  //printf("Resolves back to: %f\n", me_to_double(((a<<4)|(b&0x0F))));
+    return (a << 4) | (b & 0x0F);
+}
+
+/**
+ * Function for converting a mantissa/exponent 8bit value back
+ * to double as described in RFC3626:
+ *
+ * value = C*(1+a/16)*2^b [in seconds]
+ *
+ *  where a is the integer represented by the four highest bits of the
+ *  field and b the integer represented by the four lowest bits of the
+ *  field.
+ *
+ * me is the 8 bit mantissa/exponent value
+ *
+ * To avoid expensive floating maths, we transform the equation:
+ *     value = C * (1 + a / 16) * 2^b
+ * first, we make an int addition from the floating point addition:
+ *     value = C * ((16 + a) / 16) * 2^b
+ * then we get rid of a pair of parentheses
+ *     value = C * (16 + a) / 16 * 2^b
+ * and now we make an int multiplication from the floating point one
+ *     value = C * (16 + a) * 2^b / 16
+ * so that we can make a shift from the multiplication
+ *     value = C * ((16 + a) << b) / 16
+ * and sionce C and 16 are constants
+ *     value = ((16 + a) << b) * C / 16
+ */
+double me_to_double(const olsr_u8_t me)
+{
+    const olsr_u8_t a = me >> 4;
+    const olsr_u8_t b = me & 0x0F;
+    return ((16 + a) << b) * VTIME_SCALE_FACTOR / 16.0;
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/mantissa.h olsrd-current/src/mantissa.h
--- olsrd-0.5.3/src/mantissa.h	2005-05-29 14:47:45.000000000 +0200
+++ olsrd-current/src/mantissa.h	2007-08-28 22:45:17.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: mantissa.h,v 1.9 2005/05/29 12:47:45 br1 Exp $
+ * $Id: mantissa.h,v 1.10 2007/08/28 20:45:17 bernd67 Exp $
  */
 
 
@@ -60,10 +60,8 @@
  * me is the 8 bit mantissa/exponent value
  *
  */
-#define ME_TO_DOUBLE(me) \
-  (double)(VTIME_SCALE_FACTOR*(1+(double)(me>>4)/16)*(double)(1<<(me&0x0F)))
+double me_to_double(const olsr_u8_t);
 
-olsr_u8_t
-double_to_me(double);
+olsr_u8_t double_to_me(const double);
 
 #endif
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/mid_set.c olsrd-current/src/mid_set.c
--- olsrd-0.5.3/src/mid_set.c	2007-04-26 00:08:09.000000000 +0200
+++ olsrd-current/src/mid_set.c	2007-08-02 23:50:22.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.20 2007/04/25 22:08:09 bernd67 Exp $
+ * $Id: mid_set.c,v 1.21 2007/08/02 21:50:22 bernd67 Exp $
  */
 
 #include "defs.h"
@@ -52,7 +52,7 @@
 struct mid_entry mid_set[HASHSIZE];
 struct mid_address reverse_mid_set[HASHSIZE];
 
-struct mid_entry *mid_lookup_entry_bymain(union olsr_ip_addr *adr);
+struct mid_entry *mid_lookup_entry_bymain(const union olsr_ip_addr *adr);
 
 /**
  * Initialize the MID set
@@ -62,7 +62,7 @@
 int
 olsr_init_mid_set(void)
 {
-  int index;
+  int idx;
 
   OLSR_PRINTF(5, "MID: init\n");
 
@@ -71,13 +71,13 @@
    */
   olsr_register_scheduler_event(&olsr_time_out_mid_set, NULL, 1, 0, NULL);
 
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
-      mid_set[index].next = &mid_set[index];
-      mid_set[index].prev = &mid_set[index];
+      mid_set[idx].next = &mid_set[idx];
+      mid_set[idx].prev = &mid_set[idx];
 
-      reverse_mid_set[index].next = &reverse_mid_set[index];
-      reverse_mid_set[index].prev = &reverse_mid_set[index];
+      reverse_mid_set[idx].next = &reverse_mid_set[idx];
+      reverse_mid_set[idx].prev = &reverse_mid_set[idx];
     }
 
   return 1;
@@ -96,7 +96,7 @@
  */
 
 void 
-insert_mid_tuple(union olsr_ip_addr *m_addr, struct mid_address *alias, float vtime)
+insert_mid_tuple(const union olsr_ip_addr *m_addr, struct mid_address *alias, float vtime)
 {
   struct mid_entry *tmp;
   struct mid_address *tmp_adr;
@@ -133,9 +133,9 @@
       alias->next_alias = tmp_adr;
       tmp->ass_timer = GET_TIMESTAMP(vtime*1000);
     }
-      /*Create new node*/
   else
     {
+      /*Create new node*/
       tmp = olsr_malloc(sizeof(struct mid_entry), "MID new alias");
 
       tmp->aliases = alias;
@@ -212,7 +212,7 @@
  *@return nada
  */
 void
-insert_mid_alias(union olsr_ip_addr *main_add, union olsr_ip_addr *alias, float vtime)
+insert_mid_alias(const union olsr_ip_addr *main_add, const union olsr_ip_addr *alias, float vtime)
 {
   struct mid_address *adr;
   struct neighbor_entry *ne_old, *ne_new;
@@ -260,9 +260,6 @@
   //print_mid_list();
 }
 
-
-
-
 /**
  *Lookup the main address for a alias address
  *
@@ -272,7 +269,7 @@
  *or NULL if not found
  */
 union olsr_ip_addr *
-mid_lookup_main_addr(union olsr_ip_addr *adr)
+mid_lookup_main_addr(const union olsr_ip_addr *adr)
 {
   olsr_u32_t hash;
   struct mid_address *tmp_list;
@@ -290,14 +287,13 @@
 
 }
 
-
 /* Find mid entry to an address.
  * @param adr the main address to search for
  *
  * @return a linked list of address structs
  */
 struct mid_entry *
-mid_lookup_entry_bymain(union olsr_ip_addr *adr)
+mid_lookup_entry_bymain(const union olsr_ip_addr *adr)
 {
   struct mid_entry *tmp_list;
   olsr_u32_t hash;
@@ -314,12 +310,9 @@
       if(COMP_IP(&tmp_list->main_addr, adr))
 	return tmp_list;
     }
-
-
   return NULL;
 }
 
-
 /*
  *Find all aliases for an address.
  *
@@ -328,7 +321,7 @@
  *@return a linked list of addresses structs
  */
 struct mid_address *
-mid_lookup_aliases(union olsr_ip_addr *adr)
+mid_lookup_aliases(const union olsr_ip_addr *adr)
 {
   struct mid_entry *tmp = mid_lookup_entry_bymain(adr);
   return tmp ? tmp->aliases : NULL;
@@ -343,7 +336,7 @@
  *@return 1 if the node was updated, 0 if not
  */
 int
-olsr_update_mid_table(union olsr_ip_addr *adr, float vtime)
+olsr_update_mid_table(const union olsr_ip_addr *adr, float vtime)
 {
   struct mid_entry *tmp_list = mid_set;
   olsr_u32_t hash;
@@ -378,7 +371,7 @@
  *@return nada
  */
 void
-olsr_prune_aliases(union olsr_ip_addr *m_addr, struct mid_alias *declared_aliases)
+olsr_prune_aliases(const union olsr_ip_addr *m_addr, struct mid_alias *declared_aliases)
 {
   struct mid_entry *entry;
   olsr_u32_t hash;
@@ -405,7 +398,7 @@
   registered_aliases = entry->aliases;
   previous_alias = NULL;
 
-  while(registered_aliases != 0)
+  while(registered_aliases != NULL)
     {
       struct mid_address *current_alias = registered_aliases;
       registered_aliases = registered_aliases->next_alias;
@@ -419,7 +412,7 @@
           declared_aliases = declared_aliases->next;
         }
 
-      if (declared_aliases == 0)
+      if (declared_aliases == NULL)
         {
           /* 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));
@@ -463,14 +456,13 @@
 void
 olsr_time_out_mid_set(void *foo __attribute__((unused)))
 {
-  int index;
-
+  int idx;
 
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
-      struct mid_entry *tmp_list = mid_set[index].next;
+      struct mid_entry *tmp_list = mid_set[idx].next;
       /*Traverse MID list*/
-      while(tmp_list != &mid_set[index])
+      while(tmp_list != &mid_set[idx])
 	{
 	  /*Check if the entry is timed out*/
 	  if(TIMED_OUT(tmp_list->ass_timer))
@@ -529,15 +521,15 @@
 void
 olsr_print_mid_set(void)
 {
-  int index;
+  int idx;
 
   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++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
-      struct mid_entry *tmp_list = mid_set[index].next;
+      struct mid_entry *tmp_list = mid_set[idx].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[idx].next; tmp_list != &mid_set[idx]; tmp_list = tmp_list->next)
 	{
 	  struct mid_address *tmp_addr;
           
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/mid_set.h olsrd-current/src/mid_set.h
--- olsrd-0.5.3/src/mid_set.h	2007-02-10 20:27:32.000000000 +0100
+++ olsrd-current/src/mid_set.h	2007-08-02 23:50:22.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: mid_set.h,v 1.14 2007/02/10 19:27:32 bernd67 Exp $
+ * $Id: mid_set.h,v 1.15 2007/08/02 21:50:22 bernd67 Exp $
  */
 
 
@@ -45,6 +45,7 @@
 
 #include "olsr_types.h"
 
+
 struct mid_address
 {
   union olsr_ip_addr  alias;
@@ -79,16 +80,16 @@
 olsr_init_mid_set(void);
 
 void 
-insert_mid_tuple(union olsr_ip_addr *, struct mid_address *, float);
+insert_mid_tuple(const union olsr_ip_addr *, struct mid_address *, float);
 
 void
-insert_mid_alias(union olsr_ip_addr *, union olsr_ip_addr *, float);
+insert_mid_alias(const union olsr_ip_addr *, const union olsr_ip_addr *, float);
 
 union olsr_ip_addr *
-mid_lookup_main_addr(union olsr_ip_addr *);
+mid_lookup_main_addr(const union olsr_ip_addr *);
 
 struct mid_address *
-mid_lookup_aliases(union olsr_ip_addr *);
+mid_lookup_aliases(const union olsr_ip_addr *);
 
 void
 olsr_print_mid_set(void);
@@ -97,10 +98,10 @@
 olsr_time_out_mid_set(void *);
 
 void
-olsr_prune_aliases(union olsr_ip_addr *m_addr, struct mid_alias *declared_aliases);
+olsr_prune_aliases(const union olsr_ip_addr *m_addr, struct mid_alias *declared_aliases);
 
 int
-olsr_update_mid_table(union olsr_ip_addr *, float);
+olsr_update_mid_table(const union olsr_ip_addr *, float);
 
 int
 mid_delete_node(struct mid_entry *);
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/neighbor_table.c olsrd-current/src/neighbor_table.c
--- olsrd-0.5.3/src/neighbor_table.c	2007-04-26 00:08:09.000000000 +0200
+++ olsrd-current/src/neighbor_table.c	2007-08-02 23:57:06.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.32 2007/04/25 22:08:09 bernd67 Exp $
+ * $Id: neighbor_table.c,v 1.33 2007/08/02 21:57:06 bernd67 Exp $
  */
 
 
@@ -89,8 +89,7 @@
   entry = neighbor->neighbor_2_list.next;
 
   while(entry != &neighbor->neighbor_2_list)
-    {
-      
+    {      
       if(COMP_IP(&entry->neighbor_2->neighbor_2_addr, address))
 	{
 	  /* Dequeue */
@@ -117,9 +116,8 @@
  *representing the two hop neighbor if found. NULL if not found.
  */
 struct neighbor_2_list_entry *
-olsr_lookup_my_neighbors(struct neighbor_entry *neighbor, union olsr_ip_addr *neighbor_main_address)
+olsr_lookup_my_neighbors(const struct neighbor_entry *neighbor, const union olsr_ip_addr *neighbor_main_address)
 {
-  
   struct neighbor_2_list_entry *entry;
   
   for(entry = neighbor->neighbor_2_list.next;
@@ -147,7 +145,7 @@
  */
 
 int
-olsr_delete_neighbor_table(union olsr_ip_addr *neighbor_addr)
+olsr_delete_neighbor_table(const union olsr_ip_addr *neighbor_addr)
 {  
   struct  neighbor_2_list_entry *two_hop_list, *two_hop_to_delete;
   olsr_u32_t                    hash;
@@ -178,9 +176,7 @@
 
   while(two_hop_list != &entry->neighbor_2_list)
     {
-      struct  neighbor_2_entry *two_hop_entry;
-
-      two_hop_entry = two_hop_list->neighbor_2;
+      struct neighbor_2_entry *two_hop_entry = two_hop_list->neighbor_2;
       
       two_hop_entry->neighbor_2_pointer--;
 
@@ -223,7 +219,7 @@
  *@return 0 if neighbor already exists 1 if inserted
  */
 struct neighbor_entry *
-olsr_insert_neighbor_table(union olsr_ip_addr *main_addr)
+olsr_insert_neighbor_table(const union olsr_ip_addr *main_addr)
 {
   olsr_u32_t             hash;
   struct neighbor_entry  *new_neigh;
@@ -273,35 +269,15 @@
  *address. NULL if not found.
  */
 struct neighbor_entry *
-olsr_lookup_neighbor_table(union olsr_ip_addr *dst)
+olsr_lookup_neighbor_table(const union olsr_ip_addr *dst)
 {
-  struct neighbor_entry  *entry;
-  olsr_u32_t             hash;
-  union olsr_ip_addr     *tmp_ip;
-
   /*
    *Find main address of node
    */
-  if((tmp_ip = mid_lookup_main_addr(dst)) != NULL)
+  union olsr_ip_addr *tmp_ip = mid_lookup_main_addr(dst);
+  if(tmp_ip != NULL)
     dst = tmp_ip;
-  
-  hash = olsr_hashing(dst);
-
-  
-  //printf("\nLookup %s\n", olsr_ip_to_string(dst));
-  for(entry = neighbortable[hash].next;
-      entry != &neighbortable[hash];
-      entry = entry->next)
-    {
-      //printf("Checking %s\n", olsr_ip_to_string(&neighbor_table_tmp->neighbor_main_addr));
-      if(COMP_IP(&entry->neighbor_main_addr, dst))
-	return entry;
-      
-    }
-  //printf("NOPE\n\n");
-
-  return NULL;
-
+  return olsr_lookup_neighbor_table_alias(dst);
 }
 
 
@@ -314,13 +290,10 @@
  *address. NULL if not found.
  */
 struct neighbor_entry *
-olsr_lookup_neighbor_table_alias(union olsr_ip_addr *dst)
+olsr_lookup_neighbor_table_alias(const union olsr_ip_addr *dst)
 {
   struct neighbor_entry  *entry;
-  olsr_u32_t             hash;
-  
-  hash = olsr_hashing(dst);
-
+  olsr_u32_t             hash = olsr_hashing(dst);
   
   //printf("\nLookup %s\n", olsr_ip_to_string(dst));
   for(entry = neighbortable[hash].next;
@@ -341,13 +314,13 @@
 
 
 int
-update_neighbor_status(struct neighbor_entry *entry, int link)
+update_neighbor_status(struct neighbor_entry *entry, int lnk)
 {
   /*
    * Update neighbor entry
    */
  
-  if(link == SYM_LINK)
+  if(lnk == SYM_LINK)
     {
       /* N_status is set to SYM */
       if(entry->status == NOT_SYM)
@@ -397,9 +370,7 @@
 void
 olsr_time_out_two_hop_neighbors(struct neighbor_entry  *neighbor)
 {
-  struct neighbor_2_list_entry *two_hop_list;
-
-  two_hop_list = neighbor->neighbor_2_list.next;
+  struct neighbor_2_list_entry *two_hop_list = neighbor->neighbor_2_list.next;
 
   while(two_hop_list != &neighbor->neighbor_2_list)
     {
@@ -414,7 +385,7 @@
 	  if(two_hop_entry->neighbor_2_pointer < 1)
 	    {
 	      DEQUEUE_ELEM(two_hop_entry);
-	      free((void *)two_hop_entry);
+	      free(two_hop_entry);
 	    }
 	  
 	  two_hop_to_delete = two_hop_list;
@@ -439,12 +410,12 @@
 void
 olsr_time_out_neighborhood_tables(void)
 {
-  olsr_u8_t index;
+  int idx;
   
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
       struct neighbor_entry *entry;
-      for(entry = neighbortable[index].next; entry != &neighbortable[index]; entry = entry->next)
+      for(entry = neighbortable[idx].next; entry != &neighbortable[idx]; entry = entry->next)
 	{	  
 	  olsr_time_out_two_hop_neighbors(entry);
 	}
@@ -485,11 +456,11 @@
       struct neighbor_entry *neigh;
       for(neigh = neighbortable[i].next; neigh != &neighbortable[i]; neigh = neigh->next)
 	{
-	  struct link_entry *link = get_best_link_to_neighbor(&neigh->neighbor_main_addr);
-	  if(link)
+	  struct link_entry *lnk = get_best_link_to_neighbor(&neigh->neighbor_main_addr);
+	  if(lnk)
             {
-              double best_lq = link->neigh_link_quality;
-              double inv_best_lq = link->loss_link_quality;
+              const double best_lq = lnk->neigh_link_quality;
+              const double inv_best_lq = lnk->loss_link_quality;
 
               OLSR_PRINTF(1, fstr, olsr_ip_to_string(&neigh->neighbor_main_addr),
                           inv_best_lq, best_lq,
@@ -501,13 +472,3 @@
         }
     }
 }
-
-
-
-
-
-
-
-
-
-
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/neighbor_table.h olsrd-current/src/neighbor_table.h
--- olsrd-0.5.3/src/neighbor_table.h	2005-05-29 14:47:45.000000000 +0200
+++ olsrd-current/src/neighbor_table.h	2007-08-02 23:57:06.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: neighbor_table.h,v 1.14 2005/05/29 12:47:45 br1 Exp $
+ * $Id: neighbor_table.h,v 1.15 2007/08/02 21:57:06 bernd67 Exp $
  */
 
 
@@ -86,19 +86,19 @@
 olsr_delete_neighbor_2_pointer(struct neighbor_entry *, union olsr_ip_addr *);
 
 struct neighbor_2_list_entry *
-olsr_lookup_my_neighbors(struct neighbor_entry *, union olsr_ip_addr *);
+olsr_lookup_my_neighbors(const struct neighbor_entry *, const union olsr_ip_addr *);
 
 int
-olsr_delete_neighbor_table(union olsr_ip_addr *);
+olsr_delete_neighbor_table(const union olsr_ip_addr *);
 
 struct neighbor_entry *
-olsr_insert_neighbor_table(union olsr_ip_addr *);
+olsr_insert_neighbor_table(const union olsr_ip_addr *);
 
 struct neighbor_entry *
-olsr_lookup_neighbor_table(union olsr_ip_addr *);
+olsr_lookup_neighbor_table(const union olsr_ip_addr *);
 
 struct neighbor_entry *
-olsr_lookup_neighbor_table_alias(union olsr_ip_addr *);
+olsr_lookup_neighbor_table_alias(const union olsr_ip_addr *);
 
 void
 olsr_time_out_two_hop_neighbors(struct neighbor_entry  *);
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/net_olsr.c olsrd-current/src/net_olsr.c
--- olsrd-0.5.3/src/net_olsr.c	2007-07-06 00:43:47.000000000 +0200
+++ olsrd-current/src/net_olsr.c	2007-08-28 22:10:16.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.24 2007/07/05 22:43:47 bernd67 Exp $
+ * $Id: net_olsr.c,v 1.28 2007/08/28 20:10:16 bernd67 Exp $
  */
 
 #include "net_olsr.h"
@@ -45,11 +45,11 @@
 #include "net_os.h"
 #include "print_packet.h"
 #include "link_set.h"
+#include "lq_packet.h"
+
 #include <stdlib.h>
 #include <assert.h>
 
-extern olsr_bool lq_tc_pending;
-
 static olsr_bool disp_pack_out = OLSR_FALSE;
 
 
@@ -102,40 +102,16 @@
 void
 init_net(void)
 {
-  /* 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)
-	    {
-	      fprintf(stderr, "Error converting fixed IP %s for deny rule!!\n",
-		      deny_ipv4_defaults[i]);
-	      continue;
-	    }
-	  olsr_add_invalid_address(&addr);
-	}
-    }
-  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)
-	    {
-	      fprintf(stderr, "Error converting fixed IP %s for deny rule!!\n",
-		      deny_ipv6_defaults[i]);
-	      continue;
-	    }
-	  olsr_add_invalid_address(&addr);
-	}
-
+  const char * const *defaults = olsr_cnf->ip_version == AF_INET ? deny_ipv4_defaults : deny_ipv6_defaults;
+  
+  for (; *defaults != NULL; defaults++) {
+    union olsr_ip_addr addr;
+    if(inet_pton(olsr_cnf->ip_version, *defaults, &addr) <= 0){
+      fprintf(stderr, "Error converting fixed IP %s for deny rule!!\n", *defaults);
+      continue;
     }
+    olsr_add_invalid_address(&addr);
+  }
 }
 
 /**
@@ -521,14 +497,12 @@
  * @return the prefix length
  */
 olsr_u16_t
-olsr_netmask_to_prefix(union olsr_ip_addr *adr)
+olsr_netmask_to_prefix(const union olsr_ip_addr *adr)
 {
-  olsr_u16_t prefix;
-  int i, tmp;
+  int i;
+  olsr_u16_t prefix = 0;
 
-  prefix = 0;
-
-  for(i = 0; i < 16; i++)
+  for (i = 0; i < 16; i++)
     {
       if(adr->v6.s6_addr[i] == 0xff)
 	{
@@ -536,6 +510,7 @@
 	}
       else
 	{
+          int tmp;
 	  for(tmp = adr->v6.s6_addr[i];
 	      tmp > 0;
 	      tmp = (tmp << 1) & 0xff)
@@ -562,12 +537,10 @@
  *@return a char pointer to the string containing the IP
  */
 char *
-sockaddr_to_string(struct sockaddr *address_to_convert)
+sockaddr_to_string(const struct sockaddr *address_to_convert)
 {
-  struct sockaddr_in           *address;
-  
-  address=(struct sockaddr_in *)address_to_convert; 
-  return(inet_ntoa(address->sin_addr));
+  const struct sockaddr_in *address = (const struct sockaddr_in *)address_to_convert; 
+  return inet_ntoa(address->sin_addr);
   
 }
 
@@ -612,7 +585,7 @@
 const char *
 olsr_ip_to_string(const union olsr_ip_addr *addr)
 {
-  static int index = 0;
+  static int idx = 0;
   static char buff[4][INET6_ADDRSTRLEN > INET_ADDRSTRLEN ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN];
   const char *ret;
 
@@ -625,24 +598,24 @@
 #if 0
       struct in_addr in;
       in.s_addr = addr->v4;
-      ret = inet_ntop(AF_INET, &in, buff[index], sizeof(buff[index]));
+      ret = inet_ntop(AF_INET, &in, buff[idx], sizeof(buff[idx]));
 #else
-      ret = inet_ntop(AF_INET, &addr->v6, buff[index], sizeof(buff[index]));
+      ret = inet_ntop(AF_INET, &addr->v4, buff[idx], sizeof(buff[idx]));
 #endif
     }
   else
     {
       /* IPv6 */
-      ret = inet_ntop(AF_INET6, &addr->v6, buff[index], sizeof(buff[index]));
+      ret = inet_ntop(AF_INET6, &addr->v6, buff[idx], sizeof(buff[idx]));
     }
-  index = (index + 1) & 3;
+  idx = (idx + 1) & 3;
 
   return ret;
 }
 
 
 void
-olsr_add_invalid_address(union olsr_ip_addr *adr)
+olsr_add_invalid_address(const union olsr_ip_addr *adr)
 {
   struct deny_address_entry *new_entry;
 
@@ -667,9 +640,9 @@
  *@return a char pointer to the string containing the IP
  */
 olsr_bool
-olsr_validate_address(union olsr_ip_addr *adr)
+olsr_validate_address(const union olsr_ip_addr *adr)
 {
-  struct deny_address_entry *deny_entry = deny_entries;
+  const struct deny_address_entry *deny_entry = deny_entries;
 
   while(deny_entry)
     {
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/net_olsr.h olsrd-current/src/net_olsr.h
--- olsrd-0.5.3/src/net_olsr.h	2007-04-26 00:08:09.000000000 +0200
+++ olsrd-current/src/net_olsr.h	2007-08-20 20:46:03.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.9 2007/04/25 22:08:09 bernd67 Exp $
+ * $Id: net_olsr.h,v 1.10 2007/08/20 18:46:03 bernd67 Exp $
  */
 
 
@@ -88,10 +88,10 @@
 olsr_prefix_to_netmask(union olsr_ip_addr *, olsr_u16_t);
 
 olsr_u16_t
-olsr_netmask_to_prefix(union olsr_ip_addr *);
+olsr_netmask_to_prefix(const union olsr_ip_addr *);
 
 char *
-sockaddr_to_string(struct sockaddr *);
+sockaddr_to_string(const struct sockaddr *);
 
 const char *
 ip_to_string(const olsr_u32_t *);
@@ -109,9 +109,9 @@
 del_ptf(packet_transform_function);
 
 olsr_bool
-olsr_validate_address(union olsr_ip_addr *);
+olsr_validate_address(const union olsr_ip_addr *);
 
 void
-olsr_add_invalid_address(union olsr_ip_addr *);
+olsr_add_invalid_address(const union olsr_ip_addr *);
 
 #endif
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/olsrd_plugin.h olsrd-current/src/olsrd_plugin.h
--- olsrd-0.5.3/src/olsrd_plugin.h	2007-07-15 21:29:37.000000000 +0200
+++ olsrd-current/src/olsrd_plugin.h	2007-08-25 21:48:42.000000000 +0200
@@ -29,7 +29,7 @@
  *
  */
 
-/* $Id: olsrd_plugin.h,v 1.3 2007/07/15 19:29:37 bernd67 Exp $ */
+/* $Id: olsrd_plugin.h,v 1.4 2007/08/25 19:48:42 bernd67 Exp $ */
 
 /*
  * Example plugin for olsrd.org OLSR daemon
@@ -78,12 +78,13 @@
 
 /* Interface version 5 */
 
-typedef int (*set_plugin_parameter)(const char *value, void *data);
+typedef int (*set_plugin_parameter)(const char *value, void *data, unsigned int addon);
 
 struct olsrd_plugin_parameters {
     const char *name;
     set_plugin_parameter set_plugin_parameter;
     void *data;
+    unsigned int addon;
 };
 
 /**
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/packet.c olsrd-current/src/packet.c
--- olsrd-0.5.3/src/packet.c	2007-04-26 00:08:09.000000000 +0200
+++ olsrd-current/src/packet.c	2007-08-03 00:07:19.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.22 2007/04/25 22:08:09 bernd67 Exp $
+ * $Id: packet.c,v 1.23 2007/08/02 22:07:19 bernd67 Exp $
  */
 
 
@@ -90,8 +90,7 @@
   struct hello_neighbor   *message_neighbor, *tmp_neigh;
   struct link_entry       *links;
   struct neighbor_entry   *neighbor;
-  olsr_u16_t              index;
-  int                     link;
+  int                     idx;
 
 #ifdef DEBUG
   OLSR_PRINTF(3, "\tBuilding HELLO on interface %d\n", outif->if_nr);
@@ -123,8 +122,7 @@
 
   while(links != NULL)
     {      
-      
-      link = lookup_link_status(links);
+      int lnk = lookup_link_status(links);
       /* Update the status */
       
       /* Check if this link tuple is registered on the outgoing interface */
@@ -138,7 +136,7 @@
       
 
       /* Find the link status */
-      message_neighbor->link = link;
+      message_neighbor->link = lnk;
 
       /*
        * Calculate neighbor status
@@ -213,10 +211,10 @@
   /* Add the rest of the neighbors if running on multiple interfaces */
   
   if(ifnet != NULL && ifnet->int_next != NULL)
-    for(index=0;index<HASHSIZE;index++)
+    for(idx=0;idx<HASHSIZE;idx++)
       {       
-	for(neighbor = neighbortable[index].next;
-	    neighbor != &neighbortable[index];
+	for(neighbor = neighbortable[idx].next;
+	    neighbor != &neighbortable[idx];
 	    neighbor=neighbor->next)
 	  {
 	    /* Check that the neighbor is not added yet */
@@ -339,12 +337,11 @@
 int
 olsr_build_tc_packet(struct tc_message *message)
 {
-  struct tc_mpr_addr        *message_mpr;
+  struct tc_mpr_addr     *message_mpr;
   //struct mpr_selector       *mprs;
-  olsr_u8_t              index;
+  int                     idx;
   struct neighbor_entry  *entry;
   //struct mpr_selector_hash  *mprs_hash;
-  //olsr_u16_t          index;
   olsr_bool entry_added = OLSR_FALSE;
 
   message->multipoint_relay_selector_address=NULL;
@@ -359,10 +356,10 @@
   
 
   /* Loop trough all neighbors */  
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
-      for(entry = neighbortable[index].next;
-	  entry != &neighbortable[index];
+      for(entry = neighbortable[idx].next;
+	  entry != &neighbortable[idx];
 	  entry = entry->next)
 	{
 	  if(entry->status != SYM)
@@ -417,7 +414,7 @@
 	  
 	    } /* Switch */
 	} /* For */
-    } /* For index */
+    } /* For idx */
 
   if(entry_added)
     {
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/plugin_loader.c olsrd-current/src/plugin_loader.c
--- olsrd-0.5.3/src/plugin_loader.c	2007-08-01 18:16:05.000000000 +0200
+++ olsrd-current/src/plugin_loader.c	2007-08-31 00:25: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.29 2007/08/01 16:16:05 bernd67 Exp $
+ * $Id: plugin_loader.c,v 1.31 2007/08/30 22:25:13 bernd67 Exp $
  */
 
 #include "plugin_loader.h"
@@ -211,7 +211,8 @@
 
         plugin->register_param = dlsym(plugin->dlhandle, "olsrd_plugin_register_param");
         if(plugin->register_param == NULL) {
-            OLSR_PRINTF(1, "FAILED: \"%s\"\n", dlerror());
+            OLSR_PRINTF(0, "FAILED: \"%s\"\n", dlerror());
+            return -1;
         } else {
             OLSR_PRINTF(1, "OK\n");
         }
@@ -248,9 +249,12 @@
             unsigned int i;
             int rc = 0;
             for (i = 0; i < entry->plugin_parameters_size; i++) {
-                if (strcasecmp(entry->plugin_parameters[i].name, params->key) == 0) {
+                if (0 == entry->plugin_parameters[i].name[0] ||
+                    0 == strcasecmp(entry->plugin_parameters[i].name, params->key))
+                {
                     /* we have found it! */
-                    rc = entry->plugin_parameters[i].set_plugin_parameter(params->value, entry->plugin_parameters[i].data);
+                    rc = entry->plugin_parameters[i].set_plugin_parameter(params->value, entry->plugin_parameters[i].data,
+                        0 == entry->plugin_parameters[i].name[0] ? (unsigned int)params->key : entry->plugin_parameters[i].addon);
                     if (rc != 0) {
                         fprintf(stderr, "\nFatal error in plugin parameter \"%s\"/\"%s\"\n", params->key, params->value);
                         rv = -1;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/plugin_util.c olsrd-current/src/plugin_util.c
--- olsrd-0.5.3/src/plugin_util.c	2007-07-20 14:25:56.000000000 +0200
+++ olsrd-current/src/plugin_util.c	2007-09-02 23:04:42.000000000 +0200
@@ -1,6 +1,7 @@
 /*
  * The olsr.org Optimized Link-State Routing daemon(olsrd)
  * Copyright (c) 2007, Bernd Petrovitsch <bernd@firmix.at>
+ * Copyright (c) 2007, Sven-Ola <sven-ola@gmx.de>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without 
@@ -36,14 +37,14 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: plugin_util.c,v 1.2 2007/07/20 12:25:56 bernd67 Exp $
+ * $Id: plugin_util.c,v 1.4 2007/09/02 21:04:42 bernd67 Exp $
  */
 
 #include "plugin_util.h"
 #include "olsr.h"
 #include "defs.h"
 
-int set_plugin_port(const char *value, void *data)
+int set_plugin_port(const char *value, void *data, unsigned int addon __attribute__((unused)))
 {
     char *endptr;
     const unsigned int port = strtoul(value, &endptr, 0);
@@ -65,7 +66,7 @@
     return 0;
 }
 
-int set_plugin_ipaddress(const char *value, void *data)
+int set_plugin_ipaddress(const char *value, void *data, unsigned int addon __attribute__((unused)))
 {
     char buf[INET6_ADDRSTRLEN];
     union olsr_ip_addr ip_addr;
@@ -85,7 +86,7 @@
 }
 
 
-int set_boolean(const char *value, void *data)
+int set_boolean(const char *value, void *data, unsigned int addon __attribute__((unused)))
 {
     int *v = data;
     if (strcasecmp (value, "yes") == 0) {
@@ -98,6 +99,40 @@
     return 0;
 }
 
+int set_plugin_int(const char *value, void *data, unsigned int addon __attribute__((unused)))
+{
+    char *endptr;
+    const int theint = strtol(value, &endptr, 0);
+    if (*endptr != '\0' || endptr == value) {
+        OLSR_PRINTF(0, "Illegal int \"%s\"", value);
+        return 1;
+    }
+    if (data != NULL) {
+        int *v = data;
+        *v = theint;
+        OLSR_PRINTF(1, "%s int %d\n", "Got", theint);
+    } else {
+        OLSR_PRINTF(0, "%s int %d\n", "Ignored", theint);
+    }
+    return 0;
+}
+
+int set_plugin_string(const char *value, void *data, unsigned int addon)
+{
+    if (data != NULL) {
+        char *v = data;
+        if (strlen(value) >= addon) {
+            OLSR_PRINTF(0, "String too long \"%s\"", value);
+            return 1;
+        }
+        strcpy(v, value);
+        OLSR_PRINTF(1, "%s string %s\n", "Got", value);
+    } else {
+        OLSR_PRINTF(0, "%s string %s\n", "Ignored", value);
+    }
+    return 0;
+}
+
 /*
  * Local Variables:
  * mode: c
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/plugin_util.h olsrd-current/src/plugin_util.h
--- olsrd-0.5.3/src/plugin_util.h	2007-07-15 19:46:46.000000000 +0200
+++ olsrd-current/src/plugin_util.h	2007-08-25 21:48:42.000000000 +0200
@@ -28,7 +28,7 @@
  *
  */
 
-/* $Id: plugin_util.h,v 1.1 2007/07/15 17:46:46 bernd67 Exp $ */
+/* $Id: plugin_util.h,v 1.2 2007/08/25 19:48:42 bernd67 Exp $ */
 
 /*
  * Example plugin for olsrd.org OLSR daemon
@@ -39,9 +39,11 @@
 #define _OLSRD_PLUGIN_UTIL
 
 /* Common/utility functions for plugins */
-int set_plugin_port(const char *value, void *data);
-int set_plugin_ipaddress(const char *value, void *data);
-int set_boolean(const char *value, void *data);
+int set_plugin_port(const char *value, void *data, unsigned int);
+int set_plugin_ipaddress(const char *value, void *data, unsigned int);
+int set_boolean(const char *value, void *data, unsigned int);
+int set_plugin_int(const char *value, void *data, unsigned int);
+int set_plugin_string(const char *value, void *data, unsigned int);
 
 
 #endif
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/print_packet.c olsrd-current/src/print_packet.c
--- olsrd-0.5.3/src/print_packet.c	2007-04-22 22:25:48.000000000 +0200
+++ olsrd-current/src/print_packet.c	2007-08-28 22:45:17.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.10 2007/04/22 20:25:48 bernd67 Exp $
+ * $Id: print_packet.c,v 1.11 2007/08/28 20:45:17 bernd67 Exp $
  */
 
 #include "print_packet.h"
@@ -109,7 +109,7 @@
   fprintf(handle, "    Type: %s, size: %d, vtime: %0.2f\n", 
 	  olsr_msgtype_to_string(msg->v4.olsr_msgtype), 
 	  ntohs(msg->v4.olsr_msgsize),
-	  ME_TO_DOUBLE(msg->v4.olsr_vtime));
+	  me_to_double(msg->v4.olsr_vtime));
   fprintf(handle, "    TTL: %d, Hopcnt: %d, seqno: %d\n",
 	  (olsr_cnf->ip_version == AF_INET) ? msg->v4.ttl : msg->v6.ttl,
 	  (olsr_cnf->ip_version == AF_INET) ? msg->v4.hopcnt : msg->v6.hopcnt,
@@ -192,7 +192,7 @@
   union olsr_ip_addr *haddr;
   int hellosize = totsize - ((olsr_cnf->ip_version == AF_INET) ? OLSR_MSGHDRSZ_IPV4 : OLSR_MSGHDRSZ_IPV6);
 
-  fprintf(handle, "    +Htime: %0.2f\n", ME_TO_DOUBLE(data[2]));
+  fprintf(handle, "    +Htime: %0.2f\n", me_to_double(data[2]));
 
   fprintf(handle, "    +Willingness: %d\n", data[3]);
 
@@ -259,7 +259,7 @@
   union olsr_ip_addr *haddr;
   int hellosize = totsize - ((olsr_cnf->ip_version == AF_INET) ? OLSR_MSGHDRSZ_IPV4 : OLSR_MSGHDRSZ_IPV6);
 
-  fprintf(handle, "    +Htime: %0.2f\n", ME_TO_DOUBLE(data[2]));
+  fprintf(handle, "    +Htime: %0.2f\n", me_to_double(data[2]));
 
   fprintf(handle, "    +Willingness: %d\n", data[3]);
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/process_package.c olsrd-current/src/process_package.c
--- olsrd-0.5.3/src/process_package.c	2007-04-26 00:08:13.000000000 +0200
+++ olsrd-current/src/process_package.c	2007-08-03 00:07:19.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.40 2007/04/25 22:08:13 bernd67 Exp $
+ * $Id: process_package.c,v 1.41 2007/08/02 22:07:19 bernd67 Exp $
  */
 
 
@@ -86,7 +86,7 @@
   /*
    * Update link status
    */
-  struct link_entry         *link = update_link_entry(&in_if->ip_addr, from_addr, message, in_if);
+  struct link_entry *lnk = update_link_entry(&in_if->ip_addr, from_addr, message, in_if);
 
   if (olsr_cnf->lq_level > 0)
     {
@@ -94,7 +94,7 @@
       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);
+      olsr_update_packet_loss_hello_int(lnk, message->htime);
 
       // find the input interface in the list of neighbor interfaces
 
@@ -104,7 +104,7 @@
 
       // the current reference link quality
 
-      saved_lq = link->saved_neigh_link_quality;
+      saved_lq = lnk->saved_neigh_link_quality;
 
       if (saved_lq == 0.0)
         saved_lq = -1.0;
@@ -113,19 +113,19 @@
       // know the link quality in both directions
 
       if (walker != NULL)
-        link->neigh_link_quality = walker->link_quality;
+        lnk->neigh_link_quality = walker->link_quality;
 
       else
-        link->neigh_link_quality = 0.0;
+        lnk->neigh_link_quality = 0.0;
 
       // if the link quality has changed by more than 10 percent,
       // print the new link quality table
 
-      rel_lq = link->neigh_link_quality / saved_lq;
+      rel_lq = lnk->neigh_link_quality / saved_lq;
 
       if (rel_lq > 1.1 || rel_lq < 0.9)
         {
-          link->saved_neigh_link_quality = link->neigh_link_quality;
+          lnk->saved_neigh_link_quality = lnk->neigh_link_quality;
 
           if (olsr_cnf->lq_dlimit > 0)
           {
@@ -145,7 +145,7 @@
         }
     }
   
-  neighbor = link->neighbor;
+  neighbor = lnk->neighbor;
 
   /*
    * Hysteresis
@@ -154,13 +154,13 @@
     {
       /* Update HELLO timeout */
       //printf("MESSAGE HTIME: %f\n", message->htime);
-      olsr_update_hysteresis_hello(link, message->htime);
+      olsr_update_hysteresis_hello(lnk, message->htime);
     }
 
   /* Check if we are chosen as MPR */
   if(olsr_lookup_mpr_status(message, in_if))
     /* source_addr is always the main addr of a node! */
-    olsr_update_mprs_set(&message->source_addr, (float)message->vtime);
+    olsr_update_mprs_set(&message->source_addr, message->vtime);
 
 
 
@@ -624,10 +624,10 @@
 
   if (olsr_cnf->lq_level > 0)
     {
-      struct link_entry *link =
+      struct link_entry *lnk =
         get_best_link_to_neighbor(&neighbor->neighbor_main_addr);
 
-      if(!link)
+      if(!lnk)
 	return;
 
       // Second pass for link quality OLSR: calculate the best 2-hop
@@ -695,7 +695,7 @@
 
                       new_path_link_quality =
                         new_second_hop_link_quality *
-                        link->loss_link_quality * link->neigh_link_quality;
+                        lnk->loss_link_quality * lnk->neigh_link_quality;
 
                       // Only copy the link quality if it is better than what we have
                       // for this 2-hop neighbor
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/process_routes.c olsrd-current/src/process_routes.c
--- olsrd-0.5.3/src/process_routes.c	2007-05-14 00:23:55.000000000 +0200
+++ olsrd-current/src/process_routes.c	2007-08-03 00:07:19.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.33 2007/05/13 22:23:55 bernd67 Exp $
+ * $Id: process_routes.c,v 1.34 2007/08/02 22:07:19 bernd67 Exp $
  */
 
 #include "defs.h"
@@ -213,14 +213,14 @@
 int
 olsr_init_old_table(void)
 {
-  int index;
+  int idx;
 
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
-      old_routes[index].next = &old_routes[index];
-      old_routes[index].prev = &old_routes[index];
-      old_hna[index].next = &old_hna[index];
-      old_hna[index].prev = &old_hna[index];
+      old_routes[idx].next = &old_routes[idx];
+      old_routes[idx].prev = &old_routes[idx];
+      old_hna[idx].next = &old_hna[idx];
+      old_hna[idx].prev = &old_hna[idx];
     }
 
   return 1;
@@ -277,12 +277,12 @@
 {
   struct destination_n *kernel_route_list = NULL;
   struct rt_entry      *destination;
-  olsr_u8_t            index;
+  int                   idx;
   
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
-      for(destination = from_table[index].next;
-	  destination != &from_table[index];
+      for(destination = from_table[idx].next;
+	  destination != &from_table[idx];
 	  destination = destination->next)
 	{
 	  if (!olsr_find_up_route(destination, in_table))
@@ -399,26 +399,26 @@
 void
 olsr_move_route_table(struct rt_entry *original, struct rt_entry *new)
 {
-  olsr_16_t index;
+  int idx;
 
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
-      if(original[index].next == &original[index])
+      if(original[idx].next == &original[idx])
 	{
-	  new[index].next = &new[index];
-	  new[index].prev = &new[index];
+	  new[idx].next = &new[idx];
+	  new[idx].prev = &new[idx];
 	}
       else
 	{
 	  /* Copy to old */
-	  new[index].next = original[index].next;
-	  new[index].next->prev = &new[index];
-	  new[index].prev = original[index].prev;
-	  new[index].prev->next = &new[index];
+	  new[idx].next = original[idx].next;
+	  new[idx].next->prev = &new[idx];
+	  new[idx].prev = original[idx].prev;
+	  new[idx].prev->next = &new[idx];
 
 	  /* Clear original */
-	  original[index].next = &original[index];
-	  original[index].prev = &original[index];
+	  original[idx].next = &original[idx];
+	  original[idx].prev = &original[idx];
 	}
     }
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/rebuild_packet.c olsrd-current/src/rebuild_packet.c
--- olsrd-0.5.3/src/rebuild_packet.c	2007-04-26 00:08:13.000000000 +0200
+++ olsrd-current/src/rebuild_packet.c	2007-08-28 22:45:17.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.21 2007/04/25 22:08:13 bernd67 Exp $
+ * $Id: rebuild_packet.c,v 1.22 2007/08/28 20:45:17 bernd67 Exp $
  */
 
 
@@ -87,7 +87,7 @@
       //printf("HNA from %s\n\n", olsr_ip_to_string((union olsr_ip_addr *)&hmsg->originator));
 
       /* Get vtime */
-      hmsg->vtime = ME_TO_DOUBLE(m->v4.olsr_vtime);
+      hmsg->vtime = me_to_double(m->v4.olsr_vtime);
 
       tmp_pairs = NULL;
       hna_pairs = NULL;
@@ -127,7 +127,7 @@
       hmsg->hop_count =  m->v6.hopcnt;
       
       /* Get vtime */
-      hmsg->vtime = ME_TO_DOUBLE(m->v6.olsr_vtime);
+      hmsg->vtime = me_to_double(m->v6.olsr_vtime);
       
       tmp_pairs = NULL;
       hna_pairs = NULL;
@@ -212,7 +212,7 @@
       mmsg->mid_addr = NULL;
 
       /* Get vtime */
-      mmsg->vtime = ME_TO_DOUBLE(m->v4.olsr_vtime);
+      mmsg->vtime = me_to_double(m->v4.olsr_vtime);
 
       //printf("Sequencenuber of MID from %s is %d\n", ip_to_string(&mmsg->addr), mmsg->mid_seqno);
 
@@ -262,7 +262,7 @@
       mmsg->mid_addr = NULL;
 
       /* Get vtime */
-      mmsg->vtime = ME_TO_DOUBLE(m->v6.olsr_vtime);
+      mmsg->vtime = me_to_double(m->v6.olsr_vtime);
 
       //printf("Sequencenuber of MID from %s is %d\n", ip_to_string(&mmsg->addr), mmsg->mid_seqno);
 
@@ -373,10 +373,10 @@
 
 
       /* Get vtime */
-      hmsg->vtime = ME_TO_DOUBLE(m->v4.olsr_vtime);
+      hmsg->vtime = me_to_double(m->v4.olsr_vtime);
 
       /* Get htime */
-      hmsg->htime = ME_TO_DOUBLE(m->v4.message.hello.htime);
+      hmsg->htime = me_to_double(m->v4.message.hello.htime);
 
       /* Willingness */
       hmsg->willingness = m->v4.message.hello.willingness;
@@ -417,10 +417,10 @@
       hmsg->packet_seq_number = ntohs(m->v6.seqno);
 
       /* Get vtime */
-      hmsg->vtime = ME_TO_DOUBLE(m->v6.olsr_vtime);
+      hmsg->vtime = me_to_double(m->v6.olsr_vtime);
 
       /* Get htime */
-      hmsg->htime = ME_TO_DOUBLE(m->v6.message.hello.htime);
+      hmsg->htime = me_to_double(m->v6.message.hello.htime);
 
       /* Willingness */
       hmsg->willingness = m->v6.message.hello.willingness;
@@ -496,7 +496,7 @@
 
 
       /* Get vtime */
-      tmsg->vtime = ME_TO_DOUBLE(m->v4.olsr_vtime);
+      tmsg->vtime = me_to_double(m->v4.olsr_vtime);
 
       OLSR_PRINTF(3, "Got TC vtime: %f\n", tmsg->vtime);
 
@@ -538,7 +538,7 @@
       /* Check if sender is symmetric neighbor here !! */
       
       /* Get vtime */
-      tmsg->vtime = ME_TO_DOUBLE(m->v6.olsr_vtime);
+      tmsg->vtime = me_to_double(m->v6.olsr_vtime);
 
       OLSR_PRINTF(3, "Got TC vtime: %f\n", tmsg->vtime);
 
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/routing_table.c olsrd-current/src/routing_table.c
--- olsrd-0.5.3/src/routing_table.c	2007-04-26 00:08:14.000000000 +0200
+++ olsrd-current/src/routing_table.c	2007-08-02 23:54:54.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.27 2007/04/25 22:08:14 bernd67 Exp $
+ * $Id: routing_table.c,v 1.28 2007/08/02 21:54:54 bernd67 Exp $
  */
 
 
@@ -85,7 +85,7 @@
 int
 olsr_init_routing_table(void)
 {
-  int index;
+  int idx;
   /*
    *The hna routes hash will almost always
    *be indexed to 0
@@ -93,12 +93,12 @@
    *with the functions used on the regular
    *routing table
    */
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
-      routingtable[index].next = &routingtable[index];
-      routingtable[index].prev = &routingtable[index];
-      hna_routes[index].next = &hna_routes[index];
-      hna_routes[index].prev = &hna_routes[index];
+      routingtable[idx].next = &routingtable[idx];
+      routingtable[idx].prev = &routingtable[idx];
+      hna_routes[idx].next = &hna_routes[idx];
+      hna_routes[idx].prev = &hna_routes[idx];
     }
   return 1;
 }
@@ -164,13 +164,13 @@
 void
 olsr_free_routing_table(struct rt_entry *table)
 {
-  olsr_u8_t       index;
+  int idx;
   
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
-      struct rt_entry *destination = table[index].next;
+      struct rt_entry *destination = table[idx].next;
 
-      while(destination != &table[index])
+      while(destination != &table[idx])
 	{
 	  struct rt_entry *dst_to_delete = destination;
 	  destination = destination->next;
@@ -192,18 +192,14 @@
  */
 struct rt_entry *
 olsr_insert_routing_table(union olsr_ip_addr *dst, 
-			  union olsr_ip_addr *router, 
+			  const union olsr_ip_addr *router, 
 			  struct interface *iface, 
 			  int metric,
 			  float etx)
 {
-  struct rt_entry *new_route_entry, *rt_list;
-  olsr_u32_t       hash;
-
-  hash = olsr_hashing(dst);
-  rt_list = &routingtable[hash];
-
-  new_route_entry = olsr_malloc(sizeof(struct rt_entry), "Insert routing table");
+  const olsr_u32_t hash = olsr_hashing(dst);
+  struct rt_entry *rt_list = &routingtable[hash];
+  struct rt_entry *new_route_entry = olsr_malloc(sizeof(struct rt_entry), "Insert routing table");
 
   COPY_IP(&new_route_entry->rt_dst, dst);
   COPY_IP(&new_route_entry->rt_router, router);
@@ -249,17 +245,17 @@
 static int
 olsr_fill_routing_table_with_neighbors(void)
 {
-  int index;
+  int idx;
 
 #ifdef DEBUG
   OLSR_PRINTF(7, "FILL ROUTING TABLE WITH NEIGHBORS\n");
 #endif
 
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
       struct neighbor_entry *neighbor;
-      for(neighbor = neighbortable[index].next;
-	  neighbor != &neighbortable[index];
+      for(neighbor = neighbortable[idx].next;
+	  neighbor != &neighbortable[idx];
 	  neighbor=neighbor->next)     
 	{
 	  if(neighbor->status == SYM)
@@ -276,18 +272,18 @@
 
 	      for(addrs2 = &addrs;addrs2!=NULL;addrs2 = addrs2->next_alias)
 		{
-		  struct link_entry *link = get_best_link_to_neighbor(&addrs2->alias);
+		  const struct link_entry *lnk = get_best_link_to_neighbor(&addrs2->alias);
 #ifdef DEBUG
 		  OLSR_PRINTF(7, "(ROUTE)Adding neighbor %s\n", olsr_ip_to_string(&addrs.alias));
 #endif
-		  if(link)
+		  if(lnk)
 		    {
-		      struct interface *iface = link->if_name ? if_ifwithname(link->if_name) :
-		                                if_ifwithaddr(&link->local_iface_addr);
+		      struct interface *iface = lnk->if_name ? if_ifwithname(lnk->if_name) :
+		                                if_ifwithaddr(&lnk->local_iface_addr);
 		      if(iface)
 			{
 			  olsr_insert_routing_table(&addrs2->alias, 
-						    &link->neighbor_iface_addr,
+						    &lnk->neighbor_iface_addr,
 						    iface,
 						    1,
 						    -1.0);
@@ -336,16 +332,16 @@
 olsr_fill_routing_table_with_two_hop_neighbors(void)
 {
   struct destination_n *list_destination_n=NULL;
-  int            index;
+  int            idx;
 
   //printf("FILL ROUTING TABLE WITH TWO HOP NEIGHBORS\n");
 
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
       struct neighbor_entry *neighbor;
 
-      for(neighbor = neighbortable[index].next;
-	  neighbor != &neighbortable[index];
+      for(neighbor = neighbortable[idx].next;
+	  neighbor != &neighbortable[idx];
 	  neighbor=neighbor->next)     
 	{
 	  struct neighbor_2_list_entry *neigh_2_list; 
@@ -386,19 +382,19 @@
 
 	      for(addrsp = &addrs; addrsp; addrsp = addrsp->next_alias)
 		{
-		  struct link_entry *link = get_best_link_to_neighbor(&neighbor->neighbor_main_addr);
+		  const struct link_entry * const lnk = 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));
 #endif
-		  if(link)
+		  if(lnk)
 		    {
-                      struct interface *iface = link->if_name ? if_ifwithname(link->if_name) :
-		                                if_ifwithaddr(&link->local_iface_addr);
+                      struct interface *iface = lnk->if_name ? if_ifwithname(lnk->if_name) :
+		                                if_ifwithaddr(&lnk->local_iface_addr);
 		      if(iface)
 			{
 			  struct rt_entry *new_route_entry = 
 			    olsr_insert_routing_table(&addrsp->alias, 
-						      &link->neighbor_iface_addr,
+						      &lnk->neighbor_iface_addr,
 						      iface,
 						      2,
 						      -1.0);
@@ -550,14 +546,14 @@
 static struct rt_entry *
 olsr_check_for_higher_quality(struct rt_entry *routes, struct hna_net *net, float etx)
 {
-  int index;
+  int idx;
 
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
       struct rt_entry *tmp_routes;
       /* All entries */
-      for(tmp_routes = routes[index].next;
-	  tmp_routes != &routes[index];
+      for(tmp_routes = routes[idx].next;
+	  tmp_routes != &routes[idx];
 	  tmp_routes = tmp_routes->next)
 	{
 	  if(COMP_IP(&tmp_routes->rt_dst, &net->A_network_addr) &&
@@ -590,14 +586,14 @@
 struct rt_entry *
 olsr_check_for_lower_quality(struct rt_entry *routes, struct hna_net *net, float etx)
 {
-  int index;
+  int idx;
 
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
       struct rt_entry *tmp_routes;
       /* All entries */
-      for(tmp_routes = routes[index].next;
-	  tmp_routes != &routes[index];
+      for(tmp_routes = routes[idx].next;
+	  tmp_routes != &routes[idx];
 	  tmp_routes = tmp_routes->next)
 	{
 	  if(COMP_IP(&tmp_routes->rt_dst, &net->A_network_addr) &&
@@ -627,7 +623,7 @@
 void
 olsr_calculate_hna_routes(void)
 {
-  int index;
+  int idx;
 
 #ifdef DEBUG
   OLSR_PRINTF(3, "Calculating HNA routes\n");
@@ -635,12 +631,12 @@
 
   olsr_move_route_table(hna_routes, old_hna);
 
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
       struct hna_entry *tmp_hna;
       /* All entries */
-      for(tmp_hna = hna_set[index].next;
-	  tmp_hna != &hna_set[index];
+      for(tmp_hna = hna_set[idx].next;
+	  tmp_hna != &hna_set[idx];
 	  tmp_hna = tmp_hna->next)
 	{
 	  struct hna_net *tmp_net;
@@ -735,15 +731,15 @@
 void
 olsr_print_routing_table(struct rt_entry *table)
 {
-  int index;
+  int idx;
 
   printf("ROUTING TABLE\n");
   printf("DESTINATION\tNEXT HOP\tHOPCNT\tINTERFACE\n");
-  for(index = 0; index < HASHSIZE; index++)
+  for(idx = 0; idx < HASHSIZE; idx++)
     {
       struct rt_entry *destination;
-      for(destination = table[index].next;
-	  destination != &table[index];
+      for(destination = table[idx].next;
+	  destination != &table[idx];
 	  destination = destination->next)
 	{
 	  printf("%s\t", olsr_ip_to_string(&destination->rt_dst));
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/routing_table.h olsrd-current/src/routing_table.h
--- olsrd-0.5.3/src/routing_table.h	2005-11-17 00:55:54.000000000 +0100
+++ olsrd-current/src/routing_table.h	2007-08-02 23:54:54.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: routing_table.h,v 1.17 2005/11/16 23:55:54 tlopatic Exp $
+ * $Id: routing_table.h,v 1.18 2007/08/02 21:54:54 bernd67 Exp $
  */
 
 #ifndef _OLSR_ROUTING_TABLE
@@ -107,7 +107,7 @@
 olsr_print_routing_table(struct rt_entry *);
 
 struct rt_entry *
-olsr_insert_routing_table(union olsr_ip_addr *, union olsr_ip_addr *, struct interface *, int, float);
+olsr_insert_routing_table(union olsr_ip_addr *, const union olsr_ip_addr *, struct interface *, int, float);
 
 struct rt_entry *
 olsr_lookup_routing_table(union olsr_ip_addr *);
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/scheduler.c olsrd-current/src/scheduler.c
--- olsrd-0.5.3/src/scheduler.c	2007-08-02 14:24:37.000000000 +0200
+++ olsrd-current/src/scheduler.c	2007-08-20 01:00:21.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.41 2007/08/02 12:24:37 bernd67 Exp $
+ * $Id: scheduler.c,v 1.42 2007/08/19 23:00:21 bernd67 Exp $
  */
 
 
@@ -52,11 +52,6 @@
 #include "olsr.h"
 #include "build_msg.h"
 
-#if defined WIN32
-extern olsr_bool olsr_win32_end_request;
-extern olsr_bool olsr_win32_end_flag;
-#endif
-
 /* Timer data, global. Externed in defs.h */
 clock_t now_times;              /* current idea of times(2) reported uptime */
 struct timeval now;		/* current idea of time */
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/tc_set.c olsrd-current/src/tc_set.c
--- olsrd-0.5.3/src/tc_set.c	2007-04-26 00:08:17.000000000 +0200
+++ olsrd-current/src/tc_set.c	2007-08-03 00:07:19.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.26 2007/04/25 22:08:17 bernd67 Exp $
+ * $Id: tc_set.c,v 1.27 2007/08/02 22:07:19 bernd67 Exp $
  */
 
 
@@ -57,15 +57,15 @@
 int
 olsr_init_tc(void)
 {
-  int index;
+  int idx;
   OLSR_PRINTF(5, "TC: init topo\n");
 
   olsr_register_timeout_function(&olsr_time_out_tc_set);
 
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
-      tc_table[index].next = &tc_table[index];
-      tc_table[index].prev = &tc_table[index];
+      tc_table[idx].next = &tc_table[idx];
+      tc_table[idx].prev = &tc_table[idx];
     }
 
   return 1;
@@ -372,16 +372,16 @@
 void
 olsr_time_out_tc_set(void)
 {
-  int index;
+  int idx;
 
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
       /* For all TC entries */
-      struct tc_entry *entry = tc_table[index].next;
-      while(entry != &tc_table[index])
+      struct tc_entry *entry = tc_table[idx].next;
+      while(entry != &tc_table[idx])
 	{
           struct tc_entry *entry2;
-	  //printf("INDEX: %d\n", index);
+	  //printf("INDEX: %d\n", idx);
 	  /* For all destination entries of that TC entry */
 	  int deleted = 0;
 	  struct topo_dst *dst_entry = entry->destinations.next;
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/two_hop_neighbor_table.c olsrd-current/src/two_hop_neighbor_table.c
--- olsrd-0.5.3/src/two_hop_neighbor_table.c	2007-04-26 00:08:17.000000000 +0200
+++ olsrd-current/src/two_hop_neighbor_table.c	2007-08-03 00:07:19.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.18 2007/04/25 22:08:17 bernd67 Exp $
+ * $Id: two_hop_neighbor_table.c,v 1.19 2007/08/02 22:07:19 bernd67 Exp $
  */
 
 
@@ -56,12 +56,12 @@
 int
 olsr_init_two_hop_table(void)
 {
-  int index;
+  int idx;
 
-  for(index=0;index<HASHSIZE;index++)
+  for(idx=0;idx<HASHSIZE;idx++)
     {
-      two_hop_neighbortable[index].next = &two_hop_neighbortable[index];
-      two_hop_neighbortable[index].prev = &two_hop_neighbortable[index];
+      two_hop_neighbortable[idx].next = &two_hop_neighbortable[idx];
+      two_hop_neighbortable[idx].prev = &two_hop_neighbortable[idx];
     }
   return 1;
 }
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/unix/ifnet.c olsrd-current/src/unix/ifnet.c
--- olsrd-0.5.3/src/unix/ifnet.c	2007-05-14 00:23:55.000000000 +0200
+++ olsrd-current/src/unix/ifnet.c	2007-08-23 23:20:02.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.49 2007/05/13 22:23:55 bernd67 Exp $
+ * $Id: ifnet.c,v 1.51 2007/08/23 21:20:02 bernd67 Exp $
  */
 
 
@@ -704,15 +704,17 @@
   return 1;
 }
 
-static char basename[32];
-char* if_basename(char* name);
-char* if_basename(char* name)
+static char basenamestr[32];
+static const char* if_basename(const char* name);
+static const char* if_basename(const char* name)
 {
 	char *p = strchr(name, ':');
-	if (0 == p || p - name >= (int)(sizeof(basename) / sizeof(basename[0]) - 1)) return name;
-	memcpy(basename, name, p - name);
-	basename[p - name] = 0;
-	return basename;
+	if (NULL == p || p - name >= (int)(sizeof(basenamestr) / sizeof(basenamestr[0]) - 1)) {
+        	return name;
+        }
+	memcpy(basenamestr, name, p - name);
+	basenamestr[p - name] = 0;
+	return basenamestr;
 }
 
 /**
diff --exclude=CVS --exclude=.cvsignore -Nur olsrd-0.5.3/src/unix/misc.c olsrd-current/src/unix/misc.c
--- olsrd-0.5.3/src/unix/misc.c	2005-03-10 08:01:48.000000000 +0100
+++ olsrd-current/src/unix/misc.c	2007-08-02 23:58:43.000000000 +0200
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: misc.c,v 1.5 2005/03/10 07:01:48 kattemat Exp $
+ * $Id: misc.c,v 1.6 2007/08/02 21:58:43 bernd67 Exp $
  */
 
 
@@ -47,30 +47,23 @@
 
 void clear_console(void)
 {
-  FILE *pipe;
-  static int first_time = 1;
+  static int len = -1;
   static char clear_buff[100];
-  static olsr_u16_t len = 0;
-  int c;
   int i;
 
-  if (first_time != 0)
+  if (len < 0)
     {
-      first_time = 0;
-
-      pipe = popen("clear", "r");
-
-      for (len = 0; len < sizeof (clear_buff); len++)
+      FILE *pip = popen("clear", "r");
+      for (len = 0; len < (int)sizeof(clear_buff); len++)
         {
-          c = fgetc(pipe);
-
+          int c = fgetc(pip);
           if (c == EOF)
             break;
 
-          clear_buff[len] = (char)c;
+          clear_buff[len] = c;
         }
 
-      pclose(pipe);
+      pclose(pip);
     }
 
   for (i = 0; i < len; i++)
