This daemon is useful to me because it implements the routing protocol currently used in Berlin's Freifunk community wifi mesh. I have not been able to run this on OpenBSD for like a decade because our current port is very out of date and does not work in today's mesh configuration.
This updates the port to the latest stable release, fixes a bug in ifnet.c, adds an rc script, rolls the plugins into the -main package (the stock daemon is pretty useless without them) and removes pkg/MESSAGE. I am also adding a dependency on libnet because the daemon is otherwise unable to send UDP packets to the address 255.255.255.255 which is required for Berlin's mesh config. The files which were in the share/doc directory in old releases are gone. The docs are of pretty dubious quality in general anyway and users are better served reading the website (or, in some cases, the code). Lightly tested on a -current laptop where I can successfully get IPv4 routes to the mesh over ral(4) in IBSS mode. I have not tested v6 yet but will eventually. I plan to put this on my OpenBSD gateway to the mesh soon, where it will get some long term testing. OK? Index: Makefile =================================================================== RCS file: /cvs/ports/net/olsrd/Makefile,v retrieving revision 1.27 diff -u -p -r1.27 Makefile --- Makefile 2 Mar 2017 19:05:08 -0000 1.27 +++ Makefile 12 May 2017 15:43:05 -0000 @@ -2,31 +2,29 @@ COMMENT-main= OLSR routing daemon COMMENT-gui= OLSR routing daemon GUI -COMMENT-plugins= OLSR routing daemon plugins -VERSION= 0.6.0 +VERSION= 0.9.0.3 DISTNAME= olsrd-${VERSION} PKGNAME-main= olsrd-${VERSION} PKGNAME-gui= olsrd-gui-${VERSION} PKGNAME-plugins= olsrd-plugins-${VERSION} -REVISION= 8 CATEGORIES= net HOMEPAGE= http://www.olsr.org/ -MASTER_SITES= ${HOMEPAGE}releases/0.6/ +MASTER_SITES= ${HOMEPAGE}releases/0.9/ MAINTAINER= Martin Reindl <mar...@openbsd.org> # BSD PERMIT_PACKAGE_CDROM= Yes -MULTI_PACKAGES= -main -gui -plugins +MULTI_PACKAGES= -main -gui BUILD_DEPENDS= devel/bison -LIB_DEPENDS-main= # empty -WANTLIB-main= c +LIB_DEPENDS-main= net/libnet/1.1 +WANTLIB-main= c lib/libnet-1.1/net=11 LIB_DEPENDS-gui= x11/gtk+2 WANTLIB-gui= ${MODGETTEXT_WANTLIB} @@ -36,9 +34,6 @@ WANTLIB-gui += gdk-x11-2.0 gdk_pixbuf-2. WANTLIB-gui += gtk-x11-2.0 m pango-1.0 pangocairo-1.0 pangoft2-1.0 WANTLIB-gui += z -WANTLIB-plugins= # empty -LIB_DEPENDS-plugins= # empty -RUN_DEPENDS-plugins= olsrd-${VERSION}:net/olsrd USE_GMAKE= Yes NO_TEST= Yes @@ -46,7 +41,8 @@ NO_TEST= Yes MODULES= devel/gettext ALL_TARGET= build_all -MAKE_FLAGS= DEBUG=0 CC="${CC}" +MAKE_FLAGS= DEBUG=0 CC="${CC}" OS=obsd LIBNET=1 +CPPFLAGS+= "-I${PREFIX}/libnet-1.1" FAKE_FLAGS= SBINDIR=${DESTDIR}/${PREFIX}/sbin \ ETCDIR=${DESTDIR}/${PREFIX}/share/examples/olsrd \ LIBDIR=${DESTDIR}/${PREFIX}/lib/olsrd-plugins \ @@ -68,11 +64,8 @@ post-install: ${INSTALL_PROGRAM} ${WRKSRC}/gui/linux-gtk/olsrd-gui ${PREFIX}/sbin ${INSTALL_SCRIPT} ${WRKSRC}/lib/dot_draw/olsr-topology-view.pl \ ${PREFIX}/bin - cd ${PREFIX}/man; gzip -d man5/olsrd.conf.5.gz man8/olsrd.8.gz + cd ${PREFIX}/man; gzip -f -d man5/olsrd.conf.5.gz man8/olsrd.8.gz ${INSTALL_DATA} ${WRKSRC}/files/olsrd.conf.default.* \ ${PREFIX}/share/examples/olsrd - ${INSTALL_DATA_DIR} ${PREFIX}/share/doc/olsrd - cd ${WRKSRC}; ${INSTALL_DATA} CHANGELOG README README-Link-Quality* \ - ${PREFIX}/share/doc/olsrd .include <bsd.port.mk> Index: distinfo =================================================================== RCS file: /cvs/ports/net/olsrd/distinfo,v retrieving revision 1.8 diff -u -p -r1.8 distinfo --- distinfo 31 Oct 2013 21:12:13 -0000 1.8 +++ distinfo 3 Apr 2016 10:48:32 -0000 @@ -1,2 +1,2 @@ -SHA256 (olsrd-0.6.0.tar.gz) = qKJNqwCVxz1SSD7bX+aLtbS7dj+bKnp7idz10nXTtEI= -SIZE (olsrd-0.6.0.tar.gz) = 742138 +SHA256 (olsrd-0.9.0.3.tar.gz) = WdN1cMWOwlY2px1afPRGBEi+aT8B12iuNpp/ZuWAd/s= +SIZE (olsrd-0.9.0.3.tar.gz) = 5791920 Index: patches/patch-make_Makefile_obsd =================================================================== RCS file: /cvs/ports/net/olsrd/patches/patch-make_Makefile_obsd,v retrieving revision 1.2 diff -u -p -r1.2 patch-make_Makefile_obsd --- patches/patch-make_Makefile_obsd 6 Jul 2010 07:41:46 -0000 1.2 +++ patches/patch-make_Makefile_obsd 12 May 2017 15:19:35 -0000 @@ -1,15 +1,37 @@ $OpenBSD: patch-make_Makefile_obsd,v 1.2 2010/07/06 07:41:46 sthen Exp $ ---- make/Makefile.obsd.orig Wed Mar 31 19:03:53 2010 -+++ make/Makefile.obsd Sun Jun 13 13:42:51 2010 -@@ -11,9 +11,8 @@ HDRS += $(wildcard src/bsd/*.h src/unix/*.h) - CPPFLAGS += -D__OpenBSD__ - LIBS += +Index: make/Makefile.obsd +--- make/Makefile.obsd.orig ++++ make/Makefile.obsd +@@ -8,22 +8,24 @@ ETCDIR = /etc/olsrd + LIBDIR = $(PREFIX)/lib + DOCDIR = $(PREFIX)/share/doc + MANDIR = $(PREFIX)/man +-RCDIR = /etc/rc.d ++RCDIR = ${DESTDIR}/etc/rc.d + RCFILE = openbsd/olsrd.rcd + + SRCS += $(wildcard src/bsd/*.c src/unix/*.c) + HDRS += $(wildcard src/bsd/*.h src/unix/*.h) + +-CPPFLAGS += -D__OpenBSD__ +-LIBS += ++CPPFLAGS += -DOLSRD_GLOBAL_CONF_FILE=\"$(CFGFILE)\" -D__OpenBSD__ + ++ifdef LIBNET ++CPPFLAGS += -DSPOOF -I$(PREFIX)/include/libnet-1.1 ++LIBS += -L$(PREFIX)/lib/libnet-1.1 -lnet ++endif ++ + PLUGIN_SONAME ?= $(PLUGIN_NAME) -PLUGIN_FULLNAME ?= $(PLUGIN_NAME).so.$(PLUGIN_VER) -INSTALL_LIB = install -m 755 $(PLUGIN_FULLNAME) $(LIBDIR)/$(PLUGIN_FULLNAME); \ - /sbin/ldconfig +-UNINSTALL_LIB = rm -f $(LIBDIR)/$(PLUGIN_FULLNAME); \ +- /sbin/ldconfig +PLUGIN_FULLNAME ?= $(PLUGIN_NAME).so -+INSTALL_LIB = install -m 755 $(PLUGIN_FULLNAME) $(LIBDIR)/$(PLUGIN_FULLNAME); ++INSTALL_LIB = install -m 755 $(PLUGIN_FULLNAME) $(LIBDIR)/$(PLUGIN_FULLNAME); ++UNINSTALL_LIB = rm -f $(LIBDIR)/$(PLUGIN_FULLNAME) ifdef OLSRD_PLUGIN CFLAGS += -fPIC Index: patches/patch-src_bsd_net_c =================================================================== RCS file: patches/patch-src_bsd_net_c diff -N patches/patch-src_bsd_net_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_bsd_net_c 12 May 2017 15:21:02 -0000 @@ -0,0 +1,14 @@ +$OpenBSD$ + +Index: src/bsd/net.c +--- src/bsd/net.c.orig ++++ src/bsd/net.c +@@ -594,7 +594,7 @@ olsr_sendto(int s, const void *buf, size_t len, int fl + + /* initialize IP ID field if necessary */ + if (ip_id == 0) { +- ip_id = (u_int16_t) (olsr_random() & 0xffff); ++ ip_id = (u_int16_t) (arc4random() & 0xffff); + } + + udp_tag = libnet_build_udp(olsr_cnf->olsrport, /* src port */ Index: patches/patch-src_cfgparser_local_mk =================================================================== RCS file: /cvs/ports/net/olsrd/patches/patch-src_cfgparser_local_mk,v retrieving revision 1.1 diff -u -p -r1.1 patch-src_cfgparser_local_mk --- patches/patch-src_cfgparser_local_mk 6 Jul 2010 07:41:46 -0000 1.1 +++ patches/patch-src_cfgparser_local_mk 3 Apr 2016 10:50:31 -0000 @@ -1,7 +1,7 @@ $OpenBSD: patch-src_cfgparser_local_mk,v 1.1 2010/07/06 07:41:46 sthen Exp $ ---- src/cfgparser/local.mk.orig Wed Mar 31 18:03:53 2010 -+++ src/cfgparser/local.mk Tue Jun 29 15:25:30 2010 -@@ -73,5 +73,7 @@ $(C)oparse.c: $(C)oparse.y $(C)olsrd_conf.h $(C)Makefi +--- src/cfgparser/local.mk.orig Sun Sep 20 14:22:23 2015 ++++ src/cfgparser/local.mk Sun Apr 3 12:48:37 2016 +@@ -79,5 +79,7 @@ endif $(C)oparse.o: CFLAGS := $(filter-out -Wunreachable-code,$(CFLAGS)) Index: patches/patch-src_plugin_loader_c =================================================================== RCS file: /cvs/ports/net/olsrd/patches/patch-src_plugin_loader_c,v retrieving revision 1.1 diff -u -p -r1.1 patch-src_plugin_loader_c --- patches/patch-src_plugin_loader_c 14 Jun 2010 12:36:34 -0000 1.1 +++ patches/patch-src_plugin_loader_c 3 Apr 2016 12:24:23 -0000 @@ -1,26 +1,27 @@ $OpenBSD: patch-src_plugin_loader_c,v 1.1 2010/06/14 12:36:34 sebastia Exp $ the plugins get installed to $LOCALBASE/lib/olsrd-plugins, so load them from there. ---- src/plugin_loader.c.orig Tue Jun 1 09:42:27 2010 -+++ src/plugin_loader.c Tue Jun 1 09:43:13 2010 -@@ -87,20 +87,14 @@ olsr_load_plugins(void) +--- src/plugin_loader.c.orig Sun Sep 20 14:22:23 2015 ++++ src/plugin_loader.c Sun Apr 3 14:06:06 2016 +@@ -88,20 +88,14 @@ olsr_load_plugins(void) static int olsr_load_dl(char *libname, struct plugin_param *params) { --#if TESTLIB_PATH +-#if defined TESTLIB_PATH && TESTLIB_PATH - char path[256] = "/usr/testlib/"; --#endif -+ char path[256] = "${LOCALBASE}/lib/olsrd-plugins/"; +-#endif /* defined TESTLIB_PATH && TESTLIB_PATH */ ++ char path[256] = "/usr/local/lib/olsrd-plugins/"; struct olsr_plugin *plugin = olsr_malloc(sizeof(struct olsr_plugin), "Plugin entry"); int rv; OLSR_PRINTF(0, "---------- LOADING LIBRARY %s ----------\n", libname); --#if TESTLIB_PATH - strcat(path, libname); +-#if defined TESTLIB_PATH && TESTLIB_PATH +- strcat(path, libname); ++ strlcat(path, libname, sizeof(path)); plugin->dlhandle = dlopen(path, RTLD_NOW); --#else +-#else /* defined TESTLIB_PATH && TESTLIB_PATH */ - plugin->dlhandle = dlopen(libname, RTLD_NOW); --#endif +-#endif /* defined TESTLIB_PATH && TESTLIB_PATH */ if (plugin->dlhandle == NULL) { const int save_errno = errno; OLSR_PRINTF(0, "DL loading failed: \"%s\"!\n", dlerror()); Index: patches/patch-src_unix_ifnet_c =================================================================== RCS file: patches/patch-src_unix_ifnet_c diff -N patches/patch-src_unix_ifnet_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_unix_ifnet_c 12 May 2017 14:47:12 -0000 @@ -0,0 +1,17 @@ +$OpenBSD$ + +Index: src/unix/ifnet.c +--- src/unix/ifnet.c.orig ++++ src/unix/ifnet.c +@@ -646,7 +646,10 @@ chk_if_up(struct olsr_if *iface, int debuglvl __attrib + /* Find broadcast address */ + if (iface->cnf->ipv4_multicast.v4.s_addr) { + /* Specified broadcast */ +- memcpy(&((struct sockaddr_in *)&ifs.int_broadaddr)->sin_addr.s_addr, &iface->cnf->ipv4_multicast.v4, sizeof(uint32_t)); ++ struct sockaddr_in *sin = &ifs.int_broadaddr; ++ memcpy(&sin->sin_addr.s_addr, &iface->cnf->ipv4_multicast.v4, sizeof(uint32_t)); ++ sin->sin_len = sizeof(*sin); ++ sin->sin_family = AF_INET; + } else { + /* Autodetect */ + if (ioctl(olsr_cnf->ioctl_s, SIOCGIFBRDADDR, &ifr) < 0) { Index: pkg/MESSAGE-main =================================================================== RCS file: pkg/MESSAGE-main diff -N pkg/MESSAGE-main --- pkg/MESSAGE-main 14 Jun 2010 12:36:34 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,6 +0,0 @@ -In order to start olsrd at boot time, edit ${SYSCONFDIR}/olsrd.conf and -add the following lines to /etc/rc.local: - -if [ -x ${PREFIX}/sbin/olsrd ]; then - echo -n ' olsrd'; ${PREFIX}/sbin/olsrd -fi Index: pkg/PLIST-main =================================================================== RCS file: /cvs/ports/net/olsrd/pkg/PLIST-main,v retrieving revision 1.2 diff -u -p -r1.2 PLIST-main --- pkg/PLIST-main 6 Jul 2010 07:41:46 -0000 1.2 +++ pkg/PLIST-main 12 May 2017 15:41:41 -0000 @@ -1,17 +1,24 @@ -@comment $OpenBSD: PLIST-main,v 1.2 2010/07/06 07:41:46 sthen Exp $ -@pkgpath net/olsrd +@comment $OpenBSD$ +bin/olsr-topology-view.pl +lib/olsrd-plugins/ +lib/olsrd-plugins/olsrd_dot_draw.so +lib/olsrd-plugins/olsrd_httpinfo.so +lib/olsrd-plugins/olsrd_jsoninfo.so +lib/olsrd-plugins/olsrd_mini.so +lib/olsrd-plugins/olsrd_nameservice.so +lib/olsrd-plugins/olsrd_pgraph.so +lib/olsrd-plugins/olsrd_secure.so +lib/olsrd-plugins/olsrd_txtinfo.so +lib/olsrd-plugins/olsrd_watchdog.so @man man/man5/olsrd.conf.5 @man man/man8/olsrd.8 @bin sbin/olsrd -share/doc/olsrd/ -share/doc/olsrd/CHANGELOG -share/doc/olsrd/README -share/doc/olsrd/README-Link-Quality-Fish-Eye.txt -share/doc/olsrd/README-Link-Quality.html share/examples/olsrd/ -@comment share/examples/olsrd/olsrd.conf +@sample ${SYSCONFDIR}/olsrd/ +share/examples/olsrd/olsrd.conf +@sample ${SYSCONFDIR}/olsrd/olsrd.conf share/examples/olsrd/olsrd.conf.default.full +share/examples/olsrd/olsrd.conf.default.full.txt share/examples/olsrd/olsrd.conf.default.lq -share/examples/olsrd/olsrd.conf.default.lq-fisheye share/examples/olsrd/olsrd.conf.default.rfc -@sample ${SYSCONFDIR}/olsrd.conf +@rcscript /etc/rc.d/olsrd Index: pkg/olsrd.rc =================================================================== RCS file: pkg/olsrd.rc diff -N pkg/olsrd.rc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ pkg/olsrd.rc 3 Apr 2016 11:04:23 -0000 @@ -0,0 +1,9 @@ +#!/bin/sh + +daemon="${TRUEPREFIX}/sbin/olsrd" + +. /etc/rc.d/rc.subr + +rc_reload=NO + +rc_cmd $1