Some additional includes are required to compile the B.A.T.M.A.N. visualization daemon under FreeBSD and OSX.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Tuesday 13 January 2009 11:52:35 Antoine van Gelder wrote:
Some additional includes are required to compile the B.A.T.M.A.N. visualization daemon under FreeBSD and OSX.
Hm, the headers are also needed on other plattforms. In linux we have deep includes in some headers but this must not be always that way. I would say that they should be included in all supported plattforms. Maybe you can have a look at my patch so I didn't messed up the osx support (dont have an OS X here to test it).
Best regards, Sven
PS: Interested in porting batmand again to *bsd plattforms?
On 13 Jan 2009, at 20:46 , Sven Eckelmann wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Tuesday 13 January 2009 11:52:35 Antoine van Gelder wrote:
Some additional includes are required to compile the B.A.T.M.A.N. visualization daemon under FreeBSD and OSX.
Hm, the headers are also needed on other plattforms. In linux we have deep includes in some headers but this must not be always that way. I would say that they should be included in all supported plattforms. Maybe you can have a look at my patch so I didn't messed up the osx support (dont have an OS X here to test it).
Compiles fine under FreeBSD and OSX, tx!
PS: Interested in porting batmand again to *bsd plattforms?
Possibly - it would be nice to have the option to mesh with a beastie :)
Do you have a rough idea of what broke since it last worked ?
- antoine
On Tuesday 13 January 2009 22:29:25 Antoine van Gelder wrote:
On 13 Jan 2009, at 20:46 , Sven Eckelmann wrote:
PS: Interested in porting batmand again to *bsd plattforms?
Possibly - it would be nice to have the option to mesh with a beastie :)
Do you have a rough idea of what broke since it last worked ?
Don't know when it worked the last time but it doesnt compile at the moment.
There are also some parts marked as "not implemented" in bsd/route.c You must check if all functions in bsd/*.c are in sync with linux/*.c
Best regards, Sven
Signed-off-by: Sven Eckelmann sven.eckelmann@gmx.de --- batman/bsd/kernel.c | 9 ++------- batman/bsd/tun.c | 6 +++--- 2 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/batman/bsd/kernel.c b/batman/bsd/kernel.c index 505f551..0a126d4 100644 --- a/batman/bsd/kernel.c +++ b/batman/bsd/kernel.c @@ -35,7 +35,7 @@ #include "../os.h" #include "../batman.h"
-void set_forwarding(int state) +void set_forwarding(int32_t state) { int mib[4];
@@ -56,7 +56,7 @@ void set_forwarding(int state) err(1, "Cannot change net.inet.ip.forwarding"); }
-int get_forwarding(void) +int32_t get_forwarding(void) { int state; size_t len; @@ -138,11 +138,6 @@ int8_t bind_to_iface( int32_t udp_recv_sock, char *dev ) return 1; }
-int8_t use_kernel_module( char *dev ) -{ - return -1; -} - int32_t use_gateway_module(void) { return -1; diff --git a/batman/bsd/tun.c b/batman/bsd/tun.c index d38b954..7d4c79c 100644 --- a/batman/bsd/tun.c +++ b/batman/bsd/tun.c @@ -51,7 +51,7 @@ * this string is assumed to be dev_name_size bytes large. */ #if defined(__OpenBSD__) || defined(__Darwin__) -int open_tun_any(char *dev_name, size_t dev_name_size) +static int open_tun_any(char *dev_name, size_t dev_name_size) { int i; int fd; @@ -72,7 +72,7 @@ int open_tun_any(char *dev_name, size_t dev_name_size) return -1; } #elif defined(__FreeBSD__) -int open_tun_any(char *dev_name, size_t dev_name_size) +static int open_tun_any(char *dev_name, size_t dev_name_size) { int fd; struct stat buf; @@ -90,7 +90,7 @@ int open_tun_any(char *dev_name, size_t dev_name_size) #endif
/* Probe for tun interface availability */ -int8_t probe_tun() +int8_t probe_tun(uint8_t print_to_stderr) { int fd; fd = open_tun_any(NULL, 0);
On Wednesday 14 January 2009 01:45:26 Sven Eckelmann wrote:
On Tuesday 13 January 2009 22:29:25 Antoine van Gelder wrote:
On 13 Jan 2009, at 20:46 , Sven Eckelmann wrote:
PS: Interested in porting batmand again to *bsd plattforms?
Possibly - it would be nice to have the option to mesh with a beastie :)
Do you have a rough idea of what broke since it last worked ?
Don't know when it worked the last time but it doesnt compile at the moment.
There are also some parts marked as "not implemented" in bsd/route.c You must check if all functions in bsd/*.c are in sync with linux/*.c
The biggest problem seems to be posix/tunnel.c - it uses struct iphdr from netinet/ip.h. FreeBSD will give you struct ip which has completely different names. So you have to find a good way to get both versions for linux and for bsd without creating a big mess. You have also to include netinet/in_systm.h before including netinet/ip.h
Maybe the best way would be to add a function to get the protocol of the tunneled packet (from buffer) and a function to get the destination. After copying the implementation for linux you have to implement it for freebsd.
I hope that the rest compiles and links fine and the time to test it begins afterwards :D
Best regards, Sven
FreeBSD has different definition of udp and ip headers then systems with glibc. To support both a two new static functions were introduced.
* get_tunneled_protocol - get protocol of inside the tunneled ip packet * get_tunneled_udpdest - get udp port of tunneled udp/ip packet
New systems can easily introduced in that way without changing the real code.
Signed-off-by: Sven Eckelmann sven.eckelmann@gmx.de --- batman/posix/tunnel.c | 31 +++++++++++++++++++++++++++---- 1 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/batman/posix/tunnel.c b/batman/posix/tunnel.c index a576bb9..44a4ff0 100644 --- a/batman/posix/tunnel.c +++ b/batman/posix/tunnel.c @@ -28,6 +28,7 @@ #include <arpa/inet.h> #include <sys/ioctl.h> #include <sys/socket.h> +#include <netinet/in_systm.h> #include <netinet/ip.h> #include <netinet/udp.h> #include <netinet/tcp.h> @@ -70,6 +71,28 @@ void init_bh_ports(void)
+static uint8_t get_tunneled_protocol(const unsigned char *buff) +{ +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__Darwin__) + return ((struct ip *)(buff + 1))->ip_p; +#else + return ((struct iphdr *)(buff + 1))->protocol; +#endif +} + + + +static uint16_t get_tunneled_udpdest(const unsigned char *buff) +{ +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__Darwin__) + return ((struct udphdr *)(buff + 1 + ((struct ip *)(buff + 1))->ip_hl*4))->uh_dport; +#else + return ((struct udphdr *)(buff + 1 + ((struct iphdr *)(buff + 1))->ihl*4))->dest; +#endif +} + + + static int8_t get_tun_ip(struct sockaddr_in *gw_addr, int32_t udp_sock, uint32_t *tun_addr) { struct sockaddr_in sender_addr; @@ -257,7 +280,7 @@ void *client_to_gw_tun(void *arg) if (write(tun_fd, buff + 1, buff_len - 1) < 0) debug_output(0, "Error - can't write packet: %s\n", strerror(errno));
- if (((struct iphdr *)(buff + 1))->protocol != IPPROTO_ICMP) { + if (get_tunneled_protocol(buff) != IPPROTO_ICMP) { gw_state = GW_STATE_VERIFIED; gw_state_time = current_time; } @@ -305,11 +328,11 @@ void *client_to_gw_tun(void *arg)
ignore_packet = 0;
- if (((struct iphdr *)(buff + 1))->protocol == IPPROTO_UDP) { + if (get_tunneled_protocol(buff) == IPPROTO_UDP) {
for (i = 0; i < (int)(sizeof(bh_udp_ports)/sizeof(short)); i++) {
- if (((struct udphdr *)(buff + 1 + ((struct iphdr *)(buff + 1))->ihl*4))->dest == bh_udp_ports[i]) { + if (get_tunneled_udpdest(buff) == bh_udp_ports[i]) {
ignore_packet = 1; break; @@ -318,7 +341,7 @@ void *client_to_gw_tun(void *arg)
}
- } else if (((struct iphdr *)(buff + 1))->protocol == IPPROTO_ICMP) { + } else if (get_tunneled_protocol(buff) == IPPROTO_ICMP) {
ignore_packet = 1;
Signed-off-by: Sven Eckelmann sven.eckelmann@gmx.de --- batman/bsd/tun.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/batman/bsd/tun.c b/batman/bsd/tun.c index b44dac3..3e75c4c 100644 --- a/batman/bsd/tun.c +++ b/batman/bsd/tun.c @@ -89,6 +89,20 @@ static int open_tun_any(char *dev_name, size_t dev_name_size) } #endif
+/* Probe for iptables binary availability */ +int probe_nat_tool(void) { + fprintf(stderr, "probe_nat_tool: not implemented\n"); + return -1; +} + +void add_nat_rule(char *BATMANUNUSED(dev)) { + fprintf(stderr, "add_nat_rule: not implemented\n"); +} + +void del_nat_rule(char *BATMANUNUSED(dev)) { + fprintf(stderr, "del_nat_rule: not implemented\n"); +} + /* Probe for tun interface availability */ int8_t probe_tun(uint8_t BATMANUNUSED(print_to_stderr)) {
On Wednesday 14 January 2009 01:45:26 Sven Eckelmann wrote:
There are also some parts marked as "not implemented" in bsd/route.c You must check if all functions in bsd/*.c are in sync with linux/*.c
You should also check what needs to be ported from rev629 for the "ip source patch"
Best regards, Sven
On 14 Jan 2009, at 12:56 , Sven Eckelmann wrote:
On Wednesday 14 January 2009 01:45:26 Sven Eckelmann wrote:
There are also some parts marked as "not implemented" in bsd/route.c You must check if all functions in bsd/*.c are in sync with linux/*.c
You should also check what needs to be ported from rev629 for the "ip source patch"
Thanks Sven, you've given me a pretty clear picture of how to proceed!
I'm going to take a look at it over the weekend and see how far I get.
- antoine
Signed-off-by: Sven Eckelmann sven.eckelmann@gmx.de --- batman/bsd/kernel.c | 10 +++++----- batman/bsd/route.c | 12 ++++++------ batman/bsd/tun.c | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/batman/bsd/kernel.c b/batman/bsd/kernel.c index 0a126d4..b98c06f 100644 --- a/batman/bsd/kernel.c +++ b/batman/bsd/kernel.c @@ -76,7 +76,7 @@ int32_t get_forwarding(void) return state; }
-void set_send_redirects(int32_t state, char* dev) +void set_send_redirects(int32_t state, char* BATMANUNUSED(dev)) { int mib[4];
@@ -97,7 +97,7 @@ void set_send_redirects(int32_t state, char* dev) err(1, "Cannot change net.inet.ip.redirect"); }
-int32_t get_send_redirects(char *dev) +int32_t get_send_redirects(char *BATMANUNUSED(dev)) { int state; size_t len; @@ -117,20 +117,20 @@ int32_t get_send_redirects(char *dev) return state; }
-void set_rp_filter( int32_t state, char* dev ) +void set_rp_filter( int32_t BATMANUNUSED(state), char* BATMANUNUSED(dev) ) { /* On BSD, reverse path filtering should be disabled in the firewall. */ return; }
-int32_t get_rp_filter( char *dev ) +int32_t get_rp_filter( char *BATMANUNUSED(dev) ) { /* On BSD, reverse path filtering should be disabled in the firewall. */ return 0; }
-int8_t bind_to_iface( int32_t udp_recv_sock, char *dev ) +int8_t bind_to_iface( int32_t BATMANUNUSED(udp_recv_sock), char *BATMANUNUSED(dev) ) { /* XXX: Is binding a socket to a specific * interface possible in *BSD? diff --git a/batman/bsd/route.c b/batman/bsd/route.c index 953e995..8c9de48 100644 --- a/batman/bsd/route.c +++ b/batman/bsd/route.c @@ -139,8 +139,8 @@ static uint32_t get_dev_addr(char *dev) return addr->sin_addr.s_addr; }
-void add_del_route(uint32_t dest, uint8_t netmask, uint32_t router, uint32_t src_ip, - int32_t ifi, char *dev, uint8_t rt_table, int8_t route_type, int8_t del) +void add_del_route(uint32_t dest, uint8_t netmask, uint32_t router, uint32_t BATMANUNUSED(src_ip), + int32_t BATMANUNUSED(ifi), char *dev, uint8_t BATMANUNUSED(rt_table), int8_t BATMANUNUSED(route_type), int8_t del) { char dest_str[16], router_str[16]; struct rt_msg msg; @@ -203,20 +203,20 @@ void add_del_route(uint32_t dest, uint8_t netmask, uint32_t router, uint32_t src }
-void add_del_rule(uint32_t network, uint8_t netmask, int8_t rt_table, - uint32_t prio, char *iif, int8_t dst_rule, int8_t del ) +void add_del_rule(uint32_t BATMANUNUSED(network), uint8_t BATMANUNUSED(netmask), int8_t BATMANUNUSED(rt_table), + uint32_t BATMANUNUSED(prio), char *BATMANUNUSED(iif), int8_t BATMANUNUSED(dst_rule), int8_t BATMANUNUSED(del) ) { fprintf(stderr, "add_del_rule: not implemented\n"); return; }
-int add_del_interface_rules( int8_t del ) +int add_del_interface_rules( int8_t BATMANUNUSED(del) ) { fprintf(stderr, "add_del_interface_rules: not implemented\n"); return 0; }
-int flush_routes_rules( int8_t rt_table ) +int flush_routes_rules( int8_t BATMANUNUSED(rt_table) ) { fprintf(stderr, "flush_routes_rules: not implemented\n"); return 0; diff --git a/batman/bsd/tun.c b/batman/bsd/tun.c index 7d4c79c..b44dac3 100644 --- a/batman/bsd/tun.c +++ b/batman/bsd/tun.c @@ -90,7 +90,7 @@ static int open_tun_any(char *dev_name, size_t dev_name_size) #endif
/* Probe for tun interface availability */ -int8_t probe_tun(uint8_t print_to_stderr) +int8_t probe_tun(uint8_t BATMANUNUSED(print_to_stderr)) { int fd; fd = open_tun_any(NULL, 0); @@ -105,7 +105,7 @@ int8_t del_dev_tun(int32_t fd) return close(fd); }
-int8_t set_tun_addr(int32_t fd, uint32_t tun_addr, char *tun_ifname) +int8_t set_tun_addr(int32_t BATMANUNUSED(fd), uint32_t tun_addr, char *tun_ifname) { int so; struct ifreq ifr_tun; @@ -136,7 +136,7 @@ int8_t set_tun_addr(int32_t fd, uint32_t tun_addr, char *tun_ifname) }
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, int32_t *ifi) + char *tun_dev, size_t tun_dev_size, int32_t *fd, int32_t *BATMANUNUSED(ifi)) { int so; struct ifreq ifr_tun, ifr_if;
On 14 Jan 2009, at 02:45 , Sven Eckelmann wrote:
On Tuesday 13 January 2009 22:29:25 Antoine van Gelder wrote:
On 13 Jan 2009, at 20:46 , Sven Eckelmann wrote:
PS: Interested in porting batmand again to *bsd plattforms?
Possibly - it would be nice to have the option to mesh with a beastie :)
Do you have a rough idea of what broke since it last worked ?
Don't know when it worked the last time but it doesnt compile at the moment.
Fun weekend :)
batmand compiles under FreeBSD now but Darwin (Mac OSX) support is still broken.
From what I can make out it looks like net/if_tun.h mysteriously got renditioned at some point on the road to Leopard.
Not sure what the best strategy would be moving forward. Any advice/ suggestions ? http://tuntaposx.sourceforge.net perhaps ?
Some more information at: http://lists.apple.com/archives/Darwin-development/2000/Oct/msg00033.html
There are also some parts marked as "not implemented" in bsd/route.c You must check if all functions in bsd/*.c are in sync with linux/*.c
These are the functions to manage the policy routing rules - I've had some limited success running batmand with the --policy-routing-script option but this is going to have to wait till next weekend to finish up.
Best antoine
-- http://7degrees.co.za "Libré software for human education."
FreeBSD doesn't include as much deep includes in their socket headers as the linux ones does. To support building on freebsd we must include them explicit.
Signed-off-by: Sven Eckelmann sven.eckelmann@gmx.de CC: Antoine van Gelder antoine@7degrees.co.za --- vis-advanced/vis.c | 2 +- vis-advanced/vis.h | 2 ++ vis/vis.c | 2 +- vis/vis.h | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/vis-advanced/vis.c b/vis-advanced/vis.c index 721d690..69f69b8 100644 --- a/vis-advanced/vis.c +++ b/vis-advanced/vis.c @@ -23,10 +23,10 @@
#include <fcntl.h> +#include <sys/socket.h> #include <net/if.h> #include <sys/ioctl.h> #include <sys/select.h> -#include <sys/time.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> diff --git a/vis-advanced/vis.h b/vis-advanced/vis.h index 6f6793e..a060c83 100644 --- a/vis-advanced/vis.h +++ b/vis-advanced/vis.h @@ -25,6 +25,8 @@ #include <pthread.h> #include <sys/socket.h> #include <sys/types.h> +#include <sys/time.h> +#include <netinet/in.h> #include <arpa/inet.h> #include <errno.h>
diff --git a/vis/vis.c b/vis/vis.c index 05f4096..c488365 100644 --- a/vis/vis.c +++ b/vis/vis.c @@ -23,10 +23,10 @@
#include <fcntl.h> +#include <sys/socket.h> #include <net/if.h> #include <sys/ioctl.h> #include <sys/select.h> -#include <sys/time.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> diff --git a/vis/vis.h b/vis/vis.h index 8953b70..1f343d8 100644 --- a/vis/vis.h +++ b/vis/vis.h @@ -25,7 +25,9 @@ #include <pthread.h> #include <sys/socket.h> #include <sys/types.h> +#include <sys/time.h> #include <arpa/inet.h> +#include <netinet/in.h> #include <errno.h>
Very COOL...!!
On Wed, Jan 14, 2009 at 1:46 AM, Sven Eckelmann sven.eckelmann@gmx.dewrote:
FreeBSD doesn't include as much deep includes in their socket headers as the linux ones does. To support building on freebsd we must include them explicit.
Signed-off-by: Sven Eckelmann sven.eckelmann@gmx.de CC: Antoine van Gelder antoine@7degrees.co.za
vis-advanced/vis.c | 2 +- vis-advanced/vis.h | 2 ++ vis/vis.c | 2 +- vis/vis.h | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/vis-advanced/vis.c b/vis-advanced/vis.c index 721d690..69f69b8 100644 --- a/vis-advanced/vis.c +++ b/vis-advanced/vis.c @@ -23,10 +23,10 @@
#include <fcntl.h> +#include <sys/socket.h> #include <net/if.h> #include <sys/ioctl.h> #include <sys/select.h> -#include <sys/time.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> diff --git a/vis-advanced/vis.h b/vis-advanced/vis.h index 6f6793e..a060c83 100644 --- a/vis-advanced/vis.h +++ b/vis-advanced/vis.h @@ -25,6 +25,8 @@ #include <pthread.h> #include <sys/socket.h> #include <sys/types.h> +#include <sys/time.h> +#include <netinet/in.h> #include <arpa/inet.h> #include <errno.h>
diff --git a/vis/vis.c b/vis/vis.c index 05f4096..c488365 100644 --- a/vis/vis.c +++ b/vis/vis.c @@ -23,10 +23,10 @@
#include <fcntl.h> +#include <sys/socket.h> #include <net/if.h> #include <sys/ioctl.h> #include <sys/select.h> -#include <sys/time.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> diff --git a/vis/vis.h b/vis/vis.h index 8953b70..1f343d8 100644 --- a/vis/vis.h +++ b/vis/vis.h @@ -25,7 +25,9 @@ #include <pthread.h> #include <sys/socket.h> #include <sys/types.h> +#include <sys/time.h> #include <arpa/inet.h> +#include <netinet/in.h> #include <errno.h>
-- 1.6.0.6
B.A.T.M.A.N mailing list B.A.T.M.A.N@open-mesh.net https://list.open-mesh.net/mm/listinfo/b.a.t.m.a.n
Hello guys,
thank you very much for the patches! I've applied Svens patch because it is more general (including these headers in any case should not hurt). Compatibility patches are highly appreciated, we still have tickets open requesting Mac OS X support ... :)
best regards Simon
On Tue, Jan 13, 2009 at 12:52:35PM +0200, Antoine van Gelder wrote:
Some additional includes are required to compile the B.A.T.M.A.N. visualization daemon under FreeBSD and OSX.
b.a.t.m.a.n@lists.open-mesh.org