The following commit has been merged in the master branch: commit e6f9b9dd04f1c35c443a70c51c83ed868c3609c8 Author: Marek Lindner lindner_marek@yahoo.de Date: Tue Mar 6 19:45:56 2007 +0100
code cleanup variable bitarray size removed
diff --git a/Makefile b/Makefile index 6d85cd1..fa0a8e4 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ OS_OBJ= posix-specific.o posix.o bsd.o allocate.o bitarray.o endif
LINUX_SRC_C= batman.c posix-specific.c posix.c linux-specific.c linux.c allocate.c bitarray.c -LINUX_SRC_H= batman.h batman-specific.h list.h os.h allocate.h +LINUX_SRC_H= batman.h batman-specific.h list.h os.h allocate.h bitarray.h
all: batmand
diff --git a/batman.h b/batman.h index 6116481..3801b74 100644 --- a/batman.h +++ b/batman.h @@ -25,6 +25,7 @@ #include <sys/un.h> #include <stdint.h> #include "list.h" +#include "bitarray.h"
#define SOURCE_VERSION "0.2 alpha" @@ -47,16 +48,11 @@ #define JITTER 100 #define TTL 50 /* Time To Live of broadcast messages */ #define TIMEOUT 60000 /* sliding window size of received orginator messages in ms */ -#define SEQ_RANGE 60 /* sliding packet range of received orginator messages in squence numbers (should be a multiple of our word size) */ +#define SEQ_RANGE 64 /* sliding packet range of received orginator messages in squence numbers (should be a multiple of our word size) */
-#define TYPE_OF_WORD unsigned long /* you should choose something big, if you don't want to waste cpu */ - -#define MIN_NUM_WORDS ( SEQ_RANGE / ( sizeof(TYPE_OF_WORD) * 8 ) ) -#define RST_NUM_WORDS ( SEQ_RANGE % ( sizeof(TYPE_OF_WORD) * 8 ) ) -#define NUM_WORDS ( RST_NUM_WORDS ? ( MIN_NUM_WORDS + 1) : MIN_NUM_WORDS ) -#define WORD_BIT_SIZE ( sizeof(TYPE_OF_WORD) * 8 ) +#define NUM_WORDS ( SEQ_RANGE / WORD_BIT_SIZE )
@@ -213,12 +209,4 @@ void verbose_usage( void ); void del_default_route(); int8_t add_default_route();
-void bit_init( TYPE_OF_WORD *seq_bits ); -uint8_t get_bit_status( TYPE_OF_WORD *seq_bits, uint16_t last_seqno, uint16_t curr_seqno ); -char *bit_print( TYPE_OF_WORD *seq_bits ); -void bit_mark( TYPE_OF_WORD *seq_bits, int32_t n ); -void bit_shift( TYPE_OF_WORD *seq_bits, int32_t n ); -char bit_get_packet( TYPE_OF_WORD *seq_bits, int32_t seq_num_diff, int8_t set_mark ); -int bit_packet_count( TYPE_OF_WORD *seq_bits ); - #endif diff --git a/bitarray.c b/bitarray.c index dccd5fd..0ed6b8a 100644 --- a/bitarray.c +++ b/bitarray.c @@ -186,11 +186,11 @@ char bit_get_packet( TYPE_OF_WORD *seq_bits, int32_t seq_num_diff, int8_t set_ma int bit_packet_count( TYPE_OF_WORD *seq_bits ) {
int i, hamming = 0; - TYPE_OF_WORD word, pattern=~0; + TYPE_OF_WORD word;
for (i=0; i<NUM_WORDS; i++) {
- word= ( ( i < NUM_WORDS - 1 ) ? seq_bits[i] : seq_bits[i] & pattern >> ( WORD_BIT_SIZE - RST_NUM_WORDS ) ); + word = seq_bits[i];
while (word) {
diff --git a/linux-specific.c b/linux-specific.c index d15769e..9af8385 100644 --- a/linux-specific.c +++ b/linux-specific.c @@ -237,7 +237,7 @@ int8_t add_dev_tun( struct batman_if *batman_if, uint32_t tun_addr, char *tun_de /* set MTU of tun interface: real MTU - 28 */ if ( ifr_if.ifr_mtu < 100 ) {
- debug_output( 0, "Warning - MTU smaller than 100 -> can't reduce MTU anymore\n", strerror(errno) ); + debug_output( 0, "Warning - MTU smaller than 100 -> can't reduce MTU anymore\n" );
} else {
diff --git a/posix-specific.c b/posix-specific.c index 2e3ec56..f3f069a 100644 --- a/posix-specific.c +++ b/posix-specific.c @@ -131,7 +131,7 @@ void *unix_listen( void *arg ) {
max_sock = unix_if.unix_sock;
- while (!is_aborted()) { + while ( !is_aborted() ) {
tv.tv_sec = 1; tv.tv_usec = 0; diff --git a/posix.c b/posix.c index 22772e9..ca145f2 100644 --- a/posix.c +++ b/posix.c @@ -249,13 +249,11 @@ int main( int argc, char *argv[] ) { int8_t res; stop = 0;
-// memset( &device_node_array[0], 0, sizeof( device_node_array ) ); -// printf("B.A.T.M.A.N-experimental %s\n", VERSION);
/* check if user is root */ if ( ( getuid() ) || ( getgid() ) ) {
- fprintf( stderr, "Error - you must be root to run batmand !\n" ); + fprintf( stderr, "Error - you must be root to run %s !\n", argv[0] ); exit(EXIT_FAILURE);
} @@ -263,19 +261,15 @@ int main( int argc, char *argv[] ) { apply_init_args( argc, argv );
- signal(SIGINT, handler); - signal(SIGTERM, handler); + signal( SIGINT, handler ); + signal( SIGTERM, handler );
- gettimeofday(&start_time, NULL); - srand(getpid()); + gettimeofday( &start_time, NULL ); + srand( getpid() );
-// forward_old = get_forwarding(); -// set_forwarding(1);
res = batman();
-// delAllRoutes(); -// set_forwarding(forward_old);
close_all_sockets(); cleanup();