The following commit has been merged in the master branch: commit 38375e8bab0cbe9c7fb08a6cb84e0fccb9c9096f Author: Marek Lindner lindner_marek@yahoo.de Date: Sat Mar 17 15:16:28 2007 +0100
don't print EOD in debug level 1 or 2 minor bugfixes
diff --git a/batman.c b/batman.c index 3dcdf40..5fc6269 100644 --- a/batman.c +++ b/batman.c @@ -25,7 +25,6 @@ #include <string.h> #include <stdio.h> #include "os.h" -#include "list.h" #include "batman.h" #include "originator.h" #include "schedule.h" diff --git a/batman.h b/batman.h index 2d4b0ea..74fa7b3 100644 --- a/batman.h +++ b/batman.h @@ -17,6 +17,8 @@ * */
+ + #ifndef _BATMAN_BATMAN_H #define _BATMAN_BATMAN_H
diff --git a/originator.c b/originator.c index c9a548b..46f3458 100644 --- a/originator.c +++ b/originator.c @@ -28,9 +28,9 @@
/* needed for hash, compares 2 struct orig_node, but only their ip-addresses. assumes that * the ip address is the first field in the struct */ -int compare_orig(void *data1, void *data2) { +int compare_orig( void *data1, void *data2 ) {
- return(memcmp(data1, data2, 4)); + return ( memcmp( data1, data2, 4 ) );
}
@@ -38,7 +38,7 @@ int compare_orig(void *data1, void *data2) {
/* hashfunction to choose an entry in a hash table of given size */ /* hash algorithm from http://en.wikipedia.org/wiki/Hash_table */ -int choose_orig(void *data, int32_t size) { +int choose_orig( void *data, int32_t size ) {
unsigned char *key= data; uint32_t hash = 0; @@ -102,8 +102,7 @@ struct orig_node *get_orig_node( uint32_t addr ) { if ( swaphash == NULL ) {
debug_output( 0, "Couldn't resize hash table \n" ); - restore_defaults(); - exit(EXIT_FAILURE); + restore_and_exit();
}
@@ -218,7 +217,7 @@ void purge_orig( uint32_t curr_time ) { struct orig_node *orig_node; struct neigh_node *neigh_node, *best_neigh_node; struct gw_node *gw_node; - uint8_t gw_purged = 0, neigh_purged = 0; + uint8_t gw_purged = 0, neigh_purged; static char orig_str[ADDR_STR_LEN];
@@ -273,6 +272,7 @@ void purge_orig( uint32_t curr_time ) { } else {
best_neigh_node = NULL; + neigh_purged = 0;
/* for all neighbours towards this orginator ... */ list_for_each_safe( neigh_pos, neigh_temp, &orig_node->neigh_list ) { diff --git a/originator.h b/originator.h index af1ea96..91bf7da 100644 --- a/originator.h +++ b/originator.h @@ -19,8 +19,8 @@
-int compare_orig(void *data1, void *data2); -int choose_orig(void *data, int32_t size); +int compare_orig( void *data1, void *data2 ); +int choose_orig( void *data, int32_t size ); struct orig_node *get_orig_node( uint32_t addr ); void update_orig( struct orig_node *orig_node, struct packet *in, uint32_t neigh, struct batman_if *if_incoming, unsigned char *hna_recv_buff, int16_t hna_buff_len ); void purge_orig( uint32_t curr_time ); diff --git a/posix-specific.c b/posix-specific.c index df18fa2..8934446 100644 --- a/posix-specific.c +++ b/posix-specific.c @@ -113,13 +113,13 @@ void debug_output( int8_t debug_prio, char *format, ... ) { if ( debug_prio_intern == 3 ) dprintf( debug_level_info->fd, "[%10u] ", get_time() );
- if ( ( ( debug_level == 1 ) || ( debug_level == 2 ) ) && ( debug_level_info->fd == 1 ) && ( strncmp( format, "BOD\n", 3 ) == 0 ) ) { + if ( ( ( debug_level == 1 ) || ( debug_level == 2 ) ) && ( debug_level_info->fd == 1 ) && ( strncmp( format, "BOD", 3 ) == 0 ) ) {
system( "clear" );
} else {
- if ( ( ( debug_level != 1 ) && ( debug_level != 2 ) ) || ( debug_level_info->fd != 1 ) || ( strncmp( format, "EOD\n", 3 ) == 0 ) ) + if ( ( ( debug_level != 1 ) && ( debug_level != 2 ) ) || ( debug_level_info->fd != 1 ) || ( strncmp( format, "EOD", 3 ) != 0 ) ) vdprintf( debug_level_info->fd, format, args );
} diff --git a/schedule.c b/schedule.c index a64a186..27a03fe 100644 --- a/schedule.c +++ b/schedule.c @@ -174,10 +174,8 @@ void send_outstanding_packets() {
debug_output( 4, "Forwarding packet (originator %s, seqno %d, TTL %d) on interface %s\n", orig_str, ntohs( ((struct packet *)forw_node->pack_buff)->seqno ), ((struct packet *)forw_node->pack_buff)->ttl, forw_node->if_outgoing->dev );
- if ( send_packet( forw_node->pack_buff, forw_node->pack_buff_len, &forw_node->if_outgoing->broad, forw_node->if_outgoing->udp_send_sock ) < 0 ) { - restore_defaults(); - exit(EXIT_FAILURE); - } + if ( send_packet( forw_node->pack_buff, forw_node->pack_buff_len, &forw_node->if_outgoing->broad, forw_node->if_outgoing->udp_send_sock ) < 0 ) + restore_and_exit();
} else {
@@ -190,10 +188,8 @@ void send_outstanding_packets() {
if ( ( forw_node->if_outgoing != NULL ) ) {
- if ( send_packet( forw_node->pack_buff, forw_node->pack_buff_len, &forw_node->if_outgoing->broad, forw_node->if_outgoing->udp_send_sock ) < 0 ) { - restore_defaults(); - exit(EXIT_FAILURE); - } + if ( send_packet( forw_node->pack_buff, forw_node->pack_buff_len, &forw_node->if_outgoing->broad, forw_node->if_outgoing->udp_send_sock ) < 0 ) + restore_and_exit();
} else {
@@ -224,17 +220,13 @@ void send_outstanding_packets() { /* non-primary interfaces do not send hna information */ if ( ( forw_node->own ) && ( ((struct packet *)forw_node->pack_buff)->orig != ((struct batman_if *)if_list.next)->addr.sin_addr.s_addr ) ) {
- if ( send_packet( forw_node->pack_buff, sizeof(struct packet), &batman_if->broad, batman_if->udp_send_sock ) < 0 ) { - restore_defaults(); - exit(EXIT_FAILURE); - } + if ( send_packet( forw_node->pack_buff, sizeof(struct packet), &batman_if->broad, batman_if->udp_send_sock ) < 0 ) + restore_and_exit();
} else {
- if ( send_packet( forw_node->pack_buff, forw_node->pack_buff_len, &batman_if->broad, batman_if->udp_send_sock ) < 0 ) { - restore_defaults(); - exit(EXIT_FAILURE); - } + if ( send_packet( forw_node->pack_buff, forw_node->pack_buff_len, &batman_if->broad, batman_if->udp_send_sock ) < 0 ) + restore_and_exit();
}