The following commit has been merged in the master branch: commit 88337f8628266ba4cfc33f8cf17c8c0ebf06b870 Author: Marek Lindner lindner_marek@yahoo.de Date: Wed Sep 20 21:50:11 2006 +0200
fix freebsd changes
diff --git a/batman.c b/batman.c index 5cb8862..7fe6901 100755 --- a/batman.c +++ b/batman.c @@ -1023,7 +1023,7 @@ int batman() /* if a unidirectional neighbour sends us a packet - retransmit it with unidirectional flag to tell him that we get its packets */ /* if a bidirectional neighbour sends us a packet - retransmit it with unidirectional flag - if it is not our best link to it in order to prevent routing problems */ + if it is not our best link to it in order to prevent routing problems */ if ( ( in.orig == neigh ) && ( ( !isBidirectionalNeigh( orig_neigh_node ) ) || ( orig_neigh_node->router != 0 ) ) ) {
schedule_forward_packet(&in, 1, orig_neigh_node, neigh); diff --git a/linux.c b/linux.c index ca0896d..dd96969 100755 --- a/linux.c +++ b/linux.c @@ -36,6 +36,8 @@ #include <asm/types.h> #include <linux/if_tun.h> #include <linux/if_tunnel.h> +#include <sys/stat.h> +#include <fcntl.h>
#include "os.h" #include "batman.h" @@ -116,13 +118,17 @@ void add_del_route(unsigned int dest, unsigned int router, int del, char *dev, i /* Probe for tun interface availability */ int probe_tun() { + int fd; + if ( ( fd = open( "/dev/net/tun", O_RDWR ) ) < 0 ) {
fprintf( stderr, "Error - could not open '/dev/net/tun' ! Is the tun kernel module loaded ?\n" ); - close_all_sockets(); return 0; + } + return 1; + }
int del_ipip_tun( int fd ) { diff --git a/os.h b/os.h index ab43924..95ecdf7 100755 --- a/os.h +++ b/os.h @@ -35,5 +35,8 @@ void addr_to_string(unsigned int addr, char *str, int len); int receive_packet(unsigned char *buff, int len, unsigned int *neigh, unsigned int timeout, struct batman_if **if_incoming); int send_packet(unsigned char *buff, int len, struct sockaddr_in *broad, int sock); int rand_num(int limit); +int probe_tun(); +int del_ipip_tun( int fd ); +int add_ipip_tun( struct batman_if *batman_if, unsigned int dest_addr, char *tun_dev, int *fd );
#endif diff --git a/posix.c b/posix.c index 790594e..599851f 100644 --- a/posix.c +++ b/posix.c @@ -774,7 +774,7 @@ int main(int argc, char *argv[])
if (found_ifs == 0) { - fprintf(stderr, "Error - no interface specified\n"); + fprintf(stderr, "Error - no interface specified\n"); usage(); close_all_sockets(); exit(EXIT_FAILURE); @@ -804,8 +804,10 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); }
- if(!probe_tun()) + if ( ( ( routing_class != 0 ) || ( gateway_class != 0 ) ) && ( !probe_tun() ) ) { + close_all_sockets(); exit(EXIT_FAILURE); + }
close( fd );