remove the need for C99 math (closes: #1579)
[openwrt/svn-archive/archive.git] / net / olsrd / patches / 240-olsrd-fixes-routedel.patch
1 diff -Nur olsrd-0.4.10.orig/src/link_set.c olsrd-0.4.10/src/link_set.c
2 --- olsrd-0.4.10.orig/src/link_set.c 2006-12-01 09:04:56.000000000 +0100
3 +++ olsrd-0.4.10/src/link_set.c 2006-12-01 09:06:22.000000000 +0100
4 @@ -381,6 +381,69 @@
5 }
6
7 /**
8 + *Delete all interface link entries
9 + *
10 + *@param interface ip address
11 + */
12 +
13 +void
14 +del_if_link_entries(union olsr_ip_addr *int_addr)
15 +{
16 + struct link_entry *tmp_link_set, *last_link_entry;
17 +
18 + if(link_set == NULL)
19 + return;
20 +
21 + tmp_link_set = link_set;
22 + last_link_entry = NULL;
23 +
24 + while(tmp_link_set)
25 + {
26 +
27 + if(COMP_IP(int_addr, &tmp_link_set->local_iface_addr))
28 + {
29 + if(last_link_entry != NULL)
30 + {
31 + last_link_entry->next = tmp_link_set->next;
32 +
33 + /* Delete neighbor entry */
34 + if(tmp_link_set->neighbor->linkcount == 1)
35 + olsr_delete_neighbor_table(&tmp_link_set->neighbor->neighbor_main_addr);
36 + else
37 + tmp_link_set->neighbor->linkcount--;
38 +
39 + //olsr_delete_neighbor_if_no_link(&tmp_link_set->neighbor->neighbor_main_addr);
40 + changes_neighborhood = OLSR_TRUE;
41 +
42 + free(tmp_link_set);
43 + tmp_link_set = last_link_entry;
44 + }
45 + else
46 + {
47 + link_set = tmp_link_set->next; /* CHANGED */
48 +
49 + /* Delete neighbor entry */
50 + if(tmp_link_set->neighbor->linkcount == 1)
51 + olsr_delete_neighbor_table(&tmp_link_set->neighbor->neighbor_main_addr);
52 + else
53 + tmp_link_set->neighbor->linkcount--;
54 +
55 + changes_neighborhood = OLSR_TRUE;
56 +
57 + free(tmp_link_set);
58 + tmp_link_set = link_set;
59 + continue;
60 + }
61 + }
62 +
63 + last_link_entry = tmp_link_set;
64 + tmp_link_set = tmp_link_set->next;
65 + }
66 +
67 + return;
68 +}
69 +
70 +/**
71 *Nothing mysterious here.
72 *Adding a new link entry to the link set.
73 *
74 diff -Nur olsrd-0.4.10.orig/src/link_set.h olsrd-0.4.10/src/link_set.h
75 --- olsrd-0.4.10.orig/src/link_set.h 2005-10-23 22:58:14.000000000 +0200
76 +++ olsrd-0.4.10/src/link_set.h 2006-12-01 09:06:22.000000000 +0100
77 @@ -116,6 +116,9 @@
78 void
79 olsr_init_link_set(void);
80
81 +void
82 +del_if_link_entries(union olsr_ip_addr *);
83 +
84 struct link_entry *
85 get_best_link_to_neighbor(union olsr_ip_addr *);
86
87 diff -Nur olsrd-0.4.10.orig/src/linux/kernel_routes.c olsrd-0.4.10/src/linux/kernel_routes.c
88 --- olsrd-0.4.10.orig/src/linux/kernel_routes.c 2005-02-27 19:39:43.000000000 +0100
89 +++ olsrd-0.4.10/src/linux/kernel_routes.c 2006-12-01 09:06:22.000000000 +0100
90 @@ -244,9 +244,8 @@
91 inet_ntop(AF_INET, &destination->rt_mask.v4, mask_str, 16);
92 inet_ntop(AF_INET, &destination->rt_router.v4, router_str, 16);
93
94 - OLSR_PRINTF(1, "(ioctl)Deleting route with metric %d to %s/%s via %s/%s.\n",
95 - destination->rt_metric, dst_str, mask_str, router_str,
96 - destination->rt_if->int_name)
97 + OLSR_PRINTF(1, "(ioctl)Deleting route with metric %d to %s/%s via %s.\n",
98 + destination->rt_metric, dst_str, mask_str, router_str)
99
100 memset(&kernel_route,0,sizeof(struct rtentry));
101
102 diff -Nur olsrd-0.4.10.orig/src/lq_packet.c olsrd-0.4.10/src/lq_packet.c
103 --- olsrd-0.4.10.orig/src/lq_packet.c 2006-12-01 09:04:56.000000000 +0100
104 +++ olsrd-0.4.10/src/lq_packet.c 2006-12-01 09:06:22.000000000 +0100
105 @@ -225,8 +225,10 @@
106
107 link = get_best_link_to_neighbor(&neigh->main);
108
109 - neigh->link_quality = link->loss_link_quality;
110 - neigh->neigh_link_quality = link->neigh_link_quality;
111 + if (link) {
112 + neigh->link_quality = link->loss_link_quality;
113 + neigh->neigh_link_quality = link->neigh_link_quality;
114 + }
115
116 // queue the neighbour entry
117
118 diff -Nur olsrd-0.4.10.orig/src/unix/ifnet.c olsrd-0.4.10/src/unix/ifnet.c
119 --- olsrd-0.4.10.orig/src/unix/ifnet.c 2006-12-01 09:04:56.000000000 +0100
120 +++ olsrd-0.4.10/src/unix/ifnet.c 2006-12-01 09:06:22.000000000 +0100
121 @@ -56,6 +56,7 @@
122 #include "mantissa.h"
123 #include "lq_packet.h"
124 #include "log.h"
125 +#include "link_set.h"
126 #include <signal.h>
127 #include <sys/types.h>
128 #include <net/if.h>
129 @@ -393,6 +394,8 @@
130 OLSR_PRINTF(1, "Removing interface %s\n", iface->name)
131 olsr_syslog(OLSR_LOG_INFO, "Removing interface %s\n", iface->name);
132
133 + del_if_link_entries(&ifp->ip_addr);
134 +
135 /*
136 *Call possible ifchange functions registered by plugins
137 */