The following commit has been merged in the master branch: commit f6f34167708d4add75d5aedb3d2a3044c2e8cc2d Author: Marek Lindner lindner_marek@yahoo.de Date: Tue Apr 24 09:58:52 2007 +0200
use sequence numbers instead of timeout for bidirectional neighbour detection
diff --git a/batman.c b/batman.c index aaaf64f..fe1c59a 100644 --- a/batman.c +++ b/batman.c @@ -87,8 +87,6 @@ uint8_t routing_class = 0;
int16_t orginator_interval = 1000; /* orginator message interval in miliseconds */
-uint32_t bidirectional_timeout = 0; /* bidirectional neighbour reply timeout in ms */ - struct gw_node *curr_gateway = NULL; pthread_t curr_gateway_thread_id = 0; pthread_mutex_t curr_gw_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -519,16 +517,20 @@ int isDuplicate( struct orig_node *orig_node, uint16_t seqno ) { }
int isBntog( uint32_t neigh, struct orig_node *orig_tog_node ) { - if ( ( orig_tog_node->router != NULL ) && ( orig_tog_node->router->addr == neigh ) ) return 1; - else return 0; + + if ( ( orig_tog_node->router != NULL ) && ( orig_tog_node->router->addr == neigh ) ) + return 1; + + return 0; + }
int isBidirectionalNeigh( struct orig_node *orig_neigh_node, struct batman_if *if_incoming ) {
- if ( orig_neigh_node->bidirect_link[if_incoming->if_num] > 0 && ( orig_neigh_node->bidirect_link[if_incoming->if_num] + (bidirectional_timeout) ) >= get_time() ) + if ( ( orig_neigh_node->bidirect_link[if_incoming->if_num] + BIDIRECT_TIMEOUT ) >= if_incoming->out.seqno ) return 1; - else - return 0; + + return 0;
}
@@ -588,7 +590,6 @@ int8_t batman() {
debug_timeout = get_time(); - bidirectional_timeout = orginator_interval * 2;
if ( NULL == ( orig_hash = hash_new( 128, compare_orig, choose_orig ) ) ) return(-1); @@ -735,9 +736,9 @@ int8_t batman() { /* neighbour has to indicate direct link and it has to come via the corresponding interface */ if ( ( ((struct packet *)&in)->flags & DIRECTLINK ) && ( if_incoming->addr.sin_addr.s_addr == ((struct packet *)&in)->orig ) ) {
- orig_neigh_node->bidirect_link[if_incoming->if_num] = get_time(); + orig_neigh_node->bidirect_link[if_incoming->if_num] = ((struct packet *)&in)->seqno;
- debug_output( 4, "received my own packet from neighbour indicating bidirectional link, updating bidirect_link timestamp \n"); + debug_output( 4, "received my own packet from neighbour indicating bidirectional link, updating bidirect_link seqno \n");
}
diff --git a/batman.h b/batman.h index aabddb9..73f6bc0 100644 --- a/batman.h +++ b/batman.h @@ -56,6 +56,7 @@
#define JITTER 100 #define TTL 50 /* Time To Live of broadcast messages */ +#define BIDIRECT_TIMEOUT 2 #define TIMEOUT 60000 /* sliding window size of received orginator messages in ms */ #define SEQ_RANGE 64 /* sliding packet range of received orginator messages in squence numbers (should be a multiple of our word size) */
@@ -112,7 +113,7 @@ struct orig_node /* structure for orig_list maintaining nodes of uint32_t orig; struct neigh_node *router; struct batman_if *batman_if; - uint32_t *bidirect_link; /* if node is a bidrectional neighbour, when my originator packet was broadcasted (replied) by this node and received by me */ + uint16_t *bidirect_link; /* if node is a bidrectional neighbour, when my originator packet was broadcasted (replied) by this node and received by me */ uint32_t last_aware; /* when last packet from this node was received */ uint8_t gwflags; /* flags related to gateway functions: gateway class */ unsigned char *hna_buff; diff --git a/originator.c b/originator.c index 4285e8a..9ac52e7 100644 --- a/originator.c +++ b/originator.c @@ -90,8 +90,8 @@ struct orig_node *get_orig_node( uint32_t addr ) { orig_node->router = NULL; orig_node->batman_if = NULL;
- orig_node->bidirect_link = debugMalloc( found_ifs * sizeof(uint32_t), 402 ); - memset( orig_node->bidirect_link, 0, found_ifs * sizeof(uint32_t) ); + orig_node->bidirect_link = debugMalloc( found_ifs * sizeof(uint16_t), 402 ); + memset( orig_node->bidirect_link, 0, found_ifs * sizeof(uint16_t) );
hash_add( orig_hash, orig_node );