From (spam-protected) Tue Dec 12 11:43:18 2006 From: (spam-protected) (Andreas Tønnesen) Date: Tue, 12 Dec 2006 10:43:18 +0000 Subject: [Olsr-cvs] olsrd-current/lib/nameservice/src nameservice.c, 1.14, 1.14.2.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/nameservice/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv4822/lib/nameservice/src Modified Files: Tag: olsrd_04 nameservice.c Log Message: Added patch from John Hay(with some very minor modifications) Index: nameservice.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/nameservice/src/nameservice.c,v retrieving revision 1.14 retrieving revision 1.14.2.1 diff -C2 -d -r1.14 -r1.14.2.1 *** nameservice.c 29 May 2005 12:47:42 -0000 1.14 --- nameservice.c 12 Dec 2006 10:43:16 -0000 1.14.2.1 *************** *** 72,75 **** --- 72,77 ---- olsr_bool name_table_changed = OLSR_TRUE; + static void free_routing_table_list(struct rt_entry **list) ; + static struct rt_entry *host_lookup_routing_table(union olsr_ip_addr *); /** *************** *** 140,144 **** } else if(!strcmp(key, "dns-server")) { ! struct in_addr ip; if (strlen(value) == 0) { // set dns server ip to main address --- 142,146 ---- } else if(!strcmp(key, "dns-server")) { ! union olsr_ip_addr ip; if (strlen(value) == 0) { // set dns server ip to main address *************** *** 146,151 **** have_dns_server = OLSR_TRUE; } ! else if (inet_aton(value, &ip)) { ! my_dns_server.v4 = ip.s_addr; have_dns_server = OLSR_TRUE; } --- 148,153 ---- have_dns_server = OLSR_TRUE; } ! else if (inet_pton(olsr_cnf->ip_version, value, &ip) == 1) { ! memcpy(&my_dns_server, &ip, ipsize); have_dns_server = OLSR_TRUE; } *************** *** 170,176 **** else { // assume this is an IP address and hostname ! struct in_addr ip; ! if (inet_aton(key, &ip)) { // the IP is validated later struct name_entry *tmp; --- 172,178 ---- else { // assume this is an IP address and hostname ! union olsr_ip_addr ip; ! if (inet_pton(olsr_cnf->ip_version, key, &ip) == 1) { // the IP is validated later struct name_entry *tmp; *************** *** 179,183 **** tmp->len = strlen( tmp->name ); tmp->type = NAME_HOST; ! tmp->ip.v4 = ip.s_addr; tmp->next = my_names; my_names = tmp; --- 181,185 ---- tmp->len = strlen( tmp->name ); tmp->type = NAME_HOST; ! memcpy(&tmp->ip, &ip, ipsize); tmp->next = my_names; my_names = tmp; *************** *** 212,219 **** struct name_entry *name; struct name_entry *prev=NULL; /* fixup names and IP addresses */ for (name = my_names; name != NULL; name = name->next) { ! if (name->ip.v4 == 0) { // insert main_addr memcpy(&name->ip, &main_addr, ipsize); --- 214,224 ---- struct name_entry *name; struct name_entry *prev=NULL; + union olsr_ip_addr ipz; + + memset(&ipz, 0, sizeof(ipz)); /* fixup names and IP addresses */ for (name = my_names; name != NULL; name = name->next) { ! if (memcmp(&name->ip, &ipz, ipsize) == 0) { // insert main_addr memcpy(&name->ip, &main_addr, ipsize); *************** *** 239,243 **** if (have_dns_server) { ! if (my_dns_server.v4 == 0) { memcpy(&my_dns_server, &main_addr, ipsize); printf("\nNAME PLUGIN: announcing upstream DNS server: %s\n", --- 244,248 ---- if (have_dns_server) { ! if (memcmp(&my_dns_server, &ipz, ipsize) == 0) { memcpy(&my_dns_server, &main_addr, ipsize); printf("\nNAME PLUGIN: announcing upstream DNS server: %s\n", *************** *** 402,408 **** double vtime; int size; /* Fetch the originator of the messsage */ ! memcpy(&originator, &m->v4.originator, ipsize); /* Fetch the message based on IP version */ --- 407,420 ---- double vtime; int size; + olsr_u16_t seqno; /* Fetch the originator of the messsage */ ! if(olsr_cnf->ip_version == AF_INET) { ! memcpy(&originator, &m->v4.originator, ipsize); ! seqno = ntohs(m->v4.seqno); ! } else { ! memcpy(&originator, &m->v6.originator, ipsize); ! seqno = ntohs(m->v6.seqno); ! } /* Fetch the message based on IP version */ *************** *** 415,419 **** vtime = ME_TO_DOUBLE(m->v6.olsr_vtime); size = ntohs(m->v6.olsr_msgsize); ! namemessage = (struct namemsg*)&m->v4.message; } --- 427,431 ---- vtime = ME_TO_DOUBLE(m->v6.olsr_vtime); size = ntohs(m->v6.olsr_msgsize); ! namemessage = (struct namemsg*)&m->v6.message; } *************** *** 434,438 **** * processed if nessecary */ ! if(!olsr_check_dup_table_proc(&originator, ntohs(m->v4.seqno))) { /* If so - do not process */ goto forward; --- 446,450 ---- * processed if nessecary */ ! if(!olsr_check_dup_table_proc(&originator, seqno)) { /* If so - do not process */ goto forward; *************** *** 444,448 **** /* Forward the message if nessecary * default_fwd does all the work for us! */ ! olsr_forward_message(m, &originator, ntohs(m->v4.seqno), in_if, in_addr); } --- 456,460 ---- /* Forward the message if nessecary * default_fwd does all the work for us! */ ! olsr_forward_message(m, &originator, seqno, in_if, in_addr); } *************** *** 632,636 **** fprintf(hosts, "### do not edit\n\n"); ! fprintf(hosts, "127.0.0.1\tlocalhost\n\n"); // copy content from additional hosts filename --- 644,649 ---- fprintf(hosts, "### do not edit\n\n"); ! fprintf(hosts, "127.0.0.1\tlocalhost\n"); ! fprintf(hosts, "::1\t\tlocalhost\n\n"); // copy content from additional hosts filename *************** *** 689,696 **** { int hash; ! struct name_entry *name; struct db_entry *entry; struct rt_entry *best_routes = NULL; ! struct rt_entry *route, *tmp, *last; FILE* resolv; int i=0; --- 702,709 ---- { int hash; ! struct name_entry *name, *tmp_dns, *last_dns, *dnslist = NULL; struct db_entry *entry; struct rt_entry *best_routes = NULL; ! struct rt_entry *route, *tmp = NULL, *last; FILE* resolv; int i=0; *************** *** 714,718 **** /* find the nearest one */ ! route = olsr_lookup_routing_table(&name->ip); if (route==NULL) // it's possible that route is not present yet continue; --- 727,731 ---- /* find the nearest one */ ! route = host_lookup_routing_table(&name->ip); if (route==NULL) // it's possible that route is not present yet continue; *************** *** 720,724 **** if (best_routes == NULL || route->rt_etx < best_routes->rt_etx) { olsr_printf(6, "NAME PLUGIN: best nameserver %s\n", ! olsr_ip_to_string(&route->rt_dst)); if (best_routes!=NULL) olsr_printf(6, "NAME PLUGIN: better than %f (%s)\n", --- 733,737 ---- if (best_routes == NULL || route->rt_etx < best_routes->rt_etx) { olsr_printf(6, "NAME PLUGIN: best nameserver %s\n", ! olsr_ip_to_string(&name->ip)); if (best_routes!=NULL) olsr_printf(6, "NAME PLUGIN: better than %f (%s)\n", *************** *** 731,741 **** --- 744,763 ---- tmp->next = best_routes; best_routes = tmp; + tmp_dns = olsr_malloc(sizeof(struct name_entry), "write_resolv name_entry"); + COPY_IP(&tmp_dns->ip, &name->ip); + tmp_dns->type = name->type; + tmp_dns->len = 0; + tmp_dns->name = NULL; + tmp_dns->next = dnslist; + dnslist = tmp_dns; } else { // queue in etx order last = best_routes; + last_dns = dnslist; while ( last->next!=NULL && i<3 ) { if (last->next->rt_etx > route->rt_etx) break; last = last->next; + last_dns = last_dns->next; i++; } *************** *** 743,749 **** olsr_printf(6, "NAME PLUGIN: queue %f (%s)", route->rt_etx, ! olsr_ip_to_string(&route->rt_dst)); olsr_printf(6, " after %f (%s)\n", ! last->rt_etx, olsr_ip_to_string(&last->rt_dst)); tmp = olsr_malloc(sizeof(struct rt_entry), "new rt_entry"); --- 765,771 ---- olsr_printf(6, "NAME PLUGIN: queue %f (%s)", route->rt_etx, ! olsr_ip_to_string(&name->ip)); olsr_printf(6, " after %f (%s)\n", ! last->rt_etx, olsr_ip_to_string(&last_dns->ip)); tmp = olsr_malloc(sizeof(struct rt_entry), "new rt_entry"); *************** *** 752,755 **** --- 774,785 ---- tmp->next = last->next; last->next = tmp; + + tmp_dns = olsr_malloc(sizeof(struct name_entry), "write_resolv name_entry"); + COPY_IP(&tmp_dns->ip, &name->ip); + tmp_dns->type = name->type; + tmp_dns->len = 0; + tmp_dns->name = NULL; + tmp_dns->next = last_dns->next; + last_dns->next = tmp_dns; } else { olsr_printf(6, "NAME PLUGIN: don't need more than 3 nameservers\n"); *************** *** 769,777 **** } i=0; ! for (tmp=best_routes; tmp!=NULL && i<3; tmp=tmp->next) { ! olsr_printf(6, "NAME PLUGIN: nameserver %s\n", olsr_ip_to_string(&tmp->rt_dst)); ! fprintf(resolv, "nameserver %s\n", olsr_ip_to_string(&tmp->rt_dst)); i++; } fclose(resolv); } --- 799,811 ---- } i=0; ! for (tmp_dns=dnslist; tmp_dns!=NULL && i<3; tmp_dns=tmp_dns->next) { ! olsr_printf(6, "NAME PLUGIN: nameserver %s\n", olsr_ip_to_string(&tmp_dns->ip)); ! fprintf(resolv, "nameserver %s\n", olsr_ip_to_string(&tmp_dns->ip)); i++; } + free_name_entry_list(&dnslist); + if(tmp != NULL) { + free_routing_table_list(&tmp); + } fclose(resolv); } *************** *** 797,800 **** --- 831,851 ---- /** + * completely free a list of rt_entries + */ + static void + free_routing_table_list(struct rt_entry **list) + { + struct rt_entry **tmp = list; + struct rt_entry *to_delete; + while (*tmp != NULL) { + to_delete = *tmp; + *tmp = (*tmp)->next; + free( to_delete ); + to_delete = NULL; + } + } + + + /** * we only allow names for IP addresses which we are * responsible for: *************** *** 806,810 **** --- 857,863 ---- { struct hna4_entry *hna4; + struct hna6_entry *hna6; struct interface *iface; + union olsr_ip_addr tmp_ip, tmp_msk; olsr_printf(6, "checking %s\n", olsr_ip_to_string(addr)); *************** *** 819,833 **** } ! for (hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next) ! { ! olsr_printf(6, "HNA %s/%s\n", ! olsr_ip_to_string(&hna4->net), ! olsr_ip_to_string(&hna4->netmask)); ! if ( hna4->netmask.v4 != 0 && (addr->v4 & hna4->netmask.v4) == hna4->net.v4 ) { ! olsr_printf(6, "MATCHED\n"); ! return OLSR_TRUE; } } return OLSR_FALSE; } --- 872,954 ---- } ! if (olsr_cnf->ip_version == AF_INET) { ! for (hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next) ! { ! olsr_printf(6, "HNA %s/%s\n", ! olsr_ip_to_string(&hna4->net), ! olsr_ip_to_string(&hna4->netmask)); ! if ( hna4->netmask.v4 != 0 && ! (addr->v4 & hna4->netmask.v4) == hna4->net.v4 ) { ! olsr_printf(6, "MATCHED\n"); ! return OLSR_TRUE; ! } ! } ! } else { ! int i; ! ! for (hna6 = olsr_cnf->hna6_entries; hna6; hna6 = hna6->next) ! { ! olsr_printf(6, "HNA %s/%d\n", ! olsr_ip_to_string(&hna6->net), ! hna6->prefix_len); ! if ( hna6->prefix_len == 0 ) ! continue; ! olsr_prefix_to_netmask(&tmp_msk, hna6->prefix_len); ! for (i = 0; i < 16; i++) { ! tmp_ip.v6.s6_addr[i] = addr->v6.s6_addr[i] & ! tmp_msk.v6.s6_addr[i]; ! } ! if (COMP_IP(&tmp_ip, &hna6->net)) { ! olsr_printf(6, "MATCHED\n"); ! return OLSR_TRUE; ! } } } return OLSR_FALSE; } + + static struct rt_entry * + host_lookup_routing_table(union olsr_ip_addr *dst) + { + olsr_u32_t index; + union olsr_ip_addr tmp_ip, tmp_msk; + struct rt_entry *walker; + + walker = olsr_lookup_routing_table(dst); + if (walker != NULL) + return walker; + + for (index = 0; index < HASHSIZE; index++) { + for (walker = hna_routes[index].next; + walker != &hna_routes[index]; walker = walker->next) { + if (COMP_IP(&walker->rt_dst, dst)) + return walker; + if (olsr_cnf->ip_version == AF_INET) { + if ( walker->rt_mask.v4 != 0 && + (dst->v4 & walker->rt_mask.v4) == + walker->rt_dst.v4 ) { + olsr_printf(6, "MATCHED\n"); + return walker; + } + } else { + int i; + + if ( walker->rt_mask.v6 == 0 ) + continue; + olsr_prefix_to_netmask(&tmp_msk, + walker->rt_mask.v6); + for (i = 0; i < 16; i++) { + tmp_ip.v6.s6_addr[i] = + dst->v6.s6_addr[i] & + tmp_msk.v6.s6_addr[i]; + } + if (COMP_IP(&tmp_ip, &walker->rt_dst)) { + olsr_printf(6, "MATCHED\n"); + return walker; + } + } + } + } + return NULL; + } From (spam-protected) Tue Dec 12 11:54:54 2006 From: (spam-protected) (Andreas Tønnesen) Date: Tue, 12 Dec 2006 10:54:54 +0000 Subject: [Olsr-cvs] olsrd-current/lib/nameservice/src nameservice.c, 1.15, 1.16 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/nameservice/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv9270/lib/nameservice/src Modified Files: nameservice.c Log Message: Added patch from John Hay. Due to diff from last release to HEAD this had to be done partially manually. Hopefully I got everything right... Index: nameservice.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/nameservice/src/nameservice.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** nameservice.c 7 Jan 2006 08:17:43 -0000 1.15 --- nameservice.c 12 Dec 2006 10:54:52 -0000 1.16 *************** *** 72,75 **** --- 72,77 ---- olsr_bool name_table_changed = OLSR_TRUE; + static void free_routing_table_list(struct rt_entry **list) ; + static struct rt_entry *host_lookup_routing_table(union olsr_ip_addr *); /** *************** *** 140,144 **** } else if(!strcmp(key, "dns-server")) { ! struct in_addr ip; if (strlen(value) == 0) { // set dns server ip to main address --- 142,146 ---- } else if(!strcmp(key, "dns-server")) { ! union olsr_ip_addr ip; if (strlen(value) == 0) { // set dns server ip to main address *************** *** 146,151 **** have_dns_server = OLSR_TRUE; } ! else if (inet_aton(value, &ip)) { ! my_dns_server.v4 = ip.s_addr; have_dns_server = OLSR_TRUE; } --- 148,153 ---- have_dns_server = OLSR_TRUE; } ! else if (inet_pton(olsr_cnf->ip_version, value, &ip) == 1) { ! memcpy(&my_dns_server, &ip, olsr_cnf->ipsize); have_dns_server = OLSR_TRUE; } *************** *** 170,176 **** else { // assume this is an IP address and hostname ! struct in_addr ip; ! if (inet_aton(key, &ip)) { // the IP is validated later struct name_entry *tmp; --- 172,178 ---- else { // assume this is an IP address and hostname ! union olsr_ip_addr ip; ! if (inet_pton(olsr_cnf->ip_version, key, &ip) == 1) { // the IP is validated later struct name_entry *tmp; *************** *** 179,183 **** tmp->len = strlen( tmp->name ); tmp->type = NAME_HOST; ! tmp->ip.v4 = ip.s_addr; tmp->next = my_names; my_names = tmp; --- 181,185 ---- tmp->len = strlen( tmp->name ); tmp->type = NAME_HOST; ! memcpy(&tmp->ip, &ip, olsr_cnf->ipsize); tmp->next = my_names; my_names = tmp; *************** *** 212,219 **** struct name_entry *name; struct name_entry *prev=NULL; /* fixup names and IP addresses */ for (name = my_names; name != NULL; name = name->next) { ! if (name->ip.v4 == 0) { // insert main_addr memcpy(&name->ip, &olsr_cnf->main_addr, olsr_cnf->ipsize); --- 214,224 ---- struct name_entry *name; struct name_entry *prev=NULL; + union olsr_ip_addr ipz; + + memset(&ipz, 0, sizeof(ipz)); /* fixup names and IP addresses */ for (name = my_names; name != NULL; name = name->next) { ! if (memcmp(&name->ip, &ipz, olsr_cnf->ipsize) == 0) { // insert main_addr memcpy(&name->ip, &olsr_cnf->main_addr, olsr_cnf->ipsize); *************** *** 239,243 **** if (have_dns_server) { ! if (my_dns_server.v4 == 0) { memcpy(&my_dns_server, &olsr_cnf->main_addr, olsr_cnf->ipsize); printf("\nNAME PLUGIN: announcing upstream DNS server: %s\n", --- 244,248 ---- if (have_dns_server) { ! if (memcmp(&my_dns_server, &ipz, olsr_cnf->ipsize) == 0) { memcpy(&my_dns_server, &olsr_cnf->main_addr, olsr_cnf->ipsize); printf("\nNAME PLUGIN: announcing upstream DNS server: %s\n", *************** *** 402,408 **** double vtime; int size; /* Fetch the originator of the messsage */ ! memcpy(&originator, &m->v4.originator, olsr_cnf->ipsize); /* Fetch the message based on IP version */ --- 407,420 ---- double vtime; int size; + olsr_u16_t seqno; /* Fetch the originator of the messsage */ ! if(olsr_cnf->ip_version == AF_INET) { ! memcpy(&originator, &m->v4.originator, olsr_cnf->ipsize); ! seqno = ntohs(m->v4.seqno); ! } else { ! memcpy(&originator, &m->v6.originator, olsr_cnf->ipsize); ! seqno = ntohs(m->v6.seqno); ! } /* Fetch the message based on IP version */ *************** *** 415,419 **** vtime = ME_TO_DOUBLE(m->v6.olsr_vtime); size = ntohs(m->v6.olsr_msgsize); ! namemessage = (struct namemsg*)&m->v4.message; } --- 427,431 ---- vtime = ME_TO_DOUBLE(m->v6.olsr_vtime); size = ntohs(m->v6.olsr_msgsize); ! namemessage = (struct namemsg*)&m->v6.message; } *************** *** 434,438 **** * processed if nessecary */ ! if(!olsr_check_dup_table_proc(&originator, ntohs(m->v4.seqno))) { /* If so - do not process */ goto forward; --- 446,450 ---- * processed if nessecary */ ! if(!olsr_check_dup_table_proc(&originator, seqno)) { /* If so - do not process */ goto forward; *************** *** 444,448 **** /* Forward the message if nessecary * default_fwd does all the work for us! */ ! olsr_forward_message(m, &originator, ntohs(m->v4.seqno), in_if, in_addr); } --- 456,460 ---- /* Forward the message if nessecary * default_fwd does all the work for us! */ ! olsr_forward_message(m, &originator, seqno, in_if, in_addr); } *************** *** 632,636 **** fprintf(hosts, "### do not edit\n\n"); ! fprintf(hosts, "127.0.0.1\tlocalhost\n\n"); // copy content from additional hosts filename --- 644,649 ---- fprintf(hosts, "### do not edit\n\n"); ! fprintf(hosts, "127.0.0.1\tlocalhost\n"); ! fprintf(hosts, "::1\t\tlocalhost\n\n"); // copy content from additional hosts filename *************** *** 689,696 **** { int hash; ! struct name_entry *name; struct db_entry *entry; struct rt_entry *best_routes = NULL; ! struct rt_entry *route, *tmp, *last; FILE* resolv; int i=0; --- 702,709 ---- { int hash; ! struct name_entry *name, *tmp_dns, *last_dns, *dnslist = NULL; struct db_entry *entry; struct rt_entry *best_routes = NULL; ! struct rt_entry *route, *tmp = NULL, *last; FILE* resolv; int i=0; *************** *** 714,718 **** /* find the nearest one */ ! route = olsr_lookup_routing_table(&name->ip); if (route==NULL) // it's possible that route is not present yet continue; --- 727,731 ---- /* find the nearest one */ ! route = host_lookup_routing_table(&name->ip); if (route==NULL) // it's possible that route is not present yet continue; *************** *** 720,724 **** if (best_routes == NULL || route->rt_etx < best_routes->rt_etx) { olsr_printf(6, "NAME PLUGIN: best nameserver %s\n", ! olsr_ip_to_string(&route->rt_dst)); if (best_routes!=NULL) olsr_printf(6, "NAME PLUGIN: better than %f (%s)\n", --- 733,737 ---- if (best_routes == NULL || route->rt_etx < best_routes->rt_etx) { olsr_printf(6, "NAME PLUGIN: best nameserver %s\n", ! olsr_ip_to_string(&name->ip)); if (best_routes!=NULL) olsr_printf(6, "NAME PLUGIN: better than %f (%s)\n", *************** *** 731,741 **** --- 744,763 ---- tmp->next = best_routes; best_routes = tmp; + tmp_dns = olsr_malloc(sizeof(struct name_entry), "write_resolv name_entry"); + COPY_IP(&tmp_dns->ip, &name->ip); + tmp_dns->type = name->type; + tmp_dns->len = 0; + tmp_dns->name = NULL; + tmp_dns->next = dnslist; + dnslist = tmp_dns; } else { // queue in etx order last = best_routes; + last_dns = dnslist; while ( last->next!=NULL && i<3 ) { if (last->next->rt_etx > route->rt_etx) break; last = last->next; + last_dns = last_dns->next; i++; } *************** *** 743,749 **** olsr_printf(6, "NAME PLUGIN: queue %f (%s)", route->rt_etx, ! olsr_ip_to_string(&route->rt_dst)); olsr_printf(6, " after %f (%s)\n", ! last->rt_etx, olsr_ip_to_string(&last->rt_dst)); tmp = olsr_malloc(sizeof(struct rt_entry), "new rt_entry"); --- 765,771 ---- olsr_printf(6, "NAME PLUGIN: queue %f (%s)", route->rt_etx, ! olsr_ip_to_string(&name->ip)); olsr_printf(6, " after %f (%s)\n", ! last->rt_etx, olsr_ip_to_string(&last_dns->ip)); tmp = olsr_malloc(sizeof(struct rt_entry), "new rt_entry"); *************** *** 752,755 **** --- 774,785 ---- tmp->next = last->next; last->next = tmp; + + tmp_dns = olsr_malloc(sizeof(struct name_entry), "write_resolv name_entry"); + COPY_IP(&tmp_dns->ip, &name->ip); + tmp_dns->type = name->type; + tmp_dns->len = 0; + tmp_dns->name = NULL; + tmp_dns->next = last_dns->next; + last_dns->next = tmp_dns; } else { olsr_printf(6, "NAME PLUGIN: don't need more than 3 nameservers\n"); *************** *** 769,777 **** } i=0; ! for (tmp=best_routes; tmp!=NULL && i<3; tmp=tmp->next) { ! olsr_printf(6, "NAME PLUGIN: nameserver %s\n", olsr_ip_to_string(&tmp->rt_dst)); ! fprintf(resolv, "nameserver %s\n", olsr_ip_to_string(&tmp->rt_dst)); i++; } fclose(resolv); } --- 799,811 ---- } i=0; ! for (tmp_dns=dnslist; tmp_dns!=NULL && i<3; tmp_dns=tmp_dns->next) { ! olsr_printf(6, "NAME PLUGIN: nameserver %s\n", olsr_ip_to_string(&tmp_dns->ip)); ! fprintf(resolv, "nameserver %s\n", olsr_ip_to_string(&tmp_dns->ip)); i++; } + free_name_entry_list(&dnslist); + if(tmp != NULL) { + free_routing_table_list(&tmp); + } fclose(resolv); } *************** *** 797,800 **** --- 831,851 ---- /** + * completely free a list of rt_entries + */ + static void + free_routing_table_list(struct rt_entry **list) + { + struct rt_entry **tmp = list; + struct rt_entry *to_delete; + while (*tmp != NULL) { + to_delete = *tmp; + *tmp = (*tmp)->next; + free( to_delete ); + to_delete = NULL; + } + } + + + /** * we only allow names for IP addresses which we are * responsible for: *************** *** 806,810 **** --- 857,863 ---- { struct hna4_entry *hna4; + struct hna6_entry *hna6; struct interface *iface; + union olsr_ip_addr tmp_ip, tmp_msk; olsr_printf(6, "checking %s\n", olsr_ip_to_string(addr)); *************** *** 819,833 **** } ! for (hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next) ! { ! olsr_printf(6, "HNA %s/%s\n", ! olsr_ip_to_string(&hna4->net), ! olsr_ip_to_string(&hna4->netmask)); ! if ( hna4->netmask.v4 != 0 && (addr->v4 & hna4->netmask.v4) == hna4->net.v4 ) { ! olsr_printf(6, "MATCHED\n"); ! return OLSR_TRUE; } } return OLSR_FALSE; } --- 872,954 ---- } ! if (olsr_cnf->ip_version == AF_INET) { ! for (hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next) ! { ! olsr_printf(6, "HNA %s/%s\n", ! olsr_ip_to_string(&hna4->net), ! olsr_ip_to_string(&hna4->netmask)); ! if ( hna4->netmask.v4 != 0 && ! (addr->v4 & hna4->netmask.v4) == hna4->net.v4 ) { ! olsr_printf(6, "MATCHED\n"); ! return OLSR_TRUE; ! } ! } ! } else { ! int i; ! ! for (hna6 = olsr_cnf->hna6_entries; hna6; hna6 = hna6->next) ! { ! olsr_printf(6, "HNA %s/%d\n", ! olsr_ip_to_string(&hna6->net), ! hna6->prefix_len); ! if ( hna6->prefix_len == 0 ) ! continue; ! olsr_prefix_to_netmask(&tmp_msk, hna6->prefix_len); ! for (i = 0; i < 16; i++) { ! tmp_ip.v6.s6_addr[i] = addr->v6.s6_addr[i] & ! tmp_msk.v6.s6_addr[i]; ! } ! if (COMP_IP(&tmp_ip, &hna6->net)) { ! olsr_printf(6, "MATCHED\n"); ! return OLSR_TRUE; ! } } } return OLSR_FALSE; } + + static struct rt_entry * + host_lookup_routing_table(union olsr_ip_addr *dst) + { + olsr_u32_t index; + union olsr_ip_addr tmp_ip, tmp_msk; + struct rt_entry *walker; + + walker = olsr_lookup_routing_table(dst); + if (walker != NULL) + return walker; + + for (index = 0; index < HASHSIZE; index++) { + for (walker = hna_routes[index].next; + walker != &hna_routes[index]; walker = walker->next) { + if (COMP_IP(&walker->rt_dst, dst)) + return walker; + if (olsr_cnf->ip_version == AF_INET) { + if ( walker->rt_mask.v4 != 0 && + (dst->v4 & walker->rt_mask.v4) == + walker->rt_dst.v4 ) { + olsr_printf(6, "MATCHED\n"); + return walker; + } + } else { + int i; + + if ( walker->rt_mask.v6 == 0 ) + continue; + olsr_prefix_to_netmask(&tmp_msk, + walker->rt_mask.v6); + for (i = 0; i < 16; i++) { + tmp_ip.v6.s6_addr[i] = + dst->v6.s6_addr[i] & + tmp_msk.v6.s6_addr[i]; + } + if (COMP_IP(&tmp_ip, &walker->rt_dst)) { + olsr_printf(6, "MATCHED\n"); + return walker; + } + } + } + } + return NULL; + } From (spam-protected) Tue Dec 12 12:15:24 2006 From: (spam-protected) (Andreas Tønnesen) Date: Tue, 12 Dec 2006 11:15:24 +0000 Subject: [Olsr-cvs] olsrd-current/src net_olsr.c,1.7.2.1,1.7.2.2 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17785/src Modified Files: Tag: olsrd_04 net_olsr.c Log Message: Added FreeBSD IPv6 patches from John Hay Index: net_olsr.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/net_olsr.c,v retrieving revision 1.7.2.1 retrieving revision 1.7.2.2 diff -C2 -d -r1.7.2.1 -r1.7.2.2 *** net_olsr.c 16 Nov 2006 23:08:39 -0000 1.7.2.1 --- net_olsr.c 12 Dec 2006 11:15:21 -0000 1.7.2.2 *************** *** 497,501 **** for(;p > 0; p -= 8) { ! adr->v6.s6_addr[i] = (p < 8) ? 0xff ^ (0xff << p) : 0xff; i++; } --- 497,501 ---- for(;p > 0; p -= 8) { ! adr->v6.s6_addr[i] = (p < 8) ? 0xff ^ (0xff >> p) : 0xff; i++; } *************** *** 535,539 **** for(tmp = adr->v6.s6_addr[i]; tmp > 0; ! tmp = tmp >> 1) prefix++; } --- 535,539 ---- for(tmp = adr->v6.s6_addr[i]; tmp > 0; ! tmp = (tmp << 1) & 0xff) prefix++; } From (spam-protected) Tue Dec 12 12:15:24 2006 From: (spam-protected) (Andreas Tønnesen) Date: Tue, 12 Dec 2006 11:15:24 +0000 Subject: [Olsr-cvs] olsrd-current/src/bsd kernel_routes.c, 1.6, 1.6.2.1 net.c, 1.26.2.1, 1.26.2.2 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src/bsd In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17785/src/bsd Modified Files: Tag: olsrd_04 kernel_routes.c net.c Log Message: Added FreeBSD IPv6 patches from John Hay Index: net.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/bsd/net.c,v retrieving revision 1.26.2.1 retrieving revision 1.26.2.2 diff -C2 -d -r1.26.2.1 -r1.26.2.2 *** net.c 5 Nov 2006 23:03:26 -0000 1.26.2.1 --- net.c 12 Dec 2006 11:15:22 -0000 1.26.2.2 *************** *** 62,67 **** --- 62,69 ---- #ifdef __FreeBSD__ + #include #include #include + #include #ifndef FBSD_NO_80211 #include *************** *** 72,77 **** #endif - #ifdef SPOOF #include #include #endif /* SPOOF */ --- 74,79 ---- #endif #include + #ifdef SPOOF #include #endif /* SPOOF */ *************** *** 173,176 **** --- 175,189 ---- ignore_redir = set_sysctl_int(name, 0); + #elif defined __FreeBSD__ + if (olsr_cnf->ip_version == AF_INET) + { + name = "net.inet.icmp.drop_redirect"; + ignore_redir = set_sysctl_int(name, 1); + } + else + { + name = "net.inet6.icmp6.rediraccept"; + ignore_redir = set_sysctl_int(name, 0); + } #else if (olsr_cnf->ip_version == AF_INET) *************** *** 244,247 **** --- 257,266 ---- name = "net.inet6.icmp6.rediraccept"; + #elif defined __FreeBSD__ + if (olsr_cnf->ip_version == AF_INET) + name = "net.inet.icmp.drop_redirect"; + + else + name = "net.inet6.icmp6.rediraccept"; #else if (olsr_cnf->ip_version == AF_INET) *************** *** 339,343 **** } - #ifdef SPOOF if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &on, sizeof(on)) < 0) { --- 358,361 ---- *************** *** 353,357 **** return (-1); } - #endif /* SPOOF */ for (on = bufspace; ; on -= 1024) --- 371,374 ---- *************** *** 413,416 **** --- 430,445 ---- } + if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &on, sizeof(on)) < 0) + { + perror("SO_REUSEPORT failed"); + return (-1); + } + + if (setsockopt(sock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on, sizeof(on)) < 0) + { + perror("IPV6_RECVPKTINFO failed"); + return (-1); + } + if (bind(sock, (struct sockaddr *)sin, sizeof (*sin)) < 0) { *************** *** 432,436 **** join_mcast(struct interface *ifs, int sock) { ! /* See linux/in6.h */ struct ipv6_mreq mcastreq; --- 461,465 ---- join_mcast(struct interface *ifs, int sock) { ! /* See netinet6/in6.h */ struct ipv6_mreq mcastreq; *************** *** 439,460 **** mcastreq.ipv6mr_interface = ifs->if_index; - #if 0 OLSR_PRINTF(3, "Interface %s joining multicast %s...", ifs->int_name, olsr_ip_to_string((union olsr_ip_addr *)&ifs->int6_multaddr.sin6_addr)) - /* Send multicast */ - if(setsockopt(sock, - IPPROTO_IPV6, - IPV6_ADD_MEMBERSHIP, - (char *)&mcastreq, - sizeof(struct ipv6_mreq)) - < 0) - { - perror("Join multicast"); - return -1; - } - #else - #warning implement IPV6_ADD_MEMBERSHIP - #endif ! /* Old libc fix */ #ifdef IPV6_JOIN_GROUP /* Join reciever group */ --- 468,474 ---- mcastreq.ipv6mr_interface = ifs->if_index; OLSR_PRINTF(3, "Interface %s joining multicast %s...", ifs->int_name, olsr_ip_to_string((union olsr_ip_addr *)&ifs->int6_multaddr.sin6_addr)) ! /* rfc 3493 */ #ifdef IPV6_JOIN_GROUP /* Join reciever group */ *************** *** 465,470 **** sizeof(struct ipv6_mreq)) < 0) ! #else ! /* Join reciever group */ if(setsockopt(sock, IPPROTO_IPV6, --- 479,484 ---- sizeof(struct ipv6_mreq)) < 0) ! #else /* rfc 2133, obsoleted */ ! /* Join receiver group */ if(setsockopt(sock, IPPROTO_IPV6, *************** *** 501,504 **** --- 515,582 ---- int get_ipv6_address(char *ifname, struct sockaddr_in6 *saddr6, int scope_in) { + struct ifaddrs *ifap, *ifa; + const struct sockaddr_in6 *sin6 = NULL; + struct in6_ifreq ifr6; + int found = 0; + int s6; + u_int32_t flags6; + + if (getifaddrs(&ifap) != 0) + { + OLSR_PRINTF(3, "get_ipv6_address: getifaddrs() failed.\n") + return 0; + } + + for (ifa = ifap; ifa; ifa = ifa->ifa_next) + { + if (ifa->ifa_addr->sa_family == AF_INET6 && + strcmp(ifa->ifa_name, ifname) == 0) + { + sin6 = (const struct sockaddr_in6 *)ifa->ifa_addr; + if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) + continue; + strncpy(ifr6.ifr_name, ifname, sizeof(ifname)); + if ((s6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) + { + OLSR_PRINTF(3, "socket(AF_INET6,SOCK_DGRAM)"); + break; + } + ifr6.ifr_addr = *sin6; + if (ioctl(s6, SIOCGIFAFLAG_IN6, &ifr6) < 0) + { + OLSR_PRINTF(3, "ioctl(SIOCGIFAFLAG_IN6)"); + close(s6); + break; + } + close(s6); + flags6 = ifr6.ifr_ifru.ifru_flags6; + if ((flags6 & IN6_IFF_ANYCAST) != 0) + continue; + if (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)) + { + if (scope_in) + { + memcpy(&saddr6->sin6_addr, &sin6->sin6_addr, + sizeof(struct in6_addr)); + found = 1; + break; + } + } + else + { + if (scope_in == 0) + { + memcpy(&saddr6->sin6_addr, &sin6->sin6_addr, + sizeof(struct in6_addr)); + found = 1; + break; + } + } + } + } + freeifaddrs(ifap); + if (found) + return 1; + return 0; } *************** *** 628,632 **** socklen_t *fromlen) { - #if SPOOF struct msghdr mhdr; struct iovec iov; --- 706,709 ---- *************** *** 634,641 **** struct sockaddr_dl *sdl; struct sockaddr_in *sin = (struct sockaddr_in *) from; //XXX unsigned char chdr[4096]; int count; - struct interface *ifc; - char iname[32]; bzero(&mhdr, sizeof(mhdr)); --- 711,722 ---- struct sockaddr_dl *sdl; struct sockaddr_in *sin = (struct sockaddr_in *) from; //XXX + struct sockaddr_in6 *sin6; + struct in6_addr *iaddr6; + struct in6_pktinfo *pkti; + struct interface *ifc; + char addrstr[INET6_ADDRSTRLEN]; + char iname[IFNAMSIZ]; unsigned char chdr[4096]; int count; bzero(&mhdr, sizeof(mhdr)); *************** *** 660,671 **** /* this needs to get communicated back to caller */ *fromlen = mhdr.msg_namelen; ! ! cm = (struct cmsghdr *) chdr; ! sdl = (struct sockaddr_dl *) CMSG_DATA (cm); ! bzero (iname, sizeof (iname)); ! memcpy (iname, sdl->sdl_data, sdl->sdl_nlen); ifc = if_ifwithsock (s); if (strcmp (ifc->int_name, iname) != 0) { --- 741,777 ---- /* this needs to get communicated back to caller */ *fromlen = mhdr.msg_namelen; ! if (olsr_cnf->ip_version == AF_INET6) ! { ! for (cm = (struct cmsghdr *)CMSG_FIRSTHDR(&mhdr); cm; ! cm = (struct cmsghdr *)CMSG_NXTHDR(&mhdr, cm)) ! { ! if (cm->cmsg_level == IPPROTO_IPV6 && cm->cmsg_type == IPV6_PKTINFO) ! { ! pkti = (struct in6_pktinfo *) CMSG_DATA(cm); ! iaddr6 = &pkti->ipi6_addr; ! if_indextoname(pkti->ipi6_ifindex, iname); ! } ! } ! } ! else ! { ! cm = (struct cmsghdr *) chdr; ! sdl = (struct sockaddr_dl *) CMSG_DATA (cm); ! bzero (iname, sizeof (iname)); ! memcpy (iname, sdl->sdl_data, sdl->sdl_nlen); ! } ifc = if_ifwithsock (s); + sin6 = (struct sockaddr_in6 *)from; + OLSR_PRINTF (4, "%d bytes from %s, socket associated %s really received on %s\n", + count, + (olsr_cnf->ip_version == AF_INET6) ? + inet_ntop(AF_INET6, (char *)&sin6->sin6_addr, addrstr, + INET6_ADDRSTRLEN): + inet_ntoa (sin->sin_addr), + ifc->int_name, + iname); + if (strcmp (ifc->int_name, iname) != 0) { *************** *** 673,692 **** } - OLSR_PRINTF (2, "%d bytes from %s, socket associated %s really received on %s\n", - count, - inet_ntoa (sin->sin_addr), - ifc->int_name, - iname); - return (count); - - #else /* SPOOF */ - return recvfrom(s, - buf, - len, - 0, - from, - fromlen); - #endif /* SPOOF */ } --- 779,783 ---- Index: kernel_routes.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/bsd/kernel_routes.c,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -C2 -d -r1.6 -r1.6.2.1 *** kernel_routes.c 27 Feb 2005 10:43:38 -0000 1.6 --- kernel_routes.c 12 Dec 2006 11:15:22 -0000 1.6.2.1 *************** *** 171,181 **** } ! int olsr_ioctl_add_route6(struct rt_entry *dest) { return 0; } int olsr_ioctl_del_route6(struct rt_entry *dest) { ! return 0; } --- 171,272 ---- } ! static int add_del_route6(struct rt_entry *dest, int add) { + struct rt_msghdr *rtm; + unsigned char buff[512]; + unsigned char *walker; + struct sockaddr_in6 sin6; + struct sockaddr_dl sdl; + int step, step_dl; + int len; + char Str1[40], Str2[40]; + + inet_ntop(AF_INET6, &dest->rt_dst.v6, Str1, 40); + inet_ntop(AF_INET6, &dest->rt_router.v6, Str2, 40); + + OLSR_PRINTF(1, "%s IPv6 route to %s/%d via %s.\n", + (add != 0) ? "Adding" : "Removing", Str1, dest->rt_mask.v6, Str2) + + memset(buff, 0, sizeof (buff)); + memset(&sin6, 0, sizeof (sin6)); + memset(&sdl, 0, sizeof (sdl)); + + sin6.sin6_len = sizeof (sin6); + sin6.sin6_family = AF_INET6; + sdl.sdl_len = sizeof (sdl); + sdl.sdl_family = AF_LINK; + + step = 1 + ((sizeof (struct sockaddr_in6) - 1) | 3); + step_dl = 1 + ((sizeof (struct sockaddr_dl) - 1) | 3); + + rtm = (struct rt_msghdr *)buff; + rtm->rtm_version = RTM_VERSION; + rtm->rtm_type = (add != 0) ? RTM_ADD : RTM_DELETE; + rtm->rtm_index = 0; + rtm->rtm_flags = dest->rt_flags; + rtm->rtm_addrs = RTA_DST | RTA_GATEWAY; + rtm->rtm_seq = ++seq; + + walker = buff + sizeof (struct rt_msghdr); + + memcpy(&sin6.sin6_addr.s6_addr, &dest->rt_dst.v6, sizeof(struct in6_addr)); + + memcpy(walker, &sin6, sizeof (sin6)); + walker += step; + + if ((rtm->rtm_flags & RTF_GATEWAY) != 0) + { + memcpy(&sin6.sin6_addr.s6_addr, &dest->rt_router.v6, sizeof(struct in6_addr)); + + memcpy(walker, &sin6, sizeof (sin6)); + walker += step; + } + + // the host is directly reachable, so add the output interface's address + + else + { + memcpy(&sin6.sin6_addr.s6_addr, &dest->rt_if->int6_addr.sin6_addr.s6_addr, + sizeof(struct in6_addr)); + + memcpy(walker, &sin6, sizeof (sin6)); + walker += step; + rtm->rtm_flags |= RTF_LLINFO; + } + + if ((rtm->rtm_flags & RTF_HOST) == 0) + { + olsr_prefix_to_netmask((union olsr_ip_addr *)&sin6.sin6_addr, dest->rt_mask.v6); + memcpy(walker, &sin6, sizeof (sin6)); + walker += step; + rtm->rtm_addrs |= RTA_NETMASK; + } + + if ((rtm->rtm_flags & RTF_GATEWAY) != 0) + { + strcpy(&sdl.sdl_data[0], dest->rt_if->int_name); + sdl.sdl_nlen = (u_char)strlen(dest->rt_if->int_name); + memcpy(walker, &sdl, sizeof (sdl)); + walker += step_dl; + rtm->rtm_addrs |= RTA_IFP; + } + + rtm->rtm_msglen = (unsigned short)(walker - buff); + + len = write(rts, buff, rtm->rtm_msglen); + + if (len < rtm->rtm_msglen) + fprintf(stderr, "cannot write to routing socket: %s\n", strerror(errno)); + return 0; } + int olsr_ioctl_add_route6(struct rt_entry *dest) + { + return add_del_route6(dest, 1); + } + int olsr_ioctl_del_route6(struct rt_entry *dest) { ! return add_del_route6(dest, 0); } From (spam-protected) Tue Dec 12 12:20:55 2006 From: (spam-protected) (Andreas Tønnesen) Date: Tue, 12 Dec 2006 11:20:55 +0000 Subject: [Olsr-cvs] olsrd-current/src/bsd kernel_routes.c, 1.7, 1.8 net.c, 1.28, 1.29 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src/bsd In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv19797/src/bsd Modified Files: kernel_routes.c net.c Log Message: Added FreeBSD IPv6 patches from John Hay Index: net.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/bsd/net.c,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** net.c 5 Nov 2006 23:03:56 -0000 1.28 --- net.c 12 Dec 2006 11:20:53 -0000 1.29 *************** *** 62,67 **** --- 62,69 ---- #ifdef __FreeBSD__ + #include #include #include + #include #ifndef FBSD_NO_80211 #include *************** *** 72,77 **** #endif - #ifdef SPOOF #include #include #endif /* SPOOF */ --- 74,79 ---- #endif #include + #ifdef SPOOF #include #endif /* SPOOF */ *************** *** 173,176 **** --- 175,189 ---- ignore_redir = set_sysctl_int(name, 0); + #elif defined __FreeBSD__ + if (olsr_cnf->ip_version == AF_INET) + { + name = "net.inet.icmp.drop_redirect"; + ignore_redir = set_sysctl_int(name, 1); + } + else + { + name = "net.inet6.icmp6.rediraccept"; + ignore_redir = set_sysctl_int(name, 0); + } #else if (olsr_cnf->ip_version == AF_INET) *************** *** 244,247 **** --- 257,266 ---- name = "net.inet6.icmp6.rediraccept"; + #elif defined __FreeBSD__ + if (olsr_cnf->ip_version == AF_INET) + name = "net.inet.icmp.drop_redirect"; + + else + name = "net.inet6.icmp6.rediraccept"; #else if (olsr_cnf->ip_version == AF_INET) *************** *** 339,343 **** } - #ifdef SPOOF if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &on, sizeof(on)) < 0) { --- 358,361 ---- *************** *** 353,357 **** return (-1); } - #endif /* SPOOF */ for (on = bufspace; ; on -= 1024) --- 371,374 ---- *************** *** 413,416 **** --- 430,445 ---- } + if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &on, sizeof(on)) < 0) + { + perror("SO_REUSEPORT failed"); + return (-1); + } + + if (setsockopt(sock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on, sizeof(on)) < 0) + { + perror("IPV6_RECVPKTINFO failed"); + return (-1); + } + if (bind(sock, (struct sockaddr *)sin, sizeof (*sin)) < 0) { *************** *** 432,436 **** join_mcast(struct interface *ifs, int sock) { ! /* See linux/in6.h */ struct ipv6_mreq mcastreq; --- 461,465 ---- join_mcast(struct interface *ifs, int sock) { ! /* See netinet6/in6.h */ struct ipv6_mreq mcastreq; *************** *** 439,460 **** mcastreq.ipv6mr_interface = ifs->if_index; - #if 0 OLSR_PRINTF(3, "Interface %s joining multicast %s...", ifs->int_name, olsr_ip_to_string((union olsr_ip_addr *)&ifs->int6_multaddr.sin6_addr)) - /* Send multicast */ - if(setsockopt(sock, - IPPROTO_IPV6, - IPV6_ADD_MEMBERSHIP, - (char *)&mcastreq, - sizeof(struct ipv6_mreq)) - < 0) - { - perror("Join multicast"); - return -1; - } - #else - #warning implement IPV6_ADD_MEMBERSHIP - #endif ! /* Old libc fix */ #ifdef IPV6_JOIN_GROUP /* Join reciever group */ --- 468,474 ---- mcastreq.ipv6mr_interface = ifs->if_index; OLSR_PRINTF(3, "Interface %s joining multicast %s...", ifs->int_name, olsr_ip_to_string((union olsr_ip_addr *)&ifs->int6_multaddr.sin6_addr)) ! /* rfc 3493 */ #ifdef IPV6_JOIN_GROUP /* Join reciever group */ *************** *** 465,470 **** sizeof(struct ipv6_mreq)) < 0) ! #else ! /* Join reciever group */ if(setsockopt(sock, IPPROTO_IPV6, --- 479,484 ---- sizeof(struct ipv6_mreq)) < 0) ! #else /* rfc 2133, obsoleted */ ! /* Join receiver group */ if(setsockopt(sock, IPPROTO_IPV6, *************** *** 501,504 **** --- 515,582 ---- int get_ipv6_address(char *ifname, struct sockaddr_in6 *saddr6, int scope_in) { + struct ifaddrs *ifap, *ifa; + const struct sockaddr_in6 *sin6 = NULL; + struct in6_ifreq ifr6; + int found = 0; + int s6; + u_int32_t flags6; + + if (getifaddrs(&ifap) != 0) + { + OLSR_PRINTF(3, "get_ipv6_address: getifaddrs() failed.\n") + return 0; + } + + for (ifa = ifap; ifa; ifa = ifa->ifa_next) + { + if (ifa->ifa_addr->sa_family == AF_INET6 && + strcmp(ifa->ifa_name, ifname) == 0) + { + sin6 = (const struct sockaddr_in6 *)ifa->ifa_addr; + if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) + continue; + strncpy(ifr6.ifr_name, ifname, sizeof(ifname)); + if ((s6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) + { + OLSR_PRINTF(3, "socket(AF_INET6,SOCK_DGRAM)"); + break; + } + ifr6.ifr_addr = *sin6; + if (ioctl(s6, SIOCGIFAFLAG_IN6, &ifr6) < 0) + { + OLSR_PRINTF(3, "ioctl(SIOCGIFAFLAG_IN6)"); + close(s6); + break; + } + close(s6); + flags6 = ifr6.ifr_ifru.ifru_flags6; + if ((flags6 & IN6_IFF_ANYCAST) != 0) + continue; + if (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)) + { + if (scope_in) + { + memcpy(&saddr6->sin6_addr, &sin6->sin6_addr, + sizeof(struct in6_addr)); + found = 1; + break; + } + } + else + { + if (scope_in == 0) + { + memcpy(&saddr6->sin6_addr, &sin6->sin6_addr, + sizeof(struct in6_addr)); + found = 1; + break; + } + } + } + } + freeifaddrs(ifap); + if (found) + return 1; + return 0; } *************** *** 628,632 **** socklen_t *fromlen) { - #if SPOOF struct msghdr mhdr; struct iovec iov; --- 706,709 ---- *************** *** 634,641 **** struct sockaddr_dl *sdl; struct sockaddr_in *sin = (struct sockaddr_in *) from; //XXX unsigned char chdr[4096]; int count; - struct interface *ifc; - char iname[32]; bzero(&mhdr, sizeof(mhdr)); --- 711,722 ---- struct sockaddr_dl *sdl; struct sockaddr_in *sin = (struct sockaddr_in *) from; //XXX + struct sockaddr_in6 *sin6; + struct in6_addr *iaddr6; + struct in6_pktinfo *pkti; + struct interface *ifc; + char addrstr[INET6_ADDRSTRLEN]; + char iname[IFNAMSIZ]; unsigned char chdr[4096]; int count; bzero(&mhdr, sizeof(mhdr)); *************** *** 660,671 **** /* this needs to get communicated back to caller */ *fromlen = mhdr.msg_namelen; ! ! cm = (struct cmsghdr *) chdr; ! sdl = (struct sockaddr_dl *) CMSG_DATA (cm); ! bzero (iname, sizeof (iname)); ! memcpy (iname, sdl->sdl_data, sdl->sdl_nlen); ifc = if_ifwithsock (s); if (strcmp (ifc->int_name, iname) != 0) { --- 741,777 ---- /* this needs to get communicated back to caller */ *fromlen = mhdr.msg_namelen; ! if (olsr_cnf->ip_version == AF_INET6) ! { ! for (cm = (struct cmsghdr *)CMSG_FIRSTHDR(&mhdr); cm; ! cm = (struct cmsghdr *)CMSG_NXTHDR(&mhdr, cm)) ! { ! if (cm->cmsg_level == IPPROTO_IPV6 && cm->cmsg_type == IPV6_PKTINFO) ! { ! pkti = (struct in6_pktinfo *) CMSG_DATA(cm); ! iaddr6 = &pkti->ipi6_addr; ! if_indextoname(pkti->ipi6_ifindex, iname); ! } ! } ! } ! else ! { ! cm = (struct cmsghdr *) chdr; ! sdl = (struct sockaddr_dl *) CMSG_DATA (cm); ! bzero (iname, sizeof (iname)); ! memcpy (iname, sdl->sdl_data, sdl->sdl_nlen); ! } ifc = if_ifwithsock (s); + sin6 = (struct sockaddr_in6 *)from; + OLSR_PRINTF (4, "%d bytes from %s, socket associated %s really received on %s\n", + count, + (olsr_cnf->ip_version == AF_INET6) ? + inet_ntop(AF_INET6, (char *)&sin6->sin6_addr, addrstr, + INET6_ADDRSTRLEN): + inet_ntoa (sin->sin_addr), + ifc->int_name, + iname); + if (strcmp (ifc->int_name, iname) != 0) { *************** *** 673,692 **** } - OLSR_PRINTF (2, "%d bytes from %s, socket associated %s really received on %s\n", - count, - inet_ntoa (sin->sin_addr), - ifc->int_name, - iname); - return (count); - - #else /* SPOOF */ - return recvfrom(s, - buf, - len, - 0, - from, - fromlen); - #endif /* SPOOF */ } --- 779,783 ---- Index: kernel_routes.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/bsd/kernel_routes.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** kernel_routes.c 7 Jan 2006 08:16:22 -0000 1.7 --- kernel_routes.c 12 Dec 2006 11:20:53 -0000 1.8 *************** *** 171,181 **** } ! int olsr_ioctl_add_route6(struct rt_entry *dest) { return 0; } int olsr_ioctl_del_route6(struct rt_entry *dest) { ! return 0; } --- 171,272 ---- } ! static int add_del_route6(struct rt_entry *dest, int add) { + struct rt_msghdr *rtm; + unsigned char buff[512]; + unsigned char *walker; + struct sockaddr_in6 sin6; + struct sockaddr_dl sdl; + int step, step_dl; + int len; + char Str1[40], Str2[40]; + + inet_ntop(AF_INET6, &dest->rt_dst.v6, Str1, 40); + inet_ntop(AF_INET6, &dest->rt_router.v6, Str2, 40); + + OLSR_PRINTF(1, "%s IPv6 route to %s/%d via %s.\n", + (add != 0) ? "Adding" : "Removing", Str1, dest->rt_mask.v6, Str2) + + memset(buff, 0, sizeof (buff)); + memset(&sin6, 0, sizeof (sin6)); + memset(&sdl, 0, sizeof (sdl)); + + sin6.sin6_len = sizeof (sin6); + sin6.sin6_family = AF_INET6; + sdl.sdl_len = sizeof (sdl); + sdl.sdl_family = AF_LINK; + + step = 1 + ((sizeof (struct sockaddr_in6) - 1) | 3); + step_dl = 1 + ((sizeof (struct sockaddr_dl) - 1) | 3); + + rtm = (struct rt_msghdr *)buff; + rtm->rtm_version = RTM_VERSION; + rtm->rtm_type = (add != 0) ? RTM_ADD : RTM_DELETE; + rtm->rtm_index = 0; + rtm->rtm_flags = dest->rt_flags; + rtm->rtm_addrs = RTA_DST | RTA_GATEWAY; + rtm->rtm_seq = ++seq; + + walker = buff + sizeof (struct rt_msghdr); + + memcpy(&sin6.sin6_addr.s6_addr, &dest->rt_dst.v6, sizeof(struct in6_addr)); + + memcpy(walker, &sin6, sizeof (sin6)); + walker += step; + + if ((rtm->rtm_flags & RTF_GATEWAY) != 0) + { + memcpy(&sin6.sin6_addr.s6_addr, &dest->rt_router.v6, sizeof(struct in6_addr)); + + memcpy(walker, &sin6, sizeof (sin6)); + walker += step; + } + + // the host is directly reachable, so add the output interface's address + + else + { + memcpy(&sin6.sin6_addr.s6_addr, &dest->rt_if->int6_addr.sin6_addr.s6_addr, + sizeof(struct in6_addr)); + + memcpy(walker, &sin6, sizeof (sin6)); + walker += step; + rtm->rtm_flags |= RTF_LLINFO; + } + + if ((rtm->rtm_flags & RTF_HOST) == 0) + { + olsr_prefix_to_netmask((union olsr_ip_addr *)&sin6.sin6_addr, dest->rt_mask.v6); + memcpy(walker, &sin6, sizeof (sin6)); + walker += step; + rtm->rtm_addrs |= RTA_NETMASK; + } + + if ((rtm->rtm_flags & RTF_GATEWAY) != 0) + { + strcpy(&sdl.sdl_data[0], dest->rt_if->int_name); + sdl.sdl_nlen = (u_char)strlen(dest->rt_if->int_name); + memcpy(walker, &sdl, sizeof (sdl)); + walker += step_dl; + rtm->rtm_addrs |= RTA_IFP; + } + + rtm->rtm_msglen = (unsigned short)(walker - buff); + + len = write(rts, buff, rtm->rtm_msglen); + + if (len < rtm->rtm_msglen) + fprintf(stderr, "cannot write to routing socket: %s\n", strerror(errno)); + return 0; } + int olsr_ioctl_add_route6(struct rt_entry *dest) + { + return add_del_route6(dest, 1); + } + int olsr_ioctl_del_route6(struct rt_entry *dest) { ! return add_del_route6(dest, 0); } From (spam-protected) Tue Dec 12 12:22:17 2006 From: (spam-protected) (Andreas Tønnesen) Date: Tue, 12 Dec 2006 11:22:17 +0000 Subject: [Olsr-cvs] olsrd-current/src/cfgparser cfgfile_gen.c, 1.3, 1.4 oparse.y, 1.29, 1.30 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src/cfgparser In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv20560/src/cfgparser Modified Files: cfgfile_gen.c oparse.y Log Message: Committing some extended debug output Index: cfgfile_gen.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/cfgparser/cfgfile_gen.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** cfgfile_gen.c 17 Apr 2006 18:31:09 -0000 1.3 --- cfgfile_gen.c 12 Dec 2006 11:22:15 -0000 1.4 *************** *** 369,372 **** --- 369,373 ---- struct in_addr in4; + printf("\n\n\n\nolsrd_write_cnf_buf bufsize %d\n\n\n\n\n", bufsize); if(buf == NULL || bufsize < MAX_LINESIZE) { Index: oparse.y =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/cfgparser/oparse.y,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** oparse.y 17 Apr 2006 18:31:09 -0000 1.29 --- oparse.y 12 Dec 2006 11:22:15 -0000 1.30 *************** *** 390,394 **** if(inet_aton($2->string, &in) == 0) { ! fprintf(stderr, "Failed converting IP address %s\n", $2->string); return -1; } --- 390,394 ---- if(inet_aton($2->string, &in) == 0) { ! fprintf(stderr, "isetip4br: Failed converting IP address %s\n", $2->string); return -1; } *************** *** 447,451 **** if(inet_pton(AF_INET6, $2->string, &in6) < 0) { ! fprintf(stderr, "Failed converting IP address %s\n", $2->string); return -1; } --- 447,451 ---- if(inet_pton(AF_INET6, $2->string, &in6) < 0) { ! fprintf(stderr, "isetip6mults: Failed converting IP address %s\n", $2->string); return -1; } *************** *** 476,480 **** if(inet_pton(AF_INET6, $2->string, &in6) < 0) { ! fprintf(stderr, "Failed converting IP address %s\n", $2->string); return -1; } --- 476,480 ---- if(inet_pton(AF_INET6, $2->string, &in6) < 0) { ! fprintf(stderr, "isetip6multg: Failed converting IP address %s\n", $2->string); return -1; } *************** *** 713,717 **** if(inet_aton($1->string, &in) == 0) { ! fprintf(stderr, "Failed converting IP address %s\n", $1->string); return -1; } --- 713,717 ---- if(inet_aton($1->string, &in) == 0) { ! fprintf(stderr, "ihna4entry: Failed converting IP address %s\n", $1->string); return -1; } *************** *** 719,723 **** if(inet_aton($2->string, &in) == 0) { ! fprintf(stderr, "Failed converting IP address %s\n", $1->string); return -1; } --- 719,723 ---- if(inet_aton($2->string, &in) == 0) { ! fprintf(stderr, "ihna4entry: Failed converting IP address %s\n", $1->string); return -1; } *************** *** 750,754 **** if(inet_pton(AF_INET6, $1->string, &in6) < 0) { ! fprintf(stderr, "Failed converting IP address %s\n", $1->string); return -1; } --- 750,754 ---- if(inet_pton(AF_INET6, $1->string, &in6) < 0) { ! fprintf(stderr, "ihna6entry: Failed converting IP address %s\n", $1->string); return -1; } *************** *** 757,761 **** if(($2->integer < 0) || ($2->integer > 128)) { ! fprintf(stderr, "Illegal IPv6 prefix length %d\n", $2->integer); return -1; } --- 757,761 ---- if(($2->integer < 0) || ($2->integer > 128)) { ! fprintf(stderr, "ihna6entry: Illegal IPv6 prefix length %d\n", $2->integer); return -1; } From (spam-protected) Tue Dec 12 12:26:03 2006 From: (spam-protected) (Andreas Tønnesen) Date: Tue, 12 Dec 2006 11:26:03 +0000 Subject: [Olsr-cvs] olsrd-current CHANGELOG,1.55,1.56 Message-ID: Update of /cvsroot/olsrd/olsrd-current In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv21830 Modified Files: CHANGELOG Log Message: Bah... the CHANGELOG file is out of synch. Please add any changes you have committed Index: CHANGELOG =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/CHANGELOG,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** CHANGELOG 4 Jan 2006 09:08:08 -0000 1.55 --- CHANGELOG 12 Dec 2006 11:26:01 -0000 1.56 *************** *** 2,5 **** --- 2,13 ---- $Id$ + 0.4.11 -------------------------------------------------------------------- + + FreeBSD IPv6 SUPPORT + + Patch from John Hay applied. + + BUGFIXES + 0.4.10 -------------------------------------------------------------------- From (spam-protected) Tue Dec 12 12:26:31 2006 From: (spam-protected) (Andreas Tønnesen) Date: Tue, 12 Dec 2006 11:26:31 +0000 Subject: [Olsr-cvs] olsrd-current CHANGELOG,1.55,1.55.2.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv22204 Modified Files: Tag: olsrd_04 CHANGELOG Log Message: Bah... the CHANGELOG file is out of synch. Please add any changes you have committed Index: CHANGELOG =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/CHANGELOG,v retrieving revision 1.55 retrieving revision 1.55.2.1 diff -C2 -d -r1.55 -r1.55.2.1 *** CHANGELOG 4 Jan 2006 09:08:08 -0000 1.55 --- CHANGELOG 12 Dec 2006 11:26:29 -0000 1.55.2.1 *************** *** 2,5 **** --- 2,13 ---- $Id$ + 0.4.11 -------------------------------------------------------------------- + + FreeBSD IPv6 SUPPORT + + Patch from John Hay applied. + + BUGFIXES + 0.4.10 -------------------------------------------------------------------- From (spam-protected) Thu Dec 14 00:06:25 2006 From: (spam-protected) (Bernd Petrovitsch) Date: Wed, 13 Dec 2006 23:06:25 +0000 Subject: [Olsr-cvs] olsrd-current CHANGELOG,1.56,1.57 Message-ID: Update of /cvsroot/olsrd/olsrd-current In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv13968 Modified Files: CHANGELOG Log Message: * added 2 items Index: CHANGELOG =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/CHANGELOG,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** CHANGELOG 12 Dec 2006 11:26:01 -0000 1.56 --- CHANGELOG 13 Dec 2006 23:06:23 -0000 1.57 *************** *** 75,78 **** --- 75,80 ---- - Fixed bug(s) that could cause crash when an interface was brought down while olsrd was running. + - Removed the silent (read: unchecked) hard limit of 16 interfaces. + - Compiles now cleanly on 64bit (e.g. x86_64). 0.4.9 --------------------------------------------------------------------- From (spam-protected) Thu Dec 14 00:22:02 2006 From: (spam-protected) (Bernd Petrovitsch) Date: Wed, 13 Dec 2006 23:22:02 +0000 Subject: [Olsr-cvs] olsrd-current CHANGELOG,1.55.2.1,1.55.2.2 Message-ID: Update of /cvsroot/olsrd/olsrd-current In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv20041 Modified Files: Tag: olsrd_04 CHANGELOG Log Message: * added 2 items Index: CHANGELOG =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/CHANGELOG,v retrieving revision 1.55.2.1 retrieving revision 1.55.2.2 diff -C2 -d -r1.55.2.1 -r1.55.2.2 *** CHANGELOG 12 Dec 2006 11:26:29 -0000 1.55.2.1 --- CHANGELOG 13 Dec 2006 23:22:00 -0000 1.55.2.2 *************** *** 75,78 **** --- 75,80 ---- - Fixed bug(s) that could cause crash when an interface was brought down while olsrd was running. + - Removed the silent (read: unchecked) hard limit of 16 interfaces. + - Compiles now cleanly on 64bit (e.g. x86_64). 0.4.9 --------------------------------------------------------------------- From (spam-protected) Thu Dec 14 12:25:31 2006 From: (spam-protected) (Bernd Petrovitsch) Date: Thu, 14 Dec 2006 11:25:31 +0000 Subject: [Olsr-cvs] olsrd-current/src build_msg.c, 1.31, 1.31.2.1 hysteresis.c, 1.16, 1.16.2.1 hysteresis.h, 1.7, 1.7.2.1 link_set.c, 1.62, 1.62.2.1 link_set.h, 1.28, 1.28.2.1 lq_route.c, 1.40, 1.40.2.1 mid_set.c, 1.15, 1.15.2.1 parser.c, 1.29, 1.29.2.1 process_routes.c, 1.27.2.1, 1.27.2.2 routing_table.c, 1.23, 1.23.2.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv31920/src Modified Files: Tag: olsrd_04 build_msg.c hysteresis.c hysteresis.h link_set.c link_set.h lq_route.c mid_set.c parser.c process_routes.c routing_table.c Log Message: * applied patches from Sebastian Hagen Index: lq_route.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/lq_route.c,v retrieving revision 1.40 retrieving revision 1.40.2.1 diff -C2 -d -r1.40 -r1.40.2.1 *** lq_route.c 29 Nov 2005 18:37:58 -0000 1.40 --- lq_route.c 14 Dec 2006 11:25:29 -0000 1.40.2.1 *************** *** 563,568 **** { // find the interface for the found link ! ! inter = if_ifwithaddr(&link->local_iface_addr); // we may see NULL here if the interface is down, but we have --- 563,568 ---- { // find the interface for the found link ! inter = link->if_name ? if_ifwithname(link->if_name) : ! if_ifwithaddr(&link->local_iface_addr); // we may see NULL here if the interface is down, but we have Index: hysteresis.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/hysteresis.h,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -C2 -d -r1.7 -r1.7.2.1 *** hysteresis.h 6 Mar 2005 19:33:35 -0000 1.7 --- hysteresis.h 14 Dec 2006 11:25:29 -0000 1.7.2.1 *************** *** 61,65 **** void ! update_hysteresis_incoming(union olsr_ip_addr *, union olsr_ip_addr *, olsr_u16_t); #endif --- 61,65 ---- void ! update_hysteresis_incoming(union olsr_ip_addr *, struct interface *, olsr_u16_t); #endif Index: mid_set.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/mid_set.c,v retrieving revision 1.15 retrieving revision 1.15.2.1 diff -C2 -d -r1.15 -r1.15.2.1 *** mid_set.c 29 May 2005 12:47:45 -0000 1.15 --- mid_set.c 14 Dec 2006 11:25:29 -0000 1.15.2.1 *************** *** 52,55 **** --- 52,56 ---- struct mid_address reverse_mid_set[HASHSIZE]; + struct mid_entry *mid_lookup_entry_bymain(union olsr_ip_addr *adr); /** *************** *** 205,208 **** --- 206,212 ---- { struct mid_address *adr; + struct neighbor_entry *ne_old, *ne_new; + struct mid_entry *me_old; + int ne_ref_rp_count; adr = olsr_malloc(sizeof(struct mid_address), "Insert MID alias"); *************** *** 214,217 **** --- 218,243 ---- adr->next_alias = NULL; + // If we have an entry for this alias in neighbortable, we better adjust it's + // main address, because otherwise a fatal inconsistency between + // neighbortable and link_set will be created by way of this mid entry. + ne_old = olsr_lookup_neighbor_table_alias(alias); + if (ne_old != NULL) { + OLSR_PRINTF(2, "Remote main address change detected. Mangling neighbortable to replace %s with %s.\n", olsr_ip_to_string(alias), olsr_ip_to_string(main_add)); + olsr_delete_neighbor_table(alias); + ne_new = olsr_insert_neighbor_table(main_add); + // adjust pointers to neighbortable-entry in link_set + ne_ref_rp_count = replace_neighbor_link_set(ne_old, ne_new); + if (ne_ref_rp_count > 0) + OLSR_PRINTF(2, "Performed %d neighbortable-pointer replacements (%p -> %p) in link_set.\n", ne_ref_rp_count, ne_old, ne_new); + + me_old = mid_lookup_entry_bymain(alias); + if (me_old) { + // we knew aliases to the previous main address; better forget about + // them now. + OLSR_PRINTF(2, "I already have an mid entry mapping addresses to this alias address. Removing existing mid entry to preserve consistency of mid_set.\n"); + mid_delete_node(me_old); + } + } + insert_mid_tuple(main_add, adr, vtime); *************** *** 256,270 **** ! ! ! /* ! *Find all aliases for an address. ! * ! *@param adr the main address to search for * ! *@return a linked list of addresses structs */ ! struct mid_address * ! mid_lookup_aliases(union olsr_ip_addr *adr) { struct mid_entry *tmp_list; --- 282,292 ---- ! /* Find mid entry to an address. ! * @param adr the main address to search for * ! * @return a linked list of address structs */ ! struct mid_entry * ! mid_lookup_entry_bymain(union olsr_ip_addr *adr) { struct mid_entry *tmp_list; *************** *** 281,285 **** { if(COMP_IP(&tmp_list->main_addr, adr)) ! return tmp_list->aliases; } --- 303,307 ---- { if(COMP_IP(&tmp_list->main_addr, adr)) ! return tmp_list; } *************** *** 289,292 **** --- 311,329 ---- + /* + *Find all aliases for an address. + * + *@param adr the main address to search for + * + *@return a linked list of addresses structs + */ + inline struct mid_address * + mid_lookup_aliases(union olsr_ip_addr *adr) + { + struct mid_entry *tmp = mid_lookup_entry_bymain(adr); + return tmp ? tmp->aliases : NULL; + } + + /** *Update the timer for an entry Index: hysteresis.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/hysteresis.c,v retrieving revision 1.16 retrieving revision 1.16.2.1 diff -C2 -d -r1.16 -r1.16.2.1 *** hysteresis.c 27 Feb 2005 10:43:38 -0000 1.16 --- hysteresis.c 14 Dec 2006 11:25:29 -0000 1.16.2.1 *************** *** 163,167 **** void ! update_hysteresis_incoming(union olsr_ip_addr *remote, union olsr_ip_addr *local, olsr_u16_t seqno) { struct link_entry *link; --- 163,167 ---- void ! update_hysteresis_incoming(union olsr_ip_addr *remote, struct interface *local, olsr_u16_t seqno) { struct link_entry *link; Index: process_routes.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/process_routes.c,v retrieving revision 1.27.2.1 retrieving revision 1.27.2.2 diff -C2 -d -r1.27.2.1 -r1.27.2.2 *** process_routes.c 1 Nov 2006 09:21:44 -0000 1.27.2.1 --- process_routes.c 14 Dec 2006 11:25:29 -0000 1.27.2.2 *************** *** 117,122 **** /** ! *Create a list containing the entries in in_table ! *that does not exist in from_table * *@param from_table the table to use --- 117,122 ---- /** ! *Create a list containing the entries in from_table ! *that do not exist in in_table * *@param from_table the table to use Index: parser.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/parser.c,v retrieving revision 1.29 retrieving revision 1.29.2.1 diff -C2 -d -r1.29 -r1.29.2.1 *** parser.c 19 Nov 2005 08:49:44 -0000 1.29 --- parser.c 14 Dec 2006 11:25:29 -0000 1.29.2.1 *************** *** 194,198 **** /* IPv4 */ update_hysteresis_incoming(from_addr, ! &in_if->ip_addr, ntohs(olsr->olsr_seqno)); } --- 194,198 ---- /* IPv4 */ update_hysteresis_incoming(from_addr, ! in_if, ntohs(olsr->olsr_seqno)); } *************** *** 201,205 **** /* IPv6 */ update_hysteresis_incoming(from_addr, ! &in_if->ip_addr, ntohs(olsr->olsr_seqno)); } --- 201,205 ---- /* IPv6 */ update_hysteresis_incoming(from_addr, ! in_if, ntohs(olsr->olsr_seqno)); } *************** *** 208,212 **** if (olsr_cnf->lq_level > 0) { ! olsr_update_packet_loss(from_addr, &in_if->ip_addr, ntohs(olsr->olsr_seqno)); } --- 208,212 ---- if (olsr_cnf->lq_level > 0) { ! olsr_update_packet_loss(from_addr, in_if, ntohs(olsr->olsr_seqno)); } Index: build_msg.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/build_msg.c,v retrieving revision 1.31 retrieving revision 1.31.2.1 diff -C2 -d -r1.31 -r1.31.2.1 *** build_msg.c 10 Nov 2005 19:35:12 -0000 1.31 --- build_msg.c 14 Dec 2006 11:25:28 -0000 1.31.2.1 *************** *** 902,906 **** //printf("Sending MID (%d bytes)...\n", outputsize); ! net_outbuffer_push(ifp, msg_buffer, curr_size); --- 902,907 ---- //printf("Sending MID (%d bytes)...\n", outputsize); ! if(curr_size > OLSR_MID_IPV4_HDRSIZE) ! net_outbuffer_push(ifp, msg_buffer, curr_size); *************** *** 999,1003 **** //printf("Sending MID (%d bytes)...\n", outputsize); ! net_outbuffer_push(ifp, msg_buffer, curr_size); return OLSR_TRUE; --- 1000,1005 ---- //printf("Sending MID (%d bytes)...\n", outputsize); ! if(curr_size > OLSR_MID_IPV6_HDRSIZE) ! net_outbuffer_push(ifp, msg_buffer, curr_size); return OLSR_TRUE; Index: routing_table.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/routing_table.c,v retrieving revision 1.23 retrieving revision 1.23.2.1 diff -C2 -d -r1.23 -r1.23.2.1 *** routing_table.c 16 Nov 2005 23:55:54 -0000 1.23 --- routing_table.c 14 Dec 2006 11:25:29 -0000 1.23.2.1 *************** *** 283,287 **** if(link) { ! struct interface *iface = if_ifwithaddr(&link->local_iface_addr); if(iface) { --- 283,288 ---- if(link) { ! struct interface *iface = link->if_name ? if_ifwithname(link->if_name) : ! if_ifwithaddr(&link->local_iface_addr); if(iface) { *************** *** 397,401 **** if(link) { ! struct interface *iface = if_ifwithaddr(&link->local_iface_addr); if(iface) { --- 398,403 ---- if(link) { ! struct interface *iface = link->if_name ? if_ifwithname(link->if_name) : ! if_ifwithaddr(&link->local_iface_addr); if(iface) { Index: link_set.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/link_set.c,v retrieving revision 1.62 retrieving revision 1.62.2.1 diff -C2 -d -r1.62 -r1.62.2.1 *** link_set.c 17 Nov 2005 04:25:44 -0000 1.62 --- link_set.c 14 Dec 2006 11:25:29 -0000 1.62.2.1 *************** *** 70,74 **** static struct link_entry * ! add_new_entry(union olsr_ip_addr *, union olsr_ip_addr *, union olsr_ip_addr *, double, double); static void --- 70,74 ---- static struct link_entry * ! add_new_entry(union olsr_ip_addr *, union olsr_ip_addr *, union olsr_ip_addr *, double, double, struct interface *); static void *************** *** 203,207 **** //printf("\tChecking %s->", olsr_ip_to_string(&ifs->ip_addr)); //printf("%s : ", olsr_ip_to_string(main_addr)); ! if((link = lookup_link_entry(main_addr, &ifs->ip_addr)) != NULL) { //printf("%d\n", lookup_link_status(link)); --- 203,207 ---- //printf("\tChecking %s->", olsr_ip_to_string(&ifs->ip_addr)); //printf("%s : ", olsr_ip_to_string(main_addr)); ! if((link = lookup_link_entry(main_addr, ifs)) != NULL) { //printf("%d\n", lookup_link_status(link)); *************** *** 216,220 **** //printf("\tChecking %s->", olsr_ip_to_string(&ifs->ip_addr)); //printf("%s : ", olsr_ip_to_string(&aliases->address)); ! if((link = lookup_link_entry(&aliases->alias, &ifs->ip_addr)) != NULL) { //printf("%d\n", lookup_link_status(link)); --- 216,220 ---- //printf("\tChecking %s->", olsr_ip_to_string(&ifs->ip_addr)); //printf("%s : ", olsr_ip_to_string(&aliases->address)); ! if((link = lookup_link_entry(&aliases->alias, ifs)) != NULL) { //printf("%d\n", lookup_link_status(link)); *************** *** 272,276 **** // find the interface for the link - we select the link with the // best local interface metric ! tmp_if = if_ifwithaddr(&walker->local_iface_addr); if(!tmp_if) --- 272,277 ---- // find the interface for the link - we select the link with the // best local interface metric ! tmp_if = walker->if_name ? if_ifwithname(walker->if_name) : ! if_ifwithaddr(&walker->local_iface_addr); if(!tmp_if) *************** *** 390,410 **** *@param vtime the validity time of the entry *@param htime the HELLO interval of the remote node */ static struct link_entry * ! add_new_entry(union olsr_ip_addr *local, union olsr_ip_addr *remote, union olsr_ip_addr *remote_main, double vtime, double htime) { struct link_entry *tmp_link_set, *new_link; struct neighbor_entry *neighbor; ! tmp_link_set = link_set; ! ! while(tmp_link_set) ! { ! if(COMP_IP(remote, &tmp_link_set->neighbor_iface_addr) && ! COMP_IP(local, &tmp_link_set->local_iface_addr)) ! return tmp_link_set; ! tmp_link_set = tmp_link_set->next; ! } /* --- 391,404 ---- *@param vtime the validity time of the entry *@param htime the HELLO interval of the remote node + *@param local_if the local interface */ static struct link_entry * ! add_new_entry(union olsr_ip_addr *local, union olsr_ip_addr *remote, union olsr_ip_addr *remote_main, double vtime, double htime, struct interface *local_if) { struct link_entry *tmp_link_set, *new_link; struct neighbor_entry *neighbor; ! if((tmp_link_set = lookup_link_entry(remote, local_if))) return tmp_link_set; /* *************** *** 422,425 **** --- 416,428 ---- memset(new_link, 0 , sizeof(struct link_entry)); + + /* copy if_name, if it is defined */ + if (local_if->int_name) + { + new_link->if_name = olsr_malloc(strlen(local_if->int_name)+1, "target of if_name in new link entry"); + strcpy(new_link->if_name, local_if->int_name); + } else + new_link->if_name = NULL; + /* * L_local_iface_addr = Address of the interface *************** *** 560,564 **** */ struct link_entry * ! lookup_link_entry(union olsr_ip_addr *remote, union olsr_ip_addr *local) { struct link_entry *tmp_link_set; --- 563,567 ---- */ struct link_entry * ! lookup_link_entry(union olsr_ip_addr *remote, struct interface *local) { struct link_entry *tmp_link_set; *************** *** 569,573 **** { if(COMP_IP(remote, &tmp_link_set->neighbor_iface_addr) && ! COMP_IP(local, &tmp_link_set->local_iface_addr)) return tmp_link_set; tmp_link_set = tmp_link_set->next; --- 572,579 ---- { if(COMP_IP(remote, &tmp_link_set->neighbor_iface_addr) && ! (tmp_link_set->if_name ? ! !strcmp(tmp_link_set->if_name, local->int_name) : ! COMP_IP(&local->ip_addr, &tmp_link_set->local_iface_addr) ! )) return tmp_link_set; tmp_link_set = tmp_link_set->next; *************** *** 605,609 **** /* Add if not registered */ ! entry = add_new_entry(local, remote, &message->source_addr, message->vtime, message->htime); /* Update ASYM_time */ --- 611,615 ---- /* Add if not registered */ ! entry = add_new_entry(local, remote, &message->source_addr, message->vtime, message->htime, in_if); /* Update ASYM_time */ *************** *** 765,769 **** //olsr_delete_neighbor_if_no_link(&tmp_link_set->neighbor->neighbor_main_addr); changes_neighborhood = OLSR_TRUE; ! free(tmp_link_set); tmp_link_set = last_link_entry; --- 771,775 ---- //olsr_delete_neighbor_if_no_link(&tmp_link_set->neighbor->neighbor_main_addr); changes_neighborhood = OLSR_TRUE; ! free(tmp_link_set->if_name); free(tmp_link_set); tmp_link_set = last_link_entry; *************** *** 781,784 **** --- 787,791 ---- changes_neighborhood = OLSR_TRUE; + free(tmp_link_set->if_name); free(tmp_link_set); tmp_link_set = link_set; *************** *** 995,999 **** } ! void olsr_update_packet_loss(union olsr_ip_addr *rem, union olsr_ip_addr *loc, olsr_u16_t seqno) { --- 1002,1006 ---- } ! void olsr_update_packet_loss(union olsr_ip_addr *rem, struct interface *loc, olsr_u16_t seqno) { Index: link_set.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/link_set.h,v retrieving revision 1.28 retrieving revision 1.28.2.1 diff -C2 -d -r1.28 -r1.28.2.1 *** link_set.h 23 Oct 2005 20:58:14 -0000 1.28 --- link_set.h 14 Dec 2006 11:25:29 -0000 1.28.2.1 *************** *** 56,59 **** --- 56,60 ---- union olsr_ip_addr local_iface_addr; union olsr_ip_addr neighbor_iface_addr; + char *if_name; clock_t SYM_time; clock_t ASYM_time; *************** *** 121,125 **** struct link_entry * ! lookup_link_entry(union olsr_ip_addr *, union olsr_ip_addr *); struct link_entry * --- 122,126 ---- struct link_entry * ! lookup_link_entry(union olsr_ip_addr *, struct interface *); struct link_entry * *************** *** 140,144 **** void ! olsr_update_packet_loss(union olsr_ip_addr *, union olsr_ip_addr *, olsr_u16_t); void --- 141,145 ---- void ! olsr_update_packet_loss(union olsr_ip_addr *, struct interface *, olsr_u16_t); void From (spam-protected) Thu Dec 14 12:27:55 2006 From: (spam-protected) (Bernd Petrovitsch) Date: Thu, 14 Dec 2006 11:27:55 +0000 Subject: [Olsr-cvs] olsrd-current/lib/httpinfo/src .cvsignore,NONE,1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/httpinfo/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv32730/lib/httpinfo/src Added Files: .cvsignore Log Message: * I hate useless outpur from CVS --- NEW FILE: .cvsignore --- *.d From (spam-protected) Thu Dec 14 12:27:54 2006 From: (spam-protected) (Bernd Petrovitsch) Date: Thu, 14 Dec 2006 11:27:54 +0000 Subject: [Olsr-cvs] olsrd-current/lib/dot_draw/src .cvsignore,NONE,1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/dot_draw/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv32730/lib/dot_draw/src Added Files: .cvsignore Log Message: * I hate useless outpur from CVS --- NEW FILE: .cvsignore --- *.d From (spam-protected) Thu Dec 14 12:27:55 2006 From: (spam-protected) (Bernd Petrovitsch) Date: Thu, 14 Dec 2006 11:27:55 +0000 Subject: [Olsr-cvs] olsrd-current/lib/bmf/src .cvsignore,NONE,1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/bmf/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv32730/lib/bmf/src Added Files: .cvsignore Log Message: * I hate useless outpur from CVS --- NEW FILE: .cvsignore --- *.d From (spam-protected) Thu Dec 14 12:27:55 2006 From: (spam-protected) (Bernd Petrovitsch) Date: Thu, 14 Dec 2006 11:27:55 +0000 Subject: [Olsr-cvs] olsrd-current/lib/nameservice/src .cvsignore,NONE,1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/nameservice/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv32730/lib/nameservice/src Added Files: .cvsignore Log Message: * I hate useless outpur from CVS --- NEW FILE: .cvsignore --- *.d From (spam-protected) Thu Dec 14 12:27:54 2006 From: (spam-protected) (Bernd Petrovitsch) Date: Thu, 14 Dec 2006 11:27:54 +0000 Subject: [Olsr-cvs] olsrd-current/lib/tas/src .cvsignore,NONE,1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/tas/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv32730/lib/tas/src Added Files: .cvsignore Log Message: * I hate useless outpur from CVS --- NEW FILE: .cvsignore --- *.d From (spam-protected) Thu Dec 14 12:27:54 2006 From: (spam-protected) (Bernd Petrovitsch) Date: Thu, 14 Dec 2006 11:27:54 +0000 Subject: [Olsr-cvs] olsrd-current/lib/mini/src .cvsignore,NONE,1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/mini/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv32730/lib/mini/src Added Files: .cvsignore Log Message: * I hate useless outpur from CVS --- NEW FILE: .cvsignore --- *.d From (spam-protected) Thu Dec 14 12:27:55 2006 From: (spam-protected) (Bernd Petrovitsch) Date: Thu, 14 Dec 2006 11:27:55 +0000 Subject: [Olsr-cvs] olsrd-current/src/unix .cvsignore,NONE,1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src/unix In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv32730/src/unix Added Files: .cvsignore Log Message: * I hate useless outpur from CVS --- NEW FILE: .cvsignore --- *.d From (spam-protected) Thu Dec 14 12:27:55 2006 From: (spam-protected) (Bernd Petrovitsch) Date: Thu, 14 Dec 2006 11:27:55 +0000 Subject: [Olsr-cvs] olsrd-current/lib/dyn_gw/src .cvsignore,NONE,1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/dyn_gw/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv32730/lib/dyn_gw/src Added Files: .cvsignore Log Message: * I hate useless outpur from CVS --- NEW FILE: .cvsignore --- *.d From (spam-protected) Thu Dec 14 12:27:55 2006 From: (spam-protected) (Bernd Petrovitsch) Date: Thu, 14 Dec 2006 11:27:55 +0000 Subject: [Olsr-cvs] olsrd-current/lib/secure/src .cvsignore,NONE,1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/secure/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv32730/lib/secure/src Added Files: .cvsignore Log Message: * I hate useless outpur from CVS --- NEW FILE: .cvsignore --- *.d From (spam-protected) Thu Dec 14 12:28:34 2006 From: (spam-protected) (Bernd Petrovitsch) Date: Thu, 14 Dec 2006 11:28:34 +0000 Subject: [Olsr-cvs] olsrd-current/src/linux .cvsignore,NONE,1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src/linux In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv704/src/linux Added Files: .cvsignore Log Message: * I hate useless outpur from CVS --- NEW FILE: .cvsignore --- *.d From (spam-protected) Thu Dec 14 12:28:34 2006 From: (spam-protected) (Bernd Petrovitsch) Date: Thu, 14 Dec 2006 11:28:34 +0000 Subject: [Olsr-cvs] olsrd-current/src .cvsignore,NONE,1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv704/src Added Files: .cvsignore Log Message: * I hate useless outpur from CVS --- NEW FILE: .cvsignore --- *.d From (spam-protected) Thu Dec 14 12:28:34 2006 From: (spam-protected) (Bernd Petrovitsch) Date: Thu, 14 Dec 2006 11:28:34 +0000 Subject: [Olsr-cvs] olsrd-current/lib/tas/src/lua .cvsignore,NONE,1.1 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/tas/src/lua In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv704/lib/tas/src/lua Added Files: .cvsignore Log Message: * I hate useless outpur from CVS --- NEW FILE: .cvsignore --- *.d From (spam-protected) Thu Dec 14 12:29:22 2006 From: (spam-protected) (Bernd Petrovitsch) Date: Thu, 14 Dec 2006 11:29:22 +0000 Subject: [Olsr-cvs] olsrd-current/src build_msg.c, 1.32, 1.33 hysteresis.c, 1.16, 1.17 hysteresis.h, 1.7, 1.8 link_set.c, 1.63, 1.64 link_set.h, 1.28, 1.29 lq_route.c, 1.41, 1.42 mid_set.c, 1.15, 1.16 parser.c, 1.30, 1.31 process_routes.c, 1.28, 1.29 routing_table.c, 1.23, 1.24 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv1099/src Modified Files: build_msg.c hysteresis.c hysteresis.h link_set.c link_set.h lq_route.c mid_set.c parser.c process_routes.c routing_table.c Log Message: * applied patches from Sebastian Hagen Index: lq_route.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/lq_route.c,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** lq_route.c 7 Jan 2006 08:16:20 -0000 1.41 --- lq_route.c 14 Dec 2006 11:29:20 -0000 1.42 *************** *** 563,568 **** { // find the interface for the found link ! ! inter = if_ifwithaddr(&link->local_iface_addr); // we may see NULL here if the interface is down, but we have --- 563,568 ---- { // find the interface for the found link ! inter = link->if_name ? if_ifwithname(link->if_name) : ! if_ifwithaddr(&link->local_iface_addr); // we may see NULL here if the interface is down, but we have Index: hysteresis.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/hysteresis.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** hysteresis.h 6 Mar 2005 19:33:35 -0000 1.7 --- hysteresis.h 14 Dec 2006 11:29:19 -0000 1.8 *************** *** 61,65 **** void ! update_hysteresis_incoming(union olsr_ip_addr *, union olsr_ip_addr *, olsr_u16_t); #endif --- 61,65 ---- void ! update_hysteresis_incoming(union olsr_ip_addr *, struct interface *, olsr_u16_t); #endif Index: mid_set.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/mid_set.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** mid_set.c 29 May 2005 12:47:45 -0000 1.15 --- mid_set.c 14 Dec 2006 11:29:20 -0000 1.16 *************** *** 52,55 **** --- 52,56 ---- struct mid_address reverse_mid_set[HASHSIZE]; + struct mid_entry *mid_lookup_entry_bymain(union olsr_ip_addr *adr); /** *************** *** 205,208 **** --- 206,212 ---- { struct mid_address *adr; + struct neighbor_entry *ne_old, *ne_new; + struct mid_entry *me_old; + int ne_ref_rp_count; adr = olsr_malloc(sizeof(struct mid_address), "Insert MID alias"); *************** *** 214,217 **** --- 218,243 ---- adr->next_alias = NULL; + // If we have an entry for this alias in neighbortable, we better adjust it's + // main address, because otherwise a fatal inconsistency between + // neighbortable and link_set will be created by way of this mid entry. + ne_old = olsr_lookup_neighbor_table_alias(alias); + if (ne_old != NULL) { + OLSR_PRINTF(2, "Remote main address change detected. Mangling neighbortable to replace %s with %s.\n", olsr_ip_to_string(alias), olsr_ip_to_string(main_add)); + olsr_delete_neighbor_table(alias); + ne_new = olsr_insert_neighbor_table(main_add); + // adjust pointers to neighbortable-entry in link_set + ne_ref_rp_count = replace_neighbor_link_set(ne_old, ne_new); + if (ne_ref_rp_count > 0) + OLSR_PRINTF(2, "Performed %d neighbortable-pointer replacements (%p -> %p) in link_set.\n", ne_ref_rp_count, ne_old, ne_new); + + me_old = mid_lookup_entry_bymain(alias); + if (me_old) { + // we knew aliases to the previous main address; better forget about + // them now. + OLSR_PRINTF(2, "I already have an mid entry mapping addresses to this alias address. Removing existing mid entry to preserve consistency of mid_set.\n"); + mid_delete_node(me_old); + } + } + insert_mid_tuple(main_add, adr, vtime); *************** *** 256,270 **** ! ! ! /* ! *Find all aliases for an address. ! * ! *@param adr the main address to search for * ! *@return a linked list of addresses structs */ ! struct mid_address * ! mid_lookup_aliases(union olsr_ip_addr *adr) { struct mid_entry *tmp_list; --- 282,292 ---- ! /* Find mid entry to an address. ! * @param adr the main address to search for * ! * @return a linked list of address structs */ ! struct mid_entry * ! mid_lookup_entry_bymain(union olsr_ip_addr *adr) { struct mid_entry *tmp_list; *************** *** 281,285 **** { if(COMP_IP(&tmp_list->main_addr, adr)) ! return tmp_list->aliases; } --- 303,307 ---- { if(COMP_IP(&tmp_list->main_addr, adr)) ! return tmp_list; } *************** *** 289,292 **** --- 311,329 ---- + /* + *Find all aliases for an address. + * + *@param adr the main address to search for + * + *@return a linked list of addresses structs + */ + inline struct mid_address * + mid_lookup_aliases(union olsr_ip_addr *adr) + { + struct mid_entry *tmp = mid_lookup_entry_bymain(adr); + return tmp ? tmp->aliases : NULL; + } + + /** *Update the timer for an entry Index: hysteresis.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/hysteresis.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** hysteresis.c 27 Feb 2005 10:43:38 -0000 1.16 --- hysteresis.c 14 Dec 2006 11:29:19 -0000 1.17 *************** *** 163,167 **** void ! update_hysteresis_incoming(union olsr_ip_addr *remote, union olsr_ip_addr *local, olsr_u16_t seqno) { struct link_entry *link; --- 163,167 ---- void ! update_hysteresis_incoming(union olsr_ip_addr *remote, struct interface *local, olsr_u16_t seqno) { struct link_entry *link; Index: process_routes.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/process_routes.c,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** process_routes.c 1 Nov 2006 09:20:13 -0000 1.28 --- process_routes.c 14 Dec 2006 11:29:20 -0000 1.29 *************** *** 117,122 **** /** ! *Create a list containing the entries in in_table ! *that does not exist in from_table * *@param from_table the table to use --- 117,122 ---- /** ! *Create a list containing the entries in from_table ! *that do not exist in in_table * *@param from_table the table to use Index: parser.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/parser.c,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** parser.c 7 Jan 2006 08:16:20 -0000 1.30 --- parser.c 14 Dec 2006 11:29:20 -0000 1.31 *************** *** 202,206 **** /* IPv4 */ update_hysteresis_incoming(from_addr, ! &in_if->ip_addr, ntohs(olsr->olsr_seqno)); } --- 202,206 ---- /* IPv4 */ update_hysteresis_incoming(from_addr, ! in_if, ntohs(olsr->olsr_seqno)); } *************** *** 209,213 **** /* IPv6 */ update_hysteresis_incoming(from_addr, ! &in_if->ip_addr, ntohs(olsr->olsr_seqno)); } --- 209,213 ---- /* IPv6 */ update_hysteresis_incoming(from_addr, ! in_if, ntohs(olsr->olsr_seqno)); } *************** *** 216,220 **** if (olsr_cnf->lq_level > 0) { ! olsr_update_packet_loss(from_addr, &in_if->ip_addr, ntohs(olsr->olsr_seqno)); } --- 216,220 ---- if (olsr_cnf->lq_level > 0) { ! olsr_update_packet_loss(from_addr, in_if, ntohs(olsr->olsr_seqno)); } Index: build_msg.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/build_msg.c,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** build_msg.c 7 Jan 2006 08:16:19 -0000 1.32 --- build_msg.c 14 Dec 2006 11:29:19 -0000 1.33 *************** *** 922,926 **** //printf("Sending MID (%d bytes)...\n", outputsize); ! net_outbuffer_push(ifp, msg_buffer, curr_size); --- 922,927 ---- //printf("Sending MID (%d bytes)...\n", outputsize); ! if(curr_size > OLSR_MID_IPV4_HDRSIZE) ! net_outbuffer_push(ifp, msg_buffer, curr_size); *************** *** 1019,1023 **** //printf("Sending MID (%d bytes)...\n", outputsize); ! net_outbuffer_push(ifp, msg_buffer, curr_size); return OLSR_TRUE; --- 1020,1025 ---- //printf("Sending MID (%d bytes)...\n", outputsize); ! if(curr_size > OLSR_MID_IPV6_HDRSIZE) ! net_outbuffer_push(ifp, msg_buffer, curr_size); return OLSR_TRUE; Index: routing_table.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/routing_table.c,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** routing_table.c 16 Nov 2005 23:55:54 -0000 1.23 --- routing_table.c 14 Dec 2006 11:29:20 -0000 1.24 *************** *** 283,287 **** if(link) { ! struct interface *iface = if_ifwithaddr(&link->local_iface_addr); if(iface) { --- 283,288 ---- if(link) { ! struct interface *iface = link->if_name ? if_ifwithname(link->if_name) : ! if_ifwithaddr(&link->local_iface_addr); if(iface) { *************** *** 397,401 **** if(link) { ! struct interface *iface = if_ifwithaddr(&link->local_iface_addr); if(iface) { --- 398,403 ---- if(link) { ! struct interface *iface = link->if_name ? if_ifwithname(link->if_name) : ! if_ifwithaddr(&link->local_iface_addr); if(iface) { Index: link_set.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/link_set.c,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** link_set.c 7 Jan 2006 08:16:20 -0000 1.63 --- link_set.c 14 Dec 2006 11:29:19 -0000 1.64 *************** *** 70,74 **** static struct link_entry * ! add_new_entry(union olsr_ip_addr *, union olsr_ip_addr *, union olsr_ip_addr *, double, double); static void --- 70,74 ---- static struct link_entry * ! add_new_entry(union olsr_ip_addr *, union olsr_ip_addr *, union olsr_ip_addr *, double, double, struct interface *); static void *************** *** 203,207 **** //printf("\tChecking %s->", olsr_ip_to_string(&ifs->ip_addr)); //printf("%s : ", olsr_ip_to_string(main_addr)); ! if((link = lookup_link_entry(main_addr, &ifs->ip_addr)) != NULL) { //printf("%d\n", lookup_link_status(link)); --- 203,207 ---- //printf("\tChecking %s->", olsr_ip_to_string(&ifs->ip_addr)); //printf("%s : ", olsr_ip_to_string(main_addr)); ! if((link = lookup_link_entry(main_addr, ifs)) != NULL) { //printf("%d\n", lookup_link_status(link)); *************** *** 216,220 **** //printf("\tChecking %s->", olsr_ip_to_string(&ifs->ip_addr)); //printf("%s : ", olsr_ip_to_string(&aliases->address)); ! if((link = lookup_link_entry(&aliases->alias, &ifs->ip_addr)) != NULL) { //printf("%d\n", lookup_link_status(link)); --- 216,220 ---- //printf("\tChecking %s->", olsr_ip_to_string(&ifs->ip_addr)); //printf("%s : ", olsr_ip_to_string(&aliases->address)); ! if((link = lookup_link_entry(&aliases->alias, ifs)) != NULL) { //printf("%d\n", lookup_link_status(link)); *************** *** 272,276 **** // find the interface for the link - we select the link with the // best local interface metric ! tmp_if = if_ifwithaddr(&walker->local_iface_addr); if(!tmp_if) --- 272,277 ---- // find the interface for the link - we select the link with the // best local interface metric ! tmp_if = walker->if_name ? if_ifwithname(walker->if_name) : ! if_ifwithaddr(&walker->local_iface_addr); if(!tmp_if) *************** *** 390,410 **** *@param vtime the validity time of the entry *@param htime the HELLO interval of the remote node */ static struct link_entry * ! add_new_entry(union olsr_ip_addr *local, union olsr_ip_addr *remote, union olsr_ip_addr *remote_main, double vtime, double htime) { struct link_entry *tmp_link_set, *new_link; struct neighbor_entry *neighbor; ! tmp_link_set = link_set; ! ! while(tmp_link_set) ! { ! if(COMP_IP(remote, &tmp_link_set->neighbor_iface_addr) && ! COMP_IP(local, &tmp_link_set->local_iface_addr)) ! return tmp_link_set; ! tmp_link_set = tmp_link_set->next; ! } /* --- 391,404 ---- *@param vtime the validity time of the entry *@param htime the HELLO interval of the remote node + *@param local_if the local interface */ static struct link_entry * ! add_new_entry(union olsr_ip_addr *local, union olsr_ip_addr *remote, union olsr_ip_addr *remote_main, double vtime, double htime, struct interface *local_if) { struct link_entry *tmp_link_set, *new_link; struct neighbor_entry *neighbor; ! if((tmp_link_set = lookup_link_entry(remote, local_if))) return tmp_link_set; /* *************** *** 422,425 **** --- 416,428 ---- memset(new_link, 0 , sizeof(struct link_entry)); + + /* copy if_name, if it is defined */ + if (local_if->int_name) + { + new_link->if_name = olsr_malloc(strlen(local_if->int_name)+1, "target of if_name in new link entry"); + strcpy(new_link->if_name, local_if->int_name); + } else + new_link->if_name = NULL; + /* * L_local_iface_addr = Address of the interface *************** *** 560,564 **** */ struct link_entry * ! lookup_link_entry(union olsr_ip_addr *remote, union olsr_ip_addr *local) { struct link_entry *tmp_link_set; --- 563,567 ---- */ struct link_entry * ! lookup_link_entry(union olsr_ip_addr *remote, struct interface *local) { struct link_entry *tmp_link_set; *************** *** 569,573 **** { if(COMP_IP(remote, &tmp_link_set->neighbor_iface_addr) && ! COMP_IP(local, &tmp_link_set->local_iface_addr)) return tmp_link_set; tmp_link_set = tmp_link_set->next; --- 572,579 ---- { if(COMP_IP(remote, &tmp_link_set->neighbor_iface_addr) && ! (tmp_link_set->if_name ? ! !strcmp(tmp_link_set->if_name, local->int_name) : ! COMP_IP(&local->ip_addr, &tmp_link_set->local_iface_addr) ! )) return tmp_link_set; tmp_link_set = tmp_link_set->next; *************** *** 605,609 **** /* Add if not registered */ ! entry = add_new_entry(local, remote, &message->source_addr, message->vtime, message->htime); /* Update ASYM_time */ --- 611,615 ---- /* Add if not registered */ ! entry = add_new_entry(local, remote, &message->source_addr, message->vtime, message->htime, in_if); /* Update ASYM_time */ *************** *** 765,769 **** //olsr_delete_neighbor_if_no_link(&tmp_link_set->neighbor->neighbor_main_addr); changes_neighborhood = OLSR_TRUE; ! free(tmp_link_set); tmp_link_set = last_link_entry; --- 771,775 ---- //olsr_delete_neighbor_if_no_link(&tmp_link_set->neighbor->neighbor_main_addr); changes_neighborhood = OLSR_TRUE; ! free(tmp_link_set->if_name); free(tmp_link_set); tmp_link_set = last_link_entry; *************** *** 781,784 **** --- 787,791 ---- changes_neighborhood = OLSR_TRUE; + free(tmp_link_set->if_name); free(tmp_link_set); tmp_link_set = link_set; *************** *** 995,999 **** } ! void olsr_update_packet_loss(union olsr_ip_addr *rem, union olsr_ip_addr *loc, olsr_u16_t seqno) { --- 1002,1006 ---- } ! void olsr_update_packet_loss(union olsr_ip_addr *rem, struct interface *loc, olsr_u16_t seqno) { Index: link_set.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/link_set.h,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** link_set.h 23 Oct 2005 20:58:14 -0000 1.28 --- link_set.h 14 Dec 2006 11:29:19 -0000 1.29 *************** *** 56,59 **** --- 56,60 ---- union olsr_ip_addr local_iface_addr; union olsr_ip_addr neighbor_iface_addr; + char *if_name; clock_t SYM_time; clock_t ASYM_time; *************** *** 121,125 **** struct link_entry * ! lookup_link_entry(union olsr_ip_addr *, union olsr_ip_addr *); struct link_entry * --- 122,126 ---- struct link_entry * ! lookup_link_entry(union olsr_ip_addr *, struct interface *); struct link_entry * *************** *** 140,144 **** void ! olsr_update_packet_loss(union olsr_ip_addr *, union olsr_ip_addr *, olsr_u16_t); void --- 141,145 ---- void ! olsr_update_packet_loss(union olsr_ip_addr *, struct interface *, olsr_u16_t); void