The following commit has been merged in the master branch: commit 7c84d50621f5bd06aaf3f81ff420e1aa9b552279 Author: Stefan Sperling stsp@stsp.in-berlin.de Date: Wed Apr 4 23:13:11 2007 +0200
Make this compile on OpenBSD. I have not tested if this code does even run. It likely won't.
Among the items that still need fixing on *BSD are:
* Is adding/removing routes really working? * Multiple interface support (via berkeley packet filter?) * IP-IP tunnels
diff --git a/batman.h b/batman.h index cc5dd51..a1d1544 100644 --- a/batman.h +++ b/batman.h @@ -22,6 +22,7 @@ #ifndef _BATMAN_BATMAN_H #define _BATMAN_BATMAN_H
+#include <sys/types.h> #include <netinet/in.h> #include <pthread.h> #include <sys/un.h> diff --git a/bsd.c b/bsd.c index 9410828..1409299 100644 --- a/bsd.c +++ b/bsd.c @@ -17,6 +17,8 @@ * */
+#warning BSD support is known broken - if you compile this on BSD you are expected to fix it :-P + #include <sys/types.h> #include <sys/param.h> #include <sys/sysctl.h> @@ -36,10 +38,34 @@ #include <unistd.h> #include <stdlib.h> #include <err.h> +#include <stdarg.h>
#include "os.h" #include "batman-specific.h"
+/* Adapted from busybox */ +int vdprintf(int d, const char *format, va_list ap) +{ + char buf[1024]; + int len; + + len = vsnprintf(buf, sizeof(buf), format, ap); + return write(d, buf, len); +} + +/* From glibc */ +int dprintf(int d, const char *format, ...) +{ + va_list arg; + int done; + + va_start (arg, format); + done = vdprintf (d, format, arg); + va_end (arg); + + return done; +} + void set_forwarding(int state) { int mib[4]; @@ -81,10 +107,11 @@ int get_forwarding(void) return state; }
-int bind_to_iface( int udp_recv_sock, char *dev ) +int8_t bind_to_iface( int32_t udp_recv_sock, char *dev ) { /* XXX: Is binding a socket to a specific - * interface possible in *BSD? */ + * interface possible in *BSD? + * Possibly via bpf... */ return 1; }
@@ -101,7 +128,8 @@ struct rt_msg struct sockaddr_in gateway; };
-void add_del_route( unsigned int dest, unsigned int netmask, unsigned int router, int del, char *dev, int sock ) +void add_del_route( uint32_t dest, uint16_t netmask, uint32_t router, + int8_t del, char *dev, int32_t sock ) { char str1[16], str2[16]; int rt_sock; @@ -252,7 +280,7 @@ int open_tun_any(char *dev_name, size_t dev_name_size) #endif
/* Probe for tun interface availability */ -int probe_tun() +int8_t probe_tun() { /* FIXME tun-supprt broken int fd; @@ -266,12 +294,12 @@ int probe_tun() return 0; }
-int del_dev_tun(int fd) +int8_t del_dev_tun(int32_t fd) { return close(fd); }
-int add_dev_tun(struct batman_if *batman_if, unsigned int tun_addr, char *tun_dev, size_t tun_dev_size, int *fd) +int8_t add_dev_tun(struct batman_if *batman_if, uint32_t tun_addr, char *tun_dev, size_t tun_dev_size, int32_t *fd) { /* FIXME tun-support broken int so;