/* Kernel AODV v2.1 National Institute of Standards and Technology Luke Klein-Berndt ----------------------------------------------------- Version 2.1 new features: * Much more stable! * Added locks around important areas * Multihop Internet gatewaying now works * Multicast hack added * Many bug fixes! ----------------------------------------------------- Originally based upon MadHoc code. I am not sure how much of it is left anymore, but MadHoc proved to be a great starting point. MadHoc was written by - Fredrik Lilieblad, Oskar Mattsson, Petra Nylund, Dan Ouchterlony and Anders Roxenhag Mail: mad-hoc@flyinglinux.net This software is Open Source under the GNU General Public Licence. */ /**************************************************** rebroadcast_list ---------------------------------------------------- Rebroadcast List keeps track of the packets which have been rebroadcasted. It makes sure that a packet does not get reboradcasted twice... duplicate packets are bad! It does this by keep a list of the past N sequence numbers. There is a seperate list for each neighboring node. If a packet's seq num is below the lower bounds of the list then it is assumed that the packet is too old. If it falls in range of the list, it is checked to see if it has been recieved prior, if not it is rebroadcast. ****************************************************/ #include "rebroadcast_list.h" #ifdef AODV_MULTICAST struct ticket *ticket_roll[256]; void init_check() { int i; for (i=0;icheck,0,sizeof(u_int8_t)*LIST_SIZE); ticket_roll[target]->last_checked=0; ticket_roll[target]->current_check=0; ticket_roll[target]->check_amount=0; } amount=id-ticket_roll[target]->check_amount; if (amount < -LIST_SIZE) { if (getcurrtime()-ticket_roll[target]->last_checked>10000) { memset(ticket_roll[target]->check,0,sizeof(u_int8_t)*LIST_SIZE); ticket_roll[target]->last_checked=getcurrtime(); ticket_roll[target]->current_check=0; ticket_roll[target]->check_amount=id; printk("IP: %s ID: %u RESTARTED!!!!!!!!!!!!\n",inet_ntoa(ip),id); return 1; } printk(" %d ID: %u Amount %d Current %d been forever!\n",target,id,amount,ticket_roll[target]->check_amount); return 0; } //new_position=(LIST_SIZE+amount)%LIST_SIZE; if (amount>0) { amount=amount % LIST_SIZE; for (i=0;i<=amount;i++) { point=(i+ticket_roll[target]->current_check) % LIST_SIZE; ticket_roll[target]->check[point]=0; } ticket_roll[target]->last_checked=getcurrtime(); ticket_roll[target]->current_check=point;//(amount+ticket_roll[target]->current_check+LIST_SIZE) % LIST_SIZE; ticket_roll[target]->check_amount=id; // printk("IP: %s ID: %u New!\n",inet_ntoa(ip),id); ticket_roll[target]->check[point]=1; return 1; } point=(amount+ticket_roll[target]->current_check+LIST_SIZE) % LIST_SIZE; if (ticket_roll[target]->check[point]) { //printk("IP: %s ID: %u already recieved!\n",inet_ntoa(ip),id); return 0; } else { //printk("IP: %s ID: %u New!\n",inet_ntoa(ip),id); ticket_roll[target]->check[point]=1; return 1; } } #endif