From (spam-protected) Mon Jan 29 00:47:58 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Sun, 28 Jan 2007 23:47:58 +0000 Subject: [Olsr-cvs] olsrd-current/lib/dyn_gw_plain - New directory Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/dyn_gw_plain In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv7334/lib/dyn_gw_plain Log Message: Directory /cvsroot/olsrd/olsrd-current/lib/dyn_gw_plain added to the repository From (spam-protected) Mon Jan 29 00:47:57 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Sun, 28 Jan 2007 23:47:57 +0000 Subject: [Olsr-cvs] olsrd-current/lib/txtinfo - New directory Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/txtinfo In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv7334/lib/txtinfo Log Message: Directory /cvsroot/olsrd/olsrd-current/lib/txtinfo added to the repository From (spam-protected) Mon Jan 29 00:47:58 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Sun, 28 Jan 2007 23:47:58 +0000 Subject: [Olsr-cvs] olsrd-current/lib/quagga - New directory Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/quagga In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv7334/lib/quagga Log Message: Directory /cvsroot/olsrd/olsrd-current/lib/quagga added to the repository From (spam-protected) Mon Jan 29 00:50:12 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Sun, 28 Jan 2007 23:50:12 +0000 Subject: [Olsr-cvs] olsrd-current/lib/dyn_gw_plain/src - New directory Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/dyn_gw_plain/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv8514/lib/dyn_gw_plain/src Log Message: Directory /cvsroot/olsrd/olsrd-current/lib/dyn_gw_plain/src added to the repository From (spam-protected) Mon Jan 29 00:50:59 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Sun, 28 Jan 2007 23:50:59 +0000 Subject: [Olsr-cvs] olsrd-current/lib/txtinfo/src - New directory Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/txtinfo/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv8624/lib/txtinfo/src Log Message: Directory /cvsroot/olsrd/olsrd-current/lib/txtinfo/src added to the repository From (spam-protected) Mon Jan 29 00:53:25 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Sun, 28 Jan 2007 23:53:25 +0000 Subject: [Olsr-cvs] olsrd-current/lib/quagga/src - New directory Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/quagga/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv9803/lib/quagga/src Log Message: Directory /cvsroot/olsrd/olsrd-current/lib/quagga/src added to the repository From (spam-protected) Mon Jan 29 00:53:25 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Sun, 28 Jan 2007 23:53:25 +0000 Subject: [Olsr-cvs] olsrd-current/lib/quagga/test - New directory Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/quagga/test In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv9803/lib/quagga/test Log Message: Directory /cvsroot/olsrd/olsrd-current/lib/quagga/test added to the repository From (spam-protected) Mon Jan 29 00:54:42 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Sun, 28 Jan 2007 23:54:42 +0000 Subject: [Olsr-cvs] olsrd-current/lib/quagga/src/quagga - New directory Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/quagga/src/quagga In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv10206/lib/quagga/src/quagga Log Message: Directory /cvsroot/olsrd/olsrd-current/lib/quagga/src/quagga added to the repository From (spam-protected) Tue Jan 30 17:48:36 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Tue, 30 Jan 2007 16:48:36 +0000 Subject: [Olsr-cvs] olsrd-current/lib/dyn_gw/src olsrd_dyn_gw.c,1.18,1.19 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/dyn_gw/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv28024/lib/dyn_gw/src Modified Files: olsrd_dyn_gw.c Log Message: * fixed a compiler warning Index: olsrd_dyn_gw.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/dyn_gw/src/olsrd_dyn_gw.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** olsrd_dyn_gw.c 2 Jun 2005 13:59:12 -0000 1.18 --- olsrd_dyn_gw.c 30 Jan 2007 16:48:34 -0000 1.19 *************** *** 298,301 **** --- 298,302 ---- sleeptime_spec = remainder_spec; } + return NULL; } From (spam-protected) Tue Jan 30 17:50:22 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Tue, 30 Jan 2007 16:50:22 +0000 Subject: [Olsr-cvs] olsrd-current/make Makefile.linux,1.8,1.9 Message-ID: Update of /cvsroot/olsrd/olsrd-current/make In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv28850/make Modified Files: Makefile.linux Log Message: * fixed buggy shell command Index: Makefile.linux =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/make/Makefile.linux,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Makefile.linux 12 Nov 2006 21:54:53 -0000 1.8 --- Makefile.linux 30 Jan 2007 16:50:20 -0000 1.9 *************** *** 5,9 **** ARCH := $(shell uname -m) DESTDIR ?= ! LIBDIR = $(DESTDIR)$(shell [ "$(ARCH)" = "x86_64" && -d "/usr/lib64" ] && echo "/usr/lib64" || echo "/usr/lib") SRCS += $(wildcard src/linux/*.c) $(wildcard src/unix/*.c) --- 5,9 ---- ARCH := $(shell uname -m) DESTDIR ?= ! LIBDIR = $(DESTDIR)$(shell if [ "$(ARCH)" = "x86_64" -a -d "/usr/lib64" ]; then echo "/usr/lib64"; else echo "/usr/lib"; fi) SRCS += $(wildcard src/linux/*.c) $(wildcard src/unix/*.c) From (spam-protected) Tue Jan 30 17:51:06 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Tue, 30 Jan 2007 16:51:06 +0000 Subject: [Olsr-cvs] olsrd-current/make Makefile.osx,1.7,1.8 Message-ID: Update of /cvsroot/olsrd/olsrd-current/make In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29141/make Modified Files: Makefile.osx Log Message: * cosmetic: killed a useless Index: Makefile.osx =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/make/Makefile.osx,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Makefile.osx 12 Nov 2006 21:54:53 -0000 1.7 --- Makefile.osx 30 Jan 2007 16:51:04 -0000 1.8 *************** *** 24,28 **** LDFLAGS = -dynamic endif ! OS_LIB_PTHREAD = OS_LIB_DYNLOAD = --- 24,28 ---- LDFLAGS = -dynamic endif ! OS_LIB_PTHREAD = OS_LIB_DYNLOAD = From (spam-protected) Tue Jan 30 17:52:43 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Tue, 30 Jan 2007 16:52:43 +0000 Subject: [Olsr-cvs] olsrd-current/src interfaces.h,1.35,1.36 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29693/src Modified Files: interfaces.h Log Message: * cosmetic: whitesoace cleanup Index: interfaces.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/interfaces.h,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** interfaces.h 15 Nov 2006 23:07:59 -0000 1.35 --- interfaces.h 30 Jan 2007 16:52:41 -0000 1.36 *************** *** 157,161 **** struct if_gen_property *gen_properties;/* Generic interface properties */ ! int ttl_index; /* index in TTL array for fish-eye */ --- 157,161 ---- struct if_gen_property *gen_properties;/* Generic interface properties */ ! int ttl_index; /* index in TTL array for fish-eye */ From (spam-protected) Tue Jan 30 18:11:55 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Tue, 30 Jan 2007 17:11:55 +0000 Subject: [Olsr-cvs] olsrd-current/lib/secure/src md5.c, 1.2, 1.3 md5.h, 1.1, 1.2 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/secure/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv5024/lib/secure/src Modified Files: md5.c md5.h Log Message: * const'ified the two files to be able to remove warnings somewhere else Index: md5.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/secure/src/md5.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** md5.c 5 Apr 2005 05:39:58 -0000 1.2 --- md5.c 30 Jan 2007 17:11:52 -0000 1.3 *************** *** 45,51 **** #define S44 21 ! static void MD5Transform(UINT4 [4], unsigned char [64]); static void Encode(unsigned char *, UINT4 *, unsigned int); ! static void Decode(UINT4 *, unsigned char *, unsigned int); static void MD5_memcpy(POINTER, POINTER, unsigned int); static void MD5_memset(POINTER, int, unsigned int); --- 45,51 ---- #define S44 21 ! static void MD5Transform(UINT4 [4], const unsigned char [64]); static void Encode(unsigned char *, UINT4 *, unsigned int); ! static void Decode(UINT4 *, const unsigned char *, const unsigned int); static void MD5_memcpy(POINTER, POINTER, unsigned int); static void MD5_memset(POINTER, int, unsigned int); *************** *** 110,114 **** context. */ ! void MD5Update (MD5_CTX *context, unsigned char *input, unsigned int inputLen) { unsigned int i, index, partLen; --- 110,114 ---- context. */ ! void MD5Update (MD5_CTX *context, const unsigned char *input, const unsigned int inputLen) { unsigned int i, index, partLen; *************** *** 176,180 **** /* MD5 basic transformation. Transforms state based on block. */ ! static void MD5Transform (UINT4 state[4], unsigned char block[64]) { UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; --- 176,180 ---- /* MD5 basic transformation. Transforms state based on block. */ ! static void MD5Transform (UINT4 state[4], const unsigned char block[64]) { UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; *************** *** 282,286 **** a multiple of 4. */ ! static void Decode (UINT4 *output, unsigned char *input, unsigned int len) { unsigned int i, j; --- 282,286 ---- a multiple of 4. */ ! static void Decode (UINT4 *output, const unsigned char *input, const unsigned int len) { unsigned int i, j; Index: md5.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/secure/src/md5.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** md5.h 10 Mar 2005 19:57:48 -0000 1.1 --- md5.h 30 Jan 2007 17:11:52 -0000 1.2 *************** *** 42,46 **** void MD5Init(MD5_CTX *); ! void MD5Update(MD5_CTX *, unsigned char *, unsigned int); void MD5Final(unsigned char [16], MD5_CTX *); --- 42,46 ---- void MD5Init(MD5_CTX *); ! void MD5Update(MD5_CTX *, const unsigned char *, const unsigned int); void MD5Final(unsigned char [16], MD5_CTX *); From (spam-protected) Wed Jan 31 13:36:51 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Wed, 31 Jan 2007 12:36:51 +0000 Subject: [Olsr-cvs] olsrd-current Makefile,1.73,1.74 Message-ID: Update of /cvsroot/olsrd/olsrd-current In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv15855 Modified Files: Makefile Log Message: * applied patches from the most recent FreiFunkFirmware (and fixed compile errors) according to http://www.olsr.org/pipermail/olsr-dev/2006-December/254036.html: - olsrd-libsmake.patch - olsrd-dyngwplain.patch - olsrd-txtinfo.patch - olsrd-quagga.patch - olsrd-quagga-routehandler.patch - olsrd-optimize.patch - olsrd-bmf-fixes.patch - olsrd-fixes-sven-ola.patch - olsrd-fixes-jhay-bsd.patch - olsrd-fixes-backport.patch - olsrd-fixes-routedel.patch - olsrd-cpu-overload.patch - olsrd-secure_key_path.patch - olsrd-hna_ip_fix.patch Not applied: - olsrd-nameservice+services.patch: This patch produced too many rejects to fix easily. - olsrd-fixes-eric.patch: This was not found on the webserver. - olsrd-bmf.patch: We had already a "bmf" plug-in in there. * made the checksum type in the olsrd_secure plug-in "olsr_u8_t" (instead of a wild "char *" and "unsigned char *" mix) everywhere. It killed lots of warnings. * localized the checksum_cache array in olsrd_secure.c. Index: Makefile =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/Makefile,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** Makefile 15 Nov 2006 22:09:16 -0000 1.73 --- Makefile 31 Jan 2007 12:36:49 -0000 1.74 *************** *** 146,149 **** --- 146,154 ---- $(MAKE) -C lib/dyn_gw install + dyn_gw_plain: + $(MAKE) -C lib/dyn_gw_plain clean + $(MAKE) -C lib/dyn_gw_plain + $(MAKE) -C lib/dyn_gw_plain install + secure: $(MAKE) -C lib/secure clean From (spam-protected) Wed Jan 31 13:36:52 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Wed, 31 Jan 2007 12:36:52 +0000 Subject: [Olsr-cvs] olsrd-current/src/linux kernel_routes.c,1.19,1.20 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src/linux In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv15855/src/linux Modified Files: kernel_routes.c Log Message: * applied patches from the most recent FreiFunkFirmware (and fixed compile errors) according to http://www.olsr.org/pipermail/olsr-dev/2006-December/254036.html: - olsrd-libsmake.patch - olsrd-dyngwplain.patch - olsrd-txtinfo.patch - olsrd-quagga.patch - olsrd-quagga-routehandler.patch - olsrd-optimize.patch - olsrd-bmf-fixes.patch - olsrd-fixes-sven-ola.patch - olsrd-fixes-jhay-bsd.patch - olsrd-fixes-backport.patch - olsrd-fixes-routedel.patch - olsrd-cpu-overload.patch - olsrd-secure_key_path.patch - olsrd-hna_ip_fix.patch Not applied: - olsrd-nameservice+services.patch: This patch produced too many rejects to fix easily. - olsrd-fixes-eric.patch: This was not found on the webserver. - olsrd-bmf.patch: We had already a "bmf" plug-in in there. * made the checksum type in the olsrd_secure plug-in "olsr_u8_t" (instead of a wild "char *" and "unsigned char *" mix) everywhere. It killed lots of warnings. * localized the checksum_cache array in olsrd_secure.c. Index: kernel_routes.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/linux/kernel_routes.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** kernel_routes.c 7 Jan 2006 08:16:24 -0000 1.19 --- kernel_routes.c 31 Jan 2007 12:36:50 -0000 1.20 *************** *** 241,247 **** inet_ntop(AF_INET, &destination->rt_router.v4, router_str, 16); ! OLSR_PRINTF(1, "(ioctl)Deleting route with metric %d to %s/%s via %s/%s.\n", ! destination->rt_metric, dst_str, mask_str, router_str, ! destination->rt_if->int_name) memset(&kernel_route,0,sizeof(struct rtentry)); --- 241,246 ---- inet_ntop(AF_INET, &destination->rt_router.v4, router_str, 16); ! OLSR_PRINTF(1, "(ioctl)Deleting route with metric %d to %s/%s via %s.\n", ! destination->rt_metric, dst_str, mask_str, router_str) memset(&kernel_route,0,sizeof(struct rtentry)); From (spam-protected) Wed Jan 31 13:36:51 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Wed, 31 Jan 2007 12:36:51 +0000 Subject: [Olsr-cvs] olsrd-current/lib Makefile,1.6,1.7 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv15855/lib Modified Files: Makefile Log Message: * applied patches from the most recent FreiFunkFirmware (and fixed compile errors) according to http://www.olsr.org/pipermail/olsr-dev/2006-December/254036.html: - olsrd-libsmake.patch - olsrd-dyngwplain.patch - olsrd-txtinfo.patch - olsrd-quagga.patch - olsrd-quagga-routehandler.patch - olsrd-optimize.patch - olsrd-bmf-fixes.patch - olsrd-fixes-sven-ola.patch - olsrd-fixes-jhay-bsd.patch - olsrd-fixes-backport.patch - olsrd-fixes-routedel.patch - olsrd-cpu-overload.patch - olsrd-secure_key_path.patch - olsrd-hna_ip_fix.patch Not applied: - olsrd-nameservice+services.patch: This patch produced too many rejects to fix easily. - olsrd-fixes-eric.patch: This was not found on the webserver. - olsrd-bmf.patch: We had already a "bmf" plug-in in there. * made the checksum type in the olsrd_secure plug-in "olsr_u8_t" (instead of a wild "char *" and "unsigned char *" mix) everywhere. It killed lots of warnings. * localized the checksum_cache array in olsrd_secure.c. Index: Makefile =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/Makefile,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Makefile 21 Oct 2006 21:39:22 -0000 1.6 --- Makefile 31 Jan 2007 12:36:49 -0000 1.7 *************** *** 1,3 **** ! SUBDIRS = dot_draw dyn_gw httpinfo mini nameservice secure tas bmf .PHONY: $(SUBDIRS) --- 1,3 ---- ! SUBDIRS := $(shell find -maxdepth 1 -type d -not -name ".*" -not -name "CVS" -printf "%f\n") .PHONY: $(SUBDIRS) From (spam-protected) Wed Jan 31 13:36:52 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Wed, 31 Jan 2007 12:36:52 +0000 Subject: [Olsr-cvs] olsrd-current/src/unix ifnet.c,1.40,1.41 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src/unix In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv15855/src/unix Modified Files: ifnet.c Log Message: * applied patches from the most recent FreiFunkFirmware (and fixed compile errors) according to http://www.olsr.org/pipermail/olsr-dev/2006-December/254036.html: - olsrd-libsmake.patch - olsrd-dyngwplain.patch - olsrd-txtinfo.patch - olsrd-quagga.patch - olsrd-quagga-routehandler.patch - olsrd-optimize.patch - olsrd-bmf-fixes.patch - olsrd-fixes-sven-ola.patch - olsrd-fixes-jhay-bsd.patch - olsrd-fixes-backport.patch - olsrd-fixes-routedel.patch - olsrd-cpu-overload.patch - olsrd-secure_key_path.patch - olsrd-hna_ip_fix.patch Not applied: - olsrd-nameservice+services.patch: This patch produced too many rejects to fix easily. - olsrd-fixes-eric.patch: This was not found on the webserver. - olsrd-bmf.patch: We had already a "bmf" plug-in in there. * made the checksum type in the olsrd_secure plug-in "olsr_u8_t" (instead of a wild "char *" and "unsigned char *" mix) everywhere. It killed lots of warnings. * localized the checksum_cache array in olsrd_secure.c. Index: ifnet.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/unix/ifnet.c,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** ifnet.c 15 Nov 2006 23:07:59 -0000 1.40 --- ifnet.c 31 Jan 2007 12:36:50 -0000 1.41 *************** *** 58,61 **** --- 58,62 ---- #include "lq_packet.h" #include "log.h" + #include "link_set.h" #include #include *************** *** 411,414 **** --- 412,417 ---- olsr_syslog(OLSR_LOG_INFO, "Removing interface %s\n", iface->name); + del_if_link_entries(&ifp->ip_addr); + /* *Call possible ifchange functions registered by plugins *************** *** 713,716 **** --- 716,730 ---- } + static char basename[32]; + char* if_basename(char* name); + char* if_basename(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; + } + /** * Initializes a interface described by iface, *************** *** 857,864 **** /* Deactivate IP spoof filter */ ! deactivate_spoof(ifr.ifr_name, iface->index, olsr_cnf->ip_version); /* Disable ICMP redirects */ ! disable_redirects(ifr.ifr_name, iface->index, olsr_cnf->ip_version); } --- 871,878 ---- /* Deactivate IP spoof filter */ ! deactivate_spoof(if_basename(ifr.ifr_name), iface->index, olsr_cnf->ip_version); /* Disable ICMP redirects */ ! disable_redirects(if_basename(ifr.ifr_name), iface->index, olsr_cnf->ip_version); } *************** *** 924,928 **** ifp->int_name = olsr_malloc(strlen(ifr.ifr_name) + 1, "Interface update 3"); ! strcpy(ifp->int_name, ifr.ifr_name); /* Segfaults if using strncpy(IFNAMSIZ) why oh why?? */ ifp->int_next = ifnet; --- 938,942 ---- ifp->int_name = olsr_malloc(strlen(ifr.ifr_name) + 1, "Interface update 3"); ! strcpy(ifp->int_name, if_basename(ifr.ifr_name)); /* Segfaults if using strncpy(IFNAMSIZ) why oh why?? */ ifp->int_next = ifnet; From (spam-protected) Wed Jan 31 13:36:52 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Wed, 31 Jan 2007 12:36:52 +0000 Subject: [Olsr-cvs] olsrd-current/lib/secure/src olsrd_secure.c, 1.20, 1.21 olsrd_secure.h, 1.6, 1.7 secure_messages.h, 1.1, 1.2 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/secure/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv15855/lib/secure/src Modified Files: olsrd_secure.c olsrd_secure.h secure_messages.h Log Message: * applied patches from the most recent FreiFunkFirmware (and fixed compile errors) according to http://www.olsr.org/pipermail/olsr-dev/2006-December/254036.html: - olsrd-libsmake.patch - olsrd-dyngwplain.patch - olsrd-txtinfo.patch - olsrd-quagga.patch - olsrd-quagga-routehandler.patch - olsrd-optimize.patch - olsrd-bmf-fixes.patch - olsrd-fixes-sven-ola.patch - olsrd-fixes-jhay-bsd.patch - olsrd-fixes-backport.patch - olsrd-fixes-routedel.patch - olsrd-cpu-overload.patch - olsrd-secure_key_path.patch - olsrd-hna_ip_fix.patch Not applied: - olsrd-nameservice+services.patch: This patch produced too many rejects to fix easily. - olsrd-fixes-eric.patch: This was not found on the webserver. - olsrd-bmf.patch: We had already a "bmf" plug-in in there. * made the checksum type in the olsrd_secure plug-in "olsr_u8_t" (instead of a wild "char *" and "unsigned char *" mix) everywhere. It killed lots of warnings. * localized the checksum_cache array in olsrd_secure.c. Index: secure_messages.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/secure/src/secure_messages.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** secure_messages.h 29 May 2005 12:47:44 -0000 1.1 --- secure_messages.h 31 Jan 2007 12:36:50 -0000 1.2 *************** *** 129,133 **** olsr_u32_t challenge; ! char signature[SIGSIZE]; }; --- 129,133 ---- olsr_u32_t challenge; ! olsr_u8_t signature[SIGSIZE]; }; *************** *** 149,156 **** time_t timestamp; ! char res_sig[SIGSIZE]; ! ! char signature[SIGSIZE]; }; --- 149,155 ---- time_t timestamp; ! olsr_u8_t res_sig[SIGSIZE]; + olsr_u8_t signature[SIGSIZE]; }; *************** *** 169,175 **** time_t timestamp; ! char res_sig[SIGSIZE]; ! char signature[SIGSIZE]; }; --- 168,174 ---- time_t timestamp; ! olsr_u8_t res_sig[SIGSIZE]; ! olsr_u8_t signature[SIGSIZE]; }; Index: olsrd_secure.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/secure/src/olsrd_secure.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** olsrd_secure.h 19 Nov 2005 08:30:45 -0000 1.6 --- olsrd_secure.h 31 Jan 2007 12:36:49 -0000 1.7 *************** *** 47,51 **** ! #define KEYFILE "/root/.olsr/olsrd_secure_key" /* Schemes */ --- 47,51 ---- ! #define KEYFILE "/etc/olsrd.d/olsrd_secure_key" /* Schemes */ *************** *** 92,97 **** struct stamp timestamps[HASHSIZE]; - char checksum_cache[512 + KEYLENGTH]; - /* Input interface */ struct interface *olsr_in_if; --- 92,95 ---- *************** *** 137,141 **** int ! add_signature(char *, int*); int --- 135,139 ---- int ! add_signature(olsr_u8_t *, int*); int Index: olsrd_secure.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/secure/src/olsrd_secure.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** olsrd_secure.c 6 Nov 2006 23:46:47 -0000 1.20 --- olsrd_secure.c 31 Jan 2007 12:36:49 -0000 1.21 *************** *** 72,82 **** static void ! MD5_checksum(char *data, olsr_u16_t data_len, char *hashbuf) { MD5_CTX context; MD5Init(&context); ! MD5Update(&context, (unsigned char *)data, data_len); ! MD5Final((unsigned char *)hashbuf, &context); } --- 72,82 ---- static void ! MD5_checksum(const olsr_u8_t *data, const olsr_u16_t data_len, olsr_u8_t *hashbuf) { MD5_CTX context; MD5Init(&context); ! MD5Update(&context, data, data_len); ! MD5Final(hashbuf, &context); } *************** *** 396,400 **** */ int ! add_signature(char *pck, int *size) { struct s_olsrmsg *msg; --- 396,400 ---- */ int ! add_signature(olsr_u8_t *pck, int *size) { struct s_olsrmsg *msg; *************** *** 432,435 **** --- 432,437 ---- *size = *size + sizeof(struct s_olsrmsg); + { + olsr_u8_t checksum_cache[512 + KEYLENGTH]; /* Create packet + key cache */ /* First the OLSR packet + signature message - digest */ *************** *** 440,444 **** /* Create the hash */ CHECKSUM(checksum_cache, (*size - SIGNATURE_SIZE) + KEYLENGTH, &pck[*size - SIGNATURE_SIZE]); ! #ifdef DEBUG --- 442,446 ---- /* Create the hash */ CHECKSUM(checksum_cache, (*size - SIGNATURE_SIZE) + KEYLENGTH, &pck[*size - SIGNATURE_SIZE]); ! } #ifdef DEBUG *************** *** 471,475 **** { int packetsize; ! char sha1_hash[SIGNATURE_SIZE]; struct s_olsrmsg *sig; time_t rec_time; --- 473,477 ---- { int packetsize; ! olsr_u8_t sha1_hash[SIGNATURE_SIZE]; struct s_olsrmsg *sig; time_t rec_time; *************** *** 541,545 **** one_checksum_SHA: ! /* Create packet + key cache */ /* First the OLSR packet + signature message - digest */ --- 543,549 ---- one_checksum_SHA: ! ! { ! olsr_u8_t checksum_cache[512 + KEYLENGTH]; /* Create packet + key cache */ /* First the OLSR packet + signature message - digest */ *************** *** 548,555 **** memcpy(&checksum_cache[*size - SIGNATURE_SIZE], aes_key, KEYLENGTH); - /* generate SHA-1 */ CHECKSUM(checksum_cache, *size - SIGNATURE_SIZE + KEYLENGTH, sha1_hash); ! #ifdef DEBUG --- 552,558 ---- memcpy(&checksum_cache[*size - SIGNATURE_SIZE], aes_key, KEYLENGTH); /* generate SHA-1 */ CHECKSUM(checksum_cache, *size - SIGNATURE_SIZE + KEYLENGTH, sha1_hash); ! } #ifdef DEBUG *************** *** 684,687 **** --- 687,692 ---- olsr_printf(3, "[ENC]Size: %d\n", sizeof(struct challengemsg)); + { + olsr_u8_t checksum_cache[512 + KEYLENGTH]; /* Create packet + key cache */ /* First the OLSR packet + signature message - digest */ *************** *** 694,698 **** (sizeof(struct challengemsg) - SIGNATURE_SIZE) + KEYLENGTH, cmsg.signature); ! olsr_printf(3, "[ENC]Sending timestamp request to %s challenge 0x%x\n", olsr_ip_to_string(new_host), --- 699,703 ---- (sizeof(struct challengemsg) - SIGNATURE_SIZE) + KEYLENGTH, cmsg.signature); ! } olsr_printf(3, "[ENC]Sending timestamp request to %s challenge 0x%x\n", olsr_ip_to_string(new_host), *************** *** 734,738 **** { struct c_respmsg *msg; ! char sha1_hash[SIGNATURE_SIZE]; struct stamp *entry; --- 739,743 ---- { struct c_respmsg *msg; ! olsr_u8_t sha1_hash[SIGNATURE_SIZE]; struct stamp *entry; *************** *** 752,755 **** --- 757,762 ---- /* Check signature */ + { + olsr_u8_t checksum_cache[512 + KEYLENGTH]; /* Create packet + key cache */ /* First the OLSR packet + signature message - digest */ *************** *** 762,765 **** --- 769,773 ---- (sizeof(struct c_respmsg) - SIGNATURE_SIZE) + KEYLENGTH, sha1_hash); + } if(memcmp(sha1_hash, &msg->signature, SIGNATURE_SIZE) != 0) *************** *** 783,786 **** --- 791,796 ---- olsr_printf(3, "[ENC]Entry-challenge 0x%x\n", entry->challenge); + { + olsr_u8_t checksum_cache[512 + KEYLENGTH]; /* First the challenge received */ memcpy(checksum_cache, &entry->challenge, 4); *************** *** 792,796 **** sizeof(olsr_u32_t) + olsr_cnf->ipsize, sha1_hash); ! if(memcmp(msg->res_sig, sha1_hash, SIGNATURE_SIZE) != 0) --- 802,806 ---- sizeof(olsr_u32_t) + olsr_cnf->ipsize, sha1_hash); ! } if(memcmp(msg->res_sig, sha1_hash, SIGNATURE_SIZE) != 0) *************** *** 831,835 **** { struct r_respmsg *msg; ! char sha1_hash[SIGNATURE_SIZE]; struct stamp *entry; --- 841,845 ---- { struct r_respmsg *msg; ! olsr_u8_t sha1_hash[SIGNATURE_SIZE]; struct stamp *entry; *************** *** 847,850 **** --- 857,862 ---- /* Check signature */ + { + olsr_u8_t checksum_cache[512 + KEYLENGTH]; /* Create packet + key cache */ /* First the OLSR packet + signature message - digest */ *************** *** 857,860 **** --- 869,873 ---- (sizeof(struct r_respmsg) - SIGNATURE_SIZE) + KEYLENGTH, sha1_hash); + } if(memcmp(sha1_hash, &msg->signature, SIGNATURE_SIZE) != 0) *************** *** 878,881 **** --- 891,896 ---- olsr_printf(3, "[ENC]Entry-challenge 0x%x\n", entry->challenge); + { + olsr_u8_t checksum_cache[512 + KEYLENGTH]; /* First the challenge received */ memcpy(checksum_cache, &entry->challenge, 4); *************** *** 887,891 **** sizeof(olsr_u32_t) + olsr_cnf->ipsize, sha1_hash); ! if(memcmp(msg->res_sig, sha1_hash, SIGNATURE_SIZE) != 0) --- 902,906 ---- sizeof(olsr_u32_t) + olsr_cnf->ipsize, sha1_hash); ! } if(memcmp(msg->res_sig, sha1_hash, SIGNATURE_SIZE) != 0) *************** *** 921,925 **** { struct challengemsg *msg; ! char sha1_hash[SIGNATURE_SIZE]; struct stamp *entry; olsr_u32_t hash; --- 936,940 ---- { struct challengemsg *msg; ! olsr_u8_t sha1_hash[SIGNATURE_SIZE]; struct stamp *entry; olsr_u32_t hash; *************** *** 969,972 **** --- 984,989 ---- /* Check signature */ + { + olsr_u8_t checksum_cache[512 + KEYLENGTH]; /* Create packet + key cache */ /* First the OLSR packet + signature message - digest */ *************** *** 979,983 **** (sizeof(struct challengemsg) - SIGNATURE_SIZE) + KEYLENGTH, sha1_hash); ! if(memcmp(sha1_hash, &msg->signature, SIGNATURE_SIZE) != 0) { --- 996,1000 ---- (sizeof(struct challengemsg) - SIGNATURE_SIZE) + KEYLENGTH, sha1_hash); ! } if(memcmp(sha1_hash, &msg->signature, SIGNATURE_SIZE) != 0) { *************** *** 1048,1051 **** --- 1065,1070 ---- /* Create digest of received challenge + IP */ + { + olsr_u8_t checksum_cache[512 + KEYLENGTH]; /* Create packet + key cache */ /* First the challenge received */ *************** *** 1058,1065 **** sizeof(olsr_u32_t) + olsr_cnf->ipsize, crmsg.res_sig); ! /* Now create the digest of the message and the key */ /* Create packet + key cache */ /* First the OLSR packet + signature message - digest */ --- 1077,1086 ---- sizeof(olsr_u32_t) + olsr_cnf->ipsize, crmsg.res_sig); ! } /* Now create the digest of the message and the key */ + { + olsr_u8_t checksum_cache[512 + KEYLENGTH]; /* Create packet + key cache */ /* First the OLSR packet + signature message - digest */ *************** *** 1072,1075 **** --- 1093,1097 ---- (sizeof(struct c_respmsg) - SIGNATURE_SIZE) + KEYLENGTH, crmsg.signature); + } olsr_printf(3, "[ENC]Sending challenge response to %s challenge 0x%x\n", *************** *** 1121,1124 **** --- 1143,1148 ---- /* Create digest of received challenge + IP */ + { + olsr_u8_t checksum_cache[512 + KEYLENGTH]; /* Create packet + key cache */ /* First the challenge received */ *************** *** 1131,1138 **** sizeof(olsr_u32_t) + olsr_cnf->ipsize, rrmsg.res_sig); ! /* Now create the digest of the message and the key */ /* Create packet + key cache */ /* First the OLSR packet + signature message - digest */ --- 1155,1164 ---- sizeof(olsr_u32_t) + olsr_cnf->ipsize, rrmsg.res_sig); ! } /* Now create the digest of the message and the key */ + { + olsr_u8_t checksum_cache[512 + KEYLENGTH]; /* Create packet + key cache */ /* First the OLSR packet + signature message - digest */ *************** *** 1145,1148 **** --- 1171,1175 ---- (sizeof(struct r_respmsg) - SIGNATURE_SIZE) + KEYLENGTH, rrmsg.signature); + } olsr_printf(3, "[ENC]Sending response response to %s\n", From (spam-protected) Wed Jan 31 13:36:52 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Wed, 31 Jan 2007 12:36:52 +0000 Subject: [Olsr-cvs] olsrd-current/src/cfgparser oparse.y,1.30,1.31 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src/cfgparser In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv15855/src/cfgparser Modified Files: oparse.y Log Message: * applied patches from the most recent FreiFunkFirmware (and fixed compile errors) according to http://www.olsr.org/pipermail/olsr-dev/2006-December/254036.html: - olsrd-libsmake.patch - olsrd-dyngwplain.patch - olsrd-txtinfo.patch - olsrd-quagga.patch - olsrd-quagga-routehandler.patch - olsrd-optimize.patch - olsrd-bmf-fixes.patch - olsrd-fixes-sven-ola.patch - olsrd-fixes-jhay-bsd.patch - olsrd-fixes-backport.patch - olsrd-fixes-routedel.patch - olsrd-cpu-overload.patch - olsrd-secure_key_path.patch - olsrd-hna_ip_fix.patch Not applied: - olsrd-nameservice+services.patch: This patch produced too many rejects to fix easily. - olsrd-fixes-eric.patch: This was not found on the webserver. - olsrd-bmf.patch: We had already a "bmf" plug-in in there. * made the checksum type in the olsrd_secure plug-in "olsr_u8_t" (instead of a wild "char *" and "unsigned char *" mix) everywhere. It killed lots of warnings. * localized the checksum_cache array in olsrd_secure.c. Index: oparse.y =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/cfgparser/oparse.y,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** oparse.y 12 Dec 2006 11:22:15 -0000 1.30 --- oparse.y 31 Jan 2007 12:36:50 -0000 1.31 *************** *** 723,726 **** --- 723,727 ---- } h->netmask.v4 = in.s_addr; + h->net.v4 &= h->netmask.v4; /* Queue */ h->next = cnf->hna4_entries; From (spam-protected) Wed Jan 31 13:36:52 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Wed, 31 Jan 2007 12:36:52 +0000 Subject: [Olsr-cvs] olsrd-current/src defs.h, 1.54, 1.55 duplicate_set.c, 1.12, 1.13 hashing.c, 1.9, 1.10 hashing.h, 1.8, 1.9 link_set.c, 1.64, 1.65 link_set.h, 1.29, 1.30 lq_avl.c, 1.1, 1.2 lq_avl.h, 1.2, 1.3 lq_list.c, 1.3, 1.4 lq_list.h, 1.3, 1.4 lq_packet.c, 1.21, 1.22 lq_route.c, 1.42, 1.43 main.c, 1.89, 1.90 net_olsr.h, 1.5, 1.6 olsr.c, 1.48, 1.49 olsr.h, 1.24, 1.25 olsr_types.h, 1.4, 1.5 parser.c, 1.31, 1.32 process_routes.c, 1.29, 1.30 process_routes.h, 1.9, 1.10 scheduler.c, 1.36, 1.37 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv15855/src Modified Files: defs.h duplicate_set.c hashing.c hashing.h link_set.c link_set.h lq_avl.c lq_avl.h lq_list.c lq_list.h lq_packet.c lq_route.c main.c net_olsr.h olsr.c olsr.h olsr_types.h parser.c process_routes.c process_routes.h scheduler.c Log Message: * applied patches from the most recent FreiFunkFirmware (and fixed compile errors) according to http://www.olsr.org/pipermail/olsr-dev/2006-December/254036.html: - olsrd-libsmake.patch - olsrd-dyngwplain.patch - olsrd-txtinfo.patch - olsrd-quagga.patch - olsrd-quagga-routehandler.patch - olsrd-optimize.patch - olsrd-bmf-fixes.patch - olsrd-fixes-sven-ola.patch - olsrd-fixes-jhay-bsd.patch - olsrd-fixes-backport.patch - olsrd-fixes-routedel.patch - olsrd-cpu-overload.patch - olsrd-secure_key_path.patch - olsrd-hna_ip_fix.patch Not applied: - olsrd-nameservice+services.patch: This patch produced too many rejects to fix easily. - olsrd-fixes-eric.patch: This was not found on the webserver. - olsrd-bmf.patch: We had already a "bmf" plug-in in there. * made the checksum type in the olsrd_secure plug-in "olsr_u8_t" (instead of a wild "char *" and "unsigned char *" mix) everywhere. It killed lots of warnings. * localized the checksum_cache array in olsrd_secure.c. Index: lq_route.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/lq_route.c,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** lq_route.c 14 Dec 2006 11:29:20 -0000 1.42 --- lq_route.c 31 Jan 2007 12:36:50 -0000 1.43 *************** *** 78,81 **** --- 78,82 ---- } + #ifdef DISABLE_SVEN_OLA static int avl_comp_ipv4(void *ip1, void *ip2) { *************** *** 88,91 **** --- 89,93 ---- return 1; } + #endif static int (*avl_comp)(void *, void *); *************** *** 205,209 **** // add the vertex to the list, if it's not us ! if ((*comp)(&olsr_cnf->main_addr, node->key) != 0) { --- 207,220 ---- // add the vertex to the list, if it's not us ! #ifndef DISABLE_SVEN_OLA ! if (NULL == comp) { ! if (svenola_avl_comp_ipv4(&olsr_cnf->main_addr, node->key) != 0) ! { ! vert->node.data = vert; ! list_add_tail(vertex_list, &vert->node); ! } ! } ! else ! #endif if ((*comp)(&olsr_cnf->main_addr, node->key) != 0) { *************** *** 267,270 **** --- 278,431 ---- // XXX - bad complexity + #define SVEN_OPT + #undef SVEN_OPT_DBG + + /* + * The function extract_best() is most expensive (>50% CPU in profiling). + * It is called in two modes: while doing Dijkstra route calculation and + * while searching for a direct route/hna. The latter can be optimized + * because the stored verices do not change from call to call and it is + * more sufficient to have them sorted/popped from a list rather than + * searching the complete list by every call. Sven-Ola at gmx.de, 11/2006 + */ + + #ifdef SVEN_OPT + static struct dijk_vertex **etx_cache = 0; + static int etx_cache_count; + static int etx_cache_get; + #ifdef SVEN_OPT_DBG + static int etx_cache_saved = 0; + #endif + + static int etx_cache_compare(const void *a, const void *b) + { + // Oh jeah. I love this macro assembler :) + + if ((*(struct dijk_vertex **)a)->path_etx > (*(struct dijk_vertex **)b)->path_etx) return 1; + if ((*(struct dijk_vertex **)a)->path_etx < (*(struct dijk_vertex **)b)->path_etx) return -1; + + // This is for debugging only: etx==etx then compare pointers + // to make it possible to compare to the original search algo. + if (*(struct dijk_vertex **)a > *(struct dijk_vertex **)b) return 1; + if (*(struct dijk_vertex **)a < *(struct dijk_vertex **)b) return -1; + + return 0; + } + + static struct dijk_vertex *extract_best_route(struct list *vertex_list) + { + #ifdef SVEN_OPT_DBG + float best_etx = INFINITE_ETX + 1.0; + #endif + struct list_node *node; + struct dijk_vertex *vert; + struct dijk_vertex *res = NULL; + + #ifdef SVEN_OPT_DBG + node = list_get_head(vertex_list); + + // loop through all vertices + + while (node != NULL) + { + vert = node->data; + + // see whether the current vertex is better than what we have + + if (!vert->done && vert->path_etx < best_etx) + { + best_etx = vert->path_etx; + res = vert; + } + else if (!vert->done && vert->path_etx == best_etx && vert < res) + { + // Otherwise order is undefined if etx==etx and debug will complain + best_etx = vert->path_etx; + res = vert; + } + + node = list_get_next(node); + } + #endif + if (NULL == etx_cache) + { + int count = 0; + node = list_get_head(vertex_list); + while (node != NULL) + { + vert = node->data; + if (!vert->done && vert->path_etx < INFINITE_ETX) count++; + node = list_get_next(node); + } + if (0 < count) + { + etx_cache = olsr_malloc(sizeof(etx_cache[0]) * count, "ETX Cache"); + #ifdef SVEN_OPT_DBG + printf("count=%d, Malloc(%d)=%p\n", count, sizeof(etx_cache[0]) * count, etx_cache); + #endif + node = list_get_head(vertex_list); + etx_cache_count = 0; + etx_cache_get = 0; + while (node != NULL) + { + vert = node->data; + if (!vert->done && vert->path_etx < INFINITE_ETX) + { + etx_cache[etx_cache_count] = vert; + etx_cache_count++; + } + node = list_get_next(node); + } + #ifdef SVEN_OPT_DBG + printf("qsort(etx_cache_count=%d)\n", etx_cache_count); + #endif + qsort(etx_cache, etx_cache_count, sizeof(etx_cache[0]), etx_cache_compare); + #ifdef SVEN_OPT_DBG + if (0 < etx_cache_count) + { + int i = 0; + while(i < etx_cache_count && i < 10) + { + printf("%d: %p=%f\n", i, etx_cache[i], etx_cache[i]->path_etx); + i++; + } + } + #endif + } + } + + #ifdef SVEN_OPT_DBG + if (NULL != etx_cache) + { + struct dijk_vertex *rescache = NULL; + if (etx_cache_get < etx_cache_count) + { + rescache = etx_cache[etx_cache_get++]; + } + if (res != rescache) + { + printf("miss: etx_cache_get=%d, res=%p,%f != rescache=%p,%f\n", + etx_cache_get, res, (NULL != res ? res->path_etx : -1), rescache, (NULL != rescache ? rescache->path_etx : -1)); + } + else + { + etx_cache_saved++; + } + } + #else + if (NULL != etx_cache && etx_cache_get < etx_cache_count) + { + res = etx_cache[etx_cache_get++]; + } + #endif + + // if we've found a vertex, remove it from the set + + if (res != NULL) + res->done = OLSR_TRUE; + + return res; + } + #endif // SVEN_OPT static struct dijk_vertex *extract_best(struct list *vertex_list) *************** *** 372,377 **** if (olsr_cnf->ipsize == 4) avl_comp = avl_comp_ipv4; ! else avl_comp = avl_comp_ipv6; --- 533,541 ---- if (olsr_cnf->ipsize == 4) + #ifndef DISABLE_SVEN_OLA + avl_comp = 0; + #else avl_comp = avl_comp_ipv4; ! #endif else avl_comp = avl_comp_ipv6; *************** *** 615,618 **** --- 779,792 ---- // add HNA routes - the set of unprocessed network nodes contains // all reachable network nodes + #ifdef SVEN_OPT + #ifdef SVEN_OPT_DBG + printf("free etx_cache, saved compares=%d, etx_cache=%p\n", etx_cache_saved, etx_cache); + etx_cache_saved = 0; + #endif + if (NULL != etx_cache) { + free(etx_cache); + etx_cache = NULL; + } + #endif for (;;) *************** *** 621,625 **** --- 795,803 ---- // from the set of unprocessed network nodes + #ifdef SVEN_OPT + vert = extract_best_route(&vertex_list); + #else vert = extract_best(&vertex_list); + #endif // no more nodes left Index: duplicate_set.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/duplicate_set.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** duplicate_set.c 27 Feb 2005 18:39:43 -0000 1.12 --- duplicate_set.c 31 Jan 2007 12:36:50 -0000 1.13 *************** *** 94,98 **** /* Hash the senders address */ ! hash = olsr_hashing(originator); new_dup_entry = olsr_malloc(sizeof(struct dup_entry), "New dup entry"); --- 94,98 ---- /* Hash the senders address */ ! hash = HASHMASK & seqno; new_dup_entry = olsr_malloc(sizeof(struct dup_entry), "New dup entry"); *************** *** 132,136 **** /* Hash the senders address */ ! hash = olsr_hashing(originator); /* Check for entry */ --- 132,136 ---- /* Hash the senders address */ ! hash = HASHMASK & seqno; /* Check for entry */ *************** *** 164,168 **** /* Hash the senders address */ ! hash = olsr_hashing(originator); /* Check for entry */ --- 164,168 ---- /* Hash the senders address */ ! hash = HASHMASK & seqno; /* Check for entry */ *************** *** 269,273 **** /* Hash the senders address */ ! hash = olsr_hashing(originator); --- 269,273 ---- /* Hash the senders address */ ! hash = HASHMASK & seqno; *************** *** 314,318 **** /* Hash the senders address */ ! hash = olsr_hashing(originator); /* Check for entry */ --- 314,318 ---- /* Hash the senders address */ ! hash = HASHMASK & seqno; /* Check for entry */ Index: lq_list.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/lq_list.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** lq_list.h 20 Feb 2005 18:52:18 -0000 1.3 --- lq_list.h 31 Jan 2007 12:36:50 -0000 1.4 *************** *** 59,62 **** --- 59,68 ---- void list_init(struct list *list); + #ifndef DISABLE_SVEN_OLA + #define list_get_head(node) (node)->head + #define list_get_tail(node) (node)->tail + #define list_get_next(node) (node)->next + #define list_get_prev(node) (node)->prev + #else struct list_node *list_get_head(struct list *list); struct list_node *list_get_tail(struct list *list); *************** *** 64,67 **** --- 70,74 ---- struct list_node *list_get_next(struct list_node *node); struct list_node *list_get_prev(struct list_node *node); + #endif void list_add_head(struct list *list, struct list_node *node); Index: process_routes.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/process_routes.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** process_routes.h 29 May 2005 12:47:45 -0000 1.9 --- process_routes.h 31 Jan 2007 12:36:50 -0000 1.10 *************** *** 51,54 **** --- 51,82 ---- extern struct rt_entry old_hna[HASHSIZE]; + void + olsr_init_export_route(void); + + void + olsr_addroute_add_function(int (*)(struct rt_entry*), olsr_u8_t); + + int + olsr_addroute_remove_function(int (*)(struct rt_entry*), olsr_u8_t); + + void + olsr_delroute_add_function(int (*)(struct rt_entry*), olsr_u8_t); + + int + olsr_delroute_remove_function(int (*)(struct rt_entry*), olsr_u8_t); + + int + olsr_export_add_route (struct rt_entry*); + + int + olsr_export_del_route (struct rt_entry*); + + int + olsr_export_add_route6 (struct rt_entry*); + + int + olsr_export_del_route6 (struct rt_entry*); + + int olsr_init_old_table(void); Index: net_olsr.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/net_olsr.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** net_olsr.h 15 Nov 2006 21:13:52 -0000 1.5 --- net_olsr.h 31 Jan 2007 12:36:50 -0000 1.6 *************** *** 50,54 **** #include ! typedef int (*packet_transform_function)(char *, int *); #ifdef USE_LIBNET --- 50,54 ---- #include ! typedef int (*packet_transform_function)(olsr_u8_t *, int *); #ifdef USE_LIBNET Index: lq_list.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/lq_list.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** lq_list.c 4 Dec 2004 17:06:57 -0000 1.3 --- lq_list.c 31 Jan 2007 12:36:50 -0000 1.4 *************** *** 49,52 **** --- 49,53 ---- } + #ifdef DISABLE_SVEN_OLA struct list_node *list_get_head(struct list *list) { *************** *** 68,71 **** --- 69,73 ---- return node->prev; } + #endif void list_add_head(struct list *list, struct list_node *node) Index: lq_packet.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/lq_packet.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** lq_packet.c 11 Oct 2006 20:58:45 -0000 1.21 --- lq_packet.c 31 Jan 2007 12:36:50 -0000 1.22 *************** *** 151,155 **** struct neighbor_entry *walker; struct link_entry *link; ! static int ttl_list[] = { MAX_TTL, 3, 2, 1, 2, 1, 1, 3, 2, 1, 2, 1, 1, 0 }; // remember that we have generated an LQ TC message; this is --- 151,155 ---- 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 *************** *** 168,174 **** if (olsr_cnf->lq_fish > 0) { if (ttl_list[outif->ttl_index] == 0) outif->ttl_index = 0; ! lq_tc->comm.ttl = ttl_list[outif->ttl_index++]; --- 168,178 ---- if (olsr_cnf->lq_fish > 0) { + // SVEN_OLA: Too lazy to find the different iface inits. This will do it too. + if (outif->ttl_index >= (int)(sizeof(ttl_list) / sizeof(ttl_list[0]))) + outif->ttl_index = 0; + if (ttl_list[outif->ttl_index] == 0) outif->ttl_index = 0; ! lq_tc->comm.ttl = ttl_list[outif->ttl_index++]; *************** *** 224,229 **** link = get_best_link_to_neighbor(&neigh->main); ! neigh->link_quality = link->loss_link_quality; ! neigh->neigh_link_quality = link->neigh_link_quality; // queue the neighbour entry --- 228,235 ---- 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; ! } // queue the neighbour entry Index: olsr_types.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/olsr_types.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** olsr_types.h 15 May 2005 12:57:24 -0000 1.4 --- olsr_types.h 31 Jan 2007 12:36:50 -0000 1.5 *************** *** 94,97 **** --- 94,98 ---- { olsr_u32_t v4; + olsr_u8_t v4x[4]; struct in6_addr v6; }; Index: olsr.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/olsr.c,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** olsr.c 7 Jan 2006 08:16:20 -0000 1.48 --- olsr.c 31 Jan 2007 12:36:50 -0000 1.49 *************** *** 69,72 **** --- 69,73 ---- olsr_bool changes_neighborhood; olsr_bool changes_hna; + olsr_bool changes_force; /** *************** *** 143,146 **** --- 144,152 ---- #endif + if(!changes_force && + 2 <= olsr_cnf->lq_level && + 0 >= olsr_cnf->lq_dlimit) + return; + if(!changes_neighborhood && !changes_topology && *************** *** 172,180 **** olsr_calculate_hna_routes(); } - - else - { - olsr_calculate_lq_routing_table(); - } } --- 178,181 ---- *************** *** 188,196 **** olsr_calculate_hna_routes(); } - - else - { - olsr_calculate_lq_routing_table(); - } } --- 189,192 ---- *************** *** 203,211 **** olsr_calculate_hna_routes(); } ! ! else ! { ! olsr_calculate_lq_routing_table(); ! } } --- 199,207 ---- olsr_calculate_hna_routes(); } ! } ! ! if (olsr_cnf->lq_level >= 2) ! { ! olsr_calculate_lq_routing_table(); } *************** *** 240,243 **** --- 236,240 ---- changes_topology = OLSR_FALSE; changes_hna = OLSR_FALSE; + changes_force = OLSR_FALSE; Index: parser.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/parser.c,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** parser.c 14 Dec 2006 11:29:20 -0000 1.31 --- parser.c 31 Jan 2007 12:36:50 -0000 1.32 *************** *** 62,65 **** --- 62,73 ---- #endif + /* Sven-Ola: On very slow devices used in huge networks + * the amount of lq_tc messages is so high, that the + * recv() loop never ends. This is a small hack to end + * the loop in this cases + */ + + unsigned int cpu_overload_exit = 0; + struct parse_function_entry *parse_functions; *************** *** 356,362 **** struct interface *olsr_in_if; union olsr_ip_addr from_addr; ! for (;;) { fromlen = sizeof(struct sockaddr_storage); --- 364,377 ---- struct interface *olsr_in_if; union olsr_ip_addr from_addr; ! cpu_overload_exit = 0; ! for (;;) { + if (32 < ++cpu_overload_exit) + { + OLSR_PRINTF(1, "CPU overload detected, ending olsr_input() loop\n") + break; + } + fromlen = sizeof(struct sockaddr_storage); Index: scheduler.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/scheduler.c,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** scheduler.c 27 Jul 2006 15:53:16 -0000 1.36 --- scheduler.c 31 Jan 2007 12:36:50 -0000 1.37 *************** *** 84,87 **** --- 84,88 ---- changes_neighborhood = OLSR_TRUE; changes_topology = OLSR_TRUE; + changes_force = OLSR_TRUE; } Index: hashing.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/hashing.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** hashing.c 20 Feb 2005 18:52:18 -0000 1.9 --- hashing.c 31 Jan 2007 12:36:50 -0000 1.10 *************** *** 59,63 **** if(olsr_cnf->ip_version == AF_INET) /* IPv4 */ ! hash = (ntohl(address->v4)); else { --- 59,63 ---- if(olsr_cnf->ip_version == AF_INET) /* IPv4 */ ! hash = address->v4x[0] ^ address->v4x[1] ^ address->v4x[2] ^ address->v4x[3]; else { Index: hashing.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/hashing.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** hashing.h 20 Feb 2005 18:52:18 -0000 1.8 --- hashing.h 31 Jan 2007 12:36:50 -0000 1.9 *************** *** 44,48 **** #define _OLSR_HASHING ! #define HASHSIZE 32 #define HASHMASK (HASHSIZE - 1) --- 44,48 ---- #define _OLSR_HASHING ! #define HASHSIZE 128 #define HASHMASK (HASHSIZE - 1) Index: defs.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/defs.h,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** defs.h 15 Nov 2006 23:07:59 -0000 1.54 --- defs.h 31 Jan 2007 12:36:50 -0000 1.55 *************** *** 71,75 **** #define MAXMESSAGESIZE 1500 /* max broadcast size */ #define UDP_IPV4_HDRSIZE 28 ! #define UDP_IPV6_HDRSIZE 48 #define MIN_PACKET_SIZE(ver) (int)(sizeof(olsr_u8_t) * ((ver == AF_INET) ? 4 : 7)) --- 71,75 ---- #define MAXMESSAGESIZE 1500 /* max broadcast size */ #define UDP_IPV4_HDRSIZE 28 ! #define UDP_IPV6_HDRSIZE 62 #define MIN_PACKET_SIZE(ver) (int)(sizeof(olsr_u8_t) * ((ver == AF_INET) ? 4 : 7)) Index: lq_avl.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/lq_avl.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** lq_avl.c 22 Jan 2005 14:30:57 -0000 1.1 --- lq_avl.c 31 Jan 2007 12:36:50 -0000 1.2 *************** *** 41,44 **** --- 41,47 ---- #include + #ifndef DISABLE_SVEN_OLA + #include + #endif #include "lq_avl.h" *************** *** 53,56 **** --- 56,76 ---- } + #ifndef DISABLE_SVEN_OLA + static struct avl_node *avl_find_rec_ipv4(struct avl_node *node, void *key) + { + if (*(unsigned int *)key < *(unsigned int *)node->key) { + if (node->left != NULL) { + return avl_find_rec_ipv4(node->left, key); + } + } + else if (*(unsigned int *)key > *(unsigned int *)node->key) { + if (node->right != NULL) { + return avl_find_rec_ipv4(node->right, key); + } + } + return node; + } + #endif + static struct avl_node *avl_find_rec(struct avl_node *node, void *key, int (*comp)(void *, void *)) *************** *** 58,61 **** --- 78,86 ---- int diff; + #ifndef DISABLE_SVEN_OLA + if (0 == comp) { + return avl_find_rec_ipv4(node, key); + } + #endif diff = (*comp)(key, node->key); *************** *** 88,91 **** --- 113,123 ---- node = avl_find_rec(tree->root, key, tree->comp); + #ifndef DISABLE_SVEN_OLA + if (0 == tree->comp) { + if (0 != svenola_avl_comp_ipv4(node->key, key)) + return NULL; + } + else + #endif if ((*tree->comp)(node->key, key) != 0) return NULL; *************** *** 229,232 **** --- 261,270 ---- node = avl_find_rec(tree->root, new->key, tree->comp); + #ifndef DISABLE_SVEN_OLA + if (0 == tree->comp) { + diff = svenola_avl_comp_ipv4(new->key, node->key); + } + else + #endif diff = (*tree->comp)(new->key, node->key); Index: olsr.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/olsr.h,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** olsr.h 29 May 2005 12:47:45 -0000 1.24 --- olsr.h 31 Jan 2007 12:36:50 -0000 1.25 *************** *** 50,53 **** --- 50,54 ---- extern olsr_bool changes_neighborhood; extern olsr_bool changes_hna; + extern olsr_bool changes_force; void Index: link_set.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/link_set.h,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** link_set.h 14 Dec 2006 11:29:19 -0000 1.29 --- link_set.h 31 Jan 2007 12:36:50 -0000 1.30 *************** *** 118,121 **** --- 118,124 ---- olsr_init_link_set(void); + void + del_if_link_entries(union olsr_ip_addr *); + struct link_entry * get_best_link_to_neighbor(union olsr_ip_addr *); Index: link_set.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/link_set.c,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** link_set.c 14 Dec 2006 11:29:19 -0000 1.64 --- link_set.c 31 Jan 2007 12:36:50 -0000 1.65 *************** *** 383,386 **** --- 383,449 ---- /** + *Delete all interface link entries + * + *@param interface ip address + */ + + void + del_if_link_entries(union olsr_ip_addr *int_addr) + { + struct link_entry *tmp_link_set, *last_link_entry; + + if(link_set == NULL) + return; + + tmp_link_set = link_set; + last_link_entry = NULL; + + while(tmp_link_set) + { + + if(COMP_IP(int_addr, &tmp_link_set->local_iface_addr)) + { + if(last_link_entry != NULL) + { + last_link_entry->next = tmp_link_set->next; + + /* Delete neighbor entry */ + if(tmp_link_set->neighbor->linkcount == 1) + olsr_delete_neighbor_table(&tmp_link_set->neighbor->neighbor_main_addr); + else + tmp_link_set->neighbor->linkcount--; + + //olsr_delete_neighbor_if_no_link(&tmp_link_set->neighbor->neighbor_main_addr); + changes_neighborhood = OLSR_TRUE; + + free(tmp_link_set); + tmp_link_set = last_link_entry; + } + else + { + link_set = tmp_link_set->next; /* CHANGED */ + + /* Delete neighbor entry */ + if(tmp_link_set->neighbor->linkcount == 1) + olsr_delete_neighbor_table(&tmp_link_set->neighbor->neighbor_main_addr); + else + tmp_link_set->neighbor->linkcount--; + + changes_neighborhood = OLSR_TRUE; + + free(tmp_link_set); + tmp_link_set = link_set; + continue; + } + } + + last_link_entry = tmp_link_set; + tmp_link_set = tmp_link_set->next; + } + + return; + } + + /** *Nothing mysterious here. *Adding a new link entry to the link set. *************** *** 960,965 **** entry->loss_link_quality = (float)(entry->total_packets - entry->lost_packets) / ! (float)(entry->loss_window_size); ! // multiply the calculated link quality with the user-specified multiplier --- 1023,1029 ---- entry->loss_link_quality = (float)(entry->total_packets - entry->lost_packets) / ! (float)(entry->loss_window_size < (2 * 4) ? entry->loss_window_size: ! 4 * ((entry->loss_window_size / 4 - 1) * entry->total_packets + entry->loss_window_size) / entry->loss_window_size); ! // multiply the calculated link quality with the user-specified multiplier Index: main.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/main.c,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** main.c 14 Apr 2006 05:04:16 -0000 1.89 --- main.c 31 Jan 2007 12:36:50 -0000 1.90 *************** *** 283,286 **** --- 283,289 ---- olsr_init_parser(); + /* Initialize route-exporter */ + olsr_init_export_route(); + /* Initialize message sequencnumber */ init_msg_seqno(); *************** *** 511,515 **** fprintf(stderr, " [-midint ] [-hnaint ]\n"); fprintf(stderr, " [-T ] [-nofork] [-hemu ] \n"); ! } --- 514,518 ---- fprintf(stderr, " [-midint ] [-hnaint ]\n"); fprintf(stderr, " [-T ] [-nofork] [-hemu ] \n"); ! fprintf(stderr, " [-lql ] [-lqw ]\n"); } Index: process_routes.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/process_routes.c,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** process_routes.c 14 Dec 2006 11:29:20 -0000 1.29 --- process_routes.c 31 Jan 2007 12:36:50 -0000 1.30 *************** *** 4,7 **** --- 4,10 ---- * All rights reserved. * + * export_route_entry interface added by Immo 'FaUl Wehrenberg + * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions *************** *** 40,44 **** */ - #include "defs.h" #include "olsr.h" --- 43,46 ---- *************** *** 52,59 **** --- 54,213 ---- #endif + struct export_route_entry + { + olsr_u8_t type; /* AF_INET/AF_INET6 */ + int (*function)(struct rt_entry*); + struct export_route_entry *next; + }; + + + static struct export_route_entry *add_routes; + static struct export_route_entry *del_routes; + struct rt_entry old_routes[HASHSIZE]; struct rt_entry old_hna[HASHSIZE]; + void + olsr_addroute_add_function(int (*function)(struct rt_entry*), olsr_u8_t type) + { + struct export_route_entry *tmp; + tmp = olsr_malloc(sizeof *tmp, "olsr_addroute_add_function"); + tmp->type = type; + tmp->function = function; + tmp->next = add_routes; + add_routes = tmp; + } + + void + olsr_delroute_add_function(int (*function) (struct rt_entry*), olsr_u8_t type) + { + struct export_route_entry *tmp; + tmp = olsr_malloc(sizeof *tmp, "olsr_delroute_add_function"); + tmp->type = type; + tmp->function = function; + tmp->next = del_routes; + del_routes = tmp; + } + + + int + olsr_addroute_remove_function(int (*function) (struct rt_entry*), olsr_u8_t type) + { + struct export_route_entry *tmp, *prev = NULL /* Make compiler happy */; + tmp = add_routes; + while (tmp) + { + if (function == tmp->function && type == tmp->type) + { + if (tmp == add_routes) + { + add_routes = add_routes->next; + free (tmp); + return 1; + } + else + { + prev->next = tmp->next; + free (tmp); + return 1; + } + } + prev = tmp; + tmp = tmp->next; + } + return 0; + } + + int + olsr_delroute_remove_function(int (*function) (struct rt_entry*), olsr_u8_t type) + { + struct export_route_entry *tmp, *prev = NULL /* Make compiler happy */; + tmp = del_routes; + while (tmp) + { + if (function == tmp->function && type == tmp->type) + { + if (tmp == del_routes) + { + del_routes = del_routes->next; + free (tmp); + return 1; + } + else + { + prev->next = tmp->next; + free (tmp); + return 1; + } + } + prev = tmp; + tmp = tmp->next; + } + return 0; + } + + void + olsr_init_export_route() + { + olsr_addroute_add_function(&olsr_ioctl_add_route, AF_INET); + olsr_addroute_add_function(&olsr_ioctl_add_route6, AF_INET6); + olsr_delroute_add_function(&olsr_ioctl_del_route, AF_INET); + olsr_delroute_add_function(&olsr_ioctl_del_route6, AF_INET6); + } + + int + olsr_export_add_route (struct rt_entry *e) + { + int retval = 0; + struct export_route_entry *tmp; + for (tmp = add_routes; tmp; tmp = tmp->next) + { + if (tmp->type == AF_INET) + retval = tmp->function(e); + } + return retval; + } + + int + olsr_export_add_route6 (struct rt_entry *e) + { + int retval = 0; + struct export_route_entry *tmp; + for (tmp = add_routes; tmp; tmp = tmp->next) + { + if (tmp->type == AF_INET6) + retval = tmp->function(e); + } + return retval; + } + + int + olsr_export_del_route (struct rt_entry *e) + { + int retval = 0; + struct export_route_entry *tmp; + for (tmp = del_routes; tmp; tmp = tmp->next) + { + if (tmp->type == AF_INET) + retval = tmp->function(e); + } + return retval; + } + + int + olsr_export_del_route6 (struct rt_entry *e) + { + int retval = 0; + struct export_route_entry *tmp; + for (tmp = del_routes; tmp; tmp = tmp->next) + { + if (tmp->type == AF_INET6) + retval = tmp->function(e); + } + return retval; + } + + int *************** *** 349,355 **** { if(olsr_cnf->ip_version == AF_INET) ! error = olsr_ioctl_del_route(destination_ptr->destination); else ! error = olsr_ioctl_del_route6(destination_ptr->destination); if(error < 0) --- 503,509 ---- { if(olsr_cnf->ip_version == AF_INET) ! error = olsr_export_del_route(destination_ptr->destination); else ! error = olsr_export_del_route6(destination_ptr->destination); if(error < 0) *************** *** 435,441 **** { if(olsr_cnf->ip_version == AF_INET) ! error=olsr_ioctl_add_route(destination_kernel->destination); else ! error=olsr_ioctl_add_route6(destination_kernel->destination); if(error < 0) --- 589,595 ---- { if(olsr_cnf->ip_version == AF_INET) ! error=olsr_export_add_route(destination_kernel->destination); else ! error=olsr_export_add_route6(destination_kernel->destination); if(error < 0) Index: lq_avl.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/lq_avl.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** lq_avl.h 20 Feb 2005 18:52:18 -0000 1.2 --- lq_avl.h 31 Jan 2007 12:36:50 -0000 1.3 *************** *** 63,65 **** --- 63,70 ---- int avl_insert(struct avl_tree *, struct avl_node *); + #ifndef DISABLE_SVEN_OLA + #define svenola_avl_comp_ipv4(ip1, ip2) \ + (*(unsigned int *)ip1 == *(unsigned int *)ip2 ? 0 : \ + *(unsigned int *)ip1 < *(unsigned int *)ip2 ? -1 : +1) + #endif #endif From (spam-protected) Wed Jan 31 13:38:28 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Wed, 31 Jan 2007 12:38:28 +0000 Subject: [Olsr-cvs] olsrd-current/lib/dyn_gw_plain .cvsignore, NONE, 1.1 Makefile, NONE, 1.1 README_DYN_GW_PLAIN, NONE, 1.1 version-script.txt, NONE, 1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/dyn_gw_plain In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16361/lib/dyn_gw_plain Added Files: .cvsignore Makefile README_DYN_GW_PLAIN version-script.txt Log Message: * applied patches from the most recent FreiFunkFirmware (and fixed compile errors) according to http://www.olsr.org/pipermail/olsr-dev/2006-December/254036.html: - olsrd-libsmake.patch - olsrd-dyngwplain.patch - olsrd-txtinfo.patch - olsrd-quagga.patch - olsrd-quagga-routehandler.patch - olsrd-optimize.patch - olsrd-bmf-fixes.patch - olsrd-fixes-sven-ola.patch - olsrd-fixes-jhay-bsd.patch - olsrd-fixes-backport.patch - olsrd-fixes-routedel.patch - olsrd-cpu-overload.patch - olsrd-secure_key_path.patch - olsrd-hna_ip_fix.patch Not applied: - olsrd-nameservice+services.patch: This patch produced too many rejects to fix easily. - olsrd-fixes-eric.patch: This was not found on the webserver. - olsrd-bmf.patch: We had already a "bmf" plug-in in there. * made the checksum type in the olsrd_secure plug-in "olsr_u8_t" (instead of a wild "char *" and "unsigned char *" mix) everywhere. It killed lots of warnings. * localized the checksum_cache array in olsrd_secure.c. --- NEW FILE: .cvsignore --- *.d olsrd_dyn_gw_plain.so.* --- NEW FILE: Makefile --- (This appears to be a binary file; contents omitted.) --- NEW FILE: version-script.txt --- VERS_1.0 { global: olsrd_plugin_interface_version; olsrd_plugin_register_param; olsrd_plugin_init; local: *; }; --- NEW FILE: README_DYN_GW_PLAIN --- (This appears to be a binary file; contents omitted.) From (spam-protected) Wed Jan 31 13:38:28 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Wed, 31 Jan 2007 12:38:28 +0000 Subject: [Olsr-cvs] olsrd-current/lib/txtinfo .cvsignore, NONE, 1.1 Makefile, NONE, 1.1 README_TXTINFO, NONE, 1.1 version-script.txt, NONE, 1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/txtinfo In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16361/lib/txtinfo Added Files: .cvsignore Makefile README_TXTINFO version-script.txt Log Message: * applied patches from the most recent FreiFunkFirmware (and fixed compile errors) according to http://www.olsr.org/pipermail/olsr-dev/2006-December/254036.html: - olsrd-libsmake.patch - olsrd-dyngwplain.patch - olsrd-txtinfo.patch - olsrd-quagga.patch - olsrd-quagga-routehandler.patch - olsrd-optimize.patch - olsrd-bmf-fixes.patch - olsrd-fixes-sven-ola.patch - olsrd-fixes-jhay-bsd.patch - olsrd-fixes-backport.patch - olsrd-fixes-routedel.patch - olsrd-cpu-overload.patch - olsrd-secure_key_path.patch - olsrd-hna_ip_fix.patch Not applied: - olsrd-nameservice+services.patch: This patch produced too many rejects to fix easily. - olsrd-fixes-eric.patch: This was not found on the webserver. - olsrd-bmf.patch: We had already a "bmf" plug-in in there. * made the checksum type in the olsrd_secure plug-in "olsr_u8_t" (instead of a wild "char *" and "unsigned char *" mix) everywhere. It killed lots of warnings. * localized the checksum_cache array in olsrd_secure.c. --- NEW FILE: .cvsignore --- *.d olsrd_txtinfo.so.* --- NEW FILE: README_TXTINFO --- LoadPlugin "olsrd_txtinfo.so.0.1" { PlParam "accept" "10.247.200.4" } ABOUT telnet 127.0.0.1 2006 or wget localhost:2006 -qO - installation: make make install - Lorenz Schori --- NEW FILE: Makefile --- (This appears to be a binary file; contents omitted.) --- NEW FILE: version-script.txt --- VERS_1.0 { global: olsrd_plugin_interface_version; olsrd_plugin_register_param; olsrd_plugin_init; local: *; }; From (spam-protected) Wed Jan 31 13:38:28 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Wed, 31 Jan 2007 12:38:28 +0000 Subject: [Olsr-cvs] olsrd-current/lib/quagga/src/quagga zassert.h, NONE, 1.1 zebra.h, NONE, 1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/quagga/src/quagga In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16361/lib/quagga/src/quagga Added Files: zassert.h zebra.h Log Message: * applied patches from the most recent FreiFunkFirmware (and fixed compile errors) according to http://www.olsr.org/pipermail/olsr-dev/2006-December/254036.html: - olsrd-libsmake.patch - olsrd-dyngwplain.patch - olsrd-txtinfo.patch - olsrd-quagga.patch - olsrd-quagga-routehandler.patch - olsrd-optimize.patch - olsrd-bmf-fixes.patch - olsrd-fixes-sven-ola.patch - olsrd-fixes-jhay-bsd.patch - olsrd-fixes-backport.patch - olsrd-fixes-routedel.patch - olsrd-cpu-overload.patch - olsrd-secure_key_path.patch - olsrd-hna_ip_fix.patch Not applied: - olsrd-nameservice+services.patch: This patch produced too many rejects to fix easily. - olsrd-fixes-eric.patch: This was not found on the webserver. - olsrd-bmf.patch: We had already a "bmf" plug-in in there. * made the checksum type in the olsrd_secure plug-in "olsr_u8_t" (instead of a wild "char *" and "unsigned char *" mix) everywhere. It killed lots of warnings. * localized the checksum_cache array in olsrd_secure.c. --- NEW FILE: zebra.h --- /* Zebra common header. Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Kunihiro Ishiguro This file is part of GNU Zebra. GNU Zebra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Zebra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Zebra; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _ZEBRA_H #define _ZEBRA_H #ifdef HAVE_CONFIG_H #include "config.h" #endif /* HAVE_CONFIG_H */ #ifdef SUNOS_5 #define _XPG4_2 #define __EXTENSIONS__ typedef unsigned int u_int32_t; typedef unsigned short u_int16_t; typedef unsigned char u_int8_t; #endif /* SUNOS_5 */ #ifndef HAVE_SOCKLEN_T typedef int socklen_t; #endif /* HAVE_SOCKLEN_T */ #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_STROPTS_H #include #endif /* HAVE_STROPTS_H */ #include #ifdef HAVE_SYS_SELECT_H #include #endif /* HAVE_SYS_SELECT_H */ #include #include #include #include #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #include #ifdef HAVE_SYS_CONF_H #include #endif /* HAVE_SYS_CONF_H */ #ifdef HAVE_SYS_KSYM_H #include #endif /* HAVE_SYS_KSYM_H */ #include #include #include #include #ifdef HAVE_RUSAGE #include #endif /* HAVE_RUSAGE */ #ifdef HAVE_LIMITS_H #include #endif /* HAVE_LIMITS_H */ /* machine dependent includes */ #ifdef SUNOS_5 #include #endif /* SUNOS_5 */ /* machine dependent includes */ #ifdef HAVE_LINUX_VERSION_H #include #endif /* HAVE_LINUX_VERSION_H */ #ifdef HAVE_ASM_TYPES_H #include #endif /* HAVE_ASM_TYPES_H */ /* misc include group */ #include #if !(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) /* Not C99; do we need to define va_copy? */ #ifndef va_copy #ifdef __va_copy #define va_copy(DST,SRC) __va_copy(DST,SRC) #else /* Now we are desperate; this should work on many typical platforms. But this is slightly dangerous, because the standard does not require va_copy to be a macro. */ #define va_copy(DST,SRC) memcpy(&(DST), &(SRC), sizeof(va_list)) #warning "Not C99 and no va_copy macro available, falling back to memcpy" #endif /* __va_copy */ #endif /* !va_copy */ #endif /* !C99 */ #ifdef HAVE_LCAPS #include #include #endif /* HAVE_LCAPS */ /* network include group */ #include #ifdef HAVE_SYS_SOCKIO_H #include #endif /* HAVE_SYS_SOCKIO_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #include #include #include #ifdef HAVE_NET_NETOPT_H #include #endif /* HAVE_NET_NETOPT_H */ #include #ifdef HAVE_NET_IF_DL_H #include #endif /* HAVE_NET_IF_DL_H */ #ifdef HAVE_NET_IF_VAR_H #include #endif /* HAVE_NET_IF_VAR_H */ #ifdef HAVE_NET_ROUTE_H #include #endif /* HAVE_NET_ROUTE_H */ #ifdef HAVE_NETLINK #include #include #else #define RT_TABLE_MAIN 0 #endif /* HAVE_NETLINK */ #ifdef HAVE_NETDB_H #include #endif /* HAVE_NETDB_H */ #include #include #ifdef HAVE_INET_ND_H #include #endif /* HAVE_INET_ND_H */ #ifdef HAVE_NETINET_IN_VAR_H #include #endif /* HAVE_NETINET_IN_VAR_H */ #ifdef HAVE_NETINET6_IN6_VAR_H #include #endif /* HAVE_NETINET6_IN6_VAR_H */ #ifdef HAVE_NETINET_IN6_VAR_H #include #endif /* HAVE_NETINET_IN6_VAR_H */ #ifdef HAVE_NETINET6_IN_H #include #endif /* HAVE_NETINET6_IN_H */ #ifdef HAVE_NETINET6_IP6_H #include #endif /* HAVE_NETINET6_IP6_H */ #ifdef HAVE_NETINET_ICMP6_H #include #endif /* HAVE_NETINET_ICMP6_H */ #ifdef HAVE_NETINET6_ND6_H #include #endif /* HAVE_NETINET6_ND6_H */ /* Some systems do not define UINT32_MAX */ #ifndef UINT32_MAX #define UINT32_MAX 0xFFFFFFFFU #endif /* UINT32_MAX */ #ifdef HAVE_LIBUTIL_H #include #endif /* HAVE_LIBUTIL_H */ #ifdef HAVE_GLIBC_BACKTRACE #include #endif /* HAVE_GLIBC_BACKTRACE */ #ifdef BSDI_NRL #ifdef HAVE_NETINET6_IN6_H #include #endif /* HAVE_NETINET6_IN6_H */ #ifdef NRL #include #endif /* NRL */ #define IN6_ARE_ADDR_EQUAL IN6_IS_ADDR_EQUAL #endif /* BSDI_NRL */ /* Local includes: */ #if !(defined(__GNUC__) || defined(VTYSH_EXTRACT_PL)) #define __attribute__(x) #endif /* !__GNUC__ || VTYSH_EXTRACT_PL */ #include "zassert.h" #ifdef HAVE_BROKEN_CMSG_FIRSTHDR /* This bug is present in Solaris 8 and pre-patch Solaris 9 ; please refer to http://bugzilla.quagga.net/show_bug.cgi?id=142 */ /* Check that msg_controllen is large enough. */ #define ZCMSG_FIRSTHDR(mhdr) \ (((size_t)((mhdr)->msg_controllen) >= sizeof(struct cmsghdr)) ? \ CMSG_FIRSTHDR(mhdr) : (struct cmsghdr *)NULL) #warning "CMSG_FIRSTHDR is broken on this platform, using a workaround" #else /* HAVE_BROKEN_CMSG_FIRSTHDR */ #define ZCMSG_FIRSTHDR(M) CMSG_FIRSTHDR(M) #endif /* HAVE_BROKEN_CMSG_FIRSTHDR */ /* * RFC 3542 defines several macros for using struct cmsghdr. * Here, we define those that are not present */ /* * Internal defines, for use only in this file. * These are likely wrong on other than ILP32 machines, so warn. */ #ifndef _CMSG_DATA_ALIGN #define _CMSG_DATA_ALIGN(n) (((n) + 3) & ~3) #endif /* _CMSG_DATA_ALIGN */ #ifndef _CMSG_HDR_ALIGN #define _CMSG_HDR_ALIGN(n) (((n) + 3) & ~3) #endif /* _CMSG_HDR_ALIGN */ /* * CMSG_SPACE and CMSG_LEN are required in RFC3542, but were new in that * version. */ #ifndef CMSG_SPACE #define CMSG_SPACE(l) (_CMSG_DATA_ALIGN(sizeof(struct cmsghdr)) + \ _CMSG_HDR_ALIGN(l)) #warning "assuming 4-byte alignment for CMSG_SPACE" #endif /* CMSG_SPACE */ #ifndef CMSG_LEN #define CMSG_LEN(l) (_CMSG_DATA_ALIGN(sizeof(struct cmsghdr)) + (l)) #warning "assuming 4-byte alignment for CMSG_LEN" #endif /* CMSG_LEN */ /* The definition of struct in_pktinfo is missing in old version of GLIBC 2.1 (Redhat 6.1). */ #if defined (GNU_LINUX) && ! defined (HAVE_INPKTINFO) struct in_pktinfo { int ipi_ifindex; struct in_addr ipi_spec_dst; struct in_addr ipi_addr; }; #endif /* * OSPF Fragmentation / fragmented writes * * ospfd can support writing fragmented packets, for cases where * kernel will not fragment IP_HDRINCL and/or multicast destined * packets (ie TTBOMK all kernels, BSD, SunOS, Linux). However, * SunOS, probably BSD too, clobber the user supplied IP ID and IP * flags fields, hence user-space fragmentation will not work. * Only Linux is known to leave IP header unmolested. * Further, fragmentation really should be done the kernel, which already * supports it, and which avoids nasty IP ID state problems. * * Fragmentation of OSPF packets can be required on networks with router * with many many interfaces active in one area, or on networks with links * with low MTUs. */ #ifdef GNU_LINUX #define WANT_OSPF_WRITE_FRAGMENT #endif /* * IP_HDRINCL / struct ip byte order * * Linux: network byte order * *BSD: network, except for length and offset. (cf Stevens) * SunOS: nominally as per BSD. but bug: network order on LE. * OpenBSD: network byte order, apart from older versions which are as per * *BSD */ #if defined(__NetBSD__) || defined(__FreeBSD__) \ || (defined(__OpenBSD__) && (OpenBSD < 200311)) \ || (defined(SUNOS_5) && defined(WORDS_BIGENDIAN)) #define HAVE_IP_HDRINCL_BSD_ORDER #endif /* MAX / MIN are not commonly defined, but useful */ #ifndef MAX #define MAX(a, b) ((a) > (b) ? (a) : (b)) #endif #ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif /* For old definition. */ #ifndef IN6_ARE_ADDR_EQUAL #define IN6_ARE_ADDR_EQUAL IN6_IS_ADDR_EQUAL #endif /* IN6_ARE_ADDR_EQUAL */ /* Zebra message types. */ #define ZEBRA_INTERFACE_ADD 1 #define ZEBRA_INTERFACE_DELETE 2 #define ZEBRA_INTERFACE_ADDRESS_ADD 3 #define ZEBRA_INTERFACE_ADDRESS_DELETE 4 #define ZEBRA_INTERFACE_UP 5 #define ZEBRA_INTERFACE_DOWN 6 #define ZEBRA_IPV4_ROUTE_ADD 7 #define ZEBRA_IPV4_ROUTE_DELETE 8 #define ZEBRA_IPV6_ROUTE_ADD 9 #define ZEBRA_IPV6_ROUTE_DELETE 10 #define ZEBRA_REDISTRIBUTE_ADD 11 #define ZEBRA_REDISTRIBUTE_DELETE 12 #define ZEBRA_REDISTRIBUTE_DEFAULT_ADD 13 #define ZEBRA_REDISTRIBUTE_DEFAULT_DELETE 14 #define ZEBRA_IPV4_NEXTHOP_LOOKUP 15 #define ZEBRA_IPV6_NEXTHOP_LOOKUP 16 #define ZEBRA_IPV4_IMPORT_LOOKUP 17 #define ZEBRA_IPV6_IMPORT_LOOKUP 18 #define ZEBRA_INTERFACE_RENAME 19 #define ZEBRA_ROUTER_ID_ADD 20 #define ZEBRA_ROUTER_ID_DELETE 21 #define ZEBRA_ROUTER_ID_UPDATE 22 #define ZEBRA_MESSAGE_MAX 23 /* Zebra route's types. */ #define ZEBRA_ROUTE_SYSTEM 0 #define ZEBRA_ROUTE_KERNEL 1 #define ZEBRA_ROUTE_CONNECT 2 #define ZEBRA_ROUTE_STATIC 3 #define ZEBRA_ROUTE_RIP 4 #define ZEBRA_ROUTE_RIPNG 5 #define ZEBRA_ROUTE_OSPF 6 #define ZEBRA_ROUTE_OSPF6 7 #define ZEBRA_ROUTE_ISIS 8 #define ZEBRA_ROUTE_BGP 9 #define ZEBRA_ROUTE_HSLS 10 #define ZEBRA_ROUTE_OLSR 11 #define ZEBRA_ROUTE_MAX 12 /* Zebra's family types. */ #define ZEBRA_FAMILY_IPV4 1 #define ZEBRA_FAMILY_IPV6 2 #define ZEBRA_FAMILY_MAX 3 /* Error codes of zebra. */ #define ZEBRA_ERR_RTEXIST -1 #define ZEBRA_ERR_RTUNREACH -2 #define ZEBRA_ERR_EPERM -3 #define ZEBRA_ERR_RTNOEXIST -4 /* Zebra message flags */ #define ZEBRA_FLAG_INTERNAL 0x01 #define ZEBRA_FLAG_SELFROUTE 0x02 #define ZEBRA_FLAG_BLACKHOLE 0x04 #define ZEBRA_FLAG_IBGP 0x08 #define ZEBRA_FLAG_SELECTED 0x10 #define ZEBRA_FLAG_CHANGED 0x20 #define ZEBRA_FLAG_STATIC 0x40 #define ZEBRA_FLAG_REJECT 0x80 /* Zebra nexthop flags. */ #define ZEBRA_NEXTHOP_IFINDEX 1 #define ZEBRA_NEXTHOP_IFNAME 2 #define ZEBRA_NEXTHOP_IPV4 3 #define ZEBRA_NEXTHOP_IPV4_IFINDEX 4 #define ZEBRA_NEXTHOP_IPV4_IFNAME 5 #define ZEBRA_NEXTHOP_IPV6 6 #define ZEBRA_NEXTHOP_IPV6_IFINDEX 7 #define ZEBRA_NEXTHOP_IPV6_IFNAME 8 #define ZEBRA_NEXTHOP_BLACKHOLE 9 #ifndef INADDR_LOOPBACK #define INADDR_LOOPBACK 0x7f000001 /* Internet address 127.0.0.1. */ #endif /* Address family numbers from RFC1700. */ #define AFI_IP 1 #define AFI_IP6 2 #define AFI_MAX 3 /* Subsequent Address Family Identifier. */ #define SAFI_UNICAST 1 #define SAFI_MULTICAST 2 #define SAFI_UNICAST_MULTICAST 3 #define SAFI_MPLS_VPN 4 #define SAFI_MAX 5 /* Filter direction. */ #define FILTER_IN 0 #define FILTER_OUT 1 #define FILTER_MAX 2 /* Default Administrative Distance of each protocol. */ #define ZEBRA_KERNEL_DISTANCE_DEFAULT 0 #define ZEBRA_CONNECT_DISTANCE_DEFAULT 0 #define ZEBRA_STATIC_DISTANCE_DEFAULT 1 #define ZEBRA_RIP_DISTANCE_DEFAULT 120 #define ZEBRA_RIPNG_DISTANCE_DEFAULT 120 #define ZEBRA_OSPF_DISTANCE_DEFAULT 110 #define ZEBRA_OSPF6_DISTANCE_DEFAULT 110 #define ZEBRA_ISIS_DISTANCE_DEFAULT 115 #define ZEBRA_IBGP_DISTANCE_DEFAULT 200 #define ZEBRA_EBGP_DISTANCE_DEFAULT 20 /* Flag manipulation macros. */ #define CHECK_FLAG(V,F) ((V) & (F)) #define SET_FLAG(V,F) (V) = (V) | (F) #define UNSET_FLAG(V,F) (V) = (V) & ~(F) /* AFI and SAFI type. */ typedef u_int16_t afi_t; typedef u_int8_t safi_t; /* Zebra types. */ typedef u_int16_t zebra_size_t; typedef u_int8_t zebra_command_t; /* FIFO -- first in first out structure and macros. */ struct fifo { struct fifo *next; struct fifo *prev; }; #define FIFO_INIT(F) \ do { \ struct fifo *Xfifo = (struct fifo *)(F); \ Xfifo->next = Xfifo->prev = Xfifo; \ } while (0) #define FIFO_ADD(F,N) \ do { \ struct fifo *Xfifo = (struct fifo *)(F); \ struct fifo *Xnode = (struct fifo *)(N); \ Xnode->next = Xfifo; \ Xnode->prev = Xfifo->prev; \ Xfifo->prev = Xfifo->prev->next = Xnode; \ } while (0) #define FIFO_DEL(N) \ do { \ struct fifo *Xnode = (struct fifo *)(N); \ Xnode->prev->next = Xnode->next; \ Xnode->next->prev = Xnode->prev; \ } while (0) #define FIFO_HEAD(F) \ ((((struct fifo *)(F))->next == (struct fifo *)(F)) \ ? NULL : (F)->next) #define FIFO_EMPTY(F) \ (((struct fifo *)(F))->next == (struct fifo *)(F)) #define FIFO_TOP(F) \ (FIFO_EMPTY(F) ? NULL : ((struct fifo *)(F))->next) #endif /* _ZEBRA_H */ --- NEW FILE: zassert.h --- /* * $Id: zassert.h,v 1.1 2007/01/31 12:38:26 bernd67 Exp $ */ #ifndef _QUAGGA_ASSERT_H #define _QUAGGA_ASSERT_H extern void _zlog_assert_failed (const char *assertion, const char *file, unsigned int line, const char *function) __attribute__ ((noreturn)); #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __ASSERT_FUNCTION __func__ #elif defined(__GNUC__) #define __ASSERT_FUNCTION __FUNCTION__ #else #define __ASSERT_FUNCTION NULL #endif #define zassert(EX) ((void)((EX) ? 0 : \ (_zlog_assert_failed(#EX, __FILE__, __LINE__, \ __ASSERT_FUNCTION), 0))) #undef assert #define assert(EX) zassert(EX) #endif /* _QUAGGA_ASSERT_H */ From (spam-protected) Wed Jan 31 13:38:28 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Wed, 31 Jan 2007 12:38:28 +0000 Subject: [Olsr-cvs] olsrd-current/lib/dyn_gw_plain/src olsrd_dyn_gw_plain.c, NONE, 1.1 olsrd_dyn_gw_plain.h, NONE, 1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/dyn_gw_plain/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16361/lib/dyn_gw_plain/src Added Files: olsrd_dyn_gw_plain.c olsrd_dyn_gw_plain.h Log Message: * applied patches from the most recent FreiFunkFirmware (and fixed compile errors) according to http://www.olsr.org/pipermail/olsr-dev/2006-December/254036.html: - olsrd-libsmake.patch - olsrd-dyngwplain.patch - olsrd-txtinfo.patch - olsrd-quagga.patch - olsrd-quagga-routehandler.patch - olsrd-optimize.patch - olsrd-bmf-fixes.patch - olsrd-fixes-sven-ola.patch - olsrd-fixes-jhay-bsd.patch - olsrd-fixes-backport.patch - olsrd-fixes-routedel.patch - olsrd-cpu-overload.patch - olsrd-secure_key_path.patch - olsrd-hna_ip_fix.patch Not applied: - olsrd-nameservice+services.patch: This patch produced too many rejects to fix easily. - olsrd-fixes-eric.patch: This was not found on the webserver. - olsrd-bmf.patch: We had already a "bmf" plug-in in there. * made the checksum type in the olsrd_secure plug-in "olsr_u8_t" (instead of a wild "char *" and "unsigned char *" mix) everywhere. It killed lots of warnings. * localized the checksum_cache array in olsrd_secure.c. --- NEW FILE: olsrd_dyn_gw_plain.h --- (This appears to be a binary file; contents omitted.) --- NEW FILE: olsrd_dyn_gw_plain.c --- (This appears to be a binary file; contents omitted.) From (spam-protected) Wed Jan 31 13:38:28 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Wed, 31 Jan 2007 12:38:28 +0000 Subject: [Olsr-cvs] olsrd-current/lib/quagga .cvsignore, NONE, 1.1 ChangeLog, NONE, 1.1 Makefile, NONE, 1.1 README, NONE, 1.1 version-script.txt, NONE, 1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/quagga In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16361/lib/quagga Added Files: .cvsignore ChangeLog Makefile README version-script.txt Log Message: * applied patches from the most recent FreiFunkFirmware (and fixed compile errors) according to http://www.olsr.org/pipermail/olsr-dev/2006-December/254036.html: - olsrd-libsmake.patch - olsrd-dyngwplain.patch - olsrd-txtinfo.patch - olsrd-quagga.patch - olsrd-quagga-routehandler.patch - olsrd-optimize.patch - olsrd-bmf-fixes.patch - olsrd-fixes-sven-ola.patch - olsrd-fixes-jhay-bsd.patch - olsrd-fixes-backport.patch - olsrd-fixes-routedel.patch - olsrd-cpu-overload.patch - olsrd-secure_key_path.patch - olsrd-hna_ip_fix.patch Not applied: - olsrd-nameservice+services.patch: This patch produced too many rejects to fix easily. - olsrd-fixes-eric.patch: This was not found on the webserver. - olsrd-bmf.patch: We had already a "bmf" plug-in in there. * made the checksum type in the olsrd_secure plug-in "olsr_u8_t" (instead of a wild "char *" and "unsigned char *" mix) everywhere. It killed lots of warnings. * localized the checksum_cache array in olsrd_secure.c. --- NEW FILE: README --- --------------------------------------------------------------------- QUAGGA PLUGIN FOR OLSRD by Immo 'FaUl' Wehrenberg --------------------------------------------------------------------- This is the Quagga Plugin for the OLSRD. It allowes olsrd to redistribute from various quagga-protocols as well as to export olsr-routes to quagga so that they can be redistributed by the quagga-routing-daemons. Note Sven-Ola: You also need a source distribution of quagga-0.98.5 or quagga-0.98.6 (that is the current stable). The quagga source tree needs to be patched with quagga-0.98.6-olsr.diff, compiled and installed via 'make install'. Because many people will otherwise have compile probs, I've added 2 include files in lib/quagga/src/quagga. If you want to use another version of quagga, make sure to remove these before you compile the olsrd_quagga plugin. --------------------------------------------------------------------- PLUGIN PARAMETERS (PlParam) --------------------------------------------------------------------- PlParam "redistribute" "" where protocol is one of the following: system, kernel, connect, static, rip, ripng, ospf, ospf6, isis, bgp, hsls May be used more then once PlParam "ExportRoutes" "" exportes olsr-routes to quagga or to both, quagga and kernel no routes are exportet if not set. PlParam "Localpref" "true" sets the zebra SELECTED-flag on the routes exported to zebra which means these routes are prefered in any case. PlParam "Distance" "0-255" allowes to set Administrative distance to routes exported to zebra. --------------------------------------------------------------------- SAMPLE CONFIG --------------------------------------------------------------------- add in /etc/olsrd.conf: LoadPlugin "olsrd_quagga.so.0.2.2" { PlParam "redistribute" "ospf" PlParam "redistribute" "bgp" PlParam "ExportRoutes" "only" PlParam "Distance" "125" PlParam "Localpref" "false" } --------------------------------------------------------------------- EOF / 8.5.2006 --- NEW FILE: Makefile --- (This appears to be a binary file; contents omitted.) --- NEW FILE: version-script.txt --- VERS_1.0 { global: olsrd_plugin_interface_version; olsrd_plugin_register_param; olsrd_plugin_init; local: *; }; --- NEW FILE: .cvsignore --- *.d olsrd_quagga.so.* --- NEW FILE: ChangeLog --- 0.2.1: Immo 'FaUl' Wehrenberg : * now check (most of the) return-values of syscalls, improvement still possible... * added support for new zebra-protocoll-format (with ZEBRA_HEADER_MARKER and ZCLIENT_VERSION) if new quagga-headers are found) * Code Cleanup (removed lot of debug and test-stuff) * fixed return-bug in zebra_send_command * added copyright-stuff * removed memleak in zebra_add/delete_v4_route 0.2.0: Immo 'FaUl' Wehrenberg : * Initial release, too :-) * Added support for route-export to the zebra/quagga 0.1.0: Immo 'FaUl' Wehrenberg : * Initial release From (spam-protected) Wed Jan 31 13:38:28 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Wed, 31 Jan 2007 12:38:28 +0000 Subject: [Olsr-cvs] olsrd-current/lib/quagga/test foo.c, NONE, 1.1 foo.pl, NONE, 1.1 quagga.try1.c, NONE, 1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/quagga/test In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16361/lib/quagga/test Added Files: foo.c foo.pl quagga.try1.c Log Message: * applied patches from the most recent FreiFunkFirmware (and fixed compile errors) according to http://www.olsr.org/pipermail/olsr-dev/2006-December/254036.html: - olsrd-libsmake.patch - olsrd-dyngwplain.patch - olsrd-txtinfo.patch - olsrd-quagga.patch - olsrd-quagga-routehandler.patch - olsrd-optimize.patch - olsrd-bmf-fixes.patch - olsrd-fixes-sven-ola.patch - olsrd-fixes-jhay-bsd.patch - olsrd-fixes-backport.patch - olsrd-fixes-routedel.patch - olsrd-cpu-overload.patch - olsrd-secure_key_path.patch - olsrd-hna_ip_fix.patch Not applied: - olsrd-nameservice+services.patch: This patch produced too many rejects to fix easily. - olsrd-fixes-eric.patch: This was not found on the webserver. - olsrd-bmf.patch: We had already a "bmf" plug-in in there. * made the checksum type in the olsrd_secure plug-in "olsr_u8_t" (instead of a wild "char *" and "unsigned char *" mix) everywhere. It killed lots of warnings. * localized the checksum_cache array in olsrd_secure.c. --- NEW FILE: quagga.try1.c --- /* * (C) 2006 by Immo 'FaUl' Wehrenberg * * This code is covered by the GPLv2 * */ #include #ifdef MY_DEBUG #include #endif #include #include #include #define HAVE_SOCKLEN_T #include #include "quagga.h" #ifdef OLSR_PLUGIN #include "olsr.h" #include "log.h" #include "defs.h" #include "local_hna_set.h" #endif #define ZAPI_MESSAGE_NEXTHOP 0x01 #define ZAPI_MESSAGE_IFINDEX 0x02 #define ZAPI_MESSAGE_DISTANCE 0x04 #define ZAPI_MESSAGE_METRIC 0x08 #define STATUS_CONNECTED 1 #define BUFSIZE 1024 static char status = 0; static int zsock; // Socket to zebra... struct ipv4_route *quagga_routes = 0; // routes currently exportet to zebra /* prototypes ntern */ 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 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*); static struct ipv4_route *zebra_create_ipv4_route_table_entry (uint32_t, uint32_t, uint32_t); static struct ipv4_route *zebra_create_ipv4_route_table (void); static void zebra_free_ipv4_route_table (struct ipv4_route*); 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; puts (c); printf("type: %d\n", r.type); puts("flags:"); printf(" Internal: %s\n",r.flags&ZEBRA_FLAG_INTERNAL?"yes":"no"); printf(" Selfroute %s\n",r.flags&ZEBRA_FLAG_SELFROUTE?"yes":"no"); printf(" Blackhole %s\n",r.flags&ZEBRA_FLAG_BLACKHOLE?"yes":"no"); printf(" IBGP: %s\n",r.flags&ZEBRA_FLAG_IBGP?"yes":"no"); printf(" Selected: %s\n",r.flags&ZEBRA_FLAG_SELECTED?"yes":"no"); printf(" Changed: %s\n",r.flags&ZEBRA_FLAG_CHANGED?"yes":"no"); printf(" static: %s\n",r.flags&ZEBRA_FLAG_STATIC?"yes":"no"); printf(" reject: %s\n",r.flags&ZEBRA_FLAG_REJECT?"yes":"no"); puts("message:"); printf(" nexthop: %s\n",r.message&ZAPI_MESSAGE_NEXTHOP?"yes":"no"); printf(" ifindex: %s\n",r.message&ZAPI_MESSAGE_IFINDEX?"yes":"no"); printf(" distance: %s\n",r.message&ZAPI_MESSAGE_DISTANCE?"yes":"no"); printf(" metric: %s\n",r.message&ZAPI_MESSAGE_METRIC?"yes":"no"); printf("Prefixlen: %d\n", r.prefixlen); printf("Prefix: %d", (unsigned char)r.prefix); c = (char*) &r.prefix; while (++i < (r.prefixlen/8 + (r.prefixlen % 8 ? 1 : 0))) printf(".%d",(unsigned char)*(c + i)); while (i++ < 4) printf(".0"); puts(""); i=0; if (r.message&ZAPI_MESSAGE_NEXTHOP) { printf("nexthop-count: %d\n", r.nh_count); while (i++ < r.nh_count) { c = (unsigned char*) &r.nexthops[i]; printf ("Nexthop %d: %d", i, (unsigned char) *c); while (++x < 4) { printf (".%d", (unsigned char) c[x]); } puts(""); } i=0; } if (r.message&ZAPI_MESSAGE_IFINDEX) { printf("index-number: %d\n", r.ind_num); while (i++ < r.ind_num) printf("Index: %d: %d\n", i, r.index[i]); i=0; if (r.message&ZAPI_MESSAGE_DISTANCE) printf("Distance: %d\n",r.distance); if (r.message&ZAPI_MESSAGE_METRIC) printf("Metric: %d\n",r.metric); puts("\n"); } } #endif void *my_realloc (void *buf, size_t s, const char *c) { buf = realloc (buf, s); if (!buf) { #ifdef OLSR_PLUGIN OLSR_PRINTF (1, "OUT OF MEMORY: %s\n", strerror(errno)); olsr_syslog(OLSR_LOG_ERR, "olsrd: out of memory!: %m\n"); olsr_exit(c, EXIT_FAILURE); #else exit (EXIT_FAILURE); #endif } return buf; } #ifndef OLSR_PLUGIN void *olsr_malloc (size_t f, const char *c) { void* v = malloc (f); return v; } #endif /* Connect to the zebra-daemon, returns a socket */ int init_zebra () { struct sockaddr_in i; int ret; zsock = socket (AF_INET,SOCK_STREAM, 0); if (zsock <0 ) // TODO: Could not create socket return -1; memset (&i, 0, sizeof i); i.sin_family = AF_INET; i.sin_port = htons (ZEBRA_PORT); // i.sin_len = sizeof i; i.sin_addr.s_addr = htonl (INADDR_LOOPBACK); ret = connect (zsock, (struct sockaddr *)&i, sizeof i); if (ret < 0) { close (zsock); return -1; } status |= STATUS_CONNECTED; return zsock; } /* 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) { char *p = olsr_malloc (optlen+3, "zebra send_command"); uint16_t length = optlen + 3; // length of option + command + packet_length int ret; uint16_t len = htons(length); memcpy (p, &len, 2); p[2] = command; memcpy (p + 3, options, optlen); do { ret = write (zsock, p, length); if (ret < 0) { if (errno == EINTR) continue; } else return -1; p = p+ret; } while ((length =- ret)); 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) { char *cmdopt, *t; *optlen = 9; // first: type, flags, message, prefixlen, nexthop number, nexthop) *optlen += r.prefixlen / 8 + (r.prefixlen % 8 ? 1 : 0); cmdopt = olsr_malloc (*optlen, "zebra add_v4_route"); t = cmdopt; *t++ = 10; // Type: olsr *t++ = r.flags; // flags *t++ = r.message; // message: contains nexthop *t++ = r.prefixlen; memcpy (t, &r.prefix, r.prefixlen/8 + (r.prefixlen % 8 ? 1 : 0)); *t += r.prefixlen/8 + (r.prefixlen % 8 ? 1 : 0); *t++ = r.nh_count; memcpy (t, r.nexthops, r.nh_count * sizeof *r.nexthops); return cmdopt; } /* adds a route to zebra-daemon (needs socket from zebra, address = prefix of the route mask = netmask of the route nexthop = nexthop of the route distance = distance-value of the route */ int zebra_add_v4_route (struct ipv4_route r) { char *cmdopt; ssize_t optlen; cmdopt = zebra_route_packet (r, &optlen); puts ("DEBUG: zebra_route_packet returned"); return zebra_send_command (ZEBRA_IPV4_ROUTE_ADD, cmdopt, optlen); } /* deletes a route from the zebra-daemon ( needs socket from zebra, address = prefix of the route mask = netmask of the route nexthop = nexthop of the route distance = distance-value of the route */ int zebra_delete_v4_route (struct ipv4_route r) { char *cmdopt; ssize_t optlen; cmdopt = zebra_route_packet (r, &optlen); return zebra_send_command (ZEBRA_IPV4_ROUTE_DELETE, cmdopt, optlen); } /* Check wether there is data from zebra aviable */ void zebra_check (void* foo) { char *data, *f; ssize_t len, ret; if (!status & STATUS_CONNECTED) { } 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); } f += ret; } while ((f - data) < len); free (data); } } // 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; ssize_t ret = 0, bsize = 0; uint16_t length = 0, l = 0; int sockstate; *len = 0; sockstate = fcntl (zsock, F_GETFL, 0); fcntl (zsock, F_SETFL, sockstate|O_NONBLOCK); do { if (*len == bsize) { bsize += BUFSIZE; buf = my_realloc (buf, bsize, "Zebra try_read"); } ret = read (zsock, buf + l, bsize - l); if (ret <= 0) { if (errno == EAGAIN) { errno = 0; } else { // TODO: errorhandling ; } free (buf); return NULL; } *len += ret; while ((*len - l) > length) { // printf ("DEBUG: *len -l > length - %d - %d > %d\n", *len, l, length); l += length; memcpy (&length, buf + l, 2); length = ntohs (length); } // printf ("DEBUG: *len, l, length: %d,%d,%d\n", *len, l, length); if (((*len) - l) == length) break; // GOT FULL PACKAGE!! if (*len < l) { // printf ("DEBUG: *len, l, length: %d,%d,%d\n", *len, l, length); fcntl (zsock, F_SETFL, sockstate); continue; } } while (1); fcntl (zsock, F_SETFL, sockstate); return buf; } /* Parse a packet recived from zebra */ int zebra_parse_packet (char *packet, ssize_t maxlen) { /* Array of functions */ int (*foo[ZEBRA_MESSAGE_MAX]) (char *, size_t) = { parse_interface_add, parse_interface_delete, parse_interface_address_add, parse_interface_address_delete, parse_interface_up, parse_interface_down, ipv4_route_add, ipv4_route_delete, parse_ipv6_route_add }; puts ("DEBUG: zebra_parse_packet"); 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; } if (packet[2] - 1 < ZEBRA_MESSAGE_MAX && foo[packet[2] - 1]) { if (!(ret = foo[packet[2] - 1] (packet + 3, length - 3))) return length; else printf ("DEBUG: Parse error: %d\n", ret); } else printf ("Unknown packet type: %d\n", packet[2]); puts ("Quagga: RECIVED PACKET FROM ZEBRA THAT I CAN'T PARSE"); return length; } static int parse_interface_add (char *opt, size_t len) { //todo return 0; } static int parse_interface_delete (char *opt, size_t len) { //todo return 0; } static int parse_interface_address_add (char *opt, size_t len) { //todo return 0; } static int parse_interface_up (char *opt, size_t len) { //todo return 0; } static int parse_interface_down (char *opt, size_t len) { //todo return 0; } static int parse_interface_address_delete (char *opt, size_t len) { //todo return 0; } /* Parse an ipv4-route-packet recived from zebra */ static int parse_ipv4_route (char *opt, size_t len, struct ipv4_route *r) { // puts ("DEBUG: parse_ipv4_route"); if (len < 4) return -1; r->type = *opt++; r->flags = *opt++; r->message = *opt++; r->prefixlen = *opt++; len -= 4; r->prefix = 0; if ((int)len < r->prefixlen/8 + (r->prefixlen % 8 ? 1 : 0)) return -1; memcpy (&r->prefix, opt, r->prefixlen/8 + (r->prefixlen % 8 ? 1 : 0)); opt += r->prefixlen/8 + (r->prefixlen % 8 ? 1 : 0); if (r->message & ZAPI_MESSAGE_NEXTHOP) { if (len < 1) return -1; r->nh_count = *opt++; if (len < sizeof (uint32_t) * r->nh_count) return -1; r->nexthops = olsr_malloc (sizeof (uint32_t) * r->nh_count, "quagga: parse_ipv4_route_add"); memcpy (r->nexthops, opt, sizeof (uint32_t) * r->nh_count); opt += sizeof (uint32_t) * r->nh_count; len -= sizeof (uint32_t) * r->nh_count + 1; } if (r->message & ZAPI_MESSAGE_IFINDEX) { if (len < 1) return -2; r->ind_num = *opt++; if (len < sizeof (uint32_t) * r->ind_num) return -3; r->index = olsr_malloc (sizeof (uint32_t) * r->ind_num, "quagga: parse_ipv4_route_add"); memcpy (r->index, opt, r->ind_num * sizeof (uint32_t)); opt += sizeof (uint32_t) * r->ind_num; len -= sizeof (uint32_t) * r->ind_num; } if (r->message & ZAPI_MESSAGE_DISTANCE) // todo ; if (r->message & ZAPI_MESSAGE_METRIC) { if (len < sizeof (uint32_t)) return -4; memcpy (&r->metric, opt, sizeof (uint32_t)); } return 0; } static int ipv4_route_add (char *opt, size_t len) { struct ipv4_route r; int f; // puts ("DEBUG: ipv4_route_add"); f = parse_ipv4_route (opt, len, &r); if (f < 0) { printf ("parse-error: %d\n",f); return f; } add_hna4_route (r); return 0; } static int ipv4_route_delete (char *opt, size_t len) { struct ipv4_route r; int f; f = parse_ipv4_route (opt, len, &r); if (f < 0) return f; return delete_hna4_route (r); // OK, now delete that foo } static int parse_ipv6_route_add (char *opt, size_t len) { //todo return 0; } /* start redistribution FROM zebra */ int zebra_redistribute (unsigned char type) { return zebra_send_command (ZEBRA_REDISTRIBUTE_ADD, &type, 1); } /* end redistribution FROM zebra */ int zebra_disable_redistribute (unsigned char type) { return zebra_send_command (ZEBRA_REDISTRIBUTE_DELETE, &type, 1); } static uint32_t prefixlentomask (uint8_t prefix) { uint32_t mask; mask = 0xffffffff<<(32-prefix); mask = ntohl(mask); return mask; } int add_hna4_route (struct ipv4_route r) { union olsr_ip_addr net, mask; #ifdef MY_DEBUG dump_ipv4_route(r, "add_hna4_route"); #endif mask.v4 = prefixlentomask(r.prefixlen); net.v4 = r.prefix; #ifdef OLSR_PLUGIN add_local_hna4_entry(&net, &mask); #endif free_ipv4_route(r); return 0; } int delete_hna4_route (struct ipv4_route r) { union olsr_ip_addr net, mask; #ifdef MY_DEBUG dump_ipv4_route(r, "delete_hna4_route"); #endif mask.v4 = prefixlentomask(r.prefixlen); net.v4 = r.prefix; #ifdef OLSR_PLUGIN return remove_local_hna4_entry(&net, &mask) ? 0 : -1; #endif free_ipv4_route(r); return 0; } static void free_ipv4_route (struct ipv4_route r) { if(r.message&ZAPI_MESSAGE_IFINDEX && r.ind_num) free(r.index); if(r.message&ZAPI_MESSAGE_NEXTHOP && r.nh_count) free(r.nexthops); } void zebra_clear_routes(void) { struct ipv4_route *t; t = quagga_routes; while (t) { zebra_delete_v4_route(*t); t=t->next; } zebra_free_ipv4_route_table(quagga_routes); quagga_routes = NULL; } void zebra_update_hna (void* f) { struct ipv4_route *a = zebra_create_ipv4_route_table(); update_olsr_zebra_routes(a, quagga_routes); zebra_free_ipv4_route_table(quagga_routes); quagga_routes = a; } static struct ipv4_route *zebra_create_ipv4_route_table (void) { struct ipv4_route *r = 0, *t = 0 /* make compiler happy */; int i; struct hna_entry *e; struct hna_net *n; for (i = 0; i < HASHSIZE; i++) { e = hna_set[i].next; for(;e != &hna_set[i];e = e->next) { n = e->networks.next; for(;n != &e->networks; n = n->next) { if (!r) { r = zebra_create_ipv4_route_table_entry(n->A_network_addr.v4, n->A_netmask.v4, e->A_gateway_addr.v4); t = r; } else { t->next = zebra_create_ipv4_route_table_entry(n->A_network_addr.v4, n->A_netmask.v4, e->A_gateway_addr.v4); t = t->next; } } } } return r; } static struct ipv4_route *zebra_create_ipv4_route_table_entry (uint32_t addr, uint32_t mask, uint32_t gw) { struct ipv4_route *r; r = olsr_malloc (sizeof *r,"zebra_create_ipv4_route_table_entry"); memset (r, 0, sizeof *r); r->prefix = addr; r->prefixlen = masktoprefixlen (mask); r->message |= ZAPI_MESSAGE_NEXTHOP; r->nh_count = 1; r->nexthops = olsr_malloc (sizeof (uint32_t), "zebra_create_ipv4_route_table_entry"); *r->nexthops = gw; r->next = NULL; return r; } static uint8_t masktoprefixlen (uint32_t mask) { uint8_t prefixlen = 0; while (mask & (1 << ++prefixlen && prefixlen < 32); return prefixlen; } static void update_olsr_zebra_routes (struct ipv4_route *a, struct ipv4_route *r) { struct ipv4_route *t; if (!r) { puts("no quagga_routing_table aviable"); for (;a;a = a->next) { dump_ipv4_route (*a, "adding this route"); // zebra_add_v4_route(*r); } return; } while (a) { for (t = r; t; t = t->next) { if (a->prefix == t->prefix) if (a->prefixlen == t->prefixlen) if (*a->nexthops == *t->nexthops) { goto foo; } } dump_ipv4_route (*a, "adding this route"); //zebra_add_v4_route(*a); foo: a = a->next; } while (r) { for (t = a; t; t = t->next) { if (r->prefix == t->prefix) if (r->prefixlen == t->prefixlen) if (*r->nexthops == *t->nexthops) { goto bar; } } dump_ipv4_route (*r, "deleting this route"); //zebra_delete_v4_route(*r); bar: r = r->next; } } static void zebra_free_ipv4_route_table (struct ipv4_route *r) { struct ipv4_route *n; if (!r) return; while ((n = r->next)) { if (r->message & ZAPI_MESSAGE_NEXTHOP) free (r->nexthops); if (r->message & ZAPI_MESSAGE_IFINDEX) free (r->index); free(r); r = n; } } --- NEW FILE: foo.c --- #include "quagga.h" int main (void) { init_zebra(); zebra_redistribute (2); // zebra_redistribute (1); while (!sleep (1)) zebra_check(); return 0; } --- NEW FILE: foo.pl --- #!/usr/bin/perl use IO::Socket; $command = 11; # 11 = redistribute_add , 13 = redistribute_default_add $proto = 2; # connected $remote = IO::Socket::INET->new (Proto => "tcp", PeerAddr => "127.0.0.1", PeerPort => "2600", ); $remote->autoflush (1); #print $remote pack ("nc", 3, 13); print $remote pack ("nc",3,1); print $remote pack ("ncc", 4,$command,2); print $remote pack ("ncccccNcNcNN", 25, 7, 10, 16, 11, 25, 0xc0a80206, 0, 0, 1, 5, 1); print <$remote>; close $remote From (spam-protected) Wed Jan 31 13:38:28 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Wed, 31 Jan 2007 12:38:28 +0000 Subject: [Olsr-cvs] olsrd-current/lib/quagga/src olsrd_plugin.c, NONE, 1.1 quagga.c, NONE, 1.1 quagga.h, NONE, 1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/quagga/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16361/lib/quagga/src Added Files: olsrd_plugin.c quagga.c quagga.h Log Message: * applied patches from the most recent FreiFunkFirmware (and fixed compile errors) according to http://www.olsr.org/pipermail/olsr-dev/2006-December/254036.html: - olsrd-libsmake.patch - olsrd-dyngwplain.patch - olsrd-txtinfo.patch - olsrd-quagga.patch - olsrd-quagga-routehandler.patch - olsrd-optimize.patch - olsrd-bmf-fixes.patch - olsrd-fixes-sven-ola.patch - olsrd-fixes-jhay-bsd.patch - olsrd-fixes-backport.patch - olsrd-fixes-routedel.patch - olsrd-cpu-overload.patch - olsrd-secure_key_path.patch - olsrd-hna_ip_fix.patch Not applied: - olsrd-nameservice+services.patch: This patch produced too many rejects to fix easily. - olsrd-fixes-eric.patch: This was not found on the webserver. - olsrd-bmf.patch: We had already a "bmf" plug-in in there. * made the checksum type in the olsrd_secure plug-in "olsr_u8_t" (instead of a wild "char *" and "unsigned char *" mix) everywhere. It killed lots of warnings. * localized the checksum_cache array in olsrd_secure.c. --- NEW FILE: olsrd_plugin.c --- /*************************************************************************** projekt : olsrd-quagga file : olsrd_plugin.c usage : olsrd-plugin-handler-stuff copyright : (C) 2006 by Immo 'FaUl' Wehrenberg e-mail : immo at chaostreff-dortmund.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License version 2 as * * published by the Free Software Foundation. * * * ***************************************************************************/ #include #include #include "olsrd_plugin.h" #include "olsr.h" #include "scheduler.h" #include "defs.h" #include "quagga.h" #include "kernel_routes.h" #define PLUGIN_NAME "OLSRD quagga plugin" #define PLUGIN_VERSION "0.2.2" #define PLUGIN_AUTHOR "Immo 'FaUl' Wehrenberg" #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR static void __attribute__ ((constructor)) my_init(void); static void __attribute__ ((destructor)) my_fini(void); static void redist_hna (void); int olsrd_plugin_interface_version() { return OLSRD_PLUGIN_INTERFACE_VERSION; } int olsrd_plugin_register_param(char *key, char *value) { const char *zebra_route_types[] = {"system","kernel","connect","static", "rip","ripng","ospf","ospf6","isis", "bgp","hsls", NULL}; unsigned char i = 0; if(!strcmp(key, "redistribute")) { for (i = 0; zebra_route_types[i]; i++) if (!strcmp(value, zebra_route_types[i])) { zebra_redistribute(i); return 1; } } else if(!strcmp(key, "ExportRoutes")) { if (!strcmp(value, "only")) { if (!olsr_addroute_remove_function(&olsr_ioctl_add_route, AF_INET)) puts ("AIII, could not remove the kernel route exporter"); if (!olsr_delroute_remove_function(&olsr_ioctl_del_route, AF_INET)) 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); 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); return 1; } } else if (!strcmp(key, "Distance")) { unsigned int distance = atoi (key); if (distance < 255) zebra_olsr_distance(distance); return 1; } else if (!strcmp(key, "LocalPref")) { if (!strcmp(key, "true")) zebra_olsr_localpref(); else if (strcmp (key, "false")) return -1; return 1; } return -1; } int olsrd_plugin_init() { if(olsr_cnf->ip_version != AF_INET) { fputs("see the source - ipv4 so far not supportet\n" ,stderr); return 1; } // olsr_register_timeout_function(&olsr_timeout); olsr_register_scheduler_event(&zebra_check, NULL, 1, 0, NULL); return 0; } static void my_init(void) { init_zebra(); } static void my_fini(void) { } --- NEW FILE: quagga.h --- /*************************************************************************** projekt : olsrd-quagga file : quagga.h usage : header for quagga.c copyright : (C) 2006 by Immo 'FaUl' Wehrenberg e-mail : immo at chaostreff-dortmund.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License version 2 as * * published by the Free Software Foundation. * * * ***************************************************************************/ #include #include #include #include "routing_table.h" #define HAVE_SOCKLEN_T #include #ifndef ZEBRA_PORT #define ZEBRA_PORT 2600 #endif #ifdef ZEBRA_HEADER_MARKER #ifndef ZSERV_VERSION #define ZSERV_VERSION 1 #endif #endif struct ipv4_route { uint8_t type; uint8_t flags; uint8_t message; uint8_t prefixlen; uint32_t prefix; uint8_t nh_count; struct { uint8_t type; union { uint32_t v4; } payload; } *nexthops; uint8_t ind_num; uint32_t *index; uint32_t metric; uint32_t distance; struct ipv4_route *next; }; int init_zebra (void); char zebra_send_command (unsigned char, 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_redistribute (unsigned char); int zebra_disable_redistribute (unsigned char); int add_hna4_route (struct ipv4_route); int delete_hna4_route (struct ipv4_route); 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); --- NEW FILE: quagga.c --- /*************************************************************************** projekt : olsrd-quagga file : quagga.c usage : communication with the zebra-daemon copyright : (C) 2006 by Immo 'FaUl' Wehrenberg e-mail : immo at chaostreff-dortmund.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License version 2 as * * published by the Free Software Foundation. * * * ***************************************************************************/ #ifdef MY_DEBUG #include #endif #define HAVE_SOCKLEN_T #include #include #include #include #include #include "quagga.h" #include "olsr.h" #include "log.h" #include "defs.h" #include "local_hna_set.h" #ifdef USE_UNIX_DOMAIN_SOCKET #include #define ZEBRA_SOCKET "/var/run/quagga/zserv.api" #endif #define ZAPI_MESSAGE_NEXTHOP 0x01 #define ZAPI_MESSAGE_IFINDEX 0x02 #define ZAPI_MESSAGE_DISTANCE 0x04 #define ZAPI_MESSAGE_METRIC 0x08 #define BUFSIZE 1024 #define STATUS_CONNECTED 1 static struct { char status; // TODO: internal status int sock; // Socket to zebra... char redistribute[ZEBRA_ROUTE_MAX]; char distance; char flags; struct ipv4_route *v4_rt; // routes currently exportet to zebra } zebra; /* 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 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*); static struct ipv4_route *zebra_create_ipv4_route_table_entry (uint32_t, uint32_t, uint32_t); static struct ipv4_route *zebra_create_ipv4_route_table (void); static void zebra_free_ipv4_route_table (struct ipv4_route*); 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; puts (c); printf("type: %d\n", r.type); puts("flags:"); printf(" Internal: %s\n",r.flags&ZEBRA_FLAG_INTERNAL?"yes":"no"); printf(" Selfroute %s\n",r.flags&ZEBRA_FLAG_SELFROUTE?"yes":"no"); printf(" Blackhole %s\n",r.flags&ZEBRA_FLAG_BLACKHOLE?"yes":"no"); printf(" IBGP: %s\n",r.flags&ZEBRA_FLAG_IBGP?"yes":"no"); printf(" Selected: %s\n",r.flags&ZEBRA_FLAG_SELECTED?"yes":"no"); printf(" Changed: %s\n",r.flags&ZEBRA_FLAG_CHANGED?"yes":"no"); printf(" static: %s\n",r.flags&ZEBRA_FLAG_STATIC?"yes":"no"); printf(" reject: %s\n",r.flags&ZEBRA_FLAG_REJECT?"yes":"no"); puts("message:"); printf(" nexthop: %s\n",r.message&ZAPI_MESSAGE_NEXTHOP?"yes":"no"); printf(" ifindex: %s\n",r.message&ZAPI_MESSAGE_IFINDEX?"yes":"no"); printf(" distance: %s\n",r.message&ZAPI_MESSAGE_DISTANCE?"yes":"no"); printf(" metric: %s\n",r.message&ZAPI_MESSAGE_METRIC?"yes":"no"); printf("Prefixlen: %d\n", r.prefixlen); printf("Prefix: %d", (unsigned char)r.prefix); c = (char*) &r.prefix; while (++i < (r.prefixlen/8 + (r.prefixlen % 8 ? 1 : 0))) printf(".%d",(unsigned char)*(c + i)); while (i++ < 4) printf(".0"); puts(""); i=0; if (r.message&ZAPI_MESSAGE_NEXTHOP) { printf("nexthop-count: %d\n", r.nh_count); while (i++ < r.nh_count) { if (r.nexthops[i].type == ZEBRA_NEXTHOP_IPV4) { c = (unsigned char*) &r.nexthops[i].payload.v4; printf ("Nexthop %d: %d", i, (unsigned char) *c); while (++x < 4) { printf (".%d", (unsigned char) c[x]); } puts(""); } } i=0; } if (r.message&ZAPI_MESSAGE_IFINDEX) { printf("index-number: %d\n", r.ind_num); while (i++ < r.ind_num) printf("Index: %d: %d\n", i, r.index[i]); i=0; if (r.message&ZAPI_MESSAGE_DISTANCE) printf("Distance: %d\n",r.distance); if (r.message&ZAPI_MESSAGE_METRIC) printf("Metric: %d\n",r.metric); puts("\n"); } } #endif 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_syslog(OLSR_LOG_ERR, "olsrd: out of memory!: %m\n"); olsr_exit(c, EXIT_FAILURE); } return buf; } int init_zebra () { if (!zebra_connect()) { olsr_exit ("AIIIII, could not connect to zebra! is zebra running?", EXIT_FAILURE); } } static int zebra_reconnect (void) { struct ipv4_route *tmp; int i; if (!zebra_connect()) // 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; } 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); return 0; } prv = tmp; } return 1; } /* Connect to the zebra-daemon, returns a socket */ static int zebra_connect (void) { #ifndef USE_UNIX_DOMAIN_SOCKET struct sockaddr_in i; close (zebra.sock); zebra.sock = socket (AF_INET,SOCK_STREAM, 0); #else struct sockaddr_un i; close (zebra.sock); zebra.sock = socket (AF_UNIX,SOCK_STREAM, 0); #endif int ret; if (zebra.sock <0 ) olsr_exit("could not create socket!", EXIT_FAILURE); memset (&i, 0, sizeof i); #ifndef USE_UNIX_DOMAIN_SOCKET i.sin_family = AF_INET; i.sin_port = htons (ZEBRA_PORT); i.sin_addr.s_addr = htonl (INADDR_LOOPBACK); #else i.sun_family = AF_UNIX; strcpy (i.sun_path, ZEBRA_SOCKET); #endif ret = connect (zebra.sock, (struct sockaddr *)&i, sizeof i); if (ret < 0) { close (zebra.sock); } 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) { #ifdef ZEBRA_HEADER_MARKER char *p = olsr_malloc (optlen + 6, "zebra_send_command"); uint16_t length = optlen + 6; /* length of option + command + packet_length + marker + zserv-version */ uint16_t cmd; #else char *p = olsr_malloc (optlen + 3, "zebra_send_command"); uint16_t length = optlen + 3; // length of option + command + packet_length #endif int ret; uint16_t len = htons(length); memcpy (p, &len, 2); #ifdef ZEBRA_HEADER_MARKER p[2] = ZEBRA_HEADER_MARKER; p[3] = ZSERV_VERSION; cmd = htons (command); memcpy (p + 4, &cmd, 2); memcpy (p + 6, options, optlen); #else p[2] = command; memcpy (p + 3, options, optlen); #endif errno = 0; do { ret = write (zebra.sock, p, length); if (ret < 0) { if (errno == EINTR) { errno = 0; continue; } else { zebra.status &= ~STATUS_CONNECTED; return -1; } } p = p+ret; } while ((length -= ret)); 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) { int count; 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) if (r.nexthops->type == ZEBRA_NEXTHOP_IPV4 || r.nexthops->type == ZEBRA_NEXTHOP_IPV4_IFINDEX){ *optlen += (sizeof r.nexthops->payload.v4 + sizeof r.nexthops->type) * r.nh_count + 1; } else if (r.nexthops->type == 0) *optlen += 5; if (r.message & ZAPI_MESSAGE_IFINDEX) *optlen += r.ind_num * sizeof *r.index + 1; if (r.message & ZAPI_MESSAGE_DISTANCE) *optlen++; if (r.message & ZAPI_MESSAGE_METRIC) *optlen += sizeof r.metric; cmdopt = olsr_malloc (*optlen, "zebra add_v4_route"); t = cmdopt; *t++ = r.type; *t++ = r.flags; *t++ = r.message; *t++ = r.prefixlen; for (count = 0; count < r.prefixlen/8 + (r.prefixlen % 8 ? 1 : 0); count++) { *t++ = *((char*)&r.prefix + count); /* this is so sick!! */ } if (r.message & ZAPI_MESSAGE_NEXTHOP) { *t++ = r.nh_count; *t++ = r.nexthops->type; if (r.nexthops->type == ZEBRA_NEXTHOP_IPV4 || r.nexthops->type == ZEBRA_NEXTHOP_IPV4_IFINDEX) { for (count = 0; count != r.nh_count; count++) { memcpy (t, &r.nexthops[count].payload.v4, sizeof r.nexthops->payload.v4); t += sizeof r.nexthops->payload.v4; } } else if (r.nexthops->type == 0) { *t++ = 0; *t++ = 0; *t++ = 0; } } if (r.message & ZAPI_MESSAGE_IFINDEX) { *t++ = r.ind_num; memcpy (t, r.index, sizeof *r.index * r.ind_num); t += sizeof r.index * r.ind_num; } if (r.message & ZAPI_MESSAGE_METRIC) { memcpy (t, &r.metric, sizeof r.metric); t += sizeof r.metric; } if (r.message & ZAPI_MESSAGE_DISTANCE) *t++ = r.distance; return cmdopt; } /* adds a route to zebra-daemon */ int zebra_add_v4_route (struct ipv4_route r) { char *cmdopt; ssize_t optlen; int retval; cmdopt = zebra_route_packet (r, &optlen); retval = zebra_send_command (ZEBRA_IPV4_ROUTE_ADD, cmdopt, optlen); free (cmdopt); return retval; } /* deletes a route from the zebra-daemon */ int zebra_delete_v4_route (struct ipv4_route r) { char *cmdopt; ssize_t optlen; int retval; cmdopt = zebra_route_packet (r, &optlen); retval = zebra_send_command (ZEBRA_IPV4_ROUTE_DELETE, cmdopt, optlen); free (cmdopt); return retval; } /* Check wether there is data from zebra aviable */ void zebra_check (void* foo) { char *data, *f; ssize_t len, ret; if (!(zebra.status & STATUS_CONNECTED)) { if (!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); } f += ret; } while ((f - data) < len); free (data); } } // 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; ssize_t ret = 0, bsize = 0; uint16_t length = 0, l = 0; int sockstate; *len = 0; sockstate = fcntl (zebra.sock, F_GETFL, 0); fcntl (zebra.sock, F_SETFL, sockstate|O_NONBLOCK); do { if (*len == bsize) { bsize += BUFSIZE; 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; } free (buf); return NULL; } *len += ret; while ((*len - l) > length) { l += length; memcpy (&length, buf + l, 2); length = ntohs (length); } if (((*len) - l) == length) break; // GOT FULL PACKAGE!! if (*len < l) { fcntl (zebra.sock, F_SETFL, sockstate); continue; } } while (1); fcntl (zebra.sock, F_SETFL, sockstate); return buf; } /* Parse a packet recived from zebra */ int zebra_parse_packet (char *packet, ssize_t maxlen) { /* Array of functions */ int (*foo[ZEBRA_MESSAGE_MAX]) (char *, size_t) = { parse_interface_add, parse_interface_delete, parse_interface_address_add, parse_interface_address_delete, parse_interface_up, parse_interface_down, ipv4_route_add, ipv4_route_delete, parse_ipv6_route_add }; #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; } if (packet[2] - 1 < ZEBRA_MESSAGE_MAX && foo[packet[2] - 1]) { if (!(ret = foo[packet[2] - 1] (packet + 3, length - 3))) return length; else printf ("DEBUG: Parse error: %d\n", ret); } else printf ("Unknown packet type: %d\n", packet[2]); puts ("Quagga: RECIVED PACKET FROM ZEBRA THAT I CAN'T PARSE"); return length; } static int parse_interface_add (char *opt, size_t len) { //todo return 0; } static int parse_interface_delete (char *opt, size_t len) { //todo return 0; } static int parse_interface_address_add (char *opt, size_t len) { //todo return 0; } static int parse_interface_up (char *opt, size_t len) { //todo return 0; } static int parse_interface_down (char *opt, size_t len) { //todo return 0; } static int parse_interface_address_delete (char *opt, size_t len) { //todo return 0; } /* Parse an ipv4-route-packet recived from zebra */ static int parse_ipv4_route (char *opt, size_t len, struct ipv4_route *r) { int c; if (len < 4) return -1; r->type = *opt++; r->flags = *opt++; r->message = *opt++; r->prefixlen = *opt++; len -= 4; r->prefix = 0; if ((int)len < r->prefixlen/8 + (r->prefixlen % 8 ? 1 : 0)) return -1; memcpy (&r->prefix, opt, r->prefixlen/8 + (r->prefixlen % 8 ? 1 : 0)); opt += r->prefixlen/8 + (r->prefixlen % 8 ? 1 : 0); if (r->message & ZAPI_MESSAGE_NEXTHOP) { if (len < 1) return -1; r->nh_count = *opt++; len--; if (len < (sizeof (uint32_t) + 1) * r->nh_count) return -1; r->nexthops = olsr_malloc ((sizeof r->nexthops->type + sizeof r->nexthops->payload) * r->nh_count, "quagga: parse_ipv4_route_add"); for (c = 0; c < r->nh_count; c++) { r->nexthops[c].type = *opt++; memcpy (&r->nexthops[c].payload.v4, opt, sizeof (uint32_t)); opt += sizeof (uint32_t); len -= sizeof (uint32_t) + 1; } } if (r->message & ZAPI_MESSAGE_IFINDEX) { if (len < 1) return -1; r->ind_num = *opt++; if (len < sizeof (uint32_t) * r->ind_num) return -1; r->index = olsr_malloc (sizeof (uint32_t) * r->ind_num, "quagga: parse_ipv4_route_add"); memcpy (r->index, opt, r->ind_num * sizeof (uint32_t)); opt += sizeof (uint32_t) * r->ind_num; len -= sizeof (uint32_t) * r->ind_num; } if (r->message & ZAPI_MESSAGE_DISTANCE) { if (len < 1) return -1; r->distance = *opt++; len--; } if (r->message & ZAPI_MESSAGE_METRIC) { if (len < sizeof (uint32_t)) return -1; memcpy (&r->metric, opt, sizeof (uint32_t)); } return 0; } static int ipv4_route_add (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; } static int ipv4_route_delete (char *opt, size_t len) { struct ipv4_route r; int f; f = parse_ipv4_route (opt, len, &r); if (f < 0) return f; return delete_hna4_route (r); } static int parse_ipv6_route_add (char *opt, size_t len) { //todo return 0; } /* start redistribution FROM zebra */ int zebra_redistribute (unsigned char type) { if (type > ZEBRA_ROUTE_MAX) return -1; zebra.redistribute[type - 1] = 1; return zebra_send_command (ZEBRA_REDISTRIBUTE_ADD, &type, 1); } /* end redistribution FROM zebra */ int zebra_disable_redistribute (unsigned char type) { if (type > ZEBRA_ROUTE_MAX) return -1; zebra.redistribute[type - 1] = 0; return zebra_send_command (ZEBRA_REDISTRIBUTE_DELETE, &type, 1); } static uint32_t prefixlentomask (uint8_t prefix) { uint32_t mask = 0; if (prefix) { mask = 0xffffffff<<(32-prefix); mask = ntohl(mask); } return mask; } int add_hna4_route (struct ipv4_route r) { union olsr_ip_addr net, mask; #ifdef MY_DEBUG dump_ipv4_route(r, "add_hna4_route"); #endif mask.v4 = prefixlentomask(r.prefixlen); net.v4 = r.prefix; add_local_hna4_entry(&net, &mask); free_ipv4_route(r); return 0; } int delete_hna4_route (struct ipv4_route r) { union olsr_ip_addr net, mask; #ifdef MY_DEBUG dump_ipv4_route(r, "delete_hna4_route"); #endif mask.v4 = prefixlentomask(r.prefixlen); net.v4 = r.prefix; remove_local_hna4_entry(&net, &mask) ? 0 : -1; free_ipv4_route(r); return 0; } static void free_ipv4_route (struct ipv4_route r) { if(r.message&ZAPI_MESSAGE_IFINDEX && r.ind_num) free(r.index); if(r.message&ZAPI_MESSAGE_NEXTHOP && r.nh_count) free(r.nexthops); } static uint8_t masktoprefixlen (uint32_t mask) { uint8_t prefixlen = 0; mask = htonl (mask); if (mask) while (mask << ++prefixlen && prefixlen < 32); return prefixlen; } int zebra_add_olsr_v4_route (struct rt_entry *r) { struct ipv4_route route; int retval; route.type = ZEBRA_ROUTE_OLSR; // OLSR route.message = ZAPI_MESSAGE_METRIC; route.flags = zebra.flags; route.prefixlen = masktoprefixlen (r->rt_mask.v4); route.prefix = r->rt_dst.v4; if ((r->rt_router.v4 == r->rt_dst.v4 && route.prefixlen == 32)){ route.message |= ZAPI_MESSAGE_IFINDEX | ZAPI_MESSAGE_NEXTHOP; route.ind_num = 1; route.index = olsr_malloc (sizeof *route.index, "zebra_add_olsr_v4_route"); *route.index = htonl(r->rt_if->if_index); route.nexthops = olsr_malloc (sizeof route.nexthops->type + sizeof route.nexthops->payload, "zebra_add_olsr_v4_route"); route.nh_count = 1; route.nexthops->type = 0; } else { route.message |= ZAPI_MESSAGE_NEXTHOP; route.nh_count = 1; route.nexthops = olsr_malloc (route.nh_count * (sizeof route.nexthops->type + sizeof route.nexthops->payload), "zebra_add_olsr_v4_route"); route.nexthops->type = ZEBRA_NEXTHOP_IPV4; route.nexthops->payload.v4 = r->rt_router.v4; } route.metric = r->rt_metric; route.metric = htonl(route.metric); if (zebra.distance) { route.message |= ZAPI_MESSAGE_DISTANCE; route.distance = zebra.distance; } add_v4_route_status (route); retval = zebra_add_v4_route(route); free_ipv4_route (route); return retval; } int zebra_del_olsr_v4_route (struct rt_entry *r) { struct ipv4_route route; int retval; route.type = ZEBRA_ROUTE_OLSR; // OLSR route.message = ZAPI_MESSAGE_METRIC; route.flags = zebra.flags; route.prefixlen = masktoprefixlen (r->rt_mask.v4); route.prefix = r->rt_dst.v4; if ((r->rt_router.v4 == r->rt_dst.v4 && route.prefixlen == 32)){ route.message |= ZAPI_MESSAGE_IFINDEX; route.ind_num = 1; route.index = olsr_malloc (sizeof *route.index, "zebra_add_olsr_v4_route"); *route.index = htonl (r->rt_if->if_index); route.nexthops = olsr_malloc (sizeof route.nexthops->type + sizeof route.nexthops->payload, "zebra_add_olsr_v4_route"); route.nh_count = 1; route.nexthops->type = 0; } else { route.message |= ZAPI_MESSAGE_NEXTHOP; route.nh_count = 1; route.nexthops = olsr_malloc (route.nh_count * (sizeof route.nexthops->type + sizeof route.nexthops->payload), "zebra_add_olsr_v4_route"); route.nexthops->type = ZEBRA_NEXTHOP_IPV4; route.nexthops->payload.v4 = r->rt_router.v4; } route.metric = r->rt_metric; route.metric = htonl (route.metric); if (zebra.distance) { route.message |= ZAPI_MESSAGE_DISTANCE; route.distance = zebra.distance; } retval = zebra_delete_v4_route(route); del_v4_route_status(route); free_ipv4_route (route); return retval; } void zebra_olsr_distance (char dist) { zebra.distance = dist; } void zebra_olsr_localpref (void) { zebra.flags &= ZEBRA_FLAG_SELECTED; } From (spam-protected) Wed Jan 31 13:38:28 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Wed, 31 Jan 2007 12:38:28 +0000 Subject: [Olsr-cvs] olsrd-current/lib/txtinfo/src olsrd_plugin.c, NONE, 1.1 olsrd_txtinfo.c, NONE, 1.1 olsrd_txtinfo.h, NONE, 1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/txtinfo/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16361/lib/txtinfo/src Added Files: olsrd_plugin.c olsrd_txtinfo.c olsrd_txtinfo.h Log Message: * applied patches from the most recent FreiFunkFirmware (and fixed compile errors) according to http://www.olsr.org/pipermail/olsr-dev/2006-December/254036.html: - olsrd-libsmake.patch - olsrd-dyngwplain.patch - olsrd-txtinfo.patch - olsrd-quagga.patch - olsrd-quagga-routehandler.patch - olsrd-optimize.patch - olsrd-bmf-fixes.patch - olsrd-fixes-sven-ola.patch - olsrd-fixes-jhay-bsd.patch - olsrd-fixes-backport.patch - olsrd-fixes-routedel.patch - olsrd-cpu-overload.patch - olsrd-secure_key_path.patch - olsrd-hna_ip_fix.patch Not applied: - olsrd-nameservice+services.patch: This patch produced too many rejects to fix easily. - olsrd-fixes-eric.patch: This was not found on the webserver. - olsrd-bmf.patch: We had already a "bmf" plug-in in there. * made the checksum type in the olsrd_secure plug-in "olsr_u8_t" (instead of a wild "char *" and "unsigned char *" mix) everywhere. It killed lots of warnings. * localized the checksum_cache array in olsrd_secure.c. --- NEW FILE: olsrd_txtinfo.c --- (This appears to be a binary file; contents omitted.) --- NEW FILE: olsrd_txtinfo.h --- (This appears to be a binary file; contents omitted.) --- NEW FILE: olsrd_plugin.c --- (This appears to be a binary file; contents omitted.) From (spam-protected) Wed Jan 31 13:43:11 2007 From: (spam-protected) (Bernd Petrovitsch) Date: Wed, 31 Jan 2007 12:43:11 +0000 Subject: [Olsr-cvs] olsrd-current/lib/quagga quagga-0.98.6-olsr.diff, NONE, 1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/quagga In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv18570/lib/quagga Added Files: quagga-0.98.6-olsr.diff Log Message: * applied patches from the most recent FreiFunkFirmware (and fixed compile errors) according to http://www.olsr.org/pipermail/olsr-dev/2006-December/254036.html: - olsrd-libsmake.patch - olsrd-dyngwplain.patch - olsrd-txtinfo.patch - olsrd-quagga.patch - olsrd-quagga-routehandler.patch - olsrd-optimize.patch - olsrd-bmf-fixes.patch - olsrd-fixes-sven-ola.patch - olsrd-fixes-jhay-bsd.patch - olsrd-fixes-backport.patch - olsrd-fixes-routedel.patch - olsrd-cpu-overload.patch - olsrd-secure_key_path.patch - olsrd-hna_ip_fix.patch Not applied: - olsrd-nameservice+services.patch: This patch produced too many rejects to fix easily. - olsrd-fixes-eric.patch: This was not found on the webserver. - olsrd-bmf.patch: We had already a "bmf" plug-in in there. * made the checksum type in the olsrd_secure plug-in "olsr_u8_t" (instead of a wild "char *" and "unsigned char *" mix) everywhere. It killed lots of warnings. * localized the checksum_cache array in olsrd_secure.c. --- NEW FILE: quagga-0.98.6-olsr.diff --- 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;