remove the need for C99 math (closes: #1579)
[openwrt/svn-archive/archive.git] / net / olsrd / patches / 200-olsrd-fixes-eric.patch
1 diff -Naur olsrd-0.4.10/files/olsrd.conf.default.lq olsrd-0.4.10-patched/files/olsrd.conf.default.lq
2 --- olsrd-0.4.10/files/olsrd.conf.default.lq 2005-03-31 20:35:23.000000000 +0200
3 +++ olsrd-0.4.10-patched/files/olsrd.conf.default.lq 2006-11-16 13:22:26.000000000 +0100
4 @@ -259,6 +259,7 @@
5 # HNA validity time
6 HnaValidityTime 30.0
7
8 +
9 # When multiple links exist between hosts
10 # the weight of interface is used to determine
11 # the link to use. Normally the weight is
12 @@ -266,9 +267,29 @@
13 # on the characteristics of the interface,
14 # but here you can specify a fixed value.
15 # Olsrd will choose links with the lowest value.
16 -
17 + # Note:
18 + # Interface weight is used only when LinkQualityLevel is 0.
19 + # For any other value of LinkQualityLevel, the interface ETX
20 + # value is used instead.
21 # Weight 0
22
23
24 + # If a certain route should be preferred
25 + # or ignored by the mesh, the Link Quality
26 + # value of a node can be multiplied with a factor
27 + # entered here. In the example the route
28 + # using 192.168.0.1 would rather be ignored.
29 + # A multiplier of 0.5 will result in a small
30 + # (bad) LinkQuality value and a high (bad)
31 + # ETX value.
32 + # Note:
33 + # Link quality multiplier is used only when
34 + # LinkQualityLevel is > 0.
35 +
36 + # LinkQualityMult 192.168.0.1 0.5
37 +
38 + # This multiplier applies to all other nodes
39 + # LinkQualityMult default 0.8
40 +
41 }
42
43 diff -Naur olsrd-0.4.10/files/olsrd.conf.default.lq-fisheye olsrd-0.4.10-patched/files/olsrd.conf.default.lq-fisheye
44 --- olsrd-0.4.10/files/olsrd.conf.default.lq-fisheye 2005-12-17 08:30:34.000000000 +0100
45 +++ olsrd-0.4.10-patched/files/olsrd.conf.default.lq-fisheye 2006-11-16 13:24:18.000000000 +0100
46 @@ -267,6 +267,7 @@
47 # HNA validity time
48 HnaValidityTime 100.0
49
50 +
51 # When multiple links exist between hosts
52 # the weight of interface is used to determine
53 # the link to use. Normally the weight is
54 @@ -274,7 +275,10 @@
55 # on the characteristics of the interface,
56 # but here you can specify a fixed value.
57 # Olsrd will choose links with the lowest value.
58 -
59 + # Note:
60 + # Interface weight is used only when LinkQualityLevel is set to 0.
61 + # For any other value of LinkQualityLevel, the interface ETX
62 + # value is used instead.
63 # Weight 0
64
65
66 @@ -286,13 +290,14 @@
67 # A multiplier of 0.5 will result in a small
68 # (bad) LinkQuality value and a high (bad)
69 # ETX value.
70 + # Note:
71 + # Link quality multiplier is used only when
72 + # LinkQualityLevel is > 0.
73
74 # LinkQualityMult 192.168.0.1 0.5
75
76 # This multiplier applies to all other nodes
77 # LinkQualityMult default 0.8
78 -
79 -
80
81 }
82
83 diff -Naur olsrd-0.4.10/files/olsrd.conf.default.rfc olsrd-0.4.10-patched/files/olsrd.conf.default.rfc
84 --- olsrd-0.4.10/files/olsrd.conf.default.rfc 2005-06-04 17:34:05.000000000 +0200
85 +++ olsrd-0.4.10-patched/files/olsrd.conf.default.rfc 2006-11-16 13:23:02.000000000 +0100
86 @@ -254,6 +254,7 @@
87 # HNA validity time
88 # HnaValidityTime 15.0
89
90 +
91 # When multiple links exist between hosts
92 # the weight of interface is used to determine
93 # the link to use. Normally the weight is
94 @@ -261,9 +262,29 @@
95 # on the characteristics of the interface,
96 # but here you can specify a fixed value.
97 # Olsrd will choose links with the lowest value.
98 -
99 + # Note:
100 + # Interface weight is used only when LinkQualityLevel is set to 0.
101 + # For any other value of LinkQualityLevel, the interface ETX
102 + # value is used instead.
103 # Weight 0
104
105
106 + # If a certain route should be preferred
107 + # or ignored by the mesh, the Link Quality
108 + # value of a node can be multiplied with a factor
109 + # entered here. In the example the route
110 + # using 192.168.0.1 would rather be ignored.
111 + # A multiplier of 0.5 will result in a small
112 + # (bad) LinkQuality value and a high (bad)
113 + # ETX value.
114 + # Note:
115 + # Link quality multiplier is used only when
116 + # LinkQualityLevel is > 0.
117 +
118 + # LinkQualityMult 192.168.0.1 0.5
119 +
120 + # This multiplier applies to all other nodes
121 + # LinkQualityMult default 0.8
122 +
123 }
124
125 diff -Naur olsrd-0.4.10/lib/httpinfo/src/html.h olsrd-0.4.10-patched/lib/httpinfo/src/html.h
126 --- olsrd-0.4.10/lib/httpinfo/src/html.h 2005-03-14 22:28:15.000000000 +0100
127 +++ olsrd-0.4.10-patched/lib/httpinfo/src/html.h 2006-09-14 13:11:02.000000000 +0200
128 @@ -48,7 +48,7 @@
129
130 static const char *httpinfo_css[] =
131 {
132 - "A {text-decoration: none}\n",
133 + "#A {text-decoration: none}\n",
134 "TH{text-align: left}\n",
135 "H1, H3, TD, TH {font-family: Helvetica; font-size: 80%%}\n",
136 "h2\n {\nfont-family: Helvetica;\n font-size: 14px;text-align: center;\n",
137 diff -Naur olsrd-0.4.10/lib/httpinfo/src/olsrd_httpinfo.c olsrd-0.4.10-patched/lib/httpinfo/src/olsrd_httpinfo.c
138 --- olsrd-0.4.10/lib/httpinfo/src/olsrd_httpinfo.c 2005-12-22 16:06:52.000000000 +0100
139 +++ olsrd-0.4.10-patched/lib/httpinfo/src/olsrd_httpinfo.c 2006-11-24 12:53:25.000000000 +0100
140 @@ -713,7 +713,10 @@
141
142 size += sprintf(&buf[size], "<h2>OLSR routes in kernel</h2>\n");
143
144 - size += sprintf(&buf[size], "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Destination</th><th>Gateway</th><th>Metric</th><th>ETX</th><th>Interface</th><th>Type</th></tr>\n");
145 + size += sprintf(&buf[size], "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Destination</th><th>Gateway</th><th>Metric</th>");
146 + if (olsr_cnf->lq_level > 0)
147 + size += sprintf(&buf[size], "<th>ETX</th>");
148 + size += sprintf(&buf[size], "<th>Interface</th><th>Type</th></tr>\n");
149
150 /* Neighbors */
151 for(index = 0;index < HASHSIZE;index++)
152 @@ -722,12 +725,23 @@
153 routes != &routingtable[index];
154 routes = routes->next)
155 {
156 - size += sprintf(&buf[size], "<tr><td>%s</td><td>%s</td><td>%d</td><td>%.2f</td><td>%s</td><td>HOST</td></tr>\n",
157 - olsr_ip_to_string(&routes->rt_dst),
158 - olsr_ip_to_string(&routes->rt_router),
159 - routes->rt_metric,
160 - routes->rt_etx,
161 - routes->rt_if->int_name);
162 + size += sprintf(&buf[size],
163 + "<tr><td><a href=\"http://%s:%d/all\">%s</a></td>"
164 + "<td><a href=\"http://%s:%d/all\">%s</a></td>"
165 + "<td>%d</td>",
166 + olsr_ip_to_string(&routes->rt_dst),
167 + http_port,
168 + olsr_ip_to_string(&routes->rt_dst),
169 + olsr_ip_to_string(&routes->rt_router),
170 + http_port,
171 + olsr_ip_to_string(&routes->rt_router),
172 + routes->rt_metric);
173 + if (olsr_cnf->lq_level > 0)
174 + size += sprintf(&buf[size], "<td>%.2f</td>", routes->rt_etx);
175 + size += sprintf(&buf[size],
176 + "<td>%s</td>"
177 + "<td>HOST</td></tr>\n",
178 + routes->rt_if->int_name);
179 }
180 }
181
182 @@ -738,11 +752,21 @@
183 routes != &hna_routes[index];
184 routes = routes->next)
185 {
186 - size += sprintf(&buf[size], "<tr><td>%s</td><td>%s</td><td>%d</td><td>%s</td><td>HNA</td></tr>\n",
187 - olsr_ip_to_string(&routes->rt_dst),
188 - olsr_ip_to_string(&routes->rt_router),
189 - routes->rt_metric,
190 - routes->rt_if->int_name);
191 + size += sprintf(&buf[size],
192 + "<tr><td>%s</td>"
193 + "<td><a href=\"http://%s:%d/all\">%s</a></td>"
194 + "<td>%d</td>",
195 + olsr_ip_to_string(&routes->rt_dst),
196 + olsr_ip_to_string(&routes->rt_router),
197 + http_port,
198 + olsr_ip_to_string(&routes->rt_router),
199 + routes->rt_metric);
200 + if (olsr_cnf->lq_level > 0)
201 + size += sprintf(&buf[size], "<td>%.2f</td>", routes->rt_etx);
202 + size += sprintf(&buf[size],
203 + "<td>%s</td>"
204 + "<td>HNA</td></tr>\n",
205 + routes->rt_if->int_name);
206 }
207 }
208
209 @@ -816,17 +840,24 @@
210
211 size += sprintf(&buf[size], "</tr>\n<tr>\n");
212
213 - size += sprintf(&buf[size], "<td>Hysteresis: %s</td>\n", olsr_cnf->use_hysteresis ? "Enabled" : "Disabled");
214 -
215 - size += sprintf(&buf[size], "<td>Hyst scaling: %0.2f</td>\n", olsr_cnf->hysteresis_param.scaling);
216 - size += sprintf(&buf[size], "<td>Hyst lower/upper: %0.2f/%0.2f</td>\n", olsr_cnf->hysteresis_param.thr_low, olsr_cnf->hysteresis_param.thr_high);
217 + if (olsr_cnf->lq_level == 0)
218 + {
219 + size += sprintf(&buf[size], "<td>Hysteresis: %s</td>\n", olsr_cnf->use_hysteresis ? "Enabled" : "Disabled");
220 + if (olsr_cnf->use_hysteresis)
221 + {
222 + size += sprintf(&buf[size], "<td>Hyst scaling: %0.2f</td>\n", olsr_cnf->hysteresis_param.scaling);
223 + size += sprintf(&buf[size], "<td>Hyst lower/upper: %0.2f/%0.2f</td>\n", olsr_cnf->hysteresis_param.thr_low, olsr_cnf->hysteresis_param.thr_high);
224 + }
225 + }
226
227 size += sprintf(&buf[size], "</tr>\n<tr>\n");
228
229 - size += sprintf(&buf[size], "<td>LQ extention: %s</td>\n", olsr_cnf->lq_level ? "Enabled" : "Disabled");
230 - size += sprintf(&buf[size], "<td>LQ level: %d</td>\n", olsr_cnf->lq_level);
231 - size += sprintf(&buf[size], "<td>LQ winsize: %d</td>\n", olsr_cnf->lq_wsize);
232 - size += sprintf(&buf[size], "<td></td>\n");
233 + size += sprintf(&buf[size], "<td>LQ extension: %s</td>\n", olsr_cnf->lq_level ? "Enabled" : "Disabled");
234 + if (olsr_cnf->lq_level)
235 + {
236 + size += sprintf(&buf[size], "<td>LQ level: %d</td>\n", olsr_cnf->lq_level);
237 + size += sprintf(&buf[size], "<td>LQ winsize: %d</td>\n", olsr_cnf->lq_wsize);
238 + }
239
240 size += sprintf(&buf[size], "</tr></table>\n");
241
242 @@ -868,7 +899,6 @@
243 size += sprintf(&buf[size], "<td>WLAN: %s</td>\n", rifs->is_wireless ? "Yes" : "No");
244 size += sprintf(&buf[size], "<td>STATUS: UP</td></tr>\n");
245 }
246 -
247 }
248
249 size += sprintf(&buf[size], "</table>\n");
250 @@ -950,21 +980,39 @@
251 int size = 0, index, thop_cnt;
252
253 size += sprintf(&buf[size], "<h2>Links</h2>\n");
254 - size += sprintf(&buf[size], "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Local IP</th><th>remote IP</th><th>Hysteresis</th><th>LinkQuality</th><th>lost</th><th>total</th><th>NLQ</th><th>ETX</th></tr>\n");
255 + size += sprintf(&buf[size], "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Local IP</th><th>remote IP</th><th>Hysteresis</th>\n");
256 + if (olsr_cnf->lq_level > 0)
257 + size += sprintf(&buf[size], "<th>LinkQuality</th><th>lost</th><th>total</th><th>NLQ</th><th>ETX</th>\n");
258 + size += sprintf(&buf[size], "</tr>\n");
259
260 /* Link set */
261 link = link_set;
262 while(link)
263 {
264 - size += sprintf(&buf[size], "<tr><td>%s</td><td>%s</td><td>%0.2f</td><td>%0.2f</td><td>%d</td><td>%d</td><td>%0.2f</td><td>%0.2f</td></tr>\n",
265 - olsr_ip_to_string(&link->local_iface_addr),
266 - olsr_ip_to_string(&link->neighbor_iface_addr),
267 - link->L_link_quality,
268 - link->loss_link_quality,
269 - link->lost_packets,
270 - link->total_packets,
271 - link->neigh_link_quality,
272 - (link->loss_link_quality * link->neigh_link_quality) ? 1.0 / (link->loss_link_quality * link->neigh_link_quality) : 0.0);
273 + size += sprintf(&buf[size],
274 + "<tr><td>%s</td>"
275 + "<td><a href=\"http://%s:%d/all\">%s</a></td>"
276 + "<td>%0.2f</td>",
277 + olsr_ip_to_string(&link->local_iface_addr),
278 + olsr_ip_to_string(&link->neighbor_iface_addr),
279 + http_port,
280 + olsr_ip_to_string(&link->neighbor_iface_addr),
281 + link->L_link_quality);
282 + if (olsr_cnf->lq_level > 0)
283 + {
284 + size += sprintf(&buf[size],
285 + "<td>%0.2f</td>"
286 + "<td>%d</td>"
287 + "<td>%d</td>"
288 + "<td>%0.2f</td>"
289 + "<td>%0.2f</td></tr>\n",
290 + link->loss_link_quality,
291 + link->lost_packets,
292 + link->total_packets,
293 + link->neigh_link_quality,
294 + (link->loss_link_quality * link->neigh_link_quality) ? 1.0 / (link->loss_link_quality * link->neigh_link_quality) : 0.0);
295 + }
296 + size += sprintf(&buf[size], "</tr>\n");
297
298 link = link->next;
299 }
300 @@ -981,7 +1029,13 @@
301 neigh = neigh->next)
302 {
303 size += sprintf(&buf[size],
304 - "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%d</td>",
305 + "<tr><td><a href=\"http://%s:%d/all\">%s</a></td>"
306 + "<td>%s</td>"
307 + "<td>%s</td>"
308 + "<td>%s</td>"
309 + "<td>%d</td>",
310 + olsr_ip_to_string(&neigh->neighbor_main_addr),
311 + http_port,
312 olsr_ip_to_string(&neigh->neighbor_main_addr),
313 (neigh->status == SYM) ? "YES" : "NO",
314 neigh->is_mpr ? "YES" : "NO",
315 @@ -1021,7 +1075,10 @@
316 struct topo_dst *dst_entry;
317
318
319 - size += sprintf(&buf[size], "<h2>Topology entries</h2>\n<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Destination IP</th><th>Last hop IP</th><th>LQ</th><th>ILQ</th><th>ETX</th></tr>\n");
320 + size += sprintf(&buf[size], "<h2>Topology entries</h2>\n<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Destination IP</th><th>Last hop IP</th>");
321 + if (olsr_cnf->lq_level > 0)
322 + size += sprintf(&buf[size], "<th>LQ</th><th>ILQ</th><th>ETX</th>");
323 + size += sprintf(&buf[size], "</tr>\n");
324
325
326 /* Topology */
327 @@ -1035,12 +1092,26 @@
328 dst_entry = entry->destinations.next;
329 while(dst_entry != &entry->destinations)
330 {
331 - size += sprintf(&buf[size], "<tr><td>%s</td><td>%s</td><td>%0.2f</td><td>%0.2f</td><td>%0.2f</td></tr>\n",
332 - olsr_ip_to_string(&dst_entry->T_dest_addr),
333 - olsr_ip_to_string(&entry->T_last_addr),
334 - dst_entry->link_quality,
335 - dst_entry->inverse_link_quality,
336 - (dst_entry->link_quality * dst_entry->inverse_link_quality) ? 1.0 / (dst_entry->link_quality * dst_entry->inverse_link_quality) : 0.0);
337 + size += sprintf(&buf[size],
338 + "<tr><td><a href=\"http://%s:%d/all\">%s</a></td>"
339 + "<td><a href=\"http://%s:%d/all\">%s</a></td>",
340 + olsr_ip_to_string(&dst_entry->T_dest_addr),
341 + http_port,
342 + olsr_ip_to_string(&dst_entry->T_dest_addr),
343 + olsr_ip_to_string(&entry->T_last_addr),
344 + http_port,
345 + olsr_ip_to_string(&entry->T_last_addr));
346 + if (olsr_cnf->lq_level > 0)
347 + {
348 + size += sprintf(&buf[size],
349 + "<td>%0.2f</td>"
350 + "<td>%0.2f</td>"
351 + "<td>%0.2f</td>\n",
352 + dst_entry->link_quality,
353 + dst_entry->inverse_link_quality,
354 + (dst_entry->link_quality * dst_entry->inverse_link_quality) ? 1.0 / (dst_entry->link_quality * dst_entry->inverse_link_quality) : 0.0);
355 + }
356 + size += sprintf(&buf[size], "</tr>\n");
357
358 dst_entry = dst_entry->next;
359 }
360 @@ -1083,7 +1154,9 @@
361 olsr_ip_to_string(&tmp_net->A_network_addr));
362 size += sprintf(&buf[size], "<td>%s</td>",
363 olsr_netmask_to_string(&tmp_net->A_netmask));
364 - size += sprintf(&buf[size], "<td>%s</td></tr>\n",
365 + size += sprintf(&buf[size], "<td><a href=\"http://%s:%d/all\">%s</a></td></tr>\n",
366 + olsr_ip_to_string(&tmp_hna->A_gateway_addr),
367 + http_port,
368 olsr_ip_to_string(&tmp_hna->A_gateway_addr));
369 tmp_net = tmp_net->next;
370 }
371 @@ -1101,7 +1174,7 @@
372 int
373 build_mid_body(char *buf, olsr_u32_t bufsize)
374 {
375 - int size = 0;
376 + int size = 0, mid_cnt;
377 olsr_u8_t index;
378 struct mid_entry *entry;
379 struct mid_address *alias;
380 @@ -1114,18 +1187,21 @@
381 entry = mid_set[index].next;
382 while(entry != &mid_set[index])
383 {
384 - size += sprintf(&buf[size], "<tr><td>%s</td>\n", olsr_ip_to_string(&entry->main_addr));
385 + size += sprintf(&buf[size], "<tr><td><a href=\"http://%s:%d/all\">%s</a></td>\n",
386 + olsr_ip_to_string(&entry->main_addr),
387 + http_port,
388 + olsr_ip_to_string(&entry->main_addr));
389 size += sprintf(&buf[size], "<td><select>\n<option>IP ADDRESS</option>\n");
390
391 alias = entry->aliases;
392 + mid_cnt = 0;
393 while(alias)
394 {
395 size += sprintf(&buf[size], "<option>%s</option>\n", olsr_ip_to_string(&alias->alias));
396 + mid_cnt ++;
397 alias = alias->next_alias;
398 }
399 - size += sprintf(&buf[size], "</select>\n");
400 -
401 - size += sprintf(&buf[size], "</tr>\n");
402 + size += sprintf(&buf[size], "</select> (%d)</td></tr>\n", mid_cnt);
403 entry = entry->next;
404 }
405 }
406 diff -Naur olsrd-0.4.10/lib/httpinfo/src/olsrd_plugin.c olsrd-0.4.10-patched/lib/httpinfo/src/olsrd_plugin.c
407 --- olsrd-0.4.10/lib/httpinfo/src/olsrd_plugin.c 2005-05-29 14:47:41.000000000 +0200
408 +++ olsrd-0.4.10-patched/lib/httpinfo/src/olsrd_plugin.c 2006-09-18 03:03:50.000000000 +0200
409 @@ -51,6 +51,8 @@
410 #include <stdlib.h>
411 #include "olsrd_httpinfo.h"
412
413 +int http_port = 0;
414 +
415 static void __attribute__ ((constructor))
416 my_init(void);
417
418 diff -Naur olsrd-0.4.10/lib/httpinfo/src/olsrd_plugin.h olsrd-0.4.10-patched/lib/httpinfo/src/olsrd_plugin.h
419 --- olsrd-0.4.10/lib/httpinfo/src/olsrd_plugin.h 2005-05-29 14:47:41.000000000 +0200
420 +++ olsrd-0.4.10-patched/lib/httpinfo/src/olsrd_plugin.h 2006-09-18 03:03:38.000000000 +0200
421 @@ -71,7 +71,7 @@
422 #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR
423 #define PLUGIN_INTERFACE_VERSION 4
424
425 -int http_port;
426 +extern int http_port;
427
428 /* Allowed hosts stuff */
429
430 diff -Naur olsrd-0.4.10/src/cfgparser/cfgfile_gen.c olsrd-0.4.10-patched/src/cfgparser/cfgfile_gen.c
431 --- olsrd-0.4.10/src/cfgparser/cfgfile_gen.c 2005-12-30 03:24:00.000000000 +0100
432 +++ olsrd-0.4.10-patched/src/cfgparser/cfgfile_gen.c 2006-11-16 13:54:04.000000000 +0100
433 @@ -311,7 +311,17 @@
434 }
435 }
436
437 - fprintf(fd, " # When multiple links exist between hosts\n # the weight of interface is used to determine\n # the link to use. Normally the weight is\n # automatically calculated by olsrd based\n # on the characteristics of the interface,\n # but here you can specify a fixed value.\n # Olsrd will choose links with the lowest value.\n");
438 + fprintf(fd, " # When multiple links exist between hosts\n");
439 + fprintf(fd, " # the weight of interface is used to determine\n");
440 + fprintf(fd, " # the link to use. Normally the weight is\n");
441 + fprintf(fd, " # automatically calculated by olsrd based\n");
442 + fprintf(fd, " # on the characteristics of the interface,\n");
443 + fprintf(fd, " # but here you can specify a fixed value.\n");
444 + fprintf(fd, " # Olsrd will choose links with the lowest value.\n");
445 + fprintf(fd, " # Note:\n");
446 + fprintf(fd, " # Interface weight is used only when LinkQualityLevel is 0.\n");
447 + fprintf(fd, " # For any other value of LinkQualityLevel, the interface ETX\n");
448 + fprintf(fd, " # value is used instead.\n\n");
449 if(in->cnf->weight.fixed)
450 {
451 fprintf(fd, " Weight\t %d\n\n", in->cnf->weight.value);
452 @@ -615,9 +625,19 @@
453 }
454
455 if(first)
456 - WRITE_TO_BUF(" # When multiple links exist between hosts\n # the weight of interface is used to determine\n # the link to use. Normally the weight is\n")
457 - if(first)
458 - WRITE_TO_BUF(" # automatically calculated by olsrd based\n # on the characteristics of the interface,\n # but here you can specify a fixed value.\n # Olsrd will choose links with the lowest value.\n")
459 + {
460 + WRITE_TO_BUF(" # When multiple links exist between hosts\n");
461 + WRITE_TO_BUF(" # the weight of interface is used to determine\n");
462 + WRITE_TO_BUF(" # the link to use. Normally the weight is\n")
463 + WRITE_TO_BUF(" # automatically calculated by olsrd based\n");
464 + WRITE_TO_BUF(" # on the characteristics of the interface,\n");
465 + WRITE_TO_BUF(" # but here you can specify a fixed value.\n");
466 + WRITE_TO_BUF(" # Olsrd will choose links with the lowest value.\n")
467 + WRITE_TO_BUF(" # Note:\n");
468 + WRITE_TO_BUF(" # Interface weight is used only when LinkQualityLevel is 0.\n");
469 + WRITE_TO_BUF(" # For any other value of LinkQualityLevel, the interface ETX\n");
470 + WRITE_TO_BUF(" # value is used instead.\n\n");
471 + }
472 if(in->cnf->weight.fixed)
473 {
474 WRITE_TO_BUF(" Weight\t %d\n\n", in->cnf->weight.value)
475 diff -Naur olsrd-0.4.10/src/defs.h olsrd-0.4.10-patched/src/defs.h
476 --- olsrd-0.4.10/src/defs.h 2006-01-01 16:59:02.000000000 +0100
477 +++ olsrd-0.4.10-patched/src/defs.h 2006-09-13 15:24:48.000000000 +0200
478 @@ -72,7 +72,7 @@
479 #define MAXMESSAGESIZE 1500 /* max broadcast size */
480 #define UDP_IPV4_HDRSIZE 28
481 #define UDP_IPV6_HDRSIZE 48
482 -#define MAX_IFS 16
483 +#define MAX_IFS 32
484
485 /* Debug helper macro */
486 #ifdef DEBUG
487 diff -Naur olsrd-0.4.10/src/link_set.c olsrd-0.4.10-patched/src/link_set.c
488 --- olsrd-0.4.10/src/link_set.c 2005-11-17 05:25:44.000000000 +0100
489 +++ olsrd-0.4.10-patched/src/link_set.c 2006-11-16 13:49:17.000000000 +0100
490 @@ -263,7 +263,7 @@
491 if (!COMP_IP(&walker->neighbor->neighbor_main_addr, main_addr))
492 continue;
493
494 - // handle the non-LQ case
495 + // handle the non-LQ, RFC-compliant case
496
497 if (olsr_cnf->lq_level == 0)
498 {
499 @@ -297,7 +297,7 @@
500 }
501 }
502
503 - // handle the LQ case
504 + // handle the LQ, non-RFC compliant case
505
506 else
507 {
508 @@ -402,7 +402,8 @@
509 while(tmp_link_set)
510 {
511 if(COMP_IP(remote, &tmp_link_set->neighbor_iface_addr) &&
512 - COMP_IP(local, &tmp_link_set->local_iface_addr))
513 + COMP_IP(local, &tmp_link_set->local_iface_addr) &&
514 + COMP_IP(remote_main, &tmp_link_set->neighbor->neighbor_main_addr))
515 return tmp_link_set;
516 tmp_link_set = tmp_link_set->next;
517 }
518 @@ -501,7 +502,12 @@
519
520 /* Copy the main address - make sure this is done every time
521 * as neighbors might change main address */
522 - COPY_IP(&neighbor->neighbor_main_addr, remote_main);
523 + /* Erik Tromp - OOPS! Don't do this! Neighbor entries are hashed through their
524 + * neighbor_main_addr field, and when that field is changed, their position
525 + * in the hash table is no longer correct, so that the function
526 + * olsr_lookup_neighbor_table() can no longer find the neighbor
527 + * entry. */
528 + /*COPY_IP(&neighbor->neighbor_main_addr, remote_main);*/
529
530 neighbor->linkcount++;
531
532 @@ -516,9 +522,14 @@
533 * We'll go for one that is hopefully long
534 * enough in most cases. 10 seconds
535 */
536 - OLSR_PRINTF(1, "Adding MID alias main %s ", olsr_ip_to_string(remote_main))
537 - OLSR_PRINTF(1, "-> %s based on HELLO\n\n", olsr_ip_to_string(remote))
538 - insert_mid_alias(remote_main, remote, MID_ALIAS_HACK_VTIME);
539 + /* Erik Tromp - commented out. It is not RFC-compliant. Also, MID aliases
540 + * that are not explicitly declared by a node will be removed as soon as
541 + * the olsr_prune_aliases(...) function is called.
542 + *
543 + * OLSR_PRINTF(1, "Adding MID alias main %s ", olsr_ip_to_string(remote_main))
544 + * OLSR_PRINTF(1, "-> %s based on HELLO\n\n", olsr_ip_to_string(remote))
545 + * insert_mid_alias(remote_main, remote, MID_ALIAS_HACK_VTIME);
546 + */
547 }
548
549 return link_set;
550 diff -Naur olsrd-0.4.10/src/linux/net.h olsrd-0.4.10-patched/src/linux/net.h
551 --- olsrd-0.4.10/src/linux/net.h 2005-08-28 21:30:30.000000000 +0200
552 +++ olsrd-0.4.10-patched/src/linux/net.h 2006-09-18 01:09:50.000000000 +0200
553 @@ -55,8 +55,7 @@
554 #include <syslog.h>
555 #include <netinet/in.h>
556 #include "../olsr_protocol.h"
557 -
558 -#define MAXIFS 8 /* Maximum number of network interfaces */
559 +#include "../defs.h" /* MAX_IFS */
560
561 /* Redirect proc entry */
562 #define REDIRECT_PROC "/proc/sys/net/ipv4/conf/%s/send_redirects"
563 @@ -77,7 +76,7 @@
564 struct nic_state *next;
565 };
566
567 -struct nic_state nic_states[MAXIFS];
568 +struct nic_state nic_states[MAX_IFS];
569
570
571 extern int
572 diff -Naur olsrd-0.4.10/src/local_hna_set.c olsrd-0.4.10-patched/src/local_hna_set.c
573 --- olsrd-0.4.10/src/local_hna_set.c 2005-02-27 19:39:43.000000000 +0100
574 +++ olsrd-0.4.10-patched/src/local_hna_set.c 2006-09-20 09:55:20.000000000 +0200
575 @@ -129,6 +129,45 @@
576 return 0;
577 }
578
579 +struct hna4_entry *
580 +find_local_hna4_entry(union olsr_ip_addr *net, olsr_u32_t mask)
581 +{
582 + struct hna4_entry *h4 = olsr_cnf->hna4_entries;
583 +
584 + while(h4)
585 + {
586 + if((net->v4 == h4->net.v4) &&
587 + (mask == h4->netmask.v4))
588 + {
589 + return h4;
590 + }
591 + h4 = h4->next;
592 + }
593 +
594 + return NULL;
595 +}
596 +
597 +
598 +
599 +struct hna6_entry *
600 +find_local_hna6_entry(union olsr_ip_addr *net, olsr_u16_t prefix_len)
601 +{
602 + struct hna6_entry *h6 = olsr_cnf->hna6_entries;
603 +
604 + while(h6)
605 + {
606 + if((memcmp(net, &h6->net, ipsize) == 0) &&
607 + (prefix_len == h6->prefix_len))
608 + {
609 + return h6;
610 + }
611 + h6 = h6->next;
612 + }
613 +
614 + return NULL;
615 +}
616 +
617 +
618
619
620 int
621 diff -Naur olsrd-0.4.10/src/local_hna_set.h olsrd-0.4.10-patched/src/local_hna_set.h
622 --- olsrd-0.4.10/src/local_hna_set.h 2005-02-20 19:52:18.000000000 +0100
623 +++ olsrd-0.4.10-patched/src/local_hna_set.h 2006-09-20 09:55:42.000000000 +0200
624 @@ -58,6 +58,12 @@
625 int
626 remove_local_hna6_entry(union olsr_ip_addr *, olsr_u16_t);
627
628 +struct hna4_entry *
629 +find_local_hna4_entry(union olsr_ip_addr *net, olsr_u32_t mask);
630 +
631 +struct hna6_entry *
632 +find_local_hna6_entry(union olsr_ip_addr *net, olsr_u16_t prefix_len);
633 +
634 int
635 check_inet_gw(void);
636
637 diff -Naur olsrd-0.4.10/src/lq_mpr.c olsrd-0.4.10-patched/src/lq_mpr.c
638 --- olsrd-0.4.10/src/lq_mpr.c 2005-11-29 19:37:58.000000000 +0100
639 +++ olsrd-0.4.10-patched/src/lq_mpr.c 2006-11-16 15:18:33.000000000 +0100
640 @@ -51,7 +51,7 @@
641 struct neighbor_list_entry *walker;
642 int i, k;
643 struct neighbor_entry *neigh;
644 - double best;
645 + double best, best_1hop;
646 olsr_bool mpr_changes = OLSR_FALSE;
647 struct link_entry *link;
648
649 @@ -90,6 +90,8 @@
650 neigh2 != &two_hop_neighbortable[i];
651 neigh2 = neigh2->next)
652 {
653 + best_1hop = -1.0;
654 +
655 // check whether this 2-hop neighbour is also a neighbour
656
657 neigh = olsr_lookup_neighbor_table(&neigh2->neighbor_2_addr);
658 @@ -110,14 +112,14 @@
659 if(!link)
660 continue;
661
662 - best = link->loss_link_quality * link->neigh_link_quality;
663 + best_1hop = link->loss_link_quality * link->neigh_link_quality;
664
665 // see wether we find a better route via an MPR
666
667 for (walker = neigh2->neighbor_2_nblist.next;
668 walker != &neigh2->neighbor_2_nblist;
669 walker = walker->next)
670 - if (walker->path_link_quality > best)
671 + if (walker->path_link_quality > best_1hop)
672 break;
673
674 // we've reached the end of the list, so we haven't found
675 @@ -157,7 +159,10 @@
676 best = walker->path_link_quality;
677 }
678
679 - if (neigh != NULL)
680 + // Found a 1-hop neighbor that we haven't previously selected.
681 + // Use it as MPR only when the 2-hop path through it is better than
682 + // any existing 1-hop path.
683 + if ((neigh != NULL) && (best > best_1hop))
684 {
685 neigh->is_mpr = OLSR_TRUE;
686 neigh->skip = OLSR_TRUE;
687 diff -Naur olsrd-0.4.10/src/mid_set.c olsrd-0.4.10-patched/src/mid_set.c
688 --- olsrd-0.4.10/src/mid_set.c 2005-05-29 14:47:45.000000000 +0200
689 +++ olsrd-0.4.10-patched/src/mid_set.c 2006-11-13 14:29:14.000000000 +0100
690 @@ -46,6 +46,7 @@
691 #include "scheduler.h"
692 #include "neighbor_table.h"
693 #include "link_set.h"
694 +#include "packet.h" /* struct mid_alias */
695
696
697 struct mid_entry mid_set[HASHSIZE];
698 @@ -99,6 +100,7 @@
699 struct mid_entry *tmp;
700 struct mid_address *tmp_adr;
701 olsr_u32_t hash, alias_hash;
702 + union olsr_ip_addr *registered_m_addr;
703
704 hash = olsr_hashing(m_addr);
705 alias_hash = olsr_hashing(&alias->alias);
706 @@ -110,8 +112,16 @@
707 {
708 if(COMP_IP(&tmp->main_addr, m_addr))
709 break;
710 + }
711 +
712 + /* Check if alias is already registered with m_addr */
713 + registered_m_addr = mid_lookup_main_addr(&alias->alias);
714 + if (registered_m_addr != NULL && COMP_IP(registered_m_addr, m_addr))
715 + {
716 + /* Alias is already registered with main address. Nothing to do here. */
717 + return;
718 }
719 -
720 +
721 /*If the address was registered*/
722 if(tmp != &mid_set[hash])
723 {
724 @@ -312,7 +322,7 @@
725 /*find match*/
726 if(COMP_IP(&tmp_list->main_addr, adr))
727 {
728 - //printf("Updating timer for node %s\n",ip_to_string(&tmp_list->main_addr));
729 + // printf("MID: Updating timer for node %s\n", olsr_ip_to_string(&tmp_list->main_addr));
730 tmp_list->ass_timer = GET_TIMESTAMP(vtime*1000);
731
732 return 1;
733 @@ -322,6 +332,91 @@
734 }
735
736
737 +/**
738 + *Remove aliases from 'entry' which are not listed in 'declared_aliases'.
739 + *
740 + *@param entry the MID entry
741 + *@param declared_aliases the list of declared aliases for the MID entry
742 + *
743 + *@return nada
744 + */
745 +void
746 +olsr_prune_aliases(union olsr_ip_addr *m_addr, struct mid_alias *declared_aliases)
747 +{
748 + struct mid_entry *entry;
749 + olsr_u32_t hash;
750 + struct mid_address *registered_aliases;
751 + struct mid_address *previous_alias;
752 + struct mid_alias *save_declared_aliases = declared_aliases;
753 +
754 + hash = olsr_hashing(m_addr);
755 +
756 + /* Check for registered entry */
757 + for(entry = mid_set[hash].next;
758 + entry != &mid_set[hash];
759 + entry = entry->next)
760 + {
761 + if(COMP_IP(&entry->main_addr, m_addr))
762 + break;
763 + }
764 + if(entry == &mid_set[hash])
765 + {
766 + /* MID entry not found, nothing to prune here */
767 + return;
768 + }
769 +
770 + registered_aliases = entry->aliases;
771 + previous_alias = NULL;
772 +
773 + while(registered_aliases != 0)
774 + {
775 + struct mid_address *current_alias = registered_aliases;
776 + registered_aliases = registered_aliases->next_alias;
777 +
778 + declared_aliases = save_declared_aliases;
779 +
780 + /* Go through the list of declared aliases to find the matching current alias */
781 + while(declared_aliases != 0 &&
782 + ! COMP_IP(&current_alias->alias, &declared_aliases->alias_addr))
783 + {
784 + declared_aliases = declared_aliases->next;
785 + }
786 +
787 + if (declared_aliases == 0)
788 + {
789 + /* Current alias not found in list of declared aliases: free current alias */
790 + OLSR_PRINTF(1, "MID remove: (%s, ", olsr_ip_to_string(&entry->main_addr))
791 + OLSR_PRINTF(1, "%s)\n", olsr_ip_to_string(&current_alias->alias))
792 +
793 + /* Update linked list as seen by 'entry' */
794 + if (previous_alias != NULL)
795 + {
796 + previous_alias->next_alias = current_alias->next_alias;
797 + }
798 + else
799 + {
800 + entry->aliases = current_alias->next_alias;
801 + }
802 +
803 + /* Remove from hash table */
804 + DEQUEUE_ELEM(current_alias);
805 +
806 + free(current_alias);
807 +
808 + /*
809 + *Recalculate topology
810 + */
811 + changes_neighborhood = OLSR_TRUE;
812 + changes_topology = OLSR_TRUE;
813 + }
814 + else
815 + {
816 + previous_alias = current_alias;
817 + }
818 + }
819 +}
820 +
821 +
822
823 /**
824 *Find timed out entries and delete them
825 diff -Naur olsrd-0.4.10/src/mid_set.h olsrd-0.4.10-patched/src/mid_set.h
826 --- olsrd-0.4.10/src/mid_set.h 2005-05-29 14:47:45.000000000 +0200
827 +++ olsrd-0.4.10-patched/src/mid_set.h 2006-11-08 13:35:44.000000000 +0100
828 @@ -73,6 +73,7 @@
829 extern struct mid_entry mid_set[HASHSIZE];
830 extern struct mid_address reverse_mid_set[HASHSIZE];
831
832 +struct mid_alias;
833
834 int
835 olsr_init_mid_set(void);
836 @@ -95,6 +96,9 @@
837 void
838 olsr_time_out_mid_set(void *);
839
840 +void
841 +olsr_prune_aliases(union olsr_ip_addr *m_addr, struct mid_alias *declared_aliases);
842 +
843 int
844 olsr_update_mid_table(union olsr_ip_addr *, float);
845
846 diff -Naur olsrd-0.4.10/src/olsr.c olsrd-0.4.10-patched/src/olsr.c
847 --- olsrd-0.4.10/src/olsr.c 2005-11-17 05:25:44.000000000 +0100
848 +++ olsrd-0.4.10-patched/src/olsr.c 2006-11-09 14:12:24.000000000 +0100
849 @@ -217,13 +217,17 @@
850
851 if (olsr_cnf->debug_level > 3)
852 {
853 - olsr_print_duplicate_table();
854 + if (olsr_cnf->debug_level > 8)
855 + {
856 + olsr_print_duplicate_table();
857 + }
858 olsr_print_hna_set();
859 }
860 }
861
862 olsr_print_link_set();
863 olsr_print_neighbor_table();
864 + olsr_print_two_hop_neighbor_table();
865 olsr_print_tc_table();
866 }
867
868 diff -Naur olsrd-0.4.10/src/process_package.c olsrd-0.4.10-patched/src/process_package.c
869 --- olsrd-0.4.10/src/process_package.c 2005-11-29 19:38:40.000000000 +0100
870 +++ olsrd-0.4.10-patched/src/process_package.c 2006-11-24 12:19:33.000000000 +0100
871 @@ -52,6 +52,7 @@
872 #include "parser.h"
873 #include "duplicate_set.h"
874 #include "rebuild_packet.h"
875 +#include "local_hna_set.h"
876
877
878 /**
879 @@ -406,6 +407,8 @@
880 tmp_adr = tmp_adr->next;
881 }
882
883 + olsr_prune_aliases(&message.mid_origaddr, message.mid_addr);
884 +
885 forward:
886 olsr_forward_message(m,
887 &message.mid_origaddr,
888 @@ -470,8 +473,13 @@
889
890 while(hna_tmp)
891 {
892 - olsr_update_hna_entry(&message.originator, &hna_tmp->net, &hna_tmp->netmask, (float)message.vtime);
893 -
894 + /* Don't add an HNA entry that we are advertising ourselves. */
895 + if (!find_local_hna4_entry(&hna_tmp->net, hna_tmp->netmask.v4) &&
896 + !find_local_hna6_entry(&hna_tmp->net, hna_tmp->netmask.v6))
897 + {
898 + olsr_update_hna_entry(&message.originator, &hna_tmp->net, &hna_tmp->netmask, (float)message.vtime);
899 + }
900 +
901 hna_tmp = hna_tmp->next;
902 }
903
904 @@ -494,7 +502,7 @@
905
906 /**
907 *Processes an list of neighbors from an incoming HELLO message.
908 - *@param neighbor the neighbor who sendt the message.
909 + *@param neighbor the neighbor who sent the message.
910 *@param message the HELLO message
911 *@return nada
912 */
913 @@ -539,6 +547,31 @@
914 /* Updating the holding time for this neighbor */
915 two_hop_neighbor_yet->neighbor_2_timer = GET_TIMESTAMP(message->vtime*1000);
916 two_hop_neighbor = two_hop_neighbor_yet->neighbor_2;
917 +
918 + // For link quality OLSR, reset the path link quality here.
919 + // The path link quality will be calculated in the second pass, below.
920 + // Keep the saved_path_link_quality for reference.
921 +
922 + if (olsr_cnf->lq_level > 0)
923 + {
924 + // loop through the one-hop neighbors that see this
925 + // 'two_hop_neighbor'
926 +
927 + struct neighbor_list_entry *walker;
928 +
929 + for (walker = two_hop_neighbor->neighbor_2_nblist.next;
930 + walker != &two_hop_neighbor->neighbor_2_nblist;
931 + walker = walker->next)
932 + {
933 + // have we found the one-hop neighbor that sent the
934 + // HELLO message that we're current processing?
935 +
936 + if (walker->neighbor == neighbor)
937 + {
938 + walker->path_link_quality = 0.0;
939 + }
940 + }
941 + }
942 }
943 else
944 {
945 @@ -586,19 +619,48 @@
946 (float)message->vtime);
947 }
948 }
949 + }
950 + }
951
952 - if (olsr_cnf->lq_level > 0)
953 + // Separate, second and third pass for link quality OLSR
954 +
955 + if (olsr_cnf->lq_level > 0)
956 + {
957 + struct link_entry *link =
958 + get_best_link_to_neighbor(&neighbor->neighbor_main_addr);
959 +
960 + if(!link)
961 + return;
962 +
963 + // Second pass for link quality OLSR: calculate the best 2-hop
964 + // path costs to all the 2-hop neighbors indicated in the
965 + // HELLO message. Since the same 2-hop neighbor may be listed
966 + // more than once in the same HELLO message (each at a possibly
967 + // different quality) we want to select only the best one, not just
968 + // the last one listed in the HELLO message.
969 +
970 + for(message_neighbors = message->neighbors;
971 + message_neighbors != NULL;
972 + message_neighbors = message_neighbors->next)
973 + {
974 + if(if_ifwithaddr(&message_neighbors->address) != NULL)
975 + continue;
976 +
977 + if(((message_neighbors->status == SYM_NEIGH) ||
978 + (message_neighbors->status == MPR_NEIGH)))
979 {
980 - struct neighbor_list_entry *walker;
981 - struct link_entry *link;
982 + struct neighbor_list_entry *walker;
983 + struct neighbor_2_entry *two_hop_neighbor;
984 + struct neighbor_2_list_entry *two_hop_neighbor_yet =
985 + olsr_lookup_my_neighbors(neighbor, &message_neighbors->address);
986
987 - link = get_best_link_to_neighbor(&neighbor->neighbor_main_addr);
988 + if(!two_hop_neighbor_yet)
989 + continue;
990
991 - if(!link)
992 - continue;
993 + two_hop_neighbor = two_hop_neighbor_yet->neighbor_2;
994
995 // loop through the one-hop neighbors that see this
996 - // two hop neighbour
997 + // 'two_hop_neighbor'
998
999 for (walker = two_hop_neighbor->neighbor_2_nblist.next;
1000 walker != &two_hop_neighbor->neighbor_2_nblist;
1001 @@ -609,14 +671,7 @@
1002
1003 if (walker->neighbor == neighbor)
1004 {
1005 - double saved_lq, rel_lq;
1006 -
1007 - // saved previous total link quality
1008 -
1009 - saved_lq = walker->saved_path_link_quality;
1010 -
1011 - if (saved_lq == 0.0)
1012 - saved_lq = -1.0;
1013 + double new_second_hop_link_quality, new_path_link_quality;
1014
1015 // path link quality = link quality between us
1016 // and our one-hop neighbor x link quality between
1017 @@ -633,18 +688,75 @@
1018 // the link quality between the 1-hop neighbour and the
1019 // 2-hop neighbour
1020
1021 - walker->second_hop_link_quality =
1022 + new_second_hop_link_quality =
1023 message_neighbors->link_quality *
1024 message_neighbors->neigh_link_quality;
1025
1026 // the total quality for the route
1027 // "us --- 1-hop --- 2-hop"
1028
1029 - walker->path_link_quality =
1030 - walker->second_hop_link_quality *
1031 + new_path_link_quality =
1032 + new_second_hop_link_quality *
1033 link->loss_link_quality * link->neigh_link_quality;
1034
1035 - // if the link quality has changed by more than 10
1036 + // Only copy the link quality if it is better than what we have
1037 + // for this 2-hop neighbor
1038 + if (new_path_link_quality > walker->path_link_quality)
1039 + {
1040 + walker->second_hop_link_quality = new_second_hop_link_quality;
1041 + walker->path_link_quality = new_path_link_quality;
1042 + }
1043 + }
1044 + }
1045 + }
1046 + }
1047 +
1048 + // Third pass for link quality OLSR: check if the 2-hop path qualities have
1049 + // actually changed. If so, signal this through the 'changes_neighborhood'
1050 + // and 'changes_topology' booleans. Keep a 'saved_path_link_quality' for
1051 + // later reference.
1052 + for(message_neighbors = message->neighbors;
1053 + message_neighbors != NULL;
1054 + message_neighbors = message_neighbors->next)
1055 + {
1056 + if(if_ifwithaddr(&message_neighbors->address) != NULL)
1057 + continue;
1058 +
1059 + if(((message_neighbors->status == SYM_NEIGH) ||
1060 + (message_neighbors->status == MPR_NEIGH)))
1061 + {
1062 + struct neighbor_list_entry *walker;
1063 + struct neighbor_2_entry *two_hop_neighbor;
1064 + struct neighbor_2_list_entry *two_hop_neighbor_yet =
1065 + olsr_lookup_my_neighbors(neighbor, &message_neighbors->address);
1066 +
1067 + if(!two_hop_neighbor_yet)
1068 + continue;
1069 +
1070 + two_hop_neighbor = two_hop_neighbor_yet->neighbor_2;
1071 +
1072 + // loop through the one-hop neighbors that see this
1073 + // 'two_hop_neighbor'
1074 +
1075 + for (walker = two_hop_neighbor->neighbor_2_nblist.next;
1076 + walker != &two_hop_neighbor->neighbor_2_nblist;
1077 + walker = walker->next)
1078 + {
1079 + // have we found the one-hop neighbor that sent the
1080 + // HELLO message that we're current processing?
1081 +
1082 + if (walker->neighbor == neighbor)
1083 + {
1084 + double saved_lq, rel_lq;
1085 +
1086 + // saved previous total link quality
1087 +
1088 + saved_lq = walker->saved_path_link_quality;
1089 +
1090 + if (saved_lq == 0.0)
1091 + saved_lq = -1.0;
1092 +
1093 + // if the link cost has changed by more than 10
1094 // percent, signal
1095
1096 rel_lq = walker->path_link_quality / saved_lq;
1097 diff -Naur olsrd-0.4.10/src/routing_table.c olsrd-0.4.10-patched/src/routing_table.c
1098 --- olsrd-0.4.10/src/routing_table.c 2005-11-17 00:55:54.000000000 +0100
1099 +++ olsrd-0.4.10-patched/src/routing_table.c 2006-11-26 12:08:12.004604584 +0100
1100 @@ -65,10 +65,10 @@
1101 olsr_fill_routing_table_with_two_hop_neighbors(void);
1102
1103 static struct rt_entry *
1104 -olsr_check_for_higher_hopcount(struct rt_entry *, struct hna_net *, olsr_u16_t);
1105 +olsr_check_for_higher_quality(struct rt_entry *, struct hna_net *, float);
1106
1107 struct rt_entry *
1108 -olsr_check_for_lower_hopcount(struct rt_entry *, struct hna_net *, olsr_u16_t);
1109 +olsr_check_for_lower_quality(struct rt_entry *, struct hna_net *, float);
1110
1111 static olsr_bool
1112 two_hop_neighbor_reachable(struct neighbor_2_list_entry *);
1113 @@ -212,7 +212,12 @@
1114 new_route_entry->rt_if = iface;
1115
1116 new_route_entry->rt_metric = metric;
1117 - new_route_entry->rt_etx = etx;
1118 + if (etx< 0.0)
1119 + /* non-LQ case */
1120 + new_route_entry->rt_etx = (float)metric;
1121 + else
1122 + /* LQ case */
1123 + new_route_entry->rt_etx = etx;
1124
1125 if(COMP_IP(dst, router))
1126 /* Not GW */
1127 @@ -289,7 +294,7 @@
1128 &link->neighbor_iface_addr,
1129 iface,
1130 1,
1131 - 0);
1132 + -1.0);
1133 }
1134 }
1135
1136 @@ -404,7 +409,7 @@
1137 &link->neighbor_iface_addr,
1138 iface,
1139 2,
1140 - 0);
1141 + -1.0);
1142
1143 if(new_route_entry != NULL)
1144 {
1145 @@ -501,7 +506,7 @@
1146 &list_destination_n->destination->rt_router,
1147 list_destination_n->destination->rt_if,
1148 list_destination_n->destination->rt_metric+1,
1149 - 0);
1150 + -1.0);
1151 if(destination_n_1->destination != NULL)
1152 {
1153 destination_n_1->next=list_destination_n_1;
1154 @@ -549,17 +554,17 @@
1155
1156
1157 /**
1158 - *Check for a entry with a higher hopcount than
1159 + *Check for an entry with a higher quality (lower etx) than
1160 *a given value in a routing table
1161 *
1162 *@param routes the routingtable to look in
1163 *@param net the network entry to look for
1164 - *@param metric the metric to check for
1165 + *@param etx the metric to check for
1166 *
1167 - *@return the localted entry if found. NULL if not
1168 + *@return the located entry if found. NULL if not
1169 */
1170 static struct rt_entry *
1171 -olsr_check_for_higher_hopcount(struct rt_entry *routes, struct hna_net *net, olsr_u16_t metric)
1172 +olsr_check_for_higher_quality(struct rt_entry *routes, struct hna_net *net, float etx)
1173 {
1174 int index;
1175
1176 @@ -574,8 +579,8 @@
1177 if(COMP_IP(&tmp_routes->rt_dst, &net->A_network_addr) &&
1178 (memcmp(&tmp_routes->rt_mask, &net->A_netmask, netmask_size) == 0))
1179 {
1180 - /* Found a entry */
1181 - if(tmp_routes->rt_metric > metric)
1182 + /* Found an entry */
1183 + if(tmp_routes->rt_etx < etx)
1184 return tmp_routes;
1185 else
1186 return NULL;
1187 @@ -589,17 +594,17 @@
1188
1189
1190 /**
1191 - *Check for a entry with a lower or equal hopcount than
1192 + *Check for an entry with a lower or equal quality (higher or equal etx) than
1193 *a given value in a routing table
1194 *
1195 *@param routes the routingtable to look in
1196 *@param net the network entry to look for
1197 - *@param metric the metric to check for
1198 + *@param etx the metric to check for
1199 *
1200 - *@return the localted entry if found. NULL if not
1201 + *@return the located entry if found. NULL if not
1202 */
1203 struct rt_entry *
1204 -olsr_check_for_lower_hopcount(struct rt_entry *routes, struct hna_net *net, olsr_u16_t metric)
1205 +olsr_check_for_lower_quality(struct rt_entry *routes, struct hna_net *net, float etx)
1206 {
1207 int index;
1208
1209 @@ -614,8 +619,8 @@
1210 if(COMP_IP(&tmp_routes->rt_dst, &net->A_network_addr) &&
1211 (memcmp(&tmp_routes->rt_mask, &net->A_netmask, netmask_size) == 0))
1212 {
1213 - /* Found a entry */
1214 - if(tmp_routes->rt_metric <= metric)
1215 + /* Found an entry */
1216 + if(tmp_routes->rt_etx >= etx)
1217 return tmp_routes;
1218 else
1219 return NULL;
1220 @@ -672,13 +677,13 @@
1221 }
1222
1223 /* If there exists a better or equal entry - skip */
1224 - if(olsr_check_for_lower_hopcount(hna_routes, tmp_net, tmp_rt->rt_metric) != NULL)
1225 + if(olsr_check_for_higher_quality(hna_routes, tmp_net, tmp_rt->rt_etx) != NULL)
1226 {
1227 continue;
1228 }
1229
1230 - /* If we find an entry with higher hopcount we just edit it */
1231 - if((new_rt = olsr_check_for_higher_hopcount(hna_routes, tmp_net, tmp_rt->rt_metric)) != NULL)
1232 + /* If we find an entry with lower quality we just edit it */
1233 + if((new_rt = olsr_check_for_lower_quality(hna_routes, tmp_net, tmp_rt->rt_etx)) != NULL)
1234 {
1235 /* Fill struct */
1236 /* Net */
1237 @@ -687,6 +692,7 @@
1238 /* Gateway */
1239 COPY_IP(&new_rt->rt_router, &tmp_rt->rt_router);
1240 /* Metric */
1241 + new_rt->rt_etx = tmp_rt->rt_etx;
1242 new_rt->rt_metric = tmp_rt->rt_metric;
1243 /* Flags */
1244 new_rt->rt_flags = RTF_UP | RTF_GATEWAY;
1245 @@ -707,6 +713,7 @@
1246 /* Gateway */
1247 COPY_IP(&new_rt->rt_router, &tmp_rt->rt_router);
1248 /* Metric */
1249 + new_rt->rt_etx = tmp_rt->rt_etx;
1250 new_rt->rt_metric = tmp_rt->rt_metric;
1251 /* Flags */
1252 new_rt->rt_flags = RTF_UP | RTF_GATEWAY;
1253 diff -Naur olsrd-0.4.10/src/unix/ifnet.c olsrd-0.4.10-patched/src/unix/ifnet.c
1254 --- olsrd-0.4.10/src/unix/ifnet.c 2005-12-29 19:37:16.000000000 +0100
1255 +++ olsrd-0.4.10-patched/src/unix/ifnet.c 2006-11-16 13:14:42.000000000 +0100
1256 @@ -308,9 +308,11 @@
1257 OLSR_PRINTF(1, "IPv4 address changed for %s\n", ifr.ifr_name)
1258 OLSR_PRINTF(1, "\tOld:%s\n", sockaddr_to_string(&ifp->int_addr))
1259 OLSR_PRINTF(1, "\tNew:%s\n", sockaddr_to_string(&ifr.ifr_addr))
1260 +
1261 + ifp->int_addr = ifr.ifr_addr;
1262
1263 if(memcmp(&main_addr,
1264 - &((struct sockaddr_in *)&ifp->int_addr)->sin_addr.s_addr,
1265 + &ifp->ip_addr,
1266 ipsize) == 0)
1267 {
1268 OLSR_PRINTF(1, "New main address: %s\n", sockaddr_to_string(&ifr.ifr_addr))
1269 @@ -320,7 +322,6 @@
1270 ipsize);
1271 }
1272
1273 - ifp->int_addr = ifr.ifr_addr;
1274 memcpy(&ifp->ip_addr,
1275 &((struct sockaddr_in *)&ifp->int_addr)->sin_addr.s_addr,
1276 ipsize);
1277 @@ -845,7 +846,6 @@
1278 ifs.if_index = if_nametoindex(ifr.ifr_name);
1279
1280 /* Set interface metric */
1281 - /* Set interface metric */
1282 if(iface->cnf->weight.fixed)
1283 ifs.int_metric = iface->cnf->weight.value;
1284 else